kokorobox-native 0.11.0 → 0.12.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 CHANGED
@@ -43,7 +43,7 @@ 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 | `invokeMacosApplicationRouting` |
46
+ | macOS application routing | `applyMacosApplicationRouting`, `getMacosApplicationRoutingStatus`, `stopMacosApplicationRouting`, `openMacosApplicationRoutingSettings` |
47
47
  | Core permissions | `getCorePrivilegeStatus`, `setCorePrivileges` |
48
48
  | Privileged operations | `runServiceLifecycleElevated`, `cleanupLegacyMacosService`, `stopMacosManagedService`, `repairManagedFilePermissions` |
49
49
  | Windows | `getCurrentUserSid`, `isRunningAsAdmin`, `relaunchCurrentApplicationWithPrivilege`, `setupFirewallRules` |
@@ -79,10 +79,11 @@ LaunchDaemon plist and use `SMAppService` directly. They return an explicit
79
79
  `requires-approval` state when an administrator must approve the daemon in
80
80
  System Settings.
81
81
 
82
- `invokeMacosApplicationRouting(request)` runs the bounded, versioned macOS
83
- application-routing control-plane protocol off the Node.js main thread. It
84
- controls the bundled System Extension and Network Extension; packet forwarding
85
- continues to run in the separate extension process.
82
+ The macOS application-routing functions run the bounded control plane off the
83
+ Node.js main thread. Their typed configuration omits fixed protocol details
84
+ such as version, fail-closed behavior, loopback hosts, and reserved ports; the
85
+ native layer owns and validates that wire envelope. Packet forwarding continues
86
+ to run in the separate System Extension process.
86
87
 
87
88
  Core-file privilege APIs are supported on macOS and Linux. They accept only
88
89
  canonical, existing executables named `mihomo` or `mihomo-alpha`; callers cannot
@@ -102,6 +103,20 @@ Windows account, elevation, Firewall, and application-scan APIs report an
102
103
  `UNSUPPORTED_PLATFORM:` error on other operating systems instead of behaving as
103
104
  no-ops.
104
105
 
106
+ The capability contract includes dedicated flags for APIs that have narrower
107
+ support than the package itself:
108
+
109
+ | Capability | Supported platforms |
110
+ | --- | --- |
111
+ | `networkDnsMutation` | macOS |
112
+ | `serviceLifecycle` | Windows, macOS, Linux |
113
+ | `managedFilePermissions` | macOS, Linux |
114
+ | `windowsPrivilegeRelaunch` | Windows |
115
+ | `windowsUwpLoopback` | Windows |
116
+
117
+ Use these flags instead of inferring availability from `process.platform` or
118
+ from a related but broader capability.
119
+
105
120
  `runServiceLifecycleElevated(options)` accepts only the KokoroBox Service
106
121
  `init`, `install`, `uninstall`, `start`, `stop`, and `restart` actions. macOS
107
122
  legacy-service cleanup, managed-service stopping, and managed-file permission
package/index.d.ts CHANGED
@@ -3,6 +3,13 @@ export interface FirewallRule {
3
3
  applicationPath: string;
4
4
  }
5
5
 
