-import { buildSignedActivity, ContextType } from '../../../../helpers/activitypub'
-import { getServerActor } from '../../../../helpers/utils'
+import { buildSignedActivity } from '../../../../helpers/activitypub'
import { ActorModel } from '../../../../models/activitypub/actor'
-import { sha256 } from '../../../../helpers/core-utils'
-import { HTTP_SIGNATURE } from '../../../../initializers/constants'
-import { MActor } from '../../../../typings/models'
+import { ACTIVITY_PUB, HTTP_SIGNATURE } from '../../../../initializers/constants'
+import { MActor } from '../../../../types/models'
+import { getServerActor } from '@server/models/application/application'
+import { buildDigest } from '@server/helpers/peertube-crypto'
+import { ContextType } from '@shared/models/activitypub/context'
type Payload = { body: any, contextType?: ContextType, signatureActorId?: number }
function buildGlobalHeaders (body: any) {
return {
- Digest: buildDigest(body)
+ 'Digest': buildDigest(body),
+ 'Content-Type': 'application/activity+json',
+ 'Accept': ACTIVITY_PUB.ACCEPT_HEADER
}
}
-function buildDigest (body: any) {
- const rawBody = typeof body === 'string' ? body : JSON.stringify(body)
-
- return 'SHA-256=' + sha256(rawBody, 'base64')
-}
-
export {
- buildDigest,
buildGlobalHeaders,
computeBody,
buildSignedRequestOptions