Skip to content

Commit b80d009

Browse files
t3chguyrichvdh
andauthored
Release tranche of breaking changes (#4963)
* Remove deprecated `IJoinRoomOpts.syncRoom` option (#4914) This option is non-functional, and was deprecated in #4913. Remove it altogether. * Remove support for `onlyData != true` (#4939) * Remove deprecated fields, methods, utilities (#4959) --------- Co-authored-by: Richard van der Hoff <[email protected]> Co-authored-by: Richard van der Hoff <[email protected]>
1 parent 3a33c65 commit b80d009

File tree

19 files changed

+158
-380
lines changed

19 files changed

+158
-380
lines changed

spec/integ/crypto/crypto.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,8 +1491,10 @@ describe("crypto", () => {
14911491

14921492
expect(ev.decryptionFailureReason).toEqual(expectedErrorCode);
14931493

1494-
// `isEncryptedDisabledForUnverifiedDevices` should be true for `m.unverified` and false for other errors.
1495-
expect(ev.isEncryptedDisabledForUnverifiedDevices).toEqual(withheldCode === "m.unverified");
1494+
// `decryptionFailureReason` should be `MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE` for `m.unverified`
1495+
expect(
1496+
ev.decryptionFailureReason === DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE,
1497+
).toEqual(withheldCode === "m.unverified");
14961498
});
14971499
},
14981500
);

spec/unit/http-api/fetch.spec.ts

Lines changed: 87 additions & 35 deletions
Large diffs are not rendered by default.

spec/unit/http-api/index.spec.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ describe("MatrixHttpApi", () => {
6262
it("should fall back to `fetch` where xhr is unavailable", async () => {
6363
globalThis.XMLHttpRequest = undefined!;
6464
const fetchFn = jest.fn().mockResolvedValue({ ok: true, json: jest.fn().mockResolvedValue({}) });
65-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, fetchFn });
65+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, fetchFn, onlyData: true });
6666
upload = api.uploadContent({} as File);
6767
await upload;
6868
expect(fetchFn).toHaveBeenCalled();
6969
});
7070

7171
it("should prefer xhr where available", () => {
7272
const fetchFn = jest.fn().mockResolvedValue({ ok: true });
73-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, fetchFn });
73+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, fetchFn, onlyData: true });
7474
upload = api.uploadContent({} as File);
7575
expect(fetchFn).not.toHaveBeenCalled();
7676
expect(xhr.open).toHaveBeenCalled();
@@ -82,6 +82,7 @@ describe("MatrixHttpApi", () => {
8282
prefix,
8383
accessToken: "token",
8484
useAuthorizationHeader: false,
85+
onlyData: true,
8586
});
8687
upload = api.uploadContent({} as File);
8788
expect(xhr.open).toHaveBeenCalledWith(
@@ -96,14 +97,15 @@ describe("MatrixHttpApi", () => {
9697
baseUrl,
9798
prefix,
9899
accessToken: "token",
100+
onlyData: true,
99101
});
100102
upload = api.uploadContent({} as File);
101103
expect(xhr.open).toHaveBeenCalledWith(Method.Post, baseUrl.toLowerCase() + "/_matrix/media/v3/upload");
102104
expect(xhr.setRequestHeader).toHaveBeenCalledWith("Authorization", "Bearer token");
103105
});
104106

