territorium-proctoring
Version:
Componente de prueba
1,470 lines • 53 kB
JavaScript
'use strict';var vue=require('vue');function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _iterableToArrayLimit(arr, i) {
var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
if (_i == null) return;
var _arr = [];
var _n = true;
var _d = false;
var _s, _e;
try {
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}// import '@tensorflow/tfjs-backend-webgl';
// import * as cocoSsd from '@tensorflow-models/coco-ssd';
// import * as faceapi from '@vladmandic/face-api';
// import axios from "axios";
// import TerritoriumDeviceManager from 'territorium-device-manager';
// import * as azblob from "./azure-storage-blob.min";
// import { v4 as uuidv4 } from 'uuid';
// import { setIntervalAsync } from 'set-interval-async/dynamic';
// import { clearIntervalAsync } from 'set-interval-async';
// window.navigator.onLine
var script = /*#__PURE__*/vue.defineComponent({
name: 'TerritoriumProctoring',
// vue component name
components: {
TerritoriumDeviceManager: TerritoriumDeviceManager
},
props: {
idUniversidad: {
type: [Number, String],
default: "1483"
},
idExamen: {
type: [Number, String],
default: '6078814'
},
idEstudiante: {
type: [Number, String],
default: '1414446'
},
urlConfig: {
type: [Number, String],
default: "http://localhost:8081/getconfig"
},
authorization: {
type: [String],
default: "62b3500e1fed8933d18a154bc0df26584fc744fb3e71e32fed52b208aa07dfd6c3158990624de11faa4be9a7d6e35c730f39de2074891a98cd60ad97e70926f8"
},
urlPerfil: {
type: [Number, String],
default: "https://proctoring-files.azureedge.net/files/proctoringFiles/1483/2021-03-30/FaceId/1050159/6tLwXWjEFpY51617121804TuoL21228600.jpg"
}
},
data: function data() {
return {
modelPromise: null,
allowsLocalSupervision: false,
uriPerfil: null,
uriCaptura: null,
feedback: "",
diagnosticos: [],
capturas: [],
objetosSospechoso: ['backpack', 'handbag', 'tv', 'laptop', 'cell phone', 'book'],
analisysType: ["objetos", "reconocido", "acompanado", "detectado"],
maxDescriptorDistance: 0.6,
faceMatcher: null,
blobServiceClient: null,
containerClient: null,
containerName: "container-proctoring-test",
// blobSasUrl: "https://proctoringfiles-microsoftrouting.blob.core.windows.net/?sv=2020-02-10&ss=bfqt&srt=sco&sp=rwdlacupx&se=2025-12-31T12:45:48Z&st=2021-05-13T03:45:48Z&spr=https,http&sig=lFCX5yJiGfrkhk2BbqEUJTvJkE3dUQefRERzjh8zgcg%3D",
// urlApi: "http://localhost:8081",
urlToken: "http://localhost:8081/gentoken",
urlProcessDiagnosticos: "http://localhost:8081/territoriumService",
urlSaveDiagnosticos: "http://localhost:8081/storeevidences",
urlSaveAudio: "http://localhost:8081/storeaudio",
urlSaveVideo: "http://localhost:8081/storevideo",
sasString: "se=2025-12-31&sp=rwdlac&sv=2018-03-28&ss=b&srt=sco&sig=yygWiToa3acI3mRmryM6t1wi%2Bgh1%2B7c4mme/Z8UOEik%3D",
containerURL: null,
accountName: "proctoringfiles",
// limitSendDiagnostic: 3,
token: "",
config: {},
idCoreProctoring: null,
timeInterval: 1000,
timeElapsed: 0,
capturarFoto: 0,
capturarVideo: 0,
capturarAudio: 0,
uriAudio: null,
uriVideo: null,
blobVideo: null
};
},
watch: {
allowsLocalSupervision: 'configProctoring',
diagnosticos: 'processDiagnosticos',
capturas: 'processCapturas',
uriAudio: 'processBlobAudio',
// uriVideo: 'processVideo',
blobVideo: 'processBlobVideo'
},
methods: {
processAudio: function processAudio() {
if (this.allowsLocalSupervision) ; else {
alert("No se permite supervision local");
}
},
processVideo: function processVideo() {
var _this = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!_this.allowsLocalSupervision) {
_context.next = 7;
break;
}
// console.log("uriVideo", this.uriVideo);
_this.$refs.video.src = _this.uriVideo;
_context.next = 4;
return _this.uploadFiles(_this.uriVideo);
case 4:
_context.sent;
_context.next = 8;
break;
case 7:
alert("No se permite supervision local");
case 8:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
},
processBlobVideo: function processBlobVideo() {
var _this2 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var url;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
url = ""; // console.log("processBlob()");
// if (this.allowsLocalSupervision) {
// console.log("blobVideo", this.blobVideo);
if (_this2.blobVideo === undefined || _this2.blobVideo == null || _this2.blobVideo.size <= 0) {
_context2.next = 7;
break;
}
_context2.next = 4;
return _this2.uploadBlobVideo(_this2.blobVideo);
case 4:
url = _context2.sent;
_context2.next = 7;
return _this2.saveVideo(url);
case 7:
case "end":
return _context2.stop();
}
}
}, _callee2);
}))();
},
uploadBlobAudio: function uploadBlobAudio(dataBlob) {
var _arguments = arguments,
_this3 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
var name, url, blockBlobURL;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
name = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : "";
url = "";
_context3.prev = 2;
if (name == "") {
name = uuidv4();
name = "".concat(name, ".webm");
}
_this3.reportStatus("Uploading files..."); // const blockBlobClient = this.containerClient.getBlockBlobClient(name);
// let data = await blockBlobClient.uploadBrowserData(dataBlob);
// let url = data._response.request.url;
blockBlobURL = azblob.BlockBlobURL.fromContainerURL(_this3.containerURL, name);
_context3.next = 8;
return azblob.uploadBrowserDataToBlockBlob(azblob.Aborter.none, dataBlob, blockBlobURL);
case 8:
url = _context3.sent;
return _context3.abrupt("return", url._response.request.url);
case 12:
_context3.prev = 12;
_context3.t0 = _context3["catch"](2);
_this3.reportStatus(_context3.t0.message);
return _context3.abrupt("return", null);
case 16:
case "end":
return _context3.stop();
}
}
}, _callee3, null, [[2, 12]]);
}))();
},
processBlobAudio: function processBlobAudio() {
var _this4 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
var url;
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
// console.log("processBlobAudio()");
url = ""; // if (this.allowsLocalSupervision) {
// console.log("blobAudio", this.uriAudio);
if (_this4.uriAudio === undefined || _this4.uriAudio == null || _this4.uriAudio.size <= 0) {
_context4.next = 7;
break;
}
_context4.next = 4;
return _this4.uploadBlobAudio(_this4.uriAudio);
case 4:
url = _context4.sent;
_context4.next = 7;
return _this4.saveAudio(url);
case 7:
case "end":
return _context4.stop();
}
}
}, _callee4);
}))();
},
configProctoring: function configProctoring() {
if (this.allowsLocalSupervision) ;
},
verifyLocalAnalysis: function verifyLocalAnalysis() {
var _this5 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
var modeloCoco, urlsPhotosToVerify, urlReferencePhoto, defaultFaceMatcher, defaultObjects, resultsFaceMatcher, resultsObjects, testCorrect, referencePhoto, referenceFaceAnalysis, referenceFaceDescriptor, referenceFacialFeatures, maxDescriptorDistance, faceMatcher, index, urlPhotosToVerify, photosToVerify, photosToVerifyAnalysis, photosToVerifyDescriptor, resultFaceMatcher, predictions;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return _this5.modelPromise;
case 2:
modeloCoco = _context5.sent;
urlsPhotosToVerify = ["https://i.ibb.co/3N0ZRH1/CA1.jpg", "https://i.ibb.co/C7hXLHt/CA2.jpg", "https://i.ibb.co/tX5kjpL/CA3.jpg", "https://i.ibb.co/yW2r9D4/CA4.jpg", "https://i.ibb.co/VB67VPX/CA5.jpg", "https://i.ibb.co/dLzKt0N/CA6.jpg", "https://i.ibb.co/p0LwmBT/CA7.jpg", "https://i.ibb.co/FwSscRy/CA8.jpg", "https://i.ibb.co/wWyMj2n/CA9.jpg", "https://i.ibb.co/fSjNfwT/CA11.jpg", "https://i.ibb.co/QmWb2gC/CA10.jpg"], urlReferencePhoto = "https://i.ibb.co/fv2Nkyx/chris-Evans-Profile.jpg", defaultFaceMatcher = ["true", "false", "true", "true", "true", "true", "true", "true", "true", "true", "true"], defaultObjects = ["person", "person", "person", "person", "person", "person", "person", "person", "person", "person", "person"], resultsFaceMatcher = [], resultsObjects = [], testCorrect = 0; // image to compare
_context5.next = 6;
return faceapi.fetchImage(urlReferencePhoto);
case 6:
referencePhoto = _context5.sent;
_context5.next = 9;
return faceapi.detectSingleFace(referencePhoto).withFaceLandmarks().withFaceDescriptor();
case 9:
referenceFaceAnalysis = _context5.sent;
referenceFaceDescriptor = [referenceFaceAnalysis.descriptor];
referenceFacialFeatures = new faceapi.LabeledFaceDescriptors("true", referenceFaceDescriptor);
maxDescriptorDistance = 0.6;
faceMatcher = new faceapi.FaceMatcher(referenceFacialFeatures, maxDescriptorDistance);
index = 0;
case 15:
if (!(index < urlsPhotosToVerify.length)) {
_context5.next = 35;
break;
}
urlPhotosToVerify = urlsPhotosToVerify[index];
_context5.next = 19;
return faceapi.fetchImage(urlPhotosToVerify);
case 19:
photosToVerify = _context5.sent;
_context5.next = 22;
return faceapi.detectAllFaces(photosToVerify, new faceapi.TinyFaceDetectorOptions()).withFaceLandmarks().withFaceDescriptors();
case 22:
photosToVerifyAnalysis = _context5.sent;
photosToVerifyDescriptor = photosToVerifyAnalysis[0].descriptor;
resultFaceMatcher = faceMatcher.findBestMatch(photosToVerifyDescriptor);
if (resultFaceMatcher.label == "unknown") {
resultsFaceMatcher.push("false");
} else {
resultsFaceMatcher.push(resultFaceMatcher.label);
} // Deteccion de Objetos
_context5.next = 28;
return modeloCoco.detect(photosToVerify);
case 28:
predictions = _context5.sent;
if (predictions[0]) {
resultsObjects.push(predictions[0].class);
}
if (defaultFaceMatcher[index] == resultsFaceMatcher[index] && defaultObjects[index] == resultsObjects[index]) {
testCorrect += 1;
}
case 32:
index++;
_context5.next = 15;
break;
case 35:
_this5.allowsLocalSupervision = testCorrect == 11 ? true : false;
case 37:
case "end":
return _context5.stop();
}
}
}, _callee5);
}))();
},
verifyFace: function verifyFace(imgComparacion) {
var _this6 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
var url, diagnostico, modeloCoco, photosToVerify, photosToVerifyAnalysis, bestMatch, index, predictions, deteccion;
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.next = 2;
return _this6.uploadFiles(_this6.uriCaptura);
case 2:
url = _context6.sent;
diagnostico = {
idUniversidad: _this6.idUniversidad,
idExamen: _this6.idExamen,
IdEstudiante: _this6.idEstudiante,
fotoPerfil: _this6.urlPerfil,
objetos: [],
diagnosticos: [],
objetosSospechoso: [],
marcaTiempoCaptura: "",
marcaTiempoGuardado: "",
guardado: false,
reconocido: false,
detectadosAnalisis: 0,
detectadosCoco: 0,
url: url
};
_context6.next = 6;
return _this6.modelPromise;
case 6:
modeloCoco = _context6.sent;
_context6.next = 9;
return faceapi.fetchImage(imgComparacion);
case 9:
photosToVerify = _context6.sent;
_context6.next = 12;
return faceapi.detectAllFaces(photosToVerify).withFaceLandmarks().withFaceDescriptors();
case 12:
photosToVerifyAnalysis = _context6.sent;
_context6.next = 15;
return faceapi.detectAllFaces(photosToVerify, new faceapi.TinyFaceDetectorOptions()).withFaceLandmarks().withFaceDescriptors();
case 15:
_context6.sent;
// console.log("photosToVerifyAnalysis", photosToVerifyAnalysis);
// console.log("photosToVerifyAnalysisTiny", photosToVerifyAnalysisTiny);
if (photosToVerifyAnalysis.length > 0) {
diagnostico.detectadosAnalisis = photosToVerifyAnalysis.length;
bestMatch = photosToVerifyAnalysis.map(function (fd) {
return _this6.faceMatcher.findBestMatch(fd.descriptor);
}); // console.log("bestMatch", bestMatch)
for (index = 0; index < bestMatch.length; index++) {
if (bestMatch[index]._label == "true") {
diagnostico.reconocido = true;
}
}
}
_context6.next = 19;
return modeloCoco.detect(photosToVerify);
case 19:
predictions = _context6.sent;
deteccion = {
id: 0,
name: ""
};
diagnostico.objetos = predictions.map(function (object) {
return object.class;
});
diagnostico.objetosSospechoso = diagnostico.objetos.filter(function (item) {
return _this6.objetosSospechoso.includes(item);
});
diagnostico.detectadosCoco = diagnostico.objetos.filter(function (item) {
return item == "person";
}).length;
if (diagnostico.reconocido) {
deteccion = {
id: 6,
name: "Reconocido"
};
diagnostico.diagnosticos = [].concat(_toConsumableArray(diagnostico.diagnosticos), [deteccion]);
}
if (diagnostico.objetosSospechoso.length > 0) {
deteccion = {
id: 1,
name: "Deteccion de objeto sospechoso"
};
diagnostico.diagnosticos = [].concat(_toConsumableArray(diagnostico.diagnosticos), [deteccion]);
}
if (diagnostico.detectadosAnalisis == 0 && diagnostico.detectadosCoco == 0) {
deteccion = {
id: 16,
name: "No Detectado"
};
diagnostico.diagnosticos = [].concat(_toConsumableArray(diagnostico.diagnosticos), [deteccion]);
} else if (diagnostico.detectadosAnalisis > 1 || diagnostico.detectadosCoco > 1) {
deteccion = {
id: 21,
name: "Acompañado"
};
diagnostico.diagnosticos = [].concat(_toConsumableArray(diagnostico.diagnosticos), [deteccion]);
} else if (diagnostico.reconocido == false && (diagnostico.detectadosAnalisis > 0 || diagnostico.detectadosCoco > 0)) {
deteccion = {
id: 11,
name: "No Reconocido"
};
diagnostico.diagnosticos = [].concat(_toConsumableArray(diagnostico.diagnosticos), [deteccion]);
}
_this6.diagnosticos = [].concat(_toConsumableArray(_this6.diagnosticos), [diagnostico]);
_this6.feedback = deteccion.name; // console.log("diagnosticos", this.diagnosticos);
// 1 Deteccion de objeto sospechoso
// 6 Reconocido
// 11 No Reconocido
// 16 No Detectado
// 21 Acompañado
// 26 Sin Web Cam
// 31 Grabacion de Audio
// 36 Componente Eliminado
// 41 Error en Captura
// 46 Guardar Calificacion
// 51 Login Face Id
// 56 Sin Face Id
// 61 Sin Audio
// 66 Ausencia
// 71 Distraccion
// 76 Photo Upload
// 81 Sin Foto
// 86 Acompañado
// 91 Analisis de Audio
// 96 Video
// 101 Screen Recording
case 31:
case "end":
return _context6.stop();
}
}
}, _callee6);
}))();
},
// INSERT INTO auditoria_examenes (id_examen, idpersona, ip_acceso, timestamp_registro, request, request_url, fecha_registro, meta_datos, status) VALUES(1, 1128281476, '169.254.129.3', '2021-03-05 22:42:00.0', '[]', 'https://devopslabsterritorium-2.azurewebsites.net/', '2021-03-05', '{"file_url": "https://proctoring-files.azureedge.net/files/proctoringFiles/1507/2021-03-05/5998545/1433686/Video/4ljCFrT9bB1i1614984120ia6q67903000.webm", "timestamp": "2021-03-05 22:42:00", "session_hash": "f80ede8dff1cd91445d3a1af525d97f8621e8052", "es_incidencia": false, "tipo_incidencia": "Video", "timestamp_session": 1614984105865}', NULL);
blobToDataURL: function blobToDataURL(blob) {
return new Promise(function (resolve, reject) {
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onload = function () {
resolve(reader.result);
};
reader.onerror = reject;
});
},
getFoto: function getFoto() {
var thas = this;
return new Promise(function (resolve, reject) {
var uriCaptura = thas.$refs.devices.photo();
var captura = new Image();
captura.src = uriCaptura;
captura.onload = function () {
resolve(captura.src);
};
captura.onerror = reject;
});
},
getVideo: function getVideo() {
this.$refs.devices.video();
},
getAudio: function getAudio() {
this.$refs.devices.audio();
},
procesarPerfil: function procesarPerfil() {
var _this7 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
var response, blob, perfil, referencePhoto, referenceFaceAnalysis, referenceFaceDescriptor, referenceFacialFeatures, maxDescriptorDistance;
return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
if (!_this7.allowsLocalSupervision) {
_context7.next = 22;
break;
}
_context7.next = 3;
return axios.get(_this7.urlPerfil, {
method: 'GET',
responseType: 'blob' // important
});
case 3:
response = _context7.sent;
blob = new Blob([response.data], {
type: 'image/jpeg'
});
_context7.next = 7;
return _this7.blobToDataURL(blob);
case 7:
_this7.uriPerfil = _context7.sent;
perfil = _this7.$refs.perfil;
perfil.src = _this7.uriPerfil;
_context7.next = 12;
return faceapi.fetchImage(_this7.urlPerfil);
case 12:
referencePhoto = _context7.sent;
_context7.next = 15;
return faceapi.detectSingleFace(referencePhoto).withFaceLandmarks().withFaceDescriptor();
case 15:
referenceFaceAnalysis = _context7.sent;
referenceFaceDescriptor = [referenceFaceAnalysis.descriptor];
referenceFacialFeatures = new faceapi.LabeledFaceDescriptors("true", referenceFaceDescriptor);
maxDescriptorDistance = 0.6;
_this7.faceMatcher = new faceapi.FaceMatcher(referenceFacialFeatures, maxDescriptorDistance);
_context7.next = 22;
break;
case 22:
case "end":
return _context7.stop();
}
}
}, _callee7);
}))();
},
getDataVerify: function getDataVerify() {
var _this8 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
return regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
if (!_this8.allowsLocalSupervision) {
_context8.next = 8;
break;
}
_context8.next = 3;
return _this8.getFoto();
case 3:
_this8.uriCaptura = _context8.sent;
_context8.next = 6;
return _this8.verifyFace(_this8.uriCaptura);
case 6:
_context8.next = 8;
break;
case 8:
case "end":
return _context8.stop();
}
}
}, _callee8);
}))();
},
start: function start() {
var _this9 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
return regeneratorRuntime.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_context9.next = 2;
return _this9.getDataVerify();
case 2:
case "end":
return _context9.stop();
}
}
}, _callee9);
}))();
},
reportStatus: function reportStatus(message) {// console.log(`${message}`);
},
createContainer: function createContainer() {
var _this10 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() {
return regeneratorRuntime.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
_context10.prev = 0;
_this10.reportStatus("Creating container \"".concat(_this10.containerName, "\"..."));
_context10.next = 4;
return _this10.containerClient.create();
case 4:
_this10.reportStatus("Done.");
_context10.next = 10;
break;
case 7:
_context10.prev = 7;
_context10.t0 = _context10["catch"](0);
_this10.reportStatus(_context10.t0.message);
case 10:
case "end":
return _context10.stop();
}
}
}, _callee10, null, [[0, 7]]);
}))();
},
dataURItoBlob: function dataURItoBlob(dataURI) {
var byteString = atob(dataURI.split(',')[1]);
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ab], {
type: mimeString
});
},
uploadFiles: function uploadFiles(dataURL) {
var _arguments2 = arguments,
_this11 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
var name, url, blob, blockBlobURL;
return regeneratorRuntime.wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
name = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : "";
url = "";
blob = _this11.dataURItoBlob(dataURL);
_context11.prev = 3;
if (name == "") {
name = uuidv4();
name = "".concat(name, ".jpg");
}
_this11.reportStatus("Uploading files..."); // const blockBlobClient = this.containerClient.getBlockBlobClient(name);
// let data = await blockBlobClient.uploadBrowserData(blob);
// let url = data._response.request.url;
blockBlobURL = azblob.BlockBlobURL.fromContainerURL(_this11.containerURL, name);
_context11.next = 9;
return azblob.uploadBrowserDataToBlockBlob(azblob.Aborter.none, blob, blockBlobURL);
case 9:
url = _context11.sent;
return _context11.abrupt("return", url._response.request.url);
case 13:
_context11.prev = 13;
_context11.t0 = _context11["catch"](3);
_this11.reportStatus(_context11.t0.message);
return _context11.abrupt("return", null);
case 17:
case "end":
return _context11.stop();
}
}
}, _callee11, null, [[3, 13]]);
}))();
},
uploadBlobVideo: function uploadBlobVideo(dataBlob) {
var _arguments3 = arguments,
_this12 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
var name, url, blockBlobURL;
return regeneratorRuntime.wrap(function _callee12$(_context12) {
while (1) {
switch (_context12.prev = _context12.next) {
case 0:
name = _arguments3.length > 1 && _arguments3[1] !== undefined ? _arguments3[1] : "";
url = "";
_context12.prev = 2;
if (name == "") {
name = uuidv4();
name = "".concat(name, ".webm");
}
_this12.reportStatus("Uploading files..."); // const blockBlobClient = this.containerClient.getBlockBlobClient(name);
// // let blob = this.dataURItoBlob(dataURL);
// // let data = await blockBlobClient.uploadBrowserData(dataURL);
// let data = await blockBlobClient.uploadBrowserData(dataBlob);
blockBlobURL = azblob.BlockBlobURL.fromContainerURL(_this12.containerURL, name);
_context12.next = 8;
return azblob.uploadBrowserDataToBlockBlob(azblob.Aborter.none, dataBlob, blockBlobURL);
case 8:
url = _context12.sent;
return _context12.abrupt("return", url._response.request.url);
case 12:
_context12.prev = 12;
_context12.t0 = _context12["catch"](2);
_this12.reportStatus(_context12.t0.message);
return _context12.abrupt("return", null);
case 16:
case "end":
return _context12.stop();
}
}
}, _callee12, null, [[2, 12]]);
}))();
},
obtenerToken: function obtenerToken() {
var _this13 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
var data, config, response;
return regeneratorRuntime.wrap(function _callee13$(_context13) {
while (1) {
switch (_context13.prev = _context13.next) {
case 0:
_context13.prev = 0;
data = JSON.stringify({
"data": {
"idtest": _this13.idExamen,
"iduser": _this13.idEstudiante,
"institution": _this13.idUniversidad
}
});
config = {
method: 'post',
url: _this13.urlToken,
headers: {
'Authorization': "Bearer ".concat(_this13.authorization),
'Content-Type': 'application/json'
},
data: data
};
_context13.next = 5;
return axios(config);
case 5:
response = _context13.sent;
_this13.token = response.data;
_context13.next = 11;
break;
case 9:
_context13.prev = 9;
_context13.t0 = _context13["catch"](0);
case 11:
case "end":
return _context13.stop();
}
}
}, _callee13, null, [[0, 9]]);
}))();
},
configDiagnosticos: function configDiagnosticos() {
var _this14 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() {
var data, config, configDiagnostico;
return regeneratorRuntime.wrap(function _callee14$(_context14) {
while (1) {
switch (_context14.prev = _context14.next) {
case 0:
_context14.prev = 0;
data = {};
data = JSON.stringify(data);
config = {
method: 'get',
url: _this14.urlConfig,
headers: {
'Authorization': "Bearer ".concat(_this14.token),
'Content-Type': 'application/json'
},
data: data
};
_context14.next = 6;
return axios(config);
case 6:
configDiagnostico = _context14.sent;
_this14.config = configDiagnostico.data;
_this14.capturarFoto = _this14.config.startPhotos;
_this14.capturarVideo = _this14.config.startVideo;
_this14.capturarAudio = _this14.config.startAudio;
_context14.next = 15;
break;
case 13:
_context14.prev = 13;
_context14.t0 = _context14["catch"](0);
case 15:
case "end":
return _context14.stop();
}
}
}, _callee14, null, [[0, 13]]);
}))();
},
processDiagnosticos: function processDiagnosticos() {
var _this15 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15() {
var data, config;
return regeneratorRuntime.wrap(function _callee15$(_context15) {
while (1) {
switch (_context15.prev = _context15.next) {
case 0:
if (!(_this15.diagnosticos.length >= _this15.config.acumularPhotos)) {
_context15.next = 13;
break;
}
_context15.prev = 1;
data = {
data: _this15.diagnosticos
};
data = JSON.stringify(data);
config = {
method: 'post',
url: _this15.urlSaveDiagnosticos,
headers: {
'Authorization': "Bearer ".concat(_this15.token),
'Content-Type': 'application/json'
},
data: data
};
_context15.next = 7;
return axios(config);
case 7:
_context15.sent;
_this15.diagnosticos = []; // console.log (response.data);
_context15.next = 13;
break;
case 11:
_context15.prev = 11;
_context15.t0 = _context15["catch"](1);
case 13:
case "end":
return _context15.stop();
}
}
}, _callee15, null, [[1, 11]]);
}))();
},
processCapturas: function processCapturas() {
var _this16 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() {
var capturas, data, config;
return regeneratorRuntime.wrap(function _callee16$(_context16) {
while (1) {
switch (_context16.prev = _context16.next) {
case 0:
if (!(_this16.capturas.length >= _this16.config.acumularPhotos)) {
_context16.next = 14;
break;
}
_context16.prev = 1;
capturas = _toConsumableArray(_this16.capturas);
_this16.capturas = [];
data = {
data: capturas,
objects: _this16.objetosSospechoso,
analisysType: _this16.analisysType,
compareFace: _this16.urlPerfil
};
data = JSON.stringify(data);
config = {
method: 'post',
url: _this16.urlProcessDiagnosticos,
headers: {
'Authorization': "Bearer ".concat(_this16.token),
'Content-Type': 'application/json'
},
data: data
};
_context16.next = 9;
return axios(config);
case 9:
_context16.sent;
_context16.next = 14;
break;
case 12:
_context16.prev = 12;
_context16.t0 = _context16["catch"](1);
case 14:
case "end":
return _context16.stop();
}
}
}, _callee16, null, [[1, 12]]);
}))();
},
saveVideo: function saveVideo(url) {
var _this17 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() {
var data, config;
return regeneratorRuntime.wrap(function _callee17$(_context17) {
while (1) {
switch (_context17.prev = _context17.next) {
case 0:
_context17.prev = 0;
data = {
data: {
url: url
}
};
data = JSON.stringify(data);
config = {
method: 'post',
url: _this17.urlSaveVideo,
headers: {
'Authorization': "Bearer ".concat(_this17.token),
'Content-Type': 'application/json'
},
data: data
};
_context17.next = 6;
return axios(config);
case 6:
_context17.sent;
_context17.next = 11;
break;
case 9:
_context17.prev = 9;
_context17.t0 = _context17["catch"](0);
case 11:
case "end":
return _context17.stop();
}
}
}, _callee17, null, [[0, 9]]);
}))();
},
saveAudio: function saveAudio(url) {
var _this18 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18() {
var data, config;
return regeneratorRuntime.wrap(function _callee18$(_context18) {
while (1) {
switch (_context18.prev = _context18.next) {
case 0:
_context18.prev = 0;
data = {
data: {
url: url
}
};
data = JSON.stringify(data);
config = {
method: 'post',
url: _this18.urlSaveAudio,
headers: {
'Authorization': "Bearer ".concat(_this18.token),
'Content-Type': 'application/json'
},
data: data
};
_context18.next = 6;
return axios(config);
case 6:
_context18.sent;
_context18.next = 11;
break;
case 9:
_context18.prev = 9;
_context18.t0 = _context18["catch"](0);
case 11:
case "end":
return _context18.stop();
}
}
}, _callee18, null, [[0, 9]]);
}))();
},
coreProctoring: function coreProctoring() {
var _this19 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() {
var uriCaptura, url;
return regeneratorRuntime.wrap(function _callee19$(_context19) {
while (1) {
switch (_context19.prev = _context19.next) {
case 0:
if (_this19.timeElapsed >= _this19.capturarVideo) {
_this19.capturarVideo = _this19.capturarVideo + _this19.config.intervalVideo;
_this19.getVideo();
console.log("this.capturarVideo", _this19.capturarVideo);
}
if (_this19.timeElapsed >= _this19.capturarAudio) {
_this19.capturarAudio = _this19.capturarAudio + _this19.config.intervalAudio;
_this19.getAudio();
console.log("this.capturarAudio", _this19.capturarAudio);
}
if (!(_this19.timeElapsed >= _this19.capturarFoto)) {
_context19.next = 19;
break;
}
_this19.capturarFoto = _this19.capturarFoto + _this19.config.intervalPhotos;
if (!_this19.allowsLocalSupervision) {
_context19.next = 11;
break;
}
_context19.next = 7;
return _this19.getDataVerify();
case 7:
_context19.next = 9;
return _this19.processDiagnosticos();
case 9:
_context19.next = 18;
break;
case 11:
_context19.next = 13;
return _this19.getFoto();
case 13:
uriCaptura = _context19.sent;
_context19.next = 16;
return _this19.uploadFiles(uriCaptura);
case 16:
url = _context19.sent;
_this19.capturas = [].concat(_toConsumableArray(_this19.capturas), [url]); // console.log(this.capturas);
case 18:
console.log("this.capturarFoto", _this19.capturarFoto);
case 19:
_this19.timeElapsed = _this19.timeElapsed + _this19.timeInterval;
console.log("this.timeElapsed", _this19.timeElapsed);
case 21:
case "end":
return _context19.stop();
}
}
}, _callee19);
}))();
},
startProctoring: function startProctoring() {
var _this20 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20() {
return regeneratorRuntime.wrap(function _callee20$(_context20) {
while (1) {
switch (_context20.prev = _context20.next) {
case 0:
console.log(_this20.config);
try {
if (_this20.config.active) {
_this20.idCoreProctoring = setIntervalAsync(_this20.coreProctoring, _this20.timeInterval);
}
} catch (error) {
console.log(error);
}
case 2:
case "end":
return _context20.stop();
}
}
}, _callee20);
}))();
},
// ----------------------------------------------------------------------------------
createContainer2: function createContainer2() {
var _this21 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21() {
return regeneratorRuntime.wrap(function _callee21$(_context21) {
while (1) {
switch (_context21.prev = _context21.next) {
case 0:
_context21.prev = 0;
console.log("Creating container \"".concat(_this21.containerName, "\"..."));
_context21.next = 4;
return _this21.containerURL.create(azblob.Aborter.none);
case 4:
console.log("Done.");
_context21.next = 10;
break;
case 7:
_context21.prev = 7;
_context21.t0 = _context21["catch"](0);
console.log(_context21.t0.body.message);
case 10:
case "end":
return _context21.stop();
}
}
}, _callee21, null, [[0, 7]]);
}))();
}
},
mounted: function mounted() {
var _this22 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22() {
return regeneratorRuntime.wrap(function _callee22$(_context22) {
while (1) {
switch (_context22.prev = _context22.next) {
case 0:
_this22.allowsLocalSupervision = false;
_context22.next = 3;
return _this22.obtenerToken();
case 3:
_context22.next = 5;
return _this22.configDiagnosticos();
case 5:
// this.uriCaptura = this.$refs.devices.photo();
// this.modelPromise = cocoSsd.load();
// const modelPath = 'https://cdn.jsdelivr.net/npm/@vladmandic/face-api@1.2.3/model/';
// await faceapi.nets.tinyFaceDetector.loadFromUri(modelPath);
// await faceapi.nets.faceLandmark68Net.loadFromUri(modelPath);
// await faceapi.nets.faceRecognitionNet.loadFromUri(modelPath);
// await faceapi.nets.ssdMobilenetv1.loadFromUri(modelPath);
// await this.verifyLocalAnalysis();
// // --------------------------------------------------------------
// await this.procesarPerfil();
// // ----------------------------------------------------------------------
// AZURE
// console.log("this.config.blobSasUrl", this.config.blobSasUrl);
// this.blobServiceClient = new BlobServiceClient(this.config.blobSasUrl);
// this.containerClient = this.blobServiceClient.getContainerClient(this.containerName);
// Crear contenedor
// this.createContainer();
// await this.startProctoring();
// ----------------------------------------------------------------------------------
console.log("inicio");
_this22.containerURL = new azblob.ContainerURL("https://".concat(_this22.accountName, ".blob.core.windows.net/").concat(_this22.containerName, "?").concat(_this22.sasString), azblob.StorageURL.newPipeline(new azblob.AnonymousCredential()));
_context22.next = 9;
return _this22.createContainer2();
case 9:
_context22.next = 11;
return _this22.startProctoring();
case 11:
console.log("fin");
case 12:
case "end":
return _context22.stop();
}
}
}, _callee22);
}))();
},
beforeUnmount: function beforeUnmount() {
var _this23 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23() {
return regeneratorRuntime.wrap(function _callee23$(_context23) {
while (1) {
switch (_context23.prev = _context23.next) {
case 0:
_context23.next = 2;
return clearIntervalAsync(_this23.idCoreProctoring);
case 2:
case "end":
return _context23.stop();
}
}
}, _callee23);
}))();
}
});var _withId = /*#__PURE__*/vue.withScopeId("data-v-e6fc70d8");
vue.pushScopeId("data-v-e6fc70d8");
var _hoisted_1 = {
class: "territorium-proctoring"
};
var _hoisted_2 = {
ref: "perfil",
src: ""
};
var _hoisted_3 = {
ref: "captura",
src: ""
};
vue.popScopeId();
var render = /*#__PURE__*/_withId(function (_ctx, _cache, $props, $setup, $data, $options) {
var _component_territorium_device_manager = vue.resolveComponent("territorium-device-manager");
return vue.openBlock(), vue.createBlock("div", _hoisted_1, [vue.createVNode(_component_territorium_device_manager, {
ref: "devices",
onSendAudio: _cache[1] || (_cache[1] = function ($event) {
return _ctx.uriAudio = $event;
}),
onSendBlob: _cache[2] || (_cache[2] = function ($event) {
return _ctx.blobVideo = $event;
})
}, null, 512), vue.createVNode("label", null, vue.toDisplayString(_ctx.feedback), 1), vue.createVNode("img", _hoisted_2, null, 512), vue.createVNode("img", _hoisted_3, null, 512)]);
});function styleInject(css, ref) {
if ( ref === void 0 ) ref = {};
var insertAt = ref.insertAt;
if (!css || typeof document === 'undefined') { return; }
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if (insertAt === 'top') {
if (head.firstChild) {
head.insertBefore(style, head.firstChild);
} else {
head.appendChild(style);
}
} else {
head.appendChild(style);
}
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}var css_248z = "\n.territorium-proctoring[data-v-e6fc70d8] {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n background-color: darkgrey;\n width: 100%;\n height: 100%;\n}\n";
styleInject(css_248z);script.render = render;
script.__scopeId = "data-v-e6fc70d8";// Import vue component
// IIFE injects install function into component, allowing component
// to be registered via Vue.use() as well as Vue.component(),
var component = /*#__PURE__*/(function () {
// Get component instance
var installable = script; // Attach install function executed by Vue.use()
installable.install = function (app) {
app.component('TerritoriumProctoring', installable);
};
return installable;
})(); // It's possible to expose named exports when writing components that can
// also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo';
// export const RollupDemoDirective = directive;
var namedExports=/*#__PURE__*/Object.freeze({__proto__:null,'default': component});// only expose one global var, with named exports exposed as properties of
// that global var (eg. plugin.namedExport)
Object.entries(namedExports).forEach(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
exportName = _ref2[0],
exported = _ref2[1];
if (exportName !== 'default') component[exportName] = exported;
});module.exports=component;