@eluvio/elv-client-js 3.1.84 → 3.1.88
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.
- package/dist/ElvClient-min.js +2 -2
- package/dist/ElvClient-node-min.js +3 -3
- package/dist/ElvFrameClient-min.js +1 -1
- package/dist/src/AuthorizationClient.js +1 -1
- package/dist/src/ElvClient.js +5 -3
- package/dist/src/RemoteSigner.js +78 -51
- package/dist/src/client/ContentAccess.js +10 -7
- package/dist/src/client/ContentManagement.js +25 -17
- package/package-lock.json +1 -1
- package/package.json +1 -1
- package/src/AuthorizationClient.js +1 -1
- package/src/ElvClient.js +4 -2
- package/src/RemoteSigner.js +27 -17
- package/src/UserProfileClient.js +7 -2
- package/src/Utils.js +30 -1
- package/src/client/ContentAccess.js +10 -4
- package/src/client/ContentManagement.js +10 -1
package/dist/src/ElvClient.js
CHANGED
|
@@ -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());
|
package/dist/src/RemoteSigner.js
CHANGED
|
@@ -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,6 +51,7 @@ 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
|
|
|
@@ -140,32 +144,55 @@ function (_Ethers$Signer) {
|
|
|
140
144
|
}, {
|
|
141
145
|
key: "signDigest",
|
|
142
146
|
value: function signDigest(digest) {
|
|
143
|
-
var
|
|
144
|
-
|
|
147
|
+
var _this2 = this;
|
|
148
|
+
|
|
149
|
+
return _regeneratorRuntime.async(function signDigest$(_context3) {
|
|
145
150
|
while (1) {
|
|
146
|
-
switch (
|
|
151
|
+
switch (_context3.prev = _context3.next) {
|
|
147
152
|
case 0:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
+
}
|
|
159
186
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
signature.v = parseInt(signature.v, 16);
|
|
163
|
-
signature.recoveryParam = signature.v - 27;
|
|
164
|
-
return _context2.abrupt("return", signature);
|
|
187
|
+
_context3.next = 3;
|
|
188
|
+
return _regeneratorRuntime.awrap(this.signatureCache[digest]);
|
|
165
189
|
|
|
166
|
-
case
|
|
190
|
+
case 3:
|
|
191
|
+
return _context3.abrupt("return", _context3.sent);
|
|
192
|
+
|
|
193
|
+
case 4:
|
|
167
194
|
case "end":
|
|
168
|
-
return
|
|
195
|
+
return _context3.stop();
|
|
169
196
|
}
|
|
170
197
|
}
|
|
171
198
|
}, null, this);
|
|
@@ -173,25 +200,25 @@ function (_Ethers$Signer) {
|
|
|
173
200
|
}, {
|
|
174
201
|
key: "signMessage",
|
|
175
202
|
value: function signMessage(message) {
|
|
176
|
-
return _regeneratorRuntime.async(function signMessage$(
|
|
203
|
+
return _regeneratorRuntime.async(function signMessage$(_context4) {
|
|
177
204
|
while (1) {
|
|
178
|
-
switch (
|
|
205
|
+
switch (_context4.prev = _context4.next) {
|
|
179
206
|
case 0:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
207
|
+
_context4.t0 = Promise;
|
|
208
|
+
_context4.t1 = Ethers.utils;
|
|
209
|
+
_context4.t2 = "0x";
|
|
210
|
+
_context4.next = 5;
|
|
184
211
|
return _regeneratorRuntime.awrap(this.signDigest(Ethers.utils.hashMessage(message)));
|
|
185
212
|
|
|
186
213
|
case 5:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return
|
|
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));
|
|
191
218
|
|
|
192
219
|
case 9:
|
|
193
220
|
case "end":
|
|
194
|
-
return
|
|
221
|
+
return _context4.stop();
|
|
195
222
|
}
|
|
196
223
|
}
|
|
197
224
|
}, null, this);
|
|
@@ -200,25 +227,25 @@ function (_Ethers$Signer) {
|
|
|
200
227
|
key: "sign",
|
|
201
228
|
value: function sign(transaction) {
|
|
202
229
|
var signature;
|
|
203
|
-
return _regeneratorRuntime.async(function sign$(
|
|
230
|
+
return _regeneratorRuntime.async(function sign$(_context5) {
|
|
204
231
|
while (1) {
|
|
205
|
-
switch (
|
|
232
|
+
switch (_context5.prev = _context5.next) {
|
|
206
233
|
case 0:
|
|
207
|
-
|
|
234
|
+
_context5.next = 2;
|
|
208
235
|
return _regeneratorRuntime.awrap(Ethers.utils.resolveProperties(transaction));
|
|
209
236
|
|
|
210
237
|
case 2:
|
|
211
|
-
transaction =
|
|
212
|
-
|
|
238
|
+
transaction = _context5.sent;
|
|
239
|
+
_context5.next = 5;
|
|
213
240
|
return _regeneratorRuntime.awrap(this.signDigest(Ethers.utils.keccak256(Ethers.utils.serializeTransaction(transaction))));
|
|
214
241
|
|
|
215
242
|
case 5:
|
|
216
|
-
signature =
|
|
217
|
-
return
|
|
243
|
+
signature = _context5.sent;
|
|
244
|
+
return _context5.abrupt("return", Ethers.utils.serializeTransaction(transaction, signature));
|
|
218
245
|
|
|
219
246
|
case 7:
|
|
220
247
|
case "end":
|
|
221
|
-
return
|
|
248
|
+
return _context5.stop();
|
|
222
249
|
}
|
|
223
250
|
}
|
|
224
251
|
}, null, this);
|
|
@@ -226,34 +253,34 @@ function (_Ethers$Signer) {
|
|
|
226
253
|
}, {
|
|
227
254
|
key: "sendTransaction",
|
|
228
255
|
value: function sendTransaction(transaction) {
|
|
229
|
-
var
|
|
256
|
+
var _this3 = this;
|
|
230
257
|
|
|
231
|
-
return _regeneratorRuntime.async(function sendTransaction$(
|
|
258
|
+
return _regeneratorRuntime.async(function sendTransaction$(_context6) {
|
|
232
259
|
while (1) {
|
|
233
|
-
switch (
|
|
260
|
+
switch (_context6.prev = _context6.next) {
|
|
234
261
|
case 0:
|
|
235
262
|
if (!(transaction.nonce == null)) {
|
|
236
|
-
|
|
263
|
+
_context6.next = 5;
|
|
237
264
|
break;
|
|
238
265
|
}
|
|
239
266
|
|
|
240
267
|
transaction = Ethers.utils.shallowCopy(transaction);
|
|
241
|
-
|
|
268
|
+
_context6.next = 4;
|
|
242
269
|
return _regeneratorRuntime.awrap(this.provider.getTransactionCount(this.address, "pending"));
|
|
243
270
|
|
|
244
271
|
case 4:
|
|
245
|
-
transaction.nonce =
|
|
272
|
+
transaction.nonce = _context6.sent;
|
|
246
273
|
|
|
247
274
|
case 5:
|
|
248
|
-
return
|
|
249
|
-
return
|
|
250
|
-
return
|
|
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);
|
|
251
278
|
});
|
|
252
279
|
}));
|
|
253
280
|
|
|
254
281
|
case 6:
|
|
255
282
|
case "end":
|
|
256
|
-
return
|
|
283
|
+
return _context6.stop();
|
|
257
284
|
}
|
|
258
285
|
}
|
|
259
286
|
}, null, this);
|
|
@@ -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:
|
|
@@ -447,19 +447,20 @@ exports.CreateContentType = function _callee3(_ref4) {
|
|
|
447
447
|
* @param {Object=} metadata - Metadata of library object
|
|
448
448
|
* @param {string=} kmsId - ID of the KMS to use for content in this library. If not specified,
|
|
449
449
|
* the default KMS will be used.
|
|
450
|
+
* @param {string=} tenantId - ID of the tenant to use for this library
|
|
450
451
|
*
|
|
451
452
|
* @returns {Promise<string>} - Library ID of created library
|
|
452
453
|
*/
|
|
453
454
|
|
|
454
455
|
|
|
455
456
|
exports.CreateContentLibrary = function _callee4(_ref6) {
|
|
456
|
-
var name, description, image, imageName, _ref6$metadata, metadata, kmsId, _ref7, contractAddress,
|
|
457
|
+
var name, description, image, imageName, _ref6$metadata, metadata, kmsId, tenantId, _ref7, contractAddress, libraryId, objectId, editResponse;
|
|
457
458
|
|
|
458
459
|
return _regeneratorRuntime.async(function _callee4$(_context5) {
|
|
459
460
|
while (1) {
|
|
460
461
|
switch (_context5.prev = _context5.next) {
|
|
461
462
|
case 0:
|
|
462
|
-
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;
|
|
463
464
|
|
|
464
465
|
if (kmsId) {
|
|
465
466
|
_context5.next = 9;
|
|
@@ -487,25 +488,32 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
|
|
|
487
488
|
case 13:
|
|
488
489
|
_ref7 = _context5.sent;
|
|
489
490
|
contractAddress = _ref7.contractAddress;
|
|
490
|
-
|
|
491
|
+
|
|
492
|
+
if (tenantId) {
|
|
493
|
+
_context5.next = 19;
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
_context5.next = 18;
|
|
491
498
|
return _regeneratorRuntime.awrap(this.userProfileClient.TenantId());
|
|
492
499
|
|
|
493
|
-
case
|
|
500
|
+
case 18:
|
|
494
501
|
tenantId = _context5.sent;
|
|
495
502
|
|
|
503
|
+
case 19:
|
|
496
504
|
if (!tenantId) {
|
|
497
|
-
_context5.next =
|
|
505
|
+
_context5.next = 22;
|
|
498
506
|
break;
|
|
499
507
|
}
|
|
500
508
|
|
|
501
|
-
_context5.next =
|
|
509
|
+
_context5.next = 22;
|
|
502
510
|
return _regeneratorRuntime.awrap(this.CallContractMethod({
|
|
503
511
|
contractAddress: contractAddress,
|
|
504
512
|
methodName: "putMeta",
|
|
505
513
|
methodArgs: ["_tenantId", tenantId]
|
|
506
514
|
}));
|
|
507
515
|
|
|
508
|
-
case
|
|
516
|
+
case 22:
|
|
509
517
|
metadata = _objectSpread({}, metadata, {
|
|
510
518
|
name: name,
|
|
511
519
|
description: description,
|
|
@@ -519,15 +527,15 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
|
|
|
519
527
|
this.Log("Contract address: ".concat(contractAddress)); // Set library content object type and metadata on automatically created library object
|
|
520
528
|
|
|
521
529
|
objectId = libraryId.replace("ilib", "iq__");
|
|
522
|
-
_context5.next =
|
|
530
|
+
_context5.next = 29;
|
|
523
531
|
return _regeneratorRuntime.awrap(this.EditContentObject({
|
|
524
532
|
libraryId: libraryId,
|
|
525
533
|
objectId: objectId
|
|
526
534
|
}));
|
|
527
535
|
|
|
528
|
-
case
|
|
536
|
+
case 29:
|
|
529
537
|
editResponse = _context5.sent;
|
|
530
|
-
_context5.next =
|
|
538
|
+
_context5.next = 32;
|
|
531
539
|
return _regeneratorRuntime.awrap(this.ReplaceMetadata({
|
|
532
540
|
libraryId: libraryId,
|
|
533
541
|
objectId: objectId,
|
|
@@ -535,8 +543,8 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
|
|
|
535
543
|
writeToken: editResponse.write_token
|
|
536
544
|
}));
|
|
537
545
|
|
|
538
|
-
case
|
|
539
|
-
_context5.next =
|
|
546
|
+
case 32:
|
|
547
|
+
_context5.next = 34;
|
|
540
548
|
return _regeneratorRuntime.awrap(this.FinalizeContentObject({
|
|
541
549
|
libraryId: libraryId,
|
|
542
550
|
objectId: objectId,
|
|
@@ -544,24 +552,24 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
|
|
|
544
552
|
commitMessage: "Create library"
|
|
545
553
|
}));
|
|
546
554
|
|
|
547
|
-
case
|
|
555
|
+
case 34:
|
|
548
556
|
if (!image) {
|
|
549
|
-
_context5.next =
|
|
557
|
+
_context5.next = 37;
|
|
550
558
|
break;
|
|
551
559
|
}
|
|
552
560
|
|
|
553
|
-
_context5.next =
|
|
561
|
+
_context5.next = 37;
|
|
554
562
|
return _regeneratorRuntime.awrap(this.SetContentLibraryImage({
|
|
555
563
|
libraryId: libraryId,
|
|
556
564
|
image: image,
|
|
557
565
|
imageName: imageName
|
|
558
566
|
}));
|
|
559
567
|
|
|
560
|
-
case
|
|
568
|
+
case 37:
|
|
561
569
|
this.Log("Library ".concat(libraryId, " created"));
|
|
562
570
|
return _context5.abrupt("return", libraryId);
|
|
563
571
|
|
|
564
|
-
case
|
|
572
|
+
case 39:
|
|
565
573
|
case "end":
|
|
566
574
|
return _context5.stop();
|
|
567
575
|
}
|
package/package-lock.json
CHANGED
package/package.json
CHANGED
|
@@ -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
|
|
package/src/ElvClient.js
CHANGED
|
@@ -598,15 +598,17 @@ class ElvClient {
|
|
|
598
598
|
* @param {string=} authToken - Eluvio authorization token previously issued from OAuth ID token
|
|
599
599
|
* @param {string=} tenantId - If specified, user will be associated with the tenant
|
|
600
600
|
* @param {Object=} extraData - Additional data to pass to the login API
|
|
601
|
+
* @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)
|
|
601
602
|
*/
|
|
602
|
-
async SetRemoteSigner({idToken, authToken, tenantId, extraData}) {
|
|
603
|
+
async SetRemoteSigner({idToken, authToken, tenantId, extraData, unsignedPublicAuth}) {
|
|
603
604
|
const signer = new RemoteSigner({
|
|
604
605
|
rpcUris: this.authServiceURIs,
|
|
605
606
|
idToken,
|
|
606
607
|
authToken,
|
|
607
608
|
tenantId,
|
|
608
609
|
provider: this.ethClient.provider,
|
|
609
|
-
extraData
|
|
610
|
+
extraData,
|
|
611
|
+
unsignedPublicAuth
|
|
610
612
|
});
|
|
611
613
|
|
|
612
614
|
await signer.Initialize();
|
package/src/RemoteSigner.js
CHANGED
|
@@ -10,11 +10,13 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
10
10
|
authToken,
|
|
11
11
|
tenantId,
|
|
12
12
|
provider,
|
|
13
|
-
extraData={}
|
|
13
|
+
extraData={},
|
|
14
|
+
unsignedPublicAuth=false
|
|
14
15
|
}) {
|
|
15
16
|
super();
|
|
16
17
|
|
|
17
18
|
this.remoteSigner = true;
|
|
19
|
+
this.unsignedPublicAuth = unsignedPublicAuth;
|
|
18
20
|
|
|
19
21
|
this.HttpClient = new HttpClient({uris: rpcUris});
|
|
20
22
|
this.idToken = idToken;
|
|
@@ -24,6 +26,8 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
24
26
|
this.extraLoginData = extraData || {};
|
|
25
27
|
|
|
26
28
|
this.provider = provider;
|
|
29
|
+
|
|
30
|
+
this.signatureCache = {};
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
async Initialize() {
|
|
@@ -80,23 +84,29 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
80
84
|
* @returns - the signed message as a hex string
|
|
81
85
|
*/
|
|
82
86
|
async signDigest(digest) {
|
|
83
|
-
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
if(!this.signatureCache[digest]) {
|
|
88
|
+
this.signatureCache[digest] = new Promise(async resolve => {
|
|
89
|
+
let signature = await Utils.ResponseToJson(
|
|
90
|
+
this.HttpClient.Request({
|
|
91
|
+
method: "POST",
|
|
92
|
+
path: UrlJoin("as", "wlt", "sign", "eth", this.id),
|
|
93
|
+
headers: {
|
|
94
|
+
Authorization: `Bearer ${this.authToken}`
|
|
95
|
+
},
|
|
96
|
+
body: {
|
|
97
|
+
hash: digest
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
signature.v = parseInt(signature.v, 16);
|
|
103
|
+
signature.recoveryParam = signature.v - 27;
|
|
104
|
+
|
|
105
|
+
resolve(signature);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
98
108
|
|
|
99
|
-
return
|
|
109
|
+
return await this.signatureCache[digest];
|
|
100
110
|
}
|
|
101
111
|
|
|
102
112
|
async signMessage(message) {
|
package/src/UserProfileClient.js
CHANGED
|
@@ -438,14 +438,19 @@ await client.userProfileClient.UserMetadata()
|
|
|
438
438
|
* Note: This method is not accessible to applications. Eluvio core will drop the request.
|
|
439
439
|
*
|
|
440
440
|
* @namedParams
|
|
441
|
-
* @param
|
|
441
|
+
* @param {string} id - The tenant ID in hash format
|
|
442
|
+
* @param {string} address - The group address to use in the hash if id is not provided
|
|
442
443
|
*/
|
|
443
444
|
async SetTenantId({id, address}) {
|
|
444
|
-
if(id && !id.startsWith("iten")) {
|
|
445
|
+
if(id && (!id.startsWith("iten") || !Utils.ValidHash(id))) {
|
|
445
446
|
throw Error(`Invalid tenant ID: ${id}`);
|
|
446
447
|
}
|
|
447
448
|
|
|
448
449
|
if(address) {
|
|
450
|
+
if(!Utils.ValidAddress(address)) {
|
|
451
|
+
throw Error(`Invalid address: ${address}`);
|
|
452
|
+
}
|
|
453
|
+
|
|
449
454
|
id = `iten${Utils.AddressToHash(address)}`;
|
|
450
455
|
}
|
|
451
456
|
|
package/src/Utils.js
CHANGED
|
@@ -6,7 +6,8 @@ const VarInt = require("varint");
|
|
|
6
6
|
const URI = require("urijs");
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
|
-
keccak256
|
|
9
|
+
keccak256,
|
|
10
|
+
getAddress
|
|
10
11
|
} = require("ethers").utils;
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -245,6 +246,34 @@ const Utils = {
|
|
|
245
246
|
return (Utils.HashToAddress(firstHash) === Utils.HashToAddress(secondHash));
|
|
246
247
|
},
|
|
247
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Determine whether the address is valid
|
|
251
|
+
*
|
|
252
|
+
* @param {string} address - Address to validate
|
|
253
|
+
*
|
|
254
|
+
* @returns {boolean} - Whether or not the address is valid
|
|
255
|
+
*/
|
|
256
|
+
ValidAddress: (address) => {
|
|
257
|
+
try {
|
|
258
|
+
getAddress(address);
|
|
259
|
+
return true;
|
|
260
|
+
} catch(error) {
|
|
261
|
+
this.Log(error);
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Determine whether the hash is valid
|
|
268
|
+
*
|
|
269
|
+
* @param {string} hash - Hash to validate
|
|
270
|
+
*
|
|
271
|
+
* @returns {boolean} - Whether or not the hash is valid
|
|
272
|
+
*/
|
|
273
|
+
ValidHash: (hash) => {
|
|
274
|
+
return Utils.ValidAddress(Utils.HashToAddress(hash));
|
|
275
|
+
},
|
|
276
|
+
|
|
248
277
|
/**
|
|
249
278
|
* Convert the specified string to a bytes32 string
|
|
250
279
|
*
|