kokorobox-native 0.16.0 → 0.16.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 +13 -136
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# kokorobox-native
|
|
2
2
|
|
|
3
|
-
Native Node.js APIs used by KokoroBox Desktop. This package
|
|
4
|
-
|
|
3
|
+
Native Node.js APIs used by KokoroBox Desktop. This ESM package selects the
|
|
4
|
+
native binary for the current operating system and architecture.
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
|
@@ -9,8 +9,8 @@ it selects the native binary for the current operating system and architecture.
|
|
|
9
9
|
pnpm add kokorobox-native
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Prebuilt optional packages
|
|
13
|
-
|
|
12
|
+
Prebuilt optional packages support x64 and arm64 Windows (MSVC), macOS, and
|
|
13
|
+
GNU/Linux. For local development, the loader also accepts
|
|
14
14
|
`NAPI_RS_NATIVE_LIBRARY_PATH`.
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
@@ -19,146 +19,23 @@ macOS, and GNU/Linux. The loader also accepts a development binary through
|
|
|
19
19
|
import {
|
|
20
20
|
getNativeCapabilities,
|
|
21
21
|
getNetworkContext,
|
|
22
|
-
getTrafficPresenterPath,
|
|
23
22
|
inspectApplication,
|
|
24
23
|
} from "kokorobox-native";
|
|
25
24
|
|
|
26
25
|
const capabilities = getNativeCapabilities();
|
|
27
26
|
const network = await getNetworkContext();
|
|
28
27
|
const app = await inspectApplication("/Applications/KokoroBox.app");
|
|
29
|
-
const presenter = getTrafficPresenterPath();
|
|
30
28
|
```
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
[`index.d.ts`](index.d.ts).
|
|
30
|
+
Check `getNativeCapabilities()` before using optional platform features.
|
|
34
31
|
|
|
35
|
-
##
|
|
32
|
+
## Documentation
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
| Applications | `inspectApplication`, `scanWindowsApplications`, `findExecutables` |
|
|
43
|
-
| Rules | `fileToStr` |
|
|
44
|
-
| Platform | `getLaunchAtLogin`, `setLaunchAtLogin`, `getNetworkContext`, `waitForNetworkContextChange` |
|
|
45
|
-
| Service identity | `openServiceIdentity`, `deleteServiceIdentity`, `ServiceIdentity` |
|
|
46
|
-
| Linux terminal proxy | `setTerminalProxyEnvironment`, `clearTerminalProxyEnvironment` |
|
|
47
|
-
| macOS service | `getMacosManagedServiceStatus`, `registerMacosManagedService`, `unregisterMacosManagedService`, `reloadMacosManagedService`, `openMacosLoginItemsSettings` |
|
|
48
|
-
| macOS application routing | `applyMacosApplicationRouting`, `getMacosApplicationRoutingStatus`, `stopMacosApplicationRouting`, `openMacosApplicationRoutingSettings` |
|
|
49
|
-
| Core permissions | `getCorePrivilegeStatus`, `setCorePrivileges` |
|
|
50
|
-
| Privileged operations | `runServiceLifecycleElevated`, `cleanupLegacyMacosService`, `stopMacosManagedService`, `repairManagedFilePermissions` |
|
|
51
|
-
| Windows | `getCurrentUserSid`, `isRunningAsAdmin`, `relaunchCurrentApplicationWithPrivilege`, `ensureKokoroBoxCoreFirewall`, `listUwpLoopbackApps`, `setUwpLoopbackExemption` |
|
|
34
|
+
- [JavaScript API guide](../docs/api.md)
|
|
35
|
+
- [TypeScript declarations](index.d.ts)
|
|
36
|
+
- [Platform behavior and security contract](../docs/platform-services.md)
|
|
37
|
+
- [Traffic presenter protocol](../docs/traffic-presenter.md)
|
|
38
|
+
- [Repository layout and build commands](../README.md)
|
|
52
39
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
signing identifier on macOS. `scanWindowsApplications` is asynchronous and
|
|
56
|
-
Windows-only; it accepts an optional result limit and executable-name exclusion
|
|
57
|
-
list.
|
|
58
|
-
|
|
59
|
-
`findExecutables` asynchronously searches absolute additional directories,
|
|
60
|
-
`PATH`, and platform-standard binary locations without spawning command-line
|
|
61
|
-
tools. It returns canonical paths for stable deduplication; prefix matching is
|
|
62
|
-
available only when explicitly requested.
|
|
63
|
-
|
|
64
|
-
`ensureKokoroBoxCoreFirewall` accepts the two Mihomo executable paths and the
|
|
65
|
-
KokoroBox application path. Native fixes the three rule names and validates
|
|
66
|
-
the executable basenames before changing Windows Firewall state.
|
|
67
|
-
|
|
68
|
-
`fileToStr` converts a rule file and returns each generated output keyed by its
|
|
69
|
-
behavior, metadata for those outputs, and rules that were skipped. Its optional
|
|
70
|
-
`RuleConvertOptions` accepts Mihomo, General, Egern, and sing-box targets and
|
|
71
|
-
the formats listed in the TypeScript declaration.
|
|
72
|
-
|
|
73
|
-
Launch-at-login requires a stable filesystem-safe `identifier`, a display name,
|
|
74
|
-
and an absolute executable path. It returns the selected backend: the Windows
|
|
75
|
-
current-user Run key, macOS `SMAppService.mainApp`, or Linux XDG Autostart. On
|
|
76
|
-
macOS, `requiresApproval` reports when the entry is registered but still needs
|
|
77
|
-
approval in System Settings. Network context is best-effort, so optional fields
|
|
78
|
-
such as the default interface and SSID may be absent. macOS obtains this state
|
|
79
|
-
directly from SystemConfiguration without parsing command output.
|
|
80
|
-
Windows obtains the preferred interface and DNS servers from IP Helper and the
|
|
81
|
-
SSID from Native Wi-Fi, without spawning PowerShell.
|
|
82
|
-
|
|
83
|
-
`waitForNetworkContextChange(previous, timeoutMs)` resolves with a changed
|
|
84
|
-
snapshot or `null` when the timeout expires. `openServiceIdentity()` opens an
|
|
85
|
-
opaque Ed25519 signer backed by the platform credential store; its private key
|
|
86
|
-
is not returned to JavaScript. Linux can use an explicitly reported protected
|
|
87
|
-
file fallback when Secret Service is unavailable.
|
|
88
|
-
|
|
89
|
-
On Linux, the terminal proxy functions manage only KokoroBox's user-session
|
|
90
|
-
configuration. The set call returns whether the systemd user manager was
|
|
91
|
-
updated; clearing returns `null` when no managed file exists. See the
|
|
92
|
-
[platform-services contract](../docs/platform-services.md) for the exact path
|
|
93
|
-
and return semantics.
|
|
94
|
-
|
|
95
|
-
The macOS managed-service functions accept the basename of an embedded
|
|
96
|
-
LaunchDaemon plist and use `SMAppService` directly. They return an explicit
|
|
97
|
-
`requires-approval` state when an administrator must approve the daemon in
|
|
98
|
-
System Settings.
|
|
99
|
-
|
|
100
|
-
The macOS application-routing functions run the bounded control plane off the
|
|
101
|
-
Node.js main thread. Their typed configuration omits fixed protocol details
|
|
102
|
-
such as version, fail-closed behavior, loopback hosts, and reserved ports; the
|
|
103
|
-
native layer owns and validates that wire envelope. Packet forwarding continues
|
|
104
|
-
to run in the separate System Extension process.
|
|
105
|
-
|
|
106
|
-
Core-file privilege APIs are supported on macOS and Linux. They accept only
|
|
107
|
-
canonical, existing executables named `mihomo` or `mihomo-alpha`; callers cannot
|
|
108
|
-
use them as a general privileged-command interface. See the repository's
|
|
109
|
-
[platform-services contract](../docs/platform-services.md) for validation and
|
|
110
|
-
platform behavior.
|
|
111
|
-
|
|
112
|
-
`getTrafficPresenterPath()` returns the presenter executable shipped in the
|
|
113
|
-
same platform package as the loaded native binding. The presenter accepts the
|
|
114
|
-
versioned JSON-lines protocol documented by the `traffic-presenter` crate on
|
|
115
|
-
standard input and terminates when its parent closes that stream.
|
|
116
|
-
|
|
117
|
-
## Platform behavior
|
|
118
|
-
|
|
119
|
-
Use `getNativeCapabilities()` before enabling an optional system feature.
|
|
120
|
-
Windows account, elevation, Firewall, and application-scan APIs report an
|
|
121
|
-
`UNSUPPORTED_PLATFORM:` error on other operating systems instead of behaving as
|
|
122
|
-
no-ops.
|
|
123
|
-
|
|
124
|
-
The capability contract includes dedicated flags for APIs that have narrower
|
|
125
|
-
support than the package itself:
|
|
126
|
-
|
|
127
|
-
| Capability | Supported platforms |
|
|
128
|
-
| --- | --- |
|
|
129
|
-
| `serviceLifecycle` | Windows, macOS, Linux |
|
|
130
|
-
| `managedFilePermissions` | macOS, Linux |
|
|
131
|
-
| `windowsPrivilegeRelaunch` | Windows |
|
|
132
|
-
| `windowsUwpLoopback` | Windows |
|
|
133
|
-
| `linuxTerminalProxy` | Linux |
|
|
134
|
-
|
|
135
|
-
Use these flags instead of inferring availability from `process.platform` or
|
|
136
|
-
from a related but broader capability.
|
|
137
|
-
|
|
138
|
-
`runServiceLifecycleElevated(options)` accepts only the KokoroBox Service
|
|
139
|
-
`init`, `install`, `uninstall`, `start`, `stop`, and `restart` actions. macOS
|
|
140
|
-
legacy-service cleanup, managed-service stopping, and managed-file permission
|
|
141
|
-
repair are separate purpose-specific APIs.
|
|
142
|
-
|
|
143
|
-
`relaunchCurrentApplicationWithPrivilege(args, elevated)` starts a new copy of
|
|
144
|
-
the current Windows application without accepting an executable path. An
|
|
145
|
-
elevated relaunch presents the standard UAC prompt; the unelevated path uses
|
|
146
|
-
the interactive desktop shell token. It does not configure persistent
|
|
147
|
-
elevation.
|
|
148
|
-
|
|
149
|
-
`listUwpLoopbackApps()` reports Windows app containers with an opaque ID,
|
|
150
|
-
display metadata, category (`user`, `microsoft`, or `system`), package type,
|
|
151
|
-
and exemption status. Pass that ID to `setUwpLoopbackExemption()` to change the
|
|
152
|
-
app's loopback exemption.
|
|
153
|
-
|
|
154
|
-
## Contributing
|
|
155
|
-
|
|
156
|
-
The source is a three-crate Rust workspace. The root crate implements native
|
|
157
|
-
behavior, `napi/` maps it into this package’s JavaScript API, and
|
|
158
|
-
`traffic-presenter/` builds the sidecar. See the root
|
|
159
|
-
[README](../README.md#repository-structure) for the complete layout and build
|
|
160
|
-
commands.
|
|
161
|
-
|
|
162
|
-
This project is derived from
|
|
163
|
-
[`UruhaLushia/sparkle-native`](https://github.com/UruhaLushia/sparkle-native)
|
|
164
|
-
and is licensed under GPL-3.0-only.
|
|
40
|
+
Derived from [UruhaLushia/sparkle-native](https://github.com/UruhaLushia/sparkle-native)
|
|
41
|
+
and licensed under GPL-3.0-only.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kokorobox-native",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.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.16.
|
|
52
|
-
"kokorobox-native-win32-arm64-msvc": "0.16.
|
|
53
|
-
"kokorobox-native-darwin-x64": "0.16.
|
|
54
|
-
"kokorobox-native-darwin-arm64": "0.16.
|
|
55
|
-
"kokorobox-native-linux-x64-gnu": "0.16.
|
|
56
|
-
"kokorobox-native-linux-arm64-gnu": "0.16.
|
|
51
|
+
"kokorobox-native-win32-x64-msvc": "0.16.1",
|
|
52
|
+
"kokorobox-native-win32-arm64-msvc": "0.16.1",
|
|
53
|
+
"kokorobox-native-darwin-x64": "0.16.1",
|
|
54
|
+
"kokorobox-native-darwin-arm64": "0.16.1",
|
|
55
|
+
"kokorobox-native-linux-x64-gnu": "0.16.1",
|
|
56
|
+
"kokorobox-native-linux-arm64-gnu": "0.16.1"
|
|
57
57
|
}
|
|
58
58
|
}
|