@eluvio/elv-client-js 4.0.108 → 4.0.110

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.
@@ -427,7 +427,7 @@ var StreamGenerateOffering = /*#__PURE__*/function () {
427
427
  */
428
428
  exports.StreamStatus = /*#__PURE__*/function () {
429
429
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref7) {
430
- var name, _ref7$stopLro, stopLro, _ref7$showParams, showParams, objectId, status, libraryId, mainMeta, fabURI, edgeWriteToken, edgeMeta, recordings, sequence, period, tlro, videoLastFinalizationTimeEpochSec, videoFinalizedParts, sinceLastFinalize, recording_period, insertions, i, insertionTimeSinceEpoch, state, lroStatus, playout_urls, playout_options, hls_clear_enabled, hls_aes128_enabled, hls_sample_aes_enabled, networkInfo, token, embed_net, embed_url;
430
+ var name, _ref7$stopLro, stopLro, _ref7$showParams, showParams, objectId, status, libraryId, mainMeta, fabURI, edgeWriteToken, edgeMeta, recordings, sequence, period, tlro, videoLastFinalizationTimeEpochSec, videoFinalizedParts, sinceLastFinalize, recording_period, insertions, i, insertionTimeSinceEpoch, state, lroStatus, segDurationMeta, playout_urls, playout_options, hls_clear_enabled, hls_aes128_enabled, hls_sample_aes_enabled, networkInfo, token, embed_net, embed_url;
431
431
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
432
432
  while (1) switch (_context4.prev = _context4.next) {
433
433
  case 0:
@@ -605,107 +605,107 @@ exports.StreamStatus = /*#__PURE__*/function () {
605
605
  status.error = _context4.t3.response;
606
606
  return _context4.abrupt("return", status);
607
607
  case 89:
608
- // Convert LRO 'state' to desired 'state'
608
+ segDurationMeta = edgeMeta.live_recording.recording_config.recording_params.xc_params.seg_duration; // Convert LRO 'state' to desired 'state'
609
609
  if (state === "running" && videoLastFinalizationTimeEpochSec <= 0) {
610
610
  state = "starting";
611
- } else if (state === "running" && sinceLastFinalize > 32.9) {
611
+ } else if (state === "running" && segDurationMeta !== undefined && sinceLastFinalize > parseInt(segDurationMeta) + 5) {
612
612
  state = "stalled";
613
613
  } else if (state == "terminated") {
614
614
  state = "stopped";
615
615
  }
616
616
  status.state = state;
617
617
  if (!((state === "running" || state === "stalled" || state === "starting") && stopLro)) {
618
- _context4.next = 110;
618
+ _context4.next = 111;
619
619
  break;
620
620
  }
621
- _context4.next = 94;
621
+ _context4.next = 95;
622
622
  return this.FabricUrl({
623
623
  libraryId: libraryId,
624
624
  objectId: objectId,
625
625
  writeToken: edgeWriteToken,
626
626
  call: "live/stop/" + tlro
627
627
  });
628
- case 94:
628
+ case 95:
629
629
  lroStopUrl = _context4.sent;
630
- _context4.prev = 95;
630
+ _context4.prev = 96;
631
631
  _context4.t4 = this.utils;
632
- _context4.next = 99;
632
+ _context4.next = 100;
633
633
  return HttpClient.Fetch(lroStopUrl);
634
- case 99:
634
+ case 100:
635
635
  _context4.t5 = _context4.sent;
636
- _context4.next = 102;
636
+ _context4.next = 103;
637
637
  return _context4.t4.ResponseToJson.call(_context4.t4, _context4.t5);
638
- case 102:
638
+ case 103:
639
639
  console.log("LRO Stop: ", lroStatus.body);
640
- _context4.next = 108;
640
+ _context4.next = 109;
641
641
  break;
642
- case 105:
643
- _context4.prev = 105;
644
- _context4.t6 = _context4["catch"](95);
642
+ case 106:
643
+ _context4.prev = 106;
644
+ _context4.t6 = _context4["catch"](96);
645
645
  console.log("LRO Stop (failed): ", _context4.t6.response.statusCode);
646
- case 108:
646
+ case 109:
647
647
  state = "stopped";
648
648
  status.state = state;
649
- case 110:
649
+ case 111:
650
650
  if (!(state === "running")) {
651
- _context4.next = 141;
651
+ _context4.next = 142;
652
652
  break;
653
653
  }
654
654
  playout_urls = {};
655
- _context4.next = 114;
655
+ _context4.next = 115;
656
656
  return this.PlayoutOptions({
657
657
  objectId: objectId,
658
658
  linkPath: "public/asset_metadata/sources/default"
659
659
  });
660
- case 114:
660
+ case 115:
661
661
  playout_options = _context4.sent;
662
662
  hls_clear_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods.clear !== undefined;
663
663
  if (!hls_clear_enabled) {
664
- _context4.next = 120;
664
+ _context4.next = 121;
665
665
  break;
666
666
  }
667
- _context4.next = 119;
667
+ _context4.next = 120;
668
668
  return this.FabricUrl({
669
669
  libraryId: libraryId,
670
670
  objectId: objectId,
671
671
  rep: "playout/default/hls-clear/playlist.m3u8"
672
672
  });
673
- case 119:
674
- playout_urls.hls_clear = _context4.sent;
675
673
  case 120:
674
+ playout_urls.hls_clear = _context4.sent;
675
+ case 121:
676
676
  hls_aes128_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods["aes-128"] !== undefined;
677
677
  if (!hls_aes128_enabled) {
678
- _context4.next = 125;
678
+ _context4.next = 126;
679
679
  break;
680
680
  }
681
- _context4.next = 124;
681
+ _context4.next = 125;
682
682
  return this.FabricUrl({
683
683
  libraryId: libraryId,
684
684
  objectId: objectId,
685
685
  rep: "playout/default/hls-aes128/playlist.m3u8"
686
686
  });
687
- case 124:
688
- playout_urls.hls_aes128 = _context4.sent;
689
687
  case 125:
688
+ playout_urls.hls_aes128 = _context4.sent;
689
+ case 126:
690
690
  hls_sample_aes_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods["sample-aes"] !== undefined;
691
691
  if (!hls_sample_aes_enabled) {
692
- _context4.next = 130;
692
+ _context4.next = 131;
693
693
  break;
694
694
  }
695
- _context4.next = 129;
695
+ _context4.next = 130;
696
696
  return this.FabricUrl({
697
697
  libraryId: libraryId,
698
698
  objectId: objectId,
699
699
  rep: "playout/default/hls-sample-aes/playlist.m3u8"
700
700
  });
701
- case 129:
702
- playout_urls.hls_sample_aes = _context4.sent;
703
701
  case 130:
704
- _context4.next = 132;
702
+ playout_urls.hls_sample_aes = _context4.sent;
703
+ case 131:
704
+ _context4.next = 133;
705
705
  return this.NetworkInfo();
706
- case 132:
706
+ case 133:
707
707
  networkInfo = _context4.sent;
708
- _context4.next = 135;
708
+ _context4.next = 136;
709
709
  return this.authClient.AuthorizationToken({
710
710
  libraryId: libraryId,
711
711
  objectId: objectId,
@@ -713,7 +713,7 @@ exports.StreamStatus = /*#__PURE__*/function () {
713
713
  noCache: true,
714
714
  noAuth: true
715
715
  });
716
- case 135:
716
+ case 136:
717
717
  token = _context4.sent;
718
718
  embed_net = "main";
719
719
  if (networkInfo.name.includes("demo")) {
@@ -722,20 +722,20 @@ exports.StreamStatus = /*#__PURE__*/function () {
722
722
  embed_url = "https://embed.v3.contentfabric.io/?net=".concat(embed_net, "&p&ct=h&oid=").concat(objectId, "&mt=lv&ath=").concat(token);
723
723
  playout_urls.embed_url = embed_url;
724
724
  status.playout_urls = playout_urls;
725
- case 141:
726
- _context4.next = 146;
725
+ case 142:
726
+ _context4.next = 147;
727
727
  break;
728
- case 143:
729
- _context4.prev = 143;
728
+ case 144:
729
+ _context4.prev = 144;
730
730
  _context4.t7 = _context4["catch"](3);
731
731
  console.error(_context4.t7);
732
- case 146:
733
- return _context4.abrupt("return", status);
734
732
  case 147:
733
+ return _context4.abrupt("return", status);
734
+ case 148:
735
735
  case "end":
736
736
  return _context4.stop();
737
737
  }
738
- }, _callee4, this, [[3, 143], [34, 40], [69, 83], [95, 105]]);
738
+ }, _callee4, this, [[3, 144], [34, 40], [69, 83], [96, 106]]);
739
739
  }));
