Types
Types of options
The texts of the system prompt, and the options for Android only.
Import
import { type Prompt, type AndroidOptions } from '@apexnative/keychain';
Prompt
type Prompt = {
title?: string;
subtitle?: string;
description?: string;
cancel?: string;
fallback?: string;
confirmationRequired?: boolean;
};
The texts of the system prompt that a read of a protected item shows: the prompt of createKeychain and of a read's GetOptions. A read's prompt is merged over the storage's field by field. A field a platform doesn't have is ignored there, so one prompt works for both; a field that isn't given leaves the system's text.
| Field | Type | Description |
|---|---|---|
| title | string | iOS: the reason shown with Face ID or Touch ID (LAContext.localizedReason). Android: the title of the prompt. |
| subtitle | string | Android only: the subtitle. |
| description | string | Android only: the description. |
| cancel | string | The cancel button. iOS: localizedCancelTitle. Android: the negative button, shown only for a value without the passcode; with the passcode the system shows its own button to enter it. |
| fallback | string | iOS only: the fallback button after a failed scan (localizedFallbackTitle); '' hides it. For an item of biometrics alone (biometryAny, biometryCurrentSet), a tap ends the read with USER_FALLBACK; for the others, the fallback is the passcode. |
| confirmationRequired | boolean | Android only: whether a face match needs a tap to confirm. Default true. |
const vault = createKeychain({
accessControl: AccessControl.BiometryCurrentSet,
prompt: { title: 'Unlock your account', cancel: 'Use password', fallback: 'Use password' },
});
await vault.getItem('refreshToken', { prompt: { title: 'Confirm the payment' } }); // cancel stays
AndroidOptions
type AndroidOptions = {
keyStorage?: KeyStorage;
};
The options for Android only: the android option of createKeychain and of a write's SetOptions. iOS ignores them.
| Field | Type | Description |
|---|---|---|
| keyStorage | KeyStorage | Where the item's Keystore key lives: the TEE, StrongBox when there is one, or StrongBox or HARDWARE_UNAVAILABLE. See KeyStorage. Default 'tee'. |