memorySessions

tcmts.atproto.memorySessions · #gf2jltep · function · runs anywhere

Sign-ins kept for as long as this process runs.

import type { KeptSessions, SessionStore } from "#codebase/tcmts/atproto";

export function memorySessions(): SessionStore {
  const kept: KeptSessions = { sessions: {} };
  return {
    read: () => structuredClone(kept),
    keep(did, s) {
      if (s) {
        kept.sessions[did] = structuredClone(s);
        kept.last = did;
      } else {
        delete kept.sessions[did];
        if (kept.last === did) delete kept.last;
      }
    },
  };
}

uses

used by