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