fox-send/assets/cryptofill.js

15 lines
58 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,t={name:"Unknown",version:"0"},n=self.navigator.userAgent;return(e=/edge\/([\d\.]+)/i.exec(n))?(t.name=r.Browser.Edge,t.version=e[1]):/msie/i.test(n)?(t.name=r.Browser.IE,t.version=/msie ([\d\.]+)/i.exec(n)[1]):/Trident/i.test(n)?(t.name=r.Browser.IE,t.version=/rv:([\d\.]+)/i.exec(n)[1]):/chrome/i.test(n)?(t.name=r.Browser.Chrome,t.version=/chrome\/([\d\.]+)/i.exec(n)[1]):/safari/i.test(n)?(t.name=r.Browser.Safari,t.version=/version\/([\d\.]+)/i.exec(n)[1]):/firefox/i.test(n)&&(t.name=r.Browser.Firefox,t.version=/firefox\/([\d\.]+)/i.exec(n)[1]),t}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}]);