@eluvio/elv-client-js 4.0.10 → 4.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/ElvClient-min.js +10 -11
  2. package/dist/ElvClient-node-min.js +10 -11
  3. package/dist/ElvFrameClient-min.js +10 -11
  4. package/dist/ElvPermissionsClient-min.js +9 -10
  5. package/dist/ElvWalletClient-min.js +9 -10
  6. package/dist/ElvWalletClient-node-min.js +9 -10
  7. package/dist/src/AuthorizationClient.js +2070 -1550
  8. package/dist/src/ContentObjectVerification.js +185 -134
  9. package/dist/src/Crypto.js +319 -224
  10. package/dist/src/ElvClient.js +1114 -822
  11. package/dist/src/ElvWallet.js +106 -64
  12. package/dist/src/EthClient.js +974 -719
  13. package/dist/src/FrameClient.js +318 -222
  14. package/dist/src/HttpClient.js +154 -112
  15. package/dist/src/Id.js +6 -1
  16. package/dist/src/LogMessage.js +8 -4
  17. package/dist/src/PermissionsClient.js +1271 -973
  18. package/dist/src/RemoteSigner.js +232 -161
  19. package/dist/src/UserProfileClient.js +1038 -781
  20. package/dist/src/Utils.js +299 -159
  21. package/dist/src/Validation.js +17 -2
  22. package/dist/src/client/ABRPublishing.js +942 -772
  23. package/dist/src/client/AccessGroups.js +1095 -849
  24. package/dist/src/client/ContentAccess.js +4196 -3323
  25. package/dist/src/client/ContentManagement.js +2288 -1814
  26. package/dist/src/client/Contracts.js +614 -468
  27. package/dist/src/client/Files.js +1831 -1490
  28. package/dist/src/client/NFT.js +116 -94
  29. package/dist/src/client/NTP.js +425 -326
  30. package/dist/src/index.js +5 -2
  31. package/dist/src/walletClient/ClientMethods.js +1763 -1368
  32. package/dist/src/walletClient/Configuration.js +2 -4
  33. package/dist/src/walletClient/Notifications.js +127 -98
  34. package/dist/src/walletClient/Profile.js +246 -184
  35. package/dist/src/walletClient/Utils.js +122 -76
  36. package/dist/src/walletClient/index.js +1496 -1171
  37. package/package.json +1 -1
  38. package/src/AuthorizationClient.js +5 -5
  39. package/src/client/Files.js +1 -1
  40. package/testScripts/CreateMezMonolithic.js +0 -779
@@ -1,44 +1,66 @@
1
1
  var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
2
+
2
3
  var _typeof = require("@babel/runtime/helpers/typeof");
4
+
3
5
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
6
+
4
7
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
8
+
5
9
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
10
+
6
11
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
12
+
7
13
  var _createClass = require("@babel/runtime/helpers/createClass");
14
+
8
15
  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; }
16
+
9
17
  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; }
18
+
10
19
  if (typeof globalThis.Buffer === "undefined") {
11
20
  globalThis.Buffer = require("buffer/").Buffer;
12
21
  }
22
+
13
23
  var URI = require("urijs");
24
+
14
25
  var Ethers = require("ethers");
26
+
15
27
  var AuthorizationClient = require("./AuthorizationClient");
28
+
16
29
  var ElvWallet = require("./ElvWallet");
30
+
17
31
  var EthClient = require("./EthClient");
32
+
18
33
  var UserProfileClient = require("./UserProfileClient");
34
+
19
35
  var HttpClient = require("./HttpClient");
20
- var RemoteSigner = require("./RemoteSigner");
21
36
 
22
- // const ContentObjectVerification = require("./ContentObjectVerification");
37
+ var RemoteSigner = require("./RemoteSigner"); // const ContentObjectVerification = require("./ContentObjectVerification");
38
+
39
+
23
40
  var Utils = require("./Utils");
41
+
24
42
  var Crypto = require("./Crypto");
43
+
25
44
  var _require = require("./LogMessage"),
26
- LogMessage = _require.LogMessage;
45
+ LogMessage = _require.LogMessage;
46
+
27
47
  var Pako = require("pako");
48
+
28
49
  var _require2 = require("./Validation"),
29
- ValidatePresence = _require2.ValidatePresence;
50
+ ValidatePresence = _require2.ValidatePresence;
51
+
30
52
  var networks = {
31
53
  "main": "https://main.net955305.contentfabric.io",
32
54
  "demo": "https://demov3.net955210.contentfabric.io",
33
55
  "demov3": "https://demov3.net955210.contentfabric.io",
34
56
  "test": "https://test.net955203.contentfabric.io"
35
57
  };
58
+
36
59
  if (Utils.Platform() === Utils.PLATFORM_NODE) {
37
60
  // Define Response in node
38
61
  // eslint-disable-next-line no-global-assign
39
62
  globalThis.Response = require("node-fetch").Response;
40
63
  }
41
-
42
64
  /**
43
65
  * See the Modules section on the sidebar for details about methods related to interacting with the Fabric.
44
66
  *
@@ -46,6 +68,8 @@ if (Utils.Platform() === Utils.PLATFORM_NODE) {
46
68
  *
47
69
  * For information about the Eluvio Wallet Client, go <a href="wallet-client/index.html">here</a>.
48
70
  */
71
+
72
+
49
73
  var ElvClient = /*#__PURE__*/function () {
50
74
  "use strict";
51
75
 
@@ -79,26 +103,28 @@ var ElvClient = /*#__PURE__*/function () {
79
103
  */
80
104
  function ElvClient(_ref) {
81
105
  var contentSpaceId = _ref.contentSpaceId,
82
- networkId = _ref.networkId,
83
- networkName = _ref.networkName,
84
- fabricVersion = _ref.fabricVersion,
85
- fabricURIs = _ref.fabricURIs,
86
- ethereumURIs = _ref.ethereumURIs,
87
- authServiceURIs = _ref.authServiceURIs,
88
- searchURIs = _ref.searchURIs,
89
- _ref$ethereumContract = _ref.ethereumContractTimeout,
90
- ethereumContractTimeout = _ref$ethereumContract === void 0 ? 10 : _ref$ethereumContract,
91
- trustAuthorityId = _ref.trustAuthorityId,
92
- staticToken = _ref.staticToken,
93
- _ref$noCache = _ref.noCache,
94
- noCache = _ref$noCache === void 0 ? false : _ref$noCache,
95
- _ref$noAuth = _ref.noAuth,
96
- noAuth = _ref$noAuth === void 0 ? false : _ref$noAuth,
97
- _ref$assumeV = _ref.assumeV3,
98
- assumeV3 = _ref$assumeV === void 0 ? false : _ref$assumeV,
99
- _ref$service = _ref.service,
100
- service = _ref$service === void 0 ? "default" : _ref$service;
106
+ networkId = _ref.networkId,
107
+ networkName = _ref.networkName,
108
+ fabricVersion = _ref.fabricVersion,
109
+ fabricURIs = _ref.fabricURIs,
110
+ ethereumURIs = _ref.ethereumURIs,
111
+ authServiceURIs = _ref.authServiceURIs,
112
+ searchURIs = _ref.searchURIs,
113
+ _ref$ethereumContract = _ref.ethereumContractTimeout,
114
+ ethereumContractTimeout = _ref$ethereumContract === void 0 ? 10 : _ref$ethereumContract,
115
+ trustAuthorityId = _ref.trustAuthorityId,
116
+ staticToken = _ref.staticToken,
117
+ _ref$noCache = _ref.noCache,
118
+ noCache = _ref$noCache === void 0 ? false : _ref$noCache,
119
+ _ref$noAuth = _ref.noAuth,
120
+ noAuth = _ref$noAuth === void 0 ? false : _ref$noAuth,
121
+ _ref$assumeV = _ref.assumeV3,
122
+ assumeV3 = _ref$assumeV === void 0 ? false : _ref$assumeV,
123
+ _ref$service = _ref.service,
124
+ service = _ref$service === void 0 ? "default" : _ref$service;
125
+
101
126
  _classCallCheck(this, ElvClient);
127
+
102
128
  this.utils = Utils;
103
129
  this.contentSpaceId = contentSpaceId;
104
130
  this.contentSpaceAddress = this.utils.HashToAddress(contentSpaceId);
@@ -116,16 +142,17 @@ var ElvClient = /*#__PURE__*/function () {
116
142
  this.noCache = noCache;
117
143
  this.noAuth = noAuth;
118
144
  this.assumeV3 = assumeV3;
145
+
119
146
  if (!["search", "default"].includes(service)) {
120
147
  throw Error("Invalid service: ".concat(service));
121
148
  }
149
+
122
150
  this.service = service;
123
151
  this.debug = false;
124
152
  this.InitializeClients({
125
153
  staticToken: staticToken
126
154
  });
127
155
  }
128
-
129
156
  /**
130
157
  * Retrieve content space info and preferred fabric and blockchain URLs from the fabric
131
158
  *
@@ -138,13 +165,14 @@ var ElvClient = /*#__PURE__*/function () {
138
165
  *
139
166
  * @return {Promise<Object>} - Object containing content space ID and fabric and ethereum URLs
140
167
  */
168
+
169
+
141
170
  _createClass(ElvClient, [{
142
171
  key: "Log",
143
172
  value: function Log(message) {
144
173
  var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
145
174
  LogMessage(this, message, error);
146
175
  }
147
-
148
176
  /**
149
177
  * Enable or disable verbose logging
150
178
  *
@@ -156,10 +184,12 @@ var ElvClient = /*#__PURE__*/function () {
156
184
  * - error: custom error() function
157
185
  * - (custom functions must accept same arguments as console.log/console.error)
158
186
  */
187
+
159
188
  }, {
160
189
  key: "ToggleLogging",
161
190
  value: function ToggleLogging(enable) {
162
191
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
192
+
163
193
  // define func with closure to pass to forEach
164
194
  var setDebug = function setDebug(reporter) {
165
195
  if (reporter) {
@@ -167,7 +197,9 @@ var ElvClient = /*#__PURE__*/function () {
167
197
  reporter.debugOptions = options;
168
198
  }
169
199
  };
200
+
170
201
  [this, this.authClient, this.ethClient, this.HttpClient, this.userProfileClient].forEach(setDebug);
202
+
171
203
  if (enable) {
172
204
  this.Log("Debug Logging Enabled:\n Content Space: ".concat(this.contentSpaceId, "\n Fabric URLs: [\n\t\t").concat(this.fabricURIs.join(", \n\t\t"), "\n\t]\n Ethereum URLs: [\n\t\t").concat(this.ethereumURIs.join(", \n\t\t"), "\n\t]\n Auth Service URLs: [\n\t\t").concat(this.authServiceURIs.join(", \n\t\t"), "\n\t]\n "));
173
205
  }
@@ -180,48 +212,59 @@ var ElvClient = /*#__PURE__*/function () {
180
212
  return typeof klass[method] === "function";
181
213
  }).forEach(function (methodName) {
182
214
  var originalMethod = klass[methodName].bind(klass);
215
+
183
216
  if (originalMethod.constructor.name === "AsyncFunction") {
184
217
  klass[methodName] = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
185
218
  var start,
186
- _len,
187
- args,
188
- _key,
189
- result,
190
- _args = arguments;
219
+ _len,
220
+ args,
221
+ _key,
222
+ result,
223
+ _args = arguments;
224
+
191
225
  return _regeneratorRuntime.wrap(function _callee$(_context) {
192
- while (1) switch (_context.prev = _context.next) {
193
- case 0:
194
- start = Date.now();
195
- for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
196
- args[_key] = _args[_key];
197
- }
198
- _context.next = 4;
199
- return originalMethod.apply(void 0, args);
200
- case 4:
201
- result = _context.sent;
202
- // eslint-disable-next-line no-console
203
- console.log(methodName, Date.now() - start, "ms", JSON.stringify(args));
204
- return _context.abrupt("return", result);
205
- case 7:
206
- case "end":
207
- return _context.stop();
226
+ while (1) {
227
+ switch (_context.prev = _context.next) {
228
+ case 0:
229
+ start = Date.now();
230
+
231
+ for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
232
+ args[_key] = _args[_key];
233
+ }
234
+
235
+ _context.next = 4;
236
+ return originalMethod.apply(void 0, args);
237
+
238
+ case 4:
239
+ result = _context.sent;
240
+ // eslint-disable-next-line no-console
241
+ console.log(methodName, Date.now() - start, "ms", JSON.stringify(args));
242
+ return _context.abrupt("return", result);
243
+
244
+ case 7:
245
+ case "end":
246
+ return _context.stop();
247
+ }
208
248
  }
209
249
  }, _callee);
210
250
  }));
211
251
  } else {
212
252
  klass[methodName] = function () {
213
253
  var start = Date.now();
254
+
214
255
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
215
256
  args[_key2] = arguments[_key2];
216
257
  }
217
- var result = originalMethod.apply(void 0, args);
218
- // eslint-disable-next-line no-console
258
+
259
+ var result = originalMethod.apply(void 0, args); // eslint-disable-next-line no-console
260
+
219
261
  console.log(methodName, Date.now() - start, "ms", JSON.stringify(args));
220
262
  return result;
221
263
  };
222
264
  }
223
265
  });
224
266
  };
267
+
225
268
  MethodLogger(this);
226
269
  }
227
270
  }, {
@@ -229,78 +272,85 @@ var ElvClient = /*#__PURE__*/function () {
229
272
  value: function () {
230
273
  var _InitializeClients = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
231
274
  var _ref3,
232
- staticToken,
233
- uris,
234
- wallet,
235
- signer,
236
- _args2 = arguments;
275
+ staticToken,
276
+ uris,
277
+ wallet,
278
+ signer,
279
+ _args2 = arguments;
280
+
237
281
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
238
- while (1) switch (_context2.prev = _context2.next) {
239
- case 0:
240
- _ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, staticToken = _ref3.staticToken;
241
- // Cached info
242
- this.contentTypes = {};
243
- this.encryptionConks = {};
244
- this.stateChannelAccess = {};
245
- this.objectTenantIds = {};
246
- this.objectLibraryIds = {};
247
- this.objectImageUrls = {};
248
- this.visibilityInfo = {};
249
- this.inaccessibleLibraries = {};
250
- uris = this.service === "search" ? this.searchURIs : this.fabricURIs;
251
- this.HttpClient = new HttpClient({
252
- uris: uris,
253
- debug: this.debug
254
- });
255
- this.AuthHttpClient = new HttpClient({
256
- uris: this.authServiceURIs,
257
- debug: this.debug
258
- });
259
- this.ethClient = new EthClient({
260
- client: this,
261
- uris: this.ethereumURIs,
262
- networkId: this.networkId,
263
- debug: this.debug,
264
- timeout: this.ethereumContractTimeout
265
- });
266
- if (!this.signer) {
267
- wallet = this.GenerateWallet();
268
- signer = wallet.AddAccountFromMnemonic({
269
- mnemonic: wallet.GenerateMnemonic()
282
+ while (1) {
283
+ switch (_context2.prev = _context2.next) {
284
+ case 0:
285
+ _ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, staticToken = _ref3.staticToken;
286
+ // Cached info
287
+ this.contentTypes = {};
288
+ this.encryptionConks = {};
289
+ this.stateChannelAccess = {};
290
+ this.objectTenantIds = {};
291
+ this.objectLibraryIds = {};
292
+ this.objectImageUrls = {};
293
+ this.visibilityInfo = {};
294
+ this.inaccessibleLibraries = {};
295
+ uris = this.service === "search" ? this.searchURIs : this.fabricURIs;
296
+ this.HttpClient = new HttpClient({
297
+ uris: uris,
298
+ debug: this.debug
270
299
  });
271
- this.SetSigner({
272
- signer: signer,
273
- reset: false
300
+ this.AuthHttpClient = new HttpClient({
301
+ uris: this.authServiceURIs,
302
+ debug: this.debug
274
303
  });
275
- this.SetStaticToken({
276
- token: staticToken
304
+ this.ethClient = new EthClient({
305
+ client: this,
306
+ uris: this.ethereumURIs,
307
+ networkId: this.networkId,
308
+ debug: this.debug,
309
+ timeout: this.ethereumContractTimeout
277
310
  });
278
- }
279
- this.authClient = new AuthorizationClient({
280
- client: this,
281
- contentSpaceId: this.contentSpaceId,
282
- signer: this.signer,
283
- noCache: this.noCache,
284
- noAuth: this.noAuth,
285
- debug: this.debug
286
- });
287
- this.userProfileClient = new UserProfileClient({
288
- client: this,
289
- debug: this.debug
290
- });
291
-
292
- // Initialize crypto wasm
293
- this.Crypto = Crypto;
294
- this.Crypto.ElvCrypto();
295
- case 18:
296
- case "end":
297
- return _context2.stop();
311
+
312
+ if (!this.signer) {
313
+ wallet = this.GenerateWallet();
314
+ signer = wallet.AddAccountFromMnemonic({
315
+ mnemonic: wallet.GenerateMnemonic()
316
+ });
317
+ this.SetSigner({
318
+ signer: signer,
319
+ reset: false
320
+ });
321
+ this.SetStaticToken({
322
+ token: staticToken
323
+ });
324
+ }
325
+
326
+ this.authClient = new AuthorizationClient({
327
+ client: this,
328
+ contentSpaceId: this.contentSpaceId,
329
+ signer: this.signer,
330
+ noCache: this.noCache,
331
+ noAuth: this.noAuth,
332
+ debug: this.debug
333
+ });
334
+ this.userProfileClient = new UserProfileClient({
335
+ client: this,
336
+ debug: this.debug
337
+ }); // Initialize crypto wasm
338
+
339
+ this.Crypto = Crypto;
340
+ this.Crypto.ElvCrypto();
341
+
342
+ case 18:
343
+ case "end":
344
+ return _context2.stop();
345
+ }
298
346
  }
299
347
  }, _callee2, this);
300
348
  }));
349
+
301
350
  function InitializeClients() {
302
351
  return _InitializeClients.apply(this, arguments);
303
352
  }
353
+
304
354
  return InitializeClients;
305
355
  }()
306
356
  }, {
@@ -314,7 +364,6 @@ var ElvClient = /*#__PURE__*/function () {
314
364
  this.noAuth = !auth;
315
365
  this.authClient.noAuth = !auth;
316
366
  }
317
-
318
367
  /**
319
368
  * Update fabric URLs to prefer the specified region.
320
369
  *
@@ -327,54 +376,65 @@ var ElvClient = /*#__PURE__*/function () {
327
376
  *
328
377
  * @return {Promise<Object>} - An object containing the updated fabric, ethereum, auth service, and search URLs in order of preference
329
378
  */
379
+
330
380
  }, {
331
381
  key: "UseRegion",
332
382
  value: function () {
333
383
  var _UseRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
334
384
  var region, _yield$ElvClient$Conf, fabricURIs, ethereumURIs, authServiceURIs, searchURIs;
385
+
335
386
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
336
- while (1) switch (_context3.prev = _context3.next) {
337
- case 0:
338
- region = _ref4.region;
339
- if (this.configUrl) {
340
- _context3.next = 3;
341
- break;
342
- }
343
- throw Error("Unable to change region: Configuration URL not set");
344
- case 3:
345
- _context3.next = 5;
346
- return ElvClient.Configuration({
347
- configUrl: this.configUrl,
348
- region: region
349
- });
350
- case 5:
351
- _yield$ElvClient$Conf = _context3.sent;
352
- fabricURIs = _yield$ElvClient$Conf.fabricURIs;
353
- ethereumURIs = _yield$ElvClient$Conf.ethereumURIs;
354
- authServiceURIs = _yield$ElvClient$Conf.authServiceURIs;
355
- searchURIs = _yield$ElvClient$Conf.searchURIs;
356
- this.authServiceURIs = authServiceURIs;
357
- this.fabricURIs = fabricURIs;
358
- this.ethereumURIs = ethereumURIs;
359
- this.searchURIs = searchURIs;
360
- this.HttpClient.uris = fabricURIs;
361
- this.HttpClient.uriIndex = 0;
362
- this.ethClient.ethereumURIs = ethereumURIs;
363
- this.ethClient.ethereumURIIndex = 0;
364
- return _context3.abrupt("return", {
365
- fabricURIs: fabricURIs,
366
- ethereumURIs: ethereumURIs,
367
- searchURIs: searchURIs
368
- });
369
- case 19:
370
- case "end":
371
- return _context3.stop();
387
+ while (1) {
388
+ switch (_context3.prev = _context3.next) {
389
+ case 0:
390
+ region = _ref4.region;
391
+
392
+ if (this.configUrl) {
393
+ _context3.next = 3;
394
+ break;
395
+ }
396
+
397
+ throw Error("Unable to change region: Configuration URL not set");
398
+
399
+ case 3:
400
+ _context3.next = 5;
401
+ return ElvClient.Configuration({
402
+ configUrl: this.configUrl,
403
+ region: region
404
+ });
405
+
406
+ case 5:
407
+ _yield$ElvClient$Conf = _context3.sent;
408
+ fabricURIs = _yield$ElvClient$Conf.fabricURIs;
409
+ ethereumURIs = _yield$ElvClient$Conf.ethereumURIs;
410
+ authServiceURIs = _yield$ElvClient$Conf.authServiceURIs;
411
+ searchURIs = _yield$ElvClient$Conf.searchURIs;
412
+ this.authServiceURIs = authServiceURIs;
413
+ this.fabricURIs = fabricURIs;
414
+ this.ethereumURIs = ethereumURIs;
415
+ this.searchURIs = searchURIs;
416
+ this.HttpClient.uris = fabricURIs;
417
+ this.HttpClient.uriIndex = 0;
418
+ this.ethClient.ethereumURIs = ethereumURIs;
419
+ this.ethClient.ethereumURIIndex = 0;
420
+ return _context3.abrupt("return", {
421
+ fabricURIs: fabricURIs,
422
+ ethereumURIs: ethereumURIs,
423
+ searchURIs: searchURIs
424
+ });
425
+
426
+ case 19:
427
+ case "end":
428
+ return _context3.stop();
429
+ }
372
430
  }
373
431
  }, _callee3, this);
374
432
  }));
433
+
375
434
  function UseRegion(_x) {
376
435
  return _UseRegion.apply(this, arguments);
377
436
  }
437
+
378
438
  return UseRegion;
379
439
  }()
380
440
  /**
@@ -386,34 +446,43 @@ var ElvClient = /*#__PURE__*/function () {
386
446
  *
387
447
  * @return {Promise<Object>} - An object containing the updated fabric and ethereum URLs in order of preference
388
448
  */
449
+
389
450
  }, {
390
451
  key: "ResetRegion",
391
452
  value: function () {
392
453
  var _ResetRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
393
454
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
394
- while (1) switch (_context4.prev = _context4.next) {
395
- case 0:
396
- if (this.configUrl) {
397
- _context4.next = 2;
398
- break;
399
- }
400
- throw Error("Unable to change region: Configuration URL not set");
401
- case 2:
402
- _context4.next = 4;
403
- return this.UseRegion({
404
- region: ""
405
- });
406
- case 4:
407
- return _context4.abrupt("return", _context4.sent);
408
- case 5:
409
- case "end":
410
- return _context4.stop();
455
+ while (1) {
456
+ switch (_context4.prev = _context4.next) {
457
+ case 0:
458
+ if (this.configUrl) {
459
+ _context4.next = 2;
460
+ break;
461
+ }
462
+
463
+ throw Error("Unable to change region: Configuration URL not set");
464
+
465
+ case 2:
466
+ _context4.next = 4;
467
+ return this.UseRegion({
468
+ region: ""
469
+ });
470
+
471
+ case 4:
472
+ return _context4.abrupt("return", _context4.sent);
473
+
474
+ case 5:
475
+ case "end":
476
+ return _context4.stop();
477
+ }
411
478
  }
412
479
  }, _callee4, this);
413
480
  }));
481
+
414
482
  function ResetRegion() {
415
483
  return _ResetRegion.apply(this, arguments);
416
484
  }
485
+
417
486
  return ResetRegion;
418
487
  }()
419
488
  /**
@@ -428,33 +497,41 @@ var ElvClient = /*#__PURE__*/function () {
428
497
  *
429
498
  * @return {Promise<string>} - The node ID reported by the fabric
430
499
  */
500
+
431
501
  }, {
432
502
  key: "NodeId",
433
503
  value: function () {
434
504
  var _NodeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
435
505
  var region, _yield$ElvClient$Conf2, nodeId;
506
+
436
507
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
437
- while (1) switch (_context5.prev = _context5.next) {
438
- case 0:
439
- region = _ref5.region;
440
- _context5.next = 3;
441
- return ElvClient.Configuration({
442
- configUrl: this.configUrl,
443
- region: region
444
- });
445
- case 3:
446
- _yield$ElvClient$Conf2 = _context5.sent;
447
- nodeId = _yield$ElvClient$Conf2.nodeId;
448
- return _context5.abrupt("return", nodeId);
449
- case 6:
450
- case "end":
451
- return _context5.stop();
508
+ while (1) {
509
+ switch (_context5.prev = _context5.next) {
510
+ case 0:
511
+ region = _ref5.region;
512
+ _context5.next = 3;
513
+ return ElvClient.Configuration({
514
+ configUrl: this.configUrl,
515
+ region: region
516
+ });
517
+
518
+ case 3:
519
+ _yield$ElvClient$Conf2 = _context5.sent;
520
+ nodeId = _yield$ElvClient$Conf2.nodeId;
521
+ return _context5.abrupt("return", nodeId);
522
+
523
+ case 6:
524
+ case "end":
525
+ return _context5.stop();
526
+ }
452
527
  }
453
528
  }, _callee5, this);
454
529
  }));
