summaryrefslogtreecommitdiff
path: root/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-24 14:03:36 +0200
committerRaindropsSys <contact@minteck.org>2023-04-24 14:03:36 +0200
commit633c92eae865e957121e08de634aeee11a8b3992 (patch)
tree09d881bee1dae0b6eee49db1dfaf0f500240606c /includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels
parentc4657e4509733699c0f26a3c900bab47e915d5a0 (diff)
downloadpluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.gz
pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.bz2
pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.zip
Updated 18 files, added 1692 files and deleted includes/system/compare.inc (automated)
Diffstat (limited to 'includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels')
-rw-r--r--includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.d.ts44
-rw-r--r--includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.d.ts.map1
-rw-r--r--includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.js196
-rw-r--r--includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.js.map1
-rw-r--r--includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.d.ts2
-rw-r--r--includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.d.ts.map1
-rw-r--r--includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.js17
-rw-r--r--includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.js.map1
8 files changed, 263 insertions, 0 deletions
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.d.ts b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.d.ts
new file mode 100644
index 0000000..06a9a36
--- /dev/null
+++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.d.ts
@@ -0,0 +1,44 @@
+import { RendezvousCode, RendezvousIntent, RendezvousChannel, RendezvousTransportDetails, RendezvousTransport, RendezvousFailureReason } from "..";
+import { UnstableValue } from "../../NamespacedValue";
+declare const ECDH_V2: UnstableValue<"m.rendezvous.v2.curve25519-aes-sha256", "org.matrix.msc3903.rendezvous.v2.curve25519-aes-sha256">;
+export interface ECDHv2RendezvousCode extends RendezvousCode {
+ rendezvous: {
+ transport: RendezvousTransportDetails;
+ algorithm: typeof ECDH_V2.name | typeof ECDH_V2.altName;
+ key: string;
+ };
+}
+export type MSC3903ECDHPayload = PlainTextPayload | EncryptedPayload;
+export interface PlainTextPayload {
+ algorithm: typeof ECDH_V2.name | typeof ECDH_V2.altName;
+ key?: string;
+}
+export interface EncryptedPayload {
+ iv: string;
+ ciphertext: string;
+}
+/**
+ * Implementation of the unstable [MSC3903](https://github.com/matrix-org/matrix-spec-proposals/pull/3903)
+ * X25519/ECDH key agreement based secure rendezvous channel.
+ * Note that this is UNSTABLE and may have breaking changes without notice.
+ */
+export declare class MSC3903ECDHv2RendezvousChannel<T> implements RendezvousChannel<T> {
+ private transport;
+ private theirPublicKey?;
+ onFailure?: ((reason: RendezvousFailureReason) => void) | undefined;
+ private olmSAS?;
+ private ourPublicKey;
+ private aesKey?;
+ private connected;
+ constructor(transport: RendezvousTransport<MSC3903ECDHPayload>, theirPublicKey?: Uint8Array | undefined, onFailure?: ((reason: RendezvousFailureReason) => void) | undefined);
+ generateCode(intent: RendezvousIntent): Promise<ECDHv2RendezvousCode>;
+ connect(): Promise<string>;
+ private encrypt;
+ send(payload: T): Promise<void>;
+ private decrypt;
+ receive(): Promise<Partial<T> | undefined>;
+ close(): Promise<void>;
+ cancel(reason: RendezvousFailureReason): Promise<void>;
+}
+export {};
+//# sourceMappingURL=MSC3903ECDHv2RendezvousChannel.d.ts.map \ No newline at end of file
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.d.ts.map b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.d.ts.map
new file mode 100644
index 0000000..f23ad42
--- /dev/null
+++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"MSC3903ECDHv2RendezvousChannel.d.ts","sourceRoot":"","sources":["../../../src/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.ts"],"names":[],"mappings":"AAkBA,OAAO,EAEH,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EAC1B,MAAM,IAAI,CAAC;AAIZ,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,QAAA,MAAM,OAAO,kHAGZ,CAAC;AAEF,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IACxD,UAAU,EAAE;QACR,SAAS,EAAE,0BAA0B,CAAC;QACtC,SAAS,EAAE,OAAO,OAAO,CAAC,IAAI,GAAG,OAAO,OAAO,CAAC,OAAO,CAAC;QACxD,GAAG,EAAE,MAAM,CAAC;KACf,CAAC;CACL;AAED,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,OAAO,OAAO,CAAC,IAAI,GAAG,OAAO,OAAO,CAAC,OAAO,CAAC;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACtB;AAYD;;;;GAIG;AACH,qBAAa,8BAA8B,CAAC,CAAC,CAAE,YAAW,iBAAiB,CAAC,CAAC,CAAC;IAOtE,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IAChB,SAAS,CAAC,YAAW,uBAAuB,KAAK,IAAI;IARhE,OAAO,CAAC,MAAM,CAAC,CAAM;IACrB,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,MAAM,CAAC,CAAY;IAC3B,OAAO,CAAC,SAAS,CAAS;gBAGd,SAAS,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,EAClD,cAAc,CAAC,wBAAY,EAC5B,SAAS,CAAC,YAAW,uBAAuB,KAAK,IAAI,aAAA;IAMnD,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmBrE,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;YAwDzB,OAAO;IA0BR,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;YAY9B,OAAO;IAwBR,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAoB1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtB,MAAM,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;CAOtE"} \ No newline at end of file
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.js b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.js
new file mode 100644
index 0000000..775257b
--- /dev/null
+++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.js
@@ -0,0 +1,196 @@
+"use strict";
+
+var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.MSC3903ECDHv2RendezvousChannel = void 0;
+var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
+var _ = require("..");
+var _olmlib = require("../../crypto/olmlib");
+var _crypto = require("../../crypto/crypto");
+var _SASDecimal = require("../../crypto/verification/SASDecimal");
+var _NamespacedValue = require("../../NamespacedValue");
+/*
+Copyright 2023 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+const ECDH_V2 = new _NamespacedValue.UnstableValue("m.rendezvous.v2.curve25519-aes-sha256", "org.matrix.msc3903.rendezvous.v2.curve25519-aes-sha256");
+async function importKey(key) {
+ if (!_crypto.subtleCrypto) {
+ throw new Error("Web Crypto is not available");
+ }
+ const imported = _crypto.subtleCrypto.importKey("raw", key, {
+ name: "AES-GCM"
+ }, false, ["encrypt", "decrypt"]);
+ return imported;
+}
+
+/**
+ * Implementation of the unstable [MSC3903](https://github.com/matrix-org/matrix-spec-proposals/pull/3903)
+ * X25519/ECDH key agreement based secure rendezvous channel.
+ * Note that this is UNSTABLE and may have breaking changes without notice.
+ */
+class MSC3903ECDHv2RendezvousChannel {
+ constructor(transport, theirPublicKey, onFailure) {
+ this.transport = transport;
+ this.theirPublicKey = theirPublicKey;
+ this.onFailure = onFailure;
+ (0, _defineProperty2.default)(this, "olmSAS", void 0);
+ (0, _defineProperty2.default)(this, "ourPublicKey", void 0);
+ (0, _defineProperty2.default)(this, "aesKey", void 0);
+ (0, _defineProperty2.default)(this, "connected", false);
+ this.olmSAS = new global.Olm.SAS();
+ this.ourPublicKey = (0, _olmlib.decodeBase64)(this.olmSAS.get_pubkey());
+ }
+ async generateCode(intent) {
+ if (this.transport.ready) {
+ throw new Error("Code already generated");
+ }
+ await this.transport.send({
+ algorithm: ECDH_V2.name
+ });
+ const rendezvous = {
+ rendezvous: {
+ algorithm: ECDH_V2.name,
+ key: (0, _olmlib.encodeUnpaddedBase64)(this.ourPublicKey),
+ transport: await this.transport.details()
+ },
+ intent
+ };
+ return rendezvous;
+ }
+ async connect() {
+ if (this.connected) {
+ throw new Error("Channel already connected");
+ }
+ if (!this.olmSAS) {
+ throw new Error("Channel closed");
+ }
+ const isInitiator = !this.theirPublicKey;
+ if (isInitiator) {
+ // wait for the other side to send us their public key
+ const rawRes = await this.transport.receive();
+ if (!rawRes) {
+ throw new Error("No response from other device");
+ }
+ const res = rawRes;
+ const {
+ key,
+ algorithm
+ } = res;
+ if (!algorithm || !ECDH_V2.matches(algorithm) || !key) {
+ throw new _.RendezvousError("Unsupported algorithm: " + algorithm, _.RendezvousFailureReason.UnsupportedAlgorithm);
+ }
+ this.theirPublicKey = (0, _olmlib.decodeBase64)(key);
+ } else {
+ // send our public key unencrypted
+ await this.transport.send({
+ algorithm: ECDH_V2.name,
+ key: (0, _olmlib.encodeUnpaddedBase64)(this.ourPublicKey)
+ });
+ }
+ this.connected = true;
+ this.olmSAS.set_their_key((0, _olmlib.encodeUnpaddedBase64)(this.theirPublicKey));
+ const initiatorKey = isInitiator ? this.ourPublicKey : this.theirPublicKey;
+ const recipientKey = isInitiator ? this.theirPublicKey : this.ourPublicKey;
+ let aesInfo = ECDH_V2.name;
+ aesInfo += `|${(0, _olmlib.encodeUnpaddedBase64)(initiatorKey)}`;
+ aesInfo += `|${(0, _olmlib.encodeUnpaddedBase64)(recipientKey)}`;
+ const aesKeyBytes = this.olmSAS.generate_bytes(aesInfo, 32);
+ this.aesKey = await importKey(aesKeyBytes);
+
+ // blank the bytes out to make sure not kept in memory
+ aesKeyBytes.fill(0);
+ const rawChecksum = this.olmSAS.generate_bytes(aesInfo, 5);
+ return (0, _SASDecimal.generateDecimalSas)(Array.from(rawChecksum)).join("-");
+ }
+ async encrypt(data) {
+ if (!_crypto.subtleCrypto) {
+ throw new Error("Web Crypto is not available");
+ }
+ const iv = new Uint8Array(32);
+ _crypto.crypto.getRandomValues(iv);
+ const encodedData = new _crypto.TextEncoder().encode(JSON.stringify(data));
+ const ciphertext = await _crypto.subtleCrypto.encrypt({
+ name: "AES-GCM",
+ iv,
+ tagLength: 128
+ }, this.aesKey, encodedData);
+ return {
+ iv: (0, _olmlib.encodeUnpaddedBase64)(iv),
+ ciphertext: (0, _olmlib.encodeUnpaddedBase64)(ciphertext)
+ };
+ }
+ async send(payload) {
+ if (!this.olmSAS) {
+ throw new Error("Channel closed");
+ }
+ if (!this.aesKey) {
+ throw new Error("Shared secret not set up");
+ }
+ return this.transport.send(await this.encrypt(payload));
+ }
+ async decrypt({
+ iv,
+ ciphertext
+ }) {
+ if (!ciphertext || !iv) {
+ throw new Error("Missing ciphertext and/or iv");
+ }
+ const ciphertextBytes = (0, _olmlib.decodeBase64)(ciphertext);
+ if (!_crypto.subtleCrypto) {
+ throw new Error("Web Crypto is not available");
+ }
+ const plaintext = await _crypto.subtleCrypto.decrypt({
+ name: "AES-GCM",
+ iv: (0, _olmlib.decodeBase64)(iv),
+ tagLength: 128
+ }, this.aesKey, ciphertextBytes);
+ return JSON.parse(new TextDecoder().decode(new Uint8Array(plaintext)));
+ }
+ async receive() {
+ if (!this.olmSAS) {
+ throw new Error("Channel closed");
+ }
+ if (!this.aesKey) {
+ throw new Error("Shared secret not set up");
+ }
+ const rawData = await this.transport.receive();
+ if (!rawData) {
+ return undefined;
+ }
+ const data = rawData;
+ if (data.ciphertext && data.iv) {
+ return this.decrypt(data);
+ }
+ throw new Error("Data received but no ciphertext");
+ }
+ async close() {
+ if (this.olmSAS) {
+ this.olmSAS.free();
+ this.olmSAS = undefined;
+ }
+ }
+ async cancel(reason) {
+ try {
+ await this.transport.cancel(reason);
+ } finally {
+ await this.close();
+ }
+ }
+}
+exports.MSC3903ECDHv2RendezvousChannel = MSC3903ECDHv2RendezvousChannel;
+//# sourceMappingURL=MSC3903ECDHv2RendezvousChannel.js.map \ No newline at end of file
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.js.map b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.js.map
new file mode 100644
index 0000000..e1ec1d9
--- /dev/null
+++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"MSC3903ECDHv2RendezvousChannel.js","names":["_","require","_olmlib","_crypto","_SASDecimal","_NamespacedValue","ECDH_V2","UnstableValue","importKey","key","subtleCrypto","Error","imported","name","MSC3903ECDHv2RendezvousChannel","constructor","transport","theirPublicKey","onFailure","_defineProperty2","default","olmSAS","global","Olm","SAS","ourPublicKey","decodeBase64","get_pubkey","generateCode","intent","ready","send","algorithm","rendezvous","encodeUnpaddedBase64","details","connect","connected","isInitiator","rawRes","receive","res","matches","RendezvousError","RendezvousFailureReason","UnsupportedAlgorithm","set_their_key","initiatorKey","recipientKey","aesInfo","aesKeyBytes","generate_bytes","aesKey","fill","rawChecksum","generateDecimalSas","Array","from","join","encrypt","data","iv","Uint8Array","crypto","getRandomValues","encodedData","TextEncoder","encode","JSON","stringify","ciphertext","tagLength","payload","decrypt","ciphertextBytes","plaintext","parse","TextDecoder","decode","rawData","undefined","close","free","cancel","reason","exports"],"sources":["../../../src/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { SAS } from \"@matrix-org/olm\";\n\nimport {\n RendezvousError,\n RendezvousCode,\n RendezvousIntent,\n RendezvousChannel,\n RendezvousTransportDetails,\n RendezvousTransport,\n RendezvousFailureReason,\n} from \"..\";\nimport { encodeUnpaddedBase64, decodeBase64 } from \"../../crypto/olmlib\";\nimport { crypto, subtleCrypto, TextEncoder } from \"../../crypto/crypto\";\nimport { generateDecimalSas } from \"../../crypto/verification/SASDecimal\";\nimport { UnstableValue } from \"../../NamespacedValue\";\n\nconst ECDH_V2 = new UnstableValue(\n \"m.rendezvous.v2.curve25519-aes-sha256\",\n \"org.matrix.msc3903.rendezvous.v2.curve25519-aes-sha256\",\n);\n\nexport interface ECDHv2RendezvousCode extends RendezvousCode {\n rendezvous: {\n transport: RendezvousTransportDetails;\n algorithm: typeof ECDH_V2.name | typeof ECDH_V2.altName;\n key: string;\n };\n}\n\nexport type MSC3903ECDHPayload = PlainTextPayload | EncryptedPayload;\n\nexport interface PlainTextPayload {\n algorithm: typeof ECDH_V2.name | typeof ECDH_V2.altName;\n key?: string;\n}\n\nexport interface EncryptedPayload {\n iv: string;\n ciphertext: string;\n}\n\nasync function importKey(key: Uint8Array): Promise<CryptoKey> {\n if (!subtleCrypto) {\n throw new Error(\"Web Crypto is not available\");\n }\n\n const imported = subtleCrypto.importKey(\"raw\", key, { name: \"AES-GCM\" }, false, [\"encrypt\", \"decrypt\"]);\n\n return imported;\n}\n\n/**\n * Implementation of the unstable [MSC3903](https://github.com/matrix-org/matrix-spec-proposals/pull/3903)\n * X25519/ECDH key agreement based secure rendezvous channel.\n * Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport class MSC3903ECDHv2RendezvousChannel<T> implements RendezvousChannel<T> {\n private olmSAS?: SAS;\n private ourPublicKey: Uint8Array;\n private aesKey?: CryptoKey;\n private connected = false;\n\n public constructor(\n private transport: RendezvousTransport<MSC3903ECDHPayload>,\n private theirPublicKey?: Uint8Array,\n public onFailure?: (reason: RendezvousFailureReason) => void,\n ) {\n this.olmSAS = new global.Olm.SAS();\n this.ourPublicKey = decodeBase64(this.olmSAS.get_pubkey());\n }\n\n public async generateCode(intent: RendezvousIntent): Promise<ECDHv2RendezvousCode> {\n if (this.transport.ready) {\n throw new Error(\"Code already generated\");\n }\n\n await this.transport.send({ algorithm: ECDH_V2.name });\n\n const rendezvous: ECDHv2RendezvousCode = {\n rendezvous: {\n algorithm: ECDH_V2.name,\n key: encodeUnpaddedBase64(this.ourPublicKey),\n transport: await this.transport.details(),\n },\n intent,\n };\n\n return rendezvous;\n }\n\n public async connect(): Promise<string> {\n if (this.connected) {\n throw new Error(\"Channel already connected\");\n }\n\n if (!this.olmSAS) {\n throw new Error(\"Channel closed\");\n }\n\n const isInitiator = !this.theirPublicKey;\n\n if (isInitiator) {\n // wait for the other side to send us their public key\n const rawRes = await this.transport.receive();\n if (!rawRes) {\n throw new Error(\"No response from other device\");\n }\n const res = rawRes as Partial<PlainTextPayload>;\n const { key, algorithm } = res;\n if (!algorithm || !ECDH_V2.matches(algorithm) || !key) {\n throw new RendezvousError(\n \"Unsupported algorithm: \" + algorithm,\n RendezvousFailureReason.UnsupportedAlgorithm,\n );\n }\n\n this.theirPublicKey = decodeBase64(key);\n } else {\n // send our public key unencrypted\n await this.transport.send({\n algorithm: ECDH_V2.name,\n key: encodeUnpaddedBase64(this.ourPublicKey),\n });\n }\n\n this.connected = true;\n\n this.olmSAS.set_their_key(encodeUnpaddedBase64(this.theirPublicKey!));\n\n const initiatorKey = isInitiator ? this.ourPublicKey : this.theirPublicKey!;\n const recipientKey = isInitiator ? this.theirPublicKey! : this.ourPublicKey;\n let aesInfo = ECDH_V2.name;\n aesInfo += `|${encodeUnpaddedBase64(initiatorKey)}`;\n aesInfo += `|${encodeUnpaddedBase64(recipientKey)}`;\n\n const aesKeyBytes = this.olmSAS.generate_bytes(aesInfo, 32);\n\n this.aesKey = await importKey(aesKeyBytes);\n\n // blank the bytes out to make sure not kept in memory\n aesKeyBytes.fill(0);\n\n const rawChecksum = this.olmSAS.generate_bytes(aesInfo, 5);\n return generateDecimalSas(Array.from(rawChecksum)).join(\"-\");\n }\n\n private async encrypt(data: T): Promise<MSC3903ECDHPayload> {\n if (!subtleCrypto) {\n throw new Error(\"Web Crypto is not available\");\n }\n\n const iv = new Uint8Array(32);\n crypto.getRandomValues(iv);\n\n const encodedData = new TextEncoder().encode(JSON.stringify(data));\n\n const ciphertext = await subtleCrypto.encrypt(\n {\n name: \"AES-GCM\",\n iv,\n tagLength: 128,\n },\n this.aesKey as CryptoKey,\n encodedData,\n );\n\n return {\n iv: encodeUnpaddedBase64(iv),\n ciphertext: encodeUnpaddedBase64(ciphertext),\n };\n }\n\n public async send(payload: T): Promise<void> {\n if (!this.olmSAS) {\n throw new Error(\"Channel closed\");\n }\n\n if (!this.aesKey) {\n throw new Error(\"Shared secret not set up\");\n }\n\n return this.transport.send(await this.encrypt(payload));\n }\n\n private async decrypt({ iv, ciphertext }: EncryptedPayload): Promise<Partial<T>> {\n if (!ciphertext || !iv) {\n throw new Error(\"Missing ciphertext and/or iv\");\n }\n\n const ciphertextBytes = decodeBase64(ciphertext);\n\n if (!subtleCrypto) {\n throw new Error(\"Web Crypto is not available\");\n }\n\n const plaintext = await subtleCrypto.decrypt(\n {\n name: \"AES-GCM\",\n iv: decodeBase64(iv),\n tagLength: 128,\n },\n this.aesKey as CryptoKey,\n ciphertextBytes,\n );\n\n return JSON.parse(new TextDecoder().decode(new Uint8Array(plaintext)));\n }\n\n public async receive(): Promise<Partial<T> | undefined> {\n if (!this.olmSAS) {\n throw new Error(\"Channel closed\");\n }\n if (!this.aesKey) {\n throw new Error(\"Shared secret not set up\");\n }\n\n const rawData = await this.transport.receive();\n if (!rawData) {\n return undefined;\n }\n const data = rawData as Partial<EncryptedPayload>;\n if (data.ciphertext && data.iv) {\n return this.decrypt(data as EncryptedPayload);\n }\n\n throw new Error(\"Data received but no ciphertext\");\n }\n\n public async close(): Promise<void> {\n if (this.olmSAS) {\n this.olmSAS.free();\n this.olmSAS = undefined;\n }\n }\n\n public async cancel(reason: RendezvousFailureReason): Promise<void> {\n try {\n await this.transport.cancel(reason);\n } finally {\n await this.close();\n }\n }\n}\n"],"mappings":";;;;;;;;AAkBA,IAAAA,CAAA,GAAAC,OAAA;AASA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AA9BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA,MAAMK,OAAO,GAAG,IAAIC,8BAAa,CAC7B,uCAAuC,EACvC,wDAAwD,CAC3D;AAsBD,eAAeC,SAASA,CAACC,GAAe,EAAsB;EAC1D,IAAI,CAACC,oBAAY,EAAE;IACf,MAAM,IAAIC,KAAK,CAAC,6BAA6B,CAAC;EAClD;EAEA,MAAMC,QAAQ,GAAGF,oBAAY,CAACF,SAAS,CAAC,KAAK,EAAEC,GAAG,EAAE;IAAEI,IAAI,EAAE;EAAU,CAAC,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;EAEvG,OAAOD,QAAQ;AACnB;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAME,8BAA8B,CAAoC;EAMpEC,WAAWA,CACNC,SAAkD,EAClDC,cAA2B,EAC5BC,SAAqD,EAC9D;IAAA,KAHUF,SAAkD,GAAlDA,SAAkD;IAAA,KAClDC,cAA2B,GAA3BA,cAA2B;IAAA,KAC5BC,SAAqD,GAArDA,SAAqD;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,qBAL5C,KAAK;IAOrB,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;EACJ;EAEA,MAAaG,MAAMA,CAACC,MAA+B,EAAiB;IAChE,IAAI;MACA,MAAM,IAAI,CAACpE,SAAS,CAACmE,MAAM,CAACC,MAAM,CAAC;IACvC,CAAC,SAAS;MACN,MAAM,IAAI,CAACH,KAAK,EAAE;IACtB;EACJ;AACJ;AAACI,OAAA,CAAAvE,8BAAA,GAAAA,8BAAA"} \ No newline at end of file
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.d.ts b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.d.ts
new file mode 100644
index 0000000..04a448a
--- /dev/null
+++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.d.ts
@@ -0,0 +1,2 @@
+export * from "./MSC3903ECDHv2RendezvousChannel";
+//# sourceMappingURL=index.d.ts.map \ No newline at end of file
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.d.ts.map b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.d.ts.map
new file mode 100644
index 0000000..5bbb544
--- /dev/null
+++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rendezvous/channels/index.ts"],"names":[],"mappings":"AAgBA,cAAc,kCAAkC,CAAC"} \ No newline at end of file
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.js b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.js
new file mode 100644
index 0000000..0c20fc0
--- /dev/null
+++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.js
@@ -0,0 +1,17 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+var _MSC3903ECDHv2RendezvousChannel = require("./MSC3903ECDHv2RendezvousChannel");
+Object.keys(_MSC3903ECDHv2RendezvousChannel).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (key in exports && exports[key] === _MSC3903ECDHv2RendezvousChannel[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function () {
+ return _MSC3903ECDHv2RendezvousChannel[key];
+ }
+ });
+});
+//# sourceMappingURL=index.js.map \ No newline at end of file
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.js.map b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.js.map
new file mode 100644
index 0000000..da2c50a
--- /dev/null
+++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/rendezvous/channels/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","names":["_MSC3903ECDHv2RendezvousChannel","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../src/rendezvous/channels/index.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport * from \"./MSC3903ECDHv2RendezvousChannel\";\n"],"mappings":";;;;;AAgBA,IAAAA,+BAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,+BAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,+BAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,+BAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"} \ No newline at end of file