summaryrefslogtreecommitdiff
path: root/src/remote/activitypub/renderer/key.ts
blob: e792f487fdb11a77008db5e9bbfb2f5fc27ef841 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import config from '../../../config';
import { ILocalUser } from '../../../models/entities/user';
import { UserKeypair } from '../../../models/entities/user-keypair';
import { createPublicKey } from 'crypto';

export default (user: ILocalUser, key: UserKeypair, postfix?: string) => ({
	id: `${config.url}/users/${user.id}${postfix || '/publickey'}`,
	type: 'Key',
	owner: `${config.url}/users/${user.id}`,
	publicKeyPem: createPublicKey(key.publicKey).export({
		type: 'spki',
		format: 'pem'
	})
});