kokorobox-native 0.10.1 → 0.11.1

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
@@ -45,7 +45,8 @@ The full TypeScript declarations are shipped in
45
45
  | macOS service | `getMacosManagedServiceStatus`, `registerMacosManagedService`, `unregisterMacosManagedService`, `reloadMacosManagedService`, `openMacosLoginItemsSettings` |
46
46
  | macOS application routing | `invokeMacosApplicationRouting` |
47
47
  | Core permissions | `getCorePrivilegeStatus`, `setCorePrivileges` |
48
- | Windows | `getCurrentUserSid`, `isRunningAsAdmin`, `runElevated`, `launchElevated`, `launchUnelevated`, `setupFirewallRules` |
48
+ | Privileged operations | `runServiceLifecycleElevated`, `cleanupLegacyMacosService`, `stopMacosManagedService`, `repairManagedFilePermissions` |
49
+ | Windows | `getCurrentUserSid`, `isRunningAsAdmin`, `relaunchCurrentApplicationWithPrivilege`, `setupFirewallRules` |
49
50
 
50
51
  `inspectApplication` validates the input for the current platform and resolves
51
52
  it to a routing identifier: an executable path on Windows and Linux, or a code
@@ -101,10 +102,15 @@ Windows account, elevation, Firewall, and application-scan APIs report an
101
102
  `UNSUPPORTED_PLATFORM:` error on other operating systems instead of behaving as
102
103
  no-ops.
103
104
 
104
- `launchElevated(command, args)` and `launchUnelevated(command, args)` start a
105
- new Windows process without waiting for it. The first presents the standard UAC
106
- prompt; the second uses the interactive desktop shell token so an elevated app
107
- can restart at normal user integrity. They do not configure persistent
105
+ `runServiceLifecycleElevated(options)` accepts only the KokoroBox Service
106
+ `init`, `install`, `uninstall`, `start`, `stop`, and `restart` actions. macOS
107
+ legacy-service cleanup, managed-service stopping, and managed-file permission
108
+ repair are separate purpose-specific APIs.
109
+
110
+ `relaunchCurrentApplicationWithPrivilege(args, elevated)` starts a new copy of
111
+ the current Windows application without accepting an executable path. An
112
+ elevated relaunch presents the standard UAC prompt; the unelevated path uses
113
+ the interactive desktop shell token. It does not configure persistent
108
114
  elevation.
109
115
 
110
116
  ## Contributing
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;
@@ -185,6 +192,8 @@ export function setLaunchAtLogin(
185
192
  enabled: boolean,
186
193
  ): Promise<LaunchAtLoginStatus>;
187
194
  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>;
188
197
  /** Resolve when the native network snapshot changes, or `undefined` on timeout. */
