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.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
|
|
32
|
-
throw new ValidationError("Pinata configuration
|
|
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";
|
|
@@ -50,16 +50,16 @@ var testAuthentication = async (config) => {
|
|
|
50
50
|
headers
|
|
51
51
|
});
|
|
52
52
|
if (!request.ok) {
|
|
53
|
-
const errorData = await request.
|
|
54
|
-
if (request.status === 401) {
|
|
53
|
+
const errorData = await request.text();
|
|
54
|
+
if (request.status === 401 || request.status === 403) {
|
|
55
55
|
throw new AuthenticationError(
|
|
56
|
-
|
|
56
|
+
`Authentication failed: ${errorData}`,
|
|
57
57
|
request.status,
|
|
58
58
|
errorData
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
throw new NetworkError(
|
|
62
|
-
`HTTP error
|
|
62
|
+
`HTTP error: ${errorData}`,
|
|
63
63
|
request.status,
|
|
64
64
|
errorData
|
|
65
65
|
);
|
|
@@ -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
|
|
87
|
-
throw new ValidationError("Pinata configuration
|
|
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();
|
|
@@ -123,16 +123,16 @@ var uploadFile = async (config, file, options) => {
|
|
|
123
123
|
body: data
|
|
124
124
|
});
|
|
125
125
|
if (!request.ok) {
|
|
126
|
-
const errorData = await request.
|
|
127
|
-
if (request.status === 401) {
|
|
126
|
+
const errorData = await request.text();
|
|
127
|
+
if (request.status === 401 || request.status === 403) {
|
|
128
128
|
throw new AuthenticationError(
|
|
129
|
-
|
|
129
|
+
`Authentication failed: ${errorData}`,
|
|
130
130
|
request.status,
|
|
131
131
|
errorData
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
134
|
throw new NetworkError(
|
|
135
|
-
`HTTP error
|
|
135
|
+
`HTTP error: ${errorData}`,
|
|
136
136
|
request.status,
|
|
137
137
|
errorData
|
|
138
138
|
);
|
|
@@ -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
|
|
156
|
-
throw new ValidationError("Pinata configuration
|
|
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";
|
|
@@ -195,16 +195,16 @@ var uploadFileArray = async (config, files, options) => {
|
|
|
195
195
|
body: data
|
|
196
196
|
});
|
|
197
197
|
if (!request.ok) {
|
|
198
|
-
const errorData = await request.
|
|
199
|
-
if (request.status === 401) {
|
|
198
|
+
const errorData = await request.text();
|
|
199
|
+
if (request.status === 401 || request.status === 403) {
|
|
200
200
|
throw new AuthenticationError(
|
|
201
|
-
|
|
201
|
+
`Authentication failed: ${errorData}`,
|
|
202
202
|
request.status,
|
|
203
203
|
errorData
|
|
204
204
|
);
|
|
205
205
|
}
|
|
206
206
|
throw new NetworkError(
|
|
207
|
-
`HTTP error
|
|
207
|
+
`HTTP error: ${errorData}`,
|
|
208
208
|
request.status,
|
|
209
209
|
errorData
|
|
210
210
|
);
|
|
@@ -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
|
|
230
|
-
throw new ValidationError("Pinata configuration
|
|
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";
|
|
@@ -269,16 +269,16 @@ var uploadBase64 = async (config, base64String, options) => {
|
|
|
269
269
|
body: data
|
|
270
270
|
});
|
|
271
271
|
if (!request.ok) {
|
|
272
|
-
const errorData = await request.
|
|
273
|
-
if (request.status === 401) {
|
|
272
|
+
const errorData = await request.text();
|
|
273
|
+
if (request.status === 401 || request.status === 403) {
|
|
274
274
|
throw new AuthenticationError(
|
|
275
|
-
|
|
275
|
+
`Authentication failed: ${errorData}`,
|
|
276
276
|
request.status,
|
|
277
277
|
errorData
|
|
278
278
|
);
|
|
279
279
|
}
|
|
280
280
|
throw new NetworkError(
|
|
281
|
-
`HTTP error
|
|
281
|
+
`HTTP error: ${errorData}`,
|
|
282
282
|
request.status,
|
|
283
283
|
errorData
|
|
284
284
|
);
|
|
@@ -300,16 +300,16 @@ 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
|
|
304
|
-
throw new ValidationError("Pinata configuration
|
|
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();
|
|
308
308
|
const stream = await fetch(url);
|
|
309
309
|
if (!stream.ok) {
|
|
310
|
-
const errorData = await stream.
|
|
310
|
+
const errorData = await stream.text();
|
|
311
311
|
throw new NetworkError(
|
|
312
|
-
`HTTP error
|
|
312
|
+
`HTTP error: ${errorData}`,
|
|
313
313
|
stream.status,
|
|
314
314
|
errorData
|
|
315
315
|
);
|
|
@@ -353,16 +353,16 @@ var uploadUrl = async (config, url, options) => {
|
|
|
353
353
|
body: data
|
|
354
354
|
});
|
|
355
355
|
if (!request.ok) {
|
|
356
|
-
const errorData = await request.
|
|
357
|
-
if (request.status === 401) {
|
|
356
|
+
const errorData = await request.text();
|
|
357
|
+
if (request.status === 401 || request.status === 403) {
|
|
358
358
|
throw new AuthenticationError(
|
|
359
|
-
|
|
359
|
+
`Authentication failed: ${errorData}`,
|
|
360
360
|
request.status,
|
|
361
361
|
errorData
|
|
362
362
|
);
|
|
363
363
|
}
|
|
364
364
|
throw new NetworkError(
|
|
365
|
-
`HTTP error
|
|
365
|
+
`HTTP error: ${errorData}`,
|
|
366
366
|
request.status,
|
|
367
367
|
errorData
|
|
368
368
|
);
|
|
@@ -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
|
|
386
|
-
throw new ValidationError("Pinata configuration
|
|
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({
|
|
@@ -418,16 +418,16 @@ var uploadJson = async (config, jsonData, options) => {
|
|
|
418
418
|
body: data
|
|
419
419
|
});
|
|
420
420
|
if (!request.ok) {
|
|
421
|
-
const errorData = await request.
|
|
422
|
-
if (request.status === 401) {
|
|
421
|
+
const errorData = await request.text();
|
|
422
|
+
if (request.status === 401 || request.status === 403) {
|
|
423
423
|
throw new AuthenticationError(
|
|
424
|
-
|
|
424
|
+
`Authentication failed: ${errorData}`,
|
|
425
425
|
request.status,
|
|
426
426
|
errorData
|
|
427
427
|
);
|
|
428
428
|
}
|
|
429
429
|
throw new NetworkError(
|
|
430
|
-
`HTTP error
|
|
430
|
+
`HTTP error: ${errorData}`,
|
|
431
431
|
request.status,
|
|
432
432
|
errorData
|
|
433
433
|
);
|
|
@@ -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
|
|
451
|
-
throw new ValidationError("Pinata configuration
|
|
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;
|
|
@@ -483,16 +483,16 @@ var uploadCid = async (config, cid, options) => {
|
|
|
483
483
|
body: data
|
|
484
484
|
});
|
|
485
485
|
if (!request.ok) {
|
|
486
|
-
const errorData = await request.
|
|
487
|
-
if (request.status === 401) {
|
|
486
|
+
const errorData = await request.text();
|
|
487
|
+
if (request.status === 401 || request.status === 403) {
|
|
488
488
|
throw new AuthenticationError(
|
|
489
|
-
|
|
489
|
+
`Authentication failed: ${errorData}`,
|
|
490
490
|
request.status,
|
|
491
491
|
errorData
|
|
492
492
|
);
|
|
493
493
|
}
|
|
494
494
|
throw new NetworkError(
|
|
495
|
-
`HTTP error
|
|
495
|
+
`HTTP error: ${errorData}`,
|
|
496
496
|
request.status,
|
|
497
497
|
errorData
|
|
498
498
|
);
|
|
@@ -517,8 +517,8 @@ var wait = (milliseconds) => {
|
|
|
517
517
|
});
|
|
518
518
|
};
|
|
519
519
|
var unpinFile = async (config, files) => {
|
|
520
|
-
if (!config
|
|
521
|
-
throw new ValidationError("Pinata configuration
|
|
520
|
+
if (!config) {
|
|
521
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
522
522
|
}
|
|
523
523
|
const responses = [];
|
|
524
524
|
let headers;
|
|
@@ -542,16 +542,16 @@ var unpinFile = async (config, files) => {
|
|
|
542
542
|
});
|
|
543
543
|
await wait(300);
|
|
544
544
|
if (!response.ok) {
|
|
545
|
-
const errorData = await response.
|
|
545
|
+
const errorData = await response.text();
|
|
546
546
|
if (response.status === 401) {
|
|
547
547
|
throw new AuthenticationError(
|
|
548
|
-
|
|
548
|
+
`Authentication failed: ${errorData}`,
|
|
549
549
|
response.status,
|
|
550
550
|
errorData
|
|
551
551
|
);
|
|
552
552
|
}
|
|
553
553
|
throw new NetworkError(
|
|
554
|
-
`HTTP error
|
|
554
|
+
`HTTP error: ${errorData}`,
|
|
555
555
|
response.status,
|
|
556
556
|
errorData
|
|
557
557
|
);
|
|
@@ -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
|
|
585
|
-
throw new ValidationError("Pinata configuration
|
|
584
|
+
if (!config) {
|
|
585
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
586
586
|
}
|
|
587
587
|
const params = new URLSearchParams({
|
|
588
588
|
includesCount: "false"
|
|
@@ -647,16 +647,16 @@ var listFiles = async (config, options) => {
|
|
|
647
647
|
headers
|
|
648
648
|
});
|
|
649
649
|
if (!request.ok) {
|
|
650
|
-
const errorData = await request.
|
|
651
|
-
if (request.status === 401) {
|
|
650
|
+
const errorData = await request.text();
|
|
651
|
+
if (request.status === 401 || request.status === 403) {
|
|
652
652
|
throw new AuthenticationError(
|
|
653
|
-
|
|
653
|
+
`Authentication failed: ${errorData}`,
|
|
654
654
|
request.status,
|
|
655
655
|
errorData
|
|
656
656
|
);
|
|
657
657
|
}
|
|
658
658
|
throw new NetworkError(
|
|
659
|
-
`HTTP error
|
|
659
|
+
`HTTP error: ${errorData}`,
|
|
660
660
|
request.status,
|
|
661
661
|
errorData
|
|
662
662
|
);
|
|
@@ -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
|
|
680
|
-
throw new ValidationError("Pinata configuration
|
|
679
|
+
if (!config) {
|
|
680
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
681
681
|
}
|
|
682
682
|
const data = {
|
|
683
683
|
ipfsPinHash: options.cid,
|
|
@@ -705,16 +705,16 @@ var updateMetadata = async (config, options) => {
|
|
|
705
705
|
body: JSON.stringify(data)
|
|
706
706
|
});
|
|
707
707
|
if (!request.ok) {
|
|
708
|
-
const errorData = await request.
|
|
709
|
-
if (request.status === 401) {
|
|
708
|
+
const errorData = await request.text();
|
|
709
|
+
if (request.status === 401 || request.status === 403) {
|
|
710
710
|
throw new AuthenticationError(
|
|
711
|
-
|
|
711
|
+
`Authentication failed: ${errorData}`,
|
|
712
712
|
request.status,
|
|
713
713
|
errorData
|
|
714
714
|
);
|
|
715
715
|
}
|
|
716
716
|
throw new NetworkError(
|
|
717
|
-
`HTTP error
|
|
717
|
+
`HTTP error: ${errorData}`,
|
|
718
718
|
request.status,
|
|
719
719
|
errorData
|
|
720
720
|
);
|
|
@@ -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
|
|
834
|
-
throw new ValidationError("Pinata configuration
|
|
833
|
+
if (!config) {
|
|
834
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
835
835
|
}
|
|
836
836
|
let data;
|
|
837
837
|
let newUrl;
|
|
@@ -842,16 +842,16 @@ var getCid = async (config, cid) => {
|
|
|
842
842
|
try {
|
|
843
843
|
const request = await fetch(newUrl);
|
|
844
844
|
if (!request.ok) {
|
|
845
|
-
const errorData = await request.
|
|
846
|
-
if (request.status === 401) {
|
|
845
|
+
const errorData = await request.text();
|
|
846
|
+
if (request.status === 401 || request.status === 403) {
|
|
847
847
|
throw new AuthenticationError(
|
|
848
|
-
|
|
848
|
+
`Authentication Failed: ${errorData}`,
|
|
849
849
|
request.status,
|
|
850
850
|
errorData
|
|
851
851
|
);
|
|
852
852
|
}
|
|
853
853
|
throw new NetworkError(
|
|
854
|
-
`HTTP error
|
|
854
|
+
`HTTP error: ${errorData}`,
|
|
855
855
|
request.status,
|
|
856
856
|
errorData
|
|
857
857
|
);
|
|
@@ -894,8 +894,8 @@ var convertIPFSUrl = async (config, url) => {
|
|
|
894
894
|
|
|
895
895
|
// src/core/data/pinJobs.ts
|
|
896
896
|
var pinJobs = async (config, options) => {
|
|
897
|
-
if (!config
|
|
898
|
-
throw new ValidationError("Pinata configuration
|
|
897
|
+
if (!config) {
|
|
898
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
899
899
|
}
|
|
900
900
|
const params = new URLSearchParams({
|
|
901
901
|
includesCount: "false"
|
|
@@ -933,16 +933,16 @@ var pinJobs = async (config, options) => {
|
|
|
933
933
|
headers
|
|
934
934
|
});
|
|
935
935
|
if (!request.ok) {
|
|
936
|
-
const errorData = await request.
|
|
937
|
-
if (request.status === 401) {
|
|
936
|
+
const errorData = await request.text();
|
|
937
|
+
if (request.status === 401 || request.status === 403) {
|
|
938
938
|
throw new AuthenticationError(
|
|
939
|
-
|
|
939
|
+
`Authentication failed: ${errorData}`,
|
|
940
940
|
request.status,
|
|
941
941
|
errorData
|
|
942
942
|
);
|
|
943
943
|
}
|
|
944
944
|
throw new NetworkError(
|
|
945
|
-
`HTTP error
|
|
945
|
+
`HTTP error: ${errorData}`,
|
|
946
946
|
request.status,
|
|
947
947
|
errorData
|
|
948
948
|
);
|
|
@@ -962,8 +962,8 @@ var pinJobs = async (config, options) => {
|
|
|
962
962
|
|
|
963
963
|
// src/core/data/pinnedFileUsage.ts
|
|
964
964
|
var pinnedFileCount = async (config) => {
|
|
965
|
-
if (!config
|
|
966
|
-
throw new ValidationError("Pinata configuration
|
|
965
|
+
if (!config) {
|
|
966
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
967
967
|
}
|
|
968
968
|
let endpoint = "https://api.pinata.cloud";
|
|
969
969
|
if (config.endpointUrl) {
|
|
@@ -984,16 +984,16 @@ var pinnedFileCount = async (config) => {
|
|
|
984
984
|
headers
|
|
985
985
|
});
|
|
986
986
|
if (!request.ok) {
|
|
987
|
-
const errorData = await request.
|
|
988
|
-
if (request.status === 401) {
|
|
987
|
+
const errorData = await request.text();
|
|
988
|
+
if (request.status === 401 || request.status === 403) {
|
|
989
989
|
throw new AuthenticationError(
|
|
990
|
-
|
|
990
|
+
`Authentication failed: ${errorData}`,
|
|
991
991
|
request.status,
|
|
992
992
|
errorData
|
|
993
993
|
);
|
|
994
994
|
}
|
|
995
995
|
throw new NetworkError(
|
|
996
|
-
`HTTP error
|
|
996
|
+
`HTTP error: ${errorData}`,
|
|
997
997
|
request.status,
|
|
998
998
|
errorData
|
|
999
999
|
);
|
|
@@ -1017,8 +1017,8 @@ var pinnedFileCount = async (config) => {
|
|
|
1017
1017
|
|
|
1018
1018
|
// src/core/data/totalStorageUsage.ts
|
|
1019
1019
|
var totalStorageUsage = async (config) => {
|
|
1020
|
-
if (!config
|
|
1021
|
-
throw new ValidationError("Pinata configuration
|
|
1020
|
+
if (!config) {
|
|
1021
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1022
1022
|
}
|
|
1023
1023
|
let endpoint = "https://api.pinata.cloud";
|
|
1024
1024
|
if (config.endpointUrl) {
|
|
@@ -1039,16 +1039,16 @@ var totalStorageUsage = async (config) => {
|
|
|
1039
1039
|
headers
|
|
1040
1040
|
});
|
|
1041
1041
|
if (!request.ok) {
|
|
1042
|
-
const errorData = await request.
|
|
1043
|
-
if (request.status === 401) {
|
|
1042
|
+
const errorData = await request.text();
|
|
1043
|
+
if (request.status === 401 || request.status === 403) {
|
|
1044
1044
|
throw new AuthenticationError(
|
|
1045
|
-
|
|
1045
|
+
`Authentication failed: ${errorData}`,
|
|
1046
1046
|
request.status,
|
|
1047
1047
|
errorData
|
|
1048
1048
|
);
|
|
1049
1049
|
}
|
|
1050
1050
|
throw new NetworkError(
|
|
1051
|
-
`HTTP error
|
|
1051
|
+
`HTTP error: ${errorData}`,
|
|
1052
1052
|
request.status,
|
|
1053
1053
|
errorData
|
|
1054
1054
|
);
|
|
@@ -1072,8 +1072,8 @@ var totalStorageUsage = async (config) => {
|
|
|
1072
1072
|
|
|
1073
1073
|
// src/core/keys/createKey.ts
|
|
1074
1074
|
var createKey = async (config, options) => {
|
|
1075
|
-
if (!config
|
|
1076
|
-
throw new ValidationError("Pinata configuration
|
|
1075
|
+
if (!config) {
|
|
1076
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1077
1077
|
}
|
|
1078
1078
|
let headers;
|
|
1079
1079
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1097,16 +1097,16 @@ var createKey = async (config, options) => {
|
|
|
1097
1097
|
body: data
|
|
1098
1098
|
});
|
|
1099
1099
|
if (!request.ok) {
|
|
1100
|
-
const errorData = await request.
|
|
1101
|
-
if (request.status === 401) {
|
|
1100
|
+
const errorData = await request.text();
|
|
1101
|
+
if (request.status === 401 || request.status === 403) {
|
|
1102
1102
|
throw new AuthenticationError(
|
|
1103
|
-
|
|
1103
|
+
`Authentication failed: ${errorData}`,
|
|
1104
1104
|
request.status,
|
|
1105
1105
|
errorData
|
|
1106
1106
|
);
|
|
1107
1107
|
}
|
|
1108
1108
|
throw new NetworkError(
|
|
1109
|
-
`HTTP error
|
|
1109
|
+
`HTTP error: ${errorData}`,
|
|
1110
1110
|
request.status,
|
|
1111
1111
|
errorData
|
|
1112
1112
|
);
|
|
@@ -1126,8 +1126,8 @@ var createKey = async (config, options) => {
|
|
|
1126
1126
|
|
|
1127
1127
|
// src/core/keys/listKeys.ts
|
|
1128
1128
|
var listKeys = async (config, options) => {
|
|
1129
|
-
if (!config
|
|
1130
|
-
throw new ValidationError("Pinata configuration
|
|
1129
|
+
if (!config) {
|
|
1130
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1131
1131
|
}
|
|
1132
1132
|
let headers;
|
|
1133
1133
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1166,16 +1166,16 @@ var listKeys = async (config, options) => {
|
|
|
1166
1166
|
}
|
|
1167
1167
|
);
|
|
1168
1168
|
if (!request.ok) {
|
|
1169
|
-
const errorData = await request.
|
|
1170
|
-
if (request.status === 401) {
|
|
1169
|
+
const errorData = await request.text();
|
|
1170
|
+
if (request.status === 401 || request.status === 403) {
|
|
1171
1171
|
throw new AuthenticationError(
|
|
1172
|
-
|
|
1172
|
+
`Authentication failed: ${errorData}`,
|
|
1173
1173
|
request.status,
|
|
1174
1174
|
errorData
|
|
1175
1175
|
);
|
|
1176
1176
|
}
|
|
1177
1177
|
throw new NetworkError(
|
|
1178
|
-
`HTTP error
|
|
1178
|
+
`HTTP error: ${errorData}`,
|
|
1179
1179
|
request.status,
|
|
1180
1180
|
errorData
|
|
1181
1181
|
);
|
|
@@ -1200,8 +1200,8 @@ var wait2 = (milliseconds) => {
|
|
|
1200
1200
|
});
|
|
1201
1201
|
};
|
|
1202
1202
|
var revokeKeys = async (config, keys) => {
|
|
1203
|
-
if (!config
|
|
1204
|
-
throw new ValidationError("Pinata configuration
|
|
1203
|
+
if (!config) {
|
|
1204
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1205
1205
|
}
|
|
1206
1206
|
let headers;
|
|
1207
1207
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1226,16 +1226,16 @@ var revokeKeys = async (config, keys) => {
|
|
|
1226
1226
|
});
|
|
1227
1227
|
await wait2(300);
|
|
1228
1228
|
if (!request.ok) {
|
|
1229
|
-
const errorData = await request.
|
|
1230
|
-
if (request.status === 401) {
|
|
1229
|
+
const errorData = await request.text();
|
|
1230
|
+
if (request.status === 401 || request.status === 403) {
|
|
1231
1231
|
throw new AuthenticationError(
|
|
1232
|
-
|
|
1232
|
+
`Authentication failed: ${errorData}`,
|
|
1233
1233
|
request.status,
|
|
1234
1234
|
errorData
|
|
1235
1235
|
);
|
|
1236
1236
|
}
|
|
1237
1237
|
throw new NetworkError(
|
|
1238
|
-
`HTTP error
|
|
1238
|
+
`HTTP error: ${errorData}`,
|
|
1239
1239
|
request.status,
|
|
1240
1240
|
errorData
|
|
1241
1241
|
);
|
|
@@ -1265,8 +1265,8 @@ var revokeKeys = async (config, keys) => {
|
|
|
1265
1265
|
|
|
1266
1266
|
// src/core/groups/createGroup.ts
|
|
1267
1267
|
var createGroup = async (config, options) => {
|
|
1268
|
-
if (!config
|
|
1269
|
-
throw new ValidationError("Pinata configuration
|
|
1268
|
+
if (!config) {
|
|
1269
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1270
1270
|
}
|
|
1271
1271
|
const data = JSON.stringify(options);
|
|
1272
1272
|
let headers;
|
|
@@ -1290,16 +1290,16 @@ var createGroup = async (config, options) => {
|
|
|
1290
1290
|
body: data
|
|
1291
1291
|
});
|
|
1292
1292
|
if (!request.ok) {
|
|
1293
|
-
const errorData = await request.
|
|
1294
|
-
if (request.status === 401) {
|
|
1293
|
+
const errorData = await request.text();
|
|
1294
|
+
if (request.status === 401 || request.status === 403) {
|
|
1295
1295
|
throw new AuthenticationError(
|
|
1296
|
-
|
|
1296
|
+
`Authentication failed: ${errorData}`,
|
|
1297
1297
|
request.status,
|
|
1298
1298
|
errorData
|
|
1299
1299
|
);
|
|
1300
1300
|
}
|
|
1301
1301
|
throw new NetworkError(
|
|
1302
|
-
`HTTP error
|
|
1302
|
+
`HTTP error: ${errorData}`,
|
|
1303
1303
|
request.status,
|
|
1304
1304
|
errorData
|
|
1305
1305
|
);
|
|
@@ -1319,8 +1319,8 @@ var createGroup = async (config, options) => {
|
|
|
1319
1319
|
|
|
1320
1320
|
// src/core/groups/listGroups.ts
|
|
1321
1321
|
var listGroups = async (config, options) => {
|
|
1322
|
-
if (!config
|
|
1323
|
-
throw new ValidationError("Pinata configuration
|
|
1322
|
+
if (!config) {
|
|
1323
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1324
1324
|
}
|
|
1325
1325
|
let headers;
|
|
1326
1326
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1352,16 +1352,16 @@ var listGroups = async (config, options) => {
|
|
|
1352
1352
|
headers
|
|
1353
1353
|
});
|
|
1354
1354
|
if (!request.ok) {
|
|
1355
|
-
const errorData = await request.
|
|
1356
|
-
if (request.status === 401) {
|
|
1355
|
+
const errorData = await request.text();
|
|
1356
|
+
if (request.status === 401 || request.status === 403) {
|
|
1357
1357
|
throw new AuthenticationError(
|
|
1358
|
-
|
|
1358
|
+
`Authentication failed: ${errorData}`,
|
|
1359
1359
|
request.status,
|
|
1360
1360
|
errorData
|
|
1361
1361
|
);
|
|
1362
1362
|
}
|
|
1363
1363
|
throw new NetworkError(
|
|
1364
|
-
`HTTP error
|
|
1364
|
+
`HTTP error: ${errorData}`,
|
|
1365
1365
|
request.status,
|
|
1366
1366
|
errorData
|
|
1367
1367
|
);
|
|
@@ -1381,8 +1381,8 @@ var listGroups = async (config, options) => {
|
|
|
1381
1381
|
|
|
1382
1382
|
// src/core/groups/getGroup.ts
|
|
1383
1383
|
var getGroup = async (config, options) => {
|
|
1384
|
-
if (!config
|
|
1385
|
-
throw new ValidationError("Pinata configuration
|
|
1384
|
+
if (!config) {
|
|
1385
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1386
1386
|
}
|
|
1387
1387
|
let headers;
|
|
1388
1388
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1404,16 +1404,16 @@ var getGroup = async (config, options) => {
|
|
|
1404
1404
|
headers
|
|
1405
1405
|
});
|
|
1406
1406
|
if (!request.ok) {
|
|
1407
|
-
const errorData = await request.
|
|
1408
|
-
if (request.status === 401) {
|
|
1407
|
+
const errorData = await request.text();
|
|
1408
|
+
if (request.status === 401 || request.status === 403) {
|
|
1409
1409
|
throw new AuthenticationError(
|
|
1410
|
-
|
|
1410
|
+
`Authentication failed: ${errorData}`,
|
|
1411
1411
|
request.status,
|
|
1412
1412
|
errorData
|
|
1413
1413
|
);
|
|
1414
1414
|
}
|
|
1415
1415
|
throw new NetworkError(
|
|
1416
|
-
`HTTP error
|
|
1416
|
+
`HTTP error: ${errorData}`,
|
|
1417
1417
|
request.status,
|
|
1418
1418
|
errorData
|
|
1419
1419
|
);
|
|
@@ -1435,8 +1435,8 @@ var getGroup = async (config, options) => {
|
|
|
1435
1435
|
|
|
1436
1436
|
// src/core/groups/addToGroup.ts
|
|
1437
1437
|
var addToGroup = async (config, options) => {
|
|
1438
|
-
if (!config
|
|
1439
|
-
throw new ValidationError("Pinata configuration
|
|
1438
|
+
if (!config) {
|
|
1439
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1440
1440
|
}
|
|
1441
1441
|
const data = JSON.stringify({
|
|
1442
1442
|
cids: options.cids
|
|
@@ -1462,16 +1462,16 @@ var addToGroup = async (config, options) => {
|
|
|
1462
1462
|
body: data
|
|
1463
1463
|
});
|
|
1464
1464
|
if (!request.ok) {
|
|
1465
|
-
const errorData = await request.
|
|
1466
|
-
if (request.status === 401) {
|
|
1465
|
+
const errorData = await request.text();
|
|
1466
|
+
if (request.status === 401 || request.status === 403) {
|
|
1467
1467
|
throw new AuthenticationError(
|
|
1468
|
-
|
|
1468
|
+
`Authentication failed: ${errorData}`,
|
|
1469
1469
|
request.status,
|
|
1470
1470
|
errorData
|
|
1471
1471
|
);
|
|
1472
1472
|
}
|
|
1473
1473
|
throw new NetworkError(
|
|
1474
|
-
`HTTP error
|
|
1474
|
+
`HTTP error: ${errorData}`,
|
|
1475
1475
|
request.status,
|
|
1476
1476
|
errorData
|
|
1477
1477
|
);
|
|
@@ -1493,8 +1493,8 @@ var addToGroup = async (config, options) => {
|
|
|
1493
1493
|
|
|
1494
1494
|
// src/core/groups/updateGroup.ts
|
|
1495
1495
|
var updateGroup = async (config, options) => {
|
|
1496
|
-
if (!config
|
|
1497
|
-
throw new ValidationError("Pinata configuration
|
|
1496
|
+
if (!config) {
|
|
1497
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1498
1498
|
}
|
|
1499
1499
|
const data = JSON.stringify({
|
|
1500
1500
|
name: options.name
|
|
@@ -1520,16 +1520,16 @@ var updateGroup = async (config, options) => {
|
|
|
1520
1520
|
body: data
|
|
1521
1521
|
});
|
|
1522
1522
|
if (!request.ok) {
|
|
1523
|
-
const errorData = await request.
|
|
1524
|
-
if (request.status === 401) {
|
|
1523
|
+
const errorData = await request.text();
|
|
1524
|
+
if (request.status === 401 || request.status === 403) {
|
|
1525
1525
|
throw new AuthenticationError(
|
|
1526
|
-
|
|
1526
|
+
`Authentication failed: ${errorData}`,
|
|
1527
1527
|
request.status,
|
|
1528
1528
|
errorData
|
|
1529
1529
|
);
|
|
1530
1530
|
}
|
|
1531
1531
|
throw new NetworkError(
|
|
1532
|
-
`HTTP error
|
|
1532
|
+
`HTTP error: ${errorData}`,
|
|
1533
1533
|
request.status,
|
|
1534
1534
|
errorData
|
|
1535
1535
|
);
|
|
@@ -1549,8 +1549,8 @@ var updateGroup = async (config, options) => {
|
|
|
1549
1549
|
|
|
1550
1550
|
// src/core/groups/removeFromGroup.ts
|
|
1551
1551
|
var removeFromGroup = async (config, options) => {
|
|
1552
|
-
if (!config
|
|
1553
|
-
throw new ValidationError("Pinata configuration
|
|
1552
|
+
if (!config) {
|
|
1553
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1554
1554
|
}
|
|
1555
1555
|
let headers;
|
|
1556
1556
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1576,16 +1576,16 @@ var removeFromGroup = async (config, options) => {
|
|
|
1576
1576
|
body: data
|
|
1577
1577
|
});
|
|
1578
1578
|
if (!request.ok) {
|
|
1579
|
-
const errorData = await request.
|
|
1580
|
-
if (request.status === 401) {
|
|
1579
|
+
const errorData = await request.text();
|
|
1580
|
+
if (request.status === 401 || request.status === 403) {
|
|
1581
1581
|
throw new AuthenticationError(
|
|
1582
|
-
|
|
1582
|
+
`Authentication failed: ${errorData}`,
|
|
1583
1583
|
request.status,
|
|
1584
1584
|
errorData
|
|
1585
1585
|
);
|
|
1586
1586
|
}
|
|
1587
1587
|
throw new NetworkError(
|
|
1588
|
-
`HTTP error
|
|
1588
|
+
`HTTP error: ${errorData}`,
|
|
1589
1589
|
request.status,
|
|
1590
1590
|
errorData
|
|
1591
1591
|
);
|
|
@@ -1609,8 +1609,8 @@ var removeFromGroup = async (config, options) => {
|
|
|
1609
1609
|
|
|
1610
1610
|
// src/core/groups/deleteGroup.ts
|
|
1611
1611
|
var deleteGroup = async (config, options) => {
|
|
1612
|
-
if (!config
|
|
1613
|
-
throw new ValidationError("Pinata configuration
|
|
1612
|
+
if (!config) {
|
|
1613
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1614
1614
|
}
|
|
1615
1615
|
let headers;
|
|
1616
1616
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1632,16 +1632,16 @@ var deleteGroup = async (config, options) => {
|
|
|
1632
1632
|
headers
|
|
1633
1633
|
});
|
|
1634
1634
|
if (!request.ok) {
|
|
1635
|
-
const errorData = await request.
|
|
1636
|
-
if (request.status === 401) {
|
|
1635
|
+
const errorData = await request.text();
|
|
1636
|
+
if (request.status === 401 || request.status === 403) {
|
|
1637
1637
|
throw new AuthenticationError(
|
|
1638
|
-
|
|
1638
|
+
`Authentication failed: ${errorData}`,
|
|
1639
1639
|
request.status,
|
|
1640
1640
|
errorData
|
|
1641
1641
|
);
|
|
1642
1642
|
}
|
|
1643
1643
|
throw new NetworkError(
|
|
1644
|
-
`HTTP error
|
|
1644
|
+
`HTTP error: ${errorData}`,
|
|
1645
1645
|
request.status,
|
|
1646
1646
|
errorData
|
|
1647
1647
|
);
|
|
@@ -1661,8 +1661,8 @@ var deleteGroup = async (config, options) => {
|
|
|
1661
1661
|
|
|
1662
1662
|
// src/core/signatures/addSignature.ts
|
|
1663
1663
|
var addSignature = async (config, options) => {
|
|
1664
|
-
if (!config
|
|
1665
|
-
throw new ValidationError("Pinata configuration
|
|
1664
|
+
if (!config) {
|
|
1665
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1666
1666
|
}
|
|
1667
1667
|
const data = JSON.stringify({
|
|
1668
1668
|
signature: options.signature
|
|
@@ -1691,10 +1691,10 @@ var addSignature = async (config, options) => {
|
|
|
1691
1691
|
}
|
|
1692
1692
|
);
|
|
1693
1693
|
if (!request.ok) {
|
|
1694
|
-
const errorData = await request.
|
|
1695
|
-
if (request.status === 401) {
|
|
1694
|
+
const errorData = await request.text();
|
|
1695
|
+
if (request.status === 401 || request.status === 403) {
|
|
1696
1696
|
throw new AuthenticationError(
|
|
1697
|
-
|
|
1697
|
+
`Authentication failed: ${errorData}`,
|
|
1698
1698
|
request.status,
|
|
1699
1699
|
errorData
|
|
1700
1700
|
);
|
|
@@ -1707,7 +1707,7 @@ var addSignature = async (config, options) => {
|
|
|
1707
1707
|
);
|
|
1708
1708
|
}
|
|
1709
1709
|
throw new NetworkError(
|
|
1710
|
-
`HTTP error
|
|
1710
|
+
`HTTP error: ${errorData}`,
|
|
1711
1711
|
request.status,
|
|
1712
1712
|
errorData
|
|
1713
1713
|
);
|
|
@@ -1729,8 +1729,8 @@ var addSignature = async (config, options) => {
|
|
|
1729
1729
|
|
|
1730
1730
|
// src/core/signatures/getSignature.ts
|
|
1731
1731
|
var getSignature = async (config, cid) => {
|
|
1732
|
-
if (!config
|
|
1733
|
-
throw new ValidationError("Pinata configuration
|
|
1732
|
+
if (!config) {
|
|
1733
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1734
1734
|
}
|
|
1735
1735
|
let headers;
|
|
1736
1736
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1752,16 +1752,16 @@ var getSignature = async (config, cid) => {
|
|
|
1752
1752
|
headers
|
|
1753
1753
|
});
|
|
1754
1754
|
if (!request.ok) {
|
|
1755
|
-
const errorData = await request.
|
|
1756
|
-
if (request.status === 401) {
|
|
1755
|
+
const errorData = await request.text();
|
|
1756
|
+
if (request.status === 401 || request.status === 403) {
|
|
1757
1757
|
throw new AuthenticationError(
|
|
1758
|
-
|
|
1758
|
+
`Authentication failed: ${errorData}`,
|
|
1759
1759
|
request.status,
|
|
1760
1760
|
errorData
|
|
1761
1761
|
);
|
|
1762
1762
|
}
|
|
1763
1763
|
throw new NetworkError(
|
|
1764
|
-
`HTTP error
|
|
1764
|
+
`HTTP error: ${errorData}`,
|
|
1765
1765
|
request.status,
|
|
1766
1766
|
errorData
|
|
1767
1767
|
);
|
|
@@ -1783,8 +1783,8 @@ var getSignature = async (config, cid) => {
|
|
|
1783
1783
|
|
|
1784
1784
|
// src/core/signatures/removeSignature.ts
|
|
1785
1785
|
var removeSignature = async (config, cid) => {
|
|
1786
|
-
if (!config
|
|
1787
|
-
throw new ValidationError("Pinata configuration
|
|
1786
|
+
if (!config) {
|
|
1787
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1788
1788
|
}
|
|
1789
1789
|
let headers;
|
|
1790
1790
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1806,16 +1806,16 @@ var removeSignature = async (config, cid) => {
|
|
|
1806
1806
|
headers
|
|
1807
1807
|
});
|
|
1808
1808
|
if (!request.ok) {
|
|
1809
|
-
const errorData = await request.
|
|
1810
|
-
if (request.status === 401) {
|
|
1809
|
+
const errorData = await request.text();
|
|
1810
|
+
if (request.status === 401 || request.status === 403) {
|
|
1811
1811
|
throw new AuthenticationError(
|
|
1812
|
-
|
|
1812
|
+
`Authentication failed: ${errorData}`,
|
|
1813
1813
|
request.status,
|
|
1814
1814
|
errorData
|
|
1815
1815
|
);
|
|
1816
1816
|
}
|
|
1817
1817
|
throw new NetworkError(
|
|
1818
|
-
`HTTP error
|
|
1818
|
+
`HTTP error: ${errorData}`,
|
|
1819
1819
|
request.status,
|
|
1820
1820
|
errorData
|
|
1821
1821
|
);
|
|
@@ -1836,8 +1836,8 @@ var removeSignature = async (config, cid) => {
|
|
|
1836
1836
|
|
|
1837
1837
|
// src/core/gateway/analyticsTopUsage.ts
|
|
1838
1838
|
var analyticsTopUsage = async (config, options) => {
|
|
1839
|
-
if (!config
|
|
1840
|
-
throw new ValidationError("Pinata configuration
|
|
1839
|
+
if (!config) {
|
|
1840
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1841
1841
|
}
|
|
1842
1842
|
const params = new URLSearchParams({
|
|
1843
1843
|
includesCount: "false"
|
|
@@ -1905,16 +1905,16 @@ var analyticsTopUsage = async (config, options) => {
|
|
|
1905
1905
|
headers
|
|
1906
1906
|
});
|
|
1907
1907
|
if (!request.ok) {
|
|
1908
|
-
const errorData = await request.
|
|
1909
|
-
if (request.status === 401) {
|
|
1908
|
+
const errorData = await request.text();
|
|
1909
|
+
if (request.status === 401 || request.status === 403) {
|
|
1910
1910
|
throw new AuthenticationError(
|
|
1911
|
-
|
|
1911
|
+
`Authentication failed: ${errorData}`,
|
|
1912
1912
|
request.status,
|
|
1913
1913
|
errorData
|
|
1914
1914
|
);
|
|
1915
1915
|
}
|
|
1916
1916
|
throw new NetworkError(
|
|
1917
|
-
`HTTP error
|
|
1917
|
+
`HTTP error: ${errorData}`,
|
|
1918
1918
|
request.status,
|
|
1919
1919
|
errorData
|
|
1920
1920
|
);
|
|
@@ -1939,8 +1939,8 @@ var analyticsTopUsage = async (config, options) => {
|
|
|
1939
1939
|
|
|
1940
1940
|
// src/core/gateway/analyticsDateInterval.ts
|
|
1941
1941
|
var analyticsDateInterval = async (config, options) => {
|
|
1942
|
-
if (!config
|
|
1943
|
-
throw new ValidationError("Pinata configuration
|
|
1942
|
+
if (!config) {
|
|
1943
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1944
1944
|
}
|
|
1945
1945
|
const params = new URLSearchParams();
|
|
1946
1946
|
if (options) {
|
|
@@ -2006,16 +2006,16 @@ var analyticsDateInterval = async (config, options) => {
|
|
|
2006
2006
|
headers
|
|
2007
2007
|
});
|
|
2008
2008
|
if (!request.ok) {
|
|
2009
|
-
const errorData = await request.
|
|
2010
|
-
if (request.status === 401) {
|
|
2009
|
+
const errorData = await request.text();
|
|
2010
|
+
if (request.status === 401 || request.status === 403) {
|
|
2011
2011
|
throw new AuthenticationError(
|
|
2012
|
-
|
|
2012
|
+
`Authentication failed: ${errorData}`,
|
|
2013
2013
|
request.status,
|
|
2014
2014
|
errorData
|
|
2015
2015
|
);
|
|
2016
2016
|
}
|
|
2017
2017
|
throw new NetworkError(
|
|
2018
|
-
`HTTP error
|
|
2018
|
+
`HTTP error: ${errorData}`,
|
|
2019
2019
|
request.status,
|
|
2020
2020
|
errorData
|
|
2021
2021
|
);
|
|
@@ -2040,8 +2040,8 @@ var analyticsDateInterval = async (config, options) => {
|
|
|
2040
2040
|
|
|
2041
2041
|
// src/core/gateway/swapCid.ts
|
|
2042
2042
|
var swapCid = async (config, options) => {
|
|
2043
|
-
if (!config
|
|
2044
|
-
throw new ValidationError("Pinata configuration
|
|
2043
|
+
if (!config) {
|
|
2044
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
2045
2045
|
}
|
|
2046
2046
|
const data = JSON.stringify({
|
|
2047
2047
|
swapCid: options.swapCid
|
|
@@ -2067,10 +2067,10 @@ var swapCid = async (config, options) => {
|
|
|
2067
2067
|
body: data
|
|
2068
2068
|
});
|
|
2069
2069
|
if (!request.ok) {
|
|
2070
|
-
const errorData = await request.
|
|
2071
|
-
if (request.status === 401) {
|
|
2070
|
+
const errorData = await request.text();
|
|
2071
|
+
if (request.status === 401 || request.status === 403) {
|
|
2072
2072
|
throw new AuthenticationError(
|
|
2073
|
-
|
|
2073
|
+
`Authentication failed: ${errorData}`,
|
|
2074
2074
|
request.status,
|
|
2075
2075
|
errorData
|
|
2076
2076
|
);
|
|
@@ -2090,7 +2090,7 @@ var swapCid = async (config, options) => {
|
|
|
2090
2090
|
);
|
|
2091
2091
|
}
|
|
2092
2092
|
throw new NetworkError(
|
|
2093
|
-
`HTTP error
|
|
2093
|
+
`HTTP error: ${errorData}`,
|
|
2094
2094
|
request.status,
|
|
2095
2095
|
errorData
|
|
2096
2096
|
);
|
|
@@ -2111,8 +2111,8 @@ var swapCid = async (config, options) => {
|
|
|
2111
2111
|
|
|
2112
2112
|
// src/core/gateway/swapHistory.ts
|
|
2113
2113
|
var swapHistory = async (config, options) => {
|
|
2114
|
-
if (!config
|
|
2115
|
-
throw new ValidationError("Pinata configuration
|
|
2114
|
+
if (!config) {
|
|
2115
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
2116
2116
|
}
|
|
2117
2117
|
let headers;
|
|
2118
2118
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -2137,10 +2137,10 @@ var swapHistory = async (config, options) => {
|
|
|
2137
2137
|
}
|
|
2138
2138
|
);
|
|
2139
2139
|
if (!request.ok) {
|
|
2140
|
-
const errorData = await request.
|
|
2141
|
-
if (request.status === 401) {
|
|
2140
|
+
const errorData = await request.text();
|
|
2141
|
+
if (request.status === 401 || request.status === 403) {
|
|
2142
2142
|
throw new AuthenticationError(
|
|
2143
|
-
|
|
2143
|
+
`Authentication failed: ${errorData}`,
|
|
2144
2144
|
request.status,
|
|
2145
2145
|
errorData
|
|
2146
2146
|
);
|
|
@@ -2153,7 +2153,7 @@ var swapHistory = async (config, options) => {
|
|
|
2153
2153
|
);
|
|
2154
2154
|
}
|
|
2155
2155
|
throw new NetworkError(
|
|
2156
|
-
`HTTP error
|
|
2156
|
+
`HTTP error: ${errorData}`,
|
|
2157
2157
|
request.status,
|
|
2158
2158
|
errorData
|
|
2159
2159
|
);
|
|
@@ -2176,8 +2176,8 @@ var swapHistory = async (config, options) => {
|
|
|
2176
2176
|
|
|
2177
2177
|
// src/core/gateway/deleteSwap.ts
|
|
2178
2178
|
var deleteSwap = async (config, cid) => {
|
|
2179
|
-
if (!config
|
|
2180
|
-
throw new ValidationError("Pinata configuration
|
|
2179
|
+
if (!config) {
|
|
2180
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
2181
2181
|
}
|
|
2182
2182
|
let headers;
|
|
2183
2183
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -2199,10 +2199,10 @@ var deleteSwap = async (config, cid) => {
|
|
|
2199
2199
|
headers
|
|
2200
2200
|
});
|
|
2201
2201
|
if (!request.ok) {
|
|
2202
|
-
const errorData = await request.
|
|
2203
|
-
if (request.status === 401) {
|
|
2202
|
+
const errorData = await request.text();
|
|
2203
|
+
if (request.status === 401 || request.status === 403) {
|
|
2204
2204
|
throw new AuthenticationError(
|
|
2205
|
-
|
|
2205
|
+
`Authentication failed: ${errorData}`,
|
|
2206
2206
|
request.status,
|
|
2207
2207
|
errorData
|
|
2208
2208
|
);
|
|
@@ -2222,7 +2222,7 @@ var deleteSwap = async (config, cid) => {
|
|
|
2222
2222
|
);
|
|
2223
2223
|
}
|
|
2224
2224
|
throw new NetworkError(
|
|
2225
|
-
`HTTP error
|
|
2225
|
+
`HTTP error: ${errorData}`,
|
|
2226
2226
|
request.status,
|
|
2227
2227
|
errorData
|
|
2228
2228
|
);
|