line_push/node_modules/js-crypto-aes/dist/jscaes.bundle.min.js
2022-07-21 03:28:35 +00:00

1 line
20 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("crypto")):"function"==typeof define&&define.amd?define(["crypto"],e):"object"==typeof exports?exports.jscaes=e(require("crypto")):t.jscaes=e(t.crypto)}(this,function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/home/circleci/repo/packages/js-crypto-aes/dist",r(r.s=3)}([function(t,e,r){t.exports=r(4)},function(t,e){function r(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise(function(o,a){var i=t.apply(e,n);function c(t){r(i,o,a,c,u,"next",t)}function u(t){r(i,o,a,c,u,"throw",t)}c(void 0)})}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getRootWebCryptoAll=e.getWebCryptoAll=e.getMsCrypto=e.getWebCrypto=e.getNodeCrypto=e.default=void 0;var n=function(){return"undefined"!=typeof window?void 0:r(5)};e.getNodeCrypto=n;var o=function(){if("undefined"!=typeof window)return window.crypto?window.crypto.subtle:void 0};e.getWebCrypto=o;var a=function(){if("undefined"!=typeof window)return window.msCrypto?window.msCrypto.subtle:window.crypto?window.crypto.subtle:void 0};e.getWebCryptoAll=a;var i=function(){if("undefined"!=typeof window)return window.msCrypto?window.msCrypto:window.crypto?window.crypto:void 0};e.getRootWebCryptoAll=i;var c=function(){if("undefined"!=typeof window&&!window.crypto)return window.msCrypto?window.msCrypto.subtle:void 0};e.getMsCrypto=c;var u={getNodeCrypto:n,getWebCrypto:o,getMsCrypto:c,getWebCryptoAll:a,getRootWebCryptoAll:i};e.default=u},function(t,e,r){t.exports=r(6)},function(t,e,r){var n=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),i=new K(n||[]);return a._invoke=function(t,e,r){var n=p;return function(o,a){if(n===h)throw new Error("Generator is already running");if(n===y){if("throw"===o)throw a;return U()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=L(i,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=h;var u=s(t,e,r);if("normal"===u.type){if(n=r.done?y:f,u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=y,r.method="throw",r.arg=u.arg)}}}(t,r,i),a}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",f="suspendedYield",h="executing",y="completed",l={};function d(){}function v(){}function w(){}var g={};g[a]=function(){return this};var m=Object.getPrototypeOf,b=m&&m(m(S([])));b&&b!==r&&n.call(b,a)&&(g=b);var x=w.prototype=d.prototype=Object.create(g);function A(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function E(t){var e;this._invoke=function(r,o){function a(){return new Promise(function(e,a){!function e(r,o,a,i){var c=s(t[r],t,o);if("throw"!==c.type){var u=c.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?Promise.resolve(p.__await).then(function(t){e("next",t,a,i)},function(t){e("throw",t,a,i)}):Promise.resolve(p).then(function(t){u.value=t,a(u)},function(t){return e("throw",t,a,i)})}i(c.arg)}(r,o,e,a)})}return e=e?e.then(a,a):a()}}function L(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,L(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=s(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var a=o.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,l):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function K(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function S(t){if(t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}return{next:U}}function U(){return{value:e,done:!0}}return v.prototype=x.constructor=w,w.constructor=v,w[c]=v.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c in t||(t[c]="GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},A(E.prototype),E.prototype[i]=function(){return this},t.AsyncIterator=E,t.async=function(e,r,n,o){var a=new E(u(e,r,n,o));return t.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},A(x),x[c]="Generator",x[a]=function(){return this},x.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,K.prototype={constructor:K,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(k),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:S(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),l}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(e,r){e.exports=t},function(t,e,r){"use strict";r.r(e);var n=r(0),o=r.n(n),a=r(1),i=r.n(a),c=r(2),u={ciphers:{"AES-GCM":{nodePrefix:"aes-",nodeSuffix:"-gcm",ivLength:12,tagLength:16,staticIvLength:!0},"AES-CBC":{nodePrefix:"aes-",nodeSuffix:"-cbc",ivLength:16,staticIvLength:!0},"AES-CTR":{nodePrefix:"aes-",nodeSuffix:"-ctr",ivLength:12,staticIvLength:!1}},wrapKeys:{"AES-KW":{nodePrefix:"id-aes",nodeSuffix:"-wrap",ivLength:8,staticIvLength:!0,defaultIV:new Uint8Array([166,166,166,166,166,166,166,166])}}},s=function(t,e,r,n){var o=r.name,a=void 0===o?"AES-KW":o,i=r.iv;return f(t,e,{name:a,iv:i},n,!0)},p=function(t,e,r,n){var o=r.name,a=void 0===o?"AES-KW":o,i=r.iv;return h(t,e,{name:a,iv:i},n,!0)},f=function(t,e,r,n){var o,a,i,c,s=r.name,p=r.iv,f=r.additionalData,h=r.tagLength,l=arguments.length>4&&void 0!==arguments[4]&&arguments[4],d=y(s,e.byteLength,l?u.wrapKeys:u.ciphers);switch(s){case"AES-GCM":(o=n.createCipheriv(d,e,p,{authTagLength:h})).setAAD(f);break;case"AES-CTR":if(0===p.length||p.length>16)throw new Error("InvalidIVLength");var v=new Uint8Array(16);v.set(p),v[15]+=1,o=n.createCipheriv(d,e,v);break;default:o=n.createCipheriv(d,e,p)}try{a=new Uint8Array(o.update(t)),i=new Uint8Array(o.final()),c=new Uint8Array([]),"AES-GCM"===s&&(c=new Uint8Array(o.getAuthTag()))}catch(t){throw new Error("NodeCrypto_EncryptionFailure")}var w=new Uint8Array(a.length+i.length+c.length);return w.set(a),w.set(i,a.length),w.set(c,a.length+i.length),w},h=function(t,e,r,n){var o,a,i,c,s=r.name,p=r.iv,f=r.additionalData,h=r.tagLength,l=arguments.length>4&&void 0!==arguments[4]&&arguments[4],d=y(s,e.byteLength,l?u.wrapKeys:u.ciphers);switch(s){case"AES-GCM":(o=n.createDecipheriv(d,e,p,{authTagLength:h})).setAAD(f),a=t.slice(0,t.length-h);var v=t.slice(t.length-h);o.setAuthTag(v);break;case"AES-CTR":if(0===p.length||p.length>16)throw new Error("InvalidIVLength");var w=new Uint8Array(16);w.set(p),w[15]+=1,o=n.createDecipheriv(d,e,w),a=t;break;default:o=n.createDecipheriv(d,e,p),a=t}try{i=o.update(a),c=o.final()}catch(t){throw new Error("NodeCrypto_DecryptionFailure")}var g=new Uint8Array(c.length+i.length);return g.set(i),g.set(c,i.length),g},y=function(t,e,r){var n=r[t].nodePrefix;return(n="".concat(n).concat((8*e).toString()))+r[t].nodeSuffix},l=function(){var t=i()(o.a.mark(function t(e,r,n,a){var i,c,u,s,p,f;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.name,c=void 0===i?"AES-KW":i,u=n.iv,void 0!==window.msCrypto){t.next=20;break}return t.prev=2,t.next=5,a.importKey("raw",r,{name:c},!1,["wrapKey","unwrapKey"]);case 5:return s=t.sent,t.next=8,a.importKey("raw",e,{name:c},!0,["wrapKey","unwrapKey"]);case 8:return p=t.sent,t.next=11,a.wrapKey("raw",p,s,{name:c,iv:u});case 11:return f=t.sent,t.abrupt("return",new Uint8Array(f));case 15:throw t.prev=15,t.t0=t.catch(2),new Error("WebCrypto_FailedToWrapKey - ".concat(t.t0.message));case 18:t.next=21;break;case 20:throw new Error("ThrowAwayIeAsap");case 21:case"end":return t.stop()}},t,null,[[2,15]])}));return function(e,r,n,o){return t.apply(this,arguments)}}(),d=function(){var t=i()(o.a.mark(function t(e,r,n,a){var i,c,u,s,p;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.name,c=void 0===i?"AES-KW":i,u=n.iv,void 0!==window.msCrypto){t.next=21;break}return t.prev=2,t.next=5,a.importKey("raw",r,{name:c},!1,["wrapKey","unwrapKey"]);case 5:return s=t.sent,t.next=8,a.unwrapKey("raw",e,s,{name:c,iv:u},{name:"AES-GCM"},!0,["encrypt","decrypt"]);case 8:return p=t.sent,t.t0=Uint8Array,t.next=12,a.exportKey("raw",p);case 12:return t.t1=t.sent,t.abrupt("return",new t.t0(t.t1));case 16:throw t.prev=16,t.t2=t.catch(2),new Error("WebCrypto_FailedToUnwrapKey - ".concat(t.t2.message));case 19:t.next=22;break;case 21:throw new Error("ThrowAwayMsIeAsap");case 22:case"end":return t.stop()}},t,null,[[2,16]])}));return function(e,r,n,o){return t.apply(this,arguments)}}(),v=function(){var t=i()(o.a.mark(function t(e,r,n,a){var i,c,u,s,p,f,h,y,l,d,v;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.name,c=void 0===i?"AES-GCM":i,u=n.iv,s=n.additionalData,p=n.tagLength,f=g({name:c,iv:u,additionalData:s,tagLength:p}),void 0!==window.msCrypto){t.next=18;break}return t.prev=3,t.next=6,a.importKey("raw",r,f,!1,["encrypt","decrypt"]);case 6:return h=t.sent,t.next=9,a.encrypt(f,h,e);case 9:return y=t.sent,t.abrupt("return",new Uint8Array(y));case 13:throw t.prev=13,t.t0=t.catch(3),new Error("WebCrypto_EncryptionFailure: ".concat(t.t0.message));case 16:t.next=38;break;case 18:return t.prev=18,t.next=21,m("raw",r,f,!1,["encrypt","decrypt"],a);case 21:return l=t.sent,t.next=24,b(f,l,e,a);case 24:if(d=t.sent,"AES-GCM"!==c){t.next=32;break}return(v=new Uint8Array(d.ciphertext.byteLength+d.tag.byteLength)).set(new Uint8Array(d.ciphertext)),v.set(new Uint8Array(d.tag),d.ciphertext.byteLength),t.abrupt("return",v);case 32:return t.abrupt("return",new Uint8Array(d));case 33:t.next=38;break;case 35:throw t.prev=35,t.t1=t.catch(18),new Error("ThrowAwayMsIeAsap: ".concat(t.t1.message));case 38:case"end":return t.stop()}},t,null,[[3,13],[18,35]])}));return function(e,r,n,o){return t.apply(this,arguments)}}(),w=function(){var t=i()(o.a.mark(function t(e,r,n,a){var i,c,u,s,p,f,h,y,l,d,v;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.name,c=n.iv,u=n.additionalData,s=n.tagLength,p=g({name:i,iv:c,additionalData:u,tagLength:s}),window.msCrypto){t.next=18;break}return t.prev=3,t.next=6,a.importKey("raw",r,p,!1,["encrypt","decrypt"]);case 6:return f=t.sent,t.next=9,a.decrypt(p,f,e);case 9:return h=t.sent,t.abrupt("return",new Uint8Array(h));case 13:throw t.prev=13,t.t0=t.catch(3),new Error("WebCrypto_DecryptionFailure: ".concat(t.t0.message));case 16:t.next=39;break;case 18:return t.prev=18,t.next=21,m("raw",r,p,!1,["encrypt","decrypt"],a);case 21:if(y=t.sent,"AES-GCM"!==i){t.next=30;break}return d=e.slice(0,e.length-s),v=e.slice(e.length-s,e.length),t.next=27,x(Object.assign(p,{tag:v}),y,d,a);case 27:l=t.sent,t.next=33;break;case 30:return t.next=32,x(p,y,e,a);case 32:l=t.sent;case 33:return t.abrupt("return",new Uint8Array(l));case 36:throw t.prev=36,t.t1=t.catch(18),new Error("ThrowAwayMsIeAsap: ".concat(t.t1.message));case 39:case"end":return t.stop()}},t,null,[[3,13],[18,36]])}));return function(e,r,n,o){return t.apply(this,arguments)}}(),g=function(t){var e=t.name,r=t.iv,n=t.additionalData,o=t.tagLength,a={};switch(e){case"AES-GCM":Object.assign(a,{name:e,iv:r,tagLength:8*o}),Object.assign(a,n.length>0?{additionalData:n}:{});break;case"AES-CBC":a.name=e,a.iv=r;break;case"AES-CTR":if(0===r.length||r.length>16)throw new Error("InvalidIVLength");a.name=e,a.counter=new Uint8Array(16),a.counter.set(r),a.counter[15]+=1,a.length=128}return a},m=function(t,e,r,n,o,a){return new Promise(function(i,c){var u=a.importKey(t,e,r,n,o);u.oncomplete=function(t){i(t.target.result)},u.onerror=function(){c("KeyImportingFailed")}})},b=function(t,e,r,n){return new Promise(function(o,a){var i=n.encrypt(t,e,r);i.oncomplete=function(t){o(t.target.result)},i.onerror=function(){a("EncryptionFailure")}})},x=function(t,e,r,n){return new Promise(function(o,a){var i=n.decrypt(t,e,r);i.oncomplete=function(t){o(t.target.result)},i.onerror=function(){a("DecryptionFailure")}})},A=function(t){var e=t.name,r=t.iv,n=t.tagLength;if(Object.keys(u.ciphers).indexOf(e)<0)throw new Error("UnsupportedAlgorithm");if(u.ciphers[e].ivLength){if(!(r instanceof Uint8Array))throw new Error("InvalidArguments");if(r.byteLength<2||r.byteLength>16)throw new Error("InvalidIVLength");if(u.ciphers[e].staticIvLength&&u.ciphers[e].ivLength!==r.byteLength)throw new Error("InvalidIVLength")}if(u.ciphers[e].tagLength&&n){if(!Number.isInteger(n))throw new Error("InvalidArguments");if(n<4||n>16)throw new Error("InvalidTagLength")}},E=function(){var t=i()(o.a.mark(function t(e,r,n){var a,i,s,p,h,y,l,d;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(a=n.name,i=void 0===a?"AES-GCM":a,s=n.iv,p=n.additionalData,h=void 0===p?new Uint8Array([]):p,y=n.tagLength,e instanceof Uint8Array&&r instanceof Uint8Array){t.next=3;break}throw new Error("InvalidArguments");case 3:return A({name:i,iv:s,tagLength:y}),u.ciphers[i].tagLength&&!y&&(y=u.ciphers[i].tagLength),t.next=7,c.getWebCryptoAll();case 7:return l=t.sent,t.next=10,c.getNodeCrypto();case 10:if(d=t.sent,void 0===l||"function"!=typeof l.importKey||"function"!=typeof l.encrypt){t.next=15;break}return t.abrupt("return",v(e,r,{name:i,iv:s,additionalData:h,tagLength:y},l));case 15:if(void 0===d){t.next=19;break}return t.abrupt("return",f(e,r,{name:i,iv:s,additionalData:h,tagLength:y},d));case 19:throw new Error("UnsupportedEnvironment");case 20:case"end":return t.stop()}},t)}));return function(e,r,n){return t.apply(this,arguments)}}(),L=function(){var t=i()(o.a.mark(function t(e,r,n){var a,i,s,p,f,y,l,d;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(a=n.name,i=void 0===a?"AES-GCM":a,s=n.iv,p=n.additionalData,f=void 0===p?new Uint8Array([]):p,y=n.tagLength,e instanceof Uint8Array&&r instanceof Uint8Array){t.next=3;break}throw new Error("InvalidArguments");case 3:return A({name:i,iv:s,tagLength:y}),u.ciphers[i].tagLength&&!y&&(y=u.ciphers[i].tagLength),t.next=7,c.getWebCryptoAll();case 7:return l=t.sent,t.next=10,c.getNodeCrypto();case 10:if(d=t.sent,void 0===l||"function"!=typeof l.importKey||"function"!=typeof l.encrypt){t.next=15;break}return t.abrupt("return",w(e,r,{name:i,iv:s,additionalData:f,tagLength:y},l));case 15:if(void 0===d){t.next=19;break}return t.abrupt("return",h(e,r,{name:i,iv:s,additionalData:f,tagLength:y},d));case 19:throw new Error("UnsupportedEnvironment");case 20:case"end":return t.stop()}},t)}));return function(e,r,n){return t.apply(this,arguments)}}(),C=function(){var t=i()(o.a.mark(function t(e,r,n){var a,i,p,f,h;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(a=n.name,i=void 0===a?"AES-KW":a,e instanceof Uint8Array){t.next=3;break}throw new Error("NonUint8ArrayData");case 3:if(r instanceof Uint8Array){t.next=5;break}throw new Error("NonUint8ArrayKey");case 5:if(!(e.length%8>0)){t.next=7;break}throw new Error("WrappedKeyMustBeMultipleOf8");case 7:return t.next=9,c.getWebCryptoAll();case 9:return p=t.sent,t.next=12,c.getNodeCrypto();case 12:if(f=t.sent,h=u.wrapKeys["AES-KW"].defaultIV,void 0===p||"function"!=typeof p.importKey||"function"!=typeof p.wrapKey){t.next=18;break}return t.abrupt("return",l(e,r,{name:i,iv:h},p));case 18:if(void 0===f){t.next=22;break}return t.abrupt("return",s(e,r,{name:i,iv:h},f));case 22:throw new Error("UnsupportedEnvironment");case 23:case"end":return t.stop()}},t)}));return function(e,r,n){return t.apply(this,arguments)}}(),k=function(){var t=i()(o.a.mark(function t(e,r,n){var a,i,s,f,h;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(a=n.name,i=void 0===a?"AES-KW":a,e instanceof Uint8Array){t.next=3;break}throw new Error("NonUint8ArrayData");case 3:if(r instanceof Uint8Array){t.next=5;break}throw new Error("NonUint8ArrayKey");case 5:return t.next=7,c.getWebCryptoAll();case 7:return s=t.sent,t.next=10,c.getNodeCrypto();case 10:if(f=t.sent,h=u.wrapKeys["AES-KW"].defaultIV,void 0===s||"function"!=typeof s.importKey||"function"!=typeof s.wrapKey){t.next=16;break}return t.abrupt("return",d(e,r,{name:i,iv:h},s));case 16:if(void 0===f){t.next=20;break}return t.abrupt("return",p(e,r,{name:i,iv:h},f));case 20:throw new Error("UnsupportedEnvironment");case 21:case"end":return t.stop()}},t)}));return function(e,r,n){return t.apply(this,arguments)}}();r.d(e,"encrypt",function(){return E}),r.d(e,"decrypt",function(){return L}),r.d(e,"wrapKey",function(){return C}),r.d(e,"unwrapKey",function(){return k});e.default={encrypt:E,decrypt:L,wrapKey:C,unwrapKey:k}}])});