pinata 0.3.1 → 0.3.3

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.mjs CHANGED
@@ -28,8 +28,8 @@ var ValidationError = class extends PinataError {
28
28
 
29
29
  // src/core/authentication/testAuthentication.ts
30
30
  var testAuthentication = async (config) => {
31
- if (!config || !config.pinataJwt) {
32
- throw new ValidationError("Pinata configuration or JWT is missing");
31
+ if (!config) {
32
+ throw new ValidationError("Pinata configuration is missing");
33
33
  }
34
34
  let headers;
35
35
  let endpoint = "https://api.pinata.cloud";
@@ -83,8 +83,8 @@ var testAuthentication = async (config) => {
83
83
 
84
84
  // src/core/pinning/file.ts
85
85
  var uploadFile = async (config, file, options) => {
86
- if (!config || !config.pinataJwt) {
87
- throw new ValidationError("Pinata configuration or JWT is missing");
86
+ if (!config) {
87
+ throw new ValidationError("Pinata configuration is missing");
88
88
  }
89
89
  const jwt = options?.keys || config.pinataJwt;
90
90
  const data = new FormData();
@@ -152,8 +152,8 @@ var uploadFile = async (config, file, options) => {
152
152
 
153
153
  // src/core/pinning/fileArray.ts
154
154
  var uploadFileArray = async (config, files, options) => {
155
- if (!config || !config.pinataJwt) {
156
- throw new ValidationError("Pinata configuration or JWT is missing");
155
+ if (!config) {
156
+ throw new ValidationError("Pinata configuration is missing");
157
157
  }
158
158
  const jwt = options?.keys || config?.pinataJwt;
159
159
  const folder = options?.metadata?.name || "folder_from_sdk";
@@ -226,8 +226,8 @@ var uploadFileArray = async (config, files, options) => {
226
226
 
227
227
  // src/core/pinning/base64.ts
228
228
  var uploadBase64 = async (config, base64String, options) => {
229
- if (!config || !config.pinataJwt) {
230
- throw new ValidationError("Pinata configuration or JWT is missing");
229
+ if (!config) {
230
+ throw new ValidationError("Pinata configuration is missing");
231
231
  }
232
232
  const jwt = options?.keys || config?.pinataJwt;
233
233
  const name = options?.metadata?.name ? options?.metadata?.name : "base64 string";
@@ -300,8 +300,8 @@ var uploadBase64 = async (config, base64String, options) => {
300
300
 
301
301
  // src/core/pinning/url.ts
302
302
  var uploadUrl = async (config, url, options) => {
303
- if (!config || !config.pinataJwt) {
304
- throw new ValidationError("Pinata configuration or JWT is missing");
303
+ if (!config) {
304
+ throw new ValidationError("Pinata configuration is missing");
305
305
  }
306
306
  const jwt = options?.keys || config?.pinataJwt;
307
307
  const data = new FormData();
@@ -382,8 +382,8 @@ var uploadUrl = async (config, url, options) => {
382
382
 
383
383
  // src/core/pinning/json.ts
384
384
  var uploadJson = async (config, jsonData, options) => {
385
- if (!config || !config.pinataJwt) {
386
- throw new ValidationError("Pinata configuration or JWT is missing");
385
+ if (!config) {
386
+ throw new ValidationError("Pinata configuration is missing");
387
387
  }
388
388
  const jwt = options?.keys || config?.pinataJwt;
389
389
  const data = JSON.stringify({
@@ -447,8 +447,8 @@ var uploadJson = async (config, jsonData, options) => {
447
447
 
448
448
  // src/core/pinning/cid.ts
449
449
  var uploadCid = async (config, cid, options) => {
450
- if (!config || !config.pinataJwt) {
451
- throw new ValidationError("Pinata configuration or JWT is missing");
450
+ if (!config) {
451
+ throw new ValidationError("Pinata configuration is missing");
452
452
  }
453
453
  const jwt = options?.keys || config?.pinataJwt;
454
454
  let headers;
@@ -517,8 +517,8 @@ var wait = (milliseconds) => {
517
517
  });
518
518
  };
519
519
  var unpinFile = async (config, files) => {
520
- if (!config || !config.pinataJwt) {
521
- throw new ValidationError("Pinata configuration or JWT is missing");
520
+ if (!config) {
521
+ throw new ValidationError("Pinata configuration is missing");
522
522
  }
523
523
  const responses = [];
524
524
  let headers;
@@ -581,8 +581,8 @@ var unpinFile = async (config, files) => {
581
581
 
582
582
  // src/core/data/listFiles.ts
583
583
  var listFiles = async (config, options) => {
584
- if (!config || !config.pinataJwt) {
585
- throw new ValidationError("Pinata configuration or JWT is missing");
584
+ if (!config) {
585
+ throw new ValidationError("Pinata configuration is missing");
586
586
  }
587
587
  const params = new URLSearchParams({
588
588
  includesCount: "false"
@@ -676,8 +676,8 @@ var listFiles = async (config, options) => {
676
676
 
677
677
  // src/core/data/updateMetadata.ts
678
678
  var updateMetadata = async (config, options) => {
679
- if (!config || !config.pinataJwt) {
680
- throw new ValidationError("Pinata configuration or JWT is missing");
679
+ if (!config) {
680
+ throw new ValidationError("Pinata configuration is missing");
681
681
  }
682
682
  const data = {
683
683
  ipfsPinHash: options.cid,
@@ -830,8 +830,8 @@ async function convertToDesiredGateway(sourceUrl, desiredGatewayPrefix) {
830
830
 
831
831
  // src/core/gateway/getCid.ts
832
832
  var getCid = async (config, cid) => {
833
- if (!config || !config.pinataJwt) {
834
- throw new ValidationError("Pinata configuration or JWT is missing");
833
+ if (!config) {
834
+ throw new ValidationError("Pinata configuration is missing");
835
835
  }
836
836
  let data;
837
837
  let newUrl;
@@ -840,12 +840,7 @@ var getCid = async (config, cid) => {
840
840
  newUrl = `${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;
841
841
  }
842
842
  try {
843
- const request = await fetch(newUrl, {
844
- method: "GET",
845
- headers: {
846
- Source: "sdk/getCid"
847
- }
848
- });
843
+ const request = await fetch(newUrl);
849
844
  if (!request.ok) {
850
845
  const errorData = await request.json();
851
846
  if (request.status === 401) {
@@ -899,8 +894,8 @@ var convertIPFSUrl = async (config, url) => {
899
894
 
900
895
  // src/core/data/pinJobs.ts
901
896
  var pinJobs = async (config, options) => {
902
- if (!config || !config.pinataJwt) {
903
- throw new ValidationError("Pinata configuration or JWT is missing");
897
+ if (!config) {
898
+ throw new ValidationError("Pinata configuration is missing");
904
899
  }
905
900
  const params = new URLSearchParams({
906
901
  includesCount: "false"
@@ -967,8 +962,8 @@ var pinJobs = async (config, options) => {
967
962
 
968
963
  // src/core/data/pinnedFileUsage.ts
969
964
  var pinnedFileCount = async (config) => {
970
- if (!config || !config.pinataJwt) {
971
- throw new ValidationError("Pinata configuration or JWT is missing");
965
+ if (!config) {
966
+ throw new ValidationError("Pinata configuration is missing");
972
967
  }
973
968
  let endpoint = "https://api.pinata.cloud";
974
969
  if (config.endpointUrl) {
@@ -1022,8 +1017,8 @@ var pinnedFileCount = async (config) => {
1022
1017
 
1023
1018
  // src/core/data/totalStorageUsage.ts
1024
1019
  var totalStorageUsage = async (config) => {
1025
- if (!config || !config.pinataJwt) {
1026
- throw new ValidationError("Pinata configuration or JWT is missing");
1020
+ if (!config) {
1021
+ throw new ValidationError("Pinata configuration is missing");
1027
1022
  }
1028
1023
  let endpoint = "https://api.pinata.cloud";
1029
1024
  if (config.endpointUrl) {
@@ -1077,8 +1072,8 @@ var totalStorageUsage = async (config) => {
1077
1072
 
1078
1073
  // src/core/keys/createKey.ts
1079
1074
  var createKey = async (config, options) => {
1080
- if (!config || !config.pinataJwt) {
1081
- throw new ValidationError("Pinata configuration or JWT is missing");
1075
+ if (!config) {
1076
+ throw new ValidationError("Pinata configuration is missing");
1082
1077
  }
1083
1078
  let headers;
1084
1079
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -1131,8 +1126,8 @@ var createKey = async (config, options) => {
1131
1126
 
1132
1127
  // src/core/keys/listKeys.ts
1133
1128
  var listKeys = async (config, options) => {
1134
- if (!config || !config.pinataJwt) {
1135
- throw new ValidationError("Pinata configuration or JWT is missing");
1129
+ if (!config) {
1130
+ throw new ValidationError("Pinata configuration is missing");
1136
1131
  }
1137
1132
  let headers;
1138
1133
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -1205,8 +1200,8 @@ var wait2 = (milliseconds) => {
1205
1200
  });
1206
1201
  };
1207
1202
  var revokeKeys = async (config, keys) => {
1208
- if (!config || !config.pinataJwt) {
1209
- throw new ValidationError("Pinata configuration or JWT is missing");
1203
+ if (!config) {
1204
+ throw new ValidationError("Pinata configuration is missing");
1210
1205
  }
1211
1206
  let headers;
1212
1207
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -1270,8 +1265,8 @@ var revokeKeys = async (config, keys) => {
1270
1265
 
1271
1266
  // src/core/groups/createGroup.ts
1272
1267
  var createGroup = async (config, options) => {
1273
- if (!config || !config.pinataJwt) {
1274
- throw new ValidationError("Pinata configuration or JWT is missing");
1268
+ if (!config) {
1269
+ throw new ValidationError("Pinata configuration is missing");
1275
1270
  }
1276
1271
  const data = JSON.stringify(options);
1277
1272
  let headers;
@@ -1324,8 +1319,8 @@ var createGroup = async (config, options) => {
1324
1319
 
1325
1320
  // src/core/groups/listGroups.ts
1326
1321
  var listGroups = async (config, options) => {
1327
- if (!config || !config.pinataJwt) {
1328
- throw new ValidationError("Pinata configuration or JWT is missing");
1322
+ if (!config) {
1323
+ throw new ValidationError("Pinata configuration is missing");
1329
1324
  }
1330
1325
  let headers;
1331
1326
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -1386,8 +1381,8 @@ var listGroups = async (config, options) => {
1386
1381
 
1387
1382
  // src/core/groups/getGroup.ts
1388
1383
  var getGroup = async (config, options) => {
1389
- if (!config || !config.pinataJwt) {
1390
- throw new ValidationError("Pinata configuration or JWT is missing");
1384
+ if (!config) {
1385
+ throw new ValidationError("Pinata configuration is missing");
1391
1386
  }
1392
1387
  let headers;
1393
1388
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -1440,8 +1435,8 @@ var getGroup = async (config, options) => {
1440
1435
 
1441
1436
  // src/core/groups/addToGroup.ts
1442
1437
  var addToGroup = async (config, options) => {
1443
- if (!config || !config.pinataJwt) {
1444
- throw new ValidationError("Pinata configuration or JWT is missing");
1438
+ if (!config) {
1439
+ throw new ValidationError("Pinata configuration is missing");
1445
1440
  }
1446
1441
  const data = JSON.stringify({
1447
1442
  cids: options.cids
@@ -1498,8 +1493,8 @@ var addToGroup = async (config, options) => {
1498
1493
 
1499
1494
  // src/core/groups/updateGroup.ts
1500
1495
  var updateGroup = async (config, options) => {
1501
- if (!config || !config.pinataJwt) {
1502
- throw new ValidationError("Pinata configuration or JWT is missing");
1496
+ if (!config) {
1497
+ throw new ValidationError("Pinata configuration is missing");
1503
1498
  }
1504
1499
  const data = JSON.stringify({
1505
1500
  name: options.name
@@ -1554,8 +1549,8 @@ var updateGroup = async (config, options) => {
1554
1549
 
1555
1550
  // src/core/groups/removeFromGroup.ts
1556
1551
  var removeFromGroup = async (config, options) => {
1557
- if (!config || !config.pinataJwt) {
1558
- throw new ValidationError("Pinata configuration or JWT is missing");
1552
+ if (!config) {
1553
+ throw new ValidationError("Pinata configuration is missing");
1559
1554
  }
1560
1555
  let headers;
1561
1556
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -1614,8 +1609,8 @@ var removeFromGroup = async (config, options) => {
1614
1609
 
1615
1610
  // src/core/groups/deleteGroup.ts
1616
1611
  var deleteGroup = async (config, options) => {
1617
- if (!config || !config.pinataJwt) {
1618
- throw new ValidationError("Pinata configuration or JWT is missing");
1612
+ if (!config) {
1613
+ throw new ValidationError("Pinata configuration is missing");
1619
1614
  }
1620
1615
  let headers;
1621
1616
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -1666,8 +1661,8 @@ var deleteGroup = async (config, options) => {
1666
1661
 
1667
1662
  // src/core/signatures/addSignature.ts
1668
1663
  var addSignature = async (config, options) => {
1669
- if (!config || !config.pinataJwt) {
1670
- throw new ValidationError("Pinata configuration or JWT is missing");
1664
+ if (!config) {
1665
+ throw new ValidationError("Pinata configuration is missing");
1671
1666
  }
1672
1667
  const data = JSON.stringify({
1673
1668
  signature: options.signature
@@ -1734,8 +1729,8 @@ var addSignature = async (config, options) => {
1734
1729
 
1735
1730
  // src/core/signatures/getSignature.ts
1736
1731
  var getSignature = async (config, cid) => {
1737
- if (!config || !config.pinataJwt) {
1738
- throw new ValidationError("Pinata configuration or JWT is missing");
1732
+ if (!config) {
1733
+ throw new ValidationError("Pinata configuration is missing");
1739
1734
  }
1740
1735
  let headers;
1741
1736
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -1788,8 +1783,8 @@ var getSignature = async (config, cid) => {
1788
1783
 
1789
1784
  // src/core/signatures/removeSignature.ts
1790
1785
  var removeSignature = async (config, cid) => {
1791
- if (!config || !config.pinataJwt) {
1792
- throw new ValidationError("Pinata configuration or JWT is missing");
1786
+ if (!config) {
1787
+ throw new ValidationError("Pinata configuration is missing");
1793
1788
  }
1794
1789
  let headers;
1795
1790
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -1841,8 +1836,8 @@ var removeSignature = async (config, cid) => {
1841
1836
 
1842
1837
  // src/core/gateway/analyticsTopUsage.ts
1843
1838
  var analyticsTopUsage = async (config, options) => {
1844
- if (!config || !config.pinataJwt) {
1845
- throw new ValidationError("Pinata configuration or JWT is missing");
1839
+ if (!config) {
1840
+ throw new ValidationError("Pinata configuration is missing");
1846
1841
  }
1847
1842
  const params = new URLSearchParams({
1848
1843
  includesCount: "false"
@@ -1944,8 +1939,8 @@ var analyticsTopUsage = async (config, options) => {
1944
1939
 
1945
1940
  // src/core/gateway/analyticsDateInterval.ts
1946
1941
  var analyticsDateInterval = async (config, options) => {
1947
- if (!config || !config.pinataJwt) {
1948
- throw new ValidationError("Pinata configuration or JWT is missing");
1942
+ if (!config) {
1943
+ throw new ValidationError("Pinata configuration is missing");
1949
1944
  }
1950
1945
  const params = new URLSearchParams();
1951
1946
  if (options) {
@@ -2045,8 +2040,8 @@ var analyticsDateInterval = async (config, options) => {
2045
2040
 
2046
2041
  // src/core/gateway/swapCid.ts
2047
2042
  var swapCid = async (config, options) => {
2048
- if (!config || !config.pinataJwt) {
2049
- throw new ValidationError("Pinata configuration or JWT is missing");
2043
+ if (!config) {
2044
+ throw new ValidationError("Pinata configuration is missing");
2050
2045
  }
2051
2046
  const data = JSON.stringify({
2052
2047
  swapCid: options.swapCid
@@ -2116,8 +2111,8 @@ var swapCid = async (config, options) => {
2116
2111
 
2117
2112
  // src/core/gateway/swapHistory.ts
2118
2113
  var swapHistory = async (config, options) => {
2119
- if (!config || !config.pinataJwt) {
2120
- throw new ValidationError("Pinata configuration or JWT is missing");
2114
+ if (!config) {
2115
+ throw new ValidationError("Pinata configuration is missing");
2121
2116
  }
2122
2117
  let headers;
2123
2118
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
@@ -2181,8 +2176,8 @@ var swapHistory = async (config, options) => {
2181
2176
 
2182
2177
  // src/core/gateway/deleteSwap.ts
2183
2178
  var deleteSwap = async (config, cid) => {
2184
- if (!config || !config.pinataJwt) {
2185
- throw new ValidationError("Pinata configuration or JWT is missing");
2179
+ if (!config) {
2180
+ throw new ValidationError("Pinata configuration is missing");
2186
2181
  }
2187
2182
  let headers;
2188
2183
  if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {