@aooth/auth-moost 0.1.48 → 0.1.49

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.
@@ -450,10 +450,11 @@ declare class ProveControlOtpForm {
450
450
  }
451
451
  /**
452
452
  * Atscript interface **AuthorizeConsentForm**
453
- * @see {@link ./forms.as:1048:18}
453
+ * @see {@link ./forms.as:1050:18}
454
454
  */
455
455
  declare class AuthorizeConsentForm {
456
456
  // notice: ui.paragraph
457
+ // signedIn: ui.paragraph
457
458
  // deny: ui.action
458
459
  static __is_atscript_annotated_type: true;
459
460
  static type: TAtscriptTypeObject<keyof AuthorizeConsentForm, AuthorizeConsentForm>;
@@ -1,2 +1,2 @@
1
- import { C as Select2faForm, D as TermsBumpForm, E as StepUpConfirmForm, O as WithInlineConsentForm, S as RemoveMfaConfirmForm, T as SignupForm, _ as PincodeForm, a as ConcurrencyLimitForm, b as RecoveryFactorForm, c as EnrollConfirmForm, d as InviteForm, f as LoginCredentialsForm, g as PasswordReauthForm, h as MfaCodeForm, i as ChangePasswordForm, l as EnrollPickMethodForm, m as ManageMfaForm, n as AskPhoneForm, o as EmailIdentifierForm, p as MagicLinkRequestForm, r as AuthorizeConsentForm, s as EnrollAddressForm, t as AskEmailForm, u as EnrollTotpQrForm, v as ProveControlForm, w as SetPasswordForm, x as RecoveryModeSelectForm, y as ProveControlOtpForm } from "../forms-xaBNc5Ng.mjs";
1
+ import { C as Select2faForm, D as TermsBumpForm, E as StepUpConfirmForm, O as WithInlineConsentForm, S as RemoveMfaConfirmForm, T as SignupForm, _ as PincodeForm, a as ConcurrencyLimitForm, b as RecoveryFactorForm, c as EnrollConfirmForm, d as InviteForm, f as LoginCredentialsForm, g as PasswordReauthForm, h as MfaCodeForm, i as ChangePasswordForm, l as EnrollPickMethodForm, m as ManageMfaForm, n as AskPhoneForm, o as EmailIdentifierForm, p as MagicLinkRequestForm, r as AuthorizeConsentForm, s as EnrollAddressForm, t as AskEmailForm, u as EnrollTotpQrForm, v as ProveControlForm, w as SetPasswordForm, x as RecoveryModeSelectForm, y as ProveControlOtpForm } from "../forms-B9-r2zT5.mjs";
2
2
  export { AskEmailForm, AskPhoneForm, AuthorizeConsentForm, ChangePasswordForm, ConcurrencyLimitForm, EmailIdentifierForm, EnrollAddressForm, EnrollConfirmForm, EnrollPickMethodForm, EnrollTotpQrForm, InviteForm, LoginCredentialsForm, MagicLinkRequestForm, ManageMfaForm, MfaCodeForm, PasswordReauthForm, PincodeForm, ProveControlForm, ProveControlOtpForm, RecoveryFactorForm, RecoveryModeSelectForm, RemoveMfaConfirmForm, Select2faForm, SetPasswordForm, SignupForm, StepUpConfirmForm, TermsBumpForm, WithInlineConsentForm };
@@ -463,7 +463,7 @@ defineAnnotatedType("object", ProveControlOtpForm).prop("intro", defineAnnotated
463
463
  name: "align",
464
464
  value: "center"
465
465
  }, true).annotate("ui.form.pushDown", true).optional().$type).annotate("meta.label", "Confirm your identity").annotate("wf.context.pass", "public", true).annotate("ui.form.submit.text", "Verify and link");
