@nebulr-group/bridge-svelte 1.0.0-alpha.3 → 1.0.0-alpha.5

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.
@@ -5,7 +5,7 @@
5
5
  <BridgeAuthRoutes />
6
6
 
7
7
  Serves sign-in, sign-up, verify-email, forgot-password, set-password,
8
- invite, workspaces and handoff. An unknown page gets the app's own 404.
8
+ invite, workspaces, handoff, magic-link (a sign-in link's landing) and passkey-setup (a passkey setup link's landing). An unknown page gets the app's own 404.
9
9
 
10
10
  Customising, in rungs:
11
11
  1. `--bridge-*` CSS tokens restyle the forms.
@@ -34,6 +34,8 @@
34
34
  import InviteLanding from './InviteLanding.svelte';
35
35
  import WorkspaceChooser from './WorkspaceChooser.svelte';
36
36
  import HandoffSignIn from './HandoffSignIn.svelte';
37
+ import MagicLinkLanding from './MagicLinkLanding.svelte';
38
+ import PasskeySetupLanding from './PasskeySetupLanding.svelte';
37
39
 
38
40
  interface Props {
39
41
  /** Replaces everything around the form, on every page. */
@@ -71,6 +73,10 @@
71
73
  <SetPassword headingSnippet={pageHeading} {messages} />
72
74
  {:else if p === 'invite'}
73
75
  <InviteLanding headingSnippet={pageHeading} {messages} />
76
+ {:else if p === 'magic-link'}
77
+ <MagicLinkLanding headingSnippet={pageHeading} {messages} />
78
+ {:else if p === 'passkey-setup'}
79
+ <PasskeySetupLanding headingSnippet={pageHeading} {messages} />
74
80
  {:else if p === 'handoff'}
75
81
  <HandoffSignIn headingSnippet={pageHeading} {messages} />
76
82
  {:else if p === 'workspaces'}
@@ -0,0 +1,114 @@
1
+ <!--
2
+ Signs in from a sign-in link (a magic link), on the device that asked for
3
+ it. Opened on another device it says so, and the link still works on the
4
+ right one. The link works once: opened again, it says the link is no
5
+ longer valid.
6
+ With `storage: 'memory'` the verifier waited in localStorage, which every
7
+ tab of the origin shares, so the tab the link opens in signs in itself and
8
+ holds the session in its own memory.
9
+ -->
10
+ <script lang="ts">
11
+ import type { Snippet } from 'svelte';
12
+ import type { HTMLAttributes } from 'svelte/elements';
13
+ import { onMount } from 'svelte';
14
+ import { goto } from '$app/navigation';
15
+ import { isBridgeError, type SignInStep, type WorkspaceChoice } from '@nebulr-group/bridge-auth-core';
16
+ import { getBridge, peekConfig } from '../../core/client.js';
17
+ import type { BridgeMessages } from '../../core/config.js';
18
+ import { errorMessage, translator } from '../../core/i18n.js';
19
+ import AuthFormWrapper from '../shared/AuthFormWrapper.svelte';
20
+ import Alert from '../shared/Alert.svelte';
21
+ import Spinner from '../shared/Spinner.svelte';
22
+ import WorkspaceChooser from './WorkspaceChooser.svelte';
23
+ import { takeEmailLink } from './email-link.js';
24
+ import { bounded, leave } from './finish-link.js';
25
+
26
+ interface Props extends HTMLAttributes<HTMLDivElement> {
27
+ /** The link's token. @default read from the page's address */
28
+ token?: string;
29
+ headingSnippet?: Snippet;
30
+ /** Called once signed in. Without it, the page goes to `auth.afterSignIn`. */
31
+ onSignIn?: () => void;
32
+ onError?: (error: unknown) => void;
33
+ messages?: BridgeMessages;
34
+ }
35
+
36
+ let { token = undefined, headingSnippet, onSignIn, onError, messages, class: className, style, ...rest }: Props = $props();
37
+
38
+ const t = $derived(translator(messages));
39
+ const config = peekConfig();
40
+ const authBase = config?.authBase ?? '/auth';
41
+
42
+ type State =
43
+ | { step: 'working' }
44
+ | { step: 'signed-in'; to: string }
45
+ | { step: 'workspace'; workspaces: readonly WorkspaceChoice[]; choose: (id: string) => Promise<SignInStep> }
46
+ | { step: 'failed'; message: string; kind: string | null };
47
+ let view = $state<State>({ step: 'working' });
48
+
49
+ async function finish() {
50
+ if (onSignIn) {
51
+ onSignIn();
52
+ return;
53
+ }
54
+ // Signing in runs the route guard again, and that newer navigation can cancel this one: go again, then offer a link.
55
+ const to = config?.afterSignIn ?? '/';
56
+ const here = location.pathname;
57
+ if (!(await leave(() => goto(to, { invalidateAll: true }), () => location.pathname !== here))) view = { step: 'signed-in', to };
58
+ }
59
+
60
+ function fail(error: unknown) {
61
+ const kind = isBridgeError(error) ? error.kind : null;
62
+ view = { step: 'failed', message: kind === 'wrong-device' ? t('magicLink.wrongDevice') : errorMessage(error, t, 'link.error.invalid'), kind };
63
+ onError?.(error);
64
+ }
65
+
66
+ async function follow(step: SignInStep) {
67
+ if (step.done) await finish();
68
+ else view = { step: 'workspace', workspaces: step.workspaces, choose: step.choose };
69
+ }
70
+
71
+ onMount(() => {
72
+ const found = token ?? takeEmailLink('magic-link');
73
+ if (found === null) {
74
+ view = { step: 'failed', message: t('verify.missingLink'), kind: null };
75
+ return;
76
+ }
77
+ bounded(getBridge().magicLink.finish(found)).then(follow).catch(fail);
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-magic-link="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 === 'signed-in'}
98
+ <AuthFormWrapper heading={t('login.heading')} {headingSnippet} class={className} {style} data-bridge-magic-link="signed-in" {...rest}>
99
+ <div class="bridge-form-footer">
100
+ <a href={view.to} class="bridge-link">{t('invite.continue')}</a>
101
+ </div>
102
+ </AuthFormWrapper>
103
+ {:else if view.step === 'workspace'}
104
+ <AuthFormWrapper heading={t('workspace.chooseHeading')} {headingSnippet} class={className} {style} data-bridge-magic-link="workspace" {...rest}>
105
+ <WorkspaceChooser workspaces={view.workspaces} onChoose={choose} {messages} />
106
+ </AuthFormWrapper>
107
+ {:else}
108
+ <AuthFormWrapper heading={t('login.heading')} {headingSnippet} class={className} {style} data-bridge-magic-link="failed" data-error-kind={view.kind} {...rest}>
109
+ <Alert variant="error">{view.message}</Alert>
110
+ <div class="bridge-form-footer">
111
+ <a href={`${authBase}/sign-in`} class="bridge-link">{t('action.backToSignIn')}</a>
112
+ </div>
113
+ </AuthFormWrapper>
114
+ {/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 MagicLinkLanding: import("svelte").Component<Props, {}, "">;
14
+ type MagicLinkLanding = ReturnType<typeof MagicLinkLanding>;
15
+ export default MagicLinkLanding;
@@ -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;
@@ -44,7 +44,7 @@
44
44
  checked = true;
45
45
  getBridge()
46
46
  .signIn.options()
47
- .then((found) => (minLength = found.password.minLength))
47
+ .then((found) => (minLength = found.password?.minLength ?? minLength))
48
48
  .catch(() => undefined);
49
49
  });
50
50
 
@@ -1,19 +1,24 @@
1
1
  <!--
2
- Sign in with email and password, then pick a workspace when the person has
3
- several. On success it calls `onSignIn`, or goes to the page the person was
4
- sent here from (else `auth.afterSignIn`).
2
+ Sign in with email and password, or with a sign-in link sent by email (a
3
+ magic link), then pick a workspace when the person has several. On success
4
+ it calls `onSignIn`, or goes to the page the person was sent here from
5
+ (else `auth.afterSignIn`).
5
6
 
6
- Today's method is password. Other methods (email codes, passkeys, company
7
- login, a second step) arrive as new sign-in steps; this form shows the
8
- methods the app's sign-in options list, so they join without a new API.
7
+ The form shows the methods the app's sign-in options list: the password
8
+ fields when it offers passwords, "Email me a sign-in link" when it offers
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.
9
14
  -->
10
15
  <script lang="ts">
11
16
  import type { Snippet } from 'svelte';
12
17
  import type { HTMLAttributes } from 'svelte/elements';
13
- import { onMount } from 'svelte';
18
+ import { onDestroy, onMount } from 'svelte';
14
19
  import { goto } from '$app/navigation';
15
20
  import { page } from '$app/state';
16
- import { readReturnTo, type SignInOptions, type SignInStep, type WorkspaceChoice } from '@nebulr-group/bridge-auth-core';
21
+ import { isBridgeError, readReturnTo, type SignInOptions, type SignInStep, type WorkspaceChoice } from '@nebulr-group/bridge-auth-core';
17
22
  import { get } from 'svelte/store';
18
23
  import { getBridge, peekConfig, takeEndedReason } from '../../core/client.js';
19
24
  import { session } from '../../core/stores.js';
@@ -71,12 +76,31 @@
71
76
  let loading = $state(false);
72
77
  let failure = $state<string | null>(null);
73
78
  let notice = $state<string | null>(null);
79
+ let linkSent = $state(false);
74
80
  let options = $state<SignInOptions | null>(null);
75
81
  let choice = $state<{ workspaces: readonly WorkspaceChoice[]; choose: (id: string) => Promise<SignInStep> } | null>(null);
76
82
  let settled = $state(false);
77
83
 
78
84
  const signUpShown = $derived(showSignupLink ?? options?.signUp ?? true);
79
85
  const passwordOffered = $derived(options === null || options.methods.includes('password'));
86
+ const linkOffered = $derived(options !== null && options.methods.includes('magicLink'));
87
+ let passkeySupported = $state(false);
88
+ let setupLinkSent = $state(false);
89
+ const passkeysOffered = $derived(passkeySupported && options !== null && options.methods.includes('passkeys'));
90
+ const emailAutocomplete = $derived(passkeysOffered ? 'username webauthn' : 'username');
91
+ let autofillStarted = false;
92
+
93
+ /** Waits for the person to pick a passkey from the email field's autofill list. A closed list is not an error. */
94
+ async function startAutofill() {
95
+ const bridge = getBridge();
96
+ if (autofillStarted || !(await bridge.passkeys.autofillSupported())) return;
97
+ autofillStarted = true;
98
+ try {
99
+ await follow(await bridge.passkeys.signIn({ autofill: true, ...(workspace ? { workspace } : {}) }));
100
+ } catch (error) {
101
+ if (!isBridgeError(error, 'cancelled')) fail(error);
102
+ }
103
+ }
80
104
 
81
105
  onMount(() => {
82
106
  // Why the last session ended: told by the client as it happened, or read from the session on a fresh page.
@@ -84,12 +108,54 @@
84
108
  const ended = takeEndedReason() ?? (now.status === 'signed-out' ? now.reason : null);
85
109
  if (ended === 'session-ended') notice = t('session.ended');
86
110
  if (ended === 'access-removed') notice = t('session.accessRemoved');
87
- getBridge()
88
- .signIn.options()
89
- .then((found) => (options = found))
111
+ const bridge = getBridge();
112
+ bridge.signIn
113
+ .options()
114
+ .then(async (found) => {
115
+ options = found;
116
+ if (!found.methods.includes('passkeys')) return;
117
+ passkeySupported = await bridge.passkeys.supported();
118
+ if (passkeySupported) void startAutofill();
119
+ })
90
120
  .catch(() => undefined);
91
121
  });
92
122
 
123
+ onDestroy(() => {
124
+ // An autofill wait must not outlive the form.
125
+ if (autofillStarted) void getBridge().passkeys.cancel();
126
+ });
127
+
128
+ /** Signs in with a passkey from the browser's dialog: a phone, a security key, or this device. */
129
+ async function signInWithPasskey() {
130
+ if (loading) return;
131
+ failure = null;
132
+ notice = null;
133
+ loading = true;
134
+ try {
135
+ await follow(await getBridge().passkeys.signIn({ ...(email.trim() ? { email: email.trim() } : {}), ...(workspace ? { workspace } : {}) }));
136
+ } catch (error) {
137
+ if (isBridgeError(error, 'cancelled')) notice = t('passkey.cancelled');
138
+ else fail(error);
139
+ } finally {
140
+ loading = false;
141
+ }
142
+ }
143
+
144
+ /** Emails a link to set up a passkey on this device. The answer is the same whether or not the address has an account. */
145
+ async function sendSetupLink() {
146
+ if (loading || !email.trim()) return;
147
+ failure = null;
148
+ loading = true;
149
+ try {
150
+ await getBridge().passkeys.setupLink.request(email.trim());
151
+ setupLinkSent = true;
152
+ } catch (error) {
153
+ fail(error);
154
+ } finally {
155
+ loading = false;
156
+ }
157
+ }
158
+
93
159
  function finish() {
94
160
  settled = true;
95
161
  if (onSignIn) {
@@ -128,6 +194,23 @@
128
194
  }
129
195
  }
130
196
 
197
+ /** Asks for a sign-in link to the address typed. The answer is the same whether or not it has an account. */
198
+ async function sendLink(event?: Event) {
199
+ event?.preventDefault();
200
+ if (loading || !email.trim()) return;
201
+ failure = null;
202
+ notice = null;
203
+ loading = true;
204
+ try {
205
+ await getBridge().magicLink.start(email.trim());
206
+ linkSent = true;
207
+ } catch (error) {
208
+ fail(error);
209
+ } finally {
210
+ loading = false;
211
+ }
212
+ }
213
+
131
214
  async function choose(id: string) {
132
215
  if (choice === null) return;
133
216
  try {
@@ -161,14 +244,18 @@
161
244
  >
162
245
  {#if notice}<Alert variant="info">{notice}</Alert>{/if}
163
246
  {#if failure}<Alert variant="error">{failure}</Alert>{/if}
164
- {#if passwordOffered}
247
+ {#if setupLinkSent}
248
+ <Alert variant="info">{t('passkey.setupLinkSent')}</Alert>
249
+ {:else if linkSent}
250
+ <Alert variant="info">{t('magicLink.sent')}</Alert>
251
+ {:else if passwordOffered}
165
252
  <form onsubmit={submit}>
166
253
  <div class="bridge-form-group">
167
254
  <label for="login-email">{t('field.email')}</label>
168
255
  <input
169
256
  id="login-email"
170
257
  type="email"
171
- autocomplete="username"
258
+ autocomplete={emailAutocomplete}
172
259
  placeholder={t('placeholder.email')}
173
260
  required
174
261
  bind:value={email}
@@ -196,7 +283,48 @@
196
283
  <a href={forgotPasswordHref ?? `${authBase}/forgot-password`} class="bridge-link">{t('login.forgotPassword')}</a>
197
284
  </div>
198
285
  {/if}
286
+ {#if linkOffered}
287
+ <div class="bridge-divider" data-bridge-sign-in-or>{t('magicLink.or')}</div>
288
+ <button type="button" class="bridge-btn bridge-btn-secondary" data-bridge-magic-link-send onclick={sendLink} disabled={loading || !email.trim()}>
289
+ {t('magicLink.send')}
290
+ </button>
291
+ {/if}
292
+ </form>
293
+ {:else if linkOffered}
294
+ <form onsubmit={sendLink} data-bridge-magic-link-form>
295
+ <div class="bridge-form-group">
296
+ <label for="login-email">{t('field.email')}</label>
297
+ <input
298
+ id="login-email"
299
+ type="email"
300
+ autocomplete={emailAutocomplete}
301
+ placeholder={t('placeholder.email')}
302
+ required
303
+ bind:value={email}
304
+ disabled={loading}
305
+ />
306
+ </div>
307
+ <button type="submit" class="bridge-btn bridge-btn-primary" data-bridge-magic-link-send disabled={loading || !email.trim()}>
308
+ {#if loading}<Spinner size={16} />{/if} {t('magicLink.send')}
309
+ </button>
199
310
  </form>
311
+ {:else if passkeysOffered}
312
+ <form onsubmit={(event) => { event.preventDefault(); void signInWithPasskey(); }} data-bridge-passkey-form>
313
+ <div class="bridge-form-group">
314
+ <label for="login-email">{t('field.email')}</label>
315
+ <input id="login-email" type="email" autocomplete={emailAutocomplete} placeholder={t('placeholder.email')} bind:value={email} disabled={loading} />
316
+ </div>
317
+ </form>
318
+ {/if}
319
+
320
+ {#if passkeysOffered && !linkSent && !setupLinkSent}
321
+ {#if passwordOffered || linkOffered}<div class="bridge-divider" data-bridge-sign-in-or>{t('magicLink.or')}</div>{/if}
322
+ <button type="button" class="bridge-btn {passwordOffered || linkOffered ? 'bridge-btn-secondary' : 'bridge-btn-primary'}" data-bridge-passkey-sign-in onclick={signInWithPasskey} disabled={loading}>
323
+ {t('passkey.signIn')}
324
+ </button>
325
+ <div class="bridge-forgot-row">
326
+ <button type="button" class="bridge-link" data-bridge-passkey-setup-link onclick={sendSetupLink} disabled={loading || !email.trim()}>{t('passkey.setupLinkSend')}</button>
327
+ </div>
200
328
  {/if}
201
329
 
202
330
  {#if footer}
@@ -81,7 +81,9 @@
81
81
  let sentTo = $state<string | null>(null);
82
82
  let options = $state<SignInOptions | null>(null);
83
83
 
84
- const minLength = $derived(options?.password.minLength ?? 8);
84
+ const minLength = $derived(options?.password?.minLength ?? 8);
85
+ /** An app that offers sign-in links only takes no password: the person signs in by link. */
86
+ const passwordOffered = $derived(options === null || options.methods.includes('password'));
85
87
  // An invite is its own way in, whether or not the app takes sign-ups.
86
88
  const closed = $derived(!invite && options !== null && !options.signUp);
87
89
  let stopRelay: (() => void) | null = null;
@@ -98,11 +100,12 @@
98
100
  event.preventDefault();
99
101
  if (loading) return;
100
102
  failure = null;
101
- if (password.length < minLength) {
103
+ if (passwordOffered && password.length < minLength) {
102
104
  failure = t('password.tooShort', { count: minLength });
103
105
  return;
104
106
  }
105
107
  loading = true;
108
+ const secret = passwordOffered ? { password } : {};
106
109
  const address = email.trim();
107
110
  const names = {
108
111
  ...(firstName.trim() ? { firstName: firstName.trim() } : {}),
@@ -111,14 +114,14 @@
111
114
  try {
112
115
  if (invite) {
113
116
  // Signed in at once, in the inviting workspace: the invite's link proved the address.
114
- await getBridge().invites.signUp({ token: invite, password, ...names });
117
+ await getBridge().invites.signUp({ token: invite, ...secret, ...names });
115
118
  if (onSignIn) onSignIn();
116
119
  else void goto(config?.afterSignIn ?? '/', { invalidateAll: true });
117
120
  return;
118
121
  }
119
122
  await getBridge().signUp.start({
120
123
  email: address,
121
- password,
124
+ ...secret,
122
125
  ...names,
123
126
  ...(workspace === 'ask' ? { workspace: workspaceName.trim() || true } : workspace ? { workspace: true } : {}),
124
127
  });
@@ -172,6 +175,7 @@
172
175
  <input id="signup-email" type="email" autocomplete="email" placeholder={t('placeholder.email')} required bind:value={email} disabled={loading} />
173
176
  </div>
174
177
  {/if}
178
+ {#if passwordOffered}
175
179
  <div class="bridge-form-group">
176
180
  <label for="signup-password">{t('field.password')}</label>
177
181
  <PasswordInput
@@ -186,13 +190,14 @@
186
190
  hideLabel={t('action.hidePassword')}
187
191
  />
188
192
  </div>
193
+ {/if}
189
194
  {#if workspace === 'ask' && !invite}
190
195
  <div class="bridge-form-group">
191
196
  <label for="signup-workspace">{t('field.workspaceName')}</label>
192
197
  <input id="signup-workspace" type="text" autocomplete="organization" bind:value={workspaceName} disabled={loading} />
193
198
  </div>
194
199
  {/if}
195
- <button type="submit" class="bridge-btn bridge-btn-primary" disabled={loading || (!invite && !email.trim()) || !password}>
200
+ <button type="submit" class="bridge-btn bridge-btn-primary" disabled={loading || (!invite && !email.trim()) || (passwordOffered && !password)}>
196
201
  {#if loading}<Spinner size={16} />{:else}{t('signup.submit')}{/if}
197
202
  </button>
198
203
  </form>
@@ -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';
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>>;
@@ -25,6 +25,30 @@ const en = {
25
25
  'workspace.current': 'Current',
26
26
  'password.tooShort': 'Use at least {count} characters.',
27
27
  'feature.upgrade': 'Upgrade to use this',
28
+ 'magicLink.send': 'Email me a sign-in link',
29
+ 'magicLink.sent': 'If this address has an account, a sign-in link is on its way. Open it on this device.',
30
+ 'magicLink.finishing': 'Signing you in…',
31
+ 'magicLink.wrongDevice': 'Open the link on the device where you asked for it.',
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)',
28
52
  };
29
53
  const sv = {
30
54
  'signup.closed': 'Registrering är stängd för den här appen.',
@@ -53,6 +77,30 @@ const sv = {
53
77
  'workspace.current': 'Aktuell',
54
78
  'password.tooShort': 'Använd minst {count} tecken.',
55
79
  'feature.upgrade': 'Uppgradera för att använda detta',
80
+ 'magicLink.send': 'Mejla mig en inloggningslänk',
81
+ 'magicLink.sent': 'Om adressen har ett konto är en inloggningslänk på väg. Öppna den på den här enheten.',
82
+ 'magicLink.finishing': 'Loggar in dig…',
83
+ 'magicLink.wrongDevice': 'Öppna länken på enheten där du bad om den.',
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)',
56
104
  };
57
105
  const da = {
58
106
  'signup.closed': 'Tilmelding er lukket for denne app.',
@@ -81,6 +129,30 @@ const da = {
81
129
  'workspace.current': 'Aktuel',
82
130
  'password.tooShort': 'Brug mindst {count} tegn.',
83
131
  'feature.upgrade': 'Opgrader for at bruge dette',
132
+ 'magicLink.send': 'Send mig et login-link',
133
+ 'magicLink.sent': 'Hvis adressen har en konto, er et login-link på vej. Åbn det på denne enhed.',
134
+ 'magicLink.finishing': 'Logger dig ind…',
135
+ 'magicLink.wrongDevice': 'Åbn linket på den enhed, hvor du bad om det.',
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)',
84
156
  };
85
157
  const nb = {
86
158
  'signup.closed': 'Registrering er stengt for denne appen.',
@@ -109,6 +181,30 @@ const nb = {
109
181
  'workspace.current': 'Gjeldende',
110
182
  'password.tooShort': 'Bruk minst {count} tegn.',
111
183
  'feature.upgrade': 'Oppgrader for å bruke dette',
184
+ 'magicLink.send': 'Send meg en innloggingslenke',
185
+ 'magicLink.sent': 'Hvis adressen har en konto, er en innloggingslenke på vei. Åpne den på denne enheten.',
186
+ 'magicLink.finishing': 'Logger deg inn…',
187
+ 'magicLink.wrongDevice': 'Åpne lenken på enheten der du ba om den.',
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)',
112
208
  };
113
209
  const nl = {
114
210
  'signup.closed': 'Registreren is gesloten voor deze app.',
@@ -137,6 +233,30 @@ const nl = {
137
233
  'workspace.current': 'Huidig',
138
234
  'password.tooShort': 'Gebruik minstens {count} tekens.',
139
235
  'feature.upgrade': 'Upgrade om dit te gebruiken',
236
+ 'magicLink.send': 'Mail me een inloglink',
237
+ 'magicLink.sent': 'Als dit adres een account heeft, is er een inloglink onderweg. Open hem op dit apparaat.',
238
+ 'magicLink.finishing': 'Je wordt ingelogd…',
239
+ 'magicLink.wrongDevice': 'Open de link op het apparaat waarop je hem hebt aangevraagd.',
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)',
140
260
  };
141
261
  const de = {
142
262
  'signup.closed': 'Die Registrierung ist für diese App geschlossen.',
@@ -165,6 +285,30 @@ const de = {
165
285
  'workspace.current': 'Aktuell',
166
286
  'password.tooShort': 'Verwende mindestens {count} Zeichen.',
167
287
  'feature.upgrade': 'Upgrade, um das zu nutzen',
288
+ 'magicLink.send': 'Schick mir einen Anmeldelink',
289
+ 'magicLink.sent': 'Wenn diese Adresse ein Konto hat, ist ein Anmeldelink unterwegs. Öffne ihn auf diesem Gerät.',
290
+ 'magicLink.finishing': 'Du wirst angemeldet…',
291
+ 'magicLink.wrongDevice': 'Öffne den Link auf dem Gerät, auf dem du ihn angefordert hast.',
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)',
168
312
  };
169
313
  const fi = {
170
314
  'signup.closed': 'Rekisteröityminen on suljettu tässä sovelluksessa.',
@@ -193,6 +337,30 @@ const fi = {
193
337
  'workspace.current': 'Nykyinen',
194
338
  'password.tooShort': 'Käytä vähintään {count} merkkiä.',
195
339
  'feature.upgrade': 'Päivitä käyttääksesi tätä',
340
+ 'magicLink.send': 'Lähetä minulle kirjautumislinkki',
341
+ 'magicLink.sent': 'Jos osoitteella on tili, kirjautumislinkki on matkalla. Avaa se tällä laitteella.',
342
+ 'magicLink.finishing': 'Kirjaudutaan sisään…',
343
+ 'magicLink.wrongDevice': 'Avaa linkki laitteella, jolla pyysit sitä.',
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)',
196
364
  };
197
365
  const fr = {
198
366
  'signup.closed': 'Les inscriptions sont fermées pour cette application.',
@@ -221,6 +389,30 @@ const fr = {
221
389
  'workspace.current': 'Actuel',
222
390
  'password.tooShort': 'Utilise au moins {count} caractères.',
223
391
  'feature.upgrade': 'Passe à l\'offre supérieure pour l\'utiliser',
392
+ 'magicLink.send': 'Envoie-moi un lien de connexion',
393
+ 'magicLink.sent': 'Si cette adresse a un compte, un lien de connexion est en route. Ouvre-le sur cet appareil.',
394
+ 'magicLink.finishing': 'Connexion en cours…',
395
+ 'magicLink.wrongDevice': 'Ouvre le lien sur l\'appareil où tu l\'as demandé.',
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)',
224
416
  };
225
417
  const es = {
226
418
  'signup.closed': 'El registro está cerrado para esta aplicación.',
@@ -249,6 +441,30 @@ const es = {
249
441
  'workspace.current': 'Actual',
250
442
  'password.tooShort': 'Usa al menos {count} caracteres.',
251
443
  'feature.upgrade': 'Mejora tu plan para usar esto',
444
+ 'magicLink.send': 'Envíame un enlace para iniciar sesión',
445
+ 'magicLink.sent': 'Si esta dirección tiene una cuenta, hay un enlace para iniciar sesión en camino. Ábrelo en este dispositivo.',
446
+ 'magicLink.finishing': 'Iniciando sesión…',
447
+ 'magicLink.wrongDevice': 'Abre el enlace en el dispositivo donde lo pediste.',
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)',
252
468
  };
253
469
  const it = {
254
470
  'signup.closed': 'La registrazione è chiusa per questa app.',
@@ -277,6 +493,30 @@ const it = {
277
493
  'workspace.current': 'Attuale',
278
494
  'password.tooShort': 'Usa almeno {count} caratteri.',
279
495
  'feature.upgrade': 'Passa a un piano superiore per usarlo',
496
+ 'magicLink.send': 'Inviami un link di accesso',
497
+ 'magicLink.sent': 'Se questo indirizzo ha un account, un link di accesso è in arrivo. Aprilo su questo dispositivo.',
498
+ 'magicLink.finishing': 'Accesso in corso…',
499
+ 'magicLink.wrongDevice': 'Apri il link sul dispositivo da cui l\'hai richiesto.',
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)',
280
520
  };
281
521
  const pt = {
282
522
  'signup.closed': 'O registo está fechado para esta aplicação.',
@@ -305,6 +545,30 @@ const pt = {
305
545
  'workspace.current': 'Atual',
306
546
  'password.tooShort': 'Usa pelo menos {count} caracteres.',
307
547
  'feature.upgrade': 'Faz upgrade para usar isto',
548
+ 'magicLink.send': 'Envia-me um link para iniciar sessão',
549
+ 'magicLink.sent': 'Se este endereço tiver uma conta, um link para iniciar sessão está a caminho. Abre-o neste dispositivo.',
550
+ 'magicLink.finishing': 'A iniciar sessão…',
551
+ 'magicLink.wrongDevice': 'Abre o link no dispositivo onde o pediste.',
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)',
308
572
  };
309
573
  const pl = {
310
574
  'signup.closed': 'Rejestracja w tej aplikacji jest zamknięta.',
@@ -333,6 +597,30 @@ const pl = {
333
597
  'workspace.current': 'Bieżąca',
334
598
  'password.tooShort': 'Użyj co najmniej {count} znaków.',
335
599
  'feature.upgrade': 'Zmień plan, by z tego korzystać',
600
+ 'magicLink.send': 'Wyślij mi link do logowania',
601
+ 'magicLink.sent': 'Jeśli ten adres ma konto, link do logowania jest w drodze. Otwórz go na tym urządzeniu.',
602
+ 'magicLink.finishing': 'Logowanie…',
603
+ 'magicLink.wrongDevice': 'Otwórz link na urządzeniu, na którym o niego poproszono.',
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)',
336
624
  };
337
625
  /** The plugin's copy by primary language subtag. */
338
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"];
8
+ export declare const AUTH_PAGES: readonly ["sign-in", "sign-up", "verify-email", "forgot-password", "set-password", "invite", "workspaces", "handoff", "magic-link", "passkey-setup"];
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];
@@ -7,6 +7,8 @@ export const AUTH_PAGES = [
7
7
  'invite',
8
8
  'workspaces',
9
9
  'handoff',
10
+ 'magic-link',
11
+ 'passkey-setup',
10
12
  ];
11
13
  export const BILLING_PAGES = ['manage', 'plan', 'success', 'error'];
12
14
  /** The catch-all parameter's name: `[...bridge]`. */
@@ -40,6 +42,10 @@ export function pageForLink(link) {
40
42
  return 'set-password';
41
43
  case 'invite':
42
44
  return 'invite';
45
+ case 'magic-link':
46
+ return 'magic-link';
47
+ case 'passkey-setup':
48
+ return 'passkey-setup';
43
49
  }
44
50
  }
45
51
  /** Whether `path` is `base` or under it. */
package/dist/index.d.ts CHANGED
@@ -32,6 +32,9 @@ export { default as BridgeAuthRoutes } from './components/auth/BridgeAuthRoutes.
32
32
  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
+ 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';
35
38
  export { default as ForgotPassword } from './components/auth/ForgotPassword.svelte';
36
39
  export { default as SetPassword } from './components/auth/SetPassword.svelte';
37
40
  export { default as InviteLanding } from './components/auth/InviteLanding.svelte';
package/dist/index.js CHANGED
@@ -30,6 +30,9 @@ export { default as BridgeAuthRoutes } from './components/auth/BridgeAuthRoutes.
30
30
  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
+ 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';
33
36
  export { default as ForgotPassword } from './components/auth/ForgotPassword.svelte';
34
37
  export { default as SetPassword } from './components/auth/SetPassword.svelte';
35
38
  export { default as InviteLanding } from './components/auth/InviteLanding.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebulr-group/bridge-svelte",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.5",
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.3"
63
+ "@nebulr-group/bridge-auth-core": "1.0.0-alpha.5"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@sveltejs/kit": "^2.16.0",