740
740
  return function (_x4) {
741
741
  return _ref8.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.108",
3
+ "version": "4.0.110",
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
@@ -435,7 +435,7 @@ class ElvClient {
435
435
  const signer = wallet.AddAccountFromMnemonic({mnemonic: wallet.GenerateMnemonic()});
436
436
 
437
437
  this.SetSigner({signer, reset: false});
438
- this.SetStaticToken({token: staticToken});
438
+ await this.SetStaticToken({token: staticToken});
439
439
  }
440
440
 
441
441
  this.authClient = new AuthorizationClient({
@@ -623,7 +623,7 @@ class ElvClient {
623
623
  */
624
624
  async SpaceNodes({matchEndpoint, matchNodeId}={}) {
625
625
  let nodes;
626
- this.SetStaticToken();
626
+ await this.SetStaticToken();
627
627
 
628
628
  if(matchEndpoint) {
629
629
  ({nodes} = await this.utils.ResponseToJson(
@@ -664,7 +664,7 @@ class ElvClient {
664
664
  return match;
665
665
  });
666
666
  } else if(matchNodeId) {
667
- this.SetStaticToken();
667
+ await this.SetStaticToken();
668
668
  let node = await this.utils.ResponseToJson(
669
669
  this.HttpClient.Request({
670
670
  path: UrlJoin("nodes", matchNodeId),
@@ -877,7 +877,13 @@ class ElvClient {
877
877
  Sign
878
878
  }) {
879
879
  if(!Sign) {
880
- Sign = async message => this.authClient.Sign(message);
880
+ // Same as authClient.Sign, but authClient may not yet be initialized
881
+ Sign = async message =>
882
+ Ethers.utils.joinSignature(
883
+ this.signer.signDigest ?
884
+ await this.signer.signDigest(message) :
885
+ await this.signer._signingKey().signDigest(message)
886
+ );
881
887
  }
882
888
 
883
889
  if(addEthereumPrefix) {
@@ -1171,12 +1177,13 @@ class ElvClient {
1171
1177
  * @namedParams
1172
1178
  * @param {string=} token - The static token to use. If not provided, the default static token will be set.
1173
1179
  */
1174
- SetStaticToken({token}={}) {
1175
- if(!token) {
1176
- token = this.utils.B64(JSON.stringify({qspace_id: this.contentSpaceId}));
1180
+ async SetStaticToken({token}={}) {
1181
+ if(token) {
1182
+ this.staticToken = token;
1183
+ } else {
1184
+ this.CreateFabricToken({duration: 7 * 24 * 60 * 60 * 1000})
1185
+ .then(token => this.staticToken = token);
1177
1186
  }
1178
-
1179
- this.staticToken = token;
1180
1187
  }
1181
1188
 
1182
1189
  /**
@@ -1196,7 +1203,7 @@ class ElvClient {
1196
1203
  * @param {string} objectId - The ID of the policy object
1197
1204
  */
1198
1205
  async SetPolicyAuthorization({objectId}) {
1199
- this.SetStaticToken({
1206
+ await this.SetStaticToken({
1200
1207
  token: await this.GenerateStateChannelToken({objectId})
1201
1208
  });
1202
1209
  }
@@ -515,10 +515,12 @@ exports.StreamStatus = async function({name, stopLro=false, showParams=false}) {
515
515
  return status;
516
516
  }
517
517
 
518
+ const segDurationMeta = edgeMeta.live_recording.recording_config.recording_params.xc_params.seg_duration
519
+
518
520
  // Convert LRO 'state' to desired 'state'
519
521
  if(state === "running" && videoLastFinalizationTimeEpochSec <= 0) {
520
522
  state = "starting";
521
- } else if(state === "running" && sinceLastFinalize > 32.9) {
523
+ } else if(state === "running" && segDurationMeta !== undefined && sinceLastFinalize > (parseInt(segDurationMeta) + 5)) {
522
524
  state = "stalled";
523
525
  } else if(state == "terminated") {
524
526
  state = "stopped";