@warlock.js/auth 5.30.0 → 5.32.0
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 +18 -1
- package/esm/commands/auth-cleanup-command.d.mts +1 -2
- package/esm/commands/auth-cleanup-command.d.mts.map +1 -1
- package/esm/commands/auth-purge-never-expiring-command.d.mts +1 -2
- package/esm/commands/auth-purge-never-expiring-command.d.mts.map +1 -1
- package/esm/commands/auth-purge-never-expiring-command.mjs.map +1 -1
- package/esm/commands/jwt-secret-generator-command.d.mts +1 -2
- package/esm/commands/jwt-secret-generator-command.d.mts.map +1 -1
- package/esm/commands/jwt-secret-generator-command.mjs.map +1 -1
- package/esm/contracts/auth-contract.d.mts +1 -3
- package/esm/contracts/auth-contract.d.mts.map +1 -1
- package/esm/contracts/index.d.mts +2 -1
- package/esm/contracts/providers.d.mts +82 -50
- package/esm/contracts/providers.d.mts.map +1 -1
- package/esm/contracts/request-locals.d.mts +2 -3
- package/esm/contracts/request-locals.d.mts.map +1 -1
- package/esm/contracts/types.d.mts +59 -43
- package/esm/contracts/types.d.mts.map +1 -1
- package/esm/errors/auth-provider-sdk-missing.error.d.mts +1 -3
- package/esm/errors/auth-provider-sdk-missing.error.d.mts.map +1 -1
- package/esm/errors/email-not-verified.error.d.mts +1 -3
- package/esm/errors/email-not-verified.error.d.mts.map +1 -1
- package/esm/errors/index.d.mts +2 -1
- package/esm/errors/index.mjs +1 -1
- package/esm/errors/invalid-one-time-token.error.d.mts +1 -3
- package/esm/errors/invalid-one-time-token.error.d.mts.map +1 -1
- package/esm/errors/invalid-passkey.error.d.mts +1 -3
- package/esm/errors/invalid-passkey.error.d.mts.map +1 -1
- package/esm/errors/invalid-provider-callback.error.d.mts +1 -3
- package/esm/errors/invalid-provider-callback.error.d.mts.map +1 -1
- package/esm/errors/notifications-unavailable.error.d.mts +1 -3
- package/esm/errors/notifications-unavailable.error.d.mts.map +1 -1
- package/esm/errors/provider-email-not-verified.error.d.mts +1 -3
- package/esm/errors/provider-email-not-verified.error.d.mts.map +1 -1
- package/esm/index.d.mts +8 -0
- package/esm/localization/auth-default-translations.d.mts +1 -3
- package/esm/localization/auth-default-translations.d.mts.map +1 -1
- package/esm/localization/auth-translations.type.d.mts +11 -7
- package/esm/localization/auth-translations.type.d.mts.map +1 -1
- package/esm/localization/index.mjs +1 -1
- package/esm/localization/register-auth-translations.d.mts +1 -2
- package/esm/localization/register-auth-translations.d.mts.map +1 -1
- package/esm/middleware/auth.middleware.d.mts +10 -10
- package/esm/middleware/auth.middleware.d.mts.map +1 -1
- package/esm/middleware/auth.middleware.mjs +2 -2
- package/esm/middleware/auth.middleware.mjs.map +1 -1
- package/esm/middleware/csrf-origin-check.d.mts +4 -6
- package/esm/middleware/csrf-origin-check.d.mts.map +1 -1
- package/esm/middleware/csrf-origin-check.mjs +1 -1
- package/esm/middleware/csrf-origin-check.mjs.map +1 -1
- package/esm/middleware/index.d.mts +2 -1
- package/esm/middleware/index.mjs +1 -1
- package/esm/middleware/login-throttle.middleware.d.mts +4 -6
- package/esm/middleware/login-throttle.middleware.d.mts.map +1 -1
- package/esm/middleware/login-throttle.middleware.mjs +1 -1
- package/esm/middleware/login-throttle.middleware.mjs.map +1 -1
- package/esm/middleware/one-time-token-throttle.middleware.d.mts +2 -4
- package/esm/middleware/one-time-token-throttle.middleware.d.mts.map +1 -1
- package/esm/middleware/otp-throttle.middleware.d.mts +2 -4
- package/esm/middleware/otp-throttle.middleware.d.mts.map +1 -1
- package/esm/middleware/require-verified-email.middleware.d.mts +1 -3
- package/esm/middleware/require-verified-email.middleware.d.mts.map +1 -1
- package/esm/models/access-token/access-token.model.d.mts +6 -30
- package/esm/models/access-token/access-token.model.d.mts.map +1 -1
- package/esm/models/access-token/index.d.mts +2 -1
- package/esm/models/access-token/index.mjs +1 -1
- package/esm/models/auth-token-family/auth-token-family.model.d.mts +2 -28
- package/esm/models/auth-token-family/auth-token-family.model.d.mts.map +1 -1
- package/esm/models/auth-token-family/index.d.mts +2 -1
- package/esm/models/auth-token-family/index.mjs +1 -1
- package/esm/models/auth.model.d.mts +1 -3
- package/esm/models/auth.model.d.mts.map +1 -1
- package/esm/models/index.d.mts +8 -2
- package/esm/models/index.d.mts.map +1 -1
- package/esm/models/index.mjs +1 -1
- package/esm/models/one-time-token/index.d.mts +2 -1
- package/esm/models/one-time-token/index.mjs +1 -1
- package/esm/models/one-time-token/one-time-token.model.d.mts +3 -37
- package/esm/models/one-time-token/one-time-token.model.d.mts.map +1 -1
- package/esm/models/passkey-credential/index.d.mts +2 -1
- package/esm/models/passkey-credential/index.mjs +1 -1
- package/esm/models/passkey-credential/passkey-credential.model.d.mts +2 -32
- package/esm/models/passkey-credential/passkey-credential.model.d.mts.map +1 -1
- package/esm/models/provider-account/index.d.mts +2 -1
- package/esm/models/provider-account/index.mjs +1 -1
- package/esm/models/provider-account/provider-account.model.d.mts +2 -28
- package/esm/models/provider-account/provider-account.model.d.mts.map +1 -1
- package/esm/models/refresh-token/index.d.mts +2 -1
- package/esm/models/refresh-token/index.mjs +1 -1
- package/esm/models/refresh-token/refresh-token.model.d.mts +11 -55
- package/esm/models/refresh-token/refresh-token.model.d.mts.map +1 -1
- package/esm/otp/index.d.mts +2 -1
- package/esm/otp/index.mjs +1 -1
- package/esm/otp/otp.d.mts +2 -4
- package/esm/otp/otp.d.mts.map +1 -1
- package/esm/otp/otp.mjs +2 -1
- package/esm/otp/otp.mjs.map +1 -1
- package/esm/passkeys/index.d.mts +2 -1
- package/esm/passkeys/index.mjs +1 -1
- package/esm/passkeys/passkey-authentication.d.mts +2 -4
- package/esm/passkeys/passkey-authentication.d.mts.map +1 -1
- package/esm/passkeys/passkey-authentication.mjs +2 -1
- package/esm/passkeys/passkey-authentication.mjs.map +1 -1
- package/esm/passkeys/passkey-registration.d.mts +3 -4
- package/esm/passkeys/passkey-registration.d.mts.map +1 -1
- package/esm/passkeys/simplewebauthn.d.mts +2 -3
- package/esm/passkeys/simplewebauthn.d.mts.map +1 -1
- package/esm/passkeys/simplewebauthn.mjs +1 -1
- package/esm/providers/apple-provider.d.mts +5 -9
- package/esm/providers/apple-provider.d.mts.map +1 -1
- package/esm/providers/discord-provider.d.mts +2 -7
- package/esm/providers/discord-provider.d.mts.map +1 -1
- package/esm/providers/facebook-provider.d.mts +2 -7
- package/esm/providers/facebook-provider.d.mts.map +1 -1
- package/esm/providers/github-provider.d.mts +2 -7
- package/esm/providers/github-provider.d.mts.map +1 -1
- package/esm/providers/google-provider.d.mts +5 -10
- package/esm/providers/google-provider.d.mts.map +1 -1
- package/esm/providers/index.d.mts +2 -1
- package/esm/providers/index.mjs +1 -1
- package/esm/providers/linkedin-provider.d.mts +3 -8
- package/esm/providers/linkedin-provider.d.mts.map +1 -1
- package/esm/providers/provider-login.d.mts +3 -5
- package/esm/providers/provider-login.d.mts.map +1 -1
- package/esm/providers/provider-login.mjs +3 -2
- package/esm/providers/provider-login.mjs.map +1 -1
- package/esm/providers/provider-state-cookie.mjs +3 -2
- package/esm/providers/provider-state-cookie.mjs.map +1 -1
- package/esm/providers/x-provider.d.mts +2 -7
- package/esm/providers/x-provider.d.mts.map +1 -1
- package/esm/services/auth-events.d.mts +5 -6
- package/esm/services/auth-events.d.mts.map +1 -1
- package/esm/services/auth.service.d.mts +10 -9
- package/esm/services/auth.service.d.mts.map +1 -1
- package/esm/services/current-user.d.mts +1 -3
- package/esm/services/current-user.d.mts.map +1 -1
- package/esm/services/email-verification.d.mts +3 -5
- package/esm/services/email-verification.d.mts.map +1 -1
- package/esm/services/generate-jwt-secret.d.mts +1 -2
- package/esm/services/generate-jwt-secret.d.mts.map +1 -1
- package/esm/services/index.d.mts +2 -1
- package/esm/services/index.mjs +1 -1
- package/esm/services/jwt.d.mts +8 -29
- package/esm/services/jwt.d.mts.map +1 -1
- package/esm/services/jwt.mjs +2 -2
- package/esm/services/jwt.mjs.map +1 -1
- package/esm/services/one-time-tokens.d.mts +6 -6
- package/esm/services/one-time-tokens.d.mts.map +1 -1
- package/esm/services/password-reset.d.mts +2 -4
- package/esm/services/password-reset.d.mts.map +1 -1
- package/esm/services/resolve-request-user.d.mts +19 -14
- package/esm/services/resolve-request-user.d.mts.map +1 -1
- package/esm/services/resolve-request-user.mjs.map +1 -1
- package/esm/services/token-family-operation.mjs +1 -1
- package/esm/session/index.d.mts +2 -1
- package/esm/session/index.mjs +1 -1
- package/esm/session/page-session.d.mts +26 -18
- package/esm/session/page-session.d.mts.map +1 -1
- package/esm/utils/auth-error-codes.d.mts +11 -22
- package/esm/utils/auth-error-codes.d.mts.map +1 -1
- package/esm/utils/index.mjs +1 -1
- package/esm/utils/safe-equal.d.mts +1 -2
- package/esm/utils/safe-equal.d.mts.map +1 -1
- package/esm/utils/token-expiry.d.mts +3 -4
- package/esm/utils/token-expiry.d.mts.map +1 -1
- package/llms-full.txt +189 -111
- package/package.json +8 -8
- package/skills/auth-basics/SKILL.md +10 -13
- package/skills/customize-token-storage/SKILL.md +24 -19
- package/skills/customize-user-type/SKILL.md +3 -1
- package/skills/index.md +4 -1
- package/skills/login-with-providers/SKILL.md +54 -29
- package/skills/manage-tokens/SKILL.md +2 -2
- package/skills/overview/SKILL.md +10 -1
- package/skills/protect-routes/SKILL.md +23 -14
- package/skills/register-user/SKILL.md +4 -4
- package/skills/run-auth-commands/SKILL.md +1 -1
- package/skills/throttle-login-attempts/SKILL.md +51 -22
- package/skills/verify-email-and-reset-password/SKILL.md +7 -5
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Auth } from "../models/auth.model.mjs";
|
|
2
2
|
import { AccessToken } from "../models/access-token/access-token.model.mjs";
|
|
3
|
+
import "../models/access-token/index.mjs";
|
|
3
4
|
import { OneTimeToken } from "../models/one-time-token/one-time-token.model.mjs";
|
|
5
|
+
import "../models/one-time-token/index.mjs";
|
|
4
6
|
import { OtpConfig, PasskeysConfig, ProvidersConfig } from "./providers.mjs";
|
|
7
|
+
import "../models/refresh-token/index.mjs";
|
|
5
8
|
import { RefreshToken } from "../models/refresh-token/refresh-token.model.mjs";
|
|
6
9
|
import { Request } from "@warlock.js/core";
|
|
7
10
|
import { ChildModel } from "@warlock.js/cascade";
|
|
8
11
|
import { Algorithm } from "fast-jwt";
|
|
9
|
-
|
|
10
12
|
//#region ../../packages/auth/src/contracts/types.d.ts
|
|
11
13
|
/**
|
|
12
14
|
* Symbol to indicate no expiration for tokens
|
|
@@ -27,27 +29,27 @@ import { Algorithm } from "fast-jwt";
|
|
|
27
29
|
* export default authConfigurations;
|
|
28
30
|
* ```
|
|
29
31
|
*/
|
|
30
|
-
declare const NO_EXPIRATION = "100y";
|
|
32
|
+
export declare const NO_EXPIRATION = "100y";
|
|
31
33
|
/**
|
|
32
34
|
* Behavior when logout is called without a refresh token
|
|
33
35
|
* - "revoke-all": Revoke all refresh tokens for the user (secure default)
|
|
34
36
|
* - "error": Return an error requiring the refresh token
|
|
35
37
|
*/
|
|
36
|
-
type LogoutWithoutTokenBehavior = "revoke-all" | "error";
|
|
38
|
+
export type LogoutWithoutTokenBehavior = "revoke-all" | "error";
|
|
37
39
|
/** The single request credential source an auth middleware instance accepts. */
|
|
38
|
-
type TokenFrom = "header" | `cookie:${string}`;
|
|
40
|
+
export type TokenFrom = "header" | `cookie:${string}`;
|
|
39
41
|
/** One explicitly named credential location accepted by auth middleware. */
|
|
40
|
-
interface AuthCredentialDescriptor {
|
|
42
|
+
export interface AuthCredentialDescriptor {
|
|
41
43
|
source: "header" | "cookie";
|
|
42
44
|
key?: string;
|
|
43
45
|
}
|
|
44
46
|
/** Cookie credential and bounded duplicate window for automatic renewal. */
|
|
45
|
-
interface AuthRefreshCredentialDescriptor extends AuthCredentialDescriptor {
|
|
47
|
+
export interface AuthRefreshCredentialDescriptor extends AuthCredentialDescriptor {
|
|
46
48
|
/** Milliseconds; the service clamps this to the 0–10 second range (default 5 seconds). */
|
|
47
49
|
overlapMs?: number;
|
|
48
50
|
}
|
|
49
51
|
/** Per-route authentication behavior for the object middleware overload. */
|
|
50
|
-
interface AuthMiddlewareOptions extends Partial<AuthCredentialDescriptor> {
|
|
52
|
+
export interface AuthMiddlewareOptions extends Partial<AuthCredentialDescriptor> {
|
|
51
53
|
optional?: boolean;
|
|
52
54
|
/**
|
|
53
55
|
* Accept both a header and a cookie credential (at most one of each).
|
|
@@ -65,9 +67,9 @@ interface AuthMiddlewareOptions extends Partial<AuthCredentialDescriptor> {
|
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
69
|
/** Application policy that decides whether a resolved user may authenticate. */
|
|
68
|
-
type CanAuthenticate = (user: Auth) => boolean | Promise<boolean>;
|
|
70
|
+
export type CanAuthenticate = (user: Auth) => boolean | Promise<boolean>;
|
|
69
71
|
/** Password credentials plus the application-defined identity fields. */
|
|
70
|
-
type AuthCredentials = Record<string, unknown> & {
|
|
72
|
+
export type AuthCredentials = Record<string, unknown> & {
|
|
71
73
|
password: string;
|
|
72
74
|
};
|
|
73
75
|
/**
|
|
@@ -76,7 +78,7 @@ type AuthCredentials = Record<string, unknown> & {
|
|
|
76
78
|
* `secret` may also be supplied via the deprecated `jwt.secret` (resolved by a
|
|
77
79
|
* backward-compatible shim); one of the two is required at runtime.
|
|
78
80
|
*/
|
|
79
|
-
type AccessTokenConfig = {
|
|
81
|
+
export type AccessTokenConfig = {
|
|
80
82
|
/**
|
|
81
83
|
* Override the persisted access-token model — extend {@link AccessToken} to
|
|
82
84
|
* add columns (e.g. a tenant key) or rename them, then register the subclass
|
|
@@ -106,7 +108,7 @@ type AccessTokenConfig = {
|
|
|
106
108
|
/**
|
|
107
109
|
* Refresh-token configuration.
|
|
108
110
|
*/
|
|
109
|
-
type RefreshTokenConfig = {
|
|
111
|
+
export type RefreshTokenConfig = {
|
|
110
112
|
/**
|
|
111
113
|
* Override the persisted refresh-token model — extend {@link RefreshToken}.
|
|
112
114
|
* Defaults to the package's `RefreshToken`.
|
|
@@ -152,7 +154,7 @@ type RefreshTokenConfig = {
|
|
|
152
154
|
*
|
|
153
155
|
* @deprecated Use the top-level `accessToken` / `refreshToken` blocks.
|
|
154
156
|
*/
|
|
155
|
-
type LegacyJwtConfig = {
|
|
157
|
+
export type LegacyJwtConfig = {
|
|
156
158
|
secret?: string;
|
|
157
159
|
algorithm?: Algorithm;
|
|
158
160
|
expiresIn?: string;
|
|
@@ -173,7 +175,7 @@ type LegacyJwtConfig = {
|
|
|
173
175
|
* Read at runtime through `authConfig.pageAuth` (`auth.pageAuth.*`). API routes
|
|
174
176
|
* always keep the JSON 401 contract regardless of this setting.
|
|
175
177
|
*/
|
|
176
|
-
type PageAuthConfig = {
|
|
178
|
+
export type PageAuthConfig = {
|
|
177
179
|
/**
|
|
178
180
|
* Login path a guarded page route redirects a logged-out browser to (e.g.
|
|
179
181
|
* `"/login"`). Unset ⇒ page-route auth failures keep the JSON 401, so the
|
|
@@ -190,26 +192,29 @@ type PageAuthConfig = {
|
|
|
190
192
|
/**
|
|
191
193
|
* Data every email-verification / password-reset notification receives.
|
|
192
194
|
*/
|
|
193
|
-
type OneTimeTokenNotificationData = {
|
|
194
|
-
/** The raw token — the only place it exists; only its SHA-256 hash is stored. */
|
|
195
|
-
|
|
195
|
+
export type OneTimeTokenNotificationData = {
|
|
196
|
+
/** The raw token — the only place it exists; only its SHA-256 hash is stored. */
|
|
197
|
+
token: string;
|
|
198
|
+
/** When the token stops working. */
|
|
199
|
+
expiresAt: Date;
|
|
200
|
+
/** The link built by `auth.verification.url` / `auth.passwordReset.url`, when configured. */
|
|
196
201
|
url?: string;
|
|
197
202
|
};
|
|
198
203
|
/**
|
|
199
204
|
* Anything auth can deliver a token through — a `defineNotification(...)`
|
|
200
205
|
* result satisfies it, as does any object with a compatible `send`.
|
|
201
206
|
*/
|
|
202
|
-
type AuthNotification = {
|
|
207
|
+
export type AuthNotification = {
|
|
203
208
|
send: (to: Auth, data: OneTimeTokenNotificationData) => unknown;
|
|
204
209
|
};
|
|
205
210
|
/** Builds the link a token notification points at. */
|
|
206
|
-
type OneTimeTokenUrlBuilder = (token: string, user: Auth) => string;
|
|
211
|
+
export type OneTimeTokenUrlBuilder = (token: string, user: Auth) => string;
|
|
207
212
|
/** Persists a new plaintext password for a user during a password reset. */
|
|
208
|
-
type PasswordSetter = (user: Auth, plainPassword: string) => void | Promise<void>;
|
|
213
|
+
export type PasswordSetter = (user: Auth, plainPassword: string) => void | Promise<void>;
|
|
209
214
|
/**
|
|
210
215
|
* Email-verification configuration (`auth.verification`).
|
|
211
216
|
*/
|
|
212
|
-
type EmailVerificationConfig = {
|
|
217
|
+
export type EmailVerificationConfig = {
|
|
213
218
|
/**
|
|
214
219
|
* Token lifetime — a positive `ms` duration string.
|
|
215
220
|
* @default "24h"
|
|
@@ -220,14 +225,16 @@ type EmailVerificationConfig = {
|
|
|
220
225
|
* user schema (e.g. `emailVerifiedAt: v.date().optional()`).
|
|
221
226
|
* @default "emailVerifiedAt"
|
|
222
227
|
*/
|
|
223
|
-
field?: string;
|
|
224
|
-
|
|
228
|
+
field?: string;
|
|
229
|
+
/** Replace the default verification email. */
|
|
230
|
+
notification?: AuthNotification;
|
|
231
|
+
/** Build the verification link passed to the notification as `url`. */
|
|
225
232
|
url?: OneTimeTokenUrlBuilder;
|
|
226
233
|
};
|
|
227
234
|
/**
|
|
228
235
|
* Password-reset configuration (`auth.passwordReset`).
|
|
229
236
|
*/
|
|
230
|
-
type PasswordResetConfig = {
|
|
237
|
+
export type PasswordResetConfig = {
|
|
231
238
|
/**
|
|
232
239
|
* Token lifetime — a positive `ms` duration string.
|
|
233
240
|
* @default "60m"
|
|
@@ -237,8 +244,10 @@ type PasswordResetConfig = {
|
|
|
237
244
|
* User attribute `requestPasswordReset` looks the account up by.
|
|
238
245
|
* @default "email"
|
|
239
246
|
*/
|
|
240
|
-
identifierField?: string;
|
|
241
|
-
|
|
247
|
+
identifierField?: string;
|
|
248
|
+
/** Replace the default reset email. */
|
|
249
|
+
notification?: AuthNotification;
|
|
250
|
+
/** Build the reset link passed to the notification as `url`. */
|
|
242
251
|
url?: OneTimeTokenUrlBuilder;
|
|
243
252
|
/**
|
|
244
253
|
* Persist the new password yourself. By default auth saves a hash made by
|
|
@@ -251,17 +260,19 @@ type PasswordResetConfig = {
|
|
|
251
260
|
/**
|
|
252
261
|
* One-time token storage configuration (`auth.oneTimeToken`).
|
|
253
262
|
*/
|
|
254
|
-
type OneTimeTokenConfig = {
|
|
255
|
-
/** Override the persisted model — extend {@link OneTimeToken}. */
|
|
263
|
+
export type OneTimeTokenConfig = {
|
|
264
|
+
/** Override the persisted model — extend {@link OneTimeToken}. */
|
|
265
|
+
model?: typeof OneTimeToken;
|
|
256
266
|
};
|
|
257
|
-
type AuthConfigurations = {
|
|
267
|
+
export type AuthConfigurations = {
|
|
258
268
|
/**
|
|
259
269
|
* Define all user types — maps a user-type slug to its `Auth` model class so
|
|
260
270
|
* tokens and the middleware can resolve the right model.
|
|
261
271
|
*/
|
|
262
272
|
userType: {
|
|
263
273
|
[userType: string]: ChildModel<Auth>;
|
|
264
|
-
};
|
|
274
|
+
};
|
|
275
|
+
/** Default user type used by `authMiddleware()` and options-only overloads. */
|
|
265
276
|
defaultUserType?: string;
|
|
266
277
|
/**
|
|
267
278
|
* Decide whether a resolved user may authenticate or receive new tokens.
|
|
@@ -321,7 +332,7 @@ type AuthConfigurations = {
|
|
|
321
332
|
*/
|
|
322
333
|
jwt?: LegacyJwtConfig;
|
|
323
334
|
};
|
|
324
|
-
type AccessTokenOutput = {
|
|
335
|
+
export type AccessTokenOutput = {
|
|
325
336
|
/**
|
|
326
337
|
* JWT Token
|
|
327
338
|
*/
|
|
@@ -334,7 +345,7 @@ type AccessTokenOutput = {
|
|
|
334
345
|
/**
|
|
335
346
|
* Token pair returned after login or token refresh
|
|
336
347
|
*/
|
|
337
|
-
type TokenPair = {
|
|
348
|
+
export type TokenPair = {
|
|
338
349
|
/**
|
|
339
350
|
* JWT access token (short-lived)
|
|
340
351
|
*/
|
|
@@ -347,7 +358,7 @@ type TokenPair = {
|
|
|
347
358
|
/**
|
|
348
359
|
* Device information for session tracking
|
|
349
360
|
*/
|
|
350
|
-
type DeviceInfo = {
|
|
361
|
+
export type DeviceInfo = {
|
|
351
362
|
/**
|
|
352
363
|
* User agent string from request
|
|
353
364
|
*/
|
|
@@ -370,12 +381,12 @@ type DeviceInfo = {
|
|
|
370
381
|
*/
|
|
371
382
|
payload?: Record<string, unknown>;
|
|
372
383
|
};
|
|
373
|
-
type LoginResult<UserType extends Auth> = {
|
|
384
|
+
export type LoginResult<UserType extends Auth> = {
|
|
374
385
|
user: UserType;
|
|
375
386
|
tokens: TokenPair;
|
|
376
387
|
};
|
|
377
388
|
/** Selects a cookie Domain for one request; return `undefined` for a host-only cookie. */
|
|
378
|
-
type CookieDomainResolver = (request: Request) => string | undefined;
|
|
389
|
+
export type CookieDomainResolver = (request: Request) => string | undefined;
|
|
379
390
|
/**
|
|
380
391
|
* Configuration for the cookie an app opts into via `authService.setAuthCookie`
|
|
381
392
|
* / `clearAuthCookie` and reads back with `authMiddleware([], "cookie:<name>")`.
|
|
@@ -384,7 +395,7 @@ type CookieDomainResolver = (request: Request) => string | undefined;
|
|
|
384
395
|
* same floor every `response.cookie()` call gets, so a cookie auth session can
|
|
385
396
|
* never be weakened to a laxer policy than the framework default.
|
|
386
397
|
*/
|
|
387
|
-
type CookieAuthConfig = {
|
|
398
|
+
export type CookieAuthConfig = {
|
|
388
399
|
/**
|
|
389
400
|
* Cookie name `setAuthCookie`/`clearAuthCookie` write and clear, and that a
|
|
390
401
|
* `cookie:<name>` token source must match to read it back.
|
|
@@ -400,14 +411,15 @@ type CookieAuthConfig = {
|
|
|
400
411
|
* Cookie `Path` attribute.
|
|
401
412
|
* @default "/"
|
|
402
413
|
*/
|
|
403
|
-
path?: string;
|
|
414
|
+
path?: string;
|
|
415
|
+
/** Select a request-scoped Domain; `undefined` keeps the cookie host-only. */
|
|
404
416
|
cookieDomain?: CookieDomainResolver;
|
|
405
417
|
};
|
|
406
418
|
/**
|
|
407
419
|
* CSRF Origin-check configuration. Read via
|
|
408
420
|
* `authConfig.csrf.allowedOrigins()`.
|
|
409
421
|
*/
|
|
410
|
-
type CsrfConfig = {
|
|
422
|
+
export type CsrfConfig = {
|
|
411
423
|
/**
|
|
412
424
|
* Extra origins allowed on a cookie-authenticated unsafe-method request,
|
|
413
425
|
* in addition to the request's own origin.
|
|
@@ -421,9 +433,12 @@ type CsrfConfig = {
|
|
|
421
433
|
* *attribute* flags (`httpOnly`/`sameSite`/`secure`) are never settable here —
|
|
422
434
|
* see {@link CookieAuthConfig}.
|
|
423
435
|
*/
|
|
424
|
-
type SetAuthCookieOptions = {
|
|
425
|
-
/** Cookie name; defaults to `auth.cookie.name` (package default `"access_token"`). */
|
|
426
|
-
|
|
436
|
+
export type SetAuthCookieOptions = {
|
|
437
|
+
/** Cookie name; defaults to `auth.cookie.name` (package default `"access_token"`). */
|
|
438
|
+
name?: string;
|
|
439
|
+
/** Cookie `Path`; defaults to `auth.cookie.path` (package default `"/"`). */
|
|
440
|
+
path?: string;
|
|
441
|
+
/** Cookie `Domain` attribute. Omit for a host-only cookie. */
|
|
427
442
|
domain?: string;
|
|
428
443
|
/**
|
|
429
444
|
* `Max-Age`, in seconds. Overrides the expiry `setAuthCookie` would
|
|
@@ -434,10 +449,11 @@ type SetAuthCookieOptions = {
|
|
|
434
449
|
maxAge?: number;
|
|
435
450
|
};
|
|
436
451
|
/** Per-call overrides for {@link AuthService.clearAuthCookie}. */
|
|
437
|
-
type ClearAuthCookieOptions = {
|
|
438
|
-
/** Cookie name; defaults to `auth.cookie.name` (package default `"access_token"`). */
|
|
452
|
+
export type ClearAuthCookieOptions = {
|
|
453
|
+
/** Cookie name; defaults to `auth.cookie.name` (package default `"access_token"`). */
|
|
454
|
+
name?: string;
|
|
455
|
+
/** Cookie `Path`; defaults to `auth.cookie.path` (package default `"/"`). Must match the `Path` the cookie was set with. */
|
|
439
456
|
path?: string;
|
|
440
457
|
};
|
|
441
458
|
//#endregion
|
|
442
|
-
export { AccessTokenConfig, AccessTokenOutput, AuthConfigurations, AuthCredentialDescriptor, AuthCredentials, AuthMiddlewareOptions, AuthNotification, AuthRefreshCredentialDescriptor, CanAuthenticate, ClearAuthCookieOptions, CookieAuthConfig, CookieDomainResolver, CsrfConfig, DeviceInfo, EmailVerificationConfig, LegacyJwtConfig, LoginResult, LogoutWithoutTokenBehavior, NO_EXPIRATION, OneTimeTokenConfig, OneTimeTokenNotificationData, OneTimeTokenUrlBuilder, PageAuthConfig, PasswordResetConfig, PasswordSetter, RefreshTokenConfig, SetAuthCookieOptions, TokenFrom, TokenPair };
|
|
443
459
|
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/contracts/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/contracts/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA4Ba;;;;;;YAOD;;YAGA;;iBAGK;EACf;EACA;;;iBAIe,wCAAwC;;EAEvD;;;iBAIe,8BAA8B,QAAQ;EACrD;;;;;;;;EAQA,UAAU;;EAEV,UAAU;EACV;IAAa;IAAY;;;;YAIf,mBAAmB,MAAM,mBAAmB;;YAG5C,kBAAkB;EAC5B;;;;;;;;YASU;;;;;;EAMV,eAAe;;;;EAIf;;;;;EAKA,YAAY;;;;;;;;;;EAUZ;;;;;YAMU;;;;;EAKV,eAAe;;;;;EAKf;;;;;EAKA;;;;;;;;EAQA;;;;;EAKA;;;;;EAKA;;;;;EAKA,qBAAqB;;;;;;;;YASX;EACV;EACA,YAAY;EACZ;EACA;IACE;IACA;IACA;IACA;IACA;IACA,qBAAqB;;;;;;;;;;;YAYb;;;;;;EAMV;;;;;;EAMA;;;;;YAMU;;EAEV;;EAEA,WAAW;;EAEX;;;;;;YAOU;EACV,OAAO,IAAI,MAAM,MAAM;;;YAIb,0BAA0B,eAAe,MAAM;;YAG/C,kBAAkB,MAAM,MAAM,iCAAiC;;;;YAK/D;;;;;EAKV;;;;;;EAMA;;EAEA,eAAe;;EAEf,MAAM;;;;;YAMI;;;;;EAKV;;;;;EAKA;;EAEA,eAAe;;EAEf,MAAM;;;;;;;EAON,cAAc;;;;;YAMJ;;EAEV,eAAe;;YAGL;;;;;EAKV;KACG,mBAAmB,WAAW;;;EAGjC;;;;;EAKA,kBAAkB;;;;EAIlB,cAAc;;;;EAId,eAAe;;;;;;EAMf,WAAW;;;;;;EAMX,SAAS;;;;EAIT,OAAO;;;;EAIP,eAAe;;;;EAIf,gBAAgB;;;;EAIhB,eAAe;;;;EAIf,YAAY;;;;EAIZ,WAAW;;;;EAIX,MAAM;;;;EAIN,MAAM;;YAGI;;;;EAIV;;;;EAIA;;;;;YAMU;;;;EAIV,aAAa;;;;EAIb,eAAe;;;;;YAML;;;;EAIV;;;;EAIA;;;;EAIA;;;;;EAKA;;;;EAIA,UAAU;;YAGA,YAAY,iBAAiB;EACvC,MAAM;EACN,QAAQ;;;YAIE,wBAAwB,SAAS;;;;;;;;;YAUjC;;;;;;EAMV;;;;;EAKA;;;;;EAKA;;EAEA,eAAe;;;;;;YAOL;;;;;;EAMV;;;;;;;;YASU;;EAEV;;EAEA;;EAEA;;;;;;;EAOA;;;YAIU;;EAEV;;EAEA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ServerError } from "@warlock.js/core";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/auth/src/errors/auth-provider-sdk-missing.error.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* A login method needs a vendor SDK that is an optional peer of
|
|
@@ -7,11 +6,10 @@ import { ServerError } from "@warlock.js/core";
|
|
|
7
6
|
* the `warlock add` command that installs it; the resolver failure is kept on
|
|
8
7
|
* `cause`.
|
|
9
8
|
*/
|
|
10
|
-
declare class AuthProviderSdkMissingError extends ServerError {
|
|
9
|
+
export declare class AuthProviderSdkMissingError extends ServerError {
|
|
11
10
|
readonly packageName: string;
|
|
12
11
|
readonly feature: string;
|
|
13
12
|
constructor(packageName: string, feature: string, cause?: unknown);
|
|
14
13
|
}
|
|
15
14
|
//#endregion
|
|
16
|
-
export { AuthProviderSdkMissingError };
|
|
17
15
|
//# sourceMappingURL=auth-provider-sdk-missing.error.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-provider-sdk-missing.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/auth-provider-sdk-missing.error.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth-provider-sdk-missing.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/auth-provider-sdk-missing.error.ts"],"mappings":";;;;;;;;qBAQa,oCAAoC;WAE7B;WACA;EAFlB,YACkB,qBACA,iBAChB"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
2
|
import { ForbiddenError } from "@warlock.js/core";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/errors/email-not-verified.error.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* The authenticated user has not verified their email address. Thrown by
|
|
7
6
|
* `requireVerifiedEmail()`; core's error handler answers it with `403` and a
|
|
8
7
|
* `payload.errorCode` of `EC007`.
|
|
9
8
|
*/
|
|
10
|
-
declare class EmailNotVerifiedError extends ForbiddenError {
|
|
9
|
+
export declare class EmailNotVerifiedError extends ForbiddenError {
|
|
11
10
|
readonly code = AuthErrorCodes.EmailNotVerified;
|
|
12
11
|
constructor(message?: string);
|
|
13
12
|
}
|
|
14
13
|
//#endregion
|
|
15
|
-
export { EmailNotVerifiedError };
|
|
16
14
|
//# sourceMappingURL=email-not-verified.error.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-not-verified.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/email-not-verified.error.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"email-not-verified.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/email-not-verified.error.ts"],"mappings":";;;;;;;;qBAQa,8BAA8B;WACzB,OAAI,eAAA;EAEpB,YAAmB"}
|
package/esm/errors/index.d.mts
CHANGED
|
@@ -4,4 +4,5 @@ import { InvalidOneTimeTokenError } from "./invalid-one-time-token.error.mjs";
|
|
|
4
4
|
import { InvalidPasskeyError } from "./invalid-passkey.error.mjs";
|
|
5
5
|
import { InvalidProviderCallbackError } from "./invalid-provider-callback.error.mjs";
|
|
6
6
|
import { NotificationsUnavailableError } from "./notifications-unavailable.error.mjs";
|
|
7
|
-
import { ProviderEmailNotVerifiedError } from "./provider-email-not-verified.error.mjs";
|
|
7
|
+
import { ProviderEmailNotVerifiedError } from "./provider-email-not-verified.error.mjs";
|
|
8
|
+
export { AuthProviderSdkMissingError, EmailNotVerifiedError, InvalidOneTimeTokenError, InvalidPasskeyError, InvalidProviderCallbackError, NotificationsUnavailableError, ProviderEmailNotVerifiedError };
|
package/esm/errors/index.mjs
CHANGED
|
@@ -6,4 +6,4 @@ import { InvalidProviderCallbackError } from "./invalid-provider-callback.error.
|
|
|
6
6
|
import { NotificationsUnavailableError } from "./notifications-unavailable.error.mjs";
|
|
7
7
|
import { ProviderEmailNotVerifiedError } from "./provider-email-not-verified.error.mjs";
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { AuthProviderSdkMissingError, EmailNotVerifiedError, InvalidOneTimeTokenError, InvalidPasskeyError, InvalidProviderCallbackError, NotificationsUnavailableError, ProviderEmailNotVerifiedError };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
2
|
import { BadRequestError } from "@warlock.js/core";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/errors/invalid-one-time-token.error.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* An email-verification or password-reset token was rejected: unknown, issued
|
|
@@ -8,10 +7,9 @@ import { BadRequestError } from "@warlock.js/core";
|
|
|
8
7
|
* concurrent consumption race). Deliberately ONE error for all of them, so a
|
|
9
8
|
* caller cannot probe which case applies. Answers `400` with `EC008`.
|
|
10
9
|
*/
|
|
11
|
-
declare class InvalidOneTimeTokenError extends BadRequestError {
|
|
10
|
+
export declare class InvalidOneTimeTokenError extends BadRequestError {
|
|
12
11
|
readonly code = AuthErrorCodes.InvalidOneTimeToken;
|
|
13
12
|
constructor(message?: string);
|
|
14
13
|
}
|
|
15
14
|
//#endregion
|
|
16
|
-
export { InvalidOneTimeTokenError };
|
|
17
15
|
//# sourceMappingURL=invalid-one-time-token.error.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-one-time-token.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/invalid-one-time-token.error.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"invalid-one-time-token.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/invalid-one-time-token.error.ts"],"mappings":";;;;;;;;;qBASa,iCAAiC;WAC5B,OAAI,eAAA;EAEpB,YAAmB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
2
|
import { BadRequestError } from "@warlock.js/core";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/errors/invalid-passkey.error.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* A passkey registration or authentication was rejected — unknown, expired
|
|
@@ -8,11 +7,10 @@ import { BadRequestError } from "@warlock.js/core";
|
|
|
8
7
|
* counter that did not advance. `reason` is for logs; the message stays
|
|
9
8
|
* generic. Answers `400` with `EC011`.
|
|
10
9
|
*/
|
|
11
|
-
declare class InvalidPasskeyError extends BadRequestError {
|
|
10
|
+
export declare class InvalidPasskeyError extends BadRequestError {
|
|
12
11
|
readonly reason: string;
|
|
13
12
|
readonly code = AuthErrorCodes.InvalidPasskey;
|
|
14
13
|
constructor(reason: string, cause?: unknown);
|
|
15
14
|
}
|
|
16
15
|
//#endregion
|
|
17
|
-
export { InvalidPasskeyError };
|
|
18
16
|
//# sourceMappingURL=invalid-passkey.error.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-passkey.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/invalid-passkey.error.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"invalid-passkey.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/invalid-passkey.error.ts"],"mappings":";;;;;;;;;qBASa,4BAA4B;WAIrB;WAHF,OAAI,eAAA;EAEpB,YACkB,gBAChB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
2
|
import { BadRequestError } from "@warlock.js/core";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/errors/invalid-provider-callback.error.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* A redirect-provider callback was rejected — missing, forged or expired
|
|
@@ -8,11 +7,10 @@ import { BadRequestError } from "@warlock.js/core";
|
|
|
8
7
|
* bad signature, issuer, audience, expiry or nonce. `reason` is for logs;
|
|
9
8
|
* the response message stays generic. Answers `400` with `EC009`.
|
|
10
9
|
*/
|
|
11
|
-
declare class InvalidProviderCallbackError extends BadRequestError {
|
|
10
|
+
export declare class InvalidProviderCallbackError extends BadRequestError {
|
|
12
11
|
readonly reason: string;
|
|
13
12
|
readonly code = AuthErrorCodes.InvalidProviderCallback;
|
|
14
13
|
constructor(reason: string, cause?: unknown);
|
|
15
14
|
}
|
|
16
15
|
//#endregion
|
|
17
|
-
export { InvalidProviderCallbackError };
|
|
18
16
|
//# sourceMappingURL=invalid-provider-callback.error.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-provider-callback.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/invalid-provider-callback.error.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"invalid-provider-callback.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/invalid-provider-callback.error.ts"],"mappings":";;;;;;;;;qBASa,qCAAqC;WAI9B;WAHF,OAAI,eAAA;EAEpB,YACkB,gBAChB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ServerError } from "@warlock.js/core";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/auth/src/errors/notifications-unavailable.error.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Email verification / password reset could not send its notification because
|
|
@@ -7,9 +6,8 @@ import { ServerError } from "@warlock.js/core";
|
|
|
7
6
|
* any token is issued — auth never issues a token it cannot deliver, and never
|
|
8
7
|
* skips the send silently. The original failure is kept on `cause`.
|
|
9
8
|
*/
|
|
10
|
-
declare class NotificationsUnavailableError extends ServerError {
|
|
9
|
+
export declare class NotificationsUnavailableError extends ServerError {
|
|
11
10
|
constructor(reason: "not-installed" | "not-configured", cause?: unknown);
|
|
12
11
|
}
|
|
13
12
|
//#endregion
|
|
14
|
-
export { NotificationsUnavailableError };
|
|
15
13
|
//# sourceMappingURL=notifications-unavailable.error.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications-unavailable.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/notifications-unavailable.error.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifications-unavailable.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/notifications-unavailable.error.ts"],"mappings":";;;;;;;;qBAQa,sCAAsC;EACjD,YAAmB,4CAA4C"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
2
|
import { ForbiddenError } from "@warlock.js/core";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/errors/provider-email-not-verified.error.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* The provider did not verify the email on a profile with no existing link,
|
|
7
6
|
* so auth refused to link it to (or create) an account. Answers `403` with
|
|
8
7
|
* `EC010`.
|
|
9
8
|
*/
|
|
10
|
-
declare class ProviderEmailNotVerifiedError extends ForbiddenError {
|
|
9
|
+
export declare class ProviderEmailNotVerifiedError extends ForbiddenError {
|
|
11
10
|
readonly code = AuthErrorCodes.ProviderEmailNotVerified;
|
|
12
11
|
constructor(message?: string);
|
|
13
12
|
}
|
|
14
13
|
//#endregion
|
|
15
|
-
export { ProviderEmailNotVerifiedError };
|
|
16
14
|
//# sourceMappingURL=provider-email-not-verified.error.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-email-not-verified.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/provider-email-not-verified.error.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider-email-not-verified.error.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/errors/provider-email-not-verified.error.ts"],"mappings":";;;;;;;;qBAQa,sCAAsC;WACjC,OAAI,eAAA;EAEpB,YAAmB"}
|
package/esm/index.d.mts
CHANGED
|
@@ -9,6 +9,7 @@ import { AccessTokenConfig, AccessTokenOutput, AuthConfigurations, AuthCredentia
|
|
|
9
9
|
import { RefreshToken, RefreshTokenIssueOptions, refreshTokenSchema } from "./models/refresh-token/refresh-token.model.mjs";
|
|
10
10
|
import { Authenticable } from "./contracts/auth-contract.mjs";
|
|
11
11
|
import { RequestUser } from "./contracts/request-locals.mjs";
|
|
12
|
+
import "./contracts/index.mjs";
|
|
12
13
|
import { AuthProviderSdkMissingError } from "./errors/auth-provider-sdk-missing.error.mjs";
|
|
13
14
|
import { AuthErrorCodes } from "./utils/auth-error-codes.mjs";
|
|
14
15
|
import { EmailNotVerifiedError } from "./errors/email-not-verified.error.mjs";
|
|
@@ -17,6 +18,7 @@ import { InvalidPasskeyError } from "./errors/invalid-passkey.error.mjs";
|
|
|
17
18
|
import { InvalidProviderCallbackError } from "./errors/invalid-provider-callback.error.mjs";
|
|
18
19
|
import { NotificationsUnavailableError } from "./errors/notifications-unavailable.error.mjs";
|
|
19
20
|
import { ProviderEmailNotVerifiedError } from "./errors/provider-email-not-verified.error.mjs";
|
|
21
|
+
import "./errors/index.mjs";
|
|
20
22
|
import { AuthErrorTranslations, AuthTranslations } from "./localization/auth-translations.type.mjs";
|
|
21
23
|
import { authDefaultTranslations } from "./localization/auth-default-translations.mjs";
|
|
22
24
|
import { registerAuthTranslations } from "./localization/register-auth-translations.mjs";
|
|
@@ -26,14 +28,17 @@ import { LoginThrottleIdentifier, LoginThrottleOptions, loginThrottleMiddleware,
|
|
|
26
28
|
import { tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware } from "./middleware/one-time-token-throttle.middleware.mjs";
|
|
27
29
|
import { otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware } from "./middleware/otp-throttle.middleware.mjs";
|
|
28
30
|
import { requireVerifiedEmail } from "./middleware/require-verified-email.middleware.mjs";
|
|
31
|
+
import "./middleware/index.mjs";
|
|
29
32
|
import { AuthTokenFamily, authTokenFamilySchema } from "./models/auth-token-family/auth-token-family.model.mjs";
|
|
30
33
|
import { PasskeyCredential, passkeyCredentialSchema } from "./models/passkey-credential/passkey-credential.model.mjs";
|
|
31
34
|
import { ProviderAccount, providerAccountSchema } from "./models/provider-account/provider-account.model.mjs";
|
|
32
35
|
import { authMigrations } from "./models/index.mjs";
|
|
33
36
|
import { requestOtp, verifyOtp } from "./otp/otp.mjs";
|
|
37
|
+
import "./otp/index.mjs";
|
|
34
38
|
import { PasskeyOptionsJSON, PasskeyResponseJSON } from "./passkeys/simplewebauthn.mjs";
|
|
35
39
|
import { generatePasskeyAuthenticationOptions, verifyPasskeyAuthentication } from "./passkeys/passkey-authentication.mjs";
|
|
36
40
|
import { generatePasskeyRegistrationOptions, verifyPasskeyRegistration } from "./passkeys/passkey-registration.mjs";
|
|
41
|
+
import "./passkeys/index.mjs";
|
|
37
42
|
import { GOOGLE_AUTH_FEATURE, GoogleProvider, JoseModule, pkceChallenge } from "./providers/google-provider.mjs";
|
|
38
43
|
import { APPLE_AUTH_FEATURE, AppleJoseModule, AppleProvider } from "./providers/apple-provider.mjs";
|
|
39
44
|
import { DiscordProvider } from "./providers/discord-provider.mjs";
|
|
@@ -42,6 +47,7 @@ import { GitHubProvider } from "./providers/github-provider.mjs";
|
|
|
42
47
|
import { LINKEDIN_AUTH_FEATURE, LinkedInProvider } from "./providers/linkedin-provider.mjs";
|
|
43
48
|
import { completeProviderLogin, resolveAuthProvider, startProviderLogin } from "./providers/provider-login.mjs";
|
|
44
49
|
import { XProvider } from "./providers/x-provider.mjs";
|
|
50
|
+
import "./providers/index.mjs";
|
|
45
51
|
import { AuthEventCallback, AuthEventName, AuthEventPayloads, authEvents } from "./services/auth-events.mjs";
|
|
46
52
|
import { CookieDomainRequestRequiredError, authService } from "./services/auth.service.mjs";
|
|
47
53
|
import { currentUser } from "./services/current-user.mjs";
|
|
@@ -51,7 +57,9 @@ import { isEmailVerified, sendEmailVerification, verifyEmail } from "./services/
|
|
|
51
57
|
import { IssuedOneTimeToken, consumeOneTimeToken, hashOneTimeToken, issueOneTimeToken, oneTimeTokenModel } from "./services/one-time-tokens.mjs";
|
|
52
58
|
import { requestPasswordReset, resetPassword } from "./services/password-reset.mjs";
|
|
53
59
|
import { RequestUserFailure, RequestUserOutcome, ResolveRequestUserOptions, readCredential, resolveRequestUser, resolveRequestUserOutcome } from "./services/resolve-request-user.mjs";
|
|
60
|
+
import "./services/index.mjs";
|
|
54
61
|
import { PageSessionOptions, PageSessionResolver, SessionMiddlewareOptions, SessionResolverOptions, SessionSource, pageSession, sessionMiddleware } from "./session/page-session.mjs";
|
|
62
|
+
import "./session/index.mjs";
|
|
55
63
|
import { safeEqual } from "./utils/safe-equal.mjs";
|
|
56
64
|
import { isNeverExpiring, isUsableExpiry, tokenHasExpClaim } from "./utils/token-expiry.mjs";
|
|
57
65
|
export { APPLE_AUTH_FEATURE, AUTH_MIDDLEWARE_DESCRIPTOR, AccessToken, AccessTokenConfig, AccessTokenOutput, AppleJoseModule, AppleProvider, AppleProviderConfig, Auth, AuthConfigurations, AuthCredentialDescriptor, AuthCredentials, AuthErrorCodes, AuthErrorTranslations, AuthEventCallback, AuthEventName, AuthEventPayloads, AuthMiddlewareDescriptor, AuthMiddlewareDescriptorSource, AuthMiddlewareOptions, AuthNotification, AuthProvider, AuthProviderSdkMissingError, AuthRefreshCredentialDescriptor, AuthTokenFamily, AuthTranslations, Authenticable, CanAuthenticate, ClearAuthCookieOptions, CookieAuthConfig, CookieDomainRequestRequiredError, CookieDomainResolver, CsrfConfig, CsrfOriginMismatchError, CsrfOriginMismatchReason, DeviceInfo, DiscordProvider, DiscordProviderConfig, EmailNotVerifiedError, EmailVerificationConfig, FacebookProvider, FacebookProviderConfig, GOOGLE_AUTH_FEATURE, GitHubProvider, GitHubProviderConfig, GoogleProvider, GoogleProviderConfig, InvalidOneTimeTokenError, InvalidPasskeyError, InvalidProviderCallbackError, IssuedOneTimeToken, JoseModule, LINKEDIN_AUTH_FEATURE, LegacyJwtConfig, LinkedInProvider, LinkedInProviderConfig, LoginResult, LoginThrottleIdentifier, LoginThrottleOptions, LogoutWithoutTokenBehavior, NO_EXPIRATION, NotificationsUnavailableError, OneTimeToken, OneTimeTokenConfig, OneTimeTokenNotificationData, OneTimeTokenPurpose, OneTimeTokenUrlBuilder, OtpConfig, OtpMessage, OtpSender, PageAuthConfig, PageSessionOptions, PageSessionResolver, PasskeyCredential, type PasskeyOptionsJSON, type PasskeyResponseJSON, PasskeysConfig, PasswordResetConfig, PasswordSetter, ProviderAccount, ProviderAuthorizationState, ProviderCallbackParams, ProviderEmailNotVerifiedError, ProviderProfile, ProviderUserCreator, ProvidersConfig, RefreshToken, RefreshTokenConfig, RefreshTokenIssueOptions, RequestUser, RequestUserFailure, RequestUserOutcome, ResolveRequestUserOptions, SessionMiddlewareOptions, SessionResolverOptions, SessionSource, SetAuthCookieOptions, TokenFrom, TokenPair, TokenType, TokenTypeError, XProvider, XProviderConfig, accessTokenSchema, assertCsrfOriginAllowed, authDefaultTranslations, authEvents, authMiddleware, authMigrations, authService, authTokenFamilySchema, completeProviderLogin, consumeOneTimeToken, currentUser, generateJWTSecret, generatePasskeyAuthenticationOptions, generatePasskeyRegistrationOptions, hashOneTimeToken, isEmailVerified, isInvalidCredentialError, isNeverExpiring, isUsableExpiry, issueOneTimeToken, jwt, loginThrottleMiddleware, oneTimeTokenModel, oneTimeTokenSchema, otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware, pageSession, passkeyCredentialSchema, pkceChallenge, providerAccountSchema, readCredential, refreshTokenSchema, registerAuthCleanupCommand, registerAuthPurgeNeverExpiringCommand, registerAuthTranslations, registerJWTSecretGeneratorCommand, requestOtp, requestPasswordReset, requireVerifiedEmail, requiresCsrfOriginCheck, resetPassword, resolveAuthProvider, resolveRequestUser, resolveRequestUserOutcome, safeEqual, sendEmailVerification, sessionMiddleware, startProviderLogin, throttleIdentifierHash, tokenConsumeThrottleMiddleware, tokenHasExpClaim, tokenIssueThrottleMiddleware, verifyEmail, verifyOtp, verifyPasskeyAuthentication, verifyPasskeyRegistration };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { AuthTranslations } from "./auth-translations.type.mjs";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/auth/src/localization/auth-default-translations.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Every locale auth ships default text for, keyed by locale code.
|
|
6
5
|
*/
|
|
7
|
-
declare const authDefaultTranslations: Record<string, AuthTranslations>;
|
|
6
|
+
export declare const authDefaultTranslations: Record<string, AuthTranslations>;
|
|
8
7
|
//#endregion
|
|
9
|
-
export { authDefaultTranslations };
|
|
10
8
|
//# sourceMappingURL=auth-default-translations.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-default-translations.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/localization/auth-default-translations.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"auth-default-translations.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/localization/auth-default-translations.ts"],"mappings":";;;;;qBAOa,yBAAyB,eAAe"}
|
|
@@ -6,22 +6,26 @@
|
|
|
6
6
|
* one — translating a new `auth.errors.*` key means adding it here, and the
|
|
7
7
|
* compiler then demands a string in each built-in locale.
|
|
8
8
|
*/
|
|
9
|
-
type AuthErrorTranslations = {
|
|
10
|
-
/** 401 — no credential was sent. */
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
export type AuthErrorTranslations = {
|
|
10
|
+
/** 401 — no credential was sent. */
|
|
11
|
+
missingAccessToken: string;
|
|
12
|
+
/** 401 — the credential is malformed, expired, or revoked. */
|
|
13
|
+
invalidAccessToken: string;
|
|
14
|
+
/** 401 — the credential is valid but its user type is not allowed here. */
|
|
15
|
+
unauthorized: string;
|
|
16
|
+
/** 403 — a cookie-authenticated unsafe request came from a foreign origin. */
|
|
17
|
+
csrfOriginMismatch: string;
|
|
18
|
+
/** 429 — login throttle lockout. */
|
|
14
19
|
tooManyAttempts: string;
|
|
15
20
|
};
|
|
16
21
|
/**
|
|
17
22
|
* One locale's worth of auth translations, shaped as the keyword tree
|
|
18
23
|
* `@mongez/localization`'s `extend(localeCode, keywords)` accepts.
|
|
19
24
|
*/
|
|
20
|
-
type AuthTranslations = {
|
|
25
|
+
export type AuthTranslations = {
|
|
21
26
|
auth: {
|
|
22
27
|
errors: AuthErrorTranslations;
|
|
23
28
|
};
|
|
24
29
|
};
|
|
25
30
|
//#endregion
|
|
26
|
-
export { AuthErrorTranslations, AuthTranslations };
|
|
27
31
|
//# sourceMappingURL=auth-translations.type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-translations.type.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/localization/auth-translations.type.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"auth-translations.type.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/localization/auth-translations.type.ts"],"mappings":";;;;;;;;YAOY;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;YAOU;EACV;IACE,QAAQ"}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Runs once at import of `@warlock.js/auth`; safe to call again.
|
|
13
13
|
*/
|
|
14
|
-
declare function registerAuthTranslations(): void;
|
|
14
|
+
export declare function registerAuthTranslations(): void;
|
|
15
15
|
//#endregion
|
|
16
|
-
export { registerAuthTranslations };
|
|
17
16
|
//# sourceMappingURL=register-auth-translations.d.mts.map
|