@hesohq/sdk 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.
Files changed (45) hide show
  1. package/dist/adapters/ai-sdk.d.ts +43 -0
  2. package/dist/adapters/ai-sdk.d.ts.map +1 -0
  3. package/dist/adapters/ai-sdk.js +86 -0
  4. package/dist/adapters/ai-sdk.js.map +1 -0
  5. package/dist/adapters/mastra.d.ts +34 -0
  6. package/dist/adapters/mastra.d.ts.map +1 -0
  7. package/dist/adapters/mastra.js +84 -0
  8. package/dist/adapters/mastra.js.map +1 -0
  9. package/dist/capture.d.ts +230 -0
  10. package/dist/capture.d.ts.map +1 -0
  11. package/dist/capture.js +591 -0
  12. package/dist/capture.js.map +1 -0
  13. package/dist/cloud.d.ts +188 -0
  14. package/dist/cloud.d.ts.map +1 -0
  15. package/dist/cloud.js +196 -0
  16. package/dist/cloud.js.map +1 -0
  17. package/dist/config.d.ts +7 -0
  18. package/dist/config.d.ts.map +1 -0
  19. package/dist/config.js +16 -0
  20. package/dist/config.js.map +1 -0
  21. package/dist/delegation.d.ts +68 -0
  22. package/dist/delegation.d.ts.map +1 -0
  23. package/dist/delegation.js +139 -0
  24. package/dist/delegation.js.map +1 -0
  25. package/dist/gating.d.ts +33 -0
  26. package/dist/gating.d.ts.map +1 -0
  27. package/dist/gating.js +96 -0
  28. package/dist/gating.js.map +1 -0
  29. package/dist/index.d.ts +19 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +87 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/proxy.d.ts +30 -0
  34. package/dist/proxy.d.ts.map +1 -0
  35. package/dist/proxy.js +59 -0
  36. package/dist/proxy.js.map +1 -0
  37. package/dist/runtime.d.ts +30 -0
  38. package/dist/runtime.d.ts.map +1 -0
  39. package/dist/runtime.js +70 -0
  40. package/dist/runtime.js.map +1 -0
  41. package/dist/types.d.ts +259 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +6 -0
  44. package/dist/types.js.map +1 -0
  45. package/package.json +38 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.js","sourceRoot":"","sources":["../src/delegation.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,EAAE;AACF,iFAAiF;AACjF,0EAA0E;AAC1E,mFAAmF;AACnF,qFAAqF;AACrF,mFAAmF;AACnF,kFAAkF;AAClF,6EAA6E;AAC7E,aAAa;AACb,EAAE;AACF,qBAAqB;AACrB,8EAA8E;AAC9E,mDAAmD;AACnD,0DAA0D;AAC1D,oBAAoB;AACpB,4EAA4E;AAC5E,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,kFAAkF;AAClF,iDAAiD;;AAoGjD,wCA8BC;AA0BD,wDAcC;AAxKD,iFAAiF;AACjF,MAAM,yBAAyB,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAA;AAClF,MAAM,kBAAkB,GAAG,IAAI,CAAA;AAE/B,SAAS,KAAK,CAAC,CAAS;IACtB,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;IAC7B,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAA;QAC1B,CAAC,KAAK,EAAE,CAAA;IACV,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,KAAK,CAAC,CAAS;IACtB,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;IAC7B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;IAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,C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AAO,cAAc,CAAC;QACpB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,KAAK;QACL,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,eAAe;QACjC,iBAAiB,EAAE,GAAG;QACtB,cAAc,EAAE,GAAG,GAAG,GAAG;QACzB,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,WAAW;IAClB,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAA;IAC5B,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;IACpC,OAAO,CAAC,CAAA;AACV,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { ActionReceipt, TrustLevel, DecisionPath } from './types.js';
