3 lines
1.2 MiB
JavaScript
Raw Normal View History

2022-05-13 06:35:28 +00:00
/*! For license information please see main.e8560a6b.js.LICENSE.txt */
(()=>{var __webpack_modules__={77788:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DUMP_SESSION_KEYS=t.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=t.NOISE_MSG_MAX_LENGTH_BYTES=void 0,t.NOISE_MSG_MAX_LENGTH_BYTES=65535,t.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=t.NOISE_MSG_MAX_LENGTH_BYTES-16,t.DUMP_SESSION_KEYS={NODE_ENV:"production",PUBLIC_URL:"/examples/store-reactjs-chat",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.DUMP_SESSION_KEYS},87477:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decryptStream=t.encryptStream=void 0;const n=r(77788);t.encryptStream=function(e){return async function*(t){for await(const r of t)for(let t=0;t<r.length;t+=n.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG){let i=t+n.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG;i>r.length&&(i=r.length);const o=e.encrypt(r.slice(t,i),e.session);yield o}}},t.decryptStream=function(e){return async function*(t){for await(const r of t)for(let t=0;t<r.length;t+=n.NOISE_MSG_MAX_LENGTH_BYTES){let i=t+n.NOISE_MSG_MAX_LENGTH_BYTES;i>r.length&&(i=r.length);const{plaintext:o,valid:s}=await e.decrypt(r.slice(t,i),e.session);if(!s)throw new Error("Failed to validate decrypted chunk");yield o}}}},75698:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decode2=t.decode1=t.decode0=t.encode2=t.encode1=t.encode0=t.uint16BEDecode=t.uint16BEEncode=void 0;const i=n(r(41976)),o=r(62110);t.uint16BEEncode=(e,t,r)=>{var n;return t=t||(n=2,globalThis.Buffer?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)),new DataView(t.buffer,t.byteOffset,t.byteLength).setUint16(r,e,!1),t},t.uint16BEEncode.bytes=2;t.uint16BEDecode=e=>{if(e.length<2)throw RangeError("Could not decode int16BE");return e instanceof i.default?e.readUInt16BE(0):new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!1)},t.uint16BEDecode.bytes=2,t.encode0=function(e){return(0,o.concat)([e.ne,e.ciphertext],e.ne.length+e.ciphertext.length)},t.encode1=function(e){return(0,o.concat)([e.ne,e.ns,e.ciphertext],e.ne.length+e.ns.length+e.ciphertext.length)},t.encode2=function(e){return(0,o.concat)([e.ns,e.ciphertext],e.ns.length+e.ciphertext.length)},t.decode0=function(e){if(e.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:e.slice(0,32),ciphertext:e.slice(32,e.length),ns:new Uint8Array(0)}},t.decode1=function(e){if(e.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:e.slice(0,32),ns:e.slice(32,80),ciphertext:e.slice(80,e.length)}},t.decode2=function(e){if(e.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:new Uint8Array(0),ns:e.slice(0,48),ciphertext:e.slice(48,e.length)}}},88919:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FailedIKError=void 0;class r extends Error{constructor(e,t){super(t),this.initialMsg=e,this.name="FailedIKhandshake"}}t.FailedIKError=r},77827:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IKHandshake=void 0;const n=r(8609),i=r(75698),o=r(83605),s=r(88919),a=r(46400);t.IKHandshake=class{constructor(e,t,r,i,o,s,a,c){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=i,this.connection=o,a&&(this.remotePeer=a),this.ik=null!==c&&void 0!==c?c:new n.IK,this.session=this.ik.initSession(this.isInitiator,this.prologue,this.staticKeypair,s),this.remoteEarlyData=new Uint8Array}async stage0(){if((0,a.logLocalStaticKeys)(this.session.hs.s),(0,a.logRemoteStaticKey)(this.session.hs.rs),this.isInitiator){(0,a.logger)("IK Stage 0 - Initiator sending message...");const e=this.ik.sendMessage(this.session,this.payload);this.connection.writeLP((0,i.encode1)(e)),(0,a.logger)("IK Stage 0 - Initiator sent message."),(0,a.logLocalEphemeralKeys)(this.session.hs.e)}else{(0,a.logger)("IK Stage 0 - Responder receiving message...");const t=await this.connection.readLP();try{const e=(0,i.decode1)(t.slice()),{pla
//# sourceMappingURL=main.e8560a6b.js.map