Skip to content
Seismic Orchestration

Token stores

The tokenStore config field decides where the client keeps tokens. Three values are accepted:

ValueDescription
"memory"Default. In-process only.
"localStorage"Browser window.localStorage.
A TokenStoreCustom implementation (cookies, SQLite, Cloudflare KV, etc.).

Default is "memory".

Memory (default)

import {  } from "seismic-orchestration";
 
const  = .();                     // tokenStore: "memory"
const  = .({ : "memory" });

Tokens live in the client instance's closure. They are lost when the process exits or the tab navigates away.

localStorage

import {  } from "seismic-orchestration";
 
const  = .({ : "localStorage" });

Persists access_token, refresh_token, access_expires_at, refresh_expires_at under the seismic.* key prefix. Survives page reloads and tab restores.

localStorage is readable by any script on the origin. For apps that load untrusted third-party scripts, use a custom httpOnly-cookie store instead.

Custom stores

Implement the TokenStore interface and pass an instance:

import { , type TokenStore } from "seismic-orchestration";
 
// Example: sessionStorage, cleared when the tab closes.
function (): TokenStore {
  return {
    () {
      .("access", .);
      .("refresh", .);
      .("exp", .);
      .("rexp", .);
    },
    () {
      .();
    },
    : () => .("access"),
    : () => .("refresh"),
    : () => .("access") !== null,
  };
}
 
const  = .({ : () });

Seeding from existing tokens

For machine users whose tokens live in env vars, build a memory store and hand it in:

const  = .({
  : ({
    : .,
    : .,
  }),
});