@spfn/auth 0.1.0-alpha.88 → 0.2.0-beta.10

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 (152) hide show
  1. package/README.md +1385 -1199
  2. package/dist/config.d.ts +409 -0
  3. package/dist/config.js +244 -0
  4. package/dist/config.js.map +1 -0
  5. package/dist/dto-CRlgoCP5.d.ts +645 -0
  6. package/dist/errors.d.ts +196 -0
  7. package/dist/errors.js +173 -0
  8. package/dist/errors.js.map +1 -0
  9. package/dist/index.d.ts +287 -14
  10. package/dist/index.js +511 -6665
  11. package/dist/index.js.map +1 -1
  12. package/dist/nextjs/api.js +345 -0
  13. package/dist/nextjs/api.js.map +1 -0
  14. package/dist/{adapters/nextjs → nextjs}/server.d.ts +47 -65
  15. package/dist/nextjs/server.js +178 -0
  16. package/dist/nextjs/server.js.map +1 -0
  17. package/dist/server.d.ts +4444 -514
  18. package/dist/server.js +7977 -1210
  19. package/dist/server.js.map +1 -1
  20. package/migrations/0000_premium_famine.sql +292 -0
  21. package/migrations/meta/0000_snapshot.json +281 -46
  22. package/migrations/meta/_journal.json +2 -2
  23. package/package.json +37 -33
  24. package/dist/adapters/nextjs/api.d.ts +0 -446
  25. package/dist/adapters/nextjs/api.js +0 -3279
  26. package/dist/adapters/nextjs/api.js.map +0 -1
  27. package/dist/adapters/nextjs/server.js +0 -3645
  28. package/dist/adapters/nextjs/server.js.map +0 -1
  29. package/dist/lib/api/auth-codes-verify.d.ts +0 -37
  30. package/dist/lib/api/auth-codes-verify.js +0 -2949
  31. package/dist/lib/api/auth-codes-verify.js.map +0 -1
  32. package/dist/lib/api/auth-codes.d.ts +0 -37
  33. package/dist/lib/api/auth-codes.js +0 -2949
  34. package/dist/lib/api/auth-codes.js.map +0 -1
  35. package/dist/lib/api/auth-exists.d.ts +0 -38
  36. package/dist/lib/api/auth-exists.js +0 -2949
  37. package/dist/lib/api/auth-exists.js.map +0 -1
  38. package/dist/lib/api/auth-invitations-accept.d.ts +0 -38
  39. package/dist/lib/api/auth-invitations-accept.js +0 -2883
  40. package/dist/lib/api/auth-invitations-accept.js.map +0 -1
  41. package/dist/lib/api/auth-invitations-cancel.d.ts +0 -37
  42. package/dist/lib/api/auth-invitations-cancel.js +0 -2883
  43. package/dist/lib/api/auth-invitations-cancel.js.map +0 -1
  44. package/dist/lib/api/auth-invitations-delete.d.ts +0 -36
  45. package/dist/lib/api/auth-invitations-delete.js +0 -2883
  46. package/dist/lib/api/auth-invitations-delete.js.map +0 -1
  47. package/dist/lib/api/auth-invitations-resend.d.ts +0 -37
  48. package/dist/lib/api/auth-invitations-resend.js +0 -2883
  49. package/dist/lib/api/auth-invitations-resend.js.map +0 -1
  50. package/dist/lib/api/auth-invitations.d.ts +0 -109
  51. package/dist/lib/api/auth-invitations.js +0 -2887
  52. package/dist/lib/api/auth-invitations.js.map +0 -1
  53. package/dist/lib/api/auth-keys-rotate.d.ts +0 -37
  54. package/dist/lib/api/auth-keys-rotate.js +0 -2949
  55. package/dist/lib/api/auth-keys-rotate.js.map +0 -1
  56. package/dist/lib/api/auth-login.d.ts +0 -39
  57. package/dist/lib/api/auth-login.js +0 -2949
  58. package/dist/lib/api/auth-login.js.map +0 -1
  59. package/dist/lib/api/auth-logout.d.ts +0 -36
  60. package/dist/lib/api/auth-logout.js +0 -2949
  61. package/dist/lib/api/auth-logout.js.map +0 -1
  62. package/dist/lib/api/auth-me.d.ts +0 -50
  63. package/dist/lib/api/auth-me.js +0 -2949
  64. package/dist/lib/api/auth-me.js.map +0 -1
  65. package/dist/lib/api/auth-password.d.ts +0 -36
  66. package/dist/lib/api/auth-password.js +0 -2949
  67. package/dist/lib/api/auth-password.js.map +0 -1
  68. package/dist/lib/api/auth-register.d.ts +0 -38
  69. package/dist/lib/api/auth-register.js +0 -2949
  70. package/dist/lib/api/auth-register.js.map +0 -1
  71. package/dist/lib/api/index.d.ts +0 -356
  72. package/dist/lib/api/index.js +0 -3261
  73. package/dist/lib/api/index.js.map +0 -1
  74. package/dist/lib/config.d.ts +0 -70
  75. package/dist/lib/config.js +0 -64
  76. package/dist/lib/config.js.map +0 -1
  77. package/dist/lib/contracts/auth.d.ts +0 -302
  78. package/dist/lib/contracts/auth.js +0 -2951
  79. package/dist/lib/contracts/auth.js.map +0 -1
  80. package/dist/lib/contracts/index.d.ts +0 -3
  81. package/dist/lib/contracts/index.js +0 -3190
  82. package/dist/lib/contracts/index.js.map +0 -1
  83. package/dist/lib/contracts/invitation.d.ts +0 -243
  84. package/dist/lib/contracts/invitation.js +0 -2883
  85. package/dist/lib/contracts/invitation.js.map +0 -1
  86. package/dist/lib/crypto.d.ts +0 -76
  87. package/dist/lib/crypto.js +0 -127
  88. package/dist/lib/crypto.js.map +0 -1
  89. package/dist/lib/index.d.ts +0 -4
  90. package/dist/lib/index.js +0 -313
  91. package/dist/lib/index.js.map +0 -1
  92. package/dist/lib/session.d.ts +0 -68
  93. package/dist/lib/session.js +0 -126
  94. package/dist/lib/session.js.map +0 -1
  95. package/dist/lib/types/api.d.ts +0 -45
  96. package/dist/lib/types/api.js +0 -1
  97. package/dist/lib/types/api.js.map +0 -1
  98. package/dist/lib/types/index.d.ts +0 -3
  99. package/dist/lib/types/index.js +0 -2647
  100. package/dist/lib/types/index.js.map +0 -1
  101. package/dist/lib/types/schemas.d.ts +0 -45
  102. package/dist/lib/types/schemas.js +0 -2647
  103. package/dist/lib/types/schemas.js.map +0 -1
  104. package/dist/lib.js +0 -1
  105. package/dist/lib.js.map +0 -1
  106. package/dist/plugin.d.ts +0 -12
  107. package/dist/plugin.js +0 -9083
  108. package/dist/plugin.js.map +0 -1
  109. package/dist/server/entities/index.d.ts +0 -11
  110. package/dist/server/entities/index.js +0 -395
  111. package/dist/server/entities/index.js.map +0 -1
  112. package/dist/server/entities/invitations.d.ts +0 -241
  113. package/dist/server/entities/invitations.js +0 -184
  114. package/dist/server/entities/invitations.js.map +0 -1
  115. package/dist/server/entities/permissions.d.ts +0 -196
  116. package/dist/server/entities/permissions.js +0 -49
  117. package/dist/server/entities/permissions.js.map +0 -1
  118. package/dist/server/entities/role-permissions.d.ts +0 -107
  119. package/dist/server/entities/role-permissions.js +0 -115
  120. package/dist/server/entities/role-permissions.js.map +0 -1
  121. package/dist/server/entities/roles.d.ts +0 -196
  122. package/dist/server/entities/roles.js +0 -50
  123. package/dist/server/entities/roles.js.map +0 -1
  124. package/dist/server/entities/schema.d.ts +0 -14
  125. package/dist/server/entities/schema.js +0 -7
  126. package/dist/server/entities/schema.js.map +0 -1
  127. package/dist/server/entities/user-permissions.d.ts +0 -163
  128. package/dist/server/entities/user-permissions.js +0 -193
  129. package/dist/server/entities/user-permissions.js.map +0 -1
  130. package/dist/server/entities/user-public-keys.d.ts +0 -227
  131. package/dist/server/entities/user-public-keys.js +0 -156
  132. package/dist/server/entities/user-public-keys.js.map +0 -1
  133. package/dist/server/entities/user-social-accounts.d.ts +0 -189
  134. package/dist/server/entities/user-social-accounts.js +0 -149
  135. package/dist/server/entities/user-social-accounts.js.map +0 -1
  136. package/dist/server/entities/users.d.ts +0 -235
  137. package/dist/server/entities/users.js +0 -117
  138. package/dist/server/entities/users.js.map +0 -1
  139. package/dist/server/entities/verification-codes.d.ts +0 -191
  140. package/dist/server/entities/verification-codes.js +0 -49
  141. package/dist/server/entities/verification-codes.js.map +0 -1
  142. package/dist/server/routes/auth/index.d.ts +0 -10
  143. package/dist/server/routes/auth/index.js +0 -4460
  144. package/dist/server/routes/auth/index.js.map +0 -1
  145. package/dist/server/routes/index.d.ts +0 -6
  146. package/dist/server/routes/index.js +0 -6584
  147. package/dist/server/routes/index.js.map +0 -1
  148. package/dist/server/routes/invitations/index.d.ts +0 -10
  149. package/dist/server/routes/invitations/index.js +0 -4395
  150. package/dist/server/routes/invitations/index.js.map +0 -1
  151. package/migrations/0000_skinny_christian_walker.sql +0 -167
  152. /package/dist/{lib.d.ts → nextjs/api.d.ts} +0 -0
