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.
Optional discard and write-error observers.
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 buckets the key is restricted to, if any.
The restricted bucket IDs, 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.
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.
Application key ID configured on the client.
Stores the given authorization response and triggers an async write to disk.
The authorize-account response to persist.
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.
Resolved authorize-account realm URL for the client.
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.
FileAccountInfoserializes 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.