@eluvio/elv-client-js 4.2.22 → 4.2.23
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 +1 -1
- package/dist/ElvClient-node-min.js +1 -1
- package/dist/ElvFrameClient-min.js +1 -1
- package/dist/ElvPermissionsClient-min.js +1 -1
- package/dist/ElvWalletClient-min.js +1 -1
- package/dist/ElvWalletClient-node-min.js +1 -1
- package/dist/src/AuthorizationClient.js +12 -7
- package/dist/src/ContentObjectAudit.js +1 -2
- package/dist/src/ElvClient.js +13 -25
- package/dist/src/FrameClient.js +1 -1
- package/dist/src/HttpClient.js +47 -90
- package/dist/src/RemoteSigner.js +70 -170
- package/dist/src/abr_profiles/abr_profile_live_drm.js +10 -0
- package/dist/src/client/ContentAccess.js +1154 -1196
- package/dist/src/client/ContentManagement.js +41 -67
- package/dist/src/client/LiveConf.js +84 -171
- package/dist/src/client/LiveStream.js +2115 -5213
- package/dist/src/client/NTP.js +77 -172
- package/package.json +1 -1
- package/src/Crypto.js +13 -1
- package/src/ElvClient.js +1 -3
- package/src/client/ContentAccess.js +2 -6
- package/src/client/ContentManagement.js +2 -6
- package/dist/src/ContentObjectVerification.js +0 -281
- package/dist/src/NetworkUrls.js +0 -8
- package/dist/src/live_recording_config_profiles/live_recording_config_default.js +0 -45
package/dist/src/client/NTP.js
CHANGED
|
@@ -244,53 +244,6 @@ exports.DeleteNTPInstance = /*#__PURE__*/function () {
|
|
|
244
244
|
};
|
|
245
245
|
}();
|
|
246
246
|
|
|
247
|
-
/**
|
|
248
|
-
* Generate a report for the specified NTP instance.
|
|
249
|
-
*
|
|
250
|
-
* @methodGroup NTP Instances
|
|
251
|
-
* @namedParams
|
|
252
|
-
* @param {string} tenantId - The ID of the tenant in which this NTP instance was created
|
|
253
|
-
* @param {string} ntpId - The ID of the NTP instance
|
|
254
|
-
* @param {string} password - The code associated with the NTP instance
|
|
255
|
-
* @param {string=} email - Email address associated with the code
|
|
256
|
-
*/
|
|
257
|
-
exports.ReportNTPInstance = /*#__PURE__*/function () {
|
|
258
|
-
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref9) {
|
|
259
|
-
var tenantId, ntpId, password, email, paramsJSON, res;
|
|
260
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
261
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
262
|
-
case 0:
|
|
263
|
-
tenantId = _ref9.tenantId, ntpId = _ref9.ntpId, password = _ref9.password, email = _ref9.email;
|
|
264
|
-
ValidatePresence("tenantId", tenantId);
|
|
265
|
-
ValidatePresence("ntpId", ntpId);
|
|
266
|
-
paramsJSON = [];
|
|
267
|
-
if (password) {
|
|
268
|
-
paramsJSON.push("pwd:".concat(password));
|
|
269
|
-
}
|
|
270
|
-
if (email) {
|
|
271
|
-
paramsJSON.push("eml:".concat(email));
|
|
272
|
-
}
|
|
273
|
-
_context5.next = 8;
|
|
274
|
-
return this.authClient.MakeKMSCall({
|
|
275
|
-
tenantId: tenantId,
|
|
276
|
-
methodName: "elv_updateOTPInstance",
|
|
277
|
-
params: [tenantId, ntpId, "report", JSON.stringify(paramsJSON), Date.now()],
|
|
278
|
-
paramTypes: ["string", "string", "string", "string", "int"]
|
|
279
|
-
});
|
|
280
|
-
case 8:
|
|
281
|
-
res = _context5.sent;
|
|
282
|
-
return _context5.abrupt("return", res || {});
|
|
283
|
-
case 10:
|
|
284
|
-
case "end":
|
|
285
|
-
return _context5.stop();
|
|
286
|
-
}
|
|
287
|
-
}, _callee5, this);
|
|
288
|
-
}));
|
|
289
|
-
return function (_x5) {
|
|
290
|
-
return _ref10.apply(this, arguments);
|
|
291
|
-
};
|
|
292
|
-
}();
|
|
293
|
-
|
|
294
247
|
/**
|
|
295
248
|
* Retrieve info for NTP instances in the specified tenant
|
|
296
249
|
*
|
|
@@ -303,14 +256,14 @@ exports.ReportNTPInstance = /*#__PURE__*/function () {
|
|
|
303
256
|
* @return {Object} - List of NTP instances along with pagination information
|
|
304
257
|
*/
|
|
305
258
|
exports.ListNTPInstances = /*#__PURE__*/function () {
|
|
306
|
-
var
|
|
307
|
-
var tenantId,
|
|
308
|
-
return _regeneratorRuntime.wrap(function
|
|
309
|
-
while (1) switch (
|
|
259
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref9) {
|
|
260
|
+
var tenantId, _ref9$count, count, _ref9$offset, offset, _yield$this$authClien2, Defs, Total;
|
|
261
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
262
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
310
263
|
case 0:
|
|
311
|
-
tenantId =
|
|
264
|
+
tenantId = _ref9.tenantId, _ref9$count = _ref9.count, count = _ref9$count === void 0 ? 10 : _ref9$count, _ref9$offset = _ref9.offset, offset = _ref9$offset === void 0 ? 0 : _ref9$offset;
|
|
312
265
|
ValidatePresence("tenantId", tenantId);
|
|
313
|
-
|
|
266
|
+
_context5.next = 4;
|
|
314
267
|
return this.authClient.MakeKMSCall({
|
|
315
268
|
tenantId: tenantId,
|
|
316
269
|
methodName: "elv_listOTPInfo",
|
|
@@ -319,10 +272,10 @@ exports.ListNTPInstances = /*#__PURE__*/function () {
|
|
|
319
272
|
signature: false
|
|
320
273
|
});
|
|
321
274
|
case 4:
|
|
322
|
-
_yield$this$authClien2 =
|
|
275
|
+
_yield$this$authClien2 = _context5.sent;
|
|
323
276
|
Defs = _yield$this$authClien2.Defs;
|
|
324
277
|
Total = _yield$this$authClien2.Total;
|
|
325
|
-
return
|
|
278
|
+
return _context5.abrupt("return", {
|
|
326
279
|
ntpInstances: Object.values(Defs || {}).map(FormatNTPInfo),
|
|
327
280
|
start: offset,
|
|
328
281
|
end: Math.min(Total, offset + count),
|
|
@@ -330,12 +283,12 @@ exports.ListNTPInstances = /*#__PURE__*/function () {
|
|
|
330
283
|
});
|
|
331
284
|
case 8:
|
|
332
285
|
case "end":
|
|
333
|
-
return
|
|
286
|
+
return _context5.stop();
|
|
334
287
|
}
|
|
335
|
-
},
|
|
288
|
+
}, _callee5, this);
|
|
336
289
|
}));
|
|
337
|
-
return function (
|
|
338
|
-
return
|
|
290
|
+
return function (_x5) {
|
|
291
|
+
return _ref10.apply(this, arguments);
|
|
339
292
|
};
|
|
340
293
|
}();
|
|
341
294
|
|
|
@@ -350,16 +303,16 @@ exports.ListNTPInstances = /*#__PURE__*/function () {
|
|
|
350
303
|
* @return {Object} - Info about the NTP instance
|
|
351
304
|
*/
|
|
352
305
|
exports.NTPInstance = /*#__PURE__*/function () {
|
|
353
|
-
var
|
|
306
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref11) {
|
|
354
307
|
var tenantId, ntpId;
|
|
355
|
-
return _regeneratorRuntime.wrap(function
|
|
356
|
-
while (1) switch (
|
|
308
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
309
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
357
310
|
case 0:
|
|
358
|
-
tenantId =
|
|
311
|
+
tenantId = _ref11.tenantId, ntpId = _ref11.ntpId;
|
|
359
312
|
ValidatePresence("tenantId", tenantId);
|
|
360
313
|
ValidatePresence("ntpId", ntpId);
|
|
361
|
-
|
|
362
|
-
|
|
314
|
+
_context6.t0 = FormatNTPInfo;
|
|
315
|
+
_context6.next = 6;
|
|
363
316
|
return this.authClient.MakeKMSCall({
|
|
364
317
|
tenantId: tenantId,
|
|
365
318
|
methodName: "elv_getOTPInfo",
|
|
@@ -368,16 +321,16 @@ exports.NTPInstance = /*#__PURE__*/function () {
|
|
|
368
321
|
signature: false
|
|
369
322
|
});
|
|
370
323
|
case 6:
|
|
371
|
-
|
|
372
|
-
return
|
|
324
|
+
_context6.t1 = _context6.sent;
|
|
325
|
+
return _context6.abrupt("return", (0, _context6.t0)(_context6.t1));
|
|
373
326
|
case 8:
|
|
374
327
|
case "end":
|
|
375
|
-
return
|
|
328
|
+
return _context6.stop();
|
|
376
329
|
}
|
|
377
|
-
},
|
|
330
|
+
}, _callee6, this);
|
|
378
331
|
}));
|
|
379
|
-
return function (
|
|
380
|
-
return
|
|
332
|
+
return function (_x6) {
|
|
333
|
+
return _ref12.apply(this, arguments);
|
|
381
334
|
};
|
|
382
335
|
}();
|
|
383
336
|
|
|
@@ -398,12 +351,12 @@ exports.NTPInstance = /*#__PURE__*/function () {
|
|
|
398
351
|
* @return {Promise<Object>} - The generated ticket code and additional information about the ticket.
|
|
399
352
|
*/
|
|
400
353
|
exports.IssueNTPCode = /*#__PURE__*/function () {
|
|
401
|
-
var
|
|
354
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref13) {
|
|
402
355
|
var tenantId, ntpId, email, maxRedemptions, options, params, paramTypes;
|
|
403
|
-
return _regeneratorRuntime.wrap(function
|
|
404
|
-
while (1) switch (
|
|
356
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
357
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
405
358
|
case 0:
|
|
406
|
-
tenantId =
|
|
359
|
+
tenantId = _ref13.tenantId, ntpId = _ref13.ntpId, email = _ref13.email, maxRedemptions = _ref13.maxRedemptions;
|
|
407
360
|
ValidatePresence("tenantId", tenantId);
|
|
408
361
|
ValidatePresence("ntpId", ntpId);
|
|
409
362
|
options = [];
|
|
@@ -415,22 +368,22 @@ exports.IssueNTPCode = /*#__PURE__*/function () {
|
|
|
415
368
|
}
|
|
416
369
|
params = [tenantId, ntpId, JSON.stringify(options), Date.now()];
|
|
417
370
|
paramTypes = ["string", "string", "string", "uint"];
|
|
418
|
-
|
|
371
|
+
_context7.next = 10;
|
|
419
372
|
return this.authClient.MakeKMSCall({
|
|
420
373
|
methodName: "elv_issueOTPCode",
|
|
421
374
|
params: params,
|
|
422
375
|
paramTypes: paramTypes
|
|
423
376
|
});
|
|
424
377
|
case 10:
|
|
425
|
-
return
|
|
378
|
+
return _context7.abrupt("return", _context7.sent);
|
|
426
379
|
case 11:
|
|
427
380
|
case "end":
|
|
428
|
-
return
|
|
381
|
+
return _context7.stop();
|
|
429
382
|
}
|
|
430
|
-
},
|
|
383
|
+
}, _callee7, this);
|
|
431
384
|
}));
|
|
432
|
-
return function (
|
|
433
|
-
return
|
|
385
|
+
return function (_x7) {
|
|
386
|
+
return _ref14.apply(this, arguments);
|
|
434
387
|
};
|
|
435
388
|
}();
|
|
436
389
|
|
|
@@ -451,13 +404,13 @@ exports.IssueNTPCode = /*#__PURE__*/function () {
|
|
|
451
404
|
* @return {Promise<Object>} - The generated signed ticket code and additional information about the ticket.
|
|
452
405
|
*/
|
|
453
406
|
exports.IssueSignedNTPCode = /*#__PURE__*/function () {
|
|
454
|
-
var
|
|
407
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref15) {
|
|
455
408
|
var tenantId, ntpId, email, maxRedemptions, result, signature, multiSig;
|
|
456
|
-
return _regeneratorRuntime.wrap(function
|
|
457
|
-
while (1) switch (
|
|
409
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
410
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
458
411
|
case 0:
|
|
459
|
-
tenantId =
|
|
460
|
-
|
|
412
|
+
tenantId = _ref15.tenantId, ntpId = _ref15.ntpId, email = _ref15.email, maxRedemptions = _ref15.maxRedemptions;
|
|
413
|
+
_context8.next = 3;
|
|
461
414
|
return this.IssueNTPCode({
|
|
462
415
|
tenantId: tenantId,
|
|
463
416
|
ntpId: ntpId,
|
|
@@ -465,75 +418,27 @@ exports.IssueSignedNTPCode = /*#__PURE__*/function () {
|
|
|
465
418
|
maxRedemptions: maxRedemptions
|
|
466
419
|
});
|
|
467
420
|
case 3:
|
|
468
|
-
result =
|
|
421
|
+
result = _context8.sent;
|
|
469
422
|
if (!result.token) {
|
|
470
|
-
|
|
423
|
+
_context8.next = 10;
|
|
471
424
|
break;
|
|
472
425
|
}
|
|
473
|
-
|
|
426
|
+
_context8.next = 7;
|
|
474
427
|
return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(result.token)));
|
|
475
428
|
case 7:
|
|
476
|
-
signature =
|
|
429
|
+
signature = _context8.sent;
|
|
477
430
|
multiSig = this.utils.FormatSignature(signature);
|
|
478
431
|
result.token = "".concat(result.token, ".").concat(this.utils.B64(multiSig));
|
|
479
432
|
case 10:
|
|
480
|
-
return
|
|
433
|
+
return _context8.abrupt("return", result);
|
|
481
434
|
case 11:
|
|
482
435
|
case "end":
|
|
483
|
-
return
|
|
484
|
-
}
|
|
485
|
-
}, _callee9, this);
|
|
486
|
-
}));
|
|
487
|
-
return function (_x9) {
|
|
488
|
-
return _ref18.apply(this, arguments);
|
|
489
|
-
};
|
|
490
|
-
}();
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* Check the status of the specified ticket/code without redeeming it.
|
|
494
|
-
*
|
|
495
|
-
* @methodGroup Tickets
|
|
496
|
-
* @namedParams
|
|
497
|
-
* @param {string} tenantId - The ID of the tenant from which the ticket was issued
|
|
498
|
-
* @param {string} ntpId - The ID of the NTP instance from which the ticket was issued
|
|
499
|
-
* @param {string} code - Access code
|
|
500
|
-
* @param {string=} email - Email address associated with the code
|
|
501
|
-
*
|
|
502
|
-
* @return {Promise<Object>} - Status information for the ticket
|
|
503
|
-
*/
|
|
504
|
-
exports.NTPStatus = /*#__PURE__*/function () {
|
|
505
|
-
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref19) {
|
|
506
|
-
var tenantId, ntpId, code, email, response;
|
|
507
|
-
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
508
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
509
|
-
case 0:
|
|
510
|
-
tenantId = _ref19.tenantId, ntpId = _ref19.ntpId, code = _ref19.code, email = _ref19.email;
|
|
511
|
-
ValidatePresence("tenantId", tenantId);
|
|
512
|
-
ValidatePresence("ntpId", ntpId);
|
|
513
|
-
ValidatePresence("code", code);
|
|
514
|
-
_context10.next = 6;
|
|
515
|
-
return this.HttpClient.Request({
|
|
516
|
-
method: "POST",
|
|
517
|
-
path: UrlJoin("ks", "otp", "ntp", tenantId, ntpId, "status"),
|
|
518
|
-
body: {
|
|
519
|
-
"_PASSWORD": code,
|
|
520
|
-
"_EMAIL": email
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
case 6:
|
|
524
|
-
response = _context10.sent;
|
|
525
|
-
_context10.next = 9;
|
|
526
|
-
return response.json();
|
|
527
|
-
case 9:
|
|
528
|
-
return _context10.abrupt("return", _context10.sent);
|
|
529
|
-
case 10:
|
|
530
|
-
case "end":
|
|
531
|
-
return _context10.stop();
|
|
436
|
+
return _context8.stop();
|
|
532
437
|
}
|
|
533
|
-
},
|
|
438
|
+
}, _callee8, this);
|
|
534
439
|
}));
|
|
535
|
-
return function (
|
|
536
|
-
return
|
|
440
|
+
return function (_x8) {
|
|
441
|
+
return _ref16.apply(this, arguments);
|
|
537
442
|
};
|
|
538
443
|
}();
|
|
539
444
|
|
|
@@ -552,12 +457,12 @@ exports.NTPStatus = /*#__PURE__*/function () {
|
|
|
552
457
|
* @return {Promise<string|Object>} - The object ID which the ticket is authorized to, or an object containing the object ID and NTP ID if `includeNTPId` is specified
|
|
553
458
|
*/
|
|
554
459
|
exports.RedeemCode = /*#__PURE__*/function () {
|
|
555
|
-
var
|
|
556
|
-
var issuer, tenantId, ntpId, code, email,
|
|
557
|
-
return _regeneratorRuntime.wrap(function
|
|
558
|
-
while (1) switch (
|
|
460
|
+
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref17) {
|
|
461
|
+
var issuer, tenantId, ntpId, code, email, _ref17$includeNTPId, includeNTPId, wallet, token, response, objectId, libraryId, Hash, codeHash, codeInfo, ak, sites, info, signer;
|
|
462
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
463
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
559
464
|
case 0:
|
|
560
|
-
issuer =
|
|
465
|
+
issuer = _ref17.issuer, tenantId = _ref17.tenantId, ntpId = _ref17.ntpId, code = _ref17.code, email = _ref17.email, _ref17$includeNTPId = _ref17.includeNTPId, includeNTPId = _ref17$includeNTPId === void 0 ? false : _ref17$includeNTPId;
|
|
561
466
|
wallet = this.GenerateWallet();
|
|
562
467
|
issuer = issuer || "";
|
|
563
468
|
if (!this.signer) {
|
|
@@ -568,15 +473,15 @@ exports.RedeemCode = /*#__PURE__*/function () {
|
|
|
568
473
|
});
|
|
569
474
|
}
|
|
570
475
|
if (!issuer.startsWith("iq__")) {
|
|
571
|
-
|
|
476
|
+
_context9.next = 8;
|
|
572
477
|
break;
|
|
573
478
|
}
|
|
574
479
|
ValidateObject(issuer);
|
|
575
|
-
|
|
480
|
+
_context9.next = 28;
|
|
576
481
|
break;
|
|
577
482
|
case 8:
|
|
578
483
|
if (!(issuer && !issuer.replace(/^\//, "").startsWith("otp/ntp/iten"))) {
|
|
579
|
-
|
|
484
|
+
_context9.next = 12;
|
|
580
485
|
break;
|
|
581
486
|
}
|
|
582
487
|
throw Error("Invalid issuer: " + issuer);
|
|
@@ -587,38 +492,38 @@ exports.RedeemCode = /*#__PURE__*/function () {
|
|
|
587
492
|
if (!issuer) {
|
|
588
493
|
issuer = UrlJoin("/otp", "ntp", tenantId, ntpId || "");
|
|
589
494
|
}
|
|
590
|
-
|
|
591
|
-
|
|
495
|
+
_context9.prev = 14;
|
|
496
|
+
_context9.next = 17;
|
|
592
497
|
return this.authClient.GenerateChannelContentToken({
|
|
593
498
|
issuer: issuer,
|
|
594
499
|
code: code,
|
|
595
500
|
email: email
|
|
596
501
|
});
|
|
597
502
|
case 17:
|
|
598
|
-
token =
|
|
503
|
+
token = _context9.sent;
|
|
599
504
|
this.SetStaticToken({
|
|
600
505
|
token: token
|
|
601
506
|
});
|
|
602
507
|
response = JSON.parse(this.utils.FromB64(token));
|
|
603
|
-
return
|
|
508
|
+
return _context9.abrupt("return", includeNTPId ? {
|
|
604
509
|
objectId: response.qid,
|
|
605
510
|
ntpId: response.oid
|
|
606
511
|
} : response.qid);
|
|
607
512
|
case 23:
|
|
608
|
-
|
|
609
|
-
|
|
513
|
+
_context9.prev = 23;
|
|
514
|
+
_context9.t0 = _context9["catch"](14);
|
|
610
515
|
this.Log("Failed to redeem code:", true);
|
|
611
|
-
this.Log(
|
|
612
|
-
throw
|
|
516
|
+
this.Log(_context9.t0, true);
|
|
517
|
+
throw _context9.t0;
|
|
613
518
|
case 28:
|
|
614
519
|
// Site selector
|
|
615
520
|
objectId = issuer;
|
|
616
|
-
|
|
521
|
+
_context9.next = 31;
|
|
617
522
|
return this.ContentObjectLibraryId({
|
|
618
523
|
objectId: objectId
|
|
619
524
|
});
|
|
620
525
|
case 31:
|
|
621
|
-
libraryId =
|
|
526
|
+
libraryId = _context9.sent;
|
|
622
527
|
Hash = function Hash(code) {
|
|
623
528
|
var chars = code.split("").map(function (code) {
|
|
624
529
|
return code.charCodeAt(0);
|
|
@@ -628,49 +533,49 @@ exports.RedeemCode = /*#__PURE__*/function () {
|
|
|
628
533
|
}, 0).toString();
|
|
629
534
|
};
|
|
630
535
|
codeHash = Hash(code);
|
|
631
|
-
|
|
536
|
+
_context9.next = 36;
|
|
632
537
|
return this.ContentObjectMetadata({
|
|
633
538
|
libraryId: libraryId,
|
|
634
539
|
objectId: objectId,
|
|
635
540
|
metadataSubtree: "public/codes/".concat(codeHash)
|
|
636
541
|
});
|
|
637
542
|
case 36:
|
|
638
|
-
codeInfo =
|
|
543
|
+
codeInfo = _context9.sent;
|
|
639
544
|
if (codeInfo) {
|
|
640
|
-
|
|
545
|
+
_context9.next = 40;
|
|
641
546
|
break;
|
|
642
547
|
}
|
|
643
548
|
this.Log("Code redemption failed:\n\t".concat(issuer, "\n\t").concat(code));
|
|
644
549
|
throw Error("Invalid code: " + code);
|
|
645
550
|
case 40:
|
|
646
551
|
ak = codeInfo.ak, sites = codeInfo.sites, info = codeInfo.info;
|
|
647
|
-
|
|
552
|
+
_context9.next = 43;
|
|
648
553
|
return wallet.AddAccountFromEncryptedPK({
|
|
649
554
|
encryptedPrivateKey: this.utils.FromB64(ak),
|
|
650
555
|
password: code
|
|
651
556
|
});
|
|
652
557
|
case 43:
|
|
653
|
-
signer =
|
|
558
|
+
signer = _context9.sent;
|
|
654
559
|
this.SetSigner({
|
|
655
560
|
signer: signer
|
|
656
561
|
});
|
|
657
562
|
|
|
658
563
|
// Ensure wallet is initialized
|
|
659
|
-
|
|
564
|
+
_context9.next = 47;
|
|
660
565
|
return this.userProfileClient.WalletAddress();
|
|
661
566
|
case 47:
|
|
662
|
-
return
|
|
567
|
+
return _context9.abrupt("return", {
|
|
663
568
|
addr: this.utils.FormatAddress(signer.address),
|
|
664
569
|
sites: sites,
|
|
665
570
|
info: info || {}
|
|
666
571
|
});
|
|
667
572
|
case 48:
|
|
668
573
|
case "end":
|
|
669
|
-
return
|
|
574
|
+
return _context9.stop();
|
|
670
575
|
}
|
|
671
|
-
},
|
|
576
|
+
}, _callee9, this, [[14, 23]]);
|
|
672
577
|
}));
|
|
673
|
-
return function (
|
|
674
|
-
return
|
|
578
|
+
return function (_x9) {
|
|
579
|
+
return _ref18.apply(this, arguments);
|
|
675
580
|
};
|
|
676
581
|
}();
|
package/package.json
CHANGED
package/src/Crypto.js
CHANGED
|
@@ -82,7 +82,19 @@ const Crypto = {
|
|
|
82
82
|
return Utils.B64(cap);
|
|
83
83
|
},
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
// accepts either a raw private key string (legacy usage) or a signer
|
|
86
|
+
async DecryptCap(encryptedCap, signerOrPrivateKey) {
|
|
87
|
+
let privateKey;
|
|
88
|
+
if(typeof signerOrPrivateKey === "string") {
|
|
89
|
+
privateKey = signerOrPrivateKey;
|
|
90
|
+
} else if(signerOrPrivateKey && signerOrPrivateKey.remoteSigner) {
|
|
91
|
+
return await signerOrPrivateKey.DecryptCap(encryptedCap);
|
|
92
|
+
} else if(signerOrPrivateKey && typeof signerOrPrivateKey._signingKey === "function") {
|
|
93
|
+
privateKey = signerOrPrivateKey._signingKey().privateKey;
|
|
94
|
+
} else {
|
|
95
|
+
throw Error("Crypto.DecryptCap: second argument must be a signer or a private key string");
|
|
96
|
+
}
|
|
97
|
+
|
|
86
98
|
const elvCrypto = await Crypto.ElvCrypto();
|
|
87
99
|
privateKey = new Uint8Array(Buffer.from(privateKey.replace("0x", ""), "hex"));
|
|
88
100
|
|
package/src/ElvClient.js
CHANGED
|
@@ -1348,9 +1348,7 @@ class ElvClient {
|
|
|
1348
1348
|
|
|
1349
1349
|
ValidatePresence("message", message);
|
|
1350
1350
|
|
|
1351
|
-
return this.
|
|
1352
|
-
await this.signer.DecryptCap(message) :
|
|
1353
|
-
await this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
|
|
1351
|
+
return await this.Crypto.DecryptCap(message, this.signer);
|
|
1354
1352
|
}
|
|
1355
1353
|
|
|
1356
1354
|
/**
|
|
@@ -2743,9 +2743,7 @@ exports.CreateEncryptionConk = async function({libraryId, objectId, versionHash,
|
|
|
2743
2743
|
});
|
|
2744
2744
|
|
|
2745
2745
|
if(existingUserCap) {
|
|
2746
|
-
this.encryptionConks[objectId] = this.
|
|
2747
|
-
await this.signer.DecryptCap(existingUserCap) :
|
|
2748
|
-
await this.Crypto.DecryptCap(existingUserCap, this.signer._signingKey().privateKey);
|
|
2746
|
+
this.encryptionConks[objectId] = await this.Crypto.DecryptCap(existingUserCap, this.signer);
|
|
2749
2747
|
} else {
|
|
2750
2748
|
this.encryptionConks[objectId] = await this.Crypto.GeneratePrimaryConk({
|
|
2751
2749
|
spaceId: this.contentSpaceId,
|
|
@@ -2848,9 +2846,7 @@ exports.EncryptionConk = async function({libraryId, objectId, versionHash, write
|
|
|
2848
2846
|
});
|
|
2849
2847
|
|
|
2850
2848
|
if(existingUserCap) {
|
|
2851
|
-
this.encryptionConks[objectId] = this.
|
|
2852
|
-
await this.signer.DecryptCap(existingUserCap) :
|
|
2853
|
-
await this.Crypto.DecryptCap(existingUserCap, this.signer._signingKey().privateKey);
|
|
2849
|
+
this.encryptionConks[objectId] = await this.Crypto.DecryptCap(existingUserCap, this.signer);
|
|
2854
2850
|
} else if(writeToken) {
|
|
2855
2851
|
await this.CreateEncryptionConk({libraryId, objectId, versionHash, writeToken, createKMSConk: false});
|
|
2856
2852
|
} else {
|
|
@@ -680,9 +680,7 @@ exports.CopyContentObject = async function({libraryId, originalVersionHash, opti
|
|
|
680
680
|
const userCapKey = `eluv.caps.iusr${this.utils.AddressToHash(this.signer.address)}`;
|
|
681
681
|
|
|
682
682
|
if(metadata[userCapKey]) {
|
|
683
|
-
const userConkKey = this.
|
|
684
|
-
await this.signer.DecryptCap(metadata[userCapKey]) :
|
|
685
|
-
await this.Crypto.DecryptCap(metadata[userCapKey], this.signer._signingKey().privateKey);
|
|
683
|
+
const userConkKey = await this.Crypto.DecryptCap(metadata[userCapKey], this.signer);
|
|
686
684
|
userConkKey.qid = objectId;
|
|
687
685
|
|
|
688
686
|
await this.ReplaceMetadata({
|
|
@@ -735,9 +733,7 @@ exports.CreateNonOwnerCap = async function({objectId, libraryId, publicKey, writ
|
|
|
735
733
|
throw Error("No user cap found for current user");
|
|
736
734
|
}
|
|
737
735
|
|
|
738
|
-
const userConk = this.
|
|
739
|
-
await this.signer.DecryptCap(userCapValue) :
|
|
740
|
-
await this.Crypto.DecryptCap(userCapValue, this.signer._signingKey().privateKey);
|
|
736
|
+
const userConk = await this.Crypto.DecryptCap(userCapValue, this.signer);
|
|
741
737
|
|
|
742
738
|
const publicAddress = this.utils.PublicKeyToAddress(publicKey);
|
|
743
739
|
|