@nhost/nhost-js 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/client-BL0edWHv.cjs +2 -0
  2. package/dist/client-BL0edWHv.cjs.map +1 -0
  3. package/dist/client-BOrTAJrs.js +1304 -0
  4. package/dist/client-BOrTAJrs.js.map +1 -0
  5. package/dist/{middlewareWithAdminSession-BeIk-9HO.js → middlewareWithAdminSession-CcuYKs5Y.js} +2 -2
  6. package/dist/{middlewareWithAdminSession-BeIk-9HO.js.map → middlewareWithAdminSession-CcuYKs5Y.js.map} +1 -1
  7. package/dist/middlewareWithAdminSession-j70iKbBX.cjs +2 -0
  8. package/dist/{middlewareWithAdminSession-DDApoLkL.cjs.map → middlewareWithAdminSession-j70iKbBX.cjs.map} +1 -1
  9. package/dist/nhost-js/auth.cjs +1 -1
  10. package/dist/nhost-js/auth.cjs.map +1 -1
  11. package/dist/nhost-js/auth.js +29 -1276
  12. package/dist/nhost-js/auth.js.map +1 -1
  13. package/dist/nhost-js/fetch.cjs +1 -1
  14. package/dist/nhost-js/fetch.js +1 -1
  15. package/dist/nhost-js/storage.cjs.map +1 -1
  16. package/dist/nhost-js/storage.js.map +1 -1
  17. package/dist/nhost-js.cjs +1 -1
  18. package/dist/nhost-js.cjs.map +1 -1
  19. package/dist/nhost-js.js +2 -2
  20. package/dist/nhost-js.umd.js +1 -1
  21. package/dist/nhost-js.umd.js.map +1 -1
  22. package/dist/src/auth/client.d.ts +125 -8
  23. package/dist/src/auth/client.d.ts.map +1 -1
  24. package/dist/src/auth/client.js +29 -0
  25. package/dist/src/auth/client.js.map +1 -1
  26. package/dist/src/auth/index.d.ts +1 -0
  27. package/dist/src/auth/index.d.ts.map +1 -1
  28. package/dist/src/auth/index.js +1 -0
  29. package/dist/src/auth/index.js.map +1 -1
  30. package/dist/src/auth/pkce.d.ts +22 -0
  31. package/dist/src/auth/pkce.d.ts.map +1 -0
  32. package/dist/src/auth/pkce.js +40 -0
  33. package/dist/src/auth/pkce.js.map +1 -0
  34. package/dist/src/fetch/middlewareUpdateSessionFromResponse.d.ts.map +1 -1
  35. package/dist/src/fetch/middlewareUpdateSessionFromResponse.js +1 -0
  36. package/dist/src/fetch/middlewareUpdateSessionFromResponse.js.map +1 -1
  37. package/dist/src/storage/client.d.ts +4 -4
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +3 -1
  40. package/dist/middlewareWithAdminSession-DDApoLkL.cjs +0 -2
