Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 33e742d308 |
+4
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "matrix-js-sdk",
|
||||
"version": "41.3.0",
|
||||
"version": "41.4.0-rc.0",
|
||||
"description": "Matrix Client-Server SDK for Javascript",
|
||||
"engines": {
|
||||
"node": ">=22.0.0"
|
||||
@@ -59,7 +59,8 @@
|
||||
"oidc-client-ts": "^3.0.1",
|
||||
"p-retry": "8",
|
||||
"sdp-transform": "^3.0.0",
|
||||
"unhomoglyph": "^1.0.6"
|
||||
"unhomoglyph": "^1.0.6",
|
||||
"uuid": "13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@action-validator/cli": "^0.6.0",
|
||||
@@ -131,7 +132,7 @@
|
||||
"flatted@<=3.4.1": "^3.4.2",
|
||||
"picomatch@>=4.0.0 <4.0.4": "^4.0.4",
|
||||
"yaml@>=2.0.0 <2.8.3": "^2.8.3",
|
||||
"vite": "8.0.8"
|
||||
"vite": "7.3.2"
|
||||
}
|
||||
},
|
||||
"packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319"
|
||||
|
||||
Generated
+453
-570
File diff suppressed because it is too large
Load Diff
@@ -279,7 +279,7 @@ export const {prefix}BACKUP_DECRYPTION_KEY_BASE58 = "{ backup_recovery_key }";
|
||||
/** Signed backup data, suitable for return from `GET /_matrix/client/v3/room_keys/keys/{{roomId}}/{{sessionId}}` */
|
||||
export const {prefix}SIGNED_BACKUP_DATA: KeyBackupInfo = { json.dumps(backup_data, indent=4) };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Per-room backup data, (supposedly) suitable for return from `GET /_matrix/client/v3/room_keys/keys/{{roomId}}`.
|
||||
* Contains the key from {prefix}MEGOLM_SESSION_DATA.
|
||||
*/
|
||||
@@ -422,7 +422,7 @@ def build_exported_megolm_key(device_curve_key: x25519.X25519PrivateKey) -> tupl
|
||||
"ed25519": encode_base64(ed25519.Ed25519PrivateKey.from_private_bytes(randbytes(32)).public_key().public_bytes(Encoding.Raw, PublicFormat.Raw)),
|
||||
},
|
||||
"forwarding_curve25519_key_chain": [],
|
||||
"m.shared_history": True,
|
||||
"org.matrix.msc3061.shared_history": True,
|
||||
}
|
||||
|
||||
return megolm_export, private_key
|
||||
|
||||
@@ -592,72 +592,6 @@ describe("RustCrypto", () => {
|
||||
expect(res.length).toEqual(0);
|
||||
});
|
||||
|
||||
it.each(["m.room_key_bundle", "io.element.msc4268.room_key_bundle"])(
|
||||
"should accept key bundles when we find out about them",
|
||||
async (type: string) => {
|
||||
// Given we are faking that the received to-device message is a
|
||||
// decrypted room key bundle.
|
||||
|
||||
// @ts-ignore Overriding a private function
|
||||
rustCrypto.receiveSyncChanges = vi.fn().mockReturnValue([keyBundleEvent(type)]);
|
||||
|
||||
// And that there is a pending key bundle
|
||||
|
||||
// @ts-ignore Overriding a private function
|
||||
rustCrypto.olmMachine.getPendingKeyBundleDetailsForRoom = vi.fn().mockReturnValue({
|
||||
inviteAcceptedAtMillis: Date.now(),
|
||||
inviterId: { toString: vi.fn().mockReturnValue("@inv:s.co") },
|
||||
});
|
||||
|
||||
// When we process to-device messages
|
||||
rustCrypto.maybeAcceptKeyBundle = vi.fn().mockName("maybeAcceptKeyBundle").mockResolvedValue(null);
|
||||
await rustCrypto.preprocessToDeviceMessages([]);
|
||||
|
||||
// Then we accepted the key bundle
|
||||
expect(rustCrypto.maybeAcceptKeyBundle).toHaveBeenCalledWith("!r:s.co", "@inv:s.co");
|
||||
},
|
||||
);
|
||||
|
||||
it("should not accept other to-device messages as key bundles when we receive them", async () => {
|
||||
// Given we are faking that the received to-device message looks
|
||||
// like a room key bundle, except it has the wrong type.
|
||||
|
||||
// @ts-ignore Overriding a private function
|
||||
rustCrypto.receiveSyncChanges = vi.fn().mockReturnValue([keyBundleEvent("foo.some_other_type")]);
|
||||
|
||||
// And that there is a pending key bundle
|
||||
|
||||
// @ts-ignore Overriding a private function
|
||||
rustCrypto.olmMachine.getPendingKeyBundleDetailsForRoom = vi.fn().mockReturnValue({
|
||||
inviteAcceptedAtMillis: Date.now(),
|
||||
inviterId: { toString: vi.fn().mockReturnValue("@inv:s.co") },
|
||||
});
|
||||
|
||||
// When we process to-device messages
|
||||
rustCrypto.maybeAcceptKeyBundle = vi.fn().mockName("maybeAcceptKeyBundle").mockResolvedValue(null);
|
||||
await rustCrypto.preprocessToDeviceMessages([]);
|
||||
|
||||
// Then we do not try to accepted a key bundle
|
||||
expect(rustCrypto.maybeAcceptKeyBundle).not.toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
function keyBundleEvent(type: string): RustSdkCryptoJs.ProcessedToDeviceEvent {
|
||||
return {
|
||||
rawEvent: JSON.stringify({
|
||||
content: { room_id: "!r:s.co" },
|
||||
sender: "",
|
||||
type,
|
||||
}),
|
||||
type: 0,
|
||||
encryptionInfo: {
|
||||
sender: "",
|
||||
senderDevice: null,
|
||||
senderCurve25519Key: "",
|
||||
isSenderVerified: vi.fn().mockReturnValue(true),
|
||||
},
|
||||
} as any as RustSdkCryptoJs.ProcessedToDeviceEvent;
|
||||
}
|
||||
|
||||
it("emits VerificationRequestReceived on incoming m.key.verification.request", async () => {
|
||||
rustCrypto = await makeTestRustCrypto(
|
||||
new MatrixHttpApi(new TypedEventEmitter<HttpApiEvent, HttpApiEventHandlerMap>(), {
|
||||
|
||||
@@ -2596,7 +2596,7 @@ function rustEncryptionInfoToJsEncryptionInfo(
|
||||
}
|
||||
|
||||
interface RoomKeyBundleMessage {
|
||||
type: "m.room_key_bundle" | "io.element.msc4268.room_key_bundle";
|
||||
type: "io.element.msc4268.room_key_bundle";
|
||||
content: {
|
||||
room_id: string;
|
||||
};
|
||||
@@ -2606,16 +2606,13 @@ interface RoomKeyBundleMessage {
|
||||
* Determines if the given payload is a RoomKeyBundleMessage.
|
||||
*
|
||||
* A RoomKeyBundleMessage is identified by having a specific message type
|
||||
* ("m.room_key_bundle") and a valid room_id in its content.
|
||||
* ("io.element.msc4268.room_key_bundle") and a valid room_id in its content.
|
||||
*
|
||||
* @param message - The received to-device message to check.
|
||||
* @returns True if the payload matches the RoomKeyBundleMessage structure, false otherwise.
|
||||
*/
|
||||
function isRoomKeyBundleMessage(message: IToDeviceEvent): message is IToDeviceEvent & RoomKeyBundleMessage {
|
||||
return (
|
||||
(message.type === "io.element.msc4268.room_key_bundle" || message.type === "m.room_key_bundle") &&
|
||||
typeof message.content.room_id === "string"
|
||||
);
|
||||
return message.type === "io.element.msc4268.room_key_bundle" && typeof message.content.room_id === "string";
|
||||
}
|
||||
|
||||
type CryptoEvents = (typeof CryptoEvent)[keyof typeof CryptoEvent];
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ limitations under the License.
|
||||
* This is an internal module. See {@link createNewMatrixCall} for the public API.
|
||||
*/
|
||||
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { parse as parseSdp, write as writeSdp } from "sdp-transform";
|
||||
|
||||
import { logger } from "../logger.ts";
|
||||
@@ -2489,7 +2490,7 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
|
||||
sender_session_id: this.client.getSessionId(),
|
||||
dest_session_id: this.opponentSessionId,
|
||||
seq: toDeviceSeq,
|
||||
[ToDeviceMessageId]: globalThis.crypto.randomUUID(),
|
||||
[ToDeviceMessageId]: uuidv4(),
|
||||
};
|
||||
|
||||
this.emit(
|
||||
|
||||
Reference in New Issue
Block a user