Skip to content
Merged
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
19 changes: 11 additions & 8 deletions lib/DBSQLClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,21 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient {
* Connects DBSQLClient to endpoint
* @public
* @param options - host, path, and token are required
* @param authProvider - Optional custom authentication provider
* @returns Session object that can be used to execute statements
* @example
* const session = client.connect({host, path, token});
*/
async connect(options: ConnectionOptions): Promise<IDBSQLClient> {
this.authProvider = new PlainHttpAuthentication({
username: 'token',
password: options.token,
headers: {
'User-Agent': buildUserAgentString(options.clientId),
},
});
async connect(options: ConnectionOptions, authProvider?: IAuthentication): Promise<IDBSQLClient> {
this.authProvider =
authProvider ||
new PlainHttpAuthentication({
username: 'token',
password: options.token,
headers: {
'User-Agent': buildUserAgentString(options.clientId),
},
});

this.connection = await this.connectionProvider.connect(this.getConnectionOptions(options), this.authProvider);

Expand Down