@@ -1,1279 +1,32 @@
1
- import { c as createEnhancedFetch, F as FetchError } from "../fetch-2PHmQBIJ.js";
2
- const createAPIClient = (baseURL, chainFunctions = []) => {
3
- let fetch = createEnhancedFetch(chainFunctions);
4
- const pushChainFunction = (chainFunction) => {
5
- chainFunctions.push(chainFunction);
6
- fetch = createEnhancedFetch(chainFunctions);
7
- };
8
- const getJWKs = async (options) => {
9
- const url = `${baseURL}/.well-known/jwks.json`;
10
- const res = await fetch(url, {
11
- ...options,
12
- method: "GET",
13
- headers: {
14
- ...options?.headers
15
- }
16
- });
17
- if (res.status >= 300) {
18
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
19
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
20
- throw new FetchError(payload2, res.status, res.headers);
21
- }
22
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
23
- const payload = responseBody ? JSON.parse(responseBody) : {};
24
- return {
25
- body: payload,
26
- status: res.status,
27
- headers: res.headers
28
- };
29
- };
30
- const elevateWebauthn = async (options) => {
31
- const url = `${baseURL}/elevate/webauthn`;
32
- const res = await fetch(url, {
33
- ...options,
34
- method: "POST",
35
- headers: {
36
- ...options?.headers
37
- }
38
- });
39
- if (res.status >= 300) {
40
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
41
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
42
- throw new FetchError(payload2, res.status, res.headers);
43
- }
44
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
45
- const payload = responseBody ? JSON.parse(responseBody) : {};
46
- return {
47
- body: payload,
48
- status: res.status,
49
- headers: res.headers
50
- };
51
- };
52
- const verifyElevateWebauthn = async (body, options) => {
53
- const url = `${baseURL}/elevate/webauthn/verify`;
54
- const res = await fetch(url, {
55
- ...options,
56
- method: "POST",
57
- headers: {
58
- "Content-Type": "application/json",
59
- ...options?.headers
60
- },
61
- body: JSON.stringify(body)
62
- });
63
- if (res.status >= 300) {
64
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
65
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
66
- throw new FetchError(payload2, res.status, res.headers);
67
- }
68
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
69
- const payload = responseBody ? JSON.parse(responseBody) : {};
70
- return {
71
- body: payload,
72
- status: res.status,
73
- headers: res.headers
74
- };
75
- };
76
- const healthCheckGet = async (options) => {
77
- const url = `${baseURL}/healthz`;
78
- const res = await fetch(url, {
79
- ...options,
80
- method: "GET",
81
- headers: {
82
- ...options?.headers
83
- }
84
- });
85
- if (res.status >= 300) {
86
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
87
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
88
- throw new FetchError(payload2, res.status, res.headers);
89
- }
90
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
91
- const payload = responseBody ? JSON.parse(responseBody) : {};
92
- return {
93
- body: payload,
94
- status: res.status,
95
- headers: res.headers
96
- };
97
- };
98
- const healthCheckHead = async (options) => {
99
- const url = `${baseURL}/healthz`;
100
- const res = await fetch(url, {
101
- ...options,
102
- method: "HEAD",
103
- headers: {
104
- ...options?.headers
105
- }
106
- });
107
- if (res.status >= 300) {
108
- const responseBody = [412].includes(res.status) ? null : await res.text();
109
- const payload2 = responseBody ? JSON.parse(responseBody) : {};
110
- throw new FetchError(payload2, res.status, res.headers);
111
- }
112
- const payload = void 0;
113
- return {
114
- body: payload,
115
- status: res.status,
116
- headers: res.headers
117
- };
118
- };
119
- const linkIdToken = async (body, options) => {
120
- const url = `${baseURL}/link/idtoken`;
121
- const res = await fetch(url, {
122
- ...options,
123
- method: "POST",
124
- headers: {
125
- "Content-Type": "application/json",
126
- ...options?.headers
127
- },
128
- body: JSON.stringify(body)
129
- });
130
- if (res.status >= 300) {
131
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
132
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
133
- throw new FetchError(payload2, res.status, res.headers);
134
- }
135
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
136
- const payload = responseBody ? JSON.parse(responseBody) : {};
137
- return {
138
- body: payload,
139
- status: res.status,
140
- headers: res.headers
141
- };
142
- };
143
- const changeUserMfa = async (options) => {
144
- const url = `${baseURL}/mfa/totp/generate`;
145
- const res = await fetch(url, {
146
- ...options,
147
- method: "GET",
148
- headers: {
149
- ...options?.headers
150
- }
151
- });
152
- if (res.status >= 300) {
153
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
154
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
155
- throw new FetchError(payload2, res.status, res.headers);
156
- }
157
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
158
- const payload = responseBody ? JSON.parse(responseBody) : {};
159
- return {
160
- body: payload,
161
- status: res.status,
162
- headers: res.headers
163
- };
164
- };
165
- const createPAT = async (body, options) => {
166
- const url = `${baseURL}/pat`;
167
- const res = await fetch(url, {
168
- ...options,
169
- method: "POST",
170
- headers: {
171
- "Content-Type": "application/json",
172
- ...options?.headers
173
- },
174
- body: JSON.stringify(body)
175
- });
176
- if (res.status >= 300) {
177
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
178
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
179
- throw new FetchError(payload2, res.status, res.headers);
180
- }
181
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
182
- const payload = responseBody ? JSON.parse(responseBody) : {};
183
- return {
184
- body: payload,
185
- status: res.status,
186
- headers: res.headers
187
- };
188
- };
189
- const signInAnonymous = async (body, options) => {
190
- const url = `${baseURL}/signin/anonymous`;
191
- const res = await fetch(url, {
192
- ...options,
193
- method: "POST",
194
- headers: {
195
- "Content-Type": "application/json",
196
- ...options?.headers
197
- },
198
- body: JSON.stringify(body)
199
- });
200
- if (res.status >= 300) {
201
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
202
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
203
- throw new FetchError(payload2, res.status, res.headers);
204
- }
205
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
206
- const payload = responseBody ? JSON.parse(responseBody) : {};
207
- return {
208
- body: payload,
209
- status: res.status,
210
- headers: res.headers
211
- };
212
- };
213
- const signInEmailPassword = async (body, options) => {
214
- const url = `${baseURL}/signin/email-password`;
215
- const res = await fetch(url, {
216
- ...options,
217
- method: "POST",
218
- headers: {
219
- "Content-Type": "application/json",
220
- ...options?.headers
221
- },
222
- body: JSON.stringify(body)
223
- });
224
- if (res.status >= 300) {
225
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
226
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
227
- throw new FetchError(payload2, res.status, res.headers);
228
- }
229
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
230
- const payload = responseBody ? JSON.parse(responseBody) : {};
231
- return {
232
- body: payload,
233
- status: res.status,
234
- headers: res.headers
235
- };
236
- };
237
- const signInIdToken = async (body, options) => {
238
- const url = `${baseURL}/signin/idtoken`;
239
- const res = await fetch(url, {
240
- ...options,
241
- method: "POST",
242
- headers: {
243
- "Content-Type": "application/json",
244
- ...options?.headers
245
- },
246
- body: JSON.stringify(body)
247
- });
248
- if (res.status >= 300) {
249
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
250
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
251
- throw new FetchError(payload2, res.status, res.headers);
252
- }
253
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
254
- const payload = responseBody ? JSON.parse(responseBody) : {};
255
- return {
256
- body: payload,
257
- status: res.status,
258
- headers: res.headers
259
- };
260
- };
261
- const verifySignInMfaTotp = async (body, options) => {
262
- const url = `${baseURL}/signin/mfa/totp`;
263
- const res = await fetch(url, {
264
- ...options,
265
- method: "POST",
266
- headers: {
267
- "Content-Type": "application/json",
268
- ...options?.headers
269
- },
270
- body: JSON.stringify(body)
271
- });
272
- if (res.status >= 300) {
273
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
274
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
275
- throw new FetchError(payload2, res.status, res.headers);
276
- }
277
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
278
- const payload = responseBody ? JSON.parse(responseBody) : {};
279
- return {
280
- body: payload,
281
- status: res.status,
282
- headers: res.headers
283
- };
284
- };
285
- const signInOTPEmail = async (body, options) => {
286
- const url = `${baseURL}/signin/otp/email`;
287
- const res = await fetch(url, {
288
- ...options,
289
- method: "POST",
290
- headers: {
291
- "Content-Type": "application/json",
292
- ...options?.headers
293
- },
294
- body: JSON.stringify(body)
295
- });
296
- if (res.status >= 300) {
297
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
298
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
299
- throw new FetchError(payload2, res.status, res.headers);
300
- }
301
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
302
- const payload = responseBody ? JSON.parse(responseBody) : {};
303
- return {
304
- body: payload,
305
- status: res.status,
306
- headers: res.headers
307
- };
308
- };
309
- const verifySignInOTPEmail = async (body, options) => {
310
- const url = `${baseURL}/signin/otp/email/verify`;
311
- const res = await fetch(url, {
312
- ...options,
313
- method: "POST",
314
- headers: {
315
- "Content-Type": "application/json",
316
- ...options?.headers
317
- },
318
- body: JSON.stringify(body)
319
- });
320
- if (res.status >= 300) {
321
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
322
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
323
- throw new FetchError(payload2, res.status, res.headers);
324
- }
325
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
326
- const payload = responseBody ? JSON.parse(responseBody) : {};
327
- return {
328
- body: payload,
329
- status: res.status,
330
- headers: res.headers
331
- };
332
- };
333
- const signInPasswordlessEmail = async (body, options) => {
334
- const url = `${baseURL}/signin/passwordless/email`;
335
- const res = await fetch(url, {
336
- ...options,
337
- method: "POST",
338
- headers: {
339
- "Content-Type": "application/json",
340
- ...options?.headers
341
- },
342
- body: JSON.stringify(body)
343
- });
344
- if (res.status >= 300) {
345
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
346
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
347
- throw new FetchError(payload2, res.status, res.headers);
348
- }
349
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
350
- const payload = responseBody ? JSON.parse(responseBody) : {};
351
- return {
352
- body: payload,
353
- status: res.status,
354
- headers: res.headers
355
- };
356
- };
357
- const signInPasswordlessSms = async (body, options) => {
358
- const url = `${baseURL}/signin/passwordless/sms`;
359
- const res = await fetch(url, {
360
- ...options,
361
- method: "POST",
362
- headers: {
363
- "Content-Type": "application/json",
364
- ...options?.headers
365
- },
366
- body: JSON.stringify(body)
367
- });
368
- if (res.status >= 300) {
369
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
370
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
371
- throw new FetchError(payload2, res.status, res.headers);
372
- }
373
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
374
- const payload = responseBody ? JSON.parse(responseBody) : {};
375
- return {
376
- body: payload,
377
- status: res.status,
378
- headers: res.headers
379
- };
380
- };
381
- const verifySignInPasswordlessSms = async (body, options) => {
382
- const url = `${baseURL}/signin/passwordless/sms/otp`;
383
- const res = await fetch(url, {
384
- ...options,
385
- method: "POST",
386
- headers: {
387
- "Content-Type": "application/json",
388
- ...options?.headers
389
- },
390
- body: JSON.stringify(body)
391
- });
392
- if (res.status >= 300) {
393
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
394
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
395
- throw new FetchError(payload2, res.status, res.headers);
396
- }
397
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
398
- const payload = responseBody ? JSON.parse(responseBody) : {};
399
- return {
400
- body: payload,
401
- status: res.status,
402
- headers: res.headers
403
- };
404
- };
405
- const signInPAT = async (body, options) => {
406
- const url = `${baseURL}/signin/pat`;
407
- const res = await fetch(url, {
408
- ...options,
409
- method: "POST",
410
- headers: {
411
- "Content-Type": "application/json",
412
- ...options?.headers
413
- },
414
- body: JSON.stringify(body)
415
- });
416
- if (res.status >= 300) {
417
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
418
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
419
- throw new FetchError(payload2, res.status, res.headers);
420
- }
421
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
422
- const payload = responseBody ? JSON.parse(responseBody) : {};
423
- return {
424
- body: payload,
425
- status: res.status,
426
- headers: res.headers
427
- };
428
- };
429
- const signInProviderURL = (provider, params) => {
430
- const encodedParameters = params && Object.entries(params).flatMap(([key, value]) => {
431
- if (key === "providerSpecificParams") {
432
- if (typeof value === "object" && value !== null && !Array.isArray(value)) {
433
- return Object.entries(value).map(
434
- ([k, v]) => `${k}=${encodeURIComponent(String(v))}`
435
- );
436
- }
437
- return [`${key}=${encodeURIComponent(String(value))}`];
438
- }
439
- const stringValue = Array.isArray(value) ? value.join(",") : typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
440
- return [`${key}=${encodeURIComponent(stringValue)}`];
441
- }).join("&");
442
- const url = encodedParameters ? `${baseURL}/signin/provider/${provider}?${encodedParameters}` : `${baseURL}/signin/provider/${provider}`;
443
- return url;
444
- };
445
- const getProviderTokens = async (provider, options) => {
446
- const url = `${baseURL}/signin/provider/${provider}/callback/tokens`;
447
- const res = await fetch(url, {
448
- ...options,
449
- method: "GET",
450
- headers: {
451
- ...options?.headers
452
- }
453
- });
454
- if (res.status >= 300) {
455
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
456
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
457
- throw new FetchError(payload2, res.status, res.headers);
458
- }
459
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
460
- const payload = responseBody ? JSON.parse(responseBody) : {};
461
- return {
462
- body: payload,
463
- status: res.status,
464
- headers: res.headers
465
- };
466
- };
467
- const signInWebauthn = async (body, options) => {
468
- const url = `${baseURL}/signin/webauthn`;
469
- const res = await fetch(url, {
470
- ...options,
471
- method: "POST",
472
- headers: {
473
- "Content-Type": "application/json",
474
- ...options?.headers
475
- },
476
- body: JSON.stringify(body)
477
- });
478
- if (res.status >= 300) {
479
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
480
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
481
- throw new FetchError(payload2, res.status, res.headers);
482
- }
483
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
484
- const payload = responseBody ? JSON.parse(responseBody) : {};
485
- return {
486
- body: payload,
487
- status: res.status,
488
- headers: res.headers
489
- };
490
- };
491
- const verifySignInWebauthn = async (body, options) => {
492
- const url = `${baseURL}/signin/webauthn/verify`;
493
- const res = await fetch(url, {
494
- ...options,
495
- method: "POST",
496
- headers: {
497
- "Content-Type": "application/json",
498
- ...options?.headers
499
- },
500
- body: JSON.stringify(body)
501
- });
502
- if (res.status >= 300) {
503
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
504
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
505
- throw new FetchError(payload2, res.status, res.headers);
506
- }
507
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
508
- const payload = responseBody ? JSON.parse(responseBody) : {};
509
- return {
510
- body: payload,
511
- status: res.status,
512
- headers: res.headers
513
- };
514
- };
515
- const signOut = async (body, options) => {
516
- const url = `${baseURL}/signout`;
517
- const res = await fetch(url, {
518
- ...options,
519
- method: "POST",
520
- headers: {
521
- "Content-Type": "application/json",
522
- ...options?.headers
523
- },
524
- body: JSON.stringify(body)
525
- });
526
- if (res.status >= 300) {
527
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
528
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
529
- throw new FetchError(payload2, res.status, res.headers);
530
- }
531
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
532
- const payload = responseBody ? JSON.parse(responseBody) : {};
533
- return {
534
- body: payload,
535
- status: res.status,
536
- headers: res.headers
537
- };
538
- };
539
- const signUpEmailPassword = async (body, options) => {
540
- const url = `${baseURL}/signup/email-password`;
541
- const res = await fetch(url, {
542
- ...options,
543
- method: "POST",
544
- headers: {
545
- "Content-Type": "application/json",
546
- ...options?.headers
547
- },
548
- body: JSON.stringify(body)
549
- });
550
- if (res.status >= 300) {
551
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
552
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
553
- throw new FetchError(payload2, res.status, res.headers);
554
- }
555
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
556
- const payload = responseBody ? JSON.parse(responseBody) : {};
557
- return {
558
- body: payload,
559
- status: res.status,
560
- headers: res.headers
561
- };
562
- };
563
- const signUpWebauthn = async (body, options) => {
564
- const url = `${baseURL}/signup/webauthn`;
565
- const res = await fetch(url, {
566
- ...options,
567
- method: "POST",
568
- headers: {
569
- "Content-Type": "application/json",
570
- ...options?.headers
571
- },
572
- body: JSON.stringify(body)
573
- });
574
- if (res.status >= 300) {
575
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
576
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
577
- throw new FetchError(payload2, res.status, res.headers);
578
- }
579
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
580
- const payload = responseBody ? JSON.parse(responseBody) : {};
581
- return {
582
- body: payload,
583
- status: res.status,
584
- headers: res.headers
585
- };
586
- };
587
- const verifySignUpWebauthn = async (body, options) => {
588
- const url = `${baseURL}/signup/webauthn/verify`;
589
- const res = await fetch(url, {
590
- ...options,
591
- method: "POST",
592
- headers: {
593
- "Content-Type": "application/json",
594
- ...options?.headers
595
- },
596
- body: JSON.stringify(body)
597
- });
598
- if (res.status >= 300) {
599
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
600
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
601
- throw new FetchError(payload2, res.status, res.headers);
602
- }
603
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
604
- const payload = responseBody ? JSON.parse(responseBody) : {};
605
- return {
606
- body: payload,
607
- status: res.status,
608
- headers: res.headers
609
- };
610
- };
611
- const refreshToken = async (body, options) => {
612
- const url = `${baseURL}/token`;
613
- const res = await fetch(url, {
614
- ...options,
615
- method: "POST",
616
- headers: {
617
- "Content-Type": "application/json",
618
- ...options?.headers
619
- },
620
- body: JSON.stringify(body)
621
- });
622
- if (res.status >= 300) {
623
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
624
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
625
- throw new FetchError(payload2, res.status, res.headers);
626
- }
627
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
628
- const payload = responseBody ? JSON.parse(responseBody) : {};
629
- return {
630
- body: payload,
631
- status: res.status,
632
- headers: res.headers
633
- };
634
- };
635
- const refreshProviderToken = async (provider, body, options) => {
636
- const url = `${baseURL}/token/provider/${provider}`;
637
- const res = await fetch(url, {
638
- ...options,
639
- method: "POST",
640
- headers: {
641
- "Content-Type": "application/json",
642
- ...options?.headers
643
- },
644
- body: JSON.stringify(body)
645
- });
646
- if (res.status >= 300) {
647
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
648
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
649
- throw new FetchError(payload2, res.status, res.headers);
650
- }
651
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
652
- const payload = responseBody ? JSON.parse(responseBody) : {};
653
- return {
654
- body: payload,
655
- status: res.status,
656
- headers: res.headers
657
- };
658
- };
659
- const verifyToken = async (body, options) => {
660
- const url = `${baseURL}/token/verify`;
661
- const res = await fetch(url, {
662
- ...options,
663
- method: "POST",
664
- headers: {
665
- "Content-Type": "application/json",
666
- ...options?.headers
667
- },
668
- body: JSON.stringify(body)
669
- });
670
- if (res.status >= 300) {
671
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
672
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
673
- throw new FetchError(payload2, res.status, res.headers);
674
- }
675
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
676
- const payload = responseBody ? JSON.parse(responseBody) : {};
677
- return {
678
- body: payload,
679
- status: res.status,
680
- headers: res.headers
681
- };
682
- };
683
- const getUser = async (options) => {
684
- const url = `${baseURL}/user`;
685
- const res = await fetch(url, {
686
- ...options,
687
- method: "GET",
688
- headers: {
689
- ...options?.headers
690
- }
691
- });
692
- if (res.status >= 300) {
693
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
694
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
695
- throw new FetchError(payload2, res.status, res.headers);
696
- }
697
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
698
- const payload = responseBody ? JSON.parse(responseBody) : {};
699
- return {
700
- body: payload,
701
- status: res.status,
702
- headers: res.headers
703
- };
704
- };
705
- const deanonymizeUser = async (body, options) => {
706
- const url = `${baseURL}/user/deanonymize`;
707
- const res = await fetch(url, {
708
- ...options,
709
- method: "POST",
710
- headers: {
711
- "Content-Type": "application/json",
712
- ...options?.headers
713
- },
714
- body: JSON.stringify(body)
715
- });
716
- if (res.status >= 300) {
717
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
718
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
719
- throw new FetchError(payload2, res.status, res.headers);
720
- }
721
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
722
- const payload = responseBody ? JSON.parse(responseBody) : {};
723
- return {
724
- body: payload,
725
- status: res.status,
726
- headers: res.headers
727
- };
728
- };
729
- const changeUserEmail = async (body, options) => {
730
- const url = `${baseURL}/user/email/change`;
731
- const res = await fetch(url, {
732
- ...options,
733
- method: "POST",
734
- headers: {
735
- "Content-Type": "application/json",
736
- ...options?.headers
737
- },
738
- body: JSON.stringify(body)
739
- });
740
- if (res.status >= 300) {
741
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
742
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
743
- throw new FetchError(payload2, res.status, res.headers);
744
- }
745
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
746
- const payload = responseBody ? JSON.parse(responseBody) : {};
747
- return {
748
- body: payload,
749
- status: res.status,
750
- headers: res.headers
751
- };
752
- };
753
- const sendVerificationEmail = async (body, options) => {
754
- const url = `${baseURL}/user/email/send-verification-email`;
755
- const res = await fetch(url, {
756
- ...options,
757
- method: "POST",
758
- headers: {
759
- "Content-Type": "application/json",
760
- ...options?.headers
761
- },
762
- body: JSON.stringify(body)
763
- });
764
- if (res.status >= 300) {
765
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
766
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
767
- throw new FetchError(payload2, res.status, res.headers);
768
- }
769
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
770
- const payload = responseBody ? JSON.parse(responseBody) : {};
771
- return {
772
- body: payload,
773
- status: res.status,
774
- headers: res.headers
775
- };
776
- };
777
- const verifyChangeUserMfa = async (body, options) => {
778
- const url = `${baseURL}/user/mfa`;
779
- const res = await fetch(url, {
780
- ...options,
781
- method: "POST",
782
- headers: {
783
- "Content-Type": "application/json",
784
- ...options?.headers
785
- },
786
- body: JSON.stringify(body)
787
- });
788
- if (res.status >= 300) {
789
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
790
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
791
- throw new FetchError(payload2, res.status, res.headers);
792
- }
793
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
794
- const payload = responseBody ? JSON.parse(responseBody) : {};
795
- return {
796
- body: payload,
797
- status: res.status,
798
- headers: res.headers
799
- };
800
- };
801
- const changeUserPassword = async (body, options) => {
802
- const url = `${baseURL}/user/password`;
803
- const res = await fetch(url, {
804
- ...options,
805
- method: "POST",
806
- headers: {
807
- "Content-Type": "application/json",
808
- ...options?.headers
809
- },
810
- body: JSON.stringify(body)
811
- });
812
- if (res.status >= 300) {
813
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
814
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
815
- throw new FetchError(payload2, res.status, res.headers);
816
- }
817
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
818
- const payload = responseBody ? JSON.parse(responseBody) : {};
819
- return {
820
- body: payload,
821
- status: res.status,
822
- headers: res.headers
823
- };
824
- };
825
- const sendPasswordResetEmail = async (body, options) => {
826
- const url = `${baseURL}/user/password/reset`;
827
- const res = await fetch(url, {
828
- ...options,
829
- method: "POST",
830
- headers: {
831
- "Content-Type": "application/json",
832
- ...options?.headers
833
- },
834
- body: JSON.stringify(body)
835
- });
836
- if (res.status >= 300) {
837
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
838
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
839
- throw new FetchError(payload2, res.status, res.headers);
840
- }
841
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
842
- const payload = responseBody ? JSON.parse(responseBody) : {};
843
- return {
844
- body: payload,
845
- status: res.status,
846
- headers: res.headers
847
- };
848
- };
849
- const addSecurityKey = async (options) => {
850
- const url = `${baseURL}/user/webauthn/add`;
851
- const res = await fetch(url, {
852
- ...options,
853
- method: "POST",
854
- headers: {
855
- ...options?.headers
856
- }
857
- });
858
- if (res.status >= 300) {
859
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
860
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
861
- throw new FetchError(payload2, res.status, res.headers);
862
- }
863
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
864
- const payload = responseBody ? JSON.parse(responseBody) : {};
865
- return {
866
- body: payload,
867
- status: res.status,
868
- headers: res.headers
869
- };
870
- };
871
- const verifyAddSecurityKey = async (body, options) => {
872
- const url = `${baseURL}/user/webauthn/verify`;
873
- const res = await fetch(url, {
874
- ...options,
875
- method: "POST",
876
- headers: {
877
- "Content-Type": "application/json",
878
- ...options?.headers
879
- },
880
- body: JSON.stringify(body)
881
- });
882
- if (res.status >= 300) {
883
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
884
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
885
- throw new FetchError(payload2, res.status, res.headers);
886
- }
887
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
888
- const payload = responseBody ? JSON.parse(responseBody) : {};
889
- return {
890
- body: payload,
891
- status: res.status,
892
- headers: res.headers
893
- };
894
- };
895
- const verifyTicketURL = (params) => {
896
- const encodedParameters = params && Object.entries(params).flatMap(([key, value]) => {
897
- const stringValue = Array.isArray(value) ? value.join(",") : typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
898
- return [`${key}=${encodeURIComponent(stringValue)}`];
899
- }).join("&");
900
- const url = encodedParameters ? `${baseURL}/verify?${encodedParameters}` : `${baseURL}/verify`;
901
- return url;
902
- };
903
- const getVersion = async (options) => {
904
- const url = `${baseURL}/version`;
905
- const res = await fetch(url, {
906
- ...options,
907
- method: "GET",
908
- headers: {
909
- ...options?.headers
910
- }
911
- });
912
- if (res.status >= 300) {
913
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
914
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
915
- throw new FetchError(payload2, res.status, res.headers);
916
- }
917
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
918
- const payload = responseBody ? JSON.parse(responseBody) : {};
919
- return {
920
- body: payload,
921
- status: res.status,
922
- headers: res.headers
923
- };
924
- };
925
- const getOpenIDConfiguration = async (options) => {
926
- const url = `${baseURL}/.well-known/openid-configuration`;
927
- const res = await fetch(url, {
928
- ...options,
929
- method: "GET",
930
- headers: {
931
- ...options?.headers
932
- }
933
- });
934
- if (res.status >= 300) {
935
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
936
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
937
- throw new FetchError(payload2, res.status, res.headers);
938
- }
939
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
940
- const payload = responseBody ? JSON.parse(responseBody) : {};
941
- return {
942
- body: payload,
943
- status: res.status,
944
- headers: res.headers
945
- };
946
- };
947
- const getOAuthAuthorizationServer = async (options) => {
948
- const url = `${baseURL}/.well-known/oauth-authorization-server`;
949
- const res = await fetch(url, {
950
- ...options,
951
- method: "GET",
952
- headers: {
953
- ...options?.headers
954
- }
955
- });
956
- if (res.status >= 300) {
957
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
958
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
959
- throw new FetchError(payload2, res.status, res.headers);
960
- }
961
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
962
- const payload = responseBody ? JSON.parse(responseBody) : {};
963
- return {
964
- body: payload,
965
- status: res.status,
966
- headers: res.headers
967
- };
968
- };
969
- const oauth2AuthorizeURL = (params) => {
970
- const encodedParameters = params && Object.entries(params).flatMap(([key, value]) => {
971
- const stringValue = Array.isArray(value) ? value.join(",") : typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
972
- return [`${key}=${encodeURIComponent(stringValue)}`];
973
- }).join("&");
974
- const url = encodedParameters ? `${baseURL}/oauth2/authorize?${encodedParameters}` : `${baseURL}/oauth2/authorize`;
975
- return url;
976
- };
977
- const oauth2AuthorizePostURL = () => {
978
- const url = `${baseURL}/oauth2/authorize`;
979
- return url;
980
- };
981
- const oauth2Token = async (body, options) => {
982
- const url = `${baseURL}/oauth2/token`;
983
- const params = new URLSearchParams();
984
- if (body["grant_type"] !== void 0) {
985
- params.append("grant_type", String(body["grant_type"]));
986
- }
987
- if (body["code"] !== void 0) {
988
- params.append("code", String(body["code"]));
989
- }
990
- if (body["redirect_uri"] !== void 0) {
991
- params.append("redirect_uri", String(body["redirect_uri"]));
992
- }
993
- if (body["client_id"] !== void 0) {
994
- params.append("client_id", String(body["client_id"]));
995
- }
996
- if (body["client_secret"] !== void 0) {
997
- params.append("client_secret", String(body["client_secret"]));
998
- }
999
- if (body["code_verifier"] !== void 0) {
1000
- params.append("code_verifier", String(body["code_verifier"]));
1001
- }
1002
- if (body["refresh_token"] !== void 0) {
1003
- params.append("refresh_token", String(body["refresh_token"]));
1004
- }
1005
- if (body["resource"] !== void 0) {
1006
- params.append("resource", String(body["resource"]));
1007
- }
1008
- const res = await fetch(url, {
1009
- ...options,
1010
- method: "POST",
1011
- headers: {
1012
- "Content-Type": "application/x-www-form-urlencoded",
1013
- ...options?.headers
1014
- },
1015
- body: params.toString()
1016
- });
1017
- if (res.status >= 300) {
1018
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
1019
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
1020
- throw new FetchError(payload2, res.status, res.headers);
1021
- }
1022
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
1023
- const payload = responseBody ? JSON.parse(responseBody) : {};
1024
- return {
1025
- body: payload,
1026
- status: res.status,
1027
- headers: res.headers
1028
- };
1029
- };
1030
- const oauth2UserinfoGet = async (options) => {
1031
- const url = `${baseURL}/oauth2/userinfo`;
1032
- const res = await fetch(url, {
1033
- ...options,
1034
- method: "GET",
1035
- headers: {
1036
- ...options?.headers
1037
- }
1038
- });
1039
- if (res.status >= 300) {
1040
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
1041
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
1042
- throw new FetchError(payload2, res.status, res.headers);
1043
- }
1044
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
1045
- const payload = responseBody ? JSON.parse(responseBody) : {};
1046
- return {
1047
- body: payload,
1048
- status: res.status,
1049
- headers: res.headers
1050
- };
1051
- };
1052
- const oauth2UserinfoPost = async (options) => {
1053
- const url = `${baseURL}/oauth2/userinfo`;
1054
- const res = await fetch(url, {
1055
- ...options,
1056
- method: "POST",
1057
- headers: {
1058
- ...options?.headers
1059
- }
1060
- });
1061
- if (res.status >= 300) {
1062
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
1063
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
1064
- throw new FetchError(payload2, res.status, res.headers);
1065
- }
1066
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
1067
- const payload = responseBody ? JSON.parse(responseBody) : {};
1068
- return {
1069
- body: payload,
1070
- status: res.status,
1071
- headers: res.headers
1072
- };
1073
- };
1074
- const oauth2Jwks = async (options) => {
1075
- const url = `${baseURL}/oauth2/jwks`;
1076
- const res = await fetch(url, {
1077
- ...options,
1078
- method: "GET",
1079
- headers: {
1080
- ...options?.headers
1081
- }
1082
- });
1083
- if (res.status >= 300) {
1084
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
1085
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
1086
- throw new FetchError(payload2, res.status, res.headers);
1087
- }
1088
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
1089
- const payload = responseBody ? JSON.parse(responseBody) : {};
1090
- return {
1091
- body: payload,
1092
- status: res.status,
1093
- headers: res.headers
1094
- };
1095
- };
1096
- const oauth2Revoke = async (body, options) => {
1097
- const url = `${baseURL}/oauth2/revoke`;
1098
- const params = new URLSearchParams();
1099
- if (body["token"] !== void 0) {
1100
- params.append("token", String(body["token"]));
1101
- }
1102
- if (body["token_type_hint"] !== void 0) {
1103
- params.append("token_type_hint", String(body["token_type_hint"]));
1104
- }
1105
- if (body["client_id"] !== void 0) {
1106
- params.append("client_id", String(body["client_id"]));
1107
- }
1108
- if (body["client_secret"] !== void 0) {
1109
- params.append("client_secret", String(body["client_secret"]));
1110
- }
1111
- const res = await fetch(url, {
1112
- ...options,
1113
- method: "POST",
1114
- headers: {
1115
- "Content-Type": "application/x-www-form-urlencoded",
1116
- ...options?.headers
1117
- },
1118
- body: params.toString()
1119
- });
1120
- if (res.status >= 300) {
1121
- const responseBody = [412].includes(res.status) ? null : await res.text();
1122
- const payload2 = responseBody ? JSON.parse(responseBody) : {};
1123
- throw new FetchError(payload2, res.status, res.headers);
1124
- }
1125
- const payload = void 0;
1126
- return {
1127
- body: payload,
1128
- status: res.status,
1129
- headers: res.headers
1130
- };
1131
- };
1132
- const oauth2Introspect = async (body, options) => {
1133
- const url = `${baseURL}/oauth2/introspect`;
1134
- const params = new URLSearchParams();
1135
- if (body["token"] !== void 0) {
1136
- params.append("token", String(body["token"]));
1137
- }
1138
- if (body["token_type_hint"] !== void 0) {
1139
- params.append("token_type_hint", String(body["token_type_hint"]));
1140
- }
1141
- if (body["client_id"] !== void 0) {
1142
- params.append("client_id", String(body["client_id"]));
1143
- }
1144
- if (body["client_secret"] !== void 0) {
1145
- params.append("client_secret", String(body["client_secret"]));
1146
- }
1147
- const res = await fetch(url, {
1148
- ...options,
1149
- method: "POST",
1150
- headers: {
1151
- "Content-Type": "application/x-www-form-urlencoded",
1152
- ...options?.headers
1153
- },
1154
- body: params.toString()
1155
- });
1156
- if (res.status >= 300) {
1157
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
1158
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
1159
- throw new FetchError(payload2, res.status, res.headers);
1160
- }
1161
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
1162
- const payload = responseBody ? JSON.parse(responseBody) : {};
1163
- return {
1164
- body: payload,
1165
- status: res.status,
1166
- headers: res.headers
1167
- };
1168
- };
1169
- const oauth2LoginGet = async (params, options) => {
1170
- const encodedParameters = params && Object.entries(params).flatMap(([key, value]) => {
1171
- const stringValue = Array.isArray(value) ? value.join(",") : typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
1172
- return [`${key}=${encodeURIComponent(stringValue)}`];
1173
- }).join("&");
1174
- const url = encodedParameters ? `${baseURL}/oauth2/login?${encodedParameters}` : `${baseURL}/oauth2/login`;
1175
- const res = await fetch(url, {
1176
- ...options,
1177
- method: "GET",
1178
- headers: {
1179
- ...options?.headers
1180
- }
1181
- });
1182
- if (res.status >= 300) {
1183
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
1184
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
1185
- throw new FetchError(payload2, res.status, res.headers);
1186
- }
1187
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
1188
- const payload = responseBody ? JSON.parse(responseBody) : {};
1189
- return {
1190
- body: payload,
1191
- status: res.status,
1192
- headers: res.headers
1193
- };
1194
- };
1195
- const oauth2LoginPost = async (body, options) => {
1196
- const url = `${baseURL}/oauth2/login`;
1197
- const res = await fetch(url, {
1198
- ...options,
1199
- method: "POST",
1200
- headers: {
1201
- "Content-Type": "application/json",
1202
- ...options?.headers
1203
- },
1204
- body: JSON.stringify(body)
1205
- });
1206
- if (res.status >= 300) {
1207
- const responseBody2 = [412].includes(res.status) ? null : await res.text();
1208
- const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
1209
- throw new FetchError(payload2, res.status, res.headers);
1210
- }
1211
- const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
1212
- const payload = responseBody ? JSON.parse(responseBody) : {};
1213
- return {
1214
- body: payload,
1215
- status: res.status,
1216
- headers: res.headers
1217
- };
1218
- };
1219
- return {
1220
- baseURL,
1221
- pushChainFunction,
1222
- getJWKs,
1223
- elevateWebauthn,
1224
- verifyElevateWebauthn,
1225
- healthCheckGet,
1226
- healthCheckHead,
1227
- linkIdToken,
1228
- changeUserMfa,
1229
- createPAT,
1230
- signInAnonymous,
1231
- signInEmailPassword,
1232
- signInIdToken,
1233
- verifySignInMfaTotp,
1234
- signInOTPEmail,
1235
- verifySignInOTPEmail,
1236
- signInPasswordlessEmail,
1237
- signInPasswordlessSms,
1238
- verifySignInPasswordlessSms,
1239
- signInPAT,
1240
- signInProviderURL,
1241
- getProviderTokens,
1242
- signInWebauthn,
1243
- verifySignInWebauthn,
1244
- signOut,
1245
- signUpEmailPassword,
1246
- signUpWebauthn,
1247
- verifySignUpWebauthn,
1248
- refreshToken,
1249
- refreshProviderToken,
1250
- verifyToken,
1251
- getUser,
1252
- deanonymizeUser,
1253
- changeUserEmail,
1254
- sendVerificationEmail,
1255
- verifyChangeUserMfa,
1256
- changeUserPassword,
1257
- sendPasswordResetEmail,
1258
- addSecurityKey,
1259
- verifyAddSecurityKey,
1260
- verifyTicketURL,
1261
- getVersion,
1262
- getOpenIDConfiguration,
1263
- getOAuthAuthorizationServer,
1264
- oauth2AuthorizeURL,
1265
- oauth2AuthorizePostURL,
1266
- oauth2Token,
1267
- oauth2UserinfoGet,
1268
- oauth2UserinfoPost,
1269
- oauth2Jwks,
1270
- oauth2Revoke,
1271
- oauth2Introspect,
1272
- oauth2LoginGet,
1273
- oauth2LoginPost
1274
- };
1275
- };
1
+ import { c } from "../client-BOrTAJrs.js";
2
+ function bufferToBase64url(buf) {
3
+ let binary = "";
4
+ for (const byte of buf) {
5
+ binary += String.fromCharCode(byte);
6
+ }
7
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
8
+ }
9
+ function generateCodeVerifier() {
10
+ const buf = new Uint8Array(32);
11
+ crypto.getRandomValues(buf);
12
+ return bufferToBase64url(buf);
13
+ }
14
+ async function generateCodeChallenge(verifier) {
15
+ const hash = await crypto.subtle.digest(
16
+ "SHA-256",
17
+ new TextEncoder().encode(verifier)
18
+ );
19
+ return bufferToBase64url(new Uint8Array(hash));
20
+ }
21
+ async function generatePKCEPair() {
22
+ const verifier = generateCodeVerifier();
23
+ const challenge = await generateCodeChallenge(verifier);
24
+ return { verifier, challenge };
25
+ }
1276
26
  export {
1277
- createAPIClient
27
+ c as createAPIClient,
28
+ generateCodeChallenge,
29
+ generateCodeVerifier,
30
+ generatePKCEPair
1278
31
  };
1279
32
  //# sourceMappingURL=auth.js.map