@neko-makura/railid 4.1.0 → 4.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 +25 -7
- package/index.d.ts +18 -0
- package/no-tpm.d.ts +15 -0
- package/no-tpm.js +2 -0
- package/package.json +1 -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
|
@@ -93,6 +93,10 @@ still never falls back implicitly.
|
|
|
93
93
|
| `generateOsOnlyBuffer()` | `Buffer` | OS-only as 32 ASCII bytes, no JS string |
|
|
94
94
|
| `generateV4()` | `string` | 126-bit v4; TPM hybrid profile, fails closed |
|
|
95
95
|
| `generateV4OsOnly()` | `string` | 126-bit v4; explicit degraded OS-only profile |
|
|
96
|
+
| `generateV4Buffer()` | `Buffer` | 126-bit v4; TPM profile as 21 ASCII bytes |
|
|
97
|
+
| `generateV4BufferOsOnly()` | `Buffer` | 126-bit v4; OS-only as 21 ASCII bytes |
|
|
98
|
+
| `generateV4ManyEncoded(count)` | `Buffer` | 126-bit v4; TPM profile; `count * 21` bytes |
|
|
99
|
+
| `generateV4ManyEncodedOsOnly(count)` | `Buffer` | 126-bit v4; OS-only; `count * 21` bytes |
|
|
96
100
|
| `generateMany(count, osOnly?)` | `string[]` | Sync; `osOnly` defaults to `false` |
|
|
97
101
|
| `generateManyEncoded(count, osOnly?)` | `Buffer` | Sync; `count * 32` bytes |
|
|
98
102
|
| `generateManyAsync(count, osOnly?)` | `Promise<string[]>` | Bulk work off the JS thread |
|
|
@@ -120,7 +124,7 @@ call; for throughput use `generateManyEncoded()` or
|
|
|
120
124
|
## RailID v4 (126-bit)
|
|
121
125
|
|
|
122
126
|
v4 is a distinct 126-bit format that encodes to exactly 21 characters of
|
|
123
|
-
unpadded Base64URL. It
|
|
127
|
+
unpadded Base64URL. It has single-value, Buffer, and contiguous batch APIs:
|
|
124
128
|
|
|
125
129
|
```js
|
|
126
130
|
const railid = require('@neko-makura/railid');
|
|
@@ -131,16 +135,30 @@ console.log(id); // 21 characters
|
|
|
131
135
|
|
|
132
136
|
// Explicit degraded OS-only profile.
|
|
133
137
|
const osId = railid.generateV4OsOnly();
|
|
138
|
+
|
|
139
|
+
// The Buffer contains the 21 encoded ASCII bytes, not the raw 16-byte value.
|
|
140
|
+
const encoded = railid.generateV4BufferOsOnly();
|
|
141
|
+
|
|
142
|
+
// One contiguous Buffer with no separators: count * 21 bytes.
|
|
143
|
+
const batch = railid.generateV4ManyEncodedOsOnly(1000);
|
|
144
|
+
for (let i = 0; i < 1000; i++) {
|
|
145
|
+
const value = batch.toString('ascii', i * 21, (i + 1) * 21);
|
|
146
|
+
}
|
|
134
147
|
```
|
|
135
148
|
|
|
136
|
-
- `generateV4()`
|
|
137
|
-
or TSS transport is available
|
|
138
|
-
|
|
139
|
-
- `generateV4OsOnly()
|
|
140
|
-
|
|
149
|
+
- `generateV4()` and `generateV4ManyEncoded()` use the TPM hybrid profile,
|
|
150
|
+
which is fail-closed: if no TPM or TSS transport is available they throw
|
|
151
|
+
`TpmUnavailable` and never silently use the OS CSPRNG.
|
|
152
|
+
- `generateV4OsOnly()`, `generateV4BufferOsOnly()`, and
|
|
153
|
+
`generateV4ManyEncodedOsOnly()` are the explicit OS-only opt-ins. The
|
|
154
|
+
`no-tpm` entry point maps `generateV4`, `generateV4Buffer`, and
|
|
155
|
+
`generateV4ManyEncoded` to them.
|
|
156
|
+
- A v4 batch samples the UTC day once, so every ID in one call carries the
|
|
157
|
+
same day. `count == 0` returns an empty Buffer.
|
|
158
|
+
- v4 batch limits match v1: 1,024 IDs for the TPM profile and 1,000,000 IDs
|
|
159
|
+
for OS-only. Counts above the limit are rejected before allocation.
|
|
141
160
|
- The v1 192-bit API above is unchanged: `generate()` and `generateOsOnly()`
|
|
142
161
|
still return 32-character v1 IDs. v4 does **not** reuse those names.
|
|
143
|
-
- There is no v4 Buffer or batch API yet; those are planned for v4.2.0.
|
|
144
162
|
|
|
145
163
|
## RailID v2
|
|
146
164
|
|
package/index.d.ts
CHANGED
|
@@ -30,6 +30,24 @@ export declare function generateV4(): string;
|
|
|
30
30
|
/** Generate one 126-bit v4 RailID as a 21-character string with the OS-only profile. */
|
|
31
31
|
export declare function generateV4OsOnly(): string;
|
|
32
32
|
|
|
33
|
+
/** Generate one 126-bit v4 RailID as 21 ASCII bytes with the TPM hybrid profile. */
|
|
34
|
+
export declare function generateV4Buffer(): Buffer;
|
|
35
|
+
|
|
36
|
+
/** Generate one 126-bit v4 RailID as 21 ASCII bytes with the OS-only profile. */
|
|
37
|
+
export declare function generateV4BufferOsOnly(): Buffer;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Generate `count` v4 IDs as one contiguous `count * 21` Buffer with the TPM
|
|
41
|
+
* hybrid profile. Capped at 1,024 IDs and fails closed without a TPM.
|
|
42
|
+
*/
|
|
43
|
+
export declare function generateV4ManyEncoded(count: number): Buffer;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Generate `count` v4 IDs as one contiguous `count * 21` Buffer with the
|
|
47
|
+
* explicitly degraded OS-only profile. Capped at 1,000,000 IDs.
|
|
48
|
+
*/
|
|
49
|
+
export declare function generateV4ManyEncodedOsOnly(count: number): Buffer;
|
|
50
|
+
|
|
33
51
|
/** Generate `count` IDs synchronously as strings. */
|
|
34
52
|
export declare function generateMany(count: number, osOnly?: boolean): string[];
|
|
35
53
|
|
package/no-tpm.d.ts
CHANGED
|
@@ -21,6 +21,21 @@ export declare function generateV4(): string;
|
|
|
21
21
|
/** Same as `generateV4()`; kept for symmetry. */
|
|
22
22
|
export declare function generateV4OsOnly(): string;
|
|
23
23
|
|
|
24
|
+
/** Generate one 126-bit v4 RailID as 21 ASCII bytes with the OS-only profile. */
|
|
25
|
+
export declare function generateV4Buffer(): Buffer;
|
|
26
|
+
|
|
27
|
+
/** Same as `generateV4Buffer()`; kept for symmetry. */
|
|
28
|
+
export declare function generateV4BufferOsOnly(): Buffer;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Generate `count` v4 IDs as one contiguous `count * 21` Buffer with the
|
|
32
|
+
* OS-only profile. Capped at 1,000,000 IDs.
|
|
33
|
+
*/
|
|
34
|
+
export declare function generateV4ManyEncoded(count: number): Buffer;
|
|
35
|
+
|
|
36
|
+
/** Same as `generateV4ManyEncoded()`; kept for symmetry. */
|
|
37
|
+
export declare function generateV4ManyEncodedOsOnly(count: number): Buffer;
|
|
38
|
+
|
|
24
39
|
/** Generate `count` IDs synchronously as strings. */
|
|
25
40
|
export declare function generateMany(count: number): string[];
|
|
26
41
|
|
package/no-tpm.js
CHANGED
|
@@ -15,6 +15,8 @@ module.exports = {
|
|
|
15
15
|
// The v4 default profile is fail-closed too; this entry point is the
|
|
16
16
|
// explicit OS-only opt-in.
|
|
17
17
|
generateV4: core.generateV4OsOnly,
|
|
18
|
+
generateV4Buffer: core.generateV4BufferOsOnly,
|
|
19
|
+
generateV4ManyEncoded: (count) => core.generateV4ManyEncodedOsOnly(count),
|
|
18
20
|
// The `osOnly` argument is accepted for signature compatibility and always
|
|
19
21
|
// resolves to the OS-only profile.
|
|
20
22
|
generateMany: (count) => core.generateMany(count, true),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neko-makura/railid",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Native N-API bindings for RailID: 192-bit v1 and variable-length v2 timestamp-first identifiers with TPM 2.0 + OS CSPRNG randomness",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
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
|