@eluvio/elv-client-js 4.0.23 → 4.0.25

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, [{
@@ -256,6 +256,10 @@ var ElvClient = /*#__PURE__*/function () {
256
256
  uris: this.authServiceURIs,
257
257
  debug: this.debug
258
258
  });
259
+ this.SearchHttpClient = new HttpClient({
260
+ uris: this.searchURIs || [],
261
+ debug: this.debug
262
+ });
259
263
  this.ethClient = new EthClient({
260
264
  client: this,
261
265
  uris: this.ethereumURIs,
@@ -292,7 +296,7 @@ var ElvClient = /*#__PURE__*/function () {
292
296
  // Initialize crypto wasm
293
297
  this.Crypto = Crypto;
294
298
  this.Crypto.ElvCrypto();
295
- case 18:
299
+ case 19:
296
300
  case "end":
297
301
  return _context2.stop();
298
302
  }
@@ -318,12 +322,12 @@ var ElvClient = /*#__PURE__*/function () {
318
322
  /**
319
323
  * Update fabric URLs to prefer the specified region.
320
324
  *
321
- * Note: Client must have been initialized with FromConfiguration
325
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
322
326
  *
323
327
  * @methodGroup Nodes
324
328
  * @namedParams
325
329
  * @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
330
+ * - 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
331
  *
328
332
  * @return {Promise<Object>} - An object containing the updated fabric, ethereum, auth service, and search URLs in order of preference
329
333
  */
@@ -380,7 +384,7 @@ var ElvClient = /*#__PURE__*/function () {
380
384
  /**
381
385
  * Reset fabric URLs to prefer the best region auto-detected by the fabric.
382
386
  *
383
- * Note: Client must have been initialized with FromConfiguration
387
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
384
388
  *
385
389
  * @methodGroup Nodes
386
390
  *
@@ -419,7 +423,7 @@ var ElvClient = /*#__PURE__*/function () {
419
423
  /**
420
424
  * Retrieve the node ID reported by the fabric for the specified region
421
425
  *
422
- * Note: Client must have been initialized with FromConfiguration
426
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
423
427
  *
424
428
  * @methodGroup Nodes
425
429
  *
@@ -1068,7 +1072,7 @@ var ElvClient = /*#__PURE__*/function () {
1068
1072
  * Set the signer for this client via OAuth token. The client will exchange the given token
1069
1073
  * for the user's private key using the KMS specified in the configuration.
1070
1074
  *
1071
- * NOTE: The KMS URL(s) must be set in the initial configuration of the client (FromConfigurationUrl)
1075
+ * NOTE: The KMS URL(s) must be set in the initial configuration of the client (FromConfigurationUrl or FromNetworkName)
1072
1076
  *
1073
1077
  * @methodGroup Authorization
1074
1078
  * @namedParams
@@ -1489,20 +1493,23 @@ var ElvClient = /*#__PURE__*/function () {
1489
1493
  key: "Configuration",
1490
1494
  value: function () {
1491
1495
  var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref22) {
1492
- var configUrl, _ref22$kmsUrls, kmsUrls, region, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, searchURIs, fabricVersion;
1496
+ var configUrl, _ref22$kmsUrls, kmsUrls, region, clientIP, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, searchURIs, fabricVersion;
1493
1497
  return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1494
1498
  while (1) switch (_context21.prev = _context21.next) {
1495
1499
  case 0:
1496
- configUrl = _ref22.configUrl, _ref22$kmsUrls = _ref22.kmsUrls, kmsUrls = _ref22$kmsUrls === void 0 ? [] : _ref22$kmsUrls, region = _ref22.region;
1500
+ configUrl = _ref22.configUrl, _ref22$kmsUrls = _ref22.kmsUrls, kmsUrls = _ref22$kmsUrls === void 0 ? [] : _ref22$kmsUrls, region = _ref22.region, clientIP = _ref22.clientIP;
1497
1501
  _context21.prev = 1;
1498
1502
  uri = new URI(configUrl);
1499
1503
  uri.pathname("/config");
1500
1504
  if (region) {
1501
1505
  uri.addSearch("elvgeo", region);
1502
1506
  }
1503
- _context21.next = 7;
1507
+ if (clientIP) {
1508
+ uri.addSearch("client_ip", clientIP);
1509
+ }
1510
+ _context21.next = 8;
1504
1511
  return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
1505
- case 7:
1512
+ case 8:
1506
1513
  fabricInfo = _context21.sent;
1507
1514
  // If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
1508
1515
  filterHTTPS = function filterHTTPS(uri) {
@@ -1534,19 +1541,19 @@ var ElvClient = /*#__PURE__*/function () {
1534
1541
  searchURIs: searchURIs,
1535
1542
  fabricVersion: fabricVersion
1536
1543
  });
1537
- case 20:
1538
- _context21.prev = 20;
1544
+ case 21:
1545
+ _context21.prev = 21;
1539
1546
  _context21.t0 = _context21["catch"](1);
1540
1547
  // eslint-disable-next-line no-console
1541
1548
  console.error("Error retrieving fabric configuration:");
1542
1549
  // eslint-disable-next-line no-console
1543
1550
  console.error(_context21.t0);
1544
1551
  throw _context21.t0;
1545
- case 25:
1552
+ case 26:
1546
1553
  case "end":
1547
1554
  return _context21.stop();
1548
1555
  }
1549
- }, _callee21, null, [[1, 20]]);
1556
+ }, _callee21, null, [[1, 21]]);
1550
1557
  }));
1551
1558
  function Configuration(_x18) {
1552
1559
  return _Configuration.apply(this, arguments);
@@ -1560,7 +1567,8 @@ var ElvClient = /*#__PURE__*/function () {
1560
1567
  * @namedParams
1561
1568
  * @param {string} networkName - Name of the network to connect to ("main", "demo", "test)
1562
1569
  * @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
1570
+ * - 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
1571
+ * @param {string=} clientIP - IP address to use in determining the region to use
1564
1572
  * @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
1573
  * @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth
1566
1574
  * @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
@@ -1572,11 +1580,11 @@ var ElvClient = /*#__PURE__*/function () {
1572
1580
  key: "FromNetworkName",
1573
1581
  value: function () {
1574
1582
  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;
1583
+ var networkName, region, clientIP, trustAuthorityId, staticToken, _ref23$ethereumContra, ethereumContractTimeout, _ref23$noCache, noCache, _ref23$noAuth, noAuth, assumeV3, configUrl;
1576
1584
  return _regeneratorRuntime.wrap(function _callee22$(_context22) {
1577
1585
  while (1) switch (_context22.prev = _context22.next) {
1578
1586
  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;
1587
+ 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
1588
  configUrl = networks[networkName];
1581
1589
  if (configUrl) {
1582
1590
  _context22.next = 4;
@@ -1588,6 +1596,7 @@ var ElvClient = /*#__PURE__*/function () {
1588
1596
  return this.FromConfigurationUrl({
1589
1597
  configUrl: configUrl,
1590
1598
  region: region,
1599
+ clientIP: clientIP,
1591
1600
  trustAuthorityId: trustAuthorityId,
1592
1601
  staticToken: staticToken,
1593
1602
  ethereumContractTimeout: ethereumContractTimeout,
@@ -1615,7 +1624,8 @@ var ElvClient = /*#__PURE__*/function () {
1615
1624
  * @namedParams
1616
1625
  * @param {string} configUrl - Full URL to the config endpoint
1617
1626
  * @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
1627
+ * - 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
1628
+ * @param {string=} clientIP - IP address to use in determining the region to use
1619
1629
  * @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
1630
  * @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth
1621
1631
  * @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
@@ -1627,14 +1637,15 @@ var ElvClient = /*#__PURE__*/function () {
1627
1637
  key: "FromConfigurationUrl",
1628
1638
  value: function () {
1629
1639
  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;
1640
+ 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
1641
  return _regeneratorRuntime.wrap(function _callee23$(_context23) {
1632
1642
  while (1) switch (_context23.prev = _context23.next) {
1633
1643
  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;
1644
+ 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
1645
  _context23.next = 3;
1636
1646
  return ElvClient.Configuration({
1637
1647
  configUrl: configUrl,
1648
+ clientIP: clientIP,
1638
1649
  region: region
1639
1650
  });
1640
1651
  case 3:
@@ -2835,11 +2835,13 @@ exports.CallBitcodeMethod = /*#__PURE__*/function () {
2835
2835
  * @param {string=} versionHash - Hash of the object version - if not specified, latest version will be used
2836
2836
  * @param {string} rep - Representation to use
2837
2837
  * @param {Object=} queryParams - Query params to add to the URL
2838
+ * @param {string=} service=fabric - The service to use. By default, will use a fabric node. Options: "fabric", "search", "auth"
2838
2839
  * @param {boolean=} channelAuth=false - If specified, state channel authorization will be performed instead of access request authorization
2839
2840
  * @param {boolean=} noAuth=false - If specified, authorization will not be performed and the URL will not have an authorization
2840
2841
  * token. This is useful for accessing public assets.
2841
2842
  * @param {boolean=} noCache=false - If specified, a new access request will be made for the authorization regardless of
2842
2843
  * whether such a request exists in the client cache. This request will not be cached. This option has no effect if noAuth is true.
2844
+ * @param {boolean=} makeAccessRequest=false - If using auth, will make a full access request
2843
2845
  *
2844
2846
  * @see <a href="#FabricUrl">FabricUrl</a> for creating arbitrary fabric URLs
2845
2847
  *
@@ -2847,11 +2849,11 @@ exports.CallBitcodeMethod = /*#__PURE__*/function () {
2847
2849
  */
2848
2850
  exports.Rep = /*#__PURE__*/function () {
2849
2851
  var _ref63 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36(_ref62) {
2850
- var libraryId, objectId, versionHash, rep, _ref62$queryParams, queryParams, _ref62$channelAuth, channelAuth, _ref62$noAuth, noAuth, _ref62$noCache, noCache;
2852
+ var libraryId, objectId, versionHash, rep, _ref62$queryParams, queryParams, _ref62$service, service, _ref62$makeAccessRequ, makeAccessRequest, _ref62$channelAuth, channelAuth, _ref62$noAuth, noAuth, _ref62$noCache, noCache;
2851
2853
  return _regeneratorRuntime.wrap(function _callee36$(_context36) {
2852
2854
  while (1) switch (_context36.prev = _context36.next) {
2853
2855
  case 0:
2854
- libraryId = _ref62.libraryId, objectId = _ref62.objectId, versionHash = _ref62.versionHash, rep = _ref62.rep, _ref62$queryParams = _ref62.queryParams, queryParams = _ref62$queryParams === void 0 ? {} : _ref62$queryParams, _ref62$channelAuth = _ref62.channelAuth, channelAuth = _ref62$channelAuth === void 0 ? false : _ref62$channelAuth, _ref62$noAuth = _ref62.noAuth, noAuth = _ref62$noAuth === void 0 ? false : _ref62$noAuth, _ref62$noCache = _ref62.noCache, noCache = _ref62$noCache === void 0 ? false : _ref62$noCache;
2856
+ libraryId = _ref62.libraryId, objectId = _ref62.objectId, versionHash = _ref62.versionHash, rep = _ref62.rep, _ref62$queryParams = _ref62.queryParams, queryParams = _ref62$queryParams === void 0 ? {} : _ref62$queryParams, _ref62$service = _ref62.service, service = _ref62$service === void 0 ? "fabric" : _ref62$service, _ref62$makeAccessRequ = _ref62.makeAccessRequest, makeAccessRequest = _ref62$makeAccessRequ === void 0 ? false : _ref62$makeAccessRequ, _ref62$channelAuth = _ref62.channelAuth, channelAuth = _ref62$channelAuth === void 0 ? false : _ref62$channelAuth, _ref62$noAuth = _ref62.noAuth, noAuth = _ref62$noAuth === void 0 ? false : _ref62$noAuth, _ref62$noCache = _ref62.noCache, noCache = _ref62$noCache === void 0 ? false : _ref62$noCache;
2855
2857
  ValidateParameters({
2856
2858
  libraryId: libraryId,
2857
2859
  objectId: objectId,
@@ -2869,6 +2871,8 @@ exports.Rep = /*#__PURE__*/function () {
2869
2871
  versionHash: versionHash,
2870
2872
  rep: rep,
2871
2873
  queryParams: queryParams,
2874
+ service: service,
2875
+ makeAccessRequest: makeAccessRequest,
2872
2876
  channelAuth: channelAuth,
2873
2877
  noAuth: noAuth,
2874
2878
  noCache: noCache
@@ -2903,11 +2907,11 @@ exports.Rep = /*#__PURE__*/function () {
2903
2907
  */
2904
2908
  exports.PublicRep = /*#__PURE__*/function () {
2905
2909
  var _ref65 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee37(_ref64) {
2906
- var libraryId, objectId, versionHash, rep, _ref64$queryParams, queryParams;
2910
+ var libraryId, objectId, versionHash, rep, _ref64$queryParams, queryParams, _ref64$service, service;
2907
2911
  return _regeneratorRuntime.wrap(function _callee37$(_context37) {
2908
2912
  while (1) switch (_context37.prev = _context37.next) {
2909
2913
  case 0:
2910
- libraryId = _ref64.libraryId, objectId = _ref64.objectId, versionHash = _ref64.versionHash, rep = _ref64.rep, _ref64$queryParams = _ref64.queryParams, queryParams = _ref64$queryParams === void 0 ? {} : _ref64$queryParams;
2914
+ libraryId = _ref64.libraryId, objectId = _ref64.objectId, versionHash = _ref64.versionHash, rep = _ref64.rep, _ref64$queryParams = _ref64.queryParams, queryParams = _ref64$queryParams === void 0 ? {} : _ref64$queryParams, _ref64$service = _ref64.service, service = _ref64$service === void 0 ? "fabric" : _ref64$service;
2911
2915
  ValidateParameters({
2912
2916
  libraryId: libraryId,
2913
2917
  objectId: objectId,
@@ -2925,6 +2929,7 @@ exports.PublicRep = /*#__PURE__*/function () {
2925
2929
  versionHash: versionHash,
2926
2930
  publicRep: rep,
2927
2931
  queryParams: queryParams,
2932
+ service: service,
2928
2933
  noAuth: true
2929
2934
  }));
2930
2935
  case 5:
@@ -2952,21 +2957,23 @@ exports.PublicRep = /*#__PURE__*/function () {
2952
2957
  * @param {string=} publicRep - Public rep parameter of the url
2953
2958
  * @param {string=} call - Bitcode method to call
2954
2959
  * @param {Object=} queryParams - Query params to add to the URL
2960
+ * @param {string=} service=fabric - The service to use. By default, will use a fabric node. Options: "fabric", "search", "auth"
2955
2961
  * @param {boolean=} channelAuth=false - If specified, state channel authorization will be used instead of access request authorization
2956
2962
  * @param {boolean=} noAuth=false - If specified, authorization will not be performed and the URL will not have an authorization
2957
2963
  * token. This is useful for accessing public assets.
2958
2964
  * @param {boolean=} noCache=false - If specified, a new access request will be made for the authorization regardless of
2959
2965
  * whether such a request exists in the client cache. This request will not be cached. This option has no effect if noAuth is true.
2966
+ * @param {boolean=} makeAccessRequest=false - If using auth, will make a full access request
2960
2967
  *
2961
2968
  * @returns {Promise<string>} - URL to the specified endpoint with authorization token
2962
2969
  */
2963
2970
  exports.FabricUrl = /*#__PURE__*/function () {
2964
2971
  var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38(_ref66) {
2965
- var libraryId, objectId, versionHash, writeToken, partHash, rep, publicRep, call, _ref66$queryParams, queryParams, _ref66$channelAuth, channelAuth, _ref66$noAuth, noAuth, _ref66$noCache, noCache, authorization, path;
2972
+ var libraryId, objectId, versionHash, writeToken, partHash, rep, publicRep, call, _ref66$queryParams, queryParams, _ref66$service, service, _ref66$channelAuth, channelAuth, _ref66$makeAccessRequ, makeAccessRequest, _ref66$noAuth, noAuth, _ref66$noCache, noCache, authorization, path, httpClient;
2966
2973
  return _regeneratorRuntime.wrap(function _callee38$(_context38) {
2967
2974
  while (1) switch (_context38.prev = _context38.next) {
2968
2975
  case 0:
2969
- libraryId = _ref66.libraryId, objectId = _ref66.objectId, versionHash = _ref66.versionHash, writeToken = _ref66.writeToken, partHash = _ref66.partHash, rep = _ref66.rep, publicRep = _ref66.publicRep, call = _ref66.call, _ref66$queryParams = _ref66.queryParams, queryParams = _ref66$queryParams === void 0 ? {} : _ref66$queryParams, _ref66$channelAuth = _ref66.channelAuth, channelAuth = _ref66$channelAuth === void 0 ? false : _ref66$channelAuth, _ref66$noAuth = _ref66.noAuth, noAuth = _ref66$noAuth === void 0 ? false : _ref66$noAuth, _ref66$noCache = _ref66.noCache, noCache = _ref66$noCache === void 0 ? false : _ref66$noCache;
2976
+ libraryId = _ref66.libraryId, objectId = _ref66.objectId, versionHash = _ref66.versionHash, writeToken = _ref66.writeToken, partHash = _ref66.partHash, rep = _ref66.rep, publicRep = _ref66.publicRep, call = _ref66.call, _ref66$queryParams = _ref66.queryParams, queryParams = _ref66$queryParams === void 0 ? {} : _ref66$queryParams, _ref66$service = _ref66.service, service = _ref66$service === void 0 ? "fabric" : _ref66$service, _ref66$channelAuth = _ref66.channelAuth, channelAuth = _ref66$channelAuth === void 0 ? false : _ref66$channelAuth, _ref66$makeAccessRequ = _ref66.makeAccessRequest, makeAccessRequest = _ref66$makeAccessRequ === void 0 ? false : _ref66$makeAccessRequ, _ref66$noAuth = _ref66.noAuth, noAuth = _ref66$noAuth === void 0 ? false : _ref66$noAuth, _ref66$noCache = _ref66.noCache, noCache = _ref66$noCache === void 0 ? false : _ref66$noCache;
2970
2977
  if (objectId || versionHash) {
2971
2978
  ValidateParameters({
2972
2979
  libraryId: libraryId,
@@ -2993,6 +3000,7 @@ exports.FabricUrl = /*#__PURE__*/function () {
2993
3000
  objectId: objectId,
2994
3001
  versionHash: versionHash,
2995
3002
  channelAuth: channelAuth,
3003
+ makeAccessRequest: makeAccessRequest,
2996
3004
  noAuth: noAuth,
2997
3005
  noCache: noCache
2998
3006
  });
@@ -3033,11 +3041,17 @@ exports.FabricUrl = /*#__PURE__*/function () {
3033
3041
  } else if (call) {
3034
3042
  path = UrlJoin(path, "call", call);
3035
3043
  }
3036
- return _context38.abrupt("return", this.HttpClient.URL({
3044
+ httpClient = this.HttpClient;
3045
+ if (service === "search") {
3046
+ httpClient = this.SearchHttpClient;
3047
+ } else if (service === "auth") {
3048
+ httpClient = this.AuthHttpClient;
3049
+ }
3050
+ return _context38.abrupt("return", httpClient.URL({
3037
3051
  path: path,
3038
3052
  queryParams: queryParams
3039
3053
  }));
3040
- case 21:
3054
+ case 23:
3041
3055
  case "end":
3042
3056
  return _context38.stop();
3043
3057
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.23",
3
+ "version": "4.0.25",
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
 
@@ -384,6 +395,7 @@ class ElvClient {
384
395
  const uris = this.service === "search" ? this.searchURIs : this.fabricURIs;
385
396
  this.HttpClient = new HttpClient({uris, debug: this.debug});
386
397
  this.AuthHttpClient = new HttpClient({uris: this.authServiceURIs, debug: this.debug});
398
+ this.SearchHttpClient = new HttpClient({uris: this.searchURIs || [], debug: this.debug});
387
399
  this.ethClient = new EthClient({client: this, uris: this.ethereumURIs, networkId: this.networkId, debug: this.debug, timeout: this.ethereumContractTimeout});
388
400
 
389
401
  if(!this.signer) {
@@ -425,12 +437,12 @@ class ElvClient {
425
437
  /**
426
438
  * Update fabric URLs to prefer the specified region.
427
439
  *
428
- * Note: Client must have been initialized with FromConfiguration
440
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
429
441
  *
430
442
  * @methodGroup Nodes
431
443
  * @namedParams
432
444
  * @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
445
+ * - 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
446
  *
435
447
  * @return {Promise<Object>} - An object containing the updated fabric, ethereum, auth service, and search URLs in order of preference
436
448
  */
@@ -465,7 +477,7 @@ class ElvClient {
465
477
  /**
466
478
  * Reset fabric URLs to prefer the best region auto-detected by the fabric.
467
479
  *
468
- * Note: Client must have been initialized with FromConfiguration
480
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
469
481
  *
470
482
  * @methodGroup Nodes
471
483
  *
@@ -482,7 +494,7 @@ class ElvClient {
482
494
  /**
483
495
  * Retrieve the node ID reported by the fabric for the specified region
484
496
  *
485
- * Note: Client must have been initialized with FromConfiguration
497
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
486
498
  *
487
499
  * @methodGroup Nodes
488
500
  *
@@ -898,7 +910,7 @@ class ElvClient {
898
910
  * Set the signer for this client via OAuth token. The client will exchange the given token
899
911
  * for the user's private key using the KMS specified in the configuration.
900
912
  *
901
- * NOTE: The KMS URL(s) must be set in the initial configuration of the client (FromConfigurationUrl)
913
+ * NOTE: The KMS URL(s) must be set in the initial configuration of the client (FromConfigurationUrl or FromNetworkName)
902
914
  *
903
915
  * @methodGroup Authorization
904
916
  * @namedParams
@@ -1848,21 +1848,23 @@ exports.CallBitcodeMethod = async function({
1848
1848
  * @param {string=} versionHash - Hash of the object version - if not specified, latest version will be used
1849
1849
  * @param {string} rep - Representation to use
1850
1850
  * @param {Object=} queryParams - Query params to add to the URL
1851
+ * @param {string=} service=fabric - The service to use. By default, will use a fabric node. Options: "fabric", "search", "auth"
1851
1852
  * @param {boolean=} channelAuth=false - If specified, state channel authorization will be performed instead of access request authorization
1852
1853
  * @param {boolean=} noAuth=false - If specified, authorization will not be performed and the URL will not have an authorization
1853
1854
  * token. This is useful for accessing public assets.
1854
1855
  * @param {boolean=} noCache=false - If specified, a new access request will be made for the authorization regardless of
1855
1856
  * whether such a request exists in the client cache. This request will not be cached. This option has no effect if noAuth is true.
1857
+ * @param {boolean=} makeAccessRequest=false - If using auth, will make a full access request
1856
1858
  *
1857
1859
  * @see <a href="#FabricUrl">FabricUrl</a> for creating arbitrary fabric URLs
1858
1860
  *
1859
1861
  * @returns {Promise<string>} - URL to the specified rep endpoint with authorization token
1860
1862
  */
1861
- exports.Rep = async function({libraryId, objectId, versionHash, rep, queryParams={}, channelAuth=false, noAuth=false, noCache=false}) {
1863
+ exports.Rep = async function({libraryId, objectId, versionHash, rep, queryParams={}, service="fabric", makeAccessRequest=false, channelAuth=false, noAuth=false, noCache=false}) {
1862
1864
  ValidateParameters({libraryId, objectId, versionHash});
1863
1865
  if(!rep) { throw "Rep not specified"; }
1864
1866
 
1865
- return this.FabricUrl({libraryId, objectId, versionHash, rep, queryParams, channelAuth, noAuth, noCache});
1867
+ return this.FabricUrl({libraryId, objectId, versionHash, rep, queryParams, service, makeAccessRequest, channelAuth, noAuth, noCache});
1866
1868
  };
1867
1869
 
1868
1870
  /**
@@ -1882,11 +1884,11 @@ exports.Rep = async function({libraryId, objectId, versionHash, rep, queryParams
1882
1884
  *
1883
1885
  * @returns {Promise<string>} - URL to the specified rep endpoint with authorization token
1884
1886
  */
1885
- exports.PublicRep = async function({libraryId, objectId, versionHash, rep, queryParams={}}) {
1887
+ exports.PublicRep = async function({libraryId, objectId, versionHash, rep, queryParams={}, service="fabric"}) {
1886
1888
  ValidateParameters({libraryId, objectId, versionHash});
1887
1889
  if(!rep) { throw "Rep not specified"; }
1888
1890
 
1889
- return this.FabricUrl({libraryId, objectId, versionHash, publicRep: rep, queryParams, noAuth: true});
1891
+ return this.FabricUrl({libraryId, objectId, versionHash, publicRep: rep, queryParams, service, noAuth: true});
1890
1892
  };
1891
1893
 
1892
1894
  /**
@@ -1903,11 +1905,13 @@ exports.PublicRep = async function({libraryId, objectId, versionHash, rep, query
1903
1905
  * @param {string=} publicRep - Public rep parameter of the url
1904
1906
  * @param {string=} call - Bitcode method to call
1905
1907
  * @param {Object=} queryParams - Query params to add to the URL
1908
+ * @param {string=} service=fabric - The service to use. By default, will use a fabric node. Options: "fabric", "search", "auth"
1906
1909
  * @param {boolean=} channelAuth=false - If specified, state channel authorization will be used instead of access request authorization
1907
1910
  * @param {boolean=} noAuth=false - If specified, authorization will not be performed and the URL will not have an authorization
1908
1911
  * token. This is useful for accessing public assets.
1909
1912
  * @param {boolean=} noCache=false - If specified, a new access request will be made for the authorization regardless of
1910
1913
  * whether such a request exists in the client cache. This request will not be cached. This option has no effect if noAuth is true.
1914
+ * @param {boolean=} makeAccessRequest=false - If using auth, will make a full access request
1911
1915
  *
1912
1916
  * @returns {Promise<string>} - URL to the specified endpoint with authorization token
1913
1917
  */
@@ -1921,7 +1925,9 @@ exports.FabricUrl = async function({
1921
1925
  publicRep,
1922
1926
  call,
1923
1927
  queryParams={},
1928
+ service="fabric",
1924
1929
  channelAuth=false,
1930
+ makeAccessRequest=false,
1925
1931
  noAuth=false,
1926
1932
  noCache=false
1927
1933
  }) {
@@ -1960,6 +1966,7 @@ exports.FabricUrl = async function({
1960
1966
  objectId,
1961
1967
  versionHash,
1962
1968
  channelAuth,
1969
+ makeAccessRequest,
1963
1970
  noAuth,
1964
1971
  noCache
1965
1972
  })
@@ -1997,7 +2004,14 @@ exports.FabricUrl = async function({
1997
2004
  path = UrlJoin(path, "call", call);
1998
2005
  }
1999
2006
 
2000
- return this.HttpClient.URL({
2007
+ let httpClient = this.HttpClient;
2008
+ if(service === "search") {
2009
+ httpClient = this.SearchHttpClient;
2010
+ } else if(service === "auth") {
2011
+ httpClient = this.AuthHttpClient;
2012
+ }
2013
+
2014
+ return httpClient.URL({
2001
2015
  path,
2002
2016
  queryParams
2003
2017
  });