@meistrari/vault-sdk 1.0.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,6 +1,37 @@
1
1
  'use strict';
2
2
 
3
3
  const schemas = require('@meistrari/vault-shared/schemas');
4
+ const fileType = require('file-type');
5
+ const mimeTypes = require('mime-types');
6
+
7
+ var __defProp$1 = Object.defineProperty;
8
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __publicField$1 = (obj, key, value) => {
10
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
11
+ return value;
12
+ };
13
+ class DataTokenAuthStrategy {
14
+ constructor(dataToken) {
15
+ __publicField$1(this, "dataToken");
16
+ this.dataToken = dataToken;
17
+ }
18
+ getHeaders() {
19
+ return new Headers({
20
+ "x-data-token": this.dataToken
21
+ });
22
+ }
23
+ }
24
+ class APIKeyAuthStrategy {
25
+ constructor(apiKey) {
26
+ __publicField$1(this, "apiKey");
27
+ this.apiKey = apiKey;
28
+ }
29
+ getHeaders() {
30
+ return new Headers({
31
+ Authorization: this.apiKey
32
+ });
33
+ }
34
+ }
4
35
 
5
36
  class FetchError extends Error {
6
37
  constructor(message, url, method, response) {
@@ -34,11 +65,30 @@ async function getFileHash(blob) {
34
65
  const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
35
66
  return hashHex;
36
67
  }
68
+ async function detectFileMimeType(blob) {
69
+ const result = await fileType.fileTypeFromBlob(blob).catch(() => void 0);
70
+ if (result?.mime) {
71
+ return result.mime;
72
+ }
73
+ if ("name" in blob && typeof blob.name === "string") {
74
+ const extension = blob.name.split(".").pop()?.toLowerCase();
75
+ if (extension) {
76
+ const mimeType = mimeTypes.lookup(`.${extension}`);
77
+ if (mimeType) {
78
+ return mimeType;
79
+ }
80
+ }
81
+ }
82
+ if (blob instanceof Blob && blob.type) {
83
+ return blob.type;
84
+ }
85
+ return void 0;
86
+ }
37
87
 
38
- var __defProp$1 = Object.defineProperty;
39
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
40
- var __publicField$1 = (obj, key, value) => {
41
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
88
+ var __defProp = Object.defineProperty;
89
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
90
+ var __publicField = (obj, key, value) => {
91
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
42
92
  return value;
43
93
  };
44
94
  const compatibilityDate = "2025-05-19";
@@ -67,13 +117,13 @@ class VaultFile {
67
117
  * @param params.metadata - The metadata of the file
68
118
  */
69
119
  constructor({ config, content, id, name, metadata }) {
70
- __publicField$1(this, "id");
71
- __publicField$1(this, "name");
72
- __publicField$1(this, "metadata");
73
- __publicField$1(this, "config");
74
- __publicField$1(this, "content");
75
- __publicField$1(this, "lastDownloadUrl");
76
- __publicField$1(this, "lastUploadUrl");
120
+ __publicField(this, "id");
121
+ __publicField(this, "name");
122
+ __publicField(this, "metadata");
123
+ __publicField(this, "config");
124
+ __publicField(this, "content");
125
+ __publicField(this, "lastDownloadUrl");
126
+ __publicField(this, "lastUploadUrl");
77
127
  this.config = config;
78
128
  this.content = content;
79
129
  this.id = id;
@@ -95,37 +145,46 @@ class VaultFile {
95
145
  * @param params.method - The method to use for the fetch
96
146
  * @param params.path - The path to fetch
97
147
  * @param params.body - The body of the request
148
+ * @param params.signal - The signal to abort the request
98
149
  * @returns The response from the vault
99
150
  * @throws {FetchError} If the fetch fails
100
151
  */
101
152
  async _fetch(params) {
102
- const { method, path, body } = params;
153
+ const { method, path, body, signal } = params;
103
154
  const url = new URL(this.config.vaultUrl + path).toString();
104
155
  const headers = new Headers(this.headers);
105
156
  headers.set("x-compatibility-date", compatibilityDate);
106
157
  const response = await wrappedFetch(url, {
107
158
  method,
108
159
  body,
109
- headers
160
+ headers,
161
+ signal
110
162
  });
111
163
  const content = await response.json();
112
164
  return content;
113
165
  }
114
166
  /**
115
167
  * Creates a new file in the vault.
168
+ * @param metadata - The metadata for creating a file
169
+ * @param metadata.size - The size of the file
170
+ * @param metadata.mimeType - The mime type of the file
171
+ * @param options - The options for the request
172
+ * @param options.signal - The signal to abort the request
116
173
  *
117
174
  * @returns The metadata of the file
118
175
  * @throws {Error} If the file ID is not set
119
176
  * @throws {FetchError} If the metadata fetch fails
120
177
  */
121
- async _createFile() {
178
+ async _createFile(metadata = {}, options) {
122
179
  const response = await this._fetch({
123
180
  method: "POST",
124
181
  path: `/v2/files`,
125
182
  body: JSON.stringify({
183
+ ...metadata,
126
184
  fileName: this.name,
127
185
  sha256sum: this.id ?? this.metadata?.id ?? (this.content ? await getFileHash(this.content) : void 0)
128
- })
186
+ }),
187
+ signal: options?.signal
129
188
  }).then((data) => schemas.GetUploadUrlResponseV2.safeParse(data));
130
189
  if (!response.success) {
131
190
  throw new Error(`Invalid response from vault service. ${JSON.stringify(response.error)}`);
@@ -142,6 +201,9 @@ class VaultFile {
142
201
  * @param params.reference - The reference to the file in the vault
143
202
  * @param params.config - The configuration for the VaultFile
144
203
  * @param params.download - Whether to download the file content (default: false)
204
+ * @param options - The options for the request
205
+ * @param options.signal - The signal to abort the request
206
+ *
145
207
  * @returns A new VaultFile instance
146
208
  *
147
209
  * @example
@@ -171,13 +233,14 @@ class VaultFile {
171
233
  * const content = vaultFile.content
172
234
  * ```
173
235
  */
174
- static async fromVaultReference(params) {
236
+ static async fromVaultReference(params, options) {
175
237
  const { reference, config, download = false } = params;
176
238
  const { vaultUrl, authStrategy } = config;
177
239
  const id = removeVaultPrefix(reference);
178
240
  const response = await wrappedFetch(`${vaultUrl}/v2/files/${id}`, {
179
241
  method: "GET",
180
- headers: authStrategy.getHeaders()
242
+ headers: authStrategy.getHeaders(),
243
+ signal: options?.signal
181
244
  }).then((response2) => response2.json()).then((data) => schemas.GetDownloadUrlResponse.safeParse(data));
182
245
  if (!response.success) {
183
246
  throw new Error("Invalid response from vault service");
@@ -192,7 +255,7 @@ class VaultFile {
192
255
  name: response.data.metadata?.originalFileName
193
256
  };
194
257
  if (download) {
195
- await wrappedFetch(response.data.url, { method: "GET" }).then((response2) => response2.blob()).then((blob) => fileParams.content = blob);
258
+ await wrappedFetch(response.data.url, { method: "GET", signal: options?.signal }).then((response2) => response2.blob()).then((blob) => fileParams.content = blob);
196
259
  }
197
260
  return new VaultFile(fileParams);
198
261
  }
@@ -204,6 +267,9 @@ class VaultFile {
204
267
  * @param params.content - The content of the file
205
268
  * @param params.config - The configuration for the VaultFile
206
269
  * @param params.upload - Whether to upload the file (default: false)
270
+ * @param options - The options for the request
271
+ * @param options.signal - The signal to abort the request
272
+ *
207
273
  * @returns A new VaultFile instance
208
274
  *
209
275
  * @example
@@ -236,10 +302,12 @@ class VaultFile {
236
302
  * })
237
303
  * ```
238
304
  */
239
- static async fromContent(params) {
305
+ static async fromContent(params, options) {
240
306
  const { name, content, config, upload = false } = params;
241
307
  const { vaultUrl, authStrategy } = config;
242
308
  const sha256sum = await getFileHash(content);
309
+ const mimeType = await detectFileMimeType(content);
310
+ const size = content.size;
243
311
  const file = new VaultFile({
244
312
  content,
245
313
  config: {
@@ -249,22 +317,27 @@ class VaultFile {
249
317
  id: sha256sum,
250
318
  name
251
319
  });
252
- const createdFile = await file._createFile();
320
+ const createdFile = await file._createFile({
321
+ size,
322
+ mimeType
323
+ }, { signal: options?.signal });
253
324
  if (upload) {
254
- await file.upload(file.content, createdFile.uploadUrl);
325
+ await file.upload(file.content, createdFile.uploadUrl, { signal: options?.signal });
255
326
  }
256
327
  return file;
257
328
  }
258
329
  /**
259
330
  * Populates the metadata of the file instance.
331
+ * @param options - The options for the request
332
+ * @param options.signal - The signal to abort the request
260
333
  *
261
334
  * @returns The file instance
262
335
  * @throws {Error} If the file ID is not set
263
336
  * @throws {FetchError} If the metadata fetch fails
264
337
  */
265
- async populateMetadata() {
338
+ async populateMetadata(options) {
266
339
  try {
267
- this.metadata = await this.getFileMetadata();
340
+ this.metadata = await this.getFileMetadata({ signal: options?.signal });
268
341
  this.name = this.metadata.originalFileName;
269
342
  this.id = this.metadata.id;
270
343
  return this;
@@ -286,29 +359,34 @@ class VaultFile {
286
359
  }
287
360
  /**
288
361
  * Fetches the metadata of the file.
362
+ * @param options - The options for the request
363
+ * @param options.signal - The signal to abort the request
289
364
  *
290
365
  * @returns The metadata of the file
291
366
  * @throws {Error} If the file ID is not set
292
367
  * @throws {FetchError} If the metadata fetch fails
293
368
  */
294
- async getFileMetadata() {
369
+ async getFileMetadata(options) {
295
370
  if (!this.id) {
296
371
  throw new Error("File ID is not set");
297
372
  }
298
373
  const response = await this._fetch({
299
374
  method: "GET",
300
- path: `/v2/files/${this.id}/metadata`
375
+ path: `/v2/files/${this.id}/metadata`,
376
+ signal: options?.signal
301
377
  });
302
378
  return response;
303
379
  }
304
380
  /**
305
381
  * Fetches a upload URL for the file.
382
+ * @param options - The options for the request
383
+ * @param options.signal - The signal to abort the request
306
384
  *
307
385
  * @returns The upload URL for the file
308
386
  * @throws {Error} If the vault service returns an invalid response
309
387
  * @throws {FetchError} If the upload URL fetch fails
310
388
  */
311
- async getUploadUrl() {
389
+ async getUploadUrl(options) {
312
390
  if (this.lastUploadUrl && this.lastUploadUrl.expiresAt > /* @__PURE__ */ new Date()) {
313
391
  return this.lastUploadUrl.url;
314
392
  }
@@ -322,7 +400,8 @@ class VaultFile {
322
400
  }
323
401
  const response = await this._fetch({
324
402
  method: "PUT",
325
- path: `/v2/files/${this.id}`
403
+ path: `/v2/files/${this.id}`,
404
+ signal: options?.signal
326
405
  }).then(schemas.GetUploadUrlResponseV2.safeParse);
327
406
  if (!response.success) {
328
407
  throw new Error(`Invalid response from vault service. ${JSON.stringify(response.error)}`);
@@ -332,13 +411,15 @@ class VaultFile {
332
411
  }
333
412
  /**
334
413
  * Fetches a download URL for the file.
414
+ * @param options - The options for the request
415
+ * @param options.signal - The signal to abort the request
335
416
  *
336
417
  * @returns The download URL for the file
337
418
  * @throws {Error} If the vault service returns an invalid response
338
419
  * @throws {Error} If not file ID, name or content is set
339
420
  * @throws {FetchError} If the download URL fetch fails
340
421
  */
341
- async getDownloadUrl() {
422
+ async getDownloadUrl(options) {
342
423
  if (this.lastDownloadUrl && this.lastDownloadUrl.expiresAt > /* @__PURE__ */ new Date()) {
343
424
  return this.lastDownloadUrl.url;
344
425
  }
@@ -348,7 +429,8 @@ class VaultFile {
348
429
  const id = this.id ?? this.metadata?.id ?? (this.content ? await getFileHash(this.content) : this.name);
349
430
  const response = await this._fetch({
350
431
  method: "GET",
351
- path: `/v2/files/${id}`
432
+ path: `/v2/files/${id}`,
433
+ signal: options?.signal
352
434
  });
353
435
  this.lastDownloadUrl = { url: new URL(response.url), expiresAt: new Date(response.expiresAt) };
354
436
  return this.lastDownloadUrl.url;
@@ -359,29 +441,48 @@ class VaultFile {
359
441
  * @example
360
442
  * ```ts
361
443
  * const file = new File(['content'], 'document.txt')
362
- * const vaultFile = await VaultFile.fromBlob('document.txt', file, { vaultUrl, authStrategy })
444
+ * const vaultFile = await VaultFile.fromContent({
445
+ * name: 'document.txt',
446
+ * content: file,
447
+ * config: {
448
+ * vaultUrl,
449
+ * authStrategy,
450
+ * },
451
+ * })
363
452
  * await vaultFile.upload(file)
364
453
  * ```
365
454
  *
366
455
  * @param file - The file to upload to the vault. If not provided, the file content will be taken from the `content` property.
456
+ * @param url - The URL to upload the file to. If not provided, the upload URL will be fetched from the vault.
457
+ * @param options - The options for the request
458
+ * @param options.signal - The signal to abort the request
459
+ *
367
460
  * @throws {FetchError} If the upload fails
368
461
  * @throws {Error} If the file content is not set and no file is provided
369
462
  * @returns Promise that resolves when upload is complete
370
463
  */
371
- async upload(file, url) {
372
- if (!file && !this.content) {
373
- throw new Error("Missing file content. Use fromBlob() to create a file with content, or provide a file to upload.");
464
+ async upload(file, url, options) {
465
+ const content = file ?? this.content;
466
+ if (!content) {
467
+ throw new Error("Missing file content. Use fromContent() to create a file with content, or provide a file to upload.");
374
468
  }
375
469
  const uploadUrl = url ?? await this.getUploadUrl();
470
+ const mimeType = this.metadata?.mimeType ?? await detectFileMimeType(content);
471
+ const headers = new Headers();
472
+ if (mimeType)
473
+ headers.set("Content-Type", mimeType);
376
474
  await wrappedFetch(uploadUrl, {
377
475
  method: "PUT",
378
- body: file ?? this.content
476
+ body: content,
477
+ headers,
478
+ signal: options?.signal
379
479
  });
380
480
  }
381
- async download(responseType = "blob") {
382
- const downloadUrl = await this.getDownloadUrl();
481
+ async download(responseType = "blob", options) {
482
+ const downloadUrl = await this.getDownloadUrl({ signal: options?.signal });
383
483
  const response = await wrappedFetch(downloadUrl, {
384
- method: "GET"
484
+ method: "GET",
485
+ signal: options?.signal
385
486
  });
386
487
  const blob = await response.blob();
387
488
  if (responseType === "blob")
@@ -390,48 +491,19 @@ class VaultFile {
390
491
  }
391
492
  }
392
493
 
393
- var __defProp = Object.defineProperty;
394
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
395
- var __publicField = (obj, key, value) => {
396
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
397
- return value;
398
- };
399
- class DataTokenAuthStrategy {
400
- constructor(dataToken) {
401
- __publicField(this, "dataToken");
402
- this.dataToken = dataToken;
403
- }
404
- getHeaders() {
405
- return new Headers({
406
- "x-data-token": this.dataToken
407
- });
408
- }
409
- }
410
- class APIKeyAuthStrategy {
411
- constructor(apiKey) {
412
- __publicField(this, "apiKey");
413
- this.apiKey = apiKey;
414
- }
415
- getHeaders() {
416
- return new Headers({
417
- Authorization: this.apiKey
418
- });
419
- }
420
- }
421
-
422
494
  function vaultClient(config) {
423
- function createFromContent(name, content) {
495
+ function createFromContent(name, content, options) {
424
496
  return VaultFile.fromContent({
425
497
  name,
426
498
  content,
427
499
  config
428
- });
500
+ }, { signal: options?.signal });
429
501
  }
430
- function createFromReference(reference) {
502
+ function createFromReference(reference, options) {
431
503
  return VaultFile.fromVaultReference({
432
504
  reference,
433
505
  config
434
- });
506
+ }, { signal: options?.signal });
435
507
  }
436
508
  return { createFromContent, createFromReference };
437
509
  }
package/dist/index.d.cts CHANGED
@@ -14,6 +14,15 @@ declare class APIKeyAuthStrategy implements AuthStrategy {
14
14
  constructor(apiKey: string);
15
15
  }
16
16
 
17
+ declare class FetchError extends Error {
18
+ readonly message: string;
19
+ readonly url: string;
20
+ readonly method: string;
21
+ readonly response: Response;
22
+ constructor(message: string, url: string, method: string, response: Response);
23
+ static from(url: string, method: string, response: Response): Promise<FetchError>;
24
+ }
25
+
17
26
  type VaultConfig = {
18
27
  vaultUrl: string;
19
28
  authStrategy: AuthStrategy;
@@ -76,12 +85,18 @@ declare class VaultFile {
76
85
  * @param params.method - The method to use for the fetch
77
86
  * @param params.path - The path to fetch
78
87
  * @param params.body - The body of the request
88
+ * @param params.signal - The signal to abort the request
79
89
  * @returns The response from the vault
80
90
  * @throws {FetchError} If the fetch fails
81
91
  */
82
92
  private _fetch;
83
93
  /**
84
94
  * Creates a new file in the vault.
95
+ * @param metadata - The metadata for creating a file
96
+ * @param metadata.size - The size of the file
97
+ * @param metadata.mimeType - The mime type of the file
98
+ * @param options - The options for the request
99
+ * @param options.signal - The signal to abort the request
85
100
  *
86
101
  * @returns The metadata of the file
87
102
  * @throws {Error} If the file ID is not set
@@ -95,6 +110,9 @@ declare class VaultFile {
95
110
  * @param params.reference - The reference to the file in the vault
96
111
  * @param params.config - The configuration for the VaultFile
97
112
  * @param params.download - Whether to download the file content (default: false)
113
+ * @param options - The options for the request
114
+ * @param options.signal - The signal to abort the request
115
+ *
98
116
  * @returns A new VaultFile instance
99
117
  *
100
118
  * @example
@@ -128,6 +146,8 @@ declare class VaultFile {
128
146
  reference: string;
129
147
  config: VaultConfig;
130
148
  download?: boolean;
149
+ }, options?: {
150
+ signal?: AbortSignal;
131
151
  }): Promise<VaultFile>;
132
152
  /**
133
153
  * Creates a new VaultFile instance from given content.
@@ -137,6 +157,9 @@ declare class VaultFile {
137
157
  * @param params.content - The content of the file
138
158
  * @param params.config - The configuration for the VaultFile
139
159
  * @param params.upload - Whether to upload the file (default: false)
160
+ * @param options - The options for the request
161
+ * @param options.signal - The signal to abort the request
162
+ *
140
163
  * @returns A new VaultFile instance
141
164
  *
142
165
  * @example
@@ -174,15 +197,21 @@ declare class VaultFile {
174
197
  content: Blob | File;
175
198
  config: VaultConfig;
176
199
  upload?: boolean;
200
+ }, options?: {
201
+ signal?: AbortSignal;
177
202
  }): Promise<VaultFile>;
178
203
  /**
179
204
  * Populates the metadata of the file instance.
205
+ * @param options - The options for the request
206
+ * @param options.signal - The signal to abort the request
180
207
  *
181
208
  * @returns The file instance
182
209
  * @throws {Error} If the file ID is not set
183
210
  * @throws {FetchError} If the metadata fetch fails
184
211
  */
185
- populateMetadata(): Promise<this | undefined>;
212
+ populateMetadata(options?: {
213
+ signal?: AbortSignal;
214
+ }): Promise<this | undefined>;
186
215
  /**
187
216
  * Gets the vault reference for this file.
188
217
  *
@@ -192,49 +221,77 @@ declare class VaultFile {
192
221
  getVaultReference(): string;
193
222
  /**
194
223
  * Fetches the metadata of the file.
224
+ * @param options - The options for the request
225
+ * @param options.signal - The signal to abort the request
195
226
  *
196
227
  * @returns The metadata of the file
197
228
  * @throws {Error} If the file ID is not set
198
229
  * @throws {FetchError} If the metadata fetch fails
199
230
  */
200
- getFileMetadata(): Promise<FileMetadata>;
231
+ getFileMetadata(options?: {
232
+ signal?: AbortSignal;
233
+ }): Promise<FileMetadata>;
201
234
  /**
202
235
  * Fetches a upload URL for the file.
236
+ * @param options - The options for the request
237
+ * @param options.signal - The signal to abort the request
203
238
  *
204
239
  * @returns The upload URL for the file
205
240
  * @throws {Error} If the vault service returns an invalid response
206
241
  * @throws {FetchError} If the upload URL fetch fails
207
242
  */
208
- getUploadUrl(): Promise<URL>;
243
+ getUploadUrl(options?: {
244
+ signal?: AbortSignal;
245
+ }): Promise<URL>;
209
246
  /**
210
247
  * Fetches a download URL for the file.
248
+ * @param options - The options for the request
249
+ * @param options.signal - The signal to abort the request
211
250
  *
212
251
  * @returns The download URL for the file
213
252
  * @throws {Error} If the vault service returns an invalid response
214
253
  * @throws {Error} If not file ID, name or content is set
215
254
  * @throws {FetchError} If the download URL fetch fails
216
255
  */
217
- getDownloadUrl(): Promise<URL>;
256
+ getDownloadUrl(options?: {
257
+ signal?: AbortSignal;
258
+ }): Promise<URL>;
218
259
  /**
219
260
  * Uploads a file to the vault.
220
261
  *
221
262
  * @example
222
263
  * ```ts
223
264
  * const file = new File(['content'], 'document.txt')
224
- * const vaultFile = await VaultFile.fromBlob('document.txt', file, { vaultUrl, authStrategy })
265
+ * const vaultFile = await VaultFile.fromContent({
266
+ * name: 'document.txt',
267
+ * content: file,
268
+ * config: {
269
+ * vaultUrl,
270
+ * authStrategy,
271
+ * },
272
+ * })
225
273
  * await vaultFile.upload(file)
226
274
  * ```
227
275
  *
228
276
  * @param file - The file to upload to the vault. If not provided, the file content will be taken from the `content` property.
277
+ * @param url - The URL to upload the file to. If not provided, the upload URL will be fetched from the vault.
278
+ * @param options - The options for the request
279
+ * @param options.signal - The signal to abort the request
280
+ *
229
281
  * @throws {FetchError} If the upload fails
230
282
  * @throws {Error} If the file content is not set and no file is provided
231
283
  * @returns Promise that resolves when upload is complete
232
284
  */
233
- upload(file?: Blob, url?: string): Promise<void>;
285
+ upload(file?: Blob, url?: string, options?: {
286
+ signal?: AbortSignal;
287
+ }): Promise<void>;
234
288
  /**
235
289
  * Downloads a file from the vault.
236
290
  *
237
291
  * @param responseType - The type of the response
292
+ * @param options - The options for the request
293
+ * @param options.signal - The signal to abort the request
294
+ *
238
295
  * @returns The response from the vault
239
296
  *
240
297
  * @example
@@ -243,22 +300,22 @@ declare class VaultFile {
243
300
  * const content = await vaultFile.download()
244
301
  * ```
245
302
  */
246
- download(responseType?: 'blob'): Promise<Blob>;
247
- download(responseType: 'base64'): Promise<string>;
248
- }
249
-
250
- declare class FetchError extends Error {
251
- readonly message: string;
252
- readonly url: string;
253
- readonly method: string;
254
- readonly response: Response;
255
- constructor(message: string, url: string, method: string, response: Response);
256
- static from(url: string, method: string, response: Response): Promise<FetchError>;
303
+ download(responseType?: 'blob', options?: {
304
+ signal?: AbortSignal;
305
+ }): Promise<Blob>;
306
+ download(responseType: 'base64', options?: {
307
+ signal?: AbortSignal;
308
+ }): Promise<string>;
257
309
  }
258
310
 
259
311
  declare function vaultClient(config: VaultConfig): {
260
- createFromContent: (name: string, content: Blob | File) => Promise<VaultFile>;
261
- createFromReference: (reference: string) => Promise<VaultFile>;
312
+ createFromContent: (name: string, content: Blob | File, options?: {
313
+ signal?: AbortSignal;
314
+ }) => Promise<VaultFile>;
315
+ createFromReference: (reference: string, options?: {
316
+ signal?: AbortSignal;
317
+ }) => Promise<VaultFile>;
262
318
  };
263
319
 
264
- export { APIKeyAuthStrategy, type AuthStrategy, DataTokenAuthStrategy, FetchError, type VaultConfig, VaultFile, vaultClient };
320
+ export { APIKeyAuthStrategy, DataTokenAuthStrategy, FetchError, VaultFile, vaultClient };
321
+ export type { AuthStrategy, VaultConfig };