@authsome/ui-core 0.1.9 → 1.1.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 CHANGED
@@ -1,825 +1,1808 @@
1
- import { A as AuthErrorType, a as AuthError, V as ValidationError, C as CookieData, b as AuthContext, c as AuthProvider, S as SignInRequest, d as SignUpRequest, U as UpdateUserRequest, P as PasswordChangeRequest, e as PasswordResetRequest, f as PasswordResetConfirmRequest, O as OAuthSignInRequest, g as OAuthCallbackRequest, h as OAuthProvider, M as MagicLinkRequest, i as MagicLinkVerifyRequest, j as PhoneAuthRequest, k as PhoneVerifyRequest, T as TwoFactorSetupRequest, l as TwoFactorSetupResponse, m as TwoFactorVerifyRequest, n as TwoFactorMethod, o as PasskeyRegisterRequest, p as PasskeyCredential, q as PasskeyAuthRequest, r as Organization, s as OrganizationMembership, t as User, u as Session } from './provider-DWklI8Wr.js';
2
- export { Q as AuthResponse, v as AuthState, a3 as Device, F as DeviceAuthorizeRequest, B as DeviceCodeVerifyRequest, E as DeviceCodeVerifyResponse, D as DeviceFlowInitiateRequest, z as DeviceFlowInitiateResponse, G as DeviceTokenPollRequest, I as DeviceTokenPollResponse, H as DeviceTokenPollStatus, $ as EnrollMFAFactorRequest, L as FieldDefinition, K as FieldType, J as FieldValidation, a5 as ListSessionsOptions, a6 as ListSessionsResponse, a1 as MFAChallengeRequest, a2 as MFAChallengeResponse, _ as MFAFactor, x as OAuthConfig, R as ProviderConfig, W as RequestContext, Z as ResendVerificationRequest, X as SendVerificationEmailRequest, w as SessionData, a4 as SessionInfo, N as SignupFieldsResponse, y as TwoFactorConfig, Y as VerifyEmailRequest, a0 as VerifyMFAFactorRequest } from './provider-DWklI8Wr.js';
3
- import { Storage, Observable, Unsubscribe } from './types/index.js';
4
- export { Listener, LocalStorageAdapter, MemoryStorageAdapter, SessionStorageAdapter } from './types/index.js';
5
- export { BaseAuthProvider } from './adapters/index.js';
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_users: number;
14
+ }
15
+ interface AdminStopImpersonationRequest {
16
+ }
17
+ interface AdminUnbanUserRequest {
18
+ UserID: string;
19
+ }
20
+ interface AdminUserListResponse {
21
+ next_cursor?: string;
22
+ total: number;
23
+ users: User[];
24
+ }
25
+ interface AuthMethod {
26
+ label: string;
27
+ linked_at?: string;
28
+ provider: string;
29
+ type: string;
30
+ }
31
+ interface AuthResponse {
32
+ expires_at: string;
33
+ refresh_token: string;
34
+ session_token: string;
35
+ user: User;
36
+ }
37
+ interface BulkError {
38
+ email?: string;
39
+ error: string;
40
+ index: number;
41
+ }
42
+ interface BulkImportResult {
43
+ created: number;
44
+ errors?: BulkError[];
45
+ skipped: number;
46
+ }
47
+ interface BulkRevokeSessionsRequest {
48
+ UserID: string;
49
+ }
50
+ interface BulkRevokeSessionsResponse {
51
+ revoked: number;
52
+ user_id: string;
53
+ }
54
+ interface CallbackRequest {
55
+ Provider: string;
56
+ code: string;
57
+ error?: string;
58
+ state: string;
59
+ }
60
+ interface CallbackResponse {
61
+ expires_at: string;
62
+ is_new_user: boolean;
63
+ provider: string;
64
+ refresh_token: string;
65
+ session_token: string;
66
+ user: User;
67
+ }
68
+ interface ChallengeRequest {
69
+ code: string;
70
+ }
71
+ interface ChallengeResponse {
72
+ challenge_passed: boolean;
73
+ method: string;
74
+ }
75
+ interface ClientConfigBranding {
76
+ app_name?: string;
77
+ logo_url?: string;
78
+ }
79
+ interface ClientConfigFieldValidation {
80
+ max?: number;
81
+ max_len?: number;
82
+ min?: number;
83
+ min_len?: number;
84
+ pattern?: string;
85
+ required?: boolean;
86
+ }
87
+ interface ClientConfigMFA {
88
+ enabled: boolean;
89
+ methods: string[];
90
+ }
91
+ interface ClientConfigResponse {
92
+ app_id: string;
93
+ branding?: ClientConfigBranding;
94
+ magiclink?: ClientConfigToggle;
95
+ mfa?: ClientConfigMFA;
96
+ passkey?: ClientConfigToggle;
97
+ password?: ClientConfigToggle;
98
+ signup_fields?: ClientConfigSignupField[];
99
+ social?: ClientConfigSocial;
100
+ sso?: ClientConfigSSO;
101
+ supported_plugins: string[];
102
+ version: string;
103
+ }
104
+ interface ClientConfigSSO {
105
+ connections: ClientConfigSSOConnection[];
106
+ enabled: boolean;
107
+ }
108
+ interface ClientConfigSSOConnection {
109
+ id: string;
110
+ name: string;
111
+ }
112
+ interface ClientConfigSelectOption {
113
+ label: string;
114
+ value: string;
115
+ }
116
+ interface ClientConfigSignupField {
117
+ default?: string;
118
+ description?: string;
119
+ key: string;
120
+ label: string;
121
+ options?: ClientConfigSelectOption[];
122
+ order: number;
123
+ placeholder?: string;
124
+ type: string;
125
+ validation?: ClientConfigFieldValidation;
126
+ }
127
+ interface ClientConfigSocial {
128
+ enabled: boolean;
129
+ providers: ClientConfigSocialProvider[];
130
+ }
131
+ interface ClientConfigSocialProvider {
132
+ id: string;
133
+ name: string;
134
+ }
135
+ interface ClientConfigToggle {
136
+ enabled: boolean;
137
+ }
138
+ interface CloneEnvironmentResponse {
139
+ environment: unknown;
140
+ permissions_cloned: number;
141
+ role_id_map: Record<string, unknown>;
142
+ roles_cloned: number;
143
+ webhooks_cloned: number;
144
+ }
145
+ interface Config {
146
+ app_id: string;
147
+ app_name?: string;
148
+ created_at: string;
149
+ id: string;
150
+ logo_url?: string;
151
+ magic_link_enabled?: boolean;
152
+ mfa_enabled?: boolean;
153
+ mfa_methods?: string[];
154
+ passkey_enabled?: boolean;
155
+ password_enabled?: boolean;
156
+ social_enabled?: boolean;
157
+ social_providers?: string[];
158
+ sso_enabled?: boolean;
159
+ updated_at: string;
160
+ }
161
+ interface CreateKeyRequest {
162
+ app_id: string;
163
+ name: string;
164
+ scopes?: string[];
165
+ user_id: string;
166
+ }
167
+ interface CreateKeyResponse {
168
+ created_at: string;
169
+ expires_at?: string;
170
+ id: string;
171
+ key: string;
172
+ key_prefix: string;
173
+ name: string;
174
+ public_key: string;
175
+ public_key_prefix: string;
176
+ scopes?: string[];
177
+ }
178
+ interface CredentialInfo {
179
+ created_at: string;
180
+ display_name: string;
181
+ id: string;
182
+ transport: string[];
183
+ }
184
+ interface Definition {
185
+ category: string;
186
+ default: string;
187
+ description: string;
188
+ display_name: string;
189
+ enforceable: boolean;
190
+ key: string;
191
+ namespace: string;
192
+ scopes: string[];
193
+ sensitive: boolean;
194
+ type: string;
195
+ ui?: UIMetadata;
196
+ }
197
+ interface DefinitionGroup {
198
+ category: string;
199
+ definitions: Definition[];
200
+ namespace: string;
201
+ }
202
+ interface DeleteAccountRequest {
203
+ }
204
+ interface DeleteAppClientConfigRequest {
205
+ AppID: string;
206
+ }
207
+ interface DeleteAppSessionConfigRequest {
208
+ AppID: string;
209
+ }
210
+ interface DeleteDeviceRequest {
211
+ DeviceID: string;
212
+ }
213
+ interface DeleteOrgRequest {
214
+ OrgID: string;
215
+ }
216
+ interface DeleteRequest {
217
+ CredentialID: string;
218
+ }
219
+ interface DeleteResponse {
220
+ status: string;
221
+ }
222
+ interface DeleteSettingRequest {
223
+ Key: string;
224
+ Scope: string;
225
+ ScopeID: string;
226
+ }
227
+ interface DeleteTeamRequest {
228
+ OrgID: string;
229
+ TeamID: string;
230
+ }
231
+ interface DeleteWebhookRequest {
232
+ WebhookID: string;
233
+ }
234
+ interface Device {
235
+ app_id: string;
236
+ browser?: string;
237
+ created_at: string;
238
+ env_id: string;
239
+ fingerprint?: string;
240
+ id: string;
241
+ ip_address?: string;
242
+ last_seen_at: string;
243
+ name?: string;
244
+ os?: string;
245
+ trusted: boolean;
246
+ trusted_until?: string;
247
+ type?: string;
248
+ updated_at: string;
249
+ user_id: string;
250
+ }
251
+ interface DeviceListResponse {
252
+ devices: Device[];
253
+ }
254
+ interface DisableRequest {
255
+ }
256
+ interface DisableResponse {
257
+ status: string;
258
+ }
259
+ interface EnrollRequest {
260
+ method?: string;
261
+ phone?: string;
262
+ }
263
+ interface EnrollResponse {
264
+ id: string;
265
+ method: string;
266
+ otpauth_url: string;
267
+ secret: string;
268
+ }
269
+ interface Environment {
270
+ app_id: string;
271
+ cloned_from?: string;
272
+ color?: string;
273
+ created_at: string;
274
+ description?: string;
275
+ id: string;
276
+ is_default: boolean;
277
+ metadata?: Record<string, unknown>;
278
+ name: string;
279
+ settings?: Settings;
280
+ slug: string;
281
+ type: string;
282
+ updated_at: string;
283
+ }
284
+ interface EnvironmentListResponse {
285
+ environments: unknown;
286
+ total: number;
287
+ }
288
+ interface EnvironmentSettingsResponse {
289
+ overrides?: Settings;
290
+ settings?: Settings;
291
+ type_defaults?: Settings;
292
+ }
293
+ interface ForgotPasswordResponse {
294
+ status: string;
295
+ }
296
+ interface HealthResponse {
297
+ error?: string;
298
+ status: string;
299
+ }
300
+ interface Invitation {
301
+ created_at: string;
302
+ email: string;
303
+ expires_at: string;
304
+ id: string;
305
+ inviter_id: string;
306
+ org_id: string;
307
+ role: string;
308
+ status: string;
309
+ }
310
+ interface InvitationListResponse {
311
+ invitations: Invitation[];
312
+ }
313
+ interface KeyListItem {
314
+ created_at: string;
315
+ expires_at?: string;
316
+ id: string;
317
+ key_prefix: string;
318
+ last_used_at?: string;
319
+ name: string;
320
+ public_key_prefix?: string;
321
+ revoked: boolean;
322
+ scopes?: string[];
323
+ }
324
+ interface ListAuthMethodsResponse {
325
+ methods: AuthMethod[];
326
+ }
327
+ interface ListDefinitionsResponse {
328
+ groups: DefinitionGroup[];
329
+ total: number;
330
+ }
331
+ interface ListKeysResponse {
332
+ keys: KeyListItem[];
333
+ total: number;
334
+ }
335
+ interface ListResponse$1 {
336
+ credentials: CredentialInfo[];
337
+ }
338
+ interface LoginBeginRequest {
339
+ email?: string;
340
+ }
341
+ interface LoginBeginResponse {
342
+ options: Record<string, unknown>;
343
+ }
344
+ interface LoginFinishRequest {
345
+ }
346
+ interface LoginFinishResponse {
347
+ status: string;
348
+ user_id: string;
349
+ }
350
+ interface LoginRequest {
351
+ Provider: string;
352
+ }
353
+ interface LoginResponse {
354
+ login_url: string;
355
+ state: string;
356
+ }
357
+ interface Member {
358
+ created_at: string;
359
+ id: string;
360
+ org_id: string;
361
+ role: string;
362
+ updated_at: string;
363
+ user_id: string;
364
+ }
365
+ interface MemberListResponse {
366
+ members: Member[];
367
+ }
368
+ interface ObjectFieldDef {
369
+ display_name: string;
370
+ help_text?: string;
371
+ input_type: string;
372
+ key: string;
373
+ options?: SelectOption[];
374
+ placeholder?: string;
375
+ required?: boolean;
376
+ sensitive?: boolean;
377
+ }
378
+ interface OrgListResponse {
379
+ organizations: Organization[];
380
+ }
381
+ interface Organization {
382
+ app_id: string;
383
+ created_at: string;
384
+ created_by: string;
385
+ env_id: string;
386
+ id: string;
387
+ logo?: string;
388
+ metadata?: Record<string, unknown>;
389
+ name: string;
390
+ slug: string;
391
+ updated_at: string;
392
+ }
393
+ interface Permission {
394
+ action: string;
395
+ id: string;
396
+ resource: string;
397
+ role_id: string;
398
+ }
399
+ interface PermissionListResponse {
400
+ permissions: Permission[];
401
+ }
402
+ interface RecoveryRegenerateRequest {
403
+ }
404
+ interface RecoveryRegenerateResponse {
405
+ codes: string[];
406
+ }
407
+ interface RecoveryVerifyRequest {
408
+ code: string;
409
+ }
410
+ interface RecoveryVerifyResponse {
411
+ challenge_passed: boolean;
412
+ codes_remaining: number;
413
+ }
414
+ interface RegisterBeginRequest {
415
+ display_name?: string;
416
+ }
417
+ interface RegisterBeginResponse {
418
+ options: Record<string, unknown>;
419
+ }
420
+ interface RegisterFinishRequest {
421
+ }
422
+ interface RegisterFinishResponse {
423
+ display_name: string;
424
+ id: string;
425
+ status: string;
426
+ }
427
+ interface RemoveMemberRequest {
428
+ MemberID: string;
429
+ OrgID: string;
430
+ }
431
+ interface ResolvedSetting {
432
+ can_override: boolean;
433
+ definition?: Definition;
434
+ effective_value: string;
435
+ enforced_at?: string;
436
+ scope_values: ScopeValue[];
437
+ }
438
+ interface ResolvedSettingResponse {
439
+ setting?: ResolvedSetting;
440
+ }
441
+ interface ResolvedSettingsResponse {
442
+ settings: ResolvedSetting[];
443
+ }
444
+ interface RevokeKeyRequest {
445
+ KeyID: string;
446
+ }
447
+ interface RevokeSessionRequest {
448
+ SessionID: string;
449
+ }
450
+ interface Role {
451
+ app_id: string;
452
+ created_at: string;
453
+ description?: string;
454
+ env_id: string;
455
+ id: string;
456
+ name: string;
457
+ parent_id?: string;
458
+ slug: string;
459
+ updated_at: string;
460
+ }
461
+ interface RoleListResponse {
462
+ roles: Role[];
463
+ }
464
+ interface SMSSendRequest {
465
+ phone?: string;
466
+ }
467
+ interface SMSSendResponse {
468
+ expires_in_seconds: number;
469
+ phone_masked: string;
470
+ sent: boolean;
471
+ }
472
+ interface SMSVerifyRequest {
473
+ code: string;
474
+ }
475
+ interface SMSVerifyResponse {
476
+ method: string;
477
+ verified: boolean;
478
+ }
479
+ interface ScopeValue {
480
+ enforced: boolean;
481
+ scope: string;
482
+ scope_id?: string;
483
+ updated_at?: string;
484
+ updated_by?: string;
485
+ value: string;
486
+ version?: number;
487
+ }
488
+ interface SelectOption {
489
+ label: string;
490
+ value: string;
491
+ }
492
+ interface SendRequest {
493
+ app_id?: string;
494
+ email: string;
495
+ }
496
+ interface SendResponse {
497
+ status: string;
498
+ }
499
+ interface SessionListResponse {
500
+ sessions: Record<string, unknown>[];
501
+ }
502
+ interface SettingValueResponse {
503
+ key: string;
504
+ scope: string;
505
+ scope_id?: string;
506
+ status: string;
507
+ value: string;
508
+ }
509
+ interface Settings {
510
+ allow_test_credentials?: boolean;
511
+ check_breached?: boolean;
512
+ lockout_enabled?: boolean;
513
+ lockout_max_attempts?: number;
514
+ oauth_overrides?: Record<string, unknown>;
515
+ password_min_length?: number;
516
+ rate_limit_enabled?: boolean;
517
+ rate_limit_window_seconds?: number;
518
+ refresh_token_ttl_seconds?: number;
519
+ signin_rate_limit?: number;
520
+ signup_rate_limit?: number;
521
+ skip_email_verification?: boolean;
522
+ token_ttl_seconds?: number;
523
+ webhook_url_override?: string;
524
+ }
525
+ interface SignOutRequest {
526
+ }
527
+ interface SlugAvailableResponse {
528
+ available: boolean;
529
+ }
530
+ interface StartRequest {
531
+ Provider: string;
532
+ }
533
+ interface StartResponse {
534
+ auth_url: string;
535
+ }
536
+ interface StatusResponse {
537
+ status: string;
538
+ }
539
+ interface Team {
540
+ created_at: string;
541
+ id: string;
542
+ name: string;
543
+ org_id: string;
544
+ slug: string;
545
+ updated_at: string;
546
+ }
547
+ interface TeamListResponse {
548
+ teams: Team[];
549
+ }
550
+ interface TokenResponse {
551
+ expires_at: string;
552
+ refresh_token: string;
553
+ session_token: string;
554
+ }
555
+ interface TrustDeviceRequest {
556
+ DeviceID: string;
557
+ }
558
+ interface UIMetadata {
559
+ condition?: VisibilityCondition;
560
+ help_text?: string;
561
+ input_type: string;
562
+ object_fields?: ObjectFieldDef[];
563
+ options?: SelectOption[];
564
+ order: number;
565
+ placeholder?: string;
566
+ read_only?: boolean;
567
+ section?: string;
568
+ validation?: Validation;
569
+ }
570
+ interface UnenforceSettingRequest {
571
+ Key: string;
572
+ Scope: string;
573
+ ScopeID: string;
574
+ }
575
+ interface UnlinkAuthMethodRequest {
576
+ Provider: string;
577
+ }
578
+ interface UnlinkAuthMethodResponse {
579
+ status: string;
580
+ }
581
+ interface User {
582
+ app_id: string;
583
+ ban_expires?: string;
584
+ ban_reason?: string;
585
+ banned: boolean;
586
+ created_at: string;
587
+ deleted_at?: string;
588
+ display_username?: string;
589
+ email: string;
590
+ email_verified: boolean;
591
+ env_id: string;
592
+ first_name: string;
593
+ id: string;
594
+ image?: string;
595
+ last_name: string;
596
+ metadata?: Record<string, unknown>;
597
+ password_changed_at?: string;
598
+ phone?: string;
599
+ phone_verified: boolean;
600
+ updated_at: string;
601
+ username?: string;
602
+ }
603
+ interface UserRoleListResponse {
604
+ roles: Role[];
605
+ }
606
+ interface Validation {
607
+ max?: number;
608
+ max_len?: number;
609
+ min?: number;
610
+ min_len?: number;
611
+ pattern?: string;
612
+ required?: boolean;
613
+ }
614
+ interface VerifyMFARequest {
615
+ code: string;
616
+ }
617
+ interface VerifyMFAResponse {
618
+ method: string;
619
+ recovery_codes?: string[];
620
+ verified: boolean;
621
+ }
622
+ interface VerifyRequest {
623
+ app_id?: string;
624
+ token: string;
625
+ }
626
+ interface VerifyResponse {
627
+ expires_at: string;
628
+ refresh_token: string;
629
+ session_token: string;
630
+ user: User;
631
+ }
632
+ interface VisibilityCondition {
633
+ key: string;
634
+ operator?: string;
635
+ value: string;
636
+ }
637
+ interface Webhook {
638
+ active: boolean;
639
+ app_id: string;
640
+ created_at: string;
641
+ env_id: string;
642
+ events: string[];
643
+ id: string;
644
+ updated_at: string;
645
+ url: string;
646
+ }
647
+ interface WebhookListResponse {
648
+ webhooks: Webhook[];
649
+ }
650
+ type SetAppClientConfigRequest = {
651
+ app_name?: string;
652
+ logo_url?: string;
653
+ magic_link_enabled?: boolean;
654
+ mfa_enabled?: boolean;
655
+ mfa_methods?: string[];
656
+ passkey_enabled?: boolean;
657
+ password_enabled?: boolean;
658
+ social_enabled?: boolean;
659
+ social_providers?: string[];
660
+ sso_enabled?: boolean;
661
+ };
662
+ type SetAppSessionConfigRequest = {
663
+ bind_to_device?: boolean;
664
+ bind_to_ip?: boolean;
665
+ max_active_sessions?: number;
666
+ refresh_token_ttl_seconds?: number;
667
+ rotate_refresh_token?: boolean;
668
+ token_format?: string;
669
+ token_ttl_seconds?: number;
670
+ };
671
+ type AdminBulkRevokeSessionsRequest = BulkRevokeSessionsRequest;
672
+ type AdminBulkImportUsersRequest = {
673
+ app_id?: string;
674
+ users: Record<string, unknown>[];
675
+ };
676
+ type EnforceSettingRequest = {
677
+ app_id?: string;
678
+ org_id?: string;
679
+ scope: string;
680
+ scope_id?: string;
681
+ value: string;
682
+ };
683
+ type SetSettingRequest = {
684
+ app_id?: string;
685
+ org_id?: string;
686
+ scope: string;
687
+ scope_id?: string;
688
+ value: string;
689
+ };
690
+ type AdminBanUserRequest = {
691
+ expires_at?: string;
692
+ reason?: string;
693
+ };
694
+ type ChangePasswordRequest = {
695
+ current_password: string;
696
+ new_password: string;
697
+ };
698
+ type CreateEnvironmentRequest = {
699
+ app_id?: string;
700
+ color?: string;
701
+ description?: string;
702
+ name: string;
703
+ settings?: Record<string, unknown>;
704
+ slug: string;
705
+ type: string;
706
+ };
707
+ type UpdateEnvironmentRequest = {
708
+ color?: string;
709
+ description?: string;
710
+ name?: string;
711
+ };
712
+ type CloneEnvironmentRequest = {
713
+ description?: string;
714
+ name: string;
715
+ settings?: Record<string, unknown>;
716
+ slug: string;
717
+ type: string;
718
+ webhook_url_override?: string;
719
+ };
720
+ type UpdateEnvironmentSettingsRequest = {
721
+ allow_test_credentials?: boolean;
722
+ check_breached?: boolean;
723
+ lockout_enabled?: boolean;
724
+ lockout_max_attempts?: number;
725
+ oauth_overrides?: Record<string, unknown>;
726
+ password_min_length?: number;
727
+ rate_limit_enabled?: boolean;
728
+ rate_limit_window_seconds?: number;
729
+ refresh_token_ttl_seconds?: number;
730
+ signin_rate_limit?: number;
731
+ signup_rate_limit?: number;
732
+ skip_email_verification?: boolean;
733
+ token_ttl_seconds?: number;
734
+ webhook_url_override?: string;
735
+ };
736
+ type ForgotPasswordRequest = {
737
+ app_id?: string;
738
+ email: string;
739
+ };
740
+ type CreateAPIKeyRequest = CreateKeyRequest;
741
+ type RevokeAPIKeyRequest = RevokeKeyRequest;
742
+ type SendMagicLinkRequest = SendRequest;
743
+ type VerifyMagicLinkRequest = VerifyRequest;
744
+ type UpdateMeRequest = {
745
+ first_name?: string;
746
+ image?: string;
747
+ last_name?: string;
748
+ username?: string;
749
+ };
750
+ type DeleteMeRequest = DeleteAccountRequest;
751
+ type ChallengeMFARequest = ChallengeRequest;
752
+ type EnrollMFARequest = EnrollRequest;
753
+ type DisableMFARequest = DisableRequest;
754
+ type RegenerateMFARecoveryCodesRequest = RecoveryRegenerateRequest;
755
+ type VerifyRecoveryCodeRequest = RecoveryVerifyRequest;
756
+ type SendSMSCodeRequest = SMSSendRequest;
757
+ type VerifySMSCodeRequest = SMSVerifyRequest;
758
+ type CreateOrganizationRequest = {
759
+ app_id?: string;
760
+ logo?: string;
761
+ name: string;
762
+ slug: string;
763
+ };
764
+ type AcceptInvitationRequest = {
765
+ token: string;
766
+ };
767
+ type DeclineInvitationRequest = {
768
+ token: string;
769
+ };
770
+ type UpdateOrganizationRequest = {
771
+ logo?: string;
772
+ name?: string;
773
+ };
774
+ type DeleteOrganizationRequest = DeleteOrgRequest;
775
+ type CreateInvitationRequest = {
776
+ email: string;
777
+ role?: string;
778
+ };
779
+ type AddMemberRequest = {
780
+ role?: string;
781
+ user_id: string;
782
+ };
783
+ type UpdateMemberRequest = {
784
+ role: string;
785
+ };
786
+ type CreateTeamRequest = {
787
+ name: string;
788
+ slug: string;
789
+ };
790
+ type UpdateTeamRequest = {
791
+ name?: string;
792
+ slug?: string;
793
+ };
794
+ type PasskeyLoginBeginRequest = LoginBeginRequest;
795
+ type PasskeyLoginFinishRequest = LoginFinishRequest;
796
+ type PasskeyRegisterBeginRequest = RegisterBeginRequest;
797
+ type PasskeyRegisterFinishRequest = RegisterFinishRequest;
798
+ type DeletePasskeyRequest = DeleteRequest;
799
+ type RefreshRequest = {
800
+ refresh_token: string;
801
+ };
802
+ type ResetPasswordRequest = {
803
+ new_password: string;
804
+ token: string;
805
+ };
806
+ type AuthsomeCreateRoleRequest = {
807
+ app_id?: string;
808
+ description?: string;
809
+ name: string;
810
+ parent_id?: string;
811
+ slug: string;
812
+ };
813
+ type AuthsomeUpdateRoleRequest = {
814
+ description?: string;
815
+ name?: string;
816
+ parent_id?: string;
817
+ };
818
+ type AuthsomeAssignRoleRequest = {
819
+ org_id?: string;
820
+ user_id: string;
821
+ };
822
+ type AuthsomeAddPermissionRequest = {
823
+ action: string;
824
+ resource: string;
825
+ };
826
+ type AuthsomeUnassignRoleRequest = {
827
+ user_id: string;
828
+ };
829
+ type SignInRequest = {
830
+ app_id?: string;
831
+ email?: string;
832
+ password: string;
833
+ username?: string;
834
+ };
835
+ type SignUpRequest = {
836
+ app_id?: string;
837
+ email: string;
838
+ first_name?: string;
839
+ last_name?: string;
840
+ metadata?: Record<string, unknown>;
841
+ password: string;
842
+ username?: string;
843
+ };
844
+ type StartOAuthRequest = StartRequest;
845
+ type SsoACSRequest = ACSRequest;
846
+ type SsoCallbackRequest = CallbackRequest;
847
+ type StartSSOLoginRequest = LoginRequest;
848
+ type VerifyEmailRequest = {
849
+ token: string;
850
+ };
851
+ type CreateWebhookRequest = {
852
+ app_id?: string;
853
+ events: string[];
854
+ url: string;
855
+ };
856
+ type UpdateWebhookRequest = {
857
+ active?: boolean;
858
+ events?: string[];
859
+ url?: string;
860
+ };
6
861
 
