@eluvio/elv-client-js 4.0.22 → 4.0.24

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.
@@ -134,8 +134,8 @@ var ElvClient = /*#__PURE__*/function () {
134
134
  * @param {string} configUrl - Full URL to the config endpoint
135
135
  * @param {Array<string>} kmsUrls - List of KMS urls to use for OAuth authentication
136
136
  * @param {string=} region - Preferred region - the fabric will auto-detect the best region if not specified
137
- * - Available regions: as-east au-east eu-east-north eu-west-north na-east-north na-east-south na-west-north na-west-south eu-east-south eu-west-south
138
- *
137
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
138
+ * @param {string=} clientIP - IP address to use in determining the region to use
139
139
  * @return {Promise<Object>} - Object containing content space ID and fabric and ethereum URLs
140
140
  */
141
141
  _createClass(ElvClient, [{
@@ -318,12 +318,12 @@ var ElvClient = /*#__PURE__*/function () {
318
318
  /**
319
319
  * Update fabric URLs to prefer the specified region.
320
320
  *
321
- * Note: Client must have been initialized with FromConfiguration
321
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
322
322
  *
323
323
  * @methodGroup Nodes
324
324
  * @namedParams
325
325
  * @param {string} region - Preferred region - the fabric will auto-detect the best region if not specified
326
- * - Available regions: as-east au-east eu-east-north eu-west-north na-east-north na-east-south na-west-north na-west-south eu-east-south eu-west-south
326
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
327
327
  *
328
328
  * @return {Promise<Object>} - An object containing the updated fabric, ethereum, auth service, and search URLs in order of preference
329
329
  */
@@ -380,7 +380,7 @@ var ElvClient = /*#__PURE__*/function () {
380
380
  /**
381
381
  * Reset fabric URLs to prefer the best region auto-detected by the fabric.
382
382
  *
383
- * Note: Client must have been initialized with FromConfiguration
383
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
384
384
  *
385
385
  * @methodGroup Nodes
386
386
  *
@@ -419,7 +419,7 @@ var ElvClient = /*#__PURE__*/function () {
419
419
  /**
420
420
  * Retrieve the node ID reported by the fabric for the specified region
421
421
  *
422
- * Note: Client must have been initialized with FromConfiguration
422
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
423
423
  *
424
424
  * @methodGroup Nodes
425
425
  *
@@ -1068,7 +1068,7 @@ var ElvClient = /*#__PURE__*/function () {
1068
1068
  * Set the signer for this client via OAuth token. The client will exchange the given token
1069
1069
  * for the user's private key using the KMS specified in the configuration.
1070
1070
  *
1071
- * NOTE: The KMS URL(s) must be set in the initial configuration of the client (FromConfigurationUrl)
1071
+ * NOTE: The KMS URL(s) must be set in the initial configuration of the client (FromConfigurationUrl or FromNetworkName)
1072
1072
  *
1073
1073
  * @methodGroup Authorization
1074
1074
  * @namedParams
@@ -1489,20 +1489,23 @@ var ElvClient = /*#__PURE__*/function () {
1489
1489
  key: "Configuration",
1490
1490
  value: function () {
1491
1491
  var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref22) {
1492
- var configUrl, _ref22$kmsUrls, kmsUrls, region, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, searchURIs, fabricVersion;
1492
+ var configUrl, _ref22$kmsUrls, kmsUrls, region, clientIP, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, searchURIs, fabricVersion;
1493
1493
  return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1494
1494
  while (1) switch (_context21.prev = _context21.next) {
1495
1495
  case 0:
1496
- configUrl = _ref22.configUrl, _ref22$kmsUrls = _ref22.kmsUrls, kmsUrls = _ref22$kmsUrls === void 0 ? [] : _ref22$kmsUrls, region = _ref22.region;
1496
+ configUrl = _ref22.configUrl, _ref22$kmsUrls = _ref22.kmsUrls, kmsUrls = _ref22$kmsUrls === void 0 ? [] : _ref22$kmsUrls, region = _ref22.region, clientIP = _ref22.clientIP;
1497
1497
  _context21.prev = 1;
1498
1498
  uri = new URI(configUrl);
1499
1499
  uri.pathname("/config");
1500
1500
  if (region) {
1501
1501
  uri.addSearch("elvgeo", region);
1502
1502
  }
1503
- _context21.next = 7;
1503
+ if (clientIP) {
1504
+ uri.addSearch("client_ip", clientIP);
1505
+ }
1506
+ _context21.next = 8;
1504
1507
  return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
1505
- case 7:
1508
+ case 8:
1506
1509
  fabricInfo = _context21.sent;
1507
1510
  // If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
1508
1511
  filterHTTPS = function filterHTTPS(uri) {
@@ -1534,19 +1537,19 @@ var ElvClient = /*#__PURE__*/function () {
1534
1537
  searchURIs: searchURIs,
1535
1538
  fabricVersion: fabricVersion
1536
1539
  });
1537
- case 20:
1538
- _context21.prev = 20;
1540
+ case 21:
1541
+ _context21.prev = 21;
1539
1542
  _context21.t0 = _context21["catch"](1);
1540
1543
  // eslint-disable-next-line no-console
1541
1544
  console.error("Error retrieving fabric configuration:");
1542
1545
  // eslint-disable-next-line no-console
1543
1546
  console.error(_context21.t0);
1544
1547
  throw _context21.t0;
1545
- case 25:
1548
+ case 26:
1546
1549
  case "end":
1547
1550
  return _context21.stop();
1548
1551
  }
1549
- }, _callee21, null, [[1, 20]]);
1552
+ }, _callee21, null, [[1, 21]]);
1550
1553
  }));
1551
1554
  function Configuration(_x18) {
1552
1555
  return _Configuration.apply(this, arguments);
@@ -1560,7 +1563,8 @@ var ElvClient = /*#__PURE__*/function () {
1560
1563
  * @namedParams
1561
1564
  * @param {string} networkName - Name of the network to connect to ("main", "demo", "test)
1562
1565
  * @param {string=} region - Preferred region - the fabric will auto-detect the best region if not specified
1563
- * - Available regions: as-east au-east eu-east-north eu-west-north na-east-north na-east-south na-west-north na-west-south eu-east-south eu-west-south
1566
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
1567
+ * @param {string=} clientIP - IP address to use in determining the region to use
1564
1568
  * @param {string=} trustAuthorityId - (OAuth) The ID of the trust authority to use for OAuth authentication * @param {boolean=} noCache=false - If enabled, blockchain transactions will not be cached
1565
1569
  * @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth
1566
1570
  * @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
@@ -1572,11 +1576,11 @@ var ElvClient = /*#__PURE__*/function () {
1572
1576
  key: "FromNetworkName",
1573
1577
  value: function () {
1574
1578
  var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref23) {
1575
- var networkName, region, trustAuthorityId, staticToken, _ref23$ethereumContra, ethereumContractTimeout, _ref23$noCache, noCache, _ref23$noAuth, noAuth, assumeV3, configUrl;
1579
+ var networkName, region, clientIP, trustAuthorityId, staticToken, _ref23$ethereumContra, ethereumContractTimeout, _ref23$noCache, noCache, _ref23$noAuth, noAuth, assumeV3, configUrl;
1576
1580
  return _regeneratorRuntime.wrap(function _callee22$(_context22) {
1577
1581
  while (1) switch (_context22.prev = _context22.next) {
1578
1582
  case 0:
1579
- networkName = _ref23.networkName, region = _ref23.region, trustAuthorityId = _ref23.trustAuthorityId, staticToken = _ref23.staticToken, _ref23$ethereumContra = _ref23.ethereumContractTimeout, ethereumContractTimeout = _ref23$ethereumContra === void 0 ? 10 : _ref23$ethereumContra, _ref23$noCache = _ref23.noCache, noCache = _ref23$noCache === void 0 ? false : _ref23$noCache, _ref23$noAuth = _ref23.noAuth, noAuth = _ref23$noAuth === void 0 ? false : _ref23$noAuth, assumeV3 = _ref23.assumeV3;
1583
+ networkName = _ref23.networkName, region = _ref23.region, clientIP = _ref23.clientIP, trustAuthorityId = _ref23.trustAuthorityId, staticToken = _ref23.staticToken, _ref23$ethereumContra = _ref23.ethereumContractTimeout, ethereumContractTimeout = _ref23$ethereumContra === void 0 ? 10 : _ref23$ethereumContra, _ref23$noCache = _ref23.noCache, noCache = _ref23$noCache === void 0 ? false : _ref23$noCache, _ref23$noAuth = _ref23.noAuth, noAuth = _ref23$noAuth === void 0 ? false : _ref23$noAuth, assumeV3 = _ref23.assumeV3;
1580
1584
  configUrl = networks[networkName];
1581
1585
  if (configUrl) {
1582
1586
  _context22.next = 4;
@@ -1588,6 +1592,7 @@ var ElvClient = /*#__PURE__*/function () {
1588
1592
  return this.FromConfigurationUrl({
1589
1593
  configUrl: configUrl,
1590
1594
  region: region,
1595
+ clientIP: clientIP,
1591
1596
  trustAuthorityId: trustAuthorityId,
1592
1597
  staticToken: staticToken,
1593
1598
  ethereumContractTimeout: ethereumContractTimeout,
@@ -1615,7 +1620,8 @@ var ElvClient = /*#__PURE__*/function () {
1615
1620
  * @namedParams
1616
1621
  * @param {string} configUrl - Full URL to the config endpoint
1617
1622
  * @param {string=} region - Preferred region - the fabric will auto-detect the best region if not specified
1618
- * - Available regions: as-east au-east eu-east-north eu-west-north na-east-north na-east-south na-west-north na-west-south eu-east-south eu-west-south
1623
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
1624
+ * @param {string=} clientIP - IP address to use in determining the region to use
1619
1625
  * @param {string=} trustAuthorityId - (OAuth) The ID of the trust authority to use for OAuth authentication * @param {boolean=} noCache=false - If enabled, blockchain transactions will not be cached
1620
1626
  * @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth
1621
1627
  * @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
@@ -1627,14 +1633,15 @@ var ElvClient = /*#__PURE__*/function () {
1627
1633
  key: "FromConfigurationUrl",
1628
1634
  value: function () {
1629
1635
  var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref24) {
1630
- 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;
1636
+ var configUrl, region, clientIP, 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;
1631
1637
  return _regeneratorRuntime.wrap(function _callee23$(_context23) {
1632
1638
  while (1) switch (_context23.prev = _context23.next) {
1633
1639
  case 0:
1634
- configUrl = _ref24.configUrl, region = _ref24.region, trustAuthorityId = _ref24.trustAuthorityId, staticToken = _ref24.staticToken, _ref24$ethereumContra = _ref24.ethereumContractTimeout, ethereumContractTimeout = _ref24$ethereumContra === void 0 ? 10 : _ref24$ethereumContra, _ref24$noCache = _ref24.noCache, noCache = _ref24$noCache === void 0 ? false : _ref24$noCache, _ref24$noAuth = _ref24.noAuth, noAuth = _ref24$noAuth === void 0 ? false : _ref24$noAuth, _ref24$assumeV = _ref24.assumeV3, assumeV3 = _ref24$assumeV === void 0 ? false : _ref24$assumeV;
1640
+ configUrl = _ref24.configUrl, region = _ref24.region, clientIP = _ref24.clientIP, trustAuthorityId = _ref24.trustAuthorityId, staticToken = _ref24.staticToken, _ref24$ethereumContra = _ref24.ethereumContractTimeout, ethereumContractTimeout = _ref24$ethereumContra === void 0 ? 10 : _ref24$ethereumContra, _ref24$noCache = _ref24.noCache, noCache = _ref24$noCache === void 0 ? false : _ref24$noCache, _ref24$noAuth = _ref24.noAuth, noAuth = _ref24$noAuth === void 0 ? false : _ref24$noAuth, _ref24$assumeV = _ref24.assumeV3, assumeV3 = _ref24$assumeV === void 0 ? false : _ref24$assumeV;
1635
1641
  _context23.next = 3;
1636
1642
  return ElvClient.Configuration({
1637
1643
  configUrl: configUrl,
1644
+ clientIP: clientIP,
1638
1645
  region: region
1639
1646
  });
1640
1647
  case 3:
@@ -1118,7 +1118,8 @@ exports.DownloadFile = /*#__PURE__*/function () {
1118
1118
  libraryId: libraryId,
1119
1119
  objectId: objectId,
1120
1120
  versionHash: versionHash,
1121
- encryption: encryption
1121
+ encryption: encryption,
1122
+ makeAccessRequest: encryption === "cgck"
1122
1123
  });
1123
1124
  case 12:
1124
1125
  headers = _context15.sent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.22",
3
+ "version": "4.0.24",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
package/src/ElvClient.js CHANGED
@@ -203,14 +203,15 @@ class ElvClient {
203
203
  * @param {string} configUrl - Full URL to the config endpoint
204
204
  * @param {Array<string>} kmsUrls - List of KMS urls to use for OAuth authentication
205
205
  * @param {string=} region - Preferred region - the fabric will auto-detect the best region if not specified
206
- * - Available regions: as-east au-east eu-east-north eu-west-north na-east-north na-east-south na-west-north na-west-south eu-east-south eu-west-south
207
- *
206
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
207
+ * @param {string=} clientIP - IP address to use in determining the region to use
208
208
  * @return {Promise<Object>} - Object containing content space ID and fabric and ethereum URLs
209
209
  */
210
210
  static async Configuration({
211
211
  configUrl,
212
212
  kmsUrls=[],
213
- region
213
+ region,
214
+ clientIP
214
215
  }) {
215
216
  try {
216
217
  const uri = new URI(configUrl);
@@ -220,6 +221,10 @@ class ElvClient {
220
221
  uri.addSearch("elvgeo", region);
221
222
  }
222
223
 
224
+ if(clientIP) {
225
+ uri.addSearch("client_ip", clientIP);
226
+ }
227
+
223
228
  const fabricInfo = await Utils.ResponseToJson(
224
229
  HttpClient.Fetch(uri.toString())
225
230
  );
@@ -275,7 +280,8 @@ class ElvClient {
275
280
  * @namedParams
276
281
  * @param {string} networkName - Name of the network to connect to ("main", "demo", "test)
277
282
  * @param {string=} region - Preferred region - the fabric will auto-detect the best region if not specified
278
- * - Available regions: as-east au-east eu-east-north eu-west-north na-east-north na-east-south na-west-north na-west-south eu-east-south eu-west-south
283
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
284
+ * @param {string=} clientIP - IP address to use in determining the region to use
279
285
  * @param {string=} trustAuthorityId - (OAuth) The ID of the trust authority to use for OAuth authentication * @param {boolean=} noCache=false - If enabled, blockchain transactions will not be cached
280
286
  * @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth
281
287
  * @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
@@ -286,6 +292,7 @@ class ElvClient {
286
292
  static async FromNetworkName({
287
293
  networkName,
288
294
  region,
295
+ clientIP,
289
296
  trustAuthorityId,
290
297
  staticToken,
291
298
  ethereumContractTimeout=10,
@@ -300,6 +307,7 @@ class ElvClient {
300
307
  return await this.FromConfigurationUrl({
301
308
  configUrl,
302
309
  region,
310
+ clientIP,
303
311
  trustAuthorityId,
304
312
  staticToken,
305
313
  ethereumContractTimeout,
@@ -316,7 +324,8 @@ class ElvClient {
316
324
  * @namedParams
317
325
  * @param {string} configUrl - Full URL to the config endpoint
318
326
  * @param {string=} region - Preferred region - the fabric will auto-detect the best region if not specified
319
- * - Available regions: as-east au-east eu-east-north eu-west-north na-east-north na-east-south na-west-north na-west-south eu-east-south eu-west-south
327
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
328
+ * @param {string=} clientIP - IP address to use in determining the region to use
320
329
  * @param {string=} trustAuthorityId - (OAuth) The ID of the trust authority to use for OAuth authentication * @param {boolean=} noCache=false - If enabled, blockchain transactions will not be cached
321
330
  * @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth
322
331
  * @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
@@ -327,6 +336,7 @@ class ElvClient {
327
336
  static async FromConfigurationUrl({
328
337
  configUrl,
329
338
  region,
339
+ clientIP,
330
340
  trustAuthorityId,
331
341
  staticToken,
332
342
  ethereumContractTimeout=10,
@@ -345,6 +355,7 @@ class ElvClient {
345
355
  fabricVersion
346
356
  } = await ElvClient.Configuration({
347
357
  configUrl,
358
+ clientIP,
348
359
  region
349
360
  });
350
361
 
@@ -425,12 +436,12 @@ class ElvClient {
425
436
  /**
426
437
  * Update fabric URLs to prefer the specified region.
427
438
  *
428
- * Note: Client must have been initialized with FromConfiguration
439
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
429
440
  *
430
441
  * @methodGroup Nodes
431
442
  * @namedParams
432
443
  * @param {string} region - Preferred region - the fabric will auto-detect the best region if not specified
433
- * - Available regions: as-east au-east eu-east-north eu-west-north na-east-north na-east-south na-west-north na-west-south eu-east-south eu-west-south
444
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
434
445
  *
435
446
  * @return {Promise<Object>} - An object containing the updated fabric, ethereum, auth service, and search URLs in order of preference
436
447
  */
@@ -465,7 +476,7 @@ class ElvClient {
465
476
  /**
466
477
  * Reset fabric URLs to prefer the best region auto-detected by the fabric.
467
478
  *
468
- * Note: Client must have been initialized with FromConfiguration
479
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
469
480
  *
470
481
  * @methodGroup Nodes
471
482
  *
@@ -482,7 +493,7 @@ class ElvClient {
482
493
  /**
483
494
  * Retrieve the node ID reported by the fabric for the specified region
484
495
  *
485
- * Note: Client must have been initialized with FromConfiguration
496
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
486
497
  *
487
498
  * @methodGroup Nodes
488
499
  *
@@ -898,7 +909,7 @@ class ElvClient {
898
909
  * Set the signer for this client via OAuth token. The client will exchange the given token
899
910
  * for the user's private key using the KMS specified in the configuration.
900
911
  *
901
- * NOTE: The KMS URL(s) must be set in the initial configuration of the client (FromConfigurationUrl)
912
+ * NOTE: The KMS URL(s) must be set in the initial configuration of the client (FromConfigurationUrl or FromNetworkName)
902
913
  *
903
914
  * @methodGroup Authorization
904
915
  * @namedParams
@@ -684,7 +684,7 @@ exports.DownloadFile = async function({
684
684
  UrlJoin("q", writeToken || versionHash || objectId, "files", filePath);
685
685
 
686
686
 
687
- const headers = await this.authClient.AuthorizationHeader({libraryId, objectId, versionHash, encryption});
687
+ const headers = await this.authClient.AuthorizationHeader({libraryId, objectId, versionHash, encryption, makeAccessRequest: encryption === "cgck"});
688
688
  headers.Accept = "*/*";
689
689
 
690
690
  // If not owner, indicate re-encryption