@hesohq/node 0.1.2-dev.21
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/index.d.ts +235 -0
- package/index.js +341 -0
- package/package.json +43 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
/** The verdict returned by all single-receipt verify functions. */
|
|
7
|
+
export interface ActionVerdict {
|
|
8
|
+
/** One of the ActionOutcome variant names as a string. */
|
|
9
|
+
verdict: string
|
|
10
|
+
/** The re-derived trust level: "L0" or "L1" (only meaningful when verdict == "Valid"). */
|
|
11
|
+
trustLevel: string
|
|
12
|
+
}
|
|
13
|
+
/** Extended verdict that also includes the trusted-time status. */
|
|
14
|
+
export interface ActionVerdictWithTime {
|
|
15
|
+
verdict: string
|
|
16
|
+
trustLevel: string
|
|
17
|
+
/** "NoTrustedTime" or "AnchoredRfc3161:<gen_time>". */
|
|
18
|
+
timeStatus: string
|
|
19
|
+
}
|
|
20
|
+
/** Outcome of a chain verification. */
|
|
21
|
+
export interface ChainResult {
|
|
22
|
+
ok: boolean
|
|
23
|
+
/** Number of receipts verified (only set when ok == true). */
|
|
24
|
+
length?: number
|
|
25
|
+
/** Error kind string (only set when ok == false). */
|
|
26
|
+
error?: string
|
|
27
|
+
/** The seq at which the error occurred (only set when ok == false). */
|
|
28
|
+
seq?: number
|
|
29
|
+
/** Human-readable detail (only set when ok == false). */
|
|
30
|
+
detail?: string
|
|
31
|
+
}
|
|
32
|
+
/** Decoded claims from a verified approval token. */
|
|
33
|
+
export interface ApprovalTokenClaims {
|
|
34
|
+
/** The 32-byte random nonce as a Buffer. */
|
|
35
|
+
nonce: Buffer
|
|
36
|
+
/** Expiry as Unix seconds (BigInt). */
|
|
37
|
+
expiryUnixSecs: bigint
|
|
38
|
+
/** The verdict the human signed into the token: "approved" or "rejected". */
|
|
39
|
+
decision: string
|
|
40
|
+
/** The scope string encoded in the token. */
|
|
41
|
+
scope: string
|
|
42
|
+
/** Base64-encoded Ed25519 public key of the approver. */
|
|
43
|
+
approverPublicKey: string
|
|
44
|
+
}
|
|
45
|
+
/** The verified, decoded result of a delegation envelope. */
|
|
46
|
+
export interface VerifiedDelegation {
|
|
47
|
+
/** The authorized key `K` (raw 32-byte Ed25519 public key) as a Buffer. */
|
|
48
|
+
authorizedKey: Buffer
|
|
49
|
+
/** The subject string the operator stamped onto the delegation. */
|
|
50
|
+
sub: string
|
|
51
|
+
/** The scope the delegated authority was bound to. */
|
|
52
|
+
scope: string
|
|
53
|
+
/** The envelope's expiry as Unix seconds (BigInt). */
|
|
54
|
+
expiryUnixSecs: bigint
|
|
55
|
+
/** The envelope's not_before as Unix seconds (BigInt). */
|
|
56
|
+
notBeforeUnixSecs: bigint
|
|
57
|
+
}
|
|
58
|
+
/** Result of a commit-and-reveal redaction. */
|
|
59
|
+
export interface RedactCommitResult {
|
|
60
|
+
/** The modified fields map as JSON. */
|
|
61
|
+
fields: string
|
|
62
|
+
/** The RedactionRecord as JSON. */
|
|
63
|
+
redactionRecord: string
|
|
64
|
+
/** The redaction sidecar (salts + reveals) as JSON. */
|
|
65
|
+
sidecar: string
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Verify a single ActionReceipt from its raw JSON bytes (Buffer, Uint8Array, or string).
|
|
69
|
+
* Never panics — structural failures become `Malformed:…`.
|
|
70
|
+
*/
|
|
71
|
+
export declare function verify(receiptBytes: Buffer | Uint8Array | string): ActionVerdict
|
|
72
|
+
/** Verify a receipt AND report its trusted-time status separately. */
|
|
73
|
+
export declare function verifyWithTime(receiptBytesInput: Buffer | Uint8Array | string): ActionVerdictWithTime
|
|
74
|
+
/**
|
|
75
|
+
* Verify a receipt AND re-derive its ERT classification from the embedded taxonomy.
|
|
76
|
+
* Uses heso-engine's ClassifyReDeriver (embedded taxonomy). Only available
|
|
77
|
+
* when the `process` feature is enabled (pulls heso-engine).
|
|
78
|
+
*/
|
|
79
|
+
export declare function verifyRederiving(receiptBytesInput: Buffer | Uint8Array | string): ActionVerdict
|
|
80
|
+
/**
|
|
81
|
+
* Return the RFC-8785 (JCS) canonical bytes of an ActionContent JSON string,
|
|
82
|
+
* with `action_hash` stripped. Single source of canonical bytes — never
|
|
83
|
+
* reimplement JCS in TS.
|
|
84
|
+
*/
|
|
85
|
+
export declare function actionCanonicalBytesJs(contentJson: string): Buffer
|
|
86
|
+
/**
|
|
87
|
+
* Promote a suspended L0 `ActionContent` to its L1 body (embed the approver
|
|
88
|
+
* record, recompute `action_hash`) and return that body's RFC-8785 (JCS)
|
|
89
|
+
* canonical bytes — the exact bytes the operator and approver sign.
|
|
90
|
+
*
|
|
91
|
+
* Key-free (`build_l1_content` is pure), so this is always compiled. It lets
|
|
92
|
+
* the SDK reproduce the L1 signing payload off-process and assert byte-parity
|
|
93
|
+
* with the native mint without ever touching a key.
|
|
94
|
+
*/
|
|
95
|
+
export declare function l1ContentCanonicalBytesJs(suspendedContentJson: string, approverRecordJson: string): Buffer
|
|
96
|
+
/** BLAKE3 (64-hex) of the canonical bytes — the value that goes into `action_hash`. */
|
|
97
|
+
export declare function contentHash(contentJson: string): string
|
|
98
|
+
/** Pre-anchor BLAKE3 hash (excludes `time_anchor` from the canonical bytes). */
|
|
99
|
+
export declare function anchoredContentHashJs(contentJson: string): string
|
|
100
|
+
/** Return a short display form of a 64-hex BLAKE3 hash: `{prefix}:{first8}`. */
|
|
101
|
+
export declare function shortHash(hex: string, prefix?: string | undefined | null): string
|
|
102
|
+
/**
|
|
103
|
+
* Compute a domain-separated BLAKE3 chain-link digest from two 64-hex hashes.
|
|
104
|
+
* Maps to the display helper used by the web's crypto.ts.
|
|
105
|
+
*/
|
|
106
|
+
export declare function chainHashHex(prevHex: string, actionHex: string): string
|
|
107
|
+
/**
|
|
108
|
+
* Verify an approval token. Throws a napi Error with a `[CODE]` prefix on failure.
|
|
109
|
+
*
|
|
110
|
+
* `required_decision` ("approved"/"rejected") is NON-DEFAULTED — the caller must
|
|
111
|
+
* declare which verdict it expects, and a token whose signed decision differs is
|
|
112
|
+
* rejected `[OutOfDecision]`.
|
|
113
|
+
*/
|
|
114
|
+
export declare function verifyApprovalToken(token: Buffer, actionCanonical: Buffer, nowUnixSecs: bigint, seenNonces: Array<Buffer>, requiredScope: string, requiredDecision: string, registeredKeysB64: Array<string>): ApprovalTokenClaims
|
|
115
|
+
/**
|
|
116
|
+
* Verify a delegation envelope and its human co-sign. Throws a napi Error with a
|
|
117
|
+
* `[CODE]` prefix on failure (mirrors `verifyApprovalToken`).
|
|
118
|
+
*
|
|
119
|
+
* `wire` — raw delegation envelope bytes (Buffer)
|
|
120
|
+
* `registered_operator_key` — the org-registered operator public key (raw 32-byte Buffer)
|
|
121
|
+
* `action_hash` — the raw 32-byte BLAKE3 action digest being authorized (Buffer)
|
|
122
|
+
* `approval_token` — the human co-sign bearer token presented by K (Buffer)
|
|
123
|
+
* `required_scope` — the required scope string
|
|
124
|
+
* `required_decision` — the verdict the co-sign must carry ("approved"/"rejected"),
|
|
125
|
+
* NON-DEFAULTED (same SEC-02 binding as the approver path)
|
|
126
|
+
* `now_unix_secs` — current time as BigInt Unix seconds
|
|
127
|
+
*/
|
|
128
|
+
export declare function verifyDelegation(wire: Buffer, registeredOperatorKey: Buffer, actionHash: Buffer, approvalToken: Buffer, requiredScope: string, requiredDecision: string, nowUnixSecs: bigint): VerifiedDelegation
|
|
129
|
+
/**
|
|
130
|
+
* Verify an ordered array of ActionReceipts as a tamper-evident chain.
|
|
131
|
+
* Input: array of Buffers (one per receipt) OR a JSON string of an array.
|
|
132
|
+
*/
|
|
133
|
+
export declare function verifyChain(receiptsBytes: Array<Buffer> | string): ChainResult
|
|
134
|
+
/** Verify a session chain (lifecycle role + transition checks). */
|
|
135
|
+
export declare function verifySessionChainJs(receiptsBytes: Array<Buffer> | string): ChainResult
|
|
136
|
+
/**
|
|
137
|
+
* Verify a session chain with key-rotation as-of-position enforcement.
|
|
138
|
+
* `producer_key` is the base64 genesis producer key (TOFU pin).
|
|
139
|
+
* `decision_key` is the optional base64 genesis decision key.
|
|
140
|
+
*/
|
|
141
|
+
export declare function verifySessionChainWithRotationJs(receiptsBytes: Array<Buffer> | string, producerKey: string, decisionKey?: string | undefined | null): ChainResult
|
|
142
|
+
/**
|
|
143
|
+
* RFC-6962 inclusion proof verification (SHA-256 Merkle tree).
|
|
144
|
+
* `leaf_value_hex` is the 64-hex `action_hash`; raw bytes are the leaf value.
|
|
145
|
+
* `proof_hashes` is an array of 64-hex SHA-256 sibling hashes.
|
|
146
|
+
* `root_hex` is the 64-hex SHA-256 tree root.
|
|
147
|
+
*/
|
|
148
|
+
export declare function verifyInclusionJs(leafValueHex: string, index: number, size: number, rootHex: string, proofHashes: Array<string>): boolean
|
|
149
|
+
/** RFC-6962 consistency proof verification. */
|
|
150
|
+
export declare function verifyConsistencyJs(oldSize: number, oldRootHex: string, newSize: number, newRootHex: string, proofHashes: Array<string>): boolean
|
|
151
|
+
/**
|
|
152
|
+
* Verify a BLAKE3 audit chain from its raw JSONL bytes (Buffer or string).
|
|
153
|
+
* Returns true if every link hashes correctly, false on any break.
|
|
154
|
+
*/
|
|
155
|
+
export declare function verifyAuditChain(bytes: Buffer | string): boolean
|
|
156
|
+
/** Return the hex hash of the embedded taxonomy (golden: 9f3bbaaf…). */
|
|
157
|
+
export declare function taxonomyHash(): string
|
|
158
|
+
/** Destructively redact fields and return the modified fields JSON. */
|
|
159
|
+
export declare function redactDestructiveJs(fieldsJson: string, fieldPaths: Array<string>): string
|
|
160
|
+
/**
|
|
161
|
+
* Commit-and-reveal redaction.
|
|
162
|
+
* `salts` is an array of 32-byte Buffers (one per field, in order).
|
|
163
|
+
*/
|
|
164
|
+
export declare function redactCommitJs(fieldsJson: string, fieldPaths: Array<string>, salts: Array<Buffer>): RedactCommitResult
|
|
165
|
+
/**
|
|
166
|
+
* Construct an OperatorKey from a 32-byte seed (OsRng-free, deterministic).
|
|
167
|
+
* The preferred/documented entry point.
|
|
168
|
+
*/
|
|
169
|
+
export declare function keyFromSeed(seed: Buffer): OperatorKey
|
|
170
|
+
/**
|
|
171
|
+
* Generate a fresh random OperatorKey using OS entropy (native-only).
|
|
172
|
+
* Do NOT call from any wasm-reachable path.
|
|
173
|
+
*/
|
|
174
|
+
export declare function generateKey(): OperatorKey
|
|
175
|
+
/**
|
|
176
|
+
* BLAKE3 (64-hex) of arbitrary bytes — the result-hash primitive the Node SDK
|
|
177
|
+
* binds a tool result under, keeping "zero crypto in TS" (Node's crypto has no
|
|
178
|
+
* BLAKE3). Always available (no OsRng); the JS-side `recordResult` calls this.
|
|
179
|
+
*/
|
|
180
|
+
export declare function blake3Hex(data: Buffer | Uint8Array | string): string
|
|
181
|
+
/**
|
|
182
|
+
* Process an action through the compliance pipeline (in-process, no subprocess).
|
|
183
|
+
*
|
|
184
|
+
* `process_input_json`: JSON-encoded `ProcessInput` (Buffer, Uint8Array, or string).
|
|
185
|
+
* `project_root`: path to the project root holding `heso.toml` and `heso-local-data/`
|
|
186
|
+
* (operator key, audit log, approval queue) — the same layout the PyO3 wheel reads.
|
|
187
|
+
*
|
|
188
|
+
* Returns JSON-encoded `ProcessOutput` bytes, tagged on `status`
|
|
189
|
+
* (`allowed`/`blocked`/`suspended`). Only available with the `process` feature.
|
|
190
|
+
*
|
|
191
|
+
* Named `process_action` (JS `processAction`) — NOT `process` — because a napi
|
|
192
|
+
* export named `process` shadows Node's global `process` in the generated loader.
|
|
193
|
+
*/
|
|
194
|
+
export declare function processAction(processInputJson: Buffer | Uint8Array | string, projectRoot: string): Buffer
|
|
195
|
+
/**
|
|
196
|
+
* Assemble a complete L1 ActionReceipt from a suspended L0 body and an approver's
|
|
197
|
+
* detached co-signature, operator-signing locally with the project's key.
|
|
198
|
+
*
|
|
199
|
+
* MANDATORY-1 is enforced in-core: the loaded operator key MUST equal the
|
|
200
|
+
* suspended body's `agent_identity`, else `assemble_l1_from_parts` fails closed
|
|
201
|
+
* with `OperatorKeyMismatch`. After assembly the receipt is verified locally and
|
|
202
|
+
* returned ONLY if it opens `Valid(L1)`; any other verdict is surfaced as an
|
|
203
|
+
* error rather than handing back a receipt the offline verifier would reject.
|
|
204
|
+
*
|
|
205
|
+
* Returns the serialized ActionReceipt JSON bytes. Only available with `process`
|
|
206
|
+
* (loads a key from the filesystem; never wasm-reachable).
|
|
207
|
+
*/
|
|
208
|
+
export declare function assembleL1FromParts(suspendedContentJson: string, approverRecordJson: string, approverPubkeyB64: string, coSigB64: string, projectRoot: string, keyPassphrase?: string | undefined | null, relayedAnchorJson?: string | undefined | null): Buffer
|
|
209
|
+
/**
|
|
210
|
+
* Assemble a complete multi-approver k-of-n QUORUM ActionReceipt from a suspended
|
|
211
|
+
* L0 body, the gate's `threshold` + `roster`, and the per-approver detached
|
|
212
|
+
* co-signatures — operator-signing locally with the project's key. The result
|
|
213
|
+
* derives and embeds `L1` WITH a `multi_approval` block (a quorum is not a higher
|
|
214
|
+
* level than single-approver L1).
|
|
215
|
+
*
|
|
216
|
+
* MANDATORY-1 is enforced in-core: the loaded operator key MUST equal the
|
|
217
|
+
* suspended body's `agent_identity`, else assembly fails closed with
|
|
218
|
+
* `OperatorKeyMismatch` (surfaced as the discriminable `[OperatorKeyMismatch]`
|
|
219
|
+
* prefix the SDK's key-rotation catch keys on). After assembly the receipt is
|
|
220
|
+
* verified locally and returned ONLY if it opens `Valid(L1)` with a quorum block;
|
|
221
|
+
* any other verdict is surfaced as an error rather than handing back a receipt the
|
|
222
|
+
* offline verifier would reject.
|
|
223
|
+
*
|
|
224
|
+
* `parts_json` is a JSON array of `{ record, approverPubkeyB64, coSigB64 }`
|
|
225
|
+
* objects. `roster_json` is a JSON array of base64 approver public keys.
|
|
226
|
+
*
|
|
227
|
+
* Returns the serialized ActionReceipt JSON bytes. Only available with `process`
|
|
228
|
+
* (loads a key from the filesystem; never wasm-reachable).
|
|
229
|
+
*/
|
|
230
|
+
export declare function assembleQuorumFromParts(suspendedContentJson: string, threshold: number, rosterJson: string, partsJson: string, projectRoot: string, keyPassphrase?: string | undefined | null): Buffer
|
|
231
|
+
/** A loaded operator key, exposing just the public-key surface. */
|
|
232
|
+
export declare class OperatorKey {
|
|
233
|
+
/** Return the base64 standard-alphabet public key. */
|
|
234
|
+
publicKeyB64(): string
|
|
235
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
7
|
+
const { existsSync, readFileSync } = require('fs')
|
|
8
|
+
const { join } = require('path')
|
|
9
|
+
|
|
10
|
+
const { platform, arch } = process
|
|
11
|
+
|
|
12
|
+
let nativeBinding = null
|
|
13
|
+
let localFileExisted = false
|
|
14
|
+
let loadError = null
|
|
15
|
+
|
|
16
|
+
function isMusl() {
|
|
17
|
+
// For Node 10
|
|
18
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
19
|
+
try {
|
|
20
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
21
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
+
return !glibcVersionRuntime
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
switch (platform) {
|
|
32
|
+
case 'android':
|
|
33
|
+
switch (arch) {
|
|
34
|
+
case 'arm64':
|
|
35
|
+
localFileExisted = existsSync(join(__dirname, 'heso-node.android-arm64.node'))
|
|
36
|
+
try {
|
|
37
|
+
if (localFileExisted) {
|
|
38
|
+
nativeBinding = require('./heso-node.android-arm64.node')
|
|
39
|
+
} else {
|
|
40
|
+
nativeBinding = require('@hesohq/node-android-arm64')
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
loadError = e
|
|
44
|
+
}
|
|
45
|
+
break
|
|
46
|
+
case 'arm':
|
|
47
|
+
localFileExisted = existsSync(join(__dirname, 'heso-node.android-arm-eabi.node'))
|
|
48
|
+
try {
|
|
49
|
+
if (localFileExisted) {
|
|
50
|
+
nativeBinding = require('./heso-node.android-arm-eabi.node')
|
|
51
|
+
} else {
|
|
52
|
+
nativeBinding = require('@hesohq/node-android-arm-eabi')
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
loadError = e
|
|
56
|
+
}
|
|
57
|
+
break
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
60
|
+
}
|
|
61
|
+
break
|
|
62
|
+
case 'win32':
|
|
63
|
+
switch (arch) {
|
|
64
|
+
case 'x64':
|
|
65
|
+
localFileExisted = existsSync(
|
|
66
|
+
join(__dirname, 'heso-node.win32-x64-msvc.node')
|
|
67
|
+
)
|
|
68
|
+
try {
|
|
69
|
+
if (localFileExisted) {
|
|
70
|
+
nativeBinding = require('./heso-node.win32-x64-msvc.node')
|
|
71
|
+
} else {
|
|
72
|
+
nativeBinding = require('@hesohq/node-win32-x64-msvc')
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadError = e
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
case 'ia32':
|
|
79
|
+
localFileExisted = existsSync(
|
|
80
|
+
join(__dirname, 'heso-node.win32-ia32-msvc.node')
|
|
81
|
+
)
|
|
82
|
+
try {
|
|
83
|
+
if (localFileExisted) {
|
|
84
|
+
nativeBinding = require('./heso-node.win32-ia32-msvc.node')
|
|
85
|
+
} else {
|
|
86
|
+
nativeBinding = require('@hesohq/node-win32-ia32-msvc')
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
loadError = e
|
|
90
|
+
}
|
|
91
|
+
break
|
|
92
|
+
case 'arm64':
|
|
93
|
+
localFileExisted = existsSync(
|
|
94
|
+
join(__dirname, 'heso-node.win32-arm64-msvc.node')
|
|
95
|
+
)
|
|
96
|
+
try {
|
|
97
|
+
if (localFileExisted) {
|
|
98
|
+
nativeBinding = require('./heso-node.win32-arm64-msvc.node')
|
|
99
|
+
} else {
|
|
100
|
+
nativeBinding = require('@hesohq/node-win32-arm64-msvc')
|
|
101
|
+
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
loadError = e
|
|
104
|
+
}
|
|
105
|
+
break
|
|
106
|
+
default:
|
|
107
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
+
}
|
|
109
|
+
break
|
|
110
|
+
case 'darwin':
|
|
111
|
+
localFileExisted = existsSync(join(__dirname, 'heso-node.darwin-universal.node'))
|
|
112
|
+
try {
|
|
113
|
+
if (localFileExisted) {
|
|
114
|
+
nativeBinding = require('./heso-node.darwin-universal.node')
|
|
115
|
+
} else {
|
|
116
|
+
nativeBinding = require('@hesohq/node-darwin-universal')
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
} catch {}
|
|
120
|
+
switch (arch) {
|
|
121
|
+
case 'x64':
|
|
122
|
+
localFileExisted = existsSync(join(__dirname, 'heso-node.darwin-x64.node'))
|
|
123
|
+
try {
|
|
124
|
+
if (localFileExisted) {
|
|
125
|
+
nativeBinding = require('./heso-node.darwin-x64.node')
|
|
126
|
+
} else {
|
|
127
|
+
nativeBinding = require('@hesohq/node-darwin-x64')
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadError = e
|
|
131
|
+
}
|
|
132
|
+
break
|
|
133
|
+
case 'arm64':
|
|
134
|
+
localFileExisted = existsSync(
|
|
135
|
+
join(__dirname, 'heso-node.darwin-arm64.node')
|
|
136
|
+
)
|
|
137
|
+
try {
|
|
138
|
+
if (localFileExisted) {
|
|
139
|
+
nativeBinding = require('./heso-node.darwin-arm64.node')
|
|
140
|
+
} else {
|
|
141
|
+
nativeBinding = require('@hesohq/node-darwin-arm64')
|
|
142
|
+
}
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadError = e
|
|
145
|
+
}
|
|
146
|
+
break
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
149
|
+
}
|
|
150
|
+
break
|
|
151
|
+
case 'freebsd':
|
|
152
|
+
if (arch !== 'x64') {
|
|
153
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
154
|
+
}
|
|
155
|
+
localFileExisted = existsSync(join(__dirname, 'heso-node.freebsd-x64.node'))
|
|
156
|
+
try {
|
|
157
|
+
if (localFileExisted) {
|
|
158
|
+
nativeBinding = require('./heso-node.freebsd-x64.node')
|
|
159
|
+
} else {
|
|
160
|
+
nativeBinding = require('@hesohq/node-freebsd-x64')
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
loadError = e
|
|
164
|
+
}
|
|
165
|
+
break
|
|
166
|
+
case 'linux':
|
|
167
|
+
switch (arch) {
|
|
168
|
+
case 'x64':
|
|
169
|
+
if (isMusl()) {
|
|
170
|
+
localFileExisted = existsSync(
|
|
171
|
+
join(__dirname, 'heso-node.linux-x64-musl.node')
|
|
172
|
+
)
|
|
173
|
+
try {
|
|
174
|
+
if (localFileExisted) {
|
|
175
|
+
nativeBinding = require('./heso-node.linux-x64-musl.node')
|
|
176
|
+
} else {
|
|
177
|
+
nativeBinding = require('@hesohq/node-linux-x64-musl')
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadError = e
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
localFileExisted = existsSync(
|
|
184
|
+
join(__dirname, 'heso-node.linux-x64-gnu.node')
|
|
185
|
+
)
|
|
186
|
+
try {
|
|
187
|
+
if (localFileExisted) {
|
|
188
|
+
nativeBinding = require('./heso-node.linux-x64-gnu.node')
|
|
189
|
+
} else {
|
|
190
|
+
nativeBinding = require('@hesohq/node-linux-x64-gnu')
|
|
191
|
+
}
|
|
192
|
+
} catch (e) {
|
|
193
|
+
loadError = e
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break
|
|
197
|
+
case 'arm64':
|
|
198
|
+
if (isMusl()) {
|
|
199
|
+
localFileExisted = existsSync(
|
|
200
|
+
join(__dirname, 'heso-node.linux-arm64-musl.node')
|
|
201
|
+
)
|
|
202
|
+
try {
|
|
203
|
+
if (localFileExisted) {
|
|
204
|
+
nativeBinding = require('./heso-node.linux-arm64-musl.node')
|
|
205
|
+
} else {
|
|
206
|
+
nativeBinding = require('@hesohq/node-linux-arm64-musl')
|
|
207
|
+
}
|
|
208
|
+
} catch (e) {
|
|
209
|
+
loadError = e
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
localFileExisted = existsSync(
|
|
213
|
+
join(__dirname, 'heso-node.linux-arm64-gnu.node')
|
|
214
|
+
)
|
|
215
|
+
try {
|
|
216
|
+
if (localFileExisted) {
|
|
217
|
+
nativeBinding = require('./heso-node.linux-arm64-gnu.node')
|
|
218
|
+
} else {
|
|
219
|
+
nativeBinding = require('@hesohq/node-linux-arm64-gnu')
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadError = e
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
break
|
|
226
|
+
case 'arm':
|
|
227
|
+
if (isMusl()) {
|
|
228
|
+
localFileExisted = existsSync(
|
|
229
|
+
join(__dirname, 'heso-node.linux-arm-musleabihf.node')
|
|
230
|
+
)
|
|
231
|
+
try {
|
|
232
|
+
if (localFileExisted) {
|
|
233
|
+
nativeBinding = require('./heso-node.linux-arm-musleabihf.node')
|
|
234
|
+
} else {
|
|
235
|
+
nativeBinding = require('@hesohq/node-linux-arm-musleabihf')
|
|
236
|
+
}
|
|
237
|
+
} catch (e) {
|
|
238
|
+
loadError = e
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
localFileExisted = existsSync(
|
|
242
|
+
join(__dirname, 'heso-node.linux-arm-gnueabihf.node')
|
|
243
|
+
)
|
|
244
|
+
try {
|
|
245
|
+
if (localFileExisted) {
|
|
246
|
+
nativeBinding = require('./heso-node.linux-arm-gnueabihf.node')
|
|
247
|
+
} else {
|
|
248
|
+
nativeBinding = require('@hesohq/node-linux-arm-gnueabihf')
|
|
249
|
+
}
|
|
250
|
+
} catch (e) {
|
|
251
|
+
loadError = e
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break
|
|
255
|
+
case 'riscv64':
|
|
256
|
+
if (isMusl()) {
|
|
257
|
+
localFileExisted = existsSync(
|
|
258
|
+
join(__dirname, 'heso-node.linux-riscv64-musl.node')
|
|
259
|
+
)
|
|
260
|
+
try {
|
|
261
|
+
if (localFileExisted) {
|
|
262
|
+
nativeBinding = require('./heso-node.linux-riscv64-musl.node')
|
|
263
|
+
} else {
|
|
264
|
+
nativeBinding = require('@hesohq/node-linux-riscv64-musl')
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
loadError = e
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
localFileExisted = existsSync(
|
|
271
|
+
join(__dirname, 'heso-node.linux-riscv64-gnu.node')
|
|
272
|
+
)
|
|
273
|
+
try {
|
|
274
|
+
if (localFileExisted) {
|
|
275
|
+
nativeBinding = require('./heso-node.linux-riscv64-gnu.node')
|
|
276
|
+
} else {
|
|
277
|
+
nativeBinding = require('@hesohq/node-linux-riscv64-gnu')
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadError = e
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
break
|
|
284
|
+
case 's390x':
|
|
285
|
+
localFileExisted = existsSync(
|
|
286
|
+
join(__dirname, 'heso-node.linux-s390x-gnu.node')
|
|
287
|
+
)
|
|
288
|
+
try {
|
|
289
|
+
if (localFileExisted) {
|
|
290
|
+
nativeBinding = require('./heso-node.linux-s390x-gnu.node')
|
|
291
|
+
} else {
|
|
292
|
+
nativeBinding = require('@hesohq/node-linux-s390x-gnu')
|
|
293
|
+
}
|
|
294
|
+
} catch (e) {
|
|
295
|
+
loadError = e
|
|
296
|
+
}
|
|
297
|
+
break
|
|
298
|
+
default:
|
|
299
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
300
|
+
}
|
|
301
|
+
break
|
|
302
|
+
default:
|
|
303
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!nativeBinding) {
|
|
307
|
+
if (loadError) {
|
|
308
|
+
throw loadError
|
|
309
|
+
}
|
|
310
|
+
throw new Error(`Failed to load native binding`)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const { OperatorKey, verify, verifyWithTime, verifyRederiving, actionCanonicalBytesJs, l1ContentCanonicalBytesJs, contentHash, anchoredContentHashJs, shortHash, chainHashHex, verifyApprovalToken, verifyDelegation, verifyChain, verifySessionChainJs, verifySessionChainWithRotationJs, verifyInclusionJs, verifyConsistencyJs, verifyAuditChain, taxonomyHash, redactDestructiveJs, redactCommitJs, keyFromSeed, generateKey, blake3Hex, processAction, assembleL1FromParts, assembleQuorumFromParts } = nativeBinding
|
|
314
|
+
|
|
315
|
+
module.exports.OperatorKey = OperatorKey
|
|
316
|
+
module.exports.verify = verify
|
|
317
|
+
module.exports.verifyWithTime = verifyWithTime
|
|
318
|
+
module.exports.verifyRederiving = verifyRederiving
|
|
319
|
+
module.exports.actionCanonicalBytesJs = actionCanonicalBytesJs
|
|
320
|
+
module.exports.l1ContentCanonicalBytesJs = l1ContentCanonicalBytesJs
|
|
321
|
+
module.exports.contentHash = contentHash
|
|
322
|
+
module.exports.anchoredContentHashJs = anchoredContentHashJs
|
|
323
|
+
module.exports.shortHash = shortHash
|
|
324
|
+
module.exports.chainHashHex = chainHashHex
|
|
325
|
+
module.exports.verifyApprovalToken = verifyApprovalToken
|
|
326
|
+
module.exports.verifyDelegation = verifyDelegation
|
|
327
|
+
module.exports.verifyChain = verifyChain
|
|
328
|
+
module.exports.verifySessionChainJs = verifySessionChainJs
|
|
329
|
+
module.exports.verifySessionChainWithRotationJs = verifySessionChainWithRotationJs
|
|
330
|
+
module.exports.verifyInclusionJs = verifyInclusionJs
|
|
331
|
+
module.exports.verifyConsistencyJs = verifyConsistencyJs
|
|
332
|
+
module.exports.verifyAuditChain = verifyAuditChain
|
|
333
|
+
module.exports.taxonomyHash = taxonomyHash
|
|
334
|
+
module.exports.redactDestructiveJs = redactDestructiveJs
|
|
335
|
+
module.exports.redactCommitJs = redactCommitJs
|
|
336
|
+
module.exports.keyFromSeed = keyFromSeed
|
|
337
|
+
module.exports.generateKey = generateKey
|
|
338
|
+
module.exports.blake3Hex = blake3Hex
|
|
339
|
+
module.exports.processAction = processAction
|
|
340
|
+
module.exports.assembleL1FromParts = assembleL1FromParts
|
|
341
|
+
module.exports.assembleQuorumFromParts = assembleQuorumFromParts
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hesohq/node",
|
|
3
|
+
"version": "0.1.2-dev.21",
|
|
4
|
+
"description": "napi-rs native Node.js addon for the HESO Enterprise trust layer",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"napi": {
|
|
8
|
+
"name": "heso-node",
|
|
9
|
+
"triples": {
|
|
10
|
+
"defaults": true,
|
|
11
|
+
"additional": [
|
|
12
|
+
"aarch64-apple-darwin",
|
|
13
|
+
"aarch64-unknown-linux-gnu"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"index.js",
|
|
19
|
+
"index.d.ts"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "napi build --platform --release --features process --cargo-cwd ../../crates/heso-node .",
|
|
23
|
+
"build:debug": "napi build --platform --features process --cargo-cwd ../../crates/heso-node .",
|
|
24
|
+
"test": "node --test \"__tests__/**/*.test.mjs\""
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@napi-rs/cli": "^2.18.4"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"license": "LicenseRef-Proprietary",
|
|
36
|
+
"optionalDependencies": {
|
|
37
|
+
"@hesohq/node-darwin-arm64": "0.1.2-dev.21",
|
|
38
|
+
"@hesohq/node-darwin-x64": "0.1.2-dev.21",
|
|
39
|
+
"@hesohq/node-linux-arm64-gnu": "0.1.2-dev.21",
|
|
40
|
+
"@hesohq/node-linux-x64-gnu": "0.1.2-dev.21",
|
|
41
|
+
"@hesohq/node-win32-x64-msvc": "0.1.2-dev.21"
|
|
42
|
+
}
|
|
43
|
+
}
|