@nhost/nhost-js 4.2.2 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/fetch-2PHmQBIJ.js.map +1 -1
  2. package/dist/fetch-DWXwEnoe.cjs.map +1 -1
  3. package/dist/{middlewareWithAdminSession-DLqDQUbW.js → middlewareWithAdminSession-BeIk-9HO.js} +2 -2
  4. package/dist/middlewareWithAdminSession-BeIk-9HO.js.map +1 -0
  5. package/dist/middlewareWithAdminSession-DDApoLkL.cjs.map +1 -1
  6. package/dist/nhost-js/auth.cjs.map +1 -1
  7. package/dist/nhost-js/auth.js.map +1 -1
  8. package/dist/nhost-js/fetch.cjs.map +1 -1
  9. package/dist/nhost-js/fetch.js +1 -1
  10. package/dist/nhost-js/fetch.js.map +1 -1
  11. package/dist/nhost-js/functions.cjs.map +1 -1
  12. package/dist/nhost-js/functions.js.map +1 -1
  13. package/dist/nhost-js/graphql.cjs.map +1 -1
  14. package/dist/nhost-js/graphql.js.map +1 -1
  15. package/dist/nhost-js/session.cjs.map +1 -1
  16. package/dist/nhost-js/session.js +1 -1
  17. package/dist/nhost-js/session.js.map +1 -1
  18. package/dist/nhost-js/storage.cjs.map +1 -1
  19. package/dist/nhost-js/storage.js.map +1 -1
  20. package/dist/nhost-js.cjs.map +1 -1
  21. package/dist/nhost-js.js +2 -2
  22. package/dist/nhost-js.js.map +1 -1
  23. package/dist/nhost-js.umd.js.map +1 -1
  24. package/dist/refreshSession-Bw715ZmX.cjs.map +1 -1
  25. package/dist/{refreshSession-CG8GIEun.js → refreshSession-WwGlzgtM.js} +2 -5
  26. package/dist/refreshSession-WwGlzgtM.js.map +1 -0
  27. package/dist/src/auth/client.d.ts +28 -28
  28. package/dist/src/auth/client.js +76 -76
  29. package/dist/src/auth/index.d.ts +1 -1
  30. package/dist/src/auth/index.js +1 -1
  31. package/dist/src/fetch/fetch.js +20 -20
  32. package/dist/src/fetch/index.d.ts +7 -7
  33. package/dist/src/fetch/index.js +7 -7
  34. package/dist/src/fetch/middlewareAttachAccessToken.d.ts +2 -2
  35. package/dist/src/fetch/middlewareAttachAccessToken.js +2 -2
  36. package/dist/src/fetch/middlewareSessionRefresh.d.ts +3 -3
  37. package/dist/src/fetch/middlewareSessionRefresh.js +3 -3
  38. package/dist/src/fetch/middlewareUpdateSessionFromResponse.d.ts +2 -2
  39. package/dist/src/fetch/middlewareUpdateSessionFromResponse.js +8 -8
  40. package/dist/src/fetch/middlewareWithAdminSession.d.ts +1 -1
  41. package/dist/src/fetch/middlewareWithAdminSession.js +5 -5
  42. package/dist/src/fetch/middlewareWithHeaders.d.ts +1 -1
  43. package/dist/src/fetch/middlewareWithRole.d.ts +1 -1
  44. package/dist/src/fetch/middlewareWithRole.js +2 -2
  45. package/dist/src/functions/client.d.ts +1 -1
  46. package/dist/src/functions/client.js +6 -6
  47. package/dist/src/functions/index.d.ts +1 -1
  48. package/dist/src/functions/index.js +1 -1
  49. package/dist/src/graphql/client.d.ts +2 -2
  50. package/dist/src/graphql/client.js +6 -6
  51. package/dist/src/graphql/index.d.ts +1 -1
  52. package/dist/src/graphql/index.js +1 -1
  53. package/dist/src/index.d.ts +1 -1
  54. package/dist/src/index.js +1 -1
  55. package/dist/src/nhost.d.ts +6 -6
  56. package/dist/src/nhost.js +11 -11
  57. package/dist/src/session/index.d.ts +4 -4
  58. package/dist/src/session/index.js +3 -3
  59. package/dist/src/session/refreshSession.d.ts +3 -3
  60. package/dist/src/session/refreshSession.d.ts.map +1 -1
  61. package/dist/src/session/refreshSession.js +5 -7
  62. package/dist/src/session/refreshSession.js.map +1 -1
  63. package/dist/src/session/session.d.ts +2 -2
  64. package/dist/src/session/session.js +15 -15
  65. package/dist/src/session/storage.d.ts +3 -3
  66. package/dist/src/session/storage.js +4 -4
  67. package/dist/src/session/storageBackend.d.ts +2 -2
  68. package/dist/src/session/storageBackend.js +7 -7
  69. package/dist/src/storage/client.d.ts +5 -5
  70. package/dist/src/storage/client.js +44 -44
  71. package/dist/src/storage/index.d.ts +1 -1
  72. package/dist/src/storage/index.js +1 -1
  73. package/dist/tsconfig.tsbuildinfo +1 -1
  74. package/package.json +1 -2
  75. package/dist/middlewareWithAdminSession-DLqDQUbW.js.map +0 -1
  76. package/dist/refreshSession-CG8GIEun.js.map +0 -1
