@eluvio/elv-client-js 4.0.11 → 4.0.13

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.
Files changed (111) hide show
  1. package/dist/.keep +0 -0
  2. package/dist/ElvClient-min.js +11 -10
  3. package/dist/ElvClient-node-min.js +11 -10
  4. package/dist/ElvFrameClient-min.js +11 -10
  5. package/dist/ElvPermissionsClient-min.js +10 -9
  6. package/dist/ElvWalletClient-min.js +10 -9
  7. package/dist/ElvWalletClient-node-min.js +10 -9
  8. package/dist/src/AuthorizationClient.js +1555 -2076
  9. package/dist/src/ContentObjectVerification.js +134 -185
  10. package/dist/src/Crypto.js +224 -319
  11. package/dist/src/ElvClient.js +822 -1114
  12. package/dist/src/ElvWallet.js +64 -106
  13. package/dist/src/EthClient.js +719 -974
  14. package/dist/src/FrameClient.js +223 -319
  15. package/dist/src/HttpClient.js +117 -156
  16. package/dist/src/Id.js +1 -6
  17. package/dist/src/LogMessage.js +4 -8
  18. package/dist/src/PermissionsClient.js +973 -1271
  19. package/dist/src/RemoteSigner.js +161 -232
  20. package/dist/src/UserProfileClient.js +781 -1038
  21. package/dist/src/Utils.js +159 -299
  22. package/dist/src/Validation.js +2 -17
  23. package/dist/src/client/ABRPublishing.js +828 -958
  24. package/dist/src/client/AccessGroups.js +849 -1095
  25. package/dist/src/client/ContentAccess.js +3323 -4195
  26. package/dist/src/client/ContentManagement.js +1818 -2290
  27. package/dist/src/client/Contracts.js +468 -614
  28. package/dist/src/client/Files.js +1506 -1846
  29. package/dist/src/client/NFT.js +94 -116
  30. package/dist/src/client/NTP.js +326 -425
  31. package/dist/src/index.js +2 -5
  32. package/dist/src/walletClient/ClientMethods.js +1368 -1763
  33. package/dist/src/walletClient/Configuration.js +5 -3
  34. package/dist/src/walletClient/Notifications.js +98 -127
  35. package/dist/src/walletClient/Profile.js +184 -246
  36. package/dist/src/walletClient/Utils.js +76 -122
  37. package/dist/src/walletClient/index.js +1171 -1496
  38. package/package.json +4 -21
  39. package/src/FrameClient.js +1 -0
  40. package/src/HttpClient.js +4 -2
  41. package/src/client/ABRPublishing.js +126 -105
  42. package/src/client/ContentAccess.js +1 -0
  43. package/src/client/ContentManagement.js +4 -2
  44. package/src/walletClient/Configuration.js +3 -2
  45. package/dist/AccessClient-min.js +0 -54
  46. package/dist/AccessClient-node-min.js +0 -74
  47. package/dist/src/AccessClient.js +0 -798
  48. package/dist/src/LimitedMap.js +0 -120
  49. package/dist/src/client/Access.js +0 -1
  50. package/dist/src/client/Management.js +0 -1606
  51. package/dist/src/contracts/AccessIndexor.js +0 -831
  52. package/dist/src/contracts/Accessible.js +0 -31
  53. package/dist/src/contracts/AdmgrAdvertisement.js +0 -695
  54. package/dist/src/contracts/AdmgrCampaign.js +0 -648
  55. package/dist/src/contracts/AdmgrCampaignManager.js +0 -493
  56. package/dist/src/contracts/AdmgrCommercialOffering.js +0 -622
  57. package/dist/src/contracts/AdmgrCommercialOfferingManager.js +0 -413
  58. package/dist/src/contracts/AdmgrMarketPlace.js +0 -413
  59. package/dist/src/contracts/AvailsDelivery.js +0 -535
  60. package/dist/src/contracts/BaseAccessControlGroup.js +0 -1221
  61. package/dist/src/contracts/BaseAccessWallet.js +0 -1575
  62. package/dist/src/contracts/BaseAccessWalletFactory.js +0 -93
  63. package/dist/src/contracts/BaseContent.js +0 -1104
  64. package/dist/src/contracts/BaseContentFactory.js +0 -99
  65. package/dist/src/contracts/BaseContentFactoryExt.js +0 -219
  66. package/dist/src/contracts/BaseContentSpace.js +0 -1346
  67. package/dist/src/contracts/BaseContentType.js +0 -353
  68. package/dist/src/contracts/BaseFactory.js +0 -107
  69. package/dist/src/contracts/BaseGroupFactory.js +0 -93
  70. package/dist/src/contracts/BaseLibrary.js +0 -1035
  71. package/dist/src/contracts/BaseLibraryFactory.js +0 -96
  72. package/dist/src/contracts/Certifyer.js +0 -87
  73. package/dist/src/contracts/Container.js +0 -543
  74. package/dist/src/contracts/Content.js +0 -432
  75. package/dist/src/contracts/Editable.js +0 -295
  76. package/dist/src/contracts/FactorySpace.js +0 -57
  77. package/dist/src/contracts/KmsSpace.js +0 -52
  78. package/dist/src/contracts/LvProvider.js +0 -512
  79. package/dist/src/contracts/LvRecordableStream.js +0 -1026
  80. package/dist/src/contracts/LvRecording.js +0 -627
  81. package/dist/src/contracts/LvStreamRightsHolder.js +0 -551
  82. package/dist/src/contracts/MetaObject.js +0 -110
  83. package/dist/src/contracts/Node.js +0 -167
  84. package/dist/src/contracts/NodeSpace.js +0 -18
  85. package/dist/src/contracts/NodeSpaceImpl.js +0 -273
  86. package/dist/src/contracts/Ownable.js +0 -87
  87. package/dist/src/contracts/PaymentService.js +0 -616
  88. package/dist/src/contracts/Precompile.js +0 -15
  89. package/dist/src/contracts/SampleContentAdMarketplace.js +0 -564
  90. package/dist/src/contracts/SampleContentAdvertising.js +0 -444
  91. package/dist/src/contracts/SampleContentHelloWorld.js +0 -459
  92. package/dist/src/contracts/SampleContentLicensing.js +0 -618
  93. package/dist/src/contracts/SampleContentSigned.js +0 -447
  94. package/dist/src/contracts/SampleInstance.js +0 -438
  95. package/dist/src/contracts/SampleInstanceFactory.js +0 -451
  96. package/dist/src/contracts/Transactable.js +0 -82
  97. package/dist/src/contracts/UserSpace.js +0 -18
  98. package/dist/src/contracts/UserSpaceImpl.js +0 -43
  99. package/dist/src/contracts/Utils.js +0 -18
  100. package/dist/src/contracts/Verifier.js +0 -53
  101. package/dist/src/contracts/strings.js +0 -4
  102. package/dist/src/contracts/v2/BaseContentFactoryExt.js +0 -219
  103. package/dist/src/contracts/v2/FactorySpace.js +0 -57
  104. package/dist/src/contracts/v2/KmsSpace.js +0 -52
  105. package/dist/src/contracts/v2/NodeSpaceImpl.js +0 -273
  106. package/dist/src/contracts/v2/UserSpaceImpl.js +0 -43
  107. package/dist/src/marketplaceClient/ClientMethods.js +0 -1918
  108. package/dist/src/marketplaceClient/Configuration.js +0 -29
  109. package/dist/src/marketplaceClient/Utils.js +0 -304
  110. package/dist/src/marketplaceClient/index.js +0 -1553
  111. package/utilities/ListAccessGroups.js +0 -34
