Skip to content

createTokenStorage — @gj-kit/expo-auth

A public function from @gj-kit/expo-auth/storage. The signature below is taken directly from the 0.1.1 release declaration.

import { createTokenStorage } from '@gj-kit/expo-auth/storage';
/**
* Platform-neutral token storage factory (design §3.8). The implementation is selected by the
* `./storage` exports condition fork (§2.2·§2.3) — one public name, one branch-invariant
* signature, one app-side assembly file, no `Platform.OS` branching in the consumer (§1
* invariant 2):
*
* **Native branch** (Expo iOS/Android — the only graph that contains expo-secure-store):
* - `'durable'`: two SecureStore keys — `{keyPrefix}.accessToken` / `{keyPrefix}.refreshToken`
* (split to dodge the Android ~2KB value-size warning, §7-4).
* - `'session'`: removed from SecureStore and kept in factory memory only. Process exit =
* signed out (§7-5).
* - In-memory cache (H10): allowed only here — a single native process has no external
* writer, so the cache cannot violate the §3.1 freshness clause.
*
* **node/browser branch** (peer-free, DOM-lib-free — §2.4):
* - `'durable'`: localStorage. `'session'`: sessionStorage (tab-scoped). ⚠ Web storage is NOT
* a security boundary — any XSS on the origin can read the tokens (§7-12).
* - `getTokens` is always a read-through (no cache) and prefers sessionStorage, and the
* persistence mode is derived from where a complete pair actually lives (H14).
* - Missing localStorage/sessionStorage (SSR): memory-only fallback, no throw (§2.4).
*/
declare function createTokenStorage(options: TokenStorageOptions): TokenStorage;

This declaration is the source of truth for parameters, optionality, generics, return values, and public union/type contracts. Check the package golden path and this subpath’s import conditions for required environment, permission, and error boundaries before calling it.

  • Package: @gj-kit/expo-auth
  • Version: 0.1.1
  • Public entry: ./storage
  • Source: GitHub