PeerTube/server/lib/activitypub/actors/keys.ts

17 lines
500 B
TypeScript
Raw Normal View History

2021-06-03 16:02:29 +02:00
import { createPrivateAndPublicKeys } from '@server/helpers/peertube-crypto'
import { MActor } from '@server/types/models'
// Set account keys, this could be long so process after the account creation and do not block the client
async function generateAndSaveActorKeys <T extends MActor> (actor: T) {
const { publicKey, privateKey } = await createPrivateAndPublicKeys()
actor.publicKey = publicKey
actor.privateKey = privateKey
return actor.save()
}
export {
generateAndSaveActorKeys
}