package/dist/src/Utils.js CHANGED
@@ -1,34 +1,22 @@
1
1
  var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
2
-
3
2
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
4
-
5
3
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
6
-
7
4
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
8
-
9
5
  var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
10
-
11
6
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
-
13
7
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
-
15
8
  if (typeof globalThis.Buffer === "undefined") {
16
9
  globalThis.Buffer = require("buffer/").Buffer;
17
10
  }
18
-
19
11
  var bs58 = require("bs58");
20
-
21
12
  var BigNumber = require("bignumber.js")["default"];
22
-
23
13
  var VarInt = require("varint");
24
-
25
14
  var URI = require("urijs");
26
-
27
15
  var Pako = require("pako");
28
-
29
16
  var _require$utils = require("ethers").utils,
30
- keccak256 = _require$utils.keccak256,
31
- getAddress = _require$utils.getAddress;
17
+ keccak256 = _require$utils.keccak256,
18
+ getAddress = _require$utils.getAddress;
19
+
32
20
  /**
33
21
  * @namespace
34
22
  * @description This is a utility namespace mostly containing functions for managing
@@ -45,13 +33,10 @@ var _require$utils = require("ethers").utils,
45
33
  *
46
34
  * It can be accessed from ElvClient and FrameClient as `client.utils`
47
35
  */
