@declarion/react 0.175.0 → 0.180.0

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,39 +1,39 @@
1
- import { getMe as e, listTenants as t, logout as n, probeSession as r } from "../api/auth.js";
2
- import { startOrderNow as i } from "../api/access-expiry.js";
3
- import { cancelProactiveRefresh as a, endSessionInPage as o, ensureRefresh as s, isSignedOutInPage as c, scheduleProactiveRefresh as l, setLanguageReader as u } from "../api/client.js";
4
- import { sessionCaller as d } from "../api/audience.js";
5
- import { isEmbedTokenMode as f } from "../embed/token.js";
6
- import { warmRoutePages as p } from "../lib/capabilityPrefetch.js";
7
- import { usePreferencesStore as m } from "./preferences.js";
8
- import { create as h } from "zustand";
1
+ import { clearSignOut as e, startOrderNow as t } from "../api/access-expiry.js";
2
+ import { getMe as n, listTenants as r, logout as i, probeSession as a } from "../api/auth.js";
3
+ import { cancelProactiveRefresh as o, endSessionInPage as s, ensureRefresh as c, isSignedOutInPage as l, scheduleProactiveRefresh as u, setLanguageReader as d } from "../api/client.js";
4
+ import { sessionCaller as f } from "../api/audience.js";
5
+ import { isEmbedTokenMode as p } from "../embed/token.js";
6
+ import { warmRoutePages as m } from "../lib/capabilityPrefetch.js";
7
+ import { usePreferencesStore as h } from "./preferences.js";
8
+ import { create as g } from "zustand";
9
9
  // src/stores/auth.ts
10
- async function g(e, t, n) {
11
- let r = () => e({
10
+ async function _(t, n, r) {
11
+ let i = () => t({
12
12
  user: null,
13
13
  isAuthenticated: !1,
14
14
  isLoading: !1,
15
15
  sessionPresumed: !1,
16
16
  identitySince: performance.now()
17
17
  });
18
- if (c()) r();
18
+ if (l()) i();
19
19
  else try {
20
- let i = await n();
21
- if (c()) {
22
- r();
20
+ let a = await r();
21
+ if (l()) {
22
+ i();
23
23
  return;
24
24
  }
25
- l(i.access_expires_at), e({
26
- user: i,
25
+ e(), u(a.access_expires_at), t({
26
+ user: a,
27
27
  isAuthenticated: !0,
28
28
  isLoading: !1,
29
- activeTenant: i.tenant ?? null,
29
+ activeTenant: a.tenant ?? null,
30
30
  identitySince: performance.now()
31
- }), t().loadTenants();
31
+ }), n().loadTenants();
32
32
  } catch {
33
- r();
33
+ i();
34
34
  }
35
35
  }
36
- var _ = h((a, l) => ({
36
+ var v = g((e, o) => ({
37
37
  user: null,
38
38
  isAuthenticated: !1,
39
39
  isLoading: !0,
@@ -42,54 +42,54 @@ var _ = h((a, l) => ({
42
42
  sessionPresumed: !1,
43
43
  identitySince: 0,
44
44
  initialize: async () => {
45
- let e = i();
46
- e === "refresh-first" && (e = await s().then(() => "first-wave", () => "probe-first")), a({ sessionPresumed: e === "first-wave" }), e === "first-wave" && p(), await g(a, l, r), e === "probe-first" && l().isAuthenticated && p();
45
+ let n = t();
46
+ n === "refresh-first" && (n = await c().then(() => "first-wave", () => "probe-first")), e({ sessionPresumed: n === "first-wave" }), n === "first-wave" && m(), await _(e, o, a), n === "probe-first" && o().isAuthenticated && m();
47
47
  },
48
- reloadSession: () => g(a, l, e),
49
- recheckSession: () => g(a, l, r),
48
+ reloadSession: () => _(e, o, n),
49
+ recheckSession: () => _(e, o, a),
50
50
  refreshMe: async () => {
51
51
  try {
52
- let t = await e();
53
- if (c()) return;
54
- let n = l(), r = n.user?.id !== t.id || n.activeTenant?.id !== t.tenant?.id;
55
- a({
52
+ let t = await n();
53
+ if (l()) return;
54
+ let r = o(), i = r.user?.id !== t.id || r.activeTenant?.id !== t.tenant?.id;
55
+ e({
56
56
  user: t,
57
57
  activeTenant: t.tenant ?? null,
58
- ...r ? { identitySince: performance.now() } : {}
58
+ ...i ? { identitySince: performance.now() } : {}
59
59
  });
60
60
  } catch {}
61
61
  },
62
- setUser: (e, t) => {
63
- p(), a({
64
- user: e,
62
+ setUser: (t, n) => {
63
+ m(), e({
64
+ user: t,
65
65
  isAuthenticated: !0,
66
66
  isLoading: !1,
67
- activeTenant: t ?? null,
67
+ activeTenant: n ?? null,
68
68
  identitySince: performance.now()
69
69
  });
70
70
  },
71
71
  loadTenants: () => {
72
- t().then((e) => {
73
- c() || a({ tenants: e });
72
+ r().then((t) => {
73
+ l() || e({ tenants: t });
74
74
  }, () => void 0);
75
75
  },
76
- setActiveTenant: (e) => {
77
- a({ activeTenant: e });
76
+ setActiveTenant: (t) => {
77
+ e({ activeTenant: t });
78
78
  },
79
79
  logout: async () => {
80
- o(), a({
80
+ s(), e({
81
81
  user: null,
82
82
  isAuthenticated: !1,
83
83
  activeTenant: null,
84
84
  tenants: [],
85
85
  sessionPresumed: !1,
86
86
  identitySince: performance.now()
87
- }), await n(), y?.postMessage(v);
87
+ }), await i(), b?.postMessage(y);
88
88
  }
89
- })), v = "signed-out", y = typeof BroadcastChannel == "function" ? new BroadcastChannel("declarion.auth") : null;
90
- y?.addEventListener("message", (e) => {
91
- e.data === v && !f() && _.getState().isAuthenticated && (a(), window.location.assign("/login"));
92
- }), _.subscribe((e, t) => {
93
- u(d(e)), e.user?.id !== t.user?.id && m.getState().startIdentity();
89
+ })), y = "signed-out", b = typeof BroadcastChannel == "function" ? new BroadcastChannel("declarion.auth") : null;
90
+ b?.addEventListener("message", (e) => {
91
+ e.data === y && !p() && v.getState().isAuthenticated && (o(), window.location.assign("/login"));
92
+ }), v.subscribe((e, t) => {
93
+ d(f(e)), e.user?.id !== t.user?.id && h.getState().startIdentity();
94
94
  });
95
- export { _ as useAuthStore };
95
+ export { v as useAuthStore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.175.0",
3
+ "version": "0.180.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "React SDK for Declarion, the schema-driven business apps platform.",