@nebulr-group/bridge-svelte 0.8.0 → 0.8.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.
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { onMount } from 'svelte';
2
3
  import type { HTMLAttributes } from 'svelte/elements';
3
4
  import type { MessageOverrides } from '@nebulr-group/bridge-auth-core';
4
5
  import { getBridgeAuth } from '../../../core/bridge-instance.js';
@@ -65,6 +66,37 @@
65
66
  }
66
67
  }
67
68
 
69
+ // TBP-682: the emailed link returns to the page the request was made from,
70
+ // so this component must redeem it as well as send it. Without this branch a
71
+ // link requested here lands back here and does nothing — the token sits in
72
+ // the address bar and the user stays signed out. Mirrors LoginForm, which
73
+ // has always redeemed on mount.
74
+ onMount(async () => {
75
+ if (typeof window === 'undefined') return;
76
+
77
+ const params = new URLSearchParams(window.location.search);
78
+ const magicToken = params.get('bridge_magic_link_token');
79
+ if (!magicToken) return;
80
+
81
+ // Drop the token from the URL before redeeming, so a reload or a shared
82
+ // link cannot replay it.
83
+ params.delete('bridge_magic_link_token');
84
+ const newSearch = params.toString();
85
+ window.history.replaceState({}, '', window.location.pathname + (newSearch ? `?${newSearch}` : ''));
86
+
87
+ loading = true;
88
+ error = null;
89
+ try {
90
+ await getBridgeAuth().authenticateWithMagicLinkToken(magicToken);
91
+ // Auth state drives what the host app renders next, as with LoginForm.
92
+ } catch (err: any) {
93
+ error = authErrorMessage(err, t, 'magicLink.error.auth');
94
+ onError?.(err);
95
+ } finally {
96
+ loading = false;
97
+ }
98
+ });
99
+
68
100
  function formatExpiry(seconds: number): string {
69
101
  if (seconds >= 60) {
70
102
  const count = Math.floor(seconds / 60);
@@ -303,8 +303,16 @@ export function startBridgeRuntime(options = {}) {
303
303
  // TBP-660 — the TOKEN refresh above is skipped for a self-induced
304
304
  // reconnect; the STATE catch-up is not. Losing pushes is a property of
305
305
  // the socket swap, whoever caused it, and the catch-up cannot loop.
306
- if (_connectedOnce)
307
- requestCatchUp();
306
+ //
307
+ // TBP-686 — and it runs on the FIRST connect too. It used to be gated on
308
+ // `_connectedOnce`, which read as "only repair a reconnect" — but the
309
+ // first connect is exactly where the snapshot goes missing: the server
310
+ // publishes it fire-and-forget during authorize, before the subscription
311
+ // is live, so it loses the race and there is nothing to replay. The result
312
+ // was a signed-in page with a null workspace id, name and branding for the
313
+ // whole session. `requestCatchUp` already returns early when signed out
314
+ // and coalesces concurrent calls, so this costs one request per session.
315
+ requestCatchUp();
308
316
  _connectedOnce = true;
309
317
  for (const fn of _onOpenSubs) {
310
318
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebulr-group/bridge-svelte",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "Bridge Svelte library, This library helps you to add bridge authentication and feature flags, and payments to your svelte application.",
5
5
  "author": "Iman Pouya",
6
6
  "license": "MIT",
@@ -58,7 +58,7 @@
58
58
  "svelte": "^5.0.0",
59
59
  "@sveltejs/kit": "^2.0.0",
60
60
  "@stripe/stripe-js": ">=4.0.0",
61
- "@nebulr-group/bridge-auth-core": ">=0.7.0-beta.0 <1.0.0"
61
+ "@nebulr-group/bridge-auth-core": ">=0.7.1 <1.0.0"
62
62
  },
63
63
  "peerDependenciesMeta": {
64
64
  "@stripe/stripe-js": {
@@ -79,7 +79,7 @@
79
79
  "typescript": "^6.0.0",
80
80
  "vite": "^6.2.6",
81
81
  "vitest": "^4.1.4",
82
- "@nebulr-group/bridge-auth-core": "0.7.0"
82
+ "@nebulr-group/bridge-auth-core": "0.7.2"
83
83
  },
84
84
  "keywords": [
85
85
  "svelte",