mizzkey/packages/backend/src/remote/activitypub/renderer/key.ts
syuilo d071d18dd7
refactor: Use ESM (#8358)
* wip

* wip

* fix

* clean up

* Update tsconfig.json

* Update activitypub.ts

* wip
2022-02-27 11:07:39 +09:00

14 lines
503 B
TypeScript

import config from '@/config/index.js';
import { ILocalUser } from '@/models/entities/user.js';
import { UserKeypair } from '@/models/entities/user-keypair.js';
import { createPublicKey } from 'node: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',
}),
});