Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
les
gancio
Commits
c81114b2
Commit
c81114b2
authored
Sep 26, 2019
by
les
Browse files
[fedi] minor
parent
7c31d6c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/federation/follows.js
View file @
c81114b2
...
...
@@ -29,7 +29,7 @@ module.exports = {
'
actor
'
:
`
${
config
.
baseurl
}
/federation/u/
${
user
.
username
}
`
,
'
object
'
:
body
}
Helpers
.
signAndSend
(
message
,
user
,
body
.
actor
)
Helpers
.
signAndSend
(
message
,
user
,
req
.
fedi_user
.
inbox
)
res
.
sendStatus
(
200
)
},
...
...
server/federation/helpers.js
View file @
c81114b2
...
...
@@ -24,24 +24,24 @@ const Helpers = {
next
()
},
async
signAndSend
(
message
,
user
,
to
)
{
async
signAndSend
(
message
,
user
,
inbox
)
{
// get the URI of the actor object and append 'inbox' to it
const
to
Url
=
url
.
parse
(
to
)
const
inbox
Url
=
url
.
parse
(
inbox
)
// const toPath = toOrigin.path + '/inbox'
// get the private key
const
privkey
=
user
.
rsa
.
privateKey
const
signer
=
crypto
.
createSign
(
'
sha256
'
)
const
d
=
new
Date
()
const
stringToSign
=
`(request-target): post
${
to
Url
.
path
}
\nhost:
${
to
Url
.
hostname
}
\ndate:
${
d
.
toUTCString
()}
`
debug
(
'
Sign and send
'
,
user
.
username
,
to
)
const
stringToSign
=
`(request-target): post
${
inbox
Url
.
path
}
\nhost:
${
inbox
Url
.
hostname
}
\ndate:
${
d
.
toUTCString
()}
`
debug
(
'
Sign and send
'
,
user
.
username
,
inbox
)
signer
.
update
(
stringToSign
)
signer
.
end
()
const
signature
=
signer
.
sign
(
privkey
)
const
signature_b64
=
signature
.
toString
(
'
base64
'
)
const
header
=
`keyId="
${
config
.
baseurl
}
/federation/u/
${
user
.
username
}
",headers="(request-target) host date",signature="
${
signature_b64
}
"`
const
ret
=
await
fetch
(
to
,
{
const
ret
=
await
fetch
(
inbox
,
{
headers
:
{
'
Host
'
:
to
Url
.
hostname
,
'
Host
'
:
inbox
Url
.
hostname
,
'
Date
'
:
d
.
toUTCString
(),
'
Signature
'
:
header
,
'
Content-Type
'
:
'
application/activity+json; charset=utf-8
'
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment