@aooth/auth-moost 0.2.4 → 0.2.5
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/atscript/index.d.mts +27 -27
- package/dist/atscript/index.mjs +1 -1
- package/dist/{forms-C_VNxSDn.mjs → forms-D-MZTAyd.mjs} +23 -16
- package/dist/index.d.mts +150 -28
- package/dist/index.mjs +360 -173
- package/package.json +24 -24
- package/src/atscript/models/forms.as +29 -24
- package/src/atscript/models/forms.as.d.ts +27 -27
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as RemoveMfaConfirmForm, D as StepUpConfirmForm, E as SignupForm, O as TermsBumpForm, T as SetPasswordForm, _ as PasswordReauthForm, a as ConcurrencyLimitForm, b as ProveControlOtpForm, c as EnrollConfirmForm, d as InviteChooseUsernameForm, f as InviteForm, g as MfaCodeForm, h as ManageMfaForm, i as ChangePasswordForm, l as EnrollPickMethodForm, n as AskPhoneForm, o as EmailIdentifierForm, p as LoginCredentialsForm, r as AuthorizeConsentForm, s as EnrollAddressForm, t as AskEmailForm, u as EnrollTotpQrForm, v as PincodeForm, w as Select2faForm, y as ProveControlForm } from "./forms-
|
|
2
|
-
import { Controller, HandlerPaths, Inherit, Inject, InjectMoostLogger, Injectable, Intercept, MoostInit, Optional, Param, Resolve, TInterceptorPriority, defineAfterInterceptor, defineBeforeInterceptor, defineErrorInterceptor, getMoostMate, useControllerContext, useLogger } from "moost";
|
|
3
|
-
import { AuthCredential, AuthError, RateLimitStoreMemory, RateLimitStoreMemory as RateLimitStoreMemory$1, RateLimiter, RateLimiter as RateLimiter$1, generateMagicLinkToken, generateOpaqueToken, parseRateLimitRule, pickGoverning } from "@aooth/auth";
|
|
4
|
-
import { current, defineWook, eventTypeKey, key } from "@wooksjs/event-core";
|
|
1
|
+
import { C as RemoveMfaConfirmForm, D as StepUpConfirmForm, E as SignupForm, O as TermsBumpForm, T as SetPasswordForm, _ as PasswordReauthForm, a as ConcurrencyLimitForm, b as ProveControlOtpForm, c as EnrollConfirmForm, d as InviteChooseUsernameForm, f as InviteForm, g as MfaCodeForm, h as ManageMfaForm, i as ChangePasswordForm, l as EnrollPickMethodForm, n as AskPhoneForm, o as EmailIdentifierForm, p as LoginCredentialsForm, r as AuthorizeConsentForm, s as EnrollAddressForm, t as AskEmailForm, u as EnrollTotpQrForm, v as PincodeForm, w as Select2faForm, y as ProveControlForm } from "./forms-D-MZTAyd.mjs";
|
|
2
|
+
import { Controller, HandlerPaths, Inherit, Inject, InjectMoostLogger, Injectable, Intercept, MoostInit, Optional, Param, Resolve, TInterceptorPriority, defineAfterInterceptor, defineBeforeInterceptor, defineErrorInterceptor, formatMessage, getMoostMate, registerMessages, useControllerContext, useLogger, useTranslate } from "moost";
|
|
3
|
+
import { AuthCredential, AuthError, RATE_LIMIT_MESSAGES, RateLimitStoreMemory, RateLimitStoreMemory as RateLimitStoreMemory$1, RateLimiter, RateLimiter as RateLimiter$1, generateMagicLinkToken, generateOpaqueToken, parseRateLimitRule, pickGoverning } from "@aooth/auth";
|
|
4
|
+
import { current, defineWook, eventTypeKey, key, tryGetCurrent, useLocale } from "@wooksjs/event-core";
|
|
5
5
|
import { HttpError, resolveForwarded, useAuthorization, useCookies, useHeaders, useRequest, useResponse, useUrlParams } from "@wooksjs/event-http";
|
|
6
6
|
import { ArbacAction, ArbacResource, getArbacMate, useArbac } from "@aooth/arbac-moost";
|
|
7
|
-
import { FederatedIdentityStore, SEEN_DEVICES_DEFAULT_CAP, UserAuthError, UserService, generateMfaCode, generateTotpSecret, generateTotpUri, maskEmail, maskPhone, pickDefinedProfile, verifyTotpCode } from "@aooth/user";
|
|
7
|
+
import { FederatedIdentityStore, PASSWORD_POLICY_MESSAGES, SEEN_DEVICES_DEFAULT_CAP, USER_AUTH_ERROR_MESSAGES, 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
9
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
10
10
|
import { createAsHttpOutlet, finishWf, handleAsOutletRequest, useAtscriptWf } from "@atscript/moost-wf";
|
|
@@ -95,6 +95,61 @@ function resolveAuthOptions(opts = {}) {
|
|
|
95
95
|
exposeTokensInBody: opts.exposeTokensInBody ?? !enableCookie
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
+
// src/http-messages.ts
|
|
99
|
+
/**
|
|
100
|
+
* Code-keyed English templates of the `HttpError`s auth-moost raises outside
|
|
101
|
+
* the auth workflow (guard, controllers, `useAuth()`, the workflow trigger).
|
|
102
|
+
* Each error body carries the `code` and its `params`;
|
|
103
|
+
* `MoostHttp` translates it by code with the moost translator
|
|
104
|
+
* (`translateErrorBody`). Registered with `registerMessages` on import.
|
|
105
|
+
*
|
|
106
|
+
* The workflow's own texts are in `AOOTH_MESSAGES`; the rate limiter's 429
|
|
107
|
+
* (`RATE_LIMITED`) template is `RATE_LIMIT_MESSAGES` from `@aooth/auth`.
|
|
108
|
+
*/
|
|
109
|
+
const AOOTH_HTTP_MESSAGES = {
|
|
110
|
+
/** 401 — the guard found no credential on a protected route. */
|
|
111
|
+
AUTH_REQUIRED: "Unauthorized",
|
|
112
|
+
/** 401 — the guard's credential is invalid, expired or revoked. */
|
|
113
|
+
CREDENTIAL_INVALID: "Invalid credential",
|
|
114
|
+
/** 401 — `useAuth().getUserId()` and `AuthController` routes without a signed-in user. */
|
|
115
|
+
NOT_AUTHENTICATED: "Not authenticated",
|
|
116
|
+
/** 401 — "log out other sessions" without a current session. */
|
|
117
|
+
NO_CURRENT_SESSION: "No current session to keep",
|
|
118
|
+
/** 401 — `POST /auth/refresh` without a refresh token. */
|
|
119
|
+
MISSING_REFRESH_TOKEN: "Missing refresh token",
|
|
120
|
+
/** 401 — `POST /auth/refresh` with an unknown, expired or reused refresh token. */
|
|
121
|
+
INVALID_REFRESH_TOKEN: "Invalid refresh token",
|
|
122
|
+
/** 400 — `DELETE /auth/sessions` without `?others=true`. */
|
|
123
|
+
LOGOUT_OTHERS_REQUIRED: "Pass ?others=true to log out other sessions",
|
|
124
|
+
/** 404 — `GET /auth/invite/post-redemption` for an unknown or still pending invite. */
|
|
125
|
+
INVITE_NOT_FOUND: "Invite not found",
|
|
126
|
+
/** 400 — `GET /auth/invite/post-redemption` without `uid`. */
|
|
127
|
+
MISSING_UID: "Missing uid query parameter",
|
|
128
|
+
/** 404 — unlinking an identity the user does not have. */
|
|
129
|
+
LINKED_IDENTITY_NOT_FOUND: "Linked identity not found",
|
|
130
|
+
/** 409 — unlinking the user's only sign-in method. */
|
|
131
|
+
LAST_SIGN_IN_METHOD: "Cannot remove your only sign-in method. Set a password first, or link another provider.",
|
|
132
|
+
/** 404 — unlinking an identity of an unconfigured provider. Params: `provider`. */
|
|
133
|
+
UNKNOWN_PROVIDER: "Unknown provider '{provider}'",
|
|
134
|
+
/** 403 — the workflow trigger refused a workflow outside its allow list. Params: `workflow`. */
|
|
135
|
+
WORKFLOW_NOT_ALLOWED: "Workflow '{workflow}' is not allowed"
|
|
136
|
+
};
|
|
137
|
+
registerMessages(AOOTH_HTTP_MESSAGES);
|
|
138
|
+
/** An `HttpError` with `code`, `params` and the code's English text. */
|
|
139
|
+
function aoothHttpError(status, code, params) {
|
|
140
|
+
return codedHttpError(status, code, formatMessage(AOOTH_HTTP_MESSAGES[code], params), params);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* An `HttpError` whose body carries the message `code` and `params` next to
|
|
144
|
+
* its text, so `MoostHttp` can translate it by code.
|
|
145
|
+
*/
|
|
146
|
+
function codedHttpError(status, code, message, params) {
|
|
147
|
+
return new HttpError(status, {
|
|
148
|
+
message,
|
|
149
|
+
code,
|
|
150
|
+
...params && { params }
|
|
151
|
+
});
|
|
152
|
+
}
|
|
98
153
|
// src/auth.composables.ts
|
|
99
154
|
const authContextKey = key("auth.context");
|
|
100
155
|
const authCredentialKey = key("auth.credential");
|
|
@@ -152,7 +207,7 @@ const useAuth = defineWook((ctx) => {
|
|
|
152
207
|
};
|
|
153
208
|
const getUserId = () => {
|
|
154
209
|
const auth = getAuthContext();
|
|
155
|
-
if (!auth) throw
|
|
210
|
+
if (!auth) throw aoothHttpError(401, "NOT_AUTHENTICATED");
|
|
156
211
|
return auth.userId;
|
|
157
212
|
};
|
|
158
213
|
const isAuthenticated = () => getAuthContext() !== null;
|
|
@@ -165,7 +220,7 @@ const useAuth = defineWook((ctx) => {
|
|
|
165
220
|
const revokeSession = (sessionId) => requireCredential().revokeSession(getUserId(), sessionId);
|
|
166
221
|
const revokeOtherSessions = () => {
|
|
167
222
|
const sessionId = getSessionId();
|
|
168
|
-
if (!sessionId) throw
|
|
223
|
+
if (!sessionId) throw aoothHttpError(401, "NO_CURRENT_SESSION");
|
|
169
224
|
return requireCredential().revokeOtherSessions(getUserId(), sessionId);
|
|
170
225
|
};
|
|
171
226
|
let cachedOptions;
|
|
@@ -328,7 +383,7 @@ function authGuardInterceptor(opts) {
|
|
|
328
383
|
setAuthContext(ctx, null);
|
|
329
384
|
return;
|
|
330
385
|
}
|
|
331
|
-
throw
|
|
386
|
+
throw aoothHttpError(401, "AUTH_REQUIRED");
|
|
332
387
|
}
|
|
333
388
|
const credential = await cc.instantiate(AuthCredential);
|
|
334
389
|
setAuthCredential(ctx, credential);
|
|
@@ -338,7 +393,7 @@ function authGuardInterceptor(opts) {
|
|
|
338
393
|
setAuthContext(ctx, null);
|
|
339
394
|
return;
|
|
340
395
|
}
|
|
341
|
-
throw
|
|
396
|
+
throw aoothHttpError(401, "CREDENTIAL_INVALID");
|
|
342
397
|
}
|
|
343
398
|
setAuthContext(ctx, authContext);
|
|
344
399
|
}, TInterceptorPriority.GUARD);
|
|
@@ -424,6 +479,7 @@ function useRateLimit(ctx = current()) {
|
|
|
424
479
|
return { decision: ctx.has(rateLimitDecisionKey) ? ctx.get(rateLimitDecisionKey) : null };
|
|
425
480
|
}
|
|
426
481
|
// src/rate-limit/interceptor.ts
|
|
482
|
+
registerMessages(RATE_LIMIT_MESSAGES);
|
|
427
483
|
/**
|
|
428
484
|
* Global interceptor PAIR enforcing `@RateLimit` metadata (RL.spec.md §5.2)
|
|
429
485
|
* — register with spread:
|
|
@@ -535,11 +591,7 @@ function rateLimitInterceptors(opts) {
|
|
|
535
591
|
}
|
|
536
592
|
if (!decision.allowed) {
|
|
537
593
|
response.setHeader("retry-after", String(Math.ceil(decision.resetAfterMs / 1e3)));
|
|
538
|
-
throw
|
|
539
|
-
message: decision.message ?? "Too many requests",
|
|
540
|
-
code: decision.code ?? "RATE_LIMITED",
|
|
541
|
-
...decision.params && { params: decision.params }
|
|
542
|
-
});
|
|
594
|
+
throw codedHttpError(429, decision.code ?? "RATE_LIMITED", decision.message ?? formatMessage(RATE_LIMIT_MESSAGES.RATE_LIMITED, decision.params), decision.params);
|
|
543
595
|
}
|
|
544
596
|
};
|
|
545
597
|
return [defineBeforeInterceptor(() => evaluate("pre"), TInterceptorPriority.BEFORE_GUARD), defineBeforeInterceptor(() => evaluate("post"), TInterceptorPriority.AFTER_GUARD)];
|
|
@@ -641,6 +693,28 @@ function createInviteOutlet() {
|
|
|
641
693
|
}
|
|
642
694
|
};
|
|
643
695
|
}
|
|
696
|
+
// src/workflow/public-projection.ts
|
|
697
|
+
/**
|
|
698
|
+
* `ctx.public` — the form-facing projection `AuthWorkflow` rebuilds before
|
|
699
|
+
* every pause, in the request's language — is a per-response render value,
|
|
700
|
+
* not workflow state. `WfTriggerProvider` strips it before a paused state is
|
|
701
|
+
* persisted (store-backed and token-backed alike), so the state never carries
|
|
702
|
+
* rendered (translated) text. Only projections built by `AuthWorkflow` are
|
|
703
|
+
* stripped: an app's own `public` context key is left alone.
|
|
704
|
+
*/
|
|
705
|
+
const projections = /* @__PURE__ */ new WeakSet();
|
|
706
|
+
/** Marks `projection` as `AuthWorkflow`'s rendered `ctx.public`. */
|
|
707
|
+
function markPublicProjection(projection) {
|
|
708
|
+
projections.add(projection);
|
|
709
|
+
}
|
|
710
|
+
/** `context` without its rendered `public` projection (the same object when there is none). */
|
|
711
|
+
function withoutPublicProjection(context) {
|
|
712
|
+
if (!context || typeof context !== "object") return context;
|
|
713
|
+
const pub = context.public;
|
|
714
|
+
if (!pub || typeof pub !== "object" || !projections.has(pub)) return context;
|
|
715
|
+
const { public: _projection, ...rest } = context;
|
|
716
|
+
return rest;
|
|
717
|
+
}
|
|
644
718
|
// \0@oxc-project+runtime@0.155.0/helpers/esm/decorateMetadata.js
|
|
645
719
|
function __decorateMetadata(k, v) {
|
|
646
720
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
@@ -684,7 +758,7 @@ function normalizeWfId(id) {
|
|
|
684
758
|
return id.replace(/^\/+/, "");
|
|
685
759
|
}
|
|
686
760
|
function notAllowed(id) {
|
|
687
|
-
return
|
|
761
|
+
return aoothHttpError(403, "WORKFLOW_NOT_ALLOWED", { workflow: normalizeWfId(id) });
|
|
688
762
|
}
|
|
689
763
|
/**
|
|
690
764
|
* Wrap a strategy so a resume is checked against the allow list BEFORE the
|
|
@@ -836,6 +910,11 @@ let WfTriggerProvider = class WfTriggerProvider {
|
|
|
836
910
|
const value = opts[name] ?? base[name];
|
|
837
911
|
if (value !== void 0) hooks[name] = value;
|
|
838
912
|
}
|
|
913
|
+
const beforePersist = opts.beforePersist ?? base.beforePersist;
|
|
914
|
+
hooks.beforePersist = (state, pause) => {
|
|
915
|
+
state.context = withoutPublicProjection(state.context);
|
|
916
|
+
return beforePersist?.(state, pause);
|
|
917
|
+
};
|
|
839
918
|
const around = opts.around ?? base.around;
|
|
840
919
|
return handleAsOutletRequest({
|
|
841
920
|
...hooks,
|
|
@@ -1107,7 +1186,133 @@ let OAuthRuntime = class OAuthRuntime {
|
|
|
1107
1186
|
}
|
|
1108
1187
|
};
|
|
1109
1188
|
OAuthRuntime = __decorate([Injectable(), __decorateMetadata("design:paramtypes", [typeof OAuthProviderRegistry === "undefined" ? Object : OAuthProviderRegistry, typeof FederatedLoginService === "undefined" ? Object : FederatedLoginService])], OAuthRuntime);
|
|
1189
|
+
// src/workflow/auth-messages.ts
|
|
1190
|
+
/**
|
|
1191
|
+
* Code-keyed catalogue of every user-facing text `AuthWorkflow` produces —
|
|
1192
|
+
* form errors, banners, finish envelopes and button labels. Templates are
|
|
1193
|
+
* English; `{name}` placeholders are filled from the message params.
|
|
1194
|
+
*
|
|
1195
|
+
* Registered with moost's `registerMessages` on import, so a moost translator
|
|
1196
|
+
* (`setTranslator`) translates every code and `$i18n` serves the templates.
|
|
1197
|
+
* Override per app with `AuthWorkflowOpts.messages` (a partial map, or a
|
|
1198
|
+
* function that receives the code and params and returns the text), or
|
|
1199
|
+
* override `AuthWorkflow.msg()`.
|
|
1200
|
+
*/
|
|
1201
|
+
const AOOTH_MESSAGES = {
|
|
1202
|
+
INVALID_CREDENTIALS: "Invalid credentials",
|
|
1203
|
+
ACCOUNT_LOCKED: "Account locked, please try again later",
|
|
1204
|
+
INVALID_PASSWORD: "Invalid password",
|
|
1205
|
+
INCORRECT_PASSWORD: "Incorrect password",
|
|
1206
|
+
SESSION_LIMIT_REACHED: "Session limit reached",
|
|
1207
|
+
PASSWORD_CHANGED_SIGN_IN_AGAIN: "Your password was changed. Please sign in again.",
|
|
1208
|
+
INVALID_CODE: "Invalid code",
|
|
1209
|
+
CODE_EXPIRED: "Code expired",
|
|
1210
|
+
TOO_MANY_CODE_ATTEMPTS: "Too many invalid attempts. Please request a new code.",
|
|
1211
|
+
/** Params: `seconds`. */
|
|
1212
|
+
RESEND_WAIT: "Please wait {seconds}s before requesting a new code.",
|
|
1213
|
+
/** Params: `seconds`. */
|
|
1214
|
+
RESEND_WAIT_ANOTHER: "Please wait {seconds}s before requesting another code",
|
|
1215
|
+
/** Params: `seconds`, `channel` (`SMS` / `email`). */
|
|
1216
|
+
RESEND_WAIT_CHANNEL: "Please wait {seconds}s before requesting another {channel} code",
|
|
1217
|
+
TOTP_RESEND_NOT_APPLICABLE: "Resend is not applicable for TOTP",
|
|
1218
|
+
/** HTTP 400 — a TOTP code submitted for an account without TOTP. */
|
|
1219
|
+
TOTP_NOT_CONFIGURED: "No TOTP MFA configured",
|
|
1220
|
+
ADDRESS_REQUIRED: "This field is required",
|
|
1221
|
+
INVALID_EMAIL_ADDRESS: "Enter a valid email address",
|
|
1222
|
+
INVALID_PHONE_NUMBER: "Enter a valid phone number",
|
|
1223
|
+
OTP_DISCLOSURE_EMAIL: "By providing your email address, you consent to receive one-time security codes from us via email. Standard email delivery may apply.",
|
|
1224
|
+
OTP_DISCLOSURE_PHONE: "By providing your phone number, you consent to receive one-time security codes from us via SMS. Message and data rates may apply.",
|
|
1225
|
+
UNKNOWN_MFA_METHOD: "Unknown MFA method",
|
|
1226
|
+
UNKNOWN_METHOD: "Unknown method",
|
|
1227
|
+
METHOD_UNAVAILABLE: "That method isn't available",
|
|
1228
|
+
METHOD_NOT_CHANGEABLE: "That method can't be changed here.",
|
|
1229
|
+
KEEP_ONE_MFA_METHOD: "You must keep at least one two-factor method.",
|
|
1230
|
+
CHOOSE_OPTION: "Choose an option",
|
|
1231
|
+
ALL_MFA_METHODS_SET_UP: "You've already set up every available authentication method.",
|
|
1232
|
+
NO_MFA_CHANGES: "No changes were made to your two-factor methods.",
|
|
1233
|
+
LAST_MFA_METHOD_NOT_REMOVABLE: "You must keep at least one two-factor method, so this one can't be removed.",
|
|
1234
|
+
MFA_METHOD_TOTP: "Authenticator app",
|
|
1235
|
+
MFA_METHOD_EMAIL: "Email code",
|
|
1236
|
+
MFA_METHOD_SMS: "Text-message code",
|
|
1237
|
+
/** Params: `method` (the method's label). */
|
|
1238
|
+
MFA_METHOD_ADDED: "{method} added.",
|
|
1239
|
+
/** Params: `method`. */
|
|
1240
|
+
MFA_METHOD_UPDATED: "{method} updated.",
|
|
1241
|
+
/** Params: `method`. */
|
|
1242
|
+
MFA_METHOD_REMOVED: "{method} removed.",
|
|
1243
|
+
PASSWORDS_DO_NOT_MATCH: "Passwords do not match",
|
|
1244
|
+
PASSWORD_CHANGE_TOO_RECENT: "You changed your password too recently. Please try again later.",
|
|
1245
|
+
PASSWORD_CHANGED: "Your password has been changed.",
|
|
1246
|
+
PASSWORD_UPDATED_REDIRECTING: "Password updated. Redirecting to sign-in…",
|
|
1247
|
+
PASSWORD_UPDATED_STILL_LOCKED: "Password updated, but your account is still locked. Contact an administrator to regain access.",
|
|
1248
|
+
CHANGE_PASSWORD_HEADING: "Change your password",
|
|
1249
|
+
CHANGE_PASSWORD_INTRO: "Enter your current password, then choose a new one.",
|
|
1250
|
+
SET_PASSWORD_EXPIRED_HEADING: "Your password has expired",
|
|
1251
|
+
SET_PASSWORD_EXPIRED_INTRO: "Choose a new password to continue. The previous one is no longer valid.",
|
|
1252
|
+
SET_PASSWORD_RESET_HEADING: "Reset your password",
|
|
1253
|
+
SET_PASSWORD_RESET_INTRO: "Choose a new password for your account.",
|
|
1254
|
+
SET_PASSWORD_INVITE_HEADING: "Welcome — set your password",
|
|
1255
|
+
SET_PASSWORD_INVITE_INTRO: "Choose a password to activate your account.",
|
|
1256
|
+
SET_PASSWORD_INITIAL_HEADING: "Set your initial password",
|
|
1257
|
+
SET_PASSWORD_INITIAL_INTRO: "Your account was created without a password. Choose one to continue.",
|
|
1258
|
+
RECOVERY_INSTRUCTIONS_SENT: "If an account exists, you will receive instructions.",
|
|
1259
|
+
SIGNUP_DISABLED: "Self-signup is currently disabled.",
|
|
1260
|
+
ALREADY_HAVE_ACCOUNT: "You already have an account. Please sign in.",
|
|
1261
|
+
ACCOUNT_LINKED: "Account linked.",
|
|
1262
|
+
/** HTTP 400 — the SSO alt action named a provider that is not offered. */
|
|
1263
|
+
UNKNOWN_SSO_PROVIDER: "Unknown SSO provider",
|
|
1264
|
+
ACCOUNT_CREATED: "Your account has been created.",
|
|
1265
|
+
INVALID_ROLE: "Invalid role",
|
|
1266
|
+
INVITE_ALREADY_PENDING: "Invite already pending",
|
|
1267
|
+
USER_ALREADY_EXISTS: "User already exists",
|
|
1268
|
+
DUPLICATE_INVITE_REJECTED: "Duplicate invite rejected",
|
|
1269
|
+
INVITE_CANCELLED: "This invite has been cancelled",
|
|
1270
|
+
INVITE_REPLACED: "This invite was replaced by a newer one",
|
|
1271
|
+
INVITE_ALREADY_ACCEPTED: "This invite was already accepted.",
|
|
1272
|
+
CHOOSE_USERNAME_TAKEN: "This username is taken",
|
|
1273
|
+
USERNAME_NOT_ALLOWED: "This username is not allowed",
|
|
1274
|
+
AUTHZ_EXPIRED: "Authorization request expired. Please try again.",
|
|
1275
|
+
AUTHZ_BROWSER_MISMATCH: "This authorization could not be verified for your browser. Please start again.",
|
|
1276
|
+
AUTHZ_FAILED: "Authorization could not be completed. Please start again.",
|
|
1277
|
+
GO_TO_SIGN_IN: "Go to sign-in",
|
|
1278
|
+
BACK_TO_SIGN_IN: "Back to sign-in",
|
|
1279
|
+
REQUEST_NEW_INVITE: "Request a new invite",
|
|
1280
|
+
BACK: "Back",
|
|
1281
|
+
GO_NOW: "Go now"
|
|
1282
|
+
};
|
|
1283
|
+
registerMessages(AOOTH_MESSAGES);
|
|
1284
|
+
/** Fill `{name}` placeholders from `params`; unknown placeholders are kept. */
|
|
1285
|
+
function renderAoothMessage(template, params) {
|
|
1286
|
+
return formatMessage(template, params);
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Resolve `code`: `messages` (the app's override, when given), then moost's
|
|
1290
|
+
* translator in the current event's locale (`useTranslate`), then the English
|
|
1291
|
+
* template. Outside an event the translator is skipped.
|
|
1292
|
+
*/
|
|
1293
|
+
function resolveAoothMessage(code, params = {}, messages) {
|
|
1294
|
+
if (typeof messages === "function") {
|
|
1295
|
+
const text = messages(code, params);
|
|
1296
|
+
if (text !== void 0) return text;
|
|
1297
|
+
} else if (messages?.[code] !== void 0) return renderAoothMessage(messages[code], params);
|
|
1298
|
+
return translateCode(code, params, renderAoothMessage(AOOTH_MESSAGES[code], params));
|
|
1299
|
+
}
|
|
1300
|
+
/** The current event's locale (`useLocale()`); `undefined` outside an event. */
|
|
1301
|
+
function currentLocale() {
|
|
1302
|
+
const event = tryGetCurrent();
|
|
1303
|
+
return event ? useLocale(event).get() : void 0;
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* `code` through moost's translator in the current event's locale, else
|
|
1307
|
+
* `english` (the filled English text). Outside an event: `english`.
|
|
1308
|
+
*/
|
|
1309
|
+
function translateCode(code, params, english) {
|
|
1310
|
+
const event = tryGetCurrent();
|
|
1311
|
+
return event ? useTranslate(event)(code, params, english) : english;
|
|
1312
|
+
}
|
|
1110
1313
|
// src/user-errors.ts
|
|
1314
|
+
registerMessages(PASSWORD_POLICY_MESSAGES);
|
|
1315
|
+
registerMessages(USER_AUTH_ERROR_MESSAGES);
|
|
1111
1316
|
const STATUS = {
|
|
1112
1317
|
NOT_FOUND: 404,
|
|
1113
1318
|
ALREADY_EXISTS: 409,
|
|
@@ -1157,13 +1362,45 @@ function userAuthErrorToHttp(err) {
|
|
|
1157
1362
|
const field = userAuthErrorField(err.type);
|
|
1158
1363
|
const policies = err.type === "POLICY_VIOLATION" ? err.details?.policies : void 0;
|
|
1159
1364
|
return new HttpError(STATUS[err.type], {
|
|
1160
|
-
message: err
|
|
1365
|
+
message: userAuthErrorText(err),
|
|
1161
1366
|
code: err.type,
|
|
1162
1367
|
...policies !== void 0 && { params: { policies } },
|
|
1163
1368
|
...field && { field }
|
|
1164
1369
|
});
|
|
1165
1370
|
}
|
|
1166
1371
|
/**
|
|
1372
|
+
* A policy's texts in the request's locale (moost translator): `errorMessage`
|
|
1373
|
+
* by its `code`, `description` by `${code}_DESCRIPTION` — by the text itself
|
|
1374
|
+
* when the policy has no code. Unchanged without a translation.
|
|
1375
|
+
*/
|
|
1376
|
+
function translatePolicyTexts(policy) {
|
|
1377
|
+
const { code, params, description, errorMessage } = policy;
|
|
1378
|
+
const out = { ...policy };
|
|
1379
|
+
if (description) out.description = translateCode(code ? `${code}_DESCRIPTION` : description, params, description);
|
|
1380
|
+
if (errorMessage) out.errorMessage = translatePolicyError(policy);
|
|
1381
|
+
return out;
|
|
1382
|
+
}
|
|
1383
|
+
/** A policy's `errorMessage` in the request's locale, by its `code` (or the text itself). */
|
|
1384
|
+
function translatePolicyError({ code, params, errorMessage }) {
|
|
1385
|
+
return errorMessage && translateCode(code ?? errorMessage, params, errorMessage);
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* A `UserAuthError`'s text in the request's locale: a `POLICY_VIOLATION` lists
|
|
1389
|
+
* its failed policies' translated `errorMessage`s (`; `-joined, like the
|
|
1390
|
+
* English message) when at least one of them has a translation; otherwise —
|
|
1391
|
+
* and for any other type — the error is translated by its type, its own
|
|
1392
|
+
* message the fallback.
|
|
1393
|
+
*/
|
|
1394
|
+
function userAuthErrorText(err) {
|
|
1395
|
+
const policies = err.type === "POLICY_VIOLATION" ? err.details?.policies : void 0;
|
|
1396
|
+
const failed = Array.isArray(policies) ? policies.filter((p) => p?.passed === false) : [];
|
|
1397
|
+
if (failed.length > 0 && failed.every((p) => typeof p.errorMessage === "string")) {
|
|
1398
|
+
const texts = failed.map((p) => translatePolicyError(p));
|
|
1399
|
+
if (texts.some((text, i) => text !== failed[i].errorMessage)) return texts.join("; ");
|
|
1400
|
+
}
|
|
1401
|
+
return translateCode(err.type, void 0, err.message);
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1167
1404
|
* Error interceptor answering every `UserAuthError` a handler throws with
|
|
1168
1405
|
* {@link userAuthErrorToHttp}; other errors pass through. Attach it per
|
|
1169
1406
|
* controller (or per handler) where `UserService` errors should become 4xx
|
|
@@ -1183,78 +1420,6 @@ function userAuthErrorToHttp(err) {
|
|
|
1183
1420
|
const userAuthErrorInterceptor = defineErrorInterceptor((error, reply) => {
|
|
1184
1421
|
if (error instanceof UserAuthError) reply(userAuthErrorToHttp(error));
|
|
1185
1422
|
}, TInterceptorPriority.CATCH_ERROR);
|
|
1186
|
-
// src/workflow/auth-messages.ts
|
|
1187
|
-
/**
|
|
1188
|
-
* Code-keyed catalogue of every user-facing text `AuthWorkflow` produces —
|
|
1189
|
-
* form errors, banners, finish envelopes and button labels. Templates are
|
|
1190
|
-
* English; `{name}` placeholders are filled from the message params.
|
|
1191
|
-
*
|
|
1192
|
-
* Override per app with `AuthWorkflowOpts.messages` (a partial map, or a
|
|
1193
|
-
* function that receives the code and params and returns the text — e.g. a
|
|
1194
|
-
* lookup in your own i18n library), or override `AuthWorkflow.msg()`.
|
|
1195
|
-
*/
|
|
1196
|
-
const AOOTH_MESSAGES = {
|
|
1197
|
-
INVALID_CREDENTIALS: "Invalid credentials",
|
|
1198
|
-
ACCOUNT_LOCKED: "Account locked, please try again later",
|
|
1199
|
-
INVALID_PASSWORD: "Invalid password",
|
|
1200
|
-
INCORRECT_PASSWORD: "Incorrect password",
|
|
1201
|
-
SESSION_LIMIT_REACHED: "Session limit reached",
|
|
1202
|
-
PASSWORD_CHANGED_SIGN_IN_AGAIN: "Your password was changed. Please sign in again.",
|
|
1203
|
-
INVALID_CODE: "Invalid code",
|
|
1204
|
-
/** Params: `seconds`. */
|
|
1205
|
-
RESEND_WAIT: "Please wait {seconds}s before requesting a new code.",
|
|
1206
|
-
/** Params: `seconds`. */
|
|
1207
|
-
RESEND_WAIT_ANOTHER: "Please wait {seconds}s before requesting another code",
|
|
1208
|
-
/** Params: `seconds`, `channel` (`SMS` / `email`). */
|
|
1209
|
-
RESEND_WAIT_CHANNEL: "Please wait {seconds}s before requesting another {channel} code",
|
|
1210
|
-
TOTP_RESEND_NOT_APPLICABLE: "Resend is not applicable for TOTP",
|
|
1211
|
-
UNKNOWN_MFA_METHOD: "Unknown MFA method",
|
|
1212
|
-
UNKNOWN_METHOD: "Unknown method",
|
|
1213
|
-
METHOD_UNAVAILABLE: "That method isn't available",
|
|
1214
|
-
METHOD_NOT_CHANGEABLE: "That method can't be changed here.",
|
|
1215
|
-
KEEP_ONE_MFA_METHOD: "You must keep at least one two-factor method.",
|
|
1216
|
-
CHOOSE_OPTION: "Choose an option",
|
|
1217
|
-
ALL_MFA_METHODS_SET_UP: "You've already set up every available authentication method.",
|
|
1218
|
-
NO_MFA_CHANGES: "No changes were made to your two-factor methods.",
|
|
1219
|
-
PASSWORDS_DO_NOT_MATCH: "Passwords do not match",
|
|
1220
|
-
PASSWORD_CHANGE_TOO_RECENT: "You changed your password too recently. Please try again later.",
|
|
1221
|
-
PASSWORD_CHANGED: "Your password has been changed.",
|
|
1222
|
-
PASSWORD_UPDATED_REDIRECTING: "Password updated. Redirecting to sign-in…",
|
|
1223
|
-
PASSWORD_UPDATED_STILL_LOCKED: "Password updated, but your account is still locked. Contact an administrator to regain access.",
|
|
1224
|
-
RECOVERY_INSTRUCTIONS_SENT: "If an account exists, you will receive instructions.",
|
|
1225
|
-
SIGNUP_DISABLED: "Self-signup is currently disabled.",
|
|
1226
|
-
ALREADY_HAVE_ACCOUNT: "You already have an account. Please sign in.",
|
|
1227
|
-
ACCOUNT_LINKED: "Account linked.",
|
|
1228
|
-
INVALID_ROLE: "Invalid role",
|
|
1229
|
-
INVITE_ALREADY_PENDING: "Invite already pending",
|
|
1230
|
-
USER_ALREADY_EXISTS: "User already exists",
|
|
1231
|
-
DUPLICATE_INVITE_REJECTED: "Duplicate invite rejected",
|
|
1232
|
-
INVITE_CANCELLED: "This invite has been cancelled",
|
|
1233
|
-
INVITE_REPLACED: "This invite was replaced by a newer one",
|
|
1234
|
-
INVITE_ALREADY_ACCEPTED: "This invite was already accepted.",
|
|
1235
|
-
CHOOSE_USERNAME_TAKEN: "This username is taken",
|
|
1236
|
-
USERNAME_NOT_ALLOWED: "This username is not allowed",
|
|
1237
|
-
AUTHZ_EXPIRED: "Authorization request expired. Please try again.",
|
|
1238
|
-
AUTHZ_BROWSER_MISMATCH: "This authorization could not be verified for your browser. Please start again.",
|
|
1239
|
-
AUTHZ_FAILED: "Authorization could not be completed. Please start again.",
|
|
1240
|
-
GO_TO_SIGN_IN: "Go to sign-in",
|
|
1241
|
-
BACK_TO_SIGN_IN: "Back to sign-in",
|
|
1242
|
-
REQUEST_NEW_INVITE: "Request a new invite",
|
|
1243
|
-
BACK: "Back",
|
|
1244
|
-
GO_NOW: "Go now"
|
|
1245
|
-
};
|
|
1246
|
-
/** Fill `{name}` placeholders from `params`; unknown placeholders are kept. */
|
|
1247
|
-
function renderAoothMessage(template, params = {}) {
|
|
1248
|
-
return template.replace(/\{(\w+)\}/g, (whole, name) => Object.prototype.hasOwnProperty.call(params, name) ? String(params[name]) : whole);
|
|
1249
|
-
}
|
|
1250
|
-
/** Resolve `code` through `messages` (when given), falling back to the English template. */
|
|
1251
|
-
function resolveAoothMessage(code, params = {}, messages) {
|
|
1252
|
-
if (typeof messages === "function") {
|
|
1253
|
-
const text = messages(code, params);
|
|
1254
|
-
if (text !== void 0) return text;
|
|
1255
|
-
} else if (messages?.[code] !== void 0) return renderAoothMessage(messages[code], params);
|
|
1256
|
-
return renderAoothMessage(AOOTH_MESSAGES[code], params);
|
|
1257
|
-
}
|
|
1258
1423
|
// src/workflow/auth-workflow.schemas.ts
|
|
1259
1424
|
/**
|
|
1260
1425
|
* Canonical OTP send-then-check pair. Used by:
|
|
@@ -1449,6 +1614,12 @@ const consentsPersistTailSchema = [{
|
|
|
1449
1614
|
* schemas would no-op every step.
|
|
1450
1615
|
*/
|
|
1451
1616
|
var _AuthWorkflow;
|
|
1617
|
+
const SET_PASSWORD_COPY_KEYS = [
|
|
1618
|
+
"heading",
|
|
1619
|
+
"intro",
|
|
1620
|
+
"headingCode",
|
|
1621
|
+
"introCode"
|
|
1622
|
+
];
|
|
1452
1623
|
/**
|
|
1453
1624
|
* Default form schemas — the bundled `forms.as` models the workflow's
|
|
1454
1625
|
* `useAtscriptWf()` callers resolve to. Consumers can override any field
|
|
@@ -1713,6 +1884,12 @@ function readUsernameQueryParam() {
|
|
|
1713
1884
|
return;
|
|
1714
1885
|
}
|
|
1715
1886
|
}
|
|
1887
|
+
/** The message code of each MFA method's label. */
|
|
1888
|
+
const MFA_METHOD_LABEL_CODES = {
|
|
1889
|
+
totp: "MFA_METHOD_TOTP",
|
|
1890
|
+
email: "MFA_METHOD_EMAIL",
|
|
1891
|
+
sms: "MFA_METHOD_SMS"
|
|
1892
|
+
};
|
|
1716
1893
|
/**
|
|
1717
1894
|
* Subset-copy of `src` keyed by `keys`, omitting any key whose value is
|
|
1718
1895
|
* `undefined`. Returns `undefined` when no key carries a value — keeps
|
|
@@ -1769,21 +1946,20 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
1769
1946
|
this.consentStore = consentStore;
|
|
1770
1947
|
}
|
|
1771
1948
|
/**
|
|
1772
|
-
* Resolve a user-facing text by code (`AOOTH_MESSAGES`)
|
|
1773
|
-
*
|
|
1774
|
-
*
|
|
1775
|
-
*
|
|
1949
|
+
* Resolve a user-facing text by code (`AOOTH_MESSAGES`): `opts.messages`
|
|
1950
|
+
* first, then moost's translator in the request's locale, then the English
|
|
1951
|
+
* template. Every form error, banner, finish message and button label the
|
|
1952
|
+
* workflow produces goes through here — override for full control.
|
|
1776
1953
|
*/
|
|
1777
1954
|
msg(code, params) {
|
|
1778
1955
|
return resolveAoothMessage(code, params, this.opts.messages);
|
|
1779
1956
|
}
|
|
1780
|
-
/**
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
});
|
|
1957
|
+
/**
|
|
1958
|
+
* An `HttpError` whose body carries the message `code` and `params` next to
|
|
1959
|
+
* its (resolved) text, so an error-body translator can translate it by code.
|
|
1960
|
+
*/
|
|
1961
|
+
httpError(status, code, params) {
|
|
1962
|
+
return codedHttpError(status, code, this.msg(code, params), params);
|
|
1787
1963
|
}
|
|
1788
1964
|
/**
|
|
1789
1965
|
* Unified outbound dispatch hook for direct synchronous deliveries
|
|
@@ -1795,6 +1971,14 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
1795
1971
|
* sync-friendly: the default `void` preserves the engine's sync fast path.
|
|
1796
1972
|
*/
|
|
1797
1973
|
deliver(_payload) {}
|
|
1974
|
+
/** {@link deliver} with the request's locale stamped on the payload. */
|
|
1975
|
+
dispatch(payload) {
|
|
1976
|
+
const locale = currentLocale();
|
|
1977
|
+
return this.deliver(locale === void 0 ? payload : {
|
|
1978
|
+
...payload,
|
|
1979
|
+
locale
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1798
1982
|
/**
|
|
1799
1983
|
* The blessed one-call alert path for risk overrides — emit a
|
|
1800
1984
|
* `security-alert` delivery (e.g. from an impossible-travel
|
|
@@ -1807,7 +1991,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
1807
1991
|
async sendSecurityAlert(ctx, reason, context) {
|
|
1808
1992
|
const recipient = ctx.notice?.email;
|
|
1809
1993
|
if (!recipient) return;
|
|
1810
|
-
await this.
|
|
1994
|
+
await this.dispatch({
|
|
1811
1995
|
kind: "security-alert",
|
|
1812
1996
|
channel: "email",
|
|
1813
1997
|
recipient,
|
|
@@ -2331,12 +2515,15 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
2331
2515
|
/**
|
|
2332
2516
|
* Resolve the channel-OTP disclosure copy rendered beneath the email/phone
|
|
2333
2517
|
* input on `AskEmailForm` / `AskPhoneForm`. Reached from login.flow Phase 3.
|
|
2334
|
-
* Default returns a TCPA / PECR / CASL / GDPR-safe
|
|
2518
|
+
* Default returns a TCPA / PECR / CASL / GDPR-safe paragraph that is
|
|
2335
2519
|
* GENERIC per channel (no target templated in — the user hasn't submitted
|
|
2336
|
-
* yet at ask-time)
|
|
2520
|
+
* yet at ask-time): `OTP_DISCLOSURE_EMAIL` / `OTP_DISCLOSURE_PHONE` in the
|
|
2521
|
+
* request's language. The text is kept in the workflow state as shown and
|
|
2522
|
+
* recorded with the consent (`recordOtpChannelConsent`) — the one text the
|
|
2523
|
+
* state keeps translated, because the record must be what the user saw.
|
|
2337
2524
|
*/
|
|
2338
2525
|
resolveOtpDisclosure(_ctx, channel) {
|
|
2339
|
-
return channel === "phone" ? "
|
|
2526
|
+
return this.msg(channel === "phone" ? "OTP_DISCLOSURE_PHONE" : "OTP_DISCLOSURE_EMAIL");
|
|
2340
2527
|
}
|
|
2341
2528
|
/**
|
|
2342
2529
|
* Resolve whether to require an additional MFA round (risk step-up).
|
|
@@ -2367,41 +2554,38 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
2367
2554
|
* Resolve the invite accept-tail policy. Reached from invite.start accept
|
|
2368
2555
|
* phase. `loginUrl` defaults to `this.opts.loginUrl`. Note: today's
|
|
2369
2556
|
* `freshLoginRequired` field is GONE — the auto-login choice is the static
|
|
2370
|
-
* `AuthWorkflowOpts.autoLoginOnInvite` boolean (per §2 decision).
|
|
2557
|
+
* `AuthWorkflowOpts.autoLoginOnInvite` boolean (per §2 decision). Return
|
|
2558
|
+
* `confirmationMessage` to replace the default confirmation text
|
|
2559
|
+
* (`ACCOUNT_CREATED`, rendered in the finishing request's language) with your
|
|
2560
|
+
* own, shown as is.
|
|
2371
2561
|
*/
|
|
2372
2562
|
resolveAccept(_ctx) {
|
|
2373
2563
|
return {
|
|
2374
2564
|
alreadyAcceptedRedirectUrl: this.opts.loginUrl,
|
|
2375
2565
|
loginUrl: this.opts.loginUrl,
|
|
2376
|
-
showConfirmation: true
|
|
2377
|
-
confirmationMessage: "Your account has been created."
|
|
2566
|
+
showConfirmation: true
|
|
2378
2567
|
};
|
|
2379
2568
|
}
|
|
2380
2569
|
/**
|
|
2381
2570
|
* Copy (heading + intro) for the unified set-password screen, staged by
|
|
2382
|
-
* `create-password-form` BEFORE the pause.
|
|
2383
|
-
*
|
|
2384
|
-
*
|
|
2385
|
-
*
|
|
2386
|
-
*
|
|
2571
|
+
* `create-password-form` BEFORE the pause. The default picks message codes
|
|
2572
|
+
* — `SET_PASSWORD_{EXPIRED,RESET,INVITE,INITIAL}_{HEADING,INTRO}` by the
|
|
2573
|
+
* resolved `ctx.password.changeReason` (`expired` / `reset`), then
|
|
2574
|
+
* invite-accept (`ctx.accept`), then the initial-password fallback — which
|
|
2575
|
+
* are rendered through `msg()` in each request's language.
|
|
2576
|
+
*
|
|
2577
|
+
* Override to re-brand any phase: `heading` / `intro` are your own text,
|
|
2578
|
+
* shown as is (they win over the codes); `headingCode` / `introCode` pick
|
|
2579
|
+
* other codes. Return a partial to change one field and leave the other at
|
|
2580
|
+
* whatever an earlier step staged (spread `super`'s result to keep the
|
|
2581
|
+
* default for it), or `{}` to keep both as-is.
|
|
2387
2582
|
*/
|
|
2388
2583
|
resolveSetPasswordCopy(ctx) {
|
|
2389
2584
|
const reason = ctx.password?.changeReason;
|
|
2390
|
-
|
|
2391
|
-
heading: "Your password has expired",
|
|
2392
|
-
intro: "Choose a new password to continue. The previous one is no longer valid."
|
|
2393
|
-
};
|
|
2394
|
-
if (reason === "reset") return {
|
|
2395
|
-
heading: "Reset your password",
|
|
2396
|
-
intro: "Choose a new password for your account."
|
|
2397
|
-
};
|
|
2398
|
-
if (ctx.accept) return {
|
|
2399
|
-
heading: "Welcome — set your password",
|
|
2400
|
-
intro: "Choose a password to activate your account."
|
|
2401
|
-
};
|
|
2585
|
+
const phase = reason === "expired" ? "EXPIRED" : reason === "reset" ? "RESET" : ctx.accept ? "INVITE" : "INITIAL";
|
|
2402
2586
|
return {
|
|
2403
|
-
|
|
2404
|
-
|
|
2587
|
+
headingCode: `SET_PASSWORD_${phase}_HEADING`,
|
|
2588
|
+
introCode: `SET_PASSWORD_${phase}_INTRO`
|
|
2405
2589
|
};
|
|
2406
2590
|
}
|
|
2407
2591
|
/**
|
|
@@ -2603,6 +2787,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
2603
2787
|
*
|
|
2604
2788
|
* Called via `throwPublic` immediately before every `requireInput`-style
|
|
2605
2789
|
* pause so the FE always reads a fresh projection of the post-step ctx.
|
|
2790
|
+
* `WfTriggerProvider` strips the projection before persisting the state.
|
|
2606
2791
|
*/
|
|
2607
2792
|
populatePublic(ctx) {
|
|
2608
2793
|
const pub = {};
|
|
@@ -2640,7 +2825,12 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
2640
2825
|
if (sub) pub.trust = sub;
|
|
2641
2826
|
}
|
|
2642
2827
|
if (ctx.password) {
|
|
2643
|
-
const
|
|
2828
|
+
const { heading, headingCode, intro, introCode, policies } = ctx.password;
|
|
2829
|
+
const sub = pickDefined({
|
|
2830
|
+
heading: heading ?? (headingCode ? this.msg(headingCode) : void 0),
|
|
2831
|
+
intro: intro ?? (introCode ? this.msg(introCode) : void 0),
|
|
2832
|
+
policies: policies?.map(translatePolicyTexts)
|
|
2833
|
+
}, [
|
|
2644
2834
|
"heading",
|
|
2645
2835
|
"intro",
|
|
2646
2836
|
"policies"
|
|
@@ -2699,6 +2889,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
2699
2889
|
if (sub) pub.authz = sub;
|
|
2700
2890
|
}
|
|
2701
2891
|
ctx.public = pub;
|
|
2892
|
+
markPublicProjection(pub);
|
|
2702
2893
|
}
|
|
2703
2894
|
/**
|
|
2704
2895
|
* Wrap `wf.requireInput(opts)` so `ctx.public` is freshly projected
|
|
@@ -2751,17 +2942,17 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
2751
2942
|
* window.
|
|
2752
2943
|
*/
|
|
2753
2944
|
verifyPin(ctx, submitted) {
|
|
2754
|
-
if (!ctx.pin || !ctx.pinExpire || Date.now() > ctx.pinExpire) return { code: "
|
|
2945
|
+
if (!ctx.pin || !ctx.pinExpire || Date.now() > ctx.pinExpire) return { code: this.msg("CODE_EXPIRED") };
|
|
2755
2946
|
if (submitted !== ctx.pin) {
|
|
2756
2947
|
const attempts = (ctx.pinAttempts ?? 0) + 1;
|
|
2757
2948
|
if (attempts >= this.opts.mfa.pincodeMaxAttempts) {
|
|
2758
2949
|
delete ctx.pin;
|
|
2759
2950
|
delete ctx.pinExpire;
|
|
2760
2951
|
delete ctx.pinAttempts;
|
|
2761
|
-
return { code:
|
|
2952
|
+
return { code: this.msg("TOO_MANY_CODE_ATTEMPTS") };
|
|
2762
2953
|
}
|
|
2763
2954
|
ctx.pinAttempts = attempts;
|
|
2764
|
-
return { code: "
|
|
2955
|
+
return { code: this.msg("INVALID_CODE") };
|
|
2765
2956
|
}
|
|
2766
2957
|
delete ctx.pinAttempts;
|
|
2767
2958
|
return null;
|
|
@@ -2811,7 +3002,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
2811
3002
|
const pincode = ctx.pincode ??= {};
|
|
2812
3003
|
const channel = ctx.mfaEnroll?.method === "email" ? "email" : "sms";
|
|
2813
3004
|
pincode.sentTo = this.maskAddress(address, channel);
|
|
2814
|
-
await this.
|
|
3005
|
+
await this.dispatch({
|
|
2815
3006
|
kind: "enroll-pincode",
|
|
2816
3007
|
channel,
|
|
2817
3008
|
recipient: address,
|
|
@@ -2906,11 +3097,11 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
2906
3097
|
*/
|
|
2907
3098
|
validateMfaAddress(_ctx, method, value) {
|
|
2908
3099
|
const v = (value ?? "").trim();
|
|
2909
|
-
if (!v) return "
|
|
2910
|
-
if (method === "email") return /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(v) ? void 0 : "
|
|
3100
|
+
if (!v) return this.msg("ADDRESS_REQUIRED");
|
|
3101
|
+
if (method === "email") return /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(v) ? void 0 : this.msg("INVALID_EMAIL_ADDRESS");
|
|
2911
3102
|
if (method === "sms") {
|
|
2912
3103
|
const digits = v.replace(/[\s()+.-]/g, "");
|
|
2913
|
-
return /^[1-9]\d{6,14}$/.test(digits) ? void 0 : "
|
|
3104
|
+
return /^[1-9]\d{6,14}$/.test(digits) ? void 0 : this.msg("INVALID_PHONE_NUMBER");
|
|
2914
3105
|
}
|
|
2915
3106
|
}
|
|
2916
3107
|
/**
|
|
@@ -3084,8 +3275,8 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
3084
3275
|
initChangePassword(ctx) {
|
|
3085
3276
|
ctx.subject = useAuth().getUserId();
|
|
3086
3277
|
const password = ctx.password ??= {};
|
|
3087
|
-
password.
|
|
3088
|
-
password.
|
|
3278
|
+
password.headingCode = "CHANGE_PASSWORD_HEADING";
|
|
3279
|
+
password.introCode = "CHANGE_PASSWORD_INTRO";
|
|
3089
3280
|
}
|
|
3090
3281
|
/**
|
|
3091
3282
|
* Bind the standalone "Manage two-factor authentication" flow (add / change /
|
|
@@ -3251,7 +3442,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
3251
3442
|
if (action === "sso") {
|
|
3252
3443
|
const providerId = getInputField("ssoProvider");
|
|
3253
3444
|
const sso = providerId ? alt.ssoProviders.find((p) => p.id === providerId) : void 0;
|
|
3254
|
-
if (!sso) throw
|
|
3445
|
+
if (!sso) throw this.httpError(400, "UNKNOWN_SSO_PROVIDER");
|
|
3255
3446
|
await this.beginSso(sso.id, authzHandle);
|
|
3256
3447
|
return ALT_HANDLED;
|
|
3257
3448
|
}
|
|
@@ -3720,7 +3911,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
3720
3911
|
...userId && { userId }
|
|
3721
3912
|
}
|
|
3722
3913
|
};
|
|
3723
|
-
await this.
|
|
3914
|
+
await this.dispatch({
|
|
3724
3915
|
kind: "invite-link",
|
|
3725
3916
|
channel: "email",
|
|
3726
3917
|
recipient: email,
|
|
@@ -3830,7 +4021,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
3830
4021
|
data: { confirmed: true },
|
|
3831
4022
|
message: {
|
|
3832
4023
|
level: "success",
|
|
3833
|
-
text: ctx.accept.
|
|
4024
|
+
text: ctx.accept?.confirmationMessage ?? this.msg("ACCOUNT_CREATED")
|
|
3834
4025
|
}
|
|
3835
4026
|
});
|
|
3836
4027
|
}
|
|
@@ -3845,8 +4036,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
3845
4036
|
this.requireSubject(ctx);
|
|
3846
4037
|
const password = ctx.password ??= {};
|
|
3847
4038
|
const copy = await this.resolveSetPasswordCopy(ctx);
|
|
3848
|
-
|
|
3849
|
-
if (copy.intro !== void 0) password.intro = copy.intro;
|
|
4039
|
+
Object.assign(password, pickDefined(copy, SET_PASSWORD_COPY_KEYS));
|
|
3850
4040
|
const user = await this.refusePasswordFormReplay(ctx);
|
|
3851
4041
|
const wf = this.useAtscriptWfPublic(ctx, this.opts.forms.setPassword);
|
|
3852
4042
|
let input;
|
|
@@ -3861,7 +4051,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
3861
4051
|
try {
|
|
3862
4052
|
await this.users.setPassword(ctx.subject, input.newPassword);
|
|
3863
4053
|
} catch (err) {
|
|
3864
|
-
if (err instanceof UserAuthError) throw this.throwPublic(ctx, wf, { errors: { newPassword: err
|
|
4054
|
+
if (err instanceof UserAuthError) throw this.throwPublic(ctx, wf, { errors: { newPassword: userAuthErrorText(err) } });
|
|
3865
4055
|
throw err;
|
|
3866
4056
|
}
|
|
3867
4057
|
this.processInlineConsent(ctx, input, wf);
|
|
@@ -3871,8 +4061,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
3871
4061
|
delete ctx.passwordFormStamp;
|
|
3872
4062
|
ctx.newPasswordRequired = false;
|
|
3873
4063
|
delete password.changeReason;
|
|
3874
|
-
delete password
|
|
3875
|
-
delete password.intro;
|
|
4064
|
+
for (const key of SET_PASSWORD_COPY_KEYS) delete password[key];
|
|
3876
4065
|
}
|
|
3877
4066
|
/**
|
|
3878
4067
|
* Optional min-interval rate limit (Okta "minimum password age"). Gated
|
|
@@ -3929,7 +4118,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
3929
4118
|
} catch (err) {
|
|
3930
4119
|
if (err instanceof UserAuthError) {
|
|
3931
4120
|
const field = userAuthErrorField(err.type) ?? "newPassword";
|
|
3932
|
-
throw this.throwPublic(ctx, wf, { errors: { [field]: err
|
|
4121
|
+
throw this.throwPublic(ctx, wf, { errors: { [field]: userAuthErrorText(err) } });
|
|
3933
4122
|
}
|
|
3934
4123
|
throw err;
|
|
3935
4124
|
}
|
|
@@ -4032,11 +4221,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
4032
4221
|
* cancelled) is unit-testable without a wf event context.
|
|
4033
4222
|
*/
|
|
4034
4223
|
buildAddMfaFinishEnvelope(ctx) {
|
|
4035
|
-
const
|
|
4036
|
-
totp: "Authenticator app",
|
|
4037
|
-
email: "Email code",
|
|
4038
|
-
sms: "Text-message code"
|
|
4039
|
-
};
|
|
4224
|
+
const label = (method) => this.msg(MFA_METHOD_LABEL_CODES[method]);
|
|
4040
4225
|
const m = ctx.mfaEnroll;
|
|
4041
4226
|
const addMfa = ctx.addMfa;
|
|
4042
4227
|
const method = m?.method;
|
|
@@ -4050,7 +4235,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
4050
4235
|
},
|
|
4051
4236
|
message: {
|
|
4052
4237
|
level: "success",
|
|
4053
|
-
text:
|
|
4238
|
+
text: this.msg("MFA_METHOD_REMOVED", { method: label(addMfa.removed) })
|
|
4054
4239
|
}
|
|
4055
4240
|
};
|
|
4056
4241
|
else if (m?.done && method && addMfa?.action === "replace") envelope = {
|
|
@@ -4061,7 +4246,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
4061
4246
|
},
|
|
4062
4247
|
message: {
|
|
4063
4248
|
level: "success",
|
|
4064
|
-
text:
|
|
4249
|
+
text: this.msg("MFA_METHOD_UPDATED", { method: label(method) })
|
|
4065
4250
|
}
|
|
4066
4251
|
};
|
|
4067
4252
|
else if (m?.done && method) envelope = {
|
|
@@ -4072,7 +4257,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
4072
4257
|
},
|
|
4073
4258
|
message: {
|
|
4074
4259
|
level: "success",
|
|
4075
|
-
text:
|
|
4260
|
+
text: this.msg("MFA_METHOD_ADDED", { method: label(method) })
|
|
4076
4261
|
}
|
|
4077
4262
|
};
|
|
4078
4263
|
else if (addMfa?.blocked) envelope = {
|
|
@@ -4083,7 +4268,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
4083
4268
|
},
|
|
4084
4269
|
message: {
|
|
4085
4270
|
level: "info",
|
|
4086
|
-
text: addMfa.blocked === "last-required-factor" ?
|
|
4271
|
+
text: addMfa.blocked === "last-required-factor" ? this.msg("LAST_MFA_METHOD_NOT_REMOVABLE") : this.msg("METHOD_NOT_CHANGEABLE")
|
|
4087
4272
|
}
|
|
4088
4273
|
};
|
|
4089
4274
|
else if (candidates.length === 0 && !addMfa?.stepUpRequired) envelope = {
|
|
@@ -4314,7 +4499,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
4314
4499
|
if (isEmail) (ctx.channel ??= {}).email = value;
|
|
4315
4500
|
else (ctx.channel ??= {}).phone = value;
|
|
4316
4501
|
const code = this.mintPin(ctx, this.opts.mfa.pincodeLength, this.opts.mfa.pincodeTtlMs);
|
|
4317
|
-
await this.
|
|
4502
|
+
await this.dispatch({
|
|
4318
4503
|
kind: "enroll-pincode",
|
|
4319
4504
|
channel: isEmail ? "email" : "sms",
|
|
4320
4505
|
recipient: value,
|
|
@@ -4340,7 +4525,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
4340
4525
|
}
|
|
4341
4526
|
const recipient = isEmail ? ctx.channel?.email : ctx.channel?.phone;
|
|
4342
4527
|
const code = this.mintPin(ctx, this.opts.mfa.pincodeLength, this.opts.mfa.pincodeTtlMs);
|
|
4343
|
-
await this.
|
|
4528
|
+
await this.dispatch({
|
|
4344
4529
|
kind: "enroll-pincode",
|
|
4345
4530
|
channel: isEmail ? "email" : "sms",
|
|
4346
4531
|
recipient,
|
|
@@ -4539,21 +4724,21 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
4539
4724
|
throw err;
|
|
4540
4725
|
}
|
|
4541
4726
|
const code = this.mintPin(ctx, this.opts.mfa.pincodeLength, this.opts.mfa.pincodeTtlMs);
|
|
4542
|
-
if (ctx.mfa?.method) await this.
|
|
4727
|
+
if (ctx.mfa?.method) await this.dispatch({
|
|
4543
4728
|
kind: "mfa-pincode",
|
|
4544
4729
|
channel: target.channel,
|
|
4545
4730
|
recipient: target.address,
|
|
4546
4731
|
code,
|
|
4547
4732
|
expiresInMs: this.opts.mfa.pincodeTtlMs
|
|
4548
4733
|
});
|
|
4549
|
-
else if (ctx.signup) await this.
|
|
4734
|
+
else if (ctx.signup) await this.dispatch({
|
|
4550
4735
|
kind: "signup-pincode",
|
|
4551
4736
|
channel: "email",
|
|
4552
4737
|
recipient: target.address,
|
|
4553
4738
|
code,
|
|
4554
4739
|
expiresInMs: this.opts.mfa.pincodeTtlMs
|
|
4555
4740
|
});
|
|
4556
|
-
else await this.
|
|
4741
|
+
else await this.dispatch({
|
|
4557
4742
|
kind: "recovery-pincode",
|
|
4558
4743
|
channel: target.channel,
|
|
4559
4744
|
recipient: target.address,
|
|
@@ -4645,7 +4830,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
4645
4830
|
if (err instanceof UserAuthError) {
|
|
4646
4831
|
if (err.type === "LOCKED") throw this.throwPublic(ctx, wf, { formMessage: this.msg("ACCOUNT_LOCKED") });
|
|
4647
4832
|
if (err.type === "INACTIVE") throw this.throwPublic(ctx, wf, { errors: { code: this.msg("INVALID_CODE") } });
|
|
4648
|
-
if (err.type === "MFA_NOT_CONFIGURED") throw
|
|
4833
|
+
if (err.type === "MFA_NOT_CONFIGURED") throw this.httpError(400, "TOTP_NOT_CONFIGURED");
|
|
4649
4834
|
if (err.type === "MFA_INVALID") {
|
|
4650
4835
|
if (err.details?.lockEnds !== void 0) throw this.throwPublic(ctx, wf, { formMessage: this.msg("ACCOUNT_LOCKED") });
|
|
4651
4836
|
throw this.throwPublic(ctx, wf, { errors: { code: this.msg("INVALID_CODE") } });
|
|
@@ -5227,7 +5412,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
5227
5412
|
async notifyNewDevice(ctx) {
|
|
5228
5413
|
const recipient = ctx.notice?.email;
|
|
5229
5414
|
if (!recipient) return void 0;
|
|
5230
|
-
await this.
|
|
5415
|
+
await this.dispatch({
|
|
5231
5416
|
kind: "new-device-notice",
|
|
5232
5417
|
channel: "email",
|
|
5233
5418
|
recipient,
|
|
@@ -5824,7 +6009,7 @@ let AuthWorkflow = _AuthWorkflow = class AuthWorkflow {
|
|
|
5824
6009
|
const method = candidate.mfa.methods.find((m) => m.name === pending.otpChannel && m.confirmed);
|
|
5825
6010
|
if (!method) return null;
|
|
5826
6011
|
const code = this.mintPin(pending, this.opts.mfa.pincodeLength, this.opts.mfa.pincodeTtlMs);
|
|
5827
|
-
await this.
|
|
6012
|
+
await this.dispatch({
|
|
5828
6013
|
kind: "mfa-pincode",
|
|
5829
6014
|
channel: pending.otpChannel,
|
|
5830
6015
|
recipient: method.value,
|
|
@@ -7196,7 +7381,7 @@ const CHANGE_PASSWORD_WORKFLOW = "auth/change-password/flow";
|
|
|
7196
7381
|
const ADD_MFA_WORKFLOW = "auth/add-mfa/flow";
|
|
7197
7382
|
/** The post-redemption route's single "not found" answer. */
|
|
7198
7383
|
function inviteNotFound() {
|
|
7199
|
-
return
|
|
7384
|
+
return aoothHttpError(404, "INVITE_NOT_FOUND");
|
|
7200
7385
|
}
|
|
7201
7386
|
/** Prefer an explicit body field, fall back to the refresh cookie when enabled. */
|
|
7202
7387
|
function resolveRefreshToken(auth, body) {
|
|
@@ -7229,7 +7414,7 @@ let AuthController = class AuthController {
|
|
|
7229
7414
|
}
|
|
7230
7415
|
async logout(body) {
|
|
7231
7416
|
const auth = useAuth();
|
|
7232
|
-
if (!auth.getAuthContext()) throw
|
|
7417
|
+
if (!auth.getAuthContext()) throw aoothHttpError(401, "NOT_AUTHENTICATED");
|
|
7233
7418
|
const sessionId = auth.getSessionId();
|
|
7234
7419
|
if (sessionId) try {
|
|
7235
7420
|
await this.auth.revokeSession(auth.getUserId(), sessionId);
|
|
@@ -7248,7 +7433,7 @@ let AuthController = class AuthController {
|
|
|
7248
7433
|
async refresh(body) {
|
|
7249
7434
|
const auth = useAuth();
|
|
7250
7435
|
const refreshToken = resolveRefreshToken(auth, body);
|
|
7251
|
-
if (!refreshToken) throw
|
|
7436
|
+
if (!refreshToken) throw aoothHttpError(401, "MISSING_REFRESH_TOKEN");
|
|
7252
7437
|
const fromBody = typeof body?.refreshToken === "string";
|
|
7253
7438
|
let issue;
|
|
7254
7439
|
try {
|
|
@@ -7256,7 +7441,7 @@ let AuthController = class AuthController {
|
|
|
7256
7441
|
} catch (err) {
|
|
7257
7442
|
if (!(err instanceof AuthError)) throw err;
|
|
7258
7443
|
if (!fromBody) auth.clearCookies();
|
|
7259
|
-
throw
|
|
7444
|
+
throw aoothHttpError(401, "INVALID_REFRESH_TOKEN");
|
|
7260
7445
|
}
|
|
7261
7446
|
auth.writeCookies(issue);
|
|
7262
7447
|
const validated = await this.auth.validate(issue.accessToken);
|
|
@@ -7264,7 +7449,7 @@ let AuthController = class AuthController {
|
|
|
7264
7449
|
}
|
|
7265
7450
|
status() {
|
|
7266
7451
|
const auth = useAuth().getAuthContext();
|
|
7267
|
-
if (!auth) throw
|
|
7452
|
+
if (!auth) throw aoothHttpError(401, "NOT_AUTHENTICATED");
|
|
7268
7453
|
return auth;
|
|
7269
7454
|
}
|
|
7270
7455
|
triggerWf() {}
|
|
@@ -7313,7 +7498,7 @@ let AuthController = class AuthController {
|
|
|
7313
7498
|
*/
|
|
7314
7499
|
async invitePostRedemption(uid) {
|
|
7315
7500
|
if (!this.invitePostRedemptionEnabled()) throw inviteNotFound();
|
|
7316
|
-
if (!uid) throw
|
|
7501
|
+
if (!uid) throw aoothHttpError(400, "MISSING_UID");
|
|
7317
7502
|
if (!this.users) throw new HttpError$1(500, "UserService not wired — cannot resolve post-redemption state");
|
|
7318
7503
|
let user;
|
|
7319
7504
|
try {
|
|
@@ -7467,10 +7652,10 @@ let SessionsController = class SessionsController {
|
|
|
7467
7652
|
* sessions (including the current one) is what `POST /auth/logout` is for.
|
|
7468
7653
|
*/
|
|
7469
7654
|
async revokeOthers(others) {
|
|
7470
|
-
if (others !== "true") throw
|
|
7655
|
+
if (others !== "true") throw aoothHttpError(400, "LOGOUT_OTHERS_REQUIRED");
|
|
7471
7656
|
const auth = useAuth();
|
|
7472
7657
|
const current = auth.getSessionId();
|
|
7473
|
-
if (!current) throw
|
|
7658
|
+
if (!current) throw aoothHttpError(401, "NO_CURRENT_SESSION");
|
|
7474
7659
|
return { revoked: await this.auth.revokeOtherSessions(auth.getUserId(), current) };
|
|
7475
7660
|
}
|
|
7476
7661
|
};
|
|
@@ -7643,9 +7828,9 @@ let OAuthController = class OAuthController {
|
|
|
7643
7828
|
const userId = useAuth().getUserId();
|
|
7644
7829
|
const store = this.federated;
|
|
7645
7830
|
const owned = await store.listForUser(userId);
|
|
7646
|
-
if (!owned.find((i) => i.provider === providerId && i.subject === subject)) throw
|
|
7831
|
+
if (!owned.find((i) => i.provider === providerId && i.subject === subject)) throw aoothHttpError(404, "LINKED_IDENTITY_NOT_FOUND");
|
|
7647
7832
|
if (owned.length - 1 === 0) {
|
|
7648
|
-
if ((await this.users.getUser(userId)).password.isInitial) throw
|
|
7833
|
+
if ((await this.users.getUser(userId)).password.isInitial) throw aoothHttpError(409, "LAST_SIGN_IN_METHOD");
|
|
7649
7834
|
}
|
|
7650
7835
|
await store.unlink(providerId, subject);
|
|
7651
7836
|
await this.auth.revokeAllForUser(userId);
|
|
@@ -7656,7 +7841,7 @@ let OAuthController = class OAuthController {
|
|
|
7656
7841
|
try {
|
|
7657
7842
|
return this.registry.require(providerId);
|
|
7658
7843
|
} catch (err) {
|
|
7659
|
-
if (err instanceof OAuthError && err.type === "UNKNOWN_PROVIDER") throw
|
|
7844
|
+
if (err instanceof OAuthError && err.type === "UNKNOWN_PROVIDER") throw aoothHttpError(404, "UNKNOWN_PROVIDER", { provider: providerId });
|
|
7660
7845
|
throw err;
|
|
7661
7846
|
}
|
|
7662
7847
|
}
|
|
@@ -8222,6 +8407,8 @@ function createAuthEmailOutlet(deps) {
|
|
|
8222
8407
|
expiresAt
|
|
8223
8408
|
};
|
|
8224
8409
|
if (typeof opts.context?.username === "string") event.username = opts.context.username;
|
|
8410
|
+
const locale = currentLocale();
|
|
8411
|
+
if (locale !== void 0) event.locale = locale;
|
|
8225
8412
|
const rolesRaw = opts.context?.roles;
|
|
8226
8413
|
if (Array.isArray(rolesRaw)) {
|
|
8227
8414
|
const roles = rolesRaw.filter((r) => typeof r === "string");
|
|
@@ -8230,4 +8417,4 @@ function createAuthEmailOutlet(deps) {
|
|
|
8230
8417
|
await deps.emailSender.send(event);
|
|
8231
8418
|
});
|
|
8232
8419
|
}
|
|
8233
|
-
export { ADD_MFA_WORKFLOW, AOOTH_MESSAGES, AUTHZ_BINDING_COOKIE, AUTH_CODE_STORE_TOKEN, AuthController, AuthGuarded, AuthWorkflow, AuthorizeController, AuthorizeRuntime, CHANGE_PASSWORD_WORKFLOW, CLIENT_REDIRECT_POLICY_TOKEN, ConsentStore, DEFAULT_AUTH_WORKFLOWS, DYNAMIC_CLIENT_STORE_TOKEN, DynamicClientRegistration, FEDERATED_IDENTITY_STORE_TOKEN, INVITE_OUTLET, OAUTH_CSRF_COOKIE, OAuthController, OAuthRuntime, PENDING_AUTHORIZATION_STORE_TOKEN, Public, RESERVED_USER_KEYS, RateLimit, RateLimitStoreMemory, RateLimited, RateLimiter, SessionEnricherProvider, SessionsController, UserId, WfTrigger, WfTriggerProvider, 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, userAuthErrorInterceptor, userAuthErrorToHttp };
|
|
8420
|
+
export { ADD_MFA_WORKFLOW, AOOTH_HTTP_MESSAGES, AOOTH_MESSAGES, AUTHZ_BINDING_COOKIE, AUTH_CODE_STORE_TOKEN, AuthController, AuthGuarded, AuthWorkflow, AuthorizeController, AuthorizeRuntime, CHANGE_PASSWORD_WORKFLOW, CLIENT_REDIRECT_POLICY_TOKEN, ConsentStore, DEFAULT_AUTH_WORKFLOWS, DYNAMIC_CLIENT_STORE_TOKEN, DynamicClientRegistration, FEDERATED_IDENTITY_STORE_TOKEN, INVITE_OUTLET, OAUTH_CSRF_COOKIE, OAuthController, OAuthRuntime, PENDING_AUTHORIZATION_STORE_TOKEN, Public, RESERVED_USER_KEYS, RateLimit, RateLimitStoreMemory, RateLimited, RateLimiter, SessionEnricherProvider, SessionsController, UserId, WfTrigger, WfTriggerProvider, 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, userAuthErrorInterceptor, userAuthErrorToHttp };
|