···
async signPlcOperation(token) {
const getDidCredentials =
await this.newAgent.com.atproto.identity.getRecommendedDidCredentials();
+
const rotationKeys = getDidCredentials.data.rotationKeys;
throw new Error('No rotation key provided from the new PDS');
+
const oldDidDoc = await docResolver.resolve(this.oldAgent.did);
+
// Format the service(s) in the user's DidDocument into the operation syntax
+
for(const service of oldDidDoc.service) {
+
const idComponents = service.id.split('#');
+
oldServices[idComponents[idComponents.length - 1]] = {
+
endpoint: service.serviceEndpoint
+
// Combine old & new suggested services
+
...oldServices, // Existing services in the user's DidDocument
+
...getDidCredentials.data.services // Service(s) suggested by the new PDS
+
// Format the verification method(s) in the user's DidDocument into the operation syntax
+
let oldVerificationMethods = {};
+
for(const verificationMethod of oldDidDoc.verificationMethod) {
+
const idComponents = verificationMethod.id.split('#');
+
oldVerificationMethods[idComponents[idComponents.length - 1]] = `did:key:${verificationMethod.publicKeyMultibase}` // PLC Operation verification methods are did:keys
+
// Combine old & new suggested verification methods
+
const verificationMethods = {
+
...oldVerificationMethods, // Existing verification methods in the user's DidDocument
+
...getDidCredentials.data.verificationMethods // Verification method(s) suggested by the new PDS
+
...getDidCredentials.data.alsoKnownAs, // Suggested alsoKnownAs goes first (the first entry is the user's primary handle)
+
...oldDidDoc.alsoKnownAs.slice(1) // Pre-existing alsoKnownAs, minus the old primary handle
const plcOp = await this.oldAgent.com.atproto.identity.signPlcOperation({
+
rotationKeys: rotationKeys, // Replace rotation keys
+
alsoKnownAs: alsoKnownAs, // Merged alsoKnownAs
+
services: services, // Merged services
+
verificationMethods: verificationMethods, // Merged verification methods
await this.newAgent.com.atproto.identity.submitPlcOperation({