@exodus/auth-mobile

中文文档
6.9.8发布于 2026/11/14MITES Module近 30 天下载 1.1万

Module to simplify dealing with mobile device authentication mechanisms

原始使用文档
文档目录4 节
  1. Install
  2. Usage
  3. API Side
  4. Safe report

@exodus/auth-mobile

This feature provides a platform-independent way to enable and use authentication methods such as pin and biometric authentication in mobile React Native applications.

Install

pnpm add @exodus/auth-mobile

Usage

This feature is designed to be used together with @exodus/headless. See using the sdk.

Direct construction of the Android bioAuth module requires auth, authAtom, and logger. The feature container supplies these dependencies.

API Side

See using the sdk for more details on how features plug into the SDK.

await exodus.auth.setPin('123456') // set 6 number pin
await exodus.auth.isCorrectPin('645123') // false; rejects with `PinUnverifiable` when the stored PIN can no longer be decrypted

await exodus.auth.enableBioAuth() // enables bio authentication such as fingerprint or face id

await exodus.auth.bio.trigger() // start the bio authentication process
await exodus.auth.bio.stop() // abort

If you're building a feature that requires access to authentication details, you can depend on authAtom and observe changes:

authAtom.observe(
  ({ hasBioAuth, biometry, hasPin, pinUnverifiable, hasDeviceAuth, shouldAuthenticate }) => {
    // shouldAuthenticate is true if a PIN, biometric auth, or Device Lock is configured
    // (inidicator for the UI to restrict access to protectworthy resources such as the mnemonic phrase)
    // biometry is available biometry variant
    // pinUnverifiable is true when a PIN is stored but can no longer be decrypted
  }
)

When pinUnverifiable is true, hasPin stays true and hasDeviceAuth is turned on while the OS reports a device credential, so the OS prompt gates the wallet instead of the keypad; toggling biometrics keeps that gate. setPin recreates the entry and clears the state, parking the new PIN under <keyPrefix>pinPending while the old entry is replaced so a PIN entry exists at every step; a parked PIN verifies as the current one, and the next load() finishes an interrupted swap even while the old entry is still undecryptable.

On iOS, auth.bio.authenticate() returns false when the user cancels the Keychain prompt. Other Keychain failures are recorded through errorTracking and reject with DeviceAuthenticationFailed. Known OS error codes appear in the sanitized error message; native messages and unknown codes are omitted. Callers should catch these failures and offer a retry while keeping authentication required.

For Device Lock users, hasDeviceAuth and shouldAuthenticate remain true when the OS cannot authenticate. deviceAuthUnavailable tracks a failed availability check separately; it does not authorize access or turn Device Lock off. Native checks can also return false on transient errors, so unavailability is not proof that the user removed their device passcode. Availability checks time out after five seconds. A rejected or timed-out check preserves the last known availability, and late results are ignored.

auth.refreshDeviceAuth() reloads the complete auth state and updates availability after failed OS prompts. If loading credentials fails, it leaves the auth atom unchanged so an incomplete state cannot bypass authentication. Consumers can also call it when returning to the foreground. While device auth is unavailable, keep authentication gates closed and offer a recovery message asking the user to enable their device passcode or retry. Availability returning to normal still requires successful authentication before granting access.

Safe report

The auth section includes hasDeviceAuth, the app's active Device Lock state, alongside the legacy hasPin and hasBioAuth flags. Device Lock can be active while both legacy flags are false. deviceAuthStatus separately reports whether configured Device Lock is disabled, available, or unavailable; it can be available while hasDeviceAuth is false if legacy biometrics take precedence. An absent hasDeviceAuth value means the state was not reported. pinUnverifiable is true when the stored PIN exists but cannot be decrypted.

版本与发布记录

@exodus/auth-mobile 共发布 37 个版本,首次发布于 2023/07/05;过去 12 个月发布了 12 个版本。

版本发布日期距今
6.9.8latest2026/11/14今天
6.9.72026/11/13今天
6.9.62026/10/071 个月前
6.9.52026/10/061 个月前
6.9.42026/09/231 个月前
6.9.32026/09/161 个月前

关于 @exodus/auth-mobile 的常见问题

@exodus/auth-mobile 是什么?

Module to simplify dealing with mobile device authentication mechanisms

如何安装 @exodus/auth-mobile?

在项目目录运行 npm install @exodus/auth-mobile,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react-native(>=0.71.11 <0.79.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@exodus/auth-mobile 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/exodus__auth-mobile 是否存在。

@exodus/auth-mobile 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@exodus/auth-mobile 可以商用吗?

@exodus/auth-mobile 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@exodus/auth-mobile 的下载量有多少?

根据 npm 官方下载统计,@exodus/auth-mobile 在 2026/10/14 – 2026/11/12 这 30 天内被下载 10,745 次,日均约 358 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@exodus/auth-mobile 还在维护吗?

最新版本 6.9.8 发布于 2026/11/14(今天);至今共发布 37 个版本,其中过去 12 个月发布了 12 个;首次发布于 2023/07/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。