@classic-homes/auth 1.41.0 → 1.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{auth.svelte-DSE2NZMP.js → auth.svelte-FUCU4DYP.js} +2 -2
- package/dist/{chunk-BMCGFHVM.js → chunk-A6JJQCBU.js} +2 -2
- package/dist/{chunk-5SZT7GKG.js → chunk-G6UH4HBI.js} +2 -2
- package/dist/{chunk-HMZRBRIU.js → chunk-IR6DVUUF.js} +5 -1
- package/dist/{chunk-QLEEAHJJ.js → chunk-QV3DUSP5.js} +128 -40
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/svelte/index.d.ts +2 -2
- package/dist/svelte/index.js +4 -4
- package/dist/{user-utils-B6BNJzF2.d.ts → user-utils-Bo3lMsuT.d.ts} +17 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-IR6DVUUF.js';
|
|
2
|
+
import './chunk-QV3DUSP5.js';
|
|
3
3
|
import './chunk-K6TV3ZVS.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { authApi, InvalidAuthResponseError, RoleDeniedError } from './chunk-
|
|
1
|
+
import { authApi, InvalidAuthResponseError, RoleDeniedError } from './chunk-QV3DUSP5.js';
|
|
2
2
|
import { hasAnyRole, getUserRoles } from './chunk-K6TV3ZVS.js';
|
|
3
3
|
|
|
4
4
|
// src/core/guards.ts
|
|
@@ -19,7 +19,7 @@ function getAvailableMethods(response) {
|
|
|
19
19
|
async function setStoreAuth(response) {
|
|
20
20
|
let store;
|
|
21
21
|
try {
|
|
22
|
-
store = (await import('./auth.svelte-
|
|
22
|
+
store = (await import('./auth.svelte-FUCU4DYP.js')).authStore;
|
|
23
23
|
} catch {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { authService } from './chunk-
|
|
2
|
-
import { authStore, currentUser, isAuthenticated, authActions } from './chunk-
|
|
1
|
+
import { authService } from './chunk-A6JJQCBU.js';
|
|
2
|
+
import { authStore, currentUser, isAuthenticated, authActions } from './chunk-IR6DVUUF.js';
|
|
3
3
|
import { isInitialized, initAuth, getUserRoles } from './chunk-K6TV3ZVS.js';
|
|
4
4
|
|
|
5
5
|
// src/svelte/guards/auth-guard.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidAuthResponseError, authApi } from './chunk-
|
|
1
|
+
import { InvalidAuthResponseError, bumpSessionGeneration, authApi } from './chunk-QV3DUSP5.js';
|
|
2
2
|
import { isInitialized, getConfig, isValidSSOLogoutUrl, hasRole, hasAnyRole, hasAllRoles, decodeJWT, getStorage, getDefaultStorage } from './chunk-K6TV3ZVS.js';
|
|
3
3
|
|
|
4
4
|
// src/svelte/stores/auth.svelte.ts
|
|
@@ -111,6 +111,7 @@ var AuthStore = class {
|
|
|
111
111
|
throw new InvalidAuthResponseError("setAuth requires an access token and a user");
|
|
112
112
|
}
|
|
113
113
|
const userWithPermissions = normalizeUser(user, accessToken);
|
|
114
|
+
bumpSessionGeneration();
|
|
114
115
|
this.state = {
|
|
115
116
|
accessToken,
|
|
116
117
|
refreshToken,
|
|
@@ -174,6 +175,7 @@ var AuthStore = class {
|
|
|
174
175
|
* Clear auth state (logout).
|
|
175
176
|
*/
|
|
176
177
|
logout() {
|
|
178
|
+
bumpSessionGeneration();
|
|
177
179
|
this.state = {
|
|
178
180
|
accessToken: null,
|
|
179
181
|
refreshToken: null,
|
|
@@ -222,6 +224,7 @@ var AuthStore = class {
|
|
|
222
224
|
*/
|
|
223
225
|
handleSessionExpired() {
|
|
224
226
|
const currentPath = typeof window !== "undefined" ? window.location.pathname : "/";
|
|
227
|
+
bumpSessionGeneration();
|
|
225
228
|
this.state = {
|
|
226
229
|
accessToken: null,
|
|
227
230
|
refreshToken: null,
|
|
@@ -303,6 +306,7 @@ var AuthStore = class {
|
|
|
303
306
|
* ```
|
|
304
307
|
*/
|
|
305
308
|
reset() {
|
|
309
|
+
bumpSessionGeneration();
|
|
306
310
|
this.state = {
|
|
307
311
|
accessToken: null,
|
|
308
312
|
refreshToken: null,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isInitialized, getConfig, getUserRoles, getStorage, isTokenExpired, getFetch, isValidRedirectUrl } from './chunk-K6TV3ZVS.js';
|
|
1
|
+
import { isInitialized, getConfig, getUserRoles, getStorage, isTokenExpired, getFetch, isValidRedirectUrl, decodeJWT } from './chunk-K6TV3ZVS.js';
|
|
2
2
|
|
|
3
3
|
// src/core/sso-state.ts
|
|
4
4
|
var SSO_CLIENT_STATE_PARAM = "client_state";
|
|
@@ -96,6 +96,18 @@ var InvalidAuthResponseError = class _InvalidAuthResponseError extends Error {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
+
var SessionChangedError = class _SessionChangedError extends Error {
|
|
100
|
+
constructor(message = "The session changed while this request was in flight; it was not retried.") {
|
|
101
|
+
super(message);
|
|
102
|
+
this.name = "SessionChangedError";
|
|
103
|
+
if (Error.captureStackTrace) {
|
|
104
|
+
Error.captureStackTrace(this, _SessionChangedError);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
function isSessionChangedError(error) {
|
|
109
|
+
return error instanceof SessionChangedError || error?.name === "SessionChangedError";
|
|
110
|
+
}
|
|
99
111
|
var MFAChallengeEmailError = class _MFAChallengeEmailError extends Error {
|
|
100
112
|
constructor(message, status, retryAfterSeconds) {
|
|
101
113
|
super(message);
|
|
@@ -108,6 +120,46 @@ var MFAChallengeEmailError = class _MFAChallengeEmailError extends Error {
|
|
|
108
120
|
}
|
|
109
121
|
};
|
|
110
122
|
|
|
123
|
+
// src/core/session.ts
|
|
124
|
+
var generation = 0;
|
|
125
|
+
function bumpSessionGeneration() {
|
|
126
|
+
generation += 1;
|
|
127
|
+
}
|
|
128
|
+
function readIdentity() {
|
|
129
|
+
let parsed = {};
|
|
130
|
+
try {
|
|
131
|
+
const raw = getStorage().getItem(getConfig().storageKey ?? "classic_auth");
|
|
132
|
+
if (raw) parsed = JSON.parse(raw) ?? {};
|
|
133
|
+
} catch {
|
|
134
|
+
}
|
|
135
|
+
const accessToken = typeof parsed.accessToken === "string" ? parsed.accessToken : "";
|
|
136
|
+
const refreshToken = typeof parsed.refreshToken === "string" ? parsed.refreshToken : "";
|
|
137
|
+
const sub = accessToken ? decodeJWT(accessToken)?.sub : void 0;
|
|
138
|
+
const userId = parsed.user?.id;
|
|
139
|
+
return {
|
|
140
|
+
signedIn: accessToken !== "" || refreshToken !== "",
|
|
141
|
+
sub: typeof sub === "string" || typeof sub === "number" ? String(sub) : void 0,
|
|
142
|
+
userId: typeof userId === "string" || typeof userId === "number" ? String(userId) : void 0
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function captureSession() {
|
|
146
|
+
return { generation, identity: readIdentity() };
|
|
147
|
+
}
|
|
148
|
+
function getSessionGeneration() {
|
|
149
|
+
return generation;
|
|
150
|
+
}
|
|
151
|
+
function isCurrentSession(snapshot) {
|
|
152
|
+
if (snapshot.generation !== generation) return false;
|
|
153
|
+
const then = snapshot.identity;
|
|
154
|
+
const now = readIdentity();
|
|
155
|
+
if (then.signedIn !== now.signedIn) return false;
|
|
156
|
+
if (then.sub !== void 0 && now.sub !== void 0 && then.sub !== now.sub) return false;
|
|
157
|
+
if (then.userId !== void 0 && now.userId !== void 0 && then.userId !== now.userId) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
|
|
111
163
|
// src/core/client.ts
|
|
112
164
|
var DEFAULT_REFRESH_RETRY_DELAYS = [1e3, 3e3];
|
|
113
165
|
var refreshInflight = null;
|
|
@@ -166,7 +218,7 @@ function writeStoredTokens(accessToken, refreshToken) {
|
|
|
166
218
|
}
|
|
167
219
|
async function syncSvelteStore(apply) {
|
|
168
220
|
try {
|
|
169
|
-
const { authStore } = await import('./auth.svelte-
|
|
221
|
+
const { authStore } = await import('./auth.svelte-FUCU4DYP.js');
|
|
170
222
|
apply(authStore);
|
|
171
223
|
} catch {
|
|
172
224
|
}
|
|
@@ -176,6 +228,7 @@ function clearStoredAuth() {
|
|
|
176
228
|
const storage = getStorage();
|
|
177
229
|
storage.removeItem(config.storageKey ?? "classic_auth");
|
|
178
230
|
storage.removeItem(getSessionTokenKey());
|
|
231
|
+
bumpSessionGeneration();
|
|
179
232
|
}
|
|
180
233
|
async function expireSession() {
|
|
181
234
|
clearStoredAuth();
|
|
@@ -245,6 +298,8 @@ function refreshSession(options = {}) {
|
|
|
245
298
|
return refreshInflight;
|
|
246
299
|
}
|
|
247
300
|
async function runRefresh(options) {
|
|
301
|
+
const generation2 = getSessionGeneration();
|
|
302
|
+
const sameGeneration = () => generation2 === getSessionGeneration();
|
|
248
303
|
const presented = getRefreshToken();
|
|
249
304
|
if (!presented) {
|
|
250
305
|
await expireSession();
|
|
@@ -254,6 +309,7 @@ async function runRefresh(options) {
|
|
|
254
309
|
const current = getRefreshToken();
|
|
255
310
|
if (current !== presented) {
|
|
256
311
|
if (!current) {
|
|
312
|
+
if (!sameGeneration()) return "rejected";
|
|
257
313
|
await expireSession();
|
|
258
314
|
return "rejected";
|
|
259
315
|
}
|
|
@@ -278,6 +334,7 @@ async function runRefresh(options) {
|
|
|
278
334
|
await syncSvelteStore((authStore) => authStore.rehydrate());
|
|
279
335
|
return "refreshed";
|
|
280
336
|
}
|
|
337
|
+
if (!sameGeneration()) return "rejected";
|
|
281
338
|
await writeStoredTokens(attempt.accessToken, attempt.refreshToken);
|
|
282
339
|
return "refreshed";
|
|
283
340
|
}
|
|
@@ -287,6 +344,7 @@ async function runRefresh(options) {
|
|
|
287
344
|
await syncSvelteStore((authStore) => authStore.rehydrate());
|
|
288
345
|
return "refreshed";
|
|
289
346
|
}
|
|
347
|
+
if (!sameGeneration()) return "rejected";
|
|
290
348
|
await expireSession();
|
|
291
349
|
return "rejected";
|
|
292
350
|
}
|
|
@@ -316,7 +374,7 @@ function isApiOrigin(url, baseUrl) {
|
|
|
316
374
|
function apiRequest(endpoint, options = {}) {
|
|
317
375
|
return apiRequestInternal(endpoint, options, false);
|
|
318
376
|
}
|
|
319
|
-
async function apiRequestInternal(endpoint, options, isRetry) {
|
|
377
|
+
async function apiRequestInternal(endpoint, options, isRetry, startedIn) {
|
|
320
378
|
const {
|
|
321
379
|
authenticated: wantsAuth = false,
|
|
322
380
|
customFetch,
|
|
@@ -331,6 +389,14 @@ async function apiRequestInternal(endpoint, options, isRetry) {
|
|
|
331
389
|
const isAbsolute = /^https?:\/\//i.test(endpoint);
|
|
332
390
|
const url = isAbsolute ? endpoint : `${config.baseUrl}${endpoint}`;
|
|
333
391
|
const authenticated = wantsAuth && (!isAbsolute || isApiOrigin(url, config.baseUrl));
|
|
392
|
+
const session = startedIn ?? captureSession();
|
|
393
|
+
const assertSameSession = async () => {
|
|
394
|
+
if (isCurrentSession(session)) return;
|
|
395
|
+
if (session.generation === getSessionGeneration()) {
|
|
396
|
+
await syncSvelteStore((authStore) => authStore.rehydrate());
|
|
397
|
+
}
|
|
398
|
+
throw new SessionChangedError();
|
|
399
|
+
};
|
|
334
400
|
if (authenticated && noAuthRetry && !isRetry && typeof window !== "undefined") {
|
|
335
401
|
const accessToken = getAccessToken();
|
|
336
402
|
if (accessToken && isTokenExpired(accessToken)) {
|
|
@@ -338,6 +404,7 @@ async function apiRequestInternal(endpoint, options, isRetry) {
|
|
|
338
404
|
if (outcome === "rejected") {
|
|
339
405
|
throw new Error("Authentication failed. Please sign in again.");
|
|
340
406
|
}
|
|
407
|
+
if (authenticated) await assertSameSession();
|
|
341
408
|
}
|
|
342
409
|
}
|
|
343
410
|
const timeoutMs = timeout ?? config.requestTimeout ?? 3e4;
|
|
@@ -372,15 +439,16 @@ async function apiRequestInternal(endpoint, options, isRetry) {
|
|
|
372
439
|
body: body ? JSON.stringify(body) : void 0,
|
|
373
440
|
signal: controller.signal
|
|
374
441
|
});
|
|
375
|
-
clearTimeout(timeoutId);
|
|
376
442
|
if (response.status === 401 && authenticated && !noAuthRetry && typeof window !== "undefined") {
|
|
443
|
+
await assertSameSession();
|
|
377
444
|
if (isRetry) {
|
|
378
445
|
await expireSession();
|
|
379
446
|
throw new Error("Authentication failed. Please sign in again.");
|
|
380
447
|
}
|
|
381
448
|
const outcome = await refreshSession();
|
|
382
449
|
if (outcome === "refreshed") {
|
|
383
|
-
|
|
450
|
+
await assertSameSession();
|
|
451
|
+
return apiRequestInternal(endpoint, options, true, session);
|
|
384
452
|
}
|
|
385
453
|
if (outcome === "rejected") {
|
|
386
454
|
throw new Error("Authentication failed. Please sign in again.");
|
|
@@ -393,13 +461,17 @@ async function apiRequestInternal(endpoint, options, isRetry) {
|
|
|
393
461
|
try {
|
|
394
462
|
data = await response.json();
|
|
395
463
|
} catch (parseError) {
|
|
464
|
+
if (controller.signal.aborted) throw parseError;
|
|
396
465
|
if (!response.ok) {
|
|
397
466
|
throw new Error(`Server error (${response.status}): Invalid JSON response`);
|
|
398
467
|
}
|
|
399
468
|
throw parseError;
|
|
400
469
|
}
|
|
401
470
|
} else {
|
|
402
|
-
const responseText = await response.text().catch(() =>
|
|
471
|
+
const responseText = await response.text().catch((readError) => {
|
|
472
|
+
if (controller.signal.aborted) throw readError;
|
|
473
|
+
return "";
|
|
474
|
+
});
|
|
403
475
|
if (responseText) {
|
|
404
476
|
try {
|
|
405
477
|
data = JSON.parse(responseText);
|
|
@@ -430,7 +502,6 @@ async function apiRequestInternal(endpoint, options, isRetry) {
|
|
|
430
502
|
}
|
|
431
503
|
return data;
|
|
432
504
|
} catch (error) {
|
|
433
|
-
clearTimeout(timeoutId);
|
|
434
505
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
435
506
|
if (signal?.aborted) throw error;
|
|
436
507
|
throw new Error(`Request timed out after ${timeoutMs}ms`);
|
|
@@ -440,6 +511,7 @@ async function apiRequestInternal(endpoint, options, isRetry) {
|
|
|
440
511
|
}
|
|
441
512
|
throw new Error("API request failed");
|
|
442
513
|
} finally {
|
|
514
|
+
clearTimeout(timeoutId);
|
|
443
515
|
signal?.removeEventListener("abort", onCallerAbort);
|
|
444
516
|
}
|
|
445
517
|
}
|
|
@@ -484,16 +556,19 @@ var api = {
|
|
|
484
556
|
};
|
|
485
557
|
|
|
486
558
|
// src/core/api.ts
|
|
487
|
-
async function fetchWithTimeout(url, init) {
|
|
559
|
+
async function fetchWithTimeout(url, init, read) {
|
|
488
560
|
const config = getConfig();
|
|
489
561
|
const fetchFn = config.fetch ?? fetch;
|
|
490
562
|
const timeoutMs = config.requestTimeout ?? 3e4;
|
|
491
563
|
const controller = new AbortController();
|
|
492
564
|
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
493
565
|
try {
|
|
494
|
-
|
|
566
|
+
const response = await fetchFn(url, { ...init, signal: controller.signal });
|
|
567
|
+
const result = await read(response);
|
|
568
|
+
if (controller.signal.aborted) throw new Error("aborted");
|
|
569
|
+
return result;
|
|
495
570
|
} catch (error) {
|
|
496
|
-
if (
|
|
571
|
+
if (controller.signal.aborted) {
|
|
497
572
|
throw new Error(`Request timed out after ${timeoutMs}ms`);
|
|
498
573
|
}
|
|
499
574
|
throw error;
|
|
@@ -745,19 +820,24 @@ var authApi = {
|
|
|
745
820
|
type: data.method === "backup" || data.method === "email" ? data.method : "totp",
|
|
746
821
|
trustDevice: data.trustDevice
|
|
747
822
|
};
|
|
748
|
-
const
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
823
|
+
const result = await fetchWithTimeout(
|
|
824
|
+
`${config.baseUrl}/auth/mfa/challenge`,
|
|
825
|
+
{
|
|
826
|
+
method: "POST",
|
|
827
|
+
headers: {
|
|
828
|
+
"Content-Type": "application/json",
|
|
829
|
+
Authorization: `Bearer ${data.mfaToken}`
|
|
830
|
+
},
|
|
831
|
+
body: JSON.stringify(requestBody)
|
|
753
832
|
},
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
833
|
+
async (response) => {
|
|
834
|
+
if (!response.ok) {
|
|
835
|
+
const error = await response.json().catch(() => ({ message: "Verification failed" }));
|
|
836
|
+
throw new Error(error.error?.message || error.message || "Invalid verification code");
|
|
837
|
+
}
|
|
838
|
+
return response.json();
|
|
839
|
+
}
|
|
840
|
+
);
|
|
761
841
|
return extractData(result);
|
|
762
842
|
},
|
|
763
843
|
/**
|
|
@@ -768,11 +848,14 @@ var authApi = {
|
|
|
768
848
|
*/
|
|
769
849
|
async sendMFAChallengeEmail(mfaToken) {
|
|
770
850
|
const config = getConfig();
|
|
771
|
-
const response = await fetchWithTimeout(
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
851
|
+
const { response, body } = await fetchWithTimeout(
|
|
852
|
+
`${config.baseUrl}/auth/mfa/challenge/email/send`,
|
|
853
|
+
{
|
|
854
|
+
method: "POST",
|
|
855
|
+
headers: { Authorization: `Bearer ${mfaToken}` }
|
|
856
|
+
},
|
|
857
|
+
async (response2) => ({ response: response2, body: await response2.json().catch(() => ({})) })
|
|
858
|
+
);
|
|
776
859
|
if (!response.ok) {
|
|
777
860
|
const details = body?.error?.details;
|
|
778
861
|
const retryAfter = typeof details?.retryAfterSeconds === "number" ? details.retryAfterSeconds : typeof body?.retryAfterSeconds === "number" ? body.retryAfterSeconds : void 0;
|
|
@@ -900,19 +983,24 @@ var authApi = {
|
|
|
900
983
|
throw new Error("Not authenticated");
|
|
901
984
|
}
|
|
902
985
|
const config = getConfig();
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
986
|
+
const result = await fetchWithTimeout(
|
|
987
|
+
`${config.baseUrl}/auth/sso/link`,
|
|
988
|
+
{
|
|
989
|
+
method: "POST",
|
|
990
|
+
headers: {
|
|
991
|
+
"Content-Type": "application/json",
|
|
992
|
+
Authorization: `Bearer ${accessToken}`
|
|
993
|
+
},
|
|
994
|
+
body: JSON.stringify({ provider })
|
|
908
995
|
},
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
996
|
+
async (response) => {
|
|
997
|
+
if (!response.ok) {
|
|
998
|
+
const error = await response.json().catch(() => ({ message: "Failed to link SSO account" }));
|
|
999
|
+
throw new Error(error.error?.message || error.message || "Failed to link SSO account");
|
|
1000
|
+
}
|
|
1001
|
+
return response.json();
|
|
1002
|
+
}
|
|
1003
|
+
);
|
|
916
1004
|
const authorizationUrl = extractData(result).authorizationUrl;
|
|
917
1005
|
if (authorizationUrl) {
|
|
918
1006
|
if (!isValidRedirectUrl(authorizationUrl)) {
|
|
@@ -1012,4 +1100,4 @@ var authApi = {
|
|
|
1012
1100
|
}
|
|
1013
1101
|
};
|
|
1014
1102
|
|
|
1015
|
-
export { InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isRoleDeniedError, refreshSession, updateStoredTokens, verifySsoClientState };
|
|
1103
|
+
export { InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, api, apiRequest, authApi, bumpSessionGeneration, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isRoleDeniedError, isSessionChangedError, refreshSession, updateStoredTokens, verifySsoClientState };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { e as LoginCredentials, f as LoginResponse, g as LogoutResponse, R as RegisterData, l as RegisterResponse, q as User, k as ProfileUpdateData, C as ChangePasswordData, o as Session, A as ApiKey, c as CreateApiKeyRequest, d as CreateApiKeyResponse, U as UpdateApiKeyRequest, j as MFAStatus, i as MFASetupResponse, M as MFAChallengeData, h as MFAChallengeEmailResponse, D as Device, r as UserPreferences, L as LinkedAccount, n as SecurityEvent, P as Pagination, s as UserRolesResponse } from '../types-DF5Ny2IA.js';
|
|
2
2
|
export { a as AuthConfig, b as AuthState, m as ResetPasswordData, S as SSOConfig, p as StorageAdapter, t as createMemoryStorage, u as createSessionStorage, v as getConfig, w as getDefaultStorage, x as getFetch, y as getStorage, z as initAuth, B as isInitialized, E as resetConfig } from '../types-DF5Ny2IA.js';
|
|
3
|
-
export { A as AuthService, I as InvalidAuthResponseError, L as LoginOptions, M as MFAChallengeEmailError, a as MFAVerifyOptions, R as RoleDeniedError, b as authService, f as formatUserRoles, g as getAvatarFallback, c as getDisplayName, d as getGreeting, e as getUserEmail, h as getUserInitials, i as isRoleDeniedError } from '../user-utils-
|
|
3
|
+
export { A as AuthService, I as InvalidAuthResponseError, L as LoginOptions, M as MFAChallengeEmailError, a as MFAVerifyOptions, R as RoleDeniedError, S as SessionChangedError, b as authService, f as formatUserRoles, g as getAvatarFallback, c as getDisplayName, d as getGreeting, e as getUserEmail, h as getUserInitials, i as isRoleDeniedError, j as isSessionChangedError } from '../user-utils-Bo3lMsuT.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* SSO client state
|
package/dist/core/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AuthService, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse } from '../chunk-
|
|
2
|
-
export { InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isRoleDeniedError, refreshSession, updateStoredTokens, verifySsoClientState } from '../chunk-
|
|
1
|
+
export { AuthService, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse } from '../chunk-A6JJQCBU.js';
|
|
2
|
+
export { InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isRoleDeniedError, isSessionChangedError, refreshSession, updateStoredTokens, verifySsoClientState } from '../chunk-QV3DUSP5.js';
|
|
3
3
|
export { ROLE_HIERARCHY, ROLE_NAMES, computePrimaryRole, createMemoryStorage, createSessionStorage, decodeJWT, extractClaims, getConfig, getDefaultStorage, getEffectiveLevel, getFetch, getStorage, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initAuth, isInitialized, isTokenExpired, resetConfig } from '../chunk-K6TV3ZVS.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { A as ApiKey, a as AuthConfig, b as AuthState, C as ChangePasswordData, c as CreateApiKeyRequest, d as CreateApiKeyResponse, D as Device, L as LinkedAccount, e as LoginCredentials, f as LoginResponse, g as LogoutResponse, M as MFAChallengeData, h as MFAChallengeEmailResponse, i as MFASetupResponse, j as MFAStatus, P as Pagination, k as ProfileUpdateData, R as RegisterData, l as RegisterResponse, m as ResetPasswordData, S as SSOConfig, n as SecurityEvent, o as Session, p as StorageAdapter, U as UpdateApiKeyRequest, q as User, r as UserPreferences, s as UserRolesResponse, t as createMemoryStorage, u as createSessionStorage, v as getConfig, w as getDefaultStorage, x as getFetch, y as getStorage, z as initAuth, B as isInitialized, E as resetConfig } from './types-DF5Ny2IA.js';
|
|
2
2
|
export { ApiRequestOptions, ApiResponse, JWTPayload, ROLE_HIERARCHY, ROLE_NAMES, RefreshOutcome, RefreshSessionOptions, RoleName, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SsoClientStateResult, SsoClientStateVerification, api, apiRequest, authApi, clearStoredAuth, computePrimaryRole, consumeSsoClientState, createSsoClientState, decodeJWT, extractClaims, extractData, getAccessToken, getAvailableMethods, getEffectiveLevel, getMfaToken, getRefreshToken, getSessionToken, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initCrossTabSync, isLoginSuccessResponse, isMfaChallengeResponse, isTokenExpired, refreshSession, updateStoredTokens, verifySsoClientState } from './core/index.js';
|
|
3
|
-
export { A as AuthService, I as InvalidAuthResponseError, L as LoginOptions, M as MFAChallengeEmailError, a as MFAVerifyOptions, R as RoleDeniedError, b as authService, f as formatUserRoles, g as getAvatarFallback, c as getDisplayName, d as getGreeting, e as getUserEmail, h as getUserInitials, i as isRoleDeniedError } from './user-utils-
|
|
3
|
+
export { A as AuthService, I as InvalidAuthResponseError, L as LoginOptions, M as MFAChallengeEmailError, a as MFAVerifyOptions, R as RoleDeniedError, S as SessionChangedError, b as authService, f as formatUserRoles, g as getAvatarFallback, c as getDisplayName, d as getGreeting, e as getUserEmail, h as getUserInitials, i as isRoleDeniedError, j as isSessionChangedError } from './user-utils-Bo3lMsuT.js';
|
|
4
4
|
export { AuthClient, AuthGuardOptions, AuthGuardResult, AuthHookOptions, CreateAuthClientOptions, NavFilterOptions, RoleRestrictedItem, authActions, authStore, canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, currentUser, filterByAccess, filterNavSections, isAuthenticated, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from './svelte/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from './chunk-
|
|
2
|
-
export { AuthService, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse } from './chunk-
|
|
3
|
-
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-
|
|
4
|
-
export { InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isRoleDeniedError, refreshSession, updateStoredTokens, verifySsoClientState } from './chunk-
|
|
1
|
+
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from './chunk-G6UH4HBI.js';
|
|
2
|
+
export { AuthService, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse } from './chunk-A6JJQCBU.js';
|
|
3
|
+
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-IR6DVUUF.js';
|
|
4
|
+
export { InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isRoleDeniedError, isSessionChangedError, refreshSession, updateStoredTokens, verifySsoClientState } from './chunk-QV3DUSP5.js';
|
|
5
5
|
export { ROLE_HIERARCHY, ROLE_NAMES, computePrimaryRole, createMemoryStorage, createSessionStorage, decodeJWT, extractClaims, getConfig, getDefaultStorage, getEffectiveLevel, getFetch, getStorage, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initAuth, isInitialized, isTokenExpired, resetConfig } from './chunk-K6TV3ZVS.js';
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as AuthState, q as User, a as AuthConfig } from '../types-DF5Ny2IA.js';
|
|
2
2
|
export { z as initAuth, B as isInitialized } from '../types-DF5Ny2IA.js';
|
|
3
|
-
import { b as authService } from '../user-utils-
|
|
4
|
-
export { I as InvalidAuthResponseError, R as RoleDeniedError, f as formatUserRoles, g as getAvatarFallback, c as getDisplayName, d as getGreeting, e as getUserEmail, h as getUserInitials, i as isRoleDeniedError } from '../user-utils-
|
|
3
|
+
import { b as authService } from '../user-utils-Bo3lMsuT.js';
|
|
4
|
+
export { I as InvalidAuthResponseError, R as RoleDeniedError, S as SessionChangedError, f as formatUserRoles, g as getAvatarFallback, c as getDisplayName, d as getGreeting, e as getUserEmail, h as getUserInitials, i as isRoleDeniedError, j as isSessionChangedError } from '../user-utils-Bo3lMsuT.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Auth Store
|
package/dist/svelte/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from '../chunk-
|
|
2
|
-
export { formatUserRoles, getAvatarFallback, getDisplayName, getGreeting, getUserEmail, getUserInitials } from '../chunk-
|
|
3
|
-
export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-
|
|
4
|
-
export { InvalidAuthResponseError, RoleDeniedError, isRoleDeniedError } from '../chunk-
|
|
1
|
+
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from '../chunk-G6UH4HBI.js';
|
|
2
|
+
export { formatUserRoles, getAvatarFallback, getDisplayName, getGreeting, getUserEmail, getUserInitials } from '../chunk-A6JJQCBU.js';
|
|
3
|
+
export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-IR6DVUUF.js';
|
|
4
|
+
export { InvalidAuthResponseError, RoleDeniedError, SessionChangedError, isRoleDeniedError, isSessionChangedError } from '../chunk-QV3DUSP5.js';
|
|
5
5
|
export { initAuth, isInitialized } from '../chunk-K6TV3ZVS.js';
|
|
@@ -326,6 +326,22 @@ declare class InvalidAuthResponseError extends Error {
|
|
|
326
326
|
readonly name = "InvalidAuthResponseError";
|
|
327
327
|
constructor(message?: string);
|
|
328
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Error thrown when the session changed (logout, login as another account,
|
|
331
|
+
* expiry) while a request was in flight, and the request needed the session
|
|
332
|
+
* to continue (a 401 that would have been refreshed and retried). The request
|
|
333
|
+
* is not refreshed, retried or allowed to expire the new session: replaying it
|
|
334
|
+
* would send the previous account's request with the next account's
|
|
335
|
+
* credentials.
|
|
336
|
+
*/
|
|
337
|
+
declare class SessionChangedError extends Error {
|
|
338
|
+
readonly name = "SessionChangedError";
|
|
339
|
+
constructor(message?: string);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Type guard to check if an error is a SessionChangedError.
|
|
343
|
+
*/
|
|
344
|
+
declare function isSessionChangedError(error: unknown): error is SessionChangedError;
|
|
329
345
|
/**
|
|
330
346
|
* Error thrown when CHAPI won't send an MFA challenge email code: the
|
|
331
347
|
* challenge token is invalid or expired (401), the account has no email MFA
|
|
@@ -444,4 +460,4 @@ declare function formatUserRoles(user: User | null | undefined, options?: {
|
|
|
444
460
|
capitalize?: boolean;
|
|
445
461
|
}): string;
|
|
446
462
|
|
|
447
|
-
export { AuthService as A, InvalidAuthResponseError as I, type LoginOptions as L, MFAChallengeEmailError as M, RoleDeniedError as R, type MFAVerifyOptions as a, authService as b, getDisplayName as c, getGreeting as d, getUserEmail as e, formatUserRoles as f, getAvatarFallback as g, getUserInitials as h, isRoleDeniedError as i };
|
|
463
|
+
export { AuthService as A, InvalidAuthResponseError as I, type LoginOptions as L, MFAChallengeEmailError as M, RoleDeniedError as R, SessionChangedError as S, type MFAVerifyOptions as a, authService as b, getDisplayName as c, getGreeting as d, getUserEmail as e, formatUserRoles as f, getAvatarFallback as g, getUserInitials as h, isRoleDeniedError as i, isSessionChangedError as j };
|