530
+
455
531
  function NodeId(_x2) {
456
532
  return _NodeId.apply(this, arguments);
457
533
  }
534
+
458
535
  return NodeId;
459
536
  }()
460
537
  /**
@@ -464,6 +541,7 @@ var ElvClient = /*#__PURE__*/function () {
464
541
  *
465
542
  * @return {Promise<Object>} - An object containing the lists of fabric, ethereum, auth service, and search urls in use by the client
466
543
  */
544
+
467
545
  }, {
468
546
  key: "Nodes",
469
547
  value: function Nodes() {
@@ -474,7 +552,6 @@ var ElvClient = /*#__PURE__*/function () {
474
552
  searchURIs: this.searchURIs
475
553
  };
476
554
  }
477
-
478
555
  /**
479
556
  * Set the client to use the specified fabric, ethereum, auth service, and search nodes, in preference order
480
557
  *
@@ -486,39 +563,44 @@ var ElvClient = /*#__PURE__*/function () {
486
563
  *
487
564
  * @methodGroup Nodes
488
565
  */
566
+
489
567
  }, {
490
568
  key: "SetNodes",
491
569
  value: function SetNodes(_ref6) {
492
570
  var fabricURIs = _ref6.fabricURIs,
493
- ethereumURIs = _ref6.ethereumURIs,
494
- authServiceURIs = _ref6.authServiceURIs,
495
- searchURIs = _ref6.searchURIs;
571
+ ethereumURIs = _ref6.ethereumURIs,
572
+ authServiceURIs = _ref6.authServiceURIs,
573
+ searchURIs = _ref6.searchURIs;
574
+
496
575
  if (fabricURIs) {
497
576
  this.fabricURIs = fabricURIs;
498
577
  this.HttpClient.uris = fabricURIs;
499
578
  this.HttpClient.uriIndex = 0;
500
579
  }
580
+
501
581
  if (ethereumURIs) {
502
582
  this.ethereumURIs = ethereumURIs;
503
583
  this.ethClient.ethereumURIs = ethereumURIs;
504
584
  this.ethClient.ethereumURIIndex = 0;
505
585
  }
586
+
506
587
  if (authServiceURIs) {
507
588
  this.authServiceURIs = authServiceURIs;
508
589
  this.AuthHttpClient.uris = authServiceURIs;
509
590
  this.AuthHttpClient.uriIndex = 0;
510
591
  }
592
+
511
593
  if (searchURIs) {
512
594
  this.searchURIs = searchURIs;
513
595
  }
514
596
  }
515
-
516
597
  /**
517
598
  * Return information about how the client was connected to the network
518
599
  *
519
600
  * @methodGroup Nodes
520
601
  * @returns {Object} - The name, ID and configuration URL of the network
521
602
  */
603
+
522
604
  }, {
523
605
  key: "NetworkInfo",
524
606
  value: function NetworkInfo() {
@@ -528,7 +610,6 @@ var ElvClient = /*#__PURE__*/function () {
528
610
  configUrl: this.configUrl
529
611
  };
530
612
  }
531
-
532
613
  /* Wallet and signers */
533
614
 
534
615
  /**
@@ -537,35 +618,35 @@ var ElvClient = /*#__PURE__*/function () {
537
618
  * @methodGroup Signers
538
619
  * @returns {ElvWallet} - ElvWallet instance with this client's provider
539
620
  */
621
+
540
622
  }, {
541
623
  key: "GenerateWallet",
542
624
  value: function GenerateWallet() {
543
625
  return new ElvWallet(this.ethClient.Provider());
544
626
  }
545
-
546
627
  /**
547
628
  * Remove the signer from this client
548
629
  *
549
630
  * @methodGroup Signers
550
631
  */
632
+
551
633
  }, {
552
634
  key: "ClearSigner",
553
635
  value: function ClearSigner() {
554
636
  this.signer = undefined;
555
637
  this.InitializeClients();
556
638
  }
557
-
558
639
  /**
559
640
  * Clear saved access and state channel tokens
560
641
  *
561
642
  * @methodGroup Access Requests
562
643
  */
644
+
563
645
  }, {
564
646
  key: "ClearCache",
565
647
  value: function ClearCache() {
566
648
  this.authClient.ClearCache();
567
649
  }
568
-
569
650
  /**
570
651
  * Set the signer for this client to use for blockchain transactions
571
652
  *
@@ -573,21 +654,22 @@ var ElvClient = /*#__PURE__*/function () {
573
654
  * @namedParams
574
655
  * @param {object} signer - The ethers.js signer object
575
656
  */
657
+
576
658
  }, {
577
659
  key: "SetSigner",
578
660
  value: function SetSigner(_ref7) {
579
661
  var signer = _ref7.signer,
580
- _ref7$reset = _ref7.reset,
581
- reset = _ref7$reset === void 0 ? true : _ref7$reset;
662
+ _ref7$reset = _ref7.reset,
663
+ reset = _ref7$reset === void 0 ? true : _ref7$reset;
582
664
  this.staticToken = undefined;
583
665
  signer.connect(this.ethClient.Provider());
584
666
  signer.provider.pollingInterval = 500;
585
667
  this.signer = signer;
668
+
586
669
  if (reset) {
587
670
  this.InitializeClients();
588
671
  }
589
672
  }
590
-
591
673
  /**
592
674
  * Set signer using OAuth ID token
593
675
  *
@@ -600,51 +682,59 @@ var ElvClient = /*#__PURE__*/function () {
600
682
  * @param {Array<string>=} signerURIs - (Only if using custom OAuth) - URIs corresponding to the key server(s) to use
601
683
  * @param {boolean=} unsignedPublicAuth=false - If specified, the client will use an unsigned static token for calls that don't require authorization (reduces remote signature calls)
602
684
  */
685
+
603
686
  }, {
604
687
  key: "SetRemoteSigner",
605
688
  value: function () {
606
689
  var _SetRemoteSigner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref8) {
607
690
  var idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth, signer;
608
691
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
609
- while (1) switch (_context6.prev = _context6.next) {
610
- case 0:
611
- idToken = _ref8.idToken, authToken = _ref8.authToken, tenantId = _ref8.tenantId, extraData = _ref8.extraData, signerURIs = _ref8.signerURIs, unsignedPublicAuth = _ref8.unsignedPublicAuth;
612
- _context6.t0 = RemoteSigner;
613
- _context6.t1 = signerURIs || this.authServiceURIs;
614
- _context6.t2 = idToken;
615
- _context6.t3 = authToken;
616
- _context6.t4 = tenantId;
617
- _context6.next = 8;
618
- return this.ethClient.Provider();
619
- case 8:
620
- _context6.t5 = _context6.sent;
621
- _context6.t6 = extraData;
622
- _context6.t7 = unsignedPublicAuth;
623
- _context6.t8 = {
624
- signerURIs: _context6.t1,
625
- idToken: _context6.t2,
626
- authToken: _context6.t3,
627
- tenantId: _context6.t4,
628
- provider: _context6.t5,
629
- extraData: _context6.t6,
630
- unsignedPublicAuth: _context6.t7
631
- };
632
- signer = new _context6.t0(_context6.t8);
633
- _context6.next = 15;
634
- return signer.Initialize();
635
- case 15:
636
- this.SetSigner({
637
- signer: signer
638
- });
639
- case 16:
640
- case "end":
641
- return _context6.stop();
692
+ while (1) {
693
+ switch (_context6.prev = _context6.next) {
694
+ case 0:
695
+ idToken = _ref8.idToken, authToken = _ref8.authToken, tenantId = _ref8.tenantId, extraData = _ref8.extraData, signerURIs = _ref8.signerURIs, unsignedPublicAuth = _ref8.unsignedPublicAuth;
696
+ _context6.t0 = RemoteSigner;
697
+ _context6.t1 = signerURIs || this.authServiceURIs;
698
+ _context6.t2 = idToken;
699
+ _context6.t3 = authToken;
700
+ _context6.t4 = tenantId;
701
+ _context6.next = 8;
702
+ return this.ethClient.Provider();
703
+
704
+ case 8:
705
+ _context6.t5 = _context6.sent;
706
+ _context6.t6 = extraData;
707
+ _context6.t7 = unsignedPublicAuth;
708
+ _context6.t8 = {
709
+ signerURIs: _context6.t1,
710
+ idToken: _context6.t2,
711
+ authToken: _context6.t3,
712
+ tenantId: _context6.t4,
713
+ provider: _context6.t5,
714
+ extraData: _context6.t6,
715
+ unsignedPublicAuth: _context6.t7
716
+ };
717
+ signer = new _context6.t0(_context6.t8);
718
+ _context6.next = 15;
719
+ return signer.Initialize();
720
+
721
+ case 15:
722
+ this.SetSigner({
723
+ signer: signer
724
+ });
725
+
726
+ case 16:
727
+ case "end":
728
+ return _context6.stop();
729
+ }
642
730
  }
643
731
  }, _callee6, this);
644
732
  }));
733
+
645
734
  function SetRemoteSigner(_x3) {
646
735
  return _SetRemoteSigner.apply(this, arguments);
647
736
  }
737
+
648
738
  return SetRemoteSigner;
649
739
  }()
650
740
  /**
@@ -657,34 +747,41 @@ var ElvClient = /*#__PURE__*/function () {
657
747
  * @namedParams
658
748
  * @param {object} provider - The web3 provider object
659
749
  */
750
+
660
751
  }, {
661
752
  key: "SetSignerFromWeb3Provider",
662
753
  value: function () {
663
754
  var _SetSignerFromWeb3Provider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref9) {
664
755
  var provider, ethProvider;
665
756
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
666
- while (1) switch (_context7.prev = _context7.next) {
667
- case 0:
668
- provider = _ref9.provider;
669
- this.staticToken = undefined;
670
- ethProvider = new Ethers.providers.Web3Provider(provider);
671
- ethProvider.pollingInterval = 250;
672
- this.signer = ethProvider.getSigner();
673
- _context7.next = 7;
674
- return this.signer.getAddress();
675
- case 7:
676
- this.signer.address = _context7.sent;
677
- _context7.next = 10;
678
- return this.InitializeClients();
679
- case 10:
680
- case "end":
681
- return _context7.stop();
757
+ while (1) {
758
+ switch (_context7.prev = _context7.next) {
759
+ case 0:
760
+ provider = _ref9.provider;
761
+ this.staticToken = undefined;
762
+ ethProvider = new Ethers.providers.Web3Provider(provider);
763
+ ethProvider.pollingInterval = 250;
764
+ this.signer = ethProvider.getSigner();
765
+ _context7.next = 7;
766
+ return this.signer.getAddress();
767
+
768
+ case 7:
769
+ this.signer.address = _context7.sent;
770
+ _context7.next = 10;
771
+ return this.InitializeClients();
772
+
773
+ case 10:
774
+ case "end":
775
+ return _context7.stop();
776
+ }
682
777
  }
683
778
  }, _callee7, this);
684
779
  }));
780
+
685
781
  function SetSignerFromWeb3Provider(_x4) {
686
782
  return _SetSignerFromWeb3Provider.apply(this, arguments);
687
783
  }
784
+
688
785
  return SetSignerFromWeb3Provider;
689
786
  }()
