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