48
-
49
-
50
36
  var Utils = {
51
37
  name: "Utils",
52
38
  nullAddress: "0x0000000000000000000000000000000000000000",
53
39
  weiPerEther: new BigNumber("1000000000000000000"),
54
-
55
40
  /**
56
41
  * Convert number or string to BigNumber
57
42
  *
@@ -64,7 +49,6 @@ var Utils = {
64
49
  ToBigNumber: function ToBigNumber(value) {
65
50
  return new BigNumber(value);
66
51
  },
67
-
68
52
  /**
69
53
  * Convert wei to ether
70
54
  *
@@ -77,7 +61,6 @@ var Utils = {
77
61
  WeiToEther: function WeiToEther(wei) {
78
62
  return Utils.ToBigNumber(wei).div(Utils.weiPerEther);
79
63
  },
80
-
81
64
  /**
82
65
  * Convert ether to wei
83
66
  *
@@ -90,7 +73,6 @@ var Utils = {
90
73
  EtherToWei: function EtherToWei(ether) {
91
74
  return Utils.ToBigNumber(ether).times(Utils.weiPerEther);
92
75
  },
93
-
94
76
  /**
95
77
  * Convert address to normalized form - lower case with "0x" prefix
96
78
  *
@@ -102,16 +84,12 @@ var Utils = {
102
84
  if (!address || typeof address !== "string") {
103
85
  return "";
104
86
  }
105
-
106
87
  address = address.trim();
107
-
108
88
  if (!address.startsWith("0x")) {
109
89
  address = "0x" + address;
110
90
  }
111
-
112
91
  return address.toLowerCase();
113
92
  },
114
-
115
93
  /**
116
94
  * Formats a signature into multi-sig
117
95
  *
@@ -123,7 +101,6 @@ var Utils = {
123
101
  sig = sig.replace("0x", "");
124
102
  return "ES256K_" + bs58.encode(Buffer.from(sig, "hex"));
125
103
  },
126
-
127
104
  /**
128
105
  * Decode the specified version hash into its component parts
129
106
  *
@@ -135,29 +112,32 @@ var Utils = {
135
112
  if (!(versionHash.startsWith("hq__") || versionHash.startsWith("tq__"))) {
136
113
  throw new Error("Invalid version hash: \"".concat(versionHash, "\""));
137
114
  }
115
+ versionHash = versionHash.slice(4);
138
116
 
139
- versionHash = versionHash.slice(4); // Decode base58 payload
140
-
141
- var bytes = Utils.FromB58(versionHash); // Remove 32 byte SHA256 digest
117
+ // Decode base58 payload
118
+ var bytes = Utils.FromB58(versionHash);
142
119
 
120
+ // Remove 32 byte SHA256 digest
143
121
  var digestBytes = bytes.slice(0, 32);
144
122
  var digest = digestBytes.toString("hex");
145
- bytes = bytes.slice(32); // Determine size of varint content size
123
+ bytes = bytes.slice(32);
146
124
 
125
+ // Determine size of varint content size
147
126
  var sizeLength = 0;
148
-
149
127
  while (bytes[sizeLength] >= 128) {
150
128
  sizeLength++;
151
129
  }
130
+ sizeLength++;
152
131
 
153
- sizeLength++; // Remove size
154
-
132
+ // Remove size
155
133
  var sizeBytes = bytes.slice(0, sizeLength);
156
134
  var size = VarInt.decode(sizeBytes);
157
- bytes = bytes.slice(sizeLength); // Remaining bytes is object ID
135
+ bytes = bytes.slice(sizeLength);
158
136
 
159
- var objectId = "iq__" + Utils.B58(bytes); // Part hash is B58 encoded version hash without the ID
137
+ // Remaining bytes is object ID
138
+ var objectId = "iq__" + Utils.B58(bytes);
160
139
 
140
+ // Part hash is B58 encoded version hash without the ID
161
141
  var partHash = "hqp_" + Utils.B58(Buffer.concat([digestBytes, sizeBytes]));
162
142
  return {
163
143
  digest: digest,
@@ -166,7 +146,6 @@ var Utils = {
166
146
  partHash: partHash
167
147
  };
168
148
  },
169
-
170
149
  /**
171
150
  * Decode the specified signed token into its component parts
172
151
  *
@@ -184,7 +163,6 @@ var Utils = {
184
163
  signature: signature
185
164
  };
186
165
  },
187
-
188
166
  /**
189
167
  * Decode the specified write token into its component parts
190
168
  *
@@ -210,12 +188,11 @@ var Utils = {
210
188
  - format:
211
189
  prefix + base58(RAND_BYTES)
212
190
  */
191
+
213
192
  if (writeToken.length < 4) {
214
193
  throw new Error("Invalid write token: [\"".concat(writeToken, "\"] (unknown prefix)"));
215
194
  }
216
-
217
195
  var tokenType;
218
-
219
196
  if (writeToken.startsWith("tqw__")) {
220
197
  tokenType = "tq__";
221
198
  writeToken = writeToken.slice(5);
@@ -223,11 +200,9 @@ var Utils = {
223
200
  tokenType = writeToken.slice(0, 4);
224
201
  writeToken = writeToken.slice(4);
225
202
  }
226
-
227
203
  if (writeToken.length === 0) {
228
204
  throw new Error("Invalid write token: [\"".concat(writeToken, "\"] (too short)"));
229
205
  }
230
-
231
206
  switch (tokenType) {
232
207
  case "tqw_":
233
208
  case "tq__":
@@ -235,25 +210,19 @@ var Utils = {
235
210
  case "tqp_":
236
211
  case "tlro":
237
212
  break;
238
-
239
213
  default:
240
214
  throw new Error("Invalid write token: [\"".concat(writeToken, "\"] (unknown prefix)"));
241
- } // decode base58 payload
242
-
215
+ }
243
216
 
217
+ // decode base58 payload
244
218
  var bytes = Utils.FromB58(writeToken);
245
-
246
219
  function decodeBytes(isID, prefix) {
247
220
  var bsize = VarInt.decode(bytes, 0); // decode: count of bytes to read
248
-
249
221
  var offset = VarInt.decode.bytes; // offset in buffer to start read after decode
250
-
251
222
  var theBytes;
252
223
  var ret;
253
-
254
224
  if (isID) {
255
225
  theBytes = bytes.slice(offset + 1, bsize + offset); // skip 1st byte (code id) at offset 0
256
-
257
226
  if (theBytes.length === 0) {
258
227
  ret = "";
259
228
  } else {
@@ -263,51 +232,41 @@ var Utils = {
263
232
  theBytes = bytes.slice(offset, bsize + offset);
264
233
  ret = "0x" + theBytes.toString("hex");
265
234
  }
266
-
267
235
  bytes = bytes.slice(bsize + offset);
268
236
  return ret;
269
237
  }
270
-
271
238
  var tokenId;
272
239
  var qid;
273
240
  var nid;
274
241
  var scheme;
275
242
  var flags;
276
-
277
243
  switch (tokenType) {
278
244
  case "tqw_": // content write token v1
279
-
280
245
  case "tqpw":
281
246
  // content part write token v1
282
247
  tokenId = "0x" + bytes.toString("hex");
283
248
  break;
284
-
285
249
  case "tlro": // LRO,
286
-
287
250
  case "tq__":
288
251
  // content write token
289
252
  qid = decodeBytes(true, "iq__");
290
253
  nid = decodeBytes(true, "inod");
291
254
  tokenId = decodeBytes(false, "");
292
255
  break;
293
-
294
256
  case "tqp_":
295
257
  // content part write token
296
258
  if (bytes.length < 3) {
297
259
  throw new Error("Invalid write token: [\"".concat(writeToken, "\"] (token truncated)"));
298
260
  }
299
-
300
261
  scheme = bytes[0];
301
262
  flags = bytes[1];
302
263
  bytes = bytes.slice(2);
303
264
  tokenId = decodeBytes(false, "");
304
265
  break;
305
-
306
266
  default:
307
267
  // already raised
308
268
  throw new Error("Invalid write token: [\"".concat(writeToken, "\"] (unknown prefix)"));
309
269
  }
310
-
311
270
  return {
312
271
  tokenType: tokenType,
313
272
  // type of token
@@ -320,7 +279,6 @@ var Utils = {
320
279
  scheme: scheme,
321
280
  // encryption scheme for part write token - (tqp_)
322
281
  flags: flags // flags for part write token (tqp_)
323
-
324
282
  };
325
283
  },
326
284
 
@@ -337,7 +295,6 @@ var Utils = {
337
295
  address = address.replace(key ? "0x04" : "0x", "");
338
296
  return bs58.encode(Buffer.from(address, "hex"));
339
297
  },
340
-
341
298
  /**
342
299
  * Convert contract address to content space ID
343
300
  *
@@ -348,7 +305,6 @@ var Utils = {
348
305
  AddressToSpaceId: function AddressToSpaceId(address) {
349
306
  return "ispc" + Utils.AddressToHash(address);
350
307
  },
351
-
352
308
  /**
353
309
  * Convert contract address to content library ID
354
310
  *
@@ -359,7 +315,6 @@ var Utils = {
359
315
  AddressToLibraryId: function AddressToLibraryId(address) {
360
316
  return "ilib" + Utils.AddressToHash(address);
361
317
  },
362
-
363
318
  /**
364
319
  * Convert contract address to content object ID
365
320
  *
@@ -370,7 +325,6 @@ var Utils = {
370
325
  AddressToObjectId: function AddressToObjectId(address) {
371
326
  return "iq__" + Utils.AddressToHash(address);
372
327
  },
373
-
374
328
  /**
375
329
  * Convert any content fabric ID to the corresponding contract address
376
330
  *
@@ -384,7 +338,6 @@ var Utils = {
384
338
  hash = key ? hash : hash.substr(4);
385
339
  return Utils.FormatAddress((key ? "0x04" : "0x") + bs58.decode(hash).toString("hex"));
386
340
  },
387
-
388
341
  /**
389
342
  * Compare two addresses to determine if they are the same, regardless of format/capitalization
390
343
  *
@@ -397,10 +350,8 @@ var Utils = {
397
350
  if (!firstAddress || !secondAddress) {
398
351
  return false;
399
352
  }
400
-
401
353
  return Utils.FormatAddress(firstAddress) === Utils.FormatAddress(secondAddress);
402
354
  },
403
-
404
355
  /**
405
356
  * Compare two IDs to determine if the hashes are the same
406
357
  * by comparing the contract address they resolve to
@@ -414,14 +365,11 @@ var Utils = {
414
365
  if (!firstHash || !secondHash) {
415
366
  return false;
416
367
  }
417
-
418
368
  if (firstHash.length <= 4 || secondHash.length <= 4) {
419
369
  return false;
420
370
  }
421
-
422
371
  return Utils.HashToAddress(firstHash) === Utils.HashToAddress(secondHash);
423
372
  },
424
-
425
373
  /**
426
374
  * Determine whether the address is valid
427
375
  *
@@ -437,7 +385,6 @@ var Utils = {
437
385
  return false;
438
386
  }
439
387
  },
440
-
441
388
  /**
442
389
  * Determine whether the hash is valid
443
390
  *
@@ -448,7 +395,6 @@ var Utils = {
448
395
  ValidHash: function ValidHash(hash) {
449
396
  return Utils.ValidAddress(Utils.HashToAddress(hash));
450
397
  },
451
-
452
398
  /**
453
399
  * Convert the specified string to a bytes32 string
454
400
  *
@@ -475,15 +421,12 @@ var Utils = {
475
421
  FromB64URL: function FromB64URL(str) {
476
422
  str = str.replace(/-/g, "+").replace(/_/g, "/");
477
423
  var pad = str.length % 4;
478
-
479
424
  if (pad) {
480
425
  if (pad === 1) {
481
426
  throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");
482
427
  }
483
-
484
428
  str += new Array(5 - pad).join("=");
485
429
  }
486
-
487
430
  return Utils.FromB64(str);
488
431
  },
489
432
  B58: function B58(arr) {
@@ -495,7 +438,6 @@ var Utils = {
495
438
  FromB58ToStr: function FromB58ToStr(str) {
496
439
  return new TextDecoder().decode(Utils.FromB58(str));
497
440
  },
498
-
499
441
  /**
500
442
  * Decode the given fabric authorization token
501
443
  *
@@ -504,12 +446,10 @@ var Utils = {
504
446
  */
505
447
  DecodeAuthorizationToken: function DecodeAuthorizationToken(token) {
506
448
  token = decodeURIComponent(token);
507
-
508
449
  var _token$split = token.split("."),
509
- _token$split2 = _slicedToArray(_token$split, 2),
510
- info = _token$split2[0],
511
- signature = _token$split2[1];
512
-
450
+ _token$split2 = _slicedToArray(_token$split, 2),
451
+ info = _token$split2[0],
452
+ signature = _token$split2[1];
513
453
  info = JSON.parse(Utils.FromB64(info));
514
454
  return _objectSpread(_objectSpread({}, info), {}, {
515
455
  signature: signature
@@ -519,226 +459,175 @@ var Utils = {
519
459
  var _LimitedMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(limit, array, f) {
520
460
  var index, locked, nextIndex, results, active;
521
461
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
522
- while (1) {
523
- switch (_context3.prev = _context3.next) {
524
- case 0:
525
- index = 0;
526
- locked = false;
527
-
528
- nextIndex = /*#__PURE__*/function () {
529
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
530
- var thisIndex;
531
- return _regeneratorRuntime.wrap(function _callee$(_context) {
532
- while (1) {
533
- switch (_context.prev = _context.next) {
534
- case 0:
535
- if (!locked) {
536
- _context.next = 5;
537
- break;
538
- }
539
-
540
- _context.next = 3;
541
- return new Promise(function (resolve) {
542
- return setTimeout(resolve, 10);
543
- });
544
-
545
- case 3:
546
- _context.next = 0;
547
- break;
548
-
549
- case 5:
550
- locked = true;
551
- thisIndex = index;
552
- index += 1;
553
- locked = false;
554
- return _context.abrupt("return", thisIndex);
555
-
556
- case 10:
557
- case "end":
558
- return _context.stop();
462
+ while (1) switch (_context3.prev = _context3.next) {
463
+ case 0:
464
+ index = 0;
465
+ locked = false;
466
+ nextIndex = /*#__PURE__*/function () {
467
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
468
+ var thisIndex;
469
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
470
+ while (1) switch (_context.prev = _context.next) {
471
+ case 0:
472
+ if (!locked) {
473
+ _context.next = 5;
474
+ break;
559
475
  }
560
- }
561
- }, _callee);
562
- }));
563
-
564
- return function nextIndex() {
565
- return _ref.apply(this, arguments);
566
- };
567
- }();
568
-
569
- results = [];
570
- active = 0;
571
- return _context3.abrupt("return", new Promise(function (resolve, reject) {
572
- _toConsumableArray(Array(limit || 1)).forEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
573
- var index;
574
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
575
- while (1) {
576
- switch (_context2.prev = _context2.next) {
577
- case 0:
578
- active += 1;
579
- _context2.next = 3;
580
- return nextIndex();
581
-
582
- case 3:
583
- index = _context2.sent;
584
-
585
- case 4:
586
- if (!(index < array.length)) {
587
- _context2.next = 19;
588
- break;
589
- }
590
-
591
- _context2.prev = 5;
592
- _context2.next = 8;
593
- return f(array[index], index);
594
-
595
- case 8:
596
- results[index] = _context2.sent;
597
- _context2.next = 14;
598
- break;
599
-
600
- case 11:
601
- _context2.prev = 11;
602
- _context2.t0 = _context2["catch"](5);
603
- reject(_context2.t0);
604
-
605
- case 14:
606
- _context2.next = 16;
607
- return nextIndex();
608
-
609
- case 16:
610
- index = _context2.sent;
611
- _context2.next = 4;
612
- break;
613
-
614
- case 19:
615
- // When finished and no more workers are active, resolve
616
- active -= 1;
617
-
618
- if (active === 0) {
619
- resolve(results);
620
- }
621
-
622
- case 21:
623
- case "end":
624
- return _context2.stop();
625
- }
626
- }
627
- }, _callee2, null, [[5, 11]]);
628
- })));
476
+ _context.next = 3;
477
+ return new Promise(function (resolve) {
478
+ return setTimeout(resolve, 10);
479
+ });
480
+ case 3:
481
+ _context.next = 0;
482
+ break;
483
+ case 5:
484
+ locked = true;
485
+ thisIndex = index;
486
+ index += 1;
487
+ locked = false;
488
+ return _context.abrupt("return", thisIndex);
489
+ case 10:
490
+ case "end":
491
+ return _context.stop();
492
+ }
493
+ }, _callee);
629
494
  }));
630
-
631
- case 6:
632
- case "end":
633
- return _context3.stop();
634
- }
495
+ return function nextIndex() {
496
+ return _ref.apply(this, arguments);
497
+ };
498
+ }();
499
+ results = [];
500
+ active = 0;
501
+ return _context3.abrupt("return", new Promise(function (resolve, reject) {
502
+ _toConsumableArray(Array(limit || 1)).forEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
503
+ var index;
504
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
505
+ while (1) switch (_context2.prev = _context2.next) {
506
+ case 0:
507
+ active += 1;
508
+ _context2.next = 3;
509
+ return nextIndex();
510
+ case 3:
511
+ index = _context2.sent;
512
+ case 4:
513
+ if (!(index < array.length)) {
514
+ _context2.next = 19;
515
+ break;
516
+ }
517
+ _context2.prev = 5;
518
+ _context2.next = 8;
519
+ return f(array[index], index);
520
+ case 8:
521
+ results[index] = _context2.sent;
522
+ _context2.next = 14;
523
+ break;
524
+ case 11:
525
+ _context2.prev = 11;
526
+ _context2.t0 = _context2["catch"](5);
527
+ reject(_context2.t0);
528
+ case 14:
529
+ _context2.next = 16;
530
+ return nextIndex();
531
+ case 16:
532
+ index = _context2.sent;
533
+ _context2.next = 4;
534
+ break;
535
+ case 19:
536
+ // When finished and no more workers are active, resolve
537
+ active -= 1;
538
+ if (active === 0) {
539
+ resolve(results);
540
+ }
541
+ case 21:
542
+ case "end":
543
+ return _context2.stop();
544
+ }
545
+ }, _callee2, null, [[5, 11]]);
546
+ })));
547
+ }));
548
+ case 6:
549
+ case "end":
550
+ return _context3.stop();
635
551
  }