690
787
  /**
@@ -702,72 +799,86 @@ var ElvClient = /*#__PURE__*/function () {
702
799
  *
703
800
  * @return {string} - The address of the user
704
801
  */
802
+
705
803
  }, {
706
804
  key: "CreateAccount",
707
805
  value: function () {
708
806
  var _CreateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref10) {
709
807
  var tenantId, fundingToken, _ref10$funds, funds, groupToken, wallet, signer;
808
+
710
809
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
711
- while (1) switch (_context8.prev = _context8.next) {
712
- case 0:
713
- tenantId = _ref10.tenantId, fundingToken = _ref10.fundingToken, _ref10$funds = _ref10.funds, funds = _ref10$funds === void 0 ? 0.5 : _ref10$funds, groupToken = _ref10.groupToken;
714
- if (!this.signer) {
715
- wallet = this.GenerateWallet();
716
- signer = wallet.AddAccountFromMnemonic({
717
- mnemonic: wallet.GenerateMnemonic()
810
+ while (1) {
811
+ switch (_context8.prev = _context8.next) {
812
+ case 0:
813
+ tenantId = _ref10.tenantId, fundingToken = _ref10.fundingToken, _ref10$funds = _ref10.funds, funds = _ref10$funds === void 0 ? 0.5 : _ref10$funds, groupToken = _ref10.groupToken;
814
+
815
+ if (!this.signer) {
816
+ wallet = this.GenerateWallet();
817
+ signer = wallet.AddAccountFromMnemonic({
818
+ mnemonic: wallet.GenerateMnemonic()
819
+ });
820
+ this.SetSigner({
821
+ signer: signer
822
+ });
823
+ }
824
+
825
+ _context8.next = 4;
826
+ return this.authClient.MakeKMSRequest({
827
+ method: "POST",
828
+ path: "/ks/otp/fnd/".concat(tenantId),
829
+ body: {
830
+ toAddr: this.signer.address,
831
+ amtStr: this.utils.EtherToWei(funds)
832
+ },
833
+ headers: {
834
+ Authorization: "Bearer ".concat(fundingToken)
835
+ }
718
836
  });
719
- this.SetSigner({
720
- signer: signer
837
+
838
+ case 4:
839
+ _context8.next = 6;
840
+ return this.userProfileClient.CreateWallet();
841
+
842
+ case 6:
843
+ _context8.next = 8;
844
+ return this.userProfileClient.ReplaceUserMetadata({
845
+ metadataSubtree: "tenantContractId",
846
+ metadata: tenantId
721
847
  });
722
- }
723
- _context8.next = 4;
724
- return this.authClient.MakeKMSRequest({
725
- method: "POST",
726
- path: "/ks/otp/fnd/".concat(tenantId),
727
- body: {
728
- toAddr: this.signer.address,
729
- amtStr: this.utils.EtherToWei(funds)
730
- },
731
- headers: {
732
- Authorization: "Bearer ".concat(fundingToken)
848
+
849
+ case 8:
850
+ if (!groupToken) {
851
+ _context8.next = 11;
852
+ break;
733
853
  }
734
- });
735
- case 4:
736
- _context8.next = 6;
737
- return this.userProfileClient.CreateWallet();
738
- case 6:
739
- _context8.next = 8;
740
- return this.userProfileClient.ReplaceUserMetadata({
741
- metadataSubtree: "tenantContractId",
742
- metadata: tenantId
743
- });
744
- case 8:
745
- if (!groupToken) {
854
+
746
855
  _context8.next = 11;
747
- break;
748
- }
749
- _context8.next = 11;
750
- return this.authClient.MakeKMSRequest({
751
- method: "POST",
752
- path: "/ks/otp/grp/".concat(tenantId),
753
- body: {
754
- addAddr: this.signer.address
755
- },
756
- headers: {
757
- Authorization: "Bearer ".concat(groupToken)
758
- }
759
- });
760
- case 11:
761
- return _context8.abrupt("return", this.utils.FormatAddress(this.signer.address));
762
- case 12:
763
- case "end":
764
- return _context8.stop();
856
+ return this.authClient.MakeKMSRequest({
857
+ method: "POST",
858
+ path: "/ks/otp/grp/".concat(tenantId),
859
+ body: {
860
+ addAddr: this.signer.address
861
+ },
862
+ headers: {
863
+ Authorization: "Bearer ".concat(groupToken)
864
+ }
865
+ });
866
+
867
+ case 11:
868
+ return _context8.abrupt("return", this.utils.FormatAddress(this.signer.address));
869
+
870
+ case 12:
871
+ case "end":
872
+ return _context8.stop();
873
+ }
765
874
  }
766
875
  }, _callee8, this);
767
876
  }));
877
+
768
878
  function CreateAccount(_x5) {
769
879
  return _CreateAccount.apply(this, arguments);
770
880
  }
881
+
771
882
  return CreateAccount;
772
883
  }()
773
884
  /*
@@ -779,50 +890,65 @@ var ElvClient = /*#__PURE__*/function () {
779
890
  PAYLOAD 85b json-compressed
780
891
  json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
781
892
  */
893
+
782
894
  }, {
783
895
  key: "PersonalSign",
784
896
  value: function () {
785
897
  var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref11) {
786
898
  var _this = this;
899
+
787
900
  var message, addEthereumPrefix, Sign;
788
901
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
789
- while (1) switch (_context10.prev = _context10.next) {
790
- case 0:
791
- message = _ref11.message, addEthereumPrefix = _ref11.addEthereumPrefix, Sign = _ref11.Sign;
792
- if (!Sign) {
793
- Sign = /*#__PURE__*/function () {
794
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(message) {
795
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
796
- while (1) switch (_context9.prev = _context9.next) {
797
- case 0:
798
- return _context9.abrupt("return", _this.authClient.Sign(message));
799
- case 1:
800
- case "end":
801
- return _context9.stop();
802
- }
803
- }, _callee9);
804
- }));
805
- return function Sign(_x7) {
806
- return _ref12.apply(this, arguments);
807
- };
808
- }();
809
- }
810
- if (addEthereumPrefix) {
811
- message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
812
- }
813
- _context10.next = 5;
814
- return Sign(message);
815
- case 5:
816
- return _context10.abrupt("return", _context10.sent);
817
- case 6:
818
- case "end":
819
- return _context10.stop();
902
+ while (1) {
903
+ switch (_context10.prev = _context10.next) {
904
+ case 0:
905
+ message = _ref11.message, addEthereumPrefix = _ref11.addEthereumPrefix, Sign = _ref11.Sign;
906
+
907
+ if (!Sign) {
908
+ Sign = /*#__PURE__*/function () {
909
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(message) {
910
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
911
+ while (1) {
912
+ switch (_context9.prev = _context9.next) {
913
+ case 0:
914
+ return _context9.abrupt("return", _this.authClient.Sign(message));
915
+
916
+ case 1:
917
+ case "end":
918
+ return _context9.stop();
919
+ }
920
+ }
921
+ }, _callee9);
922
+ }));
923
+
924
+ return function Sign(_x7) {
925
+ return _ref12.apply(this, arguments);
926
+ };
927
+ }();
928
+ }
929
+
930
+ if (addEthereumPrefix) {
931
+ message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
932
+ }
933
+
934
+ _context10.next = 5;
935
+ return Sign(message);
936
+
937
+ case 5:
938
+ return _context10.abrupt("return", _context10.sent);
939
+
940
+ case 6:
941
+ case "end":
942
+ return _context10.stop();
943
+ }
820
944
  }
821
945
  }, _callee10);
822
946
  }));
947
+
823
948
  function PersonalSign(_x6) {
824
949
  return _PersonalSign.apply(this, arguments);
825
950
  }
951
+
826
952
  return PersonalSign;
827
953
  }()
828
954
  /**
@@ -836,68 +962,77 @@ var ElvClient = /*#__PURE__*/function () {
836
962
  * @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
837
963
  * @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)
838
964
  */
965
+
839
966
  }, {
840
967
  key: "CreateFabricToken",
841
968
  value: function () {
842
969
  var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
843
970
  var _ref13,
844
- _ref13$duration,
845
- duration,
846
- _ref13$spec,
847
- spec,
848
- address,
849
- Sign,
850
- _ref13$addEthereumPre,
851
- addEthereumPrefix,
852
- token,
853
- message,
854
- signature,
855
- compressedToken,
856
- _args11 = arguments;
971
+ _ref13$duration,
972
+ duration,
973
+ _ref13$spec,
974
+ spec,
975
+ address,
976
+ Sign,
977
+ _ref13$addEthereumPre,
978
+ addEthereumPrefix,
979
+ token,
980
+ message,
981
+ signature,
982
+ compressedToken,
983
+ _args11 = arguments;
984
+
857
985
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
858
- while (1) switch (_context11.prev = _context11.next) {
859
- case 0:
860
- _ref13 = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {}, _ref13$duration = _ref13.duration, duration = _ref13$duration === void 0 ? 24 * 60 * 60 * 1000 : _ref13$duration, _ref13$spec = _ref13.spec, spec = _ref13$spec === void 0 ? {} : _ref13$spec, address = _ref13.address, Sign = _ref13.Sign, _ref13$addEthereumPre = _ref13.addEthereumPrefix, addEthereumPrefix = _ref13$addEthereumPre === void 0 ? true : _ref13$addEthereumPre;
861
- address = address || this.CurrentAccountAddress();
862
- _context11.t0 = _objectSpread;
863
- _context11.t1 = _objectSpread({}, spec);
864
- _context11.t2 = {};
865
- _context11.t3 = "iusr".concat(Utils.AddressToHash(address));
866
- _context11.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
867
- _context11.next = 9;
868
- return this.ContentSpaceId();
869
- case 9:
870
- _context11.t5 = _context11.sent;
871
- _context11.t6 = Date.now();
872
- _context11.t7 = Date.now() + duration;
873
- _context11.t8 = {
874
- sub: _context11.t3,
875
- adr: _context11.t4,
876
- spc: _context11.t5,
877
- iat: _context11.t6,
878
- exp: _context11.t7
879
- };
880
- token = (0, _context11.t0)(_context11.t1, _context11.t2, _context11.t8);
881
- message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
882
- _context11.next = 17;
883
- return this.PersonalSign({
884
- message: message,
885
- addEthereumPrefix: addEthereumPrefix,
886
- Sign: Sign
887
- });
888
- case 17:
889
- signature = _context11.sent;
890
- compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
891
- return _context11.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
892
- case 20:
893
- case "end":
894
- return _context11.stop();
986
+ while (1) {
987
+ switch (_context11.prev = _context11.next) {
988
+ case 0:
989
+ _ref13 = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {}, _ref13$duration = _ref13.duration, duration = _ref13$duration === void 0 ? 24 * 60 * 60 * 1000 : _ref13$duration, _ref13$spec = _ref13.spec, spec = _ref13$spec === void 0 ? {} : _ref13$spec, address = _ref13.address, Sign = _ref13.Sign, _ref13$addEthereumPre = _ref13.addEthereumPrefix, addEthereumPrefix = _ref13$addEthereumPre === void 0 ? true : _ref13$addEthereumPre;
990
+ address = address || this.CurrentAccountAddress();
991
+ _context11.t0 = _objectSpread;
992
+ _context11.t1 = _objectSpread({}, spec);
993
+ _context11.t2 = {};
994
+ _context11.t3 = "iusr".concat(Utils.AddressToHash(address));
995
+ _context11.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
996
+ _context11.next = 9;
997
+ return this.ContentSpaceId();
998
+
999
+ case 9:
1000
+ _context11.t5 = _context11.sent;
1001
+ _context11.t6 = Date.now();
1002
+ _context11.t7 = Date.now() + duration;
1003
+ _context11.t8 = {
1004
+ sub: _context11.t3,
1005
+ adr: _context11.t4,
1006
+ spc: _context11.t5,
1007
+ iat: _context11.t6,
1008
+ exp: _context11.t7
1009
+ };
1010
+ token = (0, _context11.t0)(_context11.t1, _context11.t2, _context11.t8);
1011
+ message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
1012
+ _context11.next = 17;
1013
+ return this.PersonalSign({
1014
+ message: message,
1015
+ addEthereumPrefix: addEthereumPrefix,
1016
+ Sign: Sign
1017
+ });
1018
+
1019
+ case 17:
1020
+ signature = _context11.sent;
1021
+ compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
1022
+ return _context11.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
1023
+
1024
+ case 20:
1025
+ case "end":
1026
+ return _context11.stop();
1027
+ }
895
1028
  }
896
1029
  }, _callee11, this);
897
1030
  }));
1031
+
898
1032
  function CreateFabricToken() {
899
1033
  return _CreateFabricToken.apply(this, arguments);
900
1034
  }
1035
+
901
1036
  return CreateFabricToken;
902
1037
  }()
