pinata 2.4.6 → 2.4.8
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/chunk-BK3CLF3Z.js +163 -0
- package/dist/chunk-BK3CLF3Z.js.map +1 -0
- package/dist/chunk-ME652TQB.mjs +154 -0
- package/dist/chunk-ME652TQB.mjs.map +1 -0
- package/dist/{index-CQFQEo3K.d.mts → gateway-tools-l9hk7kz4.d.mts} +1 -18
- package/dist/{index-CQFQEo3K.d.ts → gateway-tools-l9hk7kz4.d.ts} +1 -18
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +308 -300
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -5
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +21 -1
- package/dist/react/index.d.ts +21 -1
- package/dist/react/index.js +271 -11
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +269 -1
- package/dist/react/index.mjs.map +1 -1
- package/package.json +9 -3
- package/dist/chunk-7UIMBFJ5.mjs +0 -423
- package/dist/chunk-7UIMBFJ5.mjs.map +0 -1
- package/dist/chunk-P556VRQU.js +0 -433
- package/dist/chunk-P556VRQU.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBK3CLF3Z_js = require('./chunk-BK3CLF3Z.js');
|
|
4
4
|
|
|
5
5
|
// src/core/functions/analytics/analyticsDateInterval.ts
|
|
6
6
|
var analyticsDateInterval = async (config, options) => {
|
|
7
7
|
if (!config) {
|
|
8
|
-
throw new
|
|
8
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
9
9
|
}
|
|
10
10
|
const params = new URLSearchParams();
|
|
11
11
|
if (options) {
|
|
@@ -60,7 +60,7 @@ var analyticsDateInterval = async (config, options) => {
|
|
|
60
60
|
if (!request.ok) {
|
|
61
61
|
const errorData = await request.text();
|
|
62
62
|
if (request.status === 401 || request.status === 403) {
|
|
63
|
-
throw new
|
|
63
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
64
64
|
`Authentication failed: ${errorData}`,
|
|
65
65
|
request.status,
|
|
66
66
|
{
|
|
@@ -72,7 +72,7 @@ var analyticsDateInterval = async (config, options) => {
|
|
|
72
72
|
}
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
throw new
|
|
75
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
76
76
|
error: errorData,
|
|
77
77
|
code: "HTTP_ERROR",
|
|
78
78
|
metadata: {
|
|
@@ -84,15 +84,15 @@ var analyticsDateInterval = async (config, options) => {
|
|
|
84
84
|
const resData = res.data;
|
|
85
85
|
return resData;
|
|
86
86
|
} catch (error) {
|
|
87
|
-
if (error instanceof
|
|
87
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
88
88
|
throw error;
|
|
89
89
|
}
|
|
90
90
|
if (error instanceof Error) {
|
|
91
|
-
throw new
|
|
91
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
92
92
|
`Error processing anaytics usage: ${error.message}`
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
|
-
throw new
|
|
95
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
96
96
|
"An unknown error occurred while fetching gateway usage"
|
|
97
97
|
);
|
|
98
98
|
}
|
|
@@ -101,7 +101,7 @@ var analyticsDateInterval = async (config, options) => {
|
|
|
101
101
|
// src/core/functions/analytics/analyticsTopUsage.ts
|
|
102
102
|
var analyticsTopUsage = async (config, options) => {
|
|
103
103
|
if (!config) {
|
|
104
|
-
throw new
|
|
104
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
105
105
|
}
|
|
106
106
|
const params = new URLSearchParams();
|
|
107
107
|
if (options) {
|
|
@@ -162,7 +162,7 @@ var analyticsTopUsage = async (config, options) => {
|
|
|
162
162
|
if (!request.ok) {
|
|
163
163
|
const errorData = await request.text();
|
|
164
164
|
if (request.status === 401 || request.status === 403) {
|
|
165
|
-
throw new
|
|
165
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
166
166
|
`Authentication failed: ${errorData}`,
|
|
167
167
|
request.status,
|
|
168
168
|
{
|
|
@@ -174,7 +174,7 @@ var analyticsTopUsage = async (config, options) => {
|
|
|
174
174
|
}
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
|
-
throw new
|
|
177
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
178
178
|
error: errorData,
|
|
179
179
|
code: "HTTP_ERROR",
|
|
180
180
|
metadata: {
|
|
@@ -185,15 +185,15 @@ var analyticsTopUsage = async (config, options) => {
|
|
|
185
185
|
const res = await request.json();
|
|
186
186
|
return res;
|
|
187
187
|
} catch (error) {
|
|
188
|
-
if (error instanceof
|
|
188
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
189
189
|
throw error;
|
|
190
190
|
}
|
|
191
191
|
if (error instanceof Error) {
|
|
192
|
-
throw new
|
|
192
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
193
193
|
`Error processing anaytics usage: ${error.message}`
|
|
194
194
|
);
|
|
195
195
|
}
|
|
196
|
-
throw new
|
|
196
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
197
197
|
"An unknown error occurred while fetching gateway usage"
|
|
198
198
|
);
|
|
199
199
|
}
|
|
@@ -202,7 +202,7 @@ var analyticsTopUsage = async (config, options) => {
|
|
|
202
202
|
// src/core/functions/authentication/testAuthentication.ts
|
|
203
203
|
var testAuthentication = async (config) => {
|
|
204
204
|
if (!config) {
|
|
205
|
-
throw new
|
|
205
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
206
206
|
}
|
|
207
207
|
let headers;
|
|
208
208
|
let endpoint = "https://api.pinata.cloud";
|
|
@@ -228,7 +228,7 @@ var testAuthentication = async (config) => {
|
|
|
228
228
|
if (!request.ok) {
|
|
229
229
|
const errorData = await request.text();
|
|
230
230
|
if (request.status === 401 || request.status === 403) {
|
|
231
|
-
throw new
|
|
231
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
232
232
|
`Authentication failed: ${errorData}`,
|
|
233
233
|
request.status,
|
|
234
234
|
{
|
|
@@ -240,7 +240,7 @@ var testAuthentication = async (config) => {
|
|
|
240
240
|
}
|
|
241
241
|
);
|
|
242
242
|
}
|
|
243
|
-
throw new
|
|
243
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
244
244
|
error: errorData,
|
|
245
245
|
code: "HTTP_ERROR",
|
|
246
246
|
metadata: {
|
|
@@ -251,15 +251,15 @@ var testAuthentication = async (config) => {
|
|
|
251
251
|
const res = await request.json();
|
|
252
252
|
return res;
|
|
253
253
|
} catch (error) {
|
|
254
|
-
if (error instanceof
|
|
254
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
255
255
|
throw error;
|
|
256
256
|
}
|
|
257
257
|
if (error instanceof Error) {
|
|
258
|
-
throw new
|
|
258
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
259
259
|
`Error processing authentication: ${error.message}`
|
|
260
260
|
);
|
|
261
261
|
}
|
|
262
|
-
throw new
|
|
262
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
263
263
|
"An unknown error occurred while testing authentication"
|
|
264
264
|
);
|
|
265
265
|
}
|
|
@@ -273,7 +273,7 @@ var wait = (milliseconds) => {
|
|
|
273
273
|
};
|
|
274
274
|
var deleteFile = async (config, files, privacy) => {
|
|
275
275
|
if (!config) {
|
|
276
|
-
throw new
|
|
276
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
277
277
|
}
|
|
278
278
|
const responses = [];
|
|
279
279
|
let headers;
|
|
@@ -302,7 +302,7 @@ var deleteFile = async (config, files, privacy) => {
|
|
|
302
302
|
if (!response.ok) {
|
|
303
303
|
const errorData = await response.text();
|
|
304
304
|
if (response.status === 401) {
|
|
305
|
-
throw new
|
|
305
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
306
306
|
`Authentication failed: ${errorData}`,
|
|
307
307
|
response.status,
|
|
308
308
|
{
|
|
@@ -314,7 +314,7 @@ var deleteFile = async (config, files, privacy) => {
|
|
|
314
314
|
}
|
|
315
315
|
);
|
|
316
316
|
}
|
|
317
|
-
throw new
|
|
317
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error`, response.status, {
|
|
318
318
|
error: errorData,
|
|
319
319
|
code: "HTTP_ERROR",
|
|
320
320
|
metadata: {
|
|
@@ -328,7 +328,7 @@ var deleteFile = async (config, files, privacy) => {
|
|
|
328
328
|
});
|
|
329
329
|
} catch (error) {
|
|
330
330
|
let errorMessage;
|
|
331
|
-
if (error instanceof
|
|
331
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
332
332
|
errorMessage = error.message;
|
|
333
333
|
} else if (error instanceof Error) {
|
|
334
334
|
errorMessage = `Error deleting file ${id}: ${error.message}`;
|
|
@@ -347,7 +347,7 @@ var deleteFile = async (config, files, privacy) => {
|
|
|
347
347
|
// src/core/functions/files/deleteFileVectors.ts
|
|
348
348
|
var deleteFileVectors = async (config, fileId) => {
|
|
349
349
|
if (!config) {
|
|
350
|
-
throw new
|
|
350
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
351
351
|
}
|
|
352
352
|
let headers;
|
|
353
353
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -373,7 +373,7 @@ var deleteFileVectors = async (config, fileId) => {
|
|
|
373
373
|
if (!request.ok) {
|
|
374
374
|
const errorData = await request.text();
|
|
375
375
|
if (request.status === 401 || request.status === 403) {
|
|
376
|
-
throw new
|
|
376
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
377
377
|
`Authentication failed: ${errorData}`,
|
|
378
378
|
request.status,
|
|
379
379
|
{
|
|
@@ -385,7 +385,7 @@ var deleteFileVectors = async (config, fileId) => {
|
|
|
385
385
|
}
|
|
386
386
|
);
|
|
387
387
|
}
|
|
388
|
-
throw new
|
|
388
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
389
389
|
error: errorData,
|
|
390
390
|
code: "HTTP_ERROR",
|
|
391
391
|
metadata: {
|
|
@@ -396,22 +396,22 @@ var deleteFileVectors = async (config, fileId) => {
|
|
|
396
396
|
const res = await request.json();
|
|
397
397
|
return res;
|
|
398
398
|
} catch (error) {
|
|
399
|
-
if (error instanceof
|
|
399
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
400
400
|
throw error;
|
|
401
401
|
}
|
|
402
402
|
if (error instanceof Error) {
|
|
403
|
-
throw new
|
|
403
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
404
404
|
`Error processing vectorize file: ${error.message}`
|
|
405
405
|
);
|
|
406
406
|
}
|
|
407
|
-
throw new
|
|
407
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while vectorizing file");
|
|
408
408
|
}
|
|
409
409
|
};
|
|
410
410
|
|
|
411
411
|
// src/core/functions/files/deleteSwap.ts
|
|
412
412
|
var deleteSwap = async (config, cid, network) => {
|
|
413
413
|
if (!config) {
|
|
414
|
-
throw new
|
|
414
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
415
415
|
}
|
|
416
416
|
let headers;
|
|
417
417
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -439,13 +439,13 @@ var deleteSwap = async (config, cid, network) => {
|
|
|
439
439
|
if (!request.ok) {
|
|
440
440
|
const errorData = await request.text();
|
|
441
441
|
if (request.status === 401 || request.status === 403) {
|
|
442
|
-
throw new
|
|
442
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(`Authentication failed`, request.status, {
|
|
443
443
|
error: errorData,
|
|
444
444
|
code: "AUTH_ERROR"
|
|
445
445
|
});
|
|
446
446
|
}
|
|
447
447
|
if (request.status === 403) {
|
|
448
|
-
throw new
|
|
448
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
449
449
|
"Unauthorized CID Swap Deletion",
|
|
450
450
|
request.status,
|
|
451
451
|
{
|
|
@@ -455,23 +455,23 @@ var deleteSwap = async (config, cid, network) => {
|
|
|
455
455
|
);
|
|
456
456
|
}
|
|
457
457
|
if (request.status === 404) {
|
|
458
|
-
throw new
|
|
458
|
+
throw new chunkBK3CLF3Z_js.PinataError("CID not pinned to account", request.status, {
|
|
459
459
|
error: errorData,
|
|
460
460
|
code: "NOT_FOUND"
|
|
461
461
|
});
|
|
462
462
|
}
|
|
463
|
-
throw new
|
|
463
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error occurred`, request.status, {
|
|
464
464
|
error: errorData,
|
|
465
465
|
code: "NETWORK_ERROR"
|
|
466
466
|
});
|
|
467
467
|
}
|
|
468
468
|
return request.statusText;
|
|
469
469
|
} catch (error) {
|
|
470
|
-
if (error instanceof
|
|
470
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
471
471
|
throw error;
|
|
472
472
|
}
|
|
473
473
|
if (error instanceof Error) {
|
|
474
|
-
throw new
|
|
474
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
475
475
|
`Error processing deleteSwap: ${error.message}`,
|
|
476
476
|
void 0,
|
|
477
477
|
{
|
|
@@ -479,7 +479,7 @@ var deleteSwap = async (config, cid, network) => {
|
|
|
479
479
|
}
|
|
480
480
|
);
|
|
481
481
|
}
|
|
482
|
-
throw new
|
|
482
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
483
483
|
"An unknown error occurred while deleting swap",
|
|
484
484
|
void 0,
|
|
485
485
|
{
|
|
@@ -492,7 +492,7 @@ var deleteSwap = async (config, cid, network) => {
|
|
|
492
492
|
// src/core/functions/files/list.ts
|
|
493
493
|
var listFiles = async (config, privacy, options) => {
|
|
494
494
|
if (!config) {
|
|
495
|
-
throw new
|
|
495
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
496
496
|
}
|
|
497
497
|
const params = new URLSearchParams();
|
|
498
498
|
if (options) {
|
|
@@ -548,7 +548,7 @@ var listFiles = async (config, privacy, options) => {
|
|
|
548
548
|
if (!request.ok) {
|
|
549
549
|
const errorData = await request.text();
|
|
550
550
|
if (request.status === 401 || request.status === 403) {
|
|
551
|
-
throw new
|
|
551
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
552
552
|
`Authentication failed: ${errorData}`,
|
|
553
553
|
request.status,
|
|
554
554
|
{
|
|
@@ -560,7 +560,7 @@ var listFiles = async (config, privacy, options) => {
|
|
|
560
560
|
}
|
|
561
561
|
);
|
|
562
562
|
}
|
|
563
|
-
throw new
|
|
563
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
564
564
|
error: errorData,
|
|
565
565
|
code: "HTTP_ERROR",
|
|
566
566
|
metadata: {
|
|
@@ -572,20 +572,20 @@ var listFiles = async (config, privacy, options) => {
|
|
|
572
572
|
const resData = res.data;
|
|
573
573
|
return resData;
|
|
574
574
|
} catch (error) {
|
|
575
|
-
if (error instanceof
|
|
575
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
576
576
|
throw error;
|
|
577
577
|
}
|
|
578
578
|
if (error instanceof Error) {
|
|
579
|
-
throw new
|
|
579
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing list files: ${error.message}`);
|
|
580
580
|
}
|
|
581
|
-
throw new
|
|
581
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while listing files");
|
|
582
582
|
}
|
|
583
583
|
};
|
|
584
584
|
|
|
585
585
|
// src/core/functions/files/pinnedFileUsage.ts
|
|
586
586
|
var pinnedFileCount = async (config) => {
|
|
587
587
|
if (!config) {
|
|
588
|
-
throw new
|
|
588
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
589
589
|
}
|
|
590
590
|
let endpoint = "https://api.pinata.cloud";
|
|
591
591
|
if (config.endpointUrl) {
|
|
@@ -611,7 +611,7 @@ var pinnedFileCount = async (config) => {
|
|
|
611
611
|
if (!request.ok) {
|
|
612
612
|
const errorData = await request.text();
|
|
613
613
|
if (request.status === 401 || request.status === 403) {
|
|
614
|
-
throw new
|
|
614
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
615
615
|
`Authentication failed: ${errorData}`,
|
|
616
616
|
request.status,
|
|
617
617
|
{
|
|
@@ -623,7 +623,7 @@ var pinnedFileCount = async (config) => {
|
|
|
623
623
|
}
|
|
624
624
|
);
|
|
625
625
|
}
|
|
626
|
-
throw new
|
|
626
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
627
627
|
error: errorData,
|
|
628
628
|
code: "HTTP_ERROR",
|
|
629
629
|
metadata: {
|
|
@@ -634,15 +634,15 @@ var pinnedFileCount = async (config) => {
|
|
|
634
634
|
const res = await request.json();
|
|
635
635
|
return res.pin_count;
|
|
636
636
|
} catch (error) {
|
|
637
|
-
if (error instanceof
|
|
637
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
638
638
|
throw error;
|
|
639
639
|
}
|
|
640
640
|
if (error instanceof Error) {
|
|
641
|
-
throw new
|
|
641
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
642
642
|
`Error processing pinnedFileUsage: ${error.message}`
|
|
643
643
|
);
|
|
644
644
|
}
|
|
645
|
-
throw new
|
|
645
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
646
646
|
"An unknown error occurred while getting pinned file usage"
|
|
647
647
|
);
|
|
648
648
|
}
|
|
@@ -651,7 +651,7 @@ var pinnedFileCount = async (config) => {
|
|
|
651
651
|
// src/core/functions/files/swapCid.ts
|
|
652
652
|
var swapCid = async (config, options, network) => {
|
|
653
653
|
if (!config) {
|
|
654
|
-
throw new
|
|
654
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
655
655
|
}
|
|
656
656
|
const data = JSON.stringify({
|
|
657
657
|
swap_cid: options.swapCid
|
|
@@ -686,7 +686,7 @@ var swapCid = async (config, options, network) => {
|
|
|
686
686
|
if (!request.ok) {
|
|
687
687
|
const errorData = await request.text();
|
|
688
688
|
if (request.status === 401 || request.status === 403) {
|
|
689
|
-
throw new
|
|
689
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
690
690
|
`Authentication failed: ${errorData}`,
|
|
691
691
|
request.status,
|
|
692
692
|
{
|
|
@@ -699,7 +699,7 @@ var swapCid = async (config, options, network) => {
|
|
|
699
699
|
);
|
|
700
700
|
}
|
|
701
701
|
if (request.status === 403) {
|
|
702
|
-
throw new
|
|
702
|
+
throw new chunkBK3CLF3Z_js.PinataError("Unauthorized CID Swap", request.status, {
|
|
703
703
|
error: errorData,
|
|
704
704
|
code: "AUTH_ERROR",
|
|
705
705
|
metadata: {
|
|
@@ -708,7 +708,7 @@ var swapCid = async (config, options, network) => {
|
|
|
708
708
|
});
|
|
709
709
|
}
|
|
710
710
|
if (request.status === 404) {
|
|
711
|
-
throw new
|
|
711
|
+
throw new chunkBK3CLF3Z_js.PinataError("CID not pinned to account", request.status, {
|
|
712
712
|
error: errorData,
|
|
713
713
|
code: "HTTP_ERROR",
|
|
714
714
|
metadata: {
|
|
@@ -716,7 +716,7 @@ var swapCid = async (config, options, network) => {
|
|
|
716
716
|
}
|
|
717
717
|
});
|
|
718
718
|
}
|
|
719
|
-
throw new
|
|
719
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
720
720
|
error: errorData,
|
|
721
721
|
code: "HTTP_ERROR",
|
|
722
722
|
metadata: {
|
|
@@ -728,20 +728,20 @@ var swapCid = async (config, options, network) => {
|
|
|
728
728
|
const resData = res.data;
|
|
729
729
|
return resData;
|
|
730
730
|
} catch (error) {
|
|
731
|
-
if (error instanceof
|
|
731
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
732
732
|
throw error;
|
|
733
733
|
}
|
|
734
734
|
if (error instanceof Error) {
|
|
735
|
-
throw new
|
|
735
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing CID Swap: ${error.message}`);
|
|
736
736
|
}
|
|
737
|
-
throw new
|
|
737
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while swapping CID");
|
|
738
738
|
}
|
|
739
739
|
};
|
|
740
740
|
|
|
741
741
|
// src/core/functions/files/swapHistory.ts
|
|
742
742
|
var swapHistory = async (config, options, network) => {
|
|
743
743
|
if (!config) {
|
|
744
|
-
throw new
|
|
744
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
745
745
|
}
|
|
746
746
|
let headers;
|
|
747
747
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -772,7 +772,7 @@ var swapHistory = async (config, options, network) => {
|
|
|
772
772
|
if (!request.ok) {
|
|
773
773
|
const errorData = await request.text();
|
|
774
774
|
if (request.status === 401 || request.status === 403) {
|
|
775
|
-
throw new
|
|
775
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
776
776
|
`Authentication failed: ${errorData}`,
|
|
777
777
|
request.status,
|
|
778
778
|
{
|
|
@@ -785,7 +785,7 @@ var swapHistory = async (config, options, network) => {
|
|
|
785
785
|
);
|
|
786
786
|
}
|
|
787
787
|
if (request.status === 404) {
|
|
788
|
-
throw new
|
|
788
|
+
throw new chunkBK3CLF3Z_js.PinataError("CID does not have history", request.status, {
|
|
789
789
|
error: errorData,
|
|
790
790
|
code: "HTTP_ERROR",
|
|
791
791
|
metadata: {
|
|
@@ -793,7 +793,7 @@ var swapHistory = async (config, options, network) => {
|
|
|
793
793
|
}
|
|
794
794
|
});
|
|
795
795
|
}
|
|
796
|
-
throw new
|
|
796
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
797
797
|
error: errorData,
|
|
798
798
|
code: "HTTP_ERROR",
|
|
799
799
|
metadata: {
|
|
@@ -805,13 +805,13 @@ var swapHistory = async (config, options, network) => {
|
|
|
805
805
|
const resData = res.data;
|
|
806
806
|
return resData;
|
|
807
807
|
} catch (error) {
|
|
808
|
-
if (error instanceof
|
|
808
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
809
809
|
throw error;
|
|
810
810
|
}
|
|
811
811
|
if (error instanceof Error) {
|
|
812
|
-
throw new
|
|
812
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error fetching swap history: ${error.message}`);
|
|
813
813
|
}
|
|
814
|
-
throw new
|
|
814
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
815
815
|
"An unknown error occurred while fetching swap history"
|
|
816
816
|
);
|
|
817
817
|
}
|
|
@@ -820,7 +820,7 @@ var swapHistory = async (config, options, network) => {
|
|
|
820
820
|
// src/core/functions/files/totalStorageUsage.ts
|
|
821
821
|
var totalStorageUsage = async (config) => {
|
|
822
822
|
if (!config) {
|
|
823
|
-
throw new
|
|
823
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
824
824
|
}
|
|
825
825
|
let endpoint = "https://api.pinata.cloud";
|
|
826
826
|
if (config.endpointUrl) {
|
|
@@ -843,7 +843,7 @@ var totalStorageUsage = async (config) => {
|
|
|
843
843
|
if (!request.ok) {
|
|
844
844
|
const errorData = await request.text();
|
|
845
845
|
if (request.status === 401 || request.status === 403) {
|
|
846
|
-
throw new
|
|
846
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
847
847
|
`Authentication failed: ${errorData}`,
|
|
848
848
|
request.status,
|
|
849
849
|
{
|
|
@@ -855,7 +855,7 @@ var totalStorageUsage = async (config) => {
|
|
|
855
855
|
}
|
|
856
856
|
);
|
|
857
857
|
}
|
|
858
|
-
throw new
|
|
858
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
859
859
|
error: errorData,
|
|
860
860
|
code: "HTTP_ERROR",
|
|
861
861
|
metadata: {
|
|
@@ -866,15 +866,15 @@ var totalStorageUsage = async (config) => {
|
|
|
866
866
|
const res = await request.json();
|
|
867
867
|
return res.pin_size_total;
|
|
868
868
|
} catch (error) {
|
|
869
|
-
if (error instanceof
|
|
869
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
870
870
|
throw error;
|
|
871
871
|
}
|
|
872
872
|
if (error instanceof Error) {
|
|
873
|
-
throw new
|
|
873
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
874
874
|
`Error processing totalStorageUsage: ${error.message}`
|
|
875
875
|
);
|
|
876
876
|
}
|
|
877
|
-
throw new
|
|
877
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
878
878
|
"An unknown error occurred while getting total storage usage"
|
|
879
879
|
);
|
|
880
880
|
}
|
|
@@ -883,10 +883,10 @@ var totalStorageUsage = async (config) => {
|
|
|
883
883
|
// src/core/functions/files/updateFile.ts
|
|
884
884
|
var updateFile = async (config, options, privacy) => {
|
|
885
885
|
if (!config) {
|
|
886
|
-
throw new
|
|
886
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
887
887
|
}
|
|
888
888
|
if (!options.name && (!options.keyvalues || Object.keys(options.keyvalues).length === 0)) {
|
|
889
|
-
throw new
|
|
889
|
+
throw new chunkBK3CLF3Z_js.ValidationError(
|
|
890
890
|
"At least one of 'name' or 'keyvalues' must be provided"
|
|
891
891
|
);
|
|
892
892
|
}
|
|
@@ -925,7 +925,7 @@ var updateFile = async (config, options, privacy) => {
|
|
|
925
925
|
if (!request.ok) {
|
|
926
926
|
const errorData = await request.text();
|
|
927
927
|
if (request.status === 401 || request.status === 403) {
|
|
928
|
-
throw new
|
|
928
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
929
929
|
`Authentication failed: ${errorData}`,
|
|
930
930
|
request.status,
|
|
931
931
|
{
|
|
@@ -937,7 +937,7 @@ var updateFile = async (config, options, privacy) => {
|
|
|
937
937
|
}
|
|
938
938
|
);
|
|
939
939
|
}
|
|
940
|
-
throw new
|
|
940
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
941
941
|
error: errorData,
|
|
942
942
|
code: "HTTP_ERROR",
|
|
943
943
|
metadata: {
|
|
@@ -949,20 +949,20 @@ var updateFile = async (config, options, privacy) => {
|
|
|
949
949
|
const resData = res.data;
|
|
950
950
|
return resData;
|
|
951
951
|
} catch (error) {
|
|
952
|
-
if (error instanceof
|
|
952
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
953
953
|
throw error;
|
|
954
954
|
}
|
|
955
955
|
if (error instanceof Error) {
|
|
956
|
-
throw new
|
|
956
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing updateFile: ${error.message}`);
|
|
957
957
|
}
|
|
958
|
-
throw new
|
|
958
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while updating file");
|
|
959
959
|
}
|
|
960
960
|
};
|
|
961
961
|
|
|
962
962
|
// src/core/functions/files/vectorizeFile.ts
|
|
963
963
|
var vectorizeFile = async (config, fileId) => {
|
|
964
964
|
if (!config) {
|
|
965
|
-
throw new
|
|
965
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
966
966
|
}
|
|
967
967
|
let headers;
|
|
968
968
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -988,7 +988,7 @@ var vectorizeFile = async (config, fileId) => {
|
|
|
988
988
|
if (!request.ok) {
|
|
989
989
|
const errorData = await request.text();
|
|
990
990
|
if (request.status === 401 || request.status === 403) {
|
|
991
|
-
throw new
|
|
991
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
992
992
|
`Authentication failed: ${errorData}`,
|
|
993
993
|
request.status,
|
|
994
994
|
{
|
|
@@ -1000,7 +1000,7 @@ var vectorizeFile = async (config, fileId) => {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
);
|
|
1002
1002
|
}
|
|
1003
|
-
throw new
|
|
1003
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
1004
1004
|
error: errorData,
|
|
1005
1005
|
code: "HTTP_ERROR",
|
|
1006
1006
|
metadata: {
|
|
@@ -1011,22 +1011,22 @@ var vectorizeFile = async (config, fileId) => {
|
|
|
1011
1011
|
const res = await request.json();
|
|
1012
1012
|
return res;
|
|
1013
1013
|
} catch (error) {
|
|
1014
|
-
if (error instanceof
|
|
1014
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1015
1015
|
throw error;
|
|
1016
1016
|
}
|
|
1017
1017
|
if (error instanceof Error) {
|
|
1018
|
-
throw new
|
|
1018
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
1019
1019
|
`Error processing vectorize file: ${error.message}`
|
|
1020
1020
|
);
|
|
1021
1021
|
}
|
|
1022
|
-
throw new
|
|
1022
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while vectorizing file");
|
|
1023
1023
|
}
|
|
1024
1024
|
};
|
|
1025
1025
|
|
|
1026
1026
|
// src/core/functions/files/vectorizeQuery.ts
|
|
1027
1027
|
var vectorizeQuery = async (config, options) => {
|
|
1028
1028
|
if (!config) {
|
|
1029
|
-
throw new
|
|
1029
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1030
1030
|
}
|
|
1031
1031
|
let headers;
|
|
1032
1032
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1059,7 +1059,7 @@ var vectorizeQuery = async (config, options) => {
|
|
|
1059
1059
|
if (!request.ok) {
|
|
1060
1060
|
const errorData = await request.text();
|
|
1061
1061
|
if (request.status === 401 || request.status === 403) {
|
|
1062
|
-
throw new
|
|
1062
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1063
1063
|
`Authentication failed: ${errorData}`,
|
|
1064
1064
|
request.status,
|
|
1065
1065
|
{
|
|
@@ -1071,7 +1071,7 @@ var vectorizeQuery = async (config, options) => {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
);
|
|
1073
1073
|
}
|
|
1074
|
-
throw new
|
|
1074
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
1075
1075
|
error: errorData,
|
|
1076
1076
|
code: "HTTP_ERROR",
|
|
1077
1077
|
metadata: {
|
|
@@ -1083,7 +1083,7 @@ var vectorizeQuery = async (config, options) => {
|
|
|
1083
1083
|
const resData = res.data;
|
|
1084
1084
|
if (options.returnFile) {
|
|
1085
1085
|
if (resData.matches.length === 0) {
|
|
1086
|
-
throw new
|
|
1086
|
+
throw new chunkBK3CLF3Z_js.PinataError(`No files returned in query to fetch`);
|
|
1087
1087
|
}
|
|
1088
1088
|
const cid = resData.matches[0].cid;
|
|
1089
1089
|
const fileRes = await getCid(config, cid, "files");
|
|
@@ -1091,22 +1091,22 @@ var vectorizeQuery = async (config, options) => {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
return resData;
|
|
1093
1093
|
} catch (error) {
|
|
1094
|
-
if (error instanceof
|
|
1094
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1095
1095
|
throw error;
|
|
1096
1096
|
}
|
|
1097
1097
|
if (error instanceof Error) {
|
|
1098
|
-
throw new
|
|
1098
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
1099
1099
|
`Error processing vectorize file: ${error.message}`
|
|
1100
1100
|
);
|
|
1101
1101
|
}
|
|
1102
|
-
throw new
|
|
1102
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while vectorizing file");
|
|
1103
1103
|
}
|
|
1104
1104
|
};
|
|
1105
1105
|
|
|
1106
1106
|
// src/core/functions/files/queue.ts
|
|
1107
1107
|
var queue = async (config, options) => {
|
|
1108
1108
|
if (!config) {
|
|
1109
|
-
throw new
|
|
1109
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1110
1110
|
}
|
|
1111
1111
|
const params = new URLSearchParams({
|
|
1112
1112
|
includesCount: "false"
|
|
@@ -1144,7 +1144,7 @@ var queue = async (config, options) => {
|
|
|
1144
1144
|
if (!request.ok) {
|
|
1145
1145
|
const errorData = await request.text();
|
|
1146
1146
|
if (request.status === 401 || request.status === 403) {
|
|
1147
|
-
throw new
|
|
1147
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1148
1148
|
`Authentication failed: ${errorData}`,
|
|
1149
1149
|
request.status,
|
|
1150
1150
|
{
|
|
@@ -1156,7 +1156,7 @@ var queue = async (config, options) => {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
);
|
|
1158
1158
|
}
|
|
1159
|
-
throw new
|
|
1159
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
1160
1160
|
error: errorData,
|
|
1161
1161
|
code: "HTTP_ERROR",
|
|
1162
1162
|
metadata: {
|
|
@@ -1168,20 +1168,20 @@ var queue = async (config, options) => {
|
|
|
1168
1168
|
const resData = res.data;
|
|
1169
1169
|
return resData;
|
|
1170
1170
|
} catch (error) {
|
|
1171
|
-
if (error instanceof
|
|
1171
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1172
1172
|
throw error;
|
|
1173
1173
|
}
|
|
1174
1174
|
if (error instanceof Error) {
|
|
1175
|
-
throw new
|
|
1175
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing pinJobs: ${error.message}`);
|
|
1176
1176
|
}
|
|
1177
|
-
throw new
|
|
1177
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while listing pin jobs");
|
|
1178
1178
|
}
|
|
1179
1179
|
};
|
|
1180
1180
|
|
|
1181
1181
|
// src/core/functions/files/deletePinRequest.ts
|
|
1182
1182
|
var deletePinRequest = async (config, id) => {
|
|
1183
1183
|
if (!config) {
|
|
1184
|
-
throw new
|
|
1184
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1185
1185
|
}
|
|
1186
1186
|
let headers;
|
|
1187
1187
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1207,7 +1207,7 @@ var deletePinRequest = async (config, id) => {
|
|
|
1207
1207
|
if (!response.ok) {
|
|
1208
1208
|
const errorData = await response.text();
|
|
1209
1209
|
if (response.status === 401) {
|
|
1210
|
-
throw new
|
|
1210
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1211
1211
|
`Authentication failed: ${errorData}`,
|
|
1212
1212
|
response.status,
|
|
1213
1213
|
{
|
|
@@ -1219,7 +1219,7 @@ var deletePinRequest = async (config, id) => {
|
|
|
1219
1219
|
}
|
|
1220
1220
|
);
|
|
1221
1221
|
}
|
|
1222
|
-
throw new
|
|
1222
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error`, response.status, {
|
|
1223
1223
|
error: errorData,
|
|
1224
1224
|
code: "HTTP_ERROR",
|
|
1225
1225
|
metadata: {
|
|
@@ -1229,13 +1229,13 @@ var deletePinRequest = async (config, id) => {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
return "OK";
|
|
1231
1231
|
} catch (error) {
|
|
1232
|
-
if (error instanceof
|
|
1232
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1233
1233
|
throw error;
|
|
1234
1234
|
}
|
|
1235
1235
|
if (error instanceof Error) {
|
|
1236
|
-
throw new
|
|
1236
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error deleting pin by request: ${error.message}`);
|
|
1237
1237
|
}
|
|
1238
|
-
throw new
|
|
1238
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
1239
1239
|
"An unknown error occurred while deleting pin by CID request"
|
|
1240
1240
|
);
|
|
1241
1241
|
}
|
|
@@ -1244,7 +1244,7 @@ var deletePinRequest = async (config, id) => {
|
|
|
1244
1244
|
// src/core/functions/gateway/getCid.ts
|
|
1245
1245
|
var getCid = async (config, cid, gatewayType, options) => {
|
|
1246
1246
|
if (!config) {
|
|
1247
|
-
throw new
|
|
1247
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1248
1248
|
}
|
|
1249
1249
|
let data;
|
|
1250
1250
|
let newUrl = `${config?.pinataGateway}/${gatewayType}/${cid}`;
|
|
@@ -1277,7 +1277,7 @@ var getCid = async (config, cid, gatewayType, options) => {
|
|
|
1277
1277
|
if (!request.ok) {
|
|
1278
1278
|
const errorData = await request.text();
|
|
1279
1279
|
if (request.status === 401 || request.status === 403) {
|
|
1280
|
-
throw new
|
|
1280
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1281
1281
|
`Authentication Failed: ${errorData}`,
|
|
1282
1282
|
request.status,
|
|
1283
1283
|
{
|
|
@@ -1289,7 +1289,7 @@ var getCid = async (config, cid, gatewayType, options) => {
|
|
|
1289
1289
|
}
|
|
1290
1290
|
);
|
|
1291
1291
|
}
|
|
1292
|
-
throw new
|
|
1292
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
1293
1293
|
error: errorData,
|
|
1294
1294
|
code: "HTTP_ERROR",
|
|
1295
1295
|
metadata: {
|
|
@@ -1347,7 +1347,7 @@ var getCid = async (config, cid, gatewayType, options) => {
|
|
|
1347
1347
|
if (!request.ok) {
|
|
1348
1348
|
const errorData = await request.text();
|
|
1349
1349
|
if (request.status === 401 || request.status === 403) {
|
|
1350
|
-
throw new
|
|
1350
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1351
1351
|
`Authentication Failed: ${errorData}`,
|
|
1352
1352
|
request.status,
|
|
1353
1353
|
{
|
|
@@ -1359,7 +1359,7 @@ var getCid = async (config, cid, gatewayType, options) => {
|
|
|
1359
1359
|
}
|
|
1360
1360
|
);
|
|
1361
1361
|
}
|
|
1362
|
-
throw new
|
|
1362
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
1363
1363
|
error: errorData,
|
|
1364
1364
|
code: "HTTP_ERROR",
|
|
1365
1365
|
metadata: {
|
|
@@ -1381,13 +1381,13 @@ var getCid = async (config, cid, gatewayType, options) => {
|
|
|
1381
1381
|
};
|
|
1382
1382
|
return res;
|
|
1383
1383
|
} catch (error) {
|
|
1384
|
-
if (error instanceof
|
|
1384
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1385
1385
|
throw error;
|
|
1386
1386
|
}
|
|
1387
1387
|
if (error instanceof Error) {
|
|
1388
|
-
throw new
|
|
1388
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing getCid: ${error.message}`);
|
|
1389
1389
|
}
|
|
1390
|
-
throw new
|
|
1390
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
1391
1391
|
"An unknown error occurred while getting CID contents"
|
|
1392
1392
|
);
|
|
1393
1393
|
}
|
|
@@ -1397,7 +1397,7 @@ var getCid = async (config, cid, gatewayType, options) => {
|
|
|
1397
1397
|
var convertIPFSUrl = async (config, url, gatewayPrefix) => {
|
|
1398
1398
|
let newUrl;
|
|
1399
1399
|
let prefix = gatewayPrefix || config?.pinataGateway || "https://gateway.pinata.cloud";
|
|
1400
|
-
newUrl = await
|
|
1400
|
+
newUrl = await chunkBK3CLF3Z_js.convertToDesiredGateway(url, prefix);
|
|
1401
1401
|
if (config?.pinataGatewayKey) {
|
|
1402
1402
|
`${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;
|
|
1403
1403
|
}
|
|
@@ -1407,7 +1407,7 @@ var convertIPFSUrl = async (config, url, gatewayPrefix) => {
|
|
|
1407
1407
|
// src/core/functions/gateway/createAccessLink.ts
|
|
1408
1408
|
var createAccessLink = async (config, options, imgOpts) => {
|
|
1409
1409
|
if (!config) {
|
|
1410
|
-
throw new
|
|
1410
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1411
1411
|
}
|
|
1412
1412
|
let baseUrl;
|
|
1413
1413
|
if (options?.gateway) {
|
|
@@ -1471,7 +1471,7 @@ var createAccessLink = async (config, options, imgOpts) => {
|
|
|
1471
1471
|
if (!request.ok) {
|
|
1472
1472
|
const errorData = await request.text();
|
|
1473
1473
|
if (request.status === 401 || request.status === 403) {
|
|
1474
|
-
throw new
|
|
1474
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1475
1475
|
`Authentication Failed: ${errorData}`,
|
|
1476
1476
|
request.status,
|
|
1477
1477
|
{
|
|
@@ -1483,7 +1483,7 @@ var createAccessLink = async (config, options, imgOpts) => {
|
|
|
1483
1483
|
}
|
|
1484
1484
|
);
|
|
1485
1485
|
}
|
|
1486
|
-
throw new
|
|
1486
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
1487
1487
|
error: errorData,
|
|
1488
1488
|
code: "HTTP_ERROR",
|
|
1489
1489
|
metadata: {
|
|
@@ -1494,22 +1494,22 @@ var createAccessLink = async (config, options, imgOpts) => {
|
|
|
1494
1494
|
const res = await request.json();
|
|
1495
1495
|
return res.data;
|
|
1496
1496
|
} catch (error) {
|
|
1497
|
-
if (error instanceof
|
|
1497
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1498
1498
|
throw error;
|
|
1499
1499
|
}
|
|
1500
1500
|
if (error instanceof Error) {
|
|
1501
|
-
throw new
|
|
1501
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
1502
1502
|
`Error processing createSignedURL: ${error.message}`
|
|
1503
1503
|
);
|
|
1504
1504
|
}
|
|
1505
|
-
throw new
|
|
1505
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while getting signed url");
|
|
1506
1506
|
}
|
|
1507
1507
|
};
|
|
1508
1508
|
|
|
1509
1509
|
// src/core/functions/groups/addToGroup.ts
|
|
1510
1510
|
var addToGroup = async (config, options, privacy) => {
|
|
1511
1511
|
if (!config) {
|
|
1512
|
-
throw new
|
|
1512
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1513
1513
|
}
|
|
1514
1514
|
const wait3 = (milliseconds) => {
|
|
1515
1515
|
return new Promise((resolve) => {
|
|
@@ -1548,7 +1548,7 @@ var addToGroup = async (config, options, privacy) => {
|
|
|
1548
1548
|
if (!response.ok) {
|
|
1549
1549
|
const errorData = await response.text();
|
|
1550
1550
|
if (response.status === 401) {
|
|
1551
|
-
throw new
|
|
1551
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1552
1552
|
`Authentication failed: ${errorData}`,
|
|
1553
1553
|
response.status,
|
|
1554
1554
|
{
|
|
@@ -1560,7 +1560,7 @@ var addToGroup = async (config, options, privacy) => {
|
|
|
1560
1560
|
}
|
|
1561
1561
|
);
|
|
1562
1562
|
}
|
|
1563
|
-
throw new
|
|
1563
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, response.status, {
|
|
1564
1564
|
error: errorData,
|
|
1565
1565
|
code: "HTTP_ERROR",
|
|
1566
1566
|
metadata: {
|
|
@@ -1574,7 +1574,7 @@ var addToGroup = async (config, options, privacy) => {
|
|
|
1574
1574
|
});
|
|
1575
1575
|
} catch (error) {
|
|
1576
1576
|
let errorMessage;
|
|
1577
|
-
if (error instanceof
|
|
1577
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1578
1578
|
errorMessage = error.message;
|
|
1579
1579
|
} else if (error instanceof Error) {
|
|
1580
1580
|
errorMessage = `Error adding file ${id} to group: ${error.message}`;
|
|
@@ -1593,7 +1593,7 @@ var addToGroup = async (config, options, privacy) => {
|
|
|
1593
1593
|
// src/core/functions/groups/createGroup.ts
|
|
1594
1594
|
var createGroup = async (config, options, privacy) => {
|
|
1595
1595
|
if (!config) {
|
|
1596
|
-
throw new
|
|
1596
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1597
1597
|
}
|
|
1598
1598
|
const data = JSON.stringify({
|
|
1599
1599
|
name: options.name,
|
|
@@ -1626,7 +1626,7 @@ var createGroup = async (config, options, privacy) => {
|
|
|
1626
1626
|
if (!request.ok) {
|
|
1627
1627
|
const errorData = await request.text();
|
|
1628
1628
|
if (request.status === 401 || request.status === 403) {
|
|
1629
|
-
throw new
|
|
1629
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1630
1630
|
`Authentication failed: ${errorData}`,
|
|
1631
1631
|
request.status,
|
|
1632
1632
|
{
|
|
@@ -1638,7 +1638,7 @@ var createGroup = async (config, options, privacy) => {
|
|
|
1638
1638
|
}
|
|
1639
1639
|
);
|
|
1640
1640
|
}
|
|
1641
|
-
throw new
|
|
1641
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
1642
1642
|
error: errorData,
|
|
1643
1643
|
code: "HTTP_ERROR",
|
|
1644
1644
|
metadata: {
|
|
@@ -1650,20 +1650,20 @@ var createGroup = async (config, options, privacy) => {
|
|
|
1650
1650
|
const resData = res.data;
|
|
1651
1651
|
return resData;
|
|
1652
1652
|
} catch (error) {
|
|
1653
|
-
if (error instanceof
|
|
1653
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1654
1654
|
throw error;
|
|
1655
1655
|
}
|
|
1656
1656
|
if (error instanceof Error) {
|
|
1657
|
-
throw new
|
|
1657
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing createGroup: ${error.message}`);
|
|
1658
1658
|
}
|
|
1659
|
-
throw new
|
|
1659
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while creating a group");
|
|
1660
1660
|
}
|
|
1661
1661
|
};
|
|
1662
1662
|
|
|
1663
1663
|
// src/core/functions/groups/deleteGroup.ts
|
|
1664
1664
|
var deleteGroup = async (config, options, privacy) => {
|
|
1665
1665
|
if (!config) {
|
|
1666
|
-
throw new
|
|
1666
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1667
1667
|
}
|
|
1668
1668
|
let headers;
|
|
1669
1669
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1694,7 +1694,7 @@ var deleteGroup = async (config, options, privacy) => {
|
|
|
1694
1694
|
if (!request.ok) {
|
|
1695
1695
|
const errorData = await request.text();
|
|
1696
1696
|
if (request.status === 401 || request.status === 403) {
|
|
1697
|
-
throw new
|
|
1697
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1698
1698
|
`Authentication failed: ${errorData}`,
|
|
1699
1699
|
request.status,
|
|
1700
1700
|
{
|
|
@@ -1706,7 +1706,7 @@ var deleteGroup = async (config, options, privacy) => {
|
|
|
1706
1706
|
}
|
|
1707
1707
|
);
|
|
1708
1708
|
}
|
|
1709
|
-
throw new
|
|
1709
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
1710
1710
|
error: errorData,
|
|
1711
1711
|
code: "HTTP_ERROR",
|
|
1712
1712
|
metadata: {
|
|
@@ -1717,20 +1717,20 @@ var deleteGroup = async (config, options, privacy) => {
|
|
|
1717
1717
|
const res = request.statusText;
|
|
1718
1718
|
return res;
|
|
1719
1719
|
} catch (error) {
|
|
1720
|
-
if (error instanceof
|
|
1720
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1721
1721
|
throw error;
|
|
1722
1722
|
}
|
|
1723
1723
|
if (error instanceof Error) {
|
|
1724
|
-
throw new
|
|
1724
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing deleteGroup: ${error.message}`);
|
|
1725
1725
|
}
|
|
1726
|
-
throw new
|
|
1726
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while deleting a group");
|
|
1727
1727
|
}
|
|
1728
1728
|
};
|
|
1729
1729
|
|
|
1730
1730
|
// src/core/functions/groups/getGroup.ts
|
|
1731
1731
|
var getGroup = async (config, options, privacy) => {
|
|
1732
1732
|
if (!config) {
|
|
1733
|
-
throw new
|
|
1733
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1734
1734
|
}
|
|
1735
1735
|
let headers;
|
|
1736
1736
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1761,7 +1761,7 @@ var getGroup = async (config, options, privacy) => {
|
|
|
1761
1761
|
if (!request.ok) {
|
|
1762
1762
|
const errorData = await request.text();
|
|
1763
1763
|
if (request.status === 401 || request.status === 403) {
|
|
1764
|
-
throw new
|
|
1764
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1765
1765
|
`Authentication failed: ${errorData}`,
|
|
1766
1766
|
request.status,
|
|
1767
1767
|
{
|
|
@@ -1773,7 +1773,7 @@ var getGroup = async (config, options, privacy) => {
|
|
|
1773
1773
|
}
|
|
1774
1774
|
);
|
|
1775
1775
|
}
|
|
1776
|
-
throw new
|
|
1776
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
1777
1777
|
error: errorData,
|
|
1778
1778
|
code: "HTTP_ERROR",
|
|
1779
1779
|
metadata: {
|
|
@@ -1785,13 +1785,13 @@ var getGroup = async (config, options, privacy) => {
|
|
|
1785
1785
|
const resData = res.data;
|
|
1786
1786
|
return resData;
|
|
1787
1787
|
} catch (error) {
|
|
1788
|
-
if (error instanceof
|
|
1788
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1789
1789
|
throw error;
|
|
1790
1790
|
}
|
|
1791
1791
|
if (error instanceof Error) {
|
|
1792
|
-
throw new
|
|
1792
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing getGroup: ${error.message}`);
|
|
1793
1793
|
}
|
|
1794
|
-
throw new
|
|
1794
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
1795
1795
|
"An unknown error occurred while getting info for a group"
|
|
1796
1796
|
);
|
|
1797
1797
|
}
|
|
@@ -1800,7 +1800,7 @@ var getGroup = async (config, options, privacy) => {
|
|
|
1800
1800
|
// src/core/functions/groups/listGroups.ts
|
|
1801
1801
|
var listGroups = async (config, privacy, options) => {
|
|
1802
1802
|
if (!config) {
|
|
1803
|
-
throw new
|
|
1803
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1804
1804
|
}
|
|
1805
1805
|
let headers;
|
|
1806
1806
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -1839,7 +1839,7 @@ var listGroups = async (config, privacy, options) => {
|
|
|
1839
1839
|
if (!request.ok) {
|
|
1840
1840
|
const errorData = await request.text();
|
|
1841
1841
|
if (request.status === 401 || request.status === 403) {
|
|
1842
|
-
throw new
|
|
1842
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1843
1843
|
`Authentication failed: ${errorData}`,
|
|
1844
1844
|
request.status,
|
|
1845
1845
|
{
|
|
@@ -1851,7 +1851,7 @@ var listGroups = async (config, privacy, options) => {
|
|
|
1851
1851
|
}
|
|
1852
1852
|
);
|
|
1853
1853
|
}
|
|
1854
|
-
throw new
|
|
1854
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
1855
1855
|
error: errorData,
|
|
1856
1856
|
code: "HTTP_ERROR",
|
|
1857
1857
|
metadata: {
|
|
@@ -1863,20 +1863,20 @@ var listGroups = async (config, privacy, options) => {
|
|
|
1863
1863
|
const resData = res.data;
|
|
1864
1864
|
return resData;
|
|
1865
1865
|
} catch (error) {
|
|
1866
|
-
if (error instanceof
|
|
1866
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1867
1867
|
throw error;
|
|
1868
1868
|
}
|
|
1869
1869
|
if (error instanceof Error) {
|
|
1870
|
-
throw new
|
|
1870
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing listGroups: ${error.message}`);
|
|
1871
1871
|
}
|
|
1872
|
-
throw new
|
|
1872
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while listing groups");
|
|
1873
1873
|
}
|
|
1874
1874
|
};
|
|
1875
1875
|
|
|
1876
1876
|
// src/core/functions/groups/removeFromGroup.ts
|
|
1877
1877
|
var removeFromGroup = async (config, options, privacy) => {
|
|
1878
1878
|
if (!config) {
|
|
1879
|
-
throw new
|
|
1879
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1880
1880
|
}
|
|
1881
1881
|
const wait3 = (milliseconds) => {
|
|
1882
1882
|
return new Promise((resolve) => {
|
|
@@ -1915,7 +1915,7 @@ var removeFromGroup = async (config, options, privacy) => {
|
|
|
1915
1915
|
if (!response.ok) {
|
|
1916
1916
|
const errorData = await response.text();
|
|
1917
1917
|
if (response.status === 401) {
|
|
1918
|
-
throw new
|
|
1918
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
1919
1919
|
`Authentication failed: ${errorData}`,
|
|
1920
1920
|
response.status,
|
|
1921
1921
|
{
|
|
@@ -1927,7 +1927,7 @@ var removeFromGroup = async (config, options, privacy) => {
|
|
|
1927
1927
|
}
|
|
1928
1928
|
);
|
|
1929
1929
|
}
|
|
1930
|
-
throw new
|
|
1930
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, response.status, {
|
|
1931
1931
|
error: errorData,
|
|
1932
1932
|
code: "HTTP_ERROR",
|
|
1933
1933
|
metadata: {
|
|
@@ -1941,7 +1941,7 @@ var removeFromGroup = async (config, options, privacy) => {
|
|
|
1941
1941
|
});
|
|
1942
1942
|
} catch (error) {
|
|
1943
1943
|
let errorMessage;
|
|
1944
|
-
if (error instanceof
|
|
1944
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
1945
1945
|
errorMessage = error.message;
|
|
1946
1946
|
} else if (error instanceof Error) {
|
|
1947
1947
|
errorMessage = `Error adding file ${id} to group: ${error.message}`;
|
|
@@ -1960,7 +1960,7 @@ var removeFromGroup = async (config, options, privacy) => {
|
|
|
1960
1960
|
// src/core/functions/groups/updateGroup.ts
|
|
1961
1961
|
var updateGroup = async (config, options, privacy) => {
|
|
1962
1962
|
if (!config) {
|
|
1963
|
-
throw new
|
|
1963
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
1964
1964
|
}
|
|
1965
1965
|
const data = JSON.stringify({
|
|
1966
1966
|
name: options.name,
|
|
@@ -1996,7 +1996,7 @@ var updateGroup = async (config, options, privacy) => {
|
|
|
1996
1996
|
if (!request.ok) {
|
|
1997
1997
|
const errorData = await request.text();
|
|
1998
1998
|
if (request.status === 401 || request.status === 403) {
|
|
1999
|
-
throw new
|
|
1999
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2000
2000
|
`Authentication failed: ${errorData}`,
|
|
2001
2001
|
request.status,
|
|
2002
2002
|
{
|
|
@@ -2008,7 +2008,7 @@ var updateGroup = async (config, options, privacy) => {
|
|
|
2008
2008
|
}
|
|
2009
2009
|
);
|
|
2010
2010
|
}
|
|
2011
|
-
throw new
|
|
2011
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2012
2012
|
error: errorData,
|
|
2013
2013
|
code: "HTTP_ERROR",
|
|
2014
2014
|
metadata: {
|
|
@@ -2020,20 +2020,20 @@ var updateGroup = async (config, options, privacy) => {
|
|
|
2020
2020
|
const resData = res.data;
|
|
2021
2021
|
return resData;
|
|
2022
2022
|
} catch (error) {
|
|
2023
|
-
if (error instanceof
|
|
2023
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2024
2024
|
throw error;
|
|
2025
2025
|
}
|
|
2026
2026
|
if (error instanceof Error) {
|
|
2027
|
-
throw new
|
|
2027
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing updateGroup: ${error.message}`);
|
|
2028
2028
|
}
|
|
2029
|
-
throw new
|
|
2029
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while updating group");
|
|
2030
2030
|
}
|
|
2031
2031
|
};
|
|
2032
2032
|
|
|
2033
2033
|
// src/core/functions/keys/createKey.ts
|
|
2034
2034
|
var createKey = async (config, options) => {
|
|
2035
2035
|
if (!config) {
|
|
2036
|
-
throw new
|
|
2036
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
2037
2037
|
}
|
|
2038
2038
|
let headers;
|
|
2039
2039
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -2063,7 +2063,7 @@ var createKey = async (config, options) => {
|
|
|
2063
2063
|
if (!request.ok) {
|
|
2064
2064
|
const errorData = await request.text();
|
|
2065
2065
|
if (request.status === 401 || request.status === 403) {
|
|
2066
|
-
throw new
|
|
2066
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2067
2067
|
`Authentication failed: ${errorData}`,
|
|
2068
2068
|
request.status,
|
|
2069
2069
|
{
|
|
@@ -2075,7 +2075,7 @@ var createKey = async (config, options) => {
|
|
|
2075
2075
|
}
|
|
2076
2076
|
);
|
|
2077
2077
|
}
|
|
2078
|
-
throw new
|
|
2078
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2079
2079
|
error: errorData,
|
|
2080
2080
|
code: "HTTP_ERROR",
|
|
2081
2081
|
metadata: {
|
|
@@ -2086,20 +2086,20 @@ var createKey = async (config, options) => {
|
|
|
2086
2086
|
const res = await request.json();
|
|
2087
2087
|
return res;
|
|
2088
2088
|
} catch (error) {
|
|
2089
|
-
if (error instanceof
|
|
2089
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2090
2090
|
throw error;
|
|
2091
2091
|
}
|
|
2092
2092
|
if (error instanceof Error) {
|
|
2093
|
-
throw new
|
|
2093
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing createKey: ${error.message}`);
|
|
2094
2094
|
}
|
|
2095
|
-
throw new
|
|
2095
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while creating API key");
|
|
2096
2096
|
}
|
|
2097
2097
|
};
|
|
2098
2098
|
|
|
2099
2099
|
// src/core/functions/keys/listKeys.ts
|
|
2100
2100
|
var listKeys = async (config, options) => {
|
|
2101
2101
|
if (!config) {
|
|
2102
|
-
throw new
|
|
2102
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
2103
2103
|
}
|
|
2104
2104
|
let headers;
|
|
2105
2105
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -2141,7 +2141,7 @@ var listKeys = async (config, options) => {
|
|
|
2141
2141
|
if (!request.ok) {
|
|
2142
2142
|
const errorData = await request.text();
|
|
2143
2143
|
if (request.status === 401 || request.status === 403) {
|
|
2144
|
-
throw new
|
|
2144
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2145
2145
|
`Authentication failed: ${errorData}`,
|
|
2146
2146
|
request.status,
|
|
2147
2147
|
{
|
|
@@ -2153,7 +2153,7 @@ var listKeys = async (config, options) => {
|
|
|
2153
2153
|
}
|
|
2154
2154
|
);
|
|
2155
2155
|
}
|
|
2156
|
-
throw new
|
|
2156
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2157
2157
|
error: errorData,
|
|
2158
2158
|
code: "HTTP_ERROR",
|
|
2159
2159
|
metadata: {
|
|
@@ -2164,13 +2164,13 @@ var listKeys = async (config, options) => {
|
|
|
2164
2164
|
const res = await request.json();
|
|
2165
2165
|
return res.keys;
|
|
2166
2166
|
} catch (error) {
|
|
2167
|
-
if (error instanceof
|
|
2167
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2168
2168
|
throw error;
|
|
2169
2169
|
}
|
|
2170
2170
|
if (error instanceof Error) {
|
|
2171
|
-
throw new
|
|
2171
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing listKeys: ${error.message}`);
|
|
2172
2172
|
}
|
|
2173
|
-
throw new
|
|
2173
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while listing API keys");
|
|
2174
2174
|
}
|
|
2175
2175
|
};
|
|
2176
2176
|
|
|
@@ -2182,7 +2182,7 @@ var wait2 = (milliseconds) => {
|
|
|
2182
2182
|
};
|
|
2183
2183
|
var revokeKeys = async (config, keys) => {
|
|
2184
2184
|
if (!config) {
|
|
2185
|
-
throw new
|
|
2185
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
2186
2186
|
}
|
|
2187
2187
|
let headers;
|
|
2188
2188
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -2214,7 +2214,7 @@ var revokeKeys = async (config, keys) => {
|
|
|
2214
2214
|
if (!request.ok) {
|
|
2215
2215
|
const errorData = await request.text();
|
|
2216
2216
|
if (request.status === 401 || request.status === 403) {
|
|
2217
|
-
throw new
|
|
2217
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2218
2218
|
`Authentication failed: ${errorData}`,
|
|
2219
2219
|
request.status,
|
|
2220
2220
|
{
|
|
@@ -2226,7 +2226,7 @@ var revokeKeys = async (config, keys) => {
|
|
|
2226
2226
|
}
|
|
2227
2227
|
);
|
|
2228
2228
|
}
|
|
2229
|
-
throw new
|
|
2229
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2230
2230
|
error: errorData,
|
|
2231
2231
|
code: "HTTP_ERROR",
|
|
2232
2232
|
metadata: {
|
|
@@ -2241,7 +2241,7 @@ var revokeKeys = async (config, keys) => {
|
|
|
2241
2241
|
});
|
|
2242
2242
|
} catch (error) {
|
|
2243
2243
|
let errorMessage;
|
|
2244
|
-
if (error instanceof
|
|
2244
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2245
2245
|
errorMessage = error.message;
|
|
2246
2246
|
} else if (error instanceof Error) {
|
|
2247
2247
|
errorMessage = `Error revoking key ${key}: ${error.message}`;
|
|
@@ -2260,7 +2260,7 @@ var revokeKeys = async (config, keys) => {
|
|
|
2260
2260
|
// src/core/functions/uploads/base64.ts
|
|
2261
2261
|
var uploadBase64 = async (config, base64String, network, options) => {
|
|
2262
2262
|
if (!config) {
|
|
2263
|
-
throw new
|
|
2263
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
2264
2264
|
}
|
|
2265
2265
|
const jwt = options?.keys || config?.pinataJwt;
|
|
2266
2266
|
const name = options?.metadata?.name ? options?.metadata?.name : "base64 string";
|
|
@@ -2301,7 +2301,7 @@ var uploadBase64 = async (config, base64String, network, options) => {
|
|
|
2301
2301
|
if (!request.ok) {
|
|
2302
2302
|
const errorData = await request.text();
|
|
2303
2303
|
if (request.status === 401 || request.status === 403) {
|
|
2304
|
-
throw new
|
|
2304
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2305
2305
|
`Authentication failed: ${errorData}`,
|
|
2306
2306
|
request.status,
|
|
2307
2307
|
{
|
|
@@ -2313,7 +2313,7 @@ var uploadBase64 = async (config, base64String, network, options) => {
|
|
|
2313
2313
|
}
|
|
2314
2314
|
);
|
|
2315
2315
|
}
|
|
2316
|
-
throw new
|
|
2316
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2317
2317
|
error: errorData,
|
|
2318
2318
|
code: "HTTP_ERROR",
|
|
2319
2319
|
metadata: {
|
|
@@ -2325,13 +2325,13 @@ var uploadBase64 = async (config, base64String, network, options) => {
|
|
|
2325
2325
|
const resData = res.data;
|
|
2326
2326
|
return resData;
|
|
2327
2327
|
} catch (error) {
|
|
2328
|
-
if (error instanceof
|
|
2328
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2329
2329
|
throw error;
|
|
2330
2330
|
}
|
|
2331
2331
|
if (error instanceof Error) {
|
|
2332
|
-
throw new
|
|
2332
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing base64: ${error.message}`);
|
|
2333
2333
|
}
|
|
2334
|
-
throw new
|
|
2334
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2335
2335
|
"An unknown error occurred while trying to upload base64"
|
|
2336
2336
|
);
|
|
2337
2337
|
}
|
|
@@ -2345,7 +2345,7 @@ var uploadBase64 = async (config, base64String, network, options) => {
|
|
|
2345
2345
|
if (!request.ok) {
|
|
2346
2346
|
const errorData = await request.text();
|
|
2347
2347
|
if (request.status === 401 || request.status === 403) {
|
|
2348
|
-
throw new
|
|
2348
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2349
2349
|
`Authentication failed: ${errorData}`,
|
|
2350
2350
|
request.status,
|
|
2351
2351
|
{
|
|
@@ -2357,7 +2357,7 @@ var uploadBase64 = async (config, base64String, network, options) => {
|
|
|
2357
2357
|
}
|
|
2358
2358
|
);
|
|
2359
2359
|
}
|
|
2360
|
-
throw new
|
|
2360
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2361
2361
|
error: errorData,
|
|
2362
2362
|
code: "HTTP_ERROR",
|
|
2363
2363
|
metadata: {
|
|
@@ -2382,7 +2382,7 @@ var uploadBase64 = async (config, base64String, network, options) => {
|
|
|
2382
2382
|
return resData;
|
|
2383
2383
|
} else {
|
|
2384
2384
|
const errorData = await vectorReq.text();
|
|
2385
|
-
throw new
|
|
2385
|
+
throw new chunkBK3CLF3Z_js.NetworkError(
|
|
2386
2386
|
`HTTP error during vectorization: ${errorData}`,
|
|
2387
2387
|
vectorReq.status,
|
|
2388
2388
|
{
|
|
@@ -2397,13 +2397,13 @@ var uploadBase64 = async (config, base64String, network, options) => {
|
|
|
2397
2397
|
}
|
|
2398
2398
|
return resData;
|
|
2399
2399
|
} catch (error) {
|
|
2400
|
-
if (error instanceof
|
|
2400
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2401
2401
|
throw error;
|
|
2402
2402
|
}
|
|
2403
2403
|
if (error instanceof Error) {
|
|
2404
|
-
throw new
|
|
2404
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing base64: ${error.message}`);
|
|
2405
2405
|
}
|
|
2406
|
-
throw new
|
|
2406
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2407
2407
|
"An unknown error occurred while trying to upload base64"
|
|
2408
2408
|
);
|
|
2409
2409
|
}
|
|
@@ -2412,7 +2412,7 @@ var uploadBase64 = async (config, base64String, network, options) => {
|
|
|
2412
2412
|
// src/core/functions/uploads/createSignedUploadURL.ts
|
|
2413
2413
|
var createSignedUploadURL = async (config, options, network) => {
|
|
2414
2414
|
if (!config) {
|
|
2415
|
-
throw new
|
|
2415
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
2416
2416
|
}
|
|
2417
2417
|
const date = options?.date || Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
2418
2418
|
const payload = {
|
|
@@ -2468,7 +2468,7 @@ var createSignedUploadURL = async (config, options, network) => {
|
|
|
2468
2468
|
if (!request.ok) {
|
|
2469
2469
|
const errorData = await request.text();
|
|
2470
2470
|
if (request.status === 401 || request.status === 403) {
|
|
2471
|
-
throw new
|
|
2471
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2472
2472
|
`Authentication Failed: ${errorData}`,
|
|
2473
2473
|
request.status,
|
|
2474
2474
|
{
|
|
@@ -2480,7 +2480,7 @@ var createSignedUploadURL = async (config, options, network) => {
|
|
|
2480
2480
|
}
|
|
2481
2481
|
);
|
|
2482
2482
|
}
|
|
2483
|
-
throw new
|
|
2483
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2484
2484
|
error: errorData,
|
|
2485
2485
|
code: "HTTP_ERROR",
|
|
2486
2486
|
metadata: {
|
|
@@ -2491,22 +2491,22 @@ var createSignedUploadURL = async (config, options, network) => {
|
|
|
2491
2491
|
const res = await request.json();
|
|
2492
2492
|
return res.data;
|
|
2493
2493
|
} catch (error) {
|
|
2494
|
-
if (error instanceof
|
|
2494
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2495
2495
|
throw error;
|
|
2496
2496
|
}
|
|
2497
2497
|
if (error instanceof Error) {
|
|
2498
|
-
throw new
|
|
2498
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2499
2499
|
`Error processing createSignedURL: ${error.message}`
|
|
2500
2500
|
);
|
|
2501
2501
|
}
|
|
2502
|
-
throw new
|
|
2502
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while getting signed url");
|
|
2503
2503
|
}
|
|
2504
2504
|
};
|
|
2505
2505
|
|
|
2506
2506
|
// src/core/functions/uploads/file.ts
|
|
2507
2507
|
var uploadFile = async (config, file, network, options) => {
|
|
2508
2508
|
if (!config) {
|
|
2509
|
-
throw new
|
|
2509
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
2510
2510
|
}
|
|
2511
2511
|
const jwt = options?.keys || config.pinataJwt;
|
|
2512
2512
|
let endpoint = "https://uploads.pinata.cloud/v3";
|
|
@@ -2529,13 +2529,13 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2529
2529
|
const name = options?.metadata?.name || file.name || "File from SDK";
|
|
2530
2530
|
let metadata = `filename ${btoa(name)},filetype ${btoa(file.type)},network ${btoa(network)}`;
|
|
2531
2531
|
if (options?.groupId) {
|
|
2532
|
-
metadata
|
|
2532
|
+
metadata += `,group_id ${btoa(options.groupId)}`;
|
|
2533
2533
|
}
|
|
2534
2534
|
if (options?.metadata?.keyvalues) {
|
|
2535
|
-
metadata
|
|
2535
|
+
metadata += `,keyvalues ${btoa(JSON.stringify(options.metadata.keyvalues))}`;
|
|
2536
2536
|
}
|
|
2537
2537
|
if (options?.streamable) {
|
|
2538
|
-
metadata
|
|
2538
|
+
metadata += `,streamable ${btoa("true")}`;
|
|
2539
2539
|
}
|
|
2540
2540
|
let updatedEndpoint = `${endpoint}/files`;
|
|
2541
2541
|
if (options?.url) {
|
|
@@ -2552,7 +2552,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2552
2552
|
const url = urlReq.headers.get("Location");
|
|
2553
2553
|
if (!url) {
|
|
2554
2554
|
const errorData = await urlReq.text();
|
|
2555
|
-
throw new
|
|
2555
|
+
throw new chunkBK3CLF3Z_js.NetworkError("Upload URL not provided", urlReq.status, {
|
|
2556
2556
|
error: errorData,
|
|
2557
2557
|
code: "HTTP_ERROR",
|
|
2558
2558
|
metadata: {
|
|
@@ -2590,7 +2590,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2590
2590
|
retryCount++;
|
|
2591
2591
|
if (retryCount > maxRetries) {
|
|
2592
2592
|
const errorData = uploadReq ? await uploadReq.text().catch(() => "Unknown error") : error instanceof Error ? error.message : String(error);
|
|
2593
|
-
throw new
|
|
2593
|
+
throw new chunkBK3CLF3Z_js.NetworkError(
|
|
2594
2594
|
`HTTP error during chunk upload after ${maxRetries} retries: ${errorData}`,
|
|
2595
2595
|
uploadReq?.status || 0,
|
|
2596
2596
|
{
|
|
@@ -2611,6 +2611,22 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2611
2611
|
}
|
|
2612
2612
|
if (uploadReq.status === 204) {
|
|
2613
2613
|
const cid = uploadReq.headers.get("upload-cid");
|
|
2614
|
+
if (!config.pinataJwt) {
|
|
2615
|
+
const data3 = {
|
|
2616
|
+
id: "",
|
|
2617
|
+
name: "",
|
|
2618
|
+
cid,
|
|
2619
|
+
size: file.size,
|
|
2620
|
+
created_at: "",
|
|
2621
|
+
number_of_files: 1,
|
|
2622
|
+
group_id: null,
|
|
2623
|
+
mime_type: "",
|
|
2624
|
+
keyvalues: {},
|
|
2625
|
+
vectorized: false,
|
|
2626
|
+
network: ""
|
|
2627
|
+
};
|
|
2628
|
+
return data3;
|
|
2629
|
+
}
|
|
2614
2630
|
let dataEndpoint;
|
|
2615
2631
|
if (config.endpointUrl) {
|
|
2616
2632
|
dataEndpoint = config.endpointUrl;
|
|
@@ -2643,7 +2659,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2643
2659
|
return data2;
|
|
2644
2660
|
} else {
|
|
2645
2661
|
const errorData = await vectorReq.text();
|
|
2646
|
-
throw new
|
|
2662
|
+
throw new chunkBK3CLF3Z_js.NetworkError(
|
|
2647
2663
|
`HTTP error during vectorization: ${errorData}`,
|
|
2648
2664
|
vectorReq.status,
|
|
2649
2665
|
{
|
|
@@ -2694,7 +2710,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2694
2710
|
if (!request.ok) {
|
|
2695
2711
|
const errorData = await request.text();
|
|
2696
2712
|
if (request.status === 401 || request.status === 403) {
|
|
2697
|
-
throw new
|
|
2713
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2698
2714
|
`Authentication failed: ${errorData}`,
|
|
2699
2715
|
request.status,
|
|
2700
2716
|
{
|
|
@@ -2706,7 +2722,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2706
2722
|
}
|
|
2707
2723
|
);
|
|
2708
2724
|
}
|
|
2709
|
-
throw new
|
|
2725
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2710
2726
|
error: errorData,
|
|
2711
2727
|
code: "HTTP_ERROR",
|
|
2712
2728
|
metadata: {
|
|
@@ -2718,11 +2734,11 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2718
2734
|
const resData = res.data;
|
|
2719
2735
|
return resData;
|
|
2720
2736
|
} catch (error) {
|
|
2721
|
-
if (error instanceof
|
|
2737
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2722
2738
|
throw error;
|
|
2723
2739
|
}
|
|
2724
2740
|
if (error instanceof Error) {
|
|
2725
|
-
throw new
|
|
2741
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2726
2742
|
`Error uploading file: ${error.message}`,
|
|
2727
2743
|
void 0,
|
|
2728
2744
|
{
|
|
@@ -2730,7 +2746,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2730
2746
|
}
|
|
2731
2747
|
);
|
|
2732
2748
|
}
|
|
2733
|
-
throw new
|
|
2749
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2734
2750
|
"An unknown error occurred while trying to upload file"
|
|
2735
2751
|
);
|
|
2736
2752
|
}
|
|
@@ -2744,7 +2760,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2744
2760
|
if (!request.ok) {
|
|
2745
2761
|
const errorData = await request.text();
|
|
2746
2762
|
if (request.status === 401 || request.status === 403) {
|
|
2747
|
-
throw new
|
|
2763
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2748
2764
|
`Authentication failed: ${errorData}`,
|
|
2749
2765
|
request.status,
|
|
2750
2766
|
{
|
|
@@ -2756,7 +2772,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2756
2772
|
}
|
|
2757
2773
|
);
|
|
2758
2774
|
}
|
|
2759
|
-
throw new
|
|
2775
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2760
2776
|
error: errorData,
|
|
2761
2777
|
code: "HTTP_ERROR",
|
|
2762
2778
|
metadata: {
|
|
@@ -2781,7 +2797,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2781
2797
|
return resData;
|
|
2782
2798
|
} else {
|
|
2783
2799
|
const errorData = await vectorReq.text();
|
|
2784
|
-
throw new
|
|
2800
|
+
throw new chunkBK3CLF3Z_js.NetworkError(
|
|
2785
2801
|
`HTTP error during vectorization: ${errorData}`,
|
|
2786
2802
|
vectorReq.status,
|
|
2787
2803
|
{
|
|
@@ -2796,11 +2812,11 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2796
2812
|
}
|
|
2797
2813
|
return resData;
|
|
2798
2814
|
} catch (error) {
|
|
2799
|
-
if (error instanceof
|
|
2815
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2800
2816
|
throw error;
|
|
2801
2817
|
}
|
|
2802
2818
|
if (error instanceof Error) {
|
|
2803
|
-
throw new
|
|
2819
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2804
2820
|
`Error uploading file: ${error.message}`,
|
|
2805
2821
|
void 0,
|
|
2806
2822
|
{
|
|
@@ -2808,7 +2824,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2808
2824
|
}
|
|
2809
2825
|
);
|
|
2810
2826
|
}
|
|
2811
|
-
throw new
|
|
2827
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2812
2828
|
"An unknown error occurred while trying to upload file"
|
|
2813
2829
|
);
|
|
2814
2830
|
}
|
|
@@ -2817,7 +2833,7 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2817
2833
|
// src/core/functions/uploads/fileArray.ts
|
|
2818
2834
|
var uploadFileArray = async (config, files, network, options) => {
|
|
2819
2835
|
if (!config) {
|
|
2820
|
-
throw new
|
|
2836
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
2821
2837
|
}
|
|
2822
2838
|
const jwt = options?.keys || config?.pinataJwt;
|
|
2823
2839
|
const folder = options?.metadata?.name || "folder_from_sdk";
|
|
@@ -2865,7 +2881,7 @@ var uploadFileArray = async (config, files, network, options) => {
|
|
|
2865
2881
|
if (!request.ok) {
|
|
2866
2882
|
const errorData = await request.text();
|
|
2867
2883
|
if (request.status === 401 || request.status === 403) {
|
|
2868
|
-
throw new
|
|
2884
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2869
2885
|
`Authentication failed: ${errorData}`,
|
|
2870
2886
|
request.status,
|
|
2871
2887
|
{
|
|
@@ -2877,7 +2893,7 @@ var uploadFileArray = async (config, files, network, options) => {
|
|
|
2877
2893
|
}
|
|
2878
2894
|
);
|
|
2879
2895
|
}
|
|
2880
|
-
throw new
|
|
2896
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2881
2897
|
error: errorData,
|
|
2882
2898
|
code: "HTTP_ERROR",
|
|
2883
2899
|
metadata: {
|
|
@@ -2901,13 +2917,13 @@ var uploadFileArray = async (config, files, network, options) => {
|
|
|
2901
2917
|
};
|
|
2902
2918
|
return resData;
|
|
2903
2919
|
} catch (error) {
|
|
2904
|
-
if (error instanceof
|
|
2920
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2905
2921
|
throw error;
|
|
2906
2922
|
}
|
|
2907
2923
|
if (error instanceof Error) {
|
|
2908
|
-
throw new
|
|
2924
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing fileArray: ${error.message}`);
|
|
2909
2925
|
}
|
|
2910
|
-
throw new
|
|
2926
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2911
2927
|
"An unknown error occurred while uploading an array of files"
|
|
2912
2928
|
);
|
|
2913
2929
|
}
|
|
@@ -2916,7 +2932,7 @@ var uploadFileArray = async (config, files, network, options) => {
|
|
|
2916
2932
|
// src/core/functions/uploads/json.ts
|
|
2917
2933
|
var uploadJson = async (config, jsonData, network, options) => {
|
|
2918
2934
|
if (!config) {
|
|
2919
|
-
throw new
|
|
2935
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
2920
2936
|
}
|
|
2921
2937
|
const jwt = options?.keys || config?.pinataJwt;
|
|
2922
2938
|
const json = JSON.stringify(jsonData);
|
|
@@ -2957,7 +2973,7 @@ var uploadJson = async (config, jsonData, network, options) => {
|
|
|
2957
2973
|
if (!request.ok) {
|
|
2958
2974
|
const errorData = await request.text();
|
|
2959
2975
|
if (request.status === 401 || request.status === 403) {
|
|
2960
|
-
throw new
|
|
2976
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2961
2977
|
`Authentication failed: ${errorData}`,
|
|
2962
2978
|
request.status,
|
|
2963
2979
|
{
|
|
@@ -2969,7 +2985,7 @@ var uploadJson = async (config, jsonData, network, options) => {
|
|
|
2969
2985
|
}
|
|
2970
2986
|
);
|
|
2971
2987
|
}
|
|
2972
|
-
throw new
|
|
2988
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2973
2989
|
error: errorData,
|
|
2974
2990
|
code: "HTTP_ERROR",
|
|
2975
2991
|
metadata: {
|
|
@@ -2981,13 +2997,13 @@ var uploadJson = async (config, jsonData, network, options) => {
|
|
|
2981
2997
|
const resData = res.data;
|
|
2982
2998
|
return resData;
|
|
2983
2999
|
} catch (error) {
|
|
2984
|
-
if (error instanceof
|
|
3000
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2985
3001
|
throw error;
|
|
2986
3002
|
}
|
|
2987
3003
|
if (error instanceof Error) {
|
|
2988
|
-
throw new
|
|
3004
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing base64: ${error.message}`);
|
|
2989
3005
|
}
|
|
2990
|
-
throw new
|
|
3006
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2991
3007
|
"An unknown error occurred while trying to upload base64"
|
|
2992
3008
|
);
|
|
2993
3009
|
}
|
|
@@ -3001,7 +3017,7 @@ var uploadJson = async (config, jsonData, network, options) => {
|
|
|
3001
3017
|
if (!request.ok) {
|
|
3002
3018
|
const errorData = await request.text();
|
|
3003
3019
|
if (request.status === 401 || request.status === 403) {
|
|
3004
|
-
throw new
|
|
3020
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3005
3021
|
`Authentication failed: ${errorData}`,
|
|
3006
3022
|
request.status,
|
|
3007
3023
|
{
|
|
@@ -3013,7 +3029,7 @@ var uploadJson = async (config, jsonData, network, options) => {
|
|
|
3013
3029
|
}
|
|
3014
3030
|
);
|
|
3015
3031
|
}
|
|
3016
|
-
throw new
|
|
3032
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3017
3033
|
error: errorData,
|
|
3018
3034
|
code: "HTTP_ERROR",
|
|
3019
3035
|
metadata: {
|
|
@@ -3038,7 +3054,7 @@ var uploadJson = async (config, jsonData, network, options) => {
|
|
|
3038
3054
|
return resData;
|
|
3039
3055
|
} else {
|
|
3040
3056
|
const errorData = await vectorReq.text();
|
|
3041
|
-
throw new
|
|
3057
|
+
throw new chunkBK3CLF3Z_js.NetworkError(
|
|
3042
3058
|
`HTTP error during vectorization: ${errorData}`,
|
|
3043
3059
|
vectorReq.status,
|
|
3044
3060
|
{
|
|
@@ -3053,27 +3069,27 @@ var uploadJson = async (config, jsonData, network, options) => {
|
|
|
3053
3069
|
}
|
|
3054
3070
|
return resData;
|
|
3055
3071
|
} catch (error) {
|
|
3056
|
-
if (error instanceof
|
|
3072
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3057
3073
|
throw error;
|
|
3058
3074
|
}
|
|
3059
3075
|
if (error instanceof Error) {
|
|
3060
|
-
throw new
|
|
3076
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing json: ${error.message}`);
|
|
3061
3077
|
}
|
|
3062
|
-
throw new
|
|
3078
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while uploading json");
|
|
3063
3079
|
}
|
|
3064
3080
|
};
|
|
3065
3081
|
|
|
3066
3082
|
// src/core/functions/uploads/url.ts
|
|
3067
3083
|
var uploadUrl = async (config, url, network, options) => {
|
|
3068
3084
|
if (!config) {
|
|
3069
|
-
throw new
|
|
3085
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3070
3086
|
}
|
|
3071
3087
|
const jwt = options?.keys || config?.pinataJwt;
|
|
3072
3088
|
const data = new FormData();
|
|
3073
3089
|
const stream = await fetch(url);
|
|
3074
3090
|
if (!stream.ok) {
|
|
3075
3091
|
const errorData = await stream.text();
|
|
3076
|
-
throw new
|
|
3092
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, stream.status, {
|
|
3077
3093
|
error: errorData,
|
|
3078
3094
|
code: "HTTP_ERROR",
|
|
3079
3095
|
metadata: {
|
|
@@ -3119,7 +3135,7 @@ var uploadUrl = async (config, url, network, options) => {
|
|
|
3119
3135
|
if (!request.ok) {
|
|
3120
3136
|
const errorData = await request.text();
|
|
3121
3137
|
if (request.status === 401 || request.status === 403) {
|
|
3122
|
-
throw new
|
|
3138
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3123
3139
|
`Authentication failed: ${errorData}`,
|
|
3124
3140
|
request.status,
|
|
3125
3141
|
{
|
|
@@ -3131,7 +3147,7 @@ var uploadUrl = async (config, url, network, options) => {
|
|
|
3131
3147
|
}
|
|
3132
3148
|
);
|
|
3133
3149
|
}
|
|
3134
|
-
throw new
|
|
3150
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3135
3151
|
error: errorData,
|
|
3136
3152
|
code: "HTTP_ERROR",
|
|
3137
3153
|
metadata: {
|
|
@@ -3143,13 +3159,13 @@ var uploadUrl = async (config, url, network, options) => {
|
|
|
3143
3159
|
const resData = res.data;
|
|
3144
3160
|
return resData;
|
|
3145
3161
|
} catch (error) {
|
|
3146
|
-
if (error instanceof
|
|
3162
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3147
3163
|
throw error;
|
|
3148
3164
|
}
|
|
3149
3165
|
if (error instanceof Error) {
|
|
3150
|
-
throw new
|
|
3166
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing base64: ${error.message}`);
|
|
3151
3167
|
}
|
|
3152
|
-
throw new
|
|
3168
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3153
3169
|
"An unknown error occurred while trying to upload base64"
|
|
3154
3170
|
);
|
|
3155
3171
|
}
|
|
@@ -3163,7 +3179,7 @@ var uploadUrl = async (config, url, network, options) => {
|
|
|
3163
3179
|
if (!request.ok) {
|
|
3164
3180
|
const errorData = await request.text();
|
|
3165
3181
|
if (request.status === 401 || request.status === 403) {
|
|
3166
|
-
throw new
|
|
3182
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3167
3183
|
`Authentication failed: ${errorData}`,
|
|
3168
3184
|
request.status,
|
|
3169
3185
|
{
|
|
@@ -3175,7 +3191,7 @@ var uploadUrl = async (config, url, network, options) => {
|
|
|
3175
3191
|
}
|
|
3176
3192
|
);
|
|
3177
3193
|
}
|
|
3178
|
-
throw new
|
|
3194
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3179
3195
|
error: errorData,
|
|
3180
3196
|
code: "HTTP_ERROR",
|
|
3181
3197
|
metadata: {
|
|
@@ -3200,7 +3216,7 @@ var uploadUrl = async (config, url, network, options) => {
|
|
|
3200
3216
|
return resData;
|
|
3201
3217
|
} else {
|
|
3202
3218
|
const errorData = await vectorReq.text();
|
|
3203
|
-
throw new
|
|
3219
|
+
throw new chunkBK3CLF3Z_js.NetworkError(
|
|
3204
3220
|
`HTTP error during vectorization: ${errorData}`,
|
|
3205
3221
|
vectorReq.status,
|
|
3206
3222
|
{
|
|
@@ -3215,20 +3231,20 @@ var uploadUrl = async (config, url, network, options) => {
|
|
|
3215
3231
|
}
|
|
3216
3232
|
return resData;
|
|
3217
3233
|
} catch (error) {
|
|
3218
|
-
if (error instanceof
|
|
3234
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3219
3235
|
throw error;
|
|
3220
3236
|
}
|
|
3221
3237
|
if (error instanceof Error) {
|
|
3222
|
-
throw new
|
|
3238
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing url: ${error.message}`);
|
|
3223
3239
|
}
|
|
3224
|
-
throw new
|
|
3240
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while uploading by url");
|
|
3225
3241
|
}
|
|
3226
3242
|
};
|
|
3227
3243
|
|
|
3228
3244
|
// src/core/functions/uploads/cid.ts
|
|
3229
3245
|
var uploadCid = async (config, cid, options) => {
|
|
3230
3246
|
if (!config) {
|
|
3231
|
-
throw new
|
|
3247
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3232
3248
|
}
|
|
3233
3249
|
const jwt = options?.keys || config?.pinataJwt;
|
|
3234
3250
|
let headers;
|
|
@@ -3266,7 +3282,7 @@ var uploadCid = async (config, cid, options) => {
|
|
|
3266
3282
|
if (!request.ok) {
|
|
3267
3283
|
const errorData = await request.text();
|
|
3268
3284
|
if (request.status === 401 || request.status === 403) {
|
|
3269
|
-
throw new
|
|
3285
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3270
3286
|
`Authentication failed: ${errorData}`,
|
|
3271
3287
|
request.status,
|
|
3272
3288
|
{
|
|
@@ -3278,7 +3294,7 @@ var uploadCid = async (config, cid, options) => {
|
|
|
3278
3294
|
}
|
|
3279
3295
|
);
|
|
3280
3296
|
}
|
|
3281
|
-
throw new
|
|
3297
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3282
3298
|
error: errorData,
|
|
3283
3299
|
code: "HTTP_ERROR",
|
|
3284
3300
|
metadata: {
|
|
@@ -3290,20 +3306,20 @@ var uploadCid = async (config, cid, options) => {
|
|
|
3290
3306
|
const resData = res.data;
|
|
3291
3307
|
return resData;
|
|
3292
3308
|
} catch (error) {
|
|
3293
|
-
if (error instanceof
|
|
3309
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3294
3310
|
throw error;
|
|
3295
3311
|
}
|
|
3296
3312
|
if (error instanceof Error) {
|
|
3297
|
-
throw new
|
|
3313
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing cid: ${error.message}`);
|
|
3298
3314
|
}
|
|
3299
|
-
throw new
|
|
3315
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while pinning by CID");
|
|
3300
3316
|
}
|
|
3301
3317
|
};
|
|
3302
3318
|
|
|
3303
3319
|
// src/core/classes/analytics/Analytics.ts
|
|
3304
3320
|
var Analytics = class {
|
|
3305
3321
|
constructor(config) {
|
|
3306
|
-
this.config =
|
|
3322
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
3307
3323
|
this.requests = new AnalyticsRequests(this.config);
|
|
3308
3324
|
this.bandwidth = new AnalyticsBandwidth(this.config);
|
|
3309
3325
|
}
|
|
@@ -3606,7 +3622,7 @@ var FilterGroups = class {
|
|
|
3606
3622
|
// src/core/classes/groups/PublicGroups.ts
|
|
3607
3623
|
var PublicGroups = class {
|
|
3608
3624
|
constructor(config) {
|
|
3609
|
-
this.config =
|
|
3625
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
3610
3626
|
}
|
|
3611
3627
|
updateConfig(newConfig) {
|
|
3612
3628
|
this.config = newConfig;
|
|
@@ -3637,7 +3653,7 @@ var PublicGroups = class {
|
|
|
3637
3653
|
// src/core/classes/groups/PrivateGroups.ts
|
|
3638
3654
|
var PrivateGroups = class {
|
|
3639
3655
|
constructor(config) {
|
|
3640
|
-
this.config =
|
|
3656
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
3641
3657
|
}
|
|
3642
3658
|
updateConfig(newConfig) {
|
|
3643
3659
|
this.config = newConfig;
|
|
@@ -3668,7 +3684,7 @@ var PrivateGroups = class {
|
|
|
3668
3684
|
// src/core/classes/groups/Groups.ts
|
|
3669
3685
|
var Groups = class {
|
|
3670
3686
|
constructor(config) {
|
|
3671
|
-
this.config =
|
|
3687
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
3672
3688
|
this.public = new PublicGroups(config);
|
|
3673
3689
|
this.private = new PrivateGroups(config);
|
|
3674
3690
|
}
|
|
@@ -3680,7 +3696,7 @@ var Groups = class {
|
|
|
3680
3696
|
// src/core/classes/keys/Keys.ts
|
|
3681
3697
|
var Keys = class {
|
|
3682
3698
|
constructor(config) {
|
|
3683
|
-
this.config =
|
|
3699
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
3684
3700
|
}
|
|
3685
3701
|
updateConfig(newConfig) {
|
|
3686
3702
|
this.config = newConfig;
|
|
@@ -3771,7 +3787,7 @@ var FilterKeys = class {
|
|
|
3771
3787
|
// src/core/classes/gateways/Gateways.ts
|
|
3772
3788
|
var Gateways = class {
|
|
3773
3789
|
constructor(config) {
|
|
3774
|
-
this.config =
|
|
3790
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
3775
3791
|
this.public = new PublicGateways(config);
|
|
3776
3792
|
this.private = new PrivateGateways(config);
|
|
3777
3793
|
}
|
|
@@ -3846,7 +3862,7 @@ var PublicGateways = class {
|
|
|
3846
3862
|
// src/core/functions/files/getFile.ts
|
|
3847
3863
|
var getFile = async (config, id, privacy) => {
|
|
3848
3864
|
if (!config) {
|
|
3849
|
-
throw new
|
|
3865
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3850
3866
|
}
|
|
3851
3867
|
let headers;
|
|
3852
3868
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -3874,7 +3890,7 @@ var getFile = async (config, id, privacy) => {
|
|
|
3874
3890
|
if (!request.ok) {
|
|
3875
3891
|
const errorData = await request.text();
|
|
3876
3892
|
if (request.status === 401 || request.status === 403) {
|
|
3877
|
-
throw new
|
|
3893
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3878
3894
|
`Authentication failed: ${errorData}`,
|
|
3879
3895
|
request.status,
|
|
3880
3896
|
{
|
|
@@ -3886,7 +3902,7 @@ var getFile = async (config, id, privacy) => {
|
|
|
3886
3902
|
}
|
|
3887
3903
|
);
|
|
3888
3904
|
}
|
|
3889
|
-
throw new
|
|
3905
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3890
3906
|
error: errorData,
|
|
3891
3907
|
code: "HTTP_ERROR",
|
|
3892
3908
|
metadata: {
|
|
@@ -3898,13 +3914,13 @@ var getFile = async (config, id, privacy) => {
|
|
|
3898
3914
|
const resData = res.data;
|
|
3899
3915
|
return resData;
|
|
3900
3916
|
} catch (error) {
|
|
3901
|
-
if (error instanceof
|
|
3917
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3902
3918
|
throw error;
|
|
3903
3919
|
}
|
|
3904
3920
|
if (error instanceof Error) {
|
|
3905
|
-
throw new
|
|
3921
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing getGroup: ${error.message}`);
|
|
3906
3922
|
}
|
|
3907
|
-
throw new
|
|
3923
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3908
3924
|
"An unknown error occurred while getting info for a group"
|
|
3909
3925
|
);
|
|
3910
3926
|
}
|
|
@@ -4086,7 +4102,7 @@ var FilterQueue = class {
|
|
|
4086
4102
|
// src/core/classes/files/PublicFiles.ts
|
|
4087
4103
|
var PublicFiles = class {
|
|
4088
4104
|
constructor(config) {
|
|
4089
|
-
this.config =
|
|
4105
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
4090
4106
|
}
|
|
4091
4107
|
list() {
|
|
4092
4108
|
return new FilterFiles(this.config, "public");
|
|
@@ -4120,7 +4136,7 @@ var PublicFiles = class {
|
|
|
4120
4136
|
// src/core/classes/files/PrivateFiles.ts
|
|
4121
4137
|
var PrivateFiles = class {
|
|
4122
4138
|
constructor(config) {
|
|
4123
|
-
this.config =
|
|
4139
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
4124
4140
|
}
|
|
4125
4141
|
list() {
|
|
4126
4142
|
return new FilterFiles(this.config, "private");
|
|
@@ -4157,7 +4173,7 @@ var PrivateFiles = class {
|
|
|
4157
4173
|
// src/core/classes/files/Files.ts
|
|
4158
4174
|
var Files = class {
|
|
4159
4175
|
constructor(config) {
|
|
4160
|
-
this.config =
|
|
4176
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
4161
4177
|
this.public = new PublicFiles(config);
|
|
4162
4178
|
this.private = new PrivateFiles(config);
|
|
4163
4179
|
}
|
|
@@ -4251,7 +4267,7 @@ var UploadBuilder = class {
|
|
|
4251
4267
|
// src/core/classes/uploads/PublicUpload.ts
|
|
4252
4268
|
var PublicUpload = class {
|
|
4253
4269
|
constructor(config) {
|
|
4254
|
-
this.config =
|
|
4270
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
4255
4271
|
}
|
|
4256
4272
|
updateConfig(newConfig) {
|
|
4257
4273
|
this.config = newConfig;
|
|
@@ -4312,7 +4328,7 @@ var PublicUpload = class {
|
|
|
4312
4328
|
// src/core/classes/uploads/PrivateUpload.ts
|
|
4313
4329
|
var PrivateUpload = class {
|
|
4314
4330
|
constructor(config) {
|
|
4315
|
-
this.config =
|
|
4331
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
4316
4332
|
}
|
|
4317
4333
|
updateConfig(newConfig) {
|
|
4318
4334
|
this.config = newConfig;
|
|
@@ -4370,7 +4386,7 @@ var PrivateUpload = class {
|
|
|
4370
4386
|
// src/core/classes/uploads/Upload.ts
|
|
4371
4387
|
var Upload = class {
|
|
4372
4388
|
constructor(config) {
|
|
4373
|
-
this.config =
|
|
4389
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
4374
4390
|
this.public = new PublicUpload(config);
|
|
4375
4391
|
this.private = new PrivateUpload(config);
|
|
4376
4392
|
}
|
|
@@ -4382,7 +4398,7 @@ var Upload = class {
|
|
|
4382
4398
|
// src/core/functions/signatures/addSignature.ts
|
|
4383
4399
|
var addSignature = async (config, options, network) => {
|
|
4384
4400
|
if (!config) {
|
|
4385
|
-
throw new
|
|
4401
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
4386
4402
|
}
|
|
4387
4403
|
const data = JSON.stringify({
|
|
4388
4404
|
signature: options.signature,
|
|
@@ -4414,7 +4430,7 @@ var addSignature = async (config, options, network) => {
|
|
|
4414
4430
|
if (!request.ok) {
|
|
4415
4431
|
const errorData = await request.text();
|
|
4416
4432
|
if (request.status === 401 || request.status === 403) {
|
|
4417
|
-
throw new
|
|
4433
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
4418
4434
|
`Authentication failed: ${errorData}`,
|
|
4419
4435
|
request.status,
|
|
4420
4436
|
{
|
|
@@ -4427,7 +4443,7 @@ var addSignature = async (config, options, network) => {
|
|
|
4427
4443
|
);
|
|
4428
4444
|
}
|
|
4429
4445
|
if (request.status === 403) {
|
|
4430
|
-
throw new
|
|
4446
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
4431
4447
|
"Unauthorized signing, you must be the original owner of the file and it must not have a signature",
|
|
4432
4448
|
request.status,
|
|
4433
4449
|
{
|
|
@@ -4439,7 +4455,7 @@ var addSignature = async (config, options, network) => {
|
|
|
4439
4455
|
}
|
|
4440
4456
|
);
|
|
4441
4457
|
}
|
|
4442
|
-
throw new
|
|
4458
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
4443
4459
|
error: errorData,
|
|
4444
4460
|
code: "HTTP_ERROR",
|
|
4445
4461
|
metadata: {
|
|
@@ -4450,13 +4466,13 @@ var addSignature = async (config, options, network) => {
|
|
|
4450
4466
|
const res = await request.json();
|
|
4451
4467
|
return res.data;
|
|
4452
4468
|
} catch (error) {
|
|
4453
|
-
if (error instanceof
|
|
4469
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
4454
4470
|
throw error;
|
|
4455
4471
|
}
|
|
4456
4472
|
if (error instanceof Error) {
|
|
4457
|
-
throw new
|
|
4473
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing addSignature: ${error.message}`);
|
|
4458
4474
|
}
|
|
4459
|
-
throw new
|
|
4475
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
4460
4476
|
"An unknown error occurred while adding signature to CID"
|
|
4461
4477
|
);
|
|
4462
4478
|
}
|
|
@@ -4465,7 +4481,7 @@ var addSignature = async (config, options, network) => {
|
|
|
4465
4481
|
// src/core/functions/signatures/getSignature.ts
|
|
4466
4482
|
var getSignature = async (config, cid, network) => {
|
|
4467
4483
|
if (!config) {
|
|
4468
|
-
throw new
|
|
4484
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
4469
4485
|
}
|
|
4470
4486
|
let headers;
|
|
4471
4487
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -4492,7 +4508,7 @@ var getSignature = async (config, cid, network) => {
|
|
|
4492
4508
|
if (!request.ok) {
|
|
4493
4509
|
const errorData = await request.text();
|
|
4494
4510
|
if (request.status === 401 || request.status === 403) {
|
|
4495
|
-
throw new
|
|
4511
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
4496
4512
|
`Authentication failed: ${errorData}`,
|
|
4497
4513
|
request.status,
|
|
4498
4514
|
{
|
|
@@ -4504,7 +4520,7 @@ var getSignature = async (config, cid, network) => {
|
|
|
4504
4520
|
}
|
|
4505
4521
|
);
|
|
4506
4522
|
}
|
|
4507
|
-
throw new
|
|
4523
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
4508
4524
|
error: errorData,
|
|
4509
4525
|
code: "HTTP_ERROR",
|
|
4510
4526
|
metadata: {
|
|
@@ -4515,13 +4531,13 @@ var getSignature = async (config, cid, network) => {
|
|
|
4515
4531
|
const res = await request.json();
|
|
4516
4532
|
return res.data;
|
|
4517
4533
|
} catch (error) {
|
|
4518
|
-
if (error instanceof
|
|
4534
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
4519
4535
|
throw error;
|
|
4520
4536
|
}
|
|
4521
4537
|
if (error instanceof Error) {
|
|
4522
|
-
throw new
|
|
4538
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing getSignature: ${error.message}`);
|
|
4523
4539
|
}
|
|
4524
|
-
throw new
|
|
4540
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
4525
4541
|
"An unknown error occurred while fetching signature for CID"
|
|
4526
4542
|
);
|
|
4527
4543
|
}
|
|
@@ -4530,7 +4546,7 @@ var getSignature = async (config, cid, network) => {
|
|
|
4530
4546
|
// src/core/functions/signatures/removeSignature.ts
|
|
4531
4547
|
var removeSignature = async (config, cid, network) => {
|
|
4532
4548
|
if (!config) {
|
|
4533
|
-
throw new
|
|
4549
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
4534
4550
|
}
|
|
4535
4551
|
let headers;
|
|
4536
4552
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
@@ -4557,7 +4573,7 @@ var removeSignature = async (config, cid, network) => {
|
|
|
4557
4573
|
if (!request.ok) {
|
|
4558
4574
|
const errorData = await request.text();
|
|
4559
4575
|
if (request.status === 401 || request.status === 403) {
|
|
4560
|
-
throw new
|
|
4576
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
4561
4577
|
`Authentication failed: ${errorData}`,
|
|
4562
4578
|
request.status,
|
|
4563
4579
|
{
|
|
@@ -4569,7 +4585,7 @@ var removeSignature = async (config, cid, network) => {
|
|
|
4569
4585
|
}
|
|
4570
4586
|
);
|
|
4571
4587
|
}
|
|
4572
|
-
throw new
|
|
4588
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
4573
4589
|
error: errorData,
|
|
4574
4590
|
code: "HTTP_ERROR",
|
|
4575
4591
|
metadata: {
|
|
@@ -4579,13 +4595,13 @@ var removeSignature = async (config, cid, network) => {
|
|
|
4579
4595
|
}
|
|
4580
4596
|
return "OK";
|
|
4581
4597
|
} catch (error) {
|
|
4582
|
-
if (error instanceof
|
|
4598
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
4583
4599
|
throw error;
|
|
4584
4600
|
}
|
|
4585
4601
|
if (error instanceof Error) {
|
|
4586
|
-
throw new
|
|
4602
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing addSignature: ${error.message}`);
|
|
4587
4603
|
}
|
|
4588
|
-
throw new
|
|
4604
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
4589
4605
|
"An unknown error occurred while adding signature to CID"
|
|
4590
4606
|
);
|
|
4591
4607
|
}
|
|
@@ -4594,7 +4610,7 @@ var removeSignature = async (config, cid, network) => {
|
|
|
4594
4610
|
// src/core/classes/signatures/PublicSignatures.ts
|
|
4595
4611
|
var PublicSignatures = class {
|
|
4596
4612
|
constructor(config) {
|
|
4597
|
-
this.config =
|
|
4613
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
4598
4614
|
}
|
|
4599
4615
|
updateConfig(newConfig) {
|
|
4600
4616
|
this.config = newConfig;
|
|
@@ -4614,7 +4630,7 @@ var PublicSignatures = class {
|
|
|
4614
4630
|
var Signatures = class {
|
|
4615
4631
|
//private: PrivateSignatures
|
|
4616
4632
|
constructor(config) {
|
|
4617
|
-
this.config =
|
|
4633
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
4618
4634
|
this.public = new PublicSignatures(config);
|
|
4619
4635
|
}
|
|
4620
4636
|
updateConfig(newConfig) {
|
|
@@ -4625,7 +4641,7 @@ var Signatures = class {
|
|
|
4625
4641
|
// src/core/pinataSDK.ts
|
|
4626
4642
|
var PinataSDK = class {
|
|
4627
4643
|
constructor(config) {
|
|
4628
|
-
this.config =
|
|
4644
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
4629
4645
|
this.files = new Files(this.config);
|
|
4630
4646
|
this.upload = new Upload(this.config);
|
|
4631
4647
|
this.gateways = new Gateways(this.config);
|
|
@@ -4667,43 +4683,35 @@ var PinataSDK = class {
|
|
|
4667
4683
|
|
|
4668
4684
|
Object.defineProperty(exports, "AuthenticationError", {
|
|
4669
4685
|
enumerable: true,
|
|
4670
|
-
get: function () { return
|
|
4686
|
+
get: function () { return chunkBK3CLF3Z_js.AuthenticationError; }
|
|
4671
4687
|
});
|
|
4672
4688
|
Object.defineProperty(exports, "NetworkError", {
|
|
4673
4689
|
enumerable: true,
|
|
4674
|
-
get: function () { return
|
|
4690
|
+
get: function () { return chunkBK3CLF3Z_js.NetworkError; }
|
|
4675
4691
|
});
|
|
4676
4692
|
Object.defineProperty(exports, "PinataError", {
|
|
4677
4693
|
enumerable: true,
|
|
4678
|
-
get: function () { return
|
|
4694
|
+
get: function () { return chunkBK3CLF3Z_js.PinataError; }
|
|
4679
4695
|
});
|
|
4680
4696
|
Object.defineProperty(exports, "ValidationError", {
|
|
4681
4697
|
enumerable: true,
|
|
4682
|
-
get: function () { return
|
|
4698
|
+
get: function () { return chunkBK3CLF3Z_js.ValidationError; }
|
|
4683
4699
|
});
|
|
4684
4700
|
Object.defineProperty(exports, "containsCID", {
|
|
4685
4701
|
enumerable: true,
|
|
4686
|
-
get: function () { return
|
|
4687
|
-
});
|
|
4688
|
-
Object.defineProperty(exports, "convert", {
|
|
4689
|
-
enumerable: true,
|
|
4690
|
-
get: function () { return chunkP556VRQU_js.convertToDesiredGateway; }
|
|
4702
|
+
get: function () { return chunkBK3CLF3Z_js.containsCID; }
|
|
4691
4703
|
});
|
|
4692
4704
|
Object.defineProperty(exports, "convertToDesiredGateway", {
|
|
4693
4705
|
enumerable: true,
|
|
4694
|
-
get: function () { return
|
|
4706
|
+
get: function () { return chunkBK3CLF3Z_js.convertToDesiredGateway; }
|
|
4695
4707
|
});
|
|
4696
4708
|
Object.defineProperty(exports, "formatConfig", {
|
|
4697
4709
|
enumerable: true,
|
|
4698
|
-
get: function () { return
|
|
4710
|
+
get: function () { return chunkBK3CLF3Z_js.formatConfig; }
|
|
4699
4711
|
});
|
|
4700
4712
|
Object.defineProperty(exports, "getFileIdFromUrl", {
|
|
4701
4713
|
enumerable: true,
|
|
4702
|
-
get: function () { return
|
|
4703
|
-
});
|
|
4704
|
-
Object.defineProperty(exports, "useUpload", {
|
|
4705
|
-
enumerable: true,
|
|
4706
|
-
get: function () { return chunkP556VRQU_js.useUpload; }
|
|
4714
|
+
get: function () { return chunkBK3CLF3Z_js.getFileIdFromUrl; }
|
|
4707
4715
|
});
|
|
4708
4716
|
exports.PinataSDK = PinataSDK;
|
|
4709
4717
|
exports.addToGroup = addToGroup;
|