aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/peertube-crypto.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/peertube-crypto.ts')
-rw-r--r--server/helpers/peertube-crypto.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts
index c4c735cb8..a0c9112b9 100644
--- a/server/helpers/peertube-crypto.ts
+++ b/server/helpers/peertube-crypto.ts
@@ -1,5 +1,5 @@
1import { BCRYPT_SALT_SIZE, PRIVATE_RSA_KEY_SIZE } from '../initializers' 1import { BCRYPT_SALT_SIZE, PRIVATE_RSA_KEY_SIZE } from '../initializers'
2import { AccountModel } from '../models/account/account' 2import { ActorModel } from '../models/activitypub/actor'
3import { bcryptComparePromise, bcryptGenSaltPromise, bcryptHashPromise, createPrivateKey, getPublicKey } from './core-utils' 3import { bcryptComparePromise, bcryptGenSaltPromise, bcryptHashPromise, createPrivateKey, getPublicKey } from './core-utils'
4import { jsig } from './custom-jsonld-signature' 4import { jsig } from './custom-jsonld-signature'
5import { logger } from './logger' 5import { logger } from './logger'
@@ -13,18 +13,18 @@ async function createPrivateAndPublicKeys () {
13 return { privateKey: key, publicKey } 13 return { privateKey: key, publicKey }
14} 14}
15 15
16function isSignatureVerified (fromAccount: AccountModel, signedDocument: object) { 16function isSignatureVerified (fromActor: ActorModel, signedDocument: object) {
17 const publicKeyObject = { 17 const publicKeyObject = {
18 '@context': jsig.SECURITY_CONTEXT_URL, 18 '@context': jsig.SECURITY_CONTEXT_URL,
19 '@id': fromAccount.url, 19 '@id': fromActor.url,
20 '@type': 'CryptographicKey', 20 '@type': 'CryptographicKey',
21 owner: fromAccount.url, 21 owner: fromActor.url,
22 publicKeyPem: fromAccount.publicKey 22 publicKeyPem: fromActor.publicKey
23 } 23 }
24 24
25 const publicKeyOwnerObject = { 25 const publicKeyOwnerObject = {
26 '@context': jsig.SECURITY_CONTEXT_URL, 26 '@context': jsig.SECURITY_CONTEXT_URL,
27 '@id': fromAccount.url, 27 '@id': fromActor.url,
28 publicKey: [ publicKeyObject ] 28 publicKey: [ publicKeyObject ]
29 } 29 }
30 30
@@ -40,10 +40,10 @@ function isSignatureVerified (fromAccount: AccountModel, signedDocument: object)
40 }) 40 })
41} 41}
42 42
43function signObject (byAccount: AccountModel, data: any) { 43function signObject (byActor: ActorModel, data: any) {
44 const options = { 44 const options = {
45 privateKeyPem: byAccount.privateKey, 45 privateKeyPem: byActor.privateKey,
46 creator: byAccount.url 46 creator: byActor.url
47 } 47 }
48 48
49 return jsig.promises.sign(data, options) 49 return jsig.promises.sign(data, options)