@nhost/nhost-js 3.3.1 → 4.0.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 (147) hide show
  1. package/README.md +68 -32
  2. package/dist/fetch-2PHmQBIJ.mjs +61 -0
  3. package/dist/fetch-2PHmQBIJ.mjs.map +1 -0
  4. package/dist/fetch-DWXwEnoe.js +2 -0
  5. package/dist/fetch-DWXwEnoe.js.map +1 -0
  6. package/dist/nhost-js/auth.cjs.js +2 -0
  7. package/dist/nhost-js/auth.cjs.js.map +1 -0
  8. package/dist/nhost-js/auth.es.js +917 -0
  9. package/dist/nhost-js/auth.es.js.map +1 -0
  10. package/dist/nhost-js/fetch.cjs.js +2 -0
  11. package/dist/nhost-js/fetch.cjs.js.map +1 -0
  12. package/dist/nhost-js/fetch.es.js +90 -0
  13. package/dist/nhost-js/fetch.es.js.map +1 -0
  14. package/dist/nhost-js/functions.cjs.js +2 -0
  15. package/dist/nhost-js/functions.cjs.js.map +1 -0
  16. package/dist/nhost-js/functions.es.js +45 -0
  17. package/dist/nhost-js/functions.es.js.map +1 -0
  18. package/dist/nhost-js/graphql.cjs.js +2 -0
  19. package/dist/nhost-js/graphql.cjs.js.map +1 -0
  20. package/dist/nhost-js/graphql.es.js +48 -0
  21. package/dist/nhost-js/graphql.es.js.map +1 -0
  22. package/dist/nhost-js/session.cjs.js +2 -0
  23. package/dist/nhost-js/session.cjs.js.map +1 -0
  24. package/dist/nhost-js/session.es.js +234 -0
  25. package/dist/nhost-js/session.es.js.map +1 -0
  26. package/dist/nhost-js/storage.cjs.js +2 -0
  27. package/dist/nhost-js/storage.cjs.js.map +1 -0
  28. package/dist/nhost-js/storage.es.js +324 -0
  29. package/dist/nhost-js/storage.es.js.map +1 -0
  30. package/dist/nhost-js.cjs.js +2 -0
  31. package/dist/nhost-js.cjs.js.map +1 -0
  32. package/dist/nhost-js.es.js +228 -0
  33. package/dist/nhost-js.es.js.map +1 -0
  34. package/dist/nhost-js.umd.js +2 -0
  35. package/dist/nhost-js.umd.js.map +1 -0
  36. package/dist/refreshSession-Bw715ZmX.js +2 -0
  37. package/dist/refreshSession-Bw715ZmX.js.map +1 -0
  38. package/dist/refreshSession-WwGlzgtM.mjs +95 -0
  39. package/dist/refreshSession-WwGlzgtM.mjs.map +1 -0
  40. package/dist/src/auth/client.d.ts +1763 -0
  41. package/dist/src/auth/client.d.ts.map +1 -0
  42. package/dist/src/auth/client.js +1043 -0
  43. package/dist/src/auth/client.js.map +1 -0
  44. package/dist/src/auth/index.d.ts +35 -0
  45. package/dist/src/auth/index.d.ts.map +1 -0
  46. package/dist/src/auth/index.js +35 -0
  47. package/dist/src/auth/index.js.map +1 -0
  48. package/dist/src/fetch/fetch.d.ts +88 -0
  49. package/dist/src/fetch/fetch.d.ts.map +1 -0
  50. package/dist/src/fetch/fetch.js +98 -0
  51. package/dist/src/fetch/fetch.js.map +1 -0
  52. package/dist/src/fetch/index.d.ts +38 -0
  53. package/dist/src/fetch/index.d.ts.map +1 -0
  54. package/dist/src/fetch/index.js +38 -0
  55. package/dist/src/fetch/index.js.map +1 -0
  56. package/dist/src/fetch/middlewareAttachAccessToken.d.ts +24 -0
  57. package/dist/src/fetch/middlewareAttachAccessToken.d.ts.map +1 -0
  58. package/dist/src/fetch/middlewareAttachAccessToken.js +54 -0
  59. package/dist/src/fetch/middlewareAttachAccessToken.js.map +1 -0
  60. package/dist/src/fetch/middlewareSessionRefresh.d.ts +30 -0
  61. package/dist/src/fetch/middlewareSessionRefresh.d.ts.map +1 -0
  62. package/dist/src/fetch/middlewareSessionRefresh.js +61 -0
  63. package/dist/src/fetch/middlewareSessionRefresh.js.map +1 -0
  64. package/dist/src/fetch/middlewareUpdateSessionFromResponse.d.ts +26 -0
  65. package/dist/src/fetch/middlewareUpdateSessionFromResponse.d.ts.map +1 -0
  66. package/dist/src/fetch/middlewareUpdateSessionFromResponse.js +79 -0
  67. package/dist/src/fetch/middlewareUpdateSessionFromResponse.js.map +1 -0
  68. package/dist/src/functions/client.d.ts +52 -0
  69. package/dist/src/functions/client.d.ts.map +1 -0
  70. package/dist/src/functions/client.js +89 -0
  71. package/dist/src/functions/client.js.map +1 -0
  72. package/dist/src/functions/index.d.ts +43 -0
  73. package/dist/src/functions/index.d.ts.map +1 -0
  74. package/dist/src/functions/index.js +43 -0
  75. package/dist/src/functions/index.js.map +1 -0
  76. package/dist/src/graphql/client.d.ts +93 -0
  77. package/dist/src/graphql/client.d.ts.map +1 -0
  78. package/dist/src/graphql/client.js +66 -0
  79. package/dist/src/graphql/client.js.map +1 -0
  80. package/dist/src/graphql/index.d.ts +65 -0
  81. package/dist/src/graphql/index.d.ts.map +1 -0
  82. package/dist/src/graphql/index.js +65 -0
  83. package/dist/src/graphql/index.js.map +1 -0
  84. package/dist/src/index.d.ts +35 -0
  85. package/dist/src/index.d.ts.map +1 -0
  86. package/dist/src/index.js +45 -0
  87. package/dist/src/index.js.map +1 -0
  88. package/dist/src/nhost.d.ts +301 -0
  89. package/dist/src/nhost.d.ts.map +1 -0
  90. package/dist/src/nhost.js +323 -0
  91. package/dist/src/nhost.js.map +1 -0
  92. package/dist/src/session/index.d.ts +20 -0
  93. package/dist/src/session/index.d.ts.map +1 -0
  94. package/dist/src/session/index.js +19 -0
  95. package/dist/src/session/index.js.map +1 -0
  96. package/dist/src/session/refreshSession.d.ts +17 -0
  97. package/dist/src/session/refreshSession.d.ts.map +1 -0
  98. package/dist/src/session/refreshSession.js +120 -0
  99. package/dist/src/session/refreshSession.js.map +1 -0
  100. package/dist/src/session/session.d.ts +24 -0
  101. package/dist/src/session/session.d.ts.map +1 -0
  102. package/dist/src/session/session.js +48 -0
  103. package/dist/src/session/session.js.map +1 -0
  104. package/dist/src/session/storage.d.ts +62 -0
  105. package/dist/src/session/storage.d.ts.map +1 -0
  106. package/dist/src/session/storage.js +91 -0
  107. package/dist/src/session/storage.js.map +1 -0
  108. package/dist/src/session/storageBackend.d.ts +122 -0
  109. package/dist/src/session/storageBackend.d.ts.map +1 -0
  110. package/dist/src/session/storageBackend.js +145 -0
  111. package/dist/src/session/storageBackend.js.map +1 -0
  112. package/dist/src/storage/client.d.ts +546 -0
  113. package/dist/src/storage/client.d.ts.map +1 -0
  114. package/dist/src/storage/client.js +368 -0
  115. package/dist/src/storage/client.js.map +1 -0
  116. package/dist/src/storage/index.d.ts +37 -0
  117. package/dist/src/storage/index.d.ts.map +1 -0
  118. package/dist/src/storage/index.js +37 -0
  119. package/dist/src/storage/index.js.map +1 -0
  120. package/dist/tsconfig.tsbuildinfo +1 -0
  121. package/package.json +103 -59
  122. package/dist/clients/auth.d.ts +0 -8
  123. package/dist/clients/auth.d.ts.map +0 -1
  124. package/dist/clients/functions/index.d.ts +0 -107
  125. package/dist/clients/functions/index.d.ts.map +0 -1
  126. package/dist/clients/functions/types.d.ts +0 -28
  127. package/dist/clients/functions/types.d.ts.map +0 -1
  128. package/dist/clients/graphql.d.ts +0 -8
  129. package/dist/clients/graphql.d.ts.map +0 -1
  130. package/dist/clients/index.d.ts +0 -6
  131. package/dist/clients/index.d.ts.map +0 -1
  132. package/dist/clients/nhost.d.ts +0 -83
  133. package/dist/clients/nhost.d.ts.map +0 -1
  134. package/dist/clients/storage.d.ts +0 -8
  135. package/dist/clients/storage.d.ts.map +0 -1
  136. package/dist/index.cjs.js +0 -2
  137. package/dist/index.cjs.js.map +0 -1
  138. package/dist/index.d.ts +0 -6
  139. package/dist/index.d.ts.map +0 -1
  140. package/dist/index.esm.js +0 -356
  141. package/dist/index.esm.js.map +0 -1
  142. package/dist/utils/helpers.d.ts +0 -20
  143. package/dist/utils/helpers.d.ts.map +0 -1
  144. package/dist/utils/types.d.ts +0 -57
  145. package/dist/utils/types.d.ts.map +0 -1
  146. package/umd/nhost-js.umd.js +0 -22
  147. package/umd/nhost-js.umd.js.map +0 -1