6
+ export interface UwpLoopbackApp {
7
+ sid: string;
8
+ packageName: string;
9
+ displayName: string;
10
+ enabled: boolean;
11
+ }
12
+
6
13
  export interface NativeCapabilities {
7
14
  applicationInspection: boolean;
8
15
  executableDiscovery: boolean;
@@ -13,8 +20,13 @@ export interface NativeCapabilities {
13
20
  launchAtLogin: boolean;
14
21
  networkContext: boolean;
15
22
  networkMonitor: boolean;
23
+ networkDnsMutation: boolean;
24
+ serviceLifecycle: boolean;
25
+ managedFilePermissions: boolean;
16
26
  macosServiceManagement: boolean;
17
27
  macosApplicationRouting: boolean;
28
+ windowsPrivilegeRelaunch: boolean;
29
+ windowsUwpLoopback: boolean;
18
30
  coreFilePrivileges: boolean;
19
31
  serviceIdentity: boolean;
20
32
  }
@@ -185,6 +197,8 @@ export function setLaunchAtLogin(
185
197
  enabled: boolean,
186
198
  ): Promise<LaunchAtLoginStatus>;
187
199
  export function getNetworkContext(): Promise<NetworkContext>;
200
+ /** Set DNS on the active macOS network service; [] restores automatic DNS. */
201
+ export function setActiveNetworkDns(servers: string[]): Promise<void>;
188
202
  /** Resolve when the native network snapshot changes, or `undefined` on timeout. */
189
203
  export function waitForNetworkContextChange(
190
204
  previous: NetworkContext,
@@ -196,8 +210,41 @@ export function registerMacosManagedService(plistName: string): MacOSManagedServ
196
210
  export function unregisterMacosManagedService(plistName: string): MacOSManagedServiceStatus;
197
211
  export function reloadMacosManagedService(plistName: string): MacOSManagedServiceStatus;
198
212
  export function openMacosLoginItemsSettings(): void;
199
- /** Invoke the versioned macOS Network/System Extension control-plane protocol. */
200
- export function invokeMacosApplicationRouting(request: string): Promise<string>;
213
+ export type MacosApplicationRoutingIdentifierKind = "SIGNING_IDENTIFIER" | "PROCESS_NAME";
214
+ export type MacosApplicationRoutingProtocol = "TCP" | "UDP" | "BOTH";
215
+ export type MacosApplicationRoutingAction = "PROXY" | "DIRECT" | "BLOCK";
216
+ export type MacosApplicationRoutingState =
217
+ | "disabled"
218
+ | "starting"
219
+ | "running"
220
+ | "stopping"
221
+ | "error";
222
+ export interface MacosApplicationRoutingRule {
223
+ signingIdentifier: string;
224
+ identifierKind: MacosApplicationRoutingIdentifierKind;
225
+ ruleProtocol: MacosApplicationRoutingProtocol;
226
+ action: MacosApplicationRoutingAction;
227
+ enabled: boolean;
228
+ priority: number;
229
+ }
230
+ export interface MacosApplicationRoutingConfiguration {
231
+ proxyAvailable: boolean;
232
+ proxyUdpDns: boolean;
233
+ diagnosticLogging: boolean;
234
+ rules: MacosApplicationRoutingRule[];
235
+ }
236
+ export interface MacosApplicationRoutingStatus {
237
+ state: MacosApplicationRoutingState;
238
+ needsUserApproval: boolean;
239
+ message?: string;
240
+ }
241
+ /** Apply a bounded policy through the macOS Network/System Extension control plane. */
242
+ export function applyMacosApplicationRouting(
243
+ configuration: MacosApplicationRoutingConfiguration,
244
+ ): Promise<MacosApplicationRoutingStatus>;
245
+ export function getMacosApplicationRoutingStatus(): Promise<MacosApplicationRoutingStatus>;
246
+ export function stopMacosApplicationRouting(): Promise<MacosApplicationRoutingStatus>;
247
+ export function openMacosApplicationRoutingSettings(): Promise<MacosApplicationRoutingStatus>;
201
248
  export type ServiceLifecycleAction =
202
249
  | "init"
203
250
  | "install"
@@ -246,3 +293,5 @@ export function scanWindowsApplications(
246
293
  export function getCurrentUserSid(): string;
247
294
  export function isRunningAsAdmin(): boolean;
248
295
  export function setupFirewallRules(rules: FirewallRule[]): void;
296
+ export function listUwpLoopbackApps(): UwpLoopbackApp[];
297
+ export function setUwpLoopbackExemption(sid: string, enabled: boolean): void;
package/index.js CHANGED
@@ -104,13 +104,17 @@ 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;
107
108
  export const waitForNetworkContextChange = nativeBinding.waitForNetworkContextChange;
108
109
  export const getMacosManagedServiceStatus = nativeBinding.getMacosManagedServiceStatus;
109
110
  export const registerMacosManagedService = nativeBinding.registerMacosManagedService;
110
111
  export const unregisterMacosManagedService = nativeBinding.unregisterMacosManagedService;
111
112
  export const reloadMacosManagedService = nativeBinding.reloadMacosManagedService;
112
113
  export const openMacosLoginItemsSettings = nativeBinding.openMacosLoginItemsSettings;
113
- export const invokeMacosApplicationRouting = nativeBinding.invokeMacosApplicationRouting;
114
+ export const applyMacosApplicationRouting = nativeBinding.applyMacosApplicationRouting;
115
+ export const getMacosApplicationRoutingStatus = nativeBinding.getMacosApplicationRoutingStatus;
116
+ export const stopMacosApplicationRouting = nativeBinding.stopMacosApplicationRouting;
117
+ export const openMacosApplicationRoutingSettings = nativeBinding.openMacosApplicationRoutingSettings;
114
118
  export const runServiceLifecycleElevated = nativeBinding.runServiceLifecycleElevated;
115
119
  export const cleanupLegacyMacosService = nativeBinding.cleanupLegacyMacosService;
116
120
  export const stopMacosManagedService = nativeBinding.stopMacosManagedService;
@@ -123,6 +127,8 @@ export const scanWindowsApplications = nativeBinding.scanWindowsApplications;
123
127
  export const getCurrentUserSid = nativeBinding.getCurrentUserSid;
124
128
  export const isRunningAsAdmin = nativeBinding.isRunningAsAdmin;
125
129
  export const setupFirewallRules = nativeBinding.setupFirewallRules;
130
+ export const listUwpLoopbackApps = nativeBinding.listUwpLoopbackApps;
131
+ export const setUwpLoopbackExemption = nativeBinding.setUwpLoopbackExemption;
126
132
  export const ServiceIdentity = nativeBinding.ServiceIdentity;
127
133
  export const openServiceIdentity = nativeBinding.openServiceIdentity;
128
134
  export const deleteServiceIdentity = nativeBinding.deleteServiceIdentity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kokorobox-native",
3
- "version": "0.11.0",
3
+ "version": "0.12.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.11.0",
52
- "kokorobox-native-win32-arm64-msvc": "0.11.0",
53
- "kokorobox-native-darwin-x64": "0.11.0",
54
- "kokorobox-native-darwin-arm64": "0.11.0",
55
- "kokorobox-native-linux-x64-gnu": "0.11.0",
56
- "kokorobox-native-linux-arm64-gnu": "0.11.0"
51
+ "kokorobox-native-win32-x64-msvc": "0.12.0",
52
+ "kokorobox-native-win32-arm64-msvc": "0.12.0",
53
+ "kokorobox-native-darwin-x64": "0.12.0",
54
+ "kokorobox-native-darwin-arm64": "0.12.0",
55
+ "kokorobox-native-linux-x64-gnu": "0.12.0",
56
+ "kokorobox-native-linux-arm64-gnu": "0.12.0"
57
57
  }
58
58
  }