Skip to content

Commit da4de63

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

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

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

Comments
 (0)