exam-guard
Version:
AI proctoring tool
1 lines • 2.67 kB
JavaScript
(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach((function(t){r(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function r(e,t,n){return(t=i(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}function i(t){var n=function(t){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,"string");if("object"!=e(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(n)?n:n+""}var c=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=null},t=[{key:"init",value:function(e){this.config=e}},{key:"sendCompatibilityEvents",value:function(e,t,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};console.log("sendCompatibilityEvents",e,t,r,o);var i=Object.keys(e).map((function(t){return{type:"desktop_client",name:t,data:{value:e[t]}}})),c=n(n({},o),{},{events:i}),a=new URL(r||"api/v1/proctoring/events",t);fetch(a.toString(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}).then((function(e){if(!e.ok)throw new Error("Failed to send compatibility events to ".concat(a));return e.json()})).then((function(e){console.log("Compatibility events sent successfully:",e)})).catch((function(e){console.error("Error sending compatibility events:",e)}))}},{key:"handleMessage",value:function(e){var t=e.data,n=t.type,r=t.data;switch(n){case"INIT":this.init(r);break;case"SEND_COMPATIBILITY_EVENT":this.sendCompatibilityEvents(r.checks,r.baseUrl,r.endpoint,r.payload)}}}],t&&o(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());self.addEventListener("message",(function(e){return c.handleMessage(e)}))})();