@backblaze-labs/b2-sdk - v0.2.0
    Preparing search index...

    Class FileAccountInfo

    Node-only AccountInfo backend that persists the authorization response to a JSON file. Upload URL pools remain in memory because URLs are short-lived and shouldn't be shared across processes. The JSON file contains a live B2 authorization token, so treat it as sensitive and keep it out of shared or world-readable locations. FileAccountInfo serializes writes within one process but does not provide inter-process locking. If multiple processes share one path, use FileAccountInfoOptions.onDiscard and FileAccountInfoOptions.onWriteError to observe cache churn, or prefer one cache path per resolved realm and key.

    On instantiation, call FileAccountInfo.load to populate state from disk (or start fresh if the file is missing or corrupt). The authorization response is written back to disk on every setAuth or clear call so a process restart can resume without re-authorizing. Cache files without an SDK metadata application-key binding are ignored once bound to a B2Client, because the SDK cannot verify which key wrote them.

    This module imports node:fs/promises; do not load it in browser bundles.

    Implements

    Index

    Constructors

    Properties

    path: string

    Absolute path to the JSON file that backs this account info.

    Methods

    • Awaits any pending disk writes. Call before process exit to ensure the latest state is persisted.

      Returns Promise<void>

      A promise that resolves once all queued writes are flushed.

    • Reads the JSON file at the configured path and populates in-memory state. If the file is missing or contains invalid JSON, leaves state empty and returns silently (a re-auth is expected next).

      Returns Promise<void>

      A promise that resolves when load is complete.

    • Binds this cache to the configured application key ID. B2Client calls this when a FileAccountInfo instance is supplied, so stale auth produced by another key is discarded before it can be used.

      Parameters

      • applicationKeyId: string

        Application key ID configured on the client.

      Returns void

    • Binds this cache to the configured realm URL. B2Client calls this when a FileAccountInfo instance is supplied, so stale auth produced by another realm is discarded before it can be used.

      Parameters

      • realmUrl: string

        Resolved authorize-account realm URL for the client.

      Returns void