From 620e5e2dd2f67bc3dc175a394f1a25a35ef72dcf Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 19 Sep 2024 13:37:54 +0100 Subject: [PATCH 1/5] Update matrix-bot-sdk to 0.7.1 element.5 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 809634c1..49007289 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "dependencies": { "@types/nedb": "^1.8.16", "@alloc/quick-lru": "^5.2.0", - "@vector-im/matrix-bot-sdk": "^0.7.0-element.0", + "@vector-im/matrix-bot-sdk": "^0.7.1-element.5", "chalk": "^4.1.0", "express": "^4.18.2", "express-rate-limit": "^7.1.5", diff --git a/yarn.lock b/yarn.lock index 9735ee9a..3e64e284 100644 --- a/yarn.lock +++ b/yarn.lock @@ -424,10 +424,10 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" -"@matrix-org/matrix-sdk-crypto-nodejs@0.1.0-beta.11": - version "0.1.0-beta.11" - resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-nodejs/-/matrix-sdk-crypto-nodejs-0.1.0-beta.11.tgz#537cd7a7bbce1d9745b812a5a7ffa9a5944e146c" - integrity sha512-z5adcQo4o0UAry4zs6JHGxbTDlYTUMKUfpOpigmso65ETBDumbeTSQCWRw8UeUV7aCAyVoHARqDTol9SrauEFA== +"@matrix-org/matrix-sdk-crypto-nodejs@0.2.0-beta.1": + version "0.2.0-beta.1" + resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-nodejs/-/matrix-sdk-crypto-nodejs-0.2.0-beta.1.tgz#b696707ccfa944cfed3c96cf7e54799b0f1e3329" + integrity sha512-CgbOKORfD6dvYgQTPhfN73H1RbQknrFkMnRRwCIJMt15iL2AF1gEowgbrlGhkbG6gNng4CgPnKs1iHKCRrhvmA== dependencies: https-proxy-agent "^5.0.1" node-downloader-helper "^2.1.5" @@ -716,12 +716,12 @@ resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ== -"@vector-im/matrix-bot-sdk@^0.7.0-element.0": - version "0.7.0-element.0" - resolved "https://registry.yarnpkg.com/@vector-im/matrix-bot-sdk/-/matrix-bot-sdk-0.7.0-element.0.tgz#2b27996d3c07a6cc5778076f97a499c2706b9e2c" - integrity sha512-jWL52NuICQ+cPpqft14ZdIP8laUZHC3QcbjnN3It9isSpdx6JmSaVasAsJe3yYbhI1ZSJFdSz2nAlSZ30JYGrw== +"@vector-im/matrix-bot-sdk@^0.7.1-element.5": + version "0.7.1-element.5" + resolved "https://registry.yarnpkg.com/@vector-im/matrix-bot-sdk/-/matrix-bot-sdk-0.7.1-element.5.tgz#ce4b47a96a2138165bf8f73b1bc31641ac37645b" + integrity sha512-jLe9aZIQHPJVC18A99eAzxQpQbw0lw2o7nk36NK2zyT1SpntQ7PGDu76O5ADSIc9dzssqjs7gSp2vpmeVIaTkA== dependencies: - "@matrix-org/matrix-sdk-crypto-nodejs" "0.1.0-beta.11" + "@matrix-org/matrix-sdk-crypto-nodejs" "0.2.0-beta.1" "@types/express" "^4.17.21" another-json "^0.2.0" async-lock "^1.4.0" From 12bd2feb6bcb9ee7f0cf848d844b6cdfa64f543f Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 19 Sep 2024 13:38:00 +0100 Subject: [PATCH 2/5] Update func signature --- src/contentRepo.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contentRepo.ts b/src/contentRepo.ts index d751f058..1275dd06 100644 --- a/src/contentRepo.ts +++ b/src/contentRepo.ts @@ -14,8 +14,8 @@ import { MatrixClient } from "@vector-im/matrix-bot-sdk"; * for such URLs. * @return The complete URL to the content. May be empty string if mxc is not a string. */ -function getHttpUriForMxc(baseUrl: string, mxc: string, width?: number, height?: number, - resizeMethod?: "crop"|"scale", allowDirectLinks?: boolean): string { +async function getHttpUriForMxc(baseUrl: string, mxc: string, width?: number, height?: number, + resizeMethod?: "crop"|"scale", allowDirectLinks?: boolean): Promise { console.warn("Deprecated call to ContentRepo.getHttpUriForMxc, prefer to use Intent.matrixClient.mxcToHttp"); if (typeof mxc !== "string" || !mxc) { return ""; From 8da55d9db805d068a4d57044dff7e5c8f43bf3f5 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 19 Sep 2024 13:38:02 +0100 Subject: [PATCH 3/5] add changelog --- changelog.d/509.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/509.misc diff --git a/changelog.d/509.misc b/changelog.d/509.misc new file mode 100644 index 00000000..75194f17 --- /dev/null +++ b/changelog.d/509.misc @@ -0,0 +1 @@ +Add support for authenticated media. The `contentRepo.getHttpUriForMxc` function is now async to support feature detection. \ No newline at end of file From c48e4aaab3174fa7dbb078e011454fceb38cc756 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 19 Sep 2024 13:41:15 +0100 Subject: [PATCH 4/5] Update faked error --- spec/unit/activity-tracker.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/activity-tracker.spec.ts b/spec/unit/activity-tracker.spec.ts index 921e6814..35fbc697 100644 --- a/spec/unit/activity-tracker.spec.ts +++ b/spec/unit/activity-tracker.spec.ts @@ -3,7 +3,7 @@ import { ActivityTracker } from "../../src/index"; import { WhoisInfo, PresenceEventContent, MatrixClient, MatrixError } from "@vector-im/matrix-bot-sdk"; function throwMatrixError(statusCode: number) { - throw new MatrixError({errcode: "M_UNKNOWN", error: ""}, statusCode); + throw new MatrixError({errcode: "M_UNKNOWN", error: ""}, statusCode, {}); } const TEST_USER = "@foobar:example.com"; From 903f8bb64ad27b74b9f655b4d623293fdd439854 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 19 Sep 2024 13:54:37 +0100 Subject: [PATCH 5/5] fix MatrixError signatures --- spec/integ/bridge.spec.js | 2 +- spec/unit/intent.spec.js | 2 +- spec/unit/room-upgrade-handler.spec.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/integ/bridge.spec.js b/spec/integ/bridge.spec.js index f242565b..52b17d8e 100644 --- a/spec/integ/bridge.spec.js +++ b/spec/integ/bridge.spec.js @@ -827,7 +827,7 @@ describe("Bridge", function() { const mxUser = new MatrixUser("@foo:example.com"); const intent = bridge.getIntent(mxUser.getId()); const botClient = intent.botSdkIntent; - const err = new MatrixError({ errcode: "M_FORBIDDEN" }); + const err = new MatrixError({ errcode: "M_FORBIDDEN" }, 401, {}); const errorPromise = Promise.reject(err); // This complains otherwise. errorPromise.catch((ex) => {}); diff --git a/spec/unit/intent.spec.js b/spec/unit/intent.spec.js index 37b5b39b..a692d938 100644 --- a/spec/unit/intent.spec.js +++ b/spec/unit/intent.spec.js @@ -1,6 +1,6 @@ const { Intent } = require("../.."); const { MatrixError } = require('@vector-im/matrix-bot-sdk'); -const matrixError = async (errcode, error) => { throw new MatrixError({errcode, error}, 500)}; +const matrixError = async (errcode, error) => { throw new MatrixError({errcode, error}, 500, {})}; describe("Intent", function() { let intent, botIntent, client, botClient, underlyingClient; diff --git a/spec/unit/room-upgrade-handler.spec.js b/spec/unit/room-upgrade-handler.spec.js index 66d351b5..207c444b 100644 --- a/spec/unit/room-upgrade-handler.spec.js +++ b/spec/unit/room-upgrade-handler.spec.js @@ -36,7 +36,7 @@ describe("RoomUpgradeHandler", () => { let joined; const bridge = { getIntent: () => ({ - join: async (roomId) => { joined = roomId; throw new MatrixError({errcode: "M_FORBIDDEN"}); }, + join: async (roomId) => { joined = roomId; throw new MatrixError({errcode: "M_FORBIDDEN"}, 401, {}); }, }), }; const ruh = new RoomUpgradeHandler({}, bridge); @@ -92,7 +92,7 @@ describe("RoomUpgradeHandler", () => { let joined; const bridge = { getIntent: () => ({ - join: async (roomId) => { joined = roomId; throw new MatrixError({errcode: "M_FORBIDDEN"}); }, + join: async (roomId) => { joined = roomId; throw new MatrixError({errcode: "M_FORBIDDEN"}, 401, {}); }, }), }; const ruh = new RoomUpgradeHandler({}, bridge);