@nebulr-group/bridge-svelte 1.0.0-alpha.4 → 1.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -76,6 +76,8 @@ In your app's settings in Bridge, add your app's address as a browser address an
76
76
  | State | `session`, `user`, `workspace`, `workspaces`, `me`, `flags`, `billing`, `plans`, `usage`, `liveStatus`, `getBridge()` |
77
77
  | Server | `@nebulr-group/bridge-svelte/server`: `bridgeHandle`, `requireActor`, `meter`, `flagsFor` |
78
78
  | Hand-off | `HandoffSignIn`, `readHandoff`, `handoffSignIn`: a sign-in page for a command-line tool |
79
+ | Hosted mode | `hosted: {}` in the config: `/auth/sign-in` sends people to the page Bridge hosts for the app, and `/auth/callback` (`HostedCallback`) finishes the sign-in when they come back. Register the page's origin as a browser address and `https://<your app>/auth/callback` as a sign-in return |
80
+ | Several sign-in pages | `linkAddress` in the config: which of the app's registered email-links addresses its emails link to |
79
81
 
80
82
  All the guides: [the learning docs](https://github.com/thebridgedev/bridge-svelte/tree/v1/learning).
81
83
 
@@ -5,7 +5,8 @@
5
5
  <BridgeAuthRoutes />
6
6
 
7
7
  Serves sign-in, sign-up, verify-email, forgot-password, set-password,
8
- invite, workspaces, handoff and magic-link (a sign-in link's landing). An unknown page gets the app's own 404.
8
+ invite, workspaces, handoff, magic-link (a sign-in link's landing), passkey-setup (a passkey setup link's landing)
9
+ and callback (hosted mode's return from Bridge's page). An unknown page gets the app's own 404.
9
10
 
10
11
  Customising, in rungs:
11
12
  1. `--bridge-*` CSS tokens restyle the forms.
@@ -35,6 +36,9 @@
35
36
  import WorkspaceChooser from './WorkspaceChooser.svelte';
36
37
  import HandoffSignIn from './HandoffSignIn.svelte';
37
38
  import MagicLinkLanding from './MagicLinkLanding.svelte';
39
+ import PasskeySetupLanding from './PasskeySetupLanding.svelte';
40
+ import HostedSignIn from './HostedSignIn.svelte';
41
+ import HostedCallback from './HostedCallback.svelte';
38
42
 
39
43
  interface Props {
40
44
  /** Replaces everything around the form, on every page. */
@@ -60,8 +64,12 @@
60
64
  {@render heading?.(p)}
61
65
  {/snippet}
62
66
  {@const pageHeading = heading ? boundHeading : undefined}
63
- {#if p === 'sign-in'}
67
+ {#if p === 'sign-in' && config?.hosted}
68
+ <HostedSignIn headingSnippet={pageHeading} {messages} />
69
+ {:else if p === 'sign-in'}
64
70
  <SignInForm headingSnippet={pageHeading} {messages} />
71
+ {:else if p === 'callback'}
72
+ <HostedCallback headingSnippet={pageHeading} {messages} />
65
73
  {:else if p === 'sign-up'}
66
74
  <SignUpForm headingSnippet={pageHeading} {messages} />
67
75
  {:else if p === 'verify-email'}
@@ -74,6 +82,8 @@
74
82
  <InviteLanding headingSnippet={pageHeading} {messages} />
75
83
  {:else if p === 'magic-link'}
76
84
  <MagicLinkLanding headingSnippet={pageHeading} {messages} />
85
+ {:else if p === 'passkey-setup'}
86
+ <PasskeySetupLanding headingSnippet={pageHeading} {messages} />
77
87
  {:else if p === 'handoff'}
78
88
  <HandoffSignIn headingSnippet={pageHeading} {messages} />
79
89
  {:else if p === 'workspaces'}
@@ -0,0 +1,56 @@
1
+ <!--
2
+ Hosted mode (`hosted` in the config), `<auth base>/callback`: where Bridge's
3
+ hosted page sends the person back. It checks the return (its `state` and
4
+ issuer) and trades the code with the verifier this browser kept, then goes
5
+ on to where the person was going.
6
+ -->
7
+ <script lang="ts">
8
+ import type { Snippet } from 'svelte';
9
+ import { onMount } from 'svelte';
10
+ import { goto } from '$app/navigation';
11
+ import { takeReturnTo } from '@nebulr-group/bridge-auth-core';
12
+ import { getBridge, peekConfig } from '../../core/client.js';
13
+ import type { BridgeMessages } from '../../core/config.js';
14
+ import { errorMessage, translator } from '../../core/i18n.js';
15
+ import AuthFormWrapper from '../shared/AuthFormWrapper.svelte';
16
+ import Alert from '../shared/Alert.svelte';
17
+ import Spinner from '../shared/Spinner.svelte';
18
+
19
+ interface Props {
20
+ headingSnippet?: Snippet;
21
+ messages?: BridgeMessages;
22
+ }
23
+
24
+ let { headingSnippet, messages }: Props = $props();
25
+ const t = $derived(translator(messages));
26
+ const config = peekConfig();
27
+ const authBase = config?.authBase ?? '/auth';
28
+ let failure = $state<string | null>(null);
29
+
30
+ onMount(async () => {
31
+ const back = location.href;
32
+ // The code and state leave the address bar and the history at once.
33
+ history.replaceState(history.state, '', location.pathname);
34
+ try {
35
+ await getBridge().hosted.finish(back);
36
+ await goto(takeReturnTo() ?? config?.afterSignIn ?? '/', { invalidateAll: true, replaceState: true });
37
+ } catch (error) {
38
+ failure = errorMessage(error, t, 'link.error.invalid');
39
+ }
40
+ });
41
+ </script>
42
+
43
+ {#if failure === null}
44
+ <AuthFormWrapper heading={null} data-bridge-hosted="finishing">
45
+ <div class="bridge-auth-settling" data-bridge-auth-settling>
46
+ <Spinner size={24} />
47
+ </div>
48
+ </AuthFormWrapper>
49
+ {:else}
50
+ <AuthFormWrapper heading={t('login.heading')} {headingSnippet} data-bridge-hosted="failed">
51
+ <Alert variant="error">{failure}</Alert>
52
+ <div class="bridge-form-footer">
53
+ <a href={`${authBase}/sign-in`} class="bridge-link">{t('action.backToSignIn')}</a>
54
+ </div>
55
+ </AuthFormWrapper>
56
+ {/if}
@@ -0,0 +1,9 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { BridgeMessages } from '../../core/config.js';
3
+ interface Props {
4
+ headingSnippet?: Snippet;
5
+ messages?: BridgeMessages;
6
+ }
7
+ declare const HostedCallback: import("svelte").Component<Props, {}, "">;
8
+ type HostedCallback = ReturnType<typeof HostedCallback>;
9
+ export default HostedCallback;
@@ -0,0 +1,51 @@
1
+ <!--
2
+ Hosted mode (`hosted` in the config), the sign-in page: starts a sign-in
3
+ request at Bridge and sends the browser to the page Bridge hosts for the
4
+ app. `HostedCallback` finishes it when the person comes back.
5
+ -->
6
+ <script lang="ts">
7
+ import type { Snippet } from 'svelte';
8
+ import { onMount } from 'svelte';
9
+ import { page } from '$app/state';
10
+ import { readReturnTo, stashReturnTo } from '@nebulr-group/bridge-auth-core';
11
+ import { getBridge, peekConfig } from '../../core/client.js';
12
+ import type { BridgeMessages } from '../../core/config.js';
13
+ import { errorMessage, translator } from '../../core/i18n.js';
14
+ import AuthFormWrapper from '../shared/AuthFormWrapper.svelte';
15
+ import Alert from '../shared/Alert.svelte';
16
+ import Spinner from '../shared/Spinner.svelte';
17
+
18
+ interface Props {
19
+ headingSnippet?: Snippet;
20
+ messages?: BridgeMessages;
21
+ }
22
+
23
+ let { headingSnippet, messages }: Props = $props();
24
+ const t = $derived(translator(messages));
25
+ const config = peekConfig();
26
+ let failure = $state<string | null>(null);
27
+
28
+ onMount(async () => {
29
+ try {
30
+ const hosted = config?.hosted ?? {};
31
+ const redirectUri = hosted.redirectUri ?? new URL(`${config?.authBase ?? '/auth'}/callback`, location.origin).toString();
32
+ // Where to go once signed in survives the trip to Bridge's page, in this tab.
33
+ stashReturnTo(readReturnTo(page.url, config?.returnToParam));
34
+ location.assign(await getBridge().hosted.start({ redirectUri, ...(hosted.linkAddress === undefined ? {} : { linkAddress: hosted.linkAddress }) }));
35
+ } catch (error) {
36
+ failure = errorMessage(error, t, 'login.error.invalidCredentials');
37
+ }
38
+ });
39
+ </script>
40
+
41
+ {#if failure === null}
42
+ <AuthFormWrapper heading={null} data-bridge-hosted="starting">
43
+ <div class="bridge-auth-settling" data-bridge-auth-settling>
44
+ <Spinner size={24} />
45
+ </div>
46
+ </AuthFormWrapper>
47
+ {:else}
48
+ <AuthFormWrapper heading={t('login.heading')} {headingSnippet} data-bridge-hosted="failed">
49
+ <Alert variant="error">{failure}</Alert>
50
+ </AuthFormWrapper>
51
+ {/if}
@@ -0,0 +1,9 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { BridgeMessages } from '../../core/config.js';
3
+ interface Props {
4
+ headingSnippet?: Snippet;
5
+ messages?: BridgeMessages;
6
+ }
7
+ declare const HostedSignIn: import("svelte").Component<Props, {}, "">;
8
+ type HostedSignIn = ReturnType<typeof HostedSignIn>;
9
+ export default HostedSignIn;
@@ -21,7 +21,7 @@
21
21
  import Spinner from '../shared/Spinner.svelte';
22
22
  import WorkspaceChooser from './WorkspaceChooser.svelte';
23
23
  import { takeEmailLink } from './email-link.js';
24
- import { bounded, leave } from './finish-link.js';
24
+ import { bounded, handOff, leave } from './finish-link.js';
25
25
 
26
26
  interface Props extends HTMLAttributes<HTMLDivElement> {
27
27
  /** The link's token. @default read from the page's address */
@@ -64,7 +64,8 @@
64
64
  }
65
65
 
66
66
  async function follow(step: SignInStep) {
67
- if (step.done) await finish();
67
+ if (handOff(step)) view = { step: 'working' };
68
+ else if (step.done) await finish();
68
69
  else view = { step: 'workspace', workspaces: step.workspaces, choose: step.choose };
69
70
  }
70
71
 
@@ -0,0 +1,120 @@
1
+ <!--
2
+ The signed-in person's passkeys: each one's name, when it was added and
3
+ last used, and whether it syncs to their other devices; adding one from
4
+ this device and removing one. Adding or removing needs a recent sign-in;
5
+ otherwise the person is asked to sign in again. The last way to sign in
6
+ cannot be removed.
7
+ -->
8
+ <script lang="ts">
9
+ import type { HTMLAttributes } from 'svelte/elements';
10
+ import { onMount } from 'svelte';
11
+ import { isBridgeError, type PasskeyInfo } from '@nebulr-group/bridge-auth-core';
12
+ import { getBridge } from '../../core/client.js';
13
+ import type { BridgeMessages } from '../../core/config.js';
14
+ import { errorMessage, translator } from '../../core/i18n.js';
15
+ import Alert from '../shared/Alert.svelte';
16
+ import Spinner from '../shared/Spinner.svelte';
17
+
18
+ interface Props extends HTMLAttributes<HTMLDivElement> {
19
+ /** Heading above the list. @default "Passkeys"; `null` for none */
20
+ heading?: string | null;
21
+ /** Called after a passkey was added or removed. */
22
+ onChange?: (passkeys: readonly PasskeyInfo[]) => void;
23
+ onError?: (error: unknown) => void;
24
+ messages?: BridgeMessages;
25
+ }
26
+
27
+ let { heading = undefined, onChange, onError, messages, class: className, ...rest }: Props = $props();
28
+
29
+ const t = $derived(translator(messages));
30
+ let passkeys = $state<PasskeyInfo[] | null>(null);
31
+ let supported = $state(false);
32
+ let name = $state('');
33
+ let busy = $state(false);
34
+ let failure = $state<string | null>(null);
35
+
36
+ const date = (value: string | null) => (value === null ? '' : new Date(value).toLocaleDateString());
37
+
38
+ function fail(error: unknown) {
39
+ if (isBridgeError(error, 'cancelled')) failure = t('passkey.cancelled');
40
+ else if (isBridgeError(error, 'reauthenticate')) failure = t('passkey.reauthenticate');
41
+ else if (isBridgeError(error, 'conflict') && error.code === 'last_sign_in_method') failure = t('passkey.lastMethod');
42
+ else if (isBridgeError(error, 'conflict') && error.code === 'passkey_exists') failure = t('passkey.exists');
43
+ else failure = errorMessage(error, t);
44
+ onError?.(error);
45
+ }
46
+
47
+ async function load() {
48
+ passkeys = await getBridge().passkeys.list();
49
+ }
50
+
51
+ onMount(async () => {
52
+ supported = await getBridge().passkeys.supported();
53
+ await load().catch(fail);
54
+ });
55
+
56
+ async function add() {
57
+ if (busy) return;
58
+ busy = true;
59
+ failure = null;
60
+ try {
61
+ await getBridge().passkeys.add(name.trim() || undefined);
62
+ name = '';
63
+ await load();
64
+ onChange?.(passkeys ?? []);
65
+ } catch (error) {
66
+ fail(error);
67
+ } finally {
68
+ busy = false;
69
+ }
70
+ }
71
+
72
+ async function remove(id: string) {
73
+ if (busy) return;
74
+ busy = true;
75
+ failure = null;
76
+ try {
77
+ await getBridge().passkeys.remove(id);
78
+ await load();
79
+ onChange?.(passkeys ?? []);
80
+ } catch (error) {
81
+ fail(error);
82
+ } finally {
83
+ busy = false;
84
+ }
85
+ }
86
+ </script>
87
+
88
+ <div class="bridge-passkeys {className ?? ''}" data-bridge-passkeys {...rest}>
89
+ {#if heading !== null}<h3>{heading ?? t('passkey.manageHeading')}</h3>{/if}
90
+ {#if failure}<Alert variant="error">{failure}</Alert>{/if}
91
+ {#if passkeys === null}
92
+ <Spinner size={16} />
93
+ {:else if passkeys.length === 0}
94
+ <p data-bridge-passkeys-empty>{t('passkey.empty')}</p>
95
+ {:else}
96
+ <ul class="bridge-passkey-list">
97
+ {#each passkeys as passkey (passkey.id)}
98
+ <li data-bridge-passkey={passkey.id}>
99
+ <div>
100
+ <strong>{passkey.name}</strong>
101
+ <div class="bridge-passkey-meta">
102
+ {t('passkey.added', { date: date(passkey.createdAt) })}{#if passkey.lastUsedAt} · {t('passkey.lastUsed', { date: date(passkey.lastUsedAt) })}{/if}{#if passkey.deviceType === 'multiDevice'} · {t('passkey.synced')}{/if}
103
+ </div>
104
+ </div>
105
+ <button type="button" class="bridge-btn bridge-btn-secondary" data-bridge-passkey-remove onclick={() => remove(passkey.id)} disabled={busy}>{t('passkey.remove')}</button>
106
+ </li>
107
+ {/each}
108
+ </ul>
109
+ {/if}
110
+ {#if supported}
111
+ <form onsubmit={(event) => { event.preventDefault(); void add(); }} class="bridge-passkey-add">
112
+ <input type="text" maxlength="64" placeholder={t('passkey.namePlaceholder')} bind:value={name} disabled={busy} />
113
+ <button type="submit" class="bridge-btn bridge-btn-primary" data-bridge-passkey-add disabled={busy}>
114
+ {#if busy}<Spinner size={16} />{/if} {t('passkey.add')}
115
+ </button>
116
+ </form>
117
+ {:else}
118
+ <p>{t('passkey.unsupported')}</p>
119
+ {/if}
120
+ </div>
@@ -0,0 +1,14 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import { type PasskeyInfo } from '@nebulr-group/bridge-auth-core';
3
+ import type { BridgeMessages } from '../../core/config.js';
4
+ interface Props extends HTMLAttributes<HTMLDivElement> {
5
+ /** Heading above the list. @default "Passkeys"; `null` for none */
6
+ heading?: string | null;
7
+ /** Called after a passkey was added or removed. */
8
+ onChange?: (passkeys: readonly PasskeyInfo[]) => void;
9
+ onError?: (error: unknown) => void;
10
+ messages?: BridgeMessages;
11
+ }
12
+ declare const PasskeyManager: import("svelte").Component<Props, {}, "">;
13
+ type PasskeyManager = ReturnType<typeof PasskeyManager>;
14
+ export default PasskeyManager;
@@ -0,0 +1,117 @@
1
+ <!--
2
+ Sets up a passkey from an emailed link, on the device that asked for it,
3
+ then signs the person in. The browser's dialog opens only on a click, as
4
+ Safari asks. Opened on another device it says so, and the link still works
5
+ on the right one. The link works once.
6
+ -->
7
+ <script lang="ts">
8
+ import type { Snippet } from 'svelte';
9
+ import type { HTMLAttributes } from 'svelte/elements';
10
+ import { onMount } from 'svelte';
11
+ import { goto } from '$app/navigation';
12
+ import { isBridgeError, type SignInStep, type WorkspaceChoice } from '@nebulr-group/bridge-auth-core';
13
+ import { getBridge, peekConfig } from '../../core/client.js';
14
+ import type { BridgeMessages } from '../../core/config.js';
15
+ import { errorMessage, translator } from '../../core/i18n.js';
16
+ import AuthFormWrapper from '../shared/AuthFormWrapper.svelte';
17
+ import Alert from '../shared/Alert.svelte';
18
+ import Spinner from '../shared/Spinner.svelte';
19
+ import WorkspaceChooser from './WorkspaceChooser.svelte';
20
+ import { takeEmailLink } from './email-link.js';
21
+
22
+ interface Props extends HTMLAttributes<HTMLDivElement> {
23
+ /** The link's token. @default read from the page's address */
24
+ token?: string;
25
+ headingSnippet?: Snippet;
26
+ /** Called once signed in. Without it, the page goes to `auth.afterSignIn`. */
27
+ onSignIn?: () => void;
28
+ onError?: (error: unknown) => void;
29
+ messages?: BridgeMessages;
30
+ }
31
+
32
+ let { token = undefined, headingSnippet, onSignIn, onError, messages, class: className, style, ...rest }: Props = $props();
33
+
34
+ const t = $derived(translator(messages));
35
+ const config = peekConfig();
36
+ const authBase = config?.authBase ?? '/auth';
37
+
38
+ type State =
39
+ | { step: 'ready' }
40
+ | { step: 'working' }
41
+ | { step: 'unsupported' }
42
+ | { step: 'workspace'; workspaces: readonly WorkspaceChoice[]; choose: (id: string) => Promise<SignInStep> }
43
+ | { step: 'failed'; message: string; kind: string | null; again: boolean };
44
+ let view = $state<State>({ step: 'ready' });
45
+ let found: string | null = null;
46
+
47
+ async function follow(step: SignInStep) {
48
+ if (!step.done) {
49
+ view = { step: 'workspace', workspaces: step.workspaces, choose: step.choose };
50
+ return;
51
+ }
52
+ if (onSignIn) onSignIn();
53
+ else await goto(config?.afterSignIn ?? '/', { invalidateAll: true });
54
+ }
55
+
56
+ function fail(error: unknown) {
57
+ const kind = isBridgeError(error) ? error.kind : null;
58
+ const message = kind === 'wrong-device' ? t('magicLink.wrongDevice') : kind === 'cancelled' ? t('passkey.cancelled') : errorMessage(error, t, 'link.error.invalid');
59
+ // A closed dialog leaves the link unused: the person may try again.
60
+ view = { step: 'failed', message, kind, again: kind === 'cancelled' };
61
+ onError?.(error);
62
+ }
63
+
64
+ onMount(async () => {
65
+ found = token ?? takeEmailLink('passkey-setup');
66
+ if (found === null) view = { step: 'failed', message: t('verify.missingLink'), kind: null, again: false };
67
+ else if (!(await getBridge().passkeys.supported())) view = { step: 'unsupported' };
68
+ });
69
+
70
+ async function create() {
71
+ if (found === null) return;
72
+ view = { step: 'working' };
73
+ try {
74
+ await follow(await getBridge().passkeys.setupLink.finish(found));
75
+ } catch (error) {
76
+ fail(error);
77
+ }
78
+ }
79
+
80
+ async function choose(id: string) {
81
+ if (view.step !== 'workspace') return;
82
+ try {
83
+ await follow(await view.choose(id));
84
+ } catch (error) {
85
+ fail(error);
86
+ }
87
+ }
88
+ </script>
89
+
90
+ {#if view.step === 'working'}
91
+ <AuthFormWrapper heading={null} class={className} {style} data-bridge-passkey-setup="working" {...rest}>
92
+ <div class="bridge-auth-settling" data-bridge-auth-settling>
93
+ <Spinner size={24} />
94
+ <span>{t('magicLink.finishing')}</span>
95
+ </div>
96
+ </AuthFormWrapper>
97
+ {:else if view.step === 'workspace'}
98
+ <AuthFormWrapper heading={t('workspace.chooseHeading')} {headingSnippet} class={className} {style} data-bridge-passkey-setup="workspace" {...rest}>
99
+ <WorkspaceChooser workspaces={view.workspaces} onChoose={choose} {messages} />
100
+ </AuthFormWrapper>
101
+ {:else}
102
+ <AuthFormWrapper heading={t('passkey.setupHeading')} {headingSnippet} class={className} {style} data-bridge-passkey-setup={view.step} data-error-kind={view.step === 'failed' ? view.kind : null} {...rest}>
103
+ {#if view.step === 'unsupported'}
104
+ <Alert variant="error">{t('passkey.unsupported')}</Alert>
105
+ {:else if view.step === 'failed'}
106
+ <Alert variant="error">{view.message}</Alert>
107
+ {:else}
108
+ <p>{t('passkey.setupPrompt')}</p>
109
+ {/if}
110
+ {#if view.step === 'ready' || (view.step === 'failed' && view.again)}
111
+ <button type="button" class="bridge-btn bridge-btn-primary" data-bridge-passkey-create onclick={create}>{t('passkey.create')}</button>
112
+ {/if}
113
+ <div class="bridge-form-footer">
114
+ <a href={`${authBase}/sign-in`} class="bridge-link">{t('action.backToSignIn')}</a>
115
+ </div>
116
+ </AuthFormWrapper>
117
+ {/if}
@@ -0,0 +1,15 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { BridgeMessages } from '../../core/config.js';
4
+ interface Props extends HTMLAttributes<HTMLDivElement> {
5
+ /** The link's token. @default read from the page's address */
6
+ token?: string;
7
+ headingSnippet?: Snippet;
8
+ /** Called once signed in. Without it, the page goes to `auth.afterSignIn`. */
9
+ onSignIn?: () => void;
10
+ onError?: (error: unknown) => void;
11
+ messages?: BridgeMessages;
12
+ }
13
+ declare const PasskeySetupLanding: import("svelte").Component<Props, {}, "">;
14
+ type PasskeySetupLanding = ReturnType<typeof PasskeySetupLanding>;
15
+ export default PasskeySetupLanding;
@@ -6,16 +6,20 @@
6
6
 
7
7
  The form shows the methods the app's sign-in options list: the password
8
8
  fields when it offers passwords, "Email me a sign-in link" when it offers
9
- links. Other methods (email codes, passkeys, company login, a second step)
10
- arrive as new sign-in steps and join the same way, without a new API.
9
+ links, and "Sign in with a passkey" when it offers passkeys and the browser
10
+ can use them. With passkeys, the email field also offers the person's
11
+ passkeys in its autofill list, where the browser supports it; the button
12
+ stays for a phone or a security key. Other methods (email codes, company
13
+ login, a second step) arrive as new sign-in steps and join the same way.
11
14
  -->
12
15
  <script lang="ts">
13
16
  import type { Snippet } from 'svelte';
14
17
  import type { HTMLAttributes } from 'svelte/elements';
15
- import { onMount } from 'svelte';
18
+ import { onDestroy, onMount } from 'svelte';
19
+ import { handOff } from './finish-link.js';
16
20
  import { goto } from '$app/navigation';
17
21
  import { page } from '$app/state';
18
- import { readReturnTo, type SignInOptions, type SignInStep, type WorkspaceChoice } from '@nebulr-group/bridge-auth-core';
22
+ import { isBridgeError, readReturnTo, type SignInOptions, type SignInStep, type WorkspaceChoice } from '@nebulr-group/bridge-auth-core';
19
23
  import { get } from 'svelte/store';
20
24
  import { getBridge, peekConfig, takeEndedReason } from '../../core/client.js';
21
25
  import { session } from '../../core/stores.js';
@@ -81,6 +85,23 @@
81
85
  const signUpShown = $derived(showSignupLink ?? options?.signUp ?? true);
82
86
  const passwordOffered = $derived(options === null || options.methods.includes('password'));
83
87
  const linkOffered = $derived(options !== null && options.methods.includes('magicLink'));
88
+ let passkeySupported = $state(false);
89
+ let setupLinkSent = $state(false);
90
+ const passkeysOffered = $derived(passkeySupported && options !== null && options.methods.includes('passkeys'));
91
+ const emailAutocomplete = $derived(passkeysOffered ? 'username webauthn' : 'username');
92
+ let autofillStarted = false;
93
+
94
+ /** Waits for the person to pick a passkey from the email field's autofill list. A closed list is not an error. */
95
+ async function startAutofill() {
96
+ const bridge = getBridge();
97
+ if (autofillStarted || !(await bridge.passkeys.autofillSupported())) return;
98
+ autofillStarted = true;
99
+ try {
100
+ await follow(await bridge.passkeys.signIn({ autofill: true, ...(workspace ? { workspace } : {}) }));
101
+ } catch (error) {
102
+ if (!isBridgeError(error, 'cancelled')) fail(error);
103
+ }
104
+ }
84
105
 
85
106
  onMount(() => {
86
107
  // Why the last session ended: told by the client as it happened, or read from the session on a fresh page.
@@ -88,12 +109,54 @@
88
109
  const ended = takeEndedReason() ?? (now.status === 'signed-out' ? now.reason : null);
89
110
  if (ended === 'session-ended') notice = t('session.ended');
90
111
  if (ended === 'access-removed') notice = t('session.accessRemoved');
91
- getBridge()
92
- .signIn.options()
93
- .then((found) => (options = found))
112
+ const bridge = getBridge();
113
+ bridge.signIn
114
+ .options()
115
+ .then(async (found) => {
116
+ options = found;
117
+ if (!found.methods.includes('passkeys')) return;
118
+ passkeySupported = await bridge.passkeys.supported();
119
+ if (passkeySupported) void startAutofill();
120
+ })
94
121
  .catch(() => undefined);
95
122
  });
96
123
 
124
+ onDestroy(() => {
125
+ // An autofill wait must not outlive the form.
126
+ if (autofillStarted) void getBridge().passkeys.cancel();
127
+ });
128
+
129
+ /** Signs in with a passkey from the browser's dialog: a phone, a security key, or this device. */
130
+ async function signInWithPasskey() {
131
+ if (loading) return;
132
+ failure = null;
133
+ notice = null;
134
+ loading = true;
135
+ try {
136
+ await follow(await getBridge().passkeys.signIn({ ...(email.trim() ? { email: email.trim() } : {}), ...(workspace ? { workspace } : {}) }));
137
+ } catch (error) {
138
+ if (isBridgeError(error, 'cancelled')) notice = t('passkey.cancelled');
139
+ else fail(error);
140
+ } finally {
141
+ loading = false;
142
+ }
143
+ }
144
+
145
+ /** Emails a link to set up a passkey on this device. The answer is the same whether or not the address has an account. */
146
+ async function sendSetupLink() {
147
+ if (loading || !email.trim()) return;
148
+ failure = null;
149
+ loading = true;
150
+ try {
151
+ await getBridge().passkeys.setupLink.request(email.trim());
152
+ setupLinkSent = true;
153
+ } catch (error) {
154
+ fail(error);
155
+ } finally {
156
+ loading = false;
157
+ }
158
+ }
159
+
97
160
  function finish() {
98
161
  settled = true;
99
162
  if (onSignIn) {
@@ -110,7 +173,9 @@
110
173
  }
111
174
 
112
175
  async function follow(step: SignInStep) {
113
- if (step.done) {
176
+ if (handOff(step)) {
177
+ settled = true;
178
+ } else if (step.done) {
114
179
  finish();
115
180
  } else {
116
181
  choice = { workspaces: step.workspaces, choose: step.choose };
@@ -182,7 +247,9 @@
182
247
  >
183
248
  {#if notice}<Alert variant="info">{notice}</Alert>{/if}
184
249
  {#if failure}<Alert variant="error">{failure}</Alert>{/if}
185
- {#if linkSent}
250
+ {#if setupLinkSent}
251
+ <Alert variant="info">{t('passkey.setupLinkSent')}</Alert>
252
+ {:else if linkSent}
186
253
  <Alert variant="info">{t('magicLink.sent')}</Alert>
187
254
  {:else if passwordOffered}
188
255
  <form onsubmit={submit}>
@@ -191,7 +258,7 @@
191
258
  <input
192
259
  id="login-email"
193
260
  type="email"
194
- autocomplete="username"
261
+ autocomplete={emailAutocomplete}
195
262
  placeholder={t('placeholder.email')}
196
263
  required
197
264
  bind:value={email}
@@ -233,7 +300,7 @@
233
300
  <input
234
301
  id="login-email"
235
302
  type="email"
236
- autocomplete="username"
303
+ autocomplete={emailAutocomplete}
237
304
  placeholder={t('placeholder.email')}
238
305
  required
239
306
  bind:value={email}
@@ -244,6 +311,23 @@
244
311
  {#if loading}<Spinner size={16} />{/if} {t('magicLink.send')}
245
312
  </button>
246
313
  </form>
314
+ {:else if passkeysOffered}
315
+ <form onsubmit={(event) => { event.preventDefault(); void signInWithPasskey(); }} data-bridge-passkey-form>
316
+ <div class="bridge-form-group">
317
+ <label for="login-email">{t('field.email')}</label>
318
+ <input id="login-email" type="email" autocomplete={emailAutocomplete} placeholder={t('placeholder.email')} bind:value={email} disabled={loading} />
319
+ </div>
320
+ </form>
321
+ {/if}
322
+
323
+ {#if passkeysOffered && !linkSent && !setupLinkSent}
324
+ {#if passwordOffered || linkOffered}<div class="bridge-divider" data-bridge-sign-in-or>{t('magicLink.or')}</div>{/if}
325
+ <button type="button" class="bridge-btn {passwordOffered || linkOffered ? 'bridge-btn-secondary' : 'bridge-btn-primary'}" data-bridge-passkey-sign-in onclick={signInWithPasskey} disabled={loading}>
326
+ {t('passkey.signIn')}
327
+ </button>
328
+ <div class="bridge-forgot-row">
329
+ <button type="button" class="bridge-link" data-bridge-passkey-setup-link onclick={sendSetupLink} disabled={loading || !email.trim()}>{t('passkey.setupLinkSend')}</button>
330
+ </div>
247
331
  {/if}
248
332
 
249
333
  {#if footer}
@@ -25,7 +25,7 @@
25
25
  import Spinner from '../shared/Spinner.svelte';
26
26
  import WorkspaceChooser from './WorkspaceChooser.svelte';
27
27
  import { takeEmailLink } from './email-link.js';
28
- import { bounded, leave } from './finish-link.js';
28
+ import { bounded, handOff, leave } from './finish-link.js';
29
29
 
30
30
  interface Props extends HTMLAttributes<HTMLDivElement> {
31
31
  /** The link's token. @default read from the page's address */
@@ -68,7 +68,8 @@
68
68
  }
69
69
 
70
70
  async function follow(step: SignInStep) {
71
- if (step.done) await finish();
71
+ if (handOff(step)) view = { step: 'working' };
72
+ else if (step.done) await finish();
72
73
  else view = { step: 'workspace', workspaces: step.workspaces, choose: step.choose };
73
74
  }
74
75
 
@@ -14,3 +14,12 @@ export declare function bounded<T>(work: Promise<T>, ms?: number): Promise<T>;
14
14
  * left; false after `tries`, and the page offers a link instead.
15
15
  */
16
16
  export declare function leave(go: () => Promise<unknown>, left: () => boolean, tries?: number): Promise<boolean>;
17
+ /**
18
+ * A sign-in finished for another app's sign-in request: the browser goes to
19
+ * the app's registered return with the code, and this page makes no session.
20
+ * True when it went.
21
+ */
22
+ export declare function handOff(step: {
23
+ readonly done: boolean;
24
+ readonly handoff?: string;
25
+ }, go?: (url: string) => void): boolean;
@@ -43,3 +43,14 @@ export async function leave(go, left, tries = LEAVE_TRIES) {
43
43
  }
44
44
  return false;
45
45
  }
46
+ /**
47
+ * A sign-in finished for another app's sign-in request: the browser goes to
48
+ * the app's registered return with the code, and this page makes no session.
49
+ * True when it went.
50
+ */
51
+ export function handOff(step, go = (url) => location.assign(url)) {
52
+ if (!step.done || step.handoff === undefined)
53
+ return false;
54
+ go(step.handoff);
55
+ return true;
56
+ }
@@ -62,8 +62,13 @@ export function startClient(config, extra) {
62
62
  // Memory: the refresh token and the visitor id stay in this page. A sign-up's verifier waits in localStorage
63
63
  // for its email link, which opens in a new tab, for the link's 15 minutes at most, and is removed once used.
64
64
  ...(config.storage === 'memory' ? { storage: memoryStorage(), signUpStorage: localStorageAdapter() } : {}),
65
+ ...(config.linkAddress === undefined ? {} : { linkAddress: config.linkAddress }),
65
66
  ...extra,
66
67
  });
68
+ // A page that signs in for other apps' sign-in requests takes the request from its address, before any form.
69
+ const request = config.signInRequests && typeof location !== 'undefined' ? new URLSearchParams(location.search).get('request') : null;
70
+ if (request !== null)
71
+ void client.request.use(request).catch(() => undefined);
67
72
  client.on('signed-out', ({ reason }) => {
68
73
  if (reason === 'session-ended' || reason === 'access-removed')
69
74
  lastEnded = reason;
@@ -114,10 +114,38 @@ export interface BridgeConfig {
114
114
  */
115
115
  readonly handoff?: {
116
116
  /** Return the code to the program's loopback address (`http://127.0.0.1:<port>`). */
117
- readonly loopback: true;
117
+ readonly loopback?: true;
118
+ /**
119
+ * Sign in for another app's sign-in request: opened with `?request=<id>`,
120
+ * the page signs in on the request and sends the browser to the app's
121
+ * registered return with the code. For a page that signs people in for
122
+ * other apps, such as Bridge's hosted page.
123
+ */
124
+ readonly requests?: true;
118
125
  /** The program's name, for the page's copy. @default 'the command-line tool' */
119
126
  readonly program?: string;
120
127
  };
128
+ /**
129
+ * Where the links in sign-up, sign-in link and recovery emails go: one of
130
+ * the app's registered email-links addresses, exactly, usually the address
131
+ * of these sign-in pages. Needed when the app has several sign-in pages.
132
+ * @default the app's first email-links address
133
+ */
134
+ readonly linkAddress?: string;
135
+ /**
136
+ * Hosted mode: sign in on the page Bridge hosts for the app instead of the
137
+ * app's own forms. The sign-in page sends the browser there, and
138
+ * `<auth base>/callback` finishes the sign-in when it comes back.
139
+ */
140
+ readonly hosted?: {
141
+ /**
142
+ * Where Bridge's page sends the person back: one of the app's registered
143
+ * sign-in returns, exactly. @default `<origin><auth base>/callback`
144
+ */
145
+ readonly redirectUri?: string;
146
+ /** Where an email link sent on the way goes. @default Bridge's hosted page */
147
+ readonly linkAddress?: string;
148
+ };
121
149
  }
122
150
  /** The settings with every default filled in. */
123
151
  export interface ResolvedConfig {
@@ -145,6 +173,13 @@ export interface ResolvedConfig {
145
173
  readonly handoff: {
146
174
  readonly program: string;
147
175
  } | null;
176
+ /** Whether the page signs in for other apps' sign-in requests (`?request=<id>`). */
177
+ readonly signInRequests: boolean;
178
+ readonly linkAddress: string | undefined;
179
+ readonly hosted: {
180
+ readonly redirectUri?: string;
181
+ readonly linkAddress?: string;
182
+ } | null;
148
183
  }
149
184
  /**
150
185
  * Checks the issuer before anything is sent: it must be https, except on
@@ -64,5 +64,8 @@ export function resolveConfig(config, envIssuer) {
64
64
  paywall: paywall === false ? null : (paywall ?? `${billingBase}/plan`),
65
65
  upgradeDialog: config.billing?.upgradeDialog ?? true,
66
66
  handoff: config.handoff?.loopback === true ? { program: config.handoff.program ?? 'the command-line tool' } : null,
67
+ signInRequests: config.handoff?.requests === true,
68
+ linkAddress: config.linkAddress,
69
+ hosted: config.hosted ?? null,
67
70
  };
68
71
  }
@@ -4,7 +4,7 @@
4
4
  * impersonal errors that end in a full stop, labels and buttons without one,
5
5
  * placeholders positioned in the sentence.
6
6
  */
7
- export type PluginMessageKey = 'signup.closed' | 'field.workspaceName' | 'verify.missingLink' | 'forgot.setDone' | 'invite.description' | 'invite.notOffered' | 'invite.signInToAccept' | 'invite.signUpToAccept' | 'invite.signedInAs' | 'invite.continue' | 'invite.state.revoked' | 'invite.state.used' | 'invite.state.expired' | 'invite.wrongAddress' | 'invite.alreadyMember' | 'invite.accountExists' | 'verify.continuedElsewhere' | 'handoff.invalid' | 'handoff.notOffered' | 'session.ended' | 'session.accessRemoved' | 'error.generic' | 'workspace.empty' | 'workspace.current' | 'password.tooShort' | 'feature.upgrade' | 'magicLink.send' | 'magicLink.sent' | 'magicLink.finishing' | 'magicLink.wrongDevice' | 'magicLink.or';
7
+ export type PluginMessageKey = 'signup.closed' | 'field.workspaceName' | 'verify.missingLink' | 'forgot.setDone' | 'invite.description' | 'invite.notOffered' | 'invite.signInToAccept' | 'invite.signUpToAccept' | 'invite.signedInAs' | 'invite.continue' | 'invite.state.revoked' | 'invite.state.used' | 'invite.state.expired' | 'invite.wrongAddress' | 'invite.alreadyMember' | 'invite.accountExists' | 'verify.continuedElsewhere' | 'handoff.invalid' | 'handoff.notOffered' | 'session.ended' | 'session.accessRemoved' | 'error.generic' | 'workspace.empty' | 'workspace.current' | 'password.tooShort' | 'feature.upgrade' | 'magicLink.send' | 'magicLink.sent' | 'magicLink.finishing' | 'magicLink.wrongDevice' | 'magicLink.or' | 'passkey.signIn' | 'passkey.cancelled' | 'passkey.unsupported' | 'passkey.setupLinkSend' | 'passkey.setupLinkSent' | 'passkey.setupHeading' | 'passkey.setupPrompt' | 'passkey.create' | 'passkey.manageHeading' | 'passkey.add' | 'passkey.remove' | 'passkey.empty' | 'passkey.lastUsed' | 'passkey.added' | 'passkey.synced' | 'passkey.lastMethod' | 'passkey.exists' | 'passkey.reauthenticate' | 'passkey.namePlaceholder';
8
8
  export type PluginMessages = Record<PluginMessageKey, string>;
9
9
  /** The plugin's copy by primary language subtag. */
10
10
  export declare const PLUGIN_LOCALES: Readonly<Record<string, PluginMessages>>;
@@ -30,6 +30,25 @@ const en = {
30
30
  'magicLink.finishing': 'Signing you in…',
31
31
  'magicLink.wrongDevice': 'Open the link on the device where you asked for it.',
32
32
  'magicLink.or': 'or',
33
+ 'passkey.signIn': 'Sign in with a passkey',
34
+ 'passkey.cancelled': 'No passkey was used. Try again, or sign in another way.',
35
+ 'passkey.unsupported': 'This browser cannot use passkeys.',
36
+ 'passkey.setupLinkSend': 'Email me a link to set up a passkey',
37
+ 'passkey.setupLinkSent': 'If this address has an account, a link to set up a passkey is on its way. Open it on this device.',
38
+ 'passkey.setupHeading': 'Set up a passkey',
39
+ 'passkey.setupPrompt': 'Next time, sign in with your fingerprint, face or screen lock.',
40
+ 'passkey.create': 'Create a passkey',
41
+ 'passkey.manageHeading': 'Passkeys',
42
+ 'passkey.add': 'Add a passkey',
43
+ 'passkey.remove': 'Remove',
44
+ 'passkey.empty': 'No passkeys yet.',
45
+ 'passkey.lastUsed': 'Last used {date}',
46
+ 'passkey.added': 'Added {date}',
47
+ 'passkey.synced': 'Syncs across your devices',
48
+ 'passkey.lastMethod': 'This passkey is your only way to sign in. Add another one first.',
49
+ 'passkey.exists': 'This device has a passkey already.',
50
+ 'passkey.reauthenticate': 'Sign in again to change your passkeys.',
51
+ 'passkey.namePlaceholder': 'Name (optional)',
33
52
  };
34
53
  const sv = {
35
54
  'signup.closed': 'Registrering är stängd för den här appen.',
@@ -63,6 +82,25 @@ const sv = {
63
82
  'magicLink.finishing': 'Loggar in dig…',
64
83
  'magicLink.wrongDevice': 'Öppna länken på enheten där du bad om den.',
65
84
  'magicLink.or': 'eller',
85
+ 'passkey.signIn': 'Logga in med en passkey',
86
+ 'passkey.cancelled': 'Ingen passkey användes. Försök igen eller logga in på annat sätt.',
87
+ 'passkey.unsupported': 'Den här webbläsaren kan inte använda passkeys.',
88
+ 'passkey.setupLinkSend': 'Mejla mig en länk för att skapa en passkey',
89
+ 'passkey.setupLinkSent': 'Om adressen har ett konto är en länk för att skapa en passkey på väg. Öppna den på den här enheten.',
90
+ 'passkey.setupHeading': 'Skapa en passkey',
91
+ 'passkey.setupPrompt': 'Nästa gång loggar du in med fingeravtryck, ansikte eller skärmlås.',
92
+ 'passkey.create': 'Skapa passkey',
93
+ 'passkey.manageHeading': 'Passkeys',
94
+ 'passkey.add': 'Lägg till en passkey',
95
+ 'passkey.remove': 'Ta bort',
96
+ 'passkey.empty': 'Inga passkeys än.',
97
+ 'passkey.lastUsed': 'Senast använd {date}',
98
+ 'passkey.added': 'Tillagd {date}',
99
+ 'passkey.synced': 'Synkas mellan dina enheter',
100
+ 'passkey.lastMethod': 'Den här passkeyn är ditt enda sätt att logga in. Lägg till en till först.',
101
+ 'passkey.exists': 'Den här enheten har redan en passkey.',
102
+ 'passkey.reauthenticate': 'Logga in igen för att ändra dina passkeys.',
103
+ 'passkey.namePlaceholder': 'Namn (valfritt)',
66
104
  };
67
105
  const da = {
68
106
  'signup.closed': 'Tilmelding er lukket for denne app.',
@@ -96,6 +134,25 @@ const da = {
96
134
  'magicLink.finishing': 'Logger dig ind…',
97
135
  'magicLink.wrongDevice': 'Åbn linket på den enhed, hvor du bad om det.',
98
136
  'magicLink.or': 'eller',
137
+ 'passkey.signIn': 'Log ind med en adgangsnøgle',
138
+ 'passkey.cancelled': 'Der blev ikke brugt en adgangsnøgle. Prøv igen, eller log ind på en anden måde.',
139
+ 'passkey.unsupported': 'Denne browser kan ikke bruge adgangsnøgler.',
140
+ 'passkey.setupLinkSend': 'Send mig et link til at oprette en adgangsnøgle',
141
+ 'passkey.setupLinkSent': 'Hvis adressen har en konto, er et link til at oprette en adgangsnøgle på vej. Åbn det på denne enhed.',
142
+ 'passkey.setupHeading': 'Opret en adgangsnøgle',
143
+ 'passkey.setupPrompt': 'Næste gang logger du ind med fingeraftryk, ansigt eller skærmlås.',
144
+ 'passkey.create': 'Opret adgangsnøgle',
145
+ 'passkey.manageHeading': 'Adgangsnøgler',
146
+ 'passkey.add': 'Tilføj en adgangsnøgle',
147
+ 'passkey.remove': 'Fjern',
148
+ 'passkey.empty': 'Ingen adgangsnøgler endnu.',
149
+ 'passkey.lastUsed': 'Sidst brugt {date}',
150
+ 'passkey.added': 'Tilføjet {date}',
151
+ 'passkey.synced': 'Synkroniseres mellem dine enheder',
152
+ 'passkey.lastMethod': 'Denne adgangsnøgle er din eneste måde at logge ind på. Tilføj en anden først.',
153
+ 'passkey.exists': 'Denne enhed har allerede en adgangsnøgle.',
154
+ 'passkey.reauthenticate': 'Log ind igen for at ændre dine adgangsnøgler.',
155
+ 'passkey.namePlaceholder': 'Navn (valgfrit)',
99
156
  };
100
157
  const nb = {
101
158
  'signup.closed': 'Registrering er stengt for denne appen.',
@@ -129,6 +186,25 @@ const nb = {
129
186
  'magicLink.finishing': 'Logger deg inn…',
130
187
  'magicLink.wrongDevice': 'Åpne lenken på enheten der du ba om den.',
131
188
  'magicLink.or': 'eller',
189
+ 'passkey.signIn': 'Logg inn med en passnøkkel',
190
+ 'passkey.cancelled': 'Ingen passnøkkel ble brukt. Prøv igjen, eller logg inn på en annen måte.',
191
+ 'passkey.unsupported': 'Denne nettleseren kan ikke bruke passnøkler.',
192
+ 'passkey.setupLinkSend': 'Send meg en lenke for å opprette en passnøkkel',
193
+ 'passkey.setupLinkSent': 'Hvis adressen har en konto, er en lenke for å opprette en passnøkkel på vei. Åpne den på denne enheten.',
194
+ 'passkey.setupHeading': 'Opprett en passnøkkel',
195
+ 'passkey.setupPrompt': 'Neste gang logger du inn med fingeravtrykk, ansikt eller skjermlås.',
196
+ 'passkey.create': 'Opprett passnøkkel',
197
+ 'passkey.manageHeading': 'Passnøkler',
198
+ 'passkey.add': 'Legg til en passnøkkel',
199
+ 'passkey.remove': 'Fjern',
200
+ 'passkey.empty': 'Ingen passnøkler ennå.',
201
+ 'passkey.lastUsed': 'Sist brukt {date}',
202
+ 'passkey.added': 'Lagt til {date}',
203
+ 'passkey.synced': 'Synkroniseres mellom enhetene dine',
204
+ 'passkey.lastMethod': 'Denne passnøkkelen er din eneste måte å logge inn på. Legg til en annen først.',
205
+ 'passkey.exists': 'Denne enheten har allerede en passnøkkel.',
206
+ 'passkey.reauthenticate': 'Logg inn på nytt for å endre passnøklene dine.',
207
+ 'passkey.namePlaceholder': 'Navn (valgfritt)',
132
208
  };
133
209
  const nl = {
134
210
  'signup.closed': 'Registreren is gesloten voor deze app.',
@@ -162,6 +238,25 @@ const nl = {
162
238
  'magicLink.finishing': 'Je wordt ingelogd…',
163
239
  'magicLink.wrongDevice': 'Open de link op het apparaat waarop je hem hebt aangevraagd.',
164
240
  'magicLink.or': 'of',
241
+ 'passkey.signIn': 'Inloggen met een passkey',
242
+ 'passkey.cancelled': 'Er is geen passkey gebruikt. Probeer het opnieuw of log op een andere manier in.',
243
+ 'passkey.unsupported': 'Deze browser kan geen passkeys gebruiken.',
244
+ 'passkey.setupLinkSend': 'Mail me een link om een passkey in te stellen',
245
+ 'passkey.setupLinkSent': 'Als dit adres een account heeft, is er een link onderweg om een passkey in te stellen. Open hem op dit apparaat.',
246
+ 'passkey.setupHeading': 'Een passkey instellen',
247
+ 'passkey.setupPrompt': 'Log de volgende keer in met je vingerafdruk, gezicht of schermvergrendeling.',
248
+ 'passkey.create': 'Passkey maken',
249
+ 'passkey.manageHeading': 'Passkeys',
250
+ 'passkey.add': 'Passkey toevoegen',
251
+ 'passkey.remove': 'Verwijderen',
252
+ 'passkey.empty': 'Nog geen passkeys.',
253
+ 'passkey.lastUsed': 'Laatst gebruikt {date}',
254
+ 'passkey.added': 'Toegevoegd {date}',
255
+ 'passkey.synced': 'Wordt gesynchroniseerd tussen je apparaten',
256
+ 'passkey.lastMethod': 'Deze passkey is je enige manier om in te loggen. Voeg eerst een andere toe.',
257
+ 'passkey.exists': 'Dit apparaat heeft al een passkey.',
258
+ 'passkey.reauthenticate': 'Log opnieuw in om je passkeys te wijzigen.',
259
+ 'passkey.namePlaceholder': 'Naam (optioneel)',
165
260
  };
166
261
  const de = {
167
262
  'signup.closed': 'Die Registrierung ist für diese App geschlossen.',
@@ -195,6 +290,25 @@ const de = {
195
290
  'magicLink.finishing': 'Du wirst angemeldet…',
196
291
  'magicLink.wrongDevice': 'Öffne den Link auf dem Gerät, auf dem du ihn angefordert hast.',
197
292
  'magicLink.or': 'oder',
293
+ 'passkey.signIn': 'Mit einem Passkey anmelden',
294
+ 'passkey.cancelled': 'Es wurde kein Passkey verwendet. Versuche es erneut oder melde dich anders an.',
295
+ 'passkey.unsupported': 'Dieser Browser kann keine Passkeys verwenden.',
296
+ 'passkey.setupLinkSend': 'Link zum Einrichten eines Passkeys mailen',
297
+ 'passkey.setupLinkSent': 'Wenn diese Adresse ein Konto hat, ist ein Link zum Einrichten eines Passkeys unterwegs. Öffne ihn auf diesem Gerät.',
298
+ 'passkey.setupHeading': 'Passkey einrichten',
299
+ 'passkey.setupPrompt': 'Melde dich nächstes Mal mit Fingerabdruck, Gesicht oder Bildschirmsperre an.',
300
+ 'passkey.create': 'Passkey erstellen',
301
+ 'passkey.manageHeading': 'Passkeys',
302
+ 'passkey.add': 'Passkey hinzufügen',
303
+ 'passkey.remove': 'Entfernen',
304
+ 'passkey.empty': 'Noch keine Passkeys.',
305
+ 'passkey.lastUsed': 'Zuletzt verwendet {date}',
306
+ 'passkey.added': 'Hinzugefügt {date}',
307
+ 'passkey.synced': 'Wird zwischen deinen Geräten synchronisiert',
308
+ 'passkey.lastMethod': 'Dieser Passkey ist deine einzige Möglichkeit, dich anzumelden. Füge zuerst einen weiteren hinzu.',
309
+ 'passkey.exists': 'Dieses Gerät hat bereits einen Passkey.',
310
+ 'passkey.reauthenticate': 'Melde dich erneut an, um deine Passkeys zu ändern.',
311
+ 'passkey.namePlaceholder': 'Name (optional)',
198
312
  };
199
313
  const fi = {
200
314
  'signup.closed': 'Rekisteröityminen on suljettu tässä sovelluksessa.',
@@ -228,6 +342,25 @@ const fi = {
228
342
  'magicLink.finishing': 'Kirjaudutaan sisään…',
229
343
  'magicLink.wrongDevice': 'Avaa linkki laitteella, jolla pyysit sitä.',
230
344
  'magicLink.or': 'tai',
345
+ 'passkey.signIn': 'Kirjaudu sisään pääsyavaimella',
346
+ 'passkey.cancelled': 'Pääsyavainta ei käytetty. Yritä uudelleen tai kirjaudu toisella tavalla.',
347
+ 'passkey.unsupported': 'Tämä selain ei voi käyttää pääsyavaimia.',
348
+ 'passkey.setupLinkSend': 'Lähetä minulle linkki pääsyavaimen luomiseen',
349
+ 'passkey.setupLinkSent': 'Jos osoitteella on tili, linkki pääsyavaimen luomiseen on matkalla. Avaa se tällä laitteella.',
350
+ 'passkey.setupHeading': 'Luo pääsyavain',
351
+ 'passkey.setupPrompt': 'Kirjaudu ensi kerralla sormenjäljellä, kasvoilla tai näytön lukituksella.',
352
+ 'passkey.create': 'Luo pääsyavain',
353
+ 'passkey.manageHeading': 'Pääsyavaimet',
354
+ 'passkey.add': 'Lisää pääsyavain',
355
+ 'passkey.remove': 'Poista',
356
+ 'passkey.empty': 'Ei vielä pääsyavaimia.',
357
+ 'passkey.lastUsed': 'Viimeksi käytetty {date}',
358
+ 'passkey.added': 'Lisätty {date}',
359
+ 'passkey.synced': 'Synkronoidaan laitteidesi välillä',
360
+ 'passkey.lastMethod': 'Tämä pääsyavain on ainoa tapasi kirjautua. Lisää ensin toinen.',
361
+ 'passkey.exists': 'Tällä laitteella on jo pääsyavain.',
362
+ 'passkey.reauthenticate': 'Kirjaudu uudelleen muuttaaksesi pääsyavaimiasi.',
363
+ 'passkey.namePlaceholder': 'Nimi (valinnainen)',
231
364
  };
232
365
  const fr = {
233
366
  'signup.closed': 'Les inscriptions sont fermées pour cette application.',
@@ -261,6 +394,25 @@ const fr = {
261
394
  'magicLink.finishing': 'Connexion en cours…',
262
395
  'magicLink.wrongDevice': 'Ouvre le lien sur l\'appareil où tu l\'as demandé.',
263
396
  'magicLink.or': 'ou',
397
+ 'passkey.signIn': "Se connecter avec une clé d'accès",
398
+ 'passkey.cancelled': "Aucune clé d'accès n'a été utilisée. Réessayez ou connectez-vous autrement.",
399
+ 'passkey.unsupported': "Ce navigateur ne peut pas utiliser de clés d'accès.",
400
+ 'passkey.setupLinkSend': "M'envoyer un lien pour créer une clé d'accès",
401
+ 'passkey.setupLinkSent': "Si cette adresse a un compte, un lien pour créer une clé d'accès est en route. Ouvrez-le sur cet appareil.",
402
+ 'passkey.setupHeading': "Créer une clé d'accès",
403
+ 'passkey.setupPrompt': "La prochaine fois, connectez-vous avec votre empreinte, votre visage ou le verrouillage de l'écran.",
404
+ 'passkey.create': "Créer une clé d'accès",
405
+ 'passkey.manageHeading': "Clés d'accès",
406
+ 'passkey.add': "Ajouter une clé d'accès",
407
+ 'passkey.remove': 'Supprimer',
408
+ 'passkey.empty': "Aucune clé d'accès pour l'instant.",
409
+ 'passkey.lastUsed': 'Dernière utilisation {date}',
410
+ 'passkey.added': 'Ajoutée {date}',
411
+ 'passkey.synced': 'Synchronisée entre vos appareils',
412
+ 'passkey.lastMethod': "Cette clé d'accès est votre seul moyen de connexion. Ajoutez-en une autre d'abord.",
413
+ 'passkey.exists': "Cet appareil a déjà une clé d'accès.",
414
+ 'passkey.reauthenticate': "Reconnectez-vous pour modifier vos clés d'accès.",
415
+ 'passkey.namePlaceholder': 'Nom (facultatif)',
264
416
  };
265
417
  const es = {
266
418
  'signup.closed': 'El registro está cerrado para esta aplicación.',
@@ -294,6 +446,25 @@ const es = {
294
446
  'magicLink.finishing': 'Iniciando sesión…',
295
447
  'magicLink.wrongDevice': 'Abre el enlace en el dispositivo donde lo pediste.',
296
448
  'magicLink.or': 'o',
449
+ 'passkey.signIn': 'Iniciar sesión con una llave de acceso',
450
+ 'passkey.cancelled': 'No se usó ninguna llave de acceso. Inténtalo de nuevo o inicia sesión de otra forma.',
451
+ 'passkey.unsupported': 'Este navegador no puede usar llaves de acceso.',
452
+ 'passkey.setupLinkSend': 'Envíame un enlace para crear una llave de acceso',
453
+ 'passkey.setupLinkSent': 'Si esta dirección tiene una cuenta, va de camino un enlace para crear una llave de acceso. Ábrelo en este dispositivo.',
454
+ 'passkey.setupHeading': 'Crear una llave de acceso',
455
+ 'passkey.setupPrompt': 'La próxima vez, inicia sesión con tu huella, tu cara o el bloqueo de pantalla.',
456
+ 'passkey.create': 'Crear llave de acceso',
457
+ 'passkey.manageHeading': 'Llaves de acceso',
458
+ 'passkey.add': 'Añadir una llave de acceso',
459
+ 'passkey.remove': 'Quitar',
460
+ 'passkey.empty': 'Aún no hay llaves de acceso.',
461
+ 'passkey.lastUsed': 'Último uso {date}',
462
+ 'passkey.added': 'Añadida {date}',
463
+ 'passkey.synced': 'Se sincroniza entre tus dispositivos',
464
+ 'passkey.lastMethod': 'Esta llave de acceso es tu única forma de iniciar sesión. Añade otra primero.',
465
+ 'passkey.exists': 'Este dispositivo ya tiene una llave de acceso.',
466
+ 'passkey.reauthenticate': 'Vuelve a iniciar sesión para cambiar tus llaves de acceso.',
467
+ 'passkey.namePlaceholder': 'Nombre (opcional)',
297
468
  };
298
469
  const it = {
299
470
  'signup.closed': 'La registrazione è chiusa per questa app.',
@@ -327,6 +498,25 @@ const it = {
327
498
  'magicLink.finishing': 'Accesso in corso…',
328
499
  'magicLink.wrongDevice': 'Apri il link sul dispositivo da cui l\'hai richiesto.',
329
500
  'magicLink.or': 'oppure',
501
+ 'passkey.signIn': 'Accedi con una passkey',
502
+ 'passkey.cancelled': 'Non è stata usata nessuna passkey. Riprova o accedi in un altro modo.',
503
+ 'passkey.unsupported': 'Questo browser non può usare le passkey.',
504
+ 'passkey.setupLinkSend': 'Inviami un link per creare una passkey',
505
+ 'passkey.setupLinkSent': 'Se questo indirizzo ha un account, è in arrivo un link per creare una passkey. Aprilo su questo dispositivo.',
506
+ 'passkey.setupHeading': 'Crea una passkey',
507
+ 'passkey.setupPrompt': 'La prossima volta accedi con impronta, volto o blocco schermo.',
508
+ 'passkey.create': 'Crea passkey',
509
+ 'passkey.manageHeading': 'Passkey',
510
+ 'passkey.add': 'Aggiungi una passkey',
511
+ 'passkey.remove': 'Rimuovi',
512
+ 'passkey.empty': 'Ancora nessuna passkey.',
513
+ 'passkey.lastUsed': 'Ultimo uso {date}',
514
+ 'passkey.added': 'Aggiunta {date}',
515
+ 'passkey.synced': 'Sincronizzata tra i tuoi dispositivi',
516
+ 'passkey.lastMethod': "Questa passkey è il tuo unico modo per accedere. Aggiungine prima un'altra.",
517
+ 'passkey.exists': 'Questo dispositivo ha già una passkey.',
518
+ 'passkey.reauthenticate': 'Accedi di nuovo per modificare le tue passkey.',
519
+ 'passkey.namePlaceholder': 'Nome (facoltativo)',
330
520
  };
331
521
  const pt = {
332
522
  'signup.closed': 'O registo está fechado para esta aplicação.',
@@ -360,6 +550,25 @@ const pt = {
360
550
  'magicLink.finishing': 'A iniciar sessão…',
361
551
  'magicLink.wrongDevice': 'Abre o link no dispositivo onde o pediste.',
362
552
  'magicLink.or': 'ou',
553
+ 'passkey.signIn': 'Entrar com uma chave de acesso',
554
+ 'passkey.cancelled': 'Nenhuma chave de acesso foi usada. Tente novamente ou entre de outra forma.',
555
+ 'passkey.unsupported': 'Este navegador não pode usar chaves de acesso.',
556
+ 'passkey.setupLinkSend': 'Enviar-me um link para criar uma chave de acesso',
557
+ 'passkey.setupLinkSent': 'Se este endereço tiver uma conta, um link para criar uma chave de acesso está a caminho. Abra-o neste dispositivo.',
558
+ 'passkey.setupHeading': 'Criar uma chave de acesso',
559
+ 'passkey.setupPrompt': 'Da próxima vez, entre com a sua impressão digital, rosto ou bloqueio de ecrã.',
560
+ 'passkey.create': 'Criar chave de acesso',
561
+ 'passkey.manageHeading': 'Chaves de acesso',
562
+ 'passkey.add': 'Adicionar uma chave de acesso',
563
+ 'passkey.remove': 'Remover',
564
+ 'passkey.empty': 'Ainda não há chaves de acesso.',
565
+ 'passkey.lastUsed': 'Última utilização {date}',
566
+ 'passkey.added': 'Adicionada {date}',
567
+ 'passkey.synced': 'Sincronizada entre os seus dispositivos',
568
+ 'passkey.lastMethod': 'Esta chave de acesso é a sua única forma de entrar. Adicione outra primeiro.',
569
+ 'passkey.exists': 'Este dispositivo já tem uma chave de acesso.',
570
+ 'passkey.reauthenticate': 'Entre novamente para alterar as suas chaves de acesso.',
571
+ 'passkey.namePlaceholder': 'Nome (opcional)',
363
572
  };
364
573
  const pl = {
365
574
  'signup.closed': 'Rejestracja w tej aplikacji jest zamknięta.',
@@ -393,6 +602,25 @@ const pl = {
393
602
  'magicLink.finishing': 'Logowanie…',
394
603
  'magicLink.wrongDevice': 'Otwórz link na urządzeniu, na którym o niego poproszono.',
395
604
  'magicLink.or': 'lub',
605
+ 'passkey.signIn': 'Zaloguj się kluczem dostępu',
606
+ 'passkey.cancelled': 'Nie użyto klucza dostępu. Spróbuj ponownie lub zaloguj się inaczej.',
607
+ 'passkey.unsupported': 'Ta przeglądarka nie obsługuje kluczy dostępu.',
608
+ 'passkey.setupLinkSend': 'Wyślij mi link do utworzenia klucza dostępu',
609
+ 'passkey.setupLinkSent': 'Jeśli ten adres ma konto, link do utworzenia klucza dostępu jest w drodze. Otwórz go na tym urządzeniu.',
610
+ 'passkey.setupHeading': 'Utwórz klucz dostępu',
611
+ 'passkey.setupPrompt': 'Następnym razem zaloguj się odciskiem palca, twarzą lub blokadą ekranu.',
612
+ 'passkey.create': 'Utwórz klucz dostępu',
613
+ 'passkey.manageHeading': 'Klucze dostępu',
614
+ 'passkey.add': 'Dodaj klucz dostępu',
615
+ 'passkey.remove': 'Usuń',
616
+ 'passkey.empty': 'Brak kluczy dostępu.',
617
+ 'passkey.lastUsed': 'Ostatnio użyty {date}',
618
+ 'passkey.added': 'Dodany {date}',
619
+ 'passkey.synced': 'Synchronizowany między Twoimi urządzeniami',
620
+ 'passkey.lastMethod': 'Ten klucz dostępu to Twój jedyny sposób logowania. Najpierw dodaj inny.',
621
+ 'passkey.exists': 'To urządzenie ma już klucz dostępu.',
622
+ 'passkey.reauthenticate': 'Zaloguj się ponownie, aby zmienić klucze dostępu.',
623
+ 'passkey.namePlaceholder': 'Nazwa (opcjonalnie)',
396
624
  };
397
625
  /** The plugin's copy by primary language subtag. */
398
626
  export const PLUGIN_LOCALES = { da, de, en, es, fi, fr, it, nb, nl, pl, pt, sv };
@@ -5,7 +5,7 @@
5
5
  * list, so no page an email links to can be forgotten.
6
6
  */
7
7
  import type { EmailLink } from '@nebulr-group/bridge-auth-core';
8
- export declare const AUTH_PAGES: readonly ["sign-in", "sign-up", "verify-email", "forgot-password", "set-password", "invite", "workspaces", "handoff", "magic-link"];
8
+ export declare const AUTH_PAGES: readonly ["sign-in", "sign-up", "verify-email", "forgot-password", "set-password", "invite", "workspaces", "handoff", "magic-link", "passkey-setup", "callback"];
9
9
  export type AuthPage = (typeof AUTH_PAGES)[number];
10
10
  export declare const BILLING_PAGES: readonly ["manage", "plan", "success", "error"];
11
11
  export type BillingPage = (typeof BILLING_PAGES)[number];
@@ -8,6 +8,8 @@ export const AUTH_PAGES = [
8
8
  'workspaces',
9
9
  'handoff',
10
10
  'magic-link',
11
+ 'passkey-setup',
12
+ 'callback',
11
13
  ];
12
14
  export const BILLING_PAGES = ['manage', 'plan', 'success', 'error'];
13
15
  /** The catch-all parameter's name: `[...bridge]`. */
@@ -43,6 +45,8 @@ export function pageForLink(link) {
43
45
  return 'invite';
44
46
  case 'magic-link':
45
47
  return 'magic-link';
48
+ case 'passkey-setup':
49
+ return 'passkey-setup';
46
50
  }
47
51
  }
48
52
  /** Whether `path` is `base` or under it. */
package/dist/index.d.ts CHANGED
@@ -33,11 +33,15 @@ export { default as SignInForm } from './components/auth/SignInForm.svelte';
33
33
  export { default as SignUpForm } from './components/auth/SignUpForm.svelte';
34
34
  export { default as VerifyEmail } from './components/auth/VerifyEmail.svelte';
35
35
  export { default as MagicLinkLanding } from './components/auth/MagicLinkLanding.svelte';
36
+ export { default as PasskeySetupLanding } from './components/auth/PasskeySetupLanding.svelte';
37
+ export { default as PasskeyManager } from './components/auth/PasskeyManager.svelte';
36
38
  export { default as ForgotPassword } from './components/auth/ForgotPassword.svelte';
37
39
  export { default as SetPassword } from './components/auth/SetPassword.svelte';
38
40
  export { default as InviteLanding } from './components/auth/InviteLanding.svelte';
39
41
  export { default as WorkspaceChooser } from './components/auth/WorkspaceChooser.svelte';
40
42
  export { default as HandoffSignIn } from './components/auth/HandoffSignIn.svelte';
43
+ export { default as HostedSignIn } from './components/auth/HostedSignIn.svelte';
44
+ export { default as HostedCallback } from './components/auth/HostedCallback.svelte';
41
45
  export { default as SignOutButton } from './components/auth/SignOutButton.svelte';
42
46
  export { default as ProfileName } from './components/auth/ProfileName.svelte';
43
47
  export { default as FeatureFlag } from './components/flags/FeatureFlag.svelte';
package/dist/index.js CHANGED
@@ -31,11 +31,15 @@ export { default as SignInForm } from './components/auth/SignInForm.svelte';
31
31
  export { default as SignUpForm } from './components/auth/SignUpForm.svelte';
32
32
  export { default as VerifyEmail } from './components/auth/VerifyEmail.svelte';
33
33
  export { default as MagicLinkLanding } from './components/auth/MagicLinkLanding.svelte';
34
+ export { default as PasskeySetupLanding } from './components/auth/PasskeySetupLanding.svelte';
35
+ export { default as PasskeyManager } from './components/auth/PasskeyManager.svelte';
34
36
  export { default as ForgotPassword } from './components/auth/ForgotPassword.svelte';
35
37
  export { default as SetPassword } from './components/auth/SetPassword.svelte';
36
38
  export { default as InviteLanding } from './components/auth/InviteLanding.svelte';
37
39
  export { default as WorkspaceChooser } from './components/auth/WorkspaceChooser.svelte';
38
40
  export { default as HandoffSignIn } from './components/auth/HandoffSignIn.svelte';
41
+ export { default as HostedSignIn } from './components/auth/HostedSignIn.svelte';
42
+ export { default as HostedCallback } from './components/auth/HostedCallback.svelte';
39
43
  export { default as SignOutButton } from './components/auth/SignOutButton.svelte';
40
44
  export { default as ProfileName } from './components/auth/ProfileName.svelte';
41
45
  export { default as FeatureFlag } from './components/flags/FeatureFlag.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebulr-group/bridge-svelte",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.6",
4
4
  "description": "The Bridge for SvelteKit: sign-in in your own pages, workspaces, flag-based route guards, plans and checkout, the team panel and live updates, on one setting: the issuer.",
5
5
  "author": "Iman Pouya",
6
6
  "license": "MIT",
@@ -60,7 +60,7 @@
60
60
  "@sveltejs/kit": "^2.0.0"
61
61
  },
62
62
  "dependencies": {
63
- "@nebulr-group/bridge-auth-core": "1.0.0-alpha.4"
63
+ "@nebulr-group/bridge-auth-core": "1.0.0-alpha.6"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@sveltejs/kit": "^2.16.0",