Bug 1929264 - Update matrix-js-sdk to v34.11.1. r=clokep
Also bump dependencies Differential Revision: https://phabricator.services.mozilla.com/D228645 --HG-- extra : amend_source : 03bcf709c66bbf4b9d47509d4485cd8c0d47f344
This commit is contained in:
Родитель
4f36777c9b
Коммит
bf763663ff
|
@ -1,18 +1,18 @@
|
|||
This directory contains the Matrix Client-Server SDK for Javascript available
|
||||
at https://github.com/matrix-org/matrix-js-sdk/. Current version is v34.3.1.
|
||||
at https://github.com/matrix-org/matrix-js-sdk/. Current version is v34.11.1.
|
||||
|
||||
The following npm dependencies are included:
|
||||
|
||||
* @matrix-org/olm: https://gitlab.matrix.org/matrix-org/olm/-/packages?type=npm v3.2.15
|
||||
* another-json: https://www.npmjs.com/package/another-json/ v0.2.0
|
||||
* base-x: https://www.npmjs.com/package/base-x v4.0.0
|
||||
* bs58: https://www.npmjs.com/package/bs58 v5.0.0
|
||||
* base-x: https://www.npmjs.com/package/base-x v5.0.0
|
||||
* bs58: https://www.npmjs.com/package/bs58 v6.0.0
|
||||
* content-type: https://www.npmjs.com/package/content-type v1.0.5
|
||||
* events: https://www.npmjs.com/package/events v3.3.0
|
||||
* jwt-decode: https://www.npmjs.com/package/jwt-decode v4.0.0
|
||||
* matrix-events-sdk: https://www.npmjs.com/package/matrix-events-sdk v0.0.1
|
||||
* matrix-widget-api: https://www.npmjs.com/package/matrix-widget-api v1.6.0
|
||||
* oidc-client-ts: https://www.npmjs.com/package/oidc-client-ts v3.0.1
|
||||
* matrix-widget-api: https://www.npmjs.com/package/matrix-widget-api v1.9.0
|
||||
* oidc-client-ts: https://www.npmjs.com/package/oidc-client-ts v3.1.0
|
||||
* p-retry: https://www.npmjs.com/package/p-retry v4.6.2
|
||||
* retry: https://www.npmjs.com/package/retry v0.13.1
|
||||
* sdp-transform: https://www.npmjs.com/package/sdp-transform v2.14.2
|
||||
|
@ -73,13 +73,39 @@ module.exports = {
|
|||
modules: "commonjs",
|
||||
},
|
||||
],
|
||||
"@babel/preset-typescript",
|
||||
[
|
||||
"@babel/preset-typescript",
|
||||
{
|
||||
// When using the transpiled javascript in `lib`, Node.js requires `.js` extensions on any `import`
|
||||
// specifiers. However, Jest uses the TS source (via babel) and fails to resolve the `.js` names.
|
||||
// To resolve this,we use the `.ts` names in the source, and rewrite the `import` specifiers to use
|
||||
// `.js` during transpilation, *except* when we are targetting Jest.
|
||||
rewriteImportExtensions: process.env.NODE_ENV !== "test",
|
||||
},
|
||||
],
|
||||
],
|
||||
plugins: [
|
||||
"@babel/plugin-transform-numeric-separator",
|
||||
"@babel/plugin-transform-class-properties",
|
||||
"@babel/plugin-transform-object-rest-spread",
|
||||
"@babel/plugin-syntax-dynamic-import",
|
||||
[
|
||||
"search-and-replace",
|
||||
{
|
||||
// Since rewriteImportExtensions doesn't work on dynamic imports (yet), we need to manually replace
|
||||
// the dynamic rust-crypto import.
|
||||
// (see https://github.com/babel/babel/issues/16750)
|
||||
rules:
|
||||
process.env.NODE_ENV !== "test"
|
||||
? [
|
||||
{
|
||||
search: "./rust-crypto/index.ts",
|
||||
replace: "./rust-crypto/index.js",
|
||||
},
|
||||
]
|
||||
: [],
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
```
|
||||
|
@ -106,7 +132,7 @@ sub-directory.
|
|||
```sh
|
||||
cp ../../matrix-js-sdk/node_modules/another-json/another-json.js chat/protocols/matrix/lib/another-json
|
||||
cp ../../matrix-js-sdk/node_modules/base-x/src/index.js chat/protocols/matrix/lib/base-x
|
||||
cp ../../matrix-js-sdk/node_modules/bs58/index.js chat/protocols/matrix/lib/bs58
|
||||
cp ../../matrix-js-sdk/node_modules/bs58/src/cjs/index.cjs chat/protocols/matrix/lib/bs58/index.js
|
||||
cp ../../matrix-js-sdk/node_modules/content-type/index.js chat/protocols/matrix/lib/content-type
|
||||
cp ../../matrix-js-sdk/node_modules/oidc-client-ts/dist/umd/oidc-client-ts.js chat/protocols/matrix/lib/oidc-client-ts
|
||||
cp ../../matrix-js-sdk/node_modules/jwt-decode/build/cjs/index.js chat/protocols/matrix/lib/jwt-decode
|
||||
|
|
|
@ -77,7 +77,7 @@ function base (ALPHABET) {
|
|||
var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
|
||||
var b256 = new Uint8Array(size)
|
||||
// Process the characters.
|
||||
while (source[psz]) {
|
||||
while (psz < source.length) {
|
||||
// Decode character
|
||||
var carry = BASE_MAP[source.charCodeAt(psz)]
|
||||
// Invalid character
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
const basex = require('base-x')
|
||||
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
||||
|
||||
module.exports = basex(ALPHABET)
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var base_x_1 = __importDefault(require("base-x"));
|
||||
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
exports.default = (0, base_x_1.default)(ALPHABET);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.SSOAction = exports.IdentityProviderBrand = exports.DELEGATED_OIDC_COMPATIBILITY = void 0;
|
||||
var _NamespacedValue = require("../NamespacedValue");
|
||||
var _NamespacedValue = require("../NamespacedValue.js");
|
||||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.M_BEACON_INFO = exports.M_BEACON = void 0;
|
||||
var _NamespacedValue = require("../NamespacedValue");
|
||||
var _NamespacedValue = require("../NamespacedValue.js");
|
||||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.UNSTABLE_MSC3089_TREE_SUBTYPE = exports.UNSTABLE_MSC3089_LEAF = exports.UNSTABLE_MSC3089_BRANCH = exports.UNSTABLE_MSC3088_PURPOSE = exports.UNSTABLE_MSC3088_ENABLED = exports.UNSTABLE_MSC2716_MARKER = exports.UNSTABLE_ELEMENT_FUNCTIONAL_USERS = exports.UNSIGNED_THREAD_ID_FIELD = exports.UNSIGNED_MEMBERSHIP_FIELD = exports.ToDeviceMessageId = exports.RoomType = exports.RoomCreateTypeField = exports.RelationType = exports.PUSHER_ENABLED = exports.PUSHER_DEVICE_ID = exports.MsgType = exports.MSC3912_RELATION_BASED_REDACTIONS_PROP = exports.LOCAL_NOTIFICATION_SETTINGS_PREFIX = exports.EventType = exports.EVENT_VISIBILITY_CHANGE_TYPE = void 0;
|
||||
var _NamespacedValue = require("../NamespacedValue");
|
||||
var _beacon = require("./beacon");
|
||||
var _polls = require("./polls");
|
||||
var _NamespacedValue = require("../NamespacedValue.js");
|
||||
var _beacon = require("./beacon.js");
|
||||
var _polls = require("./polls.js");
|
||||
/*
|
||||
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
exports.REFERENCE_RELATION = exports.M_TEXT = exports.M_MESSAGE = exports.M_HTML = void 0;
|
||||
exports.isEventTypeSame = isEventTypeSame;
|
||||
var _matrixEventsSdk = require("matrix-events-sdk");
|
||||
var _utilities = require("../extensible_events_v1/utilities");
|
||||
var _utilities = require("../extensible_events_v1/utilities.js");
|
||||
/*
|
||||
Copyright 2021 - 2023 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.M_TIMESTAMP = exports.M_LOCATION = exports.M_ASSET = exports.LocationAssetType = void 0;
|
||||
var _NamespacedValue = require("../NamespacedValue");
|
||||
var _extensible_events = require("./extensible_events");
|
||||
var _NamespacedValue = require("../NamespacedValue.js");
|
||||
var _extensible_events = require("./extensible_events.js");
|
||||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.UNREAD_THREAD_NOTIFICATIONS = void 0;
|
||||
var _NamespacedValue = require("../NamespacedValue");
|
||||
var _NamespacedValue = require("../NamespacedValue.js");
|
||||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.M_TOPIC = void 0;
|
||||
var _NamespacedValue = require("../NamespacedValue");
|
||||
var _NamespacedValue = require("../NamespacedValue.js");
|
||||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.ToDeviceMessageQueue = void 0;
|
||||
var _event = require("./@types/event");
|
||||
var _logger = require("./logger");
|
||||
var _client = require("./client");
|
||||
var _scheduler = require("./scheduler");
|
||||
var _sync = require("./sync");
|
||||
var _utils = require("./utils");
|
||||
var _event = require("./@types/event.js");
|
||||
var _logger = require("./logger.js");
|
||||
var _client = require("./client.js");
|
||||
var _scheduler = require("./scheduler.js");
|
||||
var _sync = require("./sync.js");
|
||||
var _utils = require("./utils.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.AutoDiscoveryError = exports.AutoDiscoveryAction = exports.AutoDiscovery = void 0;
|
||||
var _logger = require("./logger");
|
||||
var _httpApi = require("./http-api");
|
||||
var _versionSupport = require("./version-support");
|
||||
var _logger = require("./logger.js");
|
||||
var _index = require("./http-api/index.js");
|
||||
var _versionSupport = require("./version-support.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -365,8 +365,8 @@ class AutoDiscovery {
|
|||
let response;
|
||||
try {
|
||||
response = await AutoDiscovery.fetch(url, {
|
||||
method: _httpApi.Method.Get,
|
||||
signal: (0, _httpApi.timeoutSignal)(5000)
|
||||
method: _index.Method.Get,
|
||||
signal: (0, _index.timeoutSignal)(5000)
|
||||
});
|
||||
if (response.status === 404) {
|
||||
return {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var matrixcs = _interopRequireWildcard(require("./matrix"));
|
||||
var matrixcs = _interopRequireWildcard(require("./matrix.js"));
|
||||
Object.keys(matrixcs).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === matrixcs[key]) return;
|
||||
|
@ -41,7 +41,7 @@ globalThis.__js_sdk_entrypoint = true;
|
|||
let indexedDB;
|
||||
try {
|
||||
indexedDB = globalThis.indexedDB;
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
|
||||
// if our browser (appears to) support indexeddb, use an indexeddb crypto store.
|
||||
if (indexedDB) {
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.keyFromAuthData = keyFromAuthData;
|
||||
var _index = require("../crypto-api/index.js");
|
||||
/*
|
||||
* Copyright 2024 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.
|
||||
*/
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
/**
|
||||
* Derive a backup key from a passphrase using the salt and iterations from the auth data.
|
||||
* @param authData - The auth data containing the salt and iterations
|
||||
* @param passphrase - The passphrase to derive the key from
|
||||
* @deprecated Deriving a backup key from a passphrase is not part of the matrix spec. Instead, a random key is generated and stored/shared via 4S.
|
||||
*/
|
||||
function keyFromAuthData(authData, passphrase) {
|
||||
if (!authData.private_key_salt || !authData.private_key_iterations) {
|
||||
throw new Error("Salt and/or iterations not found: " + "this backup cannot be restored with a passphrase");
|
||||
}
|
||||
return (0, _index.deriveRecoveryKeyFromPassphrase)(passphrase, authData.private_key_salt, authData.private_key_iterations, authData.private_key_bits);
|
||||
}
|
|
@ -12,11 +12,11 @@ exports.makeLocationContent = void 0;
|
|||
exports.makeNotice = makeNotice;
|
||||
exports.makeTextMessage = makeTextMessage;
|
||||
exports.parseTopicContent = exports.parseLocationEvent = exports.parseBeaconInfoContent = exports.parseBeaconContent = exports.makeTopicContent = void 0;
|
||||
var _event = require("./@types/event");
|
||||
var _extensible_events = require("./@types/extensible_events");
|
||||
var _utilities = require("./extensible_events_v1/utilities");
|
||||
var _location = require("./@types/location");
|
||||
var _topic = require("./@types/topic");
|
||||
var _event = require("./@types/event.js");
|
||||
var _extensible_events = require("./@types/extensible_events.js");
|
||||
var _utilities = require("./extensible_events_v1/utilities.js");
|
||||
var _location = require("./@types/location.js");
|
||||
var _topic = require("./@types/topic.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,9 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.getHttpUriForMxc = getHttpUriForMxc;
|
||||
var _utils = require("./utils");
|
||||
/*
|
||||
Copyright 2015 - 2021 The Matrix.org Foundation C.I.C.
|
||||
Copyright 2015 - 2024 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.
|
||||
|
@ -21,6 +20,22 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Validation based on https://spec.matrix.org/v1.12/appendices/#server-name
|
||||
// We do not use the validation described in https://spec.matrix.org/v1.12/client-server-api/#security-considerations-5
|
||||
// as it'd wrongly make all MXCs invalid due to not allowing `[].:` in server names.
|
||||
const serverNameRegex = /^(?:(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|(?:\[[\dA-Fa-f:.]{2,45}])|(?:[A-Za-z\d\-.]{1,255}))(?::\d{1,5})?$/;
|
||||
function validateServerName(serverName) {
|
||||
const matches = serverNameRegex.exec(serverName);
|
||||
return matches?.[0] === serverName;
|
||||
}
|
||||
|
||||
// Validation based on https://spec.matrix.org/v1.12/client-server-api/#security-considerations-5
|
||||
const mediaIdRegex = /^[\w-]+$/;
|
||||
function validateMediaId(mediaId) {
|
||||
const matches = mediaIdRegex.exec(mediaId);
|
||||
return matches?.[0] === mediaId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP URL for an MXC URI.
|
||||
* @param baseUrl - The base homeserver url which has a content repo.
|
||||
|
@ -41,19 +56,23 @@ limitations under the License.
|
|||
* for authenticated media will *not* be checked - it is the caller's responsibility
|
||||
* to do so before calling this function. Note also that `useAuthentication`
|
||||
* implies `allowRedirects`. Defaults to false (unauthenticated endpoints).
|
||||
* @returns The complete URL to the content.
|
||||
* @returns The complete URL to the content, may be an empty string if the provided mxc is not valid.
|
||||
*/
|
||||
function getHttpUriForMxc(baseUrl, mxc, width, height, resizeMethod, allowDirectLinks = false, allowRedirects, useAuthentication) {
|
||||
if (typeof mxc !== "string" || !mxc) {
|
||||
return "";
|
||||
}
|
||||
if (mxc.indexOf("mxc://") !== 0) {
|
||||
if (!mxc.startsWith("mxc://")) {
|
||||
if (allowDirectLinks) {
|
||||
return mxc;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
const [serverName, mediaId, ...rest] = mxc.slice(6).split("/");
|
||||
if (rest.length > 0 || !validateServerName(serverName) || !validateMediaId(mediaId)) {
|
||||
return "";
|
||||
}
|
||||
if (useAuthentication) {
|
||||
allowRedirects = true; // per docs (MSC3916 always expects redirects)
|
||||
|
||||
|
@ -61,42 +80,27 @@ function getHttpUriForMxc(baseUrl, mxc, width, height, resizeMethod, allowDirect
|
|||
// for explicitness we set it here. This makes it slightly more obvious to
|
||||
// callers, hopefully.
|
||||
}
|
||||
let serverAndMediaId = mxc.slice(6); // strips mxc://
|
||||
let prefix;
|
||||
const isThumbnailRequest = !!width || !!height || !!resizeMethod;
|
||||
const verb = isThumbnailRequest ? "thumbnail" : "download";
|
||||
if (useAuthentication) {
|
||||
prefix = "/_matrix/client/v1/media/download/";
|
||||
prefix = `/_matrix/client/v1/media/${verb}`;
|
||||
} else {
|
||||
prefix = "/_matrix/media/v3/download/";
|
||||
prefix = `/_matrix/media/v3/${verb}`;
|
||||
}
|
||||
const params = {};
|
||||
const url = new URL(`${prefix}/${serverName}/${mediaId}`, baseUrl);
|
||||
if (width) {
|
||||
params["width"] = Math.round(width).toString();
|
||||
url.searchParams.set("width", Math.round(width).toString());
|
||||
}
|
||||
if (height) {
|
||||
params["height"] = Math.round(height).toString();
|
||||
url.searchParams.set("height", Math.round(height).toString());
|
||||
}
|
||||
if (resizeMethod) {
|
||||
params["method"] = resizeMethod;
|
||||
}
|
||||
if (Object.keys(params).length > 0) {
|
||||
// these are thumbnailing params so they probably want the
|
||||
// thumbnailing API...
|
||||
if (useAuthentication) {
|
||||
prefix = "/_matrix/client/v1/media/thumbnail/";
|
||||
} else {
|
||||
prefix = "/_matrix/media/v3/thumbnail/";
|
||||
}
|
||||
url.searchParams.set("method", resizeMethod);
|
||||
}
|
||||
if (typeof allowRedirects === "boolean") {
|
||||
// We add this after, so we don't convert everything to a thumbnail request.
|
||||
params["allow_redirect"] = JSON.stringify(allowRedirects);
|
||||
url.searchParams.set("allow_redirect", JSON.stringify(allowRedirects));
|
||||
}
|
||||
const fragmentOffset = serverAndMediaId.indexOf("#");
|
||||
let fragment = "";
|
||||
if (fragmentOffset >= 0) {
|
||||
fragment = serverAndMediaId.slice(fragmentOffset);
|
||||
serverAndMediaId = serverAndMediaId.slice(0, fragmentOffset);
|
||||
}
|
||||
const urlParams = Object.keys(params).length === 0 ? "" : "?" + (0, _utils.encodeParams)(params);
|
||||
return baseUrl + prefix + serverAndMediaId + urlParams + fragment;
|
||||
return url.href;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.CryptoEvent = void 0;
|
||||
/*
|
||||
* Copyright 2024 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.
|
||||
*/
|
||||
/**
|
||||
* Events emitted by the {@link CryptoApi}
|
||||
*/
|
||||
let CryptoEvent = exports.CryptoEvent = /*#__PURE__*/function (CryptoEvent) {
|
||||
CryptoEvent["UserTrustStatusChanged"] = "userTrustStatusChanged";
|
||||
CryptoEvent["KeyBackupStatus"] = "crypto.keyBackupStatus";
|
||||
CryptoEvent["KeyBackupFailed"] = "crypto.keyBackupFailed";
|
||||
CryptoEvent["KeyBackupSessionsRemaining"] = "crypto.keyBackupSessionsRemaining";
|
||||
CryptoEvent["KeyBackupDecryptionKeyCached"] = "crypto.keyBackupDecryptionKeyCached";
|
||||
CryptoEvent["VerificationRequestReceived"] = "crypto.verificationRequestReceived";
|
||||
CryptoEvent["WillUpdateDevices"] = "crypto.willUpdateDevices";
|
||||
CryptoEvent["DevicesUpdated"] = "crypto.devicesUpdated";
|
||||
CryptoEvent["KeysChanged"] = "crossSigning.keysChanged";
|
||||
CryptoEvent["LegacyCryptoStoreMigrationProgress"] = "crypto.legacyCryptoStoreMigrationProgress";
|
||||
return CryptoEvent;
|
||||
}({});
|
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
|
||||
var _CryptoEvent = require("./CryptoEvent.js");
|
|
@ -5,14 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
var _exportNames = {
|
||||
DecryptionFailureCode: true,
|
||||
DeviceIsolationModeKind: true,
|
||||
AllDevicesIsolationMode: true,
|
||||
OnlySignedDevicesIsolationMode: true,
|
||||
UserVerificationStatus: true,
|
||||
DeviceVerificationStatus: true,
|
||||
CrossSigningKey: true,
|
||||
EventShieldColour: true,
|
||||
EventShieldReason: true
|
||||
};
|
||||
exports.UserVerificationStatus = exports.EventShieldReason = exports.EventShieldColour = exports.DeviceVerificationStatus = exports.DecryptionFailureCode = exports.CrossSigningKey = void 0;
|
||||
var _verification = require("./verification");
|
||||
exports.UserVerificationStatus = exports.OnlySignedDevicesIsolationMode = exports.EventShieldReason = exports.EventShieldColour = exports.DeviceVerificationStatus = exports.DeviceIsolationModeKind = exports.DecryptionFailureCode = exports.CrossSigningKey = exports.AllDevicesIsolationMode = void 0;
|
||||
var _verification = require("./verification.js");
|
||||
Object.keys(_verification).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -24,15 +27,39 @@ Object.keys(_verification).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _keybackup = require("./keybackup");
|
||||
Object.keys(_keybackup).forEach(function (key) {
|
||||
var _recoveryKey = require("./recovery-key.js");
|
||||
Object.keys(_recoveryKey).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _keybackup[key]) return;
|
||||
if (key in exports && exports[key] === _recoveryKey[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keybackup[key];
|
||||
return _recoveryKey[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _keyPassphrase = require("./key-passphrase.js");
|
||||
Object.keys(_keyPassphrase).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _keyPassphrase[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyPassphrase[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _CryptoEvent = require("./CryptoEvent.js");
|
||||
Object.keys(_CryptoEvent).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _CryptoEvent[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _CryptoEvent[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -54,6 +81,14 @@ 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.
|
||||
*/
|
||||
/**
|
||||
* `matrix-js-sdk/lib/crypto-api`: End-to-end encryption support.
|
||||
*
|
||||
* The most important type is {@link CryptoApi}, an instance of which can be retrieved via
|
||||
* {@link MatrixClient.getCrypto}.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
/**
|
||||
* Public interface to the cryptography parts of the js-sdk
|
||||
*
|
||||
|
@ -69,6 +104,9 @@ let DecryptionFailureCode = exports.DecryptionFailureCode = /*#__PURE__*/functio
|
|||
DecryptionFailureCode["HISTORICAL_MESSAGE_BACKUP_UNCONFIGURED"] = "HISTORICAL_MESSAGE_BACKUP_UNCONFIGURED";
|
||||
DecryptionFailureCode["HISTORICAL_MESSAGE_WORKING_BACKUP"] = "HISTORICAL_MESSAGE_WORKING_BACKUP";
|
||||
DecryptionFailureCode["HISTORICAL_MESSAGE_USER_NOT_JOINED"] = "HISTORICAL_MESSAGE_USER_NOT_JOINED";
|
||||
DecryptionFailureCode["SENDER_IDENTITY_PREVIOUSLY_VERIFIED"] = "SENDER_IDENTITY_PREVIOUSLY_VERIFIED";
|
||||
DecryptionFailureCode["UNSIGNED_SENDER_DEVICE"] = "UNSIGNED_SENDER_DEVICE";
|
||||
DecryptionFailureCode["UNKNOWN_SENDER_DEVICE"] = "UNKNOWN_SENDER_DEVICE";
|
||||
DecryptionFailureCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
||||
DecryptionFailureCode["MEGOLM_BAD_ROOM"] = "MEGOLM_BAD_ROOM";
|
||||
DecryptionFailureCode["MEGOLM_MISSING_FIELDS"] = "MEGOLM_MISSING_FIELDS";
|
||||
|
@ -85,17 +123,89 @@ let DecryptionFailureCode = exports.DecryptionFailureCode = /*#__PURE__*/functio
|
|||
DecryptionFailureCode["UNKNOWN_ENCRYPTION_ALGORITHM"] = "UNKNOWN_ENCRYPTION_ALGORITHM";
|
||||
return DecryptionFailureCode;
|
||||
}({});
|
||||
/** Base {@link DeviceIsolationMode} kind. */
|
||||
let DeviceIsolationModeKind = exports.DeviceIsolationModeKind = /*#__PURE__*/function (DeviceIsolationModeKind) {
|
||||
DeviceIsolationModeKind[DeviceIsolationModeKind["AllDevicesIsolationMode"] = 0] = "AllDevicesIsolationMode";
|
||||
DeviceIsolationModeKind[DeviceIsolationModeKind["OnlySignedDevicesIsolationMode"] = 1] = "OnlySignedDevicesIsolationMode";
|
||||
return DeviceIsolationModeKind;
|
||||
}({});
|
||||
/**
|
||||
* A type of {@link DeviceIsolationMode}.
|
||||
*
|
||||
* Message encryption keys are shared with all devices in the room, except in case of
|
||||
* verified user problems (see {@link errorOnVerifiedUserProblems}).
|
||||
*
|
||||
* Events from all senders are always decrypted (and should be decorated with message shields in case
|
||||
* of authenticity warnings, see {@link EventEncryptionInfo}).
|
||||
*/
|
||||
class AllDevicesIsolationMode {
|
||||
/**
|
||||
*
|
||||
* @param errorOnVerifiedUserProblems - Behavior when sharing keys to remote devices.
|
||||
*
|
||||
* If set to `true`, sharing keys will fail (i.e. message sending will fail) with an error if:
|
||||
* - The user was previously verified but is not anymore, or:
|
||||
* - A verified user has some unverified devices (not cross-signed).
|
||||
*
|
||||
* If `false`, the keys will be distributed as usual. In this case, the client UX should display
|
||||
* warnings to inform the user about problematic devices/users, and stop them hitting this case.
|
||||
*/
|
||||
constructor(errorOnVerifiedUserProblems) {
|
||||
this.errorOnVerifiedUserProblems = errorOnVerifiedUserProblems;
|
||||
_defineProperty(this, "kind", DeviceIsolationModeKind.AllDevicesIsolationMode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A type of {@link DeviceIsolationMode}.
|
||||
*
|
||||
* Message encryption keys are only shared with devices that have been cross-signed by their owner.
|
||||
* Encryption will throw an error if a verified user replaces their identity.
|
||||
*
|
||||
* Events are decrypted only if they come from a cross-signed device. Other events will result in a decryption
|
||||
* failure. (To access the failure reason, see {@link MatrixEvent.decryptionFailureReason}.)
|
||||
*/
|
||||
exports.AllDevicesIsolationMode = AllDevicesIsolationMode;
|
||||
class OnlySignedDevicesIsolationMode {
|
||||
constructor() {
|
||||
_defineProperty(this, "kind", DeviceIsolationModeKind.OnlySignedDevicesIsolationMode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DeviceIsolationMode represents the mode of device isolation used when encrypting or decrypting messages.
|
||||
* It can be one of two types: {@link AllDevicesIsolationMode} or {@link OnlySignedDevicesIsolationMode}.
|
||||
*
|
||||
* Only supported by rust Crypto.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Options object for `CryptoApi.bootstrapCrossSigning`.
|
||||
*/
|
||||
exports.OnlySignedDevicesIsolationMode = OnlySignedDevicesIsolationMode;
|
||||
/**
|
||||
* Represents the ways in which we trust a user
|
||||
*/
|
||||
class UserVerificationStatus {
|
||||
constructor(crossSigningVerified, crossSigningVerifiedBefore, tofu) {
|
||||
constructor(crossSigningVerified, crossSigningVerifiedBefore, tofu, needsUserApproval = false) {
|
||||
this.crossSigningVerified = crossSigningVerified;
|
||||
this.crossSigningVerifiedBefore = crossSigningVerifiedBefore;
|
||||
this.tofu = tofu;
|
||||
/**
|
||||
* Indicates if the identity has changed in a way that needs user approval.
|
||||
*
|
||||
* This happens if the identity has changed since we first saw it, *unless* the new identity has also been verified
|
||||
* by our user (eg via an interactive verification).
|
||||
*
|
||||
* To rectify this, either:
|
||||
*
|
||||
* * Conduct a verification of the new identity via {@link CryptoApi.requestVerificationDM}.
|
||||
* * Pin the new identity, via {@link CryptoApi.pinCurrentUserIdentity}.
|
||||
*
|
||||
* @returns true if the identity has changed in a way that needs user approval.
|
||||
*/
|
||||
_defineProperty(this, "needsUserApproval", void 0);
|
||||
this.needsUserApproval = needsUserApproval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,6 +232,8 @@ class UserVerificationStatus {
|
|||
|
||||
/**
|
||||
* @returns true if this user's key is trusted on first use
|
||||
*
|
||||
* @deprecated No longer supported, with the Rust crypto stack.
|
||||
*/
|
||||
isTofu() {
|
||||
return this.tofu;
|
||||
|
@ -166,9 +278,9 @@ class DeviceVerificationStatus {
|
|||
* Check if we should consider this device "verified".
|
||||
*
|
||||
* A device is "verified" if either:
|
||||
* * it has been manually marked as such via {@link MatrixClient#setDeviceVerified}.
|
||||
* * it has been manually marked as such via {@link matrix.MatrixClient.setDeviceVerified}.
|
||||
* * it has been cross-signed with a verified signing key, **and** the client has been configured to trust
|
||||
* cross-signed devices via {@link Crypto.CryptoApi#setTrustCrossSignedDevices}.
|
||||
* cross-signed devices via {@link CryptoApi.setTrustCrossSignedDevices}.
|
||||
*
|
||||
* @returns true if this device is verified via any means.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.deriveRecoveryKeyFromPassphrase = deriveRecoveryKeyFromPassphrase;
|
||||
/*
|
||||
* Copyright 2024 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 DEFAULT_BIT_SIZE = 256;
|
||||
|
||||
/**
|
||||
* Derive a recovery key from a passphrase and salt using PBKDF2.
|
||||
* @see https://spec.matrix.org/v1.11/client-server-api/#deriving-keys-from-passphrases
|
||||
*
|
||||
* @param passphrase - The passphrase to derive the key from
|
||||
* @param salt - The salt to use in the derivation
|
||||
* @param iterations - The number of iterations to use in the derivation
|
||||
* @param numBits - The number of bits to derive
|
||||
*/
|
||||
async function deriveRecoveryKeyFromPassphrase(passphrase, salt, iterations, numBits = DEFAULT_BIT_SIZE) {
|
||||
if (!globalThis.crypto.subtle || !TextEncoder) {
|
||||
throw new Error("Password-based backup is not available on this platform");
|
||||
}
|
||||
const key = await globalThis.crypto.subtle.importKey("raw", new TextEncoder().encode(passphrase), {
|
||||
name: "PBKDF2"
|
||||
}, false, ["deriveBits"]);
|
||||
const keybits = await globalThis.crypto.subtle.deriveBits({
|
||||
name: "PBKDF2",
|
||||
salt: new TextEncoder().encode(salt),
|
||||
iterations: iterations,
|
||||
hash: "SHA-512"
|
||||
}, key, numBits);
|
||||
return new Uint8Array(keybits);
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.decodeRecoveryKey = decodeRecoveryKey;
|
||||
exports.encodeRecoveryKey = encodeRecoveryKey;
|
||||
var _bs = _interopRequireDefault(require("bs58"));
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
/*
|
||||
* Copyright 2024 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.
|
||||
*/
|
||||
|
||||
// picked arbitrarily but to try & avoid clashing with any bitcoin ones
|
||||
// (which are also base58 encoded, but bitcoin's involve a lot more hashing)
|
||||
const OLM_RECOVERY_KEY_PREFIX = [0x8b, 0x01];
|
||||
const KEY_SIZE = 32;
|
||||
|
||||
/**
|
||||
* Encode a recovery key using the Matrix {@link https://spec.matrix.org/v1.11/appendices/#cryptographic-key-representation | Cryptographic key representation}
|
||||
* @param key
|
||||
*/
|
||||
function encodeRecoveryKey(key) {
|
||||
const buf = Buffer.alloc(OLM_RECOVERY_KEY_PREFIX.length + key.length + 1);
|
||||
buf.set(OLM_RECOVERY_KEY_PREFIX, 0);
|
||||
buf.set(key, OLM_RECOVERY_KEY_PREFIX.length);
|
||||
let parity = 0;
|
||||
for (let i = 0; i < buf.length - 1; ++i) {
|
||||
parity ^= buf[i];
|
||||
}
|
||||
buf[buf.length - 1] = parity;
|
||||
const base58key = _bs.default.encode(buf);
|
||||
return base58key.match(/.{1,4}/g)?.join(" ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a recovery key encoded with the Matrix {@link https://spec.matrix.org/v1.11/appendices/#cryptographic-key-representation | Cryptographic key representation} encoding.
|
||||
* @param recoveryKey
|
||||
*/
|
||||
function decodeRecoveryKey(recoveryKey) {
|
||||
const result = _bs.default.decode(recoveryKey.replace(/ /g, ""));
|
||||
let parity = 0;
|
||||
for (const b of result) {
|
||||
parity ^= b;
|
||||
}
|
||||
if (parity !== 0) {
|
||||
throw new Error("Incorrect parity");
|
||||
}
|
||||
for (let i = 0; i < OLM_RECOVERY_KEY_PREFIX.length; ++i) {
|
||||
if (result[i] !== OLM_RECOVERY_KEY_PREFIX[i]) {
|
||||
throw new Error("Incorrect prefix");
|
||||
}
|
||||
}
|
||||
if (result.length !== OLM_RECOVERY_KEY_PREFIX.length + KEY_SIZE + 1) {
|
||||
throw new Error("Incorrect length");
|
||||
}
|
||||
return Uint8Array.from(result.slice(OLM_RECOVERY_KEY_PREFIX.length, OLM_RECOVERY_KEY_PREFIX.length + KEY_SIZE));
|
||||
}
|
|
@ -7,17 +7,19 @@ exports.DeviceTrustLevel = exports.CrossSigningLevel = exports.CrossSigningInfo
|
|||
Object.defineProperty(exports, "UserTrustLevel", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _cryptoApi.UserVerificationStatus;
|
||||
return _index.UserVerificationStatus;
|
||||
}
|
||||
});
|
||||
exports.createCryptoStoreCacheCallbacks = createCryptoStoreCacheCallbacks;
|
||||
exports.requestKeysDuringVerification = requestKeysDuringVerification;
|
||||
var _olmlib = require("./olmlib");
|
||||
var _logger = require("../logger");
|
||||
var _indexeddbCryptoStore = require("../crypto/store/indexeddb-crypto-store");
|
||||
var _aes = require("./aes");
|
||||
var _cryptoApi = require("../crypto-api");
|
||||
var _base = require("../base64");
|
||||
var _olmlib = require("./olmlib.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _indexeddbCryptoStore = require("../crypto/store/indexeddb-crypto-store.js");
|
||||
var _index = require("../crypto-api/index.js");
|
||||
var _base = require("../base64.js");
|
||||
var _encryptAESSecretStorageItem = _interopRequireDefault(require("../utils/encryptAESSecretStorageItem.js"));
|
||||
var _decryptAESSecretStorageItem = _interopRequireDefault(require("../utils/decryptAESSecretStorageItem.js"));
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -453,12 +455,12 @@ class CrossSigningInfo {
|
|||
// if we're checking our own key, then it's trusted if the master key
|
||||
// and self-signing key match
|
||||
if (this.userId === userCrossSigning.userId && this.getId() && this.getId() === userCrossSigning.getId() && this.getId("self_signing") && this.getId("self_signing") === userCrossSigning.getId("self_signing")) {
|
||||
return new _cryptoApi.UserVerificationStatus(true, true, this.firstUse);
|
||||
return new _index.UserVerificationStatus(true, true, this.firstUse);
|
||||
}
|
||||
if (!this.keys.user_signing) {
|
||||
// If there's no user signing key, they can't possibly be verified.
|
||||
// They may be TOFU trusted though.
|
||||
return new _cryptoApi.UserVerificationStatus(false, false, userCrossSigning.firstUse);
|
||||
return new _index.UserVerificationStatus(false, false, userCrossSigning.firstUse);
|
||||
}
|
||||
let userTrusted;
|
||||
const userMaster = userCrossSigning.keys.master;
|
||||
|
@ -466,10 +468,10 @@ class CrossSigningInfo {
|
|||
try {
|
||||
(0, _olmlib.pkVerify)(userMaster, uskId, this.userId);
|
||||
userTrusted = true;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
userTrusted = false;
|
||||
}
|
||||
return new _cryptoApi.UserVerificationStatus(userTrusted, userCrossSigning.crossSigningVerifiedBefore, userCrossSigning.firstUse);
|
||||
return new _index.UserVerificationStatus(userTrusted, userCrossSigning.crossSigningVerifiedBefore, userCrossSigning.firstUse);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -498,7 +500,7 @@ class CrossSigningInfo {
|
|||
(0, _olmlib.pkVerify)(deviceObj, publicKeyFromKeyInfo(userSSK), userCrossSigning.userId);
|
||||
// ...then we trust this device as much as far as we trust the user
|
||||
return DeviceTrustLevel.fromUserTrustLevel(userTrust, localTrust, trustCrossSignedDevices);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return new DeviceTrustLevel(false, false, localTrust, trustCrossSignedDevices);
|
||||
}
|
||||
}
|
||||
|
@ -531,7 +533,7 @@ let CrossSigningLevel = exports.CrossSigningLevel = /*#__PURE__*/function (Cross
|
|||
*
|
||||
* @deprecated Use {@link DeviceVerificationStatus}.
|
||||
*/
|
||||
class DeviceTrustLevel extends _cryptoApi.DeviceVerificationStatus {
|
||||
class DeviceTrustLevel extends _index.DeviceVerificationStatus {
|
||||
constructor(crossSigningVerified, tofu, localVerified, trustCrossSignedDevices, signedByOwner = false) {
|
||||
super({
|
||||
crossSigningVerified,
|
||||
|
@ -578,7 +580,7 @@ function createCryptoStoreCacheCallbacks(store, olmDevice) {
|
|||
});
|
||||
if (key && key.ciphertext) {
|
||||
const pickleKey = Buffer.from(olmDevice.pickleKey);
|
||||
const decrypted = await (0, _aes.decryptAES)(key, pickleKey, type);
|
||||
const decrypted = await (0, _decryptAESSecretStorageItem.default)(key, pickleKey, type);
|
||||
return (0, _base.decodeBase64)(decrypted);
|
||||
} else {
|
||||
return key;
|
||||
|
@ -589,7 +591,7 @@ function createCryptoStoreCacheCallbacks(store, olmDevice) {
|
|||
throw new Error(`storeCrossSigningKeyCache expects Uint8Array, got ${key}`);
|
||||
}
|
||||
const pickleKey = Buffer.from(olmDevice.pickleKey);
|
||||
const encryptedKey = await (0, _aes.encryptAES)((0, _base.encodeBase64)(key), pickleKey, type);
|
||||
const encryptedKey = await (0, _encryptAESSecretStorageItem.default)((0, _base.encodeBase64)(key), pickleKey, type);
|
||||
return store.doTxn("readwrite", [_indexeddbCryptoStore.IndexedDBCryptoStore.STORE_ACCOUNT], txn => {
|
||||
store.storeSecretStorePrivateKey(txn, type, encryptedKey);
|
||||
});
|
||||
|
|
|
@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.TrackingStatus = exports.DeviceList = void 0;
|
||||
var _logger = require("../logger");
|
||||
var _deviceinfo = require("./deviceinfo");
|
||||
var _CrossSigning = require("./CrossSigning");
|
||||
var olmlib = _interopRequireWildcard(require("./olmlib"));
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store");
|
||||
var _utils = require("../utils");
|
||||
var _typedEventEmitter = require("../models/typed-event-emitter");
|
||||
var _index = require("./index");
|
||||
var _logger = require("../logger.js");
|
||||
var _deviceinfo = require("./deviceinfo.js");
|
||||
var _CrossSigning = require("./CrossSigning.js");
|
||||
var olmlib = _interopRequireWildcard(require("./olmlib.js"));
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _typedEventEmitter = require("../models/typed-event-emitter.js");
|
||||
var _index = require("./index.js");
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.EncryptionSetupOperation = exports.EncryptionSetupBuilder = void 0;
|
||||
var _logger = require("../logger");
|
||||
var _event = require("../models/event");
|
||||
var _CrossSigning = require("./CrossSigning");
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store");
|
||||
var _httpApi = require("../http-api");
|
||||
var _client = require("../client");
|
||||
var _typedEventEmitter = require("../models/typed-event-emitter");
|
||||
var _logger = require("../logger.js");
|
||||
var _event = require("../models/event.js");
|
||||
var _CrossSigning = require("./CrossSigning.js");
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store.js");
|
||||
var _index = require("../http-api/index.js");
|
||||
var _client = require("../client.js");
|
||||
var _typedEventEmitter = require("../models/typed-event-emitter.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -203,16 +203,16 @@ class EncryptionSetupOperation {
|
|||
// The backup is trusted because the user provided the private key.
|
||||
// Sign the backup with the cross signing key so the key backup can
|
||||
// be trusted via cross-signing.
|
||||
await baseApis.http.authedRequest(_httpApi.Method.Put, "/room_keys/version/" + this.keyBackupInfo.version, undefined, {
|
||||
await baseApis.http.authedRequest(_index.Method.Put, "/room_keys/version/" + this.keyBackupInfo.version, undefined, {
|
||||
algorithm: this.keyBackupInfo.algorithm,
|
||||
auth_data: this.keyBackupInfo.auth_data
|
||||
}, {
|
||||
prefix: _httpApi.ClientPrefix.V3
|
||||
prefix: _index.ClientPrefix.V3
|
||||
});
|
||||
} else {
|
||||
// add new key backup
|
||||
await baseApis.http.authedRequest(_httpApi.Method.Post, "/room_keys/version", undefined, this.keyBackupInfo, {
|
||||
prefix: _httpApi.ClientPrefix.V3
|
||||
await baseApis.http.authedRequest(_index.Method.Post, "/room_keys/version", undefined, this.keyBackupInfo, {
|
||||
prefix: _index.ClientPrefix.V3
|
||||
});
|
||||
}
|
||||
// tell the backup manager to re-check the keys now that they have been (maybe) updated
|
||||
|
|
|
@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.WITHHELD_MESSAGES = exports.PayloadTooLargeError = exports.OlmDevice = void 0;
|
||||
var _logger = require("../logger");
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store");
|
||||
var _cryptoApi = require("../crypto-api");
|
||||
var _CryptoBackend = require("../common-crypto/CryptoBackend");
|
||||
var _logger = require("../logger.js");
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store.js");
|
||||
var _index = require("../crypto-api/index.js");
|
||||
var _CryptoBackend = require("../common-crypto/CryptoBackend.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -517,7 +517,7 @@ class OlmDevice {
|
|||
log.debug(`Waiting for Olm session for ${theirDeviceIdentityKey} to be created`);
|
||||
try {
|
||||
await this.sessionsInProgress[theirDeviceIdentityKey];
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// if the session failed to be created, just fall through and
|
||||
// return an empty result
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ class OlmDevice {
|
|||
log.debug(`Waiting for Olm session for ${deviceIdentityKey} to be created`);
|
||||
try {
|
||||
await this.sessionsInProgress[deviceIdentityKey];
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// if the session failed to be created, then just fall through and
|
||||
// return an empty result
|
||||
}
|
||||
|
@ -939,7 +939,7 @@ class OlmDevice {
|
|||
this.getInboundGroupSession(roomId, senderKey, sessionId, txn, (session, sessionData, withheld) => {
|
||||
if (session === null || sessionData === null) {
|
||||
if (withheld) {
|
||||
const failureCode = withheld.code === "m.unverified" ? _cryptoApi.DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE : _cryptoApi.DecryptionFailureCode.MEGOLM_KEY_WITHHELD;
|
||||
const failureCode = withheld.code === "m.unverified" ? _index.DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE : _index.DecryptionFailureCode.MEGOLM_KEY_WITHHELD;
|
||||
error = new _CryptoBackend.DecryptionError(failureCode, calculateWithheldMessage(withheld), {
|
||||
session: senderKey + "|" + sessionId
|
||||
});
|
||||
|
@ -952,7 +952,7 @@ class OlmDevice {
|
|||
res = session.decrypt(body);
|
||||
} catch (e) {
|
||||
if (e?.message === "OLM.UNKNOWN_MESSAGE_INDEX" && withheld) {
|
||||
const failureCode = withheld.code === "m.unverified" ? _cryptoApi.DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE : _cryptoApi.DecryptionFailureCode.MEGOLM_KEY_WITHHELD;
|
||||
const failureCode = withheld.code === "m.unverified" ? _index.DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE : _index.DecryptionFailureCode.MEGOLM_KEY_WITHHELD;
|
||||
error = new _CryptoBackend.DecryptionError(failureCode, calculateWithheldMessage(withheld), {
|
||||
session: senderKey + "|" + sessionId
|
||||
});
|
||||
|
|
|
@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.RoomKeyRequestState = exports.OutgoingRoomKeyRequestManager = void 0;
|
||||
var _uuid = require("uuid");
|
||||
var _logger = require("../logger");
|
||||
var _event = require("../@types/event");
|
||||
var _utils = require("../utils");
|
||||
var _logger = require("../logger.js");
|
||||
var _event = require("../@types/event.js");
|
||||
var _utils = require("../utils.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.RoomList = void 0;
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store");
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.SecretSharing = void 0;
|
||||
var _uuid = require("uuid");
|
||||
var _utils = require("../utils");
|
||||
var _event = require("../@types/event");
|
||||
var _logger = require("../logger");
|
||||
var olmlib = _interopRequireWildcard(require("./olmlib"));
|
||||
var _utils = require("../utils.js");
|
||||
var _event = require("../@types/event.js");
|
||||
var _logger = require("../logger.js");
|
||||
var olmlib = _interopRequireWildcard(require("./olmlib.js"));
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.SecretStorage = void 0;
|
||||
var _secretStorage = require("../secret-storage");
|
||||
var _SecretSharing = require("./SecretSharing");
|
||||
var _secretStorage = require("../secret-storage.js");
|
||||
var _SecretSharing = require("./SecretSharing.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -3,124 +3,25 @@
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.calculateKeyCheck = calculateKeyCheck;
|
||||
exports.decryptAES = decryptAES;
|
||||
exports.encryptAES = encryptAES;
|
||||
var _base = require("../base64");
|
||||
/*
|
||||
Copyright 2020 - 2021 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.
|
||||
*/
|
||||
|
||||
// salt for HKDF, with 8 bytes of zeros
|
||||
const zeroSalt = new Uint8Array(8);
|
||||
/**
|
||||
* encrypt a string
|
||||
*
|
||||
* @param data - the plaintext to encrypt
|
||||
* @param key - the encryption key to use
|
||||
* @param name - the name of the secret
|
||||
* @param ivStr - the initialization vector to use
|
||||
*/
|
||||
async function encryptAES(data, key, name, ivStr) {
|
||||
let iv;
|
||||
if (ivStr) {
|
||||
iv = (0, _base.decodeBase64)(ivStr);
|
||||
} else {
|
||||
iv = new Uint8Array(16);
|
||||
globalThis.crypto.getRandomValues(iv);
|
||||
|
||||
// clear bit 63 of the IV to stop us hitting the 64-bit counter boundary
|
||||
// (which would mean we wouldn't be able to decrypt on Android). The loss
|
||||
// of a single bit of iv is a price we have to pay.
|
||||
iv[8] &= 0x7f;
|
||||
Object.defineProperty(exports, "calculateKeyCheck", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _secretStorage.calculateKeyCheck;
|
||||
}
|
||||
const [aesKey, hmacKey] = await deriveKeys(key, name);
|
||||
const encodedData = new TextEncoder().encode(data);
|
||||
const ciphertext = await globalThis.crypto.subtle.encrypt({
|
||||
name: "AES-CTR",
|
||||
counter: iv,
|
||||
length: 64
|
||||
}, aesKey, encodedData);
|
||||
const hmac = await globalThis.crypto.subtle.sign({
|
||||
name: "HMAC"
|
||||
}, hmacKey, ciphertext);
|
||||
return {
|
||||
iv: (0, _base.encodeBase64)(iv),
|
||||
ciphertext: (0, _base.encodeBase64)(ciphertext),
|
||||
mac: (0, _base.encodeBase64)(hmac)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* decrypt a string
|
||||
*
|
||||
* @param data - the encrypted data
|
||||
* @param key - the encryption key to use
|
||||
* @param name - the name of the secret
|
||||
*/
|
||||
async function decryptAES(data, key, name) {
|
||||
const [aesKey, hmacKey] = await deriveKeys(key, name);
|
||||
const ciphertext = (0, _base.decodeBase64)(data.ciphertext);
|
||||
if (!(await globalThis.crypto.subtle.verify({
|
||||
name: "HMAC"
|
||||
}, hmacKey, (0, _base.decodeBase64)(data.mac), ciphertext))) {
|
||||
throw new Error(`Error decrypting secret ${name}: bad MAC`);
|
||||
});
|
||||
Object.defineProperty(exports, "decryptAES", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _decryptAESSecretStorageItem.default;
|
||||
}
|
||||
const plaintext = await globalThis.crypto.subtle.decrypt({
|
||||
name: "AES-CTR",
|
||||
counter: (0, _base.decodeBase64)(data.iv),
|
||||
length: 64
|
||||
}, aesKey, ciphertext);
|
||||
return new TextDecoder().decode(new Uint8Array(plaintext));
|
||||
}
|
||||
async function deriveKeys(key, name) {
|
||||
const hkdfkey = await globalThis.crypto.subtle.importKey("raw", key, {
|
||||
name: "HKDF"
|
||||
}, false, ["deriveBits"]);
|
||||
const keybits = await globalThis.crypto.subtle.deriveBits({
|
||||
name: "HKDF",
|
||||
salt: zeroSalt,
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/879
|
||||
info: new TextEncoder().encode(name),
|
||||
hash: "SHA-256"
|
||||
}, hkdfkey, 512);
|
||||
const aesKey = keybits.slice(0, 32);
|
||||
const hmacKey = keybits.slice(32);
|
||||
const aesProm = globalThis.crypto.subtle.importKey("raw", aesKey, {
|
||||
name: "AES-CTR"
|
||||
}, false, ["encrypt", "decrypt"]);
|
||||
const hmacProm = globalThis.crypto.subtle.importKey("raw", hmacKey, {
|
||||
name: "HMAC",
|
||||
hash: {
|
||||
name: "SHA-256"
|
||||
}
|
||||
}, false, ["sign", "verify"]);
|
||||
return Promise.all([aesProm, hmacProm]);
|
||||
}
|
||||
|
||||
// string of zeroes, for calculating the key check
|
||||
const ZERO_STR = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
|
||||
/** Calculate the MAC for checking the key.
|
||||
*
|
||||
* @param key - the key to use
|
||||
* @param iv - The initialization vector as a base64-encoded string.
|
||||
* If omitted, a random initialization vector will be created.
|
||||
* @returns An object that contains, `mac` and `iv` properties.
|
||||
*/
|
||||
function calculateKeyCheck(key, iv) {
|
||||
return encryptAES(ZERO_STR, key, "", iv);
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "encryptAES", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _encryptAESSecretStorageItem.default;
|
||||
}
|
||||
});
|
||||
var _encryptAESSecretStorageItem = _interopRequireDefault(require("../utils/encryptAESSecretStorageItem.js"));
|
||||
var _decryptAESSecretStorageItem = _interopRequireDefault(require("../utils/decryptAESSecretStorageItem.js"));
|
||||
var _secretStorage = require("../secret-storage.js");
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@ -12,7 +12,7 @@ Object.defineProperty(exports, "DecryptionError", {
|
|||
});
|
||||
exports.UnknownDeviceError = exports.EncryptionAlgorithm = exports.ENCRYPTION_CLASSES = void 0;
|
||||
exports.registerAlgorithm = registerAlgorithm;
|
||||
var _CryptoBackend = require("../../common-crypto/CryptoBackend");
|
||||
var _CryptoBackend = require("../../common-crypto/CryptoBackend.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
require("./olm");
|
||||
require("./megolm");
|
||||
var _base = require("./base");
|
||||
require("./olm.js");
|
||||
require("./megolm.js");
|
||||
var _base = require("./base.js");
|
||||
Object.keys(_base).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _base[key]) return;
|
||||
|
|
|
@ -6,16 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|||
exports.MegolmEncryption = exports.MegolmDecryption = void 0;
|
||||
exports.isRoomSharedHistory = isRoomSharedHistory;
|
||||
var _uuid = require("uuid");
|
||||
var _logger = require("../../logger");
|
||||
var olmlib = _interopRequireWildcard(require("../olmlib"));
|
||||
var _base = require("./base");
|
||||
var _OlmDevice = require("../OlmDevice");
|
||||
var _event = require("../../@types/event");
|
||||
var _OutgoingRoomKeyRequestManager = require("../OutgoingRoomKeyRequestManager");
|
||||
var _utils = require("../../utils");
|
||||
var _membership = require("../../@types/membership");
|
||||
var _cryptoApi = require("../../crypto-api");
|
||||
var _CryptoBackend = require("../../common-crypto/CryptoBackend");
|
||||
var _logger = require("../../logger.js");
|
||||
var olmlib = _interopRequireWildcard(require("../olmlib.js"));
|
||||
var _base = require("./base.js");
|
||||
var _OlmDevice = require("../OlmDevice.js");
|
||||
var _event = require("../../@types/event.js");
|
||||
var _OutgoingRoomKeyRequestManager = require("../OutgoingRoomKeyRequestManager.js");
|
||||
var _utils = require("../../utils.js");
|
||||
var _membership = require("../../@types/membership.js");
|
||||
var _index = require("../../crypto-api/index.js");
|
||||
var _CryptoBackend = require("../../common-crypto/CryptoBackend.js");
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
|
@ -764,7 +764,7 @@ class MegolmEncryption extends _base.EncryptionAlgorithm {
|
|||
// (https://github.com/matrix-org/matrix-js-sdk/issues/1255)
|
||||
try {
|
||||
await this.encryptionPreparation.promise;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// ignore any errors -- if the preparation failed, we'll just
|
||||
// restart everything here
|
||||
}
|
||||
|
@ -977,7 +977,7 @@ class MegolmDecryption extends _base.DecryptionAlgorithm {
|
|||
async decryptEvent(event) {
|
||||
const content = event.getWireContent();
|
||||
if (!content.sender_key || !content.session_id || !content.ciphertext) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.MEGOLM_MISSING_FIELDS, "Missing fields in input");
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.MEGOLM_MISSING_FIELDS, "Missing fields in input");
|
||||
}
|
||||
|
||||
// we add the event to the pending list *before* we start decryption.
|
||||
|
@ -994,10 +994,10 @@ class MegolmDecryption extends _base.DecryptionAlgorithm {
|
|||
// re-throw decryption errors as-is
|
||||
throw e;
|
||||
}
|
||||
let errorCode = _cryptoApi.DecryptionFailureCode.OLM_DECRYPT_GROUP_MESSAGE_ERROR;
|
||||
let errorCode = _index.DecryptionFailureCode.OLM_DECRYPT_GROUP_MESSAGE_ERROR;
|
||||
if (e?.message === "OLM.UNKNOWN_MESSAGE_INDEX") {
|
||||
this.requestKeysForEvent(event);
|
||||
errorCode = _cryptoApi.DecryptionFailureCode.OLM_UNKNOWN_MESSAGE_INDEX;
|
||||
errorCode = _index.DecryptionFailureCode.OLM_UNKNOWN_MESSAGE_INDEX;
|
||||
}
|
||||
throw new _CryptoBackend.DecryptionError(errorCode, e instanceof Error ? e.message : "Unknown Error: Error is undefined", {
|
||||
session: content.sender_key + "|" + content.session_id
|
||||
|
@ -1024,11 +1024,11 @@ class MegolmDecryption extends _base.DecryptionAlgorithm {
|
|||
if (problem.fixed) {
|
||||
problemDescription += " Trying to create a new secure channel and re-requesting the keys.";
|
||||
}
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.MEGOLM_UNKNOWN_INBOUND_SESSION_ID, problemDescription, {
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.MEGOLM_UNKNOWN_INBOUND_SESSION_ID, problemDescription, {
|
||||
session: content.sender_key + "|" + content.session_id
|
||||
});
|
||||
}
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.MEGOLM_UNKNOWN_INBOUND_SESSION_ID, "The sender's device has not sent us the keys for this message.", {
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.MEGOLM_UNKNOWN_INBOUND_SESSION_ID, "The sender's device has not sent us the keys for this message.", {
|
||||
session: content.sender_key + "|" + content.session_id
|
||||
});
|
||||
}
|
||||
|
@ -1046,7 +1046,7 @@ class MegolmDecryption extends _base.DecryptionAlgorithm {
|
|||
// (this is somewhat redundant, since the megolm session is scoped to the
|
||||
// room, so neither the sender nor a MITM can lie about the room_id).
|
||||
if (payload.room_id !== event.getRoomId()) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.MEGOLM_BAD_ROOM, "Message intended for room " + payload.room_id);
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.MEGOLM_BAD_ROOM, "Message intended for room " + payload.room_id);
|
||||
}
|
||||
return {
|
||||
clearEvent: payload,
|
||||
|
@ -1597,7 +1597,7 @@ class MegolmDecryption extends _base.DecryptionAlgorithm {
|
|||
isRetry: true,
|
||||
forceRedecryptIfUntrusted
|
||||
});
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// don't die if something goes wrong
|
||||
}
|
||||
}));
|
||||
|
@ -1616,7 +1616,7 @@ class MegolmDecryption extends _base.DecryptionAlgorithm {
|
|||
await Promise.all([...pending].map(async ev => {
|
||||
try {
|
||||
await ev.attemptDecryption(this.crypto);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// don't die if something goes wrong
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
var _logger = require("../../logger");
|
||||
var olmlib = _interopRequireWildcard(require("../olmlib"));
|
||||
var _deviceinfo = require("../deviceinfo");
|
||||
var _base = require("./base");
|
||||
var _cryptoApi = require("../../crypto-api");
|
||||
var _CryptoBackend = require("../../common-crypto/CryptoBackend");
|
||||
var _logger = require("../../logger.js");
|
||||
var olmlib = _interopRequireWildcard(require("../olmlib.js"));
|
||||
var _deviceinfo = require("../deviceinfo.js");
|
||||
var _base = require("./base.js");
|
||||
var _index = require("../../crypto-api/index.js");
|
||||
var _CryptoBackend = require("../../common-crypto/CryptoBackend.js");
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
@ -126,17 +126,17 @@ class OlmDecryption extends _base.DecryptionAlgorithm {
|
|||
const deviceKey = content.sender_key;
|
||||
const ciphertext = content.ciphertext;
|
||||
if (!ciphertext) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.OLM_MISSING_CIPHERTEXT, "Missing ciphertext");
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.OLM_MISSING_CIPHERTEXT, "Missing ciphertext");
|
||||
}
|
||||
if (!(this.olmDevice.deviceCurve25519Key in ciphertext)) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.OLM_NOT_INCLUDED_IN_RECIPIENTS, "Not included in recipients");
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.OLM_NOT_INCLUDED_IN_RECIPIENTS, "Not included in recipients");
|
||||
}
|
||||
const message = ciphertext[this.olmDevice.deviceCurve25519Key];
|
||||
let payloadString;
|
||||
try {
|
||||
payloadString = await this.decryptMessage(deviceKey, message);
|
||||
} catch (e) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.OLM_BAD_ENCRYPTED_MESSAGE, "Bad Encrypted Message", {
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.OLM_BAD_ENCRYPTED_MESSAGE, "Bad Encrypted Message", {
|
||||
sender: deviceKey,
|
||||
err: e
|
||||
});
|
||||
|
@ -146,10 +146,10 @@ class OlmDecryption extends _base.DecryptionAlgorithm {
|
|||
// check that we were the intended recipient, to avoid unknown-key attack
|
||||
// https://github.com/vector-im/vector-web/issues/2483
|
||||
if (payload.recipient != this.userId) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.OLM_BAD_RECIPIENT, "Message was intended for " + payload.recipient);
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.OLM_BAD_RECIPIENT, "Message was intended for " + payload.recipient);
|
||||
}
|
||||
if (payload.recipient_keys.ed25519 != this.olmDevice.deviceEd25519Key) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.OLM_BAD_RECIPIENT_KEY, "Message not intended for this device", {
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.OLM_BAD_RECIPIENT_KEY, "Message not intended for this device", {
|
||||
intended: payload.recipient_keys.ed25519,
|
||||
our_key: this.olmDevice.deviceEd25519Key
|
||||
});
|
||||
|
@ -179,7 +179,7 @@ class OlmDecryption extends _base.DecryptionAlgorithm {
|
|||
try {
|
||||
await this.crypto.deviceList.downloadKeys([event.getSender()], false);
|
||||
} catch (e) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.OLM_BAD_SENDER_CHECK_FAILED, "Could not verify sender identity", {
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.OLM_BAD_SENDER_CHECK_FAILED, "Could not verify sender identity", {
|
||||
sender: deviceKey,
|
||||
err: e
|
||||
});
|
||||
|
@ -187,7 +187,7 @@ class OlmDecryption extends _base.DecryptionAlgorithm {
|
|||
senderKeyUser = this.crypto.deviceList.getUserByIdentityKey(olmlib.OLM_ALGORITHM, deviceKey);
|
||||
}
|
||||
if (senderKeyUser !== event.getSender() && senderKeyUser !== undefined && senderKeyUser !== null) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.OLM_BAD_SENDER, "Message claimed to be from " + event.getSender(), {
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.OLM_BAD_SENDER, "Message claimed to be from " + event.getSender(), {
|
||||
real_sender: senderKeyUser
|
||||
});
|
||||
}
|
||||
|
@ -197,14 +197,14 @@ class OlmDecryption extends _base.DecryptionAlgorithm {
|
|||
// (this check is also provided via the sender's embedded ed25519 key,
|
||||
// which is checked elsewhere).
|
||||
if (payload.sender != event.getSender()) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.OLM_FORWARDED_MESSAGE, "Message forwarded from " + payload.sender, {
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.OLM_FORWARDED_MESSAGE, "Message forwarded from " + payload.sender, {
|
||||
reported_sender: event.getSender()
|
||||
});
|
||||
}
|
||||
|
||||
// Olm events intended for a room have a room_id.
|
||||
if (payload.room_id !== event.getRoomId()) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.OLM_BAD_ROOM, "Message intended for room " + payload.room_id, {
|
||||
throw new _CryptoBackend.DecryptionError(_index.DecryptionFailureCode.OLM_BAD_ROOM, "Message intended for room " + payload.room_id, {
|
||||
reported_room: event.getRoomId() || "ROOM_ID_UNDEFINED"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
Object.defineProperty(exports, "CrossSigningKey", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _cryptoApi.CrossSigningKey;
|
||||
return _index.CrossSigningKey;
|
||||
}
|
||||
});
|
||||
var _cryptoApi = require("../crypto-api");
|
||||
var _index = require("../crypto-api/index.js");
|
|
@ -5,17 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.algorithmsByName = exports.LibOlmBackupDecryptor = exports.DefaultAlgorithm = exports.Curve25519 = exports.BackupManager = exports.Aes256 = void 0;
|
||||
exports.backupTrustInfoFromLegacyTrustInfo = backupTrustInfoFromLegacyTrustInfo;
|
||||
var _client = require("../client");
|
||||
var _logger = require("../logger");
|
||||
var _olmlib = require("./olmlib");
|
||||
var _key_passphrase = require("./key_passphrase");
|
||||
var _utils = require("../utils");
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store");
|
||||
var _recoverykey = require("./recoverykey");
|
||||
var _aes = require("./aes");
|
||||
var _NamespacedValue = require("../NamespacedValue");
|
||||
var _index = require("./index");
|
||||
var _httpApi = require("../http-api");
|
||||
var _client = require("../client.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _olmlib = require("./olmlib.js");
|
||||
var _key_passphrase = require("./key_passphrase.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store.js");
|
||||
var _NamespacedValue = require("../NamespacedValue.js");
|
||||
var _index = require("./index.js");
|
||||
var _index2 = require("../http-api/index.js");
|
||||
var _index3 = require("../crypto-api/index.js");
|
||||
var _decryptAESSecretStorageItem = _interopRequireDefault(require("../utils/decryptAESSecretStorageItem.js"));
|
||||
var _encryptAESSecretStorageItem = _interopRequireDefault(require("../utils/encryptAESSecretStorageItem.js"));
|
||||
var _secretStorage = require("../secret-storage.js");
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -139,7 +142,7 @@ class BackupManager {
|
|||
throw new Error("Unknown backup algorithm");
|
||||
}
|
||||
const [privateKey, authData] = await Algorithm.prepare(key);
|
||||
const recoveryKey = (0, _recoverykey.encodeRecoveryKey)(privateKey);
|
||||
const recoveryKey = (0, _index3.encodeRecoveryKey)(privateKey);
|
||||
return {
|
||||
algorithm: Algorithm.algorithmName,
|
||||
auth_data: authData,
|
||||
|
@ -175,8 +178,8 @@ class BackupManager {
|
|||
const path = (0, _utils.encodeUri)("/room_keys/version/$version", {
|
||||
$version: version
|
||||
});
|
||||
await this.baseApis.http.authedRequest(_httpApi.Method.Delete, path, undefined, undefined, {
|
||||
prefix: _httpApi.ClientPrefix.V3
|
||||
await this.baseApis.http.authedRequest(_index2.Method.Delete, path, undefined, undefined, {
|
||||
prefix: _index2.ClientPrefix.V3
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -388,7 +391,7 @@ class BackupManager {
|
|||
} catch (err) {
|
||||
numFailures++;
|
||||
_logger.logger.log("Key backup request failed", err);
|
||||
if (err instanceof _httpApi.MatrixError) {
|
||||
if (err instanceof _index2.MatrixError) {
|
||||
const errCode = err.data.errcode;
|
||||
if (errCode == "M_NOT_FOUND" || errCode == "M_WRONG_ROOM_KEYS_VERSION") {
|
||||
// Set to false now as `checkKeyBackup` might schedule a backupsend before this one ends.
|
||||
|
@ -574,7 +577,7 @@ class Curve25519 {
|
|||
try {
|
||||
const backupPubKey = decryption.init_with_private_key(privKey);
|
||||
if (backupPubKey !== this.authData.public_key) {
|
||||
throw new _httpApi.MatrixError({
|
||||
throw new _index2.MatrixError({
|
||||
errcode: _client.MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY
|
||||
});
|
||||
}
|
||||
|
@ -628,7 +631,7 @@ class Aes256 {
|
|||
if (authData.mac) {
|
||||
const {
|
||||
mac
|
||||
} = await (0, _aes.calculateKeyCheck)(key, authData.iv);
|
||||
} = await (0, _secretStorage.calculateKeyCheck)(key, authData.iv);
|
||||
if (authData.mac.replace(/=+$/g, "") !== mac.replace(/=+/g, "")) {
|
||||
throw new Error("Key does not match");
|
||||
}
|
||||
|
@ -651,7 +654,7 @@ class Aes256 {
|
|||
const {
|
||||
iv,
|
||||
mac
|
||||
} = await (0, _aes.calculateKeyCheck)(outKey);
|
||||
} = await (0, _secretStorage.calculateKeyCheck)(outKey);
|
||||
authData.iv = iv;
|
||||
authData.mac = mac;
|
||||
return [outKey, authData];
|
||||
|
@ -669,13 +672,13 @@ class Aes256 {
|
|||
delete plainText.session_id;
|
||||
delete plainText.room_id;
|
||||
delete plainText.first_known_index;
|
||||
return (0, _aes.encryptAES)(JSON.stringify(plainText), this.key, data.session_id);
|
||||
return (0, _encryptAESSecretStorageItem.default)(JSON.stringify(plainText), this.key, data.session_id);
|
||||
}
|
||||
async decryptSessions(sessions) {
|
||||
const keys = [];
|
||||
for (const [sessionId, sessionData] of Object.entries(sessions)) {
|
||||
try {
|
||||
const decrypted = JSON.parse(await (0, _aes.decryptAES)(sessionData.session_data, this.key, sessionId));
|
||||
const decrypted = JSON.parse(await (0, _decryptAESSecretStorageItem.default)(sessionData.session_data, this.key, sessionId));
|
||||
decrypted.session_id = sessionId;
|
||||
keys.push(decrypted);
|
||||
} catch (e) {
|
||||
|
@ -688,7 +691,7 @@ class Aes256 {
|
|||
if (this.authData.mac) {
|
||||
const {
|
||||
mac
|
||||
} = await (0, _aes.calculateKeyCheck)(key, this.authData.iv);
|
||||
} = await (0, _secretStorage.calculateKeyCheck)(key, this.authData.iv);
|
||||
return this.authData.mac.replace(/=+$/g, "") === mac.replace(/=+/g, "");
|
||||
} else {
|
||||
// if we have no information, we have to assume the key is right
|
||||
|
|
|
@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.DehydrationManager = exports.DEHYDRATION_ALGORITHM = void 0;
|
||||
var _anotherJson = _interopRequireDefault(require("another-json"));
|
||||
var _base = require("../base64");
|
||||
var _indexeddbCryptoStore = require("../crypto/store/indexeddb-crypto-store");
|
||||
var _aes = require("./aes");
|
||||
var _logger = require("../logger");
|
||||
var _httpApi = require("../http-api");
|
||||
var _base = require("../base64.js");
|
||||
var _indexeddbCryptoStore = require("../crypto/store/indexeddb-crypto-store.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _index = require("../http-api/index.js");
|
||||
var _decryptAESSecretStorageItem = _interopRequireDefault(require("../utils/decryptAESSecretStorageItem.js"));
|
||||
var _encryptAESSecretStorageItem = _interopRequireDefault(require("../utils/encryptAESSecretStorageItem.js"));
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
|
@ -51,7 +52,7 @@ class DehydrationManager {
|
|||
time
|
||||
} = result;
|
||||
const pickleKey = Buffer.from(this.crypto.olmDevice.pickleKey);
|
||||
const decrypted = await (0, _aes.decryptAES)(key, pickleKey, DEHYDRATION_ALGORITHM);
|
||||
const decrypted = await (0, _decryptAESSecretStorageItem.default)(key, pickleKey, DEHYDRATION_ALGORITHM);
|
||||
this.key = (0, _base.decodeBase64)(decrypted);
|
||||
this.keyInfo = keyInfo;
|
||||
this.deviceDisplayName = deviceDisplayName;
|
||||
|
@ -120,7 +121,7 @@ class DehydrationManager {
|
|||
const pickleKey = Buffer.from(this.crypto.olmDevice.pickleKey);
|
||||
|
||||
// update the crypto store with the timestamp
|
||||
const key = await (0, _aes.encryptAES)((0, _base.encodeBase64)(this.key), pickleKey, DEHYDRATION_ALGORITHM);
|
||||
const key = await (0, _encryptAESSecretStorageItem.default)((0, _base.encodeBase64)(this.key), pickleKey, DEHYDRATION_ALGORITHM);
|
||||
await this.crypto.cryptoStore.doTxn("readwrite", [_indexeddbCryptoStore.IndexedDBCryptoStore.STORE_ACCOUNT], txn => {
|
||||
this.crypto.cryptoStore.storeSecretStorePrivateKey(txn, "dehydration", {
|
||||
keyInfo: this.keyInfo,
|
||||
|
@ -154,7 +155,7 @@ class DehydrationManager {
|
|||
}
|
||||
_logger.logger.log("Uploading account to server");
|
||||
// eslint-disable-next-line camelcase
|
||||
const dehydrateResult = await this.crypto.baseApis.http.authedRequest(_httpApi.Method.Put, "/dehydrated_device", undefined, {
|
||||
const dehydrateResult = await this.crypto.baseApis.http.authedRequest(_index.Method.Put, "/dehydrated_device", undefined, {
|
||||
device_data: deviceData,
|
||||
initial_device_display_name: this.deviceDisplayName
|
||||
}, {
|
||||
|
@ -212,7 +213,7 @@ class DehydrationManager {
|
|||
fallbackKeys[`signed_curve25519:${keyId}`] = k;
|
||||
}
|
||||
_logger.logger.log("Uploading keys to server");
|
||||
await this.crypto.baseApis.http.authedRequest(_httpApi.Method.Post, "/keys/upload/" + encodeURI(deviceId), undefined, {
|
||||
await this.crypto.baseApis.http.authedRequest(_index.Method.Post, "/keys/upload/" + encodeURI(deviceId), undefined, {
|
||||
"device_keys": deviceKeys,
|
||||
"one_time_keys": oneTimeKeys,
|
||||
"org.matrix.msc2732.fallback_keys": fallbackKeys
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.deviceInfoToDevice = deviceInfoToDevice;
|
||||
var _device = require("../models/device");
|
||||
var _device = require("../models/device.js");
|
||||
/*
|
||||
Copyright 2023 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.DeviceInfo = void 0;
|
||||
var _device = require("../models/device");
|
||||
var _device = require("../models/device.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -9,47 +9,47 @@ exports.isCryptoAvailable = isCryptoAvailable;
|
|||
exports.verificationMethods = void 0;
|
||||
var _anotherJson = _interopRequireDefault(require("another-json"));
|
||||
var _uuid = require("uuid");
|
||||
var _event = require("../@types/event");
|
||||
var _ReEmitter = require("../ReEmitter");
|
||||
var _logger = require("../logger");
|
||||
var _OlmDevice = require("./OlmDevice");
|
||||
var olmlib = _interopRequireWildcard(require("./olmlib"));
|
||||
var _DeviceList = require("./DeviceList");
|
||||
var _deviceinfo = require("./deviceinfo");
|
||||
var algorithms = _interopRequireWildcard(require("./algorithms"));
|
||||
var _CrossSigning = require("./CrossSigning");
|
||||
var _EncryptionSetup = require("./EncryptionSetup");
|
||||
var _SecretStorage = require("./SecretStorage");
|
||||
var _api = require("./api");
|
||||
var _OutgoingRoomKeyRequestManager = require("./OutgoingRoomKeyRequestManager");
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store");
|
||||
var _QRCode = require("./verification/QRCode");
|
||||
var _SAS = require("./verification/SAS");
|
||||
var _key_passphrase = require("./key_passphrase");
|
||||
var _recoverykey = require("./recoverykey");
|
||||
var _VerificationRequest = require("./verification/request/VerificationRequest");
|
||||
var _InRoomChannel = require("./verification/request/InRoomChannel");
|
||||
var _ToDeviceChannel = require("./verification/request/ToDeviceChannel");
|
||||
var _IllegalMethod = require("./verification/IllegalMethod");
|
||||
var _errors = require("../errors");
|
||||
var _aes = require("./aes");
|
||||
var _dehydration = require("./dehydration");
|
||||
var _backup = require("./backup");
|
||||
var _room = require("../models/room");
|
||||
var _roomMember = require("../models/room-member");
|
||||
var _event2 = require("../models/event");
|
||||
var _client = require("../client");
|
||||
var _RoomList = require("./RoomList");
|
||||
var _typedEventEmitter = require("../models/typed-event-emitter");
|
||||
var _CryptoBackend = require("../common-crypto/CryptoBackend");
|
||||
var _roomState = require("../models/room-state");
|
||||
var _utils = require("../utils");
|
||||
var _secretStorage = require("../secret-storage");
|
||||
var _cryptoApi = require("../crypto-api");
|
||||
var _deviceConverter = require("./device-converter");
|
||||
var _httpApi = require("../http-api");
|
||||
var _base = require("../base64");
|
||||
var _membership = require("../@types/membership");
|
||||
var _event = require("../@types/event.js");
|
||||
var _ReEmitter = require("../ReEmitter.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _OlmDevice = require("./OlmDevice.js");
|
||||
var olmlib = _interopRequireWildcard(require("./olmlib.js"));
|
||||
var _DeviceList = require("./DeviceList.js");
|
||||
var _deviceinfo = require("./deviceinfo.js");
|
||||
var algorithms = _interopRequireWildcard(require("./algorithms/index.js"));
|
||||
var _CrossSigning = require("./CrossSigning.js");
|
||||
var _EncryptionSetup = require("./EncryptionSetup.js");
|
||||
var _SecretStorage = require("./SecretStorage.js");
|
||||
var _api = require("./api.js");
|
||||
var _OutgoingRoomKeyRequestManager = require("./OutgoingRoomKeyRequestManager.js");
|
||||
var _indexeddbCryptoStore = require("./store/indexeddb-crypto-store.js");
|
||||
var _QRCode = require("./verification/QRCode.js");
|
||||
var _SAS = require("./verification/SAS.js");
|
||||
var _key_passphrase = require("./key_passphrase.js");
|
||||
var _VerificationRequest = require("./verification/request/VerificationRequest.js");
|
||||
var _InRoomChannel = require("./verification/request/InRoomChannel.js");
|
||||
var _ToDeviceChannel = require("./verification/request/ToDeviceChannel.js");
|
||||
var _IllegalMethod = require("./verification/IllegalMethod.js");
|
||||
var _errors = require("../errors.js");
|
||||
var _dehydration = require("./dehydration.js");
|
||||
var _backup = require("./backup.js");
|
||||
var _room = require("../models/room.js");
|
||||
var _roomMember = require("../models/room-member.js");
|
||||
var _event2 = require("../models/event.js");
|
||||
var _client = require("../client.js");
|
||||
var _RoomList = require("./RoomList.js");
|
||||
var _typedEventEmitter = require("../models/typed-event-emitter.js");
|
||||
var _CryptoBackend = require("../common-crypto/CryptoBackend.js");
|
||||
var _roomState = require("../models/room-state.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _secretStorage = require("../secret-storage.js");
|
||||
var _index2 = require("../crypto-api/index.js");
|
||||
var _deviceConverter = require("./device-converter.js");
|
||||
var _index3 = require("../http-api/index.js");
|
||||
var _base = require("../base64.js");
|
||||
var _membership = require("../@types/membership.js");
|
||||
var _decryptAESSecretStorageItem = _interopRequireDefault(require("../utils/decryptAESSecretStorageItem.js"));
|
||||
var _encryptAESSecretStorageItem = _interopRequireDefault(require("../utils/encryptAESSecretStorageItem.js"));
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
|
@ -120,24 +120,24 @@ const FORCE_SESSION_RETRY_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes
|
|||
/* eslint-disable camelcase */
|
||||
|
||||
/* eslint-enable camelcase */
|
||||
let CryptoEvent = exports.CryptoEvent = /*#__PURE__*/function (CryptoEvent) {
|
||||
let CryptoEvent = exports.CryptoEvent = function (CryptoEvent) {
|
||||
CryptoEvent["DeviceVerificationChanged"] = "deviceVerificationChanged";
|
||||
CryptoEvent["UserTrustStatusChanged"] = "userTrustStatusChanged";
|
||||
CryptoEvent[CryptoEvent["UserTrustStatusChanged"] = _index2.CryptoEvent.UserTrustStatusChanged] = "UserTrustStatusChanged";
|
||||
CryptoEvent["UserCrossSigningUpdated"] = "userCrossSigningUpdated";
|
||||
CryptoEvent["RoomKeyRequest"] = "crypto.roomKeyRequest";
|
||||
CryptoEvent["RoomKeyRequestCancellation"] = "crypto.roomKeyRequestCancellation";
|
||||
CryptoEvent["KeyBackupStatus"] = "crypto.keyBackupStatus";
|
||||
CryptoEvent["KeyBackupFailed"] = "crypto.keyBackupFailed";
|
||||
CryptoEvent["KeyBackupSessionsRemaining"] = "crypto.keyBackupSessionsRemaining";
|
||||
CryptoEvent["KeyBackupDecryptionKeyCached"] = "crypto.keyBackupDecryptionKeyCached";
|
||||
CryptoEvent[CryptoEvent["KeyBackupStatus"] = _index2.CryptoEvent.KeyBackupStatus] = "KeyBackupStatus";
|
||||
CryptoEvent[CryptoEvent["KeyBackupFailed"] = _index2.CryptoEvent.KeyBackupFailed] = "KeyBackupFailed";
|
||||
CryptoEvent[CryptoEvent["KeyBackupSessionsRemaining"] = _index2.CryptoEvent.KeyBackupSessionsRemaining] = "KeyBackupSessionsRemaining";
|
||||
CryptoEvent[CryptoEvent["KeyBackupDecryptionKeyCached"] = _index2.CryptoEvent.KeyBackupDecryptionKeyCached] = "KeyBackupDecryptionKeyCached";
|
||||
CryptoEvent["KeySignatureUploadFailure"] = "crypto.keySignatureUploadFailure";
|
||||
CryptoEvent["VerificationRequest"] = "crypto.verification.request";
|
||||
CryptoEvent["VerificationRequestReceived"] = "crypto.verificationRequestReceived";
|
||||
CryptoEvent[CryptoEvent["VerificationRequestReceived"] = _index2.CryptoEvent.VerificationRequestReceived] = "VerificationRequestReceived";
|
||||
CryptoEvent["Warning"] = "crypto.warning";
|
||||
CryptoEvent["WillUpdateDevices"] = "crypto.willUpdateDevices";
|
||||
CryptoEvent["DevicesUpdated"] = "crypto.devicesUpdated";
|
||||
CryptoEvent["KeysChanged"] = "crossSigning.keysChanged";
|
||||
CryptoEvent["LegacyCryptoStoreMigrationProgress"] = "crypto.legacyCryptoStoreMigrationProgress";
|
||||
CryptoEvent[CryptoEvent["WillUpdateDevices"] = _index2.CryptoEvent.WillUpdateDevices] = "WillUpdateDevices";
|
||||
CryptoEvent[CryptoEvent["DevicesUpdated"] = _index2.CryptoEvent.DevicesUpdated] = "DevicesUpdated";
|
||||
CryptoEvent[CryptoEvent["KeysChanged"] = _index2.CryptoEvent.KeysChanged] = "KeysChanged";
|
||||
CryptoEvent[CryptoEvent["LegacyCryptoStoreMigrationProgress"] = _index2.CryptoEvent.LegacyCryptoStoreMigrationProgress] = "LegacyCryptoStoreMigrationProgress";
|
||||
return CryptoEvent;
|
||||
}({});
|
||||
class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
||||
|
@ -462,6 +462,12 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
this.backupManager.checkAndStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of {@link Crypto.CryptoApi#setDeviceIsolationMode}.
|
||||
*/
|
||||
setDeviceIsolationMode(isolationMode) {
|
||||
throw new Error("Not supported");
|
||||
}
|
||||
/**
|
||||
* Implementation of {@link Crypto.CryptoApi#getVersion}.
|
||||
*/
|
||||
|
@ -545,14 +551,14 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
}
|
||||
},
|
||||
privateKey: privateKey,
|
||||
encodedPrivateKey: (0, _recoverykey.encodeRecoveryKey)(privateKey)
|
||||
encodedPrivateKey: (0, _index2.encodeRecoveryKey)(privateKey)
|
||||
};
|
||||
} else {
|
||||
decryption.generate_key();
|
||||
const privateKey = decryption.get_private_key();
|
||||
return {
|
||||
privateKey: privateKey,
|
||||
encodedPrivateKey: (0, _recoverykey.encodeRecoveryKey)(privateKey)
|
||||
encodedPrivateKey: (0, _index2.encodeRecoveryKey)(privateKey)
|
||||
};
|
||||
}
|
||||
} finally {
|
||||
|
@ -789,7 +795,7 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
const {
|
||||
iv,
|
||||
mac
|
||||
} = await (0, _aes.calculateKeyCheck)(privateKey);
|
||||
} = await (0, _secretStorage.calculateKeyCheck)(privateKey);
|
||||
keyInfo.iv = iv;
|
||||
keyInfo.mac = mac;
|
||||
await builder.setAccountData(`m.secret_storage.key.${keyId}`, keyInfo);
|
||||
|
@ -902,7 +908,7 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
secureSecretStorage: false
|
||||
});
|
||||
// write the key to 4S
|
||||
const privateKey = (0, _recoverykey.decodeRecoveryKey)(info.recovery_key);
|
||||
const privateKey = (0, _index2.decodeRecoveryKey)(info.recovery_key);
|
||||
await secretStorage.store("m.megolm_backup.v1", (0, _base.encodeBase64)(privateKey));
|
||||
|
||||
// create keyBackupInfo object to add to builder
|
||||
|
@ -970,8 +976,8 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
// add new key backup
|
||||
const {
|
||||
version
|
||||
} = await this.baseApis.http.authedRequest(_httpApi.Method.Post, "/room_keys/version", undefined, info, {
|
||||
prefix: _httpApi.ClientPrefix.V3
|
||||
} = await this.baseApis.http.authedRequest(_index3.Method.Post, "/room_keys/version", undefined, info, {
|
||||
prefix: _index3.ClientPrefix.V3
|
||||
});
|
||||
_logger.logger.log(`Created backup version ${version}`);
|
||||
|
||||
|
@ -1099,7 +1105,7 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
}
|
||||
if (encodedKey && typeof encodedKey === "object" && "ciphertext" in encodedKey) {
|
||||
const pickleKey = Buffer.from(this.olmDevice.pickleKey);
|
||||
const decrypted = await (0, _aes.decryptAES)(encodedKey, pickleKey, "m.megolm_backup.v1");
|
||||
const decrypted = await (0, _decryptAESSecretStorageItem.default)(encodedKey, pickleKey, "m.megolm_backup.v1");
|
||||
key = (0, _base.decodeBase64)(decrypted);
|
||||
}
|
||||
return key;
|
||||
|
@ -1116,7 +1122,7 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
throw new Error(`storeSessionBackupPrivateKey expects Uint8Array, got ${key}`);
|
||||
}
|
||||
const pickleKey = Buffer.from(this.olmDevice.pickleKey);
|
||||
const encryptedKey = await (0, _aes.encryptAES)((0, _base.encodeBase64)(key), pickleKey, "m.megolm_backup.v1");
|
||||
const encryptedKey = await (0, _encryptAESSecretStorageItem.default)((0, _base.encodeBase64)(key), pickleKey, "m.megolm_backup.v1");
|
||||
return this.cryptoStore.doTxn("readwrite", [_indexeddbCryptoStore.IndexedDBCryptoStore.STORE_ACCOUNT], txn => {
|
||||
this.cryptoStore.storeSecretStorePrivateKey(txn, "m.megolm_backup.v1", encryptedKey);
|
||||
});
|
||||
|
@ -1295,7 +1301,7 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
try {
|
||||
await olmlib.verifySignature(this.olmDevice, key, userId, deviceId, devices[deviceId].keys[signame]);
|
||||
deviceIds.push(deviceId);
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1352,6 +1358,13 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
return this.checkUserTrust(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of {@link Crypto.CryptoApi.pinCurrentUserIdentity}.
|
||||
*/
|
||||
async pinCurrentUserIdentity(userId) {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a given device is trusted.
|
||||
*
|
||||
|
@ -1566,7 +1579,7 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
// doesn't match the one in the auth_data, the user has entered
|
||||
// a different recovery key / the wrong passphrase.
|
||||
if (!(await algorithm.keyMatches(privKey))) {
|
||||
return Promise.reject(new _httpApi.MatrixError({
|
||||
return Promise.reject(new _index3.MatrixError({
|
||||
errcode: _client.MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY
|
||||
}));
|
||||
}
|
||||
|
@ -2400,8 +2413,8 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
|
||||
// previously: E2EState.Warning -> E2ePadlockUnverified -> Red/"Encrypted by an unverified session"
|
||||
return {
|
||||
shieldColour: _cryptoApi.EventShieldColour.RED,
|
||||
shieldReason: _cryptoApi.EventShieldReason.MISMATCHED_SENDER_KEY
|
||||
shieldColour: _index2.EventShieldColour.RED,
|
||||
shieldReason: _index2.EventShieldReason.MISMATCHED_SENDER_KEY
|
||||
};
|
||||
}
|
||||
const userTrust = this.checkUserTrust(senderId);
|
||||
|
@ -2412,13 +2425,13 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
if (!encryptionInfo.authenticated) {
|
||||
// previously: E2EState.Unauthenticated -> E2ePadlockUnauthenticated -> Grey/"The authenticity of this encrypted message can't be guaranteed on this device."
|
||||
return {
|
||||
shieldColour: _cryptoApi.EventShieldColour.GREY,
|
||||
shieldReason: _cryptoApi.EventShieldReason.AUTHENTICITY_NOT_GUARANTEED
|
||||
shieldColour: _index2.EventShieldColour.GREY,
|
||||
shieldReason: _index2.EventShieldReason.AUTHENTICITY_NOT_GUARANTEED
|
||||
};
|
||||
} else {
|
||||
// previously: E2EState.Normal -> no icon
|
||||
return {
|
||||
shieldColour: _cryptoApi.EventShieldColour.NONE,
|
||||
shieldColour: _index2.EventShieldColour.NONE,
|
||||
shieldReason: null
|
||||
};
|
||||
}
|
||||
|
@ -2427,28 +2440,28 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
if (!eventSenderTrust) {
|
||||
// previously: E2EState.Unknown -> E2ePadlockUnknown -> Grey/"Encrypted by a deleted session"
|
||||
return {
|
||||
shieldColour: _cryptoApi.EventShieldColour.GREY,
|
||||
shieldReason: _cryptoApi.EventShieldReason.UNKNOWN_DEVICE
|
||||
shieldColour: _index2.EventShieldColour.GREY,
|
||||
shieldReason: _index2.EventShieldReason.UNKNOWN_DEVICE
|
||||
};
|
||||
}
|
||||
if (!eventSenderTrust.isVerified()) {
|
||||
// previously: E2EState.Warning -> E2ePadlockUnverified -> Red/"Encrypted by an unverified session"
|
||||
return {
|
||||
shieldColour: _cryptoApi.EventShieldColour.RED,
|
||||
shieldReason: _cryptoApi.EventShieldReason.UNSIGNED_DEVICE
|
||||
shieldColour: _index2.EventShieldColour.RED,
|
||||
shieldReason: _index2.EventShieldReason.UNSIGNED_DEVICE
|
||||
};
|
||||
}
|
||||
if (!encryptionInfo.authenticated) {
|
||||
// previously: E2EState.Unauthenticated -> E2ePadlockUnauthenticated -> Grey/"The authenticity of this encrypted message can't be guaranteed on this device."
|
||||
return {
|
||||
shieldColour: _cryptoApi.EventShieldColour.GREY,
|
||||
shieldReason: _cryptoApi.EventShieldReason.AUTHENTICITY_NOT_GUARANTEED
|
||||
shieldColour: _index2.EventShieldColour.GREY,
|
||||
shieldReason: _index2.EventShieldReason.AUTHENTICITY_NOT_GUARANTEED
|
||||
};
|
||||
}
|
||||
|
||||
// previously: E2EState.Verified -> no icon
|
||||
return {
|
||||
shieldColour: _cryptoApi.EventShieldColour.NONE,
|
||||
shieldColour: _index2.EventShieldColour.NONE,
|
||||
shieldReason: null
|
||||
};
|
||||
}
|
||||
|
@ -3060,45 +3073,12 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
* resolves once the message has been encrypted and sent to the given
|
||||
* userDeviceMap, and returns the `{ contentMap, deviceInfoByDeviceId }`
|
||||
* of the successfully sent messages.
|
||||
*
|
||||
* @deprecated Instead use {@link encryptToDeviceMessages} followed by {@link MatrixClient.queueToDevice}.
|
||||
*/
|
||||
async encryptAndSendToDevices(userDeviceInfoArr, payload) {
|
||||
const toDeviceBatch = {
|
||||
eventType: _event.EventType.RoomMessageEncrypted,
|
||||
batch: []
|
||||
};
|
||||
try {
|
||||
await Promise.all(userDeviceInfoArr.map(async ({
|
||||
userId,
|
||||
deviceInfo
|
||||
}) => {
|
||||
const deviceId = deviceInfo.deviceId;
|
||||
const encryptedContent = {
|
||||
algorithm: olmlib.OLM_ALGORITHM,
|
||||
sender_key: this.olmDevice.deviceCurve25519Key,
|
||||
ciphertext: {},
|
||||
[_event.ToDeviceMessageId]: (0, _uuid.v4)()
|
||||
};
|
||||
toDeviceBatch.batch.push({
|
||||
userId,
|
||||
deviceId,
|
||||
payload: encryptedContent
|
||||
});
|
||||
await olmlib.ensureOlmSessionsForDevices(this.olmDevice, this.baseApis, new Map([[userId, [deviceInfo]]]));
|
||||
await olmlib.encryptMessageForDevice(encryptedContent.ciphertext, this.userId, this.deviceId, this.olmDevice, userId, deviceInfo, payload);
|
||||
}));
|
||||
|
||||
// prune out any devices that encryptMessageForDevice could not encrypt for,
|
||||
// in which case it will have just not added anything to the ciphertext object.
|
||||
// There's no point sending messages to devices if we couldn't encrypt to them,
|
||||
// since that's effectively a blank message.
|
||||
toDeviceBatch.batch = toDeviceBatch.batch.filter(msg => {
|
||||
if (Object.keys(msg.payload.ciphertext).length > 0) {
|
||||
return true;
|
||||
} else {
|
||||
_logger.logger.log(`No ciphertext for device ${msg.userId}:${msg.deviceId}: pruning`);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
const toDeviceBatch = await this.prepareToDeviceBatch(userDeviceInfoArr, payload);
|
||||
try {
|
||||
await this.baseApis.queueToDevice(toDeviceBatch);
|
||||
} catch (e) {
|
||||
|
@ -3110,6 +3090,76 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
async prepareToDeviceBatch(userDeviceInfoArr, payload) {
|
||||
const toDeviceBatch = {
|
||||
eventType: _event.EventType.RoomMessageEncrypted,
|
||||
batch: []
|
||||
};
|
||||
await Promise.all(userDeviceInfoArr.map(async ({
|
||||
userId,
|
||||
deviceInfo
|
||||
}) => {
|
||||
const deviceId = deviceInfo.deviceId;
|
||||
const encryptedContent = {
|
||||
algorithm: olmlib.OLM_ALGORITHM,
|
||||
sender_key: this.olmDevice.deviceCurve25519Key,
|
||||
ciphertext: {},
|
||||
[_event.ToDeviceMessageId]: (0, _uuid.v4)()
|
||||
};
|
||||
toDeviceBatch.batch.push({
|
||||
userId,
|
||||
deviceId,
|
||||
payload: encryptedContent
|
||||
});
|
||||
await olmlib.ensureOlmSessionsForDevices(this.olmDevice, this.baseApis, new Map([[userId, [deviceInfo]]]));
|
||||
await olmlib.encryptMessageForDevice(encryptedContent.ciphertext, this.userId, this.deviceId, this.olmDevice, userId, deviceInfo, payload);
|
||||
}));
|
||||
|
||||
// prune out any devices that encryptMessageForDevice could not encrypt for,
|
||||
// in which case it will have just not added anything to the ciphertext object.
|
||||
// There's no point sending messages to devices if we couldn't encrypt to them,
|
||||
// since that's effectively a blank message.
|
||||
toDeviceBatch.batch = toDeviceBatch.batch.filter(msg => {
|
||||
if (Object.keys(msg.payload.ciphertext).length > 0) {
|
||||
return true;
|
||||
} else {
|
||||
_logger.logger.log(`No ciphertext for device ${msg.userId}:${msg.deviceId}: pruning`);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return toDeviceBatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of {@link Crypto.CryptoApi#encryptToDeviceMessages}.
|
||||
*/
|
||||
async encryptToDeviceMessages(eventType, devices, payload) {
|
||||
const userIds = new Set(devices.map(({
|
||||
userId
|
||||
}) => userId));
|
||||
const deviceInfoMap = await this.downloadKeys(Array.from(userIds), false);
|
||||
const userDeviceInfoArr = [];
|
||||
devices.forEach(({
|
||||
userId,
|
||||
deviceId
|
||||
}) => {
|
||||
const devices = deviceInfoMap.get(userId);
|
||||
if (!devices) {
|
||||
_logger.logger.warn(`No devices found for user ${userId}`);
|
||||
return;
|
||||
}
|
||||
if (devices.has(deviceId)) {
|
||||
// Send the message to a specific device
|
||||
userDeviceInfoArr.push({
|
||||
userId,
|
||||
deviceInfo: devices.get(deviceId)
|
||||
});
|
||||
} else {
|
||||
_logger.logger.warn(`No device found for user ${userId} with id ${deviceId}`);
|
||||
}
|
||||
});
|
||||
return this.prepareToDeviceBatch(userDeviceInfoArr, payload);
|
||||
}
|
||||
async preprocessToDeviceMessages(events) {
|
||||
// all we do here is filter out encrypted to-device messages with the wrong algorithm. Decryption
|
||||
// happens later in decryptEvent, via the EventMapper
|
||||
|
@ -3577,7 +3627,7 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
|
|||
}
|
||||
const AlgClass = algorithms.DECRYPTION_CLASSES.get(algorithm);
|
||||
if (!AlgClass) {
|
||||
throw new _CryptoBackend.DecryptionError(_cryptoApi.DecryptionFailureCode.UNKNOWN_ENCRYPTION_ALGORITHM, 'Unknown encryption algorithm "' + algorithm + '".');
|
||||
throw new _CryptoBackend.DecryptionError(_index2.DecryptionFailureCode.UNKNOWN_ENCRYPTION_ALGORITHM, 'Unknown encryption algorithm "' + algorithm + '".');
|
||||
}
|
||||
alg = new AlgClass({
|
||||
userId: this.userId,
|
||||
|
|
|
@ -3,10 +3,22 @@
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.deriveKey = deriveKey;
|
||||
exports.keyFromAuthData = keyFromAuthData;
|
||||
Object.defineProperty(exports, "deriveKey", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index.deriveRecoveryKeyFromPassphrase;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "keyFromAuthData", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyPassphrase.keyFromAuthData;
|
||||
}
|
||||
});
|
||||
exports.keyFromPassphrase = keyFromPassphrase;
|
||||
var _randomstring = require("../randomstring");
|
||||
var _randomstring = require("../randomstring.js");
|
||||
var _index = require("../crypto-api/index.js");
|
||||
var _keyPassphrase = require("../common-crypto/key-passphrase.js");
|
||||
/*
|
||||
Copyright 2018 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
@ -24,39 +36,18 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
const DEFAULT_ITERATIONS = 500000;
|
||||
const DEFAULT_BITSIZE = 256;
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
function keyFromAuthData(authData, password) {
|
||||
if (!authData.private_key_salt || !authData.private_key_iterations) {
|
||||
throw new Error("Salt and/or iterations not found: " + "this backup cannot be restored with a passphrase");
|
||||
}
|
||||
return deriveKey(password, authData.private_key_salt, authData.private_key_iterations, authData.private_key_bits || DEFAULT_BITSIZE);
|
||||
}
|
||||
async function keyFromPassphrase(password) {
|
||||
/**
|
||||
* Generate a new recovery key, based on a passphrase.
|
||||
* @param passphrase - The passphrase to generate the key from
|
||||
*/
|
||||
async function keyFromPassphrase(passphrase) {
|
||||
const salt = (0, _randomstring.randomString)(32);
|
||||
const key = await deriveKey(password, salt, DEFAULT_ITERATIONS, DEFAULT_BITSIZE);
|
||||
const key = await (0, _index.deriveRecoveryKeyFromPassphrase)(passphrase, salt, DEFAULT_ITERATIONS);
|
||||
return {
|
||||
key,
|
||||
salt,
|
||||
iterations: DEFAULT_ITERATIONS
|
||||
};
|
||||
}
|
||||
async function deriveKey(password, salt, iterations, numBits = DEFAULT_BITSIZE) {
|
||||
if (!globalThis.crypto.subtle || !TextEncoder) {
|
||||
throw new Error("Password-based backup is not available on this platform");
|
||||
}
|
||||
const key = await globalThis.crypto.subtle.importKey("raw", new TextEncoder().encode(password), {
|
||||
name: "PBKDF2"
|
||||
}, false, ["deriveBits"]);
|
||||
const keybits = await globalThis.crypto.subtle.deriveBits({
|
||||
name: "PBKDF2",
|
||||
salt: new TextEncoder().encode(salt),
|
||||
iterations: iterations,
|
||||
hash: "SHA-512"
|
||||
}, key, numBits);
|
||||
return new Uint8Array(keybits);
|
||||
}
|
||||
|
||||
// Re-export the key passphrase functions to avoid breaking changes
|
|
@ -12,9 +12,9 @@ exports.pkSign = pkSign;
|
|||
exports.pkVerify = pkVerify;
|
||||
exports.verifySignature = verifySignature;
|
||||
var _anotherJson = _interopRequireDefault(require("another-json"));
|
||||
var _logger = require("../logger");
|
||||
var _event = require("../@types/event");
|
||||
var _utils = require("../utils");
|
||||
var _logger = require("../logger.js");
|
||||
var _event = require("../@types/event.js");
|
||||
var _utils = require("../utils.js");
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
|
|
|
@ -3,58 +3,14 @@
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.decodeRecoveryKey = decodeRecoveryKey;
|
||||
exports.encodeRecoveryKey = encodeRecoveryKey;
|
||||
var _bs = _interopRequireDefault(require("bs58"));
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
/*
|
||||
Copyright 2018 New Vector Ltd
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// picked arbitrarily but to try & avoid clashing with any bitcoin ones
|
||||
// (which are also base58 encoded, but bitcoin's involve a lot more hashing)
|
||||
const OLM_RECOVERY_KEY_PREFIX = [0x8b, 0x01];
|
||||
const KEY_SIZE = 32;
|
||||
function encodeRecoveryKey(key) {
|
||||
const buf = Buffer.alloc(OLM_RECOVERY_KEY_PREFIX.length + key.length + 1);
|
||||
buf.set(OLM_RECOVERY_KEY_PREFIX, 0);
|
||||
buf.set(key, OLM_RECOVERY_KEY_PREFIX.length);
|
||||
let parity = 0;
|
||||
for (let i = 0; i < buf.length - 1; ++i) {
|
||||
parity ^= buf[i];
|
||||
}
|
||||
buf[buf.length - 1] = parity;
|
||||
const base58key = _bs.default.encode(buf);
|
||||
return base58key.match(/.{1,4}/g)?.join(" ");
|
||||
}
|
||||
function decodeRecoveryKey(recoveryKey) {
|
||||
const result = _bs.default.decode(recoveryKey.replace(/ /g, ""));
|
||||
let parity = 0;
|
||||
for (const b of result) {
|
||||
parity ^= b;
|
||||
}
|
||||
if (parity !== 0) {
|
||||
throw new Error("Incorrect parity");
|
||||
}
|
||||
for (let i = 0; i < OLM_RECOVERY_KEY_PREFIX.length; ++i) {
|
||||
if (result[i] !== OLM_RECOVERY_KEY_PREFIX[i]) {
|
||||
throw new Error("Incorrect prefix");
|
||||
var _recoveryKey = require("../crypto-api/recovery-key.js");
|
||||
Object.keys(_recoveryKey).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _recoveryKey[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _recoveryKey[key];
|
||||
}
|
||||
}
|
||||
if (result.length !== OLM_RECOVERY_KEY_PREFIX.length + KEY_SIZE + 1) {
|
||||
throw new Error("Incorrect length");
|
||||
}
|
||||
return Uint8Array.from(result.slice(OLM_RECOVERY_KEY_PREFIX.length, OLM_RECOVERY_KEY_PREFIX.length + KEY_SIZE));
|
||||
}
|
||||
});
|
||||
});
|
|
@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.VERSION = exports.Backend = void 0;
|
||||
exports.upgradeDatabase = upgradeDatabase;
|
||||
var _logger = require("../../logger");
|
||||
var _utils = require("../../utils");
|
||||
var _base = require("./base");
|
||||
var _indexeddbCryptoStore = require("./indexeddb-crypto-store");
|
||||
var _logger = require("../../logger.js");
|
||||
var _utils = require("../../utils.js");
|
||||
var _base = require("./base.js");
|
||||
var _indexeddbCryptoStore = require("./indexeddb-crypto-store.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -1056,7 +1056,7 @@ function abortWithException(txn, e) {
|
|||
txn._mx_abortexception = e;
|
||||
try {
|
||||
txn.abort();
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// sometimes we won't be able to abort the transaction
|
||||
// (ie. if it's aborted or completed)
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.IndexedDBCryptoStore = void 0;
|
||||
var _logger = require("../../logger");
|
||||
var _localStorageCryptoStore = require("./localStorage-crypto-store");
|
||||
var _memoryCryptoStore = require("./memory-crypto-store");
|
||||
var IndexedDBCryptoStoreBackend = _interopRequireWildcard(require("./indexeddb-crypto-store-backend"));
|
||||
var _errors = require("../../errors");
|
||||
var IndexedDBHelpers = _interopRequireWildcard(require("../../indexeddb-helpers"));
|
||||
var _base = require("./base");
|
||||
var _logger = require("../../logger.js");
|
||||
var _localStorageCryptoStore = require("./localStorage-crypto-store.js");
|
||||
var _memoryCryptoStore = require("./memory-crypto-store.js");
|
||||
var IndexedDBCryptoStoreBackend = _interopRequireWildcard(require("./indexeddb-crypto-store-backend.js"));
|
||||
var _errors = require("../../errors.js");
|
||||
var IndexedDBHelpers = _interopRequireWildcard(require("../../indexeddb-helpers.js"));
|
||||
var _base = require("./base.js");
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.LocalStorageCryptoStore = void 0;
|
||||
var _logger = require("../../logger");
|
||||
var _memoryCryptoStore = require("./memory-crypto-store");
|
||||
var _base = require("./base");
|
||||
var _utils = require("../../utils");
|
||||
var _logger = require("../../logger.js");
|
||||
var _memoryCryptoStore = require("./memory-crypto-store.js");
|
||||
var _base = require("./base.js");
|
||||
var _utils = require("../../utils.js");
|
||||
/*
|
||||
Copyright 2017 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.MemoryCryptoStore = void 0;
|
||||
var _logger = require("../../logger");
|
||||
var _utils = require("../../utils");
|
||||
var _base = require("./base");
|
||||
var _logger = require("../../logger.js");
|
||||
var _utils = require("../../utils.js");
|
||||
var _base = require("./base.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.VerificationEvent = exports.VerificationBase = exports.SwitchStartEventError = void 0;
|
||||
var _event = require("../../models/event");
|
||||
var _event2 = require("../../@types/event");
|
||||
var _logger = require("../../logger");
|
||||
var _deviceinfo = require("../deviceinfo");
|
||||
var _Error = require("./Error");
|
||||
var _CrossSigning = require("../CrossSigning");
|
||||
var _typedEventEmitter = require("../../models/typed-event-emitter");
|
||||
var _verification = require("../../crypto-api/verification");
|
||||
var _event = require("../../models/event.js");
|
||||
var _event2 = require("../../@types/event.js");
|
||||
var _logger = require("../../logger.js");
|
||||
var _deviceinfo = require("../deviceinfo.js");
|
||||
var _Error = require("./Error.js");
|
||||
var _CrossSigning = require("../CrossSigning.js");
|
||||
var _typedEventEmitter = require("../../models/typed-event-emitter.js");
|
||||
var _verification = require("../../crypto-api/verification.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -7,8 +7,8 @@ exports.errorFactory = errorFactory;
|
|||
exports.errorFromEvent = errorFromEvent;
|
||||
exports.newUserCancelledError = exports.newUnknownMethodError = exports.newUnexpectedMessageError = exports.newTimeoutError = exports.newKeyMismatchError = exports.newInvalidMessageError = void 0;
|
||||
exports.newVerificationError = newVerificationError;
|
||||
var _event = require("../../models/event");
|
||||
var _event2 = require("../../@types/event");
|
||||
var _event = require("../../models/event.js");
|
||||
var _event2 = require("../../@types/event.js");
|
||||
/*
|
||||
Copyright 2018 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.IllegalMethod = void 0;
|
||||
var _Base = require("./Base");
|
||||
var _Base = require("./Base.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.SHOW_QR_CODE_METHOD = exports.SCAN_QR_CODE_METHOD = exports.ReciprocateQRCode = exports.QrCodeEvent = exports.QRCodeData = void 0;
|
||||
var _Base = require("./Base");
|
||||
var _Error = require("./Error");
|
||||
var _base = require("../../base64");
|
||||
var _logger = require("../../logger");
|
||||
var _verification = require("../../crypto-api/verification");
|
||||
var _types = require("../../types");
|
||||
var _Base = require("./Base.js");
|
||||
var _Error = require("./Error.js");
|
||||
var _base = require("../../base64.js");
|
||||
var _logger = require("../../logger.js");
|
||||
var _verification = require("../../crypto-api/verification.js");
|
||||
var _types = require("../../types.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.SasEvent = exports.SAS = void 0;
|
||||
var _anotherJson = _interopRequireDefault(require("another-json"));
|
||||
var _Base = require("./Base");
|
||||
var _Error = require("./Error");
|
||||
var _logger = require("../../logger");
|
||||
var _SASDecimal = require("./SASDecimal");
|
||||
var _event = require("../../@types/event");
|
||||
var _verification = require("../../crypto-api/verification");
|
||||
var _types = require("../../types");
|
||||
var _Base = require("./Base.js");
|
||||
var _Error = require("./Error.js");
|
||||
var _logger = require("../../logger.js");
|
||||
var _SASDecimal = require("./SASDecimal.js");
|
||||
var _event = require("../../@types/event.js");
|
||||
var _verification = require("../../crypto-api/verification.js");
|
||||
var _types = require("../../types.js");
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
|
|
|
@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.InRoomRequests = exports.InRoomChannel = void 0;
|
||||
var _VerificationRequest = require("./VerificationRequest");
|
||||
var _logger = require("../../../logger");
|
||||
var _event = require("../../../@types/event");
|
||||
var _VerificationRequest = require("./VerificationRequest.js");
|
||||
var _logger = require("../../../logger.js");
|
||||
var _event = require("../../../@types/event.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.ToDeviceRequests = exports.ToDeviceChannel = void 0;
|
||||
var _randomstring = require("../../../randomstring");
|
||||
var _logger = require("../../../logger");
|
||||
var _VerificationRequest = require("./VerificationRequest");
|
||||
var _Error = require("../Error");
|
||||
var _event = require("../../../models/event");
|
||||
var _randomstring = require("../../../randomstring.js");
|
||||
var _logger = require("../../../logger.js");
|
||||
var _VerificationRequest = require("./VerificationRequest.js");
|
||||
var _Error = require("../Error.js");
|
||||
var _event = require("../../../models/event.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -17,12 +17,12 @@ Object.defineProperty(exports, "VerificationRequestEvent", {
|
|||
return _verification.VerificationRequestEvent;
|
||||
}
|
||||
});
|
||||
var _logger = require("../../../logger");
|
||||
var _Error = require("../Error");
|
||||
var _QRCode = require("../QRCode");
|
||||
var _event = require("../../../@types/event");
|
||||
var _typedEventEmitter = require("../../../models/typed-event-emitter");
|
||||
var _verification = require("../../../crypto-api/verification");
|
||||
var _logger = require("../../../logger.js");
|
||||
var _Error = require("../Error.js");
|
||||
var _QRCode = require("../QRCode.js");
|
||||
var _event = require("../../../@types/event.js");
|
||||
var _typedEventEmitter = require("../../../models/typed-event-emitter.js");
|
||||
var _verification = require("../../../crypto-api/verification.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -5,14 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.RoomWidgetClient = void 0;
|
||||
var _matrixWidgetApi = require("matrix-widget-api");
|
||||
var _event = require("./models/event");
|
||||
var _event2 = require("./@types/event");
|
||||
var _logger = require("./logger");
|
||||
var _client = require("./client");
|
||||
var _sync = require("./sync");
|
||||
var _slidingSyncSdk = require("./sliding-sync-sdk");
|
||||
var _user = require("./models/user");
|
||||
var _utils = require("./utils");
|
||||
var _event = require("./models/event.js");
|
||||
var _event2 = require("./@types/event.js");
|
||||
var _logger = require("./logger.js");
|
||||
var _client = require("./client.js");
|
||||
var _sync = require("./sync.js");
|
||||
var _slidingSyncSdk = require("./sliding-sync-sdk.js");
|
||||
var _user = require("./models/user.js");
|
||||
var _utils = require("./utils.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -198,14 +200,20 @@ class RoomWidgetClient extends _client.MatrixClient {
|
|||
throw new Error(`Unknown room: ${roomIdOrAlias}`);
|
||||
}
|
||||
async encryptAndSendEvent(room, event, delayOpts) {
|
||||
// We need to extend the content with the redacts parameter
|
||||
// The js sdk uses event.redacts but the widget api uses event.content.redacts
|
||||
// This will be converted back to event.redacts in the widget driver.
|
||||
const content = event.event.redacts ? _objectSpread(_objectSpread({}, event.getContent()), {}, {
|
||||
redacts: event.event.redacts
|
||||
}) : event.getContent();
|
||||
if (delayOpts) {
|
||||
// TODO: updatePendingEvent for delayed events?
|
||||
const response = await this.widgetApi.sendRoomEvent(event.getType(), event.getContent(), room.roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined);
|
||||
const response = await this.widgetApi.sendRoomEvent(event.getType(), content, room.roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined);
|
||||
return this.validateSendDelayedEventResponse(response);
|
||||
}
|
||||
let response;
|
||||
try {
|
||||
response = await this.widgetApi.sendRoomEvent(event.getType(), event.getContent(), room.roomId);
|
||||
response = await this.widgetApi.sendRoomEvent(event.getType(), content, room.roomId);
|
||||
} catch (e) {
|
||||
this.updatePendingEventStatus(room, event, _event.EventStatus.NOT_SENT);
|
||||
throw e;
|
||||
|
|
|
@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.eventMapperFor = eventMapperFor;
|
||||
var _event = require("./models/event");
|
||||
var _event2 = require("./@types/event");
|
||||
var _event = require("./models/event.js");
|
||||
var _event2 = require("./@types/event.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.MessageEvent = void 0;
|
||||
var _ExtensibleEvent = require("./ExtensibleEvent");
|
||||
var _extensible_events = require("../@types/extensible_events");
|
||||
var _utilities = require("./utilities");
|
||||
var _InvalidEventError = require("./InvalidEventError");
|
||||
var _ExtensibleEvent = require("./ExtensibleEvent.js");
|
||||
var _extensible_events = require("../@types/extensible_events.js");
|
||||
var _utilities = require("./utilities.js");
|
||||
var _InvalidEventError = require("./InvalidEventError.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.PollEndEvent = void 0;
|
||||
var _extensible_events = require("../@types/extensible_events");
|
||||
var _polls = require("../@types/polls");
|
||||
var _ExtensibleEvent = require("./ExtensibleEvent");
|
||||
var _InvalidEventError = require("./InvalidEventError");
|
||||
var _MessageEvent = require("./MessageEvent");
|
||||
var _extensible_events = require("../@types/extensible_events.js");
|
||||
var _polls = require("../@types/polls.js");
|
||||
var _ExtensibleEvent = require("./ExtensibleEvent.js");
|
||||
var _InvalidEventError = require("./InvalidEventError.js");
|
||||
var _MessageEvent = require("./MessageEvent.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.PollResponseEvent = void 0;
|
||||
var _ExtensibleEvent = require("./ExtensibleEvent");
|
||||
var _polls = require("../@types/polls");
|
||||
var _extensible_events = require("../@types/extensible_events");
|
||||
var _InvalidEventError = require("./InvalidEventError");
|
||||
var _ExtensibleEvent = require("./ExtensibleEvent.js");
|
||||
var _polls = require("../@types/polls.js");
|
||||
var _extensible_events = require("../@types/extensible_events.js");
|
||||
var _InvalidEventError = require("./InvalidEventError.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.PollStartEvent = exports.PollAnswerSubevent = void 0;
|
||||
var _matrixEventsSdk = require("matrix-events-sdk");
|
||||
var _MessageEvent = require("./MessageEvent");
|
||||
var _extensible_events = require("../@types/extensible_events");
|
||||
var _polls = require("../@types/polls");
|
||||
var _InvalidEventError = require("./InvalidEventError");
|
||||
var _ExtensibleEvent = require("./ExtensibleEvent");
|
||||
var _MessageEvent = require("./MessageEvent.js");
|
||||
var _extensible_events = require("../@types/extensible_events.js");
|
||||
var _polls = require("../@types/polls.js");
|
||||
var _InvalidEventError = require("./InvalidEventError.js");
|
||||
var _ExtensibleEvent = require("./ExtensibleEvent.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -34,7 +34,6 @@ let Feature = exports.Feature = /*#__PURE__*/function (Feature) {
|
|||
Feature["AccountDataDeletion"] = "AccountDataDeletion";
|
||||
Feature["RelationsRecursion"] = "RelationsRecursion";
|
||||
Feature["IntentionalMentions"] = "IntentionalMentions";
|
||||
Feature["MigrateServerNameToVia"] = "MigrateServerNameToVia";
|
||||
return Feature;
|
||||
}({});
|
||||
const featureSupportResolver = {
|
||||
|
@ -61,9 +60,6 @@ const featureSupportResolver = {
|
|||
[Feature.IntentionalMentions]: {
|
||||
unstablePrefixes: ["org.matrix.msc3952_intentional_mentions"],
|
||||
matrixVersion: "v1.7"
|
||||
},
|
||||
[Feature.MigrateServerNameToVia]: {
|
||||
unstablePrefixes: ["org.matrix.msc4156"]
|
||||
}
|
||||
};
|
||||
async function buildFeatureSupportMap(versions) {
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.FilterComponent = void 0;
|
||||
var _thread = require("./models/thread");
|
||||
var _thread = require("./models/thread.js");
|
||||
/*
|
||||
Copyright 2016 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.Filter = void 0;
|
||||
var _sync = require("./@types/sync");
|
||||
var _filterComponent = require("./filter-component");
|
||||
var _sync = require("./@types/sync.js");
|
||||
var _filterComponent = require("./filter-component.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.FetchHttpApi = void 0;
|
||||
var _utils = require("../utils");
|
||||
var _method = require("./method");
|
||||
var _errors = require("./errors");
|
||||
var _interface = require("./interface");
|
||||
var _utils2 = require("./utils");
|
||||
var _utils = require("../utils.js");
|
||||
var _method = require("./method.js");
|
||||
var _errors = require("./errors.js");
|
||||
var _interface = require("./interface.js");
|
||||
var _utils2 = require("./utils.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
@ -305,7 +305,7 @@ class FetchHttpApi {
|
|||
const sanitizedQsString = sanitizedQs.toString();
|
||||
const sanitizedQsUrlPiece = sanitizedQsString ? `?${sanitizedQsString}` : "";
|
||||
return asUrl.origin + asUrl.pathname + sanitizedQsUrlPiece;
|
||||
} catch (error) {
|
||||
} catch {
|
||||
// defensive coding for malformed url
|
||||
return "??";
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ var _exportNames = {
|
|||
MatrixHttpApi: true
|
||||
};
|
||||
exports.MatrixHttpApi = void 0;
|
||||
var _fetch = require("./fetch");
|
||||
var _prefix = require("./prefix");
|
||||
var _fetch = require("./fetch.js");
|
||||
var _prefix = require("./prefix.js");
|
||||
Object.keys(_prefix).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -20,9 +20,9 @@ Object.keys(_prefix).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _utils = require("../utils");
|
||||
var callbacks = _interopRequireWildcard(require("../realtime-callbacks"));
|
||||
var _method = require("./method");
|
||||
var _utils = require("../utils.js");
|
||||
var callbacks = _interopRequireWildcard(require("../realtime-callbacks.js"));
|
||||
var _method = require("./method.js");
|
||||
Object.keys(_method).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -34,7 +34,7 @@ Object.keys(_method).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _errors = require("./errors");
|
||||
var _errors = require("./errors.js");
|
||||
Object.keys(_errors).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -46,7 +46,7 @@ Object.keys(_errors).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _utils2 = require("./utils");
|
||||
var _utils2 = require("./utils.js");
|
||||
Object.keys(_utils2).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -58,7 +58,7 @@ Object.keys(_utils2).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _interface = require("./interface");
|
||||
var _interface = require("./interface.js");
|
||||
Object.keys(_interface).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
|
|
@ -9,9 +9,9 @@ exports.parseErrorResponse = parseErrorResponse;
|
|||
exports.retryNetworkOperation = retryNetworkOperation;
|
||||
exports.timeoutSignal = timeoutSignal;
|
||||
var _contentType = require("content-type");
|
||||
var _logger = require("../logger");
|
||||
var _utils = require("../utils");
|
||||
var _errors = require("./errors");
|
||||
var _logger = require("../logger.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _errors = require("./errors.js");
|
||||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
var _exportNames = {};
|
||||
exports.default = void 0;
|
||||
var matrixcs = _interopRequireWildcard(require("./matrix"));
|
||||
var matrixcs = _interopRequireWildcard(require("./matrix.js"));
|
||||
Object.keys(matrixcs).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
|
|
@ -9,4 +9,4 @@ Object.defineProperty(exports, "IndexedDBStoreWorker", {
|
|||
return _indexeddbStoreWorker.IndexedDBStoreWorker;
|
||||
}
|
||||
});
|
||||
var _indexeddbStoreWorker = require("./store/indexeddb-store-worker");
|
||||
var _indexeddbStoreWorker = require("./store/indexeddb-store-worker.js");
|
|
@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.NoAuthFlowFoundError = exports.InteractiveAuth = exports.AuthType = void 0;
|
||||
var _logger = require("./logger");
|
||||
var _utils = require("./utils");
|
||||
var _httpApi = require("./http-api");
|
||||
var _logger = require("./logger.js");
|
||||
var _utils = require("./utils.js");
|
||||
var _index = require("./http-api/index.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -280,7 +280,7 @@ class InteractiveAuth {
|
|||
while (this.submitPromise) {
|
||||
try {
|
||||
await this.submitPromise;
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// use the sessionid from the last request, if one is present.
|
||||
|
@ -344,7 +344,7 @@ class InteractiveAuth {
|
|||
this.attemptAuthDeferred.resolve(result);
|
||||
this.attemptAuthDeferred = null;
|
||||
} catch (error) {
|
||||
const matrixError = error instanceof _httpApi.MatrixError ? error : null;
|
||||
const matrixError = error instanceof _index.MatrixError ? error : null;
|
||||
|
||||
// sometimes UI auth errors don't come with flows
|
||||
const errorFlows = matrixError?.data?.flows ?? null;
|
||||
|
|
|
@ -49,7 +49,7 @@ exports.Crypto = exports.ContentHelpers = void 0;
|
|||
Object.defineProperty(exports, "CryptoEvent", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _crypto2.CryptoEvent;
|
||||
return _index3.CryptoEvent;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "GroupCall", {
|
||||
|
@ -170,7 +170,7 @@ Object.defineProperty(exports, "createNewMatrixCall", {
|
|||
});
|
||||
exports.createRoomWidgetClient = createRoomWidgetClient;
|
||||
exports.setCryptoStoreFactory = setCryptoStoreFactory;
|
||||
var _memoryCryptoStore = require("./crypto/store/memory-crypto-store");
|
||||
var _memoryCryptoStore = require("./crypto/store/memory-crypto-store.js");
|
||||
Object.keys(_memoryCryptoStore).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -182,7 +182,7 @@ Object.keys(_memoryCryptoStore).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _memory = require("./store/memory");
|
||||
var _memory = require("./store/memory.js");
|
||||
Object.keys(_memory).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -194,7 +194,7 @@ Object.keys(_memory).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _scheduler = require("./scheduler");
|
||||
var _scheduler = require("./scheduler.js");
|
||||
Object.keys(_scheduler).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -206,7 +206,7 @@ Object.keys(_scheduler).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _client = require("./client");
|
||||
var _client = require("./client.js");
|
||||
Object.keys(_client).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -218,7 +218,7 @@ Object.keys(_client).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _embedded = require("./embedded");
|
||||
var _embedded = require("./embedded.js");
|
||||
Object.keys(_embedded).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -230,7 +230,7 @@ Object.keys(_embedded).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _serverCapabilities = require("./serverCapabilities");
|
||||
var _serverCapabilities = require("./serverCapabilities.js");
|
||||
Object.keys(_serverCapabilities).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -242,19 +242,19 @@ Object.keys(_serverCapabilities).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _httpApi = require("./http-api");
|
||||
Object.keys(_httpApi).forEach(function (key) {
|
||||
var _index = require("./http-api/index.js");
|
||||
Object.keys(_index).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _httpApi[key]) return;
|
||||
if (key in exports && exports[key] === _index[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _httpApi[key];
|
||||
return _index[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _autodiscovery = require("./autodiscovery");
|
||||
var _autodiscovery = require("./autodiscovery.js");
|
||||
Object.keys(_autodiscovery).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -266,7 +266,7 @@ Object.keys(_autodiscovery).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _syncAccumulator = require("./sync-accumulator");
|
||||
var _syncAccumulator = require("./sync-accumulator.js");
|
||||
Object.keys(_syncAccumulator).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -278,7 +278,7 @@ Object.keys(_syncAccumulator).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _errors = require("./errors");
|
||||
var _errors = require("./errors.js");
|
||||
Object.keys(_errors).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -290,7 +290,7 @@ Object.keys(_errors).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _base = require("./base64");
|
||||
var _base = require("./base64.js");
|
||||
Object.keys(_base).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -302,7 +302,7 @@ Object.keys(_base).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _beacon = require("./models/beacon");
|
||||
var _beacon = require("./models/beacon.js");
|
||||
Object.keys(_beacon).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -314,7 +314,7 @@ Object.keys(_beacon).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _event = require("./models/event");
|
||||
var _event = require("./models/event.js");
|
||||
Object.keys(_event).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -326,7 +326,7 @@ Object.keys(_event).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _room = require("./models/room");
|
||||
var _room = require("./models/room.js");
|
||||
Object.keys(_room).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -338,7 +338,7 @@ Object.keys(_room).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _eventTimeline = require("./models/event-timeline");
|
||||
var _eventTimeline = require("./models/event-timeline.js");
|
||||
Object.keys(_eventTimeline).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -350,7 +350,7 @@ Object.keys(_eventTimeline).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _eventTimelineSet = require("./models/event-timeline-set");
|
||||
var _eventTimelineSet = require("./models/event-timeline-set.js");
|
||||
Object.keys(_eventTimelineSet).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -362,7 +362,7 @@ Object.keys(_eventTimelineSet).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _poll = require("./models/poll");
|
||||
var _poll = require("./models/poll.js");
|
||||
Object.keys(_poll).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -374,7 +374,7 @@ Object.keys(_poll).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _roomMember = require("./models/room-member");
|
||||
var _roomMember = require("./models/room-member.js");
|
||||
Object.keys(_roomMember).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -386,7 +386,7 @@ Object.keys(_roomMember).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _roomState = require("./models/room-state");
|
||||
var _roomState = require("./models/room-state.js");
|
||||
Object.keys(_roomState).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -398,7 +398,7 @@ Object.keys(_roomState).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _thread = require("./models/thread");
|
||||
var _thread = require("./models/thread.js");
|
||||
Object.keys(_thread).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -410,7 +410,7 @@ Object.keys(_thread).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _typedEventEmitter = require("./models/typed-event-emitter");
|
||||
var _typedEventEmitter = require("./models/typed-event-emitter.js");
|
||||
Object.keys(_typedEventEmitter).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -422,7 +422,7 @@ Object.keys(_typedEventEmitter).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _user = require("./models/user");
|
||||
var _user = require("./models/user.js");
|
||||
Object.keys(_user).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -434,7 +434,7 @@ Object.keys(_user).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _device = require("./models/device");
|
||||
var _device = require("./models/device.js");
|
||||
Object.keys(_device).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -446,7 +446,7 @@ Object.keys(_device).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _searchResult = require("./models/search-result");
|
||||
var _searchResult = require("./models/search-result.js");
|
||||
Object.keys(_searchResult).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -458,19 +458,19 @@ Object.keys(_searchResult).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _oidc = require("./oidc");
|
||||
Object.keys(_oidc).forEach(function (key) {
|
||||
var _index2 = require("./oidc/index.js");
|
||||
Object.keys(_index2).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _oidc[key]) return;
|
||||
if (key in exports && exports[key] === _index2[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _oidc[key];
|
||||
return _index2[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _filter = require("./filter");
|
||||
var _filter = require("./filter.js");
|
||||
Object.keys(_filter).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -482,7 +482,7 @@ Object.keys(_filter).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _timelineWindow = require("./timeline-window");
|
||||
var _timelineWindow = require("./timeline-window.js");
|
||||
Object.keys(_timelineWindow).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -494,7 +494,7 @@ Object.keys(_timelineWindow).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _interactiveAuth = require("./interactive-auth");
|
||||
var _interactiveAuth = require("./interactive-auth.js");
|
||||
Object.keys(_interactiveAuth).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -506,7 +506,7 @@ Object.keys(_interactiveAuth).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _serviceTypes = require("./service-types");
|
||||
var _serviceTypes = require("./service-types.js");
|
||||
Object.keys(_serviceTypes).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -518,7 +518,7 @@ Object.keys(_serviceTypes).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _indexeddb = require("./store/indexeddb");
|
||||
var _indexeddb = require("./store/indexeddb.js");
|
||||
Object.keys(_indexeddb).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -530,7 +530,7 @@ Object.keys(_indexeddb).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _localStorageCryptoStore = require("./crypto/store/localStorage-crypto-store");
|
||||
var _localStorageCryptoStore = require("./crypto/store/localStorage-crypto-store.js");
|
||||
Object.keys(_localStorageCryptoStore).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -542,7 +542,7 @@ Object.keys(_localStorageCryptoStore).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _indexeddbCryptoStore = require("./crypto/store/indexeddb-crypto-store");
|
||||
var _indexeddbCryptoStore = require("./crypto/store/indexeddb-crypto-store.js");
|
||||
Object.keys(_indexeddbCryptoStore).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -554,7 +554,7 @@ Object.keys(_indexeddbCryptoStore).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _contentRepo = require("./content-repo");
|
||||
var _contentRepo = require("./content-repo.js");
|
||||
Object.keys(_contentRepo).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -566,31 +566,7 @@ Object.keys(_contentRepo).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _common = require("./@types/common");
|
||||
Object.keys(_common).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _common[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _common[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _uia = require("./@types/uia");
|
||||
Object.keys(_uia).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _uia[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _uia[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _event2 = require("./@types/event");
|
||||
var _event2 = require("./@types/event.js");
|
||||
Object.keys(_event2).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -602,7 +578,7 @@ Object.keys(_event2).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _PushRules = require("./@types/PushRules");
|
||||
var _PushRules = require("./@types/PushRules.js");
|
||||
Object.keys(_PushRules).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -614,7 +590,7 @@ Object.keys(_PushRules).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _partials = require("./@types/partials");
|
||||
var _partials = require("./@types/partials.js");
|
||||
Object.keys(_partials).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -626,7 +602,7 @@ Object.keys(_partials).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _requests = require("./@types/requests");
|
||||
var _requests = require("./@types/requests.js");
|
||||
Object.keys(_requests).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -638,7 +614,7 @@ Object.keys(_requests).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _search = require("./@types/search");
|
||||
var _search = require("./@types/search.js");
|
||||
Object.keys(_search).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -650,7 +626,7 @@ Object.keys(_search).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _beacon2 = require("./@types/beacon");
|
||||
var _beacon2 = require("./@types/beacon.js");
|
||||
Object.keys(_beacon2).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -662,7 +638,7 @@ Object.keys(_beacon2).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _topic = require("./@types/topic");
|
||||
var _topic = require("./@types/topic.js");
|
||||
Object.keys(_topic).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -674,7 +650,7 @@ Object.keys(_topic).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _location = require("./@types/location");
|
||||
var _location = require("./@types/location.js");
|
||||
Object.keys(_location).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -686,7 +662,7 @@ Object.keys(_location).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _threepids = require("./@types/threepids");
|
||||
var _threepids = require("./@types/threepids.js");
|
||||
Object.keys(_threepids).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -698,7 +674,7 @@ Object.keys(_threepids).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _auth = require("./@types/auth");
|
||||
var _auth = require("./@types/auth.js");
|
||||
Object.keys(_auth).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -710,7 +686,7 @@ Object.keys(_auth).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _polls = require("./@types/polls");
|
||||
var _polls = require("./@types/polls.js");
|
||||
Object.keys(_polls).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -722,31 +698,7 @@ Object.keys(_polls).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _local_notifications = require("./@types/local_notifications");
|
||||
Object.keys(_local_notifications).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _local_notifications[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _local_notifications[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _registration = require("./@types/registration");
|
||||
Object.keys(_registration).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _registration[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _registration[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _read_receipts = require("./@types/read_receipts");
|
||||
var _read_receipts = require("./@types/read_receipts.js");
|
||||
Object.keys(_read_receipts).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -758,19 +710,7 @@ Object.keys(_read_receipts).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _crypto = require("./@types/crypto");
|
||||
Object.keys(_crypto).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _crypto[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _crypto[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _extensible_events = require("./@types/extensible_events");
|
||||
var _extensible_events = require("./@types/extensible_events.js");
|
||||
Object.keys(_extensible_events).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -782,19 +722,19 @@ Object.keys(_extensible_events).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _IIdentityServerProvider = require("./@types/IIdentityServerProvider");
|
||||
Object.keys(_IIdentityServerProvider).forEach(function (key) {
|
||||
var _membership = require("./@types/membership.js");
|
||||
Object.keys(_membership).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _IIdentityServerProvider[key]) return;
|
||||
if (key in exports && exports[key] === _membership[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _IIdentityServerProvider[key];
|
||||
return _membership[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _roomSummary = require("./models/room-summary");
|
||||
var _roomSummary = require("./models/room-summary.js");
|
||||
Object.keys(_roomSummary).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -806,7 +746,7 @@ Object.keys(_roomSummary).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _eventStatus = require("./models/event-status");
|
||||
var _eventStatus = require("./models/event-status.js");
|
||||
Object.keys(_eventStatus).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
|
@ -818,21 +758,21 @@ Object.keys(_eventStatus).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _ContentHelpers = _interopRequireWildcard(require("./content-helpers"));
|
||||
var _ContentHelpers = _interopRequireWildcard(require("./content-helpers.js"));
|
||||
exports.ContentHelpers = _ContentHelpers;
|
||||
var _SecretStorage = _interopRequireWildcard(require("./secret-storage"));
|
||||
var _SecretStorage = _interopRequireWildcard(require("./secret-storage.js"));
|
||||
exports.SecretStorage = _SecretStorage;
|
||||
var _call = require("./webrtc/call");
|
||||
var _groupCall = require("./webrtc/groupCall");
|
||||
var _crypto2 = require("./crypto");
|
||||
var _sync = require("./sync");
|
||||
var _slidingSync = require("./sliding-sync");
|
||||
var _mediaHandler = require("./webrtc/mediaHandler");
|
||||
var _callFeed = require("./webrtc/callFeed");
|
||||
var _statsReport = require("./webrtc/stats/statsReport");
|
||||
var _relations = require("./models/relations");
|
||||
var _localStorageEventsEmitter = require("./store/local-storage-events-emitter");
|
||||
var _Crypto = _interopRequireWildcard(require("./crypto-api"));
|
||||
var _call = require("./webrtc/call.js");
|
||||
var _groupCall = require("./webrtc/groupCall.js");
|
||||
var _index3 = require("./crypto/index.js");
|
||||
var _sync = require("./sync.js");
|
||||
var _slidingSync = require("./sliding-sync.js");
|
||||
var _mediaHandler = require("./webrtc/mediaHandler.js");
|
||||
var _callFeed = require("./webrtc/callFeed.js");
|
||||
var _statsReport = require("./webrtc/stats/statsReport.js");
|
||||
var _relations = require("./models/relations.js");
|
||||
var _localStorageEventsEmitter = require("./store/local-storage-events-emitter.js");
|
||||
var _Crypto = _interopRequireWildcard(require("./crypto-api/index.js"));
|
||||
exports.Crypto = _Crypto;
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
|
@ -854,12 +794,7 @@ limitations under the License.
|
|||
|
||||
// used to be located here
|
||||
|
||||
/**
|
||||
* Types supporting cryptography.
|
||||
*
|
||||
* The most important is {@link Crypto.CryptoApi}, an instance of which can be retrieved via
|
||||
* {@link MatrixClient.getCrypto}.
|
||||
*/
|
||||
/** @deprecated Backwards-compatibility re-export. Import from `crypto-api` directly. */
|
||||
|
||||
let cryptoStoreFactory = () => new _memoryCryptoStore.MemoryCryptoStore();
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.isSessionMembershipData = exports.isLegacyCallMembershipData = exports.CallMembership = void 0;
|
||||
var _utils = require("../utils");
|
||||
var _LivekitFocus = require("./LivekitFocus");
|
||||
var _utils = require("../utils.js");
|
||||
var _LivekitFocus = require("./LivekitFocus.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -93,6 +93,9 @@ class CallMembership {
|
|||
get sender() {
|
||||
return this.parentEvent.getSender();
|
||||
}
|
||||
get eventId() {
|
||||
return this.parentEvent.getId();
|
||||
}
|
||||
get callId() {
|
||||
return this.membershipData.call_id;
|
||||
}
|
||||
|
@ -115,7 +118,13 @@ class CallMembership {
|
|||
createdTs() {
|
||||
return this.membershipData.created_ts ?? this.parentEvent.getTs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the absolute expiry time of the membership if applicable to this membership type.
|
||||
* @returns The absolute expiry time of the membership as a unix timestamp in milliseconds or undefined if not applicable
|
||||
*/
|
||||
getAbsoluteExpiry() {
|
||||
// if the membership is not a legacy membership, we assume it is MSC4143
|
||||
if (!isLegacyCallMembershipData(this.membershipData)) return undefined;
|
||||
if ("expires" in this.membershipData) {
|
||||
// we know createdTs exists since we already do the isLegacyCallMembershipData check
|
||||
|
@ -126,8 +135,13 @@ class CallMembership {
|
|||
}
|
||||
}
|
||||
|
||||
// gets the expiry time of the event, converted into the device's local time
|
||||
/**
|
||||
* Gets the expiry time of the event, converted into the device's local time.
|
||||
* @deprecated This function has been observed returning bad data and is no longer used by MatrixRTC.
|
||||
* @returns The local expiry time of the membership as a unix timestamp in milliseconds or undefined if not applicable
|
||||
*/
|
||||
getLocalExpiry() {
|
||||
// if the membership is not a legacy membership, we assume it is MSC4143
|
||||
if (!isLegacyCallMembershipData(this.membershipData)) return undefined;
|
||||
if ("expires" in this.membershipData) {
|
||||
// we know createdTs exists since we already do the isLegacyCallMembershipData check
|
||||
|
@ -140,9 +154,25 @@ class CallMembership {
|
|||
return this.membershipData.expires_ts;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns The number of milliseconds until the membership expires or undefined if applicable
|
||||
*/
|
||||
getMsUntilExpiry() {
|
||||
if (isLegacyCallMembershipData(this.membershipData)) return this.getLocalExpiry() - Date.now();
|
||||
if (isLegacyCallMembershipData(this.membershipData)) {
|
||||
// Assume that local clock is sufficiently in sync with other clocks in the distributed system.
|
||||
// We used to try and adjust for the local clock being skewed, but there are cases where this is not accurate.
|
||||
// The current implementation allows for the local clock to be -infinity to +MatrixRTCSession.MEMBERSHIP_EXPIRY_TIME/2
|
||||
return this.getAbsoluteExpiry() - Date.now();
|
||||
}
|
||||
|
||||
// Assumed to be MSC4143
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns true if the membership has expired, otherwise false
|
||||
*/
|
||||
isExpired() {
|
||||
if (isLegacyCallMembershipData(this.membershipData)) return this.getMsUntilExpiry() <= 0;
|
||||
|
||||
|
|
|
@ -4,17 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.MatrixRTCSessionEvent = exports.MatrixRTCSession = void 0;
|
||||
var _logger = require("../logger");
|
||||
var _typedEventEmitter = require("../models/typed-event-emitter");
|
||||
var _eventTimeline = require("../models/event-timeline");
|
||||
var _event = require("../@types/event");
|
||||
var _requests = require("../@types/requests");
|
||||
var _CallMembership = require("./CallMembership");
|
||||
var _roomState = require("../models/room-state");
|
||||
var _randomstring = require("../randomstring");
|
||||
var _base = require("../base64");
|
||||
var _membership = require("../@types/membership");
|
||||
var _LivekitFocus = require("./LivekitFocus");
|
||||
var _logger = require("../logger.js");
|
||||
var _typedEventEmitter = require("../models/typed-event-emitter.js");
|
||||
var _eventTimeline = require("../models/event-timeline.js");
|
||||
var _event = require("../@types/event.js");
|
||||
var _requests = require("../@types/requests.js");
|
||||
var _CallMembership = require("./CallMembership.js");
|
||||
var _roomState = require("../models/room-state.js");
|
||||
var _randomstring = require("../randomstring.js");
|
||||
var _base = require("../base64.js");
|
||||
var _membership = require("../@types/membership.js");
|
||||
var _LivekitFocus = require("./LivekitFocus.js");
|
||||
var _utils = require("../utils.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
@ -34,6 +35,7 @@ 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 logger = _logger.logger.getChild("MatrixRTCSession");
|
||||
const MEMBERSHIP_EXPIRY_TIME = 60 * 60 * 1000;
|
||||
const MEMBER_EVENT_CHECK_PERIOD = 2 * 60 * 1000; // How often we check to see if we need to re-send our member event
|
||||
const CALL_MEMBER_EVENT_RETRY_DELAY_MIN = 3000;
|
||||
|
@ -51,7 +53,7 @@ const getParticipantId = (userId, deviceId) => `${userId}:${deviceId}`;
|
|||
const getParticipantIdFromMembership = m => getParticipantId(m.sender, m.deviceId);
|
||||
function keysEqual(a, b) {
|
||||
if (a === b) return true;
|
||||
return a && b && a.length === b.length && a.every((x, i) => x === b[i]);
|
||||
return !!a && !!b && a.length === b.length && a.every((x, i) => x === b[i]);
|
||||
}
|
||||
let MatrixRTCSessionEvent = exports.MatrixRTCSessionEvent = /*#__PURE__*/function (MatrixRTCSessionEvent) {
|
||||
MatrixRTCSessionEvent["MembershipsChanged"] = "memberships_changed";
|
||||
|
@ -79,7 +81,7 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
static callMembershipsForRoom(room) {
|
||||
const roomState = room.getLiveTimeline().getState(_eventTimeline.EventTimeline.FORWARDS);
|
||||
if (!roomState) {
|
||||
_logger.logger.warn("Couldn't get state for room " + room.roomId);
|
||||
logger.warn("Couldn't get state for room " + room.roomId);
|
||||
throw new Error("Could't get state for room " + room.roomId);
|
||||
}
|
||||
const callMemberEvents = roomState.getStateEvents(_event.EventType.GroupCallMemberPrefix);
|
||||
|
@ -98,7 +100,7 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
} else if (eventKeysCount === 1 && "memberships" in content) {
|
||||
// we have a legacy (one event for all devices) event
|
||||
if (!Array.isArray(content["memberships"])) {
|
||||
_logger.logger.warn(`Malformed member event from ${memberEvent.getSender()}: memberships is not an array`);
|
||||
logger.warn(`Malformed member event from ${memberEvent.getSender()}: memberships is not an array`);
|
||||
continue;
|
||||
}
|
||||
membershipContents = content["memberships"];
|
||||
|
@ -109,26 +111,26 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
const membership = new _CallMembership.CallMembership(memberEvent, membershipData);
|
||||
if (membership.callId !== "" || membership.scope !== "m.room") {
|
||||
// for now, just ignore anything that isn't a room scope call
|
||||
_logger.logger.info(`Ignoring user-scoped call`);
|
||||
logger.info(`Ignoring user-scoped call`);
|
||||
continue;
|
||||
}
|
||||
if (membership.isExpired()) {
|
||||
_logger.logger.info(`Ignoring expired device membership ${membership.sender}/${membership.deviceId}`);
|
||||
logger.info(`Ignoring expired device membership ${membership.sender}/${membership.deviceId}`);
|
||||
continue;
|
||||
}
|
||||
if (!room.hasMembershipState(membership.sender ?? "", _membership.KnownMembership.Join)) {
|
||||
_logger.logger.info(`Ignoring membership of user ${membership.sender} who is not in the room.`);
|
||||
logger.info(`Ignoring membership of user ${membership.sender} who is not in the room.`);
|
||||
continue;
|
||||
}
|
||||
callMemberships.push(membership);
|
||||
} catch (e) {
|
||||
_logger.logger.warn("Couldn't construct call membership: ", e);
|
||||
logger.warn("Couldn't construct call membership: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
callMemberships.sort((a, b) => a.createdTs() - b.createdTs());
|
||||
if (callMemberships.length > 1) {
|
||||
_logger.logger.debug(`Call memberships in room ${room.roomId}, in order: `, callMemberships.map(m => [m.createdTs(), m.sender]));
|
||||
logger.debug(`Call memberships in room ${room.roomId}, in order: `, callMemberships.map(m => [m.createdTs(), m.sender]));
|
||||
}
|
||||
return callMemberships;
|
||||
}
|
||||
|
@ -170,41 +172,75 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
_defineProperty(this, "needCallMembershipUpdate", false);
|
||||
_defineProperty(this, "manageMediaKeys", false);
|
||||
_defineProperty(this, "useLegacyMemberEvents", true);
|
||||
// userId:deviceId => array of keys
|
||||
// userId:deviceId => array of (key, timestamp)
|
||||
_defineProperty(this, "encryptionKeys", new Map());
|
||||
_defineProperty(this, "lastEncryptionKeyUpdateRequest", void 0);
|
||||
_defineProperty(this, "disconnectDelayId", void 0);
|
||||
// We use this to store the last membership fingerprints we saw, so we can proactively re-send encryption keys
|
||||
// if it looks like a membership has been updated.
|
||||
_defineProperty(this, "lastMembershipFingerprints", void 0);
|
||||
_defineProperty(this, "currentEncryptionKeyIndex", -1);
|
||||
/**
|
||||
* The statistics for this session.
|
||||
*/
|
||||
_defineProperty(this, "statistics", {
|
||||
counters: {
|
||||
/**
|
||||
* The number of times we have sent a room event containing encryption keys.
|
||||
*/
|
||||
roomEventEncryptionKeysSent: 0,
|
||||
/**
|
||||
* The number of times we have received a room event containing encryption keys.
|
||||
*/
|
||||
roomEventEncryptionKeysReceived: 0
|
||||
},
|
||||
totals: {
|
||||
/**
|
||||
* The total age (in milliseconds) of all room events containing encryption keys that we have received.
|
||||
* We track the total age so that we can later calculate the average age of all keys received.
|
||||
*/
|
||||
roomEventEncryptionKeysReceivedTotalAge: 0
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Re-sends the encryption keys room event
|
||||
*/
|
||||
_defineProperty(this, "sendEncryptionKeysEvent", async () => {
|
||||
_defineProperty(this, "sendEncryptionKeysEvent", async indexToSend => {
|
||||
if (this.keysEventUpdateTimeout !== undefined) {
|
||||
clearTimeout(this.keysEventUpdateTimeout);
|
||||
this.keysEventUpdateTimeout = undefined;
|
||||
}
|
||||
this.lastEncryptionKeyUpdateRequest = Date.now();
|
||||
_logger.logger.info("Sending encryption keys event");
|
||||
if (!this.isJoined()) return;
|
||||
logger.info(`Sending encryption keys event. indexToSend=${indexToSend}`);
|
||||
const userId = this.client.getUserId();
|
||||
const deviceId = this.client.getDeviceId();
|
||||
if (!userId) throw new Error("No userId");
|
||||
if (!deviceId) throw new Error("No deviceId");
|
||||
const myKeys = this.getKeysForParticipant(userId, deviceId);
|
||||
if (!myKeys) {
|
||||
_logger.logger.warn("Tried to send encryption keys event but no keys found!");
|
||||
logger.warn("Tried to send encryption keys event but no keys found!");
|
||||
return;
|
||||
}
|
||||
if (typeof indexToSend !== "number" && this.currentEncryptionKeyIndex === -1) {
|
||||
logger.warn("Tried to send encryption keys event but no current key index found!");
|
||||
return;
|
||||
}
|
||||
const keyIndexToSend = indexToSend ?? this.currentEncryptionKeyIndex;
|
||||
const keyToSend = myKeys[keyIndexToSend];
|
||||
try {
|
||||
await this.client.sendEvent(this.room.roomId, _event.EventType.CallEncryptionKeysPrefix, {
|
||||
keys: myKeys.map((key, index) => {
|
||||
return {
|
||||
index,
|
||||
key: (0, _base.encodeUnpaddedBase64)(key)
|
||||
};
|
||||
}),
|
||||
const content = {
|
||||
keys: [{
|
||||
index: keyIndexToSend,
|
||||
key: (0, _base.encodeUnpaddedBase64)(keyToSend)
|
||||
}],
|
||||
device_id: deviceId,
|
||||
call_id: ""
|
||||
});
|
||||
_logger.logger.debug(`Embedded-E2EE-LOG updateEncryptionKeyEvent participantId=${userId}:${deviceId} numSent=${myKeys.length}`, this.encryptionKeys);
|
||||
call_id: "",
|
||||
sent_ts: Date.now()
|
||||
};
|
||||
this.statistics.counters.roomEventEncryptionKeysSent += 1;
|
||||
await this.client.sendEvent(this.room.roomId, _event.EventType.CallEncryptionKeysPrefix, content);
|
||||
logger.debug(`Embedded-E2EE-LOG updateEncryptionKeyEvent participantId=${userId}:${deviceId} numKeys=${myKeys.length} currentKeyIndex=${this.currentEncryptionKeyIndex} keyIndexToSend=${keyIndexToSend}`, this.encryptionKeys);
|
||||
} catch (error) {
|
||||
const matrixError = error;
|
||||
if (matrixError.event) {
|
||||
|
@ -214,75 +250,107 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
}
|
||||
if (this.keysEventUpdateTimeout === undefined) {
|
||||
const resendDelay = matrixError.data?.retry_after_ms ?? 5000;
|
||||
_logger.logger.warn(`Failed to send m.call.encryption_key, retrying in ${resendDelay}`, error);
|
||||
logger.warn(`Failed to send m.call.encryption_key, retrying in ${resendDelay}`, error);
|
||||
this.keysEventUpdateTimeout = setTimeout(this.sendEncryptionKeysEvent, resendDelay);
|
||||
} else {
|
||||
_logger.logger.info("Not scheduling key resend as another re-send is already pending");
|
||||
logger.info("Not scheduling key resend as another re-send is already pending");
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Process `m.call.encryption_keys` events to track the encryption keys for call participants.
|
||||
* This should be called each time the relevant event is received from a room timeline.
|
||||
* If the event is malformed then it will be logged and ignored.
|
||||
*
|
||||
* @param event the event to process
|
||||
*/
|
||||
_defineProperty(this, "onCallEncryption", event => {
|
||||
const userId = event.getSender();
|
||||
const content = event.getContent();
|
||||
const deviceId = content["device_id"];
|
||||
const callId = content["call_id"];
|
||||
if (!userId) {
|
||||
_logger.logger.warn(`Received m.call.encryption_keys with no userId: callId=${callId}`);
|
||||
logger.warn(`Received m.call.encryption_keys with no userId: callId=${callId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// We currently only handle callId = "" (which is the default for room scoped calls)
|
||||
if (callId !== "") {
|
||||
_logger.logger.warn(`Received m.call.encryption_keys with unsupported callId: userId=${userId}, deviceId=${deviceId}, callId=${callId}`);
|
||||
logger.warn(`Received m.call.encryption_keys with unsupported callId: userId=${userId}, deviceId=${deviceId}, callId=${callId}`);
|
||||
return;
|
||||
}
|
||||
if (!Array.isArray(content.keys)) {
|
||||
_logger.logger.warn(`Received m.call.encryption_keys where keys wasn't an array: callId=${callId}`);
|
||||
logger.warn(`Received m.call.encryption_keys where keys wasn't an array: callId=${callId}`);
|
||||
return;
|
||||
}
|
||||
if (userId === this.client.getUserId() && deviceId === this.client.getDeviceId()) {
|
||||
// We store our own sender key in the same set along with keys from others, so it's
|
||||
// important we don't allow our own keys to be set by one of these events (apart from
|
||||
// the fact that we don't need it anyway because we already know our own keys).
|
||||
_logger.logger.info("Ignoring our own keys event");
|
||||
logger.info("Ignoring our own keys event");
|
||||
return;
|
||||
}
|
||||
this.statistics.counters.roomEventEncryptionKeysReceived += 1;
|
||||
const age = Date.now() - (typeof content.sent_ts === "number" ? content.sent_ts : event.getTs());
|
||||
this.statistics.totals.roomEventEncryptionKeysReceivedTotalAge += age;
|
||||
for (const key of content.keys) {
|
||||
if (!key) {
|
||||
_logger.logger.info("Ignoring false-y key in keys event");
|
||||
logger.info("Ignoring false-y key in keys event");
|
||||
continue;
|
||||
}
|
||||
const encryptionKey = key.key;
|
||||
const encryptionKeyIndex = key.index;
|
||||
if (!encryptionKey || encryptionKeyIndex === undefined || encryptionKeyIndex === null || callId === undefined || callId === null || typeof deviceId !== "string" || typeof callId !== "string" || typeof encryptionKey !== "string" || typeof encryptionKeyIndex !== "number") {
|
||||
_logger.logger.warn(`Malformed call encryption_key: userId=${userId}, deviceId=${deviceId}, encryptionKeyIndex=${encryptionKeyIndex} callId=${callId}`);
|
||||
logger.warn(`Malformed call encryption_key: userId=${userId}, deviceId=${deviceId}, encryptionKeyIndex=${encryptionKeyIndex} callId=${callId}`);
|
||||
} else {
|
||||
_logger.logger.debug(`Embedded-E2EE-LOG onCallEncryption userId=${userId}:${deviceId} encryptionKeyIndex=${encryptionKeyIndex}`, this.encryptionKeys);
|
||||
this.setEncryptionKey(userId, deviceId, encryptionKeyIndex, encryptionKey);
|
||||
logger.debug(`Embedded-E2EE-LOG onCallEncryption userId=${userId}:${deviceId} encryptionKeyIndex=${encryptionKeyIndex} age=${age}ms`, this.encryptionKeys);
|
||||
this.setEncryptionKey(userId, deviceId, encryptionKeyIndex, encryptionKey, event.getTs());
|
||||
}
|
||||
}
|
||||
});
|
||||
_defineProperty(this, "isMyMembership", m => m.sender === this.client.getUserId() && m.deviceId === this.client.getDeviceId());
|
||||
/**
|
||||
* Examines the latest call memberships and handles any encryption key sending or rotation that is needed.
|
||||
*
|
||||
* This function should be called when the room members or call memberships might have changed.
|
||||
*/
|
||||
_defineProperty(this, "onMembershipUpdate", () => {
|
||||
const oldMemberships = this.memberships;
|
||||
this.memberships = MatrixRTCSession.callMembershipsForRoom(this.room);
|
||||
this._callId = this._callId ?? this.memberships[0]?.callId;
|
||||
const changed = oldMemberships.length != this.memberships.length || oldMemberships.some((m, i) => !_CallMembership.CallMembership.equal(m, this.memberships[i]));
|
||||
if (changed) {
|
||||
_logger.logger.info(`Memberships for call in room ${this.room.roomId} have changed: emitting`);
|
||||
logger.info(`Memberships for call in room ${this.room.roomId} have changed: emitting`);
|
||||
this.emit(MatrixRTCSessionEvent.MembershipsChanged, oldMemberships, this.memberships);
|
||||
}
|
||||
const isMyMembership = m => m.sender === this.client.getUserId() && m.deviceId === this.client.getDeviceId();
|
||||
if (this.manageMediaKeys && this.isJoined() && this.makeNewKeyTimeout === undefined) {
|
||||
const oldMebershipIds = new Set(oldMemberships.filter(m => !isMyMembership(m)).map(getParticipantIdFromMembership));
|
||||
const newMebershipIds = new Set(this.memberships.filter(m => !isMyMembership(m)).map(getParticipantIdFromMembership));
|
||||
const anyLeft = Array.from(oldMebershipIds).some(x => !newMebershipIds.has(x));
|
||||
const anyJoined = Array.from(newMebershipIds).some(x => !oldMebershipIds.has(x));
|
||||
const oldMembershipIds = new Set(oldMemberships.filter(m => !this.isMyMembership(m)).map(getParticipantIdFromMembership));
|
||||
const newMembershipIds = new Set(this.memberships.filter(m => !this.isMyMembership(m)).map(getParticipantIdFromMembership));
|
||||
|
||||
// We can use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/symmetricDifference
|
||||
// for this once available
|
||||
const anyLeft = Array.from(oldMembershipIds).some(x => !newMembershipIds.has(x));
|
||||
const anyJoined = Array.from(newMembershipIds).some(x => !oldMembershipIds.has(x));
|
||||
const oldFingerprints = this.lastMembershipFingerprints;
|
||||
// always store the fingerprints of these latest memberships
|
||||
this.storeLastMembershipFingerprints();
|
||||
if (anyLeft) {
|
||||
_logger.logger.debug(`Member(s) have left: queueing sender key rotation`);
|
||||
logger.debug(`Member(s) have left: queueing sender key rotation`);
|
||||
this.makeNewKeyTimeout = setTimeout(this.onRotateKeyTimeout, MAKE_KEY_DELAY);
|
||||
} else if (anyJoined) {
|
||||
_logger.logger.debug(`New member(s) have joined: re-sending keys`);
|
||||
this.requestKeyEventSend();
|
||||
logger.debug(`New member(s) have joined: re-sending keys`);
|
||||
this.requestSendCurrentKey();
|
||||
} else if (oldFingerprints) {
|
||||
// does it look like any of the members have updated their memberships?
|
||||
const newFingerprints = this.lastMembershipFingerprints;
|
||||
|
||||
// We can use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/symmetricDifference
|
||||
// for this once available
|
||||
const candidateUpdates = Array.from(oldFingerprints).some(x => !newFingerprints.has(x)) || Array.from(newFingerprints).some(x => !oldFingerprints.has(x));
|
||||
if (candidateUpdates) {
|
||||
logger.debug(`Member(s) have updated/reconnected: re-sending keys to everyone`);
|
||||
this.requestSendCurrentKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setExpiryTimer();
|
||||
|
@ -303,14 +371,23 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
this.updateCallMembershipRunning = false;
|
||||
}
|
||||
});
|
||||
_defineProperty(this, "delayDisconnection", async () => {
|
||||
try {
|
||||
await this.client._unstable_updateDelayedEvent(this.disconnectDelayId, _requests.UpdateDelayedEventAction.Restart);
|
||||
this.scheduleDelayDisconnection();
|
||||
} catch (e) {
|
||||
// TODO: Retry if rate-limited
|
||||
logger.error("Failed to delay our disconnection event:", e);
|
||||
}
|
||||
});
|
||||
_defineProperty(this, "onRotateKeyTimeout", () => {
|
||||
if (!this.manageMediaKeys) return;
|
||||
this.makeNewKeyTimeout = undefined;
|
||||
_logger.logger.info("Making new sender key for key rotation");
|
||||
this.makeNewSenderKey(true);
|
||||
logger.info("Making new sender key for key rotation");
|
||||
const newKeyIndex = this.makeNewSenderKey(true);
|
||||
// send immediately: if we're about to start sending with a new key, it's
|
||||
// important we get it out to others as soon as we can.
|
||||
this.sendEncryptionKeysEvent();
|
||||
this.sendEncryptionKeysEvent(newKeyIndex);
|
||||
});
|
||||
this._callId = memberships[0]?.callId;
|
||||
const roomState = this.room.getLiveTimeline().getState(_eventTimeline.EventTimeline.FORWARDS);
|
||||
|
@ -359,7 +436,7 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
*/
|
||||
joinRoomSession(fociPreferred, fociActive, joinConfig) {
|
||||
if (this.isJoined()) {
|
||||
_logger.logger.info(`Already joined to session in room ${this.room.roomId}: ignoring join call`);
|
||||
logger.info(`Already joined to session in room ${this.room.roomId}: ignoring join call`);
|
||||
return;
|
||||
}
|
||||
this.ownFocusActive = fociActive;
|
||||
|
@ -368,10 +445,10 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
this.manageMediaKeys = joinConfig?.manageMediaKeys ?? this.manageMediaKeys;
|
||||
this.useLegacyMemberEvents = joinConfig?.useLegacyMemberEvents ?? this.useLegacyMemberEvents;
|
||||
this.membershipId = (0, _randomstring.randomString)(5);
|
||||
_logger.logger.info(`Joining call session in room ${this.room.roomId} with manageMediaKeys=${this.manageMediaKeys}`);
|
||||
logger.info(`Joining call session in room ${this.room.roomId} with manageMediaKeys=${this.manageMediaKeys}`);
|
||||
if (joinConfig?.manageMediaKeys) {
|
||||
this.makeNewSenderKey();
|
||||
this.requestKeyEventSend();
|
||||
this.requestSendCurrentKey();
|
||||
}
|
||||
// We don't wait for this, mostly because it may fail and schedule a retry, so this
|
||||
// function returning doesn't really mean anything at all.
|
||||
|
@ -387,11 +464,12 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
* The membership update required to leave the session will retry if it fails.
|
||||
* Without network connection the promise will never resolve.
|
||||
* A timeout can be provided so that there is a guarantee for the promise to resolve.
|
||||
* @returns Whether the membership update was attempted and did not time out.
|
||||
*/
|
||||
async leaveRoomSession(timeout = undefined) {
|
||||
if (!this.isJoined()) {
|
||||
_logger.logger.info(`Not joined to session in room ${this.room.roomId}: ignoring leave call`);
|
||||
return new Promise(resolve => resolve(false));
|
||||
logger.info(`Not joined to session in room ${this.room.roomId}: ignoring leave call`);
|
||||
return false;
|
||||
}
|
||||
const userId = this.client.getUserId();
|
||||
const deviceId = this.client.getDeviceId();
|
||||
|
@ -410,25 +488,21 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
clearTimeout(t);
|
||||
}
|
||||
this.setNewKeyTimeouts.clear();
|
||||
_logger.logger.info(`Leaving call session in room ${this.room.roomId}`);
|
||||
logger.info(`Leaving call session in room ${this.room.roomId}`);
|
||||
this.relativeExpiry = undefined;
|
||||
this.ownFocusActive = undefined;
|
||||
this.manageMediaKeys = false;
|
||||
this.membershipId = undefined;
|
||||
this.emit(MatrixRTCSessionEvent.JoinStateChanged, false);
|
||||
const timeoutPromise = new Promise(r => {
|
||||
if (timeout) {
|
||||
// will never resolve if timeout is not set
|
||||
setTimeout(r, timeout, "timeout");
|
||||
}
|
||||
});
|
||||
return new Promise(resolve => {
|
||||
Promise.race([this.triggerCallMembershipEventUpdate(), timeoutPromise]).then(value => {
|
||||
// The timeoutPromise returns the string 'timeout' and the membership update void
|
||||
// A success implies that the membership update was quicker then the timeout.
|
||||
resolve(value != "timeout");
|
||||
});
|
||||
});
|
||||
if (timeout) {
|
||||
// The sleep promise returns the string 'timeout' and the membership update void
|
||||
// A success implies that the membership update was quicker then the timeout.
|
||||
const raceResult = await Promise.race([this.triggerCallMembershipEventUpdate(), (0, _utils.sleep)(timeout, "timeout")]);
|
||||
return raceResult !== "timeout";
|
||||
} else {
|
||||
await this.triggerCallMembershipEventUpdate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
getActiveFocus() {
|
||||
if (this.ownFocusActive && (0, _LivekitFocus.isLivekitFocusActive)(this.ownFocusActive)) {
|
||||
|
@ -444,52 +518,104 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
return oldestMembership?.getPreferredFoci()[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-emit an EncryptionKeyChanged event for each tracked encryption key. This can be used to export
|
||||
* the keys.
|
||||
*/
|
||||
reemitEncryptionKeys() {
|
||||
this.encryptionKeys.forEach((keys, participantId) => {
|
||||
keys.forEach((key, index) => {
|
||||
this.emit(MatrixRTCSessionEvent.EncryptionKeyChanged, key.key, index, participantId);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the known encryption keys for a given participant device.
|
||||
*
|
||||
* @param userId the user ID of the participant
|
||||
* @param deviceId the device ID of the participant
|
||||
* @returns The encryption keys for the given participant, or undefined if they are not known.
|
||||
*
|
||||
* @deprecated This will be made private in a future release.
|
||||
*/
|
||||
getKeysForParticipant(userId, deviceId) {
|
||||
return this.encryptionKeys.get(getParticipantId(userId, deviceId));
|
||||
return this.getKeysForParticipantInternal(userId, deviceId);
|
||||
}
|
||||
getKeysForParticipantInternal(userId, deviceId) {
|
||||
return this.encryptionKeys.get(getParticipantId(userId, deviceId))?.map(entry => entry.key);
|
||||
}
|
||||
|
||||
/**
|
||||
* A map of keys used to encrypt and decrypt (we are using a symmetric
|
||||
* cipher) given participant's media. This also includes our own key
|
||||
*
|
||||
* @deprecated This will be made private in a future release.
|
||||
*/
|
||||
getEncryptionKeys() {
|
||||
return this.encryptionKeys.entries();
|
||||
// the returned array doesn't contain the timestamps
|
||||
return Array.from(this.encryptionKeys.entries()).map(([participantId, keys]) => [participantId, keys.map(k => k.key)]).values();
|
||||
}
|
||||
getNewEncryptionKeyIndex() {
|
||||
const userId = this.client.getUserId();
|
||||
const deviceId = this.client.getDeviceId();
|
||||
if (!userId) throw new Error("No userId!");
|
||||
if (!deviceId) throw new Error("No deviceId!");
|
||||
return (this.getKeysForParticipant(userId, deviceId)?.length ?? 0) % 16;
|
||||
if (this.currentEncryptionKeyIndex === -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// maximum key index is 255
|
||||
return (this.currentEncryptionKeyIndex + 1) % 256;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an encryption key at a specified index for a participant.
|
||||
* The encryption keys for the local participanmt are also stored here under the
|
||||
* The encryption keys for the local participant are also stored here under the
|
||||
* user and device ID of the local participant.
|
||||
* If the key is older than the existing key at the index, it will be ignored.
|
||||
* @param userId - The user ID of the participant
|
||||
* @param deviceId - Device ID of the participant
|
||||
* @param encryptionKeyIndex - The index of the key to set
|
||||
* @param encryptionKeyString - The string representation of the key to set in base64
|
||||
* @param delayBeforeuse - If true, delay before emitting a key changed event. Useful when setting
|
||||
* @param timestamp - The timestamp of the key. We assume that these are monotonic for each participant device.
|
||||
* @param delayBeforeUse - If true, delay before emitting a key changed event. Useful when setting
|
||||
* encryption keys for the local participant to allow time for the key to
|
||||
* be distributed.
|
||||
*/
|
||||
setEncryptionKey(userId, deviceId, encryptionKeyIndex, encryptionKeyString, delayBeforeuse = false) {
|
||||
setEncryptionKey(userId, deviceId, encryptionKeyIndex, encryptionKeyString, timestamp, delayBeforeUse = false) {
|
||||
const keyBin = (0, _base.decodeBase64)(encryptionKeyString);
|
||||
const participantId = getParticipantId(userId, deviceId);
|
||||
const encryptionKeys = this.encryptionKeys.get(participantId) ?? [];
|
||||
if (keysEqual(encryptionKeys[encryptionKeyIndex], keyBin)) return;
|
||||
encryptionKeys[encryptionKeyIndex] = keyBin;
|
||||
this.encryptionKeys.set(participantId, encryptionKeys);
|
||||
if (delayBeforeuse) {
|
||||
if (!this.encryptionKeys.has(participantId)) {
|
||||
this.encryptionKeys.set(participantId, []);
|
||||
}
|
||||
const participantKeys = this.encryptionKeys.get(participantId);
|
||||
const existingKeyAtIndex = participantKeys[encryptionKeyIndex];
|
||||
if (existingKeyAtIndex) {
|
||||
if (existingKeyAtIndex.timestamp > timestamp) {
|
||||
logger.info(`Ignoring new key at index ${encryptionKeyIndex} for ${participantId} as it is older than existing known key`);
|
||||
return;
|
||||
}
|
||||
if (keysEqual(existingKeyAtIndex.key, keyBin)) {
|
||||
existingKeyAtIndex.timestamp = timestamp;
|
||||
return;
|
||||
}
|
||||
}
|
||||
participantKeys[encryptionKeyIndex] = {
|
||||
key: keyBin,
|
||||
timestamp
|
||||
};
|
||||
if (delayBeforeUse) {
|
||||
const useKeyTimeout = setTimeout(() => {
|
||||
this.setNewKeyTimeouts.delete(useKeyTimeout);
|
||||
_logger.logger.info(`Delayed-emitting key changed event for ${participantId} idx ${encryptionKeyIndex}`);
|
||||
logger.info(`Delayed-emitting key changed event for ${participantId} idx ${encryptionKeyIndex}`);
|
||||
if (userId === this.client.getUserId() && deviceId === this.client.getDeviceId()) {
|
||||
this.currentEncryptionKeyIndex = encryptionKeyIndex;
|
||||
}
|
||||
this.emit(MatrixRTCSessionEvent.EncryptionKeyChanged, keyBin, encryptionKeyIndex, participantId);
|
||||
}, USE_KEY_DELAY);
|
||||
this.setNewKeyTimeouts.add(useKeyTimeout);
|
||||
} else {
|
||||
if (userId === this.client.getUserId() && deviceId === this.client.getDeviceId()) {
|
||||
this.currentEncryptionKeyIndex = encryptionKeyIndex;
|
||||
}
|
||||
this.emit(MatrixRTCSessionEvent.EncryptionKeyChanged, keyBin, encryptionKeyIndex, participantId);
|
||||
}
|
||||
}
|
||||
|
@ -498,6 +624,7 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
* Generate a new sender key and add it at the next available index
|
||||
* @param delayBeforeUse - If true, wait for a short period before setting the key for the
|
||||
* media encryptor to use. If false, set the key immediately.
|
||||
* @returns The index of the new key
|
||||
*/
|
||||
makeNewSenderKey(delayBeforeUse = false) {
|
||||
const userId = this.client.getUserId();
|
||||
|
@ -506,18 +633,19 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
if (!deviceId) throw new Error("No deviceId");
|
||||
const encryptionKey = (0, _randomstring.secureRandomBase64Url)(16);
|
||||
const encryptionKeyIndex = this.getNewEncryptionKeyIndex();
|
||||
_logger.logger.info("Generated new key at index " + encryptionKeyIndex);
|
||||
this.setEncryptionKey(userId, deviceId, encryptionKeyIndex, encryptionKey, delayBeforeUse);
|
||||
logger.info("Generated new key at index " + encryptionKeyIndex);
|
||||
this.setEncryptionKey(userId, deviceId, encryptionKeyIndex, encryptionKey, Date.now(), delayBeforeUse);
|
||||
return encryptionKeyIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that we resend our keys to the room. May send a keys event immediately
|
||||
* Requests that we resend our current keys to the room. May send a keys event immediately
|
||||
* or queue for alter if one has already been sent recently.
|
||||
*/
|
||||
requestKeyEventSend() {
|
||||
requestSendCurrentKey() {
|
||||
if (!this.manageMediaKeys) return;
|
||||
if (this.lastEncryptionKeyUpdateRequest && this.lastEncryptionKeyUpdateRequest + UPDATE_ENCRYPTION_KEY_THROTTLE > Date.now()) {
|
||||
_logger.logger.info("Last encryption key event sent too recently: postponing");
|
||||
logger.info("Last encryption key event sent too recently: postponing");
|
||||
if (this.keysEventUpdateTimeout === undefined) {
|
||||
this.keysEventUpdateTimeout = setTimeout(this.sendEncryptionKeysEvent, UPDATE_ENCRYPTION_KEY_THROTTLE);
|
||||
}
|
||||
|
@ -555,6 +683,10 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
return oldestMembership.getPreferredFoci()[0];
|
||||
}
|
||||
}
|
||||
storeLastMembershipFingerprints() {
|
||||
this.lastMembershipFingerprints = new Set(this.memberships.filter(m => !this.isMyMembership(m)).map(m => `${getParticipantIdFromMembership(m)}:${m.membershipID}:${m.createdTs()}`));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs our own membership
|
||||
* @param prevMembership - The previous value of our call membership, if any
|
||||
|
@ -635,7 +767,7 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
let membershipObj;
|
||||
try {
|
||||
membershipObj = new _CallMembership.CallMembership(myCallMemberEvent, m);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return !membershipObj.isExpired();
|
||||
|
@ -673,7 +805,7 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
const localDeviceId = this.client.getDeviceId();
|
||||
if (!localUserId || !localDeviceId) throw new Error("User ID or device ID was null!");
|
||||
const callMemberEvents = roomState.events.get(_event.EventType.GroupCallMemberPrefix);
|
||||
const legacy = !!this.useLegacyMemberEvents || callMemberEvents?.size && this.stateEventsContainOngoingLegacySession(callMemberEvents);
|
||||
const legacy = this.stateEventsContainOngoingLegacySession(callMemberEvents);
|
||||
let newContent = {};
|
||||
if (legacy) {
|
||||
const myCallMemberEvent = callMemberEvents?.get(localUserId);
|
||||
|
@ -689,10 +821,10 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
} catch (e) {
|
||||
// This would indicate a bug or something weird if our own call membership
|
||||
// wasn't valid
|
||||
_logger.logger.warn("Our previous call membership was invalid - this shouldn't happen.", e);
|
||||
logger.warn("Our previous call membership was invalid - this shouldn't happen.", e);
|
||||
}
|
||||
if (myPrevMembership) {
|
||||
_logger.logger.debug(`${myPrevMembership.getMsUntilExpiry()} until our membership expires`);
|
||||
logger.debug(`${myPrevMembership.getMsUntilExpiry()} until our membership expires`);
|
||||
}
|
||||
if (!this.membershipEventNeedsUpdate(myPrevMembershipData, myPrevMembership)) {
|
||||
// nothing to do - reschedule the check again
|
||||
|
@ -703,16 +835,16 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
} else {
|
||||
newContent = this.makeNewMembership(localDeviceId);
|
||||
}
|
||||
const stateKey = legacy ? localUserId : this.makeMembershipStateKey(localUserId, localDeviceId);
|
||||
try {
|
||||
await this.client.sendStateEvent(this.room.roomId, _event.EventType.GroupCallMemberPrefix, newContent, stateKey);
|
||||
_logger.logger.info(`Sent updated call member event.`);
|
||||
|
||||
// check periodically to see if we need to refresh our member event
|
||||
if (this.isJoined()) {
|
||||
if (legacy) {
|
||||
if (legacy) {
|
||||
await this.client.sendStateEvent(this.room.roomId, _event.EventType.GroupCallMemberPrefix, newContent, localUserId);
|
||||
if (this.isJoined()) {
|
||||
// check periodically to see if we need to refresh our member event
|
||||
this.memberEventTimeout = setTimeout(this.triggerCallMembershipEventUpdate, MEMBER_EVENT_CHECK_PERIOD);
|
||||
} else {
|
||||
}
|
||||
} else if (this.isJoined()) {
|
||||
const stateKey = this.makeMembershipStateKey(localUserId, localDeviceId);
|
||||
const prepareDelayedDisconnection = async () => {
|
||||
try {
|
||||
// TODO: If delayed event times out, re-join!
|
||||
const res = await this.client._unstable_sendDelayedStateEvent(this.room.roomId, {
|
||||
|
@ -720,31 +852,63 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
}, _event.EventType.GroupCallMemberPrefix, {},
|
||||
// leave event
|
||||
stateKey);
|
||||
this.scheduleDelayDisconnection(res.delay_id);
|
||||
this.disconnectDelayId = res.delay_id;
|
||||
} catch (e) {
|
||||
_logger.logger.error("Failed to send delayed event:", e);
|
||||
// TODO: Retry if rate-limited
|
||||
logger.error("Failed to prepare delayed disconnection event:", e);
|
||||
}
|
||||
};
|
||||
await prepareDelayedDisconnection();
|
||||
// Send join event _after_ preparing the delayed disconnection event
|
||||
await this.client.sendStateEvent(this.room.roomId, _event.EventType.GroupCallMemberPrefix, newContent, stateKey);
|
||||
// If sending state cancels your own delayed state, prepare another delayed state
|
||||
// TODO: Remove this once MSC4140 is stable & doesn't cancel own delayed state
|
||||
if (this.disconnectDelayId !== undefined) {
|
||||
try {
|
||||
await this.client._unstable_updateDelayedEvent(this.disconnectDelayId, _requests.UpdateDelayedEventAction.Restart);
|
||||
} catch (e) {
|
||||
// TODO: Make embedded client include errcode, and retry only if not M_NOT_FOUND (or rate-limited)
|
||||
logger.warn("Failed to update delayed disconnection event, prepare it again:", e);
|
||||
this.disconnectDelayId = undefined;
|
||||
await prepareDelayedDisconnection();
|
||||
}
|
||||
}
|
||||
if (this.disconnectDelayId !== undefined) {
|
||||
this.scheduleDelayDisconnection();
|
||||
}
|
||||
} else {
|
||||
let sentDelayedDisconnect = false;
|
||||
if (this.disconnectDelayId !== undefined) {
|
||||
try {
|
||||
await this.client._unstable_updateDelayedEvent(this.disconnectDelayId, _requests.UpdateDelayedEventAction.Send);
|
||||
sentDelayedDisconnect = true;
|
||||
} catch (e) {
|
||||
// TODO: Retry if rate-limited
|
||||
logger.error("Failed to send our delayed disconnection event:", e);
|
||||
}
|
||||
this.disconnectDelayId = undefined;
|
||||
}
|
||||
if (!sentDelayedDisconnect) {
|
||||
await this.client.sendStateEvent(this.room.roomId, _event.EventType.GroupCallMemberPrefix, {}, this.makeMembershipStateKey(localUserId, localDeviceId));
|
||||
}
|
||||
}
|
||||
logger.info("Sent updated call member event.");
|
||||
} catch (e) {
|
||||
const resendDelay = CALL_MEMBER_EVENT_RETRY_DELAY_MIN + Math.random() * 2000;
|
||||
_logger.logger.warn(`Failed to send call member event (retrying in ${resendDelay}): ${e}`);
|
||||
await new Promise(resolve => setTimeout(resolve, resendDelay));
|
||||
logger.warn(`Failed to send call member event (retrying in ${resendDelay}): ${e}`);
|
||||
await (0, _utils.sleep)(resendDelay);
|
||||
await this.triggerCallMembershipEventUpdate();
|
||||
}
|
||||
}
|
||||
scheduleDelayDisconnection(delayId) {
|
||||
this.memberEventTimeout = setTimeout(() => this.delayDisconnection(delayId), 5000);
|
||||
}
|
||||
async delayDisconnection(delayId) {
|
||||
try {
|
||||
await this.client._unstable_updateDelayedEvent(delayId, _requests.UpdateDelayedEventAction.Restart);
|
||||
this.scheduleDelayDisconnection(delayId);
|
||||
} catch (e) {
|
||||
_logger.logger.error("Failed to delay our disconnection event", e);
|
||||
}
|
||||
scheduleDelayDisconnection() {
|
||||
this.memberEventTimeout = setTimeout(this.delayDisconnection, 5000);
|
||||
}
|
||||
stateEventsContainOngoingLegacySession(callMemberEvents) {
|
||||
if (!callMemberEvents?.size) {
|
||||
return this.useLegacyMemberEvents;
|
||||
}
|
||||
let containsAnyOngoingSession = false;
|
||||
let containsUnknownOngoingSession = false;
|
||||
for (const callMemberEvent of callMemberEvents.values()) {
|
||||
const content = callMemberEvent.getContent();
|
||||
if (Array.isArray(content["memberships"])) {
|
||||
|
@ -753,9 +917,12 @@ class MatrixRTCSession extends _typedEventEmitter.TypedEventEmitter {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (Object.keys(content).length > 0) {
|
||||
containsAnyOngoingSession ||= true;
|
||||
containsUnknownOngoingSession ||= !("focus_active" in content);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return containsAnyOngoingSession && !containsUnknownOngoingSession ? false : this.useLegacyMemberEvents;
|
||||
}
|
||||
makeMembershipStateKey(localUserId, localDeviceId) {
|
||||
const stateKey = `${localUserId}_${localDeviceId}`;
|
||||
|
|
|
@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.MatrixRTCSessionManagerEvents = exports.MatrixRTCSessionManager = void 0;
|
||||
var _logger = require("../logger");
|
||||
var _client = require("../client");
|
||||
var _typedEventEmitter = require("../models/typed-event-emitter");
|
||||
var _room = require("../models/room");
|
||||
var _roomState = require("../models/room-state");
|
||||
var _MatrixRTCSession = require("./MatrixRTCSession");
|
||||
var _event = require("../@types/event");
|
||||
var _logger = require("../logger.js");
|
||||
var _client = require("../client.js");
|
||||
var _typedEventEmitter = require("../models/typed-event-emitter.js");
|
||||
var _room = require("../models/room.js");
|
||||
var _roomState = require("../models/room-state.js");
|
||||
var _MatrixRTCSession = require("./MatrixRTCSession.js");
|
||||
var _event = require("../@types/event.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -28,6 +28,7 @@ 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 logger = _logger.logger.getChild("MatrixRTCSessionManager");
|
||||
let MatrixRTCSessionManagerEvents = exports.MatrixRTCSessionManagerEvents = /*#__PURE__*/function (MatrixRTCSessionManagerEvents) {
|
||||
MatrixRTCSessionManagerEvents["SessionStarted"] = "session_started";
|
||||
MatrixRTCSessionManagerEvents["SessionEnded"] = "session_ended";
|
||||
|
@ -57,7 +58,7 @@ class MatrixRTCSessionManager extends _typedEventEmitter.TypedEventEmitter {
|
|||
_defineProperty(this, "onRoomState", (event, _state) => {
|
||||
const room = this.client.getRoom(event.getRoomId());
|
||||
if (!room) {
|
||||
_logger.logger.error(`Got room state event for unknown room ${event.getRoomId()}!`);
|
||||
logger.error(`Got room state event for unknown room ${event.getRoomId()}!`);
|
||||
return;
|
||||
}
|
||||
if (event.getType() == _event.EventType.GroupCallMemberPrefix) {
|
||||
|
@ -106,12 +107,24 @@ class MatrixRTCSessionManager extends _typedEventEmitter.TypedEventEmitter {
|
|||
}
|
||||
return this.roomSessions.get(room.roomId);
|
||||
}
|
||||
async consumeCallEncryptionEvent(event) {
|
||||
async consumeCallEncryptionEvent(event, isRetry = false) {
|
||||
await this.client.decryptEventIfNeeded(event);
|
||||
if (event.isDecryptionFailure()) {
|
||||
if (!isRetry) {
|
||||
logger.warn(`Decryption failed for event ${event.getId()}: ${event.decryptionFailureReason} will retry once only`);
|
||||
// retry after 1 second. After this we give up.
|
||||
setTimeout(() => this.consumeCallEncryptionEvent(event, true), 1000);
|
||||
} else {
|
||||
logger.warn(`Decryption failed for event ${event.getId()}: ${event.decryptionFailureReason}`);
|
||||
}
|
||||
return;
|
||||
} else if (isRetry) {
|
||||
logger.info(`Decryption succeeded for event ${event.getId()} after retry`);
|
||||
}
|
||||
if (event.getType() !== _event.EventType.CallEncryptionKeysPrefix) return Promise.resolve();
|
||||
const room = this.client.getRoom(event.getRoomId());
|
||||
if (!room) {
|
||||
_logger.logger.error(`Got room state event for unknown room ${event.getRoomId()}!`);
|
||||
logger.error(`Got room state event for unknown room ${event.getRoomId()}!`);
|
||||
return Promise.resolve();
|
||||
}
|
||||
this.getRoomSession(room).onCallEncryption(event);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _CallMembership = require("./CallMembership");
|
||||
var _CallMembership = require("./CallMembership.js");
|
||||
Object.keys(_CallMembership).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _CallMembership[key]) return;
|
||||
|
@ -14,18 +14,7 @@ Object.keys(_CallMembership).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _focus = require("./focus");
|
||||
Object.keys(_focus).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _focus[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _focus[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _LivekitFocus = require("./LivekitFocus");
|
||||
var _LivekitFocus = require("./LivekitFocus.js");
|
||||
Object.keys(_LivekitFocus).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _LivekitFocus[key]) return;
|
||||
|
@ -36,7 +25,7 @@ Object.keys(_LivekitFocus).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _MatrixRTCSession = require("./MatrixRTCSession");
|
||||
var _MatrixRTCSession = require("./MatrixRTCSession.js");
|
||||
Object.keys(_MatrixRTCSession).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _MatrixRTCSession[key]) return;
|
||||
|
@ -47,7 +36,7 @@ Object.keys(_MatrixRTCSession).forEach(function (key) {
|
|||
}
|
||||
});
|
||||
});
|
||||
var _MatrixRTCSessionManager = require("./MatrixRTCSessionManager");
|
||||
var _MatrixRTCSessionManager = require("./MatrixRTCSessionManager.js");
|
||||
Object.keys(_MatrixRTCSessionManager).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _MatrixRTCSessionManager[key]) return;
|
||||
|
@ -57,15 +46,4 @@ Object.keys(_MatrixRTCSessionManager).forEach(function (key) {
|
|||
return _MatrixRTCSessionManager[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _types = require("./types");
|
||||
Object.keys(_types).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _types[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _types[key];
|
||||
}
|
||||
});
|
||||
});
|
|
@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.MSC3089Branch = void 0;
|
||||
var _event = require("../@types/event");
|
||||
var _eventTimeline = require("./event-timeline");
|
||||
var _event = require("../@types/event.js");
|
||||
var _eventTimeline = require("./event-timeline.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -5,12 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.TreePermissions = exports.MSC3089TreeSpace = exports.DEFAULT_TREE_POWER_LEVELS_TEMPLATE = void 0;
|
||||
var _pRetry = _interopRequireDefault(require("p-retry"));
|
||||
var _event = require("../@types/event");
|
||||
var _logger = require("../logger");
|
||||
var _utils = require("../utils");
|
||||
var _MSC3089Branch = require("./MSC3089Branch");
|
||||
var _megolm = require("../crypto/algorithms/megolm");
|
||||
var _membership = require("../@types/membership");
|
||||
var _event = require("../@types/event.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _MSC3089Branch = require("./MSC3089Branch.js");
|
||||
var _membership = require("../@types/membership.js");
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
|
@ -119,28 +118,14 @@ class MSC3089TreeSpace {
|
|||
* @param userId - The user ID to invite.
|
||||
* @param andSubspaces - True (default) to invite the user to all
|
||||
* directories/subspaces too, recursively.
|
||||
* @param shareHistoryKeys - True (default) to share encryption keys
|
||||
* with the invited user. This will allow them to decrypt the events (files)
|
||||
* in the tree. Keys will not be shared if the room is lacking appropriate
|
||||
* history visibility (by default, history visibility is "shared" in trees,
|
||||
* which is an appropriate visibility for these purposes).
|
||||
* @returns Promise which resolves when complete.
|
||||
*/
|
||||
async invite(userId, andSubspaces = true, shareHistoryKeys = true) {
|
||||
async invite(userId, andSubspaces = true) {
|
||||
const promises = [this.retryInvite(userId)];
|
||||
if (andSubspaces) {
|
||||
promises.push(...this.getDirectories().map(d => d.invite(userId, andSubspaces, shareHistoryKeys)));
|
||||
promises.push(...this.getDirectories().map(d => d.invite(userId, andSubspaces)));
|
||||
}
|
||||
return Promise.all(promises).then(() => {
|
||||
// Note: key sharing is default on because for file trees it is relatively important that the invite
|
||||
// target can actually decrypt the files. The implied use case is that by inviting a user to the tree
|
||||
// it means the sender would like the receiver to view/download the files contained within, much like
|
||||
// sharing a folder in other circles.
|
||||
if (shareHistoryKeys && (0, _megolm.isRoomSharedHistory)(this.room)) {
|
||||
// noinspection JSIgnoredPromiseFromCall - we aren't concerned as much if this fails.
|
||||
this.client.sendSharedHistoryKeys(this.roomId, [userId]);
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
}
|
||||
retryInvite(userId) {
|
||||
return (0, _utils.simpleRetryOperation)(async () => {
|
||||
|
|
|
@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.isTimestampInDuration = exports.getBeaconInfoIdentifier = exports.BeaconEvent = exports.Beacon = void 0;
|
||||
var _contentHelpers = require("../content-helpers");
|
||||
var _utils = require("../utils");
|
||||
var _typedEventEmitter = require("./typed-event-emitter");
|
||||
var _contentHelpers = require("../content-helpers.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _typedEventEmitter = require("./typed-event-emitter.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.compareEventOrdering = compareEventOrdering;
|
||||
var _client = require("../client");
|
||||
var _client = require("../client.js");
|
||||
/*
|
||||
Copyright 2023 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.EventContext = void 0;
|
||||
var _eventTimeline = require("./event-timeline");
|
||||
var _eventTimeline = require("./event-timeline.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.EventTimelineSet = exports.DuplicateStrategy = void 0;
|
||||
var _eventTimeline = require("./event-timeline");
|
||||
var _logger = require("../logger");
|
||||
var _room = require("./room");
|
||||
var _typedEventEmitter = require("./typed-event-emitter");
|
||||
var _relationsContainer = require("./relations-container");
|
||||
var _eventTimeline = require("./event-timeline.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _room = require("./room.js");
|
||||
var _typedEventEmitter = require("./typed-event-emitter.js");
|
||||
var _relationsContainer = require("./relations-container.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.EventTimeline = exports.Direction = void 0;
|
||||
var _roomState = require("./room-state");
|
||||
var _event = require("../@types/event");
|
||||
var _roomState = require("./room-state.js");
|
||||
var _event = require("../@types/event.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -11,16 +11,16 @@ Object.defineProperty(exports, "EventStatus", {
|
|||
});
|
||||
exports.MatrixEventEvent = exports.MatrixEvent = void 0;
|
||||
var _matrixEventsSdk = require("matrix-events-sdk");
|
||||
var _logger = require("../logger");
|
||||
var _event = require("../@types/event");
|
||||
var _utils = require("../utils");
|
||||
var _thread = require("./thread");
|
||||
var _ReEmitter = require("../ReEmitter");
|
||||
var _typedEventEmitter = require("./typed-event-emitter");
|
||||
var _CryptoBackend = require("../common-crypto/CryptoBackend");
|
||||
var _eventTimeline = require("./event-timeline");
|
||||
var _cryptoApi = require("../crypto-api");
|
||||
var _eventStatus = require("./event-status");
|
||||
var _logger = require("../logger.js");
|
||||
var _event = require("../@types/event.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _thread = require("./thread.js");
|
||||
var _ReEmitter = require("../ReEmitter.js");
|
||||
var _typedEventEmitter = require("./typed-event-emitter.js");
|
||||
var _CryptoBackend = require("../common-crypto/CryptoBackend.js");
|
||||
var _eventTimeline = require("./event-timeline.js");
|
||||
var _index = require("../crypto-api/index.js");
|
||||
var _eventStatus = require("./event-status.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
@ -589,7 +589,7 @@ class MatrixEvent extends _typedEventEmitter.TypedEventEmitter {
|
|||
* @deprecated: Prefer `event.decryptionFailureReason === DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE`.
|
||||
*/
|
||||
get isEncryptedDisabledForUnverifiedDevices() {
|
||||
return this.decryptionFailureReason === _cryptoApi.DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE;
|
||||
return this.decryptionFailureReason === _index.DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE;
|
||||
}
|
||||
shouldAttemptDecryption() {
|
||||
if (this.isRedacted()) return false;
|
||||
|
@ -720,7 +720,7 @@ class MatrixEvent extends _typedEventEmitter.TypedEventEmitter {
|
|||
// so we don't bother to log `e` separately.
|
||||
_logger.logger.warn(`Error decrypting event (${this.getDetails()}): ${detailedError}`);
|
||||
this.setClearDataForDecryptionFailure(String(e));
|
||||
this._decryptionFailureReason = e instanceof _CryptoBackend.DecryptionError ? e.code : _cryptoApi.DecryptionFailureCode.UNKNOWN_ERROR;
|
||||
this._decryptionFailureReason = e instanceof _CryptoBackend.DecryptionError ? e.code : _index.DecryptionFailureCode.UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
// Make sure we clear 'decryptionPromise' before sending the 'Event.decrypted' event,
|
||||
|
|
|
@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.PolicyScope = exports.PolicyRecommendation = exports.POLICIES_ACCOUNT_EVENT_TYPE = exports.IgnoredInvites = exports.IGNORE_INVITES_ACCOUNT_EVENT_KEY = void 0;
|
||||
var _matrixEventsSdk = require("matrix-events-sdk");
|
||||
var _eventTimeline = require("./event-timeline");
|
||||
var _partials = require("../@types/partials");
|
||||
var _utils = require("../utils");
|
||||
var _event = require("../@types/event");
|
||||
var _eventTimeline = require("./event-timeline.js");
|
||||
var _partials = require("../@types/partials.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _event = require("../@types/event.js");
|
||||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
@ -185,7 +185,7 @@ class IgnoredInvites {
|
|||
let regexp;
|
||||
try {
|
||||
regexp = new RegExp((0, _utils.globToRegexp)(glob));
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
// Assume invalid event.
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.isPollEvent = exports.PollEvent = exports.Poll = void 0;
|
||||
var _matrixEventsSdk = require("matrix-events-sdk");
|
||||
var _polls = require("../@types/polls");
|
||||
var _relations = require("./relations");
|
||||
var _typedEventEmitter = require("./typed-event-emitter");
|
||||
var _polls = require("../@types/polls.js");
|
||||
var _relations = require("./relations.js");
|
||||
var _typedEventEmitter = require("./typed-event-emitter.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ProfileKeyMSC4175Timezone = void 0;
|
||||
/**
|
||||
* The timezone the user is currently in. The value of this property should
|
||||
* match a timezone provided in https://www.iana.org/time-zones.
|
||||
*
|
||||
* @see https://github.com/matrix-org/matrix-spec-proposals/blob/clokep/profile-tz/proposals/4175-profile-field-time-zone.md
|
||||
*/
|
||||
const ProfileKeyMSC4175Timezone = exports.ProfileKeyMSC4175Timezone = "us.cloke.msc4175.tz";
|
|
@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.ReadReceipt = void 0;
|
||||
exports.synthesizeReceipt = synthesizeReceipt;
|
||||
var _read_receipts = require("../@types/read_receipts");
|
||||
var _typedEventEmitter = require("./typed-event-emitter");
|
||||
var _utils = require("../utils");
|
||||
var _event = require("./event");
|
||||
var _event2 = require("../@types/event");
|
||||
var _room = require("./room");
|
||||
var _logger = require("../logger");
|
||||
var _client = require("../client");
|
||||
var _read_receipts = require("../@types/read_receipts.js");
|
||||
var _typedEventEmitter = require("./typed-event-emitter.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _event = require("./event.js");
|
||||
var _event2 = require("../@types/event.js");
|
||||
var _room = require("./room.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _client = require("../client.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.RelationsContainer = void 0;
|
||||
var _relations = require("./relations");
|
||||
var _event = require("./event");
|
||||
var _relations = require("./relations.js");
|
||||
var _event = require("./event.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.RelationsEvent = exports.Relations = void 0;
|
||||
var _event = require("./event");
|
||||
var _logger = require("../logger");
|
||||
var _event2 = require("../@types/event");
|
||||
var _typedEventEmitter = require("./typed-event-emitter");
|
||||
var _room = require("./room");
|
||||
var _event = require("./event.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _event2 = require("../@types/event.js");
|
||||
var _typedEventEmitter = require("./typed-event-emitter.js");
|
||||
var _room = require("./room.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.RoomMemberEvent = exports.RoomMember = void 0;
|
||||
var _contentRepo = require("../content-repo");
|
||||
var _utils = require("../utils");
|
||||
var _logger = require("../logger");
|
||||
var _typedEventEmitter = require("./typed-event-emitter");
|
||||
var _event = require("../@types/event");
|
||||
var _membership = require("../@types/membership");
|
||||
var _contentRepo = require("../content-repo.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _typedEventEmitter = require("./typed-event-emitter.js");
|
||||
var _event = require("../@types/event.js");
|
||||
var _membership = require("../@types/membership.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.RoomReceipts = void 0;
|
||||
var _read_receipts = require("../@types/read_receipts");
|
||||
var _client = require("../client");
|
||||
var _room = require("./room");
|
||||
var _logger = require("../logger");
|
||||
var _read_receipts = require("../@types/read_receipts.js");
|
||||
var _client = require("../client.js");
|
||||
var _room = require("./room.js");
|
||||
var _logger = require("../logger.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -4,17 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.RoomStateEvent = exports.RoomState = void 0;
|
||||
var _roomMember = require("./room-member");
|
||||
var _logger = require("../logger");
|
||||
var _utils = require("../utils");
|
||||
var _event = require("../@types/event");
|
||||
var _event2 = require("./event");
|
||||
var _partials = require("../@types/partials");
|
||||
var _typedEventEmitter = require("./typed-event-emitter");
|
||||
var _beacon = require("./beacon");
|
||||
var _ReEmitter = require("../ReEmitter");
|
||||
var _beacon2 = require("../@types/beacon");
|
||||
var _membership = require("../@types/membership");
|
||||
var _roomMember = require("./room-member.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _utils = require("../utils.js");
|
||||
var _event = require("../@types/event.js");
|
||||
var _event2 = require("./event.js");
|
||||
var _partials = require("../@types/partials.js");
|
||||
var _typedEventEmitter = require("./typed-event-emitter.js");
|
||||
var _beacon = require("./beacon.js");
|
||||
var _ReEmitter = require("../ReEmitter.js");
|
||||
var _beacon2 = require("../@types/beacon.js");
|
||||
var _membership = require("../@types/membership.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -5,31 +5,31 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.RoomNameType = exports.RoomEvent = exports.Room = exports.NotificationCountType = exports.KNOWN_SAFE_ROOM_VERSION = void 0;
|
||||
var _matrixEventsSdk = require("matrix-events-sdk");
|
||||
var _eventTimelineSet = require("./event-timeline-set");
|
||||
var _eventTimeline = require("./event-timeline");
|
||||
var _contentRepo = require("../content-repo");
|
||||
var _utils = _interopRequireWildcard(require("../utils"));
|
||||
var _eventTimelineSet = require("./event-timeline-set.js");
|
||||
var _eventTimeline = require("./event-timeline.js");
|
||||
var _contentRepo = require("../content-repo.js");
|
||||
var _utils = _interopRequireWildcard(require("../utils.js"));
|
||||
var utils = _utils;
|
||||
var _event = require("./event");
|
||||
var _eventStatus = require("./event-status");
|
||||
var _roomMember = require("./room-member");
|
||||
var _roomSummary = require("./room-summary");
|
||||
var _logger = require("../logger");
|
||||
var _ReEmitter = require("../ReEmitter");
|
||||
var _event2 = require("../@types/event");
|
||||
var _client = require("../client");
|
||||
var _filter = require("../filter");
|
||||
var _roomState = require("./room-state");
|
||||
var _beacon = require("./beacon");
|
||||
var _thread = require("./thread");
|
||||
var _read_receipts = require("../@types/read_receipts");
|
||||
var _relationsContainer = require("./relations-container");
|
||||
var _readReceipt = require("./read-receipt");
|
||||
var _poll = require("./poll");
|
||||
var _roomReceipts = require("./room-receipts");
|
||||
var _compareEventOrdering = require("./compare-event-ordering");
|
||||
var _membership = require("../@types/membership");
|
||||
var _serverCapabilities = require("../serverCapabilities");
|
||||
var _event = require("./event.js");
|
||||
var _eventStatus = require("./event-status.js");
|
||||
var _roomMember = require("./room-member.js");
|
||||
var _roomSummary = require("./room-summary.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _ReEmitter = require("../ReEmitter.js");
|
||||
var _event2 = require("../@types/event.js");
|
||||
var _client = require("../client.js");
|
||||
var _filter = require("../filter.js");
|
||||
var _roomState = require("./room-state.js");
|
||||
var _beacon = require("./beacon.js");
|
||||
var _thread = require("./thread.js");
|
||||
var _read_receipts = require("../@types/read_receipts.js");
|
||||
var _relationsContainer = require("./relations-container.js");
|
||||
var _readReceipt = require("./read-receipt.js");
|
||||
var _poll = require("./poll.js");
|
||||
var _roomReceipts = require("./room-receipts.js");
|
||||
var _compareEventOrdering = require("./compare-event-ordering.js");
|
||||
var _membership = require("../@types/membership.js");
|
||||
var _serverCapabilities = require("../serverCapabilities.js");
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
|
@ -352,7 +352,7 @@ class Room extends _readReceipt.ReadReceipt {
|
|||
this.threadsTimelineSets[0] = timelineSets[0];
|
||||
this.threadsTimelineSets[1] = timelineSets[1];
|
||||
return timelineSets;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
this.threadTimelineSetsPromise = null;
|
||||
return null;
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ class Room extends _readReceipt.ReadReceipt {
|
|||
let capabilities = {};
|
||||
try {
|
||||
capabilities = await this.client.getCapabilities();
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
let versionCap = capabilities["m.room_versions"];
|
||||
if (!versionCap) {
|
||||
versionCap = {
|
||||
|
@ -1734,7 +1734,7 @@ class Room extends _readReceipt.ReadReceipt {
|
|||
}
|
||||
|
||||
/**
|
||||
* Calls {@link processPollEvent} for a list of events.
|
||||
* Process a list of poll events.
|
||||
*
|
||||
* @param events - List of events
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.SearchResult = void 0;
|
||||
var _eventContext = require("./event-context");
|
||||
var _eventContext = require("./event-context.js");
|
||||
/*
|
||||
Copyright 2015 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
|
|
|
@ -6,18 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|||
exports.ThreadFilterType = exports.ThreadEvent = exports.Thread = exports.THREAD_RELATION_TYPE = exports.FeatureSupport = exports.FILTER_RELATED_BY_SENDERS = exports.FILTER_RELATED_BY_REL_TYPES = void 0;
|
||||
exports.determineFeatureSupport = determineFeatureSupport;
|
||||
exports.threadFilterTypeToFilter = threadFilterTypeToFilter;
|
||||
var _client = require("../client");
|
||||
var _ReEmitter = require("../ReEmitter");
|
||||
var _event = require("../@types/event");
|
||||
var _event2 = require("./event");
|
||||
var _eventTimeline = require("./event-timeline");
|
||||
var _eventTimelineSet = require("./event-timeline-set");
|
||||
var _room = require("./room");
|
||||
var _NamespacedValue = require("../NamespacedValue");
|
||||
var _logger = require("../logger");
|
||||
var _readReceipt = require("./read-receipt");
|
||||
var _read_receipts = require("../@types/read_receipts");
|
||||
var _feature = require("../feature");
|
||||
var _client = require("../client.js");
|
||||
var _ReEmitter = require("../ReEmitter.js");
|
||||
var _event = require("../@types/event.js");
|
||||
var _event2 = require("./event.js");
|
||||
var _eventTimeline = require("./event-timeline.js");
|
||||
var _eventTimelineSet = require("./event-timeline-set.js");
|
||||
var _room = require("./room.js");
|
||||
var _NamespacedValue = require("../NamespacedValue.js");
|
||||
var _logger = require("../logger.js");
|
||||
var _readReceipt = require("./read-receipt.js");
|
||||
var _read_receipts = require("../@types/read_receipts.js");
|
||||
var _feature = require("../feature.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
|
@ -52,7 +52,7 @@ let EventEmitterEvents = exports.EventEmitterEvents = /*#__PURE__*/function (Eve
|
|||
*/
|
||||
class TypedEventEmitter extends _events.EventEmitter {
|
||||
/**
|
||||
* Alias for {@link TypedEventEmitter#on}.
|
||||
* Alias for {@link on}.
|
||||
*/
|
||||
addListener(event, listener) {
|
||||
return super.addListener(event, listener);
|
||||
|
@ -103,7 +103,7 @@ class TypedEventEmitter extends _events.EventEmitter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Alias for {@link TypedEventEmitter#removeListener}
|
||||
* Alias for {@link removeListener}
|
||||
*/
|
||||
off(event, listener) {
|
||||
return super.off(event, listener);
|
||||
|
@ -118,7 +118,7 @@ class TypedEventEmitter extends _events.EventEmitter {
|
|||
* being added, and called, multiple times.
|
||||
*
|
||||
* By default, event listeners are invoked in the order they are added. The
|
||||
* {@link TypedEventEmitter#prependListener} method can be used as an alternative to add the
|
||||
* {@link prependListener} method can be used as an alternative to add the
|
||||
* event listener to the beginning of the listeners array.
|
||||
*
|
||||
* @param event - The name of the event.
|
||||
|
@ -137,7 +137,7 @@ class TypedEventEmitter extends _events.EventEmitter {
|
|||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
*
|
||||
* By default, event listeners are invoked in the order they are added.
|
||||
* The {@link TypedEventEmitter#prependOnceListener} method can be used as an alternative to add the
|
||||
* The {@link prependOnceListener} method can be used as an alternative to add the
|
||||
* event listener to the beginning of the listeners array.
|
||||
*
|
||||
* @param event - The name of the event.
|
||||
|
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
exports.UserEvent = exports.User = void 0;
|
||||
var _typedEventEmitter = require("./typed-event-emitter");
|
||||
var _typedEventEmitter = require("./typed-event-emitter.js");
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
||||
|
|
|
@ -5,12 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.generateScope = exports.generateOidcAuthorizationUrl = exports.generateAuthorizationUrl = exports.generateAuthorizationParams = exports.completeAuthorizationCodeGrant = void 0;
|
||||
var _oidcClientTs = require("oidc-client-ts");
|
||||
var _logger = require("../logger");
|
||||
var _randomstring = require("../randomstring");
|
||||
var _error = require("./error");
|
||||
var _validate = require("./validate");
|
||||
var _digest = require("../digest");
|
||||
var _base = require("../base64");
|
||||
var _logger = require("../logger.js");
|
||||
var _randomstring = require("../randomstring.js");
|
||||
var _error = require("./error.js");
|
||||
var _validate = require("./validate.js");
|
||||
var _digest = require("../digest.js");
|
||||
var _base = require("../base64.js");
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче