diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-14 17:38:41 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-19 10:53:16 +0100 |
commit | 50d6de9c286abcb34ff4234d56d9cbb803db7665 (patch) | |
tree | f1732b27edcd05c7877a8358b8312f1e38c287ed /server/helpers/peertube-crypto.ts | |
parent | fadf619ad61a016c1c7fc53de5a8f398a4f77519 (diff) | |
download | PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.gz PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.zst PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.zip |
Begin moving video channel to actor
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) |