466
- defineAnnotatedType("object", AuthorizeConsentForm).prop("notice", defineAnnotatedType().designType("phantom").tags("paragraph", "ui").annotate("ui.form.order", 1).annotate("ui.form.fn.value", "(_, _d, ctx) => { const a = ctx.public?.authz; const host = a?.clientName && a?.redirectHost ? \" (\" + a.redirectHost + \")\" : \"\"; const who = a?.clientName ? \"“\" + a.clientName + \"”\" + host : \"A local application\"; const sc = a?.scope ? \" It is requesting access to: \" + a.scope + \".\" : \"\"; return who + \" wants to sign in to your account.\" + sc + \" Authorize this only if you started it.\"; }").$type).prop("deny", defineAnnotatedType().designType("phantom").tags("action", "ui").annotate("ui.form.order", 10).annotate("ui.form.action", {
466
+ defineAnnotatedType("object", AuthorizeConsentForm).prop("notice", defineAnnotatedType().designType("phantom").tags("paragraph", "ui").annotate("ui.form.order", 1).annotate("ui.form.fn.value", "(_, _d, ctx) => { const a = ctx.public?.authz; const host = a?.clientName && a?.redirectHost ? \" (\" + a.redirectHost + \")\" : \"\"; const who = a?.clientName ? \"“\" + a.clientName + \"”\" + host : \"A local application\"; const sc = a?.scope ? \" It is requesting access to: \" + a.scope + \".\" : \"\"; return who + \" wants to sign in to your account.\" + sc + \" Authorize this only if you started it.\"; }").$type).prop("signedIn", defineAnnotatedType().designType("phantom").tags("paragraph", "ui").annotate("ui.form.order", 2).annotate("ui.form.fn.hidden", "(_, _d, ctx) => !ctx.public?.authz?.signedInAs").annotate("ui.form.fn.value", "(_, _d, ctx) => \"Signed in as \" + (ctx.public?.authz?.signedInAs || \"\") + \".\"").$type).prop("deny", defineAnnotatedType().designType("phantom").tags("action", "ui").annotate("ui.form.order", 10).annotate("ui.form.action", {
467
467
  id: "deny",
468
468
  label: "Deny"
469
469
  }).annotate("ui.form.attr", {
package/dist/index.d.mts CHANGED
@@ -1521,6 +1521,42 @@ interface AuthWfFinalizePolicy {
1521
1521
  notifyNewDevice: boolean;
1522
1522
  redirect: LoginRedirect;
1523
1523
  }
1524
+ /**
1525
+ * Re-authentication policy for authorization-server logins (`ctx.authz` runs
1526
+ * only — a plain login visit never consults it). Resolved by
1527
+ * `resolveAuthzReauthPolicy(ctx)` and consumed once, inline in `init-login`
1528
+ * (which runs BEFORE the prepare-* block, like `credentials`' inline
1529
+ * resolver calls).
1530
+ *
1531
+ * - `'always-reauth'` (default) — today's behavior: every authorize leg
1532
+ * re-collects credentials, even with a live browser session.
1533
+ * - `'consent-only'` — with a live session on the trigger route, `init-login`
1534
+ * binds `ctx.subject` from it and the run skips the credentials form,
1535
+ * pausing straight on the authorize-consent screen (browser binding +
1536
+ * explicit approval still apply — see `authz-consent`). No session ⇒
1537
+ * unchanged credentials path. Requires the flow trigger route to see the
1538
+ * session credential (true for cookie-carried sessions on a same-origin
1539
+ * SPA).
1540
+ */
1541
+ interface AuthzReauthPolicy {
1542
+ mode: "consent-only" | "always-reauth";
1543
+ /**
1544
+ * `'consent-only'` only: maximum age of the SESSION ORIGIN (the
1545
+ * `SessionInfo.createdAt` of the live session's family) for the silent
1546
+ * path. An older session — or one whose origin can't be established
1547
+ * (legacy token without a `sessionId`) — falls back to the credentials
1548
+ * form (GitHub sudo-style freshness). Omit for no ceiling.
1549
+ */
1550
+ maxSessionAgeMs?: number;
1551
+ /**
1552
+ * `'consent-only'` only: when `true`, a silently-bound subject still runs
1553
+ * the MFA challenge loop before consent (the session skips only the
1554
+ * password form). Default (`false`/omitted) pre-sets `otp.verified` — the
1555
+ * session already proved its factors at login time, so the whole loop
1556
+ * (including `risk-step-up`) is skipped.
1557
+ */
1558
+ requireMfa?: boolean;
1559
+ }
1524
1560
  /** Login-time guards policy. */
1525
1561
  interface AuthWfGuardsPolicy {
1526
1562
  passwordInitial: boolean;
@@ -1948,15 +1984,17 @@ interface AuthWfPublicState {
1948
1984
  newPasswordRequired?: boolean;
1949
1985
  /**
1950
1986
  * Mirrors the display-only fields of `ctx.authz` — the requesting client's
1951
- * id/name, granted scope, and the VALIDATED redirect host (the trustworthy
1952
- * identity shown next to the attacker-choosable `clientName`), shown on the
1953
- * authorize-consent form. The `handle` and the `approved` gate stay
1987
+ * id/name, granted scope, the VALIDATED redirect host (the trustworthy
1988
+ * identity shown next to the attacker-choosable `clientName`), and — on a
1989
+ * silent (consent-only) run — the acting identity (`signedInAs`), all shown
1990
+ * on the authorize-consent form. The `handle` and the `approved` gate stay
1954
1991
  * server-only (never whitelisted onto the wire).
1955
1992
  */
1956
1993
  authz?: {
1957
1994
  clientName?: string;
1958
1995
  scope?: string;
1959
1996
  redirectHost?: string;
1997
+ signedInAs?: string;
1960
1998
  };
1961
1999
  }
1962
2000
  /** Unified workflow context shape — one type for all three flows. */
@@ -2057,6 +2095,20 @@ interface AuthWfCtx {
2057
2095
  scope?: string;
2058
2096
  redirectHost?: string;
2059
2097
  approved?: boolean;
2098
+ /**
2099
+ * Consent-only marker: `init-login` bound `ctx.subject` from a live
2100
+ * browser session (per {@link AuthzReauthPolicy} `mode: 'consent-only'`)
2101
+ * instead of the credentials form. Gates `record-login` off (a silent
2102
+ * consent is not a login event — no `lastLogin` stamp, no `afterLogin`,
2103
+ * and `isFirstLogin`-gated steps never fire for it).
2104
+ */
2105
+ silent?: boolean;
2106
+ /**
2107
+ * Acting identity shown on the consent form when the run is silent
2108
+ * ("Signed in as …") so the user can catch a wrong-account grant.
2109
+ * Display-only; mirrored to `public.authz.signedInAs`.
2110
+ */
2111
+ signedInAs?: string;
2060
2112
  };
2061
2113
  /**
2062
2114
  * FE-facing surface — the ONLY top-level ctx key whitelisted on form
@@ -2610,6 +2662,18 @@ declare class AuthWorkflow {
2610
2662
  * emailVerifiedRequired). Reached from login.flow.
2611
2663
  */
2612
2664
  protected resolveGuards(_ctx: AuthWfCtx): NonNullable<AuthWfCtx["guards"]> | Promise<NonNullable<AuthWfCtx["guards"]>>;
2665
+ /**
2666
+ * Re-authentication policy for authorization-server logins (`ctx.authz`
2667
+ * runs). Consulted inline by `init-login` — BEFORE `credentials`, like that
2668
+ * step's own inline resolver calls — and only when the START input carried
2669
+ * an `authz` handle; a plain login never consults it. Default keeps today's
2670
+ * behavior: every authorize leg re-collects credentials. Override to
2671
+ * `{ mode: 'consent-only' }` so a live browser session skips straight to
2672
+ * the authorize-consent screen (browser binding + explicit approval still
2673
+ * apply); see {@link AuthzReauthPolicy} for `maxSessionAgeMs` freshness and
2674
+ * the `requireMfa` knob.
2675
+ */
2676
+ protected resolveAuthzReauthPolicy(_ctx: AuthWfCtx): AuthzReauthPolicy | Promise<AuthzReauthPolicy>;
2613
2677
  /**
2614
2678
  * Resolve the session-policy (concurrency limit). Reached from login.flow.
2615
2679
  */
@@ -3072,7 +3136,34 @@ declare class AuthWorkflow {
3072
3136
  * clobber the user's live factor, by construction.
3073
3137
  */
3074
3138
  protected handleEnrollExit(ctx: AuthWfCtx, action: string | undefined): boolean;
3075
- initLogin(ctx: AuthWfCtx): void;
3139
+ initLogin(ctx: AuthWfCtx): undefined | Promise<undefined>;
3140
+ /**
3141
+ * `init-login`'s consent-only dispatch: run {@link probeSilentAuthz} and, on
3142
+ * a successful bind, move to the durable store strategy (the run will pause
3143
+ * on the consent form; mirrors `credentials` / `sso-callback` post-subject).
3144
+ * Split from the probe so unit tests can exercise the probe without a live
3145
+ * wf engine (`swapStrategy` requires one).
3146
+ */
3147
+ private maybeBindSilentAuthz;
3148
+ /**
3149
+ * Silent-authorize session probe (consent-only re-auth policy). Reads the
3150
+ * auth context the guard interceptor stashed for THIS trigger request —
3151
+ * `getAuthContext()` is `null` for a missing, expired, or invalid credential
3152
+ * on a `@Public()` route, so the probe is non-throwing by construction (no
3153
+ * 401 can leak out of the flow). Requires the trigger route to actually see
3154
+ * the session credential (true for cookie-carried sessions on a same-origin
3155
+ * SPA) and the guard interceptor to be mounted on it.
3156
+ *
3157
+ * Binds on success: `ctx.subject`, `ctx.authz.silent` (+ `signedInAs` for
3158
+ * the consent copy), pre-sets `otp.verified` unless `policy.requireMfa`, and
3159
+ * seeds channel state from the user row (same `seedChannelState` as the
3160
+ * federated path) so the shared enrolment / notice gates behave exactly as
3161
+ * after a fresh login. Fail-closed ordering mirrors `sso-callback`: the
3162
+ * ACCOUNT-STATE GATE runs before the subject is bound, so a locked/inactive
3163
+ * account falls back to the credentials form (where `users.login` rejects
3164
+ * it) instead of silently reaching consent.
3165
+ */
3166
+ protected probeSilentAuthz(ctx: AuthWfCtx, policy: AuthzReauthPolicy): Promise<boolean>;
3076
3167
  initInviteAdmin(ctx: AuthWfCtx): void;
3077
3168
  initInviteAccept(ctx: AuthWfCtx): void;
3078
3169
  initRecovery(ctx: AuthWfCtx): void;
@@ -4107,4 +4198,4 @@ interface AuditEmitter {
4107
4198
  emit(event: AuditEvent): Promise<void> | void;
4108
4199
  }
4109
4200
  //#endregion
4110
- export { ADD_MFA_WORKFLOW, AUTHZ_BINDING_COOKIE, AUTH_CODE_STORE_TOKEN, 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 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, 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, deriveWfStateSecret, generateMagicLinkToken, getAuthMate, getRateLimitMate, getRateLimitSubject, haversineKm, humanizeUserAgent, isSafeRelativeRedirect, oauthCsrfCookieAttrs, parseInviteRoles, rateLimitInterceptors, resolveOAuthRedirect, setRateLimitSubject, stripReservedUserKeys, useAuth, useRateLimit };
4201
+ export { ADD_MFA_WORKFLOW, AUTHZ_BINDING_COOKIE, AUTH_CODE_STORE_TOKEN, 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, 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, deriveWfStateSecret, generateMagicLinkToken, getAuthMate, getRateLimitMate, getRateLimitSubject, haversineKm, humanizeUserAgent, isSafeRelativeRedirect, oauthCsrfCookieAttrs, parseInviteRoles, rateLimitInterceptors, resolveOAuthRedirect, setRateLimitSubject, stripReservedUserKeys, useAuth, useRateLimit };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as Select2faForm, D as TermsBumpForm, E as StepUpConfirmForm, S as RemoveMfaConfirmForm, T as SignupForm, _ as PincodeForm, a as ConcurrencyLimitForm, c as EnrollConfirmForm, d as InviteForm, f as LoginCredentialsForm, g as PasswordReauthForm, h as MfaCodeForm, i as ChangePasswordForm, l as EnrollPickMethodForm, m as ManageMfaForm, n as AskPhoneForm, o as EmailIdentifierForm, r as AuthorizeConsentForm, s as EnrollAddressForm, t as AskEmailForm, u as EnrollTotpQrForm, v as ProveControlForm, w as SetPasswordForm, y as ProveControlOtpForm } from "./forms-xaBNc5Ng.mjs";
1
+ import { C as Select2faForm, D as TermsBumpForm, E as StepUpConfirmForm, S as RemoveMfaConfirmForm, T as SignupForm, _ as PincodeForm, a as ConcurrencyLimitForm, c as EnrollConfirmForm, d as InviteForm, f as LoginCredentialsForm, g as PasswordReauthForm, h as MfaCodeForm, i as ChangePasswordForm, l as EnrollPickMethodForm, m as ManageMfaForm, n as AskPhoneForm, o as EmailIdentifierForm, r as AuthorizeConsentForm, s as EnrollAddressForm, t as AskEmailForm, u as EnrollTotpQrForm, v as ProveControlForm, w as SetPasswordForm, y as ProveControlOtpForm } from "./forms-B9-r2zT5.mjs";
2
2
  import { Controller, HandlerPaths, Inherit, Inject, InjectMoostLogger, Injectable, Intercept, MoostInit, Optional, Param, Resolve, TInterceptorPriority, defineAfterInterceptor, defineBeforeInterceptor, getMoostMate, useControllerContext, useLogger } from "moost";
3
3
  import { AuthCredential, AuthError, RateLimitStoreMemory, RateLimiter, RateLimiter as RateLimiter$1, generateMagicLinkToken, generateOpaqueToken, parseRateLimitRule } from "@aooth/auth";
4
4
  import { current, defineWook, eventTypeKey, key } from "@wooksjs/event-core";
@@ -1606,6 +1606,20 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
1606
1606
  };
1607
1607
  }
1608
1608
  /**
1609
+ * Re-authentication policy for authorization-server logins (`ctx.authz`
1610
+ * runs). Consulted inline by `init-login` — BEFORE `credentials`, like that
1611
+ * step's own inline resolver calls — and only when the START input carried
1612
+ * an `authz` handle; a plain login never consults it. Default keeps today's
1613
+ * behavior: every authorize leg re-collects credentials. Override to
1614
+ * `{ mode: 'consent-only' }` so a live browser session skips straight to
1615
+ * the authorize-consent screen (browser binding + explicit approval still
1616
+ * apply); see {@link AuthzReauthPolicy} for `maxSessionAgeMs` freshness and
1617
+ * the `requireMfa` knob.
1618
+ */
1619
+ resolveAuthzReauthPolicy(_ctx) {
1620
+ return { mode: "always-reauth" };
1621
+ }
1622
+ /**
1609
1623
  * Resolve the session-policy (concurrency limit). Reached from login.flow.
1610
1624
  */
1611
1625
  resolveSessionPolicy(_ctx) {
@@ -2094,7 +2108,8 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
2094
2108
  const sub = pickDefined(ctx.authz, [
2095
2109
  "clientName",
2096
2110
  "scope",
2097
- "redirectHost"
2111
+ "redirectHost",
2112
+ "signedInAs"
2098
2113
  ]);
2099
2114
  if (sub) pub.authz = sub;
2100
2115
  }
@@ -2386,6 +2401,65 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
2386
2401
  }
2387
2402
  const authz = getInputField("authz");
2388
2403
  if (authz) ctx.authz = { handle: authz };
2404
+ if (authz && !ctx.idpInbound) {
2405
+ const policyResult = this.resolveAuthzReauthPolicy(ctx);
2406
+ if (policyResult instanceof Promise) return policyResult.then((policy) => this.maybeBindSilentAuthz(ctx, policy));
2407
+ return this.maybeBindSilentAuthz(ctx, policyResult);
2408
+ }
2409
+ }
2410
+ /**
2411
+ * `init-login`'s consent-only dispatch: run {@link probeSilentAuthz} and, on
2412
+ * a successful bind, move to the durable store strategy (the run will pause
2413
+ * on the consent form; mirrors `credentials` / `sso-callback` post-subject).
2414
+ * Split from the probe so unit tests can exercise the probe without a live
2415
+ * wf engine (`swapStrategy` requires one).
2416
+ */
2417
+ maybeBindSilentAuthz(ctx, policy) {
2418
+ if (policy.mode !== "consent-only") return void 0;
2419
+ return this.probeSilentAuthz(ctx, policy).then((bound) => {
2420
+ if (bound) swapStrategy("store");
2421
+ });
2422
+ }
2423
+ /**
2424
+ * Silent-authorize session probe (consent-only re-auth policy). Reads the
2425
+ * auth context the guard interceptor stashed for THIS trigger request —
2426
+ * `getAuthContext()` is `null` for a missing, expired, or invalid credential
2427
+ * on a `@Public()` route, so the probe is non-throwing by construction (no
2428
+ * 401 can leak out of the flow). Requires the trigger route to actually see
2429
+ * the session credential (true for cookie-carried sessions on a same-origin
2430
+ * SPA) and the guard interceptor to be mounted on it.
2431
+ *
2432
+ * Binds on success: `ctx.subject`, `ctx.authz.silent` (+ `signedInAs` for
2433
+ * the consent copy), pre-sets `otp.verified` unless `policy.requireMfa`, and
2434
+ * seeds channel state from the user row (same `seedChannelState` as the
2435
+ * federated path) so the shared enrolment / notice gates behave exactly as
2436
+ * after a fresh login. Fail-closed ordering mirrors `sso-callback`: the
2437
+ * ACCOUNT-STATE GATE runs before the subject is bound, so a locked/inactive
2438
+ * account falls back to the credentials form (where `users.login` rejects
2439
+ * it) instead of silently reaching consent.
2440
+ */
2441
+ async probeSilentAuthz(ctx, policy) {
2442
+ const session = useAuth().getAuthContext();
2443
+ if (!session) return false;
2444
+ if (policy.maxSessionAgeMs !== void 0) {
2445
+ if (!session.sessionId) return false;
2446
+ const origin = (await this.auth.listSessions(session.userId)).find((s) => s.sessionId === session.sessionId);
2447
+ if (!origin || Date.now() - origin.createdAt > policy.maxSessionAgeMs) return false;
2448
+ }
2449
+ let user;
2450
+ try {
2451
+ user = await this.users.getUser(session.userId);
2452
+ } catch {
2453
+ return false;
2454
+ }
2455
+ if (user.account.locked || !user.account.active) return false;
2456
+ ctx.subject = session.userId;
2457
+ const authz = ctx.authz;
2458
+ authz.silent = true;
2459
+ authz.signedInAs = user.username;
2460
+ if (!policy.requireMfa) (ctx.otp ??= {}).verified = true;
2461
+ await this.seedChannelState(ctx, user);
2462
+ return true;
2389
2463
  }
2390
2464
  initInviteAdmin(ctx) {
2391
2465
  ctx.autoLogin = this.opts.autoLoginOnInvite;
@@ -5128,7 +5202,7 @@ __decorate([
5128
5202
  __decorateParam(0, WorkflowParam("context")),
5129
5203
  __decorateMetadata("design:type", Function),
5130
5204
  __decorateMetadata("design:paramtypes", [Object]),
5131
- __decorateMetadata("design:returntype", void 0)
5205
+ __decorateMetadata("design:returntype", Object)
5132
5206
  ], AuthWorkflow.prototype, "initLogin", null);
5133
5207
  __decorate([
5134
5208
  Step("init-invite-admin"),
@@ -5900,7 +5974,7 @@ __decorate([
5900
5974
  },
5901
5975
  {
5902
5976
  id: "credentials",
5903
- condition: (ctx) => !ctx.idpInbound
5977
+ condition: (ctx) => !ctx.idpInbound && !ctx.subject
5904
5978
  },
5905
5979
  {
5906
5980
  id: "prove-control",
@@ -5967,7 +6041,7 @@ __decorate([
5967
6041
  { break: (ctx) => !!ctx.aborted },
5968
6042
  {
5969
6043
  id: "record-login",
5970
- condition: (ctx) => !!ctx.subject
6044
+ condition: (ctx) => !!ctx.subject && !ctx.authz?.silent
5971
6045
  },
5972
6046
  {
5973
6047
  condition: (ctx) => !ctx.authz,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aooth/auth-moost",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "description": "Moost auth integration for aoothjs — AuthGuard interceptor, useAuth composable, REST endpoints, workflows",
5
5
  "keywords": [
6
6
  "aoothjs",
@@ -59,10 +59,10 @@
59
59
  "dependencies": {
60
60
  "@atscript/moost-wf": "^0.1.121",
61
61
  "@wooksjs/http-body": "^0.7.19",
62
- "@aooth/arbac-moost": "^0.1.48",
63
- "@aooth/auth": "0.1.48",
64
- "@aooth/idp": "0.1.48",
65
- "@aooth/user": "0.1.48"
62
+ "@aooth/arbac-moost": "^0.1.49",
63
+ "@aooth/auth": "0.1.49",
64
+ "@aooth/user": "0.1.49",
65
+ "@aooth/idp": "0.1.49"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@atscript/core": "^0.1.82",
@@ -1036,7 +1036,9 @@ export interface ProveControlOtpForm {
1036
1036
  * 'Deny' action 302s the client back with `error=access_denied`. The requesting
1037
1037
  * client + scope + validated redirect host ride the `@wf.context.pass 'public'`
1038
1038
  * `ctx.public.authz` whitelist (display-only — the handle / approval gate stay
1039
- * server-side). `clientName` is REGISTRANT-SUPPLIED text (a DCR client names
1039
+ * server-side); on a silent (consent-only) run the acting identity rides the
1040
+ * same whitelist (`signedInAs`) and renders as a "Signed in as …" line so the
1041
+ * user can catch a wrong-account grant. `clientName` is REGISTRANT-SUPPLIED text (a DCR client names
1040
1042
  * itself), so the copy pairs it with the validated redirect host — where the
1041
1043
  * code is actually delivered, which a self-chosen name can't fake — and the
1042
1044
  * `ui.paragraph` renderer emits a TEXT node (never markup/links), so a
@@ -1050,6 +1052,11 @@ export interface AuthorizeConsentForm {
1050
1052
  @ui.form.fn.value '(_, _d, ctx) => { const a = ctx.public?.authz; const host = a?.clientName && a?.redirectHost ? " (" + a.redirectHost + ")" : ""; const who = a?.clientName ? "“" + a.clientName + "”" + host : "A local application"; const sc = a?.scope ? " It is requesting access to: " + a.scope + "." : ""; return who + " wants to sign in to your account." + sc + " Authorize this only if you started it."; }'
1051
1053
  notice: ui.paragraph
1052
1054
 
1055
+ @ui.form.order 2
1056
+ @ui.form.fn.hidden '(_, _d, ctx) => !ctx.public?.authz?.signedInAs'
1057
+ @ui.form.fn.value '(_, _d, ctx) => "Signed in as " + (ctx.public?.authz?.signedInAs || "") + "."'
1058
+ signedIn: ui.paragraph
1059
+
1053
1060
  @ui.form.order 10
1054
1061
  @ui.form.action 'deny', 'Deny'
1055
1062
  @ui.form.attr 'align', 'center'
@@ -493,10 +493,11 @@ export declare class ProveControlOtpForm {
493
493
 
494
494
  /**
495
495
  * Atscript interface **AuthorizeConsentForm**
496
- * @see {@link ./forms.as:1048:18}
496
+ * @see {@link ./forms.as:1050:18}
497
497
  */
498
498
  export declare class AuthorizeConsentForm {
499
499
  // notice: ui.paragraph
500
+ // signedIn: ui.paragraph
500
501
  // deny: ui.action
501
502
  static __is_atscript_annotated_type: true
502
503
  static type: TAtscriptTypeObject<keyof AuthorizeConsentForm, AuthorizeConsentForm>