@nebulr-group/bridge-svelte 1.0.0-alpha.1 → 1.0.0-alpha.2
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.
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
signs the person in. Opened on another device it says so, and the link
|
|
4
4
|
still works on the right one.
|
|
5
5
|
|
|
6
|
-
With `storage: 'memory'` the
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
With `storage: 'memory'` the session lives only in the tab that started the
|
|
7
|
+
sign-up, so this page first hands the link to that tab; when one takes it,
|
|
8
|
+
this page says to go on there. When none does, this page finishes itself.
|
|
9
9
|
-->
|
|
10
10
|
<script lang="ts">
|
|
11
11
|
import type { Snippet } from 'svelte';
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
if (relayed === null && config?.storage === 'memory') {
|
|
73
|
-
// The
|
|
73
|
+
// The session belongs in the tab that started the sign-up: offer it the link first.
|
|
74
74
|
void offerSignUpLink(config.issuer, found).then((taken) => {
|
|
75
75
|
if (taken) view = { step: 'continued' };
|
|
76
76
|
else getBridge().signUp.finish(found).then(follow, fail);
|
package/dist/core/client.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* browser, and every store and component reads it from here. Nothing is made
|
|
4
4
|
* on a server: the server side has its own helpers (`/server`), per request.
|
|
5
5
|
*/
|
|
6
|
-
import { createBridge, memoryStorage } from '@nebulr-group/bridge-auth-core';
|
|
6
|
+
import { createBridge, localStorageAdapter, memoryStorage } from '@nebulr-group/bridge-auth-core';
|
|
7
7
|
import { get, writable } from 'svelte/store';
|
|
8
8
|
import { setAppCopy } from './i18n.js';
|
|
9
9
|
const clientStore = writable(null);
|
|
@@ -59,8 +59,9 @@ export function startClient(config, extra) {
|
|
|
59
59
|
issuer: config.issuer,
|
|
60
60
|
tokenOrigins: config.tokenOrigins,
|
|
61
61
|
...(config.live ? {} : { live: false }),
|
|
62
|
-
// Memory
|
|
63
|
-
|
|
62
|
+
// Memory: the refresh token and the visitor id stay in this page. A sign-up's verifier waits in localStorage
|
|
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
|
+
...(config.storage === 'memory' ? { storage: memoryStorage(), signUpStorage: localStorageAdapter() } : {}),
|
|
64
65
|
...extra,
|
|
65
66
|
});
|
|
66
67
|
client.on('signed-out', ({ reason }) => {
|
package/dist/core/config.d.ts
CHANGED
|
@@ -65,12 +65,17 @@ export interface BridgeConfig {
|
|
|
65
65
|
*
|
|
66
66
|
* - `'local'`: in the browser's localStorage, so a reload and a new tab
|
|
67
67
|
* stay signed in.
|
|
68
|
-
* - `'memory'`: in this page's memory only.
|
|
69
|
-
* written to localStorage or sessionStorage
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
68
|
+
* - `'memory'`: in this page's memory only. The refresh token and the
|
|
69
|
+
* visitor id are never written to localStorage or sessionStorage. A
|
|
70
|
+
* reload signs in again. A new tab is signed in by another open tab of
|
|
71
|
+
* the app, passed in memory only; with no other tab open, it signs in
|
|
72
|
+
* again. The one exception is a sign-up waiting for its email link: its
|
|
73
|
+
* PKCE verifier is kept in localStorage, so the link, which opens in a
|
|
74
|
+
* new tab, finishes the sign-up in this browser even after the tab that
|
|
75
|
+
* started it is closed. It is kept for the link's 15 minutes at most and
|
|
76
|
+
* removed once used; on another device the link is refused. When the
|
|
77
|
+
* tab that started the sign-up is still open, the link is handed to it
|
|
78
|
+
* and finishes there.
|
|
74
79
|
*
|
|
75
80
|
* @default 'local'
|
|
76
81
|
*/
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
* apps that keep the session in memory (`storage: 'memory'`).
|
|
4
4
|
*
|
|
5
5
|
* A sign-up finishes only on the device that started it, with the PKCE
|
|
6
|
-
* verifier
|
|
7
|
-
*
|
|
8
|
-
* on a BroadcastChannel of the page's own origin;
|
|
9
|
-
* sign-up takes it and finishes there, and the new
|
|
10
|
-
* takes it within a moment
|
|
11
|
-
*
|
|
12
|
-
*
|
|
6
|
+
* verifier it kept in localStorage. In memory mode the session lives in the
|
|
7
|
+
* tab that started the sign-up, and the email link opens in a new one. The
|
|
8
|
+
* new tab offers the link on a BroadcastChannel of the page's own origin;
|
|
9
|
+
* the tab that started the sign-up takes it and finishes there, and the new
|
|
10
|
+
* tab says so. When no tab takes it within a moment (it was closed, or the
|
|
11
|
+
* browser put it to sleep), the new tab finishes itself with the stored
|
|
12
|
+
* verifier. On another device there is none, and Bridge answers that the
|
|
13
|
+
* link belongs to the device that started the sign-up; the link stays
|
|
14
|
+
* usable there.
|
|
13
15
|
*
|
|
14
16
|
* Only the token crosses, only between tabs of the same origin, and never
|
|
15
17
|
* through storage or an address.
|
package/dist/core/link-relay.js
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
* apps that keep the session in memory (`storage: 'memory'`).
|
|
4
4
|
*
|
|
5
5
|
* A sign-up finishes only on the device that started it, with the PKCE
|
|
6
|
-
* verifier
|
|
7
|
-
*
|
|
8
|
-
* on a BroadcastChannel of the page's own origin;
|
|
9
|
-
* sign-up takes it and finishes there, and the new
|
|
10
|
-
* takes it within a moment
|
|
11
|
-
*
|
|
12
|
-
*
|
|
6
|
+
* verifier it kept in localStorage. In memory mode the session lives in the
|
|
7
|
+
* tab that started the sign-up, and the email link opens in a new one. The
|
|
8
|
+
* new tab offers the link on a BroadcastChannel of the page's own origin;
|
|
9
|
+
* the tab that started the sign-up takes it and finishes there, and the new
|
|
10
|
+
* tab says so. When no tab takes it within a moment (it was closed, or the
|
|
11
|
+
* browser put it to sleep), the new tab finishes itself with the stored
|
|
12
|
+
* verifier. On another device there is none, and Bridge answers that the
|
|
13
|
+
* link belongs to the device that started the sign-up; the link stays
|
|
14
|
+
* usable there.
|
|
13
15
|
*
|
|
14
16
|
* Only the token crosses, only between tabs of the same origin, and never
|
|
15
17
|
* through storage or an address.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebulr-group/bridge-svelte",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
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.
|
|
63
|
+
"@nebulr-group/bridge-auth-core": "1.0.0-alpha.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@sveltejs/kit": "^2.16.0",
|