easyproctor-hml 0.0.52 → 0.0.54
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 +3 -3
- package/index.js +3 -3
- package/package.json +1 -1
- package/unpkg/easyproctor.min.js +2 -2
package/esm/index.js
CHANGED
|
@@ -17420,8 +17420,8 @@ var CameraRecorder = class {
|
|
|
17420
17420
|
this.video.srcObject = this.cameraStream;
|
|
17421
17421
|
this.video.play();
|
|
17422
17422
|
this.video.muted = true;
|
|
17423
|
-
this.canvas.width =
|
|
17424
|
-
this.canvas.height =
|
|
17423
|
+
this.canvas.width = 1280;
|
|
17424
|
+
this.canvas.height = 720;
|
|
17425
17425
|
}
|
|
17426
17426
|
async startRecording() {
|
|
17427
17427
|
const { cameraId, microphoneId, onBufferSizeErrorCallback } = this.options;
|
|
@@ -17470,7 +17470,7 @@ Setting: ${settings}`);
|
|
|
17470
17470
|
let imageFile;
|
|
17471
17471
|
this.configImageCapture();
|
|
17472
17472
|
this.imageInterval = setInterval(async () => {
|
|
17473
|
-
this.canvas.getContext("2d").drawImage(this.video, 0, 0,
|
|
17473
|
+
this.canvas.getContext("2d").drawImage(this.video, 0, 0, 1280, 720);
|
|
17474
17474
|
const image_data_url = this.canvas.toDataURL("image/jpeg");
|
|
17475
17475
|
imageFile = await this.getFile(image_data_url, `${this.proctoringId}_${this.imageCount + 1}.jpg`, "image/jpeg");
|
|
17476
17476
|
if (imageFile && this.upload && this.backendToken) {
|
package/index.js
CHANGED
|
@@ -28968,8 +28968,8 @@ var CameraRecorder = class {
|
|
|
28968
28968
|
this.video.srcObject = this.cameraStream;
|
|
28969
28969
|
this.video.play();
|
|
28970
28970
|
this.video.muted = true;
|
|
28971
|
-
this.canvas.width =
|
|
28972
|
-
this.canvas.height =
|
|
28971
|
+
this.canvas.width = 1280;
|
|
28972
|
+
this.canvas.height = 720;
|
|
28973
28973
|
}
|
|
28974
28974
|
async startRecording() {
|
|
28975
28975
|
const { cameraId, microphoneId, onBufferSizeErrorCallback } = this.options;
|
|
@@ -29018,7 +29018,7 @@ Setting: ${settings}`);
|
|
|
29018
29018
|
let imageFile;
|
|
29019
29019
|
this.configImageCapture();
|
|
29020
29020
|
this.imageInterval = setInterval(async () => {
|
|
29021
|
-
this.canvas.getContext("2d").drawImage(this.video, 0, 0,
|
|
29021
|
+
this.canvas.getContext("2d").drawImage(this.video, 0, 0, 1280, 720);
|
|
29022
29022
|
const image_data_url = this.canvas.toDataURL("image/jpeg");
|
|
29023
29023
|
imageFile = await this.getFile(image_data_url, `${this.proctoringId}_${this.imageCount + 1}.jpg`, "image/jpeg");
|
|
29024
29024
|
if (imageFile && this.upload && this.backendToken) {
|
package/package.json
CHANGED
package/unpkg/easyproctor.min.js
CHANGED
|
@@ -16,9 +16,9 @@ bitsperframe: %d
|
|
|
16
16
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){let h=new this(t);return n.forEach(x=>h.set(x)),h}static accessor(t){let h=(this[Ui]=this[Ui]={accessors:{}}).accessors,x=this.prototype;function C(O){let W=n0(O);h[W]||(ko(x,O),h[W]=!0)}return ie.isArray(t)?t.forEach(C):C(t),this}};Hr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ie.reduceDescriptors(Hr.prototype,({value:c},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>c,set(h){this[n]=h}}});ie.freezeMethods(Hr);var xt=Hr;function o0(c,t){let n=this||Fr,h=t||n,x=xt.from(h.headers),C=h.data;return ie.forEach(c,function(W){C=W.call(n,C,x.normalize(),t?t.status:void 0)}),x.normalize(),C}function l0(c){return!!(c&&c.__CANCEL__)}function qi(c,t,n){Ye.call(this,c??"canceled",Ye.ERR_CANCELED,t,n),this.name="CanceledError"}ie.inherits(qi,Ye,{__CANCEL__:!0});var hr=qi;function Oa(c,t,n){let h=n.config.validateStatus;!n.status||!h||h(n.status)?c(n):t(new Ye("Request failed with status code "+n.status,[Ye.ERR_BAD_REQUEST,Ye.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}var Xi=bt.isStandardBrowserEnv?function(){return{write:function(n,h,x,C,O,W){let be=[];be.push(n+"="+encodeURIComponent(h)),ie.isNumber(x)&&be.push("expires="+new Date(x).toGMTString()),ie.isString(C)&&be.push("path="+C),ie.isString(O)&&be.push("domain="+O),W===!0&&be.push("secure"),document.cookie=be.join("; ")},read:function(n){let h=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return h?decodeURIComponent(h[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function ka(c){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(c)}function ga(c,t){return t?c.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):c}function c0(c,t){return c&&!ka(t)?ga(c,t):t}var zi=bt.isStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a"),h;function x(C){let O=C;return t&&(n.setAttribute("href",O),O=n.href),n.setAttribute("href",O),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return h=x(window.location.href),function(O){let W=ie.isString(O)?x(O):O;return W.protocol===h.protocol&&W.host===h.host}}():function(){return function(){return!0}}();function Pa(c){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(c);return t&&t[1]||""}function go(c,t){c=c||10;let n=new Array(c),h=new Array(c),x=0,C=0,O;return t=t!==void 0?t:1e3,function(be){let le=Date.now(),ye=h[C];O||(O=le),n[x]=be,h[x]=le;let fe=C,Ne=0;for(;fe!==x;)Ne+=n[fe++],fe=fe%c;if(x=(x+1)%c,x===C&&(C=(C+1)%c),le-O<t)return;let Oe=ye&&le-ye;return Oe?Math.round(Ne*1e3/Oe):void 0}}var Yi=go;function Gi(c,t){let n=0,h=Yi(50,250);return x=>{let C=x.loaded,O=x.lengthComputable?x.total:void 0,W=C-n,be=h(W),le=C<=O;n=C;let ye={loaded:C,total:O,progress:O?C/O:void 0,bytes:W,rate:be||void 0,estimated:be&&O&&le?(O-C)/be:void 0,event:x};ye[t?"download":"upload"]=!0,c(ye)}}var Po=typeof XMLHttpRequest<"u",ji=Po&&function(c){return new Promise(function(n,h){let x=c.data,C=xt.from(c.headers).normalize(),O=c.responseType,W;function be(){c.cancelToken&&c.cancelToken.unsubscribe(W),c.signal&&c.signal.removeEventListener("abort",W)}ie.isFormData(x)&&(bt.isStandardBrowserEnv||bt.isStandardBrowserWebWorkerEnv?C.setContentType(!1):C.setContentType("multipart/form-data;",!1));let le=new XMLHttpRequest;if(c.auth){let Oe=c.auth.username||"",Se=c.auth.password?unescape(encodeURIComponent(c.auth.password)):"";C.set("Authorization","Basic "+btoa(Oe+":"+Se))}let ye=c0(c.baseURL,c.url);le.open(c.method.toUpperCase(),s0(ye,c.params,c.paramsSerializer),!0),le.timeout=c.timeout;function fe(){if(!le)return;let Oe=xt.from("getAllResponseHeaders"in le&&le.getAllResponseHeaders()),ge={data:!O||O==="text"||O==="json"?le.responseText:le.response,status:le.status,statusText:le.statusText,headers:Oe,config:c,request:le};Oa(function(je){n(je),be()},function(je){h(je),be()},ge),le=null}if("onloadend"in le?le.onloadend=fe:le.onreadystatechange=function(){!le||le.readyState!==4||le.status===0&&!(le.responseURL&&le.responseURL.indexOf("file:")===0)||setTimeout(fe)},le.onabort=function(){!le||(h(new Ye("Request aborted",Ye.ECONNABORTED,c,le)),le=null)},le.onerror=function(){h(new Ye("Network Error",Ye.ERR_NETWORK,c,le)),le=null},le.ontimeout=function(){let Se=c.timeout?"timeout of "+c.timeout+"ms exceeded":"timeout exceeded",ge=c.transitional||D0;c.timeoutErrorMessage&&(Se=c.timeoutErrorMessage),h(new Ye(Se,ge.clarifyTimeoutError?Ye.ETIMEDOUT:Ye.ECONNABORTED,c,le)),le=null},bt.isStandardBrowserEnv){let Oe=(c.withCredentials||zi(ye))&&c.xsrfCookieName&&Xi.read(c.xsrfCookieName);Oe&&C.set(c.xsrfHeaderName,Oe)}x===void 0&&C.setContentType(null),"setRequestHeader"in le&&ie.forEach(C.toJSON(),function(Se,ge){le.setRequestHeader(ge,Se)}),ie.isUndefined(c.withCredentials)||(le.withCredentials=!!c.withCredentials),O&&O!=="json"&&(le.responseType=c.responseType),typeof c.onDownloadProgress=="function"&&le.addEventListener("progress",Gi(c.onDownloadProgress,!0)),typeof c.onUploadProgress=="function"&&le.upload&&le.upload.addEventListener("progress",Gi(c.onUploadProgress)),(c.cancelToken||c.signal)&&(W=Oe=>{!le||(h(!Oe||Oe.type?new hr(null,c,le):Oe),le.abort(),le=null)},c.cancelToken&&c.cancelToken.subscribe(W),c.signal&&(c.signal.aborted?W():c.signal.addEventListener("abort",W)));let Ne=Pa(ye);if(Ne&&bt.protocols.indexOf(Ne)===-1){h(new Ye("Unsupported protocol "+Ne+":",Ye.ERR_BAD_REQUEST,c));return}le.send(x||null)})};var V0={http:N0,xhr:ji};ie.forEach(V0,(c,t)=>{if(c){try{Object.defineProperty(c,"name",{value:t})}catch{}Object.defineProperty(c,"adapterName",{value:t})}});var U0={getAdapter:c=>{c=ie.isArray(c)?c:[c];let{length:t}=c,n,h;for(let x=0;x<t&&(n=c[x],!(h=ie.isString(n)?V0[n.toLowerCase()]:n));x++);if(!h)throw h===!1?new Ye(`Adapter ${n} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(ie.hasOwnProp(V0,n)?`Adapter '${n}' is not available in the build`:`Unknown adapter '${n}'`);if(!ie.isFunction(h))throw new TypeError("adapter is not a function");return h},adapters:V0};function Na(c){if(c.cancelToken&&c.cancelToken.throwIfRequested(),c.signal&&c.signal.aborted)throw new hr(null,c)}function q0(c){return Na(c),c.headers=xt.from(c.headers),c.data=o0.call(c,c.transformRequest),["post","put","patch"].indexOf(c.method)!==-1&&c.headers.setContentType("application/x-www-form-urlencoded",!1),U0.getAdapter(c.adapter||Fr.adapter)(c).then(function(h){return Na(c),h.data=o0.call(c,c.transformResponse,h),h.headers=xt.from(h.headers),h},function(h){return l0(h)||(Na(c),h&&h.response&&(h.response.data=o0.call(c,c.transformResponse,h.response),h.response.headers=xt.from(h.response.headers))),Promise.reject(h)})}var $i=c=>c instanceof xt?c.toJSON():c;function sr(c,t){t=t||{};let n={};function h(le,ye,fe){return ie.isPlainObject(le)&&ie.isPlainObject(ye)?ie.merge.call({caseless:fe},le,ye):ie.isPlainObject(ye)?ie.merge({},ye):ie.isArray(ye)?ye.slice():ye}function x(le,ye,fe){if(ie.isUndefined(ye)){if(!ie.isUndefined(le))return h(void 0,le,fe)}else return h(le,ye,fe)}function C(le,ye){if(!ie.isUndefined(ye))return h(void 0,ye)}function O(le,ye){if(ie.isUndefined(ye)){if(!ie.isUndefined(le))return h(void 0,le)}else return h(void 0,ye)}function W(le,ye,fe){if(fe in t)return h(le,ye);if(fe in c)return h(void 0,le)}let be={url:C,method:C,data:C,baseURL:O,transformRequest:O,transformResponse:O,paramsSerializer:O,timeout:O,timeoutMessage:O,withCredentials:O,adapter:O,responseType:O,xsrfCookieName:O,xsrfHeaderName:O,onUploadProgress:O,onDownloadProgress:O,decompress:O,maxContentLength:O,maxBodyLength:O,beforeRedirect:O,transport:O,httpAgent:O,httpsAgent:O,cancelToken:O,socketPath:O,responseEncoding:O,validateStatus:W,headers:(le,ye)=>x($i(le),$i(ye),!0)};return ie.forEach(Object.keys(Object.assign({},c,t)),function(ye){let fe=be[ye]||x,Ne=fe(c[ye],t[ye],ye);ie.isUndefined(Ne)&&fe!==W||(n[ye]=Ne)}),n}var X0="1.5.0";var La={};["object","boolean","number","function","string","symbol"].forEach((c,t)=>{La[c]=function(h){return typeof h===c||"a"+(t<1?"n ":" ")+c}});var Ki={};La.transitional=function(t,n,h){function x(C,O){return"[Axios v"+X0+"] Transitional option '"+C+"'"+O+(h?". "+h:"")}return(C,O,W)=>{if(t===!1)throw new Ye(x(O," has been removed"+(n?" in "+n:"")),Ye.ERR_DEPRECATED);return n&&!Ki[O]&&(Ki[O]=!0,console.warn(x(O," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(C,O,W):!0}};function No(c,t,n){if(typeof c!="object")throw new Ye("options must be an object",Ye.ERR_BAD_OPTION_VALUE);let h=Object.keys(c),x=h.length;for(;x-- >0;){let C=h[x],O=t[C];if(O){let W=c[C],be=W===void 0||O(W,C,c);if(be!==!0)throw new Ye("option "+C+" must be "+be,Ye.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ye("Unknown option "+C,Ye.ERR_BAD_OPTION)}}var z0={assertOptions:No,validators:La};var mr=z0.validators,Vr=class{constructor(t){this.defaults=t,this.interceptors={request:new Ta,response:new Ta}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=sr(this.defaults,n);let{transitional:h,paramsSerializer:x,headers:C}=n;h!==void 0&&z0.assertOptions(h,{silentJSONParsing:mr.transitional(mr.boolean),forcedJSONParsing:mr.transitional(mr.boolean),clarifyTimeoutError:mr.transitional(mr.boolean)},!1),x!=null&&(ie.isFunction(x)?n.paramsSerializer={serialize:x}:z0.assertOptions(x,{encode:mr.function,serialize:mr.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let O=C&&ie.merge(C.common,C[n.method]);C&&ie.forEach(["delete","get","head","post","put","patch","common"],Se=>{delete C[Se]}),n.headers=xt.concat(O,C);let W=[],be=!0;this.interceptors.request.forEach(function(ge){typeof ge.runWhen=="function"&&ge.runWhen(n)===!1||(be=be&&ge.synchronous,W.unshift(ge.fulfilled,ge.rejected))});let le=[];this.interceptors.response.forEach(function(ge){le.push(ge.fulfilled,ge.rejected)});let ye,fe=0,Ne;if(!be){let Se=[q0.bind(this),void 0];for(Se.unshift.apply(Se,W),Se.push.apply(Se,le),Ne=Se.length,ye=Promise.resolve(n);fe<Ne;)ye=ye.then(Se[fe++],Se[fe++]);return ye}Ne=W.length;let Oe=n;for(fe=0;fe<Ne;){let Se=W[fe++],ge=W[fe++];try{Oe=Se(Oe)}catch(ne){ge.call(this,ne);break}}try{ye=q0.call(this,Oe)}catch(Se){return Promise.reject(Se)}for(fe=0,Ne=le.length;fe<Ne;)ye=ye.then(le[fe++],le[fe++]);return ye}getUri(t){t=sr(this.defaults,t);let n=c0(t.baseURL,t.url);return s0(n,t.params,t.paramsSerializer)}};ie.forEach(["delete","get","head","options"],function(t){Vr.prototype[t]=function(n,h){return this.request(sr(h||{},{method:t,url:n,data:(h||{}).data}))}});ie.forEach(["post","put","patch"],function(t){function n(h){return function(C,O,W){return this.request(sr(W||{},{method:t,headers:h?{"Content-Type":"multipart/form-data"}:{},url:C,data:O}))}}Vr.prototype[t]=n(),Vr.prototype[t+"Form"]=n(!0)});var _0=Vr;var u0=class{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(C){n=C});let h=this;this.promise.then(x=>{if(!h._listeners)return;let C=h._listeners.length;for(;C-- >0;)h._listeners[C](x);h._listeners=null}),this.promise.then=x=>{let C,O=new Promise(W=>{h.subscribe(W),C=W}).then(x);return O.cancel=function(){h.unsubscribe(C)},O},t(function(C,O,W){h.reason||(h.reason=new hr(C,O,W),n(h.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new u0(function(x){t=x}),cancel:t}}},Wi=u0;function Da(c){return function(n){return c.apply(null,n)}}function Fa(c){return ie.isObject(c)&&c.isAxiosError===!0}var Ha={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ha).forEach(([c,t])=>{Ha[t]=c});var Zi=Ha;function Qi(c){let t=new _0(c),n=r0(_0.prototype.request,t);return ie.extend(n,_0.prototype,t,{allOwnKeys:!0}),ie.extend(n,t,null,{allOwnKeys:!0}),n.create=function(x){return Qi(sr(c,x))},n}var ft=Qi(Fr);ft.Axios=_0;ft.CanceledError=hr;ft.CancelToken=Wi;ft.isCancel=l0;ft.VERSION=X0;ft.toFormData=dr;ft.AxiosError=Ye;ft.Cancel=ft.CanceledError;ft.all=function(t){return Promise.all(t)};ft.spread=Da;ft.isAxiosError=Fa;ft.mergeConfig=sr;ft.AxiosHeaders=xt;ft.formToJSON=c=>F0(ie.isHTMLForm(c)?new FormData(c):c);ft.getAdapter=U0.getAdapter;ft.HttpStatusCode=Zi;ft.default=ft;var Br=ft;var{Axios:x2,AxiosError:E2,CanceledError:w2,isCancel:A2,CancelToken:M2,VERSION:T2,all:B2,Cancel:I2,isAxiosError:C2,spread:O2,toFormData:k2,AxiosHeaders:g2,HttpStatusCode:P2,formToJSON:N2,getAdapter:L2,mergeConfig:D2}=Br;var Ir=class{constructor(t,n){this.backend=n;this.imageUrlPackage=[];this.imageBatchNum=0;this.contImages=0;this.proctoringId=t}async upload(t,n,h){let{file:x,onProgress:C}=t;try{let O=le=>{let ye=le.loadedBytes/x.size*100;C&&C(Math.round(ye))},W;if(h){if(this.imageBatchNum===this.contImages){let le=[];for(let fe=this.imageBatchNum;fe<this.imageBatchNum+20;fe++)le.push({objectName:`${this.proctoringId}/${this.proctoringId}_${fe+1}.jpg`,contentType:"image/jpeg"});(await this.backend.getSignedUrlImage(n,le)).map(fe=>{this.imageUrlPackage.push(fe)}),this.imageBatchNum+=20}}else W=await this.backend.getSignedUrl(n,x,this.proctoringId);let be=!1;return h?be=await Br.request({url:this.imageUrlPackage[this.contImages],method:"PUT",headers:{"Content-Type":x.type,"x-ms-blob-type":"BlockBlob"},data:x,onUploadProgress:le=>{O({loadedBytes:le.loaded})}}).then(()=>!0).catch(()=>!1).finally(()=>{this.contImages++}):be=await Br.request({url:W,method:"PUT",headers:{"Content-Type":x.type,"x-ms-blob-type":"BlockBlob"},data:x,onUploadProgress:le=>{O({loadedBytes:le.loaded})}}).then(()=>!0).catch(()=>!1),{storage:"upload",url:W,uploaded:be}}catch{throw et.registerError(this.proctoringId,`Failed to upload to AWS
|
|
17
17
|
File name: ${x.name}
|
|
18
18
|
File type: ${x.type}
|
|
19
|
-
File size: ${x.size}`),new Error("Failed to upload to AWS")}}};var Ji="not_shared_first_screen",es="not_shared_screen",Y0="multiple_monitors_detected",ts="proctoring_already_started",G0="proctoring_not_started";var rs="another_stream_active",as="browser_not_supported",is="token_missing",ss="credentials_missing";var tr=class{constructor(t,n,h,x,C){this.blobs=[];this.imageParams={frames:40,useUploadImage:!0,uploadInterval:20,saveVideo:!0};this.options={cameraId:void 0,microphoneId:void 0,onBufferSizeError:!1,onBufferSizeErrorCallback:()=>{},proctoringType:"IMAGE"};this.videoOptions={width:640,height:480};this.blobsRTC=[];this.imageCount=0;this.options=t,this.videoOptions=n,this.backend=x,this.backendToken=C,h&&(this.imageParams=h)}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new Ir(this.proctoringId,this.backend))}configImageCapture(){this.video=document.createElement("video"),this.canvas=document.createElement("canvas"),this.video.srcObject=this.cameraStream,this.video.play(),this.video.muted=!0,this.canvas.width=
|
|
19
|
+
File size: ${x.size}`),new Error("Failed to upload to AWS")}}};var Ji="not_shared_first_screen",es="not_shared_screen",Y0="multiple_monitors_detected",ts="proctoring_already_started",G0="proctoring_not_started";var rs="another_stream_active",as="browser_not_supported",is="token_missing",ss="credentials_missing";var tr=class{constructor(t,n,h,x,C){this.blobs=[];this.imageParams={frames:40,useUploadImage:!0,uploadInterval:20,saveVideo:!0};this.options={cameraId:void 0,microphoneId:void 0,onBufferSizeError:!1,onBufferSizeErrorCallback:()=>{},proctoringType:"IMAGE"};this.videoOptions={width:640,height:480};this.blobsRTC=[];this.imageCount=0;this.options=t,this.videoOptions=n,this.backend=x,this.backendToken=C,h&&(this.imageParams=h)}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new Ir(this.proctoringId,this.backend))}configImageCapture(){this.video=document.createElement("video"),this.canvas=document.createElement("canvas"),this.video.srcObject=this.cameraStream,this.video.play(),this.video.muted=!0,this.canvas.width=1280,this.canvas.height=720}async startRecording(){let{cameraId:t,microphoneId:n,onBufferSizeErrorCallback:h}=this.options,x={audio:{deviceId:n},video:{deviceId:t,width:this.videoOptions.width,height:this.videoOptions.height,frameRate:15}};try{this.cameraStream=await navigator.mediaDevices.getUserMedia(x)}catch(ye){throw ye.toString()=="NotReadableError: Could not start video source"?"N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa":ye}let{startRecording:C,stopRecording:O,pauseRecording:W,resumeRecording:be}=t0(this.cameraStream,this.blobs,this.proctoringId,this.options.onBufferSizeError,h);this.recordingStart=C,this.recordingStop=O,this.recordingPause=W,this.recordingResume=be,this.recordingStart();let le=this.cameraStream.getVideoTracks()[0].getSettings();if(this.videoOptions.width!==le.width||this.videoOptions.height!==le.height)throw et.registerAnotherStream(this.proctoringId,`Maybe have another stream active
|
|
20
20
|
Video Options: ${this.videoOptions}
|
|
21
|
-
Setting: ${le}`),rs;this.imageParams.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle()}async stopRecording(){this.recordingStop&&await this.recordingStop(),clearInterval(this.imageInterval)}async pauseRecording(){await this.recordingPause()}async resumeRecording(){await this.recordingResume()}photoShotsCycle(){let t;this.configImageCapture(),this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,
|
|
21
|
+
Setting: ${le}`),rs;this.imageParams.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle()}async stopRecording(){this.recordingStop&&await this.recordingStop(),clearInterval(this.imageInterval)}async pauseRecording(){await this.recordingPause()}async resumeRecording(){await this.recordingResume()}photoShotsCycle(){let t;this.configImageCapture(),this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,1280,720);let n=this.canvas.toDataURL("image/jpeg");t=await this.getFile(n,`${this.proctoringId}_${this.imageCount+1}.jpg`,"image/jpeg"),t&&this.upload&&this.backendToken&&(this.upload.upload({file:t},this.backendToken,!0),this.imageCount++)},this.imageParams.uploadInterval*1e3)}async saveOnSession(t){let n=this.cameraStream.getVideoTracks()[0].getSettings(),h=this.cameraStream.getAudioTracks()[0].getSettings();this.imageParams.saveVideo&&t.addRecording({device:`Audio
|
|
22
22
|
Sample Rate: ${h.sampleRate}
|
|
23
23
|
Sample Size: ${h.sampleSize}`,file:new File(this.blobs,`EP_${t.id}_camera_0.webm`,{type:"video/webm"}),origin:"Camera"})}async getFile(t,n,h){return new Promise((x,C)=>{t.length>5&&fetch(t).then(O=>O.blob()).then(O=>{let W=new File([O],n,{type:h});x(W)}).catch(O=>{C(O)})})}};var Ur=class{constructor(){}async takePicture(t,n,h={width:1080,height:720}){return this.resolution=h,await this.takePictureInterface(t,n)}async startCapture(t="default"){let n=document.querySelector("#cameraStream"),h={audio:!1,video:{facingMode:"user",aspectRatio:1.777777778,width:{min:640,ideal:640,max:1920},height:{min:400,ideal:480},deviceId:t}};this.cameraRecorder=new tr({cameraId:t,onBufferSizeErrorCallback:()=>{}},{...this.resolution}),await this.cameraRecorder.startRecording(),n.srcObject=this.cameraRecorder.cameraStream,n.play()}shot(){let t=document.querySelector("#cameraStream"),n=document.querySelector("#canvas"),h=document.querySelector("#image");n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d").drawImage(t,0,0,t.videoWidth,t.videoHeight),h.src=n.toDataURL("image/jpg"),this.base64=n.toDataURL("image/jpg")}takePictureInterface(t,n){return new Promise(h=>{let x=document.createElement("div");x.setAttribute("id","authPhoto"),x.style.backgroundColor="rgba(0,0,0,0.4)",x.style.zIndex="1000",x.style.position="fixed",x.style.top="0",x.style.left="0",x.style.height="100vh",x.style.width="100%",x.style.display="flex",x.style.alignItems="center",x.style.justifyContent="center";let C=document.createElement("div");C.style.backgroundColor="#fff",C.style.zIndex="1001",C.style.position="fixed",C.style.top="0",C.style.left="0",C.style.height="100vh",C.style.width="100%",C.style.borderRadius="10px",C.style.display="flex",C.style.flexDirection="column",C.style.alignItems="center",C.style.boxSizing="border-box";let O=document.createElement("h3");O.innerText=t||"Biometria Facial",O.style.color="rgba(0, 0, 0, .7)",O.style.fontWeight="bold",O.style.fontSize="20px",O.style.marginTop="0px",O.style.marginBottom="15px",O.style.padding="20px 0px 0px",O.style.width="100%",O.style.textAlign="center",O.style.position="fixed",O.style.top="0",O.style.left="0",O.style.zIndex="1010",C.appendChild(O);let W=document.createElement("p");W.innerText=n||"Encaixe seu rosto no formato e clique no bot\xE3o abaixo",W.style.color="rgba(0, 0, 0, .7)",W.style.fontWeight="normal",W.style.fontSize="16px",W.style.marginBottom="15px",W.style.padding="0px 0px 20px",W.style.width="100%",W.style.textAlign="center",W.style.position="fixed",W.style.top="55px",W.style.left="0",W.style.zIndex="1011",C.appendChild(W);let be=document.createElement("div"),le=document.createElement("h3"),ye=document.createElement("select");ye.setAttribute("id","cameraSelect"),be.style.padding="0 20px",be.style.width="100%",be.style.display="flex",be.style.justifyContent="space-between",be.style.marginBottom="15px",le.innerText="C\xE2mera",le.style.color="rgba(0, 0, 0, .75)",le.style.fontWeight="bold",le.style.fontSize="16px",be.appendChild(le),be.appendChild(ye);let fe=document.createElement("div"),Ne=document.createElement("video");Ne.setAttribute("id","cameraStream"),Ne.muted=!0,fe.style.position="fixed",fe.style.top="0",fe.style.left="0",fe.style.height="100vh",fe.style.width="100%",fe.style.display="flex",fe.style.justifyContent="center",Ne.style.backgroundColor="#000",Ne.style.borderRadius="10px",Ne.style.width="auto",Ne.style.height="auto",Ne.style.minHeight="100%",fe.appendChild(Ne);let Oe=document.createElement("canvas");Oe.setAttribute("id","canvas"),Oe.style.display="none",Oe.style.width="100%",Oe.style.height="100%";let Se=document.createElement("img");Se.setAttribute("id","image"),Se.style.objectFit="contain",Se.style.display="none",Se.style.borderRadius="8px",fe.appendChild(Oe),fe.appendChild(Se);let ge=document.createElement("div");ge.setAttribute("class","facial-biometry__mask"),ge.style.width="100%",ge.style.height="100%",ge.style.position="absolute",ge.style.top="0px",ge.style.left="0px",ge.style.backgroundColor="#fff",ge.style.opacity="0.8";let ne=document.createElement("div");ne.setAttribute("class","biometry__frame"),ne.style.width="100%",ne.style.height="100%",ne.style.position="absolute",ne.style.top="0px",ne.style.left="0px",ne.style.zIndex="10",fe.appendChild(ge),fe.appendChild(ne),C.appendChild(fe),this.addStyleMask();let je=document.createElement("button"),Fe=document.createElement("div");je.setAttribute("id","confirmBtn"),Fe.style.position="fixed",Fe.style.bottom="0",Fe.style.left="0",Fe.style.width="100%",Fe.style.display="flex",Fe.style.alignItems="center",Fe.style.justifyContent="center",je.style.background="url('https://iarisprod.blob.core.windows.net/imagens/camera.svg') no-repeat center",je.style.width="70px",je.style.height="70px",je.style.borderRadius="70px",je.style.border="none",je.style.backgroundColor="#16a34a",je.style.margin="20px 0",Fe.appendChild(je),C.appendChild(Fe);let Ke=document.createElement("button");Ke.style.background="url('https://iarisprod.blob.core.windows.net/imagens/close.svg') no-repeat center",Ke.style.width="70px",Ke.style.height="70px",Ke.style.borderRadius="70px",Ke.style.border="none",Ke.style.backgroundColor="#e74141",Ke.style.margin="20px 20px";let ct=document.createElement("button");ct.style.background="url('https://iarisprod.blob.core.windows.net/imagens/check.svg') no-repeat center",ct.style.width="70px",ct.style.height="70px",ct.style.borderRadius="70px",ct.style.border="none",ct.style.backgroundColor="#16a34a",ct.style.margin="20px 20px",x.appendChild(C),document.body.appendChild(x),this.setSelectOption(),this.startCapture(),je.addEventListener("click",()=>{Fe.removeChild(je),Fe.appendChild(Ke),Fe.appendChild(ct),this.shot(),Ne.style.display="none",Se.style.display="block"}),Ke.addEventListener("click",()=>{Fe.appendChild(je),Fe.removeChild(Ke),Fe.removeChild(ct),Ne.style.display="block",Se.style.display="none"}),ct.addEventListener("click",()=>{this.closeInterface(),h({base64:this.base64})})})}async setSelectOption(){let t=document.querySelector("#cameraSelect"),n=await Yt();t&&(t.value="default");let h=(x,C)=>{let O=document.createElement("option");return O.setAttribute("value",C),O.innerHTML=x,O};n.cameras.forEach(x=>{let C=h(x.label,x.id);t?.appendChild(C)}),this.onSelectOptionChange()}async onSelectOptionChange(){let t=document.querySelector("#cameraSelect");t?.addEventListener("change",async()=>{this.startCapture(t?.value)})}async closeInterface(){await this.cameraRecorder.stopRecording(),document.querySelector("#authPhoto")?.remove()}async addStyleMask(){let t=`
|
|
24
24
|
.facial-biometry__mask {
|