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/index.js CHANGED
@@ -14011,6 +14011,493 @@ var require_jszip_min = __commonJS({
14011
14011
  }
14012
14012
  });
14013
14013
 
14014
+ // node_modules/fix-webm-duration/fix-webm-duration.js
14015
+ var require_fix_webm_duration = __commonJS({
14016
+ "node_modules/fix-webm-duration/fix-webm-duration.js"(exports2, module2) {
14017
+ (function(name, definition) {
14018
+ if (typeof define === "function" && define.amd) {
14019
+ define(definition);
14020
+ } else if (typeof module2 !== "undefined" && module2.exports) {
14021
+ module2.exports = definition();
14022
+ } else {
14023
+ window.ysFixWebmDuration = definition();
14024
+ }
14025
+ })("fix-webm-duration", function() {
14026
+ var sections = {
14027
+ 172351395: { name: "EBML", type: "Container" },
14028
+ 646: { name: "EBMLVersion", type: "Uint" },
14029
+ 759: { name: "EBMLReadVersion", type: "Uint" },
14030
+ 754: { name: "EBMLMaxIDLength", type: "Uint" },
14031
+ 755: { name: "EBMLMaxSizeLength", type: "Uint" },
14032
+ 642: { name: "DocType", type: "String" },
14033
+ 647: { name: "DocTypeVersion", type: "Uint" },
14034
+ 645: { name: "DocTypeReadVersion", type: "Uint" },
14035
+ 108: { name: "Void", type: "Binary" },
14036
+ 63: { name: "CRC-32", type: "Binary" },
14037
+ 190023271: { name: "SignatureSlot", type: "Container" },
14038
+ 16010: { name: "SignatureAlgo", type: "Uint" },
14039
+ 16026: { name: "SignatureHash", type: "Uint" },
14040
+ 16037: { name: "SignaturePublicKey", type: "Binary" },
14041
+ 16053: { name: "Signature", type: "Binary" },
14042
+ 15963: { name: "SignatureElements", type: "Container" },
14043
+ 15995: { name: "SignatureElementList", type: "Container" },
14044
+ 9522: { name: "SignedElement", type: "Binary" },
14045
+ 139690087: { name: "Segment", type: "Container" },
14046
+ 21863284: { name: "SeekHead", type: "Container" },
14047
+ 3515: { name: "Seek", type: "Container" },
14048
+ 5035: { name: "SeekID", type: "Binary" },
14049
+ 5036: { name: "SeekPosition", type: "Uint" },
14050
+ 88713574: { name: "Info", type: "Container" },
14051
+ 13220: { name: "SegmentUID", type: "Binary" },
14052
+ 13188: { name: "SegmentFilename", type: "String" },
14053
+ 1882403: { name: "PrevUID", type: "Binary" },
14054
+ 1868715: { name: "PrevFilename", type: "String" },
14055
+ 2013475: { name: "NextUID", type: "Binary" },
14056
+ 1999803: { name: "NextFilename", type: "String" },
14057
+ 1092: { name: "SegmentFamily", type: "Binary" },
14058
+ 10532: { name: "ChapterTranslate", type: "Container" },
14059
+ 10748: { name: "ChapterTranslateEditionUID", type: "Uint" },
14060
+ 10687: { name: "ChapterTranslateCodec", type: "Uint" },
14061
+ 10661: { name: "ChapterTranslateID", type: "Binary" },
14062
+ 710577: { name: "TimecodeScale", type: "Uint" },
14063
+ 1161: { name: "Duration", type: "Float" },
14064
+ 1121: { name: "DateUTC", type: "Date" },
14065
+ 15273: { name: "Title", type: "String" },
14066
+ 3456: { name: "MuxingApp", type: "String" },
14067
+ 5953: { name: "WritingApp", type: "String" },
14068
+ // 0xf43b675: { name: 'Cluster', type: 'Container' },
14069
+ 103: { name: "Timecode", type: "Uint" },
14070
+ 6228: { name: "SilentTracks", type: "Container" },
14071
+ 6359: { name: "SilentTrackNumber", type: "Uint" },
14072
+ 39: { name: "Position", type: "Uint" },
14073
+ 43: { name: "PrevSize", type: "Uint" },
14074
+ 35: { name: "SimpleBlock", type: "Binary" },
14075
+ 32: { name: "BlockGroup", type: "Container" },
14076
+ 33: { name: "Block", type: "Binary" },
14077
+ 34: { name: "BlockVirtual", type: "Binary" },
14078
+ 13729: { name: "BlockAdditions", type: "Container" },
14079
+ 38: { name: "BlockMore", type: "Container" },
14080
+ 110: { name: "BlockAddID", type: "Uint" },
14081
+ 37: { name: "BlockAdditional", type: "Binary" },
14082
+ 27: { name: "BlockDuration", type: "Uint" },
14083
+ 122: { name: "ReferencePriority", type: "Uint" },
14084
+ 123: { name: "ReferenceBlock", type: "Int" },
14085
+ 125: { name: "ReferenceVirtual", type: "Int" },
14086
+ 36: { name: "CodecState", type: "Binary" },
14087
+ 13730: { name: "DiscardPadding", type: "Int" },
14088
+ 14: { name: "Slices", type: "Container" },
14089
+ 104: { name: "TimeSlice", type: "Container" },
14090
+ 76: { name: "LaceNumber", type: "Uint" },
14091
+ 77: { name: "FrameNumber", type: "Uint" },
14092
+ 75: { name: "BlockAdditionID", type: "Uint" },
14093
+ 78: { name: "Delay", type: "Uint" },
14094
+ 79: { name: "SliceDuration", type: "Uint" },
14095
+ 72: { name: "ReferenceFrame", type: "Container" },
14096
+ 73: { name: "ReferenceOffset", type: "Uint" },
14097
+ 74: { name: "ReferenceTimeCode", type: "Uint" },
14098
+ 47: { name: "EncryptedBlock", type: "Binary" },
14099
+ 106212971: { name: "Tracks", type: "Container" },
14100
+ 46: { name: "TrackEntry", type: "Container" },
14101
+ 87: { name: "TrackNumber", type: "Uint" },
14102
+ 13253: { name: "TrackUID", type: "Uint" },
14103
+ 3: { name: "TrackType", type: "Uint" },
14104
+ 57: { name: "FlagEnabled", type: "Uint" },
14105
+ 8: { name: "FlagDefault", type: "Uint" },
14106
+ 5546: { name: "FlagForced", type: "Uint" },
14107
+ 28: { name: "FlagLacing", type: "Uint" },
14108
+ 11751: { name: "MinCache", type: "Uint" },
14109
+ 11768: { name: "MaxCache", type: "Uint" },
14110
+ 254851: { name: "DefaultDuration", type: "Uint" },
14111
+ 216698: { name: "DefaultDecodedFieldDuration", type: "Uint" },
14112
+ 209231: { name: "TrackTimecodeScale", type: "Float" },
14113
+ 4991: { name: "TrackOffset", type: "Int" },
14114
+ 5614: { name: "MaxBlockAdditionID", type: "Uint" },
14115
+ 4974: { name: "Name", type: "String" },
14116
+ 177564: { name: "Language", type: "String" },
14117
+ 6: { name: "CodecID", type: "String" },
14118
+ 9122: { name: "CodecPrivate", type: "Binary" },
14119
+ 362120: { name: "CodecName", type: "String" },
14120
+ 13382: { name: "AttachmentLink", type: "Uint" },
14121
+ 1742487: { name: "CodecSettings", type: "String" },
14122
+ 1785920: { name: "CodecInfoURL", type: "String" },
14123
+ 438848: { name: "CodecDownloadURL", type: "String" },
14124
+ 42: { name: "CodecDecodeAll", type: "Uint" },
14125
+ 12203: { name: "TrackOverlay", type: "Uint" },
14126
+ 5802: { name: "CodecDelay", type: "Uint" },
14127
+ 5819: { name: "SeekPreRoll", type: "Uint" },
14128
+ 9764: { name: "TrackTranslate", type: "Container" },
14129
+ 9980: { name: "TrackTranslateEditionUID", type: "Uint" },
14130
+ 9919: { name: "TrackTranslateCodec", type: "Uint" },
14131
+ 9893: { name: "TrackTranslateTrackID", type: "Binary" },
14132
+ 96: { name: "Video", type: "Container" },
14133
+ 26: { name: "FlagInterlaced", type: "Uint" },
14134
+ 5048: { name: "StereoMode", type: "Uint" },
14135
+ 5056: { name: "AlphaMode", type: "Uint" },
14136
+ 5049: { name: "OldStereoMode", type: "Uint" },
14137
+ 48: { name: "PixelWidth", type: "Uint" },
14138
+ 58: { name: "PixelHeight", type: "Uint" },
14139
+ 5290: { name: "PixelCropBottom", type: "Uint" },
14140
+ 5307: { name: "PixelCropTop", type: "Uint" },
14141
+ 5324: { name: "PixelCropLeft", type: "Uint" },
14142
+ 5341: { name: "PixelCropRight", type: "Uint" },
14143
+ 5296: { name: "DisplayWidth", type: "Uint" },
14144
+ 5306: { name: "DisplayHeight", type: "Uint" },
14145
+ 5298: { name: "DisplayUnit", type: "Uint" },
14146
+ 5299: { name: "AspectRatioType", type: "Uint" },
14147
+ 963876: { name: "ColourSpace", type: "Binary" },
14148
+ 1029411: { name: "GammaValue", type: "Float" },
14149
+ 230371: { name: "FrameRate", type: "Float" },
14150
+ 97: { name: "Audio", type: "Container" },
14151
+ 53: { name: "SamplingFrequency", type: "Float" },
14152
+ 14517: { name: "OutputSamplingFrequency", type: "Float" },
14153
+ 31: { name: "Channels", type: "Uint" },
14154
+ 15739: { name: "ChannelPositions", type: "Binary" },
14155
+ 8804: { name: "BitDepth", type: "Uint" },
14156
+ 98: { name: "TrackOperation", type: "Container" },
14157
+ 99: { name: "TrackCombinePlanes", type: "Container" },
14158
+ 100: { name: "TrackPlane", type: "Container" },
14159
+ 101: { name: "TrackPlaneUID", type: "Uint" },
14160
+ 102: { name: "TrackPlaneType", type: "Uint" },
14161
+ 105: { name: "TrackJoinBlocks", type: "Container" },
14162
+ 109: { name: "TrackJoinUID", type: "Uint" },
14163
+ 64: { name: "TrickTrackUID", type: "Uint" },
14164
+ 65: { name: "TrickTrackSegmentUID", type: "Binary" },
14165
+ 70: { name: "TrickTrackFlag", type: "Uint" },
14166
+ 71: { name: "TrickMasterTrackUID", type: "Uint" },
14167
+ 68: { name: "TrickMasterTrackSegmentUID", type: "Binary" },
14168
+ 11648: { name: "ContentEncodings", type: "Container" },
14169
+ 8768: { name: "ContentEncoding", type: "Container" },
14170
+ 4145: { name: "ContentEncodingOrder", type: "Uint" },
14171
+ 4146: { name: "ContentEncodingScope", type: "Uint" },
14172
+ 4147: { name: "ContentEncodingType", type: "Uint" },
14173
+ 4148: { name: "ContentCompression", type: "Container" },
14174
+ 596: { name: "ContentCompAlgo", type: "Uint" },
14175
+ 597: { name: "ContentCompSettings", type: "Binary" },
14176
+ 4149: { name: "ContentEncryption", type: "Container" },
14177
+ 2017: { name: "ContentEncAlgo", type: "Uint" },
14178
+ 2018: { name: "ContentEncKeyID", type: "Binary" },
14179
+ 2019: { name: "ContentSignature", type: "Binary" },
14180
+ 2020: { name: "ContentSigKeyID", type: "Binary" },
14181
+ 2021: { name: "ContentSigAlgo", type: "Uint" },
14182
+ 2022: { name: "ContentSigHashAlgo", type: "Uint" },
14183
+ 206814059: { name: "Cues", type: "Container" },
14184
+ 59: { name: "CuePoint", type: "Container" },
14185
+ 51: { name: "CueTime", type: "Uint" },
14186
+ 55: { name: "CueTrackPositions", type: "Container" },
14187
+ 119: { name: "CueTrack", type: "Uint" },
14188
+ 113: { name: "CueClusterPosition", type: "Uint" },
14189
+ 112: { name: "CueRelativePosition", type: "Uint" },
14190
+ 50: { name: "CueDuration", type: "Uint" },
14191
+ 4984: { name: "CueBlockNumber", type: "Uint" },
14192
+ 106: { name: "CueCodecState", type: "Uint" },
14193
+ 91: { name: "CueReference", type: "Container" },
14194
+ 22: { name: "CueRefTime", type: "Uint" },
14195
+ 23: { name: "CueRefCluster", type: "Uint" },
14196
+ 4959: { name: "CueRefNumber", type: "Uint" },
14197
+ 107: { name: "CueRefCodecState", type: "Uint" },
14198
+ 155296873: { name: "Attachments", type: "Container" },
14199
+ 8615: { name: "AttachedFile", type: "Container" },
14200
+ 1662: { name: "FileDescription", type: "String" },
14201
+ 1646: { name: "FileName", type: "String" },
14202
+ 1632: { name: "FileMimeType", type: "String" },
14203
+ 1628: { name: "FileData", type: "Binary" },
14204
+ 1710: { name: "FileUID", type: "Uint" },
14205
+ 1653: { name: "FileReferral", type: "Binary" },
14206
+ 1633: { name: "FileUsedStartTime", type: "Uint" },
14207
+ 1634: { name: "FileUsedEndTime", type: "Uint" },
14208
+ 4433776: { name: "Chapters", type: "Container" },
14209
+ 1465: { name: "EditionEntry", type: "Container" },
14210
+ 1468: { name: "EditionUID", type: "Uint" },
14211
+ 1469: { name: "EditionFlagHidden", type: "Uint" },
14212
+ 1499: { name: "EditionFlagDefault", type: "Uint" },
14213
+ 1501: { name: "EditionFlagOrdered", type: "Uint" },
14214
+ 54: { name: "ChapterAtom", type: "Container" },
14215
+ 13252: { name: "ChapterUID", type: "Uint" },
14216
+ 5716: { name: "ChapterStringUID", type: "String" },
14217
+ 17: { name: "ChapterTimeStart", type: "Uint" },
14218
+ 18: { name: "ChapterTimeEnd", type: "Uint" },
14219
+ 24: { name: "ChapterFlagHidden", type: "Uint" },
14220
+ 1432: { name: "ChapterFlagEnabled", type: "Uint" },
14221
+ 11879: { name: "ChapterSegmentUID", type: "Binary" },
14222
+ 11964: { name: "ChapterSegmentEditionUID", type: "Uint" },
14223
+ 9155: { name: "ChapterPhysicalEquiv", type: "Uint" },
14224
+ 15: { name: "ChapterTrack", type: "Container" },
14225
+ 9: { name: "ChapterTrackNumber", type: "Uint" },
14226
+ 0: { name: "ChapterDisplay", type: "Container" },
14227
+ 5: { name: "ChapString", type: "String" },
14228
+ 892: { name: "ChapLanguage", type: "String" },
14229
+ 894: { name: "ChapCountry", type: "String" },
14230
+ 10564: { name: "ChapProcess", type: "Container" },
14231
+ 10581: { name: "ChapProcessCodecID", type: "Uint" },
14232
+ 1293: { name: "ChapProcessPrivate", type: "Binary" },
14233
+ 10513: { name: "ChapProcessCommand", type: "Container" },
14234
+ 10530: { name: "ChapProcessTime", type: "Uint" },
14235
+ 10547: { name: "ChapProcessData", type: "Binary" },
14236
+ 39109479: { name: "Tags", type: "Container" },
14237
+ 13171: { name: "Tag", type: "Container" },
14238
+ 9152: { name: "Targets", type: "Container" },
14239
+ 10442: { name: "TargetTypeValue", type: "Uint" },
14240
+ 9162: { name: "TargetType", type: "String" },
14241
+ 9157: { name: "TagTrackUID", type: "Uint" },
14242
+ 9161: { name: "TagEditionUID", type: "Uint" },
14243
+ 9156: { name: "TagChapterUID", type: "Uint" },
14244
+ 9158: { name: "TagAttachmentUID", type: "Uint" },
14245
+ 10184: { name: "SimpleTag", type: "Container" },
14246
+ 1443: { name: "TagName", type: "String" },
14247
+ 1146: { name: "TagLanguage", type: "String" },
14248
+ 1156: { name: "TagDefault", type: "Uint" },
14249
+ 1159: { name: "TagString", type: "String" },
14250
+ 1157: { name: "TagBinary", type: "Binary" }
14251
+ };
14252
+ function doInherit(newClass, baseClass) {
14253
+ newClass.prototype = Object.create(baseClass.prototype);
14254
+ newClass.prototype.constructor = newClass;
14255
+ }
14256
+ function WebmBase(name, type) {
14257
+ this.name = name || "Unknown";
14258
+ this.type = type || "Unknown";
14259
+ }
14260
+ WebmBase.prototype.updateBySource = function() {
14261
+ };
14262
+ WebmBase.prototype.setSource = function(source) {
14263
+ this.source = source;
14264
+ this.updateBySource();
14265
+ };
14266
+ WebmBase.prototype.updateByData = function() {
14267
+ };
14268
+ WebmBase.prototype.setData = function(data) {
14269
+ this.data = data;
14270
+ this.updateByData();
14271
+ };
14272
+ function WebmUint(name, type) {
14273
+ WebmBase.call(this, name, type || "Uint");
14274
+ }
14275
+ doInherit(WebmUint, WebmBase);
14276
+ function padHex(hex) {
14277
+ return hex.length % 2 === 1 ? "0" + hex : hex;
14278
+ }
14279
+ WebmUint.prototype.updateBySource = function() {
14280
+ this.data = "";
14281
+ for (var i3 = 0; i3 < this.source.length; i3++) {
14282
+ var hex = this.source[i3].toString(16);
14283
+ this.data += padHex(hex);
14284
+ }
14285
+ };
14286
+ WebmUint.prototype.updateByData = function() {
14287
+ var length = this.data.length / 2;
14288
+ this.source = new Uint8Array(length);
14289
+ for (var i3 = 0; i3 < length; i3++) {
14290
+ var hex = this.data.substr(i3 * 2, 2);
14291
+ this.source[i3] = parseInt(hex, 16);
14292
+ }
14293
+ };
14294
+ WebmUint.prototype.getValue = function() {
14295
+ return parseInt(this.data, 16);
14296
+ };
14297
+ WebmUint.prototype.setValue = function(value) {
14298
+ this.setData(padHex(value.toString(16)));
14299
+ };
14300
+ function WebmFloat(name, type) {
14301
+ WebmBase.call(this, name, type || "Float");
14302
+ }
14303
+ doInherit(WebmFloat, WebmBase);
14304
+ WebmFloat.prototype.getFloatArrayType = function() {
14305
+ return this.source && this.source.length === 4 ? Float32Array : Float64Array;
14306
+ };
14307
+ WebmFloat.prototype.updateBySource = function() {
14308
+ var byteArray = this.source.reverse();
14309
+ var floatArrayType = this.getFloatArrayType();
14310
+ var floatArray = new floatArrayType(byteArray.buffer);
14311
+ this.data = floatArray[0];
14312
+ };
14313
+ WebmFloat.prototype.updateByData = function() {
14314
+ var floatArrayType = this.getFloatArrayType();
14315
+ var floatArray = new floatArrayType([this.data]);
14316
+ var byteArray = new Uint8Array(floatArray.buffer);
14317
+ this.source = byteArray.reverse();
14318
+ };
14319
+ WebmFloat.prototype.getValue = function() {
14320
+ return this.data;
14321
+ };
14322
+ WebmFloat.prototype.setValue = function(value) {
14323
+ this.setData(value);
14324
+ };
14325
+ function WebmContainer(name, type) {
14326
+ WebmBase.call(this, name, type || "Container");
14327
+ }
14328
+ doInherit(WebmContainer, WebmBase);
14329
+ WebmContainer.prototype.readByte = function() {
14330
+ return this.source[this.offset++];
14331
+ };
14332
+ WebmContainer.prototype.readUint = function() {
14333
+ var firstByte = this.readByte();
14334
+ var bytes = 8 - firstByte.toString(2).length;
14335
+ var value = firstByte - (1 << 7 - bytes);
14336
+ for (var i3 = 0; i3 < bytes; i3++) {
14337
+ value *= 256;
14338
+ value += this.readByte();
14339
+ }
14340
+ return value;
14341
+ };
14342
+ WebmContainer.prototype.updateBySource = function() {
14343
+ this.data = [];
14344
+ for (this.offset = 0; this.offset < this.source.length; this.offset = end) {
14345
+ var id = this.readUint();
14346
+ var len = this.readUint();
14347
+ var end = Math.min(this.offset + len, this.source.length);
14348
+ var data = this.source.slice(this.offset, end);
14349
+ var info = sections[id] || { name: "Unknown", type: "Unknown" };
14350
+ var ctr = WebmBase;
14351
+ switch (info.type) {
14352
+ case "Container":
14353
+ ctr = WebmContainer;
14354
+ break;
14355
+ case "Uint":
14356
+ ctr = WebmUint;
14357
+ break;
14358
+ case "Float":
14359
+ ctr = WebmFloat;
14360
+ break;
14361
+ }
14362
+ var section = new ctr(info.name, info.type);
14363
+ section.setSource(data);
14364
+ this.data.push({
14365
+ id,
14366
+ idHex: id.toString(16),
14367
+ data: section
14368
+ });
14369
+ }
14370
+ };
14371
+ WebmContainer.prototype.writeUint = function(x3, draft) {
14372
+ for (var bytes = 1, flag = 128; x3 >= flag && bytes < 8; bytes++, flag *= 128) {
14373
+ }
14374
+ if (!draft) {
14375
+ var value = flag + x3;
14376
+ for (var i3 = bytes - 1; i3 >= 0; i3--) {
14377
+ var c3 = value % 256;
14378
+ this.source[this.offset + i3] = c3;
14379
+ value = (value - c3) / 256;
14380
+ }
14381
+ }
14382
+ this.offset += bytes;
14383
+ };
14384
+ WebmContainer.prototype.writeSections = function(draft) {
14385
+ this.offset = 0;
14386
+ for (var i3 = 0; i3 < this.data.length; i3++) {
14387
+ var section = this.data[i3], content = section.data.source, contentLength = content.length;
14388
+ this.writeUint(section.id, draft);
14389
+ this.writeUint(contentLength, draft);
14390
+ if (!draft) {
14391
+ this.source.set(content, this.offset);
14392
+ }
14393
+ this.offset += contentLength;
14394
+ }
14395
+ return this.offset;
14396
+ };
14397
+ WebmContainer.prototype.updateByData = function() {
14398
+ var length = this.writeSections("draft");
14399
+ this.source = new Uint8Array(length);
14400
+ this.writeSections();
14401
+ };
14402
+ WebmContainer.prototype.getSectionById = function(id) {
14403
+ for (var i3 = 0; i3 < this.data.length; i3++) {
14404
+ var section = this.data[i3];
14405
+ if (section.id === id) {
14406
+ return section.data;
14407
+ }
14408
+ }
14409
+ return null;
14410
+ };
14411
+ function WebmFile(source) {
14412
+ WebmContainer.call(this, "File", "File");
14413
+ this.setSource(source);
14414
+ }
14415
+ doInherit(WebmFile, WebmContainer);
14416
+ WebmFile.prototype.fixDuration = function(duration, options) {
14417
+ var logger = options && options.logger;
14418
+ if (logger === void 0) {
14419
+ logger = function(message) {
14420
+ console.log(message);
14421
+ };
14422
+ } else if (!logger) {
14423
+ logger = function() {
14424
+ };
14425
+ }
14426
+ var segmentSection = this.getSectionById(139690087);
14427
+ if (!segmentSection) {
14428
+ logger("[fix-webm-duration] Segment section is missing");
14429
+ return false;
14430
+ }
14431
+ var infoSection = segmentSection.getSectionById(88713574);
14432
+ if (!infoSection) {
14433
+ logger("[fix-webm-duration] Info section is missing");
14434
+ return false;
14435
+ }
14436
+ var timeScaleSection = infoSection.getSectionById(710577);
14437
+ if (!timeScaleSection) {
14438
+ logger("[fix-webm-duration] TimecodeScale section is missing");
14439
+ return false;
14440
+ }
14441
+ var durationSection = infoSection.getSectionById(1161);
14442
+ if (durationSection) {
14443
+ if (durationSection.getValue() <= 0) {
14444
+ logger(`[fix-webm-duration] Duration section is present, but the value is ${durationSection.getValue()}`);
14445
+ durationSection.setValue(duration);
14446
+ } else {
14447
+ logger(`[fix-webm-duration] Duration section is present, and the value is ${durationSection.getValue()}`);
14448
+ return false;
14449
+ }
14450
+ } else {
14451
+ logger("[fix-webm-duration] Duration section is missing");
14452
+ durationSection = new WebmFloat("Duration", "Float");
14453
+ durationSection.setValue(duration);
14454
+ infoSection.data.push({
14455
+ id: 1161,
14456
+ data: durationSection
14457
+ });
14458
+ }
14459
+ timeScaleSection.setValue(1e6);
14460
+ infoSection.updateByData();
14461
+ segmentSection.updateByData();
14462
+ this.updateByData();
14463
+ return true;
14464
+ };
14465
+ WebmFile.prototype.toBlob = function(mimeType) {
14466
+ return new Blob([this.source.buffer], { type: mimeType || "video/webm" });
14467
+ };
14468
+ function fixWebmDuration3(blob, duration, callback, options) {
14469
+ if (typeof callback === "object") {
14470
+ options = callback;
14471
+ callback = void 0;
14472
+ }
14473
+ if (!callback) {
14474
+ return new Promise(function(resolve) {
14475
+ fixWebmDuration3(blob, duration, resolve, options);
14476
+ });
14477
+ }
14478
+ try {
14479
+ var reader = new FileReader();
14480
+ reader.onloadend = function() {
14481
+ try {
14482
+ var file = new WebmFile(new Uint8Array(reader.result));
14483
+ if (file.fixDuration(duration, options)) {
14484
+ blob = file.toBlob(blob.type);
14485
+ }
14486
+ } catch (ex) {
14487
+ }
14488
+ callback(blob);
14489
+ };
14490
+ reader.readAsArrayBuffer(blob);
14491
+ } catch (ex) {
14492
+ callback(blob);
14493
+ }
14494
+ }
14495
+ fixWebmDuration3.default = fixWebmDuration3;
14496
+ return fixWebmDuration3;
14497
+ });
14498
+ }
14499
+ });
14500
+
14014
14501
  // node_modules/file-saver/dist/FileSaver.min.js
