diff --git a/packages/pds/src/api/com/atproto/identity/submitPlcOperation.ts b/packages/pds/src/api/com/atproto/identity/submitPlcOperation.ts index 66db47fe482..13ba7bc07da 100644 --- a/packages/pds/src/api/com/atproto/identity/submitPlcOperation.ts +++ b/packages/pds/src/api/com/atproto/identity/submitPlcOperation.ts @@ -3,6 +3,7 @@ import AppContext from '../../../../context' import * as plc from '@did-plc/lib' import { check } from '@atproto/common' import { InvalidRequestError } from '@atproto/xrpc-server' +import { httpLogger as log } from '../../../../logger' export default function (server: Server, ctx: AppContext) { server.com.atproto.identity.submitPlcOperation({ @@ -15,7 +16,9 @@ export default function (server: Server, ctx: AppContext) { throw new InvalidRequestError('Invalid operation') } - if (!op.rotationKeys.includes(ctx.plcRotationKey.did())) { + const rotationKey = + ctx.cfg.entryway?.plcRotationKey ?? ctx.plcRotationKey.did() + if (!op.rotationKeys.includes(rotationKey)) { throw new InvalidRequestError( "Rotation keys do not include server's rotation key", ) @@ -43,6 +46,15 @@ export default function (server: Server, ctx: AppContext) { } await ctx.plcClient.sendOperation(requester, op) + await ctx.sequencer.sequenceIdentityEvt(requester) + try { + await ctx.idResolver.did.resolve(requester, true) + } catch (err) { + log.error( + { err, did: requester }, + 'failed to refresh did after plc update', + ) + } }, }) } diff --git a/packages/pds/tests/plc-operations.test.ts b/packages/pds/tests/plc-operations.test.ts index 9c4ed9002cb..9c90b3482ff 100644 --- a/packages/pds/tests/plc-operations.test.ts +++ b/packages/pds/tests/plc-operations.test.ts @@ -223,4 +223,16 @@ describe('plc operations', () => { const didData = await ctx.plcClient.getDocumentData(alice) expect(didData.rotationKeys).toEqual([sampleKey, ctx.plcRotationKey.did()]) }) + + it('emits an identity event after a valid operation', async () => { + const lastEvt = await ctx.sequencer.db.db + .selectFrom('repo_seq') + .selectAll() + .orderBy('repo_seq.seq', 'desc') + .limit(1) + .executeTakeFirst() + assert(lastEvt) + expect(lastEvt.did).toBe(alice) + expect(lastEvt.eventType).toBe('identity') + }) })