expo-passkey
Version:
Passkey authentication for Expo apps with Better Auth integration
383 lines • 14.7 kB
TypeScript
/**
* @file Schema definitions
* @description Zod schema definitions for request validation
*/
import { z } from "zod";
/**
* Schema for registration options that can be passed with challenge request
*/
export declare const registrationOptionsSchema: z.ZodObject<{
attestation: z.ZodOptional<z.ZodEnum<["none", "indirect", "direct", "enterprise"]>>;
authenticatorSelection: z.ZodOptional<z.ZodObject<{
authenticatorAttachment: z.ZodOptional<z.ZodEnum<["platform", "cross-platform"]>>;
residentKey: z.ZodOptional<z.ZodEnum<["required", "preferred", "discouraged"]>>;
requireResidentKey: z.ZodOptional<z.ZodBoolean>;
userVerification: z.ZodOptional<z.ZodEnum<["required", "preferred", "discouraged"]>>;
}, "strip", z.ZodTypeAny, {
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
userVerification?: "required" | "preferred" | "discouraged" | undefined;
residentKey?: "required" | "preferred" | "discouraged" | undefined;
requireResidentKey?: boolean | undefined;
}, {
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
userVerification?: "required" | "preferred" | "discouraged" | undefined;
residentKey?: "required" | "preferred" | "discouraged" | undefined;
requireResidentKey?: boolean | undefined;
}>>;
timeout: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
timeout?: number | undefined;
attestation?: "none" | "indirect" | "direct" | "enterprise" | undefined;
authenticatorSelection?: {
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
userVerification?: "required" | "preferred" | "discouraged" | undefined;
residentKey?: "required" | "preferred" | "discouraged" | undefined;
requireResidentKey?: boolean | undefined;
} | undefined;
}, {
timeout?: number | undefined;
attestation?: "none" | "indirect" | "direct" | "enterprise" | undefined;
authenticatorSelection?: {
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
userVerification?: "required" | "preferred" | "discouraged" | undefined;
residentKey?: "required" | "preferred" | "discouraged" | undefined;
requireResidentKey?: boolean | undefined;
} | undefined;
}>;
export type RegistrationOptions = z.infer<typeof registrationOptionsSchema>;
/**
* Schema for WebAuthn challenge requests
*/
export declare const challengeSchema: z.ZodObject<{
userId: z.ZodString;
type: z.ZodEnum<["registration", "authentication"]>;
registrationOptions: z.ZodOptional<z.ZodObject<{
attestation: z.ZodOptional<z.ZodEnum<["none", "indirect", "direct", "enterprise"]>>;
authenticatorSelection: z.ZodOptional<z.ZodObject<{
authenticatorAttachment: z.ZodOptional<z.ZodEnum<["platform", "cross-platform"]>>;
residentKey: z.ZodOptional<z.ZodEnum<["required", "preferred", "discouraged"]>>;
requireResidentKey: z.ZodOptional<z.ZodBoolean>;
userVerification: z.ZodOptional<z.ZodEnum<["required", "preferred", "discouraged"]>>;
}, "strip", z.ZodTypeAny, {
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
userVerification?: "required" | "preferred" | "discouraged" | undefined;
residentKey?: "required" | "preferred" | "discouraged" | undefined;
requireResidentKey?: boolean | undefined;
}, {
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
userVerification?: "required" | "preferred" | "discouraged" | undefined;
residentKey?: "required" | "preferred" | "discouraged" | undefined;
requireResidentKey?: boolean | undefined;
}>>;
timeout: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
timeout?: number | undefined;
attestation?: "none" | "indirect" | "direct" | "enterprise" | undefined;
authenticatorSelection?: {
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
userVerification?: "required" | "preferred" | "discouraged" | undefined;
residentKey?: "required" | "preferred" | "discouraged" | undefined;
requireResidentKey?: boolean | undefined;
} | undefined;
}, {
timeout?: number | undefined;
attestation?: "none" | "indirect" | "direct" | "enterprise" | undefined;
authenticatorSelection?: {
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
userVerification?: "required" | "preferred" | "discouraged" | undefined;
residentKey?: "required" | "preferred" | "discouraged" | undefined;
requireResidentKey?: boolean | undefined;
} | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
userId: string;
type: "registration" | "authentication";
registrationOptions?: {
timeout?: number | undefined;
attestation?: "none" | "indirect" | "direct" | "enterprise" | undefined;
authenticatorSelection?: {
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
userVerification?: "required" | "preferred" | "discouraged" | undefined;
residentKey?: "required" | "preferred" | "discouraged" | undefined;
requireResidentKey?: boolean | undefined;
} | undefined;
} | undefined;
}, {
userId: string;
type: "registration" | "authentication";
registrationOptions?: {
timeout?: number | undefined;
attestation?: "none" | "indirect" | "direct" | "enterprise" | undefined;
authenticatorSelection?: {
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
userVerification?: "required" | "preferred" | "discouraged" | undefined;
residentKey?: "required" | "preferred" | "discouraged" | undefined;
requireResidentKey?: boolean | undefined;
} | undefined;
} | undefined;
}>;
/**
* Schema for WebAuthn passkey registration requests
*/
export declare const registerPasskeySchema: z.ZodObject<{
userId: z.ZodString;
credential: z.ZodObject<{
id: z.ZodString;
rawId: z.ZodString;
response: z.ZodObject<{
clientDataJSON: z.ZodString;
attestationObject: z.ZodString;
transports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
clientDataJSON: string;
attestationObject: string;
transports?: string[] | undefined;
}, {
clientDataJSON: string;
attestationObject: string;
transports?: string[] | undefined;
}>;
type: z.ZodLiteral<"public-key">;
clientExtensionResults: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
authenticatorAttachment: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"platform">, z.ZodLiteral<"cross-platform">]>>;
}, "strip", z.ZodTypeAny, {
id: string;
type: "public-key";
rawId: string;
response: {
clientDataJSON: string;
attestationObject: string;
transports?: string[] | undefined;
};
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
clientExtensionResults?: {} | undefined;
}, {
id: string;
type: "public-key";
rawId: string;
response: {
clientDataJSON: string;
attestationObject: string;
transports?: string[] | undefined;
};
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
clientExtensionResults?: {} | undefined;
}>;
platform: z.ZodString;
metadata: z.ZodOptional<z.ZodObject<{
deviceName: z.ZodOptional<z.ZodString>;
deviceModel: z.ZodOptional<z.ZodString>;
appVersion: z.ZodOptional<z.ZodString>;
manufacturer: z.ZodOptional<z.ZodString>;
biometricType: z.ZodOptional<z.ZodString>;
lastLocation: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
deviceName?: string | undefined;
deviceModel?: string | undefined;
appVersion?: string | undefined;
lastLocation?: string | undefined;
manufacturer?: string | undefined;
biometricType?: string | undefined;
}, {
deviceName?: string | undefined;
deviceModel?: string | undefined;
appVersion?: string | undefined;
lastLocation?: string | undefined;
manufacturer?: string | undefined;
biometricType?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
userId: string;
platform: string;
credential: {
id: string;
type: "public-key";
rawId: string;
response: {
clientDataJSON: string;
attestationObject: string;
transports?: string[] | undefined;
};
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
clientExtensionResults?: {} | undefined;
};
metadata?: {
deviceName?: string | undefined;
deviceModel?: string | undefined;
appVersion?: string | undefined;
lastLocation?: string | undefined;
manufacturer?: string | undefined;
biometricType?: string | undefined;
} | undefined;
}, {
userId: string;
platform: string;
credential: {
id: string;
type: "public-key";
rawId: string;
response: {
clientDataJSON: string;
attestationObject: string;
transports?: string[] | undefined;
};
authenticatorAttachment?: "platform" | "cross-platform" | undefined;
clientExtensionResults?: {} | undefined;
};
metadata?: {
deviceName?: string | undefined;
deviceModel?: string | undefined;
appVersion?: string | undefined;
lastLocation?: string | undefined;
manufacturer?: string | undefined;
biometricType?: string | undefined;
} | undefined;
}>;
/**
* Schema for WebAuthn passkey authentication requests
*/
export declare const authenticatePasskeySchema: z.ZodObject<{
credential: z.ZodObject<{
id: z.ZodString;
rawId: z.ZodString;
response: z.ZodObject<{
clientDataJSON: z.ZodString;
authenticatorData: z.ZodString;
signature: z.ZodString;
userHandle: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
clientDataJSON: string;
authenticatorData: string;
signature: string;
userHandle?: string | undefined;
}, {
clientDataJSON: string;
authenticatorData: string;
signature: string;
userHandle?: string | undefined;
}>;
type: z.ZodLiteral<"public-key">;
clientExtensionResults: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
}, "strip", z.ZodTypeAny, {
id: string;
type: "public-key";
rawId: string;
response: {
clientDataJSON: string;
authenticatorData: string;
signature: string;
userHandle?: string | undefined;
};
clientExtensionResults?: {} | undefined;
}, {
id: string;
type: "public-key";
rawId: string;
response: {
clientDataJSON: string;
authenticatorData: string;
signature: string;
userHandle?: string | undefined;
};
clientExtensionResults?: {} | undefined;
}>;
metadata: z.ZodOptional<z.ZodObject<{
lastLocation: z.ZodOptional<z.ZodString>;
appVersion: z.ZodOptional<z.ZodString>;
deviceModel: z.ZodOptional<z.ZodString>;
manufacturer: z.ZodOptional<z.ZodString>;
biometricType: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
deviceModel?: string | undefined;
appVersion?: string | undefined;
lastLocation?: string | undefined;
manufacturer?: string | undefined;
biometricType?: string | undefined;
}, {
deviceModel?: string | undefined;
appVersion?: string | undefined;
lastLocation?: string | undefined;
manufacturer?: string | undefined;
biometricType?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
credential: {
id: string;
type: "public-key";
rawId: string;
response: {
clientDataJSON: string;
authenticatorData: string;
signature: string;
userHandle?: string | undefined;
};
clientExtensionResults?: {} | undefined;
};
metadata?: {
deviceModel?: string | undefined;
appVersion?: string | undefined;
lastLocation?: string | undefined;
manufacturer?: string | undefined;
biometricType?: string | undefined;
} | undefined;
}, {
credential: {
id: string;
type: "public-key";
rawId: string;
response: {
clientDataJSON: string;
authenticatorData: string;
signature: string;
userHandle?: string | undefined;
};
clientExtensionResults?: {} | undefined;
};
metadata?: {
deviceModel?: string | undefined;
appVersion?: string | undefined;
lastLocation?: string | undefined;
manufacturer?: string | undefined;
biometricType?: string | undefined;
} | undefined;
}>;
/**
* Schema for list passkeys query parameters
*/
export declare const listPasskeysQuerySchema: z.ZodObject<{
limit: z.ZodOptional<z.ZodString>;
offset: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
limit?: string | undefined;
offset?: string | undefined;
}, {
limit?: string | undefined;
offset?: string | undefined;
}>;
/**
* Schema for list passkeys URL parameters
*/
export declare const listPasskeysParamsSchema: z.ZodObject<{
userId: z.ZodString;
}, "strip", z.ZodTypeAny, {
userId: string;
}, {
userId: string;
}>;
/**
* Schema for passkey revocation requests
*/
export declare const revokePasskeySchema: z.ZodObject<{
userId: z.ZodString;
credentialId: z.ZodString;
reason: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
userId: string;
credentialId: string;
reason?: string | undefined;
}, {
userId: string;
credentialId: string;
reason?: string | undefined;
}>;
//# sourceMappingURL=schema.d.ts.map