From ce33ee01cd3806201b676c318e9aa930032921b2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 18 Dec 2017 11:53:04 +0100 Subject: Use RsaSignature2017 --- server/helpers/activitypub.ts | 4 ++-- server/helpers/custom-jsonld-signature.ts | 6 +++--- server/helpers/custom-validators/activitypub/signature.ts | 2 +- server/helpers/peertube-crypto.ts | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) (limited to 'server/helpers') 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 (data: T) { 'https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1', { + 'RsaSignature2017': 'https://w3id.org/security#RsaSignature2017', 'Hashtag': 'as:Hashtag', 'uuid': 'http://schema.org/identifier', 'category': 'http://schema.org/category', @@ -17,8 +18,7 @@ function activityPubContextify (data: T) { 'nsfw': 'as:sensitive', 'language': 'http://schema.org/inLanguage', 'views': 'http://schema.org/Number', - 'size': 'http://schema.org/Number', - 'VideoChannel': 'https://peertu.be/ns/VideoChannel' + 'size': 'http://schema.org/Number' } ] }) 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 @@ import * as AsyncLRU from 'async-lru' -import * as jsonld from 'jsonld' +import * as jsonld from 'jsonld/' import * as jsig from 'jsonld-signatures' -jsig.use('jsonld', jsonld) - const nodeDocumentLoader = jsonld.documentLoaders.node() const lru = new AsyncLRU({ @@ -17,4 +15,6 @@ jsonld.documentLoader = (url, cb) => { lru.get(url, cb) } +jsig.use('jsonld', jsonld) + export { 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' import { isActivityPubUrlValid } from './misc' function isSignatureTypeValid (signatureType: string) { - return exists(signatureType) && signatureType === 'GraphSignature2012' + return exists(signatureType) && signatureType === 'RsaSignature2017' } function 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) { function signObject (byActor: ActorModel, data: any) { const options = { privateKeyPem: byActor.privateKey, - creator: byActor.url + creator: byActor.url, + algorithm: 'RsaSignature2017' } return jsig.promises.sign(data, options) -- cgit v1.2.3