14015
14502
  var require_FileSaver_min = __commonJS({
14016
14503
  "node_modules/file-saver/dist/FileSaver.min.js"(exports2, module2) {
@@ -26127,7 +26614,7 @@ var FaceDetection = class extends BaseDetection {
26127
26614
  stopDetection() {
26128
26615
  super.stopDetection();
26129
26616
  if (this.emmitedFaceAlert) {
26130
- this.handleOk("face_ok", "face_detection_on_stream");
26617
+ this.handleOk("face_stop", "face_detection_on_stream");
26131
26618
  }
26132
26619
  }
26133
26620
  // displayVideoDetections(result: { detections: any; }) {
@@ -30355,6 +30842,7 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
30355
30842
  buffer.push(e3.data);
30356
30843
  }
30357
30844
  if (stopped) {
30845
+ console.log("buildMediaRecorder ondataavailable stopped");
30358
30846
  resolvePromise && resolvePromise();
30359
30847
  }
30360
30848
  };
@@ -30424,6 +30912,9 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
30424
30912
  if (mediaRecorder.state == "recording") {
30425
30913
  console.log("stopRecording Recorder est\xE1 em estado recording, iniciando stop");
30426
30914
  resolvePromise = resolve;
30915
+ mediaRecorder.onstop = () => {
30916
+ console.log("recorder onstop");
30917
+ };
30427
30918
  stopped = true;
30428
30919
  mediaRecorder.stop();
30429
30920
  } else {
@@ -30839,6 +31330,7 @@ var VolumeMeter = class {
30839
31330
 
30840
31331
  // src/new-flow/recorders/CameraRecorder.ts
30841
31332
  var import_jszip_min = __toESM(require_jszip_min());
31333
+ var import_fix_webm_duration = __toESM(require_fix_webm_duration());
30842
31334
  var CameraRecorder = class {
30843
31335
  constructor(options, videoOptions, paramsConfig, backend, backendToken) {
30844
31336
  this.blobs = [];
@@ -30889,6 +31381,7 @@ var CameraRecorder = class {
30889
31381
  this.hardwareStream = null;
30890
31382
  this.internalClonedStream = null;
30891
31383
  this.videoElement = null;
31384
+ this.duration = 0;
30892
31385
  this.currentRetries = 0;
30893
31386
  this.packageCount = 0;
30894
31387
  this.noiseWait = 20;
@@ -31113,10 +31606,17 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31113
31606
  console.log("Camera Recorder started OK");
31114
31607
  }
31115
31608
  async stopRecording() {
31116
- var _a2, _b, _c2;
31609
+ var _a2, _b, _c2, _d;
31117
31610
  console.log("Camera Recorder stopRecording");
31118
31611
  this.isCanvasLoopActive = false;
31612
+ this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
31613
+ this.objectDetection && this.objectDetection.detecting && this.objectDetection.stopDetection();
31614
+ clearInterval(this.imageInterval);
31615
+ clearInterval(this.sendFrameInterval);
31616
+ this.volumeMeter && this.volumeMeter.stop();
31617
+ this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
31119
31618
  this.recordingStop && await this.recordingStop();
31619
+ this.duration = Date.now() - ((_a2 = this.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
31120
31620
  try {
31121
31621
  if (this.animationFrameId) {
31122
31622
  cancelAnimationFrame(this.animationFrameId);
@@ -31134,28 +31634,22 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31134
31634
  this.hardwareStream = null;
31135
31635
  }
31136
31636
  if (this.videoElement) {
31137
- (_a2 = this.videoElement) == null ? void 0 : _a2.remove();
31637
+ (_b = this.videoElement) == null ? void 0 : _b.remove();
31138
31638
  this.videoElement = null;
31139
31639
  }
31140
31640
  if (this.video) {
31141
- (_b = this.video) == null ? void 0 : _b.remove();
31641
+ (_c2 = this.video) == null ? void 0 : _c2.remove();
31142
31642
  }
31143
31643
  if (this.canvas) {
31144
- (_c2 = this.canvas) == null ? void 0 : _c2.remove();
31644
+ (_d = this.canvas) == null ? void 0 : _d.remove();
31145
31645
  }
31146
31646
  } catch {
31147
31647
  console.error("Erro ao parar os streams de m\xEDdia.");
31148
31648
  }
31149
- this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
31150
- this.objectDetection && this.objectDetection.detecting && this.objectDetection.stopDetection();
31151
- clearInterval(this.imageInterval);
31152
- clearInterval(this.sendFrameInterval);
31153
31649
  if (this.options.proctoringType == "REALTIME" && this.upload && this.backendToken) {
31154
31650
  await this.sendPackage(this.filesToUpload);
31155
31651
  await this.filesToUpload.splice(0, this.filesToUpload.length);
31156
31652
  }
31157
- this.volumeMeter && this.volumeMeter.stop();
31158
- this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
31159
31653
  }
31160
31654
  async pauseRecording() {
31161
31655
  await this.recordingPause();
@@ -31289,6 +31783,15 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31289
31783
  const settings = this.cameraStream.getVideoTracks()[0].getSettings();
31290
31784
  const settingsAudio = this.cameraStream.getAudioTracks()[0].getSettings();
31291
31785
  if (this.options.proctoringType == "VIDEO" || this.options.proctoringType == "REALTIME" || this.options.proctoringType == "IMAGE" && ((_a2 = this.paramsConfig.imageBehaviourParameters) == null ? void 0 : _a2.saveVideo)) {
31786
+ const rawBlob = new Blob(this.blobs, {
31787
+ type: ((_b = this.recorderOptions) == null ? void 0 : _b.mimeType) || "video/webm"
31788
+ });
31789
+ const fixedBlob = await (0, import_fix_webm_duration.default)(rawBlob, this.duration);
31790
+ const file = new File(
31791
+ [fixedBlob],
31792
+ `EP_${session.id}_camera_0.webm`,
31793
+ { type: rawBlob.type }
31794
+ );
31292
31795
  session.addRecording({
31293
31796
  device: `Audio
31294
31797
  Sample Rate: ${settingsAudio.sampleRate}
@@ -31296,9 +31799,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31296
31799
 
31297
31800
  Video:
31298
31801
  ${JSON.stringify(this.recorderOptions)}`,
31299
- file: new File(this.blobs, `EP_${session.id}_camera_0.webm`, {
31300
- type: ((_b = this.recorderOptions) == null ? void 0 : _b.mimeType) || "video/webm"
31301
- }),
31802
+ file,
31302
31803
  origin: "Camera" /* Camera */
31303
31804
  });
31304
31805
  }
@@ -33023,8 +33524,8 @@ var CapturePhoto = class {
33023
33524
  }
33024
33525
  };
33025
33526
 
33026
- // src/extension/extension.ts
33027
- var Extension = class {
33527
+ // src/extension/extensionEasyProctor.ts
33528
+ var ExtensionEasyProctor = class {
33028
33529
  constructor() {
33029
33530
  this.hasExtension = false;
33030
33531
  this.tryes = 0;
@@ -33069,6 +33570,89 @@ var Extension = class {
33069
33570
  }
33070
33571
  };
33071
33572
 
33573
+ // src/extension/extensionEasyCatcher.ts
33574
+ var ExtensionEasyCatcher = class {
33575
+ constructor(options) {
33576
+ this.hasExtension = false;
33577
+ this.tryes = 0;
33578
+ this.responseStart = false;
33579
+ this.options = options || {};
33580
+ }
33581
+ /**
33582
+ * Verifica se a extensão está instalada e ativa.
33583
+ * Retorna o número da versão se encontrada, ou lança erro após timeout.
33584
+ */
33585
+ checkExtensionInstalled(timeoutMs = 2e3) {
33586
+ return new Promise((resolve, reject) => {
33587
+ let handled = false;
33588
+ const handler = (event) => {
33589
+ if (event.source === window && event.data.sender === "easyproctor-extension" && event.data.message_name === "version") {
33590
+ handled = true;
33591
+ window.removeEventListener("message", handler);
33592
+ resolve(event.data.message);
33593
+ }
33594
+ };
33595
+ window.addEventListener("message", handler);
33596
+ window.postMessage({
33597
+ type: "easycatcher",
33598
+ func: "verifyExtensionEasycatcher"
33599
+ }, "*");
33600
+ setTimeout(() => {
33601
+ if (!handled) {
33602
+ window.removeEventListener("message", handler);
33603
+ reject(new Error("Extens\xE3o n\xE3o detectada ou n\xE3o respondeu."));
33604
+ }
33605
+ }, timeoutMs);
33606
+ });
33607
+ }
33608
+ /**
33609
+ * Solicita o JSON da sessão atual capturado pela extensão.
33610
+ */
33611
+ getSessionData(timeoutMs = 5e3) {
33612
+ return new Promise((resolve, reject) => {
33613
+ let handled = false;
33614
+ const handler = (event) => {
33615
+ if (event.source === window && event.data.sender === "easyproctor-extension" && event.data.message_name === "data_response") {
33616
+ handled = true;
33617
+ window.removeEventListener("message", handler);
33618
+ resolve(event.data.payload);
33619
+ }
33620
+ };
33621
+ window.addEventListener("message", handler);
33622
+ window.postMessage({
33623
+ type: "easycatcher",
33624
+ func: "getDataExtensionEasycatcher"
33625
+ }, "*");
33626
+ setTimeout(() => {
33627
+ if (!handled) {
33628
+ window.removeEventListener("message", handler);
33629
+ reject(new Error("Timeout ao aguardar dados da extens\xE3o."));
33630
+ }
33631
+ }, timeoutMs);
33632
+ });
33633
+ }
33634
+ start() {
33635
+ return new Promise((resolve, reject) => {
33636
+ let handled = false;
33637
+ const handler = (event) => {
33638
+ if (event.source === window && event.data.sender === "easyproctor-extension" && event.data.message_name === "started_confirmed") {
33639
+ handled = true;
33640
+ window.removeEventListener("message", handler);
33641
+ resolve(true);
33642
+ }
33643
+ };
33644
+ window.addEventListener("message", handler);
33645
+ window.postMessage({ type: "easycatcher", func: "startExtensionEasycatcher" }, "*");
33646
+ setTimeout(() => {
33647
+ if (!handled) {
33648
+ window.removeEventListener("message", handler);
33649
+ reject(new Error("Timeout: Extens\xE3o n\xE3o confirmou o in\xEDcio."));
33650
+ }
33651
+ }, 3e3);
33652
+ });
33653
+ }
33654
+ };
33655
+
33072
33656
  // src/modules/onChangeDevices.ts
33073
33657
  var onChangeDevices = class {
33074
33658
  constructor(repositoryDevices, proctoringId2, sessionOptions, allRecorders) {
@@ -33265,6 +33849,22 @@ var ProctoringUploader = class {
33265
33849
  }
33266
33850
  },
33267
33851
  token
33852
+ ).catch(
33853
+ async (e3) => {
33854
+ console.log("Upload File Error", e3), trackers.registerError(this.proctoringId, `Upload File
33855
+ Name: ${rec.file.name}
33856
+ Error: ${e3.message}
33857
+ Size: ${e3.error}`);
33858
+ await uploadService.upload(
33859
+ {
33860
+ file: rec.file,
33861
+ onProgress: (progress) => {
33862
+ if (onProgress) onProgress(progress);
33863
+ }
33864
+ },
33865
+ token
33866
+ );
33867
+ }
33268
33868
  );
33269
33869
  if (result) {
33270
33870
  let fileType = "";
@@ -35973,10 +36573,12 @@ registerProcessor("audio-processor", AudioProcessor);
35973
36573
  `;
35974
36574
 
35975
36575
  // src/new-flow/recorders/ScreenRecorder.ts
36576
+ var import_fix_webm_duration2 = __toESM(require_fix_webm_duration());
35976
36577
  var ScreenRecorder = class {
35977
36578
  constructor(options) {
35978
36579
  this.blobs = [];
35979
36580
  this.blobsFinal = [];
36581
+ this.duration = 0;
35980
36582
  this.options = options;
35981
36583
  }
35982
36584
  setProctoringId(proctoringId2) {
@@ -36058,15 +36660,24 @@ var ScreenRecorder = class {
36058
36660
  async resumeRecording() {
36059
36661
  }
36060
36662
  async stopRecording() {
36663
+ var _a2;
36061
36664
  this.recordingStop && await this.recordingStop();
36665
+ this.duration = Date.now() - ((_a2 = this.startTime) == null ? void 0 : _a2.getTime()) || 0;
36062
36666
  }
36063
36667
  async saveOnSession(session) {
36064
36668
  if (isMobileDevice()) return;
36669
+ const rawBlob = new Blob(this.blobs, {
36670
+ type: "video/webm"
36671
+ });
36672
+ const fixedBlob = await (0, import_fix_webm_duration2.default)(rawBlob, this.duration);
36673
+ const file = new File(
36674
+ [fixedBlob],
36675
+ `EP_${session.id}_screen_0.webm`,
36676
+ { type: rawBlob.type }
36677
+ );
36065
36678
  session.addRecording({
36066
36679
  device: "",
36067
- file: new File(this.blobs, `EP_${session.id}_screen_0.webm`, {
36068
- type: "video/webm"
36069
- }),
36680
+ file,
36070
36681
  origin: "Screen" /* Screen */
36071
36682
  });
36072
36683
  }
@@ -37144,7 +37755,7 @@ var Proctoring = class {
37144
37755
  begin: alert.begin,
37145
37756
  end: alert.end,
37146
37757
  warningCategoryEnum: this.convertRealtimeTypeToWarningType(alert.type),
37147
- alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64(),
37758
+ alertImageBase64: alert.description !== "face_stop" ? await this.allRecorders.cameraRecorder.getCurrentImageBase64() : "",
37148
37759
  retry: verifyCount < verifyMaxRetries - 1 ? true : false
37149
37760
  });
37150
37761
  return response;
@@ -37257,7 +37868,10 @@ var Proctoring = class {
37257
37868
  if (this.context.token === void 0) {
37258
37869
  throw TOKEN_MISSING;
37259
37870
  }
37260
- this.extension = new Extension();
37871
+ if (options.useChallenge) {
37872
+ this.extensionEasycatcher = new ExtensionEasyCatcher();
37873
+ }
37874
+ this.extension = new ExtensionEasyProctor();
37261
37875
  this.extension.addEventListener();
37262
37876
  const baseURL = this.backend.selectBaseUrl(this.context.type);
37263
37877
  const devices = await enumarateDevices();
@@ -37346,7 +37960,7 @@ Navigator: ${JSON.stringify(_navigator2)}`
37346
37960
  verifyingFace = true;
37347
37961
  verifyFirstFaceIntervalCount++;
37348
37962
  try {
37349
- var response = await this.backend.verifyFace(this.proctoringId, await this.allRecorders.cameraRecorder.getCurrentImageBase64(), verifyFirstFaceIntervalCount > 5 ? false : true);
37963
+ var response = await this.backend.verifyFace(this.proctoringId, await this.allRecorders.cameraRecorder.getCurrentImageBase64(), verifyFirstFaceIntervalCount > 2 ? false : true);
37350
37964
  verifyingFace = false;
37351
37965
  clearInterval(this.verifyFirstFaceInterval);
37352
37966
  } catch (error) {
@@ -37354,7 +37968,7 @@ Navigator: ${JSON.stringify(_navigator2)}`
37354
37968
  return;
37355
37969
  }
37356
37970
  }
37357
- }, 1500);
37971
+ }, 5e3);
37358
37972
  return startResponse;
37359
37973
  } catch (error) {
37360
37974
  console.log(error);
@@ -37607,6 +38221,61 @@ Error: ` + error
37607
38221
  _screenStream: (_a2 = this.allRecorders.screenRecorder) == null ? void 0 : _a2.screenStream
37608
38222
  };
37609
38223
  }
38224
+ async startChallenge(templateId) {
38225
+ var _a2;
38226
+ if (!this.sessionOptions.useChallenge) {
38227
+ throw new Error("useChallenge is set as false on start method");
38228
+ }
38229
+ await this.extensionEasycatcher.checkExtensionInstalled().catch((err) => {
38230
+ throw new Error("EasyCatcher Extension is not installed");
38231
+ });
38232
+ this.extensionEasycatcher.start();
38233
+ const start = Date.now() - ((_a2 = this.allRecorders.cameraRecorder.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
38234
+ await this.backend.startChallenge({
38235
+ proctoringId: this.proctoringId,
38236
+ templateId,
38237
+ start
38238
+ }).then((resp) => {
38239
+ console.log(resp);
38240
+ this.challengeId = resp.id;
38241
+ }).catch((reason) => {
38242
+ trackers.registerError(
38243
+ this.proctoringId,
38244
+ "N\xE3o foi poss\xEDvel iniciar desafio!"
38245
+ );
38246
+ throw reason;
38247
+ });
38248
+ this.isChallengeRunning = true;
38249
+ }
38250
+ async stopChallenge() {
38251
+ var _a2;
38252
+ if (!this.isChallengeRunning) {
38253
+ throw new Error("Challenge not started");
38254
+ }
38255
+ try {
38256
+ const sessionData = await this.extensionEasycatcher.getSessionData();
38257
+ const end = Date.now() - ((_a2 = this.allRecorders.cameraRecorder.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
38258
+ await this.backend.stopChallenge(
38259
+ this.challengeId,
38260
+ {
38261
+ end,
38262
+ data: sessionData
38263
+ }
38264
+ ).catch((reason) => {
38265
+ trackers.registerError(
38266
+ this.proctoringId,
38267
+ "N\xE3o foi poss\xEDvel finalizar o desafio no backend!"
38268
+ );
38269
+ return void 0;
38270
+ });
38271
+ this.isChallengeRunning = false;
38272
+ } catch (error) {
38273
+ trackers.registerError(
38274
+ this.proctoringId,
38275
+ "Erro ao recuperar dados da extens\xE3o: " + error.message
38276
+ );
38277
+ }
38278
+ }
37610
38279
  };
37611
38280
 
37612
38281
  // src/proctoring/SignTerm.ts
@@ -37834,6 +38503,8 @@ function useProctoring(proctoringOptions, enviromentConfig = "prod") {
37834
38503
  return originalStart(parameters2, videoOptions);
37835
38504
  };
37836
38505
  const finish = proctoring.finish.bind(proctoring);
38506
+ const startChallenge = proctoring.startChallenge.bind(proctoring);
38507
+ const stopChallenge = proctoring.stopChallenge.bind(proctoring);
37837
38508
  const pause = proctoring.pause.bind(proctoring);
37838
38509
  const resume = proctoring.resume.bind(proctoring);
37839
38510
  const onFocus = proctoring.setOnFocusCallback.bind(proctoring);
@@ -37856,6 +38527,8 @@ function useProctoring(proctoringOptions, enviromentConfig = "prod") {
37856
38527
  login,
37857
38528
  start,
37858
38529
  finish,
38530
+ startChallenge,
38531
+ stopChallenge,
37859
38532
  onFocus,
37860
38533
  onLostFocus,
37861
38534
  onChangeDevices: onChangeDevices2,