matrix-js-sdk 41.2.0 → 41.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/lib/client.d.ts +1 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +2 -0
- package/lib/client.js.map +1 -1
- package/lib/crypto-api/index.d.ts +6 -0
- package/lib/crypto-api/index.d.ts.map +1 -1
- package/lib/crypto-api/index.js +6 -0
- package/lib/crypto-api/index.js.map +1 -1
- package/lib/rust-crypto/rust-crypto.d.ts +24 -0
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/lib/rust-crypto/rust-crypto.js +33 -0
- package/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/package.json +5 -5
- package/src/client.ts +2 -1
- package/src/crypto-api/index.ts +6 -0
- package/src/rust-crypto/rust-crypto.ts +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matrix-js-sdk",
|
|
3
|
-
"version": "41.
|
|
3
|
+
"version": "41.3.0",
|
|
4
4
|
"description": "Matrix Client-Server SDK for Javascript",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"fetch-mock": "^12.6.0",
|
|
107
107
|
"happy-dom": "^20.1.0",
|
|
108
108
|
"husky": "^9.0.0",
|
|
109
|
-
"knip": "^
|
|
109
|
+
"knip": "^6.0.0",
|
|
110
110
|
"lint-staged": "^16.0.0",
|
|
111
111
|
"matrix-mock-request": "^2.5.0",
|
|
112
112
|
"prettier": "3.8.1",
|
|
@@ -114,12 +114,12 @@
|
|
|
114
114
|
"typedoc-plugin-coverage": "^4.0.0",
|
|
115
115
|
"typedoc-plugin-mdn-links": "^5.0.0",
|
|
116
116
|
"typedoc-plugin-missing-exports": "^4.0.0",
|
|
117
|
-
"typescript": "^
|
|
117
|
+
"typescript": "^6.0.0",
|
|
118
118
|
"vitest": "^4.0.17",
|
|
119
119
|
"vitest-sonar-reporter": "^3.0.0"
|
|
120
120
|
},
|
|
121
121
|
"resolutions": {
|
|
122
|
-
"expect": "30.
|
|
122
|
+
"expect": "30.3.0"
|
|
123
123
|
},
|
|
124
124
|
"pnpm": {
|
|
125
125
|
"peerDependencyRules": {
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
"eslint": "8"
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
|
-
"packageManager": "pnpm@10.
|
|
134
|
+
"packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be"
|
|
135
135
|
}
|
package/src/client.ts
CHANGED
|
@@ -101,7 +101,7 @@ import {
|
|
|
101
101
|
type RoomNameState,
|
|
102
102
|
} from "./models/room.ts";
|
|
103
103
|
import { RoomMemberEvent, type RoomMemberEventHandlerMap } from "./models/room-member.ts";
|
|
104
|
-
import {
|
|
104
|
+
import { RoomStateEvent, type IPowerLevelsContent, type RoomStateEventHandlerMap } from "./models/room-state.ts";
|
|
105
105
|
import {
|
|
106
106
|
isSendDelayedEventRequestOpts,
|
|
107
107
|
UpdateDelayedEventAction,
|
|
@@ -2027,6 +2027,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
|
2027
2027
|
|
|
2028
2028
|
// attach the event listeners needed by RustCrypto
|
|
2029
2029
|
this.on(RoomMemberEvent.Membership, rustCrypto.onRoomMembership.bind(rustCrypto));
|
|
2030
|
+
this.on(RoomStateEvent.Events, rustCrypto.onRoomStateEvent.bind(rustCrypto));
|
|
2030
2031
|
this.on(ClientEvent.Event, (event) => {
|
|
2031
2032
|
rustCrypto.onLiveEventFromSync(event);
|
|
2032
2033
|
});
|
package/src/crypto-api/index.ts
CHANGED
|
@@ -794,6 +794,9 @@ export enum DeviceIsolationModeKind {
|
|
|
794
794
|
*
|
|
795
795
|
* Events from all senders are always decrypted (and should be decorated with message shields in case
|
|
796
796
|
* of authenticity warnings, see {@link EventEncryptionInfo}).
|
|
797
|
+
*
|
|
798
|
+
* `AllDevicesIsolationMode` is used in the legacy, non-'exclude insecure devices' mode in Element Web. It is not
|
|
799
|
+
* recommended (see {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4153 | MSC4153}).
|
|
797
800
|
*/
|
|
798
801
|
export class AllDevicesIsolationMode {
|
|
799
802
|
public readonly kind = DeviceIsolationModeKind.AllDevicesIsolationMode;
|
|
@@ -820,6 +823,9 @@ export class AllDevicesIsolationMode {
|
|
|
820
823
|
*
|
|
821
824
|
* Events are decrypted only if they come from a cross-signed device. Other events will result in a decryption
|
|
822
825
|
* failure. (To access the failure reason, see {@link MatrixEvent.decryptionFailureReason}.)
|
|
826
|
+
*
|
|
827
|
+
* `OnlySignedDevicesIsolationMode` corresponds to the 'Exclude insecure devices' mode in Element Web, which is
|
|
828
|
+
* recommended by {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4153 | MSC4153}.
|
|
823
829
|
*/
|
|
824
830
|
export class OnlySignedDevicesIsolationMode {
|
|
825
831
|
public readonly kind = DeviceIsolationModeKind.OnlySignedDevicesIsolationMode;
|
|
@@ -98,6 +98,7 @@ import { VerificationMethod } from "../types.ts";
|
|
|
98
98
|
import { keyFromAuthData } from "../common-crypto/key-passphrase.ts";
|
|
99
99
|
import { type UIAuthCallback } from "../interactive-auth.ts";
|
|
100
100
|
import { getHttpUriForMxc } from "../content-repo.ts";
|
|
101
|
+
import { type RoomState } from "../matrix.ts";
|
|
101
102
|
|
|
102
103
|
const ALL_VERIFICATION_METHODS = [
|
|
103
104
|
VerificationMethod.Sas,
|
|
@@ -1955,6 +1956,43 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
|
|
|
1955
1956
|
enc.onRoomMembership(member);
|
|
1956
1957
|
}
|
|
1957
1958
|
|
|
1959
|
+
/**
|
|
1960
|
+
* Previously, it was sufficient to check if we need to rotate the room key
|
|
1961
|
+
* prior to sending a message. However, the history sharing feature
|
|
1962
|
+
* (MSC4268) breaks this logic:
|
|
1963
|
+
*
|
|
1964
|
+
* 1. Alice sends a message M1 in room X;
|
|
1965
|
+
* 2. Bob invites Charlie, who joins and immediately leaves the room;
|
|
1966
|
+
* 3. Alice sends another message M2 in room X.
|
|
1967
|
+
*
|
|
1968
|
+
* Under the old logic, Alice would not rotate her key after Charlie
|
|
1969
|
+
* leaves, resulting in M2 being encrypted with the same session as M1.
|
|
1970
|
+
* This would allow Charlie to decrypt M2 if he ever gains access to
|
|
1971
|
+
* the event.
|
|
1972
|
+
*
|
|
1973
|
+
* To counter this, we proactively discard any active outgoing Megolm
|
|
1974
|
+
* session when we see a `leave` event. Note that we have to do this in
|
|
1975
|
+
* `onRoomStateEvent` rather than `onRoomMembership`, because
|
|
1976
|
+
* `onRoomMembership` is only called when we see a *change* in membership.
|
|
1977
|
+
* In the case of a gappy sync, we might miss Charlie's invite and join,
|
|
1978
|
+
* and only see the final `leave` event (sohis membership goes from `leave`
|
|
1979
|
+
* to `leave`).
|
|
1980
|
+
*/
|
|
1981
|
+
public onRoomStateEvent(event: MatrixEvent, state: RoomState, prevEvent: MatrixEvent | null): void {
|
|
1982
|
+
if (event.getType() != EventType.RoomMember) {
|
|
1983
|
+
// Ignore all events that aren't member updates.
|
|
1984
|
+
return;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
if (
|
|
1988
|
+
event.getStateKey()! !== this.olmMachine.userId.toString() &&
|
|
1989
|
+
event.getContent().membership === KnownMembership.Leave
|
|
1990
|
+
) {
|
|
1991
|
+
this.logger.info(`Rotating session for room ${event.getRoomId()} due to member leaving the room`);
|
|
1992
|
+
this.forceDiscardSession(event.getRoomId()!);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1958
1996
|
/** Callback for OlmMachine.registerRoomKeyUpdatedCallback
|
|
1959
1997
|
*
|
|
1960
1998
|
* Called by the rust-sdk whenever there is an update to (megolm) room keys. We
|