636
552
  }, _callee3);
637
553
  }));
638
-
639
554
  function LimitedMap(_x, _x2, _x3) {
640
555
  return _LimitedMap.apply(this, arguments);
641
556
  }
642
-
643
557
  return LimitedMap;
644
558
  }(),
645
559
  ResponseToJson: function () {
646
560
  var _ResponseToJson = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(response) {
647
561
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
648
- while (1) {
649
- switch (_context4.prev = _context4.next) {
650
- case 0:
651
- return _context4.abrupt("return", Utils.ResponseToFormat("json", response));
652
-
653
- case 1:
654
- case "end":
655
- return _context4.stop();
656
- }
562
+ while (1) switch (_context4.prev = _context4.next) {
563
+ case 0:
564
+ return _context4.abrupt("return", Utils.ResponseToFormat("json", response));
565
+ case 1:
566
+ case "end":
567
+ return _context4.stop();
657
568
  }
658
569
  }, _callee4);
659
570
  }));
660
-
661
571
  function ResponseToJson(_x4) {
662
572
  return _ResponseToJson.apply(this, arguments);
663
573
  }
664
-
665
574
  return ResponseToJson;
666
575
  }(),
667
576
  ResponseToFormat: function () {
668
577
  var _ResponseToFormat = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(format, response) {
669
578
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
670
- while (1) {
671
- switch (_context5.prev = _context5.next) {
672
- case 0:
673
- _context5.next = 2;
674
- return response;
675
-
676
- case 2:
677
- response = _context5.sent;
678
- _context5.t0 = format.toLowerCase();
679
- _context5.next = _context5.t0 === "json" ? 6 : _context5.t0 === "text" ? 9 : _context5.t0 === "blob" ? 12 : _context5.t0 === "arraybuffer" ? 15 : _context5.t0 === "formdata" ? 18 : _context5.t0 === "buffer" ? 21 : 24;
680
- break;
681
-
682
- case 6:
683
- _context5.next = 8;
684
- return response.json();
685
-
686
- case 8:
687
- return _context5.abrupt("return", _context5.sent);
688
-
689
- case 9:
690
- _context5.next = 11;
691
- return response.text();
692
-
693
- case 11:
694
- return _context5.abrupt("return", _context5.sent);
695
-
696
- case 12:
697
- _context5.next = 14;
698
- return response.blob();
699
-
700
- case 14:
701
- return _context5.abrupt("return", _context5.sent);
702
-
703
- case 15:
704
- _context5.next = 17;
705
- return response.arrayBuffer();
706
-
707
- case 17:
708
- return _context5.abrupt("return", _context5.sent);
709
-
710
- case 18:
711
- _context5.next = 20;
712
- return response.formData();
713
-
714
- case 20:
715
- return _context5.abrupt("return", _context5.sent);
716
-
717
- case 21:
718
- _context5.next = 23;
719
- return response.buffer();
720
-
721
- case 23:
722
- return _context5.abrupt("return", _context5.sent);
723
-
724
- case 24:
725
- return _context5.abrupt("return", response);
726
-
727
- case 25:
728
- case "end":
729
- return _context5.stop();
730
- }
579
+ while (1) switch (_context5.prev = _context5.next) {
580
+ case 0:
581
+ _context5.next = 2;
582
+ return response;
583
+ case 2:
584
+ response = _context5.sent;
585
+ _context5.t0 = format.toLowerCase();
586
+ _context5.next = _context5.t0 === "json" ? 6 : _context5.t0 === "text" ? 9 : _context5.t0 === "blob" ? 12 : _context5.t0 === "arraybuffer" ? 15 : _context5.t0 === "formdata" ? 18 : _context5.t0 === "buffer" ? 21 : 24;
587
+ break;
588
+ case 6:
589
+ _context5.next = 8;
590
+ return response.json();
591
+ case 8:
592
+ return _context5.abrupt("return", _context5.sent);
593
+ case 9:
594
+ _context5.next = 11;
595
+ return response.text();
596
+ case 11:
597
+ return _context5.abrupt("return", _context5.sent);
598
+ case 12:
599
+ _context5.next = 14;
600
+ return response.blob();
601
+ case 14:
602
+ return _context5.abrupt("return", _context5.sent);
603
+ case 15:
604
+ _context5.next = 17;
605
+ return response.arrayBuffer();
606
+ case 17:
607
+ return _context5.abrupt("return", _context5.sent);
608
+ case 18:
609
+ _context5.next = 20;
610
+ return response.formData();
611
+ case 20:
612
+ return _context5.abrupt("return", _context5.sent);
613
+ case 21:
614
+ _context5.next = 23;
615
+ return response.buffer();
616
+ case 23:
617
+ return _context5.abrupt("return", _context5.sent);
618
+ case 24:
619
+ return _context5.abrupt("return", response);
620
+ case 25:
621
+ case "end":
622
+ return _context5.stop();
731
623
  }
732
624
  }, _callee5);
733
625
  }));
