Skip to content

Commit

Permalink
fix(backend): Handle array values for Actor.publicKey
Browse files Browse the repository at this point in the history
`publicKey`は複数の値を取りうるとされているので、そのケースへの対応。

cf. https://swicg.github.io/activitypub-http-signature/#how-to-obtain-a-signature-s-public-key

引用元の仕様では複数の値から適するものを選ぶように定められているが、まず
は簡単のためMastodonと同様に先頭の値のみを取る形で対応した。
  • Loading branch information
tesaguri committed Jul 11, 2024
1 parent 121af77 commit a425244
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type Logger from '@/logger.js';
import type { MiNote } from '@/models/Note.js';
import type { IdService } from '@/core/IdService.js';
import type { MfmService } from '@/core/MfmService.js';
import { toArray } from '@/misc/prelude/array.js';
import { toArray, toSingle } from '@/misc/prelude/array.js';
import type { GlobalEventService } from '@/core/GlobalEventService.js';
import type { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
import type { FetchInstanceMetadataService } from '@/core/FetchInstanceMetadataService.js';
Expand Down Expand Up @@ -182,6 +182,8 @@ export class ApPersonService implements OnModuleInit {
}

if (x.publicKey) {
x.publicKey = toSingle(x.publicKey);

if (typeof x.publicKey.id !== 'string') {
throw new Error('invalid Actor: publicKey.id is not a string');
}
Expand Down

0 comments on commit a425244

Please sign in to comment.