@puzzle-ui/auth 0.0.0-stage → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +54 -2
  2. package/dist/LICENSE +21 -0
  3. package/dist/auth.lifecycle.manager.cjs +835 -0
  4. package/dist/auth.lifecycle.manager.cjs.map +1 -0
  5. package/dist/auth.lifecycle.manager.d.cts +115 -0
  6. package/dist/auth.lifecycle.manager.d.ts +115 -0
  7. package/dist/auth.lifecycle.manager.js +835 -0
  8. package/dist/auth.lifecycle.manager.js.map +1 -0
  9. package/dist/auth.manager.cjs +454 -0
  10. package/dist/auth.manager.cjs.map +1 -0
  11. package/dist/auth.manager.d.cts +54 -0
  12. package/dist/auth.manager.d.ts +54 -0
  13. package/dist/auth.manager.js +454 -0
  14. package/dist/auth.manager.js.map +1 -0
  15. package/dist/auth.mfa.manager.cjs +1488 -0
  16. package/dist/auth.mfa.manager.cjs.map +1 -0
  17. package/dist/auth.mfa.manager.d.cts +100 -0
  18. package/dist/auth.mfa.manager.d.ts +100 -0
  19. package/dist/auth.mfa.manager.js +1488 -0
  20. package/dist/auth.mfa.manager.js.map +1 -0
  21. package/dist/auth.rate-limit.cjs +78 -0
  22. package/dist/auth.rate-limit.cjs.map +1 -0
  23. package/dist/auth.rate-limit.d.cts +24 -0
  24. package/dist/auth.rate-limit.d.ts +24 -0
  25. package/dist/auth.rate-limit.js +78 -0
  26. package/dist/auth.rate-limit.js.map +1 -0
  27. package/dist/auth.step-up.manager.cjs +269 -0
  28. package/dist/auth.step-up.manager.cjs.map +1 -0
  29. package/dist/auth.step-up.manager.d.cts +74 -0
  30. package/dist/auth.step-up.manager.d.ts +74 -0
  31. package/dist/auth.step-up.manager.js +268 -0
  32. package/dist/auth.step-up.manager.js.map +1 -0
  33. package/dist/auth.storage.cjs +164 -0
  34. package/dist/auth.storage.cjs.map +1 -0
  35. package/dist/auth.storage.d.cts +29 -0
  36. package/dist/auth.storage.d.ts +29 -0
  37. package/dist/auth.storage.js +148 -0
  38. package/dist/auth.storage.js.map +1 -0
  39. package/dist/errors/auth.errors.cjs +101 -0
  40. package/dist/errors/auth.errors.cjs.map +1 -0
  41. package/dist/errors/auth.errors.d.cts +62 -0
  42. package/dist/errors/auth.errors.d.ts +62 -0
  43. package/dist/errors/auth.errors.js +90 -0
  44. package/dist/errors/auth.errors.js.map +1 -0
  45. package/dist/index.cjs +54 -0
  46. package/dist/index.d.cts +21 -0
  47. package/dist/index.d.ts +21 -0
  48. package/dist/index.js +13 -0
  49. package/dist/providers/mfa-provider.types.d.cts +66 -0
  50. package/dist/providers/mfa-provider.types.d.ts +66 -0
  51. package/dist/providers/provider.types.d.cts +34 -0
  52. package/dist/providers/provider.types.d.ts +34 -0
  53. package/dist/providers/simplewebauthn-provider.cjs +185 -0
  54. package/dist/providers/simplewebauthn-provider.cjs.map +1 -0
  55. package/dist/providers/simplewebauthn-provider.d.cts +35 -0
  56. package/dist/providers/simplewebauthn-provider.d.ts +35 -0
  57. package/dist/providers/simplewebauthn-provider.js +185 -0
  58. package/dist/providers/simplewebauthn-provider.js.map +1 -0
  59. package/dist/providers/webcrypto-secret-protector.cjs +118 -0
  60. package/dist/providers/webcrypto-secret-protector.cjs.map +1 -0
  61. package/dist/providers/webcrypto-secret-protector.d.cts +14 -0
  62. package/dist/providers/webcrypto-secret-protector.d.ts +14 -0
  63. package/dist/providers/webcrypto-secret-protector.js +118 -0
  64. package/dist/providers/webcrypto-secret-protector.js.map +1 -0
  65. package/dist/types/auth-lifecycle.types.d.cts +53 -0
  66. package/dist/types/auth-lifecycle.types.d.ts +53 -0
  67. package/dist/types/auth-manager.types.d.cts +106 -0
  68. package/dist/types/auth-manager.types.d.ts +106 -0
  69. package/dist/types/credential.types.d.cts +9 -0
  70. package/dist/types/credential.types.d.ts +9 -0
  71. package/dist/types/mfa.types.d.cts +244 -0
  72. package/dist/types/mfa.types.d.ts +244 -0
  73. package/dist/types/state.types.d.cts +33 -0
  74. package/dist/types/state.types.d.ts +33 -0
  75. package/dist/types/user.types.d.cts +9 -0
  76. package/dist/types/user.types.d.ts +9 -0
  77. package/dist/utils/auth-crypto.utils.cjs +38 -0
  78. package/dist/utils/auth-crypto.utils.cjs.map +1 -0
  79. package/dist/utils/auth-crypto.utils.d.cts +4 -0
  80. package/dist/utils/auth-crypto.utils.d.ts +4 -0
  81. package/dist/utils/auth-crypto.utils.js +35 -0
  82. package/dist/utils/auth-crypto.utils.js.map +1 -0
  83. package/dist/utils/email.utils.cjs +20 -0
  84. package/dist/utils/email.utils.cjs.map +1 -0
  85. package/dist/utils/email.utils.d.cts +2 -0
  86. package/dist/utils/email.utils.d.ts +2 -0
  87. package/dist/utils/email.utils.js +19 -0
  88. package/dist/utils/email.utils.js.map +1 -0
  89. package/dist/utils/totp.utils.cjs +145 -0
  90. package/dist/utils/totp.utils.cjs.map +1 -0
  91. package/dist/utils/totp.utils.d.cts +26 -0
  92. package/dist/utils/totp.utils.d.ts +26 -0
  93. package/dist/utils/totp.utils.js +140 -0
  94. package/dist/utils/totp.utils.js.map +1 -0
  95. package/package.json +50 -4