903
1038
  /**
@@ -916,105 +1051,131 @@ var ElvClient = /*#__PURE__*/function () {
916
1051
  * enabling the user of this token to download encrypted content from the specified object
917
1052
  * @param {Object=} context - Additional JSON context
918
1053
  */
1054
+
919
1055
  }, {
920
1056
  key: "CreateSignedToken",
921
1057
  value: function () {
922
1058
  var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref14) {
923
1059
  var libraryId, objectId, versionHash, policyId, subject, _ref14$grantType, grantType, _ref14$allowDecryptio, allowDecryption, duration, _ref14$context, context, token, cap, compressedToken, signature;
1060
+
924
1061
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
925
- while (1) switch (_context12.prev = _context12.next) {
926
- case 0:
927
- libraryId = _ref14.libraryId, objectId = _ref14.objectId, versionHash = _ref14.versionHash, policyId = _ref14.policyId, subject = _ref14.subject, _ref14$grantType = _ref14.grantType, grantType = _ref14$grantType === void 0 ? "read" : _ref14$grantType, _ref14$allowDecryptio = _ref14.allowDecryption, allowDecryption = _ref14$allowDecryptio === void 0 ? false : _ref14$allowDecryptio, duration = _ref14.duration, _ref14$context = _ref14.context, context = _ref14$context === void 0 ? {} : _ref14$context;
928
- if (subject) {
929
- _context12.next = 9;
930
- break;
931
- }
932
- _context12.t0 = "iusr";
933
- _context12.t1 = this.utils;
934
- _context12.next = 6;
935
- return this.CurrentAccountAddress();
936
- case 6:
937
- _context12.t2 = _context12.sent;
938
- _context12.t3 = _context12.t1.AddressToHash.call(_context12.t1, _context12.t2);
939
- subject = _context12.t0.concat.call(_context12.t0, _context12.t3);
940
- case 9:
941
- if (policyId) {
942
- context["elv:delegation-id"] = policyId;
943
- }
944
- _context12.t4 = Buffer;
945
- _context12.next = 13;
946
- return this.CurrentAccountAddress().replace(/^0x/, "");
947
- case 13:
948
- _context12.t5 = _context12.sent;
949
- _context12.t6 = _context12.t4.from.call(_context12.t4, _context12.t5, "hex").toString("base64");
950
- _context12.t7 = subject;
951
- _context12.next = 18;
952
- return this.ContentSpaceId();
953
- case 18:
954
- _context12.t8 = _context12.sent;
955
- _context12.t9 = Date.now();
956
- _context12.t10 = Date.now() + duration;
957
- _context12.t11 = grantType;
958
- _context12.t12 = context;
959
- token = {
960
- adr: _context12.t6,
961
- sub: _context12.t7,
962
- spc: _context12.t8,
963
- iat: _context12.t9,
964
- exp: _context12.t10,
965
- gra: _context12.t11,
966
- ctx: _context12.t12
967
- };
968
- if (versionHash) {
969
- objectId = this.utils.DecodeVersionHash(versionHash).objectId;
970
- }
971
- if (!objectId) {
972
- _context12.next = 31;
973
- break;
974
- }
975
- token.qid = objectId;
976
- if (libraryId) {
977
- _context12.next = 31;
978
- break;
979
- }
980
- _context12.next = 30;
981
- return this.ContentObjectLibraryId({
982
- objectId: objectId
983
- });
984
- case 30:
985
- libraryId = _context12.sent;
986
- case 31:
987
- if (libraryId) {
988
- token.lib = libraryId;
989
- }
990
- if (!allowDecryption) {
991
- _context12.next = 37;
992
- break;
993
- }
994
- _context12.next = 35;
995
- return this.authClient.ReEncryptionConk({
996
- libraryId: libraryId,
997
- objectId: objectId
998
- });
999
- case 35:
1000
- cap = _context12.sent;
1001
- token.apk = cap.public_key;
1002
- case 37:
1003
- compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
1004
- _context12.next = 40;
1005
- return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
1006
- case 40:
1007
- signature = _context12.sent;
1008
- return _context12.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
1009
- case 42:
1010
- case "end":
1011
- return _context12.stop();
1062
+ while (1) {
1063
+ switch (_context12.prev = _context12.next) {
1064
+ case 0:
1065
+ libraryId = _ref14.libraryId, objectId = _ref14.objectId, versionHash = _ref14.versionHash, policyId = _ref14.policyId, subject = _ref14.subject, _ref14$grantType = _ref14.grantType, grantType = _ref14$grantType === void 0 ? "read" : _ref14$grantType, _ref14$allowDecryptio = _ref14.allowDecryption, allowDecryption = _ref14$allowDecryptio === void 0 ? false : _ref14$allowDecryptio, duration = _ref14.duration, _ref14$context = _ref14.context, context = _ref14$context === void 0 ? {} : _ref14$context;
1066
+
1067
+ if (subject) {
1068
+ _context12.next = 9;
1069
+ break;
1070
+ }
1071
+
1072
+ _context12.t0 = "iusr";
1073
+ _context12.t1 = this.utils;
1074
+ _context12.next = 6;
1075
+ return this.CurrentAccountAddress();
1076
+
1077
+ case 6:
1078
+ _context12.t2 = _context12.sent;
1079
+ _context12.t3 = _context12.t1.AddressToHash.call(_context12.t1, _context12.t2);
1080
+ subject = _context12.t0.concat.call(_context12.t0, _context12.t3);
1081
+
1082
+ case 9:
1083
+ if (policyId) {
1084
+ context["elv:delegation-id"] = policyId;
1085
+ }
1086
+
1087
+ _context12.t4 = Buffer;
1088
+ _context12.next = 13;
1089
+ return this.CurrentAccountAddress().replace(/^0x/, "");
1090
+
1091
+ case 13:
1092
+ _context12.t5 = _context12.sent;
1093
+ _context12.t6 = _context12.t4.from.call(_context12.t4, _context12.t5, "hex").toString("base64");
1094
+ _context12.t7 = subject;
1095
+ _context12.next = 18;
1096
+ return this.ContentSpaceId();
1097
+
1098
+ case 18:
1099
+ _context12.t8 = _context12.sent;
1100
+ _context12.t9 = Date.now();
1101
+ _context12.t10 = Date.now() + duration;
1102
+ _context12.t11 = grantType;
1103
+ _context12.t12 = context;
1104
+ token = {
1105
+ adr: _context12.t6,
1106
+ sub: _context12.t7,
1107
+ spc: _context12.t8,
1108
+ iat: _context12.t9,
1109
+ exp: _context12.t10,
1110
+ gra: _context12.t11,
1111
+ ctx: _context12.t12
1112
+ };
1113
+
1114
+ if (versionHash) {
1115
+ objectId = this.utils.DecodeVersionHash(versionHash).objectId;
1116
+ }
1117
+
1118
+ if (!objectId) {
1119
+ _context12.next = 31;
1120
+ break;
1121
+ }
1122
+
1123
+ token.qid = objectId;
1124
+
1125
+ if (libraryId) {
1126
+ _context12.next = 31;
1127
+ break;
1128
+ }
1129
+
1130
+ _context12.next = 30;
1131
+ return this.ContentObjectLibraryId({
1132
+ objectId: objectId
1133
+ });
1134
+
1135
+ case 30:
1136
+ libraryId = _context12.sent;
1137
+
1138
+ case 31:
1139
+ if (libraryId) {
1140
+ token.lib = libraryId;
1141
+ }
1142
+
1143
+ if (!allowDecryption) {
1144
+ _context12.next = 37;
1145
+ break;
1146
+ }
1147
+
1148
+ _context12.next = 35;
1149
+ return this.authClient.ReEncryptionConk({
1150
+ libraryId: libraryId,
1151
+ objectId: objectId
1152
+ });
1153
+
1154
+ case 35:
1155
+ cap = _context12.sent;
1156
+ token.apk = cap.public_key;
1157
+
1158
+ case 37:
1159
+ compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
1160
+ _context12.next = 40;
1161
+ return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
1162
+
1163
+ case 40:
1164
+ signature = _context12.sent;
1165
+ return _context12.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
1166
+
1167
+ case 42:
1168
+ case "end":
1169
+ return _context12.stop();
1170
+ }
1012
1171
  }
1013
1172
  }, _callee12, this);
1014
1173
  }));
1174
+
1015
1175
  function CreateSignedToken(_x8) {
1016
1176
  return _CreateSignedToken.apply(this, arguments);
1017
1177
  }
1178
+
1018
1179
  return CreateSignedToken;
1019
1180
  }()
1020
1181
  /**
@@ -1023,12 +1184,12 @@ var ElvClient = /*#__PURE__*/function () {
1023
1184
  * @methodGroup Signers
1024
1185
  * @returns {string} - The address of the current signer
1025
1186
  */
1187
+
1026
1188
  }, {
1027
1189
  key: "CurrentAccountAddress",
1028
1190
  value: function CurrentAccountAddress() {
1029
1191
  return this.signer ? this.utils.FormatAddress(this.signer.address) : "";
1030
1192
  }
1031
-
1032
1193
  /**
1033
1194
  * Set the OAuth token for use in state channel calls
1034
1195
  *
@@ -1036,32 +1197,38 @@ var ElvClient = /*#__PURE__*/function () {
1036
1197
  * @namedParams
1037
1198
  * @param {string} token - The OAuth ID token
1038
1199
  */
1200
+
1039
1201
  }, {
1040
1202
  key: "SetOauthToken",
1041
1203
  value: function () {
1042
1204
  var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref15) {
1043
1205
  var token, wallet, signer;
1044
1206
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
1045
- while (1) switch (_context13.prev = _context13.next) {
1046
- case 0:
1047
- token = _ref15.token;
1048
- this.oauthToken = token;
1049
- wallet = this.GenerateWallet();
1050
- signer = wallet.AddAccountFromMnemonic({
1051
- mnemonic: wallet.GenerateMnemonic()
1052
- });
1053
- this.SetSigner({
1054
- signer: signer
1055
- });
1056
- case 5:
1057
- case "end":
1058
- return _context13.stop();
1207
+ while (1) {
1208
+ switch (_context13.prev = _context13.next) {
1209
+ case 0:
1210
+ token = _ref15.token;
1211
+ this.oauthToken = token;
1212
+ wallet = this.GenerateWallet();
1213
+ signer = wallet.AddAccountFromMnemonic({
1214
+ mnemonic: wallet.GenerateMnemonic()
1215
+ });
1216
+ this.SetSigner({
1217
+ signer: signer
1218
+ });
1219
+
1220
+ case 5:
1221
+ case "end":
1222
+ return _context13.stop();
1223
+ }
1059
1224
  }
1060
1225
  }, _callee13, this);
1061
1226
  }));
1227
+
1062
1228
  function SetOauthToken(_x9) {
1063
1229
  return _SetOauthToken.apply(this, arguments);
1064
1230
  }
1231
+
1065
1232
  return SetOauthToken;
1066
1233
  }()
1067
1234
  /**
@@ -1074,101 +1241,122 @@ var ElvClient = /*#__PURE__*/function () {
1074
1241
  * @namedParams
1075
1242
  * @param {string} token - The OAuth ID
1076
1243
  */
1244
+
1077
1245
  }, {
1078
1246
  key: "SetSignerFromOauthToken",
1079
1247
  value: function () {
1080
1248
  var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref16) {
1081
1249
  var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey;
1250
+
1082
1251
  return _regeneratorRuntime.wrap(function _callee14$(_context14) {
1083
- while (1) switch (_context14.prev = _context14.next) {
1084
- case 0:
1085
- token = _ref16.token;
1086
- if (this.trustAuthorityId) {
1087
- _context14.next = 3;
1088
- break;
1089
- }
1090
- throw Error("Unable to authorize with OAuth token: No trust authority ID set");
1091
- case 3:
1092
- wallet = this.GenerateWallet();
1093
- _context14.prev = 4;
1094
- if (this.kmsURIs) {
1095
- _context14.next = 17;
1096
- break;
1097
- }
1098
- _context14.next = 8;
1099
- return ElvClient.FromConfigurationUrl({
1100
- configUrl: this.configUrl
1101
- });
1102
- case 8:
1103
- client = _context14.sent;
1104
- client.SetSigner({
1105
- signer: wallet.AddAccountFromMnemonic({
1106
- mnemonic: wallet.GenerateMnemonic()
1107
- })
1108
- });
1109
- _context14.next = 12;
1110
- return client.authClient.KMSInfo({
1111
- kmsId: this.trustAuthorityId
1112
- });
1113
- case 12:
1114
- _yield$client$authCli = _context14.sent;
1115
- urls = _yield$client$authCli.urls;
1116
- if (!(!urls || urls.length === 0)) {
1117
- _context14.next = 16;
1252
+ while (1) {
1253
+ switch (_context14.prev = _context14.next) {
1254
+ case 0:
1255
+ token = _ref16.token;
1256
+
1257
+ if (this.trustAuthorityId) {
1258
+ _context14.next = 3;
1259
+ break;
1260
+ }
1261
+
1262
+ throw Error("Unable to authorize with OAuth token: No trust authority ID set");
1263
+
1264
+ case 3:
1265
+ wallet = this.GenerateWallet();
1266
+ _context14.prev = 4;
1267
+
1268
+ if (this.kmsURIs) {
1269
+ _context14.next = 17;
1270
+ break;
1271
+ }
1272
+
1273
+ _context14.next = 8;
1274
+ return ElvClient.FromConfigurationUrl({
1275
+ configUrl: this.configUrl
1276
+ });
1277
+
1278
+ case 8:
1279
+ client = _context14.sent;
1280
+ client.SetSigner({
1281
+ signer: wallet.AddAccountFromMnemonic({
1282
+ mnemonic: wallet.GenerateMnemonic()
1283
+ })
1284
+ });
1285
+ _context14.next = 12;
1286
+ return client.authClient.KMSInfo({
1287
+ kmsId: this.trustAuthorityId
1288
+ });
1289
+
1290
+ case 12:
1291
+ _yield$client$authCli = _context14.sent;
1292
+ urls = _yield$client$authCli.urls;
1293
+
1294
+ if (!(!urls || urls.length === 0)) {
1295
+ _context14.next = 16;
1296
+ break;
1297
+ }
1298
+
1299
+ throw Error("Unable to authorize with OAuth token: No KMS URLs set");
1300
+
1301
+ case 16:
1302
+ this.kmsURIs = urls;
1303
+
1304
+ case 17:
1305
+ this.oauthToken = token;
1306
+ path = "/ks/jwt/wlt";
1307
+ httpClient = new HttpClient({
1308
+ uris: this.kmsURIs,
1309
+ debug: this.debug
1310
+ });
1311
+ _context14.next = 22;
1312
+ return this.utils.ResponseToJson(httpClient.Request({
1313
+ headers: {
1314
+ Authorization: "Bearer ".concat(token)
1315
+ },
1316
+ method: "PUT",
1317
+ path: path,
1318
+ forceFailover: true
1319
+ }));
1320
+
1321
+ case 22:
1322
+ response = _context14.sent;
1323
+ privateKey = response["UserSKHex"];
1324
+ this.SetSigner({
1325
+ signer: wallet.AddAccount({
1326
+ privateKey: privateKey
1327
+ })
1328
+ }); // Ensure wallet is initialized
1329
+
1330
+ _context14.next = 27;
1331
+ return this.userProfileClient.WalletAddress();
1332
+
1333
+ case 27:
1334
+ _context14.next = 36;
1118
1335
  break;
1119
- }
1120
- throw Error("Unable to authorize with OAuth token: No KMS URLs set");
1121
- case 16:
1122
- this.kmsURIs = urls;
1123
- case 17:
1124
- this.oauthToken = token;
1125
- path = "/ks/jwt/wlt";
1126
- httpClient = new HttpClient({
1127
- uris: this.kmsURIs,
1128
- debug: this.debug
1129
- });
1130
- _context14.next = 22;
1131
- return this.utils.ResponseToJson(httpClient.Request({
1132
- headers: {
1133
- Authorization: "Bearer ".concat(token)
1134
- },
1135
- method: "PUT",
1136
- path: path,
1137
- forceFailover: true
1138
- }));
1139
- case 22:
1140
- response = _context14.sent;
1141
- privateKey = response["UserSKHex"];
1142
- this.SetSigner({
1143
- signer: wallet.AddAccount({
1144
- privateKey: privateKey
1145
- })
1146
- });
1147
-
1148
- // Ensure wallet is initialized
1149
- _context14.next = 27;
1150
- return this.userProfileClient.WalletAddress();
1151
- case 27:
1152
- _context14.next = 36;
1153
- break;
1154
- case 29:
1155
- _context14.prev = 29;
1156
- _context14.t0 = _context14["catch"](4);
1157
- this.Log("Failed to set signer from OAuth token:", true);
1158
- this.Log(_context14.t0, true);
1159
- _context14.next = 35;
1160
- return this.ClearSigner();
1161
- case 35:
1162
- throw _context14.t0;
1163
- case 36:
1164
- case "end":
1165
- return _context14.stop();
1336
+
1337
+ case 29:
1338
+ _context14.prev = 29;
1339
+ _context14.t0 = _context14["catch"](4);
1340
+ this.Log("Failed to set signer from OAuth token:", true);
1341
+ this.Log(_context14.t0, true);
1342
+ _context14.next = 35;
1343
+ return this.ClearSigner();
1344
+
1345
+ case 35:
1346
+ throw _context14.t0;
1347
+
1348
+ case 36:
1349
+ case "end":
1350
+ return _context14.stop();
1351
+ }
1166
1352
  }
1167
1353
  }, _callee14, this, [[4, 29]]);
1168
1354
  }));
