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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +65 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -70
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -64,8 +64,8 @@ var ValidationError = class extends PinataError {
|
|
|
64
64
|
|
|
65
65
|
// src/core/authentication/testAuthentication.ts
|
|
66
66
|
var testAuthentication = async (config) => {
|
|
67
|
-
if (!config
|
|
68
|
-
throw new ValidationError("Pinata configuration
|
|
67
|
+
if (!config) {
|
|
68
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
69
69
|
}
|
|
70
70
|
let headers;
|
|
71
71
|
let endpoint = "https://api.pinata.cloud";
|
|
@@ -119,8 +119,8 @@ var testAuthentication = async (config) => {
|
|
|
119
119
|
|
|
120
120
|
// src/core/pinning/file.ts
|
|
121
121
|
var uploadFile = async (config, file, options) => {
|
|
122
|
-
if (!config
|
|
123
|
-
throw new ValidationError("Pinata configuration
|
|
122
|
+
if (!config) {
|
|
123
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
124
124
|
}
|
|
125
125
|
const jwt = options?.keys || config.pinataJwt;
|
|
126
126
|
const data = new FormData();
|
|
@@ -188,8 +188,8 @@ var uploadFile = async (config, file, options) => {
|
|
|
188
188
|
|
|
189
189
|
// src/core/pinning/fileArray.ts
|
|
190
190
|
var uploadFileArray = async (config, files, options) => {
|
|
191
|
-
if (!config
|
|
192
|
-
throw new ValidationError("Pinata configuration
|
|
191
|
+
if (!config) {
|
|
192
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
193
193
|
}
|
|
194
194
|
const jwt = options?.keys || config?.pinataJwt;
|
|
195
195
|
const folder = options?.metadata?.name || "folder_from_sdk";
|
|
@@ -262,8 +262,8 @@ var uploadFileArray = async (config, files, options) => {
|
|
|
262
262
|
|
|
263
263
|
// src/core/pinning/base64.ts
|
|
264
264
|
var uploadBase64 = async (config, base64String, options) => {
|
|
265
|
-
if (!config
|
|
266
|
-
throw new ValidationError("Pinata configuration
|
|
265
|
+
if (!config) {
|
|
266
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
267
267
|
}
|
|
268
268
|
const jwt = options?.keys || config?.pinataJwt;
|
|
269
269
|
const name = options?.metadata?.name ? options?.metadata?.name : "base64 string";
|
|
@@ -336,8 +336,8 @@ var uploadBase64 = async (config, base64String, options) => {
|
|
|
336
336
|
|
|
337
337
|
// src/core/pinning/url.ts
|
|
338
338
|
var uploadUrl = async (config, url, options) => {
|
|
339
|
-
if (!config
|
|
340
|
-
throw new ValidationError("Pinata configuration
|
|
339
|
+
if (!config) {
|
|
340
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
341
341
|
}
|
|
342
342
|
const jwt = options?.keys || config?.pinataJwt;
|
|
343
343
|
const data = new FormData();
|
|
@@ -418,8 +418,8 @@ var uploadUrl = async (config, url, options) => {
|
|
|
418
418
|
|
|
419
419
|
// src/core/pinning/json.ts
|
|
420
420
|
var uploadJson = async (config, jsonData, options) => {
|
|
421
|
-
if (!config
|
|
422
|
-
throw new ValidationError("Pinata configuration
|
|
421
|
+
if (!config) {
|
|
422
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
423
423
|
}
|
|
424
424
|
const jwt = options?.keys || config?.pinataJwt;
|
|
425
425
|
const data = JSON.stringify({
|
|
@@ -483,8 +483,8 @@ var uploadJson = async (config, jsonData, options) => {
|
|
|
483
483
|
|
|
484
484
|
// src/core/pinning/cid.ts
|
|
485
485
|
var uploadCid = async (config, cid, options) => {
|
|
486
|
-
if (!config
|
|
487
|
-
throw new ValidationError("Pinata configuration
|
|
486
|
+
if (!config) {
|
|
487
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
488
488
|
}
|
|
489
489
|
const jwt = options?.keys || config?.pinataJwt;
|
|
490
490
|
let headers;
|
|
@@ -553,8 +553,8 @@ var wait = (milliseconds) => {
|
|
|
553
553
|
});
|
|
554
554
|
};
|
|
555
555
|
var unpinFile = async (config, files) => {
|
|
556
|
-
if (!config
|
|
557
|
-
throw new ValidationError("Pinata configuration
|
|
556
|
+
if (!config) {
|
|
557
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
558
558
|
}
|
|
559
559
|
const responses = [];
|
|
560
560
|
let headers;
|
|
@@ -617,8 +617,8 @@ var unpinFile = async (config, files) => {
|
|
|
617
617
|
|
|
618
618
|
// src/core/data/listFiles.ts
|
|
619
619
|
var listFiles = async (config, options) => {
|
|
620
|
-
if (!config
|
|
621
|
-
throw new ValidationError("Pinata configuration
|
|
620
|
+
if (!config) {
|
|
621
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
622
622
|
}
|
|
623
623
|
const params = new URLSearchParams({
|
|
624
624
|
includesCount: "false"
|
|
@@ -712,8 +712,8 @@ var listFiles = async (config, options) => {
|
|
|
712
712
|
|
|
713
713
|
// src/core/data/updateMetadata.ts
|
|
714
714
|
var updateMetadata = async (config, options) => {
|
|
715
|
-
if (!config
|
|
716
|
-
throw new ValidationError("Pinata configuration
|
|
715
|
+
if (!config) {
|
|
716
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
717
717
|
}
|
|
718
718
|
const data = {
|
|
719
719
|
ipfsPinHash: options.cid,
|
|
@@ -866,8 +866,8 @@ async function convertToDesiredGateway(sourceUrl, desiredGatewayPrefix) {
|
|
|
866
866
|
|
|
867
867
|
// src/core/gateway/getCid.ts
|
|
868
868
|
var getCid = async (config, cid) => {
|
|
869
|
-
if (!config
|
|
870
|
-
throw new ValidationError("Pinata configuration
|
|
869
|
+
if (!config) {
|
|
870
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
871
871
|
}
|
|
872
872
|
let data;
|
|
873
873
|
let newUrl;
|
|
@@ -876,12 +876,7 @@ var getCid = async (config, cid) => {
|
|
|
876
876
|
newUrl = `${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;
|
|
877
877
|
}
|
|
878
878
|
try {
|
|
879
|
-
const request = await fetch(newUrl
|
|
880
|
-
method: "GET",
|
|
881
|
-
headers: {
|
|
882
|
-
Source: "sdk/getCid"
|
|
883
|
-
}
|
|
884
|
-
});
|
|
879
|
+
const request = await fetch(newUrl);
|
|
885
880
|
if (!request.ok) {
|
|
886
881
|
const errorData = await request.json();
|
|
887
882
|
if (request.status === 401) {
|
|
@@ -935,8 +930,8 @@ var convertIPFSUrl = async (config, url) => {
|
|
|
935
930
|
|
|
936
931
|
// src/core/data/pinJobs.ts
|
|
937
932
|
var pinJobs = async (config, options) => {
|
|
938
|
-
if (!config
|
|
939
|
-
throw new ValidationError("Pinata configuration
|
|
933
|
+
if (!config) {
|
|
934
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
940
935
|
}
|
|
941
936
|
const params = new URLSearchParams({
|
|
942
937
|
includesCount: "false"
|
|
@@ -1003,8 +998,8 @@ var pinJobs = async (config, options) => {
|
|
|
1003
998
|
|
|
1004
999
|
// src/core/data/pinnedFileUsage.ts
|
|
1005
1000
|
var pinnedFileCount = async (config) => {
|
|
1006
|
-
if (!config
|
|
1007
|
-
throw new ValidationError("Pinata configuration
|
|
1001
|
+
if (!config) {
|
|
1002
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1008
1003
|
}
|
|
1009
1004
|
let endpoint = "https://api.pinata.cloud";
|
|
1010
1005
|
if (config.endpointUrl) {
|
|
@@ -1058,8 +1053,8 @@ var pinnedFileCount = async (config) => {
|
|
|
1058
1053
|
|
|
1059
1054
|
// src/core/data/totalStorageUsage.ts
|
|
1060
1055
|
var totalStorageUsage = async (config) => {
|
|
1061
|
-
if (!config
|
|
1062
|
-
throw new ValidationError("Pinata configuration
|
|
1056
|
+
if (!config) {
|
|
1057
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1063
1058
|
}
|
|
1064
1059
|
let endpoint = "https://api.pinata.cloud";
|
|
1065
1060
|
if (config.endpointUrl) {
|
|
@@ -1113,8 +1108,8 @@ var totalStorageUsage = async (config) => {
|
|
|
1113
1108
|
|
|
1114
1109
|
// src/core/keys/createKey.ts
|
|
1115
1110
|
var createKey = async (config, options) => {
|
|
1116
|
-
if (!config
|
|
1117
|
-
throw new ValidationError("Pinata configuration
|
|
1111
|
+
if (!config) {
|
|
1112
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1118
1113
|
}
|
|
1119
1114
|
let headers;
|
|
1120
1115
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1167,8 +1162,8 @@ var createKey = async (config, options) => {
|
|
|
1167
1162
|
|
|
1168
1163
|
// src/core/keys/listKeys.ts
|
|
1169
1164
|
var listKeys = async (config, options) => {
|
|
1170
|
-
if (!config
|
|
1171
|
-
throw new ValidationError("Pinata configuration
|
|
1165
|
+
if (!config) {
|
|
1166
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1172
1167
|
}
|
|
1173
1168
|
let headers;
|
|
1174
1169
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1241,8 +1236,8 @@ var wait2 = (milliseconds) => {
|
|
|
1241
1236
|
});
|
|
1242
1237
|
};
|
|
1243
1238
|
var revokeKeys = async (config, keys) => {
|
|
1244
|
-
if (!config
|
|
1245
|
-
throw new ValidationError("Pinata configuration
|
|
1239
|
+
if (!config) {
|
|
1240
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1246
1241
|
}
|
|
1247
1242
|
let headers;
|
|
1248
1243
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1306,8 +1301,8 @@ var revokeKeys = async (config, keys) => {
|
|
|
1306
1301
|
|
|
1307
1302
|
// src/core/groups/createGroup.ts
|
|
1308
1303
|
var createGroup = async (config, options) => {
|
|
1309
|
-
if (!config
|
|
1310
|
-
throw new ValidationError("Pinata configuration
|
|
1304
|
+
if (!config) {
|
|
1305
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1311
1306
|
}
|
|
1312
1307
|
const data = JSON.stringify(options);
|
|
1313
1308
|
let headers;
|
|
@@ -1360,8 +1355,8 @@ var createGroup = async (config, options) => {
|
|
|
1360
1355
|
|
|
1361
1356
|
// src/core/groups/listGroups.ts
|
|
1362
1357
|
var listGroups = async (config, options) => {
|
|
1363
|
-
if (!config
|
|
1364
|
-
throw new ValidationError("Pinata configuration
|
|
1358
|
+
if (!config) {
|
|
1359
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1365
1360
|
}
|
|
1366
1361
|
let headers;
|
|
1367
1362
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1422,8 +1417,8 @@ var listGroups = async (config, options) => {
|
|
|
1422
1417
|
|
|
1423
1418
|
// src/core/groups/getGroup.ts
|
|
1424
1419
|
var getGroup = async (config, options) => {
|
|
1425
|
-
if (!config
|
|
1426
|
-
throw new ValidationError("Pinata configuration
|
|
1420
|
+
if (!config) {
|
|
1421
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1427
1422
|
}
|
|
1428
1423
|
let headers;
|
|
1429
1424
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1476,8 +1471,8 @@ var getGroup = async (config, options) => {
|
|
|
1476
1471
|
|
|
1477
1472
|
// src/core/groups/addToGroup.ts
|
|
1478
1473
|
var addToGroup = async (config, options) => {
|
|
1479
|
-
if (!config
|
|
1480
|
-
throw new ValidationError("Pinata configuration
|
|
1474
|
+
if (!config) {
|
|
1475
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1481
1476
|
}
|
|
1482
1477
|
const data = JSON.stringify({
|
|
1483
1478
|
cids: options.cids
|
|
@@ -1534,8 +1529,8 @@ var addToGroup = async (config, options) => {
|
|
|
1534
1529
|
|
|
1535
1530
|
// src/core/groups/updateGroup.ts
|
|
1536
1531
|
var updateGroup = async (config, options) => {
|
|
1537
|
-
if (!config
|
|
1538
|
-
throw new ValidationError("Pinata configuration
|
|
1532
|
+
if (!config) {
|
|
1533
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1539
1534
|
}
|
|
1540
1535
|
const data = JSON.stringify({
|
|
1541
1536
|
name: options.name
|
|
@@ -1590,8 +1585,8 @@ var updateGroup = async (config, options) => {
|
|
|
1590
1585
|
|
|
1591
1586
|
// src/core/groups/removeFromGroup.ts
|
|
1592
1587
|
var removeFromGroup = async (config, options) => {
|
|
1593
|
-
if (!config
|
|
1594
|
-
throw new ValidationError("Pinata configuration
|
|
1588
|
+
if (!config) {
|
|
1589
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1595
1590
|
}
|
|
1596
1591
|
let headers;
|
|
1597
1592
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1650,8 +1645,8 @@ var removeFromGroup = async (config, options) => {
|
|
|
1650
1645
|
|
|
1651
1646
|
// src/core/groups/deleteGroup.ts
|
|
1652
1647
|
var deleteGroup = async (config, options) => {
|
|
1653
|
-
if (!config
|
|
1654
|
-
throw new ValidationError("Pinata configuration
|
|
1648
|
+
if (!config) {
|
|
1649
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1655
1650
|
}
|
|
1656
1651
|
let headers;
|
|
1657
1652
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1702,8 +1697,8 @@ var deleteGroup = async (config, options) => {
|
|
|
1702
1697
|
|
|
1703
1698
|
// src/core/signatures/addSignature.ts
|
|
1704
1699
|
var addSignature = async (config, options) => {
|
|
1705
|
-
if (!config
|
|
1706
|
-
throw new ValidationError("Pinata configuration
|
|
1700
|
+
if (!config) {
|
|
1701
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1707
1702
|
}
|
|
1708
1703
|
const data = JSON.stringify({
|
|
1709
1704
|
signature: options.signature
|
|
@@ -1770,8 +1765,8 @@ var addSignature = async (config, options) => {
|
|
|
1770
1765
|
|
|
1771
1766
|
// src/core/signatures/getSignature.ts
|
|
1772
1767
|
var getSignature = async (config, cid) => {
|
|
1773
|
-
if (!config
|
|
1774
|
-
throw new ValidationError("Pinata configuration
|
|
1768
|
+
if (!config) {
|
|
1769
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1775
1770
|
}
|
|
1776
1771
|
let headers;
|
|
1777
1772
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1824,8 +1819,8 @@ var getSignature = async (config, cid) => {
|
|
|
1824
1819
|
|
|
1825
1820
|
// src/core/signatures/removeSignature.ts
|
|
1826
1821
|
var removeSignature = async (config, cid) => {
|
|
1827
|
-
if (!config
|
|
1828
|
-
throw new ValidationError("Pinata configuration
|
|
1822
|
+
if (!config) {
|
|
1823
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1829
1824
|
}
|
|
1830
1825
|
let headers;
|
|
1831
1826
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1877,8 +1872,8 @@ var removeSignature = async (config, cid) => {
|
|
|
1877
1872
|
|
|
1878
1873
|
// src/core/gateway/analyticsTopUsage.ts
|
|
1879
1874
|
var analyticsTopUsage = async (config, options) => {
|
|
1880
|
-
if (!config
|
|
1881
|
-
throw new ValidationError("Pinata configuration
|
|
1875
|
+
if (!config) {
|
|
1876
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1882
1877
|
}
|
|
1883
1878
|
const params = new URLSearchParams({
|
|
1884
1879
|
includesCount: "false"
|
|
@@ -1980,8 +1975,8 @@ var analyticsTopUsage = async (config, options) => {
|
|
|
1980
1975
|
|
|
1981
1976
|
// src/core/gateway/analyticsDateInterval.ts
|
|
1982
1977
|
var analyticsDateInterval = async (config, options) => {
|
|
1983
|
-
if (!config
|
|
1984
|
-
throw new ValidationError("Pinata configuration
|
|
1978
|
+
if (!config) {
|
|
1979
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1985
1980
|
}
|
|
1986
1981
|
const params = new URLSearchParams();
|
|
1987
1982
|
if (options) {
|
|
@@ -2081,8 +2076,8 @@ var analyticsDateInterval = async (config, options) => {
|
|
|
2081
2076
|
|
|
2082
2077
|
// src/core/gateway/swapCid.ts
|
|
2083
2078
|
var swapCid = async (config, options) => {
|
|
2084
|
-
if (!config
|
|
2085
|
-
throw new ValidationError("Pinata configuration
|
|
2079
|
+
if (!config) {
|
|
2080
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
2086
2081
|
}
|
|
2087
2082
|
const data = JSON.stringify({
|
|
2088
2083
|
swapCid: options.swapCid
|
|
@@ -2152,8 +2147,8 @@ var swapCid = async (config, options) => {
|
|
|
2152
2147
|
|
|
2153
2148
|
// src/core/gateway/swapHistory.ts
|
|
2154
2149
|
var swapHistory = async (config, options) => {
|
|
2155
|
-
if (!config
|
|
2156
|
-
throw new ValidationError("Pinata configuration
|
|
2150
|
+
if (!config) {
|
|
2151
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
2157
2152
|
}
|
|
2158
2153
|
let headers;
|
|
2159
2154
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -2217,8 +2212,8 @@ var swapHistory = async (config, options) => {
|
|
|
2217
2212
|
|
|
2218
2213
|
// src/core/gateway/deleteSwap.ts
|
|
2219
2214
|
var deleteSwap = async (config, cid) => {
|
|
2220
|
-
if (!config
|
|
2221
|
-
throw new ValidationError("Pinata configuration
|
|
2215
|
+
if (!config) {
|
|
2216
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
2222
2217
|
}
|
|
2223
2218
|
let headers;
|
|
2224
2219
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|