@nhost/nhost-js 4.2.2 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fetch-2PHmQBIJ.js.map +1 -1
- package/dist/fetch-DWXwEnoe.cjs.map +1 -1
- package/dist/{middlewareWithAdminSession-DLqDQUbW.js → middlewareWithAdminSession-BeIk-9HO.js} +2 -2
- package/dist/middlewareWithAdminSession-BeIk-9HO.js.map +1 -0
- package/dist/middlewareWithAdminSession-DDApoLkL.cjs.map +1 -1
- package/dist/nhost-js/auth.cjs.map +1 -1
- package/dist/nhost-js/auth.js.map +1 -1
- package/dist/nhost-js/fetch.cjs.map +1 -1
- package/dist/nhost-js/fetch.js +1 -1
- package/dist/nhost-js/fetch.js.map +1 -1
- package/dist/nhost-js/functions.cjs.map +1 -1
- package/dist/nhost-js/functions.js.map +1 -1
- package/dist/nhost-js/graphql.cjs.map +1 -1
- package/dist/nhost-js/graphql.js.map +1 -1
- package/dist/nhost-js/session.cjs.map +1 -1
- package/dist/nhost-js/session.js +1 -1
- package/dist/nhost-js/session.js.map +1 -1
- package/dist/nhost-js/storage.cjs.map +1 -1
- package/dist/nhost-js/storage.js.map +1 -1
- package/dist/nhost-js.cjs.map +1 -1
- package/dist/nhost-js.js +2 -2
- package/dist/nhost-js.js.map +1 -1
- package/dist/nhost-js.umd.js.map +1 -1
- package/dist/refreshSession-Bw715ZmX.cjs.map +1 -1
- package/dist/{refreshSession-CG8GIEun.js → refreshSession-WwGlzgtM.js} +2 -5
- package/dist/refreshSession-WwGlzgtM.js.map +1 -0
- package/dist/src/auth/client.d.ts +28 -28
- package/dist/src/auth/client.js +76 -76
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/fetch/fetch.js +20 -20
- package/dist/src/fetch/index.d.ts +7 -7
- package/dist/src/fetch/index.js +7 -7
- package/dist/src/fetch/middlewareAttachAccessToken.d.ts +2 -2
- package/dist/src/fetch/middlewareAttachAccessToken.js +2 -2
- package/dist/src/fetch/middlewareSessionRefresh.d.ts +3 -3
- package/dist/src/fetch/middlewareSessionRefresh.js +3 -3
- package/dist/src/fetch/middlewareUpdateSessionFromResponse.d.ts +2 -2
- package/dist/src/fetch/middlewareUpdateSessionFromResponse.js +8 -8
- package/dist/src/fetch/middlewareWithAdminSession.d.ts +1 -1
- package/dist/src/fetch/middlewareWithAdminSession.js +5 -5
- package/dist/src/fetch/middlewareWithHeaders.d.ts +1 -1
- package/dist/src/fetch/middlewareWithRole.d.ts +1 -1
- package/dist/src/fetch/middlewareWithRole.js +2 -2
- package/dist/src/functions/client.d.ts +1 -1
- package/dist/src/functions/client.js +6 -6
- package/dist/src/functions/index.d.ts +1 -1
- package/dist/src/functions/index.js +1 -1
- package/dist/src/graphql/client.d.ts +2 -2
- package/dist/src/graphql/client.js +6 -6
- package/dist/src/graphql/index.d.ts +1 -1
- package/dist/src/graphql/index.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/nhost.d.ts +6 -6
- package/dist/src/nhost.js +11 -11
- package/dist/src/session/index.d.ts +4 -4
- package/dist/src/session/index.js +3 -3
- package/dist/src/session/refreshSession.d.ts +3 -3
- package/dist/src/session/refreshSession.d.ts.map +1 -1
- package/dist/src/session/refreshSession.js +5 -7
- package/dist/src/session/refreshSession.js.map +1 -1
- package/dist/src/session/session.d.ts +2 -2
- package/dist/src/session/session.js +15 -15
- package/dist/src/session/storage.d.ts +3 -3
- package/dist/src/session/storage.js +4 -4
- package/dist/src/session/storageBackend.d.ts +2 -2
- package/dist/src/session/storageBackend.js +7 -7
- package/dist/src/storage/client.d.ts +5 -5
- package/dist/src/storage/client.js +44 -44
- package/dist/src/storage/index.d.ts +1 -1
- package/dist/src/storage/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/dist/middlewareWithAdminSession-DLqDQUbW.js.map +0 -1
- package/dist/refreshSession-CG8GIEun.js.map +0 -1
package/dist/src/auth/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file is auto-generated. Do not edit manually.
|
|
3
3
|
*/
|
|
4
|
-
import { createEnhancedFetch, FetchError } from
|
|
4
|
+
import { createEnhancedFetch, FetchError } from '../fetch';
|
|
5
5
|
export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
6
6
|
let fetch = createEnhancedFetch(chainFunctions);
|
|
7
7
|
const pushChainFunction = (chainFunction) => {
|
|
@@ -12,7 +12,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
12
12
|
const url = `${baseURL}/.well-known/jwks.json`;
|
|
13
13
|
const res = await fetch(url, {
|
|
14
14
|
...options,
|
|
15
|
-
method:
|
|
15
|
+
method: 'GET',
|
|
16
16
|
headers: {
|
|
17
17
|
...options?.headers,
|
|
18
18
|
},
|
|
@@ -36,7 +36,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
36
36
|
const url = `${baseURL}/elevate/webauthn`;
|
|
37
37
|
const res = await fetch(url, {
|
|
38
38
|
...options,
|
|
39
|
-
method:
|
|
39
|
+
method: 'POST',
|
|
40
40
|
headers: {
|
|
41
41
|
...options?.headers,
|
|
42
42
|
},
|
|
@@ -62,9 +62,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
62
62
|
const url = `${baseURL}/elevate/webauthn/verify`;
|
|
63
63
|
const res = await fetch(url, {
|
|
64
64
|
...options,
|
|
65
|
-
method:
|
|
65
|
+
method: 'POST',
|
|
66
66
|
headers: {
|
|
67
|
-
|
|
67
|
+
'Content-Type': 'application/json',
|
|
68
68
|
...options?.headers,
|
|
69
69
|
},
|
|
70
70
|
body: JSON.stringify(body),
|
|
@@ -90,7 +90,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
90
90
|
const url = `${baseURL}/healthz`;
|
|
91
91
|
const res = await fetch(url, {
|
|
92
92
|
...options,
|
|
93
|
-
method:
|
|
93
|
+
method: 'GET',
|
|
94
94
|
headers: {
|
|
95
95
|
...options?.headers,
|
|
96
96
|
},
|
|
@@ -114,7 +114,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
114
114
|
const url = `${baseURL}/healthz`;
|
|
115
115
|
const res = await fetch(url, {
|
|
116
116
|
...options,
|
|
117
|
-
method:
|
|
117
|
+
method: 'HEAD',
|
|
118
118
|
headers: {
|
|
119
119
|
...options?.headers,
|
|
120
120
|
},
|
|
@@ -135,9 +135,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
135
135
|
const url = `${baseURL}/link/idtoken`;
|
|
136
136
|
const res = await fetch(url, {
|
|
137
137
|
...options,
|
|
138
|
-
method:
|
|
138
|
+
method: 'POST',
|
|
139
139
|
headers: {
|
|
140
|
-
|
|
140
|
+
'Content-Type': 'application/json',
|
|
141
141
|
...options?.headers,
|
|
142
142
|
},
|
|
143
143
|
body: JSON.stringify(body),
|
|
@@ -161,7 +161,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
161
161
|
const url = `${baseURL}/mfa/totp/generate`;
|
|
162
162
|
const res = await fetch(url, {
|
|
163
163
|
...options,
|
|
164
|
-
method:
|
|
164
|
+
method: 'GET',
|
|
165
165
|
headers: {
|
|
166
166
|
...options?.headers,
|
|
167
167
|
},
|
|
@@ -187,9 +187,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
187
187
|
const url = `${baseURL}/pat`;
|
|
188
188
|
const res = await fetch(url, {
|
|
189
189
|
...options,
|
|
190
|
-
method:
|
|
190
|
+
method: 'POST',
|
|
191
191
|
headers: {
|
|
192
|
-
|
|
192
|
+
'Content-Type': 'application/json',
|
|
193
193
|
...options?.headers,
|
|
194
194
|
},
|
|
195
195
|
body: JSON.stringify(body),
|
|
@@ -215,9 +215,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
215
215
|
const url = `${baseURL}/signin/anonymous`;
|
|
216
216
|
const res = await fetch(url, {
|
|
217
217
|
...options,
|
|
218
|
-
method:
|
|
218
|
+
method: 'POST',
|
|
219
219
|
headers: {
|
|
220
|
-
|
|
220
|
+
'Content-Type': 'application/json',
|
|
221
221
|
...options?.headers,
|
|
222
222
|
},
|
|
223
223
|
body: JSON.stringify(body),
|
|
@@ -243,9 +243,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
243
243
|
const url = `${baseURL}/signin/email-password`;
|
|
244
244
|
const res = await fetch(url, {
|
|
245
245
|
...options,
|
|
246
|
-
method:
|
|
246
|
+
method: 'POST',
|
|
247
247
|
headers: {
|
|
248
|
-
|
|
248
|
+
'Content-Type': 'application/json',
|
|
249
249
|
...options?.headers,
|
|
250
250
|
},
|
|
251
251
|
body: JSON.stringify(body),
|
|
@@ -271,9 +271,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
271
271
|
const url = `${baseURL}/signin/idtoken`;
|
|
272
272
|
const res = await fetch(url, {
|
|
273
273
|
...options,
|
|
274
|
-
method:
|
|
274
|
+
method: 'POST',
|
|
275
275
|
headers: {
|
|
276
|
-
|
|
276
|
+
'Content-Type': 'application/json',
|
|
277
277
|
...options?.headers,
|
|
278
278
|
},
|
|
279
279
|
body: JSON.stringify(body),
|
|
@@ -299,9 +299,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
299
299
|
const url = `${baseURL}/signin/mfa/totp`;
|
|
300
300
|
const res = await fetch(url, {
|
|
301
301
|
...options,
|
|
302
|
-
method:
|
|
302
|
+
method: 'POST',
|
|
303
303
|
headers: {
|
|
304
|
-
|
|
304
|
+
'Content-Type': 'application/json',
|
|
305
305
|
...options?.headers,
|
|
306
306
|
},
|
|
307
307
|
body: JSON.stringify(body),
|
|
@@ -327,9 +327,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
327
327
|
const url = `${baseURL}/signin/otp/email`;
|
|
328
328
|
const res = await fetch(url, {
|
|
329
329
|
...options,
|
|
330
|
-
method:
|
|
330
|
+
method: 'POST',
|
|
331
331
|
headers: {
|
|
332
|
-
|
|
332
|
+
'Content-Type': 'application/json',
|
|
333
333
|
...options?.headers,
|
|
334
334
|
},
|
|
335
335
|
body: JSON.stringify(body),
|
|
@@ -353,9 +353,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
353
353
|
const url = `${baseURL}/signin/otp/email/verify`;
|
|
354
354
|
const res = await fetch(url, {
|
|
355
355
|
...options,
|
|
356
|
-
method:
|
|
356
|
+
method: 'POST',
|
|
357
357
|
headers: {
|
|
358
|
-
|
|
358
|
+
'Content-Type': 'application/json',
|
|
359
359
|
...options?.headers,
|
|
360
360
|
},
|
|
361
361
|
body: JSON.stringify(body),
|
|
@@ -381,9 +381,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
381
381
|
const url = `${baseURL}/signin/passwordless/email`;
|
|
382
382
|
const res = await fetch(url, {
|
|
383
383
|
...options,
|
|
384
|
-
method:
|
|
384
|
+
method: 'POST',
|
|
385
385
|
headers: {
|
|
386
|
-
|
|
386
|
+
'Content-Type': 'application/json',
|
|
387
387
|
...options?.headers,
|
|
388
388
|
},
|
|
389
389
|
body: JSON.stringify(body),
|
|
@@ -407,9 +407,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
407
407
|
const url = `${baseURL}/signin/passwordless/sms`;
|
|
408
408
|
const res = await fetch(url, {
|
|
409
409
|
...options,
|
|
410
|
-
method:
|
|
410
|
+
method: 'POST',
|
|
411
411
|
headers: {
|
|
412
|
-
|
|
412
|
+
'Content-Type': 'application/json',
|
|
413
413
|
...options?.headers,
|
|
414
414
|
},
|
|
415
415
|
body: JSON.stringify(body),
|
|
@@ -433,9 +433,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
433
433
|
const url = `${baseURL}/signin/passwordless/sms/otp`;
|
|
434
434
|
const res = await fetch(url, {
|
|
435
435
|
...options,
|
|
436
|
-
method:
|
|
436
|
+
method: 'POST',
|
|
437
437
|
headers: {
|
|
438
|
-
|
|
438
|
+
'Content-Type': 'application/json',
|
|
439
439
|
...options?.headers,
|
|
440
440
|
},
|
|
441
441
|
body: JSON.stringify(body),
|
|
@@ -461,9 +461,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
461
461
|
const url = `${baseURL}/signin/pat`;
|
|
462
462
|
const res = await fetch(url, {
|
|
463
463
|
...options,
|
|
464
|
-
method:
|
|
464
|
+
method: 'POST',
|
|
465
465
|
headers: {
|
|
466
|
-
|
|
466
|
+
'Content-Type': 'application/json',
|
|
467
467
|
...options?.headers,
|
|
468
468
|
},
|
|
469
469
|
body: JSON.stringify(body),
|
|
@@ -489,9 +489,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
489
489
|
const encodedParameters = params &&
|
|
490
490
|
Object.entries(params)
|
|
491
491
|
.flatMap(([key, value]) => {
|
|
492
|
-
if (key ===
|
|
492
|
+
if (key === 'providerSpecificParams') {
|
|
493
493
|
// Object with explode: true - each property as separate parameter
|
|
494
|
-
if (typeof value ===
|
|
494
|
+
if (typeof value === 'object' &&
|
|
495
495
|
value !== null &&
|
|
496
496
|
!Array.isArray(value)) {
|
|
497
497
|
return Object.entries(value).map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`);
|
|
@@ -500,13 +500,13 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
500
500
|
}
|
|
501
501
|
// Default handling (scalars or explode: false)
|
|
502
502
|
const stringValue = Array.isArray(value)
|
|
503
|
-
? value.join(
|
|
504
|
-
: typeof value ===
|
|
503
|
+
? value.join(',')
|
|
504
|
+
: typeof value === 'object' && value !== null
|
|
505
505
|
? JSON.stringify(value)
|
|
506
506
|
: String(value);
|
|
507
507
|
return [`${key}=${encodeURIComponent(stringValue)}`];
|
|
508
508
|
})
|
|
509
|
-
.join(
|
|
509
|
+
.join('&');
|
|
510
510
|
const url = encodedParameters
|
|
511
511
|
? `${baseURL}/signin/provider/${provider}?${encodedParameters}`
|
|
512
512
|
: `${baseURL}/signin/provider/${provider}`;
|
|
@@ -516,7 +516,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
516
516
|
const url = `${baseURL}/signin/provider/${provider}/callback/tokens`;
|
|
517
517
|
const res = await fetch(url, {
|
|
518
518
|
...options,
|
|
519
|
-
method:
|
|
519
|
+
method: 'GET',
|
|
520
520
|
headers: {
|
|
521
521
|
...options?.headers,
|
|
522
522
|
},
|
|
@@ -542,9 +542,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
542
542
|
const url = `${baseURL}/signin/webauthn`;
|
|
543
543
|
const res = await fetch(url, {
|
|
544
544
|
...options,
|
|
545
|
-
method:
|
|
545
|
+
method: 'POST',
|
|
546
546
|
headers: {
|
|
547
|
-
|
|
547
|
+
'Content-Type': 'application/json',
|
|
548
548
|
...options?.headers,
|
|
549
549
|
},
|
|
550
550
|
body: JSON.stringify(body),
|
|
@@ -570,9 +570,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
570
570
|
const url = `${baseURL}/signin/webauthn/verify`;
|
|
571
571
|
const res = await fetch(url, {
|
|
572
572
|
...options,
|
|
573
|
-
method:
|
|
573
|
+
method: 'POST',
|
|
574
574
|
headers: {
|
|
575
|
-
|
|
575
|
+
'Content-Type': 'application/json',
|
|
576
576
|
...options?.headers,
|
|
577
577
|
},
|
|
578
578
|
body: JSON.stringify(body),
|
|
@@ -598,9 +598,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
598
598
|
const url = `${baseURL}/signout`;
|
|
599
599
|
const res = await fetch(url, {
|
|
600
600
|
...options,
|
|
601
|
-
method:
|
|
601
|
+
method: 'POST',
|
|
602
602
|
headers: {
|
|
603
|
-
|
|
603
|
+
'Content-Type': 'application/json',
|
|
604
604
|
...options?.headers,
|
|
605
605
|
},
|
|
606
606
|
body: JSON.stringify(body),
|
|
@@ -624,9 +624,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
624
624
|
const url = `${baseURL}/signup/email-password`;
|
|
625
625
|
const res = await fetch(url, {
|
|
626
626
|
...options,
|
|
627
|
-
method:
|
|
627
|
+
method: 'POST',
|
|
628
628
|
headers: {
|
|
629
|
-
|
|
629
|
+
'Content-Type': 'application/json',
|
|
630
630
|
...options?.headers,
|
|
631
631
|
},
|
|
632
632
|
body: JSON.stringify(body),
|
|
@@ -652,9 +652,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
652
652
|
const url = `${baseURL}/signup/webauthn`;
|
|
653
653
|
const res = await fetch(url, {
|
|
654
654
|
...options,
|
|
655
|
-
method:
|
|
655
|
+
method: 'POST',
|
|
656
656
|
headers: {
|
|
657
|
-
|
|
657
|
+
'Content-Type': 'application/json',
|
|
658
658
|
...options?.headers,
|
|
659
659
|
},
|
|
660
660
|
body: JSON.stringify(body),
|
|
@@ -680,9 +680,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
680
680
|
const url = `${baseURL}/signup/webauthn/verify`;
|
|
681
681
|
const res = await fetch(url, {
|
|
682
682
|
...options,
|
|
683
|
-
method:
|
|
683
|
+
method: 'POST',
|
|
684
684
|
headers: {
|
|
685
|
-
|
|
685
|
+
'Content-Type': 'application/json',
|
|
686
686
|
...options?.headers,
|
|
687
687
|
},
|
|
688
688
|
body: JSON.stringify(body),
|
|
@@ -708,9 +708,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
708
708
|
const url = `${baseURL}/token`;
|
|
709
709
|
const res = await fetch(url, {
|
|
710
710
|
...options,
|
|
711
|
-
method:
|
|
711
|
+
method: 'POST',
|
|
712
712
|
headers: {
|
|
713
|
-
|
|
713
|
+
'Content-Type': 'application/json',
|
|
714
714
|
...options?.headers,
|
|
715
715
|
},
|
|
716
716
|
body: JSON.stringify(body),
|
|
@@ -734,9 +734,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
734
734
|
const url = `${baseURL}/token/provider/${provider}`;
|
|
735
735
|
const res = await fetch(url, {
|
|
736
736
|
...options,
|
|
737
|
-
method:
|
|
737
|
+
method: 'POST',
|
|
738
738
|
headers: {
|
|
739
|
-
|
|
739
|
+
'Content-Type': 'application/json',
|
|
740
740
|
...options?.headers,
|
|
741
741
|
},
|
|
742
742
|
body: JSON.stringify(body),
|
|
@@ -762,9 +762,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
762
762
|
const url = `${baseURL}/token/verify`;
|
|
763
763
|
const res = await fetch(url, {
|
|
764
764
|
...options,
|
|
765
|
-
method:
|
|
765
|
+
method: 'POST',
|
|
766
766
|
headers: {
|
|
767
|
-
|
|
767
|
+
'Content-Type': 'application/json',
|
|
768
768
|
...options?.headers,
|
|
769
769
|
},
|
|
770
770
|
body: JSON.stringify(body),
|
|
@@ -788,7 +788,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
788
788
|
const url = `${baseURL}/user`;
|
|
789
789
|
const res = await fetch(url, {
|
|
790
790
|
...options,
|
|
791
|
-
method:
|
|
791
|
+
method: 'GET',
|
|
792
792
|
headers: {
|
|
793
793
|
...options?.headers,
|
|
794
794
|
},
|
|
@@ -812,9 +812,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
812
812
|
const url = `${baseURL}/user/deanonymize`;
|
|
813
813
|
const res = await fetch(url, {
|
|
814
814
|
...options,
|
|
815
|
-
method:
|
|
815
|
+
method: 'POST',
|
|
816
816
|
headers: {
|
|
817
|
-
|
|
817
|
+
'Content-Type': 'application/json',
|
|
818
818
|
...options?.headers,
|
|
819
819
|
},
|
|
820
820
|
body: JSON.stringify(body),
|
|
@@ -838,9 +838,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
838
838
|
const url = `${baseURL}/user/email/change`;
|
|
839
839
|
const res = await fetch(url, {
|
|
840
840
|
...options,
|
|
841
|
-
method:
|
|
841
|
+
method: 'POST',
|
|
842
842
|
headers: {
|
|
843
|
-
|
|
843
|
+
'Content-Type': 'application/json',
|
|
844
844
|
...options?.headers,
|
|
845
845
|
},
|
|
846
846
|
body: JSON.stringify(body),
|
|
@@ -864,9 +864,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
864
864
|
const url = `${baseURL}/user/email/send-verification-email`;
|
|
865
865
|
const res = await fetch(url, {
|
|
866
866
|
...options,
|
|
867
|
-
method:
|
|
867
|
+
method: 'POST',
|
|
868
868
|
headers: {
|
|
869
|
-
|
|
869
|
+
'Content-Type': 'application/json',
|
|
870
870
|
...options?.headers,
|
|
871
871
|
},
|
|
872
872
|
body: JSON.stringify(body),
|
|
@@ -890,9 +890,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
890
890
|
const url = `${baseURL}/user/mfa`;
|
|
891
891
|
const res = await fetch(url, {
|
|
892
892
|
...options,
|
|
893
|
-
method:
|
|
893
|
+
method: 'POST',
|
|
894
894
|
headers: {
|
|
895
|
-
|
|
895
|
+
'Content-Type': 'application/json',
|
|
896
896
|
...options?.headers,
|
|
897
897
|
},
|
|
898
898
|
body: JSON.stringify(body),
|
|
@@ -916,9 +916,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
916
916
|
const url = `${baseURL}/user/password`;
|
|
917
917
|
const res = await fetch(url, {
|
|
918
918
|
...options,
|
|
919
|
-
method:
|
|
919
|
+
method: 'POST',
|
|
920
920
|
headers: {
|
|
921
|
-
|
|
921
|
+
'Content-Type': 'application/json',
|
|
922
922
|
...options?.headers,
|
|
923
923
|
},
|
|
924
924
|
body: JSON.stringify(body),
|
|
@@ -942,9 +942,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
942
942
|
const url = `${baseURL}/user/password/reset`;
|
|
943
943
|
const res = await fetch(url, {
|
|
944
944
|
...options,
|
|
945
|
-
method:
|
|
945
|
+
method: 'POST',
|
|
946
946
|
headers: {
|
|
947
|
-
|
|
947
|
+
'Content-Type': 'application/json',
|
|
948
948
|
...options?.headers,
|
|
949
949
|
},
|
|
950
950
|
body: JSON.stringify(body),
|
|
@@ -968,7 +968,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
968
968
|
const url = `${baseURL}/user/webauthn/add`;
|
|
969
969
|
const res = await fetch(url, {
|
|
970
970
|
...options,
|
|
971
|
-
method:
|
|
971
|
+
method: 'POST',
|
|
972
972
|
headers: {
|
|
973
973
|
...options?.headers,
|
|
974
974
|
},
|
|
@@ -994,9 +994,9 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
994
994
|
const url = `${baseURL}/user/webauthn/verify`;
|
|
995
995
|
const res = await fetch(url, {
|
|
996
996
|
...options,
|
|
997
|
-
method:
|
|
997
|
+
method: 'POST',
|
|
998
998
|
headers: {
|
|
999
|
-
|
|
999
|
+
'Content-Type': 'application/json',
|
|
1000
1000
|
...options?.headers,
|
|
1001
1001
|
},
|
|
1002
1002
|
body: JSON.stringify(body),
|
|
@@ -1024,13 +1024,13 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
1024
1024
|
.flatMap(([key, value]) => {
|
|
1025
1025
|
// Default handling (scalars or explode: false)
|
|
1026
1026
|
const stringValue = Array.isArray(value)
|
|
1027
|
-
? value.join(
|
|
1028
|
-
: typeof value ===
|
|
1027
|
+
? value.join(',')
|
|
1028
|
+
: typeof value === 'object' && value !== null
|
|
1029
1029
|
? JSON.stringify(value)
|
|
1030
1030
|
: String(value);
|
|
1031
1031
|
return [`${key}=${encodeURIComponent(stringValue)}`];
|
|
1032
1032
|
})
|
|
1033
|
-
.join(
|
|
1033
|
+
.join('&');
|
|
1034
1034
|
const url = encodedParameters
|
|
1035
1035
|
? `${baseURL}/verify?${encodedParameters}`
|
|
1036
1036
|
: `${baseURL}/verify`;
|
|
@@ -1040,7 +1040,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
|
|
|
1040
1040
|
const url = `${baseURL}/version`;
|
|
1041
1041
|
const res = await fetch(url, {
|
|
1042
1042
|
...options,
|
|
1043
|
-
method:
|
|
1043
|
+
method: 'GET',
|
|
1044
1044
|
headers: {
|
|
1045
1045
|
...options?.headers,
|
|
1046
1046
|
},
|
package/dist/src/auth/index.d.ts
CHANGED
package/dist/src/auth/index.js
CHANGED
package/dist/src/fetch/fetch.js
CHANGED
|
@@ -31,38 +31,38 @@ export function createEnhancedFetch(chainFunctions = []) {
|
|
|
31
31
|
return chainFunctions.reduceRight((nextInChain, chainFunction) => chainFunction(nextInChain), fetch);
|
|
32
32
|
}
|
|
33
33
|
function extractMessage(body) {
|
|
34
|
-
if (body && typeof body ===
|
|
34
|
+
if (body && typeof body === 'string') {
|
|
35
35
|
return body;
|
|
36
36
|
}
|
|
37
|
-
if (body && typeof body ===
|
|
37
|
+
if (body && typeof body === 'object') {
|
|
38
38
|
const typedBody = body;
|
|
39
|
-
if (
|
|
40
|
-
return typedBody[
|
|
39
|
+
if ('message' in typedBody && typeof typedBody['message'] === 'string') {
|
|
40
|
+
return typedBody['message'];
|
|
41
41
|
}
|
|
42
|
-
if (
|
|
43
|
-
return typedBody[
|
|
42
|
+
if ('error' in typedBody && typeof typedBody['error'] === 'string') {
|
|
43
|
+
return typedBody['error'];
|
|
44
44
|
}
|
|
45
|
-
if (
|
|
46
|
-
typedBody[
|
|
47
|
-
typeof typedBody[
|
|
48
|
-
const error = typedBody[
|
|
49
|
-
if (
|
|
50
|
-
return error[
|
|
45
|
+
if ('error' in typedBody &&
|
|
46
|
+
typedBody['error'] &&
|
|
47
|
+
typeof typedBody['error'] === 'object') {
|
|
48
|
+
const error = typedBody['error'];
|
|
49
|
+
if ('message' in error && typeof error['message'] === 'string') {
|
|
50
|
+
return error['message'];
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
if (
|
|
54
|
-
const messages = typedBody[
|
|
55
|
-
.filter((error) => typeof error ===
|
|
53
|
+
if ('errors' in typedBody && Array.isArray(typedBody['errors'])) {
|
|
54
|
+
const messages = typedBody['errors']
|
|
55
|
+
.filter((error) => typeof error === 'object' &&
|
|
56
56
|
error !== null &&
|
|
57
|
-
|
|
58
|
-
typeof error[
|
|
59
|
-
.map((error) => error[
|
|
57
|
+
'message' in error &&
|
|
58
|
+
typeof error['message'] === 'string')
|
|
59
|
+
.map((error) => error['message']);
|
|
60
60
|
if (messages.length > 0) {
|
|
61
|
-
return messages.join(
|
|
61
|
+
return messages.join(', ');
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
return
|
|
65
|
+
return 'An unexpected error occurred';
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Error class for representing fetch operation failures.
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
* @module fetch
|
|
12
12
|
* @packageDocumentation
|
|
13
13
|
*/
|
|
14
|
-
export { type ChainFunction, createEnhancedFetch, FetchError, type FetchFunction, type FetchResponse, } from
|
|
14
|
+
export { type ChainFunction, createEnhancedFetch, FetchError, type FetchFunction, type FetchResponse, } from './fetch';
|
|
15
15
|
/**
|
|
16
16
|
* Middleware for attaching authorization tokens to outgoing requests.
|
|
17
17
|
*
|
|
18
18
|
* @param storage - Storage implementation for retrieving session data
|
|
19
19
|
* @returns A middleware function that adds Authorization headers
|
|
20
20
|
*/
|
|
21
|
-
export { attachAccessTokenMiddleware } from
|
|
21
|
+
export { attachAccessTokenMiddleware } from './middlewareAttachAccessToken';
|
|
22
22
|
/**
|
|
23
23
|
* Middleware for automatically refreshing authentication tokens when they're about to expire.
|
|
24
24
|
*
|
|
@@ -27,27 +27,27 @@ export { attachAccessTokenMiddleware } from "./middlewareAttachAccessToken";
|
|
|
27
27
|
* @param options - Configuration options for token refresh behavior
|
|
28
28
|
* @returns A middleware function that refreshes tokens as needed
|
|
29
29
|
*/
|
|
30
|
-
export { sessionRefreshMiddleware } from
|
|
30
|
+
export { sessionRefreshMiddleware } from './middlewareSessionRefresh';
|
|
31
31
|
/**
|
|
32
32
|
* Middleware for extracting and storing session data from authentication responses.
|
|
33
33
|
*
|
|
34
34
|
* @param storage - Storage implementation for persisting session data
|
|
35
35
|
* @returns A middleware function that updates session storage
|
|
36
36
|
*/
|
|
37
|
-
export { updateSessionFromResponseMiddleware } from
|
|
37
|
+
export { updateSessionFromResponseMiddleware } from './middlewareUpdateSessionFromResponse';
|
|
38
38
|
/**
|
|
39
39
|
* Middleware for attaching Hasura admin secret for elevated permissions.
|
|
40
40
|
*
|
|
41
41
|
* @param options - Admin session options including the admin secret
|
|
42
42
|
* @returns A middleware function that adds x-hasura-admin-secret header
|
|
43
43
|
*/
|
|
44
|
-
export { type AdminSessionOptions, withAdminSessionMiddleware, } from
|
|
45
|
-
export { withHeadersMiddleware } from
|
|
44
|
+
export { type AdminSessionOptions, withAdminSessionMiddleware, } from './middlewareWithAdminSession';
|
|
45
|
+
export { withHeadersMiddleware } from './middlewareWithHeaders';
|
|
46
46
|
/**
|
|
47
47
|
* Middleware for setting the Hasura role header for requests.
|
|
48
48
|
*
|
|
49
49
|
* @param role - The Hasura role to use for requests
|
|
50
50
|
* @returns A middleware function that adds x-hasura-role header
|
|
51
51
|
*/
|
|
52
|
-
export { withRoleMiddleware } from
|
|
52
|
+
export { withRoleMiddleware } from './middlewareWithRole';
|
|
53
53
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/fetch/index.js
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
* @module fetch
|
|
12
12
|
* @packageDocumentation
|
|
13
13
|
*/
|
|
14
|
-
export { createEnhancedFetch, FetchError, } from
|
|
14
|
+
export { createEnhancedFetch, FetchError, } from './fetch';
|
|
15
15
|
/**
|
|
16
16
|
* Middleware for attaching authorization tokens to outgoing requests.
|
|
17
17
|
*
|
|
18
18
|
* @param storage - Storage implementation for retrieving session data
|
|
19
19
|
* @returns A middleware function that adds Authorization headers
|
|
20
20
|
*/
|
|
21
|
-
export { attachAccessTokenMiddleware } from
|
|
21
|
+
export { attachAccessTokenMiddleware } from './middlewareAttachAccessToken';
|
|
22
22
|
/**
|
|
23
23
|
* Middleware for automatically refreshing authentication tokens when they're about to expire.
|
|
24
24
|
*
|
|
@@ -27,27 +27,27 @@ export { attachAccessTokenMiddleware } from "./middlewareAttachAccessToken";
|
|
|
27
27
|
* @param options - Configuration options for token refresh behavior
|
|
28
28
|
* @returns A middleware function that refreshes tokens as needed
|
|
29
29
|
*/
|
|
30
|
-
export { sessionRefreshMiddleware } from
|
|
30
|
+
export { sessionRefreshMiddleware } from './middlewareSessionRefresh';
|
|
31
31
|
/**
|
|
32
32
|
* Middleware for extracting and storing session data from authentication responses.
|
|
33
33
|
*
|
|
34
34
|
* @param storage - Storage implementation for persisting session data
|
|
35
35
|
* @returns A middleware function that updates session storage
|
|
36
36
|
*/
|
|
37
|
-
export { updateSessionFromResponseMiddleware } from
|
|
37
|
+
export { updateSessionFromResponseMiddleware } from './middlewareUpdateSessionFromResponse';
|
|
38
38
|
/**
|
|
39
39
|
* Middleware for attaching Hasura admin secret for elevated permissions.
|
|
40
40
|
*
|
|
41
41
|
* @param options - Admin session options including the admin secret
|
|
42
42
|
* @returns A middleware function that adds x-hasura-admin-secret header
|
|
43
43
|
*/
|
|
44
|
-
export { withAdminSessionMiddleware, } from
|
|
45
|
-
export { withHeadersMiddleware } from
|
|
44
|
+
export { withAdminSessionMiddleware, } from './middlewareWithAdminSession';
|
|
45
|
+
export { withHeadersMiddleware } from './middlewareWithHeaders';
|
|
46
46
|
/**
|
|
47
47
|
* Middleware for setting the Hasura role header for requests.
|
|
48
48
|
*
|
|
49
49
|
* @param role - The Hasura role to use for requests
|
|
50
50
|
* @returns A middleware function that adds x-hasura-role header
|
|
51
51
|
*/
|
|
52
|
-
export { withRoleMiddleware } from
|
|
52
|
+
export { withRoleMiddleware } from './middlewareWithRole';
|
|
53
53
|
//# sourceMappingURL=index.js.map
|