Client side atproto account migrator in your web browser, along with services for backups and adversarial migrations.

use entryway for bsky.social handles and sign only bug

+30 -17
+30 -17
src/pdsmoover.js
··· 62 62 63 63 //Copying the handle from bsky website adds some random unicodes on 64 64 oldHandle = oldHandle.replace('@', '').trim().replace(/[\u202A\u202C\u200E\u200F\u2066-\u2069]/g, ''); 65 - //Resolves the did and finds the did document for the old PDS 66 - safeStatusUpdate(statusUpdateHandler, 'Resolving old PDS'); 67 - const usersDid = await handleResolver.resolve(oldHandle); 68 - const didDoc = await docResolver.resolve(usersDid); 69 - safeStatusUpdate(statusUpdateHandler, 'Resolving did document and finding your current PDS URL'); 65 + let oldAgent; 66 + let usersDid; 67 + //If it's a bsky handle just go with the entryway and let it sort everything 68 + if (oldHandle.endsWith('.bsky.social')) { 69 + oldAgent = new AtpAgent({service: 'https://bsky.social'}); 70 + const publicAgent = new AtpAgent({service: 'https://public.api.bsky.app'}); 71 + const resolveIdentityFromEntryway = await publicAgent.com.atproto.identity.resolveHandle({handle: oldHandle}); 72 + usersDid = resolveIdentityFromEntryway.data.did; 70 73 71 - let oldPds; 72 - try { 73 - oldPds = didDoc.service.filter(s => s.type === 'AtprotoPersonalDataServer')[0].serviceEndpoint; 74 - } catch (error) { 75 - console.error(error); 76 - throw new Error('Could not find a PDS in the DID document.'); 77 - } 74 + } else { 75 + //Resolves the did and finds the did document for the old PDS 76 + safeStatusUpdate(statusUpdateHandler, 'Resolving old PDS'); 77 + usersDid = await handleResolver.resolve(oldHandle); 78 + const didDoc = await docResolver.resolve(usersDid); 79 + safeStatusUpdate(statusUpdateHandler, 'Resolving did document and finding your current PDS URL'); 78 80 79 - const oldAgent = new AtpAgent({ 80 - service: oldPds, 81 - }); 81 + let oldPds; 82 + try { 83 + oldPds = didDoc.service.filter(s => s.type === 'AtprotoPersonalDataServer')[0].serviceEndpoint; 84 + } catch (error) { 85 + console.error(error); 86 + throw new Error('Could not find a PDS in the DID document.'); 87 + } 88 + 89 + oldAgent = new AtpAgent({ 90 + service: oldPds, 91 + }); 92 + 93 + } 82 94 83 95 safeStatusUpdate(statusUpdateHandler, 'Logging you in to the old PDS'); 84 96 //Login to the old PDS ··· 214 226 if (this.migratePrefs) { 215 227 const prefs = await oldAgent.app.bsky.actor.getPreferences(); 216 228 await newAgent.app.bsky.actor.putPreferences(prefs.data); 217 - this.oldAgent = oldAgent; 218 - this.newAgent = newAgent; 219 229 } 230 + 231 + this.oldAgent = oldAgent; 232 + this.newAgent = newAgent; 220 233 221 234 if (this.migratePlcRecord) { 222 235 await oldAgent.com.atproto.identity.requestPlcOperationSignature();