Skip to content

SessionState

Namespace: E2E

public sealed class SessionState

What a session’s SaveStateAsync captures (the engine’s cookies, storage, or app data), held in memory. Upstream’s SessionState (core/state.ts). It leaves the process only encrypted, under a key the caller holds, as a session-state-1 document; there is no plaintext export. Pass it to NewSessionAsync to start a session from it, on a host of the same engine, platform, and app.

Inheritance: object

View source

public string Engine { get; }

The engine that captured it, by name.

Value: string

public string Platform { get; }

The platform it was captured on.

Value: string

public Task<byte[]> ExportAsync(SessionStateKeyOptions options)

Encrypts the state with the key (AES-256-GCM, 32 bytes) into a session-state-1 document, as UTF-8 bytes. The document names the engine, the platform, a digest of the app, and the names of the secrets in the clear, authenticated; everything the state holds, secret values included, is in the ciphertext.

Parameters

Name Type Description
options SessionStateKeyOptions

Returns: Task<byte[]>

ImportAsync(byte[], SessionStateKeyOptions)

Section titled “ImportAsync(byte[], SessionStateKeyOptions)”
public static Task<SessionState> ImportAsync(byte[] data, SessionStateKeyOptions options)

Decrypts a document ExportAsync(SessionStateKeyOptions) wrote. A document that is not session-state-1, or that fails authentication under the key (a wrong key, an edited byte), is SESSION_INVALID; an expired one is SESSION_EXPIRED.

Parameters

Name Type Description
data byte[]
options SessionStateKeyOptions

Returns: Task<SessionState>