@synonymdev/pubky
    Preparing search index...

    Class Session

    An authenticated context “as the user”.

    • Use storage for reads/writes (absolute paths like /pub/app/file.txt)
    • Cookie is managed automatically by the underlying fetch client
    Index
    cookie: CookieSession | undefined

    Cookie-only view for cookie-backed sessions.

    Grant-backed sessions return undefined.

    grant: GrantSession | undefined

    Grant-only management view for grant-backed sessions.

    Cookie-backed sessions return undefined.

    Retrieve immutable info about this session (user & capabilities).

    Access the session-scoped storage API (read/write).

    • Returns void

    • Export the session metadata so it can be restored after a tab refresh.

      The export string contains no secrets; it only serializes the public SessionInfo. Browsers remain responsible for persisting the HTTP-only session cookie.

      Returns string

      A base64 string to store (e.g. in localStorage).

      Prefer exportLocalSecret() for grant sessions.

    • Export the local secret material needed to restore this session.

      For local grant sessions this exports the grant JWS and PoP client secret; restoring mints a fresh bearer. For legacy cookie sessions this exports the cookie secret when the SDK owns it. Delegated browser grant sessions cannot export raw secret material; use BrowserSessionStore.

      Treat the returned string as a bearer-equivalent secret until the grant or cookie session expires or is revoked.

      Returns Promise<string>

      A secret token that can be passed to pubky.restoreSession().

    • Returns void

    • Invalidate the session on the server (clears server cookie). Further calls to storage API will fail.

      Returns Promise<void>

    • Restore a session from an export() string.

      The HTTP-only cookie must still be present in the browser; this function does not read or write any secrets.

      Parameters

      • exported: string

        A string produced by session.export().

      • Optionalclient: Client | null

        Optional client to reuse transport configuration.

      Returns Promise<Session>

      Prefer Pubky.restoreSession(...).