@authsome/ui-core 0.1.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1140 -618
- package/dist/index.js +1458 -1515
- package/dist/index.js.map +1 -1
- package/package.json +22 -45
- package/README.md +0 -166
- package/dist/adapters/index.d.mts +0 -65
- package/dist/adapters/index.d.ts +0 -65
- package/dist/adapters/index.js +0 -94
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/index.mjs +0 -92
- package/dist/adapters/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -772
- package/dist/index.mjs +0 -1734
- package/dist/index.mjs.map +0 -1
- package/dist/provider-S9ZY5hsp.d.mts +0 -787
- package/dist/provider-S9ZY5hsp.d.ts +0 -787
- package/dist/types/index.d.mts +0 -98
- package/dist/types/index.d.ts +0 -98
- package/dist/types/index.js +0 -180
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -170
- package/dist/types/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,772 +1,1294 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
interface ACSRequest {
|
|
2
|
+
Provider: string;
|
|
3
|
+
RelayState: string;
|
|
4
|
+
SAMLResponse: string;
|
|
5
|
+
}
|
|
6
|
+
interface AdminDeleteUserRequest {
|
|
7
|
+
UserID: string;
|
|
8
|
+
}
|
|
9
|
+
interface AdminImpersonateRequest {
|
|
10
|
+
UserID: string;
|
|
11
|
+
}
|
|
12
|
+
interface AdminStatsResponse {
|
|
13
|
+
total_organizations: number;
|
|
14
|
+
total_users: number;
|
|
15
|
+
}
|
|
16
|
+
interface AdminStopImpersonationRequest {
|
|
17
|
+
}
|
|
18
|
+
interface AdminUnbanUserRequest {
|
|
19
|
+
UserID: string;
|
|
20
|
+
}
|
|
21
|
+
interface AdminUserListResponse {
|
|
22
|
+
next_cursor?: string;
|
|
23
|
+
total: number;
|
|
24
|
+
users: User[];
|
|
25
|
+
}
|
|
26
|
+
interface AuthResponse {
|
|
27
|
+
expires_at: string;
|
|
28
|
+
refresh_token: string;
|
|
29
|
+
session_token: string;
|
|
30
|
+
user: User;
|
|
31
|
+
}
|
|
32
|
+
interface CallbackRequest {
|
|
33
|
+
Provider: string;
|
|
34
|
+
code: string;
|
|
35
|
+
error?: string;
|
|
36
|
+
state: string;
|
|
37
|
+
}
|
|
38
|
+
interface CallbackResponse {
|
|
39
|
+
expires_at: string;
|
|
40
|
+
is_new_user: boolean;
|
|
41
|
+
provider: string;
|
|
42
|
+
refresh_token: string;
|
|
43
|
+
session_token: string;
|
|
44
|
+
user: User;
|
|
45
|
+
}
|
|
46
|
+
interface ChallengeRequest {
|
|
47
|
+
code: string;
|
|
48
|
+
}
|
|
49
|
+
interface ChallengeResponse {
|
|
50
|
+
challenge_passed: boolean;
|
|
51
|
+
method: string;
|
|
52
|
+
}
|
|
53
|
+
interface CreateKeyRequest {
|
|
54
|
+
app_id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
scopes?: string[];
|
|
57
|
+
user_id: string;
|
|
58
|
+
}
|
|
59
|
+
interface CreateKeyResponse {
|
|
60
|
+
created_at: string;
|
|
61
|
+
expires_at?: string;
|
|
62
|
+
id: string;
|
|
63
|
+
key: string;
|
|
64
|
+
key_prefix: string;
|
|
65
|
+
name: string;
|
|
66
|
+
scopes?: string[];
|
|
67
|
+
}
|
|
68
|
+
interface CredentialInfo {
|
|
69
|
+
created_at: string;
|
|
70
|
+
display_name: string;
|
|
71
|
+
id: string;
|
|
72
|
+
transport: string[];
|
|
73
|
+
}
|
|
74
|
+
interface DeleteAccountRequest {
|
|
75
|
+
}
|
|
76
|
+
interface DeleteDeviceRequest {
|
|
77
|
+
DeviceID: string;
|
|
78
|
+
}
|
|
79
|
+
interface DeleteOrgRequest {
|
|
80
|
+
OrgID: string;
|
|
81
|
+
}
|
|
82
|
+
interface DeleteRequest {
|
|
83
|
+
CredentialID: string;
|
|
84
|
+
}
|
|
85
|
+
interface DeleteResponse {
|
|
86
|
+
status: string;
|
|
87
|
+
}
|
|
88
|
+
interface DeleteRoleRequest {
|
|
89
|
+
RoleID: string;
|
|
90
|
+
}
|
|
91
|
+
interface DeleteTeamRequest {
|
|
92
|
+
OrgID: string;
|
|
93
|
+
TeamID: string;
|
|
94
|
+
}
|
|
95
|
+
interface DeleteWebhookRequest {
|
|
96
|
+
WebhookID: string;
|
|
97
|
+
}
|
|
98
|
+
interface Device {
|
|
99
|
+
app_id: ID;
|
|
100
|
+
browser?: string;
|
|
101
|
+
created_at: string;
|
|
102
|
+
fingerprint?: string;
|
|
103
|
+
id: ID;
|
|
104
|
+
ip_address?: string;
|
|
105
|
+
last_seen_at: string;
|
|
106
|
+
name?: string;
|
|
107
|
+
os?: string;
|
|
108
|
+
trusted: boolean;
|
|
109
|
+
type?: string;
|
|
110
|
+
updated_at: string;
|
|
111
|
+
user_id: ID;
|
|
112
|
+
}
|
|
113
|
+
interface DeviceListResponse {
|
|
114
|
+
devices: Device[];
|
|
115
|
+
}
|
|
116
|
+
interface DisableRequest {
|
|
117
|
+
}
|
|
118
|
+
interface DisableResponse {
|
|
119
|
+
status: string;
|
|
120
|
+
}
|
|
121
|
+
interface EnrollRequest {
|
|
122
|
+
method?: string;
|
|
123
|
+
phone?: string;
|
|
124
|
+
}
|
|
125
|
+
interface EnrollResponse {
|
|
126
|
+
id: string;
|
|
127
|
+
method: string;
|
|
128
|
+
otpauth_url: string;
|
|
129
|
+
secret: string;
|
|
130
|
+
}
|
|
131
|
+
interface ForgotPasswordResponse {
|
|
132
|
+
status: string;
|
|
133
|
+
}
|
|
134
|
+
interface HealthResponse {
|
|
135
|
+
error?: string;
|
|
136
|
+
status: string;
|
|
137
|
+
}
|
|
138
|
+
interface ID {
|
|
139
|
+
}
|
|
140
|
+
interface Invitation {
|
|
141
|
+
created_at: string;
|
|
142
|
+
email: string;
|
|
143
|
+
expires_at: string;
|
|
144
|
+
id: ID;
|
|
145
|
+
inviter_id: ID;
|
|
146
|
+
org_id: ID;
|
|
147
|
+
role: string;
|
|
148
|
+
status: string;
|
|
149
|
+
}
|
|
150
|
+
interface InvitationListResponse {
|
|
151
|
+
invitations: Invitation[];
|
|
152
|
+
}
|
|
153
|
+
interface KeyListItem {
|
|
154
|
+
created_at: string;
|
|
155
|
+
expires_at?: string;
|
|
156
|
+
id: string;
|
|
157
|
+
key_prefix: string;
|
|
158
|
+
last_used_at?: string;
|
|
159
|
+
name: string;
|
|
160
|
+
revoked: boolean;
|
|
161
|
+
scopes?: string[];
|
|
162
|
+
}
|
|
163
|
+
interface ListKeysResponse {
|
|
164
|
+
keys: KeyListItem[];
|
|
165
|
+
total: number;
|
|
166
|
+
}
|
|
167
|
+
interface ListResponse$1 {
|
|
168
|
+
credentials: CredentialInfo[];
|
|
169
|
+
}
|
|
170
|
+
interface LoginBeginRequest {
|
|
171
|
+
email?: string;
|
|
172
|
+
}
|
|
173
|
+
interface LoginBeginResponse {
|
|
174
|
+
options: Record<string, unknown>;
|
|
175
|
+
}
|
|
176
|
+
interface LoginFinishRequest {
|
|
177
|
+
}
|
|
178
|
+
interface LoginFinishResponse {
|
|
179
|
+
status: string;
|
|
180
|
+
user_id: string;
|
|
181
|
+
}
|
|
182
|
+
interface LoginRequest {
|
|
183
|
+
Provider: string;
|
|
184
|
+
}
|
|
185
|
+
interface LoginResponse {
|
|
186
|
+
login_url: string;
|
|
187
|
+
state: string;
|
|
188
|
+
}
|
|
189
|
+
interface Member {
|
|
190
|
+
created_at: string;
|
|
191
|
+
id: ID;
|
|
192
|
+
org_id: ID;
|
|
193
|
+
role: string;
|
|
194
|
+
updated_at: string;
|
|
195
|
+
user_id: ID;
|
|
196
|
+
}
|
|
197
|
+
interface MemberListResponse {
|
|
198
|
+
members: Member[];
|
|
199
|
+
}
|
|
200
|
+
interface OrgListResponse {
|
|
201
|
+
organizations: Organization[];
|
|
202
|
+
}
|
|
203
|
+
interface Organization {
|
|
204
|
+
app_id: ID;
|
|
205
|
+
created_at: string;
|
|
206
|
+
created_by: ID;
|
|
207
|
+
id: ID;
|
|
208
|
+
logo?: string;
|
|
209
|
+
metadata?: Record<string, unknown>;
|
|
210
|
+
name: string;
|
|
211
|
+
slug: string;
|
|
212
|
+
updated_at: string;
|
|
213
|
+
}
|
|
214
|
+
interface Permission {
|
|
215
|
+
action: string;
|
|
216
|
+
id: string;
|
|
217
|
+
resource: string;
|
|
218
|
+
role_id: string;
|
|
219
|
+
}
|
|
220
|
+
interface PermissionListResponse {
|
|
221
|
+
permissions: Permission[];
|
|
222
|
+
}
|
|
223
|
+
interface RecoveryRegenerateRequest {
|
|
224
|
+
}
|
|
225
|
+
interface RecoveryRegenerateResponse {
|
|
226
|
+
codes: string[];
|
|
227
|
+
}
|
|
228
|
+
interface RecoveryVerifyRequest {
|
|
229
|
+
code: string;
|
|
230
|
+
}
|
|
231
|
+
interface RecoveryVerifyResponse {
|
|
232
|
+
challenge_passed: boolean;
|
|
233
|
+
codes_remaining: number;
|
|
234
|
+
}
|
|
235
|
+
interface RegisterBeginRequest {
|
|
236
|
+
display_name?: string;
|
|
237
|
+
}
|
|
238
|
+
interface RegisterBeginResponse {
|
|
239
|
+
options: Record<string, unknown>;
|
|
240
|
+
}
|
|
241
|
+
interface RegisterFinishRequest {
|
|
242
|
+
}
|
|
243
|
+
interface RegisterFinishResponse {
|
|
244
|
+
display_name: string;
|
|
245
|
+
id: string;
|
|
246
|
+
status: string;
|
|
247
|
+
}
|
|
248
|
+
interface RemoveMemberRequest {
|
|
249
|
+
MemberID: string;
|
|
250
|
+
OrgID: string;
|
|
251
|
+
}
|
|
252
|
+
interface RemovePermissionRequest {
|
|
253
|
+
PermissionID: string;
|
|
254
|
+
RoleID: string;
|
|
255
|
+
}
|
|
256
|
+
interface RevokeKeyRequest {
|
|
257
|
+
KeyID: string;
|
|
258
|
+
}
|
|
259
|
+
interface RevokeSessionRequest {
|
|
260
|
+
SessionID: string;
|
|
261
|
+
}
|
|
262
|
+
interface Role {
|
|
263
|
+
app_id: string;
|
|
264
|
+
created_at: string;
|
|
265
|
+
description?: string;
|
|
266
|
+
id: string;
|
|
267
|
+
name: string;
|
|
268
|
+
parent_id?: string;
|
|
269
|
+
slug: string;
|
|
270
|
+
updated_at: string;
|
|
271
|
+
}
|
|
272
|
+
interface RoleListResponse {
|
|
273
|
+
roles: Role[];
|
|
274
|
+
}
|
|
275
|
+
interface SMSSendRequest {
|
|
276
|
+
phone?: string;
|
|
277
|
+
}
|
|
278
|
+
interface SMSSendResponse {
|
|
279
|
+
expires_in_seconds: number;
|
|
280
|
+
phone_masked: string;
|
|
281
|
+
sent: boolean;
|
|
282
|
+
}
|
|
283
|
+
interface SMSVerifyRequest {
|
|
284
|
+
code: string;
|
|
285
|
+
}
|
|
286
|
+
interface SMSVerifyResponse {
|
|
287
|
+
method: string;
|
|
288
|
+
verified: boolean;
|
|
289
|
+
}
|
|
290
|
+
interface SendRequest {
|
|
291
|
+
app_id?: string;
|
|
292
|
+
email: string;
|
|
293
|
+
}
|
|
294
|
+
interface SendResponse {
|
|
295
|
+
status: string;
|
|
296
|
+
}
|
|
297
|
+
interface SessionListResponse {
|
|
298
|
+
sessions: Record<string, unknown>[];
|
|
299
|
+
}
|
|
300
|
+
interface SignOutRequest {
|
|
301
|
+
}
|
|
302
|
+
interface SlugAvailableResponse {
|
|
303
|
+
available: boolean;
|
|
304
|
+
}
|
|
305
|
+
interface StartRequest {
|
|
306
|
+
Provider: string;
|
|
307
|
+
}
|
|
308
|
+
interface StartResponse {
|
|
309
|
+
auth_url: string;
|
|
310
|
+
}
|
|
311
|
+
interface StatusResponse {
|
|
312
|
+
status: string;
|
|
313
|
+
}
|
|
314
|
+
interface Team {
|
|
315
|
+
created_at: string;
|
|
316
|
+
id: ID;
|
|
317
|
+
name: string;
|
|
318
|
+
org_id: ID;
|
|
319
|
+
slug: string;
|
|
320
|
+
updated_at: string;
|
|
321
|
+
}
|
|
322
|
+
interface TeamListResponse {
|
|
323
|
+
teams: Team[];
|
|
324
|
+
}
|
|
325
|
+
interface TokenResponse {
|
|
326
|
+
expires_at: string;
|
|
327
|
+
refresh_token: string;
|
|
328
|
+
session_token: string;
|
|
329
|
+
}
|
|
330
|
+
interface TrustDeviceRequest {
|
|
331
|
+
DeviceID: string;
|
|
332
|
+
}
|
|
333
|
+
interface User {
|
|
334
|
+
app_id: ID;
|
|
335
|
+
ban_expires?: string;
|
|
336
|
+
ban_reason?: string;
|
|
337
|
+
banned: boolean;
|
|
338
|
+
created_at: string;
|
|
339
|
+
deleted_at?: string;
|
|
340
|
+
display_username?: string;
|
|
341
|
+
email: string;
|
|
342
|
+
email_verified: boolean;
|
|
343
|
+
id: ID;
|
|
344
|
+
image?: string;
|
|
345
|
+
metadata?: Record<string, unknown>;
|
|
346
|
+
name: string;
|
|
347
|
+
phone?: string;
|
|
348
|
+
phone_verified: boolean;
|
|
349
|
+
updated_at: string;
|
|
350
|
+
username?: string;
|
|
351
|
+
}
|
|
352
|
+
interface UserRoleListResponse {
|
|
353
|
+
roles: Role[];
|
|
354
|
+
}
|
|
355
|
+
interface VerifyMFARequest {
|
|
356
|
+
code: string;
|
|
357
|
+
}
|
|
358
|
+
interface VerifyMFAResponse {
|
|
359
|
+
method: string;
|
|
360
|
+
recovery_codes?: string[];
|
|
361
|
+
verified: boolean;
|
|
362
|
+
}
|
|
363
|
+
interface VerifyRequest {
|
|
364
|
+
app_id?: string;
|
|
365
|
+
token: string;
|
|
366
|
+
}
|
|
367
|
+
interface VerifyResponse {
|
|
368
|
+
expires_at: string;
|
|
369
|
+
refresh_token: string;
|
|
370
|
+
session_token: string;
|
|
371
|
+
user: User;
|
|
372
|
+
}
|
|
373
|
+
interface Webhook {
|
|
374
|
+
active: boolean;
|
|
375
|
+
app_id: ID;
|
|
376
|
+
created_at: string;
|
|
377
|
+
events: string[];
|
|
378
|
+
id: ID;
|
|
379
|
+
updated_at: string;
|
|
380
|
+
url: string;
|
|
381
|
+
}
|
|
382
|
+
interface WebhookListResponse {
|
|
383
|
+
webhooks: Webhook[];
|
|
384
|
+
}
|
|
385
|
+
type AdminBanUserRequest = {
|
|
386
|
+
expires_at?: string;
|
|
387
|
+
reason?: string;
|
|
388
|
+
};
|
|
389
|
+
type ChangePasswordRequest = {
|
|
390
|
+
current_password: string;
|
|
391
|
+
new_password: string;
|
|
392
|
+
};
|
|
393
|
+
type ForgotPasswordRequest = {
|
|
394
|
+
app_id?: string;
|
|
395
|
+
email: string;
|
|
396
|
+
};
|
|
397
|
+
type CreateAPIKeyRequest = CreateKeyRequest;
|
|
398
|
+
type RevokeAPIKeyRequest = RevokeKeyRequest;
|
|
399
|
+
type SendMagicLinkRequest = SendRequest;
|
|
400
|
+
type VerifyMagicLinkRequest = VerifyRequest;
|
|
401
|
+
type UpdateMeRequest = {
|
|
402
|
+
image?: string;
|
|
403
|
+
name?: string;
|
|
404
|
+
username?: string;
|
|
405
|
+
};
|
|
406
|
+
type DeleteMeRequest = DeleteAccountRequest;
|
|
407
|
+
type ChallengeMFARequest = ChallengeRequest;
|
|
408
|
+
type EnrollMFARequest = EnrollRequest;
|
|
409
|
+
type DisableMFARequest = DisableRequest;
|
|
410
|
+
type RegenerateMFARecoveryCodesRequest = RecoveryRegenerateRequest;
|
|
411
|
+
type VerifyRecoveryCodeRequest = RecoveryVerifyRequest;
|
|
412
|
+
type SendSMSCodeRequest = SMSSendRequest;
|
|
413
|
+
type VerifySMSCodeRequest = SMSVerifyRequest;
|
|
414
|
+
type CreateOrganizationRequest = {
|
|
415
|
+
app_id?: string;
|
|
416
|
+
logo?: string;
|
|
417
|
+
name: string;
|
|
418
|
+
slug: string;
|
|
419
|
+
};
|
|
420
|
+
type AcceptInvitationRequest = {
|
|
421
|
+
token: string;
|
|
422
|
+
};
|
|
423
|
+
type DeclineInvitationRequest = {
|
|
424
|
+
token: string;
|
|
425
|
+
};
|
|
426
|
+
type UpdateOrganizationRequest = {
|
|
427
|
+
logo?: string;
|
|
428
|
+
name?: string;
|
|
429
|
+
};
|
|
430
|
+
type DeleteOrganizationRequest = DeleteOrgRequest;
|
|
431
|
+
type CreateInvitationRequest = {
|
|
432
|
+
email: string;
|
|
433
|
+
role?: string;
|
|
434
|
+
};
|
|
435
|
+
type AddMemberRequest = {
|
|
436
|
+
role?: string;
|
|
437
|
+
user_id: string;
|
|
438
|
+
};
|
|
439
|
+
type UpdateMemberRequest = {
|
|
440
|
+
role: string;
|
|
441
|
+
};
|
|
442
|
+
type CreateTeamRequest = {
|
|
443
|
+
name: string;
|
|
444
|
+
slug: string;
|
|
445
|
+
};
|
|
446
|
+
type UpdateTeamRequest = {
|
|
447
|
+
name?: string;
|
|
448
|
+
slug?: string;
|
|
449
|
+
};
|
|
450
|
+
type PasskeyLoginBeginRequest = LoginBeginRequest;
|
|
451
|
+
type PasskeyLoginFinishRequest = LoginFinishRequest;
|
|
452
|
+
type PasskeyRegisterBeginRequest = RegisterBeginRequest;
|
|
453
|
+
type PasskeyRegisterFinishRequest = RegisterFinishRequest;
|
|
454
|
+
type DeletePasskeyRequest = DeleteRequest;
|
|
455
|
+
type RefreshRequest = {
|
|
456
|
+
refresh_token: string;
|
|
457
|
+
};
|
|
458
|
+
type ResetPasswordRequest = {
|
|
459
|
+
new_password: string;
|
|
460
|
+
token: string;
|
|
461
|
+
};
|
|
462
|
+
type CreateRoleRequest = {
|
|
463
|
+
app_id?: string;
|
|
464
|
+
description?: string;
|
|
465
|
+
name: string;
|
|
466
|
+
parent_id?: string;
|
|
467
|
+
slug: string;
|
|
468
|
+
};
|
|
469
|
+
type UpdateRoleRequest = {
|
|
470
|
+
description?: string;
|
|
471
|
+
name?: string;
|
|
472
|
+
parent_id?: string;
|
|
473
|
+
};
|
|
474
|
+
type AssignRoleRequest = {
|
|
475
|
+
org_id?: string;
|
|
476
|
+
user_id: string;
|
|
477
|
+
};
|
|
478
|
+
type AddPermissionRequest = {
|
|
479
|
+
action: string;
|
|
480
|
+
resource: string;
|
|
481
|
+
};
|
|
482
|
+
type UnassignRoleRequest = {
|
|
483
|
+
user_id: string;
|
|
484
|
+
};
|
|
485
|
+
type SignInRequest = {
|
|
486
|
+
app_id?: string;
|
|
487
|
+
email?: string;
|
|
488
|
+
password: string;
|
|
489
|
+
username?: string;
|
|
490
|
+
};
|
|
491
|
+
type SignUpRequest = {
|
|
492
|
+
app_id?: string;
|
|
493
|
+
email: string;
|
|
494
|
+
name?: string;
|
|
495
|
+
password: string;
|
|
496
|
+
username?: string;
|
|
497
|
+
};
|
|
498
|
+
type StartOAuthRequest = StartRequest;
|
|
499
|
+
type SsoACSRequest = ACSRequest;
|
|
500
|
+
type SsoCallbackRequest = CallbackRequest;
|
|
501
|
+
type StartSSOLoginRequest = LoginRequest;
|
|
502
|
+
type VerifyEmailRequest = {
|
|
503
|
+
token: string;
|
|
504
|
+
};
|
|
505
|
+
type CreateWebhookRequest = {
|
|
506
|
+
app_id?: string;
|
|
507
|
+
events: string[];
|
|
508
|
+
url: string;
|
|
509
|
+
};
|
|
510
|
+
type UpdateWebhookRequest = {
|
|
511
|
+
active?: boolean;
|
|
512
|
+
events?: string[];
|
|
513
|
+
url?: string;
|
|
514
|
+
};
|
|
6
515
|
|
|
7
|
-
/**
|
|
8
|
-
* Error handling utilities
|
|
9
|
-
*/
|
|
516
|
+
/** Core type definitions for AuthSome UI Kit. */
|
|
10
517
|
|
|
518
|
+
interface Session {
|
|
519
|
+
session_token: string;
|
|
520
|
+
refresh_token: string;
|
|
521
|
+
expires_at: string;
|
|
522
|
+
}
|
|
523
|
+
/** API error response. */
|
|
524
|
+
interface APIError {
|
|
525
|
+
error: string;
|
|
526
|
+
code?: number;
|
|
527
|
+
}
|
|
528
|
+
/** Authentication state. */
|
|
529
|
+
type AuthState = {
|
|
530
|
+
status: "idle";
|
|
531
|
+
} | {
|
|
532
|
+
status: "loading";
|
|
533
|
+
} | {
|
|
534
|
+
status: "authenticated";
|
|
535
|
+
user: User;
|
|
536
|
+
session: Session;
|
|
537
|
+
} | {
|
|
538
|
+
status: "unauthenticated";
|
|
539
|
+
} | {
|
|
540
|
+
status: "mfa_required";
|
|
541
|
+
session: Session;
|
|
542
|
+
} | {
|
|
543
|
+
status: "error";
|
|
544
|
+
error: string;
|
|
545
|
+
};
|
|
546
|
+
/** Configuration for the AuthSome client. */
|
|
547
|
+
interface AuthConfig {
|
|
548
|
+
/** Base URL of the AuthSome API (e.g., "https://api.example.com"). */
|
|
549
|
+
baseURL: string;
|
|
550
|
+
/** Publishable key for auto-discovering enabled auth methods. */
|
|
551
|
+
publishableKey?: string;
|
|
552
|
+
/** Pre-fetched client config (useful for SSR). */
|
|
553
|
+
initialClientConfig?: ClientConfig;
|
|
554
|
+
/** Custom fetch implementation (defaults to global fetch). */
|
|
555
|
+
fetch?: typeof fetch;
|
|
556
|
+
/** Storage implementation for persisting tokens (defaults to localStorage). */
|
|
557
|
+
storage?: TokenStorage;
|
|
558
|
+
/** Callback invoked when the auth state changes. */
|
|
559
|
+
onStateChange?: (state: AuthState) => void;
|
|
560
|
+
/** Callback invoked on authentication error. */
|
|
561
|
+
onError?: (error: APIError) => void;
|
|
562
|
+
}
|
|
563
|
+
/** Social provider info from the backend. */
|
|
564
|
+
interface SocialProviderConfig {
|
|
565
|
+
id: string;
|
|
566
|
+
name: string;
|
|
567
|
+
}
|
|
568
|
+
/** SSO connection info from the backend. */
|
|
569
|
+
interface SSOConnectionConfig {
|
|
570
|
+
id: string;
|
|
571
|
+
name: string;
|
|
572
|
+
}
|
|
11
573
|
/**
|
|
12
|
-
*
|
|
574
|
+
* Client configuration returned by the backend.
|
|
13
575
|
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
declare function createAuthError(type: AuthErrorType, message: string, details?: Record<string, unknown>, code?: string | number): AuthError;
|
|
17
|
-
/**
|
|
18
|
-
* Check if an error is an auth error
|
|
19
|
-
*/
|
|
20
|
-
declare function isAuthError(error: unknown): error is AuthError;
|
|
21
|
-
/**
|
|
22
|
-
* Convert unknown error to auth error
|
|
23
|
-
*/
|
|
24
|
-
declare function toAuthError(error: unknown): AuthError;
|
|
25
|
-
/**
|
|
26
|
-
* Check if error is a network error
|
|
27
|
-
*/
|
|
28
|
-
declare function isNetworkError(error: unknown): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Check if error indicates authentication is required
|
|
576
|
+
* Describes which auth methods are enabled so SDK components
|
|
577
|
+
* can auto-configure their UI without manual props.
|
|
31
578
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Internationalization (i18n) types and interfaces
|
|
40
|
-
*/
|
|
41
|
-
/**
|
|
42
|
-
* Complete locale interface for all auth-related text
|
|
43
|
-
*/
|
|
44
|
-
interface AuthLocale {
|
|
45
|
-
common: {
|
|
46
|
-
loading: string;
|
|
47
|
-
submit: string;
|
|
48
|
-
cancel: string;
|
|
49
|
-
continue: string;
|
|
50
|
-
back: string;
|
|
51
|
-
or: string;
|
|
52
|
-
optional: string;
|
|
53
|
-
};
|
|
54
|
-
auth: {
|
|
55
|
-
signIn: string;
|
|
56
|
-
signUp: string;
|
|
57
|
-
signOut: string;
|
|
58
|
-
email: string;
|
|
59
|
-
password: string;
|
|
60
|
-
confirmPassword: string;
|
|
61
|
-
username: string;
|
|
62
|
-
phone: string;
|
|
63
|
-
rememberMe: string;
|
|
64
|
-
forgotPassword: string;
|
|
65
|
-
continueWith: string;
|
|
66
|
-
orContinueWith: string;
|
|
67
|
-
};
|
|
68
|
-
oauth: {
|
|
69
|
-
google: string;
|
|
70
|
-
github: string;
|
|
71
|
-
microsoft: string;
|
|
72
|
-
facebook: string;
|
|
73
|
-
apple: string;
|
|
74
|
-
discord: string;
|
|
75
|
-
twitter: string;
|
|
76
|
-
linkedin: string;
|
|
77
|
-
chooseProvider: string;
|
|
78
|
-
signInPreferred: string;
|
|
79
|
-
};
|
|
80
|
-
magicLink: {
|
|
81
|
-
sendLink: string;
|
|
82
|
-
checkEmail: string;
|
|
83
|
-
linkSent: string;
|
|
84
|
-
enterEmail: string;
|
|
579
|
+
interface ClientConfig {
|
|
580
|
+
version?: string;
|
|
581
|
+
app_id?: string;
|
|
582
|
+
branding?: {
|
|
583
|
+
app_name?: string;
|
|
584
|
+
logo_url?: string;
|
|
85
585
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
sendCode: string;
|
|
89
|
-
enterCode: string;
|
|
90
|
-
verifyPhone: string;
|
|
91
|
-
codeLabel: string;
|
|
586
|
+
password?: {
|
|
587
|
+
enabled: boolean;
|
|
92
588
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
verify: string;
|
|
97
|
-
enterCode: string;
|
|
98
|
-
sms: string;
|
|
99
|
-
authenticator: string;
|
|
100
|
-
email: string;
|
|
589
|
+
social?: {
|
|
590
|
+
enabled: boolean;
|
|
591
|
+
providers: SocialProviderConfig[];
|
|
101
592
|
};
|
|
102
|
-
passkey
|
|
103
|
-
|
|
104
|
-
register: string;
|
|
105
|
-
usePasskey: string;
|
|
593
|
+
passkey?: {
|
|
594
|
+
enabled: boolean;
|
|
106
595
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
haveAccount: string;
|
|
111
|
-
signInLink: string;
|
|
112
|
-
agreeToTerms: string;
|
|
113
|
-
terms: string;
|
|
596
|
+
mfa?: {
|
|
597
|
+
enabled: boolean;
|
|
598
|
+
methods: string[];
|
|
114
599
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
subtitle: string;
|
|
118
|
-
noAccount: string;
|
|
119
|
-
signUpLink: string;
|
|
120
|
-
enterEmail: string;
|
|
600
|
+
magiclink?: {
|
|
601
|
+
enabled: boolean;
|
|
121
602
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
passwordRequired: string;
|
|
126
|
-
passwordTooShort: string;
|
|
127
|
-
passwordRequireUppercase: string;
|
|
128
|
-
passwordRequireLowercase: string;
|
|
129
|
-
passwordRequireNumber: string;
|
|
130
|
-
passwordRequireSpecial: string;
|
|
131
|
-
passwordMismatch: string;
|
|
132
|
-
usernameRequired: string;
|
|
133
|
-
usernameInvalid: string;
|
|
134
|
-
phoneRequired: string;
|
|
135
|
-
phoneInvalid: string;
|
|
136
|
-
codeRequired: string;
|
|
137
|
-
codeInvalid: string;
|
|
138
|
-
fieldRequired: string;
|
|
139
|
-
termsRequired: string;
|
|
140
|
-
};
|
|
141
|
-
errors: {
|
|
142
|
-
invalidCredentials: string;
|
|
143
|
-
userNotFound: string;
|
|
144
|
-
userExists: string;
|
|
145
|
-
invalidToken: string;
|
|
146
|
-
tokenExpired: string;
|
|
147
|
-
networkError: string;
|
|
148
|
-
mfaRequired: string;
|
|
149
|
-
emailNotVerified: string;
|
|
150
|
-
phoneNotVerified: string;
|
|
151
|
-
rateLimitExceeded: string;
|
|
152
|
-
unknownError: string;
|
|
153
|
-
generic: string;
|
|
154
|
-
};
|
|
155
|
-
success: {
|
|
156
|
-
signedIn: string;
|
|
157
|
-
signedUp: string;
|
|
158
|
-
signedOut: string;
|
|
159
|
-
linkSent: string;
|
|
160
|
-
codeSent: string;
|
|
161
|
-
verified: string;
|
|
162
|
-
welcome: string;
|
|
163
|
-
};
|
|
164
|
-
placeholders: {
|
|
165
|
-
email: string;
|
|
166
|
-
password: string;
|
|
167
|
-
confirmPassword: string;
|
|
168
|
-
username: string;
|
|
169
|
-
phone: string;
|
|
170
|
-
code: string;
|
|
171
|
-
fullName: string;
|
|
603
|
+
sso?: {
|
|
604
|
+
enabled: boolean;
|
|
605
|
+
connections: SSOConnectionConfig[];
|
|
172
606
|
};
|
|
607
|
+
/** List of server-side plugin names that are installed and active. */
|
|
608
|
+
supported_plugins?: string[];
|
|
609
|
+
}
|
|
610
|
+
/** Interface for persisting tokens across sessions. */
|
|
611
|
+
interface TokenStorage {
|
|
612
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
613
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
614
|
+
removeItem(key: string): void | Promise<void>;
|
|
173
615
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Deep partial type for locale overrides
|
|
176
|
-
*/
|
|
177
|
-
type DeepPartial<T> = {
|
|
178
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Validation utilities
|
|
183
|
-
*/
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Validate email address
|
|
187
|
-
*/
|
|
188
|
-
declare function validateEmail(email: string, locale?: AuthLocale): ValidationError | null;
|
|
189
|
-
/**
|
|
190
|
-
* Validate password
|
|
191
|
-
*/
|
|
192
|
-
declare function validatePassword(password: string, options?: {
|
|
193
|
-
minLength?: number;
|
|
194
|
-
requireUppercase?: boolean;
|
|
195
|
-
requireLowercase?: boolean;
|
|
196
|
-
requireNumber?: boolean;
|
|
197
|
-
requireSpecial?: boolean;
|
|
198
|
-
locale?: AuthLocale;
|
|
199
|
-
}): ValidationError | null;
|
|
200
|
-
/**
|
|
201
|
-
* Validate phone number
|
|
202
|
-
*/
|
|
203
|
-
declare function validatePhone(phone: string, locale?: AuthLocale): ValidationError | null;
|
|
204
|
-
/**
|
|
205
|
-
* Validate username
|
|
206
|
-
*/
|
|
207
|
-
declare function validateUsername(username: string, locale?: AuthLocale): ValidationError | null;
|
|
208
|
-
/**
|
|
209
|
-
* Validate 2FA code
|
|
210
|
-
*/
|
|
211
|
-
declare function validate2FACode(code: string, locale?: AuthLocale): ValidationError | null;
|
|
212
|
-
/**
|
|
213
|
-
* Validate required field
|
|
214
|
-
*/
|
|
215
|
-
declare function validateRequired(value: unknown, fieldName: string, locale?: AuthLocale): ValidationError | null;
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Token management utilities
|
|
219
|
-
*/
|
|
220
616
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
617
|
+
interface AuthClientConfig {
|
|
618
|
+
/** Base URL of the AuthSome API (e.g., "https://api.example.com") */
|
|
619
|
+
baseURL: string;
|
|
620
|
+
/** Optional custom fetch implementation */
|
|
621
|
+
fetch?: typeof globalThis.fetch;
|
|
622
|
+
}
|
|
623
|
+
declare class AuthClient$1 {
|
|
624
|
+
private baseURL;
|
|
625
|
+
private fetchFn;
|
|
626
|
+
constructor(config: AuthClientConfig | Pick<{
|
|
627
|
+
baseURL: string;
|
|
628
|
+
fetch?: typeof globalThis.fetch;
|
|
629
|
+
}, 'baseURL' | 'fetch'>);
|
|
227
630
|
/**
|
|
228
|
-
* Get
|
|
631
|
+
* Get AuthSome manifest
|
|
632
|
+
* GET /.well-known/authsome/manifest
|
|
229
633
|
*/
|
|
230
|
-
|
|
634
|
+
getManifest(): Promise<Record<string, unknown>>;
|
|
231
635
|
/**
|
|
232
|
-
*
|
|
636
|
+
* Get OpenAPI specification
|
|
637
|
+
* GET /.well-known/authsome/openapi
|
|
233
638
|
*/
|
|
234
|
-
|
|
639
|
+
getOpenAPI(): Promise<Record<string, unknown>>;
|
|
235
640
|
/**
|
|
236
|
-
*
|
|
641
|
+
* Stop impersonation (admin)
|
|
642
|
+
* POST /v1/auth/admin/impersonate/stop
|
|
237
643
|
*/
|
|
238
|
-
|
|
644
|
+
adminStopImpersonation(body: AdminStopImpersonationRequest, token: string): Promise<StatusResponse>;
|
|
239
645
|
/**
|
|
240
|
-
*
|
|
646
|
+
* Impersonate user (admin)
|
|
647
|
+
* POST /v1/auth/admin/impersonate/{userId}
|
|
241
648
|
*/
|
|
242
|
-
|
|
649
|
+
adminImpersonate(userId: string, body: AdminImpersonateRequest, token: string): Promise<AuthResponse>;
|
|
243
650
|
/**
|
|
244
|
-
*
|
|
651
|
+
* List organizations (admin)
|
|
652
|
+
* GET /v1/auth/admin/orgs
|
|
245
653
|
*/
|
|
246
|
-
|
|
654
|
+
adminListOrgs(token: string): Promise<OrgListResponse>;
|
|
247
655
|
/**
|
|
248
|
-
*
|
|
656
|
+
* Get stats (admin)
|
|
657
|
+
* GET /v1/auth/admin/stats
|
|
249
658
|
*/
|
|
250
|
-
|
|
659
|
+
adminGetStats(token: string): Promise<AdminStatsResponse>;
|
|
251
660
|
/**
|
|
252
|
-
*
|
|
661
|
+
* List users (admin)
|
|
662
|
+
* GET /v1/auth/admin/users
|
|
253
663
|
*/
|
|
254
|
-
|
|
664
|
+
adminListUsers(token: string): Promise<AdminUserListResponse>;
|
|
255
665
|
/**
|
|
256
|
-
*
|
|
666
|
+
* Get user (admin)
|
|
667
|
+
* GET /v1/auth/admin/users/{userId}
|
|
257
668
|
*/
|
|
258
|
-
|
|
669
|
+
adminGetUser(userId: string, token: string): Promise<User>;
|
|
259
670
|
/**
|
|
260
|
-
*
|
|
671
|
+
* Delete user (admin)
|
|
672
|
+
* DELETE /v1/auth/admin/users/{userId}
|
|
261
673
|
*/
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Cookie utility functions
|
|
267
|
-
* Framework-agnostic helpers for cookie parsing and serialization
|
|
268
|
-
*/
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Parse Set-Cookie header value into CookieData
|
|
272
|
-
* @param setCookieHeader - The Set-Cookie header value
|
|
273
|
-
* @returns Parsed cookie data
|
|
274
|
-
*/
|
|
275
|
-
declare function parseCookie(setCookieHeader: string): CookieData | null;
|
|
276
|
-
/**
|
|
277
|
-
* Extract multiple cookies from Set-Cookie headers
|
|
278
|
-
* @param setCookieHeaders - Array of Set-Cookie header values or single string
|
|
279
|
-
* @returns Array of parsed cookies
|
|
280
|
-
*/
|
|
281
|
-
declare function extractCookiesFromHeaders(setCookieHeaders: string | string[]): CookieData[];
|
|
282
|
-
/**
|
|
283
|
-
* Serialize a CookieData object into a Set-Cookie header value
|
|
284
|
-
* @param cookie - The cookie data to serialize
|
|
285
|
-
* @returns Set-Cookie header value
|
|
286
|
-
*/
|
|
287
|
-
declare function serializeCookie(cookie: CookieData): string;
|
|
288
|
-
/**
|
|
289
|
-
* Parse Cookie header value into key-value pairs
|
|
290
|
-
* @param cookieHeader - The Cookie header value
|
|
291
|
-
* @returns Object with cookie name-value pairs
|
|
292
|
-
*/
|
|
293
|
-
declare function parseCookieOptions(cookieHeader: string): Record<string, string>;
|
|
294
|
-
/**
|
|
295
|
-
* Convert cookie object to Cookie header string
|
|
296
|
-
* @param cookies - Object with cookie name-value pairs
|
|
297
|
-
* @returns Cookie header value
|
|
298
|
-
*/
|
|
299
|
-
declare function serializeCookies(cookies: Record<string, string>): string;
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Locale utility functions
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Default locale (English)
|
|
307
|
-
*/
|
|
308
|
-
declare const defaultLocale: AuthLocale;
|
|
309
|
-
/**
|
|
310
|
-
* Create a complete locale by merging overrides with the default English locale
|
|
311
|
-
*
|
|
312
|
-
* @param overrides - Partial locale object with custom translations
|
|
313
|
-
* @returns Complete locale object with all required keys
|
|
314
|
-
*
|
|
315
|
-
* @example
|
|
316
|
-
* ```typescript
|
|
317
|
-
* const spanishLocale = createLocale({
|
|
318
|
-
* auth: {
|
|
319
|
-
* signIn: 'Iniciar sesión',
|
|
320
|
-
* signUp: 'Registrarse',
|
|
321
|
-
* }
|
|
322
|
-
* });
|
|
323
|
-
* ```
|
|
324
|
-
*/
|
|
325
|
-
declare function createLocale(overrides?: DeepPartial<AuthLocale>): AuthLocale;
|
|
326
|
-
/**
|
|
327
|
-
* Interpolate template string with values
|
|
328
|
-
*
|
|
329
|
-
* Replaces {key} placeholders with corresponding values from the provided object.
|
|
330
|
-
*
|
|
331
|
-
* @param template - Template string with {key} placeholders
|
|
332
|
-
* @param values - Object with key-value pairs for interpolation
|
|
333
|
-
* @returns Interpolated string
|
|
334
|
-
*
|
|
335
|
-
* @example
|
|
336
|
-
* ```typescript
|
|
337
|
-
* interpolate('Hello, {name}!', { name: 'John' })
|
|
338
|
-
* // Returns: "Hello, John!"
|
|
339
|
-
*
|
|
340
|
-
* interpolate('Password must be at least {min} characters', { min: '8' })
|
|
341
|
-
* // Returns: "Password must be at least 8 characters"
|
|
342
|
-
* ```
|
|
343
|
-
*/
|
|
344
|
-
declare function interpolate(template: string, values: Record<string, string | number>): string;
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Auth client configuration
|
|
348
|
-
*/
|
|
349
|
-
interface AuthClientConfig {
|
|
350
|
-
provider: AuthProvider;
|
|
351
|
-
autoRefresh?: boolean;
|
|
352
|
-
refreshInterval?: number;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Auth client class
|
|
356
|
-
*/
|
|
357
|
-
declare class AuthClient {
|
|
358
|
-
private provider;
|
|
359
|
-
private autoRefresh;
|
|
360
|
-
private refreshInterval;
|
|
361
|
-
private refreshTimer?;
|
|
362
|
-
readonly state: Observable<AuthContext>;
|
|
363
|
-
get adapter(): AuthProvider;
|
|
364
|
-
constructor(config: AuthClientConfig);
|
|
674
|
+
adminDeleteUser(userId: string, body: AdminDeleteUserRequest, token: string): Promise<StatusResponse>;
|
|
365
675
|
/**
|
|
366
|
-
*
|
|
676
|
+
* Ban user (admin)
|
|
677
|
+
* POST /v1/auth/admin/users/{userId}/ban
|
|
367
678
|
*/
|
|
368
|
-
|
|
679
|
+
adminBanUser(userId: string, body: AdminBanUserRequest, token: string): Promise<StatusResponse>;
|
|
369
680
|
/**
|
|
370
|
-
*
|
|
681
|
+
* Unban user (admin)
|
|
682
|
+
* POST /v1/auth/admin/users/{userId}/unban
|
|
371
683
|
*/
|
|
372
|
-
|
|
684
|
+
adminUnbanUser(userId: string, body: AdminUnbanUserRequest, token: string): Promise<StatusResponse>;
|
|
373
685
|
/**
|
|
374
|
-
*
|
|
686
|
+
* Change password
|
|
687
|
+
* POST /v1/auth/change-password
|
|
375
688
|
*/
|
|
376
|
-
|
|
689
|
+
changePassword(body: ChangePasswordRequest, token: string): Promise<StatusResponse>;
|
|
377
690
|
/**
|
|
378
|
-
*
|
|
691
|
+
* List devices
|
|
692
|
+
* GET /v1/auth/devices
|
|
379
693
|
*/
|
|
380
|
-
|
|
694
|
+
listDevices(token: string): Promise<DeviceListResponse>;
|
|
381
695
|
/**
|
|
382
|
-
*
|
|
696
|
+
* Get device
|
|
697
|
+
* GET /v1/auth/devices/{deviceId}
|
|
383
698
|
*/
|
|
384
|
-
|
|
699
|
+
getDevice(deviceId: string, token: string): Promise<Device>;
|
|
385
700
|
/**
|
|
386
|
-
*
|
|
701
|
+
* Delete device
|
|
702
|
+
* DELETE /v1/auth/devices/{deviceId}
|
|
703
|
+
*/
|
|
704
|
+
deleteDevice(deviceId: string, body: DeleteDeviceRequest, token: string): Promise<StatusResponse>;
|
|
705
|
+
/**
|
|
706
|
+
* Trust device
|
|
707
|
+
* PATCH /v1/auth/devices/{deviceId}/trust
|
|
387
708
|
*/
|
|
388
|
-
|
|
709
|
+
trustDevice(deviceId: string, body: TrustDeviceRequest, token: string): Promise<Device>;
|
|
389
710
|
/**
|
|
390
|
-
*
|
|
711
|
+
* Forgot password
|
|
712
|
+
* POST /v1/auth/forgot-password
|
|
391
713
|
*/
|
|
392
|
-
|
|
714
|
+
forgotPassword(body: ForgotPasswordRequest): Promise<ForgotPasswordResponse>;
|
|
393
715
|
/**
|
|
394
|
-
*
|
|
716
|
+
* Health check
|
|
717
|
+
* GET /v1/auth/health
|
|
395
718
|
*/
|
|
396
|
-
|
|
719
|
+
getHealth(): Promise<HealthResponse>;
|
|
397
720
|
/**
|
|
398
|
-
*
|
|
721
|
+
* List API keys
|
|
722
|
+
* GET /v1/auth/keys
|
|
399
723
|
*/
|
|
400
|
-
|
|
724
|
+
listAPIKeys(token: string): Promise<ListKeysResponse>;
|
|
401
725
|
/**
|
|
402
|
-
*
|
|
726
|
+
* Create API key
|
|
727
|
+
* POST /v1/auth/keys
|
|
403
728
|
*/
|
|
404
|
-
|
|
729
|
+
createAPIKey(body: CreateAPIKeyRequest, token: string): Promise<CreateKeyResponse>;
|
|
405
730
|
/**
|
|
406
|
-
*
|
|
731
|
+
* Revoke API key
|
|
732
|
+
* DELETE /v1/auth/keys/{keyId}
|
|
407
733
|
*/
|
|
408
|
-
|
|
734
|
+
revokeAPIKey(keyId: string, body: RevokeAPIKeyRequest, token: string): Promise<void>;
|
|
409
735
|
/**
|
|
410
736
|
* Send magic link
|
|
737
|
+
* POST /v1/auth/magic-link/send
|
|
411
738
|
*/
|
|
412
|
-
sendMagicLink(
|
|
739
|
+
sendMagicLink(body: SendMagicLinkRequest): Promise<SendResponse>;
|
|
413
740
|
/**
|
|
414
741
|
* Verify magic link
|
|
742
|
+
* POST /v1/auth/magic-link/verify
|
|
743
|
+
*/
|
|
744
|
+
verifyMagicLink(body: VerifyMagicLinkRequest): Promise<VerifyResponse>;
|
|
745
|
+
/**
|
|
746
|
+
* Get current user
|
|
747
|
+
* GET /v1/auth/me
|
|
748
|
+
*/
|
|
749
|
+
getMe(token: string): Promise<User>;
|
|
750
|
+
/**
|
|
751
|
+
* Update current user
|
|
752
|
+
* PATCH /v1/auth/me
|
|
753
|
+
*/
|
|
754
|
+
updateMe(body: UpdateMeRequest, token: string): Promise<User>;
|
|
755
|
+
/**
|
|
756
|
+
* Delete account
|
|
757
|
+
* DELETE /v1/auth/me
|
|
758
|
+
*/
|
|
759
|
+
deleteMe(body: DeleteMeRequest, token: string): Promise<StatusResponse>;
|
|
760
|
+
/**
|
|
761
|
+
* Export user data
|
|
762
|
+
* GET /v1/auth/me/export
|
|
415
763
|
*/
|
|
416
|
-
|
|
764
|
+
exportMyData(token: string): Promise<Record<string, unknown>>;
|
|
417
765
|
/**
|
|
418
|
-
*
|
|
766
|
+
* MFA challenge
|
|
767
|
+
* POST /v1/auth/mfa/challenge
|
|
419
768
|
*/
|
|
420
|
-
|
|
769
|
+
challengeMFA(body: ChallengeMFARequest): Promise<ChallengeResponse>;
|
|
421
770
|
/**
|
|
422
|
-
*
|
|
771
|
+
* Enroll in MFA
|
|
772
|
+
* POST /v1/auth/mfa/enroll
|
|
423
773
|
*/
|
|
424
|
-
|
|
774
|
+
enrollMFA(body: EnrollMFARequest, token: string): Promise<EnrollResponse>;
|
|
425
775
|
/**
|
|
426
|
-
*
|
|
776
|
+
* Disable MFA
|
|
777
|
+
* DELETE /v1/auth/mfa/enrollment
|
|
427
778
|
*/
|
|
428
|
-
|
|
779
|
+
disableMFA(body: DisableMFARequest, token: string): Promise<DisableResponse>;
|
|
429
780
|
/**
|
|
430
|
-
*
|
|
781
|
+
* Regenerate MFA recovery codes
|
|
782
|
+
* POST /v1/auth/mfa/recovery/regenerate
|
|
431
783
|
*/
|
|
432
|
-
|
|
784
|
+
regenerateMFARecoveryCodes(body: RegenerateMFARecoveryCodesRequest, token: string): Promise<RecoveryRegenerateResponse>;
|
|
433
785
|
/**
|
|
434
|
-
*
|
|
786
|
+
* Verify MFA recovery code
|
|
787
|
+
* POST /v1/auth/mfa/recovery/verify
|
|
435
788
|
*/
|
|
436
|
-
|
|
789
|
+
verifyRecoveryCode(body: VerifyRecoveryCodeRequest): Promise<RecoveryVerifyResponse>;
|
|
437
790
|
/**
|
|
438
|
-
*
|
|
791
|
+
* Send SMS verification code
|
|
792
|
+
* POST /v1/auth/mfa/sms/send
|
|
439
793
|
*/
|
|
440
|
-
|
|
794
|
+
sendSMSCode(body: SendSMSCodeRequest, token: string): Promise<SMSSendResponse>;
|
|
441
795
|
/**
|
|
442
|
-
*
|
|
796
|
+
* Verify SMS code
|
|
797
|
+
* POST /v1/auth/mfa/sms/verify
|
|
443
798
|
*/
|
|
444
|
-
|
|
799
|
+
verifySMSCode(body: VerifySMSCodeRequest, token: string): Promise<SMSVerifyResponse>;
|
|
445
800
|
/**
|
|
446
|
-
*
|
|
801
|
+
* Verify MFA code
|
|
802
|
+
* POST /v1/auth/mfa/verify
|
|
447
803
|
*/
|
|
448
|
-
|
|
804
|
+
verifyMFA(body: VerifyMFARequest): Promise<VerifyMFAResponse>;
|
|
805
|
+
/**
|
|
806
|
+
* List organizations
|
|
807
|
+
* GET /v1/auth/orgs
|
|
808
|
+
*/
|
|
809
|
+
listOrganizations(token: string): Promise<OrgListResponse>;
|
|
810
|
+
/**
|
|
811
|
+
* Create organization
|
|
812
|
+
* POST /v1/auth/orgs
|
|
813
|
+
*/
|
|
814
|
+
createOrganization(body: CreateOrganizationRequest, token: string): Promise<Organization>;
|
|
815
|
+
/**
|
|
816
|
+
* Check slug availability
|
|
817
|
+
* GET /v1/auth/orgs/check-slug
|
|
818
|
+
*/
|
|
819
|
+
checkOrgSlug(token: string): Promise<SlugAvailableResponse>;
|
|
820
|
+
/**
|
|
821
|
+
* Accept invitation
|
|
822
|
+
* POST /v1/auth/orgs/invitations/accept
|
|
823
|
+
*/
|
|
824
|
+
acceptInvitation(body: AcceptInvitationRequest, token: string): Promise<Member>;
|
|
825
|
+
/**
|
|
826
|
+
* Decline invitation
|
|
827
|
+
* POST /v1/auth/orgs/invitations/decline
|
|
828
|
+
*/
|
|
829
|
+
declineInvitation(body: DeclineInvitationRequest, token: string): Promise<StatusResponse>;
|
|
830
|
+
/**
|
|
831
|
+
* Get organization
|
|
832
|
+
* GET /v1/auth/orgs/{orgId}
|
|
833
|
+
*/
|
|
834
|
+
getOrganization(orgId: string, token: string): Promise<Organization>;
|
|
835
|
+
/**
|
|
836
|
+
* Update organization
|
|
837
|
+
* PATCH /v1/auth/orgs/{orgId}
|
|
838
|
+
*/
|
|
839
|
+
updateOrganization(orgId: string, body: UpdateOrganizationRequest, token: string): Promise<Organization>;
|
|
840
|
+
/**
|
|
841
|
+
* Delete organization
|
|
842
|
+
* DELETE /v1/auth/orgs/{orgId}
|
|
843
|
+
*/
|
|
844
|
+
deleteOrganization(orgId: string, body: DeleteOrganizationRequest, token: string): Promise<StatusResponse>;
|
|
845
|
+
/**
|
|
846
|
+
* List invitations
|
|
847
|
+
* GET /v1/auth/orgs/{orgId}/invitations
|
|
848
|
+
*/
|
|
849
|
+
listInvitations(orgId: string, token: string): Promise<InvitationListResponse>;
|
|
850
|
+
/**
|
|
851
|
+
* Create invitation
|
|
852
|
+
* POST /v1/auth/orgs/{orgId}/invitations
|
|
853
|
+
*/
|
|
854
|
+
createInvitation(orgId: string, body: CreateInvitationRequest, token: string): Promise<Invitation>;
|
|
855
|
+
/**
|
|
856
|
+
* List members
|
|
857
|
+
* GET /v1/auth/orgs/{orgId}/members
|
|
858
|
+
*/
|
|
859
|
+
listMembers(orgId: string, token: string): Promise<MemberListResponse>;
|
|
860
|
+
/**
|
|
861
|
+
* Add member
|
|
862
|
+
* POST /v1/auth/orgs/{orgId}/members
|
|
863
|
+
*/
|
|
864
|
+
addMember(orgId: string, body: AddMemberRequest, token: string): Promise<Member>;
|
|
865
|
+
/**
|
|
866
|
+
* Update member role
|
|
867
|
+
* PATCH /v1/auth/orgs/{orgId}/members/{memberId}
|
|
868
|
+
*/
|
|
869
|
+
updateMember(orgId: string, memberId: string, body: UpdateMemberRequest, token: string): Promise<Member>;
|
|
870
|
+
/**
|
|
871
|
+
* Remove member
|
|
872
|
+
* DELETE /v1/auth/orgs/{orgId}/members/{memberId}
|
|
873
|
+
*/
|
|
874
|
+
removeMember(orgId: string, memberId: string, body: RemoveMemberRequest, token: string): Promise<StatusResponse>;
|
|
875
|
+
/**
|
|
876
|
+
* List teams
|
|
877
|
+
* GET /v1/auth/orgs/{orgId}/teams
|
|
878
|
+
*/
|
|
879
|
+
listTeams(orgId: string, token: string): Promise<TeamListResponse>;
|
|
880
|
+
/**
|
|
881
|
+
* Create team
|
|
882
|
+
* POST /v1/auth/orgs/{orgId}/teams
|
|
883
|
+
*/
|
|
884
|
+
createTeam(orgId: string, body: CreateTeamRequest, token: string): Promise<Team>;
|
|
885
|
+
/**
|
|
886
|
+
* Get team
|
|
887
|
+
* GET /v1/auth/orgs/{orgId}/teams/{teamId}
|
|
888
|
+
*/
|
|
889
|
+
getTeam(orgId: string, teamId: string, token: string): Promise<Team>;
|
|
890
|
+
/**
|
|
891
|
+
* Update team
|
|
892
|
+
* PATCH /v1/auth/orgs/{orgId}/teams/{teamId}
|
|
893
|
+
*/
|
|
894
|
+
updateTeam(orgId: string, teamId: string, body: UpdateTeamRequest, token: string): Promise<Team>;
|
|
895
|
+
/**
|
|
896
|
+
* Delete team
|
|
897
|
+
* DELETE /v1/auth/orgs/{orgId}/teams/{teamId}
|
|
898
|
+
*/
|
|
899
|
+
deleteTeam(orgId: string, teamId: string, body: DeleteTeamRequest, token: string): Promise<StatusResponse>;
|
|
449
900
|
/**
|
|
450
901
|
* List passkeys
|
|
902
|
+
* GET /v1/auth/passkeys/
|
|
451
903
|
*/
|
|
452
|
-
listPasskeys(): Promise<
|
|
904
|
+
listPasskeys(token: string): Promise<ListResponse$1>;
|
|
905
|
+
/**
|
|
906
|
+
* Begin passkey login
|
|
907
|
+
* POST /v1/auth/passkeys/login/begin
|
|
908
|
+
*/
|
|
909
|
+
passkeyLoginBegin(body: PasskeyLoginBeginRequest): Promise<LoginBeginResponse>;
|
|
910
|
+
/**
|
|
911
|
+
* Complete passkey login
|
|
912
|
+
* POST /v1/auth/passkeys/login/finish
|
|
913
|
+
*/
|
|
914
|
+
passkeyLoginFinish(body: PasskeyLoginFinishRequest): Promise<LoginFinishResponse>;
|
|
915
|
+
/**
|
|
916
|
+
* Begin passkey registration
|
|
917
|
+
* POST /v1/auth/passkeys/register/begin
|
|
918
|
+
*/
|
|
919
|
+
passkeyRegisterBegin(body: PasskeyRegisterBeginRequest, token: string): Promise<RegisterBeginResponse>;
|
|
920
|
+
/**
|
|
921
|
+
* Complete passkey registration
|
|
922
|
+
* POST /v1/auth/passkeys/register/finish
|
|
923
|
+
*/
|
|
924
|
+
passkeyRegisterFinish(body: PasskeyRegisterFinishRequest, token: string): Promise<RegisterFinishResponse>;
|
|
453
925
|
/**
|
|
454
926
|
* Delete passkey
|
|
927
|
+
* DELETE /v1/auth/passkeys/{credentialId}
|
|
455
928
|
*/
|
|
456
|
-
deletePasskey(credentialId: string): Promise<
|
|
929
|
+
deletePasskey(credentialId: string, body: DeletePasskeyRequest, token: string): Promise<DeleteResponse>;
|
|
457
930
|
/**
|
|
458
|
-
*
|
|
459
|
-
*
|
|
931
|
+
* Refresh tokens
|
|
932
|
+
* POST /v1/auth/refresh
|
|
460
933
|
*/
|
|
461
|
-
|
|
934
|
+
refresh(body: RefreshRequest): Promise<TokenResponse>;
|
|
462
935
|
/**
|
|
463
|
-
*
|
|
464
|
-
*
|
|
936
|
+
* Reset password
|
|
937
|
+
* POST /v1/auth/reset-password
|
|
465
938
|
*/
|
|
466
|
-
|
|
939
|
+
resetPassword(body: ResetPasswordRequest): Promise<StatusResponse>;
|
|
467
940
|
/**
|
|
468
|
-
*
|
|
469
|
-
*
|
|
941
|
+
* List roles
|
|
942
|
+
* GET /v1/auth/roles
|
|
470
943
|
*/
|
|
471
|
-
|
|
944
|
+
listRoles(token: string): Promise<RoleListResponse>;
|
|
472
945
|
/**
|
|
473
|
-
*
|
|
474
|
-
*
|
|
946
|
+
* Create role
|
|
947
|
+
* POST /v1/auth/roles
|
|
475
948
|
*/
|
|
476
|
-
|
|
949
|
+
createRole(body: CreateRoleRequest, token: string): Promise<Role>;
|
|
477
950
|
/**
|
|
478
|
-
*
|
|
951
|
+
* Get role
|
|
952
|
+
* GET /v1/auth/roles/{roleId}
|
|
479
953
|
*/
|
|
480
|
-
|
|
954
|
+
getRole(roleId: string, token: string): Promise<Role>;
|
|
481
955
|
/**
|
|
482
|
-
*
|
|
956
|
+
* Update role
|
|
957
|
+
* PATCH /v1/auth/roles/{roleId}
|
|
483
958
|
*/
|
|
484
|
-
|
|
959
|
+
updateRole(roleId: string, body: UpdateRoleRequest, token: string): Promise<Role>;
|
|
485
960
|
/**
|
|
486
|
-
*
|
|
961
|
+
* Delete role
|
|
962
|
+
* DELETE /v1/auth/roles/{roleId}
|
|
487
963
|
*/
|
|
488
|
-
|
|
964
|
+
deleteRole(roleId: string, body: DeleteRoleRequest, token: string): Promise<StatusResponse>;
|
|
489
965
|
/**
|
|
490
|
-
*
|
|
966
|
+
* Assign role to user
|
|
967
|
+
* POST /v1/auth/roles/{roleId}/assign
|
|
491
968
|
*/
|
|
492
|
-
|
|
969
|
+
assignRole(roleId: string, body: AssignRoleRequest, token: string): Promise<StatusResponse>;
|
|
493
970
|
/**
|
|
494
|
-
*
|
|
971
|
+
* List role permissions
|
|
972
|
+
* GET /v1/auth/roles/{roleId}/permissions
|
|
495
973
|
*/
|
|
496
|
-
|
|
974
|
+
listRolePermissions(roleId: string, token: string): Promise<PermissionListResponse>;
|
|
497
975
|
/**
|
|
498
|
-
*
|
|
976
|
+
* Add permission to role
|
|
977
|
+
* POST /v1/auth/roles/{roleId}/permissions
|
|
499
978
|
*/
|
|
500
|
-
|
|
979
|
+
addPermission(roleId: string, body: AddPermissionRequest, token: string): Promise<Permission>;
|
|
501
980
|
/**
|
|
502
|
-
*
|
|
981
|
+
* Remove permission from role
|
|
982
|
+
* DELETE /v1/auth/roles/{roleId}/permissions/{permissionId}
|
|
503
983
|
*/
|
|
504
|
-
|
|
984
|
+
removePermission(roleId: string, permissionId: string, body: RemovePermissionRequest, token: string): Promise<StatusResponse>;
|
|
505
985
|
/**
|
|
506
|
-
*
|
|
986
|
+
* Unassign role from user
|
|
987
|
+
* POST /v1/auth/roles/{roleId}/unassign
|
|
507
988
|
*/
|
|
508
|
-
|
|
989
|
+
unassignRole(roleId: string, body: UnassignRoleRequest, token: string): Promise<StatusResponse>;
|
|
509
990
|
/**
|
|
510
|
-
*
|
|
991
|
+
* List sessions
|
|
992
|
+
* GET /v1/auth/sessions
|
|
511
993
|
*/
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
private createUnsupportedError;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Authentication flow types and state machine
|
|
523
|
-
*/
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Available authentication flow steps
|
|
527
|
-
*/
|
|
528
|
-
declare enum FlowStep {
|
|
529
|
-
SIGN_IN = "sign_in",
|
|
530
|
-
SIGN_UP = "sign_up",
|
|
531
|
-
EMAIL_PASSWORD_SIGN_IN = "email_password_sign_in",
|
|
532
|
-
EMAIL_PASSWORD_SIGN_UP = "email_password_sign_up",
|
|
533
|
-
OAUTH_SELECT = "oauth_select",
|
|
534
|
-
OAUTH_CALLBACK = "oauth_callback",
|
|
535
|
-
MAGIC_LINK_REQUEST = "magic_link_request",
|
|
536
|
-
MAGIC_LINK_VERIFY = "magic_link_verify",
|
|
537
|
-
MAGIC_LINK_SENT = "magic_link_sent",
|
|
538
|
-
PHONE_REQUEST = "phone_request",
|
|
539
|
-
PHONE_VERIFY = "phone_verify",
|
|
540
|
-
USERNAME_SIGN_IN = "username_sign_in",
|
|
541
|
-
USERNAME_SIGN_UP = "username_sign_up",
|
|
542
|
-
PASSKEY_REGISTER = "passkey_register",
|
|
543
|
-
PASSKEY_AUTHENTICATE = "passkey_authenticate",
|
|
544
|
-
MFA_REQUIRED = "mfa_required",
|
|
545
|
-
MFA_SETUP = "mfa_setup",
|
|
546
|
-
MFA_VERIFY = "mfa_verify",
|
|
547
|
-
MFA_SELECT_METHOD = "mfa_select_method",
|
|
548
|
-
EMAIL_VERIFICATION_REQUIRED = "email_verification_required",
|
|
549
|
-
EMAIL_VERIFICATION_SENT = "email_verification_sent",
|
|
550
|
-
PHONE_VERIFICATION_REQUIRED = "phone_verification_required",
|
|
551
|
-
PASSWORD_RESET_REQUEST = "password_reset_request",
|
|
552
|
-
PASSWORD_RESET_SENT = "password_reset_sent",
|
|
553
|
-
PASSWORD_RESET_CONFIRM = "password_reset_confirm",
|
|
554
|
-
PASSWORD_CHANGE = "password_change",
|
|
555
|
-
PROFILE_UPDATE = "profile_update",
|
|
556
|
-
PROFILE_COMPLETE = "profile_complete",
|
|
557
|
-
SUCCESS = "success",
|
|
558
|
-
ERROR = "error",
|
|
559
|
-
CANCELLED = "cancelled"
|
|
560
|
-
}
|
|
561
|
-
/**
|
|
562
|
-
* Flow state data that can be passed between steps
|
|
563
|
-
*/
|
|
564
|
-
interface FlowState {
|
|
565
|
-
currentStep: FlowStep;
|
|
566
|
-
previousStep?: FlowStep;
|
|
567
|
-
user?: User;
|
|
568
|
-
session?: Session;
|
|
569
|
-
email?: string;
|
|
570
|
-
phone?: string;
|
|
571
|
-
username?: string;
|
|
572
|
-
mfaRequired?: boolean;
|
|
573
|
-
mfaMethods?: TwoFactorMethod[];
|
|
574
|
-
mfaToken?: string;
|
|
575
|
-
oauthProvider?: OAuthProvider;
|
|
576
|
-
oauthRedirectUrl?: string;
|
|
577
|
-
verificationRequired?: boolean;
|
|
578
|
-
verificationToken?: string;
|
|
579
|
-
verificationSent?: boolean;
|
|
580
|
-
error?: AuthError;
|
|
581
|
-
metadata?: Record<string, unknown>;
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Flow transition result
|
|
585
|
-
*/
|
|
586
|
-
interface FlowTransition {
|
|
587
|
-
nextStep: FlowStep;
|
|
588
|
-
state: Partial<FlowState>;
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Flow configuration for a specific authentication journey
|
|
592
|
-
*/
|
|
593
|
-
interface FlowConfig {
|
|
594
|
-
name: string;
|
|
595
|
-
description?: string;
|
|
596
|
-
initialStep: FlowStep;
|
|
597
|
-
allowedSteps: FlowStep[];
|
|
598
|
-
transitions: {
|
|
599
|
-
[key in FlowStep]?: {
|
|
600
|
-
onSuccess?: FlowStep;
|
|
601
|
-
onError?: FlowStep;
|
|
602
|
-
onCancel?: FlowStep;
|
|
603
|
-
onBack?: FlowStep;
|
|
604
|
-
conditions?: Array<{
|
|
605
|
-
when: (state: FlowState) => boolean;
|
|
606
|
-
then: FlowStep;
|
|
607
|
-
}>;
|
|
608
|
-
};
|
|
609
|
-
};
|
|
610
|
-
onStepChange?: (step: FlowStep, state: FlowState) => void;
|
|
611
|
-
onComplete?: (user: User, session: Session) => void;
|
|
612
|
-
onError?: (error: AuthError, state: FlowState) => void;
|
|
613
|
-
onCancel?: (state: FlowState) => void;
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Predefined flow configurations
|
|
617
|
-
*/
|
|
618
|
-
declare enum FlowConfigType {
|
|
619
|
-
SIMPLE_SIGN_IN = "simple_sign_in",
|
|
620
|
-
SIMPLE_SIGN_UP = "simple_sign_up",
|
|
621
|
-
SIGN_UP_WITH_EMAIL_VERIFICATION = "sign_up_with_email_verification",
|
|
622
|
-
SIGN_IN_WITH_MFA = "sign_in_with_mfa",
|
|
623
|
-
OAUTH_SIGN_IN = "oauth_sign_in",
|
|
624
|
-
MAGIC_LINK_FLOW = "magic_link_flow",
|
|
625
|
-
PHONE_AUTH_FLOW = "phone_auth_flow",
|
|
626
|
-
COMPLETE_SIGN_UP_FLOW = "complete_sign_up_flow",// signup → verify email → complete profile
|
|
627
|
-
SECURE_SIGN_IN_FLOW = "secure_sign_in_flow",// signin → MFA → success
|
|
628
|
-
PASSWORD_RESET_FLOW = "password_reset_flow",
|
|
629
|
-
EMAIL_VERIFICATION_FLOW = "email_verification_flow",
|
|
630
|
-
CUSTOM = "custom"
|
|
631
|
-
}
|
|
632
|
-
/**
|
|
633
|
-
* Flow action types
|
|
634
|
-
*/
|
|
635
|
-
declare enum FlowAction {
|
|
636
|
-
START = "start",
|
|
637
|
-
NEXT = "next",
|
|
638
|
-
BACK = "back",
|
|
639
|
-
CANCEL = "cancel",
|
|
640
|
-
ERROR = "error",
|
|
641
|
-
RESET = "reset"
|
|
642
|
-
}
|
|
643
|
-
/**
|
|
644
|
-
* Flow event for state machine
|
|
645
|
-
*/
|
|
646
|
-
interface FlowEvent {
|
|
647
|
-
action: FlowAction;
|
|
648
|
-
data?: Partial<FlowState>;
|
|
649
|
-
error?: AuthError;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* Authentication flow state machine engine
|
|
654
|
-
*/
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Flow engine that manages authentication flow state transitions
|
|
658
|
-
*/
|
|
659
|
-
declare class FlowEngine {
|
|
660
|
-
private config;
|
|
661
|
-
private state;
|
|
662
|
-
private history;
|
|
663
|
-
constructor(config: FlowConfig, initialState?: Partial<FlowState>);
|
|
994
|
+
listSessions(token: string): Promise<SessionListResponse>;
|
|
995
|
+
/**
|
|
996
|
+
* Revoke session
|
|
997
|
+
* DELETE /v1/auth/sessions/{sessionId}
|
|
998
|
+
*/
|
|
999
|
+
revokeSession(sessionId: string, body: RevokeSessionRequest, token: string): Promise<StatusResponse>;
|
|
664
1000
|
/**
|
|
665
|
-
*
|
|
1001
|
+
* Sign in
|
|
1002
|
+
* POST /v1/auth/signin
|
|
666
1003
|
*/
|
|
667
|
-
|
|
1004
|
+
signIn(body: SignInRequest): Promise<AuthResponse>;
|
|
668
1005
|
/**
|
|
669
|
-
*
|
|
1006
|
+
* Sign out
|
|
1007
|
+
* POST /v1/auth/signout
|
|
670
1008
|
*/
|
|
671
|
-
|
|
1009
|
+
signOut(body: SignOutRequest, token: string): Promise<StatusResponse>;
|
|
672
1010
|
/**
|
|
673
|
-
*
|
|
1011
|
+
* Sign up
|
|
1012
|
+
* POST /v1/auth/signup
|
|
674
1013
|
*/
|
|
675
|
-
|
|
1014
|
+
signUp(body: SignUpRequest): Promise<AuthResponse>;
|
|
676
1015
|
/**
|
|
677
|
-
*
|
|
1016
|
+
* Start OAuth flow
|
|
1017
|
+
* POST /v1/auth/social/{provider}
|
|
678
1018
|
*/
|
|
679
|
-
|
|
1019
|
+
startOAuth(provider: string, body: StartOAuthRequest): Promise<StartResponse>;
|
|
680
1020
|
/**
|
|
681
|
-
*
|
|
1021
|
+
* OAuth callback
|
|
1022
|
+
* GET /v1/auth/social/{provider}/callback
|
|
682
1023
|
*/
|
|
683
|
-
|
|
1024
|
+
oauthCallback(provider: string): Promise<CallbackResponse>;
|
|
684
1025
|
/**
|
|
685
|
-
*
|
|
1026
|
+
* SSO SAML ACS endpoint
|
|
1027
|
+
* POST /v1/auth/sso/{provider}/acs
|
|
686
1028
|
*/
|
|
687
|
-
|
|
1029
|
+
ssoACS(provider: string, body: SsoACSRequest): Promise<CallbackResponse>;
|
|
688
1030
|
/**
|
|
689
|
-
*
|
|
1031
|
+
* SSO callback (OIDC)
|
|
1032
|
+
* POST /v1/auth/sso/{provider}/callback
|
|
690
1033
|
*/
|
|
691
|
-
|
|
1034
|
+
ssoCallback(provider: string, body: SsoCallbackRequest): Promise<CallbackResponse>;
|
|
692
1035
|
/**
|
|
693
|
-
*
|
|
1036
|
+
* Start SSO login flow
|
|
1037
|
+
* POST /v1/auth/sso/{provider}/login
|
|
694
1038
|
*/
|
|
695
|
-
|
|
1039
|
+
startSSOLogin(provider: string, body: StartSSOLoginRequest): Promise<LoginResponse>;
|
|
696
1040
|
/**
|
|
697
|
-
*
|
|
1041
|
+
* List user roles
|
|
1042
|
+
* GET /v1/auth/users/{userId}/roles
|
|
698
1043
|
*/
|
|
699
|
-
|
|
1044
|
+
listUserRoles(userId: string, token: string): Promise<UserRoleListResponse>;
|
|
700
1045
|
/**
|
|
701
|
-
*
|
|
1046
|
+
* Verify email
|
|
1047
|
+
* POST /v1/auth/verify-email
|
|
702
1048
|
*/
|
|
703
|
-
|
|
1049
|
+
verifyEmail(body: VerifyEmailRequest): Promise<StatusResponse>;
|
|
704
1050
|
/**
|
|
705
|
-
*
|
|
1051
|
+
* List webhooks
|
|
1052
|
+
* GET /v1/auth/webhooks
|
|
706
1053
|
*/
|
|
707
|
-
|
|
1054
|
+
listWebhooks(token: string): Promise<WebhookListResponse>;
|
|
708
1055
|
/**
|
|
709
|
-
*
|
|
1056
|
+
* Create webhook
|
|
1057
|
+
* POST /v1/auth/webhooks
|
|
710
1058
|
*/
|
|
711
|
-
|
|
1059
|
+
createWebhook(body: CreateWebhookRequest, token: string): Promise<Webhook>;
|
|
712
1060
|
/**
|
|
713
|
-
*
|
|
1061
|
+
* Get webhook
|
|
1062
|
+
* GET /v1/auth/webhooks/{webhookId}
|
|
714
1063
|
*/
|
|
715
|
-
|
|
1064
|
+
getWebhook(webhookId: string, token: string): Promise<Webhook>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Update webhook
|
|
1067
|
+
* PATCH /v1/auth/webhooks/{webhookId}
|
|
1068
|
+
*/
|
|
1069
|
+
updateWebhook(webhookId: string, body: UpdateWebhookRequest, token: string): Promise<Webhook>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Delete webhook
|
|
1072
|
+
* DELETE /v1/auth/webhooks/{webhookId}
|
|
1073
|
+
*/
|
|
1074
|
+
deleteWebhook(webhookId: string, body: DeleteWebhookRequest, token: string): Promise<StatusResponse>;
|
|
1075
|
+
private request;
|
|
1076
|
+
}
|
|
1077
|
+
declare class AuthClientError extends Error {
|
|
1078
|
+
code?: number;
|
|
1079
|
+
constructor(message: string, code?: number);
|
|
716
1080
|
}
|
|
717
1081
|
|
|
718
1082
|
/**
|
|
719
|
-
*
|
|
1083
|
+
* AuthClient adapter — thin wrapper over the auto-generated API client.
|
|
1084
|
+
*
|
|
1085
|
+
* The generated client lives in ./generated/api-client.ts and covers all
|
|
1086
|
+
* core + plugin endpoints. This file extends it with a few convenience
|
|
1087
|
+
* overrides so that auth.ts (and downstream consumers) keep working
|
|
1088
|
+
* without changes.
|
|
720
1089
|
*/
|
|
721
1090
|
|
|
1091
|
+
/** Options for paginated list endpoints. */
|
|
1092
|
+
interface ListOptions {
|
|
1093
|
+
limit?: number;
|
|
1094
|
+
offset?: number;
|
|
1095
|
+
}
|
|
1096
|
+
/** Paginated list response. */
|
|
1097
|
+
interface ListResponse<T> {
|
|
1098
|
+
items: T[];
|
|
1099
|
+
total: number;
|
|
1100
|
+
}
|
|
722
1101
|
/**
|
|
723
|
-
*
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
*
|
|
728
|
-
|
|
729
|
-
declare const signInWithMFAFlow: FlowConfig;
|
|
730
|
-
/**
|
|
731
|
-
* Complete sign-up flow with email verification
|
|
732
|
-
*/
|
|
733
|
-
declare const completeSignUpFlow: FlowConfig;
|
|
734
|
-
/**
|
|
735
|
-
* Magic link authentication flow
|
|
1102
|
+
* AuthClient extends the auto-generated client with backward-compatible
|
|
1103
|
+
* convenience methods that auth.ts depends on.
|
|
1104
|
+
*
|
|
1105
|
+
* All 80+ generated endpoints are inherited as-is. Only two methods
|
|
1106
|
+
* are overridden to preserve the simpler call-site signatures used by
|
|
1107
|
+
* the auth state machine.
|
|
736
1108
|
*/
|
|
737
|
-
declare
|
|
1109
|
+
declare class AuthClient extends AuthClient$1 {
|
|
1110
|
+
/**
|
|
1111
|
+
* Refresh session tokens.
|
|
1112
|
+
*
|
|
1113
|
+
* Accepts a raw refresh-token string (used by auth.ts) or the full
|
|
1114
|
+
* RefreshRequest body.
|
|
1115
|
+
*/
|
|
1116
|
+
refresh(body: {
|
|
1117
|
+
refresh_token: string;
|
|
1118
|
+
} | string): Promise<any>;
|
|
1119
|
+
/**
|
|
1120
|
+
* Sign out.
|
|
1121
|
+
*
|
|
1122
|
+
* Accepts a raw token string (used by auth.ts) or the full
|
|
1123
|
+
* (body, token) pair from the generated client.
|
|
1124
|
+
*/
|
|
1125
|
+
signOut(bodyOrToken: unknown, token?: string): Promise<any>;
|
|
1126
|
+
/**
|
|
1127
|
+
* MFA challenge — bridge for auth.ts.
|
|
1128
|
+
*
|
|
1129
|
+
* auth.ts calls `mfaChallenge({ enrollment_id, code })` and expects
|
|
1130
|
+
* an AuthResponse back. The generated client uses `challengeMFA`.
|
|
1131
|
+
*/
|
|
1132
|
+
mfaChallenge(body: {
|
|
1133
|
+
enrollment_id?: string;
|
|
1134
|
+
code: string;
|
|
1135
|
+
}): Promise<any>;
|
|
1136
|
+
/**
|
|
1137
|
+
* Verify an MFA recovery code.
|
|
1138
|
+
*
|
|
1139
|
+
* Accepts a raw code string (used by auth.ts) or the full request body.
|
|
1140
|
+
*/
|
|
1141
|
+
verifyRecoveryCode(body: {
|
|
1142
|
+
code: string;
|
|
1143
|
+
} | string): Promise<any>;
|
|
1144
|
+
/**
|
|
1145
|
+
* Send an SMS code for MFA — bridge for auth.ts.
|
|
1146
|
+
*
|
|
1147
|
+
* Simplifies the call-site by accepting just the session token.
|
|
1148
|
+
*/
|
|
1149
|
+
sendSMSCodeForMFA(token: string): Promise<any>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Verify an SMS code for MFA — bridge for auth.ts.
|
|
1152
|
+
*
|
|
1153
|
+
* Simplifies the call-site by accepting code + token directly.
|
|
1154
|
+
*/
|
|
1155
|
+
verifySMSCodeForMFA(code: string, token: string): Promise<any>;
|
|
1156
|
+
/**
|
|
1157
|
+
* Fetch the client configuration from the backend.
|
|
1158
|
+
*
|
|
1159
|
+
* The config describes which auth methods are enabled so SDK
|
|
1160
|
+
* components can auto-configure without manual props.
|
|
1161
|
+
*/
|
|
1162
|
+
fetchClientConfig(publishableKey?: string): Promise<ClientConfig>;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
738
1165
|
/**
|
|
739
|
-
*
|
|
1166
|
+
* Framework-agnostic authentication state machine.
|
|
1167
|
+
*
|
|
1168
|
+
* Manages sign-in/sign-up flows, token persistence, automatic refresh,
|
|
1169
|
+
* and MFA challenges. Framework adapters (React, Vue, etc.) wrap this
|
|
1170
|
+
* class and expose reactive state.
|
|
740
1171
|
*/
|
|
741
|
-
|
|
1172
|
+
|
|
742
1173
|
/**
|
|
743
|
-
*
|
|
1174
|
+
* AuthManager is the core state machine that drives authentication.
|
|
1175
|
+
*
|
|
1176
|
+
* Usage:
|
|
1177
|
+
* ```ts
|
|
1178
|
+
* const auth = new AuthManager({ baseURL: "https://api.example.com" });
|
|
1179
|
+
* auth.subscribe((state) => console.log(state));
|
|
1180
|
+
* await auth.initialize(); // hydrate from storage
|
|
1181
|
+
* await auth.signIn({ email, password });
|
|
1182
|
+
* ```
|
|
744
1183
|
*/
|
|
745
|
-
declare
|
|
1184
|
+
declare class AuthManager {
|
|
1185
|
+
private client;
|
|
1186
|
+
private storage;
|
|
1187
|
+
private state;
|
|
1188
|
+
private listeners;
|
|
1189
|
+
private refreshTimer;
|
|
1190
|
+
private onError?;
|
|
1191
|
+
private publishableKey?;
|
|
1192
|
+
private clientConfig;
|
|
1193
|
+
private configListeners;
|
|
1194
|
+
private configFetchPromise;
|
|
1195
|
+
constructor(config: AuthConfig);
|
|
1196
|
+
/** Current auth state (snapshot). */
|
|
1197
|
+
getState(): AuthState;
|
|
1198
|
+
/** Subscribe to state changes. Returns an unsubscribe function. */
|
|
1199
|
+
subscribe(listener: (state: AuthState) => void): () => void;
|
|
1200
|
+
/** Access the underlying HTTP client. */
|
|
1201
|
+
getClient(): AuthClient;
|
|
1202
|
+
/**
|
|
1203
|
+
* Initialize by hydrating the session from storage.
|
|
1204
|
+
* When a publishableKey is set, also fetches client config in parallel.
|
|
1205
|
+
* Call this once on app start.
|
|
1206
|
+
*/
|
|
1207
|
+
initialize(): Promise<void>;
|
|
1208
|
+
/** Sign in with email & password. */
|
|
1209
|
+
signIn(credentials: SignInRequest): Promise<void>;
|
|
1210
|
+
/** Sign up with email & password. */
|
|
1211
|
+
signUp(data: SignUpRequest): Promise<void>;
|
|
1212
|
+
/** Sign out and clear the session. */
|
|
1213
|
+
signOut(): Promise<void>;
|
|
1214
|
+
/** Submit an MFA challenge code. */
|
|
1215
|
+
submitMFACode(enrollmentId: string, code: string): Promise<void>;
|
|
1216
|
+
/** Submit an MFA recovery code. */
|
|
1217
|
+
submitRecoveryCode(code: string): Promise<void>;
|
|
1218
|
+
/** Send an SMS code for MFA verification. Returns masked phone + expiry info. */
|
|
1219
|
+
sendSMSCode(): Promise<{
|
|
1220
|
+
sent: boolean;
|
|
1221
|
+
phone_masked: string;
|
|
1222
|
+
expires_in_seconds: number;
|
|
1223
|
+
}>;
|
|
1224
|
+
/** Submit an SMS verification code during MFA challenge. */
|
|
1225
|
+
submitSMSCode(code: string): Promise<void>;
|
|
1226
|
+
/** Refresh the current session manually. */
|
|
1227
|
+
refreshNow(): Promise<void>;
|
|
1228
|
+
/** Get the current session token (if authenticated). */
|
|
1229
|
+
getSessionToken(): string | null;
|
|
1230
|
+
/** Get the current user (if authenticated). */
|
|
1231
|
+
getUser(): User | null;
|
|
1232
|
+
/** Get the cached client config (or null if not yet fetched). */
|
|
1233
|
+
getClientConfig(): ClientConfig | null;
|
|
1234
|
+
/** Subscribe to client config changes. Returns an unsubscribe function. */
|
|
1235
|
+
subscribeConfig(listener: (config: ClientConfig | null) => void): () => void;
|
|
1236
|
+
/**
|
|
1237
|
+
* Fetch client config from the backend.
|
|
1238
|
+
* Deduplicates concurrent calls and caches the result with a TTL.
|
|
1239
|
+
*/
|
|
1240
|
+
fetchClientConfig(): Promise<ClientConfig>;
|
|
1241
|
+
/** Tear down: clear timers and listeners. */
|
|
1242
|
+
destroy(): void;
|
|
1243
|
+
private handleAuthResponse;
|
|
1244
|
+
private refreshSession;
|
|
1245
|
+
private scheduleRefresh;
|
|
1246
|
+
private clearRefreshTimer;
|
|
1247
|
+
private persistSession;
|
|
1248
|
+
private clearSession;
|
|
1249
|
+
private setClientConfig;
|
|
1250
|
+
private setState;
|
|
1251
|
+
private handleError;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
746
1254
|
/**
|
|
747
|
-
*
|
|
1255
|
+
* WebAuthn encoding helpers.
|
|
1256
|
+
*
|
|
1257
|
+
* The go-webauthn backend serialises binary fields (challenge, user.id,
|
|
1258
|
+
* credential IDs, …) as **base64url strings** in JSON. The browser
|
|
1259
|
+
* WebAuthn API requires those same fields as ArrayBuffer / Uint8Array.
|
|
1260
|
+
*
|
|
1261
|
+
* These helpers bridge the gap in both directions:
|
|
1262
|
+
* begin response → browser API (base64url string → ArrayBuffer)
|
|
1263
|
+
* browser API → finish POST (ArrayBuffer → base64url string)
|
|
748
1264
|
*/
|
|
749
|
-
|
|
1265
|
+
/** Decode a base64url-encoded string into a Uint8Array. */
|
|
1266
|
+
declare function base64urlToBuffer(base64url: string): Uint8Array;
|
|
1267
|
+
/** Encode an ArrayBuffer (or Uint8Array) to a base64url string (no padding). */
|
|
1268
|
+
declare function bufferToBase64url(buffer: ArrayBuffer | Uint8Array): string;
|
|
750
1269
|
/**
|
|
751
|
-
*
|
|
1270
|
+
* Prepare the options object returned by `/passkeys/register/begin`
|
|
1271
|
+
* for `navigator.credentials.create({ publicKey })`.
|
|
1272
|
+
*
|
|
1273
|
+
* Converts base64url strings → Uint8Array for:
|
|
1274
|
+
* challenge, user.id, excludeCredentials[].id
|
|
752
1275
|
*/
|
|
753
|
-
declare
|
|
1276
|
+
declare function prepareCreationOptions(options: Record<string, unknown>): PublicKeyCredentialCreationOptions;
|
|
754
1277
|
/**
|
|
755
|
-
*
|
|
1278
|
+
* Prepare the options object returned by `/passkeys/login/begin`
|
|
1279
|
+
* for `navigator.credentials.get({ publicKey })`.
|
|
1280
|
+
*
|
|
1281
|
+
* Converts base64url strings → Uint8Array for:
|
|
1282
|
+
* challenge, allowCredentials[].id
|
|
756
1283
|
*/
|
|
757
|
-
declare function
|
|
1284
|
+
declare function prepareRequestOptions(options: Record<string, unknown>): PublicKeyCredentialRequestOptions;
|
|
758
1285
|
/**
|
|
759
|
-
*
|
|
1286
|
+
* Serialize a PublicKeyCredential returned by navigator.credentials
|
|
1287
|
+
* into a plain object suitable for POSTing to the `/finish` endpoint.
|
|
1288
|
+
*
|
|
1289
|
+
* Converts ArrayBuffer fields → base64url strings so they survive
|
|
1290
|
+
* JSON.stringify and match what go-webauthn expects.
|
|
760
1291
|
*/
|
|
761
|
-
declare
|
|
762
|
-
simple_sign_in: FlowConfig;
|
|
763
|
-
sign_in_with_mfa: FlowConfig;
|
|
764
|
-
complete_sign_up_flow: FlowConfig;
|
|
765
|
-
magic_link_flow: FlowConfig;
|
|
766
|
-
phone_auth_flow: FlowConfig;
|
|
767
|
-
oauth_sign_in: FlowConfig;
|
|
768
|
-
password_reset_flow: FlowConfig;
|
|
769
|
-
email_verification_flow: FlowConfig;
|
|
770
|
-
};
|
|
1292
|
+
declare function serializeCredential(credential: Credential): Record<string, unknown>;
|
|
771
1293
|
|
|
772
|
-
export {
|
|
1294
|
+
export { type APIError, type KeyListItem as APIKey, type AddMemberRequest, type AdminBanUserRequest, AuthClient, type AuthClientConfig, AuthClientError, type AuthConfig, AuthManager, type AuthResponse, type AuthState, type ChallengeMFARequest, type ChangePasswordRequest, type ClientConfig, type CreateAPIKeyRequest, type CreateInvitationRequest, type CreateOrganizationRequest as CreateOrgRequest, type CreateOrganizationRequest, type Device, type EnrollMFARequest, type EnrollResponse, type ForgotPasswordRequest, type Invitation, type KeyListItem, type ListOptions, type ListResponse, type EnrollResponse as MFAEnrollment, type SendMagicLinkRequest as MagicLinkSendRequest, type VerifyMagicLinkRequest as MagicLinkVerifyRequest, type Member, type ChallengeMFARequest as MfaChallengeRequest, type EnrollMFARequest as MfaEnrollRequest, type SendSMSCodeRequest as MfaSMSSendRequest, type VerifySMSCodeRequest as MfaSMSVerifyRequest, type VerifyMFARequest as MfaVerifyRequest, type Organization, type RefreshRequest, type ResetPasswordRequest, type SSOConnectionConfig, type SendMagicLinkRequest, type SendSMSCodeRequest, type Session, type SignInRequest, type SignUpRequest, type SocialProviderConfig, type SsoACSRequest, type SsoCallbackRequest, type TokenResponse, type TokenStorage, type UpdateMeRequest, type UpdateOrganizationRequest as UpdateOrgRequest, type UpdateOrganizationRequest, type User, type VerifyEmailRequest, type VerifyMFARequest, type VerifyMagicLinkRequest, type VerifyRecoveryCodeRequest, type VerifySMSCodeRequest, base64urlToBuffer, bufferToBase64url, prepareCreationOptions, prepareRequestOptions, serializeCredential };
|