parent
25cc9e0bf1
commit
eefca034fc
|
@ -15,7 +15,7 @@ import type { Antenna } from '@/server/api/endpoints/i/import-antennas.js';
|
|||
import type { DbQueue, DeliverQueue, EndedPollNotificationQueue, InboxQueue, ObjectStorageQueue, RelationshipQueue, SystemQueue, WebhookDeliverQueue } from './QueueModule.js';
|
||||
import type { DbJobData, DeliverJobData, RelationshipJobData, ThinUser } from '../queue/types.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { ParsedSignature } from '@misskey-dev/node-http-message-signatures';
|
||||
import { genRFC3230DigestHeader, type ParsedSignature } from '@misskey-dev/node-http-message-signatures';
|
||||
|
||||
@Injectable()
|
||||
export class QueueService {
|
||||
|
@ -81,6 +81,7 @@ export class QueueService {
|
|||
id: user.id,
|
||||
},
|
||||
content: contentBody,
|
||||
digest: await genRFC3230DigestHeader(contentBody, 'SHA-256'),
|
||||
to,
|
||||
isSharedInbox,
|
||||
};
|
||||
|
|
|
@ -28,7 +28,7 @@ type PrivateKey = {
|
|||
keyId: string;
|
||||
};
|
||||
|
||||
export async function createSignedPost(args: { level: string; key: PrivateKey; url: string; body: string; additionalHeaders: Record<string, string> }) {
|
||||
export async function createSignedPost(args: { level: string; key: PrivateKey; url: string; body: string; digest?: string, additionalHeaders: Record<string, string> }) {
|
||||
const u = new URL(args.url);
|
||||
const request: RequestLike = {
|
||||
url: u.href,
|
||||
|
@ -40,9 +40,9 @@ export async function createSignedPost(args: { level: string; key: PrivateKey; u
|
|||
...args.additionalHeaders,
|
||||
},
|
||||
};
|
||||
|
||||
c
|
||||
// TODO: httpMessageSignaturesImplementationLevelによって新規格で通信をするようにする
|
||||
const digestHeader = await genRFC3230DigestHeader(args.body, 'SHA-256');
|
||||
const digestHeader = args.digest ?? await genRFC3230DigestHeader(args.body, 'SHA-256');
|
||||
request.headers['Digest'] = digestHeader;
|
||||
|
||||
const result = await signAsDraftToRequest(request, args.key, ['(request-target)', 'date', 'host', 'digest']);
|
||||
|
@ -105,7 +105,7 @@ export class ApRequestService {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
public async signedPost(user: { id: MiUser['id'] }, url: string, object: unknown, level: string): Promise<void> {
|
||||
public async signedPost(user: { id: MiUser['id'] }, url: string, object: unknown, level: string, digest?: string): Promise<void> {
|
||||
const body = typeof object === 'string' ? object : JSON.stringify(object);
|
||||
const key = await this.getPrivateKey(user.id, level);
|
||||
const req = await createSignedPost({
|
||||
|
@ -116,6 +116,7 @@ export class ApRequestService {
|
|||
additionalHeaders: {
|
||||
'User-Agent': this.config.userAgent,
|
||||
},
|
||||
digest,
|
||||
});
|
||||
|
||||
this.logger.debug('create signed post', {
|
||||
|
|
|
@ -76,7 +76,7 @@ export class DeliverProcessorService {
|
|||
await this.fetchInstanceMetadataService.fetchInstanceMetadata(_server).then(() => {});
|
||||
const server = await this.federatedInstanceService.fetch(host);
|
||||
|
||||
await this.apRequestService.signedPost(job.data.user, job.data.to, job.data.content, server.httpMessageSignaturesImplementationLevel);
|
||||
await this.apRequestService.signedPost(job.data.user, job.data.to, job.data.content, server.httpMessageSignaturesImplementationLevel, job.data.digest);
|
||||
|
||||
// Update stats
|
||||
if (server.isNotResponding) {
|
||||
|
|
|
@ -32,6 +32,8 @@ export type DeliverJobData = {
|
|||
user: ThinUser;
|
||||
/** Activity */
|
||||
content: string;
|
||||
/** Digest header */
|
||||
digest: string;
|
||||
/** inbox URL to deliver */
|
||||
to: string;
|
||||
/** whether it is sharedInbox */
|
||||
|
|
Loading…
Reference in New Issue