Feature request: expose DPoP public key, signing, and encrypt/decrypt APIs

Open
#1,458 8 comments 3 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
react-native, typescript

Research direction

Start by reviewing the existing native DPoP key handling in Auth0.swift and Auth0.Android, then trace how those implementations are bridged into react-native-auth0. Define the public-key, signing, encryption, and decryption APIs without exporting key material, including the listed failure cases. Done means both platforms expose consistent APIs and secure key-storage behavior.

Written by the indexing model from the issue text.

Description

feature request
Checklist
  • I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.
Describe the problem you'd like to have solved

With useDPoP: true, react-native-auth0 already uses a native DPoP keypair, but the library does not expose APIs to reuse that keypair for additional application-level cryptographic operations.

For our backend flow, DPoP validation is already in place and already gives the expected guarantees:

  • request binding and replay protections via claims such as htu, htm, jti, ath
  • nonce handling when required by the resource server
  • token/key binding via cnf thumbprint (the access token is tied to that DPoP key)

After this standard DPoP validation, we also need to validate additional request data (for example, request body integrity) using the same cryptographic identity represented by the DPoP keypair.

Today this is not possible with official APIs, so apps cannot reliably reuse the native Auth0-managed keypair for those additional checks.

Describe the ideal solution

Expose native cryptographic APIs that reuse the same DPoP identity managed by Auth0 native SDKs:

  • getDPoPPublicKey()
  • signWithDPoPPrivateKey(payload: string | Uint8Array)
  • encrypt(payload: string | Uint8Array, recipientJwk?: Record<string, unknown>)
  • decrypt(ciphertext: string | Uint8Array)

Security expectation:

  • private keys and key material must never be exported to JavaScript
  • only native cryptographic operations should be exposed
  • key usage must remain restricted to secure platform storage (iOS Keychain/Secure Enclave and Android Keystore)

Expected server-side validation order in the signature flow:

  1. validate Authorization token
  2. validate DPoP proof
  3. extract jwk from validated DPoP
  4. validate x-body-signature against request body with that jwk
Alternatives and current workarounds

Current workaround is patching node_modules to add custom native bridge methods on iOS and Android.

This is fragile and expensive to maintain over upgrades, and it can diverge from official Auth0 DPoP behavior over time.

Alternative of creating a second keypair outside Auth0 is also undesirable because it breaks the single cryptographic identity model already established by DPoP + cnf.

Additional context

Example API usage (body signature + DPoP):

import Auth0 from 'react-native-auth0';

const auth0 = new Auth0({
  domain: 'YOUR_DOMAIN',
  clientId: 'YOUR_CLIENT_ID',
  useDPoP: true,
});

const method = 'POST';
const path = '/method-with-signed-payload';
const body = JSON.stringify({ data: 'information-to-be-signed' });

const dpopHeaders = /* regular getDPoPHeaders() creation */;
const bodySignature = await auth0.signWithDPoPPrivateKey(body);

await fetch(`https://api.example.com${path}`, {
  method,
  headers: {
    'content-type': 'application/json',
    'x-body-signature': bodySignature,
    ...dpopHeaders,
  },
  body,
});

Example API usage (encrypt/decrypt):

const statePlaintext = JSON.stringify({ data: 'sensitive-client-state' });

// Option A: encrypt to self
const encryptedState = await auth0.encrypt(statePlaintext);

// Option B: encrypt to an explicit recipient JWK
// const recipientJwk = { kty: 'EC', crv: 'P-256', x: '...', y: '...' };
// const encryptedState = await auth0.encrypt(statePlaintext, recipientJwk);

await fetch('https://api.example.com/state', {
  method: 'PUT',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ state: encryptedState }),
});

const response = await fetch('https://api.example.com/state', { method: 'GET' });
const { state } = await response.json();
const decryptedState = await auth0.decrypt(state);

The server stores encrypted state but cannot read plaintext content in this model.

Platform expectations:

  • iOS: use the same key material managed by Auth0.swift DPoP internals.
  • Android: use the same key material managed by Auth0.Android DPoP internals.
  • If keypair does not exist yet, return a clear, typed error (or document bootstrap requirement clearly).
  • For encrypt/decrypt APIs, use secure device-bound keys managed in native keystore/keychain.

Error handling suggestion:

  • keypair not found
  • keychain/keystore access failure
  • signing failure
  • invalid payload input
  • encryption/decryption failure
Dominant language
TypeScript
Stars
553
Forks
244
Avg merge
19h
Merged PRs (30d)
39

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from auth0/react-native-auth0

All issues in auth0/react-native-auth0

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.