@eluvio/elv-client-js 4.0.105 → 4.0.108

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.
Files changed (41) hide show
  1. package/dist/ElvClient-min.js +14 -15
  2. package/dist/ElvClient-node-min.js +13 -14
  3. package/dist/ElvFrameClient-min.js +10 -10
  4. package/dist/ElvPermissionsClient-min.js +9 -9
  5. package/dist/ElvWalletClient-min.js +14 -15
  6. package/dist/ElvWalletClient-node-min.js +13 -14
  7. package/dist/src/AuthorizationClient.js +12 -9
  8. package/dist/src/ContentObjectAudit.js +3 -3
  9. package/dist/src/ContentObjectVerification.js +3 -3
  10. package/dist/src/Crypto.js +2 -2
  11. package/dist/src/ElvClient.js +28 -47
  12. package/dist/src/ElvWallet.js +5 -7
  13. package/dist/src/EthClient.js +9 -8
  14. package/dist/src/FrameClient.js +9 -8
  15. package/dist/src/HttpClient.js +2 -1
  16. package/dist/src/Id.js +2 -1
  17. package/dist/src/PermissionsClient.js +19 -31
  18. package/dist/src/RemoteSigner.js +8 -6
  19. package/dist/src/UserProfileClient.js +180 -167
  20. package/dist/src/Utils.js +3 -2
  21. package/dist/src/Validation.js +1 -13
  22. package/dist/src/client/ABRPublishing.js +2 -2
  23. package/dist/src/client/AccessGroups.js +2 -2
  24. package/dist/src/client/ContentAccess.js +3 -2
  25. package/dist/src/client/ContentManagement.js +3 -3
  26. package/dist/src/client/Contracts.js +433 -108
  27. package/dist/src/client/Files.js +2 -2
  28. package/dist/src/client/LiveConf.js +6 -4
  29. package/dist/src/client/LiveStream.js +231 -136
  30. package/dist/src/client/NFT.js +2 -2
  31. package/dist/src/walletClient/ClientMethods.js +2 -2
  32. package/dist/src/walletClient/Profile.js +2 -2
  33. package/dist/src/walletClient/Utils.js +2 -2
  34. package/dist/src/walletClient/index.js +14 -17
  35. package/package.json +1 -1
  36. package/src/UserProfileClient.js +20 -21
  37. package/src/Validation.js +0 -6
  38. package/src/client/Contracts.js +244 -42
  39. package/src/client/LiveConf.js +1 -1
  40. package/src/client/LiveStream.js +122 -44
  41. package/testScripts/TestAddTenantContractId.js +45 -4
@@ -498,25 +498,35 @@ exports.StreamStatus = /*#__PURE__*/function () {
498
498
  });
499
499
  status.edge_write_token = edgeWriteToken;
500
500
  status.stream_id = edgeWriteToken; // By convention the stream ID is its write token
501
- _context4.next = 36;
501
+ _context4.prev = 34;
502
+ _context4.next = 37;
502
503
  return this.ContentObjectMetadata({
503
504
  libraryId: libraryId,
504
505
  objectId: objectId,
505
506
  writeToken: edgeWriteToken,
506
507
  select: ["live_recording"]
507
508
  });
508
- case 36:
509
+ case 37:
509
510
  edgeMeta = _context4.sent;
510
- status.edge_meta_size = JSON.stringify(edgeMeta).length;
511
+ _context4.next = 45;
512
+ break;
513
+ case 40:
514
+ _context4.prev = 40;
515
+ _context4.t0 = _context4["catch"](34);
516
+ console.error("Unable to read edge write token metadata. Has token been deleted?", _context4.t0);
517
+ status.state = "inactive";
518
+ return _context4.abrupt("return", status);
519
+ case 45:
520
+ status.edge_meta_size = JSON.stringify(edgeMeta || "").length;
511
521
 
512
522
  // If a stream has never been started return state 'inactive'
