summaryrefslogtreecommitdiff
path: root/bot/node_modules/matrix-js-sdk/lib/crypto-api.js
diff options
context:
space:
mode:
Diffstat (limited to 'bot/node_modules/matrix-js-sdk/lib/crypto-api.js')
-rw-r--r--bot/node_modules/matrix-js-sdk/lib/crypto-api.js217
1 files changed, 217 insertions, 0 deletions
diff --git a/bot/node_modules/matrix-js-sdk/lib/crypto-api.js b/bot/node_modules/matrix-js-sdk/lib/crypto-api.js
new file mode 100644
index 0000000..696f2ba
--- /dev/null
+++ b/bot/node_modules/matrix-js-sdk/lib/crypto-api.js
@@ -0,0 +1,217 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+var _exportNames = {
+ UserVerificationStatus: true,
+ DeviceVerificationStatus: true,
+ CrossSigningKey: true,
+ EventShieldColour: true,
+ EventShieldReason: true
+};
+exports.UserVerificationStatus = exports.EventShieldReason = exports.EventShieldColour = exports.DeviceVerificationStatus = exports.CrossSigningKey = void 0;
+var _verification = require("./crypto-api/verification");
+Object.keys(_verification).forEach(function (key) {
+ if (key === "default" || key === "__esModule") return;
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
+ if (key in exports && exports[key] === _verification[key]) return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function () {
+ return _verification[key];
+ }
+ });
+});
+var _keybackup = require("./crypto-api/keybackup");
+Object.keys(_keybackup).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;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function () {
+ return _keybackup[key];
+ }
+ });
+});
+/*
+Copyright 2023 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/**
+ * Public interface to the cryptography parts of the js-sdk
+ *
+ * @remarks Currently, this is a work-in-progress. In time, more methods will be added here.
+ */
+
+/**
+ * Options object for `CryptoApi.bootstrapCrossSigning`.
+ */
+
+/**
+ * Represents the ways in which we trust a user
+ */
+class UserVerificationStatus {
+ constructor(crossSigningVerified, crossSigningVerifiedBefore, tofu) {
+ this.crossSigningVerified = crossSigningVerified;
+ this.crossSigningVerifiedBefore = crossSigningVerifiedBefore;
+ this.tofu = tofu;
+ }
+
+ /**
+ * @returns true if this user is verified via any means
+ */
+ isVerified() {
+ return this.isCrossSigningVerified();
+ }
+
+ /**
+ * @returns true if this user is verified via cross signing
+ */
+ isCrossSigningVerified() {
+ return this.crossSigningVerified;
+ }
+
+ /**
+ * @returns true if we ever verified this user before (at least for
+ * the history of verifications observed by this device).
+ */
+ wasCrossSigningVerified() {
+ return this.crossSigningVerifiedBefore;
+ }
+
+ /**
+ * @returns true if this user's key is trusted on first use
+ */
+ isTofu() {
+ return this.tofu;
+ }
+}
+exports.UserVerificationStatus = UserVerificationStatus;
+class DeviceVerificationStatus {
+ /**
+ * True if this device has been signed by its owner (and that signature verified).
+ *
+ * This doesn't necessarily mean that we have verified the device, since we may not have verified the
+ * owner's cross-signing key.
+ */
+
+ /**
+ * True if this device has been verified via cross signing.
+ *
+ * This does *not* take into account `trustCrossSignedDevices`.
+ */
+
+ /**
+ * TODO: tofu magic wtf does this do?
+ */
+
+ /**
+ * True if the device has been marked as locally verified.
+ */
+
+ /**
+ * True if the client has been configured to trust cross-signed devices via {@link CryptoApi#setTrustCrossSignedDevices}.
+ */
+
+ constructor(opts) {
+ var _opts$signedByOwner, _opts$crossSigningVer, _opts$tofu, _opts$localVerified, _opts$trustCrossSigne;
+ this.signedByOwner = (_opts$signedByOwner = opts.signedByOwner) !== null && _opts$signedByOwner !== void 0 ? _opts$signedByOwner : false;
+ this.crossSigningVerified = (_opts$crossSigningVer = opts.crossSigningVerified) !== null && _opts$crossSigningVer !== void 0 ? _opts$crossSigningVer : false;
+ this.tofu = (_opts$tofu = opts.tofu) !== null && _opts$tofu !== void 0 ? _opts$tofu : false;
+ this.localVerified = (_opts$localVerified = opts.localVerified) !== null && _opts$localVerified !== void 0 ? _opts$localVerified : false;
+ this.trustCrossSignedDevices = (_opts$trustCrossSigne = opts.trustCrossSignedDevices) !== null && _opts$trustCrossSigne !== void 0 ? _opts$trustCrossSigne : false;
+ }
+
+ /**
+ * 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 cross-signed with a verified signing key, **and** the client has been configured to trust
+ * cross-signed devices via {@link Crypto.CryptoApi#setTrustCrossSignedDevices}.
+ *
+ * @returns true if this device is verified via any means.
+ */
+ isVerified() {
+ return this.localVerified || this.trustCrossSignedDevices && this.crossSigningVerified;
+ }
+}
+
+/**
+ * Room key import progress report.
+ * Used when calling {@link CryptoApi#importRoomKeys} as the parameter of
+ * the progressCallback. Used to display feedback.
+ */
+
+/**
+ * Options object for {@link CryptoApi#importRoomKeys}.
+ */
+
+/**
+ * The result of a call to {@link CryptoApi.getCrossSigningStatus}.
+ */
+
+/**
+ * Crypto callbacks provided by the application
+ */
+
+/**
+ * Parameter of {@link CryptoApi#bootstrapSecretStorage}
+ */
+exports.DeviceVerificationStatus = DeviceVerificationStatus;
+/** Types of cross-signing key */
+let CrossSigningKey = /*#__PURE__*/function (CrossSigningKey) {
+ CrossSigningKey["Master"] = "master";
+ CrossSigningKey["SelfSigning"] = "self_signing";
+ CrossSigningKey["UserSigning"] = "user_signing";
+ return CrossSigningKey;
+}({});
+/**
+ * Information on one of the cross-signing keys.
+ * @see https://spec.matrix.org/v1.7/client-server-api/#post_matrixclientv3keysdevice_signingupload
+ */
+/**
+ * Recovery key created by {@link CryptoApi#createRecoveryKeyFromPassphrase}
+ */
+/**
+ * Result type of {@link CryptoApi#getEncryptionInfoForEvent}.
+ */
+exports.CrossSigningKey = CrossSigningKey;
+/**
+ * Types of shield to be shown for {@link EventEncryptionInfo#shieldColour}.
+ */
+let EventShieldColour = /*#__PURE__*/function (EventShieldColour) {
+ EventShieldColour[EventShieldColour["NONE"] = 0] = "NONE";
+ EventShieldColour[EventShieldColour["GREY"] = 1] = "GREY";
+ EventShieldColour[EventShieldColour["RED"] = 2] = "RED";
+ return EventShieldColour;
+}({});
+/**
+ * Reason codes for {@link EventEncryptionInfo#shieldReason}.
+ */
+exports.EventShieldColour = EventShieldColour;
+let EventShieldReason = /*#__PURE__*/function (EventShieldReason) {
+ EventShieldReason[EventShieldReason["UNKNOWN"] = 0] = "UNKNOWN";
+ EventShieldReason[EventShieldReason["UNVERIFIED_IDENTITY"] = 1] = "UNVERIFIED_IDENTITY";
+ EventShieldReason[EventShieldReason["UNSIGNED_DEVICE"] = 2] = "UNSIGNED_DEVICE";
+ EventShieldReason[EventShieldReason["UNKNOWN_DEVICE"] = 3] = "UNKNOWN_DEVICE";
+ EventShieldReason[EventShieldReason["AUTHENTICITY_NOT_GUARANTEED"] = 4] = "AUTHENTICITY_NOT_GUARANTEED";
+ EventShieldReason[EventShieldReason["MISMATCHED_SENDER_KEY"] = 5] = "MISMATCHED_SENDER_KEY";
+ return EventShieldReason;
+}({});
+exports.EventShieldReason = EventShieldReason;
+//# sourceMappingURL=crypto-api.js.map \ No newline at end of file