send/assets/cryptofill.js
2018-03-28 22:03:46 -07:00

17 lines
No EOL
99 KiB
JavaScript

var liner=function(e){function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}var t={};return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=16)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),function(e){function n(e){for(var r,t=e,n=/[^%](%\d+)/g,a=[];r=n.exec(t);)a.push({arg:r[1],index:r.index});for(var o=a.length-1;o>=0;o--){var i=a[o],s=i.arg.substring(1),c=i.index+1;t=t.substring(0,c)+arguments[+s]+t.substring(c+1+s.length)}return t=t.replace("%%","%")}function a(e){var r;r="string"==typeof e?{name:e}:e,p.checkAlgorithm(r);var t=e;return t.hash&&(t.hash=a(t.hash)),r}function o(e,r){if(!e)throw new s("Parameter '"+r+"' is required and cant be empty");if("undefined"!=typeof Buffer&&Buffer.isBuffer(e))return new Uint8Array(e);if(ArrayBuffer.isView(e)){var t=e.map(function(e){return e});return new Uint8Array(t.buffer)}if(e instanceof ArrayBuffer)return new Uint8Array(e);throw new s("Incoming parameter '"+r+"' has wrong data type. Must be ArrayBufferView or ArrayBuffer")}t.d(r,"WebCryptoError",function(){return s}),t.d(r,"AlgorithmError",function(){return c}),t.d(r,"CryptoKeyError",function(){return u}),t.d(r,"PrepareAlgorithm",function(){return a}),t.d(r,"PrepareData",function(){return o}),t.d(r,"BaseCrypto",function(){return p}),t.d(r,"AlgorithmNames",function(){return h}),t.d(r,"Base64Url",function(){return y}),t.d(r,"SubtleCrypto",function(){return x}),t.d(r,"Aes",function(){return A}),t.d(r,"AesAlgorithmError",function(){return m}),t.d(r,"AesWrapKey",function(){return w}),t.d(r,"AesEncrypt",function(){return v}),t.d(r,"AesECB",function(){return g}),t.d(r,"AesCBC",function(){return C}),t.d(r,"AesCTR",function(){return k}),t.d(r,"AesGCM",function(){return d}),t.d(r,"AesKW",function(){return b}),t.d(r,"RsaKeyGenParamsError",function(){return G}),t.d(r,"RsaHashedImportParamsError",function(){return M}),t.d(r,"Rsa",function(){return B}),t.d(r,"RsaSSA",function(){return T}),t.d(r,"RsaPSSParamsError",function(){return D}),t.d(r,"RsaPSS",function(){return j}),t.d(r,"RsaOAEPParamsError",function(){return W}),t.d(r,"RsaOAEP",function(){return H}),t.d(r,"EcKeyGenParamsError",function(){return U}),t.d(r,"Ec",function(){return _}),t.d(r,"EcAlgorithmError",function(){return K}),t.d(r,"EcDSA",function(){return S}),t.d(r,"EcDH",function(){return O}),t.d(r,"ShaAlgorithms",function(){return E}),t.d(r,"Sha",function(){return P});var i=t(8),s=function(e){function r(r){for(var t=[],a=1;a<arguments.length;a++)t[a-1]=arguments[a];var o=e.call(this)||this;o.code=0,o.message=n.apply(void 0,[r].concat(t));var i=new Error(o.message);return i.name=o.constructor.name,o.stack=i.stack,o}return Object(i.a)(r,e),r.NOT_SUPPORTED="Method is not supported",r}(Error),c=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=1,r}return Object(i.a)(r,e),r.PARAM_REQUIRED="Algorithm hasn't got required paramter '%1'",r.PARAM_WRONG_TYPE="Algorithm has got wrong type for paramter '%1'. Must be %2",r.PARAM_WRONG_VALUE="Algorithm has got wrong value for paramter '%1'. Must be %2",r.WRONG_ALG_NAME="Algorithm has got wrong name '%1'. Must be '%2'",r.UNSUPPORTED_ALGORITHM="Algorithm '%1' is not supported",r.WRONG_USAGE="Algorithm doesn't support key usage '%1'",r}(s),u=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=3,r}return Object(i.a)(r,e),r.EMPTY_KEY="CryptoKey is empty",r.WRONG_KEY_ALG="CryptoKey has wrong algorithm '%1'. Must be '%2'",r.WRONG_KEY_TYPE="CryptoKey has wrong type '%1'. Must be '%2'",r.WRONG_KEY_USAGE="CryptoKey has wrong key usage. Must be '%1'",r.NOT_EXTRACTABLE="CryptoKey is not extractable",r.WRONG_FORMAT="CryptoKey has '%1' type. It can be used with '%2' format",r.UNKNOWN_FORMAT="Unknown format in use '%1'. Must be one of 'raw', 'pkcs8', 'spki' or 'jwk'",r.ALLOWED_FORMAT="Wrong format value '%1'. Must be %2",r}(s),p=function(){function e(){}return e.checkAlgorithm=function(e){if("object"!=typeof e)throw new TypeError("Wrong algorithm data type. Must be Object");if(!e.name)throw new c(c.PARAM_REQUIRED,"name")},e.checkAlgorithmParams=function(e){this.checkAlgorithm(e)},e.checkKey=function(e,r,t,n){if(void 0===t&&(t=null),void 0===n&&(n=null),!e)throw new u(u.EMPTY_KEY);var a=e.algorithm;if(this.checkAlgorithm(a),r&&a.name.toUpperCase()!==r.toUpperCase())throw new u(u.WRONG_KEY_ALG,a.name,r);if(t&&(!e.type||e.type.toUpperCase()!==t.toUpperCase()))throw new u(u.WRONG_KEY_TYPE,e.type,t);if(n&&!e.usages.some(function(e){return n.toUpperCase()===e.toUpperCase()}))throw new u(u.WRONG_KEY_USAGE,n)},e.checkWrappedKey=function(e){if(!e.extractable)throw new u(u.NOT_EXTRACTABLE)},e.checkKeyUsages=function(e){if(!e||!e.length)throw new s("Parameter 'keyUsages' cannot be empty.")},e.checkFormat=function(e,r){switch(e.toLowerCase()){case"raw":if(r&&"secret"!==r.toLowerCase()&&r&&"public"!==r.toLowerCase())throw new u(u.WRONG_FORMAT,r,"raw");break;case"pkcs8":if(r&&"private"!==r.toLowerCase())throw new u(u.WRONG_FORMAT,r,"pkcs8");break;case"spki":if(r&&"public"!==r.toLowerCase())throw new u(u.WRONG_FORMAT,r,"spki");break;case"jwk":break;default:throw new u(u.UNKNOWN_FORMAT,e)}},e.generateKey=function(e,r,t){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.digest=function(e,r){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.sign=function(e,r,t){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.verify=function(e,r,t,n){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.encrypt=function(e,r,t){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.decrypt=function(e,r,t){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.deriveBits=function(e,r,t){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.deriveKey=function(e,r,t,n,a){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.exportKey=function(e,r){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.importKey=function(e,r,t,n,a){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.wrapKey=function(e,r,t,n){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e.unwrapKey=function(e,r,t,n,a,o,i){return new Promise(function(e,r){throw new s(s.NOT_SUPPORTED)})},e}(),h={RsaSSA:"RSASSA-PKCS1-v1_5",RsaPSS:"RSA-PSS",RsaOAEP:"RSA-OAEP",AesECB:"AES-ECB",AesCTR:"AES-CTR",AesCMAC:"AES-CMAC",AesGCM:"AES-GCM",AesCBC:"AES-CBC",AesKW:"AES-KW",Sha1:"SHA-1",Sha256:"SHA-256",Sha384:"SHA-384",Sha512:"SHA-512",EcDSA:"ECDSA",EcDH:"ECDH",Hmac:"HMAC",Pbkdf2:"PBKDF2",Hkdf:"HKDF"};if("undefined"==typeof self){var f=e;f.btoa=function(e){return new Buffer(e,"binary").toString("base64")},f.atob=function(e){return new Buffer(e,"base64").toString("binary")}}var y=function(){function e(){}return e.encode=function(e){var r=this.buffer2string(e);return btoa(r).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},e.decode=function(e){for(;e.length%4;)e+="=";var r=e.replace(/\-/g,"+").replace(/_/g,"/");return this.string2buffer(atob(r))},e.buffer2string=function(e){for(var r="",t=e.length,n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r},e.string2buffer=function(e){for(var r=new Uint8Array(e.length),t=e.length,n=0;n<t;n++)r[n]=e.charCodeAt(n);return r},e}(),l=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=7,r}return Object(i.a)(r,e),r}(c),A=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkKeyUsages=function(r){var t=this;e.checkKeyUsages.call(this,r);var n=r.filter(function(e){return-1===t.KEY_USAGES.indexOf(e)});if(n.length)throw new c(c.WRONG_USAGE,n.join(", "))},r.checkAlgorithm=function(e){if(e.name.toUpperCase()!==this.ALG_NAME.toUpperCase())throw new c(c.WRONG_ALG_NAME,e.name,this.ALG_NAME)},r.checkKeyGenParams=function(e){switch(e.length){case 128:case 192:case 256:break;default:throw new l(l.PARAM_WRONG_VALUE,"length","128, 192 or 256")}},r.generateKey=function(e,r,t){var n=this;return new Promise(function(r,a){n.checkAlgorithm(e),n.checkKeyGenParams(e),n.checkKeyUsages(t),r(void 0)})},r.exportKey=function(e,r){var t=this;return new Promise(function(n,a){t.checkKey(r,t.ALG_NAME),t.checkFormat(e,r.type),n(void 0)})},r.importKey=function(e,r,t,n,a){var o=this;return new Promise(function(r,n){if(o.checkAlgorithm(t),o.checkFormat(e),"raw"!==e.toLowerCase()&&"jwk"!==e.toLowerCase())throw new u(u.ALLOWED_FORMAT,e,"'jwk' or 'raw'");o.checkKeyUsages(a),r(void 0)})},r.ALG_NAME="",r.KEY_USAGES=[],r}(p),m=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=8,r}return Object(i.a)(r,e),r}(c),w=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.wrapKey=function(e,r,t,n){var a=this;return new Promise(function(o,i){a.checkAlgorithmParams(n),a.checkKey(t,a.ALG_NAME,"secret","wrapKey"),a.checkWrappedKey(r),a.checkFormat(e,r.type),o(void 0)})},r.unwrapKey=function(e,r,t,n,a,o,i){var s=this;return new Promise(function(r,a){s.checkAlgorithmParams(n),s.checkKey(t,s.ALG_NAME,"secret","unwrapKey"),s.checkFormat(e),r(void 0)})},r}(A),v=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.encrypt=function(e,r,t){var n=this;return new Promise(function(t,a){n.checkAlgorithmParams(e),n.checkKey(r,n.ALG_NAME,"secret","encrypt"),t(void 0)})},r.decrypt=function(e,r,t){var n=this;return new Promise(function(t,a){n.checkAlgorithmParams(e),n.checkKey(r,n.ALG_NAME,"secret","decrypt"),t(void 0)})},r.KEY_USAGES=["encrypt","decrypt","wrapKey","unwrapKey"],r}(w),g=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.ALG_NAME=h.AesECB,r}(v),C=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),!e.iv)throw new m(m.PARAM_REQUIRED,"iv");if(!(ArrayBuffer.isView(e.iv)||e.iv instanceof ArrayBuffer))throw new m(m.PARAM_WRONG_TYPE,"iv","ArrayBufferView or ArrayBuffer");if(16!==e.iv.byteLength)throw new m(m.PARAM_WRONG_VALUE,"iv","ArrayBufferView or ArrayBuffer with size 16")},r.ALG_NAME=h.AesCBC,r}(v),k=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),!e.counter||!(ArrayBuffer.isView(e.counter)||e.counter instanceof ArrayBuffer))throw new m(m.PARAM_WRONG_TYPE,"counter","ArrayBufferView or ArrayBuffer");if(16!==e.counter.byteLength)throw new m(m.PARAM_WRONG_VALUE,"counter","ArrayBufferView or ArrayBuffer with size 16");if(!(e.length>0&&e.length<=128))throw new m(m.PARAM_WRONG_VALUE,"length","number [1-128]")},r.ALG_NAME=h.AesCTR,r}(v),d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),e.additionalData&&!(ArrayBuffer.isView(e.additionalData)||e.additionalData instanceof ArrayBuffer))throw new m(m.PARAM_WRONG_TYPE,"additionalData","ArrayBufferView or ArrayBuffer");if(!e.iv)throw new m(m.PARAM_REQUIRED,"iv");if(!(ArrayBuffer.isView(e.iv)||e.iv instanceof ArrayBuffer))throw new m(m.PARAM_WRONG_TYPE,"iv","ArrayBufferView or ArrayBuffer");if(e.tagLength){if(![32,64,96,104,112,120,128].some(function(r){return r===e.tagLength}))throw new m(m.PARAM_WRONG_VALUE,"tagLength","32, 64, 96, 104, 112, 120 or 128")}},r.ALG_NAME=h.AesGCM,r}(v),b=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithmParams=function(e){this.checkAlgorithm(e)},r.ALG_NAME=h.AesKW,r.KEY_USAGES=["wrapKey","unwrapKey"],r}(w),E=[h.Sha1,h.Sha256,h.Sha384,h.Sha512].join(" | "),P=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithm=function(r){var t;switch(t="string"==typeof r?{name:r}:r,e.checkAlgorithm.call(this,t),t.name.toUpperCase()){case h.Sha1:case h.Sha256:case h.Sha384:case h.Sha512:break;default:throw new c(c.WRONG_ALG_NAME,t.name,E)}},r.digest=function(e,r){var t=this;return new Promise(function(r,n){t.checkAlgorithm(e),r(void 0)})},r}(p),U=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=9,r}return Object(i.a)(r,e),r}(c),_=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithm=function(e){if(e.name.toUpperCase()!==this.ALG_NAME.toUpperCase())throw new c(c.WRONG_ALG_NAME,e.name,this.ALG_NAME)},r.checkKeyGenParams=function(e){if(!e.namedCurve)throw new U(U.PARAM_REQUIRED,"namedCurve");if("string"!=typeof e.namedCurve)throw new U(U.PARAM_WRONG_TYPE,"namedCurve","string");switch(e.namedCurve.toUpperCase()){case"P-256":case"K-256":case"P-384":case"P-521":break;default:throw new U(U.PARAM_WRONG_VALUE,"namedCurve","K-256, P-256, P-384 or P-521")}},r.checkKeyGenUsages=function(e){var r=this;e.forEach(function(e){var t=0;for(t;t<r.KEY_USAGES.length&&r.KEY_USAGES[t].toLowerCase()!==e.toLowerCase();t++);if(t===r.KEY_USAGES.length)throw new s("Unsupported key usage '"+e+"'. Should be one of ["+r.KEY_USAGES.join(", ")+"]")})},r.generateKey=function(e,r,t){var n=this;return new Promise(function(r,a){n.checkAlgorithm(e),n.checkKeyGenParams(e),n.checkKeyGenUsages(t),r(void 0)})},r.exportKey=function(e,r){var t=this;return new Promise(function(n,a){t.checkKey(r,t.ALG_NAME),e&&"raw"===e.toLowerCase()&&"public"===r.type||t.checkFormat(e,r.type),n(void 0)})},r.importKey=function(e,r,t,n,a){var o=this;return new Promise(function(r,n){o.checkKeyGenParams(t),o.checkFormat(e),o.checkKeyGenUsages(a),r(void 0)})},r.ALG_NAME="",r.KEY_USAGES=[],r}(p),K=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=10,r}return Object(i.a)(r,e),r}(c),S=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithmParams=function(e){this.checkAlgorithm(e),P.checkAlgorithm(e.hash)},r.sign=function(e,r,t){var n=this;return new Promise(function(t,a){n.checkAlgorithmParams(e),n.checkKey(r,n.ALG_NAME,"private","sign"),t(void 0)})},r.verify=function(e,r,t,n){var a=this;return new Promise(function(t,n){a.checkAlgorithmParams(e),a.checkKey(r,a.ALG_NAME,"public","verify"),t(void 0)})},r.ALG_NAME=h.EcDSA,r.KEY_USAGES=["sign","verify","deriveKey","deriveBits"],r}(_),O=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkDeriveParams=function(e){if(this.checkAlgorithm(e),!e.public)throw new K(K.PARAM_REQUIRED,"public");this.checkKey(e.public,this.ALG_NAME,"public")},r.deriveBits=function(e,r,t){var n=this;return new Promise(function(t,a){n.checkDeriveParams(e),n.checkKey(r,n.ALG_NAME,"private","deriveBits"),t(void 0)})},r.deriveKey=function(e,r,t,n,a){var o=this;return new Promise(function(n,a){switch(o.checkDeriveParams(e),o.checkKey(r,o.ALG_NAME,"private","deriveKey"),p.checkAlgorithm(t),t.name.toUpperCase()){case h.AesCBC:C.checkKeyGenParams(t);break;case h.AesCTR:k.checkKeyGenParams(t);break;case h.AesGCM:d.checkKeyGenParams(t);break;case h.AesKW:b.checkKeyGenParams(t);break;default:throw new K("Unsupported name '"+t.name+"' for algorithm in param 'derivedKeyType'")}n(void 0)})},r.ALG_NAME=h.EcDH,r.KEY_USAGES=["deriveKey","deriveBits"],r}(_),L=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithm=function(e){if(e.name.toUpperCase()!==this.ALG_NAME.toUpperCase())throw new c(c.WRONG_ALG_NAME,e.name,this.ALG_NAME)},r.checkKeyGenParams=function(e){if("length"in e&&!(e.length>0&&e.length<=512))throw new c(c.PARAM_WRONG_VALUE,"length","more 0 and less than 512")},r.checkKeyGenUsages=function(e){var r=this;this.checkKeyUsages(e),e.forEach(function(e){var t=0;for(t;t<r.KEY_USAGES.length&&r.KEY_USAGES[t].toLowerCase()!==e.toLowerCase();t++);if(t===r.KEY_USAGES.length)throw new s("Unsupported key usage '"+e+"'. Should be one of ["+r.KEY_USAGES.join(", ")+"]")})},r.generateKey=function(e,r,t){var n=this;return new Promise(function(r,a){n.checkAlgorithm(e),n.checkKeyGenParams(e),n.checkKeyGenUsages(t),r(void 0)})},r.exportKey=function(e,r){var t=this;return new Promise(function(n,a){t.checkKey(r,t.ALG_NAME),t.checkFormat(e,r.type),n(void 0)})},r.importKey=function(e,r,t,n,a){var o=this;return new Promise(function(r,n){if(o.checkAlgorithm(t),o.checkFormat(e),"raw"!==e.toLowerCase()&&"jwk"!==e.toLowerCase())throw new u(u.ALLOWED_FORMAT,e,"'jwk' or 'raw'");o.checkKeyGenUsages(a),r(void 0)})},r.sign=function(e,r,t){var n=this;return new Promise(function(t,a){n.checkAlgorithmParams(e),n.checkKey(r,n.ALG_NAME,"secret","sign"),t(void 0)})},r.verify=function(e,r,t,n){var a=this;return new Promise(function(t,n){a.checkAlgorithmParams(e),a.checkKey(r,a.ALG_NAME,"secret","verify"),t(void 0)})},r.ALG_NAME=h.Hmac,r.KEY_USAGES=["sign","verify"],r}(p),R=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithm=function(e){if(e.name.toUpperCase()!==this.ALG_NAME.toUpperCase())throw new c(c.WRONG_ALG_NAME,e.name,this.ALG_NAME)},r.checkDeriveParams=function(e){if(this.checkAlgorithm(e),!e.salt)throw new c(c.PARAM_REQUIRED,"salt");if(!(ArrayBuffer.isView(e.salt)||e.salt instanceof ArrayBuffer))throw new c(c.PARAM_WRONG_TYPE,"salt","ArrayBuffer or ArrayBufferView");if(!e.info)throw new c(c.PARAM_REQUIRED,"info");if(!(ArrayBuffer.isView(e.info)||e.info instanceof ArrayBuffer))throw new c(c.PARAM_WRONG_TYPE,"info","ArrayBuffer or ArrayBufferView");if(!e.hash)throw new c(c.PARAM_REQUIRED,"hash");var r=a(e.hash);P.checkAlgorithm(r)},r.importKey=function(e,r,t,n,a){var o=this;return Promise.resolve().then(function(){if(n)throw new s("KDF keys must set extractable=false");if(o.checkAlgorithm(t),o.checkFormat(e),"raw"!==e.toLowerCase())throw new u(u.ALLOWED_FORMAT,e,"'raw'");o.checkKeyUsages(a)})},r.deriveKey=function(e,r,t,n,a){var o=this;return Promise.resolve().then(function(){switch(o.checkDeriveParams(e),o.checkKey(r,o.ALG_NAME,"secret","deriveKey"),p.checkAlgorithm(t),t.name.toUpperCase()){case h.AesCBC:C.checkKeyGenParams(t),C.checkKeyUsages(a);break;case h.AesCTR:k.checkKeyGenParams(t),k.checkKeyUsages(a);break;case h.AesGCM:d.checkKeyGenParams(t),d.checkKeyUsages(a);break;case h.AesKW:b.checkKeyGenParams(t),b.checkKeyUsages(a);break;case h.Hmac:L.checkKeyGenParams(t),L.checkKeyUsages(a);break;default:throw new c(c.UNSUPPORTED_ALGORITHM,t)}})},r.deriveBits=function(e,r,t){var n=this;return Promise.resolve().then(function(){if(n.checkDeriveParams(e),n.checkKey(r,n.ALG_NAME,"secret","deriveBits"),!t||"number"!=typeof t)throw new s("Parameter 'length' must be Number and more than 0")})},r.ALG_NAME=h.Hkdf,r.KEY_USAGES=["deriveKey","deriveBits"],r}(p),N=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithm=function(e){if(e.name.toUpperCase()!==this.ALG_NAME.toUpperCase())throw new c(c.WRONG_ALG_NAME,e.name,this.ALG_NAME)},r.checkDeriveParams=function(e){if(this.checkAlgorithm(e),!e.salt)throw new c(c.PARAM_REQUIRED,"salt");if(!(ArrayBuffer.isView(e.salt)||e.salt instanceof ArrayBuffer))throw new c(c.PARAM_WRONG_TYPE,"salt","ArrayBuffer or ArrayBufferView");if(!e.iterations)throw new c(c.PARAM_REQUIRED,"iterations");if(!e.hash)throw new c(c.PARAM_REQUIRED,"hash");var r=a(e.hash);P.checkAlgorithm(r)},r.importKey=function(e,r,t,n,a){var o=this;return Promise.resolve().then(function(){if(n)throw new s("KDF keys must set extractable=false");if(o.checkAlgorithm(t),o.checkFormat(e),"raw"!==e.toLowerCase())throw new u(u.ALLOWED_FORMAT,e,"'raw'");o.checkKeyUsages(a)})},r.deriveKey=function(e,r,t,n,a){var o=this;return Promise.resolve().then(function(){switch(o.checkDeriveParams(e),o.checkKey(r,o.ALG_NAME,"secret","deriveKey"),p.checkAlgorithm(t),t.name.toUpperCase()){case h.AesCBC:C.checkKeyGenParams(t),C.checkKeyUsages(a);break;case h.AesCTR:k.checkKeyGenParams(t),k.checkKeyUsages(a);break;case h.AesGCM:d.checkKeyGenParams(t),d.checkKeyUsages(a);break;case h.AesKW:b.checkKeyGenParams(t),b.checkKeyUsages(a);break;case h.Hmac:L.checkKeyGenParams(t),L.checkKeyUsages(a);break;default:throw new c(c.UNSUPPORTED_ALGORITHM,t)}})},r.deriveBits=function(e,r,t){var n=this;return Promise.resolve().then(function(){if(n.checkDeriveParams(e),n.checkKey(r,n.ALG_NAME,"secret","deriveBits"),!t||"number"!=typeof t)throw new s("Parameter 'length' must be Number and more than 0")})},r.ALG_NAME=h.Pbkdf2,r.KEY_USAGES=["deriveKey","deriveBits"],r}(p),G=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=2,r}return Object(i.a)(r,e),r}(c),M=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=6,r}return Object(i.a)(r,e),r}(c),B=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithm=function(e){if(e.name.toUpperCase()!==this.ALG_NAME.toUpperCase())throw new c(c.WRONG_ALG_NAME,e.name,this.ALG_NAME)},r.checkImportAlgorithm=function(e){if(this.checkAlgorithm(e),!e.hash)throw new M(M.PARAM_REQUIRED,"hash");P.checkAlgorithm(e.hash)},r.checkKeyGenParams=function(e){var r=e.modulusLength;if(!(r>=256&&r<=16384)||r%8)throw new G(G.PARAM_WRONG_VALUE,"modulusLength"," a multiple of 8 bits and >= 256 and <= 16384");var t=e.publicExponent;if(!t)throw new G(G.PARAM_REQUIRED,"publicExponent");if(!ArrayBuffer.isView(t))throw new G(G.PARAM_WRONG_TYPE,"publicExponent","ArrayBufferView");if(3!==t[0]&&(1!==t[0]||0!==t[1]||1!==t[2]))throw new G(G.PARAM_WRONG_VALUE,"publicExponent","Uint8Array([3]) | Uint8Array([1, 0, 1])");if(!e.hash)throw new G(G.PARAM_REQUIRED,"hash",E);P.checkAlgorithm(e.hash)},r.checkKeyGenUsages=function(e){var r=this;this.checkKeyUsages(e),e.forEach(function(e){var t=0;for(t;t<r.KEY_USAGES.length&&r.KEY_USAGES[t].toLowerCase()!==e.toLowerCase();t++);if(t===r.KEY_USAGES.length)throw new s("Unsupported key usage '"+e+"'. Should be one of ["+r.KEY_USAGES.join(", ")+"]")})},r.generateKey=function(e,r,t){var n=this;return new Promise(function(r,a){n.checkAlgorithm(e),n.checkKeyGenParams(e),n.checkKeyGenUsages(t),r(void 0)})},r.exportKey=function(e,r){var t=this;return new Promise(function(n,a){t.checkKey(r,t.ALG_NAME),t.checkFormat(e,r.type),n(void 0)})},r.importKey=function(e,r,t,n,a){var o=this;return new Promise(function(r,n){if(o.checkImportAlgorithm(t),o.checkFormat(e),"raw"===e.toLowerCase())throw new u(u.ALLOWED_FORMAT,e,"'JsonWebKey', 'pkcs8' or 'spki'");o.checkKeyGenUsages(a),r(void 0)})},r.ALG_NAME="",r.KEY_USAGES=[],r}(p),T=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.sign=function(e,r,t){var n=this;return new Promise(function(t,a){n.checkAlgorithmParams(e),n.checkKey(r,n.ALG_NAME,"private","sign"),t(void 0)})},r.verify=function(e,r,t,n){var a=this;return new Promise(function(t,n){a.checkAlgorithmParams(e),a.checkKey(r,a.ALG_NAME,"public","verify"),t(void 0)})},r.ALG_NAME=h.RsaSSA,r.KEY_USAGES=["sign","verify"],r}(B),D=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=4,r}return Object(i.a)(r,e),r}(c),j=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithmParams=function(r){var t=r;if(e.checkAlgorithmParams.call(this,t),!t.saltLength)throw new D(D.PARAM_REQUIRED,"saltLength");if(t.saltLength<0)throw new D("Parameter 'saltLength' is outside of numeric range")},r.ALG_NAME=h.RsaPSS,r}(T),W=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=5,r}return Object(i.a)(r,e),r}(c),H=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Object(i.a)(r,e),r.checkAlgorithmParams=function(e){if(e.label&&!(ArrayBuffer.isView(e.label)||e.label instanceof ArrayBuffer))throw new W(W.PARAM_WRONG_TYPE,"label","ArrayBufferView or ArrayBuffer")},r.encrypt=function(e,r,t){var n=this;return new Promise(function(t,a){n.checkAlgorithmParams(e),n.checkKey(r,n.ALG_NAME,"public","encrypt"),t(void 0)})},r.decrypt=function(e,r,t){var n=this;return new Promise(function(t,a){n.checkAlgorithmParams(e),n.checkKey(r,n.ALG_NAME,"private","decrypt"),t(void 0)})},r.wrapKey=function(e,r,t,n){var a=this;return new Promise(function(o,i){a.checkAlgorithmParams(n),a.checkKey(t,a.ALG_NAME,"public","wrapKey"),a.checkWrappedKey(r),a.checkFormat(e,r.type),o(void 0)})},r.unwrapKey=function(e,r,t,n,a,o,i){var s=this;return new Promise(function(r,a){s.checkAlgorithmParams(n),s.checkKey(t,s.ALG_NAME,"private","unwrapKey"),s.checkFormat(e),r(void 0)})},r.ALG_NAME=h.RsaOAEP,r.KEY_USAGES=["encrypt","decrypt","wrapKey","unwrapKey"],r}(B),x=function(){function e(){}return e.prototype.generateKey=function(e,r,t){return new Promise(function(n,o){var i=a(e),s=p;switch(i.name.toUpperCase()){case h.RsaSSA.toUpperCase():s=T;break;case h.RsaOAEP.toUpperCase():s=H;break;case h.RsaPSS.toUpperCase():s=j;break;case h.AesECB.toUpperCase():s=g;break;case h.AesCBC.toUpperCase():s=C;break;case h.AesCTR.toUpperCase():s=k;break;case h.AesGCM.toUpperCase():s=d;break;case h.AesKW.toUpperCase():s=b;break;case h.EcDSA.toUpperCase():s=S;break;case h.EcDH.toUpperCase():s=O;break;case h.Hmac.toUpperCase():s=L;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,i.name)}s.generateKey(i,r,t).then(n,o)})},e.prototype.digest=function(e,r){return new Promise(function(t,n){var i=a(e),s=o(r,"data"),u=p;switch(i.name.toUpperCase()){case h.Sha1.toUpperCase():case h.Sha256.toUpperCase():case h.Sha384.toUpperCase():case h.Sha512.toUpperCase():u=P;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,i.name)}u.digest(i,s).then(t,n)})},e.prototype.sign=function(e,r,t){return new Promise(function(n,i){var s=a(e),u=o(t,"data"),f=p;switch(s.name.toUpperCase()){case h.RsaSSA.toUpperCase():f=T;break;case h.RsaPSS.toUpperCase():f=j;break;case h.EcDSA.toUpperCase():f=S;break;case h.Hmac.toUpperCase():f=L;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,s.name)}f.sign(s,r,u).then(n,i)})},e.prototype.verify=function(e,r,t,n){return new Promise(function(t,i){var s=a(e),u=o(n,"signature"),f=o(n,"data"),y=p;switch(s.name.toUpperCase()){case h.RsaSSA.toUpperCase():y=T;break;case h.RsaPSS.toUpperCase():y=j;break;case h.EcDSA.toUpperCase():y=S;break;case h.Hmac.toUpperCase():y=L;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,s.name)}y.verify(s,r,u,f).then(t,i)})},e.prototype.encrypt=function(e,r,t){return new Promise(function(n,i){var s=a(e),u=o(t,"data"),f=p;switch(s.name.toUpperCase()){case h.RsaOAEP.toUpperCase():f=H;break;case h.AesECB.toUpperCase():f=g;break;case h.AesCBC.toUpperCase():f=C;break;case h.AesCTR.toUpperCase():f=k;break;case h.AesGCM.toUpperCase():f=d;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,s.name)}f.encrypt(s,r,u).then(n,i)})},e.prototype.decrypt=function(e,r,t){return new Promise(function(n,i){var s=a(e),u=o(t,"data"),f=p;switch(s.name.toUpperCase()){case h.RsaOAEP.toUpperCase():f=H;break;case h.AesECB.toUpperCase():f=g;break;case h.AesCBC.toUpperCase():f=C;break;case h.AesCTR.toUpperCase():f=k;break;case h.AesGCM.toUpperCase():f=d;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,s.name)}f.decrypt(s,r,u).then(n,i)})},e.prototype.deriveBits=function(e,r,t){return new Promise(function(n,o){var i=a(e),s=p;switch(i.name.toUpperCase()){case h.EcDH.toUpperCase():s=O;break;case h.Pbkdf2.toUpperCase():s=N;break;case h.Hkdf.toUpperCase():s=R;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,i.name)}s.deriveBits(i,r,t).then(n,o)})},e.prototype.deriveKey=function(e,r,t,n,o){return new Promise(function(i,s){var u=a(e),f=a(t),y=p;switch(u.name.toUpperCase()){case h.EcDH.toUpperCase():y=O;break;case h.Pbkdf2.toUpperCase():y=N;break;case h.Hkdf.toUpperCase():y=R;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,u.name)}y.deriveKey(u,r,f,n,o).then(i,s)})},e.prototype.exportKey=function(e,r){return new Promise(function(t,n){if(p.checkKey(r),!r.extractable)throw new u(u.NOT_EXTRACTABLE);var a=p;switch(r.algorithm.name.toUpperCase()){case h.RsaSSA.toUpperCase():a=T;break;case h.RsaPSS.toUpperCase():a=j;break;case h.AesECB.toUpperCase():a=g;break;case h.RsaOAEP.toUpperCase():a=H;break;case h.AesCBC.toUpperCase():a=C;break;case h.AesCTR.toUpperCase():a=k;break;case h.AesGCM.toUpperCase():a=d;break;case h.AesKW.toUpperCase():a=b;break;case h.EcDSA.toUpperCase():a=S;break;case h.EcDH.toUpperCase():a=O;break;case h.Hmac.toUpperCase():a=L;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,r.algorithm.name)}a.exportKey(e,r).then(t,n)})},e.prototype.importKey=function(e,r,t,n,o){return new Promise(function(i,s){var u=a(t),f=p;switch(u.name.toUpperCase()){case h.RsaSSA.toUpperCase():f=T;break;case h.RsaPSS.toUpperCase():f=j;break;case h.RsaOAEP.toUpperCase():f=H;break;case h.AesECB.toUpperCase():f=g;break;case h.AesCBC.toUpperCase():f=C;break;case h.AesCTR.toUpperCase():f=k;break;case h.AesGCM.toUpperCase():f=d;break;case h.AesKW.toUpperCase():f=b;break;case h.EcDSA.toUpperCase():f=S;break;case h.EcDH.toUpperCase():f=O;break;case h.Hmac.toUpperCase():f=L;break;case h.Pbkdf2.toUpperCase():f=N;break;case h.Hkdf.toUpperCase():f=R;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,u.name)}f.importKey(e,r,u,n,o).then(i,s)})},e.prototype.wrapKey=function(e,r,t,n){return new Promise(function(o,i){var s=a(n),u=p;switch(s.name.toUpperCase()){case h.RsaOAEP.toUpperCase():u=H;break;case h.AesECB.toUpperCase():u=g;break;case h.AesCBC.toUpperCase():u=C;break;case h.AesCTR.toUpperCase():u=k;break;case h.AesGCM.toUpperCase():u=d;break;case h.AesKW.toUpperCase():u=b;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,s.name)}u.wrapKey(e,r,t,s).then(o,i)})},e.prototype.unwrapKey=function(e,r,t,n,i,s,u){return new Promise(function(f,y){var l=a(n),A=a(i),m=o(r,"wrappedKey"),w=p;switch(l.name.toUpperCase()){case h.RsaOAEP.toUpperCase():w=H;break;case h.AesECB.toUpperCase():w=g;break;case h.AesCBC.toUpperCase():w=C;break;case h.AesCTR.toUpperCase():w=k;break;case h.AesGCM.toUpperCase():w=d;break;case h.AesKW.toUpperCase():w=b;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,l.name)}w.unwrapKey(e,m,t,l,A,s,u).then(f,y)})},e}()}.call(r,t(7))},function(e,r,t){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};return function(r,t){function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var a=t(0),o=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=10,r}return n(r,e),r.MODULE_NOT_FOUND="Module '%1' is not found. Download it from %2",r.UNSUPPORTED_ALGORITHM="Unsupported algorithm '%1'",r}(a.WebCryptoError);r.LinerError=o},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(10),a=t(3),o=function(){function e(){this.subtle=new n.SubtleCrypto}return e.prototype.getRandomValues=function(e){return a.nativeCrypto.getRandomValues(e)},e}();r.Crypto=o},function(e,r,t){"use strict";function n(e,r){var t=e[r];e[r]=function(){var n=arguments;return new Promise(function(a,o){var i=t.apply(e,n);i.oncomplete=function(e){a(e.target.result)},i.onerror=function(e){o("Error on running '"+r+"' function")}})}}Object.defineProperty(r,"__esModule",{value:!0});var a,o=t(1);if("undefined"==typeof self){var i=t(9);a={crypto:{subtle:{},getRandomValues:function(e){var r=e.buffer,t=new Uint8Array(r);return i.randomBytes(t.length).forEach(function(e,r){return t[r]=e}),e}}}}else a=self;r.nativeCrypto=a.msCrypto||a.crypto||{},r.nativeSubtle=null;try{r.nativeSubtle=r.nativeCrypto.subtle||r.nativeCrypto.webkitSubtle}catch(e){}if(a.msCrypto){if(!a.Promise)throw new o.LinerError(o.LinerError.MODULE_NOT_FOUND,"Promise","https://www.promisejs.org");n(r.nativeSubtle,"generateKey"),n(r.nativeSubtle,"digest"),n(r.nativeSubtle,"sign"),n(r.nativeSubtle,"verify"),n(r.nativeSubtle,"encrypt"),n(r.nativeSubtle,"decrypt"),n(r.nativeSubtle,"importKey"),n(r.nativeSubtle,"exportKey"),n(r.nativeSubtle,"wrapKey"),n(r.nativeSubtle,"unwrapKey"),n(r.nativeSubtle,"deriveKey"),n(r.nativeSubtle,"deriveBits")}Math.imul||(Math.imul=function(e,r){var t=e>>>16&65535,n=65535&e,a=r>>>16&65535,o=65535&r;return n*o+(t*o+n*a<<16>>>0)|0})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e){this.algorithm=e.algorithm,e.type&&(this.type=e.type),this.extractable=e.extractable,this.usages=e.usages}return e}();r.CryptoKey=n},function(e,r,t){"use strict";function n(){var e={name:"Unknown",version:"0"};try{var t=self.navigator.userAgent,n=void 0;(n=/edge\/([\d\.]+)/i.exec(t))?(e.name=r.Browser.Edge,e.version=n[1]):/msie/i.test(t)?(e.name=r.Browser.IE,e.version=/msie ([\d\.]+)/i.exec(t)[1]):/Trident/i.test(t)?(e.name=r.Browser.IE,e.version=/rv:([\d\.]+)/i.exec(t)[1]):/chrome/i.test(t)?(e.name=r.Browser.Chrome,e.version=/chrome\/([\d\.]+)/i.exec(t)[1]):/safari/i.test(t)?(e.name=r.Browser.Safari,e.version=/version\/([\d\.]+)/i.exec(t)[1]):/firefox/i.test(t)&&(e.name=r.Browser.Firefox,e.version=/firefox\/([\d\.]+)/i.exec(t)[1])}catch(e){}return e}function a(e){for(var r=new Uint8Array(e.length),t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r}function o(e){for(var r="",t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return r}function i(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=new Uint8Array(e.map(function(e){return e.length}).reduce(function(e,r){return e+r})),n=0;return e.forEach(function(e,r){for(var a=0;a<e.length;a++)t[n+a]=e[a];n+=e.length}),t}function s(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];for(var n=arguments[0],a=1;a<arguments.length;a++){var o=arguments[a];for(var i in o)n[i]=o[i]}return n}function c(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];"undefined"!=typeof self&&self.PV_WEBCRYPTO_LINER_LOG&&console.warn.apply(console,arguments)}Object.defineProperty(r,"__esModule",{value:!0}),r.Browser={IE:"Internet Explorer",Safari:"Safari",Edge:"Edge",Chrome:"Chrome",Firefox:"Firefox Mozilla",Mobile:"Mobile"},r.BrowserInfo=n,r.string2buffer=a,r.buffer2string=o,r.concat=i,r.assign=s,r.warn=c},function(e,r,t){"use strict";function n(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}Object.defineProperty(r,"__esModule",{value:!0}),n(t(3)),n(t(2))},function(e,r){var t;t=function(){return this}();try{t=t||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(e,r,t){"use strict";function n(e,r){function t(){this.constructor=e}a(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}r.a=n;/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};Object.assign},function(e,r){e.exports=require("crypto")},function(e,r,t){"use strict";function n(e,r){return Promise.resolve().then(function(){if(e.key)return e;if(e.extractable){return(new A.Crypto).subtle.exportKey("jwk",e).then(function(t){var n=o(e);return n&&(n=w.assign(n,e.algorithm)),r.importKey("jwk",t,n,!0,e.usages)})}throw new m.LinerError("'key' is Native CryptoKey. It can't be converted to JS CryptoKey")})}function a(e,r){w.BrowserInfo().name!==w.Browser.IE&&w.BrowserInfo().name!==w.Browser.Edge&&w.BrowserInfo().name!==w.Browser.Safari||!/^rsa/i.test(e.name)||(r.privateKey?(b.push({hash:e.hash,key:r.privateKey}),b.push({hash:e.hash,key:r.publicKey})):b.push({hash:e.hash,key:r}))}function o(e){var r=null;return b.some(function(t){return t.key===e&&(r=w.assign({},e.algorithm,{hash:t.hash}),!0)}),r}function i(e,r){var t=[];e.privateKey?(t.push(e.privateKey),t.push(e.publicKey)):t.push(e),t.forEach(function(e){"keyUsage"in e&&(e.usages=e.keyUsage||[],e.usages.length||(["verify","encrypt","wrapKey"].forEach(function(t){r.indexOf(t)>-1&&("public"===e.type||"secret"===e.type)&&e.usages.push(t)}),["sign","decrypt","unwrapKey","deriveKey","deriveBits"].forEach(function(t){r.indexOf(t)>-1&&("private"===e.type||"secret"===e.type)&&e.usages.push(t)})))})}function s(e,r,t){if(r&&w.BrowserInfo().name===w.Browser.IE){"extractable"in e&&(e.ext=e.extractable,delete e.extractable);var n=null;switch(r.name.toUpperCase()){case h.AlgorithmNames.AesECB.toUpperCase():case h.AlgorithmNames.AesCBC.toUpperCase():case h.AlgorithmNames.AesGCM.toUpperCase():n=v.AesCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,r.name.toUpperCase())}n&&!e.alg&&(e.alg=n.alg2jwk(r)),"key_ops"in e||(e.key_ops=t)}}function c(e){w.BrowserInfo().name===w.Browser.IE&&("ext"in e&&(e.extractable=e.ext,delete e.ext),delete e.key_ops,delete e.alg)}function u(e){var r=/AppleWebKit\/(\d+)/.exec(self.navigator.userAgent);return e.toUpperCase()===h.AlgorithmNames.RsaOAEP&&r&&parseInt(r[1],10)<604}var p=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};return function(r,t){function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var h=t(0),f=t(0),y=t(0),l=t(3),A=t(2),m=t(1),w=t(5),v=t(11),g=t(12),C=t(13),k=t(14),d=t(15),b=[],E=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return p(r,e),r.prototype.generateKey=function(r,t,n){var o,s=this,c=arguments;return e.prototype.generateKey.apply(this,c).then(function(e){if(o=y.PrepareAlgorithm(r),!(w.BrowserInfo().name===w.Browser.Edge&&o.name.toUpperCase()===h.AlgorithmNames.AesGCM||u(o.name))&&l.nativeSubtle)try{return l.nativeSubtle.generateKey.apply(l.nativeSubtle,c).catch(function(e){w.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){if(e){var c=Promise.resolve(e);if(w.BrowserInfo().name===w.Browser.Safari&&(o.name.toUpperCase()===h.AlgorithmNames.EcDH.toUpperCase()||o.name.toUpperCase()===h.AlgorithmNames.EcDSA.toUpperCase())){var u=e.publicKey;c=c.then(function(){return s.exportKey("jwk",u).then(function(a){return s.exportKey("spki",u).then(function(o){for(var i=h.Base64Url.decode(a.x),c=h.Base64Url.decode(a.y),u=i.length+c.length,p=new Uint8Array(o),f=0;f<u;f++){var y=p[p.length-f-1],l=void 0;if(l=f<c.length?c[c.length-f-1]:i[i.length+c.length-f-1],y!==l)return w.warn("WebCrypto: EC key has wrong public key JWK. Key pair will be recreated"),s.generateKey(r,t,n)}return e})})})}return c.then(function(e){return i(e,n),a(o,e),e})}var p;switch(o.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():p=v.AesCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,o.name.toLowerCase())}return p.generateKey(o,t,n)})},r.prototype.digest=function(r,t){var n,a,o=arguments;return e.prototype.digest.apply(this,o).then(function(e){if(n=y.PrepareAlgorithm(r),a=y.PrepareData(t,"data"),l.nativeSubtle)try{return l.nativeSubtle.digest.apply(l.nativeSubtle,o).catch(function(e){w.warn("WebCrypto: native digest for "+n.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native digest for "+n.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){return e||g.ShaCrypto.digest(n,a)})},r.prototype.sign=function(r,t,a){var i,s,c=arguments;return e.prototype.sign.apply(this,c).then(function(e){i=y.PrepareAlgorithm(r),s=y.PrepareData(a,"data");var n=o(t);if(n&&(c[0]=w.assign(i,n)),l.nativeSubtle)try{return l.nativeSubtle.sign.apply(l.nativeSubtle,c).catch(function(e){w.warn("WebCrypto: native sign for "+i.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native sign for "+i.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){if(e)return e;var r;switch(i.name.toLowerCase()){case h.AlgorithmNames.Hmac.toLowerCase():r=k.HmacCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,i.name.toLowerCase())}return n(t,r).then(function(e){return r.sign(i,e,s)})})},r.prototype.verify=function(r,t,n,a){var i,s,c,u=arguments;return e.prototype.verify.apply(this,u).then(function(e){i=y.PrepareAlgorithm(r),s=y.PrepareData(n,"data"),c=y.PrepareData(a,"data");var p=o(t);if(p&&(u[0]=w.assign(i,p)),l.nativeSubtle)try{return l.nativeSubtle.verify.apply(l.nativeSubtle,u).catch(function(e){w.warn("WebCrypto: native verify for "+i.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native verify for "+i.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){if("boolean"==typeof e)return e;throw i.name.toLowerCase(),new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,i.name.toLowerCase())})},r.prototype.deriveBits=function(r,t,n){var a,o=arguments;return e.prototype.deriveBits.apply(this,o).then(function(e){if(a=y.PrepareAlgorithm(r),l.nativeSubtle)try{return l.nativeSubtle.deriveBits.apply(l.nativeSubtle,o).catch(function(e){w.warn("WebCrypto: native deriveBits for "+a.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native deriveBits for "+a.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){if(e)return e;var r;switch(a.name.toLowerCase()){case h.AlgorithmNames.Pbkdf2.toLowerCase():r=C.Pbkdf2Crypto;break;case h.AlgorithmNames.Hkdf.toLowerCase():r=d.HkdfCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"deriveBits")}return r.deriveBits(a,t,n)})},r.prototype.deriveKey=function(r,t,n,a,o){var s,c,u=arguments;return e.prototype.deriveKey.apply(this,u).then(function(e){if(s=y.PrepareAlgorithm(r),c=y.PrepareAlgorithm(n),l.nativeSubtle)try{return l.nativeSubtle.deriveKey.apply(l.nativeSubtle,u).catch(function(e){w.warn("WebCrypto: native deriveKey for "+s.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native deriveKey for "+s.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){if(e)return i(e,o),e;var r;switch(s.name.toLowerCase()){case h.AlgorithmNames.Pbkdf2.toLowerCase():r=C.Pbkdf2Crypto;break;case h.AlgorithmNames.Hkdf.toLowerCase():r=d.HkdfCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"deriveKey")}return r.deriveKey(s,t,c,a,o)})},r.prototype.encrypt=function(r,t,a){var o,i,s=arguments;return e.prototype.encrypt.apply(this,s).then(function(e){if(o=y.PrepareAlgorithm(r),i=y.PrepareData(a,"data"),l.nativeSubtle)try{return l.nativeSubtle.encrypt.apply(l.nativeSubtle,s).catch(function(e){w.warn("WebCrypto: native 'encrypt' for "+o.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native 'encrypt' for "+o.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){if(e){if(w.BrowserInfo().name===w.Browser.IE&&o.name.toUpperCase()===h.AlgorithmNames.AesGCM&&e.ciphertext){var r=new Uint8Array(e.ciphertext.byteLength+e.tag.byteLength),a=0;new Uint8Array(e.ciphertext).forEach(function(e){return r[a++]=e}),new Uint8Array(e.tag).forEach(function(e){return r[a++]=e}),e=r.buffer}return Promise.resolve(e)}var s;switch(o.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():s=v.AesCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"encrypt")}return n(t,s).then(function(e){return s.encrypt(o,e,i)})})},r.prototype.decrypt=function(r,t,n){var a,o,i=arguments;return e.prototype.decrypt.apply(this,i).then(function(e){a=y.PrepareAlgorithm(r),o=y.PrepareData(n,"data");var i=o;if(w.BrowserInfo().name===w.Browser.IE&&a.name.toUpperCase()===h.AlgorithmNames.AesGCM){var s=o.byteLength-a.tagLength/8;i={ciphertext:o.buffer.slice(0,s),tag:o.buffer.slice(s,o.byteLength)}}if(t.key){var c=void 0;switch(a.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():c=v.AesCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"decrypt")}return c.decrypt(a,t,o)}return l.nativeSubtle.decrypt.call(l.nativeSubtle,a,t,i)})},r.prototype.wrapKey=function(r,t,n,a){var o,i=arguments;return e.prototype.wrapKey.apply(this,i).then(function(e){if(o=y.PrepareAlgorithm(a),l.nativeSubtle)try{return l.nativeSubtle.wrapKey.apply(l.nativeSubtle,i).catch(function(e){w.warn("WebCrypto: native 'wrapKey' for "+o.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native 'wrapKey' for "+o.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){if(e)return e;var a;switch(o.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():a=v.AesCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"wrapKey")}return a.wrapKey(r,t,n,o)})},r.prototype.unwrapKey=function(r,t,n,a,o,s,c){var u,p,f,A=this,g=arguments;return e.prototype.unwrapKey.apply(this,g).then(function(e){if(u=y.PrepareAlgorithm(a),p=y.PrepareAlgorithm(o),f=y.PrepareData(t,"wrappedKey"),n.key){var C=void 0;switch(u.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():C=v.AesCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"unwrapKey")}return C.unwrapKey(r,f,n,u,p,s,c)}return l.nativeSubtle.unwrapKey.apply(l.nativeSubtle,g).catch(function(e){return A.decrypt(u,n,t).then(function(e){var t;return t="jwk"===r?JSON.parse(w.buffer2string(new Uint8Array(e))):e,A.importKey(r,t,p,s,c)})}).then(function(e){if(e)return i(e,c),e}).catch(function(e){throw console.error(e),new Error("Cannot unwrap key from incoming data")})})},r.prototype.exportKey=function(r,t){var n=arguments;return e.prototype.exportKey.apply(this,n).then(function(){if(l.nativeSubtle)try{return l.nativeSubtle.exportKey.apply(l.nativeSubtle,n).catch(function(e){w.warn("WebCrypto: native 'exportKey' for "+t.algorithm.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native 'exportKey' for "+t.algorithm.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){if(e){"jwk"===r&&e instanceof ArrayBuffer&&(e=w.buffer2string(new Uint8Array(e)),e=JSON.parse(e));var n=o(t);return n||(n=w.assign({},t.algorithm)),s(e,n,t.usages),Promise.resolve(e)}if(!t.key)throw new m.LinerError("Cannot export native CryptoKey from JS implementation");var a;switch(t.algorithm.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():a=v.AesCrypto;break;case h.AlgorithmNames.Hmac.toLowerCase():a=k.HmacCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,t.algorithm.name.toLowerCase())}return a.exportKey(r,t)})},r.prototype.importKey=function(r,t,n,o,s){var p,f,A=arguments;return e.prototype.importKey.apply(this,A).then(function(e){p=y.PrepareAlgorithm(n),f=t;var a=w.BrowserInfo();if("jwk"!==r||(a.name!==w.Browser.Safari||/^11/.test(a.version))&&a.name!==w.Browser.IE||(w.BrowserInfo().name===w.Browser.IE&&(t=w.assign({},t),c(t)),A[1]=w.string2buffer(JSON.stringify(t)).buffer),ArrayBuffer.isView(t)&&(f=y.PrepareData(t,"keyData")),!u(p.name)&&l.nativeSubtle)try{return l.nativeSubtle.importKey.apply(l.nativeSubtle,A).catch(function(e){w.warn("WebCrypto: native 'importKey' for "+p.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native 'importKey' for "+p.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){if(e)return a(p,e),i(e,s),Promise.resolve(e);var t;switch(p.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():t=v.AesCrypto;break;case h.AlgorithmNames.Pbkdf2.toLowerCase():t=C.Pbkdf2Crypto;break;case h.AlgorithmNames.Hmac.toLowerCase():t=k.HmacCrypto;break;case h.AlgorithmNames.Hkdf.toLowerCase():t=d.HkdfCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,p.name.toLowerCase())}return t.importKey(r,f,p,o,s)})},r}(f.SubtleCrypto);r.SubtleCrypto=E,Uint8Array.prototype.forEach||(Uint8Array.prototype.forEach=function(e){for(var r=0;r<this.length;r++)e(this[r],r,this)}),Uint8Array.prototype.slice||(Uint8Array.prototype.slice=function(e,r){return new Uint8Array(this.buffer.slice(e,r))}),Uint8Array.prototype.filter||(Uint8Array.prototype.filter=function(e){for(var r=[],t=0;t<this.length;t++)e(this[t],t,this)&&r.push(this[t]);return new Uint8Array(r)})},function(e,r,t){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};return function(r,t){function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var a=t(0),o=t(1),i=t(4),s=t(5),c=t(3),u=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.generateKey=function(e,r,t){var n=this;return Promise.resolve().then(function(){n.checkModule();var a=c.nativeCrypto.getRandomValues(new Uint8Array(e.length/8)),o=new i.CryptoKey({type:"secret",algorithm:e,extractable:r,usages:t});return o.key=a,o})},r.encrypt=function(e,r,t){return Promise.resolve().then(function(){var n;switch(e.name.toUpperCase()){case a.AlgorithmNames.AesECB:var i=e;n=asmCrypto.AES_ECB.encrypt(t,r.key,!!i.padding);break;case a.AlgorithmNames.AesCBC:var s=e;n=asmCrypto.AES_CBC.encrypt(t,r.key,void 0,a.PrepareData(s.iv,"iv"));break;case a.AlgorithmNames.AesGCM:var c=e;c.tagLength=c.tagLength||128;var u=void 0;c.additionalData&&(u=a.PrepareData(c.additionalData,"additionalData")),n=asmCrypto.AES_GCM.encrypt(t,r.key,c.iv,u,c.tagLength/8);break;default:throw new o.LinerError(a.AlgorithmError.UNSUPPORTED_ALGORITHM,e.name)}return n.buffer})},r.decrypt=function(e,r,t){return Promise.resolve().then(function(){var n;switch(e.name.toUpperCase()){case a.AlgorithmNames.AesECB:var i=e;n=asmCrypto.AES_ECB.decrypt(t,r.key,!!i.padding);break;case a.AlgorithmNames.AesCBC:var s=e;n=asmCrypto.AES_CBC.decrypt(t,r.key,void 0,a.PrepareData(s.iv,"iv"));break;case a.AlgorithmNames.AesGCM:var c=e;c.tagLength=c.tagLength||128;var u=void 0;c.additionalData&&(u=a.PrepareData(c.additionalData,"additionalData")),n=asmCrypto.AES_GCM.decrypt(t,r.key,c.iv,u,c.tagLength/8);break;default:throw new o.LinerError(a.AlgorithmError.UNSUPPORTED_ALGORITHM,e.name)}return n.buffer})},r.wrapKey=function(e,r,t,n){var a;return Promise.resolve().then(function(){return a=new p.Crypto,a.subtle.exportKey(e,r)}).then(function(e){var r;return r=e instanceof ArrayBuffer?new Uint8Array(e):s.string2buffer(JSON.stringify(e)),a.subtle.encrypt(n,t,r)})},r.unwrapKey=function(e,r,t,n,a,o,i){var c;return Promise.resolve().then(function(){return c=new p.Crypto,c.subtle.decrypt(n,t,r)}).then(function(r){var t;return t="jwk"===e.toLowerCase()?JSON.parse(s.buffer2string(new Uint8Array(r))):new Uint8Array(r),c.subtle.importKey(e,t,a,o,i)})},r.alg2jwk=function(e){return"A"+e.length+/-(\w+)/i.exec(e.name.toUpperCase())[1]},r.jwk2alg=function(e){throw new Error("Not implemented")},r.exportKey=function(e,r){var t=this;return Promise.resolve().then(function(){var n=r.key;if("jwk"===e.toLowerCase()){return{alg:t.alg2jwk(r.algorithm),ext:r.extractable,k:a.Base64Url.encode(n),key_ops:r.usages,kty:"oct"}}return n.buffer})},r.importKey=function(e,r,t,n,o){return Promise.resolve().then(function(){var s;if("jwk"===e.toLowerCase()){var c=r;s=a.Base64Url.decode(c.k)}else s=new Uint8Array(r);var u=new i.CryptoKey({type:"secret",algorithm:t,extractable:n,usages:o});return u.key=s,u})},r.checkModule=function(){if("undefined"==typeof asmCrypto)throw new o.LinerError(o.LinerError.MODULE_NOT_FOUND,"asmCrypto","https://github.com/vibornoff/asmcrypto.js")},r}(a.BaseCrypto);r.AesCrypto=u;var p=t(2)},function(e,r,t){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};return function(r,t){function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var a=t(0),o=t(1),i=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.digest=function(e,r){return Promise.resolve().then(function(){if("undefined"==typeof asmCrypto)throw new o.LinerError(o.LinerError.MODULE_NOT_FOUND,"asmCrypto","https://github.com/vibornoff/asmcrypto.js");switch(e.name.toUpperCase()){case a.AlgorithmNames.Sha1:return asmCrypto.SHA1.bytes(r).buffer;case a.AlgorithmNames.Sha256:return asmCrypto.SHA256.bytes(r).buffer;case a.AlgorithmNames.Sha512:return asmCrypto.SHA512.bytes(r).buffer;default:throw new o.LinerError("Not supported algorithm '"+e.name+"'")}})},r}(a.BaseCrypto);r.ShaCrypto=i},function(e,r,t){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};return function(r,t){function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var a=t(0),o=t(1),i=t(4),s=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.importKey=function(e,r,t,n,a){return Promise.resolve().then(function(){var e=new Uint8Array(r),o=new i.CryptoKey({type:"secret",algorithm:t,extractable:n,usages:a});return o.key=e,o})},r.deriveBits=function(e,r,t){return Promise.resolve().then(function(){var n,i=new Uint8Array(e.salt),s=e.iterations,c=t/8,u="string"==typeof e.hash?e.hash:e.hash.name;switch(u.toUpperCase()){case a.AlgorithmNames.Sha512.toUpperCase():n=asmCrypto.PBKDF2_HMAC_SHA512.bytes(r.key,i,s,c);break;case a.AlgorithmNames.Sha256.toUpperCase():n=asmCrypto.PBKDF2_HMAC_SHA256.bytes(r.key,i,s,c);break;case a.AlgorithmNames.Sha1.toUpperCase():n=asmCrypto.PBKDF2_HMAC_SHA1.bytes(r.key,i,s,c);break;default:throw new o.LinerError(o.LinerError.UNSUPPORTED_ALGORITHM,u)}return n.buffer})},r.deriveKey=function(e,r,t,n,i){var s=this;return Promise.resolve().then(function(){var n=0;switch(t.name.toUpperCase()){case a.AlgorithmNames.AesCBC.toUpperCase():case a.AlgorithmNames.AesCTR.toUpperCase():case a.AlgorithmNames.AesGCM.toUpperCase():case a.AlgorithmNames.AesKW.toUpperCase():n=t.length;break;case a.AlgorithmNames.Hmac.toUpperCase():n=512;break;default:throw new o.LinerError(o.LinerError.UNSUPPORTED_ALGORITHM,t.name)}return s.deriveBits(e,r,n)}).then(function(e){return(new c.Crypto).subtle.importKey("raw",new Uint8Array(e),t,n,i)})},r}(a.BaseCrypto);r.Pbkdf2Crypto=s;var c=t(2)},function(e,r,t){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};return function(r,t){function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var a=t(0),o=t(4),i=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.importKey=function(e,r,t,n,i){return Promise.resolve().then(function(){var s;if("jwk"===e.toLowerCase()){var c=r;s=a.Base64Url.decode(c.k)}else s=new Uint8Array(r);var u=new o.CryptoKey({type:"secret",algorithm:t,extractable:n,usages:i});return u.key=s,u})},r.sign=function(e,r,t){return Promise.resolve().then(function(){return asmCrypto.HMAC_SHA256.bytes(t,r.key).buffer})},r.exportKey=function(e,r){return Promise.resolve().then(function(){var t=r.key;if("jwk"===e.toLowerCase()){return{alg:"HS256",kty:"oct",k:a.Base64Url.encode(t),key_ops:r.usages,ext:r.extractable}}return t.buffer})},r}(a.BaseCrypto);r.HmacCrypto=i},function(e,r,t){"use strict";function n(e,r){return asmCrypto.HMAC_SHA256.bytes(e,r)}function a(e,r,t){for(var n=e.length,a=Math.ceil(r/n),o=new Uint8Array(n*a+t.length+1),i=0,s=0,c=0;c<a;c++){o.set(t,s),o[s+t.length]=c+1;var u=asmCrypto.HMAC_SHA256.bytes(o.slice(i,s+t.length+1),e);o.set(u,s),i=s,s+=n}return o.slice(0,r)}function o(e,r,t,o){return a(n(e,t),r,o)}var i=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};return function(r,t){function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var s=t(0),c=t(1),u=t(4),p=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return i(r,e),r.importKey=function(e,r,t,n,a){return Promise.resolve().then(function(){var e=new Uint8Array(r),o=new u.CryptoKey({type:"secret",algorithm:t,extractable:n,usages:a});return o.key=e,o})},r.deriveBits=function(e,r,t){return Promise.resolve().then(function(){var n,a=new Uint8Array(e.salt),i=new Uint8Array(e.info),u=t/8,p="string"==typeof e.hash?e.hash:e.hash.name;switch(p.toUpperCase()){case s.AlgorithmNames.Sha256.toUpperCase():n=o(r.key,u,a,i);break;default:throw new c.LinerError(c.LinerError.UNSUPPORTED_ALGORITHM,p)}return n.buffer})},r.deriveKey=function(e,r,t,n,a){var o=this;return Promise.resolve().then(function(){var n=0;switch(t.name.toUpperCase()){case s.AlgorithmNames.AesCBC.toUpperCase():case s.AlgorithmNames.AesCTR.toUpperCase():case s.AlgorithmNames.AesGCM.toUpperCase():case s.AlgorithmNames.AesKW.toUpperCase():n=t.length;break;case s.AlgorithmNames.Hmac.toUpperCase():n=512;break;default:throw new c.LinerError(c.LinerError.UNSUPPORTED_ALGORITHM,t.name)}return o.deriveBits(e,r,n)}).then(function(e){return(new h.Crypto).subtle.importKey("raw",new Uint8Array(e),t,n,a)})},r}(s.BaseCrypto);r.HkdfCrypto=p;var h=t(2)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(6),a=self;n.nativeCrypto&&Object.freeze(n.nativeCrypto.getRandomValues),delete self.crypto,a.crypto=new n.Crypto,Object.freeze(a.crypto),r.crypto=a.crypto}]);
/*! asmCrypto v0.22.0, (c) 2018 asmCrypto.js, opensource.org/licenses/MIT */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.asmCrypto={})}(this,function(t){"use strict";var e=function(){var t,e,r=!1;function s(r,s){var i=t[(e[r]+e[s])%255];return 0!==r&&0!==s||(i=0),i}var i,n,a,h;function o(){function o(r){var s,i,n;for(i=n=function(r){var s=t[255-e[r]];return 0===r&&(s=0),s}(r),s=0;s<4;s++)n^=i=255&(i<<1|i>>>7);return n^=99}r||function(){t=[],e=[];var s,i,n=1;for(s=0;s<255;s++)t[s]=n,i=128&n,n<<=1,n&=255,128===i&&(n^=27),n^=t[s],e[t[s]]=s;t[255]=t[0],e[0]=0,r=!0}(),i=[],n=[],a=[[],[],[],[]],h=[[],[],[],[]];for(var c=0;c<256;c++){var u=o(c);i[c]=u,n[u]=c,a[0][c]=s(2,u)<<24|u<<16|u<<8|s(3,u),h[0][u]=s(14,c)<<24|s(9,c)<<16|s(13,c)<<8|s(11,c);for(var f=1;f<4;f++)a[f][c]=a[f-1][c]>>>8|a[f-1][c]<<24,h[f][u]=h[f-1][u]>>>8|h[f-1][u]<<24}}var c=function(t,e){o();var r=new Uint32Array(e);r.set(i,512),r.set(n,768);for(var s=0;s<4;s++)r.set(a[s],4096+1024*s>>2),r.set(h[s],8192+1024*s>>2);var c=function(t,e,r){"use asm";var s=0,i=0,n=0,a=0,h=0,o=0,c=0,u=0,f=0,l=0,p=0,w=0,y=0,_=0,d=0,A=0,v=0,x=0,E=0,g=0,m=0;var b=new t.Uint32Array(r),S=new t.Uint8Array(r);function C(t,e,r,h,o,c,u,f){t=t|0;e=e|0;r=r|0;h=h|0;o=o|0;c=c|0;u=u|0;f=f|0;var l=0,p=0,w=0,y=0,_=0,d=0,A=0,v=0;l=r|0x400,p=r|0x800,w=r|0xc00;o=o^b[(t|0)>>2],c=c^b[(t|4)>>2],u=u^b[(t|8)>>2],f=f^b[(t|12)>>2];for(v=16;(v|0)<=h<<4;v=v+16|0){y=b[(r|o>>22&1020)>>2]^b[(l|c>>14&1020)>>2]^b[(p|u>>6&1020)>>2]^b[(w|f<<2&1020)>>2]^b[(t|v|0)>>2],_=b[(r|c>>22&1020)>>2]^b[(l|u>>14&1020)>>2]^b[(p|f>>6&1020)>>2]^b[(w|o<<2&1020)>>2]^b[(t|v|4)>>2],d=b[(r|u>>22&1020)>>2]^b[(l|f>>14&1020)>>2]^b[(p|o>>6&1020)>>2]^b[(w|c<<2&1020)>>2]^b[(t|v|8)>>2],A=b[(r|f>>22&1020)>>2]^b[(l|o>>14&1020)>>2]^b[(p|c>>6&1020)>>2]^b[(w|u<<2&1020)>>2]^b[(t|v|12)>>2];o=y,c=_,u=d,f=A}s=b[(e|o>>22&1020)>>2]<<24^b[(e|c>>14&1020)>>2]<<16^b[(e|u>>6&1020)>>2]<<8^b[(e|f<<2&1020)>>2]^b[(t|v|0)>>2],i=b[(e|c>>22&1020)>>2]<<24^b[(e|u>>14&1020)>>2]<<16^b[(e|f>>6&1020)>>2]<<8^b[(e|o<<2&1020)>>2]^b[(t|v|4)>>2],n=b[(e|u>>22&1020)>>2]<<24^b[(e|f>>14&1020)>>2]<<16^b[(e|o>>6&1020)>>2]<<8^b[(e|c<<2&1020)>>2]^b[(t|v|8)>>2],a=b[(e|f>>22&1020)>>2]<<24^b[(e|o>>14&1020)>>2]<<16^b[(e|c>>6&1020)>>2]<<8^b[(e|u<<2&1020)>>2]^b[(t|v|12)>>2]}function M(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;C(0x0000,0x0800,0x1000,m,t,e,r,s)}function U(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;var n=0;C(0x0400,0x0c00,0x2000,m,t,s,r,e);n=i,i=a,a=n}function H(t,e,r,f){t=t|0;e=e|0;r=r|0;f=f|0;C(0x0000,0x0800,0x1000,m,h^t,o^e,c^r,u^f);h=s,o=i,c=n,u=a}function T(t,e,r,f){t=t|0;e=e|0;r=r|0;f=f|0;var l=0;C(0x0400,0x0c00,0x2000,m,t,f,r,e);l=i,i=a,a=l;s=s^h,i=i^o,n=n^c,a=a^u;h=t,o=e,c=r,u=f}function D(t,e,r,f){t=t|0;e=e|0;r=r|0;f=f|0;C(0x0000,0x0800,0x1000,m,h,o,c,u);h=s=s^t,o=i=i^e,c=n=n^r,u=a=a^f}function k(t,e,r,f){t=t|0;e=e|0;r=r|0;f=f|0;C(0x0000,0x0800,0x1000,m,h,o,c,u);s=s^t,i=i^e,n=n^r,a=a^f;h=t,o=e,c=r,u=f}function G(t,e,r,f){t=t|0;e=e|0;r=r|0;f=f|0;C(0x0000,0x0800,0x1000,m,h,o,c,u);h=s,o=i,c=n,u=a;s=s^t,i=i^e,n=n^r,a=a^f}function I(t,e,r,h){t=t|0;e=e|0;r=r|0;h=h|0;C(0x0000,0x0800,0x1000,m,f,l,p,w);w=~A&w|A&w+1;p=~d&p|d&p+((w|0)==0);l=~_&l|_&l+((p|0)==0);f=~y&f|y&f+((l|0)==0);s=s^t;i=i^e;n=n^r;a=a^h}function Z(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;var i=0,n=0,a=0,f=0,l=0,p=0,w=0,y=0,_=0,d=0;t=t^h,e=e^o,r=r^c,s=s^u;i=v|0,n=x|0,a=E|0,f=g|0;for(;(_|0)<128;_=_+1|0){if(i>>>31){l=l^t,p=p^e,w=w^r,y=y^s}i=i<<1|n>>>31,n=n<<1|a>>>31,a=a<<1|f>>>31,f=f<<1;d=s&1;s=s>>>1|r<<31,r=r>>>1|e<<31,e=e>>>1|t<<31,t=t>>>1;if(d)t=t^0xe1000000}h=l,o=p,c=w,u=y}function P(t){t=t|0;m=t}function B(t,e,r,h){t=t|0;e=e|0;r=r|0;h=h|0;s=t,i=e,n=r,a=h}function z(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;h=t,o=e,c=r,u=s}function O(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;f=t,l=e,p=r,w=s}function q(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;y=t,_=e,d=r,A=s}function L(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;w=~A&w|A&s,p=~d&p|d&r,l=~_&l|_&e,f=~y&f|y&t}function R(t){t=t|0;if(t&15)return-1;S[t|0]=s>>>24,S[t|1]=s>>>16&255,S[t|2]=s>>>8&255,S[t|3]=s&255,S[t|4]=i>>>24,S[t|5]=i>>>16&255,S[t|6]=i>>>8&255,S[t|7]=i&255,S[t|8]=n>>>24,S[t|9]=n>>>16&255,S[t|10]=n>>>8&255,S[t|11]=n&255,S[t|12]=a>>>24,S[t|13]=a>>>16&255,S[t|14]=a>>>8&255,S[t|15]=a&255;return 16}function K(t){t=t|0;if(t&15)return-1;S[t|0]=h>>>24,S[t|1]=h>>>16&255,S[t|2]=h>>>8&255,S[t|3]=h&255,S[t|4]=o>>>24,S[t|5]=o>>>16&255,S[t|6]=o>>>8&255,S[t|7]=o&255,S[t|8]=c>>>24,S[t|9]=c>>>16&255,S[t|10]=c>>>8&255,S[t|11]=c&255,S[t|12]=u>>>24,S[t|13]=u>>>16&255,S[t|14]=u>>>8&255,S[t|15]=u&255;return 16}function N(){M(0,0,0,0);v=s,x=i,E=n,g=a}function F(t,e,r){t=t|0;e=e|0;r=r|0;var h=0;if(e&15)return-1;while((r|0)>=16){V[t&7](S[e|0]<<24|S[e|1]<<16|S[e|2]<<8|S[e|3],S[e|4]<<24|S[e|5]<<16|S[e|6]<<8|S[e|7],S[e|8]<<24|S[e|9]<<16|S[e|10]<<8|S[e|11],S[e|12]<<24|S[e|13]<<16|S[e|14]<<8|S[e|15]);S[e|0]=s>>>24,S[e|1]=s>>>16&255,S[e|2]=s>>>8&255,S[e|3]=s&255,S[e|4]=i>>>24,S[e|5]=i>>>16&255,S[e|6]=i>>>8&255,S[e|7]=i&255,S[e|8]=n>>>24,S[e|9]=n>>>16&255,S[e|10]=n>>>8&255,S[e|11]=n&255,S[e|12]=a>>>24,S[e|13]=a>>>16&255,S[e|14]=a>>>8&255,S[e|15]=a&255;h=h+16|0,e=e+16|0,r=r-16|0}return h|0}function j(t,e,r){t=t|0;e=e|0;r=r|0;var s=0;if(e&15)return-1;while((r|0)>=16){W[t&1](S[e|0]<<24|S[e|1]<<16|S[e|2]<<8|S[e|3],S[e|4]<<24|S[e|5]<<16|S[e|6]<<8|S[e|7],S[e|8]<<24|S[e|9]<<16|S[e|10]<<8|S[e|11],S[e|12]<<24|S[e|13]<<16|S[e|14]<<8|S[e|15]);s=s+16|0,e=e+16|0,r=r-16|0}return s|0}var V=[M,U,H,T,D,k,G,I];var W=[H,Z];return{set_rounds:P,set_state:B,set_iv:z,set_nonce:O,set_mask:q,set_counter:L,get_state:R,get_iv:K,gcm_init:N,cipher:F,mac:j}}({Uint8Array:Uint8Array,Uint32Array:Uint32Array},t,e);return c.set_key=function(t,e,s,n,a,o,u,f,l){var p=r.subarray(0,60),w=r.subarray(256,316);p.set([e,s,n,a,o,u,f,l]);for(var y=t,_=1;y<4*t+28;y++){var d=p[y-1];(y%t==0||8===t&&y%t==4)&&(d=i[d>>>24]<<24^i[d>>>16&255]<<16^i[d>>>8&255]<<8^i[255&d]),y%t==0&&(d=d<<8^d>>>24^_<<24,_=_<<1^(128&_?27:0)),p[y]=p[y-t]^d}for(var A=0;A<y;A+=4)for(var v=0;v<4;v++)d=p[y-(4+A)+(4-v)%4],w[A+v]=A<4||A>=y-4?d:h[0][i[d>>>24]]^h[1][i[d>>>16&255]]^h[2][i[d>>>8&255]]^h[3][i[255&d]];c.set_rounds(t+5)},c};return c.ENC={ECB:0,CBC:2,CFB:4,OFB:6,CTR:7},c.DEC={ECB:1,CBC:3,CFB:5,OFB:6,CTR:7},c.MAC={CBC:0,GCM:1},c.HEAP_DATA=16384,c}(),r=new Uint8Array(1048576),s=e(null,r.buffer);function i(){var t=Error.apply(this,arguments);this.message=t.message,this.stack=t.stack}function n(){var t=Error.apply(this,arguments);this.message=t.message,this.stack=t.stack}function a(){var t=Error.apply(this,arguments);this.message=t.message,this.stack=t.stack}function h(t,e){e=!!e;for(var r=t.length,s=new Uint8Array(e?4*r:r),i=0,n=0;i<r;i++){var a=t.charCodeAt(i);if(e&&55296<=a&&a<=56319){if(++i>=r)throw new Error("Malformed string, low surrogate expected at position "+i);a=(55296^a)<<10|65536|56320^t.charCodeAt(i)}else if(!e&&a>>>8)throw new Error("Wide characters are not allowed.");!e||a<=127?s[n++]=a:a<=2047?(s[n++]=192|a>>6,s[n++]=128|63&a):a<=65535?(s[n++]=224|a>>12,s[n++]=128|a>>6&63,s[n++]=128|63&a):(s[n++]=240|a>>18,s[n++]=128|a>>12&63,s[n++]=128|a>>6&63,s[n++]=128|63&a)}return s.subarray(0,n)}function o(t){for(var e="",r=0;r<t.length;r++){var s=(255&t[r]).toString(16);s.length<2&&(e+="0"),e+=s}return e}function c(t){return btoa(function(t,e){e=!!e;for(var r=t.length,s=new Array(r),i=0,n=0;i<r;i++){var a=t[i];if(!e||a<128)s[n++]=a;else if(a>=192&&a<224&&i+1<r)s[n++]=(31&a)<<6|63&t[++i];else if(a>=224&&a<240&&i+2<r)s[n++]=(15&a)<<12|(63&t[++i])<<6|63&t[++i];else{if(!(a>=240&&a<248&&i+3<r))throw new Error("Malformed UTF8 character at byte offset "+i);var h=(7&a)<<18|(63&t[++i])<<12|(63&t[++i])<<6|63&t[++i];h<=65535?s[n++]=h:(h^=65536,s[n++]=55296|h>>10,s[n++]=56320|1023&h)}}var o="";for(i=0;i<n;i+=16384)o+=String.fromCharCode.apply(String,s.slice(i,i+16384<=n?i+16384:n));return o}(t))}function u(t){return"number"==typeof t}function f(t){return"string"==typeof t}function l(t){return t instanceof ArrayBuffer}function p(t){return t instanceof Uint8Array}function w(t,e,r){var s=e?e.byteLength:r||65536;if(4095&s||s<=0)throw new Error("heap size must be a positive integer and a multiple of 4096");return e=e||new t(new ArrayBuffer(s))}function y(t,e,r,s,i){var n=t.length-e,a=n<i?n:i;return t.set(r.subarray(s,s+a),e),a}i.prototype=Object.create(Error.prototype,{name:{value:"IllegalStateError"}}),n.prototype=Object.create(Error.prototype,{name:{value:"IllegalArgumentError"}}),a.prototype=Object.create(Error.prototype,{name:{value:"SecurityError"}});class _{constructor(t,r,s,i,n){this.nonce=null,this.counter=0,this.counterSize=0,this.heap=w(Uint8Array,i).subarray(e.HEAP_DATA),this.asm=n||e(null,this.heap.buffer),this.mode=null,this.key=null,this.AES_reset(t,r,s)}AES_set_key(t){if(void 0!==t){if(!p(t))throw new TypeError("unexpected key type");var e=t.length;if(16!==e&&24!==e&&32!==e)throw new n("illegal key size");var r=new DataView(t.buffer,t.byteOffset,t.byteLength);this.asm.set_key(e>>2,r.getUint32(0),r.getUint32(4),r.getUint32(8),r.getUint32(12),e>16?r.getUint32(16):0,e>16?r.getUint32(20):0,e>24?r.getUint32(24):0,e>24?r.getUint32(28):0),this.key=t}else if(!this.key)throw new Error("key is required")}AES_CTR_set_options(t,e,r){if(void 0!==r){if(r<8||r>48)throw new n("illegal counter size");this.counterSize=r;var s=Math.pow(2,r)-1;this.asm.set_mask(0,0,s/4294967296|0,0|s)}else this.counterSize=r=48,this.asm.set_mask(0,0,65535,4294967295);if(void 0===t)throw new Error("nonce is required");if(!p(t))throw new TypeError("unexpected nonce type");var i=t.length;if(!i||i>16)throw new n("illegal nonce size");this.nonce=t;var a=new DataView(new ArrayBuffer(16));if(new Uint8Array(a.buffer).set(t),this.asm.set_nonce(a.getUint32(0),a.getUint32(4),a.getUint32(8),a.getUint32(12)),void 0!==e){if(!u(e))throw new TypeError("unexpected counter type");if(e<0||e>=Math.pow(2,r))throw new n("illegal counter value");this.counter=e,this.asm.set_counter(0,0,e/4294967296|0,0|e)}else this.counter=0}AES_set_iv(t){if(void 0!==t){if(!p(t))throw new TypeError("unexpected iv type");if(16!==t.length)throw new n("illegal iv size");var e=new DataView(t.buffer,t.byteOffset,t.byteLength);this.iv=t,this.asm.set_iv(e.getUint32(0),e.getUint32(4),e.getUint32(8),e.getUint32(12))}else this.iv=null,this.asm.set_iv(0,0,0,0)}AES_set_padding(t){this.padding=void 0===t||!!t}AES_reset(t,e,r){return this.result=null,this.pos=0,this.len=0,this.AES_set_key(t),this.AES_set_iv(e),this.AES_set_padding(r),this}AES_Encrypt_process(t){if(!p(t))throw new TypeError("data isn't of expected type");for(var r=this.asm,s=this.heap,i=e.ENC[this.mode],n=e.HEAP_DATA,a=this.pos,h=this.len,o=0,c=t.length||0,u=0,f=0,l=new Uint8Array(h+c&-16);c>0;)h+=f=y(s,a+h,t,o,c),o+=f,c-=f,(f=r.cipher(i,n+a,h))&&l.set(s.subarray(a,a+f),u),u+=f,f<h?(a+=f,h-=f):(a=0,h=0);return this.result=l,this.pos=a,this.len=h,this}AES_Encrypt_finish(t){var r=null,s=0;void 0!==t&&(s=(r=this.AES_Encrypt_process(t).result).length);var i=this.asm,a=this.heap,h=e.ENC[this.mode],o=e.HEAP_DATA,c=this.pos,u=this.len,f=16-u%16,l=u;if(this.hasOwnProperty("padding")){if(this.padding){for(var p=0;p<f;++p)a[c+u+p]=f;l=u+=f}else if(u%16)throw new n("data length must be a multiple of the block size")}else u+=f;var w=new Uint8Array(s+l);return s&&w.set(r),u&&i.cipher(h,o+c,u),l&&w.set(a.subarray(c,c+l),s),this.result=w,this.pos=0,this.len=0,this}AES_Decrypt_process(t){if(!p(t))throw new TypeError("data isn't of expected type");var r=this.asm,s=this.heap,i=e.DEC[this.mode],n=e.HEAP_DATA,a=this.pos,h=this.len,o=0,c=t.length||0,u=0,f=h+c&-16,l=0,w=0;this.padding&&(f-=l=h+c-f||16);for(var _=new Uint8Array(f);c>0;)h+=w=y(s,a+h,t,o,c),o+=w,c-=w,(w=r.cipher(i,n+a,h-(c?0:l)))&&_.set(s.subarray(a,a+w),u),u+=w,w<h?(a+=w,h-=w):(a=0,h=0);return this.result=_,this.pos=a,this.len=h,this}AES_Decrypt_finish(t){var r=null,s=0;void 0!==t&&(s=(r=this.AES_Decrypt_process(t).result).length);var i=this.asm,h=this.heap,o=e.DEC[this.mode],c=e.HEAP_DATA,u=this.pos,f=this.len,l=f;if(f>0){if(f%16){if(this.hasOwnProperty("padding"))throw new n("data length must be a multiple of the block size");f+=16-f%16}if(i.cipher(o,c+u,f),this.hasOwnProperty("padding")&&this.padding){var p=h[u+l-1];if(p<1||p>16||p>l)throw new a("bad padding");for(var w=0,y=p;y>1;y--)w|=p^h[u+l-y];if(w)throw new a("bad padding");l-=p}}var _=new Uint8Array(s+l);return s>0&&_.set(r),l>0&&_.set(h.subarray(u,u+l),s),this.result=_,this.pos=0,this.len=0,this}}var d=68719476704;class A extends _{constructor(t,e,r,s,i,n){super(t,void 0,!1,i,n),this.nonce=null,this.adata=null,this.iv=null,this.counter=1,this.tagSize=16,this.mode="GCM",this.BLOCK_SIZE=16,this.reset(t,s,e,r)}reset(t,e,r,s){return this.AES_GCM_reset(t,e,r,s)}encrypt(t){return this.AES_GCM_encrypt(t)}decrypt(t){return this.AES_GCM_decrypt(t)}AES_GCM_Encrypt_process(t){if(!p(t))throw new TypeError("data isn't of expected type");var r=0,s=t.length||0,i=this.asm,n=this.heap,a=this.counter,h=this.pos,o=this.len,c=0,u=o+s&-16,f=0;if((a-1<<4)+o+s>d)throw new RangeError("counter overflow");for(var l=new Uint8Array(u);s>0;)o+=f=y(n,h+o,t,r,s),r+=f,s-=f,f=i.cipher(e.ENC.CTR,e.HEAP_DATA+h,o),(f=i.mac(e.MAC.GCM,e.HEAP_DATA+h,f))&&l.set(n.subarray(h,h+f),c),a+=f>>>4,c+=f,f<o?(h+=f,o-=f):(h=0,o=0);return this.result=l,this.counter=a,this.pos=h,this.len=o,this}AES_GCM_Encrypt_finish(){var t=this.asm,r=this.heap,s=this.counter,i=this.tagSize,n=this.adata,a=this.pos,h=this.len,o=new Uint8Array(h+i);t.cipher(e.ENC.CTR,e.HEAP_DATA+a,h+15&-16),h&&o.set(r.subarray(a,a+h));for(var c=h;15&c;c++)r[a+c]=0;t.mac(e.MAC.GCM,e.HEAP_DATA+a,c);var u=null!==n?n.length:0,f=(s-1<<4)+h;return r[0]=r[1]=r[2]=0,r[3]=u>>>29,r[4]=u>>>21,r[5]=u>>>13&255,r[6]=u>>>5&255,r[7]=u<<3&255,r[8]=r[9]=r[10]=0,r[11]=f>>>29,r[12]=f>>>21&255,r[13]=f>>>13&255,r[14]=f>>>5&255,r[15]=f<<3&255,t.mac(e.MAC.GCM,e.HEAP_DATA,16),t.get_iv(e.HEAP_DATA),t.set_counter(0,0,0,this.gamma0),t.cipher(e.ENC.CTR,e.HEAP_DATA,16),o.set(r.subarray(0,i),h),this.result=o,this.counter=1,this.pos=0,this.len=0,this}AES_GCM_Decrypt_process(t){if(!p(t))throw new TypeError("data isn't of expected type");var r=0,s=t.length||0,i=this.asm,n=this.heap,a=this.counter,h=this.tagSize,o=this.pos,c=this.len,u=0,f=c+s>h?c+s-h&-16:0,l=c+s-f,w=0;if((a-1<<4)+c+s>d)throw new RangeError("counter overflow");for(var _=new Uint8Array(f);s>l;)c+=w=y(n,o+c,t,r,s-l),r+=w,s-=w,w=i.mac(e.MAC.GCM,e.HEAP_DATA+o,w),(w=i.cipher(e.DEC.CTR,e.HEAP_DATA+o,w))&&_.set(n.subarray(o,o+w),u),a+=w>>>4,u+=w,o=0,c=0;return s>0&&(c+=y(n,0,t,r,s)),this.result=_,this.counter=a,this.pos=o,this.len=c,this}AES_GCM_Decrypt_finish(){var t=this.asm,r=this.heap,s=this.tagSize,n=this.adata,h=this.counter,o=this.pos,c=this.len,u=c-s;if(c<s)throw new i("authentication tag not found");for(var f=new Uint8Array(u),l=new Uint8Array(r.subarray(o+u,o+c)),p=u;15&p;p++)r[o+p]=0;t.mac(e.MAC.GCM,e.HEAP_DATA+o,p),t.cipher(e.DEC.CTR,e.HEAP_DATA+o,p),u&&f.set(r.subarray(o,o+u));var w=null!==n?n.length:0,y=(h-1<<4)+c-s;r[0]=r[1]=r[2]=0,r[3]=w>>>29,r[4]=w>>>21,r[5]=w>>>13&255,r[6]=w>>>5&255,r[7]=w<<3&255,r[8]=r[9]=r[10]=0,r[11]=y>>>29,r[12]=y>>>21&255,r[13]=y>>>13&255,r[14]=y>>>5&255,r[15]=y<<3&255,t.mac(e.MAC.GCM,e.HEAP_DATA,16),t.get_iv(e.HEAP_DATA),t.set_counter(0,0,0,this.gamma0),t.cipher(e.ENC.CTR,e.HEAP_DATA,16);var _=0;for(p=0;p<s;++p)_|=l[p]^r[p];if(_)throw new a("data integrity check failed");return this.result=f,this.counter=1,this.pos=0,this.len=0,this}AES_GCM_decrypt(t){var e=this.AES_GCM_Decrypt_process(t).result,r=this.AES_GCM_Decrypt_finish().result,s=new Uint8Array(e.length+r.length);return e.length&&s.set(e),r.length&&s.set(r,e.length),this.result=s,this}AES_GCM_encrypt(t){var e=this.AES_GCM_Encrypt_process(t).result,r=this.AES_GCM_Encrypt_finish().result,s=new Uint8Array(e.length+r.length);return e.length&&s.set(e),r.length&&s.set(r,e.length),this.result=s,this}AES_GCM_reset(t,r,s,i,a,h){this.AES_reset(t,void 0,!1);var o=this.asm,c=this.heap;if(o.gcm_init(),void 0!==(r=r)){if(!u(r))throw new TypeError("tagSize must be a number");if(r<4||r>16)throw new n("illegal tagSize value");this.tagSize=r}else this.tagSize=16;if(void 0===s)throw new Error("nonce is required");if(!p(s))throw new TypeError("unexpected nonce type");this.nonce=s;var f=s.length||0,l=new Uint8Array(16);12!==f?(this._gcm_mac_process(s),c[0]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=0,c[11]=f>>>29,c[12]=f>>>21&255,c[13]=f>>>13&255,c[14]=f>>>5&255,c[15]=f<<3&255,o.mac(e.MAC.GCM,e.HEAP_DATA,16),o.get_iv(e.HEAP_DATA),o.set_iv(),l.set(c.subarray(0,16))):(l.set(s),l[15]=1);var w=new DataView(l.buffer);if(this.gamma0=w.getUint32(12),o.set_nonce(w.getUint32(0),w.getUint32(4),w.getUint32(8),0),o.set_mask(0,0,0,4294967295),void 0!==i&&null!==i){if(!p(i))throw new TypeError("unexpected adata type");if(i.length>d)throw new n("illegal adata length");i.length?(this.adata=i,this._gcm_mac_process(i)):this.adata=null}else this.adata=null;if(void 0!==a){if(!u(a))throw new TypeError("counter must be a number");if(a<1||a>4294967295)throw new RangeError("counter must be a positive 32-bit integer");this.counter=a,o.set_counter(0,0,0,this.gamma0+a|0)}else this.counter=1,o.set_counter(0,0,0,this.gamma0+1|0);if(void 0!==h){if(!u(h))throw new TypeError("iv must be a number");this.iv=h,this.AES_set_iv(h)}return this}_gcm_mac_process(t){for(var r=this.heap,s=this.asm,i=0,n=t.length||0,a=0;n>0;){for(i+=a=y(r,0,t,i,n),n-=a;15&a;)r[a++]=0;s.mac(e.MAC.GCM,e.HEAP_DATA,a)}}}A.encrypt=function(t,e,i,n,a){if(void 0===t)throw new SyntaxError("data required");if(void 0===e)throw new SyntaxError("key required");if(void 0===i)throw new SyntaxError("nonce required");return new A(e,i,n,a,r,s).encrypt(t).result},A.decrypt=function(t,e,i,n,a){if(void 0===t)throw new SyntaxError("data required");if(void 0===e)throw new SyntaxError("key required");if(void 0===i)throw new SyntaxError("nonce required");return new A(e,i,n,a,r,s).decrypt(t).result};class v{constructor(t){if(!(t=t||{}).hash)throw new SyntaxError("option 'hash' is required");if(!t.hash.HASH_SIZE)throw new SyntaxError("option 'hash' supplied doesn't seem to be a valid hash function");return this.hash=t.hash,this.BLOCK_SIZE=this.hash.BLOCK_SIZE,this.HMAC_SIZE=this.hash.HASH_SIZE,this.key=null,this.verify=null,this.result=null,void 0===t.password&&void 0===t.verify||this.reset(t),this}reset(t){var e=(t=t||{}).password;if(null===this.key&&!f(e)&&!e)throw new i("no key is associated with the instance");this.result=null,this.hash.reset(),(e||f(e))&&(this.key=x(this.hash,e));for(var r=new Uint8Array(this.key),s=0;s<r.length;++s)r[s]^=54;this.hash.process(r);var n=t.verify;return void 0!==n?this._hmac_init_verify(n):this.verify=null,this}process(t){if(null===this.key)throw new i("no key is associated with the instance");if(null!==this.result)throw new i("state must be reset before processing new data");return this.hash.process(t),this}finish(){if(null===this.key)throw new i("no key is associated with the instance");if(null!==this.result)throw new i("state must be reset before processing new data");for(var t=this.hash.finish().result,e=new Uint8Array(this.key),r=0;r<e.length;++r)e[r]^=92;var s=this.verify,n=this.hash.reset().process(e).process(t).finish().result;if(s)if(s.length===n.length){var a=0;for(r=0;r<s.length;r++)a|=s[r]^n[r];this.result=!a}else this.result=!1;else this.result=n;return this}_hmac_init_verify(t){if(l(t)||p(t))t=new Uint8Array(t);else{if(!f(t))throw new TypeError("verify tag isn't of expected type");t=h(t)}if(t.length!==this.HMAC_SIZE)throw new n("illegal verification tag size");this.verify=t}}function x(t,e){if(l(e)&&(e=new Uint8Array(e)),f(e)&&(e=h(e)),!p(e))throw new TypeError("password isn't of expected type");var r=new Uint8Array(t.BLOCK_SIZE);return e.length>t.BLOCK_SIZE?r.set(t.reset().process(e).finish().result):r.set(e),r}var E=64,g=32;function m(t){t=t||{},this.heap=w(Uint8Array,t.heap),this.asm=t.asm||function(t,e,r){"use asm";var s=0,i=0,n=0,a=0,h=0,o=0,c=0,u=0,f=0,l=0,p=0,w=0,y=0,_=0,d=0,A=0,v=0,x=0,E=0,g=0,m=0,b=0,S=0,C=0,M=0,U=0,H=new t.Uint8Array(r);function T(t,e,r,f,l,p,w,y,_,d,A,v,x,E,g,m){t=t|0;e=e|0;r=r|0;f=f|0;l=l|0;p=p|0;w=w|0;y=y|0;_=_|0;d=d|0;A=A|0;v=v|0;x=x|0;E=E|0;g=g|0;m=m|0;var b=0,S=0,C=0,M=0,U=0,H=0,T=0,D=0;b=s;S=i;C=n;M=a;U=h;H=o;T=c;D=u;D=t+D+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(T^U&(H^T))+0x428a2f98|0;M=M+D|0;D=D+(b&S^C&(b^S))+(b>>>2^b>>>13^b>>>22^b<<30^b<<19^b<<10)|0;T=e+T+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(H^M&(U^H))+0x71374491|0;C=C+T|0;T=T+(D&b^S&(D^b))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;H=r+H+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(U^C&(M^U))+0xb5c0fbcf|0;S=S+H|0;H=H+(T&D^b&(T^D))+(T>>>2^T>>>13^T>>>22^T<<30^T<<19^T<<10)|0;U=f+U+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(M^S&(C^M))+0xe9b5dba5|0;b=b+U|0;U=U+(H&T^D&(H^T))+(H>>>2^H>>>13^H>>>22^H<<30^H<<19^H<<10)|0;M=l+M+(b>>>6^b>>>11^b>>>25^b<<26^b<<21^b<<7)+(C^b&(S^C))+0x3956c25b|0;D=D+M|0;M=M+(U&H^T&(U^H))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;C=p+C+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(S^D&(b^S))+0x59f111f1|0;T=T+C|0;C=C+(M&U^H&(M^U))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;S=w+S+(T>>>6^T>>>11^T>>>25^T<<26^T<<21^T<<7)+(b^T&(D^b))+0x923f82a4|0;H=H+S|0;S=S+(C&M^U&(C^M))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;b=y+b+(H>>>6^H>>>11^H>>>25^H<<26^H<<21^H<<7)+(D^H&(T^D))+0xab1c5ed5|0;U=U+b|0;b=b+(S&C^M&(S^C))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;D=_+D+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(T^U&(H^T))+0xd807aa98|0;M=M+D|0;D=D+(b&S^C&(b^S))+(b>>>2^b>>>13^b>>>22^b<<30^b<<19^b<<10)|0;T=d+T+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(H^M&(U^H))+0x12835b01|0;C=C+T|0;T=T+(D&b^S&(D^b))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;H=A+H+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(U^C&(M^U))+0x243185be|0;S=S+H|0;H=H+(T&D^b&(T^D))+(T>>>2^T>>>13^T>>>22^T<<30^T<<19^T<<10)|0;U=v+U+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(M^S&(C^M))+0x550c7dc3|0;b=b+U|0;U=U+(H&T^D&(H^T))+(H>>>2^H>>>13^H>>>22^H<<30^H<<19^H<<10)|0;M=x+M+(b>>>6^b>>>11^b>>>25^b<<26^b<<21^b<<7)+(C^b&(S^C))+0x72be5d74|0;D=D+M|0;M=M+(U&H^T&(U^H))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;C=E+C+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(S^D&(b^S))+0x80deb1fe|0;T=T+C|0;C=C+(M&U^H&(M^U))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;S=g+S+(T>>>6^T>>>11^T>>>25^T<<26^T<<21^T<<7)+(b^T&(D^b))+0x9bdc06a7|0;H=H+S|0;S=S+(C&M^U&(C^M))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;b=m+b+(H>>>6^H>>>11^H>>>25^H<<26^H<<21^H<<7)+(D^H&(T^D))+0xc19bf174|0;U=U+b|0;b=b+(S&C^M&(S^C))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;t=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(g>>>17^g>>>19^g>>>10^g<<15^g<<13)+t+d|0;D=t+D+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(T^U&(H^T))+0xe49b69c1|0;M=M+D|0;D=D+(b&S^C&(b^S))+(b>>>2^b>>>13^b>>>22^b<<30^b<<19^b<<10)|0;e=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(m>>>17^m>>>19^m>>>10^m<<15^m<<13)+e+A|0;T=e+T+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(H^M&(U^H))+0xefbe4786|0;C=C+T|0;T=T+(D&b^S&(D^b))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;r=(f>>>7^f>>>18^f>>>3^f<<25^f<<14)+(t>>>17^t>>>19^t>>>10^t<<15^t<<13)+r+v|0;H=r+H+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(U^C&(M^U))+0x0fc19dc6|0;S=S+H|0;H=H+(T&D^b&(T^D))+(T>>>2^T>>>13^T>>>22^T<<30^T<<19^T<<10)|0;f=(l>>>7^l>>>18^l>>>3^l<<25^l<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+f+x|0;U=f+U+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(M^S&(C^M))+0x240ca1cc|0;b=b+U|0;U=U+(H&T^D&(H^T))+(H>>>2^H>>>13^H>>>22^H<<30^H<<19^H<<10)|0;l=(p>>>7^p>>>18^p>>>3^p<<25^p<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+l+E|0;M=l+M+(b>>>6^b>>>11^b>>>25^b<<26^b<<21^b<<7)+(C^b&(S^C))+0x2de92c6f|0;D=D+M|0;M=M+(U&H^T&(U^H))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;p=(w>>>7^w>>>18^w>>>3^w<<25^w<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+p+g|0;C=p+C+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(S^D&(b^S))+0x4a7484aa|0;T=T+C|0;C=C+(M&U^H&(M^U))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;w=(y>>>7^y>>>18^y>>>3^y<<25^y<<14)+(l>>>17^l>>>19^l>>>10^l<<15^l<<13)+w+m|0;S=w+S+(T>>>6^T>>>11^T>>>25^T<<26^T<<21^T<<7)+(b^T&(D^b))+0x5cb0a9dc|0;H=H+S|0;S=S+(C&M^U&(C^M))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;y=(_>>>7^_>>>18^_>>>3^_<<25^_<<14)+(p>>>17^p>>>19^p>>>10^p<<15^p<<13)+y+t|0;b=y+b+(H>>>6^H>>>11^H>>>25^H<<26^H<<21^H<<7)+(D^H&(T^D))+0x76f988da|0;U=U+b|0;b=b+(S&C^M&(S^C))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;_=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(w>>>17^w>>>19^w>>>10^w<<15^w<<13)+_+e|0;D=_+D+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(T^U&(H^T))+0x983e5152|0;M=M+D|0;D=D+(b&S^C&(b^S))+(b>>>2^b>>>13^b>>>22^b<<30^b<<19^b<<10)|0;d=(A>>>7^A>>>18^A>>>3^A<<25^A<<14)+(y>>>17^y>>>19^y>>>10^y<<15^y<<13)+d+r|0;T=d+T+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(H^M&(U^H))+0xa831c66d|0;C=C+T|0;T=T+(D&b^S&(D^b))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;A=(v>>>7^v>>>18^v>>>3^v<<25^v<<14)+(_>>>17^_>>>19^_>>>10^_<<15^_<<13)+A+f|0;H=A+H+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(U^C&(M^U))+0xb00327c8|0;S=S+H|0;H=H+(T&D^b&(T^D))+(T>>>2^T>>>13^T>>>22^T<<30^T<<19^T<<10)|0;v=(x>>>7^x>>>18^x>>>3^x<<25^x<<14)+(d>>>17^d>>>19^d>>>10^d<<15^d<<13)+v+l|0;U=v+U+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(M^S&(C^M))+0xbf597fc7|0;b=b+U|0;U=U+(H&T^D&(H^T))+(H>>>2^H>>>13^H>>>22^H<<30^H<<19^H<<10)|0;x=(E>>>7^E>>>18^E>>>3^E<<25^E<<14)+(A>>>17^A>>>19^A>>>10^A<<15^A<<13)+x+p|0;M=x+M+(b>>>6^b>>>11^b>>>25^b<<26^b<<21^b<<7)+(C^b&(S^C))+0xc6e00bf3|0;D=D+M|0;M=M+(U&H^T&(U^H))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;E=(g>>>7^g>>>18^g>>>3^g<<25^g<<14)+(v>>>17^v>>>19^v>>>10^v<<15^v<<13)+E+w|0;C=E+C+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(S^D&(b^S))+0xd5a79147|0;T=T+C|0;C=C+(M&U^H&(M^U))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;g=(m>>>7^m>>>18^m>>>3^m<<25^m<<14)+(x>>>17^x>>>19^x>>>10^x<<15^x<<13)+g+y|0;S=g+S+(T>>>6^T>>>11^T>>>25^T<<26^T<<21^T<<7)+(b^T&(D^b))+0x06ca6351|0;H=H+S|0;S=S+(C&M^U&(C^M))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;m=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(E>>>17^E>>>19^E>>>10^E<<15^E<<13)+m+_|0;b=m+b+(H>>>6^H>>>11^H>>>25^H<<26^H<<21^H<<7)+(D^H&(T^D))+0x14292967|0;U=U+b|0;b=b+(S&C^M&(S^C))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;t=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(g>>>17^g>>>19^g>>>10^g<<15^g<<13)+t+d|0;D=t+D+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(T^U&(H^T))+0x27b70a85|0;M=M+D|0;D=D+(b&S^C&(b^S))+(b>>>2^b>>>13^b>>>22^b<<30^b<<19^b<<10)|0;e=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(m>>>17^m>>>19^m>>>10^m<<15^m<<13)+e+A|0;T=e+T+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(H^M&(U^H))+0x2e1b2138|0;C=C+T|0;T=T+(D&b^S&(D^b))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;r=(f>>>7^f>>>18^f>>>3^f<<25^f<<14)+(t>>>17^t>>>19^t>>>10^t<<15^t<<13)+r+v|0;H=r+H+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(U^C&(M^U))+0x4d2c6dfc|0;S=S+H|0;H=H+(T&D^b&(T^D))+(T>>>2^T>>>13^T>>>22^T<<30^T<<19^T<<10)|0;f=(l>>>7^l>>>18^l>>>3^l<<25^l<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+f+x|0;U=f+U+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(M^S&(C^M))+0x53380d13|0;b=b+U|0;U=U+(H&T^D&(H^T))+(H>>>2^H>>>13^H>>>22^H<<30^H<<19^H<<10)|0;l=(p>>>7^p>>>18^p>>>3^p<<25^p<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+l+E|0;M=l+M+(b>>>6^b>>>11^b>>>25^b<<26^b<<21^b<<7)+(C^b&(S^C))+0x650a7354|0;D=D+M|0;M=M+(U&H^T&(U^H))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;p=(w>>>7^w>>>18^w>>>3^w<<25^w<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+p+g|0;C=p+C+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(S^D&(b^S))+0x766a0abb|0;T=T+C|0;C=C+(M&U^H&(M^U))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;w=(y>>>7^y>>>18^y>>>3^y<<25^y<<14)+(l>>>17^l>>>19^l>>>10^l<<15^l<<13)+w+m|0;S=w+S+(T>>>6^T>>>11^T>>>25^T<<26^T<<21^T<<7)+(b^T&(D^b))+0x81c2c92e|0;H=H+S|0;S=S+(C&M^U&(C^M))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;y=(_>>>7^_>>>18^_>>>3^_<<25^_<<14)+(p>>>17^p>>>19^p>>>10^p<<15^p<<13)+y+t|0;b=y+b+(H>>>6^H>>>11^H>>>25^H<<26^H<<21^H<<7)+(D^H&(T^D))+0x92722c85|0;U=U+b|0;b=b+(S&C^M&(S^C))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;_=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(w>>>17^w>>>19^w>>>10^w<<15^w<<13)+_+e|0;D=_+D+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(T^U&(H^T))+0xa2bfe8a1|0;M=M+D|0;D=D+(b&S^C&(b^S))+(b>>>2^b>>>13^b>>>22^b<<30^b<<19^b<<10)|0;d=(A>>>7^A>>>18^A>>>3^A<<25^A<<14)+(y>>>17^y>>>19^y>>>10^y<<15^y<<13)+d+r|0;T=d+T+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(H^M&(U^H))+0xa81a664b|0;C=C+T|0;T=T+(D&b^S&(D^b))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;A=(v>>>7^v>>>18^v>>>3^v<<25^v<<14)+(_>>>17^_>>>19^_>>>10^_<<15^_<<13)+A+f|0;H=A+H+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(U^C&(M^U))+0xc24b8b70|0;S=S+H|0;H=H+(T&D^b&(T^D))+(T>>>2^T>>>13^T>>>22^T<<30^T<<19^T<<10)|0;v=(x>>>7^x>>>18^x>>>3^x<<25^x<<14)+(d>>>17^d>>>19^d>>>10^d<<15^d<<13)+v+l|0;U=v+U+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(M^S&(C^M))+0xc76c51a3|0;b=b+U|0;U=U+(H&T^D&(H^T))+(H>>>2^H>>>13^H>>>22^H<<30^H<<19^H<<10)|0;x=(E>>>7^E>>>18^E>>>3^E<<25^E<<14)+(A>>>17^A>>>19^A>>>10^A<<15^A<<13)+x+p|0;M=x+M+(b>>>6^b>>>11^b>>>25^b<<26^b<<21^b<<7)+(C^b&(S^C))+0xd192e819|0;D=D+M|0;M=M+(U&H^T&(U^H))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;E=(g>>>7^g>>>18^g>>>3^g<<25^g<<14)+(v>>>17^v>>>19^v>>>10^v<<15^v<<13)+E+w|0;C=E+C+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(S^D&(b^S))+0xd6990624|0;T=T+C|0;C=C+(M&U^H&(M^U))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;g=(m>>>7^m>>>18^m>>>3^m<<25^m<<14)+(x>>>17^x>>>19^x>>>10^x<<15^x<<13)+g+y|0;S=g+S+(T>>>6^T>>>11^T>>>25^T<<26^T<<21^T<<7)+(b^T&(D^b))+0xf40e3585|0;H=H+S|0;S=S+(C&M^U&(C^M))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;m=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(E>>>17^E>>>19^E>>>10^E<<15^E<<13)+m+_|0;b=m+b+(H>>>6^H>>>11^H>>>25^H<<26^H<<21^H<<7)+(D^H&(T^D))+0x106aa070|0;U=U+b|0;b=b+(S&C^M&(S^C))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;t=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(g>>>17^g>>>19^g>>>10^g<<15^g<<13)+t+d|0;D=t+D+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(T^U&(H^T))+0x19a4c116|0;M=M+D|0;D=D+(b&S^C&(b^S))+(b>>>2^b>>>13^b>>>22^b<<30^b<<19^b<<10)|0;e=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(m>>>17^m>>>19^m>>>10^m<<15^m<<13)+e+A|0;T=e+T+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(H^M&(U^H))+0x1e376c08|0;C=C+T|0;T=T+(D&b^S&(D^b))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;r=(f>>>7^f>>>18^f>>>3^f<<25^f<<14)+(t>>>17^t>>>19^t>>>10^t<<15^t<<13)+r+v|0;H=r+H+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(U^C&(M^U))+0x2748774c|0;S=S+H|0;H=H+(T&D^b&(T^D))+(T>>>2^T>>>13^T>>>22^T<<30^T<<19^T<<10)|0;f=(l>>>7^l>>>18^l>>>3^l<<25^l<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+f+x|0;U=f+U+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(M^S&(C^M))+0x34b0bcb5|0;b=b+U|0;U=U+(H&T^D&(H^T))+(H>>>2^H>>>13^H>>>22^H<<30^H<<19^H<<10)|0;l=(p>>>7^p>>>18^p>>>3^p<<25^p<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+l+E|0;M=l+M+(b>>>6^b>>>11^b>>>25^b<<26^b<<21^b<<7)+(C^b&(S^C))+0x391c0cb3|0;D=D+M|0;M=M+(U&H^T&(U^H))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;p=(w>>>7^w>>>18^w>>>3^w<<25^w<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+p+g|0;C=p+C+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(S^D&(b^S))+0x4ed8aa4a|0;T=T+C|0;C=C+(M&U^H&(M^U))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;w=(y>>>7^y>>>18^y>>>3^y<<25^y<<14)+(l>>>17^l>>>19^l>>>10^l<<15^l<<13)+w+m|0;S=w+S+(T>>>6^T>>>11^T>>>25^T<<26^T<<21^T<<7)+(b^T&(D^b))+0x5b9cca4f|0;H=H+S|0;S=S+(C&M^U&(C^M))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;y=(_>>>7^_>>>18^_>>>3^_<<25^_<<14)+(p>>>17^p>>>19^p>>>10^p<<15^p<<13)+y+t|0;b=y+b+(H>>>6^H>>>11^H>>>25^H<<26^H<<21^H<<7)+(D^H&(T^D))+0x682e6ff3|0;U=U+b|0;b=b+(S&C^M&(S^C))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;_=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(w>>>17^w>>>19^w>>>10^w<<15^w<<13)+_+e|0;D=_+D+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(T^U&(H^T))+0x748f82ee|0;M=M+D|0;D=D+(b&S^C&(b^S))+(b>>>2^b>>>13^b>>>22^b<<30^b<<19^b<<10)|0;d=(A>>>7^A>>>18^A>>>3^A<<25^A<<14)+(y>>>17^y>>>19^y>>>10^y<<15^y<<13)+d+r|0;T=d+T+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(H^M&(U^H))+0x78a5636f|0;C=C+T|0;T=T+(D&b^S&(D^b))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;A=(v>>>7^v>>>18^v>>>3^v<<25^v<<14)+(_>>>17^_>>>19^_>>>10^_<<15^_<<13)+A+f|0;H=A+H+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(U^C&(M^U))+0x84c87814|0;S=S+H|0;H=H+(T&D^b&(T^D))+(T>>>2^T>>>13^T>>>22^T<<30^T<<19^T<<10)|0;v=(x>>>7^x>>>18^x>>>3^x<<25^x<<14)+(d>>>17^d>>>19^d>>>10^d<<15^d<<13)+v+l|0;U=v+U+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(M^S&(C^M))+0x8cc70208|0;b=b+U|0;U=U+(H&T^D&(H^T))+(H>>>2^H>>>13^H>>>22^H<<30^H<<19^H<<10)|0;x=(E>>>7^E>>>18^E>>>3^E<<25^E<<14)+(A>>>17^A>>>19^A>>>10^A<<15^A<<13)+x+p|0;M=x+M+(b>>>6^b>>>11^b>>>25^b<<26^b<<21^b<<7)+(C^b&(S^C))+0x90befffa|0;D=D+M|0;M=M+(U&H^T&(U^H))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;E=(g>>>7^g>>>18^g>>>3^g<<25^g<<14)+(v>>>17^v>>>19^v>>>10^v<<15^v<<13)+E+w|0;C=E+C+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(S^D&(b^S))+0xa4506ceb|0;T=T+C|0;C=C+(M&U^H&(M^U))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;g=(m>>>7^m>>>18^m>>>3^m<<25^m<<14)+(x>>>17^x>>>19^x>>>10^x<<15^x<<13)+g+y|0;S=g+S+(T>>>6^T>>>11^T>>>25^T<<26^T<<21^T<<7)+(b^T&(D^b))+0xbef9a3f7|0;H=H+S|0;S=S+(C&M^U&(C^M))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;m=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(E>>>17^E>>>19^E>>>10^E<<15^E<<13)+m+_|0;b=m+b+(H>>>6^H>>>11^H>>>25^H<<26^H<<21^H<<7)+(D^H&(T^D))+0xc67178f2|0;U=U+b|0;b=b+(S&C^M&(S^C))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;s=s+b|0;i=i+S|0;n=n+C|0;a=a+M|0;h=h+U|0;o=o+H|0;c=c+T|0;u=u+D|0}function D(t){t=t|0;T(H[t|0]<<24|H[t|1]<<16|H[t|2]<<8|H[t|3],H[t|4]<<24|H[t|5]<<16|H[t|6]<<8|H[t|7],H[t|8]<<24|H[t|9]<<16|H[t|10]<<8|H[t|11],H[t|12]<<24|H[t|13]<<16|H[t|14]<<8|H[t|15],H[t|16]<<24|H[t|17]<<16|H[t|18]<<8|H[t|19],H[t|20]<<24|H[t|21]<<16|H[t|22]<<8|H[t|23],H[t|24]<<24|H[t|25]<<16|H[t|26]<<8|H[t|27],H[t|28]<<24|H[t|29]<<16|H[t|30]<<8|H[t|31],H[t|32]<<24|H[t|33]<<16|H[t|34]<<8|H[t|35],H[t|36]<<24|H[t|37]<<16|H[t|38]<<8|H[t|39],H[t|40]<<24|H[t|41]<<16|H[t|42]<<8|H[t|43],H[t|44]<<24|H[t|45]<<16|H[t|46]<<8|H[t|47],H[t|48]<<24|H[t|49]<<16|H[t|50]<<8|H[t|51],H[t|52]<<24|H[t|53]<<16|H[t|54]<<8|H[t|55],H[t|56]<<24|H[t|57]<<16|H[t|58]<<8|H[t|59],H[t|60]<<24|H[t|61]<<16|H[t|62]<<8|H[t|63])}function k(t){t=t|0;H[t|0]=s>>>24;H[t|1]=s>>>16&255;H[t|2]=s>>>8&255;H[t|3]=s&255;H[t|4]=i>>>24;H[t|5]=i>>>16&255;H[t|6]=i>>>8&255;H[t|7]=i&255;H[t|8]=n>>>24;H[t|9]=n>>>16&255;H[t|10]=n>>>8&255;H[t|11]=n&255;H[t|12]=a>>>24;H[t|13]=a>>>16&255;H[t|14]=a>>>8&255;H[t|15]=a&255;H[t|16]=h>>>24;H[t|17]=h>>>16&255;H[t|18]=h>>>8&255;H[t|19]=h&255;H[t|20]=o>>>24;H[t|21]=o>>>16&255;H[t|22]=o>>>8&255;H[t|23]=o&255;H[t|24]=c>>>24;H[t|25]=c>>>16&255;H[t|26]=c>>>8&255;H[t|27]=c&255;H[t|28]=u>>>24;H[t|29]=u>>>16&255;H[t|30]=u>>>8&255;H[t|31]=u&255}function G(){s=0x6a09e667;i=0xbb67ae85;n=0x3c6ef372;a=0xa54ff53a;h=0x510e527f;o=0x9b05688c;c=0x1f83d9ab;u=0x5be0cd19;f=l=0}function I(t,e,r,p,w,y,_,d,A,v){t=t|0;e=e|0;r=r|0;p=p|0;w=w|0;y=y|0;_=_|0;d=d|0;A=A|0;v=v|0;s=t;i=e;n=r;a=p;h=w;o=y;c=_;u=d;f=A;l=v}function Z(t,e){t=t|0;e=e|0;var r=0;if(t&63)return-1;while((e|0)>=64){D(t);t=t+64|0;e=e-64|0;r=r+64|0}f=f+r|0;if(f>>>0<r>>>0)l=l+1|0;return r|0}function P(t,e,r){t=t|0;e=e|0;r=r|0;var s=0,i=0;if(t&63)return-1;if(~r)if(r&31)return-1;if((e|0)>=64){s=Z(t,e)|0;if((s|0)==-1)return-1;t=t+s|0;e=e-s|0}s=s+e|0;f=f+e|0;if(f>>>0<e>>>0)l=l+1|0;H[t|e]=0x80;if((e|0)>=56){for(i=e+1|0;(i|0)<64;i=i+1|0)H[t|i]=0x00;D(t);e=0;H[t|0]=0}for(i=e+1|0;(i|0)<59;i=i+1|0)H[t|i]=0;H[t|56]=l>>>21&255;H[t|57]=l>>>13&255;H[t|58]=l>>>5&255;H[t|59]=l<<3&255|f>>>29;H[t|60]=f>>>21&255;H[t|61]=f>>>13&255;H[t|62]=f>>>5&255;H[t|63]=f<<3&255;D(t);if(~r)k(r);return s|0}function B(){s=p;i=w;n=y;a=_;h=d;o=A;c=v;u=x;f=64;l=0}function z(){s=E;i=g;n=m;a=b;h=S;o=C;c=M;u=U;f=64;l=0}function O(t,e,r,H,D,k,I,Z,P,B,z,O,q,L,R,K){t=t|0;e=e|0;r=r|0;H=H|0;D=D|0;k=k|0;I=I|0;Z=Z|0;P=P|0;B=B|0;z=z|0;O=O|0;q=q|0;L=L|0;R=R|0;K=K|0;G();T(t^0x5c5c5c5c,e^0x5c5c5c5c,r^0x5c5c5c5c,H^0x5c5c5c5c,D^0x5c5c5c5c,k^0x5c5c5c5c,I^0x5c5c5c5c,Z^0x5c5c5c5c,P^0x5c5c5c5c,B^0x5c5c5c5c,z^0x5c5c5c5c,O^0x5c5c5c5c,q^0x5c5c5c5c,L^0x5c5c5c5c,R^0x5c5c5c5c,K^0x5c5c5c5c);E=s;g=i;m=n;b=a;S=h;C=o;M=c;U=u;G();T(t^0x36363636,e^0x36363636,r^0x36363636,H^0x36363636,D^0x36363636,k^0x36363636,I^0x36363636,Z^0x36363636,P^0x36363636,B^0x36363636,z^0x36363636,O^0x36363636,q^0x36363636,L^0x36363636,R^0x36363636,K^0x36363636);p=s;w=i;y=n;_=a;d=h;A=o;v=c;x=u;f=64;l=0}function q(t,e,r){t=t|0;e=e|0;r=r|0;var f=0,l=0,p=0,w=0,y=0,_=0,d=0,A=0,v=0;if(t&63)return-1;if(~r)if(r&31)return-1;v=P(t,e,-1)|0;f=s,l=i,p=n,w=a,y=h,_=o,d=c,A=u;z();T(f,l,p,w,y,_,d,A,0x80000000,0,0,0,0,0,0,768);if(~r)k(r);return v|0}function L(t,e,r,f,l){t=t|0;e=e|0;r=r|0;f=f|0;l=l|0;var p=0,w=0,y=0,_=0,d=0,A=0,v=0,x=0,E=0,g=0,m=0,b=0,S=0,C=0,M=0,U=0;if(t&63)return-1;if(~l)if(l&31)return-1;H[t+e|0]=r>>>24;H[t+e+1|0]=r>>>16&255;H[t+e+2|0]=r>>>8&255;H[t+e+3|0]=r&255;q(t,e+4|0,-1)|0;p=E=s,w=g=i,y=m=n,_=b=a,d=S=h,A=C=o,v=M=c,x=U=u;f=f-1|0;while((f|0)>0){B();T(E,g,m,b,S,C,M,U,0x80000000,0,0,0,0,0,0,768);E=s,g=i,m=n,b=a,S=h,C=o,M=c,U=u;z();T(E,g,m,b,S,C,M,U,0x80000000,0,0,0,0,0,0,768);E=s,g=i,m=n,b=a,S=h,C=o,M=c,U=u;p=p^s;w=w^i;y=y^n;_=_^a;d=d^h;A=A^o;v=v^c;x=x^u;f=f-1|0}s=p;i=w;n=y;a=_;h=d;o=A;c=v;u=x;if(~l)k(l);return 0}return{reset:G,init:I,process:Z,finish:P,hmac_reset:B,hmac_init:O,hmac_finish:q,pbkdf2_generate_block:L}}({Uint8Array:Uint8Array},null,this.heap.buffer),this.BLOCK_SIZE=E,this.HASH_SIZE=g,this.reset()}m.BLOCK_SIZE=E,m.HASH_SIZE=g,m.NAME="sha256";var b=m.prototype;b.reset=function(){return this.result=null,this.pos=0,this.len=0,this.asm.reset(),this},b.process=function(t){if(null!==this.result)throw new i("state must be reset before processing new data");if(f(t)&&(t=h(t)),l(t)&&(t=new Uint8Array(t)),!p(t))throw new TypeError("data isn't of expected type");for(var e=this.asm,r=this.heap,s=this.pos,n=this.len,a=0,o=t.length,c=0;o>0;)n+=c=y(r,s+n,t,a,o),a+=c,o-=c,s+=c=e.process(s,n),(n-=c)||(s=0);return this.pos=s,this.len=n,this},b.finish=function(){if(null!==this.result)throw new i("state must be reset before processing new data");return this.asm.finish(this.pos,this.len,0),this.result=new Uint8Array(this.HASH_SIZE),this.result.set(this.heap.subarray(0,this.HASH_SIZE)),this.pos=0,this.len=0,this};var S=null;class C extends v{constructor(t){(t=t||{}).hash instanceof m||(t.hash=(null===S&&(S=new m({heapSize:1048576})),S)),super(t)}reset(t){t=t||{},this.result=null,this.hash.reset();var e=t.password;if(void 0!==e){f(e)&&(e=h(e));var r=this.key=x(this.hash,e);this.hash.reset().asm.hmac_init(r[0]<<24|r[1]<<16|r[2]<<8|r[3],r[4]<<24|r[5]<<16|r[6]<<8|r[7],r[8]<<24|r[9]<<16|r[10]<<8|r[11],r[12]<<24|r[13]<<16|r[14]<<8|r[15],r[16]<<24|r[17]<<16|r[18]<<8|r[19],r[20]<<24|r[21]<<16|r[22]<<8|r[23],r[24]<<24|r[25]<<16|r[26]<<8|r[27],r[28]<<24|r[29]<<16|r[30]<<8|r[31],r[32]<<24|r[33]<<16|r[34]<<8|r[35],r[36]<<24|r[37]<<16|r[38]<<8|r[39],r[40]<<24|r[41]<<16|r[42]<<8|r[43],r[44]<<24|r[45]<<16|r[46]<<8|r[47],r[48]<<24|r[49]<<16|r[50]<<8|r[51],r[52]<<24|r[53]<<16|r[54]<<8|r[55],r[56]<<24|r[57]<<16|r[58]<<8|r[59],r[60]<<24|r[61]<<16|r[62]<<8|r[63])}else this.hash.asm.hmac_reset();var s=t.verify;return void 0!==s?this._hmac_init_verify(s):this.verify=null,this}finish(){if(null===this.key)throw new i("no key is associated with the instance");if(null!==this.result)throw new i("state must be reset before processing new data");var t=this.hash,e=this.hash.asm,r=this.hash.heap;e.hmac_finish(t.pos,t.len,0);var s=this.verify,n=new Uint8Array(g);if(n.set(r.subarray(0,g)),s)if(s.length===n.length){for(var a=0,h=0;h<s.length;h++)a|=s[h]^n[h];this.result=!a}else this.result=!1;else this.result=n;return this}}C.BLOCK_SIZE=m.BLOCK_SIZE,C.HMAC_SIZE=m.HASH_SIZE;var M=null;function U(){return null===M&&(M=new C),M}function H(t,e){if(void 0===t)throw new SyntaxError("data required");if(void 0===e)throw new SyntaxError("password required");return U().reset({password:e}).process(t).finish().result}var T=C;T.bytes=H,T.hex=function(t,e){return o(H(t,e))},T.base64=function(t,e){return c(H(t,e))};class D{constructor(t){if(!(t=t||{}).hmac)throw new SyntaxError("option 'hmac' is required");if(!t.hmac.HMAC_SIZE)throw new SyntaxError("option 'hmac' supplied doesn't seem to be a valid HMAC function");this.hmac=t.hmac,this.count=t.count||4096,this.length=t.length||this.hmac.HMAC_SIZE,this.result=null;var e=t.password;return(e||f(e))&&this.reset(t),this}reset(t){return this.result=null,this.hmac.reset(t),this}generate(t,e,r){if(null!==this.result)throw new i("state must be reset before processing new data");if(!t&&!f(t))throw new n("bad 'salt' value");e=e||this.count,r=r||this.length,this.result=new Uint8Array(r);for(var s=Math.ceil(r/this.hmac.HMAC_SIZE),a=1;a<=s;++a){var h=(a-1)*this.hmac.HMAC_SIZE,o=(a<s?0:r%this.hmac.HMAC_SIZE)||this.hmac.HMAC_SIZE,c=new Uint8Array(this.hmac.reset().process(t).process(new Uint8Array([a>>>24&255,a>>>16&255,a>>>8&255,255&a])).finish().result);this.result.set(c.subarray(0,o),h);for(var u=1;u<e;++u){c=new Uint8Array(this.hmac.reset().process(c).finish().result);for(var l=0;l<o;++l)this.result[h+l]^=c[l]}}return this}}class k extends D{constructor(t){(t=t||{}).hmac instanceof C||(t.hmac=U()),super(t)}generate(t,e,r){if(null!==this.result)throw new i("state must be reset before processing new data");if(!t&&!f(t))throw new n("bad 'salt' value");e=e||this.count,r=r||this.length,this.result=new Uint8Array(r);for(var s=Math.ceil(r/this.hmac.HMAC_SIZE),a=1;a<=s;++a){var h=(a-1)*this.hmac.HMAC_SIZE,o=(a<s?0:r%this.hmac.HMAC_SIZE)||this.hmac.HMAC_SIZE;this.hmac.reset().process(t),this.hmac.hash.asm.pbkdf2_generate_block(this.hmac.hash.pos,this.hmac.hash.len,a,e,0),this.result.set(this.hmac.hash.heap.subarray(0,o),h)}return this}}var G=null;function I(t,e,r,s){if(void 0===t)throw new SyntaxError("password required");if(void 0===e)throw new SyntaxError("salt required");return(null===G&&(G=new k),G).reset({password:t}).generate(e,r,s).result}var Z={bytes:I,hex:function(t,e,r,s){return o(I(t,e,r,s))},base64:function(t,e,r,s){return c(I(t,e,r,s))}};t.AES_GCM=A,t.AES_GCM_Encrypt=class extends A{constructor(t,e,r,s,i,n){super(t,e,r,s,i,n)}process(t){return this.AES_GCM_Encrypt_process(t)}finish(){return this.AES_GCM_Encrypt_finish()}},t.AES_GCM_Decrypt=class extends A{constructor(t,e,r,s,i,n){super(t,e,r,s,i,n)}process(t){return this.AES_GCM_Decrypt_process(t)}finish(){return this.AES_GCM_Decrypt_finish()}},t.HMAC_SHA256=T,t.PBKDF2_HMAC_SHA256=Z,Object.defineProperty(t,"__esModule",{value:!0})});