Skip to content

Commit 5599226

Browse files
committed
[V8] remove direct process.env access, replacing with getEnv helper (#1312)
1 parent ef6c0b0 commit 5599226

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/workos.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { Vault } from './vault/vault';
3838
import { ConflictException } from './common/exceptions/conflict.exception';
3939
import { CryptoProvider } from './common/crypto/crypto-provider';
4040
import { ParseError } from './common/exceptions/parse-error';
41+
import { getEnv } from './common/utils/env';
4142

4243
const 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

Comments
 (0)