···62626363 //Copying the handle from bsky website adds some random unicodes on
6464 oldHandle = oldHandle.replace('@', '').trim().replace(/[\u202A\u202C\u200E\u200F\u2066-\u2069]/g, '');
6565- //Resolves the did and finds the did document for the old PDS
6666- safeStatusUpdate(statusUpdateHandler, 'Resolving old PDS');
6767- const usersDid = await handleResolver.resolve(oldHandle);
6868- const didDoc = await docResolver.resolve(usersDid);
6969- safeStatusUpdate(statusUpdateHandler, 'Resolving did document and finding your current PDS URL');
6565+ let oldAgent;
6666+ let usersDid;
6767+ //If it's a bsky handle just go with the entryway and let it sort everything
6868+ if (oldHandle.endsWith('.bsky.social')) {
6969+ oldAgent = new AtpAgent({service: 'https://bsky.social'});
7070+ const publicAgent = new AtpAgent({service: 'https://public.api.bsky.app'});
7171+ const resolveIdentityFromEntryway = await publicAgent.com.atproto.identity.resolveHandle({handle: oldHandle});
7272+ usersDid = resolveIdentityFromEntryway.data.did;
70737171- let oldPds;
7272- try {
7373- oldPds = didDoc.service.filter(s => s.type === 'AtprotoPersonalDataServer')[0].serviceEndpoint;
7474- } catch (error) {
7575- console.error(error);
7676- throw new Error('Could not find a PDS in the DID document.');
7777- }
7474+ } else {
7575+ //Resolves the did and finds the did document for the old PDS
7676+ safeStatusUpdate(statusUpdateHandler, 'Resolving old PDS');
7777+ usersDid = await handleResolver.resolve(oldHandle);
7878+ const didDoc = await docResolver.resolve(usersDid);
7979+ safeStatusUpdate(statusUpdateHandler, 'Resolving did document and finding your current PDS URL');
78807979- const oldAgent = new AtpAgent({
8080- service: oldPds,
8181- });
8181+ let oldPds;
8282+ try {
8383+ oldPds = didDoc.service.filter(s => s.type === 'AtprotoPersonalDataServer')[0].serviceEndpoint;
8484+ } catch (error) {
8585+ console.error(error);
8686+ throw new Error('Could not find a PDS in the DID document.');
8787+ }
8888+8989+ oldAgent = new AtpAgent({
9090+ service: oldPds,
9191+ });
9292+9393+ }
82948395 safeStatusUpdate(statusUpdateHandler, 'Logging you in to the old PDS');
8496 //Login to the old PDS
···214226 if (this.migratePrefs) {
215227 const prefs = await oldAgent.app.bsky.actor.getPreferences();
216228 await newAgent.app.bsky.actor.putPreferences(prefs.data);
217217- this.oldAgent = oldAgent;
218218- this.newAgent = newAgent;
219229 }
230230+231231+ this.oldAgent = oldAgent;
232232+ this.newAgent = newAgent;
220233221234 if (this.migratePlcRecord) {
222235 await oldAgent.com.atproto.identity.requestPlcOperationSignature();