aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/requests/activitypub.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-15 15:26:15 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:25:52 +0200
commit94565d52bb2883e09f16d1363170ac9c0dccb7a1 (patch)
tree3dcd20cd7b5a5cca80bce32b655cdbfaddf7aa59 /shared/utils/requests/activitypub.ts
parent4ee7a4c9ac9280cda930a281c2d5a9a4c409cc14 (diff)
downloadPeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.tar.gz
PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.tar.zst
PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.zip
Shared utils -> extra-utils
Because they need dev dependencies
Diffstat (limited to 'shared/utils/requests/activitypub.ts')
-rw-r--r--shared/utils/requests/activitypub.ts43
1 files changed, 0 insertions, 43 deletions
diff --git a/shared/utils/requests/activitypub.ts b/shared/utils/requests/activitypub.ts
deleted file mode 100644
index 4762a8665..000000000
--- a/shared/utils/requests/activitypub.ts
+++ /dev/null
@@ -1,43 +0,0 @@
1import { doRequest } from '../../../server/helpers/requests'
2import { HTTP_SIGNATURE } from '../../../server/initializers/constants'
3import { buildGlobalHeaders } from '../../../server/lib/job-queue/handlers/utils/activitypub-http-utils'
4import { activityPubContextify } from '../../../server/helpers/activitypub'
5
6function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) {
7 const options = {
8 method: 'POST',
9 uri: url,
10 json: body,
11 httpSignature,
12 headers
13 }
14
15 return doRequest(options)
16}
17
18async function makeFollowRequest (to: { url: string }, by: { url: string, privateKey }) {
19 const follow = {
20 type: 'Follow',
21 id: by.url + '/toto',
22 actor: by.url,
23 object: to.url
24 }
25
26 const body = activityPubContextify(follow)
27
28 const httpSignature = {
29 algorithm: HTTP_SIGNATURE.ALGORITHM,
30 authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME,
31 keyId: by.url,
32 key: by.privateKey,
33 headers: HTTP_SIGNATURE.HEADERS_TO_SIGN
34 }
35 const headers = buildGlobalHeaders(body)
36
37 return makePOSTAPRequest(to.url, body, httpSignature, headers)
38}
39
40export {
41 makePOSTAPRequest,
42 makeFollowRequest
43}