Summary
Add a new authentication option accessTokenFromEnv that reads an access token from a specified environment variable at connection time.
Motivation
This would help in two scenarios:
- Local development and quick prototyping — developers can export a short-lived token in their shell and immediately run scripts without wiring up a full service account flow.
- Security-constrained environments — in setups where credentials (client ID/secret) cannot be stored on local machines, an externally-provisioned token injected via environment variable is the only viable auth path.
Proposed behavior
accessTokenFromEnv accepts a string — the name of the environment variable that holds the access token.
const connection = await firebolt.connect({
auth: {
accessTokenFromEnv: "FIREBOLT_TOKEN",
},
engineName: 'engine_name',
account: 'account_name',
database: 'database',
});
At connection time, the SDK reads process.env.FIREBOLT_TOKEN. If the variable is set and non-empty, its value is used as the access token (equivalent to passing accessToken directly).
Combining with other auth methods
Unlike other auth options, accessTokenFromEnv can be specified alongside client_id/client_secret. When both are present, accessTokenFromEnv takes priority if the environment variable is set; otherwise the SDK falls back to the client credentials flow:
const connection = await firebolt.connect({
auth: {
// Use process.env.FIREBOLT_TOKEN if set
accessTokenFromEnv: "FIREBOLT_TOKEN",
// Fall back to client credentials otherwise
client_id: 'b1c4918c-e07e-4ab2-868b-9ae84f208d26',
client_secret: 'secret',
},
engineName: 'engine_name',
account: 'account_name',
database: 'database',
});
Resolution order
- If
accessTokenFromEnv is specified and process.env[value] is set and non-empty → use it as the access token.
- Otherwise, if
client_id/client_secret are provided → use client credentials auth.
- Otherwise → throw an authentication error.
Type changes
type ConnectionOptions = {
auth: AccessTokenAuth | ClientCredentialsAuth | FireboltCoreAuth | EnvTokenAuth | EnvTokenWithFallbackAuth;
// ...
};
type EnvTokenAuth = {
accessTokenFromEnv: string;
};
type EnvTokenWithFallbackAuth = {
accessTokenFromEnv: string;
client_id: string;
client_secret: string;
};
Summary
Add a new authentication option
accessTokenFromEnvthat reads an access token from a specified environment variable at connection time.Motivation
This would help in two scenarios:
Proposed behavior
accessTokenFromEnvaccepts a string — the name of the environment variable that holds the access token.At connection time, the SDK reads
process.env.FIREBOLT_TOKEN. If the variable is set and non-empty, its value is used as the access token (equivalent to passingaccessTokendirectly).Combining with other auth methods
Unlike other auth options,
accessTokenFromEnvcan be specified alongsideclient_id/client_secret. When both are present,accessTokenFromEnvtakes priority if the environment variable is set; otherwise the SDK falls back to the client credentials flow:Resolution order
accessTokenFromEnvis specified andprocess.env[value]is set and non-empty → use it as the access token.client_id/client_secretare provided → use client credentials auth.Type changes