easyproctor-hml 2.5.33 → 2.5.35

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/esm/index.js CHANGED
@@ -2400,6 +2400,493 @@ var require_jszip_min = __commonJS({
2400
2400
  }
2401
2401
  });
2402
2402
 
2403
+ // node_modules/fix-webm-duration/fix-webm-duration.js
2404
+ var require_fix_webm_duration = __commonJS({
2405
+ "node_modules/fix-webm-duration/fix-webm-duration.js"(exports, module) {
2406
+ (function(name, definition) {
2407
+ if (typeof define === "function" && define.amd) {
2408
+ define(definition);
2409
+ } else if (typeof module !== "undefined" && module.exports) {
2410
+ module.exports = definition();
2411
+ } else {
2412
+ window.ysFixWebmDuration = definition();
2413
+ }
2414
+ })("fix-webm-duration", function() {
2415
+ var sections = {
2416
+ 172351395: { name: "EBML", type: "Container" },
2417
+ 646: { name: "EBMLVersion", type: "Uint" },
2418
+ 759: { name: "EBMLReadVersion", type: "Uint" },
2419
+ 754: { name: "EBMLMaxIDLength", type: "Uint" },
2420
+ 755: { name: "EBMLMaxSizeLength", type: "Uint" },
2421
+ 642: { name: "DocType", type: "String" },
2422
+ 647: { name: "DocTypeVersion", type: "Uint" },
2423
+ 645: { name: "DocTypeReadVersion", type: "Uint" },
2424
+ 108: { name: "Void", type: "Binary" },
2425
+ 63: { name: "CRC-32", type: "Binary" },
2426
+ 190023271: { name: "SignatureSlot", type: "Container" },
2427
+ 16010: { name: "SignatureAlgo", type: "Uint" },
2428
+ 16026: { name: "SignatureHash", type: "Uint" },
2429
+ 16037: { name: "SignaturePublicKey", type: "Binary" },
2430
+ 16053: { name: "Signature", type: "Binary" },
2431
+ 15963: { name: "SignatureElements", type: "Container" },
2432
+ 15995: { name: "SignatureElementList", type: "Container" },
2433
+ 9522: { name: "SignedElement", type: "Binary" },
2434
+ 139690087: { name: "Segment", type: "Container" },
2435
+ 21863284: { name: "SeekHead", type: "Container" },
2436
+ 3515: { name: "Seek", type: "Container" },
2437
+ 5035: { name: "SeekID", type: "Binary" },
2438
+ 5036: { name: "SeekPosition", type: "Uint" },
2439
+ 88713574: { name: "Info", type: "Container" },
2440
+ 13220: { name: "SegmentUID", type: "Binary" },
2441
+ 13188: { name: "SegmentFilename", type: "String" },
2442
+ 1882403: { name: "PrevUID", type: "Binary" },
2443
+ 1868715: { name: "PrevFilename", type: "String" },
2444
+ 2013475: { name: "NextUID", type: "Binary" },
2445
+ 1999803: { name: "NextFilename", type: "String" },
2446
+ 1092: { name: "SegmentFamily", type: "Binary" },
2447
+ 10532: { name: "ChapterTranslate", type: "Container" },
2448
+ 10748: { name: "ChapterTranslateEditionUID", type: "Uint" },
2449
+ 10687: { name: "ChapterTranslateCodec", type: "Uint" },
2450
+ 10661: { name: "ChapterTranslateID", type: "Binary" },
2451
+ 710577: { name: "TimecodeScale", type: "Uint" },
2452
+ 1161: { name: "Duration", type: "Float" },
2453
+ 1121: { name: "DateUTC", type: "Date" },
2454
+ 15273: { name: "Title", type: "String" },
2455
+ 3456: { name: "MuxingApp", type: "String" },
2456
+ 5953: { name: "WritingApp", type: "String" },
2457
+ // 0xf43b675: { name: 'Cluster', type: 'Container' },
2458
+ 103: { name: "Timecode", type: "Uint" },
2459
+ 6228: { name: "SilentTracks", type: "Container" },
2460
+ 6359: { name: "SilentTrackNumber", type: "Uint" },
2461
+ 39: { name: "Position", type: "Uint" },
2462
+ 43: { name: "PrevSize", type: "Uint" },
2463
+ 35: { name: "SimpleBlock", type: "Binary" },
2464
+ 32: { name: "BlockGroup", type: "Container" },
2465
+ 33: { name: "Block", type: "Binary" },
2466
+ 34: { name: "BlockVirtual", type: "Binary" },
2467
+ 13729: { name: "BlockAdditions", type: "Container" },
2468
+ 38: { name: "BlockMore", type: "Container" },
2469
+ 110: { name: "BlockAddID", type: "Uint" },
2470
+ 37: { name: "BlockAdditional", type: "Binary" },
2471
+ 27: { name: "BlockDuration", type: "Uint" },
2472
+ 122: { name: "ReferencePriority", type: "Uint" },
2473
+ 123: { name: "ReferenceBlock", type: "Int" },
2474
+ 125: { name: "ReferenceVirtual", type: "Int" },
2475
+ 36: { name: "CodecState", type: "Binary" },
2476
+ 13730: { name: "DiscardPadding", type: "Int" },
2477
+ 14: { name: "Slices", type: "Container" },
2478
+ 104: { name: "TimeSlice", type: "Container" },
2479
+ 76: { name: "LaceNumber", type: "Uint" },
2480
+ 77: { name: "FrameNumber", type: "Uint" },
2481
+ 75: { name: "BlockAdditionID", type: "Uint" },
2482
+ 78: { name: "Delay", type: "Uint" },
2483
+ 79: { name: "SliceDuration", type: "Uint" },
2484
+ 72: { name: "ReferenceFrame", type: "Container" },
2485
+ 73: { name: "ReferenceOffset", type: "Uint" },
2486
+ 74: { name: "ReferenceTimeCode", type: "Uint" },
2487
+ 47: { name: "EncryptedBlock", type: "Binary" },
2488
+ 106212971: { name: "Tracks", type: "Container" },
2489
+ 46: { name: "TrackEntry", type: "Container" },
2490
+ 87: { name: "TrackNumber", type: "Uint" },
2491
+ 13253: { name: "TrackUID", type: "Uint" },
2492
+ 3: { name: "TrackType", type: "Uint" },
2493
+ 57: { name: "FlagEnabled", type: "Uint" },
2494
+ 8: { name: "FlagDefault", type: "Uint" },
2495
+ 5546: { name: "FlagForced", type: "Uint" },
2496
+ 28: { name: "FlagLacing", type: "Uint" },
2497
+ 11751: { name: "MinCache", type: "Uint" },
2498
+ 11768: { name: "MaxCache", type: "Uint" },
2499
+ 254851: { name: "DefaultDuration", type: "Uint" },
2500
+ 216698: { name: "DefaultDecodedFieldDuration", type: "Uint" },
2501
+ 209231: { name: "TrackTimecodeScale", type: "Float" },
2502
+ 4991: { name: "TrackOffset", type: "Int" },
2503
+ 5614: { name: "MaxBlockAdditionID", type: "Uint" },
2504
+ 4974: { name: "Name", type: "String" },
2505
+ 177564: { name: "Language", type: "String" },
2506
+ 6: { name: "CodecID", type: "String" },
2507
+ 9122: { name: "CodecPrivate", type: "Binary" },
2508
+ 362120: { name: "CodecName", type: "String" },
2509
+ 13382: { name: "AttachmentLink", type: "Uint" },
2510
+ 1742487: { name: "CodecSettings", type: "String" },
2511
+ 1785920: { name: "CodecInfoURL", type: "String" },
2512
+ 438848: { name: "CodecDownloadURL", type: "String" },
2513
+ 42: { name: "CodecDecodeAll", type: "Uint" },
2514
+ 12203: { name: "TrackOverlay", type: "Uint" },
2515
+ 5802: { name: "CodecDelay", type: "Uint" },
2516
+ 5819: { name: "SeekPreRoll", type: "Uint" },
2517
+ 9764: { name: "TrackTranslate", type: "Container" },
2518
+ 9980: { name: "TrackTranslateEditionUID", type: "Uint" },
2519
+ 9919: { name: "TrackTranslateCodec", type: "Uint" },
2520
+ 9893: { name: "TrackTranslateTrackID", type: "Binary" },
2521
+ 96: { name: "Video", type: "Container" },
2522
+ 26: { name: "FlagInterlaced", type: "Uint" },
2523
+ 5048: { name: "StereoMode", type: "Uint" },
2524
+ 5056: { name: "AlphaMode", type: "Uint" },
2525
+ 5049: { name: "OldStereoMode", type: "Uint" },
2526
+ 48: { name: "PixelWidth", type: "Uint" },
2527
+ 58: { name: "PixelHeight", type: "Uint" },
2528
+ 5290: { name: "PixelCropBottom", type: "Uint" },
2529
+ 5307: { name: "PixelCropTop", type: "Uint" },
2530
+ 5324: { name: "PixelCropLeft", type: "Uint" },
2531
+ 5341: { name: "PixelCropRight", type: "Uint" },
2532
+ 5296: { name: "DisplayWidth", type: "Uint" },
2533
+ 5306: { name: "DisplayHeight", type: "Uint" },
2534
+ 5298: { name: "DisplayUnit", type: "Uint" },
2535
+ 5299: { name: "AspectRatioType", type: "Uint" },
2536
+ 963876: { name: "ColourSpace", type: "Binary" },
2537
+ 1029411: { name: "GammaValue", type: "Float" },
2538
+ 230371: { name: "FrameRate", type: "Float" },
2539
+ 97: { name: "Audio", type: "Container" },
2540
+ 53: { name: "SamplingFrequency", type: "Float" },
2541
+ 14517: { name: "OutputSamplingFrequency", type: "Float" },
2542
+ 31: { name: "Channels", type: "Uint" },
2543
+ 15739: { name: "ChannelPositions", type: "Binary" },
2544
+ 8804: { name: "BitDepth", type: "Uint" },
2545
+ 98: { name: "TrackOperation", type: "Container" },
2546
+ 99: { name: "TrackCombinePlanes", type: "Container" },
2547
+ 100: { name: "TrackPlane", type: "Container" },
2548
+ 101: { name: "TrackPlaneUID", type: "Uint" },
2549
+ 102: { name: "TrackPlaneType", type: "Uint" },
2550
+ 105: { name: "TrackJoinBlocks", type: "Container" },
2551
+ 109: { name: "TrackJoinUID", type: "Uint" },
2552
+ 64: { name: "TrickTrackUID", type: "Uint" },
2553
+ 65: { name: "TrickTrackSegmentUID", type: "Binary" },
2554
+ 70: { name: "TrickTrackFlag", type: "Uint" },
2555
+ 71: { name: "TrickMasterTrackUID", type: "Uint" },
2556
+ 68: { name: "TrickMasterTrackSegmentUID", type: "Binary" },
2557
+ 11648: { name: "ContentEncodings", type: "Container" },
2558
+ 8768: { name: "ContentEncoding", type: "Container" },
2559
+ 4145: { name: "ContentEncodingOrder", type: "Uint" },
2560
+ 4146: { name: "ContentEncodingScope", type: "Uint" },
2561
+ 4147: { name: "ContentEncodingType", type: "Uint" },
2562
+ 4148: { name: "ContentCompression", type: "Container" },
2563
+ 596: { name: "ContentCompAlgo", type: "Uint" },
2564
+ 597: { name: "ContentCompSettings", type: "Binary" },
2565
+ 4149: { name: "ContentEncryption", type: "Container" },
2566
+ 2017: { name: "ContentEncAlgo", type: "Uint" },
2567
+ 2018: { name: "ContentEncKeyID", type: "Binary" },
2568
+ 2019: { name: "ContentSignature", type: "Binary" },
2569
+ 2020: { name: "ContentSigKeyID", type: "Binary" },
2570
+ 2021: { name: "ContentSigAlgo", type: "Uint" },
2571
+ 2022: { name: "ContentSigHashAlgo", type: "Uint" },
2572
+ 206814059: { name: "Cues", type: "Container" },
2573
+ 59: { name: "CuePoint", type: "Container" },
2574
+ 51: { name: "CueTime", type: "Uint" },
2575
+ 55: { name: "CueTrackPositions", type: "Container" },
2576
+ 119: { name: "CueTrack", type: "Uint" },
2577
+ 113: { name: "CueClusterPosition", type: "Uint" },
2578
+ 112: { name: "CueRelativePosition", type: "Uint" },
2579
+ 50: { name: "CueDuration", type: "Uint" },
2580
+ 4984: { name: "CueBlockNumber", type: "Uint" },
2581
+ 106: { name: "CueCodecState", type: "Uint" },
2582
+ 91: { name: "CueReference", type: "Container" },
2583
+ 22: { name: "CueRefTime", type: "Uint" },
2584
+ 23: { name: "CueRefCluster", type: "Uint" },
2585
+ 4959: { name: "CueRefNumber", type: "Uint" },
2586
+ 107: { name: "CueRefCodecState", type: "Uint" },
2587
+ 155296873: { name: "Attachments", type: "Container" },
2588
+ 8615: { name: "AttachedFile", type: "Container" },
2589
+ 1662: { name: "FileDescription", type: "String" },
2590
+ 1646: { name: "FileName", type: "String" },
2591
+ 1632: { name: "FileMimeType", type: "String" },
2592
+ 1628: { name: "FileData", type: "Binary" },
2593
+ 1710: { name: "FileUID", type: "Uint" },
2594
+ 1653: { name: "FileReferral", type: "Binary" },
2595
+ 1633: { name: "FileUsedStartTime", type: "Uint" },
2596
+ 1634: { name: "FileUsedEndTime", type: "Uint" },
2597
+ 4433776: { name: "Chapters", type: "Container" },
2598
+ 1465: { name: "EditionEntry", type: "Container" },
2599
+ 1468: { name: "EditionUID", type: "Uint" },
2600
+ 1469: { name: "EditionFlagHidden", type: "Uint" },
2601
+ 1499: { name: "EditionFlagDefault", type: "Uint" },
2602
+ 1501: { name: "EditionFlagOrdered", type: "Uint" },
2603
+ 54: { name: "ChapterAtom", type: "Container" },
2604
+ 13252: { name: "ChapterUID", type: "Uint" },
2605
+ 5716: { name: "ChapterStringUID", type: "String" },
2606
+ 17: { name: "ChapterTimeStart", type: "Uint" },
2607
+ 18: { name: "ChapterTimeEnd", type: "Uint" },
2608
+ 24: { name: "ChapterFlagHidden", type: "Uint" },
2609
+ 1432: { name: "ChapterFlagEnabled", type: "Uint" },
2610
+ 11879: { name: "ChapterSegmentUID", type: "Binary" },
2611
+ 11964: { name: "ChapterSegmentEditionUID", type: "Uint" },
2612
+ 9155: { name: "ChapterPhysicalEquiv", type: "Uint" },
2613
+ 15: { name: "ChapterTrack", type: "Container" },
2614
+ 9: { name: "ChapterTrackNumber", type: "Uint" },
2615
+ 0: { name: "ChapterDisplay", type: "Container" },
2616
+ 5: { name: "ChapString", type: "String" },
2617
+ 892: { name: "ChapLanguage", type: "String" },
2618
+ 894: { name: "ChapCountry", type: "String" },
2619
+ 10564: { name: "ChapProcess", type: "Container" },
2620
+ 10581: { name: "ChapProcessCodecID", type: "Uint" },
2621
+ 1293: { name: "ChapProcessPrivate", type: "Binary" },
2622
+ 10513: { name: "ChapProcessCommand", type: "Container" },
2623
+ 10530: { name: "ChapProcessTime", type: "Uint" },
2624
+ 10547: { name: "ChapProcessData", type: "Binary" },
2625
+ 39109479: { name: "Tags", type: "Container" },
2626
+ 13171: { name: "Tag", type: "Container" },
2627
+ 9152: { name: "Targets", type: "Container" },
2628
+ 10442: { name: "TargetTypeValue", type: "Uint" },
2629
+ 9162: { name: "TargetType", type: "String" },
2630
+ 9157: { name: "TagTrackUID", type: "Uint" },
2631
+ 9161: { name: "TagEditionUID", type: "Uint" },
2632
+ 9156: { name: "TagChapterUID", type: "Uint" },
2633
+ 9158: { name: "TagAttachmentUID", type: "Uint" },
2634
+ 10184: { name: "SimpleTag", type: "Container" },
2635
+ 1443: { name: "TagName", type: "String" },
2636
+ 1146: { name: "TagLanguage", type: "String" },
2637
+ 1156: { name: "TagDefault", type: "Uint" },
2638
+ 1159: { name: "TagString", type: "String" },
2639
+ 1157: { name: "TagBinary", type: "Binary" }
2640
+ };
2641
+ function doInherit(newClass, baseClass) {
2642
+ newClass.prototype = Object.create(baseClass.prototype);
2643
+ newClass.prototype.constructor = newClass;
2644
+ }
2645
+ function WebmBase(name, type) {
2646
+ this.name = name || "Unknown";
2647
+ this.type = type || "Unknown";
2648
+ }
2649
+ WebmBase.prototype.updateBySource = function() {
2650
+ };
2651
+ WebmBase.prototype.setSource = function(source) {
2652
+ this.source = source;
2653
+ this.updateBySource();
2654
+ };
2655
+ WebmBase.prototype.updateByData = function() {
2656
+ };
2657
+ WebmBase.prototype.setData = function(data) {
2658
+ this.data = data;
2659
+ this.updateByData();
2660
+ };
2661
+ function WebmUint(name, type) {
2662
+ WebmBase.call(this, name, type || "Uint");
2663
+ }
2664
+ doInherit(WebmUint, WebmBase);
2665
+ function padHex(hex) {
2666
+ return hex.length % 2 === 1 ? "0" + hex : hex;
2667
+ }
2668
+ WebmUint.prototype.updateBySource = function() {
2669
+ this.data = "";
2670
+ for (var i3 = 0; i3 < this.source.length; i3++) {
2671
+ var hex = this.source[i3].toString(16);
2672
+ this.data += padHex(hex);
2673
+ }
2674
+ };
2675
+ WebmUint.prototype.updateByData = function() {
2676
+ var length = this.data.length / 2;
2677
+ this.source = new Uint8Array(length);
2678
+ for (var i3 = 0; i3 < length; i3++) {
2679
+ var hex = this.data.substr(i3 * 2, 2);
2680
+ this.source[i3] = parseInt(hex, 16);
2681
+ }
2682
+ };
2683
+ WebmUint.prototype.getValue = function() {
2684
+ return parseInt(this.data, 16);
2685
+ };
2686
+ WebmUint.prototype.setValue = function(value) {
2687
+ this.setData(padHex(value.toString(16)));
2688
+ };
2689
+ function WebmFloat(name, type) {
2690
+ WebmBase.call(this, name, type || "Float");
2691
+ }
2692
+ doInherit(WebmFloat, WebmBase);
2693
+ WebmFloat.prototype.getFloatArrayType = function() {
2694
+ return this.source && this.source.length === 4 ? Float32Array : Float64Array;
2695
+ };
2696
+ WebmFloat.prototype.updateBySource = function() {
2697
+ var byteArray = this.source.reverse();
2698
+ var floatArrayType = this.getFloatArrayType();
2699
+ var floatArray = new floatArrayType(byteArray.buffer);
2700
+ this.data = floatArray[0];
2701
+ };
2702
+ WebmFloat.prototype.updateByData = function() {
2703
+ var floatArrayType = this.getFloatArrayType();
2704
+ var floatArray = new floatArrayType([this.data]);
2705
+ var byteArray = new Uint8Array(floatArray.buffer);
2706
+ this.source = byteArray.reverse();
2707
+ };
2708
+ WebmFloat.prototype.getValue = function() {
2709
+ return this.data;
2710
+ };
2711
+ WebmFloat.prototype.setValue = function(value) {
2712
+ this.setData(value);
2713
+ };
2714
+ function WebmContainer(name, type) {
2715
+ WebmBase.call(this, name, type || "Container");
2716
+ }
2717
+ doInherit(WebmContainer, WebmBase);
2718
+ WebmContainer.prototype.readByte = function() {
2719
+ return this.source[this.offset++];
2720
+ };
2721
+ WebmContainer.prototype.readUint = function() {
2722
+ var firstByte = this.readByte();
2723
+ var bytes = 8 - firstByte.toString(2).length;
2724
+ var value = firstByte - (1 << 7 - bytes);
2725
+ for (var i3 = 0; i3 < bytes; i3++) {
2726
+ value *= 256;
2727
+ value += this.readByte();
2728
+ }
2729
+ return value;
2730
+ };
2731
+ WebmContainer.prototype.updateBySource = function() {
2732
+ this.data = [];
2733
+ for (this.offset = 0; this.offset < this.source.length; this.offset = end) {
2734
+ var id = this.readUint();
2735
+ var len = this.readUint();
2736
+ var end = Math.min(this.offset + len, this.source.length);
2737
+ var data = this.source.slice(this.offset, end);
2738
+ var info = sections[id] || { name: "Unknown", type: "Unknown" };
2739
+ var ctr = WebmBase;
2740
+ switch (info.type) {
2741
+ case "Container":
2742
+ ctr = WebmContainer;
2743
+ break;
2744
+ case "Uint":
2745
+ ctr = WebmUint;
2746
+ break;
2747
+ case "Float":
2748
+ ctr = WebmFloat;
2749
+ break;
2750
+ }
2751
+ var section = new ctr(info.name, info.type);
2752
+ section.setSource(data);
2753
+ this.data.push({
2754
+ id,
2755
+ idHex: id.toString(16),
2756
+ data: section
2757
+ });
2758
+ }
2759
+ };
2760
+ WebmContainer.prototype.writeUint = function(x3, draft) {
2761
+ for (var bytes = 1, flag = 128; x3 >= flag && bytes < 8; bytes++, flag *= 128) {
2762
+ }
2763
+ if (!draft) {
2764
+ var value = flag + x3;
2765
+ for (var i3 = bytes - 1; i3 >= 0; i3--) {
2766
+ var c3 = value % 256;
2767
+ this.source[this.offset + i3] = c3;
2768
+ value = (value - c3) / 256;
2769
+ }
2770
+ }
2771
+ this.offset += bytes;
2772
+ };
2773
+ WebmContainer.prototype.writeSections = function(draft) {
2774
+ this.offset = 0;
2775
+ for (var i3 = 0; i3 < this.data.length; i3++) {
2776
+ var section = this.data[i3], content = section.data.source, contentLength = content.length;
2777
+ this.writeUint(section.id, draft);
2778
+ this.writeUint(contentLength, draft);
2779
+ if (!draft) {
2780
+ this.source.set(content, this.offset);
2781
+ }
2782
+ this.offset += contentLength;
2783
+ }
2784
+ return this.offset;
2785
+ };
2786
+ WebmContainer.prototype.updateByData = function() {
2787
+ var length = this.writeSections("draft");
2788
+ this.source = new Uint8Array(length);
2789
+ this.writeSections();
2790
+ };
2791
+ WebmContainer.prototype.getSectionById = function(id) {
2792
+ for (var i3 = 0; i3 < this.data.length; i3++) {
2793
+ var section = this.data[i3];
2794
+ if (section.id === id) {
2795
+ return section.data;
2796
+ }
2797
+ }
2798
+ return null;
2799
+ };
2800
+ function WebmFile(source) {
2801
+ WebmContainer.call(this, "File", "File");
2802
+ this.setSource(source);
2803
+ }
2804
+ doInherit(WebmFile, WebmContainer);
2805
+ WebmFile.prototype.fixDuration = function(duration, options) {
2806
+ var logger = options && options.logger;
2807
+ if (logger === void 0) {
2808
+ logger = function(message) {
2809
+ console.log(message);
2810
+ };
2811
+ } else if (!logger) {
2812
+ logger = function() {
2813
+ };
2814
+ }
2815
+ var segmentSection = this.getSectionById(139690087);
2816
+ if (!segmentSection) {
2817
+ logger("[fix-webm-duration] Segment section is missing");
2818
+ return false;
2819
+ }
2820
+ var infoSection = segmentSection.getSectionById(88713574);
2821
+ if (!infoSection) {
2822
+ logger("[fix-webm-duration] Info section is missing");
2823
+ return false;
2824
+ }
2825
+ var timeScaleSection = infoSection.getSectionById(710577);
2826
+ if (!timeScaleSection) {
2827
+ logger("[fix-webm-duration] TimecodeScale section is missing");
2828
+ return false;
2829
+ }
2830
+ var durationSection = infoSection.getSectionById(1161);
2831
+ if (durationSection) {
2832
+ if (durationSection.getValue() <= 0) {
2833
+ logger(`[fix-webm-duration] Duration section is present, but the value is ${durationSection.getValue()}`);
2834
+ durationSection.setValue(duration);
2835
+ } else {
2836
+ logger(`[fix-webm-duration] Duration section is present, and the value is ${durationSection.getValue()}`);
2837
+ return false;
2838
+ }
2839
+ } else {
2840
+ logger("[fix-webm-duration] Duration section is missing");
2841
+ durationSection = new WebmFloat("Duration", "Float");
2842
+ durationSection.setValue(duration);
2843
+ infoSection.data.push({
2844
+ id: 1161,
2845
+ data: durationSection
2846
+ });
2847
+ }
2848
+ timeScaleSection.setValue(1e6);
2849
+ infoSection.updateByData();
2850
+ segmentSection.updateByData();
2851
+ this.updateByData();
2852
+ return true;
2853
+ };
2854
+ WebmFile.prototype.toBlob = function(mimeType) {
2855
+ return new Blob([this.source.buffer], { type: mimeType || "video/webm" });
2856
+ };
2857
+ function fixWebmDuration3(blob, duration, callback, options) {
2858
+ if (typeof callback === "object") {
2859
+ options = callback;
2860
+ callback = void 0;
2861
+ }
2862
+ if (!callback) {
2863
+ return new Promise(function(resolve) {
2864
+ fixWebmDuration3(blob, duration, resolve, options);
2865
+ });
2866
+ }
2867
+ try {
2868
+ var reader = new FileReader();
2869
+ reader.onloadend = function() {
2870
+ try {
2871
+ var file = new WebmFile(new Uint8Array(reader.result));
2872
+ if (file.fixDuration(duration, options)) {
2873
+ blob = file.toBlob(blob.type);
2874
+ }
2875
+ } catch (ex) {
2876
+ }
2877
+ callback(blob);
2878
+ };
2879
+ reader.readAsArrayBuffer(blob);
2880
+ } catch (ex) {
2881
+ callback(blob);
2882
+ }
2883
+ }
2884
+ fixWebmDuration3.default = fixWebmDuration3;
2885
+ return fixWebmDuration3;
2886
+ });
2887
+ }
2888
+ });
2889
+
2403
2890
  // node_modules/file-saver/dist/FileSaver.min.js