734
-
735
626
  function ResponseToFormat(_x5, _x6) {
736
627
  return _ResponseToFormat.apply(this, arguments);
737
628
  }
738
-
739
629
  return ResponseToFormat;
740
630
  }(),
741
-
742
631
  /**
743
632
  * Resize the image file or link URL to the specified maximum height. Can also be used to remove
744
633
  * max height parameter(s) from a url if height is not specified.
@@ -750,46 +639,35 @@ var Utils = {
750
639
  */
751
640
  ResizeImage: function ResizeImage(_ref3) {
752
641
  var imageUrl = _ref3.imageUrl,
753
- height = _ref3.height;
754
-
642
+ height = _ref3.height;
755
643
  if (!imageUrl || imageUrl && !imageUrl.startsWith("http")) {
756
644
  return imageUrl;
757
645
  }
758
-
759
646
  imageUrl = URI(imageUrl).removeSearch("height").removeSearch("header-x_image_height");
760
-
761
647
  if (height && !isNaN(parseInt(height))) {
762
648
  imageUrl.addSearch("height", parseInt(height));
763
649
  }
764
-
765
650
  return imageUrl.toString();
766
651
  },
767
652
  SafeTraverse: function SafeTraverse(object) {
768
653
  for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
769
654
  keys[_key - 1] = arguments[_key];
770
655
  }
