mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-24 04:47:03 +00:00
12 lines
842 B
TypeScript
12 lines
842 B
TypeScript
// Bundled only by the isolated browser regression harness, not the auth site.
|
|
import { ApiClient } from '../src/api/client'
|
|
import { registerPasskey, discoverAndSignInWithPasskey } from '../src/lib/passkey'
|
|
const api = new ApiClient(document.body.dataset.token!, { baseUrl: document.body.dataset.hub! })
|
|
const output = document.querySelector('#result')!
|
|
document.querySelector('#register')!.addEventListener('click', () => {
|
|
void registerPasskey(api, 'Browser integration').then(() => { output.textContent = 'registered' }).catch((e) => { output.textContent = String(e) })
|
|
})
|
|
document.querySelector('#login')!.addEventListener('click', () => {
|
|
void discoverAndSignInWithPasskey().then(({ hubUrl, passkeySession }) => { output.textContent = `session:${hubUrl}:${passkeySession}` }).catch((e) => { output.textContent = String(e) })
|
|
})
|