Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/b2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ function B2(options) {
this.accountId = options.accountId;
this.applicationKeyId = options.applicationKeyId;
this.applicationKey = options.applicationKey;
this.authorizationToken = null;
this.apiUrl = null;
this.downloadUrl = null;
this.authorizationToken = options.authorizationToken ?? null;
this.apiUrl = options.apiUrl ?? null;
this.downloadUrl = options.downloadUrl ?? null;

// if any of authorizationToken, apiUrl or downloadUrl is provided, all must be present
if (this.authorizationToken || this.apiUrl || this.downloadUrl) {
if (!this.authorizationToken || !this.apiUrl || !this.downloadUrl) {
throw new Error('When using pre-authorized credentials, all three authorizationToken, apiUrl, and downloadUrl must be provided');
}
}
/*
allows an optional axios config object that overrides the default axios config
creates new axios instance so that axios-retry isn't injected into the user's code if they also use axios
Expand Down