You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
9.5 KiB
2 lines
9.5 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{529:function(e,r,t){"use strict";function n(e,r,t){return r<=e&&e<=t}function i(e){if(void 0===e)return{};if(e===Object(e))return e;throw TypeError("Could not convert argument to dictionary")}t.r(r),t.d(r,"TextEncoder",function(){return l}),t.d(r,"TextDecoder",function(){return c});var o=-1;function a(e){this.tokens=[].slice.call(e)}a.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():o},prepend:function(e){if(Array.isArray(e))for(var r=e;r.length;)this.tokens.unshift(r.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var r=e;r.length;)this.tokens.push(r.shift());else this.tokens.push(e)}};var s=-1;function u(e,r){if(e)throw TypeError("Decoder error");return r||65533}var f="utf-8";function c(e,r){if(!(this instanceof c))return new c(e,r);if((e=void 0!==e?String(e).toLowerCase():f)!==f)throw new Error("Encoding not supported. Only utf-8 is supported");r=i(r),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(r.fatal),this._ignoreBOM=Boolean(r.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function l(e,r){if(!(this instanceof l))return new l(e,r);if((e=void 0!==e?String(e).toLowerCase():f)!==f)throw new Error("Encoding not supported. Only utf-8 is supported");r=i(r),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(r.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function h(e){var r=e.fatal,t=0,i=0,a=0,f=128,c=191;this.handler=function(e,l){if(l===o&&0!==a)return a=0,u(r);if(l===o)return s;if(0===a){if(n(l,0,127))return l;if(n(l,194,223))a=1,t=l-192;else if(n(l,224,239))224===l&&(f=160),237===l&&(c=159),a=2,t=l-224;else{if(!n(l,240,244))return u(r);240===l&&(f=144),244===l&&(c=143),a=3,t=l-240}return t<<=6*a,null}if(!n(l,f,c))return t=a=i=0,f=128,c=191,e.prepend(l),u(r);if(f=128,c=191,t+=l-128<<6*(a-(i+=1)),i!==a)return null;var h=t;return t=a=i=0,h}}function d(e){e.fatal;this.handler=function(e,r){if(r===o)return s;if(n(r,0,127))return r;var t,i;n(r,128,2047)?(t=1,i=192):n(r,2048,65535)?(t=2,i=224):n(r,65536,1114111)&&(t=3,i=240);for(var a=[(r>>6*t)+i];t>0;){var u=r>>6*(t-1);a.push(128|63&u),t-=1}return a}}c.prototype={decode:function(e,r){var t;t="object"==typeof e&&e instanceof ArrayBuffer?new Uint8Array(e):"object"==typeof e&&"buffer"in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),r=i(r),this._streaming||(this._decoder=new h({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(r.stream);for(var n,o=new a(t),u=[];!o.endOfStream()&&(n=this._decoder.handler(o,o.read()))!==s;)null!==n&&(Array.isArray(n)?u.push.apply(u,n):u.push(n));if(!this._streaming){do{if((n=this._decoder.handler(o,o.read()))===s)break;null!==n&&(Array.isArray(n)?u.push.apply(u,n):u.push(n))}while(!o.endOfStream());this._decoder=null}return u.length&&(-1===["utf-8"].indexOf(this.encoding)||this._ignoreBOM||this._BOMseen||(65279===u[0]?(this._BOMseen=!0,u.shift()):this._BOMseen=!0)),function(e){for(var r="",t=0;t<e.length;++t){var n=e[t];n<=65535?r+=String.fromCharCode(n):(n-=65536,r+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return r}(u)}},l.prototype={encode:function(e,r){e=e?String(e):"",r=i(r),this._streaming||(this._encoder=new d(this._options)),this._streaming=Boolean(r.stream);for(var t,n=[],o=new a(function(e){for(var r=String(e),t=r.length,n=0,i=[];n<t;){var o=r.charCodeAt(n);if(o<55296||o>57343)i.push(o);else if(56320<=o&&o<=57343)i.push(65533);else if(55296<=o&&o<=56319)if(n===t-1)i.push(65533);else{var a=e.charCodeAt(n+1);if(56320<=a&&a<=57343){var s=1023&o,u=1023&a;i.push(65536+(s<<10)+u),n+=1}else i.push(65533)}n+=1}return i}(e));!o.endOfStream()&&(t=this._encoder.handler(o,o.read()))!==s;)Array.isArray(t)?n.push.apply(n,t):n.push(t);if(!this._streaming){for(;(t=this._encoder.handler(o,o.read()))!==s;)Array.isArray(t)?n.push.apply(n,t):n.push(t);this._encoder=null}return new Uint8Array(n)}}},536:function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.encryptMegolmKeyFile=r.decryptMegolmKeyFile=void 0;var n,i,o,a=d(t(49)),s=d(t(15)),u=d(t(61)),f=t(10),c=(r.decryptMegolmKeyFile=(n=(0,f.coroutine)(s.default.mark(function e(r,t){var n,i,o,a,l,d,p,b,m,_,k,x,O,C;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=A(r)).length<1)){e.next=3;break}throw w("Invalid file: too short",(0,h._t)("Not a valid Riot keyfile"));case 3:if(1===n[0]){e.next=6;break}throw w("Unsupported version",(0,h._t)("Not a valid Riot keyfile"));case 6:if(!((i=n.length-69)<0)){e.next=9;break}throw w("Invalid file: too short",(0,h._t)("Not a valid Riot keyfile"));case 9:return o=n.subarray(1,17),a=n.subarray(17,33),l=n[33]<<24|n[34]<<16|n[35]<<8|n[36],d=n.subarray(37,37+i),p=n.subarray(-32),e.next=16,(0,f.resolve)(c(o,l,t));case 16:return b=e.sent,m=(0,u.default)(b,2),_=m[0],k=m[1],x=n.subarray(0,-32),O=void 0,e.prev=22,e.next=25,(0,f.resolve)(v.verify({name:"HMAC"},k,p,x));case 25:O=e.sent,e.next=31;break;case 28:throw e.prev=28,e.t0=e.catch(22),w("subtleCrypto.verify failed: "+e.t0,g());case 31:if(O){e.next=33;break}throw w("hmac mismatch",(0,h._t)("Authentication check failed: incorrect password?"));case 33:return C=void 0,e.prev=34,e.next=37,(0,f.resolve)(v.decrypt({name:"AES-CTR",counter:a,length:64},_,d));case 37:C=e.sent,e.next=43;break;case 40:throw e.prev=40,e.t1=e.catch(34),w("subtleCrypto.decrypt failed: "+e.t1,g());case 43:return e.abrupt("return",(new y).decode(new Uint8Array(C)));case 44:case"end":return e.stop()}},e,this,[[22,28],[34,40]])})),function(e,r){return n.apply(this,arguments)}),r.encryptMegolmKeyFile=(i=(0,f.coroutine)(s.default.mark(function e(r,t,n){var i,o,a,l,h,d,y,b,m,A,k,x,O,C,M,S;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=(n=n||{}).kdf_rounds||5e5,o=new Uint8Array(16),window.crypto.getRandomValues(o),a=new Uint8Array(16),window.crypto.getRandomValues(a),a[8]&=127,e.next=9,(0,f.resolve)(c(o,i,t));case 9:return l=e.sent,h=(0,u.default)(l,2),d=h[0],y=h[1],b=(new p).encode(r),m=void 0,e.prev=15,e.next=18,(0,f.resolve)(v.encrypt({name:"AES-CTR",counter:a,length:64},d,b));case 18:m=e.sent,e.next=24;break;case 21:throw e.prev=21,e.t0=e.catch(15),w("subtleCrypto.encrypt failed: "+e.t0,g());case 24:return A=new Uint8Array(m),k=1+o.length+a.length+4+A.length+32,x=new Uint8Array(k),O=0,x[O++]=1,x.set(o,O),O+=o.length,x.set(a,O),O+=a.length,x[O++]=i>>24,x[O++]=i>>16&255,x[O++]=i>>8&255,x[O++]=255&i,x.set(A,O),O+=A.length,C=x.subarray(0,O),M=void 0,e.prev=41,e.next=44,(0,f.resolve)(v.sign({name:"HMAC"},y,C));case 44:M=e.sent,e.next=50;break;case 47:throw e.prev=47,e.t1=e.catch(41),w("subtleCrypto.sign failed: "+e.t1,g());case 50:return S=new Uint8Array(M),x.set(S,O),e.abrupt("return",_(x));case 53:case"end":return e.stop()}},e,this,[[15,21],[41,47]])})),function(e,r,t){return i.apply(this,arguments)}),o=(0,f.coroutine)(s.default.mark(function e(r,t,n){var i,o,u,c,l,h,d,y;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Date,o=void 0,e.prev=2,e.next=5,(0,f.resolve)(v.importKey("raw",(new p).encode(n),{name:"PBKDF2"},!1,["deriveBits"]));case 5:o=e.sent,e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(2),w("subtleCrypto.importKey failed: "+e.t0,g());case 11:return u=void 0,e.prev=12,e.next=15,(0,f.resolve)(v.deriveBits({name:"PBKDF2",salt:r,iterations:t,hash:"SHA-512"},o,512));case 15:u=e.sent,e.next=21;break;case 18:throw e.prev=18,e.t1=e.catch(12),w("subtleCrypto.deriveBits failed: "+e.t1,g());case 21:return c=new Date,console.log("E2e import/export: deriveKeys took "+(c-i)+"ms"),l=u.slice(0,32),h=u.slice(32),d=v.importKey("raw",l,{name:"AES-CTR"},!1,["encrypt","decrypt"]).catch(function(e){throw w("subtleCrypto.importKey failed for AES key: "+e,g())}),y=v.importKey("raw",h,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"]).catch(function(e){throw w("subtleCrypto.importKey failed for HMAC key: "+e,g())}),e.next=29,(0,f.resolve)(a.default.all([d,y]));case 29:return e.abrupt("return",e.sent);case 30:case"end":return e.stop()}},e,this,[[2,8],[12,18]])})),function(e,r,t){return o.apply(this,arguments)}),l=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(529)),h=t(2);function d(e){return e&&e.__esModule?e:{default:e}}var p=window.TextEncoder;p||(p=l.TextEncoder);var y=window.TextDecoder;y||(y=l.TextDecoder);var v=window.crypto.subtle||window.crypto.webkitSubtle;function w(e,r){var t=new Error(e);return t.friendlyText=r,t}function g(){return(0,h._t)("Your browser does not support the required cryptography extensions")}var b="-----BEGIN MEGOLM SESSION DATA-----",m="-----END MEGOLM SESSION DATA-----";function A(e){for(var r=(new y).decode(new Uint8Array(e)),t=0;;){var n=r.indexOf("\n",t);if(n<0)throw new Error("Header line not found");var i=r.slice(t,n).trim();if(t=n+1,i===b)break}for(var o=t;;){var a=r.indexOf("\n",t);if(r.slice(t,a<0?void 0:a).trim()===m)break;if(a<0)throw new Error("Trailer line not found");t=a+1}var s=t;return function(e){for(var r=window.atob(e),t=new Uint8Array(r.length),n=0;n<r.length;n++)t[n]=r.charCodeAt(n);return t}(r.slice(o,s))}function _(e){var r=Math.ceil(e.length/96),t=new Array(r+3);t[0]=b;var n,i,o=0,a=void 0;for(a=1;a<=r;a++)t[a]=(n=e.subarray(o,o+96),i=void 0,i=String.fromCharCode.apply(null,n),window.btoa(i)),o+=96;return t[a++]=m,t[a]="",(new p).encode(t.join("\n")).buffer}}}]);
|
|
//# sourceMappingURL=2.js.map
|