@warlock.js/auth 5.52.0 → 5.53.1
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/CHANGELOG.md +40 -0
- package/esm/contracts/index.d.mts +2 -2
- package/esm/contracts/providers.d.mts +53 -0
- package/esm/contracts/providers.d.mts.map +1 -1
- package/esm/contracts/types.d.mts +53 -0
- package/esm/contracts/types.d.mts.map +1 -1
- package/esm/contracts/types.mjs.map +1 -1
- package/esm/errors/index.d.mts +2 -1
- package/esm/errors/index.mjs +2 -1
- package/esm/errors/provider-account-link-blocked.error.d.mts +16 -0
- package/esm/errors/provider-account-link-blocked.error.d.mts.map +1 -0
- package/esm/errors/provider-account-link-blocked.error.mjs +22 -0
- package/esm/errors/provider-account-link-blocked.error.mjs.map +1 -0
- package/esm/index.d.mts +3 -2
- package/esm/index.mjs +2 -1
- package/esm/middleware/auth.middleware.mjs +1 -1
- package/esm/middleware/auth.middleware.mjs.map +1 -1
- package/esm/middleware/login-throttle.middleware.d.mts +38 -8
- package/esm/middleware/login-throttle.middleware.d.mts.map +1 -1
- package/esm/middleware/login-throttle.middleware.mjs +93 -29
- package/esm/middleware/login-throttle.middleware.mjs.map +1 -1
- package/esm/models/access-token/access-token.model.d.mts +14 -3
- package/esm/models/access-token/access-token.model.d.mts.map +1 -1
- package/esm/models/access-token/access-token.model.mjs +15 -8
- package/esm/models/access-token/access-token.model.mjs.map +1 -1
- package/esm/models/auth.model.d.mts +8 -0
- package/esm/models/auth.model.d.mts.map +1 -1
- package/esm/models/auth.model.mjs +3 -0
- package/esm/models/auth.model.mjs.map +1 -1
- package/esm/models/one-time-token/one-time-token.model.d.mts +7 -2
- package/esm/models/one-time-token/one-time-token.model.d.mts.map +1 -1
- package/esm/models/one-time-token/one-time-token.model.mjs +8 -7
- package/esm/models/one-time-token/one-time-token.model.mjs.map +1 -1
- package/esm/models/refresh-token/refresh-token.model.d.mts +15 -3
- package/esm/models/refresh-token/refresh-token.model.d.mts.map +1 -1
- package/esm/models/refresh-token/refresh-token.model.mjs +17 -12
- package/esm/models/refresh-token/refresh-token.model.mjs.map +1 -1
- package/esm/otp/otp.d.mts +5 -1
- package/esm/otp/otp.d.mts.map +1 -1
- package/esm/otp/otp.mjs +18 -3
- package/esm/otp/otp.mjs.map +1 -1
- package/esm/passkeys/passkey-authentication.mjs +2 -2
- package/esm/passkeys/passkey-authentication.mjs.map +1 -1
- package/esm/passkeys/passkey-registration.d.mts.map +1 -1
- package/esm/passkeys/passkey-registration.mjs +2 -2
- package/esm/passkeys/passkey-registration.mjs.map +1 -1
- package/esm/providers/apple-provider.d.mts +2 -0
- package/esm/providers/apple-provider.d.mts.map +1 -1
- package/esm/providers/apple-provider.mjs +4 -1
- package/esm/providers/apple-provider.mjs.map +1 -1
- package/esm/providers/discord-provider.d.mts +2 -0
- package/esm/providers/discord-provider.d.mts.map +1 -1
- package/esm/providers/discord-provider.mjs +7 -1
- package/esm/providers/discord-provider.mjs.map +1 -1
- package/esm/providers/facebook-provider.d.mts +2 -0
- package/esm/providers/facebook-provider.d.mts.map +1 -1
- package/esm/providers/facebook-provider.mjs +10 -2
- package/esm/providers/facebook-provider.mjs.map +1 -1
- package/esm/providers/github-provider.d.mts +2 -0
- package/esm/providers/github-provider.d.mts.map +1 -1
- package/esm/providers/github-provider.mjs +19 -10
- package/esm/providers/github-provider.mjs.map +1 -1
- package/esm/providers/linkedin-provider.d.mts +2 -0
- package/esm/providers/linkedin-provider.d.mts.map +1 -1
- package/esm/providers/linkedin-provider.mjs +4 -1
- package/esm/providers/linkedin-provider.mjs.map +1 -1
- package/esm/providers/provider-timeout.mjs +17 -0
- package/esm/providers/provider-timeout.mjs.map +1 -0
- package/esm/providers/resolve-provider-user.mjs +21 -1
- package/esm/providers/resolve-provider-user.mjs.map +1 -1
- package/esm/providers/x-provider.d.mts +2 -0
- package/esm/providers/x-provider.d.mts.map +1 -1
- package/esm/providers/x-provider.mjs +7 -1
- package/esm/providers/x-provider.mjs.map +1 -1
- package/esm/services/auth-config.mjs +65 -6
- package/esm/services/auth-config.mjs.map +1 -1
- package/esm/services/auth-cookie-names.mjs +49 -0
- package/esm/services/auth-cookie-names.mjs.map +1 -0
- package/esm/services/auth-events.d.mts +4 -0
- package/esm/services/auth-events.d.mts.map +1 -1
- package/esm/services/auth-events.mjs.map +1 -1
- package/esm/services/auth.service.d.mts +8 -0
- package/esm/services/auth.service.d.mts.map +1 -1
- package/esm/services/auth.service.mjs +146 -20
- package/esm/services/auth.service.mjs.map +1 -1
- package/esm/services/jwt.d.mts.map +1 -1
- package/esm/services/jwt.mjs +92 -10
- package/esm/services/jwt.mjs.map +1 -1
- package/esm/services/password-reset.d.mts +5 -0
- package/esm/services/password-reset.d.mts.map +1 -1
- package/esm/services/password-reset.mjs +15 -1
- package/esm/services/password-reset.mjs.map +1 -1
- package/esm/services/resolve-request-user.d.mts.map +1 -1
- package/esm/services/resolve-request-user.mjs +17 -3
- package/esm/services/resolve-request-user.mjs.map +1 -1
- package/esm/session/page-session.d.mts.map +1 -1
- package/esm/session/page-session.mjs +5 -3
- package/esm/session/page-session.mjs.map +1 -1
- package/esm/utils/auth-error-codes.d.mts +8 -1
- package/esm/utils/auth-error-codes.d.mts.map +1 -1
- package/esm/utils/auth-error-codes.mjs +7 -0
- package/esm/utils/auth-error-codes.mjs.map +1 -1
- package/esm/utils/token-digest.mjs +47 -0
- package/esm/utils/token-digest.mjs.map +1 -0
- package/esm/utils/token-expiry.d.mts +3 -1
- package/esm/utils/token-expiry.d.mts.map +1 -1
- package/esm/utils/token-expiry.mjs +7 -2
- package/esm/utils/token-expiry.mjs.map +1 -1
- package/llms-full.txt +70 -30
- package/llms.txt +2 -2
- package/package.json +9 -9
- package/skills/auth-basics/SKILL.md +9 -0
- package/skills/customize-token-storage/SKILL.md +10 -10
- package/skills/login-with-providers/SKILL.md +14 -3
- package/skills/manage-tokens/SKILL.md +6 -0
- package/skills/protect-routes/SKILL.md +5 -0
- package/skills/throttle-login-attempts/SKILL.md +23 -17
- package/skills/verify-email-and-reset-password/SKILL.md +3 -0
|
@@ -5,6 +5,27 @@ import ms from "ms";
|
|
|
5
5
|
|
|
6
6
|
//#region ../../packages/auth/src/services/auth-config.ts
|
|
7
7
|
const warnedLegacyKeys = /* @__PURE__ */ new Set();
|
|
8
|
+
/** One-time production warnings already logged, by key. */
|
|
9
|
+
const warnedProduction = /* @__PURE__ */ new Set();
|
|
10
|
+
/** Signing secrets shorter than this are brute-forceable from one captured token. */
|
|
11
|
+
const MIN_SECRET_BYTES = 32;
|
|
12
|
+
/** Access-token lifetimes past this get a production warning. */
|
|
13
|
+
const LONG_ACCESS_TOKEN_MS = 2592e6;
|
|
14
|
+
/** Same answer as core's `environment()`, read directly so config stays dependency-light. */
|
|
15
|
+
function isProduction() {
|
|
16
|
+
return process.env.NODE_ENV === "production";
|
|
17
|
+
}
|
|
18
|
+
/** Log `message` once per process, in production only. */
|
|
19
|
+
function warnOnceInProduction(key, message) {
|
|
20
|
+
if (!isProduction() || warnedProduction.has(key)) return;
|
|
21
|
+
warnedProduction.add(key);
|
|
22
|
+
log.warn("auth", "config", message);
|
|
23
|
+
}
|
|
24
|
+
/** Warn (production, once) when a signing secret is too short to resist offline guessing. */
|
|
25
|
+
function checkSecretStrength(key, secret) {
|
|
26
|
+
if (Buffer.byteLength(secret) >= MIN_SECRET_BYTES) return;
|
|
27
|
+
warnOnceInProduction(`secret:${key}`, `auth.${key} is shorter than ${MIN_SECRET_BYTES} bytes, so a captured token lets an attacker guess it offline and forge tokens. Generate a strong secret with "warlock jwt.generate".`);
|
|
28
|
+
}
|
|
8
29
|
const permitAuthentication = () => true;
|
|
9
30
|
/**
|
|
10
31
|
* `ms` accepts anything at runtime and answers `undefined` for a string it
|
|
@@ -83,6 +104,11 @@ const authConfig = {
|
|
|
83
104
|
canAuthenticate: async (user) => {
|
|
84
105
|
return config.key("auth.canAuthenticate", permitAuthentication)(user);
|
|
85
106
|
},
|
|
107
|
+
/**
|
|
108
|
+
* Store only a SHA-256 digest of each access and refresh token
|
|
109
|
+
* (`auth.hashTokensAtRest`). @default false
|
|
110
|
+
*/
|
|
111
|
+
hashTokensAtRest: () => config.key("auth.hashTokensAtRest", false) === true,
|
|
86
112
|
/** Login identifier normalizer, or `false` for exact matching. */
|
|
87
113
|
normalizeCredentials: () => config.key("auth.normalizeCredentials", defaultNormalizeCredentials),
|
|
88
114
|
accessToken: {
|
|
@@ -90,10 +116,22 @@ const authConfig = {
|
|
|
90
116
|
secret: () => {
|
|
91
117
|
const secret = resolve("accessToken.secret", "jwt.secret");
|
|
92
118
|
if (!secret) throw new Error("auth: no JWT secret configured — set `auth.accessToken.secret`.");
|
|
119
|
+
checkSecretStrength("accessToken.secret", secret);
|
|
93
120
|
return secret;
|
|
94
121
|
},
|
|
95
122
|
/** Signing algorithm (legacy: `auth.jwt.algorithm`). */
|
|
96
123
|
algorithm: () => resolve("accessToken.algorithm", "jwt.algorithm", "HS256"),
|
|
124
|
+
/** `iss` claim stamped on and required of every token; unset ⇒ not used. */
|
|
125
|
+
issuer: () => {
|
|
126
|
+
const issuer = config.key("auth.accessToken.issuer");
|
|
127
|
+
return typeof issuer === "string" && issuer.length > 0 ? issuer : void 0;
|
|
128
|
+
},
|
|
129
|
+
/** `aud` claim stamped on and required of every token; unset ⇒ not used. */
|
|
130
|
+
audience: () => {
|
|
131
|
+
const audience = config.key("auth.accessToken.audience");
|
|
132
|
+
if (typeof audience === "string" && audience.length > 0) return audience;
|
|
133
|
+
if (Array.isArray(audience) && audience.length > 0 && audience.every((entry) => typeof entry === "string" && entry.length > 0)) return audience;
|
|
134
|
+
},
|
|
97
135
|
/** Lifetime as an `ms`-string (legacy: `auth.jwt.expiresIn`). */
|
|
98
136
|
expiresIn: () => resolve("accessToken.expiresIn", "jwt.expiresIn"),
|
|
99
137
|
/**
|
|
@@ -101,7 +139,11 @@ const authConfig = {
|
|
|
101
139
|
* to 1 hour when unset; throws naming the key when the configured value is
|
|
102
140
|
* not a positive `ms` duration. See {@link parseDuration}.
|
|
103
141
|
*/
|
|
104
|
-
expiresInMs: () =>
|
|
142
|
+
expiresInMs: () => {
|
|
143
|
+
const lifetime = parseDuration("accessToken.expiresIn", authConfig.accessToken.expiresIn() ?? DEFAULT_ACCESS_TOKEN_EXPIRES_IN);
|
|
144
|
+
if (lifetime > LONG_ACCESS_TOKEN_MS) warnOnceInProduction("accessToken.expiresIn", "auth.accessToken.expiresIn is longer than 30 days: a stolen access token stays usable that long. Use a short lifetime (e.g. \"1h\") with refresh tokens (auth.refreshToken.enabled) instead.");
|
|
145
|
+
return lifetime;
|
|
146
|
+
}
|
|
105
147
|
},
|
|
106
148
|
pageAuth: {
|
|
107
149
|
/**
|
|
@@ -129,7 +171,9 @@ const authConfig = {
|
|
|
129
171
|
/** Cookie `Path` attribute `setAuthCookie`/`clearAuthCookie` use. @default "/" */
|
|
130
172
|
path: () => config.key("auth.cookie.path", "/"),
|
|
131
173
|
/** Select the request-scoped cookie Domain; undefined keeps it host-only. */
|
|
132
|
-
cookieDomain: () => config.key("auth.cookie.cookieDomain")
|
|
174
|
+
cookieDomain: () => config.key("auth.cookie.cookieDomain"),
|
|
175
|
+
/** Write the auth cookies as `__Host-<name>` (Secure, `Path=/`, no Domain). @default false */
|
|
176
|
+
hostPrefix: () => config.key("auth.cookie.hostPrefix", false) === true
|
|
133
177
|
},
|
|
134
178
|
csrf: {
|
|
135
179
|
/**
|
|
@@ -157,7 +201,9 @@ allowedOrigins: () => config.key("auth.csrf.allowedOrigins", []) },
|
|
|
157
201
|
/** Link builder whose result is handed to the notification as `url`. */
|
|
158
202
|
url: () => config.key("auth.passwordReset.url"),
|
|
159
203
|
/** App-owned password writer replacing the default. */
|
|
160
|
-
setPassword: () => config.key("auth.passwordReset.setPassword")
|
|
204
|
+
setPassword: () => config.key("auth.passwordReset.setPassword"),
|
|
205
|
+
/** Wait for the reset notification before `requestPasswordReset` resolves. @default false */
|
|
206
|
+
awaitDelivery: () => config.key("auth.passwordReset.awaitDelivery", false) === true
|
|
161
207
|
},
|
|
162
208
|
providers: {
|
|
163
209
|
/** `auth.providers.google`, when configured. */
|
|
@@ -182,7 +228,12 @@ allowedOrigins: () => config.key("auth.csrf.allowedOrigins", []) },
|
|
|
182
228
|
/** User attribute a verified provider email is matched against. @default "email" */
|
|
183
229
|
emailField: () => config.key("auth.providers.emailField", "email"),
|
|
184
230
|
/** App-owned user creation for a first provider login. */
|
|
185
|
-
createUser: () => config.key("auth.providers.createUser")
|
|
231
|
+
createUser: () => config.key("auth.providers.createUser"),
|
|
232
|
+
/** Linking a first provider login to an existing account by email. @default "verified" */
|
|
233
|
+
linkExisting: () => {
|
|
234
|
+
const value = config.key("auth.providers.linkExisting", "verified");
|
|
235
|
+
return value === "always" || value === "never" ? value : "verified";
|
|
236
|
+
}
|
|
186
237
|
},
|
|
187
238
|
passkeys: {
|
|
188
239
|
/** `auth.passkeys`; throws naming the keys when `rpID`, `rpName` or `origin` is missing. */
|
|
@@ -196,6 +247,8 @@ allowedOrigins: () => config.key("auth.csrf.allowedOrigins", []) },
|
|
|
196
247
|
const { origin } = authConfig.passkeys.settings();
|
|
197
248
|
return Array.isArray(origin) ? origin : [origin];
|
|
198
249
|
},
|
|
250
|
+
/** User-verification requirement for both ceremonies. @default "preferred" */
|
|
251
|
+
userVerification: () => config.key("auth.passkeys")?.userVerification === "required" ? "required" : "preferred",
|
|
199
252
|
/** Challenge lifetime in ms; throws naming the key when unusable. @default "5m" */
|
|
200
253
|
challengeExpiresInMs: () => parseDuration("passkeys.challengeExpiresIn", config.key("auth.passkeys.challengeExpiresIn", DEFAULT_PASSKEY_CHALLENGE_EXPIRES_IN))
|
|
201
254
|
},
|
|
@@ -214,11 +267,17 @@ allowedOrigins: () => config.key("auth.csrf.allowedOrigins", []) },
|
|
|
214
267
|
return build ? build(code) : `Your verification code is ${code}`;
|
|
215
268
|
},
|
|
216
269
|
/** App-owned delivery replacing the notifications channel send. */
|
|
217
|
-
send: () => config.key("auth.otp.send")
|
|
270
|
+
send: () => config.key("auth.otp.send"),
|
|
271
|
+
/** Wait for the code delivery before `requestOtp` resolves. @default false */
|
|
272
|
+
awaitDelivery: () => config.key("auth.otp.awaitDelivery", false) === true
|
|
218
273
|
},
|
|
219
274
|
refreshToken: {
|
|
220
275
|
/** Separate refresh secret (legacy: `auth.jwt.refresh.secret`); empty ⇒ fall back to the access secret. */
|
|
221
|
-
secret: () =>
|
|
276
|
+
secret: () => {
|
|
277
|
+
const secret = resolve("refreshToken.secret", "jwt.refresh.secret");
|
|
278
|
+
if (secret) checkSecretStrength("refreshToken.secret", secret);
|
|
279
|
+
return secret;
|
|
280
|
+
},
|
|
222
281
|
/** Whether refresh tokens are enabled (legacy: `auth.jwt.refresh.enabled`). */
|
|
223
282
|
enabled: () => resolve("refreshToken.enabled", "jwt.refresh.enabled", true),
|
|
224
283
|
/** Lifetime as an `ms`-string (legacy: `auth.jwt.refresh.expiresIn`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-config.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth-config.ts"],"sourcesContent":["import { config } from \"@warlock.js/core\";\nimport type { CookieDomainResolver } from \"../contracts/types\";\nimport { log } from \"@warlock.js/logger\";\nimport { type Algorithm } from \"fast-jwt\";\nimport ms from \"ms\";\nimport type {\n AuthNotification,\n CanAuthenticate,\n NormalizeCredentials,\n LogoutWithoutTokenBehavior,\n OneTimeTokenUrlBuilder,\n PasswordSetter,\n} from \"../contracts/types\";\nimport type {\n AppleProviderConfig,\n AuthProvider,\n DiscordProviderConfig,\n FacebookProviderConfig,\n GitHubProviderConfig,\n GoogleProviderConfig,\n LinkedInProviderConfig,\n OtpSender,\n PasskeysConfig,\n ProviderUserCreator,\n XProviderConfig,\n} from \"../contracts/providers\";\nimport type { Auth } from \"../models/auth.model\";\nimport { defaultNormalizeCredentials } from \"../utils/normalize-credentials\";\n\nconst warnedLegacyKeys = new Set<string>();\n\nconst permitAuthentication: CanAuthenticate = (): boolean => true;\n\n/**\n * `ms` accepts anything at runtime and answers `undefined` for a string it\n * cannot parse (`\"30dayz\"`), a *formatted string* for a number (`2592000` ⇒\n * `\"43m\"`), and throws for `\"\"`. Its published types claim the far narrower\n * `(value: ms.StringValue) => number`, which is exactly what let an\n * `as ms.StringValue` cast smuggle arbitrary config text past the compiler and\n * hand `undefined` to the JWT signer. Declare the honest runtime signature once,\n * here, so every caller is forced to deal with the `undefined`.\n */\nconst parseMs = ms as unknown as (value: unknown) => number | string | undefined;\n\n/**\n * Turn a configured lifetime into a positive number of milliseconds, or throw\n * naming the key.\n *\n * A token lifetime is a security boundary, so an unusable value is a hard error\n * rather than a silent fallback: substituting a default would trade one\n * unintended lifetime for another, just as quietly — and quiet is the whole\n * problem. Every non-positive, non-finite or non-numeric parse is rejected:\n *\n * - `\"30dayz\"` / `\"thirty days\"` ⇒ `undefined` ⇒ a JWT signed with **no `exp`\n * claim** and an `Invalid Date` written to the token row.\n * - `\"0d\"` ⇒ parses cleanly to `0`, which `fast-jwt` treats as falsy and also\n * emits with **no `exp` claim** — it survives any guard that only rejects\n * `undefined`. `\"-1h\"` signs an already-expired token.\n * - `2592000` (a bare number) ⇒ `ms` *formats* it as `\"43m\"`, a string, which\n * then turns `Date.now() + expiresIn` into an `Invalid Date`.\n */\nfunction parseDuration(key: string, raw: unknown): number {\n let parsed: number | string | undefined;\n\n try {\n parsed = parseMs(raw);\n } catch {\n // ms throws (rather than returning undefined) for \"\" and non-strings\n parsed = undefined;\n }\n\n if (typeof parsed !== \"number\" || !Number.isFinite(parsed) || parsed <= 0) {\n throw new Error(\n `auth.${key}: ${JSON.stringify(raw)} is not a valid ms duration — ` +\n `use a positive duration string such as \"1h\", \"7d\", or NO_EXPIRATION.`,\n );\n }\n\n return parsed;\n}\n\n/** Email-verification token lifetime used when nothing is configured. */\nconst DEFAULT_VERIFICATION_EXPIRES_IN = \"24h\";\n\n/** Password-reset token lifetime used when nothing is configured. */\nconst DEFAULT_PASSWORD_RESET_EXPIRES_IN = \"60m\";\n\n/** Passkey challenge lifetime used when nothing is configured. */\nconst DEFAULT_PASSKEY_CHALLENGE_EXPIRES_IN = \"5m\";\n\n/** OTP lifetime used when nothing is configured. */\nconst DEFAULT_OTP_EXPIRES_IN = \"5m\";\n\n/** Access-token lifetime used when nothing is configured. */\nconst DEFAULT_ACCESS_TOKEN_EXPIRES_IN = \"1h\";\n\n/**\n * Resolve an auth setting, preferring the new `auth.accessToken.*` /\n * `auth.refreshToken.*` key and falling back to the deprecated `auth.jwt.*`\n * shape — warning once per legacy key. Returns `fallback` when neither is set.\n *\n * This is the backward-compatible shim that lets existing `auth.jwt.*` configs\n * keep working after the config split.\n */\nfunction resolve<T>(newKey: string, legacyKey: string, fallback?: T): T {\n const fromNew = config.key(`auth.${newKey}`);\n\n if (fromNew !== undefined && fromNew !== null) {\n return fromNew as T;\n }\n\n const fromLegacy = config.key(`auth.${legacyKey}`);\n\n if (fromLegacy !== undefined && fromLegacy !== null) {\n if (!warnedLegacyKeys.has(legacyKey)) {\n warnedLegacyKeys.add(legacyKey);\n log.warn(\n \"auth\",\n \"config-deprecation\",\n `auth.${legacyKey} is deprecated — use auth.${newKey}`,\n );\n }\n\n return fromLegacy as T;\n }\n\n return fallback as T;\n}\n\n/**\n * Typed, backward-compatible access to auth configuration. The service and the\n * jwt signer read configuration exclusively through here, so the new split\n * config and the legacy `auth.jwt.*` shape both resolve the same way.\n */\nexport const authConfig = {\n canAuthenticate: async (user: Auth): Promise<boolean> => {\n const canAuthenticate = config.key<CanAuthenticate>(\n \"auth.canAuthenticate\",\n permitAuthentication,\n );\n\n return canAuthenticate(user);\n },\n /** Login identifier normalizer, or `false` for exact matching. */\n normalizeCredentials: (): false | NormalizeCredentials =>\n config.key<false | NormalizeCredentials>(\n \"auth.normalizeCredentials\",\n defaultNormalizeCredentials,\n ),\n accessToken: {\n /** Signing secret (legacy: `auth.jwt.secret`). Throws if neither is set. */\n secret: (): string => {\n const secret = resolve<string | undefined>(\"accessToken.secret\", \"jwt.secret\");\n\n if (!secret) {\n throw new Error(\"auth: no JWT secret configured — set `auth.accessToken.secret`.\");\n }\n\n return secret;\n },\n /** Signing algorithm (legacy: `auth.jwt.algorithm`). */\n algorithm: (): Algorithm => resolve(\"accessToken.algorithm\", \"jwt.algorithm\", \"HS256\"),\n /** Lifetime as an `ms`-string (legacy: `auth.jwt.expiresIn`). */\n expiresIn: (): string | undefined => resolve(\"accessToken.expiresIn\", \"jwt.expiresIn\"),\n /**\n * Lifetime in milliseconds — the only form a token issuer may use. Defaults\n * to 1 hour when unset; throws naming the key when the configured value is\n * not a positive `ms` duration. See {@link parseDuration}.\n */\n expiresInMs: (): number =>\n parseDuration(\n \"accessToken.expiresIn\",\n authConfig.accessToken.expiresIn() ?? DEFAULT_ACCESS_TOKEN_EXPIRES_IN,\n ),\n },\n pageAuth: {\n /**\n * Login path a guarded PAGE route redirects a logged-out browser to.\n *\n * Unset (the default) ⇒ page-route auth failures keep the JSON 401 API\n * contract, so existing apps see NO behavior change. Set it (e.g. \"/login\")\n * to opt a browser-facing app into login-redirect UX: a logged-out human\n * navigating to a guarded page lands on the login screen instead of reading\n * a raw JSON error blob. Finding b9ab9804.\n */\n loginPath: (): string | undefined => config.key(\"auth.pageAuth.loginPath\"),\n /**\n * Query parameter the redirect carries the originally-requested path in, so\n * the login flow can send the user back where they were headed. Defaults to\n * `\"returnUrl\"`.\n */\n returnUrlParam: (): string => config.key(\"auth.pageAuth.returnUrlParam\", \"returnUrl\"),\n },\n cookie: {\n /** Cookie name `setAuthCookie`/`clearAuthCookie` use. @default \"access_token\" */\n name: (): string => config.key(\"auth.cookie.name\", \"access_token\"),\n /** Refresh-token cookie name the session cookie helpers use. @default \"refresh_token\" */\n refreshName: (): string => config.key(\"auth.cookie.refreshName\", \"refresh_token\"),\n /** Cookie `Path` attribute `setAuthCookie`/`clearAuthCookie` use. @default \"/\" */\n path: (): string => config.key(\"auth.cookie.path\", \"/\"),\n /** Select the request-scoped cookie Domain; undefined keeps it host-only. */\n cookieDomain: (): CookieDomainResolver | undefined => config.key(\"auth.cookie.cookieDomain\"),\n },\n csrf: {\n /**\n * Extra origins allowed on a cookie-authenticated unsafe-method request,\n * beyond the request's own origin. @default []\n */\n allowedOrigins: (): string[] => config.key(\"auth.csrf.allowedOrigins\", []),\n },\n verification: {\n /** Lifetime in ms of an email-verification token; throws naming the key when unusable. @default \"24h\" */\n expiresInMs: (): number =>\n parseDuration(\n \"verification.expiresIn\",\n config.key(\"auth.verification.expiresIn\", DEFAULT_VERIFICATION_EXPIRES_IN),\n ),\n /** User attribute stamped with the verification date. @default \"emailVerifiedAt\" */\n field: (): string => config.key(\"auth.verification.field\", \"emailVerifiedAt\"),\n /** App notification replacing the default verification email. */\n notification: (): AuthNotification | undefined => config.key(\"auth.verification.notification\"),\n /** Link builder whose result is handed to the notification as `url`. */\n url: (): OneTimeTokenUrlBuilder | undefined => config.key(\"auth.verification.url\"),\n },\n passwordReset: {\n /** Lifetime in ms of a password-reset token; throws naming the key when unusable. @default \"60m\" */\n expiresInMs: (): number =>\n parseDuration(\n \"passwordReset.expiresIn\",\n config.key(\"auth.passwordReset.expiresIn\", DEFAULT_PASSWORD_RESET_EXPIRES_IN),\n ),\n /** User attribute `requestPasswordReset` looks the account up by. @default \"email\" */\n identifierField: (): string => config.key(\"auth.passwordReset.identifierField\", \"email\"),\n /** App notification replacing the default reset email. */\n notification: (): AuthNotification | undefined => config.key(\"auth.passwordReset.notification\"),\n /** Link builder whose result is handed to the notification as `url`. */\n url: (): OneTimeTokenUrlBuilder | undefined => config.key(\"auth.passwordReset.url\"),\n /** App-owned password writer replacing the default. */\n setPassword: (): PasswordSetter | undefined => config.key(\"auth.passwordReset.setPassword\"),\n },\n providers: {\n /** `auth.providers.google`, when configured. */\n google: (): GoogleProviderConfig | undefined => config.key(\"auth.providers.google\"),\n /** `auth.providers.github`, when configured. */\n github: (): GitHubProviderConfig | undefined => config.key(\"auth.providers.github\"),\n /** `auth.providers.discord`, when configured. */\n discord: (): DiscordProviderConfig | undefined => config.key(\"auth.providers.discord\"),\n /** `auth.providers.linkedin`, when configured. */\n linkedin: (): LinkedInProviderConfig | undefined => config.key(\"auth.providers.linkedin\"),\n /** `auth.providers.apple`, when configured. */\n apple: (): AppleProviderConfig | undefined => config.key(\"auth.providers.apple\"),\n /** `auth.providers.facebook`, when configured. */\n facebook: (): FacebookProviderConfig | undefined => config.key(\"auth.providers.facebook\"),\n /** `auth.providers.x`, when configured. */\n x: (): XProviderConfig | undefined => config.key(\"auth.providers.x\"),\n /** An app-registered provider under `auth.providers.custom.<name>`. */\n custom: (name: string): AuthProvider | undefined => {\n const providers = config.key<Record<string, AuthProvider>>(\"auth.providers.custom\", {});\n\n // Own keys only: `name` arrives from a URL, and \"constructor\" must not resolve to Object.\n return Object.hasOwn(providers, name) ? providers[name] : undefined;\n },\n /** User attribute a verified provider email is matched against. @default \"email\" */\n emailField: (): string => config.key(\"auth.providers.emailField\", \"email\"),\n /** App-owned user creation for a first provider login. */\n createUser: (): ProviderUserCreator | undefined => config.key(\"auth.providers.createUser\"),\n },\n passkeys: {\n /** `auth.passkeys`; throws naming the keys when `rpID`, `rpName` or `origin` is missing. */\n settings: (): PasskeysConfig => {\n const settings = config.key<PasskeysConfig | undefined>(\"auth.passkeys\");\n\n if (!settings?.rpID || !settings.rpName || !settings.origin) {\n throw new Error(\n \"@warlock.js/auth: passkeys need `auth.passkeys.rpID`, `auth.passkeys.rpName` and `auth.passkeys.origin`.\",\n );\n }\n\n return settings;\n },\n /** Allowed ceremony origins, as a list. */\n origins: (): string[] => {\n const { origin } = authConfig.passkeys.settings();\n\n return Array.isArray(origin) ? origin : [origin];\n },\n /** Challenge lifetime in ms; throws naming the key when unusable. @default \"5m\" */\n challengeExpiresInMs: (): number =>\n parseDuration(\n \"passkeys.challengeExpiresIn\",\n config.key(\"auth.passkeys.challengeExpiresIn\", DEFAULT_PASSKEY_CHALLENGE_EXPIRES_IN),\n ),\n },\n otp: {\n /** Notifications channel the code is sent through. @default \"sms\" */\n channel: (): string => config.key(\"auth.otp.channel\", \"sms\"),\n /** User attribute holding the phone number. @default \"phone\" */\n phoneField: (): string => config.key(\"auth.otp.phoneField\", \"phone\"),\n /** Code lifetime in ms; throws naming the key when unusable. @default \"5m\" */\n expiresInMs: (): number =>\n parseDuration(\"otp.expiresIn\", config.key(\"auth.otp.expiresIn\", DEFAULT_OTP_EXPIRES_IN)),\n /** Verify attempts before the code is invalidated. @default 5 */\n maxAttempts: (): number => config.key(\"auth.otp.maxAttempts\", 5),\n /** The message text for a code. */\n message: (code: string): string => {\n const build = config.key<((code: string) => string) | undefined>(\"auth.otp.message\");\n\n return build ? build(code) : `Your verification code is ${code}`;\n },\n /** App-owned delivery replacing the notifications channel send. */\n send: (): OtpSender | undefined => config.key(\"auth.otp.send\"),\n },\n refreshToken: {\n /** Separate refresh secret (legacy: `auth.jwt.refresh.secret`); empty ⇒ fall back to the access secret. */\n secret: (): string | undefined => resolve(\"refreshToken.secret\", \"jwt.refresh.secret\"),\n /** Whether refresh tokens are enabled (legacy: `auth.jwt.refresh.enabled`). */\n enabled: (): boolean => resolve(\"refreshToken.enabled\", \"jwt.refresh.enabled\", true),\n /** Lifetime as an `ms`-string (legacy: `auth.jwt.refresh.expiresIn`). */\n expiresIn: (): string => resolve(\"refreshToken.expiresIn\", \"jwt.refresh.expiresIn\", \"7d\"),\n /**\n * Lifetime in milliseconds — the only form a token issuer may use. Throws\n * naming the key when the configured value is not a positive `ms` duration.\n */\n expiresInMs: (): number =>\n parseDuration(\"refreshToken.expiresIn\", authConfig.refreshToken.expiresIn()),\n /** Rotate-on-use (legacy: `auth.jwt.refresh.rotation`). */\n rotation: (): boolean => resolve(\"refreshToken.rotation\", \"jwt.refresh.rotation\", true),\n /** Max active tokens per user (legacy: `auth.jwt.refresh.maxPerUser`). */\n maxPerUser: (): number => resolve(\"refreshToken.maxPerUser\", \"jwt.refresh.maxPerUser\", 5),\n /** Logout-without-token behavior (legacy: `auth.jwt.refresh.logoutWithoutToken`). */\n logoutWithoutToken: (): LogoutWithoutTokenBehavior =>\n resolve(\"refreshToken.logoutWithoutToken\", \"jwt.refresh.logoutWithoutToken\", \"revoke-all\"),\n },\n};\n"],"mappings":";;;;;;AA6BA,MAAM,mCAAmB,IAAI,IAAY;AAEzC,MAAM,6BAAuD;;;;;;;;;;AAW7D,MAAM,UAAU;;;;;;;;;;;;;;;;;;AAmBhB,SAAS,cAAc,KAAa,KAAsB;CACxD,IAAI;CAEJ,IAAI;EACF,SAAS,QAAQ,GAAG;CACtB,QAAQ;EAEN,SAAS;CACX;CAEA,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,SAAS,MAAM,KAAK,UAAU,GACtE,MAAM,IAAI,MACR,QAAQ,IAAI,IAAI,KAAK,UAAU,GAAG,EAAE,mGAEtC;CAGF,OAAO;AACT;;AAGA,MAAM,kCAAkC;;AAGxC,MAAM,oCAAoC;;AAG1C,MAAM,uCAAuC;;AAG7C,MAAM,yBAAyB;;AAG/B,MAAM,kCAAkC;;;;;;;;;AAUxC,SAAS,QAAW,QAAgB,WAAmB,UAAiB;CACtE,MAAM,UAAU,OAAO,IAAI,QAAQ,QAAQ;CAE3C,IAAI,YAAY,UAAa,YAAY,MACvC,OAAO;CAGT,MAAM,aAAa,OAAO,IAAI,QAAQ,WAAW;CAEjD,IAAI,eAAe,UAAa,eAAe,MAAM;EACnD,IAAI,CAAC,iBAAiB,IAAI,SAAS,GAAG;GACpC,iBAAiB,IAAI,SAAS;GAC9B,IAAI,KACF,QACA,sBACA,QAAQ,UAAU,4BAA4B,QAChD;EACF;EAEA,OAAO;CACT;CAEA,OAAO;AACT;;;;;;AAOA,MAAa,aAAa;CACxB,iBAAiB,OAAO,SAAiC;EAMvD,OALwB,OAAO,IAC7B,wBACA,oBAGmB,CAAC,CAAC,IAAI;CAC7B;;CAEA,4BACE,OAAO,IACL,6BACA,2BACF;CACF,aAAa;;EAEX,cAAsB;GACpB,MAAM,SAAS,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,IAAI;;EAEtF,kBAA0B,QAAQ,2BAA2B,0BAA0B,CAAC;;EAExF,0BACE,QAAQ,mCAAmC,kCAAkC,YAAY;CAC7F;AACF"}
|
|
1
|
+
{"version":3,"file":"auth-config.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth-config.ts"],"sourcesContent":["import { config } from \"@warlock.js/core\";\nimport type { CookieDomainResolver } from \"../contracts/types\";\nimport { log } from \"@warlock.js/logger\";\nimport { type Algorithm } from \"fast-jwt\";\nimport ms from \"ms\";\nimport type {\n AuthNotification,\n CanAuthenticate,\n NormalizeCredentials,\n LogoutWithoutTokenBehavior,\n OneTimeTokenUrlBuilder,\n PasswordSetter,\n} from \"../contracts/types\";\nimport type {\n AppleProviderConfig,\n AuthProvider,\n DiscordProviderConfig,\n FacebookProviderConfig,\n GitHubProviderConfig,\n GoogleProviderConfig,\n LinkedInProviderConfig,\n OtpSender,\n PasskeysConfig,\n ProviderLinkExisting,\n ProviderUserCreator,\n XProviderConfig,\n} from \"../contracts/providers\";\nimport type { Auth } from \"../models/auth.model\";\nimport { defaultNormalizeCredentials } from \"../utils/normalize-credentials\";\n\nconst warnedLegacyKeys = new Set<string>();\n\n/** One-time production warnings already logged, by key. */\nconst warnedProduction = new Set<string>();\n\n/** Signing secrets shorter than this are brute-forceable from one captured token. */\nconst MIN_SECRET_BYTES = 32;\n\n/** Access-token lifetimes past this get a production warning. */\nconst LONG_ACCESS_TOKEN_MS = 30 * 24 * 60 * 60 * 1000;\n\n/** Same answer as core's `environment()`, read directly so config stays dependency-light. */\nfunction isProduction(): boolean {\n return process.env.NODE_ENV === \"production\";\n}\n\n/** Log `message` once per process, in production only. */\nfunction warnOnceInProduction(key: string, message: string): void {\n if (!isProduction() || warnedProduction.has(key)) return;\n\n warnedProduction.add(key);\n log.warn(\"auth\", \"config\", message);\n}\n\n/** Warn (production, once) when a signing secret is too short to resist offline guessing. */\nfunction checkSecretStrength(key: string, secret: string): void {\n if (Buffer.byteLength(secret) >= MIN_SECRET_BYTES) return;\n\n warnOnceInProduction(\n `secret:${key}`,\n `auth.${key} is shorter than ${MIN_SECRET_BYTES} bytes, so a captured token lets an attacker ` +\n `guess it offline and forge tokens. Generate a strong secret with \"warlock jwt.generate\".`,\n );\n}\n\nconst permitAuthentication: CanAuthenticate = (): boolean => true;\n\n/**\n * `ms` accepts anything at runtime and answers `undefined` for a string it\n * cannot parse (`\"30dayz\"`), a *formatted string* for a number (`2592000` ⇒\n * `\"43m\"`), and throws for `\"\"`. Its published types claim the far narrower\n * `(value: ms.StringValue) => number`, which is exactly what let an\n * `as ms.StringValue` cast smuggle arbitrary config text past the compiler and\n * hand `undefined` to the JWT signer. Declare the honest runtime signature once,\n * here, so every caller is forced to deal with the `undefined`.\n */\nconst parseMs = ms as unknown as (value: unknown) => number | string | undefined;\n\n/**\n * Turn a configured lifetime into a positive number of milliseconds, or throw\n * naming the key.\n *\n * A token lifetime is a security boundary, so an unusable value is a hard error\n * rather than a silent fallback: substituting a default would trade one\n * unintended lifetime for another, just as quietly — and quiet is the whole\n * problem. Every non-positive, non-finite or non-numeric parse is rejected:\n *\n * - `\"30dayz\"` / `\"thirty days\"` ⇒ `undefined` ⇒ a JWT signed with **no `exp`\n * claim** and an `Invalid Date` written to the token row.\n * - `\"0d\"` ⇒ parses cleanly to `0`, which `fast-jwt` treats as falsy and also\n * emits with **no `exp` claim** — it survives any guard that only rejects\n * `undefined`. `\"-1h\"` signs an already-expired token.\n * - `2592000` (a bare number) ⇒ `ms` *formats* it as `\"43m\"`, a string, which\n * then turns `Date.now() + expiresIn` into an `Invalid Date`.\n */\nfunction parseDuration(key: string, raw: unknown): number {\n let parsed: number | string | undefined;\n\n try {\n parsed = parseMs(raw);\n } catch {\n // ms throws (rather than returning undefined) for \"\" and non-strings\n parsed = undefined;\n }\n\n if (typeof parsed !== \"number\" || !Number.isFinite(parsed) || parsed <= 0) {\n throw new Error(\n `auth.${key}: ${JSON.stringify(raw)} is not a valid ms duration — ` +\n `use a positive duration string such as \"1h\", \"7d\", or NO_EXPIRATION.`,\n );\n }\n\n return parsed;\n}\n\n/** Email-verification token lifetime used when nothing is configured. */\nconst DEFAULT_VERIFICATION_EXPIRES_IN = \"24h\";\n\n/** Password-reset token lifetime used when nothing is configured. */\nconst DEFAULT_PASSWORD_RESET_EXPIRES_IN = \"60m\";\n\n/** Passkey challenge lifetime used when nothing is configured. */\nconst DEFAULT_PASSKEY_CHALLENGE_EXPIRES_IN = \"5m\";\n\n/** OTP lifetime used when nothing is configured. */\nconst DEFAULT_OTP_EXPIRES_IN = \"5m\";\n\n/** Access-token lifetime used when nothing is configured. */\nconst DEFAULT_ACCESS_TOKEN_EXPIRES_IN = \"1h\";\n\n/**\n * Resolve an auth setting, preferring the new `auth.accessToken.*` /\n * `auth.refreshToken.*` key and falling back to the deprecated `auth.jwt.*`\n * shape — warning once per legacy key. Returns `fallback` when neither is set.\n *\n * This is the backward-compatible shim that lets existing `auth.jwt.*` configs\n * keep working after the config split.\n */\nfunction resolve<T>(newKey: string, legacyKey: string, fallback?: T): T {\n const fromNew = config.key(`auth.${newKey}`);\n\n if (fromNew !== undefined && fromNew !== null) {\n return fromNew as T;\n }\n\n const fromLegacy = config.key(`auth.${legacyKey}`);\n\n if (fromLegacy !== undefined && fromLegacy !== null) {\n if (!warnedLegacyKeys.has(legacyKey)) {\n warnedLegacyKeys.add(legacyKey);\n log.warn(\n \"auth\",\n \"config-deprecation\",\n `auth.${legacyKey} is deprecated — use auth.${newKey}`,\n );\n }\n\n return fromLegacy as T;\n }\n\n return fallback as T;\n}\n\n/**\n * Typed, backward-compatible access to auth configuration. The service and the\n * jwt signer read configuration exclusively through here, so the new split\n * config and the legacy `auth.jwt.*` shape both resolve the same way.\n */\nexport const authConfig = {\n canAuthenticate: async (user: Auth): Promise<boolean> => {\n const canAuthenticate = config.key<CanAuthenticate>(\n \"auth.canAuthenticate\",\n permitAuthentication,\n );\n\n return canAuthenticate(user);\n },\n /**\n * Store only a SHA-256 digest of each access and refresh token\n * (`auth.hashTokensAtRest`). @default false\n */\n hashTokensAtRest: (): boolean => config.key<boolean>(\"auth.hashTokensAtRest\", false) === true,\n /** Login identifier normalizer, or `false` for exact matching. */\n normalizeCredentials: (): false | NormalizeCredentials =>\n config.key<false | NormalizeCredentials>(\n \"auth.normalizeCredentials\",\n defaultNormalizeCredentials,\n ),\n accessToken: {\n /** Signing secret (legacy: `auth.jwt.secret`). Throws if neither is set. */\n secret: (): string => {\n const secret = resolve<string | undefined>(\"accessToken.secret\", \"jwt.secret\");\n\n if (!secret) {\n throw new Error(\"auth: no JWT secret configured — set `auth.accessToken.secret`.\");\n }\n\n checkSecretStrength(\"accessToken.secret\", secret);\n\n return secret;\n },\n /** Signing algorithm (legacy: `auth.jwt.algorithm`). */\n algorithm: (): Algorithm => resolve(\"accessToken.algorithm\", \"jwt.algorithm\", \"HS256\"),\n /** `iss` claim stamped on and required of every token; unset ⇒ not used. */\n issuer: (): string | undefined => {\n const issuer = config.key<unknown>(\"auth.accessToken.issuer\");\n\n return typeof issuer === \"string\" && issuer.length > 0 ? issuer : undefined;\n },\n /** `aud` claim stamped on and required of every token; unset ⇒ not used. */\n audience: (): string | string[] | undefined => {\n const audience = config.key<unknown>(\"auth.accessToken.audience\");\n\n if (typeof audience === \"string\" && audience.length > 0) return audience;\n\n if (\n Array.isArray(audience) &&\n audience.length > 0 &&\n audience.every((entry) => typeof entry === \"string\" && entry.length > 0)\n ) {\n return audience as string[];\n }\n\n return undefined;\n },\n /** Lifetime as an `ms`-string (legacy: `auth.jwt.expiresIn`). */\n expiresIn: (): string | undefined => resolve(\"accessToken.expiresIn\", \"jwt.expiresIn\"),\n /**\n * Lifetime in milliseconds — the only form a token issuer may use. Defaults\n * to 1 hour when unset; throws naming the key when the configured value is\n * not a positive `ms` duration. See {@link parseDuration}.\n */\n expiresInMs: (): number => {\n const lifetime = parseDuration(\n \"accessToken.expiresIn\",\n authConfig.accessToken.expiresIn() ?? DEFAULT_ACCESS_TOKEN_EXPIRES_IN,\n );\n\n if (lifetime > LONG_ACCESS_TOKEN_MS) {\n warnOnceInProduction(\n \"accessToken.expiresIn\",\n \"auth.accessToken.expiresIn is longer than 30 days: a stolen access token stays usable \" +\n 'that long. Use a short lifetime (e.g. \"1h\") with refresh tokens ' +\n \"(auth.refreshToken.enabled) instead.\",\n );\n }\n\n return lifetime;\n },\n },\n pageAuth: {\n /**\n * Login path a guarded PAGE route redirects a logged-out browser to.\n *\n * Unset (the default) ⇒ page-route auth failures keep the JSON 401 API\n * contract, so existing apps see NO behavior change. Set it (e.g. \"/login\")\n * to opt a browser-facing app into login-redirect UX: a logged-out human\n * navigating to a guarded page lands on the login screen instead of reading\n * a raw JSON error blob. Finding b9ab9804.\n */\n loginPath: (): string | undefined => config.key(\"auth.pageAuth.loginPath\"),\n /**\n * Query parameter the redirect carries the originally-requested path in, so\n * the login flow can send the user back where they were headed. Defaults to\n * `\"returnUrl\"`.\n */\n returnUrlParam: (): string => config.key(\"auth.pageAuth.returnUrlParam\", \"returnUrl\"),\n },\n cookie: {\n /** Cookie name `setAuthCookie`/`clearAuthCookie` use. @default \"access_token\" */\n name: (): string => config.key(\"auth.cookie.name\", \"access_token\"),\n /** Refresh-token cookie name the session cookie helpers use. @default \"refresh_token\" */\n refreshName: (): string => config.key(\"auth.cookie.refreshName\", \"refresh_token\"),\n /** Cookie `Path` attribute `setAuthCookie`/`clearAuthCookie` use. @default \"/\" */\n path: (): string => config.key(\"auth.cookie.path\", \"/\"),\n /** Select the request-scoped cookie Domain; undefined keeps it host-only. */\n cookieDomain: (): CookieDomainResolver | undefined => config.key(\"auth.cookie.cookieDomain\"),\n /** Write the auth cookies as `__Host-<name>` (Secure, `Path=/`, no Domain). @default false */\n hostPrefix: (): boolean => config.key<boolean>(\"auth.cookie.hostPrefix\", false) === true,\n },\n csrf: {\n /**\n * Extra origins allowed on a cookie-authenticated unsafe-method request,\n * beyond the request's own origin. @default []\n */\n allowedOrigins: (): string[] => config.key(\"auth.csrf.allowedOrigins\", []),\n },\n verification: {\n /** Lifetime in ms of an email-verification token; throws naming the key when unusable. @default \"24h\" */\n expiresInMs: (): number =>\n parseDuration(\n \"verification.expiresIn\",\n config.key(\"auth.verification.expiresIn\", DEFAULT_VERIFICATION_EXPIRES_IN),\n ),\n /** User attribute stamped with the verification date. @default \"emailVerifiedAt\" */\n field: (): string => config.key(\"auth.verification.field\", \"emailVerifiedAt\"),\n /** App notification replacing the default verification email. */\n notification: (): AuthNotification | undefined => config.key(\"auth.verification.notification\"),\n /** Link builder whose result is handed to the notification as `url`. */\n url: (): OneTimeTokenUrlBuilder | undefined => config.key(\"auth.verification.url\"),\n },\n passwordReset: {\n /** Lifetime in ms of a password-reset token; throws naming the key when unusable. @default \"60m\" */\n expiresInMs: (): number =>\n parseDuration(\n \"passwordReset.expiresIn\",\n config.key(\"auth.passwordReset.expiresIn\", DEFAULT_PASSWORD_RESET_EXPIRES_IN),\n ),\n /** User attribute `requestPasswordReset` looks the account up by. @default \"email\" */\n identifierField: (): string => config.key(\"auth.passwordReset.identifierField\", \"email\"),\n /** App notification replacing the default reset email. */\n notification: (): AuthNotification | undefined => config.key(\"auth.passwordReset.notification\"),\n /** Link builder whose result is handed to the notification as `url`. */\n url: (): OneTimeTokenUrlBuilder | undefined => config.key(\"auth.passwordReset.url\"),\n /** App-owned password writer replacing the default. */\n setPassword: (): PasswordSetter | undefined => config.key(\"auth.passwordReset.setPassword\"),\n /** Wait for the reset notification before `requestPasswordReset` resolves. @default false */\n awaitDelivery: (): boolean =>\n config.key<boolean>(\"auth.passwordReset.awaitDelivery\", false) === true,\n },\n providers: {\n /** `auth.providers.google`, when configured. */\n google: (): GoogleProviderConfig | undefined => config.key(\"auth.providers.google\"),\n /** `auth.providers.github`, when configured. */\n github: (): GitHubProviderConfig | undefined => config.key(\"auth.providers.github\"),\n /** `auth.providers.discord`, when configured. */\n discord: (): DiscordProviderConfig | undefined => config.key(\"auth.providers.discord\"),\n /** `auth.providers.linkedin`, when configured. */\n linkedin: (): LinkedInProviderConfig | undefined => config.key(\"auth.providers.linkedin\"),\n /** `auth.providers.apple`, when configured. */\n apple: (): AppleProviderConfig | undefined => config.key(\"auth.providers.apple\"),\n /** `auth.providers.facebook`, when configured. */\n facebook: (): FacebookProviderConfig | undefined => config.key(\"auth.providers.facebook\"),\n /** `auth.providers.x`, when configured. */\n x: (): XProviderConfig | undefined => config.key(\"auth.providers.x\"),\n /** An app-registered provider under `auth.providers.custom.<name>`. */\n custom: (name: string): AuthProvider | undefined => {\n const providers = config.key<Record<string, AuthProvider>>(\"auth.providers.custom\", {});\n\n // Own keys only: `name` arrives from a URL, and \"constructor\" must not resolve to Object.\n return Object.hasOwn(providers, name) ? providers[name] : undefined;\n },\n /** User attribute a verified provider email is matched against. @default \"email\" */\n emailField: (): string => config.key(\"auth.providers.emailField\", \"email\"),\n /** App-owned user creation for a first provider login. */\n createUser: (): ProviderUserCreator | undefined => config.key(\"auth.providers.createUser\"),\n /** Linking a first provider login to an existing account by email. @default \"verified\" */\n linkExisting: (): ProviderLinkExisting => {\n const value = config.key<unknown>(\"auth.providers.linkExisting\", \"verified\");\n\n return value === \"always\" || value === \"never\" ? value : \"verified\";\n },\n },\n passkeys: {\n /** `auth.passkeys`; throws naming the keys when `rpID`, `rpName` or `origin` is missing. */\n settings: (): PasskeysConfig => {\n const settings = config.key<PasskeysConfig | undefined>(\"auth.passkeys\");\n\n if (!settings?.rpID || !settings.rpName || !settings.origin) {\n throw new Error(\n \"@warlock.js/auth: passkeys need `auth.passkeys.rpID`, `auth.passkeys.rpName` and `auth.passkeys.origin`.\",\n );\n }\n\n return settings;\n },\n /** Allowed ceremony origins, as a list. */\n origins: (): string[] => {\n const { origin } = authConfig.passkeys.settings();\n\n return Array.isArray(origin) ? origin : [origin];\n },\n /** User-verification requirement for both ceremonies. @default \"preferred\" */\n userVerification: (): \"required\" | \"preferred\" =>\n config.key<PasskeysConfig | undefined>(\"auth.passkeys\")?.userVerification === \"required\"\n ? \"required\"\n : \"preferred\",\n /** Challenge lifetime in ms; throws naming the key when unusable. @default \"5m\" */\n challengeExpiresInMs: (): number =>\n parseDuration(\n \"passkeys.challengeExpiresIn\",\n config.key(\"auth.passkeys.challengeExpiresIn\", DEFAULT_PASSKEY_CHALLENGE_EXPIRES_IN),\n ),\n },\n otp: {\n /** Notifications channel the code is sent through. @default \"sms\" */\n channel: (): string => config.key(\"auth.otp.channel\", \"sms\"),\n /** User attribute holding the phone number. @default \"phone\" */\n phoneField: (): string => config.key(\"auth.otp.phoneField\", \"phone\"),\n /** Code lifetime in ms; throws naming the key when unusable. @default \"5m\" */\n expiresInMs: (): number =>\n parseDuration(\"otp.expiresIn\", config.key(\"auth.otp.expiresIn\", DEFAULT_OTP_EXPIRES_IN)),\n /** Verify attempts before the code is invalidated. @default 5 */\n maxAttempts: (): number => config.key(\"auth.otp.maxAttempts\", 5),\n /** The message text for a code. */\n message: (code: string): string => {\n const build = config.key<((code: string) => string) | undefined>(\"auth.otp.message\");\n\n return build ? build(code) : `Your verification code is ${code}`;\n },\n /** App-owned delivery replacing the notifications channel send. */\n send: (): OtpSender | undefined => config.key(\"auth.otp.send\"),\n /** Wait for the code delivery before `requestOtp` resolves. @default false */\n awaitDelivery: (): boolean => config.key<boolean>(\"auth.otp.awaitDelivery\", false) === true,\n },\n refreshToken: {\n /** Separate refresh secret (legacy: `auth.jwt.refresh.secret`); empty ⇒ fall back to the access secret. */\n secret: (): string | undefined => {\n const secret = resolve<string | undefined>(\"refreshToken.secret\", \"jwt.refresh.secret\");\n\n if (secret) checkSecretStrength(\"refreshToken.secret\", secret);\n\n return secret;\n },\n /** Whether refresh tokens are enabled (legacy: `auth.jwt.refresh.enabled`). */\n enabled: (): boolean => resolve(\"refreshToken.enabled\", \"jwt.refresh.enabled\", true),\n /** Lifetime as an `ms`-string (legacy: `auth.jwt.refresh.expiresIn`). */\n expiresIn: (): string => resolve(\"refreshToken.expiresIn\", \"jwt.refresh.expiresIn\", \"7d\"),\n /**\n * Lifetime in milliseconds — the only form a token issuer may use. Throws\n * naming the key when the configured value is not a positive `ms` duration.\n */\n expiresInMs: (): number =>\n parseDuration(\"refreshToken.expiresIn\", authConfig.refreshToken.expiresIn()),\n /** Rotate-on-use (legacy: `auth.jwt.refresh.rotation`). */\n rotation: (): boolean => resolve(\"refreshToken.rotation\", \"jwt.refresh.rotation\", true),\n /** Max active tokens per user (legacy: `auth.jwt.refresh.maxPerUser`). */\n maxPerUser: (): number => resolve(\"refreshToken.maxPerUser\", \"jwt.refresh.maxPerUser\", 5),\n /** Logout-without-token behavior (legacy: `auth.jwt.refresh.logoutWithoutToken`). */\n logoutWithoutToken: (): LogoutWithoutTokenBehavior =>\n resolve(\"refreshToken.logoutWithoutToken\", \"jwt.refresh.logoutWithoutToken\", \"revoke-all\"),\n },\n};\n"],"mappings":";;;;;;AA8BA,MAAM,mCAAmB,IAAI,IAAY;;AAGzC,MAAM,mCAAmB,IAAI,IAAY;;AAGzC,MAAM,mBAAmB;;AAGzB,MAAM,uBAAuB;;AAG7B,SAAS,eAAwB;CAC/B,OAAO,QAAQ,IAAI,aAAa;AAClC;;AAGA,SAAS,qBAAqB,KAAa,SAAuB;CAChE,IAAI,CAAC,aAAa,KAAK,iBAAiB,IAAI,GAAG,GAAG;CAElD,iBAAiB,IAAI,GAAG;CACxB,IAAI,KAAK,QAAQ,UAAU,OAAO;AACpC;;AAGA,SAAS,oBAAoB,KAAa,QAAsB;CAC9D,IAAI,OAAO,WAAW,MAAM,KAAK,kBAAkB;CAEnD,qBACE,UAAU,OACV,QAAQ,IAAI,mBAAmB,iBAAiB,sIAElD;AACF;AAEA,MAAM,6BAAuD;;;;;;;;;;AAW7D,MAAM,UAAU;;;;;;;;;;;;;;;;;;AAmBhB,SAAS,cAAc,KAAa,KAAsB;CACxD,IAAI;CAEJ,IAAI;EACF,SAAS,QAAQ,GAAG;CACtB,QAAQ;EAEN,SAAS;CACX;CAEA,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,SAAS,MAA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Q,OAAO,IAA4C,kBAAkB;GAEnF,OAAO,QAAQ,MAAM,IAAI,IAAI,6BAA6B;EAC5D;;EAEA,YAAmC,OAAO,IAAI,eAAe;;EAE7D,qBAA8B,OAAO,IAAa,0BAA0B,KAAK,MAAM;CACzF;CACA,cAAc;;EAEZ,cAAkC;GAChC,MAAM,SAAS,QAA4B,uBAAuB,oBAAoB;GAEtF,IAAI,QAAQ,oBAAoB,uBAAuB,MAAM;GAE7D,OAAO;EACT;;EAEA,eAAwB,QAAQ,wBAAwB,uBAAuB,IAAI;;EAEnF,iBAAyB,QAAQ,0BAA0B,yBAAyB,IAAI;;;;;EAKxF,mBACE,cAAc,0BAA0B,WAAW,aAAa,UAAU,CAAC;;EAE7E,gBAAyB,QAAQ,yBAAyB,wBAAwB,IAAI;;EAEtF,kBAA0B,QAAQ,2BAA2B,0BAA0B,CAAC;;EAExF,0BACE,QAAQ,mCAAmC,kCAAkC,YAAY;CAC7F;AACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { authConfig } from "./auth-config.mjs";
|
|
2
|
+
import { config } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../../packages/auth/src/services/auth-cookie-names.ts
|
|
5
|
+
/** Name prefix browsers only accept on a Secure, `Path=/`, Domain-less cookie set by this host. */
|
|
6
|
+
const HOST_COOKIE_PREFIX = "__Host-";
|
|
7
|
+
/** Whether `auth.cookie.hostPrefix` is on. */
|
|
8
|
+
function hostPrefixEnabled() {
|
|
9
|
+
return authConfig.cookie.hostPrefix();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The name an auth cookie is written under: `__Host-<name>` when
|
|
13
|
+
* `auth.cookie.hostPrefix` is on, else `name` unchanged.
|
|
14
|
+
*/
|
|
15
|
+
function authCookieWriteName(name) {
|
|
16
|
+
if (!hostPrefixEnabled() || name.startsWith("__Host-")) return name;
|
|
17
|
+
return `${HOST_COOKIE_PREFIX}${name}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Every name an auth cookie may currently be stored under, newest first. With
|
|
21
|
+
* `auth.cookie.hostPrefix` on, a browser may still hold the unprefixed cookie
|
|
22
|
+
* written before the switch, so both are read (and both cleared).
|
|
23
|
+
*/
|
|
24
|
+
function authCookieNames(name) {
|
|
25
|
+
const written = authCookieWriteName(name);
|
|
26
|
+
return written === name ? [name] : [written, name];
|
|
27
|
+
}
|
|
28
|
+
/** Read an auth cookie under its prefixed name first, then the unprefixed one. */
|
|
29
|
+
function readAuthCookie(request, name) {
|
|
30
|
+
for (const candidate of authCookieNames(name)) {
|
|
31
|
+
const value = request.cookie(candidate);
|
|
32
|
+
if (value) return String(value);
|
|
33
|
+
}
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Refuse a cookie write that a browser would silently drop: a `__Host-`
|
|
38
|
+
* cookie must be set with `Path=/` and no `Domain`.
|
|
39
|
+
*/
|
|
40
|
+
function assertHostPrefixAllowed(name, attributes) {
|
|
41
|
+
if (!name.startsWith("__Host-")) return;
|
|
42
|
+
if (attributes.path !== void 0 && attributes.path !== "/") throw new Error(`auth.cookie.hostPrefix: cookie "${name}" must use Path=/ but was given "${attributes.path}". Set auth.cookie.path to "/" (and do not pass another path), or turn auth.cookie.hostPrefix off.`);
|
|
43
|
+
const globalDomain = config.key("http.cookies.options")?.domain;
|
|
44
|
+
if (attributes.domain !== void 0 || globalDomain !== void 0 && globalDomain !== null) throw new Error(`auth.cookie.hostPrefix: cookie "${name}" cannot carry a Domain attribute. Remove auth.cookie.cookieDomain (and any domain in http.cookies.options), or turn auth.cookie.hostPrefix off.`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { HOST_COOKIE_PREFIX, assertHostPrefixAllowed, authCookieNames, authCookieWriteName, readAuthCookie };
|
|
49
|
+
//# sourceMappingURL=auth-cookie-names.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-cookie-names.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth-cookie-names.ts"],"sourcesContent":["import { config } from \"@warlock.js/core\";\nimport { authConfig } from \"./auth-config\";\n\n/** Name prefix browsers only accept on a Secure, `Path=/`, Domain-less cookie set by this host. */\nexport const HOST_COOKIE_PREFIX = \"__Host-\";\n\n/** Whether `auth.cookie.hostPrefix` is on. */\nfunction hostPrefixEnabled(): boolean {\n return authConfig.cookie.hostPrefix();\n}\n\n/**\n * The name an auth cookie is written under: `__Host-<name>` when\n * `auth.cookie.hostPrefix` is on, else `name` unchanged.\n */\nexport function authCookieWriteName(name: string): string {\n if (!hostPrefixEnabled() || name.startsWith(HOST_COOKIE_PREFIX)) return name;\n\n return `${HOST_COOKIE_PREFIX}${name}`;\n}\n\n/**\n * Every name an auth cookie may currently be stored under, newest first. With\n * `auth.cookie.hostPrefix` on, a browser may still hold the unprefixed cookie\n * written before the switch, so both are read (and both cleared).\n */\nexport function authCookieNames(name: string): string[] {\n const written = authCookieWriteName(name);\n\n return written === name ? [name] : [written, name];\n}\n\n/** Read an auth cookie under its prefixed name first, then the unprefixed one. */\nexport function readAuthCookie(\n request: { cookie: (name: string) => unknown },\n name: string,\n): string {\n for (const candidate of authCookieNames(name)) {\n const value = request.cookie(candidate);\n\n if (value) return String(value);\n }\n\n return \"\";\n}\n\n/**\n * Refuse a cookie write that a browser would silently drop: a `__Host-`\n * cookie must be set with `Path=/` and no `Domain`.\n */\nexport function assertHostPrefixAllowed(\n name: string,\n attributes: { path?: string; domain?: string },\n): void {\n if (!name.startsWith(HOST_COOKIE_PREFIX)) return;\n\n if (attributes.path !== undefined && attributes.path !== \"/\") {\n throw new Error(\n `auth.cookie.hostPrefix: cookie \"${name}\" must use Path=/ but was given \"${attributes.path}\". ` +\n `Set auth.cookie.path to \"/\" (and do not pass another path), or turn auth.cookie.hostPrefix off.`,\n );\n }\n\n const globalDomain = config.key<{ domain?: unknown } | undefined>(\"http.cookies.options\")?.domain;\n\n if (attributes.domain !== undefined || (globalDomain !== undefined && globalDomain !== null)) {\n throw new Error(\n `auth.cookie.hostPrefix: cookie \"${name}\" cannot carry a Domain attribute. ` +\n \"Remove auth.cookie.cookieDomain (and any domain in http.cookies.options), or turn auth.cookie.hostPrefix off.\",\n );\n }\n}\n"],"mappings":";;;;;AAIA,MAAa,qBAAqB;;AAGlC,SAAS,oBAA6B;CACpC,OAAO,WAAW,OAAO,WAAW;AACtC;;;;;AAMA,SAAgB,oBAAoB,MAAsB;CACxD,IAAI,CAAC,kBAAkB,KAAK,KAAK,oBAA6B,GAAG,OAAO;CAExE,OAAO,GAAG,qBAAqB;AACjC;;;;;;AAOA,SAAgB,gBAAgB,MAAwB;CACtD,MAAM,UAAU,oBAAoB,IAAI;CAExC,OAAO,YAAY,OAAO,CAAC,IAAI,IAAI,CAAC,SAAS,IAAI;AACnD;;AAGA,SAAgB,eACd,SACA,MACQ;CACR,KAAK,MAAM,aAAa,gBAAgB,IAAI,GAAG;EAC7C,MAAM,QAAQ,QAAQ,OAAO,SAAS;EAEtC,IAAI,OAAO,OAAO,OAAO,KAAK;CAChC;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,wBACd,MACA,YACM;CACN,IAAI,CAAC,KAAK,oBAA6B,GAAG;CAE1C,IAAI,WAAW,SAAS,UAAa,WAAW,SAAS,KACvD,MAAM,IAAI,MACR,mCAAmC,KAAK,mCAAmC,WAAW,KAAK,mGAE7F;CAGF,MAAM,eAAe,OAAO,IAAsC,sBAAsB,CAAC,EAAE;CAE3F,IAAI,WAAW,WAAW,UAAc,iBAAiB,UAAa,iBAAiB,MACrF,MAAM,IAAI,MACR,mCAAmC,KAAK,iJAE1C;AAEJ"}
|
|
@@ -28,6 +28,10 @@ export type AuthEventPayloads = {
|
|
|
28
28
|
"password.changed": [user: Auth];
|
|
29
29
|
"password.resetRequested": [user: Auth, resetToken: string];
|
|
30
30
|
"password.reset": [user: Auth];
|
|
31
|
+
/** The reset notification failed after `requestPasswordReset` had already answered. */
|
|
32
|
+
"password.resetDeliveryFailed": [user: Auth, error: unknown];
|
|
33
|
+
/** The login code could not be delivered after `requestOtp` had already answered. */
|
|
34
|
+
"otp.deliveryFailed": [user: Auth, error: unknown];
|
|
31
35
|
"session.created": [user: Auth, refreshToken: RefreshToken, deviceInfo?: DeviceInfo];
|
|
32
36
|
"session.destroyed": [user: Auth, refreshToken: RefreshToken];
|
|
33
37
|
"cleanup.completed": [expiredCount: number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-events.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth-events.ts"],"mappings":";;;;;;;;;YASY;EAEV,kBAAkB,MAAM,MAAM,WAAW,WAAW,aAAa;EACjE,iBAAiB;IAAe;IAAgB;KAAqB;EACrE,kBAAkB;IAAe;IAAgB;;EAGjD,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,oBAAoB,MAAM;EAG1B,kBAAkB,MAAM,MAAM,WAAW;EACzC,oBAAoB,MAAM,MAAM,cAAc,WAAW,iBAAiB;EAC1E,kBAAkB,MAAM,MAAM,OAAO;EACrC,kBAAkB,OAAO;EACzB,wBAAwB,kBAAkB,QAAQ;EAGlD,qBAAqB,MAAM;EAC3B,4BAA4B,MAAM,MAAM;EACxC,mBAAmB,MAAM;
|
|
1
|
+
{"version":3,"file":"auth-events.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth-events.ts"],"mappings":";;;;;;;;;YASY;EAEV,kBAAkB,MAAM,MAAM,WAAW,WAAW,aAAa;EACjE,iBAAiB;IAAe;IAAgB;KAAqB;EACrE,kBAAkB;IAAe;IAAgB;;EAGjD,SAAS,MAAM;EACf,eAAe,MAAM;EACrB,oBAAoB,MAAM;EAG1B,kBAAkB,MAAM,MAAM,WAAW;EACzC,oBAAoB,MAAM,MAAM,cAAc,WAAW,iBAAiB;EAC1E,kBAAkB,MAAM,MAAM,OAAO;EACrC,kBAAkB,OAAO;EACzB,wBAAwB,kBAAkB,QAAQ;EAGlD,qBAAqB,MAAM;EAC3B,4BAA4B,MAAM,MAAM;EACxC,mBAAmB,MAAM;;EAEzB,iCAAiC,MAAM,MAAM;;EAI7C,uBAAuB,MAAM,MAAM;EAGnC,oBAAoB,MAAM,MAAM,cAAc,cAAc,aAAa;EACzE,sBAAsB,MAAM,MAAM,cAAc;EAGhD,sBAAsB;;;;;YAMZ,sBAAsB;;;;YAKtB,kBAAkB,UAAU,qBACnC,MAAM,kBAAkB,cACjB;;;;;;;;;;;;;;;;;;;qBAyBC;;;;EAIX,GAAG,UAAU,eAAa,OAAS,GAAC,UAAY,kBAAkB,KAAK;;;;EAOvE,UAAU,UAAU,eAAa,OAAS,GAAC,UAAY,kBAAkB,KAAK;;;;EAO9E,KAAK,UAAU,eAAa,OAAS,MAAC,MAAW,kBAAkB;;;;EAgBnE,QAAQ,UAAU,eAAa,OAAS,MAAC,MAAW,kBAAkB;;;;EAOtE;;;;EAOA,IAAG,QAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-events.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth-events.ts"],"sourcesContent":["import events, { type EventSubscription } from \"@mongez/events\";\nimport { log } from \"@warlock.js/logger\";\nimport type { DeviceInfo, TokenPair } from \"../contracts/types\";\nimport type { Auth } from \"../models/auth.model\";\nimport type { RefreshToken } from \"../models/refresh-token\";\n\n/**\n * Auth event payload types\n */\nexport type AuthEventPayloads = {\n // Login events\n \"login.success\": [user: Auth, tokenPair: TokenPair, deviceInfo?: DeviceInfo];\n \"login.failed\": [credentials: { email?: string; username?: string }, reason: string];\n \"login.attempt\": [credentials: { email?: string; username?: string }];\n\n // Logout events\n logout: [user: Auth];\n \"logout.all\": [user: Auth];\n \"logout.failsafe\": [user: Auth];\n\n // Token events\n \"token.created\": [user: Auth, tokenPair: TokenPair];\n \"token.refreshed\": [user: Auth, newTokenPair: TokenPair, oldRefreshToken: RefreshToken];\n \"token.revoked\": [user: Auth, token: RefreshToken];\n \"token.expired\": [token: RefreshToken];\n \"token.familyRevoked\": [familyId: string, tokens: RefreshToken[]];\n\n // Password events\n \"password.changed\": [user: Auth];\n \"password.resetRequested\": [user: Auth, resetToken: string];\n \"password.reset\": [user: Auth];\n\n // Session events\n \"session.created\": [user: Auth, refreshToken: RefreshToken, deviceInfo?: DeviceInfo];\n \"session.destroyed\": [user: Auth, refreshToken: RefreshToken];\n\n // Cleanup events\n \"cleanup.completed\": [expiredCount: number];\n};\n\n/**\n * Auth event names\n */\nexport type AuthEventName = keyof AuthEventPayloads;\n\n/**\n * Callback type for a specific event\n */\nexport type AuthEventCallback<T extends AuthEventName> = (\n ...args: AuthEventPayloads[T]\n) => void | Promise<void>;\n\n/**\n * Event namespace prefix for auth events\n */\nconst AUTH_EVENT_PREFIX = \"auth.\";\n\n/**\n * Type-safe auth events manager\n *\n * @example\n * ```typescript\n * // Subscribe to events with full autocomplete\n * authEvents.on(\"login.success\", (user, tokenPair, deviceInfo) => {\n * console.log(`User ${user.id} logged in`);\n * });\n *\n * authEvents.on(\"token.refreshed\", (user, newPair, oldToken) => {\n * console.log(`Token refreshed for user ${user.id}`);\n * });\n *\n * // Trigger events\n * authEvents.emit(\"login.success\", user, tokenPair, deviceInfo);\n * ```\n */\nexport const authEvents = {\n /**\n * Subscribe to an auth event\n */\n on<T extends AuthEventName>(event: T, callback: AuthEventCallback<T>): EventSubscription {\n return events.subscribe(AUTH_EVENT_PREFIX + event, callback as Function);\n },\n\n /**\n * Subscribe to an auth event (alias for `on`)\n */\n subscribe<T extends AuthEventName>(event: T, callback: AuthEventCallback<T>): EventSubscription {\n return this.on(event, callback);\n },\n\n /**\n * Emit an auth event\n */\n emit<T extends AuthEventName>(event: T, ...args: AuthEventPayloads[T]): void {\n try {\n events.trigger(AUTH_EVENT_PREFIX + event, ...args);\n } catch (error) {\n // Auth events are fire-and-forget notifications: a throwing listener must\n // never break the flow that emitted it (e.g. turn a completed login into a\n // 500). Log and swallow. NOTE: this guards synchronous listener throws;\n // async listener rejections and \"later listeners still run\" need a fix in\n // @mongez/events (tracked separately).\n log.error(\"auth\", \"event\", error);\n }\n },\n\n /**\n * Emit an auth event (alias for `emit`)\n */\n trigger<T extends AuthEventName>(event: T, ...args: AuthEventPayloads[T]): void {\n this.emit(event, ...args);\n },\n\n /**\n * Unsubscribe from all auth events\n */\n unsubscribeAll(): void {\n events.unsubscribeNamespace(AUTH_EVENT_PREFIX.slice(0, -1));\n },\n\n /**\n * Unsubscribe from a specific auth event\n */\n off(event?: AuthEventName): void {\n if (event) {\n events.unsubscribe(AUTH_EVENT_PREFIX + event);\n } else {\n this.unsubscribeAll();\n }\n },\n};\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"auth-events.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth-events.ts"],"sourcesContent":["import events, { type EventSubscription } from \"@mongez/events\";\nimport { log } from \"@warlock.js/logger\";\nimport type { DeviceInfo, TokenPair } from \"../contracts/types\";\nimport type { Auth } from \"../models/auth.model\";\nimport type { RefreshToken } from \"../models/refresh-token\";\n\n/**\n * Auth event payload types\n */\nexport type AuthEventPayloads = {\n // Login events\n \"login.success\": [user: Auth, tokenPair: TokenPair, deviceInfo?: DeviceInfo];\n \"login.failed\": [credentials: { email?: string; username?: string }, reason: string];\n \"login.attempt\": [credentials: { email?: string; username?: string }];\n\n // Logout events\n logout: [user: Auth];\n \"logout.all\": [user: Auth];\n \"logout.failsafe\": [user: Auth];\n\n // Token events\n \"token.created\": [user: Auth, tokenPair: TokenPair];\n \"token.refreshed\": [user: Auth, newTokenPair: TokenPair, oldRefreshToken: RefreshToken];\n \"token.revoked\": [user: Auth, token: RefreshToken];\n \"token.expired\": [token: RefreshToken];\n \"token.familyRevoked\": [familyId: string, tokens: RefreshToken[]];\n\n // Password events\n \"password.changed\": [user: Auth];\n \"password.resetRequested\": [user: Auth, resetToken: string];\n \"password.reset\": [user: Auth];\n /** The reset notification failed after `requestPasswordReset` had already answered. */\n \"password.resetDeliveryFailed\": [user: Auth, error: unknown];\n\n // One-time code events\n /** The login code could not be delivered after `requestOtp` had already answered. */\n \"otp.deliveryFailed\": [user: Auth, error: unknown];\n\n // Session events\n \"session.created\": [user: Auth, refreshToken: RefreshToken, deviceInfo?: DeviceInfo];\n \"session.destroyed\": [user: Auth, refreshToken: RefreshToken];\n\n // Cleanup events\n \"cleanup.completed\": [expiredCount: number];\n};\n\n/**\n * Auth event names\n */\nexport type AuthEventName = keyof AuthEventPayloads;\n\n/**\n * Callback type for a specific event\n */\nexport type AuthEventCallback<T extends AuthEventName> = (\n ...args: AuthEventPayloads[T]\n) => void | Promise<void>;\n\n/**\n * Event namespace prefix for auth events\n */\nconst AUTH_EVENT_PREFIX = \"auth.\";\n\n/**\n * Type-safe auth events manager\n *\n * @example\n * ```typescript\n * // Subscribe to events with full autocomplete\n * authEvents.on(\"login.success\", (user, tokenPair, deviceInfo) => {\n * console.log(`User ${user.id} logged in`);\n * });\n *\n * authEvents.on(\"token.refreshed\", (user, newPair, oldToken) => {\n * console.log(`Token refreshed for user ${user.id}`);\n * });\n *\n * // Trigger events\n * authEvents.emit(\"login.success\", user, tokenPair, deviceInfo);\n * ```\n */\nexport const authEvents = {\n /**\n * Subscribe to an auth event\n */\n on<T extends AuthEventName>(event: T, callback: AuthEventCallback<T>): EventSubscription {\n return events.subscribe(AUTH_EVENT_PREFIX + event, callback as Function);\n },\n\n /**\n * Subscribe to an auth event (alias for `on`)\n */\n subscribe<T extends AuthEventName>(event: T, callback: AuthEventCallback<T>): EventSubscription {\n return this.on(event, callback);\n },\n\n /**\n * Emit an auth event\n */\n emit<T extends AuthEventName>(event: T, ...args: AuthEventPayloads[T]): void {\n try {\n events.trigger(AUTH_EVENT_PREFIX + event, ...args);\n } catch (error) {\n // Auth events are fire-and-forget notifications: a throwing listener must\n // never break the flow that emitted it (e.g. turn a completed login into a\n // 500). Log and swallow. NOTE: this guards synchronous listener throws;\n // async listener rejections and \"later listeners still run\" need a fix in\n // @mongez/events (tracked separately).\n log.error(\"auth\", \"event\", error);\n }\n },\n\n /**\n * Emit an auth event (alias for `emit`)\n */\n trigger<T extends AuthEventName>(event: T, ...args: AuthEventPayloads[T]): void {\n this.emit(event, ...args);\n },\n\n /**\n * Unsubscribe from all auth events\n */\n unsubscribeAll(): void {\n events.unsubscribeNamespace(AUTH_EVENT_PREFIX.slice(0, -1));\n },\n\n /**\n * Unsubscribe from a specific auth event\n */\n off(event?: AuthEventName): void {\n if (event) {\n events.unsubscribe(AUTH_EVENT_PREFIX + event);\n } else {\n this.unsubscribeAll();\n }\n },\n};\n"],"mappings":";;;;;;;AA6DA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;AAoB1B,MAAa,aAAa;;;;CAIxB,GAA4B,OAAU,UAAmD;EACvF,OAAO,OAAO,UAAU,oBAAoB,OAAO,QAAoB;CACzE;;;;CAKA,UAAmC,OAAU,UAAmD;EAC9F,OAAO,KAAK,GAAG,OAAO,QAAQ;CAChC;;;;CAKA,KAA8B,OAAU,GAAG,MAAkC;EAC3E,IAAI;GACF,OAAO,QAAQ,oBAAoB,OAAO,GAAG,IAAI;EACnD,SAAS,OAAO;GAMd,IAAI,MAAM,QAAQ,SAAS,KAAK;EAClC;CACF;;;;CAKA,QAAiC,OAAU,GAAG,MAAkC;EAC9E,KAAK,KAAK,OAAO,GAAG,IAAI;CAC1B;;;;CAKA,iBAAuB;EACrB,OAAO,qBAAqB,kBAAkB,MAAM,GAAG,EAAE,CAAC;CAC5D;;;;CAKA,IAAI,OAA6B;EAC/B,IAAI,OACF,OAAO,YAAY,oBAAoB,KAAK;OAE5C,KAAK,eAAe;CAExB;AACF"}
|
|
@@ -86,6 +86,14 @@ declare class AuthService {
|
|
|
86
86
|
private hasSuccessor;
|
|
87
87
|
private isAutomaticOverlapOpen;
|
|
88
88
|
private readAutomaticSuccessor;
|
|
89
|
+
/**
|
|
90
|
+
* With hashed token rows, keep the successor pair (encrypted) in the cache
|
|
91
|
+
* for the overlap window, so a duplicate renewal inside it can still receive
|
|
92
|
+
* the same pair. Unhashed rows need nothing: the pair is read from them.
|
|
93
|
+
* Best-effort: without a cache, a duplicate inside the window fails quietly.
|
|
94
|
+
*/
|
|
95
|
+
private parkAutomaticSuccessor;
|
|
96
|
+
private readParkedSuccessor;
|
|
89
97
|
/**
|
|
90
98
|
* Verify a plaintext password against a stored hash.
|
|
91
99
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth.service.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"auth.service.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth.service.ts"],"mappings":";;;;;;;;;;qBAmDa,yCAAyC;EACpD,YAAmB;;cAyEf;;;;;;;cAOQ;;;;cAOA;;;;cAOA;;;;EAOL,wBAAwB,MAAM,OAAO;;EAS/B,gBAAgB,MAAM,OAAO;UAI5B;UAMA;;;;;;EAiCD,oBACX,MAAM,MACN,UAAU,0BACT,QAAQ;UAMG;;;;;;;UAkDA;;;;;EAgCD,mBACX,MAAM,MACN,aAAa,aACZ,QAAQ;UAcG;;;;EAqDD,gBAAgB,MAAM,MAAM,aAAa,aAAa,QAAQ;;;;;;EAiB9D,cACX,4BACA,aAAa,aACZ,QAAQ;;;;;;EA0FE,sBACX,4BACA,0BACA;IAAW;IAAoB,aAAa;IAAY;MACvD,QAAQ;;;;;;UAgHG;UAsBN;UAMA;UAWA;UAMA;UAOM;;;;;;;UA4DA;UAmBA;;;;EAaD,eAAe,uBAAuB,yBAAyB;;;;EAO/D,aAAa,mBAAmB;;;;;;UAS/B;;;;;EA0BD,aAAa,UAAU,MAClC,OAAO,WAAW,IAClB,MAAM,kBACL,QAAQ;;;;;EAuCE,MAAM,UAAU,MAC3B,OAAO,WAAW,IAClB,aAAa,iBACb,aAAa,aACZ,QAAQ,YAAY;;;;;;;;;;EAmBV,cAAc,UAAU,MACnC,MAAM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