export type WebAuthnRegistrationResponse = {id: string, rawId: string, type: 'public-key', authenticatorAttachment?: ('cross-platform' | 'platform') | undefined, clientExtensionResults: {appid?: boolean | undefined, credProps?: ({rk?: boolean | undefined} | {[key: string]: unknown}) | undefined, hmacCreateSecret?: boolean | undefined} | {[key: string]: unknown}, response: {clientDataJSON: string, attestationObject: string, authenticatorData?: string | undefined, transports?: (Array<'ble' | 'cable' | 'hybrid' | 'internal' | 'nfc' | 'smart-card' | 'usb'>) | undefined, publicKeyAlgorithm?: number | undefined, publicKey?: string | undefined} | {[key: string]: unknown}} | {[key: string]: unknown}; export type PasskeyMigrationCompleteRequest = {response: WebAuthnRegistrationResponse, challenge: string}; export type CreateApiUsersMeMfaWebauthnMigrationArgs = {body: PasskeyMigrationCompleteRequest}; export type CreateApiUsersMeMfaWebauthnMigrationOptions = {baseUrl?: string | undefined, sessionToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Complete passkey update * * POST /users/@me/mfa/webauthn/migration */ export const createApiUsersMeMfaWebauthnMigration = async (args: CreateApiUsersMeMfaWebauthnMigrationArgs, options?: CreateApiUsersMeMfaWebauthnMigrationOptions) => { const {baseUrl = "https://web.fluxer.app/api/v1", fetch: fetchFn = fetch, sessionToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (sessionToken !== undefined) headers.set("Authorization", sessionToken) const url = `${baseUrl.replace(/\/+$/, '')}/users/@me/mfa/webauthn/migration${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };