easyproctor-hml 2.3.2 → 2.3.3

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
@@ -18523,8 +18523,10 @@ Upload Services: ${uploaderServices}`,
18523
18523
  "finish error: " + error
18524
18524
  );
18525
18525
  });
18526
- const externalSessionId = this.appChecker.getExternalCameraSessionId();
18527
- await this.backend.externalCameraFinish(externalSessionId);
18526
+ if (this.appChecker) {
18527
+ const externalSessionId = this.appChecker.getExternalCameraSessionId();
18528
+ await this.backend.externalCameraFinish(externalSessionId);
18529
+ }
18528
18530
  this.state = "Stop" /* Stop */;
18529
18531
  } catch (error) {
18530
18532
  await this.cancel();
package/index.js CHANGED
@@ -33772,8 +33772,10 @@ Upload Services: ${uploaderServices}`,
33772
33772
  "finish error: " + error
33773
33773
  );
33774
33774
  });
33775
- const externalSessionId = this.appChecker.getExternalCameraSessionId();
33776
- await this.backend.externalCameraFinish(externalSessionId);
33775
+ if (this.appChecker) {
33776
+ const externalSessionId = this.appChecker.getExternalCameraSessionId();
33777
+ await this.backend.externalCameraFinish(externalSessionId);
33778
+ }
33777
33779
  this.state = "Stop" /* Stop */;
33778
33780
  } catch (error) {
33779
33781
  await this.cancel();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor-hml",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -306,13 +306,13 @@ registerProcessor("audio-processor", AudioProcessor);
306
306
  Navigator: ${JSON.stringify(s)}`),i.cameraStream=this.allRecorders.cameraRecorder.cameraStream,this.allRecorders.screenRecorder&&(i.screenStream=this.allRecorders.screenRecorder.screenStream),this.state="Recording",i}catch(n){throw await this.cancel(),this.proctoringId&&N.registerStart(this.proctoringId,!1,`Token: ${this.context.token}
307
307
  Version: ${Ti()}
308
308
  Navigator: ${navigator}
309
- Error: ${n}`),this.state="Stop",n}}async cancel(){(this.state==="Recording"||this.state==="Starting")&&(await this.recorder.stopAll(),this.spyCam&&await this.spyCam.stopCheckSpyCam()),this.state="Stop"}async finish(t={}){try{if(this.extension.options=t,this.state!=="Recording")throw aa;await this.recorder.stopAll(),this.spyCam&&this.spyCam.stopCheckSpyCam(),this.appChecker&&await this.appChecker.disconnectWebSocket(),await this.recorder.saveAllOnSession(),await this.repository.save(this.proctoringSession);let r,n;Ti()!=="1.0.0.0"?(r=new so(this.proctoringSession,this.proctoringId,[new io(this.proctoringId)]),n="Download",this.serviceType="Download"):(r=new so(this.proctoringSession,this.proctoringId,[new ir(this.proctoringId,this.backend),new io(this.proctoringId)]),n="Upload",this.serviceType="Upload");let o=!1;this.extension.hasExtension&&await this.extension.start().then(s=>{o=s}).catch(s=>{o=!1}),(!o||!this.extension.hasExtension)&&(await r.upload(this.context.token,t.onProgress).catch(async s=>{N.registerUpload(this.proctoringSession.id,!1,`upload error: ${s}
309
+ Error: ${n}`),this.state="Stop",n}}async cancel(){(this.state==="Recording"||this.state==="Starting")&&(await this.recorder.stopAll(),this.spyCam&&await this.spyCam.stopCheckSpyCam()),this.state="Stop"}async finish(t={}){try{if(this.extension.options=t,this.state!=="Recording")throw aa;await this.recorder.stopAll(),this.spyCam&&this.spyCam.stopCheckSpyCam(),this.appChecker&&await this.appChecker.disconnectWebSocket(),await this.recorder.saveAllOnSession(),await this.repository.save(this.proctoringSession);let r,n;Ti()!=="1.0.0.0"?(r=new so(this.proctoringSession,this.proctoringId,[new io(this.proctoringId)]),n="Download",this.serviceType="Download"):(r=new so(this.proctoringSession,this.proctoringId,[new ir(this.proctoringId,this.backend),new io(this.proctoringId)]),n="Upload",this.serviceType="Upload");let o=!1;if(this.extension.hasExtension&&await this.extension.start().then(i=>{o=i}).catch(i=>{o=!1}),(!o||!this.extension.hasExtension)&&(await r.upload(this.context.token,t.onProgress).catch(async i=>{N.registerUpload(this.proctoringSession.id,!1,`upload error: ${i}
310
310
 
311
- Upload Services: ${n}`,this.serviceType),Ti()!=="1.0.0.0"&&(r=new so(this.proctoringSession,this.proctoringId,[new ir(this.proctoringId,this.backend),new io(this.proctoringId)]),n="Upload",this.serviceType="Upload",n="Download",this.serviceType="Download",await r.upload(this.context.token,t.onProgress).catch(a=>{N.registerUpload(this.proctoringSession.id,!1,`upload backup error: ${a}
311
+ Upload Services: ${n}`,this.serviceType),Ti()!=="1.0.0.0"&&(r=new so(this.proctoringSession,this.proctoringId,[new ir(this.proctoringId,this.backend),new io(this.proctoringId)]),n="Upload",this.serviceType="Upload",n="Download",this.serviceType="Download",await r.upload(this.context.token,t.onProgress).catch(s=>{N.registerUpload(this.proctoringSession.id,!1,`upload backup error: ${s}
312
312
 
313
313
  Upload Services: ${n}
314
314
  Upload backup for Safe Browser`,this.serviceType)}))}),N.registerUpload(this.proctoringSession.id,!0,`upload success
315
315
 
316
- Upload Services: ${n}`,this.serviceType)),this.proctoringSession.alerts.length>0&&await this.backend.saveAlerts(this.context,this.proctoringSession).catch(s=>{N.registerFinish(this.proctoringSession.id,!1,"save-screen error: "+s)}),await this.backend.finishAndSendUrls(this.context,this.proctoringSession).then(()=>{N.registerFinish(this.proctoringSession.id,!0,"")}).catch(s=>{N.registerFinish(this.proctoringSession.id,!1,"finish error: "+s)});let i=this.appChecker.getExternalCameraSessionId();await this.backend.externalCameraFinish(i),this.state="Stop"}catch(r){throw await this.cancel(),N.registerFinish(this.proctoringId,!1,`Token: ${this.context.token}
316
+ Upload Services: ${n}`,this.serviceType)),this.proctoringSession.alerts.length>0&&await this.backend.saveAlerts(this.context,this.proctoringSession).catch(i=>{N.registerFinish(this.proctoringSession.id,!1,"save-screen error: "+i)}),await this.backend.finishAndSendUrls(this.context,this.proctoringSession).then(()=>{N.registerFinish(this.proctoringSession.id,!0,"")}).catch(i=>{N.registerFinish(this.proctoringSession.id,!1,"finish error: "+i)}),this.appChecker){let i=this.appChecker.getExternalCameraSessionId();await this.backend.externalCameraFinish(i)}this.state="Stop"}catch(r){throw await this.cancel(),N.registerFinish(this.proctoringId,!1,`Token: ${this.context.token}
317
317
  Error: `+r),this.state="Stop",r}}async verifyMultipleMonitors(t){if(!t.allowMultipleMonitors&&await $i())throw N.registerError(this.proctoringId,"Multiplas telas detectadas!"),sa}async verifyBrowser(){let t=await J2();if(t!=="chrome"&&t!=="firefox")throw N.registerBrowserNotSupported(this.proctoringId,`Browser n\xE3o suportado:
318
318
  Tentativa utilizando o browser ${t}`),Rg}async initConfig(t){try{let r=await this.backend.getParamsConfig(this.context);this.paramsConfig={...this.paramsConfig,...r,audioBehaviourParameters:{...this.paramsConfig.audioBehaviourParameters,...r.audioBehaviourParameters},imageBehaviourParameters:{...this.paramsConfig.imageBehaviourParameters,...r.imageBehaviourParameters},videoBehaviourParameters:{...this.paramsConfig.videoBehaviourParameters,...r.videoBehaviourParameters}},t&&(this.geolocation=await Y2().then(n=>n).catch(n=>{throw n.message})),Cg(this.backend),this.sessionOptions?.useSpyScan&&(this.spyCam=new Xn(this.context,{onRealtimeAlertsCallback:n=>this.onRealtimeAlertsCallback(n)}))}catch(r){throw this.proctoringId&&N.registerError(this.proctoringId,"Erro no initConfig!"),await this.cancel(),r}}async getServerDate(){let t=await this.backend.getServerHour(this.context.token).catch(n=>{N.registerError(this.proctoringId,"N\xE3o foi poss\xEDvel requisitar a data do servidor!")});return t?new Date(t.toString()):new Date}async pause(){if(this.state!=="Recording")throw N.registerError(this.proctoringId,"Proctoring n\xE3o iniciado!"),aa;await this.recorder.stopAll(),await this.recorder.saveAllOnSession(),await this.repository.save(this.proctoringSession),this.state="Paused"}async resume(){if(this.state!="Paused")throw aa;return await this.verifyBrowser(),await this.verifyMultipleMonitors(this.sessionOptions),await this.recorder.startAll(),this.proctoringSession.recordings=[],await this.repository.save(this.proctoringSession),this.state="Recording",{cameraStream:this.allRecorders.cameraRecorder.cameraStream,_screenStream:this.allRecorders.screenRecorder?.screenStream}}};var Dc=class e{static{this.isModalOpen=!1}constructor(t){this.backend=new ft({type:t?.type||"prod",token:t.token})}async signInTerms(){if(e.isModalOpen)return Promise.reject();e.isModalOpen=!0;try{let t=await this.openModal();return new Promise(r=>{r(t)})}catch(t){return this.closeModal(),Promise.reject(t)}}openModal(){return new Promise((t,r)=>{let n=document.createElement("div");n.setAttribute("id","signTermModal");let o={backgroundColor:"rgba(0,0,0,0.4)",zIndex:"1000",position:"fixed",top:"0",left:"0",height:"100vh",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"};this.applyStyles(n,o);let i=document.createElement("div"),s={backgroundColor:"#fff",zIndex:"1001",width:"850px",maxHeight:"95%",borderRadius:"10px",display:"flex",flexDirection:"column",alignItems:"center"};this.applyStyles(i,s);let a=document.createElement("h3");a.innerText="Termo de consentimento para coleta e uso de dados";let c={color:"rgba(0, 0, 0, .7)",fontWeight:"bold",fontSize:"20px",marginBottom:"15px",padding:"20px 0px",borderBottom:"2px solid rgba(0, 0, 0, .1)",width:"100%",textAlign:"center"};this.applyStyles(a,c),i.appendChild(a);let l=document.createElement("iframe"),h="https://docs.google.com/document/u/3/d/e/2PACX-1vRMgrLhDLyDP8BHmotfPDpwAFaDHqK-mA4eBJ0Cy1mDdvHcWLsx47H4otII_4qi4rhtSf6B0OO97e9c/pub";this.backend.signTermUrl().then(se=>{if(!se)throw new Error("N\xE3o foi poss\xEDvel obter o termo de consentimento");l.setAttribute("src",se)}).catch(()=>{l.setAttribute("src",h)});let u={width:"100%",height:"500px",border:"1px solid rgba(0, 0, 0, .1)",margin:"20px",borderRadius:"5px"};this.applyStyles(l,u),i.appendChild(l);let p=document.createElement("div"),g=document.createElement("input");g.setAttribute("type","checkbox"),g.setAttribute("id","termsCheckbox");let m=document.createElement("label");m.setAttribute("for","termsCheckbox"),m.innerText="Li e aceito os termos e condi\xE7\xF5es";let y={display:"flex",alignItems:"center",gap:"10px",margin:"20px",width:"100%",paddingLeft:"20px"};this.applyStyles(p,y),p.appendChild(g),p.appendChild(m),i.appendChild(p);let b=document.createElement("div"),w={width:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderTop:"2px solid rgba(0, 0, 0, .1)"};this.applyStyles(b,w);let S=document.createElement("button");S.innerText="Cancelar";let A={width:"100%",height:"70px",backgroundColor:"#FFF",border:"none",color:"rgba(0, 0, 0, .7)",fontWeight:"bold",borderRadius:"10px",paddingTop:"5px",paddingBottom:"5px"};this.applyStyles(S,A),S.addEventListener("click",()=>{this.closeModal(),t(!1)});let B=document.createElement("span"),O={width:"3px",height:"70px",margin:"0px 2px",background:"rgba(0, 0, 0, .1)"};this.applyStyles(B,O);let R=document.createElement("button");R.innerText="Continuar",R.setAttribute("id","confirmBtn");let de={width:"100%",height:"70px",backgroundColor:"#FFF",border:"none",color:"rgba(0, 0, 0, .7)",fontWeight:"bold",borderRadius:"10px",paddingTop:"5px",paddingBottom:"5px",disabled:!0,cursor:"not-allowed"};this.applyStyles(R,de),R.disabled=!0,R.addEventListener("click",()=>{this.closeModal(),this.backend.signTerm().then(()=>{t(!0)})}),g.addEventListener("change",se=>{R.disabled=!se.target.checked,se.target.checked?(R.style.color="#007bff",R.style.cursor="pointer"):(R.style.color="rgba(0, 0, 0, .7)",R.style.cursor="not-allowed")}),b.appendChild(S),b.appendChild(B),b.appendChild(R),i.appendChild(b),n.appendChild(i),document.body.appendChild(n)})}async closeModal(){e.isModalOpen=!1,document.querySelector("#signTermModal")?.remove()}applyStyles(t,r){for(let[n,o]of Object.entries(r))t.style[n]=o}};function yd(e,t="prod"){e.showConsole||(console.log=()=>{},console.warn=()=>{},console.error=()=>{});let r={type:t,clientId:e.clientId,examId:e.examId,token:e.token,credentials:e.credentials,showConsole:e.showConsole},n=new Rc(r),o=new ha(r),i=new oo(r,()=>{}),s=new Dc(r),a=new Jn,c=n.login.bind(n),l=n.start.bind(n),h=n.finish.bind(n),u=n.pause.bind(n),p=n.resume.bind(n),g=n.setOnFocusCallback.bind(n),m=n.setOnLostFocusCallback.bind(n),y=n.onChangeDevices.bind(n),b=n.setOnBufferSizeErrorCallback.bind(n),w=n.setOnStopSharingScreenCallback.bind(n),S=n.onRealtimeAlerts.bind(n),A=s.signInTerms.bind(s),B=o.checkDevices.bind(o),O=i.checkExternalCamera.bind(i),R=o.runCheckDevicesFlow.bind(o),de=o.changeSelectedDevice.bind(o),se=a.takePicture.bind(a);return{login:c,start:l,finish:h,onFocus:g,onLostFocus:m,onChangeDevices:y,onBufferSizeError:b,onRealtimeAlerts:S,checkDevices:B,runCheckDevicesFlow:R,changeSelectedDevice:de,capturePhoto:se,enumarateDevices:St,checkPermissions:zi,checkIfhasMultipleMonitors:$i,onStopSharingScreen:w,signInTerms:A,checkExternalCamera:O}}typeof window<"u"&&(window.useProctoring=yd);})();