771
-
772
656
  if (!object) {
773
657
  return object;
774
658
  }
775
-
776
659
  if (keys.length === 1 && Array.isArray(keys[0])) {
777
660
  keys = keys[0];
778
661
  }
779
-
780
662
  var result = object;
781
-
782
663
  for (var i = 0; i < keys.length; i++) {
783
664
  result = result[keys[i]];
784
-
785
665
  if (result === undefined) {
786
666
  return undefined;
787
667
  }
788
668
  }
789
-
790
669
  return result;
791
670
  },
792
-
793
671
  /**
794
672
  * Determine if the given value is cloneable - Data passed in messages must be cloneable
795
673
  *
@@ -801,7 +679,6 @@ var Utils = {
801
679
  // Primitive value
802
680
  return true;
803
681
  }
804
-
805
682
  switch ({}.toString.call(value).slice(8, -1)) {
806
683
  // Class
807
684
  case "Boolean":
@@ -815,24 +692,19 @@ var Utils = {
815
692
  case "ImageBitmap":
816
693
  case "ArrayBuffer":
817
694
  return true;
818
-
819
695
  case "Array":
820
696
  case "Object":
821
697
  return Object.keys(value).every(function (prop) {
822
698
  return Utils.IsCloneable(value[prop]);
823
699
  });
824
-
825
700
  case "Map":
826
701
  return _toConsumableArray(value.keys()).every(Utils.IsCloneable) && _toConsumableArray(value.values()).every(Utils.IsCloneable);
827
-
828
702
  case "Set":
829
703
  return _toConsumableArray(value.keys()).every(Utils.IsCloneable);
830
-
831
704
  default:
832
705
  return false;
833
706
  }
834
707
  },
835
-
836
708
  /**
837
709
  * Make the given value cloneable if it is not already.
838
710
  *
@@ -849,17 +721,14 @@ var Utils = {
849
721
  if (Utils.IsCloneable(value)) {
850
722
  return value;
851
723
  }
852
-
853
724
  if (Buffer.isBuffer(value)) {
854
725
  return Utils.BufferToArrayBuffer(value);
855
726
  }
856
-
857
727
  switch ({}.toString.call(value).slice(8, -1)) {
858
728
  // Class
859
729
  case "Response":
860
730
  case "Function":
861
731
  return undefined;
862
-
863
732
  case "Boolean":
864
733
  case "Number":
865
734
  case "String":
@@ -871,47 +740,38 @@ var Utils = {
871
740
  case "ImageBitmap":
872
741
  case "ArrayBuffer":
873
742
  return value;
874
-
875
743
  case "Array":
876
744
  return value.map(function (element) {
877
745
  return Utils.MakeClonable(element);
878
746
  });
879
-
880
747
  case "Set":
881
748
  return new Set(Array.from(value.keys()).map(function (entry) {
882
749
  return Utils.MakeClonable(entry);
883
750
  }));
884
-
885
751
  case "Map":
886
752
  var cloneableMap = new Map();
887
753
  Array.from(value.keys()).forEach(function (key) {
888
754
  var cloneable = Utils.MakeClonable(value.get(key));
889
-
890
755
  if (cloneable) {
891
756
  cloneableMap.set(key, cloneable);
892
757
  }
893
758
  });
894
759
  return cloneableMap;
895
-
896
760
  case "Error":
897
761
  return value.message;
898
-
899
762
  case "Object":
900
763
  var cloneableObject = {};
901
764
  Object.keys(value).map(function (key) {
902
765
  var cloneable = Utils.MakeClonable(value[key]);
903
-
904
766
  if (cloneable) {
905
767
  cloneableObject[key] = cloneable;
906
768
  }
907
769
  });
908
770
  return cloneableObject;
909
-
910
771
  default:
911
772
  return JSON.parse(JSON.stringify(value));
912
773
  }
913
774
  },
914
-
915
775
  /**
916
776
  * Converts the given string to a public address
917
777
  *