513
523
  if (!(edgeMeta.live_recording === undefined || edgeMeta.live_recording.recordings === undefined || edgeMeta.live_recording.recordings.recording_sequence === undefined)) {
514
- _context4.next = 41;
524
+ _context4.next = 49;
515
525
  break;
516
526
  }
517
527
  status.state = "stopped";
518
528
  return _context4.abrupt("return", status);
519
- case 41:
529
+ case 49:
520
530
  recordings = edgeMeta.live_recording.recordings;
521
531
  status.recording_period_sequence = recordings.recording_sequence;
522
532
  sequence = recordings.recording_sequence;
@@ -542,14 +552,14 @@ exports.StreamStatus = /*#__PURE__*/function () {
542
552
  video_since_last_finalize_sec: sinceLastFinalize
543
553
  };
544
554
  status.recording_period = recording_period;
545
- _context4.next = 55;
555
+ _context4.next = 63;
546
556
  return this.FabricUrl({
547
557
  libraryId: libraryId,
548
558
  objectId: objectId,
549
559
  writeToken: edgeWriteToken,
550
560
  call: "live/status/" + tlro
551
561
  });
552
- case 55:
562
+ case 63:
553
563
  status.lro_status_url = _context4.sent;
554
564
  status.insertions = [];
555
565
  if (edgeMeta.live_recording.playout_config.interleaves != undefined && edgeMeta.live_recording.playout_config.interleaves[sequence] != undefined) {
@@ -569,15 +579,15 @@ exports.StreamStatus = /*#__PURE__*/function () {
569
579
  }
570
580
  state = "stopped";
571
581
  lroStatus = "";
572
- _context4.prev = 61;
573
- _context4.t0 = this.utils;
574
- _context4.next = 65;
582
+ _context4.prev = 69;
583
+ _context4.t1 = this.utils;
584
+ _context4.next = 73;
575
585
  return HttpClient.Fetch(status.lro_status_url);
576
- case 65:
577
- _context4.t1 = _context4.sent;
578
- _context4.next = 68;
579
- return _context4.t0.ResponseToJson.call(_context4.t0, _context4.t1);
580
- case 68:
586
+ case 73:
587
+ _context4.t2 = _context4.sent;
588
+ _context4.next = 76;
589
+ return _context4.t1.ResponseToJson.call(_context4.t1, _context4.t2);
590
+ case 76:
581
591
  lroStatus = _context4.sent;
582
592
  state = lroStatus.state;
583
593
  status.warnings = lroStatus.custom && lroStatus.custom.warnings;
@@ -585,16 +595,16 @@ exports.StreamStatus = /*#__PURE__*/function () {
585
595
  if (lroStatus.custom && lroStatus.custom.status) {
586
596
  status.recording_status = lroStatus.custom.status;
587
597
  }
588
- _context4.next = 81;
598
+ _context4.next = 89;
589
599
  break;
590
- case 75:
591
- _context4.prev = 75;
592
- _context4.t2 = _context4["catch"](61);
593
- console.log("LRO Status (failed): ", _context4.t2.response.statusCode);
600
+ case 83:
601
+ _context4.prev = 83;
602
+ _context4.t3 = _context4["catch"](69);
603
+ console.log("LRO Status (failed): ", _context4.t3.response.statusCode);
594
604
  status.state = "stopped";
595
- status.error = _context4.t2.response;
605
+ status.error = _context4.t3.response;
596
606
  return _context4.abrupt("return", status);
597
- case 81:
607
+ case 89:
598
608
  // Convert LRO 'state' to desired 'state'
599
609
  if (state === "running" && videoLastFinalizationTimeEpochSec <= 0) {
600
610
  state = "starting";
@@ -605,97 +615,97 @@ exports.StreamStatus = /*#__PURE__*/function () {
605
615
  }
606
616
  status.state = state;
607
617
  if (!((state === "running" || state === "stalled" || state === "starting") && stopLro)) {
608
- _context4.next = 102;
618
+ _context4.next = 110;
609
619
  break;
610
620
  }
611
- _context4.next = 86;
621
+ _context4.next = 94;
612
622
  return this.FabricUrl({
613
623
  libraryId: libraryId,
614
624
  objectId: objectId,
615
625
  writeToken: edgeWriteToken,
616
626
  call: "live/stop/" + tlro
617
627
  });
618
- case 86:
628
+ case 94:
619
629
  lroStopUrl = _context4.sent;
620
- _context4.prev = 87;
621
- _context4.t3 = this.utils;
622
- _context4.next = 91;
630
+ _context4.prev = 95;
631
+ _context4.t4 = this.utils;
632
+ _context4.next = 99;
623
633
  return HttpClient.Fetch(lroStopUrl);
624
- case 91:
625
- _context4.t4 = _context4.sent;
626
- _context4.next = 94;
627
- return _context4.t3.ResponseToJson.call(_context4.t3, _context4.t4);
628
- case 94:
634
+ case 99:
635
+ _context4.t5 = _context4.sent;
636
+ _context4.next = 102;
637
+ return _context4.t4.ResponseToJson.call(_context4.t4, _context4.t5);
638
+ case 102:
629
639
  console.log("LRO Stop: ", lroStatus.body);
630
- _context4.next = 100;
640
+ _context4.next = 108;
631
641
  break;
632
- case 97:
633
- _context4.prev = 97;
634
- _context4.t5 = _context4["catch"](87);
635
- console.log("LRO Stop (failed): ", _context4.t5.response.statusCode);
636
- case 100:
642
+ case 105:
643
+ _context4.prev = 105;
644
+ _context4.t6 = _context4["catch"](95);
645
+ console.log("LRO Stop (failed): ", _context4.t6.response.statusCode);
646
+ case 108:
637
647
  state = "stopped";
638
648
  status.state = state;
639
- case 102:
649
+ case 110:
640
650
  if (!(state === "running")) {
641
- _context4.next = 133;
651
+ _context4.next = 141;
642
652
  break;
643
653
  }
644
654
  playout_urls = {};
645
- _context4.next = 106;
655
+ _context4.next = 114;
646
656
  return this.PlayoutOptions({
647
657
  objectId: objectId,
648
658
  linkPath: "public/asset_metadata/sources/default"
649
659
  });
650
- case 106:
660
+ case 114:
651
661
  playout_options = _context4.sent;
652
662
  hls_clear_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods.clear !== undefined;
653
663
  if (!hls_clear_enabled) {
654
- _context4.next = 112;
664
+ _context4.next = 120;
655
665
  break;
656
666
  }
657
- _context4.next = 111;
667
+ _context4.next = 119;
658
668
  return this.FabricUrl({
659
669
  libraryId: libraryId,
660
670
  objectId: objectId,
661
671
  rep: "playout/default/hls-clear/playlist.m3u8"
662
672
  });
663
- case 111:
673
+ case 119:
664
674
  playout_urls.hls_clear = _context4.sent;
665
- case 112:
675
+ case 120:
666
676
  hls_aes128_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods["aes-128"] !== undefined;
667
677
  if (!hls_aes128_enabled) {
668
- _context4.next = 117;
678
+ _context4.next = 125;
669
679
  break;
670
680
  }
671
- _context4.next = 116;
681
+ _context4.next = 124;
672
682
  return this.FabricUrl({
673
683
  libraryId: libraryId,
674
684
  objectId: objectId,
675
685
  rep: "playout/default/hls-aes128/playlist.m3u8"
676
686
  });
677
- case 116:
687
+ case 124:
678
688
  playout_urls.hls_aes128 = _context4.sent;
679
- case 117:
689
+ case 125:
680
690
  hls_sample_aes_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods["sample-aes"] !== undefined;
681
691
  if (!hls_sample_aes_enabled) {
682
- _context4.next = 122;
692
+ _context4.next = 130;
683
693
  break;
684
694
  }
685
- _context4.next = 121;
695
+ _context4.next = 129;
686
696
  return this.FabricUrl({
687
697
  libraryId: libraryId,
688
698
  objectId: objectId,
689
699
  rep: "playout/default/hls-sample-aes/playlist.m3u8"
690
700
  });
691
- case 121:
701
+ case 129:
692
702
  playout_urls.hls_sample_aes = _context4.sent;
693
- case 122:
694
- _context4.next = 124;
703
+ case 130:
704
+ _context4.next = 132;
695
705
  return this.NetworkInfo();
696
- case 124:
706
+ case 132:
697
707
  networkInfo = _context4.sent;
698
- _context4.next = 127;
708
+ _context4.next = 135;
699
709
  return this.authClient.AuthorizationToken({
700
710
  libraryId: libraryId,
701
711
  objectId: objectId,
@@ -703,7 +713,7 @@ exports.StreamStatus = /*#__PURE__*/function () {
703
713
  noCache: true,
704
714
  noAuth: true
705
715
  });
706
- case 127:
716
+ case 135:
707
717
  token = _context4.sent;
708
718
  embed_net = "main";
709
719
  if (networkInfo.name.includes("demo")) {
@@ -712,20 +722,20 @@ exports.StreamStatus = /*#__PURE__*/function () {
712
722
  embed_url = "https://embed.v3.contentfabric.io/?net=".concat(embed_net, "&p&ct=h&oid=").concat(objectId, "&mt=lv&ath=").concat(token);
713
723
  playout_urls.embed_url = embed_url;
714
724
  status.playout_urls = playout_urls;
715
- case 133:
716
- _context4.next = 138;
725
+ case 141:
726
+ _context4.next = 146;
717
727
  break;
718
- case 135:
719
- _context4.prev = 135;
720
- _context4.t6 = _context4["catch"](3);
721
- console.error(_context4.t6);
722
- case 138:
728
+ case 143:
729
+ _context4.prev = 143;
730
+ _context4.t7 = _context4["catch"](3);
731
+ console.error(_context4.t7);
732
+ case 146:
723
733
  return _context4.abrupt("return", status);
724
- case 139:
734
+ case 147:
725
735
  case "end":
726
736
  return _context4.stop();
727
737
  }
728
- }, _callee4, this, [[3, 135], [61, 75], [87, 97]]);
738
+ }, _callee4, this, [[3, 143], [34, 40], [69, 83], [95, 105]]);
729
739
  }));
