@spfn/auth 0.1.0-alpha.88 → 0.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1385 -1199
- package/dist/config.d.ts +405 -0
- package/dist/config.js +240 -0
- package/dist/config.js.map +1 -0
- package/dist/dto-CLYtuAom.d.ts +630 -0
- package/dist/errors.d.ts +196 -0
- package/dist/errors.js +173 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +273 -14
- package/dist/index.js +511 -6665
- package/dist/index.js.map +1 -1
- package/dist/nextjs/api.js +345 -0
- package/dist/nextjs/api.js.map +1 -0
- package/dist/{adapters/nextjs → nextjs}/server.d.ts +47 -65
- package/dist/nextjs/server.js +179 -0
- package/dist/nextjs/server.js.map +1 -0
- package/dist/server.d.ts +4328 -529
- package/dist/server.js +7841 -1247
- package/dist/server.js.map +1 -1
- package/migrations/{0000_skinny_christian_walker.sql → 0000_marvelous_justice.sql} +53 -23
- package/migrations/meta/0000_snapshot.json +281 -46
- package/migrations/meta/_journal.json +2 -2
- package/package.json +31 -31
- package/dist/adapters/nextjs/api.d.ts +0 -446
- package/dist/adapters/nextjs/api.js +0 -3279
- package/dist/adapters/nextjs/api.js.map +0 -1
- package/dist/adapters/nextjs/server.js +0 -3645
- package/dist/adapters/nextjs/server.js.map +0 -1
- package/dist/lib/api/auth-codes-verify.d.ts +0 -37
- package/dist/lib/api/auth-codes-verify.js +0 -2949
- package/dist/lib/api/auth-codes-verify.js.map +0 -1
- package/dist/lib/api/auth-codes.d.ts +0 -37
- package/dist/lib/api/auth-codes.js +0 -2949
- package/dist/lib/api/auth-codes.js.map +0 -1
- package/dist/lib/api/auth-exists.d.ts +0 -38
- package/dist/lib/api/auth-exists.js +0 -2949
- package/dist/lib/api/auth-exists.js.map +0 -1
- package/dist/lib/api/auth-invitations-accept.d.ts +0 -38
- package/dist/lib/api/auth-invitations-accept.js +0 -2883
- package/dist/lib/api/auth-invitations-accept.js.map +0 -1
- package/dist/lib/api/auth-invitations-cancel.d.ts +0 -37
- package/dist/lib/api/auth-invitations-cancel.js +0 -2883
- package/dist/lib/api/auth-invitations-cancel.js.map +0 -1
- package/dist/lib/api/auth-invitations-delete.d.ts +0 -36
- package/dist/lib/api/auth-invitations-delete.js +0 -2883
- package/dist/lib/api/auth-invitations-delete.js.map +0 -1
- package/dist/lib/api/auth-invitations-resend.d.ts +0 -37
- package/dist/lib/api/auth-invitations-resend.js +0 -2883
- package/dist/lib/api/auth-invitations-resend.js.map +0 -1
- package/dist/lib/api/auth-invitations.d.ts +0 -109
- package/dist/lib/api/auth-invitations.js +0 -2887
- package/dist/lib/api/auth-invitations.js.map +0 -1
- package/dist/lib/api/auth-keys-rotate.d.ts +0 -37
- package/dist/lib/api/auth-keys-rotate.js +0 -2949
- package/dist/lib/api/auth-keys-rotate.js.map +0 -1
- package/dist/lib/api/auth-login.d.ts +0 -39
- package/dist/lib/api/auth-login.js +0 -2949
- package/dist/lib/api/auth-login.js.map +0 -1
- package/dist/lib/api/auth-logout.d.ts +0 -36
- package/dist/lib/api/auth-logout.js +0 -2949
- package/dist/lib/api/auth-logout.js.map +0 -1
- package/dist/lib/api/auth-me.d.ts +0 -50
- package/dist/lib/api/auth-me.js +0 -2949
- package/dist/lib/api/auth-me.js.map +0 -1
- package/dist/lib/api/auth-password.d.ts +0 -36
- package/dist/lib/api/auth-password.js +0 -2949
- package/dist/lib/api/auth-password.js.map +0 -1
- package/dist/lib/api/auth-register.d.ts +0 -38
- package/dist/lib/api/auth-register.js +0 -2949
- package/dist/lib/api/auth-register.js.map +0 -1
- package/dist/lib/api/index.d.ts +0 -356
- package/dist/lib/api/index.js +0 -3261
- package/dist/lib/api/index.js.map +0 -1
- package/dist/lib/config.d.ts +0 -70
- package/dist/lib/config.js +0 -64
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/contracts/auth.d.ts +0 -302
- package/dist/lib/contracts/auth.js +0 -2951
- package/dist/lib/contracts/auth.js.map +0 -1
- package/dist/lib/contracts/index.d.ts +0 -3
- package/dist/lib/contracts/index.js +0 -3190
- package/dist/lib/contracts/index.js.map +0 -1
- package/dist/lib/contracts/invitation.d.ts +0 -243
- package/dist/lib/contracts/invitation.js +0 -2883
- package/dist/lib/contracts/invitation.js.map +0 -1
- package/dist/lib/crypto.d.ts +0 -76
- package/dist/lib/crypto.js +0 -127
- package/dist/lib/crypto.js.map +0 -1
- package/dist/lib/index.d.ts +0 -4
- package/dist/lib/index.js +0 -313
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/session.d.ts +0 -68
- package/dist/lib/session.js +0 -126
- package/dist/lib/session.js.map +0 -1
- package/dist/lib/types/api.d.ts +0 -45
- package/dist/lib/types/api.js +0 -1
- package/dist/lib/types/api.js.map +0 -1
- package/dist/lib/types/index.d.ts +0 -3
- package/dist/lib/types/index.js +0 -2647
- package/dist/lib/types/index.js.map +0 -1
- package/dist/lib/types/schemas.d.ts +0 -45
- package/dist/lib/types/schemas.js +0 -2647
- package/dist/lib/types/schemas.js.map +0 -1
- package/dist/lib.js +0 -1
- package/dist/lib.js.map +0 -1
- package/dist/plugin.d.ts +0 -12
- package/dist/plugin.js +0 -9083
- package/dist/plugin.js.map +0 -1
- package/dist/server/entities/index.d.ts +0 -11
- package/dist/server/entities/index.js +0 -395
- package/dist/server/entities/index.js.map +0 -1
- package/dist/server/entities/invitations.d.ts +0 -241
- package/dist/server/entities/invitations.js +0 -184
- package/dist/server/entities/invitations.js.map +0 -1
- package/dist/server/entities/permissions.d.ts +0 -196
- package/dist/server/entities/permissions.js +0 -49
- package/dist/server/entities/permissions.js.map +0 -1
- package/dist/server/entities/role-permissions.d.ts +0 -107
- package/dist/server/entities/role-permissions.js +0 -115
- package/dist/server/entities/role-permissions.js.map +0 -1
- package/dist/server/entities/roles.d.ts +0 -196
- package/dist/server/entities/roles.js +0 -50
- package/dist/server/entities/roles.js.map +0 -1
- package/dist/server/entities/schema.d.ts +0 -14
- package/dist/server/entities/schema.js +0 -7
- package/dist/server/entities/schema.js.map +0 -1
- package/dist/server/entities/user-permissions.d.ts +0 -163
- package/dist/server/entities/user-permissions.js +0 -193
- package/dist/server/entities/user-permissions.js.map +0 -1
- package/dist/server/entities/user-public-keys.d.ts +0 -227
- package/dist/server/entities/user-public-keys.js +0 -156
- package/dist/server/entities/user-public-keys.js.map +0 -1
- package/dist/server/entities/user-social-accounts.d.ts +0 -189
- package/dist/server/entities/user-social-accounts.js +0 -149
- package/dist/server/entities/user-social-accounts.js.map +0 -1
- package/dist/server/entities/users.d.ts +0 -235
- package/dist/server/entities/users.js +0 -117
- package/dist/server/entities/users.js.map +0 -1
- package/dist/server/entities/verification-codes.d.ts +0 -191
- package/dist/server/entities/verification-codes.js +0 -49
- package/dist/server/entities/verification-codes.js.map +0 -1
- package/dist/server/routes/auth/index.d.ts +0 -10
- package/dist/server/routes/auth/index.js +0 -4460
- package/dist/server/routes/auth/index.js.map +0 -1
- package/dist/server/routes/index.d.ts +0 -6
- package/dist/server/routes/index.js +0 -6584
- package/dist/server/routes/index.js.map +0 -1
- package/dist/server/routes/invitations/index.d.ts +0 -10
- package/dist/server/routes/invitations/index.js +0 -4395
- package/dist/server/routes/invitations/index.js.map +0 -1
- /package/dist/{lib.d.ts → nextjs/api.d.ts} +0 -0
package/dist/errors.d.ts
ADDED
|
@@ -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":"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","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,273 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import * as _spfn_core_nextjs from '@spfn/core/nextjs';
|
|
2
|
+
import { R as RoleConfig, P as PermissionConfig, U as UserProfile, C as CheckAccountExistsResult, S as SendVerificationCodeResult, a as RegisterResult, L as LoginResult, b as RotateKeyResult, m as mainAuthRouter } from './dto-CLYtuAom.js';
|
|
3
|
+
export { k as AuthInitOptions, A as AuthSession, I as INVITATION_STATUSES, n as InvitationStatus, K as KEY_ALGORITHM, l as KeyAlgorithmType, i as PERMISSION_CATEGORIES, j as PermissionCategory, c as ProfileInfo, e as SOCIAL_PROVIDERS, p as SocialProvider, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, f as VerificationPurpose, V as VerificationTargetType } from './dto-CLYtuAom.js';
|
|
4
|
+
import * as _spfn_core_route from '@spfn/core/route';
|
|
5
|
+
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
6
|
+
import '@spfn/auth/server';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @spfn/auth - Built-in Roles and Permissions
|
|
10
|
+
*
|
|
11
|
+
* Core roles and permissions required by the auth package
|
|
12
|
+
* These cannot be deleted and are automatically created on initialization
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Built-in roles (required by package)
|
|
17
|
+
* These roles are always created and cannot be deleted
|
|
18
|
+
*/
|
|
19
|
+
declare const BUILTIN_ROLES: Record<string, RoleConfig>;
|
|
20
|
+
/**
|
|
21
|
+
* Built-in permissions (required by package)
|
|
22
|
+
* These permissions are always created and cannot be deleted
|
|
23
|
+
*/
|
|
24
|
+
declare const BUILTIN_PERMISSIONS: Record<string, PermissionConfig>;
|
|
25
|
+
/**
|
|
26
|
+
* Built-in role-permission mappings
|
|
27
|
+
* Defines default permissions for each built-in role
|
|
28
|
+
*/
|
|
29
|
+
declare const BUILTIN_ROLE_PERMISSIONS: Record<string, string[]>;
|
|
30
|
+
type BuiltinRoleName = keyof typeof BUILTIN_ROLE_PERMISSIONS;
|
|
31
|
+
type BuiltinPermissionName = typeof BUILTIN_PERMISSIONS[keyof typeof BUILTIN_PERMISSIONS]['name'];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Email regex pattern (RFC 5322 compliant)
|
|
35
|
+
* Validates: local-part@domain.tld
|
|
36
|
+
* - Local part: alphanumeric, dots, hyphens, underscores
|
|
37
|
+
* - Domain: alphanumeric, hyphens, dots
|
|
38
|
+
* - TLD: minimum 2 characters
|
|
39
|
+
*/
|
|
40
|
+
declare const EMAIL_PATTERN = "^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
|
|
41
|
+
/**
|
|
42
|
+
* Phone regex pattern (E.164 format)
|
|
43
|
+
* Format: +[country code][number] (1-15 digits total)
|
|
44
|
+
*/
|
|
45
|
+
declare const PHONE_PATTERN = "^\\+[1-9]\\d{1,14}$";
|
|
46
|
+
/**
|
|
47
|
+
* SHA-256 fingerprint pattern (64 hex characters)
|
|
48
|
+
*/
|
|
49
|
+
declare const FINGERPRINT_PATTERN = "^[a-f0-9]{64}$";
|
|
50
|
+
/**
|
|
51
|
+
* UUID v4 pattern (8-4-4-4-12 format)
|
|
52
|
+
*/
|
|
53
|
+
declare const UUID_PATTERN = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
|
|
54
|
+
/**
|
|
55
|
+
* Base64 pattern (DER encoded keys)
|
|
56
|
+
* Matches standard Base64 with padding
|
|
57
|
+
*/
|
|
58
|
+
declare const BASE64_PATTERN = "^[A-Za-z0-9+/]+=*$";
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Type-safe API client for auth routes
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import { authApi } from '@spfn/auth';
|
|
66
|
+
*
|
|
67
|
+
* // Get current session
|
|
68
|
+
* const session = await authApi.getAuthSession.call({});
|
|
69
|
+
*
|
|
70
|
+
* // Login
|
|
71
|
+
* const result = await authApi.login.call({
|
|
72
|
+
* body: { email, password, fingerprint, publicKey, keyId }
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare const authApi: _spfn_core_nextjs.Client<_spfn_core_route.Router<{
|
|
77
|
+
getUserProfile: _spfn_core_route.RouteDef<{}, {}, UserProfile>;
|
|
78
|
+
getInvitation: _spfn_core_route.RouteDef<{
|
|
79
|
+
params: _sinclair_typebox.TObject<{
|
|
80
|
+
token: _sinclair_typebox.TString;
|
|
81
|
+
}>;
|
|
82
|
+
}, {}, {
|
|
83
|
+
email: string;
|
|
84
|
+
role: string;
|
|
85
|
+
roleDisplayName: string;
|
|
86
|
+
invitedBy: string;
|
|
87
|
+
expiresAt: string;
|
|
88
|
+
metadata: Record<string, any> | undefined;
|
|
89
|
+
}>;
|
|
90
|
+
acceptInvitation: _spfn_core_route.RouteDef<{
|
|
91
|
+
body: _sinclair_typebox.TObject<{
|
|
92
|
+
token: _sinclair_typebox.TString;
|
|
93
|
+
password: _sinclair_typebox.TString;
|
|
94
|
+
}>;
|
|
95
|
+
}, {
|
|
96
|
+
body: _sinclair_typebox.TObject<{
|
|
97
|
+
publicKey: _sinclair_typebox.TString;
|
|
98
|
+
keyId: _sinclair_typebox.TString;
|
|
99
|
+
fingerprint: _sinclair_typebox.TString;
|
|
100
|
+
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
101
|
+
}>;
|
|
102
|
+
}, {
|
|
103
|
+
userId: number;
|
|
104
|
+
email: string;
|
|
105
|
+
role: string;
|
|
106
|
+
}>;
|
|
107
|
+
createInvitation: _spfn_core_route.RouteDef<{
|
|
108
|
+
body: _sinclair_typebox.TObject<{
|
|
109
|
+
email: _sinclair_typebox.TString;
|
|
110
|
+
roleId: _sinclair_typebox.TNumber;
|
|
111
|
+
expiresInDays: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
112
|
+
metadata: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
113
|
+
}>;
|
|
114
|
+
}, {}, {
|
|
115
|
+
id: number;
|
|
116
|
+
email: string;
|
|
117
|
+
token: string;
|
|
118
|
+
roleId: number;
|
|
119
|
+
expiresAt: string;
|
|
120
|
+
invitationUrl: string;
|
|
121
|
+
}>;
|
|
122
|
+
listInvitations: _spfn_core_route.RouteDef<{
|
|
123
|
+
query: _sinclair_typebox.TObject<{
|
|
124
|
+
status: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"pending" | "accepted" | "expired" | "cancelled">[]>>;
|
|
125
|
+
page: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
126
|
+
limit: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
127
|
+
}>;
|
|
128
|
+
}, {}, {
|
|
129
|
+
invitations: {
|
|
130
|
+
id: number;
|
|
131
|
+
email: string;
|
|
132
|
+
token: string;
|
|
133
|
+
roleId: number;
|
|
134
|
+
invitedBy: number;
|
|
135
|
+
status: "pending" | "accepted" | "expired" | "cancelled";
|
|
136
|
+
expiresAt: Date;
|
|
137
|
+
acceptedAt: Date | null;
|
|
138
|
+
cancelledAt: Date | null;
|
|
139
|
+
metadata: Record<string, any> | null;
|
|
140
|
+
createdAt: Date;
|
|
141
|
+
updatedAt: Date;
|
|
142
|
+
role: {
|
|
143
|
+
id: number;
|
|
144
|
+
name: string;
|
|
145
|
+
displayName: string;
|
|
146
|
+
};
|
|
147
|
+
inviter: {
|
|
148
|
+
id: number;
|
|
149
|
+
email: string | null;
|
|
150
|
+
};
|
|
151
|
+
}[];
|
|
152
|
+
total: number;
|
|
153
|
+
page: number;
|
|
154
|
+
limit: number;
|
|
155
|
+
totalPages: number;
|
|
156
|
+
}>;
|
|
157
|
+
cancelInvitation: _spfn_core_route.RouteDef<{
|
|
158
|
+
body: _sinclair_typebox.TObject<{
|
|
159
|
+
id: _sinclair_typebox.TNumber;
|
|
160
|
+
reason: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
161
|
+
}>;
|
|
162
|
+
}, {}, {
|
|
163
|
+
cancelledAt: string;
|
|
164
|
+
}>;
|
|
165
|
+
resendInvitation: _spfn_core_route.RouteDef<{
|
|
166
|
+
body: _sinclair_typebox.TObject<{
|
|
167
|
+
id: _sinclair_typebox.TNumber;
|
|
168
|
+
expiresInDays: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
169
|
+
}>;
|
|
170
|
+
}, {}, {
|
|
171
|
+
expiresAt: string;
|
|
172
|
+
}>;
|
|
173
|
+
deleteInvitation: _spfn_core_route.RouteDef<{
|
|
174
|
+
body: _sinclair_typebox.TObject<{
|
|
175
|
+
id: _sinclair_typebox.TNumber;
|
|
176
|
+
}>;
|
|
177
|
+
}, {}, Response>;
|
|
178
|
+
checkAccountExists: _spfn_core_route.RouteDef<{
|
|
179
|
+
body: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
180
|
+
email: _sinclair_typebox.TString;
|
|
181
|
+
}>, _sinclair_typebox.TObject<{
|
|
182
|
+
phone: _sinclair_typebox.TString;
|
|
183
|
+
}>]>;
|
|
184
|
+
}, {}, CheckAccountExistsResult>;
|
|
185
|
+
sendVerificationCode: _spfn_core_route.RouteDef<{
|
|
186
|
+
body: _sinclair_typebox.TObject<{
|
|
187
|
+
target: _sinclair_typebox.TString;
|
|
188
|
+
targetType: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"email">, _sinclair_typebox.TLiteral<"phone">]>;
|
|
189
|
+
purpose: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"registration">, _sinclair_typebox.TLiteral<"login">, _sinclair_typebox.TLiteral<"password_reset">, _sinclair_typebox.TLiteral<"email_change">, _sinclair_typebox.TLiteral<"phone_change">]>;
|
|
190
|
+
}>;
|
|
191
|
+
}, {}, SendVerificationCodeResult>;
|
|
192
|
+
verifyCode: _spfn_core_route.RouteDef<{
|
|
193
|
+
body: _sinclair_typebox.TObject<{
|
|
194
|
+
target: _sinclair_typebox.TString;
|
|
195
|
+
targetType: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"email">, _sinclair_typebox.TLiteral<"phone">]>;
|
|
196
|
+
code: _sinclair_typebox.TString;
|
|
197
|
+
purpose: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"registration">, _sinclair_typebox.TLiteral<"login">, _sinclair_typebox.TLiteral<"password_reset">, _sinclair_typebox.TLiteral<"email_change">, _sinclair_typebox.TLiteral<"phone_change">]>;
|
|
198
|
+
}>;
|
|
199
|
+
}, {}, {
|
|
200
|
+
valid: boolean;
|
|
201
|
+
verificationToken: string;
|
|
202
|
+
}>;
|
|
203
|
+
register: _spfn_core_route.RouteDef<{
|
|
204
|
+
body: _sinclair_typebox.TObject<{
|
|
205
|
+
email: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
206
|
+
phone: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
207
|
+
verificationToken: _sinclair_typebox.TString;
|
|
208
|
+
password: _sinclair_typebox.TString;
|
|
209
|
+
}>;
|
|
210
|
+
}, {
|
|
211
|
+
body: _sinclair_typebox.TObject<{
|
|
212
|
+
publicKey: _sinclair_typebox.TString;
|
|
213
|
+
keyId: _sinclair_typebox.TString;
|
|
214
|
+
fingerprint: _sinclair_typebox.TString;
|
|
215
|
+
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
216
|
+
}>;
|
|
217
|
+
}, RegisterResult>;
|
|
218
|
+
login: _spfn_core_route.RouteDef<{
|
|
219
|
+
body: _sinclair_typebox.TObject<{
|
|
220
|
+
email: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
221
|
+
phone: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
222
|
+
password: _sinclair_typebox.TString;
|
|
223
|
+
}>;
|
|
224
|
+
}, {
|
|
225
|
+
body: _sinclair_typebox.TObject<{
|
|
226
|
+
publicKey: _sinclair_typebox.TString;
|
|
227
|
+
keyId: _sinclair_typebox.TString;
|
|
228
|
+
fingerprint: _sinclair_typebox.TString;
|
|
229
|
+
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
230
|
+
oldKeyId: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
231
|
+
}>;
|
|
232
|
+
}, LoginResult>;
|
|
233
|
+
logout: _spfn_core_route.RouteDef<{
|
|
234
|
+
body: _sinclair_typebox.TObject<{}>;
|
|
235
|
+
}, {}, Response>;
|
|
236
|
+
rotateKey: _spfn_core_route.RouteDef<{
|
|
237
|
+
body: _sinclair_typebox.TObject<{}>;
|
|
238
|
+
}, {
|
|
239
|
+
body: _sinclair_typebox.TObject<{
|
|
240
|
+
publicKey: _sinclair_typebox.TString;
|
|
241
|
+
keyId: _sinclair_typebox.TString;
|
|
242
|
+
fingerprint: _sinclair_typebox.TString;
|
|
243
|
+
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
244
|
+
}>;
|
|
245
|
+
}, RotateKeyResult>;
|
|
246
|
+
changePassword: _spfn_core_route.RouteDef<{
|
|
247
|
+
body: _sinclair_typebox.TObject<{
|
|
248
|
+
currentPassword: _sinclair_typebox.TString;
|
|
249
|
+
newPassword: _sinclair_typebox.TString;
|
|
250
|
+
}>;
|
|
251
|
+
}, {}, Response>;
|
|
252
|
+
getAuthSession: _spfn_core_route.RouteDef<{}, {}, {
|
|
253
|
+
role: {
|
|
254
|
+
id: number;
|
|
255
|
+
name: string;
|
|
256
|
+
displayName: string;
|
|
257
|
+
priority: number;
|
|
258
|
+
};
|
|
259
|
+
permissions: {
|
|
260
|
+
id: number;
|
|
261
|
+
name: string;
|
|
262
|
+
displayName: string;
|
|
263
|
+
category: "auth" | "custom" | "user" | "rbac" | "system" | undefined;
|
|
264
|
+
}[];
|
|
265
|
+
userId: number;
|
|
266
|
+
email: string | null;
|
|
267
|
+
emailVerified: boolean;
|
|
268
|
+
phoneVerified: boolean;
|
|
269
|
+
}>;
|
|
270
|
+
}>>;
|
|
271
|
+
type AuthRouter = typeof mainAuthRouter;
|
|
272
|
+
|
|
273
|
+
export { type AuthRouter, BASE64_PATTERN, BUILTIN_PERMISSIONS, BUILTIN_ROLES, BUILTIN_ROLE_PERMISSIONS, type BuiltinPermissionName, type BuiltinRoleName, EMAIL_PATTERN, FINGERPRINT_PATTERN, PHONE_PATTERN, PermissionConfig, RoleConfig, UUID_PATTERN, UserProfile, authApi };
|