Skip to content

Commit 3d3f7d6

Browse files
authored
Update dependencies (and fix a few security notices) (#1024)
* Update new dependencies. * Support ESM parse-duration * changelog * drop only! * fix types
1 parent 6a2246b commit 3d3f7d6

File tree

9 files changed

+161
-1283
lines changed

9 files changed

+161
-1283
lines changed

changelog.d/1024.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update dependencies with security advisories.

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
"@vector-im/compound-design-tokens": "^2.0.1",
5252
"@vector-im/compound-web": "^7.3.0",
5353
"ajv": "^8.11.0",
54-
"axios": "^1.7.5",
54+
"axios": "^1.7.9",
5555
"clsx": "^2.1.1",
5656
"cors": "^2.8.5",
5757
"date-fns": "^4.1.0",
5858
"express": "^4.20.0",
59-
"figma-js": "^1.14.0",
59+
"figma-js": "^1.16.1-0",
6060
"helmet": "^7.1.0",
6161
"http-status-codes": "^2.2.0",
6262
"ioredis": "^5.2.3",
@@ -68,7 +68,7 @@
6868
"micromatch": "^4.0.8",
6969
"mime": "^4.0.4",
7070
"node-emoji": "^2.1.3",
71-
"parse-duration": "^1.1.0",
71+
"parse-duration": "^2.1.3",
7272
"preact-render-to-string": "^6.3.1",
7373
"prom-client": "^15.1.0",
7474
"quickjs-emscripten": "^0.31.0",
@@ -105,7 +105,7 @@
105105
"@types/node": "^22",
106106
"@types/xml2js": "^0.4.11",
107107
"@uiw/react-codemirror": "^4.12.3",
108-
"babel-cli": "^6.26.0",
108+
"@babel/core": "^7.26.9",
109109
"babel-jest": "^29.7.0",
110110
"busboy": "^1.6.0",
111111
"chai": "^4",
@@ -117,13 +117,13 @@
117117
"jest": "^29.7.0",
118118
"mocha": "^10.8.2",
119119
"nyc": "^17.1.0",
120-
"preact": "^10.24.3",
120+
"preact": "^10.26.2",
121121
"rimraf": "6.0.1",
122122
"sass": "^1.81.0",
123123
"ts-node": "10.9.2",
124124
"typescript": "^5.7.2",
125125
"typescript-eslint": "^8.16.0",
126-
"vite": "^5.4.11"
126+
"vite": "^5.4.12"
127127
},
128128
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
129129
}

src/Connections/GenericHook.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,11 @@ export class GenericHookConnection extends BaseConnection implements IConnection
228228
}
229229
const hookId = randomUUID();
230230
const validState = GenericHookConnection.validateState(data);
231+
const expiryTime = await config.generic.maxExpiryTimeMs;
231232
if (validState.expirationDate) {
232233
const durationRemaining = new Date(validState.expirationDate).getTime() - Date.now();
233-
if (config.generic.maxExpiryTimeMs) {
234-
if (durationRemaining > config.generic.maxExpiryTimeMs) {
234+
if (expiryTime) {
235+
if (durationRemaining > expiryTime) {
235236
throw new ApiError('Expiration date cannot exceed the configured max expiry time', ErrCode.BadValue);
236237
}
237238
}

src/Connections/SetupConnection.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import { IConnection, IConnectionState, ProvisionConnectionOpts } from "./IConne
1414
import { ApiError, Logger } from "matrix-appservice-bridge";
1515
import { Intent } from "matrix-bot-sdk";
1616
import YAML from 'yaml';
17-
import parseDuration from 'parse-duration';
1817
import { HoundConnection } from "./HoundConnection";
1918
const md = new markdown();
2019
const log = new Logger("SetupConnection");
20+
const parseDurationImport = import('parse-duration');
2121

2222
const OUTBOUND_DOCS_LINK = "https://matrix-org.github.io/matrix-hookshot/latest/setup/webhooks.html";
2323

@@ -218,9 +218,9 @@ export class SetupConnection extends CommandConnection {
218218

219219
let expirationDate: string|undefined = undefined;
220220
if (liveDuration) {
221-
const expirationDuration = parseDuration(liveDuration);
221+
const expirationDuration = await (await parseDurationImport).default(liveDuration);
222222
if (!expirationDuration) {
223-
throw new CommandError("Bad webhook duration", "A webhook name must be between 3-64 characters.");
223+
throw new CommandError("Bad webhook duration", "Duration could not be parsed");
224224
}
225225
expirationDate = new Date(expirationDuration + Date.now()).toISOString();
226226
}

src/Widgets/BridgeWidgetApi.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class BridgeWidgetApi extends ProvisioningApi {
113113
if (req.params.service === 'github') {
114114
res.send(this.config.github?.publicConfig(this.github));
115115
} else {
116-
res.send(this.config.getPublicConfigForService(req.params.service));
116+
res.send(await this.config.getPublicConfigForService(req.params.service));
117117
}
118118
}
119119

src/config/Config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -686,14 +686,14 @@ export class BridgeConfig {
686686
return services;
687687
}
688688

689-
public getPublicConfigForService(serviceName: string): Record<string, unknown>|GenericHookServiceConfig {
689+
public async getPublicConfigForService(serviceName: string): Promise<Record<string, unknown>|GenericHookServiceConfig> {
690690
let config: undefined|Record<string, unknown>|GenericHookServiceConfig;
691691
switch (serviceName) {
692692
case "feeds":
693693
config = this.feeds?.publicConfig;
694694
break;
695695
case "generic":
696-
config = this.generic?.publicConfig;
696+
config = await this.generic?.publicConfig;
697697
break;
698698
case "github":
699699
config = this.github?.publicConfig();

src/config/sections/generichooks.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { GenericHookServiceConfig } from "../../Connections";
22
import { ConfigError } from "../../errors";
33
import { hideKey } from "../Decorators";
4-
import parseDuration from "parse-duration";
4+
const parseDurationImport = import("parse-duration");
55

66
function makePrefixedUrl(urlString: string): URL {
77
return new URL(urlString.endsWith("/") ? urlString : urlString + "/");
@@ -35,7 +35,7 @@ export class BridgeConfigGenericWebhooks {
3535
public readonly enableHttpGet: boolean;
3636

3737
@hideKey()
38-
public readonly maxExpiryTimeMs?: number;
38+
public readonly maxExpiryTimeMs?: Promise<number|undefined>;
3939
public readonly sendExpiryNotice: boolean;
4040
public readonly requireExpiryTime: boolean;
4141
// Public facing value for config generator
@@ -56,19 +56,19 @@ export class BridgeConfigGenericWebhooks {
5656
this.userIdPrefix = yaml.userIdPrefix;
5757
this.allowJsTransformationFunctions = yaml.allowJsTransformationFunctions;
5858
this.waitForComplete = yaml.waitForComplete;
59-
this.maxExpiryTimeMs = yaml.maxExpiryTime ? parseDuration(yaml.maxExpiryTime) : undefined;
6059
this.maxExpiryTime = yaml.maxExpiryTime;
60+
this.maxExpiryTimeMs = yaml.maxExpiryTime ? parseDurationImport.then(v => v.default(yaml.maxExpiryTime!) ?? undefined) : undefined;
6161
}
6262

6363
@hideKey()
64-
public get publicConfig(): GenericHookServiceConfig {
65-
return {
64+
public get publicConfig(): Promise<GenericHookServiceConfig> {
65+
return (async () => ({
6666
userIdPrefix: this.userIdPrefix,
6767
allowJsTransformationFunctions: this.allowJsTransformationFunctions,
6868
waitForComplete: this.waitForComplete,
69-
maxExpiryTime: this.maxExpiryTimeMs,
69+
maxExpiryTime: await this.maxExpiryTimeMs,
7070
requireExpiryTime: this.requireExpiryTime,
71-
}
71+
}))();
7272
}
7373

7474
}

tests/connections/GitlabRepoTest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ describe("GitLabRepoConnection", () => {
200200
intent.expectNoEvent();
201201
});
202202

203-
it.only("will filter out issues matching excludingLabels.", async () => {
203+
it("will filter out issues matching excludingLabels.", async () => {
204204
const { connection, intent } = createConnection({
205205
excludingLabels: ["exclude-me"]
206206
});

0 commit comments

Comments
 (0)