expo-passkey
Version:
Passkey authentication for Expo apps with Better Auth integration
149 lines • 4.57 kB
TypeScript
/**
* @file Server-specific type definitions
* @module expo-passkey/types/server
*/
import { z } from "zod";
/**
* Schema configuration for the Expo Passkey plugin
*/
export interface ExpoPasskeySchemaConfig {
authPasskey?: {
modelName?: string;
};
passkeyChallenge?: {
modelName?: string;
};
}
/**
* Configuration options for the Expo Passkey server plugin
*/
export interface ExpoPasskeyOptions {
/** Relying Party Name for the passkey */
rpName: string;
/** Relying Party ID for the passkey */
rpId: string;
/**
* Expected origins for WebAuthn verification
* For ios, this is your associated domain, for android this is the SHA-256 hash of the apk signing certificate and is in this format:
* android:apk-key-hash:{base64url-encoded-hash}
*/
origin?: string | string[];
/** Schema configuration for database models */
schema?: ExpoPasskeySchemaConfig;
/** Rate limiting configuration */
rateLimit?: {
/** Window for registration attempts in seconds */
registerWindow?: number;
/** Maximum registration attempts per window */
registerMax?: number;
/** Window for authentication attempts in seconds */
authenticateWindow?: number;
/** Maximum authentication attempts per window */
authenticateMax?: number;
};
/** Cleanup configuration for old/inactive passkeys */
cleanup?: {
/** Number of days after which inactive passkeys are revoked */
inactiveDays?: number;
/**
* Disable the interval for automatically cleaning up inactive passkeys.
* Set to true for serverless environments.
* When true, cleanup will still run once on startup but not continuously.
*/
disableInterval?: boolean;
};
/** Logger configuration */
logger?: {
enabled?: boolean;
level?: "debug" | "info" | "warn" | "error";
};
}
/**
* Internal configuration with resolved model names
*/
export interface ResolvedSchemaConfig {
authPasskeyModel: string;
passkeyChallengeModel: string;
}
/**
* Database schema for the authPasskey model
*/
export declare const authPasskeySchema: z.ZodObject<{
id: z.ZodString;
userId: z.ZodString;
credentialId: z.ZodString;
publicKey: z.ZodString;
counter: z.ZodDefault<z.ZodNumber>;
platform: z.ZodString;
lastUsed: z.ZodString;
status: z.ZodDefault<z.ZodEnum<["active", "revoked"]>>;
createdAt: z.ZodString;
updatedAt: z.ZodString;
revokedAt: z.ZodOptional<z.ZodString>;
revokedReason: z.ZodOptional<z.ZodString>;
metadata: z.ZodOptional<z.ZodString>;
aaguid: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
id: string;
userId: string;
credentialId: string;
publicKey: string;
counter: number;
platform: string;
lastUsed: string;
status: "active" | "revoked";
createdAt: string;
updatedAt: string;
revokedAt?: string | undefined;
revokedReason?: string | undefined;
metadata?: string | undefined;
aaguid?: string | undefined;
}, {
id: string;
userId: string;
credentialId: string;
publicKey: string;
platform: string;
lastUsed: string;
createdAt: string;
updatedAt: string;
counter?: number | undefined;
status?: "active" | "revoked" | undefined;
revokedAt?: string | undefined;
revokedReason?: string | undefined;
metadata?: string | undefined;
aaguid?: string | undefined;
}>;
/**
* Database schema for the passkeyChallenge model
*/
export declare const passkeyChallengeSchema: z.ZodObject<{
id: z.ZodString;
userId: z.ZodString;
challenge: z.ZodString;
type: z.ZodEnum<["registration", "authentication"]>;
createdAt: z.ZodString;
expiresAt: z.ZodString;
registrationOptions: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
id: string;
userId: string;
createdAt: string;
type: "registration" | "authentication";
challenge: string;
expiresAt: string;
registrationOptions?: string | undefined;
}, {
id: string;
userId: string;
createdAt: string;
type: "registration" | "authentication";
challenge: string;
expiresAt: string;
registrationOptions?: string | undefined;
}>;
/** AuthPasskey model type */
export type AuthPasskey = z.infer<typeof authPasskeySchema>;
/** PasskeyChallenge model type */
export type PasskeyChallenge = z.infer<typeof passkeyChallengeSchema>;
//# sourceMappingURL=server.d.ts.map