kokorobox-native 0.11.1 → 0.13.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/README.md +24 -6
- package/index.d.ts +44 -10
- package/index.js +5 -3
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -43,10 +43,10 @@ The full TypeScript declarations are shipped in
|
|
|
43
43
|
| Rules | `fileToStr` |
|
|
44
44
|
| Platform | `getLaunchAtLogin`, `setLaunchAtLogin`, `getNetworkContext` |
|
|
45
45
|
| macOS service | `getMacosManagedServiceStatus`, `registerMacosManagedService`, `unregisterMacosManagedService`, `reloadMacosManagedService`, `openMacosLoginItemsSettings` |
|
|
46
|
-
| macOS application routing | `
|
|
46
|
+
| macOS application routing | `applyMacosApplicationRouting`, `getMacosApplicationRoutingStatus`, `stopMacosApplicationRouting`, `openMacosApplicationRoutingSettings` |
|
|
47
47
|
| Core permissions | `getCorePrivilegeStatus`, `setCorePrivileges` |
|
|
48
48
|
| Privileged operations | `runServiceLifecycleElevated`, `cleanupLegacyMacosService`, `stopMacosManagedService`, `repairManagedFilePermissions` |
|
|
49
|
-
| Windows | `getCurrentUserSid`, `isRunningAsAdmin`, `relaunchCurrentApplicationWithPrivilege`, `
|
|
49
|
+
| Windows | `getCurrentUserSid`, `isRunningAsAdmin`, `relaunchCurrentApplicationWithPrivilege`, `ensureKokoroBoxCoreFirewall` |
|
|
50
50
|
|
|
51
51
|
`inspectApplication` validates the input for the current platform and resolves
|
|
52
52
|
it to a routing identifier: an executable path on Windows and Linux, or a code
|
|
@@ -59,6 +59,10 @@ list.
|
|
|
59
59
|
tools. It returns canonical paths for stable deduplication; prefix matching is
|
|
60
60
|
available only when explicitly requested.
|
|
61
61
|
|
|
62
|
+
`ensureKokoroBoxCoreFirewall` accepts the two Mihomo executable paths and the
|
|
63
|
+
KokoroBox application path. Native fixes the three rule names and validates
|
|
64
|
+
the executable basenames before changing Windows Firewall state.
|
|
65
|
+
|
|
62
66
|
`fileToStr` converts a rule file and returns each generated output keyed by its
|
|
63
67
|
behavior, metadata for those outputs, and rules that were skipped. Its optional
|
|
64
68
|
`RuleConvertOptions` accepts Mihomo, General, Egern, and sing-box targets and
|
|
@@ -79,10 +83,11 @@ LaunchDaemon plist and use `SMAppService` directly. They return an explicit
|
|
|
79
83
|
`requires-approval` state when an administrator must approve the daemon in
|
|
80
84
|
System Settings.
|
|
81
85
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
The macOS application-routing functions run the bounded control plane off the
|
|
87
|
+
Node.js main thread. Their typed configuration omits fixed protocol details
|
|
88
|
+
such as version, fail-closed behavior, loopback hosts, and reserved ports; the
|
|
89
|
+
native layer owns and validates that wire envelope. Packet forwarding continues
|
|
90
|
+
to run in the separate System Extension process.
|
|
86
91
|
|
|
87
92
|
Core-file privilege APIs are supported on macOS and Linux. They accept only
|
|
88
93
|
canonical, existing executables named `mihomo` or `mihomo-alpha`; callers cannot
|
|
@@ -102,6 +107,19 @@ Windows account, elevation, Firewall, and application-scan APIs report an
|
|
|
102
107
|
`UNSUPPORTED_PLATFORM:` error on other operating systems instead of behaving as
|
|
103
108
|
no-ops.
|
|
104
109
|
|
|
110
|
+
The capability contract includes dedicated flags for APIs that have narrower
|
|
111
|
+
support than the package itself:
|
|
112
|
+
|
|
113
|
+
| Capability | Supported platforms |
|
|
114
|
+
| --- | --- |
|
|
115
|
+
| `serviceLifecycle` | Windows, macOS, Linux |
|
|
116
|
+
| `managedFilePermissions` | macOS, Linux |
|
|
117
|
+
| `windowsPrivilegeRelaunch` | Windows |
|
|
118
|
+
| `windowsUwpLoopback` | Windows |
|
|
119
|
+
|
|
120
|
+
Use these flags instead of inferring availability from `process.platform` or
|
|
121
|
+
from a related but broader capability.
|
|
122
|
+
|
|
105
123
|
`runServiceLifecycleElevated(options)` accepts only the KokoroBox Service
|
|
106
124
|
`init`, `install`, `uninstall`, `start`, `stop`, and `restart` actions. macOS
|
|
107
125
|
legacy-service cleanup, managed-service stopping, and managed-file permission
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export interface FirewallRule {
|
|
2
|
-
name: string;
|
|
3
|
-
applicationPath: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
1
|
export interface UwpLoopbackApp {
|
|
7
2
|
sid: string;
|
|
8
3
|
packageName: string;
|
|
@@ -20,8 +15,12 @@ export interface NativeCapabilities {
|
|
|
20
15
|
launchAtLogin: boolean;
|
|
21
16
|
networkContext: boolean;
|
|
22
17
|
networkMonitor: boolean;
|
|
18
|
+
serviceLifecycle: boolean;
|
|
19
|
+
managedFilePermissions: boolean;
|
|
23
20
|
macosServiceManagement: boolean;
|
|
24
21
|
macosApplicationRouting: boolean;
|
|
22
|
+
windowsPrivilegeRelaunch: boolean;
|
|
23
|
+
windowsUwpLoopback: boolean;
|
|
25
24
|
coreFilePrivileges: boolean;
|
|
26
25
|
serviceIdentity: boolean;
|
|
27
26
|
}
|
|
@@ -192,8 +191,6 @@ export function setLaunchAtLogin(
|
|
|
192
191
|
enabled: boolean,
|
|
193
192
|
): Promise<LaunchAtLoginStatus>;
|
|
194
193
|
export function getNetworkContext(): Promise<NetworkContext>;
|
|
195
|
-
/** Set DNS on the active macOS network service; [] restores automatic DNS. */
|
|
196
|
-
export function setActiveNetworkDns(servers: string[]): Promise<void>;
|
|
197
194
|
/** Resolve when the native network snapshot changes, or `undefined` on timeout. */
|
|
198
195
|
export function waitForNetworkContextChange(
|
|
199
196
|
previous: NetworkContext,
|
|
@@ -205,8 +202,41 @@ export function registerMacosManagedService(plistName: string): MacOSManagedServ
|
|
|
205
202
|
export function unregisterMacosManagedService(plistName: string): MacOSManagedServiceStatus;
|
|
206
203
|
export function reloadMacosManagedService(plistName: string): MacOSManagedServiceStatus;
|
|
207
204
|
export function openMacosLoginItemsSettings(): void;
|
|
208
|
-
|
|
209
|
-
export
|
|
205
|
+
export type MacosApplicationRoutingIdentifierKind = "SIGNING_IDENTIFIER" | "PROCESS_NAME";
|
|
206
|
+
export type MacosApplicationRoutingProtocol = "TCP" | "UDP" | "BOTH";
|
|
207
|
+
export type MacosApplicationRoutingAction = "PROXY" | "DIRECT" | "BLOCK";
|
|
208
|
+
export type MacosApplicationRoutingState =
|
|
209
|
+
| "disabled"
|
|
210
|
+
| "starting"
|
|
211
|
+
| "running"
|
|
212
|
+
| "stopping"
|
|
213
|
+
| "error";
|
|
214
|
+
export interface MacosApplicationRoutingRule {
|
|
215
|
+
signingIdentifier: string;
|
|
216
|
+
identifierKind: MacosApplicationRoutingIdentifierKind;
|
|
217
|
+
ruleProtocol: MacosApplicationRoutingProtocol;
|
|
218
|
+
action: MacosApplicationRoutingAction;
|
|
219
|
+
enabled: boolean;
|
|
220
|
+
priority: number;
|
|
221
|
+
}
|
|
222
|
+
export interface MacosApplicationRoutingConfiguration {
|
|
223
|
+
proxyAvailable: boolean;
|
|
224
|
+
proxyUdpDns: boolean;
|
|
225
|
+
diagnosticLogging: boolean;
|
|
226
|
+
rules: MacosApplicationRoutingRule[];
|
|
227
|
+
}
|
|
228
|
+
export interface MacosApplicationRoutingStatus {
|
|
229
|
+
state: MacosApplicationRoutingState;
|
|
230
|
+
needsUserApproval: boolean;
|
|
231
|
+
message?: string;
|
|
232
|
+
}
|
|
233
|
+
/** Apply a bounded policy through the macOS Network/System Extension control plane. */
|
|
234
|
+
export function applyMacosApplicationRouting(
|
|
235
|
+
configuration: MacosApplicationRoutingConfiguration,
|
|
236
|
+
): Promise<MacosApplicationRoutingStatus>;
|
|
237
|
+
export function getMacosApplicationRoutingStatus(): Promise<MacosApplicationRoutingStatus>;
|
|
238
|
+
export function stopMacosApplicationRouting(): Promise<MacosApplicationRoutingStatus>;
|
|
239
|
+
export function openMacosApplicationRoutingSettings(): Promise<MacosApplicationRoutingStatus>;
|
|
210
240
|
export type ServiceLifecycleAction =
|
|
211
241
|
| "init"
|
|
212
242
|
| "install"
|
|
@@ -254,6 +284,10 @@ export function scanWindowsApplications(
|
|
|
254
284
|
): Promise<ApplicationScanResult>;
|
|
255
285
|
export function getCurrentUserSid(): string;
|
|
256
286
|
export function isRunningAsAdmin(): boolean;
|
|
257
|
-
export function
|
|
287
|
+
export function ensureKokoroBoxCoreFirewall(
|
|
288
|
+
mihomoPath: string,
|
|
289
|
+
mihomoAlphaPath: string,
|
|
290
|
+
applicationPath: string,
|
|
291
|
+
): void;
|
|
258
292
|
export function listUwpLoopbackApps(): UwpLoopbackApp[];
|
|
259
293
|
export function setUwpLoopbackExemption(sid: string, enabled: boolean): void;
|
package/index.js
CHANGED
|
@@ -104,14 +104,16 @@ export const findExecutables = nativeBinding.findExecutables;
|
|
|
104
104
|
export const getLaunchAtLogin = nativeBinding.getLaunchAtLogin;
|
|
105
105
|
export const setLaunchAtLogin = nativeBinding.setLaunchAtLogin;
|
|
106
106
|
export const getNetworkContext = nativeBinding.getNetworkContext;
|
|
107
|
-
export const setActiveNetworkDns = nativeBinding.setActiveNetworkDns;
|
|
108
107
|
export const waitForNetworkContextChange = nativeBinding.waitForNetworkContextChange;
|
|
109
108
|
export const getMacosManagedServiceStatus = nativeBinding.getMacosManagedServiceStatus;
|
|
110
109
|
export const registerMacosManagedService = nativeBinding.registerMacosManagedService;
|
|
111
110
|
export const unregisterMacosManagedService = nativeBinding.unregisterMacosManagedService;
|
|
112
111
|
export const reloadMacosManagedService = nativeBinding.reloadMacosManagedService;
|
|
113
112
|
export const openMacosLoginItemsSettings = nativeBinding.openMacosLoginItemsSettings;
|
|
114
|
-
export const
|
|
113
|
+
export const applyMacosApplicationRouting = nativeBinding.applyMacosApplicationRouting;
|
|
114
|
+
export const getMacosApplicationRoutingStatus = nativeBinding.getMacosApplicationRoutingStatus;
|
|
115
|
+
export const stopMacosApplicationRouting = nativeBinding.stopMacosApplicationRouting;
|
|
116
|
+
export const openMacosApplicationRoutingSettings = nativeBinding.openMacosApplicationRoutingSettings;
|
|
115
117
|
export const runServiceLifecycleElevated = nativeBinding.runServiceLifecycleElevated;
|
|
116
118
|
export const cleanupLegacyMacosService = nativeBinding.cleanupLegacyMacosService;
|
|
117
119
|
export const stopMacosManagedService = nativeBinding.stopMacosManagedService;
|
|
@@ -123,7 +125,7 @@ export const inspectApplication = nativeBinding.inspectApplication;
|
|
|
123
125
|
export const scanWindowsApplications = nativeBinding.scanWindowsApplications;
|
|
124
126
|
export const getCurrentUserSid = nativeBinding.getCurrentUserSid;
|
|
125
127
|
export const isRunningAsAdmin = nativeBinding.isRunningAsAdmin;
|
|
126
|
-
export const
|
|
128
|
+
export const ensureKokoroBoxCoreFirewall = nativeBinding.ensureKokoroBoxCoreFirewall;
|
|
127
129
|
export const listUwpLoopbackApps = nativeBinding.listUwpLoopbackApps;
|
|
128
130
|
export const setUwpLoopbackExemption = nativeBinding.setUwpLoopbackExemption;
|
|
129
131
|
export const ServiceIdentity = nativeBinding.ServiceIdentity;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kokorobox-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "KokoroBox native bridge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
|
-
"kokorobox-native-win32-x64-msvc": "0.
|
|
52
|
-
"kokorobox-native-win32-arm64-msvc": "0.
|
|
53
|
-
"kokorobox-native-darwin-x64": "0.
|
|
54
|
-
"kokorobox-native-darwin-arm64": "0.
|
|
55
|
-
"kokorobox-native-linux-x64-gnu": "0.
|
|
56
|
-
"kokorobox-native-linux-arm64-gnu": "0.
|
|
51
|
+
"kokorobox-native-win32-x64-msvc": "0.13.0",
|
|
52
|
+
"kokorobox-native-win32-arm64-msvc": "0.13.0",
|
|
53
|
+
"kokorobox-native-darwin-x64": "0.13.0",
|
|
54
|
+
"kokorobox-native-darwin-arm64": "0.13.0",
|
|
55
|
+
"kokorobox-native-linux-x64-gnu": "0.13.0",
|
|
56
|
+
"kokorobox-native-linux-arm64-gnu": "0.13.0"
|
|
57
57
|
}
|
|
58
58
|
}
|