1355
+
1169
1356
  function SetSignerFromOauthToken(_x10) {
1170
1357
  return _SetSignerFromOauthToken.apply(this, arguments);
1171
1358
  }
1359
+
1172
1360
  return SetSignerFromOauthToken;
1173
1361
  }()
1174
1362
  /**
@@ -1178,28 +1366,30 @@ var ElvClient = /*#__PURE__*/function () {
1178
1366
  * @namedParams
1179
1367
  * @param {string=} token - The static token to use. If not provided, the default static token will be set.
1180
1368
  */
1369
+
1181
1370
  }, {
1182
1371
  key: "SetStaticToken",
1183
1372
  value: function SetStaticToken() {
1184
1373
  var _ref17 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1185
- token = _ref17.token;
1374
+ token = _ref17.token;
1375
+
1186
1376
  if (!token) {
1187
1377
  token = this.utils.B64(JSON.stringify({
1188
1378
  qspace_id: this.contentSpaceId
1189
1379
  }));
1190
1380
  }
1381
+
1191
1382
  this.staticToken = token;
1192
1383
  }
1193
-
1194
1384
  /**
1195
1385
  * Clear the set static token for the client
1196
1386
  */
1387
+
1197
1388
  }, {
1198
1389
  key: "ClearStaticToken",
1199
1390
  value: function ClearStaticToken() {
1200
1391
  this.staticToken = undefined;
1201
1392
  }
1202
-
1203
1393
  /**
1204
1394
  * Authorize the client against the specified policy.
1205
1395
  *
@@ -1209,35 +1399,43 @@ var ElvClient = /*#__PURE__*/function () {
1209
1399
  * @namedParams
1210
1400
  * @param {string} objectId - The ID of the policy object
1211
1401
  */
1402
+
1212
1403
  }, {
1213
1404
  key: "SetPolicyAuthorization",
1214
1405
  value: function () {
1215
1406
  var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref18) {
1216
1407
  var objectId;
1217
1408
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1218
- while (1) switch (_context15.prev = _context15.next) {
1219
- case 0:
1220
- objectId = _ref18.objectId;
1221
- _context15.t0 = this;
1222
- _context15.next = 4;
1223
- return this.GenerateStateChannelToken({
1224
- objectId: objectId
1225
- });
1226
- case 4:
1227
- _context15.t1 = _context15.sent;
1228
- _context15.t2 = {
1229
- token: _context15.t1
1230
- };
1231
- _context15.t0.SetStaticToken.call(_context15.t0, _context15.t2);
1232
- case 7:
1233
- case "end":
1234
- return _context15.stop();
1409
+ while (1) {
1410
+ switch (_context15.prev = _context15.next) {
1411
+ case 0:
1412
+ objectId = _ref18.objectId;
1413
+ _context15.t0 = this;
1414
+ _context15.next = 4;
1415
+ return this.GenerateStateChannelToken({
1416
+ objectId: objectId
1417
+ });
1418
+
1419
+ case 4:
1420
+ _context15.t1 = _context15.sent;
1421
+ _context15.t2 = {
1422
+ token: _context15.t1
1423
+ };
1424
+
1425
+ _context15.t0.SetStaticToken.call(_context15.t0, _context15.t2);
1426
+
1427
+ case 7:
1428
+ case "end":
1429
+ return _context15.stop();
1430
+ }
1235
1431
  }
1236
1432
  }, _callee15, this);
1237
1433
  }));
1434
+
1238
1435
  function SetPolicyAuthorization(_x11) {
1239
1436
  return _SetPolicyAuthorization.apply(this, arguments);
1240
1437
  }
1438
+
1241
1439
  return SetPolicyAuthorization;
1242
1440
  }()
1243
1441
  /**
@@ -1246,28 +1444,35 @@ var ElvClient = /*#__PURE__*/function () {
1246
1444
  * @param {string} string - The string to sign
1247
1445
  * @return {Promise<string>} - The signed string
1248
1446
  */
1447
+
1249
1448
  }, {
1250
1449
  key: "Sign",
1251
1450
  value: function () {
1252
1451
  var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(string) {
1253
1452
  var signature;
1254
1453
  return _regeneratorRuntime.wrap(function _callee16$(_context16) {
1255
- while (1) switch (_context16.prev = _context16.next) {
1256
- case 0:
1257
- _context16.next = 2;
1258
- return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
1259
- case 2:
1260
- signature = _context16.sent;
1261
- return _context16.abrupt("return", this.utils.FormatSignature(signature));
1262
- case 4:
1263
- case "end":
1264
- return _context16.stop();
1454
+ while (1) {
1455
+ switch (_context16.prev = _context16.next) {
1456
+ case 0:
1457
+ _context16.next = 2;
1458
+ return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
1459
+
1460
+ case 2:
1461
+ signature = _context16.sent;
1462
+ return _context16.abrupt("return", this.utils.FormatSignature(signature));
1463
+
1464
+ case 4:
1465
+ case "end":
1466
+ return _context16.stop();
1467
+ }
1265
1468
  }
1266
1469
  }, _callee16, this);
1267
1470
  }));
1471
+
1268
1472
  function Sign(_x12) {
1269
1473
  return _Sign.apply(this, arguments);
1270
1474
  }
1475
+
1271
1476
  return Sign;
1272
1477
  }()
1273
1478
  /**
@@ -1279,35 +1484,45 @@ var ElvClient = /*#__PURE__*/function () {
1279
1484
  *
1280
1485
  * @return {Promise<string>} - The encrypted message
1281
1486
  */
1487
+
1282
1488
  }, {
1283
1489
  key: "EncryptECIES",
1284
1490
  value: function () {
1285
1491
  var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref19) {
1286
1492
  var message, publicKey;
1287
1493
  return _regeneratorRuntime.wrap(function _callee17$(_context17) {
1288
- while (1) switch (_context17.prev = _context17.next) {
1289
- case 0:
1290
- message = _ref19.message, publicKey = _ref19.publicKey;
1291
- if (this.signer) {
1292
- _context17.next = 3;
1293
- break;
1294
- }
1295
- throw "Signer not set";
1296
- case 3:
1297
- ValidatePresence("message", message);
1298
- _context17.next = 6;
1299
- return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
1300
- case 6:
1301
- return _context17.abrupt("return", _context17.sent);
1302
- case 7:
1303
- case "end":
1304
- return _context17.stop();
1494
+ while (1) {
1495
+ switch (_context17.prev = _context17.next) {
1496
+ case 0:
1497
+ message = _ref19.message, publicKey = _ref19.publicKey;
1498
+
1499
+ if (this.signer) {
1500
+ _context17.next = 3;
1501
+ break;
1502
+ }
1503
+
1504
+ throw "Signer not set";
1505
+
1506
+ case 3:
1507
+ ValidatePresence("message", message);
1508
+ _context17.next = 6;
1509
+ return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
1510
+
1511
+ case 6:
1512
+ return _context17.abrupt("return", _context17.sent);
1513
+
1514
+ case 7:
1515
+ case "end":
1516
+ return _context17.stop();
1517
+ }
1305
1518
  }
1306
1519
  }, _callee17, this);
1307
1520
  }));
1521
+
1308
1522
  function EncryptECIES(_x13) {
1309
1523
  return _EncryptECIES.apply(this, arguments);
1310
1524
  }
1525
+
1311
1526
  return EncryptECIES;
1312
1527
  }()
1313
1528
  /**
@@ -1318,35 +1533,45 @@ var ElvClient = /*#__PURE__*/function () {
1318
1533
  *
1319
1534
  * @return {Promise<string | Object>} - The decrypted string or object
1320
1535
  */
1536
+
1321
1537
  }, {
1322
1538
  key: "DecryptECIES",
1323
1539
  value: function () {
1324
1540
  var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref20) {
1325
1541
  var message;
1326
1542
  return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1327
- while (1) switch (_context18.prev = _context18.next) {
1328
- case 0:
1329
- message = _ref20.message;
1330
- if (this.signer) {
1331
- _context18.next = 3;
1332
- break;
1333
- }
1334
- throw "Signer not set";
1335
- case 3:
1336
- ValidatePresence("message", message);
1337
- _context18.next = 6;
1338
- return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
1339
- case 6:
1340
- return _context18.abrupt("return", _context18.sent);
1341
- case 7:
1342
- case "end":
1343
- return _context18.stop();
1543
+ while (1) {
1544
+ switch (_context18.prev = _context18.next) {
1545
+ case 0:
1546
+ message = _ref20.message;
1547
+
1548
+ if (this.signer) {
1549
+ _context18.next = 3;
1550
+ break;
1551
+ }
1552
+
1553
+ throw "Signer not set";
1554
+
1555
+ case 3:
1556
+ ValidatePresence("message", message);
1557
+ _context18.next = 6;
1558
+ return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
1559
+
1560
+ case 6:
1561
+ return _context18.abrupt("return", _context18.sent);
1562
+
1563
+ case 7:
1564
+ case "end":
1565
+ return _context18.stop();
1566
+ }
1344
1567
  }
1345
1568
  }, _callee18, this);
1346
1569
  }));
1570
+
1347
1571
  function DecryptECIES(_x14) {
1348
1572
  return _DecryptECIES.apply(this, arguments);
1349
1573
  }
1574
+
1350
1575
  return DecryptECIES;
1351
1576
  }()
