mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-05-04 20:03:15 +00:00
3 lines
1.9 MiB
JavaScript
3 lines
1.9 MiB
JavaScript
|
|
/*! For license information please see main.4b3f1bf8.js.LICENSE.txt */
|
||
|
|
(()=>{var __webpack_modules__={77788:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DUMP_SESSION_KEYS=e.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=e.NOISE_MSG_MAX_LENGTH_BYTES=void 0,e.NOISE_MSG_MAX_LENGTH_BYTES=65535,e.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=e.NOISE_MSG_MAX_LENGTH_BYTES-16,e.DUMP_SESSION_KEYS={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.DUMP_SESSION_KEYS},87477:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decryptStream=e.encryptStream=void 0;const n=r(77788);e.encryptStream=function(t){return async function*(e){for await(const r of e)for(let e=0;e<r.length;e+=n.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG){let i=e+n.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG;i>r.length&&(i=r.length);const o=t.encrypt(r.slice(e,i),t.session);yield o}}},e.decryptStream=function(t){return async function*(e){for await(const r of e)for(let e=0;e<r.length;e+=n.NOISE_MSG_MAX_LENGTH_BYTES){let i=e+n.NOISE_MSG_MAX_LENGTH_BYTES;i>r.length&&(i=r.length);const{plaintext:o,valid:s}=await t.decrypt(r.slice(e,i),t.session);if(!s)throw new Error("Failed to validate decrypted chunk");yield o}}}},75698:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.decode2=e.decode1=e.decode0=e.encode2=e.encode1=e.encode0=e.uint16BEDecode=e.uint16BEEncode=void 0;const i=n(r(41976)),o=r(62110);e.uint16BEEncode=(t,e,r)=>{var n;return e=e||(n=2,globalThis.Buffer?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)),new DataView(e.buffer,e.byteOffset,e.byteLength).setUint16(r,t,!1),e},e.uint16BEEncode.bytes=2;e.uint16BEDecode=t=>{if(t.length<2)throw RangeError("Could not decode int16BE");return t instanceof i.default?t.readUInt16BE(0):new DataView(t.buffer,t.byteOffset,t.byteLength).getUint16(0,!1)},e.uint16BEDecode.bytes=2,e.encode0=function(t){return(0,o.concat)([t.ne,t.ciphertext],t.ne.length+t.ciphertext.length)},e.encode1=function(t){return(0,o.concat)([t.ne,t.ns,t.ciphertext],t.ne.length+t.ns.length+t.ciphertext.length)},e.encode2=function(t){return(0,o.concat)([t.ns,t.ciphertext],t.ns.length+t.ciphertext.length)},e.decode0=function(t){if(t.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:t.slice(0,32),ciphertext:t.slice(32,t.length),ns:new Uint8Array(0)}},e.decode1=function(t){if(t.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:t.slice(0,32),ns:t.slice(32,80),ciphertext:t.slice(80,t.length)}},e.decode2=function(t){if(t.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:new Uint8Array(0),ns:t.slice(0,48),ciphertext:t.slice(48,t.length)}}},88919:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FailedIKError=void 0;class r extends Error{constructor(t,e){super(e),this.initialMsg=t,this.name="FailedIKhandshake"}}e.FailedIKError=r},77827:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IKHandshake=void 0;const n=r(8609),i=r(75698),o=r(83605),s=r(88919),a=r(46400);e.IKHandshake=class{constructor(t,e,r,i,o,s,a,u){this.isInitiator=t,this.payload=e,this.prologue=r,this.staticKeypair=i,this.connection=o,a&&(this.remotePeer=a),this.ik=null!==u&&void 0!==u?u: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 t=this.ik.sendMessage(this.session,this.payload);this.connection.writeLP((0,i.encode1)(t)),(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 e=await this.connection.readLP();try{const t=(0,i.decode1)(e.slice()),{plaintext:r,valid:n}=this.ik.re
|
||
|
|
//# sourceMappingURL=main.4b3f1bf8.js.map
|