Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webcrypto-liner

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webcrypto-liner - npm Package Compare versions

Comparing version 0.1.23 to 0.1.24

0

BrowserSupport.md

@@ -0,0 +0,0 @@ # WebCrypto-Liner Browser Support

4

dist/webcrypto-liner.lib.js

@@ -1,2 +0,2 @@

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.i=function(e){return e},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=15)}([function(e,r,t){"use strict";(function(e){function n(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];for(var n,a=e,o=/[^%](%\d+)/g,i=[];n=o.exec(a);)i.push({arg:n[1],index:n.index});for(var s=i.length-1;s>=0;s--){var c=i[s],u=c.arg.substring(1),h=c.index+1;a=a.substring(0,h)+arguments[+u]+a.substring(h+1+u.length)}return a=a.replace("%%","%")}function a(e){var r;r="string"==typeof e?{name:e}:e,h.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(ArrayBuffer.isView(e))return new Uint8Array(e.buffer);if(e instanceof ArrayBuffer)return new Uint8Array(e);throw new s("Incoming parameter '"+r+"' has wrong data type. Must be ArrayBufferView or ArrayBuffer")}Object.defineProperty(r,"__esModule",{value:!0});var i=t(6);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 h}),t.d(r,"AlgorithmNames",function(){return p}),t.d(r,"Base64Url",function(){return l}),t.d(r,"SubtleCrypto",function(){return W}),t.d(r,"Aes",function(){return m}),t.d(r,"AesAlgorithmError",function(){return A}),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 d}),t.d(r,"AesGCM",function(){return E}),t.d(r,"AesKW",function(){return P}),t.d(r,"RsaKeyGenParamsError",function(){return O}),t.d(r,"RsaHashedImportParamsError",function(){return G}),t.d(r,"Rsa",function(){return M}),t.d(r,"RsaSSA",function(){return B}),t.d(r,"RsaPSSParamsError",function(){return T}),t.d(r,"RsaPSS",function(){return D}),t.d(r,"RsaOAEPParamsError",function(){return x}),t.d(r,"RsaOAEP",function(){return H}),t.d(r,"EcKeyGenParamsError",function(){return S}),t.d(r,"Ec",function(){return _}),t.d(r,"EcAlgorithmError",function(){return U}),t.d(r,"EcDSA",function(){return L}),t.d(r,"EcDH",function(){return R}),t.d(r,"ShaAlgorithms",function(){return k}),t.d(r,"Sha",function(){return b});var 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 t.i(i.a)(r,e),r}(Error);s.NOT_SUPPORTED="Method is not supported";var c=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=1,r}return t.i(i.a)(r,e),r}(s);c.PARAM_REQUIRED="Algorithm hasn't got required paramter '%1'",c.PARAM_WRONG_TYPE="Algorithm has got wrong type for paramter '%1'. Must be %2",c.PARAM_WRONG_VALUE="Algorithm has got wrong value for paramter '%1'. Must be %2",c.WRONG_ALG_NAME="Algorithm has got wrong name '%1'. Must be '%2'",c.UNSUPPORTED_ALGORITHM="Algorithm '%1' is not supported",c.WRONG_USAGE="Algorithm doesn't support key usage '%1'";var u=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=3,r}return t.i(i.a)(r,e),r}(s);u.EMPTY_KEY="CryptoKey is empty",u.WRONG_KEY_ALG="CryptoKey has wrong algorithm '%1'. Must be '%2'",u.WRONG_KEY_TYPE="CryptoKey has wrong type '%1'. Must be '%2'",u.WRONG_KEY_USAGE="CryptoKey has wrong key usage. Must be '%1'",u.NOT_EXTRACTABLE="CryptoKey is not extractable",u.WRONG_FORMAT="CryptoKey has '%1' type. It can be used with '%2' format",u.UNKNOWN_FORMAT="Unknown format in use '%1'. Must be one of 'raw', 'pkcs8', 'spki' or 'jwk'",u.ALLOWED_FORMAT="Wrong format value '%1'. Must be %2";var h=function(){function e(){}return e.checkAlgorithm=function(e){if("object"!=typeof e)throw new TypeError("Wrong algorithm data type. Must be Object");if(!("name"in e))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}(),p={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"};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 l=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}(),y=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=7,r}return t.i(i.a)(r,e),r}(c),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 y(y.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}(h);m.ALG_NAME="",m.KEY_USAGES=[];var A=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=8,r}return t.i(i.a)(r,e),r}(c),w=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(m),v=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(w);v.KEY_USAGES=["encrypt","decrypt","wrapKey","unwrapKey"];var g=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r}(v);g.ALG_NAME=p.AesECB;var C=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),!e.iv)throw new A(A.PARAM_REQUIRED,"iv");if(!(ArrayBuffer.isView(e.iv)||e.iv instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"iv","ArrayBufferView or ArrayBuffer");if(16!==e.iv.byteLength)throw new A(A.PARAM_WRONG_VALUE,"iv","ArrayBufferView or ArrayBuffer with size 16")},r}(v);C.ALG_NAME=p.AesCBC;var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),!e.counter||!(ArrayBuffer.isView(e.counter)||e.counter instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"counter","ArrayBufferView or ArrayBuffer");if(16!==e.counter.byteLength)throw new A(A.PARAM_WRONG_VALUE,"counter","ArrayBufferView or ArrayBuffer with size 16");if(!(e.length>0&&e.length<=128))throw new A(A.PARAM_WRONG_VALUE,"length","number [1-128]")},r}(v);d.ALG_NAME=p.AesCTR;var E=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),e.additionalData&&!(ArrayBuffer.isView(e.additionalData)||e.additionalData instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"additionalData","ArrayBufferView or ArrayBuffer");if(!e.iv)throw new A(A.PARAM_REQUIRED,"iv");if(!(ArrayBuffer.isView(e.iv)||e.iv instanceof ArrayBuffer))throw new A(A.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 A(A.PARAM_WRONG_VALUE,"tagLength","32, 64, 96, 104, 112, 120 or 128")}},r}(v);E.ALG_NAME=p.AesGCM;var P=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){this.checkAlgorithm(e)},r}(w);P.ALG_NAME=p.AesKW,P.KEY_USAGES=["wrapKey","unwrapKey"];var k=[p.Sha1,p.Sha256,p.Sha384,p.Sha512].join(" | "),b=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 p.Sha1:case p.Sha256:case p.Sha384:case p.Sha512:break;default:throw new c(c.WRONG_ALG_NAME,t.name,k)}},r.digest=function(e,r){var t=this;return new Promise(function(r,n){t.checkAlgorithm(e),r(void 0)})},r}(h),S=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=9,r}return t.i(i.a)(r,e),r}(c),_=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 S(S.PARAM_REQUIRED,"namedCurve");if("string"!=typeof e.namedCurve)throw new S(S.PARAM_WRONG_TYPE,"namedCurve","string");switch(e.namedCurve.toUpperCase()){case"P-256":case"P-384":case"P-521":break;default:throw new S(S.PARAM_WRONG_VALUE,"namedCurve","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}(h);_.ALG_NAME="",_.KEY_USAGES=[];var U=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=10,r}return t.i(i.a)(r,e),r}(c),L=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){this.checkAlgorithm(e),b.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}(_);L.ALG_NAME=p.EcDSA,L.KEY_USAGES=["sign","verify","deriveKey","deriveBits"];var R=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkDeriveParams=function(e){if(this.checkAlgorithm(e),!e.public)throw new U(U.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"),h.checkAlgorithm(t),t.name.toUpperCase()){case p.AesCBC:C.checkKeyGenParams(t);break;case p.AesCTR:d.checkKeyGenParams(t);break;case p.AesGCM:E.checkKeyGenParams(t);break;case p.AesKW:P.checkKeyGenParams(t);break;default:throw new U("Unsupported name '"+t.name+"' for algorithm in param 'derivedKeyType'")}n(void 0)})},r}(_);R.ALG_NAME=p.EcDH,R.KEY_USAGES=["deriveKey","deriveBits"];var K=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(h);K.ALG_NAME=p.Hmac,K.KEY_USAGES=["sign","verify"];var N=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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);b.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"),h.checkAlgorithm(t),t.name.toUpperCase()){case p.AesCBC:C.checkKeyGenParams(t),C.checkKeyUsages(a);break;case p.AesCTR:d.checkKeyGenParams(t),d.checkKeyUsages(a);break;case p.AesGCM:E.checkKeyGenParams(t),E.checkKeyUsages(a);break;case p.AesKW:P.checkKeyGenParams(t),P.checkKeyUsages(a);break;case p.Hmac:K.checkKeyGenParams(t),K.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}(h);N.ALG_NAME=p.Pbkdf2,N.KEY_USAGES=["deriveKey","deriveBits"];var O=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=2,r}return t.i(i.a)(r,e),r}(c),G=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=6,r}return t.i(i.a)(r,e),r}(c),M=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 G(G.PARAM_REQUIRED,"hash");b.checkAlgorithm(e.hash)},r.checkKeyGenParams=function(e){var r=e.modulusLength;if(!(r>=256&&r<=16384)||r%8)throw new O(O.PARAM_WRONG_VALUE,"modulusLength"," a multiple of 8 bits and >= 256 and <= 16384");var t=e.publicExponent;if(!t)throw new O(O.PARAM_REQUIRED,"publicExponent");if(!ArrayBuffer.isView(t))throw new O(O.PARAM_WRONG_TYPE,"publicExponent","ArrayBufferView");if(3!==t[0]&&(1!==t[0]||0!==t[1]||1!==t[2]))throw new O(O.PARAM_WRONG_VALUE,"publicExponent","Uint8Array([3]) | Uint8Array([1, 0, 1])");if(!e.hash)throw new O(O.PARAM_REQUIRED,"hash",k);b.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}(h);M.ALG_NAME="",M.KEY_USAGES=[];var B=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(M);B.ALG_NAME=p.RsaSSA,B.KEY_USAGES=["sign","verify"];var T=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=4,r}return t.i(i.a)(r,e),r}(c),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(r){var t=r;if(e.checkAlgorithmParams.call(this,t),!t.saltLength)throw new T(T.PARAM_REQUIRED,"saltLength");if(t.saltLength<0)throw new T("Parameter 'saltLength' is outside of numeric range")},r}(B);D.ALG_NAME=p.RsaPSS;var x=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=5,r}return t.i(i.a)(r,e),r}(c),H=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(e.label&&!(ArrayBuffer.isView(e.label)||e.label instanceof ArrayBuffer))throw new x(x.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}(M);H.ALG_NAME=p.RsaOAEP,H.KEY_USAGES=["encrypt","decrypt","wrapKey","unwrapKey"];var W=function(){function e(){}return e.prototype.generateKey=function(e,r,t){return new Promise(function(n,o){var i=a(e),s=h;switch(i.name.toUpperCase()){case p.RsaSSA.toUpperCase():s=B;break;case p.RsaOAEP.toUpperCase():s=H;break;case p.RsaPSS.toUpperCase():s=D;break;case p.AesECB.toUpperCase():s=g;break;case p.AesCBC.toUpperCase():s=C;break;case p.AesCTR.toUpperCase():s=d;break;case p.AesGCM.toUpperCase():s=E;break;case p.AesKW.toUpperCase():s=P;break;case p.EcDSA.toUpperCase():s=L;break;case p.EcDH.toUpperCase():s=R;break;case p.Hmac.toUpperCase():s=K;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=h;switch(i.name.toUpperCase()){case p.Sha1.toUpperCase():case p.Sha256.toUpperCase():case p.Sha384.toUpperCase():case p.Sha512.toUpperCase():u=b;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=h;switch(s.name.toUpperCase()){case p.RsaSSA.toUpperCase():f=B;break;case p.RsaPSS.toUpperCase():f=D;break;case p.EcDSA.toUpperCase():f=L;break;case p.Hmac.toUpperCase():f=K;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"),l=h;switch(s.name.toUpperCase()){case p.RsaSSA.toUpperCase():l=B;break;case p.RsaPSS.toUpperCase():l=D;break;case p.EcDSA.toUpperCase():l=L;break;case p.Hmac.toUpperCase():l=K;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,s.name)}l.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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;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=h;switch(i.name.toUpperCase()){case p.EcDH.toUpperCase():s=R;break;case p.Pbkdf2.toUpperCase():s=N;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),l=h;switch(u.name.toUpperCase()){case p.EcDH.toUpperCase():l=R;break;case p.Pbkdf2.toUpperCase():l=N;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,u.name)}l.deriveKey(u,r,f,n,o).then(i,s)})},e.prototype.exportKey=function(e,r){return new Promise(function(t,n){if(h.checkKey(r),!r.extractable)throw new u(u.NOT_EXTRACTABLE);var a=h;switch(r.algorithm.name.toUpperCase()){case p.RsaSSA.toUpperCase():a=B;break;case p.RsaPSS.toUpperCase():a=D;break;case p.AesECB.toUpperCase():a=g;break;case p.RsaOAEP.toUpperCase():a=H;break;case p.AesCBC.toUpperCase():a=C;break;case p.AesCTR.toUpperCase():a=d;break;case p.AesGCM.toUpperCase():a=E;break;case p.AesKW.toUpperCase():a=P;break;case p.EcDSA.toUpperCase():a=L;break;case p.EcDH.toUpperCase():a=R;break;case p.Hmac.toUpperCase():a=K;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=h;switch(u.name.toUpperCase()){case p.RsaSSA.toUpperCase():f=B;break;case p.RsaPSS.toUpperCase():f=D;break;case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;break;case p.AesKW.toUpperCase():f=P;break;case p.EcDSA.toUpperCase():f=L;break;case p.EcDH.toUpperCase():f=R;break;case p.Hmac.toUpperCase():f=K;break;case p.Pbkdf2.toUpperCase():f=N;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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():u=H;break;case p.AesECB.toUpperCase():u=g;break;case p.AesCBC.toUpperCase():u=C;break;case p.AesCTR.toUpperCase():u=d;break;case p.AesGCM.toUpperCase():u=E;break;case p.AesKW.toUpperCase():u=P;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,l){var y=a(n),m=a(i),A=o(r,"wrappedKey"),w=h;switch(y.name.toUpperCase()){case p.RsaOAEP.toUpperCase():w=H;break;case p.AesECB.toUpperCase():w=g;break;case p.AesCBC.toUpperCase():w=C;break;case p.AesCTR.toUpperCase():w=d;break;case p.AesGCM.toUpperCase():w=E;break;case p.AesKW.toUpperCase():w=P;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,y.name)}w.unwrapKey(e,A,t,y,m,s,u).then(f,l)})},e}()}).call(r,t(8))},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}(a.WebCryptoError);o.MODULE_NOT_FOUND="Module '%1' is not found. Download it from %2",o.UNSUPPORTED_ALGORITHM="Unsupported algorithm '%1'",r.LinerError=o},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(13),a=t(4),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(){var e,t={name:"",version:""},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}Object.defineProperty(r,"__esModule",{value:!0}),r.Browser={IE:"Internet Explorer",Safari:"Safari",Edge:"Edge",Chrome:"Chrome",Firefox:"Firefox Mozilla"},r.BrowserInfo=n,r.string2buffer=a,r.buffer2string=o,r.concat=i,r.assign=s},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(14);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(){}return e}();r.CryptoKey=n},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;/*! *****************************************************************************
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.i=function(e){return e},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=15)}([function(e,r,t){"use strict";(function(e){function n(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];for(var n,a=e,o=/[^%](%\d+)/g,i=[];n=o.exec(a);)i.push({arg:n[1],index:n.index});for(var s=i.length-1;s>=0;s--){var c=i[s],u=c.arg.substring(1),h=c.index+1;a=a.substring(0,h)+arguments[+u]+a.substring(h+1+u.length)}return a=a.replace("%%","%")}function a(e){var r;r="string"==typeof e?{name:e}:e,h.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(ArrayBuffer.isView(e))return new Uint8Array(e.buffer);if(e instanceof ArrayBuffer)return new Uint8Array(e);throw new s("Incoming parameter '"+r+"' has wrong data type. Must be ArrayBufferView or ArrayBuffer")}Object.defineProperty(r,"__esModule",{value:!0});var i=t(6);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 h}),t.d(r,"AlgorithmNames",function(){return p}),t.d(r,"Base64Url",function(){return l}),t.d(r,"SubtleCrypto",function(){return W}),t.d(r,"Aes",function(){return m}),t.d(r,"AesAlgorithmError",function(){return A}),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 d}),t.d(r,"AesGCM",function(){return E}),t.d(r,"AesKW",function(){return P}),t.d(r,"RsaKeyGenParamsError",function(){return O}),t.d(r,"RsaHashedImportParamsError",function(){return G}),t.d(r,"Rsa",function(){return M}),t.d(r,"RsaSSA",function(){return B}),t.d(r,"RsaPSSParamsError",function(){return T}),t.d(r,"RsaPSS",function(){return D}),t.d(r,"RsaOAEPParamsError",function(){return x}),t.d(r,"RsaOAEP",function(){return H}),t.d(r,"EcKeyGenParamsError",function(){return S}),t.d(r,"Ec",function(){return _}),t.d(r,"EcAlgorithmError",function(){return U}),t.d(r,"EcDSA",function(){return L}),t.d(r,"EcDH",function(){return R}),t.d(r,"ShaAlgorithms",function(){return k}),t.d(r,"Sha",function(){return b});var 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 t.i(i.a)(r,e),r}(Error);s.NOT_SUPPORTED="Method is not supported";var c=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=1,r}return t.i(i.a)(r,e),r}(s);c.PARAM_REQUIRED="Algorithm hasn't got required paramter '%1'",c.PARAM_WRONG_TYPE="Algorithm has got wrong type for paramter '%1'. Must be %2",c.PARAM_WRONG_VALUE="Algorithm has got wrong value for paramter '%1'. Must be %2",c.WRONG_ALG_NAME="Algorithm has got wrong name '%1'. Must be '%2'",c.UNSUPPORTED_ALGORITHM="Algorithm '%1' is not supported",c.WRONG_USAGE="Algorithm doesn't support key usage '%1'";var u=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=3,r}return t.i(i.a)(r,e),r}(s);u.EMPTY_KEY="CryptoKey is empty",u.WRONG_KEY_ALG="CryptoKey has wrong algorithm '%1'. Must be '%2'",u.WRONG_KEY_TYPE="CryptoKey has wrong type '%1'. Must be '%2'",u.WRONG_KEY_USAGE="CryptoKey has wrong key usage. Must be '%1'",u.NOT_EXTRACTABLE="CryptoKey is not extractable",u.WRONG_FORMAT="CryptoKey has '%1' type. It can be used with '%2' format",u.UNKNOWN_FORMAT="Unknown format in use '%1'. Must be one of 'raw', 'pkcs8', 'spki' or 'jwk'",u.ALLOWED_FORMAT="Wrong format value '%1'. Must be %2";var h=function(){function e(){}return e.checkAlgorithm=function(e){if("object"!=typeof e)throw new TypeError("Wrong algorithm data type. Must be Object");if(!("name"in e))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}(),p={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"};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 l=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}(),y=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=7,r}return t.i(i.a)(r,e),r}(c),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 y(y.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}(h);m.ALG_NAME="",m.KEY_USAGES=[];var A=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=8,r}return t.i(i.a)(r,e),r}(c),w=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(m),v=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(w);v.KEY_USAGES=["encrypt","decrypt","wrapKey","unwrapKey"];var g=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r}(v);g.ALG_NAME=p.AesECB;var C=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),!e.iv)throw new A(A.PARAM_REQUIRED,"iv");if(!(ArrayBuffer.isView(e.iv)||e.iv instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"iv","ArrayBufferView or ArrayBuffer");if(16!==e.iv.byteLength)throw new A(A.PARAM_WRONG_VALUE,"iv","ArrayBufferView or ArrayBuffer with size 16")},r}(v);C.ALG_NAME=p.AesCBC;var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),!e.counter||!(ArrayBuffer.isView(e.counter)||e.counter instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"counter","ArrayBufferView or ArrayBuffer");if(16!==e.counter.byteLength)throw new A(A.PARAM_WRONG_VALUE,"counter","ArrayBufferView or ArrayBuffer with size 16");if(!(e.length>0&&e.length<=128))throw new A(A.PARAM_WRONG_VALUE,"length","number [1-128]")},r}(v);d.ALG_NAME=p.AesCTR;var E=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),e.additionalData&&!(ArrayBuffer.isView(e.additionalData)||e.additionalData instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"additionalData","ArrayBufferView or ArrayBuffer");if(!e.iv)throw new A(A.PARAM_REQUIRED,"iv");if(!(ArrayBuffer.isView(e.iv)||e.iv instanceof ArrayBuffer))throw new A(A.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 A(A.PARAM_WRONG_VALUE,"tagLength","32, 64, 96, 104, 112, 120 or 128")}},r}(v);E.ALG_NAME=p.AesGCM;var P=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){this.checkAlgorithm(e)},r}(w);P.ALG_NAME=p.AesKW,P.KEY_USAGES=["wrapKey","unwrapKey"];var k=[p.Sha1,p.Sha256,p.Sha384,p.Sha512].join(" | "),b=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 p.Sha1:case p.Sha256:case p.Sha384:case p.Sha512:break;default:throw new c(c.WRONG_ALG_NAME,t.name,k)}},r.digest=function(e,r){var t=this;return new Promise(function(r,n){t.checkAlgorithm(e),r(void 0)})},r}(h),S=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=9,r}return t.i(i.a)(r,e),r}(c),_=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 S(S.PARAM_REQUIRED,"namedCurve");if("string"!=typeof e.namedCurve)throw new S(S.PARAM_WRONG_TYPE,"namedCurve","string");switch(e.namedCurve.toUpperCase()){case"P-256":case"P-384":case"P-521":break;default:throw new S(S.PARAM_WRONG_VALUE,"namedCurve","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}(h);_.ALG_NAME="",_.KEY_USAGES=[];var U=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=10,r}return t.i(i.a)(r,e),r}(c),L=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){this.checkAlgorithm(e),b.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}(_);L.ALG_NAME=p.EcDSA,L.KEY_USAGES=["sign","verify","deriveKey","deriveBits"];var R=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkDeriveParams=function(e){if(this.checkAlgorithm(e),!e.public)throw new U(U.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"),h.checkAlgorithm(t),t.name.toUpperCase()){case p.AesCBC:C.checkKeyGenParams(t);break;case p.AesCTR:d.checkKeyGenParams(t);break;case p.AesGCM:E.checkKeyGenParams(t);break;case p.AesKW:P.checkKeyGenParams(t);break;default:throw new U("Unsupported name '"+t.name+"' for algorithm in param 'derivedKeyType'")}n(void 0)})},r}(_);R.ALG_NAME=p.EcDH,R.KEY_USAGES=["deriveKey","deriveBits"];var K=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(h);K.ALG_NAME=p.Hmac,K.KEY_USAGES=["sign","verify"];var N=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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);b.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"),h.checkAlgorithm(t),t.name.toUpperCase()){case p.AesCBC:C.checkKeyGenParams(t),C.checkKeyUsages(a);break;case p.AesCTR:d.checkKeyGenParams(t),d.checkKeyUsages(a);break;case p.AesGCM:E.checkKeyGenParams(t),E.checkKeyUsages(a);break;case p.AesKW:P.checkKeyGenParams(t),P.checkKeyUsages(a);break;case p.Hmac:K.checkKeyGenParams(t),K.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}(h);N.ALG_NAME=p.Pbkdf2,N.KEY_USAGES=["deriveKey","deriveBits"];var O=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=2,r}return t.i(i.a)(r,e),r}(c),G=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=6,r}return t.i(i.a)(r,e),r}(c),M=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 G(G.PARAM_REQUIRED,"hash");b.checkAlgorithm(e.hash)},r.checkKeyGenParams=function(e){var r=e.modulusLength;if(!(r>=256&&r<=16384)||r%8)throw new O(O.PARAM_WRONG_VALUE,"modulusLength"," a multiple of 8 bits and >= 256 and <= 16384");var t=e.publicExponent;if(!t)throw new O(O.PARAM_REQUIRED,"publicExponent");if(!ArrayBuffer.isView(t))throw new O(O.PARAM_WRONG_TYPE,"publicExponent","ArrayBufferView");if(3!==t[0]&&(1!==t[0]||0!==t[1]||1!==t[2]))throw new O(O.PARAM_WRONG_VALUE,"publicExponent","Uint8Array([3]) | Uint8Array([1, 0, 1])");if(!e.hash)throw new O(O.PARAM_REQUIRED,"hash",k);b.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}(h);M.ALG_NAME="",M.KEY_USAGES=[];var B=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(M);B.ALG_NAME=p.RsaSSA,B.KEY_USAGES=["sign","verify"];var T=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=4,r}return t.i(i.a)(r,e),r}(c),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(r){var t=r;if(e.checkAlgorithmParams.call(this,t),!t.saltLength)throw new T(T.PARAM_REQUIRED,"saltLength");if(t.saltLength<0)throw new T("Parameter 'saltLength' is outside of numeric range")},r}(B);D.ALG_NAME=p.RsaPSS;var x=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=5,r}return t.i(i.a)(r,e),r}(c),H=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(e.label&&!(ArrayBuffer.isView(e.label)||e.label instanceof ArrayBuffer))throw new x(x.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}(M);H.ALG_NAME=p.RsaOAEP,H.KEY_USAGES=["encrypt","decrypt","wrapKey","unwrapKey"];var W=function(){function e(){}return e.prototype.generateKey=function(e,r,t){return new Promise(function(n,o){var i=a(e),s=h;switch(i.name.toUpperCase()){case p.RsaSSA.toUpperCase():s=B;break;case p.RsaOAEP.toUpperCase():s=H;break;case p.RsaPSS.toUpperCase():s=D;break;case p.AesECB.toUpperCase():s=g;break;case p.AesCBC.toUpperCase():s=C;break;case p.AesCTR.toUpperCase():s=d;break;case p.AesGCM.toUpperCase():s=E;break;case p.AesKW.toUpperCase():s=P;break;case p.EcDSA.toUpperCase():s=L;break;case p.EcDH.toUpperCase():s=R;break;case p.Hmac.toUpperCase():s=K;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=h;switch(i.name.toUpperCase()){case p.Sha1.toUpperCase():case p.Sha256.toUpperCase():case p.Sha384.toUpperCase():case p.Sha512.toUpperCase():u=b;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=h;switch(s.name.toUpperCase()){case p.RsaSSA.toUpperCase():f=B;break;case p.RsaPSS.toUpperCase():f=D;break;case p.EcDSA.toUpperCase():f=L;break;case p.Hmac.toUpperCase():f=K;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"),l=h;switch(s.name.toUpperCase()){case p.RsaSSA.toUpperCase():l=B;break;case p.RsaPSS.toUpperCase():l=D;break;case p.EcDSA.toUpperCase():l=L;break;case p.Hmac.toUpperCase():l=K;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,s.name)}l.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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;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=h;switch(i.name.toUpperCase()){case p.EcDH.toUpperCase():s=R;break;case p.Pbkdf2.toUpperCase():s=N;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),l=h;switch(u.name.toUpperCase()){case p.EcDH.toUpperCase():l=R;break;case p.Pbkdf2.toUpperCase():l=N;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,u.name)}l.deriveKey(u,r,f,n,o).then(i,s)})},e.prototype.exportKey=function(e,r){return new Promise(function(t,n){if(h.checkKey(r),!r.extractable)throw new u(u.NOT_EXTRACTABLE);var a=h;switch(r.algorithm.name.toUpperCase()){case p.RsaSSA.toUpperCase():a=B;break;case p.RsaPSS.toUpperCase():a=D;break;case p.AesECB.toUpperCase():a=g;break;case p.RsaOAEP.toUpperCase():a=H;break;case p.AesCBC.toUpperCase():a=C;break;case p.AesCTR.toUpperCase():a=d;break;case p.AesGCM.toUpperCase():a=E;break;case p.AesKW.toUpperCase():a=P;break;case p.EcDSA.toUpperCase():a=L;break;case p.EcDH.toUpperCase():a=R;break;case p.Hmac.toUpperCase():a=K;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=h;switch(u.name.toUpperCase()){case p.RsaSSA.toUpperCase():f=B;break;case p.RsaPSS.toUpperCase():f=D;break;case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;break;case p.AesKW.toUpperCase():f=P;break;case p.EcDSA.toUpperCase():f=L;break;case p.EcDH.toUpperCase():f=R;break;case p.Hmac.toUpperCase():f=K;break;case p.Pbkdf2.toUpperCase():f=N;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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():u=H;break;case p.AesECB.toUpperCase():u=g;break;case p.AesCBC.toUpperCase():u=C;break;case p.AesCTR.toUpperCase():u=d;break;case p.AesGCM.toUpperCase():u=E;break;case p.AesKW.toUpperCase():u=P;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,l){var y=a(n),m=a(i),A=o(r,"wrappedKey"),w=h;switch(y.name.toUpperCase()){case p.RsaOAEP.toUpperCase():w=H;break;case p.AesECB.toUpperCase():w=g;break;case p.AesCBC.toUpperCase():w=C;break;case p.AesCTR.toUpperCase():w=d;break;case p.AesGCM.toUpperCase():w=E;break;case p.AesKW.toUpperCase():w=P;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,y.name)}w.unwrapKey(e,A,t,y,m,s,u).then(f,l)})},e}()}).call(r,t(13))},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}(a.WebCryptoError);o.MODULE_NOT_FOUND="Module '%1' is not found. Download it from %2",o.UNSUPPORTED_ALGORITHM="Unsupported algorithm '%1'",r.LinerError=o},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(12),a=t(4),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(){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]):/mobile/i.test(n)?(t.name=r.Browser.Mobile,t.version=/mobile\/([\w]+)/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}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},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(14);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(){}return e}();r.CryptoKey=n},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.

@@ -15,2 +15,2 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use

***************************************************************************** */
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,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(4)),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";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(5),s=t(3),c=t(4),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;return o.key=a,o.algorithm=e,o.extractable=r,o.type="secret",o.usages=t,o})},r.encrypt=function(e,r,t){return Promise.resolve().then(function(){var n;switch(e.name.toUpperCase()){case a.AlgorithmNames.AesECB:;n=asmCrypto.AES_ECB.encrypt(t,r.key,!0);break;case a.AlgorithmNames.AesCBC:var i=e;n=asmCrypto.AES_CBC.encrypt(t,r.key,void 0,a.PrepareData(i.iv,"iv"));break;case a.AlgorithmNames.AesGCM:var s=e;s.tagLength=s.tagLength||128;var c=void 0;s.additionalData&&(c=a.PrepareData(s.additionalData,"additionalData")),n=asmCrypto.AES_GCM.encrypt(t,r.key,s.iv,c,s.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:;n=asmCrypto.AES_ECB.decrypt(t,r.key,!0);break;case a.AlgorithmNames.AesCBC:var i=e;n=asmCrypto.AES_CBC.decrypt(t,r.key,void 0,a.PrepareData(i.iv,"iv"));break;case a.AlgorithmNames.AesGCM:var s=e;s.tagLength=s.tagLength||128;var c=void 0;s.additionalData&&(c=a.PrepareData(s.additionalData,"additionalData")),n=asmCrypto.AES_GCM.decrypt(t,r.key,s.iv,c,s.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 h.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 h.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 n;if("jwk"===e.toLowerCase()){var s=r;n=a.Base64Url.decode(s.k)}else n=new Uint8Array(r);var c=new i.CryptoKey;return c.algorithm=t,c.type="secret",c.usages=o,c.key=n,c})},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 h=t(2)},function(e,r,t){"use strict";function n(e){for(var r=new Uint8Array(e),t=[],n=0;n<r.length;n++)t.push(r[n]);return t}function a(e,r){e.length%2&&(e="0"+e);for(var t=new Uint8Array(e.length/2),n=0;n<e.length;n++){var a=e.slice(n,++n+1);t[(n-1)/2]=parseInt(a,16)}if(r){var o=t.length;o=o>32?o>48?66:48:32,t.length<o&&(t=h.concat(new Uint8Array(o-t.length),t))}return t}function o(e,r){for(var t="",n=0;n<e.length;n++){var a=e[n].toString(16);t+=a.length%2?"0"+a:a}if(r){var o=e.length;o=o>32?o>48?66:48:32,t.length/2<o&&(t=new Array(2*o-t.length+1).join("0")+t)}return t}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(5),h=t(3),p=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return i(r,e),r.generateKey=function(e,r,t){var n=this;return Promise.resolve().then(function(){n.checkModule();var t=e,a=new elliptic.ec(t.namedCurve.replace("-","").toLowerCase()),o=new u.CryptoKey,i=new u.CryptoKey;return o.key=i.key=a.genKeyPair(),o.algorithm=i.algorithm=t,o.extractable=r,i.extractable=!0,o.type="private",i.type="public",e.name===s.AlgorithmNames.EcDSA?(o.usages=["sign"],i.usages=["verify"]):e.name===s.AlgorithmNames.EcDH&&(o.usages=["deriveKey","deriveBits"],i.usages=[]),{privateKey:o,publicKey:i}})},r.sign=function(e,r,t){return Promise.resolve().then(function(){var r=e;return(new f.Crypto).subtle.digest(r.hash,t)}).then(function(e){var t=n(e),i=r.key.sign(t);return a(o(i.r.toArray(),!0)+o(i.s.toArray(),!0)).buffer})},r.verify=function(e,r,t,a){var o;return Promise.resolve().then(function(){var r=e;return o={r:t.slice(0,t.byteLength/2),s:t.slice(t.byteLength/2)},(new f.Crypto).subtle.digest(r.hash,a)}).then(function(e){var t=n(e);return r.key.verify(t,o)})},r.deriveKey=function(e,r,t,n,a){var o=this;return Promise.resolve().then(function(){return o.deriveBits(e,r,t.length)}).then(function(e){return(new f.Crypto).subtle.importKey("raw",new Uint8Array(e),t,n,a)})},r.deriveBits=function(e,r,t){return Promise.resolve().then(function(){var n=(Promise.resolve(null),r.key.derive(e.public.key.getPublic())),a=new Uint8Array(n.toArray()),o=a.length;return o=o>32?o>48?66:48:32,a.length<o&&(a=h.concat(new Uint8Array(o-a.length),a)),a.slice(0,t/8).buffer})},r.exportKey=function(e,r){return Promise.resolve().then(function(){var t=r.key;if("jwk"===e.toLowerCase()){var n=t.getPublic("hex").slice(2),o=n.slice(0,n.length/2),i=n.slice(n.length/2,n.length);if("public"===r.type){var u={crv:r.algorithm.namedCurve,ext:r.extractable,x:s.Base64Url.encode(a(o,!0)),y:s.Base64Url.encode(a(i,!0)),key_ops:r.usages,kty:"EC"};return u}var u={crv:r.algorithm.namedCurve,ext:r.extractable,d:s.Base64Url.encode(a(t.getPrivate("hex"),!0)),x:s.Base64Url.encode(a(o,!0)),y:s.Base64Url.encode(a(i,!0)),key_ops:r.usages,kty:"EC"};return u}throw new c.LinerError("Format '"+e+"' is not implemented")})},r.importKey=function(e,r,t,n,a){return Promise.resolve().then(function(){var i=new u.CryptoKey;if(i.algorithm=t,"jwk"!==e.toLowerCase())throw new c.LinerError("Format '"+e+"' is not implemented");var p=new elliptic.ec(r.crv.replace("-","").toLowerCase());if(r.d)i.key=p.keyFromPrivate(s.Base64Url.decode(r.d)),i.type="private";else{var f=h.concat(new Uint8Array([4]),s.Base64Url.decode(r.x),s.Base64Url.decode(r.y)),l=o(f);i.key=p.keyFromPublic(l,"hex"),i.type="public"}return i.extractable=n,i.usages=a,i})},r.checkModule=function(){if("undefined"==typeof elliptic)throw new c.LinerError(c.LinerError.MODULE_NOT_FOUND,"elliptic","https://github.com/indutny/elliptic")},r}(s.BaseCrypto);r.EcCrypto=p;var f=t(2)},function(e,r,t){"use strict";function n(e){var r=!0;return e.filter(function(e){return(!r||0!==e)&&(r=!1,!0)})}var a=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 o=t(0),i=t(1),s=t(3),c=t(5),u=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return a(r,e),r.generateKey=function(e,r,t){var n=this;return Promise.resolve().then(function(){n.checkModule();var a=3===e.publicExponent[0]?3:65537,s=asmCrypto.RSA.generateKey(e.modulusLength,a),u=new c.CryptoKey,h=new c.CryptoKey;switch(u.key=h.key=s,u.algorithm=h.algorithm=e,u.extractable=r,h.extractable=!0,u.type="private",h.type="public",e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():u.usages=n.filterUsages(["decrypt","unwrapKey"],t),h.usages=n.filterUsages(["encrypt","wrapKey"],t);break;case o.AlgorithmNames.RsaSSA.toLowerCase():case o.AlgorithmNames.RsaPSS.toLowerCase():u.usages=n.filterUsages(["sign"],t),h.usages=n.filterUsages(["verify"],t);break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}return{privateKey:u,publicKey:h}})},r.sign=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaSSA.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_PKCS1_v1_5_SHA1.sign;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_PKCS1_v1_5_SHA256.sign;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_PKCS1_v1_5_SHA512.sign;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}return s(t,r.key).buffer;case o.AlgorithmNames.RsaPSS.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_PSS_SHA1.sign;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_PSS_SHA256.sign;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_PSS_SHA512.sign;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}return s(t,r.key,a.saltLength).buffer;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.verify=function(e,r,t,n){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaSSA.toLowerCase():var a,s=r.algorithm;switch(s.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:a=asmCrypto.RSA_PKCS1_v1_5_SHA1.verify;break;case o.AlgorithmNames.Sha256:a=asmCrypto.RSA_PKCS1_v1_5_SHA256.verify;break;case o.AlgorithmNames.Sha512:a=asmCrypto.RSA_PKCS1_v1_5_SHA512.verify;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}try{return a(t,n,r.key)}catch(e){return console.warn("Verify error: "+e.message),!1}case o.AlgorithmNames.RsaPSS.toLowerCase():var c=r.algorithm,u=e,h=void 0;switch(c.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:h=asmCrypto.RSA_PSS_SHA1.verify;break;case o.AlgorithmNames.Sha256:h=asmCrypto.RSA_PSS_SHA256.verify;break;case o.AlgorithmNames.Sha512:h=asmCrypto.RSA_PSS_SHA512.verify;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}try{return h(t,n,r.key,u.saltLength)}catch(e){return console.warn("Verify error: "+e.message),!1}default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.encrypt=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_OAEP_SHA1.encrypt;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_OAEP_SHA256.encrypt;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_OAEP_SHA512.encrypt;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,n.name+" "+n.hash.name)}var c=void 0;return a.label&&(c=o.PrepareData(a.label,"label")),s(t,r.key,c);default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.decrypt=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_OAEP_SHA1.decrypt;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_OAEP_SHA256.decrypt;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_OAEP_SHA512.decrypt;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,n.name+" "+n.hash.name)}var c=void 0;return a.label&&(c=o.PrepareData(a.label,"label")),s(t,r.key,c);default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.wrapKey=function(e,r,t,n){var a;return Promise.resolve().then(function(){return a=new h.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 h.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){var r=e.hash,t=/(\d+)/.exec(r.name)[1];switch(e.name.toUpperCase()){case o.AlgorithmNames.RsaOAEP.toUpperCase():return"RSA-OAEP"+("1"===t?"":"-"+t);case o.AlgorithmNames.RsaPSS.toUpperCase():return"PS"+t;case o.AlgorithmNames.RsaSSA.toUpperCase():return"RS"+t;default:throw new o.AlgorithmError(o.AlgorithmError.UNSUPPORTED_ALGORITHM,e.name)}},r.jwk2alg=function(e){throw new Error("Not implemented")},r.exportKey=function(e,r){var t=this;return Promise.resolve().then(function(){if("jwk"===e.toLowerCase()){var a={kty:"RSA",ext:!0,key_ops:r.usages};return a.alg=t.alg2jwk(r.algorithm),a.n=o.Base64Url.encode(n(r.key[0])),a.e=o.Base64Url.encode(n(r.key[1])),"private"===r.type&&(a.d=o.Base64Url.encode(n(r.key[2])),a.p=o.Base64Url.encode(n(r.key[3])),a.q=o.Base64Url.encode(n(r.key[4])),a.dp=o.Base64Url.encode(n(r.key[5])),a.dq=o.Base64Url.encode(n(r.key[6])),a.qi=o.Base64Url.encode(n(r.key[7]))),a}throw new i.LinerError(i.LinerError.NOT_SUPPORTED)})},r.importKey=function(e,r,t,n,a){return Promise.resolve().then(function(){var n,s=new c.CryptoKey;if(s.algorithm=t,s.usages=a,s.key=[],"jwk"===e.toLowerCase())return n=r,s.key[0]=o.Base64Url.decode(n.n),s.key[1]=3===o.Base64Url.decode(n.e)[0]?new Uint8Array([0,0,0,3]):new Uint8Array([0,1,0,1]),n.d?(s.type="private",s.key[2]=o.Base64Url.decode(n.d),s.key[3]=o.Base64Url.decode(n.p),s.key[4]=o.Base64Url.decode(n.q),s.key[5]=o.Base64Url.decode(n.dp),s.key[6]=o.Base64Url.decode(n.dq),s.key[7]=o.Base64Url.decode(n.qi)):s.type="public",s;throw new i.LinerError(i.LinerError.NOT_SUPPORTED)})},r.checkModule=function(){if("undefined"==typeof asmCrypto)throw new i.LinerError(i.LinerError.MODULE_NOT_FOUND,"asmCrypto","https://github.com/vibornoff/asmcrypto.js")},r.filterUsages=function(e,r){return e.filter(function(e){return!!r.filter(function(r){return e===r}).length})},r}(o.BaseCrypto);r.RsaCrypto=u;var h=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";function n(e,r){return Promise.resolve().then(function(){if(e.key)return e;if(e.extractable){return(new y.Crypto).subtle.exportKey("jwk",e).then(function(t){var n=o(e);return n&&(n=A.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){A.BrowserInfo().name!==A.Browser.IE&&A.BrowserInfo().name!==A.Browser.Edge&&A.BrowserInfo().name!==A.Browser.Safari||!/^rsa/i.test(e.name)||(r.privateKey?(d.push({hash:e.hash,key:r.privateKey}),d.push({hash:e.hash,key:r.publicKey})):d.push({hash:e.hash,key:r}))}function o(e){var r=null;return d.some(function(t){return t.key===e&&(r=A.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&&A.BrowserInfo().name===A.Browser.IE){"extractable"in e&&(e.ext=e.extractable,delete e.extractable);var n=null;switch(r.name.toUpperCase()){case h.AlgorithmNames.RsaOAEP.toUpperCase():case h.AlgorithmNames.RsaPSS.toUpperCase():case h.AlgorithmNames.RsaSSA.toUpperCase():n=g.RsaCrypto;break;case h.AlgorithmNames.AesECB.toUpperCase():case h.AlgorithmNames.AesCBC.toUpperCase():case h.AlgorithmNames.AesGCM.toUpperCase():n=w.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){A.BrowserInfo().name===A.Browser.IE&&("ext"in e&&(e.extractable=e.ext,delete e.ext),delete e.key_ops,delete e.alg)}var u=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),p=t(0),f=t(0),l=t(4),y=t(2),m=t(1),A=t(3),w=t(9),v=t(12),g=t(11),C=t(10),d=[],E=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),r.prototype.generateKey=function(r,t,n){var o,s=arguments;return e.prototype.generateKey.apply(this,s).then(function(e){if(o=f.PrepareAlgorithm(r),(A.BrowserInfo().name!==A.Browser.Edge||o.name.toUpperCase()!==h.AlgorithmNames.AesGCM)&&l.nativeSubtle)try{return l.nativeSubtle.generateKey.apply(l.nativeSubtle,s).catch(function(e){console.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return i(e,n),a(o,e),e;var r;switch(o.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():r=w.AesCrypto;break;case h.AlgorithmNames.EcDSA.toLowerCase():case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaSSA.toLowerCase():r=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,o.name.toLowerCase())}return r.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=f.PrepareAlgorithm(r),a=f.PrepareData(t,"data"),l.nativeSubtle)try{return l.nativeSubtle.digest.apply(l.nativeSubtle,o).catch(function(e){console.warn("WebCrypto: native digest for "+n.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native digest for "+n.name+" doesn't work.",e.message||"")}}).then(function(e){return e||v.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=f.PrepareAlgorithm(r),s=f.PrepareData(a,"data");var n=o(t);if(n&&(c[0]=A.assign(i,n)),l.nativeSubtle)try{return l.nativeSubtle.sign.apply(l.nativeSubtle,c).catch(function(e){console.warn("WebCrypto: native sign for "+i.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native sign for "+i.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return e;var r;switch(i.name.toLowerCase()){case h.AlgorithmNames.EcDSA.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():r=g.RsaCrypto;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,a,i){var s,c,u,p=arguments;return e.prototype.verify.apply(this,p).then(function(e){s=f.PrepareAlgorithm(r),c=f.PrepareData(a,"data"),u=f.PrepareData(i,"data");var n=o(t);if(n&&(p[0]=A.assign(s,n)),l.nativeSubtle)try{return l.nativeSubtle.verify.apply(l.nativeSubtle,p).catch(function(e){console.warn("WebCrypto: native verify for "+s.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native verify for "+s.name+" doesn't work.",e.message||"")}}).then(function(e){if("boolean"==typeof e)return e;var r;switch(s.name.toLowerCase()){case h.AlgorithmNames.EcDSA.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():r=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,s.name.toLowerCase())}return n(t,r).then(function(e){return r.verify(s,e,c,u)})})},r.prototype.deriveBits=function(r,t,n){var a,o=arguments;return e.prototype.deriveBits.apply(this,o).then(function(e){if(a=f.PrepareAlgorithm(r),l.nativeSubtle)try{return l.nativeSubtle.deriveBits.apply(l.nativeSubtle,o).catch(function(e){console.warn("WebCrypto: native deriveBits for "+a.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native deriveBits for "+a.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return e;var r;switch(a.name.toLowerCase()){case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;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=f.PrepareAlgorithm(r),c=f.PrepareAlgorithm(n),l.nativeSubtle)try{return l.nativeSubtle.deriveKey.apply(l.nativeSubtle,u).catch(function(e){console.warn("WebCrypto: native deriveKey for "+s.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native deriveKey for "+s.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return i(e,o),e;var r;switch(s.name.toLowerCase()){case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"deriveBits")}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=f.PrepareAlgorithm(r),i=f.PrepareData(a,"data"),l.nativeSubtle)try{return l.nativeSubtle.encrypt.apply(l.nativeSubtle,s).catch(function(e){console.warn("WebCrypto: native 'encrypt' for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'encrypt' for "+o.name+" doesn't work.",e.message||"")}}).then(function(e){if(e){if(A.BrowserInfo().name===A.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():s=g.RsaCrypto;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=f.PrepareAlgorithm(r),o=f.PrepareData(n,"data");var i=o;if(A.BrowserInfo().name===A.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():c=g.RsaCrypto;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=f.PrepareAlgorithm(a),l.nativeSubtle)try{return l.nativeSubtle.wrapKey.apply(l.nativeSubtle,i).catch(function(e){console.warn("WebCrypto: native 'wrapKey' for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'wrapKey' for "+o.name+" doesn't work.",e.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():a=g.RsaCrypto;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,y,v=this,C=arguments;return e.prototype.unwrapKey.apply(this,C).then(function(e){if(u=f.PrepareAlgorithm(a),p=f.PrepareAlgorithm(o),y=f.PrepareData(t,"wrappedKey"),n.key){var d=void 0;switch(u.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():d=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():d=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"unwrapKey")}return d.unwrapKey(r,y,n,u,p,s,c)}return l.nativeSubtle.unwrapKey.apply(l.nativeSubtle,C).catch(function(e){return v.decrypt(u,n,t).then(function(e){var t;return t="jwk"===r?JSON.parse(A.buffer2string(new Uint8Array(e))):e,v.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){console.warn("WebCrypto: native 'exportKey' for "+t.algorithm.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'exportKey' for "+t.algorithm.name+" doesn't work.",e.message||"")}}).then(function(e){if(e){"jwk"===r&&e instanceof ArrayBuffer&&(e=A.buffer2string(new Uint8Array(e)),e=JSON.parse(e));var n=o(t);return n||(n=A.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=w.AesCrypto;break;case h.AlgorithmNames.EcDH.toLowerCase():case h.AlgorithmNames.EcDSA.toLowerCase():a=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaOAEP.toLowerCase():a=g.RsaCrypto;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 u,p,y=arguments;return e.prototype.importKey.apply(this,y).then(function(e){if(u=f.PrepareAlgorithm(n),p=t,A.BrowserInfo().name!==A.Browser.Safari&&A.BrowserInfo().name!==A.Browser.IE||(A.BrowserInfo().name===A.Browser.IE&&(t=A.assign({},t),c(t)),y[1]=A.string2buffer(JSON.stringify(t)).buffer),ArrayBuffer.isView(t)&&(p=f.PrepareData(t,"keyData")),l.nativeSubtle)try{return l.nativeSubtle.importKey.apply(l.nativeSubtle,y).catch(function(e){console.warn("WebCrypto: native 'importKey' for "+u.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'importKey' for "+u.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return a(u,e),i(e,s),Promise.resolve(e);var t;switch(u.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():t=w.AesCrypto;break;case h.AlgorithmNames.EcDH.toLowerCase():case h.AlgorithmNames.EcDSA.toLowerCase():t=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaOAEP.toLowerCase():t=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,u.name.toLowerCase())}return t.importKey(r,p,u,o,s)})},r}(p.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){e.exports=require("crypto")},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(7);Object.freeze(Math),Object.freeze(Math.random),Object.freeze(Math.imul),n.nativeCrypto&&Object.freeze(n.nativeCrypto.getRandomValues),r.crypto=new n.Crypto}]);
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,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(4)),n(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=t(5),s=t(3),c=t(4),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;return o.key=a,o.algorithm=e,o.extractable=r,o.type="secret",o.usages=t,o})},r.encrypt=function(e,r,t){return Promise.resolve().then(function(){var n;switch(e.name.toUpperCase()){case a.AlgorithmNames.AesECB:;n=asmCrypto.AES_ECB.encrypt(t,r.key,!0);break;case a.AlgorithmNames.AesCBC:var i=e;n=asmCrypto.AES_CBC.encrypt(t,r.key,void 0,a.PrepareData(i.iv,"iv"));break;case a.AlgorithmNames.AesGCM:var s=e;s.tagLength=s.tagLength||128;var c=void 0;s.additionalData&&(c=a.PrepareData(s.additionalData,"additionalData")),n=asmCrypto.AES_GCM.encrypt(t,r.key,s.iv,c,s.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:;n=asmCrypto.AES_ECB.decrypt(t,r.key,!0);break;case a.AlgorithmNames.AesCBC:var i=e;n=asmCrypto.AES_CBC.decrypt(t,r.key,void 0,a.PrepareData(i.iv,"iv"));break;case a.AlgorithmNames.AesGCM:var s=e;s.tagLength=s.tagLength||128;var c=void 0;s.additionalData&&(c=a.PrepareData(s.additionalData,"additionalData")),n=asmCrypto.AES_GCM.decrypt(t,r.key,s.iv,c,s.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 h.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 h.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 n;if("jwk"===e.toLowerCase()){var s=r;n=a.Base64Url.decode(s.k)}else n=new Uint8Array(r);var c=new i.CryptoKey;return c.algorithm=t,c.type="secret",c.usages=o,c.key=n,c})},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 h=t(2)},function(e,r,t){"use strict";function n(e){for(var r=new Uint8Array(e),t=[],n=0;n<r.length;n++)t.push(r[n]);return t}function a(e,r){e.length%2&&(e="0"+e);for(var t=new Uint8Array(e.length/2),n=0;n<e.length;n++){var a=e.slice(n,++n+1);t[(n-1)/2]=parseInt(a,16)}if(r){var o=t.length;o=o>32?o>48?66:48:32,t.length<o&&(t=h.concat(new Uint8Array(o-t.length),t))}return t}function o(e,r){for(var t="",n=0;n<e.length;n++){var a=e[n].toString(16);t+=a.length%2?"0"+a:a}if(r){var o=e.length;o=o>32?o>48?66:48:32,t.length/2<o&&(t=new Array(2*o-t.length+1).join("0")+t)}return t}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(5),h=t(3),p=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return i(r,e),r.generateKey=function(e,r,t){var n=this;return Promise.resolve().then(function(){n.checkModule();var t=e,a=new elliptic.ec(t.namedCurve.replace("-","").toLowerCase()),o=new u.CryptoKey,i=new u.CryptoKey;return o.key=i.key=a.genKeyPair(),o.algorithm=i.algorithm=t,o.extractable=r,i.extractable=!0,o.type="private",i.type="public",e.name===s.AlgorithmNames.EcDSA?(o.usages=["sign"],i.usages=["verify"]):e.name===s.AlgorithmNames.EcDH&&(o.usages=["deriveKey","deriveBits"],i.usages=[]),{privateKey:o,publicKey:i}})},r.sign=function(e,r,t){return Promise.resolve().then(function(){var r=e;return(new f.Crypto).subtle.digest(r.hash,t)}).then(function(e){var t=n(e),i=r.key.sign(t);return a(o(i.r.toArray(),!0)+o(i.s.toArray(),!0)).buffer})},r.verify=function(e,r,t,a){var o;return Promise.resolve().then(function(){var r=e;return o={r:t.slice(0,t.byteLength/2),s:t.slice(t.byteLength/2)},(new f.Crypto).subtle.digest(r.hash,a)}).then(function(e){var t=n(e);return r.key.verify(t,o)})},r.deriveKey=function(e,r,t,n,a){var o=this;return Promise.resolve().then(function(){return o.deriveBits(e,r,t.length)}).then(function(e){return(new f.Crypto).subtle.importKey("raw",new Uint8Array(e),t,n,a)})},r.deriveBits=function(e,r,t){return Promise.resolve().then(function(){var n=(Promise.resolve(null),r.key.derive(e.public.key.getPublic())),a=new Uint8Array(n.toArray()),o=a.length;return o=o>32?o>48?66:48:32,a.length<o&&(a=h.concat(new Uint8Array(o-a.length),a)),a.slice(0,t/8).buffer})},r.exportKey=function(e,r){return Promise.resolve().then(function(){var t=r.key;if("jwk"===e.toLowerCase()){var n=t.getPublic("hex").slice(2),o=n.slice(0,n.length/2),i=n.slice(n.length/2,n.length);if("public"===r.type){var u={crv:r.algorithm.namedCurve,ext:r.extractable,x:s.Base64Url.encode(a(o,!0)),y:s.Base64Url.encode(a(i,!0)),key_ops:r.usages,kty:"EC"};return u}var u={crv:r.algorithm.namedCurve,ext:r.extractable,d:s.Base64Url.encode(a(t.getPrivate("hex"),!0)),x:s.Base64Url.encode(a(o,!0)),y:s.Base64Url.encode(a(i,!0)),key_ops:r.usages,kty:"EC"};return u}throw new c.LinerError("Format '"+e+"' is not implemented")})},r.importKey=function(e,r,t,n,a){return Promise.resolve().then(function(){var i=new u.CryptoKey;if(i.algorithm=t,"jwk"!==e.toLowerCase())throw new c.LinerError("Format '"+e+"' is not implemented");var p=new elliptic.ec(r.crv.replace("-","").toLowerCase());if(r.d)i.key=p.keyFromPrivate(s.Base64Url.decode(r.d)),i.type="private";else{var f=h.concat(new Uint8Array([4]),s.Base64Url.decode(r.x),s.Base64Url.decode(r.y)),l=o(f);i.key=p.keyFromPublic(l,"hex"),i.type="public"}return i.extractable=n,i.usages=a,i})},r.checkModule=function(){if("undefined"==typeof elliptic)throw new c.LinerError(c.LinerError.MODULE_NOT_FOUND,"elliptic","https://github.com/indutny/elliptic")},r}(s.BaseCrypto);r.EcCrypto=p;var f=t(2)},function(e,r,t){"use strict";function n(e){var r=!0;return e.filter(function(e){return(!r||0!==e)&&(r=!1,!0)})}var a=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 o=t(0),i=t(1),s=t(3),c=t(5),u=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return a(r,e),r.generateKey=function(e,r,t){var n=this;return Promise.resolve().then(function(){n.checkModule();var a=3===e.publicExponent[0]?3:65537,s=asmCrypto.RSA.generateKey(e.modulusLength,a),u=new c.CryptoKey,h=new c.CryptoKey;switch(u.key=h.key=s,u.algorithm=h.algorithm=e,u.extractable=r,h.extractable=!0,u.type="private",h.type="public",e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():u.usages=n.filterUsages(["decrypt","unwrapKey"],t),h.usages=n.filterUsages(["encrypt","wrapKey"],t);break;case o.AlgorithmNames.RsaSSA.toLowerCase():case o.AlgorithmNames.RsaPSS.toLowerCase():u.usages=n.filterUsages(["sign"],t),h.usages=n.filterUsages(["verify"],t);break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}return{privateKey:u,publicKey:h}})},r.sign=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaSSA.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_PKCS1_v1_5_SHA1.sign;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_PKCS1_v1_5_SHA256.sign;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_PKCS1_v1_5_SHA512.sign;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}return s(t,r.key).buffer;case o.AlgorithmNames.RsaPSS.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_PSS_SHA1.sign;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_PSS_SHA256.sign;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_PSS_SHA512.sign;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}return s(t,r.key,a.saltLength).buffer;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.verify=function(e,r,t,n){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaSSA.toLowerCase():var a,s=r.algorithm;switch(s.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:a=asmCrypto.RSA_PKCS1_v1_5_SHA1.verify;break;case o.AlgorithmNames.Sha256:a=asmCrypto.RSA_PKCS1_v1_5_SHA256.verify;break;case o.AlgorithmNames.Sha512:a=asmCrypto.RSA_PKCS1_v1_5_SHA512.verify;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}try{return a(t,n,r.key)}catch(e){return console.warn("Verify error: "+e.message),!1}case o.AlgorithmNames.RsaPSS.toLowerCase():var c=r.algorithm,u=e,h=void 0;switch(c.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:h=asmCrypto.RSA_PSS_SHA1.verify;break;case o.AlgorithmNames.Sha256:h=asmCrypto.RSA_PSS_SHA256.verify;break;case o.AlgorithmNames.Sha512:h=asmCrypto.RSA_PSS_SHA512.verify;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}try{return h(t,n,r.key,u.saltLength)}catch(e){return console.warn("Verify error: "+e.message),!1}default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.encrypt=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_OAEP_SHA1.encrypt;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_OAEP_SHA256.encrypt;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_OAEP_SHA512.encrypt;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,n.name+" "+n.hash.name)}var c=void 0;return a.label&&(c=o.PrepareData(a.label,"label")),s(t,r.key,c);default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.decrypt=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_OAEP_SHA1.decrypt;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_OAEP_SHA256.decrypt;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_OAEP_SHA512.decrypt;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,n.name+" "+n.hash.name)}var c=void 0;return a.label&&(c=o.PrepareData(a.label,"label")),s(t,r.key,c);default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.wrapKey=function(e,r,t,n){var a;return Promise.resolve().then(function(){return a=new h.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 h.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){var r=e.hash,t=/(\d+)/.exec(r.name)[1];switch(e.name.toUpperCase()){case o.AlgorithmNames.RsaOAEP.toUpperCase():return"RSA-OAEP"+("1"===t?"":"-"+t);case o.AlgorithmNames.RsaPSS.toUpperCase():return"PS"+t;case o.AlgorithmNames.RsaSSA.toUpperCase():return"RS"+t;default:throw new o.AlgorithmError(o.AlgorithmError.UNSUPPORTED_ALGORITHM,e.name)}},r.jwk2alg=function(e){throw new Error("Not implemented")},r.exportKey=function(e,r){var t=this;return Promise.resolve().then(function(){if("jwk"===e.toLowerCase()){var a={kty:"RSA",ext:!0,key_ops:r.usages};return a.alg=t.alg2jwk(r.algorithm),a.n=o.Base64Url.encode(n(r.key[0])),a.e=o.Base64Url.encode(n(r.key[1])),"private"===r.type&&(a.d=o.Base64Url.encode(n(r.key[2])),a.p=o.Base64Url.encode(n(r.key[3])),a.q=o.Base64Url.encode(n(r.key[4])),a.dp=o.Base64Url.encode(n(r.key[5])),a.dq=o.Base64Url.encode(n(r.key[6])),a.qi=o.Base64Url.encode(n(r.key[7]))),a}throw new i.LinerError(i.LinerError.NOT_SUPPORTED)})},r.importKey=function(e,r,t,n,a){return Promise.resolve().then(function(){var n,s=new c.CryptoKey;if(s.algorithm=t,s.usages=a,s.key=[],"jwk"===e.toLowerCase())return n=r,s.key[0]=o.Base64Url.decode(n.n),s.key[1]=3===o.Base64Url.decode(n.e)[0]?new Uint8Array([0,0,0,3]):new Uint8Array([0,1,0,1]),n.d?(s.type="private",s.key[2]=o.Base64Url.decode(n.d),s.key[3]=o.Base64Url.decode(n.p),s.key[4]=o.Base64Url.decode(n.q),s.key[5]=o.Base64Url.decode(n.dp),s.key[6]=o.Base64Url.decode(n.dq),s.key[7]=o.Base64Url.decode(n.qi)):s.type="public",s;throw new i.LinerError(i.LinerError.NOT_SUPPORTED)})},r.checkModule=function(){if("undefined"==typeof asmCrypto)throw new i.LinerError(i.LinerError.MODULE_NOT_FOUND,"asmCrypto","https://github.com/vibornoff/asmcrypto.js")},r.filterUsages=function(e,r){return e.filter(function(e){return!!r.filter(function(r){return e===r}).length})},r}(o.BaseCrypto);r.RsaCrypto=u;var h=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";function n(e,r){return Promise.resolve().then(function(){if(e.key)return e;if(e.extractable){return(new y.Crypto).subtle.exportKey("jwk",e).then(function(t){var n=o(e);return n&&(n=A.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){A.BrowserInfo().name!==A.Browser.IE&&A.BrowserInfo().name!==A.Browser.Edge&&A.BrowserInfo().name!==A.Browser.Safari||!/^rsa/i.test(e.name)||(r.privateKey?(d.push({hash:e.hash,key:r.privateKey}),d.push({hash:e.hash,key:r.publicKey})):d.push({hash:e.hash,key:r}))}function o(e){var r=null;return d.some(function(t){return t.key===e&&(r=A.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&&A.BrowserInfo().name===A.Browser.IE){"extractable"in e&&(e.ext=e.extractable,delete e.extractable);var n=null;switch(r.name.toUpperCase()){case h.AlgorithmNames.RsaOAEP.toUpperCase():case h.AlgorithmNames.RsaPSS.toUpperCase():case h.AlgorithmNames.RsaSSA.toUpperCase():n=g.RsaCrypto;break;case h.AlgorithmNames.AesECB.toUpperCase():case h.AlgorithmNames.AesCBC.toUpperCase():case h.AlgorithmNames.AesGCM.toUpperCase():n=w.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){A.BrowserInfo().name===A.Browser.IE&&("ext"in e&&(e.extractable=e.ext,delete e.ext),delete e.key_ops,delete e.alg)}var u=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),p=t(0),f=t(0),l=t(4),y=t(2),m=t(1),A=t(3),w=t(8),v=t(11),g=t(10),C=t(9),d=[],E=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),r.prototype.generateKey=function(r,t,n){var o,s=arguments;return e.prototype.generateKey.apply(this,s).then(function(e){if(o=f.PrepareAlgorithm(r),(A.BrowserInfo().name!==A.Browser.Edge||o.name.toUpperCase()!==h.AlgorithmNames.AesGCM)&&l.nativeSubtle)try{return l.nativeSubtle.generateKey.apply(l.nativeSubtle,s).catch(function(e){console.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return i(e,n),a(o,e),e;var r;switch(o.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():r=w.AesCrypto;break;case h.AlgorithmNames.EcDSA.toLowerCase():case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaSSA.toLowerCase():r=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,o.name.toLowerCase())}return r.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=f.PrepareAlgorithm(r),a=f.PrepareData(t,"data"),l.nativeSubtle)try{return l.nativeSubtle.digest.apply(l.nativeSubtle,o).catch(function(e){console.warn("WebCrypto: native digest for "+n.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native digest for "+n.name+" doesn't work.",e.message||"")}}).then(function(e){return e||v.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=f.PrepareAlgorithm(r),s=f.PrepareData(a,"data");var n=o(t);if(n&&(c[0]=A.assign(i,n)),l.nativeSubtle)try{return l.nativeSubtle.sign.apply(l.nativeSubtle,c).catch(function(e){console.warn("WebCrypto: native sign for "+i.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native sign for "+i.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return e;var r;switch(i.name.toLowerCase()){case h.AlgorithmNames.EcDSA.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():r=g.RsaCrypto;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,a,i){var s,c,u,p=arguments;return e.prototype.verify.apply(this,p).then(function(e){s=f.PrepareAlgorithm(r),c=f.PrepareData(a,"data"),u=f.PrepareData(i,"data");var n=o(t);if(n&&(p[0]=A.assign(s,n)),l.nativeSubtle)try{return l.nativeSubtle.verify.apply(l.nativeSubtle,p).catch(function(e){console.warn("WebCrypto: native verify for "+s.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native verify for "+s.name+" doesn't work.",e.message||"")}}).then(function(e){if("boolean"==typeof e)return e;var r;switch(s.name.toLowerCase()){case h.AlgorithmNames.EcDSA.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():r=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,s.name.toLowerCase())}return n(t,r).then(function(e){return r.verify(s,e,c,u)})})},r.prototype.deriveBits=function(r,t,n){var a,o=arguments;return e.prototype.deriveBits.apply(this,o).then(function(e){if(a=f.PrepareAlgorithm(r),l.nativeSubtle)try{return l.nativeSubtle.deriveBits.apply(l.nativeSubtle,o).catch(function(e){console.warn("WebCrypto: native deriveBits for "+a.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native deriveBits for "+a.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return e;var r;switch(a.name.toLowerCase()){case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;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=f.PrepareAlgorithm(r),c=f.PrepareAlgorithm(n),l.nativeSubtle)try{return l.nativeSubtle.deriveKey.apply(l.nativeSubtle,u).catch(function(e){console.warn("WebCrypto: native deriveKey for "+s.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native deriveKey for "+s.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return i(e,o),e;var r;switch(s.name.toLowerCase()){case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"deriveBits")}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=f.PrepareAlgorithm(r),i=f.PrepareData(a,"data"),l.nativeSubtle)try{return l.nativeSubtle.encrypt.apply(l.nativeSubtle,s).catch(function(e){console.warn("WebCrypto: native 'encrypt' for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'encrypt' for "+o.name+" doesn't work.",e.message||"")}}).then(function(e){if(e){if(A.BrowserInfo().name===A.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():s=g.RsaCrypto;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=f.PrepareAlgorithm(r),o=f.PrepareData(n,"data");var i=o;if(A.BrowserInfo().name===A.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():c=g.RsaCrypto;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=f.PrepareAlgorithm(a),l.nativeSubtle)try{return l.nativeSubtle.wrapKey.apply(l.nativeSubtle,i).catch(function(e){console.warn("WebCrypto: native 'wrapKey' for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'wrapKey' for "+o.name+" doesn't work.",e.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():a=g.RsaCrypto;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,y,v=this,C=arguments;return e.prototype.unwrapKey.apply(this,C).then(function(e){if(u=f.PrepareAlgorithm(a),p=f.PrepareAlgorithm(o),y=f.PrepareData(t,"wrappedKey"),n.key){var d=void 0;switch(u.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():d=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():d=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"unwrapKey")}return d.unwrapKey(r,y,n,u,p,s,c)}return l.nativeSubtle.unwrapKey.apply(l.nativeSubtle,C).catch(function(e){return v.decrypt(u,n,t).then(function(e){var t;return t="jwk"===r?JSON.parse(A.buffer2string(new Uint8Array(e))):e,v.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){console.warn("WebCrypto: native 'exportKey' for "+t.algorithm.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'exportKey' for "+t.algorithm.name+" doesn't work.",e.message||"")}}).then(function(e){if(e){"jwk"===r&&e instanceof ArrayBuffer&&(e=A.buffer2string(new Uint8Array(e)),e=JSON.parse(e));var n=o(t);return n||(n=A.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=w.AesCrypto;break;case h.AlgorithmNames.EcDH.toLowerCase():case h.AlgorithmNames.EcDSA.toLowerCase():a=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaOAEP.toLowerCase():a=g.RsaCrypto;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 u,p,y=arguments;return e.prototype.importKey.apply(this,y).then(function(e){if(u=f.PrepareAlgorithm(n),p=t,A.BrowserInfo().name!==A.Browser.Safari&&A.BrowserInfo().name!==A.Browser.IE||(A.BrowserInfo().name===A.Browser.IE&&(t=A.assign({},t),c(t)),y[1]=A.string2buffer(JSON.stringify(t)).buffer),ArrayBuffer.isView(t)&&(p=f.PrepareData(t,"keyData")),l.nativeSubtle)try{return l.nativeSubtle.importKey.apply(l.nativeSubtle,y).catch(function(e){console.warn("WebCrypto: native 'importKey' for "+u.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'importKey' for "+u.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return a(u,e),i(e,s),Promise.resolve(e);var t;switch(u.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():t=w.AesCrypto;break;case h.AlgorithmNames.EcDH.toLowerCase():case h.AlgorithmNames.EcDSA.toLowerCase():t=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaOAEP.toLowerCase():t=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,u.name.toLowerCase())}return t.importKey(r,p,u,o,s)})},r}(p.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){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){e.exports=require("crypto")},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(7);Object.freeze(Math),Object.freeze(Math.random),Object.freeze(Math.imul),n.nativeCrypto&&Object.freeze(n.nativeCrypto.getRandomValues),r.crypto=new n.Crypto}]);

@@ -1,2 +0,2 @@

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.i=function(e){return e},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";(function(e){function n(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];for(var n,a=e,o=/[^%](%\d+)/g,i=[];n=o.exec(a);)i.push({arg:n[1],index:n.index});for(var s=i.length-1;s>=0;s--){var c=i[s],u=c.arg.substring(1),h=c.index+1;a=a.substring(0,h)+arguments[+u]+a.substring(h+1+u.length)}return a=a.replace("%%","%")}function a(e){var r;r="string"==typeof e?{name:e}:e,h.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(ArrayBuffer.isView(e))return new Uint8Array(e.buffer);if(e instanceof ArrayBuffer)return new Uint8Array(e);throw new s("Incoming parameter '"+r+"' has wrong data type. Must be ArrayBufferView or ArrayBuffer")}Object.defineProperty(r,"__esModule",{value:!0});var i=t(6);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 h}),t.d(r,"AlgorithmNames",function(){return p}),t.d(r,"Base64Url",function(){return l}),t.d(r,"SubtleCrypto",function(){return W}),t.d(r,"Aes",function(){return m}),t.d(r,"AesAlgorithmError",function(){return A}),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 d}),t.d(r,"AesGCM",function(){return E}),t.d(r,"AesKW",function(){return P}),t.d(r,"RsaKeyGenParamsError",function(){return N}),t.d(r,"RsaHashedImportParamsError",function(){return G}),t.d(r,"Rsa",function(){return M}),t.d(r,"RsaSSA",function(){return B}),t.d(r,"RsaPSSParamsError",function(){return T}),t.d(r,"RsaPSS",function(){return D}),t.d(r,"RsaOAEPParamsError",function(){return x}),t.d(r,"RsaOAEP",function(){return H}),t.d(r,"EcKeyGenParamsError",function(){return S}),t.d(r,"Ec",function(){return _}),t.d(r,"EcAlgorithmError",function(){return U}),t.d(r,"EcDSA",function(){return L}),t.d(r,"EcDH",function(){return R}),t.d(r,"ShaAlgorithms",function(){return k}),t.d(r,"Sha",function(){return b});var 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 t.i(i.a)(r,e),r}(Error);s.NOT_SUPPORTED="Method is not supported";var c=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=1,r}return t.i(i.a)(r,e),r}(s);c.PARAM_REQUIRED="Algorithm hasn't got required paramter '%1'",c.PARAM_WRONG_TYPE="Algorithm has got wrong type for paramter '%1'. Must be %2",c.PARAM_WRONG_VALUE="Algorithm has got wrong value for paramter '%1'. Must be %2",c.WRONG_ALG_NAME="Algorithm has got wrong name '%1'. Must be '%2'",c.UNSUPPORTED_ALGORITHM="Algorithm '%1' is not supported",c.WRONG_USAGE="Algorithm doesn't support key usage '%1'";var u=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=3,r}return t.i(i.a)(r,e),r}(s);u.EMPTY_KEY="CryptoKey is empty",u.WRONG_KEY_ALG="CryptoKey has wrong algorithm '%1'. Must be '%2'",u.WRONG_KEY_TYPE="CryptoKey has wrong type '%1'. Must be '%2'",u.WRONG_KEY_USAGE="CryptoKey has wrong key usage. Must be '%1'",u.NOT_EXTRACTABLE="CryptoKey is not extractable",u.WRONG_FORMAT="CryptoKey has '%1' type. It can be used with '%2' format",u.UNKNOWN_FORMAT="Unknown format in use '%1'. Must be one of 'raw', 'pkcs8', 'spki' or 'jwk'",u.ALLOWED_FORMAT="Wrong format value '%1'. Must be %2";var h=function(){function e(){}return e.checkAlgorithm=function(e){if("object"!=typeof e)throw new TypeError("Wrong algorithm data type. Must be Object");if(!("name"in e))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}(),p={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"};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 l=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}(),y=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=7,r}return t.i(i.a)(r,e),r}(c),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 y(y.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}(h);m.ALG_NAME="",m.KEY_USAGES=[];var A=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=8,r}return t.i(i.a)(r,e),r}(c),w=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(m),v=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(w);v.KEY_USAGES=["encrypt","decrypt","wrapKey","unwrapKey"];var g=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r}(v);g.ALG_NAME=p.AesECB;var C=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),!e.iv)throw new A(A.PARAM_REQUIRED,"iv");if(!(ArrayBuffer.isView(e.iv)||e.iv instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"iv","ArrayBufferView or ArrayBuffer");if(16!==e.iv.byteLength)throw new A(A.PARAM_WRONG_VALUE,"iv","ArrayBufferView or ArrayBuffer with size 16")},r}(v);C.ALG_NAME=p.AesCBC;var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),!e.counter||!(ArrayBuffer.isView(e.counter)||e.counter instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"counter","ArrayBufferView or ArrayBuffer");if(16!==e.counter.byteLength)throw new A(A.PARAM_WRONG_VALUE,"counter","ArrayBufferView or ArrayBuffer with size 16");if(!(e.length>0&&e.length<=128))throw new A(A.PARAM_WRONG_VALUE,"length","number [1-128]")},r}(v);d.ALG_NAME=p.AesCTR;var E=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),e.additionalData&&!(ArrayBuffer.isView(e.additionalData)||e.additionalData instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"additionalData","ArrayBufferView or ArrayBuffer");if(!e.iv)throw new A(A.PARAM_REQUIRED,"iv");if(!(ArrayBuffer.isView(e.iv)||e.iv instanceof ArrayBuffer))throw new A(A.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 A(A.PARAM_WRONG_VALUE,"tagLength","32, 64, 96, 104, 112, 120 or 128")}},r}(v);E.ALG_NAME=p.AesGCM;var P=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){this.checkAlgorithm(e)},r}(w);P.ALG_NAME=p.AesKW,P.KEY_USAGES=["wrapKey","unwrapKey"];var k=[p.Sha1,p.Sha256,p.Sha384,p.Sha512].join(" | "),b=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 p.Sha1:case p.Sha256:case p.Sha384:case p.Sha512:break;default:throw new c(c.WRONG_ALG_NAME,t.name,k)}},r.digest=function(e,r){var t=this;return new Promise(function(r,n){t.checkAlgorithm(e),r(void 0)})},r}(h),S=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=9,r}return t.i(i.a)(r,e),r}(c),_=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 S(S.PARAM_REQUIRED,"namedCurve");if("string"!=typeof e.namedCurve)throw new S(S.PARAM_WRONG_TYPE,"namedCurve","string");switch(e.namedCurve.toUpperCase()){case"P-256":case"P-384":case"P-521":break;default:throw new S(S.PARAM_WRONG_VALUE,"namedCurve","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}(h);_.ALG_NAME="",_.KEY_USAGES=[];var U=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=10,r}return t.i(i.a)(r,e),r}(c),L=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){this.checkAlgorithm(e),b.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}(_);L.ALG_NAME=p.EcDSA,L.KEY_USAGES=["sign","verify","deriveKey","deriveBits"];var R=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkDeriveParams=function(e){if(this.checkAlgorithm(e),!e.public)throw new U(U.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"),h.checkAlgorithm(t),t.name.toUpperCase()){case p.AesCBC:C.checkKeyGenParams(t);break;case p.AesCTR:d.checkKeyGenParams(t);break;case p.AesGCM:E.checkKeyGenParams(t);break;case p.AesKW:P.checkKeyGenParams(t);break;default:throw new U("Unsupported name '"+t.name+"' for algorithm in param 'derivedKeyType'")}n(void 0)})},r}(_);R.ALG_NAME=p.EcDH,R.KEY_USAGES=["deriveKey","deriveBits"];var K=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(h);K.ALG_NAME=p.Hmac,K.KEY_USAGES=["sign","verify"];var O=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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);b.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"),h.checkAlgorithm(t),t.name.toUpperCase()){case p.AesCBC:C.checkKeyGenParams(t),C.checkKeyUsages(a);break;case p.AesCTR:d.checkKeyGenParams(t),d.checkKeyUsages(a);break;case p.AesGCM:E.checkKeyGenParams(t),E.checkKeyUsages(a);break;case p.AesKW:P.checkKeyGenParams(t),P.checkKeyUsages(a);break;case p.Hmac:K.checkKeyGenParams(t),K.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}(h);O.ALG_NAME=p.Pbkdf2,O.KEY_USAGES=["deriveKey","deriveBits"];var N=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=2,r}return t.i(i.a)(r,e),r}(c),G=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=6,r}return t.i(i.a)(r,e),r}(c),M=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 G(G.PARAM_REQUIRED,"hash");b.checkAlgorithm(e.hash)},r.checkKeyGenParams=function(e){var r=e.modulusLength;if(!(r>=256&&r<=16384)||r%8)throw new N(N.PARAM_WRONG_VALUE,"modulusLength"," a multiple of 8 bits and >= 256 and <= 16384");var t=e.publicExponent;if(!t)throw new N(N.PARAM_REQUIRED,"publicExponent");if(!ArrayBuffer.isView(t))throw new N(N.PARAM_WRONG_TYPE,"publicExponent","ArrayBufferView");if(3!==t[0]&&(1!==t[0]||0!==t[1]||1!==t[2]))throw new N(N.PARAM_WRONG_VALUE,"publicExponent","Uint8Array([3]) | Uint8Array([1, 0, 1])");if(!e.hash)throw new N(N.PARAM_REQUIRED,"hash",k);b.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}(h);M.ALG_NAME="",M.KEY_USAGES=[];var B=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(M);B.ALG_NAME=p.RsaSSA,B.KEY_USAGES=["sign","verify"];var T=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=4,r}return t.i(i.a)(r,e),r}(c),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(r){var t=r;if(e.checkAlgorithmParams.call(this,t),!t.saltLength)throw new T(T.PARAM_REQUIRED,"saltLength");if(t.saltLength<0)throw new T("Parameter 'saltLength' is outside of numeric range")},r}(B);D.ALG_NAME=p.RsaPSS;var x=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=5,r}return t.i(i.a)(r,e),r}(c),H=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(e.label&&!(ArrayBuffer.isView(e.label)||e.label instanceof ArrayBuffer))throw new x(x.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}(M);H.ALG_NAME=p.RsaOAEP,H.KEY_USAGES=["encrypt","decrypt","wrapKey","unwrapKey"];var W=function(){function e(){}return e.prototype.generateKey=function(e,r,t){return new Promise(function(n,o){var i=a(e),s=h;switch(i.name.toUpperCase()){case p.RsaSSA.toUpperCase():s=B;break;case p.RsaOAEP.toUpperCase():s=H;break;case p.RsaPSS.toUpperCase():s=D;break;case p.AesECB.toUpperCase():s=g;break;case p.AesCBC.toUpperCase():s=C;break;case p.AesCTR.toUpperCase():s=d;break;case p.AesGCM.toUpperCase():s=E;break;case p.AesKW.toUpperCase():s=P;break;case p.EcDSA.toUpperCase():s=L;break;case p.EcDH.toUpperCase():s=R;break;case p.Hmac.toUpperCase():s=K;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=h;switch(i.name.toUpperCase()){case p.Sha1.toUpperCase():case p.Sha256.toUpperCase():case p.Sha384.toUpperCase():case p.Sha512.toUpperCase():u=b;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=h;switch(s.name.toUpperCase()){case p.RsaSSA.toUpperCase():f=B;break;case p.RsaPSS.toUpperCase():f=D;break;case p.EcDSA.toUpperCase():f=L;break;case p.Hmac.toUpperCase():f=K;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"),l=h;switch(s.name.toUpperCase()){case p.RsaSSA.toUpperCase():l=B;break;case p.RsaPSS.toUpperCase():l=D;break;case p.EcDSA.toUpperCase():l=L;break;case p.Hmac.toUpperCase():l=K;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,s.name)}l.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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;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=h;switch(i.name.toUpperCase()){case p.EcDH.toUpperCase():s=R;break;case p.Pbkdf2.toUpperCase():s=O;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),l=h;switch(u.name.toUpperCase()){case p.EcDH.toUpperCase():l=R;break;case p.Pbkdf2.toUpperCase():l=O;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,u.name)}l.deriveKey(u,r,f,n,o).then(i,s)})},e.prototype.exportKey=function(e,r){return new Promise(function(t,n){if(h.checkKey(r),!r.extractable)throw new u(u.NOT_EXTRACTABLE);var a=h;switch(r.algorithm.name.toUpperCase()){case p.RsaSSA.toUpperCase():a=B;break;case p.RsaPSS.toUpperCase():a=D;break;case p.AesECB.toUpperCase():a=g;break;case p.RsaOAEP.toUpperCase():a=H;break;case p.AesCBC.toUpperCase():a=C;break;case p.AesCTR.toUpperCase():a=d;break;case p.AesGCM.toUpperCase():a=E;break;case p.AesKW.toUpperCase():a=P;break;case p.EcDSA.toUpperCase():a=L;break;case p.EcDH.toUpperCase():a=R;break;case p.Hmac.toUpperCase():a=K;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=h;switch(u.name.toUpperCase()){case p.RsaSSA.toUpperCase():f=B;break;case p.RsaPSS.toUpperCase():f=D;break;case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;break;case p.AesKW.toUpperCase():f=P;break;case p.EcDSA.toUpperCase():f=L;break;case p.EcDH.toUpperCase():f=R;break;case p.Hmac.toUpperCase():f=K;break;case p.Pbkdf2.toUpperCase():f=O;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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():u=H;break;case p.AesECB.toUpperCase():u=g;break;case p.AesCBC.toUpperCase():u=C;break;case p.AesCTR.toUpperCase():u=d;break;case p.AesGCM.toUpperCase():u=E;break;case p.AesKW.toUpperCase():u=P;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,l){var y=a(n),m=a(i),A=o(r,"wrappedKey"),w=h;switch(y.name.toUpperCase()){case p.RsaOAEP.toUpperCase():w=H;break;case p.AesECB.toUpperCase():w=g;break;case p.AesCBC.toUpperCase():w=C;break;case p.AesCTR.toUpperCase():w=d;break;case p.AesGCM.toUpperCase():w=E;break;case p.AesKW.toUpperCase():w=P;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,y.name)}w.unwrapKey(e,A,t,y,m,s,u).then(f,l)})},e}()}).call(r,t(8))},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}(a.WebCryptoError);o.MODULE_NOT_FOUND="Module '%1' is not found. Download it from %2",o.UNSUPPORTED_ALGORITHM="Unsupported algorithm '%1'",r.LinerError=o},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(13),a=t(4),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(){var e,t={name:"",version:""},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}Object.defineProperty(r,"__esModule",{value:!0}),r.Browser={IE:"Internet Explorer",Safari:"Safari",Edge:"Edge",Chrome:"Chrome",Firefox:"Firefox Mozilla"},r.BrowserInfo=n,r.string2buffer=a,r.buffer2string=o,r.concat=i,r.assign=s},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(14);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(){}return e}();r.CryptoKey=n},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;/*! *****************************************************************************
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.i=function(e){return e},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";(function(e){function n(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];for(var n,a=e,o=/[^%](%\d+)/g,i=[];n=o.exec(a);)i.push({arg:n[1],index:n.index});for(var s=i.length-1;s>=0;s--){var c=i[s],u=c.arg.substring(1),h=c.index+1;a=a.substring(0,h)+arguments[+u]+a.substring(h+1+u.length)}return a=a.replace("%%","%")}function a(e){var r;r="string"==typeof e?{name:e}:e,h.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(ArrayBuffer.isView(e))return new Uint8Array(e.buffer);if(e instanceof ArrayBuffer)return new Uint8Array(e);throw new s("Incoming parameter '"+r+"' has wrong data type. Must be ArrayBufferView or ArrayBuffer")}Object.defineProperty(r,"__esModule",{value:!0});var i=t(6);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 h}),t.d(r,"AlgorithmNames",function(){return p}),t.d(r,"Base64Url",function(){return l}),t.d(r,"SubtleCrypto",function(){return W}),t.d(r,"Aes",function(){return m}),t.d(r,"AesAlgorithmError",function(){return A}),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 d}),t.d(r,"AesGCM",function(){return E}),t.d(r,"AesKW",function(){return P}),t.d(r,"RsaKeyGenParamsError",function(){return N}),t.d(r,"RsaHashedImportParamsError",function(){return G}),t.d(r,"Rsa",function(){return M}),t.d(r,"RsaSSA",function(){return B}),t.d(r,"RsaPSSParamsError",function(){return T}),t.d(r,"RsaPSS",function(){return D}),t.d(r,"RsaOAEPParamsError",function(){return x}),t.d(r,"RsaOAEP",function(){return H}),t.d(r,"EcKeyGenParamsError",function(){return S}),t.d(r,"Ec",function(){return _}),t.d(r,"EcAlgorithmError",function(){return U}),t.d(r,"EcDSA",function(){return L}),t.d(r,"EcDH",function(){return R}),t.d(r,"ShaAlgorithms",function(){return k}),t.d(r,"Sha",function(){return b});var 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 t.i(i.a)(r,e),r}(Error);s.NOT_SUPPORTED="Method is not supported";var c=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=1,r}return t.i(i.a)(r,e),r}(s);c.PARAM_REQUIRED="Algorithm hasn't got required paramter '%1'",c.PARAM_WRONG_TYPE="Algorithm has got wrong type for paramter '%1'. Must be %2",c.PARAM_WRONG_VALUE="Algorithm has got wrong value for paramter '%1'. Must be %2",c.WRONG_ALG_NAME="Algorithm has got wrong name '%1'. Must be '%2'",c.UNSUPPORTED_ALGORITHM="Algorithm '%1' is not supported",c.WRONG_USAGE="Algorithm doesn't support key usage '%1'";var u=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=3,r}return t.i(i.a)(r,e),r}(s);u.EMPTY_KEY="CryptoKey is empty",u.WRONG_KEY_ALG="CryptoKey has wrong algorithm '%1'. Must be '%2'",u.WRONG_KEY_TYPE="CryptoKey has wrong type '%1'. Must be '%2'",u.WRONG_KEY_USAGE="CryptoKey has wrong key usage. Must be '%1'",u.NOT_EXTRACTABLE="CryptoKey is not extractable",u.WRONG_FORMAT="CryptoKey has '%1' type. It can be used with '%2' format",u.UNKNOWN_FORMAT="Unknown format in use '%1'. Must be one of 'raw', 'pkcs8', 'spki' or 'jwk'",u.ALLOWED_FORMAT="Wrong format value '%1'. Must be %2";var h=function(){function e(){}return e.checkAlgorithm=function(e){if("object"!=typeof e)throw new TypeError("Wrong algorithm data type. Must be Object");if(!("name"in e))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}(),p={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"};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 l=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}(),y=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=7,r}return t.i(i.a)(r,e),r}(c),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 y(y.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}(h);m.ALG_NAME="",m.KEY_USAGES=[];var A=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=8,r}return t.i(i.a)(r,e),r}(c),w=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(m),v=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(w);v.KEY_USAGES=["encrypt","decrypt","wrapKey","unwrapKey"];var g=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r}(v);g.ALG_NAME=p.AesECB;var C=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),!e.iv)throw new A(A.PARAM_REQUIRED,"iv");if(!(ArrayBuffer.isView(e.iv)||e.iv instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"iv","ArrayBufferView or ArrayBuffer");if(16!==e.iv.byteLength)throw new A(A.PARAM_WRONG_VALUE,"iv","ArrayBufferView or ArrayBuffer with size 16")},r}(v);C.ALG_NAME=p.AesCBC;var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),!e.counter||!(ArrayBuffer.isView(e.counter)||e.counter instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"counter","ArrayBufferView or ArrayBuffer");if(16!==e.counter.byteLength)throw new A(A.PARAM_WRONG_VALUE,"counter","ArrayBufferView or ArrayBuffer with size 16");if(!(e.length>0&&e.length<=128))throw new A(A.PARAM_WRONG_VALUE,"length","number [1-128]")},r}(v);d.ALG_NAME=p.AesCTR;var E=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(this.checkAlgorithm(e),e.additionalData&&!(ArrayBuffer.isView(e.additionalData)||e.additionalData instanceof ArrayBuffer))throw new A(A.PARAM_WRONG_TYPE,"additionalData","ArrayBufferView or ArrayBuffer");if(!e.iv)throw new A(A.PARAM_REQUIRED,"iv");if(!(ArrayBuffer.isView(e.iv)||e.iv instanceof ArrayBuffer))throw new A(A.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 A(A.PARAM_WRONG_VALUE,"tagLength","32, 64, 96, 104, 112, 120 or 128")}},r}(v);E.ALG_NAME=p.AesGCM;var P=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){this.checkAlgorithm(e)},r}(w);P.ALG_NAME=p.AesKW,P.KEY_USAGES=["wrapKey","unwrapKey"];var k=[p.Sha1,p.Sha256,p.Sha384,p.Sha512].join(" | "),b=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 p.Sha1:case p.Sha256:case p.Sha384:case p.Sha512:break;default:throw new c(c.WRONG_ALG_NAME,t.name,k)}},r.digest=function(e,r){var t=this;return new Promise(function(r,n){t.checkAlgorithm(e),r(void 0)})},r}(h),S=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=9,r}return t.i(i.a)(r,e),r}(c),_=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 S(S.PARAM_REQUIRED,"namedCurve");if("string"!=typeof e.namedCurve)throw new S(S.PARAM_WRONG_TYPE,"namedCurve","string");switch(e.namedCurve.toUpperCase()){case"P-256":case"P-384":case"P-521":break;default:throw new S(S.PARAM_WRONG_VALUE,"namedCurve","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}(h);_.ALG_NAME="",_.KEY_USAGES=[];var U=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=10,r}return t.i(i.a)(r,e),r}(c),L=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){this.checkAlgorithm(e),b.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}(_);L.ALG_NAME=p.EcDSA,L.KEY_USAGES=["sign","verify","deriveKey","deriveBits"];var R=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkDeriveParams=function(e){if(this.checkAlgorithm(e),!e.public)throw new U(U.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"),h.checkAlgorithm(t),t.name.toUpperCase()){case p.AesCBC:C.checkKeyGenParams(t);break;case p.AesCTR:d.checkKeyGenParams(t);break;case p.AesGCM:E.checkKeyGenParams(t);break;case p.AesKW:P.checkKeyGenParams(t);break;default:throw new U("Unsupported name '"+t.name+"' for algorithm in param 'derivedKeyType'")}n(void 0)})},r}(_);R.ALG_NAME=p.EcDH,R.KEY_USAGES=["deriveKey","deriveBits"];var K=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(h);K.ALG_NAME=p.Hmac,K.KEY_USAGES=["sign","verify"];var O=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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);b.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"),h.checkAlgorithm(t),t.name.toUpperCase()){case p.AesCBC:C.checkKeyGenParams(t),C.checkKeyUsages(a);break;case p.AesCTR:d.checkKeyGenParams(t),d.checkKeyUsages(a);break;case p.AesGCM:E.checkKeyGenParams(t),E.checkKeyUsages(a);break;case p.AesKW:P.checkKeyGenParams(t),P.checkKeyUsages(a);break;case p.Hmac:K.checkKeyGenParams(t),K.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}(h);O.ALG_NAME=p.Pbkdf2,O.KEY_USAGES=["deriveKey","deriveBits"];var N=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=2,r}return t.i(i.a)(r,e),r}(c),G=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=6,r}return t.i(i.a)(r,e),r}(c),M=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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 G(G.PARAM_REQUIRED,"hash");b.checkAlgorithm(e.hash)},r.checkKeyGenParams=function(e){var r=e.modulusLength;if(!(r>=256&&r<=16384)||r%8)throw new N(N.PARAM_WRONG_VALUE,"modulusLength"," a multiple of 8 bits and >= 256 and <= 16384");var t=e.publicExponent;if(!t)throw new N(N.PARAM_REQUIRED,"publicExponent");if(!ArrayBuffer.isView(t))throw new N(N.PARAM_WRONG_TYPE,"publicExponent","ArrayBufferView");if(3!==t[0]&&(1!==t[0]||0!==t[1]||1!==t[2]))throw new N(N.PARAM_WRONG_VALUE,"publicExponent","Uint8Array([3]) | Uint8Array([1, 0, 1])");if(!e.hash)throw new N(N.PARAM_REQUIRED,"hash",k);b.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}(h);M.ALG_NAME="",M.KEY_USAGES=[];var B=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(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}(M);B.ALG_NAME=p.RsaSSA,B.KEY_USAGES=["sign","verify"];var T=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=4,r}return t.i(i.a)(r,e),r}(c),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(r){var t=r;if(e.checkAlgorithmParams.call(this,t),!t.saltLength)throw new T(T.PARAM_REQUIRED,"saltLength");if(t.saltLength<0)throw new T("Parameter 'saltLength' is outside of numeric range")},r}(B);D.ALG_NAME=p.RsaPSS;var x=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=5,r}return t.i(i.a)(r,e),r}(c),H=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.i(i.a)(r,e),r.checkAlgorithmParams=function(e){if(e.label&&!(ArrayBuffer.isView(e.label)||e.label instanceof ArrayBuffer))throw new x(x.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}(M);H.ALG_NAME=p.RsaOAEP,H.KEY_USAGES=["encrypt","decrypt","wrapKey","unwrapKey"];var W=function(){function e(){}return e.prototype.generateKey=function(e,r,t){return new Promise(function(n,o){var i=a(e),s=h;switch(i.name.toUpperCase()){case p.RsaSSA.toUpperCase():s=B;break;case p.RsaOAEP.toUpperCase():s=H;break;case p.RsaPSS.toUpperCase():s=D;break;case p.AesECB.toUpperCase():s=g;break;case p.AesCBC.toUpperCase():s=C;break;case p.AesCTR.toUpperCase():s=d;break;case p.AesGCM.toUpperCase():s=E;break;case p.AesKW.toUpperCase():s=P;break;case p.EcDSA.toUpperCase():s=L;break;case p.EcDH.toUpperCase():s=R;break;case p.Hmac.toUpperCase():s=K;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=h;switch(i.name.toUpperCase()){case p.Sha1.toUpperCase():case p.Sha256.toUpperCase():case p.Sha384.toUpperCase():case p.Sha512.toUpperCase():u=b;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=h;switch(s.name.toUpperCase()){case p.RsaSSA.toUpperCase():f=B;break;case p.RsaPSS.toUpperCase():f=D;break;case p.EcDSA.toUpperCase():f=L;break;case p.Hmac.toUpperCase():f=K;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"),l=h;switch(s.name.toUpperCase()){case p.RsaSSA.toUpperCase():l=B;break;case p.RsaPSS.toUpperCase():l=D;break;case p.EcDSA.toUpperCase():l=L;break;case p.Hmac.toUpperCase():l=K;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,s.name)}l.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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;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=h;switch(i.name.toUpperCase()){case p.EcDH.toUpperCase():s=R;break;case p.Pbkdf2.toUpperCase():s=O;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),l=h;switch(u.name.toUpperCase()){case p.EcDH.toUpperCase():l=R;break;case p.Pbkdf2.toUpperCase():l=O;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,u.name)}l.deriveKey(u,r,f,n,o).then(i,s)})},e.prototype.exportKey=function(e,r){return new Promise(function(t,n){if(h.checkKey(r),!r.extractable)throw new u(u.NOT_EXTRACTABLE);var a=h;switch(r.algorithm.name.toUpperCase()){case p.RsaSSA.toUpperCase():a=B;break;case p.RsaPSS.toUpperCase():a=D;break;case p.AesECB.toUpperCase():a=g;break;case p.RsaOAEP.toUpperCase():a=H;break;case p.AesCBC.toUpperCase():a=C;break;case p.AesCTR.toUpperCase():a=d;break;case p.AesGCM.toUpperCase():a=E;break;case p.AesKW.toUpperCase():a=P;break;case p.EcDSA.toUpperCase():a=L;break;case p.EcDH.toUpperCase():a=R;break;case p.Hmac.toUpperCase():a=K;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=h;switch(u.name.toUpperCase()){case p.RsaSSA.toUpperCase():f=B;break;case p.RsaPSS.toUpperCase():f=D;break;case p.RsaOAEP.toUpperCase():f=H;break;case p.AesECB.toUpperCase():f=g;break;case p.AesCBC.toUpperCase():f=C;break;case p.AesCTR.toUpperCase():f=d;break;case p.AesGCM.toUpperCase():f=E;break;case p.AesKW.toUpperCase():f=P;break;case p.EcDSA.toUpperCase():f=L;break;case p.EcDH.toUpperCase():f=R;break;case p.Hmac.toUpperCase():f=K;break;case p.Pbkdf2.toUpperCase():f=O;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=h;switch(s.name.toUpperCase()){case p.RsaOAEP.toUpperCase():u=H;break;case p.AesECB.toUpperCase():u=g;break;case p.AesCBC.toUpperCase():u=C;break;case p.AesCTR.toUpperCase():u=d;break;case p.AesGCM.toUpperCase():u=E;break;case p.AesKW.toUpperCase():u=P;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,l){var y=a(n),m=a(i),A=o(r,"wrappedKey"),w=h;switch(y.name.toUpperCase()){case p.RsaOAEP.toUpperCase():w=H;break;case p.AesECB.toUpperCase():w=g;break;case p.AesCBC.toUpperCase():w=C;break;case p.AesCTR.toUpperCase():w=d;break;case p.AesGCM.toUpperCase():w=E;break;case p.AesKW.toUpperCase():w=P;break;default:throw new c(c.UNSUPPORTED_ALGORITHM,y.name)}w.unwrapKey(e,A,t,y,m,s,u).then(f,l)})},e}()}).call(r,t(13))},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}(a.WebCryptoError);o.MODULE_NOT_FOUND="Module '%1' is not found. Download it from %2",o.UNSUPPORTED_ALGORITHM="Unsupported algorithm '%1'",r.LinerError=o},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(12),a=t(4),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(){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]):/mobile/i.test(n)?(t.name=r.Browser.Mobile,t.version=/mobile\/([\w]+)/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}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},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(14);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(){}return e}();r.CryptoKey=n},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.

@@ -15,2 +15,2 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use

***************************************************************************** */
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,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(4)),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";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(5),s=t(3),c=t(4),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;return o.key=a,o.algorithm=e,o.extractable=r,o.type="secret",o.usages=t,o})},r.encrypt=function(e,r,t){return Promise.resolve().then(function(){var n;switch(e.name.toUpperCase()){case a.AlgorithmNames.AesECB:;n=asmCrypto.AES_ECB.encrypt(t,r.key,!0);break;case a.AlgorithmNames.AesCBC:var i=e;n=asmCrypto.AES_CBC.encrypt(t,r.key,void 0,a.PrepareData(i.iv,"iv"));break;case a.AlgorithmNames.AesGCM:var s=e;s.tagLength=s.tagLength||128;var c=void 0;s.additionalData&&(c=a.PrepareData(s.additionalData,"additionalData")),n=asmCrypto.AES_GCM.encrypt(t,r.key,s.iv,c,s.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:;n=asmCrypto.AES_ECB.decrypt(t,r.key,!0);break;case a.AlgorithmNames.AesCBC:var i=e;n=asmCrypto.AES_CBC.decrypt(t,r.key,void 0,a.PrepareData(i.iv,"iv"));break;case a.AlgorithmNames.AesGCM:var s=e;s.tagLength=s.tagLength||128;var c=void 0;s.additionalData&&(c=a.PrepareData(s.additionalData,"additionalData")),n=asmCrypto.AES_GCM.decrypt(t,r.key,s.iv,c,s.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 h.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 h.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 n;if("jwk"===e.toLowerCase()){var s=r;n=a.Base64Url.decode(s.k)}else n=new Uint8Array(r);var c=new i.CryptoKey;return c.algorithm=t,c.type="secret",c.usages=o,c.key=n,c})},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 h=t(2)},function(e,r,t){"use strict";function n(e){for(var r=new Uint8Array(e),t=[],n=0;n<r.length;n++)t.push(r[n]);return t}function a(e,r){e.length%2&&(e="0"+e);for(var t=new Uint8Array(e.length/2),n=0;n<e.length;n++){var a=e.slice(n,++n+1);t[(n-1)/2]=parseInt(a,16)}if(r){var o=t.length;o=o>32?o>48?66:48:32,t.length<o&&(t=h.concat(new Uint8Array(o-t.length),t))}return t}function o(e,r){for(var t="",n=0;n<e.length;n++){var a=e[n].toString(16);t+=a.length%2?"0"+a:a}if(r){var o=e.length;o=o>32?o>48?66:48:32,t.length/2<o&&(t=new Array(2*o-t.length+1).join("0")+t)}return t}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(5),h=t(3),p=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return i(r,e),r.generateKey=function(e,r,t){var n=this;return Promise.resolve().then(function(){n.checkModule();var t=e,a=new elliptic.ec(t.namedCurve.replace("-","").toLowerCase()),o=new u.CryptoKey,i=new u.CryptoKey;return o.key=i.key=a.genKeyPair(),o.algorithm=i.algorithm=t,o.extractable=r,i.extractable=!0,o.type="private",i.type="public",e.name===s.AlgorithmNames.EcDSA?(o.usages=["sign"],i.usages=["verify"]):e.name===s.AlgorithmNames.EcDH&&(o.usages=["deriveKey","deriveBits"],i.usages=[]),{privateKey:o,publicKey:i}})},r.sign=function(e,r,t){return Promise.resolve().then(function(){var r=e;return(new f.Crypto).subtle.digest(r.hash,t)}).then(function(e){var t=n(e),i=r.key.sign(t);return a(o(i.r.toArray(),!0)+o(i.s.toArray(),!0)).buffer})},r.verify=function(e,r,t,a){var o;return Promise.resolve().then(function(){var r=e;return o={r:t.slice(0,t.byteLength/2),s:t.slice(t.byteLength/2)},(new f.Crypto).subtle.digest(r.hash,a)}).then(function(e){var t=n(e);return r.key.verify(t,o)})},r.deriveKey=function(e,r,t,n,a){var o=this;return Promise.resolve().then(function(){return o.deriveBits(e,r,t.length)}).then(function(e){return(new f.Crypto).subtle.importKey("raw",new Uint8Array(e),t,n,a)})},r.deriveBits=function(e,r,t){return Promise.resolve().then(function(){var n=(Promise.resolve(null),r.key.derive(e.public.key.getPublic())),a=new Uint8Array(n.toArray()),o=a.length;return o=o>32?o>48?66:48:32,a.length<o&&(a=h.concat(new Uint8Array(o-a.length),a)),a.slice(0,t/8).buffer})},r.exportKey=function(e,r){return Promise.resolve().then(function(){var t=r.key;if("jwk"===e.toLowerCase()){var n=t.getPublic("hex").slice(2),o=n.slice(0,n.length/2),i=n.slice(n.length/2,n.length);if("public"===r.type){var u={crv:r.algorithm.namedCurve,ext:r.extractable,x:s.Base64Url.encode(a(o,!0)),y:s.Base64Url.encode(a(i,!0)),key_ops:r.usages,kty:"EC"};return u}var u={crv:r.algorithm.namedCurve,ext:r.extractable,d:s.Base64Url.encode(a(t.getPrivate("hex"),!0)),x:s.Base64Url.encode(a(o,!0)),y:s.Base64Url.encode(a(i,!0)),key_ops:r.usages,kty:"EC"};return u}throw new c.LinerError("Format '"+e+"' is not implemented")})},r.importKey=function(e,r,t,n,a){return Promise.resolve().then(function(){var i=new u.CryptoKey;if(i.algorithm=t,"jwk"!==e.toLowerCase())throw new c.LinerError("Format '"+e+"' is not implemented");var p=new elliptic.ec(r.crv.replace("-","").toLowerCase());if(r.d)i.key=p.keyFromPrivate(s.Base64Url.decode(r.d)),i.type="private";else{var f=h.concat(new Uint8Array([4]),s.Base64Url.decode(r.x),s.Base64Url.decode(r.y)),l=o(f);i.key=p.keyFromPublic(l,"hex"),i.type="public"}return i.extractable=n,i.usages=a,i})},r.checkModule=function(){if("undefined"==typeof elliptic)throw new c.LinerError(c.LinerError.MODULE_NOT_FOUND,"elliptic","https://github.com/indutny/elliptic")},r}(s.BaseCrypto);r.EcCrypto=p;var f=t(2)},function(e,r,t){"use strict";function n(e){var r=!0;return e.filter(function(e){return(!r||0!==e)&&(r=!1,!0)})}var a=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 o=t(0),i=t(1),s=t(3),c=t(5),u=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return a(r,e),r.generateKey=function(e,r,t){var n=this;return Promise.resolve().then(function(){n.checkModule();var a=3===e.publicExponent[0]?3:65537,s=asmCrypto.RSA.generateKey(e.modulusLength,a),u=new c.CryptoKey,h=new c.CryptoKey;switch(u.key=h.key=s,u.algorithm=h.algorithm=e,u.extractable=r,h.extractable=!0,u.type="private",h.type="public",e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():u.usages=n.filterUsages(["decrypt","unwrapKey"],t),h.usages=n.filterUsages(["encrypt","wrapKey"],t);break;case o.AlgorithmNames.RsaSSA.toLowerCase():case o.AlgorithmNames.RsaPSS.toLowerCase():u.usages=n.filterUsages(["sign"],t),h.usages=n.filterUsages(["verify"],t);break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}return{privateKey:u,publicKey:h}})},r.sign=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaSSA.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_PKCS1_v1_5_SHA1.sign;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_PKCS1_v1_5_SHA256.sign;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_PKCS1_v1_5_SHA512.sign;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}return s(t,r.key).buffer;case o.AlgorithmNames.RsaPSS.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_PSS_SHA1.sign;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_PSS_SHA256.sign;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_PSS_SHA512.sign;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}return s(t,r.key,a.saltLength).buffer;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.verify=function(e,r,t,n){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaSSA.toLowerCase():var a,s=r.algorithm;switch(s.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:a=asmCrypto.RSA_PKCS1_v1_5_SHA1.verify;break;case o.AlgorithmNames.Sha256:a=asmCrypto.RSA_PKCS1_v1_5_SHA256.verify;break;case o.AlgorithmNames.Sha512:a=asmCrypto.RSA_PKCS1_v1_5_SHA512.verify;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}try{return a(t,n,r.key)}catch(e){return console.warn("Verify error: "+e.message),!1}case o.AlgorithmNames.RsaPSS.toLowerCase():var c=r.algorithm,u=e,h=void 0;switch(c.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:h=asmCrypto.RSA_PSS_SHA1.verify;break;case o.AlgorithmNames.Sha256:h=asmCrypto.RSA_PSS_SHA256.verify;break;case o.AlgorithmNames.Sha512:h=asmCrypto.RSA_PSS_SHA512.verify;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}try{return h(t,n,r.key,u.saltLength)}catch(e){return console.warn("Verify error: "+e.message),!1}default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.encrypt=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_OAEP_SHA1.encrypt;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_OAEP_SHA256.encrypt;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_OAEP_SHA512.encrypt;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,n.name+" "+n.hash.name)}var c=void 0;return a.label&&(c=o.PrepareData(a.label,"label")),s(t,r.key,c);default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.decrypt=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_OAEP_SHA1.decrypt;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_OAEP_SHA256.decrypt;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_OAEP_SHA512.decrypt;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,n.name+" "+n.hash.name)}var c=void 0;return a.label&&(c=o.PrepareData(a.label,"label")),s(t,r.key,c);default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.wrapKey=function(e,r,t,n){var a;return Promise.resolve().then(function(){return a=new h.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 h.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){var r=e.hash,t=/(\d+)/.exec(r.name)[1];switch(e.name.toUpperCase()){case o.AlgorithmNames.RsaOAEP.toUpperCase():return"RSA-OAEP"+("1"===t?"":"-"+t);case o.AlgorithmNames.RsaPSS.toUpperCase():return"PS"+t;case o.AlgorithmNames.RsaSSA.toUpperCase():return"RS"+t;default:throw new o.AlgorithmError(o.AlgorithmError.UNSUPPORTED_ALGORITHM,e.name)}},r.jwk2alg=function(e){throw new Error("Not implemented")},r.exportKey=function(e,r){var t=this;return Promise.resolve().then(function(){if("jwk"===e.toLowerCase()){var a={kty:"RSA",ext:!0,key_ops:r.usages};return a.alg=t.alg2jwk(r.algorithm),a.n=o.Base64Url.encode(n(r.key[0])),a.e=o.Base64Url.encode(n(r.key[1])),"private"===r.type&&(a.d=o.Base64Url.encode(n(r.key[2])),a.p=o.Base64Url.encode(n(r.key[3])),a.q=o.Base64Url.encode(n(r.key[4])),a.dp=o.Base64Url.encode(n(r.key[5])),a.dq=o.Base64Url.encode(n(r.key[6])),a.qi=o.Base64Url.encode(n(r.key[7]))),a}throw new i.LinerError(i.LinerError.NOT_SUPPORTED)})},r.importKey=function(e,r,t,n,a){return Promise.resolve().then(function(){var n,s=new c.CryptoKey;if(s.algorithm=t,s.usages=a,s.key=[],"jwk"===e.toLowerCase())return n=r,s.key[0]=o.Base64Url.decode(n.n),s.key[1]=3===o.Base64Url.decode(n.e)[0]?new Uint8Array([0,0,0,3]):new Uint8Array([0,1,0,1]),n.d?(s.type="private",s.key[2]=o.Base64Url.decode(n.d),s.key[3]=o.Base64Url.decode(n.p),s.key[4]=o.Base64Url.decode(n.q),s.key[5]=o.Base64Url.decode(n.dp),s.key[6]=o.Base64Url.decode(n.dq),s.key[7]=o.Base64Url.decode(n.qi)):s.type="public",s;throw new i.LinerError(i.LinerError.NOT_SUPPORTED)})},r.checkModule=function(){if("undefined"==typeof asmCrypto)throw new i.LinerError(i.LinerError.MODULE_NOT_FOUND,"asmCrypto","https://github.com/vibornoff/asmcrypto.js")},r.filterUsages=function(e,r){return e.filter(function(e){return!!r.filter(function(r){return e===r}).length})},r}(o.BaseCrypto);r.RsaCrypto=u;var h=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";function n(e,r){return Promise.resolve().then(function(){if(e.key)return e;if(e.extractable){return(new y.Crypto).subtle.exportKey("jwk",e).then(function(t){var n=o(e);return n&&(n=A.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){A.BrowserInfo().name!==A.Browser.IE&&A.BrowserInfo().name!==A.Browser.Edge&&A.BrowserInfo().name!==A.Browser.Safari||!/^rsa/i.test(e.name)||(r.privateKey?(d.push({hash:e.hash,key:r.privateKey}),d.push({hash:e.hash,key:r.publicKey})):d.push({hash:e.hash,key:r}))}function o(e){var r=null;return d.some(function(t){return t.key===e&&(r=A.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&&A.BrowserInfo().name===A.Browser.IE){"extractable"in e&&(e.ext=e.extractable,delete e.extractable);var n=null;switch(r.name.toUpperCase()){case h.AlgorithmNames.RsaOAEP.toUpperCase():case h.AlgorithmNames.RsaPSS.toUpperCase():case h.AlgorithmNames.RsaSSA.toUpperCase():n=g.RsaCrypto;break;case h.AlgorithmNames.AesECB.toUpperCase():case h.AlgorithmNames.AesCBC.toUpperCase():case h.AlgorithmNames.AesGCM.toUpperCase():n=w.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){A.BrowserInfo().name===A.Browser.IE&&("ext"in e&&(e.extractable=e.ext,delete e.ext),delete e.key_ops,delete e.alg)}var u=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),p=t(0),f=t(0),l=t(4),y=t(2),m=t(1),A=t(3),w=t(9),v=t(12),g=t(11),C=t(10),d=[],E=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),r.prototype.generateKey=function(r,t,n){var o,s=arguments;return e.prototype.generateKey.apply(this,s).then(function(e){if(o=f.PrepareAlgorithm(r),(A.BrowserInfo().name!==A.Browser.Edge||o.name.toUpperCase()!==h.AlgorithmNames.AesGCM)&&l.nativeSubtle)try{return l.nativeSubtle.generateKey.apply(l.nativeSubtle,s).catch(function(e){console.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return i(e,n),a(o,e),e;var r;switch(o.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():r=w.AesCrypto;break;case h.AlgorithmNames.EcDSA.toLowerCase():case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaSSA.toLowerCase():r=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,o.name.toLowerCase())}return r.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=f.PrepareAlgorithm(r),a=f.PrepareData(t,"data"),l.nativeSubtle)try{return l.nativeSubtle.digest.apply(l.nativeSubtle,o).catch(function(e){console.warn("WebCrypto: native digest for "+n.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native digest for "+n.name+" doesn't work.",e.message||"")}}).then(function(e){return e||v.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=f.PrepareAlgorithm(r),s=f.PrepareData(a,"data");var n=o(t);if(n&&(c[0]=A.assign(i,n)),l.nativeSubtle)try{return l.nativeSubtle.sign.apply(l.nativeSubtle,c).catch(function(e){console.warn("WebCrypto: native sign for "+i.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native sign for "+i.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return e;var r;switch(i.name.toLowerCase()){case h.AlgorithmNames.EcDSA.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():r=g.RsaCrypto;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,a,i){var s,c,u,p=arguments;return e.prototype.verify.apply(this,p).then(function(e){s=f.PrepareAlgorithm(r),c=f.PrepareData(a,"data"),u=f.PrepareData(i,"data");var n=o(t);if(n&&(p[0]=A.assign(s,n)),l.nativeSubtle)try{return l.nativeSubtle.verify.apply(l.nativeSubtle,p).catch(function(e){console.warn("WebCrypto: native verify for "+s.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native verify for "+s.name+" doesn't work.",e.message||"")}}).then(function(e){if("boolean"==typeof e)return e;var r;switch(s.name.toLowerCase()){case h.AlgorithmNames.EcDSA.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():r=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,s.name.toLowerCase())}return n(t,r).then(function(e){return r.verify(s,e,c,u)})})},r.prototype.deriveBits=function(r,t,n){var a,o=arguments;return e.prototype.deriveBits.apply(this,o).then(function(e){if(a=f.PrepareAlgorithm(r),l.nativeSubtle)try{return l.nativeSubtle.deriveBits.apply(l.nativeSubtle,o).catch(function(e){console.warn("WebCrypto: native deriveBits for "+a.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native deriveBits for "+a.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return e;var r;switch(a.name.toLowerCase()){case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;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=f.PrepareAlgorithm(r),c=f.PrepareAlgorithm(n),l.nativeSubtle)try{return l.nativeSubtle.deriveKey.apply(l.nativeSubtle,u).catch(function(e){console.warn("WebCrypto: native deriveKey for "+s.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native deriveKey for "+s.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return i(e,o),e;var r;switch(s.name.toLowerCase()){case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"deriveBits")}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=f.PrepareAlgorithm(r),i=f.PrepareData(a,"data"),l.nativeSubtle)try{return l.nativeSubtle.encrypt.apply(l.nativeSubtle,s).catch(function(e){console.warn("WebCrypto: native 'encrypt' for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'encrypt' for "+o.name+" doesn't work.",e.message||"")}}).then(function(e){if(e){if(A.BrowserInfo().name===A.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():s=g.RsaCrypto;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=f.PrepareAlgorithm(r),o=f.PrepareData(n,"data");var i=o;if(A.BrowserInfo().name===A.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():c=g.RsaCrypto;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=f.PrepareAlgorithm(a),l.nativeSubtle)try{return l.nativeSubtle.wrapKey.apply(l.nativeSubtle,i).catch(function(e){console.warn("WebCrypto: native 'wrapKey' for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'wrapKey' for "+o.name+" doesn't work.",e.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():a=g.RsaCrypto;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,y,v=this,C=arguments;return e.prototype.unwrapKey.apply(this,C).then(function(e){if(u=f.PrepareAlgorithm(a),p=f.PrepareAlgorithm(o),y=f.PrepareData(t,"wrappedKey"),n.key){var d=void 0;switch(u.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():d=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():d=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"unwrapKey")}return d.unwrapKey(r,y,n,u,p,s,c)}return l.nativeSubtle.unwrapKey.apply(l.nativeSubtle,C).catch(function(e){return v.decrypt(u,n,t).then(function(e){var t;return t="jwk"===r?JSON.parse(A.buffer2string(new Uint8Array(e))):e,v.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){console.warn("WebCrypto: native 'exportKey' for "+t.algorithm.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'exportKey' for "+t.algorithm.name+" doesn't work.",e.message||"")}}).then(function(e){if(e){"jwk"===r&&e instanceof ArrayBuffer&&(e=A.buffer2string(new Uint8Array(e)),e=JSON.parse(e));var n=o(t);return n||(n=A.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=w.AesCrypto;break;case h.AlgorithmNames.EcDH.toLowerCase():case h.AlgorithmNames.EcDSA.toLowerCase():a=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaOAEP.toLowerCase():a=g.RsaCrypto;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 u,p,y=arguments;return e.prototype.importKey.apply(this,y).then(function(e){if(u=f.PrepareAlgorithm(n),p=t,A.BrowserInfo().name!==A.Browser.Safari&&A.BrowserInfo().name!==A.Browser.IE||(A.BrowserInfo().name===A.Browser.IE&&(t=A.assign({},t),c(t)),y[1]=A.string2buffer(JSON.stringify(t)).buffer),ArrayBuffer.isView(t)&&(p=f.PrepareData(t,"keyData")),l.nativeSubtle)try{return l.nativeSubtle.importKey.apply(l.nativeSubtle,y).catch(function(e){console.warn("WebCrypto: native 'importKey' for "+u.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'importKey' for "+u.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return a(u,e),i(e,s),Promise.resolve(e);var t;switch(u.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():t=w.AesCrypto;break;case h.AlgorithmNames.EcDH.toLowerCase():case h.AlgorithmNames.EcDSA.toLowerCase():t=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaOAEP.toLowerCase():t=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,u.name.toLowerCase())}return t.importKey(r,p,u,o,s)})},r}(p.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){e.exports=require("crypto")},,function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(7),a=self;Object.freeze(Math),Object.freeze(Math.random),Object.freeze(Math.imul),n.nativeCrypto&&Object.freeze(n.nativeCrypto.getRandomValues),delete self.crypto,a.crypto=new n.Crypto,Object.freeze(a.crypto),r.crypto=a.crypto}]);
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,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(4)),n(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=t(5),s=t(3),c=t(4),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;return o.key=a,o.algorithm=e,o.extractable=r,o.type="secret",o.usages=t,o})},r.encrypt=function(e,r,t){return Promise.resolve().then(function(){var n;switch(e.name.toUpperCase()){case a.AlgorithmNames.AesECB:;n=asmCrypto.AES_ECB.encrypt(t,r.key,!0);break;case a.AlgorithmNames.AesCBC:var i=e;n=asmCrypto.AES_CBC.encrypt(t,r.key,void 0,a.PrepareData(i.iv,"iv"));break;case a.AlgorithmNames.AesGCM:var s=e;s.tagLength=s.tagLength||128;var c=void 0;s.additionalData&&(c=a.PrepareData(s.additionalData,"additionalData")),n=asmCrypto.AES_GCM.encrypt(t,r.key,s.iv,c,s.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:;n=asmCrypto.AES_ECB.decrypt(t,r.key,!0);break;case a.AlgorithmNames.AesCBC:var i=e;n=asmCrypto.AES_CBC.decrypt(t,r.key,void 0,a.PrepareData(i.iv,"iv"));break;case a.AlgorithmNames.AesGCM:var s=e;s.tagLength=s.tagLength||128;var c=void 0;s.additionalData&&(c=a.PrepareData(s.additionalData,"additionalData")),n=asmCrypto.AES_GCM.decrypt(t,r.key,s.iv,c,s.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 h.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 h.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 n;if("jwk"===e.toLowerCase()){var s=r;n=a.Base64Url.decode(s.k)}else n=new Uint8Array(r);var c=new i.CryptoKey;return c.algorithm=t,c.type="secret",c.usages=o,c.key=n,c})},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 h=t(2)},function(e,r,t){"use strict";function n(e){for(var r=new Uint8Array(e),t=[],n=0;n<r.length;n++)t.push(r[n]);return t}function a(e,r){e.length%2&&(e="0"+e);for(var t=new Uint8Array(e.length/2),n=0;n<e.length;n++){var a=e.slice(n,++n+1);t[(n-1)/2]=parseInt(a,16)}if(r){var o=t.length;o=o>32?o>48?66:48:32,t.length<o&&(t=h.concat(new Uint8Array(o-t.length),t))}return t}function o(e,r){for(var t="",n=0;n<e.length;n++){var a=e[n].toString(16);t+=a.length%2?"0"+a:a}if(r){var o=e.length;o=o>32?o>48?66:48:32,t.length/2<o&&(t=new Array(2*o-t.length+1).join("0")+t)}return t}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(5),h=t(3),p=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return i(r,e),r.generateKey=function(e,r,t){var n=this;return Promise.resolve().then(function(){n.checkModule();var t=e,a=new elliptic.ec(t.namedCurve.replace("-","").toLowerCase()),o=new u.CryptoKey,i=new u.CryptoKey;return o.key=i.key=a.genKeyPair(),o.algorithm=i.algorithm=t,o.extractable=r,i.extractable=!0,o.type="private",i.type="public",e.name===s.AlgorithmNames.EcDSA?(o.usages=["sign"],i.usages=["verify"]):e.name===s.AlgorithmNames.EcDH&&(o.usages=["deriveKey","deriveBits"],i.usages=[]),{privateKey:o,publicKey:i}})},r.sign=function(e,r,t){return Promise.resolve().then(function(){var r=e;return(new f.Crypto).subtle.digest(r.hash,t)}).then(function(e){var t=n(e),i=r.key.sign(t);return a(o(i.r.toArray(),!0)+o(i.s.toArray(),!0)).buffer})},r.verify=function(e,r,t,a){var o;return Promise.resolve().then(function(){var r=e;return o={r:t.slice(0,t.byteLength/2),s:t.slice(t.byteLength/2)},(new f.Crypto).subtle.digest(r.hash,a)}).then(function(e){var t=n(e);return r.key.verify(t,o)})},r.deriveKey=function(e,r,t,n,a){var o=this;return Promise.resolve().then(function(){return o.deriveBits(e,r,t.length)}).then(function(e){return(new f.Crypto).subtle.importKey("raw",new Uint8Array(e),t,n,a)})},r.deriveBits=function(e,r,t){return Promise.resolve().then(function(){var n=(Promise.resolve(null),r.key.derive(e.public.key.getPublic())),a=new Uint8Array(n.toArray()),o=a.length;return o=o>32?o>48?66:48:32,a.length<o&&(a=h.concat(new Uint8Array(o-a.length),a)),a.slice(0,t/8).buffer})},r.exportKey=function(e,r){return Promise.resolve().then(function(){var t=r.key;if("jwk"===e.toLowerCase()){var n=t.getPublic("hex").slice(2),o=n.slice(0,n.length/2),i=n.slice(n.length/2,n.length);if("public"===r.type){var u={crv:r.algorithm.namedCurve,ext:r.extractable,x:s.Base64Url.encode(a(o,!0)),y:s.Base64Url.encode(a(i,!0)),key_ops:r.usages,kty:"EC"};return u}var u={crv:r.algorithm.namedCurve,ext:r.extractable,d:s.Base64Url.encode(a(t.getPrivate("hex"),!0)),x:s.Base64Url.encode(a(o,!0)),y:s.Base64Url.encode(a(i,!0)),key_ops:r.usages,kty:"EC"};return u}throw new c.LinerError("Format '"+e+"' is not implemented")})},r.importKey=function(e,r,t,n,a){return Promise.resolve().then(function(){var i=new u.CryptoKey;if(i.algorithm=t,"jwk"!==e.toLowerCase())throw new c.LinerError("Format '"+e+"' is not implemented");var p=new elliptic.ec(r.crv.replace("-","").toLowerCase());if(r.d)i.key=p.keyFromPrivate(s.Base64Url.decode(r.d)),i.type="private";else{var f=h.concat(new Uint8Array([4]),s.Base64Url.decode(r.x),s.Base64Url.decode(r.y)),l=o(f);i.key=p.keyFromPublic(l,"hex"),i.type="public"}return i.extractable=n,i.usages=a,i})},r.checkModule=function(){if("undefined"==typeof elliptic)throw new c.LinerError(c.LinerError.MODULE_NOT_FOUND,"elliptic","https://github.com/indutny/elliptic")},r}(s.BaseCrypto);r.EcCrypto=p;var f=t(2)},function(e,r,t){"use strict";function n(e){var r=!0;return e.filter(function(e){return(!r||0!==e)&&(r=!1,!0)})}var a=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 o=t(0),i=t(1),s=t(3),c=t(5),u=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return a(r,e),r.generateKey=function(e,r,t){var n=this;return Promise.resolve().then(function(){n.checkModule();var a=3===e.publicExponent[0]?3:65537,s=asmCrypto.RSA.generateKey(e.modulusLength,a),u=new c.CryptoKey,h=new c.CryptoKey;switch(u.key=h.key=s,u.algorithm=h.algorithm=e,u.extractable=r,h.extractable=!0,u.type="private",h.type="public",e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():u.usages=n.filterUsages(["decrypt","unwrapKey"],t),h.usages=n.filterUsages(["encrypt","wrapKey"],t);break;case o.AlgorithmNames.RsaSSA.toLowerCase():case o.AlgorithmNames.RsaPSS.toLowerCase():u.usages=n.filterUsages(["sign"],t),h.usages=n.filterUsages(["verify"],t);break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}return{privateKey:u,publicKey:h}})},r.sign=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaSSA.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_PKCS1_v1_5_SHA1.sign;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_PKCS1_v1_5_SHA256.sign;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_PKCS1_v1_5_SHA512.sign;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}return s(t,r.key).buffer;case o.AlgorithmNames.RsaPSS.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_PSS_SHA1.sign;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_PSS_SHA256.sign;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_PSS_SHA512.sign;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}return s(t,r.key,a.saltLength).buffer;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.verify=function(e,r,t,n){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaSSA.toLowerCase():var a,s=r.algorithm;switch(s.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:a=asmCrypto.RSA_PKCS1_v1_5_SHA1.verify;break;case o.AlgorithmNames.Sha256:a=asmCrypto.RSA_PKCS1_v1_5_SHA256.verify;break;case o.AlgorithmNames.Sha512:a=asmCrypto.RSA_PKCS1_v1_5_SHA512.verify;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}try{return a(t,n,r.key)}catch(e){return console.warn("Verify error: "+e.message),!1}case o.AlgorithmNames.RsaPSS.toLowerCase():var c=r.algorithm,u=e,h=void 0;switch(c.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:h=asmCrypto.RSA_PSS_SHA1.verify;break;case o.AlgorithmNames.Sha256:h=asmCrypto.RSA_PSS_SHA256.verify;break;case o.AlgorithmNames.Sha512:h=asmCrypto.RSA_PSS_SHA512.verify;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,r.algorithm.name)}try{return h(t,n,r.key,u.saltLength)}catch(e){return console.warn("Verify error: "+e.message),!1}default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.encrypt=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_OAEP_SHA1.encrypt;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_OAEP_SHA256.encrypt;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_OAEP_SHA512.encrypt;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,n.name+" "+n.hash.name)}var c=void 0;return a.label&&(c=o.PrepareData(a.label,"label")),s(t,r.key,c);default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.decrypt=function(e,r,t){return Promise.resolve().then(function(){switch(e.name.toLowerCase()){case o.AlgorithmNames.RsaOAEP.toLowerCase():var n=r.algorithm,a=e,s=void 0;switch(n.hash.name.toUpperCase()){case o.AlgorithmNames.Sha1:s=asmCrypto.RSA_OAEP_SHA1.decrypt;break;case o.AlgorithmNames.Sha256:s=asmCrypto.RSA_OAEP_SHA256.decrypt;break;case o.AlgorithmNames.Sha512:s=asmCrypto.RSA_OAEP_SHA512.decrypt;break;default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,n.name+" "+n.hash.name)}var c=void 0;return a.label&&(c=o.PrepareData(a.label,"label")),s(t,r.key,c);default:throw new i.LinerError(i.LinerError.UNSUPPORTED_ALGORITHM,e.name)}})},r.wrapKey=function(e,r,t,n){var a;return Promise.resolve().then(function(){return a=new h.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 h.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){var r=e.hash,t=/(\d+)/.exec(r.name)[1];switch(e.name.toUpperCase()){case o.AlgorithmNames.RsaOAEP.toUpperCase():return"RSA-OAEP"+("1"===t?"":"-"+t);case o.AlgorithmNames.RsaPSS.toUpperCase():return"PS"+t;case o.AlgorithmNames.RsaSSA.toUpperCase():return"RS"+t;default:throw new o.AlgorithmError(o.AlgorithmError.UNSUPPORTED_ALGORITHM,e.name)}},r.jwk2alg=function(e){throw new Error("Not implemented")},r.exportKey=function(e,r){var t=this;return Promise.resolve().then(function(){if("jwk"===e.toLowerCase()){var a={kty:"RSA",ext:!0,key_ops:r.usages};return a.alg=t.alg2jwk(r.algorithm),a.n=o.Base64Url.encode(n(r.key[0])),a.e=o.Base64Url.encode(n(r.key[1])),"private"===r.type&&(a.d=o.Base64Url.encode(n(r.key[2])),a.p=o.Base64Url.encode(n(r.key[3])),a.q=o.Base64Url.encode(n(r.key[4])),a.dp=o.Base64Url.encode(n(r.key[5])),a.dq=o.Base64Url.encode(n(r.key[6])),a.qi=o.Base64Url.encode(n(r.key[7]))),a}throw new i.LinerError(i.LinerError.NOT_SUPPORTED)})},r.importKey=function(e,r,t,n,a){return Promise.resolve().then(function(){var n,s=new c.CryptoKey;if(s.algorithm=t,s.usages=a,s.key=[],"jwk"===e.toLowerCase())return n=r,s.key[0]=o.Base64Url.decode(n.n),s.key[1]=3===o.Base64Url.decode(n.e)[0]?new Uint8Array([0,0,0,3]):new Uint8Array([0,1,0,1]),n.d?(s.type="private",s.key[2]=o.Base64Url.decode(n.d),s.key[3]=o.Base64Url.decode(n.p),s.key[4]=o.Base64Url.decode(n.q),s.key[5]=o.Base64Url.decode(n.dp),s.key[6]=o.Base64Url.decode(n.dq),s.key[7]=o.Base64Url.decode(n.qi)):s.type="public",s;throw new i.LinerError(i.LinerError.NOT_SUPPORTED)})},r.checkModule=function(){if("undefined"==typeof asmCrypto)throw new i.LinerError(i.LinerError.MODULE_NOT_FOUND,"asmCrypto","https://github.com/vibornoff/asmcrypto.js")},r.filterUsages=function(e,r){return e.filter(function(e){return!!r.filter(function(r){return e===r}).length})},r}(o.BaseCrypto);r.RsaCrypto=u;var h=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";function n(e,r){return Promise.resolve().then(function(){if(e.key)return e;if(e.extractable){return(new y.Crypto).subtle.exportKey("jwk",e).then(function(t){var n=o(e);return n&&(n=A.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){A.BrowserInfo().name!==A.Browser.IE&&A.BrowserInfo().name!==A.Browser.Edge&&A.BrowserInfo().name!==A.Browser.Safari||!/^rsa/i.test(e.name)||(r.privateKey?(d.push({hash:e.hash,key:r.privateKey}),d.push({hash:e.hash,key:r.publicKey})):d.push({hash:e.hash,key:r}))}function o(e){var r=null;return d.some(function(t){return t.key===e&&(r=A.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&&A.BrowserInfo().name===A.Browser.IE){"extractable"in e&&(e.ext=e.extractable,delete e.extractable);var n=null;switch(r.name.toUpperCase()){case h.AlgorithmNames.RsaOAEP.toUpperCase():case h.AlgorithmNames.RsaPSS.toUpperCase():case h.AlgorithmNames.RsaSSA.toUpperCase():n=g.RsaCrypto;break;case h.AlgorithmNames.AesECB.toUpperCase():case h.AlgorithmNames.AesCBC.toUpperCase():case h.AlgorithmNames.AesGCM.toUpperCase():n=w.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){A.BrowserInfo().name===A.Browser.IE&&("ext"in e&&(e.extractable=e.ext,delete e.ext),delete e.key_ops,delete e.alg)}var u=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),p=t(0),f=t(0),l=t(4),y=t(2),m=t(1),A=t(3),w=t(8),v=t(11),g=t(10),C=t(9),d=[],E=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),r.prototype.generateKey=function(r,t,n){var o,s=arguments;return e.prototype.generateKey.apply(this,s).then(function(e){if(o=f.PrepareAlgorithm(r),(A.BrowserInfo().name!==A.Browser.Edge||o.name.toUpperCase()!==h.AlgorithmNames.AesGCM)&&l.nativeSubtle)try{return l.nativeSubtle.generateKey.apply(l.nativeSubtle,s).catch(function(e){console.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return i(e,n),a(o,e),e;var r;switch(o.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():r=w.AesCrypto;break;case h.AlgorithmNames.EcDSA.toLowerCase():case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaSSA.toLowerCase():r=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,o.name.toLowerCase())}return r.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=f.PrepareAlgorithm(r),a=f.PrepareData(t,"data"),l.nativeSubtle)try{return l.nativeSubtle.digest.apply(l.nativeSubtle,o).catch(function(e){console.warn("WebCrypto: native digest for "+n.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native digest for "+n.name+" doesn't work.",e.message||"")}}).then(function(e){return e||v.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=f.PrepareAlgorithm(r),s=f.PrepareData(a,"data");var n=o(t);if(n&&(c[0]=A.assign(i,n)),l.nativeSubtle)try{return l.nativeSubtle.sign.apply(l.nativeSubtle,c).catch(function(e){console.warn("WebCrypto: native sign for "+i.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native sign for "+i.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return e;var r;switch(i.name.toLowerCase()){case h.AlgorithmNames.EcDSA.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():r=g.RsaCrypto;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,a,i){var s,c,u,p=arguments;return e.prototype.verify.apply(this,p).then(function(e){s=f.PrepareAlgorithm(r),c=f.PrepareData(a,"data"),u=f.PrepareData(i,"data");var n=o(t);if(n&&(p[0]=A.assign(s,n)),l.nativeSubtle)try{return l.nativeSubtle.verify.apply(l.nativeSubtle,p).catch(function(e){console.warn("WebCrypto: native verify for "+s.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native verify for "+s.name+" doesn't work.",e.message||"")}}).then(function(e){if("boolean"==typeof e)return e;var r;switch(s.name.toLowerCase()){case h.AlgorithmNames.EcDSA.toLowerCase():r=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():r=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,s.name.toLowerCase())}return n(t,r).then(function(e){return r.verify(s,e,c,u)})})},r.prototype.deriveBits=function(r,t,n){var a,o=arguments;return e.prototype.deriveBits.apply(this,o).then(function(e){if(a=f.PrepareAlgorithm(r),l.nativeSubtle)try{return l.nativeSubtle.deriveBits.apply(l.nativeSubtle,o).catch(function(e){console.warn("WebCrypto: native deriveBits for "+a.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native deriveBits for "+a.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return e;var r;switch(a.name.toLowerCase()){case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;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=f.PrepareAlgorithm(r),c=f.PrepareAlgorithm(n),l.nativeSubtle)try{return l.nativeSubtle.deriveKey.apply(l.nativeSubtle,u).catch(function(e){console.warn("WebCrypto: native deriveKey for "+s.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native deriveKey for "+s.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return i(e,o),e;var r;switch(s.name.toLowerCase()){case h.AlgorithmNames.EcDH.toLowerCase():r=C.EcCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"deriveBits")}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=f.PrepareAlgorithm(r),i=f.PrepareData(a,"data"),l.nativeSubtle)try{return l.nativeSubtle.encrypt.apply(l.nativeSubtle,s).catch(function(e){console.warn("WebCrypto: native 'encrypt' for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'encrypt' for "+o.name+" doesn't work.",e.message||"")}}).then(function(e){if(e){if(A.BrowserInfo().name===A.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():s=g.RsaCrypto;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=f.PrepareAlgorithm(r),o=f.PrepareData(n,"data");var i=o;if(A.BrowserInfo().name===A.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():c=g.RsaCrypto;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=f.PrepareAlgorithm(a),l.nativeSubtle)try{return l.nativeSubtle.wrapKey.apply(l.nativeSubtle,i).catch(function(e){console.warn("WebCrypto: native 'wrapKey' for "+o.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'wrapKey' for "+o.name+" doesn't work.",e.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=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():a=g.RsaCrypto;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,y,v=this,C=arguments;return e.prototype.unwrapKey.apply(this,C).then(function(e){if(u=f.PrepareAlgorithm(a),p=f.PrepareAlgorithm(o),y=f.PrepareData(t,"wrappedKey"),n.key){var d=void 0;switch(u.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():d=w.AesCrypto;break;case h.AlgorithmNames.RsaOAEP.toLowerCase():d=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.NOT_SUPPORTED,"unwrapKey")}return d.unwrapKey(r,y,n,u,p,s,c)}return l.nativeSubtle.unwrapKey.apply(l.nativeSubtle,C).catch(function(e){return v.decrypt(u,n,t).then(function(e){var t;return t="jwk"===r?JSON.parse(A.buffer2string(new Uint8Array(e))):e,v.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){console.warn("WebCrypto: native 'exportKey' for "+t.algorithm.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'exportKey' for "+t.algorithm.name+" doesn't work.",e.message||"")}}).then(function(e){if(e){"jwk"===r&&e instanceof ArrayBuffer&&(e=A.buffer2string(new Uint8Array(e)),e=JSON.parse(e));var n=o(t);return n||(n=A.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=w.AesCrypto;break;case h.AlgorithmNames.EcDH.toLowerCase():case h.AlgorithmNames.EcDSA.toLowerCase():a=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaOAEP.toLowerCase():a=g.RsaCrypto;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 u,p,y=arguments;return e.prototype.importKey.apply(this,y).then(function(e){if(u=f.PrepareAlgorithm(n),p=t,A.BrowserInfo().name!==A.Browser.Safari&&A.BrowserInfo().name!==A.Browser.IE||(A.BrowserInfo().name===A.Browser.IE&&(t=A.assign({},t),c(t)),y[1]=A.string2buffer(JSON.stringify(t)).buffer),ArrayBuffer.isView(t)&&(p=f.PrepareData(t,"keyData")),l.nativeSubtle)try{return l.nativeSubtle.importKey.apply(l.nativeSubtle,y).catch(function(e){console.warn("WebCrypto: native 'importKey' for "+u.name+" doesn't work.",e.message||"")})}catch(e){console.warn("WebCrypto: native 'importKey' for "+u.name+" doesn't work.",e.message||"")}}).then(function(e){if(e)return a(u,e),i(e,s),Promise.resolve(e);var t;switch(u.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerCase():case h.AlgorithmNames.AesCBC.toLowerCase():case h.AlgorithmNames.AesGCM.toLowerCase():t=w.AesCrypto;break;case h.AlgorithmNames.EcDH.toLowerCase():case h.AlgorithmNames.EcDSA.toLowerCase():t=C.EcCrypto;break;case h.AlgorithmNames.RsaSSA.toLowerCase():case h.AlgorithmNames.RsaPSS.toLowerCase():case h.AlgorithmNames.RsaOAEP.toLowerCase():t=g.RsaCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,u.name.toLowerCase())}return t.importKey(r,p,u,o,s)})},r}(p.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){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){e.exports=require("crypto")},,function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(7),a=self;Object.freeze(Math),Object.freeze(Math.random),Object.freeze(Math.imul),n.nativeCrypto&&Object.freeze(n.nativeCrypto.getRandomValues),delete self.crypto,a.crypto=new n.Crypto,Object.freeze(a.crypto),r.crypto=a.crypto}]);
{
"name": "webcrypto-liner",
"version": "0.1.23",
"version": "0.1.24",
"description": "A WebCrypto pollyfill that \"smooths out\" the rough-edges in existing User Agent implementations.",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -0,0 +0,0 @@ # webcrypto-liner

//**************************************************************************************
var Browser = {
const Browser = {
IE: "Internet Explorer",

@@ -8,2 +8,3 @@ Safari: "Safari",

Firefox: "Firefox Mozilla",
Mobile: "Mobile",
};

@@ -13,8 +14,8 @@ //**************************************************************************************

{
var res = {
name: "",
version: ""
const res = {
name: "Unknown",
version: "0"
};
var userAgent = self.navigator.userAgent;
const userAgent = self.navigator.userAgent;

@@ -35,2 +36,6 @@ switch(true)

break;
case (/mobile/i.test(userAgent)):
res.name = Browser.Mobile;
res.version = /mobile\/([\w]+)/i.exec(userAgent)[1];
break;
case (/chrome/i.test(userAgent)):

@@ -76,2 +81,3 @@ res.name = Browser.Chrome;

case Browser.Safari:
case Browser.Mobile:
importScripts(path + "asmcrypto.min.js");

@@ -78,0 +84,0 @@ importScripts(path + "elliptic.min.js");

@@ -8,2 +8,3 @@ //**************************************************************************************

Firefox: "Firefox Mozilla",
Mobile: "Mobile",
};

@@ -14,4 +15,4 @@ //**************************************************************************************

const res = {
name: "",
version: ""
name: "Unknown",
version: "0"
};

@@ -35,2 +36,6 @@

break;
case (/mobile/i.test(userAgent)):
res.name = Browser.Mobile;
res.version = /mobile\/([\w]+)/i.exec(userAgent)[1];
break;
case (/chrome/i.test(userAgent)):

@@ -91,2 +96,3 @@ res.name = Browser.Chrome;

case Browser.Safari:
case Browser.Mobile:
importScripts(path + "asmcrypto.min.js");

@@ -93,0 +99,0 @@ importScripts(path + "elliptic.min.js");

@@ -0,0 +0,0 @@ import { BaseCrypto, AlgorithmNames, AlgorithmError, Base64Url, PrepareData } from "webcrypto-core";

@@ -0,0 +0,0 @@ import { SubtleCrypto } from "./subtle";

@@ -0,0 +0,0 @@ import { BaseCrypto, AlgorithmNames, AlgorithmError, Base64Url } from "webcrypto-core";

@@ -0,0 +0,0 @@ import { WebCryptoError } from "webcrypto-core";

@@ -7,2 +7,3 @@ export let Browser = {

Firefox: "Firefox Mozilla",
Mobile: "Mobile",
};

@@ -15,4 +16,4 @@

const res = {
name: "",
version: "",
name: "Unknown",
version: "0",
};

@@ -32,2 +33,5 @@ const userAgent = self.navigator.userAgent;

res.version = /rv:([\d\.]+)/i.exec(userAgent) ![1];
} else if (/mobile/i.test(userAgent)) {
res.name = Browser.Mobile;
res.version = /mobile\/([\w]+)/i.exec(userAgent) ![1];
} else if (/chrome/i.test(userAgent)) {

@@ -34,0 +38,0 @@ res.name = Browser.Chrome;

export * from "./init";
export * from "./crypto";

@@ -0,0 +0,0 @@ import { LinerError } from "./error";

@@ -0,0 +0,0 @@ export interface CryptoKeyPair extends NativeCryptoKeyPair {

@@ -0,0 +0,0 @@ import { Crypto, nativeCrypto } from "./index";

@@ -0,0 +0,0 @@ import { AlgorithmError, AlgorithmNames, Base64Url, BaseCrypto, PrepareData } from "webcrypto-core";

@@ -0,0 +0,0 @@ import { BaseCrypto, AlgorithmNames, AlgorithmError, Base64Url } from "webcrypto-core";

@@ -0,0 +0,0 @@ import { Crypto, nativeCrypto } from "./index";

@@ -0,0 +0,0 @@ // Core

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ declare namespace EllipticJS {

@@ -0,0 +0,0 @@ interface AlgorithmConverter {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ /* This Source Code Form is subject to the terms of the Mozilla Public

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ // http://wiki.commonjs.org/wiki/Unit_Testing/1.0

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ "use strict"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc