Skip to content

SSOStorage

@blobs/sdk v0.1.0


@blobs/sdk / sso / SSOStorage

Defined in: sso/SSOStorage.ts:20

Persists SSOState in localStorage and broadcasts changes across tabs via the standard storage event.

Provides a small in-tab pub/sub API on top of localStorage so other pages of the same app can react to in-flight SSO requests, available sessions, and recent history. Use one shared instance per page.

Constructors

Constructor

new SSOStorage(): SSOStorage

Defined in: sso/SSOStorage.ts:24

Hooks the cross-tab storage listener so other tabs’ writes propagate.

Returns

SSOStorage

Methods

getState()

getState(): SSOState

Defined in: sso/SSOStorage.ts:36

Reads the current SSOState from localStorage.

Returns

SSOState

The parsed state, or an empty state if missing/corrupt.


setState()

setState(state): void

Defined in: sso/SSOStorage.ts:56

Replaces the entire SSOState in localStorage and notifies in-tab listeners.

Parameters

state

SSOState

New state to persist.

Returns

void


updateState()

updateState(updates): void

Defined in: sso/SSOStorage.ts:73

Merges partial updates into the existing SSOState.

Parameters

updates

Partial<SSOState>

Fields to overwrite; other fields are preserved.

Returns

void


clearState()

clearState(): void

Defined in: sso/SSOStorage.ts:80

Removes all SSO state from localStorage and notifies listeners.

Returns

void


getAvailableSessions()

getAvailableSessions(): SSOCandidate[]

Defined in: sso/SSOStorage.ts:94

Returns sessions that can be presented as one-click sign-in candidates.

Returns

SSOCandidate[]

Each stored session promoted to an SSOCandidate with a default 24h expiry.


setAvailableSessions()

setAvailableSessions(sessions): void

Defined in: sso/SSOStorage.ts:110

Persists the given sessions as the available one-click candidates.

Parameters

sessions

SSOCandidate[]

Candidate sessions to advertise.

Returns

void


setActiveRequest()

setActiveRequest(request): void

Defined in: sso/SSOStorage.ts:126

Marks an SSO request as in-flight so other tabs can observe it.

Parameters

request

{ id: string; networkName: string; requestedBy: string; timestamp: number; config: SSOConfig; } | undefined

Active request descriptor (or undefined to clear).

Returns

void


clearActiveRequest()

clearActiveRequest(): void

Defined in: sso/SSOStorage.ts:131

Clears the active SSO request marker.

Returns

void


getActiveRequest()

getActiveRequest(): { id: string; networkName: string; requestedBy: string; timestamp: number; config: SSOConfig; } | undefined

Defined in: sso/SSOStorage.ts:138

Returns the active SSO request, if any.

Returns

{ id: string; networkName: string; requestedBy: string; timestamp: number; config: SSOConfig; } | undefined


addHistory()

addHistory(entry): void

Defined in: sso/SSOStorage.ts:147

Prepends an entry to the SSO history, capped at the most recent 50 events.

Parameters

entry

History row describing the outcome of an SSO flow.

timestamp

number

type

"error" | "success" | "cancelled"

networkName

string

message?

string

Returns

void


getHistory()

getHistory(): object[] | undefined

Defined in: sso/SSOStorage.ts:163

Returns the SSO history, oldest-first within the cap.

Returns

object[] | undefined


clearHistory()

clearHistory(): void

Defined in: sso/SSOStorage.ts:168

Empties the SSO history.

Returns

void


subscribe()

subscribe(id, callback): () => void

Defined in: sso/SSOStorage.ts:179

Subscribes to state-change notifications (own tab and other tabs).

Parameters

id

string

Caller-supplied identifier for the listener (used as the unsubscribe key).

callback

(state) => void

Invoked with the new state after each change.

Returns

Unsubscribe function.

() => void


destroy()

destroy(): void

Defined in: sso/SSOStorage.ts:230

Detaches the cross-tab listener and clears all in-tab subscribers.

Call this when the surrounding SSOManager is torn down.

Returns

void