Skip to content

Commit 05036ca

Browse files
committed
fix: wrap Node.js API call in environment check
- process.env is not available in browser environments - Wrap process.env call in main.ts in if statement that checks for browser presence
1 parent 4e444b9 commit 05036ca

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/main.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@ import axios from 'axios';
22
import { v4 as uuidv4 } from 'uuid';
33

44
import {
5-
type StixBundle,
6-
type AttackObject,
75
extensibleStixBundleSchema,
6+
type AttackObject,
87
type AttackObjects,
8+
type StixBundle,
99
} from './schemas/sdo/stix-bundle.schema.js';
1010

1111
import {
12-
techniqueSchema,
13-
tacticSchema,
14-
matrixSchema,
15-
mitigationSchema,
16-
relationshipSchema,
17-
dataSourceSchema,
12+
analyticSchema,
13+
assetSchema,
14+
campaignSchema,
15+
collectionSchema,
1816
dataComponentSchema,
17+
dataSourceSchema,
18+
detectionStrategySchema,
1919
groupSchema,
20-
malwareSchema,
21-
toolSchema,
22-
markingDefinitionSchema,
2320
identitySchema,
24-
collectionSchema,
25-
campaignSchema,
26-
assetSchema,
2721
logSourceSchema,
28-
detectionStrategySchema,
29-
analyticSchema,
22+
malwareSchema,
23+
markingDefinitionSchema,
24+
matrixSchema,
25+
mitigationSchema,
26+
relationshipSchema,
27+
tacticSchema,
28+
techniqueSchema,
29+
toolSchema,
3030
} from './schemas/index.js';
3131

3232
import {
@@ -53,9 +53,11 @@ const readFile = async (path: string): Promise<string> => {
5353
}
5454
};
5555

56-
const GITHUB_BASE_URL =
57-
process.env.GITHUB_BASE_URL ||
58-
'https://raw.githubusercontent.com/mitre-attack/attack-stix-data/master';
56+
let GITHUB_BASE_URL = ""
57+
if (typeof window !== 'undefined') {
58+
GITHUB_BASE_URL =
59+
process.env.GITHUB_BASE_URL || 'https://raw.githubusercontent.com/mitre-attack/attack-stix-data/master';
60+
}
5961

6062
interface DataSourceMap {
6163
[key: string]: {

0 commit comments

Comments
 (0)