import { Secp256k1PrivateKeyExportable } from '@atcute/crypto'; import { Client, type DidString } from '@atproto/lex'; import { PasswordSession } from '@atproto/lex-password-session'; import type { KeyPairInfo } from './plc-ops.js'; import { PlcOps } from './plc-ops.js'; type StatusHandler = ((status: string) => void) | null; /** Rate-limit summary set when a 429 stopped the blob restore (non-fatal). */ export interface BlobRestoreRateLimit { uploaded: number; remaining: number; resetAt?: Date; } declare class Restore { /** * If you want to use a different plc directory create your own instance of the plc ops class and pass it in here */ plcOps: PlcOps; /** * This is the base url for the pds moover instance used to restore the files from a backup. */ pdsMooverInstance: string; /** * To keep it simple, only uses secp256k for the temp verification key that is used to create the new account on the new PDS * and is temporarily assigned to the user's account on PLC */ tempVerificationKeypair: Secp256k1PrivateKeyExportable | null; /** The logged-in session on the new PDS */ session: PasswordSession | null; /** Authenticated client for the new PDS (unauthenticated until recover() logs in) */ newPdsClient: Client | null; /** * The keypair that is used to sign the plc operation */ recoveryRotationKeyPair: KeyPairInfo | null; /** * Set when a 429 stopped the blob restore. Non-fatal: the account is still * activated and the remaining blobs can be imported later from the Missing * Blobs page. */ blobRestoreRateLimit: BlobRestoreRateLimit | null; /** * If this is true we are just restoring the repo and blobs. Ideally for rerunning a restore process after account recovery */ RestoreFromBackup: boolean; /** * If set to true then it will do the account recovery. Writes a temp key to the did doc, * create a new account on the new pds, and then submit a new plc op for the pds to have control (finishes the migration, can always restore the backup later) */ AccountRecovery: boolean; /** * @param pdsMooverInstance - The url of the pds moover instance to restore from. Defaults to https://pdsmoover.com */ constructor(pdsMooverInstance?: string); /** * Recovers an account with the users rotation key and restores the repo from a PDS MOOver backup * This method can fail, and the account was still recovered, it's best to check the PLC logs to see where an account stands before reruns * @param rotationKey - The users private rotation key, can be a multi key or hex key * @param rotationKeyType - The type of the key, secp256k1 or p256. Required if the key is in hex format, defaults to secp256k1 * @param currentHandleOrDid - The users current handle or did, if they don't have a DNS record it will have to be their did for success * @param newPDS - The new PDS url, like https://coolnewpds.com * @param newHandle - Can be the users DNS handle if it is already setup with their did, if not it's bob.mypds.com * @param newPassword - The new password for the new account * @param newEmail - The new email for the new account * @param inviteCode - The invite code for the new PDS if it requires one * @param cidToRestoreTo - The cid of the plc op to restore to, used mostly to revert a fraudulent plc op. Want to give it the last valid operations cid * @param verificationCode - The verification code from the captcha/gate flow, required if the new PDS has phoneVerificationRequired * @param onStatus - A function that takes a string used to update the UI. Like (status) => console.log(status) * @returns If there is a failure during restoring the back up (after the status Success! Restoring your repo...) then your account is most likely * recovered and future runs need to have the RestoreFromBackup flag set to true and AccountRecovery set to false. */ recover(rotationKey: string, rotationKeyType: string | undefined, currentHandleOrDid: string, newPDS: string, newHandle: string, newPassword: string, newEmail: string, inviteCode: string | null, cidToRestoreTo?: string | null, verificationCode?: string | null, onStatus?: StatusHandler): Promise; /** * This method signs the plc operation over to the new PDS and activates the account * Assumes you have already created a new account during the recovery process and logged in * Uses the recommended did doc from the PDS as a base and adds the users rotation key to the rotation keys array */ signRestorePlcOperation(usersDid: DidString, additionalRotationKeysToAdd: string[] | undefined, prevCid: string): Promise; } export { Restore }; //# sourceMappingURL=restore.d.ts.map