@tktchurch/auth 0.9.1 → 0.9.5

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.
@@ -0,0 +1,1379 @@
1
+ type DataSubjectRequestType = "access" | "correction" | "erasure" | "grievance" | "nominate";
2
+ type DataSubjectRequestStatus = "submitted" | "in_progress" | "resolved" | "rejected" | "cancelled";
3
+ type DataExportStatus = "pending" | "processing" | "completed" | "failed" | "expired";
4
+ interface PrivacyNotice {
5
+ id: string;
6
+ version: string;
7
+ locale: string;
8
+ purpose: string;
9
+ title: string;
10
+ body: string;
11
+ effectiveAt: string;
12
+ isActive: boolean;
13
+ createdAt?: string;
14
+ }
15
+ interface PrivacyConsentRecord {
16
+ id: string;
17
+ userId: string;
18
+ noticeId: string;
19
+ lawfulBasis: string;
20
+ purposes: string[];
21
+ acceptedAt: string;
22
+ withdrawnAt?: string;
23
+ createdAt?: string;
24
+ }
25
+ interface DataSubjectRequest {
26
+ id: string;
27
+ userId: string;
28
+ organizationId?: string;
29
+ type: DataSubjectRequestType;
30
+ status: DataSubjectRequestStatus;
31
+ description?: string;
32
+ handlerUserId?: string;
33
+ slaDeadline?: string;
34
+ resolutionNotes?: string;
35
+ resolvedAt?: string;
36
+ createdAt?: string;
37
+ updatedAt?: string;
38
+ }
39
+ interface DataExportJob {
40
+ id: string;
41
+ status: DataExportStatus;
42
+ format: string;
43
+ downloadUrl?: string;
44
+ payload?: Record<string, string>;
45
+ expiresAt?: string;
46
+ errorMessage?: string;
47
+ completedAt?: string;
48
+ createdAt?: string;
49
+ }
50
+ interface GrievanceOfficer {
51
+ name: string;
52
+ email: string;
53
+ phone?: string;
54
+ address?: string;
55
+ slaDays: number;
56
+ }
57
+ interface RetentionPolicy {
58
+ id: string;
59
+ resourceType: string;
60
+ ttlDays: number;
61
+ isActive: boolean;
62
+ createdAt?: string;
63
+ }
64
+ interface PrivacyEndpoints {
65
+ currentNotice(input?: {
66
+ locale?: string;
67
+ purpose?: string;
68
+ }): Promise<PrivacyNotice>;
69
+ recordConsent(input: {
70
+ noticeId: string;
71
+ purposes: string[];
72
+ lawfulBasis?: string;
73
+ }): Promise<PrivacyConsentRecord>;
74
+ withdrawConsent(consentId: string): Promise<void>;
75
+ submitDataRequest(input: {
76
+ type: DataSubjectRequestType;
77
+ description?: string;
78
+ }): Promise<DataSubjectRequest>;
79
+ listMyRequests(query?: PageQuery): Promise<PageResponse<DataSubjectRequest>>;
80
+ requestExport(input?: {
81
+ refresh?: boolean;
82
+ }): Promise<DataExportJob>;
83
+ downloadExport(exportId: string): Promise<Record<string, string>>;
84
+ grievanceOfficer(): Promise<GrievanceOfficer>;
85
+ admin: {
86
+ listDataRequests(query?: PageQuery & {
87
+ type?: DataSubjectRequestType;
88
+ status?: DataSubjectRequestStatus;
89
+ userId?: string;
90
+ }): Promise<PageResponse<DataSubjectRequest>>;
91
+ getDataRequest(id: string): Promise<DataSubjectRequest>;
92
+ resolveDataRequest(id: string, input: {
93
+ status: DataSubjectRequestStatus;
94
+ resolutionNotes?: string;
95
+ handlerUserId?: string;
96
+ }): Promise<DataSubjectRequest>;
97
+ attachExportArtifact(exportId: string, input: {
98
+ downloadUrl: string;
99
+ expiresAt?: string;
100
+ }): Promise<DataExportJob>;
101
+ listNotices(query?: PageQuery): Promise<PageResponse<PrivacyNotice>>;
102
+ createNotice(input: JsonObject): Promise<PrivacyNotice>;
103
+ updateNotice(id: string, input: JsonObject): Promise<PrivacyNotice>;
104
+ listRetentionPolicies(query?: PageQuery): Promise<PageResponse<RetentionPolicy>>;
105
+ createRetentionPolicy(input: {
106
+ resourceType: string;
107
+ ttlDays: number;
108
+ isActive?: boolean;
109
+ }): Promise<RetentionPolicy>;
110
+ updateRetentionPolicy(id: string, input: {
111
+ ttlDays?: number;
112
+ isActive?: boolean;
113
+ }): Promise<RetentionPolicy>;
114
+ };
115
+ }
116
+
117
+ interface OAuthAuthorizationServerMetadata {
118
+ issuer: string;
119
+ authorizationEndpoint: string;
120
+ tokenEndpoint: string;
121
+ jwksUri?: string;
122
+ revocationEndpoint?: string;
123
+ introspectionEndpoint?: string;
124
+ registrationEndpoint?: string;
125
+ scopesSupported?: string[];
126
+ responseTypesSupported: string[];
127
+ grantTypesSupported?: string[];
128
+ codeChallengeMethodsSupported?: string[];
129
+ /** RFC 9126 pushed authorization request endpoint. */
130
+ pushedAuthorizationRequestEndpoint?: string;
131
+ /** RFC 9126: whether the server requires PAR. */
132
+ requirePushedAuthorizationRequests?: boolean;
133
+ /** RFC 9396 supported authorization details types. */
134
+ authorizationDetailsTypesSupported?: string[];
135
+ raw: JsonObject;
136
+ }
137
+ interface MemberLookupInput {
138
+ memberId: string;
139
+ }
140
+ interface MemberProfile {
141
+ memberId: string;
142
+ firstName?: string;
143
+ middleName?: string;
144
+ lastName?: string;
145
+ email?: string;
146
+ phoneNumber?: string;
147
+ familyName?: string;
148
+ }
149
+ interface MemberDirectoryEndpoints {
150
+ lookup(input: MemberLookupInput): Promise<MemberProfile>;
151
+ }
152
+ interface FederatedSignInUrlOptions {
153
+ clientId?: string;
154
+ redirectUri: string;
155
+ state?: string;
156
+ scope?: string;
157
+ }
158
+ interface FederatedLinkStartOptions {
159
+ redirectUri: string;
160
+ state?: string;
161
+ }
162
+ interface FederatedEndpoints {
163
+ googleSignInUrl(options: FederatedSignInUrlOptions): string;
164
+ appleSignInUrl(options: FederatedSignInUrlOptions): string;
165
+ googleLinkStart(options: FederatedLinkStartOptions): string;
166
+ appleLinkStart(options: FederatedLinkStartOptions): string;
167
+ googleLinkFinalize(input: {
168
+ code: string;
169
+ state: string;
170
+ }): Promise<JsonObject>;
171
+ appleLinkFinalize(input: {
172
+ idToken: string;
173
+ state: string;
174
+ }): Promise<JsonObject>;
175
+ }
176
+ interface FamilyMember {
177
+ id: string;
178
+ userId?: string;
179
+ email?: string;
180
+ role: string;
181
+ status: string;
182
+ externalMemberId?: string;
183
+ }
184
+ interface FamilyAccount {
185
+ id: string;
186
+ name: string;
187
+ source?: string;
188
+ externalFamilyId?: string;
189
+ members: FamilyMember[];
190
+ }
191
+ interface FamilyInviteInput {
192
+ email: string;
193
+ role?: string;
194
+ }
195
+ interface FamiliesEndpoints {
196
+ list(): Promise<FamilyAccount[]>;
197
+ invite(familyId: string, input: FamilyInviteInput): Promise<FamilyAccount>;
198
+ removeMember(familyId: string, memberId: string): Promise<void>;
199
+ }
200
+ interface DependentRecord {
201
+ id: string;
202
+ firstName?: string;
203
+ lastName?: string;
204
+ birthdate?: string;
205
+ accountType: string;
206
+ delegationLevel?: string;
207
+ canActOnBehalf?: boolean;
208
+ consentGivenAt?: string;
209
+ age?: number;
210
+ createdAt?: string;
211
+ }
212
+ interface GuardianConsentRecord {
213
+ id: string;
214
+ dependentUserId: string;
215
+ serviceType: string;
216
+ consentType: string;
217
+ consentedAt?: string;
218
+ expiresAt?: string;
219
+ revokedAt?: string;
220
+ isActive?: boolean;
221
+ coppaApplicable?: boolean;
222
+ gdprArticle8Applicable?: boolean;
223
+ }
224
+ interface GuardianFamilyMember {
225
+ memberId: string;
226
+ userId?: string;
227
+ role: string;
228
+ status: string;
229
+ canActOnBehalf?: boolean;
230
+ delegationLevel?: string;
231
+ accountType?: string;
232
+ displayName?: string;
233
+ }
234
+ interface GuardianFamily {
235
+ id: string;
236
+ name: string;
237
+ organizationId?: string;
238
+ members: GuardianFamilyMember[];
239
+ }
240
+ interface DependentsEndpoints {
241
+ list(): Promise<DependentRecord[]>;
242
+ create(input: JsonObject): Promise<DependentRecord>;
243
+ update(dependentId: string, input: JsonObject): Promise<DependentRecord>;
244
+ remove(dependentId: string): Promise<void>;
245
+ getFamily(): Promise<GuardianFamily>;
246
+ joinOrCreateFamily(input?: JsonObject): Promise<GuardianFamily>;
247
+ grantConsent(dependentId: string, input: JsonObject): Promise<GuardianConsentRecord>;
248
+ revokeConsent(dependentId: string, consentId: string): Promise<void>;
249
+ }
250
+ interface ClientProviderRecord {
251
+ id: string;
252
+ clientId?: string;
253
+ provider: string;
254
+ providerDisplayName?: string;
255
+ isEnabled?: boolean;
256
+ priority?: number;
257
+ customScopes?: string[];
258
+ createdAt?: string;
259
+ updatedAt?: string;
260
+ }
261
+ interface AvailableProviderRecord {
262
+ provider: string;
263
+ displayName?: string;
264
+ isConfigured?: boolean;
265
+ defaultScopes: string[];
266
+ }
267
+ interface ClientProviderEndpoints {
268
+ listAvailable(): Promise<AvailableProviderRecord[]>;
269
+ list(clientId: string): Promise<ClientProviderRecord[]>;
270
+ enable(clientId: string, input: JsonObject): Promise<ClientProviderRecord>;
271
+ get(clientId: string, provider: string): Promise<ClientProviderRecord>;
272
+ update(clientId: string, provider: string, input: JsonObject): Promise<ClientProviderRecord>;
273
+ disable(clientId: string, provider: string): Promise<void>;
274
+ }
275
+ interface ClientApiKeyRecord {
276
+ id: string;
277
+ organizationId?: string;
278
+ clientId?: string;
279
+ name: string;
280
+ keyPrefix?: string;
281
+ scopes: string[];
282
+ isActive?: boolean;
283
+ expiresAt?: string;
284
+ lastUsedAt?: string;
285
+ createdAt?: string;
286
+ }
287
+ interface CreatedClientApiKeyRecord extends ClientApiKeyRecord {
288
+ key?: string;
289
+ }
290
+ interface ClientApiKeysEndpoints {
291
+ list(clientId: string): Promise<ClientApiKeyRecord[]>;
292
+ create(clientId: string, input: JsonObject): Promise<CreatedClientApiKeyRecord>;
293
+ delete(clientId: string, keyId: string): Promise<void>;
294
+ }
295
+ interface TokenExchangeRequest {
296
+ subjectToken: string;
297
+ subjectTokenType?: string;
298
+ requestedSubject: string;
299
+ scope?: string;
300
+ audience?: string;
301
+ }
302
+ interface AuthorizationConsentBody {
303
+ username: string;
304
+ password: string;
305
+ approved?: boolean;
306
+ requestedScopes?: string[];
307
+ mfaCode?: string;
308
+ mfaBackupCode?: string;
309
+ }
310
+ interface AuthorizationConsentResponse {
311
+ redirectUri: string;
312
+ code?: string;
313
+ state?: string;
314
+ error?: string;
315
+ errorDescription?: string;
316
+ mfaMethods?: string[];
317
+ accessToken?: string;
318
+ tokenType?: string;
319
+ expiresIn?: number;
320
+ scope?: string;
321
+ idToken?: string;
322
+ }
323
+ interface ConsentWithCredentialsOptions {
324
+ callbackUrl: string;
325
+ username: string;
326
+ password: string;
327
+ approved?: boolean;
328
+ requestedScopes?: string[];
329
+ mfaCode?: string;
330
+ mfaBackupCode?: string;
331
+ }
332
+ interface AuthorizationConsentEvaluateBody {
333
+ username: string;
334
+ password: string;
335
+ requestedScopes?: string[];
336
+ mfaCode?: string;
337
+ mfaBackupCode?: string;
338
+ }
339
+ interface AuthorizationConsentEvaluateResponse {
340
+ consentSatisfied: boolean;
341
+ requiresMfa: boolean;
342
+ mfaMethods?: string[];
343
+ uncoveredScopes?: string[];
344
+ error?: string;
345
+ errorDescription?: string;
346
+ }
347
+ interface EvaluateConsentWithCredentialsOptions {
348
+ callbackUrl: string;
349
+ username: string;
350
+ password: string;
351
+ requestedScopes?: string[];
352
+ mfaCode?: string;
353
+ mfaBackupCode?: string;
354
+ }
355
+ interface PublicClientInfo {
356
+ clientId: string;
357
+ name: string;
358
+ description?: string;
359
+ isFirstParty: boolean;
360
+ /** Registered OAuth redirect URIs (not secret; used for hosted-login allowlisting). */
361
+ redirectUris: string[];
362
+ }
363
+ interface JwksDocument {
364
+ keys: JsonObject[];
365
+ }
366
+ interface InitRecoveryRequest {
367
+ clientId?: string;
368
+ recoveryType?: string;
369
+ redirectUri?: string;
370
+ }
371
+ interface PasswordResetRequestInput {
372
+ email?: string;
373
+ identifier?: string;
374
+ recoveryEmail?: string;
375
+ phoneNumber?: string;
376
+ memberId?: string;
377
+ securityQuestion?: string;
378
+ securityAnswer?: string;
379
+ redirectUri?: string;
380
+ }
381
+ interface PasswordResetRequestResult {
382
+ ok: boolean;
383
+ message: string;
384
+ }
385
+ interface PasswordResetValidationResult {
386
+ ok: boolean;
387
+ valid: boolean;
388
+ expiresAt?: string;
389
+ }
390
+ interface PasswordResetCompleteInput {
391
+ token: string;
392
+ password: string;
393
+ passwordConfirm: string;
394
+ }
395
+ interface PasswordResetCompleteResult {
396
+ ok: boolean;
397
+ message: string;
398
+ }
399
+ interface MfaSetupRequest {
400
+ deviceName: string;
401
+ }
402
+ interface MfaSetupResponse {
403
+ deviceId: string;
404
+ secret: string;
405
+ qrCodeUri: string;
406
+ backupCodes: string[];
407
+ algorithm: string;
408
+ digits: number;
409
+ period: number;
410
+ }
411
+ interface MfaVerifyRequest {
412
+ deviceId: string;
413
+ totpCode: string;
414
+ }
415
+ interface MfaDevice {
416
+ id: string;
417
+ deviceName: string;
418
+ isVerified: boolean;
419
+ isPrimary: boolean;
420
+ createdAt?: string;
421
+ lastUsedAt?: string;
422
+ }
423
+ interface MaintenanceStatus {
424
+ isActive: boolean;
425
+ message?: string;
426
+ scheduledStart?: string;
427
+ scheduledEnd?: string;
428
+ [key: string]: JsonValue | undefined;
429
+ }
430
+ interface ConsentRecord {
431
+ id: string;
432
+ clientId?: string;
433
+ clientName?: string;
434
+ scopes: string[];
435
+ isRevoked: boolean;
436
+ createdAt?: string;
437
+ updatedAt?: string;
438
+ [key: string]: JsonValue | undefined;
439
+ }
440
+ interface RecoveryContact {
441
+ id: string;
442
+ name?: string;
443
+ email?: string;
444
+ phoneNumber?: string;
445
+ relationship?: string;
446
+ isVerified?: boolean;
447
+ [key: string]: JsonValue | undefined;
448
+ }
449
+ interface UserIdentity {
450
+ id: string;
451
+ provider: string;
452
+ providerUserId?: string;
453
+ email?: string;
454
+ isPrimary?: boolean;
455
+ [key: string]: JsonValue | undefined;
456
+ }
457
+ interface AdminEntity {
458
+ id: string;
459
+ [key: string]: JsonValue | undefined;
460
+ }
461
+ interface ClientRecord extends AdminEntity {
462
+ clientId: string;
463
+ name: string;
464
+ description?: string;
465
+ isActive?: boolean;
466
+ isSystem?: boolean;
467
+ }
468
+ interface ScopeRecord extends AdminEntity {
469
+ name: string;
470
+ description?: string;
471
+ category?: string;
472
+ }
473
+ interface RoleRecord extends AdminEntity {
474
+ name: string;
475
+ slug: string;
476
+ description?: string;
477
+ }
478
+ interface PermissionRecord extends AdminEntity {
479
+ resource: string;
480
+ action: string;
481
+ description?: string;
482
+ }
483
+ interface OrganizationRecord extends AdminEntity {
484
+ name: string;
485
+ slug?: string;
486
+ }
487
+ interface AuditLogRecord extends AdminEntity {
488
+ action: string;
489
+ resourceType?: string;
490
+ resourceId?: string;
491
+ createdAt?: string;
492
+ }
493
+ interface WebhookRecord extends AdminEntity {
494
+ name: string;
495
+ url: string;
496
+ isActive?: boolean;
497
+ }
498
+ interface ClientListQuery extends PageQuery {
499
+ search?: string;
500
+ name?: string;
501
+ isActive?: boolean;
502
+ isDefault?: boolean;
503
+ createdAfter?: string;
504
+ createdBefore?: string;
505
+ sortBy?: string;
506
+ order?: "asc" | "desc";
507
+ }
508
+ interface UserListQuery extends PageQuery {
509
+ search?: string;
510
+ email?: string;
511
+ username?: string;
512
+ isActive?: boolean;
513
+ isVerified?: boolean;
514
+ mfaEnabled?: boolean;
515
+ createdAfter?: string;
516
+ createdBefore?: string;
517
+ sortBy?: string;
518
+ order?: "asc" | "desc";
519
+ }
520
+ interface RoleListQuery extends PageQuery {
521
+ search?: string;
522
+ name?: string;
523
+ slug?: string;
524
+ createdAfter?: string;
525
+ createdBefore?: string;
526
+ sortBy?: string;
527
+ order?: "asc" | "desc";
528
+ }
529
+ interface AuditLogListQuery extends PageQuery {
530
+ search?: string;
531
+ userId?: string;
532
+ organizationId?: string;
533
+ action?: string;
534
+ resourceType?: string;
535
+ status?: string;
536
+ createdAfter?: string;
537
+ createdBefore?: string;
538
+ sortBy?: string;
539
+ order?: "asc" | "desc";
540
+ }
541
+ interface ConsentListQuery extends PageQuery {
542
+ clientId?: string;
543
+ includeRevoked?: boolean;
544
+ }
545
+ interface DashboardRangeQuery {
546
+ range?: "7d" | "30d" | "90d";
547
+ }
548
+ interface PasswordResetEndpoints {
549
+ request(input: PasswordResetRequestInput): Promise<PasswordResetRequestResult>;
550
+ validate(token: string): Promise<PasswordResetValidationResult>;
551
+ complete(input: PasswordResetCompleteInput): Promise<PasswordResetCompleteResult>;
552
+ }
553
+ interface MfaEndpoints {
554
+ setup(input: MfaSetupRequest): Promise<MfaSetupResponse>;
555
+ verify(input: MfaVerifyRequest): Promise<JsonObject>;
556
+ devices(): Promise<MfaDevice[]>;
557
+ removeDevice(deviceId: string): Promise<void>;
558
+ regenerateBackupCodes(): Promise<{
559
+ backupCodes: string[];
560
+ }>;
561
+ disable(input?: {
562
+ password?: string;
563
+ }): Promise<void>;
564
+ }
565
+ interface MaintenanceEndpoints {
566
+ status(): Promise<MaintenanceStatus>;
567
+ enable(input?: JsonObject): Promise<MaintenanceStatus>;
568
+ disable(): Promise<MaintenanceStatus>;
569
+ schedule(input: JsonObject): Promise<JsonObject>;
570
+ listScheduled(): Promise<JsonObject[]>;
571
+ }
572
+ interface OAuthMetaEndpoints {
573
+ publicClient(clientId: string): Promise<PublicClientInfo>;
574
+ discoverAuthorizationServer(): Promise<OAuthAuthorizationServerMetadata>;
575
+ }
576
+ interface ConsentsEndpoints {
577
+ me: {
578
+ list(query?: ConsentListQuery): Promise<PageResponse<ConsentRecord>>;
579
+ get(id: string): Promise<ConsentRecord>;
580
+ create(input: JsonObject): Promise<ConsentRecord>;
581
+ update(id: string, input: JsonObject): Promise<ConsentRecord>;
582
+ revoke(id: string): Promise<void>;
583
+ stats(): Promise<JsonObject>;
584
+ };
585
+ list(query?: ConsentListQuery): Promise<PageResponse<ConsentRecord>>;
586
+ get(id: string): Promise<ConsentRecord>;
587
+ listForUser(userId: string, query?: ConsentListQuery): Promise<PageResponse<ConsentRecord>>;
588
+ listForClient(clientId: string, query?: ConsentListQuery): Promise<PageResponse<ConsentRecord>>;
589
+ revoke(id: string): Promise<void>;
590
+ stats(): Promise<JsonObject>;
591
+ }
592
+ interface ClientsEndpoints {
593
+ list(query?: ClientListQuery): Promise<PageResponse<ClientRecord>>;
594
+ create(input: JsonObject): Promise<ClientRecord>;
595
+ get(id: string): Promise<ClientRecord>;
596
+ update(id: string, input: JsonObject): Promise<ClientRecord>;
597
+ delete(id: string): Promise<void>;
598
+ regenerateSecret(id: string): Promise<JsonObject>;
599
+ assignScope(clientId: string, scopeId: string): Promise<void>;
600
+ removeScope(clientId: string, scopeId: string): Promise<void>;
601
+ stats(id: string, query?: DashboardRangeQuery): Promise<JsonObject>;
602
+ apiKeys: ClientApiKeysEndpoints;
603
+ providers: ClientProviderEndpoints;
604
+ }
605
+ interface ScopesEndpoints {
606
+ list(query?: PageQuery): Promise<PageResponse<ScopeRecord>>;
607
+ create(input: JsonObject): Promise<ScopeRecord>;
608
+ get(id: string): Promise<ScopeRecord>;
609
+ update(id: string, input: JsonObject): Promise<ScopeRecord>;
610
+ delete(id: string): Promise<void>;
611
+ }
612
+ interface RolesEndpoints {
613
+ list(query?: RoleListQuery): Promise<PageResponse<RoleRecord>>;
614
+ create(input: JsonObject): Promise<RoleRecord>;
615
+ get(id: string): Promise<RoleRecord>;
616
+ update(id: string, input: JsonObject): Promise<RoleRecord>;
617
+ delete(id: string): Promise<void>;
618
+ assignPermission(roleId: string, permissionId: string): Promise<void>;
619
+ removePermission(roleId: string, permissionId: string): Promise<void>;
620
+ }
621
+ interface PermissionsEndpoints {
622
+ list(query?: PageQuery): Promise<PageResponse<PermissionRecord>>;
623
+ create(input: JsonObject): Promise<PermissionRecord>;
624
+ get(id: string): Promise<PermissionRecord>;
625
+ update(id: string, input: JsonObject): Promise<PermissionRecord>;
626
+ delete(id: string): Promise<void>;
627
+ }
628
+ interface OrganizationsEndpoints {
629
+ list(query?: PageQuery): Promise<PageResponse<OrganizationRecord>>;
630
+ create(input: JsonObject): Promise<OrganizationRecord>;
631
+ get(id: string): Promise<OrganizationRecord>;
632
+ update(id: string, input: JsonObject): Promise<OrganizationRecord>;
633
+ delete(id: string): Promise<void>;
634
+ }
635
+ interface AuditLogsEndpoints {
636
+ list(query?: AuditLogListQuery): Promise<PageResponse<AuditLogRecord>>;
637
+ get(id: string): Promise<AuditLogRecord>;
638
+ }
639
+ interface DashboardEndpoints {
640
+ get(query?: DashboardRangeQuery): Promise<JsonObject>;
641
+ overview(query?: DashboardRangeQuery): Promise<JsonObject>;
642
+ timeSeries: {
643
+ registrations(query?: DashboardRangeQuery): Promise<JsonObject>;
644
+ logins(query?: DashboardRangeQuery): Promise<JsonObject>;
645
+ tokens(query?: DashboardRangeQuery): Promise<JsonObject>;
646
+ failures(query?: DashboardRangeQuery): Promise<JsonObject>;
647
+ };
648
+ distributions: {
649
+ devices(query?: DashboardRangeQuery): Promise<JsonObject>;
650
+ browsers(query?: DashboardRangeQuery): Promise<JsonObject>;
651
+ os(query?: DashboardRangeQuery): Promise<JsonObject>;
652
+ geography(query?: DashboardRangeQuery): Promise<JsonObject>;
653
+ grantTypes(query?: DashboardRangeQuery): Promise<JsonObject>;
654
+ mfa(query?: DashboardRangeQuery): Promise<JsonObject>;
655
+ };
656
+ security: {
657
+ summary(query?: DashboardRangeQuery): Promise<JsonObject>;
658
+ };
659
+ activity: {
660
+ recentLogins(query?: DashboardRangeQuery): Promise<JsonObject>;
661
+ recentSecurity(query?: DashboardRangeQuery): Promise<JsonObject>;
662
+ };
663
+ }
664
+ interface JwtKeysEndpoints {
665
+ list(query?: PageQuery): Promise<PageResponse<AdminEntity>>;
666
+ create(input: JsonObject): Promise<AdminEntity>;
667
+ get(id: string): Promise<AdminEntity>;
668
+ detail(id: string): Promise<JsonObject>;
669
+ update(id: string, input: JsonObject): Promise<AdminEntity>;
670
+ delete(id: string): Promise<void>;
671
+ rotate(): Promise<JsonObject>;
672
+ }
673
+ interface WebhooksEndpoints {
674
+ list(query?: PageQuery): Promise<PageResponse<WebhookRecord>>;
675
+ create(input: JsonObject): Promise<WebhookRecord>;
676
+ get(id: string): Promise<WebhookRecord>;
677
+ update(id: string, input: JsonObject): Promise<WebhookRecord>;
678
+ delete(id: string): Promise<void>;
679
+ deliveries(id: string, query?: PageQuery): Promise<PageResponse<JsonObject>>;
680
+ rotateSecret(id: string): Promise<JsonObject>;
681
+ }
682
+ interface CustomAttributesEndpoints {
683
+ list(query?: PageQuery): Promise<PageResponse<AdminEntity>>;
684
+ create(input: JsonObject): Promise<AdminEntity>;
685
+ get(id: string): Promise<AdminEntity>;
686
+ update(id: string, input: JsonObject): Promise<AdminEntity>;
687
+ delete(id: string): Promise<void>;
688
+ }
689
+ interface AuthMethodsEndpoints {
690
+ list(): Promise<JsonObject[]>;
691
+ enable(methodType: string, input: JsonObject): Promise<JsonObject>;
692
+ update(methodType: string, input: JsonObject): Promise<JsonObject>;
693
+ disable(methodType: string): Promise<void>;
694
+ }
695
+ interface AuthenticationFlowsAdminEndpoints {
696
+ list(query?: PageQuery): Promise<PageResponse<AdminEntity>>;
697
+ create(input: JsonObject): Promise<AdminEntity>;
698
+ get(id: string): Promise<AdminEntity>;
699
+ update(id: string, input: JsonObject): Promise<AdminEntity>;
700
+ delete(id: string): Promise<void>;
701
+ addStep(flowId: string, input: JsonObject): Promise<JsonObject>;
702
+ updateStep(flowId: string, stepId: string, input: JsonObject): Promise<JsonObject>;
703
+ deleteStep(flowId: string, stepId: string): Promise<void>;
704
+ }
705
+ interface UsersAdminEndpoints {
706
+ list(query?: UserListQuery): Promise<PageResponse<AdminEntity>>;
707
+ create(input: JsonObject): Promise<AdminEntity>;
708
+ get(id: string): Promise<AdminEntity>;
709
+ update(id: string, input: JsonObject): Promise<AdminEntity>;
710
+ delete(id: string): Promise<void>;
711
+ assignRole(userId: string, roleId: string): Promise<void>;
712
+ removeRole(userId: string, roleId: string): Promise<void>;
713
+ setPassword(userId: string, input: JsonObject): Promise<JsonObject>;
714
+ resetMfa(userId: string): Promise<JsonObject>;
715
+ getMfaDevices(userId: string): Promise<MfaDevice[]>;
716
+ getWebAuthnCredentials(userId: string): Promise<unknown[]>;
717
+ }
718
+ interface CommsEndpoints {
719
+ smsProviders: {
720
+ list(query?: PageQuery): Promise<PageResponse<AdminEntity>>;
721
+ create(input: JsonObject): Promise<AdminEntity>;
722
+ get(id: string): Promise<AdminEntity>;
723
+ update(id: string, input: JsonObject): Promise<AdminEntity>;
724
+ delete(id: string): Promise<void>;
725
+ test(id: string, input?: JsonObject): Promise<JsonObject>;
726
+ };
727
+ emailProviders: {
728
+ list(query?: PageQuery): Promise<PageResponse<AdminEntity>>;
729
+ create(input: JsonObject): Promise<AdminEntity>;
730
+ get(id: string): Promise<AdminEntity>;
731
+ update(id: string, input: JsonObject): Promise<AdminEntity>;
732
+ delete(id: string): Promise<void>;
733
+ test(id: string, input?: JsonObject): Promise<JsonObject>;
734
+ };
735
+ emailTemplates: {
736
+ list(query?: PageQuery): Promise<PageResponse<AdminEntity>>;
737
+ create(input: JsonObject): Promise<AdminEntity>;
738
+ get(id: string): Promise<AdminEntity>;
739
+ update(id: string, input: JsonObject): Promise<AdminEntity>;
740
+ delete(id: string): Promise<void>;
741
+ types(): Promise<JsonObject[]>;
742
+ preview(id: string, input?: JsonObject): Promise<JsonObject>;
743
+ };
744
+ smsLogs: {
745
+ list(query?: PageQuery): Promise<PageResponse<AdminEntity>>;
746
+ get(id: string): Promise<AdminEntity>;
747
+ };
748
+ systemSmsProviders: {
749
+ list(query?: PageQuery): Promise<PageResponse<AdminEntity>>;
750
+ create(input: JsonObject): Promise<AdminEntity>;
751
+ get(id: string): Promise<AdminEntity>;
752
+ update(id: string, input: JsonObject): Promise<AdminEntity>;
753
+ delete(id: string): Promise<void>;
754
+ test(id: string, input?: JsonObject): Promise<JsonObject>;
755
+ };
756
+ testPhones: {
757
+ list(query?: PageQuery): Promise<PageResponse<AdminEntity>>;
758
+ create(input: JsonObject): Promise<AdminEntity>;
759
+ update(id: string, input: JsonObject): Promise<AdminEntity>;
760
+ delete(id: string): Promise<void>;
761
+ };
762
+ }
763
+
764
+ /** Public maintenance probe — status only (no admin schedule/enable APIs). */
765
+ interface ConsumerMaintenanceEndpoints {
766
+ status(): Promise<MaintenanceStatus>;
767
+ }
768
+ /** Self-service user profile APIs without admin user-management helpers. */
769
+ type ConsumerUserEndpoints = Omit<UserEndpoints, "admin">;
770
+ /** OAuth/OIDC consumer client surface shipped on public npmjs. */
771
+ interface ConsumerAuthClient {
772
+ token: TokenEndpoints;
773
+ flow: FlowEndpoints;
774
+ oidc: OidcEndpoints;
775
+ authorize: AuthorizeEndpoints;
776
+ user: ConsumerUserEndpoints;
777
+ sessions: SessionEndpoints;
778
+ webauthn: WebAuthnEndpoints;
779
+ passwordReset: PasswordResetEndpoints;
780
+ mfa: MfaEndpoints;
781
+ maintenance: ConsumerMaintenanceEndpoints;
782
+ oauth: OAuthMetaEndpoints;
783
+ tokens: TokenStateEndpoints;
784
+ }
785
+
786
+ /** JSON primitive value type. */
787
+ type JsonPrimitive = string | number | boolean | null;
788
+ /** JSON value type used in extensible payloads. */
789
+ type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
790
+ /** JSON object type used in extensible payloads. */
791
+ type JsonObject = {
792
+ [key: string]: JsonValue;
793
+ };
794
+ /**
795
+ * A single RFC 9396 (Rich Authorization Requests) authorization detail object.
796
+ * `type` is required and identifies the detail type; all other members
797
+ * (`locations`, `actions`, `datatypes`, `identifier`, `privileges`, and any
798
+ * type-specific fields) are open-ended.
799
+ */
800
+ interface AuthorizationDetail {
801
+ type: string;
802
+ locations?: string[];
803
+ actions?: string[];
804
+ datatypes?: string[];
805
+ identifier?: string;
806
+ privileges?: string[];
807
+ [key: string]: JsonValue | undefined;
808
+ }
809
+ /** Canonical token shape used by SDK storage and endpoint wrappers. */
810
+ interface AuthTokens {
811
+ accessToken: string;
812
+ tokenType: string;
813
+ expiresIn: number;
814
+ refreshToken?: string;
815
+ scope?: string;
816
+ idToken?: string;
817
+ /** RFC 9396 granted authorization details, when returned by the server. */
818
+ authorizationDetails?: AuthorizationDetail[];
819
+ }
820
+ /**
821
+ * Pluggable token persistence contract.
822
+ *
823
+ * Implementations must:
824
+ * - Never log token values.
825
+ * - Validate payloads on read and write (use `assertValidAuthTokens` / `parseStoredAuthTokens`).
826
+ * - Prefer hardware-backed or server-side storage for refresh tokens in production.
827
+ * - Clear state on unrecoverable auth errors (the client calls `clear()` via `fetchWithAuth`).
828
+ */
829
+ interface TokenStorage {
830
+ get(): Promise<AuthTokens | null> | AuthTokens | null;
831
+ set(tokens: AuthTokens | null): Promise<void> | void;
832
+ clear(): Promise<void> | void;
833
+ }
834
+ /** Client factory configuration. */
835
+ interface AuthClientConfig {
836
+ clientId: string;
837
+ clientSecret?: string;
838
+ baseUrl?: string;
839
+ fetch?: typeof globalThis.fetch;
840
+ storage?: TokenStorage;
841
+ timeoutMs?: number;
842
+ defaultHeaders?: Record<string, string>;
843
+ autoRefresh?: boolean;
844
+ allowClientSecretInBrowser?: boolean;
845
+ /**
846
+ * Permits `http://` base URLs outside loopback hosts. Default `false`.
847
+ * Use only for trusted local integration tests — never in production.
848
+ */
849
+ allowInsecureTransport?: boolean;
850
+ }
851
+ /** Resource owner password token request. */
852
+ interface PasswordTokenRequest {
853
+ username?: string;
854
+ email?: string;
855
+ password: string;
856
+ scope?: string;
857
+ mfaCode?: string;
858
+ mfaBackupCode?: string;
859
+ }
860
+ /** Refresh token request. */
861
+ interface RefreshTokenRequest {
862
+ refreshToken?: string;
863
+ scope?: string;
864
+ }
865
+ /** Client credentials request. */
866
+ interface ClientCredentialsRequest {
867
+ scope?: string;
868
+ }
869
+ /** Authorization code token exchange request (with optional PKCE). */
870
+ interface AuthorizationCodeTokenRequest {
871
+ code: string;
872
+ redirectUri: string;
873
+ codeVerifier?: string;
874
+ scope?: string;
875
+ }
876
+ /** Options for building an authorization-code + PKCE redirect request. */
877
+ interface AuthorizationUrlOptions {
878
+ /** Absolute redirect URI registered for this client. */
879
+ redirectUri: string;
880
+ /** Space-delimited scopes. Defaults to `openid profile email offline_access`. */
881
+ scope?: string;
882
+ /** Pre-generated `state`; one is generated (CSPRNG) when omitted. */
883
+ state?: string;
884
+ /** Pre-generated `nonce`; one is generated (CSPRNG) when omitted. */
885
+ nonce?: string;
886
+ /** PKCE challenge method. Defaults to `S256`. */
887
+ codeChallengeMethod?: "S256" | "plain";
888
+ /** OIDC `prompt` parameter (e.g. `login`, `none`, `consent`). */
889
+ prompt?: string;
890
+ /** OIDC `login_hint` to prefill the identifier. */
891
+ loginHint?: string;
892
+ /** OAuth `response_type`. Defaults to `code`. */
893
+ responseType?: string;
894
+ /** Override the authorization endpoint (defaults to `{baseUrl}/oauth/authorize`). */
895
+ authorizationEndpoint?: string;
896
+ /** RFC 9396 rich authorization details to request (serialized as JSON). */
897
+ authorizationDetails?: AuthorizationDetail[];
898
+ /**
899
+ * RFC 9126 pushed-request reference. When set, the SDK builds a slim
900
+ * authorization URL carrying only `client_id` and `request_uri`.
901
+ */
902
+ requestUri?: string;
903
+ /** Additional non-standard query parameters to append. */
904
+ extraParams?: Record<string, string>;
905
+ }
906
+ /**
907
+ * Everything produced when starting an auth-code flow. The caller MUST persist
908
+ * `state`, `nonce`, `codeVerifier`, and `redirectUri` (e.g. in an httpOnly
909
+ * cookie or server session) and replay them when handling the callback.
910
+ */
911
+ interface AuthorizationRequest {
912
+ /** Fully-formed authorization URL to redirect the user agent to. */
913
+ url: string;
914
+ /** CSRF anti-forgery token; verify on callback. */
915
+ state: string;
916
+ /** OIDC nonce; bind to the returned ID token. */
917
+ nonce: string;
918
+ /** PKCE verifier; required at token exchange. Treat as a secret. */
919
+ codeVerifier: string;
920
+ /** PKCE challenge that was sent in the URL. */
921
+ codeChallenge: string;
922
+ /** Redirect URI echoed at token exchange. */
923
+ redirectUri: string;
924
+ /** Resolved scope string. */
925
+ scope: string;
926
+ /** RFC 9126 request_uri, present only when the request was pushed via PAR. */
927
+ requestUri?: string;
928
+ }
929
+ /** Options for pushing an authorization request (RFC 9126). */
930
+ interface PushAuthorizationRequestOptions extends AuthorizationUrlOptions {
931
+ }
932
+ /** Result of a successful pushed authorization request (RFC 9126). */
933
+ interface PushedAuthorizationResult {
934
+ /** The `urn:ietf:params:oauth:request_uri:...` reference. */
935
+ requestUri: string;
936
+ /** Lifetime of the request_uri in seconds. */
937
+ expiresIn: number;
938
+ /** The persisted request artefacts (state/nonce/codeVerifier) to replay on callback. */
939
+ request: AuthorizationRequest;
940
+ }
941
+ /** Result of probing `GET /oauth/authorize` with `redirect: manual`. */
942
+ interface AuthorizationProbeResult {
943
+ kind: "redirect" | "json";
944
+ status: number;
945
+ location?: string;
946
+ authorizationUrl?: string;
947
+ payload?: JsonObject;
948
+ }
949
+ /** Parsed authorization-server redirect callback parameters. */
950
+ interface CallbackParams {
951
+ code?: string;
952
+ state?: string;
953
+ error?: string;
954
+ errorDescription?: string;
955
+ errorUri?: string;
956
+ /** Any additional parameters present on the callback URL. */
957
+ raw: Record<string, string>;
958
+ }
959
+ /** Options for the one-call callback handler that validates state and exchanges the code. */
960
+ interface HandleCallbackOptions {
961
+ /** The callback URL, its query string, or pre-parsed params. */
962
+ callback: string | URLSearchParams | Record<string, string> | CallbackParams;
963
+ /** The `state` issued in {@link AuthorizationRequest}; verified constant-time. */
964
+ expectedState: string;
965
+ /** The PKCE verifier issued in {@link AuthorizationRequest}. */
966
+ codeVerifier: string;
967
+ /** The redirect URI issued in {@link AuthorizationRequest}. */
968
+ redirectUri: string;
969
+ /** Optional scope override forwarded to the token exchange. */
970
+ scope?: string;
971
+ }
972
+ /** OIDC discovery document (`/.well-known/openid-configuration`), camelCased subset. */
973
+ interface OidcDiscoveryDocument {
974
+ issuer: string;
975
+ authorizationEndpoint: string;
976
+ tokenEndpoint: string;
977
+ userinfoEndpoint?: string;
978
+ jwksUri: string;
979
+ revocationEndpoint?: string;
980
+ introspectionEndpoint?: string;
981
+ responseTypesSupported: string[];
982
+ grantTypesSupported?: string[];
983
+ scopesSupported?: string[];
984
+ codeChallengeMethodsSupported?: string[];
985
+ /** Raw, unmapped document for fields not surfaced above. */
986
+ raw: JsonObject;
987
+ }
988
+ /** Token revocation request. */
989
+ interface RevokeTokenRequest {
990
+ token?: string;
991
+ tokenTypeHint?: "access_token" | "refresh_token";
992
+ }
993
+ /** Token introspection request. */
994
+ interface IntrospectTokenRequest {
995
+ token: string;
996
+ }
997
+ /** Token introspection response. */
998
+ interface TokenIntrospectionResponse {
999
+ active: boolean;
1000
+ scope?: string;
1001
+ clientId?: string;
1002
+ username?: string;
1003
+ tokenType?: string;
1004
+ exp?: number;
1005
+ iat?: number;
1006
+ sub?: string;
1007
+ /** RFC 9396 authorization details associated with the token. */
1008
+ authorizationDetails?: AuthorizationDetail[];
1009
+ }
1010
+ /** Individual form field definition required for a flow step. */
1011
+ interface StepInputField {
1012
+ name: string;
1013
+ type: string;
1014
+ required: boolean;
1015
+ description: string;
1016
+ sensitive: boolean;
1017
+ }
1018
+ /** Input schema definition for a flow step. */
1019
+ interface StepInputSchema {
1020
+ fields: StepInputField[];
1021
+ }
1022
+ /** Authentication or registration flow step metadata. */
1023
+ interface FlowStep {
1024
+ stepId: string;
1025
+ stepType: string;
1026
+ name: string;
1027
+ description?: string;
1028
+ order: number;
1029
+ isRequired: boolean;
1030
+ timeout: number;
1031
+ inputSchema?: StepInputSchema;
1032
+ }
1033
+ /** Auth flow initialization request. */
1034
+ interface InitAuthenticationRequest {
1035
+ clientId?: string;
1036
+ username?: string;
1037
+ flowType?: string;
1038
+ }
1039
+ /** Registration flow initialization request. */
1040
+ interface InitRegistrationRequest {
1041
+ clientId?: string;
1042
+ inviteCode?: string;
1043
+ /** e.g. `phone_registration` for phone OTP signup flows. */
1044
+ flowType?: string;
1045
+ }
1046
+ /** Shared response for auth/registration flow initialization. */
1047
+ interface FlowInitResponse {
1048
+ sessionId: string;
1049
+ flowId: string;
1050
+ flowName: string;
1051
+ currentStep: FlowStep;
1052
+ remainingSteps: FlowStep[];
1053
+ expiresAt: string;
1054
+ /**
1055
+ * One-time plaintext continuation token (Q-022). Clients must store it and
1056
+ * send it on every subsequent step / status poll — session_id alone is not enough.
1057
+ */
1058
+ continuationToken: string;
1059
+ }
1060
+ /** Execute current flow step request. */
1061
+ interface ExecuteStepRequest {
1062
+ sessionId: string;
1063
+ stepId: string;
1064
+ credential: Record<string, string>;
1065
+ /** Required continuation token from {@link FlowInitResponse.continuationToken}. */
1066
+ continuationToken: string;
1067
+ }
1068
+ /** Flow step response when additional steps are still required. */
1069
+ interface FlowStepInProgressResult {
1070
+ status: "in_progress";
1071
+ sessionId: string;
1072
+ nextStep: FlowStep;
1073
+ completedSteps: string[];
1074
+ remainingSteps: FlowStep[];
1075
+ /** Server debug payload (e.g. OTP code in non-prod). Never expose to browsers unless gated. */
1076
+ debug?: Record<string, unknown>;
1077
+ }
1078
+ /** Flow step response when authentication is complete and tokens are issued. */
1079
+ interface FlowStepCompleteResult {
1080
+ status: "complete";
1081
+ accessToken: string;
1082
+ refreshToken?: string;
1083
+ tokenType: string;
1084
+ expiresIn: number;
1085
+ scope?: string;
1086
+ amr: string[];
1087
+ acr: string;
1088
+ }
1089
+ /** Discriminated union of flow step execution outcomes. */
1090
+ type FlowStepResult = FlowStepInProgressResult | FlowStepCompleteResult;
1091
+ /** Full flow session status payload. */
1092
+ interface FlowSessionStatus {
1093
+ sessionId: string;
1094
+ status: string;
1095
+ purpose: string;
1096
+ currentStep?: FlowStep;
1097
+ completedSteps: string[];
1098
+ remainingSteps: FlowStep[];
1099
+ failedAttempts: number;
1100
+ expiresAt: string;
1101
+ lastActivityAt: string;
1102
+ }
1103
+ /** Standard page metadata. */
1104
+ interface PageQuery {
1105
+ page?: number;
1106
+ perPage?: number;
1107
+ }
1108
+ /** Standard page metadata. */
1109
+ interface PageMetadata {
1110
+ page: number;
1111
+ per: number;
1112
+ total: number;
1113
+ }
1114
+ /** Standard paginated response. */
1115
+ interface PageResponse<T> {
1116
+ items: T[];
1117
+ metadata: PageMetadata;
1118
+ }
1119
+
1120
+ /** Session list item. */
1121
+ interface SessionSummary {
1122
+ id: string;
1123
+ deviceName?: string;
1124
+ deviceType: string;
1125
+ browser?: string;
1126
+ os?: string;
1127
+ ipAddress: string;
1128
+ country?: string;
1129
+ city?: string;
1130
+ isActive: boolean;
1131
+ isCurrent: boolean;
1132
+ isTrusted: boolean;
1133
+ lastUsedAt?: string;
1134
+ createdAt?: string;
1135
+ }
1136
+ /** Session detail payload. */
1137
+ interface SessionDetail {
1138
+ id: string;
1139
+ deviceId?: string;
1140
+ deviceName?: string;
1141
+ deviceType: string;
1142
+ userAgent?: string;
1143
+ browser?: string;
1144
+ browserVersion?: string;
1145
+ os?: string;
1146
+ osVersion?: string;
1147
+ ipAddress: string;
1148
+ country?: string;
1149
+ city?: string;
1150
+ isActive: boolean;
1151
+ isRevoked: boolean;
1152
+ isCurrent: boolean;
1153
+ isTrusted: boolean;
1154
+ requiresMfa: boolean;
1155
+ accessTokenCount: number;
1156
+ lastUsedAt?: string;
1157
+ expiresAt?: string;
1158
+ createdAt?: string;
1159
+ revokedAt?: string;
1160
+ revocationReason?: string;
1161
+ }
1162
+ /** Session update payload. */
1163
+ interface UpdateSessionRequest {
1164
+ deviceName?: string;
1165
+ isTrusted?: boolean;
1166
+ }
1167
+ /** Optional reason payload used during session revocation. */
1168
+ interface RevokeSessionRequest {
1169
+ reason?: string;
1170
+ }
1171
+ /** Session/token revocation summary. */
1172
+ interface RevocationResponse {
1173
+ success: boolean;
1174
+ sessionsRevoked: number;
1175
+ tokensRevoked: number;
1176
+ }
1177
+ /** Current user profile payload from `/api/v1/users/me`. */
1178
+ interface UserProfile {
1179
+ id: string;
1180
+ organizationId?: string;
1181
+ email?: string;
1182
+ username?: string;
1183
+ firstName?: string;
1184
+ lastName?: string;
1185
+ isActive?: boolean;
1186
+ isVerified?: boolean;
1187
+ mfaEnabled?: boolean;
1188
+ [key: string]: JsonValue | undefined;
1189
+ }
1190
+ /** OIDC UserInfo response payload. */
1191
+ interface UserInfoResponse {
1192
+ sub: string;
1193
+ name?: string;
1194
+ givenName?: string;
1195
+ familyName?: string;
1196
+ middleName?: string;
1197
+ nickname?: string;
1198
+ preferredUsername?: string;
1199
+ profile?: string;
1200
+ picture?: string;
1201
+ website?: string;
1202
+ gender?: string;
1203
+ birthdate?: string;
1204
+ zoneinfo?: string;
1205
+ locale?: string;
1206
+ updatedAt?: number;
1207
+ email?: string;
1208
+ emailVerified?: boolean;
1209
+ phoneNumber?: string;
1210
+ phoneNumberVerified?: boolean;
1211
+ [key: string]: JsonValue | undefined;
1212
+ }
1213
+ /** WebAuthn endpoint wrappers (browser ceremony intentionally out-of-scope). */
1214
+ interface WebAuthnEndpoints {
1215
+ registerBegin(payload: Record<string, JsonValue>): Promise<Record<string, JsonValue>>;
1216
+ registerFinish(payload: Record<string, JsonValue>): Promise<Record<string, JsonValue>>;
1217
+ authenticateBegin(payload: Record<string, JsonValue>): Promise<Record<string, JsonValue>>;
1218
+ authenticateFinish(payload: Record<string, JsonValue>): Promise<Record<string, JsonValue>>;
1219
+ credentials(): Promise<Record<string, JsonValue>>;
1220
+ removeCredential(credentialId: string, input?: {
1221
+ password?: string;
1222
+ }): Promise<void>;
1223
+ renameCredential(credentialId: string, payload: Record<string, JsonValue>): Promise<Record<string, JsonValue>>;
1224
+ setPrimaryCredential(credentialId: string): Promise<Record<string, JsonValue>>;
1225
+ }
1226
+ /** OAuth token endpoint wrappers. */
1227
+ interface TokenEndpoints {
1228
+ password(input: PasswordTokenRequest): Promise<AuthTokens>;
1229
+ refresh(input?: RefreshTokenRequest): Promise<AuthTokens>;
1230
+ clientCredentials(input?: ClientCredentialsRequest): Promise<AuthTokens>;
1231
+ authorizationCode(input: AuthorizationCodeTokenRequest): Promise<AuthTokens>;
1232
+ tokenExchange(input: TokenExchangeRequest): Promise<AuthTokens>;
1233
+ revoke(input?: RevokeTokenRequest): Promise<void>;
1234
+ introspect(input: IntrospectTokenRequest): Promise<TokenIntrospectionResponse>;
1235
+ }
1236
+ /** Authentication and registration flow endpoint wrappers. */
1237
+ interface FlowEndpoints {
1238
+ initAuthentication(input?: InitAuthenticationRequest): Promise<FlowInitResponse>;
1239
+ executeStep(input: ExecuteStepRequest): Promise<FlowStepResult>;
1240
+ initRegistration(input?: InitRegistrationRequest): Promise<FlowInitResponse>;
1241
+ executeRegistrationStep(input: ExecuteStepRequest): Promise<FlowStepResult>;
1242
+ initRecovery(input?: InitRecoveryRequest): Promise<FlowInitResponse>;
1243
+ executeRecoveryStep(input: ExecuteStepRequest): Promise<FlowStepResult>;
1244
+ /**
1245
+ * Poll flow session status. `continuationToken` is required by the server
1246
+ * (Q-022); omitting it yields 400.
1247
+ */
1248
+ getStatus(sessionId: string, continuationToken: string): Promise<FlowSessionStatus>;
1249
+ }
1250
+ /** OIDC endpoint wrappers. */
1251
+ interface OidcEndpoints {
1252
+ userInfo(): Promise<UserInfoResponse>;
1253
+ discover(): Promise<OidcDiscoveryDocument>;
1254
+ jwks(): Promise<JwksDocument>;
1255
+ }
1256
+ /**
1257
+ * Authorization-code + PKCE redirect-flow helpers. This is the high-level
1258
+ * surface that removes per-app duplication of PKCE/state/URL plumbing.
1259
+ */
1260
+ interface AuthorizeEndpoints {
1261
+ createRequest(options: AuthorizationUrlOptions): Promise<AuthorizationRequest>;
1262
+ /**
1263
+ * RFC 9126: push the authorization request to the server and return a
1264
+ * one-time `request_uri` plus a slim authorization `request` referencing it.
1265
+ */
1266
+ pushAuthorizationRequest(options: PushAuthorizationRequestOptions): Promise<PushedAuthorizationResult>;
1267
+ parseCallback(input: string | URLSearchParams | Record<string, string>): CallbackParams;
1268
+ handleCallback(options: HandleCallbackOptions): Promise<AuthTokens>;
1269
+ consent(callbackUrl: string, body: AuthorizationConsentBody): Promise<AuthorizationConsentResponse>;
1270
+ consentWithCredentials(options: ConsentWithCredentialsOptions): Promise<AuthorizationConsentResponse>;
1271
+ evaluateConsent(callbackUrl: string, body: AuthorizationConsentEvaluateBody): Promise<AuthorizationConsentEvaluateResponse>;
1272
+ evaluateConsentWithCredentials(options: EvaluateConsentWithCredentialsOptions): Promise<AuthorizationConsentEvaluateResponse>;
1273
+ probeAuthorize(url: string): Promise<AuthorizationProbeResult>;
1274
+ }
1275
+ /** Current-user endpoint wrappers. */
1276
+ interface UserEndpoints {
1277
+ me(): Promise<UserProfile>;
1278
+ updateMe(input: JsonObject): Promise<UserProfile>;
1279
+ changePassword(input: {
1280
+ currentPassword: string;
1281
+ newPassword: string;
1282
+ }): Promise<void>;
1283
+ uploadAvatar(file: Blob | Buffer, filename?: string): Promise<UserProfile>;
1284
+ deleteAvatar(): Promise<UserProfile>;
1285
+ verifyPhone(input: JsonObject): Promise<JsonObject>;
1286
+ verifyRecoveryEmail(input: JsonObject): Promise<JsonObject>;
1287
+ securityOverview(): Promise<JsonObject>;
1288
+ recoveryContacts: {
1289
+ list(): Promise<RecoveryContact[]>;
1290
+ create(input: JsonObject): Promise<RecoveryContact>;
1291
+ update(contactId: string, input: JsonObject): Promise<RecoveryContact>;
1292
+ delete(contactId: string): Promise<void>;
1293
+ };
1294
+ identities: {
1295
+ list(): Promise<UserIdentity[]>;
1296
+ unlink(identityId: string): Promise<void>;
1297
+ setPrimary(identityId: string): Promise<JsonObject>;
1298
+ };
1299
+ deleteMe(input: {
1300
+ password: string;
1301
+ }): Promise<void>;
1302
+ admin: UsersAdminEndpoints;
1303
+ }
1304
+ /** Session list query parameters. */
1305
+ interface SessionListQuery {
1306
+ page?: number;
1307
+ perPage?: number;
1308
+ userId?: string;
1309
+ }
1310
+ /** Session management endpoint wrappers. */
1311
+ interface SessionEndpoints {
1312
+ list(input?: SessionListQuery): Promise<PageResponse<SessionSummary>>;
1313
+ current(): Promise<SessionDetail>;
1314
+ get(id: string): Promise<SessionDetail>;
1315
+ update(id: string, input: UpdateSessionRequest): Promise<SessionDetail>;
1316
+ revoke(id: string, input?: RevokeSessionRequest): Promise<RevocationResponse>;
1317
+ revokeAll(): Promise<RevocationResponse>;
1318
+ revokeAllDevices(): Promise<RevocationResponse>;
1319
+ }
1320
+ /** Token state helper endpoints for direct storage access. */
1321
+ interface TokenStateEndpoints {
1322
+ get(): Promise<AuthTokens | null>;
1323
+ set(tokens: AuthTokens | null): Promise<void>;
1324
+ clear(): Promise<void>;
1325
+ }
1326
+ /** Fully composed SDK client surface (internal / GitHub Packages build). */
1327
+ interface AuthClient extends ConsumerAuthClient {
1328
+ user: UserEndpoints;
1329
+ maintenance: MaintenanceEndpoints;
1330
+ consents: ConsentsEndpoints;
1331
+ clients: ClientsEndpoints;
1332
+ scopes: ScopesEndpoints;
1333
+ roles: RolesEndpoints;
1334
+ permissions: PermissionsEndpoints;
1335
+ organizations: OrganizationsEndpoints;
1336
+ auditLogs: AuditLogsEndpoints;
1337
+ dashboard: DashboardEndpoints;
1338
+ jwtKeys: JwtKeysEndpoints;
1339
+ webhooks: WebhooksEndpoints;
1340
+ customAttributes: CustomAttributesEndpoints;
1341
+ authMethods: AuthMethodsEndpoints;
1342
+ authenticationFlows: AuthenticationFlowsAdminEndpoints;
1343
+ comms: CommsEndpoints;
1344
+ memberDirectory: MemberDirectoryEndpoints;
1345
+ federated: FederatedEndpoints;
1346
+ families: FamiliesEndpoints;
1347
+ dependents: DependentsEndpoints;
1348
+ privacy: PrivacyEndpoints;
1349
+ fetchWithAuth(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
1350
+ /**
1351
+ * Low-level escape hatch: issue a request to an arbitrary path on the
1352
+ * configured auth server through the SDK's HTTP client (baseUrl resolution,
1353
+ * default headers, timeout, and RFC-style error normalization), returning the
1354
+ * parsed JSON body unmodified. Use for transparent passthrough/proxy endpoints
1355
+ * that must preserve the server's raw response shape rather than a mapped one.
1356
+ * Throws `AuthError` on non-2xx responses.
1357
+ */
1358
+ request<T = unknown>(path: string, options?: ApiRequestOptions): Promise<T>;
1359
+ }
1360
+ /** Options for the generic {@link AuthClient.request} escape hatch. */
1361
+ interface ApiRequestOptions {
1362
+ method?: string;
1363
+ headers?: Record<string, string>;
1364
+ /** JSON-serializable body (objects are sent as `application/json`). */
1365
+ body?: unknown;
1366
+ /** Bearer token to attach for authenticated passthrough calls. */
1367
+ token?: string;
1368
+ }
1369
+
1370
+ /**
1371
+ * Creates in-memory token storage suitable for Node, edge, and browser runtimes.
1372
+ *
1373
+ * Tokens are not encrypted and do not survive process restarts. This is the
1374
+ * default and the recommended choice for server-side clients (SSR routes,
1375
+ * workers) where persistence belongs in HttpOnly cookies or a server session.
1376
+ */
1377
+ declare function createMemoryTokenStorage(): TokenStorage;
1378
+
1379
+ export { type TokenStorage as $, type AuthClientConfig as A, type OidcEndpoints as B, type ConsumerAuthClient as C, type PageResponse as D, type ExecuteStepRequest as E, type FlowEndpoints as F, type PasswordResetEndpoints as G, type HandleCallbackOptions as H, type InitAuthenticationRequest as I, type PasswordTokenRequest as J, type PublicClientInfo as K, type PushAuthorizationRequestOptions as L, type MaintenanceStatus as M, type PushedAuthorizationResult as N, type OAuthAuthorizationServerMetadata as O, type PageQuery as P, type RevocationResponse as Q, type RefreshTokenRequest as R, type RevokeSessionRequest as S, type RevokeTokenRequest as T, type SessionDetail as U, type SessionEndpoints as V, type SessionListQuery as W, type SessionSummary as X, type TokenEndpoints as Y, type TokenExchangeRequest as Z, type TokenIntrospectionResponse as _, type AuthClient as a, type UpdateSessionRequest as a0, type UserEndpoints as a1, type UserInfoResponse as a2, type UserProfile as a3, type WebAuthnEndpoints as a4, createMemoryTokenStorage as a5, type AuthTokens as b, type AuthorizationCodeTokenRequest as c, type AuthorizationConsentBody as d, type AuthorizationConsentResponse as e, type AuthorizationDetail as f, type AuthorizationProbeResult as g, type AuthorizationRequest as h, type AuthorizationUrlOptions as i, type AuthorizeEndpoints as j, type CallbackParams as k, type ClientCredentialsRequest as l, type ConsumerMaintenanceEndpoints as m, type ConsumerUserEndpoints as n, type FlowInitResponse as o, type FlowSessionStatus as p, type FlowStep as q, type FlowStepCompleteResult as r, type FlowStepInProgressResult as s, type FlowStepResult as t, type InitRegistrationRequest as u, type IntrospectTokenRequest as v, type MfaDevice as w, type MfaEndpoints as x, type OAuthMetaEndpoints as y, type OidcDiscoveryDocument as z };