2
+ export interface GateResult {
3
+ allowed: boolean;
4
+ trustLevel: TrustLevel | null;
5
+ verdict: string;
6
+ }
7
+ /**
8
+ * Verify a receipt JSON string or Buffer and return whether it should be allowed.
9
+ *
10
+ * `minTrust` is the REQUIRED trust floor, not a hint:
11
+ * - 'L0' (default) accepts ANY valid receipt — including one that was never
12
+ * escalated to a human. Use it for monitoring/observe-only callers; it does
13
+ * NOT assert that a human approved an action a policy would have gated.
14
+ * - 'L1' additionally requires a human approver co-signature (trustLevel 'L1').
15
+ *
16
+ * To enforce that a receipt's decision path matches what the call should have
17
+ * required, pair this with `isDecisionAllowed`.
18
+ */
19
+ export declare function gate(receiptBytes: Buffer | string, minTrust?: TrustLevel): GateResult;
20
+ /**
21
+ * Assert that the receipt is valid and meets the minimum trust level.
22
+ * Throws with a descriptive message if the gate fails.
23
+ */
24
+ export declare function assertGate(receiptBytes: Buffer | string, minTrust?: TrustLevel): void;
25
+ /**
26
+ * Return the short display hash for an action_hash hex string.
27
+ */
28
+ export declare function shortHash(hex: string, prefix?: string): string;
29
+ /**
30
+ * True if the receipt's decision_path matches one of the allowed paths.
31
+ */
32
+ export declare function isDecisionAllowed(receipt: ActionReceipt, allowedPaths: DecisionPath[]): boolean;
33
+ //# sourceMappingURL=gating.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gating.d.ts","sourceRoot":"","sources":["../src/gating.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAMzE,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,UAAU,GAAG,IAAI,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAClB,YAAY,EAAE,MAAM,GAAG,MAAM,EAC7B,QAAQ,GAAE,UAAiB,GAC1B,UAAU,CAYZ;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,MAAM,GAAG,MAAM,EAC7B,QAAQ,GAAE,UAAiB,GAC1B,IAAI,CAON;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,YAAY,EAAE,GAC3B,OAAO,CAET"}
package/dist/gating.js ADDED
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ // Gating helpers — thin wrappers over the native verify surface.
3
+ //
4
+ // This Node SDK binds to @hesohq/node via @hesohq/core's main entry (which
5
+ // re-exports @hesohq/node). `core.verify` is the native addon's verify — it
6
+ // takes the receipt bytes and returns an ActionVerdict with a camelCase
7
+ // `trustLevel`. The isomorphic WASM verifier (@hesohq/core/browser ->
8
+ // @hesohq/verify-wasm) is a DIFFERENT surface (`verifyActionReceipt`, snake_case
9
+ // `trust_level`) and is not used here.
10
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ var desc = Object.getOwnPropertyDescriptor(m, k);
13
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }) : (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ o[k2] = m[k];
20
+ }));
21
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
22
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
23
+ }) : function(o, v) {
24
+ o["default"] = v;
25
+ });
26
+ var __importStar = (this && this.__importStar) || (function () {
27
+ var ownKeys = function(o) {
28
+ ownKeys = Object.getOwnPropertyNames || function (o) {
29
+ var ar = [];
30
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
31
+ return ar;
32
+ };
33
+ return ownKeys(o);
34
+ };
35
+ return function (mod) {
36
+ if (mod && mod.__esModule) return mod;
37
+ var result = {};
38
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
39
+ __setModuleDefault(result, mod);
40
+ return result;
41
+ };
42
+ })();
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.gate = gate;
45
+ exports.assertGate = assertGate;
46
+ exports.shortHash = shortHash;
47
+ exports.isDecisionAllowed = isDecisionAllowed;
48
+ // Import @hesohq/core statically — it's a hard dep and tree-shakers handle it.
49
+ const core = __importStar(require("@hesohq/core"));
50
+ /**
51
+ * Verify a receipt JSON string or Buffer and return whether it should be allowed.
52
+ *
53
+ * `minTrust` is the REQUIRED trust floor, not a hint:
54
+ * - 'L0' (default) accepts ANY valid receipt — including one that was never
55
+ * escalated to a human. Use it for monitoring/observe-only callers; it does
56
+ * NOT assert that a human approved an action a policy would have gated.
57
+ * - 'L1' additionally requires a human approver co-signature (trustLevel 'L1').
58
+ *
59
+ * To enforce that a receipt's decision path matches what the call should have
60
+ * required, pair this with `isDecisionAllowed`.
61
+ */
62
+ function gate(receiptBytes, minTrust = 'L0') {
63
+ const result = core.verify(receiptBytes);
64
+ const verdictOk = result.verdict === 'Valid';
65
+ const trustOk = minTrust === 'L0'
66
+ ? (result.trustLevel === 'L0' || result.trustLevel === 'L1')
67
+ : result.trustLevel === 'L1';
68
+ return {
69
+ allowed: verdictOk && trustOk,
70
+ trustLevel: verdictOk ? result.trustLevel : null,
71
+ verdict: result.verdict,
72
+ };
73
+ }
74
+ /**
75
+ * Assert that the receipt is valid and meets the minimum trust level.
76
+ * Throws with a descriptive message if the gate fails.
77
+ */
78
+ function assertGate(receiptBytes, minTrust = 'L0') {
79
+ const result = gate(receiptBytes, minTrust);
80
+ if (!result.allowed) {
81
+ throw new Error(`@hesohq/sdk: gate rejected receipt — verdict=${result.verdict} trustLevel=${result.trustLevel ?? 'none'} required=${minTrust}`);
82
+ }
83
+ }
84
+ /**
85
+ * Return the short display hash for an action_hash hex string.
86
+ */
87
+ function shortHash(hex, prefix) {
88
+ return core.shortHash(hex, prefix ?? null);
89
+ }
90
+ /**
91
+ * True if the receipt's decision_path matches one of the allowed paths.
92
+ */
93
+ function isDecisionAllowed(receipt, allowedPaths) {
94
+ return allowedPaths.includes(receipt.content.policy.decision_path);
95
+ }
96
+ //# sourceMappingURL=gating.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gating.js","sourceRoot":"","sources":["../src/gating.ts"],"names":[],"mappings":";AAAA,iEAAiE;AACjE,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,sEAAsE;AACtE,iFAAiF;AACjF,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BvC,oBAeC;AAMD,gCAUC;AAKD,8BAEC;AAKD,8CAKC;AArED,+EAA+E;AAC/E,mDAAoC;AAQpC;;;;;;;;;;;GAWG;AACH,SAAgB,IAAI,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';
2
+ export type { HesoCoreConfig } from './config.js';
3
+ export { init, currentConfig } from './runtime.js';
4
+ export type { HesoRuntimeConfig, InitOptions } from './runtime.js';
5
+ export { BlockedError, SuspendedError, BridgeError, ApprovalRejectedError, OperatorKeyMismatchError, finalizeL1, finalizeQuorum, } from './capture.js';
6
+ export type { Outcome, Action, OutcomeKind, Surface, Fields, GateOptions, ReSuspendResult, } from './capture.js';
7
+ export * as engine from './capture.js';
8
+ export * as aiSdk from './adapters/ai-sdk.js';
9
+ export * as mastra from './adapters/mastra.js';
10
+ export { gate, assertGate, shortHash, isDecisionAllowed } from './gating.js';
11
+ export type { GateResult } from './gating.js';
12
+ export { pullPolicy, pushReceipt, pushReceipts, pollApproval, waitForApproval, getL1Parts, getQuorumParts, submitApprovalToken, } from './cloud.js';
13
+ export type { PolicyPullResult, ReceiptPushResult, ApprovalView, ResolvedApproval, L1Parts, QuorumParts, QuorumLeg, SubmitTokenInput, } from './cloud.js';
14
+ export { wrap } from './proxy.js';
15
+ export type { WrapOptions } from './proxy.js';
16
+ export { signDelegation, mintDelegationEnvelope } from './delegation.js';
17
+ export type { OperatorSigner, DelegationInput, MintDelegationInput, SignedDelegation, } from './delegation.js';
18
+ export type { Verb, DecisionPath, ApproverDecision, RedactionMode, TrustLevel, ConditionOp, SignatureKeyId, MatchedCondition, PolicyOutcome, ApproverRecord, RedactionMarker, RedactionRecord, ActionDetail, ActionContent, MultiApproval, SignatureEntry, ActionReceipt, VerdictState, Run, AuditEntry, AuditChain, FieldDiffEntry, ApprovalOutcome, Role, MemberStatus, Capability, RoutingTarget, ApprovalRouting, Approver, Approval, TrustRung, RoleMeta, Member, Eligibility, RuleSubject, RuleCondition, ApproverTarget, SentenceToken, PolicyRule, SimulationResult, StatCounter, } from './types.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,E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IAAI,EACJ,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACZ,GAAG,EACH,UAAU,EACV,UAAU,EACV,cAAc,EACd,eAAe,EACf,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,aAAa,EACb,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,MAAM,EACN,WAAW,EACX,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,WAAW,GACZ,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ // @hesohq/sdk — HESO Enterprise SDK public surface.
3
+ //
4
+ // Zero crypto in TS: this Node SDK is bound to the native @hesohq/node addon —
5
+ // verification via @hesohq/core (whose main entry re-exports @hesohq/node), and
6
+ // in-process minting/gating via @hesohq/node directly (Node-only, loaded lazily).
7
+ // The isomorphic WASM verifier is @hesohq/core/browser; this package is the
8
+ // Node-only build and does not use it.
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.mintDelegationEnvelope = exports.signDelegation = exports.wrap = exports.submitApprovalToken = exports.getQuorumParts = exports.getL1Parts = exports.waitForApproval = exports.pollApproval = exports.pushReceipts = exports.pushReceipt = exports.pullPolicy = exports.isDecisionAllowed = exports.shortHash = exports.assertGate = exports.gate = exports.mastra = exports.aiSdk = exports.engine = exports.finalizeQuorum = exports.finalizeL1 = exports.OperatorKeyMismatchError = exports.ApprovalRejectedError = exports.BridgeError = exports.SuspendedError = exports.BlockedError = exports.currentConfig = exports.init = exports.configure = void 0;
44
+ var config_js_1 = require("./config.js");
45
+ Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return config_js_1.configure; } });
46
+ // Engine runtime + the in-process gate/mint core (Node-only).
47
+ var runtime_js_1 = require("./runtime.js");
48
+ Object.defineProperty(exports, "init", { enumerable: true, get: function () { return runtime_js_1.init; } });
49
+ Object.defineProperty(exports, "currentConfig", { enumerable: true, get: function () { return runtime_js_1.currentConfig; } });
50
+ var capture_js_1 = require("./capture.js");
51
+ Object.defineProperty(exports, "BlockedError", { enumerable: true, get: function () { return capture_js_1.BlockedError; } });
52
+ Object.defineProperty(exports, "SuspendedError", { enumerable: true, get: function () { return capture_js_1.SuspendedError; } });
53
+ Object.defineProperty(exports, "BridgeError", { enumerable: true, get: function () { return capture_js_1.BridgeError; } });
54
+ Object.defineProperty(exports, "ApprovalRejectedError", { enumerable: true, get: function () { return capture_js_1.ApprovalRejectedError; } });
55
+ Object.defineProperty(exports, "OperatorKeyMismatchError", { enumerable: true, get: function () { return capture_js_1.OperatorKeyMismatchError; } });
56
+ Object.defineProperty(exports, "finalizeL1", { enumerable: true, get: function () { return capture_js_1.finalizeL1; } });
57
+ Object.defineProperty(exports, "finalizeQuorum", { enumerable: true, get: function () { return capture_js_1.finalizeQuorum; } });
58
+ // The shared capture core — `engine.gate` / `engine.evaluate` / `engine.recordResult`.
59
+ // Apply the one gate pattern to any framework; the framework adapters are thin
60
+ // wrappers over it.
61
+ exports.engine = __importStar(require("./capture.js"));
62
+ // Framework drop-in adapters (Node-only). Namespaced to avoid colliding `gateTool`
63
+ // names; also reachable via the `./adapters/*` subpath exports in package.json.
64
+ exports.aiSdk = __importStar(require("./adapters/ai-sdk.js"));
65
+ exports.mastra = __importStar(require("./adapters/mastra.js"));
66
+ var gating_js_1 = require("./gating.js");
67
+ Object.defineProperty(exports, "gate", { enumerable: true, get: function () { return gating_js_1.gate; } });
68
+ Object.defineProperty(exports, "assertGate", { enumerable: true, get: function () { return gating_js_1.assertGate; } });
69
+ Object.defineProperty(exports, "shortHash", { enumerable: true, get: function () { return gating_js_1.shortHash; } });
70
+ Object.defineProperty(exports, "isDecisionAllowed", { enumerable: true, get: function () { return gating_js_1.isDecisionAllowed; } });
71
+ var cloud_js_1 = require("./cloud.js");
72
+ Object.defineProperty(exports, "pullPolicy", { enumerable: true, get: function () { return cloud_js_1.pullPolicy; } });
73
+ Object.defineProperty(exports, "pushReceipt", { enumerable: true, get: function () { return cloud_js_1.pushReceipt; } });
74
+ Object.defineProperty(exports, "pushReceipts", { enumerable: true, get: function () { return cloud_js_1.pushReceipts; } });
75
+ Object.defineProperty(exports, "pollApproval", { enumerable: true, get: function () { return cloud_js_1.pollApproval; } });
76
+ Object.defineProperty(exports, "waitForApproval", { enumerable: true, get: function () { return cloud_js_1.waitForApproval; } });
77
+ Object.defineProperty(exports, "getL1Parts", { enumerable: true, get: function () { return cloud_js_1.getL1Parts; } });
78
+ Object.defineProperty(exports, "getQuorumParts", { enumerable: true, get: function () { return cloud_js_1.getQuorumParts; } });
79
+ Object.defineProperty(exports, "submitApprovalToken", { enumerable: true, get: function () { return cloud_js_1.submitApprovalToken; } });
80
+ var proxy_js_1 = require("./proxy.js");
81
+ Object.defineProperty(exports, "wrap", { enumerable: true, get: function () { return proxy_js_1.wrap; } });
82
+ // Operator delegation-envelope minting (client-approval gates). Zero crypto in TS —
83
+ // the caller injects an OperatorSigner; the wire is byte-pinned to the Rust core.
84
+ var delegation_js_1 = require("./delegation.js");
85
+ Object.defineProperty(exports, "signDelegation", { enumerable: true, get: function () { return delegation_js_1.signDelegation; } });
86
+ Object.defineProperty(exports, "mintDelegationEnvelope", { enumerable: true, get: function () { return delegation_js_1.mintDelegationEnvelope; } });
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,kFAAkF;AAClF,4EAA4E;AAC5E,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvC,yCAAuC;AAA9B,sGAAA,SAAS,OAAA;AAGlB,8DAA8D;AAC9D,2CAAkD;AAAzC,kGAAA,IAAI,OAAA;AAAE,2GAAA,aAAa,OAAA;AAG5B,2CAQqB;AAPnB,0GAAA,YAAY,OAAA;AACZ,4GAAA,cAAc,OAAA;AACd,yGAAA,WAAW,OAAA;AACX,mHAAA,qBAAqB,OAAA;AACrB,sHAAA,wBAAwB,OAAA;AACxB,wGAAA,UAAU,OAAA;AACV,4GAAA,cAAc,OAAA;AAYhB,uFAAuF;AACvF,+EAA+E;AAC/E,oBAAoB;AACpB,uDAAsC;AAEtC,mFAAmF;AACnF,gFAAgF;AAChF,8DAA6C;AAC7C,+DAA8C;AAE9C,yCAA4E;AAAnE,iGAAA,IAAI,OAAA;AAAE,uGAAA,UAAU,OAAA;AAAE,sGAAA,SAAS,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAGvD,uCASmB;AARjB,sGAAA,UAAU,OAAA;AACV,uGAAA,WAAW,OAAA;AACX,wGAAA,YAAY,OAAA;AACZ,wGAAA,YAAY,OAAA;AACZ,2GAAA,eAAe,OAAA;AACf,sGAAA,UAAU,OAAA;AACV,0GAAA,cAAc,OAAA;AACd,+GAAA,mBAAmB,OAAA;AAarB,uCAAiC;AAAxB,gGAAA,IAAI,OAAA;AAGb,oFAAoF;AACpF,kFAAkF;AAClF,iDAAwE;AAA/D,+GAAA,cAAc,OAAA;AAAE,uHAAA,sBAAsB,OAAA"}
@@ -0,0 +1,30 @@
1
+ import type { TrustLevel } from './types.js';
2
+ export interface WrapOptions {
3
+ /** Minimum trust level required for each intercepted call. Default: 'L0'. */
4
+ minTrust?: TrustLevel;
5
+ /**
6
+ * Called when a receipt fails the gate check. Defaults to throwing an error.
7
+ * Return `true` to allow the call anyway (e.g. for monitoring-only mode).
8
+ */
9
+ onGateFail?: (method: string, verdict: string) => boolean | Promise<boolean>;
10
+ /**
11
+ * If provided, called with the raw receipt JSON after each successful call.
12
+ * Useful for shipping receipts to the outbox.
13
+ */
14
+ onReceipt?: (method: string, receiptJson: string) => void | Promise<void>;
15
+ }
16
+ /**
17
+ * Wrap an arbitrary client object with transparent HESO receipt verification.
18
+ *
19
+ * Every method call on the returned proxy:
20
+ * 1. Forwards arguments to the underlying method.
21
+ * 2. Checks whether the result carries a `__heso_receipt` field.
22
+ * 3. If it does, gates it (validity + `minTrust`) via the native verify surface
23
+ * before returning the result.
24
+ *
25
+ * This is a best-effort pattern for clients that attach receipts to their
26
+ * response objects. For clients that return receipts out-of-band, use
27
+ * `gate()` / `assertGate()` directly.
28
+ */
29
+ export declare function wrap<T extends object>(client: T, options?: WrapOptions): T;
30
+ //# sourceMappingURL=proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,UAAU,CAAA;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC5E;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,GAAE,WAAgB,GAAG,CAAC,CAsC9E"}
package/dist/proxy.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ // Transparent proxy wrapper — wrap(client) returns a Proxy that intercepts
3
+ // every method call, captures a receipt for each action, and gates it before
4
+ // forwarding the result to the caller.
5
+ //
6
+ // Zero crypto in TS: verification runs through `gate()`, which binds to the
7
+ // native @hesohq/node addon (via @hesohq/core's main entry) in this Node SDK.
8
+ // `gate()` checks receipt VALIDITY against `minTrust`; with the default
9
+ // minTrust='L0' it accepts any valid receipt and does NOT assert the receipt's
10
+ // decision path — pass minTrust='L1' to require a human co-signature.
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.wrap = wrap;
13
+ const gating_js_1 = require("./gating.js");
14
+ /**
15
+ * Wrap an arbitrary client object with transparent HESO receipt verification.
16
+ *
17
+ * Every method call on the returned proxy:
18
+ * 1. Forwards arguments to the underlying method.
19
+ * 2. Checks whether the result carries a `__heso_receipt` field.
20
+ * 3. If it does, gates it (validity + `minTrust`) via the native verify surface
21
+ * before returning the result.
22
+ *
23
+ * This is a best-effort pattern for clients that attach receipts to their
24
+ * response objects. For clients that return receipts out-of-band, use
25
+ * `gate()` / `assertGate()` directly.
26
+ */
27
+ function wrap(client, options = {}) {
28
+ const { minTrust = 'L0', onGateFail, onReceipt } = options;
29
+ return new Proxy(client, {
30
+ get(target, prop, receiver) {
31
+ const value = Reflect.get(target, prop, receiver);
32
+ if (typeof value !== 'function')
33
+ return value;
34
+ return async function (...args) {
35
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
+ const result = await value.apply(target, args);
37
+ // Look for a receipt attached to the result
38
+ if (result !== null && typeof result === 'object' && '__heso_receipt' in result) {
39
+ const receiptJson = result.__heso_receipt;
40
+ const gateResult = (0, gating_js_1.gate)(receiptJson, minTrust);
41
+ if (onReceipt) {
42
+ await Promise.resolve(onReceipt(String(prop), receiptJson));
43
+ }
44
+ if (!gateResult.allowed) {
45
+ const allowAnyway = onGateFail
46
+ ? await Promise.resolve(onGateFail(String(prop), gateResult.verdict))
47
+ : false;
48
+ if (!allowAnyway) {
49
+ throw new Error(`@hesohq/sdk: gate rejected receipt on ${String(prop)} — ` +
50
+ `verdict=${gateResult.verdict} trustLevel=${gateResult.trustLevel ?? 'none'}`);
51
+ }
52
+ }
53
+ }
54
+ return result;
55
+ };
56
+ },
57
+ });
58
+ }
59
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":";AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,uCAAuC;AACvC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,sEAAsE;;AAiCtE,oBAsCC;AArED,2CAAkC;AAkBlC;;;;;;;;;;;;GAYG;AACH,SAAgB,IAAI,CAAmB,MAAS,EAAE,UAAuB,EAAE;IACzE,MAAM,EAAE,QAAQ,GAAG,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I,MAAM,EAAE,CAC9E,CAAA;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,OAAO,MAAM,CAAA;YACf,CAAC,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ export interface HesoRuntimeConfig {
2
+ /** Directory holding `heso.toml` and `heso-local-data/` (operator key, audit log). */
3
+ projectRoot: string;
4
+ /** Default workflow id stamped on actions (and the default chain session). */
5
+ workflow: string;
6
+ /** Default account/tenant stamped on actions. */
7
+ account: string;
8
+ /** RFC-3339 instant pinned into every action for reproducible runs, or null. */
9
+ clockOverride: string | null;
10
+ /** When true (default) a blocked/suspended action throws; false = observe-only. */
11
+ blocking: boolean;
12
+ }
13
+ export interface InitOptions {
14
+ projectRoot?: string;
15
+ workflow?: string;
16
+ account?: string;
17
+ clockOverride?: string;
18
+ blocking?: boolean;
19
+ }
20
+ /**
21
+ * Resolve and install the engine runtime config, returning it. Call once at
22
+ * startup before gating an action. Re-calling replaces the active config (cheap,
23
+ * intended — e.g. for tests).
24
+ */
25
+ export declare function init(options?: InitOptions): HesoRuntimeConfig;
26
+ /** The active engine config, or null before {@link init}. */
27
+ export declare function currentConfig(): HesoRuntimeConfig | null;
28
+ /** The active engine config, or throw if {@link init} has not run. */
29
+ export declare function requireConfig(): HesoRuntimeConfig;
30
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,iBAAiB;IAChC,sFAAsF;IACtF,WAAW,EAAE,MAAM,CAAA;IACnB,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAA;IAChB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAA;IACf,gFAAgF;IAChF,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,mFAAmF;IACnF,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAID;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,iBAAiB,CAUjE;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,IAAI,iBAAiB,GAAG,IAAI,CAExD;AAED,sEAAsE;AACtE,wBAAgB,aAAa,IAAI,iBAAiB,CAKjD"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ // Engine runtime config — the in-process gate/mint counterpart to the cloud
3
+ // `configure()`. Resolves the project root (the dir holding `heso.toml` and
4
+ // `heso-local-data/`: operator key, audit log, chains), the default
5
+ // workflow/account stamped on every action, an optional pinned clock, and the
6
+ // blocking/observe-only switch. Mirrors the Python SDK's `heso.init` / `Config`.
7
+ //
8
+ // Resolution order for every setting: explicit option > environment > discovery >
9
+ // built-in default.
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.init = init;
12
+ exports.currentConfig = currentConfig;
13
+ exports.requireConfig = requireConfig;
14
+ const node_fs_1 = require("node:fs");
15
+ const node_path_1 = require("node:path");
16
+ let _runtime = null;
17
+ /**
18
+ * Resolve and install the engine runtime config, returning it. Call once at
19
+ * startup before gating an action. Re-calling replaces the active config (cheap,
20
+ * intended — e.g. for tests).
21
+ */
22
+ function init(options = {}) {
23
+ const config = {
24
+ projectRoot: resolveProjectRoot(options.projectRoot),
25
+ workflow: options.workflow ?? process.env.HESO_WORKFLOW ?? 'default',
26
+ account: options.account ?? process.env.HESO_ACCOUNT ?? 'default',
27
+ clockOverride: options.clockOverride ?? process.env.HESO_CLOCK ?? null,
28
+ blocking: options.blocking ?? resolveBlocking(),
29
+ };
30
+ _runtime = config;
31
+ return config;
32
+ }
33
+ /** The active engine config, or null before {@link init}. */
34
+ function currentConfig() {
35
+ return _runtime;
36
+ }
37
+ /** The active engine config, or throw if {@link init} has not run. */
38
+ function requireConfig() {
39
+ if (_runtime === null) {
40
+ throw new Error('@hesohq/sdk: call init() before gating an action');
41
+ }
42
+ return _runtime;
43
+ }
44
+ /** Read `HESO_BLOCKING` (off/false/0/no ⇒ observe-only). Unset ⇒ enforce. */
45
+ function resolveBlocking() {
46
+ const raw = process.env.HESO_BLOCKING;
47
+ if (raw === undefined)
48
+ return true;
49
+ const v = raw.trim().toLowerCase();
50
+ return !(v === '0' || v === 'false' || v === 'no' || v === 'off');
51
+ }
52
+ /** Find the dir owning `heso.toml`: explicit > $HESO_PROJECT_ROOT > nearest ancestor > cwd. */
53
+ function resolveProjectRoot(explicit) {
54
+ if (explicit !== undefined)
55
+ return (0, node_path_1.resolve)(explicit);
56
+ const env = process.env.HESO_PROJECT_ROOT;
57
+ if (env)
58
+ return (0, node_path_1.resolve)(env);
59
+ let dir = process.cwd();
60
+ for (;;) {
61
+ if ((0, node_fs_1.existsSync)((0, node_path_1.resolve)(dir, 'heso.toml')))
62
+ return dir;
63
+ const parent = (0, node_path_1.dirname)(dir);
64
+ if (parent === dir)
65
+ break;
66
+ dir = parent;
67
+ }
68
+ return process.cwd();
69
+ }
70
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,oEAAoE;AACpE,8EAA8E;AAC9E,iFAAiF;AACjF,EAAE;AACF,kFAAkF;AAClF,oBAAoB;;AAiCpB,oBAUC;AAGD,sCAEC;AAGD,sCAKC;AAtDD,qCAAoC;AACpC,yCAA4C;AAuB5C,IAAI,QAAQ,GAA6B,IAAI,CAAA;AAE7C;;;;GAIG;AACH,SAAgB,IAAI,CAAC,UAAuB,EAAE;IAC5C,MAAM,MAAM,GAAsB;QAChC,WA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