export type RegisterFinishRequest = {challenge_id: string, credential: unknown, name?: (string | null) | undefined}; export type CreateApiApiAuthPasskeyRegisterFinishArgs = {body: RegisterFinishRequest}; export type CreateApiApiAuthPasskeyRegisterFinishOptions = {baseUrl: string, cookieAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Finish Passkey Registration * * POST /api/auth/passkey/register/finish */ export const createApiApiAuthPasskeyRegisterFinish = async (args: CreateApiApiAuthPasskeyRegisterFinishArgs, options: CreateApiApiAuthPasskeyRegisterFinishOptions) => { const {baseUrl, fetch: fetchFn = fetch, cookieAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (cookieAuth !== undefined) cookies.push("gitarena-session=" + encodeURIComponent(cookieAuth)) const url = `${baseUrl.replace(/\/+$/, '')}/api/auth/passkey/register/finish${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 };