kokorobox-native 0.10.1 → 0.11.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
@@ -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
@@ -198,6 +198,38 @@ export function reloadMacosManagedService(plistName: string): MacOSManagedServic
198
198
  export function openMacosLoginItemsSettings(): void;
199
199
  /** Invoke the versioned macOS Network/System Extension control-plane protocol. */
200
200
  export function invokeMacosApplicationRouting(request: string): Promise<string>;
201
+ export type ServiceLifecycleAction =
202
+ | "init"
203
+ | "install"
204
+ | "uninstall"
205
+ | "start"
206
+ | "stop"
207
+ | "restart";
208
+ export interface ServiceLifecycleOptions {
209
+ executablePath: string;
210
+ action: ServiceLifecycleAction;
211
+ publicKey?: string;
212
+ authorizedSid?: string;
213
+ authorizedUid?: number;
214
+ }
215
+ /** Run only a validated KokoroBox Service lifecycle action with elevation. */
216
+ export function runServiceLifecycleElevated(options: ServiceLifecycleOptions): Promise<void>;
217
+ /** Remove only the fixed pre-SMAppService KokoroBox LaunchDaemon files. */
218
+ export function cleanupLegacyMacosService(): Promise<void>;
219
+ /** Stop the fixed KokoroBox SMAppService daemon label. */
220
+ export function stopMacosManagedService(): Promise<void>;
221
+ /** Repair one file below a validated managed root for the requested Unix owner. */
222
+ export function repairManagedFilePermissions(
223
+ target: string,
224
+ managedRoot: string,
225
+ uid: number,
226
+ gid: number,
227
+ ): Promise<void>;
228
+ /** Relaunch the current Windows application at the requested privilege level. */
229
+ export function relaunchCurrentApplicationWithPrivilege(
230
+ args: string[],
231
+ elevated: boolean,
232
+ ): void;
201
233
  /** Inspect only validated `mihomo` and `mihomo-alpha` executable paths. */
202
234
  export function getCorePrivilegeStatus(paths: string[]): CorePrivilegeStatus[];
203
235
  /** Grant or revoke the constrained Unix core-file privilege. */
@@ -213,7 +245,4 @@ export function scanWindowsApplications(
213
245
  ): Promise<ApplicationScanResult>;
214
246
  export function getCurrentUserSid(): string;
215
247
  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
248
  export function setupFirewallRules(rules: FirewallRule[]): void;
package/index.js CHANGED
@@ -111,15 +111,17 @@ export const unregisterMacosManagedService = nativeBinding.unregisterMacosManage
111
111
  export const reloadMacosManagedService = nativeBinding.reloadMacosManagedService;
112
112
  export const openMacosLoginItemsSettings = nativeBinding.openMacosLoginItemsSettings;
113
113
  export const invokeMacosApplicationRouting = nativeBinding.invokeMacosApplicationRouting;
114
+ export const runServiceLifecycleElevated = nativeBinding.runServiceLifecycleElevated;
115
+ export const cleanupLegacyMacosService = nativeBinding.cleanupLegacyMacosService;
116
+ export const stopMacosManagedService = nativeBinding.stopMacosManagedService;
117
+ export const repairManagedFilePermissions = nativeBinding.repairManagedFilePermissions;
118
+ export const relaunchCurrentApplicationWithPrivilege = nativeBinding.relaunchCurrentApplicationWithPrivilege;
114
119
  export const getCorePrivilegeStatus = nativeBinding.getCorePrivilegeStatus;
115
120
  export const setCorePrivileges = nativeBinding.setCorePrivileges;
116
121
  export const inspectApplication = nativeBinding.inspectApplication;
117
122
  export const scanWindowsApplications = nativeBinding.scanWindowsApplications;
118
123
  export const getCurrentUserSid = nativeBinding.getCurrentUserSid;
119
124
  export const isRunningAsAdmin = nativeBinding.isRunningAsAdmin;
120
- export const runElevated = nativeBinding.runElevated;
121
- export const launchElevated = nativeBinding.launchElevated;
122
- export const launchUnelevated = nativeBinding.launchUnelevated;
123
125
  export const setupFirewallRules = nativeBinding.setupFirewallRules;
124
126
  export const ServiceIdentity = nativeBinding.ServiceIdentity;
125
127
  export const openServiceIdentity = nativeBinding.openServiceIdentity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kokorobox-native",
3
- "version": "0.10.1",
3
+ "version": "0.11.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.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.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"
57
57
  }
58
58
  }