diff --git a/assets/js/gn-checkout.js b/assets/js/gn-checkout.js deleted file mode 100644 index 4d5212a..0000000 --- a/assets/js/gn-checkout.js +++ /dev/null @@ -1,293 +0,0 @@ -window.onload = function () { - jQuery( document ).ready( - function ($) { - - let swalCss = $( "" ).html( ".colored-toast .swal2-title {color: white;}.colored-toast .swal2-close {color: white;}.colored-toast .swal2-html-container {color: white;}.colored-toast.swal2-icon-error {background-color: #f27474 !important;}" ) - $( "#gn-checkout-js" ).after( swalCss ); - - if (document.getElementById("gn_boleto_cpf_cnpj")) { - $( '#gn_boleto_cpf_cnpj' ).keyup( - function () { - $( '#gn_boleto_cpf_cnpj' ).val().length > 14 ? VMasker(document.querySelector("#gn_boleto_cpf_cnpj")).maskPattern("99.999.999/9999-99") : VMasker(document.querySelector("#gn_boleto_cpf_cnpj")).maskPattern("999.999.999-99"); - } - ) - $( '#gn_boleto_cpf_cnpj' ).blur( - function () { - var cpf_cnpj = $( '#gn_boleto_cpf_cnpj' ).val(); - - if ( ! validate_cpf_cnpj( cpf_cnpj )) { - $( '#gn_boleto_cpf_cnpj' ).css( 'border', '1px solid red' ); - customError("CPF/CNPJ Inválido"); - } else { - $( '#gn_boleto_cpf_cnpj' ).css( 'border', '1px solid green' ); - } - } - ) - } - - if (document.getElementById('gn_pix_cpf_cnpj' )) { - $( '#gn_pix_cpf_cnpj' ).keyup( - function () { - $( '#gn_pix_cpf_cnpj' ).val().length > 14 ? VMasker(document.querySelector("#gn_pix_cpf_cnpj")).maskPattern("99.999.999/9999-99") : VMasker(document.querySelector("#gn_pix_cpf_cnpj")).maskPattern("999.999.999-99"); - } - ) - $( '#gn_pix_cpf_cnpj' ).blur( - function () { - var cpf_cnpj = $( '#gn_pix_cpf_cnpj' ).val(); - - if ( ! validate_cpf_cnpj( cpf_cnpj )) { - $( '#gn_pix_cpf_cnpj' ).css( 'border', '1px solid red' ); - customError("CPF/CNPJ Inválido"); - } else { - $( '#gn_pix_cpf_cnpj' ).css( 'border', '1px solid green' ); - } - } - ) - } - - if (document.getElementById('gn_cartao_cpf_cnpj' )) { - $( '#gn_cartao_cpf_cnpj' ).keyup( - function () { - $( '#gn_cartao_cpf_cnpj' ).val().length > 14 ? VMasker(document.querySelector("#gn_cartao_cpf_cnpj")).maskPattern("99.999.999/9999-99") : VMasker(document.querySelector("#gn_cartao_cpf_cnpj")).maskPattern("999.999.999-99"); - } - ) - $( '#gn_cartao_cpf_cnpj' ).blur( - function () { - var cpf_cnpj = $( '#gn_cartao_cpf_cnpj' ).val(); - - if ( ! validate_cpf_cnpj( cpf_cnpj )) { - $( '#gn_cartao_cpf_cnpj' ).css( 'border', '1px solid red' ); - customError("CPF/CNPJ Inválido"); - } else { - $( '#gn_cartao_cpf_cnpj' ).css( 'border', '1px solid green' ); - } - } - ) - } - - if (document.getElementById('gn_cartao_birth' )) { - VMasker(document.querySelector("#gn_cartao_birth")).maskPattern("99/99/9999"); - $( '#gn_cartao_birth' ).blur( - function () { - var date = $( '#gn_cartao_birth' ).val(); - - if ( ! verify_date( date )) { - $( '#gn_cartao_birth' ).css( 'border', '1px solid red' ); - customError( 'Data de nascimento inválida!' ); - } else { - $( '#gn_cartao_birth' ).css( 'border', '1px solid green' ); - } - } - ) - } - - if (document.getElementById( 'gn_cartao_expiration' )) { - VMasker(document.querySelector("#gn_cartao_expiration")).maskPattern("99/9999"); - $( '#gn_cartao_expiration' ).blur( - function () { - var exp = $( '#gn_cartao_expiration' ).val(); - - if ( ! validate_cartao_expiration( exp )) { - $( '#gn_cartao_expiration' ).css( 'border', '1px solid red' ); - customError( 'Validade do cartão inválida!' ); - } else { - $( '#gn_cartao_expiration' ).css( 'border', '1px solid green' ); - } - } - ) - } - - if (document.getElementById('gn_cartao_number' )) { - VMasker(document.querySelector("#gn_cartao_number")).maskPattern("9999 9999 9999 99999"); - } - - // Esconder campos caso haja o brazillian market - - if (typeof $( '#billing_cpf' ).val() !== 'undefined') { - - // cpf_cnpj boleto - $( '#gn_boleto_cpf_cnpj' ).val( $( '#billing_cpf' ).val() ) - $( '#gn_field_boleto' ).hide(); - - // cpf_cnpj cartão - $( '#gn_cartao_cpf_cnpj' ).val( $( '#billing_cpf' ).val() ) - $( '#gn_field_cpf_cnpj' ).hide(); - $( "#gn_field_birth" ).removeClass( "form-row-last" ).addClass( "form-row-wide" ); - - // cpf_cnpj Pix - $( '#gn_pix_cpf_cnpj' ).val( $( '#billing_cpf' ).val() ) - $( '#gn_field_pix' ).hide(); - - $( '#billing_cpf' ).keyup(function () { - - // cpf_cnpj boleto - $( '#gn_boleto_cpf_cnpj' ).val( $( '#billing_cpf' ).val() ) - $( '#gn_field_boleto' ).hide(); - - // cpf_cnpj cartão - $( '#gn_cartao_cpf_cnpj' ).val( $( '#billing_cpf' ).val() ) - $( '#gn_field_cpf_cnpj' ).hide(); - $( "#gn_field_birth" ).removeClass( "form-row-last" ).addClass( "form-row-wide" ); - - // cpf_cnpj Pix - $( '#gn_pix_cpf_cnpj' ).val( $( '#billing_cpf' ).val() ) - $( '#gn_field_pix' ).hide(); - } - ) - } - - if (typeof $( '#billing_cnpj' ).val() !== 'undefined') { - $( '#billing_cnpj' ).keyup( - function () { - // cpf_cnpj boleto - $( '#gn_boleto_cpf_cnpj' ).val( $( '#billing_cnpj' ).val() ) - $( '#gn_field_boleto' ).hide(); - - // cpf_cnpj cartão - $( '#gn_cartao_cpf_cnpj' ).val( $( '#billing_cnpj' ).val() ) - $( '#gn_field_cpf_cnpj' ).hide(); - $( "#gn_field_birth" ).removeClass( "form-row-last" ).addClass( "form-row-wide" ); - - // cpf_cnpj Pix - $( '#gn_pix_cpf_cnpj' ).val( $( '#billing_cnpj' ).val() ) - $( '#gn_field_pix' ).hide(); - } - ) - } - - if (typeof $( '#billing_birthdate' ).val() !== 'undefined') { - - $( '#gn_cartao_birth' ).val( $( '#billing_birthdate' ).val() ) - $( '#gn_field_birth' ).hide(); - - $( '#billing_birthdate' ).keyup( - function () { - $( '#gn_cartao_birth' ).val( $( '#billing_birthdate' ).val() ) - $( '#gn_field_birth' ).hide(); - } - ) - } - - // Bairro obrigatório - if (typeof $( '#billing_neighborhood_field > label > span' ).html() !== 'undefined') { - $( '#billing_neighborhood_field > label > span' ).html( $( '#billing_neighborhood_field > label > span' ).html().replace( 'opcional', 'obrigatório' ) ) - } - - } - ); - - function validate_cpf_cnpj(cpf_cnpj) { - - cpf_cnpj = cpf_cnpj.trim().replace( /\./g, '' ).replace( '-', '' ).replace( '/', '' ); - - if (cpf_cnpj < 11) { - return false; - } - - if (cpf_cnpj.length == 11) { - var remnant, sum = 0; - - for (i = 1; i <= 9; i++) { - sum = sum + parseInt( cpf_cnpj.substring( i - 1, i ) ) * (11 - i); - } - remnant = (sum * 10) % 11; - - if ((remnant == 10) || (remnant == 11)) { - remnant = 0; - } - if (remnant != parseInt( cpf_cnpj.substring( 9, 10 ) )) { - return false; - } - - sum = 0; - - for (i = 1; i <= 10; i++) { - sum = sum + parseInt( cpf_cnpj.substring( i - 1, i ) ) * (12 - i); - } - remnant = (sum * 10) % 11; - - if ((remnant == 10) || (remnant == 11)) { - remnant = 0; - } - if (remnant != parseInt( cpf_cnpj.substring( 10, 11 ) )) { - return false; - } - return true; - - } else if (cpf_cnpj.length == 14) { - var tam = cpf_cnpj.length - 2 - var numbers = cpf_cnpj.substring( 0, tam ); - var digits = cpf_cnpj.substring( tam ); - var sum = 0; - var pos = tam - 7; - - for (i = tam; i >= 1; i--) { - sum += numbers.charAt( tam - i ) * pos--; - if (pos < 2) { - pos = 9; - } - } - - var result = sum % 11 < 2 ? 0 : 11 - sum % 11; - - if (result != digits.charAt( 0 )) { - return false; - } - - tam = tam + 1; - numbers = cpf_cnpj.substring( 0, tam ); - sum = 0; - pos = tam - 7; - - for (i = tam; i >= 1; i--) { - sum += numbers.charAt( tam - i ) * pos--; - if (pos < 2) { - pos = 9; - } - } - - result = sum % 11 < 2 ? 0 : 11 - sum % 11; - - if (result != digits.charAt( 1 )) { - return false; - } - - return true; - } - - } - - function verify_date(date) { - var patternValidateDate = /^(((0[1-9]|[12][0-9]|3[01])([-.\/])(0[13578]|10|12)([-.\/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([-.\/])(0[469]|11)([-.\/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([-.\/])(02)([-.\/])(\d{4}))|((29)(\.|-|\/)(02)([-.\/])([02468][048]00))|((29)([-.\/])(02)([-.\/])([13579][26]00))|((29)([-.\/])(02)([-.\/])([0-9][0-9][0][48]))|((29)([-.\/])(02)([-.\/])([0-9][0-9][2468][048]))|((29)([-.\/])(02)([-.\/])([0-9][0-9][13579][26])))$/; - return patternValidateDate.test( date ); - } - - function validate_cartao_expiration(exp) { - exp = exp.split( '/' ); - const newDate = new Date(); - const year = newDate.getFullYear(); - - if ((parseInt( exp[0] ) > 12 || (parseInt( exp[0] < 0 )) || (parseInt( exp[1] < year )))) { - return false; - } - return true; - - } - - function customError(msg) { - Swal.mixin( - { - toast: true, - position: 'top-right', - iconColor: 'white', - customClass: { - popup: 'colored-toast' - }, - showConfirmButton: false, - timer: 5000, - timerProgressBar: true - } - ).fire( { icon: 'error', title: msg } ) - } - -}; diff --git a/assets/js/payment-token-efi.min.js b/assets/js/payment-token-efi.min.js new file mode 100755 index 0000000..7a9b26a --- /dev/null +++ b/assets/js/payment-token-efi.min.js @@ -0,0 +1 @@ +(()=>{var t={370:t=>{var e;window,e=()=>(()=>{var t={155:t=>{var e,r,i=t.exports={};function n(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(t){if(e===setTimeout)return setTimeout(t,0);if((e===n||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:n}catch(t){e=n}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var a,h=[],u=!1,c=-1;function l(){u&&a&&(u=!1,a.length?h=a.concat(h):c=-1,h.length&&f())}function f(){if(!u){var t=o(l);u=!0;for(var e=h.length;e;){for(a=h,h=[];++c1)for(var r=1;r{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i={};return(()=>{"use strict";function t(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function e(t,e){return t&e}function n(t,e){return t|e}function s(t,e){return t^e}function o(t,e){return t&~e}function a(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function h(t){for(var e=0;0!=t;)t&=t-1,++e;return e}r.d(i,{default:()=>ot});var u,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function l(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=c.charAt(r>>6)+c.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=c.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=c.charAt(r>>2)+c.charAt((3&r)<<4));(3&i.length)>0;)i+="=";return i}function f(e){var r,i="",n=0,s=0;for(r=0;r>2),s=3&o,n=1):1==n?(i+=t(s<<2|o>>4),s=15&o,n=2):2==n?(i+=t(s),i+=t(o>>2),s=3&o,n=3):(i+=t(s<<2|o>>4),i+=t(15&o),n=0))}return 1==n&&(i+=t(s<<2)),i}var p,d={decode:function(t){var e;if(void 0===p){var r="= \f\n\r\t \u2028\u2029";for(p=Object.create(null),e=0;e<64;++e)p["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(p["-"]=62,p._=63,e=0;e=4?(i[i.length]=n>>16,i[i.length]=n>>8&255,i[i.length]=255&n,n=0,s=0):n<<=6}}switch(s){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=n>>10;break;case 3:i[i.length]=n>>16,i[i.length]=n>>8&255}return i},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=d.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return d.decode(t)}},g=1e13,m=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var r,i,n=this.buf,s=n.length;for(r=0;r0&&(n[r]=e)},t.prototype.sub=function(t){var e,r,i=this.buf,n=i.length;for(e=0;e=0;--i)r+=(g+e[i]).toString().substring(1);return r},t.prototype.valueOf=function(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*g+t[r];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),v=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,y=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function b(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}var T,w=function(){function t(e,r){this.hexDigits="0123456789ABCDEF",e instanceof t?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=r)}return t.prototype.get=function(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset ".concat(t," on a stream of length ").concat(this.enc.length));return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]},t.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},t.prototype.hexDump=function(t,e,r){for(var i="",n=t;n176)return!1}return!0},t.prototype.parseStringISO=function(t,e){for(var r="",i=t;i191&&n<224?String.fromCharCode((31&n)<<6|63&this.get(i++)):String.fromCharCode((15&n)<<12|(63&this.get(i++))<<6|63&this.get(i++))}return r},t.prototype.parseStringBMP=function(t,e){for(var r,i,n="",s=t;s127,s=n?255:0,o="";i==s&&++t4){for(o=i,r<<=3;0==(128&(+o^s));)o=+o<<1,--r;o="("+r+" bit)\n"}n&&(i-=256);for(var a=new m(i),h=t+1;h=h;--u)s+=a>>u&1?"1":"0";if(s.length>r)return n+b(s,r)}return n+s},t.prototype.parseOctetString=function(t,e,r){if(this.isASCII(t,e))return b(this.parseStringISO(t,e),r);var i=e-t,n="("+i+" byte)\n";i>(r/=2)&&(e=t+r);for(var s=t;sr&&(n+="…"),n},t.prototype.parseOID=function(t,e,r){for(var i="",n=new m,s=0,o=t;or)return b(i,r);n=new m,s=0}}return s>0&&(i+=".incomplete"),i},t}(),S=function(){function t(t,e,r,i,n){if(!(i instanceof E))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=i,this.sub=n}return t.prototype.typeName=function(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}},t.prototype.content=function(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return b(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return b(this.stream.parseStringISO(e,e+r),t);case 30:return b(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null},t.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},t.prototype.toPrettyString=function(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,i=this.sub.length;r6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var i=0;i>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new m;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),D=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],x=(1<<26)/D[D.length-1],R=function(){function r(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}return r.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var r;if(16==e)r=4;else if(8==e)r=3;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return this.toRadix(e);r=2}var i,n=(1<0)for(h>h)>0&&(s=!0,o=t(i));a>=0;)h>(h+=this.DB-r)):(i=this[a]>>(h-=r)&n,h<=0&&(h+=this.DB,--a)),i>0&&(s=!0),s&&(o+=t(i));return s?o:"0"},r.prototype.negate=function(){var t=V();return r.ZERO.subTo(this,t),t},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(t){var e=V();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(r.ZERO)>0&&t.subTo(e,e),e},r.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new O(e):new A(e),this.exp(t,r)},r.prototype.clone=function(){var t=V();return this.copyTo(t),t},r.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var r,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i>i)!=(this.s&this.DM)>>i&&(e[n++]=r|this.s<=0;)i<8?(r=(this[t]&(1<>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=r);return e},r.prototype.equals=function(t){return 0==this.compareTo(t)},r.prototype.min=function(t){return this.compareTo(t)<0?this:t},r.prototype.max=function(t){return this.compareTo(t)>0?this:t},r.prototype.and=function(t){var r=V();return this.bitwiseTo(t,e,r),r},r.prototype.or=function(t){var e=V();return this.bitwiseTo(t,n,e),e},r.prototype.xor=function(t){var e=V();return this.bitwiseTo(t,s,e),e},r.prototype.andNot=function(t){var e=V();return this.bitwiseTo(t,o,e),e},r.prototype.not=function(){for(var t=V(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=V();for(i.sqrTo(o[1],c);a<=u;)o[a]=V(),i.mulTo(c,o[a-2],o[a]),a+=2}var l,f,p=t.t-1,d=!0,g=V();for(n=H(t[p])-1;p>=0;){for(n>=h?l=t[p]>>n-h&u:(l=(t[p]&(1<0&&(l|=t[p-1]>>this.DB+n-h)),a=r;0==(1&l);)l>>=1,--a;if((n-=a)<0&&(n+=this.DB,--p),d)o[l].copyTo(s),d=!1;else{for(;a>1;)i.sqrTo(s,g),i.sqrTo(g,s),a-=2;a>0?i.sqrTo(s,g):(f=s,s=g,g=f),i.mulTo(g,o[l],s)}for(;p>=0&&0==(t[p]&1<=0?(i.subTo(n,i),e&&s.subTo(a,s),o.subTo(h,o)):(n.subTo(i,n),e&&a.subTo(s,a),h.subTo(o,h))}return 0!=n.compareTo(r.ONE)?r.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},r.prototype.pow=function(t){return this.exp(t,new B)},r.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var n=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(n0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},r.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=D[D.length-1]){for(e=0;e=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},r.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},r.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,s=!1,o=0;--n>=0;){var a=8==i?255&+t[n]:q(t,n);a<0?"-"==t.charAt(n)&&(s=!0):(s=!1,0==o?this[this.t++]=a:o+i>this.DB?(this[this.t-1]|=(a&(1<>this.DB-o):this[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==i&&0!=(128&+t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},r.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},r.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--a)e[a+s+1]=this[a]>>i|o,o=(this[a]&n)<=0;--a)e[a]=0;e[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()},r.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,n=this.DB-i,s=(1<>i;for(var o=r+1;o>i;i>0&&(e[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()},r.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),s=i.t;for(e.t=s+n.t;--s>=0;)e[s]=0;for(s=0;s=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},r.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var s=this.abs();if(s.t0?(n.lShiftTo(u,o),s.lShiftTo(u,i)):(n.copyTo(o),s.copyTo(i));var c=o.t,l=o[c-1];if(0!=l){var f=l*(1<1?o[c-2]>>this.F2:0),p=this.FV/f,d=(1<=0&&(i[i.t++]=1,i.subTo(y,i)),r.ONE.dlShiftTo(c,y),y.subTo(o,o);o.t=0;){var b=i[--m]==l?this.DM:Math.floor(i[m]*p+(i[m-1]+g)*d);if((i[m]+=o.am(0,b,i,v,0,c))0&&i.rShiftTo(u,i),a<0&&r.ZERO.subTo(i,i)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},r.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},r.prototype.exp=function(t,e){if(t>4294967295||t<1)return r.ONE;var i=V(),n=V(),s=e.convert(this),o=H(t)-1;for(s.copyTo(i);--o>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,s,i);else{var a=i;i=n,n=a}return e.revert(i)},r.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},r.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=L(r),n=V(),s=V(),o="";for(this.divRemTo(i,n,s);n.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,n.divRemTo(i,n,s);return s.intValue().toString(t)+o},r.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),s=!1,o=0,a=0,h=0;h=i&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(a,0)),s&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(r.ONE.shiftLeft(t-1),n,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(r.ONE.shiftLeft(t-1),this);else{var s=[],o=7&t;s.length=1+(t>>3),e.nextBytes(s),o>0?s[0]&=(1<>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()},r.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},r.prototype.multiplyLowerTo=function(t,e,r){var i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(var n=r.t-this.t;i=0;)r[i]=0;for(i=Math.max(e-this.t,0);i0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r},r.prototype.millerRabin=function(t){var e=this.subtract(r.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>D.length&&(t=D.length);for(var s=V(),o=0;o0&&(r.rShiftTo(o,r),i.rShiftTo(o,i));var a=function(){(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),r.compareTo(i)>=0?(r.subTo(i,r),r.rShiftTo(1,r)):(i.subTo(r,i),i.rShiftTo(1,i)),r.signum()>0?setTimeout(a,0):(o>0&&i.lShiftTo(o,i),setTimeout((function(){e(i)}),0))};setTimeout(a,10)}},r.prototype.fromNumberAsync=function(t,e,i,s){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(r.ONE.shiftLeft(t-1),n,this),this.isEven()&&this.dAddOffset(1,0);var o=this,a=function(){o.dAddOffset(2,0),o.bitLength()>t&&o.subTo(r.ONE.shiftLeft(t-1),o),o.isProbablePrime(e)?setTimeout((function(){s()}),0):setTimeout(a,0)};setTimeout(a,0)}else{var h=[],u=7&t;h.length=1+(t>>3),e.nextBytes(h),u>0?h[0]&=(1<=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),A=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=V();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),I=function(){function t(t){this.m=t,this.r2=V(),this.q3=V(),R.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=V();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function V(){return new R(null)}function N(t,e){return new R(t,e)}var P="undefined"!=typeof navigator;P&&"Microsoft Internet Explorer"==navigator.appName?(R.prototype.am=function(t,e,r,i,n,s){for(var o=32767&e,a=e>>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;n=((h=o*h+((32767&c)<<15)+r[i]+(1073741823&n))>>>30)+(c>>>15)+a*u+(n>>>30),r[i++]=1073741823&h}return n},T=30):P&&"Netscape"!=navigator.appName?(R.prototype.am=function(t,e,r,i,n,s){for(;--s>=0;){var o=e*this[t++]+r[i]+n;n=Math.floor(o/67108864),r[i++]=67108863&o}return n},T=26):(R.prototype.am=function(t,e,r,i,n,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;n=((h=o*h+((16383&c)<<14)+r[i]+n)>>28)+(c>>14)+a*u,r[i++]=268435455&h}return n},T=28),R.prototype.DB=T,R.prototype.DM=(1<>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}R.ZERO=L(0),R.ONE=L(1);var _,k,$=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0},t.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},t}(),U=null;if(null==U){U=[],k=0;var K=void 0;if("undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues){var F=new Uint32Array(256);for(window.crypto.getRandomValues(F),K=0;K=256||k>=256)window.removeEventListener?window.removeEventListener("mousemove",Z,!1):window.detachEvent&&window.detachEvent("onmousemove",Z);else try{var e=t.x+t.y;U[k++]=255&e,z+=1}catch(t){}};"undefined"!=typeof window&&(window.addEventListener?window.addEventListener("mousemove",Z,!1):window.attachEvent&&window.attachEvent("onmousemove",Z))}function G(){if(null==_){for(_=new $;k<256;){var t=Math.floor(65536*Math.random());U[k++]=255&t}for(_.init(U),k=0;k0&&e.length>0?(this.n=N(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")},t.prototype.encrypt=function(t){var e=this.n.bitLength()+7>>3,r=function(t,e){if(e=0&&e>0;){var n=t.charCodeAt(i--);n<128?r[--e]=n:n>127&&n<2048?(r[--e]=63&n|128,r[--e]=n>>6|192):(r[--e]=63&n|128,r[--e]=n>>6&63|128,r[--e]=n>>12|224)}r[--e]=0;for(var s=new Y,o=[];e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new R(r)}(t,e);if(null==r)return null;var i=this.doPublic(r);if(null==i)return null;for(var n=i.toString(16),s=n.length,o=0;o<2*e-s;o++)n="0"+n;return n},t.prototype.setPrivate=function(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=N(t,16),this.e=parseInt(e,16),this.d=N(r,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,r,i,n,s,o,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=N(t,16),this.e=parseInt(e,16),this.d=N(r,16),this.p=N(i,16),this.q=N(n,16),this.dmp1=N(s,16),this.dmq1=N(o,16),this.coeff=N(a,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var r=new Y,i=t>>1;this.e=parseInt(e,16);for(var n=new R(e,16);;){for(;this.p=new R(t-i,1,r),0!=this.p.subtract(R.ONE).gcd(n).compareTo(R.ONE)||!this.p.isProbablePrime(10););for(;this.q=new R(i,1,r),0!=this.q.subtract(R.ONE).gcd(n).compareTo(R.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(R.ONE),a=this.q.subtract(R.ONE),h=o.multiply(a);if(0==h.gcd(n).compareTo(R.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=N(t,16),r=this.doPrivate(e);return null==r?null:function(t,e){for(var r=t.toByteArray(),i=0;i=r.length)return null;for(var n="";++i191&&s<224?(n+=String.fromCharCode((31&s)<<6|63&r[i+1]),++i):(n+=String.fromCharCode((15&s)<<12|(63&r[i+1])<<6|63&r[i+2]),i+=2)}return n}(r,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,r){var i=new Y,n=t>>1;this.e=parseInt(e,16);var s=new R(e,16),o=this,a=function(){var e=function(){if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(R.ONE),i=o.q.subtract(R.ONE),n=e.multiply(i);0==n.gcd(s).compareTo(R.ONE)?(o.n=o.p.multiply(o.q),o.d=s.modInverse(n),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(i),o.coeff=o.q.modInverse(o.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},h=function(){o.q=V(),o.q.fromNumberAsync(n,1,i,(function(){o.q.subtract(R.ONE).gcda(s,(function(t){0==t.compareTo(R.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(h,0)}))}))},u=function(){o.p=V(),o.p.fromNumberAsync(t-n,1,i,(function(){o.p.subtract(R.ONE).gcda(s,(function(t){0==t.compareTo(R.ONE)&&o.p.isProbablePrime(10)?setTimeout(h,0):setTimeout(u,0)}))}))};setTimeout(u,0)};setTimeout(a,0)},t.prototype.sign=function(t,e,r){var i=function(t,e){if(e15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},Q.asn1.DERAbstractString=function(t){Q.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},X.lang.extend(Q.asn1.DERAbstractString,Q.asn1.ASN1Object),Q.asn1.DERAbstractTime=function(t){Q.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,r){var i=this.zeroPadding,n=this.localDateToUTC(t),s=String(n.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+i(String(n.getMonth()+1),2)+i(String(n.getDate()),2)+i(String(n.getHours()),2)+i(String(n.getMinutes()),2)+i(String(n.getSeconds()),2);if(!0===r){var a=n.getMilliseconds();if(0!=a){var h=i(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,r,i,n,s){var o=new Date(Date.UTC(t,e-1,r,i,n,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},X.lang.extend(Q.asn1.DERAbstractTime,Q.asn1.ASN1Object),Q.asn1.DERAbstractStructured=function(t){Q.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},X.lang.extend(Q.asn1.DERAbstractStructured,Q.asn1.ASN1Object),Q.asn1.DERBoolean=function(){Q.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},X.lang.extend(Q.asn1.DERBoolean,Q.asn1.ASN1Object),Q.asn1.DERInteger=function(t){Q.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Q.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new R(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},X.lang.extend(Q.asn1.DERInteger,Q.asn1.ASN1Object),Q.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=Q.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}Q.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7=2?(n[n.length]=s,s=0,o=0):s<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}(t):d.unarmor(t),n=S.decode(i);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=N(e,16),r=n.sub[2].getHexStringValue(),this.e=parseInt(r,16);var s=n.sub[3].getHexStringValue();this.d=N(s,16);var o=n.sub[4].getHexStringValue();this.p=N(o,16);var a=n.sub[5].getHexStringValue();this.q=N(a,16);var h=n.sub[6].getHexStringValue();this.dmp1=N(h,16);var c=n.sub[7].getHexStringValue();this.dmq1=N(c,16);var l=n.sub[8].getHexStringValue();this.coeff=N(l,16)}else{if(2!==n.sub.length)return!1;if(n.sub[0].sub){var f=n.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=N(e,16),r=f.sub[1].getHexStringValue(),this.e=parseInt(r,16)}else e=n.sub[0].getHexStringValue(),this.n=N(e,16),r=n.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new Q.asn1.DERInteger({int:0}),new Q.asn1.DERInteger({bigint:this.n}),new Q.asn1.DERInteger({int:this.e}),new Q.asn1.DERInteger({bigint:this.d}),new Q.asn1.DERInteger({bigint:this.p}),new Q.asn1.DERInteger({bigint:this.q}),new Q.asn1.DERInteger({bigint:this.dmp1}),new Q.asn1.DERInteger({bigint:this.dmq1}),new Q.asn1.DERInteger({bigint:this.coeff})]};return new Q.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return l(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new Q.asn1.DERSequence({array:[new Q.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new Q.asn1.DERNull]}),e=new Q.asn1.DERSequence({array:[new Q.asn1.DERInteger({bigint:this.n}),new Q.asn1.DERInteger({int:this.e})]}),r=new Q.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new Q.asn1.DERSequence({array:[t,r]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return l(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var r="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(r,"g")).join("\n")},e.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return(t+=e.wordwrap(this.getPrivateBaseKeyB64())+"\n")+"-----END RSA PRIVATE KEY-----"},e.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return(t+=e.wordwrap(this.getPublicBaseKeyB64())+"\n")+"-----END PUBLIC KEY-----"},e.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.hasPrivateKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},e.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},e}(J),nt=r(155),st=void 0!==nt?null===(et=nt.env)||void 0===et?void 0:"3.3.1":void 0;const ot=function(){function t(t){void 0===t&&(t={}),t=t||{},this.default_key_size=t.default_key_size?parseInt(t.default_key_size,10):1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new it(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(f(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return l(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,r){try{return l(this.getKey().sign(t,e,r))}catch(t){return!1}},t.prototype.verify=function(t,e,r){try{return this.getKey().verify(t,f(e),r)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new it,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version=st,t}()})(),i.default})(),t.exports=e()}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={exports:{}};return t[i](s,s.exports,r),s.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};(()=>{"use strict";r.r(i),r.d(i,{CreditCard:()=>f});class t extends Error{constructor(t){super(t.mensagem),this.codigo=t.codigo,this.nome=t.nome,this.mensagem=t.mensagem}}class e{static async getSalt(e,r=!1){const i=await fetch("https://tokenizer.gerencianet.com.br/salt",{method:"GET",headers:{"Account-code":e,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}});i.ok||await i.json().then((e=>{r&&console.error("Salt",e);const i={codigo:void 0!==e.code?e.code:500,nome:void 0!==e.error?e.error:"request_error",mensagem:void 0!==e.error_description?e.error_description:"Falha ao capturar o salt no processo getSalt"};throw new t(i)}));const n=await i.json();return document.cookie=`${encodeURIComponent("salt")}=${encodeURIComponent(n.data)}; max-age=60; expires=${new Date(Date.now()+60).toUTCString()}; path=/; SameSite=Strict; Secure`,n.data}}class n{static async getPublicKey(e,r,i=!1){const n="production"===r?"https://api.gerencianet.com.br/v1/pubkey":"https://sandbox.gerencianet.com.br/v1/pubkey",s=await fetch(`${n}?code=${e}`,{method:"GET"});s.ok||await s.json().then((e=>{i&&console.error("PublicKey",e);const r={codigo:void 0!==e.code?e.code:500,nome:void 0!==e.error?e.error:"request_error",mensagem:void 0!==e.error_description?e.error_description:"Falha ao capturar a chave pública no processo getPublicKey"};throw new t(r)}));const o=await s.json(),a=(new Date).setSeconds(55);return document.cookie=`${encodeURIComponent("expireAt")}=${encodeURIComponent(a)}; max-age=60; expires=${new Date(Date.now()+60).toUTCString()}; path=/; SameSite=Strict; Secure`,document.cookie=`${encodeURIComponent("publicKey")}=${encodeURIComponent(o.data)}; max-age=60; expires=${new Date(Date.now()+60).toUTCString()}; path=/; SameSite=Strict; Secure`,o.data}}var s=r(370),o=r.n(s);class a{static async encryptCardData(e,r,i,n=!1){try{e.salt=r,n&&console.info("creditCard",e);const t=JSON.stringify(e),s=new(o());return await s.setPublicKey(i),await s.encrypt(t)}catch(e){throw n&&console.error(e),new t(e={codigo:500,nome:"encrypt_error",mensagem:"Erro ao criptografar os dados do cartão"})}}}class h{static async getPaymentToken(e,r,i,n=!1){const s="production"===i?"https://tokenizer.gerencianet.com.br/card":"https://sandbox.gerencianet.com.br/v1/card",o=await fetch(s,{method:"POST",headers:{"Account-code":e,"Content-Type":"application/json; charset=UTF-8"},body:JSON.stringify({data:r})});return o.ok||await o.json().then((e=>{n&&console.error("SaveCardData",e);const r={codigo:void 0!==e.code?e.code:500,nome:void 0!==e.error?e.error:"request_error",mensagem:void 0!==e.error_description?e.error_description:"Falha ao capturar paymentToken no processo getPaymentToken"};throw new t(r)})),(await o.json()).data}}class u{static async getInstallments(e,r,i,n,s=!1){const o="production"===n?"https://api.gerencianet.com.br/v1/installments":"https://sandbox.gerencianet.com.br/v1/installments",a=await fetch(`${o}/${e}/jsonp?brand=${r}&total=${i}`,{method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}});return(await a.json().then((e=>{if(200!==e.code){s&&console.error("Installment request",e);const r={codigo:void 0!==e.code?e.code:500,nome:void 0!==e.error?e.error:"request_error",mensagem:void 0!==e.error_description?e.error_description:"Falha ao capturar payment_token no processo SaveCardData"};throw new t(r)}return e}))).data}}class c{static async getBrand(t){const e=/^4[0-9]{0,15}$/,r=/^5[1-5][0-9]{0,14}$/,i=/^6(?:011|5[0-9]{2})[0-9]{0,12}$/,n=/^3[47][0-9]{0,13}$/,s=/^(606282\d{10}(\d{3})?)|(3841\d{15})$/,o=/^3(?:0[0-5]|[68][0-9])[0-9]{0,11}$/,a=/^6(?:011|5[0-9]{2})[0-9]{0,12}$/,h=/^2(?:014|149)[0-9]{0,11}$/,u=/^(?:2131|1800|35\d{3})\d{0,11}$/,c=/^8699[0-9]{0,11}$/,l=/^50[0-9]{0,17}$/,f=t.replace(/\D/g,"");let p="";switch(!0){case e.test(f):p="visa";break;case r.test(f):p="mastercard";break;case i.test(f):p="elo";break;case n.test(f):p="amex";break;case s.test(f):p="hipercard";break;case o.test(f):case a.test(f):case h.test(f):case u.test(f):case c.test(f):case l.test(f):p="unsupported";break;default:p="undefined"}return p}}class l{static accountIdentifier(e){if(!/^[a-zA-Z0-9]{32}$/i.test(e))throw new t({nome:"valor_invalido",mensagem:`Identificador de conta "${e}" inválido`,codigo:400});return e}static environment(e){const r=["production","homologation"],i=e.toLowerCase();if(!r.includes(i)){const e={nome:"valor_invalido",mensagem:`Escolha um ambiente de integração entre "${r.join('" e "')}"`,codigo:400};throw new t(e)}return i}static creditCard(t){const{brand:e,number:r,cvv:i,expirationMonth:n,expirationYear:s,reuse:o}=t;return{brand:this.brand(e,r),number:this.cardNumber(r),cvv:this.cardCvv(i),expiration_month:this.expirationMonth(n),expiration_year:this.expirationYear(s,n),reuse:this.reusable(o)}}static brand(e){const r=["visa","mastercard","amex","elo","hipercard"],i=e.toLowerCase();if(!r.includes(i)){const e={nome:"valor_invalido",mensagem:`Escolha uma bandeira entre "${r.join('", "')}"`,codigo:400};throw new t(e)}return i}static total(e){if("string"==typeof e&&(e=parseInt(e.replace(/\D/g,""),10),isNaN(e)))throw new t({nome:"valor_invalido",mensagem:"O valor total deve ser um número",codigo:400});if(e<300)throw new t({nome:"valor_invalido",mensagem:`O valor ${e} é inferior ao limite mínimo (R$3,00)`,codigo:400});return e}static cardNumber(e){const r=e.replace(/\D/g,"");if(!/^\d{16}$/.test(r))throw new t({nome:"valor_invalido",mensagem:`Número do cartão "${e}" inválido`,codigo:400});return r}static cardCvv(e){if(!/^[0-9]+$/.test(e)||3!==e.length)throw new t({nome:"valor_invalido",mensagem:`Número CVV do cartão "${e}" inválido`,codigo:400});return e}static expirationMonth(e){const r=parseInt(e);if(r<1||r>12||!/^\d{2}$/.test(e))throw new t({nome:"valor_invalido",mensagem:`Mês de validade do cartão "${e}" inválido`,codigo:400});return r}static expirationYear(e,r){const i=(new Date).getFullYear(),n=(new Date).getMonth()+1,s=parseInt(e,10);if(isNaN(s)||si+10)throw new t({nome:"valor_invalido",mensagem:`Ano de validade do cartão "${e}" inválido`,codigo:400});if(s===i&&r<=n)throw new t({nome:"valor_invalido",mensagem:`Data de validade do cartão "${r}/${e}" expirada`,codigo:400});return s}static reusable(e=!1){if("boolean"!=typeof e&&!["true","false"].includes(e.toString()))throw new t({nome:"valor_invalido",mensagem:'O parâmetro "reuse" deve ser um booleano ou uma string "true" ou "false"',codigo:400});return e}static debugger(t){return"boolean"==typeof t||["true","false"].includes(t.toString())||(t=!1),t}}class f{static accountIdentifier;static environment;static creditCard;static brand;static total;static cardNumber;static salt;static publicKey;static debugger(t){try{return this.debug=l.debugger(t),this.debug&&console.info("Debugger ativo."),this}catch(t){this.debug=!1}}static setAccount(e){try{return this.accountIdentifier=l.accountIdentifier(e),this}catch(e){throw this.debug&&console.error(e),new t(e)}}static setEnvironment(e){try{return this.environment=l.environment(e),this}catch(e){throw this.debug&&console.error(e),new t(e)}}static setCreditCardData(e){try{return this.creditCard=l.creditCard(e),this}catch(e){throw this.debug&&console.error(e),new t(e)}}static setBrand(e){try{return this.brand=l.brand(e),this}catch(e){throw this.debug&&console.error(e),new t(e)}}static setTotal(e){try{return this.total=l.total(e),this}catch(e){throw this.debug&&console.error(e),new t(e)}}static setCardNumber(t){return this.cardNumber=t,this}static async getPaymentToken(){const r=new Date;if(document.cookie.split(";").some((t=>t.trim().startsWith("expireAt=")))){const t=document.cookie.replace(/(?:(?:^|.*;\s*)expireAt\s*\=\s*([^;]*).*$)|^.*$/,"$1");if(r.setSeconds(1)").html(".colored-toast .swal2-title {color: white;}.colored-toast .swal2-close {color: white;}.colored-toast .swal2-html-container {color: white;}.colored-toast.swal2-icon-error {background-color: #f27474 !important;}") - $("#payment").after(swalCss); + if(!document.getElementById('swalCss')){ + let swalCss = $( "" ).html( ".colored-toast .swal2-title {color: white;}.colored-toast .swal2-close {color: white;}.colored-toast .swal2-html-container {color: white;}.colored-toast.swal2-icon-error {background-color: #f27474 !important;}" ) + $( "#payment" ).after( swalCss ); + } if (document.getElementById("gn_boleto_cpf_cnpj")) { $('#gn_boleto_cpf_cnpj').keyup( diff --git a/assets/js/scripts-cartao.js b/assets/js/scripts-cartao.js old mode 100644 new mode 100755 index d680731..97321fe --- a/assets/js/scripts-cartao.js +++ b/assets/js/scripts-cartao.js @@ -1,337 +1,345 @@ -jQuery( document ).ready(function ($) { - - function detectCardType(number) { - let cards = { - visa: /^4[0-9]{12}(?:[0-9]{3})?$/, - mastercard: /^5[1-5][0-9]{14}$/, - amex: /^3[47][0-9]{13}$/, - elo: /^((((636368)|(438935)|(504175)|(451416)|(636297))\d{0,10})|((5067)|(4576)|(4011))\d{0,12})/, - hipercard: /^(606282\d{10}(\d{3})?)|(3841\d{15})/ - } - - for (let key in cards) { - if (cards[key].test(number)) { - return key - } - } - Swal.fire( - 'Bandeira do cartão não aceita', - 'Por favor, tente novamente com outro cartão.
Bandeiras aceitas: Visa, Mastercard, Amex, Elo, Hipercard', - 'info' - ) - return 0; +jQuery(document).ready(function ($) { + + if(!document.getElementById('swalCss')){ + let swalCss = $("").html(".colored-toast .swal2-title {color: white;}.colored-toast .swal2-close {color: white;}.colored-toast .swal2-html-container {color: white;}.colored-toast.swal2-icon-error {background-color: #f27474 !important;}") + $("#payment").after(swalCss); } - - $gn.ready(function (checkout) { - - // Gerar Payment Token - jQuery("#gn_cartao_expiration").on('keyup', function () { - let cardNumber = jQuery("#gn_cartao_number").val().replace(/\s/g, ''); - let cardCvv = jQuery("#gn_cartao_cvv").val(); - let cardExpiration = jQuery("#gn_cartao_expiration").val().split("/"); - - if (jQuery("#gn_cartao_expiration").val().length >= 7) { - - Swal.fire({ - title: 'Por favor, aguarde...', - text: '', - showConfirmButton: false, - }) - - let brand = detectCardType(cardNumber); - - if (brand != 0) { - let params = { - brand: brand, // bandeira do cartão - number: cardNumber, // número do cartão - cvv: cardCvv, // código de segurança - expiration_month: cardExpiration[0], // mês de vencimento - expiration_year: cardExpiration[1] // ano de vencimento - } - checkout.getPaymentToken(params, - function (error, response) { - if (error) { - // Trata o erro ocorrido - console.error(error); - Swal.fire( - 'Ocorreu um erro', - 'Houve uma falha ao gerar o Token do seu cartão. Por favor, entre em contato com o administrador da loja.', - 'error' - ) - } else { + + + + // Gerar Payment Token + jQuery("#gn_cartao_expiration").on('keyup', function () { + let cardExpiration = jQuery("#gn_cartao_expiration").val().split("/"); + + if (jQuery("#gn_cartao_expiration").val().length >= 7) { + + Swal.fire({ + title: 'Por favor, aguarde...', + text: '', + showConfirmButton: false, + }) + + EfiJs.CreditCard + // .debugger(true) + .setCardNumber(jQuery("#gn_cartao_number").val()) + .verifyCardBrand() + .then(brand => { + if (brand !== 'undefined') { + EfiJs.CreditCard + //.debugger(true) + .setAccount(options.payeeCode) + .setEnvironment(options.enviroment) // 'production' or 'homologation' + .setCreditCardData({ + brand: brand, + number: jQuery("#gn_cartao_number").val(), + cvv: jQuery("#gn_cartao_cvv").val(), + expirationMonth: cardExpiration[0], + expirationYear: cardExpiration[1] + }) + .getPaymentToken() + .then(data => { // Trata a resposta - jQuery('#gn_payment_token').val(response.data.payment_token); + jQuery('#gn_payment_token').val(data.payment_token); swal.close() - } - } - ); - } - } - - - }); - - - jQuery("#gn_cartao_number").keyup(function () { - - let total = document.querySelector("#order_review > table > tfoot > tr.order-total > td > strong > span > bdi").innerHTML.replace('R$', '').replaceAll(',', '').replaceAll('.', '').replaceAll(' ', ''); - console.log(total); - let cardNumber = jQuery("#gn_cartao_number").val().replace(/\s/g, ''); - if (cardNumber.length >= 16) { - - let brand = detectCardType(cardNumber); - - if (brand != 0) { - checkout.getInstallments( - parseInt(total), // valor total da cobrança - brand, // bandeira do cartão - function (error, response) { - if (error) { - // Trata o erro ocorrido - console.log(error); - Swal.fire( - 'Ocorreu um erro', - 'Houve um erro ao recuperar o número de parcelas. Por favor, entre em contato com o administrador da loja.', - 'error' - ) - } else { - // Trata a respostae + }).catch(err => { + swalError(err); + throw new Error(`Something went wrong in getPaymentToken(.\n ${err}`); + }); + } + }).catch(err => { + swalError(err); + throw new Error(`Something went wrong in verifyCardBrand(.\n ${err}`); + }); + } + + }); + + + // Buscar Parcelas + jQuery("#gn_cartao_number").keyup(function () { + + let total = document.querySelector("#order_review > table > tfoot > tr.order-total > td > strong > span > bdi").innerHTML.replace('R$', '').replaceAll(',', '').replaceAll('.', '').replaceAll(' ', ''); + console.log(total); + + if (jQuery("#gn_cartao_number").val().length >= 19) { + + EfiJs.CreditCard + // .debugger(true) + .setCardNumber(jQuery("#gn_cartao_number").val()) + .verifyCardBrand() + .then(brand => { + if (brand !== 'undefined') { + EfiJs.CreditCard + //.debugger(true) + .setAccount(options.payeeCode) + .setEnvironment(options.enviroment) // 'production' or 'homologation' + .setBrand(brand) + .setTotal(total) + .getInstallments() + .then(response => { jQuery('#gn_cartao_no_installments').hide(); - jQuery('#gn_cartao_installments') .find('option') .remove() - - response.data.installments.forEach(element => { + + response.installments.forEach(element => { jQuery('#gn_cartao_installments').append(jQuery('