@skylabs-digital/react-identity-access 3.0.0 → 3.1.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/README.md +439 -352
- package/dist/errors/SessionErrors.d.ts +10 -0
- package/dist/errors/SessionErrors.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1043 -899
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/services/AuthApiService.d.ts +1 -0
- package/dist/services/AuthApiService.d.ts.map +1 -1
- package/dist/services/SessionManager.d.ts +10 -3
- package/dist/services/SessionManager.d.ts.map +1 -1
- package/dist/utils/configValidation.d.ts +39 -0
- package/dist/utils/configValidation.d.ts.map +1 -0
- package/dist/utils/jwt.d.ts +25 -0
- package/dist/utils/jwt.d.ts.map +1 -0
- package/package.json +15 -16
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s, Fragment as B, jsxs as f } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { useLocation as
|
|
4
|
-
class
|
|
2
|
+
import me, { createContext as fe, useState as N, useRef as Ee, useCallback as te, useMemo as V, useEffect as re, useContext as ne } from "react";
|
|
3
|
+
import { useLocation as xe, Navigate as be, useNavigate as wt, useSearchParams as vt } from "react-router-dom";
|
|
4
|
+
class he {
|
|
5
5
|
constructor(e, t = 1e4) {
|
|
6
6
|
this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
|
|
7
7
|
}
|
|
@@ -21,7 +21,7 @@ class de {
|
|
|
21
21
|
const c = await this.sessionManager.getValidAccessToken();
|
|
22
22
|
d = { ...d, Authorization: `Bearer ${c}` };
|
|
23
23
|
}
|
|
24
|
-
const T = new AbortController(),
|
|
24
|
+
const T = new AbortController(), R = setTimeout(() => T.abort(), l);
|
|
25
25
|
try {
|
|
26
26
|
const c = await fetch(a, {
|
|
27
27
|
method: e,
|
|
@@ -29,12 +29,12 @@ class de {
|
|
|
29
29
|
body: n ? JSON.stringify(n) : void 0,
|
|
30
30
|
signal: T.signal
|
|
31
31
|
});
|
|
32
|
-
if (clearTimeout(
|
|
32
|
+
if (clearTimeout(R), !c.ok)
|
|
33
33
|
throw new Error(`HTTP ${c.status}: ${c.statusText}`);
|
|
34
|
-
const
|
|
35
|
-
return !
|
|
34
|
+
const S = c.headers.get("content-type");
|
|
35
|
+
return !S || !S.includes("application/json") ? {} : await c.json();
|
|
36
36
|
} catch (c) {
|
|
37
|
-
throw clearTimeout(
|
|
37
|
+
throw clearTimeout(R), c instanceof Error && c.name === "AbortError" ? new Error(`Request timeout after ${l}ms`) : c;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async get(e, t) {
|
|
@@ -50,7 +50,7 @@ class de {
|
|
|
50
50
|
return this.executeRequest("DELETE", e, void 0, t);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function ce(r) {
|
|
54
54
|
if (!r) return "";
|
|
55
55
|
const e = new URLSearchParams();
|
|
56
56
|
for (const [n, i] of Object.entries(r))
|
|
@@ -58,7 +58,7 @@ function le(r) {
|
|
|
58
58
|
const t = e.toString();
|
|
59
59
|
return t ? `?${t}` : "";
|
|
60
60
|
}
|
|
61
|
-
class
|
|
61
|
+
class Je {
|
|
62
62
|
constructor(e) {
|
|
63
63
|
this.httpService = e;
|
|
64
64
|
}
|
|
@@ -67,7 +67,7 @@ class Ge {
|
|
|
67
67
|
}
|
|
68
68
|
async getApps(e) {
|
|
69
69
|
const t = await this.httpService.get(
|
|
70
|
-
`/apps/${
|
|
70
|
+
`/apps/${ce(e)}`
|
|
71
71
|
);
|
|
72
72
|
return { apps: t.data, meta: t.meta };
|
|
73
73
|
}
|
|
@@ -98,27 +98,27 @@ class Ge {
|
|
|
98
98
|
return (await this.httpService.get(`/apps/${e}/export-config`)).data;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
const
|
|
102
|
-
function
|
|
103
|
-
var
|
|
104
|
-
const { appId: t, baseUrl: n } = r, i = ((
|
|
101
|
+
const $e = fe(null), Tt = 5 * 60 * 1e3;
|
|
102
|
+
function Sr({ config: r, children: e }) {
|
|
103
|
+
var k, m, g;
|
|
104
|
+
const { appId: t, baseUrl: n } = r, i = ((k = r.cache) == null ? void 0 : k.enabled) ?? !0, a = ((m = r.cache) == null ? void 0 : m.ttl) ?? Tt, l = ((g = r.cache) == null ? void 0 : g.storageKey) ?? `app_cache_${t}`, [d, T] = N(() => {
|
|
105
105
|
if (!i) return null;
|
|
106
106
|
try {
|
|
107
107
|
const b = localStorage.getItem(l);
|
|
108
108
|
if (!b) return null;
|
|
109
|
-
const
|
|
110
|
-
return Date.now() -
|
|
109
|
+
const C = JSON.parse(b);
|
|
110
|
+
return Date.now() - C.timestamp < a && C.appId === t ? C.data : (localStorage.removeItem(l), null);
|
|
111
111
|
} catch {
|
|
112
112
|
return null;
|
|
113
113
|
}
|
|
114
|
-
}), [
|
|
115
|
-
|
|
116
|
-
const
|
|
114
|
+
}), [R, c] = N(!d), [S, h] = N(null), x = Ee(d);
|
|
115
|
+
x.current = d;
|
|
116
|
+
const P = te(
|
|
117
117
|
async (b = !1) => {
|
|
118
|
-
if (!(!b && i &&
|
|
118
|
+
if (!(!b && i && x.current))
|
|
119
119
|
try {
|
|
120
120
|
c(!0), h(null);
|
|
121
|
-
const o = await new
|
|
121
|
+
const o = await new Je(new he(n)).getPublicAppInfo(t);
|
|
122
122
|
if (T(o), i)
|
|
123
123
|
try {
|
|
124
124
|
const p = {
|
|
@@ -130,60 +130,60 @@ function lr({ config: r, children: e }) {
|
|
|
130
130
|
} catch (p) {
|
|
131
131
|
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Failed to cache app info:", p);
|
|
132
132
|
}
|
|
133
|
-
} catch (
|
|
134
|
-
const o =
|
|
133
|
+
} catch (C) {
|
|
134
|
+
const o = C instanceof Error ? C : new Error("Failed to load app information");
|
|
135
135
|
h(o), T(null);
|
|
136
136
|
} finally {
|
|
137
137
|
c(!1);
|
|
138
138
|
}
|
|
139
139
|
},
|
|
140
140
|
[n, t, i, l]
|
|
141
|
-
), I =
|
|
142
|
-
if (!(!i || !
|
|
141
|
+
), I = te(async () => {
|
|
142
|
+
if (!(!i || !x.current))
|
|
143
143
|
try {
|
|
144
144
|
const b = localStorage.getItem(l);
|
|
145
145
|
if (!b) return;
|
|
146
|
-
const
|
|
147
|
-
if (Date.now() -
|
|
148
|
-
const p = await new
|
|
146
|
+
const C = JSON.parse(b);
|
|
147
|
+
if (Date.now() - C.timestamp <= a * 0.5) return;
|
|
148
|
+
const p = await new Je(new he(n)).getPublicAppInfo(t);
|
|
149
149
|
T(p);
|
|
150
|
-
const
|
|
150
|
+
const E = {
|
|
151
151
|
data: p,
|
|
152
152
|
timestamp: Date.now(),
|
|
153
153
|
appId: t
|
|
154
154
|
};
|
|
155
|
-
localStorage.setItem(l, JSON.stringify(
|
|
155
|
+
localStorage.setItem(l, JSON.stringify(E));
|
|
156
156
|
} catch (b) {
|
|
157
157
|
process.env.NODE_ENV === "development" && console.warn("[AppProvider] Background app refresh failed:", b);
|
|
158
158
|
}
|
|
159
|
-
}, [n, t, i, a, l]), A =
|
|
159
|
+
}, [n, t, i, a, l]), A = V(
|
|
160
160
|
() => ({
|
|
161
161
|
appId: t,
|
|
162
162
|
baseUrl: n,
|
|
163
163
|
appInfo: d,
|
|
164
|
-
isAppLoading:
|
|
165
|
-
appError:
|
|
164
|
+
isAppLoading: R,
|
|
165
|
+
appError: S,
|
|
166
166
|
retryApp: () => {
|
|
167
|
-
|
|
167
|
+
P(!0);
|
|
168
168
|
}
|
|
169
169
|
}),
|
|
170
|
-
[t, n, d,
|
|
170
|
+
[t, n, d, R, S, P]
|
|
171
171
|
);
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
}, []), /* @__PURE__ */ s(
|
|
172
|
+
return re(() => {
|
|
173
|
+
x.current ? I() : P();
|
|
174
|
+
}, []), /* @__PURE__ */ s($e.Provider, { value: A, children: e });
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
const r =
|
|
176
|
+
function Re() {
|
|
177
|
+
const r = ne($e);
|
|
178
178
|
if (!r)
|
|
179
179
|
throw new Error("useApp must be used within an AppProvider");
|
|
180
180
|
return r;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
183
|
-
return
|
|
182
|
+
function Ue() {
|
|
183
|
+
return ne($e);
|
|
184
184
|
}
|
|
185
|
-
const
|
|
186
|
-
class
|
|
185
|
+
const kr = Re;
|
|
186
|
+
class ee extends Error {
|
|
187
187
|
constructor(e, t) {
|
|
188
188
|
const n = {
|
|
189
189
|
token_expired: "Refresh token has expired",
|
|
@@ -193,21 +193,111 @@ class te extends Error {
|
|
|
193
193
|
super(t || n[e]), this.name = "SessionExpiredError", this.reason = e;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
class
|
|
196
|
+
class St extends Error {
|
|
197
197
|
constructor(e) {
|
|
198
198
|
super(`Token refresh timed out after ${e}ms`), this.name = "TokenRefreshTimeoutError", this.timeoutMs = e;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
class
|
|
201
|
+
class kt extends Error {
|
|
202
202
|
constructor(e, t) {
|
|
203
203
|
super(
|
|
204
204
|
`Token refresh failed after ${e} attempts: ${(t == null ? void 0 : t.message) || "Unknown error"}`
|
|
205
205
|
), this.name = "TokenRefreshError", this.attempts = e, this.lastError = t;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
|
|
208
|
+
class oe extends Error {
|
|
209
|
+
constructor(e, t, n) {
|
|
210
|
+
super(`Invalid configuration "${e}": ${n} (received: ${Et(t)})`), this.name = "ConfigurationError", this.field = e, this.received = t;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function Et(r) {
|
|
214
|
+
if (r === void 0) return "undefined";
|
|
215
|
+
try {
|
|
216
|
+
const e = JSON.stringify(r);
|
|
217
|
+
return e === void 0 ? typeof r : e.length > 50 ? `${e.slice(0, 47)}...` : e;
|
|
218
|
+
} catch {
|
|
219
|
+
return typeof r;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function Ze(r) {
|
|
223
|
+
return JSON.parse(atob(r.replace(/-/g, "+").replace(/_/g, "/")));
|
|
224
|
+
}
|
|
225
|
+
function Ae(r) {
|
|
226
|
+
const e = r.split(".");
|
|
227
|
+
if (e.length !== 3) return null;
|
|
228
|
+
try {
|
|
229
|
+
return { header: Ze(e[0]), payload: Ze(e[1]) };
|
|
230
|
+
} catch {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function Ke(r) {
|
|
235
|
+
const e = Ae(r), t = e == null ? void 0 : e.payload.exp;
|
|
236
|
+
return typeof t == "number" ? t * 1e3 : void 0;
|
|
237
|
+
}
|
|
238
|
+
function xt(r, e) {
|
|
239
|
+
var n;
|
|
240
|
+
const t = (n = Ae(r)) == null ? void 0 : n.payload[e];
|
|
241
|
+
return typeof t == "string" ? t : void 0;
|
|
242
|
+
}
|
|
243
|
+
const Rt = /^(javascript|data|vbscript|file):/i, At = /^https?:\/\//i;
|
|
244
|
+
function Pt(r, e = "baseUrl") {
|
|
245
|
+
if (!(r == null || r === "")) {
|
|
246
|
+
if (typeof r != "string")
|
|
247
|
+
throw new oe(e, r, "must be a string");
|
|
248
|
+
if (Rt.test(r))
|
|
249
|
+
throw new oe(e, r, "dangerous URL scheme is not allowed");
|
|
250
|
+
if (!At.test(r))
|
|
251
|
+
throw new oe(e, r, "must start with http:// or https://");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function ge(r, e, t = {}) {
|
|
255
|
+
if (e === void 0) return;
|
|
256
|
+
if (typeof e != "number" || !Number.isFinite(e))
|
|
257
|
+
throw new oe(r, e, "must be a finite number");
|
|
258
|
+
const { min: n = 0, max: i = Number.MAX_SAFE_INTEGER } = t;
|
|
259
|
+
if (e < n)
|
|
260
|
+
throw new oe(r, e, `must be >= ${n}`);
|
|
261
|
+
if (e > i)
|
|
262
|
+
throw new oe(r, e, `must be <= ${i}`);
|
|
263
|
+
}
|
|
264
|
+
function Ye(r, e) {
|
|
265
|
+
if (e !== void 0 && typeof e != "boolean")
|
|
266
|
+
throw new oe(r, e, "must be a boolean");
|
|
267
|
+
}
|
|
268
|
+
function It(r, e = "accessToken") {
|
|
269
|
+
if (typeof r != "string" || r.length === 0)
|
|
270
|
+
throw new oe(e, r, "must be a non-empty string");
|
|
271
|
+
if (!r.includes(".")) return;
|
|
272
|
+
const t = r.split(".");
|
|
273
|
+
if (t.length !== 3)
|
|
274
|
+
throw new oe(
|
|
275
|
+
e,
|
|
276
|
+
`<${t.length}-segment token>`,
|
|
277
|
+
"JWT must have exactly 3 segments (header.payload.signature)"
|
|
278
|
+
);
|
|
279
|
+
if (Ae(r) === null)
|
|
280
|
+
throw new oe(
|
|
281
|
+
e,
|
|
282
|
+
"<malformed JWT>",
|
|
283
|
+
"JWT header or payload is not valid base64url-encoded JSON"
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
function Lt(r) {
|
|
287
|
+
if (r !== void 0 && (typeof r != "number" || !Number.isFinite(r) || r <= 0))
|
|
288
|
+
throw new oe("expiresIn", r, "must be a finite positive number (seconds)");
|
|
289
|
+
}
|
|
290
|
+
function Ft(r) {
|
|
291
|
+
if (r !== void 0 && (typeof r != "number" || !Number.isFinite(r) || r <= 0))
|
|
292
|
+
throw new oe(
|
|
293
|
+
"expiresAt",
|
|
294
|
+
r,
|
|
295
|
+
"must be a finite positive timestamp (ms since epoch)"
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
const ie = class ie {
|
|
209
299
|
constructor(e = {}) {
|
|
210
|
-
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, this.consecutiveBackgroundFailures = 0, this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.onSessionExpired = e.onSessionExpired, this.baseUrl = e.baseUrl || "", this.enableCookieSession = e.enableCookieSession ?? !1, this.proactiveRefreshMargin = e.proactiveRefreshMargin ?? 6e4, this.refreshQueueTimeout = e.refreshQueueTimeout ?? 1e4, this.maxRefreshRetries = e.maxRefreshRetries ?? 3, this.retryBackoffBase = e.retryBackoffBase ?? 1e3, this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey), this.scheduleProactiveRefresh();
|
|
300
|
+
this.refreshPromise = null, this.refreshQueue = [], this.proactiveTimerId = null, this.backgroundRetryTimerId = null, this.isDestroyed = !1, this.sessionGeneration = 0, this.consecutiveBackgroundFailures = 0, this.memoryStore = null, this.visibilityListener = null, ie.validateConfig(e), this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.onSessionExpired = e.onSessionExpired, this.baseUrl = e.baseUrl || "", this.enableCookieSession = e.enableCookieSession ?? !1, this.proactiveRefreshMargin = e.proactiveRefreshMargin ?? 6e4, this.refreshQueueTimeout = e.refreshQueueTimeout ?? 1e4, this.maxRefreshRetries = e.maxRefreshRetries ?? 3, this.retryBackoffBase = e.retryBackoffBase ?? 1e3, this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey), this.attachVisibilityListener(), this.scheduleProactiveRefresh();
|
|
211
301
|
}
|
|
212
302
|
/**
|
|
213
303
|
* Get or create a SessionManager instance for the given config.
|
|
@@ -215,69 +305,95 @@ const K = class K {
|
|
|
215
305
|
* Mutable config (callbacks, baseUrl) is updated on the existing instance.
|
|
216
306
|
*/
|
|
217
307
|
static getInstance(e = {}) {
|
|
218
|
-
const t =
|
|
308
|
+
const t = ie.resolveStorageKey(e), n = ie.instances.get(t);
|
|
219
309
|
if (n)
|
|
220
310
|
return n.updateConfig(e), n;
|
|
221
|
-
const i = new
|
|
222
|
-
return
|
|
311
|
+
const i = new ie(e);
|
|
312
|
+
return ie.instances.set(t, i), i;
|
|
223
313
|
}
|
|
224
314
|
/** Reset all singleton instances. For testing only. */
|
|
225
315
|
static resetAllInstances() {
|
|
226
|
-
for (const e of
|
|
316
|
+
for (const e of ie.instances.values())
|
|
227
317
|
e.destroy();
|
|
228
|
-
|
|
318
|
+
ie.instances.clear();
|
|
229
319
|
}
|
|
230
320
|
static resolveStorageKey(e) {
|
|
231
321
|
return e.storageKey || "auth_tokens";
|
|
232
322
|
}
|
|
323
|
+
static validateConfig(e) {
|
|
324
|
+
Pt(e.baseUrl), Ye("enableCookieSession", e.enableCookieSession), Ye("autoRefresh", e.autoRefresh), ge("refreshThreshold", e.refreshThreshold, { min: 0 }), ge("proactiveRefreshMargin", e.proactiveRefreshMargin, { min: 0 }), ge("refreshQueueTimeout", e.refreshQueueTimeout, { min: 1 }), ge("maxRefreshRetries", e.maxRefreshRetries, { min: 0 }), ge("retryBackoffBase", e.retryBackoffBase, { min: 1 });
|
|
325
|
+
}
|
|
233
326
|
/** Update mutable config (callbacks, baseUrl) on an existing instance. */
|
|
234
327
|
updateConfig(e) {
|
|
235
328
|
e.onSessionExpired !== void 0 && (this.onSessionExpired = e.onSessionExpired), e.onRefreshFailed !== void 0 && (this.onRefreshFailed = e.onRefreshFailed), e.baseUrl && (this.baseUrl = e.baseUrl), e.enableCookieSession !== void 0 && (this.enableCookieSession = e.enableCookieSession);
|
|
236
329
|
}
|
|
237
|
-
// --- Storage helpers ---
|
|
238
330
|
createTokenStorage(e) {
|
|
239
|
-
return {
|
|
331
|
+
return ie.probeLocalStorage() || this.activateMemoryFallback(), {
|
|
240
332
|
get: () => {
|
|
333
|
+
const t = this.storageGet(e);
|
|
334
|
+
if (!t) return null;
|
|
241
335
|
try {
|
|
242
|
-
|
|
243
|
-
return t ? JSON.parse(t) : null;
|
|
336
|
+
return JSON.parse(t);
|
|
244
337
|
} catch {
|
|
245
338
|
return null;
|
|
246
339
|
}
|
|
247
340
|
},
|
|
248
341
|
set: (t) => {
|
|
249
|
-
|
|
250
|
-
localStorage.setItem(e, JSON.stringify(t));
|
|
251
|
-
} catch {
|
|
252
|
-
}
|
|
342
|
+
this.storageSet(e, JSON.stringify(t));
|
|
253
343
|
},
|
|
254
344
|
clear: () => {
|
|
255
|
-
|
|
256
|
-
localStorage.removeItem(e);
|
|
257
|
-
} catch {
|
|
258
|
-
}
|
|
345
|
+
this.storageRemove(e);
|
|
259
346
|
}
|
|
260
347
|
};
|
|
261
348
|
}
|
|
262
|
-
|
|
263
|
-
|
|
349
|
+
static probeLocalStorage() {
|
|
350
|
+
if (typeof localStorage > "u") return !1;
|
|
264
351
|
try {
|
|
265
|
-
|
|
266
|
-
return t.length !== 3 ? null : JSON.parse(atob(t[1].replace(/-/g, "+").replace(/_/g, "/")));
|
|
352
|
+
return localStorage.setItem("__sm_probe__", "1"), localStorage.removeItem("__sm_probe__"), !0;
|
|
267
353
|
} catch {
|
|
268
|
-
return
|
|
354
|
+
return !1;
|
|
269
355
|
}
|
|
270
356
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
357
|
+
activateMemoryFallback() {
|
|
358
|
+
return this.memoryStore || (this.memoryStore = /* @__PURE__ */ new Map(), process.env.NODE_ENV === "development" && console.warn(
|
|
359
|
+
"[SessionManager] localStorage unavailable — falling back to in-memory session. Cross-tab and reload persistence are lost."
|
|
360
|
+
)), this.memoryStore;
|
|
361
|
+
}
|
|
362
|
+
storageGet(e) {
|
|
363
|
+
if (this.memoryStore) return this.memoryStore.get(e) ?? null;
|
|
364
|
+
try {
|
|
365
|
+
return localStorage.getItem(e);
|
|
366
|
+
} catch {
|
|
367
|
+
return this.activateMemoryFallback().get(e) ?? null;
|
|
368
|
+
}
|
|
274
369
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
370
|
+
storageSet(e, t) {
|
|
371
|
+
if (this.memoryStore) {
|
|
372
|
+
this.memoryStore.set(e, t);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
try {
|
|
376
|
+
localStorage.setItem(e, t);
|
|
377
|
+
} catch {
|
|
378
|
+
this.activateMemoryFallback().set(e, t);
|
|
379
|
+
}
|
|
278
380
|
}
|
|
381
|
+
storageRemove(e) {
|
|
382
|
+
if (this.memoryStore) {
|
|
383
|
+
this.memoryStore.delete(e);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
try {
|
|
387
|
+
localStorage.removeItem(e);
|
|
388
|
+
} catch {
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
// --- Token CRUD ---
|
|
279
392
|
setTokens(e) {
|
|
280
|
-
|
|
393
|
+
if (It(e.accessToken, "accessToken"), e.refreshToken !== void 0 && typeof e.refreshToken != "string")
|
|
394
|
+
throw new oe("refreshToken", e.refreshToken, "must be a string");
|
|
395
|
+
Lt(e.expiresIn), Ft(e.expiresAt);
|
|
396
|
+
const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || Ke(e.accessToken), n = {
|
|
281
397
|
...e,
|
|
282
398
|
expiresAt: t
|
|
283
399
|
}, i = this.tokenStorage.get() || {};
|
|
@@ -287,7 +403,7 @@ const K = class K {
|
|
|
287
403
|
const { accessToken: e, refreshToken: t, expiresAt: n, expiresIn: i, tokenType: a } = this.tokenStorage.get() || {};
|
|
288
404
|
if (!e)
|
|
289
405
|
return null;
|
|
290
|
-
const l = n ||
|
|
406
|
+
const l = n || Ke(e);
|
|
291
407
|
return {
|
|
292
408
|
accessToken: e,
|
|
293
409
|
refreshToken: t,
|
|
@@ -328,6 +444,26 @@ const K = class K {
|
|
|
328
444
|
cancelProactiveTimer() {
|
|
329
445
|
this.proactiveTimerId !== null && (clearTimeout(this.proactiveTimerId), this.proactiveTimerId = null), this.backgroundRetryTimerId !== null && (clearTimeout(this.backgroundRetryTimerId), this.backgroundRetryTimerId = null);
|
|
330
446
|
}
|
|
447
|
+
attachVisibilityListener() {
|
|
448
|
+
if (!this.visibilityListener && !(typeof document > "u" || typeof document.addEventListener != "function")) {
|
|
449
|
+
this.visibilityListener = () => {
|
|
450
|
+
document.visibilityState !== "visible" || this.isDestroyed || this.scheduleProactiveRefresh();
|
|
451
|
+
};
|
|
452
|
+
try {
|
|
453
|
+
document.addEventListener("visibilitychange", this.visibilityListener);
|
|
454
|
+
} catch {
|
|
455
|
+
this.visibilityListener = null;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
detachVisibilityListener() {
|
|
460
|
+
if (this.visibilityListener && typeof document < "u")
|
|
461
|
+
try {
|
|
462
|
+
document.removeEventListener("visibilitychange", this.visibilityListener);
|
|
463
|
+
} catch {
|
|
464
|
+
}
|
|
465
|
+
this.visibilityListener = null;
|
|
466
|
+
}
|
|
331
467
|
backgroundRefresh() {
|
|
332
468
|
if (this.isDestroyed) return;
|
|
333
469
|
const e = this.getTokens();
|
|
@@ -336,13 +472,13 @@ const K = class K {
|
|
|
336
472
|
this.startRefreshAndResolveQueue(e.refreshToken).then(() => {
|
|
337
473
|
this.consecutiveBackgroundFailures = 0;
|
|
338
474
|
}).catch((n) => {
|
|
339
|
-
if (!(n instanceof
|
|
475
|
+
if (!(n instanceof ee)) {
|
|
340
476
|
if (this.sessionGeneration === t) {
|
|
341
|
-
if (this.consecutiveBackgroundFailures++, this.consecutiveBackgroundFailures >=
|
|
477
|
+
if (this.consecutiveBackgroundFailures++, this.consecutiveBackgroundFailures >= ie.MAX_BACKGROUND_FAILURES) {
|
|
342
478
|
process.env.NODE_ENV === "development" && console.error(
|
|
343
479
|
`[SessionManager] Background refresh failed ${this.consecutiveBackgroundFailures} consecutive times — expiring session`
|
|
344
480
|
), this.consecutiveBackgroundFailures = 0, this.handleSessionExpired(
|
|
345
|
-
new
|
|
481
|
+
new ee("token_invalid", "Background refresh failed repeatedly")
|
|
346
482
|
);
|
|
347
483
|
return;
|
|
348
484
|
}
|
|
@@ -409,13 +545,13 @@ const K = class K {
|
|
|
409
545
|
async getValidAccessToken() {
|
|
410
546
|
const e = this.getTokens();
|
|
411
547
|
if (!(e != null && e.accessToken)) {
|
|
412
|
-
const t = new
|
|
548
|
+
const t = new ee("token_invalid", "No tokens available");
|
|
413
549
|
throw this.handleSessionExpired(t), t;
|
|
414
550
|
}
|
|
415
551
|
if (!this.shouldRefreshToken(e) && !this.isTokenExpired(e))
|
|
416
552
|
return e.accessToken;
|
|
417
553
|
if (!e.refreshToken) {
|
|
418
|
-
const t = new
|
|
554
|
+
const t = new ee("token_invalid", "No refresh token available");
|
|
419
555
|
throw this.handleSessionExpired(t), t;
|
|
420
556
|
}
|
|
421
557
|
return this.refreshPromise ? this.enqueueForToken() : this.startRefreshAndResolveQueue(e.refreshToken);
|
|
@@ -427,14 +563,14 @@ const K = class K {
|
|
|
427
563
|
try {
|
|
428
564
|
return { Authorization: `Bearer ${await this.getValidAccessToken()}` };
|
|
429
565
|
} catch (e) {
|
|
430
|
-
return e instanceof
|
|
566
|
+
return e instanceof ee && this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
431
567
|
}
|
|
432
568
|
}
|
|
433
569
|
enqueueForToken() {
|
|
434
570
|
return new Promise((e, t) => {
|
|
435
571
|
const n = setTimeout(() => {
|
|
436
572
|
const i = this.refreshQueue.findIndex((a) => a.timeoutId === n);
|
|
437
|
-
i !== -1 && this.refreshQueue.splice(i, 1), t(new
|
|
573
|
+
i !== -1 && this.refreshQueue.splice(i, 1), t(new St(this.refreshQueueTimeout));
|
|
438
574
|
}, this.refreshQueueTimeout);
|
|
439
575
|
this.refreshQueue.push({ resolve: e, reject: t, timeoutId: n });
|
|
440
576
|
});
|
|
@@ -447,7 +583,7 @@ const K = class K {
|
|
|
447
583
|
return this.resolveQueue(n), n;
|
|
448
584
|
} catch (t) {
|
|
449
585
|
const n = t instanceof Error ? t : new Error("Token refresh failed");
|
|
450
|
-
throw n instanceof
|
|
586
|
+
throw n instanceof ee ? (this.rejectQueue(n), this.handleSessionExpired(n)) : this.rejectQueue(n), n;
|
|
451
587
|
} finally {
|
|
452
588
|
this.refreshPromise = null;
|
|
453
589
|
}
|
|
@@ -470,13 +606,13 @@ const K = class K {
|
|
|
470
606
|
const n = this.sessionGeneration;
|
|
471
607
|
for (let i = 0; i <= this.maxRefreshRetries; i++) {
|
|
472
608
|
if (this.sessionGeneration !== n)
|
|
473
|
-
throw new
|
|
609
|
+
throw new ee("token_invalid", "Session cleared during refresh");
|
|
474
610
|
try {
|
|
475
611
|
await this.performTokenRefresh(e, n);
|
|
476
612
|
return;
|
|
477
613
|
} catch (a) {
|
|
478
614
|
const l = a instanceof Error ? a : new Error(String(a));
|
|
479
|
-
if (l instanceof
|
|
615
|
+
if (l instanceof ee)
|
|
480
616
|
throw l;
|
|
481
617
|
if (t = l, i < this.maxRefreshRetries) {
|
|
482
618
|
const d = this.retryBackoffBase * Math.pow(2, i);
|
|
@@ -484,7 +620,7 @@ const K = class K {
|
|
|
484
620
|
}
|
|
485
621
|
}
|
|
486
622
|
}
|
|
487
|
-
throw new
|
|
623
|
+
throw new kt(this.maxRefreshRetries + 1, t);
|
|
488
624
|
}
|
|
489
625
|
/**
|
|
490
626
|
* Single refresh attempt with error classification.
|
|
@@ -503,7 +639,7 @@ const K = class K {
|
|
|
503
639
|
const n = this.getTokens();
|
|
504
640
|
if (n != null && n.accessToken && !this.isTokenExpired(n) && !this.shouldRefreshToken(n))
|
|
505
641
|
return;
|
|
506
|
-
const i = (n == null ? void 0 : n.refreshToken) || e, a = `${this.baseUrl}/auth/refresh`, l =
|
|
642
|
+
const i = (n == null ? void 0 : n.refreshToken) || e, a = `${this.baseUrl}/auth/refresh`, l = xt(i, "deviceId"), d = { refreshToken: i };
|
|
507
643
|
l && (d.deviceId = l);
|
|
508
644
|
let T;
|
|
509
645
|
try {
|
|
@@ -519,20 +655,20 @@ const K = class K {
|
|
|
519
655
|
if (!T.ok) {
|
|
520
656
|
let c = "";
|
|
521
657
|
try {
|
|
522
|
-
const
|
|
523
|
-
c = (
|
|
658
|
+
const S = await T.json();
|
|
659
|
+
c = (S.message || S.error || "").toLowerCase();
|
|
524
660
|
} catch {
|
|
525
661
|
c = T.statusText.toLowerCase();
|
|
526
662
|
}
|
|
527
|
-
throw T.status === 401 ? c.includes("expired") ? new
|
|
663
|
+
throw T.status === 401 ? c.includes("expired") ? new ee("token_expired") : c.includes("invalid") ? new ee("token_invalid") : new ee("token_invalid", `Unauthorized: ${c}`) : T.status === 400 ? c.includes("inactive") ? new ee("user_inactive") : c.includes("expired") || c.includes("invalid") ? new ee("token_invalid", c) : c.includes("reuse") || c.includes("revoked") ? new ee("token_invalid", c) : new Error(`Token refresh failed (400): ${c}`) : new Error(`Token refresh failed: ${T.status} ${c}`);
|
|
528
664
|
}
|
|
529
665
|
if (this.sessionGeneration !== t)
|
|
530
|
-
throw new
|
|
531
|
-
const
|
|
666
|
+
throw new ee("token_invalid", "Session cleared during refresh");
|
|
667
|
+
const R = await T.json();
|
|
532
668
|
this.setTokens({
|
|
533
|
-
accessToken:
|
|
534
|
-
refreshToken:
|
|
535
|
-
expiresIn:
|
|
669
|
+
accessToken: R.accessToken,
|
|
670
|
+
refreshToken: R.refreshToken || i,
|
|
671
|
+
expiresIn: R.expiresIn
|
|
536
672
|
});
|
|
537
673
|
}
|
|
538
674
|
// --- Session expiry handler ---
|
|
@@ -555,7 +691,7 @@ const K = class K {
|
|
|
555
691
|
// --- Session lifecycle ---
|
|
556
692
|
clearSession() {
|
|
557
693
|
this.sessionGeneration++, this.cancelProactiveTimer(), this.clearTokens();
|
|
558
|
-
const e = new
|
|
694
|
+
const e = new ee("token_invalid", "Session cleared");
|
|
559
695
|
this.rejectQueue(e);
|
|
560
696
|
}
|
|
561
697
|
/**
|
|
@@ -563,15 +699,15 @@ const K = class K {
|
|
|
563
699
|
* Cancels all timers and rejects pending queue entries.
|
|
564
700
|
*/
|
|
565
701
|
destroy() {
|
|
566
|
-
this.isDestroyed = !0,
|
|
567
|
-
const e = new
|
|
702
|
+
this.isDestroyed = !0, ie.instances.delete(this.storageKey), this.cancelProactiveTimer(), this.detachVisibilityListener();
|
|
703
|
+
const e = new ee("token_invalid", "SessionManager destroyed");
|
|
568
704
|
this.rejectQueue(e);
|
|
569
705
|
}
|
|
570
706
|
// --- JWT helpers ---
|
|
571
707
|
getTokenPayload() {
|
|
572
|
-
var t;
|
|
708
|
+
var t, n;
|
|
573
709
|
const e = (t = this.getTokens()) == null ? void 0 : t.accessToken;
|
|
574
|
-
return e ?
|
|
710
|
+
return e ? ((n = Ae(e)) == null ? void 0 : n.payload) ?? null : null;
|
|
575
711
|
}
|
|
576
712
|
/**
|
|
577
713
|
* Get userId from token (source of truth) or fallback to stored user
|
|
@@ -591,11 +727,11 @@ const K = class K {
|
|
|
591
727
|
return new Promise((t) => setTimeout(t, e));
|
|
592
728
|
}
|
|
593
729
|
};
|
|
594
|
-
|
|
595
|
-
let
|
|
596
|
-
class
|
|
730
|
+
ie.instances = /* @__PURE__ */ new Map(), ie.MAX_BACKGROUND_FAILURES = 3;
|
|
731
|
+
let Me = ie;
|
|
732
|
+
class Nt {
|
|
597
733
|
constructor(e) {
|
|
598
|
-
this.httpService = e, this.pendingVerifications = /* @__PURE__ */ new Map();
|
|
734
|
+
this.httpService = e, this.pendingVerifications = /* @__PURE__ */ new Map(), this.pendingMagicLinks = /* @__PURE__ */ new Map();
|
|
599
735
|
}
|
|
600
736
|
// Public endpoints - no auth required
|
|
601
737
|
async login(e) {
|
|
@@ -626,10 +762,17 @@ class bt {
|
|
|
626
762
|
await this.httpService.post("/auth/password-reset/request", e);
|
|
627
763
|
}
|
|
628
764
|
async sendMagicLink(e) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
e
|
|
632
|
-
|
|
765
|
+
const t = JSON.stringify([
|
|
766
|
+
e.email,
|
|
767
|
+
e.tenantId,
|
|
768
|
+
e.appId ?? "",
|
|
769
|
+
e.frontendUrl ?? ""
|
|
770
|
+
]), n = this.pendingMagicLinks.get(t);
|
|
771
|
+
if (n) return n;
|
|
772
|
+
const i = this.httpService.post("/auth/magic-link/send", e).finally(() => {
|
|
773
|
+
this.pendingMagicLinks.delete(t);
|
|
774
|
+
});
|
|
775
|
+
return this.pendingMagicLinks.set(t, i), i;
|
|
633
776
|
}
|
|
634
777
|
async verifyMagicLink(e) {
|
|
635
778
|
const t = e.token, n = this.pendingVerifications.get(t);
|
|
@@ -646,7 +789,7 @@ class bt {
|
|
|
646
789
|
await this.httpService.post("/auth/change-password", e);
|
|
647
790
|
}
|
|
648
791
|
}
|
|
649
|
-
class
|
|
792
|
+
class Ct {
|
|
650
793
|
constructor(e) {
|
|
651
794
|
this.httpService = e;
|
|
652
795
|
}
|
|
@@ -664,7 +807,7 @@ class wt {
|
|
|
664
807
|
}
|
|
665
808
|
async getRolesByApp(e, t) {
|
|
666
809
|
const n = await this.httpService.get(
|
|
667
|
-
`/roles/app/${e}${
|
|
810
|
+
`/roles/app/${e}${ce(t)}`,
|
|
668
811
|
{ skipAuth: !0 }
|
|
669
812
|
);
|
|
670
813
|
return { roles: n.data, meta: n.meta };
|
|
@@ -677,12 +820,12 @@ class wt {
|
|
|
677
820
|
}
|
|
678
821
|
async getUserRoles(e, t) {
|
|
679
822
|
const n = await this.httpService.get(
|
|
680
|
-
`/roles/user/${e}${
|
|
823
|
+
`/roles/user/${e}${ce(t)}`
|
|
681
824
|
);
|
|
682
825
|
return { roles: n.data, meta: n.meta };
|
|
683
826
|
}
|
|
684
827
|
}
|
|
685
|
-
class
|
|
828
|
+
class Dt {
|
|
686
829
|
constructor(e) {
|
|
687
830
|
this.httpService = e;
|
|
688
831
|
}
|
|
@@ -691,7 +834,7 @@ class vt {
|
|
|
691
834
|
}
|
|
692
835
|
async getUsers(e) {
|
|
693
836
|
const t = await this.httpService.get(
|
|
694
|
-
`/users/${
|
|
837
|
+
`/users/${ce(e)}`
|
|
695
838
|
);
|
|
696
839
|
return { users: t.data, meta: t.meta };
|
|
697
840
|
}
|
|
@@ -705,7 +848,7 @@ class vt {
|
|
|
705
848
|
await this.httpService.delete(`/users/${e}`);
|
|
706
849
|
}
|
|
707
850
|
}
|
|
708
|
-
class
|
|
851
|
+
class ye {
|
|
709
852
|
constructor(e, t) {
|
|
710
853
|
this.httpService = e, this.appId = t;
|
|
711
854
|
}
|
|
@@ -714,7 +857,7 @@ class me {
|
|
|
714
857
|
}
|
|
715
858
|
async getTenants(e) {
|
|
716
859
|
const t = await this.httpService.get(
|
|
717
|
-
`/tenants/${
|
|
860
|
+
`/tenants/${ce(e)}`
|
|
718
861
|
);
|
|
719
862
|
return { tenants: t.data, meta: t.meta };
|
|
720
863
|
}
|
|
@@ -749,7 +892,7 @@ class me {
|
|
|
749
892
|
)).data;
|
|
750
893
|
}
|
|
751
894
|
}
|
|
752
|
-
function
|
|
895
|
+
function Mt(r, e) {
|
|
753
896
|
if (r === "localhost" || r.startsWith("127.") || r.startsWith("192.168."))
|
|
754
897
|
return null;
|
|
755
898
|
if (e) {
|
|
@@ -765,24 +908,24 @@ function Tt(r, e) {
|
|
|
765
908
|
const n = r.split(".");
|
|
766
909
|
return n.length >= 3 && n[0] !== "www" ? n[0] : null;
|
|
767
910
|
}
|
|
768
|
-
function
|
|
911
|
+
function $t(r, e = "tenant", t) {
|
|
769
912
|
const i = new URLSearchParams(r).get(e);
|
|
770
913
|
return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
|
|
771
914
|
}
|
|
772
|
-
function
|
|
915
|
+
function Ut(r, e, t) {
|
|
773
916
|
const { tenantMode: n, baseDomain: i, selectorParam: a, fixedTenantSlug: l } = r;
|
|
774
|
-
return n === "fixed" ? l || null : n === "subdomain" ?
|
|
917
|
+
return n === "fixed" ? l || null : n === "subdomain" ? Mt(e.hostname, i) : n === "selector" ? $t(e.search, a, t) : null;
|
|
775
918
|
}
|
|
776
|
-
function
|
|
919
|
+
function Bt(r, e, t) {
|
|
777
920
|
if (t)
|
|
778
921
|
return `${r}.${t}`;
|
|
779
922
|
const n = e.split(".");
|
|
780
923
|
return n.length === 2 ? `${r}.${e}` : n.length >= 3 ? (n[0] = r, n.join(".")) : null;
|
|
781
924
|
}
|
|
782
|
-
const
|
|
783
|
-
function
|
|
925
|
+
const Be = fe(null);
|
|
926
|
+
function Er({ config: r, children: e }) {
|
|
784
927
|
var j, Z, $;
|
|
785
|
-
const { baseUrl: t, appInfo: n, appId: i } =
|
|
928
|
+
const { baseUrl: t, appInfo: n, appId: i } = Re(), a = te(() => typeof window > "u" ? null : Ut(
|
|
786
929
|
{
|
|
787
930
|
tenantMode: r.tenantMode || "selector",
|
|
788
931
|
baseDomain: r.baseDomain,
|
|
@@ -794,111 +937,111 @@ function ur({ config: r, children: e }) {
|
|
|
794
937
|
search: window.location.search
|
|
795
938
|
},
|
|
796
939
|
window.localStorage
|
|
797
|
-
), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [l, d] = N(() => a()), T = ((j = r.cache) == null ? void 0 : j.enabled) ?? !0,
|
|
798
|
-
() => ({ enabled: T, ttl:
|
|
799
|
-
[T,
|
|
800
|
-
), [h,
|
|
940
|
+
), [r.tenantMode, r.baseDomain, r.selectorParam, r.fixedTenantSlug]), [l, d] = N(() => a()), T = ((j = r.cache) == null ? void 0 : j.enabled) ?? !0, R = ((Z = r.cache) == null ? void 0 : Z.ttl) ?? 5 * 60 * 1e3, c = (($ = r.cache) == null ? void 0 : $.storageKey) ?? `tenant_cache_${l || "default"}`, S = V(
|
|
941
|
+
() => ({ enabled: T, ttl: R, storageKey: c }),
|
|
942
|
+
[T, R, c]
|
|
943
|
+
), [h, x] = N(() => {
|
|
801
944
|
if (r.initialTenant) return r.initialTenant;
|
|
802
|
-
if (!
|
|
945
|
+
if (!S.enabled || !l) return null;
|
|
803
946
|
try {
|
|
804
|
-
const
|
|
805
|
-
if (!
|
|
806
|
-
const
|
|
807
|
-
return Date.now() -
|
|
947
|
+
const U = localStorage.getItem(S.storageKey);
|
|
948
|
+
if (!U) return null;
|
|
949
|
+
const L = JSON.parse(U);
|
|
950
|
+
return Date.now() - L.timestamp < S.ttl && L.tenantSlug === l ? L.data : (localStorage.removeItem(S.storageKey), null);
|
|
808
951
|
} catch {
|
|
809
952
|
return null;
|
|
810
953
|
}
|
|
811
|
-
}), [
|
|
812
|
-
|
|
954
|
+
}), [P, I] = N(!h && !r.initialTenant), [A, k] = N(null), [m, g] = N(null), [b, C] = N(!1), [o, p] = N(null);
|
|
955
|
+
re(() => {
|
|
813
956
|
if (r.tenantMode === "fixed") return;
|
|
814
|
-
const
|
|
815
|
-
d(
|
|
957
|
+
const U = a();
|
|
958
|
+
d(U);
|
|
816
959
|
}, [a, r.tenantMode]);
|
|
817
|
-
const
|
|
818
|
-
async (
|
|
819
|
-
if (!(!
|
|
960
|
+
const E = (n == null ? void 0 : n.settingsSchema) || null, y = te(
|
|
961
|
+
async (U, L = !1) => {
|
|
962
|
+
if (!(!L && S.enabled && h && h.subdomain === U))
|
|
820
963
|
try {
|
|
821
|
-
I(!0),
|
|
822
|
-
const
|
|
823
|
-
if (
|
|
964
|
+
I(!0), k(null);
|
|
965
|
+
const q = new he(t), W = await new ye(q, i).getPublicTenantInfo(U);
|
|
966
|
+
if (x(W), S.enabled)
|
|
824
967
|
try {
|
|
825
|
-
const
|
|
968
|
+
const K = {
|
|
826
969
|
data: W,
|
|
827
970
|
timestamp: Date.now(),
|
|
828
|
-
tenantSlug:
|
|
971
|
+
tenantSlug: U
|
|
829
972
|
};
|
|
830
|
-
localStorage.setItem(
|
|
831
|
-
} catch (
|
|
832
|
-
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Failed to cache tenant info:",
|
|
973
|
+
localStorage.setItem(S.storageKey, JSON.stringify(K));
|
|
974
|
+
} catch (K) {
|
|
975
|
+
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Failed to cache tenant info:", K);
|
|
833
976
|
}
|
|
834
|
-
} catch (
|
|
835
|
-
const
|
|
836
|
-
|
|
977
|
+
} catch (q) {
|
|
978
|
+
const _ = q instanceof Error ? q : new Error("Failed to load tenant information");
|
|
979
|
+
k(_), x(null);
|
|
837
980
|
} finally {
|
|
838
981
|
I(!1);
|
|
839
982
|
}
|
|
840
983
|
},
|
|
841
|
-
[t, i,
|
|
842
|
-
), u =
|
|
843
|
-
if (!(!
|
|
984
|
+
[t, i, S, h]
|
|
985
|
+
), u = te(async () => {
|
|
986
|
+
if (!(!S.enabled || !h || !l))
|
|
844
987
|
try {
|
|
845
|
-
const
|
|
846
|
-
if (!
|
|
847
|
-
const
|
|
848
|
-
if (Date.now() -
|
|
849
|
-
const
|
|
850
|
-
|
|
851
|
-
const
|
|
852
|
-
data:
|
|
988
|
+
const U = localStorage.getItem(S.storageKey);
|
|
989
|
+
if (!U) return;
|
|
990
|
+
const L = JSON.parse(U);
|
|
991
|
+
if (Date.now() - L.timestamp > S.ttl * 0.5) {
|
|
992
|
+
const _ = new he(t), K = await new ye(_, i).getPublicTenantInfo(l);
|
|
993
|
+
x(K);
|
|
994
|
+
const Y = {
|
|
995
|
+
data: K,
|
|
853
996
|
timestamp: Date.now(),
|
|
854
997
|
tenantSlug: l
|
|
855
998
|
};
|
|
856
|
-
localStorage.setItem(
|
|
999
|
+
localStorage.setItem(S.storageKey, JSON.stringify(Y));
|
|
857
1000
|
}
|
|
858
|
-
} catch (
|
|
859
|
-
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:",
|
|
1001
|
+
} catch (U) {
|
|
1002
|
+
process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", U);
|
|
860
1003
|
}
|
|
861
|
-
}, [t, i,
|
|
1004
|
+
}, [t, i, S, h, l]), v = te(async () => {
|
|
862
1005
|
if (h != null && h.id)
|
|
863
1006
|
try {
|
|
864
|
-
|
|
865
|
-
const
|
|
866
|
-
g(
|
|
867
|
-
} catch (
|
|
868
|
-
const
|
|
869
|
-
p(
|
|
1007
|
+
C(!0), p(null);
|
|
1008
|
+
const U = new he(t), q = await new ye(U, h.appId).getTenantSettings(h.id);
|
|
1009
|
+
g(q);
|
|
1010
|
+
} catch (U) {
|
|
1011
|
+
const L = U instanceof Error ? U : new Error("Failed to load tenant settings");
|
|
1012
|
+
p(L), g(null);
|
|
870
1013
|
} finally {
|
|
871
|
-
|
|
1014
|
+
C(!1);
|
|
872
1015
|
}
|
|
873
|
-
}, [t, h]),
|
|
1016
|
+
}, [t, h]), D = te(() => {
|
|
874
1017
|
v();
|
|
875
|
-
}, [v]),
|
|
876
|
-
(
|
|
877
|
-
if (!
|
|
1018
|
+
}, [v]), se = te(
|
|
1019
|
+
(U) => {
|
|
1020
|
+
if (!E)
|
|
878
1021
|
return { isValid: !0, errors: [] };
|
|
879
|
-
const
|
|
1022
|
+
const L = [];
|
|
880
1023
|
try {
|
|
881
|
-
return
|
|
882
|
-
var
|
|
883
|
-
const W =
|
|
884
|
-
if ((
|
|
885
|
-
|
|
1024
|
+
return E.properties && Object.entries(E.properties).forEach(([q, _]) => {
|
|
1025
|
+
var K;
|
|
1026
|
+
const W = U[q];
|
|
1027
|
+
if ((K = E.required) != null && K.includes(q) && W == null) {
|
|
1028
|
+
L.push(`Field '${q}' is required`);
|
|
886
1029
|
return;
|
|
887
1030
|
}
|
|
888
1031
|
if (W != null) {
|
|
889
|
-
if (
|
|
890
|
-
const
|
|
891
|
-
|
|
1032
|
+
if (_.type) {
|
|
1033
|
+
const Y = _.type, le = typeof W;
|
|
1034
|
+
Y === "string" && le !== "string" ? L.push(`Field '${q}' must be a string`) : (Y === "number" || Y === "integer") && le !== "number" ? L.push(`Field '${q}' must be a number`) : Y === "boolean" && le !== "boolean" ? L.push(`Field '${q}' must be a boolean`) : Y === "array" && !Array.isArray(W) && L.push(`Field '${q}' must be an array`);
|
|
892
1035
|
}
|
|
893
|
-
|
|
894
|
-
`Field '${
|
|
895
|
-
),
|
|
896
|
-
`Field '${
|
|
897
|
-
),
|
|
1036
|
+
_.minLength !== void 0 && typeof W == "string" && W.length < _.minLength && L.push(
|
|
1037
|
+
`Field '${q}' must be at least ${_.minLength} characters long`
|
|
1038
|
+
), _.maxLength !== void 0 && typeof W == "string" && W.length > _.maxLength && L.push(
|
|
1039
|
+
`Field '${q}' must be no more than ${_.maxLength} characters long`
|
|
1040
|
+
), _.minimum !== void 0 && typeof W == "number" && W < _.minimum && L.push(`Field '${q}' must be at least ${_.minimum}`), _.maximum !== void 0 && typeof W == "number" && W > _.maximum && L.push(`Field '${q}' must be no more than ${_.maximum}`), _.pattern && typeof W == "string" && (new RegExp(_.pattern).test(W) || L.push(`Field '${q}' does not match the required pattern`)), _.enum && !_.enum.includes(W) && L.push(`Field '${q}' must be one of: ${_.enum.join(", ")}`);
|
|
898
1041
|
}
|
|
899
1042
|
}), {
|
|
900
|
-
isValid:
|
|
901
|
-
errors:
|
|
1043
|
+
isValid: L.length === 0,
|
|
1044
|
+
errors: L
|
|
902
1045
|
};
|
|
903
1046
|
} catch {
|
|
904
1047
|
return {
|
|
@@ -907,98 +1050,98 @@ function ur({ config: r, children: e }) {
|
|
|
907
1050
|
};
|
|
908
1051
|
}
|
|
909
1052
|
},
|
|
910
|
-
[
|
|
1053
|
+
[E]
|
|
911
1054
|
);
|
|
912
|
-
|
|
913
|
-
!r.initialTenant && l ? h ? u() : y(l) : !r.initialTenant && !l && (
|
|
914
|
-
}, [r.initialTenant, l, h, y, u]),
|
|
915
|
-
h != null && h.id ? v() : (g(null), p(null),
|
|
1055
|
+
re(() => {
|
|
1056
|
+
!r.initialTenant && l ? h ? u() : y(l) : !r.initialTenant && !l && (x(null), k(null), I(!1));
|
|
1057
|
+
}, [r.initialTenant, l, h, y, u]), re(() => {
|
|
1058
|
+
h != null && h.id ? v() : (g(null), p(null), C(!1));
|
|
916
1059
|
}, [h == null ? void 0 : h.id, v]);
|
|
917
|
-
const
|
|
918
|
-
(
|
|
919
|
-
const { mode:
|
|
1060
|
+
const F = te(
|
|
1061
|
+
(U, L) => {
|
|
1062
|
+
const { mode: q = "reload", redirectPath: _ } = L || {}, W = r.tenantMode || "selector";
|
|
920
1063
|
if (W === "fixed") {
|
|
921
1064
|
process.env.NODE_ENV === "development" && console.warn(
|
|
922
1065
|
"[TenantProvider] switchTenant is a no-op in fixed mode. Tenant is always:",
|
|
923
1066
|
r.fixedTenantSlug
|
|
924
|
-
),
|
|
1067
|
+
), _ && (window.location.href = _);
|
|
925
1068
|
return;
|
|
926
1069
|
}
|
|
927
|
-
if (localStorage.setItem("tenant",
|
|
928
|
-
const
|
|
929
|
-
|
|
930
|
-
|
|
1070
|
+
if (localStorage.setItem("tenant", U), W === "subdomain") {
|
|
1071
|
+
const K = window.location.hostname, Y = Bt(
|
|
1072
|
+
U,
|
|
1073
|
+
K,
|
|
931
1074
|
r.baseDomain
|
|
932
1075
|
);
|
|
933
|
-
if (!
|
|
1076
|
+
if (!Y) {
|
|
934
1077
|
process.env.NODE_ENV === "development" && console.warn(
|
|
935
1078
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
936
|
-
|
|
1079
|
+
K
|
|
937
1080
|
);
|
|
938
1081
|
return;
|
|
939
1082
|
}
|
|
940
|
-
const
|
|
941
|
-
new URLSearchParams(window.location.search).forEach((
|
|
942
|
-
|
|
943
|
-
}), window.location.href =
|
|
1083
|
+
const le = _ || window.location.pathname, Te = new URL(`${window.location.protocol}//${Y}${le}`);
|
|
1084
|
+
new URLSearchParams(window.location.search).forEach((Fe, Ne) => {
|
|
1085
|
+
Te.searchParams.set(Ne, Fe);
|
|
1086
|
+
}), window.location.href = Te.toString();
|
|
944
1087
|
} else if (W === "selector") {
|
|
945
|
-
const
|
|
946
|
-
if (
|
|
947
|
-
const
|
|
948
|
-
window.location.href =
|
|
1088
|
+
const K = _ || window.location.pathname, Y = new URLSearchParams(window.location.search);
|
|
1089
|
+
if (Y.set(r.selectorParam || "tenant", U), q === "reload") {
|
|
1090
|
+
const le = `${K}?${Y.toString()}${window.location.hash}`;
|
|
1091
|
+
window.location.href = le;
|
|
949
1092
|
} else {
|
|
950
|
-
const
|
|
951
|
-
window.history.pushState({}, "",
|
|
1093
|
+
const le = `${K}?${Y.toString()}${window.location.hash}`;
|
|
1094
|
+
window.history.pushState({}, "", le), d(U), y(U);
|
|
952
1095
|
}
|
|
953
1096
|
}
|
|
954
1097
|
},
|
|
955
1098
|
[r.tenantMode, r.selectorParam, r.baseDomain, r.fixedTenantSlug, y]
|
|
956
|
-
), H =
|
|
1099
|
+
), H = V(() => ({
|
|
957
1100
|
// Tenant info
|
|
958
1101
|
tenant: h,
|
|
959
1102
|
tenantSlug: l,
|
|
960
|
-
isTenantLoading:
|
|
1103
|
+
isTenantLoading: P,
|
|
961
1104
|
tenantError: A,
|
|
962
1105
|
retryTenant: () => {
|
|
963
1106
|
l && y(l);
|
|
964
1107
|
},
|
|
965
1108
|
// Settings
|
|
966
1109
|
settings: m,
|
|
967
|
-
settingsSchema:
|
|
1110
|
+
settingsSchema: E,
|
|
968
1111
|
isSettingsLoading: b,
|
|
969
1112
|
settingsError: o,
|
|
970
1113
|
// Actions
|
|
971
|
-
refreshSettings:
|
|
972
|
-
switchTenant:
|
|
1114
|
+
refreshSettings: D,
|
|
1115
|
+
switchTenant: F,
|
|
973
1116
|
// Validation
|
|
974
|
-
validateSettings:
|
|
1117
|
+
validateSettings: se
|
|
975
1118
|
}), [
|
|
976
1119
|
h,
|
|
977
1120
|
l,
|
|
978
|
-
|
|
1121
|
+
P,
|
|
979
1122
|
A,
|
|
980
1123
|
m,
|
|
981
|
-
|
|
1124
|
+
E,
|
|
982
1125
|
b,
|
|
983
1126
|
o,
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1127
|
+
D,
|
|
1128
|
+
F,
|
|
1129
|
+
se
|
|
987
1130
|
]);
|
|
988
|
-
return /* @__PURE__ */ s(
|
|
1131
|
+
return /* @__PURE__ */ s(Be.Provider, { value: H, children: e });
|
|
989
1132
|
}
|
|
990
|
-
function
|
|
991
|
-
const r =
|
|
1133
|
+
function ve() {
|
|
1134
|
+
const r = ne(Be);
|
|
992
1135
|
if (!r)
|
|
993
1136
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
994
1137
|
return r;
|
|
995
1138
|
}
|
|
996
|
-
function
|
|
997
|
-
return
|
|
1139
|
+
function pe() {
|
|
1140
|
+
return ne(Be);
|
|
998
1141
|
}
|
|
999
|
-
const
|
|
1000
|
-
function
|
|
1001
|
-
const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } =
|
|
1142
|
+
const xr = ve;
|
|
1143
|
+
function Rr() {
|
|
1144
|
+
const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = ve();
|
|
1002
1145
|
return {
|
|
1003
1146
|
settings: r,
|
|
1004
1147
|
settingsSchema: e,
|
|
@@ -1007,8 +1150,8 @@ function hr() {
|
|
|
1007
1150
|
validateSettings: i
|
|
1008
1151
|
};
|
|
1009
1152
|
}
|
|
1010
|
-
function
|
|
1011
|
-
const { tenant: r, tenantSlug: e, isTenantLoading: t, tenantError: n, retryTenant: i } =
|
|
1153
|
+
function ot() {
|
|
1154
|
+
const { tenant: r, tenantSlug: e, isTenantLoading: t, tenantError: n, retryTenant: i } = ve();
|
|
1012
1155
|
return {
|
|
1013
1156
|
tenant: r,
|
|
1014
1157
|
tenantSlug: e,
|
|
@@ -1017,265 +1160,265 @@ function et() {
|
|
|
1017
1160
|
retry: i
|
|
1018
1161
|
};
|
|
1019
1162
|
}
|
|
1020
|
-
const
|
|
1021
|
-
function
|
|
1163
|
+
const _e = "userTenants";
|
|
1164
|
+
function _t() {
|
|
1022
1165
|
try {
|
|
1023
|
-
const r = localStorage.getItem(
|
|
1166
|
+
const r = localStorage.getItem(_e);
|
|
1024
1167
|
return r ? JSON.parse(r) : [];
|
|
1025
1168
|
} catch {
|
|
1026
1169
|
return [];
|
|
1027
1170
|
}
|
|
1028
1171
|
}
|
|
1029
|
-
function
|
|
1172
|
+
function Xe(r) {
|
|
1030
1173
|
try {
|
|
1031
|
-
localStorage.setItem(
|
|
1174
|
+
localStorage.setItem(_e, JSON.stringify(r));
|
|
1032
1175
|
} catch {
|
|
1033
1176
|
}
|
|
1034
1177
|
}
|
|
1035
|
-
function
|
|
1178
|
+
function et() {
|
|
1036
1179
|
try {
|
|
1037
|
-
localStorage.removeItem(
|
|
1180
|
+
localStorage.removeItem(_e);
|
|
1038
1181
|
} catch {
|
|
1039
1182
|
}
|
|
1040
1183
|
}
|
|
1041
|
-
const
|
|
1042
|
-
function
|
|
1043
|
-
const t =
|
|
1184
|
+
const Pe = fe(null), Ie = fe(null);
|
|
1185
|
+
function Ar({ config: r = {}, children: e }) {
|
|
1186
|
+
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? r.baseUrl ?? "", a = (t == null ? void 0 : t.appId) ?? r.appId, l = (n == null ? void 0 : n.tenant) ?? null, d = (n == null ? void 0 : n.tenantSlug) ?? null, T = (n == null ? void 0 : n.switchTenant) ?? (() => {
|
|
1044
1187
|
});
|
|
1045
1188
|
if (!i)
|
|
1046
1189
|
throw new Error(
|
|
1047
1190
|
"[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
|
|
1048
1191
|
);
|
|
1049
|
-
const [
|
|
1050
|
-
|
|
1051
|
-
const o =
|
|
1192
|
+
const [R, c] = N(r.initialRoles || []), [S, h] = N(!r.initialRoles), [x, P] = N(null), [I, A] = N(!1), [k, m] = N(null), [g, b] = N(() => _t()), C = Ee({ done: !1 });
|
|
1193
|
+
C.current.done || (C.current.done = !0);
|
|
1194
|
+
const o = V(() => Me.getInstance({
|
|
1052
1195
|
baseUrl: i,
|
|
1053
1196
|
enableCookieSession: r.enableCookieSession,
|
|
1054
1197
|
refreshQueueTimeout: r.refreshQueueTimeout,
|
|
1055
1198
|
proactiveRefreshMargin: r.proactiveRefreshMargin,
|
|
1056
1199
|
onSessionExpired: (w) => {
|
|
1057
|
-
|
|
1200
|
+
P(null), m(null), b([]), et(), r.onSessionExpired ? r.onSessionExpired(w) : r.onRefreshFailed && r.onRefreshFailed();
|
|
1058
1201
|
}
|
|
1059
1202
|
}), [
|
|
1060
1203
|
i,
|
|
1061
1204
|
r.enableCookieSession,
|
|
1062
1205
|
r.refreshQueueTimeout,
|
|
1063
1206
|
r.proactiveRefreshMargin
|
|
1064
|
-
]), [p,
|
|
1207
|
+
]), [p, E] = N(() => {
|
|
1065
1208
|
const w = o.getTokens();
|
|
1066
1209
|
return w ? o.hasValidSession() || !!w.refreshToken : !!r.enableCookieSession;
|
|
1067
|
-
}), y =
|
|
1068
|
-
const w = new
|
|
1210
|
+
}), y = C.current.done && !p, u = V(() => {
|
|
1211
|
+
const w = new he(i);
|
|
1069
1212
|
return w.setSessionManager(o), w;
|
|
1070
|
-
}, [i, o]), v =
|
|
1071
|
-
() => new
|
|
1213
|
+
}, [i, o]), v = V(
|
|
1214
|
+
() => new Nt(u),
|
|
1072
1215
|
[u]
|
|
1073
|
-
),
|
|
1074
|
-
() => new
|
|
1216
|
+
), D = V(
|
|
1217
|
+
() => new Dt(u),
|
|
1075
1218
|
[u]
|
|
1076
|
-
),
|
|
1077
|
-
() => new
|
|
1219
|
+
), se = V(
|
|
1220
|
+
() => new Ct(u),
|
|
1078
1221
|
[u]
|
|
1079
|
-
),
|
|
1080
|
-
() => o.hasValidSession() &&
|
|
1081
|
-
[o,
|
|
1082
|
-
), Z =
|
|
1222
|
+
), F = V(() => x != null && x.roleId && R.find((w) => w.id === x.roleId) || null, [x, R]), H = V(() => (F == null ? void 0 : F.permissions) || [], [F]), j = V(
|
|
1223
|
+
() => o.hasValidSession() && x !== null,
|
|
1224
|
+
[o, x]
|
|
1225
|
+
), Z = V(() => (x == null ? void 0 : x.tenantId) != null, [x]), $ = Ee(null), U = async (w = !1) => {
|
|
1083
1226
|
try {
|
|
1084
|
-
if (!o.hasValidSession() || !w &&
|
|
1085
|
-
const
|
|
1086
|
-
if (!
|
|
1227
|
+
if (!o.hasValidSession() || !w && x) return;
|
|
1228
|
+
const M = o.getUserId();
|
|
1229
|
+
if (!M) {
|
|
1087
1230
|
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] No userId available in token or storage");
|
|
1088
1231
|
return;
|
|
1089
1232
|
}
|
|
1090
1233
|
A(!0), m(null);
|
|
1091
|
-
const z = await
|
|
1092
|
-
|
|
1093
|
-
} catch (
|
|
1094
|
-
const z =
|
|
1234
|
+
const z = await D.getUserById(M);
|
|
1235
|
+
P(z), o.setUser(z);
|
|
1236
|
+
} catch (M) {
|
|
1237
|
+
const z = M instanceof Error ? M : new Error("Failed to load user data");
|
|
1095
1238
|
m(z), process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to load user data:", z);
|
|
1096
1239
|
} finally {
|
|
1097
1240
|
A(!1);
|
|
1098
1241
|
}
|
|
1099
|
-
},
|
|
1100
|
-
var
|
|
1101
|
-
const { username:
|
|
1102
|
-
let
|
|
1103
|
-
|
|
1242
|
+
}, L = async (w) => {
|
|
1243
|
+
var He;
|
|
1244
|
+
const { username: M, password: z, tenantSlug: O, redirectPath: Q } = w;
|
|
1245
|
+
let X = l == null ? void 0 : l.id, J = d;
|
|
1246
|
+
O && (X = (await new ye(u, a).getPublicTenantInfo(O)).id, J = O);
|
|
1104
1247
|
const G = await v.login({
|
|
1105
|
-
username:
|
|
1248
|
+
username: M,
|
|
1106
1249
|
password: z,
|
|
1107
1250
|
appId: a,
|
|
1108
|
-
tenantId:
|
|
1109
|
-
}),
|
|
1251
|
+
tenantId: X
|
|
1252
|
+
}), Se = O && O !== d;
|
|
1110
1253
|
if (o.setTokens({
|
|
1111
1254
|
accessToken: G.accessToken,
|
|
1112
1255
|
refreshToken: G.refreshToken,
|
|
1113
1256
|
expiresIn: G.expiresIn
|
|
1114
1257
|
}), G.user) {
|
|
1115
|
-
o.setUser(G.user),
|
|
1258
|
+
o.setUser(G.user), P(G.user);
|
|
1116
1259
|
try {
|
|
1117
|
-
await
|
|
1118
|
-
} catch (
|
|
1119
|
-
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:",
|
|
1260
|
+
await U();
|
|
1261
|
+
} catch (ke) {
|
|
1262
|
+
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", ke);
|
|
1120
1263
|
}
|
|
1121
1264
|
}
|
|
1122
|
-
G.tenants && G.tenants.length > 0 && (b(G.tenants),
|
|
1123
|
-
const
|
|
1124
|
-
if (
|
|
1265
|
+
G.tenants && G.tenants.length > 0 && (b(G.tenants), Xe(G.tenants));
|
|
1266
|
+
const Ge = ((He = G.user) == null ? void 0 : He.tenantId) !== null;
|
|
1267
|
+
if (Se && J)
|
|
1125
1268
|
return T(J, { redirectPath: Q }), G;
|
|
1126
1269
|
if (Q && Q !== window.location.pathname)
|
|
1127
1270
|
return T(J || d || "", { redirectPath: Q }), G;
|
|
1128
|
-
if (!
|
|
1129
|
-
const
|
|
1130
|
-
if (G.tenants.length === 1 &&
|
|
1131
|
-
const
|
|
1132
|
-
return T(
|
|
1271
|
+
if (!Ge && G.tenants && G.tenants.length > 0) {
|
|
1272
|
+
const ke = w.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
|
|
1273
|
+
if (G.tenants.length === 1 && ke) {
|
|
1274
|
+
const Qe = G.tenants[0];
|
|
1275
|
+
return T(Qe.subdomain, { redirectPath: Q }), G;
|
|
1133
1276
|
} else G.tenants.length > 1 && r.onTenantSelectionRequired && r.onTenantSelectionRequired(G.tenants);
|
|
1134
1277
|
}
|
|
1135
1278
|
return G;
|
|
1136
|
-
},
|
|
1137
|
-
const { email:
|
|
1138
|
-
if (!
|
|
1279
|
+
}, q = async (w) => {
|
|
1280
|
+
const { email: M, phoneNumber: z, name: O, password: Q, lastName: X, tenantId: J } = w;
|
|
1281
|
+
if (!M && !z)
|
|
1139
1282
|
throw new Error("Either email or phoneNumber is required");
|
|
1140
|
-
if (!
|
|
1283
|
+
if (!O || !Q)
|
|
1141
1284
|
throw new Error("Name and password are required");
|
|
1142
1285
|
return v.signup({
|
|
1143
|
-
email:
|
|
1286
|
+
email: M,
|
|
1144
1287
|
phoneNumber: z,
|
|
1145
|
-
name:
|
|
1288
|
+
name: O,
|
|
1146
1289
|
password: Q,
|
|
1147
1290
|
tenantId: J ?? (l == null ? void 0 : l.id),
|
|
1148
|
-
lastName:
|
|
1291
|
+
lastName: X,
|
|
1149
1292
|
appId: a
|
|
1150
1293
|
});
|
|
1151
|
-
},
|
|
1152
|
-
const { email:
|
|
1153
|
-
if (!
|
|
1294
|
+
}, _ = async (w) => {
|
|
1295
|
+
const { email: M, phoneNumber: z, name: O, password: Q, tenantName: X, lastName: J } = w;
|
|
1296
|
+
if (!M && !z)
|
|
1154
1297
|
throw new Error("Either email or phoneNumber is required");
|
|
1155
|
-
if (!
|
|
1298
|
+
if (!O || !Q || !X)
|
|
1156
1299
|
throw new Error("Name, password, and tenantName are required");
|
|
1157
1300
|
return v.signupTenantAdmin({
|
|
1158
|
-
email:
|
|
1301
|
+
email: M,
|
|
1159
1302
|
phoneNumber: z,
|
|
1160
|
-
name:
|
|
1303
|
+
name: O,
|
|
1161
1304
|
password: Q,
|
|
1162
|
-
tenantName:
|
|
1305
|
+
tenantName: X,
|
|
1163
1306
|
appId: a,
|
|
1164
1307
|
lastName: J
|
|
1165
1308
|
});
|
|
1166
1309
|
}, W = async (w) => {
|
|
1167
1310
|
await v.changePassword(w);
|
|
1168
|
-
},
|
|
1169
|
-
const { email:
|
|
1170
|
-
if (!
|
|
1311
|
+
}, K = async (w) => {
|
|
1312
|
+
const { email: M, tenantId: z } = w, O = z ?? (l == null ? void 0 : l.id);
|
|
1313
|
+
if (!O)
|
|
1171
1314
|
throw new Error("tenantId is required for password reset");
|
|
1172
|
-
await v.requestPasswordReset({ email:
|
|
1173
|
-
},
|
|
1315
|
+
await v.requestPasswordReset({ email: M, tenantId: O });
|
|
1316
|
+
}, Y = async (w) => {
|
|
1174
1317
|
await v.confirmPasswordReset(w);
|
|
1175
|
-
},
|
|
1176
|
-
const { email:
|
|
1318
|
+
}, le = async (w) => {
|
|
1319
|
+
const { email: M, frontendUrl: z, name: O, lastName: Q, tenantId: X } = w, J = X ?? (l == null ? void 0 : l.id);
|
|
1177
1320
|
if (!J)
|
|
1178
1321
|
throw new Error("tenantId is required for magic link authentication");
|
|
1179
1322
|
return v.sendMagicLink({
|
|
1180
|
-
email:
|
|
1323
|
+
email: M,
|
|
1181
1324
|
tenantId: J,
|
|
1182
1325
|
frontendUrl: z,
|
|
1183
|
-
name:
|
|
1326
|
+
name: O,
|
|
1184
1327
|
lastName: Q,
|
|
1185
1328
|
appId: a
|
|
1186
1329
|
});
|
|
1187
|
-
},
|
|
1188
|
-
const { token:
|
|
1189
|
-
let Q = l == null ? void 0 : l.id,
|
|
1190
|
-
|
|
1330
|
+
}, Te = async (w) => {
|
|
1331
|
+
const { token: M, email: z, tenantSlug: O } = w;
|
|
1332
|
+
let Q = l == null ? void 0 : l.id, X = d;
|
|
1333
|
+
O && (Q = (await new ye(u, a).getPublicTenantInfo(O)).id, X = O);
|
|
1191
1334
|
const J = await v.verifyMagicLink({
|
|
1192
|
-
token:
|
|
1335
|
+
token: M,
|
|
1193
1336
|
email: z,
|
|
1194
1337
|
appId: a,
|
|
1195
1338
|
tenantId: Q
|
|
1196
|
-
}), G =
|
|
1339
|
+
}), G = O && O !== d;
|
|
1197
1340
|
if (o.setTokens({
|
|
1198
1341
|
accessToken: J.accessToken,
|
|
1199
1342
|
refreshToken: J.refreshToken,
|
|
1200
1343
|
expiresIn: J.expiresIn
|
|
1201
1344
|
}), J.user) {
|
|
1202
|
-
o.setUser(J.user),
|
|
1345
|
+
o.setUser(J.user), P(J.user);
|
|
1203
1346
|
try {
|
|
1204
|
-
await
|
|
1205
|
-
} catch (
|
|
1206
|
-
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after magic link:",
|
|
1347
|
+
await U();
|
|
1348
|
+
} catch (Se) {
|
|
1349
|
+
process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after magic link:", Se);
|
|
1207
1350
|
}
|
|
1208
1351
|
}
|
|
1209
|
-
return G &&
|
|
1210
|
-
},
|
|
1352
|
+
return G && X && X !== d && T(X), J;
|
|
1353
|
+
}, We = async () => {
|
|
1211
1354
|
const w = o.getTokens();
|
|
1212
1355
|
if (!(w != null && w.refreshToken))
|
|
1213
1356
|
throw new Error("No refresh token available");
|
|
1214
|
-
const
|
|
1357
|
+
const M = await v.refreshToken({
|
|
1215
1358
|
refreshToken: w.refreshToken
|
|
1216
1359
|
});
|
|
1217
1360
|
o.setTokens({
|
|
1218
|
-
accessToken:
|
|
1219
|
-
refreshToken:
|
|
1220
|
-
expiresIn:
|
|
1361
|
+
accessToken: M.accessToken,
|
|
1362
|
+
refreshToken: M.refreshToken || w.refreshToken,
|
|
1363
|
+
expiresIn: M.expiresIn
|
|
1221
1364
|
});
|
|
1222
|
-
},
|
|
1223
|
-
o.clearSession(),
|
|
1224
|
-
},
|
|
1365
|
+
}, Fe = () => {
|
|
1366
|
+
o.clearSession(), P(null), m(null), b([]), et();
|
|
1367
|
+
}, Ne = (w) => {
|
|
1225
1368
|
o.setTokens(w);
|
|
1226
|
-
},
|
|
1227
|
-
o.clearSession(),
|
|
1228
|
-
},
|
|
1369
|
+
}, ht = () => o.hasValidSession(), pt = () => {
|
|
1370
|
+
o.clearSession(), P(null), m(null);
|
|
1371
|
+
}, ft = async () => {
|
|
1229
1372
|
if (a)
|
|
1230
1373
|
try {
|
|
1231
1374
|
h(!0);
|
|
1232
|
-
const { roles: w } = await
|
|
1375
|
+
const { roles: w } = await se.getRolesByApp(a);
|
|
1233
1376
|
c(w);
|
|
1234
1377
|
} catch (w) {
|
|
1235
1378
|
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", w);
|
|
1236
1379
|
} finally {
|
|
1237
1380
|
h(!1);
|
|
1238
1381
|
}
|
|
1239
|
-
},
|
|
1240
|
-
const { redirectPath: z } =
|
|
1241
|
-
if (!(
|
|
1382
|
+
}, mt = async (w, M) => {
|
|
1383
|
+
const { redirectPath: z } = M || {}, O = o.getTokens();
|
|
1384
|
+
if (!(O != null && O.refreshToken))
|
|
1242
1385
|
throw new Error("No refresh token available for tenant switch");
|
|
1243
1386
|
const Q = await v.switchTenant({
|
|
1244
|
-
refreshToken:
|
|
1387
|
+
refreshToken: O.refreshToken,
|
|
1245
1388
|
tenantId: w
|
|
1246
1389
|
});
|
|
1247
1390
|
o.setTokens({
|
|
1248
1391
|
accessToken: Q.accessToken,
|
|
1249
|
-
refreshToken:
|
|
1392
|
+
refreshToken: O.refreshToken,
|
|
1250
1393
|
expiresIn: Q.expiresIn
|
|
1251
|
-
}),
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1254
|
-
},
|
|
1394
|
+
}), P(Q.user), o.setUser(Q.user);
|
|
1395
|
+
const X = g.find((J) => J.id === w);
|
|
1396
|
+
X && T(X.subdomain, { redirectPath: z });
|
|
1397
|
+
}, gt = async () => {
|
|
1255
1398
|
const w = await v.getUserTenants();
|
|
1256
|
-
return b(w),
|
|
1399
|
+
return b(w), Xe(w), w;
|
|
1257
1400
|
};
|
|
1258
1401
|
$.current = {
|
|
1259
|
-
login:
|
|
1260
|
-
signup:
|
|
1261
|
-
signupTenantAdmin:
|
|
1262
|
-
sendMagicLink:
|
|
1263
|
-
verifyMagicLink:
|
|
1402
|
+
login: L,
|
|
1403
|
+
signup: q,
|
|
1404
|
+
signupTenantAdmin: _,
|
|
1405
|
+
sendMagicLink: le,
|
|
1406
|
+
verifyMagicLink: Te,
|
|
1264
1407
|
changePassword: W,
|
|
1265
|
-
requestPasswordReset:
|
|
1266
|
-
confirmPasswordReset:
|
|
1267
|
-
refreshToken:
|
|
1268
|
-
logout:
|
|
1269
|
-
setTokens:
|
|
1270
|
-
hasValidSession:
|
|
1271
|
-
clearSession:
|
|
1272
|
-
loadUserData:
|
|
1273
|
-
refreshUser: () =>
|
|
1274
|
-
refreshRoles:
|
|
1275
|
-
switchToTenant:
|
|
1276
|
-
refreshUserTenants:
|
|
1408
|
+
requestPasswordReset: K,
|
|
1409
|
+
confirmPasswordReset: Y,
|
|
1410
|
+
refreshToken: We,
|
|
1411
|
+
logout: Fe,
|
|
1412
|
+
setTokens: Ne,
|
|
1413
|
+
hasValidSession: ht,
|
|
1414
|
+
clearSession: pt,
|
|
1415
|
+
loadUserData: U,
|
|
1416
|
+
refreshUser: () => U(),
|
|
1417
|
+
refreshRoles: ft,
|
|
1418
|
+
switchToTenant: mt,
|
|
1419
|
+
refreshUserTenants: gt
|
|
1277
1420
|
};
|
|
1278
|
-
const
|
|
1421
|
+
const yt = V(
|
|
1279
1422
|
() => ({
|
|
1280
1423
|
login: (w) => $.current.login(w),
|
|
1281
1424
|
signup: (w) => $.current.signup(w),
|
|
@@ -1293,100 +1436,100 @@ function pr({ config: r = {}, children: e }) {
|
|
|
1293
1436
|
loadUserData: (w) => $.current.loadUserData(w),
|
|
1294
1437
|
refreshUser: () => $.current.refreshUser(),
|
|
1295
1438
|
refreshRoles: () => $.current.refreshRoles(),
|
|
1296
|
-
switchToTenant: (w,
|
|
1439
|
+
switchToTenant: (w, M) => $.current.switchToTenant(w, M),
|
|
1297
1440
|
refreshUserTenants: () => $.current.refreshUserTenants()
|
|
1298
1441
|
}),
|
|
1299
1442
|
[]
|
|
1300
|
-
),
|
|
1301
|
-
const w = (
|
|
1443
|
+
), bt = V(() => {
|
|
1444
|
+
const w = (M) => !H || H.length === 0 ? !1 : typeof M == "string" ? H.includes(M) : H.includes(`${M.resource}.${M.action}`);
|
|
1302
1445
|
return {
|
|
1303
1446
|
isAuthenticated: j,
|
|
1304
1447
|
isAuthInitializing: !y,
|
|
1305
1448
|
isAuthReady: y,
|
|
1306
|
-
currentUser:
|
|
1449
|
+
currentUser: x,
|
|
1307
1450
|
isUserLoading: I,
|
|
1308
|
-
userError:
|
|
1309
|
-
userRole:
|
|
1451
|
+
userError: k,
|
|
1452
|
+
userRole: F,
|
|
1310
1453
|
userPermissions: H,
|
|
1311
|
-
availableRoles:
|
|
1312
|
-
rolesLoading:
|
|
1454
|
+
availableRoles: R,
|
|
1455
|
+
rolesLoading: S,
|
|
1313
1456
|
userTenants: g,
|
|
1314
1457
|
hasTenantContext: Z,
|
|
1315
1458
|
sessionManager: o,
|
|
1316
1459
|
authenticatedHttpService: u,
|
|
1317
1460
|
hasPermission: w,
|
|
1318
|
-
hasAnyPermission: (
|
|
1319
|
-
hasAllPermissions: (
|
|
1461
|
+
hasAnyPermission: (M) => M.some((z) => w(z)),
|
|
1462
|
+
hasAllPermissions: (M) => M.every((z) => w(z)),
|
|
1320
1463
|
getUserPermissionStrings: () => H || []
|
|
1321
1464
|
};
|
|
1322
1465
|
}, [
|
|
1323
1466
|
j,
|
|
1324
1467
|
y,
|
|
1325
|
-
|
|
1468
|
+
x,
|
|
1326
1469
|
I,
|
|
1327
|
-
S,
|
|
1328
|
-
L,
|
|
1329
|
-
H,
|
|
1330
|
-
P,
|
|
1331
1470
|
k,
|
|
1471
|
+
F,
|
|
1472
|
+
H,
|
|
1473
|
+
R,
|
|
1474
|
+
S,
|
|
1332
1475
|
g,
|
|
1333
1476
|
Z,
|
|
1334
1477
|
o,
|
|
1335
1478
|
u
|
|
1336
1479
|
]);
|
|
1337
|
-
return
|
|
1480
|
+
return re(() => {
|
|
1338
1481
|
if (r.initialRoles || !a) return;
|
|
1339
1482
|
let w = !1;
|
|
1340
|
-
return h(!0),
|
|
1341
|
-
w || c(
|
|
1342
|
-
}).catch((
|
|
1343
|
-
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:",
|
|
1483
|
+
return h(!0), se.getRolesByApp(a).then(({ roles: M }) => {
|
|
1484
|
+
w || c(M);
|
|
1485
|
+
}).catch((M) => {
|
|
1486
|
+
process.env.NODE_ENV === "development" && console.error("[AuthProvider] Failed to fetch roles:", M);
|
|
1344
1487
|
}).finally(() => {
|
|
1345
1488
|
w || h(!1);
|
|
1346
1489
|
}), () => {
|
|
1347
1490
|
w = !0;
|
|
1348
1491
|
};
|
|
1349
|
-
}, [a, r.initialRoles,
|
|
1492
|
+
}, [a, r.initialRoles, se]), re(() => {
|
|
1350
1493
|
let w = !1;
|
|
1351
1494
|
return (async () => {
|
|
1352
|
-
var
|
|
1353
|
-
if (!o.hasValidSession() && ((
|
|
1495
|
+
var O;
|
|
1496
|
+
if (!o.hasValidSession() && ((O = o.getTokens()) != null && O.refreshToken) && await o.waitForPendingRefresh(), w || !o.hasValidSession() && !o.getTokens() && r.enableCookieSession && (await o.attemptCookieSessionRestore(), w))
|
|
1354
1497
|
return;
|
|
1355
1498
|
const z = o.getUser();
|
|
1356
|
-
z && o.hasValidSession() &&
|
|
1499
|
+
z && o.hasValidSession() && P(z), E(!1);
|
|
1357
1500
|
})(), () => {
|
|
1358
1501
|
w = !0;
|
|
1359
1502
|
};
|
|
1360
|
-
}, [o, r.enableCookieSession]),
|
|
1361
|
-
!
|
|
1503
|
+
}, [o, r.enableCookieSession]), re(() => {
|
|
1504
|
+
!x && !I && !k && o.hasValidSession() ? $.current.loadUserData().catch(() => {
|
|
1362
1505
|
}).finally(() => {
|
|
1363
|
-
|
|
1364
|
-
}) :
|
|
1365
|
-
}, [
|
|
1506
|
+
E(!1);
|
|
1507
|
+
}) : E(!1);
|
|
1508
|
+
}, [x, I, k, o]), /* @__PURE__ */ s(Ie.Provider, { value: yt, children: /* @__PURE__ */ s(Pe.Provider, { value: bt, children: e }) });
|
|
1366
1509
|
}
|
|
1367
|
-
function
|
|
1368
|
-
const r =
|
|
1510
|
+
function Pr() {
|
|
1511
|
+
const r = ne(Pe);
|
|
1369
1512
|
if (!r)
|
|
1370
1513
|
throw new Error("useAuthState must be used within an AuthProvider");
|
|
1371
1514
|
return r;
|
|
1372
1515
|
}
|
|
1373
|
-
function
|
|
1374
|
-
const r =
|
|
1516
|
+
function Ir() {
|
|
1517
|
+
const r = ne(Ie);
|
|
1375
1518
|
if (!r)
|
|
1376
1519
|
throw new Error("useAuthActions must be used within an AuthProvider");
|
|
1377
1520
|
return r;
|
|
1378
1521
|
}
|
|
1379
|
-
function
|
|
1380
|
-
const r =
|
|
1522
|
+
function de() {
|
|
1523
|
+
const r = ne(Pe), e = ne(Ie);
|
|
1381
1524
|
if (!r || !e)
|
|
1382
1525
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1383
|
-
return
|
|
1526
|
+
return V(() => ({ ...r, ...e }), [r, e]);
|
|
1384
1527
|
}
|
|
1385
|
-
function
|
|
1386
|
-
const r =
|
|
1387
|
-
return
|
|
1528
|
+
function Oe() {
|
|
1529
|
+
const r = ne(Pe), e = ne(Ie);
|
|
1530
|
+
return V(() => !r || !e ? null : { ...r, ...e }, [r, e]);
|
|
1388
1531
|
}
|
|
1389
|
-
class
|
|
1532
|
+
class Ot {
|
|
1390
1533
|
constructor(e) {
|
|
1391
1534
|
this.httpService = e;
|
|
1392
1535
|
}
|
|
@@ -1398,7 +1541,7 @@ class Pt {
|
|
|
1398
1541
|
}
|
|
1399
1542
|
async getFeatureFlags(e) {
|
|
1400
1543
|
const t = await this.httpService.get(
|
|
1401
|
-
`/feature-flags/${
|
|
1544
|
+
`/feature-flags/${ce(e)}`
|
|
1402
1545
|
);
|
|
1403
1546
|
return { featureFlags: t.data, meta: t.meta };
|
|
1404
1547
|
}
|
|
@@ -1417,7 +1560,7 @@ class Pt {
|
|
|
1417
1560
|
async getTenantFeatureFlags(e, t) {
|
|
1418
1561
|
if (!e || !t)
|
|
1419
1562
|
throw new Error("Tenant ID and App ID are required");
|
|
1420
|
-
const n =
|
|
1563
|
+
const n = ce({ tenantId: e, appId: t });
|
|
1421
1564
|
return (await this.httpService.get(
|
|
1422
1565
|
`/tenant-feature-flags${n}`,
|
|
1423
1566
|
{ headers: { "X-Tenant-ID": e }, skipAuth: !0 }
|
|
@@ -1426,18 +1569,18 @@ class Pt {
|
|
|
1426
1569
|
async getTenantFeatureFlag(e, t, n) {
|
|
1427
1570
|
if (!e || !t || !n)
|
|
1428
1571
|
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
1429
|
-
const i =
|
|
1572
|
+
const i = ce({ tenantId: t, appId: n });
|
|
1430
1573
|
return (await this.httpService.get(
|
|
1431
1574
|
`/tenant-feature-flags/${e}${i}`,
|
|
1432
1575
|
{ headers: { "X-Tenant-ID": t }, skipAuth: !0 }
|
|
1433
1576
|
)).data;
|
|
1434
1577
|
}
|
|
1435
1578
|
}
|
|
1436
|
-
const
|
|
1437
|
-
function
|
|
1438
|
-
const t =
|
|
1439
|
-
const m = new
|
|
1440
|
-
return new
|
|
1579
|
+
const Ve = fe(null);
|
|
1580
|
+
function Lr({ config: r = {}, children: e }) {
|
|
1581
|
+
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (t == null ? void 0 : t.appId) ?? "", l = (n == null ? void 0 : n.tenant) ?? null, [d, T] = N([]), [R, c] = N(!1), [S, h] = N(null), [x, P] = N(!1), I = V(() => {
|
|
1582
|
+
const m = new he(i);
|
|
1583
|
+
return new Ot(m);
|
|
1441
1584
|
}, [i]), A = async () => {
|
|
1442
1585
|
if (!(l != null && l.id)) {
|
|
1443
1586
|
T([]);
|
|
@@ -1454,45 +1597,45 @@ function gr({ config: r = {}, children: e }) {
|
|
|
1454
1597
|
c(!1);
|
|
1455
1598
|
}
|
|
1456
1599
|
};
|
|
1457
|
-
|
|
1600
|
+
re(() => {
|
|
1458
1601
|
if (!i || !a) return;
|
|
1459
|
-
A().finally(() =>
|
|
1602
|
+
A().finally(() => P(!0));
|
|
1460
1603
|
const m = r.refreshInterval || 5 * 60 * 1e3, g = setInterval(A, m);
|
|
1461
1604
|
return () => clearInterval(g);
|
|
1462
1605
|
}, [l == null ? void 0 : l.id, i, a, r.refreshInterval]);
|
|
1463
|
-
const
|
|
1606
|
+
const k = V(() => {
|
|
1464
1607
|
const m = (p) => {
|
|
1465
|
-
const
|
|
1466
|
-
return (
|
|
1467
|
-
}, g = (p) => d.find((
|
|
1468
|
-
const
|
|
1469
|
-
return
|
|
1470
|
-
},
|
|
1608
|
+
const E = d.find((y) => y.key === p);
|
|
1609
|
+
return (E == null ? void 0 : E.value) === !0;
|
|
1610
|
+
}, g = (p) => d.find((E) => E.key === p), b = (p) => {
|
|
1611
|
+
const E = d.find((y) => y.key === p);
|
|
1612
|
+
return E ? E.value ? "enabled" : "disabled" : "not_found";
|
|
1613
|
+
}, C = async () => {
|
|
1471
1614
|
await A();
|
|
1472
|
-
}, o = !!(i && a) && (
|
|
1615
|
+
}, o = !!(i && a) && (x || !(l != null && l.id));
|
|
1473
1616
|
return {
|
|
1474
1617
|
featureFlags: d,
|
|
1475
|
-
loading:
|
|
1476
|
-
error:
|
|
1618
|
+
loading: R,
|
|
1619
|
+
error: S,
|
|
1477
1620
|
isReady: o,
|
|
1478
1621
|
isEnabled: m,
|
|
1479
1622
|
getFlag: g,
|
|
1480
1623
|
getFlagState: b,
|
|
1481
|
-
refresh:
|
|
1624
|
+
refresh: C
|
|
1482
1625
|
};
|
|
1483
|
-
}, [d,
|
|
1484
|
-
return /* @__PURE__ */ s(
|
|
1626
|
+
}, [d, R, S, i, a, l == null ? void 0 : l.id, x]);
|
|
1627
|
+
return /* @__PURE__ */ s(Ve.Provider, { value: k, children: e });
|
|
1485
1628
|
}
|
|
1486
|
-
function
|
|
1487
|
-
const r =
|
|
1629
|
+
function Vt() {
|
|
1630
|
+
const r = ne(Ve);
|
|
1488
1631
|
if (!r)
|
|
1489
1632
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1490
1633
|
return r;
|
|
1491
1634
|
}
|
|
1492
|
-
function
|
|
1493
|
-
return
|
|
1635
|
+
function at() {
|
|
1636
|
+
return ne(Ve);
|
|
1494
1637
|
}
|
|
1495
|
-
class
|
|
1638
|
+
class qt {
|
|
1496
1639
|
constructor(e) {
|
|
1497
1640
|
this.httpService = e;
|
|
1498
1641
|
}
|
|
@@ -1532,68 +1675,68 @@ class Rt {
|
|
|
1532
1675
|
)).data;
|
|
1533
1676
|
}
|
|
1534
1677
|
}
|
|
1535
|
-
const
|
|
1536
|
-
function
|
|
1537
|
-
const t =
|
|
1538
|
-
const
|
|
1539
|
-
return new
|
|
1678
|
+
const qe = fe(void 0);
|
|
1679
|
+
function Fr({ config: r = {}, children: e }) {
|
|
1680
|
+
const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [l, d] = N(null), [T, R] = N(!1), [c, S] = N(null), [h, x] = N(!1), P = V(() => {
|
|
1681
|
+
const k = new he(i);
|
|
1682
|
+
return new qt(k);
|
|
1540
1683
|
}, [i]), I = async () => {
|
|
1541
1684
|
if (!(a != null && a.id)) {
|
|
1542
1685
|
d(null);
|
|
1543
1686
|
return;
|
|
1544
1687
|
}
|
|
1545
|
-
|
|
1688
|
+
R(!0), S(null);
|
|
1546
1689
|
try {
|
|
1547
|
-
const
|
|
1548
|
-
d(
|
|
1549
|
-
} catch (
|
|
1550
|
-
const m =
|
|
1551
|
-
|
|
1690
|
+
const k = await P.getTenantSubscriptionFeatures(a.id);
|
|
1691
|
+
d(k);
|
|
1692
|
+
} catch (k) {
|
|
1693
|
+
const m = k instanceof Error ? k.message : "Failed to fetch subscription";
|
|
1694
|
+
S(m), r.onError && r.onError(k instanceof Error ? k : new Error(m));
|
|
1552
1695
|
} finally {
|
|
1553
|
-
|
|
1696
|
+
R(!1);
|
|
1554
1697
|
}
|
|
1555
1698
|
};
|
|
1556
|
-
|
|
1557
|
-
if (!i || (I().finally(() =>
|
|
1558
|
-
const
|
|
1699
|
+
re(() => {
|
|
1700
|
+
if (!i || (I().finally(() => x(!0)), !r.refreshInterval)) return;
|
|
1701
|
+
const k = r.refreshInterval || 10 * 60 * 1e3, m = setInterval(I, k);
|
|
1559
1702
|
return () => clearInterval(m);
|
|
1560
1703
|
}, [a == null ? void 0 : a.id, i, r.refreshInterval]);
|
|
1561
|
-
const A =
|
|
1562
|
-
const
|
|
1563
|
-
const y =
|
|
1704
|
+
const A = V(() => {
|
|
1705
|
+
const k = (l == null ? void 0 : l.features) || [], m = (E) => {
|
|
1706
|
+
const y = k.find((u) => u.key === E);
|
|
1564
1707
|
return y ? y.type === "BOOLEAN" || y.type === "boolean" ? y.value === !0 : !!y.value : !1;
|
|
1565
|
-
}, g = (
|
|
1566
|
-
const u =
|
|
1708
|
+
}, g = (E) => k.find((y) => y.key === E), b = (E, y) => {
|
|
1709
|
+
const u = k.find((v) => v.key === E);
|
|
1567
1710
|
return u ? u.value : y;
|
|
1568
|
-
},
|
|
1711
|
+
}, C = (E) => !l || !l.isActive ? !1 : E.includes(l.planId), o = async () => {
|
|
1569
1712
|
await I();
|
|
1570
1713
|
}, p = !!i && (h || !(a != null && a.id));
|
|
1571
1714
|
return {
|
|
1572
1715
|
subscription: l,
|
|
1573
|
-
features:
|
|
1716
|
+
features: k,
|
|
1574
1717
|
loading: T,
|
|
1575
1718
|
error: c,
|
|
1576
1719
|
isReady: p,
|
|
1577
1720
|
isFeatureEnabled: m,
|
|
1578
1721
|
getFeature: g,
|
|
1579
1722
|
getFeatureValue: b,
|
|
1580
|
-
hasAllowedPlan:
|
|
1723
|
+
hasAllowedPlan: C,
|
|
1581
1724
|
refresh: o
|
|
1582
1725
|
};
|
|
1583
1726
|
}, [l, T, c, i, a == null ? void 0 : a.id, h]);
|
|
1584
|
-
return /* @__PURE__ */ s(
|
|
1727
|
+
return /* @__PURE__ */ s(qe.Provider, { value: A, children: e });
|
|
1585
1728
|
}
|
|
1586
|
-
function
|
|
1587
|
-
const r =
|
|
1729
|
+
function zt() {
|
|
1730
|
+
const r = ne(qe);
|
|
1588
1731
|
if (r === void 0)
|
|
1589
1732
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1590
1733
|
return r;
|
|
1591
1734
|
}
|
|
1592
|
-
function
|
|
1593
|
-
return
|
|
1735
|
+
function lt() {
|
|
1736
|
+
return ne(qe) ?? null;
|
|
1594
1737
|
}
|
|
1595
|
-
var
|
|
1596
|
-
const
|
|
1738
|
+
var ae = /* @__PURE__ */ ((r) => (r.SUPERUSER = "SUPERUSER", r.TENANT_ADMIN = "TENANT_ADMIN", r.USER = "USER", r))(ae || {});
|
|
1739
|
+
const ze = {
|
|
1597
1740
|
publicGuest: "/",
|
|
1598
1741
|
publicUser: "/account",
|
|
1599
1742
|
publicAdmin: "/admin",
|
|
@@ -1601,7 +1744,7 @@ const _e = {
|
|
|
1601
1744
|
tenantUser: "/dashboard",
|
|
1602
1745
|
tenantAdmin: "/admin/dashboard",
|
|
1603
1746
|
default: "/"
|
|
1604
|
-
},
|
|
1747
|
+
}, ct = {
|
|
1605
1748
|
// Public/Landing zones
|
|
1606
1749
|
landing: { tenant: "forbidden", auth: "optional" },
|
|
1607
1750
|
publicOnly: { tenant: "forbidden", auth: "forbidden" },
|
|
@@ -1614,26 +1757,26 @@ const _e = {
|
|
|
1614
1757
|
tenantOpen: { tenant: "required", auth: "optional" },
|
|
1615
1758
|
tenantAuth: { tenant: "required", auth: "required" },
|
|
1616
1759
|
// User type zones
|
|
1617
|
-
user: { tenant: "required", auth: "required", userType:
|
|
1618
|
-
admin: { tenant: "required", auth: "required", userType:
|
|
1760
|
+
user: { tenant: "required", auth: "required", userType: ae.USER },
|
|
1761
|
+
admin: { tenant: "required", auth: "required", userType: ae.TENANT_ADMIN },
|
|
1619
1762
|
// Fully open
|
|
1620
1763
|
open: { tenant: "optional", auth: "optional" }
|
|
1621
|
-
},
|
|
1622
|
-
zoneRoots:
|
|
1623
|
-
presets:
|
|
1764
|
+
}, je = fe(null), jt = {
|
|
1765
|
+
zoneRoots: ze,
|
|
1766
|
+
presets: ct,
|
|
1624
1767
|
loadingFallback: null,
|
|
1625
1768
|
accessDeniedFallback: null,
|
|
1626
1769
|
onAccessDenied: void 0,
|
|
1627
1770
|
returnToParam: "returnTo",
|
|
1628
1771
|
returnToStorage: "url"
|
|
1629
1772
|
};
|
|
1630
|
-
function
|
|
1631
|
-
const t =
|
|
1773
|
+
function Nr({ config: r = {}, children: e }) {
|
|
1774
|
+
const t = V(() => {
|
|
1632
1775
|
const n = {
|
|
1633
|
-
...
|
|
1776
|
+
...ze,
|
|
1634
1777
|
...r.zoneRoots
|
|
1635
1778
|
}, i = {
|
|
1636
|
-
...
|
|
1779
|
+
...ct,
|
|
1637
1780
|
...r.presets
|
|
1638
1781
|
};
|
|
1639
1782
|
return {
|
|
@@ -1646,18 +1789,18 @@ function br({ config: r = {}, children: e }) {
|
|
|
1646
1789
|
returnToStorage: r.returnToStorage ?? "url"
|
|
1647
1790
|
};
|
|
1648
1791
|
}, [r]);
|
|
1649
|
-
return /* @__PURE__ */ s(
|
|
1792
|
+
return /* @__PURE__ */ s(je.Provider, { value: t, children: e });
|
|
1650
1793
|
}
|
|
1651
|
-
function
|
|
1652
|
-
const r =
|
|
1794
|
+
function Cr() {
|
|
1795
|
+
const r = ne(je);
|
|
1653
1796
|
if (!r)
|
|
1654
1797
|
throw new Error("useRouting must be used within a RoutingProvider");
|
|
1655
1798
|
return r;
|
|
1656
1799
|
}
|
|
1657
|
-
function
|
|
1658
|
-
return
|
|
1800
|
+
function Wt() {
|
|
1801
|
+
return ne(je) ?? jt;
|
|
1659
1802
|
}
|
|
1660
|
-
const
|
|
1803
|
+
const tt = () => /* @__PURE__ */ f(
|
|
1661
1804
|
"div",
|
|
1662
1805
|
{
|
|
1663
1806
|
style: {
|
|
@@ -1694,7 +1837,7 @@ const Je = () => /* @__PURE__ */ f(
|
|
|
1694
1837
|
)
|
|
1695
1838
|
]
|
|
1696
1839
|
}
|
|
1697
|
-
),
|
|
1840
|
+
), rt = ({
|
|
1698
1841
|
userType: r,
|
|
1699
1842
|
minUserType: e,
|
|
1700
1843
|
missingPermissions: t
|
|
@@ -1735,36 +1878,36 @@ const Je = () => /* @__PURE__ */ f(
|
|
|
1735
1878
|
] })
|
|
1736
1879
|
]
|
|
1737
1880
|
}
|
|
1738
|
-
),
|
|
1881
|
+
), Gt = (r, e) => {
|
|
1739
1882
|
const t = {
|
|
1740
|
-
[
|
|
1741
|
-
[
|
|
1742
|
-
[
|
|
1883
|
+
[ae.USER]: 1,
|
|
1884
|
+
[ae.TENANT_ADMIN]: 2,
|
|
1885
|
+
[ae.SUPERUSER]: 3
|
|
1743
1886
|
};
|
|
1744
1887
|
return t[r] >= t[e];
|
|
1745
1888
|
};
|
|
1746
|
-
function
|
|
1889
|
+
function Dr({
|
|
1747
1890
|
children: r,
|
|
1748
1891
|
fallback: e,
|
|
1749
1892
|
minUserType: t,
|
|
1750
1893
|
requiredPermissions: n,
|
|
1751
1894
|
requireAllPermissions: i = !1
|
|
1752
1895
|
}) {
|
|
1753
|
-
const { hasValidSession: a, sessionManager: l, hasPermission: d, hasAnyPermission: T, hasAllPermissions:
|
|
1896
|
+
const { hasValidSession: a, sessionManager: l, hasPermission: d, hasAnyPermission: T, hasAllPermissions: R } = de();
|
|
1754
1897
|
if (!a())
|
|
1755
|
-
return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(
|
|
1898
|
+
return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(tt, {}) });
|
|
1756
1899
|
const c = l.getUser();
|
|
1757
1900
|
if (!c)
|
|
1758
|
-
return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(
|
|
1759
|
-
if (t && !
|
|
1760
|
-
return /* @__PURE__ */ s(
|
|
1761
|
-
if (n && n.length > 0 && !(i ?
|
|
1762
|
-
const h = n.filter((
|
|
1763
|
-
return /* @__PURE__ */ s(
|
|
1901
|
+
return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(tt, {}) });
|
|
1902
|
+
if (t && !Gt(c.userType, t))
|
|
1903
|
+
return /* @__PURE__ */ s(rt, { userType: c.userType, minUserType: t });
|
|
1904
|
+
if (n && n.length > 0 && !(i ? R(n) : T(n))) {
|
|
1905
|
+
const h = n.filter((x) => !d(x)).map((x) => typeof x == "string" ? x : x.name);
|
|
1906
|
+
return /* @__PURE__ */ s(rt, { missingPermissions: h });
|
|
1764
1907
|
}
|
|
1765
1908
|
return /* @__PURE__ */ s(B, { children: r });
|
|
1766
1909
|
}
|
|
1767
|
-
const
|
|
1910
|
+
const Ht = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1768
1911
|
"div",
|
|
1769
1912
|
{
|
|
1770
1913
|
style: {
|
|
@@ -1800,7 +1943,7 @@ const Dt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1800
1943
|
}
|
|
1801
1944
|
)
|
|
1802
1945
|
}
|
|
1803
|
-
),
|
|
1946
|
+
), nt = ({
|
|
1804
1947
|
userType: r,
|
|
1805
1948
|
requiredUserType: e,
|
|
1806
1949
|
missingPermissions: t
|
|
@@ -1851,8 +1994,8 @@ const Dt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1851
1994
|
}
|
|
1852
1995
|
)
|
|
1853
1996
|
}
|
|
1854
|
-
),
|
|
1855
|
-
function
|
|
1997
|
+
), Qt = (r, e) => r === e;
|
|
1998
|
+
function Mr({
|
|
1856
1999
|
children: r,
|
|
1857
2000
|
redirectTo: e = "/login",
|
|
1858
2001
|
requiredUserType: t,
|
|
@@ -1860,34 +2003,34 @@ function Tr({
|
|
|
1860
2003
|
requireAllPermissions: i = !1,
|
|
1861
2004
|
fallback: a
|
|
1862
2005
|
}) {
|
|
1863
|
-
const { hasValidSession: l, sessionManager: d, hasPermission: T, hasAnyPermission:
|
|
1864
|
-
if (
|
|
2006
|
+
const { hasValidSession: l, sessionManager: d, hasPermission: T, hasAnyPermission: R, hasAllPermissions: c } = de(), S = xe();
|
|
2007
|
+
if (re(() => {
|
|
1865
2008
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1866
2009
|
"[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
|
|
1867
2010
|
);
|
|
1868
2011
|
}, []), !l())
|
|
1869
2012
|
return a ? /* @__PURE__ */ s(B, { children: a }) : /* @__PURE__ */ f(B, { children: [
|
|
1870
|
-
/* @__PURE__ */ s(
|
|
1871
|
-
/* @__PURE__ */ s(
|
|
2013
|
+
/* @__PURE__ */ s(Ht, { redirectPath: e }),
|
|
2014
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: S.pathname }, replace: !0 })
|
|
1872
2015
|
] });
|
|
1873
2016
|
const h = d.getUser();
|
|
1874
2017
|
if (!h)
|
|
1875
|
-
return /* @__PURE__ */ s(
|
|
1876
|
-
if (t && !
|
|
2018
|
+
return /* @__PURE__ */ s(be, { to: e, state: { from: S.pathname }, replace: !0 });
|
|
2019
|
+
if (t && !Qt(h.userType, t))
|
|
1877
2020
|
return /* @__PURE__ */ s(
|
|
1878
|
-
|
|
2021
|
+
nt,
|
|
1879
2022
|
{
|
|
1880
2023
|
userType: h.userType,
|
|
1881
2024
|
requiredUserType: t
|
|
1882
2025
|
}
|
|
1883
2026
|
);
|
|
1884
|
-
if (n && n.length > 0 && !(i ? c(n) :
|
|
1885
|
-
const
|
|
1886
|
-
return /* @__PURE__ */ s(
|
|
2027
|
+
if (n && n.length > 0 && !(i ? c(n) : R(n))) {
|
|
2028
|
+
const P = n.filter((I) => !T(I)).map((I) => typeof I == "string" ? I : I.name);
|
|
2029
|
+
return /* @__PURE__ */ s(nt, { missingPermissions: P });
|
|
1887
2030
|
}
|
|
1888
2031
|
return /* @__PURE__ */ s(B, { children: r });
|
|
1889
2032
|
}
|
|
1890
|
-
const
|
|
2033
|
+
const Jt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1891
2034
|
"div",
|
|
1892
2035
|
{
|
|
1893
2036
|
style: {
|
|
@@ -1924,18 +2067,18 @@ const Ut = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1924
2067
|
)
|
|
1925
2068
|
}
|
|
1926
2069
|
);
|
|
1927
|
-
function
|
|
1928
|
-
const { tenant: n, isLoading: i, error: a } =
|
|
1929
|
-
return
|
|
2070
|
+
function $r({ children: r, redirectTo: e = "/", fallback: t }) {
|
|
2071
|
+
const { tenant: n, isLoading: i, error: a } = ot(), l = xe();
|
|
2072
|
+
return re(() => {
|
|
1930
2073
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1931
2074
|
"[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
|
|
1932
2075
|
);
|
|
1933
2076
|
}, []), i || a ? null : n ? /* @__PURE__ */ s(B, { children: r }) : t ? /* @__PURE__ */ s(B, { children: t }) : /* @__PURE__ */ f(B, { children: [
|
|
1934
|
-
/* @__PURE__ */ s(
|
|
1935
|
-
/* @__PURE__ */ s(
|
|
2077
|
+
/* @__PURE__ */ s(Jt, { redirectPath: e }),
|
|
2078
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: l.pathname }, replace: !0 })
|
|
1936
2079
|
] });
|
|
1937
2080
|
}
|
|
1938
|
-
const
|
|
2081
|
+
const Zt = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
1939
2082
|
"div",
|
|
1940
2083
|
{
|
|
1941
2084
|
style: {
|
|
@@ -1972,41 +2115,41 @@ const $t = ({ redirectPath: r }) => /* @__PURE__ */ s(
|
|
|
1972
2115
|
)
|
|
1973
2116
|
}
|
|
1974
2117
|
);
|
|
1975
|
-
function
|
|
1976
|
-
const { tenant: n, isLoading: i, error: a } =
|
|
1977
|
-
return
|
|
2118
|
+
function Ur({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
|
|
2119
|
+
const { tenant: n, isLoading: i, error: a } = ot(), l = xe();
|
|
2120
|
+
return re(() => {
|
|
1978
2121
|
process.env.NODE_ENV === "development" && console.warn(
|
|
1979
2122
|
"[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
|
|
1980
2123
|
);
|
|
1981
2124
|
}, []), i || a ? null : n ? t ? /* @__PURE__ */ s(B, { children: t }) : /* @__PURE__ */ f(B, { children: [
|
|
1982
|
-
/* @__PURE__ */ s(
|
|
1983
|
-
/* @__PURE__ */ s(
|
|
2125
|
+
/* @__PURE__ */ s(Zt, { redirectPath: e }),
|
|
2126
|
+
/* @__PURE__ */ s(be, { to: e, state: { from: l.pathname }, replace: !0 })
|
|
1984
2127
|
] }) : /* @__PURE__ */ s(B, { children: r });
|
|
1985
2128
|
}
|
|
1986
|
-
function
|
|
2129
|
+
function Kt(r, e) {
|
|
1987
2130
|
return e ? r ? Array.isArray(e) ? e.includes(r) : r === e : !1 : !0;
|
|
1988
2131
|
}
|
|
1989
|
-
function
|
|
2132
|
+
function st(r, e) {
|
|
1990
2133
|
return !r || r === "optional" ? "skip" : r === "required" ? e ? "pass" : "fail" : r === "forbidden" ? e ? "fail" : "pass" : "skip";
|
|
1991
2134
|
}
|
|
1992
|
-
function
|
|
1993
|
-
return
|
|
2135
|
+
function Yt(r, e) {
|
|
2136
|
+
return st(r.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : st(r.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : r.userType && e.isAuthenticated && !Kt(e.userType, r.userType) ? "wrong_user_type" : r.permissions && r.permissions.length > 0 && !(r.requireAllPermissions !== !1 ? (a) => a.every((l) => e.permissions.includes(l)) : (a) => a.some((l) => e.permissions.includes(l)))(r.permissions) ? "missing_permissions" : null;
|
|
1994
2137
|
}
|
|
1995
|
-
function
|
|
1996
|
-
return r.hasTenant ? r.isAuthenticated ? r.userType ===
|
|
2138
|
+
function Xt(r, e) {
|
|
2139
|
+
return r.hasTenant ? r.isAuthenticated ? r.userType === ae.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : r.isAuthenticated ? r.userType === ae.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
|
|
1997
2140
|
}
|
|
1998
|
-
function
|
|
2141
|
+
function er(r, e, t, n, i) {
|
|
1999
2142
|
if (!e || i !== "url")
|
|
2000
2143
|
return r;
|
|
2001
2144
|
const a = typeof e == "string" ? e : t, l = r.includes("?") ? "&" : "?";
|
|
2002
2145
|
return `${r}${l}${n}=${encodeURIComponent(a)}`;
|
|
2003
2146
|
}
|
|
2004
|
-
function
|
|
2147
|
+
function tr(r, e, t) {
|
|
2005
2148
|
if (!r || t === "url") return;
|
|
2006
2149
|
const n = typeof r == "string" ? r : e, i = "zone_return_to";
|
|
2007
2150
|
t === "session" ? sessionStorage.setItem(i, n) : t === "local" && localStorage.setItem(i, n);
|
|
2008
2151
|
}
|
|
2009
|
-
const
|
|
2152
|
+
const ue = ({
|
|
2010
2153
|
children: r,
|
|
2011
2154
|
preset: e,
|
|
2012
2155
|
tenant: t,
|
|
@@ -2016,14 +2159,14 @@ const ce = ({
|
|
|
2016
2159
|
requireAllPermissions: l = !0,
|
|
2017
2160
|
returnTo: d,
|
|
2018
2161
|
onAccessDenied: T,
|
|
2019
|
-
redirectTo:
|
|
2162
|
+
redirectTo: R,
|
|
2020
2163
|
loadingFallback: c,
|
|
2021
|
-
accessDeniedFallback:
|
|
2164
|
+
accessDeniedFallback: S
|
|
2022
2165
|
}) => {
|
|
2023
|
-
const h =
|
|
2166
|
+
const h = xe(), { isAuthenticated: x, isAuthInitializing: P, currentUser: I, userPermissions: A } = de(), { tenant: k, isTenantLoading: m } = ve(), g = Wt(), b = V(() => {
|
|
2024
2167
|
if (e)
|
|
2025
2168
|
return g.presets[e];
|
|
2026
|
-
}, [e, g.presets]),
|
|
2169
|
+
}, [e, g.presets]), C = V(
|
|
2027
2170
|
() => ({
|
|
2028
2171
|
tenant: t ?? (b == null ? void 0 : b.tenant),
|
|
2029
2172
|
auth: n ?? (b == null ? void 0 : b.auth),
|
|
@@ -2032,29 +2175,29 @@ const ce = ({
|
|
|
2032
2175
|
requireAllPermissions: l
|
|
2033
2176
|
}),
|
|
2034
2177
|
[t, n, i, a, b, l]
|
|
2035
|
-
), o =
|
|
2178
|
+
), o = V(
|
|
2036
2179
|
() => ({
|
|
2037
|
-
hasTenant: !!
|
|
2038
|
-
isAuthenticated:
|
|
2180
|
+
hasTenant: !!k,
|
|
2181
|
+
isAuthenticated: x,
|
|
2039
2182
|
userType: I == null ? void 0 : I.userType,
|
|
2040
2183
|
permissions: A,
|
|
2041
|
-
isLoading:
|
|
2184
|
+
isLoading: P || m
|
|
2042
2185
|
}),
|
|
2043
2186
|
[
|
|
2044
|
-
|
|
2045
|
-
|
|
2187
|
+
k,
|
|
2188
|
+
x,
|
|
2046
2189
|
I == null ? void 0 : I.userType,
|
|
2047
2190
|
A,
|
|
2048
|
-
|
|
2191
|
+
P,
|
|
2049
2192
|
m
|
|
2050
2193
|
]
|
|
2051
|
-
), p =
|
|
2194
|
+
), p = V(() => o.isLoading ? null : Yt(C, o), [C, o]), E = V(() => p ? R || Xt(o, g.zoneRoots) : null, [p, R, o, g.zoneRoots]), y = V(() => !p || !E ? null : {
|
|
2052
2195
|
type: p,
|
|
2053
2196
|
required: {
|
|
2054
|
-
tenant:
|
|
2055
|
-
auth:
|
|
2056
|
-
userType:
|
|
2057
|
-
permissions:
|
|
2197
|
+
tenant: C.tenant,
|
|
2198
|
+
auth: C.auth,
|
|
2199
|
+
userType: C.userType,
|
|
2200
|
+
permissions: C.permissions
|
|
2058
2201
|
},
|
|
2059
2202
|
current: {
|
|
2060
2203
|
hasTenant: o.hasTenant,
|
|
@@ -2062,12 +2205,12 @@ const ce = ({
|
|
|
2062
2205
|
userType: o.userType,
|
|
2063
2206
|
permissions: o.permissions
|
|
2064
2207
|
},
|
|
2065
|
-
redirectTo:
|
|
2066
|
-
}, [p,
|
|
2067
|
-
if (
|
|
2208
|
+
redirectTo: E
|
|
2209
|
+
}, [p, E, C, o]);
|
|
2210
|
+
if (re(() => {
|
|
2068
2211
|
y && (T ? T(y) : g.onAccessDenied && g.onAccessDenied(y));
|
|
2069
|
-
}, [y, T, g]),
|
|
2070
|
-
y && d &&
|
|
2212
|
+
}, [y, T, g]), re(() => {
|
|
2213
|
+
y && d && tr(d, h.pathname + h.search, g.returnToStorage);
|
|
2071
2214
|
}, [
|
|
2072
2215
|
y,
|
|
2073
2216
|
d,
|
|
@@ -2076,21 +2219,21 @@ const ce = ({
|
|
|
2076
2219
|
g.returnToStorage
|
|
2077
2220
|
]), o.isLoading)
|
|
2078
2221
|
return /* @__PURE__ */ s(B, { children: c ?? g.loadingFallback ?? null });
|
|
2079
|
-
if (y &&
|
|
2080
|
-
const u =
|
|
2222
|
+
if (y && E) {
|
|
2223
|
+
const u = S ?? g.accessDeniedFallback;
|
|
2081
2224
|
if (u)
|
|
2082
2225
|
return /* @__PURE__ */ s(B, { children: u });
|
|
2083
|
-
const v =
|
|
2084
|
-
|
|
2226
|
+
const v = er(
|
|
2227
|
+
E,
|
|
2085
2228
|
d,
|
|
2086
2229
|
h.pathname + h.search,
|
|
2087
2230
|
g.returnToParam,
|
|
2088
2231
|
g.returnToStorage
|
|
2089
2232
|
);
|
|
2090
|
-
return /* @__PURE__ */ s(
|
|
2233
|
+
return /* @__PURE__ */ s(be, { to: v, replace: !0 });
|
|
2091
2234
|
}
|
|
2092
2235
|
return /* @__PURE__ */ s(B, { children: r });
|
|
2093
|
-
},
|
|
2236
|
+
}, Br = (r) => /* @__PURE__ */ s(ue, { tenant: "required", ...r }), _r = (r) => /* @__PURE__ */ s(ue, { tenant: "forbidden", ...r }), Or = (r) => /* @__PURE__ */ s(ue, { auth: "required", ...r }), Vr = (r) => /* @__PURE__ */ s(ue, { auth: "forbidden", ...r }), qr = (r) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.TENANT_ADMIN, ...r }), zr = (r) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.USER, ...r }), jr = (r) => /* @__PURE__ */ s(ue, { tenant: "optional", auth: "optional", ...r }), Wr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "required", ...r }), Gr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "optional", ...r }), Hr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "forbidden", ...r }), rr = () => /* @__PURE__ */ f(
|
|
2094
2237
|
"div",
|
|
2095
2238
|
{
|
|
2096
2239
|
style: {
|
|
@@ -2107,13 +2250,13 @@ const ce = ({
|
|
|
2107
2250
|
]
|
|
2108
2251
|
}
|
|
2109
2252
|
);
|
|
2110
|
-
function
|
|
2253
|
+
function Qr({
|
|
2111
2254
|
children: r,
|
|
2112
|
-
fallback: e = /* @__PURE__ */ s(
|
|
2255
|
+
fallback: e = /* @__PURE__ */ s(rr, {}),
|
|
2113
2256
|
allowedPlans: t,
|
|
2114
2257
|
requiredFeature: n
|
|
2115
2258
|
}) {
|
|
2116
|
-
const { subscription: i, hasAllowedPlan: a, isFeatureEnabled: l, loading: d } =
|
|
2259
|
+
const { subscription: i, hasAllowedPlan: a, isFeatureEnabled: l, loading: d } = zt();
|
|
2117
2260
|
return d ? /* @__PURE__ */ s(
|
|
2118
2261
|
"div",
|
|
2119
2262
|
{
|
|
@@ -2126,7 +2269,7 @@ function Cr({
|
|
|
2126
2269
|
}
|
|
2127
2270
|
) : i ? i.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ s(B, { children: e }) : n && !l(n) ? /* @__PURE__ */ s(B, { children: e }) : /* @__PURE__ */ s(B, { children: r }) : /* @__PURE__ */ s(B, { children: e }) : /* @__PURE__ */ s(B, { children: e });
|
|
2128
2271
|
}
|
|
2129
|
-
const
|
|
2272
|
+
const nr = ({ flagName: r }) => /* @__PURE__ */ f(
|
|
2130
2273
|
"div",
|
|
2131
2274
|
{
|
|
2132
2275
|
style: {
|
|
@@ -2153,8 +2296,8 @@ const zt = ({ flagName: r }) => /* @__PURE__ */ f(
|
|
|
2153
2296
|
]
|
|
2154
2297
|
}
|
|
2155
2298
|
);
|
|
2156
|
-
function
|
|
2157
|
-
const { isEnabled: n, loading: i } =
|
|
2299
|
+
function Jr({ name: r, children: e, fallback: t }) {
|
|
2300
|
+
const { isEnabled: n, loading: i } = Vt();
|
|
2158
2301
|
return i ? /* @__PURE__ */ s(
|
|
2159
2302
|
"div",
|
|
2160
2303
|
{
|
|
@@ -2168,29 +2311,29 @@ function Ur({ name: r, children: e, fallback: t }) {
|
|
|
2168
2311
|
},
|
|
2169
2312
|
children: "Loading feature flags..."
|
|
2170
2313
|
}
|
|
2171
|
-
) : n(r) ? /* @__PURE__ */ s(B, { children: e }) : /* @__PURE__ */ s(B, { children: t || /* @__PURE__ */ s(
|
|
2172
|
-
}
|
|
2173
|
-
function
|
|
2174
|
-
const { submit: e, defaultErrorMessage: t, validate: n, onSuccess: i, onError: a } = r, [l, d] = N(!1), [T,
|
|
2175
|
-
|
|
2176
|
-
}, []),
|
|
2177
|
-
|
|
2178
|
-
if (!
|
|
2179
|
-
const m = { ...
|
|
2314
|
+
) : n(r) ? /* @__PURE__ */ s(B, { children: e }) : /* @__PURE__ */ s(B, { children: t || /* @__PURE__ */ s(nr, { flagName: r }) });
|
|
2315
|
+
}
|
|
2316
|
+
function we(r) {
|
|
2317
|
+
const { submit: e, defaultErrorMessage: t, validate: n, onSuccess: i, onError: a } = r, [l, d] = N(!1), [T, R] = N(""), [c, S] = N({}), h = te((A, k) => {
|
|
2318
|
+
S((m) => ({ ...m, [A]: k }));
|
|
2319
|
+
}, []), x = te((A) => {
|
|
2320
|
+
S((k) => {
|
|
2321
|
+
if (!k[A]) return k;
|
|
2322
|
+
const m = { ...k };
|
|
2180
2323
|
return delete m[A], m;
|
|
2181
2324
|
});
|
|
2182
|
-
}, []),
|
|
2183
|
-
|
|
2184
|
-
}, []), I =
|
|
2325
|
+
}, []), P = te(() => {
|
|
2326
|
+
R(""), S({});
|
|
2327
|
+
}, []), I = te(
|
|
2185
2328
|
async (A) => {
|
|
2186
2329
|
if (A && A.preventDefault(), !(n && !n())) {
|
|
2187
|
-
d(!0),
|
|
2330
|
+
d(!0), R("");
|
|
2188
2331
|
try {
|
|
2189
|
-
const
|
|
2190
|
-
return i == null || i(
|
|
2191
|
-
} catch (
|
|
2192
|
-
const m =
|
|
2193
|
-
|
|
2332
|
+
const k = await e();
|
|
2333
|
+
return i == null || i(k), k;
|
|
2334
|
+
} catch (k) {
|
|
2335
|
+
const m = k instanceof Error ? k.message : t;
|
|
2336
|
+
R(m), a == null || a(m);
|
|
2194
2337
|
return;
|
|
2195
2338
|
} finally {
|
|
2196
2339
|
d(!1);
|
|
@@ -2202,15 +2345,15 @@ function ye(r) {
|
|
|
2202
2345
|
return {
|
|
2203
2346
|
loading: l,
|
|
2204
2347
|
error: T,
|
|
2205
|
-
setError:
|
|
2348
|
+
setError: R,
|
|
2206
2349
|
fieldErrors: c,
|
|
2207
2350
|
setFieldError: h,
|
|
2208
|
-
clearFieldError:
|
|
2209
|
-
resetErrors:
|
|
2351
|
+
clearFieldError: x,
|
|
2352
|
+
resetErrors: P,
|
|
2210
2353
|
handleSubmit: I
|
|
2211
2354
|
};
|
|
2212
2355
|
}
|
|
2213
|
-
const
|
|
2356
|
+
const it = {
|
|
2214
2357
|
container: {
|
|
2215
2358
|
maxWidth: "400px",
|
|
2216
2359
|
width: "100%",
|
|
@@ -2374,18 +2517,18 @@ const Xe = {
|
|
|
2374
2517
|
color: "#6b7280"
|
|
2375
2518
|
}
|
|
2376
2519
|
};
|
|
2377
|
-
function
|
|
2520
|
+
function Le(r, e) {
|
|
2378
2521
|
return {
|
|
2379
|
-
...
|
|
2522
|
+
...it,
|
|
2380
2523
|
...e,
|
|
2381
2524
|
button: {
|
|
2382
|
-
...
|
|
2525
|
+
...it.button,
|
|
2383
2526
|
backgroundColor: r,
|
|
2384
2527
|
...(e == null ? void 0 : e.button) || {}
|
|
2385
2528
|
}
|
|
2386
2529
|
};
|
|
2387
2530
|
}
|
|
2388
|
-
const
|
|
2531
|
+
const sr = () => me.createElement(
|
|
2389
2532
|
"svg",
|
|
2390
2533
|
{
|
|
2391
2534
|
width: "16",
|
|
@@ -2398,9 +2541,9 @@ const jt = () => fe.createElement(
|
|
|
2398
2541
|
strokeLinejoin: "round",
|
|
2399
2542
|
style: { flexShrink: 0 }
|
|
2400
2543
|
},
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
),
|
|
2544
|
+
me.createElement("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
2545
|
+
me.createElement("circle", { cx: "12", cy: "12", r: "3" })
|
|
2546
|
+
), ir = () => me.createElement(
|
|
2404
2547
|
"svg",
|
|
2405
2548
|
{
|
|
2406
2549
|
width: "16",
|
|
@@ -2413,14 +2556,14 @@ const jt = () => fe.createElement(
|
|
|
2413
2556
|
strokeLinejoin: "round",
|
|
2414
2557
|
style: { flexShrink: 0 }
|
|
2415
2558
|
},
|
|
2416
|
-
|
|
2559
|
+
me.createElement("path", {
|
|
2417
2560
|
d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"
|
|
2418
2561
|
}),
|
|
2419
|
-
|
|
2420
|
-
),
|
|
2421
|
-
showPassword: /* @__PURE__ */ s(
|
|
2422
|
-
hidePassword: /* @__PURE__ */ s(
|
|
2423
|
-
},
|
|
2562
|
+
me.createElement("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2563
|
+
), or = {
|
|
2564
|
+
showPassword: /* @__PURE__ */ s(sr, {}),
|
|
2565
|
+
hidePassword: /* @__PURE__ */ s(ir, {})
|
|
2566
|
+
}, ar = {
|
|
2424
2567
|
title: "Sign In",
|
|
2425
2568
|
usernameLabel: "Email or Phone",
|
|
2426
2569
|
usernamePlaceholder: "Enter your email or phone number",
|
|
@@ -2439,7 +2582,7 @@ const jt = () => fe.createElement(
|
|
|
2439
2582
|
showPasswordAriaLabel: "Show password",
|
|
2440
2583
|
hidePasswordAriaLabel: "Hide password"
|
|
2441
2584
|
};
|
|
2442
|
-
function
|
|
2585
|
+
function Zr({
|
|
2443
2586
|
copy: r = {},
|
|
2444
2587
|
styles: e = {},
|
|
2445
2588
|
icons: t = {},
|
|
@@ -2449,28 +2592,28 @@ function $r({
|
|
|
2449
2592
|
onSignupClick: l,
|
|
2450
2593
|
onMagicLinkClick: d,
|
|
2451
2594
|
showForgotPassword: T = !0,
|
|
2452
|
-
showSignupLink:
|
|
2595
|
+
showSignupLink: R = !0,
|
|
2453
2596
|
showMagicLinkOption: c = !0,
|
|
2454
|
-
className:
|
|
2597
|
+
className: S
|
|
2455
2598
|
}) {
|
|
2456
|
-
const [h,
|
|
2599
|
+
const [h, x] = N(""), [P, I] = N(""), [A, k] = N(!1), { login: m } = de(), g = { ...ar, ...r }, b = Le("#3b82f6", e), C = { ...or, ...t }, o = we({
|
|
2457
2600
|
defaultErrorMessage: g.errorMessage,
|
|
2458
2601
|
validate: () => {
|
|
2459
2602
|
const u = [];
|
|
2460
|
-
return h.trim() || u.push("username"),
|
|
2603
|
+
return h.trim() || u.push("username"), P.trim() || u.push("password"), u.forEach((v) => o.setFieldError(v, !0)), u.length === 0;
|
|
2461
2604
|
},
|
|
2462
|
-
submit: () => m({ username: h, password:
|
|
2605
|
+
submit: () => m({ username: h, password: P }),
|
|
2463
2606
|
onSuccess: n,
|
|
2464
2607
|
onError: i
|
|
2465
2608
|
}), p = (u) => ({
|
|
2466
2609
|
...b.input,
|
|
2467
2610
|
...o.fieldErrors[u] ? b.inputError : {}
|
|
2468
|
-
}),
|
|
2611
|
+
}), E = !h || !P || o.loading, y = {
|
|
2469
2612
|
...b.button,
|
|
2470
2613
|
...o.loading ? b.buttonLoading : {},
|
|
2471
|
-
...
|
|
2614
|
+
...E ? b.buttonDisabled : {}
|
|
2472
2615
|
};
|
|
2473
|
-
return /* @__PURE__ */ f("div", { className:
|
|
2616
|
+
return /* @__PURE__ */ f("div", { className: S, style: b.container, children: [
|
|
2474
2617
|
/* @__PURE__ */ s("h2", { style: b.title, children: g.title }),
|
|
2475
2618
|
/* @__PURE__ */ f("form", { onSubmit: o.handleSubmit, style: b.form, children: [
|
|
2476
2619
|
/* @__PURE__ */ f("div", { style: b.fieldGroup, children: [
|
|
@@ -2483,7 +2626,7 @@ function $r({
|
|
|
2483
2626
|
type: "text",
|
|
2484
2627
|
value: h,
|
|
2485
2628
|
onChange: (u) => {
|
|
2486
|
-
|
|
2629
|
+
x(u.target.value), o.clearFieldError("username");
|
|
2487
2630
|
},
|
|
2488
2631
|
placeholder: g.usernamePlaceholder,
|
|
2489
2632
|
style: p("username"),
|
|
@@ -2500,7 +2643,7 @@ function $r({
|
|
|
2500
2643
|
id: "password",
|
|
2501
2644
|
name: "password",
|
|
2502
2645
|
type: A ? "text" : "password",
|
|
2503
|
-
value:
|
|
2646
|
+
value: P,
|
|
2504
2647
|
onChange: (u) => {
|
|
2505
2648
|
I(u.target.value), o.clearFieldError("password");
|
|
2506
2649
|
},
|
|
@@ -2513,19 +2656,19 @@ function $r({
|
|
|
2513
2656
|
"button",
|
|
2514
2657
|
{
|
|
2515
2658
|
type: "button",
|
|
2516
|
-
onClick: () =>
|
|
2659
|
+
onClick: () => k(!A),
|
|
2517
2660
|
style: b.passwordToggle,
|
|
2518
2661
|
disabled: o.loading,
|
|
2519
2662
|
"aria-label": A ? g.hidePasswordAriaLabel : g.showPasswordAriaLabel,
|
|
2520
|
-
children: A ?
|
|
2663
|
+
children: A ? C.hidePassword : C.showPassword
|
|
2521
2664
|
}
|
|
2522
2665
|
)
|
|
2523
2666
|
] })
|
|
2524
2667
|
] }),
|
|
2525
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled:
|
|
2668
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: E, style: y, children: o.loading ? g.loadingText : g.submitButton }),
|
|
2526
2669
|
o.error && /* @__PURE__ */ s("div", { style: b.errorText, children: o.error })
|
|
2527
2670
|
] }),
|
|
2528
|
-
(T ||
|
|
2671
|
+
(T || R || c) && /* @__PURE__ */ f("div", { style: b.linkContainer, children: [
|
|
2529
2672
|
c && /* @__PURE__ */ f("div", { children: [
|
|
2530
2673
|
/* @__PURE__ */ f("span", { style: b.divider, children: [
|
|
2531
2674
|
g.magicLinkText,
|
|
@@ -2533,10 +2676,10 @@ function $r({
|
|
|
2533
2676
|
] }),
|
|
2534
2677
|
/* @__PURE__ */ s("a", { onClick: d, style: b.link, children: g.magicLinkLink })
|
|
2535
2678
|
] }),
|
|
2536
|
-
c && (T ||
|
|
2679
|
+
c && (T || R) && /* @__PURE__ */ s("div", { style: b.divider, children: g.dividerBullet }),
|
|
2537
2680
|
T && /* @__PURE__ */ s("a", { onClick: a, style: b.link, children: g.forgotPasswordLink }),
|
|
2538
|
-
T &&
|
|
2539
|
-
|
|
2681
|
+
T && R && /* @__PURE__ */ s("div", { style: b.divider, children: g.dividerBullet }),
|
|
2682
|
+
R && /* @__PURE__ */ f("div", { children: [
|
|
2540
2683
|
/* @__PURE__ */ f("span", { style: b.divider, children: [
|
|
2541
2684
|
g.signupText,
|
|
2542
2685
|
" "
|
|
@@ -2546,7 +2689,7 @@ function $r({
|
|
|
2546
2689
|
] })
|
|
2547
2690
|
] });
|
|
2548
2691
|
}
|
|
2549
|
-
const
|
|
2692
|
+
const lr = {
|
|
2550
2693
|
title: "Create Account",
|
|
2551
2694
|
nameLabel: "First Name",
|
|
2552
2695
|
namePlaceholder: "Enter your first name",
|
|
@@ -2576,7 +2719,7 @@ const Qt = {
|
|
|
2576
2719
|
tenantNotFoundError: "Tenant not found",
|
|
2577
2720
|
dividerBullet: "•"
|
|
2578
2721
|
};
|
|
2579
|
-
function
|
|
2722
|
+
function Kr({
|
|
2580
2723
|
copy: r = {},
|
|
2581
2724
|
styles: e = {},
|
|
2582
2725
|
signupType: t = "user",
|
|
@@ -2586,24 +2729,24 @@ function Mr({
|
|
|
2586
2729
|
onMagicLinkClick: l,
|
|
2587
2730
|
showLoginLink: d = !0,
|
|
2588
2731
|
showMagicLinkOption: T = !0,
|
|
2589
|
-
className:
|
|
2732
|
+
className: R
|
|
2590
2733
|
}) {
|
|
2591
|
-
var
|
|
2592
|
-
const [c,
|
|
2734
|
+
var U;
|
|
2735
|
+
const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [A, k] = N(""), [m, g] = N(""), [b, C] = N(""), [o, p] = N(""), { signup: E, signupTenantAdmin: y } = de(), u = ((U = pe()) == null ? void 0 : U.tenant) ?? null, v = { ...lr, ...r }, D = Le("#10b981", e), se = !!c && (!!P || !!A) && !!m && !!b && (t === "user" || !!o), F = we({
|
|
2593
2736
|
defaultErrorMessage: v.errorMessage,
|
|
2594
2737
|
validate: () => {
|
|
2595
|
-
const
|
|
2596
|
-
return c.trim() ||
|
|
2738
|
+
const L = [];
|
|
2739
|
+
return c.trim() || L.push("name"), !P.trim() && !A.trim() && (L.push("email"), L.push("phoneNumber")), m.trim() || L.push("password"), b.trim() || L.push("confirmPassword"), t === "tenant" && !o.trim() && L.push("tenantName"), L.forEach((q) => F.setFieldError(q, !0)), L.length > 0 ? !1 : m !== b ? (F.setError(v.passwordMismatchError), F.setFieldError("confirmPassword", !0), !1) : t === "user" && !(u != null && u.id) ? (F.setError(v.tenantNotFoundError), !1) : !0;
|
|
2597
2740
|
},
|
|
2598
2741
|
submit: async () => t === "tenant" ? y({
|
|
2599
|
-
email:
|
|
2742
|
+
email: P || void 0,
|
|
2600
2743
|
phoneNumber: A || void 0,
|
|
2601
2744
|
name: c,
|
|
2602
2745
|
password: m,
|
|
2603
2746
|
tenantName: o,
|
|
2604
2747
|
lastName: h || void 0
|
|
2605
|
-
}) :
|
|
2606
|
-
email:
|
|
2748
|
+
}) : E({
|
|
2749
|
+
email: P || void 0,
|
|
2607
2750
|
phoneNumber: A || void 0,
|
|
2608
2751
|
name: c,
|
|
2609
2752
|
password: m,
|
|
@@ -2612,21 +2755,21 @@ function Mr({
|
|
|
2612
2755
|
}),
|
|
2613
2756
|
onSuccess: n,
|
|
2614
2757
|
onError: i
|
|
2615
|
-
}), H = (
|
|
2616
|
-
...
|
|
2617
|
-
...
|
|
2618
|
-
}), j = !
|
|
2619
|
-
...
|
|
2620
|
-
...
|
|
2621
|
-
...j ?
|
|
2758
|
+
}), H = (L) => ({
|
|
2759
|
+
...D.input,
|
|
2760
|
+
...F.fieldErrors[L] ? D.inputError : {}
|
|
2761
|
+
}), j = !se || F.loading, Z = {
|
|
2762
|
+
...D.button,
|
|
2763
|
+
...F.loading ? D.buttonLoading : {},
|
|
2764
|
+
...j ? D.buttonDisabled : {}
|
|
2622
2765
|
}, $ = () => {
|
|
2623
|
-
|
|
2766
|
+
F.clearFieldError("email"), F.clearFieldError("phoneNumber");
|
|
2624
2767
|
};
|
|
2625
|
-
return /* @__PURE__ */ f("div", { className:
|
|
2626
|
-
/* @__PURE__ */ s("h2", { style:
|
|
2627
|
-
/* @__PURE__ */ f("form", { onSubmit:
|
|
2628
|
-
/* @__PURE__ */ f("div", { style:
|
|
2629
|
-
/* @__PURE__ */ s("label", { style:
|
|
2768
|
+
return /* @__PURE__ */ f("div", { className: R, style: D.container, children: [
|
|
2769
|
+
/* @__PURE__ */ s("h2", { style: D.title, children: v.title }),
|
|
2770
|
+
/* @__PURE__ */ f("form", { onSubmit: F.handleSubmit, style: D.form, children: [
|
|
2771
|
+
/* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
|
|
2772
|
+
/* @__PURE__ */ s("label", { style: D.label, children: v.nameLabel }),
|
|
2630
2773
|
/* @__PURE__ */ s(
|
|
2631
2774
|
"input",
|
|
2632
2775
|
{
|
|
@@ -2634,17 +2777,17 @@ function Mr({
|
|
|
2634
2777
|
name: "name",
|
|
2635
2778
|
type: "text",
|
|
2636
2779
|
value: c,
|
|
2637
|
-
onChange: (
|
|
2638
|
-
|
|
2780
|
+
onChange: (L) => {
|
|
2781
|
+
S(L.target.value), F.clearFieldError("name");
|
|
2639
2782
|
},
|
|
2640
2783
|
placeholder: v.namePlaceholder,
|
|
2641
2784
|
style: H("name"),
|
|
2642
|
-
disabled:
|
|
2785
|
+
disabled: F.loading
|
|
2643
2786
|
}
|
|
2644
2787
|
)
|
|
2645
2788
|
] }),
|
|
2646
|
-
/* @__PURE__ */ f("div", { style:
|
|
2647
|
-
/* @__PURE__ */ s("label", { style:
|
|
2789
|
+
/* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
|
|
2790
|
+
/* @__PURE__ */ s("label", { style: D.label, children: v.lastNameLabel }),
|
|
2648
2791
|
/* @__PURE__ */ s(
|
|
2649
2792
|
"input",
|
|
2650
2793
|
{
|
|
@@ -2652,33 +2795,33 @@ function Mr({
|
|
|
2652
2795
|
name: "lastName",
|
|
2653
2796
|
type: "text",
|
|
2654
2797
|
value: h,
|
|
2655
|
-
onChange: (
|
|
2798
|
+
onChange: (L) => x(L.target.value),
|
|
2656
2799
|
placeholder: v.lastNamePlaceholder,
|
|
2657
|
-
style:
|
|
2658
|
-
disabled:
|
|
2800
|
+
style: D.input,
|
|
2801
|
+
disabled: F.loading
|
|
2659
2802
|
}
|
|
2660
2803
|
)
|
|
2661
2804
|
] }),
|
|
2662
|
-
/* @__PURE__ */ f("div", { style:
|
|
2663
|
-
/* @__PURE__ */ s("label", { style:
|
|
2805
|
+
/* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
|
|
2806
|
+
/* @__PURE__ */ s("label", { style: D.label, children: v.emailLabel }),
|
|
2664
2807
|
/* @__PURE__ */ s(
|
|
2665
2808
|
"input",
|
|
2666
2809
|
{
|
|
2667
2810
|
id: "email",
|
|
2668
2811
|
name: "email",
|
|
2669
2812
|
type: "email",
|
|
2670
|
-
value:
|
|
2671
|
-
onChange: (
|
|
2672
|
-
I(
|
|
2813
|
+
value: P,
|
|
2814
|
+
onChange: (L) => {
|
|
2815
|
+
I(L.target.value), $();
|
|
2673
2816
|
},
|
|
2674
2817
|
placeholder: v.emailPlaceholder,
|
|
2675
2818
|
style: H("email"),
|
|
2676
|
-
disabled:
|
|
2819
|
+
disabled: F.loading
|
|
2677
2820
|
}
|
|
2678
2821
|
)
|
|
2679
2822
|
] }),
|
|
2680
|
-
/* @__PURE__ */ f("div", { style:
|
|
2681
|
-
/* @__PURE__ */ s("label", { style:
|
|
2823
|
+
/* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
|
|
2824
|
+
/* @__PURE__ */ s("label", { style: D.label, children: v.phoneNumberLabel }),
|
|
2682
2825
|
/* @__PURE__ */ s(
|
|
2683
2826
|
"input",
|
|
2684
2827
|
{
|
|
@@ -2686,18 +2829,18 @@ function Mr({
|
|
|
2686
2829
|
name: "phoneNumber",
|
|
2687
2830
|
type: "tel",
|
|
2688
2831
|
value: A,
|
|
2689
|
-
onChange: (
|
|
2690
|
-
|
|
2832
|
+
onChange: (L) => {
|
|
2833
|
+
k(L.target.value), $();
|
|
2691
2834
|
},
|
|
2692
2835
|
placeholder: v.phoneNumberPlaceholder,
|
|
2693
2836
|
style: H("phoneNumber"),
|
|
2694
|
-
disabled:
|
|
2837
|
+
disabled: F.loading
|
|
2695
2838
|
}
|
|
2696
2839
|
)
|
|
2697
2840
|
] }),
|
|
2698
|
-
/* @__PURE__ */ s("div", { style:
|
|
2699
|
-
/* @__PURE__ */ f("div", { style:
|
|
2700
|
-
/* @__PURE__ */ s("label", { style:
|
|
2841
|
+
/* @__PURE__ */ s("div", { style: D.hintText, children: v.contactMethodHint }),
|
|
2842
|
+
/* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
|
|
2843
|
+
/* @__PURE__ */ s("label", { style: D.label, children: v.passwordLabel }),
|
|
2701
2844
|
/* @__PURE__ */ s(
|
|
2702
2845
|
"input",
|
|
2703
2846
|
{
|
|
@@ -2705,17 +2848,17 @@ function Mr({
|
|
|
2705
2848
|
name: "password",
|
|
2706
2849
|
type: "password",
|
|
2707
2850
|
value: m,
|
|
2708
|
-
onChange: (
|
|
2709
|
-
g(
|
|
2851
|
+
onChange: (L) => {
|
|
2852
|
+
g(L.target.value), F.clearFieldError("password");
|
|
2710
2853
|
},
|
|
2711
2854
|
placeholder: v.passwordPlaceholder,
|
|
2712
2855
|
style: H("password"),
|
|
2713
|
-
disabled:
|
|
2856
|
+
disabled: F.loading
|
|
2714
2857
|
}
|
|
2715
2858
|
)
|
|
2716
2859
|
] }),
|
|
2717
|
-
/* @__PURE__ */ f("div", { style:
|
|
2718
|
-
/* @__PURE__ */ s("label", { style:
|
|
2860
|
+
/* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
|
|
2861
|
+
/* @__PURE__ */ s("label", { style: D.label, children: v.confirmPasswordLabel }),
|
|
2719
2862
|
/* @__PURE__ */ s(
|
|
2720
2863
|
"input",
|
|
2721
2864
|
{
|
|
@@ -2723,17 +2866,17 @@ function Mr({
|
|
|
2723
2866
|
name: "confirmPassword",
|
|
2724
2867
|
type: "password",
|
|
2725
2868
|
value: b,
|
|
2726
|
-
onChange: (
|
|
2727
|
-
|
|
2869
|
+
onChange: (L) => {
|
|
2870
|
+
C(L.target.value), F.clearFieldError("confirmPassword"), F.error === v.passwordMismatchError && F.setError("");
|
|
2728
2871
|
},
|
|
2729
2872
|
placeholder: v.confirmPasswordPlaceholder,
|
|
2730
2873
|
style: H("confirmPassword"),
|
|
2731
|
-
disabled:
|
|
2874
|
+
disabled: F.loading
|
|
2732
2875
|
}
|
|
2733
2876
|
)
|
|
2734
2877
|
] }),
|
|
2735
|
-
t === "tenant" && /* @__PURE__ */ f("div", { style:
|
|
2736
|
-
/* @__PURE__ */ s("label", { style:
|
|
2878
|
+
t === "tenant" && /* @__PURE__ */ f("div", { style: D.fieldGroup, children: [
|
|
2879
|
+
/* @__PURE__ */ s("label", { style: D.label, children: v.tenantNameLabel }),
|
|
2737
2880
|
/* @__PURE__ */ s(
|
|
2738
2881
|
"input",
|
|
2739
2882
|
{
|
|
@@ -2741,38 +2884,38 @@ function Mr({
|
|
|
2741
2884
|
name: "tenantName",
|
|
2742
2885
|
type: "text",
|
|
2743
2886
|
value: o,
|
|
2744
|
-
onChange: (
|
|
2745
|
-
p(
|
|
2887
|
+
onChange: (L) => {
|
|
2888
|
+
p(L.target.value), F.clearFieldError("tenantName");
|
|
2746
2889
|
},
|
|
2747
2890
|
placeholder: v.tenantNamePlaceholder,
|
|
2748
2891
|
style: H("tenantName"),
|
|
2749
|
-
disabled:
|
|
2892
|
+
disabled: F.loading
|
|
2750
2893
|
}
|
|
2751
2894
|
)
|
|
2752
2895
|
] }),
|
|
2753
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: j, style: Z, children:
|
|
2754
|
-
|
|
2896
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: j, style: Z, children: F.loading ? v.loadingText : v.submitButton }),
|
|
2897
|
+
F.error && /* @__PURE__ */ s("div", { style: D.errorText, children: F.error })
|
|
2755
2898
|
] }),
|
|
2756
|
-
(d || T) && /* @__PURE__ */ f("div", { style:
|
|
2899
|
+
(d || T) && /* @__PURE__ */ f("div", { style: D.linkContainer, children: [
|
|
2757
2900
|
T && /* @__PURE__ */ f("div", { children: [
|
|
2758
|
-
/* @__PURE__ */ f("span", { style:
|
|
2901
|
+
/* @__PURE__ */ f("span", { style: D.divider, children: [
|
|
2759
2902
|
v.magicLinkText,
|
|
2760
2903
|
" "
|
|
2761
2904
|
] }),
|
|
2762
|
-
/* @__PURE__ */ s("a", { onClick: l, style:
|
|
2905
|
+
/* @__PURE__ */ s("a", { onClick: l, style: D.link, children: v.magicLinkLink })
|
|
2763
2906
|
] }),
|
|
2764
|
-
T && d && /* @__PURE__ */ s("div", { style:
|
|
2907
|
+
T && d && /* @__PURE__ */ s("div", { style: D.divider, children: v.dividerBullet }),
|
|
2765
2908
|
d && /* @__PURE__ */ f("div", { children: [
|
|
2766
|
-
/* @__PURE__ */ f("span", { style:
|
|
2909
|
+
/* @__PURE__ */ f("span", { style: D.divider, children: [
|
|
2767
2910
|
v.loginText,
|
|
2768
2911
|
" "
|
|
2769
2912
|
] }),
|
|
2770
|
-
/* @__PURE__ */ s("a", { onClick: a, style:
|
|
2913
|
+
/* @__PURE__ */ s("a", { onClick: a, style: D.link, children: v.loginLink })
|
|
2771
2914
|
] })
|
|
2772
2915
|
] })
|
|
2773
2916
|
] });
|
|
2774
2917
|
}
|
|
2775
|
-
const
|
|
2918
|
+
const cr = {
|
|
2776
2919
|
title: "Sign In with Magic Link",
|
|
2777
2920
|
emailLabel: "Email",
|
|
2778
2921
|
emailPlaceholder: "Enter your email",
|
|
@@ -2797,7 +2940,7 @@ const Jt = {
|
|
|
2797
2940
|
missingTenantOrEmailError: "Missing tenant or email",
|
|
2798
2941
|
dividerBullet: "•"
|
|
2799
2942
|
};
|
|
2800
|
-
function
|
|
2943
|
+
function Yr({
|
|
2801
2944
|
copy: r = {},
|
|
2802
2945
|
styles: e = {},
|
|
2803
2946
|
onSuccess: t,
|
|
@@ -2807,37 +2950,37 @@ function Br({
|
|
|
2807
2950
|
showTraditionalLinks: l = !0,
|
|
2808
2951
|
className: d,
|
|
2809
2952
|
verifyToken: T,
|
|
2810
|
-
frontendUrl:
|
|
2953
|
+
frontendUrl: R
|
|
2811
2954
|
}) {
|
|
2812
2955
|
var H;
|
|
2813
|
-
const [c,
|
|
2956
|
+
const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [A, k] = N(!1), [m, g] = N(""), [b, C] = N(!1), { sendMagicLink: o, verifyMagicLink: p } = de(), E = ((H = pe()) == null ? void 0 : H.tenant) ?? null, y = { ...cr, ...r }, u = Le("#3b82f6", e), v = we({
|
|
2814
2957
|
defaultErrorMessage: y.errorMessage,
|
|
2815
2958
|
validate: () => {
|
|
2816
2959
|
const j = [];
|
|
2817
|
-
return c.trim() || j.push("email"), b && !h.trim() && j.push("name"), j.forEach((Z) => v.setFieldError(Z, !0)), j.length > 0 ? !1 :
|
|
2960
|
+
return c.trim() || j.push("email"), b && !h.trim() && j.push("name"), j.forEach((Z) => v.setFieldError(Z, !0)), j.length > 0 ? !1 : E != null && E.id ? !0 : (v.setError(y.tenantNotFoundError), !1);
|
|
2818
2961
|
},
|
|
2819
2962
|
submit: async () => {
|
|
2820
2963
|
g("");
|
|
2821
|
-
const j =
|
|
2964
|
+
const j = R || (typeof window < "u" ? window.location.origin : ""), Z = await o({
|
|
2822
2965
|
email: c,
|
|
2823
|
-
tenantId:
|
|
2966
|
+
tenantId: E.id,
|
|
2824
2967
|
frontendUrl: j,
|
|
2825
2968
|
name: b ? h : void 0,
|
|
2826
|
-
lastName: b ?
|
|
2969
|
+
lastName: b ? P : void 0
|
|
2827
2970
|
});
|
|
2828
2971
|
return g(y.successMessage), Z;
|
|
2829
2972
|
},
|
|
2830
2973
|
onSuccess: t,
|
|
2831
2974
|
onError: n
|
|
2832
2975
|
});
|
|
2833
|
-
|
|
2976
|
+
re(() => {
|
|
2834
2977
|
if (!T) return;
|
|
2835
2978
|
(async () => {
|
|
2836
|
-
if (!
|
|
2979
|
+
if (!E || !c) {
|
|
2837
2980
|
v.setError(y.missingTenantOrEmailError);
|
|
2838
2981
|
return;
|
|
2839
2982
|
}
|
|
2840
|
-
|
|
2983
|
+
k(!0), v.setError("");
|
|
2841
2984
|
try {
|
|
2842
2985
|
const Z = await p({ token: T, email: c });
|
|
2843
2986
|
t == null || t(Z);
|
|
@@ -2845,17 +2988,17 @@ function Br({
|
|
|
2845
2988
|
const $ = Z instanceof Error ? Z.message : "Failed to verify magic link";
|
|
2846
2989
|
v.setError($), n == null || n($);
|
|
2847
2990
|
} finally {
|
|
2848
|
-
|
|
2991
|
+
k(!1);
|
|
2849
2992
|
}
|
|
2850
2993
|
})();
|
|
2851
2994
|
}, [T]);
|
|
2852
|
-
const
|
|
2995
|
+
const D = (j) => ({
|
|
2853
2996
|
...u.input,
|
|
2854
2997
|
...v.fieldErrors[j] ? u.inputError : {}
|
|
2855
|
-
}),
|
|
2998
|
+
}), se = !c || v.loading || A, F = {
|
|
2856
2999
|
...u.button,
|
|
2857
3000
|
...v.loading || A ? u.buttonLoading : {},
|
|
2858
|
-
...
|
|
3001
|
+
...se ? u.buttonDisabled : {}
|
|
2859
3002
|
};
|
|
2860
3003
|
return A ? /* @__PURE__ */ f("div", { className: d, style: u.container, children: [
|
|
2861
3004
|
/* @__PURE__ */ s("h2", { style: u.title, children: y.verifyingText }),
|
|
@@ -2874,10 +3017,10 @@ function Br({
|
|
|
2874
3017
|
type: "email",
|
|
2875
3018
|
value: c,
|
|
2876
3019
|
onChange: (j) => {
|
|
2877
|
-
|
|
3020
|
+
S(j.target.value), v.clearFieldError("email");
|
|
2878
3021
|
},
|
|
2879
3022
|
placeholder: y.emailPlaceholder,
|
|
2880
|
-
style:
|
|
3023
|
+
style: D("email"),
|
|
2881
3024
|
disabled: v.loading || A
|
|
2882
3025
|
}
|
|
2883
3026
|
)
|
|
@@ -2886,7 +3029,7 @@ function Br({
|
|
|
2886
3029
|
"button",
|
|
2887
3030
|
{
|
|
2888
3031
|
type: "button",
|
|
2889
|
-
onClick: () =>
|
|
3032
|
+
onClick: () => C(!0),
|
|
2890
3033
|
style: u.toggleLink,
|
|
2891
3034
|
children: y.showNameToggle
|
|
2892
3035
|
}
|
|
@@ -2902,10 +3045,10 @@ function Br({
|
|
|
2902
3045
|
type: "text",
|
|
2903
3046
|
value: h,
|
|
2904
3047
|
onChange: (j) => {
|
|
2905
|
-
|
|
3048
|
+
x(j.target.value), v.clearFieldError("name");
|
|
2906
3049
|
},
|
|
2907
3050
|
placeholder: y.namePlaceholder,
|
|
2908
|
-
style:
|
|
3051
|
+
style: D("name"),
|
|
2909
3052
|
disabled: v.loading || A
|
|
2910
3053
|
}
|
|
2911
3054
|
)
|
|
@@ -2918,7 +3061,7 @@ function Br({
|
|
|
2918
3061
|
id: "lastName",
|
|
2919
3062
|
name: "lastName",
|
|
2920
3063
|
type: "text",
|
|
2921
|
-
value:
|
|
3064
|
+
value: P,
|
|
2922
3065
|
onChange: (j) => I(j.target.value),
|
|
2923
3066
|
placeholder: y.lastNamePlaceholder,
|
|
2924
3067
|
style: u.input,
|
|
@@ -2931,14 +3074,14 @@ function Br({
|
|
|
2931
3074
|
{
|
|
2932
3075
|
type: "button",
|
|
2933
3076
|
onClick: () => {
|
|
2934
|
-
|
|
3077
|
+
C(!1), x(""), I("");
|
|
2935
3078
|
},
|
|
2936
3079
|
style: u.toggleLink,
|
|
2937
3080
|
children: y.hideNameToggle
|
|
2938
3081
|
}
|
|
2939
3082
|
) })
|
|
2940
3083
|
] }),
|
|
2941
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled:
|
|
3084
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: se, style: F, children: v.loading ? y.loadingText : y.submitButton }),
|
|
2942
3085
|
v.error && /* @__PURE__ */ s("div", { style: u.errorText, children: v.error }),
|
|
2943
3086
|
m && /* @__PURE__ */ s("div", { style: u.successText, children: m })
|
|
2944
3087
|
] }),
|
|
@@ -2961,7 +3104,7 @@ function Br({
|
|
|
2961
3104
|
] })
|
|
2962
3105
|
] });
|
|
2963
3106
|
}
|
|
2964
|
-
const
|
|
3107
|
+
const ur = {
|
|
2965
3108
|
title: "Verifying Magic Link",
|
|
2966
3109
|
verifyingMessage: "Please wait while we verify your magic link...",
|
|
2967
3110
|
successMessage: "Magic link verified successfully! You are now logged in.",
|
|
@@ -2970,7 +3113,7 @@ const Zt = {
|
|
|
2970
3113
|
retryButton: "Try Again",
|
|
2971
3114
|
backToLoginButton: "Back to Login",
|
|
2972
3115
|
missingParamsError: "Missing required parameters: token or email"
|
|
2973
|
-
},
|
|
3116
|
+
}, ut = {
|
|
2974
3117
|
container: {
|
|
2975
3118
|
maxWidth: "400px",
|
|
2976
3119
|
width: "100%",
|
|
@@ -3063,7 +3206,7 @@ const Zt = {
|
|
|
3063
3206
|
backButtonHover: {
|
|
3064
3207
|
backgroundColor: "#e5e7eb"
|
|
3065
3208
|
}
|
|
3066
|
-
},
|
|
3209
|
+
}, dr = () => /* @__PURE__ */ s("div", { style: ut.spinner }), hr = () => /* @__PURE__ */ f(
|
|
3067
3210
|
"svg",
|
|
3068
3211
|
{
|
|
3069
3212
|
width: "48",
|
|
@@ -3080,7 +3223,7 @@ const Zt = {
|
|
|
3080
3223
|
/* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
3081
3224
|
]
|
|
3082
3225
|
}
|
|
3083
|
-
),
|
|
3226
|
+
), pr = () => /* @__PURE__ */ f(
|
|
3084
3227
|
"svg",
|
|
3085
3228
|
{
|
|
3086
3229
|
width: "48",
|
|
@@ -3098,12 +3241,12 @@ const Zt = {
|
|
|
3098
3241
|
/* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
3099
3242
|
]
|
|
3100
3243
|
}
|
|
3101
|
-
),
|
|
3102
|
-
loading: /* @__PURE__ */ s(
|
|
3103
|
-
success: /* @__PURE__ */ s(
|
|
3104
|
-
error: /* @__PURE__ */ s(
|
|
3244
|
+
), fr = {
|
|
3245
|
+
loading: /* @__PURE__ */ s(dr, {}),
|
|
3246
|
+
success: /* @__PURE__ */ s(hr, {}),
|
|
3247
|
+
error: /* @__PURE__ */ s(pr, {})
|
|
3105
3248
|
};
|
|
3106
|
-
function
|
|
3249
|
+
function Xr({
|
|
3107
3250
|
copy: r = {},
|
|
3108
3251
|
styles: e = {},
|
|
3109
3252
|
icons: t = {},
|
|
@@ -3113,48 +3256,48 @@ function Or({
|
|
|
3113
3256
|
onBackToLogin: l,
|
|
3114
3257
|
className: d,
|
|
3115
3258
|
token: T,
|
|
3116
|
-
email:
|
|
3259
|
+
email: R,
|
|
3117
3260
|
appId: c,
|
|
3118
|
-
tenantSlug:
|
|
3261
|
+
tenantSlug: S,
|
|
3119
3262
|
autoRedirectDelay: h = 3e3
|
|
3120
3263
|
}) {
|
|
3121
|
-
const [
|
|
3264
|
+
const [x, P] = N("verifying"), [I, A] = N(""), { verifyMagicLink: k } = de(), m = { ...ur, ...r }, g = { ...ut, ...e }, b = { ...fr, ...t }, C = () => {
|
|
3122
3265
|
if (typeof window > "u") return {};
|
|
3123
3266
|
const u = new URLSearchParams(window.location.search);
|
|
3124
3267
|
return {
|
|
3125
3268
|
token: T || u.get("token") || "",
|
|
3126
|
-
email:
|
|
3269
|
+
email: R || u.get("email") || "",
|
|
3127
3270
|
appId: c || u.get("appId") || "",
|
|
3128
|
-
tenantSlug:
|
|
3271
|
+
tenantSlug: S || u.get("tenantSlug") || void 0
|
|
3129
3272
|
};
|
|
3130
3273
|
}, o = async () => {
|
|
3131
|
-
|
|
3274
|
+
P("verifying"), A("");
|
|
3132
3275
|
try {
|
|
3133
|
-
const u =
|
|
3276
|
+
const u = C();
|
|
3134
3277
|
if (!u.token || !u.email)
|
|
3135
3278
|
throw new Error(m.missingParamsError);
|
|
3136
|
-
const v = await
|
|
3279
|
+
const v = await k({
|
|
3137
3280
|
token: u.token,
|
|
3138
3281
|
email: u.email,
|
|
3139
3282
|
tenantSlug: u.tenantSlug
|
|
3140
3283
|
});
|
|
3141
|
-
|
|
3142
|
-
|
|
3284
|
+
P("success"), n == null || n(v), h > 0 && setTimeout(() => {
|
|
3285
|
+
P("redirecting");
|
|
3143
3286
|
}, h);
|
|
3144
3287
|
} catch (u) {
|
|
3145
3288
|
const v = u.message || m.errorMessage;
|
|
3146
|
-
A(v),
|
|
3289
|
+
A(v), P("error"), i == null || i(v);
|
|
3147
3290
|
}
|
|
3148
3291
|
}, p = () => {
|
|
3149
3292
|
a == null || a(), o();
|
|
3150
|
-
},
|
|
3293
|
+
}, E = () => {
|
|
3151
3294
|
l == null || l();
|
|
3152
3295
|
};
|
|
3153
|
-
|
|
3296
|
+
re(() => {
|
|
3154
3297
|
o();
|
|
3155
3298
|
}, []);
|
|
3156
3299
|
const y = () => {
|
|
3157
|
-
switch (
|
|
3300
|
+
switch (x) {
|
|
3158
3301
|
case "verifying":
|
|
3159
3302
|
return /* @__PURE__ */ f("div", { style: g.message, children: [
|
|
3160
3303
|
b.loading,
|
|
@@ -3185,8 +3328,8 @@ function Or({
|
|
|
3185
3328
|
},
|
|
3186
3329
|
onMouseOut: (u) => {
|
|
3187
3330
|
const v = g.retryButton || {};
|
|
3188
|
-
Object.keys(g.retryButtonHover || {}).forEach((
|
|
3189
|
-
u.currentTarget.style[
|
|
3331
|
+
Object.keys(g.retryButtonHover || {}).forEach((D) => {
|
|
3332
|
+
u.currentTarget.style[D] = v[D] ?? "";
|
|
3190
3333
|
});
|
|
3191
3334
|
},
|
|
3192
3335
|
children: m.retryButton
|
|
@@ -3195,15 +3338,15 @@ function Or({
|
|
|
3195
3338
|
/* @__PURE__ */ s(
|
|
3196
3339
|
"button",
|
|
3197
3340
|
{
|
|
3198
|
-
onClick:
|
|
3341
|
+
onClick: E,
|
|
3199
3342
|
style: g.backButton,
|
|
3200
3343
|
onMouseOver: (u) => {
|
|
3201
3344
|
Object.assign(u.currentTarget.style, g.backButtonHover);
|
|
3202
3345
|
},
|
|
3203
3346
|
onMouseOut: (u) => {
|
|
3204
3347
|
const v = g.backButton || {};
|
|
3205
|
-
Object.keys(g.backButtonHover || {}).forEach((
|
|
3206
|
-
u.currentTarget.style[
|
|
3348
|
+
Object.keys(g.backButtonHover || {}).forEach((D) => {
|
|
3349
|
+
u.currentTarget.style[D] = v[D] ?? "";
|
|
3207
3350
|
});
|
|
3208
3351
|
},
|
|
3209
3352
|
children: m.backToLoginButton
|
|
@@ -3226,7 +3369,7 @@ function Or({
|
|
|
3226
3369
|
y()
|
|
3227
3370
|
] });
|
|
3228
3371
|
}
|
|
3229
|
-
const
|
|
3372
|
+
const mr = {
|
|
3230
3373
|
title: "Reset Password",
|
|
3231
3374
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
3232
3375
|
emailLabel: "Email",
|
|
@@ -3253,7 +3396,7 @@ const tr = {
|
|
|
3253
3396
|
tenantNotFoundError: "Tenant not found",
|
|
3254
3397
|
dividerBullet: "•"
|
|
3255
3398
|
};
|
|
3256
|
-
function
|
|
3399
|
+
function en({
|
|
3257
3400
|
copy: r = {},
|
|
3258
3401
|
styles: e = {},
|
|
3259
3402
|
mode: t = "request",
|
|
@@ -3264,32 +3407,32 @@ function _r({
|
|
|
3264
3407
|
onModeChange: d,
|
|
3265
3408
|
className: T
|
|
3266
3409
|
}) {
|
|
3267
|
-
var
|
|
3268
|
-
const [
|
|
3410
|
+
var se;
|
|
3411
|
+
const [R, c] = N(""), [S, h] = N(n), [x, P] = N(""), [I, A] = N(""), [k, m] = N(""), { requestPasswordReset: g, confirmPasswordReset: b } = de(), C = ((se = pe()) == null ? void 0 : se.tenant) ?? null, o = { ...mr, ...r }, p = Le("#f59e0b", e), E = we({
|
|
3269
3412
|
defaultErrorMessage: o.errorMessage,
|
|
3270
|
-
validate: () =>
|
|
3413
|
+
validate: () => R.trim() ? C != null && C.id ? !0 : (E.setError(o.tenantNotFoundError), !1) : (E.setFieldError("email", !0), !1),
|
|
3271
3414
|
submit: async () => {
|
|
3272
|
-
m(""), await g({ email:
|
|
3415
|
+
m(""), await g({ email: R, tenantId: C.id }), m(o.successMessage);
|
|
3273
3416
|
},
|
|
3274
3417
|
onSuccess: () => i == null ? void 0 : i(),
|
|
3275
3418
|
onError: a
|
|
3276
|
-
}), y =
|
|
3419
|
+
}), y = we({
|
|
3277
3420
|
defaultErrorMessage: o.errorMessage,
|
|
3278
3421
|
validate: () => {
|
|
3279
|
-
const
|
|
3280
|
-
return
|
|
3422
|
+
const F = [];
|
|
3423
|
+
return S.trim() || F.push("token"), x.trim() || F.push("newPassword"), I.trim() || F.push("confirmPassword"), F.forEach((H) => y.setFieldError(H, !0)), F.length > 0 ? !1 : x !== I ? (y.setError(o.passwordMismatchError), y.setFieldError("confirmPassword", !0), !1) : !0;
|
|
3281
3424
|
},
|
|
3282
3425
|
submit: async () => {
|
|
3283
|
-
m(""), await b({ token:
|
|
3426
|
+
m(""), await b({ token: S, newPassword: x }), m(o.resetSuccessMessage);
|
|
3284
3427
|
},
|
|
3285
3428
|
onSuccess: () => i == null ? void 0 : i(),
|
|
3286
3429
|
onError: a
|
|
3287
3430
|
});
|
|
3288
3431
|
if (t === "reset") {
|
|
3289
|
-
const
|
|
3432
|
+
const F = ($) => ({
|
|
3290
3433
|
...p.input,
|
|
3291
3434
|
...y.fieldErrors[$] ? p.inputError : {}
|
|
3292
|
-
}), j = !(!!
|
|
3435
|
+
}), j = !(!!S && !!x && !!I) || y.loading, Z = {
|
|
3293
3436
|
...p.button,
|
|
3294
3437
|
...y.loading ? p.buttonLoading : {},
|
|
3295
3438
|
...j ? p.buttonDisabled : {}
|
|
@@ -3304,12 +3447,12 @@ function _r({
|
|
|
3304
3447
|
"input",
|
|
3305
3448
|
{
|
|
3306
3449
|
type: "text",
|
|
3307
|
-
value:
|
|
3450
|
+
value: S,
|
|
3308
3451
|
onChange: ($) => {
|
|
3309
3452
|
h($.target.value), y.clearFieldError("token");
|
|
3310
3453
|
},
|
|
3311
3454
|
placeholder: o.tokenPlaceholder,
|
|
3312
|
-
style:
|
|
3455
|
+
style: F("token"),
|
|
3313
3456
|
disabled: y.loading
|
|
3314
3457
|
}
|
|
3315
3458
|
)
|
|
@@ -3320,12 +3463,12 @@ function _r({
|
|
|
3320
3463
|
"input",
|
|
3321
3464
|
{
|
|
3322
3465
|
type: "password",
|
|
3323
|
-
value:
|
|
3466
|
+
value: x,
|
|
3324
3467
|
onChange: ($) => {
|
|
3325
|
-
|
|
3468
|
+
P($.target.value), y.clearFieldError("newPassword");
|
|
3326
3469
|
},
|
|
3327
3470
|
placeholder: o.newPasswordPlaceholder,
|
|
3328
|
-
style:
|
|
3471
|
+
style: F("newPassword"),
|
|
3329
3472
|
disabled: y.loading
|
|
3330
3473
|
}
|
|
3331
3474
|
)
|
|
@@ -3341,14 +3484,14 @@ function _r({
|
|
|
3341
3484
|
A($.target.value), y.clearFieldError("confirmPassword"), y.error === o.passwordMismatchError && y.setError("");
|
|
3342
3485
|
},
|
|
3343
3486
|
placeholder: o.confirmPasswordPlaceholder,
|
|
3344
|
-
style:
|
|
3487
|
+
style: F("confirmPassword"),
|
|
3345
3488
|
disabled: y.loading
|
|
3346
3489
|
}
|
|
3347
3490
|
)
|
|
3348
3491
|
] }),
|
|
3349
3492
|
/* @__PURE__ */ s("button", { type: "submit", disabled: j, style: Z, children: y.loading ? o.resetLoadingText : o.resetSubmitButton }),
|
|
3350
3493
|
y.error && /* @__PURE__ */ s("div", { style: p.errorText, children: y.error }),
|
|
3351
|
-
|
|
3494
|
+
k && /* @__PURE__ */ s("div", { style: p.successText, children: k })
|
|
3352
3495
|
] }),
|
|
3353
3496
|
/* @__PURE__ */ f("div", { style: p.linkContainer, children: [
|
|
3354
3497
|
/* @__PURE__ */ s("a", { onClick: l, style: p.link, children: o.backToLoginLink }),
|
|
@@ -3359,37 +3502,37 @@ function _r({
|
|
|
3359
3502
|
] })
|
|
3360
3503
|
] });
|
|
3361
3504
|
}
|
|
3362
|
-
const u = (
|
|
3505
|
+
const u = (F) => ({
|
|
3363
3506
|
...p.input,
|
|
3364
|
-
...
|
|
3365
|
-
}), v = !
|
|
3507
|
+
...E.fieldErrors[F] ? p.inputError : {}
|
|
3508
|
+
}), v = !R || E.loading, D = {
|
|
3366
3509
|
...p.button,
|
|
3367
|
-
...
|
|
3510
|
+
...E.loading ? p.buttonLoading : {},
|
|
3368
3511
|
...v ? p.buttonDisabled : {}
|
|
3369
3512
|
};
|
|
3370
3513
|
return /* @__PURE__ */ f("div", { className: T, style: p.container, children: [
|
|
3371
3514
|
/* @__PURE__ */ s("h2", { style: p.title, children: o.title }),
|
|
3372
3515
|
/* @__PURE__ */ s("p", { style: p.subtitle, children: o.subtitle }),
|
|
3373
|
-
/* @__PURE__ */ f("form", { onSubmit:
|
|
3516
|
+
/* @__PURE__ */ f("form", { onSubmit: E.handleSubmit, style: p.form, children: [
|
|
3374
3517
|
/* @__PURE__ */ f("div", { style: p.fieldGroup, children: [
|
|
3375
3518
|
/* @__PURE__ */ s("label", { style: p.label, children: o.emailLabel }),
|
|
3376
3519
|
/* @__PURE__ */ s(
|
|
3377
3520
|
"input",
|
|
3378
3521
|
{
|
|
3379
3522
|
type: "email",
|
|
3380
|
-
value:
|
|
3381
|
-
onChange: (
|
|
3382
|
-
c(
|
|
3523
|
+
value: R,
|
|
3524
|
+
onChange: (F) => {
|
|
3525
|
+
c(F.target.value), E.clearFieldError("email");
|
|
3383
3526
|
},
|
|
3384
3527
|
placeholder: o.emailPlaceholder,
|
|
3385
3528
|
style: u("email"),
|
|
3386
|
-
disabled:
|
|
3529
|
+
disabled: E.loading
|
|
3387
3530
|
}
|
|
3388
3531
|
)
|
|
3389
3532
|
] }),
|
|
3390
|
-
/* @__PURE__ */ s("button", { type: "submit", disabled: v, style:
|
|
3391
|
-
|
|
3392
|
-
|
|
3533
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: v, style: D, children: E.loading ? o.loadingText : o.submitButton }),
|
|
3534
|
+
E.error && /* @__PURE__ */ s("div", { style: p.errorText, children: E.error }),
|
|
3535
|
+
k && /* @__PURE__ */ s("div", { style: p.successText, children: k })
|
|
3393
3536
|
] }),
|
|
3394
3537
|
/* @__PURE__ */ f("div", { style: p.linkContainer, children: [
|
|
3395
3538
|
/* @__PURE__ */ s("a", { onClick: l, style: p.link, children: o.backToLoginLink }),
|
|
@@ -3400,7 +3543,7 @@ function _r({
|
|
|
3400
3543
|
] })
|
|
3401
3544
|
] });
|
|
3402
3545
|
}
|
|
3403
|
-
const
|
|
3546
|
+
const gr = () => /* @__PURE__ */ s(
|
|
3404
3547
|
"div",
|
|
3405
3548
|
{
|
|
3406
3549
|
style: {
|
|
@@ -3412,7 +3555,7 @@ const rr = () => /* @__PURE__ */ s(
|
|
|
3412
3555
|
},
|
|
3413
3556
|
children: /* @__PURE__ */ s("div", { children: "Loading..." })
|
|
3414
3557
|
}
|
|
3415
|
-
),
|
|
3558
|
+
), yr = ({ error: r, retry: e }) => /* @__PURE__ */ f(
|
|
3416
3559
|
"div",
|
|
3417
3560
|
{
|
|
3418
3561
|
style: {
|
|
@@ -3446,43 +3589,43 @@ const rr = () => /* @__PURE__ */ s(
|
|
|
3446
3589
|
]
|
|
3447
3590
|
}
|
|
3448
3591
|
);
|
|
3449
|
-
function
|
|
3592
|
+
function tn({
|
|
3450
3593
|
children: r,
|
|
3451
3594
|
loadingFallback: e,
|
|
3452
3595
|
errorFallback: t,
|
|
3453
3596
|
requireTenant: n = !0
|
|
3454
3597
|
}) {
|
|
3455
|
-
const { isAppLoading: i, appError: a, retryApp: l } =
|
|
3456
|
-
}), I = (T == null ? void 0 : T.isAuthReady) ?? !0, A = (
|
|
3457
|
-
a && l(), h && d &&
|
|
3598
|
+
const { isAppLoading: i, appError: a, retryApp: l } = Re(), d = pe(), T = Oe(), R = at(), c = lt(), S = (d == null ? void 0 : d.isTenantLoading) ?? !1, h = (d == null ? void 0 : d.tenantError) ?? null, x = (d == null ? void 0 : d.tenantSlug) ?? null, P = (d == null ? void 0 : d.retryTenant) ?? (() => {
|
|
3599
|
+
}), I = (T == null ? void 0 : T.isAuthReady) ?? !0, A = (R == null ? void 0 : R.isReady) ?? !0, k = (c == null ? void 0 : c.isReady) ?? !0, m = n && d && x, o = i || m && S || T && !I || R && !A || c && !k, p = a || (m ? h : null), E = () => {
|
|
3600
|
+
a && l(), h && d && P();
|
|
3458
3601
|
};
|
|
3459
3602
|
if (o)
|
|
3460
|
-
return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(
|
|
3603
|
+
return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(gr, {}) });
|
|
3461
3604
|
if (p) {
|
|
3462
|
-
const y = typeof t == "function" ? t(p,
|
|
3605
|
+
const y = typeof t == "function" ? t(p, E) : t || /* @__PURE__ */ s(yr, { error: p, retry: E });
|
|
3463
3606
|
return /* @__PURE__ */ s(B, { children: y });
|
|
3464
3607
|
}
|
|
3465
3608
|
return /* @__PURE__ */ s(B, { children: r });
|
|
3466
3609
|
}
|
|
3467
|
-
function
|
|
3468
|
-
const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } =
|
|
3469
|
-
}),
|
|
3610
|
+
function rn(r = !0) {
|
|
3611
|
+
const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } = Re(), a = pe(), l = Oe(), d = at(), T = lt(), R = (a == null ? void 0 : a.isTenantLoading) ?? !1, c = (a == null ? void 0 : a.tenantError) ?? null, S = (a == null ? void 0 : a.tenant) ?? null, h = (a == null ? void 0 : a.tenantSlug) ?? null, x = (a == null ? void 0 : a.retryTenant) ?? (() => {
|
|
3612
|
+
}), P = (l == null ? void 0 : l.isAuthReady) ?? !0, I = (d == null ? void 0 : d.isReady) ?? !0, A = (T == null ? void 0 : T.isReady) ?? !0, k = r && a && h, C = e || k && R || l && !P || d && !I || T && !A, o = t || (k ? c : null);
|
|
3470
3613
|
return {
|
|
3471
|
-
isLoading:
|
|
3614
|
+
isLoading: C,
|
|
3472
3615
|
error: o,
|
|
3473
|
-
isReady: !
|
|
3616
|
+
isReady: !C && !o && i !== null && (!k || S !== null),
|
|
3474
3617
|
retry: () => {
|
|
3475
|
-
t && n(), c && a &&
|
|
3618
|
+
t && n(), c && a && x();
|
|
3476
3619
|
},
|
|
3477
3620
|
// Individual states
|
|
3478
3621
|
app: { isLoading: e, error: t, data: i },
|
|
3479
|
-
tenant: a ? { isLoading:
|
|
3480
|
-
auth: l ? { isReady:
|
|
3622
|
+
tenant: a ? { isLoading: R, error: c, data: S } : null,
|
|
3623
|
+
auth: l ? { isReady: P } : null,
|
|
3481
3624
|
featureFlags: d ? { isReady: I } : null,
|
|
3482
3625
|
subscription: T ? { isReady: A } : null
|
|
3483
3626
|
};
|
|
3484
3627
|
}
|
|
3485
|
-
const
|
|
3628
|
+
const br = {
|
|
3486
3629
|
wrapper: {
|
|
3487
3630
|
position: "relative"
|
|
3488
3631
|
},
|
|
@@ -3526,7 +3669,7 @@ const sr = {
|
|
|
3526
3669
|
marginLeft: 8
|
|
3527
3670
|
}
|
|
3528
3671
|
};
|
|
3529
|
-
function
|
|
3672
|
+
function nn({
|
|
3530
3673
|
tenants: r,
|
|
3531
3674
|
currentTenantId: e,
|
|
3532
3675
|
onSelect: t,
|
|
@@ -3536,68 +3679,68 @@ function zr({
|
|
|
3536
3679
|
itemClassName: l = "",
|
|
3537
3680
|
renderItem: d,
|
|
3538
3681
|
placeholder: T = "Select tenant",
|
|
3539
|
-
disabled:
|
|
3682
|
+
disabled: R = !1,
|
|
3540
3683
|
showCurrentTenant: c = !0
|
|
3541
3684
|
}) {
|
|
3542
|
-
var
|
|
3543
|
-
const
|
|
3544
|
-
|
|
3685
|
+
var C;
|
|
3686
|
+
const S = { ...br, ...n }, h = Oe(), [x, P] = N(!1), I = Ee(null), A = r ?? (h == null ? void 0 : h.userTenants) ?? [], k = e ?? ((C = h == null ? void 0 : h.currentUser) == null ? void 0 : C.tenantId) ?? null, m = async (o) => {
|
|
3687
|
+
P(!1), t ? t(o) : h != null && h.switchToTenant && await h.switchToTenant(o);
|
|
3545
3688
|
};
|
|
3546
|
-
|
|
3689
|
+
re(() => {
|
|
3547
3690
|
const o = (p) => {
|
|
3548
|
-
I.current && !I.current.contains(p.target) &&
|
|
3691
|
+
I.current && !I.current.contains(p.target) && P(!1);
|
|
3549
3692
|
};
|
|
3550
3693
|
return document.addEventListener("mousedown", o), () => document.removeEventListener("mousedown", o);
|
|
3551
3694
|
}, []);
|
|
3552
|
-
const g = A.find((o) => o.id ===
|
|
3695
|
+
const g = A.find((o) => o.id === k);
|
|
3553
3696
|
if (A.length === 0)
|
|
3554
3697
|
return null;
|
|
3555
3698
|
if (A.length === 1 && c)
|
|
3556
3699
|
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s("span", { children: A[0].name }) });
|
|
3557
3700
|
const b = (o, p) => /* @__PURE__ */ f("span", { style: { fontWeight: p ? "bold" : "normal" }, children: [
|
|
3558
3701
|
o.name,
|
|
3559
|
-
o.role && /* @__PURE__ */ f("span", { style:
|
|
3702
|
+
o.role && /* @__PURE__ */ f("span", { style: S.itemRole, children: [
|
|
3560
3703
|
"(",
|
|
3561
3704
|
o.role,
|
|
3562
3705
|
")"
|
|
3563
3706
|
] })
|
|
3564
3707
|
] });
|
|
3565
|
-
return /* @__PURE__ */ f("div", { ref: I, className: i, style:
|
|
3708
|
+
return /* @__PURE__ */ f("div", { ref: I, className: i, style: S.wrapper, children: [
|
|
3566
3709
|
/* @__PURE__ */ f(
|
|
3567
3710
|
"button",
|
|
3568
3711
|
{
|
|
3569
3712
|
type: "button",
|
|
3570
|
-
onClick: () => !
|
|
3571
|
-
disabled:
|
|
3713
|
+
onClick: () => !R && P(!x),
|
|
3714
|
+
disabled: R,
|
|
3572
3715
|
style: {
|
|
3573
|
-
...
|
|
3574
|
-
...
|
|
3716
|
+
...S.button,
|
|
3717
|
+
...R ? S.buttonDisabled : {}
|
|
3575
3718
|
},
|
|
3576
3719
|
children: [
|
|
3577
3720
|
g ? g.name : T,
|
|
3578
|
-
/* @__PURE__ */ s("span", { style:
|
|
3721
|
+
/* @__PURE__ */ s("span", { style: S.arrow, children: x ? "▲" : "▼" })
|
|
3579
3722
|
]
|
|
3580
3723
|
}
|
|
3581
3724
|
),
|
|
3582
|
-
|
|
3583
|
-
const p = o.id ===
|
|
3725
|
+
x && /* @__PURE__ */ s("div", { className: a, style: S.dropdown, children: A.map((o) => {
|
|
3726
|
+
const p = o.id === k;
|
|
3584
3727
|
return /* @__PURE__ */ s(
|
|
3585
3728
|
"div",
|
|
3586
3729
|
{
|
|
3587
3730
|
className: l,
|
|
3588
3731
|
onClick: () => m(o.id),
|
|
3589
3732
|
style: {
|
|
3590
|
-
...
|
|
3591
|
-
...p ?
|
|
3733
|
+
...S.item,
|
|
3734
|
+
...p ? S.itemSelected : {}
|
|
3592
3735
|
},
|
|
3593
|
-
onMouseEnter: (
|
|
3594
|
-
p || Object.assign(
|
|
3736
|
+
onMouseEnter: (E) => {
|
|
3737
|
+
p || Object.assign(E.currentTarget.style, S.itemHover);
|
|
3595
3738
|
},
|
|
3596
|
-
onMouseLeave: (
|
|
3739
|
+
onMouseLeave: (E) => {
|
|
3597
3740
|
if (!p) {
|
|
3598
|
-
const y =
|
|
3599
|
-
Object.keys(
|
|
3600
|
-
|
|
3741
|
+
const y = S.item || {};
|
|
3742
|
+
Object.keys(S.itemHover || {}).forEach((u) => {
|
|
3743
|
+
E.currentTarget.style[u] = y[u] ?? "";
|
|
3601
3744
|
});
|
|
3602
3745
|
}
|
|
3603
3746
|
},
|
|
@@ -3608,7 +3751,7 @@ function zr({
|
|
|
3608
3751
|
}) })
|
|
3609
3752
|
] });
|
|
3610
3753
|
}
|
|
3611
|
-
class
|
|
3754
|
+
class sn {
|
|
3612
3755
|
constructor(e) {
|
|
3613
3756
|
this.httpService = e;
|
|
3614
3757
|
}
|
|
@@ -3617,7 +3760,7 @@ class jr {
|
|
|
3617
3760
|
}
|
|
3618
3761
|
async getPermissions(e) {
|
|
3619
3762
|
const t = await this.httpService.get(
|
|
3620
|
-
`/permissions/${
|
|
3763
|
+
`/permissions/${ce(e)}`
|
|
3621
3764
|
);
|
|
3622
3765
|
return { permissions: t.data, meta: t.meta };
|
|
3623
3766
|
}
|
|
@@ -3635,13 +3778,13 @@ class jr {
|
|
|
3635
3778
|
}
|
|
3636
3779
|
async getAppPermissions(e, t) {
|
|
3637
3780
|
const n = await this.httpService.get(
|
|
3638
|
-
`/permissions/apps/${e}${
|
|
3781
|
+
`/permissions/apps/${e}${ce(t)}`,
|
|
3639
3782
|
{ skipAuth: !0 }
|
|
3640
3783
|
);
|
|
3641
3784
|
return { permissions: n.data, meta: n.meta };
|
|
3642
3785
|
}
|
|
3643
3786
|
}
|
|
3644
|
-
class
|
|
3787
|
+
class on {
|
|
3645
3788
|
constructor(e) {
|
|
3646
3789
|
this.httpService = e;
|
|
3647
3790
|
}
|
|
@@ -3653,7 +3796,7 @@ class Wr {
|
|
|
3653
3796
|
}
|
|
3654
3797
|
async getSubscriptionPlans(e) {
|
|
3655
3798
|
const t = await this.httpService.get(
|
|
3656
|
-
`/subscription-plans/${
|
|
3799
|
+
`/subscription-plans/${ce(e)}`
|
|
3657
3800
|
);
|
|
3658
3801
|
return { plans: t.data, meta: t.meta };
|
|
3659
3802
|
}
|
|
@@ -3672,7 +3815,7 @@ class Wr {
|
|
|
3672
3815
|
await this.httpService.delete(`/subscription-plans/${e}`);
|
|
3673
3816
|
}
|
|
3674
3817
|
}
|
|
3675
|
-
class
|
|
3818
|
+
class an {
|
|
3676
3819
|
constructor(e) {
|
|
3677
3820
|
this.httpService = e;
|
|
3678
3821
|
}
|
|
@@ -3681,24 +3824,24 @@ class Gr {
|
|
|
3681
3824
|
return await this.httpService.get("/health");
|
|
3682
3825
|
}
|
|
3683
3826
|
}
|
|
3684
|
-
const
|
|
3685
|
-
function
|
|
3827
|
+
const dt = "returnTo", Ce = "zone_return_to", De = "zone_return_to";
|
|
3828
|
+
function ln(r = {}) {
|
|
3686
3829
|
const {
|
|
3687
3830
|
zoneRoots: e = {},
|
|
3688
|
-
returnToParam: t =
|
|
3831
|
+
returnToParam: t = dt,
|
|
3689
3832
|
returnToStorage: n = "url"
|
|
3690
|
-
} = r, i =
|
|
3833
|
+
} = r, i = wt(), [a, l] = vt(), { isAuthenticated: d, currentUser: T } = de(), { tenant: R } = ve(), c = V(() => ({ ...ze, ...e }), [e]), S = !!R, h = T == null ? void 0 : T.userType, x = V(() => {
|
|
3691
3834
|
switch (n) {
|
|
3692
3835
|
case "url":
|
|
3693
3836
|
return a.get(t);
|
|
3694
3837
|
case "session":
|
|
3695
|
-
return sessionStorage.getItem(
|
|
3838
|
+
return sessionStorage.getItem(Ce);
|
|
3696
3839
|
case "local":
|
|
3697
|
-
return localStorage.getItem(
|
|
3840
|
+
return localStorage.getItem(De);
|
|
3698
3841
|
default:
|
|
3699
3842
|
return null;
|
|
3700
3843
|
}
|
|
3701
|
-
}, [n, a, t]),
|
|
3844
|
+
}, [n, a, t]), P = te(() => {
|
|
3702
3845
|
switch (n) {
|
|
3703
3846
|
case "url": {
|
|
3704
3847
|
const m = new URLSearchParams(a);
|
|
@@ -3706,13 +3849,13 @@ function Hr(r = {}) {
|
|
|
3706
3849
|
break;
|
|
3707
3850
|
}
|
|
3708
3851
|
case "session":
|
|
3709
|
-
sessionStorage.removeItem(
|
|
3852
|
+
sessionStorage.removeItem(Ce);
|
|
3710
3853
|
break;
|
|
3711
3854
|
case "local":
|
|
3712
|
-
localStorage.removeItem(
|
|
3855
|
+
localStorage.removeItem(De);
|
|
3713
3856
|
break;
|
|
3714
3857
|
}
|
|
3715
|
-
}, [n, a, t, l]), I =
|
|
3858
|
+
}, [n, a, t, l]), I = te(
|
|
3716
3859
|
(m) => {
|
|
3717
3860
|
switch (n) {
|
|
3718
3861
|
case "url": {
|
|
@@ -3721,101 +3864,102 @@ function Hr(r = {}) {
|
|
|
3721
3864
|
break;
|
|
3722
3865
|
}
|
|
3723
3866
|
case "session":
|
|
3724
|
-
sessionStorage.setItem(
|
|
3867
|
+
sessionStorage.setItem(Ce, m);
|
|
3725
3868
|
break;
|
|
3726
3869
|
case "local":
|
|
3727
|
-
localStorage.setItem(
|
|
3870
|
+
localStorage.setItem(De, m);
|
|
3728
3871
|
break;
|
|
3729
3872
|
}
|
|
3730
3873
|
},
|
|
3731
3874
|
[n, a, t, l]
|
|
3732
|
-
), A =
|
|
3875
|
+
), A = te(
|
|
3733
3876
|
(m) => {
|
|
3734
3877
|
const g = c[m] || c.default;
|
|
3735
3878
|
i(g);
|
|
3736
3879
|
},
|
|
3737
3880
|
[i, c]
|
|
3738
|
-
),
|
|
3881
|
+
), k = te(() => S ? d ? h === ae.TENANT_ADMIN ? c.tenantAdmin : c.tenantUser : c.tenantGuest : d ? h === ae.TENANT_ADMIN ? c.publicAdmin : c.publicUser : c.publicGuest, [S, d, h, c]);
|
|
3739
3882
|
return {
|
|
3740
|
-
returnToUrl:
|
|
3741
|
-
clearReturnTo:
|
|
3883
|
+
returnToUrl: x,
|
|
3884
|
+
clearReturnTo: P,
|
|
3742
3885
|
setReturnTo: I,
|
|
3743
3886
|
navigateToZone: A,
|
|
3744
|
-
getSmartRedirect:
|
|
3887
|
+
getSmartRedirect: k
|
|
3745
3888
|
};
|
|
3746
3889
|
}
|
|
3747
|
-
function
|
|
3890
|
+
function cn(r, e, t = dt, n = "url") {
|
|
3748
3891
|
if (!e || n !== "url")
|
|
3749
3892
|
return r;
|
|
3750
3893
|
const i = new URL(r, window.location.origin);
|
|
3751
3894
|
return i.searchParams.set(t, e), i.pathname + i.search;
|
|
3752
3895
|
}
|
|
3753
3896
|
export {
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3897
|
+
qr as AdminZone,
|
|
3898
|
+
Je as AppApiService,
|
|
3899
|
+
tn as AppLoader,
|
|
3900
|
+
Sr as AppProvider,
|
|
3901
|
+
Nt as AuthApiService,
|
|
3902
|
+
Ar as AuthProvider,
|
|
3903
|
+
Or as AuthenticatedZone,
|
|
3904
|
+
oe as ConfigurationError,
|
|
3905
|
+
ct as DEFAULT_ZONE_PRESETS,
|
|
3906
|
+
ze as DEFAULT_ZONE_ROOTS,
|
|
3907
|
+
Jr as FeatureFlag,
|
|
3908
|
+
Ot as FeatureFlagApiService,
|
|
3909
|
+
Lr as FeatureFlagProvider,
|
|
3910
|
+
Vr as GuestZone,
|
|
3911
|
+
an as HealthApiService,
|
|
3912
|
+
he as HttpService,
|
|
3913
|
+
Ur as LandingRoute,
|
|
3914
|
+
Zr as LoginForm,
|
|
3915
|
+
Yr as MagicLinkForm,
|
|
3916
|
+
Xr as MagicLinkVerify,
|
|
3917
|
+
jr as OpenZone,
|
|
3918
|
+
en as PasswordRecoveryForm,
|
|
3919
|
+
sn as PermissionApiService,
|
|
3920
|
+
Dr as Protected,
|
|
3921
|
+
Mr as ProtectedRoute,
|
|
3922
|
+
_r as PublicZone,
|
|
3923
|
+
Ct as RoleApiService,
|
|
3924
|
+
Nr as RoutingProvider,
|
|
3925
|
+
ee as SessionExpiredError,
|
|
3926
|
+
Me as SessionManager,
|
|
3927
|
+
Kr as SignupForm,
|
|
3928
|
+
qt as SubscriptionApiService,
|
|
3929
|
+
Qr as SubscriptionGuard,
|
|
3930
|
+
on as SubscriptionPlanApiService,
|
|
3931
|
+
Fr as SubscriptionProvider,
|
|
3932
|
+
ye as TenantApiService,
|
|
3933
|
+
Wr as TenantAuthenticatedZone,
|
|
3934
|
+
Hr as TenantGuestZone,
|
|
3935
|
+
Gr as TenantOpenZone,
|
|
3936
|
+
Er as TenantProvider,
|
|
3937
|
+
$r as TenantRoute,
|
|
3938
|
+
nn as TenantSelector,
|
|
3939
|
+
Br as TenantZone,
|
|
3940
|
+
kt as TokenRefreshError,
|
|
3941
|
+
St as TokenRefreshTimeoutError,
|
|
3942
|
+
Dt as UserApiService,
|
|
3943
|
+
ae as UserType,
|
|
3944
|
+
zr as UserZone,
|
|
3945
|
+
ue as ZoneRoute,
|
|
3946
|
+
cn as buildRedirectUrl,
|
|
3947
|
+
kr as useApi,
|
|
3948
|
+
Re as useApp,
|
|
3949
|
+
rn as useAppLoaderState,
|
|
3950
|
+
de as useAuth,
|
|
3951
|
+
Ir as useAuthActions,
|
|
3952
|
+
Oe as useAuthOptional,
|
|
3953
|
+
Pr as useAuthState,
|
|
3954
|
+
Vt as useFeatureFlags,
|
|
3955
|
+
Cr as useRouting,
|
|
3956
|
+
Wt as useRoutingOptional,
|
|
3957
|
+
Rr as useSettings,
|
|
3958
|
+
zt as useSubscription,
|
|
3959
|
+
ve as useTenant,
|
|
3960
|
+
ot as useTenantInfo,
|
|
3961
|
+
pe as useTenantOptional,
|
|
3962
|
+
xr as useTenantSettings,
|
|
3963
|
+
ln as useZoneNavigation
|
|
3820
3964
|
};
|
|
3821
3965
|
//# sourceMappingURL=index.es.js.map
|