resumeSession

tcmts.registry.session.resumeSession · #zizztpcm · term · runs in the browser

uses localStorage

The session kept from a visit before, if there is one and it still works.

import { configure, oauthSession, SIGNED_IN, signedInHere } from "#codebase/tcmts/registry/session";
import type { RegistrySession } from "#codebase/tcmts/registry/session";
import { getSession } from "@atcute/oauth-browser-client";

export async function resumeSession(): Promise<RegistrySession | undefined> {
  const did = localStorage.getItem(SIGNED_IN);
  if (!did) return undefined;
  await configure();
  try {
    return oauthSession(await getSession(did as `did:${string}:${string}`, { allowStale: true }));
  } catch {
    localStorage.removeItem(SIGNED_IN);
    await signedInHere(undefined);
    return undefined;
  }
}

uses

used by