@eluvio/elv-client-js 4.0.147 → 4.1.0
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 +2 -67
- package/dist/ElvClient-min.js.LICENSE.txt +72 -0
- package/dist/ElvClient-node-min.js +2 -66
- package/dist/ElvClient-node-min.js.LICENSE.txt +72 -0
- package/dist/ElvFrameClient-min.js +2 -60
- package/dist/ElvFrameClient-min.js.LICENSE.txt +72 -0
- package/dist/ElvPermissionsClient-min.js +2 -60
- package/dist/ElvPermissionsClient-min.js.LICENSE.txt +72 -0
- package/dist/ElvWalletClient-min.js +2 -67
- package/dist/ElvWalletClient-min.js.LICENSE.txt +72 -0
- package/dist/ElvWalletClient-node-min.js +2 -66
- package/dist/ElvWalletClient-node-min.js.LICENSE.txt +72 -0
- package/dist/src/AuthorizationClient.js +713 -715
- package/dist/src/ContentObjectAudit.js +59 -59
- package/dist/src/Crypto.js +85 -86
- package/dist/src/ElvClient.js +532 -501
- package/dist/src/ElvWallet.js +30 -28
- package/dist/src/EthClient.js +316 -316
- package/dist/src/FrameClient.js +70 -71
- package/dist/src/HttpClient.js +60 -60
- package/dist/src/Id.js +1 -2
- package/dist/src/PermissionsClient.js +501 -489
- package/dist/src/RemoteSigner.js +83 -84
- package/dist/src/UserProfileClient.js +392 -374
- package/dist/src/Utils.js +67 -67
- package/dist/src/Validation.js +20 -12
- package/dist/src/client/ABRPublishing.js +412 -356
- package/dist/src/client/AccessGroups.js +479 -476
- package/dist/src/client/ContentAccess.js +1750 -1804
- package/dist/src/client/ContentManagement.js +874 -874
- package/dist/src/client/Contracts.js +586 -590
- package/dist/src/client/Files.js +702 -686
- package/dist/src/client/LiveConf.js +3 -5
- package/dist/src/client/LiveStream.js +659 -652
- package/dist/src/client/NFT.js +16 -16
- package/dist/src/client/NTP.js +84 -84
- package/dist/src/client/Shares.js +51 -51
- package/dist/src/walletClient/ClientMethods.js +979 -953
- package/dist/src/walletClient/Notifications.js +14 -14
- package/dist/src/walletClient/Profile.js +68 -68
- package/dist/src/walletClient/Utils.js +17 -17
- package/dist/src/walletClient/index.js +574 -564
- package/package.json +17 -16
- package/src/client/AccessGroups.js +1 -1
- package/testScripts/Test.js +5 -1
- package/webpack.config.js +10 -13
- package/dist/src/ContentObjectVerification.js +0 -281
package/dist/src/ElvClient.js
CHANGED
|
@@ -5,8 +5,8 @@ var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
|
5
5
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
6
6
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
7
7
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
8
|
-
function ownKeys(
|
|
9
|
-
function _objectSpread(
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
10
|
if (typeof globalThis.Buffer === "undefined") {
|
|
11
11
|
globalThis.Buffer = require("buffer/").Buffer;
|
|
12
12
|
}
|
|
@@ -147,7 +147,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
147
147
|
* @param {string=} clientIP - IP address to use in determining the region to use
|
|
148
148
|
* @return {Promise<Object>} - Object containing content space ID and fabric and ethereum URLs
|
|
149
149
|
*/
|
|
150
|
-
_createClass(ElvClient, [{
|
|
150
|
+
return _createClass(ElvClient, [{
|
|
151
151
|
key: "Log",
|
|
152
152
|
value: function Log(message) {
|
|
153
153
|
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -190,28 +190,28 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
190
190
|
}).forEach(function (methodName) {
|
|
191
191
|
var originalMethod = klass[methodName].bind(klass);
|
|
192
192
|
if (originalMethod.constructor.name === "AsyncFunction") {
|
|
193
|
-
klass[methodName] = /*#__PURE__*/_asyncToGenerator(
|
|
193
|
+
klass[methodName] = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
194
194
|
var start,
|
|
195
195
|
_len,
|
|
196
196
|
args,
|
|
197
197
|
_key,
|
|
198
198
|
result,
|
|
199
199
|
_args = arguments;
|
|
200
|
-
return _regeneratorRuntime.wrap(function
|
|
200
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
201
201
|
while (1) switch (_context.prev = _context.next) {
|
|
202
202
|
case 0:
|
|
203
203
|
start = Date.now();
|
|
204
204
|
for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
205
205
|
args[_key] = _args[_key];
|
|
206
206
|
}
|
|
207
|
-
_context.next =
|
|
207
|
+
_context.next = 1;
|
|
208
208
|
return originalMethod.apply(void 0, args);
|
|
209
|
-
case
|
|
209
|
+
case 1:
|
|
210
210
|
result = _context.sent;
|
|
211
211
|
// eslint-disable-next-line no-console
|
|
212
212
|
console.log(methodName, Date.now() - start, "ms", JSON.stringify(args));
|
|
213
213
|
return _context.abrupt("return", result);
|
|
214
|
-
case
|
|
214
|
+
case 2:
|
|
215
215
|
case "end":
|
|
216
216
|
return _context.stop();
|
|
217
217
|
}
|
|
@@ -236,14 +236,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
236
236
|
}, {
|
|
237
237
|
key: "InitializeClients",
|
|
238
238
|
value: function () {
|
|
239
|
-
var _InitializeClients = _asyncToGenerator(
|
|
239
|
+
var _InitializeClients = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
240
240
|
var _ref3,
|
|
241
241
|
staticToken,
|
|
242
242
|
uris,
|
|
243
243
|
wallet,
|
|
244
244
|
signer,
|
|
245
245
|
_args2 = arguments;
|
|
246
|
-
return _regeneratorRuntime.wrap(function
|
|
246
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
247
247
|
while (1) switch (_context2.prev = _context2.next) {
|
|
248
248
|
case 0:
|
|
249
249
|
_ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, staticToken = _ref3.staticToken;
|
|
@@ -251,6 +251,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
251
251
|
this.contentTypes = {};
|
|
252
252
|
this.encryptionConks = {};
|
|
253
253
|
this.stateChannelAccess = {};
|
|
254
|
+
this.objectInfo = {};
|
|
254
255
|
this.objectTenantIds = {};
|
|
255
256
|
this.objectLibraryIds = {};
|
|
256
257
|
this.objectImageUrls = {};
|
|
@@ -310,7 +311,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
310
311
|
// Initialize crypto wasm
|
|
311
312
|
this.Crypto = Crypto;
|
|
312
313
|
this.Crypto.ElvCrypto();
|
|
313
|
-
case
|
|
314
|
+
case 1:
|
|
314
315
|
case "end":
|
|
315
316
|
return _context2.stop();
|
|
316
317
|
}
|
|
@@ -347,25 +348,25 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
347
348
|
*/
|
|
348
349
|
}, {
|
|
349
350
|
key: "UseRegion",
|
|
350
|
-
value: function () {
|
|
351
|
-
var _UseRegion = _asyncToGenerator(
|
|
351
|
+
value: (function () {
|
|
352
|
+
var _UseRegion = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
352
353
|
var region, _yield$ElvClient$Conf, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs;
|
|
353
|
-
return _regeneratorRuntime.wrap(function
|
|
354
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
354
355
|
while (1) switch (_context3.prev = _context3.next) {
|
|
355
356
|
case 0:
|
|
356
357
|
region = _ref4.region;
|
|
357
358
|
if (this.configUrl) {
|
|
358
|
-
_context3.next =
|
|
359
|
+
_context3.next = 1;
|
|
359
360
|
break;
|
|
360
361
|
}
|
|
361
362
|
throw Error("Unable to change region: Configuration URL not set");
|
|
362
|
-
case
|
|
363
|
-
_context3.next =
|
|
363
|
+
case 1:
|
|
364
|
+
_context3.next = 2;
|
|
364
365
|
return ElvClient.Configuration({
|
|
365
366
|
configUrl: this.configUrl,
|
|
366
367
|
region: region
|
|
367
368
|
});
|
|
368
|
-
case
|
|
369
|
+
case 2:
|
|
369
370
|
_yield$ElvClient$Conf = _context3.sent;
|
|
370
371
|
fabricURIs = _yield$ElvClient$Conf.fabricURIs;
|
|
371
372
|
ethereumURIs = _yield$ElvClient$Conf.ethereumURIs;
|
|
@@ -387,7 +388,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
387
388
|
authServiceURIs: authServiceURIs,
|
|
388
389
|
searchURIs: searchURIs
|
|
389
390
|
});
|
|
390
|
-
case
|
|
391
|
+
case 3:
|
|
391
392
|
case "end":
|
|
392
393
|
return _context3.stop();
|
|
393
394
|
}
|
|
@@ -407,26 +408,27 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
407
408
|
*
|
|
408
409
|
* @return {Promise<Object>} - An object containing the updated fabric and ethereum URLs in order of preference
|
|
409
410
|
*/
|
|
411
|
+
)
|
|
410
412
|
}, {
|
|
411
413
|
key: "ResetRegion",
|
|
412
|
-
value: function () {
|
|
413
|
-
var _ResetRegion = _asyncToGenerator(
|
|
414
|
-
return _regeneratorRuntime.wrap(function
|
|
414
|
+
value: (function () {
|
|
415
|
+
var _ResetRegion = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
416
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
415
417
|
while (1) switch (_context4.prev = _context4.next) {
|
|
416
418
|
case 0:
|
|
417
419
|
if (this.configUrl) {
|
|
418
|
-
_context4.next =
|
|
420
|
+
_context4.next = 1;
|
|
419
421
|
break;
|
|
420
422
|
}
|
|
421
423
|
throw Error("Unable to change region: Configuration URL not set");
|
|
422
|
-
case
|
|
423
|
-
_context4.next =
|
|
424
|
+
case 1:
|
|
425
|
+
_context4.next = 2;
|
|
424
426
|
return this.UseRegion({
|
|
425
427
|
region: ""
|
|
426
428
|
});
|
|
427
|
-
case
|
|
429
|
+
case 2:
|
|
428
430
|
return _context4.abrupt("return", _context4.sent);
|
|
429
|
-
case
|
|
431
|
+
case 3:
|
|
430
432
|
case "end":
|
|
431
433
|
return _context4.stop();
|
|
432
434
|
}
|
|
@@ -449,25 +451,26 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
449
451
|
*
|
|
450
452
|
* @return {Promise<string>} - The node ID reported by the fabric
|
|
451
453
|
*/
|
|
454
|
+
)
|
|
452
455
|
}, {
|
|
453
456
|
key: "NodeId",
|
|
454
|
-
value: function () {
|
|
455
|
-
var _NodeId = _asyncToGenerator(
|
|
457
|
+
value: (function () {
|
|
458
|
+
var _NodeId = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
|
|
456
459
|
var region, _yield$ElvClient$Conf2, nodeId;
|
|
457
|
-
return _regeneratorRuntime.wrap(function
|
|
460
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
458
461
|
while (1) switch (_context5.prev = _context5.next) {
|
|
459
462
|
case 0:
|
|
460
463
|
region = _ref5.region;
|
|
461
|
-
_context5.next =
|
|
464
|
+
_context5.next = 1;
|
|
462
465
|
return ElvClient.Configuration({
|
|
463
466
|
configUrl: this.configUrl,
|
|
464
467
|
region: region
|
|
465
468
|
});
|
|
466
|
-
case
|
|
469
|
+
case 1:
|
|
467
470
|
_yield$ElvClient$Conf2 = _context5.sent;
|
|
468
471
|
nodeId = _yield$ElvClient$Conf2.nodeId;
|
|
469
472
|
return _context5.abrupt("return", nodeId);
|
|
470
|
-
case
|
|
473
|
+
case 2:
|
|
471
474
|
case "end":
|
|
472
475
|
return _context5.stop();
|
|
473
476
|
}
|
|
@@ -485,6 +488,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
485
488
|
*
|
|
486
489
|
* @return {Promise<Object>} - An object containing the lists of fabric, ethereum, auth service, and search urls in use by the client
|
|
487
490
|
*/
|
|
491
|
+
)
|
|
488
492
|
}, {
|
|
489
493
|
key: "Nodes",
|
|
490
494
|
value: function Nodes() {
|
|
@@ -557,8 +561,8 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
557
561
|
*/
|
|
558
562
|
}, {
|
|
559
563
|
key: "SpaceNodes",
|
|
560
|
-
value: function () {
|
|
561
|
-
var _SpaceNodes = _asyncToGenerator(
|
|
564
|
+
value: (function () {
|
|
565
|
+
var _SpaceNodes = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
562
566
|
var _this = this;
|
|
563
567
|
var _ref7,
|
|
564
568
|
matchEndpoint,
|
|
@@ -570,16 +574,16 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
570
574
|
_yield$this$utils$Res2,
|
|
571
575
|
_nodes,
|
|
572
576
|
_args6 = arguments;
|
|
573
|
-
return _regeneratorRuntime.wrap(function
|
|
577
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
574
578
|
while (1) switch (_context6.prev = _context6.next) {
|
|
575
579
|
case 0:
|
|
576
580
|
_ref7 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, matchEndpoint = _ref7.matchEndpoint, matchNodeId = _ref7.matchNodeId, matchWriteToken = _ref7.matchWriteToken;
|
|
577
581
|
this.SetStaticToken();
|
|
578
582
|
if (!matchEndpoint) {
|
|
579
|
-
_context6.next =
|
|
583
|
+
_context6.next = 3;
|
|
580
584
|
break;
|
|
581
585
|
}
|
|
582
|
-
_context6.next =
|
|
586
|
+
_context6.next = 1;
|
|
583
587
|
return this.utils.ResponseToJson(this.HttpClient.Request({
|
|
584
588
|
path: UrlJoin("nodes"),
|
|
585
589
|
method: "GET",
|
|
@@ -587,15 +591,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
587
591
|
Authorization: "Bearer ".concat(this.staticToken)
|
|
588
592
|
}
|
|
589
593
|
}));
|
|
590
|
-
case
|
|
594
|
+
case 1:
|
|
591
595
|
_yield$this$utils$Res = _context6.sent;
|
|
592
596
|
nodes = _yield$this$utils$Res.nodes;
|
|
593
597
|
if (!(!nodes || !Array.isArray(nodes) || nodes.length === 0)) {
|
|
594
|
-
_context6.next =
|
|
598
|
+
_context6.next = 2;
|
|
595
599
|
break;
|
|
596
600
|
}
|
|
597
601
|
return _context6.abrupt("return", []);
|
|
598
|
-
case
|
|
602
|
+
case 2:
|
|
599
603
|
return _context6.abrupt("return", nodes.filter(function (node) {
|
|
600
604
|
var match = false;
|
|
601
605
|
if (node.services && node.services.fabric_api && node.services.fabric_api.urls) {
|
|
@@ -612,13 +616,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
612
616
|
_this.ClearStaticToken();
|
|
613
617
|
return match;
|
|
614
618
|
}));
|
|
615
|
-
case
|
|
619
|
+
case 3:
|
|
616
620
|
if (!matchNodeId) {
|
|
617
|
-
_context6.next =
|
|
621
|
+
_context6.next = 5;
|
|
618
622
|
break;
|
|
619
623
|
}
|
|
620
624
|
this.SetStaticToken();
|
|
621
|
-
_context6.next =
|
|
625
|
+
_context6.next = 4;
|
|
622
626
|
return this.utils.ResponseToJson(this.HttpClient.Request({
|
|
623
627
|
path: UrlJoin("nodes", matchNodeId),
|
|
624
628
|
method: "GET",
|
|
@@ -626,17 +630,17 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
626
630
|
Authorization: "Bearer ".concat(this.staticToken)
|
|
627
631
|
}
|
|
628
632
|
}));
|
|
629
|
-
case
|
|
633
|
+
case 4:
|
|
630
634
|
node = _context6.sent;
|
|
631
635
|
this.ClearStaticToken();
|
|
632
636
|
return _context6.abrupt("return", [node]);
|
|
633
|
-
case
|
|
637
|
+
case 5:
|
|
634
638
|
if (!matchWriteToken) {
|
|
635
|
-
_context6.next =
|
|
639
|
+
_context6.next = 7;
|
|
636
640
|
break;
|
|
637
641
|
}
|
|
638
642
|
this.SetStaticToken();
|
|
639
|
-
_context6.next =
|
|
643
|
+
_context6.next = 6;
|
|
640
644
|
return this.utils.ResponseToJson(this.HttpClient.Request({
|
|
641
645
|
path: UrlJoin("nodes"),
|
|
642
646
|
method: "GET",
|
|
@@ -647,12 +651,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
647
651
|
token: matchWriteToken
|
|
648
652
|
}
|
|
649
653
|
}));
|
|
650
|
-
case
|
|
654
|
+
case 6:
|
|
651
655
|
_yield$this$utils$Res2 = _context6.sent;
|
|
652
656
|
_nodes = _yield$this$utils$Res2.nodes;
|
|
653
657
|
this.ClearStaticToken();
|
|
654
658
|
return _context6.abrupt("return", _nodes);
|
|
655
|
-
case
|
|
659
|
+
case 7:
|
|
656
660
|
case "end":
|
|
657
661
|
return _context6.stop();
|
|
658
662
|
}
|
|
@@ -669,6 +673,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
669
673
|
* @methodGroup Nodes
|
|
670
674
|
* @returns {Object} - The name, ID and configuration URL of the network
|
|
671
675
|
*/
|
|
676
|
+
)
|
|
672
677
|
}, {
|
|
673
678
|
key: "NetworkInfo",
|
|
674
679
|
value: function NetworkInfo() {
|
|
@@ -690,31 +695,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
690
695
|
*/
|
|
691
696
|
}, {
|
|
692
697
|
key: "WriteTokenNodeUrlNetwork",
|
|
693
|
-
value: function () {
|
|
694
|
-
var _WriteTokenNodeUrlNetwork = _asyncToGenerator(
|
|
698
|
+
value: (function () {
|
|
699
|
+
var _WriteTokenNodeUrlNetwork = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref8) {
|
|
695
700
|
var writeToken, nodes, nodeUrl;
|
|
696
|
-
return _regeneratorRuntime.wrap(function
|
|
701
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
697
702
|
while (1) switch (_context7.prev = _context7.next) {
|
|
698
703
|
case 0:
|
|
699
704
|
writeToken = _ref8.writeToken;
|
|
700
705
|
ValidateWriteToken(writeToken);
|
|
701
|
-
_context7.next =
|
|
706
|
+
_context7.next = 1;
|
|
702
707
|
return this.SpaceNodes({
|
|
703
708
|
matchWriteToken: writeToken
|
|
704
709
|
});
|
|
705
|
-
case
|
|
710
|
+
case 1:
|
|
706
711
|
nodes = _context7.sent;
|
|
707
712
|
nodeUrl = nodes && nodes[0] && nodes[0].services && nodes[0].services.fabric_api && nodes[0].services.fabric_api.urls && nodes[0].services.fabric_api.urls[0];
|
|
708
713
|
if (nodeUrl) {
|
|
709
|
-
_context7.next =
|
|
714
|
+
_context7.next = 2;
|
|
710
715
|
break;
|
|
711
716
|
}
|
|
712
717
|
// eslint-disable-next-line no-console
|
|
713
718
|
console.error("No node url found for write token: ".concat(writeToken));
|
|
714
719
|
return _context7.abrupt("return", "");
|
|
715
|
-
case
|
|
720
|
+
case 2:
|
|
716
721
|
return _context7.abrupt("return", nodeUrl ? nodeUrl.toString() : undefined);
|
|
717
|
-
case
|
|
722
|
+
case 3:
|
|
718
723
|
case "end":
|
|
719
724
|
return _context7.stop();
|
|
720
725
|
}
|
|
@@ -734,6 +739,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
734
739
|
*
|
|
735
740
|
* @returns {string} - The node url for a write token
|
|
736
741
|
*/
|
|
742
|
+
)
|
|
737
743
|
}, {
|
|
738
744
|
key: "WriteTokenNodeUrlLocal",
|
|
739
745
|
value: function WriteTokenNodeUrlLocal(_ref9) {
|
|
@@ -744,9 +750,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
744
750
|
}
|
|
745
751
|
}, {
|
|
746
752
|
key: "RecordWriteToken",
|
|
747
|
-
value: function RecordWriteToken(
|
|
748
|
-
var writeToken =
|
|
749
|
-
fabricNodeUrl =
|
|
753
|
+
value: function RecordWriteToken(_ref0) {
|
|
754
|
+
var writeToken = _ref0.writeToken,
|
|
755
|
+
fabricNodeUrl = _ref0.fabricNodeUrl;
|
|
750
756
|
this.HttpClient.RecordWriteToken(writeToken, fabricNodeUrl);
|
|
751
757
|
}
|
|
752
758
|
|
|
@@ -796,10 +802,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
796
802
|
*/
|
|
797
803
|
}, {
|
|
798
804
|
key: "SetSigner",
|
|
799
|
-
value: function SetSigner(
|
|
800
|
-
var signer =
|
|
801
|
-
|
|
802
|
-
reset =
|
|
805
|
+
value: function SetSigner(_ref1) {
|
|
806
|
+
var signer = _ref1.signer,
|
|
807
|
+
_ref1$reset = _ref1.reset,
|
|
808
|
+
reset = _ref1$reset === void 0 ? true : _ref1$reset;
|
|
803
809
|
this.staticToken = undefined;
|
|
804
810
|
signer.connect(this.ethClient.Provider());
|
|
805
811
|
signer.provider.pollingInterval = 500;
|
|
@@ -823,41 +829,41 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
823
829
|
*/
|
|
824
830
|
}, {
|
|
825
831
|
key: "SetRemoteSigner",
|
|
826
|
-
value: function () {
|
|
827
|
-
var _SetRemoteSigner = _asyncToGenerator(
|
|
828
|
-
var idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth, signer;
|
|
829
|
-
return _regeneratorRuntime.wrap(function
|
|
832
|
+
value: (function () {
|
|
833
|
+
var _SetRemoteSigner = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref10) {
|
|
834
|
+
var idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth, signer, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
|
|
835
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
830
836
|
while (1) switch (_context8.prev = _context8.next) {
|
|
831
837
|
case 0:
|
|
832
|
-
idToken =
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
_context8.next =
|
|
838
|
+
idToken = _ref10.idToken, authToken = _ref10.authToken, tenantId = _ref10.tenantId, extraData = _ref10.extraData, signerURIs = _ref10.signerURIs, unsignedPublicAuth = _ref10.unsignedPublicAuth;
|
|
839
|
+
_t = RemoteSigner;
|
|
840
|
+
_t2 = signerURIs || this.authServiceURIs;
|
|
841
|
+
_t3 = idToken;
|
|
842
|
+
_t4 = authToken;
|
|
843
|
+
_t5 = tenantId;
|
|
844
|
+
_context8.next = 1;
|
|
839
845
|
return this.ethClient.Provider();
|
|
840
|
-
case
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
signerURIs:
|
|
846
|
-
idToken:
|
|
847
|
-
authToken:
|
|
848
|
-
tenantId:
|
|
849
|
-
provider:
|
|
850
|
-
extraData:
|
|
851
|
-
unsignedPublicAuth:
|
|
846
|
+
case 1:
|
|
847
|
+
_t6 = _context8.sent;
|
|
848
|
+
_t7 = extraData;
|
|
849
|
+
_t8 = unsignedPublicAuth;
|
|
850
|
+
_t9 = {
|
|
851
|
+
signerURIs: _t2,
|
|
852
|
+
idToken: _t3,
|
|
853
|
+
authToken: _t4,
|
|
854
|
+
tenantId: _t5,
|
|
855
|
+
provider: _t6,
|
|
856
|
+
extraData: _t7,
|
|
857
|
+
unsignedPublicAuth: _t8
|
|
852
858
|
};
|
|
853
|
-
signer = new
|
|
854
|
-
_context8.next =
|
|
859
|
+
signer = new _t(_t9);
|
|
860
|
+
_context8.next = 2;
|
|
855
861
|
return signer.Initialize();
|
|
856
|
-
case
|
|
862
|
+
case 2:
|
|
857
863
|
this.SetSigner({
|
|
858
864
|
signer: signer
|
|
859
865
|
});
|
|
860
|
-
case
|
|
866
|
+
case 3:
|
|
861
867
|
case "end":
|
|
862
868
|
return _context8.stop();
|
|
863
869
|
}
|
|
@@ -878,26 +884,27 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
878
884
|
* @namedParams
|
|
879
885
|
* @param {object} provider - The web3 provider object
|
|
880
886
|
*/
|
|
887
|
+
)
|
|
881
888
|
}, {
|
|
882
889
|
key: "SetSignerFromWeb3Provider",
|
|
883
|
-
value: function () {
|
|
884
|
-
var _SetSignerFromWeb3Provider = _asyncToGenerator(
|
|
890
|
+
value: (function () {
|
|
891
|
+
var _SetSignerFromWeb3Provider = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref11) {
|
|
885
892
|
var provider, ethProvider;
|
|
886
|
-
return _regeneratorRuntime.wrap(function
|
|
893
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
887
894
|
while (1) switch (_context9.prev = _context9.next) {
|
|
888
895
|
case 0:
|
|
889
|
-
provider =
|
|
896
|
+
provider = _ref11.provider;
|
|
890
897
|
this.staticToken = undefined;
|
|
891
898
|
ethProvider = new Ethers.providers.Web3Provider(provider);
|
|
892
899
|
ethProvider.pollingInterval = 250;
|
|
893
900
|
this.signer = ethProvider.getSigner();
|
|
894
|
-
_context9.next =
|
|
901
|
+
_context9.next = 1;
|
|
895
902
|
return this.signer.getAddress();
|
|
896
|
-
case
|
|
903
|
+
case 1:
|
|
897
904
|
this.signer.address = _context9.sent;
|
|
898
|
-
_context9.next =
|
|
905
|
+
_context9.next = 2;
|
|
899
906
|
return this.InitializeClients();
|
|
900
|
-
case
|
|
907
|
+
case 2:
|
|
901
908
|
case "end":
|
|
902
909
|
return _context9.stop();
|
|
903
910
|
}
|
|
@@ -923,15 +930,16 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
923
930
|
*
|
|
924
931
|
* @return {string} - The address of the user
|
|
925
932
|
*/
|
|
933
|
+
)
|
|
926
934
|
}, {
|
|
927
935
|
key: "CreateAccount",
|
|
928
|
-
value: function () {
|
|
929
|
-
var _CreateAccount = _asyncToGenerator(
|
|
930
|
-
var tenantId, fundingToken,
|
|
931
|
-
return _regeneratorRuntime.wrap(function
|
|
932
|
-
while (1) switch (
|
|
936
|
+
value: (function () {
|
|
937
|
+
var _CreateAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(_ref12) {
|
|
938
|
+
var tenantId, fundingToken, _ref12$funds, funds, groupToken, wallet, signer;
|
|
939
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
940
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
933
941
|
case 0:
|
|
934
|
-
tenantId =
|
|
942
|
+
tenantId = _ref12.tenantId, fundingToken = _ref12.fundingToken, _ref12$funds = _ref12.funds, funds = _ref12$funds === void 0 ? 0.5 : _ref12$funds, groupToken = _ref12.groupToken;
|
|
935
943
|
if (!this.signer) {
|
|
936
944
|
wallet = this.GenerateWallet();
|
|
937
945
|
signer = wallet.AddAccountFromMnemonic({
|
|
@@ -941,7 +949,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
941
949
|
signer: signer
|
|
942
950
|
});
|
|
943
951
|
}
|
|
944
|
-
|
|
952
|
+
_context0.next = 1;
|
|
945
953
|
return this.authClient.MakeKMSRequest({
|
|
946
954
|
method: "POST",
|
|
947
955
|
path: "/ks/otp/fnd/".concat(tenantId),
|
|
@@ -953,21 +961,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
953
961
|
Authorization: "Bearer ".concat(fundingToken)
|
|
954
962
|
}
|
|
955
963
|
});
|
|
956
|
-
case
|
|
957
|
-
|
|
964
|
+
case 1:
|
|
965
|
+
_context0.next = 2;
|
|
958
966
|
return this.userProfileClient.CreateWallet();
|
|
959
|
-
case
|
|
960
|
-
|
|
967
|
+
case 2:
|
|
968
|
+
_context0.next = 3;
|
|
961
969
|
return this.userProfileClient.ReplaceUserMetadata({
|
|
962
970
|
metadataSubtree: "tenantContractId",
|
|
963
971
|
metadata: tenantId
|
|
964
972
|
});
|
|
965
|
-
case
|
|
973
|
+
case 3:
|
|
966
974
|
if (!groupToken) {
|
|
967
|
-
|
|
975
|
+
_context0.next = 4;
|
|
968
976
|
break;
|
|
969
977
|
}
|
|
970
|
-
|
|
978
|
+
_context0.next = 4;
|
|
971
979
|
return this.authClient.MakeKMSRequest({
|
|
972
980
|
method: "POST",
|
|
973
981
|
path: "/ks/otp/grp/".concat(tenantId),
|
|
@@ -978,13 +986,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
978
986
|
Authorization: "Bearer ".concat(groupToken)
|
|
979
987
|
}
|
|
980
988
|
});
|
|
981
|
-
case
|
|
982
|
-
return
|
|
983
|
-
case
|
|
989
|
+
case 4:
|
|
990
|
+
return _context0.abrupt("return", this.utils.FormatAddress(this.signer.address));
|
|
991
|
+
case 5:
|
|
984
992
|
case "end":
|
|
985
|
-
return
|
|
993
|
+
return _context0.stop();
|
|
986
994
|
}
|
|
987
|
-
},
|
|
995
|
+
}, _callee0, this);
|
|
988
996
|
}));
|
|
989
997
|
function CreateAccount(_x6) {
|
|
990
998
|
return _CreateAccount.apply(this, arguments);
|
|
@@ -1000,65 +1008,67 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1000
1008
|
PAYLOAD 85b json-compressed
|
|
1001
1009
|
json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
|
|
1002
1010
|
*/
|
|
1011
|
+
)
|
|
1003
1012
|
}, {
|
|
1004
1013
|
key: "PersonalSign",
|
|
1005
|
-
value: function () {
|
|
1006
|
-
var _PersonalSign = _asyncToGenerator(
|
|
1014
|
+
value: (function () {
|
|
1015
|
+
var _PersonalSign = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref13) {
|
|
1007
1016
|
var _this2 = this;
|
|
1008
1017
|
var message, addEthereumPrefix, Sign;
|
|
1009
|
-
return _regeneratorRuntime.wrap(function
|
|
1010
|
-
while (1) switch (
|
|
1018
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
1019
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1011
1020
|
case 0:
|
|
1012
|
-
message =
|
|
1021
|
+
message = _ref13.message, addEthereumPrefix = _ref13.addEthereumPrefix, Sign = _ref13.Sign;
|
|
1013
1022
|
if (!Sign) {
|
|
1014
1023
|
// Same as authClient.Sign, but authClient may not yet be initialized
|
|
1015
1024
|
Sign = /*#__PURE__*/function () {
|
|
1016
|
-
var
|
|
1017
|
-
|
|
1018
|
-
|
|
1025
|
+
var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1(message) {
|
|
1026
|
+
var _t0, _t1, _t10;
|
|
1027
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
1028
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
1019
1029
|
case 0:
|
|
1020
|
-
|
|
1030
|
+
_t0 = Ethers.utils;
|
|
1021
1031
|
if (!_this2.signer.signDigest) {
|
|
1022
|
-
|
|
1032
|
+
_context1.next = 2;
|
|
1023
1033
|
break;
|
|
1024
1034
|
}
|
|
1025
|
-
|
|
1035
|
+
_context1.next = 1;
|
|
1026
1036
|
return _this2.signer.signDigest(message);
|
|
1027
|
-
case
|
|
1028
|
-
|
|
1029
|
-
|
|
1037
|
+
case 1:
|
|
1038
|
+
_t1 = _context1.sent;
|
|
1039
|
+
_context1.next = 4;
|
|
1030
1040
|
break;
|
|
1031
|
-
case
|
|
1032
|
-
|
|
1041
|
+
case 2:
|
|
1042
|
+
_context1.next = 3;
|
|
1033
1043
|
return _this2.signer._signingKey().signDigest(message);
|
|
1034
|
-
case
|
|
1035
|
-
|
|
1036
|
-
case
|
|
1037
|
-
|
|
1038
|
-
return
|
|
1039
|
-
case
|
|
1044
|
+
case 3:
|
|
1045
|
+
_t1 = _context1.sent;
|
|
1046
|
+
case 4:
|
|
1047
|
+
_t10 = _t1;
|
|
1048
|
+
return _context1.abrupt("return", _t0.joinSignature.call(_t0, _t10));
|
|
1049
|
+
case 5:
|
|
1040
1050
|
case "end":
|
|
1041
|
-
return
|
|
1051
|
+
return _context1.stop();
|
|
1042
1052
|
}
|
|
1043
|
-
},
|
|
1053
|
+
}, _callee1);
|
|
1044
1054
|
}));
|
|
1045
1055
|
return function Sign(_x8) {
|
|
1046
|
-
return
|
|
1056
|
+
return _ref14.apply(this, arguments);
|
|
1047
1057
|
};
|
|
1048
1058
|
}();
|
|
1049
1059
|
}
|
|
1050
1060
|
if (addEthereumPrefix) {
|
|
1051
1061
|
message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
|
|
1052
1062
|
}
|
|
1053
|
-
|
|
1063
|
+
_context10.next = 1;
|
|
1054
1064
|
return Sign(message);
|
|
1055
|
-
case
|
|
1056
|
-
return
|
|
1057
|
-
case
|
|
1065
|
+
case 1:
|
|
1066
|
+
return _context10.abrupt("return", _context10.sent);
|
|
1067
|
+
case 2:
|
|
1058
1068
|
case "end":
|
|
1059
|
-
return
|
|
1069
|
+
return _context10.stop();
|
|
1060
1070
|
}
|
|
1061
|
-
},
|
|
1071
|
+
}, _callee10);
|
|
1062
1072
|
}));
|
|
1063
1073
|
function PersonalSign(_x7) {
|
|
1064
1074
|
return _PersonalSign.apply(this, arguments);
|
|
@@ -1076,68 +1086,79 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1076
1086
|
* @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
|
|
1077
1087
|
* @param {boolean=} addEthereumPrefix=true - If specified, the 'Ethereum Signed Message' prefixed hash format will be performed. Disable this if the provided Sign method already does this (e.g. Metamask)
|
|
1078
1088
|
*/
|
|
1089
|
+
)
|
|
1079
1090
|
}, {
|
|
1080
1091
|
key: "CreateFabricToken",
|
|
1081
|
-
value: function () {
|
|
1082
|
-
var _CreateFabricToken = _asyncToGenerator(
|
|
1083
|
-
var
|
|
1084
|
-
|
|
1092
|
+
value: (function () {
|
|
1093
|
+
var _CreateFabricToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
1094
|
+
var _ref15,
|
|
1095
|
+
_ref15$duration,
|
|
1085
1096
|
duration,
|
|
1086
|
-
|
|
1097
|
+
_ref15$spec,
|
|
1087
1098
|
spec,
|
|
1088
1099
|
address,
|
|
1089
1100
|
Sign,
|
|
1090
|
-
|
|
1101
|
+
_ref15$addEthereumPre,
|
|
1091
1102
|
addEthereumPrefix,
|
|
1092
|
-
|
|
1103
|
+
_ref15$context,
|
|
1093
1104
|
context,
|
|
1094
1105
|
token,
|
|
1095
1106
|
message,
|
|
1096
1107
|
signature,
|
|
1097
1108
|
compressedToken,
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1109
|
+
_args11 = arguments,
|
|
1110
|
+
_t11,
|
|
1111
|
+
_t12,
|
|
1112
|
+
_t13,
|
|
1113
|
+
_t14,
|
|
1114
|
+
_t15,
|
|
1115
|
+
_t16,
|
|
1116
|
+
_t17,
|
|
1117
|
+
_t18,
|
|
1118
|
+
_t19,
|
|
1119
|
+
_t20;
|
|
1120
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
1121
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1101
1122
|
case 0:
|
|
1102
|
-
|
|
1123
|
+
_ref15 = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {}, _ref15$duration = _ref15.duration, duration = _ref15$duration === void 0 ? 24 * 60 * 60 * 1000 : _ref15$duration, _ref15$spec = _ref15.spec, spec = _ref15$spec === void 0 ? {} : _ref15$spec, address = _ref15.address, Sign = _ref15.Sign, _ref15$addEthereumPre = _ref15.addEthereumPrefix, addEthereumPrefix = _ref15$addEthereumPre === void 0 ? true : _ref15$addEthereumPre, _ref15$context = _ref15.context, context = _ref15$context === void 0 ? {} : _ref15$context;
|
|
1103
1124
|
address = address || this.CurrentAccountAddress();
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1125
|
+
_t11 = _objectSpread;
|
|
1126
|
+
_t12 = _objectSpread({}, spec);
|
|
1127
|
+
_t13 = {};
|
|
1128
|
+
_t14 = "iusr".concat(Utils.AddressToHash(address));
|
|
1129
|
+
_t15 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
|
|
1130
|
+
_context11.next = 1;
|
|
1110
1131
|
return this.ContentSpaceId();
|
|
1111
|
-
case
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
sub:
|
|
1118
|
-
adr:
|
|
1119
|
-
spc:
|
|
1120
|
-
iat:
|
|
1121
|
-
exp:
|
|
1122
|
-
ctx:
|
|
1132
|
+
case 1:
|
|
1133
|
+
_t16 = _context11.sent;
|
|
1134
|
+
_t17 = Date.now();
|
|
1135
|
+
_t18 = Date.now() + duration;
|
|
1136
|
+
_t19 = context;
|
|
1137
|
+
_t20 = {
|
|
1138
|
+
sub: _t14,
|
|
1139
|
+
adr: _t15,
|
|
1140
|
+
spc: _t16,
|
|
1141
|
+
iat: _t17,
|
|
1142
|
+
exp: _t18,
|
|
1143
|
+
ctx: _t19
|
|
1123
1144
|
};
|
|
1124
|
-
token = (
|
|
1145
|
+
token = _t11(_t12, _t13, _t20);
|
|
1125
1146
|
message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
|
|
1126
|
-
|
|
1147
|
+
_context11.next = 2;
|
|
1127
1148
|
return this.PersonalSign({
|
|
1128
1149
|
message: message,
|
|
1129
1150
|
addEthereumPrefix: addEthereumPrefix,
|
|
1130
1151
|
Sign: Sign
|
|
1131
1152
|
});
|
|
1132
|
-
case
|
|
1133
|
-
signature =
|
|
1153
|
+
case 2:
|
|
1154
|
+
signature = _context11.sent;
|
|
1134
1155
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1135
|
-
return
|
|
1136
|
-
case
|
|
1156
|
+
return _context11.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1157
|
+
case 3:
|
|
1137
1158
|
case "end":
|
|
1138
|
-
return
|
|
1159
|
+
return _context11.stop();
|
|
1139
1160
|
}
|
|
1140
|
-
},
|
|
1161
|
+
}, _callee11, this);
|
|
1141
1162
|
}));
|
|
1142
1163
|
function CreateFabricToken() {
|
|
1143
1164
|
return _CreateFabricToken.apply(this, arguments);
|
|
@@ -1162,126 +1183,127 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1162
1183
|
* @param {number=} issueTime - Issue Time in milliseconds
|
|
1163
1184
|
* @param {number=} expirationTime - Expiration Time in milliseconds
|
|
1164
1185
|
*/
|
|
1186
|
+
)
|
|
1165
1187
|
}, {
|
|
1166
1188
|
key: "CreateSignedToken",
|
|
1167
|
-
value: function () {
|
|
1168
|
-
var _CreateSignedToken = _asyncToGenerator(
|
|
1169
|
-
var libraryId, objectId, versionHash, policyId, subject,
|
|
1170
|
-
return _regeneratorRuntime.wrap(function
|
|
1171
|
-
while (1) switch (
|
|
1189
|
+
value: (function () {
|
|
1190
|
+
var _CreateSignedToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref16) {
|
|
1191
|
+
var libraryId, objectId, versionHash, policyId, subject, _ref16$grantType, grantType, _ref16$allowDecryptio, allowDecryption, duration, _ref16$context, context, issueTime, expirationTime, issueDateTime, token, cap, compressedToken, signature, _t21, _t22, _t23, _t24, _t25, _t26, _t27, _t28, _t29, _t30, _t31, _t32, _t33;
|
|
1192
|
+
return _regeneratorRuntime.wrap(function (_context12) {
|
|
1193
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1172
1194
|
case 0:
|
|
1173
|
-
libraryId =
|
|
1195
|
+
libraryId = _ref16.libraryId, objectId = _ref16.objectId, versionHash = _ref16.versionHash, policyId = _ref16.policyId, subject = _ref16.subject, _ref16$grantType = _ref16.grantType, grantType = _ref16$grantType === void 0 ? "read" : _ref16$grantType, _ref16$allowDecryptio = _ref16.allowDecryption, allowDecryption = _ref16$allowDecryptio === void 0 ? false : _ref16$allowDecryptio, duration = _ref16.duration, _ref16$context = _ref16.context, context = _ref16$context === void 0 ? {} : _ref16$context, issueTime = _ref16.issueTime, expirationTime = _ref16.expirationTime;
|
|
1174
1196
|
if (subject) {
|
|
1175
|
-
|
|
1197
|
+
_context12.next = 2;
|
|
1176
1198
|
break;
|
|
1177
1199
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1200
|
+
_t21 = "iusr";
|
|
1201
|
+
_t22 = this.utils;
|
|
1202
|
+
_context12.next = 1;
|
|
1181
1203
|
return this.CurrentAccountAddress();
|
|
1182
|
-
case
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
subject =
|
|
1186
|
-
case
|
|
1204
|
+
case 1:
|
|
1205
|
+
_t23 = _context12.sent;
|
|
1206
|
+
_t24 = _t22.AddressToHash.call(_t22, _t23);
|
|
1207
|
+
subject = _t21.concat.call(_t21, _t24);
|
|
1208
|
+
case 2:
|
|
1187
1209
|
if (policyId) {
|
|
1188
1210
|
context["elv:delegation-id"] = policyId;
|
|
1189
1211
|
}
|
|
1190
1212
|
issueDateTime = issueTime || Date.now();
|
|
1191
|
-
|
|
1192
|
-
|
|
1213
|
+
_t25 = Buffer;
|
|
1214
|
+
_context12.next = 3;
|
|
1193
1215
|
return this.CurrentAccountAddress().replace(/^0x/, "");
|
|
1194
|
-
case
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1216
|
+
case 3:
|
|
1217
|
+
_t26 = _context12.sent;
|
|
1218
|
+
_t27 = _t25.from.call(_t25, _t26, "hex").toString("base64");
|
|
1219
|
+
_t28 = subject;
|
|
1220
|
+
_context12.next = 4;
|
|
1199
1221
|
return this.ContentSpaceId();
|
|
1200
|
-
case
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1222
|
+
case 4:
|
|
1223
|
+
_t29 = _context12.sent;
|
|
1224
|
+
_t30 = issueDateTime;
|
|
1225
|
+
_t31 = expirationTime || issueDateTime + duration;
|
|
1226
|
+
_t32 = grantType;
|
|
1227
|
+
_t33 = context;
|
|
1206
1228
|
token = {
|
|
1207
|
-
adr:
|
|
1208
|
-
sub:
|
|
1209
|
-
spc:
|
|
1210
|
-
iat:
|
|
1211
|
-
exp:
|
|
1212
|
-
gra:
|
|
1213
|
-
ctx:
|
|
1229
|
+
adr: _t27,
|
|
1230
|
+
sub: _t28,
|
|
1231
|
+
spc: _t29,
|
|
1232
|
+
iat: _t30,
|
|
1233
|
+
exp: _t31,
|
|
1234
|
+
gra: _t32,
|
|
1235
|
+
ctx: _t33
|
|
1214
1236
|
};
|
|
1215
1237
|
if (versionHash) {
|
|
1216
1238
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1217
1239
|
}
|
|
1218
1240
|
if (!objectId) {
|
|
1219
|
-
|
|
1241
|
+
_context12.next = 6;
|
|
1220
1242
|
break;
|
|
1221
1243
|
}
|
|
1222
1244
|
token.qid = objectId;
|
|
1223
1245
|
if (libraryId) {
|
|
1224
|
-
|
|
1246
|
+
_context12.next = 6;
|
|
1225
1247
|
break;
|
|
1226
1248
|
}
|
|
1227
|
-
|
|
1249
|
+
_context12.next = 5;
|
|
1228
1250
|
return this.ContentObjectLibraryId({
|
|
1229
1251
|
objectId: objectId
|
|
1230
1252
|
});
|
|
1231
|
-
case
|
|
1232
|
-
libraryId =
|
|
1233
|
-
case
|
|
1253
|
+
case 5:
|
|
1254
|
+
libraryId = _context12.sent;
|
|
1255
|
+
case 6:
|
|
1234
1256
|
if (libraryId) {
|
|
1235
1257
|
token.lib = libraryId;
|
|
1236
1258
|
}
|
|
1237
1259
|
if (!allowDecryption) {
|
|
1238
|
-
|
|
1260
|
+
_context12.next = 8;
|
|
1239
1261
|
break;
|
|
1240
1262
|
}
|
|
1241
|
-
|
|
1263
|
+
_context12.next = 7;
|
|
1242
1264
|
return this.authClient.ReEncryptionConk({
|
|
1243
1265
|
libraryId: libraryId,
|
|
1244
1266
|
objectId: objectId
|
|
1245
1267
|
});
|
|
1246
|
-
case
|
|
1247
|
-
cap =
|
|
1268
|
+
case 7:
|
|
1269
|
+
cap = _context12.sent;
|
|
1248
1270
|
token.apk = cap.public_key;
|
|
1249
|
-
case
|
|
1271
|
+
case 8:
|
|
1250
1272
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1251
|
-
|
|
1273
|
+
_context12.next = 9;
|
|
1252
1274
|
return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
|
|
1253
|
-
case
|
|
1254
|
-
signature =
|
|
1255
|
-
return
|
|
1256
|
-
case
|
|
1275
|
+
case 9:
|
|
1276
|
+
signature = _context12.sent;
|
|
1277
|
+
return _context12.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1278
|
+
case 10:
|
|
1257
1279
|
case "end":
|
|
1258
|
-
return
|
|
1280
|
+
return _context12.stop();
|
|
1259
1281
|
}
|
|
1260
|
-
},
|
|
1282
|
+
}, _callee12, this);
|
|
1261
1283
|
}));
|
|
1262
1284
|
function CreateSignedToken(_x9) {
|
|
1263
1285
|
return _CreateSignedToken.apply(this, arguments);
|
|
1264
1286
|
}
|
|
1265
1287
|
return CreateSignedToken;
|
|
1266
|
-
}()
|
|
1288
|
+
}())
|
|
1267
1289
|
}, {
|
|
1268
1290
|
key: "CreateAuthorizationToken",
|
|
1269
1291
|
value: function () {
|
|
1270
|
-
var _CreateAuthorizationToken = _asyncToGenerator(
|
|
1271
|
-
return _regeneratorRuntime.wrap(function
|
|
1272
|
-
while (1) switch (
|
|
1292
|
+
var _CreateAuthorizationToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(args) {
|
|
1293
|
+
return _regeneratorRuntime.wrap(function (_context13) {
|
|
1294
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1273
1295
|
case 0:
|
|
1274
|
-
|
|
1296
|
+
_context13.next = 1;
|
|
1275
1297
|
return this.authClient.AuthorizationToken(args);
|
|
1298
|
+
case 1:
|
|
1299
|
+
return _context13.abrupt("return", _context13.sent);
|
|
1276
1300
|
case 2:
|
|
1277
|
-
return _context15.abrupt("return", _context15.sent);
|
|
1278
|
-
case 3:
|
|
1279
1301
|
case "end":
|
|
1280
|
-
return
|
|
1302
|
+
return _context13.stop();
|
|
1281
1303
|
}
|
|
1282
|
-
},
|
|
1304
|
+
}, _callee13, this);
|
|
1283
1305
|
}));
|
|
1284
|
-
function CreateAuthorizationToken(
|
|
1306
|
+
function CreateAuthorizationToken(_x0) {
|
|
1285
1307
|
return _CreateAuthorizationToken.apply(this, arguments);
|
|
1286
1308
|
}
|
|
1287
1309
|
return CreateAuthorizationToken;
|
|
@@ -1302,31 +1324,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1302
1324
|
*/
|
|
1303
1325
|
}, {
|
|
1304
1326
|
key: "CreateSignedMessageJSON",
|
|
1305
|
-
value: function () {
|
|
1306
|
-
var _CreateSignedMessageJSON = _asyncToGenerator(
|
|
1327
|
+
value: (function () {
|
|
1328
|
+
var _CreateSignedMessageJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref17) {
|
|
1307
1329
|
var message, type, msg, signature;
|
|
1308
|
-
return _regeneratorRuntime.wrap(function
|
|
1309
|
-
while (1) switch (
|
|
1330
|
+
return _regeneratorRuntime.wrap(function (_context14) {
|
|
1331
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1310
1332
|
case 0:
|
|
1311
|
-
message =
|
|
1333
|
+
message = _ref17.message;
|
|
1312
1334
|
// Only one kind of signature supported currently
|
|
1313
1335
|
type = "mje_"; // JSON message, EIP192 signature
|
|
1314
1336
|
msg = JSON.stringify(message);
|
|
1315
|
-
|
|
1337
|
+
_context14.next = 1;
|
|
1316
1338
|
return this.PersonalSign({
|
|
1317
1339
|
message: msg,
|
|
1318
1340
|
addEthereumPrefix: true
|
|
1319
1341
|
});
|
|
1320
|
-
case
|
|
1321
|
-
signature =
|
|
1322
|
-
return
|
|
1323
|
-
case
|
|
1342
|
+
case 1:
|
|
1343
|
+
signature = _context14.sent;
|
|
1344
|
+
return _context14.abrupt("return", "".concat(type).concat(Utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(msg)]))));
|
|
1345
|
+
case 2:
|
|
1324
1346
|
case "end":
|
|
1325
|
-
return
|
|
1347
|
+
return _context14.stop();
|
|
1326
1348
|
}
|
|
1327
|
-
},
|
|
1349
|
+
}, _callee14, this);
|
|
1328
1350
|
}));
|
|
1329
|
-
function CreateSignedMessageJSON(
|
|
1351
|
+
function CreateSignedMessageJSON(_x1) {
|
|
1330
1352
|
return _CreateSignedMessageJSON.apply(this, arguments);
|
|
1331
1353
|
}
|
|
1332
1354
|
return CreateSignedMessageJSON;
|
|
@@ -1339,41 +1361,42 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1339
1361
|
* @param {string} signedMessage - a signed message as created by CreateSignedMessageJSON
|
|
1340
1362
|
* @returns {Promise<Object>} - The decoded message, signer address, signature and signature type
|
|
1341
1363
|
*/
|
|
1364
|
+
)
|
|
1342
1365
|
}, {
|
|
1343
1366
|
key: "DecodeSignedMessageJSON",
|
|
1344
|
-
value: function () {
|
|
1345
|
-
var _DecodeSignedMessageJSON = _asyncToGenerator(
|
|
1346
|
-
var signedMessage, type, msgBytes, signature, msg, obj, prefixedMsgHash, signerAddr;
|
|
1347
|
-
return _regeneratorRuntime.wrap(function
|
|
1348
|
-
while (1) switch (
|
|
1367
|
+
value: (function () {
|
|
1368
|
+
var _DecodeSignedMessageJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref18) {
|
|
1369
|
+
var signedMessage, type, msgBytes, signature, msg, obj, prefixedMsgHash, signerAddr, _t34;
|
|
1370
|
+
return _regeneratorRuntime.wrap(function (_context15) {
|
|
1371
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1349
1372
|
case 0:
|
|
1350
|
-
signedMessage =
|
|
1373
|
+
signedMessage = _ref18.signedMessage;
|
|
1351
1374
|
type = signedMessage.slice(0, 4);
|
|
1352
|
-
|
|
1353
|
-
|
|
1375
|
+
_t34 = type;
|
|
1376
|
+
_context15.next = _t34 === "mje_" ? 1 : 2;
|
|
1354
1377
|
break;
|
|
1355
|
-
case
|
|
1378
|
+
case 1:
|
|
1356
1379
|
msgBytes = Utils.FromB58(signedMessage.slice(4));
|
|
1357
1380
|
signature = msgBytes.slice(0, 65);
|
|
1358
1381
|
msg = msgBytes.slice(65);
|
|
1359
1382
|
obj = JSON.parse(msg);
|
|
1360
1383
|
prefixedMsgHash = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(msg.length).concat(msg), "utf-8"));
|
|
1361
1384
|
signerAddr = Ethers.utils.recoverAddress(prefixedMsgHash, signature);
|
|
1362
|
-
return
|
|
1385
|
+
return _context15.abrupt("return", {
|
|
1363
1386
|
type: type,
|
|
1364
1387
|
message: obj,
|
|
1365
1388
|
signerAddress: signerAddr,
|
|
1366
1389
|
signature: "0x" + signature.toString("hex")
|
|
1367
1390
|
});
|
|
1368
|
-
case
|
|
1391
|
+
case 2:
|
|
1369
1392
|
throw new Error("Bad message type: ".concat(type));
|
|
1370
|
-
case
|
|
1393
|
+
case 3:
|
|
1371
1394
|
case "end":
|
|
1372
|
-
return
|
|
1395
|
+
return _context15.stop();
|
|
1373
1396
|
}
|
|
1374
|
-
},
|
|
1397
|
+
}, _callee15);
|
|
1375
1398
|
}));
|
|
1376
|
-
function DecodeSignedMessageJSON(
|
|
1399
|
+
function DecodeSignedMessageJSON(_x10) {
|
|
1377
1400
|
return _DecodeSignedMessageJSON.apply(this, arguments);
|
|
1378
1401
|
}
|
|
1379
1402
|
return DecodeSignedMessageJSON;
|
|
@@ -1384,6 +1407,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1384
1407
|
* @methodGroup Signers
|
|
1385
1408
|
* @returns {string} - The address of the current signer
|
|
1386
1409
|
*/
|
|
1410
|
+
)
|
|
1387
1411
|
}, {
|
|
1388
1412
|
key: "CurrentAccountAddress",
|
|
1389
1413
|
value: function CurrentAccountAddress() {
|
|
@@ -1399,13 +1423,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1399
1423
|
*/
|
|
1400
1424
|
}, {
|
|
1401
1425
|
key: "SetOauthToken",
|
|
1402
|
-
value: function () {
|
|
1403
|
-
var _SetOauthToken = _asyncToGenerator(
|
|
1426
|
+
value: (function () {
|
|
1427
|
+
var _SetOauthToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref19) {
|
|
1404
1428
|
var token, wallet, signer;
|
|
1405
|
-
return _regeneratorRuntime.wrap(function
|
|
1406
|
-
while (1) switch (
|
|
1429
|
+
return _regeneratorRuntime.wrap(function (_context16) {
|
|
1430
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1407
1431
|
case 0:
|
|
1408
|
-
token =
|
|
1432
|
+
token = _ref19.token;
|
|
1409
1433
|
this.oauthToken = token;
|
|
1410
1434
|
wallet = this.GenerateWallet();
|
|
1411
1435
|
signer = wallet.AddAccountFromMnemonic({
|
|
@@ -1414,13 +1438,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1414
1438
|
this.SetSigner({
|
|
1415
1439
|
signer: signer
|
|
1416
1440
|
});
|
|
1417
|
-
case
|
|
1441
|
+
case 1:
|
|
1418
1442
|
case "end":
|
|
1419
|
-
return
|
|
1443
|
+
return _context16.stop();
|
|
1420
1444
|
}
|
|
1421
|
-
},
|
|
1445
|
+
}, _callee16, this);
|
|
1422
1446
|
}));
|
|
1423
|
-
function SetOauthToken(
|
|
1447
|
+
function SetOauthToken(_x11) {
|
|
1424
1448
|
return _SetOauthToken.apply(this, arguments);
|
|
1425
1449
|
}
|
|
1426
1450
|
return SetOauthToken;
|
|
@@ -1435,60 +1459,61 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1435
1459
|
* @namedParams
|
|
1436
1460
|
* @param {string} token - The OAuth ID
|
|
1437
1461
|
*/
|
|
1462
|
+
)
|
|
1438
1463
|
}, {
|
|
1439
1464
|
key: "SetSignerFromOauthToken",
|
|
1440
|
-
value: function () {
|
|
1441
|
-
var _SetSignerFromOauthToken = _asyncToGenerator(
|
|
1442
|
-
var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey;
|
|
1443
|
-
return _regeneratorRuntime.wrap(function
|
|
1444
|
-
while (1) switch (
|
|
1465
|
+
value: (function () {
|
|
1466
|
+
var _SetSignerFromOauthToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref20) {
|
|
1467
|
+
var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey, _t35;
|
|
1468
|
+
return _regeneratorRuntime.wrap(function (_context17) {
|
|
1469
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1445
1470
|
case 0:
|
|
1446
|
-
token =
|
|
1471
|
+
token = _ref20.token;
|
|
1447
1472
|
if (this.trustAuthorityId) {
|
|
1448
|
-
|
|
1473
|
+
_context17.next = 1;
|
|
1449
1474
|
break;
|
|
1450
1475
|
}
|
|
1451
1476
|
throw Error("Unable to authorize with OAuth token: No trust authority ID set");
|
|
1452
|
-
case
|
|
1477
|
+
case 1:
|
|
1453
1478
|
wallet = this.GenerateWallet();
|
|
1454
|
-
|
|
1479
|
+
_context17.prev = 2;
|
|
1455
1480
|
if (this.kmsURIs) {
|
|
1456
|
-
|
|
1481
|
+
_context17.next = 6;
|
|
1457
1482
|
break;
|
|
1458
1483
|
}
|
|
1459
|
-
|
|
1484
|
+
_context17.next = 3;
|
|
1460
1485
|
return ElvClient.FromConfigurationUrl({
|
|
1461
1486
|
configUrl: this.configUrl
|
|
1462
1487
|
});
|
|
1463
|
-
case
|
|
1464
|
-
client =
|
|
1488
|
+
case 3:
|
|
1489
|
+
client = _context17.sent;
|
|
1465
1490
|
client.SetSigner({
|
|
1466
1491
|
signer: wallet.AddAccount({
|
|
1467
1492
|
privateKey: this.defaultKey
|
|
1468
1493
|
})
|
|
1469
1494
|
});
|
|
1470
|
-
|
|
1495
|
+
_context17.next = 4;
|
|
1471
1496
|
return client.authClient.KMSInfo({
|
|
1472
1497
|
kmsId: this.trustAuthorityId
|
|
1473
1498
|
});
|
|
1474
|
-
case
|
|
1475
|
-
_yield$client$authCli =
|
|
1499
|
+
case 4:
|
|
1500
|
+
_yield$client$authCli = _context17.sent;
|
|
1476
1501
|
urls = _yield$client$authCli.urls;
|
|
1477
1502
|
if (!(!urls || urls.length === 0)) {
|
|
1478
|
-
|
|
1503
|
+
_context17.next = 5;
|
|
1479
1504
|
break;
|
|
1480
1505
|
}
|
|
1481
1506
|
throw Error("Unable to authorize with OAuth token: No KMS URLs set");
|
|
1482
|
-
case
|
|
1507
|
+
case 5:
|
|
1483
1508
|
this.kmsURIs = urls;
|
|
1484
|
-
case
|
|
1509
|
+
case 6:
|
|
1485
1510
|
this.oauthToken = token;
|
|
1486
1511
|
path = "/ks/jwt/wlt";
|
|
1487
1512
|
httpClient = new HttpClient({
|
|
1488
1513
|
uris: this.kmsURIs,
|
|
1489
1514
|
debug: this.debug
|
|
1490
1515
|
});
|
|
1491
|
-
|
|
1516
|
+
_context17.next = 7;
|
|
1492
1517
|
return this.utils.ResponseToJson(httpClient.Request({
|
|
1493
1518
|
headers: {
|
|
1494
1519
|
Authorization: "Bearer ".concat(token)
|
|
@@ -1497,8 +1522,8 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1497
1522
|
path: path,
|
|
1498
1523
|
forceFailover: true
|
|
1499
1524
|
}));
|
|
1500
|
-
case
|
|
1501
|
-
response =
|
|
1525
|
+
case 7:
|
|
1526
|
+
response = _context17.sent;
|
|
1502
1527
|
privateKey = response["UserSKHex"];
|
|
1503
1528
|
this.SetSigner({
|
|
1504
1529
|
signer: wallet.AddAccount({
|
|
@@ -1507,27 +1532,27 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1507
1532
|
});
|
|
1508
1533
|
|
|
1509
1534
|
// Ensure wallet is initialized
|
|
1510
|
-
|
|
1535
|
+
_context17.next = 8;
|
|
1511
1536
|
return this.userProfileClient.WalletAddress();
|
|
1512
|
-
case
|
|
1513
|
-
|
|
1537
|
+
case 8:
|
|
1538
|
+
_context17.next = 11;
|
|
1514
1539
|
break;
|
|
1515
|
-
case
|
|
1516
|
-
|
|
1517
|
-
|
|
1540
|
+
case 9:
|
|
1541
|
+
_context17.prev = 9;
|
|
1542
|
+
_t35 = _context17["catch"](2);
|
|
1518
1543
|
this.Log("Failed to set signer from OAuth token:", true);
|
|
1519
|
-
this.Log(
|
|
1520
|
-
|
|
1544
|
+
this.Log(_t35, true);
|
|
1545
|
+
_context17.next = 10;
|
|
1521
1546
|
return this.ClearSigner();
|
|
1522
|
-
case
|
|
1523
|
-
throw
|
|
1524
|
-
case
|
|
1547
|
+
case 10:
|
|
1548
|
+
throw _t35;
|
|
1549
|
+
case 11:
|
|
1525
1550
|
case "end":
|
|
1526
|
-
return
|
|
1551
|
+
return _context17.stop();
|
|
1527
1552
|
}
|
|
1528
|
-
},
|
|
1553
|
+
}, _callee17, this, [[2, 9]]);
|
|
1529
1554
|
}));
|
|
1530
|
-
function SetSignerFromOauthToken(
|
|
1555
|
+
function SetSignerFromOauthToken(_x12) {
|
|
1531
1556
|
return _SetSignerFromOauthToken.apply(this, arguments);
|
|
1532
1557
|
}
|
|
1533
1558
|
return SetSignerFromOauthToken;
|
|
@@ -1541,10 +1566,11 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1541
1566
|
*
|
|
1542
1567
|
* @return {string} - The created static token
|
|
1543
1568
|
*/
|
|
1569
|
+
)
|
|
1544
1570
|
}, {
|
|
1545
1571
|
key: "CreateStaticToken",
|
|
1546
|
-
value: function CreateStaticToken(
|
|
1547
|
-
var libraryId =
|
|
1572
|
+
value: function CreateStaticToken(_ref21) {
|
|
1573
|
+
var libraryId = _ref21.libraryId;
|
|
1548
1574
|
var token = {
|
|
1549
1575
|
qspace_id: this.client.contentSpaceId
|
|
1550
1576
|
};
|
|
@@ -1565,10 +1591,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1565
1591
|
}, {
|
|
1566
1592
|
key: "SetStaticToken",
|
|
1567
1593
|
value: function SetStaticToken() {
|
|
1568
|
-
var
|
|
1569
|
-
token =
|
|
1570
|
-
|
|
1571
|
-
update =
|
|
1594
|
+
var _ref22 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1595
|
+
token = _ref22.token,
|
|
1596
|
+
_ref22$update = _ref22.update,
|
|
1597
|
+
update = _ref22$update === void 0 ? false : _ref22$update;
|
|
1572
1598
|
if (token) {
|
|
1573
1599
|
this.staticToken = token;
|
|
1574
1600
|
} else {
|
|
@@ -1599,31 +1625,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1599
1625
|
*/
|
|
1600
1626
|
}, {
|
|
1601
1627
|
key: "SetPolicyAuthorization",
|
|
1602
|
-
value: function () {
|
|
1603
|
-
var _SetPolicyAuthorization = _asyncToGenerator(
|
|
1604
|
-
var objectId;
|
|
1605
|
-
return _regeneratorRuntime.wrap(function
|
|
1606
|
-
while (1) switch (
|
|
1628
|
+
value: (function () {
|
|
1629
|
+
var _SetPolicyAuthorization = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref23) {
|
|
1630
|
+
var objectId, _t36, _t37, _t38;
|
|
1631
|
+
return _regeneratorRuntime.wrap(function (_context18) {
|
|
1632
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1607
1633
|
case 0:
|
|
1608
|
-
objectId =
|
|
1609
|
-
|
|
1610
|
-
|
|
1634
|
+
objectId = _ref23.objectId;
|
|
1635
|
+
_t36 = this;
|
|
1636
|
+
_context18.next = 1;
|
|
1611
1637
|
return this.GenerateStateChannelToken({
|
|
1612
1638
|
objectId: objectId
|
|
1613
1639
|
});
|
|
1614
|
-
case
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
token:
|
|
1640
|
+
case 1:
|
|
1641
|
+
_t37 = _context18.sent;
|
|
1642
|
+
_t38 = {
|
|
1643
|
+
token: _t37
|
|
1618
1644
|
};
|
|
1619
|
-
|
|
1620
|
-
case
|
|
1645
|
+
_t36.SetStaticToken.call(_t36, _t38);
|
|
1646
|
+
case 2:
|
|
1621
1647
|
case "end":
|
|
1622
|
-
return
|
|
1648
|
+
return _context18.stop();
|
|
1623
1649
|
}
|
|
1624
|
-
},
|
|
1650
|
+
}, _callee18, this);
|
|
1625
1651
|
}));
|
|
1626
|
-
function SetPolicyAuthorization(
|
|
1652
|
+
function SetPolicyAuthorization(_x13) {
|
|
1627
1653
|
return _SetPolicyAuthorization.apply(this, arguments);
|
|
1628
1654
|
}
|
|
1629
1655
|
return SetPolicyAuthorization;
|
|
@@ -1634,26 +1660,27 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1634
1660
|
* @param {string} string - The string to sign
|
|
1635
1661
|
* @return {Promise<string>} - The signed string
|
|
1636
1662
|
*/
|
|
1663
|
+
)
|
|
1637
1664
|
}, {
|
|
1638
1665
|
key: "Sign",
|
|
1639
|
-
value: function () {
|
|
1640
|
-
var _Sign = _asyncToGenerator(
|
|
1666
|
+
value: (function () {
|
|
1667
|
+
var _Sign = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee19(string) {
|
|
1641
1668
|
var signature;
|
|
1642
|
-
return _regeneratorRuntime.wrap(function
|
|
1643
|
-
while (1) switch (
|
|
1669
|
+
return _regeneratorRuntime.wrap(function (_context19) {
|
|
1670
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1644
1671
|
case 0:
|
|
1645
|
-
|
|
1672
|
+
_context19.next = 1;
|
|
1646
1673
|
return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
|
|
1674
|
+
case 1:
|
|
1675
|
+
signature = _context19.sent;
|
|
1676
|
+
return _context19.abrupt("return", this.utils.FormatSignature(signature));
|
|
1647
1677
|
case 2:
|
|
1648
|
-
signature = _context21.sent;
|
|
1649
|
-
return _context21.abrupt("return", this.utils.FormatSignature(signature));
|
|
1650
|
-
case 4:
|
|
1651
1678
|
case "end":
|
|
1652
|
-
return
|
|
1679
|
+
return _context19.stop();
|
|
1653
1680
|
}
|
|
1654
|
-
},
|
|
1681
|
+
}, _callee19, this);
|
|
1655
1682
|
}));
|
|
1656
|
-
function Sign(
|
|
1683
|
+
function Sign(_x14) {
|
|
1657
1684
|
return _Sign.apply(this, arguments);
|
|
1658
1685
|
}
|
|
1659
1686
|
return Sign;
|
|
@@ -1667,33 +1694,34 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1667
1694
|
*
|
|
1668
1695
|
* @return {Promise<string>} - The encrypted message
|
|
1669
1696
|
*/
|
|
1697
|
+
)
|
|
1670
1698
|
}, {
|
|
1671
1699
|
key: "EncryptECIES",
|
|
1672
|
-
value: function () {
|
|
1673
|
-
var _EncryptECIES = _asyncToGenerator(
|
|
1700
|
+
value: (function () {
|
|
1701
|
+
var _EncryptECIES = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref24) {
|
|
1674
1702
|
var message, publicKey;
|
|
1675
|
-
return _regeneratorRuntime.wrap(function
|
|
1676
|
-
while (1) switch (
|
|
1703
|
+
return _regeneratorRuntime.wrap(function (_context20) {
|
|
1704
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1677
1705
|
case 0:
|
|
1678
|
-
message =
|
|
1706
|
+
message = _ref24.message, publicKey = _ref24.publicKey;
|
|
1679
1707
|
if (this.signer) {
|
|
1680
|
-
|
|
1708
|
+
_context20.next = 1;
|
|
1681
1709
|
break;
|
|
1682
1710
|
}
|
|
1683
1711
|
throw "Signer not set";
|
|
1684
|
-
case
|
|
1712
|
+
case 1:
|
|
1685
1713
|
ValidatePresence("message", message);
|
|
1686
|
-
|
|
1714
|
+
_context20.next = 2;
|
|
1687
1715
|
return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
|
|
1688
|
-
case
|
|
1689
|
-
return
|
|
1690
|
-
case
|
|
1716
|
+
case 2:
|
|
1717
|
+
return _context20.abrupt("return", _context20.sent);
|
|
1718
|
+
case 3:
|
|
1691
1719
|
case "end":
|
|
1692
|
-
return
|
|
1720
|
+
return _context20.stop();
|
|
1693
1721
|
}
|
|
1694
|
-
},
|
|
1722
|
+
}, _callee20, this);
|
|
1695
1723
|
}));
|
|
1696
|
-
function EncryptECIES(
|
|
1724
|
+
function EncryptECIES(_x15) {
|
|
1697
1725
|
return _EncryptECIES.apply(this, arguments);
|
|
1698
1726
|
}
|
|
1699
1727
|
return EncryptECIES;
|
|
@@ -1706,33 +1734,34 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1706
1734
|
*
|
|
1707
1735
|
* @return {Promise<string | Object>} - The decrypted string or object
|
|
1708
1736
|
*/
|
|
1737
|
+
)
|
|
1709
1738
|
}, {
|
|
1710
1739
|
key: "DecryptECIES",
|
|
1711
|
-
value: function () {
|
|
1712
|
-
var _DecryptECIES = _asyncToGenerator(
|
|
1740
|
+
value: (function () {
|
|
1741
|
+
var _DecryptECIES = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref25) {
|
|
1713
1742
|
var message;
|
|
1714
|
-
return _regeneratorRuntime.wrap(function
|
|
1715
|
-
while (1) switch (
|
|
1743
|
+
return _regeneratorRuntime.wrap(function (_context21) {
|
|
1744
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1716
1745
|
case 0:
|
|
1717
|
-
message =
|
|
1746
|
+
message = _ref25.message;
|
|
1718
1747
|
if (this.signer) {
|
|
1719
|
-
|
|
1748
|
+
_context21.next = 1;
|
|
1720
1749
|
break;
|
|
1721
1750
|
}
|
|
1722
1751
|
throw "Signer not set";
|
|
1723
|
-
case
|
|
1752
|
+
case 1:
|
|
1724
1753
|
ValidatePresence("message", message);
|
|
1725
|
-
|
|
1754
|
+
_context21.next = 2;
|
|
1726
1755
|
return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
|
|
1727
|
-
case
|
|
1728
|
-
return
|
|
1729
|
-
case
|
|
1756
|
+
case 2:
|
|
1757
|
+
return _context21.abrupt("return", _context21.sent);
|
|
1758
|
+
case 3:
|
|
1730
1759
|
case "end":
|
|
1731
|
-
return
|
|
1760
|
+
return _context21.stop();
|
|
1732
1761
|
}
|
|
1733
|
-
},
|
|
1762
|
+
}, _callee21, this);
|
|
1734
1763
|
}));
|
|
1735
|
-
function DecryptECIES(
|
|
1764
|
+
function DecryptECIES(_x16) {
|
|
1736
1765
|
return _DecryptECIES.apply(this, arguments);
|
|
1737
1766
|
}
|
|
1738
1767
|
return DecryptECIES;
|
|
@@ -1748,40 +1777,41 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1748
1777
|
*
|
|
1749
1778
|
* @return {Promise<*>} - Response in the specified format
|
|
1750
1779
|
*/
|
|
1780
|
+
)
|
|
1751
1781
|
}, {
|
|
1752
1782
|
key: "Request",
|
|
1753
|
-
value: function () {
|
|
1754
|
-
var _Request = _asyncToGenerator(
|
|
1755
|
-
var url,
|
|
1756
|
-
return _regeneratorRuntime.wrap(function
|
|
1757
|
-
while (1) switch (
|
|
1783
|
+
value: (function () {
|
|
1784
|
+
var _Request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref26) {
|
|
1785
|
+
var url, _ref26$format, format, _ref26$method, method, _ref26$headers, headers, body;
|
|
1786
|
+
return _regeneratorRuntime.wrap(function (_context22) {
|
|
1787
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1758
1788
|
case 0:
|
|
1759
|
-
url =
|
|
1760
|
-
return
|
|
1789
|
+
url = _ref26.url, _ref26$format = _ref26.format, format = _ref26$format === void 0 ? "json" : _ref26$format, _ref26$method = _ref26.method, method = _ref26$method === void 0 ? "GET" : _ref26$method, _ref26$headers = _ref26.headers, headers = _ref26$headers === void 0 ? {} : _ref26$headers, body = _ref26.body;
|
|
1790
|
+
return _context22.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
|
|
1761
1791
|
method: method,
|
|
1762
1792
|
headers: headers,
|
|
1763
1793
|
body: body
|
|
1764
1794
|
})));
|
|
1765
|
-
case
|
|
1795
|
+
case 1:
|
|
1766
1796
|
case "end":
|
|
1767
|
-
return
|
|
1797
|
+
return _context22.stop();
|
|
1768
1798
|
}
|
|
1769
|
-
},
|
|
1799
|
+
}, _callee22, this);
|
|
1770
1800
|
}));
|
|
1771
|
-
function Request(
|
|
1801
|
+
function Request(_x17) {
|
|
1772
1802
|
return _Request.apply(this, arguments);
|
|
1773
1803
|
}
|
|
1774
1804
|
return Request;
|
|
1775
|
-
}()
|
|
1805
|
+
}())
|
|
1776
1806
|
}, {
|
|
1777
1807
|
key: "MakeAuthServiceRequest",
|
|
1778
1808
|
value: function () {
|
|
1779
|
-
var _MakeAuthServiceRequest = _asyncToGenerator(
|
|
1780
|
-
var kmsId, objectId, versionHash,
|
|
1781
|
-
return _regeneratorRuntime.wrap(function
|
|
1782
|
-
while (1) switch (
|
|
1809
|
+
var _MakeAuthServiceRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref27) {
|
|
1810
|
+
var kmsId, objectId, versionHash, _ref27$method, method, path, bodyType, _ref27$body, body, _ref27$queryParams, queryParams, headers, format, response;
|
|
1811
|
+
return _regeneratorRuntime.wrap(function (_context23) {
|
|
1812
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1783
1813
|
case 0:
|
|
1784
|
-
kmsId =
|
|
1814
|
+
kmsId = _ref27.kmsId, objectId = _ref27.objectId, versionHash = _ref27.versionHash, _ref27$method = _ref27.method, method = _ref27$method === void 0 ? "GET" : _ref27$method, path = _ref27.path, bodyType = _ref27.bodyType, _ref27$body = _ref27.body, body = _ref27$body === void 0 ? {} : _ref27$body, _ref27$queryParams = _ref27.queryParams, queryParams = _ref27$queryParams === void 0 ? {} : _ref27$queryParams, headers = _ref27.headers, format = _ref27.format;
|
|
1785
1815
|
response = this.authClient.MakeAuthServiceRequest({
|
|
1786
1816
|
kmsId: kmsId,
|
|
1787
1817
|
objectId: objectId,
|
|
@@ -1793,14 +1823,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1793
1823
|
queryParams: queryParams,
|
|
1794
1824
|
headers: headers
|
|
1795
1825
|
});
|
|
1796
|
-
return
|
|
1797
|
-
case
|
|
1826
|
+
return _context23.abrupt("return", !format ? response : this.utils.ResponseToFormat(format, response));
|
|
1827
|
+
case 1:
|
|
1798
1828
|
case "end":
|
|
1799
|
-
return
|
|
1829
|
+
return _context23.stop();
|
|
1800
1830
|
}
|
|
1801
|
-
},
|
|
1831
|
+
}, _callee23, this);
|
|
1802
1832
|
}));
|
|
1803
|
-
function MakeAuthServiceRequest(
|
|
1833
|
+
function MakeAuthServiceRequest(_x18) {
|
|
1804
1834
|
return _MakeAuthServiceRequest.apply(this, arguments);
|
|
1805
1835
|
}
|
|
1806
1836
|
return MakeAuthServiceRequest;
|
|
@@ -1821,18 +1851,18 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1821
1851
|
}, {
|
|
1822
1852
|
key: "CallFromFrameMessage",
|
|
1823
1853
|
value: function () {
|
|
1824
|
-
var _CallFromFrameMessage = _asyncToGenerator(
|
|
1854
|
+
var _CallFromFrameMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee24(message, Respond) {
|
|
1825
1855
|
var _this4 = this;
|
|
1826
|
-
var callback, method, methodResults, responseError;
|
|
1827
|
-
return _regeneratorRuntime.wrap(function
|
|
1828
|
-
while (1) switch (
|
|
1856
|
+
var callback, method, methodResults, responseError, _t39;
|
|
1857
|
+
return _regeneratorRuntime.wrap(function (_context24) {
|
|
1858
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1829
1859
|
case 0:
|
|
1830
1860
|
if (!(message.type !== "ElvFrameRequest")) {
|
|
1831
|
-
|
|
1861
|
+
_context24.next = 1;
|
|
1832
1862
|
break;
|
|
1833
1863
|
}
|
|
1834
|
-
return
|
|
1835
|
-
case
|
|
1864
|
+
return _context24.abrupt("return");
|
|
1865
|
+
case 1:
|
|
1836
1866
|
if (message.callbackId) {
|
|
1837
1867
|
callback = function callback(result) {
|
|
1838
1868
|
Respond(_this4.utils.MakeClonable({
|
|
@@ -1843,103 +1873,103 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1843
1873
|
};
|
|
1844
1874
|
message.args.callback = callback;
|
|
1845
1875
|
}
|
|
1846
|
-
|
|
1876
|
+
_context24.prev = 2;
|
|
1847
1877
|
method = message.calledMethod;
|
|
1848
1878
|
if (!(message.module === "walletClient")) {
|
|
1849
|
-
|
|
1879
|
+
_context24.next = 6;
|
|
1850
1880
|
break;
|
|
1851
1881
|
}
|
|
1852
1882
|
if (this.walletClient) {
|
|
1853
|
-
|
|
1883
|
+
_context24.next = 3;
|
|
1854
1884
|
break;
|
|
1855
1885
|
}
|
|
1856
1886
|
throw Error("Wallet client not set");
|
|
1857
|
-
case
|
|
1887
|
+
case 3:
|
|
1858
1888
|
if (!this.walletClient.ForbiddenMethods().includes(method)) {
|
|
1859
|
-
|
|
1889
|
+
_context24.next = 4;
|
|
1860
1890
|
break;
|
|
1861
1891
|
}
|
|
1862
1892
|
throw Error("Invalid user profile method: " + method);
|
|
1863
|
-
case
|
|
1864
|
-
|
|
1893
|
+
case 4:
|
|
1894
|
+
_context24.next = 5;
|
|
1865
1895
|
return this.walletClient[method](message.args);
|
|
1866
|
-
case
|
|
1867
|
-
methodResults =
|
|
1868
|
-
|
|
1896
|
+
case 5:
|
|
1897
|
+
methodResults = _context24.sent;
|
|
1898
|
+
_context24.next = 12;
|
|
1869
1899
|
break;
|
|
1870
|
-
case
|
|
1900
|
+
case 6:
|
|
1871
1901
|
if (!(message.module === "userProfileClient")) {
|
|
1872
|
-
|
|
1902
|
+
_context24.next = 9;
|
|
1873
1903
|
break;
|
|
1874
1904
|
}
|
|
1875
1905
|
if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
|
|
1876
|
-
|
|
1906
|
+
_context24.next = 7;
|
|
1877
1907
|
break;
|
|
1878
1908
|
}
|
|
1879
1909
|
throw Error("Invalid user profile method: " + method);
|
|
1880
|
-
case
|
|
1881
|
-
|
|
1910
|
+
case 7:
|
|
1911
|
+
_context24.next = 8;
|
|
1882
1912
|
return this.userProfileClient[method](message.args);
|
|
1883
|
-
case
|
|
1884
|
-
methodResults =
|
|
1885
|
-
|
|
1913
|
+
case 8:
|
|
1914
|
+
methodResults = _context24.sent;
|
|
1915
|
+
_context24.next = 12;
|
|
1886
1916
|
break;
|
|
1887
|
-
case
|
|
1917
|
+
case 9:
|
|
1888
1918
|
if (this.FrameAllowedMethods().includes(method)) {
|
|
1889
|
-
|
|
1919
|
+
_context24.next = 10;
|
|
1890
1920
|
break;
|
|
1891
1921
|
}
|
|
1892
1922
|
throw Error("Invalid method: " + method);
|
|
1893
|
-
case
|
|
1894
|
-
|
|
1923
|
+
case 10:
|
|
1924
|
+
_context24.next = 11;
|
|
1895
1925
|
return this[method](message.args);
|
|
1896
|
-
case
|
|
1897
|
-
methodResults =
|
|
1898
|
-
case
|
|
1926
|
+
case 11:
|
|
1927
|
+
methodResults = _context24.sent;
|
|
1928
|
+
case 12:
|
|
1899
1929
|
Respond(this.utils.MakeClonable({
|
|
1900
1930
|
type: "ElvFrameResponse",
|
|
1901
1931
|
requestId: message.requestId,
|
|
1902
1932
|
response: methodResults
|
|
1903
1933
|
}));
|
|
1904
|
-
|
|
1934
|
+
_context24.next = 14;
|
|
1905
1935
|
break;
|
|
1906
|
-
case
|
|
1907
|
-
|
|
1908
|
-
|
|
1936
|
+
case 13:
|
|
1937
|
+
_context24.prev = 13;
|
|
1938
|
+
_t39 = _context24["catch"](2);
|
|
1909
1939
|
// eslint-disable-next-line no-console
|
|
1910
|
-
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(
|
|
1940
|
+
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_t39) === "object" ? JSON.stringify(_t39, null, 2) : _t39), true);
|
|
1911
1941
|
|
|
1912
1942
|
// eslint-disable-next-line no-console
|
|
1913
1943
|
console.error(message);
|
|
1914
1944
|
// eslint-disable-next-line no-console
|
|
1915
|
-
console.error(
|
|
1916
|
-
responseError =
|
|
1945
|
+
console.error(_t39);
|
|
1946
|
+
responseError = _t39 instanceof Error ? _t39.message : _t39;
|
|
1917
1947
|
Respond(this.utils.MakeClonable({
|
|
1918
1948
|
type: "ElvFrameResponse",
|
|
1919
1949
|
requestId: message.requestId,
|
|
1920
1950
|
error: responseError
|
|
1921
1951
|
}));
|
|
1922
|
-
case
|
|
1952
|
+
case 14:
|
|
1923
1953
|
case "end":
|
|
1924
|
-
return
|
|
1954
|
+
return _context24.stop();
|
|
1925
1955
|
}
|
|
1926
|
-
},
|
|
1956
|
+
}, _callee24, this, [[2, 13]]);
|
|
1927
1957
|
}));
|
|
1928
|
-
function CallFromFrameMessage(
|
|
1958
|
+
function CallFromFrameMessage(_x19, _x20) {
|
|
1929
1959
|
return _CallFromFrameMessage.apply(this, arguments);
|
|
1930
1960
|
}
|
|
1931
1961
|
return CallFromFrameMessage;
|
|
1932
1962
|
}()
|
|
1933
1963
|
}], [{
|
|
1934
1964
|
key: "Configuration",
|
|
1935
|
-
value: function () {
|
|
1936
|
-
var _Configuration = _asyncToGenerator(
|
|
1937
|
-
var configUrl,
|
|
1938
|
-
return _regeneratorRuntime.wrap(function
|
|
1939
|
-
while (1) switch (
|
|
1965
|
+
value: (function () {
|
|
1966
|
+
var _Configuration = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref28) {
|
|
1967
|
+
var configUrl, _ref28$kmsUrls, kmsUrls, region, clientIP, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion, _t40;
|
|
1968
|
+
return _regeneratorRuntime.wrap(function (_context25) {
|
|
1969
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1940
1970
|
case 0:
|
|
1941
|
-
configUrl =
|
|
1942
|
-
|
|
1971
|
+
configUrl = _ref28.configUrl, _ref28$kmsUrls = _ref28.kmsUrls, kmsUrls = _ref28$kmsUrls === void 0 ? [] : _ref28$kmsUrls, region = _ref28.region, clientIP = _ref28.clientIP;
|
|
1972
|
+
_context25.prev = 1;
|
|
1943
1973
|
uri = new URI(configUrl);
|
|
1944
1974
|
uri.pathname("/config");
|
|
1945
1975
|
if (region) {
|
|
@@ -1948,10 +1978,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1948
1978
|
if (clientIP) {
|
|
1949
1979
|
uri.addSearch("client_ip", clientIP);
|
|
1950
1980
|
}
|
|
1951
|
-
|
|
1981
|
+
_context25.next = 2;
|
|
1952
1982
|
return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
|
|
1953
|
-
case
|
|
1954
|
-
fabricInfo =
|
|
1983
|
+
case 2:
|
|
1984
|
+
fabricInfo = _context25.sent;
|
|
1955
1985
|
// If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
|
|
1956
1986
|
filterHTTPS = function filterHTTPS(uri) {
|
|
1957
1987
|
return uri.toLowerCase().startsWith("https");
|
|
@@ -1974,7 +2004,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1974
2004
|
}
|
|
1975
2005
|
searchURIs = fabricInfo.network.services.search || [];
|
|
1976
2006
|
fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
|
|
1977
|
-
return
|
|
2007
|
+
return _context25.abrupt("return", {
|
|
1978
2008
|
nodeId: fabricInfo.node_id,
|
|
1979
2009
|
contentSpaceId: fabricInfo.qspace.id,
|
|
1980
2010
|
networkId: (fabricInfo.qspace.ethereum || {}).network_id,
|
|
@@ -1987,21 +2017,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1987
2017
|
searchURIs: searchURIs,
|
|
1988
2018
|
fabricVersion: fabricVersion
|
|
1989
2019
|
});
|
|
1990
|
-
case
|
|
1991
|
-
|
|
1992
|
-
|
|
2020
|
+
case 3:
|
|
2021
|
+
_context25.prev = 3;
|
|
2022
|
+
_t40 = _context25["catch"](1);
|
|
1993
2023
|
// eslint-disable-next-line no-console
|
|
1994
2024
|
console.error("Error retrieving fabric configuration:");
|
|
1995
2025
|
// eslint-disable-next-line no-console
|
|
1996
|
-
console.error(
|
|
1997
|
-
throw
|
|
1998
|
-
case
|
|
2026
|
+
console.error(_t40);
|
|
2027
|
+
throw _t40;
|
|
2028
|
+
case 4:
|
|
1999
2029
|
case "end":
|
|
2000
|
-
return
|
|
2030
|
+
return _context25.stop();
|
|
2001
2031
|
}
|
|
2002
|
-
},
|
|
2032
|
+
}, _callee25, null, [[1, 3]]);
|
|
2003
2033
|
}));
|
|
2004
|
-
function Configuration(
|
|
2034
|
+
function Configuration(_x21) {
|
|
2005
2035
|
return _Configuration.apply(this, arguments);
|
|
2006
2036
|
}
|
|
2007
2037
|
return Configuration;
|
|
@@ -2013,6 +2043,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2013
2043
|
*
|
|
2014
2044
|
* @return {Object} - An object using network names as keys and configuration URLs as values.
|
|
2015
2045
|
*/
|
|
2046
|
+
)
|
|
2016
2047
|
}, {
|
|
2017
2048
|
key: "Networks",
|
|
2018
2049
|
value: function Networks() {
|
|
@@ -2037,21 +2068,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2037
2068
|
*/
|
|
2038
2069
|
}, {
|
|
2039
2070
|
key: "FromNetworkName",
|
|
2040
|
-
value: function () {
|
|
2041
|
-
var _FromNetworkName = _asyncToGenerator(
|
|
2042
|
-
var networkName, region, clientIP, trustAuthorityId, staticToken,
|
|
2043
|
-
return _regeneratorRuntime.wrap(function
|
|
2044
|
-
while (1) switch (
|
|
2071
|
+
value: (function () {
|
|
2072
|
+
var _FromNetworkName = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref29) {
|
|
2073
|
+
var networkName, region, clientIP, trustAuthorityId, staticToken, _ref29$ethereumContra, ethereumContractTimeout, _ref29$noCache, noCache, _ref29$noAuth, noAuth, assumeV3, configUrl;
|
|
2074
|
+
return _regeneratorRuntime.wrap(function (_context26) {
|
|
2075
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2045
2076
|
case 0:
|
|
2046
|
-
networkName =
|
|
2077
|
+
networkName = _ref29.networkName, region = _ref29.region, clientIP = _ref29.clientIP, trustAuthorityId = _ref29.trustAuthorityId, staticToken = _ref29.staticToken, _ref29$ethereumContra = _ref29.ethereumContractTimeout, ethereumContractTimeout = _ref29$ethereumContra === void 0 ? 10 : _ref29$ethereumContra, _ref29$noCache = _ref29.noCache, noCache = _ref29$noCache === void 0 ? false : _ref29$noCache, _ref29$noAuth = _ref29.noAuth, noAuth = _ref29$noAuth === void 0 ? false : _ref29$noAuth, assumeV3 = _ref29.assumeV3;
|
|
2047
2078
|
configUrl = networks[networkName];
|
|
2048
2079
|
if (configUrl) {
|
|
2049
|
-
|
|
2080
|
+
_context26.next = 1;
|
|
2050
2081
|
break;
|
|
2051
2082
|
}
|
|
2052
2083
|
throw Error("Invalid network name: " + networkName);
|
|
2053
|
-
case
|
|
2054
|
-
|
|
2084
|
+
case 1:
|
|
2085
|
+
_context26.next = 2;
|
|
2055
2086
|
return this.FromConfigurationUrl({
|
|
2056
2087
|
configUrl: configUrl,
|
|
2057
2088
|
region: region,
|
|
@@ -2063,15 +2094,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2063
2094
|
noAuth: noAuth,
|
|
2064
2095
|
assumeV3: assumeV3
|
|
2065
2096
|
});
|
|
2066
|
-
case
|
|
2067
|
-
return
|
|
2068
|
-
case
|
|
2097
|
+
case 2:
|
|
2098
|
+
return _context26.abrupt("return", _context26.sent);
|
|
2099
|
+
case 3:
|
|
2069
2100
|
case "end":
|
|
2070
|
-
return
|
|
2101
|
+
return _context26.stop();
|
|
2071
2102
|
}
|
|
2072
|
-
},
|
|
2103
|
+
}, _callee26, this);
|
|
2073
2104
|
}));
|
|
2074
|
-
function FromNetworkName(
|
|
2105
|
+
function FromNetworkName(_x22) {
|
|
2075
2106
|
return _FromNetworkName.apply(this, arguments);
|
|
2076
2107
|
}
|
|
2077
2108
|
return FromNetworkName;
|
|
@@ -2092,23 +2123,24 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2092
2123
|
*
|
|
2093
2124
|
* @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
|
|
2094
2125
|
*/
|
|
2126
|
+
)
|
|
2095
2127
|
}, {
|
|
2096
2128
|
key: "FromConfigurationUrl",
|
|
2097
|
-
value: function () {
|
|
2098
|
-
var _FromConfigurationUrl = _asyncToGenerator(
|
|
2099
|
-
var configUrl, region, clientIP, trustAuthorityId, staticToken,
|
|
2100
|
-
return _regeneratorRuntime.wrap(function
|
|
2101
|
-
while (1) switch (
|
|
2129
|
+
value: (function () {
|
|
2130
|
+
var _FromConfigurationUrl = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref30) {
|
|
2131
|
+
var configUrl, region, clientIP, trustAuthorityId, staticToken, _ref30$ethereumContra, ethereumContractTimeout, _ref30$noCache, noCache, _ref30$noAuth, noAuth, _ref30$assumeV, assumeV3, _yield$ElvClient$Conf3, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion, client;
|
|
2132
|
+
return _regeneratorRuntime.wrap(function (_context27) {
|
|
2133
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2102
2134
|
case 0:
|
|
2103
|
-
configUrl =
|
|
2104
|
-
|
|
2135
|
+
configUrl = _ref30.configUrl, region = _ref30.region, clientIP = _ref30.clientIP, trustAuthorityId = _ref30.trustAuthorityId, staticToken = _ref30.staticToken, _ref30$ethereumContra = _ref30.ethereumContractTimeout, ethereumContractTimeout = _ref30$ethereumContra === void 0 ? 10 : _ref30$ethereumContra, _ref30$noCache = _ref30.noCache, noCache = _ref30$noCache === void 0 ? false : _ref30$noCache, _ref30$noAuth = _ref30.noAuth, noAuth = _ref30$noAuth === void 0 ? false : _ref30$noAuth, _ref30$assumeV = _ref30.assumeV3, assumeV3 = _ref30$assumeV === void 0 ? false : _ref30$assumeV;
|
|
2136
|
+
_context27.next = 1;
|
|
2105
2137
|
return ElvClient.Configuration({
|
|
2106
2138
|
configUrl: configUrl,
|
|
2107
2139
|
clientIP: clientIP,
|
|
2108
2140
|
region: region
|
|
2109
2141
|
});
|
|
2110
|
-
case
|
|
2111
|
-
_yield$ElvClient$Conf3 =
|
|
2142
|
+
case 1:
|
|
2143
|
+
_yield$ElvClient$Conf3 = _context27.sent;
|
|
2112
2144
|
contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
|
|
2113
2145
|
networkId = _yield$ElvClient$Conf3.networkId;
|
|
2114
2146
|
networkName = _yield$ElvClient$Conf3.networkName;
|
|
@@ -2138,20 +2170,19 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2138
2170
|
client.configUrl = configUrl;
|
|
2139
2171
|
client.region = region;
|
|
2140
2172
|
client.clientIP = clientIP;
|
|
2141
|
-
return
|
|
2142
|
-
case
|
|
2173
|
+
return _context27.abrupt("return", client);
|
|
2174
|
+
case 2:
|
|
2143
2175
|
case "end":
|
|
2144
|
-
return
|
|
2176
|
+
return _context27.stop();
|
|
2145
2177
|
}
|
|
2146
|
-
},
|
|
2178
|
+
}, _callee27);
|
|
2147
2179
|
}));
|
|
2148
|
-
function FromConfigurationUrl(
|
|
2180
|
+
function FromConfigurationUrl(_x23) {
|
|
2149
2181
|
return _FromConfigurationUrl.apply(this, arguments);
|
|
2150
2182
|
}
|
|
2151
2183
|
return FromConfigurationUrl;
|
|
2152
|
-
}()
|
|
2184
|
+
}())
|
|
2153
2185
|
}]);
|
|
2154
|
-
return ElvClient;
|
|
2155
2186
|
}();
|
|
2156
2187
|
Object.assign(ElvClient.prototype, require("./client/AccessGroups"));
|
|
2157
2188
|
Object.assign(ElvClient.prototype, require("./client/ContentAccess"));
|