730
740
  return function (_x4) {
731
741
  return _ref8.apply(this, arguments);
@@ -823,6 +833,7 @@ exports.StreamCreate = /*#__PURE__*/function () {
823
833
  edge_write_token: edgeToken,
824
834
  state: "active" // indicates there is an active session (set to 'closed' when done)
825
835
  },
836
+
826
837
  fabric_config: {
827
838
  edge_write_token: edgeToken
828
839
  }
@@ -1465,6 +1476,7 @@ exports.StreamInsertion = /*#__PURE__*/function () {
1465
1476
  insertionInfo = {
1466
1477
  duration_sec: 0 // Minimum of video and audio duration
1467
1478
  };
1479
+
1468
1480
  ["video", "audio"].forEach(function (mt) {
1469
1481
  var stream = offeringMeta.media_struct.streams[mt];
1470
1482
  insertionInfo[mt] = {
@@ -2271,106 +2283,121 @@ exports.StreamCopyToVod = /*#__PURE__*/function () {
2271
2283
  *
2272
2284
  * @methodGroup Live Stream
2273
2285
  * @namedParams
2286
+ * @param {string=} libraryId - Library ID of the live stream
2274
2287
  * @param {string} objectId - Object ID of the live stream
2288
+ * @param {string=} writeToken - Write token of the draft
2275
2289
  * @param {Array<string>} types - Specify which type of watermark to remove. Possible values:
2276
2290
  * - "image"
2277
2291
  * - "text"
2292
+ * - "forensic"
2278
2293
  * @param {boolean=} finalize - If enabled, target object will be finalized after removing watermark
2279
2294
  *
2280
2295
  * @return {Promise<Object>} - The finalize response
2281
2296
  */
2282
2297
  exports.StreamRemoveWatermark = /*#__PURE__*/function () {
2283
2298
  var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref28) {
2284
- var objectId, types, _ref28$finalize, finalize, libraryId, _yield$this$EditConte3, writeToken, edgeWriteToken, recordingParamsPath, recordingMetadata, finalizeResponse;
2299
+ var libraryId, objectId, writeToken, types, _ref28$finalize, finalize, _yield$this$EditConte3, edgeWriteToken, metadataPath, objectMetadata, finalizeResponse;
2285
2300
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
2286
2301
  while (1) switch (_context15.prev = _context15.next) {
2287
2302
  case 0:
2288
- objectId = _ref28.objectId, types = _ref28.types, _ref28$finalize = _ref28.finalize, finalize = _ref28$finalize === void 0 ? true : _ref28$finalize;
2303
+ libraryId = _ref28.libraryId, objectId = _ref28.objectId, writeToken = _ref28.writeToken, types = _ref28.types, _ref28$finalize = _ref28.finalize, finalize = _ref28$finalize === void 0 ? true : _ref28$finalize;
2289
2304
  ValidateObject(objectId);
2290
- _context15.next = 4;
2305
+ if (libraryId) {
2306
+ _context15.next = 6;
2307
+ break;
2308
+ }
2309
+ _context15.next = 5;
2291
2310
  return this.ContentObjectLibraryId({
2292
2311
  objectId: objectId
2293
2312
  });
2294
- case 4:
2313
+ case 5:
2295
2314
  libraryId = _context15.sent;
2296
- _context15.next = 7;
2315
+ case 6:
2316
+ if (writeToken) {
2317
+ _context15.next = 11;
2318
+ break;
2319
+ }
2320
+ _context15.next = 9;
2297
2321
  return this.EditContentObject({
2298
2322
  objectId: objectId,
2299
2323
  libraryId: libraryId
2300
2324
  });
2301
- case 7:
2325
+ case 9:
2302
2326
  _yield$this$EditConte3 = _context15.sent;
2303
2327
  writeToken = _yield$this$EditConte3.writeToken;
2328
+ case 11:
2304
2329
  this.Log("Removing watermark types: ".concat(types.join(", "), " ").concat(libraryId, " ").concat(objectId));
2305
- _context15.next = 12;
2330
+ _context15.next = 14;
2306
2331
  return this.ContentObjectMetadata({
2307
2332
  objectId: objectId,
2308
2333
  libraryId: libraryId,
2309
2334
  metadataSubtree: "/live_recording/fabric_config/edge_write_token"
2310
2335
  });
2311
- case 12:
2336
+ case 14:
2312
2337
  edgeWriteToken = _context15.sent;
2313
- recordingParamsPath = "live_recording/recording_config/recording_params";
2314
- _context15.next = 16;
2338
+ metadataPath = "live_recording/playout_config";
2339
+ _context15.next = 18;
2315
2340
  return this.ContentObjectMetadata({
2316
2341
  libraryId: libraryId,
2317
2342
  objectId: objectId,
2318
2343
  writeToken: writeToken,
2319
- metadataSubtree: recordingParamsPath,
2344
+ metadataSubtree: metadataPath,
2320
2345
  resolveLinks: false
2321
2346
  });
2322
- case 16:
2323
- recordingMetadata = _context15.sent;
2324
- if (recordingMetadata) {
2325
- _context15.next = 19;
2347
+ case 18:
2348
+ objectMetadata = _context15.sent;
2349
+ if (objectMetadata) {
2350
+ _context15.next = 21;
2326
2351
  break;
2327
2352
  }
2328
- throw Error("Stream object must be configured");
2329
- case 19:
2353
+ throw Error("Stream object must be configured before removing a watermark");
2354
+ case 21:
2330
2355
  types.forEach(function (type) {
2331
2356
  if (type === "text") {
2332
- delete recordingMetadata.simple_watermark;
2357
+ delete objectMetadata.simple_watermark;
2333
2358
  } else if (type === "image") {
2334
- delete recordingMetadata.image_watermark;
2359
+ delete objectMetadata.image_watermark;
2360
+ } else if (type === "forensic") {
2361
+ delete objectMetadata.forensic_watermark;
2335
2362
  }
2336
2363
  });
2337
- _context15.next = 22;
2364
+ _context15.next = 24;
2338
2365
  return this.ReplaceMetadata({
2339
2366
  libraryId: libraryId,
2340
2367
  objectId: objectId,
2341
2368
  writeToken: writeToken,
2342
- metadataSubtree: recordingParamsPath,
2343
- metadata: recordingMetadata
2369
+ metadataSubtree: metadataPath,
2370
+ metadata: objectMetadata
2344
2371
  });
2345
- case 22:
2372
+ case 24:
2346
2373
  if (!edgeWriteToken) {
2347
- _context15.next = 25;
2374
+ _context15.next = 27;
2348
2375
  break;
2349
2376
  }
2350
- _context15.next = 25;
2377
+ _context15.next = 27;
2351
2378
  return this.ReplaceMetadata({
2352
2379
  libraryId: libraryId,
2353
2380
  objectId: objectId,
2354
2381
  writeToken: edgeWriteToken,
2355
- metadataSubtree: recordingParamsPath,
2356
- metadata: recordingMetadata
2382
+ metadataSubtree: metadataPath,
2383
+ metadata: objectMetadata
2357
2384
  });
2358
- case 25:
2385
+ case 27:
2359
2386
  if (!finalize) {
2360
- _context15.next = 30;
2387
+ _context15.next = 32;
2361
2388
  break;
2362
2389
  }
2363
- _context15.next = 28;
2390
+ _context15.next = 30;
2364
2391
  return this.FinalizeContentObject({
2365
2392
  libraryId: libraryId,
2366
2393
  objectId: objectId,
2367
2394
  writeToken: writeToken,
2368
2395
  commitMessage: "Watermark removed"
2369
2396
  });
2370
- case 28:
2397
+ case 30:
2371
2398
  finalizeResponse = _context15.sent;
2372
2399
  return _context15.abrupt("return", finalizeResponse);
2373
- case 30:
2400
+ case 32:
2374
2401
  case "end":
2375
2402
  return _context15.stop();
2376
2403
  }
@@ -2386,109 +2413,177 @@ exports.StreamRemoveWatermark = /*#__PURE__*/function () {
2386
2413
  *
2387
2414
  * @methodGroup Live Stream
2388
2415
  * @namedParams
2416
+ * @param {string=} libraryId - Library ID of the live stream
2389
2417
  * @param {string} objectId - Object ID of the live stream
2418
+ * @param {string=} writeToken - Write token of the draft
2390
2419
  * @param {Object} simpleWatermark - Text watermark
2391
2420
  * @param {Object} imageWatermark - Image watermark
2421
+ * @param {Object} forensicWatermark - Forensic watermark
2392
2422
  * @param {boolean=} finalize - If enabled, target object will be finalized after adding watermark
2423
+ * Watermark examples:
2424
+ *
2425
+ * Simple Watermark:
2426
+ {
2427
+ "font_color": "",
2428
+ "font_relative_height": 0,
2429
+ "shadow": false,
2430
+ "template": "",
2431
+ "timecode": "",
2432
+ "timecode_rate": 0,
2433
+ "x": "",
2434
+ "y": ""
2435
+ }
2436
+ *
2437
+ * Image watermark:
2438
+ {
2439
+ "image": "",
2440
+ "align_h": "",
2441
+ "align_v": "",
2442
+ "target_video_height": 0,
2443
+ "wm_enabled": false
2444
+ }
2445
+ *
2446
+ * Forensic watermark:
2447
+ {
2448
+ "algo": 6,
2449
+ "forensic_duration": 0,
2450
+ "forensic_start": "",
2451
+ "image_a": <path_to_image>,
2452
+ "image_b": <path_to_image>,
2453
+ "is_stub": true,
2454
+ "payload_bit_nb": 23,
2455
+ "wm_enabled": true
2456
+ }
2457
+ *
2393
2458
  *
2394
2459
  * @return {Promise<Object>} - The finalize response
2395
2460
  */
2396
2461
  exports.StreamAddWatermark = /*#__PURE__*/function () {
2397
2462
  var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref30) {
2398
- var objectId, simpleWatermark, imageWatermark, _ref30$finalize, finalize, libraryId, _yield$this$EditConte4, writeToken, edgeWriteToken, recordingParamsPath, recordingMetadata, response, finalizeResponse;
2463
+ var libraryId, objectId, writeToken, simpleWatermark, imageWatermark, forensicWatermark, _ref30$finalize, finalize, _yield$this$EditConte4, edgeWriteToken, watermarkType, metadataPath, objectMetadata, watermarkArgCount, response, finalizeResponse;
2399
2464
  return _regeneratorRuntime.wrap(function _callee16$(_context16) {
2400
2465
  while (1) switch (_context16.prev = _context16.next) {
2401
2466
  case 0:
2402
- objectId = _ref30.objectId, simpleWatermark = _ref30.simpleWatermark, imageWatermark = _ref30.imageWatermark, _ref30$finalize = _ref30.finalize, finalize = _ref30$finalize === void 0 ? true : _ref30$finalize;
2467
+ libraryId = _ref30.libraryId, objectId = _ref30.objectId, writeToken = _ref30.writeToken, simpleWatermark = _ref30.simpleWatermark, imageWatermark = _ref30.imageWatermark, forensicWatermark = _ref30.forensicWatermark, _ref30$finalize = _ref30.finalize, finalize = _ref30$finalize === void 0 ? true : _ref30$finalize;
2403
2468
  ValidateObject(objectId);
2404
- _context16.next = 4;
2469
+ if (libraryId) {
2470
+ _context16.next = 6;
2471
+ break;
2472
+ }
2473
+ _context16.next = 5;
2405
2474
  return this.ContentObjectLibraryId({
2406
2475
  objectId: objectId
2407
2476
  });
2408
- case 4:
2477
+ case 5:
2409
2478
  libraryId = _context16.sent;
2410
- _context16.next = 7;
2479
+ case 6:
2480
+ if (writeToken) {
2481
+ _context16.next = 11;
2482
+ break;
2483
+ }
2484
+ _context16.next = 9;
2411
2485
  return this.EditContentObject({
2412
2486
  objectId: objectId,
2413
2487
  libraryId: libraryId
2414
2488
  });
2415
- case 7:
2489
+ case 9:
2416
2490
  _yield$this$EditConte4 = _context16.sent;
2417
2491
  writeToken = _yield$this$EditConte4.writeToken;
2418
- _context16.next = 11;
2492
+ case 11:
2493
+ _context16.next = 13;
2419
2494
  return this.ContentObjectMetadata({
2420
2495
  objectId: objectId,
2421
2496
  libraryId: libraryId,
2422
2497
  metadataSubtree: "/live_recording/fabric_config/edge_write_token"
2423
2498
  });
2424
- case 11:
2499
+ case 13:
2425
2500
  edgeWriteToken = _context16.sent;
2426
- this.Log("Adding watermarking type: ".concat(imageWatermark ? "image" : "text", " ").concat(libraryId, " ").concat(objectId));
2427
- recordingParamsPath = "live_recording/recording_config/recording_params";
2428
- _context16.next = 16;
2501
+ watermarkType = imageWatermark ? "image" : forensicWatermark ? "forensic" : "text";
2502
+ metadataPath = "live_recording/playout_config";
2503
+ this.Log("Adding watermarking type: ".concat(watermarkType, " ").concat(libraryId, " ").concat(objectId));
2504
+ _context16.next = 19;
2429
2505
  return this.ContentObjectMetadata({
2430
2506
  libraryId: libraryId,
2431
2507
  objectId: objectId,
2432
2508
  writeToken: writeToken,
2433
- metadataSubtree: recordingParamsPath,
2509
+ metadataSubtree: metadataPath,
2434
2510
  resolveLinks: false
2435
2511
  });
2436
- case 16:
2437
- recordingMetadata = _context16.sent;
2438
- if (recordingMetadata) {
2439
- _context16.next = 19;
2512
+ case 19:
2513
+ objectMetadata = _context16.sent;
2514
+ if (objectMetadata) {
2515
+ _context16.next = 22;
2440
2516
  break;
2441
2517
  }
2442
- throw Error("Stream object must be configured");
2443
- case 19:
2518
+ throw Error("Stream object must be configured before adding a watermark");
2519
+ case 22:
2520
+ watermarkArgCount = [simpleWatermark, imageWatermark, forensicWatermark].filter(function (i) {
2521
+ return !!i;
2522
+ }).length;
2523
+ console.log("watermark arg count", watermarkArgCount);
2524
+ if (!(watermarkArgCount === 0)) {
2525
+ _context16.next = 28;
2526
+ break;
2527
+ }
2528
+ throw Error("No watermark was provided");
2529
+ case 28:
2530
+ if (!(watermarkArgCount > 1)) {
2531
+ _context16.next = 30;
2532
+ break;
2533
+ }
2534
+ throw Error("Only one watermark is allowed");
2535
+ case 30:
2444
2536
  if (simpleWatermark) {
2445
- recordingMetadata.simple_watermark = simpleWatermark;
2537
+ objectMetadata.simple_watermark = simpleWatermark;
2446
2538
  } else if (imageWatermark) {
2447
- recordingMetadata.image_watermark = imageWatermark;
2539
+ objectMetadata.image_watermark = imageWatermark;
2540
+ } else if (forensicWatermark) {
2541
+ objectMetadata.forensic_watermark = forensicWatermark;
2448
2542
  }
2449
- _context16.next = 22;
2543
+ _context16.next = 33;
2450
2544
  return this.ReplaceMetadata({
2451
2545
  libraryId: libraryId,
2452
2546
  objectId: objectId,
2453
2547
  writeToken: writeToken,
2454
- metadataSubtree: recordingParamsPath,
2455
- metadata: recordingMetadata
2548
+ metadataSubtree: metadataPath,
2549
+ metadata: objectMetadata
2456
2550
  });
2457
- case 22:
2551
+ case 33:
2458
2552
  if (!edgeWriteToken) {
2459
- _context16.next = 25;
2553
+ _context16.next = 36;
2460
2554
  break;
2461
2555
  }
2462
- _context16.next = 25;
2556
+ _context16.next = 36;
2463
2557
  return this.ReplaceMetadata({
2464
2558
  libraryId: libraryId,
2465
2559
  objectId: objectId,
2466
2560
  writeToken: edgeWriteToken,
2467
- metadataSubtree: recordingParamsPath,
2468
- metadata: recordingMetadata
2561
+ metadataSubtree: metadataPath,
2562
+ metadata: objectMetadata
2469
2563
  });
2470
- case 25:
2564
+ case 36:
2471
2565
  response = {
2472
- "imageWatermark": recordingMetadata.image_watermark,
2473
- "textWatermark": recordingMetadata.simple_watermark
2566
+ "imageWatermark": objectMetadata.image_watermark,
2567
+ "textWatermark": objectMetadata.simple_watermark,
2568
+ "forensicWatermark": objectMetadata.forensic_watermark
2474
2569
  };
2475
2570
  if (!finalize) {
2476
- _context16.next = 31;
2571
+ _context16.next = 42;
2477
2572
  break;
2478
2573
  }
2479
- _context16.next = 29;
2574
+ _context16.next = 40;
2480
2575
  return this.FinalizeContentObject({
2481
2576
  libraryId: libraryId,
2482
2577
  objectId: objectId,
2483
2578
  writeToken: writeToken,
2484
2579
  commitMessage: "Watermark set"
2485
2580
  });
2486
- case 29:
2581
+ case 40:
2487
2582
  finalizeResponse = _context16.sent;
2488
2583
  response.hash = finalizeResponse.hash;
2489
- case 31:
2584
+ case 42:
2490
2585
  return _context16.abrupt("return", response);
2491
- case 32:
2586
+ case 43:
2492
2587
  case "end":
2493
2588
  return _context16.stop();
2494
2589
  }