Skip to content

Commit

Permalink
Support authenticated media (by updating the matrix-bot-sdk) (#509)
Browse files Browse the repository at this point in the history
* Update matrix-bot-sdk to 0.7.1 element.5

* Update func signature

* add changelog

* Update faked error

* fix MatrixError signatures
  • Loading branch information
Half-Shot authored Sep 19, 2024
1 parent 6d6700c commit cde3327
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions changelog.d/509.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for authenticated media. The `contentRepo.getHttpUriForMxc` function is now async to support feature detection.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion spec/integ/bridge.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {});
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/activity-tracker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/intent.spec.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/room-upgrade-handler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/contentRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
console.warn("Deprecated call to ContentRepo.getHttpUriForMxc, prefer to use Intent.matrixClient.mxcToHttp");
if (typeof mxc !== "string" || !mxc) {
return "";
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit cde3327

Please sign in to comment.