@@ -38,6 +38,7 @@ import { Vault } from './vault/vault';
3838import { ConflictException } from './common/exceptions/conflict.exception' ;
3939import { CryptoProvider } from './common/crypto/crypto-provider' ;
4040import { ParseError } from './common/exceptions/parse-error' ;
41+ import { getEnv } from './common/utils/env' ;
4142
4243const VERSION = '8.0.0-beta.2' ;
4344
@@ -68,16 +69,9 @@ export class WorkOS {
6869 readonly widgets = new Widgets ( this ) ;
6970 readonly vault = new Vault ( this ) ;
7071
71- constructor (
72- readonly key ?: string ,
73- readonly options : WorkOSOptions = { } ,
74- ) {
72+ constructor ( readonly key ?: string , readonly options : WorkOSOptions = { } ) {
7573 if ( ! key ) {
76- // process might be undefined in some environments
77- this . key =
78- typeof process !== 'undefined'
79- ? process ?. env . WORKOS_API_KEY
80- : undefined ;
74+ this . key = getEnv ( 'WORKOS_API_KEY' ) ;
8175
8276 if ( ! this . key ) {
8377 throw new NoApiKeyProvidedException ( ) ;
@@ -89,8 +83,8 @@ export class WorkOS {
8983 }
9084
9185 this . clientId = this . options . clientId ;
92- if ( ! this . clientId && typeof process !== 'undefined' ) {
93- this . clientId = process ?. env . WORKOS_CLIENT_ID ;
86+ if ( ! this . clientId ) {
87+ this . clientId = getEnv ( ' WORKOS_CLIENT_ID' ) ;
9488 }
9589
9690 const protocol : string = this . options . https ? 'https' : 'http' ;
0 commit comments