@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,917 @@
1
+ import { c as createEnhancedFetch, F as FetchError } from "../fetch-2PHmQBIJ.mjs";
2
+ const createAPIClient = (baseURL, chainFunctions = []) => {
3
+ let fetch = createEnhancedFetch(chainFunctions);
4
+ const pushChainFunction = (chainFunction) => {
5
+ chainFunctions.push(chainFunction);
6
+ fetch = createEnhancedFetch(chainFunctions);
7
+ };
8
+ const getJWKs = async (options) => {
9
+ const url = `${baseURL}/.well-known/jwks.json`;
10
+ const res = await fetch(url, {
11
+ ...options,
12
+ method: "GET",
13
+ headers: {
14
+ ...options?.headers
15
+ }
16
+ });
17
+ if (res.status >= 300) {
18
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
19
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
20
+ throw new FetchError(payload2, res.status, res.headers);
21
+ }
22
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
23
+ const payload = responseBody ? JSON.parse(responseBody) : {};
24
+ return {
25
+ body: payload,
26
+ status: res.status,
27
+ headers: res.headers
28
+ };
29
+ };
30
+ const elevateWebauthn = async (options) => {
31
+ const url = `${baseURL}/elevate/webauthn`;
32
+ const res = await fetch(url, {
33
+ ...options,
34
+ method: "POST",
35
+ headers: {
36
+ ...options?.headers
37
+ }
38
+ });
39
+ if (res.status >= 300) {
40
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
41
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
42
+ throw new FetchError(payload2, res.status, res.headers);
43
+ }
44
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
45
+ const payload = responseBody ? JSON.parse(responseBody) : {};
46
+ return {
47
+ body: payload,
48
+ status: res.status,
49
+ headers: res.headers
50
+ };
51
+ };
52
+ const verifyElevateWebauthn = async (body, options) => {
53
+ const url = `${baseURL}/elevate/webauthn/verify`;
54
+ const res = await fetch(url, {
55
+ ...options,
56
+ method: "POST",
57
+ headers: {
58
+ "Content-Type": "application/json",
59
+ ...options?.headers
60
+ },
61
+ body: JSON.stringify(body)
62
+ });
63
+ if (res.status >= 300) {
64
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
65
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
66
+ throw new FetchError(payload2, res.status, res.headers);
67
+ }
68
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
69
+ const payload = responseBody ? JSON.parse(responseBody) : {};
70
+ return {
71
+ body: payload,
72
+ status: res.status,
73
+ headers: res.headers
74
+ };
75
+ };
76
+ const healthCheckGet = async (options) => {
77
+ const url = `${baseURL}/healthz`;
78
+ const res = await fetch(url, {
79
+ ...options,
80
+ method: "GET",
81
+ headers: {
82
+ ...options?.headers
83
+ }
84
+ });
85
+ if (res.status >= 300) {
86
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
87
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
88
+ throw new FetchError(payload2, res.status, res.headers);
89
+ }
90
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
91
+ const payload = responseBody ? JSON.parse(responseBody) : {};
92
+ return {
93
+ body: payload,
94
+ status: res.status,
95
+ headers: res.headers
96
+ };
97
+ };
98
+ const healthCheckHead = async (options) => {
99
+ const url = `${baseURL}/healthz`;
100
+ const res = await fetch(url, {
101
+ ...options,
102
+ method: "HEAD",
103
+ headers: {
104
+ ...options?.headers
105
+ }
106
+ });
107
+ if (res.status >= 300) {
108
+ const responseBody = [412].includes(res.status) ? null : await res.text();
109
+ const payload2 = responseBody ? JSON.parse(responseBody) : {};
110
+ throw new FetchError(payload2, res.status, res.headers);
111
+ }
112
+ const payload = void 0;
113
+ return {
114
+ body: payload,
115
+ status: res.status,
116
+ headers: res.headers
117
+ };
118
+ };
119
+ const linkIdToken = async (body, options) => {
120
+ const url = `${baseURL}/link/idtoken`;
121
+ const res = await fetch(url, {
122
+ ...options,
123
+ method: "POST",
124
+ headers: {
125
+ "Content-Type": "application/json",
126
+ ...options?.headers
127
+ },
128
+ body: JSON.stringify(body)
129
+ });
130
+ if (res.status >= 300) {
131
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
132
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
133
+ throw new FetchError(payload2, res.status, res.headers);
134
+ }
135
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
136
+ const payload = responseBody ? JSON.parse(responseBody) : {};
137
+ return {
138
+ body: payload,
139
+ status: res.status,
140
+ headers: res.headers
141
+ };
142
+ };
143
+ const changeUserMfa = async (options) => {
144
+ const url = `${baseURL}/mfa/totp/generate`;
145
+ const res = await fetch(url, {
146
+ ...options,
147
+ method: "GET",
148
+ headers: {
149
+ ...options?.headers
150
+ }
151
+ });
152
+ if (res.status >= 300) {
153
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
154
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
155
+ throw new FetchError(payload2, res.status, res.headers);
156
+ }
157
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
158
+ const payload = responseBody ? JSON.parse(responseBody) : {};
159
+ return {
160
+ body: payload,
161
+ status: res.status,
162
+ headers: res.headers
163
+ };
164
+ };
165
+ const createPAT = async (body, options) => {
166
+ const url = `${baseURL}/pat`;
167
+ const res = await fetch(url, {
168
+ ...options,
169
+ method: "POST",
170
+ headers: {
171
+ "Content-Type": "application/json",
172
+ ...options?.headers
173
+ },
174
+ body: JSON.stringify(body)
175
+ });
176
+ if (res.status >= 300) {
177
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
178
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
179
+ throw new FetchError(payload2, res.status, res.headers);
180
+ }
181
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
182
+ const payload = responseBody ? JSON.parse(responseBody) : {};
183
+ return {
184
+ body: payload,
185
+ status: res.status,
186
+ headers: res.headers
187
+ };
188
+ };
189
+ const signInAnonymous = async (body, options) => {
190
+ const url = `${baseURL}/signin/anonymous`;
191
+ const res = await fetch(url, {
192
+ ...options,
193
+ method: "POST",
194
+ headers: {
195
+ "Content-Type": "application/json",
196
+ ...options?.headers
197
+ },
198
+ body: JSON.stringify(body)
199
+ });
200
+ if (res.status >= 300) {
201
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
202
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
203
+ throw new FetchError(payload2, res.status, res.headers);
204
+ }
205
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
206
+ const payload = responseBody ? JSON.parse(responseBody) : {};
207
+ return {
208
+ body: payload,
209
+ status: res.status,
210
+ headers: res.headers
211
+ };
212
+ };
213
+ const signInEmailPassword = async (body, options) => {
214
+ const url = `${baseURL}/signin/email-password`;
215
+ const res = await fetch(url, {
216
+ ...options,
217
+ method: "POST",
218
+ headers: {
219
+ "Content-Type": "application/json",
220
+ ...options?.headers
221
+ },
222
+ body: JSON.stringify(body)
223
+ });
224
+ if (res.status >= 300) {
225
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
226
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
227
+ throw new FetchError(payload2, res.status, res.headers);
228
+ }
229
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
230
+ const payload = responseBody ? JSON.parse(responseBody) : {};
231
+ return {
232
+ body: payload,
233
+ status: res.status,
234
+ headers: res.headers
235
+ };
236
+ };
237
+ const signInIdToken = async (body, options) => {
238
+ const url = `${baseURL}/signin/idtoken`;
239
+ const res = await fetch(url, {
240
+ ...options,
241
+ method: "POST",
242
+ headers: {
243
+ "Content-Type": "application/json",
244
+ ...options?.headers
245
+ },
246
+ body: JSON.stringify(body)
247
+ });
248
+ if (res.status >= 300) {
249
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
250
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
251
+ throw new FetchError(payload2, res.status, res.headers);
252
+ }
253
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
254
+ const payload = responseBody ? JSON.parse(responseBody) : {};
255
+ return {
256
+ body: payload,
257
+ status: res.status,
258
+ headers: res.headers
259
+ };
260
+ };
261
+ const verifySignInMfaTotp = async (body, options) => {
262
+ const url = `${baseURL}/signin/mfa/totp`;
263
+ const res = await fetch(url, {
264
+ ...options,
265
+ method: "POST",
266
+ headers: {
267
+ "Content-Type": "application/json",
268
+ ...options?.headers
269
+ },
270
+ body: JSON.stringify(body)
271
+ });
272
+ if (res.status >= 300) {
273
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
274
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
275
+ throw new FetchError(payload2, res.status, res.headers);
276
+ }
277
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
278
+ const payload = responseBody ? JSON.parse(responseBody) : {};
279
+ return {
280
+ body: payload,
281
+ status: res.status,
282
+ headers: res.headers
283
+ };
284
+ };
285
+ const signInOTPEmail = async (body, options) => {
286
+ const url = `${baseURL}/signin/otp/email`;
287
+ const res = await fetch(url, {
288
+ ...options,
289
+ method: "POST",
290
+ headers: {
291
+ "Content-Type": "application/json",
292
+ ...options?.headers
293
+ },
294
+ body: JSON.stringify(body)
295
+ });
296
+ if (res.status >= 300) {
297
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
298
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
299
+ throw new FetchError(payload2, res.status, res.headers);
300
+ }
301
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
302
+ const payload = responseBody ? JSON.parse(responseBody) : {};
303
+ return {
304
+ body: payload,
305
+ status: res.status,
306
+ headers: res.headers
307
+ };
308
+ };
309
+ const verifySignInOTPEmail = async (body, options) => {
310
+ const url = `${baseURL}/signin/otp/email/verify`;
311
+ const res = await fetch(url, {
312
+ ...options,
313
+ method: "POST",
314
+ headers: {
315
+ "Content-Type": "application/json",
316
+ ...options?.headers
317
+ },
318
+ body: JSON.stringify(body)
319
+ });
320
+ if (res.status >= 300) {
321
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
322
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
323
+ throw new FetchError(payload2, res.status, res.headers);
324
+ }
325
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
326
+ const payload = responseBody ? JSON.parse(responseBody) : {};
327
+ return {
328
+ body: payload,
329
+ status: res.status,
330
+ headers: res.headers
331
+ };
332
+ };
333
+ const signInPasswordlessEmail = async (body, options) => {
334
+ const url = `${baseURL}/signin/passwordless/email`;
335
+ const res = await fetch(url, {
336
+ ...options,
337
+ method: "POST",
338
+ headers: {
339
+ "Content-Type": "application/json",
340
+ ...options?.headers
341
+ },
342
+ body: JSON.stringify(body)
343
+ });
344
+ if (res.status >= 300) {
345
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
346
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
347
+ throw new FetchError(payload2, res.status, res.headers);
348
+ }
349
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
350
+ const payload = responseBody ? JSON.parse(responseBody) : {};
351
+ return {
352
+ body: payload,
353
+ status: res.status,
354
+ headers: res.headers
355
+ };
356
+ };
357
+ const signInPasswordlessSms = async (body, options) => {
358
+ const url = `${baseURL}/signin/passwordless/sms`;
359
+ const res = await fetch(url, {
360
+ ...options,
361
+ method: "POST",
362
+ headers: {
363
+ "Content-Type": "application/json",
364
+ ...options?.headers
365
+ },
366
+ body: JSON.stringify(body)
367
+ });
368
+ if (res.status >= 300) {
369
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
370
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
371
+ throw new FetchError(payload2, res.status, res.headers);
372
+ }
373
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
374
+ const payload = responseBody ? JSON.parse(responseBody) : {};
375
+ return {
376
+ body: payload,
377
+ status: res.status,
378
+ headers: res.headers
379
+ };
380
+ };
381
+ const verifySignInPasswordlessSms = async (body, options) => {
382
+ const url = `${baseURL}/signin/passwordless/sms/otp`;
383
+ const res = await fetch(url, {
384
+ ...options,
385
+ method: "POST",
386
+ headers: {
387
+ "Content-Type": "application/json",
388
+ ...options?.headers
389
+ },
390
+ body: JSON.stringify(body)
391
+ });
392
+ if (res.status >= 300) {
393
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
394
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
395
+ throw new FetchError(payload2, res.status, res.headers);
396
+ }
397
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
398
+ const payload = responseBody ? JSON.parse(responseBody) : {};
399
+ return {
400
+ body: payload,
401
+ status: res.status,
402
+ headers: res.headers
403
+ };
404
+ };
405
+ const signInPAT = async (body, options) => {
406
+ const url = `${baseURL}/signin/pat`;
407
+ const res = await fetch(url, {
408
+ ...options,
409
+ method: "POST",
410
+ headers: {
411
+ "Content-Type": "application/json",
412
+ ...options?.headers
413
+ },
414
+ body: JSON.stringify(body)
415
+ });
416
+ if (res.status >= 300) {
417
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
418
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
419
+ throw new FetchError(payload2, res.status, res.headers);
420
+ }
421
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
422
+ const payload = responseBody ? JSON.parse(responseBody) : {};
423
+ return {
424
+ body: payload,
425
+ status: res.status,
426
+ headers: res.headers
427
+ };
428
+ };
429
+ const signInProviderURL = (provider, params) => {
430
+ const encodedParameters = params && Object.entries(params).map(([key, value]) => {
431
+ const stringValue = Array.isArray(value) ? value.join(",") : typeof value === "object" ? JSON.stringify(value) : value;
432
+ return `${key}=${encodeURIComponent(stringValue)}`;
433
+ }).join("&");
434
+ const url = encodedParameters ? `${baseURL}/signin/provider/${provider}?${encodedParameters}` : `${baseURL}/signin/provider/${provider}`;
435
+ return url;
436
+ };
437
+ const signInWebauthn = async (body, options) => {
438
+ const url = `${baseURL}/signin/webauthn`;
439
+ const res = await fetch(url, {
440
+ ...options,
441
+ method: "POST",
442
+ headers: {
443
+ "Content-Type": "application/json",
444
+ ...options?.headers
445
+ },
446
+ body: JSON.stringify(body)
447
+ });
448
+ if (res.status >= 300) {
449
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
450
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
451
+ throw new FetchError(payload2, res.status, res.headers);
452
+ }
453
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
454
+ const payload = responseBody ? JSON.parse(responseBody) : {};
455
+ return {
456
+ body: payload,
457
+ status: res.status,
458
+ headers: res.headers
459
+ };
460
+ };
461
+ const verifySignInWebauthn = async (body, options) => {
462
+ const url = `${baseURL}/signin/webauthn/verify`;
463
+ const res = await fetch(url, {
464
+ ...options,
465
+ method: "POST",
466
+ headers: {
467
+ "Content-Type": "application/json",
468
+ ...options?.headers
469
+ },
470
+ body: JSON.stringify(body)
471
+ });
472
+ if (res.status >= 300) {
473
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
474
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
475
+ throw new FetchError(payload2, res.status, res.headers);
476
+ }
477
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
478
+ const payload = responseBody ? JSON.parse(responseBody) : {};
479
+ return {
480
+ body: payload,
481
+ status: res.status,
482
+ headers: res.headers
483
+ };
484
+ };
485
+ const signOut = async (body, options) => {
486
+ const url = `${baseURL}/signout`;
487
+ const res = await fetch(url, {
488
+ ...options,
489
+ method: "POST",
490
+ headers: {
491
+ "Content-Type": "application/json",
492
+ ...options?.headers
493
+ },
494
+ body: JSON.stringify(body)
495
+ });
496
+ if (res.status >= 300) {
497
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
498
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
499
+ throw new FetchError(payload2, res.status, res.headers);
500
+ }
501
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
502
+ const payload = responseBody ? JSON.parse(responseBody) : {};
503
+ return {
504
+ body: payload,
505
+ status: res.status,
506
+ headers: res.headers
507
+ };
508
+ };
509
+ const signUpEmailPassword = async (body, options) => {
510
+ const url = `${baseURL}/signup/email-password`;
511
+ const res = await fetch(url, {
512
+ ...options,
513
+ method: "POST",
514
+ headers: {
515
+ "Content-Type": "application/json",
516
+ ...options?.headers
517
+ },
518
+ body: JSON.stringify(body)
519
+ });
520
+ if (res.status >= 300) {
521
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
522
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
523
+ throw new FetchError(payload2, res.status, res.headers);
524
+ }
525
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
526
+ const payload = responseBody ? JSON.parse(responseBody) : {};
527
+ return {
528
+ body: payload,
529
+ status: res.status,
530
+ headers: res.headers
531
+ };
532
+ };
533
+ const signUpWebauthn = async (body, options) => {
534
+ const url = `${baseURL}/signup/webauthn`;
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 responseBody2 = [412].includes(res.status) ? null : await res.text();
546
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
547
+ throw new FetchError(payload2, res.status, res.headers);
548
+ }
549
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
550
+ const payload = responseBody ? JSON.parse(responseBody) : {};
551
+ return {
552
+ body: payload,
553
+ status: res.status,
554
+ headers: res.headers
555
+ };
556
+ };
557
+ const verifySignUpWebauthn = async (body, options) => {
558
+ const url = `${baseURL}/signup/webauthn/verify`;
559
+ const res = await fetch(url, {
560
+ ...options,
561
+ method: "POST",
562
+ headers: {
563
+ "Content-Type": "application/json",
564
+ ...options?.headers
565
+ },
566
+ body: JSON.stringify(body)
567
+ });
568
+ if (res.status >= 300) {
569
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
570
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
571
+ throw new FetchError(payload2, res.status, res.headers);
572
+ }
573
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
574
+ const payload = responseBody ? JSON.parse(responseBody) : {};
575
+ return {
576
+ body: payload,
577
+ status: res.status,
578
+ headers: res.headers
579
+ };
580
+ };
581
+ const refreshToken = async (body, options) => {
582
+ const url = `${baseURL}/token`;
583
+ const res = await fetch(url, {
584
+ ...options,
585
+ method: "POST",
586
+ headers: {
587
+ "Content-Type": "application/json",
588
+ ...options?.headers
589
+ },
590
+ body: JSON.stringify(body)
591
+ });
592
+ if (res.status >= 300) {
593
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
594
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
595
+ throw new FetchError(payload2, res.status, res.headers);
596
+ }
597
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
598
+ const payload = responseBody ? JSON.parse(responseBody) : {};
599
+ return {
600
+ body: payload,
601
+ status: res.status,
602
+ headers: res.headers
603
+ };
604
+ };
605
+ const verifyToken = async (body, options) => {
606
+ const url = `${baseURL}/token/verify`;
607
+ const res = await fetch(url, {
608
+ ...options,
609
+ method: "POST",
610
+ headers: {
611
+ "Content-Type": "application/json",
612
+ ...options?.headers
613
+ },
614
+ body: JSON.stringify(body)
615
+ });
616
+ if (res.status >= 300) {
617
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
618
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
619
+ throw new FetchError(payload2, res.status, res.headers);
620
+ }
621
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
622
+ const payload = responseBody ? JSON.parse(responseBody) : {};
623
+ return {
624
+ body: payload,
625
+ status: res.status,
626
+ headers: res.headers
627
+ };
628
+ };
629
+ const getUser = async (options) => {
630
+ const url = `${baseURL}/user`;
631
+ const res = await fetch(url, {
632
+ ...options,
633
+ method: "GET",
634
+ headers: {
635
+ ...options?.headers
636
+ }
637
+ });
638
+ if (res.status >= 300) {
639
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
640
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
641
+ throw new FetchError(payload2, res.status, res.headers);
642
+ }
643
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
644
+ const payload = responseBody ? JSON.parse(responseBody) : {};
645
+ return {
646
+ body: payload,
647
+ status: res.status,
648
+ headers: res.headers
649
+ };
650
+ };
651
+ const deanonymizeUser = async (body, options) => {
652
+ const url = `${baseURL}/user/deanonymize`;
653
+ const res = await fetch(url, {
654
+ ...options,
655
+ method: "POST",
656
+ headers: {
657
+ "Content-Type": "application/json",
658
+ ...options?.headers
659
+ },
660
+ body: JSON.stringify(body)
661
+ });
662
+ if (res.status >= 300) {
663
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
664
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
665
+ throw new FetchError(payload2, res.status, res.headers);
666
+ }
667
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
668
+ const payload = responseBody ? JSON.parse(responseBody) : {};
669
+ return {
670
+ body: payload,
671
+ status: res.status,
672
+ headers: res.headers
673
+ };
674
+ };
675
+ const changeUserEmail = async (body, options) => {
676
+ const url = `${baseURL}/user/email/change`;
677
+ const res = await fetch(url, {
678
+ ...options,
679
+ method: "POST",
680
+ headers: {
681
+ "Content-Type": "application/json",
682
+ ...options?.headers
683
+ },
684
+ body: JSON.stringify(body)
685
+ });
686
+ if (res.status >= 300) {
687
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
688
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
689
+ throw new FetchError(payload2, res.status, res.headers);
690
+ }
691
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
692
+ const payload = responseBody ? JSON.parse(responseBody) : {};
693
+ return {
694
+ body: payload,
695
+ status: res.status,
696
+ headers: res.headers
697
+ };
698
+ };
699
+ const sendVerificationEmail = async (body, options) => {
700
+ const url = `${baseURL}/user/email/send-verification-email`;
701
+ const res = await fetch(url, {
702
+ ...options,
703
+ method: "POST",
704
+ headers: {
705
+ "Content-Type": "application/json",
706
+ ...options?.headers
707
+ },
708
+ body: JSON.stringify(body)
709
+ });
710
+ if (res.status >= 300) {
711
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
712
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
713
+ throw new FetchError(payload2, res.status, res.headers);
714
+ }
715
+ const responseBody = [204, 205, 304].includes(res.status) ? null : 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 verifyChangeUserMfa = async (body, options) => {
724
+ const url = `${baseURL}/user/mfa`;
725
+ const res = await fetch(url, {
726
+ ...options,
727
+ method: "POST",
728
+ headers: {
729
+ "Content-Type": "application/json",
730
+ ...options?.headers
731
+ },
732
+ body: JSON.stringify(body)
733
+ });
734
+ if (res.status >= 300) {
735
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
736
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
737
+ throw new FetchError(payload2, res.status, res.headers);
738
+ }
739
+ const responseBody = [204, 205, 304].includes(res.status) ? null : 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 changeUserPassword = async (body, options) => {
748
+ const url = `${baseURL}/user/password`;
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 responseBody2 = [412].includes(res.status) ? null : await res.text();
760
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
761
+ throw new FetchError(payload2, res.status, res.headers);
762
+ }
763
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
764
+ const payload = responseBody ? JSON.parse(responseBody) : {};
765
+ return {
766
+ body: payload,
767
+ status: res.status,
768
+ headers: res.headers
769
+ };
770
+ };
771
+ const sendPasswordResetEmail = async (body, options) => {
772
+ const url = `${baseURL}/user/password/reset`;
773
+ const res = await fetch(url, {
774
+ ...options,
775
+ method: "POST",
776
+ headers: {
777
+ "Content-Type": "application/json",
778
+ ...options?.headers
779
+ },
780
+ body: JSON.stringify(body)
781
+ });
782
+ if (res.status >= 300) {
783
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
784
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
785
+ throw new FetchError(payload2, res.status, res.headers);
786
+ }
787
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
788
+ const payload = responseBody ? JSON.parse(responseBody) : {};
789
+ return {
790
+ body: payload,
791
+ status: res.status,
792
+ headers: res.headers
793
+ };
794
+ };
795
+ const addSecurityKey = async (options) => {
796
+ const url = `${baseURL}/user/webauthn/add`;
797
+ const res = await fetch(url, {
798
+ ...options,
799
+ method: "POST",
800
+ headers: {
801
+ ...options?.headers
802
+ }
803
+ });
804
+ if (res.status >= 300) {
805
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
806
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
807
+ throw new FetchError(payload2, res.status, res.headers);
808
+ }
809
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
810
+ const payload = responseBody ? JSON.parse(responseBody) : {};
811
+ return {
812
+ body: payload,
813
+ status: res.status,
814
+ headers: res.headers
815
+ };
816
+ };
817
+ const verifyAddSecurityKey = async (body, options) => {
818
+ const url = `${baseURL}/user/webauthn/verify`;
819
+ const res = await fetch(url, {
820
+ ...options,
821
+ method: "POST",
822
+ headers: {
823
+ "Content-Type": "application/json",
824
+ ...options?.headers
825
+ },
826
+ body: JSON.stringify(body)
827
+ });
828
+ if (res.status >= 300) {
829
+ const responseBody2 = [412].includes(res.status) ? null : await res.text();
830
+ const payload2 = responseBody2 ? JSON.parse(responseBody2) : {};
831
+ throw new FetchError(payload2, res.status, res.headers);
832
+ }
833
+ const responseBody = [204, 205, 304].includes(res.status) ? null : await res.text();
834
+ const payload = responseBody ? JSON.parse(responseBody) : {};
835
+ return {
836
+ body: payload,
837
+ status: res.status,
838
+ headers: res.headers
839
+ };
840
+ };
841
+ const verifyTicketURL = (params) => {
842
+ const encodedParameters = params && Object.entries(params).map(([key, value]) => {
843
+ const stringValue = Array.isArray(value) ? value.join(",") : typeof value === "object" ? JSON.stringify(value) : value;
844
+ return `${key}=${encodeURIComponent(stringValue)}`;
845
+ }).join("&");
846
+ const url = encodedParameters ? `${baseURL}/verify?${encodedParameters}` : `${baseURL}/verify`;
847
+ return url;
848
+ };
849
+ const getVersion = async (options) => {
850
+ const url = `${baseURL}/version`;
851
+ const res = await fetch(url, {
852
+ ...options,
853
+ method: "GET",
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
+ return {
872
+ baseURL,
873
+ pushChainFunction,
874
+ getJWKs,
875
+ elevateWebauthn,
876
+ verifyElevateWebauthn,
877
+ healthCheckGet,
878
+ healthCheckHead,
879
+ linkIdToken,
880
+ changeUserMfa,
881
+ createPAT,
882
+ signInAnonymous,
883
+ signInEmailPassword,
884
+ signInIdToken,
885
+ verifySignInMfaTotp,
886
+ signInOTPEmail,
887
+ verifySignInOTPEmail,
888
+ signInPasswordlessEmail,
889
+ signInPasswordlessSms,
890
+ verifySignInPasswordlessSms,
891
+ signInPAT,
892
+ signInProviderURL,
893
+ signInWebauthn,
894
+ verifySignInWebauthn,
895
+ signOut,
896
+ signUpEmailPassword,
897
+ signUpWebauthn,
898
+ verifySignUpWebauthn,
899
+ refreshToken,
900
+ verifyToken,
901
+ getUser,
902
+ deanonymizeUser,
903
+ changeUserEmail,
904
+ sendVerificationEmail,
905
+ verifyChangeUserMfa,
906
+ changeUserPassword,
907
+ sendPasswordResetEmail,
908
+ addSecurityKey,
909
+ verifyAddSecurityKey,
910
+ verifyTicketURL,
911
+ getVersion
912
+ };
913
+ };
914
+ export {
915
+ createAPIClient
916
+ };
917
+ //# sourceMappingURL=auth.es.js.map