@@ -0,0 +1,148 @@
1
+ // src/auth.storage.ts
2
+ const AUTH_USER_COLLECTION = "auth_users";
3
+ const AUTH_CREDENTIAL_COLLECTION = "auth_credentials";
4
+ const AUTH_ACTION_TOKEN_COLLECTION = "auth_action_tokens";
5
+ const AUTH_AUDIT_COLLECTION = "auth_audit_events";
6
+ const AUTH_RATE_LIMIT_COLLECTION = "auth_rate_limits";
7
+ const AUTH_MFA_FACTOR_COLLECTION = "auth_mfa_factors";
8
+ const AUTH_MFA_CHALLENGE_COLLECTION = "auth_mfa_challenges";
9
+ const AUTH_RECOVERY_CODE_COLLECTION = "auth_recovery_codes";
10
+ const authUserCollection = {
11
+ name: AUTH_USER_COLLECTION,
12
+ indexes: [{
13
+ name: "normalized_email_unique",
14
+ fields: ["normalizedEmail"],
15
+ unique: true
16
+ }]
17
+ };
18
+ const authCredentialCollection = {
19
+ name: AUTH_CREDENTIAL_COLLECTION,
20
+ indexes: [{
21
+ name: "user_kind_unique",
22
+ fields: ["userId", "kind"],
23
+ unique: true
24
+ }, {
25
+ name: "user_id",
26
+ fields: ["userId"]
27
+ }]
28
+ };
29
+ const authActionTokenCollection = {
30
+ name: AUTH_ACTION_TOKEN_COLLECTION,
31
+ indexes: [
32
+ {
33
+ name: "token_hash_unique",
34
+ fields: ["tokenHash"],
35
+ unique: true
36
+ },
37
+ {
38
+ name: "user_purpose",
39
+ fields: ["userId", "purpose"]
40
+ },
41
+ {
42
+ name: "token_expiration",
43
+ fields: ["expiresAt"]
44
+ }
45
+ ]
46
+ };
47
+ const authAuditCollection = {
48
+ name: AUTH_AUDIT_COLLECTION,
49
+ indexes: [{
50
+ name: "user_created",
51
+ fields: ["userId", "createdAt"]
52
+ }, {
53
+ name: "action_created",
54
+ fields: ["action", "createdAt"]
55
+ }]
56
+ };
57
+ const authRateLimitCollection = {
58
+ name: AUTH_RATE_LIMIT_COLLECTION,
59
+ indexes: [{
60
+ name: "rate_limit_reset",
61
+ fields: ["resetAt"]
62
+ }]
63
+ };
64
+ const authMfaFactorCollection = {
65
+ name: AUTH_MFA_FACTOR_COLLECTION,
66
+ indexes: [
67
+ {
68
+ name: "factor_key_unique",
69
+ fields: ["factorKey"],
70
+ unique: true
71
+ },
72
+ {
73
+ name: "factor_user_status",
74
+ fields: ["userId", "status"]
75
+ },
76
+ {
77
+ name: "factor_credential_id",
78
+ fields: ["credentialId"]
79
+ }
80
+ ]
81
+ };
82
+ const authMfaChallengeCollection = {
83
+ name: AUTH_MFA_CHALLENGE_COLLECTION,
84
+ indexes: [
85
+ {
86
+ name: "mfa_challenge_token_unique",
87
+ fields: ["tokenHash"],
88
+ unique: true
89
+ },
90
+ {
91
+ name: "mfa_challenge_user",
92
+ fields: ["userId", "purpose"]
93
+ },
94
+ {
95
+ name: "mfa_challenge_expiration",
96
+ fields: ["expiresAt"]
97
+ }
98
+ ]
99
+ };
100
+ const authRecoveryCodeCollection = {
101
+ name: AUTH_RECOVERY_CODE_COLLECTION,
102
+ indexes: [{
103
+ name: "recovery_code_hash_unique",
104
+ fields: ["codeHash"],
105
+ unique: true
106
+ }, {
107
+ name: "recovery_code_user",
108
+ fields: ["userId", "consumedAt"]
109
+ }]
110
+ };
111
+ const initializeAuthStorage = async (storage, options = {}) => {
112
+ if (!storage.capabilities.uniqueConstraints || !storage.capabilities.atomicBatch) throw new Error("Authentication storage requires unique constraints and atomic batches.");
113
+ await storage.registerCollection({
114
+ ...authUserCollection,
115
+ name: options.usersCollection ?? "auth_users"
116
+ });
117
+ await storage.registerCollection({
118
+ ...authCredentialCollection,
119
+ name: options.credentialsCollection ?? "auth_credentials"
120
+ });
121
+ await storage.registerCollection({
122
+ ...authActionTokenCollection,
123
+ name: options.actionTokensCollection ?? "auth_action_tokens"
124
+ });
125
+ await storage.registerCollection({
126
+ ...authAuditCollection,
127
+ name: options.auditCollection ?? "auth_audit_events"
128
+ });
129
+ await storage.registerCollection({
130
+ ...authRateLimitCollection,
131
+ name: options.rateLimitsCollection ?? "auth_rate_limits"
132
+ });
133
+ await storage.registerCollection({
134
+ ...authMfaFactorCollection,
135
+ name: options.factorsCollection ?? "auth_mfa_factors"
136
+ });
137
+ await storage.registerCollection({
138
+ ...authMfaChallengeCollection,
139
+ name: options.challengesCollection ?? "auth_mfa_challenges"
140
+ });
141
+ await storage.registerCollection({
142
+ ...authRecoveryCodeCollection,
143
+ name: options.recoveryCodesCollection ?? "auth_recovery_codes"
144
+ });
145
+ };
146
+ export { AUTH_ACTION_TOKEN_COLLECTION, AUTH_AUDIT_COLLECTION, AUTH_CREDENTIAL_COLLECTION, AUTH_MFA_CHALLENGE_COLLECTION, AUTH_MFA_FACTOR_COLLECTION, AUTH_RATE_LIMIT_COLLECTION, AUTH_RECOVERY_CODE_COLLECTION, AUTH_USER_COLLECTION, authActionTokenCollection, authAuditCollection, authCredentialCollection, authMfaChallengeCollection, authMfaFactorCollection, authRateLimitCollection, authRecoveryCodeCollection, authUserCollection, initializeAuthStorage };
147
+
148
+ //# sourceMappingURL=auth.storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.storage.js","names":[],"sources":["../src/auth.storage.ts"],"sourcesContent":["import type {\n StorageAdapter,\n StorageCollection,\n StorageRecord,\n} from \"@puzzle-ui/storage\";\n\nimport type { AuthUser } from \"./types/user.types\";\nimport type { PasswordCredentialStorageRecord } from \"./types/credential.types\";\n\nimport type {\n AuthActionTokenStorageRecord,\n AuthAuditEventStorageRecord,\n AuthRateLimitStorageRecord,\n} from \"./types/auth-lifecycle.types\";\n\nimport type {\n AuthMfaChallengeStorageRecord,\n AuthMfaFactorStorageRecord,\n AuthRecoveryCodeStorageRecord,\n} from \"./types/mfa.types\";\n\nexport const AUTH_USER_COLLECTION = \"auth_users\";\nexport const AUTH_CREDENTIAL_COLLECTION = \"auth_credentials\";\nexport const AUTH_ACTION_TOKEN_COLLECTION = \"auth_action_tokens\";\nexport const AUTH_AUDIT_COLLECTION = \"auth_audit_events\";\nexport const AUTH_RATE_LIMIT_COLLECTION = \"auth_rate_limits\";\n\nexport const AUTH_MFA_FACTOR_COLLECTION = \"auth_mfa_factors\";\nexport const AUTH_MFA_CHALLENGE_COLLECTION = \"auth_mfa_challenges\";\nexport const AUTH_RECOVERY_CODE_COLLECTION = \"auth_recovery_codes\";\n\nexport type AuthUserStorageRecord = AuthUser &\n StorageRecord & {\n readonly normalizedEmail: string;\n readonly deactivatedAt: Date | null;\n readonly sessionsInvalidatedAt: Date | null;\n };\n\nexport const authUserCollection: StorageCollection<AuthUserStorageRecord> = {\n name: AUTH_USER_COLLECTION,\n indexes: [\n {\n name: \"normalized_email_unique\",\n fields: [\"normalizedEmail\"],\n unique: true,\n },\n ],\n};\n\nexport const authCredentialCollection: StorageCollection<PasswordCredentialStorageRecord> =\n {\n name: AUTH_CREDENTIAL_COLLECTION,\n indexes: [\n {\n name: \"user_kind_unique\",\n fields: [\"userId\", \"kind\"],\n unique: true,\n },\n {\n name: \"user_id\",\n fields: [\"userId\"],\n },\n ],\n };\n\nexport const authActionTokenCollection: StorageCollection<AuthActionTokenStorageRecord> =\n {\n name: AUTH_ACTION_TOKEN_COLLECTION,\n indexes: [\n {\n name: \"token_hash_unique\",\n fields: [\"tokenHash\"],\n unique: true,\n },\n {\n name: \"user_purpose\",\n fields: [\"userId\", \"purpose\"],\n },\n {\n name: \"token_expiration\",\n fields: [\"expiresAt\"],\n },\n ],\n };\n\nexport const authAuditCollection: StorageCollection<AuthAuditEventStorageRecord> =\n {\n name: AUTH_AUDIT_COLLECTION,\n indexes: [\n {\n name: \"user_created\",\n fields: [\"userId\", \"createdAt\"],\n },\n {\n name: \"action_created\",\n fields: [\"action\", \"createdAt\"],\n },\n ],\n };\n\nexport const authRateLimitCollection: StorageCollection<AuthRateLimitStorageRecord> =\n {\n name: AUTH_RATE_LIMIT_COLLECTION,\n indexes: [\n {\n name: \"rate_limit_reset\",\n fields: [\"resetAt\"],\n },\n ],\n };\n\nexport const authMfaFactorCollection: StorageCollection<AuthMfaFactorStorageRecord> =\n {\n name: AUTH_MFA_FACTOR_COLLECTION,\n indexes: [\n {\n name: \"factor_key_unique\",\n fields: [\"factorKey\"],\n unique: true,\n },\n {\n name: \"factor_user_status\",\n fields: [\"userId\", \"status\"],\n },\n {\n name: \"factor_credential_id\",\n fields: [\"credentialId\"],\n },\n ],\n };\n\nexport const authMfaChallengeCollection: StorageCollection<AuthMfaChallengeStorageRecord> =\n {\n name: AUTH_MFA_CHALLENGE_COLLECTION,\n indexes: [\n {\n name: \"mfa_challenge_token_unique\",\n fields: [\"tokenHash\"],\n unique: true,\n },\n {\n name: \"mfa_challenge_user\",\n fields: [\"userId\", \"purpose\"],\n },\n {\n name: \"mfa_challenge_expiration\",\n fields: [\"expiresAt\"],\n },\n ],\n };\n\nexport const authRecoveryCodeCollection: StorageCollection<AuthRecoveryCodeStorageRecord> =\n {\n name: AUTH_RECOVERY_CODE_COLLECTION,\n indexes: [\n {\n name: \"recovery_code_hash_unique\",\n fields: [\"codeHash\"],\n unique: true,\n },\n {\n name: \"recovery_code_user\",\n fields: [\"userId\", \"consumedAt\"],\n },\n ],\n };\n\nexport type InitializeAuthStorageOptions = {\n readonly usersCollection?: string;\n readonly credentialsCollection?: string;\n readonly actionTokensCollection?: string;\n readonly auditCollection?: string;\n readonly rateLimitsCollection?: string;\n\n readonly factorsCollection?: string;\n readonly challengesCollection?: string;\n readonly recoveryCodesCollection?: string;\n};\n\nexport const initializeAuthStorage = async (\n storage: StorageAdapter,\n options: InitializeAuthStorageOptions = {},\n): Promise<void> => {\n if (\n !storage.capabilities.uniqueConstraints ||\n !storage.capabilities.atomicBatch\n ) {\n throw new Error(\n \"Authentication storage requires unique constraints and atomic batches.\",\n );\n }\n\n await storage.registerCollection({\n ...authUserCollection,\n name: options.usersCollection ?? AUTH_USER_COLLECTION,\n });\n\n await storage.registerCollection({\n ...authCredentialCollection,\n name: options.credentialsCollection ?? AUTH_CREDENTIAL_COLLECTION,\n });\n\n await storage.registerCollection({\n ...authActionTokenCollection,\n name: options.actionTokensCollection ?? AUTH_ACTION_TOKEN_COLLECTION,\n });\n\n await storage.registerCollection({\n ...authAuditCollection,\n name: options.auditCollection ?? AUTH_AUDIT_COLLECTION,\n });\n\n await storage.registerCollection({\n ...authRateLimitCollection,\n name: options.rateLimitsCollection ?? AUTH_RATE_LIMIT_COLLECTION,\n });\n\n await storage.registerCollection({\n ...authMfaFactorCollection,\n name: options.factorsCollection ?? AUTH_MFA_FACTOR_COLLECTION,\n });\n\n await storage.registerCollection({\n ...authMfaChallengeCollection,\n name: options.challengesCollection ?? AUTH_MFA_CHALLENGE_COLLECTION,\n });\n\n await storage.registerCollection({\n ...authRecoveryCodeCollection,\n name: options.recoveryCodesCollection ?? AUTH_RECOVERY_CODE_COLLECTION,\n });\n};\n"],"mappings":";AAqBA,MAAa,uBAAuB;AACpC,MAAa,6BAA6B;AAC1C,MAAa,+BAA+B;AAC5C,MAAa,wBAAwB;AACrC,MAAa,6BAA6B;AAE1C,MAAa,6BAA6B;AAC1C,MAAa,gCAAgC;AAC7C,MAAa,gCAAgC;AAS7C,MAAa,qBAA+D;CAC1E,MAAM;CACN,SAAS,CACP;EACE,MAAM;EACN,QAAQ,CAAC,iBAAiB;EAC1B,QAAQ;CACV,CACF;AACF;AAEA,MAAa,2BACX;CACE,MAAM;CACN,SAAS,CACP;EACE,MAAM;EACN,QAAQ,CAAC,UAAU,MAAM;EACzB,QAAQ;CACV,GACA;EACE,MAAM;EACN,QAAQ,CAAC,QAAQ;CACnB,CACF;AACF;AAEF,MAAa,4BACX;CACE,MAAM;CACN,SAAS;EACP;GACE,MAAM;GACN,QAAQ,CAAC,WAAW;GACpB,QAAQ;EACV;EACA;GACE,MAAM;GACN,QAAQ,CAAC,UAAU,SAAS;EAC9B;EACA;GACE,MAAM;GACN,QAAQ,CAAC,WAAW;EACtB;CACF;AACF;AAEF,MAAa,sBACX;CACE,MAAM;CACN,SAAS,CACP;EACE,MAAM;EACN,QAAQ,CAAC,UAAU,WAAW;CAChC,GACA;EACE,MAAM;EACN,QAAQ,CAAC,UAAU,WAAW;CAChC,CACF;AACF;AAEF,MAAa,0BACX;CACE,MAAM;CACN,SAAS,CACP;EACE,MAAM;EACN,QAAQ,CAAC,SAAS;CACpB,CACF;AACF;AAEF,MAAa,0BACX;CACE,MAAM;CACN,SAAS;EACP;GACE,MAAM;GACN,QAAQ,CAAC,WAAW;GACpB,QAAQ;EACV;EACA;GACE,MAAM;GACN,QAAQ,CAAC,UAAU,QAAQ;EAC7B;EACA;GACE,MAAM;GACN,QAAQ,CAAC,cAAc;EACzB;CACF;AACF;AAEF,MAAa,6BACX;CACE,MAAM;CACN,SAAS;EACP;GACE,MAAM;GACN,QAAQ,CAAC,WAAW;GACpB,QAAQ;EACV;EACA;GACE,MAAM;GACN,QAAQ,CAAC,UAAU,SAAS;EAC9B;EACA;GACE,MAAM;GACN,QAAQ,CAAC,WAAW;EACtB;CACF;AACF;AAEF,MAAa,6BACX;CACE,MAAM;CACN,SAAS,CACP;EACE,MAAM;EACN,QAAQ,CAAC,UAAU;EACnB,QAAQ;CACV,GACA;EACE,MAAM;EACN,QAAQ,CAAC,UAAU,YAAY;CACjC,CACF;AACF;AAcF,MAAa,wBAAwB,OACnC,SACA,UAAwC,CAAC,MACvB;CAClB,IACE,CAAC,QAAQ,aAAa,qBACtB,CAAC,QAAQ,aAAa,aAEtB,MAAM,IAAI,MACR,wEACF;CAGF,MAAM,QAAQ,mBAAmB;EAC/B,GAAG;EACH,MAAM,QAAQ,mBAAA;CAChB,CAAC;CAED,MAAM,QAAQ,mBAAmB;EAC/B,GAAG;EACH,MAAM,QAAQ,yBAAA;CAChB,CAAC;CAED,MAAM,QAAQ,mBAAmB;EAC/B,GAAG;EACH,MAAM,QAAQ,0BAAA;CAChB,CAAC;CAED,MAAM,QAAQ,mBAAmB;EAC/B,GAAG;EACH,MAAM,QAAQ,mBAAA;CAChB,CAAC;CAED,MAAM,QAAQ,mBAAmB;EAC/B,GAAG;EACH,MAAM,QAAQ,wBAAA;CAChB,CAAC;CAED,MAAM,QAAQ,mBAAmB;EAC/B,GAAG;EACH,MAAM,QAAQ,qBAAA;CAChB,CAAC;CAED,MAAM,QAAQ,mBAAmB;EAC/B,GAAG;EACH,MAAM,QAAQ,wBAAA;CAChB,CAAC;CAED,MAAM,QAAQ,mBAAmB;EAC/B,GAAG;EACH,MAAM,QAAQ,2BAAA;CAChB,CAAC;AACH"}
@@ -0,0 +1,101 @@
1
+ // src/errors/auth.errors.ts
2
+ var AuthError = class extends Error {
3
+ code;
4
+ cause;
5
+ details;
6
+ constructor(code, message, options) {
7
+ super(message);
8
+ this.name = "AuthError";
9
+ this.code = code;
10
+ this.cause = options?.cause;
11
+ this.details = options?.details;
12
+ }
13
+ };
14
+ var AuthValidationError = class extends AuthError {
15
+ constructor(message) {
16
+ super("INVALID_INPUT", message);
17
+ this.name = "AuthValidationError";
18
+ }
19
+ };
20
+ var AuthInvalidCredentialsError = class extends AuthError {
21
+ constructor() {
22
+ super("INVALID_CREDENTIALS", "Invalid email or password.");
23
+ this.name = "AuthInvalidCredentialsError";
24
+ }
25
+ };
26
+ var AuthEmailVerificationRequiredError = class extends AuthError {
27
+ constructor() {
28
+ super("EMAIL_NOT_VERIFIED", "Verify your email address before signing in.");
29
+ this.name = "AuthEmailVerificationRequiredError";
30
+ }
31
+ };
32
+ var AuthAccountConflictError = class extends AuthError {
33
+ constructor(options) {
34
+ super("CONFLICT", "Unable to create an account with the supplied details.", options);
35
+ this.name = "AuthAccountConflictError";
36
+ }
37
+ };
38
+ var AuthRateLimitError = class extends AuthError {
39
+ resetAt;
40
+ constructor(resetAt) {
41
+ super("RATE_LIMITED", "Too many authentication attempts. Try again later.", { details: { resetAt } });
42
+ this.name = "AuthRateLimitError";
43
+ this.resetAt = resetAt;
44
+ }
45
+ };
46
+ var AuthConfigurationError = class extends AuthError {
47
+ constructor(message, options) {
48
+ super("CONFIGURATION", message, options);
49
+ this.name = "AuthConfigurationError";
50
+ }
51
+ };
52
+ var AuthProviderError = class extends AuthError {
53
+ constructor(message, options) {
54
+ super("PROVIDER", message, options);
55
+ this.name = "AuthProviderError";
56
+ }
57
+ };
58
+ var AuthSessionError = class extends AuthError {
59
+ constructor(message, options) {
60
+ super("SESSION", message, options);
61
+ this.name = "AuthSessionError";
62
+ }
63
+ };
64
+ var AuthTokenError = class extends AuthError {
65
+ constructor() {
66
+ super("INVALID_TOKEN", "This link is invalid or has expired.");
67
+ this.name = "AuthTokenError";
68
+ }
69
+ };
70
+ /**
71
+ * Deliberately generic.
72
+ *
73
+ * Do not expose whether a challenge exists, which factor failed,
74
+ * or whether a recovery code belonged to another account.
75
+ */
76
+ var AuthMfaChallengeError = class extends AuthError {
77
+ constructor(options) {
78
+ super("MFA_CHALLENGE", "The authentication challenge is invalid or has expired.", options);
79
+ this.name = "AuthMfaChallengeError";
80
+ }
81
+ };
82
+ var AuthMfaFactorError = class extends AuthError {
83
+ constructor(message = "The authentication factor could not be used.", options) {
84
+ super("MFA_FACTOR", message, options);
85
+ this.name = "AuthMfaFactorError";
86
+ }
87
+ };
88
+ exports.AuthAccountConflictError = AuthAccountConflictError;
89
+ exports.AuthConfigurationError = AuthConfigurationError;
90
+ exports.AuthEmailVerificationRequiredError = AuthEmailVerificationRequiredError;
91
+ exports.AuthError = AuthError;
92
+ exports.AuthInvalidCredentialsError = AuthInvalidCredentialsError;
93
+ exports.AuthMfaChallengeError = AuthMfaChallengeError;
94
+ exports.AuthMfaFactorError = AuthMfaFactorError;
95
+ exports.AuthProviderError = AuthProviderError;
96
+ exports.AuthRateLimitError = AuthRateLimitError;
97
+ exports.AuthSessionError = AuthSessionError;
98
+ exports.AuthTokenError = AuthTokenError;
99
+ exports.AuthValidationError = AuthValidationError;
100
+
101
+ //# sourceMappingURL=auth.errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.errors.cjs","names":[],"sources":["../../src/errors/auth.errors.ts"],"sourcesContent":["export type AuthErrorCode =\n | \"INVALID_INPUT\"\n | \"INVALID_CREDENTIALS\"\n | \"EMAIL_NOT_VERIFIED\"\n | \"RATE_LIMITED\"\n | \"CONFLICT\"\n | \"CONFIGURATION\"\n | \"PROVIDER\"\n | \"SESSION\"\n | \"INVALID_TOKEN\"\n | \"MFA_CHALLENGE\"\n | \"MFA_FACTOR\";\n\nexport class AuthError extends Error {\n readonly code: AuthErrorCode;\n override readonly cause?: unknown;\n readonly details?: Readonly<Record<string, unknown>>;\n\n constructor(\n code: AuthErrorCode,\n message: string,\n options?: {\n readonly cause?: unknown;\n readonly details?: Readonly<Record<string, unknown>>;\n },\n ) {\n super(message);\n\n this.name = \"AuthError\";\n this.code = code;\n this.cause = options?.cause;\n this.details = options?.details;\n }\n}\n\nexport class AuthValidationError extends AuthError {\n constructor(message: string) {\n super(\"INVALID_INPUT\", message);\n this.name = \"AuthValidationError\";\n }\n}\n\nexport class AuthInvalidCredentialsError extends AuthError {\n constructor() {\n super(\"INVALID_CREDENTIALS\", \"Invalid email or password.\");\n this.name = \"AuthInvalidCredentialsError\";\n }\n}\n\nexport class AuthEmailVerificationRequiredError extends AuthError {\n constructor() {\n super(\"EMAIL_NOT_VERIFIED\", \"Verify your email address before signing in.\");\n this.name = \"AuthEmailVerificationRequiredError\";\n }\n}\n\nexport class AuthAccountConflictError extends AuthError {\n constructor(options?: { readonly cause?: unknown }) {\n super(\n \"CONFLICT\",\n \"Unable to create an account with the supplied details.\",\n options,\n );\n\n this.name = \"AuthAccountConflictError\";\n }\n}\n\nexport class AuthRateLimitError extends AuthError {\n readonly resetAt: Date;\n\n constructor(resetAt: Date) {\n super(\n \"RATE_LIMITED\",\n \"Too many authentication attempts. Try again later.\",\n {\n details: { resetAt },\n },\n );\n\n this.name = \"AuthRateLimitError\";\n this.resetAt = resetAt;\n }\n}\n\nexport class AuthConfigurationError extends AuthError {\n constructor(message: string, options?: { readonly cause?: unknown }) {\n super(\"CONFIGURATION\", message, options);\n this.name = \"AuthConfigurationError\";\n }\n}\n\nexport class AuthProviderError extends AuthError {\n constructor(message: string, options?: { readonly cause?: unknown }) {\n super(\"PROVIDER\", message, options);\n this.name = \"AuthProviderError\";\n }\n}\n\nexport class AuthSessionError extends AuthError {\n constructor(message: string, options?: { readonly cause?: unknown }) {\n super(\"SESSION\", message, options);\n this.name = \"AuthSessionError\";\n }\n}\n\nexport class AuthTokenError extends AuthError {\n constructor() {\n super(\"INVALID_TOKEN\", \"This link is invalid or has expired.\");\n this.name = \"AuthTokenError\";\n }\n}\n\n/**\n * Deliberately generic.\n *\n * Do not expose whether a challenge exists, which factor failed,\n * or whether a recovery code belonged to another account.\n */\nexport class AuthMfaChallengeError extends AuthError {\n constructor(options?: { readonly cause?: unknown }) {\n super(\n \"MFA_CHALLENGE\",\n \"The authentication challenge is invalid or has expired.\",\n options,\n );\n\n this.name = \"AuthMfaChallengeError\";\n }\n}\n\nexport class AuthMfaFactorError extends AuthError {\n constructor(\n message = \"The authentication factor could not be used.\",\n options?: {\n readonly cause?: unknown;\n },\n ) {\n super(\"MFA_FACTOR\", message, options);\n this.name = \"AuthMfaFactorError\";\n }\n}\n"],"mappings":";AAaA,IAAa,YAAb,cAA+B,MAAM;CACnC;CACA;CACA;CAEA,YACE,MACA,SACA,SAIA;EACA,MAAM,OAAO;EAEb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,QAAQ,SAAS;EACtB,KAAK,UAAU,SAAS;CAC1B;AACF;AAEA,IAAa,sBAAb,cAAyC,UAAU;CACjD,YAAY,SAAiB;EAC3B,MAAM,iBAAiB,OAAO;EAC9B,KAAK,OAAO;CACd;AACF;AAEA,IAAa,8BAAb,cAAiD,UAAU;CACzD,cAAc;EACZ,MAAM,uBAAuB,4BAA4B;EACzD,KAAK,OAAO;CACd;AACF;AAEA,IAAa,qCAAb,cAAwD,UAAU;CAChE,cAAc;EACZ,MAAM,sBAAsB,8CAA8C;EAC1E,KAAK,OAAO;CACd;AACF;AAEA,IAAa,2BAAb,cAA8C,UAAU;CACtD,YAAY,SAAwC;EAClD,MACE,YACA,0DACA,OACF;EAEA,KAAK,OAAO;CACd;AACF;AAEA,IAAa,qBAAb,cAAwC,UAAU;CAChD;CAEA,YAAY,SAAe;EACzB,MACE,gBACA,sDACA,EACE,SAAS,EAAE,QAAQ,EACrB,CACF;EAEA,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;AAEA,IAAa,yBAAb,cAA4C,UAAU;CACpD,YAAY,SAAiB,SAAwC;EACnE,MAAM,iBAAiB,SAAS,OAAO;EACvC,KAAK,OAAO;CACd;AACF;AAEA,IAAa,oBAAb,cAAuC,UAAU;CAC/C,YAAY,SAAiB,SAAwC;EACnE,MAAM,YAAY,SAAS,OAAO;EAClC,KAAK,OAAO;CACd;AACF;AAEA,IAAa,mBAAb,cAAsC,UAAU;CAC9C,YAAY,SAAiB,SAAwC;EACnE,MAAM,WAAW,SAAS,OAAO;EACjC,KAAK,OAAO;CACd;AACF;AAEA,IAAa,iBAAb,cAAoC,UAAU;CAC5C,cAAc;EACZ,MAAM,iBAAiB,sCAAsC;EAC7D,KAAK,OAAO;CACd;AACF;;;;;;;AAQA,IAAa,wBAAb,cAA2C,UAAU;CACnD,YAAY,SAAwC;EAClD,MACE,iBACA,2DACA,OACF;EAEA,KAAK,OAAO;CACd;AACF;AAEA,IAAa,qBAAb,cAAwC,UAAU;CAChD,YACE,UAAU,gDACV,SAGA;EACA,MAAM,cAAc,SAAS,OAAO;EACpC,KAAK,OAAO;CACd;AACF"}
@@ -0,0 +1,62 @@
1
+ export type AuthErrorCode = "INVALID_INPUT" | "INVALID_CREDENTIALS" | "EMAIL_NOT_VERIFIED" | "RATE_LIMITED" | "CONFLICT" | "CONFIGURATION" | "PROVIDER" | "SESSION" | "INVALID_TOKEN" | "MFA_CHALLENGE" | "MFA_FACTOR";
2
+ export declare class AuthError extends Error {
3
+ readonly code: AuthErrorCode;
4
+ readonly cause?: unknown;
5
+ readonly details?: Readonly<Record<string, unknown>>;
6
+ constructor(code: AuthErrorCode, message: string, options?: {
7
+ readonly cause?: unknown;
8
+ readonly details?: Readonly<Record<string, unknown>>;
9
+ });
10
+ }
11
+ export declare class AuthValidationError extends AuthError {
12
+ constructor(message: string);
13
+ }
14
+ export declare class AuthInvalidCredentialsError extends AuthError {
15
+ constructor();
16
+ }
17
+ export declare class AuthEmailVerificationRequiredError extends AuthError {
18
+ constructor();
19
+ }
20
+ export declare class AuthAccountConflictError extends AuthError {
21
+ constructor(options?: {
22
+ readonly cause?: unknown;
23
+ });
24
+ }
25
+ export declare class AuthRateLimitError extends AuthError {
26
+ readonly resetAt: Date;
27
+ constructor(resetAt: Date);
28
+ }
29
+ export declare class AuthConfigurationError extends AuthError {
30
+ constructor(message: string, options?: {
31
+ readonly cause?: unknown;
32
+ });
33
+ }
34
+ export declare class AuthProviderError extends AuthError {
35
+ constructor(message: string, options?: {
36
+ readonly cause?: unknown;
37
+ });
38
+ }
39
+ export declare class AuthSessionError extends AuthError {
40
+ constructor(message: string, options?: {
41
+ readonly cause?: unknown;
42
+ });
43
+ }
44
+ export declare class AuthTokenError extends AuthError {
45
+ constructor();
46
+ }
47
+ /**
48
+ * Deliberately generic.
49
+ *
50
+ * Do not expose whether a challenge exists, which factor failed,
51
+ * or whether a recovery code belonged to another account.
52
+ */
53
+ export declare class AuthMfaChallengeError extends AuthError {
54
+ constructor(options?: {
55
+ readonly cause?: unknown;
56
+ });
57
+ }
58
+ export declare class AuthMfaFactorError extends AuthError {
59
+ constructor(message?: string, options?: {
60
+ readonly cause?: unknown;
61
+ });
62
+ }
@@ -0,0 +1,62 @@
1
+ export type AuthErrorCode = "INVALID_INPUT" | "INVALID_CREDENTIALS" | "EMAIL_NOT_VERIFIED" | "RATE_LIMITED" | "CONFLICT" | "CONFIGURATION" | "PROVIDER" | "SESSION" | "INVALID_TOKEN" | "MFA_CHALLENGE" | "MFA_FACTOR";
2
+ export declare class AuthError extends Error {
3
+ readonly code: AuthErrorCode;
4
+ readonly cause?: unknown;
5
+ readonly details?: Readonly<Record<string, unknown>>;
6
+ constructor(code: AuthErrorCode, message: string, options?: {
7
+ readonly cause?: unknown;
8
+ readonly details?: Readonly<Record<string, unknown>>;
9
+ });
10
+ }
11
+ export declare class AuthValidationError extends AuthError {
12
+ constructor(message: string);
13
+ }
14
+ export declare class AuthInvalidCredentialsError extends AuthError {
15
+ constructor();
16
+ }
17
+ export declare class AuthEmailVerificationRequiredError extends AuthError {
18
+ constructor();
19
+ }
20
+ export declare class AuthAccountConflictError extends AuthError {
21
+ constructor(options?: {
22
+ readonly cause?: unknown;
23
+ });
24
+ }
25
+ export declare class AuthRateLimitError extends AuthError {
26
+ readonly resetAt: Date;
27
+ constructor(resetAt: Date);
28
+ }
29
+ export declare class AuthConfigurationError extends AuthError {
30
+ constructor(message: string, options?: {
31
+ readonly cause?: unknown;
32
+ });
33
+ }
34
+ export declare class AuthProviderError extends AuthError {
35
+ constructor(message: string, options?: {
36
+ readonly cause?: unknown;
37
+ });
38
+ }
39
+ export declare class AuthSessionError extends AuthError {
40
+ constructor(message: string, options?: {
41
+ readonly cause?: unknown;
42
+ });
43
+ }
44
+ export declare class AuthTokenError extends AuthError {
45
+ constructor();
46
+ }
47
+ /**
48
+ * Deliberately generic.
49
+ *
50
+ * Do not expose whether a challenge exists, which factor failed,
51
+ * or whether a recovery code belonged to another account.
52
+ */
53
+ export declare class AuthMfaChallengeError extends AuthError {
54
+ constructor(options?: {
55
+ readonly cause?: unknown;
56
+ });
57
+ }
58
+ export declare class AuthMfaFactorError extends AuthError {
59
+ constructor(message?: string, options?: {
60
+ readonly cause?: unknown;
61
+ });
62
+ }
@@ -0,0 +1,90 @@
1
+ // src/errors/auth.errors.ts
2
+ var AuthError = class extends Error {
3
+ code;
4
+ cause;
5
+ details;
6
+ constructor(code, message, options) {
7
+ super(message);
8
+ this.name = "AuthError";
9
+ this.code = code;
10
+ this.cause = options?.cause;
11
+ this.details = options?.details;
12
+ }
13
+ };
14
+ var AuthValidationError = class extends AuthError {
15
+ constructor(message) {
16
+ super("INVALID_INPUT", message);
17
+ this.name = "AuthValidationError";
18
+ }
19
+ };
20
+ var AuthInvalidCredentialsError = class extends AuthError {
21
+ constructor() {
22
+ super("INVALID_CREDENTIALS", "Invalid email or password.");
23
+ this.name = "AuthInvalidCredentialsError";
24
+ }
25
+ };
26
+ var AuthEmailVerificationRequiredError = class extends AuthError {
27
+ constructor() {
28
+ super("EMAIL_NOT_VERIFIED", "Verify your email address before signing in.");
29
+ this.name = "AuthEmailVerificationRequiredError";
30
+ }
31
+ };
32
+ var AuthAccountConflictError = class extends AuthError {
33
+ constructor(options) {
34
+ super("CONFLICT", "Unable to create an account with the supplied details.", options);
35
+ this.name = "AuthAccountConflictError";
36
+ }
37
+ };
38
+ var AuthRateLimitError = class extends AuthError {
39
+ resetAt;
40
+ constructor(resetAt) {
41
+ super("RATE_LIMITED", "Too many authentication attempts. Try again later.", { details: { resetAt } });
42
+ this.name = "AuthRateLimitError";
43
+ this.resetAt = resetAt;
44
+ }
45
+ };
46
+ var AuthConfigurationError = class extends AuthError {
47
+ constructor(message, options) {
48
+ super("CONFIGURATION", message, options);
49
+ this.name = "AuthConfigurationError";
50
+ }
51
+ };
52
+ var AuthProviderError = class extends AuthError {
53
+ constructor(message, options) {
54
+ super("PROVIDER", message, options);
55
+ this.name = "AuthProviderError";
56
+ }
57
+ };
58
+ var AuthSessionError = class extends AuthError {
59
+ constructor(message, options) {
60
+ super("SESSION", message, options);
61
+ this.name = "AuthSessionError";
62
+ }
63
+ };
64
+ var AuthTokenError = class extends AuthError {
65
+ constructor() {
66
+ super("INVALID_TOKEN", "This link is invalid or has expired.");
67
+ this.name = "AuthTokenError";
68
+ }
69
+ };
70
+ /**
71
+ * Deliberately generic.
72
+ *
73
+ * Do not expose whether a challenge exists, which factor failed,
74
+ * or whether a recovery code belonged to another account.
75
+ */
76
+ var AuthMfaChallengeError = class extends AuthError {
77
+ constructor(options) {
78
+ super("MFA_CHALLENGE", "The authentication challenge is invalid or has expired.", options);
79
+ this.name = "AuthMfaChallengeError";
80
+ }
81
+ };
82
+ var AuthMfaFactorError = class extends AuthError {
83
+ constructor(message = "The authentication factor could not be used.", options) {
84
+ super("MFA_FACTOR", message, options);
85
+ this.name = "AuthMfaFactorError";
86
+ }
87
+ };
88
+ export { AuthAccountConflictError, AuthConfigurationError, AuthEmailVerificationRequiredError, AuthError, AuthInvalidCredentialsError, AuthMfaChallengeError, AuthMfaFactorError, AuthProviderError, AuthRateLimitError, AuthSessionError, AuthTokenError, AuthValidationError };
89
+
90
+ //# sourceMappingURL=auth.errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.errors.js","names":[],"sources":["../../src/errors/auth.errors.ts"],"sourcesContent":["export type AuthErrorCode =\n | \"INVALID_INPUT\"\n | \"INVALID_CREDENTIALS\"\n | \"EMAIL_NOT_VERIFIED\"\n | \"RATE_LIMITED\"\n | \"CONFLICT\"\n | \"CONFIGURATION\"\n | \"PROVIDER\"\n | \"SESSION\"\n | \"INVALID_TOKEN\"\n | \"MFA_CHALLENGE\"\n | \"MFA_FACTOR\";\n\nexport class AuthError extends Error {\n readonly code: AuthErrorCode;\n override readonly cause?: unknown;\n readonly details?: Readonly<Record<string, unknown>>;\n\n constructor(\n code: AuthErrorCode,\n message: string,\n options?: {\n readonly cause?: unknown;\n readonly details?: Readonly<Record<string, unknown>>;\n },\n ) {\n super(message);\n\n this.name = \"AuthError\";\n this.code = code;\n this.cause = options?.cause;\n this.details = options?.details;\n }\n}\n\nexport class AuthValidationError extends AuthError {\n constructor(message: string) {\n super(\"INVALID_INPUT\", message);\n this.name = \"AuthValidationError\";\n }\n}\n\nexport class AuthInvalidCredentialsError extends AuthError {\n constructor() {\n super(\"INVALID_CREDENTIALS\", \"Invalid email or password.\");\n this.name = \"AuthInvalidCredentialsError\";\n }\n}\n\nexport class AuthEmailVerificationRequiredError extends AuthError {\n constructor() {\n super(\"EMAIL_NOT_VERIFIED\", \"Verify your email address before signing in.\");\n this.name = \"AuthEmailVerificationRequiredError\";\n }\n}\n\nexport class AuthAccountConflictError extends AuthError {\n constructor(options?: { readonly cause?: unknown }) {\n super(\n \"CONFLICT\",\n \"Unable to create an account with the supplied details.\",\n options,\n );\n\n this.name = \"AuthAccountConflictError\";\n }\n}\n\nexport class AuthRateLimitError extends AuthError {\n readonly resetAt: Date;\n\n constructor(resetAt: Date) {\n super(\n \"RATE_LIMITED\",\n \"Too many authentication attempts. Try again later.\",\n {\n details: { resetAt },\n },\n );\n\n this.name = \"AuthRateLimitError\";\n this.resetAt = resetAt;\n }\n}\n\nexport class AuthConfigurationError extends AuthError {\n constructor(message: string, options?: { readonly cause?: unknown }) {\n super(\"CONFIGURATION\", message, options);\n this.name = \"AuthConfigurationError\";\n }\n}\n\nexport class AuthProviderError extends AuthError {\n constructor(message: string, options?: { readonly cause?: unknown }) {\n super(\"PROVIDER\", message, options);\n this.name = \"AuthProviderError\";\n }\n}\n\nexport class AuthSessionError extends AuthError {\n constructor(message: string, options?: { readonly cause?: unknown }) {\n super(\"SESSION\", message, options);\n this.name = \"AuthSessionError\";\n }\n}\n\nexport class AuthTokenError extends AuthError {\n constructor() {\n super(\"INVALID_TOKEN\", \"This link is invalid or has expired.\");\n this.name = \"AuthTokenError\";\n }\n}\n\n/**\n * Deliberately generic.\n *\n * Do not expose whether a challenge exists, which factor failed,\n * or whether a recovery code belonged to another account.\n */\nexport class AuthMfaChallengeError extends AuthError {\n constructor(options?: { readonly cause?: unknown }) {\n super(\n \"MFA_CHALLENGE\",\n \"The authentication challenge is invalid or has expired.\",\n options,\n );\n\n this.name = \"AuthMfaChallengeError\";\n }\n}\n\nexport class AuthMfaFactorError extends AuthError {\n constructor(\n message = \"The authentication factor could not be used.\",\n options?: {\n readonly cause?: unknown;\n },\n ) {\n super(\"MFA_FACTOR\", message, options);\n this.name = \"AuthMfaFactorError\";\n }\n}\n"],"mappings":";AAaA,IAAa,YAAb,cAA+B,MAAM;CACnC;CACA;CACA;CAEA,YACE,MACA,SACA,SAIA;EACA,MAAM,OAAO;EAEb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,QAAQ,SAAS;EACtB,KAAK,UAAU,SAAS;CAC1B;AACF;AAEA,IAAa,sBAAb,cAAyC,UAAU;CACjD,YAAY,SAAiB;EAC3B,MAAM,iBAAiB,OAAO;EAC9B,KAAK,OAAO;CACd;AACF;AAEA,IAAa,8BAAb,cAAiD,UAAU;CACzD,cAAc;EACZ,MAAM,uBAAuB,4BAA4B;EACzD,KAAK,OAAO;CACd;AACF;AAEA,IAAa,qCAAb,cAAwD,UAAU;CAChE,cAAc;EACZ,MAAM,sBAAsB,8CAA8C;EAC1E,KAAK,OAAO;CACd;AACF;AAEA,IAAa,2BAAb,cAA8C,UAAU;CACtD,YAAY,SAAwC;EAClD,MACE,YACA,0DACA,OACF;EAEA,KAAK,OAAO;CACd;AACF;AAEA,IAAa,qBAAb,cAAwC,UAAU;CAChD;CAEA,YAAY,SAAe;EACzB,MACE,gBACA,sDACA,EACE,SAAS,EAAE,QAAQ,EACrB,CACF;EAEA,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;AAEA,IAAa,yBAAb,cAA4C,UAAU;CACpD,YAAY,SAAiB,SAAwC;EACnE,MAAM,iBAAiB,SAAS,OAAO;EACvC,KAAK,OAAO;CACd;AACF;AAEA,IAAa,oBAAb,cAAuC,UAAU;CAC/C,YAAY,SAAiB,SAAwC;EACnE,MAAM,YAAY,SAAS,OAAO;EAClC,KAAK,OAAO;CACd;AACF;AAEA,IAAa,mBAAb,cAAsC,UAAU;CAC9C,YAAY,SAAiB,SAAwC;EACnE,MAAM,WAAW,SAAS,OAAO;EACjC,KAAK,OAAO;CACd;AACF;AAEA,IAAa,iBAAb,cAAoC,UAAU;CAC5C,cAAc;EACZ,MAAM,iBAAiB,sCAAsC;EAC7D,KAAK,OAAO;CACd;AACF;;;;;;;AAQA,IAAa,wBAAb,cAA2C,UAAU;CACnD,YAAY,SAAwC;EAClD,MACE,iBACA,2DACA,OACF;EAEA,KAAK,OAAO;CACd;AACF;AAEA,IAAa,qBAAb,cAAwC,UAAU;CAChD,YACE,UAAU,gDACV,SAGA;EACA,MAAM,cAAc,SAAS,OAAO;EACpC,KAAK,OAAO;CACd;AACF"}
package/dist/index.cjs ADDED
@@ -0,0 +1,54 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_auth_manager = require("./auth.manager.cjs");
3
+ const require_auth_lifecycle_manager = require("./auth.lifecycle.manager.cjs");
4
+ const require_auth_rate_limit = require("./auth.rate-limit.cjs");
5
+ const require_auth_mfa_manager = require("./auth.mfa.manager.cjs");
6
+ const require_auth_step_up_manager = require("./auth.step-up.manager.cjs");
7
+ const require_auth_storage = require("./auth.storage.cjs");
8
+ const require_webcrypto_secret_protector = require("./providers/webcrypto-secret-protector.cjs");
9
+ const require_simplewebauthn_provider = require("./providers/simplewebauthn-provider.cjs");
10
+ const require_auth_errors = require("./errors/auth.errors.cjs");
11
+ const require_email_utils = require("./utils/email.utils.cjs");
12
+ const require_auth_crypto_utils = require("./utils/auth-crypto.utils.cjs");
13
+ const require_totp_utils = require("./utils/totp.utils.cjs");
14
+ exports.AUTH_ACTION_TOKEN_COLLECTION = require_auth_storage.AUTH_ACTION_TOKEN_COLLECTION;
15
+ exports.AUTH_AUDIT_COLLECTION = require_auth_storage.AUTH_AUDIT_COLLECTION;
16
+ exports.AUTH_CREDENTIAL_COLLECTION = require_auth_storage.AUTH_CREDENTIAL_COLLECTION;
17
+ exports.AUTH_MFA_CHALLENGE_COLLECTION = require_auth_storage.AUTH_MFA_CHALLENGE_COLLECTION;
18
+ exports.AUTH_MFA_FACTOR_COLLECTION = require_auth_storage.AUTH_MFA_FACTOR_COLLECTION;
19
+ exports.AUTH_MFA_STEP_UP_COLLECTION = require_auth_step_up_manager.AUTH_MFA_STEP_UP_COLLECTION;
20
+ exports.AUTH_RATE_LIMIT_COLLECTION = require_auth_storage.AUTH_RATE_LIMIT_COLLECTION;
21
+ exports.AUTH_RECOVERY_CODE_COLLECTION = require_auth_storage.AUTH_RECOVERY_CODE_COLLECTION;
22
+ exports.AUTH_USER_COLLECTION = require_auth_storage.AUTH_USER_COLLECTION;
23
+ exports.AuthAccountConflictError = require_auth_errors.AuthAccountConflictError;
24
+ exports.AuthConfigurationError = require_auth_errors.AuthConfigurationError;
25
+ exports.AuthEmailVerificationRequiredError = require_auth_errors.AuthEmailVerificationRequiredError;
26
+ exports.AuthError = require_auth_errors.AuthError;
27
+ exports.AuthInvalidCredentialsError = require_auth_errors.AuthInvalidCredentialsError;
28
+ exports.AuthMfaChallengeError = require_auth_errors.AuthMfaChallengeError;
29
+ exports.AuthMfaFactorError = require_auth_errors.AuthMfaFactorError;
30
+ exports.AuthProviderError = require_auth_errors.AuthProviderError;
31
+ exports.AuthRateLimitError = require_auth_errors.AuthRateLimitError;
32
+ exports.AuthSessionError = require_auth_errors.AuthSessionError;
33
+ exports.AuthTokenError = require_auth_errors.AuthTokenError;
34
+ exports.AuthValidationError = require_auth_errors.AuthValidationError;
35
+ exports.SimpleWebAuthnProvider = require_simplewebauthn_provider.SimpleWebAuthnProvider;
36
+ exports.StorageAuthLifecycleManager = require_auth_lifecycle_manager.StorageAuthLifecycleManager;
37
+ exports.StorageAuthManager = require_auth_manager.StorageAuthManager;
38
+ exports.StorageAuthMfaManager = require_auth_mfa_manager.StorageAuthMfaManager;
39
+ exports.StorageAuthStepUpManager = require_auth_step_up_manager.StorageAuthStepUpManager;
40
+ exports.StorageRateLimitProvider = require_auth_rate_limit.StorageRateLimitProvider;
41
+ exports.WebCryptoAuthSecretProtector = require_webcrypto_secret_protector.WebCryptoAuthSecretProtector;
42
+ exports.createRateLimitKey = require_auth_crypto_utils.createRateLimitKey;
43
+ exports.createTotpUri = require_totp_utils.createTotpUri;
44
+ exports.decodeBase32 = require_totp_utils.decodeBase32;
45
+ exports.encodeBase32 = require_totp_utils.encodeBase32;
46
+ exports.generateAuthId = require_auth_crypto_utils.generateAuthId;
47
+ exports.generateSecureAuthToken = require_auth_crypto_utils.generateSecureAuthToken;
48
+ exports.generateTotpCode = require_totp_utils.generateTotpCode;
49
+ exports.generateTotpSecret = require_totp_utils.generateTotpSecret;
50
+ exports.hashAuthToken = require_auth_crypto_utils.hashAuthToken;
51
+ exports.initializeAuthStorage = require_auth_storage.initializeAuthStorage;
52
+ exports.normalizeDisplayName = require_email_utils.normalizeDisplayName;
53
+ exports.normalizeEmail = require_email_utils.normalizeEmail;
54
+ exports.verifyTotpCode = require_totp_utils.verifyTotpCode;
@@ -0,0 +1,21 @@
1
+ import { StorageAuthManager, StorageAuthManagerDependencies } from "./auth.manager.cjs";
2
+ import { ChangePasswordInput, DeactivateAuthAccountInput, DeleteAuthAccountInput, RequestEmailChangeInput, RequestEmailVerificationInput, RequestPasswordResetInput, ResetPasswordInput, StorageAuthLifecycleManager, StorageAuthLifecycleManagerDependencies, UpdateAuthProfileInput } from "./auth.lifecycle.manager.cjs";
3
+ import { StorageRateLimitProvider, StorageRateLimitProviderOptions } from "./auth.rate-limit.cjs";
4
+ import { StorageAuthMfaManager, StorageAuthMfaManagerDependencies } from "./auth.mfa.manager.cjs";
5
+ import { AUTH_MFA_STEP_UP_COLLECTION, AuthStepUpChallengeStorageRecord, AuthStepUpManagerOptions, AuthStepUpPendingState, BeginStepUpInput, BeginStepUpPasskeyInput, CompleteStepUpInput, FinishStepUpPasskeyInput, StorageAuthStepUpManager, StorageAuthStepUpManagerDependencies } from "./auth.step-up.manager.cjs";
6
+ import { AUTH_ACTION_TOKEN_COLLECTION, AUTH_AUDIT_COLLECTION, AUTH_CREDENTIAL_COLLECTION, AUTH_MFA_CHALLENGE_COLLECTION, AUTH_MFA_FACTOR_COLLECTION, AUTH_RATE_LIMIT_COLLECTION, AUTH_RECOVERY_CODE_COLLECTION, AUTH_USER_COLLECTION, AuthUserStorageRecord, InitializeAuthStorageOptions, initializeAuthStorage } from "./auth.storage.cjs";
7
+ import { AuthUser } from "./types/user.types.cjs";
8
+ import { AuthState } from "./types/state.types.cjs";
9
+ import { PasswordCredentialStorageRecord } from "./types/credential.types.cjs";
10
+ import { AuthManager, AuthManagerDependencies, AuthManagerOptions, AuthMfaPolicy, AuthRateLimitPolicies, AuthRateLimitRule, AuthRateLimitScopePolicy, AuthRegisterInput, AuthRegisterResult, AuthResult, AuthSession, AuthSignInInput, AuthSignInResult } from "./types/auth-manager.types.cjs";
11
+ import { AuthActionTokenPurpose, AuthActionTokenStorageRecord, AuthAuditAction, AuthAuditEventStorageRecord, AuthLifecycleManagerOptions, AuthLifecycleRateLimitAction, AuthLifecycleRateLimitPolicies, AuthLifecycleRateLimitPolicy, AuthRateLimitStorageRecord } from "./types/auth-lifecycle.types.cjs";
12
+ import { EmailMessage, EmailProvider, PasswordHash, PasswordHasher, RateLimitProvider } from "./providers/provider.types.cjs";
13
+ import { AuthSecretProtector, ProtectedAuthSecret, WebAuthnAuthenticationVerification, WebAuthnOptionsJSON, WebAuthnProvider, WebAuthnRegistrationCredential, WebAuthnRegistrationVerification } from "./providers/mfa-provider.types.cjs";
14
+ import { WebCryptoAuthSecretProtector, WebCryptoAuthSecretProtectorOptions } from "./providers/webcrypto-secret-protector.cjs";
15
+ import { SimpleWebAuthnProvider } from "./providers/simplewebauthn-provider.cjs";
16
+ import { AuthAccountConflictError, AuthConfigurationError, AuthEmailVerificationRequiredError, AuthError, AuthErrorCode, AuthInvalidCredentialsError, AuthMfaChallengeError, AuthMfaFactorError, AuthProviderError, AuthRateLimitError, AuthSessionError, AuthTokenError, AuthValidationError } from "./errors/auth.errors.cjs";
17
+ import { AuthMfaAvailableFactor, AuthMfaChallengePurpose, AuthMfaChallengeStorageRecord, AuthMfaEnrollmentCompleted, AuthMfaEnrollmentFactor, AuthMfaEnrollmentPendingResult, AuthMfaFactor, AuthMfaFactorStatus, AuthMfaFactorStorageRecord, AuthMfaFactorType, AuthMfaGateway, AuthMfaManagerOptions, AuthMfaPendingResult, AuthMfaTotpOptions, AuthMfaWebAuthnOptions, AuthRecoveryCodeStorageRecord, BeginPasskeyRegistrationInput, BeginPasskeySignInInput, BeginRequiredMfaEnrollmentInput, BeginTotpEnrollmentInput, CompleteMfaSignInInput, FinishPasskeyRegistrationInput, FinishRequiredPasskeyEnrollmentInput, MfaEnrollmentCompleted, PasskeyMfaCompletedInput, PasskeyMfaStarted, PasskeyRegistrationStarted, PasskeySignInStarted, RegenerateRecoveryCodesInput, RemoveMfaFactorInput, TotpEnrollmentStarted, VerifyRequiredTotpEnrollmentInput, VerifyTotpEnrollmentInput } from "./types/mfa.types.cjs";
18
+ import { normalizeDisplayName, normalizeEmail } from "./utils/email.utils.cjs";
19
+ import { createRateLimitKey, generateAuthId, generateSecureAuthToken, hashAuthToken } from "./utils/auth-crypto.utils.cjs";
20
+ import { createTotpUri, decodeBase32, encodeBase32, generateTotpCode, generateTotpSecret, verifyTotpCode } from "./utils/totp.utils.cjs";
21
+ export { AUTH_ACTION_TOKEN_COLLECTION, AUTH_AUDIT_COLLECTION, AUTH_CREDENTIAL_COLLECTION, AUTH_MFA_CHALLENGE_COLLECTION, AUTH_MFA_FACTOR_COLLECTION, AUTH_MFA_STEP_UP_COLLECTION, AUTH_RATE_LIMIT_COLLECTION, AUTH_RECOVERY_CODE_COLLECTION, AUTH_USER_COLLECTION, AuthAccountConflictError, type AuthActionTokenPurpose, type AuthActionTokenStorageRecord, type AuthAuditAction, type AuthAuditEventStorageRecord, AuthConfigurationError, AuthEmailVerificationRequiredError, AuthError, type AuthErrorCode, AuthInvalidCredentialsError, type AuthLifecycleManagerOptions, type AuthLifecycleRateLimitAction, type AuthLifecycleRateLimitPolicies, type AuthLifecycleRateLimitPolicy, type AuthManager, type AuthManagerDependencies, type AuthManagerOptions, type AuthMfaAvailableFactor, AuthMfaChallengeError, type AuthMfaChallengePurpose, type AuthMfaChallengeStorageRecord, type AuthMfaEnrollmentCompleted, type AuthMfaEnrollmentFactor, type AuthMfaEnrollmentPendingResult, type AuthMfaFactor, AuthMfaFactorError, type AuthMfaFactorStatus, type AuthMfaFactorStorageRecord, type AuthMfaFactorType, type AuthMfaGateway, type AuthMfaManagerOptions, type AuthMfaPendingResult, type AuthMfaPolicy, type AuthMfaTotpOptions, type AuthMfaWebAuthnOptions, AuthProviderError, AuthRateLimitError, type AuthRateLimitPolicies, type AuthRateLimitRule, type AuthRateLimitScopePolicy, type AuthRateLimitStorageRecord, type AuthRecoveryCodeStorageRecord, type AuthRegisterInput, type AuthRegisterResult, type AuthResult, type AuthSecretProtector, type AuthSession, AuthSessionError, type AuthSignInInput, type AuthSignInResult, type AuthState, type AuthStepUpChallengeStorageRecord, type AuthStepUpManagerOptions, type AuthStepUpPendingState, AuthTokenError, type AuthUser, type AuthUserStorageRecord, AuthValidationError, type BeginPasskeyRegistrationInput, type BeginPasskeySignInInput, type BeginRequiredMfaEnrollmentInput, type BeginStepUpInput, type BeginStepUpPasskeyInput, type BeginTotpEnrollmentInput, type ChangePasswordInput, type CompleteMfaSignInInput, type CompleteStepUpInput, type DeactivateAuthAccountInput, type DeleteAuthAccountInput, type EmailMessage, type EmailProvider, type FinishPasskeyRegistrationInput, type FinishRequiredPasskeyEnrollmentInput, type FinishStepUpPasskeyInput, type InitializeAuthStorageOptions, type MfaEnrollmentCompleted, type PasskeyMfaCompletedInput, type PasskeyMfaStarted, type PasskeyRegistrationStarted, type PasskeySignInStarted, type PasswordCredentialStorageRecord, type PasswordHash, type PasswordHasher, type ProtectedAuthSecret, type RateLimitProvider, type RegenerateRecoveryCodesInput, type RemoveMfaFactorInput, type RequestEmailChangeInput, type RequestEmailVerificationInput, type RequestPasswordResetInput, type ResetPasswordInput, SimpleWebAuthnProvider, StorageAuthLifecycleManager, type StorageAuthLifecycleManagerDependencies, StorageAuthManager, type StorageAuthManagerDependencies, StorageAuthMfaManager, type StorageAuthMfaManagerDependencies, StorageAuthStepUpManager, type StorageAuthStepUpManagerDependencies, StorageRateLimitProvider, type StorageRateLimitProviderOptions, type TotpEnrollmentStarted, type UpdateAuthProfileInput, type VerifyRequiredTotpEnrollmentInput, type VerifyTotpEnrollmentInput, type WebAuthnAuthenticationVerification, type WebAuthnOptionsJSON, type WebAuthnProvider, type WebAuthnRegistrationCredential, type WebAuthnRegistrationVerification, WebCryptoAuthSecretProtector, type WebCryptoAuthSecretProtectorOptions, createRateLimitKey, createTotpUri, decodeBase32, encodeBase32, generateAuthId, generateSecureAuthToken, generateTotpCode, generateTotpSecret, hashAuthToken, initializeAuthStorage, normalizeDisplayName, normalizeEmail, verifyTotpCode };
@@ -0,0 +1,21 @@
1
+ import { StorageAuthManager, StorageAuthManagerDependencies } from "./auth.manager.js";
2
+ import { ChangePasswordInput, DeactivateAuthAccountInput, DeleteAuthAccountInput, RequestEmailChangeInput, RequestEmailVerificationInput, RequestPasswordResetInput, ResetPasswordInput, StorageAuthLifecycleManager, StorageAuthLifecycleManagerDependencies, UpdateAuthProfileInput } from "./auth.lifecycle.manager.js";
3
+ import { StorageRateLimitProvider, StorageRateLimitProviderOptions } from "./auth.rate-limit.js";
4
+ import { StorageAuthMfaManager, StorageAuthMfaManagerDependencies } from "./auth.mfa.manager.js";
5
+ import { AUTH_MFA_STEP_UP_COLLECTION, AuthStepUpChallengeStorageRecord, AuthStepUpManagerOptions, AuthStepUpPendingState, BeginStepUpInput, BeginStepUpPasskeyInput, CompleteStepUpInput, FinishStepUpPasskeyInput, StorageAuthStepUpManager, StorageAuthStepUpManagerDependencies } from "./auth.step-up.manager.js";
6
+ import { AUTH_ACTION_TOKEN_COLLECTION, AUTH_AUDIT_COLLECTION, AUTH_CREDENTIAL_COLLECTION, AUTH_MFA_CHALLENGE_COLLECTION, AUTH_MFA_FACTOR_COLLECTION, AUTH_RATE_LIMIT_COLLECTION, AUTH_RECOVERY_CODE_COLLECTION, AUTH_USER_COLLECTION, AuthUserStorageRecord, InitializeAuthStorageOptions, initializeAuthStorage } from "./auth.storage.js";
7
+ import { AuthUser } from "./types/user.types.js";
8
+ import { AuthState } from "./types/state.types.js";
9
+ import { PasswordCredentialStorageRecord } from "./types/credential.types.js";
10
+ import { AuthManager, AuthManagerDependencies, AuthManagerOptions, AuthMfaPolicy, AuthRateLimitPolicies, AuthRateLimitRule, AuthRateLimitScopePolicy, AuthRegisterInput, AuthRegisterResult, AuthResult, AuthSession, AuthSignInInput, AuthSignInResult } from "./types/auth-manager.types.js";
11
+ import { AuthActionTokenPurpose, AuthActionTokenStorageRecord, AuthAuditAction, AuthAuditEventStorageRecord, AuthLifecycleManagerOptions, AuthLifecycleRateLimitAction, AuthLifecycleRateLimitPolicies, AuthLifecycleRateLimitPolicy, AuthRateLimitStorageRecord } from "./types/auth-lifecycle.types.js";
12
+ import { EmailMessage, EmailProvider, PasswordHash, PasswordHasher, RateLimitProvider } from "./providers/provider.types.js";
13
+ import { AuthSecretProtector, ProtectedAuthSecret, WebAuthnAuthenticationVerification, WebAuthnOptionsJSON, WebAuthnProvider, WebAuthnRegistrationCredential, WebAuthnRegistrationVerification } from "./providers/mfa-provider.types.js";
14
+ import { WebCryptoAuthSecretProtector, WebCryptoAuthSecretProtectorOptions } from "./providers/webcrypto-secret-protector.js";
15
+ import { SimpleWebAuthnProvider } from "./providers/simplewebauthn-provider.js";
16
+ import { AuthAccountConflictError, AuthConfigurationError, AuthEmailVerificationRequiredError, AuthError, AuthErrorCode, AuthInvalidCredentialsError, AuthMfaChallengeError, AuthMfaFactorError, AuthProviderError, AuthRateLimitError, AuthSessionError, AuthTokenError, AuthValidationError } from "./errors/auth.errors.js";
17
+ import { AuthMfaAvailableFactor, AuthMfaChallengePurpose, AuthMfaChallengeStorageRecord, AuthMfaEnrollmentCompleted, AuthMfaEnrollmentFactor, AuthMfaEnrollmentPendingResult, AuthMfaFactor, AuthMfaFactorStatus, AuthMfaFactorStorageRecord, AuthMfaFactorType, AuthMfaGateway, AuthMfaManagerOptions, AuthMfaPendingResult, AuthMfaTotpOptions, AuthMfaWebAuthnOptions, AuthRecoveryCodeStorageRecord, BeginPasskeyRegistrationInput, BeginPasskeySignInInput, BeginRequiredMfaEnrollmentInput, BeginTotpEnrollmentInput, CompleteMfaSignInInput, FinishPasskeyRegistrationInput, FinishRequiredPasskeyEnrollmentInput, MfaEnrollmentCompleted, PasskeyMfaCompletedInput, PasskeyMfaStarted, PasskeyRegistrationStarted, PasskeySignInStarted, RegenerateRecoveryCodesInput, RemoveMfaFactorInput, TotpEnrollmentStarted, VerifyRequiredTotpEnrollmentInput, VerifyTotpEnrollmentInput } from "./types/mfa.types.js";
18
+ import { normalizeDisplayName, normalizeEmail } from "./utils/email.utils.js";
19
+ import { createRateLimitKey, generateAuthId, generateSecureAuthToken, hashAuthToken } from "./utils/auth-crypto.utils.js";
20
+ import { createTotpUri, decodeBase32, encodeBase32, generateTotpCode, generateTotpSecret, verifyTotpCode } from "./utils/totp.utils.js";
21
+ export { AUTH_ACTION_TOKEN_COLLECTION, AUTH_AUDIT_COLLECTION, AUTH_CREDENTIAL_COLLECTION, AUTH_MFA_CHALLENGE_COLLECTION, AUTH_MFA_FACTOR_COLLECTION, AUTH_MFA_STEP_UP_COLLECTION, AUTH_RATE_LIMIT_COLLECTION, AUTH_RECOVERY_CODE_COLLECTION, AUTH_USER_COLLECTION, AuthAccountConflictError, type AuthActionTokenPurpose, type AuthActionTokenStorageRecord, type AuthAuditAction, type AuthAuditEventStorageRecord, AuthConfigurationError, AuthEmailVerificationRequiredError, AuthError, type AuthErrorCode, AuthInvalidCredentialsError, type AuthLifecycleManagerOptions, type AuthLifecycleRateLimitAction, type AuthLifecycleRateLimitPolicies, type AuthLifecycleRateLimitPolicy, type AuthManager, type AuthManagerDependencies, type AuthManagerOptions, type AuthMfaAvailableFactor, AuthMfaChallengeError, type AuthMfaChallengePurpose, type AuthMfaChallengeStorageRecord, type AuthMfaEnrollmentCompleted, type AuthMfaEnrollmentFactor, type AuthMfaEnrollmentPendingResult, type AuthMfaFactor, AuthMfaFactorError, type AuthMfaFactorStatus, type AuthMfaFactorStorageRecord, type AuthMfaFactorType, type AuthMfaGateway, type AuthMfaManagerOptions, type AuthMfaPendingResult, type AuthMfaPolicy, type AuthMfaTotpOptions, type AuthMfaWebAuthnOptions, AuthProviderError, AuthRateLimitError, type AuthRateLimitPolicies, type AuthRateLimitRule, type AuthRateLimitScopePolicy, type AuthRateLimitStorageRecord, type AuthRecoveryCodeStorageRecord, type AuthRegisterInput, type AuthRegisterResult, type AuthResult, type AuthSecretProtector, type AuthSession, AuthSessionError, type AuthSignInInput, type AuthSignInResult, type AuthState, type AuthStepUpChallengeStorageRecord, type AuthStepUpManagerOptions, type AuthStepUpPendingState, AuthTokenError, type AuthUser, type AuthUserStorageRecord, AuthValidationError, type BeginPasskeyRegistrationInput, type BeginPasskeySignInInput, type BeginRequiredMfaEnrollmentInput, type BeginStepUpInput, type BeginStepUpPasskeyInput, type BeginTotpEnrollmentInput, type ChangePasswordInput, type CompleteMfaSignInInput, type CompleteStepUpInput, type DeactivateAuthAccountInput, type DeleteAuthAccountInput, type EmailMessage, type EmailProvider, type FinishPasskeyRegistrationInput, type FinishRequiredPasskeyEnrollmentInput, type FinishStepUpPasskeyInput, type InitializeAuthStorageOptions, type MfaEnrollmentCompleted, type PasskeyMfaCompletedInput, type PasskeyMfaStarted, type PasskeyRegistrationStarted, type PasskeySignInStarted, type PasswordCredentialStorageRecord, type PasswordHash, type PasswordHasher, type ProtectedAuthSecret, type RateLimitProvider, type RegenerateRecoveryCodesInput, type RemoveMfaFactorInput, type RequestEmailChangeInput, type RequestEmailVerificationInput, type RequestPasswordResetInput, type ResetPasswordInput, SimpleWebAuthnProvider, StorageAuthLifecycleManager, type StorageAuthLifecycleManagerDependencies, StorageAuthManager, type StorageAuthManagerDependencies, StorageAuthMfaManager, type StorageAuthMfaManagerDependencies, StorageAuthStepUpManager, type StorageAuthStepUpManagerDependencies, StorageRateLimitProvider, type StorageRateLimitProviderOptions, type TotpEnrollmentStarted, type UpdateAuthProfileInput, type VerifyRequiredTotpEnrollmentInput, type VerifyTotpEnrollmentInput, type WebAuthnAuthenticationVerification, type WebAuthnOptionsJSON, type WebAuthnProvider, type WebAuthnRegistrationCredential, type WebAuthnRegistrationVerification, WebCryptoAuthSecretProtector, type WebCryptoAuthSecretProtectorOptions, createRateLimitKey, createTotpUri, decodeBase32, encodeBase32, generateAuthId, generateSecureAuthToken, generateTotpCode, generateTotpSecret, hashAuthToken, initializeAuthStorage, normalizeDisplayName, normalizeEmail, verifyTotpCode };
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ import { StorageAuthManager } from "./auth.manager.js";
2
+ import { StorageAuthLifecycleManager } from "./auth.lifecycle.manager.js";
3
+ import { StorageRateLimitProvider } from "./auth.rate-limit.js";
4
+ import { StorageAuthMfaManager } from "./auth.mfa.manager.js";
5
+ import { AUTH_MFA_STEP_UP_COLLECTION, StorageAuthStepUpManager } from "./auth.step-up.manager.js";
6
+ import { AUTH_ACTION_TOKEN_COLLECTION, AUTH_AUDIT_COLLECTION, AUTH_CREDENTIAL_COLLECTION, AUTH_MFA_CHALLENGE_COLLECTION, AUTH_MFA_FACTOR_COLLECTION, AUTH_RATE_LIMIT_COLLECTION, AUTH_RECOVERY_CODE_COLLECTION, AUTH_USER_COLLECTION, initializeAuthStorage } from "./auth.storage.js";
7
+ import { WebCryptoAuthSecretProtector } from "./providers/webcrypto-secret-protector.js";
8
+ import { SimpleWebAuthnProvider } from "./providers/simplewebauthn-provider.js";
9
+ import { AuthAccountConflictError, AuthConfigurationError, AuthEmailVerificationRequiredError, AuthError, AuthInvalidCredentialsError, AuthMfaChallengeError, AuthMfaFactorError, AuthProviderError, AuthRateLimitError, AuthSessionError, AuthTokenError, AuthValidationError } from "./errors/auth.errors.js";
10
+ import { normalizeDisplayName, normalizeEmail } from "./utils/email.utils.js";
11
+ import { createRateLimitKey, generateAuthId, generateSecureAuthToken, hashAuthToken } from "./utils/auth-crypto.utils.js";
12
+ import { createTotpUri, decodeBase32, encodeBase32, generateTotpCode, generateTotpSecret, verifyTotpCode } from "./utils/totp.utils.js";
13
+ export { AUTH_ACTION_TOKEN_COLLECTION, AUTH_AUDIT_COLLECTION, AUTH_CREDENTIAL_COLLECTION, AUTH_MFA_CHALLENGE_COLLECTION, AUTH_MFA_FACTOR_COLLECTION, AUTH_MFA_STEP_UP_COLLECTION, AUTH_RATE_LIMIT_COLLECTION, AUTH_RECOVERY_CODE_COLLECTION, AUTH_USER_COLLECTION, AuthAccountConflictError, AuthConfigurationError, AuthEmailVerificationRequiredError, AuthError, AuthInvalidCredentialsError, AuthMfaChallengeError, AuthMfaFactorError, AuthProviderError, AuthRateLimitError, AuthSessionError, AuthTokenError, AuthValidationError, SimpleWebAuthnProvider, StorageAuthLifecycleManager, StorageAuthManager, StorageAuthMfaManager, StorageAuthStepUpManager, StorageRateLimitProvider, WebCryptoAuthSecretProtector, createRateLimitKey, createTotpUri, decodeBase32, encodeBase32, generateAuthId, generateSecureAuthToken, generateTotpCode, generateTotpSecret, hashAuthToken, initializeAuthStorage, normalizeDisplayName, normalizeEmail, verifyTotpCode };