@litko/yara-x 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +524 -320
- package/package.json +11 -5
package/index.js
CHANGED
|
@@ -4,556 +4,760 @@
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
6
|
const { createRequire } = require('node:module')
|
|
7
|
-
require = createRequire(__filename)
|
|
7
|
+
require = createRequire(__filename);
|
|
8
8
|
|
|
9
|
-
const { readFileSync } = require(
|
|
10
|
-
let nativeBinding = null
|
|
11
|
-
const loadErrors = []
|
|
9
|
+
const { readFileSync } = require("node:fs");
|
|
10
|
+
let nativeBinding = null;
|
|
11
|
+
const loadErrors = [];
|
|
12
12
|
|
|
13
13
|
const isMusl = () => {
|
|
14
|
-
let musl = false
|
|
15
|
-
if (process.platform ===
|
|
16
|
-
musl = isMuslFromFilesystem()
|
|
14
|
+
let musl = false;
|
|
15
|
+
if (process.platform === "linux") {
|
|
16
|
+
musl = isMuslFromFilesystem();
|
|
17
17
|
if (musl === null) {
|
|
18
|
-
musl = isMuslFromReport()
|
|
18
|
+
musl = isMuslFromReport();
|
|
19
19
|
}
|
|
20
20
|
if (musl === null) {
|
|
21
|
-
musl = isMuslFromChildProcess()
|
|
21
|
+
musl = isMuslFromChildProcess();
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
return musl
|
|
25
|
-
}
|
|
24
|
+
return musl;
|
|
25
|
+
};
|
|
26
26
|
|
|
27
|
-
const isFileMusl = (f) => f.includes(
|
|
27
|
+
const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
|
|
28
28
|
|
|
29
29
|
const isMuslFromFilesystem = () => {
|
|
30
30
|
try {
|
|
31
|
-
return readFileSync(
|
|
31
|
+
return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
|
|
32
32
|
} catch {
|
|
33
|
-
return null
|
|
33
|
+
return null;
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
|
|
37
37
|
const isMuslFromReport = () => {
|
|
38
|
-
let report = null
|
|
39
|
-
if (typeof process.report?.getReport ===
|
|
40
|
-
process.report.excludeNetwork = true
|
|
41
|
-
report = process.report.getReport()
|
|
38
|
+
let report = null;
|
|
39
|
+
if (typeof process.report?.getReport === "function") {
|
|
40
|
+
process.report.excludeNetwork = true;
|
|
41
|
+
report = process.report.getReport();
|
|
42
42
|
}
|
|
43
43
|
if (!report) {
|
|
44
|
-
return null
|
|
44
|
+
return null;
|
|
45
45
|
}
|
|
46
46
|
if (report.header && report.header.glibcVersionRuntime) {
|
|
47
|
-
return false
|
|
47
|
+
return false;
|
|
48
48
|
}
|
|
49
49
|
if (Array.isArray(report.sharedObjects)) {
|
|
50
50
|
if (report.sharedObjects.some(isFileMusl)) {
|
|
51
|
-
return true
|
|
51
|
+
return true;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
return false
|
|
55
|
-
}
|
|
54
|
+
return false;
|
|
55
|
+
};
|
|
56
56
|
|
|
57
57
|
const isMuslFromChildProcess = () => {
|
|
58
58
|
try {
|
|
59
|
-
return require(
|
|
59
|
+
return require("child_process")
|
|
60
|
+
.execSync("ldd --version", { encoding: "utf8" })
|
|
61
|
+
.includes("musl");
|
|
60
62
|
} catch (e) {
|
|
61
63
|
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
62
|
-
return false
|
|
64
|
+
return false;
|
|
63
65
|
}
|
|
64
|
-
}
|
|
66
|
+
};
|
|
65
67
|
|
|
66
68
|
function requireNative() {
|
|
67
69
|
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
68
70
|
try {
|
|
69
71
|
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
70
72
|
} catch (err) {
|
|
71
|
-
loadErrors.push(err)
|
|
73
|
+
loadErrors.push(err);
|
|
72
74
|
}
|
|
73
|
-
} else if (process.platform ===
|
|
74
|
-
if (process.arch ===
|
|
75
|
+
} else if (process.platform === "android") {
|
|
76
|
+
if (process.arch === "arm64") {
|
|
75
77
|
try {
|
|
76
|
-
return require(
|
|
78
|
+
return require("./yara-x.android-arm64.node");
|
|
77
79
|
} catch (e) {
|
|
78
|
-
loadErrors.push(e)
|
|
80
|
+
loadErrors.push(e);
|
|
79
81
|
}
|
|
80
82
|
try {
|
|
81
|
-
const binding = require(
|
|
82
|
-
const bindingPackageVersion =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
const binding = require("@litko/yara-x-android-arm64");
|
|
84
|
+
const bindingPackageVersion =
|
|
85
|
+
require("@litko/yara-x-android-arm64/package.json").version;
|
|
86
|
+
if (
|
|
87
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
88
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
89
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
90
|
+
) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return binding;
|
|
87
96
|
} catch (e) {
|
|
88
|
-
loadErrors.push(e)
|
|
97
|
+
loadErrors.push(e);
|
|
89
98
|
}
|
|
90
|
-
} else if (process.arch ===
|
|
99
|
+
} else if (process.arch === "arm") {
|
|
91
100
|
try {
|
|
92
|
-
return require(
|
|
101
|
+
return require("./yara-x.android-arm-eabi.node");
|
|
93
102
|
} catch (e) {
|
|
94
|
-
loadErrors.push(e)
|
|
103
|
+
loadErrors.push(e);
|
|
95
104
|
}
|
|
96
105
|
try {
|
|
97
|
-
const binding = require(
|
|
98
|
-
const bindingPackageVersion =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
const binding = require("@litko/yara-x-android-arm-eabi");
|
|
107
|
+
const bindingPackageVersion =
|
|
108
|
+
require("@litko/yara-x-android-arm-eabi/package.json").version;
|
|
109
|
+
if (
|
|
110
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
111
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
112
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
113
|
+
) {
|
|
114
|
+
throw new Error(
|
|
115
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return binding;
|
|
103
119
|
} catch (e) {
|
|
104
|
-
loadErrors.push(e)
|
|
120
|
+
loadErrors.push(e);
|
|
105
121
|
}
|
|
106
122
|
} else {
|
|
107
|
-
loadErrors.push(
|
|
123
|
+
loadErrors.push(
|
|
124
|
+
new Error(`Unsupported architecture on Android ${process.arch}`),
|
|
125
|
+
);
|
|
108
126
|
}
|
|
109
|
-
} else if (process.platform ===
|
|
110
|
-
if (process.arch ===
|
|
111
|
-
if (
|
|
127
|
+
} else if (process.platform === "win32") {
|
|
128
|
+
if (process.arch === "x64") {
|
|
129
|
+
if (
|
|
130
|
+
process.report?.getReport?.()?.header?.osName?.startsWith?.("MINGW")
|
|
131
|
+
) {
|
|
112
132
|
try {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
return require("./yara-x.win32-x64-gnu.node");
|
|
134
|
+
} catch (e) {
|
|
135
|
+
loadErrors.push(e);
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const binding = require("@litko/yara-x-win32-x64-gnu");
|
|
139
|
+
const bindingPackageVersion =
|
|
140
|
+
require("@litko/yara-x-win32-x64-gnu/package.json").version;
|
|
141
|
+
if (
|
|
142
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
143
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
144
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
145
|
+
) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
return binding;
|
|
151
|
+
} catch (e) {
|
|
152
|
+
loadErrors.push(e);
|
|
122
153
|
}
|
|
123
|
-
return binding
|
|
124
|
-
} catch (e) {
|
|
125
|
-
loadErrors.push(e)
|
|
126
|
-
}
|
|
127
154
|
} else {
|
|
128
155
|
try {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
156
|
+
return require("./yara-x.win32-x64-msvc.node");
|
|
157
|
+
} catch (e) {
|
|
158
|
+
loadErrors.push(e);
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
const binding = require("@litko/yara-x-win32-x64-msvc");
|
|
162
|
+
const bindingPackageVersion =
|
|
163
|
+
require("@litko/yara-x-win32-x64-msvc/package.json").version;
|
|
164
|
+
if (
|
|
165
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
166
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
167
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
168
|
+
) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return binding;
|
|
174
|
+
} catch (e) {
|
|
175
|
+
loadErrors.push(e);
|
|
138
176
|
}
|
|
139
|
-
return binding
|
|
140
|
-
} catch (e) {
|
|
141
|
-
loadErrors.push(e)
|
|
142
|
-
}
|
|
143
177
|
}
|
|
144
|
-
} else if (process.arch ===
|
|
178
|
+
} else if (process.arch === "ia32") {
|
|
145
179
|
try {
|
|
146
|
-
return require(
|
|
180
|
+
return require("./yara-x.win32-ia32-msvc.node");
|
|
147
181
|
} catch (e) {
|
|
148
|
-
loadErrors.push(e)
|
|
182
|
+
loadErrors.push(e);
|
|
149
183
|
}
|
|
150
184
|
try {
|
|
151
|
-
const binding = require(
|
|
152
|
-
const bindingPackageVersion =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
185
|
+
const binding = require("@litko/yara-x-win32-ia32-msvc");
|
|
186
|
+
const bindingPackageVersion =
|
|
187
|
+
require("@litko/yara-x-win32-ia32-msvc/package.json").version;
|
|
188
|
+
if (
|
|
189
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
190
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
191
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
192
|
+
) {
|
|
193
|
+
throw new Error(
|
|
194
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return binding;
|
|
157
198
|
} catch (e) {
|
|
158
|
-
loadErrors.push(e)
|
|
199
|
+
loadErrors.push(e);
|
|
159
200
|
}
|
|
160
|
-
} else if (process.arch ===
|
|
201
|
+
} else if (process.arch === "arm64") {
|
|
161
202
|
try {
|
|
162
|
-
return require(
|
|
203
|
+
return require("./yara-x.win32-arm64-msvc.node");
|
|
163
204
|
} catch (e) {
|
|
164
|
-
loadErrors.push(e)
|
|
205
|
+
loadErrors.push(e);
|
|
165
206
|
}
|
|
166
207
|
try {
|
|
167
|
-
const binding = require(
|
|
168
|
-
const bindingPackageVersion =
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
208
|
+
const binding = require("@litko/yara-x-win32-arm64-msvc");
|
|
209
|
+
const bindingPackageVersion =
|
|
210
|
+
require("@litko/yara-x-win32-arm64-msvc/package.json").version;
|
|
211
|
+
if (
|
|
212
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
213
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
214
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
215
|
+
) {
|
|
216
|
+
throw new Error(
|
|
217
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
return binding;
|
|
173
221
|
} catch (e) {
|
|
174
|
-
loadErrors.push(e)
|
|
222
|
+
loadErrors.push(e);
|
|
175
223
|
}
|
|
176
224
|
} else {
|
|
177
|
-
loadErrors.push(
|
|
225
|
+
loadErrors.push(
|
|
226
|
+
new Error(`Unsupported architecture on Windows: ${process.arch}`),
|
|
227
|
+
);
|
|
178
228
|
}
|
|
179
|
-
} else if (process.platform ===
|
|
229
|
+
} else if (process.platform === "darwin") {
|
|
180
230
|
try {
|
|
181
|
-
return require(
|
|
231
|
+
return require("./yara-x.darwin-universal.node");
|
|
182
232
|
} catch (e) {
|
|
183
|
-
loadErrors.push(e)
|
|
233
|
+
loadErrors.push(e);
|
|
184
234
|
}
|
|
185
235
|
try {
|
|
186
|
-
const binding = require(
|
|
187
|
-
const bindingPackageVersion =
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
236
|
+
const binding = require("@litko/yara-x-darwin-universal");
|
|
237
|
+
const bindingPackageVersion =
|
|
238
|
+
require("@litko/yara-x-darwin-universal/package.json").version;
|
|
239
|
+
if (
|
|
240
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
241
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
242
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
243
|
+
) {
|
|
244
|
+
throw new Error(
|
|
245
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
return binding;
|
|
192
249
|
} catch (e) {
|
|
193
|
-
loadErrors.push(e)
|
|
250
|
+
loadErrors.push(e);
|
|
194
251
|
}
|
|
195
|
-
if (process.arch ===
|
|
252
|
+
if (process.arch === "x64") {
|
|
196
253
|
try {
|
|
197
|
-
return require(
|
|
254
|
+
return require("./yara-x.darwin-x64.node");
|
|
198
255
|
} catch (e) {
|
|
199
|
-
loadErrors.push(e)
|
|
256
|
+
loadErrors.push(e);
|
|
200
257
|
}
|
|
201
258
|
try {
|
|
202
|
-
const binding = require(
|
|
203
|
-
const bindingPackageVersion =
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
259
|
+
const binding = require("@litko/yara-x-darwin-x64");
|
|
260
|
+
const bindingPackageVersion =
|
|
261
|
+
require("@litko/yara-x-darwin-x64/package.json").version;
|
|
262
|
+
if (
|
|
263
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
264
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
265
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
266
|
+
) {
|
|
267
|
+
throw new Error(
|
|
268
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
return binding;
|
|
208
272
|
} catch (e) {
|
|
209
|
-
loadErrors.push(e)
|
|
273
|
+
loadErrors.push(e);
|
|
210
274
|
}
|
|
211
|
-
} else if (process.arch ===
|
|
275
|
+
} else if (process.arch === "arm64") {
|
|
212
276
|
try {
|
|
213
|
-
return require(
|
|
277
|
+
return require("./yara-x.darwin-arm64.node");
|
|
214
278
|
} catch (e) {
|
|
215
|
-
loadErrors.push(e)
|
|
279
|
+
loadErrors.push(e);
|
|
216
280
|
}
|
|
217
281
|
try {
|
|
218
|
-
const binding = require(
|
|
219
|
-
const bindingPackageVersion =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
282
|
+
const binding = require("@litko/yara-x-darwin-arm64");
|
|
283
|
+
const bindingPackageVersion =
|
|
284
|
+
require("@litko/yara-x-darwin-arm64/package.json").version;
|
|
285
|
+
if (
|
|
286
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
287
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
288
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
289
|
+
) {
|
|
290
|
+
throw new Error(
|
|
291
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
return binding;
|
|
224
295
|
} catch (e) {
|
|
225
|
-
loadErrors.push(e)
|
|
296
|
+
loadErrors.push(e);
|
|
226
297
|
}
|
|
227
298
|
} else {
|
|
228
|
-
loadErrors.push(
|
|
299
|
+
loadErrors.push(
|
|
300
|
+
new Error(`Unsupported architecture on macOS: ${process.arch}`),
|
|
301
|
+
);
|
|
229
302
|
}
|
|
230
|
-
} else if (process.platform ===
|
|
231
|
-
if (process.arch ===
|
|
303
|
+
} else if (process.platform === "freebsd") {
|
|
304
|
+
if (process.arch === "x64") {
|
|
232
305
|
try {
|
|
233
|
-
return require(
|
|
306
|
+
return require("./yara-x.freebsd-x64.node");
|
|
234
307
|
} catch (e) {
|
|
235
|
-
loadErrors.push(e)
|
|
308
|
+
loadErrors.push(e);
|
|
236
309
|
}
|
|
237
310
|
try {
|
|
238
|
-
const binding = require(
|
|
239
|
-
const bindingPackageVersion =
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
311
|
+
const binding = require("@litko/yara-x-freebsd-x64");
|
|
312
|
+
const bindingPackageVersion =
|
|
313
|
+
require("@litko/yara-x-freebsd-x64/package.json").version;
|
|
314
|
+
if (
|
|
315
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
316
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
317
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
318
|
+
) {
|
|
319
|
+
throw new Error(
|
|
320
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
return binding;
|
|
244
324
|
} catch (e) {
|
|
245
|
-
loadErrors.push(e)
|
|
325
|
+
loadErrors.push(e);
|
|
246
326
|
}
|
|
247
|
-
} else if (process.arch ===
|
|
327
|
+
} else if (process.arch === "arm64") {
|
|
248
328
|
try {
|
|
249
|
-
return require(
|
|
329
|
+
return require("./yara-x.freebsd-arm64.node");
|
|
250
330
|
} catch (e) {
|
|
251
|
-
loadErrors.push(e)
|
|
331
|
+
loadErrors.push(e);
|
|
252
332
|
}
|
|
253
333
|
try {
|
|
254
|
-
const binding = require(
|
|
255
|
-
const bindingPackageVersion =
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
334
|
+
const binding = require("@litko/yara-x-freebsd-arm64");
|
|
335
|
+
const bindingPackageVersion =
|
|
336
|
+
require("@litko/yara-x-freebsd-arm64/package.json").version;
|
|
337
|
+
if (
|
|
338
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
339
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
340
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
341
|
+
) {
|
|
342
|
+
throw new Error(
|
|
343
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
return binding;
|
|
260
347
|
} catch (e) {
|
|
261
|
-
loadErrors.push(e)
|
|
348
|
+
loadErrors.push(e);
|
|
262
349
|
}
|
|
263
350
|
} else {
|
|
264
|
-
loadErrors.push(
|
|
351
|
+
loadErrors.push(
|
|
352
|
+
new Error(`Unsupported architecture on FreeBSD: ${process.arch}`),
|
|
353
|
+
);
|
|
265
354
|
}
|
|
266
|
-
} else if (process.platform ===
|
|
267
|
-
if (process.arch ===
|
|
355
|
+
} else if (process.platform === "linux") {
|
|
356
|
+
if (process.arch === "x64") {
|
|
268
357
|
if (isMusl()) {
|
|
269
358
|
try {
|
|
270
|
-
return require(
|
|
359
|
+
return require("./yara-x.linux-x64-musl.node");
|
|
271
360
|
} catch (e) {
|
|
272
|
-
loadErrors.push(e)
|
|
361
|
+
loadErrors.push(e);
|
|
273
362
|
}
|
|
274
363
|
try {
|
|
275
|
-
const binding = require(
|
|
276
|
-
const bindingPackageVersion =
|
|
277
|
-
|
|
278
|
-
|
|
364
|
+
const binding = require("@litko/yara-x-linux-x64-musl");
|
|
365
|
+
const bindingPackageVersion =
|
|
366
|
+
require("@litko/yara-x-linux-x64-musl/package.json").version;
|
|
367
|
+
if (
|
|
368
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
369
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
370
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
371
|
+
) {
|
|
372
|
+
throw new Error(
|
|
373
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
374
|
+
);
|
|
279
375
|
}
|
|
280
|
-
return binding
|
|
376
|
+
return binding;
|
|
281
377
|
} catch (e) {
|
|
282
|
-
loadErrors.push(e)
|
|
378
|
+
loadErrors.push(e);
|
|
283
379
|
}
|
|
284
380
|
} else {
|
|
285
381
|
try {
|
|
286
|
-
return require(
|
|
382
|
+
return require("./yara-x.linux-x64-gnu.node");
|
|
287
383
|
} catch (e) {
|
|
288
|
-
loadErrors.push(e)
|
|
384
|
+
loadErrors.push(e);
|
|
289
385
|
}
|
|
290
386
|
try {
|
|
291
|
-
const binding = require(
|
|
292
|
-
const bindingPackageVersion =
|
|
293
|
-
|
|
294
|
-
|
|
387
|
+
const binding = require("@litko/yara-x-linux-x64-gnu");
|
|
388
|
+
const bindingPackageVersion =
|
|
389
|
+
require("@litko/yara-x-linux-x64-gnu/package.json").version;
|
|
390
|
+
if (
|
|
391
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
392
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
393
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
394
|
+
) {
|
|
395
|
+
throw new Error(
|
|
396
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
397
|
+
);
|
|
295
398
|
}
|
|
296
|
-
return binding
|
|
399
|
+
return binding;
|
|
297
400
|
} catch (e) {
|
|
298
|
-
loadErrors.push(e)
|
|
401
|
+
loadErrors.push(e);
|
|
299
402
|
}
|
|
300
403
|
}
|
|
301
|
-
} else if (process.arch ===
|
|
404
|
+
} else if (process.arch === "arm64") {
|
|
302
405
|
if (isMusl()) {
|
|
303
406
|
try {
|
|
304
|
-
return require(
|
|
407
|
+
return require("./yara-x.linux-arm64-musl.node");
|
|
305
408
|
} catch (e) {
|
|
306
|
-
loadErrors.push(e)
|
|
409
|
+
loadErrors.push(e);
|
|
307
410
|
}
|
|
308
411
|
try {
|
|
309
|
-
const binding = require(
|
|
310
|
-
const bindingPackageVersion =
|
|
311
|
-
|
|
312
|
-
|
|
412
|
+
const binding = require("@litko/yara-x-linux-arm64-musl");
|
|
413
|
+
const bindingPackageVersion =
|
|
414
|
+
require("@litko/yara-x-linux-arm64-musl/package.json").version;
|
|
415
|
+
if (
|
|
416
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
417
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
418
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
419
|
+
) {
|
|
420
|
+
throw new Error(
|
|
421
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
422
|
+
);
|
|
313
423
|
}
|
|
314
|
-
return binding
|
|
424
|
+
return binding;
|
|
315
425
|
} catch (e) {
|
|
316
|
-
loadErrors.push(e)
|
|
426
|
+
loadErrors.push(e);
|
|
317
427
|
}
|
|
318
428
|
} else {
|
|
319
429
|
try {
|
|
320
|
-
return require(
|
|
430
|
+
return require("./yara-x.linux-arm64-gnu.node");
|
|
321
431
|
} catch (e) {
|
|
322
|
-
loadErrors.push(e)
|
|
432
|
+
loadErrors.push(e);
|
|
323
433
|
}
|
|
324
434
|
try {
|
|
325
|
-
const binding = require(
|
|
326
|
-
const bindingPackageVersion =
|
|
327
|
-
|
|
328
|
-
|
|
435
|
+
const binding = require("@litko/yara-x-linux-arm64-gnu");
|
|
436
|
+
const bindingPackageVersion =
|
|
437
|
+
require("@litko/yara-x-linux-arm64-gnu/package.json").version;
|
|
438
|
+
if (
|
|
439
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
440
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
441
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
442
|
+
) {
|
|
443
|
+
throw new Error(
|
|
444
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
445
|
+
);
|
|
329
446
|
}
|
|
330
|
-
return binding
|
|
447
|
+
return binding;
|
|
331
448
|
} catch (e) {
|
|
332
|
-
loadErrors.push(e)
|
|
449
|
+
loadErrors.push(e);
|
|
333
450
|
}
|
|
334
451
|
}
|
|
335
|
-
} else if (process.arch ===
|
|
452
|
+
} else if (process.arch === "arm") {
|
|
336
453
|
if (isMusl()) {
|
|
337
454
|
try {
|
|
338
|
-
return require(
|
|
455
|
+
return require("./yara-x.linux-arm-musleabihf.node");
|
|
339
456
|
} catch (e) {
|
|
340
|
-
loadErrors.push(e)
|
|
457
|
+
loadErrors.push(e);
|
|
341
458
|
}
|
|
342
459
|
try {
|
|
343
|
-
const binding = require(
|
|
344
|
-
const bindingPackageVersion =
|
|
345
|
-
|
|
346
|
-
|
|
460
|
+
const binding = require("@litko/yara-x-linux-arm-musleabihf");
|
|
461
|
+
const bindingPackageVersion =
|
|
462
|
+
require("@litko/yara-x-linux-arm-musleabihf/package.json").version;
|
|
463
|
+
if (
|
|
464
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
465
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
466
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
467
|
+
) {
|
|
468
|
+
throw new Error(
|
|
469
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
470
|
+
);
|
|
347
471
|
}
|
|
348
|
-
return binding
|
|
472
|
+
return binding;
|
|
349
473
|
} catch (e) {
|
|
350
|
-
loadErrors.push(e)
|
|
474
|
+
loadErrors.push(e);
|
|
351
475
|
}
|
|
352
476
|
} else {
|
|
353
477
|
try {
|
|
354
|
-
return require(
|
|
478
|
+
return require("./yara-x.linux-arm-gnueabihf.node");
|
|
355
479
|
} catch (e) {
|
|
356
|
-
loadErrors.push(e)
|
|
480
|
+
loadErrors.push(e);
|
|
357
481
|
}
|
|
358
482
|
try {
|
|
359
|
-
const binding = require(
|
|
360
|
-
const bindingPackageVersion =
|
|
361
|
-
|
|
362
|
-
|
|
483
|
+
const binding = require("@litko/yara-x-linux-arm-gnueabihf");
|
|
484
|
+
const bindingPackageVersion =
|
|
485
|
+
require("@litko/yara-x-linux-arm-gnueabihf/package.json").version;
|
|
486
|
+
if (
|
|
487
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
488
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
489
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
490
|
+
) {
|
|
491
|
+
throw new Error(
|
|
492
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
493
|
+
);
|
|
363
494
|
}
|
|
364
|
-
return binding
|
|
495
|
+
return binding;
|
|
365
496
|
} catch (e) {
|
|
366
|
-
loadErrors.push(e)
|
|
497
|
+
loadErrors.push(e);
|
|
367
498
|
}
|
|
368
499
|
}
|
|
369
|
-
} else if (process.arch ===
|
|
500
|
+
} else if (process.arch === "loong64") {
|
|
370
501
|
if (isMusl()) {
|
|
371
502
|
try {
|
|
372
|
-
return require(
|
|
503
|
+
return require("./yara-x.linux-loong64-musl.node");
|
|
373
504
|
} catch (e) {
|
|
374
|
-
loadErrors.push(e)
|
|
505
|
+
loadErrors.push(e);
|
|
375
506
|
}
|
|
376
507
|
try {
|
|
377
|
-
const binding = require(
|
|
378
|
-
const bindingPackageVersion =
|
|
379
|
-
|
|
380
|
-
|
|
508
|
+
const binding = require("@litko/yara-x-linux-loong64-musl");
|
|
509
|
+
const bindingPackageVersion =
|
|
510
|
+
require("@litko/yara-x-linux-loong64-musl/package.json").version;
|
|
511
|
+
if (
|
|
512
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
513
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
514
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
515
|
+
) {
|
|
516
|
+
throw new Error(
|
|
517
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
518
|
+
);
|
|
381
519
|
}
|
|
382
|
-
return binding
|
|
520
|
+
return binding;
|
|
383
521
|
} catch (e) {
|
|
384
|
-
loadErrors.push(e)
|
|
522
|
+
loadErrors.push(e);
|
|
385
523
|
}
|
|
386
524
|
} else {
|
|
387
525
|
try {
|
|
388
|
-
return require(
|
|
526
|
+
return require("./yara-x.linux-loong64-gnu.node");
|
|
389
527
|
} catch (e) {
|
|
390
|
-
loadErrors.push(e)
|
|
528
|
+
loadErrors.push(e);
|
|
391
529
|
}
|
|
392
530
|
try {
|
|
393
|
-
const binding = require(
|
|
394
|
-
const bindingPackageVersion =
|
|
395
|
-
|
|
396
|
-
|
|
531
|
+
const binding = require("@litko/yara-x-linux-loong64-gnu");
|
|
532
|
+
const bindingPackageVersion =
|
|
533
|
+
require("@litko/yara-x-linux-loong64-gnu/package.json").version;
|
|
534
|
+
if (
|
|
535
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
536
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
537
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
538
|
+
) {
|
|
539
|
+
throw new Error(
|
|
540
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
541
|
+
);
|
|
397
542
|
}
|
|
398
|
-
return binding
|
|
543
|
+
return binding;
|
|
399
544
|
} catch (e) {
|
|
400
|
-
loadErrors.push(e)
|
|
545
|
+
loadErrors.push(e);
|
|
401
546
|
}
|
|
402
547
|
}
|
|
403
|
-
} else if (process.arch ===
|
|
548
|
+
} else if (process.arch === "riscv64") {
|
|
404
549
|
if (isMusl()) {
|
|
405
550
|
try {
|
|
406
|
-
return require(
|
|
551
|
+
return require("./yara-x.linux-riscv64-musl.node");
|
|
407
552
|
} catch (e) {
|
|
408
|
-
loadErrors.push(e)
|
|
553
|
+
loadErrors.push(e);
|
|
409
554
|
}
|
|
410
555
|
try {
|
|
411
|
-
const binding = require(
|
|
412
|
-
const bindingPackageVersion =
|
|
413
|
-
|
|
414
|
-
|
|
556
|
+
const binding = require("@litko/yara-x-linux-riscv64-musl");
|
|
557
|
+
const bindingPackageVersion =
|
|
558
|
+
require("@litko/yara-x-linux-riscv64-musl/package.json").version;
|
|
559
|
+
if (
|
|
560
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
561
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
562
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
563
|
+
) {
|
|
564
|
+
throw new Error(
|
|
565
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
566
|
+
);
|
|
415
567
|
}
|
|
416
|
-
return binding
|
|
568
|
+
return binding;
|
|
417
569
|
} catch (e) {
|
|
418
|
-
loadErrors.push(e)
|
|
570
|
+
loadErrors.push(e);
|
|
419
571
|
}
|
|
420
572
|
} else {
|
|
421
573
|
try {
|
|
422
|
-
return require(
|
|
574
|
+
return require("./yara-x.linux-riscv64-gnu.node");
|
|
423
575
|
} catch (e) {
|
|
424
|
-
loadErrors.push(e)
|
|
576
|
+
loadErrors.push(e);
|
|
425
577
|
}
|
|
426
578
|
try {
|
|
427
|
-
const binding = require(
|
|
428
|
-
const bindingPackageVersion =
|
|
429
|
-
|
|
430
|
-
|
|
579
|
+
const binding = require("@litko/yara-x-linux-riscv64-gnu");
|
|
580
|
+
const bindingPackageVersion =
|
|
581
|
+
require("@litko/yara-x-linux-riscv64-gnu/package.json").version;
|
|
582
|
+
if (
|
|
583
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
584
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
585
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
586
|
+
) {
|
|
587
|
+
throw new Error(
|
|
588
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
589
|
+
);
|
|
431
590
|
}
|
|
432
|
-
return binding
|
|
591
|
+
return binding;
|
|
433
592
|
} catch (e) {
|
|
434
|
-
loadErrors.push(e)
|
|
593
|
+
loadErrors.push(e);
|
|
435
594
|
}
|
|
436
595
|
}
|
|
437
|
-
} else if (process.arch ===
|
|
596
|
+
} else if (process.arch === "ppc64") {
|
|
438
597
|
try {
|
|
439
|
-
return require(
|
|
598
|
+
return require("./yara-x.linux-ppc64-gnu.node");
|
|
440
599
|
} catch (e) {
|
|
441
|
-
loadErrors.push(e)
|
|
600
|
+
loadErrors.push(e);
|
|
442
601
|
}
|
|
443
602
|
try {
|
|
444
|
-
const binding = require(
|
|
445
|
-
const bindingPackageVersion =
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
603
|
+
const binding = require("@litko/yara-x-linux-ppc64-gnu");
|
|
604
|
+
const bindingPackageVersion =
|
|
605
|
+
require("@litko/yara-x-linux-ppc64-gnu/package.json").version;
|
|
606
|
+
if (
|
|
607
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
608
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
609
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
610
|
+
) {
|
|
611
|
+
throw new Error(
|
|
612
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
return binding;
|
|
450
616
|
} catch (e) {
|
|
451
|
-
loadErrors.push(e)
|
|
617
|
+
loadErrors.push(e);
|
|
452
618
|
}
|
|
453
|
-
} else if (process.arch ===
|
|
619
|
+
} else if (process.arch === "s390x") {
|
|
454
620
|
try {
|
|
455
|
-
return require(
|
|
621
|
+
return require("./yara-x.linux-s390x-gnu.node");
|
|
456
622
|
} catch (e) {
|
|
457
|
-
loadErrors.push(e)
|
|
623
|
+
loadErrors.push(e);
|
|
458
624
|
}
|
|
459
625
|
try {
|
|
460
|
-
const binding = require(
|
|
461
|
-
const bindingPackageVersion =
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
626
|
+
const binding = require("@litko/yara-x-linux-s390x-gnu");
|
|
627
|
+
const bindingPackageVersion =
|
|
628
|
+
require("@litko/yara-x-linux-s390x-gnu/package.json").version;
|
|
629
|
+
if (
|
|
630
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
631
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
632
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
633
|
+
) {
|
|
634
|
+
throw new Error(
|
|
635
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
return binding;
|
|
466
639
|
} catch (e) {
|
|
467
|
-
loadErrors.push(e)
|
|
640
|
+
loadErrors.push(e);
|
|
468
641
|
}
|
|
469
642
|
} else {
|
|
470
|
-
loadErrors.push(
|
|
643
|
+
loadErrors.push(
|
|
644
|
+
new Error(`Unsupported architecture on Linux: ${process.arch}`),
|
|
645
|
+
);
|
|
471
646
|
}
|
|
472
|
-
} else if (process.platform ===
|
|
473
|
-
if (process.arch ===
|
|
647
|
+
} else if (process.platform === "openharmony") {
|
|
648
|
+
if (process.arch === "arm64") {
|
|
474
649
|
try {
|
|
475
|
-
return require(
|
|
650
|
+
return require("./yara-x.openharmony-arm64.node");
|
|
476
651
|
} catch (e) {
|
|
477
|
-
loadErrors.push(e)
|
|
652
|
+
loadErrors.push(e);
|
|
478
653
|
}
|
|
479
654
|
try {
|
|
480
|
-
const binding = require(
|
|
481
|
-
const bindingPackageVersion =
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
655
|
+
const binding = require("@litko/yara-x-openharmony-arm64");
|
|
656
|
+
const bindingPackageVersion =
|
|
657
|
+
require("@litko/yara-x-openharmony-arm64/package.json").version;
|
|
658
|
+
if (
|
|
659
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
660
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
661
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
662
|
+
) {
|
|
663
|
+
throw new Error(
|
|
664
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
return binding;
|
|
486
668
|
} catch (e) {
|
|
487
|
-
loadErrors.push(e)
|
|
669
|
+
loadErrors.push(e);
|
|
488
670
|
}
|
|
489
|
-
} else if (process.arch ===
|
|
671
|
+
} else if (process.arch === "x64") {
|
|
490
672
|
try {
|
|
491
|
-
return require(
|
|
673
|
+
return require("./yara-x.openharmony-x64.node");
|
|
492
674
|
} catch (e) {
|
|
493
|
-
loadErrors.push(e)
|
|
675
|
+
loadErrors.push(e);
|
|
494
676
|
}
|
|
495
677
|
try {
|
|
496
|
-
const binding = require(
|
|
497
|
-
const bindingPackageVersion =
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
678
|
+
const binding = require("@litko/yara-x-openharmony-x64");
|
|
679
|
+
const bindingPackageVersion =
|
|
680
|
+
require("@litko/yara-x-openharmony-x64/package.json").version;
|
|
681
|
+
if (
|
|
682
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
683
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
684
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
685
|
+
) {
|
|
686
|
+
throw new Error(
|
|
687
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
return binding;
|
|
502
691
|
} catch (e) {
|
|
503
|
-
loadErrors.push(e)
|
|
692
|
+
loadErrors.push(e);
|
|
504
693
|
}
|
|
505
|
-
} else if (process.arch ===
|
|
694
|
+
} else if (process.arch === "arm") {
|
|
506
695
|
try {
|
|
507
|
-
return require(
|
|
696
|
+
return require("./yara-x.openharmony-arm.node");
|
|
508
697
|
} catch (e) {
|
|
509
|
-
loadErrors.push(e)
|
|
698
|
+
loadErrors.push(e);
|
|
510
699
|
}
|
|
511
700
|
try {
|
|
512
|
-
const binding = require(
|
|
513
|
-
const bindingPackageVersion =
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
701
|
+
const binding = require("@litko/yara-x-openharmony-arm");
|
|
702
|
+
const bindingPackageVersion =
|
|
703
|
+
require("@litko/yara-x-openharmony-arm/package.json").version;
|
|
704
|
+
if (
|
|
705
|
+
bindingPackageVersion !== "0.4.0" &&
|
|
706
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
707
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
708
|
+
) {
|
|
709
|
+
throw new Error(
|
|
710
|
+
`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
return binding;
|
|
518
714
|
} catch (e) {
|
|
519
|
-
loadErrors.push(e)
|
|
715
|
+
loadErrors.push(e);
|
|
520
716
|
}
|
|
521
717
|
} else {
|
|
522
|
-
loadErrors.push(
|
|
718
|
+
loadErrors.push(
|
|
719
|
+
new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`),
|
|
720
|
+
);
|
|
523
721
|
}
|
|
524
722
|
} else {
|
|
525
|
-
loadErrors.push(
|
|
723
|
+
loadErrors.push(
|
|
724
|
+
new Error(
|
|
725
|
+
`Unsupported OS: ${process.platform}, architecture: ${process.arch}`,
|
|
726
|
+
),
|
|
727
|
+
);
|
|
526
728
|
}
|
|
527
729
|
}
|
|
528
730
|
|
|
529
|
-
nativeBinding = requireNative()
|
|
731
|
+
nativeBinding = requireNative();
|
|
530
732
|
|
|
531
733
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
532
|
-
let wasiBinding = null
|
|
533
|
-
let wasiBindingError = null
|
|
734
|
+
let wasiBinding = null;
|
|
735
|
+
let wasiBindingError = null;
|
|
534
736
|
try {
|
|
535
|
-
wasiBinding = require(
|
|
536
|
-
nativeBinding = wasiBinding
|
|
737
|
+
wasiBinding = require("./yara-x.wasi.cjs");
|
|
738
|
+
nativeBinding = wasiBinding;
|
|
537
739
|
} catch (err) {
|
|
538
740
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
539
|
-
wasiBindingError = err
|
|
741
|
+
wasiBindingError = err;
|
|
540
742
|
}
|
|
541
743
|
}
|
|
542
744
|
if (!nativeBinding) {
|
|
543
745
|
try {
|
|
544
|
-
wasiBinding = require(
|
|
545
|
-
nativeBinding = wasiBinding
|
|
746
|
+
wasiBinding = require("@litko/yara-x-wasm32-wasi");
|
|
747
|
+
nativeBinding = wasiBinding;
|
|
546
748
|
} catch (err) {
|
|
547
749
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
548
|
-
wasiBindingError.cause = err
|
|
549
|
-
loadErrors.push(err)
|
|
750
|
+
wasiBindingError.cause = err;
|
|
751
|
+
loadErrors.push(err);
|
|
550
752
|
}
|
|
551
753
|
}
|
|
552
754
|
}
|
|
553
|
-
if (process.env.NAPI_RS_FORCE_WASI ===
|
|
554
|
-
const error = new Error(
|
|
555
|
-
|
|
556
|
-
|
|
755
|
+
if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
|
|
756
|
+
const error = new Error(
|
|
757
|
+
"WASI binding not found and NAPI_RS_FORCE_WASI is set to error",
|
|
758
|
+
);
|
|
759
|
+
error.cause = wasiBindingError;
|
|
760
|
+
throw error;
|
|
557
761
|
}
|
|
558
762
|
}
|
|
559
763
|
|
|
@@ -562,23 +766,23 @@ if (!nativeBinding) {
|
|
|
562
766
|
throw new Error(
|
|
563
767
|
`Cannot find native binding. ` +
|
|
564
768
|
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
565
|
-
|
|
769
|
+
"Please try `npm i` again after removing both package-lock.json and node_modules directory.",
|
|
566
770
|
{
|
|
567
771
|
cause: loadErrors.reduce((err, cur) => {
|
|
568
|
-
cur.cause = err
|
|
569
|
-
return cur
|
|
772
|
+
cur.cause = err;
|
|
773
|
+
return cur;
|
|
570
774
|
}),
|
|
571
775
|
},
|
|
572
|
-
)
|
|
776
|
+
);
|
|
573
777
|
}
|
|
574
|
-
throw new Error(`Failed to load native binding`)
|
|
778
|
+
throw new Error(`Failed to load native binding`);
|
|
575
779
|
}
|
|
576
780
|
|
|
577
|
-
module.exports = nativeBinding
|
|
578
|
-
module.exports.YaraX = nativeBinding.YaraX
|
|
579
|
-
module.exports.compile = nativeBinding.compile
|
|
580
|
-
module.exports.compileFileToWasm = nativeBinding.compileFileToWasm
|
|
581
|
-
module.exports.compileToWasm = nativeBinding.compileToWasm
|
|
582
|
-
module.exports.create = nativeBinding.create
|
|
583
|
-
module.exports.fromFile = nativeBinding.fromFile
|
|
584
|
-
module.exports.validate = nativeBinding.validate
|
|
781
|
+
module.exports = nativeBinding;
|
|
782
|
+
module.exports.YaraX = nativeBinding.YaraX;
|
|
783
|
+
module.exports.compile = nativeBinding.compile;
|
|
784
|
+
module.exports.compileFileToWasm = nativeBinding.compileFileToWasm;
|
|
785
|
+
module.exports.compileToWasm = nativeBinding.compileToWasm;
|
|
786
|
+
module.exports.create = nativeBinding.create;
|
|
787
|
+
module.exports.fromFile = nativeBinding.fromFile;
|
|
788
|
+
module.exports.validate = nativeBinding.validate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litko/yara-x",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"packageManager": "pnpm@10.18.0",
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"targets": [
|
|
10
10
|
"x86_64-apple-darwin",
|
|
11
11
|
"aarch64-apple-darwin",
|
|
12
|
-
"x86_64-unknown-linux-gnu"
|
|
12
|
+
"x86_64-unknown-linux-gnu",
|
|
13
|
+
"x86_64-pc-windows-msvc",
|
|
14
|
+
"aarch64-pc-windows-msvc",
|
|
15
|
+
"aarch64-unknown-linux-gnu"
|
|
13
16
|
]
|
|
14
17
|
},
|
|
15
18
|
"license": "MIT",
|
|
@@ -59,8 +62,11 @@
|
|
|
59
62
|
"rust"
|
|
60
63
|
],
|
|
61
64
|
"optionalDependencies": {
|
|
62
|
-
"@litko/yara-x-darwin-x64": "0.
|
|
63
|
-
"@litko/yara-x-darwin-arm64": "0.
|
|
64
|
-
"@litko/yara-x-linux-x64-gnu": "0.
|
|
65
|
+
"@litko/yara-x-darwin-x64": "0.5.0",
|
|
66
|
+
"@litko/yara-x-darwin-arm64": "0.5.0",
|
|
67
|
+
"@litko/yara-x-linux-x64-gnu": "0.5.0",
|
|
68
|
+
"@litko/yara-x-win32-x64-msvc": "0.5.0",
|
|
69
|
+
"@litko/yara-x-win32-arm64-msvc": "0.5.0",
|
|
70
|
+
"@litko/yara-x-linux-arm64-gnu": "0.5.0"
|
|
65
71
|
}
|
|
66
72
|
}
|