expo-crypto-dpop by boostbrothers/agent-skills
npx skills add https://github.com/boostbrothers/agent-skills --skill expo-crypto-dpop基于 RFC 9449 标准的 DPoP 认证模块。安全地生成和存储 EC P-256 密钥对,并为 OAuth 2.0 访问令牌生成密码学绑定的 DPoP 证明 JWT。
在以下情况下引用此技能:
解决 Bearer 令牌安全漏洞的 RFC 9449 扩展机制:
在应用启动时调用以确保密钥对。应用重装时自动删除旧密钥并生成新密钥。
import { ensureKeyPair } from 'expo-crypto-dpop';
// 应用初始化时
await ensureKeyPair();
每次 API 请求时调用以生成 DPoP 证明 JWT。
import { createProof } from 'expo-crypto-dpop';
const proof = await createProof({
htm: 'POST', // HTTP 方法
htu: 'https://api.example.com/token', // HTTP URI (不含查询参数!)
accessToken: 'eyJ...', // 可选: 绑定访问令牌 (ath 声明)
nonce: 'server-nonce', // 可选: 服务器提供的 nonce
});
RFC 9449 표준 기반 DPoP(Demonstrating Proof-of-Possession) 인증 모듈. EC P-256 키 쌍을 안전하게 생성·보관하고, OAuth 2.0 액세스 토큰에 암호학적으로 바인딩된 DPoP 증명 JWT를 생성합니다.
Reference this skill when:
Bearer 토큰의 보안 취약점을 해결하는 RFC 9449 확장 메커니즘:
앱 시작 시 호출하여 키 쌍을 확보. 앱 재설치 시 구 키 삭제 후 새 키 자동 생성.
import { ensureKeyPair } from 'expo-crypto-dpop';
// 앱 초기화 시
await ensureKeyPair();
매 API 요청마다 호출하여 DPoP 증명 JWT를 생성.
import { createProof } from 'expo-crypto-dpop';
const proof = await createProof({
htm: 'POST', // HTTP 메서드
htu: 'https://api.example.com/token', // HTTP URI (쿼리 파라미터 제외!)
accessToken: 'eyJ...', // 선택: 액세스 토큰 바인딩 (ath 클레임)
nonce: 'server-nonce', // 선택: 서버 제공 nonce
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
⚠️ 重要 : 根据 RFC 9449,htu 不应包含查询参数和片段。仅使用 URL 对象的 origin + pathname。
注销时删除 DPoP 密钥 (可选,取决于安全策略)。
import { deleteKeyPair } from 'expo-crypto-dpop';
await deleteKeyPair();
Header:
{
"typ": "dpop+jwt",
"alg": "ES256",
"jwk": { "kty": "EC", "crv": "P-256", "x": "...", "y": "..." }
}
Payload:
{
"jti": "unique-id",
"htm": "POST",
"htu": "https://api.example.com/token",
"iat": 1234567890,
"ath": "base64url(sha256(access_token))",
"nonce": "server-provided-nonce"
}
应用 → expo-crypto-dpop → expo-secure-store →
├── iOS: Security.framework (Keychain)
└── Android: KeyStore
→ OAuth 服务器
主要功能:
KEY_GENERATION_FAILED : 无法访问原生加密库。检查 expo-secure-store 设置。
KEY_NOT_FOUND : 密钥对不存在。确认是否已先调用 ensureKeyPair()。
SIGNING_FAILED : JWT 签名失败。检查密钥对的完整性。重装后发生此问题,请使用 ensureKeyPair() 重新生成密钥。
INVALID_INPUT : 检查 htm、htu 参数。确认 htu 不包含查询参数。
应用重装后认证失败 : iOS Keychain 可能在应用删除后仍保留数据。ensureKeyPair() 会自动处理此问题,但服务器端也需要支持密钥更新。
阅读集成模式文件以了解 Axios 拦截器设置:
rules/integration-patterns.md — Axios 拦截器、Nonce 处理、令牌刷新流程
获取包含所有扩展规则的完整指南:AGENTS.md
每周安装数
1
仓库
首次出现
今天
安全审计
安装于
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
⚠️ CRITICAL : htu는 RFC 9449에 따라 쿼리 파라미터와 프래그먼트를 포함하지 않아야 합니다. URL 객체의 origin + pathname만 사용하세요.
로그아웃 시 DPoP 키 삭제 (선택사항, 보안 정책에 따라 결정).
import { deleteKeyPair } from 'expo-crypto-dpop';
await deleteKeyPair();
Header:
{
"typ": "dpop+jwt",
"alg": "ES256",
"jwk": { "kty": "EC", "crv": "P-256", "x": "...", "y": "..." }
}
Payload:
{
"jti": "unique-id",
"htm": "POST",
"htu": "https://api.example.com/token",
"iat": 1234567890,
"ath": "base64url(sha256(access_token))",
"nonce": "server-provided-nonce"
}
앱 → expo-crypto-dpop → expo-secure-store →
├── iOS: Security.framework (Keychain)
└── Android: KeyStore
→ OAuth 서버
주요 기능:
KEY_GENERATION_FAILED : 네이티브 암호화 라이브러리 접근 실패. expo-secure-store 설정 확인.
KEY_NOT_FOUND : 키 쌍이 존재하지 않음. ensureKeyPair()를 먼저 호출했는지 확인.
SIGNING_FAILED : JWT 서명 실패. 키 쌍 무결성 확인. 재설치 후 발생 시 ensureKeyPair()로 키 재생성.
INVALID_INPUT : htm, htu 파라미터 확인. htu에 쿼리 파라미터가 포함되지 않았는지 확인.
앱 재설치 후 인증 실패 : iOS Keychain은 앱 삭제 후에도 데이터가 남을 수 있음. ensureKeyPair()가 이를 자동 처리하지만, 서버 측에서도 키 갱신을 지원해야 함.
Read the integration patterns file for Axios interceptor setup:
rules/integration-patterns.md — Axios 인터셉터, Nonce 처리, 토큰 갱신 흐름
For the complete guide with all rules expanded: AGENTS.md
Weekly Installs
1
Repository
First Seen
Today
Security Audits
Installed on
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
Better Auth 最佳实践指南:集成、配置与安全设置完整教程
30,700 周安装