7
- /**
8
- * Error handling utilities
9
- */
862
+ /** Core type definitions for AuthSome UI Kit. */
10
863
 
864
+ interface Session {
865
+ session_token: string;
866
+ refresh_token: string;
867
+ expires_at: string;
868
+ }
869
+ /** API error response. */
870
+ interface APIError {
871
+ error: string;
872
+ code?: number;
873
+ }
874
+ /** Authentication state. */
875
+ type AuthState = {
876
+ status: "idle";
877
+ } | {
878
+ status: "loading";
879
+ } | {
880
+ status: "authenticated";
881
+ user: User;
882
+ session: Session;
883
+ } | {
884
+ status: "unauthenticated";
885
+ } | {
886
+ status: "mfa_required";
887
+ session: Session;
888
+ } | {
889
+ status: "error";
890
+ error: string;
891
+ };
892
+ /** Configuration for the AuthSome client. */
893
+ interface AuthConfig {
894
+ /** Base URL of the AuthSome API (e.g., "https://api.example.com"). */
895
+ baseURL: string;
896
+ /** Publishable key for auto-discovering enabled auth methods. */
897
+ publishableKey?: string;
898
+ /** Pre-fetched client config (useful for SSR). */
899
+ initialClientConfig?: ClientConfig;
900
+ /** Custom fetch implementation (defaults to global fetch). */
901
+ fetch?: typeof fetch;
902
+ /** Storage implementation for persisting tokens (defaults to localStorage). */
903
+ storage?: TokenStorage;
904
+ /** Callback invoked when the auth state changes. */
905
+ onStateChange?: (state: AuthState) => void;
906
+ /** Callback invoked on authentication error. */
907
+ onError?: (error: APIError) => void;
908
+ }
909
+ /** Social provider info from the backend. */
910
+ interface SocialProviderConfig {
911
+ id: string;
912
+ name: string;
913
+ }
914
+ /** SSO connection info from the backend. */
915
+ interface SSOConnectionConfig {
916
+ id: string;
917
+ name: string;
918
+ }
919
+ /** A single option for select/radio/checkbox signup fields. */
920
+ interface SignupFieldOption {
921
+ label: string;
922
+ value: string;
923
+ }
924
+ /** Validation rules for a signup field. */
925
+ interface SignupFieldValidation {
926
+ required?: boolean;
927
+ min_len?: number;
928
+ max_len?: number;
929
+ pattern?: string;
930
+ min?: number;
931
+ max?: number;
932
+ }
933
+ /** A custom signup form field from the backend. */
934
+ interface SignupFieldConfig {
935
+ key: string;
936
+ label: string;
937
+ type: string;
938
+ placeholder?: string;
939
+ description?: string;
940
+ options?: SignupFieldOption[];
941
+ default?: string;
942
+ validation?: SignupFieldValidation;
943
+ order: number;
944
+ }
11
945
  /**
12
- * Create an auth error
946
+ * Client configuration returned by the backend.
13
947
  *
14
- * @deprecated Use `new AuthError()` directly instead
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
948
+ * Describes which auth methods are enabled so SDK components
949
+ * can auto-configure their UI without manual props.
27
950
  */
