Constructs a FileAccountInfo bound to a JSON file on disk. The file is
created on the first setAuth write; reading it back happens via
load.
Absolute path to the JSON file that backs this account info.
Takes a large-file part upload URL from the in-memory pool.
Large file to check out a part upload URL for.
A reusable part upload URL entry, or null if none are pooled.
Takes an upload URL from the in-memory pool for the given bucket.
Bucket to check out an upload URL for.
A reusable upload URL entry, or null if none are pooled.
Discards in-memory state and clears the on-disk file.
Removes a part upload URL from the pool after an error.
Large file the failed part upload URL belongs to.
Part upload URL entry to evict.
Removes an upload URL from the pool after an upload error.
Bucket the failed upload URL belongs to.
Upload URL entry to evict.
Awaits any pending disk writes. Call before process exit to ensure the latest state is persisted.
A promise that resolves once all queued writes are flushed.
Returns the server-enforced minimum part size for multipart uploads.
The absolute minimum part size in bytes.
Returns the cached account identifier.
The authorized account ID.
Returns the bucket the key is restricted to, if any.
The restricted bucket ID, or null if the key is unrestricted.
Returns the cached B2 API URL.
The base URL for B2 API calls.
Returns the currently cached authorization response, or null if none.
The cached authorization response, or null if not authorized.
Returns the cached session authorization token.
The current authorization token.
Returns the cached file-download URL.
The base URL for file downloads.
Returns the server-recommended part size for multipart uploads.
The recommended part size in bytes.
Returns the cached S3-compatible API URL.
The base URL for the S3-compatible API.
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).
A promise that resolves when load is complete.
Returns a still-valid part upload URL to the pool for reuse.
Large file the part upload URL belongs to.
Part upload URL entry to return.
Returns a still-valid upload URL to the pool for reuse.
Bucket the upload URL belongs to.
Upload URL entry to return.
Stores the given authorization response and triggers an async write to disk.
The authorize-account response to persist.
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.
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.
This module imports
node:fs/promises; do not load it in browser bundles.