Skip to content

Commit 43ad6bf

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

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

4445
const VERSION = '8.0.0-beta.2';
4546

@@ -72,16 +73,9 @@ export class WorkOS {
7273
readonly widgets = new Widgets(this);
7374
readonly vault = new Vault(this);
7475

75-
constructor(
76-
readonly key?: string,
77-
readonly options: WorkOSOptions = {},
78-
) {
76+
constructor(readonly key?: string, readonly options: WorkOSOptions = {}) {
7977
if (!key) {
80-
// process might be undefined in some environments
81-
this.key =
82-
typeof process !== 'undefined'
83-
? process?.env.WORKOS_API_KEY
84-
: undefined;
78+
this.key = getEnv('WORKOS_API_KEY');
8579

8680
if (!this.key) {
8781
throw new NoApiKeyProvidedException();
@@ -93,8 +87,8 @@ export class WorkOS {
9387
}
9488

9589
this.clientId = this.options.clientId;
96-
if (!this.clientId && typeof process !== 'undefined') {
97-
this.clientId = process?.env.WORKOS_CLIENT_ID;
90+
if (!this.clientId) {
91+
this.clientId = getEnv('WORKOS_CLIENT_ID');
9892
}
9993

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

0 commit comments

Comments
 (0)