Client side atproto account migrator in your web browser, along with services for backups and adversarial migrations.
4.0 kB
69 lines
1/**
2 * Handles normal PDS Migrations between two PDSs that are both up.
3 * On pdsmoover.com this is the logic for the MOOver
4 */
5export class Migrator {
6 /** @type {AtpAgent} */
7 oldAgent: AtpAgent;
8 /** @type {AtpAgent} */
9 newAgent: AtpAgent;
10 /** @type {[string]} */
11 missingBlobs: [string];
12 /** @type {boolean} */
13 createNewAccount: boolean;
14 /** @type {boolean} */
15 migrateRepo: boolean;
16 /** @type {boolean} */
17 migrateBlobs: boolean;
18 /** @type {boolean} */
19 migrateMissingBlobs: boolean;
20 /** @type {boolean} */
21 migratePrefs: boolean;
22 /** @type {boolean} */
23 migratePlcRecord: boolean;
24 /**
25 * This migrator is pretty cut and dry and makes a few assumptions
26 * 1. You are using the same password between each account
27 * 2. If this command fails for something like oauth 2fa code it throws an error and expects the same values when ran again.
28 * 3. You can control which "actions" happen by setting the class variables to false.
29 * 4. Each instance of the class is assumed to be for a single migration
30 * @param {string} oldHandle - The handle you use on your old pds, something like alice.bsky.social
31 * @param {string} password - Your password for your current login. Has to be your real password, no app password. When setting up a new account we reuse it as well for that account
32 * @param {string} newPdsUrl - The new URL for your pds. Like https://coolnewpds.com
33 * @param {string} newEmail - The email you want to use on the new pds (can be the same as the previous one as long as it's not already being used on the new pds)
34 * @param {string} newHandle - The new handle you want, like alice.bsky.social, or if you already have a domain name set as a handle can use it myname.com.
35 * @param {string|null} inviteCode - The invite code you got from the PDS you are migrating to. If null does not include one
36 * @param {function|null} statusUpdateHandler - a function that takes a string used to update the UI. Like (status) => console.log(status)
37 * @param {string|null} twoFactorCode - Optional, but needed if it fails with 2fa required
38 */
39 migrate(oldHandle: string, password: string, newPdsUrl: string, newEmail: string, newHandle: string, inviteCode: string | null, statusUpdateHandler?: Function | null, twoFactorCode?: string | null): Promise<void>;
40 /**
41 * Sign and submits the PLC operation to officially migrate the account
42 * @param {string} token - the PLC token sent in the email. If you're just wanting to run this rerun migrate with all the flags set as false except for migratePlcRecord
43 * @param additionalRotationKeysToAdd {string[]} - additional rotation keys to add in addition to the ones provided by the new PDS.
44 * @returns {Promise<void>}
45 */
46 signPlcOperation(token: string, additionalRotationKeysToAdd?: string[]): Promise<void>;
47 /**
48 * Using this method assumes the Migrator class was constructed new and this was called.
49 * Find the user's previous PDS from the PLC op logs,
50 * logs in and deactivates their old account if it was found still active.
51 *
52 * @param oldHandle {string}
53 * @param oldPassword {string}
54 * @param {function|null} statusUpdateHandler - a function that takes a string used to update the UI.
55 * Like (status) => console.log(status)
56 * @param {string|null} twoFactorCode - Optional, but needed if it fails with 2fa required
57 * @returns {Promise<void>}
58 */
59 deactivateOldAccount(oldHandle: string, oldPassword: string, statusUpdateHandler?: Function | null, twoFactorCode?: string | null): Promise<void>;
60 /**
61 * Signs the logged-in user in this.newAgent for backups with PDS MOOver. This is usually called after migrate and signPlcOperation are successful
62 *
63 * @param {string} didWeb
64 * @returns {Promise<void>}
65 */
66 signUpForBackupsFromMigration(didWeb?: string): Promise<void>;
67}
68import { AtpAgent } from '@atproto/api';
69//# sourceMappingURL=pdsmoover.d.ts.map