@warlock.js/auth 5.12.0 → 5.14.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 +30 -0
- package/README.md +88 -86
- package/esm/commands/auth-cleanup-command.mjs +1 -1
- package/esm/commands/auth-cleanup-command.mjs.map +1 -1
- package/esm/contracts/index.d.mts +2 -1
- package/esm/contracts/providers.d.mts +101 -0
- package/esm/contracts/providers.d.mts.map +1 -0
- package/esm/contracts/types.d.mts +94 -1
- package/esm/contracts/types.d.mts.map +1 -1
- package/esm/contracts/types.mjs.map +1 -1
- package/esm/errors/auth-provider-sdk-missing.error.d.mts +17 -0
- package/esm/errors/auth-provider-sdk-missing.error.d.mts.map +1 -0
- package/esm/errors/auth-provider-sdk-missing.error.mjs +22 -0
- package/esm/errors/auth-provider-sdk-missing.error.mjs.map +1 -0
- package/esm/errors/email-not-verified.error.d.mts +16 -0
- package/esm/errors/email-not-verified.error.d.mts.map +1 -0
- package/esm/errors/email-not-verified.error.mjs +20 -0
- package/esm/errors/email-not-verified.error.mjs.map +1 -0
- package/esm/errors/index.d.mts +7 -0
- package/esm/errors/index.mjs +9 -0
- package/esm/errors/invalid-one-time-token.error.d.mts +17 -0
- package/esm/errors/invalid-one-time-token.error.d.mts.map +1 -0
- package/esm/errors/invalid-one-time-token.error.mjs +21 -0
- package/esm/errors/invalid-one-time-token.error.mjs.map +1 -0
- package/esm/errors/invalid-passkey.error.d.mts +18 -0
- package/esm/errors/invalid-passkey.error.d.mts.map +1 -0
- package/esm/errors/invalid-passkey.error.mjs +23 -0
- package/esm/errors/invalid-passkey.error.mjs.map +1 -0
- package/esm/errors/invalid-provider-callback.error.d.mts +18 -0
- package/esm/errors/invalid-provider-callback.error.d.mts.map +1 -0
- package/esm/errors/invalid-provider-callback.error.mjs +23 -0
- package/esm/errors/invalid-provider-callback.error.mjs.map +1 -0
- package/esm/errors/notifications-unavailable.error.d.mts +15 -0
- package/esm/errors/notifications-unavailable.error.d.mts.map +1 -0
- package/esm/errors/notifications-unavailable.error.mjs +20 -0
- package/esm/errors/notifications-unavailable.error.mjs.map +1 -0
- package/esm/errors/provider-email-not-verified.error.d.mts +16 -0
- package/esm/errors/provider-email-not-verified.error.d.mts.map +1 -0
- package/esm/errors/provider-email-not-verified.error.mjs +20 -0
- package/esm/errors/provider-email-not-verified.error.mjs.map +1 -0
- package/esm/index.d.mts +27 -3
- package/esm/index.mjs +27 -1
- package/esm/middleware/index.d.mts +4 -1
- package/esm/middleware/index.mjs +3 -0
- package/esm/middleware/one-time-token-throttle.middleware.d.mts +36 -0
- package/esm/middleware/one-time-token-throttle.middleware.d.mts.map +1 -0
- package/esm/middleware/one-time-token-throttle.middleware.mjs +53 -0
- package/esm/middleware/one-time-token-throttle.middleware.mjs.map +1 -0
- package/esm/middleware/otp-throttle.middleware.d.mts +30 -0
- package/esm/middleware/otp-throttle.middleware.d.mts.map +1 -0
- package/esm/middleware/otp-throttle.middleware.mjs +45 -0
- package/esm/middleware/otp-throttle.middleware.mjs.map +1 -0
- package/esm/middleware/require-verified-email.middleware.d.mts +18 -0
- package/esm/middleware/require-verified-email.middleware.d.mts.map +1 -0
- package/esm/middleware/require-verified-email.middleware.mjs +24 -0
- package/esm/middleware/require-verified-email.middleware.mjs.map +1 -0
- package/esm/models/access-token/access-token.model.d.mts +8 -0
- package/esm/models/access-token/access-token.model.d.mts.map +1 -1
- package/esm/models/access-token/access-token.model.mjs +3 -0
- package/esm/models/access-token/access-token.model.mjs.map +1 -1
- package/esm/models/index.d.mts +3 -1
- package/esm/models/index.d.mts.map +1 -1
- package/esm/models/index.mjs +16 -1
- package/esm/models/index.mjs.map +1 -1
- package/esm/models/one-time-token/index.d.mts +1 -0
- package/esm/models/one-time-token/index.mjs +3 -0
- package/esm/models/one-time-token/migration.mjs +31 -0
- package/esm/models/one-time-token/migration.mjs.map +1 -0
- package/esm/models/one-time-token/one-time-token.model.d.mts +173 -0
- package/esm/models/one-time-token/one-time-token.model.d.mts.map +1 -0
- package/esm/models/one-time-token/one-time-token.model.mjs +151 -0
- package/esm/models/one-time-token/one-time-token.model.mjs.map +1 -0
- package/esm/models/passkey-credential/index.d.mts +1 -0
- package/esm/models/passkey-credential/index.mjs +3 -0
- package/esm/models/passkey-credential/migration.mjs +25 -0
- package/esm/models/passkey-credential/migration.mjs.map +1 -0
- package/esm/models/passkey-credential/passkey-credential.model.d.mts +108 -0
- package/esm/models/passkey-credential/passkey-credential.model.d.mts.map +1 -0
- package/esm/models/passkey-credential/passkey-credential.model.mjs +70 -0
- package/esm/models/passkey-credential/passkey-credential.model.mjs.map +1 -0
- package/esm/models/provider-account/index.d.mts +1 -0
- package/esm/models/provider-account/index.mjs +3 -0
- package/esm/models/provider-account/migration.mjs +25 -0
- package/esm/models/provider-account/migration.mjs.map +1 -0
- package/esm/models/provider-account/provider-account.model.d.mts +75 -0
- package/esm/models/provider-account/provider-account.model.d.mts.map +1 -0
- package/esm/models/provider-account/provider-account.model.mjs +55 -0
- package/esm/models/provider-account/provider-account.model.mjs.map +1 -0
- package/esm/models/refresh-token/refresh-token.model.d.mts +7 -0
- package/esm/models/refresh-token/refresh-token.model.d.mts.map +1 -1
- package/esm/models/refresh-token/refresh-token.model.mjs +3 -0
- package/esm/models/refresh-token/refresh-token.model.mjs.map +1 -1
- package/esm/otp/index.d.mts +1 -0
- package/esm/otp/index.mjs +3 -0
- package/esm/otp/otp.d.mts +38 -0
- package/esm/otp/otp.d.mts.map +1 -0
- package/esm/otp/otp.mjs +105 -0
- package/esm/otp/otp.mjs.map +1 -0
- package/esm/passkeys/index.d.mts +3 -0
- package/esm/passkeys/index.mjs +4 -0
- package/esm/passkeys/passkey-authentication.d.mts +33 -0
- package/esm/passkeys/passkey-authentication.d.mts.map +1 -0
- package/esm/passkeys/passkey-authentication.mjs +93 -0
- package/esm/passkeys/passkey-authentication.mjs.map +1 -0
- package/esm/passkeys/passkey-challenges.mjs +53 -0
- package/esm/passkeys/passkey-challenges.mjs.map +1 -0
- package/esm/passkeys/passkey-registration.d.mts +29 -0
- package/esm/passkeys/passkey-registration.d.mts.map +1 -0
- package/esm/passkeys/passkey-registration.mjs +88 -0
- package/esm/passkeys/passkey-registration.mjs.map +1 -0
- package/esm/passkeys/simplewebauthn.d.mts +21 -0
- package/esm/passkeys/simplewebauthn.d.mts.map +1 -0
- package/esm/passkeys/simplewebauthn.mjs +13 -0
- package/esm/passkeys/simplewebauthn.mjs.map +1 -0
- package/esm/providers/google-provider.d.mts +40 -0
- package/esm/providers/google-provider.d.mts.map +1 -0
- package/esm/providers/google-provider.mjs +105 -0
- package/esm/providers/google-provider.mjs.map +1 -0
- package/esm/providers/index.d.mts +2 -0
- package/esm/providers/index.mjs +4 -0
- package/esm/providers/provider-login.d.mts +43 -0
- package/esm/providers/provider-login.d.mts.map +1 -0
- package/esm/providers/provider-login.mjs +86 -0
- package/esm/providers/provider-login.mjs.map +1 -0
- package/esm/providers/provider-state-cookie.mjs +63 -0
- package/esm/providers/provider-state-cookie.mjs.map +1 -0
- package/esm/providers/resolve-provider-user.mjs +45 -0
- package/esm/providers/resolve-provider-user.mjs.map +1 -0
- package/esm/services/auth-config.mjs +72 -0
- package/esm/services/auth-config.mjs.map +1 -1
- package/esm/services/auth.service.d.mts +18 -1
- package/esm/services/auth.service.d.mts.map +1 -1
- package/esm/services/auth.service.mjs +28 -1
- package/esm/services/auth.service.mjs.map +1 -1
- package/esm/services/email-verification.d.mts +35 -0
- package/esm/services/email-verification.d.mts.map +1 -0
- package/esm/services/email-verification.mjs +55 -0
- package/esm/services/email-verification.mjs.map +1 -0
- package/esm/services/index.d.mts +4 -1
- package/esm/services/index.mjs +3 -0
- package/esm/services/one-time-tokens.d.mts +32 -0
- package/esm/services/one-time-tokens.d.mts.map +1 -0
- package/esm/services/one-time-tokens.mjs +56 -0
- package/esm/services/one-time-tokens.mjs.map +1 -0
- package/esm/services/optional-peer.mjs +37 -0
- package/esm/services/optional-peer.mjs.map +1 -0
- package/esm/services/password-reset.d.mts +34 -0
- package/esm/services/password-reset.d.mts.map +1 -0
- package/esm/services/password-reset.mjs +81 -0
- package/esm/services/password-reset.mjs.map +1 -0
- package/esm/services/token-notifications.mjs +87 -0
- package/esm/services/token-notifications.mjs.map +1 -0
- package/esm/utils/auth-error-codes.d.mts +39 -1
- package/esm/utils/auth-error-codes.d.mts.map +1 -1
- package/esm/utils/auth-error-codes.mjs +33 -0
- package/esm/utils/auth-error-codes.mjs.map +1 -1
- package/esm/utils/index.mjs +1 -0
- package/esm/utils/safe-equal.d.mts +6 -0
- package/esm/utils/safe-equal.d.mts.map +1 -0
- package/esm/utils/safe-equal.mjs +13 -0
- package/esm/utils/safe-equal.mjs.map +1 -0
- package/llms-full.txt +313 -10
- package/llms.txt +2 -0
- package/package.json +21 -7
- package/skills/login-with-providers/SKILL.md +154 -0
- package/skills/manage-tokens/SKILL.md +7 -1
- package/skills/register-user/SKILL.md +6 -8
- package/skills/run-auth-commands/SKILL.md +1 -1
- package/skills/verify-email-and-reset-password/SKILL.md +137 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
|
+
import { ForbiddenError } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/errors/email-not-verified.error.ts
|
|
5
|
+
/**
|
|
6
|
+
* The authenticated user has not verified their email address. Thrown by
|
|
7
|
+
* `requireVerifiedEmail()`; core's error handler answers it with `403` and a
|
|
8
|
+
* `payload.errorCode` of `EC007`.
|
|
9
|
+
*/
|
|
10
|
+
var EmailNotVerifiedError = class extends ForbiddenError {
|
|
11
|
+
constructor(message = "Email address is not verified.") {
|
|
12
|
+
super(message, { errorCode: "EC007" });
|
|
13
|
+
this.code = "EC007";
|
|
14
|
+
this.name = "EmailNotVerifiedError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { EmailNotVerifiedError };
|
|
20
|
+
//# sourceMappingURL=email-not-verified.error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-not-verified.error.mjs","names":[],"sources":["../../../../../../../auth/src/errors/email-not-verified.error.ts"],"sourcesContent":["import { ForbiddenError } from \"@warlock.js/core\";\nimport { AuthErrorCodes } from \"../utils/auth-error-codes\";\n\n/**\n * The authenticated user has not verified their email address. Thrown by\n * `requireVerifiedEmail()`; core's error handler answers it with `403` and a\n * `payload.errorCode` of `EC007`.\n */\nexport class EmailNotVerifiedError extends ForbiddenError {\n public readonly code = AuthErrorCodes.EmailNotVerified;\n\n public constructor(message = \"Email address is not verified.\") {\n super(message, { errorCode: AuthErrorCodes.EmailNotVerified });\n this.name = \"EmailNotVerifiedError\";\n }\n}\n"],"mappings":";;;;;;;;;AAQA,IAAa,wBAAb,cAA2C,eAAe;CAGxD,AAAO,YAAY,UAAU,kCAAkC;EAC7D,MAAM,SAAS,EAAE,mBAA2C,CAAC;;EAC7D,KAAK,OAAO;CACd;AACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AuthProviderSdkMissingError } from "./auth-provider-sdk-missing.error.mjs";
|
|
2
|
+
import { EmailNotVerifiedError } from "./email-not-verified.error.mjs";
|
|
3
|
+
import { InvalidOneTimeTokenError } from "./invalid-one-time-token.error.mjs";
|
|
4
|
+
import { InvalidPasskeyError } from "./invalid-passkey.error.mjs";
|
|
5
|
+
import { InvalidProviderCallbackError } from "./invalid-provider-callback.error.mjs";
|
|
6
|
+
import { NotificationsUnavailableError } from "./notifications-unavailable.error.mjs";
|
|
7
|
+
import { ProviderEmailNotVerifiedError } from "./provider-email-not-verified.error.mjs";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthProviderSdkMissingError } from "./auth-provider-sdk-missing.error.mjs";
|
|
2
|
+
import { EmailNotVerifiedError } from "./email-not-verified.error.mjs";
|
|
3
|
+
import { InvalidOneTimeTokenError } from "./invalid-one-time-token.error.mjs";
|
|
4
|
+
import { InvalidPasskeyError } from "./invalid-passkey.error.mjs";
|
|
5
|
+
import { InvalidProviderCallbackError } from "./invalid-provider-callback.error.mjs";
|
|
6
|
+
import { NotificationsUnavailableError } from "./notifications-unavailable.error.mjs";
|
|
7
|
+
import { ProviderEmailNotVerifiedError } from "./provider-email-not-verified.error.mjs";
|
|
8
|
+
|
|
9
|
+
export { };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
|
+
import { BadRequestError } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/errors/invalid-one-time-token.error.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* An email-verification or password-reset token was rejected: unknown, issued
|
|
7
|
+
* for the other purpose, expired, or already consumed (including losing a
|
|
8
|
+
* concurrent consumption race). Deliberately ONE error for all of them, so a
|
|
9
|
+
* caller cannot probe which case applies. Answers `400` with `EC008`.
|
|
10
|
+
*/
|
|
11
|
+
declare class InvalidOneTimeTokenError extends BadRequestError {
|
|
12
|
+
readonly code = AuthErrorCodes.InvalidOneTimeToken;
|
|
13
|
+
constructor(message?: string);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { InvalidOneTimeTokenError };
|
|
17
|
+
//# sourceMappingURL=invalid-one-time-token.error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid-one-time-token.error.d.mts","names":[],"sources":["../../../../../../../auth/src/errors/invalid-one-time-token.error.ts"],"mappings":";;;;;;AASA;;;;cAAa,wBAAA,SAAiC,eAAe;EAAA,SAC3C,IAAA,GAAI,cAAA,CAAA,mBAAA;cAED,OAAA;AAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
|
+
import { BadRequestError } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/errors/invalid-one-time-token.error.ts
|
|
5
|
+
/**
|
|
6
|
+
* An email-verification or password-reset token was rejected: unknown, issued
|
|
7
|
+
* for the other purpose, expired, or already consumed (including losing a
|
|
8
|
+
* concurrent consumption race). Deliberately ONE error for all of them, so a
|
|
9
|
+
* caller cannot probe which case applies. Answers `400` with `EC008`.
|
|
10
|
+
*/
|
|
11
|
+
var InvalidOneTimeTokenError = class extends BadRequestError {
|
|
12
|
+
constructor(message = "Invalid or expired token.") {
|
|
13
|
+
super(message, { errorCode: "EC008" });
|
|
14
|
+
this.code = "EC008";
|
|
15
|
+
this.name = "InvalidOneTimeTokenError";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { InvalidOneTimeTokenError };
|
|
21
|
+
//# sourceMappingURL=invalid-one-time-token.error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid-one-time-token.error.mjs","names":[],"sources":["../../../../../../../auth/src/errors/invalid-one-time-token.error.ts"],"sourcesContent":["import { BadRequestError } from \"@warlock.js/core\";\nimport { AuthErrorCodes } from \"../utils/auth-error-codes\";\n\n/**\n * An email-verification or password-reset token was rejected: unknown, issued\n * for the other purpose, expired, or already consumed (including losing a\n * concurrent consumption race). Deliberately ONE error for all of them, so a\n * caller cannot probe which case applies. Answers `400` with `EC008`.\n */\nexport class InvalidOneTimeTokenError extends BadRequestError {\n public readonly code = AuthErrorCodes.InvalidOneTimeToken;\n\n public constructor(message = \"Invalid or expired token.\") {\n super(message, { errorCode: AuthErrorCodes.InvalidOneTimeToken });\n this.name = \"InvalidOneTimeTokenError\";\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,2BAAb,cAA8C,gBAAgB;CAG5D,AAAO,YAAY,UAAU,6BAA6B;EACxD,MAAM,SAAS,EAAE,mBAA8C,CAAC;;EAChE,KAAK,OAAO;CACd;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
|
+
import { BadRequestError } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/errors/invalid-passkey.error.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A passkey registration or authentication was rejected — unknown, expired
|
|
7
|
+
* or used challenge, unknown credential, failed verification, or a signature
|
|
8
|
+
* counter that did not advance. `reason` is for logs; the message stays
|
|
9
|
+
* generic. Answers `400` with `EC011`.
|
|
10
|
+
*/
|
|
11
|
+
declare class InvalidPasskeyError extends BadRequestError {
|
|
12
|
+
readonly reason: string;
|
|
13
|
+
readonly code = AuthErrorCodes.InvalidPasskey;
|
|
14
|
+
constructor(reason: string, cause?: unknown);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { InvalidPasskeyError };
|
|
18
|
+
//# sourceMappingURL=invalid-passkey.error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid-passkey.error.d.mts","names":[],"sources":["../../../../../../../auth/src/errors/invalid-passkey.error.ts"],"mappings":";;;;;;AASA;;;;cAAa,mBAAA,SAA4B,eAAe;EAAA,SAIpC,MAAA;EAAA,SAHF,IAAA,GAAI,cAAA,CAAA,cAAA;cAGF,MAAA,UAChB,KAAA;AAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
|
+
import { BadRequestError } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/errors/invalid-passkey.error.ts
|
|
5
|
+
/**
|
|
6
|
+
* A passkey registration or authentication was rejected — unknown, expired
|
|
7
|
+
* or used challenge, unknown credential, failed verification, or a signature
|
|
8
|
+
* counter that did not advance. `reason` is for logs; the message stays
|
|
9
|
+
* generic. Answers `400` with `EC011`.
|
|
10
|
+
*/
|
|
11
|
+
var InvalidPasskeyError = class extends BadRequestError {
|
|
12
|
+
constructor(reason, cause) {
|
|
13
|
+
super("Passkey verification failed.", { errorCode: "EC011" });
|
|
14
|
+
this.reason = reason;
|
|
15
|
+
this.code = "EC011";
|
|
16
|
+
this.name = "InvalidPasskeyError";
|
|
17
|
+
this.cause = cause;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { InvalidPasskeyError };
|
|
23
|
+
//# sourceMappingURL=invalid-passkey.error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid-passkey.error.mjs","names":[],"sources":["../../../../../../../auth/src/errors/invalid-passkey.error.ts"],"sourcesContent":["import { BadRequestError } from \"@warlock.js/core\";\nimport { AuthErrorCodes } from \"../utils/auth-error-codes\";\n\n/**\n * A passkey registration or authentication was rejected — unknown, expired\n * or used challenge, unknown credential, failed verification, or a signature\n * counter that did not advance. `reason` is for logs; the message stays\n * generic. Answers `400` with `EC011`.\n */\nexport class InvalidPasskeyError extends BadRequestError {\n public readonly code = AuthErrorCodes.InvalidPasskey;\n\n public constructor(\n public readonly reason: string,\n cause?: unknown,\n ) {\n super(\"Passkey verification failed.\", { errorCode: AuthErrorCodes.InvalidPasskey });\n this.name = \"InvalidPasskeyError\";\n this.cause = cause;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,sBAAb,cAAyC,gBAAgB;CAGvD,AAAO,YACL,AAAgB,QAChB,OACA;EACA,MAAM,gCAAgC,EAAE,mBAAyC,CAAC;EAHlE;;EAIhB,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
|
+
import { BadRequestError } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/errors/invalid-provider-callback.error.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A redirect-provider callback was rejected — missing, forged or expired
|
|
7
|
+
* state cookie, `state` mismatch, failed code exchange, or an id_token with a
|
|
8
|
+
* bad signature, issuer, audience, expiry or nonce. `reason` is for logs;
|
|
9
|
+
* the response message stays generic. Answers `400` with `EC009`.
|
|
10
|
+
*/
|
|
11
|
+
declare class InvalidProviderCallbackError extends BadRequestError {
|
|
12
|
+
readonly reason: string;
|
|
13
|
+
readonly code = AuthErrorCodes.InvalidProviderCallback;
|
|
14
|
+
constructor(reason: string, cause?: unknown);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { InvalidProviderCallbackError };
|
|
18
|
+
//# sourceMappingURL=invalid-provider-callback.error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid-provider-callback.error.d.mts","names":[],"sources":["../../../../../../../auth/src/errors/invalid-provider-callback.error.ts"],"mappings":";;;;;;AASA;;;;cAAa,4BAAA,SAAqC,eAAe;EAAA,SAI7C,MAAA;EAAA,SAHF,IAAA,GAAI,cAAA,CAAA,uBAAA;cAGF,MAAA,UAChB,KAAA;AAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
|
+
import { BadRequestError } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/errors/invalid-provider-callback.error.ts
|
|
5
|
+
/**
|
|
6
|
+
* A redirect-provider callback was rejected — missing, forged or expired
|
|
7
|
+
* state cookie, `state` mismatch, failed code exchange, or an id_token with a
|
|
8
|
+
* bad signature, issuer, audience, expiry or nonce. `reason` is for logs;
|
|
9
|
+
* the response message stays generic. Answers `400` with `EC009`.
|
|
10
|
+
*/
|
|
11
|
+
var InvalidProviderCallbackError = class extends BadRequestError {
|
|
12
|
+
constructor(reason, cause) {
|
|
13
|
+
super("Login with the provider failed.", { errorCode: "EC009" });
|
|
14
|
+
this.reason = reason;
|
|
15
|
+
this.code = "EC009";
|
|
16
|
+
this.name = "InvalidProviderCallbackError";
|
|
17
|
+
this.cause = cause;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { InvalidProviderCallbackError };
|
|
23
|
+
//# sourceMappingURL=invalid-provider-callback.error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid-provider-callback.error.mjs","names":[],"sources":["../../../../../../../auth/src/errors/invalid-provider-callback.error.ts"],"sourcesContent":["import { BadRequestError } from \"@warlock.js/core\";\nimport { AuthErrorCodes } from \"../utils/auth-error-codes\";\n\n/**\n * A redirect-provider callback was rejected — missing, forged or expired\n * state cookie, `state` mismatch, failed code exchange, or an id_token with a\n * bad signature, issuer, audience, expiry or nonce. `reason` is for logs;\n * the response message stays generic. Answers `400` with `EC009`.\n */\nexport class InvalidProviderCallbackError extends BadRequestError {\n public readonly code = AuthErrorCodes.InvalidProviderCallback;\n\n public constructor(\n public readonly reason: string,\n cause?: unknown,\n ) {\n super(\"Login with the provider failed.\", {\n errorCode: AuthErrorCodes.InvalidProviderCallback,\n });\n this.name = \"InvalidProviderCallbackError\";\n this.cause = cause;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,+BAAb,cAAkD,gBAAgB;CAGhE,AAAO,YACL,AAAgB,QAChB,OACA;EACA,MAAM,mCAAmC,EACvC,mBACF,CAAC;EALe;;EAMhB,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ServerError } from "@warlock.js/core";
|
|
2
|
+
|
|
3
|
+
//#region ../auth/src/errors/notifications-unavailable.error.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Email verification / password reset could not send its notification because
|
|
6
|
+
* `@warlock.js/notifications` is not installed or not configured. Thrown BEFORE
|
|
7
|
+
* any token is issued — auth never issues a token it cannot deliver, and never
|
|
8
|
+
* skips the send silently. The original failure is kept on `cause`.
|
|
9
|
+
*/
|
|
10
|
+
declare class NotificationsUnavailableError extends ServerError {
|
|
11
|
+
constructor(reason: "not-installed" | "not-configured", cause?: unknown);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { NotificationsUnavailableError };
|
|
15
|
+
//# sourceMappingURL=notifications-unavailable.error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications-unavailable.error.d.mts","names":[],"sources":["../../../../../../../auth/src/errors/notifications-unavailable.error.ts"],"mappings":";;;;;AAQA;;;;cAAa,6BAAA,SAAsC,WAAW;cACzC,MAAA,sCAA4C,KAAA;AAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ServerError } from "@warlock.js/core";
|
|
2
|
+
|
|
3
|
+
//#region ../auth/src/errors/notifications-unavailable.error.ts
|
|
4
|
+
/**
|
|
5
|
+
* Email verification / password reset could not send its notification because
|
|
6
|
+
* `@warlock.js/notifications` is not installed or not configured. Thrown BEFORE
|
|
7
|
+
* any token is issued — auth never issues a token it cannot deliver, and never
|
|
8
|
+
* skips the send silently. The original failure is kept on `cause`.
|
|
9
|
+
*/
|
|
10
|
+
var NotificationsUnavailableError = class extends ServerError {
|
|
11
|
+
constructor(reason, cause) {
|
|
12
|
+
super(reason === "not-installed" ? "@warlock.js/auth: email verification and password reset send through @warlock.js/notifications, which is not installed — add it to the app's dependencies." : "@warlock.js/auth: email verification and password reset send through @warlock.js/notifications, which is not configured — add `src/config/notifications.ts` with a `mail` channel.");
|
|
13
|
+
this.name = "NotificationsUnavailableError";
|
|
14
|
+
this.cause = cause;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { NotificationsUnavailableError };
|
|
20
|
+
//# sourceMappingURL=notifications-unavailable.error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications-unavailable.error.mjs","names":[],"sources":["../../../../../../../auth/src/errors/notifications-unavailable.error.ts"],"sourcesContent":["import { ServerError } from \"@warlock.js/core\";\n\n/**\n * Email verification / password reset could not send its notification because\n * `@warlock.js/notifications` is not installed or not configured. Thrown BEFORE\n * any token is issued — auth never issues a token it cannot deliver, and never\n * skips the send silently. The original failure is kept on `cause`.\n */\nexport class NotificationsUnavailableError extends ServerError {\n public constructor(reason: \"not-installed\" | \"not-configured\", cause?: unknown) {\n super(\n reason === \"not-installed\"\n ? \"@warlock.js/auth: email verification and password reset send through \" +\n \"@warlock.js/notifications, which is not installed — add it to the app's dependencies.\"\n : \"@warlock.js/auth: email verification and password reset send through \" +\n \"@warlock.js/notifications, which is not configured — add `src/config/notifications.ts` \" +\n \"with a `mail` channel.\",\n );\n this.name = \"NotificationsUnavailableError\";\n this.cause = cause;\n }\n}\n"],"mappings":";;;;;;;;;AAQA,IAAa,gCAAb,cAAmD,YAAY;CAC7D,AAAO,YAAY,QAA4C,OAAiB;EAC9E,MACE,WAAW,kBACP,+JAEA,oLAGN;EACA,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
|
+
import { ForbiddenError } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/errors/provider-email-not-verified.error.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The provider did not verify the email on a profile with no existing link,
|
|
7
|
+
* so auth refused to link it to (or create) an account. Answers `403` with
|
|
8
|
+
* `EC010`.
|
|
9
|
+
*/
|
|
10
|
+
declare class ProviderEmailNotVerifiedError extends ForbiddenError {
|
|
11
|
+
readonly code = AuthErrorCodes.ProviderEmailNotVerified;
|
|
12
|
+
constructor(message?: string);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ProviderEmailNotVerifiedError };
|
|
16
|
+
//# sourceMappingURL=provider-email-not-verified.error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-email-not-verified.error.d.mts","names":[],"sources":["../../../../../../../auth/src/errors/provider-email-not-verified.error.ts"],"mappings":";;;;;;AAQA;;;cAAa,6BAAA,SAAsC,cAAc;EAAA,SAC/C,IAAA,GAAI,cAAA,CAAA,wBAAA;cAED,OAAA;AAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
|
|
2
|
+
import { ForbiddenError } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/errors/provider-email-not-verified.error.ts
|
|
5
|
+
/**
|
|
6
|
+
* The provider did not verify the email on a profile with no existing link,
|
|
7
|
+
* so auth refused to link it to (or create) an account. Answers `403` with
|
|
8
|
+
* `EC010`.
|
|
9
|
+
*/
|
|
10
|
+
var ProviderEmailNotVerifiedError = class extends ForbiddenError {
|
|
11
|
+
constructor(message = "The provider has not verified this email address.") {
|
|
12
|
+
super(message, { errorCode: "EC010" });
|
|
13
|
+
this.code = "EC010";
|
|
14
|
+
this.name = "ProviderEmailNotVerifiedError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ProviderEmailNotVerifiedError };
|
|
20
|
+
//# sourceMappingURL=provider-email-not-verified.error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-email-not-verified.error.mjs","names":[],"sources":["../../../../../../../auth/src/errors/provider-email-not-verified.error.ts"],"sourcesContent":["import { ForbiddenError } from \"@warlock.js/core\";\nimport { AuthErrorCodes } from \"../utils/auth-error-codes\";\n\n/**\n * The provider did not verify the email on a profile with no existing link,\n * so auth refused to link it to (or create) an account. Answers `403` with\n * `EC010`.\n */\nexport class ProviderEmailNotVerifiedError extends ForbiddenError {\n public readonly code = AuthErrorCodes.ProviderEmailNotVerified;\n\n public constructor(message = \"The provider has not verified this email address.\") {\n super(message, { errorCode: AuthErrorCodes.ProviderEmailNotVerified });\n this.name = \"ProviderEmailNotVerifiedError\";\n }\n}\n"],"mappings":";;;;;;;;;AAQA,IAAa,gCAAb,cAAmD,eAAe;CAGhE,AAAO,YAAY,UAAU,qDAAqD;EAChF,MAAM,SAAS,EAAE,mBAAmD,CAAC;;EACrE,KAAK,OAAO;CACd;AACF"}
|
package/esm/index.d.mts
CHANGED
|
@@ -3,20 +3,44 @@ import { registerAuthPurgeNeverExpiringCommand } from "./commands/auth-purge-nev
|
|
|
3
3
|
import { registerJWTSecretGeneratorCommand } from "./commands/jwt-secret-generator-command.mjs";
|
|
4
4
|
import { Auth } from "./models/auth.model.mjs";
|
|
5
5
|
import { AccessToken, accessTokenSchema } from "./models/access-token/access-token.model.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { OneTimeToken, OneTimeTokenPurpose, oneTimeTokenSchema } from "./models/one-time-token/one-time-token.model.mjs";
|
|
7
|
+
import { AuthProvider, GoogleProviderConfig, OtpConfig, OtpMessage, OtpSender, PasskeysConfig, ProviderAuthorizationState, ProviderCallbackParams, ProviderProfile, ProviderUserCreator, ProvidersConfig } from "./contracts/providers.mjs";
|
|
8
|
+
import { AccessTokenConfig, AccessTokenOutput, AuthConfigurations, AuthCredentials, AuthNotification, CanAuthenticate, ClearAuthCookieOptions, CookieAuthConfig, CsrfConfig, DeviceInfo, EmailVerificationConfig, LegacyJwtConfig, LoginResult, LogoutWithoutTokenBehavior, NO_EXPIRATION, OneTimeTokenConfig, OneTimeTokenNotificationData, OneTimeTokenUrlBuilder, PageAuthConfig, PasswordResetConfig, PasswordSetter, RefreshTokenConfig, SetAuthCookieOptions, TokenFrom, TokenPair } from "./contracts/types.mjs";
|
|
7
9
|
import { RefreshToken, RefreshTokenIssueOptions, refreshTokenSchema } from "./models/refresh-token/refresh-token.model.mjs";
|
|
8
10
|
import { Authenticable } from "./contracts/auth-contract.mjs";
|
|
9
11
|
import { RequestUser } from "./contracts/request-locals.mjs";
|
|
10
|
-
import {
|
|
12
|
+
import { AuthProviderSdkMissingError } from "./errors/auth-provider-sdk-missing.error.mjs";
|
|
11
13
|
import { AuthErrorCodes } from "./utils/auth-error-codes.mjs";
|
|
14
|
+
import { EmailNotVerifiedError } from "./errors/email-not-verified.error.mjs";
|
|
15
|
+
import { InvalidOneTimeTokenError } from "./errors/invalid-one-time-token.error.mjs";
|
|
16
|
+
import { InvalidPasskeyError } from "./errors/invalid-passkey.error.mjs";
|
|
17
|
+
import { InvalidProviderCallbackError } from "./errors/invalid-provider-callback.error.mjs";
|
|
18
|
+
import { NotificationsUnavailableError } from "./errors/notifications-unavailable.error.mjs";
|
|
19
|
+
import { ProviderEmailNotVerifiedError } from "./errors/provider-email-not-verified.error.mjs";
|
|
20
|
+
import { authMiddleware } from "./middleware/auth.middleware.mjs";
|
|
12
21
|
import { CsrfOriginMismatchError, CsrfOriginMismatchReason, assertCsrfOriginAllowed, requiresCsrfOriginCheck } from "./middleware/csrf-origin-check.mjs";
|
|
13
22
|
import { LoginThrottleIdentifier, LoginThrottleOptions, loginThrottleMiddleware } from "./middleware/login-throttle.middleware.mjs";
|
|
23
|
+
import { tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware } from "./middleware/one-time-token-throttle.middleware.mjs";
|
|
24
|
+
import { otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware } from "./middleware/otp-throttle.middleware.mjs";
|
|
25
|
+
import { requireVerifiedEmail } from "./middleware/require-verified-email.middleware.mjs";
|
|
26
|
+
import { PasskeyCredential, passkeyCredentialSchema } from "./models/passkey-credential/passkey-credential.model.mjs";
|
|
27
|
+
import { ProviderAccount, providerAccountSchema } from "./models/provider-account/provider-account.model.mjs";
|
|
14
28
|
import { authMigrations } from "./models/index.mjs";
|
|
29
|
+
import { requestOtp, verifyOtp } from "./otp/otp.mjs";
|
|
30
|
+
import { PasskeyOptionsJSON, PasskeyResponseJSON } from "./passkeys/simplewebauthn.mjs";
|
|
31
|
+
import { generatePasskeyAuthenticationOptions, verifyPasskeyAuthentication } from "./passkeys/passkey-authentication.mjs";
|
|
32
|
+
import { generatePasskeyRegistrationOptions, verifyPasskeyRegistration } from "./passkeys/passkey-registration.mjs";
|
|
33
|
+
import { GOOGLE_AUTH_FEATURE, GoogleProvider, JoseModule, pkceChallenge } from "./providers/google-provider.mjs";
|
|
34
|
+
import { completeProviderLogin, resolveAuthProvider, startProviderLogin } from "./providers/provider-login.mjs";
|
|
15
35
|
import { AuthEventCallback, AuthEventName, AuthEventPayloads, authEvents } from "./services/auth-events.mjs";
|
|
16
36
|
import { authService } from "./services/auth.service.mjs";
|
|
17
37
|
import { currentUser } from "./services/current-user.mjs";
|
|
18
38
|
import { generateJWTSecret } from "./services/generate-jwt-secret.mjs";
|
|
19
39
|
import { TokenType, TokenTypeError, isInvalidCredentialError, jwt } from "./services/jwt.mjs";
|
|
40
|
+
import { isEmailVerified, sendEmailVerification, verifyEmail } from "./services/email-verification.mjs";
|
|
41
|
+
import { IssuedOneTimeToken, consumeOneTimeToken, hashOneTimeToken, issueOneTimeToken, oneTimeTokenModel } from "./services/one-time-tokens.mjs";
|
|
42
|
+
import { requestPasswordReset, resetPassword } from "./services/password-reset.mjs";
|
|
43
|
+
import { safeEqual } from "./utils/safe-equal.mjs";
|
|
20
44
|
import { isNeverExpiring, isUsableExpiry, tokenHasExpClaim } from "./utils/token-expiry.mjs";
|
|
21
|
-
export { AccessToken, AccessTokenConfig, AccessTokenOutput, Auth, AuthConfigurations, AuthCredentials, AuthErrorCodes, AuthEventCallback, AuthEventName, AuthEventPayloads, Authenticable, CanAuthenticate, ClearAuthCookieOptions, CookieAuthConfig, CsrfConfig, CsrfOriginMismatchError, CsrfOriginMismatchReason, DeviceInfo, LegacyJwtConfig, LoginResult, LoginThrottleIdentifier, LoginThrottleOptions, LogoutWithoutTokenBehavior, NO_EXPIRATION, PageAuthConfig, RefreshToken, RefreshTokenConfig, RefreshTokenIssueOptions, RequestUser, SetAuthCookieOptions, TokenFrom, TokenPair, TokenType, TokenTypeError, accessTokenSchema, assertCsrfOriginAllowed, authEvents, authMiddleware, authMigrations, authService, currentUser, generateJWTSecret, isInvalidCredentialError, isNeverExpiring, isUsableExpiry, jwt, loginThrottleMiddleware, refreshTokenSchema, registerAuthCleanupCommand, registerAuthPurgeNeverExpiringCommand, registerJWTSecretGeneratorCommand, requiresCsrfOriginCheck, tokenHasExpClaim };
|
|
45
|
+
export { AccessToken, AccessTokenConfig, AccessTokenOutput, Auth, AuthConfigurations, AuthCredentials, AuthErrorCodes, AuthEventCallback, AuthEventName, AuthEventPayloads, AuthNotification, AuthProvider, AuthProviderSdkMissingError, Authenticable, CanAuthenticate, ClearAuthCookieOptions, CookieAuthConfig, CsrfConfig, CsrfOriginMismatchError, CsrfOriginMismatchReason, DeviceInfo, EmailNotVerifiedError, EmailVerificationConfig, GOOGLE_AUTH_FEATURE, GoogleProvider, GoogleProviderConfig, InvalidOneTimeTokenError, InvalidPasskeyError, InvalidProviderCallbackError, IssuedOneTimeToken, JoseModule, LegacyJwtConfig, LoginResult, LoginThrottleIdentifier, LoginThrottleOptions, LogoutWithoutTokenBehavior, NO_EXPIRATION, NotificationsUnavailableError, OneTimeToken, OneTimeTokenConfig, OneTimeTokenNotificationData, OneTimeTokenPurpose, OneTimeTokenUrlBuilder, OtpConfig, OtpMessage, OtpSender, PageAuthConfig, PasskeyCredential, type PasskeyOptionsJSON, type PasskeyResponseJSON, PasskeysConfig, PasswordResetConfig, PasswordSetter, ProviderAccount, ProviderAuthorizationState, ProviderCallbackParams, ProviderEmailNotVerifiedError, ProviderProfile, ProviderUserCreator, ProvidersConfig, RefreshToken, RefreshTokenConfig, RefreshTokenIssueOptions, RequestUser, SetAuthCookieOptions, TokenFrom, TokenPair, TokenType, TokenTypeError, accessTokenSchema, assertCsrfOriginAllowed, authEvents, authMiddleware, authMigrations, authService, completeProviderLogin, consumeOneTimeToken, currentUser, generateJWTSecret, generatePasskeyAuthenticationOptions, generatePasskeyRegistrationOptions, hashOneTimeToken, isEmailVerified, isInvalidCredentialError, isNeverExpiring, isUsableExpiry, issueOneTimeToken, jwt, loginThrottleMiddleware, oneTimeTokenModel, oneTimeTokenSchema, otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware, passkeyCredentialSchema, pkceChallenge, providerAccountSchema, refreshTokenSchema, registerAuthCleanupCommand, registerAuthPurgeNeverExpiringCommand, registerJWTSecretGeneratorCommand, requestOtp, requestPasswordReset, requireVerifiedEmail, requiresCsrfOriginCheck, resetPassword, resolveAuthProvider, safeEqual, sendEmailVerification, startProviderLogin, tokenConsumeThrottleMiddleware, tokenHasExpClaim, tokenIssueThrottleMiddleware, verifyEmail, verifyOtp, verifyPasskeyAuthentication, verifyPasskeyRegistration };
|
|
22
46
|
import "./contracts/request-locals.mjs";
|
package/esm/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isNeverExpiring, isUsableExpiry, tokenHasExpClaim } from "./utils/token-expiry.mjs";
|
|
2
2
|
import { AccessToken, accessTokenSchema } from "./models/access-token/access-token.model.mjs";
|
|
3
|
+
import { OneTimeToken, oneTimeTokenSchema } from "./models/one-time-token/one-time-token.model.mjs";
|
|
3
4
|
import { RefreshToken, refreshTokenSchema } from "./models/refresh-token/refresh-token.model.mjs";
|
|
4
5
|
import { authEvents } from "./services/auth-events.mjs";
|
|
5
6
|
import { AuthErrorCodes } from "./utils/auth-error-codes.mjs";
|
|
@@ -10,14 +11,39 @@ import { registerAuthPurgeNeverExpiringCommand } from "./commands/auth-purge-nev
|
|
|
10
11
|
import { generateJWTSecret } from "./services/generate-jwt-secret.mjs";
|
|
11
12
|
import { registerJWTSecretGeneratorCommand } from "./commands/jwt-secret-generator-command.mjs";
|
|
12
13
|
import { NO_EXPIRATION } from "./contracts/types.mjs";
|
|
14
|
+
import { AuthProviderSdkMissingError } from "./errors/auth-provider-sdk-missing.error.mjs";
|
|
15
|
+
import { EmailNotVerifiedError } from "./errors/email-not-verified.error.mjs";
|
|
16
|
+
import { InvalidOneTimeTokenError } from "./errors/invalid-one-time-token.error.mjs";
|
|
17
|
+
import { InvalidPasskeyError } from "./errors/invalid-passkey.error.mjs";
|
|
18
|
+
import { InvalidProviderCallbackError } from "./errors/invalid-provider-callback.error.mjs";
|
|
19
|
+
import { NotificationsUnavailableError } from "./errors/notifications-unavailable.error.mjs";
|
|
20
|
+
import { ProviderEmailNotVerifiedError } from "./errors/provider-email-not-verified.error.mjs";
|
|
21
|
+
import "./errors/index.mjs";
|
|
13
22
|
import { CsrfOriginMismatchError, assertCsrfOriginAllowed, requiresCsrfOriginCheck } from "./middleware/csrf-origin-check.mjs";
|
|
14
23
|
import { authMiddleware } from "./middleware/auth.middleware.mjs";
|
|
15
24
|
import { loginThrottleMiddleware } from "./middleware/login-throttle.middleware.mjs";
|
|
25
|
+
import { tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware } from "./middleware/one-time-token-throttle.middleware.mjs";
|
|
26
|
+
import { otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware } from "./middleware/otp-throttle.middleware.mjs";
|
|
27
|
+
import { requireVerifiedEmail } from "./middleware/require-verified-email.middleware.mjs";
|
|
16
28
|
import "./middleware/index.mjs";
|
|
29
|
+
import { PasskeyCredential, passkeyCredentialSchema } from "./models/passkey-credential/passkey-credential.model.mjs";
|
|
30
|
+
import { ProviderAccount, providerAccountSchema } from "./models/provider-account/provider-account.model.mjs";
|
|
17
31
|
import { currentUser } from "./services/current-user.mjs";
|
|
32
|
+
import { consumeOneTimeToken, hashOneTimeToken, issueOneTimeToken, oneTimeTokenModel } from "./services/one-time-tokens.mjs";
|
|
33
|
+
import { isEmailVerified, sendEmailVerification, verifyEmail } from "./services/email-verification.mjs";
|
|
34
|
+
import { requestPasswordReset, resetPassword } from "./services/password-reset.mjs";
|
|
18
35
|
import "./services/index.mjs";
|
|
19
36
|
import { Auth } from "./models/auth.model.mjs";
|
|
20
37
|
import { authMigrations } from "./models/index.mjs";
|
|
38
|
+
import { safeEqual } from "./utils/safe-equal.mjs";
|
|
39
|
+
import { requestOtp, verifyOtp } from "./otp/otp.mjs";
|
|
40
|
+
import "./otp/index.mjs";
|
|
41
|
+
import { generatePasskeyAuthenticationOptions, verifyPasskeyAuthentication } from "./passkeys/passkey-authentication.mjs";
|
|
42
|
+
import { generatePasskeyRegistrationOptions, verifyPasskeyRegistration } from "./passkeys/passkey-registration.mjs";
|
|
43
|
+
import "./passkeys/index.mjs";
|
|
44
|
+
import { GOOGLE_AUTH_FEATURE, GoogleProvider, pkceChallenge } from "./providers/google-provider.mjs";
|
|
45
|
+
import { completeProviderLogin, resolveAuthProvider, startProviderLogin } from "./providers/provider-login.mjs";
|
|
46
|
+
import "./providers/index.mjs";
|
|
21
47
|
import "./utils/index.mjs";
|
|
22
48
|
|
|
23
|
-
export { AccessToken, Auth, AuthErrorCodes, CsrfOriginMismatchError, NO_EXPIRATION, RefreshToken, TokenTypeError, accessTokenSchema, assertCsrfOriginAllowed, authEvents, authMiddleware, authMigrations, authService, currentUser, generateJWTSecret, isInvalidCredentialError, isNeverExpiring, isUsableExpiry, jwt, loginThrottleMiddleware, refreshTokenSchema, registerAuthCleanupCommand, registerAuthPurgeNeverExpiringCommand, registerJWTSecretGeneratorCommand, requiresCsrfOriginCheck, tokenHasExpClaim };
|
|
49
|
+
export { AccessToken, Auth, AuthErrorCodes, AuthProviderSdkMissingError, CsrfOriginMismatchError, EmailNotVerifiedError, GOOGLE_AUTH_FEATURE, GoogleProvider, InvalidOneTimeTokenError, InvalidPasskeyError, InvalidProviderCallbackError, NO_EXPIRATION, NotificationsUnavailableError, OneTimeToken, PasskeyCredential, ProviderAccount, ProviderEmailNotVerifiedError, RefreshToken, TokenTypeError, accessTokenSchema, assertCsrfOriginAllowed, authEvents, authMiddleware, authMigrations, authService, completeProviderLogin, consumeOneTimeToken, currentUser, generateJWTSecret, generatePasskeyAuthenticationOptions, generatePasskeyRegistrationOptions, hashOneTimeToken, isEmailVerified, isInvalidCredentialError, isNeverExpiring, isUsableExpiry, issueOneTimeToken, jwt, loginThrottleMiddleware, oneTimeTokenModel, oneTimeTokenSchema, otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware, passkeyCredentialSchema, pkceChallenge, providerAccountSchema, refreshTokenSchema, registerAuthCleanupCommand, registerAuthPurgeNeverExpiringCommand, registerJWTSecretGeneratorCommand, requestOtp, requestPasswordReset, requireVerifiedEmail, requiresCsrfOriginCheck, resetPassword, resolveAuthProvider, safeEqual, sendEmailVerification, startProviderLogin, tokenConsumeThrottleMiddleware, tokenHasExpClaim, tokenIssueThrottleMiddleware, verifyEmail, verifyOtp, verifyPasskeyAuthentication, verifyPasskeyRegistration };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { authMiddleware } from "./auth.middleware.mjs";
|
|
2
2
|
import { CsrfOriginMismatchError, CsrfOriginMismatchReason, assertCsrfOriginAllowed, requiresCsrfOriginCheck } from "./csrf-origin-check.mjs";
|
|
3
|
-
import { LoginThrottleIdentifier, LoginThrottleOptions, loginThrottleMiddleware } from "./login-throttle.middleware.mjs";
|
|
3
|
+
import { LoginThrottleIdentifier, LoginThrottleOptions, loginThrottleMiddleware } from "./login-throttle.middleware.mjs";
|
|
4
|
+
import { tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware } from "./one-time-token-throttle.middleware.mjs";
|
|
5
|
+
import { otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware } from "./otp-throttle.middleware.mjs";
|
|
6
|
+
import { requireVerifiedEmail } from "./require-verified-email.middleware.mjs";
|
package/esm/middleware/index.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { CsrfOriginMismatchError, assertCsrfOriginAllowed, requiresCsrfOriginCheck } from "./csrf-origin-check.mjs";
|
|
2
2
|
import { authMiddleware } from "./auth.middleware.mjs";
|
|
3
3
|
import { loginThrottleMiddleware } from "./login-throttle.middleware.mjs";
|
|
4
|
+
import { tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware } from "./one-time-token-throttle.middleware.mjs";
|
|
5
|
+
import { otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware } from "./otp-throttle.middleware.mjs";
|
|
6
|
+
import { requireVerifiedEmail } from "./require-verified-email.middleware.mjs";
|
|
4
7
|
|
|
5
8
|
export { };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LoginThrottleOptions } from "./login-throttle.middleware.mjs";
|
|
2
|
+
import { Middleware } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/middleware/one-time-token-throttle.middleware.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Throttle for routes that ISSUE a verification or reset token ("send
|
|
7
|
+
* verification email", "forgot password"). Built on
|
|
8
|
+
* {@link loginThrottleMiddleware}, tracked per email and per IP, with one
|
|
9
|
+
* difference: EVERY request counts. A reset request answers the same success
|
|
10
|
+
* for known and unknown emails, so a failure-aware counter would never trip.
|
|
11
|
+
*
|
|
12
|
+
* Defaults: 3 requests per 1h window, then a 1h lockout (`429`, `EC004`).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* router.post("/auth/forgot-password", forgotPassword, {
|
|
16
|
+
* middleware: [tokenIssueThrottleMiddleware()],
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
declare function tokenIssueThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
20
|
+
/**
|
|
21
|
+
* Throttle for routes that CONSUME a token ("verify email", "reset
|
|
22
|
+
* password"). Built on {@link loginThrottleMiddleware}: per IP (the body
|
|
23
|
+
* carries a token, not an account), failure-aware — a rejected token counts,
|
|
24
|
+
* a successful use clears the counter.
|
|
25
|
+
*
|
|
26
|
+
* Defaults: 10 failures per 15m window, then a 15m lockout (`429`, `EC004`).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* router.post("/auth/reset-password", resetPasswordController, {
|
|
30
|
+
* middleware: [tokenConsumeThrottleMiddleware()],
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
declare function tokenConsumeThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware };
|
|
36
|
+
//# sourceMappingURL=one-time-token-throttle.middleware.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-time-token-throttle.middleware.d.mts","names":[],"sources":["../../../../../../../auth/src/middleware/one-time-token-throttle.middleware.ts"],"mappings":";;;;;;AAiBA;;;;;;;;AAA4F;AAwB5F;;;iBAxBgB,4BAAA,CAA6B,OAAA,GAAS,oBAAA,GAA4B,UAAU;;;;;AAwBE;;;;;;;;;iBAA9E,8BAAA,CAA+B,OAAA,GAAS,oBAAA,GAA4B,UAAU"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { loginThrottleMiddleware } from "./login-throttle.middleware.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../auth/src/middleware/one-time-token-throttle.middleware.ts
|
|
4
|
+
/**
|
|
5
|
+
* Throttle for routes that ISSUE a verification or reset token ("send
|
|
6
|
+
* verification email", "forgot password"). Built on
|
|
7
|
+
* {@link loginThrottleMiddleware}, tracked per email and per IP, with one
|
|
8
|
+
* difference: EVERY request counts. A reset request answers the same success
|
|
9
|
+
* for known and unknown emails, so a failure-aware counter would never trip.
|
|
10
|
+
*
|
|
11
|
+
* Defaults: 3 requests per 1h window, then a 1h lockout (`429`, `EC004`).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* router.post("/auth/forgot-password", forgotPassword, {
|
|
15
|
+
* middleware: [tokenIssueThrottleMiddleware()],
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
function tokenIssueThrottleMiddleware(options = {}) {
|
|
19
|
+
return loginThrottleMiddleware({
|
|
20
|
+
max: 3,
|
|
21
|
+
window: "1h",
|
|
22
|
+
lockoutDuration: "1h",
|
|
23
|
+
by: ["email", "ip"],
|
|
24
|
+
isFailure: () => true,
|
|
25
|
+
...options
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Throttle for routes that CONSUME a token ("verify email", "reset
|
|
30
|
+
* password"). Built on {@link loginThrottleMiddleware}: per IP (the body
|
|
31
|
+
* carries a token, not an account), failure-aware — a rejected token counts,
|
|
32
|
+
* a successful use clears the counter.
|
|
33
|
+
*
|
|
34
|
+
* Defaults: 10 failures per 15m window, then a 15m lockout (`429`, `EC004`).
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* router.post("/auth/reset-password", resetPasswordController, {
|
|
38
|
+
* middleware: [tokenConsumeThrottleMiddleware()],
|
|
39
|
+
* });
|
|
40
|
+
*/
|
|
41
|
+
function tokenConsumeThrottleMiddleware(options = {}) {
|
|
42
|
+
return loginThrottleMiddleware({
|
|
43
|
+
max: 10,
|
|
44
|
+
window: "15m",
|
|
45
|
+
lockoutDuration: "15m",
|
|
46
|
+
by: ["ip"],
|
|
47
|
+
...options
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { tokenConsumeThrottleMiddleware, tokenIssueThrottleMiddleware };
|
|
53
|
+
//# sourceMappingURL=one-time-token-throttle.middleware.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-time-token-throttle.middleware.mjs","names":[],"sources":["../../../../../../../auth/src/middleware/one-time-token-throttle.middleware.ts"],"sourcesContent":["import type { Middleware } from \"@warlock.js/core\";\nimport { loginThrottleMiddleware, type LoginThrottleOptions } from \"./login-throttle.middleware\";\n\n/**\n * Throttle for routes that ISSUE a verification or reset token (\"send\n * verification email\", \"forgot password\"). Built on\n * {@link loginThrottleMiddleware}, tracked per email and per IP, with one\n * difference: EVERY request counts. A reset request answers the same success\n * for known and unknown emails, so a failure-aware counter would never trip.\n *\n * Defaults: 3 requests per 1h window, then a 1h lockout (`429`, `EC004`).\n *\n * @example\n * router.post(\"/auth/forgot-password\", forgotPassword, {\n * middleware: [tokenIssueThrottleMiddleware()],\n * });\n */\nexport function tokenIssueThrottleMiddleware(options: LoginThrottleOptions = {}): Middleware {\n return loginThrottleMiddleware({\n max: 3,\n window: \"1h\",\n lockoutDuration: \"1h\",\n by: [\"email\", \"ip\"],\n isFailure: () => true,\n ...options,\n });\n}\n\n/**\n * Throttle for routes that CONSUME a token (\"verify email\", \"reset\n * password\"). Built on {@link loginThrottleMiddleware}: per IP (the body\n * carries a token, not an account), failure-aware — a rejected token counts,\n * a successful use clears the counter.\n *\n * Defaults: 10 failures per 15m window, then a 15m lockout (`429`, `EC004`).\n *\n * @example\n * router.post(\"/auth/reset-password\", resetPasswordController, {\n * middleware: [tokenConsumeThrottleMiddleware()],\n * });\n */\nexport function tokenConsumeThrottleMiddleware(options: LoginThrottleOptions = {}): Middleware {\n return loginThrottleMiddleware({\n max: 10,\n window: \"15m\",\n lockoutDuration: \"15m\",\n by: [\"ip\"],\n ...options,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAgB,6BAA6B,UAAgC,CAAC,GAAe;CAC3F,OAAO,wBAAwB;EAC7B,KAAK;EACL,QAAQ;EACR,iBAAiB;EACjB,IAAI,CAAC,SAAS,IAAI;EAClB,iBAAiB;EACjB,GAAG;CACL,CAAC;AACH;;;;;;;;;;;;;;AAeA,SAAgB,+BAA+B,UAAgC,CAAC,GAAe;CAC7F,OAAO,wBAAwB;EAC7B,KAAK;EACL,QAAQ;EACR,iBAAiB;EACjB,IAAI,CAAC,IAAI;EACT,GAAG;CACL,CAAC;AACH"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LoginThrottleOptions } from "./login-throttle.middleware.mjs";
|
|
2
|
+
import { Middleware } from "@warlock.js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/middleware/otp-throttle.middleware.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Throttle for the route that SENDS a login code. {@link tokenIssueThrottleMiddleware}
|
|
7
|
+
* keyed on the `phone` input and IP: every request counts (the answer is the
|
|
8
|
+
* same for unknown phones), 3 per 1h, then a 1h lockout (`429`, `EC004`).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* router.post("/auth/otp/request", requestOtpController, {
|
|
12
|
+
* middleware: [otpRequestThrottleMiddleware()],
|
|
13
|
+
* });
|
|
14
|
+
*/
|
|
15
|
+
declare function otpRequestThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
16
|
+
/**
|
|
17
|
+
* Throttle for the route that VERIFIES a login code. {@link loginThrottleMiddleware}
|
|
18
|
+
* keyed on `phone` and IP, failure-aware: 5 failures per 15m, then a 15m lockout
|
|
19
|
+
* (`429`, `EC004`). Complements the per-code attempt cap, which a fresh code
|
|
20
|
+
* would otherwise reset.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* router.post("/auth/otp/verify", verifyOtpController, {
|
|
24
|
+
* middleware: [otpVerifyThrottleMiddleware()],
|
|
25
|
+
* });
|
|
26
|
+
*/
|
|
27
|
+
declare function otpVerifyThrottleMiddleware(options?: LoginThrottleOptions): Middleware;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware };
|
|
30
|
+
//# sourceMappingURL=otp-throttle.middleware.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-throttle.middleware.d.mts","names":[],"sources":["../../../../../../../auth/src/middleware/otp-throttle.middleware.ts"],"mappings":";;;;;;AAcA;;;;;;;;iBAAgB,4BAAA,CAA6B,OAAA,GAAS,oBAAA,GAA4B,UAAU;AAe5F;;;;;;;;AAA2F;;;AAA3F,iBAAgB,2BAAA,CAA4B,OAAA,GAAS,oBAAA,GAA4B,UAAU"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { loginThrottleMiddleware } from "./login-throttle.middleware.mjs";
|
|
2
|
+
import { tokenIssueThrottleMiddleware } from "./one-time-token-throttle.middleware.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../auth/src/middleware/otp-throttle.middleware.ts
|
|
5
|
+
/**
|
|
6
|
+
* Throttle for the route that SENDS a login code. {@link tokenIssueThrottleMiddleware}
|
|
7
|
+
* keyed on the `phone` input and IP: every request counts (the answer is the
|
|
8
|
+
* same for unknown phones), 3 per 1h, then a 1h lockout (`429`, `EC004`).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* router.post("/auth/otp/request", requestOtpController, {
|
|
12
|
+
* middleware: [otpRequestThrottleMiddleware()],
|
|
13
|
+
* });
|
|
14
|
+
*/
|
|
15
|
+
function otpRequestThrottleMiddleware(options = {}) {
|
|
16
|
+
return tokenIssueThrottleMiddleware({
|
|
17
|
+
identifierKey: "phone",
|
|
18
|
+
...options
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Throttle for the route that VERIFIES a login code. {@link loginThrottleMiddleware}
|
|
23
|
+
* keyed on `phone` and IP, failure-aware: 5 failures per 15m, then a 15m lockout
|
|
24
|
+
* (`429`, `EC004`). Complements the per-code attempt cap, which a fresh code
|
|
25
|
+
* would otherwise reset.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* router.post("/auth/otp/verify", verifyOtpController, {
|
|
29
|
+
* middleware: [otpVerifyThrottleMiddleware()],
|
|
30
|
+
* });
|
|
31
|
+
*/
|
|
32
|
+
function otpVerifyThrottleMiddleware(options = {}) {
|
|
33
|
+
return loginThrottleMiddleware({
|
|
34
|
+
max: 5,
|
|
35
|
+
window: "15m",
|
|
36
|
+
lockoutDuration: "15m",
|
|
37
|
+
by: ["email", "ip"],
|
|
38
|
+
identifierKey: "phone",
|
|
39
|
+
...options
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { otpRequestThrottleMiddleware, otpVerifyThrottleMiddleware };
|
|
45
|
+
//# sourceMappingURL=otp-throttle.middleware.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-throttle.middleware.mjs","names":[],"sources":["../../../../../../../auth/src/middleware/otp-throttle.middleware.ts"],"sourcesContent":["import type { Middleware } from \"@warlock.js/core\";\nimport { loginThrottleMiddleware, type LoginThrottleOptions } from \"./login-throttle.middleware\";\nimport { tokenIssueThrottleMiddleware } from \"./one-time-token-throttle.middleware\";\n\n/**\n * Throttle for the route that SENDS a login code. {@link tokenIssueThrottleMiddleware}\n * keyed on the `phone` input and IP: every request counts (the answer is the\n * same for unknown phones), 3 per 1h, then a 1h lockout (`429`, `EC004`).\n *\n * @example\n * router.post(\"/auth/otp/request\", requestOtpController, {\n * middleware: [otpRequestThrottleMiddleware()],\n * });\n */\nexport function otpRequestThrottleMiddleware(options: LoginThrottleOptions = {}): Middleware {\n return tokenIssueThrottleMiddleware({ identifierKey: \"phone\", ...options });\n}\n\n/**\n * Throttle for the route that VERIFIES a login code. {@link loginThrottleMiddleware}\n * keyed on `phone` and IP, failure-aware: 5 failures per 15m, then a 15m lockout\n * (`429`, `EC004`). Complements the per-code attempt cap, which a fresh code\n * would otherwise reset.\n *\n * @example\n * router.post(\"/auth/otp/verify\", verifyOtpController, {\n * middleware: [otpVerifyThrottleMiddleware()],\n * });\n */\nexport function otpVerifyThrottleMiddleware(options: LoginThrottleOptions = {}): Middleware {\n return loginThrottleMiddleware({\n max: 5,\n window: \"15m\",\n lockoutDuration: \"15m\",\n by: [\"email\", \"ip\"],\n identifierKey: \"phone\",\n ...options,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAgB,6BAA6B,UAAgC,CAAC,GAAe;CAC3F,OAAO,6BAA6B;EAAE,eAAe;EAAS,GAAG;CAAQ,CAAC;AAC5E;;;;;;;;;;;;AAaA,SAAgB,4BAA4B,UAAgC,CAAC,GAAe;CAC1F,OAAO,wBAAwB;EAC7B,KAAK;EACL,QAAQ;EACR,iBAAiB;EACjB,IAAI,CAAC,SAAS,IAAI;EAClB,eAAe;EACf,GAAG;CACL,CAAC;AACH"}
|