@neko-makura/railid 1.1.0 → 1.2.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 +64 -5
- package/no-tpm.d.ts +37 -0
- package/no-tpm.js +24 -0
- package/package.json +4 -1
- package/railid-tpm.linux-x64-gnu.node +0 -0
- package/railid.darwin-arm64.node +0 -0
- package/railid.darwin-x64.node +0 -0
- package/railid.linux-arm-gnu.node +0 -0
- package/railid.linux-arm64-gnu.node +0 -0
- package/railid.linux-arm64-musl.node +0 -0
- package/railid.linux-riscv64-gnu.node +0 -0
- package/railid.linux-x64-gnu.node +0 -0
- package/railid.linux-x64-musl.node +0 -0
- package/railid.win32-arm64-msvc.node +0 -0
- package/railid.win32-x64-msvc.node +0 -0
package/README.md
CHANGED
|
@@ -8,6 +8,29 @@ npm install @neko-makura/railid
|
|
|
8
8
|
|
|
9
9
|
The package includes prebuilt N-API binaries. Node.js 18 or newer is required.
|
|
10
10
|
|
|
11
|
+
## Platforms
|
|
12
|
+
|
|
13
|
+
| Platform | Architecture | libc | Backend |
|
|
14
|
+
|---|---|---|---|
|
|
15
|
+
| Linux | x64 | glibc | TPM (`libtss2`) + OS-only fallback |
|
|
16
|
+
| Linux | x64 | musl | OS-only |
|
|
17
|
+
| Linux | arm64 | glibc | OS-only |
|
|
18
|
+
| Linux | arm64 | musl | OS-only |
|
|
19
|
+
| Linux | armv7 | glibc (hard-float) | OS-only |
|
|
20
|
+
| Linux | riscv64 | glibc | OS-only |
|
|
21
|
+
| Windows | x64 | MSVC | TPM (TBS) |
|
|
22
|
+
| Windows | arm64 | MSVC | TPM (TBS) |
|
|
23
|
+
| macOS | x64 | — | OS-only |
|
|
24
|
+
| macOS | arm64 | — | OS-only |
|
|
25
|
+
|
|
26
|
+
`index.js` selects the addon from `process.platform`, `process.arch` and, on
|
|
27
|
+
Linux, whether the Node process runs on glibc or musl.
|
|
28
|
+
|
|
29
|
+
The riscv64 addon targets the `riscv64gc` glibc ABI used by distribution Node
|
|
30
|
+
builds (for example Ubuntu 24.04). Node.js does not publish official riscv64
|
|
31
|
+
binaries; use a distribution package.
|
|
32
|
+
|
|
33
|
+
|
|
11
34
|
## Usage
|
|
12
35
|
|
|
13
36
|
```js
|
|
@@ -37,6 +60,26 @@ const decoded = railid.decode(id);
|
|
|
37
60
|
console.log(decoded.timestampMs, decoded.randomHex, decoded.encoded);
|
|
38
61
|
```
|
|
39
62
|
|
|
63
|
+
## TPM-less deployments
|
|
64
|
+
|
|
65
|
+
The default entry point keeps the fail-closed TPM hybrid profile: `generate()`
|
|
66
|
+
throws `TpmUnavailable` when the backend or the device is missing. Hosts that
|
|
67
|
+
never have a TPM (for example a Raspberry Pi 4) should import the explicit
|
|
68
|
+
TPM-less entry point:
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
const railid = require('@neko-makura/railid/no-tpm');
|
|
72
|
+
|
|
73
|
+
railid.backend(); // "os-only"
|
|
74
|
+
const id = railid.generate();
|
|
75
|
+
const ids = railid.generateMany(1000);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
It exposes the same functions and output format, but every generator uses the
|
|
79
|
+
explicitly degraded OS-only profile and `generateMany(count)` takes no profile
|
|
80
|
+
argument. The choice is visible at the import site, and the default entry point
|
|
81
|
+
still never falls back implicitly.
|
|
82
|
+
|
|
40
83
|
## API
|
|
41
84
|
|
|
42
85
|
| Function | Result | Notes |
|
|
@@ -87,8 +130,8 @@ use the batch APIs.
|
|
|
87
130
|
|
|
88
131
|
## Linux and TPM
|
|
89
132
|
|
|
90
|
-
The Linux TPM binary links against `libtss2` (`tss-esapi`). The
|
|
91
|
-
two Linux x64 binaries:
|
|
133
|
+
The Linux x64 glibc TPM binary links against `libtss2` (`tss-esapi`). The
|
|
134
|
+
package ships two Linux x64 glibc binaries:
|
|
92
135
|
|
|
93
136
|
- `railid-tpm.linux-x64-gnu.node` — TPM backend; needs `libtss2`
|
|
94
137
|
- `railid.linux-x64-gnu.node` — OS-only; no TSS dependency
|
|
@@ -104,6 +147,10 @@ Debian/Ubuntu TPM users need:
|
|
|
104
147
|
sudo apt install libtss2
|
|
105
148
|
```
|
|
106
149
|
|
|
150
|
+
Alpine, arm64, armv7 and riscv64 ship the OS-only backend only. Those
|
|
151
|
+
platforms load `railid.<platform>-<arch>[-<libc>].node` directly, so `generate()`
|
|
152
|
+
throws `TpmUnavailable` and `generateOsOnly()` is the supported profile.
|
|
153
|
+
|
|
107
154
|
Windows uses the system TBS service (`Tbs.dll`) and needs no extra DLL. macOS
|
|
108
155
|
ships the OS-only backend.
|
|
109
156
|
|
|
@@ -116,13 +163,25 @@ Requirements:
|
|
|
116
163
|
- Node.js 18+
|
|
117
164
|
|
|
118
165
|
```bash
|
|
119
|
-
npm run build #
|
|
166
|
+
npm run build # host default
|
|
120
167
|
npm run build -- --os-only
|
|
168
|
+
npm run build -- --target linux-arm64-musl # cross target, OS-only
|
|
169
|
+
npm run verify # check every .node binary against its target tag
|
|
121
170
|
npm test
|
|
122
171
|
```
|
|
123
172
|
|
|
124
|
-
|
|
125
|
-
|
|
173
|
+
`node scripts/build.js --list` prints the supported targets. On Linux the
|
|
174
|
+
default build produces both TPM and OS-only binaries for x64; other targets
|
|
175
|
+
produce the OS-only binary. On Windows it produces the TPM binary. On macOS it
|
|
176
|
+
produces both OS-only slices.
|
|
177
|
+
|
|
178
|
+
Cross-compiling without a matching host is easiest in a container. The helper
|
|
179
|
+
installs the toolchain for the requested target:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
docker run --rm -v "$PWD:/src" -w /src/node rust:1.88-alpine \
|
|
183
|
+
sh scripts/build-in-docker.sh linux-arm64-musl
|
|
184
|
+
```
|
|
126
185
|
|
|
127
186
|
## Benchmarks
|
|
128
187
|
|
package/no-tpm.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DecodedRailId } from "./index";
|
|
2
|
+
|
|
3
|
+
export type { DecodedRailId };
|
|
4
|
+
export type Backend = "os-only";
|
|
5
|
+
|
|
6
|
+
/** Generate one RailID with the explicitly degraded OS-only profile. */
|
|
7
|
+
export declare function generate(): string;
|
|
8
|
+
|
|
9
|
+
/** Same as `generate()`; kept for symmetry with the default entry point. */
|
|
10
|
+
export declare function generateOsOnly(): string;
|
|
11
|
+
|
|
12
|
+
/** Generate one OS-only RailID as 32 ASCII bytes, without a JS string. */
|
|
13
|
+
export declare function generateBuffer(): Buffer;
|
|
14
|
+
|
|
15
|
+
/** Same as `generateBuffer()`; kept for symmetry. */
|
|
16
|
+
export declare function generateOsOnlyBuffer(): Buffer;
|
|
17
|
+
|
|
18
|
+
/** Generate `count` IDs synchronously as strings. */
|
|
19
|
+
export declare function generateMany(count: number): string[];
|
|
20
|
+
|
|
21
|
+
/** Generate `count` IDs synchronously as one contiguous `count * 32` Buffer. */
|
|
22
|
+
export declare function generateManyEncoded(count: number): Buffer;
|
|
23
|
+
|
|
24
|
+
/** Generate `count` IDs asynchronously as strings. */
|
|
25
|
+
export declare function generateManyAsync(count: number): Promise<string[]>;
|
|
26
|
+
|
|
27
|
+
/** Generate `count` IDs asynchronously as one contiguous `count * 32` Buffer. */
|
|
28
|
+
export declare function generateManyEncodedAsync(count: number): Promise<Buffer>;
|
|
29
|
+
|
|
30
|
+
/** Decode and validate a RailID. */
|
|
31
|
+
export declare function decode(input: string): DecodedRailId;
|
|
32
|
+
|
|
33
|
+
/** RailID crate version. */
|
|
34
|
+
export declare function version(): string;
|
|
35
|
+
|
|
36
|
+
/** Always `"os-only"` for this entry point. */
|
|
37
|
+
export declare function backend(): Backend;
|
package/no-tpm.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// TPM-less entry point.
|
|
4
|
+
//
|
|
5
|
+
// The default entry point keeps the fail-closed TPM hybrid profile: `generate()`
|
|
6
|
+
// throws when no TPM is available. This module is the explicit opt-in for hosts
|
|
7
|
+
// that never have a TPM. Every generator here uses the degraded OS-only
|
|
8
|
+
// profile, and the choice is visible at the import site.
|
|
9
|
+
const core = require('./index.js');
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
...core,
|
|
13
|
+
generate: core.generateOsOnly,
|
|
14
|
+
generateBuffer: core.generateOsOnlyBuffer,
|
|
15
|
+
// The `osOnly` argument is accepted for signature compatibility and always
|
|
16
|
+
// resolves to the OS-only profile.
|
|
17
|
+
generateMany: (count) => core.generateMany(count, true),
|
|
18
|
+
generateManyEncoded: (count) => core.generateManyEncoded(count, true),
|
|
19
|
+
generateManyAsync: (count) => core.generateManyAsync(count, true),
|
|
20
|
+
generateManyEncodedAsync: (count) => core.generateManyEncodedAsync(count, true),
|
|
21
|
+
// The loaded binary may still contain the TPM backend, but this module never
|
|
22
|
+
// calls it.
|
|
23
|
+
backend: () => 'os-only',
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neko-makura/railid",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Native N-API bindings for RailID: 192-bit timestamp-first identifiers with TPM 2.0 + OS CSPRNG randomness",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,12 +28,15 @@
|
|
|
28
28
|
"files": [
|
|
29
29
|
"index.js",
|
|
30
30
|
"index.d.ts",
|
|
31
|
+
"no-tpm.js",
|
|
32
|
+
"no-tpm.d.ts",
|
|
31
33
|
"*.node",
|
|
32
34
|
"README.md",
|
|
33
35
|
"LICENSE"
|
|
34
36
|
],
|
|
35
37
|
"scripts": {
|
|
36
38
|
"build": "node scripts/build.js",
|
|
39
|
+
"verify": "node scripts/verify.js",
|
|
37
40
|
"test": "node test.js",
|
|
38
41
|
"pack:check": "npm pack --dry-run"
|
|
39
42
|
}
|
|
Binary file
|
package/railid.darwin-arm64.node
CHANGED
|
Binary file
|
package/railid.darwin-x64.node
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|