@@ -39,6 +39,7 @@ import { Vault } from './vault/vault';
3939import { ConflictException } from './common/exceptions/conflict.exception' ;
4040import { CryptoProvider } from './common/crypto/crypto-provider' ;
4141import { ParseError } from './common/exceptions/parse-error' ;
42+ import { getEnv } from './common/utils/env' ;
4243
4344const VERSION = '8.0.0-beta.2' ;
4445
@@ -70,16 +71,9 @@ export class WorkOS {
7071 readonly widgets = new Widgets ( this ) ;
7172 readonly vault = new Vault ( this ) ;
7273
73- constructor (
74- readonly key ?: string ,
75- readonly options : WorkOSOptions = { } ,
76- ) {
74+ constructor ( readonly key ?: string , readonly options : WorkOSOptions = { } ) {
7775 if ( ! key ) {
78- // process might be undefined in some environments
79- this . key =
80- typeof process !== 'undefined'
81- ? process ?. env . WORKOS_API_KEY
82- : undefined ;
76+ this . key = getEnv ( 'WORKOS_API_KEY' ) ;
8377
8478 if ( ! this . key ) {
8579 throw new NoApiKeyProvidedException ( ) ;
@@ -91,8 +85,8 @@ export class WorkOS {
9185 }
9286
9387 this . clientId = this . options . clientId ;
94- if ( ! this . clientId && typeof process !== 'undefined' ) {
95- this . clientId = process ?. env . WORKOS_CLIENT_ID ;
88+ if ( ! this . clientId ) {
89+ this . clientId = getEnv ( ' WORKOS_CLIENT_ID' ) ;
9690 }
9791
9892 const protocol : string = this . options . https ? 'https' : 'http' ;
0 commit comments