@aooth/auth-moost 0.1.47 → 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
@@ -1005,9 +1005,21 @@ interface TokenSuccess {
1005
1005
  access_token?: string;
1006
1006
  id_token?: string;
1007
1007
  expires_in?: number;
1008
+ /** Rotating refresh token — minted iff the grant's `TokenPolicy.refresh` opted in. */
1009
+ refresh_token?: string;
1008
1010
  /** The authenticated user id (`sub`) — convenience for a CLI; not part of the OIDC token response. */
1009
1011
  userId: string;
1010
1012
  }
1013
+ /** The `POST /auth/token` request body (RFC 6749 §4.1.3 / §6, form- or JSON-shaped). */
1014
+ interface TokenRequestBody {
1015
+ grant_type?: string;
1016
+ code?: string;
1017
+ code_verifier?: string;
1018
+ client_id?: string;
1019
+ client_secret?: string;
1020
+ refresh_token?: string;
1021
+ resource?: string | string[];
1022
+ }
1011
1023
  /** A minimal OIDC discovery document (`/.well-known/openid-configuration`). */
1012
1024
  interface OidcDiscoveryDocument {
1013
1025
  issuer: string;
@@ -1023,11 +1035,15 @@ interface OidcDiscoveryDocument {
1023
1035
  code_challenge_methods_supported: string[];
1024
1036
  token_endpoint_auth_methods_supported: string[];
1025
1037
  }
1026
- /** RFC 7591 §3.2.1 registration response — public client, so no secret fields. */
1038
+ /** RFC 7591 §3.2.1 registration response. Secret fields present iff a secret was issued. */
1027
1039
  interface ClientRegistrationSuccess {
1028
1040
  client_id: string;
1029
1041
  /** Seconds since epoch (the RFC's unit — NOT ms). */
1030
1042
  client_id_issued_at: number;
1043
+ /** The minted secret (`client_secret_post` registrations) — disclosed HERE and only here. */
1044
+ client_secret?: string;
1045
+ /** REQUIRED when a secret is issued; `0` ⇒ the secret does not expire. */
1046
+ client_secret_expires_at?: number;
1031
1047
  redirect_uris: string[];
1032
1048
  token_endpoint_auth_method: string;
1033
1049
  grant_types: string[];
@@ -1117,14 +1133,26 @@ declare class AuthorizeController {
1117
1133
  */
1118
1134
  protected scopesSupported(): string[] | undefined;
1119
1135
  authorize(responseType: string | undefined, redirectUri: string | undefined, clientId: string | undefined, state: string | undefined, codeChallenge: string | undefined, codeChallengeMethod: string | undefined, scope: string | undefined, nonce: string | undefined, resource: string | undefined): Promise<string>;
1120
- token(body: {
1121
- grant_type?: string;
1122
- code?: string;
1123
- code_verifier?: string;
1124
- client_id?: string;
1125
- client_secret?: string;
1126
- resource?: string | string[];
1127
- } | undefined): Promise<TokenSuccess | TokenError>;
1136
+ token(body: TokenRequestBody | undefined): Promise<TokenSuccess | TokenError>;
1137
+ /**
1138
+ * `grant_type=refresh_token` (OAuth 2.1 §4.3): rotate the presented refresh
1139
+ * token into a fresh access + refresh pair. Only a family minted BY this
1140
+ * token endpoint for a registered client redeems here — the
1141
+ * `metadata.authzClientId` stamp is the binding, checked BEFORE any rotation
1142
+ * (so a browser-session refresh token, or another client's, is a plain
1143
+ * `invalid_grant` with the family untouched). Client authentication mirrors
1144
+ * the code branch; the grant's authority (kind, payload, per-mint ttl) rides
1145
+ * the credential family — nothing is re-derived here. Reuse of an
1146
+ * already-rotated token revokes the whole family inside the session layer
1147
+ * (the standard theft response) and surfaces as `invalid_grant`.
1148
+ */
1149
+ protected refreshTokenGrant(body: TokenRequestBody): Promise<TokenSuccess | TokenError>;
1150
+ /**
1151
+ * Client authentication shared by both grant branches (RFC 6749 §2.3):
1152
+ * `true` iff the policy accepts the presented credentials (or defines no
1153
+ * `authenticateClient` hook). Callers map `false` to `401 invalid_client`.
1154
+ */
1155
+ protected clientAuthenticates(clientId: string, clientSecret: string | undefined): Promise<boolean>;
1128
1156
  /**
1129
1157
  * OIDC discovery (Tier 2). Derives every endpoint from the signer's `issuer`
1130
1158
  * (configured as `{origin}/auth`), so a relying `OidcProvider` configured with
@@ -1152,10 +1180,12 @@ declare class AuthorizeController {
1152
1180
  * RFC 7591 Dynamic Client Registration (OAUTH.md R2) — anonymous by spec;
1153
1181
  * 404 unless a registration operation is wired ({@link
1154
1182
  * getDynamicClientRegistration}). A thin HTTP adapter: validation, abuse
1155
- * knobs (guard / cap / never-used GC) and persistence live in
1156
- * `DynamicClientRegistration` (`@aooth/auth`). Public clients only — the
1157
- * response carries NO `client_secret` and NO `client_secret_expires_at`
1158
- * (RFC 7591 §3.2.1 requires them only when a secret is issued).
1183
+ * knobs (guard / cap / never-used GC), secret minting and persistence live
1184
+ * in `DynamicClientRegistration` (`@aooth/auth`). A `client_secret_post`
1185
+ * registration is echoed with its minted `client_secret` +
1186
+ * `client_secret_expires_at` — the ONE disclosure (only the hash is stored);
1187
+ * public (`"none"`) registrations carry neither field (RFC 7591 §3.2.1
1188
+ * requires them only when a secret is issued).
1159
1189
  */
1160
1190
  register(body: unknown): Promise<ClientRegistrationSuccess | ClientRegistrationFailure | TokenError>;
1161
1191
  /** The signer's public JWKS (Tier 2). 404 when no signer is wired. */
@@ -1491,6 +1521,42 @@ interface AuthWfFinalizePolicy {
1491
1521
  notifyNewDevice: boolean;
1492
1522
  redirect: LoginRedirect;
1493
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
+ }
1494
1560
  /** Login-time guards policy. */
1495
1561
  interface AuthWfGuardsPolicy {
1496
1562
  passwordInitial: boolean;
@@ -1918,15 +1984,17 @@ interface AuthWfPublicState {
1918
1984
  newPasswordRequired?: boolean;
1919
1985
  /**
1920
1986
  * Mirrors the display-only fields of `ctx.authz` — the requesting client's
1921
- * id/name, granted scope, and the VALIDATED redirect host (the trustworthy
1922
- * identity shown next to the attacker-choosable `clientName`), shown on the
1923
- * 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
1924
1991
  * server-only (never whitelisted onto the wire).
1925
1992
  */
1926
1993
  authz?: {
1927
1994
  clientName?: string;
1928
1995
  scope?: string;
1929
1996
  redirectHost?: string;
1997
+ signedInAs?: string;
1930
1998
  };
1931
1999
  }
1932
2000
  /** Unified workflow context shape — one type for all three flows. */
@@ -2027,6 +2095,20 @@ interface AuthWfCtx {
2027
2095
  scope?: string;
2028
2096
  redirectHost?: string;
2029
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;
2030
2112
  };
2031
2113
  /**
2032
2114
  * FE-facing surface — the ONLY top-level ctx key whitelisted on form
@@ -2580,6 +2662,18 @@ declare class AuthWorkflow {
2580
2662
  * emailVerifiedRequired). Reached from login.flow.
2581
2663
  */
2582
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>;
2583
2677
  /**
2584
2678
  * Resolve the session-policy (concurrency limit). Reached from login.flow.
2585
2679
  */
@@ -3042,7 +3136,34 @@ declare class AuthWorkflow {
3042
3136
  * clobber the user's live factor, by construction.
3043
3137
  */
3044
3138
  protected handleEnrollExit(ctx: AuthWfCtx, action: string | undefined): boolean;
3045
- 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>;
3046
3167
  initInviteAdmin(ctx: AuthWfCtx): void;
3047
3168
  initInviteAccept(ctx: AuthWfCtx): void;
3048
3169
  initRecovery(ctx: AuthWfCtx): void;
@@ -4077,4 +4198,4 @@ interface AuditEmitter {
4077
4198
  emit(event: AuditEvent): Promise<void> | void;
4078
4199
  }
4079
4200
  //#endregion
4080
- 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,16 +1,16 @@
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
- import { AuthCredential, AuthError, RateLimitStoreMemory, RateLimiter, RateLimiter as RateLimiter$1, generateMagicLinkToken, parseRateLimitRule } from "@aooth/auth";
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";
5
5
  import { HttpError, useAuthorization, useCookies, useHeaders, useRequest, useResponse, useUrlParams } from "@wooksjs/event-http";
6
6
  import { ArbacAction, ArbacResource, getArbacMate, useArbac } from "@aooth/arbac-moost";
7
7
  import { FederatedIdentityStore, SEEN_DEVICES_DEFAULT_CAP, UserAuthError, UserService, generateMfaCode, generateTotpSecret, generateTotpUri, maskEmail, maskPhone, pickDefinedProfile, verifyTotpCode } from "@aooth/user";
8
8
  import { Body, Delete, Get, HttpError as HttpError$1, Post, Query } from "@moostjs/event-http";
9
- import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
9
+ import { createHash, timingSafeEqual } from "node:crypto";
10
10
  import { createAsHttpOutlet, finishWf, handleAsOutletRequest, useAtscriptWf } from "@atscript/moost-wf";
11
11
  import { EncapsulatedStateStrategy, MoostWf, Step, StepRetriableError, StepTTL, Workflow, WorkflowParam, WorkflowSchema, createEmailOutlet, outletEmail, swapStrategy, useWfFinished, useWfState } from "@moostjs/event-wf";
12
12
  import { FederatedLoginService, OAuthError, OAuthProviderRegistry, generateRandomState, pkceChallengeFor } from "@aooth/idp";
13
- import { ClientRegistrationError, DynamicClientRegistration, NoopOidcClaimsResolver, buildAuthorizationServerMetadata, buildAuthorizationServerMetadata as buildAuthorizationServerMetadata$1, buildProtectedResourceMetadata, buildWwwAuthenticateBearerChallenge, canonicalizeIssuer, canonicalizeIssuer as canonicalizeIssuer$1 } from "@aooth/auth/authz";
13
+ import { ClientRegistrationError, DynamicClientRegistration, NoopOidcClaimsResolver, buildAuthorizationServerMetadata, buildAuthorizationServerMetadata as buildAuthorizationServerMetadata$1, buildProtectedResourceMetadata, buildWwwAuthenticateBearerChallenge, canonicalizeIssuer, canonicalizeIssuer as canonicalizeIssuer$1, tokenPolicyToIssueOptions } from "@aooth/auth/authz";
14
14
  //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
15
15
  function __decorate(decorators, target, key, desc) {
16
16
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -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,
@@ -7029,7 +7103,7 @@ let AuthorizeController = class AuthorizeController {
7029
7103
  if (resource !== void 0) {
7030
7104
  if (useUrlParams(current()).params().getAll("resource").length > 1 || resource.length > 2e3) return this.redirectError(resolved.redirectUri, "invalid_target", state);
7031
7105
  }
7032
- const binding = randomBytes(32).toString("base64url");
7106
+ const binding = generateOpaqueToken();
7033
7107
  const { handle, expiresAt } = await this.pending.create({
7034
7108
  ...resolved.clientId !== void 0 && { clientId: resolved.clientId },
7035
7109
  ...resolved.clientName !== void 0 && { clientName: resolved.clientName },
@@ -7057,6 +7131,7 @@ let AuthorizeController = class AuthorizeController {
7057
7131
  return "";
7058
7132
  }
7059
7133
  async token(body) {
7134
+ if (body?.grant_type === "refresh_token") return await this.refreshTokenGrant(body);
7060
7135
  const res = useResponse(current());
7061
7136
  if (body?.grant_type !== "authorization_code") {
7062
7137
  res.status = 400;
@@ -7080,12 +7155,7 @@ let AuthorizeController = class AuthorizeController {
7080
7155
  res.status = 401;
7081
7156
  return { error: "invalid_client" };
7082
7157
  }
7083
- try {
7084
- await this.policy.authenticateClient?.({
7085
- clientId: row.clientId,
7086
- ...body.client_secret !== void 0 && { clientSecret: body.client_secret }
7087
- });
7088
- } catch {
7158
+ if (!await this.clientAuthenticates(row.clientId, body.client_secret)) {
7089
7159
  res.status = 401;
7090
7160
  return { error: "invalid_client" };
7091
7161
  }
@@ -7122,10 +7192,12 @@ let AuthorizeController = class AuthorizeController {
7122
7192
  }
7123
7193
  let accessToken;
7124
7194
  let expiresIn;
7195
+ let refreshToken;
7125
7196
  if (wantAccessToken) {
7126
- const issued = await this.auth.issue(row.userId, tokenPolicyToIssueOptions(row.tokenPolicy));
7197
+ const issued = await this.auth.issue(row.userId, tokenPolicyToIssueOptions(row.tokenPolicy, row.clientId));
7127
7198
  accessToken = issued.accessToken;
7128
- expiresIn = Math.max(0, Math.floor((issued.accessExpiresAt - Date.now()) / 1e3));
7199
+ expiresIn = expiresInSeconds(issued.accessExpiresAt);
7200
+ refreshToken = issued.refreshToken;
7129
7201
  }
7130
7202
  let idToken;
7131
7203
  if (signing) {
@@ -7144,11 +7216,73 @@ let AuthorizeController = class AuthorizeController {
7144
7216
  access_token: accessToken,
7145
7217
  expires_in: expiresIn
7146
7218
  },
7219
+ ...refreshToken !== void 0 && { refresh_token: refreshToken },
7147
7220
  ...idToken !== void 0 && { id_token: idToken },
7148
7221
  userId: row.userId
7149
7222
  };
7150
7223
  }
7151
7224
  /**
7225
+ * `grant_type=refresh_token` (OAuth 2.1 §4.3): rotate the presented refresh
7226
+ * token into a fresh access + refresh pair. Only a family minted BY this
7227
+ * token endpoint for a registered client redeems here — the
7228
+ * `metadata.authzClientId` stamp is the binding, checked BEFORE any rotation
7229
+ * (so a browser-session refresh token, or another client's, is a plain
7230
+ * `invalid_grant` with the family untouched). Client authentication mirrors
7231
+ * the code branch; the grant's authority (kind, payload, per-mint ttl) rides
7232
+ * the credential family — nothing is re-derived here. Reuse of an
7233
+ * already-rotated token revokes the whole family inside the session layer
7234
+ * (the standard theft response) and surfaces as `invalid_grant`.
7235
+ */
7236
+ async refreshTokenGrant(body) {
7237
+ const res = useResponse(current());
7238
+ if (typeof body.refresh_token !== "string" || body.refresh_token.length === 0) {
7239
+ res.status = 400;
7240
+ return { error: "invalid_request" };
7241
+ }
7242
+ const clientId = body.client_id;
7243
+ if (typeof clientId !== "string" || clientId.length === 0) {
7244
+ res.status = 401;
7245
+ return { error: "invalid_client" };
7246
+ }
7247
+ if (!await this.clientAuthenticates(clientId, body.client_secret)) {
7248
+ res.status = 401;
7249
+ return { error: "invalid_client" };
7250
+ }
7251
+ let issued;
7252
+ try {
7253
+ issued = await this.auth.refresh(body.refresh_token, { guard: (state) => {
7254
+ if (state.metadata?.authzClientId !== clientId) throw new Error("refresh token was not issued to this client");
7255
+ } });
7256
+ } catch {
7257
+ res.status = 400;
7258
+ return { error: "invalid_grant" };
7259
+ }
7260
+ res.status = 200;
7261
+ return {
7262
+ token_type: "Bearer",
7263
+ access_token: issued.accessToken,
7264
+ expires_in: expiresInSeconds(issued.accessExpiresAt),
7265
+ ...issued.refreshToken !== void 0 && { refresh_token: issued.refreshToken },
7266
+ userId: issued.userId
7267
+ };
7268
+ }
7269
+ /**
7270
+ * Client authentication shared by both grant branches (RFC 6749 §2.3):
7271
+ * `true` iff the policy accepts the presented credentials (or defines no
7272
+ * `authenticateClient` hook). Callers map `false` to `401 invalid_client`.
7273
+ */
7274
+ async clientAuthenticates(clientId, clientSecret) {
7275
+ try {
7276
+ await this.policy.authenticateClient?.({
7277
+ clientId,
7278
+ ...clientSecret !== void 0 && { clientSecret }
7279
+ });
7280
+ return true;
7281
+ } catch {
7282
+ return false;
7283
+ }
7284
+ }
7285
+ /**
7152
7286
  * OIDC discovery (Tier 2). Derives every endpoint from the signer's `issuer`
7153
7287
  * (configured as `{origin}/auth`), so a relying `OidcProvider` configured with
7154
7288
  * the same `issuer` resolves `/authorize`, `/token`, and `/jwks` automatically.
@@ -7172,7 +7306,7 @@ let AuthorizeController = class AuthorizeController {
7172
7306
  jwks_uri: `${iss}/jwks`,
7173
7307
  ...this.getDynamicClientRegistration() && { registration_endpoint: `${iss}/register` },
7174
7308
  response_types_supported: ["code"],
7175
- grant_types_supported: ["authorization_code"],
7309
+ grant_types_supported: ["authorization_code", "refresh_token"],
7176
7310
  subject_types_supported: ["public"],
7177
7311
  id_token_signing_alg_values_supported: [signer.alg],
7178
7312
  scopes_supported: [
@@ -7215,10 +7349,12 @@ let AuthorizeController = class AuthorizeController {
7215
7349
  * RFC 7591 Dynamic Client Registration (OAUTH.md R2) — anonymous by spec;
7216
7350
  * 404 unless a registration operation is wired ({@link
7217
7351
  * getDynamicClientRegistration}). A thin HTTP adapter: validation, abuse
7218
- * knobs (guard / cap / never-used GC) and persistence live in
7219
- * `DynamicClientRegistration` (`@aooth/auth`). Public clients only — the
7220
- * response carries NO `client_secret` and NO `client_secret_expires_at`
7221
- * (RFC 7591 §3.2.1 requires them only when a secret is issued).
7352
+ * knobs (guard / cap / never-used GC), secret minting and persistence live
7353
+ * in `DynamicClientRegistration` (`@aooth/auth`). A `client_secret_post`
7354
+ * registration is echoed with its minted `client_secret` +
7355
+ * `client_secret_expires_at` — the ONE disclosure (only the hash is stored);
7356
+ * public (`"none"`) registrations carry neither field (RFC 7591 §3.2.1
7357
+ * requires them only when a secret is issued).
7222
7358
  */
7223
7359
  async register(body) {
7224
7360
  const res = useResponse(current());
@@ -7240,6 +7376,10 @@ let AuthorizeController = class AuthorizeController {
7240
7376
  return {
7241
7377
  client_id: client.clientId,
7242
7378
  client_id_issued_at: Math.floor(client.createdAt / 1e3),
7379
+ ...client.clientSecret !== void 0 && {
7380
+ client_secret: client.clientSecret,
7381
+ client_secret_expires_at: client.clientSecretExpiresAt
7382
+ },
7243
7383
  redirect_uris: client.redirectUris,
7244
7384
  token_endpoint_auth_method: client.tokenEndpointAuthMethod,
7245
7385
  grant_types: client.grantTypes,
@@ -7355,13 +7495,9 @@ AuthorizeController = __decorate([
7355
7495
  Object
7356
7496
  ])
7357
7497
  ], AuthorizeController);
7358
- /** Flatten a {@link TokenPolicy} into the `issue()` options it forwards. */
7359
- function tokenPolicyToIssueOptions(policy) {
7360
- return {
7361
- ...policy.payload,
7362
- ...policy.kind !== void 0 && { kind: policy.kind },
7363
- ...policy.ttl !== void 0 && { ttl: policy.ttl }
7364
- };
7498
+ /** RFC 6749 `expires_in`: whole seconds from now until `expiresAt`, floored at 0. */
7499
+ function expiresInSeconds(expiresAt) {
7500
+ return Math.max(0, Math.floor((expiresAt - Date.now()) / 1e3));
7365
7501
  }
7366
7502
  //#endregion
7367
7503
  //#region src/workflows/auth-email-outlet.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aooth/auth-moost",
3
- "version": "0.1.47",
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.47",
63
- "@aooth/auth": "0.1.47",
64
- "@aooth/idp": "0.1.47",
65
- "@aooth/user": "0.1.47"
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>