OptionalauthHow long auth tokens issued via b2_authorize_account are valid
for, in milliseconds. Defaults to 24 hours (real B2). Tests that
want to exercise the 401/reauth retry path can lower this so a
single call to B2Simulator.advanceTime expires the token.
OptionalminimumThe minimum part size the simulator advertises in b2_authorize_account
responses (apiInfo.storageApi.absoluteMinimumPartSize). Defaults to
5_000_000 to mirror production B2. Lower this in tests that exercise
multipart control-flow branches but don't need realistic part sizes,
because v8 coverage instrumentation pushes 5 MB+ part hashing past 60 s
on the slowest CI runners, which trips vitest's IPC RPC timeout.
OptionalonDiagnostic hook: invoked with any error thrown or rejected by
onWebhookDeliver / onReplicate. Without this, errors thrown by
user-supplied hooks are silently swallowed (intentional: a buggy
hook must not corrupt an otherwise-successful upload), which makes
test debugging hard when a hook quietly stops firing. Register
onHookError to surface what would otherwise be invisible.
OptionalonPluggable hook: invoked after every successful upload on a bucket
configured as a replication source. Receives the source FileVersion
and the destination bucket ID. Tests can register a hook to
verify replication intent without actually copying bytes inside
the simulator.
OptionalonPluggable hook: invoked after every successful upload, copy, or
finishLargeFile on a bucket with a matching event-notification
rule. Tests can register a hook to assert the SDK's webhook
publishing path without spinning up a real HTTP listener.
Receives the freshly-stored FileVersion, the bucket the upload
landed in, and the rule that matched. Returns a promise so async
hook implementations are allowed; the simulator never blocks on it
(errors thrown from the hook are surfaced via bestEffort to
avoid masking the underlying API call's success).
OptionalrecommendedThe recommended part size the simulator advertises in
b2_authorize_account responses (apiInfo.storageApi.recommendedPartSize).
Defaults to 100_000_000 to mirror production B2. Lower this when a test
needs to exercise the SDK's "use the recommended size when the caller
omits partSize" default-branch without uploading 100 MB of bytes.
OptionalstrictWhen true, the simulator enforces application-key capability
checks, bucket scoping, prefix scoping, and auth-token expiry on
every request. The default false keeps the simulator permissive
(matching its long-standing behaviour) so the existing test suite
doesn't have to set up keys with the right capabilities.
In strict mode:
bad_auth_token.expired_auth_token.unauthorized.unauthorized.Each test can opt in: new B2Simulator({ strictAuth: true }).
Options for constructing a B2Simulator.