aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-18 11:53:04 +0100
committerChocobozzz <me@florianbigard.com>2017-12-19 10:53:16 +0100
commitce33ee01cd3806201b676c318e9aa930032921b2 (patch)
treea067f57a571f417fc7b70f39af4302cd17183b07 /server/helpers
parent555846c99fa43b237814d32bd55d8124405187d3 (diff)
downloadPeerTube-ce33ee01cd3806201b676c318e9aa930032921b2.tar.gz
PeerTube-ce33ee01cd3806201b676c318e9aa930032921b2.tar.zst
PeerTube-ce33ee01cd3806201b676c318e9aa930032921b2.zip
Use RsaSignature2017
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/activitypub.ts4
-rw-r--r--server/helpers/custom-jsonld-signature.ts6
-rw-r--r--server/helpers/custom-validators/activitypub/signature.ts2
-rw-r--r--server/helpers/peertube-crypto.ts3
4 files changed, 8 insertions, 7 deletions
diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts
index 5850fc19f..b6207c915 100644
--- a/server/helpers/activitypub.ts
+++ b/server/helpers/activitypub.ts
@@ -10,6 +10,7 @@ function activityPubContextify <T> (data: T) {
10 'https://www.w3.org/ns/activitystreams', 10 'https://www.w3.org/ns/activitystreams',
11 'https://w3id.org/security/v1', 11 'https://w3id.org/security/v1',
12 { 12 {
13 'RsaSignature2017': 'https://w3id.org/security#RsaSignature2017',
13 'Hashtag': 'as:Hashtag', 14 'Hashtag': 'as:Hashtag',
14 'uuid': 'http://schema.org/identifier', 15 'uuid': 'http://schema.org/identifier',
15 'category': 'http://schema.org/category', 16 'category': 'http://schema.org/category',
@@ -17,8 +18,7 @@ function activityPubContextify <T> (data: T) {
17 'nsfw': 'as:sensitive', 18 'nsfw': 'as:sensitive',
18 'language': 'http://schema.org/inLanguage', 19 'language': 'http://schema.org/inLanguage',
19 'views': 'http://schema.org/Number', 20 'views': 'http://schema.org/Number',
20 'size': 'http://schema.org/Number', 21 'size': 'http://schema.org/Number'
21 'VideoChannel': 'https://peertu.be/ns/VideoChannel'
22 } 22 }
23 ] 23 ]
24 }) 24 })
diff --git a/server/helpers/custom-jsonld-signature.ts b/server/helpers/custom-jsonld-signature.ts
index afb960618..e4f28018e 100644
--- a/server/helpers/custom-jsonld-signature.ts
+++ b/server/helpers/custom-jsonld-signature.ts
@@ -1,9 +1,7 @@
1import * as AsyncLRU from 'async-lru' 1import * as AsyncLRU from 'async-lru'
2import * as jsonld from 'jsonld' 2import * as jsonld from 'jsonld/'
3import * as jsig from 'jsonld-signatures' 3import * as jsig from 'jsonld-signatures'
4 4
5jsig.use('jsonld', jsonld)
6
7const nodeDocumentLoader = jsonld.documentLoaders.node() 5const nodeDocumentLoader = jsonld.documentLoaders.node()
8 6
9const lru = new AsyncLRU({ 7const lru = new AsyncLRU({
@@ -17,4 +15,6 @@ jsonld.documentLoader = (url, cb) => {
17 lru.get(url, cb) 15 lru.get(url, cb)
18} 16}
19 17
18jsig.use('jsonld', jsonld)
19
20export { jsig } 20export { jsig }
diff --git a/server/helpers/custom-validators/activitypub/signature.ts b/server/helpers/custom-validators/activitypub/signature.ts
index 683ed2b1c..cfb65361e 100644
--- a/server/helpers/custom-validators/activitypub/signature.ts
+++ b/server/helpers/custom-validators/activitypub/signature.ts
@@ -2,7 +2,7 @@ import { exists } from '../misc'
2import { isActivityPubUrlValid } from './misc' 2import { isActivityPubUrlValid } from './misc'
3 3
4function isSignatureTypeValid (signatureType: string) { 4function isSignatureTypeValid (signatureType: string) {
5 return exists(signatureType) && signatureType === 'GraphSignature2012' 5 return exists(signatureType) && signatureType === 'RsaSignature2017'
6} 6}
7 7
8function isSignatureCreatorValid (signatureCreator: string) { 8function isSignatureCreatorValid (signatureCreator: string) {
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts
index a0c9112b9..313c12e26 100644
--- a/server/helpers/peertube-crypto.ts
+++ b/server/helpers/peertube-crypto.ts
@@ -43,7 +43,8 @@ function isSignatureVerified (fromActor: ActorModel, signedDocument: object) {
43function signObject (byActor: ActorModel, data: any) { 43function signObject (byActor: ActorModel, data: any) {
44 const options = { 44 const options = {
45 privateKeyPem: byActor.privateKey, 45 privateKeyPem: byActor.privateKey,
46 creator: byActor.url 46 creator: byActor.url,
47 algorithm: 'RsaSignature2017'
47 } 48 }
48 49
49 return jsig.promises.sign(data, options) 50 return jsig.promises.sign(data, options)