1352
1577
  /**
@@ -1360,129 +1585,157 @@ var ElvClient = /*#__PURE__*/function () {
1360
1585
  *
1361
1586
  * @return {Promise<*>} - Response in the specified format
1362
1587
  */
1588
+
1363
1589
  }, {
1364
1590
  key: "Request",
1365
1591
  value: function () {
1366
1592
  var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref21) {
1367
1593
  var url, _ref21$format, format, _ref21$method, method, _ref21$headers, headers, body;
1594
+
1368
1595
  return _regeneratorRuntime.wrap(function _callee19$(_context19) {
1369
- while (1) switch (_context19.prev = _context19.next) {
1370
- case 0:
1371
- url = _ref21.url, _ref21$format = _ref21.format, format = _ref21$format === void 0 ? "json" : _ref21$format, _ref21$method = _ref21.method, method = _ref21$method === void 0 ? "GET" : _ref21$method, _ref21$headers = _ref21.headers, headers = _ref21$headers === void 0 ? {} : _ref21$headers, body = _ref21.body;
1372
- return _context19.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
1373
- method: method,
1374
- headers: headers,
1375
- body: body
1376
- })));
1377
- case 2:
1378
- case "end":
1379
- return _context19.stop();
1596
+ while (1) {
1597
+ switch (_context19.prev = _context19.next) {
1598
+ case 0:
1599
+ url = _ref21.url, _ref21$format = _ref21.format, format = _ref21$format === void 0 ? "json" : _ref21$format, _ref21$method = _ref21.method, method = _ref21$method === void 0 ? "GET" : _ref21$method, _ref21$headers = _ref21.headers, headers = _ref21$headers === void 0 ? {} : _ref21$headers, body = _ref21.body;
1600
+ return _context19.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
1601
+ method: method,
1602
+ headers: headers,
1603
+ body: body
1604
+ })));
1605
+
1606
+ case 2:
1607
+ case "end":
1608
+ return _context19.stop();
1609
+ }
1380
1610
  }
1381
1611
  }, _callee19, this);
1382
1612
  }));
1613
+
1383
1614
  function Request(_x15) {
1384
1615
  return _Request.apply(this, arguments);
1385
1616
  }
1617
+
1386
1618
  return Request;
1387
1619
  }()
1388
1620
  /* FrameClient related */
1389
1621
  // Whitelist of methods allowed to be called using the frame API
1622
+
1390
1623
  }, {
1391
1624
  key: "FrameAllowedMethods",
1392
1625
  value: function FrameAllowedMethods() {
1393
1626
  var _this2 = this;
1627
+
1394
1628
  var forbiddenMethods = ["constructor", "AccessGroupMembershipMethod", "CallFromFrameMessage", "ClearSigner", "CreateAccount", "EnableMethodLogging", "FormatBlockNumbers", "FrameAllowedMethods", "FromConfigurationUrl", "GenerateWallet", "InitializeClients", "Log", "PersonalSign", "SetRemoteSigner", "SetSigner", "SetSignerFromWeb3Provider", "Sign", "ToggleLogging"];
1395
1629
  return Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(function (method) {
1396
1630
  return typeof _this2[method] === "function" && !forbiddenMethods.includes(method);
1397
1631
  });
1398
- }
1632
+ } // Call a method specified in a message from a frame
1399
1633
 
1400
- // Call a method specified in a message from a frame
1401
1634
  }, {
1402
1635
  key: "CallFromFrameMessage",
1403
1636
  value: function () {
1404
1637
  var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(message, Respond) {
1405
1638
  var _this3 = this;
1639
+
1406
1640
  var callback, method, methodResults, responseError;
1407
1641
  return _regeneratorRuntime.wrap(function _callee20$(_context20) {
1408
- while (1) switch (_context20.prev = _context20.next) {
1409
- case 0:
1410
- if (!(message.type !== "ElvFrameRequest")) {
1411
- _context20.next = 2;
1412
- break;
1413
- }
1414
- return _context20.abrupt("return");
1415
- case 2:
1416
- if (message.callbackId) {
1417
- callback = function callback(result) {
1418
- Respond(_this3.utils.MakeClonable({
1419
- type: "ElvFrameResponse",
1420
- requestId: message.callbackId,
1421
- response: result
1422
- }));
1423
- };
1424
- message.args.callback = callback;
1425
- }
1426
- _context20.prev = 3;
1427
- method = message.calledMethod;
1428
- if (!(message.module === "userProfileClient")) {
1429
- _context20.next = 13;
1430
- break;
1431
- }
1432
- if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
1433
- _context20.next = 8;
1642
+ while (1) {
1643
+ switch (_context20.prev = _context20.next) {
1644
+ case 0:
1645
+ if (!(message.type !== "ElvFrameRequest")) {
1646
+ _context20.next = 2;
1647
+ break;
1648
+ }
1649
+
1650
+ return _context20.abrupt("return");
1651
+
1652
+ case 2:
1653
+ if (message.callbackId) {
1654
+ callback = function callback(result) {
1655
+ Respond(_this3.utils.MakeClonable({
1656
+ type: "ElvFrameResponse",
1657
+ requestId: message.callbackId,
1658
+ response: result
1659
+ }));
1660
+ };
1661
+
1662
+ message.args.callback = callback;
1663
+ }
1664
+
1665
+ _context20.prev = 3;
1666
+ method = message.calledMethod;
1667
+
1668
+ if (!(message.module === "userProfileClient")) {
1669
+ _context20.next = 13;
1670
+ break;
1671
+ }
1672
+
1673
+ if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
1674
+ _context20.next = 8;
1675
+ break;
1676
+ }
1677
+
1678
+ throw Error("Invalid user profile method: " + method);
1679
+
1680
+ case 8:
1681
+ _context20.next = 10;
1682
+ return this.userProfileClient[method](message.args);
1683
+
1684
+ case 10:
1685
+ methodResults = _context20.sent;
1686
+ _context20.next = 18;
1434
1687
  break;
1435
- }
1436
- throw Error("Invalid user profile method: " + method);
1437
- case 8:
1438
- _context20.next = 10;
1439
- return this.userProfileClient[method](message.args);
1440
- case 10:
1441
- methodResults = _context20.sent;
1442
- _context20.next = 18;
1443
- break;
1444
- case 13:
1445
- if (this.FrameAllowedMethods().includes(method)) {
1446
- _context20.next = 15;
1688
+
1689
+ case 13:
1690
+ if (this.FrameAllowedMethods().includes(method)) {
1691
+ _context20.next = 15;
1692
+ break;
1693
+ }
1694
+
1695
+ throw Error("Invalid method: " + method);
1696
+
1697
+ case 15:
1698
+ _context20.next = 17;
1699
+ return this[method](message.args);
1700
+
1701
+ case 17:
1702
+ methodResults = _context20.sent;
1703
+
1704
+ case 18:
1705
+ Respond(this.utils.MakeClonable({
1706
+ type: "ElvFrameResponse",
1707
+ requestId: message.requestId,
1708
+ response: methodResults
1709
+ }));
1710
+ _context20.next = 27;
1447
1711
  break;
1448
- }
1449
- throw Error("Invalid method: " + method);
1450
- case 15:
1451
- _context20.next = 17;
1452
- return this[method](message.args);
1453
- case 17:
1454
- methodResults = _context20.sent;
1455
- case 18:
1456
- Respond(this.utils.MakeClonable({
1457
- type: "ElvFrameResponse",
1458
- requestId: message.requestId,
1459
- response: methodResults
1460
- }));
1461
- _context20.next = 27;
1462
- break;
1463
- case 21:
1464
- _context20.prev = 21;
1465
- _context20.t0 = _context20["catch"](3);
1466
- // eslint-disable-next-line no-console
1467
- this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context20.t0) === "object" ? JSON.stringify(_context20.t0, null, 2) : _context20.t0), true);
1468
-
1469
- // eslint-disable-next-line no-console
1470
- console.error(_context20.t0);
1471
- responseError = _context20.t0 instanceof Error ? _context20.t0.message : _context20.t0;
1472
- Respond(this.utils.MakeClonable({
1473
- type: "ElvFrameResponse",
1474
- requestId: message.requestId,
1475
- error: responseError
1476
- }));
1477
- case 27:
1478
- case "end":
1479
- return _context20.stop();
1712
+
1713
+ case 21:
1714
+ _context20.prev = 21;
1715
+ _context20.t0 = _context20["catch"](3);
1716
+ // eslint-disable-next-line no-console
1717
+ this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context20.t0) === "object" ? JSON.stringify(_context20.t0, null, 2) : _context20.t0), true); // eslint-disable-next-line no-console
1718
+
1719
+ console.error(_context20.t0);
1720
+ responseError = _context20.t0 instanceof Error ? _context20.t0.message : _context20.t0;
1721
+ Respond(this.utils.MakeClonable({
1722
+ type: "ElvFrameResponse",
1723
+ requestId: message.requestId,
1724
+ error: responseError
1725
+ }));
1726
+
1727
+ case 27:
1728
+ case "end":
1729
+ return _context20.stop();
1730
+ }
1480
1731
  }
1481
1732
  }, _callee20, this, [[3, 21]]);
1482
1733
  }));
1734
+
1483
1735
  function CallFromFrameMessage(_x16, _x17) {
1484
1736
  return _CallFromFrameMessage.apply(this, arguments);
1485
1737
  }
1738
+
1486
1739
  return CallFromFrameMessage;
1487
1740
  }()
1488
1741
  }], [{
@@ -1490,67 +1743,85 @@ var ElvClient = /*#__PURE__*/function () {
1490
1743
  value: function () {
1491
1744
  var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref22) {
1492
1745
  var configUrl, _ref22$kmsUrls, kmsUrls, region, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, searchURIs, fabricVersion;
1746
+
1493
1747
  return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1494
- while (1) switch (_context21.prev = _context21.next) {
1495
- case 0:
1496
- configUrl = _ref22.configUrl, _ref22$kmsUrls = _ref22.kmsUrls, kmsUrls = _ref22$kmsUrls === void 0 ? [] : _ref22$kmsUrls, region = _ref22.region;
1497
- _context21.prev = 1;
1498
- uri = new URI(configUrl);
1499
- uri.pathname("/config");
1500
- if (region) {
1501
- uri.addSearch("elvgeo", region);
1502
- }
1503
- _context21.next = 7;
1504
- return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
1505
- case 7:
1506
- fabricInfo = _context21.sent;
1507
- // If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
1508
- filterHTTPS = function filterHTTPS(uri) {
1509
- return uri.toLowerCase().startsWith("https");
1510
- };
1511
- fabricURIs = fabricInfo.network.services.fabric_api;
1512
- if (fabricURIs.find(filterHTTPS)) {
1513
- fabricURIs = fabricURIs.filter(filterHTTPS);
1514
- }
1515
- ethereumURIs = fabricInfo.network.services.ethereum_api;
1516
- if (ethereumURIs.find(filterHTTPS)) {
1517
- ethereumURIs = ethereumURIs.filter(filterHTTPS);
1518
- }
1519
- authServiceURIs = fabricInfo.network.services.authority_service || [];
1520
- if (authServiceURIs.find(filterHTTPS)) {
1521
- authServiceURIs = authServiceURIs.filter(filterHTTPS);
1522
- }
1523
- searchURIs = fabricInfo.network.services.search || [];
1524
- fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
1525
- return _context21.abrupt("return", {
1526
- nodeId: fabricInfo.node_id,
1527
- contentSpaceId: fabricInfo.qspace.id,
1528
- networkId: (fabricInfo.qspace.ethereum || {}).network_id,
1529
- networkName: ((fabricInfo.qspace || {}).names || [])[0],
1530
- fabricURIs: fabricURIs,
1531
- ethereumURIs: ethereumURIs,
1532
- authServiceURIs: authServiceURIs,
1533
- kmsURIs: kmsUrls,
1534
- searchURIs: searchURIs,
1535
- fabricVersion: fabricVersion
1536
- });
1537
- case 20:
1538
- _context21.prev = 20;
1539
- _context21.t0 = _context21["catch"](1);
1540
- // eslint-disable-next-line no-console
1541
- console.error("Error retrieving fabric configuration:");
1542
- // eslint-disable-next-line no-console
1543
- console.error(_context21.t0);
1544
- throw _context21.t0;
1545
- case 25:
1546
- case "end":
1547
- return _context21.stop();
1748
+ while (1) {
1749
+ switch (_context21.prev = _context21.next) {
1750
+ case 0:
1751
+ configUrl = _ref22.configUrl, _ref22$kmsUrls = _ref22.kmsUrls, kmsUrls = _ref22$kmsUrls === void 0 ? [] : _ref22$kmsUrls, region = _ref22.region;
1752
+ _context21.prev = 1;
1753
+ uri = new URI(configUrl);
1754
+ uri.pathname("/config");
1755
+
1756
+ if (region) {
1757
+ uri.addSearch("elvgeo", region);
1758
+ }
1759
+
1760
+ _context21.next = 7;
1761
+ return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
1762
+
1763
+ case 7:
1764
+ fabricInfo = _context21.sent;
1765
+
1766
+ // If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
1767
+ filterHTTPS = function filterHTTPS(uri) {
1768
+ return uri.toLowerCase().startsWith("https");
1769
+ };
1770
+
1771
+ fabricURIs = fabricInfo.network.services.fabric_api;
1772
+
1773
+ if (fabricURIs.find(filterHTTPS)) {
1774
+ fabricURIs = fabricURIs.filter(filterHTTPS);
1775
+ }
1776
+
1777
+ ethereumURIs = fabricInfo.network.services.ethereum_api;
1778
+
1779
+ if (ethereumURIs.find(filterHTTPS)) {
1780
+ ethereumURIs = ethereumURIs.filter(filterHTTPS);
1781
+ }
1782
+
1783
+ authServiceURIs = fabricInfo.network.services.authority_service || [];
1784
+
1785
+ if (authServiceURIs.find(filterHTTPS)) {
1786
+ authServiceURIs = authServiceURIs.filter(filterHTTPS);
1787
+ }
1788
+
1789
+ searchURIs = fabricInfo.network.services.search || [];
1790
+ fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
1791
+ return _context21.abrupt("return", {
1792
+ nodeId: fabricInfo.node_id,
1793
+ contentSpaceId: fabricInfo.qspace.id,
1794
+ networkId: (fabricInfo.qspace.ethereum || {}).network_id,
1795
+ networkName: ((fabricInfo.qspace || {}).names || [])[0],
1796
+ fabricURIs: fabricURIs,
1797
+ ethereumURIs: ethereumURIs,
1798
+ authServiceURIs: authServiceURIs,
1799
+ kmsURIs: kmsUrls,
1800
+ searchURIs: searchURIs,
1801
+ fabricVersion: fabricVersion
1802
+ });
1803
+
1804
+ case 20:
1805
+ _context21.prev = 20;
1806
+ _context21.t0 = _context21["catch"](1);
1807
+ // eslint-disable-next-line no-console
1808
+ console.error("Error retrieving fabric configuration:"); // eslint-disable-next-line no-console
1809
+
1810
+ console.error(_context21.t0);
1811
+ throw _context21.t0;
1812
+
1813
+ case 25:
1814
+ case "end":
1815
+ return _context21.stop();
1816
+ }
1548
1817
  }
1549
1818
  }, _callee21, null, [[1, 20]]);
1550
1819
  }));
