easyproctor-hml 0.0.27 → 0.0.28

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
@@ -29571,13 +29571,13 @@ var Proctoring = class {
29571
29571
  this.sessionOptions = { ...getDefaultProctoringOptions, ...options };
29572
29572
  this.videoOptions = validatePartialVideoOptions(_videoOptions);
29573
29573
  await this.initConfig();
29574
- console.log("verifyMultipleMonitors");
29575
- console.log("this.state" + this.state);
29574
+ alert("verifyMultipleMonitors");
29575
+ alert("this.state" + this.state);
29576
29576
  await this.verifyMultipleMonitors(this.sessionOptions);
29577
29577
  if (this.state != "Stop" /* Stop */) {
29578
29578
  throw PROCTORING_ALREADY_STARTED;
29579
29579
  }
29580
- console.log("change Status");
29580
+ alert("change Status");
29581
29581
  this.state = "Starting" /* Starting */;
29582
29582
  if (await this.repository.hasSessions()) {
29583
29583
  await this.repository.clear();
package/index.js CHANGED
@@ -41105,13 +41105,13 @@ var Proctoring = class {
41105
41105
  this.sessionOptions = { ...getDefaultProctoringOptions, ...options };
41106
41106
  this.videoOptions = validatePartialVideoOptions(_videoOptions);
41107
41107
  await this.initConfig();
41108
- console.log("verifyMultipleMonitors");
41109
- console.log("this.state" + this.state);
41108
+ alert("verifyMultipleMonitors");
41109
+ alert("this.state" + this.state);
41110
41110
  await this.verifyMultipleMonitors(this.sessionOptions);
41111
41111
  if (this.state != "Stop" /* Stop */) {
41112
41112
  throw PROCTORING_ALREADY_STARTED;
41113
41113
  }
41114
- console.log("change Status");
41114
+ alert("change Status");
41115
41115
  this.state = "Starting" /* Starting */;
41116
41116
  if (await this.repository.hasSessions()) {
41117
41117
  await this.repository.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor-hml",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -58,7 +58,7 @@ bitsperframe: %d
58
58
  Size: ${e.file.size}`,o),a}}throw new Error("Could not upload")}};var R0=class{constructor(e,r,n){this.alerts=[];this.onLostFocusCallback=e.onLostFocusCallback,this.onFocusCallback=e.onFocusCallback,this.onNoiseDetectedCallback=e.onNoiseDetectedCallback,this.optionsProctoring=r,this.cameraRecorder=n}async startRecording(){this.startTime=new Date(Date.now()),this.intervalNoiseDetection=setInterval(()=>this.onNoiseDetected(),500),this.optionsProctoring.captureScreen&&(window.addEventListener("blur",()=>this.onLostFocus()),window.addEventListener("focus",()=>this.onReturnFocus()))}async pauseRecording(){window.removeEventListener("blur",()=>this.onLostFocus()),window.removeEventListener("focus",()=>this.onReturnFocus()),window.removeEventListener("focus",()=>this.onNoiseDetected()),this.volumeMeter.stop(),clearInterval(this.intervalNoiseDetection)}async resumeRecording(){this.volumeMeter=void 0,this.intervalNoiseDetection=setInterval(()=>this.onNoiseDetected(),500),this.optionsProctoring.captureScreen&&(window.addEventListener("blur",()=>this.onLostFocus()),window.addEventListener("focus",()=>this.onReturnFocus()),window.addEventListener("focus",()=>this.onNoiseDetected()))}async stopRecording(){window.removeEventListener("blur",()=>this.onLostFocus()),window.removeEventListener("focus",()=>this.onReturnFocus()),window.removeEventListener("focus",()=>this.onNoiseDetected()),this.volumeMeter&&this.volumeMeter.stop(),clearInterval(this.intervalNoiseDetection)}async saveOnSession(e){this.alerts.forEach(r=>{e.addAlert(r)})}onLostFocus(){Date.now()-this.startTime?.getTime()>1e4&&(this.onLostFocusCallback(),this.alerts.push({begin:Date.now()-this.startTime.getTime(),end:0,alert:25}))}onReturnFocus(){let e=this.alerts[this.alerts.length-1];e&&(this.onFocusCallback(),e.end=Date.now()-this.startTime.getTime())}onNoiseDetected(){!this.volumeMeter&&this.cameraRecorder.cameraStream&&(this.volumeMeter=new Ja(this.cameraRecorder.cameraStream),this.volumeMeter.start().catch(e=>{console.log(e),this.volumeMeter=void 0})),this.volumeMeter?.getVolume()>=(this.optionsProctoring.noiseLimit||40)&&this.onNoiseDetectedCallback()}};var xp=gf();function bf(t){return new xp(t)}var T0=class{constructor(){this.blobs=[]}async startRecording(){this.recorder=bf({bitRate:128}),this.recorder.start().catch(e=>{throw new Error("Error on Audio to Start Recording")})}async pauseRecording(){}async resumeRecording(){}async stopRecording(){if(!this.recorder)return;let e=await this.recorder.stop().getMp3().then(async([r,n])=>({buffer:r,blob:n})).catch(r=>{alert("We could not retrieve your message")});e&&this.blobs.push(e.blob)}async saveOnSession(e){e.addRecording({device:"",file:new File(this.blobs,`EP_${e.id}_audio_0.mp3`,{type:"audio/mp3"}),origin:"Mic"})}};var E0=class{constructor(e){this.blobs=[];this.blobsFinal=[];this.options=e}async startRecording(){this.startTime=new Date(Date.now());let{allowOnlyFirstMonitor:e,onStopSharingScreenCallback:r}=this.options,n={video:{cursor:"always"},audio:!1};this.screenStream=await navigator.mediaDevices.getDisplayMedia(n);let i=this.screenStream.getVideoTracks();if(i[0].onended=r,navigator.userAgent.indexOf("Firefox")>-1&&!i.find(w=>w.label=="Primary Monitor")&&e)throw g0;if(!(i.find(d=>["screen:0:0","Primary Monitor"].includes(d.label))!=null)&&e)throw i.forEach(d=>{d.stop()}),hf;let{startRecording:l,stopRecording:c}=ho(this.screenStream,this.blobs);this.recordingStart=l,this.recordingStop=c,this.recordingStart()}async pauseRecording(){}async resumeRecording(){}async stopRecording(){await this.recordingStop()}async saveOnSession(e){e.addRecording({device:"",file:new File(this.blobs,`EP_${e.id}_screen_0.webm`,{type:"video/webm"}),origin:"Screen"})}};var $o=class{constructor(e,r){this.dbName="EasyProctorDb";this.dbVersion=2;this.storeName="exams2";this.dbName=e,this.storeName=r}async save(e){let{transaction:r,store:n}=await this.connectToStore("readwrite");return this.processRequest(n.put(e),r).then(()=>{})}async delete(e){let{transaction:r,store:n}=await this.connectToStore("readwrite");return this.processRequest(n.delete(e),r)}async get(e){let{transaction:r,store:n}=await this.connectToStore("readwrite");return this.processRequest(n.get(e),r).catch(()=>{})}async getDevices(e){let{transaction:r,store:n}=await this.connectToStore("readwrite");return this.processRequest(n.get(e),r).catch(()=>{})}async list(){let{transaction:e,store:r}=await this.connectToStore("readonly");return this.processRequest(r.getAll(),e)}async clear(){let{transaction:e,store:r}=await this.connectToStore("readwrite");return this.processRequest(r.clear(),e)}async processRequest(e,r){return new Promise((n,i)=>{e.onerror=a=>{i(e.error?.message)},e.onsuccess=a=>{r.commit(),n(e.result)}})}async hasSessions(){return(await this.list()).length>0}async connectToStore(e){let i=(await this.connect()).result.transaction(this.storeName,e),a=i.objectStore(this.storeName);return{transaction:i,store:a}}async connect(){return this.connection?this.connection:new Promise((e,r)=>{let n=window.indexedDB.open(this.dbName,this.dbVersion);n.onerror=i=>{r("Can't connect to IndexedDB")},n.onupgradeneeded=i=>{let a=n.result;a.onerror=o=>{},a.createObjectStore(this.storeName,{keyPath:"id"})},n.onsuccess=i=>{this.connection=n,e(n)}})}};var Zo=class{constructor(e,r){this.backend=r;this.proctoringId=e}async upload(e,r){let{file:n,onProgress:i}=e;try{let a=c=>{let d=c.loadedBytes/n.size*100;i&&i(Math.round(d))},o=await this.backend.getAwsSignedUrl(r,n),l=await wa.request({url:o,method:"PUT",headers:{"Content-Type":n.type},data:n,onUploadProgress:c=>{a({loadedBytes:c.loaded})}}).then(()=>!0).catch(()=>!1);return await this.backend.sendAwsToAzure(r,n),{storage:"AwsS3",url:o,uploaded:l}}catch{throw Qt.registerError(this.proctoringId,`Failed to upload to AWS
59
59
  File name: ${n.name}
60
60
  File type: ${n.type}
61
- File size: ${n.size}`),new Error("Failed to upload to AWS")}}};function Zc(){let t=window.navigator.userAgent.split("SEB/");return t.length>1?t[1]:"1.0.0.0"}var A0=class{constructor(e){this.context=e;this.proctoringId="";this.insights=void 0;this.state="Stop";this.serviceType="Upload";this.onStopSharingScreenCallback=()=>{console.log("Stop sharing screen"),Qt.registerStopSharingScreen(this.proctoringId,"Stop sharing screen")};this.onLostFocusCallback=()=>{};this.onFocusCallback=()=>{};this.onNoiseDetectedCallback=()=>{};this.backend=new x0({type:e.type}),this.repository=new $o("EasyProctorDb","exams2"),this.repositoryDevices=new $o("EasyProctorDbDevices","devices")}setOnStopSharingScreenCallback(e){this.onStopSharingScreenCallback=()=>e()}setOnLostFocusCallback(e){this.onLostFocusCallback=()=>e()}setOnFocusCallback(e){this.onFocusCallback=()=>e()}setOnNoiseDetectedCallback(e){this.onNoiseDetectedCallback=()=>e()}async onChangeDevices(e={}){new y0(this.repositoryDevices,this.proctoringId).startRecording(e)}createRecorders(e=Di){let r=new Qn({cameraId:this.sessionOptions.cameraId,microphoneId:this.sessionOptions.microphoneId},{width:this.videoOptions.width,height:this.videoOptions.height},this.backend,this.context.token,this.proctoringId),n=new T0,i=this.sessionOptions.captureScreen?new E0({allowOnlyFirstMonitor:this.sessionOptions.allowOnlyFirstMonitor??!0,onStopSharingScreenCallback:()=>this.onStopSharingScreenCallback()}):void 0,a=new R0({onFocusCallback:()=>this.onFocusCallback(),onLostFocusCallback:()=>this.onLostFocusCallback(),onNoiseDetectedCallback:()=>this.onNoiseDetectedCallback()},e,r);this.onChangeDevices();let o=[r,n,i,a].filter(Boolean);return this.recorder=new w0(this.proctoringSession,o),{cameraRecorder:r,audioRecorder:n,screenRecorder:i,alertRecorder:a}}async start(e=Di,r={}){try{this.extension=new S0,this.extension.addEventListener();let n=this.backend.selectBaseUrl(this.context.type),i=await An();if(await this.repositoryDevices.save({...i,id:"devices"}),this.sessionOptions={...Di,...e},this.videoOptions=p0(r),await this.initConfig(),console.log("verifyMultipleMonitors"),console.log("this.state"+this.state),await this.verifyMultipleMonitors(this.sessionOptions),this.state!="Stop")throw pf;console.log("change Status"),this.state="Starting",await this.repository.hasSessions()&&await this.repository.clear();let a=await this.backend.confirmStart({clientId:this.context.clientId,examId:this.context.examId,token:this.context.token},this.sessionOptions.proctoringType);return this.proctoringId=a.id,this.proctoringSession=new _s(this.proctoringId),this.allRecorders=this.createRecorders(this.sessionOptions),await this.recorder.startAll(),await this.repository.save(this.proctoringSession),Qt.registerStart(this.proctoringId,!0,""),a.cameraStream=this.allRecorders.cameraRecorder.cameraStream,this.allRecorders.screenRecorder&&(a.screenStream=this.allRecorders.screenRecorder.screenStream),this.state="Recording",a}catch(n){throw await this.cancel(),Qt.registerStart(this.proctoringId,!1,`Token: ${this.context.token}
61
+ File size: ${n.size}`),new Error("Failed to upload to AWS")}}};function Zc(){let t=window.navigator.userAgent.split("SEB/");return t.length>1?t[1]:"1.0.0.0"}var A0=class{constructor(e){this.context=e;this.proctoringId="";this.insights=void 0;this.state="Stop";this.serviceType="Upload";this.onStopSharingScreenCallback=()=>{console.log("Stop sharing screen"),Qt.registerStopSharingScreen(this.proctoringId,"Stop sharing screen")};this.onLostFocusCallback=()=>{};this.onFocusCallback=()=>{};this.onNoiseDetectedCallback=()=>{};this.backend=new x0({type:e.type}),this.repository=new $o("EasyProctorDb","exams2"),this.repositoryDevices=new $o("EasyProctorDbDevices","devices")}setOnStopSharingScreenCallback(e){this.onStopSharingScreenCallback=()=>e()}setOnLostFocusCallback(e){this.onLostFocusCallback=()=>e()}setOnFocusCallback(e){this.onFocusCallback=()=>e()}setOnNoiseDetectedCallback(e){this.onNoiseDetectedCallback=()=>e()}async onChangeDevices(e={}){new y0(this.repositoryDevices,this.proctoringId).startRecording(e)}createRecorders(e=Di){let r=new Qn({cameraId:this.sessionOptions.cameraId,microphoneId:this.sessionOptions.microphoneId},{width:this.videoOptions.width,height:this.videoOptions.height},this.backend,this.context.token,this.proctoringId),n=new T0,i=this.sessionOptions.captureScreen?new E0({allowOnlyFirstMonitor:this.sessionOptions.allowOnlyFirstMonitor??!0,onStopSharingScreenCallback:()=>this.onStopSharingScreenCallback()}):void 0,a=new R0({onFocusCallback:()=>this.onFocusCallback(),onLostFocusCallback:()=>this.onLostFocusCallback(),onNoiseDetectedCallback:()=>this.onNoiseDetectedCallback()},e,r);this.onChangeDevices();let o=[r,n,i,a].filter(Boolean);return this.recorder=new w0(this.proctoringSession,o),{cameraRecorder:r,audioRecorder:n,screenRecorder:i,alertRecorder:a}}async start(e=Di,r={}){try{this.extension=new S0,this.extension.addEventListener();let n=this.backend.selectBaseUrl(this.context.type),i=await An();if(await this.repositoryDevices.save({...i,id:"devices"}),this.sessionOptions={...Di,...e},this.videoOptions=p0(r),await this.initConfig(),alert("verifyMultipleMonitors"),alert("this.state"+this.state),await this.verifyMultipleMonitors(this.sessionOptions),this.state!="Stop")throw pf;alert("change Status"),this.state="Starting",await this.repository.hasSessions()&&await this.repository.clear();let a=await this.backend.confirmStart({clientId:this.context.clientId,examId:this.context.examId,token:this.context.token},this.sessionOptions.proctoringType);return this.proctoringId=a.id,this.proctoringSession=new _s(this.proctoringId),this.allRecorders=this.createRecorders(this.sessionOptions),await this.recorder.startAll(),await this.repository.save(this.proctoringSession),Qt.registerStart(this.proctoringId,!0,""),a.cameraStream=this.allRecorders.cameraRecorder.cameraStream,this.allRecorders.screenRecorder&&(a.screenStream=this.allRecorders.screenRecorder.screenStream),this.state="Recording",a}catch(n){throw await this.cancel(),Qt.registerStart(this.proctoringId,!1,`Token: ${this.context.token}
62
62
  Error: `+n),this.state="Stop",n}}async cancel(){(this.state==="Recording"||this.state==="Starting")&&await this.recorder.stopAll(),this.state="Stop"}async finish(e={}){if(this.extension.options=e,this.state!=="Recording")throw b0;await this.recorder.stopAll(),await this.recorder.saveAllOnSession(),await this.repository.save(this.proctoringSession);let r,n;Zc()!=="1.0.0.0"?(r=new to(this.proctoringSession,this.proctoringId,[new eo(this.proctoringId)]),n="Download",this.serviceType="Download"):(r=new to(this.proctoringSession,this.proctoringId,[new da(this.proctoringId,this.backend),new Zo(this.proctoringId,this.backend),new eo(this.proctoringId)]),n="Azure, AWS, Download",this.serviceType="Upload");let i=!1;this.extension.hasExtension&&await this.extension.start().then(a=>{i=a}).catch(a=>{i=!1}),(!i||!this.extension.hasExtension)&&(await r.upload(this.context.token,e.onProgress).catch(async a=>{Qt.registerUpload(this.proctoringSession.id,!1,`upload error: ${a}
63
63
 
64
64
  Upload Services: ${n}`,this.serviceType),Zc()!=="1.0.0.0"&&(r=new to(this.proctoringSession,this.proctoringId,[new da(this.proctoringId,this.backend),new Zo(this.proctoringId,this.backend),new eo(this.proctoringId)]),n="Azure, AWS, Download",this.serviceType="Upload",await r.upload(this.context.token,e.onProgress).catch(o=>{Qt.registerUpload(this.proctoringSession.id,!1,`upload backup error: ${o}