@eluvio/elv-client-js 3.1.83 → 3.1.87

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.
@@ -218,7 +218,7 @@ function () {
218
218
  break;
219
219
 
220
220
  case 23:
221
- if (!noAuth) {
221
+ if (!(noAuth && this.client.signer && this.client.signer.remoteSigner && this.client.signer.unsignedPublicAuth)) {
222
222
  _context2.next = 25;
223
223
  break;
224
224
  }
@@ -614,24 +614,26 @@ function () {
614
614
  * @param {string=} authToken - Eluvio authorization token previously issued from OAuth ID token
615
615
  * @param {string=} tenantId - If specified, user will be associated with the tenant
616
616
  * @param {Object=} extraData - Additional data to pass to the login API
617
+ * @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)
617
618
  */
618
619
 
619
620
  }, {
620
621
  key: "SetRemoteSigner",
621
622
  value: function SetRemoteSigner(_ref9) {
622
- var idToken, authToken, tenantId, extraData, signer;
623
+ var idToken, authToken, tenantId, extraData, unsignedPublicAuth, signer;
623
624
  return _regeneratorRuntime.async(function SetRemoteSigner$(_context6) {
624
625
  while (1) {
625
626
  switch (_context6.prev = _context6.next) {
626
627
  case 0:
627
- idToken = _ref9.idToken, authToken = _ref9.authToken, tenantId = _ref9.tenantId, extraData = _ref9.extraData;
628
+ idToken = _ref9.idToken, authToken = _ref9.authToken, tenantId = _ref9.tenantId, extraData = _ref9.extraData, unsignedPublicAuth = _ref9.unsignedPublicAuth;
628
629
  signer = new RemoteSigner({
629
630
  rpcUris: this.authServiceURIs,
630
631
  idToken: idToken,
631
632
  authToken: authToken,
632
633
  tenantId: tenantId,
633
634
  provider: this.ethClient.provider,
634
- extraData: extraData
635
+ extraData: extraData,
636
+ unsignedPublicAuth: unsignedPublicAuth
635
637
  });
636
638
  _context6.next = 4;
637
639
  return _regeneratorRuntime.awrap(signer.Initialize());
@@ -34,12 +34,15 @@ function (_Ethers$Signer) {
34
34
  tenantId = _ref.tenantId,
35
35
  provider = _ref.provider,
36
36
  _ref$extraData = _ref.extraData,
37
- extraData = _ref$extraData === void 0 ? {} : _ref$extraData;
37
+ extraData = _ref$extraData === void 0 ? {} : _ref$extraData,
38
+ _ref$unsignedPublicAu = _ref.unsignedPublicAuth,
39
+ unsignedPublicAuth = _ref$unsignedPublicAu === void 0 ? false : _ref$unsignedPublicAu;
38
40
 
39
41
  _classCallCheck(this, RemoteSigner);
40
42
 
41
43
  _this = _possibleConstructorReturn(this, _getPrototypeOf(RemoteSigner).call(this));
42
44
  _this.remoteSigner = true;
45
+ _this.unsignedPublicAuth = unsignedPublicAuth;
43
46
  _this.HttpClient = new HttpClient({
44
47
  uris: rpcUris
45
48
  });
@@ -48,13 +51,14 @@ function (_Ethers$Signer) {
48
51
  _this.authToken = authToken;
49
52
  _this.extraLoginData = extraData || {};
50
53
  _this.provider = provider;
54
+ _this.signatureCache = {};
51
55
  return _this;
52
56
  }
53
57
 
54
58
  _createClass(RemoteSigner, [{
55
59
  key: "Initialize",
56
60
  value: function Initialize() {
57
- var _ref2, addr, eth, token, keys;
61
+ var _ref2, addr, eth, token, keys, address;
58
62
 
59
63
  return _regeneratorRuntime.async(function Initialize$(_context) {
60
64
  while (1) {
@@ -91,7 +95,7 @@ function (_Ethers$Signer) {
91
95
 
92
96
  case 10:
93
97
  if (this.address) {
94
- _context.next = 15;
98
+ _context.next = 16;
95
99
  break;
96
100
  }
97
101
 
@@ -106,13 +110,19 @@ function (_Ethers$Signer) {
106
110
 
107
111
  case 13:
108
112
  keys = _context.sent;
109
- this.address = Utils.HashToAddress(keys.eth[0]);
113
+ address = keys.eth[0];
110
114
 
111
- case 15:
115
+ if (address && address.startsWith("0x")) {
116
+ this.address = address;
117
+ } else {
118
+ this.address = Utils.HashToAddress(keys.eth[0]);
119
+ }
120
+
121
+ case 16:
112
122
  this.id = this.address ? "ikms".concat(Utils.AddressToHash(this.address)) : undefined;
113
123
  this.signer = this.provider.getSigner(this.address);
114
124
 
115
- case 17:
125
+ case 18:
116
126
  case "end":
117
127
  return _context.stop();
118
128
  }
@@ -134,32 +144,55 @@ function (_Ethers$Signer) {
134
144
  }, {
135
145
  key: "signDigest",
136
146
  value: function signDigest(digest) {
137
- var signature;
138
- return _regeneratorRuntime.async(function signDigest$(_context2) {
147
+ var _this2 = this;
148
+
149
+ return _regeneratorRuntime.async(function signDigest$(_context3) {
139
150
  while (1) {
140
- switch (_context2.prev = _context2.next) {
151
+ switch (_context3.prev = _context3.next) {
141
152
  case 0:
142
- _context2.next = 2;
143
- return _regeneratorRuntime.awrap(Utils.ResponseToJson(this.HttpClient.Request({
144
- method: "POST",
145
- path: UrlJoin("as", "wlt", "sign", "eth", this.id),
146
- headers: {
147
- Authorization: "Bearer ".concat(this.authToken)
148
- },
149
- body: {
150
- hash: digest
151
- }
152
- })));
153
+ if (!this.signatureCache[digest]) {
154
+ this.signatureCache[digest] = new Promise(function _callee(resolve) {
155
+ var signature;
156
+ return _regeneratorRuntime.async(function _callee$(_context2) {
157
+ while (1) {
158
+ switch (_context2.prev = _context2.next) {
159
+ case 0:
160
+ _context2.next = 2;
161
+ return _regeneratorRuntime.awrap(Utils.ResponseToJson(_this2.HttpClient.Request({
162
+ method: "POST",
163
+ path: UrlJoin("as", "wlt", "sign", "eth", _this2.id),
164
+ headers: {
165
+ Authorization: "Bearer ".concat(_this2.authToken)
166
+ },
167
+ body: {
168
+ hash: digest
169
+ }
170
+ })));
171
+
172
+ case 2:
173
+ signature = _context2.sent;
174
+ signature.v = parseInt(signature.v, 16);
175
+ signature.recoveryParam = signature.v - 27;
176
+ resolve(signature);
177
+
178
+ case 6:
179
+ case "end":
180
+ return _context2.stop();
181
+ }
182
+ }
183
+ });
184
+ });
185
+ }
153
186
 
154
- case 2:
155
- signature = _context2.sent;
156
- signature.v = parseInt(signature.v, 16);
157
- signature.recoveryParam = signature.v - 27;
158
- return _context2.abrupt("return", signature);
187
+ _context3.next = 3;
188
+ return _regeneratorRuntime.awrap(this.signatureCache[digest]);
159
189
 
160
- case 6:
190
+ case 3:
191
+ return _context3.abrupt("return", _context3.sent);
192
+
193
+ case 4:
161
194
  case "end":
162
- return _context2.stop();
195
+ return _context3.stop();
163
196
  }
164
197
  }
165
198
  }, null, this);
@@ -167,25 +200,25 @@ function (_Ethers$Signer) {
167
200
  }, {
168
201
  key: "signMessage",
169
202
  value: function signMessage(message) {
170
- return _regeneratorRuntime.async(function signMessage$(_context3) {
203
+ return _regeneratorRuntime.async(function signMessage$(_context4) {
171
204
  while (1) {
172
- switch (_context3.prev = _context3.next) {
205
+ switch (_context4.prev = _context4.next) {
173
206
  case 0:
174
- _context3.t0 = Promise;
175
- _context3.t1 = Ethers.utils;
176
- _context3.t2 = "0x";
177
- _context3.next = 5;
207
+ _context4.t0 = Promise;
208
+ _context4.t1 = Ethers.utils;
209
+ _context4.t2 = "0x";
210
+ _context4.next = 5;
178
211
  return _regeneratorRuntime.awrap(this.signDigest(Ethers.utils.hashMessage(message)));
179
212
 
180
213
  case 5:
181
- _context3.t3 = _context3.sent;
182
- _context3.t4 = _context3.t2.concat.call(_context3.t2, _context3.t3);
183
- _context3.t5 = _context3.t1.joinSignature.call(_context3.t1, _context3.t4);
184
- return _context3.abrupt("return", _context3.t0.resolve.call(_context3.t0, _context3.t5));
214
+ _context4.t3 = _context4.sent;
215
+ _context4.t4 = _context4.t2.concat.call(_context4.t2, _context4.t3);
216
+ _context4.t5 = _context4.t1.joinSignature.call(_context4.t1, _context4.t4);
217
+ return _context4.abrupt("return", _context4.t0.resolve.call(_context4.t0, _context4.t5));
185
218
 
186
219
  case 9:
187
220
  case "end":
188
- return _context3.stop();
221
+ return _context4.stop();
189
222
  }
190
223
  }
191
224
  }, null, this);
@@ -194,25 +227,25 @@ function (_Ethers$Signer) {
194
227
  key: "sign",
195
228
  value: function sign(transaction) {
196
229
  var signature;
197
- return _regeneratorRuntime.async(function sign$(_context4) {
230
+ return _regeneratorRuntime.async(function sign$(_context5) {
198
231
  while (1) {
199
- switch (_context4.prev = _context4.next) {
232
+ switch (_context5.prev = _context5.next) {
200
233
  case 0:
201
- _context4.next = 2;
234
+ _context5.next = 2;
202
235
  return _regeneratorRuntime.awrap(Ethers.utils.resolveProperties(transaction));
203
236
 
204
237
  case 2:
205
- transaction = _context4.sent;
206
- _context4.next = 5;
238
+ transaction = _context5.sent;
239
+ _context5.next = 5;
207
240
  return _regeneratorRuntime.awrap(this.signDigest(Ethers.utils.keccak256(Ethers.utils.serializeTransaction(transaction))));
208
241
 
209
242
  case 5:
210
- signature = _context4.sent;
211
- return _context4.abrupt("return", Ethers.utils.serializeTransaction(transaction, signature));
243
+ signature = _context5.sent;
244
+ return _context5.abrupt("return", Ethers.utils.serializeTransaction(transaction, signature));
212
245
 
213
246
  case 7:
214
247
  case "end":
215
- return _context4.stop();
248
+ return _context5.stop();
216
249
  }
217
250
  }
218
251
  }, null, this);
@@ -220,34 +253,34 @@ function (_Ethers$Signer) {
220
253
  }, {
221
254
  key: "sendTransaction",
222
255
  value: function sendTransaction(transaction) {
223
- var _this2 = this;
256
+ var _this3 = this;
224
257
 
225
- return _regeneratorRuntime.async(function sendTransaction$(_context5) {
258
+ return _regeneratorRuntime.async(function sendTransaction$(_context6) {
226
259
  while (1) {
227
- switch (_context5.prev = _context5.next) {
260
+ switch (_context6.prev = _context6.next) {
228
261
  case 0:
229
262
  if (!(transaction.nonce == null)) {
230
- _context5.next = 5;
263
+ _context6.next = 5;
231
264
  break;
232
265
  }
233
266
 
234
267
  transaction = Ethers.utils.shallowCopy(transaction);
235
- _context5.next = 4;
268
+ _context6.next = 4;
236
269
  return _regeneratorRuntime.awrap(this.provider.getTransactionCount(this.address, "pending"));
237
270
 
238
271
  case 4:
239
- transaction.nonce = _context5.sent;
272
+ transaction.nonce = _context6.sent;
240
273
 
241
274
  case 5:
242
- return _context5.abrupt("return", Ethers.utils.populateTransaction(transaction, this.provider, this.address).then(function (tx) {
243
- return _this2.sign(tx).then(function (signedTransaction) {
244
- return _this2.provider.sendTransaction(signedTransaction);
275
+ return _context6.abrupt("return", Ethers.utils.populateTransaction(transaction, this.provider, this.address).then(function (tx) {
276
+ return _this3.sign(tx).then(function (signedTransaction) {
277
+ return _this3.provider.sendTransaction(signedTransaction);
245
278
  });
246
279
  }));
247
280
 
248
281
  case 6:
249
282
  case "end":
250
- return _context5.stop();
283
+ return _context6.stop();
251
284
  }
252
285
  }
253
286
  }, null, this);
package/dist/src/Utils.js CHANGED
@@ -21,6 +21,8 @@ var BigNumber = require("bignumber.js")["default"];
21
21
  var VarInt = require("varint");
22
22
 
23
23
  var URI = require("urijs");
24
+
25
+ var keccak256 = require("ethers").utils.keccak256;
24
26
  /**
25
27
  * @namespace
26
28
  * @description This is a utility namespace mostly containing functions for managing
@@ -163,11 +165,13 @@ var Utils = {
163
165
  * Convert contract address to multiformat hash
164
166
  *
165
167
  * @param {string} address - Address of contract
168
+ * @param {boolean} key - Whether or not the first param is a public key. Defaults to address type
166
169
  *
167
170
  * @returns {string} - Hash of contract address
168
171
  */
169
172
  AddressToHash: function AddressToHash(address) {
170
- address = address.replace("0x", "");
173
+ var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
174
+ address = address.replace(key ? "0x04" : "0x", "");
171
175
  return bs58.encode(Buffer.from(address, "hex"));
172
176
  },
173
177
 
@@ -208,12 +212,14 @@ var Utils = {
208
212
  * Convert any content fabric ID to the corresponding contract address
209
213
  *
210
214
  * @param {string} hash - Hash to convert to address
215
+ * @param {boolean} key - Whether or not the first param is a key. Defaults to address type
211
216
  *
212
217
  * @returns {string} - Contract address of item
213
218
  */
214
219
  HashToAddress: function HashToAddress(hash) {
215
- hash = hash.substr(4);
216
- return Utils.FormatAddress("0x" + bs58.decode(hash).toString("hex"));
220
+ var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
221
+ hash = key ? hash : hash.substr(4);
222
+ return Utils.FormatAddress((key ? "0x04" : "0x") + bs58.decode(hash).toString("hex"));
217
223
  },
218
224
 
219
225
  /**
@@ -667,6 +673,20 @@ var Utils = {
667
673
  return JSON.parse(JSON.stringify(value));
668
674
  }
669
675
  },
676
+
677
+ /**
678
+ * Converts the given string to a public address
679
+ *
680
+ * @param key - Public key to convert to a public address
681
+ *
682
+ * @returns {string} - the public address
683
+ */
684
+ PublicKeyToAddress: function PublicKeyToAddress(key) {
685
+ var keyData = new Uint8Array(Buffer.from(key.replace("0x04", ""), "hex"));
686
+ var keccakHash = keccak256(keyData);
687
+ var address = "0x" + keccakHash.slice(26);
688
+ return Utils.FormatAddress(address);
689
+ },
670
690
  PLATFORM_NODE: "node",
671
691
  PLATFORM_WEB: "web",
672
692
  PLATFORM_REACT_NATIVE: "react-native",
@@ -2389,19 +2389,20 @@ exports.AvailableOfferings = function _callee30(_ref22) {
2389
2389
  * @param {Object=} context - Additional audience data to include in the authorization request.
2390
2390
  * - Note: Context must be a map of string->string
2391
2391
  * @param {Object=} authorizationToken - Additional authorization token for authorizing this request
2392
+ * @param {Object=} options - Additional query parameters to pass when requesting available playout options, such as clipping parameters.
2392
2393
  */
2393
2394
 
2394
2395
 
2395
2396
  exports.PlayoutOptions = function _callee33(_ref24) {
2396
2397
  var _this9 = this;
2397
2398
 
2398
- var offeringURI, objectId, versionHash, writeToken, linkPath, _ref24$signedLink, signedLink, _ref24$protocols, protocols, _ref24$handler, handler, _ref24$offering, offering, playoutType, _ref24$drms, drms, context, _ref24$hlsjsProfile, hlsjsProfile, authorizationToken, uriInfo, libraryId, offeringPath, link, _ref25, path, linkTarget, audienceData, authorization, queryParams, playoutOptions, playoutMap, sessionId, multiview, i, option, protocol, drm, playoutPath, licenseServers, cert, method, certUrl, protocolMatch, drmMatch;
2399
+ var offeringURI, objectId, versionHash, writeToken, linkPath, _ref24$signedLink, signedLink, _ref24$protocols, protocols, _ref24$handler, handler, _ref24$offering, offering, playoutType, _ref24$drms, drms, context, _ref24$hlsjsProfile, hlsjsProfile, authorizationToken, _ref24$options, options, uriInfo, libraryId, offeringPath, link, _ref25, path, linkTarget, audienceData, authorization, queryParams, playoutOptions, playoutMap, sessionId, multiview, i, option, protocol, drm, playoutPath, licenseServers, cert, method, certUrl, protocolMatch, drmMatch;
2399
2400
 
2400
2401
  return _regeneratorRuntime.async(function _callee33$(_context33) {
2401
2402
  while (1) {
2402
2403
  switch (_context33.prev = _context33.next) {
2403
2404
  case 0:
2404
- offeringURI = _ref24.offeringURI, objectId = _ref24.objectId, versionHash = _ref24.versionHash, writeToken = _ref24.writeToken, linkPath = _ref24.linkPath, _ref24$signedLink = _ref24.signedLink, signedLink = _ref24$signedLink === void 0 ? false : _ref24$signedLink, _ref24$protocols = _ref24.protocols, protocols = _ref24$protocols === void 0 ? ["dash", "hls"] : _ref24$protocols, _ref24$handler = _ref24.handler, handler = _ref24$handler === void 0 ? "playout" : _ref24$handler, _ref24$offering = _ref24.offering, offering = _ref24$offering === void 0 ? "default" : _ref24$offering, playoutType = _ref24.playoutType, _ref24$drms = _ref24.drms, drms = _ref24$drms === void 0 ? [] : _ref24$drms, context = _ref24.context, _ref24$hlsjsProfile = _ref24.hlsjsProfile, hlsjsProfile = _ref24$hlsjsProfile === void 0 ? true : _ref24$hlsjsProfile, authorizationToken = _ref24.authorizationToken;
2405
+ offeringURI = _ref24.offeringURI, objectId = _ref24.objectId, versionHash = _ref24.versionHash, writeToken = _ref24.writeToken, linkPath = _ref24.linkPath, _ref24$signedLink = _ref24.signedLink, signedLink = _ref24$signedLink === void 0 ? false : _ref24$signedLink, _ref24$protocols = _ref24.protocols, protocols = _ref24$protocols === void 0 ? ["dash", "hls"] : _ref24$protocols, _ref24$handler = _ref24.handler, handler = _ref24$handler === void 0 ? "playout" : _ref24$handler, _ref24$offering = _ref24.offering, offering = _ref24$offering === void 0 ? "default" : _ref24$offering, playoutType = _ref24.playoutType, _ref24$drms = _ref24.drms, drms = _ref24$drms === void 0 ? [] : _ref24$drms, context = _ref24.context, _ref24$hlsjsProfile = _ref24.hlsjsProfile, hlsjsProfile = _ref24$hlsjsProfile === void 0 ? true : _ref24$hlsjsProfile, authorizationToken = _ref24.authorizationToken, _ref24$options = _ref24.options, options = _ref24$options === void 0 ? {} : _ref24$options;
2405
2406
 
2406
2407
  if (!offeringURI) {
2407
2408
  _context33.next = 8;
@@ -2558,10 +2559,10 @@ exports.PlayoutOptions = function _callee33(_ref24) {
2558
2559
  };
2559
2560
 
2560
2561
  authorization = [_context33.t9, _context33.t10].flat().filter(_context33.t11);
2561
- queryParams = {
2562
+ queryParams = _objectSpread({
2562
2563
  authorization: authorization,
2563
2564
  resolve: !!linkPath
2564
- };
2565
+ }, options);
2565
2566
  _context33.t12 = Object;
2566
2567
  _context33.next = 61;
2567
2568
  return _regeneratorRuntime.awrap(this.utils.ResponseToJson(this.HttpClient.Request({
@@ -2825,17 +2826,18 @@ exports.PlayoutOptions = function _callee33(_ref24) {
2825
2826
  * @param {Object=} context - Additional audience data to include in the authorization request
2826
2827
  * - Note: Context must be a map of string->string
2827
2828
  * @param {Object=} authorizationToken - Additional authorization token for authorizing this request
2829
+ * @param {Object=} options - Additional query parameters to pass when requesting available playout options, such as clipping parameters.
2828
2830
  */
2829
2831
 
2830
2832
 
2831
2833
  exports.BitmovinPlayoutOptions = function _callee34(_ref27) {
2832
- var objectId, versionHash, writeToken, linkPath, _ref27$signedLink, signedLink, _ref27$protocols, protocols, _ref27$drms, drms, _ref27$handler, handler, _ref27$offering, offering, playoutType, context, authorizationToken, playoutOptions, _ref28, linkTarget, authorization, config;
2834
+ var objectId, versionHash, writeToken, linkPath, _ref27$signedLink, signedLink, _ref27$protocols, protocols, _ref27$drms, drms, _ref27$handler, handler, _ref27$offering, offering, playoutType, context, authorizationToken, _ref27$options, options, playoutOptions, _ref28, linkTarget, authorization, config;
2833
2835
 
2834
2836
  return _regeneratorRuntime.async(function _callee34$(_context34) {
2835
2837
  while (1) {
2836
2838
  switch (_context34.prev = _context34.next) {
2837
2839
  case 0:
2838
- objectId = _ref27.objectId, versionHash = _ref27.versionHash, writeToken = _ref27.writeToken, linkPath = _ref27.linkPath, _ref27$signedLink = _ref27.signedLink, signedLink = _ref27$signedLink === void 0 ? false : _ref27$signedLink, _ref27$protocols = _ref27.protocols, protocols = _ref27$protocols === void 0 ? ["dash", "hls"] : _ref27$protocols, _ref27$drms = _ref27.drms, drms = _ref27$drms === void 0 ? [] : _ref27$drms, _ref27$handler = _ref27.handler, handler = _ref27$handler === void 0 ? "playout" : _ref27$handler, _ref27$offering = _ref27.offering, offering = _ref27$offering === void 0 ? "default" : _ref27$offering, playoutType = _ref27.playoutType, context = _ref27.context, authorizationToken = _ref27.authorizationToken;
2840
+ objectId = _ref27.objectId, versionHash = _ref27.versionHash, writeToken = _ref27.writeToken, linkPath = _ref27.linkPath, _ref27$signedLink = _ref27.signedLink, signedLink = _ref27$signedLink === void 0 ? false : _ref27$signedLink, _ref27$protocols = _ref27.protocols, protocols = _ref27$protocols === void 0 ? ["dash", "hls"] : _ref27$protocols, _ref27$drms = _ref27.drms, drms = _ref27$drms === void 0 ? [] : _ref27$drms, _ref27$handler = _ref27.handler, handler = _ref27$handler === void 0 ? "playout" : _ref27$handler, _ref27$offering = _ref27.offering, offering = _ref27$offering === void 0 ? "default" : _ref27$offering, playoutType = _ref27.playoutType, context = _ref27.context, authorizationToken = _ref27.authorizationToken, _ref27$options = _ref27.options, options = _ref27$options === void 0 ? {} : _ref27$options;
2839
2841
  versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
2840
2842
 
2841
2843
  if (!objectId) {
@@ -2856,7 +2858,8 @@ exports.BitmovinPlayoutOptions = function _callee34(_ref27) {
2856
2858
  playoutType: playoutType,
2857
2859
  hlsjsProfile: false,
2858
2860
  context: context,
2859
- authorizationToken: authorizationToken
2861
+ authorizationToken: authorizationToken,
2862
+ options: options
2860
2863
  }));
2861
2864
 
2862
2865
  case 5:
@@ -32,8 +32,7 @@ var _require = require("../Validation"),
32
32
  ValidateVersion = _require.ValidateVersion,
33
33
  ValidateWriteToken = _require.ValidateWriteToken,
34
34
  ValidateParameters = _require.ValidateParameters,
35
- ValidatePresence = _require.ValidatePresence,
36
- ValidateAddress = _require.ValidateAddress;
35
+ ValidatePresence = _require.ValidatePresence;
37
36
 
38
37
  exports.SetVisibility = function _callee(_ref) {
39
38
  var id, visibility, hasSetVisibility, event;
@@ -448,19 +447,20 @@ exports.CreateContentType = function _callee3(_ref4) {
448
447
  * @param {Object=} metadata - Metadata of library object
449
448
  * @param {string=} kmsId - ID of the KMS to use for content in this library. If not specified,
450
449
  * the default KMS will be used.
450
+ * @param {string=} tenantId - ID of the tenant to use for this library
451
451
  *
452
452
  * @returns {Promise<string>} - Library ID of created library
453
453
  */
454
454
 
455
455
 
456
456
  exports.CreateContentLibrary = function _callee4(_ref6) {
457
- var name, description, image, imageName, _ref6$metadata, metadata, kmsId, _ref7, contractAddress, tenantId, libraryId, objectId, editResponse;
457
+ var name, description, image, imageName, _ref6$metadata, metadata, kmsId, tenantId, _ref7, contractAddress, libraryId, objectId, editResponse;
458
458
 
459
459
  return _regeneratorRuntime.async(function _callee4$(_context5) {
460
460
  while (1) {
461
461
  switch (_context5.prev = _context5.next) {
462
462
  case 0:
463
- name = _ref6.name, description = _ref6.description, image = _ref6.image, imageName = _ref6.imageName, _ref6$metadata = _ref6.metadata, metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata, kmsId = _ref6.kmsId;
463
+ name = _ref6.name, description = _ref6.description, image = _ref6.image, imageName = _ref6.imageName, _ref6$metadata = _ref6.metadata, metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata, kmsId = _ref6.kmsId, tenantId = _ref6.tenantId;
464
464
 
465
465
  if (kmsId) {
466
466
  _context5.next = 9;
@@ -488,25 +488,32 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
488
488
  case 13:
489
489
  _ref7 = _context5.sent;
490
490
  contractAddress = _ref7.contractAddress;
491
- _context5.next = 17;
491
+
492
+ if (tenantId) {
493
+ _context5.next = 19;
494
+ break;
495
+ }
496
+
497
+ _context5.next = 18;
492
498
  return _regeneratorRuntime.awrap(this.userProfileClient.TenantId());
493
499
 
494
- case 17:
500
+ case 18:
495
501
  tenantId = _context5.sent;
496
502
 
503
+ case 19:
497
504
  if (!tenantId) {
498
- _context5.next = 21;
505
+ _context5.next = 22;
499
506
  break;
500
507
  }
501
508
 
502
- _context5.next = 21;
509
+ _context5.next = 22;
503
510
  return _regeneratorRuntime.awrap(this.CallContractMethod({
504
511
  contractAddress: contractAddress,
505
512
  methodName: "putMeta",
506
513
  methodArgs: ["_tenantId", tenantId]
507
514
  }));
508
515
 
509
- case 21:
516
+ case 22:
510
517
  metadata = _objectSpread({}, metadata, {
511
518
  name: name,
512
519
  description: description,
@@ -520,15 +527,15 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
520
527
  this.Log("Contract address: ".concat(contractAddress)); // Set library content object type and metadata on automatically created library object
521
528
 
522
529
  objectId = libraryId.replace("ilib", "iq__");
523
- _context5.next = 28;
530
+ _context5.next = 29;
524
531
  return _regeneratorRuntime.awrap(this.EditContentObject({
525
532
  libraryId: libraryId,
526
533
  objectId: objectId
527
534
  }));
528
535
 
529
- case 28:
536
+ case 29:
530
537
  editResponse = _context5.sent;
531
- _context5.next = 31;
538
+ _context5.next = 32;
532
539
  return _regeneratorRuntime.awrap(this.ReplaceMetadata({
533
540
  libraryId: libraryId,
534
541
  objectId: objectId,
@@ -536,8 +543,8 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
536
543
  writeToken: editResponse.write_token
537
544
  }));
538
545
 
539
- case 31:
540
- _context5.next = 33;
546
+ case 32:
547
+ _context5.next = 34;
541
548
  return _regeneratorRuntime.awrap(this.FinalizeContentObject({
542
549
  libraryId: libraryId,
543
550
  objectId: objectId,
@@ -545,24 +552,24 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
545
552
  commitMessage: "Create library"
546
553
  }));
547
554
 
548
- case 33:
555
+ case 34:
549
556
  if (!image) {
550
- _context5.next = 36;
557
+ _context5.next = 37;
551
558
  break;
552
559
  }
553
560
 
554
- _context5.next = 36;
561
+ _context5.next = 37;
555
562
  return _regeneratorRuntime.awrap(this.SetContentLibraryImage({
556
563
  libraryId: libraryId,
557
564
  image: image,
558
565
  imageName: imageName
559
566
  }));
560
567
 
561
- case 36:
568
+ case 37:
562
569
  this.Log("Library ".concat(libraryId, " created"));
563
570
  return _context5.abrupt("return", libraryId);
564
571
 
565
- case 38:
572
+ case 39:
566
573
  case "end":
567
574
  return _context5.stop();
568
575
  }
@@ -1246,7 +1253,6 @@ exports.CopyContentObject = function _callee12(_ref15) {
1246
1253
  * @param {string} libraryId - ID of the library
1247
1254
  * @param {string} objectId - ID of the object
1248
1255
  * @param {string} publicKey - Public key for the target cap
1249
- * @param {string} publicAddress - Public address for the target cap key
1250
1256
  * @param {string} writeToken - Write token for the content object - If specified, info will be retrieved from the write draft instead of creating a new draft and finalizing
1251
1257
  *
1252
1258
  * @returns {Promise<Object>}
@@ -1254,37 +1260,37 @@ exports.CopyContentObject = function _callee12(_ref15) {
1254
1260
 
1255
1261
 
1256
1262
  exports.CreateNonOwnerCap = function _callee13(_ref17) {
1257
- var objectId, libraryId, publicKey, publicAddress, writeToken, userCapKey, userCapValue, userConk, targetUserCapKey, targetUserCapValue, finalize;
1263
+ var objectId, libraryId, publicKey, writeToken, userCapKey, userCapValue, userConk, publicAddress, targetUserCapKey, targetUserCapValue, finalize;
1258
1264
  return _regeneratorRuntime.async(function _callee13$(_context14) {
1259
1265
  while (1) {
1260
1266
  switch (_context14.prev = _context14.next) {
1261
1267
  case 0:
1262
- objectId = _ref17.objectId, libraryId = _ref17.libraryId, publicKey = _ref17.publicKey, publicAddress = _ref17.publicAddress, writeToken = _ref17.writeToken;
1263
- publicAddress = ValidateAddress(publicAddress);
1268
+ objectId = _ref17.objectId, libraryId = _ref17.libraryId, publicKey = _ref17.publicKey, writeToken = _ref17.writeToken;
1264
1269
  userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
1265
- _context14.next = 5;
1270
+ _context14.next = 4;
1266
1271
  return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
1267
1272
  objectId: objectId,
1268
1273
  libraryId: libraryId,
1269
1274
  metadataSubtree: userCapKey
1270
1275
  }));
1271
1276
 
1272
- case 5:
1277
+ case 4:
1273
1278
  userCapValue = _context14.sent;
1274
1279
 
1275
1280
  if (userCapValue) {
1276
- _context14.next = 8;
1281
+ _context14.next = 7;
1277
1282
  break;
1278
1283
  }
1279
1284
 
1280
1285
  throw Error("No user cap found for current user");
1281
1286
 
1282
- case 8:
1283
- _context14.next = 10;
1287
+ case 7:
1288
+ _context14.next = 9;
1284
1289
  return _regeneratorRuntime.awrap(this.Crypto.DecryptCap(userCapValue, this.signer.signingKey.privateKey));
1285
1290
 
1286
- case 10:
1291
+ case 9:
1287
1292
  userConk = _context14.sent;
1293
+ publicAddress = this.utils.PublicKeyToAddress(publicKey);
1288
1294
  targetUserCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(publicAddress));
1289
1295
  _context14.next = 14;
1290
1296
  return _regeneratorRuntime.awrap(this.Crypto.EncryptConk(userConk, publicKey));
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.83",
3
+ "version": "3.1.87",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.83",
3
+ "version": "3.1.87",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/ElvClient.js",
6
6
  "author": "Kevin Talmadge",
@@ -160,7 +160,7 @@ class AuthorizationClient {
160
160
  oauthToken
161
161
  });
162
162
  } else {
163
- if(noAuth) {
163
+ if(noAuth && this.client.signer && this.client.signer.remoteSigner && this.client.signer.unsignedPublicAuth) {
164
164
  return this.CreateStaticToken({libraryId});
165
165
  }
166
166