1820
+
1551
1821
  function Configuration(_x18) {
1552
1822
  return _Configuration.apply(this, arguments);
1553
1823
  }
1824
+
1554
1825
  return Configuration;
1555
1826
  }()
1556
1827
  /**
@@ -1568,44 +1839,55 @@ var ElvClient = /*#__PURE__*/function () {
1568
1839
  *
1569
1840
  * @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
1570
1841
  */
1842
+
1571
1843
  }, {
1572
1844
  key: "FromNetworkName",
1573
1845
  value: function () {
1574
1846
  var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref23) {
1575
1847
  var networkName, region, trustAuthorityId, staticToken, _ref23$ethereumContra, ethereumContractTimeout, _ref23$noCache, noCache, _ref23$noAuth, noAuth, assumeV3, configUrl;
1848
+
1576
1849
  return _regeneratorRuntime.wrap(function _callee22$(_context22) {
1577
- while (1) switch (_context22.prev = _context22.next) {
1578
- case 0:
1579
- networkName = _ref23.networkName, region = _ref23.region, trustAuthorityId = _ref23.trustAuthorityId, staticToken = _ref23.staticToken, _ref23$ethereumContra = _ref23.ethereumContractTimeout, ethereumContractTimeout = _ref23$ethereumContra === void 0 ? 10 : _ref23$ethereumContra, _ref23$noCache = _ref23.noCache, noCache = _ref23$noCache === void 0 ? false : _ref23$noCache, _ref23$noAuth = _ref23.noAuth, noAuth = _ref23$noAuth === void 0 ? false : _ref23$noAuth, assumeV3 = _ref23.assumeV3;
1580
- configUrl = networks[networkName];
1581
- if (configUrl) {
1582
- _context22.next = 4;
1583
- break;
1584
- }
1585
- throw Error("Invalid network name: " + networkName);
1586
- case 4:
1587
- _context22.next = 6;
1588
- return this.FromConfigurationUrl({
1589
- configUrl: configUrl,
1590
- region: region,
1591
- trustAuthorityId: trustAuthorityId,
1592
- staticToken: staticToken,
1593
- ethereumContractTimeout: ethereumContractTimeout,
1594
- noCache: noCache,
1595
- noAuth: noAuth,
1596
- assumeV3: assumeV3
1597
- });
1598
- case 6:
1599
- return _context22.abrupt("return", _context22.sent);
1600
- case 7:
1601
- case "end":
1602
- return _context22.stop();
1850
+ while (1) {
1851
+ switch (_context22.prev = _context22.next) {
1852
+ case 0:
1853
+ networkName = _ref23.networkName, region = _ref23.region, trustAuthorityId = _ref23.trustAuthorityId, staticToken = _ref23.staticToken, _ref23$ethereumContra = _ref23.ethereumContractTimeout, ethereumContractTimeout = _ref23$ethereumContra === void 0 ? 10 : _ref23$ethereumContra, _ref23$noCache = _ref23.noCache, noCache = _ref23$noCache === void 0 ? false : _ref23$noCache, _ref23$noAuth = _ref23.noAuth, noAuth = _ref23$noAuth === void 0 ? false : _ref23$noAuth, assumeV3 = _ref23.assumeV3;
1854
+ configUrl = networks[networkName];
1855
+
1856
+ if (configUrl) {
1857
+ _context22.next = 4;
1858
+ break;
1859
+ }
1860
+
1861
+ throw Error("Invalid network name: " + networkName);
1862
+
1863
+ case 4:
1864
+ _context22.next = 6;
1865
+ return this.FromConfigurationUrl({
1866
+ configUrl: configUrl,
1867
+ region: region,
1868
+ trustAuthorityId: trustAuthorityId,
1869
+ staticToken: staticToken,
1870
+ ethereumContractTimeout: ethereumContractTimeout,
1871
+ noCache: noCache,
1872
+ noAuth: noAuth,
1873
+ assumeV3: assumeV3
1874
+ });
1875
+
1876
+ case 6:
1877
+ return _context22.abrupt("return", _context22.sent);
1878
+
1879
+ case 7:
1880
+ case "end":
1881
+ return _context22.stop();
1882
+ }
1603
1883
  }
1604
1884
  }, _callee22, this);
1605
1885
  }));
1886
+
1606
1887
  function FromNetworkName(_x19) {
1607
1888
  return _FromNetworkName.apply(this, arguments);
1608
1889
  }
1890
+
1609
1891
  return FromNetworkName;
1610
1892
  }()
1611
1893
  /**
@@ -1623,62 +1905,72 @@ var ElvClient = /*#__PURE__*/function () {
1623
1905
  *
1624
1906
  * @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
1625
1907
  */
1908
+
1626
1909
  }, {
1627
1910
  key: "FromConfigurationUrl",
1628
1911
  value: function () {
1629
1912
  var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref24) {
1630
1913
  var configUrl, region, trustAuthorityId, staticToken, _ref24$ethereumContra, ethereumContractTimeout, _ref24$noCache, noCache, _ref24$noAuth, noAuth, _ref24$assumeV, assumeV3, _yield$ElvClient$Conf3, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, searchURIs, fabricVersion, client;
1914
+
1631
1915
  return _regeneratorRuntime.wrap(function _callee23$(_context23) {
1632
- while (1) switch (_context23.prev = _context23.next) {
1633
- case 0:
1634
- configUrl = _ref24.configUrl, region = _ref24.region, trustAuthorityId = _ref24.trustAuthorityId, staticToken = _ref24.staticToken, _ref24$ethereumContra = _ref24.ethereumContractTimeout, ethereumContractTimeout = _ref24$ethereumContra === void 0 ? 10 : _ref24$ethereumContra, _ref24$noCache = _ref24.noCache, noCache = _ref24$noCache === void 0 ? false : _ref24$noCache, _ref24$noAuth = _ref24.noAuth, noAuth = _ref24$noAuth === void 0 ? false : _ref24$noAuth, _ref24$assumeV = _ref24.assumeV3, assumeV3 = _ref24$assumeV === void 0 ? false : _ref24$assumeV;
1635
- _context23.next = 3;
1636
- return ElvClient.Configuration({
1637
- configUrl: configUrl,
1638
- region: region
1639
- });
1640
- case 3:
1641
- _yield$ElvClient$Conf3 = _context23.sent;
1642
- contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
1643
- networkId = _yield$ElvClient$Conf3.networkId;
1644
- networkName = _yield$ElvClient$Conf3.networkName;
1645
- fabricURIs = _yield$ElvClient$Conf3.fabricURIs;
1646
- ethereumURIs = _yield$ElvClient$Conf3.ethereumURIs;
1647
- authServiceURIs = _yield$ElvClient$Conf3.authServiceURIs;
1648
- searchURIs = _yield$ElvClient$Conf3.searchURIs;
1649
- fabricVersion = _yield$ElvClient$Conf3.fabricVersion;
1650
- client = new ElvClient({
1651
- contentSpaceId: contentSpaceId,
1652
- networkId: networkId,
1653
- networkName: networkName,
1654
- fabricVersion: fabricVersion,
1655
- fabricURIs: fabricURIs,
1656
- ethereumURIs: ethereumURIs,
1657
- authServiceURIs: authServiceURIs,
1658
- searchURIs: searchURIs,
1659
- ethereumContractTimeout: ethereumContractTimeout,
1660
- trustAuthorityId: trustAuthorityId,
1661
- staticToken: staticToken,
1662
- noCache: noCache,
1663
- noAuth: noAuth,
1664
- assumeV3: assumeV3
1665
- });
1666
- client.configUrl = configUrl;
1667
- return _context23.abrupt("return", client);
1668
- case 15:
1669
- case "end":
1670
- return _context23.stop();
1916
+ while (1) {
1917
+ switch (_context23.prev = _context23.next) {
1918
+ case 0:
1919
+ configUrl = _ref24.configUrl, region = _ref24.region, trustAuthorityId = _ref24.trustAuthorityId, staticToken = _ref24.staticToken, _ref24$ethereumContra = _ref24.ethereumContractTimeout, ethereumContractTimeout = _ref24$ethereumContra === void 0 ? 10 : _ref24$ethereumContra, _ref24$noCache = _ref24.noCache, noCache = _ref24$noCache === void 0 ? false : _ref24$noCache, _ref24$noAuth = _ref24.noAuth, noAuth = _ref24$noAuth === void 0 ? false : _ref24$noAuth, _ref24$assumeV = _ref24.assumeV3, assumeV3 = _ref24$assumeV === void 0 ? false : _ref24$assumeV;
1920
+ _context23.next = 3;
1921
+ return ElvClient.Configuration({
1922
+ configUrl: configUrl,
1923
+ region: region
1924
+ });
1925
+
1926
+ case 3:
1927
+ _yield$ElvClient$Conf3 = _context23.sent;
1928
+ contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
1929
+ networkId = _yield$ElvClient$Conf3.networkId;
1930
+ networkName = _yield$ElvClient$Conf3.networkName;
1931
+ fabricURIs = _yield$ElvClient$Conf3.fabricURIs;
1932
+ ethereumURIs = _yield$ElvClient$Conf3.ethereumURIs;
1933
+ authServiceURIs = _yield$ElvClient$Conf3.authServiceURIs;
1934
+ searchURIs = _yield$ElvClient$Conf3.searchURIs;
1935
+ fabricVersion = _yield$ElvClient$Conf3.fabricVersion;
1936
+ client = new ElvClient({
1937
+ contentSpaceId: contentSpaceId,
1938
+ networkId: networkId,
1939
+ networkName: networkName,
1940
+ fabricVersion: fabricVersion,
1941
+ fabricURIs: fabricURIs,
1942
+ ethereumURIs: ethereumURIs,
1943
+ authServiceURIs: authServiceURIs,
1944
+ searchURIs: searchURIs,
1945
+ ethereumContractTimeout: ethereumContractTimeout,
1946
+ trustAuthorityId: trustAuthorityId,
1947
+ staticToken: staticToken,
1948
+ noCache: noCache,
1949
+ noAuth: noAuth,
1950
+ assumeV3: assumeV3
1951
+ });
1952
+ client.configUrl = configUrl;
1953
+ return _context23.abrupt("return", client);
1954
+
1955
+ case 15:
1956
+ case "end":
1957
+ return _context23.stop();
1958
+ }
1671
1959
  }
1672
1960
  }, _callee23);
1673
1961
  }));
1962
+
1674
1963
  function FromConfigurationUrl(_x20) {
1675
1964
  return _FromConfigurationUrl.apply(this, arguments);
1676
1965
  }
1966
+
1677
1967
  return FromConfigurationUrl;
1678
1968
  }()
1679
1969
  }]);
1970
+
1680
1971
  return ElvClient;
1681
1972
  }();
1973
+
1682
1974
  Object.assign(ElvClient.prototype, require("./client/AccessGroups"));
1683
1975
  Object.assign(ElvClient.prototype, require("./client/ContentAccess"));
1684
1976
  Object.assign(ElvClient.prototype, require("./client/Contracts"));