Skip to main content
‹ Options
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.

FieldTypeDescription
titlestringiOS: the reason shown with Face ID or Touch ID (LAContext.localizedReason). Android: the title of the prompt.
subtitlestringAndroid only: the subtitle.
descriptionstringAndroid only: the description.
cancelstringThe 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.
fallbackstringiOS 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.
confirmationRequiredbooleanAndroid 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.

FieldTypeDescription
keyStorageKeyStorageWhere the item's Keystore key lives: the TEE, StrongBox when there is one, or StrongBox or HARDWARE_UNAVAILABLE. See KeyStorage. Default 'tee'.

See also​