@declarion/react 0.177.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.
- package/dist-lib/api/access-expiry.js +28 -6
- package/dist-lib/api/agents.js +19 -8
- package/dist-lib/api/auth.js +63 -62
- package/dist-lib/components/agents/AgentChatPanel.impl.js +275 -177
- package/dist-lib/components/agents/transcript-runs.js +19 -7
- package/dist-lib/components/detail-layout/EvidenceBlock.js +1 -1
- package/dist-lib/components/pages/auth/SignIn.js +4 -2
- package/dist-lib/components/pages/profile/Profile.impl.js +149 -135
- package/dist-lib/index.d.ts +19 -1
- package/dist-lib/stores/auth.js +45 -45
- package/package.json +1 -1
package/dist-lib/stores/auth.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { cancelProactiveRefresh as
|
|
4
|
-
import { sessionCaller as
|
|
5
|
-
import { isEmbedTokenMode as
|
|
6
|
-
import { warmRoutePages as
|
|
7
|
-
import { usePreferencesStore as
|
|
8
|
-
import { create as
|
|
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
|
|
11
|
-
let
|
|
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 (
|
|
18
|
+
if (l()) i();
|
|
19
19
|
else try {
|
|
20
|
-
let
|
|
21
|
-
if (
|
|
22
|
-
|
|
20
|
+
let a = await r();
|
|
21
|
+
if (l()) {
|
|
22
|
+
i();
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
user:
|
|
25
|
+
e(), u(a.access_expires_at), t({
|
|
26
|
+
user: a,
|
|
27
27
|
isAuthenticated: !0,
|
|
28
28
|
isLoading: !1,
|
|
29
|
-
activeTenant:
|
|
29
|
+
activeTenant: a.tenant ?? null,
|
|
30
30
|
identitySince: performance.now()
|
|
31
|
-
}),
|
|
31
|
+
}), n().loadTenants();
|
|
32
32
|
} catch {
|
|
33
|
-
|
|
33
|
+
i();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
var
|
|
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
|
|
46
|
-
|
|
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: () =>
|
|
49
|
-
recheckSession: () =>
|
|
48
|
+
reloadSession: () => _(e, o, n),
|
|
49
|
+
recheckSession: () => _(e, o, a),
|
|
50
50
|
refreshMe: async () => {
|
|
51
51
|
try {
|
|
52
|
-
let t = await
|
|
53
|
-
if (
|
|
54
|
-
let
|
|
55
|
-
|
|
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
|
-
...
|
|
58
|
+
...i ? { identitySince: performance.now() } : {}
|
|
59
59
|
});
|
|
60
60
|
} catch {}
|
|
61
61
|
},
|
|
62
|
-
setUser: (
|
|
63
|
-
|
|
64
|
-
user:
|
|
62
|
+
setUser: (t, n) => {
|
|
63
|
+
m(), e({
|
|
64
|
+
user: t,
|
|
65
65
|
isAuthenticated: !0,
|
|
66
66
|
isLoading: !1,
|
|
67
|
-
activeTenant:
|
|
67
|
+
activeTenant: n ?? null,
|
|
68
68
|
identitySince: performance.now()
|
|
69
69
|
});
|
|
70
70
|
},
|
|
71
71
|
loadTenants: () => {
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
r().then((t) => {
|
|
73
|
+
l() || e({ tenants: t });
|
|
74
74
|
}, () => void 0);
|
|
75
75
|
},
|
|
76
|
-
setActiveTenant: (
|
|
77
|
-
|
|
76
|
+
setActiveTenant: (t) => {
|
|
77
|
+
e({ activeTenant: t });
|
|
78
78
|
},
|
|
79
79
|
logout: async () => {
|
|
80
|
-
|
|
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
|
|
87
|
+
}), await i(), b?.postMessage(y);
|
|
88
88
|
}
|
|
89
|
-
})),
|
|
90
|
-
|
|
91
|
-
e.data ===
|
|
92
|
-
}),
|
|
93
|
-
|
|
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 {
|
|
95
|
+
export { v as useAuthStore };
|