easyproctor-hml 2.4.1 → 2.4.2
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 +4 -2
- package/index.js +4 -2
- package/package.json +1 -1
- package/proctoring/proctoring.d.ts +1 -0
- package/unpkg/easyproctor.min.js +2 -2
- package/unpkg/easyproctor.min.js.map +7 -0
package/esm/index.js
CHANGED
|
@@ -13248,6 +13248,7 @@ var Proctoring = class {
|
|
|
13248
13248
|
constructor(context) {
|
|
13249
13249
|
this.context = context;
|
|
13250
13250
|
this.deviceData = null;
|
|
13251
|
+
this.sessionStartTime = 0;
|
|
13251
13252
|
this.paramsConfig = {
|
|
13252
13253
|
audioBehaviourParameters: {
|
|
13253
13254
|
recordingBitrate: 128,
|
|
@@ -13447,6 +13448,7 @@ var Proctoring = class {
|
|
|
13447
13448
|
this.geolocation ? this.geolocation.coords.longitude : void 0
|
|
13448
13449
|
);
|
|
13449
13450
|
this.proctoringId = startResponse.id;
|
|
13451
|
+
this.sessionStartTime = Date.now();
|
|
13450
13452
|
trackers.registerDevicesChecked(
|
|
13451
13453
|
this.proctoringId,
|
|
13452
13454
|
!!this.deviceData,
|
|
@@ -13721,7 +13723,7 @@ Error: ` + error
|
|
|
13721
13723
|
throw new Error("EasyCatcher Extension is not installed");
|
|
13722
13724
|
});
|
|
13723
13725
|
this.extensionEasycatcher.start();
|
|
13724
|
-
const start = Date.now();
|
|
13726
|
+
const start = Date.now() - this.sessionStartTime;
|
|
13725
13727
|
await this.backend.startChallenge({
|
|
13726
13728
|
proctoringId: this.proctoringId,
|
|
13727
13729
|
templateId,
|
|
@@ -13744,7 +13746,7 @@ Error: ` + error
|
|
|
13744
13746
|
}
|
|
13745
13747
|
try {
|
|
13746
13748
|
const sessionData = await this.extensionEasycatcher.getSessionData();
|
|
13747
|
-
const end = Date.now();
|
|
13749
|
+
const end = Date.now() - this.sessionStartTime;
|
|
13748
13750
|
await this.backend.stopChallenge(
|
|
13749
13751
|
this.challengeId,
|
|
13750
13752
|
{
|
package/index.js
CHANGED
|
@@ -25663,6 +25663,7 @@ var Proctoring = class {
|
|
|
25663
25663
|
constructor(context) {
|
|
25664
25664
|
this.context = context;
|
|
25665
25665
|
this.deviceData = null;
|
|
25666
|
+
this.sessionStartTime = 0;
|
|
25666
25667
|
this.paramsConfig = {
|
|
25667
25668
|
audioBehaviourParameters: {
|
|
25668
25669
|
recordingBitrate: 128,
|
|
@@ -25862,6 +25863,7 @@ var Proctoring = class {
|
|
|
25862
25863
|
this.geolocation ? this.geolocation.coords.longitude : void 0
|
|
25863
25864
|
);
|
|
25864
25865
|
this.proctoringId = startResponse.id;
|
|
25866
|
+
this.sessionStartTime = Date.now();
|
|
25865
25867
|
trackers.registerDevicesChecked(
|
|
25866
25868
|
this.proctoringId,
|
|
25867
25869
|
!!this.deviceData,
|
|
@@ -26136,7 +26138,7 @@ Error: ` + error
|
|
|
26136
26138
|
throw new Error("EasyCatcher Extension is not installed");
|
|
26137
26139
|
});
|
|
26138
26140
|
this.extensionEasycatcher.start();
|
|
26139
|
-
const start = Date.now();
|
|
26141
|
+
const start = Date.now() - this.sessionStartTime;
|
|
26140
26142
|
await this.backend.startChallenge({
|
|
26141
26143
|
proctoringId: this.proctoringId,
|
|
26142
26144
|
templateId,
|
|
@@ -26159,7 +26161,7 @@ Error: ` + error
|
|
|
26159
26161
|
}
|
|
26160
26162
|
try {
|
|
26161
26163
|
const sessionData = await this.extensionEasycatcher.getSessionData();
|
|
26162
|
-
const end = Date.now();
|
|
26164
|
+
const end = Date.now() - this.sessionStartTime;
|
|
26163
26165
|
await this.backend.stopChallenge(
|
|
26164
26166
|
this.challengeId,
|
|
26165
26167
|
{
|
package/package.json
CHANGED
package/unpkg/easyproctor.min.js
CHANGED
|
@@ -294,7 +294,7 @@ registerProcessor("audio-processor", AudioProcessor);
|
|
|
294
294
|
0% { transform: rotate(0deg); }
|
|
295
295
|
100% { transform: rotate(360deg); }
|
|
296
296
|
}
|
|
297
|
-
`,n=document.createElement("style");n.innerHTML=i,document.head.appendChild(n)}};var sa=class{constructor(t){this.context=t;this.deviceData=null;this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128,noiseLimit:40},imageBehaviourParameters:{frames:40,useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectFace:!1,detectPerson:!1,detectCellPhone:!1,detectNoise:!1,detectSpeech:!1}};this.proctoringId="";this.insights=void 0;this.state="Stop";this.serviceType="Upload";this.onStopSharingScreenCallback=()=>{};this.onLostFocusCallback=()=>{};this.onFocusCallback=()=>{};this.onChangeDevicesCallback=t=>{};this.onRealtimeAlertsCallback=t=>{};this.onBufferSizeErrorCallback=t=>{};this.backend=new Ct({type:t.type||"prod",token:t.token}),this.repository=new In("EasyProctorDb","exams2"),this.repositoryDevices=new In("EasyProctorDbDevices","devices"),this.context.credentials?.cpf&&(this.auth=new oa(this.context.credentials.cpf,this.backend))}setOnStopSharingScreenCallback(t){this.onStopSharingScreenCallback=async()=>{D.registerStopSharingScreen(this.proctoringId,"Stop sharing screen"),this.allRecorders?.alertRecorder?.addAlert({alert:34,type:3}),this.allRecorders?.screenRecorder?.stopRecording(),t()}}setOnLostFocusCallback(t){this.onLostFocusCallback=()=>t()}setOnFocusCallback(t){this.onFocusCallback=()=>t()}async onChangeDevices(t={}){new vs(this.repositoryDevices,this.proctoringId,this.sessionOptions,this.allRecorders).startRecording(t),this.onChangeDevicesCallback=i=>t.status&&t.status(i)}async onRealtimeAlerts(t={}){this.onRealtimeAlertsCallback=r=>t.data&&t.data(r)}setOnBufferSizeErrorCallback(t){this.onBufferSizeErrorCallback=r=>t(r)}setDeviceCheckData(t){this.deviceData=t}createRecorders(t=et){this.onChangeDevices();let r=new Vt({cameraId:this.sessionOptions.cameraId,microphoneId:this.sessionOptions.microphoneId,onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:a=>this.onBufferSizeErrorCallback(a),proctoringType:this.sessionOptions.proctoringType,onChangeDevicesCallback:a=>this.onChangeDevicesCallback(a),onRealtimeAlertsCallback:a=>this.onRealtimeAlertsCallback(a)},{width:this.videoOptions.width,height:this.videoOptions.height,minWidth:this.videoOptions.minWidth,minHeight:this.videoOptions.minHeight},this.paramsConfig,this.backend,this.context.token),i=this.sessionOptions.captureScreen?new na({allowOnlyFirstMonitor:this.sessionOptions.allowOnlyFirstMonitor??!0,allowMultipleMonitors:this.sessionOptions.allowMultipleMonitors??!0,screenRecorderOptions:this.sessionOptions.screenRecorderOptions,onStopSharingScreenCallback:()=>this.onStopSharingScreenCallback(),onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:()=>this.onBufferSizeErrorCallback()}):void 0,n=new Ss({onFocusCallback:()=>this.onFocusCallback(),onLostFocusCallback:()=>this.onLostFocusCallback()},t),o=new ia(t,this.proctoringSession,this.paramsConfig,r,a=>this.onRealtimeAlertsCallback(a),this.backend,this.context.token),s=[r,i,n].filter(Boolean);return s.push(o),this.recorder=new ws(this.proctoringSession,s),{cameraRecorder:r,screenRecorder:i,alertRecorder:n,noiseRecorder:o}}async login(){if(!this.context.credentials?.cpf)throw Bm;this.context.token=await this.auth.login()}async start(t=et,r={}){try{if(this.context.token===void 0)throw Om;t.useChallenge&&(this.extensionEasycatcher=new bs),this.extension=new ys,this.extension.addEventListener();let i=this.backend.selectBaseUrl(this.context.type),n=await st();await this.repositoryDevices.save({...n,id:"devices"}),this.sessionOptions={...et,...t},this.videoOptions=ds(r),await this.initConfig(t.useGeolocation),await this.verifyBrowser(),this.sessionOptions.captureScreen&&await this.verifyMultipleMonitors(this.sessionOptions);try{t?.useSpyScan&&await this.spyCam.isAlive()}catch{throw Fm}if(this.state!="Stop")throw Rm;this.state="Starting",await this.repository.hasSessions()&&await this.repository.clear(),this.proctoringSession=new Er,this.allRecorders=this.createRecorders(this.sessionOptions),await this.recorder.startAll();let o=await this.backend.confirmStart({clientId:this.context.clientId,examId:this.context.examId,token:this.context.token},this.sessionOptions.proctoringType,this.geolocation?this.geolocation.coords.latitude:void 0,this.geolocation?this.geolocation.coords.longitude:void 0);this.proctoringId=o.id,D.registerDevicesChecked(this.proctoringId,!!this.deviceData,`Devices checked: ${JSON.stringify(this.deviceData)} | Devices List: ${n}`),this.allRecorders.cameraRecorder.setProctoringId(this.proctoringId),this.allRecorders.noiseRecorder.setProctoringId(this.proctoringId),this.proctoringSession.setProctoringId(this.proctoringId),t?.useSpyScan&&(this.spyCam.setProctoringId(this.proctoringId),this.spyCam.startCheckSpyCam(this.paramsConfig.spyScanInterval??5,{deviceType:3})),await this.repository.save(this.proctoringSession);let s={};for(let a in navigator)s[a]=navigator[a];return D.registerStart(this.proctoringId,!0,`Version: ${Dn()}
|
|
297
|
+
`,n=document.createElement("style");n.innerHTML=i,document.head.appendChild(n)}};var sa=class{constructor(t){this.context=t;this.deviceData=null;this.sessionStartTime=0;this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128,noiseLimit:40},imageBehaviourParameters:{frames:40,useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectFace:!1,detectPerson:!1,detectCellPhone:!1,detectNoise:!1,detectSpeech:!1}};this.proctoringId="";this.insights=void 0;this.state="Stop";this.serviceType="Upload";this.onStopSharingScreenCallback=()=>{};this.onLostFocusCallback=()=>{};this.onFocusCallback=()=>{};this.onChangeDevicesCallback=t=>{};this.onRealtimeAlertsCallback=t=>{};this.onBufferSizeErrorCallback=t=>{};this.backend=new Ct({type:t.type||"prod",token:t.token}),this.repository=new In("EasyProctorDb","exams2"),this.repositoryDevices=new In("EasyProctorDbDevices","devices"),this.context.credentials?.cpf&&(this.auth=new oa(this.context.credentials.cpf,this.backend))}setOnStopSharingScreenCallback(t){this.onStopSharingScreenCallback=async()=>{D.registerStopSharingScreen(this.proctoringId,"Stop sharing screen"),this.allRecorders?.alertRecorder?.addAlert({alert:34,type:3}),this.allRecorders?.screenRecorder?.stopRecording(),t()}}setOnLostFocusCallback(t){this.onLostFocusCallback=()=>t()}setOnFocusCallback(t){this.onFocusCallback=()=>t()}async onChangeDevices(t={}){new vs(this.repositoryDevices,this.proctoringId,this.sessionOptions,this.allRecorders).startRecording(t),this.onChangeDevicesCallback=i=>t.status&&t.status(i)}async onRealtimeAlerts(t={}){this.onRealtimeAlertsCallback=r=>t.data&&t.data(r)}setOnBufferSizeErrorCallback(t){this.onBufferSizeErrorCallback=r=>t(r)}setDeviceCheckData(t){this.deviceData=t}createRecorders(t=et){this.onChangeDevices();let r=new Vt({cameraId:this.sessionOptions.cameraId,microphoneId:this.sessionOptions.microphoneId,onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:a=>this.onBufferSizeErrorCallback(a),proctoringType:this.sessionOptions.proctoringType,onChangeDevicesCallback:a=>this.onChangeDevicesCallback(a),onRealtimeAlertsCallback:a=>this.onRealtimeAlertsCallback(a)},{width:this.videoOptions.width,height:this.videoOptions.height,minWidth:this.videoOptions.minWidth,minHeight:this.videoOptions.minHeight},this.paramsConfig,this.backend,this.context.token),i=this.sessionOptions.captureScreen?new na({allowOnlyFirstMonitor:this.sessionOptions.allowOnlyFirstMonitor??!0,allowMultipleMonitors:this.sessionOptions.allowMultipleMonitors??!0,screenRecorderOptions:this.sessionOptions.screenRecorderOptions,onStopSharingScreenCallback:()=>this.onStopSharingScreenCallback(),onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:()=>this.onBufferSizeErrorCallback()}):void 0,n=new Ss({onFocusCallback:()=>this.onFocusCallback(),onLostFocusCallback:()=>this.onLostFocusCallback()},t),o=new ia(t,this.proctoringSession,this.paramsConfig,r,a=>this.onRealtimeAlertsCallback(a),this.backend,this.context.token),s=[r,i,n].filter(Boolean);return s.push(o),this.recorder=new ws(this.proctoringSession,s),{cameraRecorder:r,screenRecorder:i,alertRecorder:n,noiseRecorder:o}}async login(){if(!this.context.credentials?.cpf)throw Bm;this.context.token=await this.auth.login()}async start(t=et,r={}){try{if(this.context.token===void 0)throw Om;t.useChallenge&&(this.extensionEasycatcher=new bs),this.extension=new ys,this.extension.addEventListener();let i=this.backend.selectBaseUrl(this.context.type),n=await st();await this.repositoryDevices.save({...n,id:"devices"}),this.sessionOptions={...et,...t},this.videoOptions=ds(r),await this.initConfig(t.useGeolocation),await this.verifyBrowser(),this.sessionOptions.captureScreen&&await this.verifyMultipleMonitors(this.sessionOptions);try{t?.useSpyScan&&await this.spyCam.isAlive()}catch{throw Fm}if(this.state!="Stop")throw Rm;this.state="Starting",await this.repository.hasSessions()&&await this.repository.clear(),this.proctoringSession=new Er,this.allRecorders=this.createRecorders(this.sessionOptions),await this.recorder.startAll();let o=await this.backend.confirmStart({clientId:this.context.clientId,examId:this.context.examId,token:this.context.token},this.sessionOptions.proctoringType,this.geolocation?this.geolocation.coords.latitude:void 0,this.geolocation?this.geolocation.coords.longitude:void 0);this.proctoringId=o.id,this.sessionStartTime=Date.now(),D.registerDevicesChecked(this.proctoringId,!!this.deviceData,`Devices checked: ${JSON.stringify(this.deviceData)} | Devices List: ${n}`),this.allRecorders.cameraRecorder.setProctoringId(this.proctoringId),this.allRecorders.noiseRecorder.setProctoringId(this.proctoringId),this.proctoringSession.setProctoringId(this.proctoringId),t?.useSpyScan&&(this.spyCam.setProctoringId(this.proctoringId),this.spyCam.startCheckSpyCam(this.paramsConfig.spyScanInterval??5,{deviceType:3})),await this.repository.save(this.proctoringSession);let s={};for(let a in navigator)s[a]=navigator[a];return D.registerStart(this.proctoringId,!0,`Version: ${Dn()}
|
|
298
298
|
Navigator: ${JSON.stringify(s)}`),o.cameraStream=this.allRecorders.cameraRecorder.cameraStream,this.allRecorders.screenRecorder&&(o.screenStream=this.allRecorders.screenRecorder.screenStream),this.state="Recording",o}catch(i){throw await this.cancel(),this.proctoringId&&D.registerStart(this.proctoringId,!1,`Token: ${this.context.token}
|
|
299
299
|
Version: ${Dn()}
|
|
300
300
|
Navigator: ${navigator}
|
|
@@ -307,4 +307,4 @@ Upload backup for Safe Browser`,this.serviceType)}))}),D.registerUpload(this.pro
|
|
|
307
307
|
|
|
308
308
|
Upload Services: ${i}`,this.serviceType)),this.proctoringSession.alerts.length>0&&await this.backend.saveAlerts(this.context,this.proctoringSession).catch(o=>{D.registerFinish(this.proctoringSession.id,!1,"save-screen error: "+o)}),await this.backend.finishAndSendUrls(this.context,this.sessionOptions).then(()=>{D.registerFinish(this.proctoringSession.id,!0,"")}).catch(o=>{D.registerFinish(this.proctoringSession.id,!1,"finish error: "+o)}),this.state="Stop"}catch(r){throw await this.cancel(),D.registerFinish(this.proctoringId,!1,`Token: ${this.context.token}
|
|
309
309
|
Error: `+r),this.state="Stop",r}}async verifyMultipleMonitors(t){if(!t.allowMultipleMonitors&&await Yn())throw D.registerError(this.proctoringId,"Multiplas telas detectadas!"),ps}async verifyBrowser(){let t=await Hg();if(t!=="chrome"&&t!=="firefox")throw D.registerBrowserNotSupported(this.proctoringId,`Browser n\xE3o suportado:
|
|
310
|
-
Tentativa utilizando o browser ${t}`),Dm}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 Wg().then(i=>i).catch(i=>{throw i.message})),xm(this.backend),this.sessionOptions?.useSpyScan&&(this.spyCam=new vi(this.context,{onRealtimeAlertsCallback:i=>this.onRealtimeAlertsCallback(i)}))}catch(r){throw this.proctoringId&&D.registerError(this.proctoringId,"Erro no initConfig!"),await this.cancel(),r}}async getServerDate(){let t=await this.backend.getServerHour(this.context.token).catch(i=>{D.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 D.registerError(this.proctoringId,"Proctoring n\xE3o iniciado!"),ms;await this.recorder.stopAll(),await this.recorder.saveAllOnSession(),await this.repository.save(this.proctoringSession),this.state="Paused"}async resume(){if(this.state!="Paused")throw ms;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}}async startChallenge(t){if(!this.sessionOptions.useChallenge)throw new Error("useChallenge is set as false on start method");await this.extensionEasycatcher.checkExtensionInstalled().catch(i=>{throw new Error("EasyCatcher Extension is not installed")}),this.extensionEasycatcher.start();let r=Date.now();await this.backend.startChallenge({proctoringId:this.proctoringId,templateId:t,start:r}).then(i=>{console.log(i),this.challengeId=i.id}).catch(i=>{throw D.registerError(this.proctoringId,"N\xE3o foi poss\xEDvel iniciar desafio!"),i}),this.isChallengeRunning=!0}async stopChallenge(){if(!this.isChallengeRunning)throw new Error("Challenge not started");try{let t=await this.extensionEasycatcher.getSessionData(),r=Date.now();await this.backend.stopChallenge(this.challengeId,{end:r,data:t}).catch(i=>{D.registerError(this.proctoringId,"N\xE3o foi poss\xEDvel finalizar o desafio no backend!")}),this.isChallengeRunning=!1}catch(t){D.registerError(this.proctoringId,"Erro ao recuperar dados da extens\xE3o: "+t.message)}}};var Bn=class{constructor(t){this.backend=new Ct({type:t?.type||"prod",token:t.token})}async signInTerms(){if(Bn.isModalOpen)return Promise.reject();Bn.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 i=document.createElement("div");i.setAttribute("id","signTermModal");let n={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(i,n);let o=document.createElement("div"),s={backgroundColor:"#fff",zIndex:"1001",width:"850px",maxHeight:"95%",borderRadius:"10px",display:"flex",flexDirection:"column",alignItems:"center"};this.applyStyles(o,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),o.appendChild(a);let l=document.createElement("iframe"),d="https://docs.google.com/document/u/3/d/e/2PACX-1vRMgrLhDLyDP8BHmotfPDpwAFaDHqK-mA4eBJ0Cy1mDdvHcWLsx47H4otII_4qi4rhtSf6B0OO97e9c/pub";this.backend.signTermUrl().then(pe=>{if(!pe)throw new Error("N\xE3o foi poss\xEDvel obter o termo de consentimento");l.setAttribute("src",pe)}).catch(()=>{l.setAttribute("src",d)});let u={width:"100%",height:"500px",border:"1px solid rgba(0, 0, 0, .1)",margin:"20px",borderRadius:"5px"};this.applyStyles(l,u),o.appendChild(l);let m=document.createElement("div"),y=document.createElement("input");y.setAttribute("type","checkbox"),y.setAttribute("id","termsCheckbox");let p=document.createElement("label");p.setAttribute("for","termsCheckbox"),p.innerText="Li e aceito os termos e condi\xE7\xF5es";let f={display:"flex",alignItems:"center",gap:"10px",margin:"20px",width:"100%",paddingLeft:"20px"};this.applyStyles(m,f),m.appendChild(y),m.appendChild(p),o.appendChild(m);let g=document.createElement("div"),b={width:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderTop:"2px solid rgba(0, 0, 0, .1)"};this.applyStyles(g,b);let k=document.createElement("button");k.innerText="Cancelar";let C={width:"100%",height:"70px",backgroundColor:"#FFF",border:"none",color:"rgba(0, 0, 0, .7)",fontWeight:"bold",borderRadius:"10px",paddingTop:"5px",paddingBottom:"5px"};this.applyStyles(k,C),k.addEventListener("click",()=>{this.closeModal(),t(!1)});let O=document.createElement("span"),F={width:"3px",height:"70px",margin:"0px 2px",background:"rgba(0, 0, 0, .1)"};this.applyStyles(O,F);let P=document.createElement("button");P.innerText="Continuar",P.setAttribute("id","confirmBtn");let _e={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(P,_e),P.disabled=!0,P.addEventListener("click",()=>{this.closeModal(),this.backend.signTerm().then(()=>{t(!0)})}),y.addEventListener("change",pe=>{P.disabled=!pe.target.checked,pe.target.checked?(P.style.color="#007bff",P.style.cursor="pointer"):(P.style.color="rgba(0, 0, 0, .7)",P.style.cursor="not-allowed")}),g.appendChild(k),g.appendChild(O),g.appendChild(P),o.appendChild(g),i.appendChild(o),document.body.appendChild(i)})}async closeModal(){Bn.isModalOpen=!1,document.querySelector("#signTermModal")?.remove()}applyStyles(t,r){for(let[i,n]of Object.entries(r))t.style[i]=n}},On=Bn;On.isModalOpen=!1;function Sd(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},i=new sa(r),n=new yn(r),o=new On(r),s=new wi,a=i.login.bind(i),c=i.start.bind(i),l=async Fn=>{let Ht=n.getDeviceCheckResult();return Ht&&i.setDeviceCheckData(Ht),c(Fn)},d=i.finish.bind(i),u=i.startChallenge.bind(i),m=i.stopChallenge.bind(i),y=i.pause.bind(i),p=i.resume.bind(i),f=i.setOnFocusCallback.bind(i),g=i.setOnLostFocusCallback.bind(i),b=i.onChangeDevices.bind(i),k=i.setOnBufferSizeErrorCallback.bind(i),C=i.setOnStopSharingScreenCallback.bind(i),O=i.onRealtimeAlerts.bind(i),F=o.signInTerms.bind(o),P=n.checkDevices.bind(n),_e=n.runCheckDevicesFlow.bind(n),pe=n.changeSelectedDevice.bind(n),mr=s.takePicture.bind(s);return{login:a,start:l,finish:d,startChallenge:u,stopChallenge:m,onFocus:f,onLostFocus:g,onChangeDevices:b,onBufferSizeError:k,onRealtimeAlerts:O,checkDevices:P,runCheckDevicesFlow:_e,changeSelectedDevice:pe,capturePhoto:mr,enumarateDevices:st,checkPermissions:Jn,checkIfhasMultipleMonitors:Yn,onStopSharingScreen:C,signInTerms:F}}typeof window<"u"&&(window.useProctoring=Sd);})();
|
|
310
|
+
Tentativa utilizando o browser ${t}`),Dm}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 Wg().then(i=>i).catch(i=>{throw i.message})),xm(this.backend),this.sessionOptions?.useSpyScan&&(this.spyCam=new vi(this.context,{onRealtimeAlertsCallback:i=>this.onRealtimeAlertsCallback(i)}))}catch(r){throw this.proctoringId&&D.registerError(this.proctoringId,"Erro no initConfig!"),await this.cancel(),r}}async getServerDate(){let t=await this.backend.getServerHour(this.context.token).catch(i=>{D.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 D.registerError(this.proctoringId,"Proctoring n\xE3o iniciado!"),ms;await this.recorder.stopAll(),await this.recorder.saveAllOnSession(),await this.repository.save(this.proctoringSession),this.state="Paused"}async resume(){if(this.state!="Paused")throw ms;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}}async startChallenge(t){if(!this.sessionOptions.useChallenge)throw new Error("useChallenge is set as false on start method");await this.extensionEasycatcher.checkExtensionInstalled().catch(i=>{throw new Error("EasyCatcher Extension is not installed")}),this.extensionEasycatcher.start();let r=Date.now()-this.sessionStartTime;await this.backend.startChallenge({proctoringId:this.proctoringId,templateId:t,start:r}).then(i=>{console.log(i),this.challengeId=i.id}).catch(i=>{throw D.registerError(this.proctoringId,"N\xE3o foi poss\xEDvel iniciar desafio!"),i}),this.isChallengeRunning=!0}async stopChallenge(){if(!this.isChallengeRunning)throw new Error("Challenge not started");try{let t=await this.extensionEasycatcher.getSessionData(),r=Date.now()-this.sessionStartTime;await this.backend.stopChallenge(this.challengeId,{end:r,data:t}).catch(i=>{D.registerError(this.proctoringId,"N\xE3o foi poss\xEDvel finalizar o desafio no backend!")}),this.isChallengeRunning=!1}catch(t){D.registerError(this.proctoringId,"Erro ao recuperar dados da extens\xE3o: "+t.message)}}};var Bn=class{constructor(t){this.backend=new Ct({type:t?.type||"prod",token:t.token})}async signInTerms(){if(Bn.isModalOpen)return Promise.reject();Bn.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 i=document.createElement("div");i.setAttribute("id","signTermModal");let n={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(i,n);let o=document.createElement("div"),s={backgroundColor:"#fff",zIndex:"1001",width:"850px",maxHeight:"95%",borderRadius:"10px",display:"flex",flexDirection:"column",alignItems:"center"};this.applyStyles(o,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),o.appendChild(a);let l=document.createElement("iframe"),d="https://docs.google.com/document/u/3/d/e/2PACX-1vRMgrLhDLyDP8BHmotfPDpwAFaDHqK-mA4eBJ0Cy1mDdvHcWLsx47H4otII_4qi4rhtSf6B0OO97e9c/pub";this.backend.signTermUrl().then(pe=>{if(!pe)throw new Error("N\xE3o foi poss\xEDvel obter o termo de consentimento");l.setAttribute("src",pe)}).catch(()=>{l.setAttribute("src",d)});let u={width:"100%",height:"500px",border:"1px solid rgba(0, 0, 0, .1)",margin:"20px",borderRadius:"5px"};this.applyStyles(l,u),o.appendChild(l);let m=document.createElement("div"),y=document.createElement("input");y.setAttribute("type","checkbox"),y.setAttribute("id","termsCheckbox");let p=document.createElement("label");p.setAttribute("for","termsCheckbox"),p.innerText="Li e aceito os termos e condi\xE7\xF5es";let f={display:"flex",alignItems:"center",gap:"10px",margin:"20px",width:"100%",paddingLeft:"20px"};this.applyStyles(m,f),m.appendChild(y),m.appendChild(p),o.appendChild(m);let g=document.createElement("div"),b={width:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderTop:"2px solid rgba(0, 0, 0, .1)"};this.applyStyles(g,b);let k=document.createElement("button");k.innerText="Cancelar";let C={width:"100%",height:"70px",backgroundColor:"#FFF",border:"none",color:"rgba(0, 0, 0, .7)",fontWeight:"bold",borderRadius:"10px",paddingTop:"5px",paddingBottom:"5px"};this.applyStyles(k,C),k.addEventListener("click",()=>{this.closeModal(),t(!1)});let O=document.createElement("span"),F={width:"3px",height:"70px",margin:"0px 2px",background:"rgba(0, 0, 0, .1)"};this.applyStyles(O,F);let P=document.createElement("button");P.innerText="Continuar",P.setAttribute("id","confirmBtn");let _e={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(P,_e),P.disabled=!0,P.addEventListener("click",()=>{this.closeModal(),this.backend.signTerm().then(()=>{t(!0)})}),y.addEventListener("change",pe=>{P.disabled=!pe.target.checked,pe.target.checked?(P.style.color="#007bff",P.style.cursor="pointer"):(P.style.color="rgba(0, 0, 0, .7)",P.style.cursor="not-allowed")}),g.appendChild(k),g.appendChild(O),g.appendChild(P),o.appendChild(g),i.appendChild(o),document.body.appendChild(i)})}async closeModal(){Bn.isModalOpen=!1,document.querySelector("#signTermModal")?.remove()}applyStyles(t,r){for(let[i,n]of Object.entries(r))t.style[i]=n}},On=Bn;On.isModalOpen=!1;function Sd(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},i=new sa(r),n=new yn(r),o=new On(r),s=new wi,a=i.login.bind(i),c=i.start.bind(i),l=async Fn=>{let Ht=n.getDeviceCheckResult();return Ht&&i.setDeviceCheckData(Ht),c(Fn)},d=i.finish.bind(i),u=i.startChallenge.bind(i),m=i.stopChallenge.bind(i),y=i.pause.bind(i),p=i.resume.bind(i),f=i.setOnFocusCallback.bind(i),g=i.setOnLostFocusCallback.bind(i),b=i.onChangeDevices.bind(i),k=i.setOnBufferSizeErrorCallback.bind(i),C=i.setOnStopSharingScreenCallback.bind(i),O=i.onRealtimeAlerts.bind(i),F=o.signInTerms.bind(o),P=n.checkDevices.bind(n),_e=n.runCheckDevicesFlow.bind(n),pe=n.changeSelectedDevice.bind(n),mr=s.takePicture.bind(s);return{login:a,start:l,finish:d,startChallenge:u,stopChallenge:m,onFocus:f,onLostFocus:g,onChangeDevices:b,onBufferSizeError:k,onRealtimeAlerts:O,checkDevices:P,runCheckDevicesFlow:_e,changeSelectedDevice:pe,capturePhoto:mr,enumarateDevices:st,checkPermissions:Jn,checkIfhasMultipleMonitors:Yn,onStopSharingScreen:C,signInTerms:F}}typeof window<"u"&&(window.useProctoring=Sd);})();
|