@eluvio/elv-client-js 4.0.105 → 4.0.107

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.
@@ -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);
@@ -2271,106 +2281,121 @@ exports.StreamCopyToVod = /*#__PURE__*/function () {
2271
2281
  *
2272
2282
  * @methodGroup Live Stream
2273
2283
  * @namedParams
2284
+ * @param {string=} libraryId - Library ID of the live stream
2274
2285
  * @param {string} objectId - Object ID of the live stream
2286
+ * @param {string=} writeToken - Write token of the draft
2275
2287
  * @param {Array<string>} types - Specify which type of watermark to remove. Possible values:
2276
2288
  * - "image"
2277
2289
  * - "text"
2290
+ * - "forensic"
2278
2291
  * @param {boolean=} finalize - If enabled, target object will be finalized after removing watermark
2279
2292
  *
2280
2293
  * @return {Promise<Object>} - The finalize response
2281
2294
  */
2282
2295
  exports.StreamRemoveWatermark = /*#__PURE__*/function () {
2283
2296
  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;
2297
+ var libraryId, objectId, writeToken, types, _ref28$finalize, finalize, _yield$this$EditConte3, edgeWriteToken, metadataPath, objectMetadata, finalizeResponse;
2285
2298
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
2286
2299
  while (1) switch (_context15.prev = _context15.next) {
2287
2300
  case 0:
2288
- objectId = _ref28.objectId, types = _ref28.types, _ref28$finalize = _ref28.finalize, finalize = _ref28$finalize === void 0 ? true : _ref28$finalize;
2301
+ 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
2302
  ValidateObject(objectId);
2290
- _context15.next = 4;
2303
+ if (libraryId) {
2304
+ _context15.next = 6;
2305
+ break;
2306
+ }
2307
+ _context15.next = 5;
2291
2308
  return this.ContentObjectLibraryId({
2292
2309
  objectId: objectId
2293
2310
  });
2294
- case 4:
2311
+ case 5:
2295
2312
  libraryId = _context15.sent;
2296
- _context15.next = 7;
2313
+ case 6:
2314
+ if (writeToken) {
2315
+ _context15.next = 11;
2316
+ break;
2317
+ }
2318
+ _context15.next = 9;
2297
2319
  return this.EditContentObject({
2298
2320
  objectId: objectId,
2299
2321
  libraryId: libraryId
2300
2322
  });
2301
- case 7:
2323
+ case 9:
2302
2324
  _yield$this$EditConte3 = _context15.sent;
2303
2325
  writeToken = _yield$this$EditConte3.writeToken;
2326
+ case 11:
2304
2327
  this.Log("Removing watermark types: ".concat(types.join(", "), " ").concat(libraryId, " ").concat(objectId));
2305
- _context15.next = 12;
2328
+ _context15.next = 14;
2306
2329
  return this.ContentObjectMetadata({
2307
2330
  objectId: objectId,
2308
2331
  libraryId: libraryId,
2309
2332
  metadataSubtree: "/live_recording/fabric_config/edge_write_token"
2310
2333
  });
2311
- case 12:
2334
+ case 14:
2312
2335
  edgeWriteToken = _context15.sent;
2313
- recordingParamsPath = "live_recording/recording_config/recording_params";
2314
- _context15.next = 16;
2336
+ metadataPath = "live_recording/playout_config";
2337
+ _context15.next = 18;
2315
2338
  return this.ContentObjectMetadata({
2316
2339
  libraryId: libraryId,
2317
2340
  objectId: objectId,
2318
2341
  writeToken: writeToken,
2319
- metadataSubtree: recordingParamsPath,
2342
+ metadataSubtree: metadataPath,
2320
2343
  resolveLinks: false
2321
2344
  });
2322
- case 16:
2323
- recordingMetadata = _context15.sent;
2324
- if (recordingMetadata) {
2325
- _context15.next = 19;
2345
+ case 18:
2346
+ objectMetadata = _context15.sent;
2347
+ if (objectMetadata) {
2348
+ _context15.next = 21;
2326
2349
  break;
2327
2350
  }
2328
- throw Error("Stream object must be configured");
2329
- case 19:
2351
+ throw Error("Stream object must be configured before removing a watermark");
2352
+ case 21:
2330
2353
  types.forEach(function (type) {
2331
2354
  if (type === "text") {
2332
- delete recordingMetadata.simple_watermark;
2355
+ delete objectMetadata.simple_watermark;
2333
2356
  } else if (type === "image") {
2334
- delete recordingMetadata.image_watermark;
2357
+ delete objectMetadata.image_watermark;
2358
+ } else if (type === "forensic") {
2359
+ delete objectMetadata.forensic_watermark;
2335
2360
  }
2336
2361
  });
2337
- _context15.next = 22;
2362
+ _context15.next = 24;
2338
2363
  return this.ReplaceMetadata({
2339
2364
  libraryId: libraryId,
2340
2365
  objectId: objectId,
2341
2366
  writeToken: writeToken,
2342
- metadataSubtree: recordingParamsPath,
2343
- metadata: recordingMetadata
2367
+ metadataSubtree: metadataPath,
2368
+ metadata: objectMetadata
2344
2369
  });
2345
- case 22:
2370
+ case 24:
2346
2371
  if (!edgeWriteToken) {
2347
- _context15.next = 25;
2372
+ _context15.next = 27;
2348
2373
  break;
2349
2374
  }
2350
- _context15.next = 25;
2375
+ _context15.next = 27;
2351
2376
  return this.ReplaceMetadata({
2352
2377
  libraryId: libraryId,
2353
2378
  objectId: objectId,
2354
2379
  writeToken: edgeWriteToken,
2355
- metadataSubtree: recordingParamsPath,
2356
- metadata: recordingMetadata
2380
+ metadataSubtree: metadataPath,
2381
+ metadata: objectMetadata
2357
2382
  });
2358
- case 25:
2383
+ case 27:
2359
2384
  if (!finalize) {
2360
- _context15.next = 30;
2385
+ _context15.next = 32;
2361
2386
  break;
2362
2387
  }
2363
- _context15.next = 28;
2388
+ _context15.next = 30;
2364
2389
  return this.FinalizeContentObject({
2365
2390
  libraryId: libraryId,
2366
2391
  objectId: objectId,
2367
2392
  writeToken: writeToken,
2368
2393
  commitMessage: "Watermark removed"
2369
2394
  });
2370
- case 28:
2395
+ case 30:
2371
2396
  finalizeResponse = _context15.sent;
2372
2397
  return _context15.abrupt("return", finalizeResponse);
2373
- case 30:
2398
+ case 32:
2374
2399
  case "end":
2375
2400
  return _context15.stop();
2376
2401
  }
@@ -2386,109 +2411,177 @@ exports.StreamRemoveWatermark = /*#__PURE__*/function () {
2386
2411
  *
2387
2412
  * @methodGroup Live Stream
2388
2413
  * @namedParams
2414
+ * @param {string=} libraryId - Library ID of the live stream
2389
2415
  * @param {string} objectId - Object ID of the live stream
2416
+ * @param {string=} writeToken - Write token of the draft
2390
2417
  * @param {Object} simpleWatermark - Text watermark
2391
2418
  * @param {Object} imageWatermark - Image watermark
2419
+ * @param {Object} forensicWatermark - Forensic watermark
2392
2420
  * @param {boolean=} finalize - If enabled, target object will be finalized after adding watermark
2421
+ * Watermark examples:
2422
+ *
2423
+ * Simple Watermark:
2424
+ {
2425
+ "font_color": "",
2426
+ "font_relative_height": 0,
2427
+ "shadow": false,
2428
+ "template": "",
2429
+ "timecode": "",
2430
+ "timecode_rate": 0,
2431
+ "x": "",
2432
+ "y": ""
2433
+ }
2434
+ *
2435
+ * Image watermark:
2436
+ {
2437
+ "image": "",
2438
+ "align_h": "",
2439
+ "align_v": "",
2440
+ "target_video_height": 0,
2441
+ "wm_enabled": false
2442
+ }
2443
+ *
2444
+ * Forensic watermark:
2445
+ {
2446
+ "algo": 6,
2447
+ "forensic_duration": 0,
2448
+ "forensic_start": "",
2449
+ "image_a": <path_to_image>,
2450
+ "image_b": <path_to_image>,
2451
+ "is_stub": true,
2452
+ "payload_bit_nb": 23,
2453
+ "wm_enabled": true
2454
+ }
2455
+ *
2393
2456
  *
2394
2457
  * @return {Promise<Object>} - The finalize response
2395
2458
  */
2396
2459
  exports.StreamAddWatermark = /*#__PURE__*/function () {
2397
2460
  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;
2461
+ var libraryId, objectId, writeToken, simpleWatermark, imageWatermark, forensicWatermark, _ref30$finalize, finalize, _yield$this$EditConte4, edgeWriteToken, watermarkType, metadataPath, objectMetadata, watermarkArgCount, response, finalizeResponse;
2399
2462
  return _regeneratorRuntime.wrap(function _callee16$(_context16) {
2400
2463
  while (1) switch (_context16.prev = _context16.next) {
2401
2464
  case 0:
2402
- objectId = _ref30.objectId, simpleWatermark = _ref30.simpleWatermark, imageWatermark = _ref30.imageWatermark, _ref30$finalize = _ref30.finalize, finalize = _ref30$finalize === void 0 ? true : _ref30$finalize;
2465
+ 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
2466
  ValidateObject(objectId);
2404
- _context16.next = 4;
2467
+ if (libraryId) {
2468
+ _context16.next = 6;
2469
+ break;
2470
+ }
2471
+ _context16.next = 5;
2405
2472
  return this.ContentObjectLibraryId({
2406
2473
  objectId: objectId
2407
2474
  });
2408
- case 4:
2475
+ case 5:
2409
2476
  libraryId = _context16.sent;
2410
- _context16.next = 7;
2477
+ case 6:
2478
+ if (writeToken) {
2479
+ _context16.next = 11;
2480
+ break;
2481
+ }
2482
+ _context16.next = 9;
2411
2483
  return this.EditContentObject({
2412
2484
  objectId: objectId,
2413
2485
  libraryId: libraryId
2414
2486
  });
2415
- case 7:
2487
+ case 9:
2416
2488
  _yield$this$EditConte4 = _context16.sent;
2417
2489
  writeToken = _yield$this$EditConte4.writeToken;
2418
- _context16.next = 11;
2490
+ case 11:
2491
+ _context16.next = 13;
2419
2492
  return this.ContentObjectMetadata({
2420
2493
  objectId: objectId,
2421
2494
  libraryId: libraryId,
2422
2495
  metadataSubtree: "/live_recording/fabric_config/edge_write_token"
2423
2496
  });
2424
- case 11:
2497
+ case 13:
2425
2498
  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;
2499
+ watermarkType = imageWatermark ? "image" : forensicWatermark ? "forensic" : "text";
2500
+ metadataPath = "live_recording/playout_config";
2501
+ this.Log("Adding watermarking type: ".concat(watermarkType, " ").concat(libraryId, " ").concat(objectId));
2502
+ _context16.next = 19;
2429
2503
  return this.ContentObjectMetadata({
2430
2504
  libraryId: libraryId,
2431
2505
  objectId: objectId,
2432
2506
  writeToken: writeToken,
2433
- metadataSubtree: recordingParamsPath,
2507
+ metadataSubtree: metadataPath,
2434
2508
  resolveLinks: false
2435
2509
  });
2436
- case 16:
2437
- recordingMetadata = _context16.sent;
2438
- if (recordingMetadata) {
2439
- _context16.next = 19;
2510
+ case 19:
2511
+ objectMetadata = _context16.sent;
2512
+ if (objectMetadata) {
2513
+ _context16.next = 22;
2440
2514
  break;
2441
2515
  }
2442
- throw Error("Stream object must be configured");
2443
- case 19:
2516
+ throw Error("Stream object must be configured before adding a watermark");
2517
+ case 22:
2518
+ watermarkArgCount = [simpleWatermark, imageWatermark, forensicWatermark].filter(function (i) {
2519
+ return !!i;
2520
+ }).length;
2521
+ console.log("watermark arg count", watermarkArgCount);
2522
+ if (!(watermarkArgCount === 0)) {
2523
+ _context16.next = 28;
2524
+ break;
2525
+ }
2526
+ throw Error("No watermark was provided");
2527
+ case 28:
2528
+ if (!(watermarkArgCount > 1)) {
2529
+ _context16.next = 30;
2530
+ break;
2531
+ }
2532
+ throw Error("Only one watermark is allowed");
2533
+ case 30:
2444
2534
  if (simpleWatermark) {
2445
- recordingMetadata.simple_watermark = simpleWatermark;
2535
+ objectMetadata.simple_watermark = simpleWatermark;
2446
2536
  } else if (imageWatermark) {
2447
- recordingMetadata.image_watermark = imageWatermark;
2537
+ objectMetadata.image_watermark = imageWatermark;
2538
+ } else if (forensicWatermark) {
2539
+ objectMetadata.forensic_watermark = forensicWatermark;
2448
2540
  }
2449
- _context16.next = 22;
2541
+ _context16.next = 33;
2450
2542
  return this.ReplaceMetadata({
2451
2543
  libraryId: libraryId,
2452
2544
  objectId: objectId,
2453
2545
  writeToken: writeToken,
2454
- metadataSubtree: recordingParamsPath,
2455
- metadata: recordingMetadata
2546
+ metadataSubtree: metadataPath,
2547
+ metadata: objectMetadata
2456
2548
  });
2457
- case 22:
2549
+ case 33:
2458
2550
  if (!edgeWriteToken) {
2459
- _context16.next = 25;
2551
+ _context16.next = 36;
2460
2552
  break;
2461
2553
  }
2462
- _context16.next = 25;
2554
+ _context16.next = 36;
2463
2555
  return this.ReplaceMetadata({
2464
2556
  libraryId: libraryId,
2465
2557
  objectId: objectId,
2466
2558
  writeToken: edgeWriteToken,
2467
- metadataSubtree: recordingParamsPath,
2468
- metadata: recordingMetadata
2559
+ metadataSubtree: metadataPath,
2560
+ metadata: objectMetadata
2469
2561
  });
2470
- case 25:
2562
+ case 36:
2471
2563
  response = {
2472
- "imageWatermark": recordingMetadata.image_watermark,
2473
- "textWatermark": recordingMetadata.simple_watermark
2564
+ "imageWatermark": objectMetadata.image_watermark,
2565
+ "textWatermark": objectMetadata.simple_watermark,
2566
+ "forensicWatermark": objectMetadata.forensic_watermark
2474
2567
  };
2475
2568
  if (!finalize) {
2476
- _context16.next = 31;
2569
+ _context16.next = 42;
2477
2570
  break;
2478
2571
  }
2479
- _context16.next = 29;
2572
+ _context16.next = 40;
2480
2573
  return this.FinalizeContentObject({
2481
2574
  libraryId: libraryId,
2482
2575
  objectId: objectId,
2483
2576
  writeToken: writeToken,
2484
2577
  commitMessage: "Watermark set"
2485
2578
  });
2486
- case 29:
2579
+ case 40:
2487
2580
  finalizeResponse = _context16.sent;
2488
2581
  response.hash = finalizeResponse.hash;
2489
- case 31:
2582
+ case 42:
2490
2583
  return _context16.abrupt("return", response);
2491
- case 32:
2584
+ case 43:
2492
2585
  case "end":
2493
2586
  return _context16.stop();
2494
2587
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.105",
3
+ "version": "4.0.107",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",