1
0
forked from mirror/misskey

signatureAlgorithm

This commit is contained in:
tamaina 2024-02-27 01:41:34 +00:00
parent 172546f3ef
commit 1d780ac010
3 changed files with 9 additions and 8 deletions

View File

@ -501,7 +501,7 @@ export class ApRendererService {
discoverable: user.isExplorable, discoverable: user.isExplorable,
publicKey: this.renderKey(user, keypair.publicKey, '#main-key'), publicKey: this.renderKey(user, keypair.publicKey, '#main-key'),
additionalPublicKeys: [ additionalPublicKeys: [
...(keypair.ed25519PublicKey ? [this.renderKey(user, keypair.ed25519PublicKey, '#ed25519-key', { type: keypair.ed25519SignatureAlgorithm!, signatureValue: keypair.ed25519PublicKeySignature! })] : []), ...(keypair.ed25519PublicKey ? [this.renderKey(user, keypair.ed25519PublicKey, '#ed25519-key', { signatureAlgorithm: keypair.ed25519SignatureAlgorithm!, signatureValue: keypair.ed25519PublicKeySignature! })] : []),
], ],
isCat: user.isCat, isCat: user.isCat,
attachment: attachment.length ? attachment : undefined, attachment: attachment.length ? attachment : undefined,
@ -649,6 +649,7 @@ export class ApRendererService {
'_misskey_votes': 'misskey:_misskey_votes', '_misskey_votes': 'misskey:_misskey_votes',
'_misskey_summary': 'misskey:_misskey_summary', '_misskey_summary': 'misskey:_misskey_summary',
'isCat': 'misskey:isCat', 'isCat': 'misskey:isCat',
additionalPublicKeys: 'misskey:additionalPublicKeys',
// vcard // vcard
vcard: 'http://www.w3.org/2006/vcard/ns#', vcard: 'http://www.w3.org/2006/vcard/ns#',
}, },

View File

@ -216,8 +216,8 @@ export class ApPersonService implements OnModuleInit {
if (!key.signature) { if (!key.signature) {
throw new Error('invalid Actor: additionalPublicKeys.signature is not set'); throw new Error('invalid Actor: additionalPublicKeys.signature is not set');
} }
if (typeof key.signature.type !== 'string') { if (typeof key.signature.signatureAlgorithm !== 'string') {
throw new Error('invalid Actor: additionalPublicKeys.signature.type is not a string'); throw new Error('invalid Actor: additionalPublicKeys.signature.signatureAlgorithm is not a string');
} }
if (typeof key.signature.signatureValue !== 'string') { if (typeof key.signature.signatureValue !== 'string') {
throw new Error('invalid Actor: additionalPublicKeys.signature.signatureValue is not a string'); throw new Error('invalid Actor: additionalPublicKeys.signature.signatureValue is not a string');
@ -397,8 +397,8 @@ export class ApPersonService implements OnModuleInit {
if (person.additionalPublicKeys) { if (person.additionalPublicKeys) {
for (const key of person.additionalPublicKeys) { for (const key of person.additionalPublicKeys) {
if ( if (
key.signature && key.signature.type && key.signature.signatureValue && key.signature && key.signature.signatureAlgorithm && key.signature.signatureValue &&
verify(key.signature.type, Buffer.from(key.publicKeyPem), person.publicKey.publicKeyPem, Buffer.from(key.signature.signatureValue, 'base64')) verify(key.signature.signatureAlgorithm, Buffer.from(key.publicKeyPem), person.publicKey.publicKeyPem, Buffer.from(key.signature.signatureValue, 'base64'))
) { ) {
await transactionalEntityManager.save(new MiUserPublickey({ await transactionalEntityManager.save(new MiUserPublickey({
keyId: key.id, keyId: key.id,
@ -564,8 +564,8 @@ export class ApPersonService implements OnModuleInit {
if (person.additionalPublicKeys) { if (person.additionalPublicKeys) {
for (const key of person.additionalPublicKeys) { for (const key of person.additionalPublicKeys) {
if ( if (
key.signature && key.signature.type && key.signature.signatureValue && key.signature && key.signature.signatureAlgorithm && key.signature.signatureValue &&
verify(key.signature.type, Buffer.from(key.publicKeyPem), person.publicKey.publicKeyPem, Buffer.from(key.signature.signatureValue, 'base64')) verify(key.signature.signatureAlgorithm, Buffer.from(key.publicKeyPem), person.publicKey.publicKeyPem, Buffer.from(key.signature.signatureValue, 'base64'))
) { ) {
await this.userPublickeysRepository.update({ keyId: key.id }, { await this.userPublickeysRepository.update({ keyId: key.id }, {
userId: exist.id, userId: exist.id,

View File

@ -241,7 +241,7 @@ export interface IKey extends IObject {
* Signature of publicKeyPem, signed by root privateKey (for additionalPublicKey) * Signature of publicKeyPem, signed by root privateKey (for additionalPublicKey)
*/ */
signature?: { signature?: {
type: string; signatureAlgorithm: string;
signatureValue: string signatureValue: string
}; };
} }