summaryrefslogtreecommitdiff
path: root/packages/backend/src/queue
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-06-06 22:03:53 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-06-09 11:03:51 -0400
commit424e163c6f305830fe2b8aeb6c9fecc2bf93c61a (patch)
treeca2fbae5320499f90d12f16215a2033780c7f85a /packages/backend/src/queue
parentoutput log messages with correct level (diff)
downloadsharkey-424e163c6f305830fe2b8aeb6c9fecc2bf93c61a.tar.gz
sharkey-424e163c6f305830fe2b8aeb6c9fecc2bf93c61a.tar.bz2
sharkey-424e163c6f305830fe2b8aeb6c9fecc2bf93c61a.zip
fix type errors with JsonLdService and remove unused factory pattern
Diffstat (limited to 'packages/backend/src/queue')
-rw-r--r--packages/backend/src/queue/processors/InboxProcessorService.ts15
1 files changed, 6 insertions, 9 deletions
diff --git a/packages/backend/src/queue/processors/InboxProcessorService.ts b/packages/backend/src/queue/processors/InboxProcessorService.ts
index 612b16dfbf..5f82d558b3 100644
--- a/packages/backend/src/queue/processors/InboxProcessorService.ts
+++ b/packages/backend/src/queue/processors/InboxProcessorService.ts
@@ -21,7 +21,7 @@ import { ApDbResolverService } from '@/core/activitypub/ApDbResolverService.js';
import { StatusError } from '@/misc/status-error.js';
import { UtilityService } from '@/core/UtilityService.js';
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
-import { JsonLdService } from '@/core/activitypub/JsonLdService.js';
+import { isSigned, JsonLdService } from '@/core/activitypub/JsonLdService.js';
import { ApInboxService } from '@/core/activitypub/ApInboxService.js';
import { bindThis } from '@/decorators.js';
import { IdentifiableError } from '@/misc/identifiable-error.js';
@@ -179,8 +179,8 @@ export class InboxProcessorService implements OnApplicationShutdown {
// また、signatureのsignerは、activity.actorと一致する必要がある
if (!httpSignatureValidated || authUser.user.uri !== actorId) {
// 一致しなくても、でもLD-Signatureがありそうならそっちも見る
- const ldSignature = activity.signature;
- if (ldSignature) {
+ if (isSigned(activity)) {
+ const ldSignature = activity.signature;
if (ldSignature.type !== 'RsaSignature2017') {
throw new Bull.UnrecoverableError(`skip: unsupported LD-signature type ${ldSignature.type}`);
}
@@ -202,24 +202,21 @@ export class InboxProcessorService implements OnApplicationShutdown {
throw new Bull.UnrecoverableError('skip: LD-SignatureのユーザーはpublicKeyを持っていませんでした');
}
- const jsonLd = this.jsonLdService.use();
-
// LD-Signature検証
- const verified = await jsonLd.verifyRsaSignature2017(activity, authUser.key.keyPem).catch(() => false);
+ const verified = await this.jsonLdService.verifyRsaSignature2017(activity, authUser.key.keyPem).catch(() => false);
if (!verified) {
throw new Bull.UnrecoverableError('skip: LD-Signatureの検証に失敗しました');
}
// アクティビティを正規化
- delete activity.signature;
+ const copy = { ...activity, signature: undefined };
try {
- activity = await jsonLd.compact(activity) as IActivity;
+ activity = await this.jsonLdService.compact(copy) as IActivity;
} catch (e) {
throw new Bull.UnrecoverableError(`skip: failed to compact activity: ${e}`);
}
// TODO: 元のアクティビティと非互換な形に正規化される場合は転送をスキップする
// https://github.com/mastodon/mastodon/blob/664b0ca/app/services/activitypub/process_collection_service.rb#L24-L29
- activity.signature = ldSignature;
// もう一度actorチェック
if (authUser.user.uri !== actorId) {