/**
** EFIRMA CLASS FOR SUPPORTING SAFARI AND IOS IFRAME COOKIES.
**
** USO: INICIALIZAR LA CLASE CON EL CONSTRUCTOR
**
** VARIABLES
** @frameID : El ID de un
donde se renderizara el iframe donde se mostrara el documento.
** @frameURL: La URL de acceso al usuario, esta sera obtenida de las respuestas API de creacion y consulta de documentos.
**
** HTML
** Para su funcionamiento correcto en Safari 13.1 y anteriores, es necesario que, despues de inicializar la clase EfirmaTools,
** cree un boton que mande a llamar el metodo EfirmaTools.openWindow();
**
**
** El botón podra ser estilizado a cualquier apariencia segun su interfaz.
**
**
********EJEMPLO HTML
********
********
********
********
********
********
********
********
********
********
********
********
** AL PRESIONAR EL BOTON SE ABRIRA UNA VENTANA Y SE CERRARA AUTOMATICAMENTE, DESPUES SE MOSTRARA EL IFRAME SOLICITANDO EL CODIGO OTP DEL CORREO.
**/
class EfirmaTools {
constructor(frameID, frameURL) {
if (frameID === undefined || frameURL === undefined) {
console.error('Please initialize EfirmaTools properly')
return;
}
this.frame = frameID;
this.frameURL = frameURL;
this.efirmaStorageUrl = 'https://efirma.com/storage';
this.messageListener();
}
openWindow() {
if (this.frame === undefined || this.frameURL === undefined) {
console.error('Please initialize EfirmaTools properly;')
return;
}
window.open(this.efirmaStorageUrl, '_blank');
let str = '';
document.getElementById(this.frame).innerHTML = str;
return;
}
messageListener(){
window.addEventListener(
"message",
function(e) {
console.log(e.data.return_url);
if (e.data.return_url.length >0) {
location.href = e.data.return_url
}
}
);
}
}