Skip to content

Commit 23da99a

Browse files
authored
[V8] remove direct process.env access, replacing with getEnv helper (#1312)
1 parent 1593c85 commit 23da99a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/workos.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { Actions } from './actions/actions';
3636
import { Vault } from './vault/vault';
3737
import { ConflictException } from './common/exceptions/conflict.exception';
3838
import { CryptoProvider } from './common/crypto/crypto-provider';
39+
import { getEnv } from './common/utils/env';
3940

4041
const VERSION = '8.0.0-beta.2';
4142

@@ -71,11 +72,7 @@ export class WorkOS {
7172
readonly options: WorkOSOptions = {},
7273
) {
7374
if (!key) {
74-
// process might be undefined in some environments
75-
this.key =
76-
typeof process !== 'undefined'
77-
? process?.env.WORKOS_API_KEY
78-
: undefined;
75+
this.key = getEnv('WORKOS_API_KEY');
7976

8077
if (!this.key) {
8178
throw new NoApiKeyProvidedException();
@@ -87,8 +84,8 @@ export class WorkOS {
8784
}
8885

8986
this.clientId = this.options.clientId;
90-
if (!this.clientId && typeof process !== 'undefined') {
91-
this.clientId = process?.env.WORKOS_CLIENT_ID;
87+
if (!this.clientId) {
88+
this.clientId = getEnv('WORKOS_CLIENT_ID');
9289
}
9390

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

0 commit comments

Comments
 (0)