@@ -0,0 +1,196 @@
1
+ import { UnauthorizedError, ForbiddenError, ConflictError, ValidationError, ErrorRegistry } from '@spfn/core/errors';
2
+
3
+ /**
4
+ * Authentication & Authorization Error Classes
5
+ *
6
+ * Custom error classes for auth-specific scenarios
7
+ */
8
+
9
+ /**
10
+ * Invalid Credentials Error (401)
11
+ *
12
+ * Thrown when login credentials are incorrect
13
+ */
14
+ declare class InvalidCredentialsError extends UnauthorizedError {
15
+ constructor(data?: {
16
+ message?: string;
17
+ details?: Record<string, any>;
18
+ });
19
+ }
20
+ /**
21
+ * Invalid Token Error (401)
22
+ *
23
+ * Thrown when authentication token is invalid or malformed
24
+ */
25
+ declare class InvalidTokenError extends UnauthorizedError {
26
+ constructor(data?: {
27
+ message?: string;
28
+ details?: Record<string, any>;
29
+ });
30
+ }
31
+ /**
32
+ * Token Expired Error (401)
33
+ *
34
+ * Thrown when authentication token has expired
35
+ */
36
+ declare class TokenExpiredError extends UnauthorizedError {
37
+ constructor(data?: {
38
+ message?: string;
39
+ details?: Record<string, any>;
40
+ });
41
+ }
42
+ /**
43
+ * Key Expired Error (401)
44
+ *
45
+ * Thrown when public key has expired
46
+ */
47
+ declare class KeyExpiredError extends UnauthorizedError {
48
+ constructor(data?: {
49
+ message?: string;
50
+ details?: Record<string, any>;
51
+ });
52
+ }
53
+ /**
54
+ * Account Disabled Error (403)
55
+ *
56
+ * Thrown when user account is disabled or inactive
57
+ */
58
+ declare class AccountDisabledError extends ForbiddenError {
59
+ constructor(data?: {
60
+ status?: string;
61
+ message?: string;
62
+ details?: Record<string, any>;
63
+ });
64
+ }
65
+ /**
66
+ * Account Already Exists Error (409)
67
+ *
68
+ * Thrown when trying to register with existing email/phone
69
+ */
70
+ declare class AccountAlreadyExistsError extends ConflictError {
71
+ constructor(data?: {
72
+ identifier?: string;
73
+ identifierType?: 'email' | 'phone';
74
+ message?: string;
75
+ details?: Record<string, any>;
76
+ });
77
+ }
78
+ /**
79
+ * Invalid Verification Code Error (400)
80
+ *
81
+ * Thrown when verification code is invalid, expired, or already used
82
+ */
83
+ declare class InvalidVerificationCodeError extends ValidationError {
84
+ constructor(data?: {
85
+ message?: string;
86
+ details?: Record<string, any>;
87
+ });
88
+ }
89
+ /**
90
+ * Invalid Verification Token Error (400)
91
+ *
92
+ * Thrown when verification token is invalid or expired
93
+ */
94
+ declare class InvalidVerificationTokenError extends ValidationError {
95
+ constructor(data?: {
96
+ message?: string;
97
+ details?: Record<string, any>;
98
+ });
99
+ }
100
+ /**
101
+ * Invalid Key Fingerprint Error (400)
102
+ *
103
+ * Thrown when public key fingerprint doesn't match the public key
104
+ */
105
+ declare class InvalidKeyFingerprintError extends ValidationError {
106
+ constructor(data?: {
107
+ message?: string;
108
+ details?: Record<string, any>;
109
+ });
110
+ }
111
+ /**
112
+ * Verification Token Purpose Mismatch Error (400)
113
+ *
114
+ * Thrown when verification token purpose doesn't match expected purpose
115
+ */
116
+ declare class VerificationTokenPurposeMismatchError extends ValidationError {
117
+ constructor(data?: {
118
+ expected?: string;
119
+ actual?: string;
120
+ message?: string;
121
+ details?: Record<string, any>;
122
+ });
123
+ }
124
+ /**
125
+ * Verification Token Target Mismatch Error (400)
126
+ *
127
+ * Thrown when verification token target doesn't match provided email/phone
128
+ */
129
+ declare class VerificationTokenTargetMismatchError extends ValidationError {
130
+ constructor(data?: {
131
+ message?: string;
132
+ details?: Record<string, any>;
133
+ });
134
+ }
135
+ /**
136
+ * Insufficient Permissions Error (403)
137
+ *
138
+ * Thrown when user lacks required permissions for the operation
139
+ */
140
+ declare class InsufficientPermissionsError extends ForbiddenError {
141
+ constructor(data?: {
142
+ requiredPermissions?: string[];
143
+ message?: string;
144
+ details?: Record<string, any>;
145
+ });
146
+ }
147
+ /**
148
+ * Insufficient Role Error (403)
149
+ *
150
+ * Thrown when user lacks required role for the operation
151
+ */
152
+ declare class InsufficientRoleError extends ForbiddenError {
153
+ constructor(data?: {
154
+ requiredRoles?: string[];
155
+ message?: string;
156
+ details?: Record<string, any>;
157
+ });
158
+ }
159
+
160
+ type authErrors_AccountAlreadyExistsError = AccountAlreadyExistsError;
161
+ declare const authErrors_AccountAlreadyExistsError: typeof AccountAlreadyExistsError;
162
+ type authErrors_AccountDisabledError = AccountDisabledError;
163
+ declare const authErrors_AccountDisabledError: typeof AccountDisabledError;
164
+ type authErrors_InsufficientPermissionsError = InsufficientPermissionsError;
165
+ declare const authErrors_InsufficientPermissionsError: typeof InsufficientPermissionsError;
166
+ type authErrors_InsufficientRoleError = InsufficientRoleError;
167
+ declare const authErrors_InsufficientRoleError: typeof InsufficientRoleError;
168
+ type authErrors_InvalidCredentialsError = InvalidCredentialsError;
169
+ declare const authErrors_InvalidCredentialsError: typeof InvalidCredentialsError;
170
+ type authErrors_InvalidKeyFingerprintError = InvalidKeyFingerprintError;
171
+ declare const authErrors_InvalidKeyFingerprintError: typeof InvalidKeyFingerprintError;
172
+ type authErrors_InvalidTokenError = InvalidTokenError;
173
+ declare const authErrors_InvalidTokenError: typeof InvalidTokenError;
174
+ type authErrors_InvalidVerificationCodeError = InvalidVerificationCodeError;
175
+ declare const authErrors_InvalidVerificationCodeError: typeof InvalidVerificationCodeError;
176
+ type authErrors_InvalidVerificationTokenError = InvalidVerificationTokenError;
177
+ declare const authErrors_InvalidVerificationTokenError: typeof InvalidVerificationTokenError;
178
+ type authErrors_KeyExpiredError = KeyExpiredError;
179
+ declare const authErrors_KeyExpiredError: typeof KeyExpiredError;
180
+ type authErrors_TokenExpiredError = TokenExpiredError;
181
+ declare const authErrors_TokenExpiredError: typeof TokenExpiredError;
182
+ type authErrors_VerificationTokenPurposeMismatchError = VerificationTokenPurposeMismatchError;
183
+ declare const authErrors_VerificationTokenPurposeMismatchError: typeof VerificationTokenPurposeMismatchError;
184
+ type authErrors_VerificationTokenTargetMismatchError = VerificationTokenTargetMismatchError;
185
+ declare const authErrors_VerificationTokenTargetMismatchError: typeof VerificationTokenTargetMismatchError;
186
+ declare namespace authErrors {
187
+ export { authErrors_AccountAlreadyExistsError as AccountAlreadyExistsError, authErrors_AccountDisabledError as AccountDisabledError, authErrors_InsufficientPermissionsError as InsufficientPermissionsError, authErrors_InsufficientRoleError as InsufficientRoleError, authErrors_InvalidCredentialsError as InvalidCredentialsError, authErrors_InvalidKeyFingerprintError as InvalidKeyFingerprintError, authErrors_InvalidTokenError as InvalidTokenError, authErrors_InvalidVerificationCodeError as InvalidVerificationCodeError, authErrors_InvalidVerificationTokenError as InvalidVerificationTokenError, authErrors_KeyExpiredError as KeyExpiredError, authErrors_TokenExpiredError as TokenExpiredError, authErrors_VerificationTokenPurposeMismatchError as VerificationTokenPurposeMismatchError, authErrors_VerificationTokenTargetMismatchError as VerificationTokenTargetMismatchError };
188
+ }
189
+
190
+ /**
191
+ * Auth Error Exports
192
+ */
193
+
194
+ declare const authErrorRegistry: ErrorRegistry;
195
+
196
+ export { AccountAlreadyExistsError, AccountDisabledError, authErrors as AuthError, InsufficientPermissionsError, InsufficientRoleError, InvalidCredentialsError, InvalidKeyFingerprintError, InvalidTokenError, InvalidVerificationCodeError, InvalidVerificationTokenError, KeyExpiredError, TokenExpiredError, VerificationTokenPurposeMismatchError, VerificationTokenTargetMismatchError, authErrorRegistry };
package/dist/errors.js ADDED
@@ -0,0 +1,173 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/errors/index.ts
8
+ import { ErrorRegistry } from "@spfn/core/errors";
9
+
10
+ // src/errors/auth-errors.ts
11
+ var auth_errors_exports = {};
12
+ __export(auth_errors_exports, {
13
+ AccountAlreadyExistsError: () => AccountAlreadyExistsError,
14
+ AccountDisabledError: () => AccountDisabledError,
15
+ InsufficientPermissionsError: () => InsufficientPermissionsError,
16
+ InsufficientRoleError: () => InsufficientRoleError,
17
+ InvalidCredentialsError: () => InvalidCredentialsError,
18
+ InvalidKeyFingerprintError: () => InvalidKeyFingerprintError,
19
+ InvalidTokenError: () => InvalidTokenError,
20
+ InvalidVerificationCodeError: () => InvalidVerificationCodeError,
21
+ InvalidVerificationTokenError: () => InvalidVerificationTokenError,
22
+ KeyExpiredError: () => KeyExpiredError,
23
+ TokenExpiredError: () => TokenExpiredError,
24
+ VerificationTokenPurposeMismatchError: () => VerificationTokenPurposeMismatchError,
25
+ VerificationTokenTargetMismatchError: () => VerificationTokenTargetMismatchError
26
+ });
27
+ import {
28
+ ValidationError,
29
+ UnauthorizedError,
30
+ ForbiddenError,
31
+ ConflictError
32
+ } from "@spfn/core/errors";
33
+ var InvalidCredentialsError = class extends UnauthorizedError {
34
+ constructor(data = {}) {
35
+ super({ message: data.message || "Invalid credentials", details: data.details });
36
+ this.name = "InvalidCredentialsError";
37
+ }
38
+ };
39
+ var InvalidTokenError = class extends UnauthorizedError {
40
+ constructor(data = {}) {
41
+ super({ message: data.message || "Invalid authentication token", details: data.details });
42
+ this.name = "InvalidTokenError";
43
+ }
44
+ };
45
+ var TokenExpiredError = class extends UnauthorizedError {
46
+ constructor(data = {}) {
47
+ super({ message: data.message || "Authentication token has expired", details: data.details });
48
+ this.name = "TokenExpiredError";
49
+ }
50
+ };
51
+ var KeyExpiredError = class extends UnauthorizedError {
52
+ constructor(data = {}) {
53
+ super({ message: data.message || "Public key has expired", details: data.details });
54
+ this.name = "KeyExpiredError";
55
+ }
56
+ };
57
+ var AccountDisabledError = class extends ForbiddenError {
58
+ constructor(data = {}) {
59
+ const status = data.status || "disabled";
60
+ super({
61
+ message: data.message || `Account is ${status}`,
62
+ details: { status, ...data.details }
63
+ });
64
+ this.name = "AccountDisabledError";
65
+ }
66
+ };
67
+ var AccountAlreadyExistsError = class extends ConflictError {
68
+ constructor(data = {}) {
69
+ super({
70
+ message: data.message || "Account already exists",
71
+ details: {
72
+ identifier: data.identifier,
73
+ identifierType: data.identifierType,
74
+ ...data.details
75
+ }
76
+ });
77
+ this.name = "AccountAlreadyExistsError";
78
+ }
79
+ };
80
+ var InvalidVerificationCodeError = class extends ValidationError {
81
+ constructor(data = {}) {
82
+ super({ message: data.message || "Invalid verification code", details: data.details });
83
+ this.name = "InvalidVerificationCodeError";
84
+ }
85
+ };
86
+ var InvalidVerificationTokenError = class extends ValidationError {
87
+ constructor(data = {}) {
88
+ super({ message: data.message || "Invalid or expired verification token", details: data.details });
89
+ this.name = "InvalidVerificationTokenError";
90
+ }
91
+ };
92
+ var InvalidKeyFingerprintError = class extends ValidationError {
93
+ constructor(data = {}) {
94
+ super({ message: data.message || "Invalid key fingerprint", details: data.details });
95
+ this.name = "InvalidKeyFingerprintError";
96
+ }
97
+ };
98
+ var VerificationTokenPurposeMismatchError = class extends ValidationError {
99
+ constructor(data = {}) {
100
+ const expected = data.expected || "unknown";
101
+ const actual = data.actual || "unknown";
102
+ super({
103
+ message: data.message || `Verification token is for ${actual}, but ${expected} was expected`,
104
+ details: { expected, actual, ...data.details }
105
+ });
106
+ this.name = "VerificationTokenPurposeMismatchError";
107
+ }
108
+ };
109
+ var VerificationTokenTargetMismatchError = class extends ValidationError {
110
+ constructor(data = {}) {
111
+ super({
112
+ message: data.message || "Verification token does not match provided email/phone",
113
+ details: data.details
114
+ });
115
+ this.name = "VerificationTokenTargetMismatchError";
116
+ }
117
+ };
118
+ var InsufficientPermissionsError = class extends ForbiddenError {
119
+ constructor(data = {}) {
120
+ const requiredPermissions = data.requiredPermissions || [];
121
+ super({
122
+ message: data.message || `Missing required permissions: ${requiredPermissions.join(", ")}`,
123
+ details: { requiredPermissions, ...data.details }
124
+ });
125
+ this.name = "InsufficientPermissionsError";
126
+ }
127
+ };
128
+ var InsufficientRoleError = class extends ForbiddenError {
129
+ constructor(data = {}) {
130
+ const requiredRoles = data.requiredRoles || [];
131
+ super({
132
+ message: data.message || `Required roles: ${requiredRoles.join(", ")}`,
133
+ details: { requiredRoles, ...data.details }
134
+ });
135
+ this.name = "InsufficientRoleError";
136
+ }
137
+ };
138
+
139
+ // src/errors/index.ts
140
+ var authErrorRegistry = new ErrorRegistry();
141
+ authErrorRegistry.append([
142
+ InvalidCredentialsError,
143
+ InvalidTokenError,
144
+ TokenExpiredError,
145
+ KeyExpiredError,
146
+ AccountDisabledError,
147
+ AccountAlreadyExistsError,
148
+ InvalidVerificationCodeError,
149
+ InvalidVerificationTokenError,
150
+ InvalidKeyFingerprintError,
151
+ VerificationTokenPurposeMismatchError,
152
+ VerificationTokenTargetMismatchError,
153
+ InsufficientPermissionsError,
154
+ InsufficientRoleError
155
+ ]);
156
+ export {
157
+ AccountAlreadyExistsError,
158
+ AccountDisabledError,
159
+ auth_errors_exports as AuthError,
160
+ InsufficientPermissionsError,
161
+ InsufficientRoleError,
162
+ InvalidCredentialsError,
163
+ InvalidKeyFingerprintError,
164
+ InvalidTokenError,
165
+ InvalidVerificationCodeError,
166
+ InvalidVerificationTokenError,
167
+ KeyExpiredError,
168
+ TokenExpiredError,
169
+ VerificationTokenPurposeMismatchError,
170
+ VerificationTokenTargetMismatchError,
171
+ authErrorRegistry
172
+ };
173
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors/index.ts","../src/errors/auth-errors.ts"],"sourcesContent":["/**\n * Auth Error Exports\n */\n\nimport { ErrorRegistry } from \"@spfn/core/errors\";\n\nimport {\n InvalidCredentialsError,\n InvalidTokenError,\n TokenExpiredError,\n KeyExpiredError,\n AccountDisabledError,\n AccountAlreadyExistsError,\n InvalidVerificationCodeError,\n InvalidVerificationTokenError,\n InvalidKeyFingerprintError,\n VerificationTokenPurposeMismatchError,\n VerificationTokenTargetMismatchError,\n InsufficientPermissionsError,\n InsufficientRoleError,\n} from './auth-errors';\n\nexport {\n InvalidCredentialsError,\n InvalidTokenError,\n TokenExpiredError,\n KeyExpiredError,\n AccountDisabledError,\n AccountAlreadyExistsError,\n InvalidVerificationCodeError,\n InvalidVerificationTokenError,\n InvalidKeyFingerprintError,\n VerificationTokenPurposeMismatchError,\n VerificationTokenTargetMismatchError,\n InsufficientPermissionsError,\n InsufficientRoleError,\n} from './auth-errors';\n\nexport const authErrorRegistry = new ErrorRegistry();\nauthErrorRegistry.append([\n InvalidCredentialsError,\n InvalidTokenError,\n TokenExpiredError,\n KeyExpiredError,\n AccountDisabledError,\n AccountAlreadyExistsError,\n InvalidVerificationCodeError,\n InvalidVerificationTokenError,\n InvalidKeyFingerprintError,\n VerificationTokenPurposeMismatchError,\n VerificationTokenTargetMismatchError,\n InsufficientPermissionsError,\n InsufficientRoleError,\n]);\n\nexport * as AuthError from './auth-errors';","/**\n * Authentication & Authorization Error Classes\n *\n * Custom error classes for auth-specific scenarios\n */\n\nimport {\n ValidationError,\n UnauthorizedError,\n ForbiddenError,\n ConflictError\n} from '@spfn/core/errors';\n\n/**\n * Invalid Credentials Error (401)\n *\n * Thrown when login credentials are incorrect\n */\nexport class InvalidCredentialsError extends UnauthorizedError\n{\n constructor(data: { message?: string; details?: Record<string, any> } = {})\n {\n super({ message: data.message || 'Invalid credentials', details: data.details });\n this.name = 'InvalidCredentialsError';\n }\n}\n\n/**\n * Invalid Token Error (401)\n *\n * Thrown when authentication token is invalid or malformed\n */\nexport class InvalidTokenError extends UnauthorizedError\n{\n constructor(data: { message?: string; details?: Record<string, any> } = {})\n {\n super({ message: data.message || 'Invalid authentication token', details: data.details });\n this.name = 'InvalidTokenError';\n }\n}\n\n/**\n * Token Expired Error (401)\n *\n * Thrown when authentication token has expired\n */\nexport class TokenExpiredError extends UnauthorizedError\n{\n constructor(data: { message?: string; details?: Record<string, any> } = {})\n {\n super({ message: data.message || 'Authentication token has expired', details: data.details });\n this.name = 'TokenExpiredError';\n }\n}\n\n/**\n * Key Expired Error (401)\n *\n * Thrown when public key has expired\n */\nexport class KeyExpiredError extends UnauthorizedError\n{\n constructor(data: { message?: string; details?: Record<string, any> } = {})\n {\n super({ message: data.message || 'Public key has expired', details: data.details });\n this.name = 'KeyExpiredError';\n }\n}\n\n/**\n * Account Disabled Error (403)\n *\n * Thrown when user account is disabled or inactive\n */\nexport class AccountDisabledError extends ForbiddenError\n{\n constructor(data: { status?: string; message?: string; details?: Record<string, any> } = {})\n {\n const status = data.status || 'disabled';\n super({\n message: data.message || `Account is ${status}`,\n details: { status, ...data.details }\n });\n this.name = 'AccountDisabledError';\n }\n}\n\n/**\n * Account Already Exists Error (409)\n *\n * Thrown when trying to register with existing email/phone\n */\nexport class AccountAlreadyExistsError extends ConflictError\n{\n constructor(data: { identifier?: string; identifierType?: 'email' | 'phone'; message?: string; details?: Record<string, any> } = {})\n {\n super({\n message: data.message || 'Account already exists',\n details: {\n identifier: data.identifier,\n identifierType: data.identifierType,\n ...data.details\n }\n });\n this.name = 'AccountAlreadyExistsError';\n }\n}\n\n/**\n * Invalid Verification Code Error (400)\n *\n * Thrown when verification code is invalid, expired, or already used\n */\nexport class InvalidVerificationCodeError extends ValidationError\n{\n constructor(data: { message?: string; details?: Record<string, any> } = {})\n {\n super({ message: data.message || 'Invalid verification code', details: data.details });\n this.name = 'InvalidVerificationCodeError';\n }\n}\n\n/**\n * Invalid Verification Token Error (400)\n *\n * Thrown when verification token is invalid or expired\n */\nexport class InvalidVerificationTokenError extends ValidationError\n{\n constructor(data: { message?: string; details?: Record<string, any> } = {})\n {\n super({ message: data.message || 'Invalid or expired verification token', details: data.details });\n this.name = 'InvalidVerificationTokenError';\n }\n}\n\n/**\n * Invalid Key Fingerprint Error (400)\n *\n * Thrown when public key fingerprint doesn't match the public key\n */\nexport class InvalidKeyFingerprintError extends ValidationError\n{\n constructor(data: { message?: string; details?: Record<string, any> } = {})\n {\n super({ message: data.message || 'Invalid key fingerprint', details: data.details });\n this.name = 'InvalidKeyFingerprintError';\n }\n}\n\n/**\n * Verification Token Purpose Mismatch Error (400)\n *\n * Thrown when verification token purpose doesn't match expected purpose\n */\nexport class VerificationTokenPurposeMismatchError extends ValidationError\n{\n constructor(data: { expected?: string; actual?: string; message?: string; details?: Record<string, any> } = {})\n {\n const expected = data.expected || 'unknown';\n const actual = data.actual || 'unknown';\n super({\n message: data.message || `Verification token is for ${actual}, but ${expected} was expected`,\n details: { expected, actual, ...data.details }\n });\n this.name = 'VerificationTokenPurposeMismatchError';\n }\n}\n\n/**\n * Verification Token Target Mismatch Error (400)\n *\n * Thrown when verification token target doesn't match provided email/phone\n */\nexport class VerificationTokenTargetMismatchError extends ValidationError\n{\n constructor(data: { message?: string; details?: Record<string, any> } = {})\n {\n super({\n message: data.message || 'Verification token does not match provided email/phone',\n details: data.details\n });\n this.name = 'VerificationTokenTargetMismatchError';\n }\n}\n\n/**\n * Insufficient Permissions Error (403)\n *\n * Thrown when user lacks required permissions for the operation\n */\nexport class InsufficientPermissionsError extends ForbiddenError\n{\n constructor(data: { requiredPermissions?: string[]; message?: string; details?: Record<string, any> } = {})\n {\n const requiredPermissions = data.requiredPermissions || [];\n super({\n message: data.message || `Missing required permissions: ${requiredPermissions.join(', ')}`,\n details: { requiredPermissions, ...data.details }\n });\n this.name = 'InsufficientPermissionsError';\n }\n}\n\n/**\n * Insufficient Role Error (403)\n *\n * Thrown when user lacks required role for the operation\n */\nexport class InsufficientRoleError extends ForbiddenError\n{\n constructor(data: { requiredRoles?: string[]; message?: string; details?: Record<string, any> } = {})\n {\n const requiredRoles = data.requiredRoles || [];\n super({\n message: data.message || `Required roles: ${requiredRoles.join(', ')}`,\n details: { requiredRoles, ...data.details }\n });\n this.name = 'InsufficientRoleError';\n }\n}"],"mappings":";;;;;;;AAIA,SAAS,qBAAqB;;;ACJ9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAOA,IAAM,0BAAN,cAAsC,kBAC7C;AAAA,EACI,YAAY,OAA4D,CAAC,GACzE;AACI,UAAM,EAAE,SAAS,KAAK,WAAW,uBAAuB,SAAS,KAAK,QAAQ,CAAC;AAC/E,SAAK,OAAO;AAAA,EAChB;AACJ;AAOO,IAAM,oBAAN,cAAgC,kBACvC;AAAA,EACI,YAAY,OAA4D,CAAC,GACzE;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