in packages/better-auth/src/plugins/passkey/index.ts [126:254]
generatePasskeyRegistrationOptions: createAuthEndpoint(
"/passkey/generate-register-options",
{
method: "GET",
use: [freshSessionMiddleware],
query: z
.object({
authenticatorAttachment: z
.enum(["platform", "cross-platform"])
.optional(),
})
.optional(),
metadata: {
client: false,
openapi: {
description: "Generate registration options for a new passkey",
responses: {
200: {
description: "Success",
parameters: {
query: {
authenticatorAttachment: {
description: `Type of authenticator to use for registration.
"platform" for device-specific authenticators,
"cross-platform" for authenticators that can be used across devices.`,
required: false,
},
},
},
content: {
"application/json": {
schema: {
type: "object",
properties: {
challenge: {
type: "string",
},
rp: {
type: "object",
properties: {
name: {
type: "string",
},
id: {
type: "string",
},
},
},
user: {
type: "object",
properties: {
id: {
type: "string",
},
name: {
type: "string",
},
displayName: {
type: "string",
},
},
},
pubKeyCredParams: {
type: "array",
items: {
type: "object",
properties: {
type: {
type: "string",
},
alg: {
type: "number",
},
},
},
},
timeout: {
type: "number",
},
excludeCredentials: {
type: "array",
items: {
type: "object",
properties: {
id: {
type: "string",
},
type: {
type: "string",
},
transports: {
type: "array",
items: {
type: "string",
},
},
},
},
},
authenticatorSelection: {
type: "object",
properties: {
authenticatorAttachment: {
type: "string",
},
requireResidentKey: {
type: "boolean",
},
userVerification: {
type: "string",
},
},
},
attestation: {
type: "string",
},
extensions: {
type: "object",
},
},
},
},
},
},
},
},
},
},