@nhost/nhost-js 4.4.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.
- package/dist/client-BL0edWHv.cjs +2 -0
- package/dist/client-BL0edWHv.cjs.map +1 -0
- package/dist/client-BOrTAJrs.js +1304 -0
- package/dist/client-BOrTAJrs.js.map +1 -0
- package/dist/{middlewareWithAdminSession-BeIk-9HO.js → middlewareWithAdminSession-CcuYKs5Y.js} +2 -2
- package/dist/{middlewareWithAdminSession-BeIk-9HO.js.map → middlewareWithAdminSession-CcuYKs5Y.js.map} +1 -1
- package/dist/middlewareWithAdminSession-j70iKbBX.cjs +2 -0
- package/dist/{middlewareWithAdminSession-DDApoLkL.cjs.map → middlewareWithAdminSession-j70iKbBX.cjs.map} +1 -1
- package/dist/nhost-js/auth.cjs +1 -1
- package/dist/nhost-js/auth.cjs.map +1 -1
- package/dist/nhost-js/auth.js +29 -970
- package/dist/nhost-js/auth.js.map +1 -1
- package/dist/nhost-js/fetch.cjs +1 -1
- package/dist/nhost-js/fetch.js +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 +1 -1
- package/dist/nhost-js.cjs.map +1 -1
- package/dist/nhost-js.js +2 -2
- package/dist/nhost-js.umd.js +1 -1
- package/dist/nhost-js.umd.js.map +1 -1
- package/dist/src/auth/client.d.ts +753 -8
- package/dist/src/auth/client.d.ts.map +1 -1
- package/dist/src/auth/client.js +391 -0
- package/dist/src/auth/client.js.map +1 -1
- package/dist/src/auth/index.d.ts +1 -0
- package/dist/src/auth/index.d.ts.map +1 -1
- package/dist/src/auth/index.js +1 -0
- package/dist/src/auth/index.js.map +1 -1
- package/dist/src/auth/pkce.d.ts +22 -0
- package/dist/src/auth/pkce.d.ts.map +1 -0
- package/dist/src/auth/pkce.js +40 -0
- package/dist/src/auth/pkce.js.map +1 -0
- package/dist/src/fetch/middlewareUpdateSessionFromResponse.d.ts.map +1 -1
- package/dist/src/fetch/middlewareUpdateSessionFromResponse.js +1 -0
- package/dist/src/fetch/middlewareUpdateSessionFromResponse.js.map +1 -1
- package/dist/src/storage/client.d.ts +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/dist/middlewareWithAdminSession-DDApoLkL.cjs +0 -2
package/dist/nhost-js/auth.js
CHANGED
|
@@ -1,973 +1,32 @@
|
|
|
1
|
-
import { c
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
return {
|
|
926
|
-
baseURL,
|
|
927
|
-
pushChainFunction,
|
|
928
|
-
getJWKs,
|
|
929
|
-
elevateWebauthn,
|
|
930
|
-
verifyElevateWebauthn,
|
|
931
|
-
healthCheckGet,
|
|
932
|
-
healthCheckHead,
|
|
933
|
-
linkIdToken,
|
|
934
|
-
changeUserMfa,
|
|
935
|
-
createPAT,
|
|
936
|
-
signInAnonymous,
|
|
937
|
-
signInEmailPassword,
|
|
938
|
-
signInIdToken,
|
|
939
|
-
verifySignInMfaTotp,
|
|
940
|
-
signInOTPEmail,
|
|
941
|
-
verifySignInOTPEmail,
|
|
942
|
-
signInPasswordlessEmail,
|
|
943
|
-
signInPasswordlessSms,
|
|
944
|
-
verifySignInPasswordlessSms,
|
|
945
|
-
signInPAT,
|
|
946
|
-
signInProviderURL,
|
|
947
|
-
getProviderTokens,
|
|
948
|
-
signInWebauthn,
|
|
949
|
-
verifySignInWebauthn,
|
|
950
|
-
signOut,
|
|
951
|
-
signUpEmailPassword,
|
|
952
|
-
signUpWebauthn,
|
|
953
|
-
verifySignUpWebauthn,
|
|
954
|
-
refreshToken,
|
|
955
|
-
refreshProviderToken,
|
|
956
|
-
verifyToken,
|
|
957
|
-
getUser,
|
|
958
|
-
deanonymizeUser,
|
|
959
|
-
changeUserEmail,
|
|
960
|
-
sendVerificationEmail,
|
|
961
|
-
verifyChangeUserMfa,
|
|
962
|
-
changeUserPassword,
|
|
963
|
-
sendPasswordResetEmail,
|
|
964
|
-
addSecurityKey,
|
|
965
|
-
verifyAddSecurityKey,
|
|
966
|
-
verifyTicketURL,
|
|
967
|
-
getVersion
|
|
968
|
-
};
|
|
969
|
-
};
|
|
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
|
+
}
|
|
970
26
|
export {
|
|
971
|
-
createAPIClient
|
|
27
|
+
c as createAPIClient,
|
|
28
|
+
generateCodeChallenge,
|
|
29
|
+
generateCodeVerifier,
|
|
30
|
+
generatePKCEPair
|
|
972
31
|
};
|
|
973
32
|
//# sourceMappingURL=auth.js.map
|