feat: complete Ancestor quote bot with production-ready Docker support
This commit is contained in:
39
node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js
generated
vendored
39
node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js
generated
vendored
@@ -1,3 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.deviceKeysToDeviceMap = deviceKeysToDeviceMap;
|
||||
exports.downloadDeviceToJsDevice = downloadDeviceToJsDevice;
|
||||
exports.rustDeviceToJsDevice = rustDeviceToJsDevice;
|
||||
var RustSdkCryptoJs = _interopRequireWildcard(require("@matrix-org/matrix-sdk-crypto-wasm"));
|
||||
var _device = require("../models/device");
|
||||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
||||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
/*
|
||||
Copyright 2023 The Matrix.org Foundation C.I.C.
|
||||
|
||||
@@ -14,8 +26,6 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm";
|
||||
import { Device, DeviceVerification } from "../models/device.js";
|
||||
/**
|
||||
* Convert a {@link RustSdkCryptoJs.Device} to a {@link Device}
|
||||
* @param device - Rust Sdk device
|
||||
@@ -23,7 +33,7 @@ import { Device, DeviceVerification } from "../models/device.js";
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function rustDeviceToJsDevice(device, userId) {
|
||||
function rustDeviceToJsDevice(device, userId) {
|
||||
// Copy rust device keys to Device.keys
|
||||
const keys = new Map();
|
||||
for (const [keyId, key] of device.keys.entries()) {
|
||||
@@ -31,11 +41,11 @@ export function rustDeviceToJsDevice(device, userId) {
|
||||
}
|
||||
|
||||
// Compute verified from device state
|
||||
let verified = DeviceVerification.Unverified;
|
||||
let verified = _device.DeviceVerification.Unverified;
|
||||
if (device.isBlacklisted()) {
|
||||
verified = DeviceVerification.Blocked;
|
||||
verified = _device.DeviceVerification.Blocked;
|
||||
} else if (device.isVerified()) {
|
||||
verified = DeviceVerification.Verified;
|
||||
verified = _device.DeviceVerification.Verified;
|
||||
}
|
||||
|
||||
// Convert rust signatures to Device.signatures
|
||||
@@ -67,15 +77,14 @@ export function rustDeviceToJsDevice(device, userId) {
|
||||
break;
|
||||
}
|
||||
});
|
||||
return new Device({
|
||||
return new _device.Device({
|
||||
deviceId: device.deviceId.toString(),
|
||||
userId: userId.toString(),
|
||||
keys,
|
||||
algorithms: Array.from(algorithms),
|
||||
verified,
|
||||
signatures,
|
||||
displayName: device.displayName,
|
||||
dehydrated: device.isDehydrated
|
||||
displayName: device.displayName
|
||||
});
|
||||
}
|
||||
|
||||
@@ -85,7 +94,7 @@ export function rustDeviceToJsDevice(device, userId) {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function deviceKeysToDeviceMap(deviceKeys) {
|
||||
function deviceKeysToDeviceMap(deviceKeys) {
|
||||
return new Map(Object.entries(deviceKeys).map(([deviceId, device]) => [deviceId, downloadDeviceToJsDevice(device)]));
|
||||
}
|
||||
|
||||
@@ -97,22 +106,22 @@ export function deviceKeysToDeviceMap(deviceKeys) {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function downloadDeviceToJsDevice(device) {
|
||||
function downloadDeviceToJsDevice(device) {
|
||||
var _device$unsigned;
|
||||
const keys = new Map(Object.entries(device.keys));
|
||||
const displayName = device.unsigned?.device_display_name;
|
||||
const displayName = (_device$unsigned = device.unsigned) === null || _device$unsigned === void 0 ? void 0 : _device$unsigned.device_display_name;
|
||||
const signatures = new Map();
|
||||
if (device.signatures) {
|
||||
// oxlint-disable-next-line guard-for-in
|
||||
for (const userId in device.signatures) {
|
||||
signatures.set(userId, new Map(Object.entries(device.signatures[userId])));
|
||||
}
|
||||
}
|
||||
return new Device({
|
||||
return new _device.Device({
|
||||
deviceId: device.device_id,
|
||||
userId: device.user_id,
|
||||
keys,
|
||||
algorithms: device.algorithms,
|
||||
verified: DeviceVerification.Unverified,
|
||||
verified: _device.DeviceVerification.Unverified,
|
||||
signatures,
|
||||
displayName
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user