diff options
Diffstat (limited to 'server/helpers/peertube-crypto.ts')
-rw-r--r-- | server/helpers/peertube-crypto.ts | 18 |
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 @@ | |||
1 | import { BCRYPT_SALT_SIZE, PRIVATE_RSA_KEY_SIZE } from '../initializers' | 1 | import { BCRYPT_SALT_SIZE, PRIVATE_RSA_KEY_SIZE } from '../initializers' |
2 | import { AccountModel } from '../models/account/account' | 2 | import { ActorModel } from '../models/activitypub/actor' |
3 | import { bcryptComparePromise, bcryptGenSaltPromise, bcryptHashPromise, createPrivateKey, getPublicKey } from './core-utils' | 3 | import { bcryptComparePromise, bcryptGenSaltPromise, bcryptHashPromise, createPrivateKey, getPublicKey } from './core-utils' |
4 | import { jsig } from './custom-jsonld-signature' | 4 | import { jsig } from './custom-jsonld-signature' |
5 | import { logger } from './logger' | 5 | import { logger } from './logger' |
@@ -13,18 +13,18 @@ async function createPrivateAndPublicKeys () { | |||
13 | return { privateKey: key, publicKey } | 13 | return { privateKey: key, publicKey } |
14 | } | 14 | } |
15 | 15 | ||
16 | function isSignatureVerified (fromAccount: AccountModel, signedDocument: object) { | 16 | function 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 | ||
43 | function signObject (byAccount: AccountModel, data: any) { | 43 | function 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) |