@@ -4,7 +4,7 @@
4
4
  * This module provides different storage adapters for persisting authentication sessions
5
5
  * across page reloads and browser sessions.
6
6
  */
7
- import type { Session } from "./session";
7
+ import type { Session } from './session';
8
8
  /**
9
9
  * Session storage interface for session persistence.
10
10
  * This interface can be implemented to provide custom storage solutions.
@@ -102,7 +102,7 @@ export declare class CookieStorage implements SessionStorageBackend {
102
102
  cookieName?: string;
103
103
  expirationDays?: number;
104
104
  secure?: boolean;
105
- sameSite?: "strict" | "lax" | "none";
105
+ sameSite?: 'strict' | 'lax' | 'none';
106
106
  });
107
107
  /**
108
108
  * Gets the session from cookies
@@ -7,7 +7,7 @@
7
7
  /**
8
8
  * Default storage key used for storing the Nhost session
9
9
  */
10
- export const DEFAULT_SESSION_KEY = "nhostSession";
10
+ export const DEFAULT_SESSION_KEY = 'nhostSession';
11
11
  /**
12
12
  * Browser localStorage implementation of StorageInterface.
13
13
  * Persists the session across page reloads and browser restarts.
@@ -100,19 +100,19 @@ export class CookieStorage {
100
100
  this.cookieName = options?.cookieName || DEFAULT_SESSION_KEY;
101
101
  this.expirationDays = options?.expirationDays ?? 30;
102
102
  this.secure = options?.secure ?? true;
103
- this.sameSite = options?.sameSite || "lax";
103
+ this.sameSite = options?.sameSite || 'lax';
104
104
  }
105
105
  /**
106
106
  * Gets the session from cookies
107
107
  * @returns The stored session or null if not found
108
108
  */
109
109
  get() {
110
- const cookies = document.cookie.split(";");
110
+ const cookies = document.cookie.split(';');
111
111
  for (const cookie of cookies) {
112
- const [name, value] = cookie.trim().split("=");
112
+ const [name, value] = cookie.trim().split('=');
113
113
  if (name === this.cookieName) {
114
114
  try {
115
- return JSON.parse(decodeURIComponent(value || ""));
115
+ return JSON.parse(decodeURIComponent(value || ''));
116
116
  }
117
117
  catch {
118
118
  this.remove();
@@ -130,7 +130,7 @@ export class CookieStorage {
130
130
  const expires = new Date();
131
131
  expires.setTime(expires.getTime() + this.expirationDays * 24 * 60 * 60 * 1000);
132
132
  const cookieValue = encodeURIComponent(JSON.stringify(value));
133
- const cookieString = `${this.cookieName}=${cookieValue}; expires=${expires.toUTCString()}; path=/; ${this.secure ? "secure; " : ""}SameSite=${this.sameSite}`;
133
+ const cookieString = `${this.cookieName}=${cookieValue}; expires=${expires.toUTCString()}; path=/; ${this.secure ? 'secure; ' : ''}SameSite=${this.sameSite}`;
134
134
  // biome-ignore lint/suspicious/noDocumentCookie: this is unnecessary
135
135
  document.cookie = cookieString;
136
136
  }
@@ -139,7 +139,7 @@ export class CookieStorage {
139
139
  */
140
140
  remove() {
141
141
  // biome-ignore lint/suspicious/noDocumentCookie: this is unnecessary
142
- document.cookie = `${this.cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; ${this.secure ? "secure; " : ""}SameSite=${this.sameSite}`;
142
+ document.cookie = `${this.cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; ${this.secure ? 'secure; ' : ''}SameSite=${this.sameSite}`;
143
143
  }
144
144
  }
145
145
  //# sourceMappingURL=storageBackend.js.map
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file is auto-generated. Do not edit manually.
3
3
  */
4
- import type { ChainFunction, FetchResponse } from "../fetch";
4
+ import type { ChainFunction, FetchResponse } from '../fetch';
5
5
  /**
6
6
  * Date in RFC 2822 format
7
7
  */
@@ -255,7 +255,7 @@ export interface VersionInformation {
255
255
  /**
256
256
  * Output format for image files. Use 'auto' for content negotiation based on Accept header
257
257
  */
258
- export type OutputImageFormat = "auto" | "same" | "jpeg" | "webp" | "png" | "avif" | "heic";
258
+ export type OutputImageFormat = 'auto' | 'same' | 'jpeg' | 'webp' | 'png' | 'avif' | 'heic';
259
259
  /**
260
260
  *
261
261
  @property bucket-id? (`string`) - Target bucket identifier where files will be stored.
@@ -267,15 +267,15 @@ export interface UploadFilesBody {
267
267
  * Target bucket identifier where files will be stored.
268
268
  * Example - `"user-uploads"`
269
269
  */
270
- "bucket-id"?: string;
270
+ 'bucket-id'?: string;
271
271
  /**
272
272
  * Optional custom metadata for each uploaded file. Must match the order of the file[] array.
273
273
  */
274
- "metadata[]"?: UploadFileMetadata[];
274
+ 'metadata[]'?: UploadFileMetadata[];
275
275
  /**
276
276
  * Array of files to upload.
277
277
  */
278
- "file[]": Blob[];
278
+ 'file[]': Blob[];
279
279
  }
280
280
  /**
281
281
  *
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file is auto-generated. Do not edit manually.
3
3
  */
4
- import { createEnhancedFetch, FetchError } from "../fetch";
4
+ import { createEnhancedFetch, FetchError } from '../fetch';
5
5
  export const createAPIClient = (baseURL, chainFunctions = []) => {
6
6
  let fetch = createEnhancedFetch(chainFunctions);
7
7
  const pushChainFunction = (chainFunction) => {
@@ -11,33 +11,33 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
11
11
  const uploadFiles = async (body, options) => {
12
12
  const url = `${baseURL}/files`;
13
13
  const formData = new FormData();
14
- const isReactNative = typeof navigator !== "undefined" &&
15
- navigator.product === "ReactNative";
16
- if (body["bucket-id"] !== undefined) {
17
- formData.append("bucket-id", body["bucket-id"]);
14
+ const isReactNative = typeof navigator !== 'undefined' &&
15
+ navigator.product === 'ReactNative';
16
+ if (body['bucket-id'] !== undefined) {
17
+ formData.append('bucket-id', body['bucket-id']);
18
18
  }
19
- if (body["metadata[]"] !== undefined) {
20
- body["metadata[]"].forEach((value) => {
19
+ if (body['metadata[]'] !== undefined) {
20
+ body['metadata[]'].forEach((value) => {
21
21
  if (isReactNative) {
22
- formData.append("metadata[]", {
22
+ formData.append('metadata[]', {
23
23
  string: JSON.stringify(value),
24
- type: "application/json",
25
- name: "",
24
+ type: 'application/json',
25
+ name: '',
26
26
  });
27
27
  }
28
28
  else {
29
- formData.append("metadata[]", new Blob([JSON.stringify(value)], { type: "application/json" }), "");
29
+ formData.append('metadata[]', new Blob([JSON.stringify(value)], { type: 'application/json' }), '');
30
30
  }
31
31
  });
32
32
  }
33
- if (body["file[]"] !== undefined) {
34
- body["file[]"].forEach((value) => {
35
- formData.append("file[]", value);
33
+ if (body['file[]'] !== undefined) {
34
+ body['file[]'].forEach((value) => {
35
+ formData.append('file[]', value);
36
36
  });
37
37
  }
38
38
  const res = await fetch(url, {
39
39
  ...options,
40
- method: "POST",
40
+ method: 'POST',
41
41
  body: formData,
42
42
  });
43
43
  if (res.status >= 300) {
@@ -61,7 +61,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
61
61
  const url = `${baseURL}/files/${id}`;
62
62
  const res = await fetch(url, {
63
63
  ...options,
64
- method: "DELETE",
64
+ method: 'DELETE',
65
65
  headers: {
66
66
  ...options?.headers,
67
67
  },
@@ -84,19 +84,19 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
84
84
  .flatMap(([key, value]) => {
85
85
  // Default handling (scalars or explode: false)
86
86
  const stringValue = Array.isArray(value)
87
- ? value.join(",")
88
- : typeof value === "object" && value !== null
87
+ ? value.join(',')
88
+ : typeof value === 'object' && value !== null
89
89
  ? JSON.stringify(value)
90
90
  : String(value);
91
91
  return [`${key}=${encodeURIComponent(stringValue)}`];
92
92
  })
93
- .join("&");
93
+ .join('&');
94
94
  const url = encodedParameters
95
95
  ? `${baseURL}/files/${id}?${encodedParameters}`
96
96
  : `${baseURL}/files/${id}`;
97
97
  const res = await fetch(url, {
98
98
  ...options,
99
- method: "GET",
99
+ method: 'GET',
100
100
  headers: {
101
101
  ...options?.headers,
102
102
  },
@@ -119,19 +119,19 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
119
119
  .flatMap(([key, value]) => {
120
120
  // Default handling (scalars or explode: false)
121
121
  const stringValue = Array.isArray(value)
122
- ? value.join(",")
123
- : typeof value === "object" && value !== null
122
+ ? value.join(',')
123
+ : typeof value === 'object' && value !== null
124
124
  ? JSON.stringify(value)
125
125
  : String(value);
126
126
  return [`${key}=${encodeURIComponent(stringValue)}`];
127
127
  })
128
- .join("&");
128
+ .join('&');
129
129
  const url = encodedParameters
130
130
  ? `${baseURL}/files/${id}?${encodedParameters}`
131
131
  : `${baseURL}/files/${id}`;
132
132
  const res = await fetch(url, {
133
133
  ...options,
134
- method: "HEAD",
134
+ method: 'HEAD',
135
135
  headers: {
136
136
  ...options?.headers,
137
137
  },
@@ -151,28 +151,28 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
151
151
  const replaceFile = async (id, body, options) => {
152
152
  const url = `${baseURL}/files/${id}`;
153
153
  const formData = new FormData();
154
- const isReactNative = typeof navigator !== "undefined" &&
155
- navigator.product === "ReactNative";
156
- if (body["metadata"] !== undefined) {
154
+ const isReactNative = typeof navigator !== 'undefined' &&
155
+ navigator.product === 'ReactNative';
156
+ if (body['metadata'] !== undefined) {
157
157
  if (isReactNative) {
158
- formData.append("metadata", {
159
- string: JSON.stringify(body["metadata"]),
160
- type: "application/json",
161
- name: "",
158
+ formData.append('metadata', {
159
+ string: JSON.stringify(body['metadata']),
160
+ type: 'application/json',
161
+ name: '',
162
162
  });
163
163
  }
164
164
  else {
165
- formData.append("metadata", new Blob([JSON.stringify(body["metadata"])], {
166
- type: "application/json",
167
- }), "");
165
+ formData.append('metadata', new Blob([JSON.stringify(body['metadata'])], {
166
+ type: 'application/json',
167
+ }), '');
168
168
  }
169
169
  }
170
- if (body["file"] !== undefined) {
171
- formData.append("file", body["file"]);
170
+ if (body['file'] !== undefined) {
171
+ formData.append('file', body['file']);
172
172
  }
173
173
  const res = await fetch(url, {
174
174
  ...options,
175
- method: "PUT",
175
+ method: 'PUT',
176
176
  body: formData,
177
177
  });
178
178
  if (res.status >= 300) {
@@ -194,7 +194,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
194
194
  const url = `${baseURL}/files/${id}/presignedurl`;
195
195
  const res = await fetch(url, {
196
196
  ...options,
197
- method: "GET",
197
+ method: 'GET',
198
198
  headers: {
199
199
  ...options?.headers,
200
200
  },
@@ -220,7 +220,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
220
220
  const url = `${baseURL}/ops/delete-broken-metadata`;
221
221
  const res = await fetch(url, {
222
222
  ...options,
223
- method: "POST",
223
+ method: 'POST',
224
224
  headers: {
225
225
  ...options?.headers,
226
226
  },
@@ -246,7 +246,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
246
246
  const url = `${baseURL}/ops/delete-orphans`;
247
247
  const res = await fetch(url, {
248
248
  ...options,
249
- method: "POST",
249
+ method: 'POST',
250
250
  headers: {
251
251
  ...options?.headers,
252
252
  },
@@ -272,7 +272,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
272
272
  const url = `${baseURL}/ops/list-broken-metadata`;
273
273
  const res = await fetch(url, {
274
274
  ...options,
275
- method: "POST",
275
+ method: 'POST',
276
276
  headers: {
277
277
  ...options?.headers,
278
278
  },
@@ -298,7 +298,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
298
298
  const url = `${baseURL}/ops/list-not-uploaded`;
299
299
  const res = await fetch(url, {
300
300
  ...options,
301
- method: "POST",
301
+ method: 'POST',
302
302
  headers: {
303
303
  ...options?.headers,
304
304
  },
@@ -324,7 +324,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
324
324
  const url = `${baseURL}/ops/list-orphans`;
325
325
  const res = await fetch(url, {
326
326
  ...options,
327
- method: "POST",
327
+ method: 'POST',
328
328
  headers: {
329
329
  ...options?.headers,
330
330
  },
@@ -350,7 +350,7 @@ export const createAPIClient = (baseURL, chainFunctions = []) => {
350
350
  const url = `${baseURL}/version`;
351
351
  const res = await fetch(url, {
352
352
  ...options,
353
- method: "GET",
353
+ method: 'GET',
354
354
  headers: {
355
355
  ...options?.headers,
356
356
  },
@@ -33,5 +33,5 @@
33
33
  * @module storage
34
34
  * @packageDocumentation
35
35
  */
36
- export * from "./client";
36
+ export * from './client';
37
37
  //# sourceMappingURL=index.d.ts.map
@@ -33,5 +33,5 @@
33
33
  * @module storage
34
34
  * @packageDocumentation
35
35
  */
36
- export * from "./client";
36
+ export * from './client';
37
37
  //# sourceMappingURL=index.js.map