@warlock.js/auth 5.31.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 +6 -0
- 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/jwt-secret-generator-command.d.mts +1 -2
- package/esm/commands/jwt-secret-generator-command.d.mts.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/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/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 -6
- 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 -4
- 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 -5
- 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 -4
- 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 -4
- 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 +7 -7
- 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/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/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-auth-translations.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/localization/register-auth-translations.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"register-auth-translations.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/localization/register-auth-translations.ts"],"mappings":";;;;;;;;;;;;;wBAgBgB"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { AuthMiddlewareOptions, TokenFrom } from "../contracts/types.mjs";
|
|
2
2
|
import { Middleware } from "@warlock.js/core";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/middleware/auth.middleware.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Well-known symbol under which `authMiddleware()` tags the middleware it
|
|
7
6
|
* returns. Shared via the global symbol registry so other packages can read the
|
|
8
7
|
* descriptor structurally (`Symbol.for("warlock.auth")`) without importing auth.
|
|
9
8
|
*/
|
|
10
|
-
declare const AUTH_MIDDLEWARE_DESCRIPTOR: unique symbol;
|
|
9
|
+
export declare const AUTH_MIDDLEWARE_DESCRIPTOR: unique symbol;
|
|
11
10
|
/** A credential source an auth middleware reads: the Authorization header or a named cookie. */
|
|
12
|
-
type AuthMiddlewareDescriptorSource = "header" | {
|
|
11
|
+
export type AuthMiddlewareDescriptorSource = "header" | {
|
|
13
12
|
cookie: string;
|
|
14
13
|
};
|
|
15
14
|
/**
|
|
16
15
|
* Frozen, JSON-safe description of how an `authMiddleware()` instance
|
|
17
16
|
* authenticates, stored (non-enumerably) under {@link AUTH_MIDDLEWARE_DESCRIPTOR}.
|
|
18
17
|
*/
|
|
19
|
-
type AuthMiddlewareDescriptor = {
|
|
20
|
-
/** Resolved credential sources; with dual sources the header comes first. */
|
|
18
|
+
export type AuthMiddlewareDescriptor = {
|
|
19
|
+
/** Resolved credential sources; with dual sources the header comes first. */
|
|
20
|
+
sources: AuthMiddlewareDescriptorSource[];
|
|
21
|
+
/** Resolved allowed user types; an empty array means any authenticated user. */
|
|
21
22
|
userTypes: string[];
|
|
22
23
|
};
|
|
23
24
|
/**
|
|
@@ -41,10 +42,9 @@ type AuthMiddlewareDescriptor = {
|
|
|
41
42
|
* router.get("/back-office", authMiddleware(["admin", "staff"]), backOfficeController);
|
|
42
43
|
* router.get("/browser-account", authMiddleware([], "cookie:token"), accountController);
|
|
43
44
|
*/
|
|
44
|
-
declare function authMiddleware(): Middleware;
|
|
45
|
-
declare function authMiddleware(options: AuthMiddlewareOptions): Middleware;
|
|
46
|
-
declare function authMiddleware(allowedUserType: string | string[], options?: AuthMiddlewareOptions): Middleware;
|
|
47
|
-
declare function authMiddleware(allowedUserType: string | string[], tokenFrom?: TokenFrom): Middleware;
|
|
45
|
+
export declare function authMiddleware(): Middleware;
|
|
46
|
+
export declare function authMiddleware(options: AuthMiddlewareOptions): Middleware;
|
|
47
|
+
export declare function authMiddleware(allowedUserType: string | string[], options?: AuthMiddlewareOptions): Middleware;
|
|
48
|
+
export declare function authMiddleware(allowedUserType: string | string[], tokenFrom?: TokenFrom): Middleware;
|
|
48
49
|
//#endregion
|
|
49
|
-
export { AUTH_MIDDLEWARE_DESCRIPTOR, AuthMiddlewareDescriptor, AuthMiddlewareDescriptorSource, authMiddleware };
|
|
50
50
|
//# sourceMappingURL=auth.middleware.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.middleware.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/auth.middleware.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.middleware.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/auth.middleware.ts"],"mappings":";;;;;;;;qBAsBa;;YAGD;EAA8C;;;;;;YAM9C;;EAEV,SAAS;;EAET;;;;;;;;;;;;;;;;;;;;;;;wBAoGc,kBAAkB;wBAClB,eAAe,SAAS,wBAAwB;wBAChD,eACd,oCACA,UAAU,wBACT;wBACa,eACd,oCACA,YAAY,YACX"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { TokenFrom } from "../contracts/types.mjs";
|
|
2
2
|
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
3
3
|
import { Request } from "@warlock.js/core";
|
|
4
|
-
|
|
5
4
|
//#region ../../packages/auth/src/middleware/csrf-origin-check.d.ts
|
|
6
5
|
/** Why {@link assertCsrfOriginAllowed} refused a request. */
|
|
7
|
-
type CsrfOriginMismatchReason = "origin-mismatch" | "referer-mismatch" | "missing-origin-and-referer";
|
|
6
|
+
export type CsrfOriginMismatchReason = "origin-mismatch" | "referer-mismatch" | "missing-origin-and-referer";
|
|
8
7
|
/**
|
|
9
8
|
* A cookie-authenticated, unsafe-method request whose `Origin`/`Referer`
|
|
10
9
|
* failed the check. `reason` names exactly why,
|
|
11
10
|
* so an error transformer or an incident log never has to string-match the
|
|
12
11
|
* message.
|
|
13
12
|
*/
|
|
14
|
-
declare class CsrfOriginMismatchError extends Error {
|
|
13
|
+
export declare class CsrfOriginMismatchError extends Error {
|
|
15
14
|
readonly reason: CsrfOriginMismatchReason;
|
|
16
15
|
readonly code = AuthErrorCodes.CsrfOriginMismatch;
|
|
17
16
|
constructor(reason: CsrfOriginMismatchReason);
|
|
@@ -23,7 +22,7 @@ declare class CsrfOriginMismatchError extends Error {
|
|
|
23
22
|
* only a cookie-sourced credential can be silently replayed cross-site by a
|
|
24
23
|
* browser, so only it needs the check.
|
|
25
24
|
*/
|
|
26
|
-
declare function requiresCsrfOriginCheck(tokenFrom: TokenFrom, method: string): boolean;
|
|
25
|
+
export declare function requiresCsrfOriginCheck(tokenFrom: TokenFrom, method: string): boolean;
|
|
27
26
|
/**
|
|
28
27
|
* CSRF Origin check for a cookie-authenticated unsafe-method request (lead
|
|
29
28
|
* decision 3). Allowed when `Origin` — or, when `Origin` is absent, `Referer`
|
|
@@ -43,7 +42,6 @@ declare function requiresCsrfOriginCheck(tokenFrom: TokenFrom, method: string):
|
|
|
43
42
|
* Callers gate this behind {@link requiresCsrfOriginCheck} — this function
|
|
44
43
|
* itself does not re-check the token source or the method.
|
|
45
44
|
*/
|
|
46
|
-
declare function assertCsrfOriginAllowed(request: Request): void;
|
|
45
|
+
export declare function assertCsrfOriginAllowed(request: Request): void;
|
|
47
46
|
//#endregion
|
|
48
|
-
export { CsrfOriginMismatchError, CsrfOriginMismatchReason, assertCsrfOriginAllowed, requiresCsrfOriginCheck };
|
|
49
47
|
//# sourceMappingURL=csrf-origin-check.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csrf-origin-check.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/csrf-origin-check.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"csrf-origin-check.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/csrf-origin-check.ts"],"mappings":";;;;;YAQY;;;;;;;qBAWC,gCAAgC;WAGf,QAAQ;WAF3B,OAAI,eAAA;EAEb,YAA4B,QAAQ;;;;;;;;;wBAatB,wBAAwB,WAAW,WAAW;;;;;;;;;;;;;;;;;;;;wBAuB9C,wBAAwB,SAAS"}
|
|
@@ -3,7 +3,7 @@ import { resolveCsrfOriginVerdict } from "@warlock.js/core";
|
|
|
3
3
|
|
|
4
4
|
//#region ../../packages/auth/src/middleware/csrf-origin-check.ts
|
|
5
5
|
/** HTTP methods the CSRF Origin check exempts — reads, never state changes. */
|
|
6
|
-
const SAFE_METHODS = new Set([
|
|
6
|
+
const SAFE_METHODS = /* @__PURE__ */ new Set([
|
|
7
7
|
"GET",
|
|
8
8
|
"HEAD",
|
|
9
9
|
"OPTIONS"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csrf-origin-check.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/csrf-origin-check.ts"],"sourcesContent":["import { resolveCsrfOriginVerdict, type Request } from \"@warlock.js/core\";\nimport type { TokenFrom } from \"../contracts/types\";\nimport { AuthErrorCodes } from \"../utils/auth-error-codes\";\n\n/** HTTP methods the CSRF Origin check exempts — reads, never state changes. */\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\n/** Why {@link assertCsrfOriginAllowed} refused a request. */\nexport type CsrfOriginMismatchReason =\n | \"origin-mismatch\"\n | \"referer-mismatch\"\n | \"missing-origin-and-referer\";\n\n/**\n * A cookie-authenticated, unsafe-method request whose `Origin`/`Referer`\n * failed the check. `reason` names exactly why,\n * so an error transformer or an incident log never has to string-match the\n * message.\n */\nexport class CsrfOriginMismatchError extends Error {\n readonly code = AuthErrorCodes.CsrfOriginMismatch;\n\n constructor(public readonly reason: CsrfOriginMismatchReason) {\n super(`CSRF Origin check failed: ${reason}`);\n this.name = \"CsrfOriginMismatchError\";\n }\n}\n\n/**\n * Whether a request is in scope for the CSRF Origin check at all — only a\n * `cookie:`-sourced credential on an unsafe method (POST/PUT/PATCH/DELETE) is.\n * Header-token auth and safe methods (GET/HEAD/OPTIONS) are always exempt:\n * only a cookie-sourced credential can be silently replayed cross-site by a\n * browser, so only it needs the check.\n */\nexport function requiresCsrfOriginCheck(tokenFrom: TokenFrom, method: string): boolean {\n return tokenFrom.startsWith(\"cookie:\") && !SAFE_METHODS.has(method.toUpperCase());\n}\n\n/**\n * CSRF Origin check for a cookie-authenticated unsafe-method request (lead\n * decision 3). Allowed when `Origin` — or, when `Origin` is absent, `Referer`\n * — names the request's own origin or an entry in `auth.csrf.allowedOrigins`.\n * Throws {@link CsrfOriginMismatchError} otherwise, including when BOTH\n * headers are absent.\n *\n * Delegates the actual same-origin/allowedOrigins/trustProxy-aware\n * comparison to `@warlock.js/core`'s `resolveCsrfOriginVerdict`\n * (`core/src/http/csrf-origin-policy.ts`) — SECURITY card 8a752ab2 moved that\n * logic down into `core` so this middleware's check and core's own default\n * CSRF-Origin guard (`core/src/http/csrf-default-guard.ts`, which now runs\n * even earlier, ahead of this middleware, for cookie-carrying unsafe-method\n * requests generally) share one implementation instead of two copies that\n * could drift apart.\n *\n * Callers gate this behind {@link requiresCsrfOriginCheck} — this function\n * itself does not re-check the token source or the method.\n */\nexport function assertCsrfOriginAllowed(request: Request): void {\n const verdict = resolveCsrfOriginVerdict(request);\n\n if (!verdict.allowed) {\n throw new CsrfOriginMismatchError(verdict.reason);\n }\n}\n"],"mappings":";;;;;AAKA,MAAM,
|
|
1
|
+
{"version":3,"file":"csrf-origin-check.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/csrf-origin-check.ts"],"sourcesContent":["import { resolveCsrfOriginVerdict, type Request } from \"@warlock.js/core\";\nimport type { TokenFrom } from \"../contracts/types\";\nimport { AuthErrorCodes } from \"../utils/auth-error-codes\";\n\n/** HTTP methods the CSRF Origin check exempts — reads, never state changes. */\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\n/** Why {@link assertCsrfOriginAllowed} refused a request. */\nexport type CsrfOriginMismatchReason =\n | \"origin-mismatch\"\n | \"referer-mismatch\"\n | \"missing-origin-and-referer\";\n\n/**\n * A cookie-authenticated, unsafe-method request whose `Origin`/`Referer`\n * failed the check. `reason` names exactly why,\n * so an error transformer or an incident log never has to string-match the\n * message.\n */\nexport class CsrfOriginMismatchError extends Error {\n readonly code = AuthErrorCodes.CsrfOriginMismatch;\n\n constructor(public readonly reason: CsrfOriginMismatchReason) {\n super(`CSRF Origin check failed: ${reason}`);\n this.name = \"CsrfOriginMismatchError\";\n }\n}\n\n/**\n * Whether a request is in scope for the CSRF Origin check at all — only a\n * `cookie:`-sourced credential on an unsafe method (POST/PUT/PATCH/DELETE) is.\n * Header-token auth and safe methods (GET/HEAD/OPTIONS) are always exempt:\n * only a cookie-sourced credential can be silently replayed cross-site by a\n * browser, so only it needs the check.\n */\nexport function requiresCsrfOriginCheck(tokenFrom: TokenFrom, method: string): boolean {\n return tokenFrom.startsWith(\"cookie:\") && !SAFE_METHODS.has(method.toUpperCase());\n}\n\n/**\n * CSRF Origin check for a cookie-authenticated unsafe-method request (lead\n * decision 3). Allowed when `Origin` — or, when `Origin` is absent, `Referer`\n * — names the request's own origin or an entry in `auth.csrf.allowedOrigins`.\n * Throws {@link CsrfOriginMismatchError} otherwise, including when BOTH\n * headers are absent.\n *\n * Delegates the actual same-origin/allowedOrigins/trustProxy-aware\n * comparison to `@warlock.js/core`'s `resolveCsrfOriginVerdict`\n * (`core/src/http/csrf-origin-policy.ts`) — SECURITY card 8a752ab2 moved that\n * logic down into `core` so this middleware's check and core's own default\n * CSRF-Origin guard (`core/src/http/csrf-default-guard.ts`, which now runs\n * even earlier, ahead of this middleware, for cookie-carrying unsafe-method\n * requests generally) share one implementation instead of two copies that\n * could drift apart.\n *\n * Callers gate this behind {@link requiresCsrfOriginCheck} — this function\n * itself does not re-check the token source or the method.\n */\nexport function assertCsrfOriginAllowed(request: Request): void {\n const verdict = resolveCsrfOriginVerdict(request);\n\n if (!verdict.allowed) {\n throw new CsrfOriginMismatchError(verdict.reason);\n }\n}\n"],"mappings":";;;;;AAKA,MAAM,+BAAe,IAAI,IAAI;CAAC;CAAO;CAAQ;AAAS,CAAC;;;;;;;AAcvD,IAAa,0BAAb,cAA6C,MAAM;CAGjD,YAAY,AAAgB,QAAkC;EAC5D,MAAM,6BAA6B,QAAQ;EADjB;;EAE1B,KAAK,OAAO;CACd;AACF;;;;;;;;AASA,SAAgB,wBAAwB,WAAsB,QAAyB;CACrF,OAAO,UAAU,WAAW,SAAS,KAAK,CAAC,aAAa,IAAI,OAAO,YAAY,CAAC;AAClF;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,wBAAwB,SAAwB;CAC9D,MAAM,UAAU,yBAAyB,OAAO;CAEhD,IAAI,CAAC,QAAQ,SACX,MAAM,IAAI,wBAAwB,QAAQ,MAAM;AAEpD"}
|
|
@@ -3,4 +3,5 @@ import { CsrfOriginMismatchError, CsrfOriginMismatchReason, assertCsrfOriginAllo
|
|
|
3
3
|
import { LoginThrottleIdentifier, LoginThrottleOptions, loginThrottleMiddleware, throttleIdentifierHash } from "./login-throttle.middleware.mjs";
|
|
4
4
|
import { tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware } from "./one-time-token-throttle.middleware.mjs";
|
|
5
5
|
import { otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware } from "./otp-throttle.middleware.mjs";
|
|
6
|
-
import { requireVerifiedEmail } from "./require-verified-email.middleware.mjs";
|
|
6
|
+
import { requireVerifiedEmail } from "./require-verified-email.middleware.mjs";
|
|
7
|
+
export { AUTH_MIDDLEWARE_DESCRIPTOR, AuthMiddlewareDescriptor, AuthMiddlewareDescriptorSource, CsrfOriginMismatchError, CsrfOriginMismatchReason, LoginThrottleIdentifier, LoginThrottleOptions, assertCsrfOriginAllowed, authMiddleware, loginThrottleMiddleware, otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware, requireVerifiedEmail, requiresCsrfOriginCheck, throttleIdentifierHash, tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware };
|
package/esm/middleware/index.mjs
CHANGED
|
@@ -5,4 +5,4 @@ import { tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware } from "./
|
|
|
5
5
|
import { otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware } from "./otp-throttle.middleware.mjs";
|
|
6
6
|
import { requireVerifiedEmail } from "./require-verified-email.middleware.mjs";
|
|
7
7
|
|
|
8
|
-
export {
|
|
8
|
+
export { AUTH_MIDDLEWARE_DESCRIPTOR, CsrfOriginMismatchError, assertCsrfOriginAllowed, authMiddleware, loginThrottleMiddleware, otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware, requireVerifiedEmail, requiresCsrfOriginCheck, throttleIdentifierHash, tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Middleware, Request, Response } from "@warlock.js/core";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/auth/src/middleware/login-throttle.middleware.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Built-in identifier kinds the throttle knows how to extract from a request.
|
|
@@ -11,7 +10,7 @@ import { Middleware, Request, Response } from "@warlock.js/core";
|
|
|
11
10
|
*
|
|
12
11
|
* Lockout trips when ANY tracked identifier crosses `max` — defense-in-depth.
|
|
13
12
|
*/
|
|
14
|
-
type LoginThrottleIdentifier = "email" | "ip";
|
|
13
|
+
export type LoginThrottleIdentifier = "email" | "ip";
|
|
15
14
|
/**
|
|
16
15
|
* Options for {@link loginThrottleMiddleware}.
|
|
17
16
|
*
|
|
@@ -22,7 +21,7 @@ type LoginThrottleIdentifier = "email" | "ip";
|
|
|
22
21
|
* @example
|
|
23
22
|
* loginThrottleMiddleware({ max: 5, window: "15m", lockoutDuration: "15m" });
|
|
24
23
|
*/
|
|
25
|
-
type LoginThrottleOptions = {
|
|
24
|
+
export type LoginThrottleOptions = {
|
|
26
25
|
/**
|
|
27
26
|
* Failures allowed within the window before the identifier is locked.
|
|
28
27
|
*
|
|
@@ -88,7 +87,7 @@ type LoginThrottleOptions = {
|
|
|
88
87
|
*
|
|
89
88
|
* Exported for tests and for apps that inspect throttle keys.
|
|
90
89
|
*/
|
|
91
|
-
declare function throttleIdentifierHash(kind: string, value: string): string;
|
|
90
|
+
export declare function throttleIdentifierHash(kind: string, value: string): string;
|
|
92
91
|
/**
|
|
93
92
|
* Failure-aware login throttle. Locks an identifier (account, IP, or both)
|
|
94
93
|
* after too many failed login attempts within a window — without penalising
|
|
@@ -125,7 +124,6 @@ declare function throttleIdentifierHash(kind: string, value: string): string;
|
|
|
125
124
|
* middleware: [loginThrottleMiddleware({ by: ["ip"], max: 10, window: "1m" })],
|
|
126
125
|
* });
|
|
127
126
|
*/
|
|
128
|
-
declare function loginThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
127
|
+
export declare function loginThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
129
128
|
//#endregion
|
|
130
|
-
export { LoginThrottleIdentifier, LoginThrottleOptions, loginThrottleMiddleware, throttleIdentifierHash };
|
|
131
129
|
//# sourceMappingURL=login-throttle.middleware.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-throttle.middleware.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/login-throttle.middleware.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"login-throttle.middleware.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/login-throttle.middleware.ts"],"mappings":";;;;;;;;;;;;YAkBY;;;;;;;;;;;YAYA;;;;;;EAMV;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA,KAAK;;;;;;;;EASL;;;;EAKA;;;;;;;;EASA,aAAa,UAAU;;;;;;EAOvB,YAAY,SAAS;;;;;;;;;;;;;;;;wBAwCP,uBAAuB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0IrC,wBAAwB,UAAS,uBAA4B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LoginThrottleOptions } from "./login-throttle.middleware.mjs";
|
|
2
2
|
import { Middleware } from "@warlock.js/core";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/middleware/one-time-token-throttle.middleware.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Throttle for routes that ISSUE a verification or reset token ("send
|
|
@@ -16,7 +15,7 @@ import { Middleware } from "@warlock.js/core";
|
|
|
16
15
|
* middleware: [tokenIssueThrottleMiddleware()],
|
|
17
16
|
* });
|
|
18
17
|
*/
|
|
19
|
-
declare function tokenIssueThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
18
|
+
export declare function tokenIssueThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
20
19
|
/**
|
|
21
20
|
* Throttle for routes that CONSUME a token ("verify email", "reset
|
|
22
21
|
* password"). Built on {@link loginThrottleMiddleware}: per IP (the body
|
|
@@ -30,7 +29,6 @@ declare function tokenIssueThrottleMiddleware(options?: LoginThrottleOptions): M
|
|
|
30
29
|
* middleware: [tokenConsumeThrottleMiddleware()],
|
|
31
30
|
* });
|
|
32
31
|
*/
|
|
33
|
-
declare function tokenConsumeThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
32
|
+
export declare function tokenConsumeThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
34
33
|
//#endregion
|
|
35
|
-
export { tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware };
|
|
36
34
|
//# sourceMappingURL=one-time-token-throttle.middleware.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-time-token-throttle.middleware.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/one-time-token-throttle.middleware.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"one-time-token-throttle.middleware.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/one-time-token-throttle.middleware.ts"],"mappings":";;;;;;;;;;;;;;;;;wBAiBgB,6BAA6B,UAAS,uBAA4B;;;;;;;;;;;;;;wBAwBlE,+BAA+B,UAAS,uBAA4B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LoginThrottleOptions } from "./login-throttle.middleware.mjs";
|
|
2
2
|
import { Middleware } from "@warlock.js/core";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/middleware/otp-throttle.middleware.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Throttle for the route that SENDS a login code. {@link tokenIssueThrottleMiddleware}
|
|
@@ -12,7 +11,7 @@ import { Middleware } from "@warlock.js/core";
|
|
|
12
11
|
* middleware: [otpRequestThrottleMiddleware()],
|
|
13
12
|
* });
|
|
14
13
|
*/
|
|
15
|
-
declare function otpRequestThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
14
|
+
export declare function otpRequestThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
16
15
|
/**
|
|
17
16
|
* Throttle for the route that VERIFIES a login code. {@link loginThrottleMiddleware}
|
|
18
17
|
* keyed on `phone` and IP, failure-aware: 5 failures per 15m, then a 15m lockout
|
|
@@ -24,7 +23,6 @@ declare function otpRequestThrottleMiddleware(options?: LoginThrottleOptions): M
|
|
|
24
23
|
* middleware: [otpVerifyThrottleMiddleware()],
|
|
25
24
|
* });
|
|
26
25
|
*/
|
|
27
|
-
declare function otpVerifyThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
26
|
+
export declare function otpVerifyThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
28
27
|
//#endregion
|
|
29
|
-
export { otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware };
|
|
30
28
|
//# sourceMappingURL=otp-throttle.middleware.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp-throttle.middleware.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/otp-throttle.middleware.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"otp-throttle.middleware.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/otp-throttle.middleware.ts"],"mappings":";;;;;;;;;;;;;wBAcgB,6BAA6B,UAAS,uBAA4B;;;;;;;;;;;;wBAelE,4BAA4B,UAAS,uBAA4B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Middleware } from "@warlock.js/core";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/auth/src/middleware/require-verified-email.middleware.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Opt-in route gate that rejects a user who has not verified their email with
|
|
@@ -12,7 +11,6 @@ import { Middleware } from "@warlock.js/core";
|
|
|
12
11
|
* middleware: [authMiddleware("user"), requireVerifiedEmail()],
|
|
13
12
|
* });
|
|
14
13
|
*/
|
|
15
|
-
declare function requireVerifiedEmail(): Middleware;
|
|
14
|
+
export declare function requireVerifiedEmail(): Middleware;
|
|
16
15
|
//#endregion
|
|
17
|
-
export { requireVerifiedEmail };
|
|
18
16
|
//# sourceMappingURL=require-verified-email.middleware.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require-verified-email.middleware.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/require-verified-email.middleware.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"require-verified-email.middleware.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/middleware/require-verified-email.middleware.ts"],"mappings":";;;;;;;;;;;;;wBAegB,wBAAwB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Auth } from "../auth.model.mjs";
|
|
2
2
|
import { Model } from "@warlock.js/cascade";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/models/access-token/access-token.model.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Seal schema for the persisted access-token record. Exported so an override
|
|
@@ -10,10 +9,11 @@ import { Model } from "@warlock.js/cascade";
|
|
|
10
9
|
* `last_access` and the `is_active` soft-revoke flag were removed — neither was
|
|
11
10
|
* ever read; access tokens are revoked by deleting the row.
|
|
12
11
|
*/
|
|
13
|
-
declare const accessTokenSchema: import("@warlock.js/seal").ObjectValidator<{
|
|
12
|
+
export declare const accessTokenSchema: import("@warlock.js/seal").ObjectValidator<{
|
|
14
13
|
token: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
15
14
|
user_id: import("@warlock.js/seal").ScalarValidator & import("@warlock.js/seal").StandardSchemaV1<string | number | boolean, string | number | boolean>;
|
|
16
|
-
user_type: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
15
|
+
user_type: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
16
|
+
/** Null for tokens issued before family tracking was introduced. */
|
|
17
17
|
family_id: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string> & {
|
|
18
18
|
isOptional: true;
|
|
19
19
|
};
|
|
@@ -29,12 +29,13 @@ declare const accessTokenSchema: import("@warlock.js/seal").ObjectValidator<{
|
|
|
29
29
|
* override can rename/add columns by registering under
|
|
30
30
|
* `config.auth.accessToken.model`.
|
|
31
31
|
*/
|
|
32
|
-
declare class AccessToken extends Model {
|
|
32
|
+
export declare class AccessToken extends Model {
|
|
33
33
|
static table: string;
|
|
34
34
|
static schema: import("@warlock.js/seal").ObjectValidator<{
|
|
35
35
|
token: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
36
36
|
user_id: import("@warlock.js/seal").ScalarValidator & import("@warlock.js/seal").StandardSchemaV1<string | number | boolean, string | number | boolean>;
|
|
37
|
-
user_type: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
37
|
+
user_type: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
38
|
+
/** Null for tokens issued before family tracking was introduced. */
|
|
38
39
|
family_id: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string> & {
|
|
39
40
|
isOptional: true;
|
|
40
41
|
};
|
|
@@ -129,5 +130,4 @@ declare class AccessToken extends Model {
|
|
|
129
130
|
static purgeNeverExpiring(): Promise<AccessToken[]>;
|
|
130
131
|
}
|
|
131
132
|
//#endregion
|
|
132
|
-
export { AccessToken, accessTokenSchema };
|
|
133
133
|
//# sourceMappingURL=access-token.model.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-token.model.d.mts","names":[],"sources":["../../../../../../../../../packages/auth/src/models/access-token/access-token.model.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"access-token.model.d.mts","names":[],"sources":["../../../../../../../../../packages/auth/src/models/access-token/access-token.model.ts"],"mappings":";;;;;;;;;;;qBAaa,8CAAiB;;;;;;;;;;;;;;;;;;;;qBAmBjB,oBAAoB;SACjB;SAEA,mCAAM;;;;;;;;;;;;;;;;SAQN;;;;;;;;SASA;;MAGH;;MAKA;;;;;;;;;;;;;;;;MAmBA;;;;;;;MAcA;;;;SAOG,MAAM,MAAM,MAAM,eAAe,WAAW,MAAM,oBAAiB,QAAA;;;;SAanE,YAAY,gBAAgB,QAAQ;;;;SAOpC,cAAc,MAAM,MAAM,gBAAa;;;;SAOvC,iBAAiB,MAAM,OAAI;;;;;;SASrB,6BAA6B,MAAM,MAAM,mBAAmB;;;;;SAS5D,gBAAgB;;;;;;;;;;;;SAqBhB,qBAAqB,QAAQ;;;;;;SAW7B,sBAAsB,QAAQ"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import { AccessToken, accessTokenSchema } from "./access-token.model.mjs";
|
|
1
|
+
import { AccessToken, accessTokenSchema } from "./access-token.model.mjs";
|
|
2
|
+
export { AccessToken, accessTokenSchema };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Auth } from "../auth.model.mjs";
|
|
2
2
|
import { Model } from "@warlock.js/cascade";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/models/auth-token-family/auth-token-family.model.d.ts
|
|
5
4
|
/** Durable revision authority for one refresh-token rotation family. */
|
|
6
|
-
declare const authTokenFamilySchema: import("@warlock.js/seal").ObjectValidator<{
|
|
5
|
+
export declare const authTokenFamilySchema: import("@warlock.js/seal").ObjectValidator<{
|
|
7
6
|
family_id: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
8
7
|
user_id: import("@warlock.js/seal").ScalarValidator & import("@warlock.js/seal").StandardSchemaV1<string | number | boolean, string | number | boolean>;
|
|
9
8
|
user_type: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
@@ -15,7 +14,7 @@ declare const authTokenFamilySchema: import("@warlock.js/seal").ObjectValidator<
|
|
|
15
14
|
};
|
|
16
15
|
}>;
|
|
17
16
|
/** Coordinates family-wide refresh, replay containment, and logout transitions. */
|
|
18
|
-
declare class AuthTokenFamily extends Model {
|
|
17
|
+
export declare class AuthTokenFamily extends Model {
|
|
19
18
|
static table: string;
|
|
20
19
|
static schema: import("@warlock.js/seal").ObjectValidator<{
|
|
21
20
|
family_id: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
@@ -46,5 +45,4 @@ declare class AuthTokenFamily extends Model {
|
|
|
46
45
|
static revoke(familyId: string, expectedRevision: number): Promise<number>;
|
|
47
46
|
}
|
|
48
47
|
//#endregion
|
|
49
|
-
export { AuthTokenFamily, authTokenFamilySchema };
|
|
50
48
|
//# sourceMappingURL=auth-token-family.model.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-token-family.model.d.mts","names":[],"sources":["../../../../../../../../../packages/auth/src/models/auth-token-family/auth-token-family.model.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth-token-family.model.d.mts","names":[],"sources":["../../../../../../../../../packages/auth/src/models/auth-token-family/auth-token-family.model.ts"],"mappings":";;;;qBAKa,kDAAqB;;;;;;;;;;;;qBASrB,wBAAwB;SACrB;SAEA,mCAAM;;;;;;;;;;;;MAGT;;SAKG,MAAM,MAAM,MAAM,mBAAgB,QAAA;SASlC,eAAe,mBAAmB,QAAQ;;SAKpC,OAAO,MAAM,MAAM,mBAAmB,QAAQ;;SAgCpD,UAAU,MAAM,OAAO,QAAQ;;;;;SAU/B,gBAAgB,kBAAkB,2BAA2B;;SAQ7D,OAAO,kBAAkB,2BAA2B"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import { AuthTokenFamily, authTokenFamilySchema } from "./auth-token-family.model.mjs";
|
|
1
|
+
import { AuthTokenFamily, authTokenFamilySchema } from "./auth-token-family.model.mjs";
|
|
2
|
+
export { AuthTokenFamily, authTokenFamilySchema };
|
|
@@ -2,9 +2,8 @@ import { AccessTokenOutput, DeviceInfo, TokenPair } from "../contracts/types.mjs
|
|
|
2
2
|
import { RefreshToken } from "./refresh-token/refresh-token.model.mjs";
|
|
3
3
|
import { Authenticable } from "../contracts/auth-contract.mjs";
|
|
4
4
|
import { ChildModel, Model, ModelSchema } from "@warlock.js/cascade";
|
|
5
|
-
|
|
6
5
|
//#region ../../packages/auth/src/models/auth.model.d.ts
|
|
7
|
-
declare abstract class Auth<Schema extends ModelSchema = ModelSchema> extends Model<Schema> implements Authenticable {
|
|
6
|
+
export declare abstract class Auth<Schema extends ModelSchema = ModelSchema> extends Model<Schema> implements Authenticable {
|
|
8
7
|
/**
|
|
9
8
|
* Get user type
|
|
10
9
|
*/
|
|
@@ -55,5 +54,4 @@ declare abstract class Auth<Schema extends ModelSchema = ModelSchema> extends Mo
|
|
|
55
54
|
confirmPassword(password: string): Promise<boolean>;
|
|
56
55
|
}
|
|
57
56
|
//#endregion
|
|
58
|
-
export { Auth };
|
|
59
57
|
//# sourceMappingURL=auth.model.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.model.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/models/auth.model.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.model.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/models/auth.model.ts"],"mappings":";;;;;8BAMsB,KAAK,eAAe,cAAc,qBAC9C,MAAM,mBACH;;;;eAKS;;;;EAKb,sBAAkB;;;;EAOZ,gBAAgB,aAAa,aAAa,QAAQ;;;;EAOlD,oBAAoB,aAAa,QAAQ;;;;EAOzC,qBAAqB,aAAa,aAAa,QAAQ;;;;EAOvD,kBAAkB,gBAAgB;;;;EAOlC,mBAAmB,gBAAgB;;;;EAOnC,yBAAyB;;;;EAOzB,mBAAmB;;;;EAOnB,kBAAkB,QAAQ;;;;SAOnB,QAAQ,MAAM,WAAW,OAAO,YAAY,QAAQ;;;;EAO3D,gBAAgB,mBAAmB"}
|
package/esm/models/index.d.mts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { Auth } from "./auth.model.mjs";
|
|
2
2
|
import { AccessToken, accessTokenSchema } from "./access-token/access-token.model.mjs";
|
|
3
|
+
import "./access-token/index.mjs";
|
|
3
4
|
import { OneTimeToken, OneTimeTokenPurpose, oneTimeTokenSchema } from "./one-time-token/one-time-token.model.mjs";
|
|
5
|
+
import "./one-time-token/index.mjs";
|
|
6
|
+
import "./refresh-token/index.mjs";
|
|
4
7
|
import { RefreshToken, RefreshTokenIssueOptions, refreshTokenSchema } from "./refresh-token/refresh-token.model.mjs";
|
|
5
8
|
import { AuthTokenFamily, authTokenFamilySchema } from "./auth-token-family/auth-token-family.model.mjs";
|
|
9
|
+
import "./auth-token-family/index.mjs";
|
|
6
10
|
import { PasskeyCredential, passkeyCredentialSchema } from "./passkey-credential/passkey-credential.model.mjs";
|
|
11
|
+
import "./passkey-credential/index.mjs";
|
|
7
12
|
import { ProviderAccount, providerAccountSchema } from "./provider-account/provider-account.model.mjs";
|
|
13
|
+
import "./provider-account/index.mjs";
|
|
8
14
|
//#region ../../packages/auth/src/models/index.d.ts
|
|
9
|
-
declare const authMigrations: import("@warlock.js/cascade").MigrationConstructor[];
|
|
15
|
+
export declare const authMigrations: import("@warlock.js/cascade").MigrationConstructor[];
|
|
10
16
|
//#endregion
|
|
11
|
-
export {
|
|
17
|
+
export { AccessToken, Auth, AuthTokenFamily, OneTimeToken, OneTimeTokenPurpose, PasskeyCredential, ProviderAccount, RefreshToken, RefreshTokenIssueOptions, accessTokenSchema, authTokenFamilySchema, oneTimeTokenSchema, passkeyCredentialSchema, providerAccountSchema, refreshTokenSchema };
|
|
12
18
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/models/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/models/index.ts"],"mappings":";;;;;;;;;;;;;;qBAiBa,8CAAc"}
|
package/esm/models/index.mjs
CHANGED
|
@@ -33,5 +33,5 @@ const authMigrations = [
|
|
|
33
33
|
];
|
|
34
34
|
|
|
35
35
|
//#endregion
|
|
36
|
-
export { authMigrations };
|
|
36
|
+
export { AccessToken, Auth, AuthTokenFamily, OneTimeToken, PasskeyCredential, ProviderAccount, RefreshToken, accessTokenSchema, authMigrations, authTokenFamilySchema, oneTimeTokenSchema, passkeyCredentialSchema, providerAccountSchema, refreshTokenSchema };
|
|
37
37
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import { OneTimeToken, OneTimeTokenPurpose, oneTimeTokenSchema } from "./one-time-token.model.mjs";
|
|
1
|
+
import { OneTimeToken, OneTimeTokenPurpose, oneTimeTokenSchema } from "./one-time-token.model.mjs";
|
|
2
|
+
export { OneTimeToken, OneTimeTokenPurpose, oneTimeTokenSchema };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Auth } from "../auth.model.mjs";
|
|
2
2
|
import { Model } from "@warlock.js/cascade";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/models/one-time-token/one-time-token.model.d.ts
|
|
5
4
|
/** What a one-time token may be used for. A token only ever satisfies its own purpose. */
|
|
6
|
-
type OneTimeTokenPurpose = "email-verification" | "password-reset" | "otp" | "passkey-registration" | "passkey-authentication";
|
|
5
|
+
export type OneTimeTokenPurpose = "email-verification" | "password-reset" | "otp" | "passkey-registration" | "passkey-authentication";
|
|
7
6
|
/**
|
|
8
7
|
* Seal schema for the persisted one-time token. Exported so an override can
|
|
9
8
|
* extend it (e.g. a tenant key).
|
|
10
9
|
*/
|
|
11
|
-
declare const oneTimeTokenSchema: import("@warlock.js/seal").ObjectValidator<{
|
|
10
|
+
export declare const oneTimeTokenSchema: import("@warlock.js/seal").ObjectValidator<{
|
|
12
11
|
token_hash: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
13
12
|
purpose: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
14
13
|
user_id: import("@warlock.js/seal").ScalarValidator & import("@warlock.js/seal").StandardSchemaV1<string | number | boolean, string | number | boolean> & {
|
|
@@ -34,7 +33,7 @@ declare const oneTimeTokenSchema: import("@warlock.js/seal").ObjectValidator<{
|
|
|
34
33
|
* enforced by {@link consumeIfActive}, a conditional update in the same shape
|
|
35
34
|
* as `RefreshToken.revokeIfActive`. Override via `config.auth.oneTimeToken.model`.
|
|
36
35
|
*/
|
|
37
|
-
declare class OneTimeToken extends Model {
|
|
36
|
+
export declare class OneTimeToken extends Model {
|
|
38
37
|
static table: string;
|
|
39
38
|
static schema: import("@warlock.js/seal").ObjectValidator<{
|
|
40
39
|
token_hash: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
@@ -111,5 +110,4 @@ declare class OneTimeToken extends Model {
|
|
|
111
110
|
static invalidateActiveFor(user: Auth, purpose: OneTimeTokenPurpose): Promise<number>;
|
|
112
111
|
}
|
|
113
112
|
//#endregion
|
|
114
|
-
export { OneTimeToken, OneTimeTokenPurpose, oneTimeTokenSchema };
|
|
115
113
|
//# sourceMappingURL=one-time-token.model.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-time-token.model.d.mts","names":[],"sources":["../../../../../../../../../packages/auth/src/models/one-time-token/one-time-token.model.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"one-time-token.model.d.mts","names":[],"sources":["../../../../../../../../../packages/auth/src/models/one-time-token/one-time-token.model.ts"],"mappings":";;;;YAMY;;;;;qBAWC,+CAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoBlB,qBAAqB;SAClB;SAEA,mCAAM;;;;;;;;;;;;;;;;;;;;;;SAON;;;;;;;SAQA;;MAGH;;MAKA;;MAKA;;MAKA;;;;;;EAaE,mBAAmB;;SAYlB,MACZ,MAAM,MACN,SAAS,qBACT,mBACA,WAAW,OAAI,QAAA;;;;;SAiBH,eACZ,SAAS,qBACT,mBACA,WAAW,MACX,OAAO,OAAI,QAAA;;SAcC,cACZ,MAAM,MACN,SAAS,sBACR,QAAQ;;;;;;EAYE,cAAc,cAAc;;;;;;;SAmBrB,cAAc;;SAepB,WACZ,mBACA,SAAS,sBACR,QAAQ;;;;;SAQG,oBAAoB,MAAM,MAAM,SAAS,sBAAsB"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import { PasskeyCredential, passkeyCredentialSchema } from "./passkey-credential.model.mjs";
|
|
1
|
+
import { PasskeyCredential, passkeyCredentialSchema } from "./passkey-credential.model.mjs";
|
|
2
|
+
export { PasskeyCredential, passkeyCredentialSchema };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Auth } from "../auth.model.mjs";
|
|
2
2
|
import { Model } from "@warlock.js/cascade";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/models/passkey-credential/passkey-credential.model.d.ts
|
|
5
4
|
/** Seal schema for a stored passkey. Exported so an override can extend it. */
|
|
6
|
-
declare const passkeyCredentialSchema: import("@warlock.js/seal").ObjectValidator<{
|
|
5
|
+
export declare const passkeyCredentialSchema: import("@warlock.js/seal").ObjectValidator<{
|
|
7
6
|
credential_id: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
8
7
|
public_key: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
9
8
|
counter: import("@warlock.js/seal").IntValidator & import("@warlock.js/seal").StandardSchemaV1<number, number>;
|
|
@@ -20,7 +19,7 @@ declare const passkeyCredentialSchema: import("@warlock.js/seal").ObjectValidato
|
|
|
20
19
|
* base64url; `counter` is the last signature counter seen, which an
|
|
21
20
|
* authentication must advance (a clone detector).
|
|
22
21
|
*/
|
|
23
|
-
declare class PasskeyCredential extends Model {
|
|
22
|
+
export declare class PasskeyCredential extends Model {
|
|
24
23
|
static table: string;
|
|
25
24
|
static schema: import("@warlock.js/seal").ObjectValidator<{
|
|
26
25
|
credential_id: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
@@ -60,5 +59,4 @@ declare class PasskeyCredential extends Model {
|
|
|
60
59
|
advanceCounter(expected: number, newCounter: number): Promise<boolean>;
|
|
61
60
|
}
|
|
62
61
|
//#endregion
|
|
63
|
-
export { PasskeyCredential, passkeyCredentialSchema };
|
|
64
62
|
//# sourceMappingURL=passkey-credential.model.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passkey-credential.model.d.mts","names":[],"sources":["../../../../../../../../../packages/auth/src/models/passkey-credential/passkey-credential.model.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"passkey-credential.model.d.mts","names":[],"sources":["../../../../../../../../../packages/auth/src/models/passkey-credential/passkey-credential.model.ts"],"mappings":";;;;qBAKa,oDAAuB;;;;;;;;;;;;;;;;;qBAcvB,0BAA0B;SACvB;SAEA,mCAAM;;;;;;;;;;;;;;;;;;SAQN;;MAGH;;MAKA;;MAKA;;MAKA;;SAKG,mBAAmB,uBAAuB,QAAQ;;SAKlD,QAAQ,MAAM,OAAO,QAAQ;;;;;EAQ9B,eAAe,kBAAkB,qBAAqB"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import { ProviderAccount, providerAccountSchema } from "./provider-account.model.mjs";
|
|
1
|
+
import { ProviderAccount, providerAccountSchema } from "./provider-account.model.mjs";
|
|
2
|
+
export { ProviderAccount, providerAccountSchema };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Auth } from "../auth.model.mjs";
|
|
2
2
|
import { Model } from "@warlock.js/cascade";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/auth/src/models/provider-account/provider-account.model.d.ts
|
|
5
4
|
/** Seal schema for a provider link. Exported so an override can extend it. */
|
|
6
|
-
declare const providerAccountSchema: import("@warlock.js/seal").ObjectValidator<{
|
|
5
|
+
export declare const providerAccountSchema: import("@warlock.js/seal").ObjectValidator<{
|
|
7
6
|
provider: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
8
7
|
provider_user_id: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
9
8
|
user_id: import("@warlock.js/seal").ScalarValidator & import("@warlock.js/seal").StandardSchemaV1<string | number | boolean, string | number | boolean>;
|
|
@@ -18,7 +17,7 @@ declare const providerAccountSchema: import("@warlock.js/seal").ObjectValidator<
|
|
|
18
17
|
* a user is created for it; afterwards the link alone resolves the user, so a
|
|
19
18
|
* later email change at the provider cannot move the login to another account.
|
|
20
19
|
*/
|
|
21
|
-
declare class ProviderAccount extends Model {
|
|
20
|
+
export declare class ProviderAccount extends Model {
|
|
22
21
|
static table: string;
|
|
23
22
|
static schema: import("@warlock.js/seal").ObjectValidator<{
|
|
24
23
|
provider: import("@warlock.js/seal").StringValidator & import("@warlock.js/seal").StandardSchemaV1<string, string>;
|
|
@@ -39,5 +38,4 @@ declare class ProviderAccount extends Model {
|
|
|
39
38
|
static link(provider: string, providerUserId: string, user: Auth, email?: string): Promise<ProviderAccount>;
|
|
40
39
|
}
|
|
41
40
|
//#endregion
|
|
42
|
-
export { ProviderAccount, providerAccountSchema };
|
|
43
41
|
//# sourceMappingURL=provider-account.model.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-account.model.d.mts","names":[],"sources":["../../../../../../../../../packages/auth/src/models/provider-account/provider-account.model.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider-account.model.d.mts","names":[],"sources":["../../../../../../../../../packages/auth/src/models/provider-account/provider-account.model.ts"],"mappings":";;;;qBAKa,kDAAqB;;;;;;;;;;;;;;;qBAcrB,wBAAwB;SACrB;SAEA,mCAAM;;;;;;;;;;MAGT;;MAKA;;SAKG,SACZ,kBACA,yBACC,QAAQ;;SAKG,KAAK,kBAAkB,wBAAwB,MAAM,MAAM,iBAAc,QAAA"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import { RefreshToken, RefreshTokenIssueOptions, refreshTokenSchema } from "./refresh-token.model.mjs";
|
|
1
|
+
import { RefreshToken, RefreshTokenIssueOptions, refreshTokenSchema } from "./refresh-token.model.mjs";
|
|
2
|
+
export { RefreshToken, RefreshTokenIssueOptions, refreshTokenSchema };
|