si-hawk 0.0.0-stage → 1.1.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/LICENSE +37 -0
- package/README.md +218 -3
- package/assets/hawk.jpeg +0 -0
- package/assets/manifest.json +19 -0
- package/package.json +55 -6
- package/src/capabilities.js +152 -0
- package/src/cli.js +182 -0
- package/src/detect.js +165 -0
- package/src/evo.js +3 -0
- package/src/fingerprint.js +122 -0
- package/src/format.js +447 -0
- package/src/index.js +192 -0
- package/src/inv.js +3 -0
- package/src/monitor.js +110 -0
- package/src/network.js +211 -0
- package/src/node.js +184 -0
- package/src/portable.js +84 -0
- package/src/processes.js +41 -0
- package/src/scan.js +263 -0
- package/src/services.js +30 -0
- package/src/types.d.ts +216 -0
- package/src/util.js +16 -0
- package/src/windows.js +201 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Uviwe Menyiwe (Azura Daemon), HAEL Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
NOTE ON PER-PACKAGE LICENSES: this repository is a monorepo, and not every
|
|
26
|
+
package below is MIT-licensed. This root license applies to the repository
|
|
27
|
+
scaffolding and to every package whose own package.json declares "license":
|
|
28
|
+
"MIT" (the majority). Exceptions, each with its own LICENSE file in that
|
|
29
|
+
package's directory:
|
|
30
|
+
|
|
31
|
+
- packages/constitution, packages/contracts, packages/council,
|
|
32
|
+
packages/customs-shield, packages/nervous-system, packages/weave
|
|
33
|
+
are licensed under Apache License 2.0.
|
|
34
|
+
- tools/lycon-browser is licensed under the Mozilla Public License 2.0.
|
|
35
|
+
|
|
36
|
+
Check a given package's package.json "license" field and its own LICENSE
|
|
37
|
+
file, if present, before assuming MIT applies.
|
package/README.md
CHANGED
|
@@ -1,3 +1,218 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# SI-Hawk — Device Intelligence and System Observer
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
SI-Hawk is a local-first, command-line-first device intelligence and system observation toolkit. It observes and monitors the device running it and, only when explicitly requested, the immediate radio/network surroundings visible to that device. It is a researcher and observer, not a protector, browser sentinel, or enforcement tool.
|
|
6
|
+
|
|
7
|
+
The assigned Hawk portrait is preserved in `assets/hawk.jpeg` for the local project and future interfaces. Its assignment and checksum are recorded in [`assets/manifest.json`](assets/manifest.json). The assigned Lycon–Hawk composition is not present in this local copy; Hawk does not substitute other artwork for it.
|
|
8
|
+
|
|
9
|
+
## Quick Start — command line
|
|
10
|
+
|
|
11
|
+
After `si-hawk` is published to npm, install the package and run the unified executable:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install --global si-hawk
|
|
15
|
+
|
|
16
|
+
si-hawk --help
|
|
17
|
+
si-hawk --version
|
|
18
|
+
si-hawk inv
|
|
19
|
+
si-hawk evo
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Until publication, run the CLI directly from a checkout with `node src/cli.js --help` or `node src/cli.js inv`.
|
|
23
|
+
|
|
24
|
+
The legacy `hawk`, `hawk-inv`, and `hawk-evo` executables remain available as compatibility aliases. The existing published `@azura22/hawk` package is preserved and is not overwritten by this package transition.
|
|
25
|
+
|
|
26
|
+
- `si-hawk inv` reports the current device: identity, CPU, memory, storage, battery, connected components, processes, services, and network state where the operating system exposes them.
|
|
27
|
+
- `si-hawk evo` observes nearby Wi-Fi access points and passively received Bluetooth LE advertisements. This is an explicit scan command; it does not join networks, connect to devices, or search beyond the local radio range.
|
|
28
|
+
|
|
29
|
+
Use `--section processes|network|services|hardware|device` to expand one host section, or `--full` to show all details in the readable layout. `--json` writes JSON to stdout; `--json-file <path>` writes it to a file only when requested. CLI reports redact device identifiers by default; use `--redact none` only when the output destination is trusted. `--no-color` disables color. Host watch mode does not perform nearby radio scans unless `--nearby` is supplied.
|
|
30
|
+
|
|
31
|
+
### Import from Node.js
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { hawkInv, hawkEvo } from 'si-hawk';
|
|
35
|
+
|
|
36
|
+
const device = await hawkInv();
|
|
37
|
+
const surroundings = await hawkEvo();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Both functions return promises and can be called independently by scripts and applications. Until the package is published to npm, install this draft branch locally with `npm install git+https://github.com/Daemon22/hawk.git#codex/hawk-inv-evo-cli`. GitHub authentication with access to this private repository is required.
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
### Host observer (Node.js)
|
|
45
|
+
|
|
46
|
+
`si-hawk inv --json` returns a point-in-time report of the device running SI-Hawk. It reads CPU model and logical processor count, RAM, storage for the volume containing the selected path, device identity where the OS exposes it, battery state where available, running processes, OS services, network interfaces, and the device's own Wi-Fi association. Each item carries its source and scope; unavailable values include a reason. SI-Hawk does not infer missing device facts.
|
|
47
|
+
|
|
48
|
+
`si-hawk evo` (or `si-hawk scan`) observes nearby Wi-Fi access points and passively received Bluetooth LE advertisements where an OS adapter is available. The command has readable text output; add `--json` for JSON. Add `--watch --interval 30` to observe successive scans and report newly seen or no-longer-seen entries. Watch is an explicit foreground command; SI-Hawk does not install a background service or persist nearby-device history.
|
|
49
|
+
|
|
50
|
+
CPU utilization is calculated from OS cumulative CPU counters sampled for at least one second. RAM and storage percentages are calculated from OS-reported byte counts. Device type, model, battery, process, service, and network fields come from named OS interfaces. Process command-line arguments are excluded. Access controls may limit inventories to processes, services, or devices visible to Hawk's execution context.
|
|
51
|
+
|
|
52
|
+
Run a continuing watch with JSON Lines output and observed changes:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
si-hawk --host --watch --interval 30 --json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The first record establishes a baseline. Later records report process starts/stops, service changes, active Wi-Fi connection changes, newly seen or removed nearby networks and Bluetooth LE advertisements, secondary neighbor-cache changes, and title-free foreground-application changes. The interval is a target; a slow OS query can make observations take longer.
|
|
59
|
+
|
|
60
|
+
Windows reads identity from the BIOS registry and PnP container data, battery state from `GetSystemPowerStatus`, processes from PowerShell `Get-Process`, services from `Get-Service`, attached PnP containers from `pnputil`, and the active Wi-Fi association from `netsh wlan show interfaces`. Nearby Wi-Fi uses `netsh wlan show networks mode=bssid`. Linux reads model/chassis from `/sys/class/dmi/id`, battery from `/sys/class/power_supply`, processes from `ps`, running services from `systemctl`, neighbors from `ip neigh`, and the active Wi-Fi association and nearby access points from `iw dev <interface> scan passive`. Passive Bluetooth LE observation uses `hcitool lescan --passive --duplicates` when installed. macOS reads hardware model from `system_profiler`, battery from `pmset`, processes from `ps`, launch agents/daemons from `launchctl`, neighbors from `arp`, and its current Wi-Fi network from `networksetup`; nearby Wi-Fi uses Apple's `airport -s` tool when present. Windows passive Bluetooth LE observation uses `BluetoothLEAdvertisementWatcher` through Windows PowerShell for a short observation window; availability depends on the radio, driver, and OS permissions. macOS passive scanning is unavailable through the current adapter, so Hawk reports the reason instead of starting active device discovery. Interface configuration comes from Node's OS interface. Device type remains null when the platform provides no direct value. Foreground application monitoring reports only process ID and process name, never a window title: Windows uses `GetForegroundWindow`/`GetWindowThreadProcessId`; Linux supports X11 through `xdotool` and reports Wayland as unavailable; macOS uses System Events and may require Accessibility permission.
|
|
61
|
+
|
|
62
|
+
SI-Hawk labels its evidence by detection case: `own-association` is the host OS's current Wi-Fi link; `nearby-access-point` is a network heard by the local Wi-Fi scan; and `same-lan-neighbor` is an entry in the host's OS neighbor cache. These cases do not imply each other. Nearby scans do not establish that SI-Hawk or the user is authorized to join a network. Neighbor entries can be stale or incomplete. Current adapters cannot classify hotspot mode; SI-Hawk reports that as unavailable instead of inferring it from an SSID or BSSID.
|
|
63
|
+
|
|
64
|
+
SI-Hawk does not connect, join, authenticate to, or alter a network or device. It does not capture other people's traffic, enable monitor mode, deauthenticate, interfere, or keep long-term history of a specific device. The Wi-Fi scan is an OS-managed scan; platform drivers control the radio scan behavior. Bluetooth is passive LE advertisement reception only. If an OS exposes only active Bluetooth discovery, SI-Hawk reports Bluetooth scanning unavailable and does not start active discovery.
|
|
65
|
+
|
|
66
|
+
The OpenWrt router adapter is legacy, non-core, and opt-in. It is excluded from the default host report and all `hawk scan` paths. It is not needed to report the monitored device's own Wi-Fi connection:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
si-hawk --host --router --json
|
|
70
|
+
si-hawk --host --router --watch --interval 30 --json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Set `HAWK_ROUTER_UBUS_URL`, `HAWK_ROUTER_USERNAME`, and `HAWK_ROUTER_PASSWORD` in the environment for a read-only OpenWrt account. The adapter calls `luci-rpc.getHostHints`, `network.wireless.status`, and `iwinfo.assoclist` through ubus JSON-RPC. Configure rpcd ACLs for only those read methods plus session login/destroy. HTTPS is mandatory for router credentials. Router queries are off unless `--router` is passed. The list covers associated stations on queried OpenWrt access points; it does not cover all router brands, wired devices, other mesh nodes, or every device elsewhere on the network.
|
|
74
|
+
|
|
75
|
+
SI-Hawk displays reports locally and does not upload them. CLI reports redact device identifiers by default; use `--redact none` only for trusted destinations. Host reports contain local system observations, and nearby radio scans can contain public SSIDs and advertisement metadata; each scan is an explicit command and nearby-device change comparisons remain in memory for that running watch only. The foreground-app field excludes window titles. Legacy browser APIs remain limited to signals exposed to the current page; they cannot list system processes or other apps. Cross-application and cross-device monitoring require separately installed, authorized agents.
|
|
76
|
+
|
|
77
|
+
OpenWrt references: [ubus sessions and JSON-RPC](https://openwrt.org/docs/techref/ubus), [network ubus methods](https://openwrt.org/docs/guide-developer/ubus/network), and [iwinfo association methods](https://openwrt.org/docs/guide-developer/ubus/iwinfo).
|
|
78
|
+
|
|
79
|
+
### Legacy browser API — non-core
|
|
80
|
+
|
|
81
|
+
The following browser APIs remain available for compatibility. They do not define SI-Hawk's identity or core command-line role.
|
|
82
|
+
|
|
83
|
+
#### `hawk.detect(env?)`
|
|
84
|
+
|
|
85
|
+
Returns device info from user-agent parsing **and** environment capabilities (UA parsing + feature checks merged).
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
{
|
|
89
|
+
type: 'desktop', // 'mobile' | 'tablet' | 'desktop' | 'bot'
|
|
90
|
+
brand: 'Apple',
|
|
91
|
+
model: 'Macintosh',
|
|
92
|
+
os: 'macOS',
|
|
93
|
+
osVersion: '14.0',
|
|
94
|
+
browser: 'Chrome',
|
|
95
|
+
version: '120.0',
|
|
96
|
+
engine: 'Blink',
|
|
97
|
+
bot: false,
|
|
98
|
+
language: 'en-US',
|
|
99
|
+
languages: ['en-US', 'en'],
|
|
100
|
+
onLine: true,
|
|
101
|
+
cookieEnabled: true,
|
|
102
|
+
// Capabilities (merged from detectCapabilities):
|
|
103
|
+
screen: { supported: true, width: 2560, height: 1600, availWidth: 2560, availHeight: 1575, colorDepth: 30, pixelRatio: 2, orientation: null },
|
|
104
|
+
touch: { supported: false, touchSupport: false, maxTouchPoints: 0, pointerEnabled: false },
|
|
105
|
+
webgl: { supported: false, version: null, vendor: null, renderer: null, unmaskedVendor: null, unmaskedRenderer: null },
|
|
106
|
+
audio: { supported: false, sampleRate: null, channelCount: null, contextSupport: false },
|
|
107
|
+
sw: { supported: true },
|
|
108
|
+
storage: { supported: true, localStorage: true, sessionStorage: true, indexedDB: true, quota: null, usage: null },
|
|
109
|
+
network: { supported: false, online: true, connection: null },
|
|
110
|
+
performance: { supported: false, memory: { usedJSHeapSize: null, totalJSHeapSize: null, jsHeapSizeLimit: null }, timing: null, nowPrecision: null },
|
|
111
|
+
battery: { supported: false }
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Field reference:
|
|
116
|
+
- `type` — device type: `'desktop' | 'mobile' | 'tablet' | 'bot'`
|
|
117
|
+
- `brand` — device/OS brand: `'Apple' | 'Samsung' | 'Huawei' | ... | 'unknown'`
|
|
118
|
+
- `model` — extracted device model from the UA (e.g. `'Pixel 8 Pro'`, `'SM-S918B'`); `null` when not present
|
|
119
|
+
- `os` — operating system: `'windows' | 'macos' | 'linux' | 'android' | 'ios' | 'chromeos' | 'windows-phone' | 'unknown'`
|
|
120
|
+
- `osVersion` — OS version string (e.g. `'10.0'`, `'14'`, `'17.2'`); `null` when not detectable
|
|
121
|
+
- `browser` — browser name: `'Chrome' | 'Firefox' | 'Edge' | 'Safari' | 'Opera' | 'Samsung Internet' | 'unknown'`
|
|
122
|
+
- `version` — browser version string (e.g. `'120.0.0.0'`); `null` when not detectable
|
|
123
|
+
- `engine` — rendering engine: `'blink' | 'webkit' | 'gecko' | 'presto' | 'unknown'`
|
|
124
|
+
- `bot` — whether the UA matches a known bot/crawler signature
|
|
125
|
+
|
|
126
|
+
OS names are lowercase. Browsers listed in priority order: Edge (including `EdgiOS`/`EdgA`) is checked before Chrome; Opera (including Opera Mini) before Chrome; Samsung Internet before Chrome; Chrome (including `CriOS`) before Safari.
|
|
127
|
+
|
|
128
|
+
#### `hawk.fingerprint(env?)`
|
|
129
|
+
|
|
130
|
+
Generates a privacy-respecting device fingerprint. No personal data, cookies, or tracking IDs.
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
{
|
|
134
|
+
hash: 'a1b2c3d4e5f6a7b8c9d0e1f2', // 24-char hex hash
|
|
135
|
+
components: { // individual 8-char signal hashes
|
|
136
|
+
userAgent: '4a3b2c1d',
|
|
137
|
+
screen: '7f8e9d0a',
|
|
138
|
+
timezone: '1b2c3d4e',
|
|
139
|
+
language: '5e6f7a8b',
|
|
140
|
+
platform: '9c0d1e2f',
|
|
141
|
+
cpuCores: '3a4b5c6d',
|
|
142
|
+
deviceMemory: '7e8f9a0b',
|
|
143
|
+
canvas: '1c2d3e4f',
|
|
144
|
+
webgl: '5e6f7a8b',
|
|
145
|
+
audio: '9c0d1e2f',
|
|
146
|
+
fonts: '3a4b5c6d'
|
|
147
|
+
},
|
|
148
|
+
timestamp: 1700000000000
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Every advertised component influences the final 24-character hash. Changing any signal — language, screen, timezone, platform, CPU cores, device memory, canvas, WebGL, audio, or fonts — produces a different fingerprint.
|
|
153
|
+
|
|
154
|
+
#### `hawk.monitor(callback, env?)`
|
|
155
|
+
|
|
156
|
+
Subscribes to environment changes. Returns an unsubscribe function.
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
const unsub = hawk.monitor(({ type, detail }) => {
|
|
160
|
+
console.log(type, detail)
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
unsub() // stop monitoring
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Events:
|
|
167
|
+
- `visibility` — `{ hidden }`
|
|
168
|
+
- `network` — `{ online }`
|
|
169
|
+
- `connection` — `{ effectiveType, downlink, rtt }`
|
|
170
|
+
- `battery` — `{ charging, level }`
|
|
171
|
+
|
|
172
|
+
When the optional `env` argument is omitted, `globalThis` is used. When a browser API is unavailable, the corresponding event listener is simply not registered. Unsubscribe removes all registered listeners, including those from asynchronous `navigator.getBattery()` resolution.
|
|
173
|
+
|
|
174
|
+
#### `hawk.snapshot(env?)`
|
|
175
|
+
|
|
176
|
+
Returns everything in one call: detect (device + capabilities merged) + fingerprint + timestamp.
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
{
|
|
180
|
+
detect: { /* same as hawk.detect() */ },
|
|
181
|
+
fingerprint: { /* same as hawk.fingerprint() */ },
|
|
182
|
+
timestamp: 1700000000000
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Modules
|
|
187
|
+
|
|
188
|
+
All functions are available as named exports and as methods on the default `hawk` object.
|
|
189
|
+
|
|
190
|
+
| Export | Description |
|
|
191
|
+
|--------|-------------|
|
|
192
|
+
| `detect(env?)` | Legacy, non-core: parse user-agent + read navigator/capability info |
|
|
193
|
+
| `fingerprint(env?)` | Legacy, non-core: generate a 24-char privacy-respecting fingerprint |
|
|
194
|
+
| `snapshot(env?)` | Legacy, non-core: combine detect + fingerprint + timestamp |
|
|
195
|
+
| `monitor(callback, env?)` | Legacy, non-core: subscribe to environment change events |
|
|
196
|
+
| `parseUserAgent(ua)` | Standalone UA parser (returns browser, os, engine, type, bot, model, brand, version, osVersion) |
|
|
197
|
+
| `detectDevice(env?)` | Read navigator extras (language, onLine, cookieEnabled, etc.) |
|
|
198
|
+
| `detectCapabilities(env?)` | Read screen, touch, WebGL, audio, storage, network, service worker, battery, performance |
|
|
199
|
+
| `generateFingerprint(env?)` | Standalone fingerprint generator |
|
|
200
|
+
| `djb2(str, seed?)` | djb2 hash → 8-char hex string |
|
|
201
|
+
| `tryFn(fn, fallback?)` | Safe function wrapper (returns fallback on error) |
|
|
202
|
+
| `detectNode()` | Node.js environment info |
|
|
203
|
+
| `fingerprintNode()` | Node.js-specific fingerprint hash |
|
|
204
|
+
|
|
205
|
+
## Notes
|
|
206
|
+
|
|
207
|
+
- All functions accept an optional `env` parameter (defaults to `globalThis`) for testing or SSR.
|
|
208
|
+
- In Node.js, functions return partial results where browser APIs are unavailable (all capability `supported` flags become `false`).
|
|
209
|
+
- Zero external dependencies.
|
|
210
|
+
- All resource-heavy APIs (AudioContext, canvas elements, temporary DOM nodes) are cleaned up after use.
|
|
211
|
+
|
|
212
|
+
## Publishing
|
|
213
|
+
|
|
214
|
+
The package is distributed as **`si-hawk`**. The previously published **`@azura22/hawk`** package remains preserved.
|
|
215
|
+
|
|
216
|
+
Publication is handled by `.github/workflows/publish.yml`. Before creating a release, add an npm **Granular Access Token** with publish permission for `si-hawk` as the repository secret `NPM_TOKEN` at **Settings → Secrets and variables → Actions → New repository secret**. The token must not be committed to the repository or pasted into source files.
|
|
217
|
+
|
|
218
|
+
After adding the secret, create and publish a GitHub Release, or start the `Publish package` workflow manually. The workflow installs from the lockfile, runs the full test suite, and publishes with npm provenance and public access.
|
package/assets/hawk.jpeg
ADDED
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"identity": "HAWK / HAWKETH",
|
|
3
|
+
"assets": {
|
|
4
|
+
"portrait": {
|
|
5
|
+
"path": "hawk.jpeg",
|
|
6
|
+
"status": "present",
|
|
7
|
+
"role": "assigned Hawk portrait / identity image",
|
|
8
|
+
"source": "SAOS/identity_assets/hawk.jpeg",
|
|
9
|
+
"sha256": "8e3fde4188a9dff647eabf8bd70a14e45f7b73e6076e8e19b4f640bbc3a91526",
|
|
10
|
+
"preservation": "original bytes copied without editing or re-encoding"
|
|
11
|
+
},
|
|
12
|
+
"lyconHawkPairedComposition": {
|
|
13
|
+
"canonicalAssignment": "conjunctions/lycon-hawk-paired.png",
|
|
14
|
+
"status": "not-found-in-local-projects-checked",
|
|
15
|
+
"path": null,
|
|
16
|
+
"preservation": "do not generate a substitute; attach the assigned source when located"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "si-hawk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "si-hawk",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Local-first SI-Hawk device intelligence and system observation toolkit",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"types": "src/types.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/types.d.ts",
|
|
11
|
+
"import": "./src/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"si-hawk": "src/cli.js",
|
|
17
|
+
"hawk": "src/cli.js",
|
|
18
|
+
"hawk-inv": "src/inv.js",
|
|
19
|
+
"hawk-evo": "src/evo.js"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "node --test test/hawk.test.js test/polish.test.js test/node.test.js test/scan.test.js test/format.test.js test/cli.test.js",
|
|
23
|
+
"cli": "node src/cli.js",
|
|
24
|
+
"test:cli": "node --test test/cli.test.js"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"src/",
|
|
28
|
+
"assets/"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"device",
|
|
35
|
+
"observer",
|
|
36
|
+
"monitoring",
|
|
37
|
+
"host",
|
|
38
|
+
"telemetry",
|
|
39
|
+
"wifi",
|
|
40
|
+
"bluetooth",
|
|
41
|
+
"cli"
|
|
42
|
+
],
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/Daemon22/hawk.git"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/Daemon22/hawk/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/Daemon22/hawk#readme",
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { tryFn } from './util.js';
|
|
2
|
+
|
|
3
|
+
export function detectScreen(env = globalThis) {
|
|
4
|
+
env = env || {};
|
|
5
|
+
const screen = tryFn(() => env.screen || {}, {});
|
|
6
|
+
const win = tryFn(() => env.window || env || {}, env || {});
|
|
7
|
+
return {
|
|
8
|
+
supported: tryFn(() => !!env.screen && typeof env.screen === 'object', false),
|
|
9
|
+
width: tryFn(() => screen.width ?? null, null),
|
|
10
|
+
height: tryFn(() => screen.height ?? null, null),
|
|
11
|
+
availWidth: tryFn(() => screen.availWidth ?? null, null),
|
|
12
|
+
availHeight: tryFn(() => screen.availHeight ?? null, null),
|
|
13
|
+
colorDepth: tryFn(() => screen.colorDepth ?? null, null),
|
|
14
|
+
pixelRatio: tryFn(() => win.devicePixelRatio ?? null, null),
|
|
15
|
+
orientation: tryFn(() => screen.orientation?.type ?? null, null),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function detectTouch(env = globalThis) {
|
|
20
|
+
env = env || {};
|
|
21
|
+
const nav = tryFn(() => env.navigator || {}, {});
|
|
22
|
+
const touchSupport = tryFn(() => 'ontouchstart' in env, false);
|
|
23
|
+
const maxTouchPoints = tryFn(() => nav.maxTouchPoints ?? 0, 0);
|
|
24
|
+
const pointerEnabled = !!tryFn(() => nav.pointerEnabled || (env.matchMedia && env.matchMedia('(pointer: fine)').matches), false);
|
|
25
|
+
return {
|
|
26
|
+
supported: touchSupport || maxTouchPoints > 0,
|
|
27
|
+
touchSupport,
|
|
28
|
+
maxTouchPoints,
|
|
29
|
+
pointerEnabled,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function detectWebGL(env = globalThis) {
|
|
34
|
+
return tryFn(() => {
|
|
35
|
+
const canvas = env.document.createElement('canvas');
|
|
36
|
+
const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
|
|
37
|
+
if (!gl) return { supported: false };
|
|
38
|
+
const debug = gl.getExtension('WEBGL_debug_renderer_info');
|
|
39
|
+
return {
|
|
40
|
+
supported: true,
|
|
41
|
+
version: gl.getParameter(gl.VERSION) || 'WebGL 1.0',
|
|
42
|
+
vendor: gl.getParameter(gl.VENDOR),
|
|
43
|
+
renderer: gl.getParameter(gl.RENDERER),
|
|
44
|
+
unmaskedVendor: debug ? gl.getParameter(debug.UNMASKED_VENDOR_WEBGL) : null,
|
|
45
|
+
unmaskedRenderer: debug ? gl.getParameter(debug.UNMASKED_RENDERER_WEBGL) : null,
|
|
46
|
+
};
|
|
47
|
+
}, { supported: false });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function detectAudio(env = globalThis) {
|
|
51
|
+
return tryFn(() => {
|
|
52
|
+
const AudioContext = env.AudioContext || env.webkitAudioContext;
|
|
53
|
+
if (!AudioContext) return { supported: false };
|
|
54
|
+
const ctx = new AudioContext();
|
|
55
|
+
const result = {
|
|
56
|
+
supported: true,
|
|
57
|
+
sampleRate: ctx.sampleRate,
|
|
58
|
+
channelCount: ctx.destination?.maxChannelCount || 2,
|
|
59
|
+
contextSupport: true,
|
|
60
|
+
};
|
|
61
|
+
tryFn(() => ctx.close?.(), null);
|
|
62
|
+
return result;
|
|
63
|
+
}, { supported: false });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function detectStorage(env = globalThis) {
|
|
67
|
+
env = env || {};
|
|
68
|
+
const nav = tryFn(() => env.navigator || {}, {});
|
|
69
|
+
const supported = tryFn(() => !!env.localStorage && !!env.sessionStorage, false);
|
|
70
|
+
return {
|
|
71
|
+
supported,
|
|
72
|
+
localStorage: tryFn(() => !!env.localStorage, false),
|
|
73
|
+
sessionStorage: tryFn(() => !!env.sessionStorage, false),
|
|
74
|
+
indexedDB: tryFn(() => !!env.indexedDB, false),
|
|
75
|
+
quota: null,
|
|
76
|
+
usage: null,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function detectNetwork(env = globalThis) {
|
|
81
|
+
env = env || {};
|
|
82
|
+
const nav = tryFn(() => env.navigator || {}, {});
|
|
83
|
+
const conn = tryFn(() => nav.connection || nav.mozConnection || nav.webkitConnection, null);
|
|
84
|
+
return {
|
|
85
|
+
supported: !!conn,
|
|
86
|
+
online: tryFn(() => nav.onLine ?? null, null),
|
|
87
|
+
connection: conn ? {
|
|
88
|
+
type: tryFn(() => conn.type || conn.effectiveType || null, null),
|
|
89
|
+
downlink: tryFn(() => conn.downlink ?? null, null),
|
|
90
|
+
rtt: tryFn(() => conn.rtt ?? null, null),
|
|
91
|
+
saveData: tryFn(() => !!conn.saveData, false),
|
|
92
|
+
} : null,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function detectServiceWorker(env = globalThis) {
|
|
97
|
+
env = env || {};
|
|
98
|
+
const nav = tryFn(() => env.navigator || {}, {});
|
|
99
|
+
return { supported: tryFn(() => !!nav.serviceWorker, false) };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function detectBattery(env = globalThis) {
|
|
103
|
+
env = env || {};
|
|
104
|
+
const nav = tryFn(() => env.navigator || {}, {});
|
|
105
|
+
// BatteryManager is inherently async; detect() returns the sync
|
|
106
|
+
// support flag only. Use monitor() or navigator.getBattery() directly
|
|
107
|
+
// for live battery state.
|
|
108
|
+
const supported = tryFn(() => typeof nav.getBattery === 'function', false);
|
|
109
|
+
return { supported };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function detectPerformance(env = globalThis) {
|
|
113
|
+
env = env || {};
|
|
114
|
+
const perf = tryFn(() => env.performance || {}, {});
|
|
115
|
+
const mem = tryFn(() => perf.memory || {}, {});
|
|
116
|
+
return {
|
|
117
|
+
supported: tryFn(() => typeof perf.now === 'function', false),
|
|
118
|
+
memory: {
|
|
119
|
+
usedJSHeapSize: mem.usedJSHeapSize || null,
|
|
120
|
+
totalJSHeapSize: mem.totalJSHeapSize || null,
|
|
121
|
+
jsHeapSizeLimit: mem.jsHeapSizeLimit || null,
|
|
122
|
+
},
|
|
123
|
+
timing: tryFn(() => perf.timing ? {
|
|
124
|
+
navigationStart: perf.timing.navigationStart,
|
|
125
|
+
domComplete: perf.timing.domComplete,
|
|
126
|
+
loadEventEnd: perf.timing.loadEventEnd,
|
|
127
|
+
} : null, null),
|
|
128
|
+
nowPrecision: tryFn(() => {
|
|
129
|
+
if (typeof perf.now !== 'function') return null;
|
|
130
|
+
const t0 = perf.now();
|
|
131
|
+
const t1 = perf.now();
|
|
132
|
+
return t1 - t0 >= 0 ? t1 - t0 : null;
|
|
133
|
+
}, null),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function detectCapabilities(env = globalThis) {
|
|
138
|
+
env = env || {};
|
|
139
|
+
const fallback = { supported: false };
|
|
140
|
+
const safe = (fn) => tryFn(() => fn(env), fallback);
|
|
141
|
+
return {
|
|
142
|
+
screen: safe(detectScreen),
|
|
143
|
+
touch: safe(detectTouch),
|
|
144
|
+
webgl: safe(detectWebGL),
|
|
145
|
+
audio: safe(detectAudio),
|
|
146
|
+
storage: safe(detectStorage),
|
|
147
|
+
network: safe(detectNetwork),
|
|
148
|
+
sw: safe(detectServiceWorker),
|
|
149
|
+
battery: safe(detectBattery),
|
|
150
|
+
performance: safe(detectPerformance),
|
|
151
|
+
};
|
|
152
|
+
}
|