@authsome/ui-core 1.3.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1068 -24
- package/dist/index.js +1193 -104
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
// src/generated/api-client.ts
|
|
2
2
|
var AuthClient = class {
|
|
3
3
|
baseURL;
|
|
4
|
+
publishableKey;
|
|
4
5
|
fetchFn;
|
|
5
6
|
constructor(config) {
|
|
6
7
|
this.baseURL = config.baseURL.replace(/\/+$/, "");
|
|
8
|
+
this.publishableKey = config.publishableKey;
|
|
7
9
|
this.fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
8
10
|
}
|
|
11
|
+
/** Set the publishable key sent on every request as X-Publishable-Key. */
|
|
12
|
+
setPublishableKey(key) {
|
|
13
|
+
this.publishableKey = key;
|
|
14
|
+
}
|
|
15
|
+
/** Get the current publishable key. */
|
|
16
|
+
getPublishableKey() {
|
|
17
|
+
return this.publishableKey;
|
|
18
|
+
}
|
|
9
19
|
// ──────────────────────────────────────────────────
|
|
10
20
|
// Generated methods
|
|
11
21
|
// ──────────────────────────────────────────────────
|
|
@@ -33,6 +43,240 @@ var AuthClient = class {
|
|
|
33
43
|
void 0
|
|
34
44
|
);
|
|
35
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* OpenID Connect Discovery
|
|
48
|
+
* GET /.well-known/openid-configuration
|
|
49
|
+
*/
|
|
50
|
+
async oidcDiscovery(token) {
|
|
51
|
+
const path = "/.well-known/openid-configuration";
|
|
52
|
+
return this.request(
|
|
53
|
+
"GET",
|
|
54
|
+
path,
|
|
55
|
+
void 0,
|
|
56
|
+
token
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* List SCIM Groups
|
|
61
|
+
* GET /scim/v2/Groups
|
|
62
|
+
*/
|
|
63
|
+
async scimListGroups(token) {
|
|
64
|
+
const path = "/scim/v2/Groups";
|
|
65
|
+
return this.request(
|
|
66
|
+
"GET",
|
|
67
|
+
path,
|
|
68
|
+
void 0,
|
|
69
|
+
token
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create SCIM Group
|
|
74
|
+
* POST /scim/v2/Groups
|
|
75
|
+
*/
|
|
76
|
+
async scimCreateGroup(body, token) {
|
|
77
|
+
const path = "/scim/v2/Groups";
|
|
78
|
+
return this.request(
|
|
79
|
+
"POST",
|
|
80
|
+
path,
|
|
81
|
+
body,
|
|
82
|
+
token
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get SCIM Group
|
|
87
|
+
* GET /scim/v2/Groups/{groupId}
|
|
88
|
+
*/
|
|
89
|
+
async scimGetGroup(groupId, token) {
|
|
90
|
+
const path = `/scim/v2/Groups/${groupId}`;
|
|
91
|
+
return this.request(
|
|
92
|
+
"GET",
|
|
93
|
+
path,
|
|
94
|
+
void 0,
|
|
95
|
+
token
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Replace SCIM Group
|
|
100
|
+
* PUT /scim/v2/Groups/{groupId}
|
|
101
|
+
*/
|
|
102
|
+
async scimReplaceGroup(groupId, body, token) {
|
|
103
|
+
const path = `/scim/v2/Groups/${groupId}`;
|
|
104
|
+
return this.request(
|
|
105
|
+
"PUT",
|
|
106
|
+
path,
|
|
107
|
+
body,
|
|
108
|
+
token
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Patch SCIM Group
|
|
113
|
+
* PATCH /scim/v2/Groups/{groupId}
|
|
114
|
+
*/
|
|
115
|
+
async scimPatchGroup(groupId, body, token) {
|
|
116
|
+
const path = `/scim/v2/Groups/${groupId}`;
|
|
117
|
+
return this.request(
|
|
118
|
+
"PATCH",
|
|
119
|
+
path,
|
|
120
|
+
body,
|
|
121
|
+
token
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Delete SCIM Group
|
|
126
|
+
* DELETE /scim/v2/Groups/{groupId}
|
|
127
|
+
*/
|
|
128
|
+
async scimDeleteGroup(groupId, body, token) {
|
|
129
|
+
const path = `/scim/v2/Groups/${groupId}`;
|
|
130
|
+
return this.request(
|
|
131
|
+
"DELETE",
|
|
132
|
+
path,
|
|
133
|
+
body,
|
|
134
|
+
token
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* SCIM Resource Types
|
|
139
|
+
* GET /scim/v2/ResourceTypes
|
|
140
|
+
*/
|
|
141
|
+
async scimResourceTypes(token) {
|
|
142
|
+
const path = "/scim/v2/ResourceTypes";
|
|
143
|
+
return this.request(
|
|
144
|
+
"GET",
|
|
145
|
+
path,
|
|
146
|
+
void 0,
|
|
147
|
+
token
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* SCIM Schemas
|
|
152
|
+
* GET /scim/v2/Schemas
|
|
153
|
+
*/
|
|
154
|
+
async scimSchemas(token) {
|
|
155
|
+
const path = "/scim/v2/Schemas";
|
|
156
|
+
return this.request(
|
|
157
|
+
"GET",
|
|
158
|
+
path,
|
|
159
|
+
void 0,
|
|
160
|
+
token
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* SCIM Service Provider Configuration
|
|
165
|
+
* GET /scim/v2/ServiceProviderConfig
|
|
166
|
+
*/
|
|
167
|
+
async scimServiceProviderConfig(token) {
|
|
168
|
+
const path = "/scim/v2/ServiceProviderConfig";
|
|
169
|
+
return this.request(
|
|
170
|
+
"GET",
|
|
171
|
+
path,
|
|
172
|
+
void 0,
|
|
173
|
+
token
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* List SCIM Users
|
|
178
|
+
* GET /scim/v2/Users
|
|
179
|
+
*/
|
|
180
|
+
async scimListUsers(token) {
|
|
181
|
+
const path = "/scim/v2/Users";
|
|
182
|
+
return this.request(
|
|
183
|
+
"GET",
|
|
184
|
+
path,
|
|
185
|
+
void 0,
|
|
186
|
+
token
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Create SCIM User
|
|
191
|
+
* POST /scim/v2/Users
|
|
192
|
+
*/
|
|
193
|
+
async scimCreateUser(body, token) {
|
|
194
|
+
const path = "/scim/v2/Users";
|
|
195
|
+
return this.request(
|
|
196
|
+
"POST",
|
|
197
|
+
path,
|
|
198
|
+
body,
|
|
199
|
+
token
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get SCIM User
|
|
204
|
+
* GET /scim/v2/Users/{userId}
|
|
205
|
+
*/
|
|
206
|
+
async scimGetUser(userId, token) {
|
|
207
|
+
const path = `/scim/v2/Users/${userId}`;
|
|
208
|
+
return this.request(
|
|
209
|
+
"GET",
|
|
210
|
+
path,
|
|
211
|
+
void 0,
|
|
212
|
+
token
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Replace SCIM User
|
|
217
|
+
* PUT /scim/v2/Users/{userId}
|
|
218
|
+
*/
|
|
219
|
+
async scimReplaceUser(userId, body, token) {
|
|
220
|
+
const path = `/scim/v2/Users/${userId}`;
|
|
221
|
+
return this.request(
|
|
222
|
+
"PUT",
|
|
223
|
+
path,
|
|
224
|
+
body,
|
|
225
|
+
token
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Patch SCIM User
|
|
230
|
+
* PATCH /scim/v2/Users/{userId}
|
|
231
|
+
*/
|
|
232
|
+
async scimPatchUser(userId, body, token) {
|
|
233
|
+
const path = `/scim/v2/Users/${userId}`;
|
|
234
|
+
return this.request(
|
|
235
|
+
"PATCH",
|
|
236
|
+
path,
|
|
237
|
+
body,
|
|
238
|
+
token
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Delete SCIM User
|
|
243
|
+
* DELETE /scim/v2/Users/{userId}
|
|
244
|
+
*/
|
|
245
|
+
async scimDeleteUser(userId, body, token) {
|
|
246
|
+
const path = `/scim/v2/Users/${userId}`;
|
|
247
|
+
return this.request(
|
|
248
|
+
"DELETE",
|
|
249
|
+
path,
|
|
250
|
+
body,
|
|
251
|
+
token
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Create application (admin)
|
|
256
|
+
* POST /v1/admin/apps
|
|
257
|
+
*/
|
|
258
|
+
async adminCreateApp(body, token) {
|
|
259
|
+
const path = "/v1/admin/apps";
|
|
260
|
+
return this.request(
|
|
261
|
+
"POST",
|
|
262
|
+
path,
|
|
263
|
+
body,
|
|
264
|
+
token
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Delete application (admin)
|
|
269
|
+
* DELETE /v1/admin/apps/{appId}
|
|
270
|
+
*/
|
|
271
|
+
async adminDeleteApp(appId, body, token) {
|
|
272
|
+
const path = `/v1/admin/apps/${appId}`;
|
|
273
|
+
return this.request(
|
|
274
|
+
"DELETE",
|
|
275
|
+
path,
|
|
276
|
+
body,
|
|
277
|
+
token
|
|
278
|
+
);
|
|
279
|
+
}
|
|
36
280
|
/**
|
|
37
281
|
* Get per-app client config overrides
|
|
38
282
|
* GET /v1/admin/apps/{appId}/client-config
|
|
@@ -163,12 +407,115 @@ var AuthClient = class {
|
|
|
163
407
|
token
|
|
164
408
|
);
|
|
165
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* List OAuth2 clients
|
|
412
|
+
* GET /v1/admin/oauth/clients
|
|
413
|
+
*/
|
|
414
|
+
async listOAuth2Clients(token) {
|
|
415
|
+
const path = "/v1/admin/oauth/clients";
|
|
416
|
+
return this.request(
|
|
417
|
+
"GET",
|
|
418
|
+
path,
|
|
419
|
+
void 0,
|
|
420
|
+
token
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Create OAuth2 client
|
|
425
|
+
* POST /v1/admin/oauth/clients
|
|
426
|
+
*/
|
|
427
|
+
async createOAuth2Client(body, token) {
|
|
428
|
+
const path = "/v1/admin/oauth/clients";
|
|
429
|
+
return this.request(
|
|
430
|
+
"POST",
|
|
431
|
+
path,
|
|
432
|
+
body,
|
|
433
|
+
token
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Delete OAuth2 client
|
|
438
|
+
* DELETE /v1/admin/oauth/clients/{clientId}
|
|
439
|
+
*/
|
|
440
|
+
async deleteOAuth2Client(clientId, body, token) {
|
|
441
|
+
const path = `/v1/admin/oauth/clients/${clientId}`;
|
|
442
|
+
return this.request(
|
|
443
|
+
"DELETE",
|
|
444
|
+
path,
|
|
445
|
+
body,
|
|
446
|
+
token
|
|
447
|
+
);
|
|
448
|
+
}
|
|
166
449
|
/**
|
|
167
450
|
* List organizations (admin)
|
|
168
451
|
* GET /v1/admin/orgs
|
|
169
452
|
*/
|
|
170
|
-
async adminListOrgs(
|
|
453
|
+
async adminListOrgs() {
|
|
171
454
|
const path = "/v1/admin/orgs";
|
|
455
|
+
return this.request(
|
|
456
|
+
"GET",
|
|
457
|
+
path,
|
|
458
|
+
void 0
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Grant platform-owner role (admin)
|
|
463
|
+
* POST /v1/admin/platform/owners
|
|
464
|
+
*/
|
|
465
|
+
async adminGrantPlatformOwner(body, token) {
|
|
466
|
+
const path = "/v1/admin/platform/owners";
|
|
467
|
+
return this.request(
|
|
468
|
+
"POST",
|
|
469
|
+
path,
|
|
470
|
+
body,
|
|
471
|
+
token
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Revoke platform-owner role (admin)
|
|
476
|
+
* DELETE /v1/admin/platform/owners/{userID}
|
|
477
|
+
*/
|
|
478
|
+
async adminRevokePlatformOwner(userID, body, token) {
|
|
479
|
+
const path = `/v1/admin/platform/owners/${userID}`;
|
|
480
|
+
return this.request(
|
|
481
|
+
"DELETE",
|
|
482
|
+
path,
|
|
483
|
+
body,
|
|
484
|
+
token
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* List service accounts (admin)
|
|
489
|
+
* GET /v1/admin/service-accounts
|
|
490
|
+
*/
|
|
491
|
+
async adminListServiceAccounts(token) {
|
|
492
|
+
const path = "/v1/admin/service-accounts";
|
|
493
|
+
return this.request(
|
|
494
|
+
"GET",
|
|
495
|
+
path,
|
|
496
|
+
void 0,
|
|
497
|
+
token
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Create service account (admin)
|
|
502
|
+
* POST /v1/admin/service-accounts
|
|
503
|
+
*/
|
|
504
|
+
async adminCreateServiceAccount(body, token) {
|
|
505
|
+
const path = "/v1/admin/service-accounts";
|
|
506
|
+
return this.request(
|
|
507
|
+
"POST",
|
|
508
|
+
path,
|
|
509
|
+
body,
|
|
510
|
+
token
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Get service account (admin)
|
|
515
|
+
* GET /v1/admin/service-accounts/{serviceAccountId}
|
|
516
|
+
*/
|
|
517
|
+
async adminGetServiceAccount(serviceAccountId, token) {
|
|
518
|
+
const path = `/v1/admin/service-accounts/${serviceAccountId}`;
|
|
172
519
|
return this.request(
|
|
173
520
|
"GET",
|
|
174
521
|
path,
|
|
@@ -176,6 +523,32 @@ var AuthClient = class {
|
|
|
176
523
|
token
|
|
177
524
|
);
|
|
178
525
|
}
|
|
526
|
+
/**
|
|
527
|
+
* Delete service account (admin)
|
|
528
|
+
* DELETE /v1/admin/service-accounts/{serviceAccountId}
|
|
529
|
+
*/
|
|
530
|
+
async adminDeleteServiceAccount(serviceAccountId, body, token) {
|
|
531
|
+
const path = `/v1/admin/service-accounts/${serviceAccountId}`;
|
|
532
|
+
return this.request(
|
|
533
|
+
"DELETE",
|
|
534
|
+
path,
|
|
535
|
+
body,
|
|
536
|
+
token
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Create service account API key (admin)
|
|
541
|
+
* POST /v1/admin/service-accounts/{serviceAccountId}/api-keys
|
|
542
|
+
*/
|
|
543
|
+
async adminCreateServiceAccountAPIKey(serviceAccountId, body, token) {
|
|
544
|
+
const path = `/v1/admin/service-accounts/${serviceAccountId}/api-keys`;
|
|
545
|
+
return this.request(
|
|
546
|
+
"POST",
|
|
547
|
+
path,
|
|
548
|
+
body,
|
|
549
|
+
token
|
|
550
|
+
);
|
|
551
|
+
}
|
|
179
552
|
/**
|
|
180
553
|
* List all setting definitions
|
|
181
554
|
* GET /v1/admin/settings/definitions
|
|
@@ -203,89 +576,517 @@ var AuthClient = class {
|
|
|
203
576
|
);
|
|
204
577
|
}
|
|
205
578
|
/**
|
|
206
|
-
* Enforce a setting value at a scope
|
|
207
|
-
* PUT /v1/admin/settings/enforce/{key}
|
|
579
|
+
* Enforce a setting value at a scope
|
|
580
|
+
* PUT /v1/admin/settings/enforce/{key}
|
|
581
|
+
*/
|
|
582
|
+
async enforceSetting(key, body, token) {
|
|
583
|
+
const path = `/v1/admin/settings/enforce/${key}`;
|
|
584
|
+
return this.request(
|
|
585
|
+
"PUT",
|
|
586
|
+
path,
|
|
587
|
+
body,
|
|
588
|
+
token
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Remove enforcement from a setting
|
|
593
|
+
* DELETE /v1/admin/settings/enforce/{key}
|
|
594
|
+
*/
|
|
595
|
+
async unenforceSetting(key, body, token) {
|
|
596
|
+
const path = `/v1/admin/settings/enforce/${key}`;
|
|
597
|
+
return this.request(
|
|
598
|
+
"DELETE",
|
|
599
|
+
path,
|
|
600
|
+
body,
|
|
601
|
+
token
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Resolve all settings at a scope
|
|
606
|
+
* GET /v1/admin/settings/resolve
|
|
607
|
+
*/
|
|
608
|
+
async resolveSettings(token) {
|
|
609
|
+
const path = "/v1/admin/settings/resolve";
|
|
610
|
+
return this.request(
|
|
611
|
+
"GET",
|
|
612
|
+
path,
|
|
613
|
+
void 0,
|
|
614
|
+
token
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Resolve one setting with cascade details
|
|
619
|
+
* GET /v1/admin/settings/resolve/{key}
|
|
620
|
+
*/
|
|
621
|
+
async resolveSetting(key, token) {
|
|
622
|
+
const path = `/v1/admin/settings/resolve/${key}`;
|
|
623
|
+
return this.request(
|
|
624
|
+
"GET",
|
|
625
|
+
path,
|
|
626
|
+
void 0,
|
|
627
|
+
token
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Set a setting value at a scope
|
|
632
|
+
* PUT /v1/admin/settings/values/{key}
|
|
633
|
+
*/
|
|
634
|
+
async setSetting(key, body, token) {
|
|
635
|
+
const path = `/v1/admin/settings/values/${key}`;
|
|
636
|
+
return this.request(
|
|
637
|
+
"PUT",
|
|
638
|
+
path,
|
|
639
|
+
body,
|
|
640
|
+
token
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Delete a setting override at a scope
|
|
645
|
+
* DELETE /v1/admin/settings/values/{key}
|
|
646
|
+
*/
|
|
647
|
+
async deleteSetting(key, body, token) {
|
|
648
|
+
const path = `/v1/admin/settings/values/${key}`;
|
|
649
|
+
return this.request(
|
|
650
|
+
"DELETE",
|
|
651
|
+
path,
|
|
652
|
+
body,
|
|
653
|
+
token
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* List social providers (admin)
|
|
658
|
+
* GET /v1/admin/social/providers
|
|
659
|
+
*/
|
|
660
|
+
async socialAdminListProviders(app_id, token) {
|
|
661
|
+
const params = new URLSearchParams();
|
|
662
|
+
if (app_id !== void 0) params.set("app_id", String(app_id));
|
|
663
|
+
const qs = params.toString();
|
|
664
|
+
const path = "/v1/admin/social/providers" + (qs ? `?${qs}` : "");
|
|
665
|
+
return this.request(
|
|
666
|
+
"GET",
|
|
667
|
+
path,
|
|
668
|
+
void 0,
|
|
669
|
+
token
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* List supported social providers
|
|
674
|
+
* GET /v1/admin/social/providers/catalog
|
|
675
|
+
*/
|
|
676
|
+
async socialAdminCatalog(token) {
|
|
677
|
+
const path = "/v1/admin/social/providers/catalog";
|
|
678
|
+
return this.request(
|
|
679
|
+
"GET",
|
|
680
|
+
path,
|
|
681
|
+
void 0,
|
|
682
|
+
token
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Configure a social provider (admin)
|
|
687
|
+
* PUT /v1/admin/social/providers/{provider}
|
|
688
|
+
*/
|
|
689
|
+
async socialAdminUpsertProvider(provider, body, app_id, token) {
|
|
690
|
+
const params = new URLSearchParams();
|
|
691
|
+
if (app_id !== void 0) params.set("app_id", String(app_id));
|
|
692
|
+
const qs = params.toString();
|
|
693
|
+
const path = `/v1/admin/social/providers/${provider}` + (qs ? `?${qs}` : "");
|
|
694
|
+
return this.request(
|
|
695
|
+
"PUT",
|
|
696
|
+
path,
|
|
697
|
+
body,
|
|
698
|
+
token
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Delete a social provider (admin)
|
|
703
|
+
* DELETE /v1/admin/social/providers/{provider}
|
|
704
|
+
*/
|
|
705
|
+
async socialAdminDeleteProvider(provider, app_id, token) {
|
|
706
|
+
const params = new URLSearchParams();
|
|
707
|
+
if (app_id !== void 0) params.set("app_id", String(app_id));
|
|
708
|
+
const qs = params.toString();
|
|
709
|
+
const path = `/v1/admin/social/providers/${provider}` + (qs ? `?${qs}` : "");
|
|
710
|
+
return this.request(
|
|
711
|
+
"DELETE",
|
|
712
|
+
path,
|
|
713
|
+
void 0,
|
|
714
|
+
token
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* List SSO connections for an app (admin)
|
|
719
|
+
* GET /v1/admin/sso/connections
|
|
720
|
+
*/
|
|
721
|
+
async ssoAdminListConnections(app_id, token) {
|
|
722
|
+
const params = new URLSearchParams();
|
|
723
|
+
if (app_id !== void 0) params.set("app_id", String(app_id));
|
|
724
|
+
const qs = params.toString();
|
|
725
|
+
const path = "/v1/admin/sso/connections" + (qs ? `?${qs}` : "");
|
|
726
|
+
return this.request(
|
|
727
|
+
"GET",
|
|
728
|
+
path,
|
|
729
|
+
void 0,
|
|
730
|
+
token
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Create SSO connection (admin)
|
|
735
|
+
* POST /v1/admin/sso/connections
|
|
736
|
+
*/
|
|
737
|
+
async ssoAdminCreateConnection(body, token) {
|
|
738
|
+
const path = "/v1/admin/sso/connections";
|
|
739
|
+
return this.request(
|
|
740
|
+
"POST",
|
|
741
|
+
path,
|
|
742
|
+
body,
|
|
743
|
+
token
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Get SSO connection (admin)
|
|
748
|
+
* GET /v1/admin/sso/connections/{connectionId}
|
|
749
|
+
*/
|
|
750
|
+
async ssoAdminGetConnection(connectionId, token) {
|
|
751
|
+
const path = `/v1/admin/sso/connections/${connectionId}`;
|
|
752
|
+
return this.request(
|
|
753
|
+
"GET",
|
|
754
|
+
path,
|
|
755
|
+
void 0,
|
|
756
|
+
token
|
|
757
|
+
);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Update SSO connection (admin)
|
|
761
|
+
* PUT /v1/admin/sso/connections/{connectionId}
|
|
762
|
+
*/
|
|
763
|
+
async ssoAdminUpdateConnection(connectionId, body, token) {
|
|
764
|
+
const path = `/v1/admin/sso/connections/${connectionId}`;
|
|
765
|
+
return this.request(
|
|
766
|
+
"PUT",
|
|
767
|
+
path,
|
|
768
|
+
body,
|
|
769
|
+
token
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Delete SSO connection (admin)
|
|
774
|
+
* DELETE /v1/admin/sso/connections/{connectionId}
|
|
775
|
+
*/
|
|
776
|
+
async ssoAdminDeleteConnection(connectionId, token) {
|
|
777
|
+
const path = `/v1/admin/sso/connections/${connectionId}`;
|
|
778
|
+
return this.request(
|
|
779
|
+
"DELETE",
|
|
780
|
+
path,
|
|
781
|
+
void 0,
|
|
782
|
+
token
|
|
783
|
+
);
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Get stats (admin)
|
|
787
|
+
* GET /v1/admin/stats
|
|
788
|
+
*/
|
|
789
|
+
async adminGetStats(token) {
|
|
790
|
+
const path = "/v1/admin/stats";
|
|
791
|
+
return this.request(
|
|
792
|
+
"GET",
|
|
793
|
+
path,
|
|
794
|
+
void 0,
|
|
795
|
+
token
|
|
796
|
+
);
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* List users (admin)
|
|
800
|
+
* GET /v1/admin/users
|
|
801
|
+
*/
|
|
802
|
+
async adminListUsers(token) {
|
|
803
|
+
const path = "/v1/admin/users";
|
|
804
|
+
return this.request(
|
|
805
|
+
"GET",
|
|
806
|
+
path,
|
|
807
|
+
void 0,
|
|
808
|
+
token
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Create user (admin)
|
|
813
|
+
* POST /v1/admin/users/create
|
|
814
|
+
*/
|
|
815
|
+
async adminCreateUser(body, token) {
|
|
816
|
+
const path = "/v1/admin/users/create";
|
|
817
|
+
return this.request(
|
|
818
|
+
"POST",
|
|
819
|
+
path,
|
|
820
|
+
body,
|
|
821
|
+
token
|
|
822
|
+
);
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Get user (admin)
|
|
826
|
+
* GET /v1/admin/users/{userId}
|
|
827
|
+
*/
|
|
828
|
+
async adminGetUser(userId, token) {
|
|
829
|
+
const path = `/v1/admin/users/${userId}`;
|
|
830
|
+
return this.request(
|
|
831
|
+
"GET",
|
|
832
|
+
path,
|
|
833
|
+
void 0,
|
|
834
|
+
token
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Update user (admin)
|
|
839
|
+
* PATCH /v1/admin/users/{userId}
|
|
840
|
+
*/
|
|
841
|
+
async adminUpdateUser(userId, body, token) {
|
|
842
|
+
const path = `/v1/admin/users/${userId}`;
|
|
843
|
+
return this.request(
|
|
844
|
+
"PATCH",
|
|
845
|
+
path,
|
|
846
|
+
body,
|
|
847
|
+
token
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Delete user (admin)
|
|
852
|
+
* DELETE /v1/admin/users/{userId}
|
|
853
|
+
*/
|
|
854
|
+
async adminDeleteUser(userId, body, token) {
|
|
855
|
+
const path = `/v1/admin/users/${userId}`;
|
|
856
|
+
return this.request(
|
|
857
|
+
"DELETE",
|
|
858
|
+
path,
|
|
859
|
+
body,
|
|
860
|
+
token
|
|
861
|
+
);
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Ban user (admin)
|
|
865
|
+
* POST /v1/admin/users/{userId}/ban
|
|
866
|
+
*/
|
|
867
|
+
async adminBanUser(userId, body, token) {
|
|
868
|
+
const path = `/v1/admin/users/${userId}/ban`;
|
|
869
|
+
return this.request(
|
|
870
|
+
"POST",
|
|
871
|
+
path,
|
|
872
|
+
body,
|
|
873
|
+
token
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Unban user (admin)
|
|
878
|
+
* POST /v1/admin/users/{userId}/unban
|
|
879
|
+
*/
|
|
880
|
+
async adminUnbanUser(userId, body, token) {
|
|
881
|
+
const path = `/v1/admin/users/${userId}/unban`;
|
|
882
|
+
return this.request(
|
|
883
|
+
"POST",
|
|
884
|
+
path,
|
|
885
|
+
body,
|
|
886
|
+
token
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* List coupons
|
|
891
|
+
* GET /v1/billing/coupons
|
|
892
|
+
*/
|
|
893
|
+
async listCoupons(token) {
|
|
894
|
+
const path = "/v1/billing/coupons";
|
|
895
|
+
return this.request(
|
|
896
|
+
"GET",
|
|
897
|
+
path,
|
|
898
|
+
void 0,
|
|
899
|
+
token
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Create coupon
|
|
904
|
+
* POST /v1/billing/coupons
|
|
905
|
+
*/
|
|
906
|
+
async createCoupon(body, token) {
|
|
907
|
+
const path = "/v1/billing/coupons";
|
|
908
|
+
return this.request(
|
|
909
|
+
"POST",
|
|
910
|
+
path,
|
|
911
|
+
body,
|
|
912
|
+
token
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Delete coupon
|
|
917
|
+
* DELETE /v1/billing/coupons/{couponId}
|
|
918
|
+
*/
|
|
919
|
+
async deleteCoupon(couponId, body, token) {
|
|
920
|
+
const path = `/v1/billing/coupons/${couponId}`;
|
|
921
|
+
return this.request(
|
|
922
|
+
"DELETE",
|
|
923
|
+
path,
|
|
924
|
+
body,
|
|
925
|
+
token
|
|
926
|
+
);
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Check feature entitlement
|
|
930
|
+
* GET /v1/billing/entitlements/{featureKey}
|
|
931
|
+
*/
|
|
932
|
+
async checkEntitlement(featureKey, token) {
|
|
933
|
+
const path = `/v1/billing/entitlements/${featureKey}`;
|
|
934
|
+
return this.request(
|
|
935
|
+
"GET",
|
|
936
|
+
path,
|
|
937
|
+
void 0,
|
|
938
|
+
token
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* List invoices
|
|
943
|
+
* GET /v1/billing/invoices
|
|
944
|
+
*/
|
|
945
|
+
async listInvoices(token) {
|
|
946
|
+
const path = "/v1/billing/invoices";
|
|
947
|
+
return this.request(
|
|
948
|
+
"GET",
|
|
949
|
+
path,
|
|
950
|
+
void 0,
|
|
951
|
+
token
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Get invoice
|
|
956
|
+
* GET /v1/billing/invoices/{invoiceId}
|
|
957
|
+
*/
|
|
958
|
+
async getInvoice(invoiceId, token) {
|
|
959
|
+
const path = `/v1/billing/invoices/${invoiceId}`;
|
|
960
|
+
return this.request(
|
|
961
|
+
"GET",
|
|
962
|
+
path,
|
|
963
|
+
void 0,
|
|
964
|
+
token
|
|
965
|
+
);
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Mark invoice as paid
|
|
969
|
+
* POST /v1/billing/invoices/{invoiceId}/pay
|
|
970
|
+
*/
|
|
971
|
+
async markInvoicePaid(invoiceId, body, token) {
|
|
972
|
+
const path = `/v1/billing/invoices/${invoiceId}/pay`;
|
|
973
|
+
return this.request(
|
|
974
|
+
"POST",
|
|
975
|
+
path,
|
|
976
|
+
body,
|
|
977
|
+
token
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Void an invoice
|
|
982
|
+
* POST /v1/billing/invoices/{invoiceId}/void
|
|
983
|
+
*/
|
|
984
|
+
async voidInvoice(invoiceId, body, token) {
|
|
985
|
+
const path = `/v1/billing/invoices/${invoiceId}/void`;
|
|
986
|
+
return this.request(
|
|
987
|
+
"POST",
|
|
988
|
+
path,
|
|
989
|
+
body,
|
|
990
|
+
token
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* List billing plans
|
|
995
|
+
* GET /v1/billing/plans
|
|
996
|
+
*/
|
|
997
|
+
async listBillingPlans(token) {
|
|
998
|
+
const path = "/v1/billing/plans";
|
|
999
|
+
return this.request(
|
|
1000
|
+
"GET",
|
|
1001
|
+
path,
|
|
1002
|
+
void 0,
|
|
1003
|
+
token
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Create billing plan
|
|
1008
|
+
* POST /v1/billing/plans
|
|
208
1009
|
*/
|
|
209
|
-
async
|
|
210
|
-
const path =
|
|
1010
|
+
async createBillingPlan(body, token) {
|
|
1011
|
+
const path = "/v1/billing/plans";
|
|
211
1012
|
return this.request(
|
|
212
|
-
"
|
|
1013
|
+
"POST",
|
|
213
1014
|
path,
|
|
214
1015
|
body,
|
|
215
1016
|
token
|
|
216
1017
|
);
|
|
217
1018
|
}
|
|
218
1019
|
/**
|
|
219
|
-
*
|
|
220
|
-
*
|
|
1020
|
+
* Get billing plan
|
|
1021
|
+
* GET /v1/billing/plans/{planId}
|
|
221
1022
|
*/
|
|
222
|
-
async
|
|
223
|
-
const path = `/v1/
|
|
1023
|
+
async getBillingPlan(planId, token) {
|
|
1024
|
+
const path = `/v1/billing/plans/${planId}`;
|
|
224
1025
|
return this.request(
|
|
225
|
-
"
|
|
1026
|
+
"GET",
|
|
226
1027
|
path,
|
|
227
|
-
|
|
1028
|
+
void 0,
|
|
228
1029
|
token
|
|
229
1030
|
);
|
|
230
1031
|
}
|
|
231
1032
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
1033
|
+
* Activate a billing plan
|
|
1034
|
+
* POST /v1/billing/plans/{planId}/activate
|
|
234
1035
|
*/
|
|
235
|
-
async
|
|
236
|
-
const path =
|
|
1036
|
+
async activateBillingPlan(planId, body, token) {
|
|
1037
|
+
const path = `/v1/billing/plans/${planId}/activate`;
|
|
237
1038
|
return this.request(
|
|
238
|
-
"
|
|
1039
|
+
"POST",
|
|
239
1040
|
path,
|
|
240
|
-
|
|
1041
|
+
body,
|
|
241
1042
|
token
|
|
242
1043
|
);
|
|
243
1044
|
}
|
|
244
1045
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
1046
|
+
* Archive a billing plan
|
|
1047
|
+
* POST /v1/billing/plans/{planId}/archive
|
|
247
1048
|
*/
|
|
248
|
-
async
|
|
249
|
-
const path = `/v1/
|
|
1049
|
+
async archiveBillingPlan(planId, body, token) {
|
|
1050
|
+
const path = `/v1/billing/plans/${planId}/archive`;
|
|
250
1051
|
return this.request(
|
|
251
|
-
"
|
|
1052
|
+
"POST",
|
|
252
1053
|
path,
|
|
253
|
-
|
|
1054
|
+
body,
|
|
254
1055
|
token
|
|
255
1056
|
);
|
|
256
1057
|
}
|
|
257
1058
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
1059
|
+
* List subscriptions
|
|
1060
|
+
* GET /v1/billing/subscriptions
|
|
260
1061
|
*/
|
|
261
|
-
async
|
|
262
|
-
const path =
|
|
1062
|
+
async listSubscriptions(token) {
|
|
1063
|
+
const path = "/v1/billing/subscriptions";
|
|
263
1064
|
return this.request(
|
|
264
|
-
"
|
|
1065
|
+
"GET",
|
|
265
1066
|
path,
|
|
266
|
-
|
|
1067
|
+
void 0,
|
|
267
1068
|
token
|
|
268
1069
|
);
|
|
269
1070
|
}
|
|
270
1071
|
/**
|
|
271
|
-
*
|
|
272
|
-
*
|
|
1072
|
+
* Create subscription
|
|
1073
|
+
* POST /v1/billing/subscriptions
|
|
273
1074
|
*/
|
|
274
|
-
async
|
|
275
|
-
const path =
|
|
1075
|
+
async createSubscription(body, token) {
|
|
1076
|
+
const path = "/v1/billing/subscriptions";
|
|
276
1077
|
return this.request(
|
|
277
|
-
"
|
|
1078
|
+
"POST",
|
|
278
1079
|
path,
|
|
279
1080
|
body,
|
|
280
1081
|
token
|
|
281
1082
|
);
|
|
282
1083
|
}
|
|
283
1084
|
/**
|
|
284
|
-
* Get
|
|
285
|
-
* GET /v1/
|
|
1085
|
+
* Get active subscription
|
|
1086
|
+
* GET /v1/billing/subscriptions/active
|
|
286
1087
|
*/
|
|
287
|
-
async
|
|
288
|
-
const path = "/v1/
|
|
1088
|
+
async getActiveSubscription(token) {
|
|
1089
|
+
const path = "/v1/billing/subscriptions/active";
|
|
289
1090
|
return this.request(
|
|
290
1091
|
"GET",
|
|
291
1092
|
path,
|
|
@@ -294,50 +1095,50 @@ var AuthClient = class {
|
|
|
294
1095
|
);
|
|
295
1096
|
}
|
|
296
1097
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
1098
|
+
* Cancel subscription
|
|
1099
|
+
* POST /v1/billing/subscriptions/{subId}/cancel
|
|
299
1100
|
*/
|
|
300
|
-
async
|
|
301
|
-
const path =
|
|
1101
|
+
async cancelSubscription(subId, body, token) {
|
|
1102
|
+
const path = `/v1/billing/subscriptions/${subId}/cancel`;
|
|
302
1103
|
return this.request(
|
|
303
|
-
"
|
|
1104
|
+
"POST",
|
|
304
1105
|
path,
|
|
305
|
-
|
|
1106
|
+
body,
|
|
306
1107
|
token
|
|
307
1108
|
);
|
|
308
1109
|
}
|
|
309
1110
|
/**
|
|
310
|
-
*
|
|
311
|
-
*
|
|
1111
|
+
* Change subscription plan
|
|
1112
|
+
* POST /v1/billing/subscriptions/{subId}/change-plan
|
|
312
1113
|
*/
|
|
313
|
-
async
|
|
314
|
-
const path = `/v1/
|
|
1114
|
+
async changeSubscriptionPlan(subId, body, token) {
|
|
1115
|
+
const path = `/v1/billing/subscriptions/${subId}/change-plan`;
|
|
315
1116
|
return this.request(
|
|
316
|
-
"
|
|
1117
|
+
"POST",
|
|
317
1118
|
path,
|
|
318
|
-
|
|
1119
|
+
body,
|
|
319
1120
|
token
|
|
320
1121
|
);
|
|
321
1122
|
}
|
|
322
1123
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
1124
|
+
* Pause subscription
|
|
1125
|
+
* POST /v1/billing/subscriptions/{subId}/pause
|
|
325
1126
|
*/
|
|
326
|
-
async
|
|
327
|
-
const path = `/v1/
|
|
1127
|
+
async pauseSubscription(subId, body, token) {
|
|
1128
|
+
const path = `/v1/billing/subscriptions/${subId}/pause`;
|
|
328
1129
|
return this.request(
|
|
329
|
-
"
|
|
1130
|
+
"POST",
|
|
330
1131
|
path,
|
|
331
1132
|
body,
|
|
332
1133
|
token
|
|
333
1134
|
);
|
|
334
1135
|
}
|
|
335
1136
|
/**
|
|
336
|
-
*
|
|
337
|
-
* POST /v1/
|
|
1137
|
+
* Resume subscription
|
|
1138
|
+
* POST /v1/billing/subscriptions/{subId}/resume
|
|
338
1139
|
*/
|
|
339
|
-
async
|
|
340
|
-
const path = `/v1/
|
|
1140
|
+
async resumeSubscription(subId, body, token) {
|
|
1141
|
+
const path = `/v1/billing/subscriptions/${subId}/resume`;
|
|
341
1142
|
return this.request(
|
|
342
1143
|
"POST",
|
|
343
1144
|
path,
|
|
@@ -346,15 +1147,15 @@ var AuthClient = class {
|
|
|
346
1147
|
);
|
|
347
1148
|
}
|
|
348
1149
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
1150
|
+
* Get usage summary
|
|
1151
|
+
* GET /v1/billing/usage
|
|
351
1152
|
*/
|
|
352
|
-
async
|
|
353
|
-
const path =
|
|
1153
|
+
async getUsageSummary(token) {
|
|
1154
|
+
const path = "/v1/billing/usage";
|
|
354
1155
|
return this.request(
|
|
355
|
-
"
|
|
1156
|
+
"GET",
|
|
356
1157
|
path,
|
|
357
|
-
|
|
1158
|
+
void 0,
|
|
358
1159
|
token
|
|
359
1160
|
);
|
|
360
1161
|
}
|
|
@@ -384,6 +1185,42 @@ var AuthClient = class {
|
|
|
384
1185
|
token
|
|
385
1186
|
);
|
|
386
1187
|
}
|
|
1188
|
+
/**
|
|
1189
|
+
* List consents
|
|
1190
|
+
* GET /v1/consent
|
|
1191
|
+
*/
|
|
1192
|
+
async listConsents() {
|
|
1193
|
+
const path = "/v1/consent";
|
|
1194
|
+
return this.request(
|
|
1195
|
+
"GET",
|
|
1196
|
+
path,
|
|
1197
|
+
void 0
|
|
1198
|
+
);
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Grant consent
|
|
1202
|
+
* POST /v1/consent/grant
|
|
1203
|
+
*/
|
|
1204
|
+
async grantConsent(body) {
|
|
1205
|
+
const path = "/v1/consent/grant";
|
|
1206
|
+
return this.request(
|
|
1207
|
+
"POST",
|
|
1208
|
+
path,
|
|
1209
|
+
body
|
|
1210
|
+
);
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Revoke consent
|
|
1214
|
+
* POST /v1/consent/revoke
|
|
1215
|
+
*/
|
|
1216
|
+
async revokeConsent(body) {
|
|
1217
|
+
const path = "/v1/consent/revoke";
|
|
1218
|
+
return this.request(
|
|
1219
|
+
"POST",
|
|
1220
|
+
path,
|
|
1221
|
+
body
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
387
1224
|
/**
|
|
388
1225
|
* List devices
|
|
389
1226
|
* GET /v1/devices
|
|
@@ -577,6 +1414,18 @@ var AuthClient = class {
|
|
|
577
1414
|
void 0
|
|
578
1415
|
);
|
|
579
1416
|
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Introspect token
|
|
1419
|
+
* POST /v1/introspect
|
|
1420
|
+
*/
|
|
1421
|
+
async introspectToken(body) {
|
|
1422
|
+
const path = "/v1/introspect";
|
|
1423
|
+
return this.request(
|
|
1424
|
+
"POST",
|
|
1425
|
+
path,
|
|
1426
|
+
body
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
580
1429
|
/**
|
|
581
1430
|
* List API keys
|
|
582
1431
|
* GET /v1/keys
|
|
@@ -718,6 +1567,19 @@ var AuthClient = class {
|
|
|
718
1567
|
token
|
|
719
1568
|
);
|
|
720
1569
|
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Switch active organization
|
|
1572
|
+
* POST /v1/me/switch-org
|
|
1573
|
+
*/
|
|
1574
|
+
async switchOrg(body, token) {
|
|
1575
|
+
const path = "/v1/me/switch-org";
|
|
1576
|
+
return this.request(
|
|
1577
|
+
"POST",
|
|
1578
|
+
path,
|
|
1579
|
+
body,
|
|
1580
|
+
token
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
721
1583
|
/**
|
|
722
1584
|
* MFA challenge
|
|
723
1585
|
* POST /v1/mfa/challenge
|
|
@@ -819,6 +1681,80 @@ var AuthClient = class {
|
|
|
819
1681
|
body
|
|
820
1682
|
);
|
|
821
1683
|
}
|
|
1684
|
+
/**
|
|
1685
|
+
* OAuth2 Authorization
|
|
1686
|
+
* GET /v1/oauth/authorize
|
|
1687
|
+
*/
|
|
1688
|
+
async oauth2Authorize() {
|
|
1689
|
+
const path = "/v1/oauth/authorize";
|
|
1690
|
+
return this.request(
|
|
1691
|
+
"GET",
|
|
1692
|
+
path,
|
|
1693
|
+
void 0
|
|
1694
|
+
);
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Device Authorization
|
|
1698
|
+
* POST /v1/oauth/device/authorize
|
|
1699
|
+
*/
|
|
1700
|
+
async oauth2DeviceAuthorize(body) {
|
|
1701
|
+
const path = "/v1/oauth/device/authorize";
|
|
1702
|
+
return this.request(
|
|
1703
|
+
"POST",
|
|
1704
|
+
path,
|
|
1705
|
+
body
|
|
1706
|
+
);
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Complete device authorization
|
|
1710
|
+
* POST /v1/oauth/device/complete
|
|
1711
|
+
*/
|
|
1712
|
+
async oauth2DeviceComplete(body) {
|
|
1713
|
+
const path = "/v1/oauth/device/complete";
|
|
1714
|
+
return this.request(
|
|
1715
|
+
"POST",
|
|
1716
|
+
path,
|
|
1717
|
+
body
|
|
1718
|
+
);
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* Revoke token
|
|
1722
|
+
* POST /v1/oauth/revoke
|
|
1723
|
+
*/
|
|
1724
|
+
async oauth2Revoke(body, token) {
|
|
1725
|
+
const path = "/v1/oauth/revoke";
|
|
1726
|
+
return this.request(
|
|
1727
|
+
"POST",
|
|
1728
|
+
path,
|
|
1729
|
+
body,
|
|
1730
|
+
token
|
|
1731
|
+
);
|
|
1732
|
+
}
|
|
1733
|
+
/**
|
|
1734
|
+
* OAuth2 Token
|
|
1735
|
+
* POST /v1/oauth/token
|
|
1736
|
+
*/
|
|
1737
|
+
async oauth2Token(body) {
|
|
1738
|
+
const path = "/v1/oauth/token";
|
|
1739
|
+
return this.request(
|
|
1740
|
+
"POST",
|
|
1741
|
+
path,
|
|
1742
|
+
body
|
|
1743
|
+
);
|
|
1744
|
+
}
|
|
1745
|
+
/**
|
|
1746
|
+
* OIDC UserInfo
|
|
1747
|
+
* GET /v1/oauth/userinfo
|
|
1748
|
+
*/
|
|
1749
|
+
async oauth2UserInfo(token) {
|
|
1750
|
+
const path = "/v1/oauth/userinfo";
|
|
1751
|
+
return this.request(
|
|
1752
|
+
"GET",
|
|
1753
|
+
path,
|
|
1754
|
+
void 0,
|
|
1755
|
+
token
|
|
1756
|
+
);
|
|
1757
|
+
}
|
|
822
1758
|
/**
|
|
823
1759
|
* List organizations
|
|
824
1760
|
* GET /v1/orgs
|
|
@@ -1068,10 +2004,10 @@ var AuthClient = class {
|
|
|
1068
2004
|
}
|
|
1069
2005
|
/**
|
|
1070
2006
|
* List passkeys
|
|
1071
|
-
* GET /v1/passkeys
|
|
2007
|
+
* GET /v1/passkeys
|
|
1072
2008
|
*/
|
|
1073
2009
|
async listPasskeys(token) {
|
|
1074
|
-
const path = "/v1/passkeys
|
|
2010
|
+
const path = "/v1/passkeys";
|
|
1075
2011
|
return this.request(
|
|
1076
2012
|
"GET",
|
|
1077
2013
|
path,
|
|
@@ -1142,6 +2078,30 @@ var AuthClient = class {
|
|
|
1142
2078
|
token
|
|
1143
2079
|
);
|
|
1144
2080
|
}
|
|
2081
|
+
/**
|
|
2082
|
+
* Start phone authentication
|
|
2083
|
+
* POST /v1/phone/start
|
|
2084
|
+
*/
|
|
2085
|
+
async phoneAuthStart(body) {
|
|
2086
|
+
const path = "/v1/phone/start";
|
|
2087
|
+
return this.request(
|
|
2088
|
+
"POST",
|
|
2089
|
+
path,
|
|
2090
|
+
body
|
|
2091
|
+
);
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* Verify phone OTP
|
|
2095
|
+
* POST /v1/phone/verify
|
|
2096
|
+
*/
|
|
2097
|
+
async phoneAuthVerify(body) {
|
|
2098
|
+
const path = "/v1/phone/verify";
|
|
2099
|
+
return this.request(
|
|
2100
|
+
"POST",
|
|
2101
|
+
path,
|
|
2102
|
+
body
|
|
2103
|
+
);
|
|
2104
|
+
}
|
|
1145
2105
|
/**
|
|
1146
2106
|
* Refresh tokens
|
|
1147
2107
|
* POST /v1/refresh
|
|
@@ -1444,6 +2404,18 @@ var AuthClient = class {
|
|
|
1444
2404
|
body
|
|
1445
2405
|
);
|
|
1446
2406
|
}
|
|
2407
|
+
/**
|
|
2408
|
+
* Resend email verification
|
|
2409
|
+
* POST /v1/verify-email/resend
|
|
2410
|
+
*/
|
|
2411
|
+
async resendEmailVerification(body) {
|
|
2412
|
+
const path = "/v1/verify-email/resend";
|
|
2413
|
+
return this.request(
|
|
2414
|
+
"POST",
|
|
2415
|
+
path,
|
|
2416
|
+
body
|
|
2417
|
+
);
|
|
2418
|
+
}
|
|
1447
2419
|
/**
|
|
1448
2420
|
* List webhooks
|
|
1449
2421
|
* GET /v1/webhooks
|
|
@@ -1520,6 +2492,9 @@ var AuthClient = class {
|
|
|
1520
2492
|
if (token) {
|
|
1521
2493
|
headers["Authorization"] = `Bearer ${token}`;
|
|
1522
2494
|
}
|
|
2495
|
+
if (this.publishableKey) {
|
|
2496
|
+
headers["X-Publishable-Key"] = this.publishableKey;
|
|
2497
|
+
}
|
|
1523
2498
|
const response = await this.fetchFn(`${this.baseURL}${path}`, {
|
|
1524
2499
|
method,
|
|
1525
2500
|
headers,
|
|
@@ -1533,7 +2508,10 @@ var AuthClient = class {
|
|
|
1533
2508
|
}
|
|
1534
2509
|
throw new AuthClientError(
|
|
1535
2510
|
apiError?.error ?? `Request failed with status ${response.status}`,
|
|
1536
|
-
apiError?.code ?? response.status
|
|
2511
|
+
apiError?.code ?? response.status,
|
|
2512
|
+
apiError?.type,
|
|
2513
|
+
apiError
|
|
2514
|
+
// full decoded body so callers can read extras like mfa_ticket / available_methods
|
|
1537
2515
|
);
|
|
1538
2516
|
}
|
|
1539
2517
|
if (response.status === 204) {
|
|
@@ -1544,10 +2522,23 @@ var AuthClient = class {
|
|
|
1544
2522
|
};
|
|
1545
2523
|
var AuthClientError = class extends Error {
|
|
1546
2524
|
code;
|
|
1547
|
-
|
|
2525
|
+
// Stable string error code from the backend envelope (e.g.
|
|
2526
|
+
// "email_not_verified", "captcha_required", "mfa_required"). Lets
|
|
2527
|
+
// the UI branch on specific failure modes instead of pattern-
|
|
2528
|
+
// matching on the human-readable message.
|
|
2529
|
+
type;
|
|
2530
|
+
// Full decoded JSON body when the response body was JSON. Lets
|
|
2531
|
+
// callers read tagged extras the envelope carries beyond
|
|
2532
|
+
// {error, code, type} — e.g. mfa_ticket and available_methods on
|
|
2533
|
+
// a 403 with type:"mfa_required". Undefined when the body wasn't
|
|
2534
|
+
// JSON.
|
|
2535
|
+
details;
|
|
2536
|
+
constructor(message, code, type, details) {
|
|
1548
2537
|
super(message);
|
|
1549
2538
|
this.name = "AuthClientError";
|
|
1550
2539
|
this.code = code;
|
|
2540
|
+
this.type = type;
|
|
2541
|
+
this.details = details;
|
|
1551
2542
|
}
|
|
1552
2543
|
};
|
|
1553
2544
|
|
|
@@ -1609,18 +2600,55 @@ var AuthClient2 = class extends AuthClient {
|
|
|
1609
2600
|
async verifySMSCodeForMFA(code, token) {
|
|
1610
2601
|
return super.verifySMSCode({ code }, token);
|
|
1611
2602
|
}
|
|
2603
|
+
/**
|
|
2604
|
+
* Complete a device authorization (RFC 8628).
|
|
2605
|
+
*
|
|
2606
|
+
* Approves or denies a device code. Requires an authenticated session —
|
|
2607
|
+
* pass the session token so the backend can identify the user.
|
|
2608
|
+
*/
|
|
2609
|
+
async completeDeviceAuthorization(userCode, action, token) {
|
|
2610
|
+
const base = this.baseURL;
|
|
2611
|
+
const fetchFn = this.fetchFn;
|
|
2612
|
+
const headers = {
|
|
2613
|
+
"Content-Type": "application/json"
|
|
2614
|
+
};
|
|
2615
|
+
if (token) {
|
|
2616
|
+
headers.Authorization = `Bearer ${token}`;
|
|
2617
|
+
}
|
|
2618
|
+
const res = await fetchFn(`${base}/v1/oauth/device/complete`, {
|
|
2619
|
+
method: "POST",
|
|
2620
|
+
headers,
|
|
2621
|
+
credentials: "include",
|
|
2622
|
+
body: JSON.stringify({ user_code: userCode, action })
|
|
2623
|
+
});
|
|
2624
|
+
if (!res.ok) {
|
|
2625
|
+
const body = await res.json().catch(() => ({}));
|
|
2626
|
+
throw new AuthClientError(
|
|
2627
|
+
body.error || "Failed to authorize device",
|
|
2628
|
+
res.status
|
|
2629
|
+
);
|
|
2630
|
+
}
|
|
2631
|
+
return res.json();
|
|
2632
|
+
}
|
|
1612
2633
|
/**
|
|
1613
2634
|
* Fetch the client configuration from the backend.
|
|
1614
2635
|
*
|
|
1615
2636
|
* The config describes which auth methods are enabled so SDK
|
|
1616
2637
|
* components can auto-configure without manual props.
|
|
2638
|
+
*
|
|
2639
|
+
* Reads `baseURL` and `fetchFn` directly off the generated parent
|
|
2640
|
+
* class — earlier generator templates kept a `this.config` ref but
|
|
2641
|
+
* the current embedded template stores fields individually, so the
|
|
2642
|
+
* old `(this as any).config.baseURL` shape produced `undefined` and
|
|
2643
|
+
* the URL constructor threw.
|
|
1617
2644
|
*/
|
|
1618
2645
|
async fetchClientConfig(publishableKey) {
|
|
1619
|
-
const
|
|
2646
|
+
const baseURL = this.baseURL;
|
|
2647
|
+
const fetchFn = this.fetchFn ?? globalThis.fetch;
|
|
2648
|
+
const url = new URL("/v1/client-config", baseURL);
|
|
1620
2649
|
if (publishableKey) {
|
|
1621
2650
|
url.searchParams.set("key", publishableKey);
|
|
1622
2651
|
}
|
|
1623
|
-
const fetchFn = this.config.fetch ?? globalThis.fetch;
|
|
1624
2652
|
const res = await fetchFn(url.toString(), {
|
|
1625
2653
|
method: "GET",
|
|
1626
2654
|
headers: { "Content-Type": "application/json" }
|
|
@@ -1745,6 +2773,26 @@ var AuthManager = class {
|
|
|
1745
2773
|
};
|
|
1746
2774
|
await this.handleAuthResponse(res.user, session);
|
|
1747
2775
|
} catch (err) {
|
|
2776
|
+
if (err instanceof AuthClientError && err.type === "mfa_required" && err.details) {
|
|
2777
|
+
const ticket = typeof err.details["mfa_ticket"] === "string" ? err.details["mfa_ticket"] : "";
|
|
2778
|
+
const methods = Array.isArray(err.details["available_methods"]) ? err.details["available_methods"] : [];
|
|
2779
|
+
if (ticket) {
|
|
2780
|
+
this.setState({
|
|
2781
|
+
status: "mfa_required",
|
|
2782
|
+
email: credentials.email ?? "",
|
|
2783
|
+
mfaTicket: ticket,
|
|
2784
|
+
availableMethods: methods
|
|
2785
|
+
});
|
|
2786
|
+
return;
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
if (err instanceof AuthClientError && err.type === "email_not_verified") {
|
|
2790
|
+
this.setState({
|
|
2791
|
+
status: "email_not_verified",
|
|
2792
|
+
email: credentials.email ?? ""
|
|
2793
|
+
});
|
|
2794
|
+
throw err;
|
|
2795
|
+
}
|
|
1748
2796
|
this.handleError(err);
|
|
1749
2797
|
throw err;
|
|
1750
2798
|
}
|
|
@@ -1752,18 +2800,35 @@ var AuthManager = class {
|
|
|
1752
2800
|
/** Sign up with email & password. */
|
|
1753
2801
|
async signUp(data) {
|
|
1754
2802
|
try {
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
};
|
|
1761
|
-
await this.handleAuthResponse(res.user, session);
|
|
2803
|
+
await this.client.signUp(data);
|
|
2804
|
+
this.setState({
|
|
2805
|
+
status: "verification_pending",
|
|
2806
|
+
email: data.email
|
|
2807
|
+
});
|
|
1762
2808
|
} catch (err) {
|
|
1763
2809
|
this.handleError(err);
|
|
1764
2810
|
throw err;
|
|
1765
2811
|
}
|
|
1766
2812
|
}
|
|
2813
|
+
/**
|
|
2814
|
+
* Resend the verification email for an unverified account.
|
|
2815
|
+
*
|
|
2816
|
+
* Always resolves; the backend returns 200 regardless of whether the
|
|
2817
|
+
* email is registered, unregistered, or already verified — that's the
|
|
2818
|
+
* enumeration-resistance contract. UI callers should disable the
|
|
2819
|
+
* button + show a generic "if your email is registered, we sent a new
|
|
2820
|
+
* link" confirmation rather than branching on the response.
|
|
2821
|
+
*/
|
|
2822
|
+
async resendVerification(email) {
|
|
2823
|
+
if (!email) return;
|
|
2824
|
+
try {
|
|
2825
|
+
await this.client.resendEmailVerification({ email });
|
|
2826
|
+
} catch (err) {
|
|
2827
|
+
this.onError?.({
|
|
2828
|
+
error: err instanceof Error ? err.message : "resend failed"
|
|
2829
|
+
});
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
1767
2832
|
/** Sign out and clear the session. */
|
|
1768
2833
|
async signOut() {
|
|
1769
2834
|
const token = this.getSessionToken();
|
|
@@ -1777,21 +2842,48 @@ var AuthManager = class {
|
|
|
1777
2842
|
await this.clearSession();
|
|
1778
2843
|
this.setState({ status: "unauthenticated" });
|
|
1779
2844
|
}
|
|
1780
|
-
/**
|
|
1781
|
-
|
|
1782
|
-
|
|
2845
|
+
/**
|
|
2846
|
+
* Submit the MFA challenge code against the ticket from the
|
|
2847
|
+
* mfa_required state. On success: real session minted, state →
|
|
2848
|
+
* "authenticated". On bad code: state stays "mfa_required" so
|
|
2849
|
+
* the form can show the error inline; the ticket remains valid
|
|
2850
|
+
* for the 5-minute server-side TTL.
|
|
2851
|
+
*
|
|
2852
|
+
* Throws if called outside the mfa_required state — the caller
|
|
2853
|
+
* has nowhere to send the code.
|
|
2854
|
+
*/
|
|
2855
|
+
async submitMFAChallenge(code) {
|
|
2856
|
+
const state = this.state;
|
|
2857
|
+
if (state.status !== "mfa_required") {
|
|
2858
|
+
throw new Error("auth: submitMFAChallenge called outside the mfa_required state");
|
|
2859
|
+
}
|
|
1783
2860
|
try {
|
|
1784
|
-
const res = await this.client.
|
|
2861
|
+
const res = await this.client.challengeMFA({
|
|
2862
|
+
mfa_ticket: state.mfaTicket,
|
|
2863
|
+
code
|
|
2864
|
+
});
|
|
1785
2865
|
const session = {
|
|
1786
2866
|
session_token: res.session_token,
|
|
1787
2867
|
refresh_token: res.refresh_token,
|
|
1788
|
-
expires_at: new Date(Date.now() + 36e5).toISOString()
|
|
2868
|
+
expires_at: res.expires_at ?? new Date(Date.now() + 36e5).toISOString()
|
|
1789
2869
|
};
|
|
1790
2870
|
await this.handleAuthResponse(res.user, session);
|
|
1791
2871
|
} catch (err) {
|
|
1792
|
-
this.
|
|
2872
|
+
this.onError?.({
|
|
2873
|
+
error: err instanceof Error ? err.message : "challenge failed"
|
|
2874
|
+
});
|
|
2875
|
+
throw err;
|
|
1793
2876
|
}
|
|
1794
2877
|
}
|
|
2878
|
+
/**
|
|
2879
|
+
* @deprecated Use submitMFAChallenge(code). The old enrollment-id
|
|
2880
|
+
* + partial-session shape was removed in the MFA consolidation;
|
|
2881
|
+
* this thin shim only exists so older callers don't break their
|
|
2882
|
+
* build, but the enrollmentId argument is now ignored.
|
|
2883
|
+
*/
|
|
2884
|
+
async submitMFACode(_enrollmentId, code) {
|
|
2885
|
+
return this.submitMFAChallenge(code);
|
|
2886
|
+
}
|
|
1795
2887
|
/** Submit an MFA recovery code. */
|
|
1796
2888
|
async submitRecoveryCode(code) {
|
|
1797
2889
|
this.setState({ status: "loading" });
|
|
@@ -1836,16 +2928,26 @@ var AuthManager = class {
|
|
|
1836
2928
|
if (state.status !== "authenticated") return;
|
|
1837
2929
|
await this.refreshSession(state.session.refresh_token);
|
|
1838
2930
|
}
|
|
1839
|
-
/**
|
|
2931
|
+
/**
|
|
2932
|
+
* Get the current session token (if authenticated). Returns null
|
|
2933
|
+
* during the MFA challenge — there is no real session yet, only a
|
|
2934
|
+
* ticket the challenge handler validates internally.
|
|
2935
|
+
*/
|
|
1840
2936
|
getSessionToken() {
|
|
1841
2937
|
if (this.state.status === "authenticated") {
|
|
1842
2938
|
return this.state.session.session_token;
|
|
1843
2939
|
}
|
|
1844
|
-
if (this.state.status === "mfa_required") {
|
|
1845
|
-
return this.state.session.session_token;
|
|
1846
|
-
}
|
|
1847
2940
|
return null;
|
|
1848
2941
|
}
|
|
2942
|
+
/**
|
|
2943
|
+
* Get the active MFA ticket (only set during the mfa_required
|
|
2944
|
+
* state). Form components driving the challenge UI read this to
|
|
2945
|
+
* confirm they have a partial-auth credential before letting the
|
|
2946
|
+
* user submit a code.
|
|
2947
|
+
*/
|
|
2948
|
+
getMFATicket() {
|
|
2949
|
+
return this.state.status === "mfa_required" ? this.state.mfaTicket : null;
|
|
2950
|
+
}
|
|
1849
2951
|
/** Get the current user (if authenticated). */
|
|
1850
2952
|
getUser() {
|
|
1851
2953
|
if (this.state.status === "authenticated") {
|
|
@@ -1970,22 +3072,9 @@ var AuthManager = class {
|
|
|
1970
3072
|
handleError(err) {
|
|
1971
3073
|
const message = err instanceof AuthClientError ? err.message : "An unexpected error occurred";
|
|
1972
3074
|
const code = err instanceof AuthClientError ? err.code : void 0;
|
|
1973
|
-
|
|
1974
|
-
const token = this.getSessionToken();
|
|
1975
|
-
if (token) {
|
|
1976
|
-
this.setState({
|
|
1977
|
-
status: "mfa_required",
|
|
1978
|
-
session: {
|
|
1979
|
-
session_token: token,
|
|
1980
|
-
refresh_token: "",
|
|
1981
|
-
expires_at: new Date(Date.now() + 3e5).toISOString()
|
|
1982
|
-
}
|
|
1983
|
-
});
|
|
1984
|
-
return;
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
3075
|
+
const type = err instanceof AuthClientError ? err.type : void 0;
|
|
1987
3076
|
this.setState({ status: "error", error: message });
|
|
1988
|
-
this.onError?.({ error: message, code });
|
|
3077
|
+
this.onError?.({ error: message, code, type });
|
|
1989
3078
|
}
|
|
1990
3079
|
};
|
|
1991
3080
|
|