Client side atproto account migrator in your web browser, along with services for backups and adversarial migrations. pdsmoover.com
pds atproto migrations moo cow

auto cont if repo exists

authored by baileytownsend.dev and committed by tangled.org ab778ec0 86650db3

+20 -25
+19 -24
packages/moover/lib/pdsmoover.js
··· 81 safeStatusUpdate(statusUpdateHandler, 'Resolving old PDS') 82 let { usersDid: didFromLookUp, pds: oldPds } = await handleAndPDSResolver(oldHandle) 83 usersDid = didFromLookUp 84 - // usersDid = await handleResolver.resolve(oldHandle) 85 - // const didDoc = await docResolver.resolve(usersDid) 86 - // safeStatusUpdate( 87 - // statusUpdateHandler, 88 - // 'Resolving did document and finding your current PDS URL', 89 - // ) 90 - 91 - // let oldPds 92 - // try { 93 - // oldPds = didDoc.service.filter(s => s.type === 'AtprotoPersonalDataServer')[0] 94 - // .serviceEndpoint 95 - // } catch (error) { 96 - // console.error(error) 97 - // throw new Error('Could not find a PDS in the DID document.') 98 - // } 99 100 oldAgent = new AtpAgent({ 101 service: oldPds, ··· 143 if (verificationCode) { 144 createAccountRequest.verificationCode = verificationCode 145 } 146 - const createNewAccount = await newAgent.com.atproto.server.createAccount( 147 - createAccountRequest, 148 - { 149 - headers: { authorization: `Bearer ${serviceJwt}` }, 150 - encoding: 'application/json', 151 - }, 152 - ) 153 154 - if (createNewAccount.data.did !== usersDid.toString()) { 155 - throw new Error('Did not create the new account with the same did as the old account') 156 } 157 } 158 safeStatusUpdate(statusUpdateHandler, 'Logging in with the new account')
··· 81 safeStatusUpdate(statusUpdateHandler, 'Resolving old PDS') 82 let { usersDid: didFromLookUp, pds: oldPds } = await handleAndPDSResolver(oldHandle) 83 usersDid = didFromLookUp 84 85 oldAgent = new AtpAgent({ 86 service: oldPds, ··· 128 if (verificationCode) { 129 createAccountRequest.verificationCode = verificationCode 130 } 131 + try { 132 + const createNewAccount = await newAgent.com.atproto.server.createAccount( 133 + createAccountRequest, 134 + { 135 + headers: { authorization: `Bearer ${serviceJwt}` }, 136 + encoding: 'application/json', 137 + }, 138 + ) 139 140 + if (createNewAccount.data.did !== usersDid.toString()) { 141 + throw new Error('Did not create the new account with the same did as the old account') 142 + } 143 + } catch (error) { 144 + // Ideally should catch if the repo already exists, and if so silently log it and move along to the next step 145 + if (error?.error === 'AlreadyExists') { 146 + console.log('Repo already exists, logging in') 147 + } else { 148 + // Catches any other error and stops the migration process 149 + throw error 150 + } 151 } 152 } 153 safeStatusUpdate(statusUpdateHandler, 'Logging in with the new account')
+1 -1
packages/moover/package.json
··· 1 { 2 "name": "@pds-moover/moover", 3 - "version": "1.0.5", 4 "description": "Utilities for ATProto PDS migrations and recovery", 5 "repository": { 6 "type": "git",
··· 1 { 2 "name": "@pds-moover/moover", 3 + "version": "1.0.6", 4 "description": "Utilities for ATProto PDS migrations and recovery", 5 "repository": { 6 "type": "git",