28
- declare function isNetworkError(error: unknown): boolean;
29
- /**
30
- * Check if error indicates authentication is required
31
- */
32
- declare function isUnauthenticatedError(error: unknown): boolean;
33
- /**
34
- * Check if error requires MFA
35
- */
36
- declare function isMFARequiredError(error: unknown): boolean;
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;
85
- };
86
- phone: {
87
- enterPhone: string;
88
- sendCode: string;
89
- enterCode: string;
90
- verifyPhone: string;
91
- codeLabel: string;
92
- };
93
- mfa: {
94
- required: string;
95
- selectMethod: string;
96
- verify: string;
97
- enterCode: string;
98
- sms: string;
99
- authenticator: string;
100
- email: string;
101
- };
102
- passkey: {
103
- signInWith: string;
104
- register: string;
105
- usePasskey: string;
106
- };
107
- deviceFlow: {
108
- title: string;
109
- subtitle: string;
110
- enterCode: string;
111
- enterCodeDescription: string;
112
- codeLabel: string;
113
- codePlaceholder: string;
114
- codeHint: string;
115
- verify: string;
116
- verifyCode: string;
117
- invalidCode: string;
118
- noCode: string;
119
- getCodeHelp: string;
120
- authorizationTitle: string;
121
- authorizationSubtitle: string;
122
- authorizeTitle: string;
123
- authorizeDescription: string;
124
- requestingAccess: string;
125
- codeConfirm: string;
126
- requestedPermissions: string;
127
- securityWarning: string;
128
- scopes: string;
129
- approve: string;
130
- deny: string;
131
- authorizedTitle: string;
132
- authorizedMessage: string;
133
- authorizedDescription: string;
134
- authorizedHint: string;
135
- returnToCli: string;
136
- deniedTitle: string;
137
- deniedMessage: string;
138
- deniedDescription: string;
139
- deniedHint: string;
951
+ interface ClientConfig {
952
+ version?: string;
953
+ app_id?: string;
954
+ branding?: {
955
+ app_name?: string;
956
+ logo_url?: string;
140
957
  };
141
- signUp: {
142
- title: string;
143
- subtitle: string;
144
- haveAccount: string;
145
- signInLink: string;
146
- agreeToTerms: string;
147
- terms: string;
958
+ password?: {
959
+ enabled: boolean;
148
960
  };
149
- signIn: {
150
- title: string;
151
- subtitle: string;
152
- noAccount: string;
153
- signUpLink: string;
154
- enterEmail: string;
961
+ social?: {
962
+ enabled: boolean;
963
+ providers: SocialProviderConfig[];
155
964
  };
156
- validation: {
157
- emailRequired: string;
158
- emailInvalid: string;
159
- passwordRequired: string;
160
- passwordTooShort: string;
161
- passwordRequireUppercase: string;
162
- passwordRequireLowercase: string;
163
- passwordRequireNumber: string;
164
- passwordRequireSpecial: string;
165
- passwordMismatch: string;
166
- usernameRequired: string;
167
- usernameInvalid: string;
168
- phoneRequired: string;
169
- phoneInvalid: string;
170
- codeRequired: string;
171
- codeInvalid: string;
172
- fieldRequired: string;
173
- termsRequired: string;
965
+ passkey?: {
966
+ enabled: boolean;
174
967
  };
175
- errors: {
176
- invalidCredentials: string;
177
- userNotFound: string;
178
- userExists: string;
179
- invalidToken: string;
180
- tokenExpired: string;
181
- networkError: string;
182
- mfaRequired: string;
183
- emailNotVerified: string;
184
- phoneNotVerified: string;
185
- rateLimitExceeded: string;
186
- unknownError: string;
187
- generic: string;
968
+ mfa?: {
969
+ enabled: boolean;
970
+ methods: string[];
188
971
  };
189
- success: {
190
- signedIn: string;
191
- signedUp: string;
192
- signedOut: string;
193
- linkSent: string;
194
- codeSent: string;
195
- verified: string;
196
- welcome: string;
972
+ magiclink?: {
973
+ enabled: boolean;
197
974
  };
198
- placeholders: {
199
- email: string;
200
- password: string;
201
- confirmPassword: string;
202
- username: string;
203
- phone: string;
204
- code: string;
205
- fullName: string;
975
+ sso?: {
976
+ enabled: boolean;
977
+ connections: SSOConnectionConfig[];
206
978
  };
979
+ /** List of server-side plugin names that are installed and active. */
980
+ supported_plugins?: string[];
981
+ /** Custom signup form fields configured for this app. */
982
+ signup_fields?: SignupFieldConfig[];
983
+ }
984
+ /** Interface for persisting tokens across sessions. */
985
+ interface TokenStorage {
986
+ getItem(key: string): string | null | Promise<string | null>;
987
+ setItem(key: string, value: string): void | Promise<void>;
988
+ removeItem(key: string): void | Promise<void>;
207
989
  }
208
- /**
209
- * Deep partial type for locale overrides
210
- */
211
- type DeepPartial<T> = {
212
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
213
- };
214
-
215
- /**
216
- * Validation utilities
217
- */
218
-
219
- /**
220
- * Validate email address
221
- */
222
- declare function validateEmail(email: string, locale?: AuthLocale): ValidationError | null;
223
- /**
224
- * Validate password
225
- */
226
- declare function validatePassword(password: string, options?: {
227
- minLength?: number;
228
- requireUppercase?: boolean;
229
- requireLowercase?: boolean;
230
- requireNumber?: boolean;
231
- requireSpecial?: boolean;
232
- locale?: AuthLocale;
233
- }): ValidationError | null;
234
- /**
235
- * Validate phone number
236
- */
237
- declare function validatePhone(phone: string, locale?: AuthLocale): ValidationError | null;
238
- /**
239
- * Validate username
240
- */
241
- declare function validateUsername(username: string, locale?: AuthLocale): ValidationError | null;
242
- /**
243
- * Validate 2FA code
244
- */
245
- declare function validate2FACode(code: string, locale?: AuthLocale): ValidationError | null;
246
- /**
247
- * Validate required field
248
- */
249
- declare function validateRequired(value: unknown, fieldName: string, locale?: AuthLocale): ValidationError | null;
250
-
251
- /**
252
- * Token management utilities
253
- */
254
990
 
255
- /**
256
- * Token manager class
257
- */
258
- declare class TokenManager {
259
- private storage;
260
- constructor(storage?: Storage);
991
+ interface AuthClientConfig {
992
+ /** Base URL of the AuthSome API (e.g., "https://api.example.com") */
993
+ baseURL: string;
994
+ /** Optional custom fetch implementation */
995
+ fetch?: typeof globalThis.fetch;
996
+ }
997
+ declare class AuthClient$1 {
998
+ private baseURL;
999
+ private fetchFn;
1000
+ constructor(config: AuthClientConfig | Pick<{
1001
+ baseURL: string;
1002
+ fetch?: typeof globalThis.fetch;
1003
+ }, 'baseURL' | 'fetch'>);
1004
+ /**
1005
+ * Get AuthSome manifest
1006
+ * GET /.well-known/authsome/manifest
1007
+ */
1008
+ getManifest(): Promise<Record<string, unknown>>;
1009
+ /**
1010
+ * Get OpenAPI specification
1011
+ * GET /.well-known/authsome/openapi
1012
+ */
1013
+ getOpenAPI(): Promise<Record<string, unknown>>;
261
1014
  /**
262
- * Get access token
1015
+ * Get per-app client config overrides
1016
+ * GET /v1/admin/apps/{appId}/client-config
263
1017
  */
264
- getToken(): Promise<string | null>;
1018
+ getAppClientConfig(appId: string, token: string): Promise<Config>;
265
1019
  /**
266
- * Set access token
1020
+ * Set per-app client config overrides
1021
+ * PUT /v1/admin/apps/{appId}/client-config
267
1022
  */
268
- setToken(token: string): Promise<void>;
1023
+ setAppClientConfig(appId: string, body: SetAppClientConfigRequest, token: string): Promise<Config>;
269
1024
  /**
270
- * Remove access token
1025
+ * Delete per-app client config overrides
1026
+ * DELETE /v1/admin/apps/{appId}/client-config
271
1027
  */
272
- removeToken(): Promise<void>;
1028
+ deleteAppClientConfig(appId: string, body: DeleteAppClientConfigRequest, token: string): Promise<StatusResponse>;
273
1029
  /**
274
- * Get refresh token
1030
+ * Get per-app session config
1031
+ * GET /v1/admin/apps/{appId}/session-config
275
1032
  */
276
- getRefreshToken(): Promise<string | null>;
1033
+ getAppSessionConfig(appId: string, token: string): Promise<Config>;
277
1034
  /**
278
- * Set refresh token
1035
+ * Set per-app session config
1036
+ * PUT /v1/admin/apps/{appId}/session-config
279
1037
  */
280
- setRefreshToken(token: string): Promise<void>;
1038
+ setAppSessionConfig(appId: string, body: SetAppSessionConfigRequest, token: string): Promise<Config>;
281
1039
  /**
282
- * Remove refresh token
1040
+ * Delete per-app session config
1041
+ * DELETE /v1/admin/apps/{appId}/session-config
283
1042
  */
284
- removeRefreshToken(): Promise<void>;
1043
+ deleteAppSessionConfig(appId: string, body: DeleteAppSessionConfigRequest, token: string): Promise<StatusResponse>;
285
1044
  /**
286
- * Clear all tokens
1045
+ * Bulk revoke sessions (admin)
1046
+ * DELETE /v1/admin/bulk/sessions
287
1047
  */
288
- clearTokens(): Promise<void>;
1048
+ adminBulkRevokeSessions(body: AdminBulkRevokeSessionsRequest, token: string): Promise<BulkRevokeSessionsResponse>;
289
1049
  /**
290
- * Check if token is expired
1050
+ * Bulk import users (admin)
1051
+ * POST /v1/admin/bulk/users/import
291
1052
  */
292
- isTokenExpired(token: string): boolean;
1053
+ adminBulkImportUsers(body: AdminBulkImportUsersRequest, token: string): Promise<BulkImportResult>;
293
1054
  /**
294
- * Decode JWT token (without verification)
1055
+ * Stop impersonation (admin)
1056
+ * POST /v1/admin/impersonate/stop
295
1057
  */
296
- private decodeToken;
297
- }
298
-
299
- /**
300
- * Cookie utility functions
301
- * Framework-agnostic helpers for cookie parsing and serialization
302
- */
303
-
304
- /**
305
- * Parse Set-Cookie header value into CookieData
306
- * @param setCookieHeader - The Set-Cookie header value
307
- * @returns Parsed cookie data
308
- */
309
- declare function parseCookie(setCookieHeader: string): CookieData | null;
310
- /**
311
- * Extract multiple cookies from Set-Cookie headers
312
- * @param setCookieHeaders - Array of Set-Cookie header values or single string
313
- * @returns Array of parsed cookies
314
- */
315
- declare function extractCookiesFromHeaders(setCookieHeaders: string | string[]): CookieData[];
316
- /**
317
- * Serialize a CookieData object into a Set-Cookie header value
318
- * @param cookie - The cookie data to serialize
319
- * @returns Set-Cookie header value
320
- */
321
- declare function serializeCookie(cookie: CookieData): string;
322
- /**
323
- * Parse Cookie header value into key-value pairs
324
- * @param cookieHeader - The Cookie header value
325
- * @returns Object with cookie name-value pairs
326
- */
327
- declare function parseCookieOptions(cookieHeader: string): Record<string, string>;
328
- /**
329
- * Convert cookie object to Cookie header string
330
- * @param cookies - Object with cookie name-value pairs
331
- * @returns Cookie header value
332
- */
333
- declare function serializeCookies(cookies: Record<string, string>): string;
334
-
335
- /**
336
- * Locale utility functions
337
- */
338
-
339
- /**
340
- * Default locale (English)
341
- */
342
- declare const defaultLocale: AuthLocale;
343
- /**
344
- * Create a complete locale by merging overrides with the default English locale
345
- *
346
- * @param overrides - Partial locale object with custom translations
347
- * @returns Complete locale object with all required keys
348
- *
349
- * @example
350
- * ```typescript
351
- * const spanishLocale = createLocale({
352
- * auth: {
353
- * signIn: 'Iniciar sesión',
354
- * signUp: 'Registrarse',
355
- * }
356
- * });
357
- * ```
358
- */
359
- declare function createLocale(overrides?: DeepPartial<AuthLocale>): AuthLocale;
360
- /**
361
- * Interpolate template string with values
362
- *
363
- * Replaces {key} placeholders with corresponding values from the provided object.
364
- *
365
- * @param template - Template string with {key} placeholders
366
- * @param values - Object with key-value pairs for interpolation
367
- * @returns Interpolated string
368
- *
369
- * @example
370
- * ```typescript
371
- * interpolate('Hello, {name}!', { name: 'John' })
372
- * // Returns: "Hello, John!"
373
- *
374
- * interpolate('Password must be at least {min} characters', { min: '8' })
375
- * // Returns: "Password must be at least 8 characters"
376
- * ```
377
- */
378
- declare function interpolate(template: string, values: Record<string, string | number>): string;
379
-
380
- /**
381
- * Auth client configuration
382
- */
383
- interface AuthClientConfig {
384
- provider: AuthProvider;
385
- autoRefresh?: boolean;
386
- refreshInterval?: number;
387
- }
388
- /**
389
- * Auth client class
390
- */
391
- declare class AuthClient {
392
- private provider;
393
- private autoRefresh;
394
- private refreshInterval;
395
- private refreshTimer?;
396
- readonly state: Observable<AuthContext>;
397
- get adapter(): AuthProvider;
398
- constructor(config: AuthClientConfig);
1058
+ adminStopImpersonation(body: AdminStopImpersonationRequest, token: string): Promise<StatusResponse>;
399
1059
  /**
400
- * Initialize the auth client
1060
+ * Impersonate user (admin)
1061
+ * POST /v1/admin/impersonate/{userId}
401
1062
  */
402
- initialize(): Promise<void>;
1063
+ adminImpersonate(userId: string, body: AdminImpersonateRequest, token: string): Promise<AuthResponse>;
403
1064
  /**
404
- * Sign in with credentials
1065
+ * List organizations (admin)
1066
+ * GET /v1/admin/orgs
405
1067
  */
406
- signIn(request: SignInRequest): Promise<void>;
1068
+ adminListOrgs(token: string): Promise<OrgListResponse>;
407
1069
  /**
408
- * Sign up with credentials
1070
+ * List all setting definitions
1071
+ * GET /v1/admin/settings/definitions
409
1072
  */
410
- signUp(request: SignUpRequest): Promise<void>;
1073
+ listSettingsDefinitions(token: string): Promise<ListDefinitionsResponse>;
411
1074
  /**
412
- * Sign out
1075
+ * List definitions for a namespace
1076
+ * GET /v1/admin/settings/definitions/{namespace}
413
1077
  */
414
- signOut(): Promise<void>;
1078
+ listNamespaceSettingsDefinitions(namespace: string, token: string): Promise<ListDefinitionsResponse>;
1079
+ /**
1080
+ * Enforce a setting value at a scope
1081
+ * PUT /v1/admin/settings/enforce/{key}
1082
+ */
1083
+ enforceSetting(key: string, body: EnforceSettingRequest, token: string): Promise<SettingValueResponse>;
1084
+ /**
1085
+ * Remove enforcement from a setting
1086
+ * DELETE /v1/admin/settings/enforce/{key}
1087
+ */
1088
+ unenforceSetting(key: string, body: UnenforceSettingRequest, token: string): Promise<StatusResponse>;
1089
+ /**
1090
+ * Resolve all settings at a scope
1091
+ * GET /v1/admin/settings/resolve
1092
+ */
1093
+ resolveSettings(token: string): Promise<ResolvedSettingsResponse>;
1094
+ /**
1095
+ * Resolve one setting with cascade details
1096
+ * GET /v1/admin/settings/resolve/{key}
1097
+ */
1098
+ resolveSetting(key: string, token: string): Promise<ResolvedSettingResponse>;
1099
+ /**
1100
+ * Set a setting value at a scope
1101
+ * PUT /v1/admin/settings/values/{key}
1102
+ */
1103
+ setSetting(key: string, body: SetSettingRequest, token: string): Promise<SettingValueResponse>;
1104
+ /**
1105
+ * Delete a setting override at a scope
1106
+ * DELETE /v1/admin/settings/values/{key}
1107
+ */
1108
+ deleteSetting(key: string, body: DeleteSettingRequest, token: string): Promise<StatusResponse>;
1109
+ /**
1110
+ * Get stats (admin)
1111
+ * GET /v1/admin/stats
1112
+ */
1113
+ adminGetStats(token: string): Promise<AdminStatsResponse>;
1114
+ /**
1115
+ * List users (admin)
1116
+ * GET /v1/admin/users
1117
+ */
1118
+ adminListUsers(token: string): Promise<AdminUserListResponse>;
1119
+ /**
1120
+ * Get user (admin)
1121
+ * GET /v1/admin/users/{userId}
1122
+ */
1123
+ adminGetUser(userId: string, token: string): Promise<User>;
1124
+ /**
1125
+ * Delete user (admin)
1126
+ * DELETE /v1/admin/users/{userId}
1127
+ */
1128
+ adminDeleteUser(userId: string, body: AdminDeleteUserRequest, token: string): Promise<StatusResponse>;
1129
+ /**
1130
+ * Ban user (admin)
1131
+ * POST /v1/admin/users/{userId}/ban
1132
+ */
1133
+ adminBanUser(userId: string, body: AdminBanUserRequest, token: string): Promise<StatusResponse>;
415
1134
  /**
416
- * Update user profile
1135
+ * Unban user (admin)
1136
+ * POST /v1/admin/users/{userId}/unban
417
1137
  */
418
- updateUser(request: UpdateUserRequest): Promise<void>;
1138
+ adminUnbanUser(userId: string, body: AdminUnbanUserRequest, token: string): Promise<StatusResponse>;
419
1139
  /**
420
1140
  * Change password
1141
+ * POST /v1/change-password
1142
+ */
1143
+ changePassword(body: ChangePasswordRequest, token: string): Promise<StatusResponse>;
1144
+ /**
1145
+ * Get client configuration
1146
+ * GET /v1/client-config
1147
+ */
1148
+ getClientConfig(token: string): Promise<ClientConfigResponse>;
1149
+ /**
1150
+ * List devices
1151
+ * GET /v1/devices
1152
+ */
1153
+ listDevices(token: string): Promise<DeviceListResponse>;
1154
+ /**
1155
+ * Get device
1156
+ * GET /v1/devices/{deviceId}
1157
+ */
1158
+ getDevice(deviceId: string, token: string): Promise<Device>;
1159
+ /**
1160
+ * Delete device
1161
+ * DELETE /v1/devices/{deviceId}
1162
+ */
1163
+ deleteDevice(deviceId: string, body: DeleteDeviceRequest, token: string): Promise<StatusResponse>;
1164
+ /**
1165
+ * Trust device
1166
+ * PATCH /v1/devices/{deviceId}/trust
1167
+ */
1168
+ trustDevice(deviceId: string, body: TrustDeviceRequest, token: string): Promise<Device>;
1169
+ /**
1170
+ * List environments
1171
+ * GET /v1/environments
1172
+ */
1173
+ listEnvironments(token: string): Promise<EnvironmentListResponse>;
1174
+ /**
1175
+ * Create environment
1176
+ * POST /v1/environments
1177
+ */
1178
+ createEnvironment(body: CreateEnvironmentRequest, token: string): Promise<Environment>;
1179
+ /**
1180
+ * Get environment
1181
+ * GET /v1/environments/{envId}
1182
+ */
1183
+ getEnvironment(envId: string, token: string): Promise<Environment>;
1184
+ /**
1185
+ * Update environment
1186
+ * PATCH /v1/environments/{envId}
1187
+ */
1188
+ updateEnvironment(envId: string, body: UpdateEnvironmentRequest, token: string): Promise<Environment>;
1189
+ /**
1190
+ * Delete environment
1191
+ * DELETE /v1/environments/{envId}
1192
+ */
1193
+ deleteEnvironment(envId: string, token: string): Promise<StatusResponse>;
1194
+ /**
1195
+ * Clone environment
1196
+ * POST /v1/environments/{envId}/clone
1197
+ */
1198
+ cloneEnvironment(envId: string, body: CloneEnvironmentRequest, token: string): Promise<CloneEnvironmentResponse>;
1199
+ /**
1200
+ * Set default environment
1201
+ * POST /v1/environments/{envId}/set-default
1202
+ */
1203
+ setDefaultEnvironment(envId: string, token: string): Promise<StatusResponse>;
1204
+ /**
1205
+ * Get environment settings
1206
+ * GET /v1/environments/{envId}/settings
1207
+ */
1208
+ getEnvironmentSettings(envId: string, token: string): Promise<EnvironmentSettingsResponse>;
1209
+ /**
1210
+ * Update environment settings
1211
+ * PATCH /v1/environments/{envId}/settings
421
1212
  */
422
- changePassword(request: PasswordChangeRequest): Promise<void>;
1213
+ updateEnvironmentSettings(envId: string, body: UpdateEnvironmentSettingsRequest, token: string): Promise<Environment>;
423
1214
  /**
424
- * Request password reset
1215
+ * Forgot password
1216
+ * POST /v1/forgot-password
425
1217
  */
426
- requestPasswordReset(request: PasswordResetRequest): Promise<void>;
1218
+ forgotPassword(body: ForgotPasswordRequest): Promise<ForgotPasswordResponse>;
427
1219
  /**
428
- * Confirm password reset
1220
+ * Health check
1221
+ * GET /v1/health
429
1222
  */
430
- confirmPasswordReset(request: PasswordResetConfirmRequest): Promise<void>;
1223
+ getHealth(): Promise<HealthResponse>;
431
1224
  /**
432
- * Get OAuth sign in URL
1225
+ * List API keys
1226
+ * GET /v1/keys
433
1227
  */
434
- getOAuthUrl(request: OAuthSignInRequest): Promise<string>;
1228
+ listAPIKeys(token: string): Promise<ListKeysResponse>;
435
1229
  /**
436
- * Handle OAuth callback
1230
+ * Create API key
1231
+ * POST /v1/keys
437
1232
  */
438
- handleOAuthCallback(request: OAuthCallbackRequest): Promise<void>;
1233
+ createAPIKey(body: CreateAPIKeyRequest, token: string): Promise<CreateKeyResponse>;
439
1234
  /**
440
- * Get available OAuth providers
1235
+ * Revoke API key
1236
+ * DELETE /v1/keys/{keyId}
441
1237
  */
442
- getOAuthProviders(): Promise<OAuthProvider[]>;
1238
+ revokeAPIKey(keyId: string, body: RevokeAPIKeyRequest, token: string): Promise<void>;
443
1239
  /**
444
1240
  * Send magic link
1241
+ * POST /v1/magic-link/send
445
1242
  */
446
- sendMagicLink(request: MagicLinkRequest): Promise<void>;
1243
+ sendMagicLink(body: SendMagicLinkRequest): Promise<SendResponse>;
447
1244
  /**
448
1245
  * Verify magic link
1246
+ * POST /v1/magic-link/verify
1247
+ */
1248
+ verifyMagicLink(body: VerifyMagicLinkRequest): Promise<VerifyResponse>;
1249
+ /**
1250
+ * Get current user
1251
+ * GET /v1/me
1252
+ */
1253
+ getMe(token: string): Promise<User>;
1254
+ /**
1255
+ * Update current user
1256
+ * PATCH /v1/me
1257
+ */
1258
+ updateMe(body: UpdateMeRequest, token: string): Promise<User>;
1259
+ /**
1260
+ * Delete account
1261
+ * DELETE /v1/me
1262
+ */
1263
+ deleteMe(body: DeleteMeRequest, token: string): Promise<StatusResponse>;
1264
+ /**
1265
+ * List linked auth methods
1266
+ * GET /v1/me/auth-methods
1267
+ */
1268
+ listAuthMethods(token: string): Promise<ListAuthMethodsResponse>;
1269
+ /**
1270
+ * Unlink an auth method
1271
+ * DELETE /v1/me/auth-methods/{provider}
1272
+ */
1273
+ unlinkAuthMethod(provider: string, body: UnlinkAuthMethodRequest, token: string): Promise<UnlinkAuthMethodResponse>;
1274
+ /**
1275
+ * Export user data
1276
+ * GET /v1/me/export
1277
+ */
1278
+ exportMyData(token: string): Promise<Record<string, unknown>>;
1279
+ /**
1280
+ * MFA challenge
1281
+ * POST /v1/mfa/challenge
1282
+ */
1283
+ challengeMFA(body: ChallengeMFARequest): Promise<ChallengeResponse>;
1284
+ /**
1285
+ * Enroll in MFA
1286
+ * POST /v1/mfa/enroll
1287
+ */
1288
+ enrollMFA(body: EnrollMFARequest, token: string): Promise<EnrollResponse>;
1289
+ /**
1290
+ * Disable MFA
1291
+ * DELETE /v1/mfa/enrollment
1292
+ */
1293
+ disableMFA(body: DisableMFARequest, token: string): Promise<DisableResponse>;
1294
+ /**
1295
+ * Regenerate MFA recovery codes
1296
+ * POST /v1/mfa/recovery/regenerate
1297
+ */
1298
+ regenerateMFARecoveryCodes(body: RegenerateMFARecoveryCodesRequest, token: string): Promise<RecoveryRegenerateResponse>;
1299
+ /**
1300
+ * Verify MFA recovery code
1301
+ * POST /v1/mfa/recovery/verify
1302
+ */
1303
+ verifyRecoveryCode(body: VerifyRecoveryCodeRequest): Promise<RecoveryVerifyResponse>;
1304
+ /**
1305
+ * Send SMS verification code
1306
+ * POST /v1/mfa/sms/send
1307
+ */
1308
+ sendSMSCode(body: SendSMSCodeRequest, token: string): Promise<SMSSendResponse>;
1309
+ /**
1310
+ * Verify SMS code
1311
+ * POST /v1/mfa/sms/verify
1312
+ */
1313
+ verifySMSCode(body: VerifySMSCodeRequest, token: string): Promise<SMSVerifyResponse>;
1314
+ /**
1315
+ * Verify MFA code
1316
+ * POST /v1/mfa/verify
1317
+ */
1318
+ verifyMFA(body: VerifyMFARequest): Promise<VerifyMFAResponse>;
1319
+ /**
1320
+ * List organizations
1321
+ * GET /v1/orgs
1322
+ */
1323
+ listOrganizations(token: string): Promise<OrgListResponse>;
1324
+ /**
1325
+ * Create organization
1326
+ * POST /v1/orgs
1327
+ */
1328
+ createOrganization(body: CreateOrganizationRequest, token: string): Promise<Organization>;
1329
+ /**
1330
+ * Check slug availability
1331
+ * GET /v1/orgs/check-slug
449
1332
  */
450
- verifyMagicLink(request: MagicLinkVerifyRequest): Promise<void>;
1333
+ checkOrgSlug(token: string): Promise<SlugAvailableResponse>;
451
1334
  /**
452
- * Send phone verification code
1335
+ * Accept invitation
1336
+ * POST /v1/orgs/invitations/accept
453
1337
  */
454
- sendPhoneCode(request: PhoneAuthRequest): Promise<void>;
1338
+ acceptInvitation(body: AcceptInvitationRequest, token: string): Promise<Member>;
455
1339
  /**
456
- * Verify phone code
1340
+ * Decline invitation
1341
+ * POST /v1/orgs/invitations/decline
457
1342
  */
458
- verifyPhoneCode(request: PhoneVerifyRequest): Promise<void>;
1343
+ declineInvitation(body: DeclineInvitationRequest, token: string): Promise<StatusResponse>;
459
1344
  /**
460
- * Setup 2FA
1345
+ * Get organization
1346
+ * GET /v1/orgs/{orgId}
461
1347
  */
462
- setupTwoFactor(request: TwoFactorSetupRequest): Promise<TwoFactorSetupResponse>;
1348
+ getOrganization(orgId: string, token: string): Promise<Organization>;
463
1349
  /**
464
- * Verify 2FA code
1350
+ * Update organization
1351
+ * PATCH /v1/orgs/{orgId}
465
1352
  */
466
- verifyTwoFactor(request: TwoFactorVerifyRequest): Promise<void>;
1353
+ updateOrganization(orgId: string, body: UpdateOrganizationRequest, token: string): Promise<Organization>;
467
1354
  /**
468
- * Disable 2FA
1355
+ * Delete organization
1356
+ * DELETE /v1/orgs/{orgId}
469
1357
  */
470
- disableTwoFactor(): Promise<void>;
1358
+ deleteOrganization(orgId: string, body: DeleteOrganizationRequest, token: string): Promise<StatusResponse>;
471
1359
  /**
472
- * Get 2FA status
1360
+ * List invitations
1361
+ * GET /v1/orgs/{orgId}/invitations
473
1362
  */
474
- getTwoFactorStatus(): Promise<TwoFactorMethod[]>;
1363
+ listInvitations(orgId: string, token: string): Promise<InvitationListResponse>;
475
1364
  /**
476
- * Register passkey
1365
+ * Create invitation
1366
+ * POST /v1/orgs/{orgId}/invitations
477
1367
  */
478
- registerPasskey(request: PasskeyRegisterRequest): Promise<PasskeyCredential>;
1368
+ createInvitation(orgId: string, body: CreateInvitationRequest, token: string): Promise<Invitation>;
479
1369
  /**
480
- * Authenticate with passkey
1370
+ * List members
1371
+ * GET /v1/orgs/{orgId}/members
481
1372
  */
482
- authenticatePasskey(request: PasskeyAuthRequest): Promise<void>;
1373
+ listMembers(orgId: string, token: string): Promise<MemberListResponse>;
1374
+ /**
1375
+ * Add member
1376
+ * POST /v1/orgs/{orgId}/members
1377
+ */
1378
+ addMember(orgId: string, body: AddMemberRequest, token: string): Promise<Member>;
1379
+ /**
1380
+ * Update member role
1381
+ * PATCH /v1/orgs/{orgId}/members/{memberId}
1382
+ */
1383
+ updateMember(orgId: string, memberId: string, body: UpdateMemberRequest, token: string): Promise<Member>;
1384
+ /**
1385
+ * Remove member
1386
+ * DELETE /v1/orgs/{orgId}/members/{memberId}
1387
+ */
1388
+ removeMember(orgId: string, memberId: string, body: RemoveMemberRequest, token: string): Promise<StatusResponse>;
1389
+ /**
1390
+ * List teams
1391
+ * GET /v1/orgs/{orgId}/teams
1392
+ */
1393
+ listTeams(orgId: string, token: string): Promise<TeamListResponse>;
1394
+ /**
1395
+ * Create team
1396
+ * POST /v1/orgs/{orgId}/teams
1397
+ */
1398
+ createTeam(orgId: string, body: CreateTeamRequest, token: string): Promise<Team>;
1399
+ /**
1400
+ * Get team
1401
+ * GET /v1/orgs/{orgId}/teams/{teamId}
1402
+ */
1403
+ getTeam(orgId: string, teamId: string, token: string): Promise<Team>;
1404
+ /**
1405
+ * Update team
1406
+ * PATCH /v1/orgs/{orgId}/teams/{teamId}
1407
+ */
1408
+ updateTeam(orgId: string, teamId: string, body: UpdateTeamRequest, token: string): Promise<Team>;
1409
+ /**
1410
+ * Delete team
1411
+ * DELETE /v1/orgs/{orgId}/teams/{teamId}
1412
+ */
1413
+ deleteTeam(orgId: string, teamId: string, body: DeleteTeamRequest, token: string): Promise<StatusResponse>;
483
1414
  /**
484
1415
  * List passkeys
1416
+ * GET /v1/passkeys/
485
1417
  */
486
- listPasskeys(): Promise<PasskeyCredential[]>;
1418
+ listPasskeys(token: string): Promise<ListResponse$1>;
1419
+ /**
1420
+ * Begin passkey login
1421
+ * POST /v1/passkeys/login/begin
1422
+ */
1423
+ passkeyLoginBegin(body: PasskeyLoginBeginRequest): Promise<LoginBeginResponse>;
1424
+ /**
1425
+ * Complete passkey login
1426
+ * POST /v1/passkeys/login/finish
1427
+ */
1428
+ passkeyLoginFinish(body: PasskeyLoginFinishRequest): Promise<LoginFinishResponse>;
1429
+ /**
1430
+ * Begin passkey registration
1431
+ * POST /v1/passkeys/register/begin
1432
+ */
1433
+ passkeyRegisterBegin(body: PasskeyRegisterBeginRequest, token: string): Promise<RegisterBeginResponse>;
1434
+ /**
1435
+ * Complete passkey registration
1436
+ * POST /v1/passkeys/register/finish
1437
+ */
1438
+ passkeyRegisterFinish(body: PasskeyRegisterFinishRequest, token: string): Promise<RegisterFinishResponse>;
487
1439
  /**
488
1440
  * Delete passkey
1441
+ * DELETE /v1/passkeys/{credentialId}
489
1442
  */
490
- deletePasskey(credentialId: string): Promise<void>;
1443
+ deletePasskey(credentialId: string, body: DeletePasskeyRequest, token: string): Promise<DeleteResponse>;
491
1444
  /**
492
- * Get all organizations the user belongs to
493
- * Only available if the provider supports organizations
1445
+ * Refresh tokens
1446
+ * POST /v1/refresh
494
1447
  */
495
- getOrganizations(): Promise<Organization[]>;
1448
+ refresh(body: RefreshRequest): Promise<TokenResponse>;
496
1449
  /**
497
- * Get the currently active organization
498
- * Only available if the provider supports organizations
1450
+ * Reset password
1451
+ * POST /v1/reset-password
499
1452
  */
500
- getActiveOrganization(): Promise<Organization | null>;
1453
+ resetPassword(body: ResetPasswordRequest): Promise<StatusResponse>;
501
1454
  /**
502
- * Set the active organization and refresh user state
503
- * Only available if the provider supports organizations
1455
+ * List roles
1456
+ * GET /v1/roles
504
1457
  */
505
- setActiveOrganization(organizationId: string): Promise<void>;
1458
+ authsomeListRoles(token: string): Promise<RoleListResponse>;
506
1459
  /**
507
- * Get organization memberships with roles and permissions
508
- * Only available if the provider supports organizations
1460
+ * Create role
1461
+ * POST /v1/roles
509
1462
  */
510
- getOrganizationMemberships(): Promise<OrganizationMembership[]>;
1463
+ authsomeCreateRole(body: AuthsomeCreateRoleRequest, token: string): Promise<Role>;
511
1464
  /**
512
- * Check if the provider supports organizations
1465
+ * Get role
1466
+ * GET /v1/roles/{roleId}
513
1467
  */
514
- supportsOrganizations(): boolean;
1468
+ authsomeGetRole(roleId: string, token: string): Promise<Role>;
515
1469
  /**
516
- * Refresh session
1470
+ * Update role
1471
+ * PATCH /v1/roles/{roleId}
517
1472
  */
518
- refreshSession(): Promise<void>;
1473
+ authsomeUpdateRole(roleId: string, body: AuthsomeUpdateRoleRequest, token: string): Promise<Role>;
519
1474
  /**
520
- * Get current user
1475
+ * Delete role
1476
+ * DELETE /v1/roles/{roleId}
521
1477
  */
522
- getUser(): User | null;
1478
+ authsomeDeleteRole(roleId: string, token: string): Promise<StatusResponse>;
523
1479
  /**
524
- * Get current session
1480
+ * Assign role to user
1481
+ * POST /v1/roles/{roleId}/assign
525
1482
  */
526
- getSession(): Session | null;
1483
+ authsomeAssignRole(roleId: string, body: AuthsomeAssignRoleRequest, token: string): Promise<StatusResponse>;
527
1484
  /**
528
- * Check if authenticated
1485
+ * List role permissions
1486
+ * GET /v1/roles/{roleId}/permissions
529
1487
  */
530
- isAuthenticated(): boolean;
1488
+ authsomeListRolePermissions(roleId: string, token: string): Promise<PermissionListResponse>;
531
1489
  /**
532
- * Get current error
1490
+ * Add permission to role
1491
+ * POST /v1/roles/{roleId}/permissions
533
1492
  */
534
- getError(): AuthError | null;
1493
+ authsomeAddPermission(roleId: string, body: AuthsomeAddPermissionRequest, token: string): Promise<Permission>;
535
1494
  /**
536
- * Clear error
1495
+ * Remove permission from role
1496
+ * DELETE /v1/roles/{roleId}/permissions/{permissionId}
537
1497
  */
538
- clearError(): void;
1498
+ authsomeRemovePermission(roleId: string, permissionId: string, token: string): Promise<StatusResponse>;
539
1499
  /**
540
- * Subscribe to auth state changes
1500
+ * Unassign role from user
1501
+ * POST /v1/roles/{roleId}/unassign
541
1502
  */
542
- subscribe(listener: (context: AuthContext) => void): Unsubscribe;
1503
+ authsomeUnassignRole(roleId: string, body: AuthsomeUnassignRoleRequest, token: string): Promise<StatusResponse>;
543
1504
  /**
544
- * Cleanup resources
1505
+ * List sessions
1506
+ * GET /v1/sessions
545
1507
  */
546
- destroy(): void;
547
- private updateState;
548
- private setLoading;
549
- private handleError;
550
- private startAutoRefresh;
551
- private stopAutoRefresh;
552
- private createUnsupportedError;
553
- }
554
-
555
- /**
556
- * Authentication flow types and state machine
557
- */
558
-
559
- /**
560
- * Available authentication flow steps
561
- */
562
- declare enum FlowStep {
563
- SIGN_IN = "sign_in",
564
- SIGN_UP = "sign_up",
565
- EMAIL_PASSWORD_SIGN_IN = "email_password_sign_in",
566
- EMAIL_PASSWORD_SIGN_UP = "email_password_sign_up",
567
- OAUTH_SELECT = "oauth_select",
568
- OAUTH_CALLBACK = "oauth_callback",
569
- MAGIC_LINK_REQUEST = "magic_link_request",
570
- MAGIC_LINK_VERIFY = "magic_link_verify",
571
- MAGIC_LINK_SENT = "magic_link_sent",
572
- PHONE_REQUEST = "phone_request",
573
- PHONE_VERIFY = "phone_verify",
574
- USERNAME_SIGN_IN = "username_sign_in",
575
- USERNAME_SIGN_UP = "username_sign_up",
576
- PASSKEY_REGISTER = "passkey_register",
577
- PASSKEY_AUTHENTICATE = "passkey_authenticate",
578
- MFA_REQUIRED = "mfa_required",
579
- MFA_SETUP = "mfa_setup",
580
- MFA_VERIFY = "mfa_verify",
581
- MFA_SELECT_METHOD = "mfa_select_method",
582
- EMAIL_VERIFICATION_REQUIRED = "email_verification_required",
583
- EMAIL_VERIFICATION_SENT = "email_verification_sent",
584
- PHONE_VERIFICATION_REQUIRED = "phone_verification_required",
585
- PASSWORD_RESET_REQUEST = "password_reset_request",
586
- PASSWORD_RESET_SENT = "password_reset_sent",
587
- PASSWORD_RESET_CONFIRM = "password_reset_confirm",
588
- PASSWORD_CHANGE = "password_change",
589
- PROFILE_UPDATE = "profile_update",
590
- PROFILE_COMPLETE = "profile_complete",
591
- DEVICE_FLOW_INITIATE = "device_flow_initiate",
592
- DEVICE_CODE_ENTRY = "device_code_entry",
593
- DEVICE_CODE_VERIFY = "device_code_verify",
594
- DEVICE_AUTHORIZE = "device_authorize",
595
- DEVICE_POLLING = "device_polling",
596
- DEVICE_AUTHORIZED = "device_authorized",
597
- DEVICE_DENIED = "device_denied",
598
- SUCCESS = "success",
599
- ERROR = "error",
600
- CANCELLED = "cancelled"
601
- }
602
- /**
603
- * Flow state data that can be passed between steps
604
- */
605
- interface FlowState {
606
- currentStep: FlowStep;
607
- previousStep?: FlowStep;
608
- user?: User;
609
- session?: Session;
610
- email?: string;
611
- phone?: string;
612
- username?: string;
613
- token?: string;
614
- mfaRequired?: boolean;
615
- mfaMethods?: TwoFactorMethod[];
616
- mfaToken?: string;
617
- oauthProvider?: OAuthProvider;
618
- oauthRedirectUrl?: string;
619
- verificationRequired?: boolean;
620
- verificationToken?: string;
621
- verificationSent?: boolean;
622
- deviceCode?: string;
623
- userCode?: string;
624
- verificationUri?: string;
625
- verificationUriComplete?: string;
626
- deviceCodeExpiresIn?: number;
627
- devicePollingInterval?: number;
628
- deviceClientId?: string;
629
- deviceScopes?: string[];
630
- deviceAuthorized?: boolean;
631
- error?: AuthError;
632
- metadata?: Record<string, unknown>;
633
- }
634
- /**
635
- * Flow transition result
636
- */
637
- interface FlowTransition {
638
- nextStep: FlowStep;
639
- state: Partial<FlowState>;
640
- }
641
- /**
642
- * Flow configuration for a specific authentication journey
643
- */
644
- interface FlowConfig {
645
- name: string;
646
- description?: string;
647
- initialStep: FlowStep;
648
- allowedSteps: FlowStep[];
649
- transitions: {
650
- [key in FlowStep]?: {
651
- onSuccess?: FlowStep;
652
- onError?: FlowStep;
653
- onCancel?: FlowStep;
654
- onBack?: FlowStep;
655
- conditions?: Array<{
656
- when: (state: FlowState) => boolean;
657
- then: FlowStep;
658
- }>;
659
- };
660
- };
661
- onStepChange?: (step: FlowStep, state: FlowState) => void;
662
- onComplete?: (user: User, session: Session) => void;
663
- onError?: (error: AuthError, state: FlowState) => void;
664
- onCancel?: (state: FlowState) => void;
665
- }
666
- /**
667
- * Predefined flow configurations
668
- */
669
- declare enum FlowConfigType {
670
- SIMPLE_SIGN_IN = "simple_sign_in",
671
- SIMPLE_SIGN_UP = "simple_sign_up",
672
- SIGN_UP_WITH_EMAIL_VERIFICATION = "sign_up_with_email_verification",
673
- SIGN_IN_WITH_MFA = "sign_in_with_mfa",
674
- OAUTH_SIGN_IN = "oauth_sign_in",
675
- MAGIC_LINK_FLOW = "magic_link_flow",
676
- PHONE_AUTH_FLOW = "phone_auth_flow",
677
- COMPLETE_SIGN_UP_FLOW = "complete_sign_up_flow",// signup → verify email → complete profile
678
- SECURE_SIGN_IN_FLOW = "secure_sign_in_flow",// signin → MFA → success
679
- PASSWORD_RESET_FLOW = "password_reset_flow",
680
- EMAIL_VERIFICATION_FLOW = "email_verification_flow",
681
- DEVICE_FLOW = "device_flow",
682
- CUSTOM = "custom"
683
- }
684
- /**
685
- * Flow action types
686
- */
687
- declare enum FlowAction {
688
- START = "start",
689
- NEXT = "next",
690
- BACK = "back",
691
- CANCEL = "cancel",
692
- ERROR = "error",
693
- RESET = "reset"
694
- }
695
- /**
696
- * Flow event for state machine
697
- */
698
- interface FlowEvent {
699
- action: FlowAction;
700
- data?: Partial<FlowState>;
701
- error?: AuthError;
702
- }
703
-
704
- /**
705
- * Authentication flow state machine engine
706
- */
707
-
708
- /**
709
- * Flow engine that manages authentication flow state transitions
710
- */
711
- declare class FlowEngine {
712
- private config;
713
- private state;
714
- private history;
715
- constructor(config: FlowConfig, initialState?: Partial<FlowState>);
1508
+ listSessions(token: string): Promise<SessionListResponse>;
716
1509
  /**
717
- * Get current flow state
1510
+ * Revoke session
1511
+ * DELETE /v1/sessions/{sessionId}
718
1512
  */
719
- getState(): FlowState;
1513
+ revokeSession(sessionId: string, body: RevokeSessionRequest, token: string): Promise<StatusResponse>;
720
1514
  /**
721
- * Get current step
1515
+ * Sign in
1516
+ * POST /v1/signin
722
1517
  */
723
- getCurrentStep(): FlowStep;
1518
+ signIn(body: SignInRequest): Promise<AuthResponse>;
724
1519
  /**
725
- * Check if step is allowed in this flow
1520
+ * Sign out
1521
+ * POST /v1/signout
726
1522
  */
727
- isStepAllowed(step: FlowStep): boolean;
1523
+ signOut(body: SignOutRequest, token: string): Promise<StatusResponse>;
728
1524
  /**
729
- * Transition to next step based on action
1525
+ * Sign up
1526
+ * POST /v1/signup
730
1527
  */
731
- transition(event: FlowEvent): Promise<FlowState>;
1528
+ signUp(body: SignUpRequest): Promise<AuthResponse>;
732
1529
  /**
733
- * Start or restart the flow
1530
+ * Start OAuth flow
1531
+ * POST /v1/social/{provider}
734
1532
  */
735
- private handleStart;
1533
+ startOAuth(provider: string, body: StartOAuthRequest): Promise<StartResponse>;
736
1534
  /**
737
- * Move to next step
1535
+ * OAuth callback
1536
+ * GET /v1/social/{provider}/callback
738
1537
  */
739
- private handleNext;
1538
+ oauthCallback(provider: string): Promise<CallbackResponse>;
740
1539
  /**
741
- * Go back to previous step
1540
+ * SSO SAML ACS endpoint
1541
+ * POST /v1/sso/{provider}/acs
742
1542
  */
743
- private handleBack;
1543
+ ssoACS(provider: string, body: SsoACSRequest): Promise<CallbackResponse>;
744
1544
  /**
745
- * Cancel the flow
1545
+ * SSO callback (OIDC)
1546
+ * POST /v1/sso/{provider}/callback
746
1547
  */
747
- private handleCancel;
1548
+ ssoCallback(provider: string, body: SsoCallbackRequest): Promise<CallbackResponse>;
748
1549
  /**
749
- * Handle error in flow
1550
+ * Start SSO login flow
1551
+ * POST /v1/sso/{provider}/login
750
1552
  */
751
- private handleError;
1553
+ startSSOLogin(provider: string, body: StartSSOLoginRequest): Promise<LoginResponse>;
1554
+ /**
1555
+ * List user roles
1556
+ * GET /v1/users/{userId}/roles
1557
+ */
1558
+ authsomeListUserRoles(userId: string, token: string): Promise<UserRoleListResponse>;
752
1559
  /**
753
- * Reset flow to initial state
1560
+ * Verify email
1561
+ * POST /v1/verify-email
754
1562
  */
755
- private handleReset;
1563
+ verifyEmail(body: VerifyEmailRequest): Promise<StatusResponse>;
756
1564
  /**
757
- * Move to a specific step
1565
+ * List webhooks
1566
+ * GET /v1/webhooks
758
1567
  */
759
- private moveToStep;
1568
+ listWebhooks(token: string): Promise<WebhookListResponse>;
760
1569
  /**
761
- * Get flow history
1570
+ * Create webhook
1571
+ * POST /v1/webhooks
762
1572
  */
763
- getHistory(): FlowStep[];
1573
+ createWebhook(body: CreateWebhookRequest, token: string): Promise<Webhook>;
764
1574
  /**
765
- * Check if can go back
1575
+ * Get webhook
1576
+ * GET /v1/webhooks/{webhookId}
766
1577
  */
767
- canGoBack(): boolean;
1578
+ getWebhook(webhookId: string, token: string): Promise<Webhook>;
1579
+ /**
1580
+ * Update webhook
1581
+ * PATCH /v1/webhooks/{webhookId}
1582
+ */
1583
+ updateWebhook(webhookId: string, body: UpdateWebhookRequest, token: string): Promise<Webhook>;
1584
+ /**
1585
+ * Delete webhook
1586
+ * DELETE /v1/webhooks/{webhookId}
1587
+ */
1588
+ deleteWebhook(webhookId: string, body: DeleteWebhookRequest, token: string): Promise<StatusResponse>;
1589
+ private request;
1590
+ }
1591
+ declare class AuthClientError extends Error {
1592
+ code?: number;
1593
+ constructor(message: string, code?: number);
768
1594
  }
769
1595
 
770
1596
  /**
771
- * Predefined flow configurations
1597
+ * AuthClient adapter — thin wrapper over the auto-generated API client.
1598
+ *
1599
+ * The generated client lives in ./generated/api-client.ts and covers all
1600
+ * core + plugin endpoints. This file extends it with a few convenience
1601
+ * overrides so that auth.ts (and downstream consumers) keep working
1602
+ * without changes.
772
1603
  */
773
1604
 
1605
+ /** Options for paginated list endpoints. */
1606
+ interface ListOptions {
1607
+ limit?: number;
1608
+ offset?: number;
1609
+ }
1610
+ /** Paginated list response. */
1611
+ interface ListResponse<T> {
1612
+ items: T[];
1613
+ total: number;
1614
+ }
774
1615
  /**
775
- * Simple sign-in flow (email/password only)
776
- */
777
- declare const simpleSignInFlow: FlowConfig;
778
- /**
779
- * Sign-in with MFA support
780
- */
781
- declare const signInWithMFAFlow: FlowConfig;
782
- /**
783
- * Complete sign-up flow with email verification
784
- */
785
- declare const completeSignUpFlow: FlowConfig;
786
- /**
787
- * Magic link authentication flow
1616
+ * AuthClient extends the auto-generated client with backward-compatible
1617
+ * convenience methods that auth.ts depends on.
1618
+ *
1619
+ * All 80+ generated endpoints are inherited as-is. Only two methods
1620
+ * are overridden to preserve the simpler call-site signatures used by
1621
+ * the auth state machine.
788
1622
  */
789
- declare const magicLinkFlow: FlowConfig;
1623
+ declare class AuthClient extends AuthClient$1 {
1624
+ /**
1625
+ * Refresh session tokens.
1626
+ *
1627
+ * Accepts a raw refresh-token string (used by auth.ts) or the full
1628
+ * RefreshRequest body.
1629
+ */
1630
+ refresh(body: {
1631
+ refresh_token: string;
1632
+ } | string): Promise<any>;
1633
+ /**
1634
+ * Sign out.
1635
+ *
1636
+ * Accepts a raw token string (used by auth.ts) or the full
1637
+ * (body, token) pair from the generated client.
1638
+ */
1639
+ signOut(bodyOrToken: unknown, token?: string): Promise<any>;
1640
+ /**
1641
+ * MFA challenge — bridge for auth.ts.
1642
+ *
1643
+ * auth.ts calls `mfaChallenge({ enrollment_id, code })` and expects
1644
+ * an AuthResponse back. The generated client uses `challengeMFA`.
1645
+ */
1646
+ mfaChallenge(body: {
1647
+ enrollment_id?: string;
1648
+ code: string;
1649
+ }): Promise<any>;
1650
+ /**
1651
+ * Verify an MFA recovery code.
1652
+ *
1653
+ * Accepts a raw code string (used by auth.ts) or the full request body.
1654
+ */
1655
+ verifyRecoveryCode(body: {
1656
+ code: string;
1657
+ } | string): Promise<any>;
1658
+ /**
1659
+ * Send an SMS code for MFA — bridge for auth.ts.
1660
+ *
1661
+ * Simplifies the call-site by accepting just the session token.
1662
+ */
1663
+ sendSMSCodeForMFA(token: string): Promise<any>;
1664
+ /**
1665
+ * Verify an SMS code for MFA — bridge for auth.ts.
1666
+ *
1667
+ * Simplifies the call-site by accepting code + token directly.
1668
+ */
1669
+ verifySMSCodeForMFA(code: string, token: string): Promise<any>;
1670
+ /**
1671
+ * Fetch the client configuration from the backend.
1672
+ *
1673
+ * The config describes which auth methods are enabled so SDK
1674
+ * components can auto-configure without manual props.
1675
+ */
1676
+ fetchClientConfig(publishableKey?: string): Promise<ClientConfig>;
1677
+ }
1678
+
790
1679
  /**
791
- * Phone authentication flow
1680
+ * Framework-agnostic authentication state machine.
1681
+ *
1682
+ * Manages sign-in/sign-up flows, token persistence, automatic refresh,
1683
+ * and MFA challenges. Framework adapters (React, Vue, etc.) wrap this
1684
+ * class and expose reactive state.
792
1685
  */
793
- declare const phoneAuthFlow: FlowConfig;
1686
+
794
1687
  /**
795
- * OAuth sign-in flow
1688
+ * AuthManager is the core state machine that drives authentication.
1689
+ *
1690
+ * Usage:
1691
+ * ```ts
1692
+ * const auth = new AuthManager({ baseURL: "https://api.example.com" });
1693
+ * auth.subscribe((state) => console.log(state));
1694
+ * await auth.initialize(); // hydrate from storage
1695
+ * await auth.signIn({ email, password });
1696
+ * ```
796
1697
  */
797
- declare const oauthSignInFlow: FlowConfig;
1698
+ declare class AuthManager {
1699
+ private client;
1700
+ private storage;
1701
+ private state;
1702
+ private listeners;
1703
+ private refreshTimer;
1704
+ private onError?;
1705
+ private publishableKey?;
1706
+ private clientConfig;
1707
+ private configListeners;
1708
+ private configFetchPromise;
1709
+ constructor(config: AuthConfig);
1710
+ /** Current auth state (snapshot). */
1711
+ getState(): AuthState;
1712
+ /** Subscribe to state changes. Returns an unsubscribe function. */
1713
+ subscribe(listener: (state: AuthState) => void): () => void;
1714
+ /** Access the underlying HTTP client. */
1715
+ getClient(): AuthClient;
1716
+ /**
1717
+ * Initialize by hydrating the session from storage.
1718
+ * When a publishableKey is set, also fetches client config in parallel.
1719
+ * Call this once on app start.
1720
+ */
1721
+ initialize(): Promise<void>;
1722
+ /** Sign in with email & password. */
1723
+ signIn(credentials: SignInRequest): Promise<void>;
1724
+ /** Sign up with email & password. */
1725
+ signUp(data: SignUpRequest): Promise<void>;
1726
+ /** Sign out and clear the session. */
1727
+ signOut(): Promise<void>;
1728
+ /** Submit an MFA challenge code. */
1729
+ submitMFACode(enrollmentId: string, code: string): Promise<void>;
1730
+ /** Submit an MFA recovery code. */
1731
+ submitRecoveryCode(code: string): Promise<void>;
1732
+ /** Send an SMS code for MFA verification. Returns masked phone + expiry info. */
1733
+ sendSMSCode(): Promise<{
1734
+ sent: boolean;
1735
+ phone_masked: string;
1736
+ expires_in_seconds: number;
1737
+ }>;
1738
+ /** Submit an SMS verification code during MFA challenge. */
1739
+ submitSMSCode(code: string): Promise<void>;
1740
+ /** Refresh the current session manually. */
1741
+ refreshNow(): Promise<void>;
1742
+ /** Get the current session token (if authenticated). */
1743
+ getSessionToken(): string | null;
1744
+ /** Get the current user (if authenticated). */
1745
+ getUser(): User | null;
1746
+ /** Get the cached client config (or null if not yet fetched). */
1747
+ getClientConfig(): ClientConfig | null;
1748
+ /** Subscribe to client config changes. Returns an unsubscribe function. */
1749
+ subscribeConfig(listener: (config: ClientConfig | null) => void): () => void;
1750
+ /**
1751
+ * Fetch client config from the backend.
1752
+ * Deduplicates concurrent calls and caches the result with a TTL.
1753
+ */
1754
+ fetchClientConfig(): Promise<ClientConfig>;
1755
+ /** Tear down: clear timers and listeners. */
1756
+ destroy(): void;
1757
+ private handleAuthResponse;
1758
+ private refreshSession;
1759
+ private scheduleRefresh;
1760
+ private clearRefreshTimer;
1761
+ private persistSession;
1762
+ private clearSession;
1763
+ private setClientConfig;
1764
+ private setState;
1765
+ private handleError;
1766
+ }
1767
+
798
1768
  /**
799
- * Password reset flow
1769
+ * WebAuthn encoding helpers.
1770
+ *
1771
+ * The go-webauthn backend serialises binary fields (challenge, user.id,
1772
+ * credential IDs, …) as **base64url strings** in JSON. The browser
1773
+ * WebAuthn API requires those same fields as ArrayBuffer / Uint8Array.
1774
+ *
1775
+ * These helpers bridge the gap in both directions:
1776
+ * begin response → browser API (base64url string → ArrayBuffer)
1777
+ * browser API → finish POST (ArrayBuffer → base64url string)
800
1778
  */
801
- declare const passwordResetFlow: FlowConfig;
1779
+ /** Decode a base64url-encoded string into a Uint8Array. */
1780
+ declare function base64urlToBuffer(base64url: string): Uint8Array;
1781
+ /** Encode an ArrayBuffer (or Uint8Array) to a base64url string (no padding). */
1782
+ declare function bufferToBase64url(buffer: ArrayBuffer | Uint8Array): string;
802
1783
  /**
803
- * Email verification flow
1784
+ * Prepare the options object returned by `/passkeys/register/begin`
1785
+ * for `navigator.credentials.create({ publicKey })`.
1786
+ *
1787
+ * Converts base64url strings → Uint8Array for:
1788
+ * challenge, user.id, excludeCredentials[].id
804
1789
  */
805
- declare const emailVerificationFlow: FlowConfig;
1790
+ declare function prepareCreationOptions(options: Record<string, unknown>): PublicKeyCredentialCreationOptions;
806
1791
  /**
807
- * Get predefined flow configuration by type
1792
+ * Prepare the options object returned by `/passkeys/login/begin`
1793
+ * for `navigator.credentials.get({ publicKey })`.
1794
+ *
1795
+ * Converts base64url strings → Uint8Array for:
1796
+ * challenge, allowCredentials[].id
808
1797
  */
809
- declare function getFlowConfig(type: FlowConfigType): FlowConfig;
1798
+ declare function prepareRequestOptions(options: Record<string, unknown>): PublicKeyCredentialRequestOptions;
810
1799
  /**
811
- * Export all predefined flows
1800
+ * Serialize a PublicKeyCredential returned by navigator.credentials
1801
+ * into a plain object suitable for POSTing to the `/finish` endpoint.
1802
+ *
1803
+ * Converts ArrayBuffer fields → base64url strings so they survive
1804
+ * JSON.stringify and match what go-webauthn expects.
812
1805
  */
813
- declare const predefinedFlows: {
814
- simple_sign_in: FlowConfig;
815
- sign_in_with_mfa: FlowConfig;
816
- complete_sign_up_flow: FlowConfig;
817
- magic_link_flow: FlowConfig;
818
- phone_auth_flow: FlowConfig;
819
- oauth_sign_in: FlowConfig;
820
- password_reset_flow: FlowConfig;
821
- email_verification_flow: FlowConfig;
822
- device_flow: FlowConfig;
823
- };
1806
+ declare function serializeCredential(credential: Credential): Record<string, unknown>;
824
1807
 
825
- export { AuthClient, type AuthClientConfig, AuthContext, AuthError, AuthErrorType, type AuthLocale, AuthProvider, CookieData, type DeepPartial, FlowAction, type FlowConfig, FlowConfigType, FlowEngine, type FlowEvent, type FlowState, FlowStep, type FlowTransition, MagicLinkRequest, MagicLinkVerifyRequest, OAuthCallbackRequest, OAuthProvider, OAuthSignInRequest, Observable, Organization, OrganizationMembership, PasskeyAuthRequest, PasskeyCredential, PasskeyRegisterRequest, PasswordChangeRequest, PasswordResetConfirmRequest, PasswordResetRequest, PhoneAuthRequest, PhoneVerifyRequest, Session, SignInRequest, SignUpRequest, Storage, TokenManager, TwoFactorMethod, TwoFactorSetupRequest, TwoFactorSetupResponse, TwoFactorVerifyRequest, Unsubscribe, UpdateUserRequest, User, ValidationError, completeSignUpFlow, createAuthError, createLocale, defaultLocale, emailVerificationFlow, extractCookiesFromHeaders, getFlowConfig, interpolate, isAuthError, isMFARequiredError, isNetworkError, isUnauthenticatedError, magicLinkFlow, oauthSignInFlow, parseCookie, parseCookieOptions, passwordResetFlow, phoneAuthFlow, predefinedFlows, serializeCookie, serializeCookies, signInWithMFAFlow, simpleSignInFlow, toAuthError, validate2FACode, validateEmail, validatePassword, validatePhone, validateRequired, validateUsername };
1808
+ 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 SignupFieldConfig, type SignupFieldOption, type SignupFieldValidation, 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 };