@pds-moover/moover #

This is the core logic that runs PDS MOOver. With this you should be able to create your own "PDS MOOver" without having to figure out the atproto logic.
It is platform agnostic: plain TypeScript on top of fetch and WebCrypto, so it runs in a browser, in Node (19+) or
anywhere else that has those. It never stores anything and never signs anyone in on its own. You hand it sessions, and
it tells you when there is something worth saving.
pnpm add @pds-moover/moover
ESM only.
What is in the box #
- Migrator - Moves an account to a new PDS
- MissingBlobs - Finds blobs a migration left on your old PDS and uploads them to your new one
- BackupService - Sign up for backups, request one, or remove them on a PDS MOOver instance
- Restore - Recovers an account with a rotation key and restores the repo from a backup
- RotationKeyService and the rotation key helpers - Read and change the rotation keys on a did:plc identity
- PlcOps - Helpers for manual PLC operations
- deactivateOldAccount - Turns off the account left behind on the old PDS
- lib/atprotoUtils.ts - Handle and PDS resolution
Bring your own session #
Anything that acts on the user's current account takes an AccountAgent:
interface AccountAgent {
readonly did: string
fetchHandler(pathname: string, init?: RequestInit): Promise<Response>
}
An OAuth session from @atproto/oauth-client-browser (or -node) is one, and so is a PasswordSession from
@atproto/lex-password-session. The package does not care which.
import { Migrator } from '@pds-moover/moover'
import { PasswordSession } from '@atproto/lex-password-session'
// In the PDS MOOver web ui this is the user's OAuth session. A password session works the same.
const current = await PasswordSession.login({
service: 'https://old.pds.example',
identifier: 'alice.old.pds.example',
password: '...',
})
const migrator = new Migrator()
migrator.useOldSession(current)
// Persist the destination session if you want to resume after a restart
migrator.onSessionUpdate = data => save(data)
await migrator.migrate({
newPdsUrl: 'https://new.pds.example',
newEmail: 'alice@example.com',
newHandle: 'alice.new.pds.example',
newPassword: '...',
statusUpdateHandler: status => console.log(status),
})
// migrate() asked the old PDS to email a PLC token. Once the user has it:
const keys = await migrator.getRotationKeyContext()
await migrator.signPlcOperation(token, [...myOwnKeys, ...keys.newPdsKeys])
// The move is done. Turning the old account off is its own, best-effort step.
await migrator.tryDeactivateOldAccount()
The destination account is always a password session the migrator creates itself (it is the one creating the account).
Other things you can plug in #
- Where Restore keeps its temporary key.
Restoreputs a temporary verification key on the identity while it recovers an account. Pass aTempKeyStoreas the third constructor argument to keep that key across restarts, so a retry reuses it. The default (MemoryTempKeyStore) only lasts as long as the object. - Which network services it talks to.
setEndpoints({ plcDirectoryUrl, slingshotUrl, dohUrl, publicApiUrl })points the package at a private PLC directory, your own slingshot, or a mock. Call it before creating services.
Upgrading from 1.x #
2.0 is a breaking release.
- No more handle and password for the current account.
Migrator.loginPreflightandmigrateno longer log in to the old PDS. CalluseOldSession(agent)first.BackupService.loginAndStatusis replaced byuseSession(agent)andgetRepoStatusOrNull();MissingBlobsgainsuseCurrentSession(agent). migrate()takes an options object instead of 12 positional parameters.signPlcOperation(token, rotationKeys)takes the complete rotation key list, in priority order, instead of extra keys to add. Build it fromgetRotationKeyContext()so keys already on the identity are not dropped by accident.signPlcOperationno longer deactivates the old account. CalltryDeactivateOldAccount()afterwards (ordeactivateOldAccount()with the old password). Do it only once no blobs are left behind:countBlobsLeftBehind()tells you.restoreSessions(old, new)is nowrestoreNewSession(new). Only the destination session is the package's to restore.- ESM only. The UMD/CommonJS bundle is gone, and dependencies are no longer bundled into the output.