@spfn/auth 0.2.1 → 0.3.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/LICENSE +1 -1
- package/README.md +1091 -2385
- package/dist/authenticate-55LeXHqZ.d.ts +1447 -0
- package/dist/client-proof.d.ts +606 -0
- package/dist/client-proof.js +1842 -0
- package/dist/client-proof.js.map +1 -0
- package/dist/config.d.ts +319 -3
- package/dist/config.js +155 -5
- package/dist/config.js.map +1 -1
- package/dist/crypto.d.ts +61 -0
- package/dist/crypto.js +108 -0
- package/dist/crypto.js.map +1 -0
- package/dist/errors.d.ts +180 -3
- package/dist/errors.js +116 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +166 -18
- package/dist/index.js +132 -8
- package/dist/index.js.map +1 -1
- package/dist/nextjs/api.js +404 -96
- package/dist/nextjs/api.js.map +1 -1
- package/dist/nextjs/server.d.ts +5 -4
- package/dist/nextjs/server.js +165 -26
- package/dist/nextjs/server.js.map +1 -1
- package/dist/server.d.ts +2356 -1053
- package/dist/server.js +5153 -736
- package/dist/server.js.map +1 -1
- package/dist/session-DTHahDQ9.d.ts +53 -0
- package/dist/types-DYyhze28.d.ts +98 -0
- package/dist/wire-version-CtzMKvBB.d.ts +134 -0
- package/migrations/20251125021229_premium_famine/snapshot.json +2641 -0
- package/migrations/20260225130050_smooth_the_fury/snapshot.json +2686 -0
- package/migrations/20260308141417_deep_iceman/snapshot.json +2686 -0
- package/migrations/20260308151309_perfect_deathbird/snapshot.json +2731 -0
- package/migrations/20260308201135_concerned_rawhide_kid/snapshot.json +2786 -0
- package/migrations/20260629103209_lethal_lifeguard/migration.sql +32 -0
- package/migrations/20260629103209_lethal_lifeguard/snapshot.json +2786 -0
- package/migrations/20260709073531_easy_hardball/migration.sql +24 -0
- package/migrations/20260709073531_easy_hardball/snapshot.json +3119 -0
- package/migrations/20260714081434_glossy_major_mapleleaf/migration.sql +1 -0
- package/migrations/20260714081434_glossy_major_mapleleaf/snapshot.json +3112 -0
- package/migrations/20260804105939_amazing_bushwacker/migration.sql +3 -0
- package/migrations/20260804105939_amazing_bushwacker/snapshot.json +3112 -0
- package/migrations/20260804110033_fat_piledriver/migration.sql +2 -0
- package/migrations/20260804110033_fat_piledriver/snapshot.json +3138 -0
- package/migrations/20260805143152_vengeful_ravenous/migration.sql +4 -0
- package/migrations/20260805143152_vengeful_ravenous/snapshot.json +3190 -0
- package/migrations/20260807145911_mixed_invisible_woman/migration.sql +11 -0
- package/migrations/20260807145911_mixed_invisible_woman/snapshot.json +3334 -0
- package/package.json +59 -40
- package/dist/authenticate-eucncHxN.d.ts +0 -940
- package/migrations/meta/0000_snapshot.json +0 -1632
- package/migrations/meta/0001_snapshot.json +0 -1660
- package/migrations/meta/0002_snapshot.json +0 -1660
- package/migrations/meta/0003_snapshot.json +0 -1689
- package/migrations/meta/0004_snapshot.json +0 -1721
- package/migrations/meta/_journal.json +0 -41
- /package/migrations/{0000_premium_famine.sql → 20251125021229_premium_famine/migration.sql} +0 -0
- /package/migrations/{0001_smooth_the_fury.sql → 20260225130050_smooth_the_fury/migration.sql} +0 -0
- /package/migrations/{0002_deep_iceman.sql → 20260308141417_deep_iceman/migration.sql} +0 -0
- /package/migrations/{0003_perfect_deathbird.sql → 20260308151309_perfect_deathbird/migration.sql} +0 -0
- /package/migrations/{0004_concerned_rawhide_kid.sql → 20260308201135_concerned_rawhide_kid/migration.sql} +0 -0
|
@@ -1,940 +0,0 @@
|
|
|
1
|
-
import * as _spfn_core_route from '@spfn/core/route';
|
|
2
|
-
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
3
|
-
import { Static } from '@sinclair/typebox';
|
|
4
|
-
import { User } from '@spfn/auth/server';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Role information for client/API responses
|
|
8
|
-
*/
|
|
9
|
-
interface Role {
|
|
10
|
-
id: number;
|
|
11
|
-
name: string;
|
|
12
|
-
displayName: string;
|
|
13
|
-
description: string | null;
|
|
14
|
-
isBuiltin: boolean;
|
|
15
|
-
isSystem: boolean;
|
|
16
|
-
isActive: boolean;
|
|
17
|
-
priority: number;
|
|
18
|
-
createdAt: Date;
|
|
19
|
-
updatedAt: Date;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Permission information for client/API responses
|
|
23
|
-
*/
|
|
24
|
-
interface Permission {
|
|
25
|
-
id: number;
|
|
26
|
-
name: string;
|
|
27
|
-
displayName: string;
|
|
28
|
-
description: string | null;
|
|
29
|
-
category: string | null;
|
|
30
|
-
isBuiltin: boolean;
|
|
31
|
-
isSystem: boolean;
|
|
32
|
-
isActive: boolean;
|
|
33
|
-
metadata: Record<string, any> | null;
|
|
34
|
-
createdAt: Date;
|
|
35
|
-
updatedAt: Date;
|
|
36
|
-
}
|
|
37
|
-
interface AuthSession {
|
|
38
|
-
userId: number;
|
|
39
|
-
publicId: string;
|
|
40
|
-
email: string | null;
|
|
41
|
-
emailVerified: boolean;
|
|
42
|
-
phoneVerified: boolean;
|
|
43
|
-
role: Role;
|
|
44
|
-
permissions: Permission[];
|
|
45
|
-
}
|
|
46
|
-
interface ProfileInfo {
|
|
47
|
-
profileId: number;
|
|
48
|
-
displayName: string | null;
|
|
49
|
-
firstName: string | null;
|
|
50
|
-
lastName: string | null;
|
|
51
|
-
avatarUrl: string | null;
|
|
52
|
-
bio: string | null;
|
|
53
|
-
locale: string;
|
|
54
|
-
timezone: string;
|
|
55
|
-
website: string | null;
|
|
56
|
-
location: string | null;
|
|
57
|
-
company: string | null;
|
|
58
|
-
jobTitle: string | null;
|
|
59
|
-
metadata: Record<string, any> | null;
|
|
60
|
-
createdAt: Date;
|
|
61
|
-
updatedAt: Date;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* User Profile Response
|
|
65
|
-
*
|
|
66
|
-
* Complete user data including:
|
|
67
|
-
* - User fields at top level (userId, email, etc.)
|
|
68
|
-
* - Profile data as nested field (optional)
|
|
69
|
-
*
|
|
70
|
-
* Excludes:
|
|
71
|
-
* - Role and permissions (use auth session API)
|
|
72
|
-
*/
|
|
73
|
-
interface UserProfile {
|
|
74
|
-
userId: number;
|
|
75
|
-
publicId: string;
|
|
76
|
-
email: string | null;
|
|
77
|
-
username: string | null;
|
|
78
|
-
emailVerified: boolean;
|
|
79
|
-
phoneVerified: boolean;
|
|
80
|
-
lastLoginAt: Date | null;
|
|
81
|
-
createdAt: Date;
|
|
82
|
-
updatedAt: Date;
|
|
83
|
-
profile: ProfileInfo | null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @spfn/auth - Shared Types
|
|
88
|
-
*
|
|
89
|
-
* Common types and constants used across the auth package
|
|
90
|
-
*/
|
|
91
|
-
/**
|
|
92
|
-
* Supported JWT signature algorithms
|
|
93
|
-
*
|
|
94
|
-
* - ES256: ECDSA with P-256 and SHA-256 (recommended, smaller keys)
|
|
95
|
-
* - RS256: RSA with SHA-256 (fallback, larger keys)
|
|
96
|
-
*/
|
|
97
|
-
declare const KEY_ALGORITHM: readonly ["ES256", "RS256"];
|
|
98
|
-
/**
|
|
99
|
-
* Key algorithm type derived from the const array
|
|
100
|
-
*/
|
|
101
|
-
type KeyAlgorithmType = typeof KEY_ALGORITHM[number];
|
|
102
|
-
/**
|
|
103
|
-
* Invitation status enum values
|
|
104
|
-
* Single source of truth for all invitation statuses
|
|
105
|
-
*/
|
|
106
|
-
declare const INVITATION_STATUSES: readonly ["pending", "accepted", "expired", "cancelled"];
|
|
107
|
-
/**
|
|
108
|
-
* Invitation status type derived from the const array
|
|
109
|
-
*/
|
|
110
|
-
type InvitationStatus = typeof INVITATION_STATUSES[number];
|
|
111
|
-
/**
|
|
112
|
-
* User status enum values
|
|
113
|
-
* Single source of truth for all user statuses
|
|
114
|
-
*/
|
|
115
|
-
declare const USER_STATUSES: readonly ["active", "inactive", "suspended"];
|
|
116
|
-
/**
|
|
117
|
-
* User status type derived from the const array
|
|
118
|
-
*/
|
|
119
|
-
type UserStatus = typeof USER_STATUSES[number];
|
|
120
|
-
/**
|
|
121
|
-
* Social provider enum values
|
|
122
|
-
* Single source of truth for supported OAuth providers
|
|
123
|
-
*/
|
|
124
|
-
declare const SOCIAL_PROVIDERS: readonly ["google", "github", "kakao", "naver"];
|
|
125
|
-
/**
|
|
126
|
-
* Social provider type derived from the const array
|
|
127
|
-
*/
|
|
128
|
-
type SocialProvider = typeof SOCIAL_PROVIDERS[number];
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @spfn/auth - Auth Service
|
|
132
|
-
*
|
|
133
|
-
* Core authentication logic: registration, login, logout, password management
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
interface CheckAccountExistsParams {
|
|
137
|
-
email?: string;
|
|
138
|
-
phone?: string;
|
|
139
|
-
}
|
|
140
|
-
interface CheckAccountExistsResult {
|
|
141
|
-
exists: boolean;
|
|
142
|
-
identifier: string;
|
|
143
|
-
identifierType: 'email' | 'phone';
|
|
144
|
-
}
|
|
145
|
-
interface RegisterParams {
|
|
146
|
-
email?: string;
|
|
147
|
-
phone?: string;
|
|
148
|
-
verificationToken: string;
|
|
149
|
-
password: string;
|
|
150
|
-
publicKey: string;
|
|
151
|
-
keyId: string;
|
|
152
|
-
fingerprint: string;
|
|
153
|
-
algorithm?: KeyAlgorithmType;
|
|
154
|
-
metadata?: Record<string, unknown>;
|
|
155
|
-
}
|
|
156
|
-
interface RegisterResult {
|
|
157
|
-
userId: string;
|
|
158
|
-
publicId: string;
|
|
159
|
-
email?: string;
|
|
160
|
-
phone?: string;
|
|
161
|
-
}
|
|
162
|
-
interface LoginParams {
|
|
163
|
-
email?: string;
|
|
164
|
-
phone?: string;
|
|
165
|
-
password: string;
|
|
166
|
-
publicKey: string;
|
|
167
|
-
keyId: string;
|
|
168
|
-
fingerprint: string;
|
|
169
|
-
oldKeyId?: string;
|
|
170
|
-
algorithm?: KeyAlgorithmType;
|
|
171
|
-
}
|
|
172
|
-
interface LoginResult {
|
|
173
|
-
userId: string;
|
|
174
|
-
publicId: string;
|
|
175
|
-
email?: string;
|
|
176
|
-
phone?: string;
|
|
177
|
-
passwordChangeRequired: boolean;
|
|
178
|
-
}
|
|
179
|
-
interface LogoutParams {
|
|
180
|
-
userId: number;
|
|
181
|
-
keyId: string;
|
|
182
|
-
}
|
|
183
|
-
interface ChangePasswordParams {
|
|
184
|
-
userId: number;
|
|
185
|
-
currentPassword: string;
|
|
186
|
-
newPassword: string;
|
|
187
|
-
passwordHash?: string;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Check if an account exists by email or phone
|
|
191
|
-
*/
|
|
192
|
-
declare function checkAccountExistsService(params: CheckAccountExistsParams): Promise<CheckAccountExistsResult>;
|
|
193
|
-
/**
|
|
194
|
-
* Register a new user account
|
|
195
|
-
*/
|
|
196
|
-
declare function registerService(params: RegisterParams): Promise<RegisterResult>;
|
|
197
|
-
/**
|
|
198
|
-
* Authenticate user and create session
|
|
199
|
-
*/
|
|
200
|
-
declare function loginService(params: LoginParams): Promise<LoginResult>;
|
|
201
|
-
/**
|
|
202
|
-
* Logout user (revoke current key)
|
|
203
|
-
*/
|
|
204
|
-
declare function logoutService(params: LogoutParams): Promise<void>;
|
|
205
|
-
/**
|
|
206
|
-
* Change user password
|
|
207
|
-
*/
|
|
208
|
-
declare function changePasswordService(params: ChangePasswordParams): Promise<void>;
|
|
209
|
-
|
|
210
|
-
declare const EmailSchema: _sinclair_typebox.TString;
|
|
211
|
-
declare const PhoneSchema: _sinclair_typebox.TString;
|
|
212
|
-
declare const PasswordSchema: _sinclair_typebox.TString;
|
|
213
|
-
declare const TargetTypeSchema: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"email">, _sinclair_typebox.TLiteral<"phone">]>;
|
|
214
|
-
type VerificationTargetType = Static<typeof TargetTypeSchema>;
|
|
215
|
-
declare const VERIFICATION_TARGET_TYPES: readonly ["email", "phone"];
|
|
216
|
-
declare const VerificationPurposeSchema: _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">]>;
|
|
217
|
-
type VerificationPurpose = Static<typeof VerificationPurposeSchema>;
|
|
218
|
-
declare const VERIFICATION_PURPOSES: readonly ["registration", "login", "password_reset", "email_change", "phone_change"];
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @spfn/auth - Verification Service
|
|
222
|
-
*
|
|
223
|
-
* Handles OTP code generation, validation, and delivery
|
|
224
|
-
*/
|
|
225
|
-
|
|
226
|
-
interface SendVerificationCodeParams {
|
|
227
|
-
target: string;
|
|
228
|
-
targetType: VerificationTargetType;
|
|
229
|
-
purpose: VerificationPurpose;
|
|
230
|
-
}
|
|
231
|
-
interface SendVerificationCodeResult {
|
|
232
|
-
success: boolean;
|
|
233
|
-
expiresAt: string;
|
|
234
|
-
}
|
|
235
|
-
interface VerifyCodeParams {
|
|
236
|
-
target: string;
|
|
237
|
-
targetType: VerificationTargetType;
|
|
238
|
-
code: string;
|
|
239
|
-
purpose: VerificationPurpose;
|
|
240
|
-
}
|
|
241
|
-
interface VerifyCodeResult {
|
|
242
|
-
valid: boolean;
|
|
243
|
-
verificationToken: string;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Send verification code via email or SMS
|
|
247
|
-
*/
|
|
248
|
-
declare function sendVerificationCodeService(params: SendVerificationCodeParams): Promise<SendVerificationCodeResult>;
|
|
249
|
-
/**
|
|
250
|
-
* Verify OTP code and return verification token
|
|
251
|
-
*/
|
|
252
|
-
declare function verifyCodeService(params: VerifyCodeParams): Promise<{
|
|
253
|
-
valid: boolean;
|
|
254
|
-
verificationToken: string;
|
|
255
|
-
}>;
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* @spfn/auth - Key Service
|
|
259
|
-
*
|
|
260
|
-
* Handles public key registration, rotation, and revocation
|
|
261
|
-
*/
|
|
262
|
-
|
|
263
|
-
interface RegisterPublicKeyParams {
|
|
264
|
-
userId: number;
|
|
265
|
-
keyId: string;
|
|
266
|
-
publicKey: string;
|
|
267
|
-
fingerprint: string;
|
|
268
|
-
algorithm?: KeyAlgorithmType;
|
|
269
|
-
}
|
|
270
|
-
interface RotateKeyParams {
|
|
271
|
-
userId: number;
|
|
272
|
-
oldKeyId: string;
|
|
273
|
-
newKeyId: string;
|
|
274
|
-
newPublicKey: string;
|
|
275
|
-
fingerprint: string;
|
|
276
|
-
algorithm?: KeyAlgorithmType;
|
|
277
|
-
}
|
|
278
|
-
interface RotateKeyResult {
|
|
279
|
-
success: boolean;
|
|
280
|
-
keyId: string;
|
|
281
|
-
}
|
|
282
|
-
interface RevokeKeyParams {
|
|
283
|
-
userId: number;
|
|
284
|
-
keyId: string;
|
|
285
|
-
reason: string;
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Register a new public key for a user
|
|
289
|
-
*/
|
|
290
|
-
declare function registerPublicKeyService(params: RegisterPublicKeyParams): Promise<void>;
|
|
291
|
-
/**
|
|
292
|
-
* Rotate user's public key (revoke old, register new)
|
|
293
|
-
*/
|
|
294
|
-
declare function rotateKeyService(params: RotateKeyParams): Promise<RotateKeyResult>;
|
|
295
|
-
/**
|
|
296
|
-
* Revoke a user's public key
|
|
297
|
-
*/
|
|
298
|
-
declare function revokeKeyService(params: RevokeKeyParams): Promise<void>;
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* @spfn/auth - RBAC Type Definitions
|
|
302
|
-
*
|
|
303
|
-
* Type definitions for role and permission configuration
|
|
304
|
-
*/
|
|
305
|
-
/**
|
|
306
|
-
* Permission category enum values
|
|
307
|
-
* Single source of truth for permission categories
|
|
308
|
-
*/
|
|
309
|
-
declare const PERMISSION_CATEGORIES: readonly ["auth", "user", "rbac", "system", "custom"];
|
|
310
|
-
/**
|
|
311
|
-
* Permission category type derived from the const array
|
|
312
|
-
*/
|
|
313
|
-
type PermissionCategory = typeof PERMISSION_CATEGORIES[number];
|
|
314
|
-
interface RoleConfig {
|
|
315
|
-
name: string;
|
|
316
|
-
displayName: string;
|
|
317
|
-
description?: string;
|
|
318
|
-
priority?: number;
|
|
319
|
-
isSystem?: boolean;
|
|
320
|
-
isBuiltin?: boolean;
|
|
321
|
-
}
|
|
322
|
-
interface PermissionConfig {
|
|
323
|
-
name: string;
|
|
324
|
-
displayName: string;
|
|
325
|
-
description?: string;
|
|
326
|
-
category?: PermissionCategory;
|
|
327
|
-
isSystem?: boolean;
|
|
328
|
-
isBuiltin?: boolean;
|
|
329
|
-
}
|
|
330
|
-
interface AuthInitOptions {
|
|
331
|
-
/**
|
|
332
|
-
* Additional roles to create
|
|
333
|
-
* Built-in roles (user, admin, superadmin) are automatically included
|
|
334
|
-
*/
|
|
335
|
-
roles?: RoleConfig[];
|
|
336
|
-
/**
|
|
337
|
-
* Additional permissions to create
|
|
338
|
-
* Built-in permissions are automatically included
|
|
339
|
-
*/
|
|
340
|
-
permissions?: PermissionConfig[];
|
|
341
|
-
/**
|
|
342
|
-
* Role-Permission mappings
|
|
343
|
-
* Built-in mappings are automatically included
|
|
344
|
-
* You can extend built-in roles or define mappings for custom roles
|
|
345
|
-
*
|
|
346
|
-
* @example
|
|
347
|
-
* ```typescript
|
|
348
|
-
* {
|
|
349
|
-
* // Extend built-in admin role
|
|
350
|
-
* admin: ['project:create', 'project:delete'],
|
|
351
|
-
*
|
|
352
|
-
* // Define custom role permissions
|
|
353
|
-
* 'project-manager': ['project:create', 'task:assign'],
|
|
354
|
-
* }
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
|
-
rolePermissions?: Record<string, string[]>;
|
|
358
|
-
/**
|
|
359
|
-
* Default role name for new users
|
|
360
|
-
* Must be a valid role name that exists after initialization
|
|
361
|
-
* @default 'user'
|
|
362
|
-
*/
|
|
363
|
-
defaultRole?: string;
|
|
364
|
-
/**
|
|
365
|
-
* Default session TTL (Time To Live)
|
|
366
|
-
*
|
|
367
|
-
* Supports:
|
|
368
|
-
* - Number: seconds (e.g., 2592000)
|
|
369
|
-
* - String: duration format ('30d', '12h', '45m', '3600s')
|
|
370
|
-
*
|
|
371
|
-
* Can be overridden at runtime with `remember` parameter.
|
|
372
|
-
*
|
|
373
|
-
* @default '7d' (7 days)
|
|
374
|
-
*
|
|
375
|
-
* @example
|
|
376
|
-
* ```typescript
|
|
377
|
-
* {
|
|
378
|
-
* sessionTtl: '30d', // 30 days
|
|
379
|
-
* }
|
|
380
|
-
* ```
|
|
381
|
-
*/
|
|
382
|
-
sessionTtl?: string | number;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* One-Time Token Service
|
|
387
|
-
*
|
|
388
|
-
* Issues and verifies one-time tokens for direct API access.
|
|
389
|
-
*/
|
|
390
|
-
interface IssueOneTimeTokenResult {
|
|
391
|
-
token: string;
|
|
392
|
-
expiresAt: string;
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Issue a one-time token for the authenticated user
|
|
396
|
-
*
|
|
397
|
-
* @param userId - Authenticated user's ID
|
|
398
|
-
* @returns Token string and ISO expiration timestamp
|
|
399
|
-
*/
|
|
400
|
-
declare function issueOneTimeTokenService(userId: string): Promise<IssueOneTimeTokenResult>;
|
|
401
|
-
/**
|
|
402
|
-
* Verify and consume a one-time token
|
|
403
|
-
*
|
|
404
|
-
* @param token - The one-time token to verify
|
|
405
|
-
* @returns userId if valid, null if invalid/expired/consumed
|
|
406
|
-
*/
|
|
407
|
-
declare function verifyOneTimeTokenService(token: string): Promise<string | null>;
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* @spfn/auth - OAuth Service
|
|
411
|
-
*
|
|
412
|
-
* OAuth 인증 비즈니스 로직
|
|
413
|
-
* - Google OAuth Authorization Code Flow
|
|
414
|
-
* - 소셜 계정 연결/생성
|
|
415
|
-
* - publicKey는 state에서 추출하여 등록
|
|
416
|
-
*/
|
|
417
|
-
|
|
418
|
-
interface OAuthStartParams {
|
|
419
|
-
provider: SocialProvider;
|
|
420
|
-
returnUrl: string;
|
|
421
|
-
publicKey: string;
|
|
422
|
-
keyId: string;
|
|
423
|
-
fingerprint: string;
|
|
424
|
-
algorithm: KeyAlgorithmType;
|
|
425
|
-
metadata?: Record<string, unknown>;
|
|
426
|
-
}
|
|
427
|
-
interface OAuthStartResult {
|
|
428
|
-
authUrl: string;
|
|
429
|
-
}
|
|
430
|
-
interface OAuthCallbackParams {
|
|
431
|
-
provider: SocialProvider;
|
|
432
|
-
code: string;
|
|
433
|
-
state: string;
|
|
434
|
-
}
|
|
435
|
-
interface OAuthCallbackResult {
|
|
436
|
-
redirectUrl: string;
|
|
437
|
-
userId: string;
|
|
438
|
-
keyId: string;
|
|
439
|
-
isNewUser: boolean;
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* OAuth 로그인 시작 - Provider 로그인 페이지로 리다이렉트할 URL 생성
|
|
443
|
-
*
|
|
444
|
-
* Next.js에서 키쌍을 생성한 후, publicKey를 state에 포함하여 호출
|
|
445
|
-
*/
|
|
446
|
-
declare function oauthStartService(params: OAuthStartParams): Promise<OAuthStartResult>;
|
|
447
|
-
/**
|
|
448
|
-
* OAuth 콜백 처리 - Code를 Token으로 교환하고 사용자 생성/연결
|
|
449
|
-
*
|
|
450
|
-
* state에서 publicKey를 추출하여 서버에 등록
|
|
451
|
-
* Next.js는 반환된 userId, keyId로 세션을 구성
|
|
452
|
-
*/
|
|
453
|
-
declare function oauthCallbackService(params: OAuthCallbackParams): Promise<OAuthCallbackResult>;
|
|
454
|
-
/**
|
|
455
|
-
* OAuth 에러 리다이렉트 URL 생성
|
|
456
|
-
*/
|
|
457
|
-
declare function buildOAuthErrorUrl(error: string): string;
|
|
458
|
-
/**
|
|
459
|
-
* OAuth provider가 활성화되어 있는지 확인
|
|
460
|
-
*/
|
|
461
|
-
declare function isOAuthProviderEnabled(provider: SocialProvider): boolean;
|
|
462
|
-
/**
|
|
463
|
-
* 활성화된 모든 OAuth provider 목록
|
|
464
|
-
*/
|
|
465
|
-
declare function getEnabledOAuthProviders(): SocialProvider[];
|
|
466
|
-
/**
|
|
467
|
-
* Google access token 조회 (만료 시 자동 리프레시)
|
|
468
|
-
*
|
|
469
|
-
* 저장된 토큰이 만료 임박(5분 이내) 또는 만료 상태이면
|
|
470
|
-
* refresh token으로 자동 갱신 후 DB 업데이트하여 유효한 토큰 반환.
|
|
471
|
-
*
|
|
472
|
-
* @param userId - 사용자 ID
|
|
473
|
-
* @returns 유효한 Google access token
|
|
474
|
-
*/
|
|
475
|
-
declare function getGoogleAccessToken(userId: number): Promise<string>;
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* @spfn/auth - Main Router
|
|
479
|
-
*
|
|
480
|
-
* Combines all auth-related routes into a single router
|
|
481
|
-
*/
|
|
482
|
-
/**
|
|
483
|
-
* Main auth router
|
|
484
|
-
* Exports all authentication-related routes
|
|
485
|
-
*
|
|
486
|
-
* Routes:
|
|
487
|
-
* - Auth: /_auth/exists, /_auth/codes, /_auth/login, /_auth/logout, etc.
|
|
488
|
-
* - OAuth: /_auth/oauth/google, /_auth/oauth/google/callback, etc.
|
|
489
|
-
* - Invitations: /_auth/invitations/*
|
|
490
|
-
* - Users: /_auth/users/*
|
|
491
|
-
* - Admin: /_auth/admin/* (superadmin only)
|
|
492
|
-
*/
|
|
493
|
-
declare const mainAuthRouter: _spfn_core_route.Router<{
|
|
494
|
-
checkAccountExists: _spfn_core_route.RouteDef<{
|
|
495
|
-
body: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
496
|
-
email: _sinclair_typebox.TString;
|
|
497
|
-
}>, _sinclair_typebox.TObject<{
|
|
498
|
-
phone: _sinclair_typebox.TString;
|
|
499
|
-
}>]>;
|
|
500
|
-
}, {}, CheckAccountExistsResult>;
|
|
501
|
-
sendVerificationCode: _spfn_core_route.RouteDef<{
|
|
502
|
-
body: _sinclair_typebox.TObject<{
|
|
503
|
-
target: _sinclair_typebox.TString;
|
|
504
|
-
targetType: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"email">, _sinclair_typebox.TLiteral<"phone">]>;
|
|
505
|
-
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">]>;
|
|
506
|
-
}>;
|
|
507
|
-
}, {}, SendVerificationCodeResult>;
|
|
508
|
-
verifyCode: _spfn_core_route.RouteDef<{
|
|
509
|
-
body: _sinclair_typebox.TObject<{
|
|
510
|
-
target: _sinclair_typebox.TString;
|
|
511
|
-
targetType: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"email">, _sinclair_typebox.TLiteral<"phone">]>;
|
|
512
|
-
code: _sinclair_typebox.TString;
|
|
513
|
-
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">]>;
|
|
514
|
-
}>;
|
|
515
|
-
}, {}, {
|
|
516
|
-
valid: boolean;
|
|
517
|
-
verificationToken: string;
|
|
518
|
-
}>;
|
|
519
|
-
register: _spfn_core_route.RouteDef<{
|
|
520
|
-
body: _sinclair_typebox.TObject<{
|
|
521
|
-
email: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
522
|
-
phone: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
523
|
-
verificationToken: _sinclair_typebox.TString;
|
|
524
|
-
password: _sinclair_typebox.TString;
|
|
525
|
-
metadata: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TUnknown>>;
|
|
526
|
-
}>;
|
|
527
|
-
}, {
|
|
528
|
-
body: _sinclair_typebox.TObject<{
|
|
529
|
-
publicKey: _sinclair_typebox.TString;
|
|
530
|
-
keyId: _sinclair_typebox.TString;
|
|
531
|
-
fingerprint: _sinclair_typebox.TString;
|
|
532
|
-
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
533
|
-
}>;
|
|
534
|
-
}, RegisterResult>;
|
|
535
|
-
login: _spfn_core_route.RouteDef<{
|
|
536
|
-
body: _sinclair_typebox.TObject<{
|
|
537
|
-
email: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
538
|
-
phone: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
539
|
-
password: _sinclair_typebox.TString;
|
|
540
|
-
}>;
|
|
541
|
-
}, {
|
|
542
|
-
body: _sinclair_typebox.TObject<{
|
|
543
|
-
publicKey: _sinclair_typebox.TString;
|
|
544
|
-
keyId: _sinclair_typebox.TString;
|
|
545
|
-
fingerprint: _sinclair_typebox.TString;
|
|
546
|
-
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
547
|
-
oldKeyId: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
548
|
-
}>;
|
|
549
|
-
}, LoginResult>;
|
|
550
|
-
logout: _spfn_core_route.RouteDef<{}, {}, void>;
|
|
551
|
-
rotateKey: _spfn_core_route.RouteDef<{}, {
|
|
552
|
-
body: _sinclair_typebox.TObject<{
|
|
553
|
-
publicKey: _sinclair_typebox.TString;
|
|
554
|
-
keyId: _sinclair_typebox.TString;
|
|
555
|
-
fingerprint: _sinclair_typebox.TString;
|
|
556
|
-
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
557
|
-
}>;
|
|
558
|
-
}, RotateKeyResult>;
|
|
559
|
-
changePassword: _spfn_core_route.RouteDef<{
|
|
560
|
-
body: _sinclair_typebox.TObject<{
|
|
561
|
-
currentPassword: _sinclair_typebox.TString;
|
|
562
|
-
newPassword: _sinclair_typebox.TString;
|
|
563
|
-
}>;
|
|
564
|
-
}, {}, void>;
|
|
565
|
-
getAuthSession: _spfn_core_route.RouteDef<{}, {}, {
|
|
566
|
-
role: {
|
|
567
|
-
id: number;
|
|
568
|
-
name: string;
|
|
569
|
-
displayName: string;
|
|
570
|
-
priority: number;
|
|
571
|
-
};
|
|
572
|
-
permissions: {
|
|
573
|
-
id: number;
|
|
574
|
-
name: string;
|
|
575
|
-
displayName: string;
|
|
576
|
-
category: "auth" | "custom" | "user" | "rbac" | "system" | undefined;
|
|
577
|
-
}[];
|
|
578
|
-
userId: number;
|
|
579
|
-
publicId: string;
|
|
580
|
-
email: string | null;
|
|
581
|
-
emailVerified: boolean;
|
|
582
|
-
phoneVerified: boolean;
|
|
583
|
-
}>;
|
|
584
|
-
issueOneTimeToken: _spfn_core_route.RouteDef<{}, {}, IssueOneTimeTokenResult>;
|
|
585
|
-
oauthGoogleStart: _spfn_core_route.RouteDef<{
|
|
586
|
-
query: _sinclair_typebox.TObject<{
|
|
587
|
-
state: _sinclair_typebox.TString;
|
|
588
|
-
}>;
|
|
589
|
-
}, {}, Response>;
|
|
590
|
-
oauthGoogleCallback: _spfn_core_route.RouteDef<{
|
|
591
|
-
query: _sinclair_typebox.TObject<{
|
|
592
|
-
code: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
593
|
-
state: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
594
|
-
error: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
595
|
-
error_description: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
596
|
-
}>;
|
|
597
|
-
}, {}, Response>;
|
|
598
|
-
oauthStart: _spfn_core_route.RouteDef<{
|
|
599
|
-
body: _sinclair_typebox.TObject<{
|
|
600
|
-
provider: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"google" | "github" | "kakao" | "naver">[]>;
|
|
601
|
-
returnUrl: _sinclair_typebox.TString;
|
|
602
|
-
publicKey: _sinclair_typebox.TString;
|
|
603
|
-
keyId: _sinclair_typebox.TString;
|
|
604
|
-
fingerprint: _sinclair_typebox.TString;
|
|
605
|
-
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
606
|
-
metadata: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TUnknown>>;
|
|
607
|
-
}>;
|
|
608
|
-
}, {}, OAuthStartResult>;
|
|
609
|
-
oauthProviders: _spfn_core_route.RouteDef<{}, {}, {
|
|
610
|
-
providers: ("google" | "github" | "kakao" | "naver")[];
|
|
611
|
-
}>;
|
|
612
|
-
getGoogleOAuthUrl: _spfn_core_route.RouteDef<{
|
|
613
|
-
body: _sinclair_typebox.TObject<{
|
|
614
|
-
returnUrl: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
615
|
-
state: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
616
|
-
}>;
|
|
617
|
-
}, {}, {
|
|
618
|
-
authUrl: string;
|
|
619
|
-
}>;
|
|
620
|
-
oauthFinalize: _spfn_core_route.RouteDef<{
|
|
621
|
-
body: _sinclair_typebox.TObject<{
|
|
622
|
-
userId: _sinclair_typebox.TString;
|
|
623
|
-
keyId: _sinclair_typebox.TString;
|
|
624
|
-
returnUrl: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
625
|
-
}>;
|
|
626
|
-
}, {}, {
|
|
627
|
-
success: boolean;
|
|
628
|
-
userId: string;
|
|
629
|
-
keyId: string;
|
|
630
|
-
returnUrl: string;
|
|
631
|
-
}>;
|
|
632
|
-
getInvitation: _spfn_core_route.RouteDef<{
|
|
633
|
-
params: _sinclair_typebox.TObject<{
|
|
634
|
-
token: _sinclair_typebox.TString;
|
|
635
|
-
}>;
|
|
636
|
-
}, {}, {
|
|
637
|
-
email: string;
|
|
638
|
-
role: string;
|
|
639
|
-
roleDisplayName: string;
|
|
640
|
-
invitedBy: string;
|
|
641
|
-
expiresAt: string;
|
|
642
|
-
metadata: Record<string, any> | undefined;
|
|
643
|
-
}>;
|
|
644
|
-
acceptInvitation: _spfn_core_route.RouteDef<{
|
|
645
|
-
body: _sinclair_typebox.TObject<{
|
|
646
|
-
token: _sinclair_typebox.TString;
|
|
647
|
-
password: _sinclair_typebox.TString;
|
|
648
|
-
}>;
|
|
649
|
-
}, {
|
|
650
|
-
body: _sinclair_typebox.TObject<{
|
|
651
|
-
publicKey: _sinclair_typebox.TString;
|
|
652
|
-
keyId: _sinclair_typebox.TString;
|
|
653
|
-
fingerprint: _sinclair_typebox.TString;
|
|
654
|
-
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
655
|
-
}>;
|
|
656
|
-
}, {
|
|
657
|
-
userId: number;
|
|
658
|
-
email: string;
|
|
659
|
-
role: string;
|
|
660
|
-
}>;
|
|
661
|
-
createInvitation: _spfn_core_route.RouteDef<{
|
|
662
|
-
body: _sinclair_typebox.TObject<{
|
|
663
|
-
email: _sinclair_typebox.TString;
|
|
664
|
-
roleId: _sinclair_typebox.TNumber;
|
|
665
|
-
expiresInDays: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
666
|
-
expiresAt: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
667
|
-
metadata: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
668
|
-
}>;
|
|
669
|
-
}, {}, {
|
|
670
|
-
id: number;
|
|
671
|
-
email: string;
|
|
672
|
-
token: string;
|
|
673
|
-
roleId: number;
|
|
674
|
-
expiresAt: string;
|
|
675
|
-
invitationUrl: string;
|
|
676
|
-
}>;
|
|
677
|
-
listInvitations: _spfn_core_route.RouteDef<{
|
|
678
|
-
query: _sinclair_typebox.TObject<{
|
|
679
|
-
status: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"pending" | "accepted" | "expired" | "cancelled">[]>>;
|
|
680
|
-
page: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
681
|
-
limit: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
682
|
-
}>;
|
|
683
|
-
}, {}, {
|
|
684
|
-
invitations: {
|
|
685
|
-
id: number;
|
|
686
|
-
email: string;
|
|
687
|
-
token: string;
|
|
688
|
-
roleId: number;
|
|
689
|
-
invitedBy: number;
|
|
690
|
-
status: "pending" | "accepted" | "expired" | "cancelled";
|
|
691
|
-
expiresAt: Date;
|
|
692
|
-
acceptedAt: Date | null;
|
|
693
|
-
cancelledAt: Date | null;
|
|
694
|
-
metadata: Record<string, any> | null;
|
|
695
|
-
createdAt: Date;
|
|
696
|
-
updatedAt: Date;
|
|
697
|
-
role: {
|
|
698
|
-
id: number;
|
|
699
|
-
name: string;
|
|
700
|
-
displayName: string;
|
|
701
|
-
};
|
|
702
|
-
inviter: {
|
|
703
|
-
id: number;
|
|
704
|
-
email: string | null;
|
|
705
|
-
};
|
|
706
|
-
}[];
|
|
707
|
-
total: number;
|
|
708
|
-
page: number;
|
|
709
|
-
limit: number;
|
|
710
|
-
totalPages: number;
|
|
711
|
-
}>;
|
|
712
|
-
cancelInvitation: _spfn_core_route.RouteDef<{
|
|
713
|
-
body: _sinclair_typebox.TObject<{
|
|
714
|
-
id: _sinclair_typebox.TNumber;
|
|
715
|
-
reason: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
716
|
-
}>;
|
|
717
|
-
}, {}, {
|
|
718
|
-
cancelledAt: string;
|
|
719
|
-
}>;
|
|
720
|
-
resendInvitation: _spfn_core_route.RouteDef<{
|
|
721
|
-
body: _sinclair_typebox.TObject<{
|
|
722
|
-
id: _sinclair_typebox.TNumber;
|
|
723
|
-
expiresInDays: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
724
|
-
}>;
|
|
725
|
-
}, {}, {
|
|
726
|
-
expiresAt: string;
|
|
727
|
-
}>;
|
|
728
|
-
deleteInvitation: _spfn_core_route.RouteDef<{
|
|
729
|
-
body: _sinclair_typebox.TObject<{
|
|
730
|
-
id: _sinclair_typebox.TNumber;
|
|
731
|
-
}>;
|
|
732
|
-
}, {}, void>;
|
|
733
|
-
getUserProfile: _spfn_core_route.RouteDef<{}, {}, UserProfile>;
|
|
734
|
-
updateUserProfile: _spfn_core_route.RouteDef<{
|
|
735
|
-
body: _sinclair_typebox.TObject<{
|
|
736
|
-
displayName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
737
|
-
firstName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
738
|
-
lastName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
739
|
-
avatarUrl: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
740
|
-
bio: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
741
|
-
locale: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
742
|
-
timezone: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
743
|
-
dateOfBirth: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
744
|
-
gender: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
745
|
-
website: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
746
|
-
location: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
747
|
-
company: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
748
|
-
jobTitle: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
749
|
-
metadata: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
|
|
750
|
-
}>;
|
|
751
|
-
}, {}, ProfileInfo>;
|
|
752
|
-
checkUsername: _spfn_core_route.RouteDef<{
|
|
753
|
-
query: _sinclair_typebox.TObject<{
|
|
754
|
-
username: _sinclair_typebox.TString;
|
|
755
|
-
}>;
|
|
756
|
-
}, {}, {
|
|
757
|
-
available: boolean;
|
|
758
|
-
}>;
|
|
759
|
-
updateUsername: _spfn_core_route.RouteDef<{
|
|
760
|
-
body: _sinclair_typebox.TObject<{
|
|
761
|
-
username: _sinclair_typebox.TUnion<[_sinclair_typebox.TString, _sinclair_typebox.TNull]>;
|
|
762
|
-
}>;
|
|
763
|
-
}, {}, {
|
|
764
|
-
createdAt: Date;
|
|
765
|
-
updatedAt: Date;
|
|
766
|
-
id: number;
|
|
767
|
-
publicId: string;
|
|
768
|
-
email: string | null;
|
|
769
|
-
phone: string | null;
|
|
770
|
-
username: string | null;
|
|
771
|
-
passwordHash: string | null;
|
|
772
|
-
passwordChangeRequired: boolean;
|
|
773
|
-
roleId: number;
|
|
774
|
-
status: "active" | "inactive" | "suspended";
|
|
775
|
-
emailVerifiedAt: Date | null;
|
|
776
|
-
phoneVerifiedAt: Date | null;
|
|
777
|
-
lastLoginAt: Date | null;
|
|
778
|
-
}>;
|
|
779
|
-
updateLocale: _spfn_core_route.RouteDef<{
|
|
780
|
-
body: _sinclair_typebox.TObject<{
|
|
781
|
-
locale: _sinclair_typebox.TString;
|
|
782
|
-
}>;
|
|
783
|
-
}, {}, {
|
|
784
|
-
locale: string;
|
|
785
|
-
}>;
|
|
786
|
-
listRoles: _spfn_core_route.RouteDef<{
|
|
787
|
-
query: _sinclair_typebox.TObject<{
|
|
788
|
-
includeInactive: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
789
|
-
}>;
|
|
790
|
-
}, {}, {
|
|
791
|
-
roles: {
|
|
792
|
-
description: string | null;
|
|
793
|
-
id: number;
|
|
794
|
-
name: string;
|
|
795
|
-
displayName: string;
|
|
796
|
-
isBuiltin: boolean;
|
|
797
|
-
isSystem: boolean;
|
|
798
|
-
isActive: boolean;
|
|
799
|
-
priority: number;
|
|
800
|
-
createdAt: Date;
|
|
801
|
-
updatedAt: Date;
|
|
802
|
-
}[];
|
|
803
|
-
}>;
|
|
804
|
-
createAdminRole: _spfn_core_route.RouteDef<{
|
|
805
|
-
body: _sinclair_typebox.TObject<{
|
|
806
|
-
name: _sinclair_typebox.TString;
|
|
807
|
-
displayName: _sinclair_typebox.TString;
|
|
808
|
-
description: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
809
|
-
priority: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
810
|
-
permissionIds: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TNumber>>;
|
|
811
|
-
}>;
|
|
812
|
-
}, {}, {
|
|
813
|
-
role: {
|
|
814
|
-
description: string | null;
|
|
815
|
-
id: number;
|
|
816
|
-
name: string;
|
|
817
|
-
displayName: string;
|
|
818
|
-
isBuiltin: boolean;
|
|
819
|
-
isSystem: boolean;
|
|
820
|
-
isActive: boolean;
|
|
821
|
-
priority: number;
|
|
822
|
-
createdAt: Date;
|
|
823
|
-
updatedAt: Date;
|
|
824
|
-
};
|
|
825
|
-
}>;
|
|
826
|
-
updateAdminRole: _spfn_core_route.RouteDef<{
|
|
827
|
-
params: _sinclair_typebox.TObject<{
|
|
828
|
-
id: _sinclair_typebox.TNumber;
|
|
829
|
-
}>;
|
|
830
|
-
body: _sinclair_typebox.TObject<{
|
|
831
|
-
displayName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
832
|
-
description: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
833
|
-
priority: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
834
|
-
isActive: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
835
|
-
}>;
|
|
836
|
-
}, {}, {
|
|
837
|
-
role: {
|
|
838
|
-
description: string | null;
|
|
839
|
-
id: number;
|
|
840
|
-
name: string;
|
|
841
|
-
displayName: string;
|
|
842
|
-
isBuiltin: boolean;
|
|
843
|
-
isSystem: boolean;
|
|
844
|
-
isActive: boolean;
|
|
845
|
-
priority: number;
|
|
846
|
-
createdAt: Date;
|
|
847
|
-
updatedAt: Date;
|
|
848
|
-
};
|
|
849
|
-
}>;
|
|
850
|
-
deleteAdminRole: _spfn_core_route.RouteDef<{
|
|
851
|
-
params: _sinclair_typebox.TObject<{
|
|
852
|
-
id: _sinclair_typebox.TNumber;
|
|
853
|
-
}>;
|
|
854
|
-
}, {}, void>;
|
|
855
|
-
updateUserRole: _spfn_core_route.RouteDef<{
|
|
856
|
-
params: _sinclair_typebox.TObject<{
|
|
857
|
-
userId: _sinclair_typebox.TNumber;
|
|
858
|
-
}>;
|
|
859
|
-
body: _sinclair_typebox.TObject<{
|
|
860
|
-
roleId: _sinclair_typebox.TNumber;
|
|
861
|
-
}>;
|
|
862
|
-
}, {}, {
|
|
863
|
-
userId: number;
|
|
864
|
-
roleId: number;
|
|
865
|
-
}>;
|
|
866
|
-
}>;
|
|
867
|
-
|
|
868
|
-
interface AuthContext {
|
|
869
|
-
user: User;
|
|
870
|
-
userId: string;
|
|
871
|
-
keyId: string;
|
|
872
|
-
role: string | null;
|
|
873
|
-
locale: string;
|
|
874
|
-
}
|
|
875
|
-
declare module 'hono' {
|
|
876
|
-
interface ContextVariableMap {
|
|
877
|
-
auth: AuthContext;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
/**
|
|
881
|
-
* Authentication middleware
|
|
882
|
-
*
|
|
883
|
-
* Verifies client-signed JWT token using stored public key
|
|
884
|
-
* Must be applied to routes that require authentication
|
|
885
|
-
*
|
|
886
|
-
* @example
|
|
887
|
-
* ```typescript
|
|
888
|
-
* // In server.config.ts
|
|
889
|
-
* import { authenticate } from '@spfn/auth/server/middleware';
|
|
890
|
-
*
|
|
891
|
-
* export default defineServerConfig()
|
|
892
|
-
* .middlewares([authenticate])
|
|
893
|
-
* .routes(appRouter)
|
|
894
|
-
* .build();
|
|
895
|
-
*
|
|
896
|
-
* // In route file - skip auth for public routes
|
|
897
|
-
* export const publicRoute = route.get('/health')
|
|
898
|
-
* .skip(['auth']) // Type-safe skip
|
|
899
|
-
* .handler(async (c) => c.success({ status: 'ok' }));
|
|
900
|
-
*
|
|
901
|
-
* // Protected route - auth applied automatically
|
|
902
|
-
* export const protectedRoute = route.get('/profile')
|
|
903
|
-
* .handler(async (c) => {
|
|
904
|
-
* const auth = c.get('auth'); // Get auth context
|
|
905
|
-
* const { user, userId, keyId } = auth;
|
|
906
|
-
* // Or access directly: c.get('auth').user
|
|
907
|
-
* });
|
|
908
|
-
* ```
|
|
909
|
-
*/
|
|
910
|
-
declare const authenticate: _spfn_core_route.NamedMiddleware<"auth">;
|
|
911
|
-
/**
|
|
912
|
-
* Optional authentication middleware
|
|
913
|
-
*
|
|
914
|
-
* Same as `authenticate` but does NOT reject unauthenticated requests.
|
|
915
|
-
* - No token → continues without auth context
|
|
916
|
-
* - Invalid token → continues without auth context
|
|
917
|
-
* - Valid token → sets auth context normally
|
|
918
|
-
*
|
|
919
|
-
* Auto-skips the global 'auth' middleware when used at route level.
|
|
920
|
-
*
|
|
921
|
-
* @example
|
|
922
|
-
* ```typescript
|
|
923
|
-
* // No need for .skip(['auth']) — handled automatically
|
|
924
|
-
* export const getProducts = route.get('/products')
|
|
925
|
-
* .use([optionalAuth])
|
|
926
|
-
* .handler(async (c) => {
|
|
927
|
-
* const auth = getOptionalAuth(c); // AuthContext | undefined
|
|
928
|
-
*
|
|
929
|
-
* if (auth)
|
|
930
|
-
* {
|
|
931
|
-
* return getPersonalizedProducts(auth.userId);
|
|
932
|
-
* }
|
|
933
|
-
*
|
|
934
|
-
* return getPublicProducts();
|
|
935
|
-
* });
|
|
936
|
-
* ```
|
|
937
|
-
*/
|
|
938
|
-
declare const optionalAuth: _spfn_core_route.NamedMiddleware<"optionalAuth">;
|
|
939
|
-
|
|
940
|
-
export { oauthCallbackService as $, type AuthSession as A, type LogoutParams as B, type CheckAccountExistsResult as C, type ChangePasswordParams as D, sendVerificationCodeService as E, verifyCodeService as F, type SendVerificationCodeParams as G, type VerifyCodeParams as H, type IssueOneTimeTokenResult as I, type VerifyCodeResult as J, KEY_ALGORITHM as K, type LoginResult as L, registerPublicKeyService as M, rotateKeyService as N, type OAuthStartResult as O, type PermissionConfig as P, revokeKeyService as Q, type RoleConfig as R, type SendVerificationCodeResult as S, type RegisterPublicKeyParams as T, type UserProfile as U, type VerificationTargetType as V, type RotateKeyParams as W, type RevokeKeyParams as X, issueOneTimeTokenService as Y, verifyOneTimeTokenService as Z, oauthStartService as _, type RegisterResult as a, buildOAuthErrorUrl as a0, isOAuthProviderEnabled as a1, getEnabledOAuthProviders as a2, getGoogleAccessToken as a3, type OAuthStartParams as a4, type OAuthCallbackParams as a5, type OAuthCallbackResult as a6, authenticate as a7, optionalAuth as a8, EmailSchema as a9, PhoneSchema as aa, PasswordSchema as ab, TargetTypeSchema as ac, VerificationPurposeSchema as ad, type RotateKeyResult as b, type ProfileInfo as c, INVITATION_STATUSES as d, USER_STATUSES as e, SOCIAL_PROVIDERS as f, type VerificationPurpose as g, VERIFICATION_TARGET_TYPES as h, VERIFICATION_PURPOSES as i, PERMISSION_CATEGORIES as j, type PermissionCategory as k, type AuthInitOptions as l, mainAuthRouter as m, type KeyAlgorithmType as n, type InvitationStatus as o, type UserStatus as p, type SocialProvider as q, type AuthContext as r, checkAccountExistsService as s, registerService as t, loginService as u, logoutService as v, changePasswordService as w, type CheckAccountExistsParams as x, type RegisterParams as y, type LoginParams as z };
|