Skip to content

Commit 70ce5b5

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

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
@@ -39,6 +39,7 @@ import { Vault } from './vault/vault';
3939
import { ConflictException } from './common/exceptions/conflict.exception';
4040
import { CryptoProvider } from './common/crypto/crypto-provider';
4141
import { ParseError } from './common/exceptions/parse-error';
42+
import { getEnv } from './common/utils/env';
4243

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

Comments
 (0)