@@ -0,0 +1,1043 @@
1
+ /**
2
+ * This file is auto-generated. Do not edit manually.
3
+ */
4
+ import { createEnhancedFetch, FetchError } from "../fetch";
5
+ export const createAPIClient = (baseURL, chainFunctions = []) => {
6
+ let fetch = createEnhancedFetch(chainFunctions);
7
+ const pushChainFunction = (chainFunction) => {
8
+ chainFunctions.push(chainFunction);
9
+ fetch = createEnhancedFetch(chainFunctions);
10
+ };
11
+ const getJWKs = async (options) => {
12
+ const url = `${baseURL}/.well-known/jwks.json`;
13
+ const res = await fetch(url, {
14
+ ...options,
15
+ method: "GET",
16
+ headers: {
17
+ ...options?.headers,
18
+ },
19
+ });
20
+ if (res.status >= 300) {
21
+ const responseBody = [412].includes(res.status) ? null : await res.text();
22
+ const payload = responseBody ? JSON.parse(responseBody) : {};
23
+ throw new FetchError(payload, res.status, res.headers);
24
+ }
25
+ const responseBody = [204, 205, 304].includes(res.status)
26
+ ? null
27
+ : await res.text();
28
+ const payload = responseBody ? JSON.parse(responseBody) : {};
29
+ return {
30
+ body: payload,
31
+ status: res.status,
32
+ headers: res.headers,
33
+ };
34
+ };
35
+ const elevateWebauthn = async (options) => {
36
+ const url = `${baseURL}/elevate/webauthn`;
37
+ const res = await fetch(url, {
38
+ ...options,
39
+ method: "POST",
40
+ headers: {
41
+ ...options?.headers,
42
+ },
43
+ });
44
+ if (res.status >= 300) {
45
+ const responseBody = [412].includes(res.status) ? null : await res.text();
46
+ const payload = responseBody ? JSON.parse(responseBody) : {};
47
+ throw new FetchError(payload, res.status, res.headers);
48
+ }
49
+ const responseBody = [204, 205, 304].includes(res.status)
50
+ ? null
51
+ : await res.text();
52
+ const payload = responseBody
53
+ ? JSON.parse(responseBody)
54
+ : {};
55
+ return {
56
+ body: payload,
57
+ status: res.status,
58
+ headers: res.headers,
59
+ };
60
+ };
61
+ const verifyElevateWebauthn = async (body, options) => {
62
+ const url = `${baseURL}/elevate/webauthn/verify`;
63
+ const res = await fetch(url, {
64
+ ...options,
65
+ method: "POST",
66
+ headers: {
67
+ "Content-Type": "application/json",
68
+ ...options?.headers,
69
+ },
70
+ body: JSON.stringify(body),
71
+ });
72
+ if (res.status >= 300) {
73
+ const responseBody = [412].includes(res.status) ? null : await res.text();
74
+ const payload = responseBody ? JSON.parse(responseBody) : {};
75
+ throw new FetchError(payload, res.status, res.headers);
76
+ }
77
+ const responseBody = [204, 205, 304].includes(res.status)
78
+ ? null
79
+ : await res.text();
80
+ const payload = responseBody
81
+ ? JSON.parse(responseBody)
82
+ : {};
83
+ return {
84
+ body: payload,
85
+ status: res.status,
86
+ headers: res.headers,
87
+ };
88
+ };
89
+ const healthCheckGet = async (options) => {
90
+ const url = `${baseURL}/healthz`;
91
+ const res = await fetch(url, {
92
+ ...options,
93
+ method: "GET",
94
+ headers: {
95
+ ...options?.headers,
96
+ },
97
+ });
98
+ if (res.status >= 300) {
99
+ const responseBody = [412].includes(res.status) ? null : await res.text();
100
+ const payload = responseBody ? JSON.parse(responseBody) : {};
101
+ throw new FetchError(payload, res.status, res.headers);
102
+ }
103
+ const responseBody = [204, 205, 304].includes(res.status)
104
+ ? null
105
+ : await res.text();
106
+ const payload = responseBody ? JSON.parse(responseBody) : {};
107
+ return {
108
+ body: payload,
109
+ status: res.status,
110
+ headers: res.headers,
111
+ };
112
+ };
113
+ const healthCheckHead = async (options) => {
114
+ const url = `${baseURL}/healthz`;
115
+ const res = await fetch(url, {
116
+ ...options,
117
+ method: "HEAD",
118
+ headers: {
119
+ ...options?.headers,
120
+ },
121
+ });
122
+ if (res.status >= 300) {
123
+ const responseBody = [412].includes(res.status) ? null : await res.text();
124
+ const payload = responseBody ? JSON.parse(responseBody) : {};
125
+ throw new FetchError(payload, res.status, res.headers);
126
+ }
127
+ const payload = undefined;
128
+ return {
129
+ body: payload,
130
+ status: res.status,
131
+ headers: res.headers,
132
+ };
133
+ };
134
+ const linkIdToken = async (body, options) => {
135
+ const url = `${baseURL}/link/idtoken`;
136
+ const res = await fetch(url, {
137
+ ...options,
138
+ method: "POST",
139
+ headers: {
140
+ "Content-Type": "application/json",
141
+ ...options?.headers,
142
+ },
143
+ body: JSON.stringify(body),
144
+ });
145
+ if (res.status >= 300) {
146
+ const responseBody = [412].includes(res.status) ? null : await res.text();
147
+ const payload = responseBody ? JSON.parse(responseBody) : {};
148
+ throw new FetchError(payload, res.status, res.headers);
149
+ }
150
+ const responseBody = [204, 205, 304].includes(res.status)
151
+ ? null
152
+ : await res.text();
153
+ const payload = responseBody ? JSON.parse(responseBody) : {};
154
+ return {
155
+ body: payload,
156
+ status: res.status,
157
+ headers: res.headers,
158
+ };
159
+ };
160
+ const changeUserMfa = async (options) => {
161
+ const url = `${baseURL}/mfa/totp/generate`;
162
+ const res = await fetch(url, {
163
+ ...options,
164
+ method: "GET",
165
+ headers: {
166
+ ...options?.headers,
167
+ },
168
+ });
169
+ if (res.status >= 300) {
170
+ const responseBody = [412].includes(res.status) ? null : await res.text();
171
+ const payload = responseBody ? JSON.parse(responseBody) : {};
172
+ throw new FetchError(payload, res.status, res.headers);
173
+ }
174
+ const responseBody = [204, 205, 304].includes(res.status)
175
+ ? null
176
+ : await res.text();
177
+ const payload = responseBody
178
+ ? JSON.parse(responseBody)
179
+ : {};
180
+ return {
181
+ body: payload,
182
+ status: res.status,
183
+ headers: res.headers,
184
+ };
185
+ };
186
+ const createPAT = async (body, options) => {
187
+ const url = `${baseURL}/pat`;
188
+ const res = await fetch(url, {
189
+ ...options,
190
+ method: "POST",
191
+ headers: {
192
+ "Content-Type": "application/json",
193
+ ...options?.headers,
194
+ },
195
+ body: JSON.stringify(body),
196
+ });
197
+ if (res.status >= 300) {
198
+ const responseBody = [412].includes(res.status) ? null : await res.text();
199
+ const payload = responseBody ? JSON.parse(responseBody) : {};
200
+ throw new FetchError(payload, res.status, res.headers);
201
+ }
202
+ const responseBody = [204, 205, 304].includes(res.status)
203
+ ? null
204
+ : await res.text();
205
+ const payload = responseBody
206
+ ? JSON.parse(responseBody)
207
+ : {};
208
+ return {
209
+ body: payload,
210
+ status: res.status,
211
+ headers: res.headers,
212
+ };
213
+ };
214
+ const signInAnonymous = async (body, options) => {
215
+ const url = `${baseURL}/signin/anonymous`;
216
+ const res = await fetch(url, {
217
+ ...options,
218
+ method: "POST",
219
+ headers: {
220
+ "Content-Type": "application/json",
221
+ ...options?.headers,
222
+ },
223
+ body: JSON.stringify(body),
224
+ });
225
+ if (res.status >= 300) {
226
+ const responseBody = [412].includes(res.status) ? null : await res.text();
227
+ const payload = responseBody ? JSON.parse(responseBody) : {};
228
+ throw new FetchError(payload, res.status, res.headers);
229
+ }
230
+ const responseBody = [204, 205, 304].includes(res.status)
231
+ ? null
232
+ : await res.text();
233
+ const payload = responseBody
234
+ ? JSON.parse(responseBody)
235
+ : {};
236
+ return {
237
+ body: payload,
238
+ status: res.status,
239
+ headers: res.headers,
240
+ };
241
+ };
242
+ const signInEmailPassword = async (body, options) => {
243
+ const url = `${baseURL}/signin/email-password`;
244
+ const res = await fetch(url, {
245
+ ...options,
246
+ method: "POST",
247
+ headers: {
248
+ "Content-Type": "application/json",
249
+ ...options?.headers,
250
+ },
251
+ body: JSON.stringify(body),
252
+ });
253
+ if (res.status >= 300) {
254
+ const responseBody = [412].includes(res.status) ? null : await res.text();
255
+ const payload = responseBody ? JSON.parse(responseBody) : {};
256
+ throw new FetchError(payload, res.status, res.headers);
257
+ }
258
+ const responseBody = [204, 205, 304].includes(res.status)
259
+ ? null
260
+ : await res.text();
261
+ const payload = responseBody
262
+ ? JSON.parse(responseBody)
263
+ : {};
264
+ return {
265
+ body: payload,
266
+ status: res.status,
267
+ headers: res.headers,
268
+ };
269
+ };
270
+ const signInIdToken = async (body, options) => {
271
+ const url = `${baseURL}/signin/idtoken`;
272
+ const res = await fetch(url, {
273
+ ...options,
274
+ method: "POST",
275
+ headers: {
276
+ "Content-Type": "application/json",
277
+ ...options?.headers,
278
+ },
279
+ body: JSON.stringify(body),
280
+ });
281
+ if (res.status >= 300) {
282
+ const responseBody = [412].includes(res.status) ? null : await res.text();
283
+ const payload = responseBody ? JSON.parse(responseBody) : {};
284
+ throw new FetchError(payload, res.status, res.headers);
285
+ }
286
+ const responseBody = [204, 205, 304].includes(res.status)
287
+ ? null
288
+ : await res.text();
289
+ const payload = responseBody
290
+ ? JSON.parse(responseBody)
291
+ : {};
292
+ return {
293
+ body: payload,
294
+ status: res.status,
295
+ headers: res.headers,
296
+ };
297
+ };
298
+ const verifySignInMfaTotp = async (body, options) => {
299
+ const url = `${baseURL}/signin/mfa/totp`;
300
+ const res = await fetch(url, {
301
+ ...options,
302
+ method: "POST",
303
+ headers: {
304
+ "Content-Type": "application/json",
305
+ ...options?.headers,
306
+ },
307
+ body: JSON.stringify(body),
308
+ });
309
+ if (res.status >= 300) {
310
+ const responseBody = [412].includes(res.status) ? null : await res.text();
311
+ const payload = responseBody ? JSON.parse(responseBody) : {};
312
+ throw new FetchError(payload, res.status, res.headers);
313
+ }
314
+ const responseBody = [204, 205, 304].includes(res.status)
315
+ ? null
316
+ : await res.text();
317
+ const payload = responseBody
318
+ ? JSON.parse(responseBody)
319
+ : {};
320
+ return {
321
+ body: payload,
322
+ status: res.status,
323
+ headers: res.headers,
324
+ };
325
+ };
326
+ const signInOTPEmail = async (body, options) => {
327
+ const url = `${baseURL}/signin/otp/email`;
328
+ const res = await fetch(url, {
329
+ ...options,
330
+ method: "POST",
331
+ headers: {
332
+ "Content-Type": "application/json",
333
+ ...options?.headers,
334
+ },
335
+ body: JSON.stringify(body),
336
+ });
337
+ if (res.status >= 300) {
338
+ const responseBody = [412].includes(res.status) ? null : await res.text();
339
+ const payload = responseBody ? JSON.parse(responseBody) : {};
340
+ throw new FetchError(payload, res.status, res.headers);
341
+ }
342
+ const responseBody = [204, 205, 304].includes(res.status)
343
+ ? null
344
+ : await res.text();
345
+ const payload = responseBody ? JSON.parse(responseBody) : {};
346
+ return {
347
+ body: payload,
348
+ status: res.status,
349
+ headers: res.headers,
350
+ };
351
+ };
352
+ const verifySignInOTPEmail = async (body, options) => {
353
+ const url = `${baseURL}/signin/otp/email/verify`;
354
+ const res = await fetch(url, {
355
+ ...options,
356
+ method: "POST",
357
+ headers: {
358
+ "Content-Type": "application/json",
359
+ ...options?.headers,
360
+ },
361
+ body: JSON.stringify(body),
362
+ });
363
+ if (res.status >= 300) {
364
+ const responseBody = [412].includes(res.status) ? null : await res.text();
365
+ const payload = responseBody ? JSON.parse(responseBody) : {};
366
+ throw new FetchError(payload, res.status, res.headers);
367
+ }
368
+ const responseBody = [204, 205, 304].includes(res.status)
369
+ ? null
370
+ : await res.text();
371
+ const payload = responseBody
372
+ ? JSON.parse(responseBody)
373
+ : {};
374
+ return {
375
+ body: payload,
376
+ status: res.status,
377
+ headers: res.headers,
378
+ };
379
+ };
380
+ const signInPasswordlessEmail = async (body, options) => {
381
+ const url = `${baseURL}/signin/passwordless/email`;
382
+ const res = await fetch(url, {
383
+ ...options,
384
+ method: "POST",
385
+ headers: {
386
+ "Content-Type": "application/json",
387
+ ...options?.headers,
388
+ },
389
+ body: JSON.stringify(body),
390
+ });
391
+ if (res.status >= 300) {
392
+ const responseBody = [412].includes(res.status) ? null : await res.text();
393
+ const payload = responseBody ? JSON.parse(responseBody) : {};
394
+ throw new FetchError(payload, res.status, res.headers);
395
+ }
396
+ const responseBody = [204, 205, 304].includes(res.status)
397
+ ? null
398
+ : await res.text();
399
+ const payload = responseBody ? JSON.parse(responseBody) : {};
400
+ return {
401
+ body: payload,
402
+ status: res.status,
403
+ headers: res.headers,
404
+ };
405
+ };
406
+ const signInPasswordlessSms = async (body, options) => {
407
+ const url = `${baseURL}/signin/passwordless/sms`;
408
+ const res = await fetch(url, {
409
+ ...options,
410
+ method: "POST",
411
+ headers: {
412
+ "Content-Type": "application/json",
413
+ ...options?.headers,
414
+ },
415
+ body: JSON.stringify(body),
416
+ });
417
+ if (res.status >= 300) {
418
+ const responseBody = [412].includes(res.status) ? null : await res.text();
419
+ const payload = responseBody ? JSON.parse(responseBody) : {};
420
+ throw new FetchError(payload, res.status, res.headers);
421
+ }
422
+ const responseBody = [204, 205, 304].includes(res.status)
423
+ ? null
424
+ : await res.text();
425
+ const payload = responseBody ? JSON.parse(responseBody) : {};
426
+ return {
427
+ body: payload,
428
+ status: res.status,
429
+ headers: res.headers,
430
+ };
431
+ };
432
+ const verifySignInPasswordlessSms = async (body, options) => {
433
+ const url = `${baseURL}/signin/passwordless/sms/otp`;
434
+ const res = await fetch(url, {
435
+ ...options,
436
+ method: "POST",
437
+ headers: {
438
+ "Content-Type": "application/json",
439
+ ...options?.headers,
440
+ },
441
+ body: JSON.stringify(body),
442
+ });
443
+ if (res.status >= 300) {
444
+ const responseBody = [412].includes(res.status) ? null : await res.text();
445
+ const payload = responseBody ? JSON.parse(responseBody) : {};
446
+ throw new FetchError(payload, res.status, res.headers);
447
+ }
448
+ const responseBody = [204, 205, 304].includes(res.status)
449
+ ? null
450
+ : await res.text();
451
+ const payload = responseBody
452
+ ? JSON.parse(responseBody)
453
+ : {};
454
+ return {
455
+ body: payload,
456
+ status: res.status,
457
+ headers: res.headers,
458
+ };
459
+ };
460
+ const signInPAT = async (body, options) => {
461
+ const url = `${baseURL}/signin/pat`;
462
+ const res = await fetch(url, {
463
+ ...options,
464
+ method: "POST",
465
+ headers: {
466
+ "Content-Type": "application/json",
467
+ ...options?.headers,
468
+ },
469
+ body: JSON.stringify(body),
470
+ });
471
+ if (res.status >= 300) {
472
+ const responseBody = [412].includes(res.status) ? null : await res.text();
473
+ const payload = responseBody ? JSON.parse(responseBody) : {};
474
+ throw new FetchError(payload, res.status, res.headers);
475
+ }
476
+ const responseBody = [204, 205, 304].includes(res.status)
477
+ ? null
478
+ : await res.text();
479
+ const payload = responseBody
480
+ ? JSON.parse(responseBody)
481
+ : {};
482
+ return {
483
+ body: payload,
484
+ status: res.status,
485
+ headers: res.headers,
486
+ };
487
+ };
488
+ const signInProviderURL = (provider, params) => {
489
+ const encodedParameters = params &&
490
+ Object.entries(params)
491
+ .map(([key, value]) => {
492
+ const stringValue = Array.isArray(value)
493
+ ? value.join(",")
494
+ : typeof value === "object"
495
+ ? JSON.stringify(value)
496
+ : value;
497
+ return `${key}=${encodeURIComponent(stringValue)}`;
498
+ })
499
+ .join("&");
500
+ const url = encodedParameters
501
+ ? `${baseURL}/signin/provider/${provider}?${encodedParameters}`
502
+ : `${baseURL}/signin/provider/${provider}`;
503
+ return url;
504
+ };
505
+ const signInWebauthn = async (body, options) => {
506
+ const url = `${baseURL}/signin/webauthn`;
507
+ const res = await fetch(url, {
508
+ ...options,
509
+ method: "POST",
510
+ headers: {
511
+ "Content-Type": "application/json",
512
+ ...options?.headers,
513
+ },
514
+ body: JSON.stringify(body),
515
+ });
516
+ if (res.status >= 300) {
517
+ const responseBody = [412].includes(res.status) ? null : await res.text();
518
+ const payload = responseBody ? JSON.parse(responseBody) : {};
519
+ throw new FetchError(payload, res.status, res.headers);
520
+ }
521
+ const responseBody = [204, 205, 304].includes(res.status)
522
+ ? null
523
+ : await res.text();
524
+ const payload = responseBody
525
+ ? JSON.parse(responseBody)
526
+ : {};
527
+ return {
528
+ body: payload,
529
+ status: res.status,
530
+ headers: res.headers,
531
+ };
532
+ };
533
+ const verifySignInWebauthn = async (body, options) => {
534
+ const url = `${baseURL}/signin/webauthn/verify`;
535
+ const res = await fetch(url, {
536
+ ...options,
537
+ method: "POST",
538
+ headers: {
539
+ "Content-Type": "application/json",
540
+ ...options?.headers,
541
+ },
542
+ body: JSON.stringify(body),
543
+ });
544
+ if (res.status >= 300) {
545
+ const responseBody = [412].includes(res.status) ? null : await res.text();
546
+ const payload = responseBody ? JSON.parse(responseBody) : {};
547
+ throw new FetchError(payload, res.status, res.headers);
548
+ }
549
+ const responseBody = [204, 205, 304].includes(res.status)
550
+ ? null
551
+ : await res.text();
552
+ const payload = responseBody
553
+ ? JSON.parse(responseBody)
554
+ : {};
555
+ return {
556
+ body: payload,
557
+ status: res.status,
558
+ headers: res.headers,
559
+ };
560
+ };
561
+ const signOut = async (body, options) => {
562
+ const url = `${baseURL}/signout`;
563
+ const res = await fetch(url, {
564
+ ...options,
565
+ method: "POST",
566
+ headers: {
567
+ "Content-Type": "application/json",
568
+ ...options?.headers,
569
+ },
570
+ body: JSON.stringify(body),
571
+ });
572
+ if (res.status >= 300) {
573
+ const responseBody = [412].includes(res.status) ? null : await res.text();
574
+ const payload = responseBody ? JSON.parse(responseBody) : {};
575
+ throw new FetchError(payload, res.status, res.headers);
576
+ }
577
+ const responseBody = [204, 205, 304].includes(res.status)
578
+ ? null
579
+ : 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 signUpEmailPassword = async (body, options) => {
588
+ const url = `${baseURL}/signup/email-password`;
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 responseBody = [412].includes(res.status) ? null : await res.text();
600
+ const payload = responseBody ? JSON.parse(responseBody) : {};
601
+ throw new FetchError(payload, res.status, res.headers);
602
+ }
603
+ const responseBody = [204, 205, 304].includes(res.status)
604
+ ? null
605
+ : await res.text();
606
+ const payload = responseBody
607
+ ? JSON.parse(responseBody)
608
+ : {};
609
+ return {
610
+ body: payload,
611
+ status: res.status,
612
+ headers: res.headers,
613
+ };
614
+ };
615
+ const signUpWebauthn = async (body, options) => {
616
+ const url = `${baseURL}/signup/webauthn`;
617
+ const res = await fetch(url, {
618
+ ...options,
619
+ method: "POST",
620
+ headers: {
621
+ "Content-Type": "application/json",
622
+ ...options?.headers,
623
+ },
624
+ body: JSON.stringify(body),
625
+ });
626
+ if (res.status >= 300) {
627
+ const responseBody = [412].includes(res.status) ? null : await res.text();
628
+ const payload = responseBody ? JSON.parse(responseBody) : {};
629
+ throw new FetchError(payload, res.status, res.headers);
630
+ }
631
+ const responseBody = [204, 205, 304].includes(res.status)
632
+ ? null
633
+ : await res.text();
634
+ const payload = responseBody
635
+ ? JSON.parse(responseBody)
636
+ : {};
637
+ return {
638
+ body: payload,
639
+ status: res.status,
640
+ headers: res.headers,
641
+ };
642
+ };
643
+ const verifySignUpWebauthn = async (body, options) => {
644
+ const url = `${baseURL}/signup/webauthn/verify`;
645
+ const res = await fetch(url, {
646
+ ...options,
647
+ method: "POST",
648
+ headers: {
649
+ "Content-Type": "application/json",
650
+ ...options?.headers,
651
+ },
652
+ body: JSON.stringify(body),
653
+ });
654
+ if (res.status >= 300) {
655
+ const responseBody = [412].includes(res.status) ? null : await res.text();
656
+ const payload = responseBody ? JSON.parse(responseBody) : {};
657
+ throw new FetchError(payload, res.status, res.headers);
658
+ }
659
+ const responseBody = [204, 205, 304].includes(res.status)
660
+ ? null
661
+ : await res.text();
662
+ const payload = responseBody
663
+ ? JSON.parse(responseBody)
664
+ : {};
665
+ return {
666
+ body: payload,
667
+ status: res.status,
668
+ headers: res.headers,
669
+ };
670
+ };
671
+ const refreshToken = async (body, options) => {
672
+ const url = `${baseURL}/token`;
673
+ const res = await fetch(url, {
674
+ ...options,
675
+ method: "POST",
676
+ headers: {
677
+ "Content-Type": "application/json",
678
+ ...options?.headers,
679
+ },
680
+ body: JSON.stringify(body),
681
+ });
682
+ if (res.status >= 300) {
683
+ const responseBody = [412].includes(res.status) ? null : await res.text();
684
+ const payload = responseBody ? JSON.parse(responseBody) : {};
685
+ throw new FetchError(payload, res.status, res.headers);
686
+ }
687
+ const responseBody = [204, 205, 304].includes(res.status)
688
+ ? null
689
+ : await res.text();
690
+ const payload = responseBody ? JSON.parse(responseBody) : {};
691
+ return {
692
+ body: payload,
693
+ status: res.status,
694
+ headers: res.headers,
695
+ };
696
+ };
697
+ const verifyToken = async (body, options) => {
698
+ const url = `${baseURL}/token/verify`;
699
+ const res = await fetch(url, {
700
+ ...options,
701
+ method: "POST",
702
+ headers: {
703
+ "Content-Type": "application/json",
704
+ ...options?.headers,
705
+ },
706
+ body: JSON.stringify(body),
707
+ });
708
+ if (res.status >= 300) {
709
+ const responseBody = [412].includes(res.status) ? null : await res.text();
710
+ const payload = responseBody ? JSON.parse(responseBody) : {};
711
+ throw new FetchError(payload, res.status, res.headers);
712
+ }
713
+ const responseBody = [204, 205, 304].includes(res.status)
714
+ ? null
715
+ : await res.text();
716
+ const payload = responseBody ? JSON.parse(responseBody) : {};
717
+ return {
718
+ body: payload,
719
+ status: res.status,
720
+ headers: res.headers,
721
+ };
722
+ };
723
+ const getUser = async (options) => {
724
+ const url = `${baseURL}/user`;
725
+ const res = await fetch(url, {
726
+ ...options,
727
+ method: "GET",
728
+ headers: {
729
+ ...options?.headers,
730
+ },
731
+ });
732
+ if (res.status >= 300) {
733
+ const responseBody = [412].includes(res.status) ? null : await res.text();
734
+ const payload = responseBody ? JSON.parse(responseBody) : {};
735
+ throw new FetchError(payload, res.status, res.headers);
736
+ }
737
+ const responseBody = [204, 205, 304].includes(res.status)
738
+ ? null
739
+ : await res.text();
740
+ const payload = responseBody ? JSON.parse(responseBody) : {};
741
+ return {
742
+ body: payload,
743
+ status: res.status,
744
+ headers: res.headers,
745
+ };
746
+ };
747
+ const deanonymizeUser = async (body, options) => {
748
+ const url = `${baseURL}/user/deanonymize`;
749
+ const res = await fetch(url, {
750
+ ...options,
751
+ method: "POST",
752
+ headers: {
753
+ "Content-Type": "application/json",
754
+ ...options?.headers,
755
+ },
756
+ body: JSON.stringify(body),
757
+ });
758
+ if (res.status >= 300) {
759
+ const responseBody = [412].includes(res.status) ? null : await res.text();
760
+ const payload = responseBody ? JSON.parse(responseBody) : {};
761
+ throw new FetchError(payload, res.status, res.headers);
762
+ }
763
+ const responseBody = [204, 205, 304].includes(res.status)
764
+ ? null
765
+ : await res.text();
766
+ const payload = responseBody ? JSON.parse(responseBody) : {};
767
+ return {
768
+ body: payload,
769
+ status: res.status,
770
+ headers: res.headers,
771
+ };
772
+ };
773
+ const changeUserEmail = async (body, options) => {
774
+ const url = `${baseURL}/user/email/change`;
775
+ const res = await fetch(url, {
776
+ ...options,
777
+ method: "POST",
778
+ headers: {
779
+ "Content-Type": "application/json",
780
+ ...options?.headers,
781
+ },
782
+ body: JSON.stringify(body),
783
+ });
784
+ if (res.status >= 300) {
785
+ const responseBody = [412].includes(res.status) ? null : await res.text();
786
+ const payload = responseBody ? JSON.parse(responseBody) : {};
787
+ throw new FetchError(payload, res.status, res.headers);
788
+ }
789
+ const responseBody = [204, 205, 304].includes(res.status)
790
+ ? null
791
+ : await res.text();
792
+ const payload = responseBody ? JSON.parse(responseBody) : {};
793
+ return {
794
+ body: payload,
795
+ status: res.status,
796
+ headers: res.headers,
797
+ };
798
+ };
799
+ const sendVerificationEmail = async (body, options) => {
800
+ const url = `${baseURL}/user/email/send-verification-email`;
801
+ const res = await fetch(url, {
802
+ ...options,
803
+ method: "POST",
804
+ headers: {
805
+ "Content-Type": "application/json",
806
+ ...options?.headers,
807
+ },
808
+ body: JSON.stringify(body),
809
+ });
810
+ if (res.status >= 300) {
811
+ const responseBody = [412].includes(res.status) ? null : await res.text();
812
+ const payload = responseBody ? JSON.parse(responseBody) : {};
813
+ throw new FetchError(payload, res.status, res.headers);
814
+ }
815
+ const responseBody = [204, 205, 304].includes(res.status)
816
+ ? null
817
+ : 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 verifyChangeUserMfa = async (body, options) => {
826
+ const url = `${baseURL}/user/mfa`;
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 responseBody = [412].includes(res.status) ? null : await res.text();
838
+ const payload = responseBody ? JSON.parse(responseBody) : {};
839
+ throw new FetchError(payload, res.status, res.headers);
840
+ }
841
+ const responseBody = [204, 205, 304].includes(res.status)
842
+ ? null
843
+ : await res.text();
844
+ const payload = responseBody ? JSON.parse(responseBody) : {};
845
+ return {
846
+ body: payload,
847
+ status: res.status,
848
+ headers: res.headers,
849
+ };
850
+ };
851
+ const changeUserPassword = async (body, options) => {
852
+ const url = `${baseURL}/user/password`;
853
+ const res = await fetch(url, {
854
+ ...options,
855
+ method: "POST",
856
+ headers: {
857
+ "Content-Type": "application/json",
858
+ ...options?.headers,
859
+ },
860
+ body: JSON.stringify(body),
861
+ });
862
+ if (res.status >= 300) {
863
+ const responseBody = [412].includes(res.status) ? null : await res.text();
864
+ const payload = responseBody ? JSON.parse(responseBody) : {};
865
+ throw new FetchError(payload, res.status, res.headers);
866
+ }
867
+ const responseBody = [204, 205, 304].includes(res.status)
868
+ ? null
869
+ : await res.text();
870
+ const payload = responseBody ? JSON.parse(responseBody) : {};
871
+ return {
872
+ body: payload,
873
+ status: res.status,
874
+ headers: res.headers,
875
+ };
876
+ };
877
+ const sendPasswordResetEmail = async (body, options) => {
878
+ const url = `${baseURL}/user/password/reset`;
879
+ const res = await fetch(url, {
880
+ ...options,
881
+ method: "POST",
882
+ headers: {
883
+ "Content-Type": "application/json",
884
+ ...options?.headers,
885
+ },
886
+ body: JSON.stringify(body),
887
+ });
888
+ if (res.status >= 300) {
889
+ const responseBody = [412].includes(res.status) ? null : await res.text();
890
+ const payload = responseBody ? JSON.parse(responseBody) : {};
891
+ throw new FetchError(payload, res.status, res.headers);
892
+ }
893
+ const responseBody = [204, 205, 304].includes(res.status)
894
+ ? null
895
+ : await res.text();
896
+ const payload = responseBody ? JSON.parse(responseBody) : {};
897
+ return {
898
+ body: payload,
899
+ status: res.status,
900
+ headers: res.headers,
901
+ };
902
+ };
903
+ const addSecurityKey = async (options) => {
904
+ const url = `${baseURL}/user/webauthn/add`;
905
+ const res = await fetch(url, {
906
+ ...options,
907
+ method: "POST",
908
+ headers: {
909
+ ...options?.headers,
910
+ },
911
+ });
912
+ if (res.status >= 300) {
913
+ const responseBody = [412].includes(res.status) ? null : await res.text();
914
+ const payload = responseBody ? JSON.parse(responseBody) : {};
915
+ throw new FetchError(payload, res.status, res.headers);
916
+ }
917
+ const responseBody = [204, 205, 304].includes(res.status)
918
+ ? null
919
+ : await res.text();
920
+ const payload = responseBody
921
+ ? JSON.parse(responseBody)
922
+ : {};
923
+ return {
924
+ body: payload,
925
+ status: res.status,
926
+ headers: res.headers,
927
+ };
928
+ };
929
+ const verifyAddSecurityKey = async (body, options) => {
930
+ const url = `${baseURL}/user/webauthn/verify`;
931
+ const res = await fetch(url, {
932
+ ...options,
933
+ method: "POST",
934
+ headers: {
935
+ "Content-Type": "application/json",
936
+ ...options?.headers,
937
+ },
938
+ body: JSON.stringify(body),
939
+ });
940
+ if (res.status >= 300) {
941
+ const responseBody = [412].includes(res.status) ? null : await res.text();
942
+ const payload = responseBody ? JSON.parse(responseBody) : {};
943
+ throw new FetchError(payload, res.status, res.headers);
944
+ }
945
+ const responseBody = [204, 205, 304].includes(res.status)
946
+ ? null
947
+ : await res.text();
948
+ const payload = responseBody
949
+ ? JSON.parse(responseBody)
950
+ : {};
951
+ return {
952
+ body: payload,
953
+ status: res.status,
954
+ headers: res.headers,
955
+ };
956
+ };
957
+ const verifyTicketURL = (params) => {
958
+ const encodedParameters = params &&
959
+ Object.entries(params)
960
+ .map(([key, value]) => {
961
+ const stringValue = Array.isArray(value)
962
+ ? value.join(",")
963
+ : typeof value === "object"
964
+ ? JSON.stringify(value)
965
+ : value;
966
+ return `${key}=${encodeURIComponent(stringValue)}`;
967
+ })
968
+ .join("&");
969
+ const url = encodedParameters
970
+ ? `${baseURL}/verify?${encodedParameters}`
971
+ : `${baseURL}/verify`;
972
+ return url;
973
+ };
974
+ const getVersion = async (options) => {
975
+ const url = `${baseURL}/version`;
976
+ const res = await fetch(url, {
977
+ ...options,
978
+ method: "GET",
979
+ headers: {
980
+ ...options?.headers,
981
+ },
982
+ });
983
+ if (res.status >= 300) {
984
+ const responseBody = [412].includes(res.status) ? null : await res.text();
985
+ const payload = responseBody ? JSON.parse(responseBody) : {};
986
+ throw new FetchError(payload, res.status, res.headers);
987
+ }
988
+ const responseBody = [204, 205, 304].includes(res.status)
989
+ ? null
990
+ : await res.text();
991
+ const payload = responseBody
992
+ ? JSON.parse(responseBody)
993
+ : {};
994
+ return {
995
+ body: payload,
996
+ status: res.status,
997
+ headers: res.headers,
998
+ };
999
+ };
1000
+ return {
1001
+ baseURL,
1002
+ pushChainFunction,
1003
+ getJWKs,
1004
+ elevateWebauthn,
1005
+ verifyElevateWebauthn,
1006
+ healthCheckGet,
1007
+ healthCheckHead,
1008
+ linkIdToken,
1009
+ changeUserMfa,
1010
+ createPAT,
1011
+ signInAnonymous,
1012
+ signInEmailPassword,
1013
+ signInIdToken,
1014
+ verifySignInMfaTotp,
1015
+ signInOTPEmail,
1016
+ verifySignInOTPEmail,
1017
+ signInPasswordlessEmail,
1018
+ signInPasswordlessSms,
1019
+ verifySignInPasswordlessSms,
1020
+ signInPAT,
1021
+ signInProviderURL,
1022
+ signInWebauthn,
1023
+ verifySignInWebauthn,
1024
+ signOut,
1025
+ signUpEmailPassword,
1026
+ signUpWebauthn,
1027
+ verifySignUpWebauthn,
1028
+ refreshToken,
1029
+ verifyToken,
1030
+ getUser,
1031
+ deanonymizeUser,
1032
+ changeUserEmail,
1033
+ sendVerificationEmail,
1034
+ verifyChangeUserMfa,
1035
+ changeUserPassword,
1036
+ sendPasswordResetEmail,
1037
+ addSecurityKey,
1038
+ verifyAddSecurityKey,
1039
+ verifyTicketURL,
1040
+ getVersion,
1041
+ };
1042
+ };
1043
+ //# sourceMappingURL=client.js.map