React Native library for DPoP proof generation and key management.
- Generate DPoP proofs (
dpop+jwt) signed with ES256. - Manage key pairs in the device keystore (create, rotate, delete).
- Export public key in
JWK,DER, orRAWformat. - Calculate JWK thumbprint (
SHA-256, base64url). - Verify if a proof is bound to a given key alias.
- Retrieve non-sensitive key metadata (hardware-backed, StrongBox info, etc.).
- iOS key storage uses Secure Enclave when available, with Keychain fallback.
- Android: supported.
- iOS: supported.
npm install react-native-dpopFor iOS, install pods in your app project:
cd ios && pod installimport { DPoP } from 'react-native-dpop';
const dpop = await DPoP.generateProof({
htu: 'https://api.example.com/token',
htm: 'POST',
accessToken: 'ACCESS_TOKEN',
nonce: 'server-nonce',
});
const proof = dpop.proof;
const thumbprint = await dpop.calculateThumbprint();
const publicJwk = await dpop.getPublicKey('JWK');
const isBound = await dpop.isBoundToAlias();GenerateProofInputDPoPProofContextDPoPKeyInfoSecureHardwareFallbackReason = 'UNAVAILABLE' | 'PROVIDER_ERROR' | 'POLICY_REJECTED' | 'UNKNOWN'PublicJwkPublicKeyFormat = 'JWK' | 'DER' | 'RAW'
DPoP.generateProof(input): Promise<DPoP>DPoP.assertHardwareBacked(alias?): Promise<void>DPoP.deleteKeyPair(alias?): Promise<void>DPoP.getKeyInfo(alias?): Promise<DPoPKeyInfo>DPoP.hasKeyPair(alias?): Promise<boolean>DPoP.rotateKeyPair(alias?): Promise<void>
proof: stringproofContext: DPoPProofContextalias?: string
calculateThumbprint(): Promise<string>getPublicKey(format): Promise<PublicJwk | string>signWithDpopPrivateKey(payload): Promise<string>isBoundToAlias(alias?): Promise<boolean>
Native errors are rejected with codes such as:
ERR_DPOP_GENERATE_PROOFERR_DPOP_CALCULATE_THUMBPRINTERR_DPOP_PUBLIC_KEYERR_DPOP_SIGN_WITH_PRIVATE_KEYERR_DPOP_HAS_KEY_PAIRERR_DPOP_GET_KEY_INFOERR_DPOP_ROTATE_KEY_PAIRERR_DPOP_DELETE_KEY_PAIRERR_DPOP_ASSERT_HARDWARE_BACKEDERR_DPOP_IS_BOUND_TO_ALIAS
- If no alias is provided, the default alias is
react-native-dpop. getKeyInforeturns cross-platform fields and platform-specific details inhardware:- Android:
hardware.android.strongBoxAvailable,hardware.android.strongBoxBacked,hardware.android.securityLevel,hardware.android.strongBoxFallbackReason - iOS:
hardware.ios.secureEnclaveAvailable,hardware.ios.secureEnclaveBacked,hardware.ios.securityLevel,hardware.ios.secureEnclaveFallbackReason
- Android:
- Fallback reasons are sanitized enums (no raw native error):
UNAVAILABLE,PROVIDER_ERROR,POLICY_REJECTED,UNKNOWN. securityLevelsemantics:null: no key material available (or not reported)1: not backed by secure enclave/strong dedicated hardware2: hardware-backed (iOS Secure Enclave, Android typically TEE)3: Android-only StrongBox (when reported by the device)
- On iOS,
securityLevelis normalized by this library (2for Secure Enclave-backed keys,1for Keychain fallback), not a native Apple numeric level API. htmis normalized to uppercase in proof generation.athis derived fromaccessToken(SHA-256, base64url) when provided.jtiandiatare auto-generated when omitted.
MIT