@classic-homes/auth 1.46.0 → 1.49.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 +57 -2
- package/dist/auth.svelte-D5UAUBOK.js +3 -0
- package/dist/{chunk-7SFVHDFP.js → chunk-6KCX7A53.js} +73 -3
- package/dist/{chunk-BGQVBSXN.js → chunk-KWRXKW3R.js} +44 -4
- package/dist/{chunk-TJRFP24M.js → chunk-OP5MZRBE.js} +3 -3
- package/dist/{chunk-EFS272S3.js → chunk-TANYGU4O.js} +5 -1
- package/dist/{chunk-Q4Q3CJVC.js → chunk-YLRB4RW5.js} +2 -2
- package/dist/core/index.d.ts +100 -6
- package/dist/core/index.js +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/dist/svelte/index.d.ts +4 -4
- package/dist/svelte/index.js +5 -5
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/{types-DF5Ny2IA.d.ts → types-YhPCxYU9.d.ts} +19 -1
- package/dist/{user-utils-DYyljbJR.d.ts → user-utils-CmbXLkt_.d.ts} +7 -1
- package/package.json +1 -1
- package/dist/auth.svelte-IWSWWF6U.js +0 -3
package/README.md
CHANGED
|
@@ -184,11 +184,33 @@ if (!accepted) {
|
|
|
184
184
|
```
|
|
185
185
|
|
|
186
186
|
Set `sso.requireClientState: true` once the API echoing `client_state` is
|
|
187
|
-
deployed to that environment
|
|
188
|
-
accepted, so log `result` to watch the
|
|
187
|
+
deployed to that environment (CHAPI does since the 2026-11 security release).
|
|
188
|
+
Until then (the default) every result is accepted, so log `result` to watch the
|
|
189
|
+
rollout.
|
|
189
190
|
|
|
190
191
|
### 5. MFA Challenge Verification
|
|
191
192
|
|
|
193
|
+
The MFA challenge page gets its token from the URL hash (`#mfaChallengeToken=…`),
|
|
194
|
+
either from the SSO callback or from your own password sign-in. Accept it only
|
|
195
|
+
when it is bound to this tab: `acceptMfaChallengeHash` checks the echoed
|
|
196
|
+
`client_state` (SSO; consumed) or compares the token with the one
|
|
197
|
+
`authService.login()` remembered when it returned the challenge (password).
|
|
198
|
+
A hash token matching neither came from a link someone else made.
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
import { acceptMfaChallengeHash } from '@classic-homes/auth/core';
|
|
202
|
+
|
|
203
|
+
const { accepted, token, via, result } = acceptMfaChallengeHash(window.location.hash);
|
|
204
|
+
window.history.replaceState({}, '', window.location.pathname); // drop the token from the URL
|
|
205
|
+
if (!accepted || !token) goto('/auth/login');
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
It follows `sso.requireClientState` like `verifySsoClientState`. If you call
|
|
209
|
+
`authApi.login` directly (not `authService.login`), call
|
|
210
|
+
`rememberMfaChallengeToken(mfaToken)` yourself before navigating to the MFA
|
|
211
|
+
page; `authService.verifyMFAChallenge` clears it on success
|
|
212
|
+
(`clearMfaChallengeToken()` for a cancel).
|
|
213
|
+
|
|
192
214
|
```typescript
|
|
193
215
|
import { authService } from '@classic-homes/auth/core';
|
|
194
216
|
|
|
@@ -206,6 +228,32 @@ async function handleMFAVerify(mfaToken: string, code: string, trustDevice: bool
|
|
|
206
228
|
}
|
|
207
229
|
```
|
|
208
230
|
|
|
231
|
+
### SSO account linking
|
|
232
|
+
|
|
233
|
+
`authService.linkAccount(provider)` (`authApi.linkSSOAccount`) sends the
|
|
234
|
+
signed-in user to the IdP. CHAPI then redirects to
|
|
235
|
+
`/account?link=pending#sso_link_code=<code>` (or `?link=error&message=…`) and
|
|
236
|
+
**links nothing** until the same signed-in user posts that one-time code back.
|
|
237
|
+
On your `/account` page:
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
import { authService, isApiError, readSsoLinkResult } from '@classic-homes/auth/core';
|
|
241
|
+
|
|
242
|
+
const link = readSsoLinkResult(); // reads and strips link/message/sso_link_code from the URL
|
|
243
|
+
if (link?.status === 'pending') {
|
|
244
|
+
try {
|
|
245
|
+
const { provider } = await authService.completeSSOLink(link.code);
|
|
246
|
+
toast.success(`Linked your ${provider} account`);
|
|
247
|
+
} catch (error) {
|
|
248
|
+
// 400: unknown, expired or already-used code, or the SSO account is linked to another user
|
|
249
|
+
// 403: started by a different account, or the IdP email is unverified / not this account's
|
|
250
|
+
toast.error(isApiError(error) ? error.message : 'Linking failed');
|
|
251
|
+
}
|
|
252
|
+
} else if (link?.status === 'error') {
|
|
253
|
+
toast.error(link.message ?? 'Linking failed');
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
209
257
|
### 6. Protect Routes
|
|
210
258
|
|
|
211
259
|
```typescript
|
|
@@ -400,6 +448,13 @@ import {
|
|
|
400
448
|
// API
|
|
401
449
|
authApi,
|
|
402
450
|
|
|
451
|
+
// SSO / MFA binding and account linking
|
|
452
|
+
verifySsoClientState,
|
|
453
|
+
acceptMfaChallengeHash,
|
|
454
|
+
rememberMfaChallengeToken,
|
|
455
|
+
clearMfaChallengeToken,
|
|
456
|
+
readSsoLinkResult,
|
|
457
|
+
|
|
403
458
|
// MFA Guards
|
|
404
459
|
isMfaChallengeResponse,
|
|
405
460
|
isLoginSuccessResponse,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isInitialized, getConfig, getUserRoles, clearAccessSubject, getStorage, isTokenExpired, getFetch, isAccessProbeActive, isValidRedirectUrl, ACCESS_DEBUG_HEADER, ACCESS_REDACTED_HEADER, ACCESS_REDACTED_TRUNCATED_HEADER, parseRedactedHeader, reportAccess, requirementFromDenial, decodeJWT } from './chunk-
|
|
1
|
+
import { isInitialized, getConfig, getUserRoles, clearAccessSubject, getStorage, isTokenExpired, getFetch, isAccessProbeActive, isValidRedirectUrl, ACCESS_DEBUG_HEADER, ACCESS_REDACTED_HEADER, ACCESS_REDACTED_TRUNCATED_HEADER, parseRedactedHeader, reportAccess, requirementFromDenial, decodeJWT } from './chunk-TANYGU4O.js';
|
|
2
2
|
|
|
3
3
|
// src/core/sso-state.ts
|
|
4
4
|
var SSO_CLIENT_STATE_PARAM = "client_state";
|
|
@@ -67,6 +67,52 @@ function verifySsoClientState(input) {
|
|
|
67
67
|
const required = isInitialized() && getConfig().sso?.requireClientState === true;
|
|
68
68
|
return { result, accepted: result === "ok" || !required };
|
|
69
69
|
}
|
|
70
|
+
var MFA_CHALLENGE_TOKEN_PARAM = "mfaChallengeToken";
|
|
71
|
+
function mfaTokenKey() {
|
|
72
|
+
const prefix = isInitialized() ? getConfig().storageKey ?? "classic_auth" : "classic_auth";
|
|
73
|
+
return `${prefix}_mfa_challenge_token`;
|
|
74
|
+
}
|
|
75
|
+
function rememberMfaChallengeToken(token) {
|
|
76
|
+
const store = sessionStore();
|
|
77
|
+
if (!store || !token) return false;
|
|
78
|
+
try {
|
|
79
|
+
store.setItem(mfaTokenKey(), token);
|
|
80
|
+
return true;
|
|
81
|
+
} catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function clearMfaChallengeToken() {
|
|
86
|
+
const store = sessionStore();
|
|
87
|
+
if (!store) return;
|
|
88
|
+
try {
|
|
89
|
+
store.removeItem(mfaTokenKey());
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function rememberedMfaChallengeToken() {
|
|
94
|
+
const store = sessionStore();
|
|
95
|
+
if (!store) return null;
|
|
96
|
+
try {
|
|
97
|
+
return store.getItem(mfaTokenKey());
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function acceptMfaChallengeHash(input) {
|
|
103
|
+
const params = typeof input === "string" ? new URLSearchParams(input.replace(/^#/, "")) : input;
|
|
104
|
+
const token = params.get(MFA_CHALLENGE_TOKEN_PARAM);
|
|
105
|
+
const required = isInitialized() && getConfig().sso?.requireClientState === true;
|
|
106
|
+
if (!token) return { result: "missing", accepted: false, token: null, via: null };
|
|
107
|
+
const receivedState = params.get(SSO_CLIENT_STATE_PARAM);
|
|
108
|
+
if (receivedState !== null) {
|
|
109
|
+
const result2 = consumeSsoClientState(receivedState);
|
|
110
|
+
return { result: result2, accepted: result2 === "ok" || !required, token, via: "sso" };
|
|
111
|
+
}
|
|
112
|
+
const remembered = rememberedMfaChallengeToken();
|
|
113
|
+
const result = !remembered ? "missing" : timingSafeEqual(remembered, token) ? "ok" : "mismatch";
|
|
114
|
+
return { result, accepted: result === "ok" || !required, token, via: "password" };
|
|
115
|
+
}
|
|
70
116
|
|
|
71
117
|
// src/core/errors.ts
|
|
72
118
|
var RoleDeniedError = class _RoleDeniedError extends Error {
|
|
@@ -236,7 +282,7 @@ function writeStoredTokens(accessToken, refreshToken) {
|
|
|
236
282
|
}
|
|
237
283
|
async function syncSvelteStore(apply) {
|
|
238
284
|
try {
|
|
239
|
-
const { authStore } = await import('./auth.svelte-
|
|
285
|
+
const { authStore } = await import('./auth.svelte-D5UAUBOK.js');
|
|
240
286
|
apply(authStore);
|
|
241
287
|
} catch {
|
|
242
288
|
}
|
|
@@ -1069,6 +1115,9 @@ var authApi = {
|
|
|
1069
1115
|
*
|
|
1070
1116
|
* Initiates the SSO linking flow by making an authenticated API call.
|
|
1071
1117
|
* The server returns an authorization URL to redirect the user to.
|
|
1118
|
+
* The IdP returns the user to `/account?link=pending#sso_link_code=…`;
|
|
1119
|
+
* nothing is linked until that page calls `completeSSOLink(code)`
|
|
1120
|
+
* (read the code with `readSsoLinkResult()`).
|
|
1072
1121
|
*/
|
|
1073
1122
|
async linkSSOAccount(provider = "authentik") {
|
|
1074
1123
|
if (typeof window === "undefined") return;
|
|
@@ -1105,6 +1154,27 @@ var authApi = {
|
|
|
1105
1154
|
window.location.href = authorizationUrl;
|
|
1106
1155
|
}
|
|
1107
1156
|
},
|
|
1157
|
+
/**
|
|
1158
|
+
* Finish linking an SSO account (`POST /auth/sso/link/complete`).
|
|
1159
|
+
*
|
|
1160
|
+
* After the IdP, CHAPI redirects to `/account?link=pending#sso_link_code=…`
|
|
1161
|
+
* and writes no link until the signed-in user who started it sends that
|
|
1162
|
+
* one-time code here. Throws `ApiError`: 400 for an unknown, expired or used
|
|
1163
|
+
* code (or an SSO account already linked to another user), 403 when the
|
|
1164
|
+
* link was started by a different account or the IdP email is unverified or
|
|
1165
|
+
* differs from the account email.
|
|
1166
|
+
*/
|
|
1167
|
+
async completeSSOLink(code) {
|
|
1168
|
+
const response = await apiRequest(
|
|
1169
|
+
"/auth/sso/link/complete",
|
|
1170
|
+
{
|
|
1171
|
+
method: "POST",
|
|
1172
|
+
body: { code },
|
|
1173
|
+
authenticated: true
|
|
1174
|
+
}
|
|
1175
|
+
);
|
|
1176
|
+
return extractData(response);
|
|
1177
|
+
},
|
|
1108
1178
|
// ============================================================================
|
|
1109
1179
|
// Security Events
|
|
1110
1180
|
// ============================================================================
|
|
@@ -1194,4 +1264,4 @@ var authApi = {
|
|
|
1194
1264
|
}
|
|
1195
1265
|
};
|
|
1196
1266
|
|
|
1197
|
-
export { ApiError, 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, isApiError, isRoleDeniedError, isSessionChangedError, refreshSession, updateStoredTokens, verifySsoClientState };
|
|
1267
|
+
export { ApiError, InvalidAuthResponseError, MFAChallengeEmailError, MFA_CHALLENGE_TOKEN_PARAM, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, acceptMfaChallengeHash, api, apiRequest, authApi, bumpSessionGeneration, clearMfaChallengeToken, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isApiError, isRoleDeniedError, isSessionChangedError, refreshSession, rememberMfaChallengeToken, updateStoredTokens, verifySsoClientState };
|
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
import { authApi, InvalidAuthResponseError, RoleDeniedError } from './chunk-
|
|
2
|
-
import { getUserRoles } from './chunk-
|
|
1
|
+
import { authApi, rememberMfaChallengeToken, InvalidAuthResponseError, RoleDeniedError, clearMfaChallengeToken } from './chunk-6KCX7A53.js';
|
|
2
|
+
import { getUserRoles } from './chunk-TANYGU4O.js';
|
|
3
|
+
|
|
4
|
+
// src/core/sso-link.ts
|
|
5
|
+
var SSO_LINK_CODE_PARAM = "sso_link_code";
|
|
6
|
+
var SSO_LINK_STATUS_PARAM = "link";
|
|
7
|
+
function readSsoLinkResult(options = {}) {
|
|
8
|
+
const fromWindow = options.url === void 0;
|
|
9
|
+
if (fromWindow && typeof window === "undefined") return null;
|
|
10
|
+
const url = new URL(fromWindow ? window.location.href : String(options.url));
|
|
11
|
+
const hash = new URLSearchParams(url.hash.replace(/^#/, ""));
|
|
12
|
+
const code = hash.get(SSO_LINK_CODE_PARAM);
|
|
13
|
+
const status = url.searchParams.get(SSO_LINK_STATUS_PARAM);
|
|
14
|
+
const message = url.searchParams.get("message");
|
|
15
|
+
let result = null;
|
|
16
|
+
if (code) result = { status: "pending", code };
|
|
17
|
+
else if (status === "error") result = { status: "error", message };
|
|
18
|
+
if (result && fromWindow && options.clear !== false) clearLinkParams(url, hash);
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
function clearLinkParams(url, hash) {
|
|
22
|
+
url.searchParams.delete(SSO_LINK_STATUS_PARAM);
|
|
23
|
+
url.searchParams.delete("message");
|
|
24
|
+
hash.delete(SSO_LINK_CODE_PARAM);
|
|
25
|
+
const rest = hash.toString();
|
|
26
|
+
url.hash = rest ? `#${rest}` : "";
|
|
27
|
+
try {
|
|
28
|
+
window.history.replaceState(window.history.state, "", url.toString());
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
3
32
|
|
|
4
33
|
// src/core/guards.ts
|
|
5
34
|
function isMfaChallengeResponse(response) {
|
|
@@ -19,7 +48,7 @@ function getAvailableMethods(response) {
|
|
|
19
48
|
async function setStoreAuth(response) {
|
|
20
49
|
let store;
|
|
21
50
|
try {
|
|
22
|
-
store = (await import('./auth.svelte-
|
|
51
|
+
store = (await import('./auth.svelte-D5UAUBOK.js')).authStore;
|
|
23
52
|
} catch {
|
|
24
53
|
return;
|
|
25
54
|
}
|
|
@@ -38,6 +67,8 @@ var AuthService = class {
|
|
|
38
67
|
async login(credentials, options) {
|
|
39
68
|
const response = await authApi.login(credentials);
|
|
40
69
|
if (isMfaChallengeResponse(response)) {
|
|
70
|
+
const mfaToken = getMfaToken(response);
|
|
71
|
+
if (mfaToken) rememberMfaChallengeToken(mfaToken);
|
|
41
72
|
return response;
|
|
42
73
|
}
|
|
43
74
|
if (!isLoginSuccessResponse(response)) {
|
|
@@ -223,6 +254,7 @@ var AuthService = class {
|
|
|
223
254
|
if (!isLoginSuccessResponse(response)) {
|
|
224
255
|
throw new InvalidAuthResponseError();
|
|
225
256
|
}
|
|
257
|
+
clearMfaChallengeToken();
|
|
226
258
|
if (options?.allowedRoles?.length) {
|
|
227
259
|
if (!holdsAnyRole(response.user, options.allowedRoles)) {
|
|
228
260
|
throw new RoleDeniedError(
|
|
@@ -315,6 +347,14 @@ var AuthService = class {
|
|
|
315
347
|
async linkAccount(provider = "authentik") {
|
|
316
348
|
await authApi.linkSSOAccount(provider);
|
|
317
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* Finish linking an SSO account with the one-time `sso_link_code` the
|
|
352
|
+
* `/account` page received (see `readSsoLinkResult()`). Throws `ApiError`
|
|
353
|
+
* (400 unknown/used code, 403 different user or unverified/mismatched email).
|
|
354
|
+
*/
|
|
355
|
+
async completeSSOLink(code) {
|
|
356
|
+
return await authApi.completeSSOLink(code);
|
|
357
|
+
}
|
|
318
358
|
/**
|
|
319
359
|
* Unlink an SSO account.
|
|
320
360
|
*/
|
|
@@ -400,4 +440,4 @@ function formatUserRoles(user, options = {}) {
|
|
|
400
440
|
return formatted.join(separator);
|
|
401
441
|
}
|
|
402
442
|
|
|
403
|
-
export { AuthService, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse };
|
|
443
|
+
export { AuthService, SSO_LINK_CODE_PARAM, SSO_LINK_STATUS_PARAM, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, readSsoLinkResult };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { authService } from './chunk-
|
|
2
|
-
import { authStore, currentUser, isAuthenticated, authActions } from './chunk-
|
|
3
|
-
import { evaluateAccess, effectiveSubject, isAccessProbeActive, reportDecision, isInitialized, initAuth } from './chunk-
|
|
1
|
+
import { authService } from './chunk-KWRXKW3R.js';
|
|
2
|
+
import { authStore, currentUser, isAuthenticated, authActions } from './chunk-YLRB4RW5.js';
|
|
3
|
+
import { evaluateAccess, effectiveSubject, isAccessProbeActive, reportDecision, isInitialized, initAuth } from './chunk-TANYGU4O.js';
|
|
4
4
|
|
|
5
5
|
// src/svelte/guards/auth-guard.ts
|
|
6
6
|
function checkAuth(options = {}) {
|
|
@@ -332,6 +332,8 @@ var ROLE_NAMES = [
|
|
|
332
332
|
"warranty_staff",
|
|
333
333
|
"hotsheet_editor",
|
|
334
334
|
"office_admin",
|
|
335
|
+
"area_manager",
|
|
336
|
+
"project_manager",
|
|
335
337
|
"employee",
|
|
336
338
|
"user",
|
|
337
339
|
"vendor",
|
|
@@ -347,7 +349,7 @@ var ROLE_HIERARCHY = {
|
|
|
347
349
|
subcontractor: 1,
|
|
348
350
|
// Staff tier (2): the read-only `employee` floor, the field-app clones of
|
|
349
351
|
// `agent`, every `<department>_staff` docs role, `hotsheet_editor` and
|
|
350
|
-
// `office_admin`.
|
|
352
|
+
// `office_admin`, `area_manager`, `project_manager`.
|
|
351
353
|
employee: 2,
|
|
352
354
|
agent: 2,
|
|
353
355
|
builder: 2,
|
|
@@ -369,6 +371,8 @@ var ROLE_HIERARCHY = {
|
|
|
369
371
|
warranty_staff: 2,
|
|
370
372
|
hotsheet_editor: 2,
|
|
371
373
|
office_admin: 2,
|
|
374
|
+
area_manager: 2,
|
|
375
|
+
project_manager: 2,
|
|
372
376
|
manager: 3,
|
|
373
377
|
admin: 4
|
|
374
378
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InvalidAuthResponseError, bumpSessionGeneration, authApi } from './chunk-
|
|
2
|
-
import { onAccessSubjectChange, isInitialized, getConfig, isValidSSOLogoutUrl, hasRole, hasAnyRole, hasAllRoles, effectiveSubject, reportDecision, decodeJWT, getStorage, getDefaultStorage } from './chunk-
|
|
1
|
+
import { InvalidAuthResponseError, bumpSessionGeneration, authApi } from './chunk-6KCX7A53.js';
|
|
2
|
+
import { onAccessSubjectChange, isInitialized, getConfig, isValidSSOLogoutUrl, hasRole, hasAnyRole, hasAllRoles, effectiveSubject, reportDecision, decodeJWT, getStorage, getDefaultStorage } from './chunk-TANYGU4O.js';
|
|
3
3
|
|
|
4
4
|
// src/svelte/stores/auth.svelte.ts
|
|
5
5
|
var STORAGE_VERSION = 2;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { e as LoginCredentials, f as LoginResponse, g as LogoutResponse, R as RegisterData, l as RegisterResponse,
|
|
2
|
-
export { a as AuthConfig, b as AuthState, m as ResetPasswordData, S as SSOConfig,
|
|
3
|
-
export { A as ApiError, a as AuthService, I as InvalidAuthResponseError, L as LoginOptions, M as MFAChallengeEmailError, b as MFAVerifyOptions, R as RoleDeniedError, S as SessionChangedError, c as authService, f as formatUserRoles, g as getAvatarFallback, d as getDisplayName, e as getGreeting, h as getUserEmail, i as getUserInitials, j as isApiError, k as isRoleDeniedError, l as isSessionChangedError } from '../user-utils-
|
|
1
|
+
import { o as SSOLinkResult, e as LoginCredentials, f as LoginResponse, g as LogoutResponse, R as RegisterData, l as RegisterResponse, s as User, k as ProfileUpdateData, C as ChangePasswordData, q 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, t as UserPreferences, L as LinkedAccount, n as SSOLinkCompleteResponse, p as SecurityEvent, P as Pagination, u as UserRolesResponse } from '../types-YhPCxYU9.js';
|
|
2
|
+
export { a as AuthConfig, b as AuthState, m as ResetPasswordData, S as SSOConfig, r as StorageAdapter, v as createMemoryStorage, w as createSessionStorage, x as getConfig, y as getDefaultStorage, z as getFetch, B as getStorage, E as initAuth, F as isInitialized, G as resetConfig } from '../types-YhPCxYU9.js';
|
|
3
|
+
export { A as ApiError, a as AuthService, I as InvalidAuthResponseError, L as LoginOptions, M as MFAChallengeEmailError, b as MFAVerifyOptions, R as RoleDeniedError, S as SessionChangedError, c as authService, f as formatUserRoles, g as getAvatarFallback, d as getDisplayName, e as getGreeting, h as getUserEmail, i as getUserInitials, j as isApiError, k as isRoleDeniedError, l as isSessionChangedError } from '../user-utils-CmbXLkt_.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* SSO client state
|
|
@@ -64,6 +64,84 @@ declare function consumeSsoClientState(received: string | null | undefined): Sso
|
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
66
|
declare function verifySsoClientState(input: string | URLSearchParams | null | undefined): SsoClientStateVerification;
|
|
67
|
+
/** Hash-fragment parameter carrying the MFA challenge token. */
|
|
68
|
+
declare const MFA_CHALLENGE_TOKEN_PARAM = "mfaChallengeToken";
|
|
69
|
+
/**
|
|
70
|
+
* Remember the MFA challenge token a password sign-in received, for this tab,
|
|
71
|
+
* so the MFA challenge page can accept that token from its URL hash
|
|
72
|
+
* (`acceptMfaChallengeHash`). `authService.login()` calls this for you when
|
|
73
|
+
* the response is an MFA challenge. Returns `false` when sessionStorage is
|
|
74
|
+
* unavailable.
|
|
75
|
+
*/
|
|
76
|
+
declare function rememberMfaChallengeToken(token: string): boolean;
|
|
77
|
+
/** Forget the remembered MFA challenge token (after verifying, or on cancel). */
|
|
78
|
+
declare function clearMfaChallengeToken(): void;
|
|
79
|
+
interface MfaChallengeHashVerification extends SsoClientStateVerification {
|
|
80
|
+
/** The `mfaChallengeToken` from the hash, or `null` when it has none. */
|
|
81
|
+
token: string | null;
|
|
82
|
+
/** Which binding was checked: the SSO `client_state`, or the password flow's remembered token. */
|
|
83
|
+
via: 'sso' | 'password' | null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Decide whether the MFA challenge page may use the token in its URL hash.
|
|
87
|
+
*
|
|
88
|
+
* - SSO MFA redirect: the hash carries `client_state`, which must match the
|
|
89
|
+
* value this tab stored when it started SSO (consumed, single-use).
|
|
90
|
+
* - Password sign-in: no `client_state`; the token must equal the one this tab
|
|
91
|
+
* remembered when `login()` returned the challenge.
|
|
92
|
+
*
|
|
93
|
+
* A token that matches neither came from a link someone else made. The same
|
|
94
|
+
* `sso.requireClientState` policy as `verifySsoClientState` decides whether
|
|
95
|
+
* a failed binding is rejected (`accepted: false`). A hash without a token is
|
|
96
|
+
* never accepted.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const params = new URLSearchParams(window.location.hash.slice(1));
|
|
101
|
+
* const { accepted, token } = acceptMfaChallengeHash(params);
|
|
102
|
+
* if (!accepted || !token) return goto('/login');
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare function acceptMfaChallengeHash(input: URLSearchParams | string): MfaChallengeHashVerification;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* SSO account linking: the return trip to `/account`.
|
|
109
|
+
*
|
|
110
|
+
* `linkSSOAccount()` sends the signed-in user to the IdP. CHAPI then redirects
|
|
111
|
+
* to `<frontend>/account?link=pending#sso_link_code=<code>` (or
|
|
112
|
+
* `?link=error&message=…`) and writes no link until the same user posts the
|
|
113
|
+
* one-time code to `POST /auth/sso/link/complete` (`completeSSOLink`).
|
|
114
|
+
*
|
|
115
|
+
* The code sits in the hash so it never reaches a server log or `Referer`;
|
|
116
|
+
* `readSsoLinkResult()` removes it from the address bar as it reads it, so a
|
|
117
|
+
* reload, a shared URL or the history entry can't replay it.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/** Hash-fragment parameter carrying the one-time link code. */
|
|
121
|
+
declare const SSO_LINK_CODE_PARAM = "sso_link_code";
|
|
122
|
+
/** Query parameter CHAPI sets on the `/account` redirect (`pending` | `error`). */
|
|
123
|
+
declare const SSO_LINK_STATUS_PARAM = "link";
|
|
124
|
+
interface ReadSsoLinkResultOptions {
|
|
125
|
+
/** URL to read; defaults to `window.location.href`. */
|
|
126
|
+
url?: string | URL;
|
|
127
|
+
/**
|
|
128
|
+
* Remove `link`, `message` and `sso_link_code` from the address bar with
|
|
129
|
+
* `history.replaceState` (default `true`; only when reading the current page).
|
|
130
|
+
*/
|
|
131
|
+
clear?: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Read (and by default clear) the outcome of an SSO account-link round trip.
|
|
135
|
+
* Returns `null` when the URL is not a link return.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const link = readSsoLinkResult();
|
|
140
|
+
* if (link?.status === 'pending') await authService.completeSSOLink(link.code);
|
|
141
|
+
* else if (link?.status === 'error') showError(link.message ?? 'Linking failed');
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
declare function readSsoLinkResult(options?: ReadSsoLinkResultOptions): SSOLinkResult | null;
|
|
67
145
|
|
|
68
146
|
/**
|
|
69
147
|
* HTTP Client
|
|
@@ -409,8 +487,22 @@ declare const authApi: {
|
|
|
409
487
|
*
|
|
410
488
|
* Initiates the SSO linking flow by making an authenticated API call.
|
|
411
489
|
* The server returns an authorization URL to redirect the user to.
|
|
490
|
+
* The IdP returns the user to `/account?link=pending#sso_link_code=…`;
|
|
491
|
+
* nothing is linked until that page calls `completeSSOLink(code)`
|
|
492
|
+
* (read the code with `readSsoLinkResult()`).
|
|
412
493
|
*/
|
|
413
494
|
linkSSOAccount(provider?: string): Promise<void>;
|
|
495
|
+
/**
|
|
496
|
+
* Finish linking an SSO account (`POST /auth/sso/link/complete`).
|
|
497
|
+
*
|
|
498
|
+
* After the IdP, CHAPI redirects to `/account?link=pending#sso_link_code=…`
|
|
499
|
+
* and writes no link until the signed-in user who started it sends that
|
|
500
|
+
* one-time code here. Throws `ApiError`: 400 for an unknown, expired or used
|
|
501
|
+
* code (or an SSO account already linked to another user), 403 when the
|
|
502
|
+
* link was started by a different account or the IdP email is unverified or
|
|
503
|
+
* differs from the account email.
|
|
504
|
+
*/
|
|
505
|
+
completeSSOLink(code: string): Promise<SSOLinkCompleteResponse>;
|
|
414
506
|
/**
|
|
415
507
|
* Get security event history.
|
|
416
508
|
*/
|
|
@@ -616,7 +708,9 @@ declare function extractClaims<T extends string>(token: string, claims: T[]): Pi
|
|
|
616
708
|
* `hotsheet_editor` is a grant-on-top role for the Hotsheet hub's write
|
|
617
709
|
* surface; `office_admin` is a grant-on-top role for the office
|
|
618
710
|
* administrative assistant (home closing & financing fields, permits, walks,
|
|
619
|
-
* lenders); `
|
|
711
|
+
* lenders); `area_manager` / `project_manager` are grant-on-top roles for
|
|
712
|
+
* the construction managers who sign up to attend walks (one person may hold
|
|
713
|
+
* both); `employee` is the read-only base staff
|
|
620
714
|
* floor (default for Authentik SSO); `vendor`/`customer`/`subcontractor` are
|
|
621
715
|
* clones of `user`, row-scoped to their own homes.
|
|
622
716
|
*
|
|
@@ -624,7 +718,7 @@ declare function extractClaims<T extends string>(token: string, claims: T[]): Pi
|
|
|
624
718
|
* field app's clone of `agent`, the second is that department's docs role.
|
|
625
719
|
* Someone on the stormwater team who also reads the docs holds both.
|
|
626
720
|
*/
|
|
627
|
-
declare const ROLE_NAMES: readonly ["admin", "manager", "agent", "builder", "customer_service", "demo", "stormwater", "accounting_staff", "architecture_staff", "construction_staff", "crl_staff", "design_staff", "hr_staff", "it_staff", "landdev_staff", "marketing_staff", "purchasing_staff", "sales_staff", "stormwater_staff", "warranty_staff", "hotsheet_editor", "office_admin", "employee", "user", "vendor", "customer", "subcontractor", "guest"];
|
|
721
|
+
declare const ROLE_NAMES: readonly ["admin", "manager", "agent", "builder", "customer_service", "demo", "stormwater", "accounting_staff", "architecture_staff", "construction_staff", "crl_staff", "design_staff", "hr_staff", "it_staff", "landdev_staff", "marketing_staff", "purchasing_staff", "sales_staff", "stormwater_staff", "warranty_staff", "hotsheet_editor", "office_admin", "area_manager", "project_manager", "employee", "user", "vendor", "customer", "subcontractor", "guest"];
|
|
628
722
|
/**
|
|
629
723
|
* A known role name.
|
|
630
724
|
*
|
|
@@ -867,4 +961,4 @@ declare function parseRedactedHeader(value: string | null | undefined): {
|
|
|
867
961
|
omitted: number;
|
|
868
962
|
};
|
|
869
963
|
|
|
870
|
-
export { ACCESS_DEBUG_HEADER, ACCESS_REDACTED_HEADER, ACCESS_REDACTED_TRUNCATED_HEADER, type AccessCheckEvent, type AccessCheckSource, type AccessEvaluation, type AccessProbe, type AccessRequirement, type AccessSubject, ApiKey, type ApiRequestOptions, type ApiResponse, ChangePasswordData, CreateApiKeyRequest, CreateApiKeyResponse, Device, type JWTPayload, LinkedAccount, LoginCredentials, LoginResponse, LogoutResponse, MFAChallengeData, MFAChallengeEmailResponse, MFASetupResponse, MFAStatus, Pagination, ProfileUpdateData, ROLE_HIERARCHY, ROLE_NAMES, type RedactedField, type RefreshOutcome, type RefreshSessionOptions, RegisterData, RegisterResponse, type RoleName, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SecurityEvent, Session, type SsoClientStateResult, type SsoClientStateVerification, UpdateApiKeyRequest, User, UserPreferences, UserRolesResponse, api, apiRequest, authApi, clearAccessSubject, clearStoredAuth, computePrimaryRole, consumeSsoClientState, createSsoClientState, decodeJWT, effectiveSubject, evaluateAccess, extractClaims, extractData, getAccessSubjectOverride, getAccessToken, getAvailableMethods, getEffectiveLevel, getMfaToken, getRefreshToken, getSessionToken, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initCrossTabSync, isAccessProbeActive, isLoginSuccessResponse, isMfaChallengeResponse, isTokenExpired, onAccessSubjectChange, parseRedactedHeader, refreshSession, reportAccess, reportDecision, requirementFromDenial, setAccessProbe, setAccessSubject, updateStoredTokens, verifySsoClientState };
|
|
964
|
+
export { ACCESS_DEBUG_HEADER, ACCESS_REDACTED_HEADER, ACCESS_REDACTED_TRUNCATED_HEADER, type AccessCheckEvent, type AccessCheckSource, type AccessEvaluation, type AccessProbe, type AccessRequirement, type AccessSubject, ApiKey, type ApiRequestOptions, type ApiResponse, ChangePasswordData, CreateApiKeyRequest, CreateApiKeyResponse, Device, type JWTPayload, LinkedAccount, LoginCredentials, LoginResponse, LogoutResponse, MFAChallengeData, MFAChallengeEmailResponse, MFASetupResponse, MFAStatus, MFA_CHALLENGE_TOKEN_PARAM, type MfaChallengeHashVerification, Pagination, ProfileUpdateData, ROLE_HIERARCHY, ROLE_NAMES, type ReadSsoLinkResultOptions, type RedactedField, type RefreshOutcome, type RefreshSessionOptions, RegisterData, RegisterResponse, type RoleName, SSOLinkCompleteResponse, SSOLinkResult, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SSO_LINK_CODE_PARAM, SSO_LINK_STATUS_PARAM, SecurityEvent, Session, type SsoClientStateResult, type SsoClientStateVerification, UpdateApiKeyRequest, User, UserPreferences, UserRolesResponse, acceptMfaChallengeHash, api, apiRequest, authApi, clearAccessSubject, clearMfaChallengeToken, clearStoredAuth, computePrimaryRole, consumeSsoClientState, createSsoClientState, decodeJWT, effectiveSubject, evaluateAccess, extractClaims, extractData, getAccessSubjectOverride, getAccessToken, getAvailableMethods, getEffectiveLevel, getMfaToken, getRefreshToken, getSessionToken, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initCrossTabSync, isAccessProbeActive, isLoginSuccessResponse, isMfaChallengeResponse, isTokenExpired, onAccessSubjectChange, parseRedactedHeader, readSsoLinkResult, refreshSession, rememberMfaChallengeToken, reportAccess, reportDecision, requirementFromDenial, setAccessProbe, setAccessSubject, updateStoredTokens, verifySsoClientState };
|
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 { ApiError, InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isApiError, isRoleDeniedError, isSessionChangedError, refreshSession, updateStoredTokens, verifySsoClientState } from '../chunk-
|
|
3
|
-
export { ACCESS_DEBUG_HEADER, ACCESS_REDACTED_HEADER, ACCESS_REDACTED_TRUNCATED_HEADER, ROLE_HIERARCHY, ROLE_NAMES, clearAccessSubject, computePrimaryRole, createMemoryStorage, createSessionStorage, decodeJWT, effectiveSubject, evaluateAccess, extractClaims, getAccessSubjectOverride, getConfig, getDefaultStorage, getEffectiveLevel, getFetch, getStorage, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initAuth, isAccessProbeActive, isInitialized, isTokenExpired, onAccessSubjectChange, parseRedactedHeader, reportAccess, reportDecision, requirementFromDenial, resetConfig, setAccessProbe, setAccessSubject } from '../chunk-
|
|
1
|
+
export { AuthService, SSO_LINK_CODE_PARAM, SSO_LINK_STATUS_PARAM, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, readSsoLinkResult } from '../chunk-KWRXKW3R.js';
|
|
2
|
+
export { ApiError, InvalidAuthResponseError, MFAChallengeEmailError, MFA_CHALLENGE_TOKEN_PARAM, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, acceptMfaChallengeHash, api, apiRequest, authApi, clearMfaChallengeToken, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isApiError, isRoleDeniedError, isSessionChangedError, refreshSession, rememberMfaChallengeToken, updateStoredTokens, verifySsoClientState } from '../chunk-6KCX7A53.js';
|
|
3
|
+
export { ACCESS_DEBUG_HEADER, ACCESS_REDACTED_HEADER, ACCESS_REDACTED_TRUNCATED_HEADER, ROLE_HIERARCHY, ROLE_NAMES, clearAccessSubject, computePrimaryRole, createMemoryStorage, createSessionStorage, decodeJWT, effectiveSubject, evaluateAccess, extractClaims, getAccessSubjectOverride, getConfig, getDefaultStorage, getEffectiveLevel, getFetch, getStorage, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initAuth, isAccessProbeActive, isInitialized, isTokenExpired, onAccessSubjectChange, parseRedactedHeader, reportAccess, reportDecision, requirementFromDenial, resetConfig, setAccessProbe, setAccessSubject } from '../chunk-TANYGU4O.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
|
|
2
|
-
export { ACCESS_DEBUG_HEADER, ACCESS_REDACTED_HEADER, ACCESS_REDACTED_TRUNCATED_HEADER, AccessCheckEvent, AccessCheckSource, AccessEvaluation, AccessProbe, AccessRequirement, AccessSubject, ApiRequestOptions, ApiResponse, JWTPayload, ROLE_HIERARCHY, ROLE_NAMES, RedactedField, RefreshOutcome, RefreshSessionOptions, RoleName, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SsoClientStateResult, SsoClientStateVerification, api, apiRequest, authApi, clearAccessSubject, clearStoredAuth, computePrimaryRole, consumeSsoClientState, createSsoClientState, decodeJWT, effectiveSubject, evaluateAccess, extractClaims, extractData, getAccessSubjectOverride, getAccessToken, getAvailableMethods, getEffectiveLevel, getMfaToken, getRefreshToken, getSessionToken, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initCrossTabSync, isAccessProbeActive, isLoginSuccessResponse, isMfaChallengeResponse, isTokenExpired, onAccessSubjectChange, parseRedactedHeader, refreshSession, reportAccess, reportDecision, requirementFromDenial, setAccessProbe, setAccessSubject, updateStoredTokens, verifySsoClientState } from './core/index.js';
|
|
3
|
-
export { A as ApiError, a as AuthService, I as InvalidAuthResponseError, L as LoginOptions, M as MFAChallengeEmailError, b as MFAVerifyOptions, R as RoleDeniedError, S as SessionChangedError, c as authService, f as formatUserRoles, g as getAvatarFallback, d as getDisplayName, e as getGreeting, h as getUserEmail, i as getUserInitials, j as isApiError, k as isRoleDeniedError, l as isSessionChangedError } from './user-utils-
|
|
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 SSOLinkCompleteResponse, o as SSOLinkResult, p as SecurityEvent, q as Session, r as StorageAdapter, U as UpdateApiKeyRequest, s as User, t as UserPreferences, u as UserRolesResponse, v as createMemoryStorage, w as createSessionStorage, x as getConfig, y as getDefaultStorage, z as getFetch, B as getStorage, E as initAuth, F as isInitialized, G as resetConfig } from './types-YhPCxYU9.js';
|
|
2
|
+
export { ACCESS_DEBUG_HEADER, ACCESS_REDACTED_HEADER, ACCESS_REDACTED_TRUNCATED_HEADER, AccessCheckEvent, AccessCheckSource, AccessEvaluation, AccessProbe, AccessRequirement, AccessSubject, ApiRequestOptions, ApiResponse, JWTPayload, MFA_CHALLENGE_TOKEN_PARAM, MfaChallengeHashVerification, ROLE_HIERARCHY, ROLE_NAMES, ReadSsoLinkResultOptions, RedactedField, RefreshOutcome, RefreshSessionOptions, RoleName, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SSO_LINK_CODE_PARAM, SSO_LINK_STATUS_PARAM, SsoClientStateResult, SsoClientStateVerification, acceptMfaChallengeHash, api, apiRequest, authApi, clearAccessSubject, clearMfaChallengeToken, clearStoredAuth, computePrimaryRole, consumeSsoClientState, createSsoClientState, decodeJWT, effectiveSubject, evaluateAccess, extractClaims, extractData, getAccessSubjectOverride, getAccessToken, getAvailableMethods, getEffectiveLevel, getMfaToken, getRefreshToken, getSessionToken, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initCrossTabSync, isAccessProbeActive, isLoginSuccessResponse, isMfaChallengeResponse, isTokenExpired, onAccessSubjectChange, parseRedactedHeader, readSsoLinkResult, refreshSession, rememberMfaChallengeToken, reportAccess, reportDecision, requirementFromDenial, setAccessProbe, setAccessSubject, updateStoredTokens, verifySsoClientState } from './core/index.js';
|
|
3
|
+
export { A as ApiError, a as AuthService, I as InvalidAuthResponseError, L as LoginOptions, M as MFAChallengeEmailError, b as MFAVerifyOptions, R as RoleDeniedError, S as SessionChangedError, c as authService, f as formatUserRoles, g as getAvatarFallback, d as getDisplayName, e as getGreeting, h as getUserEmail, i as getUserInitials, j as isApiError, k as isRoleDeniedError, l as isSessionChangedError } from './user-utils-CmbXLkt_.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 { ApiError, InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isApiError, isRoleDeniedError, isSessionChangedError, refreshSession, updateStoredTokens, verifySsoClientState } from './chunk-
|
|
5
|
-
export { ACCESS_DEBUG_HEADER, ACCESS_REDACTED_HEADER, ACCESS_REDACTED_TRUNCATED_HEADER, ROLE_HIERARCHY, ROLE_NAMES, clearAccessSubject, computePrimaryRole, createMemoryStorage, createSessionStorage, decodeJWT, effectiveSubject, evaluateAccess, extractClaims, getAccessSubjectOverride, getConfig, getDefaultStorage, getEffectiveLevel, getFetch, getStorage, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initAuth, isAccessProbeActive, isInitialized, isTokenExpired, onAccessSubjectChange, parseRedactedHeader, reportAccess, reportDecision, requirementFromDenial, resetConfig, setAccessProbe, setAccessSubject } from './chunk-
|
|
1
|
+
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from './chunk-OP5MZRBE.js';
|
|
2
|
+
export { AuthService, SSO_LINK_CODE_PARAM, SSO_LINK_STATUS_PARAM, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, readSsoLinkResult } from './chunk-KWRXKW3R.js';
|
|
3
|
+
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-YLRB4RW5.js';
|
|
4
|
+
export { ApiError, InvalidAuthResponseError, MFAChallengeEmailError, MFA_CHALLENGE_TOKEN_PARAM, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, acceptMfaChallengeHash, api, apiRequest, authApi, clearMfaChallengeToken, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isApiError, isRoleDeniedError, isSessionChangedError, refreshSession, rememberMfaChallengeToken, updateStoredTokens, verifySsoClientState } from './chunk-6KCX7A53.js';
|
|
5
|
+
export { ACCESS_DEBUG_HEADER, ACCESS_REDACTED_HEADER, ACCESS_REDACTED_TRUNCATED_HEADER, ROLE_HIERARCHY, ROLE_NAMES, clearAccessSubject, computePrimaryRole, createMemoryStorage, createSessionStorage, decodeJWT, effectiveSubject, evaluateAccess, extractClaims, getAccessSubjectOverride, getConfig, getDefaultStorage, getEffectiveLevel, getFetch, getStorage, getTokenExpiration, getTokenRemainingTime, getUserRoles, hasAllRoles, hasAnyRole, hasRole, initAuth, isAccessProbeActive, isInitialized, isTokenExpired, onAccessSubjectChange, parseRedactedHeader, reportAccess, reportDecision, requirementFromDenial, resetConfig, setAccessProbe, setAccessSubject } from './chunk-TANYGU4O.js';
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as AuthState,
|
|
2
|
-
export {
|
|
3
|
-
import { c as authService } from '../user-utils-
|
|
4
|
-
export { I as InvalidAuthResponseError, R as RoleDeniedError, S as SessionChangedError, f as formatUserRoles, g as getAvatarFallback, d as getDisplayName, e as getGreeting, h as getUserEmail, i as getUserInitials, k as isRoleDeniedError, l as isSessionChangedError } from '../user-utils-
|
|
1
|
+
import { b as AuthState, s as User, a as AuthConfig } from '../types-YhPCxYU9.js';
|
|
2
|
+
export { E as initAuth, F as isInitialized } from '../types-YhPCxYU9.js';
|
|
3
|
+
import { c as authService } from '../user-utils-CmbXLkt_.js';
|
|
4
|
+
export { I as InvalidAuthResponseError, R as RoleDeniedError, S as SessionChangedError, f as formatUserRoles, g as getAvatarFallback, d as getDisplayName, e as getGreeting, h as getUserEmail, i as getUserInitials, k as isRoleDeniedError, l as isSessionChangedError } from '../user-utils-CmbXLkt_.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, SessionChangedError, isRoleDeniedError, isSessionChangedError } from '../chunk-
|
|
5
|
-
export { initAuth, isInitialized } from '../chunk-
|
|
1
|
+
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from '../chunk-OP5MZRBE.js';
|
|
2
|
+
export { formatUserRoles, getAvatarFallback, getDisplayName, getGreeting, getUserEmail, getUserInitials } from '../chunk-KWRXKW3R.js';
|
|
3
|
+
export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-YLRB4RW5.js';
|
|
4
|
+
export { InvalidAuthResponseError, RoleDeniedError, SessionChangedError, isRoleDeniedError, isSessionChangedError } from '../chunk-6KCX7A53.js';
|
|
5
|
+
export { initAuth, isInitialized } from '../chunk-TANYGU4O.js';
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as User, D as Device, f as LoginResponse, p as SecurityEvent, q as Session, A as ApiKey, L as LinkedAccount, g as LogoutResponse, i as MFASetupResponse, j as MFAStatus, l as RegisterResponse, t as UserPreferences, r as StorageAdapter, b as AuthState, a as AuthConfig } from '../types-YhPCxYU9.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* User Fixtures
|
package/dist/testing/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hasRole, hasAnyRole, hasAllRoles, initAuth, resetConfig, getUserRoles, isTokenExpired, decodeJWT } from '../chunk-
|
|
1
|
+
import { hasRole, hasAnyRole, hasAllRoles, initAuth, resetConfig, getUserRoles, isTokenExpired, decodeJWT } from '../chunk-TANYGU4O.js';
|
|
2
2
|
|
|
3
3
|
// src/testing/fixtures/users.ts
|
|
4
4
|
var mockUser = {
|
|
@@ -379,6 +379,24 @@ interface LinkedAccount {
|
|
|
379
379
|
createdAt: string;
|
|
380
380
|
lastUsedAt?: string | null;
|
|
381
381
|
}
|
|
382
|
+
/** `POST /auth/sso/link/complete` result: the link is written. */
|
|
383
|
+
interface SSOLinkCompleteResponse {
|
|
384
|
+
linked: true;
|
|
385
|
+
provider: string;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Where an SSO account-link round trip left the `/account` page
|
|
389
|
+
* (`readSsoLinkResult()`):
|
|
390
|
+
* - `pending`: the IdP verified the identity; call `completeSSOLink(code)`
|
|
391
|
+
* - `error`: the IdP step failed; `message` is the server's reason
|
|
392
|
+
*/
|
|
393
|
+
type SSOLinkResult = {
|
|
394
|
+
status: 'pending';
|
|
395
|
+
code: string;
|
|
396
|
+
} | {
|
|
397
|
+
status: 'error';
|
|
398
|
+
message: string | null;
|
|
399
|
+
};
|
|
382
400
|
interface SecurityEvent {
|
|
383
401
|
id: string;
|
|
384
402
|
eventType: string;
|
|
@@ -413,4 +431,4 @@ interface ResetPasswordData {
|
|
|
413
431
|
newPassword: string;
|
|
414
432
|
}
|
|
415
433
|
|
|
416
|
-
export { type ApiKey as A,
|
|
434
|
+
export { type ApiKey as A, getStorage as B, type ChangePasswordData as C, type Device as D, initAuth as E, isInitialized as F, resetConfig as G, type LinkedAccount as L, type MFAChallengeData as M, type Pagination as P, type RegisterData as R, type SSOConfig as S, type UpdateApiKeyRequest as U, type AuthConfig as a, type AuthState as b, type CreateApiKeyRequest as c, type CreateApiKeyResponse as d, type LoginCredentials as e, type LoginResponse as f, type LogoutResponse as g, type MFAChallengeEmailResponse as h, type MFASetupResponse as i, type MFAStatus as j, type ProfileUpdateData as k, type RegisterResponse as l, type ResetPasswordData as m, type SSOLinkCompleteResponse as n, type SSOLinkResult as o, type SecurityEvent as p, type Session as q, type StorageAdapter as r, type User as s, type UserPreferences as t, type UserRolesResponse as u, createMemoryStorage as v, createSessionStorage as w, getConfig as x, getDefaultStorage as y, getFetch as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as LoginCredentials, f as LoginResponse, g as LogoutResponse, R as RegisterData, l as RegisterResponse,
|
|
1
|
+
import { e as LoginCredentials, f as LoginResponse, g as LogoutResponse, R as RegisterData, l as RegisterResponse, s as User, k as ProfileUpdateData, q 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, t as UserPreferences, L as LinkedAccount, n as SSOLinkCompleteResponse, p as SecurityEvent, P as Pagination } from './types-YhPCxYU9.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Auth Service
|
|
@@ -247,6 +247,12 @@ declare class AuthService {
|
|
|
247
247
|
* Link an SSO account (redirects to SSO provider).
|
|
248
248
|
*/
|
|
249
249
|
linkAccount(provider?: string): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
* Finish linking an SSO account with the one-time `sso_link_code` the
|
|
252
|
+
* `/account` page received (see `readSsoLinkResult()`). Throws `ApiError`
|
|
253
|
+
* (400 unknown/used code, 403 different user or unverified/mismatched email).
|
|
254
|
+
*/
|
|
255
|
+
completeSSOLink(code: string): Promise<SSOLinkCompleteResponse>;
|
|
250
256
|
/**
|
|
251
257
|
* Unlink an SSO account.
|
|
252
258
|
*/
|
package/package.json
CHANGED