@@ -41,6 +41,7 @@ import { Vault } from './vault/vault';
4141import { ConflictException } from './common/exceptions/conflict.exception' ;
4242import { CryptoProvider } from './common/crypto/crypto-provider' ;
4343import { ParseError } from './common/exceptions/parse-error' ;
44+ import { getEnv } from './common/utils/env' ;
4445
4546const VERSION = '8.0.0-beta.2' ;
4647
@@ -74,16 +75,9 @@ export class WorkOS {
7475 readonly webhooks : Webhooks ;
7576 readonly widgets = new Widgets ( this ) ;
7677
77- constructor (
78- readonly key ?: string ,
79- readonly options : WorkOSOptions = { } ,
80- ) {
78+ constructor ( readonly key ?: string , readonly options : WorkOSOptions = { } ) {
8179 if ( ! key ) {
82- // process might be undefined in some environments
83- this . key =
84- typeof process !== 'undefined'
85- ? process ?. env . WORKOS_API_KEY
86- : undefined ;
80+ this . key = getEnv ( 'WORKOS_API_KEY' ) ;
8781
8882 if ( ! this . key ) {
8983 throw new NoApiKeyProvidedException ( ) ;
@@ -95,8 +89,8 @@ export class WorkOS {
9589 }
9690
9791 this . clientId = this . options . clientId ;
98- if ( ! this . clientId && typeof process !== 'undefined' ) {
99- this . clientId = process ?. env . WORKOS_CLIENT_ID ;
92+ if ( ! this . clientId ) {
93+ this . clientId = getEnv ( ' WORKOS_CLIENT_ID' ) ;
10094 }
10195
10296 const protocol : string = this . options . https ? 'https' : 'http' ;
0 commit comments