expo-passkey
Version:
Passkey authentication for Expo apps with Better Auth integration
173 lines • 7.75 kB
TypeScript
/**
* @file Web-only implementation of the Expo Passkey client
* @module expo-passkey/client/core.web
*/
import type { BetterFetchOption, BetterFetchPlugin, ErrorContext } from "@better-fetch/fetch";
import type { AuthenticatePasskeyResult, ChallengeResult, ExpoPasskeyClientOptions, ExpoPasskeyServerPlugin, ListPasskeysResult, PasskeyMetadata, PasskeyRegistrationCheckResult, RegisterPasskeyResult, RevokePasskeyResult } from "../types";
/**
* Creates web-only Expo Passkey client plugin
*/
export declare const expoPasskeyClient: (options?: ExpoPasskeyClientOptions) => {
id: "expo-passkey";
$InferServerPlugin: ExpoPasskeyServerPlugin;
pathMethods: {
"/expo-passkey/challenge": "POST";
"/expo-passkey/register": "POST";
"/expo-passkey/authenticate": "POST";
"/expo-passkey/list/:userId": "GET";
"/expo-passkey/revoke": "POST";
};
getActions: ($fetch: import("@better-fetch/fetch").BetterFetch) => {
getChallenge: (data: {
userId?: string;
type: "registration" | "authentication";
registrationOptions?: {
attestation?: "none" | "indirect" | "direct" | "enterprise";
authenticatorSelection?: {
authenticatorAttachment?: "platform" | "cross-platform";
residentKey?: "required" | "preferred" | "discouraged";
requireResidentKey?: boolean;
userVerification?: "required" | "preferred" | "discouraged";
};
timeout?: number;
};
}, fetchOptions?: BetterFetchOption) => Promise<ChallengeResult>;
/**
* Web-only passkey registration
*/
registerPasskey: (data: {
userId: string;
userName: string;
displayName?: string;
rpName?: string;
rpId?: string;
attestation?: "none" | "indirect" | "direct" | "enterprise";
authenticatorSelection?: {
authenticatorAttachment?: "platform" | "cross-platform";
residentKey?: "required" | "preferred" | "discouraged";
requireResidentKey?: boolean;
userVerification?: "required" | "preferred" | "discouraged";
};
timeout?: number;
metadata?: Partial<PasskeyMetadata>;
}, fetchOptions?: BetterFetchOption) => Promise<RegisterPasskeyResult>;
/**
* Web-only passkey authentication
*/
authenticateWithPasskey: (data?: {
userId?: string;
rpId?: string;
timeout?: number;
userVerification?: "required" | "preferred" | "discouraged";
metadata?: Partial<PasskeyMetadata>;
}, fetchOptions?: BetterFetchOption) => Promise<AuthenticatePasskeyResult>;
/**
* List passkeys for a user
*/
listPasskeys: (data: {
userId: string;
limit?: number;
offset?: number;
}, fetchOptions?: BetterFetchOption) => Promise<ListPasskeysResult>;
/**
* Revoke a passkey
*/
revokePasskey: (data: {
credentialId: string;
reason?: string;
}, fetchOptions?: BetterFetchOption) => Promise<RevokePasskeyResult>;
/**
* Check passkey registration for user
*/
checkPasskeyRegistration: (userId: string, fetchOptions?: BetterFetchOption) => Promise<PasskeyRegistrationCheckResult>;
isPasskeySupported: () => Promise<boolean>;
getBiometricInfo: () => Promise<null>;
getDeviceInfo: () => Promise<{
deviceId: string;
platform: "web";
model: string;
manufacturer: null;
osVersion: string;
appVersion: string;
biometricSupport: {
isSupported: boolean;
isEnrolled: boolean;
availableTypes: never[];
authenticationType: string;
error: null;
platformDetails: {
platform: string;
version: string;
};
};
}>;
getStorageKeys: () => null;
hasPasskeysRegistered: () => Promise<boolean>;
hasUserPasskeysRegistered: (_userId: string) => Promise<boolean>;
removeLocalCredential: (_credentialId: string) => Promise<void>;
isPlatformAuthenticatorAvailable: () => Promise<boolean>;
};
fetchPlugins: {
id: string;
name: string;
description: string;
version: string;
hooks: {
onError: (context: ErrorContext) => Promise<void>;
};
init: (url: string, options?: BetterFetchOption) => Promise<{
url: string;
options: {
headers: Record<string, string>;
cache?: RequestCache;
credentials?: RequestCredentials;
integrity?: string;
keepalive?: boolean;
method?: string;
mode?: RequestMode;
priority?: RequestPriority;
redirect?: RequestRedirect;
referrer?: string;
referrerPolicy?: ReferrerPolicy;
signal?: AbortSignal | null;
window?: null;
onRequest?: <T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>) => Promise<import("@better-fetch/fetch").RequestContext | void> | import("@better-fetch/fetch").RequestContext | void;
onResponse?: (context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void;
onSuccess?: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
onError?: (context: ErrorContext) => Promise<void> | void;
onRetry?: (response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void;
hookOptions?: {
cloneResponse?: boolean;
};
timeout?: number;
customFetchImpl?: import("@better-fetch/fetch").FetchEsque;
plugins?: BetterFetchPlugin[];
baseURL?: string;
throw?: boolean;
auth?: {
type: "Bearer";
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
} | {
type: "Basic";
username: string | (() => string | undefined) | undefined;
password: string | (() => string | undefined) | undefined;
} | {
type: "Custom";
prefix: string | (() => string | undefined) | undefined;
value: string | (() => string | undefined) | undefined;
};
body?: any;
query?: any;
params?: any;
duplex?: "full" | "half";
jsonParser?: (text: string) => Promise<any> | any;
retry?: import("@better-fetch/fetch").RetryOptions;
retryAttempt?: number;
output?: import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File;
errorSchema?: import("@better-fetch/fetch").StandardSchemaV1;
disableValidation?: boolean;
};
}>;
}[];
};
//# sourceMappingURL=core.web.d.ts.map