@telegram-apps/sdk
Version:
TypeScript Source Development Kit for Telegram Mini Apps client application.
122 lines (121 loc) • 5.68 kB
TypeScript
import { BiometryTokenUpdateStatus, BiometryAuthRequestStatus } from '@telegram-apps/bridge';
import { AbortablePromise } from 'better-promises';
import { AuthenticateOptions, RequestAccessOptions, UpdateTokenOptions } from './types.js';
/**
* @returns True if the biometry manager is supported.
*/
export declare const isSupported: import('@telegram-apps/signals').Computed<boolean>;
/**
* Mounts the Biometry component.
* @since Mini Apps v7.2
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (mount.isAvailable()) {
* await mount();
* }
*/
export declare const mount: import('../../wrappers/wrapSafe.js').SafeWrapped<(abortSignal: any) => AbortablePromise<void>, true, never>;
export declare const mountPromise: import('@telegram-apps/signals').Computed<AbortablePromise<any> | undefined>, isMounting: import('@telegram-apps/signals').Computed<boolean>;
export declare const mountError: import('@telegram-apps/signals').Computed<Error | undefined>;
export declare const _isMounted: import('@telegram-apps/signals').Signal<boolean>, isMounted: import('@telegram-apps/signals').Computed<boolean>;
/**
* Attempts to authenticate a user using biometrics and fetch a previously stored secure token.
* @param options - method options.
* @since Mini Apps v7.2
* @returns Token from the local secure storage saved previously or undefined.
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @throws {FunctionNotAvailableError} The parent component is not mounted
* @throws {ConcurrentCallError} Biometry authentication is already in progress
* @throws {NotAvailableError} Biometry is not available
* @example
* if (authenticate.isAvailable()) {
* const { status, token } = await authenticate({
* reason: 'Authenticate to open wallet',
* });
* }
*/
export declare const authenticate: import('../../wrappers/wrapSafe.js').SafeWrapped<(options?: AuthenticateOptions) => AbortablePromise<{
/**
* Authentication status.
*/
status: BiometryAuthRequestStatus;
/**
* Token from the local secure storage saved previously.
*/
token?: string;
}>, true, never>;
export declare const authPromise: import('@telegram-apps/signals').Computed<AbortablePromise<{
/**
* Authentication status.
*/
status: BiometryAuthRequestStatus;
/**
* Token from the local secure storage saved previously.
*/
token?: string;
}> | undefined>, isAuthenticating: import('@telegram-apps/signals').Computed<boolean>;
export declare const authError: import('@telegram-apps/signals').Computed<Error | undefined>;
/**
* Opens the biometric access settings for bots. Useful when you need to request biometrics
* access to users who haven't granted it yet.
*
* _Note that this method can be called only in response to user interaction with the Mini App
* interface (e.g. a click inside the Mini App or on the main button)_.
* @since Mini Apps v7.2
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (openSettings.isAvailable()) {
* openSettings();
* }
*/
export declare const openSettings: import('../../wrappers/wrapSafe.js').SafeWrapped<() => void, true, never>;
/**
* Requests permission to use biometrics.
* @since Mini Apps v7.2
* @returns Promise with true, if access was granted.
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @throws {FunctionNotAvailableError} The parent component is not mounted
* @throws {ConcurrentCallError} Biometry access request is already in progress
* @throws {NotAvailableError} Biometry is not available
* @example
* if (requestAccess.isAvailable()) {
* const accessGranted = await requestAccess({
* reason: 'Authenticate to open wallet',
* });
* }
*/
export declare const requestAccess: import('../../wrappers/wrapSafe.js').SafeWrapped<(options?: RequestAccessOptions) => AbortablePromise<boolean>, true, never>;
export declare const requestAccessPromise: import('@telegram-apps/signals').Computed<AbortablePromise<boolean> | undefined>, isRequestingAccess: import('@telegram-apps/signals').Computed<boolean>;
export declare const requestAccessError: import('@telegram-apps/signals').Computed<Error | undefined>;
/**
* Unmounts the component.
*/
export declare function unmount(): void;
/**
* Updates the biometric token in a secure storage on the device.
* @since Mini Apps v7.2
* @returns Promise with `true`, if token was updated.
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @throws {FunctionNotAvailableError} The parent component is not mounted
* @example Setting a new token
* if (updateToken.isAvailable()) {
* updateToken({
* token: 'abcdef',
* })
* }
* @example Deleting the token
* if (updateToken.isAvailable()) {
* updateToken();
* }
*/
export declare const updateToken: import('../../wrappers/wrapSafe.js').SafeWrapped<(options?: UpdateTokenOptions) => AbortablePromise<BiometryTokenUpdateStatus>, true, never>;