pinata 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -50,16 +50,16 @@ var testAuthentication = async (config) => {
50
50
  headers
51
51
  });
52
52
  if (!request.ok) {
53
- const errorData = await request.json();
54
- if (request.status === 401) {
53
+ const errorData = await request.text();
54
+ if (request.status === 401 || request.status === 403) {
55
55
  throw new AuthenticationError(
56
- "Authentication failed",
56
+ `Authentication failed: ${errorData}`,
57
57
  request.status,
58
58
  errorData
59
59
  );
60
60
  }
61
61
  throw new NetworkError(
62
- `HTTP error! status: ${request.status}`,
62
+ `HTTP error: ${errorData}`,
63
63
  request.status,
64
64
  errorData
65
65
  );
@@ -123,16 +123,16 @@ var uploadFile = async (config, file, options) => {
123
123
  body: data
124
124
  });
125
125
  if (!request.ok) {
126
- const errorData = await request.json();
127
- if (request.status === 401) {
126
+ const errorData = await request.text();
127
+ if (request.status === 401 || request.status === 403) {
128
128
  throw new AuthenticationError(
129
- "Authentication failed",
129
+ `Authentication failed: ${errorData}`,
130
130
  request.status,
131
131
  errorData
132
132
  );
133
133
  }
134
134
  throw new NetworkError(
135
- `HTTP error! status: ${request.status}`,
135
+ `HTTP error: ${errorData}`,
136
136
  request.status,
137
137
  errorData
138
138
  );
@@ -195,16 +195,16 @@ var uploadFileArray = async (config, files, options) => {
195
195
  body: data
196
196
  });
197
197
  if (!request.ok) {
198
- const errorData = await request.json();
199
- if (request.status === 401) {
198
+ const errorData = await request.text();
199
+ if (request.status === 401 || request.status === 403) {
200
200
  throw new AuthenticationError(
201
- "Authentication failed",
201
+ `Authentication failed: ${errorData}`,
202
202
  request.status,
203
203
  errorData
204
204
  );
205
205
  }
206
206
  throw new NetworkError(
207
- `HTTP error! status: ${request.status}`,
207
+ `HTTP error: ${errorData}`,
208
208
  request.status,
209
209
  errorData
210
210
  );
@@ -269,16 +269,16 @@ var uploadBase64 = async (config, base64String, options) => {
269
269
  body: data
270
270
  });
271
271
  if (!request.ok) {
272
- const errorData = await request.json();
273
- if (request.status === 401) {
272
+ const errorData = await request.text();
273
+ if (request.status === 401 || request.status === 403) {
274
274
  throw new AuthenticationError(
275
- "Authentication failed",
275
+ `Authentication failed: ${errorData}`,
276
276
  request.status,
277
277
  errorData
278
278
  );
279
279
  }
280
280
  throw new NetworkError(
281
- `HTTP error! status: ${request.status}`,
281
+ `HTTP error: ${errorData}`,
282
282
  request.status,
283
283
  errorData
284
284
  );
@@ -307,9 +307,9 @@ var uploadUrl = async (config, url, options) => {
307
307
  const data = new FormData();
308
308
  const stream = await fetch(url);
309
309
  if (!stream.ok) {
310
- const errorData = await stream.json();
310
+ const errorData = await stream.text();
311
311
  throw new NetworkError(
312
- `HTTP error! status: ${stream.status}`,
312
+ `HTTP error: ${errorData}`,
313
313
  stream.status,
314
314
  errorData
315
315
  );
@@ -353,16 +353,16 @@ var uploadUrl = async (config, url, options) => {
353
353
  body: data
354
354
  });
355
355
  if (!request.ok) {
356
- const errorData = await request.json();
357
- if (request.status === 401) {
356
+ const errorData = await request.text();
357
+ if (request.status === 401 || request.status === 403) {
358
358
  throw new AuthenticationError(
359
- "Authentication failed",
359
+ `Authentication failed: ${errorData}`,
360
360
  request.status,
361
361
  errorData
362
362
  );
363
363
  }
364
364
  throw new NetworkError(
365
- `HTTP error! status: ${request.status}`,
365
+ `HTTP error: ${errorData}`,
366
366
  request.status,
367
367
  errorData
368
368
  );
@@ -418,16 +418,16 @@ var uploadJson = async (config, jsonData, options) => {
418
418
  body: data
419
419
  });
420
420
  if (!request.ok) {
421
- const errorData = await request.json();
422
- if (request.status === 401) {
421
+ const errorData = await request.text();
422
+ if (request.status === 401 || request.status === 403) {
423
423
  throw new AuthenticationError(
424
- "Authentication failed",
424
+ `Authentication failed: ${errorData}`,
425
425
  request.status,
426
426
  errorData
427
427
  );
428
428
  }
429
429
  throw new NetworkError(
430
- `HTTP error! status: ${request.status}`,
430
+ `HTTP error: ${errorData}`,
431
431
  request.status,
432
432
  errorData
433
433
  );
@@ -483,16 +483,16 @@ var uploadCid = async (config, cid, options) => {
483
483
  body: data
484
484
  });
485
485
  if (!request.ok) {
486
- const errorData = await request.json();
487
- if (request.status === 401) {
486
+ const errorData = await request.text();
487
+ if (request.status === 401 || request.status === 403) {
488
488
  throw new AuthenticationError(
489
- "Authentication failed",
489
+ `Authentication failed: ${errorData}`,
490
490
  request.status,
491
491
  errorData
492
492
  );
493
493
  }
494
494
  throw new NetworkError(
495
- `HTTP error! status: ${request.status}`,
495
+ `HTTP error: ${errorData}`,
496
496
  request.status,
497
497
  errorData
498
498
  );
@@ -542,16 +542,16 @@ var unpinFile = async (config, files) => {
542
542
  });
543
543
  await wait(300);
544
544
  if (!response.ok) {
545
- const errorData = await response.json();
545
+ const errorData = await response.text();
546
546
  if (response.status === 401) {
547
547
  throw new AuthenticationError(
548
- "Authentication failed",
548
+ `Authentication failed: ${errorData}`,
549
549
  response.status,
550
550
  errorData
551
551
  );
552
552
  }
553
553
  throw new NetworkError(
554
- `HTTP error! status: ${response.status}`,
554
+ `HTTP error: ${errorData}`,
555
555
  response.status,
556
556
  errorData
557
557
  );
@@ -647,16 +647,16 @@ var listFiles = async (config, options) => {
647
647
  headers
648
648
  });
649
649
  if (!request.ok) {
650
- const errorData = await request.json();
651
- if (request.status === 401) {
650
+ const errorData = await request.text();
651
+ if (request.status === 401 || request.status === 403) {
652
652
  throw new AuthenticationError(
653
- "Authentication failed",
653
+ `Authentication failed: ${errorData}`,
654
654
  request.status,
655
655
  errorData
656
656
  );
657
657
  }
658
658
  throw new NetworkError(
659
- `HTTP error! status: ${request.status}`,
659
+ `HTTP error: ${errorData}`,
660
660
  request.status,
661
661
  errorData
662
662
  );
@@ -705,16 +705,16 @@ var updateMetadata = async (config, options) => {
705
705
  body: JSON.stringify(data)
706
706
  });
707
707
  if (!request.ok) {
708
- const errorData = await request.json();
709
- if (request.status === 401) {
708
+ const errorData = await request.text();
709
+ if (request.status === 401 || request.status === 403) {
710
710
  throw new AuthenticationError(
711
- "Authentication failed",
711
+ `Authentication failed: ${errorData}`,
712
712
  request.status,
713
713
  errorData
714
714
  );
715
715
  }
716
716
  throw new NetworkError(
717
- `HTTP error! status: ${request.status}`,
717
+ `HTTP error: ${errorData}`,
718
718
  request.status,
719
719
  errorData
720
720
  );
@@ -842,16 +842,16 @@ var getCid = async (config, cid) => {
842
842
  try {
843
843
  const request = await fetch(newUrl);
844
844
  if (!request.ok) {
845
- const errorData = await request.json();
846
- if (request.status === 401) {
845
+ const errorData = await request.text();
846
+ if (request.status === 401 || request.status === 403) {
847
847
  throw new AuthenticationError(
848
- "Authentication failed",
848
+ `Authentication Failed: ${errorData}`,
849
849
  request.status,
850
850
  errorData
851
851
  );
852
852
  }
853
853
  throw new NetworkError(
854
- `HTTP error! status: ${request.status}`,
854
+ `HTTP error: ${errorData}`,
855
855
  request.status,
856
856
  errorData
857
857
  );
@@ -933,16 +933,16 @@ var pinJobs = async (config, options) => {
933
933
  headers
934
934
  });
935
935
  if (!request.ok) {
936
- const errorData = await request.json();
937
- if (request.status === 401) {
936
+ const errorData = await request.text();
937
+ if (request.status === 401 || request.status === 403) {
938
938
  throw new AuthenticationError(
939
- "Authentication failed",
939
+ `Authentication failed: ${errorData}`,
940
940
  request.status,
941
941
  errorData
942
942
  );
943
943
  }
944
944
  throw new NetworkError(
945
- `HTTP error! status: ${request.status}`,
945
+ `HTTP error: ${errorData}`,
946
946
  request.status,
947
947
  errorData
948
948
  );
@@ -984,16 +984,16 @@ var pinnedFileCount = async (config) => {
984
984
  headers
985
985
  });
986
986
  if (!request.ok) {
987
- const errorData = await request.json();
988
- if (request.status === 401) {
987
+ const errorData = await request.text();
988
+ if (request.status === 401 || request.status === 403) {
989
989
  throw new AuthenticationError(
990
- "Authentication failed",
990
+ `Authentication failed: ${errorData}`,
991
991
  request.status,
992
992
  errorData
993
993
  );
994
994
  }
995
995
  throw new NetworkError(
996
- `HTTP error! status: ${request.status}`,
996
+ `HTTP error: ${errorData}`,
997
997
  request.status,
998
998
  errorData
999
999
  );
@@ -1039,16 +1039,16 @@ var totalStorageUsage = async (config) => {
1039
1039
  headers
1040
1040
  });
1041
1041
  if (!request.ok) {
1042
- const errorData = await request.json();
1043
- if (request.status === 401) {
1042
+ const errorData = await request.text();
1043
+ if (request.status === 401 || request.status === 403) {
1044
1044
  throw new AuthenticationError(
1045
- "Authentication failed",
1045
+ `Authentication failed: ${errorData}`,
1046
1046
  request.status,
1047
1047
  errorData
1048
1048
  );
1049
1049
  }
1050
1050
  throw new NetworkError(
1051
- `HTTP error! status: ${request.status}`,
1051
+ `HTTP error: ${errorData}`,
1052
1052
  request.status,
1053
1053
  errorData
1054
1054
  );
@@ -1097,16 +1097,16 @@ var createKey = async (config, options) => {
1097
1097
  body: data
1098
1098
  });
1099
1099
  if (!request.ok) {
1100
- const errorData = await request.json();
1101
- if (request.status === 401) {
1100
+ const errorData = await request.text();
1101
+ if (request.status === 401 || request.status === 403) {
1102
1102
  throw new AuthenticationError(
1103
- "Authentication failed",
1103
+ `Authentication failed: ${errorData}`,
1104
1104
  request.status,
1105
1105
  errorData
1106
1106
  );
1107
1107
  }
1108
1108
  throw new NetworkError(
1109
- `HTTP error! status: ${request.status}`,
1109
+ `HTTP error: ${errorData}`,
1110
1110
  request.status,
1111
1111
  errorData
1112
1112
  );
@@ -1166,16 +1166,16 @@ var listKeys = async (config, options) => {
1166
1166
  }
1167
1167
  );
1168
1168
  if (!request.ok) {
1169
- const errorData = await request.json();
1170
- if (request.status === 401) {
1169
+ const errorData = await request.text();
1170
+ if (request.status === 401 || request.status === 403) {
1171
1171
  throw new AuthenticationError(
1172
- "Authentication failed",
1172
+ `Authentication failed: ${errorData}`,
1173
1173
  request.status,
1174
1174
  errorData
1175
1175
  );
1176
1176
  }
1177
1177
  throw new NetworkError(
1178
- `HTTP error! status: ${request.status}`,
1178
+ `HTTP error: ${errorData}`,
1179
1179
  request.status,
1180
1180
  errorData
1181
1181
  );
@@ -1226,16 +1226,16 @@ var revokeKeys = async (config, keys) => {
1226
1226
  });
1227
1227
  await wait2(300);
1228
1228
  if (!request.ok) {
1229
- const errorData = await request.json();
1230
- if (request.status === 401) {
1229
+ const errorData = await request.text();
1230
+ if (request.status === 401 || request.status === 403) {
1231
1231
  throw new AuthenticationError(
1232
- "Authentication failed",
1232
+ `Authentication failed: ${errorData}`,
1233
1233
  request.status,
1234
1234
  errorData
1235
1235
  );
1236
1236
  }
1237
1237
  throw new NetworkError(
1238
- `HTTP error! status: ${request.status}`,
1238
+ `HTTP error: ${errorData}`,
1239
1239
  request.status,
1240
1240
  errorData
1241
1241
  );
@@ -1290,16 +1290,16 @@ var createGroup = async (config, options) => {
1290
1290
  body: data
1291
1291
  });
1292
1292
  if (!request.ok) {
1293
- const errorData = await request.json();
1294
- if (request.status === 401) {
1293
+ const errorData = await request.text();
1294
+ if (request.status === 401 || request.status === 403) {
1295
1295
  throw new AuthenticationError(
1296
- "Authentication failed",
1296
+ `Authentication failed: ${errorData}`,
1297
1297
  request.status,
1298
1298
  errorData
1299
1299
  );
1300
1300
  }
1301
1301
  throw new NetworkError(
1302
- `HTTP error! status: ${request.status}`,
1302
+ `HTTP error: ${errorData}`,
1303
1303
  request.status,
1304
1304
  errorData
1305
1305
  );
@@ -1352,16 +1352,16 @@ var listGroups = async (config, options) => {
1352
1352
  headers
1353
1353
  });
1354
1354
  if (!request.ok) {
1355
- const errorData = await request.json();
1356
- if (request.status === 401) {
1355
+ const errorData = await request.text();
1356
+ if (request.status === 401 || request.status === 403) {
1357
1357
  throw new AuthenticationError(
1358
- "Authentication failed",
1358
+ `Authentication failed: ${errorData}`,
1359
1359
  request.status,
1360
1360
  errorData
1361
1361
  );
1362
1362
  }
1363
1363
  throw new NetworkError(
1364
- `HTTP error! status: ${request.status}`,
1364
+ `HTTP error: ${errorData}`,
1365
1365
  request.status,
1366
1366
  errorData
1367
1367
  );
@@ -1404,16 +1404,16 @@ var getGroup = async (config, options) => {
1404
1404
  headers
1405
1405
  });
1406
1406
  if (!request.ok) {
1407
- const errorData = await request.json();
1408
- if (request.status === 401) {
1407
+ const errorData = await request.text();
1408
+ if (request.status === 401 || request.status === 403) {
1409
1409
  throw new AuthenticationError(
1410
- "Authentication failed",
1410
+ `Authentication failed: ${errorData}`,
1411
1411
  request.status,
1412
1412
  errorData
1413
1413
  );
1414
1414
  }
1415
1415
  throw new NetworkError(
1416
- `HTTP error! status: ${request.status}`,
1416
+ `HTTP error: ${errorData}`,
1417
1417
  request.status,
1418
1418
  errorData
1419
1419
  );
@@ -1462,16 +1462,16 @@ var addToGroup = async (config, options) => {
1462
1462
  body: data
1463
1463
  });
1464
1464
  if (!request.ok) {
1465
- const errorData = await request.json();
1466
- if (request.status === 401) {
1465
+ const errorData = await request.text();
1466
+ if (request.status === 401 || request.status === 403) {
1467
1467
  throw new AuthenticationError(
1468
- "Authentication failed",
1468
+ `Authentication failed: ${errorData}`,
1469
1469
  request.status,
1470
1470
  errorData
1471
1471
  );
1472
1472
  }
1473
1473
  throw new NetworkError(
1474
- `HTTP error! status: ${request.status}`,
1474
+ `HTTP error: ${errorData}`,
1475
1475
  request.status,
1476
1476
  errorData
1477
1477
  );
@@ -1520,16 +1520,16 @@ var updateGroup = async (config, options) => {
1520
1520
  body: data
1521
1521
  });
1522
1522
  if (!request.ok) {
1523
- const errorData = await request.json();
1524
- if (request.status === 401) {
1523
+ const errorData = await request.text();
1524
+ if (request.status === 401 || request.status === 403) {
1525
1525
  throw new AuthenticationError(
1526
- "Authentication failed",
1526
+ `Authentication failed: ${errorData}`,
1527
1527
  request.status,
1528
1528
  errorData
1529
1529
  );
1530
1530
  }
1531
1531
  throw new NetworkError(
1532
- `HTTP error! status: ${request.status}`,
1532
+ `HTTP error: ${errorData}`,
1533
1533
  request.status,
1534
1534
  errorData
1535
1535
  );
@@ -1576,16 +1576,16 @@ var removeFromGroup = async (config, options) => {
1576
1576
  body: data
1577
1577
  });
1578
1578
  if (!request.ok) {
1579
- const errorData = await request.json();
1580
- if (request.status === 401) {
1579
+ const errorData = await request.text();
1580
+ if (request.status === 401 || request.status === 403) {
1581
1581
  throw new AuthenticationError(
1582
- "Authentication failed",
1582
+ `Authentication failed: ${errorData}`,
1583
1583
  request.status,
1584
1584
  errorData
1585
1585
  );
1586
1586
  }
1587
1587
  throw new NetworkError(
1588
- `HTTP error! status: ${request.status}`,
1588
+ `HTTP error: ${errorData}`,
1589
1589
  request.status,
1590
1590
  errorData
1591
1591
  );
@@ -1632,16 +1632,16 @@ var deleteGroup = async (config, options) => {
1632
1632
  headers
1633
1633
  });
1634
1634
  if (!request.ok) {
1635
- const errorData = await request.json();
1636
- if (request.status === 401) {
1635
+ const errorData = await request.text();
1636
+ if (request.status === 401 || request.status === 403) {
1637
1637
  throw new AuthenticationError(
1638
- "Authentication failed",
1638
+ `Authentication failed: ${errorData}`,
1639
1639
  request.status,
1640
1640
  errorData
1641
1641
  );
1642
1642
  }
1643
1643
  throw new NetworkError(
1644
- `HTTP error! status: ${request.status}`,
1644
+ `HTTP error: ${errorData}`,
1645
1645
  request.status,
1646
1646
  errorData
1647
1647
  );
@@ -1691,10 +1691,10 @@ var addSignature = async (config, options) => {
1691
1691
  }
1692
1692
  );
1693
1693
  if (!request.ok) {
1694
- const errorData = await request.json();
1695
- if (request.status === 401) {
1694
+ const errorData = await request.text();
1695
+ if (request.status === 401 || request.status === 403) {
1696
1696
  throw new AuthenticationError(
1697
- "Authentication failed",
1697
+ `Authentication failed: ${errorData}`,
1698
1698
  request.status,
1699
1699
  errorData
1700
1700
  );
@@ -1707,7 +1707,7 @@ var addSignature = async (config, options) => {
1707
1707
  );
1708
1708
  }
1709
1709
  throw new NetworkError(
1710
- `HTTP error! status: ${request.status}`,
1710
+ `HTTP error: ${errorData}`,
1711
1711
  request.status,
1712
1712
  errorData
1713
1713
  );
@@ -1752,16 +1752,16 @@ var getSignature = async (config, cid) => {
1752
1752
  headers
1753
1753
  });
1754
1754
  if (!request.ok) {
1755
- const errorData = await request.json();
1756
- if (request.status === 401) {
1755
+ const errorData = await request.text();
1756
+ if (request.status === 401 || request.status === 403) {
1757
1757
  throw new AuthenticationError(
1758
- "Authentication failed",
1758
+ `Authentication failed: ${errorData}`,
1759
1759
  request.status,
1760
1760
  errorData
1761
1761
  );
1762
1762
  }
1763
1763
  throw new NetworkError(
1764
- `HTTP error! status: ${request.status}`,
1764
+ `HTTP error: ${errorData}`,
1765
1765
  request.status,
1766
1766
  errorData
1767
1767
  );
@@ -1806,16 +1806,16 @@ var removeSignature = async (config, cid) => {
1806
1806
  headers
1807
1807
  });
1808
1808
  if (!request.ok) {
1809
- const errorData = await request.json();
1810
- if (request.status === 401) {
1809
+ const errorData = await request.text();
1810
+ if (request.status === 401 || request.status === 403) {
1811
1811
  throw new AuthenticationError(
1812
- "Authentication failed",
1812
+ `Authentication failed: ${errorData}`,
1813
1813
  request.status,
1814
1814
  errorData
1815
1815
  );
1816
1816
  }
1817
1817
  throw new NetworkError(
1818
- `HTTP error! status: ${request.status}`,
1818
+ `HTTP error: ${errorData}`,
1819
1819
  request.status,
1820
1820
  errorData
1821
1821
  );
@@ -1905,16 +1905,16 @@ var analyticsTopUsage = async (config, options) => {
1905
1905
  headers
1906
1906
  });
1907
1907
  if (!request.ok) {
1908
- const errorData = await request.json();
1909
- if (request.status === 401) {
1908
+ const errorData = await request.text();
1909
+ if (request.status === 401 || request.status === 403) {
1910
1910
  throw new AuthenticationError(
1911
- "Authentication failed",
1911
+ `Authentication failed: ${errorData}`,
1912
1912
  request.status,
1913
1913
  errorData
1914
1914
  );
1915
1915
  }
1916
1916
  throw new NetworkError(
1917
- `HTTP error! status: ${request.status}`,
1917
+ `HTTP error: ${errorData}`,
1918
1918
  request.status,
1919
1919
  errorData
1920
1920
  );
@@ -2006,16 +2006,16 @@ var analyticsDateInterval = async (config, options) => {
2006
2006
  headers
2007
2007
  });
2008
2008
  if (!request.ok) {
2009
- const errorData = await request.json();
2010
- if (request.status === 401) {
2009
+ const errorData = await request.text();
2010
+ if (request.status === 401 || request.status === 403) {
2011
2011
  throw new AuthenticationError(
2012
- "Authentication failed",
2012
+ `Authentication failed: ${errorData}`,
2013
2013
  request.status,
2014
2014
  errorData
2015
2015
  );
2016
2016
  }
2017
2017
  throw new NetworkError(
2018
- `HTTP error! status: ${request.status}`,
2018
+ `HTTP error: ${errorData}`,
2019
2019
  request.status,
2020
2020
  errorData
2021
2021
  );
@@ -2067,10 +2067,10 @@ var swapCid = async (config, options) => {
2067
2067
  body: data
2068
2068
  });
2069
2069
  if (!request.ok) {
2070
- const errorData = await request.json();
2071
- if (request.status === 401) {
2070
+ const errorData = await request.text();
2071
+ if (request.status === 401 || request.status === 403) {
2072
2072
  throw new AuthenticationError(
2073
- "Authentication failed",
2073
+ `Authentication failed: ${errorData}`,
2074
2074
  request.status,
2075
2075
  errorData
2076
2076
  );
@@ -2090,7 +2090,7 @@ var swapCid = async (config, options) => {
2090
2090
  );
2091
2091
  }
2092
2092
  throw new NetworkError(
2093
- `HTTP error! status: ${request.status}`,
2093
+ `HTTP error: ${errorData}`,
2094
2094
  request.status,
2095
2095
  errorData
2096
2096
  );
@@ -2137,10 +2137,10 @@ var swapHistory = async (config, options) => {
2137
2137
  }
2138
2138
  );
2139
2139
  if (!request.ok) {
2140
- const errorData = await request.json();
2141
- if (request.status === 401) {
2140
+ const errorData = await request.text();
2141
+ if (request.status === 401 || request.status === 403) {
2142
2142
  throw new AuthenticationError(
2143
- "Authentication failed",
2143
+ `Authentication failed: ${errorData}`,
2144
2144
  request.status,
2145
2145
  errorData
2146
2146
  );
@@ -2153,7 +2153,7 @@ var swapHistory = async (config, options) => {
2153
2153
  );
2154
2154
  }
2155
2155
  throw new NetworkError(
2156
- `HTTP error! status: ${request.status}`,
2156
+ `HTTP error: ${errorData}`,
2157
2157
  request.status,
2158
2158
  errorData
2159
2159
  );
@@ -2199,10 +2199,10 @@ var deleteSwap = async (config, cid) => {
2199
2199
  headers
2200
2200
  });
2201
2201
  if (!request.ok) {
2202
- const errorData = await request.json();
2203
- if (request.status === 401) {
2202
+ const errorData = await request.text();
2203
+ if (request.status === 401 || request.status === 403) {
2204
2204
  throw new AuthenticationError(
2205
- "Authentication failed",
2205
+ `Authentication failed: ${errorData}`,
2206
2206
  request.status,
2207
2207
  errorData
2208
2208
  );
@@ -2222,7 +2222,7 @@ var deleteSwap = async (config, cid) => {
2222
2222
  );
2223
2223
  }
2224
2224
  throw new NetworkError(
2225
- `HTTP error! status: ${request.status}`,
2225
+ `HTTP error: ${errorData}`,
2226
2226
  request.status,
2227
2227
  errorData
2228
2228
  );