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
11 changes: 4 additions & 7 deletions src/workos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { Actions } from './actions/actions';
import { Vault } from './vault/vault';
import { ConflictException } from './common/exceptions/conflict.exception';
import { CryptoProvider } from './common/crypto/crypto-provider';
import { getEnv } from './common/utils/env';

const VERSION = '8.0.0-beta.2';

Expand Down Expand Up @@ -71,11 +72,7 @@ export class WorkOS {
readonly options: WorkOSOptions = {},
) {
if (!key) {
// process might be undefined in some environments
this.key =
typeof process !== 'undefined'
? process?.env.WORKOS_API_KEY
: undefined;
this.key = getEnv('WORKOS_API_KEY');

if (!this.key) {
throw new NoApiKeyProvidedException();
Expand All @@ -87,8 +84,8 @@ export class WorkOS {
}

this.clientId = this.options.clientId;
if (!this.clientId && typeof process !== 'undefined') {
this.clientId = process?.env.WORKOS_CLIENT_ID;
if (!this.clientId) {
this.clientId = getEnv('WORKOS_CLIENT_ID');
}

const protocol: string = this.options.https ? 'https' : 'http';
Expand Down