pinata 0.3.2 → 0.3.4
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 +193 -193
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +193 -193
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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";
|
|
@@ -86,16 +86,16 @@ var testAuthentication = async (config) => {
|
|
|
86
86
|
headers
|
|
87
87
|
});
|
|
88
88
|
if (!request.ok) {
|
|
89
|
-
const errorData = await request.
|
|
90
|
-
if (request.status === 401) {
|
|
89
|
+
const errorData = await request.text();
|
|
90
|
+
if (request.status === 401 || request.status === 403) {
|
|
91
91
|
throw new AuthenticationError(
|
|
92
|
-
|
|
92
|
+
`Authentication failed: ${errorData}`,
|
|
93
93
|
request.status,
|
|
94
94
|
errorData
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
97
|
throw new NetworkError(
|
|
98
|
-
`HTTP error
|
|
98
|
+
`HTTP error: ${errorData}`,
|
|
99
99
|
request.status,
|
|
100
100
|
errorData
|
|
101
101
|
);
|
|
@@ -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();
|
|
@@ -159,16 +159,16 @@ var uploadFile = async (config, file, options) => {
|
|
|
159
159
|
body: data
|
|
160
160
|
});
|
|
161
161
|
if (!request.ok) {
|
|
162
|
-
const errorData = await request.
|
|
163
|
-
if (request.status === 401) {
|
|
162
|
+
const errorData = await request.text();
|
|
163
|
+
if (request.status === 401 || request.status === 403) {
|
|
164
164
|
throw new AuthenticationError(
|
|
165
|
-
|
|
165
|
+
`Authentication failed: ${errorData}`,
|
|
166
166
|
request.status,
|
|
167
167
|
errorData
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
170
|
throw new NetworkError(
|
|
171
|
-
`HTTP error
|
|
171
|
+
`HTTP error: ${errorData}`,
|
|
172
172
|
request.status,
|
|
173
173
|
errorData
|
|
174
174
|
);
|
|
@@ -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";
|
|
@@ -231,16 +231,16 @@ var uploadFileArray = async (config, files, options) => {
|
|
|
231
231
|
body: data
|
|
232
232
|
});
|
|
233
233
|
if (!request.ok) {
|
|
234
|
-
const errorData = await request.
|
|
235
|
-
if (request.status === 401) {
|
|
234
|
+
const errorData = await request.text();
|
|
235
|
+
if (request.status === 401 || request.status === 403) {
|
|
236
236
|
throw new AuthenticationError(
|
|
237
|
-
|
|
237
|
+
`Authentication failed: ${errorData}`,
|
|
238
238
|
request.status,
|
|
239
239
|
errorData
|
|
240
240
|
);
|
|
241
241
|
}
|
|
242
242
|
throw new NetworkError(
|
|
243
|
-
`HTTP error
|
|
243
|
+
`HTTP error: ${errorData}`,
|
|
244
244
|
request.status,
|
|
245
245
|
errorData
|
|
246
246
|
);
|
|
@@ -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";
|
|
@@ -305,16 +305,16 @@ var uploadBase64 = async (config, base64String, options) => {
|
|
|
305
305
|
body: data
|
|
306
306
|
});
|
|
307
307
|
if (!request.ok) {
|
|
308
|
-
const errorData = await request.
|
|
309
|
-
if (request.status === 401) {
|
|
308
|
+
const errorData = await request.text();
|
|
309
|
+
if (request.status === 401 || request.status === 403) {
|
|
310
310
|
throw new AuthenticationError(
|
|
311
|
-
|
|
311
|
+
`Authentication failed: ${errorData}`,
|
|
312
312
|
request.status,
|
|
313
313
|
errorData
|
|
314
314
|
);
|
|
315
315
|
}
|
|
316
316
|
throw new NetworkError(
|
|
317
|
-
`HTTP error
|
|
317
|
+
`HTTP error: ${errorData}`,
|
|
318
318
|
request.status,
|
|
319
319
|
errorData
|
|
320
320
|
);
|
|
@@ -336,16 +336,16 @@ 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();
|
|
344
344
|
const stream = await fetch(url);
|
|
345
345
|
if (!stream.ok) {
|
|
346
|
-
const errorData = await stream.
|
|
346
|
+
const errorData = await stream.text();
|
|
347
347
|
throw new NetworkError(
|
|
348
|
-
`HTTP error
|
|
348
|
+
`HTTP error: ${errorData}`,
|
|
349
349
|
stream.status,
|
|
350
350
|
errorData
|
|
351
351
|
);
|
|
@@ -389,16 +389,16 @@ var uploadUrl = async (config, url, options) => {
|
|
|
389
389
|
body: data
|
|
390
390
|
});
|
|
391
391
|
if (!request.ok) {
|
|
392
|
-
const errorData = await request.
|
|
393
|
-
if (request.status === 401) {
|
|
392
|
+
const errorData = await request.text();
|
|
393
|
+
if (request.status === 401 || request.status === 403) {
|
|
394
394
|
throw new AuthenticationError(
|
|
395
|
-
|
|
395
|
+
`Authentication failed: ${errorData}`,
|
|
396
396
|
request.status,
|
|
397
397
|
errorData
|
|
398
398
|
);
|
|
399
399
|
}
|
|
400
400
|
throw new NetworkError(
|
|
401
|
-
`HTTP error
|
|
401
|
+
`HTTP error: ${errorData}`,
|
|
402
402
|
request.status,
|
|
403
403
|
errorData
|
|
404
404
|
);
|
|
@@ -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({
|
|
@@ -454,16 +454,16 @@ var uploadJson = async (config, jsonData, options) => {
|
|
|
454
454
|
body: data
|
|
455
455
|
});
|
|
456
456
|
if (!request.ok) {
|
|
457
|
-
const errorData = await request.
|
|
458
|
-
if (request.status === 401) {
|
|
457
|
+
const errorData = await request.text();
|
|
458
|
+
if (request.status === 401 || request.status === 403) {
|
|
459
459
|
throw new AuthenticationError(
|
|
460
|
-
|
|
460
|
+
`Authentication failed: ${errorData}`,
|
|
461
461
|
request.status,
|
|
462
462
|
errorData
|
|
463
463
|
);
|
|
464
464
|
}
|
|
465
465
|
throw new NetworkError(
|
|
466
|
-
`HTTP error
|
|
466
|
+
`HTTP error: ${errorData}`,
|
|
467
467
|
request.status,
|
|
468
468
|
errorData
|
|
469
469
|
);
|
|
@@ -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;
|
|
@@ -519,16 +519,16 @@ var uploadCid = async (config, cid, options) => {
|
|
|
519
519
|
body: data
|
|
520
520
|
});
|
|
521
521
|
if (!request.ok) {
|
|
522
|
-
const errorData = await request.
|
|
523
|
-
if (request.status === 401) {
|
|
522
|
+
const errorData = await request.text();
|
|
523
|
+
if (request.status === 401 || request.status === 403) {
|
|
524
524
|
throw new AuthenticationError(
|
|
525
|
-
|
|
525
|
+
`Authentication failed: ${errorData}`,
|
|
526
526
|
request.status,
|
|
527
527
|
errorData
|
|
528
528
|
);
|
|
529
529
|
}
|
|
530
530
|
throw new NetworkError(
|
|
531
|
-
`HTTP error
|
|
531
|
+
`HTTP error: ${errorData}`,
|
|
532
532
|
request.status,
|
|
533
533
|
errorData
|
|
534
534
|
);
|
|
@@ -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;
|
|
@@ -578,16 +578,16 @@ var unpinFile = async (config, files) => {
|
|
|
578
578
|
});
|
|
579
579
|
await wait(300);
|
|
580
580
|
if (!response.ok) {
|
|
581
|
-
const errorData = await response.
|
|
581
|
+
const errorData = await response.text();
|
|
582
582
|
if (response.status === 401) {
|
|
583
583
|
throw new AuthenticationError(
|
|
584
|
-
|
|
584
|
+
`Authentication failed: ${errorData}`,
|
|
585
585
|
response.status,
|
|
586
586
|
errorData
|
|
587
587
|
);
|
|
588
588
|
}
|
|
589
589
|
throw new NetworkError(
|
|
590
|
-
`HTTP error
|
|
590
|
+
`HTTP error: ${errorData}`,
|
|
591
591
|
response.status,
|
|
592
592
|
errorData
|
|
593
593
|
);
|
|
@@ -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"
|
|
@@ -683,16 +683,16 @@ var listFiles = async (config, options) => {
|
|
|
683
683
|
headers
|
|
684
684
|
});
|
|
685
685
|
if (!request.ok) {
|
|
686
|
-
const errorData = await request.
|
|
687
|
-
if (request.status === 401) {
|
|
686
|
+
const errorData = await request.text();
|
|
687
|
+
if (request.status === 401 || request.status === 403) {
|
|
688
688
|
throw new AuthenticationError(
|
|
689
|
-
|
|
689
|
+
`Authentication failed: ${errorData}`,
|
|
690
690
|
request.status,
|
|
691
691
|
errorData
|
|
692
692
|
);
|
|
693
693
|
}
|
|
694
694
|
throw new NetworkError(
|
|
695
|
-
`HTTP error
|
|
695
|
+
`HTTP error: ${errorData}`,
|
|
696
696
|
request.status,
|
|
697
697
|
errorData
|
|
698
698
|
);
|
|
@@ -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,
|
|
@@ -741,16 +741,16 @@ var updateMetadata = async (config, options) => {
|
|
|
741
741
|
body: JSON.stringify(data)
|
|
742
742
|
});
|
|
743
743
|
if (!request.ok) {
|
|
744
|
-
const errorData = await request.
|
|
745
|
-
if (request.status === 401) {
|
|
744
|
+
const errorData = await request.text();
|
|
745
|
+
if (request.status === 401 || request.status === 403) {
|
|
746
746
|
throw new AuthenticationError(
|
|
747
|
-
|
|
747
|
+
`Authentication failed: ${errorData}`,
|
|
748
748
|
request.status,
|
|
749
749
|
errorData
|
|
750
750
|
);
|
|
751
751
|
}
|
|
752
752
|
throw new NetworkError(
|
|
753
|
-
`HTTP error
|
|
753
|
+
`HTTP error: ${errorData}`,
|
|
754
754
|
request.status,
|
|
755
755
|
errorData
|
|
756
756
|
);
|
|
@@ -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;
|
|
@@ -878,16 +878,16 @@ var getCid = async (config, cid) => {
|
|
|
878
878
|
try {
|
|
879
879
|
const request = await fetch(newUrl);
|
|
880
880
|
if (!request.ok) {
|
|
881
|
-
const errorData = await request.
|
|
882
|
-
if (request.status === 401) {
|
|
881
|
+
const errorData = await request.text();
|
|
882
|
+
if (request.status === 401 || request.status === 403) {
|
|
883
883
|
throw new AuthenticationError(
|
|
884
|
-
|
|
884
|
+
`Authentication Failed: ${errorData}`,
|
|
885
885
|
request.status,
|
|
886
886
|
errorData
|
|
887
887
|
);
|
|
888
888
|
}
|
|
889
889
|
throw new NetworkError(
|
|
890
|
-
`HTTP error
|
|
890
|
+
`HTTP error: ${errorData}`,
|
|
891
891
|
request.status,
|
|
892
892
|
errorData
|
|
893
893
|
);
|
|
@@ -930,8 +930,8 @@ var convertIPFSUrl = async (config, url) => {
|
|
|
930
930
|
|
|
931
931
|
// src/core/data/pinJobs.ts
|
|
932
932
|
var pinJobs = async (config, options) => {
|
|
933
|
-
if (!config
|
|
934
|
-
throw new ValidationError("Pinata configuration
|
|
933
|
+
if (!config) {
|
|
934
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
935
935
|
}
|
|
936
936
|
const params = new URLSearchParams({
|
|
937
937
|
includesCount: "false"
|
|
@@ -969,16 +969,16 @@ var pinJobs = async (config, options) => {
|
|
|
969
969
|
headers
|
|
970
970
|
});
|
|
971
971
|
if (!request.ok) {
|
|
972
|
-
const errorData = await request.
|
|
973
|
-
if (request.status === 401) {
|
|
972
|
+
const errorData = await request.text();
|
|
973
|
+
if (request.status === 401 || request.status === 403) {
|
|
974
974
|
throw new AuthenticationError(
|
|
975
|
-
|
|
975
|
+
`Authentication failed: ${errorData}`,
|
|
976
976
|
request.status,
|
|
977
977
|
errorData
|
|
978
978
|
);
|
|
979
979
|
}
|
|
980
980
|
throw new NetworkError(
|
|
981
|
-
`HTTP error
|
|
981
|
+
`HTTP error: ${errorData}`,
|
|
982
982
|
request.status,
|
|
983
983
|
errorData
|
|
984
984
|
);
|
|
@@ -998,8 +998,8 @@ var pinJobs = async (config, options) => {
|
|
|
998
998
|
|
|
999
999
|
// src/core/data/pinnedFileUsage.ts
|
|
1000
1000
|
var pinnedFileCount = async (config) => {
|
|
1001
|
-
if (!config
|
|
1002
|
-
throw new ValidationError("Pinata configuration
|
|
1001
|
+
if (!config) {
|
|
1002
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1003
1003
|
}
|
|
1004
1004
|
let endpoint = "https://api.pinata.cloud";
|
|
1005
1005
|
if (config.endpointUrl) {
|
|
@@ -1020,16 +1020,16 @@ var pinnedFileCount = async (config) => {
|
|
|
1020
1020
|
headers
|
|
1021
1021
|
});
|
|
1022
1022
|
if (!request.ok) {
|
|
1023
|
-
const errorData = await request.
|
|
1024
|
-
if (request.status === 401) {
|
|
1023
|
+
const errorData = await request.text();
|
|
1024
|
+
if (request.status === 401 || request.status === 403) {
|
|
1025
1025
|
throw new AuthenticationError(
|
|
1026
|
-
|
|
1026
|
+
`Authentication failed: ${errorData}`,
|
|
1027
1027
|
request.status,
|
|
1028
1028
|
errorData
|
|
1029
1029
|
);
|
|
1030
1030
|
}
|
|
1031
1031
|
throw new NetworkError(
|
|
1032
|
-
`HTTP error
|
|
1032
|
+
`HTTP error: ${errorData}`,
|
|
1033
1033
|
request.status,
|
|
1034
1034
|
errorData
|
|
1035
1035
|
);
|
|
@@ -1053,8 +1053,8 @@ var pinnedFileCount = async (config) => {
|
|
|
1053
1053
|
|
|
1054
1054
|
// src/core/data/totalStorageUsage.ts
|
|
1055
1055
|
var totalStorageUsage = async (config) => {
|
|
1056
|
-
if (!config
|
|
1057
|
-
throw new ValidationError("Pinata configuration
|
|
1056
|
+
if (!config) {
|
|
1057
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1058
1058
|
}
|
|
1059
1059
|
let endpoint = "https://api.pinata.cloud";
|
|
1060
1060
|
if (config.endpointUrl) {
|
|
@@ -1075,16 +1075,16 @@ var totalStorageUsage = async (config) => {
|
|
|
1075
1075
|
headers
|
|
1076
1076
|
});
|
|
1077
1077
|
if (!request.ok) {
|
|
1078
|
-
const errorData = await request.
|
|
1079
|
-
if (request.status === 401) {
|
|
1078
|
+
const errorData = await request.text();
|
|
1079
|
+
if (request.status === 401 || request.status === 403) {
|
|
1080
1080
|
throw new AuthenticationError(
|
|
1081
|
-
|
|
1081
|
+
`Authentication failed: ${errorData}`,
|
|
1082
1082
|
request.status,
|
|
1083
1083
|
errorData
|
|
1084
1084
|
);
|
|
1085
1085
|
}
|
|
1086
1086
|
throw new NetworkError(
|
|
1087
|
-
`HTTP error
|
|
1087
|
+
`HTTP error: ${errorData}`,
|
|
1088
1088
|
request.status,
|
|
1089
1089
|
errorData
|
|
1090
1090
|
);
|
|
@@ -1108,8 +1108,8 @@ var totalStorageUsage = async (config) => {
|
|
|
1108
1108
|
|
|
1109
1109
|
// src/core/keys/createKey.ts
|
|
1110
1110
|
var createKey = async (config, options) => {
|
|
1111
|
-
if (!config
|
|
1112
|
-
throw new ValidationError("Pinata configuration
|
|
1111
|
+
if (!config) {
|
|
1112
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1113
1113
|
}
|
|
1114
1114
|
let headers;
|
|
1115
1115
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1133,16 +1133,16 @@ var createKey = async (config, options) => {
|
|
|
1133
1133
|
body: data
|
|
1134
1134
|
});
|
|
1135
1135
|
if (!request.ok) {
|
|
1136
|
-
const errorData = await request.
|
|
1137
|
-
if (request.status === 401) {
|
|
1136
|
+
const errorData = await request.text();
|
|
1137
|
+
if (request.status === 401 || request.status === 403) {
|
|
1138
1138
|
throw new AuthenticationError(
|
|
1139
|
-
|
|
1139
|
+
`Authentication failed: ${errorData}`,
|
|
1140
1140
|
request.status,
|
|
1141
1141
|
errorData
|
|
1142
1142
|
);
|
|
1143
1143
|
}
|
|
1144
1144
|
throw new NetworkError(
|
|
1145
|
-
`HTTP error
|
|
1145
|
+
`HTTP error: ${errorData}`,
|
|
1146
1146
|
request.status,
|
|
1147
1147
|
errorData
|
|
1148
1148
|
);
|
|
@@ -1162,8 +1162,8 @@ var createKey = async (config, options) => {
|
|
|
1162
1162
|
|
|
1163
1163
|
// src/core/keys/listKeys.ts
|
|
1164
1164
|
var listKeys = async (config, options) => {
|
|
1165
|
-
if (!config
|
|
1166
|
-
throw new ValidationError("Pinata configuration
|
|
1165
|
+
if (!config) {
|
|
1166
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1167
1167
|
}
|
|
1168
1168
|
let headers;
|
|
1169
1169
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1202,16 +1202,16 @@ var listKeys = async (config, options) => {
|
|
|
1202
1202
|
}
|
|
1203
1203
|
);
|
|
1204
1204
|
if (!request.ok) {
|
|
1205
|
-
const errorData = await request.
|
|
1206
|
-
if (request.status === 401) {
|
|
1205
|
+
const errorData = await request.text();
|
|
1206
|
+
if (request.status === 401 || request.status === 403) {
|
|
1207
1207
|
throw new AuthenticationError(
|
|
1208
|
-
|
|
1208
|
+
`Authentication failed: ${errorData}`,
|
|
1209
1209
|
request.status,
|
|
1210
1210
|
errorData
|
|
1211
1211
|
);
|
|
1212
1212
|
}
|
|
1213
1213
|
throw new NetworkError(
|
|
1214
|
-
`HTTP error
|
|
1214
|
+
`HTTP error: ${errorData}`,
|
|
1215
1215
|
request.status,
|
|
1216
1216
|
errorData
|
|
1217
1217
|
);
|
|
@@ -1236,8 +1236,8 @@ var wait2 = (milliseconds) => {
|
|
|
1236
1236
|
});
|
|
1237
1237
|
};
|
|
1238
1238
|
var revokeKeys = async (config, keys) => {
|
|
1239
|
-
if (!config
|
|
1240
|
-
throw new ValidationError("Pinata configuration
|
|
1239
|
+
if (!config) {
|
|
1240
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1241
1241
|
}
|
|
1242
1242
|
let headers;
|
|
1243
1243
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1262,16 +1262,16 @@ var revokeKeys = async (config, keys) => {
|
|
|
1262
1262
|
});
|
|
1263
1263
|
await wait2(300);
|
|
1264
1264
|
if (!request.ok) {
|
|
1265
|
-
const errorData = await request.
|
|
1266
|
-
if (request.status === 401) {
|
|
1265
|
+
const errorData = await request.text();
|
|
1266
|
+
if (request.status === 401 || request.status === 403) {
|
|
1267
1267
|
throw new AuthenticationError(
|
|
1268
|
-
|
|
1268
|
+
`Authentication failed: ${errorData}`,
|
|
1269
1269
|
request.status,
|
|
1270
1270
|
errorData
|
|
1271
1271
|
);
|
|
1272
1272
|
}
|
|
1273
1273
|
throw new NetworkError(
|
|
1274
|
-
`HTTP error
|
|
1274
|
+
`HTTP error: ${errorData}`,
|
|
1275
1275
|
request.status,
|
|
1276
1276
|
errorData
|
|
1277
1277
|
);
|
|
@@ -1301,8 +1301,8 @@ var revokeKeys = async (config, keys) => {
|
|
|
1301
1301
|
|
|
1302
1302
|
// src/core/groups/createGroup.ts
|
|
1303
1303
|
var createGroup = async (config, options) => {
|
|
1304
|
-
if (!config
|
|
1305
|
-
throw new ValidationError("Pinata configuration
|
|
1304
|
+
if (!config) {
|
|
1305
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1306
1306
|
}
|
|
1307
1307
|
const data = JSON.stringify(options);
|
|
1308
1308
|
let headers;
|
|
@@ -1326,16 +1326,16 @@ var createGroup = async (config, options) => {
|
|
|
1326
1326
|
body: data
|
|
1327
1327
|
});
|
|
1328
1328
|
if (!request.ok) {
|
|
1329
|
-
const errorData = await request.
|
|
1330
|
-
if (request.status === 401) {
|
|
1329
|
+
const errorData = await request.text();
|
|
1330
|
+
if (request.status === 401 || request.status === 403) {
|
|
1331
1331
|
throw new AuthenticationError(
|
|
1332
|
-
|
|
1332
|
+
`Authentication failed: ${errorData}`,
|
|
1333
1333
|
request.status,
|
|
1334
1334
|
errorData
|
|
1335
1335
|
);
|
|
1336
1336
|
}
|
|
1337
1337
|
throw new NetworkError(
|
|
1338
|
-
`HTTP error
|
|
1338
|
+
`HTTP error: ${errorData}`,
|
|
1339
1339
|
request.status,
|
|
1340
1340
|
errorData
|
|
1341
1341
|
);
|
|
@@ -1355,8 +1355,8 @@ var createGroup = async (config, options) => {
|
|
|
1355
1355
|
|
|
1356
1356
|
// src/core/groups/listGroups.ts
|
|
1357
1357
|
var listGroups = async (config, options) => {
|
|
1358
|
-
if (!config
|
|
1359
|
-
throw new ValidationError("Pinata configuration
|
|
1358
|
+
if (!config) {
|
|
1359
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1360
1360
|
}
|
|
1361
1361
|
let headers;
|
|
1362
1362
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1388,16 +1388,16 @@ var listGroups = async (config, options) => {
|
|
|
1388
1388
|
headers
|
|
1389
1389
|
});
|
|
1390
1390
|
if (!request.ok) {
|
|
1391
|
-
const errorData = await request.
|
|
1392
|
-
if (request.status === 401) {
|
|
1391
|
+
const errorData = await request.text();
|
|
1392
|
+
if (request.status === 401 || request.status === 403) {
|
|
1393
1393
|
throw new AuthenticationError(
|
|
1394
|
-
|
|
1394
|
+
`Authentication failed: ${errorData}`,
|
|
1395
1395
|
request.status,
|
|
1396
1396
|
errorData
|
|
1397
1397
|
);
|
|
1398
1398
|
}
|
|
1399
1399
|
throw new NetworkError(
|
|
1400
|
-
`HTTP error
|
|
1400
|
+
`HTTP error: ${errorData}`,
|
|
1401
1401
|
request.status,
|
|
1402
1402
|
errorData
|
|
1403
1403
|
);
|
|
@@ -1417,8 +1417,8 @@ var listGroups = async (config, options) => {
|
|
|
1417
1417
|
|
|
1418
1418
|
// src/core/groups/getGroup.ts
|
|
1419
1419
|
var getGroup = async (config, options) => {
|
|
1420
|
-
if (!config
|
|
1421
|
-
throw new ValidationError("Pinata configuration
|
|
1420
|
+
if (!config) {
|
|
1421
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1422
1422
|
}
|
|
1423
1423
|
let headers;
|
|
1424
1424
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1440,16 +1440,16 @@ var getGroup = async (config, options) => {
|
|
|
1440
1440
|
headers
|
|
1441
1441
|
});
|
|
1442
1442
|
if (!request.ok) {
|
|
1443
|
-
const errorData = await request.
|
|
1444
|
-
if (request.status === 401) {
|
|
1443
|
+
const errorData = await request.text();
|
|
1444
|
+
if (request.status === 401 || request.status === 403) {
|
|
1445
1445
|
throw new AuthenticationError(
|
|
1446
|
-
|
|
1446
|
+
`Authentication failed: ${errorData}`,
|
|
1447
1447
|
request.status,
|
|
1448
1448
|
errorData
|
|
1449
1449
|
);
|
|
1450
1450
|
}
|
|
1451
1451
|
throw new NetworkError(
|
|
1452
|
-
`HTTP error
|
|
1452
|
+
`HTTP error: ${errorData}`,
|
|
1453
1453
|
request.status,
|
|
1454
1454
|
errorData
|
|
1455
1455
|
);
|
|
@@ -1471,8 +1471,8 @@ var getGroup = async (config, options) => {
|
|
|
1471
1471
|
|
|
1472
1472
|
// src/core/groups/addToGroup.ts
|
|
1473
1473
|
var addToGroup = async (config, options) => {
|
|
1474
|
-
if (!config
|
|
1475
|
-
throw new ValidationError("Pinata configuration
|
|
1474
|
+
if (!config) {
|
|
1475
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1476
1476
|
}
|
|
1477
1477
|
const data = JSON.stringify({
|
|
1478
1478
|
cids: options.cids
|
|
@@ -1498,16 +1498,16 @@ var addToGroup = async (config, options) => {
|
|
|
1498
1498
|
body: data
|
|
1499
1499
|
});
|
|
1500
1500
|
if (!request.ok) {
|
|
1501
|
-
const errorData = await request.
|
|
1502
|
-
if (request.status === 401) {
|
|
1501
|
+
const errorData = await request.text();
|
|
1502
|
+
if (request.status === 401 || request.status === 403) {
|
|
1503
1503
|
throw new AuthenticationError(
|
|
1504
|
-
|
|
1504
|
+
`Authentication failed: ${errorData}`,
|
|
1505
1505
|
request.status,
|
|
1506
1506
|
errorData
|
|
1507
1507
|
);
|
|
1508
1508
|
}
|
|
1509
1509
|
throw new NetworkError(
|
|
1510
|
-
`HTTP error
|
|
1510
|
+
`HTTP error: ${errorData}`,
|
|
1511
1511
|
request.status,
|
|
1512
1512
|
errorData
|
|
1513
1513
|
);
|
|
@@ -1529,8 +1529,8 @@ var addToGroup = async (config, options) => {
|
|
|
1529
1529
|
|
|
1530
1530
|
// src/core/groups/updateGroup.ts
|
|
1531
1531
|
var updateGroup = async (config, options) => {
|
|
1532
|
-
if (!config
|
|
1533
|
-
throw new ValidationError("Pinata configuration
|
|
1532
|
+
if (!config) {
|
|
1533
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1534
1534
|
}
|
|
1535
1535
|
const data = JSON.stringify({
|
|
1536
1536
|
name: options.name
|
|
@@ -1556,16 +1556,16 @@ var updateGroup = async (config, options) => {
|
|
|
1556
1556
|
body: data
|
|
1557
1557
|
});
|
|
1558
1558
|
if (!request.ok) {
|
|
1559
|
-
const errorData = await request.
|
|
1560
|
-
if (request.status === 401) {
|
|
1559
|
+
const errorData = await request.text();
|
|
1560
|
+
if (request.status === 401 || request.status === 403) {
|
|
1561
1561
|
throw new AuthenticationError(
|
|
1562
|
-
|
|
1562
|
+
`Authentication failed: ${errorData}`,
|
|
1563
1563
|
request.status,
|
|
1564
1564
|
errorData
|
|
1565
1565
|
);
|
|
1566
1566
|
}
|
|
1567
1567
|
throw new NetworkError(
|
|
1568
|
-
`HTTP error
|
|
1568
|
+
`HTTP error: ${errorData}`,
|
|
1569
1569
|
request.status,
|
|
1570
1570
|
errorData
|
|
1571
1571
|
);
|
|
@@ -1585,8 +1585,8 @@ var updateGroup = async (config, options) => {
|
|
|
1585
1585
|
|
|
1586
1586
|
// src/core/groups/removeFromGroup.ts
|
|
1587
1587
|
var removeFromGroup = async (config, options) => {
|
|
1588
|
-
if (!config
|
|
1589
|
-
throw new ValidationError("Pinata configuration
|
|
1588
|
+
if (!config) {
|
|
1589
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1590
1590
|
}
|
|
1591
1591
|
let headers;
|
|
1592
1592
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1612,16 +1612,16 @@ var removeFromGroup = async (config, options) => {
|
|
|
1612
1612
|
body: data
|
|
1613
1613
|
});
|
|
1614
1614
|
if (!request.ok) {
|
|
1615
|
-
const errorData = await request.
|
|
1616
|
-
if (request.status === 401) {
|
|
1615
|
+
const errorData = await request.text();
|
|
1616
|
+
if (request.status === 401 || request.status === 403) {
|
|
1617
1617
|
throw new AuthenticationError(
|
|
1618
|
-
|
|
1618
|
+
`Authentication failed: ${errorData}`,
|
|
1619
1619
|
request.status,
|
|
1620
1620
|
errorData
|
|
1621
1621
|
);
|
|
1622
1622
|
}
|
|
1623
1623
|
throw new NetworkError(
|
|
1624
|
-
`HTTP error
|
|
1624
|
+
`HTTP error: ${errorData}`,
|
|
1625
1625
|
request.status,
|
|
1626
1626
|
errorData
|
|
1627
1627
|
);
|
|
@@ -1645,8 +1645,8 @@ var removeFromGroup = async (config, options) => {
|
|
|
1645
1645
|
|
|
1646
1646
|
// src/core/groups/deleteGroup.ts
|
|
1647
1647
|
var deleteGroup = async (config, options) => {
|
|
1648
|
-
if (!config
|
|
1649
|
-
throw new ValidationError("Pinata configuration
|
|
1648
|
+
if (!config) {
|
|
1649
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1650
1650
|
}
|
|
1651
1651
|
let headers;
|
|
1652
1652
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1668,16 +1668,16 @@ var deleteGroup = async (config, options) => {
|
|
|
1668
1668
|
headers
|
|
1669
1669
|
});
|
|
1670
1670
|
if (!request.ok) {
|
|
1671
|
-
const errorData = await request.
|
|
1672
|
-
if (request.status === 401) {
|
|
1671
|
+
const errorData = await request.text();
|
|
1672
|
+
if (request.status === 401 || request.status === 403) {
|
|
1673
1673
|
throw new AuthenticationError(
|
|
1674
|
-
|
|
1674
|
+
`Authentication failed: ${errorData}`,
|
|
1675
1675
|
request.status,
|
|
1676
1676
|
errorData
|
|
1677
1677
|
);
|
|
1678
1678
|
}
|
|
1679
1679
|
throw new NetworkError(
|
|
1680
|
-
`HTTP error
|
|
1680
|
+
`HTTP error: ${errorData}`,
|
|
1681
1681
|
request.status,
|
|
1682
1682
|
errorData
|
|
1683
1683
|
);
|
|
@@ -1697,8 +1697,8 @@ var deleteGroup = async (config, options) => {
|
|
|
1697
1697
|
|
|
1698
1698
|
// src/core/signatures/addSignature.ts
|
|
1699
1699
|
var addSignature = async (config, options) => {
|
|
1700
|
-
if (!config
|
|
1701
|
-
throw new ValidationError("Pinata configuration
|
|
1700
|
+
if (!config) {
|
|
1701
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1702
1702
|
}
|
|
1703
1703
|
const data = JSON.stringify({
|
|
1704
1704
|
signature: options.signature
|
|
@@ -1727,10 +1727,10 @@ var addSignature = async (config, options) => {
|
|
|
1727
1727
|
}
|
|
1728
1728
|
);
|
|
1729
1729
|
if (!request.ok) {
|
|
1730
|
-
const errorData = await request.
|
|
1731
|
-
if (request.status === 401) {
|
|
1730
|
+
const errorData = await request.text();
|
|
1731
|
+
if (request.status === 401 || request.status === 403) {
|
|
1732
1732
|
throw new AuthenticationError(
|
|
1733
|
-
|
|
1733
|
+
`Authentication failed: ${errorData}`,
|
|
1734
1734
|
request.status,
|
|
1735
1735
|
errorData
|
|
1736
1736
|
);
|
|
@@ -1743,7 +1743,7 @@ var addSignature = async (config, options) => {
|
|
|
1743
1743
|
);
|
|
1744
1744
|
}
|
|
1745
1745
|
throw new NetworkError(
|
|
1746
|
-
`HTTP error
|
|
1746
|
+
`HTTP error: ${errorData}`,
|
|
1747
1747
|
request.status,
|
|
1748
1748
|
errorData
|
|
1749
1749
|
);
|
|
@@ -1765,8 +1765,8 @@ var addSignature = async (config, options) => {
|
|
|
1765
1765
|
|
|
1766
1766
|
// src/core/signatures/getSignature.ts
|
|
1767
1767
|
var getSignature = async (config, cid) => {
|
|
1768
|
-
if (!config
|
|
1769
|
-
throw new ValidationError("Pinata configuration
|
|
1768
|
+
if (!config) {
|
|
1769
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1770
1770
|
}
|
|
1771
1771
|
let headers;
|
|
1772
1772
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1788,16 +1788,16 @@ var getSignature = async (config, cid) => {
|
|
|
1788
1788
|
headers
|
|
1789
1789
|
});
|
|
1790
1790
|
if (!request.ok) {
|
|
1791
|
-
const errorData = await request.
|
|
1792
|
-
if (request.status === 401) {
|
|
1791
|
+
const errorData = await request.text();
|
|
1792
|
+
if (request.status === 401 || request.status === 403) {
|
|
1793
1793
|
throw new AuthenticationError(
|
|
1794
|
-
|
|
1794
|
+
`Authentication failed: ${errorData}`,
|
|
1795
1795
|
request.status,
|
|
1796
1796
|
errorData
|
|
1797
1797
|
);
|
|
1798
1798
|
}
|
|
1799
1799
|
throw new NetworkError(
|
|
1800
|
-
`HTTP error
|
|
1800
|
+
`HTTP error: ${errorData}`,
|
|
1801
1801
|
request.status,
|
|
1802
1802
|
errorData
|
|
1803
1803
|
);
|
|
@@ -1819,8 +1819,8 @@ var getSignature = async (config, cid) => {
|
|
|
1819
1819
|
|
|
1820
1820
|
// src/core/signatures/removeSignature.ts
|
|
1821
1821
|
var removeSignature = async (config, cid) => {
|
|
1822
|
-
if (!config
|
|
1823
|
-
throw new ValidationError("Pinata configuration
|
|
1822
|
+
if (!config) {
|
|
1823
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1824
1824
|
}
|
|
1825
1825
|
let headers;
|
|
1826
1826
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1842,16 +1842,16 @@ var removeSignature = async (config, cid) => {
|
|
|
1842
1842
|
headers
|
|
1843
1843
|
});
|
|
1844
1844
|
if (!request.ok) {
|
|
1845
|
-
const errorData = await request.
|
|
1846
|
-
if (request.status === 401) {
|
|
1845
|
+
const errorData = await request.text();
|
|
1846
|
+
if (request.status === 401 || request.status === 403) {
|
|
1847
1847
|
throw new AuthenticationError(
|
|
1848
|
-
|
|
1848
|
+
`Authentication failed: ${errorData}`,
|
|
1849
1849
|
request.status,
|
|
1850
1850
|
errorData
|
|
1851
1851
|
);
|
|
1852
1852
|
}
|
|
1853
1853
|
throw new NetworkError(
|
|
1854
|
-
`HTTP error
|
|
1854
|
+
`HTTP error: ${errorData}`,
|
|
1855
1855
|
request.status,
|
|
1856
1856
|
errorData
|
|
1857
1857
|
);
|
|
@@ -1872,8 +1872,8 @@ var removeSignature = async (config, cid) => {
|
|
|
1872
1872
|
|
|
1873
1873
|
// src/core/gateway/analyticsTopUsage.ts
|
|
1874
1874
|
var analyticsTopUsage = async (config, options) => {
|
|
1875
|
-
if (!config
|
|
1876
|
-
throw new ValidationError("Pinata configuration
|
|
1875
|
+
if (!config) {
|
|
1876
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1877
1877
|
}
|
|
1878
1878
|
const params = new URLSearchParams({
|
|
1879
1879
|
includesCount: "false"
|
|
@@ -1941,16 +1941,16 @@ var analyticsTopUsage = async (config, options) => {
|
|
|
1941
1941
|
headers
|
|
1942
1942
|
});
|
|
1943
1943
|
if (!request.ok) {
|
|
1944
|
-
const errorData = await request.
|
|
1945
|
-
if (request.status === 401) {
|
|
1944
|
+
const errorData = await request.text();
|
|
1945
|
+
if (request.status === 401 || request.status === 403) {
|
|
1946
1946
|
throw new AuthenticationError(
|
|
1947
|
-
|
|
1947
|
+
`Authentication failed: ${errorData}`,
|
|
1948
1948
|
request.status,
|
|
1949
1949
|
errorData
|
|
1950
1950
|
);
|
|
1951
1951
|
}
|
|
1952
1952
|
throw new NetworkError(
|
|
1953
|
-
`HTTP error
|
|
1953
|
+
`HTTP error: ${errorData}`,
|
|
1954
1954
|
request.status,
|
|
1955
1955
|
errorData
|
|
1956
1956
|
);
|
|
@@ -1975,8 +1975,8 @@ var analyticsTopUsage = async (config, options) => {
|
|
|
1975
1975
|
|
|
1976
1976
|
// src/core/gateway/analyticsDateInterval.ts
|
|
1977
1977
|
var analyticsDateInterval = async (config, options) => {
|
|
1978
|
-
if (!config
|
|
1979
|
-
throw new ValidationError("Pinata configuration
|
|
1978
|
+
if (!config) {
|
|
1979
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1980
1980
|
}
|
|
1981
1981
|
const params = new URLSearchParams();
|
|
1982
1982
|
if (options) {
|
|
@@ -2042,16 +2042,16 @@ var analyticsDateInterval = async (config, options) => {
|
|
|
2042
2042
|
headers
|
|
2043
2043
|
});
|
|
2044
2044
|
if (!request.ok) {
|
|
2045
|
-
const errorData = await request.
|
|
2046
|
-
if (request.status === 401) {
|
|
2045
|
+
const errorData = await request.text();
|
|
2046
|
+
if (request.status === 401 || request.status === 403) {
|
|
2047
2047
|
throw new AuthenticationError(
|
|
2048
|
-
|
|
2048
|
+
`Authentication failed: ${errorData}`,
|
|
2049
2049
|
request.status,
|
|
2050
2050
|
errorData
|
|
2051
2051
|
);
|
|
2052
2052
|
}
|
|
2053
2053
|
throw new NetworkError(
|
|
2054
|
-
`HTTP error
|
|
2054
|
+
`HTTP error: ${errorData}`,
|
|
2055
2055
|
request.status,
|
|
2056
2056
|
errorData
|
|
2057
2057
|
);
|
|
@@ -2076,8 +2076,8 @@ var analyticsDateInterval = async (config, options) => {
|
|
|
2076
2076
|
|
|
2077
2077
|
// src/core/gateway/swapCid.ts
|
|
2078
2078
|
var swapCid = async (config, options) => {
|
|
2079
|
-
if (!config
|
|
2080
|
-
throw new ValidationError("Pinata configuration
|
|
2079
|
+
if (!config) {
|
|
2080
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
2081
2081
|
}
|
|
2082
2082
|
const data = JSON.stringify({
|
|
2083
2083
|
swapCid: options.swapCid
|
|
@@ -2103,10 +2103,10 @@ var swapCid = async (config, options) => {
|
|
|
2103
2103
|
body: data
|
|
2104
2104
|
});
|
|
2105
2105
|
if (!request.ok) {
|
|
2106
|
-
const errorData = await request.
|
|
2107
|
-
if (request.status === 401) {
|
|
2106
|
+
const errorData = await request.text();
|
|
2107
|
+
if (request.status === 401 || request.status === 403) {
|
|
2108
2108
|
throw new AuthenticationError(
|
|
2109
|
-
|
|
2109
|
+
`Authentication failed: ${errorData}`,
|
|
2110
2110
|
request.status,
|
|
2111
2111
|
errorData
|
|
2112
2112
|
);
|
|
@@ -2126,7 +2126,7 @@ var swapCid = async (config, options) => {
|
|
|
2126
2126
|
);
|
|
2127
2127
|
}
|
|
2128
2128
|
throw new NetworkError(
|
|
2129
|
-
`HTTP error
|
|
2129
|
+
`HTTP error: ${errorData}`,
|
|
2130
2130
|
request.status,
|
|
2131
2131
|
errorData
|
|
2132
2132
|
);
|
|
@@ -2147,8 +2147,8 @@ var swapCid = async (config, options) => {
|
|
|
2147
2147
|
|
|
2148
2148
|
// src/core/gateway/swapHistory.ts
|
|
2149
2149
|
var swapHistory = async (config, options) => {
|
|
2150
|
-
if (!config
|
|
2151
|
-
throw new ValidationError("Pinata configuration
|
|
2150
|
+
if (!config) {
|
|
2151
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
2152
2152
|
}
|
|
2153
2153
|
let headers;
|
|
2154
2154
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -2173,10 +2173,10 @@ var swapHistory = async (config, options) => {
|
|
|
2173
2173
|
}
|
|
2174
2174
|
);
|
|
2175
2175
|
if (!request.ok) {
|
|
2176
|
-
const errorData = await request.
|
|
2177
|
-
if (request.status === 401) {
|
|
2176
|
+
const errorData = await request.text();
|
|
2177
|
+
if (request.status === 401 || request.status === 403) {
|
|
2178
2178
|
throw new AuthenticationError(
|
|
2179
|
-
|
|
2179
|
+
`Authentication failed: ${errorData}`,
|
|
2180
2180
|
request.status,
|
|
2181
2181
|
errorData
|
|
2182
2182
|
);
|
|
@@ -2189,7 +2189,7 @@ var swapHistory = async (config, options) => {
|
|
|
2189
2189
|
);
|
|
2190
2190
|
}
|
|
2191
2191
|
throw new NetworkError(
|
|
2192
|
-
`HTTP error
|
|
2192
|
+
`HTTP error: ${errorData}`,
|
|
2193
2193
|
request.status,
|
|
2194
2194
|
errorData
|
|
2195
2195
|
);
|
|
@@ -2212,8 +2212,8 @@ var swapHistory = async (config, options) => {
|
|
|
2212
2212
|
|
|
2213
2213
|
// src/core/gateway/deleteSwap.ts
|
|
2214
2214
|
var deleteSwap = async (config, cid) => {
|
|
2215
|
-
if (!config
|
|
2216
|
-
throw new ValidationError("Pinata configuration
|
|
2215
|
+
if (!config) {
|
|
2216
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
2217
2217
|
}
|
|
2218
2218
|
let headers;
|
|
2219
2219
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -2235,10 +2235,10 @@ var deleteSwap = async (config, cid) => {
|
|
|
2235
2235
|
headers
|
|
2236
2236
|
});
|
|
2237
2237
|
if (!request.ok) {
|
|
2238
|
-
const errorData = await request.
|
|
2239
|
-
if (request.status === 401) {
|
|
2238
|
+
const errorData = await request.text();
|
|
2239
|
+
if (request.status === 401 || request.status === 403) {
|
|
2240
2240
|
throw new AuthenticationError(
|
|
2241
|
-
|
|
2241
|
+
`Authentication failed: ${errorData}`,
|
|
2242
2242
|
request.status,
|
|
2243
2243
|
errorData
|
|
2244
2244
|
);
|
|
@@ -2258,7 +2258,7 @@ var deleteSwap = async (config, cid) => {
|
|
|
2258
2258
|
);
|
|
2259
2259
|
}
|
|
2260
2260
|
throw new NetworkError(
|
|
2261
|
-
`HTTP error
|
|
2261
|
+
`HTTP error: ${errorData}`,
|
|
2262
2262
|
request.status,
|
|
2263
2263
|
errorData
|
|
2264
2264
|
);
|