@@ -40,6 +40,7 @@ import { Vault } from './vault/vault';
4040import { ConflictException } from './common/exceptions/conflict.exception' ;
4141import { CryptoProvider } from './common/crypto/crypto-provider' ;
4242import { ParseError } from './common/exceptions/parse-error' ;
43+ import { getEnv } from './common/utils/env' ;
4344
4445const VERSION = '8.0.0-beta.2' ;
4546
@@ -72,16 +73,9 @@ export class WorkOS {
7273 readonly widgets = new Widgets ( this ) ;
7374 readonly vault = new Vault ( this ) ;
7475
75- constructor (
76- readonly key ?: string ,
77- readonly options : WorkOSOptions = { } ,
78- ) {
76+ constructor ( readonly key ?: string , readonly options : WorkOSOptions = { } ) {
7977 if ( ! key ) {
80- // process might be undefined in some environments
81- this . key =
82- typeof process !== 'undefined'
83- ? process ?. env . WORKOS_API_KEY
84- : undefined ;
78+ this . key = getEnv ( 'WORKOS_API_KEY' ) ;
8579
8680 if ( ! this . key ) {
8781 throw new NoApiKeyProvidedException ( ) ;
@@ -93,8 +87,8 @@ export class WorkOS {
9387 }
9488
9589 this . clientId = this . options . clientId ;
96- if ( ! this . clientId && typeof process !== 'undefined' ) {
97- this . clientId = process ?. env . WORKOS_CLIENT_ID ;
90+ if ( ! this . clientId ) {
91+ this . clientId = getEnv ( ' WORKOS_CLIENT_ID' ) ;
9892 }
9993
10094 const protocol : string = this . options . https ? 'https' : 'http' ;
0 commit comments