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 81 safeStatusUpdate(statusUpdateHandler, 'Resolving old PDS') 82 82 let { usersDid: didFromLookUp, pds: oldPds } = await handleAndPDSResolver(oldHandle) 83 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 84 100 85 oldAgent = new AtpAgent({ 101 86 service: oldPds, ··· 143 128 if (verificationCode) { 144 129 createAccountRequest.verificationCode = verificationCode 145 130 } 146 - const createNewAccount = await newAgent.com.atproto.server.createAccount( 147 - createAccountRequest, 148 - { 149 - headers: { authorization: `Bearer ${serviceJwt}` }, 150 - encoding: 'application/json', 151 - }, 152 - ) 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 + ) 153 139 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') 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 + } 156 151 } 157 152 } 158 153 safeStatusUpdate(statusUpdateHandler, 'Logging in with the new account')
+1 -1
packages/moover/package.json
··· 1 1 { 2 2 "name": "@pds-moover/moover", 3 - "version": "1.0.5", 3 + "version": "1.0.6", 4 4 "description": "Utilities for ATProto PDS migrations and recovery", 5 5 "repository": { 6 6 "type": "git",