Skip to content

Commit

Permalink
Merge pull request #9 from koszti/connect-async
Browse files Browse the repository at this point in the history
Add authentication options
  • Loading branch information
natesilva committed Mar 12, 2021
2 parents adf04f9 + 4eace38 commit 3f4e815
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/Snowflake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ export class Snowflake {
});
}

/** Establishes a connection if we aren't in a fatal state. */
connectAsync() {
return new Promise<void>((resolve, reject) => {
this.sdk_connection.connectAsync(err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}

/**
* Immediately terminates the connection without waiting for currently
* executing statements to complete.
Expand Down
24 changes: 22 additions & 2 deletions src/types/ConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,28 @@ export interface ConnectionOptions {
account: string;
/** Snowflake user login name to connect with. */
username: string;
/** Password for the user. */
password: string;
/**
* Specifies the authenticator to use for verifying user login credentials.
* You can set this to one of the following values:
* SNOWFLAKE: Use the internal Snowflake authenticator. You must also set the password option.
* EXTERNALBROWSER: Use your web browser to authenticate with Okta, ADFS, or any other
* SAML 2.0-compliant identity provider (IdP) that has been defined for your account
* OAUTH: Use OAuth for authentication. You must also set the token option to the OAuth token
* SNOWFLAKE_JWT: Use key pair authentication
*/
authenticator?: string;
/** Password for the user. Set this option if you set the authenticator option to
* SNOWFLAKE or if you left the authenticator option unset.
*/
password?: string;
/** Specifies the OAuth token to use for authentication. */
token?: string;
/** Specifies the private key (in PEM format) for key pair authentication. */
privateKey?: string;
/** Specifies the local path to the private key file (e.g. rsa_key.p8). */
privateKeyPath?: string;
/** Specifies the passcode to decrypt the private key file, if the file is encrypted. */
privateKeyPass?: string;
/**
* The ID for the region where your account is located.
*
Expand Down

0 comments on commit 3f4e815

Please sign in to comment.