Skip to content

React Native SDK doesn't support custom-jwt authentication type #2220

@hkoichi

Description

@hkoichi

React Native SDK doesn't support custom-jwt authentication type

Environment

  • Package: @account-kit/react-native-signer version 4.66.2
  • Platform: React Native
  • Comparison: Web SDK (@account-kit/react) v4.65.0+ supports custom-jwt authentication

Description

The React Native SDK has a complete implementation of JWT authentication via the submitJwt method, but the authentication flow fails at runtime because "custom-jwt" is not included in the validAuthenticatingTypes array.

Current Behavior

When attempting to authenticate with a custom JWT using the following code:

await authenticateAsync({
  type: "custom-jwt",
  jwt: idToken,
});

The authentication fails with the error:

Error: Unsupported authenticating type

Root Cause

In node_modules/@account-kit/react-native-signer/src/client.ts at line 72-76:

private validAuthenticatingTypes: AuthenticatingEventMetadata["type"][] = [
  "email",
  "otp",
  "oauth",
];

The completeAuthWithBundle method (line 189-191) validates the authentication type:

if (!this.validAuthenticatingTypes.includes(params.authenticatingType)) {
  throw new Error("Unsupported authenticating type");
}

However, the submitJwt method (lines 167-179) is fully implemented and uses "custom-jwt":

override async submitJwt(
  args: Omit<JwtParams, "targetPublicKey">,
): Promise<JwtResponse> {
  this.eventEmitter.emit("authenticating", { type: "custom-jwt" });

  const publicKey = await this.stamper.init();
  return this.request("/v1/auth-jwt", {
    jwt: args.jwt,
    targetPublicKey: publicKey,
    authProvider: args.authProvider,
    expirationSeconds: args.expirationSeconds,
  });
}

Expected Behavior

The "custom-jwt" authentication type should be supported in React Native, just as it is in the Web SDK.

Proposed Fix

Add "custom-jwt" to the validAuthenticatingTypes array:

private validAuthenticatingTypes: AuthenticatingEventMetadata["type"][] = [
  "email",
  "otp",
  "oauth",
  "custom-jwt",  // Add this
];

Use Case

We are implementing a unified authentication flow where users:

  1. Authenticate with our OAuth provider (OIDC-compliant)
  2. Receive an ID token with a nonce generated from the Account Kit targetPublicKey
  3. Use that ID token to authenticate with Account Kit via custom JWT

This pattern is documented in the Alchemy docs:
https://www.alchemy.com/docs/wallets/authentication/login-methods/bring-your-own-auth

The Web SDK supports this flow perfectly, but React Native requires a workaround using type assertions to bypass the validation check.

Current Workaround

await authenticateAsync({
  type: "custom-jwt" as unknown as "email",
  jwt,
} as any);

This bypasses TypeScript type checking and the runtime validation, but it's not ideal and requires disabling linter rules.

Additional Context

All the infrastructure for custom JWT authentication already exists in the React Native SDK:

  • submitJwt method is implemented
  • ✅ Backend API endpoint /v1/auth-jwt is called
  • ✅ Event emission works correctly
  • ❌ Only the validation array is missing "custom-jwt"

This appears to be an oversight rather than an intentional limitation.

Impact

This prevents React Native developers from using the "Bring Your Own Auth" feature that is available in the Web SDK, limiting authentication options for mobile applications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions