Skip to content

Commit 0b7b4a3

Browse files
authored
Merge pull request from GHSA-f7g9-xhcq-5ww6
1 parent ab47261 commit 0b7b4a3

File tree

4 files changed

+83
-54
lines changed

4 files changed

+83
-54
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"jsdom": "20.0.3",
9191
"json5": "2.2.3",
9292
"json5-loader": "4.0.1",
93-
"jsonld": "5.2.0",
93+
"jsonld": "8.3.2",
9494
"katex": "0.16.10",
9595
"koa": "2.15.2",
9696
"koa-bodyparser": "4.4.1",

pnpm-lock.yaml

+69-52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/queue/processors/inbox.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type ApContext = {
3737

3838
export const tryProcessInbox = async (data: InboxJobData, ctx?: ApContext): Promise<string> => {
3939
const signature = data.signature;
40-
const activity = data.activity;
40+
let activity = data.activity;
4141

4242
const resolver = ctx?.resolver || new Resolver();
4343

@@ -121,6 +121,11 @@ export const tryProcessInbox = async (data: InboxJobData, ctx?: ApContext): Prom
121121
if (await isBlockedHost(ldHost)) {
122122
return `skip: Blocked instance: ${ldHost}`;
123123
}
124+
125+
const activity2 = JSON.parse(JSON.stringify(activity));
126+
delete activity2.signature;
127+
const compacted = await ldSignature.compact(activity2);
128+
activity = compacted as any;
124129
} else {
125130
return `skip: http-signature verification failed and ${config.ignoreApForwarded ? 'ignoreApForwarded' : 'no LD-Signature'}. keyId=${signature.keyId}`;
126131
}

src/remote/activitypub/misc/ld-signature.ts

+7
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ export class LdSignature {
103103
});
104104
}
105105

106+
public async compact(data: any) {
107+
const customLoader = this.getLoader();
108+
return await jsonld.compact(data, data['@context'], {
109+
documentLoader: customLoader
110+
});
111+
}
112+
106113
private getLoader() {
107114
return async (url: string): Promise<any> => {
108115
if (!url.match('^https?\:\/\/')) throw `Invalid URL ${url}`;

0 commit comments

Comments
 (0)