pinata 0.3.4 → 1.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.
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -117,7 +107,7 @@ var testAuthentication = async (config) => {
117
107
  }
118
108
  };
119
109
 
120
- // src/core/pinning/file.ts
110
+ // src/core/uploads/file.ts
121
111
  var uploadFile = async (config, file, options) => {
122
112
  if (!config) {
123
113
  throw new ValidationError("Pinata configuration is missing");
@@ -125,20 +115,10 @@ var uploadFile = async (config, file, options) => {
125
115
  const jwt = options?.keys || config.pinataJwt;
126
116
  const data = new FormData();
127
117
  data.append("file", file, file.name);
128
- data.append(
129
- "pinataOptions",
130
- JSON.stringify({
131
- cidVersion: options?.cidVersion,
132
- groupId: options?.groupId
133
- })
134
- );
135
- data.append(
136
- "pinataMetadata",
137
- JSON.stringify({
138
- name: options?.metadata?.name || file.name || "File from SDK",
139
- keyvalues: options?.metadata?.keyValues
140
- })
141
- );
118
+ data.append("name", options?.metadata?.name || file.name || "File from SDK");
119
+ if (options?.groupId) {
120
+ data.append("group_id", options.groupId);
121
+ }
142
122
  let headers;
143
123
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
144
124
  headers = { ...config.customHeaders };
@@ -148,12 +128,12 @@ var uploadFile = async (config, file, options) => {
148
128
  Source: "sdk/file"
149
129
  };
150
130
  }
151
- let endpoint = "https://api.pinata.cloud";
131
+ let endpoint = "https://uploads.pinata.cloud/v3";
152
132
  if (config.endpointUrl) {
153
133
  endpoint = config.endpointUrl;
154
134
  }
155
135
  try {
156
- const request = await fetch(`${endpoint}/pinning/pinFileToIPFS`, {
136
+ const request = await fetch(`${endpoint}/files`, {
157
137
  method: "POST",
158
138
  headers,
159
139
  body: data
@@ -186,81 +166,7 @@ var uploadFile = async (config, file, options) => {
186
166
  }
187
167
  };
188
168
 
189
- // src/core/pinning/fileArray.ts
190
- var uploadFileArray = async (config, files, options) => {
191
- if (!config) {
192
- throw new ValidationError("Pinata configuration is missing");
193
- }
194
- const jwt = options?.keys || config?.pinataJwt;
195
- const folder = options?.metadata?.name || "folder_from_sdk";
196
- const data = new FormData();
197
- for (const file of Array.from(files)) {
198
- data.append("file", file, `${folder}/${file.name}`);
199
- }
200
- data.append(
201
- "pinataMetadata",
202
- JSON.stringify({
203
- name: folder,
204
- keyvalues: options?.metadata?.keyValues
205
- })
206
- );
207
- data.append(
208
- "pinataOptions",
209
- JSON.stringify({
210
- cidVersion: options?.cidVersion,
211
- groupId: options?.groupId
212
- })
213
- );
214
- let headers;
215
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
216
- headers = { ...config.customHeaders };
217
- } else {
218
- headers = {
219
- Authorization: `Bearer ${jwt}`,
220
- Source: "sdk/fileArray"
221
- };
222
- }
223
- let endpoint = "https://api.pinata.cloud";
224
- if (config.endpointUrl) {
225
- endpoint = config.endpointUrl;
226
- }
227
- try {
228
- const request = await fetch(`${endpoint}/pinning/pinFileToIPFS`, {
229
- method: "POST",
230
- headers,
231
- body: data
232
- });
233
- if (!request.ok) {
234
- const errorData = await request.text();
235
- if (request.status === 401 || request.status === 403) {
236
- throw new AuthenticationError(
237
- `Authentication failed: ${errorData}`,
238
- request.status,
239
- errorData
240
- );
241
- }
242
- throw new NetworkError(
243
- `HTTP error: ${errorData}`,
244
- request.status,
245
- errorData
246
- );
247
- }
248
- const res = await request.json();
249
- return res;
250
- } catch (error) {
251
- if (error instanceof PinataError) {
252
- throw error;
253
- }
254
- if (error instanceof Error) {
255
- throw new PinataError(`Error processing fileArray: ${error.message}`);
256
- }
257
- throw new PinataError(
258
- "An unknown error occurred while uploading an array of files"
259
- );
260
- }
261
- };
262
-
263
- // src/core/pinning/base64.ts
169
+ // src/core/uploads/base64.ts
264
170
  var uploadBase64 = async (config, base64String, options) => {
265
171
  if (!config) {
266
172
  throw new ValidationError("Pinata configuration is missing");
@@ -271,20 +177,10 @@ var uploadBase64 = async (config, base64String, options) => {
271
177
  const blob = new Blob([buffer]);
272
178
  const data = new FormData();
273
179
  data.append("file", blob, name);
274
- data.append(
275
- "pinataOptions",
276
- JSON.stringify({
277
- cidVersion: options?.cidVersion,
278
- groupId: options?.groupId
279
- })
280
- );
281
- data.append(
282
- "pinataMetadata",
283
- JSON.stringify({
284
- name,
285
- keyvalues: options?.metadata?.keyValues
286
- })
287
- );
180
+ data.append("name", name);
181
+ if (options?.groupId) {
182
+ data.append("group_id", options.groupId);
183
+ }
288
184
  let headers;
289
185
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
290
186
  headers = { ...config.customHeaders };
@@ -294,12 +190,12 @@ var uploadBase64 = async (config, base64String, options) => {
294
190
  Source: "sdk/base64"
295
191
  };
296
192
  }
297
- let endpoint = "https://api.pinata.cloud";
193
+ let endpoint = "https://uploads.pinata.cloud/v3";
298
194
  if (config.endpointUrl) {
299
195
  endpoint = config.endpointUrl;
300
196
  }
301
197
  try {
302
- const request = await fetch(`${endpoint}/pinning/pinFileToIPFS`, {
198
+ const request = await fetch(`${endpoint}/files`, {
303
199
  method: "POST",
304
200
  headers,
305
201
  body: data
@@ -334,7 +230,7 @@ var uploadBase64 = async (config, base64String, options) => {
334
230
  }
335
231
  };
336
232
 
337
- // src/core/pinning/url.ts
233
+ // src/core/uploads/url.ts
338
234
  var uploadUrl = async (config, url, options) => {
339
235
  if (!config) {
340
236
  throw new ValidationError("Pinata configuration is missing");
@@ -355,20 +251,10 @@ var uploadUrl = async (config, url, options) => {
355
251
  const name = options?.metadata?.name ?? "url_upload";
356
252
  const file = new File([blob], name);
357
253
  data.append("file", file, name);
358
- data.append(
359
- "pinataOptions",
360
- JSON.stringify({
361
- cidVersion: options?.cidVersion,
362
- groupId: options?.groupId
363
- })
364
- );
365
- data.append(
366
- "pinataMetadata",
367
- JSON.stringify({
368
- name,
369
- keyvalues: options?.metadata?.keyValues
370
- })
371
- );
254
+ data.append("name", name);
255
+ if (options?.groupId) {
256
+ data.append("group_id", options.groupId);
257
+ }
372
258
  let headers;
373
259
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
374
260
  headers = { ...config.customHeaders };
@@ -378,12 +264,12 @@ var uploadUrl = async (config, url, options) => {
378
264
  Source: "sdk/url"
379
265
  };
380
266
  }
381
- let endpoint = "https://api.pinata.cloud";
267
+ let endpoint = "https://uploads.pinata.cloud/v3";
382
268
  if (config.endpointUrl) {
383
269
  endpoint = config.endpointUrl;
384
270
  }
385
271
  try {
386
- const request = await fetch(`${endpoint}/pinning/pinFileToIPFS`, {
272
+ const request = await fetch(`${endpoint}/files`, {
387
273
  method: "POST",
388
274
  headers,
389
275
  body: data
@@ -416,39 +302,36 @@ var uploadUrl = async (config, url, options) => {
416
302
  }
417
303
  };
418
304
 
419
- // src/core/pinning/json.ts
305
+ // src/core/uploads/json.ts
420
306
  var uploadJson = async (config, jsonData, options) => {
421
307
  if (!config) {
422
308
  throw new ValidationError("Pinata configuration is missing");
423
309
  }
424
310
  const jwt = options?.keys || config?.pinataJwt;
425
- const data = JSON.stringify({
426
- pinataContent: jsonData,
427
- pinataOptions: {
428
- cidVersion: options?.cidVersion,
429
- groupId: options?.groupId
430
- },
431
- pinataMetadata: {
432
- name: options?.metadata?.name || "json",
433
- keyvalues: options?.metadata?.keyValues
434
- }
435
- });
311
+ const json = JSON.stringify(jsonData);
312
+ const blob = new Blob([json]);
313
+ const file = new File([blob], "data.json", { type: "application/json" });
314
+ const data = new FormData();
315
+ data.append("file", file, file.name);
316
+ data.append("name", options?.metadata?.name || file.name || "File from SDK");
317
+ if (options?.groupId) {
318
+ data.append("group_id", options.groupId);
319
+ }
436
320
  let headers;
437
321
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
438
322
  headers = { ...config.customHeaders };
439
323
  } else {
440
324
  headers = {
441
325
  Authorization: `Bearer ${jwt}`,
442
- "Content-Type": "application/json",
443
326
  Source: "sdk/json"
444
327
  };
445
328
  }
446
- let endpoint = "https://api.pinata.cloud";
329
+ let endpoint = "https://uploads.pinata.cloud/v3";
447
330
  if (config.endpointUrl) {
448
331
  endpoint = config.endpointUrl;
449
332
  }
450
333
  try {
451
- const request = await fetch(`${endpoint}/pinning/pinJSONToIPFS`, {
334
+ const request = await fetch(`${endpoint}/files`, {
452
335
  method: "POST",
453
336
  headers,
454
337
  body: data
@@ -481,78 +364,13 @@ var uploadJson = async (config, jsonData, options) => {
481
364
  }
482
365
  };
483
366
 
484
- // src/core/pinning/cid.ts
485
- var uploadCid = async (config, cid, options) => {
486
- if (!config) {
487
- throw new ValidationError("Pinata configuration is missing");
488
- }
489
- const jwt = options?.keys || config?.pinataJwt;
490
- let headers;
491
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
492
- headers = { ...config.customHeaders };
493
- } else {
494
- headers = {
495
- Authorization: `Bearer ${jwt}`,
496
- "Content-Type": "application/json",
497
- Source: "sdk/cid"
498
- };
499
- }
500
- const data = JSON.stringify({
501
- hashToPin: cid,
502
- pinataMetadata: {
503
- name: options?.metadata ? options?.metadata?.name : cid,
504
- keyvalues: options?.metadata?.keyValues
505
- },
506
- pinataOptions: {
507
- hostNodes: options?.peerAddresses ? options.peerAddresses : "",
508
- groupId: options?.groupId
509
- }
510
- });
511
- let endpoint = "https://api.pinata.cloud";
512
- if (config.endpointUrl) {
513
- endpoint = config.endpointUrl;
514
- }
515
- try {
516
- const request = await fetch(`${endpoint}/pinning/pinByHash`, {
517
- method: "POST",
518
- headers,
519
- body: data
520
- });
521
- if (!request.ok) {
522
- const errorData = await request.text();
523
- if (request.status === 401 || request.status === 403) {
524
- throw new AuthenticationError(
525
- `Authentication failed: ${errorData}`,
526
- request.status,
527
- errorData
528
- );
529
- }
530
- throw new NetworkError(
531
- `HTTP error: ${errorData}`,
532
- request.status,
533
- errorData
534
- );
535
- }
536
- const res = await request.json();
537
- return res;
538
- } catch (error) {
539
- if (error instanceof PinataError) {
540
- throw error;
541
- }
542
- if (error instanceof Error) {
543
- throw new PinataError(`Error processing cid: ${error.message}`);
544
- }
545
- throw new PinataError("An unknown error occurred while pinning by CID");
546
- }
547
- };
548
-
549
- // src/core/pinning/unpin.ts
367
+ // src/core/files/delete.ts
550
368
  var wait = (milliseconds) => {
551
369
  return new Promise((resolve) => {
552
370
  setTimeout(resolve, milliseconds);
553
371
  });
554
372
  };
555
- var unpinFile = async (config, files) => {
373
+ var deleteFile = async (config, files) => {
556
374
  if (!config) {
557
375
  throw new ValidationError("Pinata configuration is missing");
558
376
  }
@@ -566,13 +384,13 @@ var unpinFile = async (config, files) => {
566
384
  Source: "sdk/unpin"
567
385
  };
568
386
  }
569
- let endpoint = "https://api.pinata.cloud";
387
+ let endpoint = "https://api.pinata.cloud/v3";
570
388
  if (config.endpointUrl) {
571
389
  endpoint = config.endpointUrl;
572
390
  }
573
- for (const hash of files) {
391
+ for (const id of files) {
574
392
  try {
575
- const response = await fetch(`${endpoint}/pinning/unpin/${hash}`, {
393
+ const response = await fetch(`${endpoint}/files/${id}`, {
576
394
  method: "DELETE",
577
395
  headers
578
396
  });
@@ -592,22 +410,21 @@ var unpinFile = async (config, files) => {
592
410
  errorData
593
411
  );
594
412
  }
595
- const result = await response.text();
596
413
  responses.push({
597
- hash,
598
- status: result
414
+ id,
415
+ status: response.statusText
599
416
  });
600
417
  } catch (error) {
601
418
  let errorMessage;
602
419
  if (error instanceof PinataError) {
603
420
  errorMessage = error.message;
604
421
  } else if (error instanceof Error) {
605
- errorMessage = `Error unpinning file ${hash}: ${error.message}`;
422
+ errorMessage = `Error deleting file ${id}: ${error.message}`;
606
423
  } else {
607
- errorMessage = `An unknown error occurred while unpinning file ${hash}`;
424
+ errorMessage = `An unknown error occurred while deleting file ${id}`;
608
425
  }
609
426
  responses.push({
610
- hash,
427
+ id,
611
428
  status: errorMessage
612
429
  });
613
430
  }
@@ -615,59 +432,26 @@ var unpinFile = async (config, files) => {
615
432
  return responses;
616
433
  };
617
434
 
618
- // src/core/data/listFiles.ts
435
+ // src/core/files/list.ts
619
436
  var listFiles = async (config, options) => {
620
437
  if (!config) {
621
438
  throw new ValidationError("Pinata configuration is missing");
622
439
  }
623
- const params = new URLSearchParams({
624
- includesCount: "false"
625
- });
440
+ const params = new URLSearchParams();
626
441
  if (options) {
627
- const {
628
- cid,
629
- pinStart,
630
- pinEnd,
631
- pinSizeMin,
632
- pinSizeMax,
633
- pageLimit,
634
- pageOffset,
635
- name,
636
- key,
637
- value,
638
- operator,
639
- groupId
640
- } = options;
641
- if (cid)
642
- params.append("cid", cid);
643
- if (pinStart)
644
- params.append("pinStart", pinStart);
645
- if (pinEnd)
646
- params.append("pinEnd", pinEnd);
647
- if (pinSizeMin)
648
- params.append("pinSizeMin", pinSizeMin.toString());
649
- if (pinSizeMax)
650
- params.append("pinSizeMax", pinSizeMax.toString());
651
- if (pageLimit)
652
- params.append("pageLimit", pageLimit.toString());
653
- if (pageOffset)
654
- params.append("pageOffset", pageOffset.toString());
655
- if (groupId)
656
- params.append("groupId", groupId);
657
- if (name)
658
- params.append("metadata[name]", name);
659
- if (key && value) {
660
- const keyValueParam = JSON.stringify({
661
- [key]: { value, op: operator || "eq" }
662
- });
663
- params.append("metadata[keyvalues]", keyValueParam);
664
- }
442
+ const { limit, pageToken, cidPending } = options;
443
+ if (limit)
444
+ params.append("limit", limit.toString());
445
+ if (pageToken)
446
+ params.append("pageToken", pageToken);
447
+ if (cidPending)
448
+ params.append("cidPending", "true");
665
449
  }
666
- let endpoint = "https://api.pinata.cloud";
450
+ let endpoint = "https://api.pinata.cloud/v3";
667
451
  if (config.endpointUrl) {
668
452
  endpoint = config.endpointUrl;
669
453
  }
670
- const url = `${endpoint}/data/pinList?status=pinned&${params.toString()}`;
454
+ const url = `${endpoint}/files?${params.toString()}`;
671
455
  try {
672
456
  let headers;
673
457
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -698,7 +482,8 @@ var listFiles = async (config, options) => {
698
482
  );
699
483
  }
700
484
  const res = await request.json();
701
- return res.rows;
485
+ const resData = res.data;
486
+ return resData;
702
487
  } catch (error) {
703
488
  if (error instanceof PinataError) {
704
489
  throw error;
@@ -710,16 +495,14 @@ var listFiles = async (config, options) => {
710
495
  }
711
496
  };
712
497
 
713
- // src/core/data/updateMetadata.ts
714
- var updateMetadata = async (config, options) => {
498
+ // src/core/files/updateFile.ts
499
+ var updateFile = async (config, options) => {
715
500
  if (!config) {
716
501
  throw new ValidationError("Pinata configuration is missing");
717
502
  }
718
- const data = {
719
- ipfsPinHash: options.cid,
720
- name: options.name,
721
- keyvalues: options.keyValues
722
- };
503
+ const data = JSON.stringify({
504
+ name: options.name
505
+ });
723
506
  let headers;
724
507
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
725
508
  headers = { ...config.customHeaders };
@@ -730,15 +513,15 @@ var updateMetadata = async (config, options) => {
730
513
  Source: "sdk/updateMetadata"
731
514
  };
732
515
  }
733
- let endpoint = "https://api.pinata.cloud";
516
+ let endpoint = "https://api.pinata.cloud/v3";
734
517
  if (config.endpointUrl) {
735
518
  endpoint = config.endpointUrl;
736
519
  }
737
520
  try {
738
- const request = await fetch(`${endpoint}/pinning/hashMetadata`, {
521
+ const request = await fetch(`${endpoint}/files/${options.id}`, {
739
522
  method: "PUT",
740
523
  headers,
741
- body: JSON.stringify(data)
524
+ body: data
742
525
  });
743
526
  if (!request.ok) {
744
527
  const errorData = await request.text();
@@ -755,128 +538,49 @@ var updateMetadata = async (config, options) => {
755
538
  errorData
756
539
  );
757
540
  }
758
- const res = await request.text();
759
- return res;
541
+ const res = await request.json();
542
+ const resData = res.data;
543
+ return resData;
760
544
  } catch (error) {
761
545
  if (error instanceof PinataError) {
762
546
  throw error;
763
547
  }
764
548
  if (error instanceof Error) {
765
- throw new PinataError(
766
- `Error processing updateMetadata: ${error.message}`
767
- );
549
+ throw new PinataError(`Error processing updateFile: ${error.message}`);
768
550
  }
769
- throw new PinataError("An unknown error occurred while updating metadata");
551
+ throw new PinataError("An unknown error occurred while updating file");
770
552
  }
771
553
  };
772
554
 
773
- // src/utils/gateway-tools.ts
774
- var isIPFSModule;
775
- async function getIsIPFS() {
776
- if (!isIPFSModule) {
777
- isIPFSModule = await import("is-ipfs");
778
- }
779
- return isIPFSModule;
780
- }
781
- async function containsCID(input) {
782
- if (typeof input !== "string") {
783
- throw new Error("Input is not a string");
784
- }
785
- const isIPFS = await getIsIPFS();
786
- const startsWithCID = (str) => {
787
- const parts = str.split("/");
788
- return isIPFS.cid(parts[0]) ? parts[0] : null;
789
- };
790
- const directCID = startsWithCID(input);
791
- if (directCID) {
792
- return {
793
- containsCid: true,
794
- cid: directCID
795
- };
796
- }
797
- let url;
798
- try {
799
- url = new URL(input);
800
- } catch (error) {
801
- const parts = input.split(/\/|\?/);
802
- for (const part of parts) {
803
- const cid = startsWithCID(part);
804
- if (cid) {
805
- return {
806
- containsCid: true,
807
- cid
808
- };
809
- }
810
- }
811
- return {
812
- containsCid: false,
813
- cid: null
814
- };
815
- }
816
- const subdomains = url.hostname.split(".");
817
- for (const subdomain of subdomains) {
818
- if (isIPFS.cid(subdomain)) {
819
- return {
820
- containsCid: true,
821
- cid: subdomain
822
- };
823
- }
824
- }
825
- const pathParts = url.pathname.split("/");
826
- for (const part of pathParts) {
827
- const cid = startsWithCID(part);
828
- if (cid) {
829
- return {
830
- containsCid: true,
831
- cid
832
- };
833
- }
834
- }
835
- return {
836
- containsCid: false,
837
- cid: null
838
- };
839
- }
840
- async function convertToDesiredGateway(sourceUrl, desiredGatewayPrefix) {
841
- const results = await containsCID(sourceUrl);
842
- if (results.containsCid !== true) {
843
- throw new Error("url does not contain CID");
844
- }
845
- if (!sourceUrl.startsWith("https") && !sourceUrl.startsWith("ipfs://")) {
846
- return `${desiredGatewayPrefix}/ipfs/${sourceUrl}`;
847
- }
848
- const urlObj = new URL(sourceUrl);
849
- const path = urlObj.pathname + urlObj.search + urlObj.hash;
850
- if (sourceUrl.startsWith(`ipfs://${results.cid}`)) {
851
- return `${desiredGatewayPrefix}/ipfs/${results.cid}${path}`;
852
- }
853
- if (sourceUrl.includes(`/ipfs/${results.cid}`)) {
854
- return `${desiredGatewayPrefix}${path}`;
855
- }
856
- if (sourceUrl.includes(`/ipns/${results.cid}`)) {
857
- return `${desiredGatewayPrefix}${path}`;
858
- }
859
- if (urlObj.hostname.includes(results.cid)) {
860
- return `${desiredGatewayPrefix}/ipfs/${results.cid}${path}`;
861
- }
862
- throw new Error(
863
- "unsupported URL pattern, please submit a github issue with the URL utilized"
864
- );
865
- }
866
-
867
555
  // src/core/gateway/getCid.ts
868
556
  var getCid = async (config, cid) => {
869
557
  if (!config) {
870
558
  throw new ValidationError("Pinata configuration is missing");
871
559
  }
872
560
  let data;
873
- let newUrl;
874
- newUrl = await convertToDesiredGateway(cid, config?.pinataGateway);
875
- if (config?.pinataGatewayKey) {
876
- newUrl = `${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;
877
- }
561
+ let newUrl = `${config?.pinataGateway}/files/${cid}`;
562
+ const params = new URLSearchParams();
563
+ const date = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
564
+ const payload = JSON.stringify({
565
+ url: newUrl,
566
+ date,
567
+ expires: 30,
568
+ method: "GET"
569
+ });
570
+ const signedUrlRequest = await fetch(
571
+ "https://api.pinata.cloud/v3/files/sign",
572
+ {
573
+ method: "POST",
574
+ headers: {
575
+ "Content-Type": "application/json",
576
+ Authorization: `Bearer ${config?.pinataJwt}`
577
+ },
578
+ body: payload
579
+ }
580
+ );
581
+ const signedUrl = await signedUrlRequest.json();
878
582
  try {
879
- const request = await fetch(newUrl);
583
+ const request = await fetch(signedUrl.data);
880
584
  if (!request.ok) {
881
585
  const errorData = await request.text();
882
586
  if (request.status === 401 || request.status === 403) {
@@ -918,55 +622,31 @@ var getCid = async (config, cid) => {
918
622
  }
919
623
  };
920
624
 
921
- // src/core/gateway/convertIPFSUrl.ts
922
- var convertIPFSUrl = async (config, url) => {
923
- let newUrl;
924
- newUrl = await convertToDesiredGateway(url, config?.pinataGateway);
925
- if (config?.pinataGatewayKey) {
926
- `${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;
927
- }
928
- return newUrl;
929
- };
930
-
931
- // src/core/data/pinJobs.ts
932
- var pinJobs = async (config, options) => {
625
+ // src/core/keys/createKey.ts
626
+ var createKey = async (config, options) => {
933
627
  if (!config) {
934
628
  throw new ValidationError("Pinata configuration is missing");
935
629
  }
936
- const params = new URLSearchParams({
937
- includesCount: "false"
938
- });
939
- if (options) {
940
- const { ipfs_pin_hash: cid, status, sort, limit, offset } = options;
941
- if (cid)
942
- params.append("ipfs_pin_hash", cid.toString());
943
- if (status)
944
- params.append("status", status.toString());
945
- if (sort)
946
- params.append("sort", sort.toString());
947
- if (limit)
948
- params.append("limit", limit.toString());
949
- if (offset)
950
- params.append("offset", offset.toString());
951
- }
952
- let endpoint = "https://api.pinata.cloud";
953
- if (config.endpointUrl) {
954
- endpoint = config.endpointUrl;
955
- }
956
- const url = `${endpoint}/pinning/pinJobs?${params.toString()}`;
957
630
  let headers;
958
631
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
959
632
  headers = { ...config.customHeaders };
960
633
  } else {
961
634
  headers = {
962
635
  Authorization: `Bearer ${config.pinataJwt}`,
963
- Source: "sdk/pinJobs"
636
+ "Content-Type": "application/json",
637
+ Source: "sdk/createKey"
964
638
  };
965
639
  }
640
+ const data = JSON.stringify(options);
641
+ let endpoint = "https://api.pinata.cloud/v3";
642
+ if (config.endpointUrl) {
643
+ endpoint = config.endpointUrl;
644
+ }
966
645
  try {
967
- const request = await fetch(url, {
968
- method: "GET",
969
- headers
646
+ const request = await fetch(`${endpoint}/pinata/keys`, {
647
+ method: "POST",
648
+ headers,
649
+ body: data
970
650
  });
971
651
  if (!request.ok) {
972
652
  const errorData = await request.text();
@@ -984,41 +664,59 @@ var pinJobs = async (config, options) => {
984
664
  );
985
665
  }
986
666
  const res = await request.json();
987
- return res.rows;
667
+ return res;
988
668
  } catch (error) {
989
669
  if (error instanceof PinataError) {
990
670
  throw error;
991
671
  }
992
672
  if (error instanceof Error) {
993
- throw new PinataError(`Error processing pinJobs: ${error.message}`);
673
+ throw new PinataError(`Error processing createKey: ${error.message}`);
994
674
  }
995
- throw new PinataError("An unknown error occurred while listing pin jobs");
675
+ throw new PinataError("An unknown error occurred while creating API key");
996
676
  }
997
677
  };
998
678
 
999
- // src/core/data/pinnedFileUsage.ts
1000
- var pinnedFileCount = async (config) => {
679
+ // src/core/keys/listKeys.ts
680
+ var listKeys = async (config, options) => {
1001
681
  if (!config) {
1002
682
  throw new ValidationError("Pinata configuration is missing");
1003
683
  }
1004
- let endpoint = "https://api.pinata.cloud";
1005
- if (config.endpointUrl) {
1006
- endpoint = config.endpointUrl;
1007
- }
1008
684
  let headers;
1009
685
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1010
686
  headers = { ...config.customHeaders };
1011
687
  } else {
1012
688
  headers = {
1013
689
  Authorization: `Bearer ${config.pinataJwt}`,
1014
- Source: "sdk/pinnedFileUsage"
690
+ "Content-Type": "application/json",
691
+ Source: "sdk/listKeys"
1015
692
  };
1016
693
  }
694
+ const params = new URLSearchParams();
695
+ if (options) {
696
+ const { offset, name, revoked, limitedUse, exhausted } = options;
697
+ if (offset)
698
+ params.append("offset", offset.toString());
699
+ if (revoked !== void 0)
700
+ params.append("revoked", revoked.toString());
701
+ if (limitedUse !== void 0)
702
+ params.append("limitedUse", limitedUse.toString());
703
+ if (exhausted !== void 0)
704
+ params.append("exhausted", exhausted.toString());
705
+ if (name)
706
+ params.append("name", name);
707
+ }
708
+ let endpoint = "https://api.pinata.cloud/v3";
709
+ if (config.endpointUrl) {
710
+ endpoint = config.endpointUrl;
711
+ }
1017
712
  try {
1018
- const request = await fetch(`${endpoint}/data/userPinnedDataTotal`, {
1019
- method: "GET",
1020
- headers
1021
- });
713
+ const request = await fetch(
714
+ `${endpoint}/pinata/keys?${params.toString()}`,
715
+ {
716
+ method: "GET",
717
+ headers
718
+ }
719
+ );
1022
720
  if (!request.ok) {
1023
721
  const errorData = await request.text();
1024
722
  if (request.status === 401 || request.status === 403) {
@@ -1035,207 +733,25 @@ var pinnedFileCount = async (config) => {
1035
733
  );
1036
734
  }
1037
735
  const res = await request.json();
1038
- return res.pin_count;
736
+ return res.keys;
1039
737
  } catch (error) {
1040
738
  if (error instanceof PinataError) {
1041
739
  throw error;
1042
740
  }
1043
741
  if (error instanceof Error) {
1044
- throw new PinataError(
1045
- `Error processing pinnedFileUsage: ${error.message}`
1046
- );
742
+ throw new PinataError(`Error processing listKeys: ${error.message}`);
1047
743
  }
1048
- throw new PinataError(
1049
- "An unknown error occurred while getting pinned file usage"
1050
- );
744
+ throw new PinataError("An unknown error occurred while listing API keys");
1051
745
  }
1052
746
  };
1053
747
 
1054
- // src/core/data/totalStorageUsage.ts
1055
- var totalStorageUsage = async (config) => {
1056
- if (!config) {
1057
- throw new ValidationError("Pinata configuration is missing");
1058
- }
1059
- let endpoint = "https://api.pinata.cloud";
1060
- if (config.endpointUrl) {
1061
- endpoint = config.endpointUrl;
1062
- }
1063
- let headers;
1064
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1065
- headers = { ...config.customHeaders };
1066
- } else {
1067
- headers = {
1068
- Authorization: `Bearer ${config.pinataJwt}`,
1069
- Source: "sdk/totalStorageUsage"
1070
- };
1071
- }
1072
- try {
1073
- const request = await fetch(`${endpoint}/data/userPinnedDataTotal`, {
1074
- method: "GET",
1075
- headers
1076
- });
1077
- if (!request.ok) {
1078
- const errorData = await request.text();
1079
- if (request.status === 401 || request.status === 403) {
1080
- throw new AuthenticationError(
1081
- `Authentication failed: ${errorData}`,
1082
- request.status,
1083
- errorData
1084
- );
1085
- }
1086
- throw new NetworkError(
1087
- `HTTP error: ${errorData}`,
1088
- request.status,
1089
- errorData
1090
- );
1091
- }
1092
- const res = await request.json();
1093
- return res.pin_size_total;
1094
- } catch (error) {
1095
- if (error instanceof PinataError) {
1096
- throw error;
1097
- }
1098
- if (error instanceof Error) {
1099
- throw new PinataError(
1100
- `Error processing totalStorageUsage: ${error.message}`
1101
- );
1102
- }
1103
- throw new PinataError(
1104
- "An unknown error occurred while getting total storage usage"
1105
- );
1106
- }
1107
- };
1108
-
1109
- // src/core/keys/createKey.ts
1110
- var createKey = async (config, options) => {
1111
- if (!config) {
1112
- throw new ValidationError("Pinata configuration is missing");
1113
- }
1114
- let headers;
1115
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1116
- headers = { ...config.customHeaders };
1117
- } else {
1118
- headers = {
1119
- Authorization: `Bearer ${config.pinataJwt}`,
1120
- "Content-Type": "application/json",
1121
- Source: "sdk/createKey"
1122
- };
1123
- }
1124
- const data = JSON.stringify(options);
1125
- let endpoint = "https://api.pinata.cloud";
1126
- if (config.endpointUrl) {
1127
- endpoint = config.endpointUrl;
1128
- }
1129
- try {
1130
- const request = await fetch(`${endpoint}/v3/pinata/keys`, {
1131
- method: "POST",
1132
- headers,
1133
- body: data
1134
- });
1135
- if (!request.ok) {
1136
- const errorData = await request.text();
1137
- if (request.status === 401 || request.status === 403) {
1138
- throw new AuthenticationError(
1139
- `Authentication failed: ${errorData}`,
1140
- request.status,
1141
- errorData
1142
- );
1143
- }
1144
- throw new NetworkError(
1145
- `HTTP error: ${errorData}`,
1146
- request.status,
1147
- errorData
1148
- );
1149
- }
1150
- const res = await request.json();
1151
- return res;
1152
- } catch (error) {
1153
- if (error instanceof PinataError) {
1154
- throw error;
1155
- }
1156
- if (error instanceof Error) {
1157
- throw new PinataError(`Error processing createKey: ${error.message}`);
1158
- }
1159
- throw new PinataError("An unknown error occurred while creating API key");
1160
- }
1161
- };
1162
-
1163
- // src/core/keys/listKeys.ts
1164
- var listKeys = async (config, options) => {
1165
- if (!config) {
1166
- throw new ValidationError("Pinata configuration is missing");
1167
- }
1168
- let headers;
1169
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1170
- headers = { ...config.customHeaders };
1171
- } else {
1172
- headers = {
1173
- Authorization: `Bearer ${config.pinataJwt}`,
1174
- "Content-Type": "application/json",
1175
- Source: "sdk/listKeys"
1176
- };
1177
- }
1178
- const params = new URLSearchParams();
1179
- if (options) {
1180
- const { offset, name, revoked, limitedUse, exhausted } = options;
1181
- if (offset)
1182
- params.append("offset", offset.toString());
1183
- if (revoked !== void 0)
1184
- params.append("revoked", revoked.toString());
1185
- if (limitedUse !== void 0)
1186
- params.append("limitedUse", limitedUse.toString());
1187
- if (exhausted !== void 0)
1188
- params.append("exhausted", exhausted.toString());
1189
- if (name)
1190
- params.append("name", name);
1191
- }
1192
- let endpoint = "https://api.pinata.cloud";
1193
- if (config.endpointUrl) {
1194
- endpoint = config.endpointUrl;
1195
- }
1196
- try {
1197
- const request = await fetch(
1198
- `${endpoint}/v3/pinata/keys?${params.toString()}`,
1199
- {
1200
- method: "GET",
1201
- headers
1202
- }
1203
- );
1204
- if (!request.ok) {
1205
- const errorData = await request.text();
1206
- if (request.status === 401 || request.status === 403) {
1207
- throw new AuthenticationError(
1208
- `Authentication failed: ${errorData}`,
1209
- request.status,
1210
- errorData
1211
- );
1212
- }
1213
- throw new NetworkError(
1214
- `HTTP error: ${errorData}`,
1215
- request.status,
1216
- errorData
1217
- );
1218
- }
1219
- const res = await request.json();
1220
- return res.keys;
1221
- } catch (error) {
1222
- if (error instanceof PinataError) {
1223
- throw error;
1224
- }
1225
- if (error instanceof Error) {
1226
- throw new PinataError(`Error processing listKeys: ${error.message}`);
1227
- }
1228
- throw new PinataError("An unknown error occurred while listing API keys");
1229
- }
1230
- };
1231
-
1232
- // src/core/keys/revokeKeys.ts
1233
- var wait2 = (milliseconds) => {
1234
- return new Promise((resolve) => {
1235
- setTimeout(resolve, milliseconds);
1236
- });
1237
- };
1238
- var revokeKeys = async (config, keys) => {
748
+ // src/core/keys/revokeKeys.ts
749
+ var wait2 = (milliseconds) => {
750
+ return new Promise((resolve) => {
751
+ setTimeout(resolve, milliseconds);
752
+ });
753
+ };
754
+ var revokeKeys = async (config, keys) => {
1239
755
  if (!config) {
1240
756
  throw new ValidationError("Pinata configuration is missing");
1241
757
  }
@@ -1250,13 +766,13 @@ var revokeKeys = async (config, keys) => {
1250
766
  };
1251
767
  }
1252
768
  const responses = [];
1253
- let endpoint = "https://api.pinata.cloud";
769
+ let endpoint = "https://api.pinata.cloud/v3";
1254
770
  if (config.endpointUrl) {
1255
771
  endpoint = config.endpointUrl;
1256
772
  }
1257
773
  for (const key of keys) {
1258
774
  try {
1259
- const request = await fetch(`${endpoint}/v3/pinata/keys/${key}`, {
775
+ const request = await fetch(`${endpoint}/pinata/keys/${key}`, {
1260
776
  method: "PUT",
1261
777
  headers
1262
778
  });
@@ -1304,7 +820,10 @@ var createGroup = async (config, options) => {
1304
820
  if (!config) {
1305
821
  throw new ValidationError("Pinata configuration is missing");
1306
822
  }
1307
- const data = JSON.stringify(options);
823
+ const data = JSON.stringify({
824
+ name: options.name,
825
+ is_public: options.isPublic
826
+ });
1308
827
  let headers;
1309
828
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1310
829
  headers = { ...config.customHeaders };
@@ -1315,12 +834,12 @@ var createGroup = async (config, options) => {
1315
834
  Source: "sdk/createGroup"
1316
835
  };
1317
836
  }
1318
- let endpoint = "https://api.pinata.cloud";
837
+ let endpoint = "https://api.pinata.cloud/v3";
1319
838
  if (config.endpointUrl) {
1320
839
  endpoint = config.endpointUrl;
1321
840
  }
1322
841
  try {
1323
- const request = await fetch(`${endpoint}/groups`, {
842
+ const request = await fetch(`${endpoint}/files/groups`, {
1324
843
  method: "POST",
1325
844
  headers,
1326
845
  body: data
@@ -1341,7 +860,8 @@ var createGroup = async (config, options) => {
1341
860
  );
1342
861
  }
1343
862
  const res = await request.json();
1344
- return res;
863
+ const resData = res.data;
864
+ return resData;
1345
865
  } catch (error) {
1346
866
  if (error instanceof PinataError) {
1347
867
  throw error;
@@ -1370,23 +890,28 @@ var listGroups = async (config, options) => {
1370
890
  }
1371
891
  const params = new URLSearchParams();
1372
892
  if (options) {
1373
- const { offset, nameContains, limit } = options;
1374
- if (offset)
1375
- params.append("offset", offset.toString());
893
+ const { pageToken, nameContains, limit, isPublic } = options;
894
+ if (pageToken)
895
+ params.append("pageToken", pageToken.toString());
896
+ if (isPublic)
897
+ params.append("isPublic", isPublic.toString());
1376
898
  if (nameContains !== void 0)
1377
899
  params.append("nameContains", nameContains.toString());
1378
900
  if (limit !== void 0)
1379
901
  params.append("limit", limit.toString());
1380
902
  }
1381
- let endpoint = "https://api.pinata.cloud";
903
+ let endpoint = "https://api.pinata.cloud/v3";
1382
904
  if (config.endpointUrl) {
1383
905
  endpoint = config.endpointUrl;
1384
906
  }
1385
907
  try {
1386
- const request = await fetch(`${endpoint}/groups?${params.toString()}`, {
1387
- method: "GET",
1388
- headers
1389
- });
908
+ const request = await fetch(
909
+ `${endpoint}/files/groups?${params.toString()}`,
910
+ {
911
+ method: "GET",
912
+ headers
913
+ }
914
+ );
1390
915
  if (!request.ok) {
1391
916
  const errorData = await request.text();
1392
917
  if (request.status === 401 || request.status === 403) {
@@ -1403,7 +928,8 @@ var listGroups = async (config, options) => {
1403
928
  );
1404
929
  }
1405
930
  const res = await request.json();
1406
- return res;
931
+ const resData = res.data;
932
+ return resData;
1407
933
  } catch (error) {
1408
934
  if (error instanceof PinataError) {
1409
935
  throw error;
@@ -1430,12 +956,12 @@ var getGroup = async (config, options) => {
1430
956
  Source: "sdk/getGroup"
1431
957
  };
1432
958
  }
1433
- let endpoint = "https://api.pinata.cloud";
959
+ let endpoint = "https://api.pinata.cloud/v3";
1434
960
  if (config.endpointUrl) {
1435
961
  endpoint = config.endpointUrl;
1436
962
  }
1437
963
  try {
1438
- const request = await fetch(`${endpoint}/groups/${options.groupId}`, {
964
+ const request = await fetch(`${endpoint}/files/groups/${options.groupId}`, {
1439
965
  method: "GET",
1440
966
  headers
1441
967
  });
@@ -1455,7 +981,8 @@ var getGroup = async (config, options) => {
1455
981
  );
1456
982
  }
1457
983
  const res = await request.json();
1458
- return res;
984
+ const resData = res.data;
985
+ return resData;
1459
986
  } catch (error) {
1460
987
  if (error instanceof PinataError) {
1461
988
  throw error;
@@ -1469,71 +996,14 @@ var getGroup = async (config, options) => {
1469
996
  }
1470
997
  };
1471
998
 
1472
- // src/core/groups/addToGroup.ts
1473
- var addToGroup = async (config, options) => {
1474
- if (!config) {
1475
- throw new ValidationError("Pinata configuration is missing");
1476
- }
1477
- const data = JSON.stringify({
1478
- cids: options.cids
1479
- });
1480
- let headers;
1481
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1482
- headers = { ...config.customHeaders };
1483
- } else {
1484
- headers = {
1485
- Authorization: `Bearer ${config.pinataJwt}`,
1486
- "Content-Type": "application/json",
1487
- Source: "sdk/addToGroup"
1488
- };
1489
- }
1490
- let endpoint = "https://api.pinata.cloud";
1491
- if (config.endpointUrl) {
1492
- endpoint = config.endpointUrl;
1493
- }
1494
- try {
1495
- const request = await fetch(`${endpoint}/groups/${options.groupId}/cids`, {
1496
- method: "PUT",
1497
- headers,
1498
- body: data
1499
- });
1500
- if (!request.ok) {
1501
- const errorData = await request.text();
1502
- if (request.status === 401 || request.status === 403) {
1503
- throw new AuthenticationError(
1504
- `Authentication failed: ${errorData}`,
1505
- request.status,
1506
- errorData
1507
- );
1508
- }
1509
- throw new NetworkError(
1510
- `HTTP error: ${errorData}`,
1511
- request.status,
1512
- errorData
1513
- );
1514
- }
1515
- const res = await request.text();
1516
- return res;
1517
- } catch (error) {
1518
- if (error instanceof PinataError) {
1519
- throw error;
1520
- }
1521
- if (error instanceof Error) {
1522
- throw new PinataError(`Error processing addToGroup: ${error.message}`);
1523
- }
1524
- throw new PinataError(
1525
- "An unknown error occurred while adding CIDs to group"
1526
- );
1527
- }
1528
- };
1529
-
1530
999
  // src/core/groups/updateGroup.ts
1531
1000
  var updateGroup = async (config, options) => {
1532
1001
  if (!config) {
1533
1002
  throw new ValidationError("Pinata configuration is missing");
1534
1003
  }
1535
1004
  const data = JSON.stringify({
1536
- name: options.name
1005
+ name: options.name,
1006
+ is_public: options.isPublic
1537
1007
  });
1538
1008
  let headers;
1539
1009
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -1545,559 +1015,12 @@ var updateGroup = async (config, options) => {
1545
1015
  Source: "sdk/updateGroup"
1546
1016
  };
1547
1017
  }
1548
- let endpoint = "https://api.pinata.cloud";
1549
- if (config.endpointUrl) {
1550
- endpoint = config.endpointUrl;
1551
- }
1552
- try {
1553
- const request = await fetch(`${endpoint}/groups/${options.groupId}`, {
1554
- method: "PUT",
1555
- headers,
1556
- body: data
1557
- });
1558
- if (!request.ok) {
1559
- const errorData = await request.text();
1560
- if (request.status === 401 || request.status === 403) {
1561
- throw new AuthenticationError(
1562
- `Authentication failed: ${errorData}`,
1563
- request.status,
1564
- errorData
1565
- );
1566
- }
1567
- throw new NetworkError(
1568
- `HTTP error: ${errorData}`,
1569
- request.status,
1570
- errorData
1571
- );
1572
- }
1573
- const res = await request.json();
1574
- return res;
1575
- } catch (error) {
1576
- if (error instanceof PinataError) {
1577
- throw error;
1578
- }
1579
- if (error instanceof Error) {
1580
- throw new PinataError(`Error processing updateGroup: ${error.message}`);
1581
- }
1582
- throw new PinataError("An unknown error occurred while updating group");
1583
- }
1584
- };
1585
-
1586
- // src/core/groups/removeFromGroup.ts
1587
- var removeFromGroup = async (config, options) => {
1588
- if (!config) {
1589
- throw new ValidationError("Pinata configuration is missing");
1590
- }
1591
- let headers;
1592
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1593
- headers = { ...config.customHeaders };
1594
- } else {
1595
- headers = {
1596
- Authorization: `Bearer ${config.pinataJwt}`,
1597
- "Content-Type": "application/json",
1598
- Source: "sdk/removeFromGroup"
1599
- };
1600
- }
1601
- const data = JSON.stringify({
1602
- cids: options.cids
1603
- });
1604
- let endpoint = "https://api.pinata.cloud";
1605
- if (config.endpointUrl) {
1606
- endpoint = config.endpointUrl;
1607
- }
1608
- try {
1609
- const request = await fetch(`${endpoint}/groups/${options.groupId}/cids`, {
1610
- method: "DELETE",
1611
- headers,
1612
- body: data
1613
- });
1614
- if (!request.ok) {
1615
- const errorData = await request.text();
1616
- if (request.status === 401 || request.status === 403) {
1617
- throw new AuthenticationError(
1618
- `Authentication failed: ${errorData}`,
1619
- request.status,
1620
- errorData
1621
- );
1622
- }
1623
- throw new NetworkError(
1624
- `HTTP error: ${errorData}`,
1625
- request.status,
1626
- errorData
1627
- );
1628
- }
1629
- const res = await request.text();
1630
- return res;
1631
- } catch (error) {
1632
- if (error instanceof PinataError) {
1633
- throw error;
1634
- }
1635
- if (error instanceof Error) {
1636
- throw new PinataError(
1637
- `Error processing removeFromGroup: ${error.message}`
1638
- );
1639
- }
1640
- throw new PinataError(
1641
- "An unknown error occurred while removing CIDs from a group"
1642
- );
1643
- }
1644
- };
1645
-
1646
- // src/core/groups/deleteGroup.ts
1647
- var deleteGroup = async (config, options) => {
1648
- if (!config) {
1649
- throw new ValidationError("Pinata configuration is missing");
1650
- }
1651
- let headers;
1652
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1653
- headers = { ...config.customHeaders };
1654
- } else {
1655
- headers = {
1656
- Authorization: `Bearer ${config.pinataJwt}`,
1657
- "Content-Type": "application/json",
1658
- Source: "sdk/deleteGroup"
1659
- };
1660
- }
1661
- let endpoint = "https://api.pinata.cloud";
1662
- if (config.endpointUrl) {
1663
- endpoint = config.endpointUrl;
1664
- }
1665
- try {
1666
- const request = await fetch(`${endpoint}/groups/${options.groupId}`, {
1667
- method: "DELETE",
1668
- headers
1669
- });
1670
- if (!request.ok) {
1671
- const errorData = await request.text();
1672
- if (request.status === 401 || request.status === 403) {
1673
- throw new AuthenticationError(
1674
- `Authentication failed: ${errorData}`,
1675
- request.status,
1676
- errorData
1677
- );
1678
- }
1679
- throw new NetworkError(
1680
- `HTTP error: ${errorData}`,
1681
- request.status,
1682
- errorData
1683
- );
1684
- }
1685
- const res = await request.text();
1686
- return res;
1687
- } catch (error) {
1688
- if (error instanceof PinataError) {
1689
- throw error;
1690
- }
1691
- if (error instanceof Error) {
1692
- throw new PinataError(`Error processing deleteGroup: ${error.message}`);
1693
- }
1694
- throw new PinataError("An unknown error occurred while deleting a group");
1695
- }
1696
- };
1697
-
1698
- // src/core/signatures/addSignature.ts
1699
- var addSignature = async (config, options) => {
1700
- if (!config) {
1701
- throw new ValidationError("Pinata configuration is missing");
1702
- }
1703
- const data = JSON.stringify({
1704
- signature: options.signature
1705
- });
1706
- let headers;
1707
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1708
- headers = { ...config.customHeaders };
1709
- } else {
1710
- headers = {
1711
- Authorization: `Bearer ${config.pinataJwt}`,
1712
- "Content-Type": "application/json",
1713
- Source: "sdk/addSignature"
1714
- };
1715
- }
1716
- let endpoint = "https://api.pinata.cloud";
1717
- if (config.endpointUrl) {
1718
- endpoint = config.endpointUrl;
1719
- }
1720
- try {
1721
- const request = await fetch(
1722
- `${endpoint}/v3/ipfs/signature/${options.cid}`,
1723
- {
1724
- method: "POST",
1725
- headers,
1726
- body: data
1727
- }
1728
- );
1729
- if (!request.ok) {
1730
- const errorData = await request.text();
1731
- if (request.status === 401 || request.status === 403) {
1732
- throw new AuthenticationError(
1733
- `Authentication failed: ${errorData}`,
1734
- request.status,
1735
- errorData
1736
- );
1737
- }
1738
- if (request.status === 403) {
1739
- throw new PinataError(
1740
- "Unauthorized signing, you must be the original owner of the file and it must not have a signature",
1741
- request.status,
1742
- errorData
1743
- );
1744
- }
1745
- throw new NetworkError(
1746
- `HTTP error: ${errorData}`,
1747
- request.status,
1748
- errorData
1749
- );
1750
- }
1751
- const res = await request.json();
1752
- return res.data;
1753
- } catch (error) {
1754
- if (error instanceof PinataError) {
1755
- throw error;
1756
- }
1757
- if (error instanceof Error) {
1758
- throw new PinataError(`Error processing addSignature: ${error.message}`);
1759
- }
1760
- throw new PinataError(
1761
- "An unknown error occurred while adding signature to CID"
1762
- );
1763
- }
1764
- };
1765
-
1766
- // src/core/signatures/getSignature.ts
1767
- var getSignature = async (config, cid) => {
1768
- if (!config) {
1769
- throw new ValidationError("Pinata configuration is missing");
1770
- }
1771
- let headers;
1772
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1773
- headers = { ...config.customHeaders };
1774
- } else {
1775
- headers = {
1776
- Authorization: `Bearer ${config.pinataJwt}`,
1777
- "Content-Type": "application/json",
1778
- Source: "sdk/getSignature"
1779
- };
1780
- }
1781
- let endpoint = "https://api.pinata.cloud";
1782
- if (config.endpointUrl) {
1783
- endpoint = config.endpointUrl;
1784
- }
1785
- try {
1786
- const request = await fetch(`${endpoint}/v3/ipfs/signature/${cid}`, {
1787
- method: "GET",
1788
- headers
1789
- });
1790
- if (!request.ok) {
1791
- const errorData = await request.text();
1792
- if (request.status === 401 || request.status === 403) {
1793
- throw new AuthenticationError(
1794
- `Authentication failed: ${errorData}`,
1795
- request.status,
1796
- errorData
1797
- );
1798
- }
1799
- throw new NetworkError(
1800
- `HTTP error: ${errorData}`,
1801
- request.status,
1802
- errorData
1803
- );
1804
- }
1805
- const res = await request.json();
1806
- return res.data;
1807
- } catch (error) {
1808
- if (error instanceof PinataError) {
1809
- throw error;
1810
- }
1811
- if (error instanceof Error) {
1812
- throw new PinataError(`Error processing getSignature: ${error.message}`);
1813
- }
1814
- throw new PinataError(
1815
- "An unknown error occurred while fetching signature for CID"
1816
- );
1817
- }
1818
- };
1819
-
1820
- // src/core/signatures/removeSignature.ts
1821
- var removeSignature = async (config, cid) => {
1822
- if (!config) {
1823
- throw new ValidationError("Pinata configuration is missing");
1824
- }
1825
- let headers;
1826
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1827
- headers = { ...config.customHeaders };
1828
- } else {
1829
- headers = {
1830
- Authorization: `Bearer ${config.pinataJwt}`,
1831
- "Content-Type": "application/json",
1832
- Source: "sdk/removeSignature"
1833
- };
1834
- }
1835
- let endpoint = "https://api.pinata.cloud";
1836
- if (config.endpointUrl) {
1837
- endpoint = config.endpointUrl;
1838
- }
1839
- try {
1840
- const request = await fetch(`${endpoint}/v3/ipfs/signature/${cid}`, {
1841
- method: "DELETE",
1842
- headers
1843
- });
1844
- if (!request.ok) {
1845
- const errorData = await request.text();
1846
- if (request.status === 401 || request.status === 403) {
1847
- throw new AuthenticationError(
1848
- `Authentication failed: ${errorData}`,
1849
- request.status,
1850
- errorData
1851
- );
1852
- }
1853
- throw new NetworkError(
1854
- `HTTP error: ${errorData}`,
1855
- request.status,
1856
- errorData
1857
- );
1858
- }
1859
- return "OK";
1860
- } catch (error) {
1861
- if (error instanceof PinataError) {
1862
- throw error;
1863
- }
1864
- if (error instanceof Error) {
1865
- throw new PinataError(`Error processing addSignature: ${error.message}`);
1866
- }
1867
- throw new PinataError(
1868
- "An unknown error occurred while adding signature to CID"
1869
- );
1870
- }
1871
- };
1872
-
1873
- // src/core/gateway/analyticsTopUsage.ts
1874
- var analyticsTopUsage = async (config, options) => {
1875
- if (!config) {
1876
- throw new ValidationError("Pinata configuration is missing");
1877
- }
1878
- const params = new URLSearchParams({
1879
- includesCount: "false"
1880
- });
1881
- if (options) {
1882
- const {
1883
- cid,
1884
- gateway_domain,
1885
- start_date,
1886
- end_date,
1887
- file_name,
1888
- user_agent,
1889
- country,
1890
- region,
1891
- referer,
1892
- limit,
1893
- sort_order,
1894
- sort_by,
1895
- attribute
1896
- } = options;
1897
- if (cid)
1898
- params.append("cid", cid);
1899
- if (gateway_domain)
1900
- params.append("gateway_domain", gateway_domain);
1901
- if (start_date)
1902
- params.append("start_date", start_date);
1903
- if (end_date)
1904
- params.append("end_date", end_date);
1905
- if (file_name)
1906
- params.append("file_name", file_name);
1907
- if (user_agent)
1908
- params.append("user_agent", user_agent.toString());
1909
- if (country)
1910
- params.append("country", country.toString());
1911
- if (region)
1912
- params.append("region", region);
1913
- if (referer)
1914
- params.append("referer", referer.toString());
1915
- if (limit)
1916
- params.append("limit", limit.toString());
1917
- if (sort_order)
1918
- params.append("sort_order", sort_order);
1919
- if (sort_by)
1920
- params.append("sort_by", sort_by);
1921
- if (attribute)
1922
- params.append("by", attribute);
1923
- }
1924
- let endpoint = "https://api.pinata.cloud";
1925
- if (config.endpointUrl) {
1926
- endpoint = config.endpointUrl;
1927
- }
1928
- const url = `${endpoint}/v3/ipfs/gateway_analytics_top?${params.toString()}`;
1929
- try {
1930
- let headers;
1931
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
1932
- headers = { ...config.customHeaders };
1933
- } else {
1934
- headers = {
1935
- Authorization: `Bearer ${config.pinataJwt}`,
1936
- Source: "sdk/analyticsTopUsage"
1937
- };
1938
- }
1939
- const request = await fetch(url, {
1940
- method: "GET",
1941
- headers
1942
- });
1943
- if (!request.ok) {
1944
- const errorData = await request.text();
1945
- if (request.status === 401 || request.status === 403) {
1946
- throw new AuthenticationError(
1947
- `Authentication failed: ${errorData}`,
1948
- request.status,
1949
- errorData
1950
- );
1951
- }
1952
- throw new NetworkError(
1953
- `HTTP error: ${errorData}`,
1954
- request.status,
1955
- errorData
1956
- );
1957
- }
1958
- const res = await request.json();
1959
- const resData = res.data;
1960
- return resData;
1961
- } catch (error) {
1962
- if (error instanceof PinataError) {
1963
- throw error;
1964
- }
1965
- if (error instanceof Error) {
1966
- throw new PinataError(
1967
- `Error processing anaytics usage: ${error.message}`
1968
- );
1969
- }
1970
- throw new PinataError(
1971
- "An unknown error occurred while fetching gateway usage"
1972
- );
1973
- }
1974
- };
1975
-
1976
- // src/core/gateway/analyticsDateInterval.ts
1977
- var analyticsDateInterval = async (config, options) => {
1978
- if (!config) {
1979
- throw new ValidationError("Pinata configuration is missing");
1980
- }
1981
- const params = new URLSearchParams();
1982
- if (options) {
1983
- const {
1984
- cid,
1985
- gateway_domain,
1986
- start_date,
1987
- end_date,
1988
- file_name,
1989
- user_agent,
1990
- country,
1991
- region,
1992
- referer,
1993
- limit,
1994
- sort_order,
1995
- date_interval,
1996
- sort_by
1997
- } = options;
1998
- if (cid)
1999
- params.append("cid", cid);
2000
- if (gateway_domain)
2001
- params.append("gateway_domain", gateway_domain);
2002
- if (start_date)
2003
- params.append("start_date", start_date);
2004
- if (end_date)
2005
- params.append("end_date", end_date);
2006
- if (file_name)
2007
- params.append("file_name", file_name);
2008
- if (user_agent)
2009
- params.append("user_agent", user_agent.toString());
2010
- if (country)
2011
- params.append("country", country.toString());
2012
- if (region)
2013
- params.append("region", region);
2014
- if (referer)
2015
- params.append("referer", referer.toString());
2016
- if (limit)
2017
- params.append("limit", limit.toString());
2018
- if (sort_order)
2019
- params.append("sort_order", sort_order);
2020
- if (sort_by)
2021
- params.append("sort_by", sort_by);
2022
- if (date_interval)
2023
- params.append("by", date_interval);
2024
- }
2025
- let endpoint = "https://api.pinata.cloud";
2026
- if (config.endpointUrl) {
2027
- endpoint = config.endpointUrl;
2028
- }
2029
- const url = `${endpoint}/v3/ipfs/gateway_analytics_time_series?${params.toString()}`;
2030
- try {
2031
- let headers;
2032
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
2033
- headers = { ...config.customHeaders };
2034
- } else {
2035
- headers = {
2036
- Authorization: `Bearer ${config.pinataJwt}`,
2037
- Source: "sdk/analyticsDateInterval"
2038
- };
2039
- }
2040
- const request = await fetch(url, {
2041
- method: "GET",
2042
- headers
2043
- });
2044
- if (!request.ok) {
2045
- const errorData = await request.text();
2046
- if (request.status === 401 || request.status === 403) {
2047
- throw new AuthenticationError(
2048
- `Authentication failed: ${errorData}`,
2049
- request.status,
2050
- errorData
2051
- );
2052
- }
2053
- throw new NetworkError(
2054
- `HTTP error: ${errorData}`,
2055
- request.status,
2056
- errorData
2057
- );
2058
- }
2059
- const res = await request.json();
2060
- const resData = res.data;
2061
- return resData;
2062
- } catch (error) {
2063
- if (error instanceof PinataError) {
2064
- throw error;
2065
- }
2066
- if (error instanceof Error) {
2067
- throw new PinataError(
2068
- `Error processing anaytics usage: ${error.message}`
2069
- );
2070
- }
2071
- throw new PinataError(
2072
- "An unknown error occurred while fetching gateway usage"
2073
- );
2074
- }
2075
- };
2076
-
2077
- // src/core/gateway/swapCid.ts
2078
- var swapCid = async (config, options) => {
2079
- if (!config) {
2080
- throw new ValidationError("Pinata configuration is missing");
2081
- }
2082
- const data = JSON.stringify({
2083
- swapCid: options.swapCid
2084
- });
2085
- let headers;
2086
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
2087
- headers = { ...config.customHeaders };
2088
- } else {
2089
- headers = {
2090
- Authorization: `Bearer ${config.pinataJwt}`,
2091
- "Content-Type": "application/json",
2092
- Source: "sdk/swapCid"
2093
- };
2094
- }
2095
- let endpoint = "https://api.pinata.cloud";
1018
+ let endpoint = "https://api.pinata.cloud/v3";
2096
1019
  if (config.endpointUrl) {
2097
1020
  endpoint = config.endpointUrl;
2098
1021
  }
2099
1022
  try {
2100
- const request = await fetch(`${endpoint}/v3/ipfs/swap/${options.cid}`, {
1023
+ const request = await fetch(`${endpoint}/files/groups/${options.groupId}`, {
2101
1024
  method: "PUT",
2102
1025
  headers,
2103
1026
  body: data
@@ -2111,20 +1034,6 @@ var swapCid = async (config, options) => {
2111
1034
  errorData
2112
1035
  );
2113
1036
  }
2114
- if (request.status === 403) {
2115
- throw new PinataError(
2116
- "Unauthorized CID Swap",
2117
- request.status,
2118
- errorData
2119
- );
2120
- }
2121
- if (request.status === 404) {
2122
- throw new PinataError(
2123
- "CID not pinned to account",
2124
- request.status,
2125
- errorData
2126
- );
2127
- }
2128
1037
  throw new NetworkError(
2129
1038
  `HTTP error: ${errorData}`,
2130
1039
  request.status,
@@ -2139,14 +1048,14 @@ var swapCid = async (config, options) => {
2139
1048
  throw error;
2140
1049
  }
2141
1050
  if (error instanceof Error) {
2142
- throw new PinataError(`Error processing CID Swap: ${error.message}`);
1051
+ throw new PinataError(`Error processing updateGroup: ${error.message}`);
2143
1052
  }
2144
- throw new PinataError("An unknown error occurred while swapping CID");
1053
+ throw new PinataError("An unknown error occurred while updating group");
2145
1054
  }
2146
1055
  };
2147
1056
 
2148
- // src/core/gateway/swapHistory.ts
2149
- var swapHistory = async (config, options) => {
1057
+ // src/core/groups/deleteGroup.ts
1058
+ var deleteGroup = async (config, options) => {
2150
1059
  if (!config) {
2151
1060
  throw new ValidationError("Pinata configuration is missing");
2152
1061
  }
@@ -2157,21 +1066,18 @@ var swapHistory = async (config, options) => {
2157
1066
  headers = {
2158
1067
  Authorization: `Bearer ${config.pinataJwt}`,
2159
1068
  "Content-Type": "application/json",
2160
- Source: "sdk/swapHistory"
1069
+ Source: "sdk/deleteGroup"
2161
1070
  };
2162
1071
  }
2163
- let endpoint = "https://api.pinata.cloud";
1072
+ let endpoint = "https://api.pinata.cloud/v3";
2164
1073
  if (config.endpointUrl) {
2165
1074
  endpoint = config.endpointUrl;
2166
1075
  }
2167
1076
  try {
2168
- const request = await fetch(
2169
- `${endpoint}/v3/ipfs/swap/${options.cid}?domain=${options.domain}`,
2170
- {
2171
- method: "GET",
2172
- headers
2173
- }
2174
- );
1077
+ const request = await fetch(`${endpoint}/files/groups/${options.groupId}`, {
1078
+ method: "DELETE",
1079
+ headers
1080
+ });
2175
1081
  if (!request.ok) {
2176
1082
  const errorData = await request.text();
2177
1083
  if (request.status === 401 || request.status === 403) {
@@ -2181,78 +1087,52 @@ var swapHistory = async (config, options) => {
2181
1087
  errorData
2182
1088
  );
2183
1089
  }
2184
- if (request.status === 404) {
2185
- throw new PinataError(
2186
- "CID does not have history",
2187
- request.status,
2188
- errorData
2189
- );
2190
- }
2191
1090
  throw new NetworkError(
2192
1091
  `HTTP error: ${errorData}`,
2193
1092
  request.status,
2194
1093
  errorData
2195
1094
  );
2196
1095
  }
2197
- const res = await request.json();
2198
- const resData = res.data;
2199
- return resData;
1096
+ const res = request.statusText;
1097
+ return res;
2200
1098
  } catch (error) {
2201
1099
  if (error instanceof PinataError) {
2202
1100
  throw error;
2203
1101
  }
2204
1102
  if (error instanceof Error) {
2205
- throw new PinataError(`Error fetching swap history: ${error.message}`);
1103
+ throw new PinataError(`Error processing deleteGroup: ${error.message}`);
2206
1104
  }
2207
- throw new PinataError(
2208
- "An unknown error occurred while fetching swap history"
2209
- );
1105
+ throw new PinataError("An unknown error occurred while deleting a group");
2210
1106
  }
2211
1107
  };
2212
1108
 
2213
- // src/core/gateway/deleteSwap.ts
2214
- var deleteSwap = async (config, cid) => {
1109
+ // src/core/gateway/createSignedURL.ts
1110
+ var createSignedURL = async (config, options) => {
2215
1111
  if (!config) {
2216
1112
  throw new ValidationError("Pinata configuration is missing");
2217
1113
  }
2218
- let headers;
2219
- if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
2220
- headers = { ...config.customHeaders };
2221
- } else {
2222
- headers = {
2223
- Authorization: `Bearer ${config.pinataJwt}`,
2224
- "Content-Type": "application/json",
2225
- Source: "sdk/deleteSwap"
2226
- };
2227
- }
2228
- let endpoint = "https://api.pinata.cloud";
2229
- if (config.endpointUrl) {
2230
- endpoint = config.endpointUrl;
2231
- }
1114
+ let newUrl = `${config?.pinataGateway}/files/${options.cid}`;
1115
+ const date = options?.date || Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
1116
+ const payload = JSON.stringify({
1117
+ url: newUrl,
1118
+ date,
1119
+ expires: options.expires,
1120
+ method: "GET"
1121
+ });
2232
1122
  try {
2233
- const request = await fetch(`${endpoint}/v3/ipfs/swap/${cid}`, {
2234
- method: "DELETE",
2235
- headers
1123
+ const request = await fetch("https://api.pinata.cloud/v3/files/sign", {
1124
+ method: "POST",
1125
+ headers: {
1126
+ "Content-Type": "application/json",
1127
+ Authorization: `Bearer ${config?.pinataJwt}`
1128
+ },
1129
+ body: payload
2236
1130
  });
2237
1131
  if (!request.ok) {
2238
1132
  const errorData = await request.text();
2239
1133
  if (request.status === 401 || request.status === 403) {
2240
1134
  throw new AuthenticationError(
2241
- `Authentication failed: ${errorData}`,
2242
- request.status,
2243
- errorData
2244
- );
2245
- }
2246
- if (request.status === 403) {
2247
- throw new PinataError(
2248
- "Unauthorized CID Swap Deletion",
2249
- request.status,
2250
- errorData
2251
- );
2252
- }
2253
- if (request.status === 404) {
2254
- throw new PinataError(
2255
- "CID not pinned to account",
1135
+ `Authentication Failed: ${errorData}`,
2256
1136
  request.status,
2257
1137
  errorData
2258
1138
  );
@@ -2263,15 +1143,18 @@ var deleteSwap = async (config, cid) => {
2263
1143
  errorData
2264
1144
  );
2265
1145
  }
2266
- return request.statusText;
1146
+ const res = await request.json();
1147
+ return res.data;
2267
1148
  } catch (error) {
2268
1149
  if (error instanceof PinataError) {
2269
1150
  throw error;
2270
1151
  }
2271
1152
  if (error instanceof Error) {
2272
- throw new PinataError(`Error processing deleteSwap: ${error.message}`);
1153
+ throw new PinataError(
1154
+ `Error processing createSignedURL: ${error.message}`
1155
+ );
2273
1156
  }
2274
- throw new PinataError("An unknown error occurred while deleting swap");
1157
+ throw new PinataError("An unknown error occurred while getting signed url");
2275
1158
  }
2276
1159
  };
2277
1160
 
@@ -2287,41 +1170,45 @@ var formatConfig = (config) => {
2287
1170
  return config;
2288
1171
  };
2289
1172
  var PinataSDK = class {
1173
+ //signatures: Signatures;
2290
1174
  constructor(config) {
2291
1175
  this.config = formatConfig(config);
1176
+ this.files = new Files(this.config);
2292
1177
  this.upload = new Upload(this.config);
2293
1178
  this.gateways = new Gateways(this.config);
2294
- this.usage = new Usage(this.config);
2295
1179
  this.keys = new Keys(this.config);
2296
1180
  this.groups = new Groups(this.config);
2297
- this.signatures = new Signatures(this.config);
2298
1181
  }
2299
1182
  setNewHeaders(headers) {
2300
1183
  if (!this.config) {
2301
1184
  this.config = { pinataJwt: "", customHeaders: {} };
2302
1185
  }
2303
1186
  this.config.customHeaders = { ...this.config.customHeaders, ...headers };
1187
+ this.files.updateConfig(this.config);
2304
1188
  this.upload.updateConfig(this.config);
2305
1189
  this.gateways.updateConfig(this.config);
2306
- this.usage.updateConfig(this.config);
2307
1190
  this.keys.updateConfig(this.config);
2308
1191
  this.groups.updateConfig(this.config);
2309
- this.signatures.updateConfig(this.config);
2310
1192
  }
2311
1193
  testAuthentication() {
2312
1194
  return testAuthentication(this.config);
2313
1195
  }
2314
- unpin(files) {
2315
- return unpinFile(this.config, files);
1196
+ };
1197
+ var Files = class {
1198
+ constructor(config) {
1199
+ this.config = formatConfig(config);
1200
+ }
1201
+ updateConfig(newConfig) {
1202
+ this.config = newConfig;
2316
1203
  }
2317
- listFiles() {
1204
+ list() {
2318
1205
  return new FilterFiles(this.config);
2319
1206
  }
2320
- updateMetadata(options) {
2321
- return updateMetadata(this.config, options);
1207
+ delete(files) {
1208
+ return deleteFile(this.config, files);
2322
1209
  }
2323
- pinJobs() {
2324
- return new FilterPinJobs(this.config);
1210
+ update(options) {
1211
+ return updateFile(this.config, options);
2325
1212
  }
2326
1213
  };
2327
1214
  var UploadBuilder = class {
@@ -2329,7 +1216,6 @@ var UploadBuilder = class {
2329
1216
  this.config = config;
2330
1217
  this.uploadFunction = uploadFunction;
2331
1218
  this.args = args;
2332
- this.version = 1;
2333
1219
  }
2334
1220
  addMetadata(metadata) {
2335
1221
  this.metadata = metadata;
@@ -2339,18 +1225,14 @@ var UploadBuilder = class {
2339
1225
  this.keys = jwt;
2340
1226
  return this;
2341
1227
  }
2342
- cidVersion(v) {
2343
- this.version = v;
2344
- return this;
2345
- }
1228
+ // cidVersion(v: 0 | 1): UploadBuilder<T> {
1229
+ // this.version = v;
1230
+ // return this;
1231
+ // }
2346
1232
  group(groupId) {
2347
1233
  this.groupId = groupId;
2348
1234
  return this;
2349
1235
  }
2350
- peerAddress(peerAddresses) {
2351
- this.peerAddresses = peerAddresses;
2352
- return this;
2353
- }
2354
1236
  then(onfulfilled, onrejected) {
2355
1237
  const options = this.args[this.args.length - 1] || {};
2356
1238
  if (this.metadata) {
@@ -2362,12 +1244,6 @@ var UploadBuilder = class {
2362
1244
  if (this.groupId) {
2363
1245
  options.groupId = this.groupId;
2364
1246
  }
2365
- if (this.version) {
2366
- options.cidVersion = this.version;
2367
- }
2368
- if (this.peerAddresses && "peerAddresses" in options) {
2369
- options.peerAddresses = this.peerAddresses;
2370
- }
2371
1247
  this.args[this.args.length - 1] = options;
2372
1248
  return this.uploadFunction(this.config, ...this.args).then(
2373
1249
  onfulfilled,
@@ -2385,9 +1261,12 @@ var Upload = class {
2385
1261
  file(file, options) {
2386
1262
  return new UploadBuilder(this.config, uploadFile, file, options);
2387
1263
  }
2388
- fileArray(files, options) {
2389
- return new UploadBuilder(this.config, uploadFileArray, files, options);
2390
- }
1264
+ // fileArray(
1265
+ // files: FileObject[],
1266
+ // options?: UploadOptions,
1267
+ // ): UploadBuilder<UploadResponse> {
1268
+ // return new UploadBuilder(this.config, uploadFileArray, files, options);
1269
+ // }
2391
1270
  base64(base64String, options) {
2392
1271
  return new UploadBuilder(this.config, uploadBase64, base64String, options);
2393
1272
  }
@@ -2397,97 +1276,58 @@ var Upload = class {
2397
1276
  json(data, options) {
2398
1277
  return new UploadBuilder(this.config, uploadJson, data, options);
2399
1278
  }
2400
- cid(cid, options) {
2401
- return new UploadBuilder(this.config, uploadCid, cid, options);
2402
- }
2403
1279
  };
2404
1280
  var FilterFiles = class {
1281
+ // rate limit vars
1282
+ // private requestCount = 0;
1283
+ // private lastRequestTime = 0;
1284
+ // private readonly MAX_REQUESTS_PER_MINUTE = 30;
1285
+ // private readonly MINUTE_IN_MS = 60000;
2405
1286
  constructor(config) {
2406
1287
  this.query = {};
2407
- // rate limit vars
2408
- this.requestCount = 0;
2409
- this.lastRequestTime = 0;
2410
- this.MAX_REQUESTS_PER_MINUTE = 30;
2411
- this.MINUTE_IN_MS = 6e4;
2412
1288
  this.config = config;
2413
1289
  }
2414
- cid(cid) {
2415
- this.query.cid = cid;
2416
- return this;
2417
- }
2418
- pinStart(date) {
2419
- this.query.pinStart = date;
2420
- return this;
2421
- }
2422
- pinEnd(date) {
2423
- this.query.pinEnd = date;
2424
- return this;
2425
- }
2426
- pinSizeMin(size) {
2427
- this.query.pinSizeMin = size;
2428
- return this;
2429
- }
2430
- pinSizeMax(size) {
2431
- this.query.pinSizeMax = size;
2432
- return this;
2433
- }
2434
- pageLimit(limit) {
2435
- this.query.pageLimit = limit;
2436
- return this;
2437
- }
2438
- pageOffset(offset) {
2439
- this.query.pageOffset = offset;
2440
- return this;
2441
- }
2442
- name(name) {
2443
- this.query.name = name;
2444
- return this;
2445
- }
2446
- group(groupId) {
2447
- this.query.groupId = groupId;
1290
+ limit(limit) {
1291
+ this.query.limit = limit;
2448
1292
  return this;
2449
1293
  }
2450
- keyValue(key, value, operator) {
2451
- this.query.key = key;
2452
- this.query.value = value;
2453
- if (operator) {
2454
- this.query.operator = operator;
2455
- }
1294
+ cidPending(cidPending) {
1295
+ this.query.cidPending = cidPending;
2456
1296
  return this;
2457
1297
  }
2458
1298
  then(onfulfilled) {
2459
- return listFiles(this.config, this.query).then(onfulfilled);
2460
- }
2461
- // rate limit, hopefully temporary?
2462
- async rateLimit() {
2463
- this.requestCount++;
2464
- const now = Date.now();
2465
- if (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {
2466
- const timePassedSinceLastRequest = now - this.lastRequestTime;
2467
- if (timePassedSinceLastRequest < this.MINUTE_IN_MS) {
2468
- const delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;
2469
- await new Promise((resolve) => setTimeout(resolve, delayTime));
2470
- }
2471
- this.requestCount = 0;
2472
- }
2473
- this.lastRequestTime = Date.now();
2474
- }
1299
+ return this.fetchPage().then(onfulfilled);
1300
+ }
1301
+ async fetchPage() {
1302
+ if (this.currentPageToken) {
1303
+ this.query.pageToken = this.currentPageToken;
1304
+ }
1305
+ const response = await listFiles(this.config, this.query);
1306
+ this.currentPageToken = response.next_page_token;
1307
+ return response.files;
1308
+ }
1309
+ // // rate limit, hopefully temporary?
1310
+ // private async rateLimit(): Promise<void> {
1311
+ // this.requestCount++;
1312
+ // const now = Date.now();
1313
+ // if (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {
1314
+ // const timePassedSinceLastRequest = now - this.lastRequestTime;
1315
+ // if (timePassedSinceLastRequest < this.MINUTE_IN_MS) {
1316
+ // const delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;
1317
+ // await new Promise((resolve) => setTimeout(resolve, delayTime));
1318
+ // }
1319
+ // this.requestCount = 0;
1320
+ // }
1321
+ // this.lastRequestTime = Date.now();
1322
+ // }
2475
1323
  async *[Symbol.asyncIterator]() {
2476
- let hasMore = true;
2477
- let offset = 0;
2478
- const limit = this.query.pageLimit || 10;
2479
- while (hasMore) {
2480
- await this.rateLimit();
2481
- this.query.pageOffset = offset;
2482
- this.query.pageLimit = limit;
2483
- const items = await listFiles(this.config, this.query);
1324
+ while (true) {
1325
+ const items = await this.fetchPage();
2484
1326
  for (const item of items) {
2485
1327
  yield item;
2486
1328
  }
2487
- if (items.length === 0) {
2488
- hasMore = false;
2489
- } else {
2490
- offset += items.length;
1329
+ if (!this.currentPageToken) {
1330
+ break;
2491
1331
  }
2492
1332
  }
2493
1333
  }
@@ -2509,125 +1349,63 @@ var Gateways = class {
2509
1349
  get(cid) {
2510
1350
  return getCid(this.config, cid);
2511
1351
  }
2512
- convert(url) {
2513
- return convertIPFSUrl(this.config, url);
2514
- }
2515
- topUsageAnalytics(options) {
2516
- return new TopGatewayAnalyticsBuilder(
2517
- this.config,
2518
- options.domain,
2519
- options.start,
2520
- options.end,
2521
- options.sortBy,
2522
- options.attribute
2523
- );
2524
- }
2525
- dateIntervalAnalytics(options) {
2526
- return new TimeIntervalGatewayAnalyticsBuilder(
2527
- this.config,
2528
- options.domain,
2529
- options.start,
2530
- options.end,
2531
- options.interval
2532
- );
2533
- }
2534
- swapCid(options) {
2535
- return swapCid(this.config, options);
2536
- }
2537
- swapHistory(options) {
2538
- return swapHistory(this.config, options);
2539
- }
2540
- deleteSwap(cid) {
2541
- return deleteSwap(this.config, cid);
2542
- }
2543
- };
2544
- var FilterPinJobs = class {
2545
- constructor(config) {
2546
- this.query = {};
2547
- // rate limit vars
2548
- this.requestCount = 0;
2549
- this.lastRequestTime = 0;
2550
- this.MAX_REQUESTS_PER_MINUTE = 30;
2551
- this.MINUTE_IN_MS = 6e4;
2552
- this.config = config;
2553
- }
2554
- cid(cid) {
2555
- this.query.ipfs_pin_hash = cid;
2556
- return this;
2557
- }
2558
- status(status) {
2559
- this.query.status = status;
2560
- return this;
2561
- }
2562
- pageLimit(limit) {
2563
- this.query.limit = limit;
2564
- return this;
2565
- }
2566
- pageOffset(offset) {
2567
- this.query.offset = offset;
2568
- return this;
2569
- }
2570
- sort(sort) {
2571
- this.query.sort = sort;
2572
- return this;
2573
- }
2574
- then(onfulfilled) {
2575
- return pinJobs(this.config, this.query).then(onfulfilled);
2576
- }
2577
- // rate limit, hopefully temporary?
2578
- async rateLimit() {
2579
- this.requestCount++;
2580
- const now = Date.now();
2581
- if (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {
2582
- const timePassedSinceLastRequest = now - this.lastRequestTime;
2583
- if (timePassedSinceLastRequest < this.MINUTE_IN_MS) {
2584
- const delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;
2585
- await new Promise((resolve) => setTimeout(resolve, delayTime));
2586
- }
2587
- this.requestCount = 0;
2588
- }
2589
- this.lastRequestTime = Date.now();
2590
- }
2591
- async *[Symbol.asyncIterator]() {
2592
- let hasMore = true;
2593
- let offset = 0;
2594
- const limit = this.query.limit || 10;
2595
- while (hasMore) {
2596
- await this.rateLimit();
2597
- this.query.offset = offset;
2598
- this.query.limit = limit;
2599
- const items = await pinJobs(this.config, this.query);
2600
- for (const item of items) {
2601
- yield item;
2602
- }
2603
- if (items.length === 0) {
2604
- hasMore = false;
2605
- } else {
2606
- offset += items.length;
2607
- }
2608
- }
2609
- }
2610
- async all() {
2611
- const allItems = [];
2612
- for await (const item of this) {
2613
- allItems.push(item);
2614
- }
2615
- return allItems;
2616
- }
2617
- };
2618
- var Usage = class {
2619
- constructor(config) {
2620
- this.config = formatConfig(config);
2621
- }
2622
- updateConfig(newConfig) {
2623
- this.config = newConfig;
2624
- }
2625
- pinnedFileCount() {
2626
- return pinnedFileCount(this.config);
2627
- }
2628
- totalStorageSize() {
2629
- return totalStorageUsage(this.config);
2630
- }
1352
+ createSignedURL(options) {
1353
+ return createSignedURL(this.config, options);
1354
+ }
1355
+ // get(cid: string): OptimizeImage {
1356
+ // return new OptimizeImage(this.config, cid);
1357
+ // }
1358
+ // convert(url: string, gatewayPrefix?: string): Promise<string> {
1359
+ // return convertIPFSUrl(this.config, url, gatewayPrefix);
1360
+ // }
1361
+ // containsCID(cid: string): Promise<ContainsCIDResponse> {
1362
+ // return containsCID(cid);
1363
+ // }
1364
+ // topUsageAnalytics(options: {
1365
+ // domain: string;
1366
+ // start: string;
1367
+ // end: string;
1368
+ // sortBy: "requests" | "bandwidth";
1369
+ // attribute:
1370
+ // | "cid"
1371
+ // | "country"
1372
+ // | "region"
1373
+ // | "user_agent"
1374
+ // | "referer"
1375
+ // | "file_name";
1376
+ // }): TopGatewayAnalyticsBuilder {
1377
+ // return new TopGatewayAnalyticsBuilder(
1378
+ // this.config,
1379
+ // options.domain,
1380
+ // options.start,
1381
+ // options.end,
1382
+ // options.sortBy,
1383
+ // options.attribute,
1384
+ // );
1385
+ // }
1386
+ // dateIntervalAnalytics(options: {
1387
+ // domain: string;
1388
+ // start: string;
1389
+ // end: string;
1390
+ // interval: "day" | "week";
1391
+ // }): TimeIntervalGatewayAnalyticsBuilder {
1392
+ // return new TimeIntervalGatewayAnalyticsBuilder(
1393
+ // this.config,
1394
+ // options.domain,
1395
+ // options.start,
1396
+ // options.end,
1397
+ // options.interval,
1398
+ // );
1399
+ // }
1400
+ // swapCid(options: SwapCidOptions): Promise<SwapCidResponse> {
1401
+ // return swapCid(this.config, options);
1402
+ // }
1403
+ // swapHistory(options: SwapHistoryOptions): Promise<SwapCidResponse[]> {
1404
+ // return swapHistory(this.config, options);
1405
+ // }
1406
+ // deleteSwap(cid: string): Promise<string> {
1407
+ // return deleteSwap(this.config, cid);
1408
+ // }
2631
1409
  };
2632
1410
  var Keys = class {
2633
1411
  constructor(config) {
@@ -2647,13 +1425,13 @@ var Keys = class {
2647
1425
  }
2648
1426
  };
2649
1427
  var FilterKeys = class {
1428
+ // rate limit vars
1429
+ // private requestCount = 0;
1430
+ // private lastRequestTime = 0;
1431
+ // private readonly MAX_REQUESTS_PER_MINUTE = 30;
1432
+ // private readonly MINUTE_IN_MS = 60000;
2650
1433
  constructor(config) {
2651
1434
  this.query = {};
2652
- // rate limit vars
2653
- this.requestCount = 0;
2654
- this.lastRequestTime = 0;
2655
- this.MAX_REQUESTS_PER_MINUTE = 30;
2656
- this.MINUTE_IN_MS = 6e4;
2657
1435
  this.config = config;
2658
1436
  }
2659
1437
  offset(offset) {
@@ -2679,25 +1457,23 @@ var FilterKeys = class {
2679
1457
  then(onfulfilled) {
2680
1458
  return listKeys(this.config, this.query).then(onfulfilled);
2681
1459
  }
2682
- // rate limit, hopefully temporary?
2683
- async rateLimit() {
2684
- this.requestCount++;
2685
- const now = Date.now();
2686
- if (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {
2687
- const timePassedSinceLastRequest = now - this.lastRequestTime;
2688
- if (timePassedSinceLastRequest < this.MINUTE_IN_MS) {
2689
- const delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;
2690
- await new Promise((resolve) => setTimeout(resolve, delayTime));
2691
- }
2692
- this.requestCount = 0;
2693
- }
2694
- this.lastRequestTime = Date.now();
2695
- }
1460
+ // private async rateLimit(): Promise<void> {
1461
+ // this.requestCount++;
1462
+ // const now = Date.now();
1463
+ // if (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {
1464
+ // const timePassedSinceLastRequest = now - this.lastRequestTime;
1465
+ // if (timePassedSinceLastRequest < this.MINUTE_IN_MS) {
1466
+ // const delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;
1467
+ // await new Promise((resolve) => setTimeout(resolve, delayTime));
1468
+ // }
1469
+ // this.requestCount = 0;
1470
+ // }
1471
+ // this.lastRequestTime = Date.now();
1472
+ // }
2696
1473
  async *[Symbol.asyncIterator]() {
2697
1474
  let hasMore = true;
2698
1475
  let offset = 0;
2699
1476
  while (hasMore) {
2700
- await this.rateLimit();
2701
1477
  this.query.offset = offset;
2702
1478
  const items = await listKeys(this.config, this.query);
2703
1479
  for (const item of items) {
@@ -2734,12 +1510,12 @@ var Groups = class {
2734
1510
  get(options) {
2735
1511
  return getGroup(this.config, options);
2736
1512
  }
2737
- addCids(options) {
2738
- return addToGroup(this.config, options);
2739
- }
2740
- removeCids(options) {
2741
- return removeFromGroup(this.config, options);
2742
- }
1513
+ // addFiles(options: GroupCIDOptions): Promise<string> {
1514
+ // return addToGroup(this.config, options);
1515
+ // }
1516
+ // removeFiles(options: GroupCIDOptions): Promise<string> {
1517
+ // return removeFromGroup(this.config, options);
1518
+ // }
2743
1519
  update(options) {
2744
1520
  return updateGroup(this.config, options);
2745
1521
  }
@@ -2750,57 +1526,56 @@ var Groups = class {
2750
1526
  var FilterGroups = class {
2751
1527
  constructor(config) {
2752
1528
  this.query = {};
2753
- // rate limit vars
2754
- this.requestCount = 0;
2755
- this.lastRequestTime = 0;
2756
- this.MAX_REQUESTS_PER_MINUTE = 30;
2757
- this.MINUTE_IN_MS = 6e4;
2758
1529
  this.config = config;
2759
1530
  }
2760
- offset(offset) {
2761
- this.query.offset = offset;
2762
- return this;
2763
- }
2764
- name(nameContains) {
2765
- this.query.nameContains = nameContains;
2766
- return this;
2767
- }
1531
+ // name(nameContains: string): FilterGroups {
1532
+ // this.query.nameContains = nameContains;
1533
+ // return this;
1534
+ // }
2768
1535
  limit(limit) {
2769
1536
  this.query.limit = limit;
2770
1537
  return this;
2771
1538
  }
1539
+ isPublic(isPublic) {
1540
+ this.query.isPublic = isPublic;
1541
+ return this;
1542
+ }
2772
1543
  then(onfulfilled) {
2773
- return listGroups(this.config, this.query).then(onfulfilled);
1544
+ return this.fetchPage().then((response) => {
1545
+ this.nextPageToken = response.next_page_token;
1546
+ return response.groups;
1547
+ }).then(onfulfilled);
2774
1548
  }
2775
- // rate limit, hopefully temporary?
2776
- async rateLimit() {
2777
- this.requestCount++;
2778
- const now = Date.now();
2779
- if (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {
2780
- const timePassedSinceLastRequest = now - this.lastRequestTime;
2781
- if (timePassedSinceLastRequest < this.MINUTE_IN_MS) {
2782
- const delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;
2783
- await new Promise((resolve) => setTimeout(resolve, delayTime));
2784
- }
2785
- this.requestCount = 0;
1549
+ async fetchPage() {
1550
+ if (this.nextPageToken) {
1551
+ this.query.pageToken = this.nextPageToken;
2786
1552
  }
2787
- this.lastRequestTime = Date.now();
1553
+ return listGroups(this.config, this.query);
2788
1554
  }
1555
+ // rate limit, hopefully temporary?
1556
+ // private async rateLimit(): Promise<void> {
1557
+ // this.requestCount++;
1558
+ // const now = Date.now();
1559
+ // if (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {
1560
+ // const timePassedSinceLastRequest = now - this.lastRequestTime;
1561
+ // if (timePassedSinceLastRequest < this.MINUTE_IN_MS) {
1562
+ // const delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;
1563
+ // await new Promise((resolve) => setTimeout(resolve, delayTime));
1564
+ // }
1565
+ // this.requestCount = 0;
1566
+ // }
1567
+ // this.lastRequestTime = Date.now();
1568
+ // }
2789
1569
  async *[Symbol.asyncIterator]() {
2790
- let hasMore = true;
2791
- let offset = 0;
2792
- while (hasMore) {
2793
- await this.rateLimit();
2794
- this.query.offset = offset;
2795
- const items = await listGroups(this.config, this.query);
2796
- for (const item of items) {
1570
+ while (true) {
1571
+ const response = await this.fetchPage();
1572
+ for (const item of response.groups) {
2797
1573
  yield item;
2798
1574
  }
2799
- if (items.length === 0) {
2800
- hasMore = false;
2801
- } else {
2802
- offset += items.length;
1575
+ if (!response.next_page_token) {
1576
+ break;
2803
1577
  }
1578
+ this.nextPageToken = response.next_page_token;
2804
1579
  }
2805
1580
  }
2806
1581
  async all() {
@@ -2811,122 +1586,6 @@ var FilterGroups = class {
2811
1586
  return allItems;
2812
1587
  }
2813
1588
  };
2814
- var Signatures = class {
2815
- constructor(config) {
2816
- this.config = formatConfig(config);
2817
- }
2818
- updateConfig(newConfig) {
2819
- this.config = newConfig;
2820
- }
2821
- add(options) {
2822
- return addSignature(this.config, options);
2823
- }
2824
- get(cid) {
2825
- return getSignature(this.config, cid);
2826
- }
2827
- delete(cid) {
2828
- return removeSignature(this.config, cid);
2829
- }
2830
- };
2831
- var GatewayAnalyticsBuilder = class {
2832
- constructor(config, query) {
2833
- this.requestCount = 0;
2834
- this.lastRequestTime = 0;
2835
- this.MAX_REQUESTS_PER_MINUTE = 30;
2836
- this.MINUTE_IN_MS = 6e4;
2837
- this.config = config;
2838
- this.query = query;
2839
- }
2840
- cid(cid) {
2841
- this.query.cid = cid;
2842
- return this;
2843
- }
2844
- fileName(fileName) {
2845
- this.query.file_name = fileName;
2846
- return this;
2847
- }
2848
- userAgent(userAgent) {
2849
- this.query.user_agent = userAgent;
2850
- return this;
2851
- }
2852
- country(country) {
2853
- this.query.country = country;
2854
- return this;
2855
- }
2856
- region(region) {
2857
- this.query.region = region;
2858
- return this;
2859
- }
2860
- referer(referer) {
2861
- this.query.referer = referer;
2862
- return this;
2863
- }
2864
- limit(limit) {
2865
- this.query.limit = limit;
2866
- return this;
2867
- }
2868
- sort(order) {
2869
- this.query.sort_order = order;
2870
- return this;
2871
- }
2872
- async rateLimit() {
2873
- this.requestCount++;
2874
- const now = Date.now();
2875
- if (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {
2876
- const timePassedSinceLastRequest = now - this.lastRequestTime;
2877
- if (timePassedSinceLastRequest < this.MINUTE_IN_MS) {
2878
- const delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;
2879
- await new Promise((resolve) => setTimeout(resolve, delayTime));
2880
- }
2881
- this.requestCount = 0;
2882
- }
2883
- this.lastRequestTime = Date.now();
2884
- }
2885
- async getAnalytics() {
2886
- await this.rateLimit();
2887
- throw new Error("getAnalytics method must be implemented in derived class");
2888
- }
2889
- then(onfulfilled) {
2890
- return this.getAnalytics().then(onfulfilled);
2891
- }
2892
- };
2893
- var TopGatewayAnalyticsBuilder = class extends GatewayAnalyticsBuilder {
2894
- constructor(config, domain, start, end, sortBy, attribute) {
2895
- super(config, {
2896
- gateway_domain: domain,
2897
- start_date: start,
2898
- end_date: end,
2899
- sort_by: sortBy,
2900
- attribute
2901
- });
2902
- }
2903
- async getAnalytics() {
2904
- return analyticsTopUsage(this.config, this.query);
2905
- }
2906
- async all() {
2907
- return this.getAnalytics();
2908
- }
2909
- };
2910
- var TimeIntervalGatewayAnalyticsBuilder = class extends GatewayAnalyticsBuilder {
2911
- constructor(config, domain, start, end, dateInterval) {
2912
- super(config, {
2913
- gateway_domain: domain,
2914
- start_date: start,
2915
- end_date: end,
2916
- date_interval: dateInterval
2917
- });
2918
- }
2919
- sortBy(sortBy) {
2920
- this.query.sort_by = sortBy;
2921
- return this;
2922
- }
2923
- async getAnalytics() {
2924
- return analyticsDateInterval(this.config, this.query);
2925
- }
2926
- async all() {
2927
- return this.getAnalytics();
2928
- }
2929
- };
2930
1589
  // Annotate the CommonJS export names for ESM import in node:
2931
1590
  0 && (module.exports = {
2932
1591
  PinataSDK