@happyvertical/smrt-users 0.60.15 → 0.60.17
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/AGENTS.md +27 -0
- package/README.md +66 -0
- package/dist/chunks/{PasswordCredentialService-AL5GT_UL.js → PasswordCredentialService-D_evcc-I.js} +143 -5
- package/dist/chunks/PasswordCredentialService-D_evcc-I.js.map +1 -0
- package/dist/chunks/{TerminalAuthService-CgePPat5.js → TerminalAuthService-lE2aS7C_.js} +132 -8
- package/dist/chunks/TerminalAuthService-lE2aS7C_.js.map +1 -0
- package/dist/collections/SessionCollection.d.ts +30 -0
- package/dist/collections/SessionCollection.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +110 -11
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +89 -1
- package/dist/models/Session.d.ts +45 -0
- package/dist/models/Session.d.ts.map +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/operator.js +1 -1
- package/dist/services/MagicLinkService.d.ts +55 -0
- package/dist/services/MagicLinkService.d.ts.map +1 -1
- package/dist/services/OidcLoginService.d.ts +63 -0
- package/dist/services/OidcLoginService.d.ts.map +1 -1
- package/dist/services/PasswordCredentialService.d.ts +23 -0
- package/dist/services/PasswordCredentialService.d.ts.map +1 -1
- package/dist/services/SessionService.d.ts +8 -0
- package/dist/services/SessionService.d.ts.map +1 -1
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +82 -5
- package/dist/smrt-knowledge.okf.md +3 -2
- package/dist/step-up.d.ts +57 -0
- package/dist/step-up.d.ts.map +1 -0
- package/dist/step-up.js +36 -0
- package/dist/step-up.js.map +1 -0
- package/dist/svelte/components/AccountSecurityPanel.svelte +55 -2
- package/dist/svelte/components/InviteUserModal.svelte +36 -33
- package/dist/svelte/components/MagicLinkForm.svelte +36 -2
- package/dist/svelte/components/OidcProviderButtons.svelte +25 -2
- package/dist/svelte/components/PasskeySignInButton.svelte +15 -2
- package/dist/svelte/components/SignInForm.svelte +30 -2
- package/dist/svelte/components/SignUpForm.svelte +30 -2
- package/dist/svelte/components/UserAvatar.svelte +29 -23
- package/dist/svelte/components/UserCard.svelte +68 -68
- package/dist/svelte/components/UserForm.svelte +19 -19
- package/dist/svelte/components/UserList.svelte +22 -17
- package/dist/svelte/components/UserMenu.svelte +90 -89
- package/dist/sveltekit.js +2 -2
- package/package.json +16 -12
- package/dist/chunks/PasswordCredentialService-AL5GT_UL.js.map +0 -1
- package/dist/chunks/TerminalAuthService-CgePPat5.js.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -145,6 +145,33 @@ are not prerequisites for unrelated user-package work.
|
|
|
145
145
|
server-set (`setSessionData` refuses it). State-changing handlers require
|
|
146
146
|
`application/json` (415). Challenge rows are reaped only 10 minutes past expiry
|
|
147
147
|
(clock skew).
|
|
148
|
+
- Step-up (#4841, `src/step-up.ts`, subpath `./step-up`): `requireRecentAuthentication`
|
|
149
|
+
decides on `SessionContext.reauthenticatedAt`, derived from the stored row:
|
|
150
|
+
`data.reauthenticatedAt` (server-set through `SessionCollection.markReauthenticated`
|
|
151
|
+
only after a deliberate fresh authentication; `setSessionData` refuses it;
|
|
152
|
+
extend/activity never move it) or the sign-in time of a password or passkey
|
|
153
|
+
session only (`STEP_UP_SIGN_IN_AUTH_METHODS` = `password`, `passkey`; an OIDC
|
|
154
|
+
or magic-link SIGN-IN, `terminal`, `pin`, `mobile` never count: an unlocked
|
|
155
|
+
stolen device can complete them without the person). Rule: an EXISTING
|
|
156
|
+
session never counts as fresh by itself; a DELIBERATE fresh authentication
|
|
157
|
+
with any supported method does, so an OIDC-only or magic-link-only owner can
|
|
158
|
+
still step up. Methods, all stamping the EXISTING session (never minting one),
|
|
159
|
+
all refusing layered/PIN/ceilinged sessions (`Session.isStepUpEligible`):
|
|
160
|
+
`PasswordCredentialService.stepUp` (limiter-guarded password check);
|
|
161
|
+
`OidcLoginService.beginStepUp`/`completeStepUp` (authorization request with
|
|
162
|
+
`prompt=login` + `max_age=0`; the transaction is stored on the session as
|
|
163
|
+
`data.oidcStepUpIntent`, taken at the callback so it is single use; the ID
|
|
164
|
+
token must verify as at sign-in AND carry `auth_time` inside the window, not
|
|
165
|
+
before the intent started, not future; its issuer+subject must be an existing
|
|
166
|
+
`OidcIdentity` of the session user's own profile; a provider that omits
|
|
167
|
+
`auth_time` or ignores `prompt`/`max_age` is refused);
|
|
168
|
+
`MagicLinkService.requestStepUp`/`consumeStepUp` (token claim `purpose:
|
|
169
|
+
step_up` + session digest + user id, TTL <= 300 s, single use; `verify` and
|
|
170
|
+
`inspect` refuse it so it cannot sign in; `consumeStepUp` refuses a link
|
|
171
|
+
without that purpose). Every step-up refusal is one `StepUpRequiredError`
|
|
172
|
+
(`step_up_required`) that does not say which check failed. A passkey owner
|
|
173
|
+
re-authenticates with a fresh passkey sign-in. Keep the entry free of
|
|
174
|
+
side-effect imports.
|
|
148
175
|
- A layered session whose tenant differs from its parent's never loads (null
|
|
149
176
|
is allowed: narrower). Limiter rows carry `retain_until`; retention must
|
|
150
177
|
not fall back to a process-wide horizon.
|
package/README.md
CHANGED
|
@@ -1150,6 +1150,72 @@ What the app must do:
|
|
|
1150
1150
|
|
|
1151
1151
|
Passkeys/WebAuthn are a separate credential: see "Passkey sign-in" below.
|
|
1152
1152
|
|
|
1153
|
+
### Step-up (recent authentication) for sensitive actions
|
|
1154
|
+
|
|
1155
|
+
A signed-in session is not proof the person is at the keyboard now. For an
|
|
1156
|
+
action that must not ride on an old or unlocked session (replacing a vault
|
|
1157
|
+
account, #4841), require a recent authentication:
|
|
1158
|
+
|
|
1159
|
+
```ts
|
|
1160
|
+
import { requireRecentAuthentication } from '@happyvertical/smrt-users/step-up';
|
|
1161
|
+
|
|
1162
|
+
const ctx = await sessionService.loadSessionContext(sessionId);
|
|
1163
|
+
// throws StepUpRequiredError (code 'step_up_required') unless the person
|
|
1164
|
+
// proved a credential within the last 5 minutes (maxAgeSeconds, max 1 hour)
|
|
1165
|
+
requireRecentAuthentication(ctx, { maxAgeSeconds: 300 });
|
|
1166
|
+
```
|
|
1167
|
+
|
|
1168
|
+
- The proof is server-side session state. A password or passkey sign-in counts
|
|
1169
|
+
at mint; `oidc`, `magic-link`, `terminal`, `pin`, `mobile` and host-defined
|
|
1170
|
+
sessions do not (an OIDC login can complete silently from the provider's
|
|
1171
|
+
existing browser session, and a magic link from the device's own mail app,
|
|
1172
|
+
so an unlocked stolen device could mint either). `ctx.reauthenticatedAt` is
|
|
1173
|
+
derived from the stored row.
|
|
1174
|
+
- The rule: **an existing session never counts as fresh by itself; a
|
|
1175
|
+
deliberate fresh authentication with any supported method does.** Every
|
|
1176
|
+
method below stamps the EXISTING session (no new session, no user switch),
|
|
1177
|
+
refuses layered/PIN and ceilinged sessions, and answers every refusal with
|
|
1178
|
+
one error that does not say which check failed, so a person who signs in
|
|
1179
|
+
only with Google/OIDC or only by email link can still step up.
|
|
1180
|
+
- **Password**: the page asks for the password and the host calls
|
|
1181
|
+
`(await passwordAuth.service()).stepUp({ sessionId, password, ipAddress })`.
|
|
1182
|
+
It uses the sign-in limiter and constant-work verification; every refusal
|
|
1183
|
+
is one `PasswordCredentialError`.
|
|
1184
|
+
- **Passkey**: re-authenticate with a fresh passkey sign-in and use the new
|
|
1185
|
+
session; there is no separate passkey step-up ceremony.
|
|
1186
|
+
- **OIDC**: `const { url } = await oidc.beginStepUp({ sessionId })`, redirect
|
|
1187
|
+
the person to `url`, then on the callback
|
|
1188
|
+
`await oidc.completeStepUp({ sessionId, callbackUrl })`. The request sets
|
|
1189
|
+
`prompt=login` and `max_age=0`. The transaction (state, nonce, PKCE
|
|
1190
|
+
verifier) is held on the session server-side as its one pending intent
|
|
1191
|
+
(`data.oidcStepUpIntent`, one at a time, dies with the session); the
|
|
1192
|
+
callback takes it, so it works once. The ID token is verified as at
|
|
1193
|
+
sign-in, and must also carry `auth_time` that is within the step-up window
|
|
1194
|
+
(default 300 s, `stepUpWindowSeconds`), not before the intent started and
|
|
1195
|
+
not in the future. The returned issuer+subject must be an existing OIDC
|
|
1196
|
+
identity of the session's own user: it never creates a user or switches
|
|
1197
|
+
one. A provider that does not emit `auth_time`, or ignores
|
|
1198
|
+
`prompt`/`max_age`, is refused, so confirm yours returns `auth_time`. Use a
|
|
1199
|
+
`redirectUri` registered with the provider for step-up (it must not be
|
|
1200
|
+
handled as a sign-in callback). Refusals are `StepUpRequiredError`.
|
|
1201
|
+
- **Magic link**: `const { token, email } = await links.requestStepUp({
|
|
1202
|
+
sessionId })` issues a link of purpose `step_up`, bound to that session and
|
|
1203
|
+
its user, valid for at most 300 s and once; email it to `email` (the
|
|
1204
|
+
user's own address). When the person opens it, the host calls
|
|
1205
|
+
`await links.consumeStepUp({ token, sessionId })` with the SAME session
|
|
1206
|
+
cookie. A sign-in link cannot step up and a step-up link cannot sign in
|
|
1207
|
+
(`verify()`/`inspect()` refuse it); another session or user, an expired or
|
|
1208
|
+
reused link, or a changed account email are all `StepUpRequiredError`.
|
|
1209
|
+
- The stamp (`SESSION_DATA_KEYS.reauthenticatedAt`) is never client input
|
|
1210
|
+
(`setSessionData` refuses it), is not moved by refresh, activity or
|
|
1211
|
+
`extend()`, is carried unchanged across tenant-switch rotation, and dies
|
|
1212
|
+
with the session.
|
|
1213
|
+
- `isTenantOwnerSession(ctx)` is the matching owner test: a direct active
|
|
1214
|
+
`owner` membership on a first-class session (not a member, `terminal`/`pin`
|
|
1215
|
+
device, layered, ceilinged or inherited one).
|
|
1216
|
+
- The `@happyvertical/smrt-users/step-up` entry has no side effects and can be
|
|
1217
|
+
imported by packages that must not load the whole identity module.
|
|
1218
|
+
|
|
1153
1219
|
### Passkey sign-in
|
|
1154
1220
|
|
|
1155
1221
|
`PasskeyCredentialService` (#3275) gives an app passkey (WebAuthn) sign-in for
|
package/dist/chunks/{PasswordCredentialService-AL5GT_UL.js → PasswordCredentialService-D_evcc-I.js}
RENAMED
|
@@ -246,6 +246,7 @@ var __decorateClass$11 = (decorators, target, key, kind) => {
|
|
|
246
246
|
return result;
|
|
247
247
|
};
|
|
248
248
|
var __publicField$11 = (obj, key, value) => __defNormalProp$11(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
249
|
+
var STEP_UP_SIGN_IN_AUTH_METHODS = Object.freeze(["password", "passkey"]);
|
|
249
250
|
var DEFAULT_SESSION_TTL = 10080 * 60;
|
|
250
251
|
var SESSION_DATA_KEYS = {
|
|
251
252
|
/** `string[]` of permission slugs the session's resolved set is intersected with. */
|
|
@@ -273,6 +274,25 @@ var SESSION_DATA_KEYS = {
|
|
|
273
274
|
*/
|
|
274
275
|
authenticatedAt: "authenticatedAt",
|
|
275
276
|
/**
|
|
277
|
+
* ISO timestamp of the last step-up: a fresh password check made on this
|
|
278
|
+
* already-signed-in session (#4841). Written only by
|
|
279
|
+
* `SessionCollection.markReauthenticated` after the credential was verified;
|
|
280
|
+
* never from client input (`setSessionData` refuses it), never moved by
|
|
281
|
+
* `extend()`/activity, carried forward unchanged by tenant-switch rotation
|
|
282
|
+
* and gone with the session. See {@link Session.getReauthenticatedAt}.
|
|
283
|
+
*/
|
|
284
|
+
reauthenticatedAt: "reauthenticatedAt",
|
|
285
|
+
/**
|
|
286
|
+
* The pending OIDC step-up intent of this session: the authorization
|
|
287
|
+
* transaction (state, nonce, PKCE verifier) of a re-authentication the
|
|
288
|
+
* session itself started, with its expiry. Written only by
|
|
289
|
+
* `SessionCollection.recordStepUpIntent`, consumed (removed) by
|
|
290
|
+
* `SessionCollection.takeStepUpIntent` on the callback, so it is single use
|
|
291
|
+
* and dies with the session. Never from client input (`setSessionData`
|
|
292
|
+
* refuses it).
|
|
293
|
+
*/
|
|
294
|
+
oidcStepUpIntent: "oidcStepUpIntent",
|
|
295
|
+
/**
|
|
276
296
|
* Row id of the passkey (`users_passkey_credentials`) a session was signed
|
|
277
297
|
* in with. Set only by `PasskeyCredentialService` at mint; it decides which
|
|
278
298
|
* session a passkey removal ends. Never from client input, and
|
|
@@ -319,6 +339,14 @@ var Session = class extends SmrtObject {
|
|
|
319
339
|
return this.parentSessionId !== null && this.parentSessionId !== "";
|
|
320
340
|
}
|
|
321
341
|
/**
|
|
342
|
+
* Whether this session may step up (#4841) at all: a first-class session,
|
|
343
|
+
* not a layered or PIN one, with no permission ceiling. Every step-up method
|
|
344
|
+
* (password, OIDC, magic link) requires it.
|
|
345
|
+
*/
|
|
346
|
+
isStepUpEligible() {
|
|
347
|
+
return !this.isLayered() && this.authMethod !== "pin" && this.getPermissionCeiling() === null;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
322
350
|
* Absolute expiry cap (`data.absoluteExpiresAt`), or null when the session
|
|
323
351
|
* has none. An unreadable value fails closed as "already passed".
|
|
324
352
|
*/
|
|
@@ -354,6 +382,27 @@ var Session = class extends SmrtObject {
|
|
|
354
382
|
return created instanceof Date && !Number.isNaN(created.getTime()) ? created : null;
|
|
355
383
|
}
|
|
356
384
|
/**
|
|
385
|
+
* When the person last proved a credential on this session (#4841): the
|
|
386
|
+
* newer of the step-up stamp (`data.reauthenticatedAt`) and the sign-in time
|
|
387
|
+
* ({@link Session.getAuthenticatedAt}), the latter counting only for an
|
|
388
|
+
* interactive sign-in method in {@link STEP_UP_SIGN_IN_AUTH_METHODS}. A
|
|
389
|
+
* `terminal`, `pin`, `mobile` or host-defined session proves nothing about
|
|
390
|
+
* the person at mint. A present but malformed step-up stamp returns null
|
|
391
|
+
* (fail closed, even if the sign-in time is fresh).
|
|
392
|
+
*/
|
|
393
|
+
getReauthenticatedAt() {
|
|
394
|
+
const raw = this.data?.[SESSION_DATA_KEYS.reauthenticatedAt];
|
|
395
|
+
let stepUp = null;
|
|
396
|
+
if (raw !== void 0 && raw !== null) {
|
|
397
|
+
const at = typeof raw === "string" ? new Date(raw) : null;
|
|
398
|
+
if (!at || Number.isNaN(at.getTime())) return null;
|
|
399
|
+
stepUp = at;
|
|
400
|
+
}
|
|
401
|
+
const signIn = typeof this.authMethod === "string" && STEP_UP_SIGN_IN_AUTH_METHODS.includes(this.authMethod) ? this.getAuthenticatedAt() : null;
|
|
402
|
+
if (stepUp && signIn) return stepUp > signIn ? stepUp : signIn;
|
|
403
|
+
return stepUp ?? signIn;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
357
406
|
* Permission ceiling (`data.permissionCeiling`), or null when the session
|
|
358
407
|
* has none. A present but malformed value fails closed as an empty ceiling.
|
|
359
408
|
*/
|
|
@@ -815,10 +864,69 @@ var SessionCollection = class extends SmrtCollection {
|
|
|
815
864
|
return true;
|
|
816
865
|
}
|
|
817
866
|
/**
|
|
867
|
+
* Record a step-up (#4841): stamp `data.reauthenticatedAt` on a live session.
|
|
868
|
+
* Call ONLY after the person's credential was verified on the server; this
|
|
869
|
+
* method proves nothing itself. Returns the stamp, or null when the session
|
|
870
|
+
* is unknown, not active, expired, or not `userId`'s (when given). Only the
|
|
871
|
+
* stamp moves: expiry, activity and every other `data` key are untouched,
|
|
872
|
+
* so ordinary use or refresh can never extend it.
|
|
873
|
+
*/
|
|
874
|
+
async markReauthenticated(sessionId, options = {}) {
|
|
875
|
+
const at = options.at ?? /* @__PURE__ */ new Date();
|
|
876
|
+
for (let attempt = 0; attempt < 4; attempt += 1) {
|
|
877
|
+
const session = await this.findValidSession(sessionId);
|
|
878
|
+
if (!session) return null;
|
|
879
|
+
if (options.userId !== void 0 && session.userId !== options.userId) return null;
|
|
880
|
+
session.setData(SESSION_DATA_KEYS.reauthenticatedAt, at.toISOString());
|
|
881
|
+
try {
|
|
882
|
+
await session.save();
|
|
883
|
+
return at;
|
|
884
|
+
} catch (error) {
|
|
885
|
+
if (attempt === 3 || !(error instanceof Error && "code" in error && error.code === "RUNTIME_REVISION_CONFLICT")) throw error;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
return null;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Record the OIDC step-up intent of a live session (#4841): the transaction
|
|
892
|
+
* a re-authentication the session itself started must come back with. Only
|
|
893
|
+
* one intent is pending per session; a new one replaces the old. Returns
|
|
894
|
+
* false when the session is unknown, not live, or not `userId`'s.
|
|
895
|
+
*/
|
|
896
|
+
async recordStepUpIntent(sessionId, intent, options = {}) {
|
|
897
|
+
const session = await this.findValidSession(sessionId);
|
|
898
|
+
if (!session) return false;
|
|
899
|
+
if (options.userId !== void 0 && session.userId !== options.userId) return false;
|
|
900
|
+
session.setData(SESSION_DATA_KEYS.oidcStepUpIntent, intent);
|
|
901
|
+
await session.save();
|
|
902
|
+
return true;
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Take (read and remove) the pending OIDC step-up intent, so it can be used
|
|
906
|
+
* once. Returns null when there is none, the session is not live or not
|
|
907
|
+
* `userId`'s, or the removal lost a write race (the other writer holds the
|
|
908
|
+
* intent). Never retries: a contested intent is a refused one.
|
|
909
|
+
*/
|
|
910
|
+
async takeStepUpIntent(sessionId, options = {}) {
|
|
911
|
+
const session = await this.findValidSession(sessionId);
|
|
912
|
+
if (!session) return null;
|
|
913
|
+
if (options.userId !== void 0 && session.userId !== options.userId) return null;
|
|
914
|
+
const raw = session.data?.[SESSION_DATA_KEYS.oidcStepUpIntent];
|
|
915
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
916
|
+
session.removeData(SESSION_DATA_KEYS.oidcStepUpIntent);
|
|
917
|
+
try {
|
|
918
|
+
await session.save();
|
|
919
|
+
} catch (error) {
|
|
920
|
+
if (error instanceof Error && "code" in error && error.code === "RUNTIME_REVISION_CONFLICT") return null;
|
|
921
|
+
throw error;
|
|
922
|
+
}
|
|
923
|
+
return raw;
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
818
926
|
* Set custom session data
|
|
819
927
|
*/
|
|
820
928
|
async setSessionData(sessionId, key, value) {
|
|
821
|
-
if (key === SESSION_DATA_KEYS.authenticatedAt || key === SESSION_DATA_KEYS.passkeyCredentialId) return false;
|
|
929
|
+
if (key === SESSION_DATA_KEYS.authenticatedAt || key === SESSION_DATA_KEYS.reauthenticatedAt || key === SESSION_DATA_KEYS.oidcStepUpIntent || key === SESSION_DATA_KEYS.passkeyCredentialId) return false;
|
|
822
930
|
const session = await this.findValidSession(sessionId);
|
|
823
931
|
if (!session) return false;
|
|
824
932
|
session.setData(key, value);
|
|
@@ -5301,6 +5409,10 @@ var PermissionResolver = class PermissionResolver {
|
|
|
5301
5409
|
};
|
|
5302
5410
|
//#endregion
|
|
5303
5411
|
//#region src/services/SessionService.ts
|
|
5412
|
+
function withoutStepUpIntent(data) {
|
|
5413
|
+
const { [SESSION_DATA_KEYS.oidcStepUpIntent]: _intent, ...rest } = data ?? {};
|
|
5414
|
+
return rest;
|
|
5415
|
+
}
|
|
5304
5416
|
var SessionService = class SessionService {
|
|
5305
5417
|
options;
|
|
5306
5418
|
sessionCollection;
|
|
@@ -5402,7 +5514,8 @@ var SessionService = class SessionService {
|
|
|
5402
5514
|
sessionId: session.id,
|
|
5403
5515
|
authMethod: session.authMethod,
|
|
5404
5516
|
parent,
|
|
5405
|
-
permissionCeiling
|
|
5517
|
+
permissionCeiling,
|
|
5518
|
+
reauthenticatedAt: current.getReauthenticatedAt()
|
|
5406
5519
|
};
|
|
5407
5520
|
}
|
|
5408
5521
|
return null;
|
|
@@ -5526,7 +5639,7 @@ var SessionService = class SessionService {
|
|
|
5526
5639
|
userAgent: session.userAgent,
|
|
5527
5640
|
ipAddress: session.ipAddress,
|
|
5528
5641
|
data: {
|
|
5529
|
-
...session.data,
|
|
5642
|
+
...withoutStepUpIntent(session.data),
|
|
5530
5643
|
[SESSION_DATA_KEYS.authenticatedAt]: session.data?.[SESSION_DATA_KEYS.authenticatedAt] ?? (session.created_at instanceof Date ? session.created_at.toISOString() : (/* @__PURE__ */ new Date(0)).toISOString())
|
|
5531
5644
|
},
|
|
5532
5645
|
authMethod: session.authMethod,
|
|
@@ -5849,6 +5962,31 @@ var PasswordCredentialService = class PasswordCredentialService {
|
|
|
5849
5962
|
}
|
|
5850
5963
|
}
|
|
5851
5964
|
/**
|
|
5965
|
+
* Re-verify the signed-in person's password on their CURRENT session and
|
|
5966
|
+
* stamp `data.reauthenticatedAt` (#4841), which
|
|
5967
|
+
* `requireRecentAuthentication` then reads. Goes through the same limiter
|
|
5968
|
+
* and constant-work verification as sign-in and self-service changes, so it
|
|
5969
|
+
* is no oracle outside the sign-in budget. A layered/PIN session or one with
|
|
5970
|
+
* a permission ceiling never steps up. Every refusal (no or dead session,
|
|
5971
|
+
* wrong password, none set) is one {@link PasswordCredentialError}. The
|
|
5972
|
+
* stamp is not client input and ordinary session use never moves it.
|
|
5973
|
+
*/
|
|
5974
|
+
async stepUp(input) {
|
|
5975
|
+
const sessionId = typeof input.sessionId === "string" ? input.sessionId.trim() : "";
|
|
5976
|
+
if (!sessionId) throw new PasswordCredentialError();
|
|
5977
|
+
const session = await this.sessionRows.findValidSession(sessionId);
|
|
5978
|
+
if (!session?.isStepUpEligible()) throw new PasswordCredentialError();
|
|
5979
|
+
const user = await this.users.get(session.userId);
|
|
5980
|
+
if (!user?.id || !user.isActive()) throw new PasswordCredentialError();
|
|
5981
|
+
await this.verifyCurrent(user, input.password, input.ipAddress, "step-up");
|
|
5982
|
+
const at = await this.sessionRows.markReauthenticated(sessionId, { userId: user.id });
|
|
5983
|
+
if (!at) throw new PasswordCredentialError();
|
|
5984
|
+
return {
|
|
5985
|
+
sessionId,
|
|
5986
|
+
reauthenticatedAt: at.toISOString()
|
|
5987
|
+
};
|
|
5988
|
+
}
|
|
5989
|
+
/**
|
|
5852
5990
|
* Set a password where the person has none: the person themself from any
|
|
5853
5991
|
* first-class session, or an administrator holding `managePermission` for
|
|
5854
5992
|
* someone else (which, if a password already exists, replaces it and ends
|
|
@@ -6181,6 +6319,6 @@ var PasswordCredentialService = class PasswordCredentialService {
|
|
|
6181
6319
|
}
|
|
6182
6320
|
};
|
|
6183
6321
|
//#endregion
|
|
6184
|
-
export { PermissionCatalogService as $, InvalidCredentialsError as A,
|
|
6322
|
+
export { PermissionCatalogService as $, InvalidCredentialsError as A, STEP_UP_SIGN_IN_AUTH_METHODS as At, backfillUserEmailKeys as B, DEFAULT_LOGIN_ATTEMPT_WINDOW_SECONDS as C, SessionCollection as Ct, DEFAULT_LOGIN_MAX_ATTEMPTS as D, normalizeUsername as Dt, DEFAULT_LOGIN_LOCKOUT_MAX_SECONDS as E, normalizeEmail as Et, OidcProvisioningError as F, Membership as Ft, MAX_TENANT_HIERARCHY_DEPTH as G, TenantPermissionOverride as H, UserCollection as I, __exportAll as It, assertTenantTableName as J, TenantHierarchyError as K, requireExistingOwnedPerson as L, LoginRateLimitError as M, generateSessionId as Mt, hashSecret as N, Role as Nt, DEFAULT_SOURCE_LOCKOUT_AUDIT_SECONDS as O, DEFAULT_SESSION_TTL as Ot, verifySecretHash as P, Permission as Pt, RolePermissionCollection as Q, USER_EMAIL_KEY_BACKFILL_NAME as R, normalizeAncestorReadPolicy as S, UsersLoginAttempt as St, DEFAULT_LOGIN_LOCKOUT_FACTOR as T, isValidEmail as Tt, TenantCollection as U, TenantPermissionOverrideCollection as V, Tenant as W, recordTenantHierarchyChanges as X, planTenantHierarchy as Y, DEFAULT_ROLE_PERMISSION_PATTERNS as Z, PermissionResolver as _, GroupCollection as _t, DEFAULT_PASSWORD_RECOVERY_MAX_AGE_SECONDS as a, RolePermission as at, getConfiguredAncestorReadPolicy as b, UsersLoginAuditEvent as bt, PASSWORD_PERMISSION_DEFINITIONS as c, UsersPasswordCredentialCollection as ct, PasswordCredentialForbiddenError as d, MembershipOverride as dt, deriveOperationPermissionCollectionName as et, PasswordCredentialService as f, MembershipCollection as ft, SessionService as g, GroupMember as gt, outOfBandProofSessionData as h, GroupMemberCollection as ht, DEFAULT_PASSWORD_MIN_LENGTH as i, withoutListBounds as it, LoginAttemptLimiter as j, Session as jt, DurableLoginAuditSink as k, SESSION_DATA_KEYS as kt, PASSWORD_RECOVERY_MAX_AGE_CEILING_SECONDS as l, UsersPasswordCredential as lt, ensurePasswordPermissionsRegistered as m, GroupRole as mt, DEFAULT_PASSWORD_MANAGE_PERMISSION as n, normalizeOperationPermissionAction as nt, PASSWORD_LOGIN_KIND as o, RoleCollection as ot, PasswordPolicyError as p, GroupRoleCollection as pt, applyTenantHierarchyUpdates as q, DEFAULT_PASSWORD_MAX_LENGTH as r, syncPermissionCatalog as rt, PASSWORD_MAX_LENGTH_CEILING as s, PermissionCollection as st, DEFAULT_PASSWORD_DENYLIST as t, deriveOperationPermissionSlug as tt, PasswordCredentialError as u, MembershipOverrideCollection as ut, ANCESTOR_READ_ACTION as v, Group as vt, DEFAULT_LOGIN_LOCKOUT_BASE_SECONDS as w, User as wt, isAncestorReadableSlug as x, UsersLoginAttemptCollection as xt, DEFAULT_ANCESTOR_READ_MAX_DEPTH as y, UsersLoginAuditEventCollection as yt, UserEmailKeyBackfillError as z };
|
|
6185
6323
|
|
|
6186
|
-
//# sourceMappingURL=PasswordCredentialService-
|
|
6324
|
+
//# sourceMappingURL=PasswordCredentialService-D_evcc-I.js.map
|