@aooth/auth-moost 0.2.1 → 0.2.3

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/index.d.mts CHANGED
@@ -1,15 +1,14 @@
1
1
  import { Mate, TConsoleBase, TInterceptorDef, TMateParamMeta, TMoostMetadata } from "moost";
2
2
  import { AuthContext, AuthContext as AuthContext$1, AuthCredential, AuthEmailEvent, AuthEmailKind, AuthEmailKind as AuthEmailKind$1, AuthSmsEvent, AuthSmsKind, BuildMagicLinkUrl, BuildMagicLinkUrl as BuildMagicLinkUrl$1, CredentialMetadata, EmailSender, EmailSender as EmailSender$1, EnrichedSession, EnrichedSession as EnrichedSession$1, IssueResult, IssueResult as IssueResult$1, RateLimitDecision, RateLimitDecision as RateLimitDecision$1, RateLimitRule, RateLimitRule as RateLimitRule$1, RateLimitRuleInput, RateLimitRuleInput as RateLimitRuleInput$1, RateLimitStore, RateLimitStore as RateLimitStore$1, RateLimitStoreMemory, RateLimiter, RateLimiter as RateLimiter$1, RateLimiterOptions, SessionEnricher, SessionEnricher as SessionEnricher$1, SessionInfo, SessionInfo as SessionInfo$1, SmsSender, generateMagicLinkToken } from "@aooth/auth";
3
3
  import { EventContext } from "@wooksjs/event-core";
4
- import { TCookieAttributesInput } from "@wooksjs/event-http";
5
- import { FederatedIdentityStore, FederatedProfileSnapshot, MfaMethod, TransferablePolicy, TrustedDeviceRecord, UserCredentials, UserService } from "@aooth/user";
4
+ import { HttpError, TCookieAttributesInput } from "@wooksjs/event-http";
5
+ import { FederatedIdentityStore, FederatedProfileSnapshot, MfaMethod, TransferablePolicy, TrustedDeviceRecord, UserAuthError, UserAuthErrorType, UserCredentials, UserService } from "@aooth/user";
6
6
  import { HttpError as HttpError$1 } from "@moostjs/event-http";
7
7
  import { FinishWfOpts, WfFinished, useAtscriptWf } from "@atscript/moost-wf";
8
- import { MoostWf, WfOutlet, WfOutletTokenConfig, WfStateStrategy } from "@moostjs/event-wf";
8
+ import { MoostWf, WfOutlet, WfOutletTokenConfig, WfOutletTriggerConfig, WfStateStrategy } from "@moostjs/event-wf";
9
9
  import { FederatedLoginService, NormalizedProfile, OAuthProviderRegistry } from "@aooth/idp";
10
10
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
11
11
  import { AuthCodeStore, AuthorizationServerMetadata, AuthorizationServerMetadata as AuthorizationServerMetadata$1, BuildAuthorizationServerMetadataOptions, BuildProtectedResourceMetadataOptions, ClientRedirectPolicy, DynamicClientRegistration, DynamicClientRegistration as DynamicClientRegistration$1, DynamicClientRegistrationOptions, IdTokenSigner, OidcClaimsResolver, PendingAuthorizationStore, ProtectedResourceMetadata, WwwAuthenticateBearerChallengeOptions, buildAuthorizationServerMetadata, buildProtectedResourceMetadata, buildWwwAuthenticateBearerChallenge, canonicalizeIssuer } from "@aooth/auth/authz";
12
- //#region src/auth.config.d.ts
13
12
  /** Resolved cookie attributes. Same shape is used for both access + refresh. */
