webcrypto-liner
Advanced tools
Comparing version 0.1.24 to 0.1.25
@@ -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(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;/*! ***************************************************************************** | ||
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";Object.defineProperty(r,"__esModule",{value:!0}),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("undefined"!=typeof Buffer&&Buffer.isBuffer(e))return new Uint8Array(e);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")}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 i=t(6),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. | ||
@@ -3,0 +3,0 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use |
@@ -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(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;/*! ***************************************************************************** | ||
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";Object.defineProperty(r,"__esModule",{value:!0}),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("undefined"!=typeof Buffer&&Buffer.isBuffer(e))return new Uint8Array(e);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")}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 i=t(6),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. | ||
@@ -3,0 +3,0 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use |
{ | ||
"name": "webcrypto-liner", | ||
"version": "0.1.24", | ||
"version": "0.1.25", | ||
"description": "A WebCrypto pollyfill that \"smooths out\" the rough-edges in existing User Agent implementations.", | ||
@@ -21,11 +21,11 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@types/node": "*", | ||
"@types/node": "^7.0.32", | ||
"asmcrypto.js": "*", | ||
"elliptic": "*", | ||
"webcrypto-core": "^0.1.15" | ||
"typescript": "2.3.4", | ||
"webcrypto-core": "^0.1.16" | ||
}, | ||
"devDependencies": { | ||
"ts-loader": "^0.9.5", | ||
"typescript": "*", | ||
"webpack": "^2.4.1" | ||
"webpack": "^2.6.1" | ||
}, | ||
@@ -32,0 +32,0 @@ "author": "PeculiarVentures", |
@@ -201,3 +201,3 @@ import { BaseCrypto, AlgorithmNames, AlgorithmError, Base64Url } from "webcrypto-core"; | ||
const key: EcCryptoKey = new CryptoKey(); | ||
key.algorithm = algorithm; | ||
key.algorithm = algorithm as any; | ||
if (format.toLowerCase() === "jwk") { | ||
@@ -204,0 +204,0 @@ const ecKey = new elliptic.ec((keyData as JsonWebKey).crv!.replace("-", "").toLowerCase()); |
@@ -23,3 +23,3 @@ // Core | ||
function PrepareKey(key: CryptoKey, subtle: typeof BaseCrypto): PromiseLike<CryptoKey> { | ||
function PrepareKey(key: CryptoKey, subtle: typeof BaseCrypto) { | ||
return Promise.resolve() | ||
@@ -49,3 +49,3 @@ .then(() => { | ||
public generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: string[]): PromiseLike<NativeCryptoKey | NativeCryptoKeyPair> { | ||
public generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: string[]) { | ||
const args = arguments; | ||
@@ -485,3 +485,3 @@ let alg: Algorithm; | ||
public exportKey(format: string, key: CryptoKey): PromiseLike<JsonWebKey | ArrayBuffer> { | ||
public exportKey(format: string, key: CryptoKey) { | ||
const args = arguments; | ||
@@ -540,3 +540,3 @@ return super.exportKey.apply(this, args) | ||
public importKey(format: string, keyData: JsonWebKey | BufferSource, algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey> { | ||
public importKey(format: string, keyData: JsonWebKey | BufferSource, algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: string[]) { | ||
const args = arguments; | ||
@@ -543,0 +543,0 @@ let alg: Algorithm; |
@@ -34,4 +34,4 @@ /** | ||
class RSA_OAEP_SHA1 { | ||
static encrypt(data: BufferSource, key: RsaKey, label?: BufferSource): BufferSource; | ||
static decrypt(data: BufferSource, key: RsaKey, label?: BufferSource): BufferSource; | ||
static encrypt(data: BufferSource, key: RsaKey, label?: BufferSource): ArrayBuffer; | ||
static decrypt(data: BufferSource, key: RsaKey, label?: BufferSource): ArrayBuffer; | ||
} | ||
@@ -38,0 +38,0 @@ |
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"target": "es5", | ||
@@ -6,0 +5,0 @@ "lib": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
3816
301441
5
+ Addedtypescript@2.3.4
+ Added@types/node@7.10.14(transitive)
+ Addedtypescript@2.3.4(transitive)
- Removed@types/node@22.10.2(transitive)
- Removedundici-types@6.20.0(transitive)
Updated@types/node@^7.0.32
Updatedwebcrypto-core@^0.1.16