Error with createCredential in React Native Passkey on Android 14

147 Views Asked by At

I'm integrating the f-23/react-native-passkey (link) library into a React Native app for passkey functionality. It works on iOS 17.2, but on Android 14 (Pixel 7 API 34, Model: sdk_gphone64_arm64), I encounter an error during the registration process with the following message:

{
  "error": "Native error",
  "message": "androidx.credentials.exception.CreateCredentialCustomException:"
}

Here's the passkey request that triggers this error:

import { Passkey } from "react-native-passkey";

const publicKeyCredentialCreationOptions = {
  "attestation": null,
  "authenticatorSelection": {
    "requireResidentKey": false,
    "residentKey": "discouraged",
    "userVerification": "preferred"
  },
  "challenge": "kpPEPXgP7D1wjV6MlRBPSUz+nCtJisjOD+vywQMJkL8=",
  "excludeCredentials": [],
  "extensions": {
    "credProps": true
  },
  "pubKeyCredParams": [
    {
      "alg": -7,
      "type": "public-key"
    },
    {
      "alg": -257,
      "type": "public-key"
    }
  ],
  "rp": {
    "id": "localhost",
    "name": "Rewire"
  },
  "timeout": 1800000,
  "user": {
    "displayName": "Passkey Test",
    "id": "2HzoHm_hY0CjuEESY9tY6-3SdjmNHOoNqaPDcZGzsr0",
    "name": "Passkey Test"
  }
};

await Passkey.register(publicKeyCredentialCreationOptions);

I double-checked everything in the Digital Asset Links on Android:

  GET https://<mydomain>/.well-known/assetlinks.json
[
  {
    "relation": [
      "delegate_permission/common.handle_all_urls",
      "delegate_permission/common.get_login_creds"
    ],
    "target": {
      "namespace": "android_app",
      "package_name": "com.rewire.app",
      "sha256_cert_fingerprints": [
        SHA_HEX_VALUE // this was replaced with the real SHA_HEX_VALUE
      ]
    }
  }
]

The error came from line 34 (link):

val result = currentActivity?.let { credentialManager.createCredential(it, createPublicKeyCredentialRequest) }

Debugging in Android Studio indicates an issue related to Google Password Manager, but without specific details. Here is the relevant debugger output:

Debugger Output

I've double-checked all configurations and can't pinpoint the issue. Any insights into what might be causing this error, or suggestions for further debugging steps would be greatly appreciated.

0

There are 0 best solutions below