@neko-makura/railid 1.1.1 → 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 CHANGED
@@ -60,6 +60,26 @@ const decoded = railid.decode(id);
60
60
  console.log(decoded.timestampMs, decoded.randomHex, decoded.encoded);
61
61
  ```
62
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
+
63
83
  ## API
64
84
 
65
85
  | Function | Result | Notes |
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.1.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,6 +28,8 @@
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"
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file