@octane-xplat/fingerprint 0.19.0 → 0.20.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 +2 -115
- package/dist/cli.js +1 -1
- package/dist/index.js +27 -13
- package/dist/native-config.js +1 -1
- package/dist/native-resolutions.js +1 -1
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -1,118 +1,5 @@
|
|
|
1
1
|
# @octane-xplat/fingerprint
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
JavaScript update. A fingerprint is a SHA-256 identity plus a list of hashed
|
|
5
|
-
inputs. The API follows [Expo Fingerprint](https://docs.expo.dev/versions/latest/sdk/fingerprint/)
|
|
6
|
-
names while collecting NativeScript inputs instead of Expo or React Native inputs.
|
|
3
|
+
[Documentation](https://octane-xplat.goddardai.org/package-fingerprint).
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
app's development dependencies with Node 22.22.2 or newer and Bun:
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
bun add -D @octane-xplat/fingerprint
|
|
13
|
-
bun run xplat-fingerprint --dir . --platform ios > native-inputs.json
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
The command prints JSON containing `hash` and `sources`. Compare it after a
|
|
17
|
-
change; each difference names an added, removed or changed input. Ordinary
|
|
18
|
-
app JavaScript changes do not change the native identity.
|
|
19
|
-
|
|
20
|
-
```sh
|
|
21
|
-
bun run xplat-fingerprint --dir . --platform ios --diff native-inputs.json
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Use in a build script
|
|
25
|
-
|
|
26
|
-
Create `scripts/native-inputs.mjs` in the app. The same inputs in different
|
|
27
|
-
checkout directories produce the same hash. Source records contain paths,
|
|
28
|
-
reasons and hashes; they omit the configuration values and file contents.
|
|
29
|
-
|
|
30
|
-
```js
|
|
31
|
-
import {
|
|
32
|
-
createFingerprintAsync,
|
|
33
|
-
createProjectHashAsync,
|
|
34
|
-
diffFingerprintChangesAsync,
|
|
35
|
-
} from '@octane-xplat/fingerprint'
|
|
36
|
-
|
|
37
|
-
const before = await createFingerprintAsync('.', { platforms: ['ios'] })
|
|
38
|
-
console.log(before.hash, before.sources.length)
|
|
39
|
-
console.log(await createProjectHashAsync('.', { platforms: ['ios'] }))
|
|
40
|
-
console.log(await diffFingerprintChangesAsync(before, '.', { platforms: ['ios'] }))
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
The defaults collect iOS and Android inputs together. Select a single platform
|
|
44
|
-
when comparing native binaries. Installed dependencies and a resolved Bun or pnpm
|
|
45
|
-
lockfile are required. When both lockfiles are present, set `packageManager`
|
|
46
|
-
in `package.json` to select one. Missing or ambiguous native dependency metadata fails
|
|
47
|
-
the operation rather than producing a compatibility claim.
|
|
48
|
-
|
|
49
|
-
```js
|
|
50
|
-
import { createFingerprintAsync, diffFingerprints } from '@octane-xplat/fingerprint'
|
|
51
|
-
|
|
52
|
-
const before = await createFingerprintAsync('.', { platforms: ['android'] })
|
|
53
|
-
const after = await createFingerprintAsync('.', { platforms: ['android'] })
|
|
54
|
-
console.log(diffFingerprints(before, after))
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Compare with an OTA binary
|
|
58
|
-
|
|
59
|
-
Follow [phone update setup](https://octane-xplat.goddardai.org/updates) to build
|
|
60
|
-
an OTA-enabled release. Its prepare hook captures compiler and SDK identity,
|
|
61
|
-
build mode, declared compiler overrides, native sources and resolved native
|
|
62
|
-
dependencies. The hook bakes the hash into native startup and saves a private
|
|
63
|
-
build record at `.xplat/fingerprints/ios.json` or `android.json`. Keep `.xplat/`
|
|
64
|
-
out of Git. Use that record to reproduce the build's compiler context on a
|
|
65
|
-
publishing machine; a source-only invocation has a different context.
|
|
66
|
-
|
|
67
|
-
```sh
|
|
68
|
-
bun run xplat-fingerprint --dir . \
|
|
69
|
-
--build-record .xplat/fingerprints/ios.json \
|
|
70
|
-
--diff .xplat/fingerprints/ios.json
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
An empty diff means the collected inputs still match. It does not prove that
|
|
74
|
-
arbitrary custom build steps are deterministic or that a payload is safe.
|
|
75
|
-
The OTA publisher checks the record automatically; native startup separately
|
|
76
|
-
rejects an incompatible staged payload before its JavaScript runs.
|
|
77
|
-
|
|
78
|
-
## Include a custom native input
|
|
79
|
-
|
|
80
|
-
Add `fingerprint.config.json` at the app root when a custom build step reads
|
|
81
|
-
an additional file. `extraSources` augments automatic collection; executable
|
|
82
|
-
fingerprint config files are unsupported. `ignorePaths` and `.fingerprintignore`
|
|
83
|
-
can exclude extra inputs, but excluding an automatic native input is an error.
|
|
84
|
-
|
|
85
|
-
```json
|
|
86
|
-
{
|
|
87
|
-
"extraSources": [
|
|
88
|
-
{
|
|
89
|
-
"type": "file",
|
|
90
|
-
"filePath": "native-options.json",
|
|
91
|
-
"reasons": ["custom native generator input"]
|
|
92
|
-
}
|
|
93
|
-
],
|
|
94
|
-
"toolchain": { "customGeneratorVersion": "1" }
|
|
95
|
-
}
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
The collector includes evaluated NativeScript configuration, custom resources,
|
|
99
|
-
declared `NativeSource` files, native plugin files and versions, relevant Bun or pnpm
|
|
100
|
-
resolutions and patches, hooks, native declarations and available Pod/SwiftPM/
|
|
101
|
-
Gradle lock records. It executes the app's trusted NativeScript configuration
|
|
102
|
-
as build code, including relative configuration helpers. Declare any extra
|
|
103
|
-
inputs those helpers consume. Symbolic links must stay within their declared
|
|
104
|
-
input root. Inspect the collected records when qualifying a custom build:
|
|
105
|
-
|
|
106
|
-
```js
|
|
107
|
-
import { createFingerprintAsync } from '@octane-xplat/fingerprint'
|
|
108
|
-
|
|
109
|
-
const fingerprint = await createFingerprintAsync('.', { platforms: ['ios'] })
|
|
110
|
-
for (const source of fingerprint.sources) console.log(source)
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Source collection also accepts `macos`, `linux` and `windows` for build-tool
|
|
114
|
-
diagnostics. OTA activation remains iOS/Android only; there is no browser
|
|
115
|
-
runtime API. Apple compiler capture belongs on the Apple build host, and
|
|
116
|
-
Android compiler capture belongs on its configured SDK host. Android runtime
|
|
117
|
-
qualification is currently unverified. See the [implementation evidence](../../.agents/docs/notes/fingerprint.md)
|
|
118
|
-
for collector limits and platform verification.
|
|
5
|
+
[API reference](https://octane-xplat.goddardai.org/api-fingerprint).
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import process from 'node:process';
|
|
|
3
3
|
import { parseArgs } from 'node:util';
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
5
|
import { resolve } from 'node:path';
|
|
6
|
-
import { createFingerprintAsync, diffFingerprintChangesAsync, NATIVE_FINGERPRINT_FORMAT, } from
|
|
6
|
+
import { createFingerprintAsync, diffFingerprintChangesAsync, NATIVE_FINGERPRINT_FORMAT, } from './index.js';
|
|
7
7
|
const { values } = parseArgs({
|
|
8
8
|
options: {
|
|
9
9
|
dir: { type: 'string' },
|
package/dist/index.js
CHANGED
|
@@ -6,10 +6,10 @@ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
|
6
6
|
import { minimatch } from 'minimatch';
|
|
7
7
|
import { parse } from 'yaml';
|
|
8
8
|
import { parse as parseJsonc } from 'jsonc-parser';
|
|
9
|
-
import { nativeResolutions } from
|
|
10
|
-
import { configValue, readNativeConfig } from
|
|
11
|
-
export { captureNativeToolchainAsync } from
|
|
12
|
-
export { readNativeConfig as resolveNativeConfigAsync } from
|
|
9
|
+
import { nativeResolutions } from './native-resolutions.js';
|
|
10
|
+
import { configValue, readNativeConfig } from './native-config.js';
|
|
11
|
+
export { captureNativeToolchainAsync } from './toolchain.js';
|
|
12
|
+
export { readNativeConfig as resolveNativeConfigAsync } from './native-config.js';
|
|
13
13
|
export const NATIVE_FINGERPRINT_FORMAT = 'octane-xplat.native-fingerprint.v1';
|
|
14
14
|
const hash = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
15
15
|
const slash = (path) => path.split(sep).join('/');
|
|
@@ -370,18 +370,32 @@ export async function createFingerprintAsync(projectRoot, supplied = {}) {
|
|
|
370
370
|
if (key === identity || key.startsWith(identity + '(')) {
|
|
371
371
|
return true;
|
|
372
372
|
}
|
|
373
|
-
const
|
|
373
|
+
const resolution = typeof raw === 'object' && raw !== null && 'resolution' in raw
|
|
374
|
+
? raw.resolution
|
|
375
|
+
: undefined;
|
|
374
376
|
return (key.startsWith(pkg.name + '@file:') &&
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
377
|
+
typeof resolution === 'object' &&
|
|
378
|
+
resolution !== null &&
|
|
379
|
+
'type' in resolution &&
|
|
380
|
+
resolution.type === 'directory' &&
|
|
381
|
+
'directory' in resolution &&
|
|
382
|
+
typeof resolution.directory === 'string' &&
|
|
383
|
+
existsSync(resolve(lockRoot, resolution.directory)) &&
|
|
384
|
+
realpathSync(resolve(lockRoot, resolution.directory)) === packageRoot);
|
|
379
385
|
})
|
|
380
386
|
.map(([key, raw]) => {
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
const resolution = typeof raw === 'object' && raw !== null && 'resolution' in raw
|
|
388
|
+
? raw.resolution
|
|
389
|
+
: undefined;
|
|
390
|
+
return typeof resolution === 'object' &&
|
|
391
|
+
resolution !== null &&
|
|
392
|
+
'type' in resolution &&
|
|
393
|
+
resolution.type === 'directory'
|
|
394
|
+
? [
|
|
395
|
+
identity + ':directory',
|
|
396
|
+
{ ...raw, resolution: { type: 'directory' } },
|
|
397
|
+
]
|
|
398
|
+
: [key, raw];
|
|
385
399
|
});
|
|
386
400
|
if (bunEntry) {
|
|
387
401
|
const source = String(bunEntry[0]);
|
package/dist/native-config.js
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { dirname, resolve } from 'node:path';
|
|
5
5
|
import { compileFunction } from 'node:vm';
|
|
6
|
-
import { ModuleKind, transpileModule } from 'typescript';
|
|
6
|
+
import { ModuleKind, transpileModule } from 'typescript-classic';
|
|
7
7
|
/** Evaluate the trusted app config as NativeScript does, with a fresh module per call. */
|
|
8
8
|
export async function readNativeConfig(root) {
|
|
9
9
|
const override = process.env.NATIVESCRIPT_CONFIG_NAME;
|
|
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { glob, readFile, realpath } from 'node:fs/promises';
|
|
3
3
|
import { join, resolve, sep } from 'node:path';
|
|
4
4
|
import { parse } from 'yaml';
|
|
5
|
-
import { configValue } from
|
|
5
|
+
import { configValue } from './native-config.js';
|
|
6
6
|
/** Native lock records omit cache paths and derived origin hashes, retaining resolved identities. */
|
|
7
7
|
export async function nativeResolutions(root, platforms, nativeConfig, add, tree) {
|
|
8
8
|
const nativeRoot = resolve(root, typeof nativeConfig.buildPath === 'string' ? nativeConfig.buildPath : 'platforms');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octane-xplat/fingerprint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Expo-shaped native compatibility fingerprints for Octane Xplat projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,20 +26,22 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
|
-
"build": "tsc -p tsconfig.build.json",
|
|
30
|
-
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
29
|
+
"build": "tsc --runExternalCode -p tsconfig.build.json",
|
|
30
|
+
"typecheck": "tsc --runExternalCode -p tsconfig.build.json --noEmit",
|
|
31
31
|
"test": "node --test tests/*.test.mjs",
|
|
32
32
|
"prepack": "bun run build",
|
|
33
33
|
"test:packed": "node tests/packed-consumer.mjs"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"jsonc-parser": "3.3.1",
|
|
37
|
-
"minimatch": "
|
|
38
|
-
"
|
|
39
|
-
"
|
|
37
|
+
"minimatch": "11.0.3",
|
|
38
|
+
"yaml": "2.9.1",
|
|
39
|
+
"typescript-classic": "npm:typescript@5.9.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@types/node": "
|
|
42
|
+
"@types/node": "26.6.6",
|
|
43
|
+
"@tsrx/content-mapper": "0.1.2",
|
|
44
|
+
"typescript": "7.1.0-beta"
|
|
43
45
|
},
|
|
44
46
|
"engines": {
|
|
45
47
|
"node": ">=22.22.2"
|