@eluvio/elv-client-js 4.0.7 → 4.0.9

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