2404
2891
  var require_FileSaver_min = __commonJS({
2405
2892
  "node_modules/file-saver/dist/FileSaver.min.js"(exports, module) {
@@ -8842,7 +9329,7 @@ var FaceDetection = class extends BaseDetection {
8842
9329
  stopDetection() {
8843
9330
  super.stopDetection();
8844
9331
  if (this.emmitedFaceAlert) {
8845
- this.handleOk("face_ok", "face_detection_on_stream");
9332
+ this.handleOk("face_stop", "face_detection_on_stream");
8846
9333
  }
8847
9334
  }
8848
9335
  // displayVideoDetections(result: { detections: any; }) {
@@ -12258,6 +12745,7 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12258
12745
  buffer.push(e3.data);
12259
12746
  }
12260
12747
  if (stopped) {
12748
+ console.log("buildMediaRecorder ondataavailable stopped");
12261
12749
  resolvePromise && resolvePromise();
12262
12750
  }
12263
12751
  };
@@ -12327,6 +12815,9 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12327
12815
  if (mediaRecorder.state == "recording") {
12328
12816
  console.log("stopRecording Recorder est\xE1 em estado recording, iniciando stop");
12329
12817
  resolvePromise = resolve;
12818
+ mediaRecorder.onstop = () => {
12819
+ console.log("recorder onstop");
12820
+ };
12330
12821
  stopped = true;
12331
12822
  mediaRecorder.stop();
12332
12823
  } else {
@@ -12742,6 +13233,7 @@ var VolumeMeter = class {
12742
13233
 
12743
13234
  // src/new-flow/recorders/CameraRecorder.ts
12744
13235
  var import_jszip_min = __toESM(require_jszip_min());
13236
+ var import_fix_webm_duration = __toESM(require_fix_webm_duration());
12745
13237
  var CameraRecorder = class {
12746
13238
  constructor(options, videoOptions, paramsConfig, backend, backendToken) {
12747
13239
  this.blobs = [];
@@ -12792,6 +13284,7 @@ var CameraRecorder = class {
12792
13284
  this.hardwareStream = null;
12793
13285
  this.internalClonedStream = null;
12794
13286
  this.videoElement = null;
13287
+ this.duration = 0;
12795
13288
  this.currentRetries = 0;
12796
13289
  this.packageCount = 0;
12797
13290
  this.noiseWait = 20;
@@ -13016,10 +13509,17 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13016
13509
  console.log("Camera Recorder started OK");
13017
13510
  }
13018
13511
  async stopRecording() {
13019
- var _a2, _b, _c2;
13512
+ var _a2, _b, _c2, _d;
13020
13513
  console.log("Camera Recorder stopRecording");
13021
13514
  this.isCanvasLoopActive = false;
13515
+ this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
13516
+ this.objectDetection && this.objectDetection.detecting && this.objectDetection.stopDetection();
13517
+ clearInterval(this.imageInterval);
13518
+ clearInterval(this.sendFrameInterval);
13519
+ this.volumeMeter && this.volumeMeter.stop();
13520
+ this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
13022
13521
  this.recordingStop && await this.recordingStop();
13522
+ this.duration = Date.now() - ((_a2 = this.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
13023
13523
  try {
13024
13524
  if (this.animationFrameId) {
13025
13525
  cancelAnimationFrame(this.animationFrameId);
@@ -13037,28 +13537,22 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13037
13537
  this.hardwareStream = null;
13038
13538
  }
13039
13539
  if (this.videoElement) {
13040
- (_a2 = this.videoElement) == null ? void 0 : _a2.remove();
13540
+ (_b = this.videoElement) == null ? void 0 : _b.remove();
13041
13541
  this.videoElement = null;
13042
13542
  }
13043
13543
  if (this.video) {
13044
- (_b = this.video) == null ? void 0 : _b.remove();
13544
+ (_c2 = this.video) == null ? void 0 : _c2.remove();
13045
13545
  }
13046
13546
  if (this.canvas) {
13047
- (_c2 = this.canvas) == null ? void 0 : _c2.remove();
13547
+ (_d = this.canvas) == null ? void 0 : _d.remove();
13048
13548
  }
13049
13549
  } catch (e3) {
13050
13550
  console.error("Erro ao parar os streams de m\xEDdia.");
13051
13551
  }
13052
- this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
13053
- this.objectDetection && this.objectDetection.detecting && this.objectDetection.stopDetection();
13054
- clearInterval(this.imageInterval);
13055
- clearInterval(this.sendFrameInterval);
13056
13552
  if (this.options.proctoringType == "REALTIME" && this.upload && this.backendToken) {
13057
13553
  await this.sendPackage(this.filesToUpload);
13058
13554
  await this.filesToUpload.splice(0, this.filesToUpload.length);
13059
13555
  }
13060
- this.volumeMeter && this.volumeMeter.stop();
13061
- this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
13062
13556
  }
13063
13557
  async pauseRecording() {
13064
13558
  await this.recordingPause();
@@ -13192,6 +13686,15 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13192
13686
  const settings = this.cameraStream.getVideoTracks()[0].getSettings();
13193
13687
  const settingsAudio = this.cameraStream.getAudioTracks()[0].getSettings();
13194
13688
  if (this.options.proctoringType == "VIDEO" || this.options.proctoringType == "REALTIME" || this.options.proctoringType == "IMAGE" && ((_a2 = this.paramsConfig.imageBehaviourParameters) == null ? void 0 : _a2.saveVideo)) {
13689
+ const rawBlob = new Blob(this.blobs, {
13690
+ type: ((_b = this.recorderOptions) == null ? void 0 : _b.mimeType) || "video/webm"
13691
+ });
13692
+ const fixedBlob = await (0, import_fix_webm_duration.default)(rawBlob, this.duration);
13693
+ const file = new File(
13694
+ [fixedBlob],
13695
+ `EP_${session.id}_camera_0.webm`,
13696
+ { type: rawBlob.type }
13697
+ );
13195
13698
  session.addRecording({
13196
13699
  device: `Audio
13197
13700
  Sample Rate: ${settingsAudio.sampleRate}
@@ -13199,9 +13702,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13199
13702
 
13200
13703
  Video:
13201
13704
  ${JSON.stringify(this.recorderOptions)}`,
13202
- file: new File(this.blobs, `EP_${session.id}_camera_0.webm`, {
13203
- type: ((_b = this.recorderOptions) == null ? void 0 : _b.mimeType) || "video/webm"
13204
- }),
13705
+ file,
13205
13706
  origin: "Camera" /* Camera */
13206
13707
  });
13207
13708
  }
@@ -14926,8 +15427,8 @@ var CapturePhoto = class {
14926
15427
  }
14927
15428
  };
14928
15429
 
14929
- // src/extension/extension.ts
14930
- var Extension = class {
15430
+ // src/extension/extensionEasyProctor.ts
15431
+ var ExtensionEasyProctor = class {
14931
15432
  constructor() {
14932
15433
  this.hasExtension = false;
14933
15434
  this.tryes = 0;
@@ -14972,6 +15473,89 @@ var Extension = class {
14972
15473
  }
14973
15474
  };
14974
15475
 
15476
+ // src/extension/extensionEasyCatcher.ts
15477
+ var ExtensionEasyCatcher = class {
15478
+ constructor(options) {
15479
+ this.hasExtension = false;
15480
+ this.tryes = 0;
15481
+ this.responseStart = false;
15482
+ this.options = options || {};
15483
+ }
15484
+ /**
15485
+ * Verifica se a extensão está instalada e ativa.
15486
+ * Retorna o número da versão se encontrada, ou lança erro após timeout.
15487
+ */
15488
+ checkExtensionInstalled(timeoutMs = 2e3) {
15489
+ return new Promise((resolve, reject) => {
15490
+ let handled = false;
15491
+ const handler = (event) => {
15492
+ if (event.source === window && event.data.sender === "easyproctor-extension" && event.data.message_name === "version") {
15493
+ handled = true;
15494
+ window.removeEventListener("message", handler);
15495
+ resolve(event.data.message);
15496
+ }
15497
+ };
15498
+ window.addEventListener("message", handler);
15499
+ window.postMessage({
15500
+ type: "easycatcher",
15501
+ func: "verifyExtensionEasycatcher"
15502
+ }, "*");
15503
+ setTimeout(() => {
15504
+ if (!handled) {
15505
+ window.removeEventListener("message", handler);
15506
+ reject(new Error("Extens\xE3o n\xE3o detectada ou n\xE3o respondeu."));
15507
+ }
15508
+ }, timeoutMs);
15509
+ });
15510
+ }
15511
+ /**
15512
+ * Solicita o JSON da sessão atual capturado pela extensão.
15513
+ */
15514
+ getSessionData(timeoutMs = 5e3) {
15515
+ return new Promise((resolve, reject) => {
15516
+ let handled = false;
15517
+ const handler = (event) => {
15518
+ if (event.source === window && event.data.sender === "easyproctor-extension" && event.data.message_name === "data_response") {
15519
+ handled = true;
15520
+ window.removeEventListener("message", handler);
15521
+ resolve(event.data.payload);
15522
+ }
15523
+ };
15524
+ window.addEventListener("message", handler);
15525
+ window.postMessage({
15526
+ type: "easycatcher",
15527
+ func: "getDataExtensionEasycatcher"
15528
+ }, "*");
15529
+ setTimeout(() => {
15530
+ if (!handled) {
15531
+ window.removeEventListener("message", handler);
15532
+ reject(new Error("Timeout ao aguardar dados da extens\xE3o."));
15533
+ }
15534
+ }, timeoutMs);
15535
+ });
15536
+ }
15537
+ start() {
15538
+ return new Promise((resolve, reject) => {
15539
+ let handled = false;
15540
+ const handler = (event) => {
15541
+ if (event.source === window && event.data.sender === "easyproctor-extension" && event.data.message_name === "started_confirmed") {
15542
+ handled = true;
15543
+ window.removeEventListener("message", handler);
15544
+ resolve(true);
15545
+ }
15546
+ };
15547
+ window.addEventListener("message", handler);
15548
+ window.postMessage({ type: "easycatcher", func: "startExtensionEasycatcher" }, "*");
15549
+ setTimeout(() => {
15550
+ if (!handled) {
15551
+ window.removeEventListener("message", handler);
15552
+ reject(new Error("Timeout: Extens\xE3o n\xE3o confirmou o in\xEDcio."));
15553
+ }
15554
+ }, 3e3);
15555
+ });
15556
+ }
15557
+ };
15558
+
14975
15559
  // src/modules/onChangeDevices.ts
14976
15560
  var onChangeDevices = class {
14977
15561
  constructor(repositoryDevices, proctoringId2, sessionOptions, allRecorders) {
@@ -15168,6 +15752,22 @@ var ProctoringUploader = class {
15168
15752
  }
15169
15753
  },
15170
15754
  token
15755
+ ).catch(
15756
+ async (e3) => {
15757
+ console.log("Upload File Error", e3), trackers.registerError(this.proctoringId, `Upload File
15758
+ Name: ${rec.file.name}
15759
+ Error: ${e3.message}
15760
+ Size: ${e3.error}`);
15761
+ await uploadService.upload(
15762
+ {
15763
+ file: rec.file,
15764
+ onProgress: (progress) => {
15765
+ if (onProgress) onProgress(progress);
15766
+ }
15767
+ },
15768
+ token
15769
+ );
15770
+ }
15171
15771
  );
15172
15772
  if (result) {
15173
15773
  let fileType = "";
@@ -17876,10 +18476,12 @@ registerProcessor("audio-processor", AudioProcessor);
17876
18476
  `;
17877
18477
 
17878
18478
  // src/new-flow/recorders/ScreenRecorder.ts
18479
+ var import_fix_webm_duration2 = __toESM(require_fix_webm_duration());
17879
18480
  var ScreenRecorder = class {
17880
18481
  constructor(options) {
17881
18482
  this.blobs = [];
17882
18483
  this.blobsFinal = [];
18484
+ this.duration = 0;
17883
18485
  this.options = options;
17884
18486
  }
17885
18487
  setProctoringId(proctoringId2) {
@@ -17961,15 +18563,24 @@ var ScreenRecorder = class {
17961
18563
  async resumeRecording() {
17962
18564
  }
17963
18565
  async stopRecording() {
18566
+ var _a2;
17964
18567
  this.recordingStop && await this.recordingStop();
18568
+ this.duration = Date.now() - ((_a2 = this.startTime) == null ? void 0 : _a2.getTime()) || 0;
17965
18569
  }
17966
18570
  async saveOnSession(session) {
17967
18571
  if (isMobileDevice()) return;
18572
+ const rawBlob = new Blob(this.blobs, {
18573
+ type: "video/webm"
18574
+ });
18575
+ const fixedBlob = await (0, import_fix_webm_duration2.default)(rawBlob, this.duration);
18576
+ const file = new File(
18577
+ [fixedBlob],
18578
+ `EP_${session.id}_screen_0.webm`,
18579
+ { type: rawBlob.type }
18580
+ );
17968
18581
  session.addRecording({
17969
18582
  device: "",
17970
- file: new File(this.blobs, `EP_${session.id}_screen_0.webm`, {
17971
- type: "video/webm"
17972
- }),
18583
+ file,
17973
18584
  origin: "Screen" /* Screen */
17974
18585
  });
17975
18586
  }
@@ -21895,7 +22506,7 @@ var Proctoring = class {
21895
22506
  begin: alert.begin,
21896
22507
  end: alert.end,
21897
22508
  warningCategoryEnum: this.convertRealtimeTypeToWarningType(alert.type),
21898
- alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64(),
22509
+ alertImageBase64: alert.description !== "face_stop" ? await this.allRecorders.cameraRecorder.getCurrentImageBase64() : "",
21899
22510
  retry: verifyCount < verifyMaxRetries - 1 ? true : false
21900
22511
  });
21901
22512
  return response;
@@ -22008,7 +22619,10 @@ var Proctoring = class {
22008
22619
  if (this.context.token === void 0) {
22009
22620
  throw TOKEN_MISSING;
22010
22621
  }
22011
- this.extension = new Extension();
22622
+ if (options.useChallenge) {
22623
+ this.extensionEasycatcher = new ExtensionEasyCatcher();
22624
+ }
22625
+ this.extension = new ExtensionEasyProctor();
22012
22626
  this.extension.addEventListener();
22013
22627
  const baseURL = this.backend.selectBaseUrl(this.context.type);
22014
22628
  const devices = await enumarateDevices();
@@ -22097,7 +22711,7 @@ Navigator: ${JSON.stringify(_navigator2)}`
22097
22711
  verifyingFace = true;
22098
22712
  verifyFirstFaceIntervalCount++;
22099
22713
  try {
22100
- var response = await this.backend.verifyFace(this.proctoringId, await this.allRecorders.cameraRecorder.getCurrentImageBase64(), verifyFirstFaceIntervalCount > 5 ? false : true);
22714
+ var response = await this.backend.verifyFace(this.proctoringId, await this.allRecorders.cameraRecorder.getCurrentImageBase64(), verifyFirstFaceIntervalCount > 2 ? false : true);
22101
22715
  verifyingFace = false;
22102
22716
  clearInterval(this.verifyFirstFaceInterval);
22103
22717
  } catch (error) {
@@ -22105,7 +22719,7 @@ Navigator: ${JSON.stringify(_navigator2)}`
22105
22719
  return;
22106
22720
  }
22107
22721
  }
22108
- }, 1500);
22722
+ }, 5e3);
22109
22723
  return startResponse;
22110
22724
  } catch (error) {
22111
22725
  console.log(error);
@@ -22358,6 +22972,61 @@ Error: ` + error
22358
22972
  _screenStream: (_a2 = this.allRecorders.screenRecorder) == null ? void 0 : _a2.screenStream
22359
22973
  };
22360
22974
  }
22975
+ async startChallenge(templateId) {
22976
+ var _a2;
22977
+ if (!this.sessionOptions.useChallenge) {
22978
+ throw new Error("useChallenge is set as false on start method");
22979
+ }
22980
+ await this.extensionEasycatcher.checkExtensionInstalled().catch((err) => {
22981
+ throw new Error("EasyCatcher Extension is not installed");
22982
+ });
22983
+ this.extensionEasycatcher.start();
22984
+ const start = Date.now() - ((_a2 = this.allRecorders.cameraRecorder.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
22985
+ await this.backend.startChallenge({
22986
+ proctoringId: this.proctoringId,
22987
+ templateId,
22988
+ start
22989
+ }).then((resp) => {
22990
+ console.log(resp);
22991
+ this.challengeId = resp.id;
22992
+ }).catch((reason) => {
22993
+ trackers.registerError(
22994
+ this.proctoringId,
22995
+ "N\xE3o foi poss\xEDvel iniciar desafio!"
22996
+ );
22997
+ throw reason;
22998
+ });
22999
+ this.isChallengeRunning = true;
23000
+ }
23001
+ async stopChallenge() {
23002
+ var _a2;
23003
+ if (!this.isChallengeRunning) {
23004
+ throw new Error("Challenge not started");
23005
+ }
23006
+ try {
23007
+ const sessionData = await this.extensionEasycatcher.getSessionData();
23008
+ const end = Date.now() - ((_a2 = this.allRecorders.cameraRecorder.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
23009
+ await this.backend.stopChallenge(
23010
+ this.challengeId,
23011
+ {
23012
+ end,
23013
+ data: sessionData
23014
+ }
23015
+ ).catch((reason) => {
23016
+ trackers.registerError(
23017
+ this.proctoringId,
23018
+ "N\xE3o foi poss\xEDvel finalizar o desafio no backend!"
23019
+ );
23020
+ return void 0;
23021
+ });
23022
+ this.isChallengeRunning = false;
23023
+ } catch (error) {
23024
+ trackers.registerError(
23025
+ this.proctoringId,
23026
+ "Erro ao recuperar dados da extens\xE3o: " + error.message
23027
+ );
23028
+ }
23029
+ }
22361
23030
  };
22362
23031
 
22363
23032
  // src/proctoring/SignTerm.ts
@@ -22585,6 +23254,8 @@ function useProctoring(proctoringOptions, enviromentConfig = "prod") {
22585
23254
  return originalStart(parameters2, videoOptions);
22586
23255
  };
22587
23256
  const finish = proctoring.finish.bind(proctoring);
23257
+ const startChallenge = proctoring.startChallenge.bind(proctoring);
23258
+ const stopChallenge = proctoring.stopChallenge.bind(proctoring);
22588
23259
  const pause = proctoring.pause.bind(proctoring);
22589
23260
  const resume = proctoring.resume.bind(proctoring);
22590
23261
  const onFocus = proctoring.setOnFocusCallback.bind(proctoring);
@@ -22607,6 +23278,8 @@ function useProctoring(proctoringOptions, enviromentConfig = "prod") {
22607
23278
  login,
22608
23279
  start,
22609
23280
  finish,
23281
+ startChallenge,
23282
+ stopChallenge,
22610
23283
  onFocus,
22611
23284
  onLostFocus,
22612
23285
  onChangeDevices: onChangeDevices2,