Something went wrong. Try again.
Client side atproto account migrator in your web browser, along with services for backups and adversarial migrations. pdsmoover.com
pds atproto migrations moo cow
Something went wrong. Try again.
1.8 kB · 39 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031323334353637383940import {createSessionCache, type SessionCache} from '$lib/sessionCache';
/** * Persists the current ('current') and old ('old') login sessions of an in-progress missing-blobs * import in localStorage so a page refresh can automatically restore them and offer to resume the * import instead of forcing the user to re-enter both passwords and re-trigger 2FA. This matters * most in the rate-limited case, where the user is told to come back in ~24h. All persistence * policy lives in the generic `sessionCache` factory; the `@pds-moover/moover` package only * exposes generic hooks (onSessionUpdate / restoreSessions). * * Only the current side is required: a refresh before the old-PDS login still resumes (restore the * current session, show the missing count, drop the user at the old-PDS password step). An * old-side-only orphan is cleared. * * Security note: this stores access + refresh JWTs in localStorage. Acceptable for this SPA, * mitigated by clearing on completion / start-over and by PasswordSession.resume() invalidating * dead sessions. */
const STORAGE_KEY = 'pdsmoover:missing-blobs-sessions:v1';
export type MissingBlobsSessionCache = SessionCache<'current' | 'old'>;
const cache = createSessionCache<'current' | 'old'>(STORAGE_KEY, ['current']);
/** * Persist (data) or drop (null) one side of the import. When both sides end up gone the whole key * is removed so we never leave an orphaned entry behind. */export const saveSide = cache.saveSide;
/** * Read the cached sessions. Resume needs at least the current side; an old-side-only orphan is * cleared and null is returned. */export const load = cache.load;
/** Remove the whole cache entry (completion / start-over / expired sessions). */export const clear = cache.clear;