콘텐츠로 이동

TokenStorage — @gj-kit/expo-auth

@gj-kit/expo-auth에서 공개하는 interface입니다. package version 0.1.1의 release declaration을 그대로 표시합니다.

import { TokenStorage } from '@gj-kit/expo-auth';
/**
* Storage seam (design §3.1). Implementation contract:
*
* - `getTokens` returns a pair only when BOTH tokens are present; half states converge to
* `null` (H12 — a torn write reads as "signed out", never as corrupt data).
* - `getTokens` **freshness**: inside the refresh critical section (§3.5) a read must reflect
* the last write committed by any other tab/instance — the precondition of the H2b adoption
* and the H3 comparison. An in-memory cache is only allowed where no external writer exists
* (native single process — §3.8); the web implementation is read-through.
* - `setTokens` with `persistence` omitted keeps the current mode (H14 — a rotation after a
* session login must not silently promote tokens to durable). The initial default is
* implementation-defined.
* - `clearTokens` is idempotent and resets the persistence mode to the implementation default.
* - No method may throw an error whose message contains a token string (§4.2).
*/
interface TokenStorage {
getTokens(): Promise<TokenPair | null>;
setTokens(tokens: TokenPair, options?: {
readonly persistence?: TokenPersistence | undefined;
}): Promise<void>;
clearTokens(): Promise<void>;
}

이 선언은 매개변수, optionality, 제네릭, 반환값, 공개 union/type 계약의 정본입니다. 호출 전 필요한 환경·권한·오류 경계는 패키지 Golden path와 이 subpath의 import 조건을 함께 확인하세요.

  • 패키지: @gj-kit/expo-auth
  • 버전: 0.1.1
  • 공개 entry: .
  • 소스: GitHub

Storage seam (design §3.1). Implementation contract:

  • getTokens returns a pair only when BOTH tokens are present; half states converge to null (H12 — a torn write reads as “signed out”, never as corrupt data).
  • getTokens freshness: inside the refresh critical section (§3.5) a read must reflect the last write committed by any other tab/instance — the precondition of the H2b adoption and the H3 comparison. An in-memory cache is only allowed where no external writer exists (native single process — §3.8); the web implementation is read-through.
  • setTokens with persistence omitted keeps the current mode (H14 — a rotation after a session login must not silently promote tokens to durable). The initial default is implementation-defined.
  • clearTokens is idempotent and resets the persistence mode to the implementation default.
  • No method may throw an error whose message contains a token string (§4.2).