mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 03:26:07 +00:00
fix(native): the handoff's passkey sign-in lives in native/browserSignIn, so the page hook reaches no API on its own
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { sha256 } from '@noble/hashes/sha2';
|
||||
import { bytesToHex } from '@noble/hashes/utils';
|
||||
import { startAuthentication } from '@simplewebauthn/browser';
|
||||
import { authApi } from '../api/client';
|
||||
import { nativeAuthApi } from '../api/nativeAuth';
|
||||
import { APP_URL_SCHEME, TrekShell } from './trekShell';
|
||||
|
||||
@@ -76,6 +78,13 @@ export async function requestHandoffCode(challenge: string): Promise<string> {
|
||||
return code;
|
||||
}
|
||||
|
||||
/** The browser side of a passkey sign-in the app started: the prompt, then the session cookie. */
|
||||
export async function signInWithPasskey(): Promise<void> {
|
||||
const options = await authApi.passkey.loginOptions();
|
||||
const assertion = await startAuthentication({ optionsJSON: options });
|
||||
await authApi.passkey.loginVerify(assertion);
|
||||
}
|
||||
|
||||
export class BrowserSignInCancelled extends Error {
|
||||
constructor() {
|
||||
super('Sign-in cancelled');
|
||||
|
||||
Reference in New Issue
Block a user