Skip to content

Commit fa36cde

Browse files
authored
Merge pull request #161 from ecubus/fix-sa-in-macos
[opt]:make secureAccess work in windows only
2 parents b34a25c + bb9315f commit fa36cde

File tree

9 files changed

+63
-16
lines changed

9 files changed

+63
-16
lines changed

resources/lib/js/crc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/lib/js/cryptoExt.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/lib/js/sa.node

15.5 KB
Binary file not shown.

resources/lib/js/uds.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/lib/js/uds.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/lib/js/utli.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/share/uds.d.ts.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,8 @@
928928
private addr?;
929929
constructor(testerName: string, service: ServiceItem, addr?: UdsAddress);
930930
/**
931-
* Get the UDS address of the response.
932-
* @returns UdsAddress
931+
* Get the UDS address of the response. The address may be undefined if not set.
932+
* @returns {UdsAddress | undefined} The UDS address if set, undefined otherwise
933933
*/
934934
getUdsAddress(): UdsAddress | undefined;
935935
/**
@@ -1004,7 +1004,7 @@
10041004
constructor(testerName: string, service: ServiceItem, addr?: UdsAddress);
10051005
/**
10061006
* Get the UDS address of the request.
1007-
* @returns UdsAddress
1007+
* @returns {UdsAddress | undefined} The UDS address if set, undefined otherwise
10081008
*/
10091009
getUdsAddress(): UdsAddress | undefined;
10101010
/**
@@ -1456,8 +1456,7 @@
14561456
/**
14571457
* Register a virtual entity
14581458
*
1459-
* @deprecated This API is deprecated and will be removed in a future version.
1460-
* Please see {@link https://example.com} for the new API documentation.
1459+
* @deprecated This API is deprecated and not working, enable it through the simulate_by field in the tester config
14611460
*
14621461
* @category DOIP
14631462
* @param {EntityAddr} entity - The entity to be registered.

src/main/worker/secureAccess/index.ts

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,52 @@
1-
import saNode from './build/Release/sa.node'
2-
// import { createRequire } from 'node:module'
3-
// const require = createRequire(import.meta.url)
4-
// const saNode = require('./build/Release/sa.node')
1+
// 条件导入sa.node,只在Windows平台导入
2+
let saNode: any
3+
if (process.platform == 'win32') {
4+
// eslint-disable-next-line @typescript-eslint/no-var-requires
5+
saNode = require('./build/Release/sa.node')
6+
} else {
7+
// 非Windows平台提供空实现
8+
saNode = {
9+
SeedKey: class {
10+
constructor() {}
11+
IsLoaded() {
12+
return false
13+
}
14+
LoadDLL() {
15+
throw new Error('SecureAccessDll is only available on Windows platform')
16+
}
17+
GenerateKeyExOpt() {
18+
throw new Error('SecureAccessDll is only available on Windows platform')
19+
}
20+
GenerateKeyEx() {
21+
throw new Error('SecureAccessDll is only available on Windows platform')
22+
}
23+
},
24+
UINT8_ARRAY: class {
25+
constructor() {}
26+
setitem() {}
27+
cast() {
28+
return this
29+
}
30+
},
31+
INT8_ARRAY: class {
32+
constructor() {}
33+
setitem() {}
34+
cast() {
35+
return this
36+
}
37+
},
38+
UINT32_PTR: class {
39+
constructor() {}
40+
assign() {}
41+
value() {
42+
return 0
43+
}
44+
cast() {
45+
return this
46+
}
47+
}
48+
}
49+
}
550

651
/**
752
* @category UDS

webpack.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const nodeResolve = require('@rollup/plugin-node-resolve');
66
const dts = require('rollup-plugin-dts').default;
77
// const {generateDtsBundle}=require('dts-bundle-generator');
88

9-
109
async function bundleDts(
1110
input,
1211
output
@@ -170,7 +169,11 @@ module.exports = {
170169
},
171170
target: 'node',
172171
plugins: [
173-
new MyCustomPlugin()
172+
new MyCustomPlugin(),
173+
// 添加条件编译插件
174+
new webpack.DefinePlugin({
175+
'process.platform': JSON.stringify(process.platform),
176+
})
174177
],
175178
module: {
176179
rules: [

0 commit comments

Comments
 (0)