|
| 1 | +<p align="center"> |
| 2 | + <a href="https://clerk.com?utm_source=github&utm_medium=clerk_expo_biometrics" target="_blank" rel="noopener noreferrer"> |
| 3 | + <picture> |
| 4 | + <source media="(prefers-color-scheme: dark)" srcset="https://images.clerk.com/static/logo-dark-mode-400x400.png"> |
| 5 | + <img src="https://images.clerk.com/static/logo-light-mode-400x400.png" height="64"> |
| 6 | + </picture> |
| 7 | + </a> |
| 8 | + <br /> |
| 9 | + <h1 align="center">@clerk/expo-biometrics</h1> |
| 10 | +</p> |
| 11 | + |
| 12 | +<div align="center"> |
| 13 | + |
| 14 | +[](https://clerk.com/discord) |
| 15 | +[](https://clerk.com/docs?utm_source=github&utm_medium=expo_biometrics) |
| 16 | +[](https://x.com/intent/follow?screen_name=clerk) |
| 17 | + |
| 18 | +[Changelog](https://github.com/clerk/javascript/blob/main/packages/expo-biometrics/CHANGELOG.md) |
| 19 | +· |
| 20 | +[Report a Bug](https://github.com/clerk/javascript/issues/new?assignees=&labels=needs-triage&projects=&template=BUG_REPORT.yml) |
| 21 | +· |
| 22 | +[Request a Feature](https://feedback.clerk.com/roadmap) |
| 23 | +· |
| 24 | +[Get help](https://clerk.com/contact/support?utm_source=github&utm_medium=expo_biometrics) |
| 25 | + |
| 26 | +</div> |
| 27 | + |
| 28 | +> [!WARNING] |
| 29 | +> This package is experimental. Pin its version, as breaking changes can happen in minor releases. |
| 30 | +
|
| 31 | +The native building block for Clerk biometric credentials in Expo apps. It creates hardware-backed signing keys, signs challenges behind a Face ID / Touch ID prompt, and stores the on-device records that link each key to a Clerk credential. It does not talk to Clerk's API; `@clerk/expo` builds the sign-in and enrollment flows on top of it. |
| 32 | + |
| 33 | +The key and record layout is shared with the Clerk iOS SDK, so credentials enrolled by either SDK in the same app are visible to both. |
| 34 | + |
| 35 | +### Prerequisites |
| 36 | + |
| 37 | +- Expo SDK 54 or later, in a development build (the module is not available in Expo Go or on the web) |
| 38 | +- iOS. Android support is not implemented yet: every call rejects with `not_implemented`. |
| 39 | +- `NSFaceIDUsageDescription` in your `Info.plist`. The `@clerk/expo` config plugin sets it through its `faceIDPermission` option. |
| 40 | + |
| 41 | +## Installation |
| 42 | + |
| 43 | +```sh |
| 44 | +npx expo install @clerk/expo-biometrics |
| 45 | +``` |
| 46 | + |
| 47 | +Then rebuild your native app. |
| 48 | + |
| 49 | +## API |
| 50 | + |
| 51 | +```ts |
| 52 | +import { |
| 53 | + createKey, |
| 54 | + deleteKey, |
| 55 | + deleteRecord, |
| 56 | + ensureInstallationMarker, |
| 57 | + getAppIdentifier, |
| 58 | + getAvailability, |
| 59 | + hasKey, |
| 60 | + listRecords, |
| 61 | + saveRecord, |
| 62 | + sign, |
| 63 | +} from '@clerk/expo-biometrics'; |
| 64 | +``` |
| 65 | + |
| 66 | +| Function | Description | |
| 67 | +| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | |
| 68 | +| `getAppIdentifier()` | The app identifier sent to Clerk as `app_identifier` (the iOS bundle identifier). | |
| 69 | +| `getAvailability()` | The device's biometry type and whether biometrics or device owner authentication can be evaluated. | |
| 70 | +| `createKey(policy)` | Creates a Secure Enclave P-256 key and returns its `localKeyId` and public key JWK. | |
| 71 | +| `sign(localKeyId, clientData, reason?)` | Prompts for authentication and returns an ES256 signature over `clientData` (raw `r \|\| s`, base64url without padding). | |
| 72 | +| `hasKey(localKeyId)` / `deleteKey(localKeyId)` | Checks for or deletes a key. | |
| 73 | +| `listRecords()` | Every stored credential record, for every app identifier. | |
| 74 | +| `saveRecord(record, options)` | Saves a record. With `removeOtherRecordsForApp: true`, deletes the app's other records and their keys. | |
| 75 | +| `deleteRecord(localKeyId)` | Deletes a key, then the records that reference it. | |
| 76 | +| `ensureInstallationMarker()` | Deletes records and keys left behind by a previous installation of the app. The store functions call it for you. | |
| 77 | + |
| 78 | +Every error is a `ClerkBiometricsError` with a stable `code`, such as `user_canceled`, `biometry_not_enrolled`, `biometry_lockout`, `key_not_found`, or `storage_failed`. |
| 79 | + |
| 80 | +## License |
| 81 | + |
| 82 | +This project is licensed under the **MIT license**. |
| 83 | + |
| 84 | +See [LICENSE](https://github.com/clerk/javascript/blob/main/packages/expo-biometrics/LICENSE) for more information. |
0 commit comments