>8*l-u&255;if(0!==(h.charCodeAt(0)&d))throw new Error("Bits beyond keysize not zero as expected.");var y=r.generate(f,p),g="";for(c=0;c2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(d.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=d[0],c.validity.notAfter=d[1],c.tbsCertificate=r.tbsCertificate,t){if(c.md=null,c.signatureOid in h){var o=h[c.signatureOid];switch(o){case"sha1WithRSAEncryption":c.md=u.md.sha1.create();break;case"md5WithRSAEncryption":c.md=u.md.md5.create();break;case"sha256WithRSAEncryption":c.md=u.md.sha256.create();break;case"sha512WithRSAEncryption":c.md=u.md.sha512.create();break;case"RSASSA-PSS":c.md=u.md.sha256.create()}}if(null===c.md){var s=new Error("Could not compute certificate digest. Unknown signature OID.");
throw s.signatureOid=c.signatureOid,s}var g=l.toDer(c.tbsCertificate);c.md.update(g.getBytes())}var v=u.md.sha1.create();c.issuer.getField=function(e){return a(c.issuer,e)},c.issuer.addField=function(e){i([e]),c.issuer.attributes.push(e)},c.issuer.attributes=p.RDNAttributesAsArray(r.certIssuer,v),r.certIssuerUniqueId&&(c.issuer.uniqueId=r.certIssuerUniqueId),c.issuer.hash=v.digest().toHex();var m=u.md.sha1.create();return c.subject.getField=function(e){return a(c.subject,e)},c.subject.addField=function(e){i([e]),c.subject.attributes.push(e)},c.subject.attributes=p.RDNAttributesAsArray(r.certSubject,m),r.certSubjectUniqueId&&(c.subject.uniqueId=r.certSubjectUniqueId),c.subject.hash=m.digest().toHex(),r.certExtensions?c.extensions=p.certificateExtensionsFromAsn1(r.certExtensions):c.extensions=[],c.publicKey=p.publicKeyFromAsn1(r.subjectPublicKeyInfo),c},p.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r1&&(a=r.value.charCodeAt(1),n=r.value.length>2?r.value.charCodeAt(2):0),t.digitalSignature=128===(128&a),t.nonRepudiation=64===(64&a),t.keyEncipherment=32===(32&a),t.dataEncipherment=16===(16&a),t.keyAgreement=8===(8&a),t.keyCertSign=4===(4&a),t.cRLSign=2===(2&a),t.encipherOnly=1===(1&a),t.decipherOnly=128===(128&n)}else if("basicConstraints"===t.name){var r=l.fromDer(t.value);r.value.length>0&&r.value[0].type===l.Type.BOOLEAN?t.cA=0!==r.value[0].value.charCodeAt(0):t.cA=!1;var i=null;r.value.length>0&&r.value[0].type===l.Type.INTEGER?i=r.value[0].value:r.value.length>1&&(i=r.value[1].value),null!==i&&(t.pathLenConstraint=l.derToInteger(i))}else if("extKeyUsage"===t.name)for(var r=l.fromDer(t.value),s=0;s1&&(a=r.value.charCodeAt(1)),t.client=128===(128&a),t.server=64===(64&a),t.email=32===(32&a),t.objsign=16===(16&a),t.reserved=8===(8&a),t.sslCA=4===(4&a),t.emailCA=2===(2&a),t.objCA=1===(1&a)}else if("subjectAltName"===t.name||"issuerAltName"===t.name){t.altNames=[];for(var c,r=l.fromDer(t.value),p=0;p0&&t.value.push(p.certificateExtensionsToAsn1(e.extensions)),t},p.getCertificationRequestInfo=function(e){var t=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(e.version).getBytes()),n(e.subject),p.publicKeyToAsn1(e.publicKey),c(e)]);return t},p.distinguishedNameToAsn1=function(e){return n(e)},p.certificateToAsn1=function(e){var t=e.tbsCertificate||p.getTBSCertificate(e);return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[t,l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(e.signatureOid).getBytes()),o(e.signatureOid,e.signatureParameters)]),l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},p.certificateExtensionsToAsn1=function(e){var t=l.create(l.Class.CONTEXT_SPECIFIC,3,!0,[]),r=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);t.value.push(r);for(var a=0;ac.validity.notAfter)&&(s={message:"Certificate is not valid yet or has expired.",error:p.certificateError.certificate_expired,notBefore:c.validity.notBefore,notAfter:c.validity.notAfter,now:n}),null===s){if(l=t[0]||e.getIssuer(c),null===l&&c.isIssuer(c)&&(h=!0,l=c),l){var f=l;u.util.isArray(f)||(f=[f]);for(var d=!1;!d&&f.length>0;){l=f.shift();try{d=l.verify(c)}catch(e){}}d||(s={message:"Certificate signature is invalid.",error:p.certificateError.bad_certificate})}null!==s||l&&!h||e.hasCertificate(c)||(s={message:"Certificate is not trusted.",error:p.certificateError.unknown_ca})}if(null===s&&l&&!c.isIssuer(l)&&(s={message:"Certificate issuer is invalid.",error:p.certificateError.bad_certificate}),null===s)for(var y={keyUsage:!0,basicConstraints:!0},g=0;null===s&&gm.pathLenConstraint&&(s={message:"Certificate basicConstraints pathLenConstraint violated.",error:p.certificateError.bad_certificate})}}var S=null===s||s.error,T=r?r(S,o,a):S;if(T!==!0)throw S===!0&&(s={message:"The application rejected the certificate.",error:p.certificateError.bad_certificate}),(T||0===T)&&("object"!=typeof T||u.util.isArray(T)?"string"==typeof T&&(s.error=T):(T.message&&(s.message=T.message),T.error&&(s.error=T.error))),s;s=null,i=!1,++o}while(t.length>0);return!0}},function(e,t,r){function a(e){if("string"==typeof e&&(e=s.util.createBuffer(e)),s.util.isArray(e)&&e.length>4){var t=e;e=s.util.createBuffer();for(var r=0;r0))return!0;for(var a=0;a0))return!0;for(var a=0;a0)return!1;var r=e.length(),a=e.at(r-1);return!(a>this.blockSize<<2)&&(e.truncate(a),!0)},o.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},o.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=a(e.iv),this._prev=this._iv.slice(0)}},o.cbc.prototype.encrypt=function(e,t,r){if(e.length()0))return!0;for(var a=0;a0))return!0;for(var a=0;a0)return!1;var r=e.length(),a=e.at(r-1);return!(a>this.blockSize<<2)&&(e.truncate(a),!0)},o.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0},o.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=a(e.iv),this._inBlock=this._iv.slice(0),this._partialBytes=0},o.cfb.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n0)e.read-=this.blockSize;else for(var n=0;n0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}},o.cfb.prototype.decrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n0)e.read-=this.blockSize;else for(var n=0;n0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}},o.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0},o.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=a(e.iv),this._inBlock=this._iv.slice(0),this._partialBytes=0},o.ofb.prototype.encrypt=function(e,t,r){var a=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n0)e.read-=this.blockSize;else for(var n=0;n0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}},o.ofb.prototype.decrypt=o.ofb.prototype.encrypt,o.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0},o.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=a(e.iv),this._inBlock=this._iv.slice(0),this._partialBytes=0},o.ctr.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}n(this._inBlock)},o.ctr.prototype.decrypt=o.ctr.prototype.encrypt,o.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0,this._R=3774873600},o.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t=s.util.createBuffer(e.iv);this._cipherLength=0;var r;if(r="additionalData"in e?s.util.createBuffer(e.additionalData):s.util.createBuffer(),"tagLength"in e?this._tagLength=e.tagLength:this._tagLength=128,this._tag=null,e.decrypt&&(this._tag=s.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var a=t.length();if(12===a)this._j0=[t.getInt32(),t.getInt32(),t.getInt32(),1];else{for(this._j0=[0,0,0,0];t.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(i(8*a)))}this._inBlock=this._j0.slice(0),n(this._inBlock),this._partialBytes=0,r=s.util.createBuffer(r),this._aDataLength=i(8*r.length());var o=r.length()%this.blockSize;for(o&&r.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];r.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()])},o.gcm.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize){for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),n(this._inBlock)},o.gcm.prototype.decrypt=function(e,t,r){var a=e.length();if(a0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),n(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i0;--a)t[a]=e[a]>>>1|(1&e[a-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},o.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var a=r/8|0,n=e[a]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},o.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},o.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,a=4*r,n=16*r,i=new Array(n),s=0;s>>1,n=new Array(r);n[a]=e.slice(0);for(var i=a>>>1;i>0;)this.pow(n[2*i],n[i]=[]),i>>=1;for(i=2;i=0;c--)R>>=8,R+=b.at(c)+k.at(c),k.setAt(c,255&R);N.putBuffer(k)}E=N,p.putBuffer(I)}return p.truncate(p.length()-n),p},l.pbe.getCipher=function(e,t,r){switch(e){case l.oids.pkcs5PBES2:return l.pbe.getCipherForPBES2(e,t,r);case l.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case l.oids["pbewithSHAAnd40BitRC2-CBC"]:return l.pbe.getCipherForPKCS12PBE(e,t,r);default:var a=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw a.oid=e,a.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],a}},l.pbe.getCipherForPBES2=function(e,t,r){var a={},i=[];if(!u.validate(t,f,a,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}if(e=u.derToOid(a.kdfOid),e!==l.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=e,s.supportedOids=["pkcs5PBKDF2"],s}if(e=u.derToOid(a.encOid),e!==l.oids["aes128-CBC"]&&e!==l.oids["aes192-CBC"]&&e!==l.oids["aes256-CBC"]&&e!==l.oids["des-EDE3-CBC"]&&e!==l.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=e,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var c=a.kdfSalt,p=o.util.createBuffer(a.kdfIterationCount);p=p.getInt(p.length()<<3);var h,d;switch(l.oids[e]){case"aes128-CBC":h=16,d=o.aes.createDecryptionCipher;break;case"aes192-CBC":h=24,d=o.aes.createDecryptionCipher;break;case"aes256-CBC":h=32,d=o.aes.createDecryptionCipher;break;case"des-EDE3-CBC":h=24,d=o.des.createDecryptionCipher;break;case"desCBC":h=8,d=o.des.createDecryptionCipher}var y=n(a.prfOid),g=o.pkcs5.pbkdf2(r,c,p,h,y),v=a.encIv,m=d(g);return m.start(v),m},l.pbe.getCipherForPKCS12PBE=function(e,t,r){var a={},i=[];if(!u.validate(t,d,a,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var c=o.util.createBuffer(a.salt),p=o.util.createBuffer(a.iterations);p=p.getInt(p.length()<<3);var h,f,y;switch(e){case l.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:h=24,f=8,y=o.des.startDecrypting;break;case l.oids["pbewithSHAAnd40BitRC2-CBC"]:h=5,f=8,y=function(e,t){var r=o.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=e,s}var g=n(a.prfOid),v=l.pbe.generatePkcs12Key(r,c,1,p,h,g);g.start();var m=l.pbe.generatePkcs12Key(r,c,2,p,f,g);return y(v,m)},l.pbe.opensslDeriveBytes=function(e,t,r,n){if("undefined"==typeof n||null===n){if(!("md5"in o.md))throw new Error('"md5" hash algorithm unavailable.');n=o.md.md5.create()}null===t&&(t="");for(var i=[a(n,e+t)],s=16,c=1;s>24&255,s>>16&255,s>>8&255,255&s);r.start(),r.update(e+o),a+=r.digest().getBytes()}return a.substring(0,t)}var n=r(0);r(1),r(2),r(9);var i=e.exports=n.pkcs1=n.pkcs1||{};i.encode_rsa_oaep=function(e,t,r){var i,s,o,c;"string"==typeof r?(i=r,s=arguments[3]||void 0,o=arguments[4]||void 0):r&&(i=r.label||void 0,s=r.seed||void 0,o=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),o?o.start():o=n.md.sha1.create(),c||(c=o);var u=Math.ceil(e.n.bitLength()/8),l=u-2*o.digestLength-2;if(t.length>l){var p=new Error("RSAES-OAEP input message length is too long.");throw p.length=t.length,p.maxLength=l,p}i||(i=""),o.update(i,"raw");for(var h=o.digest(),f="",d=l-t.length,y=0;y=0&&n.push(o):n.push(o))}return n}function n(e){if(e.composed||e.constructed){for(var t=u.util.createBuffer(),r=0;r0&&(n=l.create(l.Class.UNIVERSAL,l.Type.SET,!0,c));var f=[],d=[];null!==t&&(d=u.util.isArray(t)?t:[t]);for(var y=[],g=0;g0){var E=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,y),S=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(p.oids.data).getBytes()),l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,l.toDer(E).getBytes())])]);f.push(S)}var T=null;if(null!==e){var I=p.wrapRsaPrivateKey(p.privateKeyToAsn1(e));T=null===r?l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(p.oids.keyBag).getBytes()),l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[I]),n]):l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(p.oids.pkcs8ShroudedKeyBag).getBytes()),l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[p.encryptPrivateKeyInfo(I,r,a)]),n]);var A=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[T]),b=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(p.oids.data).getBytes()),l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,l.toDer(A).getBytes())])]);f.push(b)}var B,N=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,f);if(a.useMac){var o=u.md.sha1.create(),k=new u.util.ByteBuffer(u.random.getBytes(a.saltSize)),R=a.count,e=h.generateKey(r,k,3,R,20),w=u.hmac.create();w.start(o,e),w.update(l.toDer(N).getBytes());var L=w.getMac();B=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(p.oids.sha1).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")]),l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,L.getBytes())]),l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,k.getBytes()),l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(R).getBytes())])}return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(3).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(p.oids.data).getBytes()),l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,l.toDer(N).getBytes())])]),B])},h.generateKey=u.pbe.generatePkcs12Key},function(e,t,r){var a=r(0);r(3),r(1);var n=a.asn1,i=e.exports=a.pkcs7asn1=a.pkcs7asn1||{};a.pkcs7=a.pkcs7||{},a.pkcs7.asn1=i;var s={name:"ContentInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};i.contentInfoValidator=s;var o={name:"EncryptedContentInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:n.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};i.envelopedDataValidator={name:"EnvelopedData",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:n.Class.UNIVERSAL,type:n.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(o)},i.encryptedDataValidator={name:"EncryptedData",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"}].concat(o)};var c={name:"SignerInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:n.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:n.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};i.signedDataValidator={name:"SignedData",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:n.Class.UNIVERSAL,type:n.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},s,{name:"SignedData.Certificates",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:n.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:n.Class.UNIVERSAL,type:n.Type.SET,capture:"signerInfos",optional:!0,value:[c]}]},i.recipientInfoValidator={name:"RecipientInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:n.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}},function(e,t,r){var a=r(0);r(3),r(6),r(22),r(7),r(15),r(24),r(16),r(11),r(1),r(17);var n=a.asn1,i=e.exports=a.pki=a.pki||{};i.pemToDer=function(e){var t=a.pem.decode(e)[0];if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert PEM to DER; PEM is encrypted.");return a.util.createBuffer(t.body)},i.privateKeyFromPem=function(e){var t=a.pem.decode(e)[0];if("PRIVATE KEY"!==t.type&&"RSA PRIVATE KEY"!==t.type){var r=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert private key from PEM; PEM is encrypted.");var s=n.fromDer(t.body);return i.privateKeyFromAsn1(s)},i.privateKeyToPem=function(e,t){var r={type:"RSA PRIVATE KEY",body:n.toDer(i.privateKeyToAsn1(e)).getBytes()};return a.pem.encode(r,{maxline:t})},i.privateKeyInfoToPem=function(e,t){var r={type:"PRIVATE KEY",body:n.toDer(e).getBytes()};return a.pem.encode(r,{maxline:t})}},function(e,t,r){var a=r(0);r(1),r(13),r(2),function(){function t(e,t,a,n){return"workers"in a?i(e,t,a,n):r(e,t,a,n)}function r(e,t,r,a){var i=s(e,t),c=0,u=o(i.bitLength());"millerRabinTests"in r&&(u=r.millerRabinTests);var l=10;
"maxBlockTime"in r&&(l=r.maxBlockTime),n(i,e,t,c,u,l,a)}function n(e,t,r,i,o,c,u){var p=+new Date;do{if(e.bitLength()>t&&(e=s(t,r)),e.isProbablePrime(o))return u(null,e);e.dAddOffset(l[i++%8],0)}while(c<0||+new Date-pe&&(c=s(e,t));var f=c.toString(16);r.target.postMessage({hex:f,workLoad:p}),c.dAddOffset(h,0)}}l=Math.max(1,l);for(var a=[],n=0;n=32)return i(),e();var t=32-o.pools[0].messageLength<<5;o.seedFile(t,function(t,r){return t?e(t):(o.collect(r),i(),void e())})}function r(){if(o.pools[0].messageLength>=32)return i();var e=32-o.pools[0].messageLength<<5;o.collect(o.seedFileSync(e)),i()}function i(){var e=o.plugin.md.create();e.update(o.pools[0].digest().getBytes()),o.pools[0].start();for(var t=1,r=1;r<32;++r)t=31===t?2147483648:t<<2,t%o.reseeds===0&&(e.update(o.pools[r].digest().getBytes()),o.pools[r].start());var a=e.digest().getBytes();e.start(),e.update(a);var n=e.digest().getBytes();o.key=o.plugin.formatKey(a),o.seed=o.plugin.formatSeed(n),o.reseeds=4294967295===o.reseeds?0:o.reseeds+1,o.generated=0}function s(e){var t=null;if("undefined"!=typeof window){var r=window.crypto||window.msCrypto;r&&r.getRandomValues&&(t=function(e){return r.getRandomValues(e)})}var n=a.util.createBuffer();if(t)for(;n.length()>16),u+=(32767&c)<<16,u+=c>>15,u=(2147483647&u)+(u>>31),p=4294967295&u;for(var o=0;o<3;++o)l=p>>>(o<<3),l^=Math.floor(256*Math.random()),n.putByte(String.fromCharCode(255&l))}return n.getBytes(e)}for(var o={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0},c=e.md,u=new Array(32),l=0;l<32;++l)u[l]=c.create();return o.pools=u,o.pool=0,o.generate=function(e,r){function n(p){if(p)return r(p);if(l.length()>=e)return r(null,l.getBytes(e));if(o.generated>1048575&&(o.key=null),null===o.key)return a.util.nextTick(function(){t(n)});var h=i(o.key,o.seed);o.generated+=h.length,l.putBytes(h),o.key=c(i(o.key,s(o.seed))),o.seed=u(i(o.key,o.seed)),a.util.setImmediate(n)}if(!r)return o.generateSync(e);var i=o.plugin.cipher,s=o.plugin.increment,c=o.plugin.formatKey,u=o.plugin.formatSeed,l=a.util.createBuffer();o.key=null,n()},o.generateSync=function(e){var t=o.plugin.cipher,n=o.plugin.increment,i=o.plugin.formatKey,s=o.plugin.formatSeed;o.key=null;for(var c=a.util.createBuffer();c.length()1048575&&(o.key=null),null===o.key&&r();var u=t(o.key,o.seed);o.generated+=u.length,c.putBytes(u),o.key=i(t(o.key,n(o.seed))),o.seed=s(t(o.key,o.seed))}return c.getBytes(e)},n?(o.seedFile=function(e,t){n.randomBytes(e,function(e,r){return e?t(e):void t(null,r.toString())})},o.seedFileSync=function(e){return n.randomBytes(e).toString()}):(o.seedFile=function(e,t){try{t(null,s(e))}catch(e){t(e)}},o.seedFileSync=s),o.collect=function(e){for(var t=e.length,r=0;r>a&255);o.collect(r)},o.registerWorker=function(e){if(e===self)o.seedFile=function(e,t){function r(e){var a=e.data;a.forge&&a.forge.prng&&(self.removeEventListener("message",r),t(a.forge.prng.err,a.forge.prng.bytes))}self.addEventListener("message",r),self.postMessage({forge:{prng:{needed:e}}})};else{var t=function(t){var r=t.data;r.forge&&r.forge.prng&&o.seedFile(r.forge.prng.needed,function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})})};e.addEventListener("message",t)}},o}},function(e,t,r){var a=r(0);r(1);var n=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],i=[1,2,3,5],s=function(e,t){return e<>16-t},o=function(e,t){return(65535&e)>>t|e<<16-t&65535};e.exports=a.rc2=a.rc2||{},a.rc2.expandKey=function(e,t){"string"==typeof e&&(e=a.util.createBuffer(e)),t=t||128;var r,i=e,s=e.length(),o=t,c=Math.ceil(o/8),u=255>>(7&o);for(r=s;r<128;r++)i.putByte(n[i.at(r-1)+i.at(r-s)&255]);for(i.setAt(128-c,n[i.at(128-c)&u]),r=127-c;r>=0;r--)i.setAt(r,n[i.at(r+1)^i.at(r+c)]);return i};var c=function(e,t,r){var n,c,u,l,p=!1,h=null,f=null,d=null,y=[];for(e=a.rc2.expandKey(e,t),u=0;u<64;u++)y.push(e.getInt16Le());r?(n=function(e){for(u=0;u<4;u++)e[u]+=y[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=s(e[u],i[u]),l++},c=function(e){for(u=0;u<4;u++)e[u]+=y[63&e[(u+3)%4]]}):(n=function(e){for(u=3;u>=0;u--)e[u]=o(e[u],i[u]),e[u]-=y[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),l--},c=function(e){for(u=3;u>=0;u--)e[u]-=y[63&e[(u+3)%4]]});var g=function(e){var t=[];for(u=0;u<4;u++){var a=h.getInt16Le();null!==d&&(r?a^=d.getInt16Le():d.putInt16Le(a)),t.push(65535&a)}l=r?0:63;for(var n=0;n=8;)g([[5,n],[1,c],[6,n],[1,c],[5,n]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,h,!r);else{var a=8===h.le
…[+224003 body chars; --range 200911: or --grep TEXT]
# 01a1da59-5caf-7ad6-a6eb-fc5a00c4ebc9 2026-11-14 13:57:31 curl/hunter-2 status=200 243ms
GET https://acc-gw-insign.baloise.de/insign-core-bundle.js?v35941
--- response (245705 B text/javascript;charset=UTF-8)
HTTP/1.1 200 OK
Date: Sat, 14 Nov 2026 13:57:31 GMT
Server: Apache
Set-Cookie: c716e68c1aecbbf4a6dcc9a52da1ab6e=$xc/nJYMUhgkkODsTLfN7ZjY8Xe8iFwsCSDV!mXAuyVkCijAfbPUwWNsdltIAr_j3Nz2m7CD2Q==; Path=/; Secure; HttpOnly; SameSite=None
Content-Length: 244794
permissions-policy: camera=(self), geolocation=(self), fullscreen=(self), sync-xhr=(self)
referrer-policy: no-referrer
x-content-type-options: nosniff
content-security-policy: frame-ancestors localhost
vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Accept-Encoding
cache-control: public, max-age=315360000
expires: Thu, 19 Aug 2027 14:05:06 GMT
last-modified: Wed, 19 Aug 2026 14:05:06 GMT
etag: "38e3242dcf19074f346bbd3928465203d9e03625"
x-xss-protection: 1; mode=block
cache-control: private
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=31536000
Content-Type: text/javascript;charset=UTF-8
(function(root,factory){'use strict';if(typeof define==='function'&&define.amd){define(['exports'],factory);}else if(typeof exports==='object'){factory(exports);}else{var INSIGNAPP={};root.INSIGNAPP=INSIGNAPP;factory(INSIGNAPP);}}((typeof window==='object'&&window)||this,function(INSIGNAPP){'use strict';return INSIGNAPP;}));
'use strict';var INSIGNAPP=INSIGNAPP||{};INSIGNAPP.config=(function(){var my={};my.escapeHTML=function(unsafeText){var ret=DOMPurify.sanitize(_.escape(unsafeText));return ret;};try{var ios7Test=navigator.userAgent.match(/7\_0([_0-9]*)/),timer=undefined,messageMap={},props={};my.messages=function(){var module={};module.get=function(msgReq,callback,noLog){var id=undefined;if(typeof msgReq==='string'){id=msgReq;}else if(msgReq&&msgReq.id){id=msgReq.id;}
if(!id){if(typeof callback==='function'){callback('');}
return'';}
var msg=messageMap[id];if(!msg&&id!=='message.empty'){if(!noLog){my.consoleLog("ERROR: failed to resolve message with id: "+id);}
msg=msgReq;}else if(msgReq.params){for(var i in msgReq.params){msg=msg.replace('{'+i+'}',msgReq.params[i]);}}
while(msg!==undefined&&msg.indexOf('${')!==-1){let replRegex=/\${(.*)}/;let toReplace=msg.match(replRegex);if(toReplace.length>1){let replacement=messageMap[toReplace[1]];if(replacement!==undefined){msg=msg.replaceAll(toReplace[0],replacement);}else{break;}}}
if(typeof callback==='function'){callback(msg);}
return msg;};module.has=function(msgId){return!!messageMap[msgId];};return module;}();my.setMessages=function setMessages(json){messageMap=json;};my.loadguiProperties=(function($){var module={};module.get=function get(a_prop){if(typeof a_prop==='undefined'){return props;}else{return props[a_prop];}};return module;});my.setProps=function setProps(a_props){props=a_props;};my.expirationTime=-1;my.expirationURL='clienterror';my.maxPagesToKeepLoaded=50;my.maxThumbsToKeepLoaded=50;my.sessionid='';my.fullName='';my.minPoints=5;my.tan='';my.processStep='';my.manifestError=false;my.isDebug=true;my.isEmbeddedMode=false;my.useAppForBerater=true;my.applosPerTouch=undefined;my.useApplosPerMailForBerater=false;my.useApplosPerSmsForBerater=false;my.useAppForKunde=true;my.useApplosPerMailForKunde=false;my.useApplosPerSmsForKunde=false;my.useApplosPerQRCodeForKunde=false;my.isUpadSupported=false;my.upadPorts=[56431,56437,56439];my.upadSSLPorts=[56231,56237,56239];my.upadServer=undefined;my.upadCommunicationURL=undefined;my.useUpad=false;my.geolocationPos={};my.smsVersandEnabledForSession=false;my.lifetime=150;my.isAushaendigenPflicht=false;my.isExternEnabled=true;my.roletype="owner";my.singleSignOnEnabled=false;my.fotoupload=false;my.fotouploadType="own";my.localStorage;my.dateiUploadOnly=false;my.maxOpenThumbConnections=15;my.maxOpenImageConnections=10;my.getThumbTimeout=30000;my.getImageTimeout=60000;my.maxParallelUploads=1;my.isApplos=false;my.upadFailDetectionCounter=0;my.upadDetectionCounter=0;my.upadDetectionInProgress=false;my.upadTimeout;my.appversion='';my.externSenddocsOnfinishCustomerMails='';my.saveInProgress=false;my.isForcedColorDark=matchMedia('(forced-colors: active)').matches;my.allowedExtensions=[];my.allowedImageExtensions=[];my.isTouchDevice='ontouchend'in document||'ontouchstart'in document.documentElement||'ontouchstart'in window||(typeof navigator.maxTouchPoints!=='undefined'&&navigator.maxTouchPoints>2&&navigator.maxTouchPoints!==256?true:false)||(typeof navigator.msMaxTouchPoints!=='undefined'&&navigator.msMaxTouchPoints>0?true:false)||(window.matchMedia&&window.matchMedia("(any-pointer:coarse)").matches);my.manualDeviceDetect=function(){var manual=false;if(storeManualDeviceDetect()===false){manual=true;}else{try
{let manualDevice=localStorage.getItem('manualDeviceDetect');if(manualDevice!=null){manual='true'==manualDevice;}}
catch(exp)
{}}
return manual;};my.manualTouchDevice=function(){var touch=false;if(storeManualDeviceDetect()===false){if(my.applosPerTouch===true){touch=true;}}else{let manualTouch=localStorage.getItem('manualTouchDevice');if(manualTouch!=null){touch='true'==manualTouch;}}
return touch;};my.isTouch=function(){if(my.manualDeviceDetect()){return my.manualTouchDevice();}else if(typeof isCrmTouchEnabled==="function"){return isCrmTouchEnabled();}else{return my.isTouchDevice;}};function unpairUpad(){if(INSIGNAPP&&INSIGNAPP.data&&INSIGNAPP.data.getPairedMobiles){INSIGNAPP.data.getPairedMobiles(INSIGNAPP.config.sessionid,function(mobileObj){for(var i=0;i0;}
function iOSversion(){if(/iP(hone|od|ad)/.test(navigator.platform)){var v=(navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(v[1],10),parseInt(v[2],10),parseInt(v[3]||0,10)];}}
my.isMobile={Android:matchUserAgent(/Android/i),BlackBerry:matchUserAgent(/BlackBerry/i),BB10:matchUserAgent(/BB10/i),Convertible:('ontouchstart'in window)||(navigator.maxTouchPoints>0)||(navigator.msMaxTouchPoints>0),iOS:(true===matchUserAgent(/iPhone|iPad|iPod/i)||(navigator.platform==='MacIntel'&&typeof window.orientation!='undefined'))&&false===matchUserAgent(/Windows Phone/i),iPhone:matchUserAgent(/iPhone|iPod/i),iPad:matchUserAgent(/iPad/i)||(navigator.platform==='MacIntel'&&typeof window.orientation!='undefined'),Opera:matchUserAgent(/Opera Mini/i),Windows:matchUserAgent(/IEMobile/i)||matchUserAgent(/Windows Phone/i)||matchUserAgent(/Microsoft Office Mobile/i),SamsungBrowser:matchUserAgent(/SamsungBrowser/i),any:false};my.isMobile.any=my.isMobile.Android||my.isMobile.BlackBerry||my.isMobile.BB10||my.isMobile.iOS||my.isMobile.Opera||my.isMobile.Windows||my.isMobile.SamsungBrowser;my.isMobile.iOS9=my.isMobile.iOS&&(navigator.userAgent.match(/OS 9_[0-9_]+ like Mac OS X/i)!==null);my.isMobile.iOS7=my.isMobile.iOS&&ios7Test!=null&&ios7Test.length>0&&(ios7Test[1]==""||ios7Test[1].charAt(1)<="4");my.isMobile.iOS5=my.isMobile.iOS&&(navigator.userAgent.match(/OS 5_[0-9_]+ like Mac OS X/i)!==null);my.isMobile.iOS13=(my.isMobile.iOS&&iOSversion()&&iOSversion()[0]===13)||(my.isMobile.iOS&&matchUserAgent(/Version\/13/i));my.isMobile.firefoxMobile=my.isMobile.any&&matchUserAgent(/Mozilla/i);my.hasWebcam=false;my.videoDevices=[];my.unpairUpad=unpairUpad;try{if(navigator&&navigator.mediaDevices&&typeof navigator.mediaDevices.enumerateDevices==="function"){navigator.mediaDevices.enumerateDevices().then(function(devices){for(var i=0;i-1){return true;}else{return false;}}
my.isPrivate=function(){var db=void 0,on=function(){return true;},off=function(){return false;},tryls=function(){try{return localStorage.length?off():(localStorage.x=1,localStorage.removeItem("x"),off());}catch(e){return on();}};if(window.webkitRequestFileSystem){webkitRequestFileSystem(window.TEMPORARY,1,off,on);}else if("MozAppearance"in document.documentElement.style){return(db=indexedDB.open("test"),db.onerror=on,db.onsuccess=off);}else if(/constructor/i.test(window.HTMLElement)){return tryls();}else if(!window.indexedDB&&(window.PointerEvent||window.MSPointerEvent)){return on();}else{return off();}};function LocalStorageAlternative(){var structureLocalStorage={};this.setItem=function(key,value){structureLocalStorage[key]=value;};this.getItem=function(key){if(typeof structureLocalStorage[key]!='undefined'){return structureLocalStorage[key];}else{return null;}};this.removeItem=function(key){structureLocalStorage[key]=undefined;};}
function gotLocation(location){my.geolocationPos={accuracy:location.coords.accuracy,altitude:location.coords.altitude,altitudeAccuracy:location.coords.altitudeAccuracy,heading:location.coords.heading,latitude:location.coords.latitude,longitude:location.coords.longitude,speed:location.coords.speed};}
var locationOptions={timeout:5000,maximumAge:0};my.dsgvoAbfrageActive=function(){return INSIGNAPP.config.dsgvoAbfrage&&(!INSIGNAPP.config.dsgvoTargetMobile||my.isTouch());}
my.init=function(insignroot){if(!String.prototype.endsWith){String.prototype.endsWith=function(searchString,position){var subjectString=this.toString();if(typeof position!=='number'||!isFinite(position)||Math.floor(position)!==position||position>subjectString.length){position=subjectString.length;}
position-=searchString.length;var lastIndex=subjectString.indexOf(searchString,position);return lastIndex!==-1&&lastIndex===position;};}
if(!insignroot.endsWith('/')){insignroot=insignroot+'/';}
INSIGNAPP.config.insignpath=insignroot;INSIGNAPP.config.getMessage=INSIGNAPP.config.messages.get;INSIGNAPP.config.guiProperties=INSIGNAPP.config.loadguiProperties(jQuery);if(typeof my.guiProperties.get("guiNoGPS")!=="undefined"){my.isNoGPS=my.guiProperties.get("guiNoGPS")==="true";}
if((my.isNoGPS==false)&&my.isTouch()&&navigator.geolocation&&window.location.protocol=="https:"){navigator.geolocation.getCurrentPosition(gotLocation,null,locationOptions);}
var roles=this.getURLParam("myroles");if(roles==="Parameter not found"){my.myRoles=null;}else{my.myRoles=roles;}
if(INSIGNAPP.sign!==undefined&&INSIGNAPP.sign.crypt!==undefined){INSIGNAPP.sign.crypt.createSharedSecret();}
var jwt=this.getURLParam("jwt");if(jwt==="Parameter not found"){}else{my.jwt=jwt[0];}};my.queryLocationNoTouch=function(){if((my.isNoGPS==false)&&navigator.geolocation&&window.location.protocol=="https:"){navigator.geolocation.getCurrentPosition(gotLocation,null,locationOptions);}};my.setSessionId=function(sessionid){if(sessionid===''||(typeof sessionid==='undefined')){var param=this.getURLParam('sessionid');if(param[0].length>1){my.sessionid=param[0];}else if(param=="Parameter not found"){my.sessionid='';}}else{my.sessionid=sessionid;}
if(!INSIGNAPP.config.guiProperties){INSIGNAPP.config.guiProperties=INSIGNAPP.config.loadguiProperties(jQuery);}};my.setClientId=function(clientid){my.clientid=clientid;};my.setDualscreenClientMayEdit=function(mayedit){my.dualscreenClientMayEdit=mayedit;};my.setTAN=function(tan){if(tan===''||(typeof tan==='undefined')){INSIGNAPP.data.getTAN(my.sessionid,function(tan){INSIGNAPP.config.tan=tan;$('.vorgangsnummer').text(tan);});}else{my.tan=tan;}};my.setLifetime=function(a_strLifetime){var iLifetime=Number(a_strLifetime);my.lifetime=iLifetime?iLifetime:my.lifetime;};my.consoleLog=function(output){if(my.isDebug&&window.console){console.log(output);}};my.setExpirationTime=function(expirationTime){var numExpirationTime=Number(expirationTime);my.expirationTime=numExpirationTime?numExpirationTime:my.expirationTime;}
my.getExpirationTime=function(){return my.expirationTime;}
my.setExpirationUrl=function(expirationURL){my.expirationURL=expirationURL;}
my.getURLParam=function(param){param=param.replace(/\?/ig,"").replace(/=/ig,"");var url=window.location.href;var parameters=url.substring(url.indexOf("?")+1).split("&");for(var i=0;i1){$unpairAll.removeClass(strClassHidden);}
var oLastUsed=new Date(0);var strClassActive="active";var strClassInactive="inactive";$.each(oPairedMobiles,function(a_iIndex,a_oMobile){var $newMobile=$("#pairedMobileTemplate").clone().removeAttr("id").removeClass(strClassHidden).addClass(strClassMobile);if(a_oMobile.lastUsed){var $status=$newMobile.find(".table-column-status");var oLastUsedNew=new Date(a_oMobile.lastUsed);if(oLastUsedNew>oLastUsed){oLastUsed=oLastUsedNew;$mobileTable.find("."+strClassMobile+"."+strClassActive).removeClass(strClassActive);$status.addClass(strClassActive);}else{$status.addClass(strClassInactive);}}
if(a_oMobile.displayName==="UPAD"){$newMobile.find(".table-column-modell").text("U-Pad");$newMobile.find(".resendPairing").remove();}
else{var label=a_oMobile.displayName;if(INSIGNAPP.config.isApplosPermanent){if((a_oMobile.phoneNumber&&a_oMobile.phoneNumber!='')||(a_oMobile.email&&a_oMobile.email!='')){if(a_oMobile.phoneNumber&&a_oMobile.phoneNumber!=''){label=label+" ("+a_oMobile.phoneNumber+")";$newMobile.find(".resendPairingLink").data("phoneNumber",a_oMobile.phoneNumber);$newMobile.find(".resendPairingLink").data("email","");}else if(a_oMobile.email&&a_oMobile.email!=''){label=label+" ("+a_oMobile.email+")";$newMobile.find(".resendPairingLink").data("email",a_oMobile.email);$newMobile.find(".resendPairingLink").data("phoneNumber","");}
$newMobile.find(".resendPairingLink").data("mobileid",a_oMobile.id);}else{$newMobile.find(".resendPairing").remove();}}else{$newMobile.find(".resendPairing").remove();}
$newMobile.find(".table-column-modell").text(label);}
$newMobile.find(".unpair").data("mobileid",a_oMobile.id);$newMobile.find(".unpair").data("mobileobj",a_oMobile);$mobileTable.append($newMobile);});}});if(my.manualDeviceDetect()){var manualtouch=my.manualTouchDevice();toggleManualCheckbox(true);toggleTouchCheckbox(manualtouch);toggleNormCheckbox(!manualtouch);}else{var touchscreen=INSIGNAPP.config.messages.get('einstellungen.device.touch');var screen=INSIGNAPP.config.messages.get('einstellungen.device.notouch');$('.device-detected').text(my.isTouch()?touchscreen:screen);}
var browserLanguage=INSIGNAPP.config.language;$('#language select').val(browserLanguage);$(".berater-language-select").multiselect('refresh');};my.getRealNameWithSignatureAddition=function(realName){if(INSIGNAPP.config.signatureAddition){const realNameNotEmpty=typeof realName!=='undefined'&&realName!=='';const signatureAddition=' ('+_.unescape(INSIGNAPP.config.signatureAddition)+')';return realNameNotEmpty?realName+signatureAddition:signatureAddition;}else{return realName;}}
my.resizeBg=function(){var $bg=$('.hintergrundicon'),$content=$('.content'),contentHeight,windowHeight,bgTop;if($bg.length>0){bgTop=$bg.offset().top;contentHeight=$content.outerHeight();windowHeight=$(window).height();if(contentHeight+bgTop-1&&nua.indexOf('android ')>-1&&nua.indexOf('applewebkit')>-1);if(my.isAndroidAndVersionSmaller(4.1)&&isNativeAndroidBrowser){INSIGNAPP.config.consoleLog("unsupported browser: android brower version "+nua+" with native android browser, at least android version 4.1 needed");result.supported=false;result.messageID="unsupported.android.browser";}
return result;};my.getLocalStorage=function(){if(typeof my.localStorage!='undefined'){return my.localStorage;}else{try{localStorage.setItem("storage","");localStorage.removeItem("storage");my.localStorage=localStorage;}catch(err){my.localStorage=new LocalStorageAlternative();}}
return my.localStorage;};my.getSessionStorage=function(){if(typeof my.sessionStorage!='undefined'){return my.sessionStorage;}else{try{sessionStorage.setItem('storage','');sessionStorage.removeItem('storage');my.sessionStorage=sessionStorage;}catch(err){my.sessionStorage=new LocalStorageAlternative();}}
return my.sessionStorage;};my.allowedExtensionsToString=function(){return''+(my.allowedExtensions).join(', ');};my.allowedImageExtensionsToString=function(){return''+(my.allowedImageExtensions).join(', ');};my.isAllowedExtension=function(ext){return my.allowedExtensionsToString().indexOf(ext.toLowerCase())>-1;};my.isAllowedImageExtension=function(imgExt){return my.allowedImageExtensionsToString().indexOf(imgExt.toLowerCase())>-1;};my.isAllowedAttachmentExtension=function(ext){let allowedTypes="";if(INSIGNAPP.config.allowedFileAttachmentTypes&&INSIGNAPP.config.allowedFileAttachmentTypes.length>0){allowedTypes=INSIGNAPP.config.allowedFileAttachmentTypes.toLowerCase();}
return allowedTypes.indexOf(ext.toLowerCase())>-1;};my.toggleDeviceCheckbox=function($elem){var $cb=$elem.find('.icon_cb'),$div=$cb.find('div'),$cb_radio=$elem.find('.icon_cb_radio'),$div_radio=$cb_radio.find('div');if($cb.prop('id')=='manual-checkbox'){if($div.hasClass('check')){toggleManualCheckbox(false);}else{toggleManualCheckbox(true);}}else if($cb_radio.prop('id')=='touch-checkbox'){if(!$div_radio.hasClass('check_radio')){toggleTouchCheckbox(true);}}else if($cb_radio.prop('id')=='norm-checkbox'){if(!$div_radio.hasClass('check_radio')){toggleNormCheckbox(true);}}};my.screenType={touch:"touch",normal:"normal",auto:"auto"}
my.toggleScreenTypeNewGallery=function(screenType){if(screenType===my.screenType.touch){if(storeManualDeviceDetect()){localStorage.setItem('manualDeviceDetect',true);localStorage.setItem('manualTouchDevice',true);}}
else if(screenType===my.screenType.normal){if(storeManualDeviceDetect()){localStorage.setItem('manualDeviceDetect',true);localStorage.setItem('manualTouchDevice',false);}}
else{localStorage.setItem('manualDeviceDetect',false);localStorage.removeItem('manualTouchDevice');}}
function storeManualDeviceDetect(){return typeof my.applosPerTouch=='undefined';}
function toggleManualCheckbox(checked){var $div=$('#manual-checkbox div'),$touch=$('.device-manual-touch'),$norm=$('.device-manual-norm'),$autoDetect=$('.device-detected');if(checked){$div.addClass('check');$touch.removeClass('disabled');$norm.removeClass('disabled');if(storeManualDeviceDetect()){localStorage.setItem('manualDeviceDetect',true);}
toggleTouchCheckbox(true);var inactive=INSIGNAPP.config.messages.get('einstellungen.device.manual.checked');$autoDetect.text(inactive);}else{$div.removeClass('check');$touch.addClass('disabled');$norm.addClass('disabled');toggleTouchCheckbox(false);toggleNormCheckbox(false);if(storeManualDeviceDetect()){localStorage.setItem('manualDeviceDetect',false);}
var touchscreen=INSIGNAPP.config.messages.get('einstellungen.device.touch');var screen=INSIGNAPP.config.messages.get('einstellungen.device.notouch');$autoDetect.text(my.isTouch()?touchscreen:screen);}
if(storeManualDeviceDetect()===false){if(my.applosPerTouch==true){$('#einstellungen_content_device_list').hide();$('#einstellungen_content_device_options').hide();}else{$('.device-manual').css({'pointer-events':'none','-webkit-filter':'grayscale(100%)','filter':'grayscale(100%)'});}}}
function toggleNormCheckbox(checked){var $div=$('#norm-checkbox div'),$touchCbDiv=$('#touch-checkbox div');if(checked){if($touchCbDiv.hasClass('check_radio')){$div.addClass('check_radio');toggleTouchCheckbox(false);}else{$div.addClass('check_radio');}}else{$div.removeClass('check_radio');}}
function toggleTouchCheckbox(checked){var $div=$('#touch-checkbox div'),$normCbDiv=$('#norm-checkbox div');if(checked){if($normCbDiv.hasClass('check_radio')){$div.addClass('check_radio');toggleNormCheckbox(false);}else{$div.addClass('check_radio');}
if(storeManualDeviceDetect()){localStorage.setItem('manualTouchDevice',true);}}else{$div.removeClass('check_radio');if(storeManualDeviceDetect()){localStorage.setItem('manualTouchDevice',false);}}}
my.isSmartphone=false;my.isFullscreen=false;$(document).ajaxStart(function(){my.resetTimeout();});my.setTimeout=function(){if(my.expirationTime!=-1){if(timer){window.clearTimeout(timer);}
timer=window.setTimeout(function(){if(!my.isApplos){$(window).off('beforeunload');INSIGNAPP.data.changeWindowLocationWithSubmit(my.expirationURL,true,{},true);}},(my.expirationTime*60*1000));}};my.resetTimeout=function(){if(timer){window.clearTimeout(timer);}
my.setTimeout();};my.isCommonPhotoAndFileButton=false;}catch(exp){$(document).ready(function(){INSIGNAPP.data.tracekit(exp);});}
function getQueryString(){var key=false,res={},itm=null;var qs=location.search.substring(1);if(arguments.length>0&&arguments[0].length>1)
key=arguments[0];var pattern=/([^&=]+)=([^&]*)/g;while(itm=pattern.exec(qs)){if(key!==false&&decodeURIComponent(itm[1])===key)
return decodeURIComponent(itm[2]);else if(key===false)
res[decodeURIComponent(itm[1])]=decodeURIComponent(itm[2]);}
return key===false?res:null;}
function updateFooter(){if(INSIGNAPP.config.isExtern&&!INSIGNAPP.config.isUserMode){$('.sid-footer').remove();}}
my.isUserMode=false;$(document).ready(function(){if(window.checkCookie===false){if(window.location.href.indexOf(INSIGNAPP.config.expirationURL)===-1){window.location=INSIGNAPP.config.expirationURL;}}
try{var user=getQueryString("user");if(user){my.isUserMode=INSIGNAPP.config.isExtern;my.userid=user;}
updateFooter();}catch(Exp){console.log(Exp);}});return my;})();if(!Array.prototype.indexOf){Array.prototype.indexOf=function(elt)
{var len=this.length>>>0;var from=Number(arguments[1])||0;from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0)
from+=len;for(;from{if(!str){return new Uint8Array()}
const arr=[]
for(let i=0,len=str.length;i{return Array.from(new Uint8Array(buf)).map(x=>('00'+x.toString(16)).slice(-2)).join('')}
function createKeys(forBio,serverPublicKey,type){if(!serverPublicKey){INSIGNAPP.config.consoleLog("ERROR: aborting createKeys due to missing type: "+type);return;}
const serverPublicKeyArray=StringToArray(window.atob(serverPublicKey));window.crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-384",},true,["deriveKey","deriveBits"]).then(function(key){if(forBio){publicKeyBio=key.publicKey;privateKeyBio=key.privateKey;}else{publicKeyCheck=key.publicKey;privateKeyCheck=key.privateKey;}
window.crypto.subtle.exportKey("jwk",key.publicKey).then(function(keydata){var publicKeyJson=JSON.stringify(keydata);if(forBio){publicKeyBioForExport=publicKeyJson;}else{publicKeyCheckForExport=publicKeyJson;}});return window.crypto.subtle.exportKey('raw',key.publicKey)}).then(browserPublicKey=>{var ret=null;try{ret=window.crypto.subtle.importKey('spki',serverPublicKeyArray,{name:'ECDH',namedCurve:'P-384'},true,[])}catch(exp){console.log(exp);}
return ret;}).then(serverPublicKeyImported=>{var privateKey;if(forBio){privateKey=privateKeyBio;}else{privateKey=privateKeyCheck;}
return window.crypto.subtle.deriveBits({name:'ECDH',namedCurve:'P-384',public:serverPublicKeyImported},privateKey,256)}).then(sharedSecret=>{crypto.subtle.importKey("raw",sharedSecret,{name:"AES-CTR"},true,["decrypt","encrypt"]).then(function(keyObj){if(forBio){sharedSecretBiodata=keyObj;}else{sharedSecretCheck=keyObj;}});})}
module.createSharedSecret=async function(){if(INSIGNAPP.config.bioKeyIsEc){createKeys(true,INSIGNAPP.config.bioKey,"bioKey");}
createKeys(false,INSIGNAPP.config.checkKey,"checkKey");}
module.getPublicKeyBio=function(){return publicKeyBio;}
module.getPublicKeyCheck=function(){return publicKeyCheck;}
module.getPublicBioKeyForExport=function(){return publicKeyBioForExport;}
module.getPublicCheckForExport=function(){return publicKeyCheckForExport;}
module.checkHashalgorithm=async function(){var image="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";var hash=await sha256(image);if(hash==="95dfc7f247c2cbf515e436b1081136d2006adb48df8e27412e72d7d90e9d66a9"){return true;}
INSIGNAPP.data.sendToTraceKit({error:'hashAlgorithmError',hash:hash,image:image},INSIGNAPP.config.sessionid,"","");return false;}
module.encryptAES=async function(data,key,iv){var ret=crypto.subtle.encrypt({name:"aes-ctr",counter:iv,length:128},key,StringToArray(data));return ret;};module.encryptRSA=function(data,pubKey){var key=gen(32);var iv=gen(16);var cipher=forge.cipher.createCipher('AES-CBC',key);cipher.start({iv:iv});cipher.update(forge.util.createBuffer(data,'raw'));cipher.finish();var encData=cipher.output;if(typeof this.publicKeyRSA==='undefined'){this.publicKeyRSA=forge.pki.publicKeyFromPem(pubKey);}
var encKey=this.publicKeyRSA.encrypt(key);var encIV=this.publicKeyRSA.encrypt(iv);var concat=forge.util.createBuffer();concat.putString("v2");concat.putInt32(encKey.length);concat.putBytes(encKey);concat.putInt32(encIV.length);concat.putBytes(encIV);concat.putBytes(encData.data);return concat.bytes();};module.encryptChecksum=async function(data,key,iv){var ret=crypto.subtle.encrypt({name:"aes-ctr",counter:iv,length:128},key,StringToArray(data));return ret;};module.compressAndEncrypt=async function(sigDataStruct,pubKey,callback){sigDataStruct=unescape(encodeURIComponent(sigDataStruct));var sigDataUint8=StringToArray(sigDataStruct),sigDataDeflate=pako.deflate(sigDataUint8,{to:'string'}),iv=window.crypto.getRandomValues(new Uint8Array(16)),sigDataEncrypted,sigDataEncryptedb64;if(INSIGNAPP.config.bioKeyIsEc){sigDataEncrypted=await module.encryptAES(sigDataDeflate,sharedSecretBiodata,iv);sigDataEncryptedb64=buf2Hex(iv)+buf2Hex(sigDataEncrypted);}else{sigDataEncrypted=module.encryptRSA(sigDataDeflate,pubKey);sigDataEncryptedb64=forge.util.encode64(sigDataEncrypted);}
var algorithmOk=module.checkHashalgorithm();if(algorithmOk===false){return false;}
var dataHash=await sha256(sigDataEncryptedb64);var iv2=window.crypto.getRandomValues(new Uint8Array(16));var checksumEncrypted=await module.encryptChecksum(dataHash,sharedSecretCheck,iv2),checksumEncryptedHex=buf2Hex(iv2)+buf2Hex(checksumEncrypted);return sigDataEncryptedb64+':::'+checksumEncryptedHex;};module.compressAndEncryptExtended=async function(sigDataStruct,pubKey,oneTimePassword,image64,lineDataStruct){sigDataStruct=unescape(encodeURIComponent(sigDataStruct));var sigDataUint8=StringToArray(sigDataStruct),sigDataDeflate=pako.deflate(sigDataUint8,{to:'string'}),iv=window.crypto.getRandomValues(new Uint8Array(16)),sigDataEncryptedb64;if(INSIGNAPP.config.bioKeyIsEc){sigDataEncryptedb64=buf2Hex(iv)+buf2Hex(await module.encryptAES(sigDataDeflate,sharedSecretBiodata,iv));}else{sigDataEncryptedb64=forge.util.encode64(module.encryptRSA(sigDataDeflate,pubKey));}
var dataHash=await sha256(sigDataEncryptedb64);var checkDic={checksum:dataHash,oneTimePassword:oneTimePassword};var algorithmOk=module.checkHashalgorithm();if(algorithmOk===false){return false;}
var iv2=window.crypto.getRandomValues(new Uint8Array(16));var checksumEncrypted=await module.encryptChecksum(JSON.stringify(checkDic),sharedSecretCheck,iv2),checksumEncryptedHex=buf2Hex(iv2)+buf2Hex(checksumEncrypted);var checkImageEncryptedHex='';if(image64){var image64Hash=await sha256(image64);var checkImageDic={checksumImage:image64Hash,oneTimePassword:oneTimePassword};var iv3=window.crypto.getRandomValues(new Uint8Array(16));var checkImageEncrypted=await module.encryptChecksum(JSON.stringify(checkImageDic),sharedSecretCheck,iv3);checkImageEncryptedHex=buf2Hex(iv3)+buf2Hex(checkImageEncrypted);}
var checkLinesEncryptedHex='';if(lineDataStruct){lineDataStruct=unescape(encodeURIComponent(lineDataStruct));var dataHashLines=await sha256(lineDataStruct);var checkDicLines={checksum:dataHashLines,oneTimePassword:oneTimePassword};var iv4=window.crypto.getRandomValues(new Uint8Array(16));var checkLinesEncrypted=await module.encryptChecksum(JSON.stringify(checkDicLines),sharedSecretCheck,iv4);checkLinesEncryptedHex=buf2Hex(iv4)+buf2Hex(checkLinesEncrypted);}
const s=sigDataEncryptedb64+':::'+checksumEncryptedHex+':::'+checkImageEncryptedHex+':::'+checkLinesEncryptedHex;return s;};async function sha256(string){const utf8=new TextEncoder().encode(string);const hashBuffer=await crypto.subtle.digest('SHA-256',utf8);const hashArray=Array.from(new Uint8Array(hashBuffer));const hashHex=hashArray.map((bytes)=>bytes.toString(16).padStart(2,'0')).join('');return hashHex;}
function hex(buffer){var digest=''
var view=new DataView(buffer)
for(var i=0;i1){if(i';}else{strErrorMessage=strErrorMessage+currentErrorMessage;}}else{strErrorMessage=currentErrorMessage;}}}catch(e){strErrorMessage=INSIGNAPP.config.messages.get(data.message);}}
return strErrorMessage;}
function parseServerErrorTitle(data){var errorTitle=null;if(data&&data.message){var titleMessage=data.message+".title";errorTitle=INSIGNAPP.config.messages.has(titleMessage)?INSIGNAPP.config.messages.get(titleMessage):null;}
return errorTitle}
function getAlert(){if(typeof INSIGNAPP.viewmodel!=='undefined'){if(typeof INSIGNAPP.viewmodel.alert!=='undefined'){return INSIGNAPP.viewmodel.alert;}else{return INSIGNAPP.viewmodel.alert;}}else{return INSIGNAPP.alert;}}
function showAjaxError(jqXHR,textStatus,errorThrown){if(jqXHR&&jqXHR.statusText){var consoleOutput=('Fehler bei Aufruf des Service: \n'+'result.statusText='+jqXHR.statusText+';status='+
textStatus+';err='+errorThrown);INSIGNAPP.config.consoleLog(consoleOutput);}
var strErrorMessage=parseServerError(errorThrown);var strErrorTitel=parseServerErrorTitle(errorThrown);if(typeof INSIGNAPP.galleryUtil!='undefined'){hideLoadingSpinner();}else if(typeof INSIGNAPP.customerportal!='undefined'){INSIGNAPP.customerportal.hideLoadingSpinner();}
if(typeof strErrorMessage=='string'&&strErrorMessage){getAlert().show('error',{message:strErrorMessage,messageLabel:strErrorTitel});}}
var inWorkOverlay=(function(){var count=0;var timeout;var module={};module.show=function(zindex){count++;timeout=setTimeout(function(){if($('#ajax_in_work_overlay').length===0&&count>0){$('body').append('');}},500);if(zindex){setTimeout(function(){$("#ajax_in_work_overlay").css("z-index",""+zindex);},500);}};module.hide=function(){if(count>0)count--;if(count<=0){$('#ajax_in_work_overlay').remove();clearTimeout(timeout);}else{INSIGNAPP.config.consoleLog("Not hiding spinner as count is "+count);}};module.showInWorkOverLayImmediately=function(){if($("#ajax_in_work_overlay").length===0){$('body').append('');}
count++;};module.removeInWorkOverLayImmediately=function(){$('#ajax_in_work_overlay').remove();count=0;clearTimeout(timeout);};module.getCounter=function(){return count;};return module;})();function makeAjax(options){$.support.cors=true;var oRequest=$.Deferred(function(a_oRequest){makeRequest(options);function makeRequest(options){if(options.showOverlay){inWorkOverlay.show(options.overLayZ);}
if(typeof options.dataType==='undefined'){options.dataType='json';}
if(typeof options.global==='undefined'){options.global=true;}
var url=INSIGNAPP.config.insignpath+options.url;var headers={"X-Requested-With":"XMLHttpRequest"};if(INSIGNAPP.config.jwt){headers["INSIGN_JWT"]="Bearer "+INSIGNAPP.config.jwt;}
var $XHR=$.ajax(url,{headers:headers,contentType:options.type,data:options.data,method:options.transMethod,dataType:options.dataType,global:options.global,complete:function(){if(options.showOverlay){inWorkOverlay.hide();}},success:function(a_oData,a_strTextStatus,a_$XHR){var contentType=a_$XHR.getResponseHeader('content-type')||'';var isResponseFromServer=contentType.indexOf(options.dataType)!=-1||contentType==='';if(isResponseFromServer){if(typeof a_oData=="object"&&typeof a_oData.error!='undefined'&&a_oData.error!=null&&a_oData.error!==0){a_oRequest.reject(a_$XHR,a_strTextStatus,a_oData);}else{a_oRequest.resolve(a_oData,a_strTextStatus,a_$XHR);}}else if(options.showErrorAlert!==false){error(a_$XHR,a_strTextStatus,a_oData);}},error:function(a_$XHR,a_strTextStatus,a_oData){if(options.showErrorAlert!==false&&!INSIGNAPP.config.isOffline&&!INSIGNAPP.data.ignoreNextError){error(a_$XHR,a_strTextStatus,a_oData,options);}else{a_oRequest.reject(a_$XHR,a_strTextStatus,a_oData);}
INSIGNAPP.data.ignoreNextError=false;}});a_oRequest.fail(function(){$XHR.abort();});}
function error(a_$XHR,textStatus,a_oData,options){if(textStatus==='abort'){return;}
INSIGNAPP.data.removeInWorkOverLayImmediately();if(typeof INSIGNAPP.galleryUtil!='undefined'){hideLoadingSpinner();}
var dialogtype='connection-error';var msg='alert.connectionajaxerror';if(a_$XHR.responseURL!=undefined&&a_$XHR.responseURL.indexOf('/detection')!=-1){return;}
if(a_$XHR.status===401){window.location.reload();}
if(a_$XHR.status===403||a_$XHR.status===599){if(a_$XHR.responseJSON&&a_$XHR.responseJSON.message){if(!options.show599and403ErrorAsDialog){if(INSIGNAPP.config.expirationURL.indexOf('clienterror')!=-1&&a_$XHR.responseJSON.errorPageData&&''!==a_$XHR.responseJSON.errorPageData.lastErrormessage){var errorPageData={lastErrortitle:a_$XHR.responseJSON.errorPageData.lastErrortitle,lastErrormessage:a_$XHR.responseJSON.errorPageData.lastErrormessage,expiration:new Date().getTime()+5000};sessionStorage.setItem('errorPageData',JSON.stringify(errorPageData));}
INSIGNAPP.data.changeWindowLocationWithSubmit(INSIGNAPP.config.expirationURL,true,{},true);}}else{INSIGNAPP.data.changeWindowLocation(INSIGNAPP.config.insignpath+'599.jsp',true);}
if(!options.show599and403ErrorAsDialog){return;}}
if(a_$XHR.responseJSON&&a_$XHR.responseJSON.error&&a_$XHR.responseJSON.error!==0){dialogtype='error';msg=a_$XHR.responseJSON.message;var storageErrorMsg={};storageErrorMsg.message="error.signature.storage";if(msg.substring(0,msg.indexOf(" (code"))===parseServerError(storageErrorMsg)){a_oRequest.reject(a_$XHR,parseServerError(storageErrorMsg),a_oData);return;}}
if(INSIGNAPP.viewmodel!==undefined&&getAlert()!==undefined&&(!options||!options.noRedo)){if(dialogtype==='connection-error'){if(options.retryOnConnectionerror){return makeAjax(options);}else{getAlert().showConnectionError();}}
else{getAlert().show(dialogtype,{message:msg,fnOnClose:function(){a_oRequest.reject(a_$XHR,textStatus,a_oData);}});}}else
{a_oRequest.reject(a_$XHR,textStatus,a_oData);}}});if(options.callbackComplete){oRequest.always(options.callbackComplete);}
if(options.callbackSuccess){oRequest.done(options.callbackSuccess);}
if(options.callbackFail){oRequest.fail(options.callbackFail);}else{oRequest.fail(showAjaxError);}
return oRequest;}
function makeGetAjax(options){var defaultOptions={transMethod:'GET',type:'application/json'};if(typeof options=="object"){options=$.extend(defaultOptions,options);}
var deferred=makeAjax(options);return deferred;}
function makePostAjax(options){var defaultOptions={transMethod:'POST',type:'application/json'};if(typeof options=="object"){options=$.extend(defaultOptions,options);}
var deferred=makeAjax(options);return deferred;}
function makeDeleteAjax(options){var defaultOptions={transMethod:'DELETE',type:'application/json'};if(typeof options=="object"){options=$.extend(defaultOptions,options);}
var deferred=makeAjax(options);return deferred;}
my.initDocsData=function(json,status,callback){if(json.error===0){my.docsData=json;INSIGNAPP.config.needToAcceeptToSignText=json.needToAcceeptToSignText;INSIGNAPP.config.resetSignatureForExtern=json.resetSignatureForExtern;INSIGNAPP.config.resetSignatureForExternID=json.resetSignatureForExternID;if(INSIGNAPP.autocomplete){INSIGNAPP.autocomplete.init(json.autocompleteEntries);}
var doc;for(var i=0;iINSIGNAPP.viewmodel.Main.vorgang.model.getModelDocumentById(doc.docid).isModified());return docsChangedData;};my.getDocData=function(docid,callback){if(typeof my.docsData!=='undefined'){var document=getDocument(_.unescape(docid));callback(document);}else{my.getDocumentsData(function(){callback(getDocument(_.unescape(docid)));},true);}};my.fetchNewDocs=function(docIds,callbackNew,callbackUpdate){INSIGNAPP.data.showInWorkOverlay();var idStr="";for(var i in docIds){if(idStr.length>0)idStr+=',';idStr+=docIds[i].docid;}
var params={includeAnnotations:true,ids:idStr}
var options={url:'get/documents/by/ids?'+$.param(params),data:JSON.stringify({sessionid:INSIGNAPP.config.sessionid}),callbackSuccess:function(json,status){if(json.error!==0){showAjaxError(json,status,json.error);}else{var newDocs=[];var updatedDocs=[];for(var i in docIds){var id=docIds[i].docid;var doc=_.find(json.documents,function(d){return d.docid==id;});var existingdoc=_.find(my.docsData.documents,function(elem){return elem.docid==id;});if(existingdoc)
{doc.publickey=json.publickey;updatedDocs.push({docid:id,filename:docIds[i].filename,doc:doc});}
else
{my.docsData.documents[my.docsData.documents.length]=doc;doc.publickey=my.docsData.publickey;checkRatio(doc);newDocs.push(doc);}}
callbackUpdate(updatedDocs);callbackNew(newDocs);INSIGNAPP.data.hideInWorkOverlay();}},callbackFail:function(jqXHR,textStatus,errorThrown){INSIGNAPP.data.hideInWorkOverlay();showAjaxError(jqXHR,textStatus,errorThrown);}};return makePostAjax(options);};my.fetchAllDocs=function(onSuccess){var options={url:'get/documents/full?includeAnnotations=true',data:JSON.stringify({sessionid:INSIGNAPP.config.sessionid}),callbackSuccess:onSuccess}
makePostAjax(options);}
my.changeDocumentsOrder=function(docIdsList,sessionId,$currentParentLiElement,$toSwapWithParentLiElement,currentDocIdx,toSwapWithElemDocIdx,currentThumbnails,toSwapWithThumbnails,moveUp,_modelVorgang){const options={url:'configure/reorderDocumentsUser?orderlist='+docIdsList,showOverlay:true,data:JSON.stringify({sessionid:sessionId}),callbackSuccess:function(){const totalDocNum=INSIGNAPP.viewmodel.Main.vorgang.model.getDokumente().length;let $canvasParent=$('.pagecontainer');let $currentCanvParent=$canvasParent.find('.page[data-doc="'+currentDocIdx+'"]');let $toSwapCanvParent=$canvasParent.find('.page[data-doc="'+toSwapWithElemDocIdx+'"]');if(moveUp){$currentParentLiElement.insertBefore($toSwapWithParentLiElement);if(toSwapWithElemDocIdx===0){$currentParentLiElement.find('.moveDocUp').addClass('d-none');$toSwapWithParentLiElement.find('.moveDocUp').removeClass('d-none');}
if((currentDocIdx+1)===totalDocNum){$currentParentLiElement.find('.moveDocDown').removeClass('d-none');$toSwapWithParentLiElement.find('.moveDocDown').addClass('d-none');}}
else{$currentParentLiElement.insertAfter($toSwapWithParentLiElement);if(currentDocIdx===0){$currentParentLiElement.find('.moveDocUp').removeClass('d-none');$toSwapWithParentLiElement.find('.moveDocUp').addClass('d-none');}
if((toSwapWithElemDocIdx+1)===totalDocNum){$toSwapWithParentLiElement.find('.moveDocUp').removeClass('d-none');$toSwapWithParentLiElement.find('.moveDocDown').removeClass('d-none');$currentParentLiElement.find('.moveDocDown').addClass('d-none');}}
INSIGNAPP.config.consoleLog('success saving new order of documents data');INSIGNAPP.utils.setIsDocumentOrderChanged(true);let aktiveDokument=parseInt(INSIGNAPP.viewmodel.Main.vorgang.model.aktivesDokument().getDocIndex());let isAktiveCurrOrSpd=(aktiveDokument===currentDocIdx||aktiveDokument===toSwapWithElemDocIdx);localStorage.setItem('isAktiveCurrOrSpd',String(isAktiveCurrOrSpd));localStorage.setItem('sessionID',sessionId);localStorage.setItem('docIndex',toSwapWithElemDocIdx);localStorage.setItem('isDocOrderChanged',"true");localStorage.setItem('lastActiveItem',String(aktiveDokument));let docToGo=0;if(!isAktiveCurrOrSpd){docToGo=aktiveDokument;}
if(aktiveDokument===currentDocIdx){localStorage.setItem('docIndex',toSwapWithElemDocIdx);docToGo=toSwapWithElemDocIdx;}else if(aktiveDokument===toSwapWithElemDocIdx){localStorage.setItem('docIndex',currentDocIdx);docToGo=currentDocIdx;}
window.onbeforeunload=null;$(':focus, [autofocus]').blur();let currentUrl=window.location.href;if(currentUrl.includes('#page')){currentUrl=currentUrl.replace(/#page\d+_doc\d+/,'');}
currentUrl+=`#page0_doc${docToGo}`;var date=new Date();date.setTime(date.getTime()+(5*60*1000));document.cookie="isDocOrderChanged=true; expires="+date.toUTCString()+";";INSIGNAPP.data.submitUrlAsForm(currentUrl,{sessionid:INSIGNAPP.config.sessionid});},callbackFail:function(a_$XHR,a_strTextStatus,a_oData){INSIGNAPP.viewmodel.alert.show('error',{message:a_oData.message});},};makePostAjax(options);}
my.isSignatureSigned=function(docid,signID,callback){var options={url:'get/signature/signed?idSignature='+encodeURIComponent(signID)+'&idDoc='+encodeURIComponent(docid),showOverlay:true,data:JSON.stringify({sessionid:INSIGNAPP.config.sessionid}),callbackSuccess:function(json,status){if(json.error!==0){showAjaxError(json,status,json.error);return;}
callback(json.message=="true");}}
if(!INSIGNAPP.config.isOffline){makePostAjax(options);}else{callback(true);}}
my.getDataForSign=function(docid,signID,callback){var options={url:"rest/signprocess/getDataForSign",data:JSON.stringify({sessionid:INSIGNAPP.config.sessionid,signatureID:signID,docID:docid}),showOverlay:true,callbackSuccess:function(json){callback(json);}};if(!INSIGNAPP.config.isOffline){makePostAjax(options);}else{callback({hash:"offline"});}};my.deletePage=function(docid,page,callback){var data={sessionid:INSIGNAPP.config.sessionid}
var options={url:'configure/deletePage?docid='+docid+"&page="+page,data:JSON.stringify(data),callbackSuccess:callback};makePostAjax(options);};my.fetchNewPhoto=function(callback,forAnnotation){var options={url:'get/documents/full?includeAnnotations=true',data:JSON.stringify({sessionid:INSIGNAPP.config.sessionid}),callbackSuccess:function(json,status){var newDoc;if(json.error!==0){showAjaxError(json,status,json.error);}else{if(!forAnnotation&&((INSIGNAPP.config.fotouploadType==="own"&&INSIGNAPP.viewmodel.Main.vorgang.model.getGwgDoc()===null)||INSIGNAPP.pdfviewer.currentDoc==-1)){for(var i in json.documents){newDoc=json.documents[i];for(var j in my.docsData.documents){if(newDoc.docid==my.docsData.documents[j].docid){newDoc=undefined;break;}}
if(newDoc){break;}}
if(newDoc===undefined){throw new Error('insign.data.fetchNewPhoto: foto nicht gefunden');}
my.docsData.documents[my.docsData.documents.length]=newDoc;newDoc.publickey=my.docsData.publickey;checkRatio(newDoc);}else{var actDoc=INSIGNAPP.pdfviewer.currentDoc>=0?my.docsData.documents[INSIGNAPP.pdfviewer.currentDoc].docid:null;if(INSIGNAPP.config.isGWGModus&&INSIGNAPP.viewmodel.Main.vorgang.model.getGwgDoc()!==null){actDoc=INSIGNAPP.viewmodel.Main.vorgang.model.getGwgDoc().daten().docid;}
for(var i in json.documents){if(json.documents[i].docid==actDoc){newDoc=json.documents[i];break;}}}}
callback(newDoc);}};makePostAjax(options);};my.getSessionSignaturesDone=function(sessionid,callback){if(my.docsData&&typeof my.docsData!=='undefined'){callback(my.docsData.numberOfSignaturesNeededDone&&typeof my.docsData.numberOfSignaturesNeededDone!=='undefined'?my.docsData.numberOfSignaturesNeededDone:0);}else{callback(0);}};my.getSessionModTimestamp=function(sessionid,callback){if(my.docsData&&typeof my.docsData!=='undefined'){callback(my.docsData.modifiedTimestamp);}else{callback('');}};my.getTAN=function(sessionid,callback){if(my.docsData&&typeof my.docsData!=='undefined'){callback(my.docsData.tan);}else{callback('');}};my.getDocImage=function(docid,page,callback){callback('image/getdocumentpageimageb64?'+$.param({docid:encodeURIComponent(docid),page:page}));};my.getDocThumb=function(sessionid,docid,page,callback,vorgangsverwaltungid){var callbackurl=INSIGNAPP.config.insignpath+'image/getdocumentthumbnail64?'+$.param({docid:encodeURIComponent(docid),page:page});if(vorgangsverwaltungid)callbackurl+='&idVorgangsverwaltung='+vorgangsverwaltungid;callback(callbackurl);};my.getSessions=function(callback){var options={url:'get/sessions',data:JSON.stringify({sessionid:INSIGNAPP.config.sessionid}),callbackSuccess:callback};makePostAjax(options);};my.delegateExtern=function(sessionid,data,callback){data.sessionid=sessionid;var url='extern/delegate';var options={url:url,data:JSON.stringify(data),showOverlay:true,callbackSuccess:callback};makePostAjax(options);};my.resetSignatureExtern=function(sessionid,docid,callback){var url='extern/resetlastSignature';var options={url:url,data:JSON.stringify({docid:docid,sessionid:sessionid}),showOverlay:true,callbackSuccess:callback};makePostAjax(options);};my.getExternInfo=function(sessionid,callback){var url='get/externInfos';if(INSIGNAPP.config.sessionid){url+='?idVorgangsverwaltung='+INSIGNAPP.config.sessionid;}
var options={url:url,data:JSON.stringify({sessionid:sessionid}),callbackSuccess:callback};makePostAjax(options);};my.setSessionData=function(sessionid,data,callback){data.sessionid=sessionid;var url='get/setDisplay';if(sessionid!==INSIGNAPP.config.sessionid&&INSIGNAPP.config.sessionid&&INSIGNAPP.config.sessionid!=''){url+='?idVorgangsverwaltung='+INSIGNAPP.config.sessionid;}
var options={url:url,data:JSON.stringify(data),callbackSuccess:callback,showErrorAlert:false,callbackFail:function(jqXHR){if(jqXHR){if(data.displayname&&data.displayname.trim().match(/["*?<>|';~$\\]+/g)){$('#displayname').val(data.displayname.replace(/["*?<>|';~$\\]+/g,""));}
getAlert().show('error',{message:jqXHR.responseJSON.message});hideLoadingSpinner();}
return;}};makePostAjax(options);};my.setSessionAusgehaendigt=function(isAusgehaendigtOriginal,callback){my.docsData.ausgehaendigtOriginal=isAusgehaendigtOriginal;if(true===isAusgehaendigtOriginal){for(var i=0;iiMaxWait){INSIGNAPP.config.consoleLog('abort waiting for notification: time limit of '+iMaxWait+'ms reached');timedout=true;a_oNotificationRequest.reject();}else if(a_oNotificationRequest.state()=='pending'){var data={sessionid:a_strSessionid,clienttype:'pc',smartphoneregistered:a_bSmartphoneRegistered,newDevice:a_bNewDevice};if(INSIGNAPP.config.isUserMode){data['userID']=INSIGNAPP.config.userid;}
INSIGNAPP.config.consoleLog('start new notification-request');var options={url:'rest/signprocess/waitfornotify',data:JSON.stringify(data)};var oAjaxRequest=makePostAjax(options);a_oNotificationRequest.fail(oAjaxRequest.reject);oAjaxRequest.done(function(a_oData,a_strTextStatus,a_$XHR){INSIGNAPP.config.consoleLog('request done -> expected notifications: '+a_arrNotificationid.toString()+', received: '+a_oData.notification.notificationid);var notificationReady=$.inArray(a_oData.notification.notificationid,a_arrNotificationid)>=0;if(typeof a_oData.notification.notificationid!=='undefined'&&a_oData.notification.notificationid==='SMARTPHONE_READY'&&typeof a_oData.notification.origin!=='undefined'&&a_oData.notification.origin!==a_requestedClientType){notificationReady=false;}
if(notificationReady){INSIGNAPP.config.consoleLog('success: notification received');if(typeof a_oData.notification.notificationid!='undefined'&&a_oData.notification.notificationid==='SMARTPHONE_PAIRED'&&'smartphonekunde'!=a_requestedClientType){var options={url:'rest/mobilepairing/needspairing',data:JSON.stringify({sessionid:data.sessionid,clienttype:a_requestedClientType})};var oNeedsPairing=makePostAjax(options);oNeedsPairing.fail(a_oNotificationRequest.reject);oNeedsPairing.done(function(a_oNeedsPairingResponseData,a_oTextStatus,a_$XHR){if(a_oNeedsPairingResponseData.needsPairing){notifyRequest(a_iStartTime,false,a_bNewDevice);}else{a_oNotificationRequest.resolve(a_oNeedsPairingResponseData,a_strTextStatus,a_$XHR);}});}else{a_oNotificationRequest.resolve(a_oData,a_strTextStatus,a_$XHR);}}else if(typeof a_oData.notification.notificationid!='undefined'&&a_oData.notification.notificationid==='SMARTPHONE_REGISTRIERT'){notifyRequest(a_iStartTime,true,false);}else if(typeof a_oData.notification.notificationid!='undefined'&&a_oData.notification.notificationid==='NO_NOTIFICATION'){notifyRequest(a_iStartTime,false,a_bNewDevice);}else{notifyRequest(a_iStartTime,a_bSmartphoneRegistered,a_bNewDevice);}});oAjaxRequest.fail(a_oNotificationRequest.reject);}}
notifyRequest(INSIGNAPP.config.timestamp(),a_bSmartphoneRegistered,a_bNewDevice);});oNotificationRequest.extendWait=function(){resetTimeFlag=true;};oNotificationRequest.isTimedOut=function(){return timedout;};oNotificationRequest.fail(a_fnFail);oNotificationRequest.done(a_fnSuccess);return oNotificationRequest;};my.sendNotification=function(a_strSessionid,a_strClienttypeRecipient,a_oNotification,a_fnSuccess){var oClientNotification;if(typeof a_oNotification=='string'){oClientNotification={clienttype:a_strClienttypeRecipient,notificationid:a_oNotification,lifetime:INSIGNAPP.config.lifetime};}else{oClientNotification=a_oNotification;}
var oSendNotification={sessionid:a_strSessionid,clienttype:a_strClienttypeRecipient,notification:oClientNotification};var options={url:'rest/signprocess/sendnotify',data:JSON.stringify(oSendNotification),showOverlay:true,callbackSuccess:a_fnSuccess};return makePostAjax(options);};my.needsPairing=function(options){var oNeedsPairing=makePostAjax({url:'rest/mobilepairing/needspairing',data:JSON.stringify({sessionid:options.sessionId,clienttype:options.clientType}),showOverlay:true});oNeedsPairing.fail(options.callbackOnFail);oNeedsPairing.done(options.callbackOnSuccess);};my.requestPairingCode=function(options){var req=makePostAjax({url:'rest/mobilepairing/requestcode',data:JSON.stringify({sessionid:options.sessionId,clienttype:options.clientType,isNoSign:options.isNoSign,batchSignatureid:options.batchSignatureid})});req.done(function(res){options.callback(res.code,res.lifetime);});req.fail(function(){if(options.callbackOnFail){options.callbackOnFail();}});return req;};function getPairedDeviceInfo(sessionid,clientType,callback){var options={url:'rest/mobilepairing/getpaireddevice',data:JSON.stringify({sessionid:sessionid,clienttype:clientType}),showOverlay:true},ajax=makePostAjax(options);ajax.done(function(json){callback(json);});ajax.fail(function(result,status,err){callback('?');});}
function getPairedDevice(sessionId,clientType,callback){getPairedDeviceInfo(sessionId,clientType,function(json){if(json.devices){callback(json.devices);}else{callback(json);}});}
my.getPairedDevice=getPairedDevice;my.getPairedDeviceInfo=getPairedDeviceInfo;my.getPairedMobiles=function(a_strSessionID,a_fnSuccess){var oUnpairInput={};if(a_strSessionID&&typeof a_strSessionID=='string'){oUnpairInput['sessionid']=a_strSessionID;}
var options={url:'rest/mobilepairing/getpairedmobiles',data:JSON.stringify(oUnpairInput),callbackSuccess:a_fnSuccess};return makePostAjax(options);};my.subUnpair=function(callback){if(!my.unpairChannel)my.unpairChannel=INSIGNAPP.pubsub.createChannel();return my.unpairChannel.subscribe(callback);};my.unsubUnpair=function(subscribeToken){if(my.unpairChannel)my.unpairChannel.unsubscribe(subscribeToken);};my.hasOffline=function(a_strSessionID,a_strMobileID,a_fnSuccess,fnError){var oUnpairInput={pairingToken:a_strMobileID};if(a_strSessionID&&typeof a_strSessionID=='string'){oUnpairInput['sessionid']=a_strSessionID;}
var options={url:'rest/mobilepairing/hasOffline?sessionid='+a_strSessionID,data:JSON.stringify(oUnpairInput),showOverlay:true,callbackSuccess:function(json){if(a_fnSuccess){a_fnSuccess(json);}}};return makePostAjax(options);};my.unpairMobile=function(a_strSessionID,a_strMobileID,a_fnSuccess){var oUnpairInput={pairingToken:a_strMobileID};if(a_strSessionID&&typeof a_strSessionID=='string'){oUnpairInput['sessionid']=a_strSessionID;}
var options={url:'rest/mobilepairing/unpair',data:JSON.stringify(oUnpairInput),showOverlay:true,callbackSuccess:function(){if(my.unpairChannel){my.unpairChannel.publish();}
if(a_fnSuccess){a_fnSuccess();}}};return makePostAjax(options);};my.unpairAll=function(a_strSessionID,a_fnSuccess){var oUnpairInput={};if(a_strSessionID&&typeof a_strSessionID=='string'){oUnpairInput['sessionid']=a_strSessionID;}
var options={url:'rest/mobilepairing/unpairall',data:JSON.stringify(oUnpairInput),showOverlay:true,callbackSuccess:function(){if(my.unpairChannel){my.unpairChannel.publish('berater');}
if(a_fnSuccess){a_fnSuccess();}}};return makePostAjax(options);};my.unpairAllForUser=function(a_strSessionID,a_fnSuccess){var options={url:'rest/mobilepairing/unpairallforuser',data:JSON.stringify({sessionid:a_strSessionID}),showOverlay:true,callbackSuccess:function(){if(my.unpairChannel){my.unpairChannel.publish('berater');}
if(a_fnSuccess){a_fnSuccess();}}};return makePostAjax(options);};my.unpairAllCustomer=function(a_strSessionID,a_fnSuccess){var options={url:'rest/mobilepairing/unpairallCustomer',data:JSON.stringify({sessionid:a_strSessionID}),showOverlay:true,callbackSuccess:function(){if(my.unpairChannel){my.unpairChannel.publish('kunden');}
if(a_fnSuccess){a_fnSuccess();}}};return makePostAjax(options);};my.unpairAllUser=function(a_strSessionID,a_fnSuccess){var options={url:'rest/mobilepairing/unpairallUser',data:JSON.stringify({sessionid:a_strSessionID}),showOverlay:true,callbackSuccess:function(){if(my.unpairChannel){my.unpairChannel.publish('berater');}
if(a_fnSuccess){a_fnSuccess();}}};return makePostAjax(options);};my.resendApplosPermanentLink=function(options,callbackSuccess,callbackFail){options.recipientsms=formatRecipientSms(options.recipientsms);var options={url:'applos/resendApplosPermanentLink',data:JSON.stringify(options),showOverlay:false,callbackSuccess:function(json,status){callbackSuccess(json,status);},callbackFail:function(a_$XHR,a_strTextStatus,a_oData){applosError(a_$XHR,a_strTextStatus,a_oData,callbackFail);}};if(INSIGNAPP.config.userid){options.url.concat("?user="+INSIGNAPP.config.userid)}
return makePostAjax(options);}
my.setQrCodeImage=function(pairingCode,callbackSuccess){var data={sessionid:INSIGNAPP.config.sessionid,pairingcode:pairingCode}
var options={url:"applos/qrcode",data:JSON.stringify(data),dataType:"text",showOverlay:false,callbackSuccess:function(text,status){callbackSuccess(text);},callbackFail:function(error){}};return makePostAjax(options);}
my.displaySignatureImage=function(url,data,callbackSuccess){var options={url:url,data:JSON.stringify(data),dataType:"text",showOverlay:false,callbackSuccess:function(text,status){callbackSuccess(text);},callbackFail:function(error){}};return makePostAjax(options);}
my.creatApiToken=function(a_strSessionID,a_fnSuccess){var options={url:'maketoken',data:(a_strSessionID&&a_strSessionID!=="")?JSON.stringify({sessionid:a_strSessionID}):'',showOverlay:true,dataType:"text",callbackSuccess:function(data){if(a_fnSuccess){a_fnSuccess(data);}}};return makePostAjax(options);};my.cancelSession=function(a_strSessionID){INSIGNAPP.data.ignoreNextError=true;var redirect=false,callbackUrl=INSIGNAPP.config.callbackurl;if(callbackUrl.contains("editTemplate/callback")){return;}
if(callbackUrl.contains("editTemplate/cancel")){redirect=true;}
var options={url:'configure/fertig?redirect='+redirect,data:{sessionid:a_strSessionID},dataType:'html',showOverlay:false};return makeGetAjax(options);};my.startHeartbeat=function(){if(INSIGNAPP.config.heartbeatActive){setTimeout(heartbeat,INSIGNAPP.config.heartbeatSeconds*1000);}}
var inFotoProcess=false;my.startFotoProcess=function(a_strSessionid,a_fnCallback,deviceNames,forceSmartphoneKunde,annotationID){var oFotoProcess=$.Deferred(function(a_oFotoProcess){var strIdFotoSuccess='FOTO_ERFOLGREICH',strIdFotoAbort='FOTO_ABBRUCH',strIdReady='SMARTPHONE_READY',clientType=(INSIGNAPP.config.isExtern&&!INSIGNAPP.config.isUserMode)||forceSmartphoneKunde||!INSIGNAPP.viewmodel.signControl.configAllowPhotoByBerater()?INSIGNAPP.constants.SIGN.CLIENT_TYPE.KUNDE_SMARTPHONE:INSIGNAPP.constants.SIGN.CLIENT_TYPE.BERATER_SMARTPHONE;var oDataStartFotoProcess={sessionid:a_strSessionid,clienttype:clientType,document:INSIGNAPP.pdfviewer.currentDoc>=0?my.docsData.documents[INSIGNAPP.pdfviewer.currentDoc].docid:null};if(annotationID){oDataStartFotoProcess.annotationID=annotationID;}
if(annotationID===false){oDataStartFotoProcess.resetAnnotationID=true;}
var options={url:'rest/signprocess/startfoto',data:JSON.stringify(oDataStartFotoProcess),showOverlay:true};if(INSIGNAPP.config.isGWGModus&&!INSIGNAPP.viewmodel.Main.vorgang.model.canAddGWGImages()){INSIGNAPP.viewmodel.alert.show('error',{message:"alert.waitForFoto.gwg.tomany"});return;}
var oStartFotoProcess=makePostAjax(options);oStartFotoProcess.fail(function(a_oData,a_strTextStatus,a_$XHR){a_oFotoProcess.reject(a_$XHR,a_strTextStatus,a_oData);INSIGNAPP.viewmodel.alert.show('error',{message:a_oData.notification?a_oData.notification.notification:""});});oStartFotoProcess.done(function(a_oData,a_strTextStatus,a_$XHR){if(a_oData.notificationid=='FOTO_METADATEN_ABGELEGT'){var oFotoNotificationRequest=my.requestNotification(a_strSessionid,true,false,[strIdFotoSuccess,strIdFotoAbort,strIdReady],a_oFotoProcess.reject,undefined,oDataStartFotoProcess.clienttype);oFotoNotificationRequest.done(function(a_oData,a_strTextStatus,a_$XHR){if(a_oData.notification.notificationid==strIdReady){my.startFotoProcess(a_strSessionid,a_fnCallback,deviceNames,forceSmartphoneKunde);}else if(a_oData.notification.notificationid==strIdFotoSuccess){a_oFotoProcess.resolve(a_oData,a_strTextStatus,a_$XHR);}else if(a_oData.notification.notificationid==strIdFotoAbort){a_oFotoProcess.reject(a_$XHR,a_strTextStatus,a_oData);}else{a_oFotoProcess.reject(a_$XHR,a_strTextStatus,a_oData);INSIGNAPP.viewmodel.alert.show('error',{message:a_oData.notification.notification});}});var messageId='alert.waitForFoto.message',messageText='',deviceName='';if(INSIGNAPP.config.isGWGModus){messageId=INSIGNAPP.viewmodel.Main.vorgang.model.getGwgDoc()===null?'alert.waitForFoto.gwg.first':'alert.waitForFoto.gwg.second';messageId=INSIGNAPP.viewmodel.Main.vorgang.model.hasGWGImages()?"alert.waitForFoto.gwg.generic":messageId;}
if(typeof deviceNames=="object"&&deviceNames.length>1){messageId='alert.waitForFoto.message.multi';for(var i in deviceNames){deviceName+=i>0?', ':'';if(deviceNames[i].displayName==="UPAD"||deviceNames[i].deviceName==="UPAD"){deviceName+="U-Pad";}
else{deviceName+=deviceNames[i].displayName||deviceNames[i].deviceName;}}}else{if(deviceNames[0].displayName==="UPAD"||deviceNames[0].deviceName==="UPAD"){deviceName="U-Pad";}
else{deviceName=deviceNames[0].displayName||deviceNames[0].deviceName;}}
messageText=INSIGNAPP.config.getMessage({id:messageId,params:[deviceName]});if(clientType===INSIGNAPP.constants.SIGN.CLIENT_TYPE.BERATER_SMARTPHONE&&!deviceNames[0].applos){messageText+=INSIGNAPP.config.getMessage({id:'alert.waitForFotoSign.devicehint',params:[]});}
var links=[];links.push({showLink:INSIGNAPP.config.useAppForKunde||INSIGNAPP.config.useApplosPerMailForKunde||INSIGNAPP.config.useApplosPerSmsForKunde||INSIGNAPP.config.useApplosPerQRCodeForKunde,messageLink:clientType===INSIGNAPP.constants.SIGN.CLIENT_TYPE.KUNDE_SMARTPHONE||(clientType===INSIGNAPP.constants.SIGN.CLIENT_TYPE.BERATER_SMARTPHONE&&INSIGNAPP.config.isUserMode)?'alert.wait.link.kundenText':'alert.wait.link.foto',fnOnClickLink:function(){my.cancelFotoProcess(a_strSessionid,forceSmartphoneKunde);oFotoNotificationRequest.reject();if(clientType===INSIGNAPP.constants.SIGN.CLIENT_TYPE.KUNDE_SMARTPHONE){INSIGNAPP.config.consoleLog('unpair smartphonekunde');INSIGNAPP.data.unpairAllCustomer(a_strSessionid,function(){});}else if(clientType===INSIGNAPP.constants.SIGN.CLIENT_TYPE.BERATER_SMARTPHONE&&INSIGNAPP.config.isUserMode){INSIGNAPP.config.consoleLog('unpair smartphone');INSIGNAPP.data.unpairAllForUser(a_strSessionid,function(){});}
else{oFotoProcess.reject();INSIGNAPP.viewmodel.Upload.makePhoto(true);}}});links.push({showLink:INSIGNAPP.config.hasWebcam,messageLink:'upload.foto.webcam.link',fnOnClickLink:function(){INSIGNAPP.webcam.callWebcam("alertModal");my.cancelFotoProcess(a_strSessionid,forceSmartphoneKunde);oFotoNotificationRequest.reject();INSIGNAPP.viewmodel.alert.remove(iAlertID);}});var alertOption={links:links,message:messageText,messageLabel:'alert.wait.photo.heading',textBeforeBtn:INSIGNAPP.config.getMessage('tan.name')+": "+INSIGNAPP.config.tan,fnOnClose:function(){INSIGNAPP.config.consoleLog('close wait dialog with oFotoNotificationRequest='+oFotoNotificationRequest.state()+' and a_oFotoProcess='+a_oFotoProcess.state());if(oFotoNotificationRequest.state()==='pending'&&a_oFotoProcess.state()==='pending'){my.cancelFotoProcess(a_strSessionid,forceSmartphoneKunde);}
oFotoNotificationRequest.reject();},showCloseBtn:false};var iAlertID=INSIGNAPP.viewmodel.alert.show('wait',alertOption);oFotoNotificationRequest.always(function(){if(iAlertID!==undefined){try{INSIGNAPP.viewmodel.alert.remove(iAlertID);}catch(e){}}});}else if(a_oData.notificationid==strIdFotoSuccess){a_oFotoProcess.resolve(a_oData,a_strTextStatus,a_$XHR);}else if(a_oData.notificationid==strIdReady){my.startFotoProcess(a_strSessionid,a_fnCallback,deviceNames);}else{a_oFotoProcess.reject(a_$XHR,a_strTextStatus,a_oData);}});});oFotoProcess.done(a_fnCallback);return oFotoProcess;};my.setSessionVar=function(json,callback){json.sessionid=INSIGNAPP.config.sessionid;var options={url:'configure/setSessionVar',data:JSON.stringify(json),callbackSuccess:callback,callbackFail:callback}
makePostAjax(options);};my.sendFoto=function(json,callback){var options={url:'rest/store/photoApplos',data:JSON.stringify(json),showOverlay:true,callbackSuccess:callback,callbackFail:callback};makePostAjax(options);}
my.cancelFotoProcess=function(sessionid,forceCustomer){var clientType=(INSIGNAPP.config.isExtern&&!INSIGNAPP.config.isUserMode)||forceCustomer?INSIGNAPP.constants.SIGN.CLIENT_TYPE.KUNDE_SMARTPHONE:INSIGNAPP.constants.SIGN.CLIENT_TYPE.BERATER_SMARTPHONE;var input={sessionid:sessionid,clienttype:clientType};var options={url:'rest/signprocess/cancelfoto',data:JSON.stringify(input),showOverlay:true,callbackSuccess:function(){},callbackFail:function(){}};makePostAjax(options);};my.requestCancelSignProcess=function(requestData){var options={url:'rest/signprocess/cancel',data:JSON.stringify(requestData),showOverlay:true,callbackSuccess:function(){},callbackFail:function(){}};return makePostAjax(options);};my.requestDualscreen=function(data,callback){var options={url:'dualscreen/start',data:JSON.stringify(data),showOverlay:true,callbackSuccess:callback};return makePostAjax(options);}
my.requestPrivate=function(sessionid,value,callback){var options={url:'rest/store/private?value='+value,data:JSON.stringify({sessionid:sessionid}),showOverlay:true,callbackSuccess:callback};return makePostAjax(options);}
my.requestSignProcessStart=function(datastartsignprocess){var options={url:'rest/signprocess/start',data:JSON.stringify(datastartsignprocess),};return makePostAjax(options);};my.dsgvoDeclinedMobile=function(data,callback){var options={url:'rest/signprocess/gdprDeclined',data:JSON.stringify(data),callbackSuccess:callback};return makePostAjax(options);};my.gdprAccept=function(data,callback){var options={url:'rest/signprocess/gdprAccepted',data:JSON.stringify(data),callbackSuccess:callback};if(INSIGNAPP.config.isExtern){INSIGNAPP.config.dsgvoAbfrage=false;}
return makePostAjax(options);};my.gdprStatus=function(data,callback){var options={url:'rest/signprocess/gdprStatus',data:JSON.stringify(data),callbackSuccess:callback};return makePostAjax(options);};my.sendManualReminder=function(options){var data={sessionid:options.sessionid}
var params={};if(data.sessionid!==INSIGNAPP.config.sessionid&&INSIGNAPP.config.sessionid){data.idVorgangsverwaltung=INSIGNAPP.config.sessionid;}
var options={url:'load/sendManualReminder?'+$.param(params),data:JSON.stringify(data),showOverlay:true,showErrorAlert:true,callbackSuccess:options.successCallback};return makePostAjax(options);};function getAessmsValidationStatus(success){var data={sessionid:INSIGNAPP.config.sessionid}
var optionsSend={url:'aessms/getvalidationstatus',data:JSON.stringify(data),showOverlay:true,showErrorAlert:true,callbackSuccess:success};makePostAjax(optionsSend);}
function requestAessmsCode(mobileNr,callback,fail){INSIGNAPP.config.consoleLog('sending aessmsMobilenumber for code...');var jsonSend={mobile:formatRecipientSms(mobileNr),sessionid:INSIGNAPP.config.sessionid};var optionsSend={url:'aessms/requestcode',data:JSON.stringify(jsonSend),showOverlay:true,showErrorAlert:false,callbackSuccess:callback,callbackFail:function(a_$XHR){var msg=parseServerError(a_$XHR.responseJSON);if(!msg||msg.trim().length===0){msg='error.aessms.sms';}
fail(msg);}};makePostAjax(optionsSend);}
function verifyAessmsCode(code,success,fail){INSIGNAPP.config.consoleLog('verifying Aessms code...');var param={verificationCode:code};var data={sessionid:INSIGNAPP.config.sessionid}
var optionsSignMtan={url:'aessms/verifycode?'+$.param(param),data:JSON.stringify(data),showErrorAlert:false,callbackFail:function(a_$XHR){var msg=parseServerError(a_$XHR.responseJSON);if(!msg||msg.trim().length===0){msg='error.aessms.code';}
fail(msg);},callbackSuccess:function(json){INSIGNAPP.config.consoleLog('aessms code verified');success(json);}};makePostAjax(optionsSignMtan);}
function sendMtan(mtanReceiver,callback,fail,sessionid,docid,signatureid){INSIGNAPP.config.consoleLog('sending mTAN...');var jsonSendMtan={docid:docid,signatureid:signatureid,sessionid:sessionid};if(typeof mtanReceiver==='string'){$.extend(jsonSendMtan,{recipientsms:formatRecipientSms(mtanReceiver)});}
var optionsSendMtan={url:'sendmtan',data:JSON.stringify(jsonSendMtan),showOverlay:true,showErrorAlert:false,callbackSuccess:callback,callbackFail:function(a_$XHR){var msg=parseServerError(a_$XHR.responseJSON);if(!msg||msg.trim().length===0){msg='error.mtan.sms';}
fail(msg);}};makePostAjax(optionsSendMtan);}
function validateMtan(mtan,success,fail,sessionid,docid,signatureid,onSignComplete){INSIGNAPP.config.consoleLog('verifying mTAN...');var jsonSignWithMtan={mtan:mtan,signatureid:signatureid,docid:docid,sessionid:sessionid};var optionsSignMtan={url:'signwithmtan',data:JSON.stringify(jsonSignWithMtan),showErrorAlert:false,callbackFail:function(a_$XHR){var msg=parseServerError(a_$XHR.responseJSON);if(!msg||msg.trim().length===0){msg='error.mtan.code';}
fail(msg);},callbackSuccess:function(json){INSIGNAPP.config.consoleLog('mTAN verified');success(json);onSignComplete(json);}};makePostAjax(optionsSignMtan);}
my.sendMtan=sendMtan;my.formatRecipientSms=formatRecipientSms;my.validateMtan=validateMtan;my.requestAessmsCode=requestAessmsCode;my.verifyAessmsCode=verifyAessmsCode;my.getAessmsValidationStatus=getAessmsValidationStatus;my.requestValidation=function(datastartsignprocess,callback){if(INSIGNAPP.config.validationServiceActive){var doc=INSIGNAPP.viewmodel.Main.vorgang.model.getModelDocumentById(datastartsignprocess.docid),cancel=false,post;if(!doc.hasBeenSigned()){var alertWait=INSIGNAPP.viewmodel.alert.show('wait',{messageLabel:'alert.plausi.service.test.heading',message:'plausi.service.test',showCloseBtn:false,showFooter:false,fnOnClickCloseIcn:function(){cancel=true;post.reject();}})
function requestValidationCall(){var options={url:'rest/plausi/validate',data:JSON.stringify(datastartsignprocess),callbackSuccess:function(json){if(cancel){return;}
_.forEach(doc.getAnnotations(),function(obj){delete obj.validationError});INSIGNAPP.viewmodel.alert.remove(alertWait);callback();},callbackFail:function(a_$XHR){if(cancel){return;}
_.forEach(doc.getAnnotations(),function(obj){delete obj.validationError});var json=a_$XHR.responseJSON;var idMap=INSIGNAPP.viewmodel.FormEditor.getAnnotationIDMap(),docIndex=doc.getDocIndex(),hasErrors=false,noSkip=json.noSkip===true;INSIGNAPP.viewmodel.alert.remove(alertWait);if(json.error===5){INSIGNAPP.viewmodel.alert.show('error',{message:INSIGNAPP.config.getMessage('plausi.service.error'),fnOnClose:function(){callback();}});return;}
var anno,invalidMap={},counter=0;_.forEach(Object.keys(json.fields),function(key){counter++;anno=doc.getAnnotationById(key);const $page=$("#"+idMap[docIndex+"_"+key]);if(anno){hasErrors=true;anno.validationError=json.fields[key];var $field=$page.find("input");if($field.length===0){$field=$page.find("textarea");}
if($field.length>0){INSIGNAPP.viewmodel.FormEditor.setPopover($field,json.fields[key],true,anno,$page);$field.popover('show');}}else{invalidMap[key]=json.fields[key];console.error("no annotation for key: "+key+" with errormessage: "+json.fields[key]);}});_.forEach(Object.keys(json.warnFields),function(key){counter++;anno=doc.getAnnotationById(key);const $page=$("#"+idMap[docIndex+"_"+key]);if(anno){anno.validationWarning=json.warnFields[key];var $field=$page.find("input");if($field.length===0){$field=$page.find("textarea");}
if($field.length>0){INSIGNAPP.viewmodel.FormEditor.setPopover($field,json.warnFields[key],true,anno,$page);$field.popover('show');}}else{invalidMap[key]=json.warnFields[key];console.error("no annotation for key: "+key+" with warningmessage: "+json.fields[key]);}});if(Object.keys(invalidMap).length>0){INSIGNAPP.viewmodel.alert.show('error',{message:INSIGNAPP.config.getMessage('error.validation.wrongkey'),appendMap:invalidMap});return;}
var modi=doc.modi,modiAvailable=modi.modusIsAvailable(INSIGNAPP.constants.MODUS_ID.EDIT);if(doc.allowEdit()&&modiAvailable&&modiAvailable.available&&modiAvailable.modus.isAktivierbar()){INSIGNAPP.viewmodel.Modus.changeModus(modi,modelVorgang,INSIGNAPP.view.Aushaendigen,INSIGNAPP.constants.MODUS_ID.EDIT);}
if(counter===0){var plausi=INSIGNAPP.viewmodel.Plausi.show("mitAbhilfe",{abhilfeBtnFunction:function(){$('#plausiPopup').modal('hide');callback();},aktion:'plausi.aktion.sign',abhilfeBtnText:"plausi.warning.ignore",showAbhilfeBtn:!noSkip,grund:json.message,showReasonOnly:true});return;}
var plausi=INSIGNAPP.viewmodel.Plausi.show("mitAbhilfe",{abhilfeBtnFunction:function(){var annos=doc.getAnnotations();for(var i=0;i{delayValidation();});}else{$(".popover.popoverValidationService").remove();maxTriesReached=true;}}else{requestValidationCall();}}
if(INSIGNAPP.config.saveInProgress){sleep(ms).then(()=>{delayValidation();});$(".popover.popoverValidationService").remove();if(maxTriesReached){return false;}}else{$(".popover.popoverValidationService").remove();requestValidationCall();}}else{callback();}}else{callback();}}
function sleep(ms){return new Promise(resolve=>setTimeout(resolve,ms));}
my.decideProcessManagerLocation=function(oldlocation,oldsessionidname){var change=false,location=oldlocation,sessionidname=oldsessionidname;if(INSIGNAPP.config.isStartUser){change=true
location='start/gallery';sessionidname='insignsessionid';}
return{location:location,change:change,sessionidname:sessionidname};}
my.submitUrlAsForm=function(location,data){$('#urlsubmit').remove();var form=$('