189
198
  export function waitForNetworkContextChange(
190
199
  previous: NetworkContext,
@@ -198,6 +207,38 @@ export function reloadMacosManagedService(plistName: string): MacOSManagedServic
198
207
  export function openMacosLoginItemsSettings(): void;
199
208
  /** Invoke the versioned macOS Network/System Extension control-plane protocol. */
200
209
  export function invokeMacosApplicationRouting(request: string): Promise<string>;
210
+ export type ServiceLifecycleAction =
211
+ | "init"
212
+ | "install"
213
+ | "uninstall"
214
+ | "start"
215
+ | "stop"
216
+ | "restart";
217
+ export interface ServiceLifecycleOptions {
218
+ executablePath: string;
219
+ action: ServiceLifecycleAction;
220
+ publicKey?: string;
221
+ authorizedSid?: string;
222
+ authorizedUid?: number;
223
+ }
224
+ /** Run only a validated KokoroBox Service lifecycle action with elevation. */
225
+ export function runServiceLifecycleElevated(options: ServiceLifecycleOptions): Promise<void>;
226
+ /** Remove only the fixed pre-SMAppService KokoroBox LaunchDaemon files. */
227
+ export function cleanupLegacyMacosService(): Promise<void>;
228
+ /** Stop the fixed KokoroBox SMAppService daemon label. */
229
+ export function stopMacosManagedService(): Promise<void>;
230
+ /** Repair one file below a validated managed root for the requested Unix owner. */
231
+ export function repairManagedFilePermissions(
232
+ target: string,
233
+ managedRoot: string,
234
+ uid: number,
235
+ gid: number,
236
+ ): Promise<void>;
237
+ /** Relaunch the current Windows application at the requested privilege level. */
238
+ export function relaunchCurrentApplicationWithPrivilege(
239
+ args: string[],
240
+ elevated: boolean,
241
+ ): void;
201
242
  /** Inspect only validated `mihomo` and `mihomo-alpha` executable paths. */
202
243
  export function getCorePrivilegeStatus(paths: string[]): CorePrivilegeStatus[];
203
244
  /** Grant or revoke the constrained Unix core-file privilege. */
@@ -213,7 +254,6 @@ export function scanWindowsApplications(
213
254
  ): Promise<ApplicationScanResult>;
214
255
  export function getCurrentUserSid(): string;
215
256
  export function isRunningAsAdmin(): boolean;
216
- export function runElevated(command: string, args?: string[]): number;
217
- export function launchElevated(command: string, args?: string[]): void;
218
- export function launchUnelevated(command: string, args?: string[]): void;
219
257
  export function setupFirewallRules(rules: FirewallRule[]): void;
258
+ export function listUwpLoopbackApps(): UwpLoopbackApp[];
259
+ export function setUwpLoopbackExemption(sid: string, enabled: boolean): void;
package/index.js CHANGED
@@ -104,6 +104,7 @@ 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;
@@ -111,16 +112,20 @@ export const unregisterMacosManagedService = nativeBinding.unregisterMacosManage
111
112
  export const reloadMacosManagedService = nativeBinding.reloadMacosManagedService;
112
113
  export const openMacosLoginItemsSettings = nativeBinding.openMacosLoginItemsSettings;
113
114
  export const invokeMacosApplicationRouting = nativeBinding.invokeMacosApplicationRouting;
115
+ export const runServiceLifecycleElevated = nativeBinding.runServiceLifecycleElevated;
116
+ export const cleanupLegacyMacosService = nativeBinding.cleanupLegacyMacosService;
117
+ export const stopMacosManagedService = nativeBinding.stopMacosManagedService;
118
+ export const repairManagedFilePermissions = nativeBinding.repairManagedFilePermissions;
119
+ export const relaunchCurrentApplicationWithPrivilege = nativeBinding.relaunchCurrentApplicationWithPrivilege;
114
120
  export const getCorePrivilegeStatus = nativeBinding.getCorePrivilegeStatus;
115
121
  export const setCorePrivileges = nativeBinding.setCorePrivileges;
116
122
  export const inspectApplication = nativeBinding.inspectApplication;
117
123
  export const scanWindowsApplications = nativeBinding.scanWindowsApplications;
118
124
  export const getCurrentUserSid = nativeBinding.getCurrentUserSid;
119
125
  export const isRunningAsAdmin = nativeBinding.isRunningAsAdmin;
120
- export const runElevated = nativeBinding.runElevated;
121
- export const launchElevated = nativeBinding.launchElevated;
122
- export const launchUnelevated = nativeBinding.launchUnelevated;
123
126
  export const setupFirewallRules = nativeBinding.setupFirewallRules;
127
+ export const listUwpLoopbackApps = nativeBinding.listUwpLoopbackApps;
128
+ export const setUwpLoopbackExemption = nativeBinding.setUwpLoopbackExemption;
124
129
  export const ServiceIdentity = nativeBinding.ServiceIdentity;
125
130
  export const openServiceIdentity = nativeBinding.openServiceIdentity;
126
131
  export const deleteServiceIdentity = nativeBinding.deleteServiceIdentity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kokorobox-native",
3
- "version": "0.10.1",
3
+ "version": "0.11.1",
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.10.1",
52
- "kokorobox-native-win32-arm64-msvc": "0.10.1",
53
- "kokorobox-native-darwin-x64": "0.10.1",
54
- "kokorobox-native-darwin-arm64": "0.10.1",
55
- "kokorobox-native-linux-x64-gnu": "0.10.1",
56
- "kokorobox-native-linux-arm64-gnu": "0.10.1"
51
+ "kokorobox-native-win32-x64-msvc": "0.11.1",
52
+ "kokorobox-native-win32-arm64-msvc": "0.11.1",
53
+ "kokorobox-native-darwin-x64": "0.11.1",
54
+ "kokorobox-native-darwin-arm64": "0.11.1",
55
+ "kokorobox-native-linux-x64-gnu": "0.11.1",
56
+ "kokorobox-native-linux-arm64-gnu": "0.11.1"
57
57
  }
58
58
  }