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