Mirror from bluesky-social/pds
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add recovery key to migration script

dholms 2402759c 3810cfb0

+20 -1
+20 -1
ACCOUNT_MIGRATION.md
··· 73 73 74 74 ```ts 75 75 import AtpAgent from '@atproto/api' 76 + import { Secp256k1Keypair } from '@atproto/crypto' 77 + import * as ui8 from 'uint8arrays' 76 78 77 79 const OLD_PDS_URL = 'https://bsky.social' 78 80 const NEW_PDS_URL = 'https://example.com' ··· 158 160 // Migrate Identity 159 161 // ------------------ 160 162 163 + const recoveryKey = await Secp256k1Keypair.create({ exportable: true }) 164 + const privateKeyBytes = await recoveryKey.export() 165 + const privateKey = ui8.toString(privateKeyBytes, 'hex') 166 + 161 167 await oldAgent.com.atproto.identity.requestPlcOperationSignature() 162 168 163 169 const getDidCredentials = 164 170 await newAgent.com.atproto.identity.getRecommendedDidCredentials() 171 + const rotationKeys = getDidCredentials.data.rotationKeys ?? [] 172 + if (!rotationKeys) { 173 + throw new Error('No rotation key provided') 174 + } 175 + const credentials = { 176 + ...getDidCredentials.data, 177 + rotationKeys: [recoveryKey.did(), ...rotationKeys], 178 + } 165 179 166 180 // @NOTE, this token will need to come from the email from the previous step 167 181 const TOKEN = '' 168 182 169 183 const plcOp = await oldAgent.com.atproto.identity.signPlcOperation({ 170 184 token: TOKEN, 171 - ...getDidCredentials.data, 185 + ...credentials, 172 186 }) 173 187 188 + console.log( 189 + `❗ Your private recovery key is: ${privateKey}. Please store this in a secure location! ❗`, 190 + ) 191 + 174 192 await newAgent.com.atproto.identity.submitPlcOperation({ 175 193 operation: plcOp.data.operation, 176 194 }) ··· 181 199 await newAgent.com.atproto.server.activateAccount() 182 200 await oldAgent.com.atproto.server.deactivateAccount({}) 183 201 } 202 + 184 203 ```