105107
it("should include filename by default", () => {
106-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
108+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
107109
upload = api.uploadContent({} as File, { name: "name" });
108110
expect(xhr.open).toHaveBeenCalledWith(
109111
Method.Post,
@@ -112,21 +114,21 @@ describe("MatrixHttpApi", () => {
112114
});
113115

114116
it("should allow not sending the filename", () => {
115-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
117+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
116118
upload = api.uploadContent({} as File, { name: "name", includeFilename: false });
117119
expect(xhr.open).toHaveBeenCalledWith(Method.Post, baseUrl.toLowerCase() + "/_matrix/media/v3/upload");
118120
});
119121

120122
it("should abort xhr when the upload is aborted", () => {
121-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
123+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
122124
upload = api.uploadContent({} as File);
123125
api.cancelUpload(upload);
124126
expect(xhr.abort).toHaveBeenCalled();
125127
return expect(upload).rejects.toThrow("Aborted");
126128
});
127129

128130
it("should timeout if no progress in 30s", () => {
129-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
131+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
130132
upload = api.uploadContent({} as File);
131133
jest.advanceTimersByTime(25000);
132134
// @ts-ignore
@@ -138,7 +140,7 @@ describe("MatrixHttpApi", () => {
138140
});
139141

140142
it("should call progressHandler", () => {
141-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
143+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
142144
const progressHandler = jest.fn();
143145
upload = api.uploadContent({} as File, { progressHandler });
144146
const progressEvent = new Event("progress") as ProgressEvent;
@@ -154,7 +156,7 @@ describe("MatrixHttpApi", () => {
154156
});
155157

156158
it("should error when no response body", () => {
157-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
159+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
158160
upload = api.uploadContent({} as File);
159161

160162
xhr.readyState = DONE;
@@ -167,7 +169,7 @@ describe("MatrixHttpApi", () => {
167169
});
168170

169171
it("should error on a 400-code", () => {
170-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
172+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
171173
upload = api.uploadContent({} as File);
172174

173175
xhr.readyState = DONE;
@@ -184,7 +186,7 @@ describe("MatrixHttpApi", () => {
184186
});
185187

186188
it("should return response on successful upload", () => {
187-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
189+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
188190
upload = api.uploadContent({} as File);
189191

190192
xhr.readyState = DONE;
@@ -198,14 +200,14 @@ describe("MatrixHttpApi", () => {
198200
});
199201

200202
it("should abort xhr when calling `cancelUpload`", () => {
201-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
203+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
202204
upload = api.uploadContent({} as File);
203205
expect(api.cancelUpload(upload)).toBeTruthy();
204206
expect(xhr.abort).toHaveBeenCalled();
205207
});
206208

207209
it("should return false when `cancelUpload` is called but unsuccessful", async () => {
208-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
210+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
209211
upload = api.uploadContent({} as File);
210212

211213
xhr.readyState = DONE;
@@ -220,15 +222,20 @@ describe("MatrixHttpApi", () => {
220222
});
221223

222224
it("should return active uploads in `getCurrentUploads`", () => {
223-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix });
225+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, onlyData: true });
224226
upload = api.uploadContent({} as File);
225227
expect(api.getCurrentUploads().find((u) => u.promise === upload)).toBeTruthy();
226228
api.cancelUpload(upload);
227229
expect(api.getCurrentUploads().find((u) => u.promise === upload)).toBeFalsy();
228230
});
229231

230232
it("should return expected object from `getContentUri`", () => {
231-
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), { baseUrl, prefix, accessToken: "token" });
233+
const api = new MatrixHttpApi(new TypedEventEmitter<any, any>(), {
234+
baseUrl,
235+
prefix,
236+
accessToken: "token",
237+
onlyData: true,
238+
});
232239
expect(api.getContentUri()).toMatchSnapshot();
233240
});
234241
});

spec/unit/matrix-client.spec.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,24 +3597,6 @@ describe("MatrixClient", function () {
35973597
});
35983598
});
35993599

3600-
describe("getAuthIssuer", () => {
3601-
it("should use unstable prefix", async () => {
3602-
httpLookups = [
3603-
{
3604-
method: "GET",
3605-
path: `/auth_issuer`,
3606-
data: {
3607-
issuer: "https://issuer/",
3608-
},
3609-
prefix: "/_matrix/client/unstable/org.matrix.msc2965",
3610-
},
3611-
];
3612-
3613-
await expect(client.getAuthIssuer()).resolves.toEqual({ issuer: "https://issuer/" });
3614-
expect(httpLookups.length).toEqual(0);
3615-
});
3616-
});
3617-
36183600
describe("getAuthMetadata", () => {
36193601
beforeEach(() => {
36203602
fetchMock.mockReset();

spec/unit/models/event.spec.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ describe("MatrixEvent", () => {
379379
expect(encryptedEvent.isBeingDecrypted()).toBeFalsy();
380380
expect(encryptedEvent.isDecryptionFailure()).toBeTruthy();
381381
expect(encryptedEvent.decryptionFailureReason).toEqual(DecryptionFailureCode.UNKNOWN_ERROR);
382-
expect(encryptedEvent.isEncryptedDisabledForUnverifiedDevices).toBeFalsy();
382+
expect(encryptedEvent.decryptionFailureReason).not.toBe(
383+
DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE,
384+
);
383385
expect(encryptedEvent.getContent()).toEqual({
384386
msgtype: "m.bad.encrypted",
385387
body: "** Unable to decrypt: Error: test error **",
@@ -403,7 +405,9 @@ describe("MatrixEvent", () => {
403405
expect(encryptedEvent.decryptionFailureReason).toEqual(
404406
DecryptionFailureCode.MEGOLM_UNKNOWN_INBOUND_SESSION_ID,
405407
);
406-
expect(encryptedEvent.isEncryptedDisabledForUnverifiedDevices).toBeFalsy();
408+
expect(encryptedEvent.decryptionFailureReason).not.toBe(
409+
DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE,
410+
);
407411
expect(encryptedEvent.getContent()).toEqual({
408412
msgtype: "m.bad.encrypted",
409413
body: "** Unable to decrypt: DecryptionError: uisi **",
@@ -427,7 +431,9 @@ describe("MatrixEvent", () => {
427431
expect(encryptedEvent.isEncrypted()).toBeTruthy();
428432
expect(encryptedEvent.isBeingDecrypted()).toBeFalsy();
429433
expect(encryptedEvent.isDecryptionFailure()).toBeTruthy();
430-
expect(encryptedEvent.isEncryptedDisabledForUnverifiedDevices).toBeTruthy();
434+
expect(encryptedEvent.decryptionFailureReason).toBe(
435+
DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE,
436+
);
431437
expect(encryptedEvent.getContent()).toEqual({
432438
msgtype: "m.bad.encrypted",
433439
body: "** Unable to decrypt: DecryptionError: The sender has disabled encrypting to unverified devices. **",

src/@types/requests.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ import { type EventType, type RelationType, type RoomType } from "./event.ts";
2727
/* eslint-disable camelcase */
2828

2929
export interface IJoinRoomOpts {
30-
/**
31-
* @deprecated does nothing
32-
*/
33-
syncRoom?: boolean;
34-
3530
/**
3631
* If the caller has a keypair 3pid invite, the signing URL is passed in this parameter.
3732
*/

src/@types/uia.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,3 @@ import { type AuthDict } from "../interactive-auth.ts";
2222
export type UIARequest<T> = T & {
2323
auth?: AuthDict;
2424
};
25-
26-
/**
27-
* Helper type to represent HTTP response body for a UIA enabled endpoint
28-
* @deprecated - a successful response for a UIA enabled endpoint is no different, UIA is signalled via an error
29-
*/
30-
export type UIAResponse<T> = T;

src/client.ts

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,20 +1085,6 @@ export enum ClientEvent {
10851085
*/
10861086
ClientWellKnown = "WellKnown.client",
10871087
ReceivedVoipEvent = "received_voip_event",
1088-
/**
1089-
* @deprecated This event is not supported anymore.
1090-
*
1091-
* Fires if a to-device event is received that cannot be decrypted.
1092-
* Encrypted to-device events will (generally) use plain Olm encryption,
1093-
* in which case decryption failures are fatal: the event will never be
1094-
* decryptable, unlike Megolm encrypted events where the key may simply
1095-
* arrive later.
1096-
*
1097-
* An undecryptable to-device event is therefore likely to indicate problems.
1098-
*
1099-
* The payload is the undecyptable to-device event
1100-
*/
1101-
UndecryptableToDeviceEvent = "toDeviceEvent.undecryptable",
11021088
TurnServers = "turnServers",
11031089
TurnServersError = "turnServers.error",
11041090
}
@@ -1163,7 +1149,6 @@ export type ClientEventHandlerMap = {
11631149
[ClientEvent.Event]: (event: MatrixEvent) => void;
11641150
[ClientEvent.ToDeviceEvent]: (event: MatrixEvent) => void;
11651151
[ClientEvent.ReceivedToDeviceMessage]: (payload: ReceivedToDeviceMessage) => void;
1166-
[ClientEvent.UndecryptableToDeviceEvent]: (event: MatrixEvent) => void;
11671152
[ClientEvent.AccountData]: (event: MatrixEvent, lastEvent?: MatrixEvent) => void;
11681153
[ClientEvent.Room]: (room: Room) => void;
11691154
[ClientEvent.DeleteRoom]: (roomId: string) => void;
@@ -6862,9 +6847,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
68626847
*
68636848
* @param opts - options object
68646849
*
6865-
* @returns Promise which resolves to response object, as
6866-
* determined by this.opts.onlyData, opts.rawResponse, and
6867-
* opts.onlyContentUri. Rejects with an error (usually a MatrixError).
6850+
* @returns Promise which resolves to response object, or rejects with an error (usually a MatrixError).
68686851
*/
68696852
public uploadContent(file: FileType, opts?: UploadOpts): Promise<UploadResponse> {
68706853
return this.http.uploadContent(file, opts);
@@ -8417,21 +8400,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
84178400
}
84188401
}
84198402

8420-
/**
8421-
* Get the OIDC issuer responsible for authentication on this server, if any
8422-
* @returns Resolves: A promise of an object containing the OIDC issuer if configured
8423-
* @returns Rejects: when the request fails (module:http-api.MatrixError)
8424-
* @experimental - part of MSC2965
8425-
* @deprecated in favour of getAuthMetadata
8426-
*/
8427-
public async getAuthIssuer(): Promise<{
8428-
issuer: string;
8429-
}> {
8430-
return this.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
8431-
prefix: ClientPrefix.Unstable + "/org.matrix.msc2965",
8432-
});
8433-
}
8434-
84358403
/**
84368404
* Discover and validate delegated auth configuration
84378405
* - delegated auth issuer openid-configuration is reachable
@@ -8451,7 +8419,12 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
84518419
});
84528420
} catch (e) {
84538421
if (e instanceof MatrixError && e.errcode === "M_UNRECOGNIZED") {
8454-
const { issuer } = await this.getAuthIssuer();
8422+
// Fall back to older variant of MSC2965
8423+
const { issuer } = await this.http.request<{
8424+
issuer: string;
8425+
}>(Method.Get, "/auth_issuer", undefined, undefined, {
8426+
prefix: ClientPrefix.Unstable + "/org.matrix.msc2965",
8427+
});
84558428
return discoverAndValidateOIDCIssuerWellKnown(issuer);
84568429
}
84578430
throw e;

0 commit comments

Comments
 (0)