14
13
  interface ResolvedAuthCookieConfig {
15
14
  name: string;
@@ -67,8 +66,6 @@ interface ResolvedAuthOptions {
67
66
  enableBearer: boolean;
68
67
  exposeTokensInBody: boolean;
69
68
  }
70
- //#endregion
71
- //#region src/consent.store.d.ts
72
69
  /**
73
70
  * Consent event emitted to the `ConsentStore.save(username, events)` DI
74
71
  * provider. Storage shape is intentionally the consumer's call — Mongo users
@@ -133,7 +130,7 @@ interface ConsentDescriptor {
133
130
  * no-op defaults — customers extend this class and replace via
134
131
  * `createReplaceRegistry([ConsentStore, MyConsentStore])`.
135
132
  */
136
- declare class ConsentStore {
133
+ export declare class ConsentStore {
137
134
  /**
138
135
  * Returns descriptors for general-purpose consents this user still needs to
139
136
  * accept on the next prompt boundary — terms / privacy / marketing / age /
@@ -170,8 +167,6 @@ declare class ConsentStore {
170
167
  */
171
168
  recordOtpChannelConsent(_username: string, _channel: "email" | "sms", _target: string, _disclosure: string): Promise<void>;
172
169
  }
173
- //#endregion
174
- //#region src/auth.guard.d.ts
175
170
  /**
176
171
  * `GUARD`-priority interceptor factory that authenticates incoming requests.
177
172
  *
@@ -193,15 +188,13 @@ declare class ConsentStore {
193
188
  * an admin-only invite endpoint protects its outlet HTTP route, not the
194
189
  * step handler).
195
190
  */
196
- declare function authGuardInterceptor(opts?: AuthOptions): TInterceptorDef;
191
+ export declare function authGuardInterceptor(opts?: AuthOptions): TInterceptorDef;
197
192
  /**
198
193
  * Decorator-factory sugar for attaching `authGuardInterceptor(opts)` to a
199
194
  * specific controller or method instead of globally. Equivalent to
200
195
  * `@Intercept(authGuardInterceptor(opts))`.
201
196
  */
202
- declare function AuthGuarded(opts?: AuthOptions): ClassDecorator & MethodDecorator;
203
- //#endregion
204
- //#region ../../node_modules/.pnpm/@wooksjs+event-wf@0.8.0_@prostojs+logger@0.4.3_@prostojs+router@0.3.6_@wooksjs+event-co_86044e452e9fcfb26549e7ecde073940/node_modules/@wooksjs/event-wf/dist/index.d.ts
197
+ export declare function AuthGuarded(opts?: AuthOptions): ClassDecorator & MethodDecorator;
205
198
  interface WfFinishedResponse {
206
199
  type: 'redirect' | 'data';
207
200
  /** Redirect URL or response body */
@@ -214,8 +207,6 @@ interface WfFinishedResponse {
214
207
  options?: Record<string, unknown>;
215
208
  }>;
216
209
  }
217
- //#endregion
218
- //#region src/auth.dto.d.ts
219
210
  /** POST /auth/refresh request body. Falls back to the refresh cookie when absent. */
220
211
  interface AuthRefreshBody {
221
212
  refreshToken?: string;
@@ -249,8 +240,6 @@ interface AuthLoginResponse {
249
240
  interface AuthOkResponse {
250
241
  ok: true;
251
242
  }
252
- //#endregion
253
- //#region src/auth.composables.d.ts
254
243
  interface AuthBindings {
255
244
  getAuthContext<TPayload extends object = Record<string, unknown>>(): AuthContext$1<TPayload> | null;
256
245
  /** @throws `HttpError(401)` if no `AuthContext` is present in the event. */
@@ -306,9 +295,7 @@ interface AuthBindings {
306
295
  * `HttpError(500)` loudly — that's a configuration error, not a runtime
307
296
  * fallback case.
308
297
  */
309
- declare const useAuth: import("@wooksjs/event-core").WookComposable<AuthBindings>;
310
- //#endregion
311
- //#region src/auth.decorator.d.ts
298
+ export declare const useAuth: import("@wooksjs/event-core").WookComposable<AuthBindings>;
312
299
  /**
313
300
  * Marks a route or controller as fully public — opts out of BOTH
314
301
  * authentication (auth-moost's bearer guard) AND authorization
@@ -321,7 +308,7 @@ declare const useAuth: import("@wooksjs/event-core").WookComposable<AuthBindings
321
308
  *
322
309
  * Method-level decoration overrides class-level.
323
310
  */
324
- declare const Public: () => ClassDecorator & MethodDecorator;
311
+ export declare const Public: () => ClassDecorator & MethodDecorator;
325
312
  /**
326
313
  * Resolves the authenticated user's id (string) for a handler parameter.
327
314
  *
@@ -330,9 +317,7 @@ declare const Public: () => ClassDecorator & MethodDecorator;
330
317
  * `AuthContext` is credential context, not user profile data, and this library
331
318
  * does not own a user profile type.
332
319
  */
333
- declare const UserId: () => ParameterDecorator & PropertyDecorator;
334
- //#endregion
335
- //#region src/auth.mate.d.ts
320
+ export declare const UserId: () => ParameterDecorator & PropertyDecorator;
336
321
  /**
337
322
  * Auth metadata fields written by `@Public()` and read by `authGuardInterceptor`.
338
323
  * Merged into `TMoostMetadata` so other moost-aware tooling sees them.
@@ -348,9 +333,7 @@ type AuthMate = Mate<TMoostMetadata & {
348
333
  }, TMoostMetadata & {
349
334
  params: TMateParamMeta[];
350
335
  }>;
351
- declare function getAuthMate(): AuthMate;
352
- //#endregion
353
- //#region src/workflow/auth-messages.d.ts
336
+ export declare function getAuthMate(): AuthMate;
354
337
  /**
355
338
  * Code-keyed catalogue of every user-facing text `AuthWorkflow` produces —
356
339
  * form errors, banners, finish envelopes and button labels. Templates are
@@ -360,7 +343,7 @@ declare function getAuthMate(): AuthMate;
360
343
  * function that receives the code and params and returns the text — e.g. a
361
344
  * lookup in your own i18n library), or override `AuthWorkflow.msg()`.
362
345
  */
363
- declare const AOOTH_MESSAGES: {
346
+ export declare const AOOTH_MESSAGES: {
364
347
  readonly INVALID_CREDENTIALS: "Invalid credentials";
365
348
  readonly ACCOUNT_LOCKED: "Account locked, please try again later";
366
349
  readonly INVALID_PASSWORD: "Invalid password";
@@ -421,26 +404,24 @@ type AoothMessageParams = Readonly<Record<string, string | number>>;
421
404
  */
422
405
  type AoothMessages = Partial<Record<AoothMessageCode, string>> | ((code: AoothMessageCode, params: AoothMessageParams) => string | undefined);
423
406
  /** Fill `{name}` placeholders from `params`; unknown placeholders are kept. */
424
- declare function renderAoothMessage(template: string, params?: AoothMessageParams): string;
407
+ export declare function renderAoothMessage(template: string, params?: AoothMessageParams): string;
425
408
  /** Resolve `code` through `messages` (when given), falling back to the English template. */
426
- declare function resolveAoothMessage(code: AoothMessageCode, params?: AoothMessageParams, messages?: AoothMessages): string;
427
- //#endregion
428
- //#region src/auth.controller.d.ts
409
+ export declare function resolveAoothMessage(code: AoothMessageCode, params?: AoothMessageParams, messages?: AoothMessages): string;
429
410
  /** Workflows allowed by the bundled `/auth/trigger` endpoint. Subclasses override `triggerWf()` to extend. */
430
- declare const DEFAULT_AUTH_WORKFLOWS: readonly ["auth/login/flow", "auth/invite/start", "auth/recovery/flow", "auth/signup/flow"];
411
+ export declare const DEFAULT_AUTH_WORKFLOWS: readonly ["auth/login/flow", "auth/invite/start", "auth/recovery/flow", "auth/signup/flow"];
431
412
  /**
432
413
  * Workflow id allowed by the GUARDED `/auth/change-password` trigger.
433
414
  * Deliberately NOT in `DEFAULT_AUTH_WORKFLOWS` — the authenticated
434
415
  * change-password flow must never be reachable from the public `/auth/trigger`.
435
416
  */
436
- declare const CHANGE_PASSWORD_WORKFLOW = "auth/change-password/flow";
417
+ export declare const CHANGE_PASSWORD_WORKFLOW = "auth/change-password/flow";
437
418
  /**
438
419
  * Workflow id allowed by the GUARDED `/auth/add-mfa` trigger — the authenticated
439
420
  * "add a second factor" flow. Like {@link CHANGE_PASSWORD_WORKFLOW}, deliberately
440
421
  * NOT in `DEFAULT_AUTH_WORKFLOWS`: it must never be reachable from the public
441
422
  * `/auth/trigger`.
442
423
  */
443
- declare const ADD_MFA_WORKFLOW = "auth/add-mfa/flow";
424
+ export declare const ADD_MFA_WORKFLOW = "auth/add-mfa/flow";
444
425
  /**
445
426
  * Public REST endpoints for credential management. Four endpoints total:
446
427
  *
@@ -458,7 +439,7 @@ declare const ADD_MFA_WORKFLOW = "auth/add-mfa/flow";
458
439
  * allow-list (override `triggerWf()` with a different `@WfTrigger({ allow })`)
459
440
  * or to inject custom outlets / state stores by subclassing `WfTriggerProvider`.
460
441
  */
461
- declare class AuthController {
442
+ export declare class AuthController {
462
443
  protected readonly auth: AuthCredential;
463
444
  protected readonly users?: UserService | undefined;
464
445
  constructor(auth: AuthCredential, users?: UserService | undefined);
@@ -540,8 +521,6 @@ declare class AuthController {
540
521
  messages?: AoothMessages;
541
522
  };
542
523
  }
543
- //#endregion
544
- //#region src/sessions.controller.d.ts
545
524
  /**
546
525
  * Injectable read-time session enricher. Default is identity — aooth ships NO
547
526
  * UA-parser or GeoIP dependency. Consumers who want `device` / `browser` / `os`
@@ -561,7 +540,7 @@ declare class AuthController {
561
540
  *
562
541
  * Singleton scope is required — `@Injectable()` (no scope arg) → SINGLETON.
563
542
  */
564
- declare class SessionEnricherProvider {
543
+ export declare class SessionEnricherProvider {
565
544
  enrich(session: SessionInfo$1): EnrichedSession$1 | Promise<EnrichedSession$1>;
566
545
  }
567
546
  /**
@@ -587,7 +566,7 @@ declare class SessionEnricherProvider {
587
566
  * NOT `@Public()` — the auth guard rejects unauthenticated callers with 401 and
588
567
  * ARBAC gates each action; a customer enables it with `allow("auth.sessions", "*")`.
589
568
  */
590
- declare class SessionsController {
569
+ export declare class SessionsController {
591
570
  protected readonly auth: AuthCredential;
592
571
  protected readonly enricher: SessionEnricherProvider;
593
572
  constructor(auth: AuthCredential, enricher: SessionEnricherProvider);
@@ -611,9 +590,85 @@ declare class SessionsController {
611
590
  revoked: number;
612
591
  }>;
613
592
  }
614
- //#endregion
615
- //#region src/wf-trigger/decorator.d.ts
616
- interface WfTriggerOpts {
593
+ /** The body of an `HttpError` made by {@link userAuthErrorToHttp}. */
594
+ interface UserAuthErrorBody {
595
+ message: string;
596
+ /** The `UserAuthError` type (`"PASSWORD_IN_HISTORY"`, `"NOT_FOUND"`, …). */
597
+ code: UserAuthErrorType;
598
+ /** `POLICY_VIOLATION`: `{ policies: [{ description, passed }] }` — every policy and its result. */
599
+ params?: Record<string, unknown>;
600
+ /** The form field the error belongs to (password errors only). */
601
+ field?: "currentPassword" | "newPassword" | "confirmPassword";
602
+ }
603
+ /**
604
+ * Map a `UserAuthError` (thrown by `UserService`) to an `HttpError` whose body
605
+ * carries `code` (the error type), the message and — for password errors —
606
+ * the form `field` it belongs to (named as in the bundled password forms):
607
+ *
608
+ * | type | status | field |
609
+ * |---|---|---|
610
+ * | `NOT_FOUND` | 404 | |
611
+ * | `ALREADY_EXISTS`, `CAS_EXHAUSTED` | 409 | |
612
+ * | `INVALID_CREDENTIALS` | 400 | `currentPassword` |
613
+ * | `PASSWORD_IN_HISTORY` | 400 | `newPassword` |
614
+ * | `POLICY_VIOLATION` (+ `params.policies`) | 422 | `newPassword` |
615
+ * | `PASSWORDS_MISMATCH` | 400 | `confirmPassword` |
616
+ * | `MFA_INVALID`, `MFA_NOT_CONFIGURED` | 400 | |
617
+ * | `INACTIVE`, `LOCKED`, `MFA_REQUIRED` | 403 | |
618
+ *
619
+ * For routes such as an admin "set password" endpoint. Do not use it on a
620
+ * sign-in endpoint: distinct answers for unknown, inactive and locked accounts
621
+ * let a caller enumerate accounts (the bundled login workflow answers them
622
+ * uniformly).
623
+ */
624
+ export declare function userAuthErrorToHttp(err: UserAuthError): HttpError<UserAuthErrorBody>;
625
+ /**
626
+ * Error interceptor answering every `UserAuthError` a handler throws with
627
+ * {@link userAuthErrorToHttp}; other errors pass through. Attach it per
628
+ * controller (or per handler) where `UserService` errors should become 4xx
629
+ * instead of 500 — typically admin and self-service routes:
630
+ *
631
+ * ```ts
632
+ * @Controller("admin/users")
633
+ * @Intercept(userAuthErrorInterceptor)
634
+ * export class AdminUsersController {}
635
+ * ```
636
+ *
637
+ * Don't install it globally: a custom sign-in or recovery handler calling
638
+ * `login()` / `verifyMfa()` would then answer unknown, inactive and locked
639
+ * accounts with distinct 404 / 403 codes — account enumeration, defeating
640
+ * `lockoutDisclosure: 'uniform'`.
641
+ */
642
+ export declare const userAuthErrorInterceptor: TInterceptorDef;
643
+ declare const HOOK_NAMES: readonly ["around", "beforePersist", "renderEnvelope", "restoreOnError", "maxRestores"];
644
+ /**
645
+ * Workflow-trigger hooks passed through to the wooks trigger
646
+ * (`handleWfOutletRequest`). Set them app-wide by overriding
647
+ * {@link WfTriggerProvider.triggerHooks}, or per route on `@WfTrigger(...)`
648
+ * (a route's hook replaces the provider's hook of the same name).
649
+ *
650
+ * - `around(run)` — wraps everything the request does to workflow state and
651
+ * the outside world (allow checks, consume/start/resume, `beforePersist`,
652
+ * persist, outlet delivery), e.g. `(run) => db.transaction(run)`. It may
653
+ * call `run()` again after a failure; each run starts over from the request.
654
+ * - `beforePersist(state, pause)` — runs right before a paused state is
655
+ * persisted, inside `around`; throw to abort (nothing persisted, no delivery).
656
+ * - `renderEnvelope(envelope, info)` — maps every body the trigger answers
657
+ * with (paused envelopes and finished values), e.g. to translate texts.
658
+ * - `restoreOnError` — opt-in (default off): when a resume fails after its
659
+ * token was consumed, put the pre-step state back under the same token so
660
+ * the link can be retried (at most `maxRestores` times, default 3, never
661
+ * extending its lifetime). Needs a durable strategy that reports expiries
662
+ * (`HandleStateStrategy`); it rolls back everything the step wrote to the
663
+ * workflow context. Leave it off for steps with side effects that must not
664
+ * run twice. Set provider-wide, it also covers the bundled credential steps
665
+ * (set password, recovery reset, MFA enrolment) — prefer enabling it per
666
+ * route, or a predicate that accepts only transient store errors. The
667
+ * bundled password forms refuse a restored state once the password changed.
668
+ */
669
+ type WfTriggerHooks = Pick<WfOutletTriggerConfig, (typeof HOOK_NAMES)[number]>;
670
+ /** Per-request options of {@link WfTriggerProvider.handle} (what `@WfTrigger(...)` passes). */
671
+ interface WfTriggerOpts extends WfTriggerHooks {
617
672
  /**
618
673
  * Workflow ids this trigger may START and RESUME (a leading `/` is ignored).
619
674
  * Omitted = unrestricted; `[]` = deny every workflow. A state token minted
@@ -623,21 +678,35 @@ interface WfTriggerOpts {
623
678
  /** Per-endpoint token wire override. Defaults to the provider's wire (`{read:['body','query','cookie'], write:'body', name:'wfs'}`). */
624
679
  token?: WfOutletTokenConfig;
625
680
  }
681
+ /** Named state-strategy registry: the shape `handleAsOutletRequest` reads off `state`. */
682
+ type StateRegistry = {
683
+ strategies: Record<string, WfStateStrategy>;
684
+ default: string;
685
+ };
626
686
  /**
627
- * Method decorator that turns a handler into a workflow trigger.
687
+ * Derive the exact 32-byte key the encapsulated wf-state strategy requires from
688
+ * an arbitrary-length app secret.
628
689
  *
629
- * The handler may have an empty body — the interceptor's after-phase invokes
630
- * `WfTriggerProvider.handle()` when the handler returns `undefined`. Subclasses
631
- * that need to short-circuit (e.g. emit a custom error response) just return a
632
- * non-undefined value from the overridden handler and the trigger is skipped.
690
+ * The default {@link WfTriggerProvider.wfStateSecret} reuses the auth secret via
691
+ * `AuthCredential.deriveStateKey()`, which only works for stores backed by a
692
+ * symmetric secret (JWT / encapsulated). A stateful store (e.g. atscript-db —
693
+ * the recommended default once you adopt the session-listing APIs) has no key
694
+ * material to derive from, so its `deriveStateKey()` throws. Such consumers must
695
+ * override `wfStateSecret()` and supply their own secret — but the strategy
696
+ * needs *exactly* 32 bytes (a raw string is otherwise parsed as hex), so the
697
+ * obvious `return env.MY_SECRET` fails. This helper does the SHA-256-to-32-bytes
698
+ * derivation for you, no `node:crypto` import required:
633
699
  *
634
- * The single `useControllerContext().instantiate(...)` call is the one
635
- * documented escape hatch: interceptors are functions, not classes, so there's
636
- * no ctor to inject into. Every class still uses constructor injection.
700
+ * ```ts
701
+ * protected override wfStateSecret(): Buffer {
702
+ * return deriveWfStateSecret(env.MY_SECRET);
703
+ * }
704
+ * ```
705
+ *
706
+ * Deterministic — the same input always yields the same key, so it is stable
707
+ * across restarts (matching what `deriveStateKey` provided).
637
708
  */
638
- declare const WfTrigger: (opts?: WfTriggerOpts) => ClassDecorator & MethodDecorator;
639
- //#endregion
640
- //#region src/wf-trigger/provider.d.ts
709
+ export declare function deriveWfStateSecret(secret: string): Buffer;
641
710
  /**
642
711
  * DI singleton owning the workflow-trigger wiring: state persistence, outlets,
643
712
  * and token wire. Consumers subclass to swap the durable state strategy, add
@@ -669,36 +738,7 @@ declare const WfTrigger: (opts?: WfTriggerOpts) => ClassDecorator & MethodDecora
669
738
  * and the wf engine reads action + form data directly from `body.input`. No
670
739
  * app-level bridging of `body.action` is needed.
671
740
  */
672
- /** Named state-strategy registry: the shape `handleAsOutletRequest` reads off `state`. */
673
- type StateRegistry = {
674
- strategies: Record<string, WfStateStrategy>;
675
- default: string;
676
- };
677
- /**
678
- * Derive the exact 32-byte key the encapsulated wf-state strategy requires from
679
- * an arbitrary-length app secret.
680
- *
681
- * The default {@link WfTriggerProvider.wfStateSecret} reuses the auth secret via
682
- * `AuthCredential.deriveStateKey()`, which only works for stores backed by a
683
- * symmetric secret (JWT / encapsulated). A stateful store (e.g. atscript-db —
684
- * the recommended default once you adopt the session-listing APIs) has no key
685
- * material to derive from, so its `deriveStateKey()` throws. Such consumers must
686
- * override `wfStateSecret()` and supply their own secret — but the strategy
687
- * needs *exactly* 32 bytes (a raw string is otherwise parsed as hex), so the
688
- * obvious `return env.MY_SECRET` fails. This helper does the SHA-256-to-32-bytes
689
- * derivation for you, no `node:crypto` import required:
690
- *
691
- * ```ts
692
- * protected override wfStateSecret(): Buffer {
693
- * return deriveWfStateSecret(env.MY_SECRET);
694
- * }
695
- * ```
696
- *
697
- * Deterministic — the same input always yields the same key, so it is stable
698
- * across restarts (matching what `deriveStateKey` provided).
699
- */
700
- declare function deriveWfStateSecret(secret: string): Buffer;
701
- declare class WfTriggerProvider {
741
+ export declare class WfTriggerProvider {
702
742
  protected readonly wf: MoostWf;
703
743
  protected readonly auth: AuthCredential;
704
744
  /**
@@ -724,6 +764,19 @@ declare class WfTriggerProvider {
724
764
  /** Durable strategy a workflow swaps to after the first validated input. Default = encapsulated (no real store); customers override to return e.g. new HandleStateStrategy({ store: <redis/db> }). */
725
765
  protected storeStrategy(): WfStateStrategy;
726
766
  private makeEncapsulated;
767
+ /**
768
+ * App-wide workflow-trigger hooks ({@link WfTriggerHooks}): `around`,
769
+ * `beforePersist`, `renderEnvelope`, `restoreOnError` / `maxRestores`.
770
+ * Default: none. A route's `@WfTrigger({...})` option of the same name
771
+ * replaces the hook returned here. Called once per trigger request.
772
+ *
773
+ * ```ts
774
+ * protected override triggerHooks(): WfTriggerHooks {
775
+ * return { around: (run) => db.transaction(run) };
776
+ * }
777
+ * ```
778
+ */
779
+ protected triggerHooks(): WfTriggerHooks;
727
780
  private cachedState?;
728
781
  /** Named strategy registry: every wf starts on `encapsulated` (default); a step calls swapStrategy('store') to move durable. Built lazily so subclass overrides (storeStrategy/wfStateSecret) are in effect. */
729
782
  protected stateRegistry(): StateRegistry;
@@ -731,26 +784,38 @@ declare class WfTriggerProvider {
731
784
  * Handle one trigger request. `allow` lists the workflow ids this route may
732
785
  * START and RESUME (matched without a leading `/`); omitted = unrestricted,
733
786
  * `[]` = deny all. A state token minted for a workflow outside the list is
734
- * refused with 403 before it is consumed.
787
+ * refused with 403 before it is consumed. Trigger hooks set in `opts`
788
+ * replace the {@link triggerHooks} of the same name.
735
789
  */
736
- handle(opts?: {
737
- allow?: string[];
738
- token?: WfOutletTokenConfig;
739
- }): Promise<unknown>;
790
+ handle(opts?: WfTriggerOpts): Promise<unknown>;
740
791
  }
741
- //#endregion
742
- //#region src/workflow/invite-outlet.d.ts
792
+ /**
793
+ * Method decorator that turns a handler into a workflow trigger.
794
+ *
795
+ * The handler may have an empty body — the interceptor's after-phase invokes
796
+ * `WfTriggerProvider.handle()` when the handler returns `undefined`. Subclasses
797
+ * that need to short-circuit (e.g. emit a custom error response) just return a
798
+ * non-undefined value from the overridden handler and the trigger is skipped.
799
+ *
800
+ * `opts` also takes the workflow-trigger hooks (`around`, `beforePersist`,
801
+ * `renderEnvelope`, `restoreOnError`, `maxRestores` — see `WfTriggerHooks`);
802
+ * each one set here replaces the provider's `triggerHooks()` hook of the
803
+ * same name for this route.
804
+ *
805
+ * The single `useControllerContext().instantiate(...)` call is the one
806
+ * documented escape hatch: interceptors are functions, not classes, so there's
807
+ * no ctor to inject into. Every class still uses constructor injection.
808
+ */
809
+ export declare const WfTrigger: (opts?: WfTriggerOpts) => ClassDecorator & MethodDecorator;
743
810
  /** Name of the outlet `AuthWorkflow` pauses on for `inviteDelivery: 'deliver' | 'return-link'`. */
744
- declare const INVITE_OUTLET = "invite";
811
+ export declare const INVITE_OUTLET = "invite";
745
812
  /**
746
813
  * The `invite` outlet (registered by default on `WfTriggerProvider`): hands
747
814
  * the resume token to the callback the `send-email` step registered, which
748
815
  * builds the link and delivers it (`'deliver'`) or returns it to the issuer
749
816
  * (`'return-link'`). The token never rides the response on its own.
750
817
  */
751
- declare function createInviteOutlet(): WfOutlet;
752
- //#endregion
753
- //#region src/rate-limit/mate.d.ts
818
+ export declare function createInviteOutlet(): WfOutlet;
754
819
  /**
755
820
  * Caller-identity strategy for a rate-limited route (RL.spec.md §5.3):
756
821
  * - `'ip'` — client IP (the public-endpoint mode; honors `trustProxy`).
@@ -810,9 +875,7 @@ type RateLimitMate = Mate<TMoostMetadata & {
810
875
  }, TMoostMetadata & {
811
876
  params: TMateParamMeta[];
812
877
  }>;
813
- declare function getRateLimitMate(): RateLimitMate;
814
- //#endregion
815
- //#region src/rate-limit/interceptor.d.ts
878
+ export declare function getRateLimitMate(): RateLimitMate;
816
879
  interface RateLimitInterceptorOptions {
817
880
  /**
818
881
  * The shared limiter (wire your `RateLimitStoreRedis` here). When omitted,
@@ -837,7 +900,7 @@ interface RateLimitInterceptorOptions {
837
900
  trustProxy?: boolean;
838
901
  /** Emit draft `RateLimit-*` headers on every response of a limited route. Default: `true`. */
839
902
  headers?: boolean;
840
- /** App-wide default 429 message template. */
903
+ /** App-wide default 429 message template (placeholders `{{limit}}`, `{{window}}`, `{{delta}}`). */
841
904
  message?: string;
842
905
  }
843
906
  /**
@@ -870,11 +933,11 @@ interface RateLimitInterceptorOptions {
870
933
  *
871
934
  * On rejection: draft `RateLimit-*` headers + `Retry-After` are written to
872
935
  * the accumulated response (they survive the throw — wooks renders the error
873
- * onto the same `HttpResponse`), then `HttpError(429, message)` is thrown.
936
+ * onto the same `HttpResponse`), then an `HttpError(429)` is thrown whose body
937
+ * carries the rendered `message`, `code: "RATE_LIMITED"` and
938
+ * `params: { policy, limit, window, retryAfter }` (seconds) — translate by code.
874
939
  */
875
- declare function rateLimitInterceptors(opts?: RateLimitInterceptorOptions): TInterceptorDef[];
876
- //#endregion
877
- //#region src/rate-limit/decorator.d.ts
940
+ export declare function rateLimitInterceptors(opts?: RateLimitInterceptorOptions): TInterceptorDef[];
878
941
  /**
879
942
  * Declares rate-limit rules for a controller method (or every method of a
880
943
  * controller, when applied at class level — method-level metadata replaces
@@ -896,8 +959,8 @@ declare function rateLimitInterceptors(opts?: RateLimitInterceptorOptions): TInt
896
959
  * Rules are parsed eagerly, so a bad rule string throws at decoration
897
960
  * (boot) time, not per request.
898
961
  */
899
- declare function RateLimit(disabled: false): ClassDecorator & MethodDecorator;
900
- declare function RateLimit(...rulesAndOpts: [RateLimitRuleInput$1, ...Array<RateLimitRuleInput$1 | RateLimitDecoratorOptions>]): ClassDecorator & MethodDecorator;
962
+ export declare function RateLimit(disabled: false): ClassDecorator & MethodDecorator;
963
+ export declare function RateLimit(...rulesAndOpts: [RateLimitRuleInput$1, ...Array<RateLimitRuleInput$1 | RateLimitDecoratorOptions>]): ClassDecorator & MethodDecorator;
901
964
  /**
902
965
  * Decorator-factory sugar for attaching the `rateLimitInterceptors(opts)`
903
966
  * PAIR to a specific controller or method instead of globally — the
@@ -905,9 +968,7 @@ declare function RateLimit(...rulesAndOpts: [RateLimitRuleInput$1, ...Array<Rate
905
968
  * dropping the pre-guard def loses flood protection for ip-keyed routes,
906
969
  * dropping the post-guard def silently disables `key: 'user'` routes.
907
970
  */
908
- declare function RateLimited(opts?: RateLimitInterceptorOptions): ClassDecorator & MethodDecorator;
909
- //#endregion
910
- //#region src/rate-limit/composables.d.ts
971
+ export declare function RateLimited(opts?: RateLimitInterceptorOptions): ClassDecorator & MethodDecorator;
911
972
  /**
912
973
  * Supply the rate-limit subject for a named key strategy — the seam for
913
974
  * custom IAMs / tenant resolvers. Call from GUARD-priority (or earlier)
@@ -915,9 +976,9 @@ declare function RateLimited(opts?: RateLimitInterceptorOptions): ClassDecorator
915
976
  * prefix, e.g. `iam:<sub>`) and always wins over the built-in `user` /
916
977
  * `session` derivations. Full contract: docs `/moost/rate-limit`.
917
978
  */
918
- declare function setRateLimitSubject(kind: string, subject: string, ctx?: EventContext): void;
979
+ export declare function setRateLimitSubject(kind: string, subject: string, ctx?: EventContext): void;
919
980
  /** Read a named rate-limit subject set for this event (or `undefined`). */
920
- declare function getRateLimitSubject(kind: string, ctx?: EventContext): string | undefined;
981
+ export declare function getRateLimitSubject(kind: string, ctx?: EventContext): string | undefined;
921
982
  interface RateLimitBindings {
922
983
  /**
923
984
  * The decision the interceptor computed for this event, or `null` when the
@@ -930,9 +991,7 @@ interface RateLimitBindings {
930
991
  * wook) — it's a single slot read, and workflow child events inherit the
931
992
  * HTTP parent's slot transparently.
932
993
  */
933
- declare function useRateLimit(ctx?: EventContext): RateLimitBindings;
934
- //#endregion
935
- //#region src/oauth/oauth.controller.d.ts
994
+ export declare function useRateLimit(ctx?: EventContext): RateLimitBindings;
936
995
  /**
937
996
  * REST surface for federated-login ACCOUNT MANAGEMENT (OAuth2 / OIDC), RFC
938
997
  * IDP.md §3.7. Two routes — anonymous LOGIN is NOT here: it lives in the login
@@ -966,7 +1025,7 @@ declare function useRateLimit(ctx?: EventContext): RateLimitBindings;
966
1025
  * session, never from a parameter. Subclass + add `@ArbacAction(...)` to gate
967
1026
  * them further (e.g. an admin cross-user view).
968
1027
  */
969
- declare class OAuthController {
1028
+ export declare class OAuthController {
970
1029
  protected readonly registry: OAuthProviderRegistry;
971
1030
  protected readonly auth: AuthCredential;
972
1031
  protected readonly users: UserService;
@@ -1053,29 +1112,25 @@ interface ConnectedAccount {
1053
1112
  displayName?: string;
1054
1113
  avatarUrl?: string;
1055
1114
  }
1056
- //#endregion
1057
- //#region src/oauth/oauth-csrf.d.ts
1058
1115
  /**
1059
1116
  * Name of the double-submit anti-CSRF cookie set at `/:provider/start` and
1060
1117
  * verified in `oauth-exchange`. Holds the signed-state `random`; the callback
1061
1118
  * proves it speaks for the same browser that started the flow by matching the
1062
1119
  * cookie value against the verified `state.random` (RFC IDP.md §7).
1063
1120
  */
1064
- declare const OAUTH_CSRF_COOKIE = "aooth_oauth";
1121
+ export declare const OAUTH_CSRF_COOKIE = "aooth_oauth";
1065
1122
  /**
1066
1123
  * Cookie attributes for the CSRF cookie. `SameSite=Lax` (NOT `Strict`) so the
1067
1124
  * top-level GET navigation BACK from the provider still carries it; `httpOnly`
1068
1125
  * so script can't read it; short `maxAge` matched to the state TTL. `secure` is
1069
1126
  * caller-controlled (off for the http test harness, on in production).
1070
1127
  */
1071
- declare function oauthCsrfCookieAttrs(opts: {
1128
+ export declare function oauthCsrfCookieAttrs(opts: {
1072
1129
  secure: boolean;
1073
1130
  /** Cookie lifetime in seconds — match the signed-state TTL (default 600). */
1074
1131
  maxAgeSec?: number;
1075
1132
  path?: string;
1076
1133
  }): TCookieAttributesInput;
1077
- //#endregion
1078
- //#region src/oauth/oauth-redirect.d.ts
1079
1134
  /**
1080
1135
  * Open-redirect defense for the post-login `redirect` carried across the OAuth
1081
1136
  * bounce (RFC IDP.md §7). The provider round-trips whatever target the SPA
@@ -1090,16 +1145,14 @@ declare function oauthCsrfCookieAttrs(opts: {
1090
1145
  * carry no control/whitespace characters (which browsers may strip, changing
1091
1146
  * the parsed target). Everything else falls back to the caller's default.
1092
1147
  */
1093
- declare function isSafeRelativeRedirect(target: string | undefined): target is string;
1148
+ export declare function isSafeRelativeRedirect(target: string | undefined): target is string;
1094
1149
  /**
1095
1150
  * Return `requested` when it is a safe same-origin relative redirect, else
1096
1151
  * `fallback`. Used at `/start` (before signing) and re-checked in
1097
1152
  * `oauth-exchange` (before honoring) — defense in depth around the signed
1098
1153
  * round-trip.
1099
1154
  */
1100
- declare function resolveOAuthRedirect(requested: string | undefined, fallback: string): string;
1101
- //#endregion
1102
- //#region src/oauth/oauth-runtime.d.ts
1155
+ export declare function resolveOAuthRedirect(requested: string | undefined, fallback: string): string;
1103
1156
  /**
1104
1157
  * DI holder bundling the two app-provided federated-login singletons the
1105
1158
  * `sso-callback` workflow step needs. It exists so the step can resolve them
@@ -1113,13 +1166,11 @@ declare function resolveOAuthRedirect(requested: string | undefined, fallback: s
1113
1166
  * unchanged). NO flow store: the PKCE verifier + OIDC nonce are derived
1114
1167
  * statelessly from the signed-state seed (see `OAuthProviderRegistry.deriveSeededPkce`).
1115
1168
  */
1116
- declare class OAuthRuntime {
1169
+ export declare class OAuthRuntime {
1117
1170
  readonly registry: OAuthProviderRegistry;
1118
1171
  readonly federated: FederatedLoginService;
1119
1172
  constructor(registry: OAuthProviderRegistry, federated: FederatedLoginService);
1120
1173
  }
1121
- //#endregion
1122
- //#region src/oauth/oauth-tokens.d.ts
1123
1174
  /**
1124
1175
  * Explicit string DI token for the ABSTRACT `FederatedIdentityStore`.
1125
1176
  *
@@ -1140,9 +1191,7 @@ declare class OAuthRuntime {
1140
1191
  * )
1141
1192
  * ```
1142
1193
  */
1143
- declare const FEDERATED_IDENTITY_STORE_TOKEN = "aooth:FederatedIdentityStore";
1144
- //#endregion
1145
- //#region src/authz/authorize.controller.d.ts
1194
+ export declare const FEDERATED_IDENTITY_STORE_TOKEN = "aooth:FederatedIdentityStore";
1146
1195
  /** RFC-6749-shaped token-endpoint error response. */
1147
1196
  interface TokenError {
1148
1197
  error: string;
@@ -1226,7 +1275,7 @@ interface ClientRegistrationFailure {
1226
1275
  * intent, audience, scope) is fixed at `/authorize` time and recorded on the
1227
1276
  * pending authorization + the issued code — never inferred at `/token`.
1228
1277
  */
1229
- declare class AuthorizeController {
1278
+ export declare class AuthorizeController {
1230
1279
  protected readonly auth: AuthCredential;
1231
1280
  protected readonly policy: ClientRedirectPolicy;
1232
1281
  protected readonly pending: PendingAuthorizationStore;
@@ -1341,8 +1390,6 @@ declare class AuthorizeController {
1341
1390
  /** Fail soft: 302 the validated client redirect with an `?error=` (+ echoed `state`). */
1342
1391
  protected redirectError(redirectUri: string, error: string, state: string | undefined): string;
1343
1392
  }
1344
- //#endregion
1345
- //#region src/authz/authorize-runtime.d.ts
1346
1393
  /**
1347
1394
  * DI holder bundling the two abstract authorization-server stores the login-wf
1348
1395
  * terminal (`mint-authz-code`) needs. A `@Step` body cannot `@Inject` a string
@@ -1352,13 +1399,11 @@ declare class AuthorizeController {
1352
1399
  * injects `AuthCredential` & friends), keeping `AuthWorkflow`'s documented ctor
1353
1400
  * untouched. Mirrors `OAuthRuntime`.
1354
1401
  */
1355
- declare class AuthorizeRuntime {
1402
+ export declare class AuthorizeRuntime {
1356
1403
  readonly pending: PendingAuthorizationStore;
1357
1404
  readonly codes: AuthCodeStore;
1358
1405
  constructor(pending: PendingAuthorizationStore, codes: AuthCodeStore);
1359
1406
  }
1360
- //#endregion
1361
- //#region src/authz/authz-binding.d.ts
1362
1407
  /**
1363
1408
  * Name of the double-submit cookie that binds an in-flight authorization
1364
1409
  * request to the browser that started it. Set at `GET /auth/authorize` (holding
@@ -1374,7 +1419,7 @@ declare class AuthorizeRuntime {
1374
1419
  * fails the match here, because the victim's browser never holds the secret. So
1375
1420
  * a handle can only be redeemed by the same browser that started the request.
1376
1421
  */
1377
- declare const AUTHZ_BINDING_COOKIE = "aooth_authz";
1422
+ export declare const AUTHZ_BINDING_COOKIE = "aooth_authz";
1378
1423
  /**
1379
1424
  * Cookie attributes for the authorize-binding cookie — the same httpOnly /
1380
1425
  * `SameSite=Lax` shape as the OAuth CSRF cookie (Lax, NOT Strict, so the
@@ -1386,12 +1431,10 @@ declare const AUTHZ_BINDING_COOKIE = "aooth_authz";
1386
1431
  * `ttlMs`. `secure` is caller-controlled (off for the http test harness, on in
1387
1432
  * production).
1388
1433
  */
1389
- declare function authzBindingCookieAttrs(opts: {
1434
+ export declare function authzBindingCookieAttrs(opts: {
1390
1435
  secure: boolean;
1391
1436
  maxAgeSec: number;
1392
1437
  }): TCookieAttributesInput;
1393
- //#endregion
1394
- //#region src/authz/authz-tokens.d.ts
1395
1438
  /**
1396
1439
  * Explicit string DI tokens for the ABSTRACT authorization-server stores
1397
1440
  * ({@link import("@aooth/auth/authz").PendingAuthorizationStore},
@@ -1416,15 +1459,15 @@ declare function authzBindingCookieAttrs(opts: {
1416
1459
  * )
1417
1460
  * ```
1418
1461
  */
1419
- declare const PENDING_AUTHORIZATION_STORE_TOKEN = "aooth:PendingAuthorizationStore";
1420
- declare const AUTH_CODE_STORE_TOKEN = "aooth:AuthCodeStore";
1462
+ export declare const PENDING_AUTHORIZATION_STORE_TOKEN = "aooth:PendingAuthorizationStore";
1463
+ export declare const AUTH_CODE_STORE_TOKEN = "aooth:AuthCodeStore";
1421
1464
  /**
1422
1465
  * DI token for the {@link import("@aooth/auth/authz").ClientRedirectPolicy} — an
1423
1466
  * interface, so it has no class reference to inject by. Provide the concrete
1424
1467
  * policy (e.g. `new LoopbackClientPolicy()`, a `RegisteredClientPolicy`, or a
1425
1468
  * `CompositeClientPolicy` of both) under this string.
1426
1469
  */
1427
- declare const CLIENT_REDIRECT_POLICY_TOKEN = "aooth:ClientRedirectPolicy";
1470
+ export declare const CLIENT_REDIRECT_POLICY_TOKEN = "aooth:ClientRedirectPolicy";
1428
1471
  /**
1429
1472
  * DI token for the {@link import("@aooth/auth/authz").DynamicClientStore}
1430
1473
  * (RFC 7591 dynamic registrations) — an abstract class, same auto-instantiation
@@ -1435,9 +1478,7 @@ declare const CLIENT_REDIRECT_POLICY_TOKEN = "aooth:ClientRedirectPolicy";
1435
1478
  * overrides `getDynamicClientRegistration()`. The same store instance also
1436
1479
  * backs the `DynamicClientPolicy` composed into the redirect policy.
1437
1480
  */
1438
- declare const DYNAMIC_CLIENT_STORE_TOKEN = "aooth:DynamicClientStore";
1439
- //#endregion
1440
- //#region src/workflow/auth-workflow.ctx.d.ts
1481
+ export declare const DYNAMIC_CLIENT_STORE_TOKEN = "aooth:DynamicClientStore";
1441
1482
  type MfaTransport = "sms" | "email" | "totp";
1442
1483
  /** Per-user MFA method summary surfaced to forms via `@wf.context.pass 'mfa'`. */
1443
1484
  interface MfaSummary {
@@ -2207,6 +2248,12 @@ interface AuthWfCtx {
2207
2248
  * password. Server-only flow control.
2208
2249
  */
2209
2250
  passwordStamp?: number;
2251
+ /**
2252
+ * `password.lastChanged` when a password form was first reached; a replay
2253
+ * after the password changed answers 410 `PASSWORD_CHANGED_SIGN_IN_AGAIN`.
2254
+ * Cleared once the password is stored. Server-only flow control.
2255
+ */
2256
+ passwordFormStamp?: number;
2210
2257
  /**
2211
2258
  * Idempotency latch for the single `record-login` funnel step. Set true once
2212
2259
  * a login has been stamped this run — by the `credentials` step (the password
@@ -2310,8 +2357,6 @@ interface AuthWfCtx {
2310
2357
  */
2311
2358
  public?: AuthWfPublicState;
2312
2359
  }
2313
- //#endregion
2314
- //#region src/workflow/auth-workflow.opts.d.ts
2315
2360
  interface AuthWorkflowOpts {
2316
2361
  autoLoginOnInvite?: boolean;
2317
2362
  autoLoginOnRecover?: boolean;
@@ -2539,8 +2584,6 @@ interface ResolvedAuthWorkflowOpts {
2539
2584
  authzConsent: TAtscriptAnnotatedType;
2540
2585
  };
2541
2586
  }
2542
- //#endregion
2543
- //#region src/workflow/auth-workflow.d.ts
2544
2587
  /**
2545
2588
  * Unified outbound-dispatch payload. Customers override `deliver(payload)` on
2546
2589
  * the `AuthWorkflow` subclass to route by `kind` (per-purpose templates) and
@@ -2608,12 +2651,12 @@ type AuthDeliveryPayload = {
2608
2651
  * declares one — or an attacker submits one as an extra field — the strip
2609
2652
  * applied at the workflow step blocks shadowing.
2610
2653
  */
2611
- declare const RESERVED_USER_KEYS: ReadonlySet<string>;
2654
+ export declare const RESERVED_USER_KEYS: ReadonlySet<string>;
2612
2655
  /**
2613
2656
  * Return a shallow copy of `profile` with `RESERVED_USER_KEYS` removed.
2614
2657
  * Does not mutate the input.
2615
2658
  */
2616
- declare function stripReservedUserKeys(profile: Record<string, unknown>): Record<string, unknown>;
2659
+ export declare function stripReservedUserKeys(profile: Record<string, unknown>): Record<string, unknown>;
2617
2660
  /**
2618
2661
  * Best-effort "Browser on OS" label from a raw User-Agent string — feeds the
2619
2662
  * `name` field of `seenDevices` records so a device list reads "Chrome on
@@ -2622,8 +2665,8 @@ declare function stripReservedUserKeys(profile: Record<string, unknown>): Record
2622
2665
  * Returns just the browser or just the OS when only one side is detected;
2623
2666
  * `undefined` for empty / fully unrecognized input.
2624
2667
  */
2625
- declare function humanizeUserAgent(ua: string | undefined): string | undefined;
2626
- declare function haversineKm(a: {
2668
+ export declare function humanizeUserAgent(ua: string | undefined): string | undefined;
2669
+ export declare function haversineKm(a: {
2627
2670
  lat: number;
2628
2671
  lon: number;
2629
2672
  }, b: {
@@ -2631,7 +2674,7 @@ declare function haversineKm(a: {
2631
2674
  lon: number;
2632
2675
  }): number;
2633
2676
  /** Trim + de-duplicate role identifiers submitted via the admin invite form. */
2634
- declare function parseInviteRoles(input?: string[]): string[];
2677
+ export declare function parseInviteRoles(input?: string[]): string[];
2635
2678
  /**
2636
2679
  * Single source of truth for the "this invite was already accepted" finish
2637
2680
  * envelope. Used by both `idempotent-redirect` (in-workflow) and by
@@ -2642,13 +2685,13 @@ declare function parseInviteRoles(input?: string[]): string[];
2642
2685
  * `alreadyAcceptedRedirectUrl` being non-empty — mirrors how the resolver
2643
2686
  * defaults it, but lets consumers blank it to suppress the secondary button.
2644
2687
  */
2645
- declare function buildInviteAlreadyAcceptedEnvelope(opts: {
2688
+ export declare function buildInviteAlreadyAcceptedEnvelope(opts: {
2646
2689
  loginUrl: string;
2647
2690
  alreadyAcceptedRedirectUrl: string;
2648
2691
  /** Text overrides (see `AuthWorkflowOpts.messages`). */
2649
2692
  messages?: AoothMessages;
2650
2693
  }): FinishWfOpts;
2651
- declare class AuthWorkflow {
2694
+ export declare class AuthWorkflow {
2652
2695
  protected readonly opts: ResolvedAuthWorkflowOpts;
2653
2696
  protected readonly users: UserService;
2654
2697
  protected readonly auth: AuthCredential;
@@ -3761,6 +3804,19 @@ declare class AuthWorkflow {
3761
3804
  * convention).
3762
3805
  */
3763
3806
  changePasswordForm(ctx: AuthWfCtx): Promise<unknown>;
3807
+ /**
3808
+ * Refuse a password form whose account password changed after the form was
3809
+ * first reached: the first visit stamps `password.lastChanged`
3810
+ * (`ctx.passwordFormStamp`); a later visit that finds another value is a
3811
+ * replay of an already-used form — a single-use token put back by the
3812
+ * trigger's `restoreOnError` after a later failure, or a re-submitted
3813
+ * encapsulated token — and answers 410 `PASSWORD_CHANGED_SIGN_IN_AGAIN`
3814
+ * instead of changing the password again. Returns the account row; on an
3815
+ * invite accept it is read through {@link currentInviteRow}, so a cancelled
3816
+ * or superseded invite answers 410. A deleted account returns `null` and is
3817
+ * not checked: the step's own password write then answers it as a form error.
3818
+ */
3819
+ private refusePasswordFormReplay;
3764
3820
  /**
3765
3821
  * Change-password terminal — sign the current device in on a FRESH session
3766
3822
  * and end the one the change was made from, then emit a success message.
@@ -4552,8 +4608,6 @@ declare class AuthWorkflow {
4552
4608
  */
4553
4609
  signupFlow(): void;
4554
4610
  }
4555
- //#endregion
4556
- //#region src/workflows/auth-email-outlet.d.ts
4557
4611
  interface AuthEmailOutletDeps {
4558
4612
  emailSender: EmailSender$1;
4559
4613
  buildMagicLinkUrl: BuildMagicLinkUrl$1;
@@ -4565,9 +4619,7 @@ interface AuthEmailOutletDeps {
4565
4619
  * `EmailSender`. Single-use: pass the same instance into one
4566
4620
  * `handleWfOutletRequest({ outlets })`.
4567
4621
  */
4568
- declare function createAuthEmailOutlet(deps: AuthEmailOutletDeps): WfOutlet;
4569
- //#endregion
4570
- //#region src/audit/index.d.ts
4622
+ export declare function createAuthEmailOutlet(deps: AuthEmailOutletDeps): WfOutlet;
4571
4623
  /**
4572
4624
  * Audit event emitter — used by `AuthWorkflow`'s audit-login step (and
4573
4625
  * future recovery / invite audit steps) to fan out login.success and similar
@@ -4593,5 +4645,4 @@ interface AuditEvent {
4593
4645
  interface AuditEmitter {
4594
4646
  emit(event: AuditEvent): Promise<void> | void;
4595
4647
  }
4596
- //#endregion
4597
- export { ADD_MFA_WORKFLOW, AOOTH_MESSAGES, AUTHZ_BINDING_COOKIE, AUTH_CODE_STORE_TOKEN, type AoothMessageCode, type AoothMessageParams, type AoothMessages, type AuditEmitter, type AuditEvent, type AuthBindings, type AuthContext, AuthController, type AuthDeliveryPayload, type AuthEmailEvent, type AuthEmailKind, type AuthEmailOutletDeps, AuthGuarded, type AuthLoginResponse, type AuthLogoutBody, type AuthOkResponse, type AuthOptions, type AuthRefreshBody, type AuthSmsEvent, type AuthSmsKind, type AuthWfCompletionState, type AuthWfConsentsState, type AuthWfCtx, type AuthWfMfaEnrollState, type AuthWfOAuthState, type AuthWfPasswordUiState, type AuthWfPincodeUiState, AuthWorkflow, type AuthWorkflowOpts, type AuthorizationServerMetadata, AuthorizeController, AuthorizeRuntime, type AuthzReauthPolicy, type BuildAuthorizationServerMetadataOptions, type BuildMagicLinkUrl, type BuildProtectedResourceMetadataOptions, CHANGE_PASSWORD_WORKFLOW, CLIENT_REDIRECT_POLICY_TOKEN, type ConcurrencyLimitOptions, type ConnectedAccount, type ConsentDescriptor, type ConsentDescriptorLike, type ConsentEvent, ConsentStore, DEFAULT_AUTH_WORKFLOWS, DYNAMIC_CLIENT_STORE_TOKEN, DynamicClientRegistration, type DynamicClientRegistrationOptions, type EmailSender, type EnrichedSession, FEDERATED_IDENTITY_STORE_TOKEN, INVITE_OUTLET, type IssueResult, type LoginRedirect, type MfaSummary, type MfaTransport, OAUTH_CSRF_COOKIE, OAuthController, OAuthRuntime, PENDING_AUTHORIZATION_STORE_TOKEN, type ProtectedResourceMetadata, Public, RESERVED_USER_KEYS, RateLimit, type RateLimitBindings, type RateLimitDecision, type RateLimitDecoratorOptions, type RateLimitInterceptorOptions, type RateLimitKeyStrategy, type RateLimitRule, type RateLimitRuleInput, type RateLimitStore, RateLimitStoreMemory, RateLimited, RateLimiter, type RateLimiterOptions, type ResolvedAuthCookieConfig, type ResolvedAuthOptions, type ResolvedAuthWorkflowOpts, type SessionEnricher, SessionEnricherProvider, type SessionInfo, SessionsController, type SmsSender, type SsoProvider, type TAuthMeta, type TRateLimitMeta, UserId, WfTrigger, type WfTriggerOpts, WfTriggerProvider, type WwwAuthenticateBearerChallengeOptions, authGuardInterceptor, authzBindingCookieAttrs, buildAuthorizationServerMetadata, buildInviteAlreadyAcceptedEnvelope, buildProtectedResourceMetadata, buildWwwAuthenticateBearerChallenge, canonicalizeIssuer, createAuthEmailOutlet, createInviteOutlet, deriveWfStateSecret, generateMagicLinkToken, getAuthMate, getRateLimitMate, getRateLimitSubject, haversineKm, humanizeUserAgent, isSafeRelativeRedirect, oauthCsrfCookieAttrs, parseInviteRoles, rateLimitInterceptors, renderAoothMessage, resolveAoothMessage, resolveOAuthRedirect, setRateLimitSubject, stripReservedUserKeys, useAuth, useRateLimit };
4648
+ export { type AoothMessageCode, type AoothMessageParams, type AoothMessages, type AuditEmitter, type AuditEvent, type AuthBindings, type AuthContext, type AuthDeliveryPayload, type AuthEmailEvent, type AuthEmailKind, type AuthEmailOutletDeps, type AuthLoginResponse, type AuthLogoutBody, type AuthOkResponse, type AuthOptions, type AuthRefreshBody, type AuthSmsEvent, type AuthSmsKind, type AuthWfCompletionState, type AuthWfConsentsState, type AuthWfCtx, type AuthWfMfaEnrollState, type AuthWfOAuthState, type AuthWfPasswordUiState, type AuthWfPincodeUiState, type AuthWorkflowOpts, type AuthorizationServerMetadata, type AuthzReauthPolicy, type BuildAuthorizationServerMetadataOptions, type BuildMagicLinkUrl, type BuildProtectedResourceMetadataOptions, type ConcurrencyLimitOptions, type ConnectedAccount, type ConsentDescriptor, type ConsentDescriptorLike, type ConsentEvent, DynamicClientRegistration, type DynamicClientRegistrationOptions, type EmailSender, type EnrichedSession, type IssueResult, type LoginRedirect, type MfaSummary, type MfaTransport, type ProtectedResourceMetadata, type RateLimitBindings, type RateLimitDecision, type RateLimitDecoratorOptions, type RateLimitInterceptorOptions, type RateLimitKeyStrategy, type RateLimitRule, type RateLimitRuleInput, type RateLimitStore, RateLimitStoreMemory, RateLimiter, type RateLimiterOptions, type ResolvedAuthCookieConfig, type ResolvedAuthOptions, type ResolvedAuthWorkflowOpts, type SessionEnricher, type SessionInfo, type SmsSender, type SsoProvider, type TAuthMeta, type TRateLimitMeta, type UserAuthErrorBody, type WfTriggerHooks, type WfTriggerOpts, type WwwAuthenticateBearerChallengeOptions, buildAuthorizationServerMetadata, buildProtectedResourceMetadata, buildWwwAuthenticateBearerChallenge, canonicalizeIssuer, generateMagicLinkToken };