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.js CHANGED
@@ -86,16 +86,16 @@ var testAuthentication = async (config) => {
86
86
  headers
87
87
  });
88
88
  if (!request.ok) {
89
- const errorData = await request.json();
90
- if (request.status === 401) {
89
+ const errorData = await request.text();
90
+ if (request.status === 401 || request.status === 403) {
91
91
  throw new AuthenticationError(
92
- "Authentication failed",
92
+ `Authentication failed: ${errorData}`,
93
93
  request.status,
94
94
  errorData
95
95
  );
96
96
  }
97
97
  throw new NetworkError(
98
- `HTTP error! status: ${request.status}`,
98
+ `HTTP error: ${errorData}`,
99
99
  request.status,
100
100
  errorData
101
101
  );
@@ -159,16 +159,16 @@ var uploadFile = async (config, file, options) => {
159
159
  body: data
160
160
  });
161
161
  if (!request.ok) {
162
- const errorData = await request.json();
163
- if (request.status === 401) {
162
+ const errorData = await request.text();
163
+ if (request.status === 401 || request.status === 403) {
164
164
  throw new AuthenticationError(
165
- "Authentication failed",
165
+ `Authentication failed: ${errorData}`,
166
166
  request.status,
167
167
  errorData
168
168
  );
169
169
  }
170
170
  throw new NetworkError(
171
- `HTTP error! status: ${request.status}`,
171
+ `HTTP error: ${errorData}`,
172
172
  request.status,
173
173
  errorData
174
174
  );
@@ -231,16 +231,16 @@ var uploadFileArray = async (config, files, options) => {
231
231
  body: data
232
232
  });
233
233
  if (!request.ok) {
234
- const errorData = await request.json();
235
- if (request.status === 401) {
234
+ const errorData = await request.text();
235
+ if (request.status === 401 || request.status === 403) {
236
236
  throw new AuthenticationError(
237
- "Authentication failed",
237
+ `Authentication failed: ${errorData}`,
238
238
  request.status,
239
239
  errorData
240
240
  );
241
241
  }
242
242
  throw new NetworkError(
243
- `HTTP error! status: ${request.status}`,
243
+ `HTTP error: ${errorData}`,
244
244
  request.status,
245
245
  errorData
246
246
  );
@@ -305,16 +305,16 @@ var uploadBase64 = async (config, base64String, options) => {
305
305
  body: data
306
306
  });
307
307
  if (!request.ok) {
308
- const errorData = await request.json();
309
- if (request.status === 401) {
308
+ const errorData = await request.text();
309
+ if (request.status === 401 || request.status === 403) {
310
310
  throw new AuthenticationError(
311
- "Authentication failed",
311
+ `Authentication failed: ${errorData}`,
312
312
  request.status,
313
313
  errorData
314
314
  );
315
315
  }
316
316
  throw new NetworkError(
317
- `HTTP error! status: ${request.status}`,
317
+ `HTTP error: ${errorData}`,
318
318
  request.status,
319
319
  errorData
320
320
  );
@@ -343,9 +343,9 @@ var uploadUrl = async (config, url, options) => {
343
343
  const data = new FormData();
344
344
  const stream = await fetch(url);
345
345
  if (!stream.ok) {
346
- const errorData = await stream.json();
346
+ const errorData = await stream.text();
347
347
  throw new NetworkError(
348
- `HTTP error! status: ${stream.status}`,
348
+ `HTTP error: ${errorData}`,
349
349
  stream.status,
350
350
  errorData
351
351
  );
@@ -389,16 +389,16 @@ var uploadUrl = async (config, url, options) => {
389
389
  body: data
390
390
  });
391
391
  if (!request.ok) {
392
- const errorData = await request.json();
393
- if (request.status === 401) {
392
+ const errorData = await request.text();
393
+ if (request.status === 401 || request.status === 403) {
394
394
  throw new AuthenticationError(
395
- "Authentication failed",
395
+ `Authentication failed: ${errorData}`,
396
396
  request.status,
397
397
  errorData
398
398
  );
399
399
  }
400
400
  throw new NetworkError(
401
- `HTTP error! status: ${request.status}`,
401
+ `HTTP error: ${errorData}`,
402
402
  request.status,
403
403
  errorData
404
404
  );
@@ -454,16 +454,16 @@ var uploadJson = async (config, jsonData, options) => {
454
454
  body: data
455
455
  });
456
456
  if (!request.ok) {
457
- const errorData = await request.json();
458
- if (request.status === 401) {
457
+ const errorData = await request.text();
458
+ if (request.status === 401 || request.status === 403) {
459
459
  throw new AuthenticationError(
460
- "Authentication failed",
460
+ `Authentication failed: ${errorData}`,
461
461
  request.status,
462
462
  errorData
463
463
  );
464
464
  }
465
465
  throw new NetworkError(
466
- `HTTP error! status: ${request.status}`,
466
+ `HTTP error: ${errorData}`,
467
467
  request.status,
468
468
  errorData
469
469
  );
@@ -519,16 +519,16 @@ var uploadCid = async (config, cid, options) => {
519
519
  body: data
520
520
  });
521
521
  if (!request.ok) {
522
- const errorData = await request.json();
523
- if (request.status === 401) {
522
+ const errorData = await request.text();
523
+ if (request.status === 401 || request.status === 403) {
524
524
  throw new AuthenticationError(
525
- "Authentication failed",
525
+ `Authentication failed: ${errorData}`,
526
526
  request.status,
527
527
  errorData
528
528
  );
529
529
  }
530
530
  throw new NetworkError(
531
- `HTTP error! status: ${request.status}`,
531
+ `HTTP error: ${errorData}`,
532
532
  request.status,
533
533
  errorData
534
534
  );
@@ -578,16 +578,16 @@ var unpinFile = async (config, files) => {
578
578
  });
579
579
  await wait(300);
580
580
  if (!response.ok) {
581
- const errorData = await response.json();
581
+ const errorData = await response.text();
582
582
  if (response.status === 401) {
583
583
  throw new AuthenticationError(
584
- "Authentication failed",
584
+ `Authentication failed: ${errorData}`,
585
585
  response.status,
586
586
  errorData
587
587
  );
588
588
  }
589
589
  throw new NetworkError(
590
- `HTTP error! status: ${response.status}`,
590
+ `HTTP error: ${errorData}`,
591
591
  response.status,
592
592
  errorData
593
593
  );
@@ -683,16 +683,16 @@ var listFiles = async (config, options) => {
683
683
  headers
684
684
  });
685
685
  if (!request.ok) {
686
- const errorData = await request.json();
687
- if (request.status === 401) {
686
+ const errorData = await request.text();
687
+ if (request.status === 401 || request.status === 403) {
688
688
  throw new AuthenticationError(
689
- "Authentication failed",
689
+ `Authentication failed: ${errorData}`,
690
690
  request.status,
691
691
  errorData
692
692
  );
693
693
  }
694
694
  throw new NetworkError(
695
- `HTTP error! status: ${request.status}`,
695
+ `HTTP error: ${errorData}`,
696
696
  request.status,
697
697
  errorData
698
698
  );
@@ -741,16 +741,16 @@ var updateMetadata = async (config, options) => {
741
741
  body: JSON.stringify(data)
742
742
  });
743
743
  if (!request.ok) {
744
- const errorData = await request.json();
745
- if (request.status === 401) {
744
+ const errorData = await request.text();
745
+ if (request.status === 401 || request.status === 403) {
746
746
  throw new AuthenticationError(
747
- "Authentication failed",
747
+ `Authentication failed: ${errorData}`,
748
748
  request.status,
749
749
  errorData
750
750
  );
751
751
  }
752
752
  throw new NetworkError(
753
- `HTTP error! status: ${request.status}`,
753
+ `HTTP error: ${errorData}`,
754
754
  request.status,
755
755
  errorData
756
756
  );
@@ -878,16 +878,16 @@ var getCid = async (config, cid) => {
878
878
  try {
879
879
  const request = await fetch(newUrl);
880
880
  if (!request.ok) {
881
- const errorData = await request.json();
882
- if (request.status === 401) {
881
+ const errorData = await request.text();
882
+ if (request.status === 401 || request.status === 403) {
883
883
  throw new AuthenticationError(
884
- "Authentication failed",
884
+ `Authentication Failed: ${errorData}`,
885
885
  request.status,
886
886
  errorData
887
887
  );
888
888
  }
889
889
  throw new NetworkError(
890
- `HTTP error! status: ${request.status}`,
890
+ `HTTP error: ${errorData}`,
891
891
  request.status,
892
892
  errorData
893
893
  );
@@ -969,16 +969,16 @@ var pinJobs = async (config, options) => {
969
969
  headers
970
970
  });
971
971
  if (!request.ok) {
972
- const errorData = await request.json();
973
- if (request.status === 401) {
972
+ const errorData = await request.text();
973
+ if (request.status === 401 || request.status === 403) {
974
974
  throw new AuthenticationError(
975
- "Authentication failed",
975
+ `Authentication failed: ${errorData}`,
976
976
  request.status,
977
977
  errorData
978
978
  );
979
979
  }
980
980
  throw new NetworkError(
981
- `HTTP error! status: ${request.status}`,
981
+ `HTTP error: ${errorData}`,
982
982
  request.status,
983
983
  errorData
984
984
  );
@@ -1020,16 +1020,16 @@ var pinnedFileCount = async (config) => {
1020
1020
  headers
1021
1021
  });
1022
1022
  if (!request.ok) {
1023
- const errorData = await request.json();
1024
- if (request.status === 401) {
1023
+ const errorData = await request.text();
1024
+ if (request.status === 401 || request.status === 403) {
1025
1025
  throw new AuthenticationError(
1026
- "Authentication failed",
1026
+ `Authentication failed: ${errorData}`,
1027
1027
  request.status,
1028
1028
  errorData
1029
1029
  );
1030
1030
  }
1031
1031
  throw new NetworkError(
1032
- `HTTP error! status: ${request.status}`,
1032
+ `HTTP error: ${errorData}`,
1033
1033
  request.status,
1034
1034
  errorData
1035
1035
  );
@@ -1075,16 +1075,16 @@ var totalStorageUsage = async (config) => {
1075
1075
  headers
1076
1076
  });
1077
1077
  if (!request.ok) {
1078
- const errorData = await request.json();
1079
- if (request.status === 401) {
1078
+ const errorData = await request.text();
1079
+ if (request.status === 401 || request.status === 403) {
1080
1080
  throw new AuthenticationError(
1081
- "Authentication failed",
1081
+ `Authentication failed: ${errorData}`,
1082
1082
  request.status,
1083
1083
  errorData
1084
1084
  );
1085
1085
  }
1086
1086
  throw new NetworkError(
1087
- `HTTP error! status: ${request.status}`,
1087
+ `HTTP error: ${errorData}`,
1088
1088
  request.status,
1089
1089
  errorData
1090
1090
  );
@@ -1133,16 +1133,16 @@ var createKey = async (config, options) => {
1133
1133
  body: data
1134
1134
  });
1135
1135
  if (!request.ok) {
1136
- const errorData = await request.json();
1137
- if (request.status === 401) {
1136
+ const errorData = await request.text();
1137
+ if (request.status === 401 || request.status === 403) {
1138
1138
  throw new AuthenticationError(
1139
- "Authentication failed",
1139
+ `Authentication failed: ${errorData}`,
1140
1140
  request.status,
1141
1141
  errorData
1142
1142
  );
1143
1143
  }
1144
1144
  throw new NetworkError(
1145
- `HTTP error! status: ${request.status}`,
1145
+ `HTTP error: ${errorData}`,
1146
1146
  request.status,
1147
1147
  errorData
1148
1148
  );
@@ -1202,16 +1202,16 @@ var listKeys = async (config, options) => {
1202
1202
  }
1203
1203
  );
1204
1204
  if (!request.ok) {
1205
- const errorData = await request.json();
1206
- if (request.status === 401) {
1205
+ const errorData = await request.text();
1206
+ if (request.status === 401 || request.status === 403) {
1207
1207
  throw new AuthenticationError(
1208
- "Authentication failed",
1208
+ `Authentication failed: ${errorData}`,
1209
1209
  request.status,
1210
1210
  errorData
1211
1211
  );
1212
1212
  }
1213
1213
  throw new NetworkError(
1214
- `HTTP error! status: ${request.status}`,
1214
+ `HTTP error: ${errorData}`,
1215
1215
  request.status,
1216
1216
  errorData
1217
1217
  );
@@ -1262,16 +1262,16 @@ var revokeKeys = async (config, keys) => {
1262
1262
  });
1263
1263
  await wait2(300);
1264
1264
  if (!request.ok) {
1265
- const errorData = await request.json();
1266
- if (request.status === 401) {
1265
+ const errorData = await request.text();
1266
+ if (request.status === 401 || request.status === 403) {
1267
1267
  throw new AuthenticationError(
1268
- "Authentication failed",
1268
+ `Authentication failed: ${errorData}`,
1269
1269
  request.status,
1270
1270
  errorData
1271
1271
  );
1272
1272
  }
1273
1273
  throw new NetworkError(
1274
- `HTTP error! status: ${request.status}`,
1274
+ `HTTP error: ${errorData}`,
1275
1275
  request.status,
1276
1276
  errorData
1277
1277
  );
@@ -1326,16 +1326,16 @@ var createGroup = async (config, options) => {
1326
1326
  body: data
1327
1327
  });
1328
1328
  if (!request.ok) {
1329
- const errorData = await request.json();
1330
- if (request.status === 401) {
1329
+ const errorData = await request.text();
1330
+ if (request.status === 401 || request.status === 403) {
1331
1331
  throw new AuthenticationError(
1332
- "Authentication failed",
1332
+ `Authentication failed: ${errorData}`,
1333
1333
  request.status,
1334
1334
  errorData
1335
1335
  );
1336
1336
  }
1337
1337
  throw new NetworkError(
1338
- `HTTP error! status: ${request.status}`,
1338
+ `HTTP error: ${errorData}`,
1339
1339
  request.status,
1340
1340
  errorData
1341
1341
  );
@@ -1388,16 +1388,16 @@ var listGroups = async (config, options) => {
1388
1388
  headers
1389
1389
  });
1390
1390
  if (!request.ok) {
1391
- const errorData = await request.json();
1392
- if (request.status === 401) {
1391
+ const errorData = await request.text();
1392
+ if (request.status === 401 || request.status === 403) {
1393
1393
  throw new AuthenticationError(
1394
- "Authentication failed",
1394
+ `Authentication failed: ${errorData}`,
1395
1395
  request.status,
1396
1396
  errorData
1397
1397
  );
1398
1398
  }
1399
1399
  throw new NetworkError(
1400
- `HTTP error! status: ${request.status}`,
1400
+ `HTTP error: ${errorData}`,
1401
1401
  request.status,
1402
1402
  errorData
1403
1403
  );
@@ -1440,16 +1440,16 @@ var getGroup = async (config, options) => {
1440
1440
  headers
1441
1441
  });
1442
1442
  if (!request.ok) {
1443
- const errorData = await request.json();
1444
- if (request.status === 401) {
1443
+ const errorData = await request.text();
1444
+ if (request.status === 401 || request.status === 403) {
1445
1445
  throw new AuthenticationError(
1446
- "Authentication failed",
1446
+ `Authentication failed: ${errorData}`,
1447
1447
  request.status,
1448
1448
  errorData
1449
1449
  );
1450
1450
  }
1451
1451
  throw new NetworkError(
1452
- `HTTP error! status: ${request.status}`,
1452
+ `HTTP error: ${errorData}`,
1453
1453
  request.status,
1454
1454
  errorData
1455
1455
  );
@@ -1498,16 +1498,16 @@ var addToGroup = async (config, options) => {
1498
1498
  body: data
1499
1499
  });
1500
1500
  if (!request.ok) {
1501
- const errorData = await request.json();
1502
- if (request.status === 401) {
1501
+ const errorData = await request.text();
1502
+ if (request.status === 401 || request.status === 403) {
1503
1503
  throw new AuthenticationError(
1504
- "Authentication failed",
1504
+ `Authentication failed: ${errorData}`,
1505
1505
  request.status,
1506
1506
  errorData
1507
1507
  );
1508
1508
  }
1509
1509
  throw new NetworkError(
1510
- `HTTP error! status: ${request.status}`,
1510
+ `HTTP error: ${errorData}`,
1511
1511
  request.status,
1512
1512
  errorData
1513
1513
  );
@@ -1556,16 +1556,16 @@ var updateGroup = async (config, options) => {
1556
1556
  body: data
1557
1557
  });
1558
1558
  if (!request.ok) {
1559
- const errorData = await request.json();
1560
- if (request.status === 401) {
1559
+ const errorData = await request.text();
1560
+ if (request.status === 401 || request.status === 403) {
1561
1561
  throw new AuthenticationError(
1562
- "Authentication failed",
1562
+ `Authentication failed: ${errorData}`,
1563
1563
  request.status,
1564
1564
  errorData
1565
1565
  );
1566
1566
  }
1567
1567
  throw new NetworkError(
1568
- `HTTP error! status: ${request.status}`,
1568
+ `HTTP error: ${errorData}`,
1569
1569
  request.status,
1570
1570
  errorData
1571
1571
  );
@@ -1612,16 +1612,16 @@ var removeFromGroup = async (config, options) => {
1612
1612
  body: data
1613
1613
  });
1614
1614
  if (!request.ok) {
1615
- const errorData = await request.json();
1616
- if (request.status === 401) {
1615
+ const errorData = await request.text();
1616
+ if (request.status === 401 || request.status === 403) {
1617
1617
  throw new AuthenticationError(
1618
- "Authentication failed",
1618
+ `Authentication failed: ${errorData}`,
1619
1619
  request.status,
1620
1620
  errorData
1621
1621
  );
1622
1622
  }
1623
1623
  throw new NetworkError(
1624
- `HTTP error! status: ${request.status}`,
1624
+ `HTTP error: ${errorData}`,
1625
1625
  request.status,
1626
1626
  errorData
1627
1627
  );
@@ -1668,16 +1668,16 @@ var deleteGroup = async (config, options) => {
1668
1668
  headers
1669
1669
  });
1670
1670
  if (!request.ok) {
1671
- const errorData = await request.json();
1672
- if (request.status === 401) {
1671
+ const errorData = await request.text();
1672
+ if (request.status === 401 || request.status === 403) {
1673
1673
  throw new AuthenticationError(
1674
- "Authentication failed",
1674
+ `Authentication failed: ${errorData}`,
1675
1675
  request.status,
1676
1676
  errorData
1677
1677
  );
1678
1678
  }
1679
1679
  throw new NetworkError(
1680
- `HTTP error! status: ${request.status}`,
1680
+ `HTTP error: ${errorData}`,
1681
1681
  request.status,
1682
1682
  errorData
1683
1683
  );
@@ -1727,10 +1727,10 @@ var addSignature = async (config, options) => {
1727
1727
  }
1728
1728
  );
1729
1729
  if (!request.ok) {
1730
- const errorData = await request.json();
1731
- if (request.status === 401) {
1730
+ const errorData = await request.text();
1731
+ if (request.status === 401 || request.status === 403) {
1732
1732
  throw new AuthenticationError(
1733
- "Authentication failed",
1733
+ `Authentication failed: ${errorData}`,
1734
1734
  request.status,
1735
1735
  errorData
1736
1736
  );
@@ -1743,7 +1743,7 @@ var addSignature = async (config, options) => {
1743
1743
  );
1744
1744
  }
1745
1745
  throw new NetworkError(
1746
- `HTTP error! status: ${request.status}`,
1746
+ `HTTP error: ${errorData}`,
1747
1747
  request.status,
1748
1748
  errorData
1749
1749
  );
@@ -1788,16 +1788,16 @@ var getSignature = async (config, cid) => {
1788
1788
  headers
1789
1789
  });
1790
1790
  if (!request.ok) {
1791
- const errorData = await request.json();
1792
- if (request.status === 401) {
1791
+ const errorData = await request.text();
1792
+ if (request.status === 401 || request.status === 403) {
1793
1793
  throw new AuthenticationError(
1794
- "Authentication failed",
1794
+ `Authentication failed: ${errorData}`,
1795
1795
  request.status,
1796
1796
  errorData
1797
1797
  );
1798
1798
  }
1799
1799
  throw new NetworkError(
1800
- `HTTP error! status: ${request.status}`,
1800
+ `HTTP error: ${errorData}`,
1801
1801
  request.status,
1802
1802
  errorData
1803
1803
  );
@@ -1842,16 +1842,16 @@ var removeSignature = async (config, cid) => {
1842
1842
  headers
1843
1843
  });
1844
1844
  if (!request.ok) {
1845
- const errorData = await request.json();
1846
- if (request.status === 401) {
1845
+ const errorData = await request.text();
1846
+ if (request.status === 401 || request.status === 403) {
1847
1847
  throw new AuthenticationError(
1848
- "Authentication failed",
1848
+ `Authentication failed: ${errorData}`,
1849
1849
  request.status,
1850
1850
  errorData
1851
1851
  );
1852
1852
  }
1853
1853
  throw new NetworkError(
1854
- `HTTP error! status: ${request.status}`,
1854
+ `HTTP error: ${errorData}`,
1855
1855
  request.status,
1856
1856
  errorData
1857
1857
  );
@@ -1941,16 +1941,16 @@ var analyticsTopUsage = async (config, options) => {
1941
1941
  headers
1942
1942
  });
1943
1943
  if (!request.ok) {
1944
- const errorData = await request.json();
1945
- if (request.status === 401) {
1944
+ const errorData = await request.text();
1945
+ if (request.status === 401 || request.status === 403) {
1946
1946
  throw new AuthenticationError(
1947
- "Authentication failed",
1947
+ `Authentication failed: ${errorData}`,
1948
1948
  request.status,
1949
1949
  errorData
1950
1950
  );
1951
1951
  }
1952
1952
  throw new NetworkError(
1953
- `HTTP error! status: ${request.status}`,
1953
+ `HTTP error: ${errorData}`,
1954
1954
  request.status,
1955
1955
  errorData
1956
1956
  );
@@ -2042,16 +2042,16 @@ var analyticsDateInterval = async (config, options) => {
2042
2042
  headers
2043
2043
  });
2044
2044
  if (!request.ok) {
2045
- const errorData = await request.json();
2046
- if (request.status === 401) {
2045
+ const errorData = await request.text();
2046
+ if (request.status === 401 || request.status === 403) {
2047
2047
  throw new AuthenticationError(
2048
- "Authentication failed",
2048
+ `Authentication failed: ${errorData}`,
2049
2049
  request.status,
2050
2050
  errorData
2051
2051
  );
2052
2052
  }
2053
2053
  throw new NetworkError(
2054
- `HTTP error! status: ${request.status}`,
2054
+ `HTTP error: ${errorData}`,
2055
2055
  request.status,
2056
2056
  errorData
2057
2057
  );
@@ -2103,10 +2103,10 @@ var swapCid = async (config, options) => {
2103
2103
  body: data
2104
2104
  });
2105
2105
  if (!request.ok) {
2106
- const errorData = await request.json();
2107
- if (request.status === 401) {
2106
+ const errorData = await request.text();
2107
+ if (request.status === 401 || request.status === 403) {
2108
2108
  throw new AuthenticationError(
2109
- "Authentication failed",
2109
+ `Authentication failed: ${errorData}`,
2110
2110
  request.status,
2111
2111
  errorData
2112
2112
  );
@@ -2126,7 +2126,7 @@ var swapCid = async (config, options) => {
2126
2126
  );
2127
2127
  }
2128
2128
  throw new NetworkError(
2129
- `HTTP error! status: ${request.status}`,
2129
+ `HTTP error: ${errorData}`,
2130
2130
  request.status,
2131
2131
  errorData
2132
2132
  );
@@ -2173,10 +2173,10 @@ var swapHistory = async (config, options) => {
2173
2173
  }
2174
2174
  );
2175
2175
  if (!request.ok) {
2176
- const errorData = await request.json();
2177
- if (request.status === 401) {
2176
+ const errorData = await request.text();
2177
+ if (request.status === 401 || request.status === 403) {
2178
2178
  throw new AuthenticationError(
2179
- "Authentication failed",
2179
+ `Authentication failed: ${errorData}`,
2180
2180
  request.status,
2181
2181
  errorData
2182
2182
  );
@@ -2189,7 +2189,7 @@ var swapHistory = async (config, options) => {
2189
2189
  );
2190
2190
  }
2191
2191
  throw new NetworkError(
2192
- `HTTP error! status: ${request.status}`,
2192
+ `HTTP error: ${errorData}`,
2193
2193
  request.status,
2194
2194
  errorData
2195
2195
  );
@@ -2235,10 +2235,10 @@ var deleteSwap = async (config, cid) => {
2235
2235
  headers
2236
2236
  });
2237
2237
  if (!request.ok) {
2238
- const errorData = await request.json();
2239
- if (request.status === 401) {
2238
+ const errorData = await request.text();
2239
+ if (request.status === 401 || request.status === 403) {
2240
2240
  throw new AuthenticationError(
2241
- "Authentication failed",
2241
+ `Authentication failed: ${errorData}`,
2242
2242
  request.status,
2243
2243
  errorData
2244
2244
  );
@@ -2258,7 +2258,7 @@ var deleteSwap = async (config, cid) => {
2258
2258
  );
2259
2259
  }
2260
2260
  throw new NetworkError(
2261
- `HTTP error! status: ${request.status}`,
2261
+ `HTTP error: ${errorData}`,
2262
2262
  request.status,
2263
2263
  errorData
2264
2264
  );