attenu-guard 0.3.0 → 0.4.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/CHANGELOG.md +62 -0
- package/README.md +8 -2
- package/dist/cjs/adapters/langgraph.d.ts +27 -3
- package/dist/cjs/adapters/langgraph.d.ts.map +1 -1
- package/dist/cjs/adapters/langgraph.js +290 -11
- package/dist/cjs/adapters/langgraph.js.map +1 -1
- package/dist/cjs/audit.d.ts +38 -1
- package/dist/cjs/audit.d.ts.map +1 -1
- package/dist/cjs/audit.js +69 -8
- package/dist/cjs/audit.js.map +1 -1
- package/dist/cjs/canonical.d.ts +19 -0
- package/dist/cjs/canonical.d.ts.map +1 -1
- package/dist/cjs/canonical.js +60 -2
- package/dist/cjs/canonical.js.map +1 -1
- package/dist/cjs/ceilings.d.ts.map +1 -1
- package/dist/cjs/ceilings.js +18 -0
- package/dist/cjs/ceilings.js.map +1 -1
- package/dist/cjs/chain.d.ts +32 -0
- package/dist/cjs/chain.d.ts.map +1 -1
- package/dist/cjs/chain.js +0 -0
- package/dist/cjs/chain.js.map +1 -1
- package/dist/cjs/cli.d.ts.map +1 -1
- package/dist/cjs/cli.js +4 -0
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/evidence.d.ts +41 -2
- package/dist/cjs/evidence.d.ts.map +1 -1
- package/dist/cjs/evidence.js +571 -13
- package/dist/cjs/evidence.js.map +1 -1
- package/dist/cjs/guard.d.ts +163 -9
- package/dist/cjs/guard.d.ts.map +1 -1
- package/dist/cjs/guard.js +426 -26
- package/dist/cjs/guard.js.map +1 -1
- package/dist/cjs/index.d.ts +12 -9
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +24 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/params.d.ts +52 -0
- package/dist/cjs/params.d.ts.map +1 -0
- package/dist/cjs/params.js +97 -0
- package/dist/cjs/params.js.map +1 -0
- package/dist/cjs/reasons.d.ts +89 -1
- package/dist/cjs/reasons.d.ts.map +1 -1
- package/dist/cjs/reasons.js +99 -3
- package/dist/cjs/reasons.js.map +1 -1
- package/dist/cjs/version.d.ts +10 -0
- package/dist/cjs/version.d.ts.map +1 -0
- package/dist/cjs/version.js +13 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/cjs/wire.d.ts.map +1 -1
- package/dist/cjs/wire.js +7 -0
- package/dist/cjs/wire.js.map +1 -1
- package/dist/esm/adapters/langgraph.d.ts +27 -3
- package/dist/esm/adapters/langgraph.d.ts.map +1 -1
- package/dist/esm/adapters/langgraph.js +290 -11
- package/dist/esm/adapters/langgraph.js.map +1 -1
- package/dist/esm/audit.d.ts +38 -1
- package/dist/esm/audit.d.ts.map +1 -1
- package/dist/esm/audit.js +68 -8
- package/dist/esm/audit.js.map +1 -1
- package/dist/esm/canonical.d.ts +19 -0
- package/dist/esm/canonical.d.ts.map +1 -1
- package/dist/esm/canonical.js +58 -1
- package/dist/esm/canonical.js.map +1 -1
- package/dist/esm/ceilings.d.ts.map +1 -1
- package/dist/esm/ceilings.js +19 -1
- package/dist/esm/ceilings.js.map +1 -1
- package/dist/esm/chain.d.ts +32 -0
- package/dist/esm/chain.d.ts.map +1 -1
- package/dist/esm/chain.js +0 -0
- package/dist/esm/chain.js.map +1 -1
- package/dist/esm/cli.d.ts.map +1 -1
- package/dist/esm/cli.js +4 -0
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/evidence.d.ts +41 -2
- package/dist/esm/evidence.d.ts.map +1 -1
- package/dist/esm/evidence.js +570 -12
- package/dist/esm/evidence.js.map +1 -1
- package/dist/esm/guard.d.ts +163 -9
- package/dist/esm/guard.d.ts.map +1 -1
- package/dist/esm/guard.js +393 -27
- package/dist/esm/guard.js.map +1 -1
- package/dist/esm/index.d.ts +12 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/params.d.ts +52 -0
- package/dist/esm/params.d.ts.map +1 -0
- package/dist/esm/params.js +92 -0
- package/dist/esm/params.js.map +1 -0
- package/dist/esm/reasons.d.ts +89 -1
- package/dist/esm/reasons.d.ts.map +1 -1
- package/dist/esm/reasons.js +97 -2
- package/dist/esm/reasons.js.map +1 -1
- package/dist/esm/version.d.ts +10 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +10 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/esm/wire.d.ts.map +1 -1
- package/dist/esm/wire.js +8 -1
- package/dist/esm/wire.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -30,23 +30,26 @@
|
|
|
30
30
|
*/
|
|
31
31
|
export { Authority, AuthorityError } from "./authority.js";
|
|
32
32
|
export type { AuthorityInit, AuthorityWire } from "./authority.js";
|
|
33
|
-
export { Guard, AuthorityDenied } from "./guard.js";
|
|
34
|
-
export type { CheckOptions, IssueOptions, RecordDenialOptions } from "./guard.js";
|
|
35
|
-
export {
|
|
36
|
-
export type { DispositionValue, ReasonCodeValue, ReasonInit } from "./reasons.js";
|
|
33
|
+
export { Guard, AuthorityDenied, DuplicateOutcomeError } from "./guard.js";
|
|
34
|
+
export type { AdapterInfo, CheckOptions, IssueOptions, ReceiptInfo, RecordDenialOptions, RecordOutcomeOptions, } from "./guard.js";
|
|
35
|
+
export { BODY_STATES, CAPTURES, DISPOSITIONS, BodyState, Capture, CompletionResult, Decision, Disposition, Reason, ReasonCode, } from "./reasons.js";
|
|
36
|
+
export type { BodyStateValue, CaptureValue, DispositionValue, ReasonCodeValue, ReasonInit, } from "./reasons.js";
|
|
37
|
+
export { PARAMS_C14N_VERSION, PARAMS_HASH_REASONS, ParamsHashReason, SALT_HEX_LEN, decodeSalt } from "./params.js";
|
|
38
|
+
export type { ParamsHashReasonValue } from "./params.js";
|
|
39
|
+
export { commit as commitParams } from "./params.js";
|
|
37
40
|
export { Allow, CallLimit, Deny, EgressRank, Prefix, RowLimit, SpendCap, UnknownCeiling, ceilingFromWire, ctxFieldOf, describe, isMetered, registerCeiling, } from "./ceilings.js";
|
|
38
41
|
export type { Ceiling, CeilingClass, Context } from "./ceilings.js";
|
|
39
|
-
export { AuditLog, GENESIS, SCHEMA_VERSION, chainIdOf, hashEntry } from "./audit.js";
|
|
42
|
+
export { AuditLog, CommittedAuditError, GENESIS, SCHEMA_VERSION, chainIdOf, hashEntry } from "./audit.js";
|
|
40
43
|
export type { Anchor, AuditLogInit, LedgerEntry, Sink } from "./audit.js";
|
|
41
44
|
export { Chain, ManualClock, MonotonicClock } from "./chain.js";
|
|
42
45
|
export type { Clock, ChainInit, Node } from "./chain.js";
|
|
43
46
|
export { StrikePolicy } from "./strikes.js";
|
|
44
47
|
export type { StrikeMode, StrikePolicyInit } from "./strikes.js";
|
|
45
|
-
export { EvidenceLeakError, LEDGER_FIELDS, anchorFor, delegationGraph, denials, exportBundle, parseBundle, redactionReport, verifyBundle, } from "./evidence.js";
|
|
46
|
-
export type { Bundle, DelegationGraph, DenialRow, ExportOptions, GraphNode, RedactionReport, RedactionViolation, VerifyChecks, VerifyReport, } from "./evidence.js";
|
|
48
|
+
export { EvidenceLeakError, LEDGER_FIELDS, SUPPORTED_BUNDLE_VERSIONS, anchorFor, delegationGraph, denials, exportBundle, parseBundle, redactionReport, verifyBundle, } from "./evidence.js";
|
|
49
|
+
export type { Bundle, DelegationGraph, DenialRow, ExecutionBinding, ExportOptions, GraphNode, RedactionReport, RedactionViolation, VerifyChecks, VerifyReport, } from "./evidence.js";
|
|
47
50
|
export { Ed25519Signer, Ed25519Verifier, HS256TestSigner, VerifiedChain, WireError, WireReasonCode, b64urlDecode, b64urlEncode, load, } from "./wire.js";
|
|
48
51
|
export type { LoadOptions, Signer, WireReasonCodeValue } from "./wire.js";
|
|
49
|
-
export { CanonicalizationError, DuplicateMemberError, LoneSurrogateError, NonFiniteNumberError, RawNumber, UnsupportedTypeError, canonicalBytes, canonicalJson, compareCodePoints, parseJson, pyNumber, sortedStrings, toPlain, } from "./canonical.js";
|
|
52
|
+
export { CanonicalizationError, DuplicateMemberError, LoneSurrogateError, MAX_SAFE_INTEGER, NonFiniteNumberError, RawNumber, UnsafeIntegerError, UnsupportedTypeError, canonicalBytes, canonicalJson, compareCodePoints, parseJson, pyNumber, sortedStrings, toPlain, } from "./canonical.js";
|
|
50
53
|
export type { CJson, Json } from "./canonical.js";
|
|
51
|
-
export
|
|
54
|
+
export { VERSION } from "./version.js";
|
|
52
55
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC3E,YAAY,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,MAAM,EACN,UA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,EACf,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,SAAS,EACT,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,IAAI,GACL,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAE1E,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,OAAO,GACR,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -29,14 +29,16 @@
|
|
|
29
29
|
* one verifies with the other.
|
|
30
30
|
*/
|
|
31
31
|
export { Authority, AuthorityError } from "./authority.js";
|
|
32
|
-
export { Guard, AuthorityDenied } from "./guard.js";
|
|
33
|
-
export {
|
|
32
|
+
export { Guard, AuthorityDenied, DuplicateOutcomeError } from "./guard.js";
|
|
33
|
+
export { BODY_STATES, CAPTURES, DISPOSITIONS, BodyState, Capture, CompletionResult, Decision, Disposition, Reason, ReasonCode, } from "./reasons.js";
|
|
34
|
+
export { PARAMS_C14N_VERSION, PARAMS_HASH_REASONS, ParamsHashReason, SALT_HEX_LEN, decodeSalt } from "./params.js";
|
|
35
|
+
export { commit as commitParams } from "./params.js";
|
|
34
36
|
export { Allow, CallLimit, Deny, EgressRank, Prefix, RowLimit, SpendCap, UnknownCeiling, ceilingFromWire, ctxFieldOf, describe, isMetered, registerCeiling, } from "./ceilings.js";
|
|
35
|
-
export { AuditLog, GENESIS, SCHEMA_VERSION, chainIdOf, hashEntry } from "./audit.js";
|
|
37
|
+
export { AuditLog, CommittedAuditError, GENESIS, SCHEMA_VERSION, chainIdOf, hashEntry } from "./audit.js";
|
|
36
38
|
export { Chain, ManualClock, MonotonicClock } from "./chain.js";
|
|
37
39
|
export { StrikePolicy } from "./strikes.js";
|
|
38
|
-
export { EvidenceLeakError, LEDGER_FIELDS, anchorFor, delegationGraph, denials, exportBundle, parseBundle, redactionReport, verifyBundle, } from "./evidence.js";
|
|
40
|
+
export { EvidenceLeakError, LEDGER_FIELDS, SUPPORTED_BUNDLE_VERSIONS, anchorFor, delegationGraph, denials, exportBundle, parseBundle, redactionReport, verifyBundle, } from "./evidence.js";
|
|
39
41
|
export { Ed25519Signer, Ed25519Verifier, HS256TestSigner, VerifiedChain, WireError, WireReasonCode, b64urlDecode, b64urlEncode, load, } from "./wire.js";
|
|
40
|
-
export { CanonicalizationError, DuplicateMemberError, LoneSurrogateError, NonFiniteNumberError, RawNumber, UnsupportedTypeError, canonicalBytes, canonicalJson, compareCodePoints, parseJson, pyNumber, sortedStrings, toPlain, } from "./canonical.js";
|
|
41
|
-
export
|
|
42
|
+
export { CanonicalizationError, DuplicateMemberError, LoneSurrogateError, MAX_SAFE_INTEGER, NonFiniteNumberError, RawNumber, UnsafeIntegerError, UnsupportedTypeError, canonicalBytes, canonicalJson, compareCodePoints, parseJson, pyNumber, sortedStrings, toPlain, } from "./canonical.js";
|
|
43
|
+
export { VERSION } from "./version.js";
|
|
42
44
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAA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aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,SAAS,EACT,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,IAAI,GACL,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,OAAO,GACR,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* params.ts — the `params_c14n_v1` argument commitment (docs/execution-binding spec section 4).
|
|
3
|
+
*
|
|
4
|
+
* Two observations, two hashes: `authorized_params_hash` (on the `allow` entry, from what
|
|
5
|
+
* `Guard.check` was called with) and `invoked_params_hash` (on the `outcome` entry, from what the
|
|
6
|
+
* body-owning wrapper observed immediately before the actual invocation). Substitution between
|
|
7
|
+
* them is visible only because both exist; neither raw value is ever logged.
|
|
8
|
+
*
|
|
9
|
+
* Commitment: `SHA-256(rawSalt || UTF8(JCS(params)))`, lowercase hex — `rawSalt` is the chain's
|
|
10
|
+
* 16-byte `paramsSalt` (see chain.ts), fixed for the chain's lifetime; `JCS(params)` reuses
|
|
11
|
+
* `canonicalBytes` verbatim (RFC 8785), so the numeric domain and encoding rules are identical to
|
|
12
|
+
* every other signing surface in this library.
|
|
13
|
+
*
|
|
14
|
+
* One divergence from the Python module this mirrors, deliberately closed rather than inherited:
|
|
15
|
+
* Python's general `canonical.dumps` tolerates an out-of-range INTEGRAL float (e.g. `1e20`) —
|
|
16
|
+
* needed for a pinned JCS-divergence-class test — so `attenu_guard.params` runs its own domain
|
|
17
|
+
* pre-check in front of it. TypeScript's `canonicalBytes` has no such tolerance: because
|
|
18
|
+
* JavaScript has one numeric type, `checkSafeInteger` already rejects EVERY unsafe integer,
|
|
19
|
+
* literal or float-shaped alike (see canonical.ts's `UnsafeIntegerError`). The spec's rule for
|
|
20
|
+
* this profile is stated runtime-neutrally — "every mathematically integral number outside
|
|
21
|
+
* ±(2^53−1) is rejected, regardless of the host's numeric type" — so this module still runs its
|
|
22
|
+
* OWN independent domain check (mirroring Python's `_has_unsafe_integral_float`) rather than
|
|
23
|
+
* leaning on `canonicalBytes`'s already-strict behaviour: that behaviour is an accident of
|
|
24
|
+
* JavaScript having no int/float distinction, not a promise `params.ts` should depend on.
|
|
25
|
+
*
|
|
26
|
+
* Outside the domain (either reason): no hash, and the caller writes `paramsHashReason:
|
|
27
|
+
* "unsupported"` on the record whose hash is absent — never throws. A caller that never attempts
|
|
28
|
+
* a commitment at all writes neither field; "unsupported" and "never attempted" are deliberately
|
|
29
|
+
* distinguishable states, not folded into one.
|
|
30
|
+
*/
|
|
31
|
+
import { type Json } from "./canonical.js";
|
|
32
|
+
export declare const PARAMS_C14N_VERSION = "params_c14n_v1";
|
|
33
|
+
export declare const SALT_HEX_LEN = 32;
|
|
34
|
+
/** `"unsupported"` — the one reason a params commitment can be absent. */
|
|
35
|
+
export declare const ParamsHashReason: {
|
|
36
|
+
readonly UNSUPPORTED: "unsupported";
|
|
37
|
+
};
|
|
38
|
+
export type ParamsHashReasonValue = (typeof ParamsHashReason)[keyof typeof ParamsHashReason];
|
|
39
|
+
export declare const PARAMS_HASH_REASONS: ReadonlySet<string>;
|
|
40
|
+
/**
|
|
41
|
+
* The 16 raw bytes a chain's `paramsSalt` (32 lowercase hex chars, on the `root` entry) decodes
|
|
42
|
+
* to. Throws on anything else — a malformed salt must fail loudly, not silently hash against the
|
|
43
|
+
* wrong number of bytes.
|
|
44
|
+
*/
|
|
45
|
+
export declare function decodeSalt(paramsSaltHex: string): Buffer;
|
|
46
|
+
/**
|
|
47
|
+
* `[hashHex, reason]`. `hashHex` is the lowercase-hex `params_c14n_v1` commitment, or `null` if
|
|
48
|
+
* `params` is outside the domain — in which case `reason === ParamsHashReason.UNSUPPORTED`.
|
|
49
|
+
* Exactly one of the two is non-null.
|
|
50
|
+
*/
|
|
51
|
+
export declare function commit(paramsValue: Json, rawSalt: Buffer): [string | null, string | null];
|
|
52
|
+
//# sourceMappingURL=params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,EAA2D,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEpG,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB;;CAEnB,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE7F,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAA4C,CAAC;AAEjG;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAOxD;AAoBD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAiBzF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* params.ts — the `params_c14n_v1` argument commitment (docs/execution-binding spec section 4).
|
|
3
|
+
*
|
|
4
|
+
* Two observations, two hashes: `authorized_params_hash` (on the `allow` entry, from what
|
|
5
|
+
* `Guard.check` was called with) and `invoked_params_hash` (on the `outcome` entry, from what the
|
|
6
|
+
* body-owning wrapper observed immediately before the actual invocation). Substitution between
|
|
7
|
+
* them is visible only because both exist; neither raw value is ever logged.
|
|
8
|
+
*
|
|
9
|
+
* Commitment: `SHA-256(rawSalt || UTF8(JCS(params)))`, lowercase hex — `rawSalt` is the chain's
|
|
10
|
+
* 16-byte `paramsSalt` (see chain.ts), fixed for the chain's lifetime; `JCS(params)` reuses
|
|
11
|
+
* `canonicalBytes` verbatim (RFC 8785), so the numeric domain and encoding rules are identical to
|
|
12
|
+
* every other signing surface in this library.
|
|
13
|
+
*
|
|
14
|
+
* One divergence from the Python module this mirrors, deliberately closed rather than inherited:
|
|
15
|
+
* Python's general `canonical.dumps` tolerates an out-of-range INTEGRAL float (e.g. `1e20`) —
|
|
16
|
+
* needed for a pinned JCS-divergence-class test — so `attenu_guard.params` runs its own domain
|
|
17
|
+
* pre-check in front of it. TypeScript's `canonicalBytes` has no such tolerance: because
|
|
18
|
+
* JavaScript has one numeric type, `checkSafeInteger` already rejects EVERY unsafe integer,
|
|
19
|
+
* literal or float-shaped alike (see canonical.ts's `UnsafeIntegerError`). The spec's rule for
|
|
20
|
+
* this profile is stated runtime-neutrally — "every mathematically integral number outside
|
|
21
|
+
* ±(2^53−1) is rejected, regardless of the host's numeric type" — so this module still runs its
|
|
22
|
+
* OWN independent domain check (mirroring Python's `_has_unsafe_integral_float`) rather than
|
|
23
|
+
* leaning on `canonicalBytes`'s already-strict behaviour: that behaviour is an accident of
|
|
24
|
+
* JavaScript having no int/float distinction, not a promise `params.ts` should depend on.
|
|
25
|
+
*
|
|
26
|
+
* Outside the domain (either reason): no hash, and the caller writes `paramsHashReason:
|
|
27
|
+
* "unsupported"` on the record whose hash is absent — never throws. A caller that never attempts
|
|
28
|
+
* a commitment at all writes neither field; "unsupported" and "never attempted" are deliberately
|
|
29
|
+
* distinguishable states, not folded into one.
|
|
30
|
+
*/
|
|
31
|
+
import { createHash } from "node:crypto";
|
|
32
|
+
import { CanonicalizationError, MAX_SAFE_INTEGER, canonicalBytes } from "./canonical.js";
|
|
33
|
+
export const PARAMS_C14N_VERSION = "params_c14n_v1";
|
|
34
|
+
export const SALT_HEX_LEN = 32; // 16 raw bytes, hex-encoded
|
|
35
|
+
/** `"unsupported"` — the one reason a params commitment can be absent. */
|
|
36
|
+
export const ParamsHashReason = {
|
|
37
|
+
UNSUPPORTED: "unsupported",
|
|
38
|
+
};
|
|
39
|
+
export const PARAMS_HASH_REASONS = new Set(Object.values(ParamsHashReason));
|
|
40
|
+
/**
|
|
41
|
+
* The 16 raw bytes a chain's `paramsSalt` (32 lowercase hex chars, on the `root` entry) decodes
|
|
42
|
+
* to. Throws on anything else — a malformed salt must fail loudly, not silently hash against the
|
|
43
|
+
* wrong number of bytes.
|
|
44
|
+
*/
|
|
45
|
+
export function decodeSalt(paramsSaltHex) {
|
|
46
|
+
if (!/^[0-9a-f]{32}$/.test(paramsSaltHex)) {
|
|
47
|
+
throw new Error(`params_salt must decode to 16 raw bytes; got ${JSON.stringify(paramsSaltHex)}`);
|
|
48
|
+
}
|
|
49
|
+
return Buffer.from(paramsSaltHex, "hex");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `true` if `value` contains, anywhere in its structure, a number that is mathematically integral
|
|
53
|
+
* and exceeds ±`MAX_SAFE_INTEGER` — the params_c14n_v1 domain boundary, checked independently of
|
|
54
|
+
* `canonicalBytes` (see the module doc comment).
|
|
55
|
+
*/
|
|
56
|
+
function hasUnsafeIntegralNumber(value) {
|
|
57
|
+
if (typeof value === "number") {
|
|
58
|
+
return Number.isFinite(value) && Number.isInteger(value) && Math.abs(value) > MAX_SAFE_INTEGER;
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(value)) {
|
|
61
|
+
return value.some(hasUnsafeIntegralNumber);
|
|
62
|
+
}
|
|
63
|
+
if (value !== null && typeof value === "object") {
|
|
64
|
+
return Object.values(value).some(hasUnsafeIntegralNumber);
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* `[hashHex, reason]`. `hashHex` is the lowercase-hex `params_c14n_v1` commitment, or `null` if
|
|
70
|
+
* `params` is outside the domain — in which case `reason === ParamsHashReason.UNSUPPORTED`.
|
|
71
|
+
* Exactly one of the two is non-null.
|
|
72
|
+
*/
|
|
73
|
+
export function commit(paramsValue, rawSalt) {
|
|
74
|
+
if (hasUnsafeIntegralNumber(paramsValue)) {
|
|
75
|
+
return [null, ParamsHashReason.UNSUPPORTED];
|
|
76
|
+
}
|
|
77
|
+
let encoded;
|
|
78
|
+
try {
|
|
79
|
+
encoded = canonicalBytes(paramsValue); // UTF8(JCS(params)) — canonicalBytes already returns UTF-8 bytes
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
if (e instanceof CanonicalizationError) {
|
|
83
|
+
return [null, ParamsHashReason.UNSUPPORTED];
|
|
84
|
+
}
|
|
85
|
+
throw e;
|
|
86
|
+
}
|
|
87
|
+
const h = createHash("sha256");
|
|
88
|
+
h.update(rawSalt);
|
|
89
|
+
h.update(encoded);
|
|
90
|
+
return [h.digest("hex"), null];
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../src/params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAEpG,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC,CAAC,4BAA4B;AAE5D,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,WAAW,EAAE,aAAa;CAClB,CAAC;AAIX,MAAM,CAAC,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC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,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,qBAAqB,EAAE,CAAC;YACvC,OAAO,CAAC,IAAI,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;IACD,MAAM,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClB,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/esm/reasons.d.ts
CHANGED
|
@@ -33,6 +33,13 @@ export declare const ReasonCode: {
|
|
|
33
33
|
readonly CHAIN_CEILING: "chain_ceiling";
|
|
34
34
|
/** The principal holds no authority at all in this chain. */
|
|
35
35
|
readonly NO_AUTHORITY: "no_authority";
|
|
36
|
+
/** `check` refused: the node already called `complete()`. */
|
|
37
|
+
readonly NODE_FINALIZED: "node_finalized";
|
|
38
|
+
/**
|
|
39
|
+
* The CSPRNG failed while allocating `callId`; fail-closed — the call is denied and
|
|
40
|
+
* nothing is written.
|
|
41
|
+
*/
|
|
42
|
+
readonly CALL_ID_UNAVAILABLE: "call_id_unavailable";
|
|
36
43
|
};
|
|
37
44
|
export type ReasonCodeValue = (typeof ReasonCode)[keyof typeof ReasonCode];
|
|
38
45
|
/**
|
|
@@ -52,6 +59,68 @@ export declare const Disposition: {
|
|
|
52
59
|
};
|
|
53
60
|
export type DispositionValue = (typeof Disposition)[keyof typeof Disposition];
|
|
54
61
|
export declare const DISPOSITIONS: ReadonlySet<string>;
|
|
62
|
+
/**
|
|
63
|
+
* What the adapter's code path WILL observe for a given `check`ed call (0.9.0 execution binding)
|
|
64
|
+
* — recorded on the `allow` entry alongside `adapter` (module/version/hookPath). Describes
|
|
65
|
+
* observation CAPABILITY only, never a claim of quality: a verifier routes a call into
|
|
66
|
+
* observed/unobserved reporting from this label, never trusts it as evidence on its own.
|
|
67
|
+
*/
|
|
68
|
+
export declare const Capture: {
|
|
69
|
+
/** The adapter's wrapper calls the body itself, synchronously. */
|
|
70
|
+
readonly WRAPPER_SYNC: "wrapper_sync";
|
|
71
|
+
/** ... and awaits it. */
|
|
72
|
+
readonly WRAPPER_ASYNC: "wrapper_async";
|
|
73
|
+
/** The framework itself calls back after the body runs. */
|
|
74
|
+
readonly FRAMEWORK_POST_HOOK: "framework_post_hook";
|
|
75
|
+
/** The adapter sees the call authorized but never observes it finish. */
|
|
76
|
+
readonly PRE_HOOK_ONLY: "pre_hook_only";
|
|
77
|
+
};
|
|
78
|
+
export type CaptureValue = (typeof Capture)[keyof typeof Capture];
|
|
79
|
+
export declare const CAPTURES: ReadonlySet<string>;
|
|
80
|
+
/**
|
|
81
|
+
* The `outcome` record's observation of how a body-owning wrapper's call ended (0.9.0 execution
|
|
82
|
+
* binding, docs/execution-binding spec section 3) — an OBSERVATION, not a judgment about the
|
|
83
|
+
* world. There is no `executed`/`blocked`/`timeout`/`cancelled` at this layer; each of those
|
|
84
|
+
* words claims knowledge a wrapper does not always have. Adapters emitting into a richer outcome
|
|
85
|
+
* vocabulary own that mapping.
|
|
86
|
+
*/
|
|
87
|
+
export declare const BodyState: {
|
|
88
|
+
/** The body returned to the wrapper. */
|
|
89
|
+
readonly RETURNED: "returned";
|
|
90
|
+
/** It raised (`errorCode` required, from the exception's class/constructor name). */
|
|
91
|
+
readonly RAISED: "raised";
|
|
92
|
+
/** The wrapper stopped observing while the body may still run. */
|
|
93
|
+
readonly ABANDONED: "abandoned";
|
|
94
|
+
/** The wrapper returned a generator/stream/future it does not itself consume. */
|
|
95
|
+
readonly DEFERRED: "deferred";
|
|
96
|
+
};
|
|
97
|
+
export type BodyStateValue = (typeof BodyState)[keyof typeof BodyState];
|
|
98
|
+
export declare const BODY_STATES: ReadonlySet<string>;
|
|
99
|
+
/**
|
|
100
|
+
* `Guard.complete()`'s return value on a `schemaVersion: 2` chain ONLY (0.9.0, docs/
|
|
101
|
+
* execution-binding spec section 1): whether the node was actually finalized, and — when it
|
|
102
|
+
* refused because calls are still pending an outcome — the `callId`s it is waiting on. On a
|
|
103
|
+
* `schemaVersion: 1` chain (the default), `complete()` returns a plain `boolean`,
|
|
104
|
+
* byte-and-type IDENTICAL to every release before 0.9.0 — v1 never gained pending-call
|
|
105
|
+
* awareness, so there is nothing new for it to report and no reason to change its return type
|
|
106
|
+
* (mirrors attenu-guard Python's merge-gate fix restoring this exact split).
|
|
107
|
+
*
|
|
108
|
+
* Python's v2 return value is bool-coercible via `__bool__`, so `if guard.complete():` keeps
|
|
109
|
+
* reading naturally there. JavaScript has no such hook for `if` — `ToBoolean` on any object is
|
|
110
|
+
* unconditionally `true`, so on v2 an `if (guard.complete())` check cannot be bridged to `false`
|
|
111
|
+
* no matter what this class defines, and neither can `assert.equal`/`assert.strictEqual` from
|
|
112
|
+
* `node:assert/strict` (no coercion at all). What CAN be bridged: `valueOf()` returns
|
|
113
|
+
* `.completed`, so contexts that genuinely coerce via `==`/`!=` (loose equality), template
|
|
114
|
+
* literals, and arithmetic still read as a boolean. On v2, read `.completed` explicitly wherever
|
|
115
|
+
* you would have written `if (guard.complete())`.
|
|
116
|
+
*/
|
|
117
|
+
export declare class CompletionResult {
|
|
118
|
+
readonly completed: boolean;
|
|
119
|
+
readonly pendingCallIds: readonly string[];
|
|
120
|
+
constructor(completed: boolean, pendingCallIds?: readonly string[]);
|
|
121
|
+
valueOf(): boolean;
|
|
122
|
+
toString(): string;
|
|
123
|
+
}
|
|
55
124
|
export interface ReasonInit {
|
|
56
125
|
/** Which ceiling or dimension, e.g. "max_rows". */
|
|
57
126
|
constraint?: string | null;
|
|
@@ -83,10 +152,29 @@ export declare class Decision {
|
|
|
83
152
|
readonly allowed: boolean;
|
|
84
153
|
readonly reasons: readonly Reason[];
|
|
85
154
|
readonly determiningNode: string | null;
|
|
86
|
-
|
|
155
|
+
/**
|
|
156
|
+
* 0.9.0 execution binding: set only on a `schemaVersion: 2` chain (`Guard.check` /
|
|
157
|
+
* `Guard.recordDenial`); `null` on schema-version-1 chains and on any `Decision` built
|
|
158
|
+
* outside a `Guard` transition (`wouldAllow`, tests).
|
|
159
|
+
*/
|
|
160
|
+
readonly callId: string | null;
|
|
161
|
+
constructor(allowed: boolean, reasons?: readonly Reason[], determiningNode?: string | null,
|
|
162
|
+
/**
|
|
163
|
+
* 0.9.0 execution binding: set only on a `schemaVersion: 2` chain (`Guard.check` /
|
|
164
|
+
* `Guard.recordDenial`); `null` on schema-version-1 chains and on any `Decision` built
|
|
165
|
+
* outside a `Guard` transition (`wouldAllow`, tests).
|
|
166
|
+
*/
|
|
167
|
+
callId?: string | null);
|
|
87
168
|
/** A single human-readable line — for logs, CLIs and error messages. */
|
|
88
169
|
explain(): string;
|
|
170
|
+
/**
|
|
171
|
+
* `callId` is included only when set (a `schemaVersion: 2` chain's `check`/`recordDenial`) — a
|
|
172
|
+
* v1 Decision's serialized shape stays byte-and-key identical to every release before 0.9.0,
|
|
173
|
+
* never gaining a `call_id: null` key it never had.
|
|
174
|
+
*/
|
|
89
175
|
toDict(): Record<string, Json>;
|
|
176
|
+
/** A copy of this Decision with `callId` set — mirrors Python's `dataclasses.replace`. */
|
|
177
|
+
withCallId(callId: string | null): Decision;
|
|
90
178
|
static allow(node?: string | null): Decision;
|
|
91
179
|
static deny(reasons: Reason | readonly Reason[], node?: string | null): Decision;
|
|
92
180
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reasons.d.ts","sourceRoot":"","sources":["../../src/reasons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;IASrB,4EAA4E;;;;;;;;IAU5E,6DAA6D;;
|
|
1
|
+
{"version":3,"file":"reasons.d.ts","sourceRoot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;IACxE,OAAO,IAAI,MAAM;IAMjB;;;;OAIG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;IAU9B,0FAA0F;IAC1F,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ;IAI3C,MAAM,CAAC,KAAK,CAAC,IAAI,GAAE,MAAM,GAAG,IAAW,GAAG,QAAQ;IAIlD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EAAE,IAAI,GAAE,MAAM,GAAG,IAAW,GAAG,QAAQ;CAIvF"}
|
package/dist/esm/reasons.js
CHANGED
|
@@ -34,6 +34,14 @@ export const ReasonCode = {
|
|
|
34
34
|
CHAIN_CEILING: "chain_ceiling",
|
|
35
35
|
/** The principal holds no authority at all in this chain. */
|
|
36
36
|
NO_AUTHORITY: "no_authority",
|
|
37
|
+
// 0.9.0 execution-binding transition (schema_version=2 chains only — see guard.ts):
|
|
38
|
+
/** `check` refused: the node already called `complete()`. */
|
|
39
|
+
NODE_FINALIZED: "node_finalized",
|
|
40
|
+
/**
|
|
41
|
+
* The CSPRNG failed while allocating `callId`; fail-closed — the call is denied and
|
|
42
|
+
* nothing is written.
|
|
43
|
+
*/
|
|
44
|
+
CALL_ID_UNAVAILABLE: "call_id_unavailable",
|
|
37
45
|
};
|
|
38
46
|
/**
|
|
39
47
|
* WHY a denied scope was not in the node's authority — the ledger's answer to
|
|
@@ -51,6 +59,73 @@ export const Disposition = {
|
|
|
51
59
|
OUT_OF_AUTHORITY: "out_of_authority",
|
|
52
60
|
};
|
|
53
61
|
export const DISPOSITIONS = new Set(Object.values(Disposition));
|
|
62
|
+
/**
|
|
63
|
+
* What the adapter's code path WILL observe for a given `check`ed call (0.9.0 execution binding)
|
|
64
|
+
* — recorded on the `allow` entry alongside `adapter` (module/version/hookPath). Describes
|
|
65
|
+
* observation CAPABILITY only, never a claim of quality: a verifier routes a call into
|
|
66
|
+
* observed/unobserved reporting from this label, never trusts it as evidence on its own.
|
|
67
|
+
*/
|
|
68
|
+
export const Capture = {
|
|
69
|
+
/** The adapter's wrapper calls the body itself, synchronously. */
|
|
70
|
+
WRAPPER_SYNC: "wrapper_sync",
|
|
71
|
+
/** ... and awaits it. */
|
|
72
|
+
WRAPPER_ASYNC: "wrapper_async",
|
|
73
|
+
/** The framework itself calls back after the body runs. */
|
|
74
|
+
FRAMEWORK_POST_HOOK: "framework_post_hook",
|
|
75
|
+
/** The adapter sees the call authorized but never observes it finish. */
|
|
76
|
+
PRE_HOOK_ONLY: "pre_hook_only",
|
|
77
|
+
};
|
|
78
|
+
export const CAPTURES = new Set(Object.values(Capture));
|
|
79
|
+
/**
|
|
80
|
+
* The `outcome` record's observation of how a body-owning wrapper's call ended (0.9.0 execution
|
|
81
|
+
* binding, docs/execution-binding spec section 3) — an OBSERVATION, not a judgment about the
|
|
82
|
+
* world. There is no `executed`/`blocked`/`timeout`/`cancelled` at this layer; each of those
|
|
83
|
+
* words claims knowledge a wrapper does not always have. Adapters emitting into a richer outcome
|
|
84
|
+
* vocabulary own that mapping.
|
|
85
|
+
*/
|
|
86
|
+
export const BodyState = {
|
|
87
|
+
/** The body returned to the wrapper. */
|
|
88
|
+
RETURNED: "returned",
|
|
89
|
+
/** It raised (`errorCode` required, from the exception's class/constructor name). */
|
|
90
|
+
RAISED: "raised",
|
|
91
|
+
/** The wrapper stopped observing while the body may still run. */
|
|
92
|
+
ABANDONED: "abandoned",
|
|
93
|
+
/** The wrapper returned a generator/stream/future it does not itself consume. */
|
|
94
|
+
DEFERRED: "deferred",
|
|
95
|
+
};
|
|
96
|
+
export const BODY_STATES = new Set(Object.values(BodyState));
|
|
97
|
+
/**
|
|
98
|
+
* `Guard.complete()`'s return value on a `schemaVersion: 2` chain ONLY (0.9.0, docs/
|
|
99
|
+
* execution-binding spec section 1): whether the node was actually finalized, and — when it
|
|
100
|
+
* refused because calls are still pending an outcome — the `callId`s it is waiting on. On a
|
|
101
|
+
* `schemaVersion: 1` chain (the default), `complete()` returns a plain `boolean`,
|
|
102
|
+
* byte-and-type IDENTICAL to every release before 0.9.0 — v1 never gained pending-call
|
|
103
|
+
* awareness, so there is nothing new for it to report and no reason to change its return type
|
|
104
|
+
* (mirrors attenu-guard Python's merge-gate fix restoring this exact split).
|
|
105
|
+
*
|
|
106
|
+
* Python's v2 return value is bool-coercible via `__bool__`, so `if guard.complete():` keeps
|
|
107
|
+
* reading naturally there. JavaScript has no such hook for `if` — `ToBoolean` on any object is
|
|
108
|
+
* unconditionally `true`, so on v2 an `if (guard.complete())` check cannot be bridged to `false`
|
|
109
|
+
* no matter what this class defines, and neither can `assert.equal`/`assert.strictEqual` from
|
|
110
|
+
* `node:assert/strict` (no coercion at all). What CAN be bridged: `valueOf()` returns
|
|
111
|
+
* `.completed`, so contexts that genuinely coerce via `==`/`!=` (loose equality), template
|
|
112
|
+
* literals, and arithmetic still read as a boolean. On v2, read `.completed` explicitly wherever
|
|
113
|
+
* you would have written `if (guard.complete())`.
|
|
114
|
+
*/
|
|
115
|
+
export class CompletionResult {
|
|
116
|
+
completed;
|
|
117
|
+
pendingCallIds;
|
|
118
|
+
constructor(completed, pendingCallIds = []) {
|
|
119
|
+
this.completed = completed;
|
|
120
|
+
this.pendingCallIds = pendingCallIds;
|
|
121
|
+
}
|
|
122
|
+
valueOf() {
|
|
123
|
+
return this.completed;
|
|
124
|
+
}
|
|
125
|
+
toString() {
|
|
126
|
+
return String(this.completed);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
54
129
|
/** One specific cause of a denial. */
|
|
55
130
|
export class Reason {
|
|
56
131
|
code;
|
|
@@ -103,10 +178,18 @@ export class Decision {
|
|
|
103
178
|
allowed;
|
|
104
179
|
reasons;
|
|
105
180
|
determiningNode;
|
|
106
|
-
|
|
181
|
+
callId;
|
|
182
|
+
constructor(allowed, reasons = [], determiningNode = null,
|
|
183
|
+
/**
|
|
184
|
+
* 0.9.0 execution binding: set only on a `schemaVersion: 2` chain (`Guard.check` /
|
|
185
|
+
* `Guard.recordDenial`); `null` on schema-version-1 chains and on any `Decision` built
|
|
186
|
+
* outside a `Guard` transition (`wouldAllow`, tests).
|
|
187
|
+
*/
|
|
188
|
+
callId = null) {
|
|
107
189
|
this.allowed = allowed;
|
|
108
190
|
this.reasons = reasons;
|
|
109
191
|
this.determiningNode = determiningNode;
|
|
192
|
+
this.callId = callId;
|
|
110
193
|
}
|
|
111
194
|
/** A single human-readable line — for logs, CLIs and error messages. */
|
|
112
195
|
explain() {
|
|
@@ -116,12 +199,24 @@ export class Decision {
|
|
|
116
199
|
return "denied";
|
|
117
200
|
return "denied: " + this.reasons.map((r) => r.toString()).join("; ");
|
|
118
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* `callId` is included only when set (a `schemaVersion: 2` chain's `check`/`recordDenial`) — a
|
|
204
|
+
* v1 Decision's serialized shape stays byte-and-key identical to every release before 0.9.0,
|
|
205
|
+
* never gaining a `call_id: null` key it never had.
|
|
206
|
+
*/
|
|
119
207
|
toDict() {
|
|
120
|
-
|
|
208
|
+
const d = {
|
|
121
209
|
allowed: this.allowed,
|
|
122
210
|
reasons: this.reasons.map((r) => r.toDict()),
|
|
123
211
|
determining_node: this.determiningNode,
|
|
124
212
|
};
|
|
213
|
+
if (this.callId !== null)
|
|
214
|
+
d["call_id"] = this.callId;
|
|
215
|
+
return d;
|
|
216
|
+
}
|
|
217
|
+
/** A copy of this Decision with `callId` set — mirrors Python's `dataclasses.replace`. */
|
|
218
|
+
withCallId(callId) {
|
|
219
|
+
return new Decision(this.allowed, this.reasons, this.determiningNode, callId);
|
|
125
220
|
}
|
|
126
221
|
static allow(node = null) {
|
|
127
222
|
return new Decision(true, [], node);
|
package/dist/esm/reasons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reasons.js","sourceRoot":"","sources":["../../src/reasons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;;GAGG;AACH,MAAM,CAAC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AyB;YAC9B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YAC5C,gBAAgB,EAAE,IAAI,CAAC,eAAe;SACvC,CAAC;QACF,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI;YAAE,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACrD,OAAO,CAAC,CAAC;IACX,CAAC;IAED,0FAA0F;IAC1F,UAAU,CAAC,MAAqB;QAC9B,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAsB,IAAI;QACrC,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAmC,EAAE,OAAsB,IAAI;QACzE,MAAM,IAAI,GAAG,OAAO,YAAY,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzE,OAAO,IAAI,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* version.ts — the package version, as its own leaf module.
|
|
3
|
+
*
|
|
4
|
+
* guard.ts needs this (to attribute a guard-supplied `adapter.version` on a bare `check()` with
|
|
5
|
+
* no wrapper — see the "Execution binding" section of guard.ts's module doc comment) and is
|
|
6
|
+
* itself imported BY index.ts, so index.ts cannot be the source: `guard.ts -> index.ts ->
|
|
7
|
+
* guard.ts` would be circular. A one-constant leaf module has nothing to be circular with.
|
|
8
|
+
*/
|
|
9
|
+
export declare const VERSION = "0.3.0";
|
|
10
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* version.ts — the package version, as its own leaf module.
|
|
3
|
+
*
|
|
4
|
+
* guard.ts needs this (to attribute a guard-supplied `adapter.version` on a bare `check()` with
|
|
5
|
+
* no wrapper — see the "Execution binding" section of guard.ts's module doc comment) and is
|
|
6
|
+
* itself imported BY index.ts, so index.ts cannot be the source: `guard.ts -> index.ts ->
|
|
7
|
+
* guard.ts` would be circular. A one-constant leaf module has nothing to be circular with.
|
|
8
|
+
*/
|
|
9
|
+
export const VERSION = "0.3.0";
|
|
10
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
package/dist/esm/wire.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../src/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EASL,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../src/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EASL,KAAK,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;gBAEZ,MAAM,EAAE,MAAM,EAAE,OAAO,SAAK;CAKzC;AA4JD;;;;;GAKG;AACH,qBAAa,aAAa;IAEtB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE;IAClC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;IAClD,QAAQ,CAAC,aAAa,EAAE,SAAS;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM;gBAJnB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EACzC,aAAa,EAAE,SAAS,EACxB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM;IAG9B;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAE,OAAO,GAAG,IAAW,GAAG,QAAQ;CAG7D;AAED,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAC5C;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,IAAI,CAClB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,WAAgB,GACxB,aAAa,CAkKf"}
|
package/dist/esm/wire.js
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
import { createHash, createHmac, createPrivateKey, createPublicKey, generateKeyPairSync, sign as cryptoSign, timingSafeEqual, verify as cryptoVerify, } from "node:crypto";
|
|
30
30
|
import { TextDecoder } from "node:util";
|
|
31
31
|
import { Authority } from "./authority.js";
|
|
32
|
-
import { CanonicalizationError, DuplicateMemberError, NonFiniteNumberError, RawNumber, canonicalJson, parseJson, toPlain, } from "./canonical.js";
|
|
32
|
+
import { CanonicalizationError, DuplicateMemberError, NonFiniteNumberError, RawNumber, UnsafeIntegerError, canonicalJson, parseJson, toPlain, } from "./canonical.js";
|
|
33
33
|
import { ReasonCode } from "./reasons.js";
|
|
34
34
|
/**
|
|
35
35
|
* stdlib HMAC-SHA256 signer — the default for tests, examples and local dev,
|
|
@@ -294,6 +294,13 @@ function parseToken(token) {
|
|
|
294
294
|
if (e instanceof NonFiniteNumberError) {
|
|
295
295
|
throw new WireError(WireReasonCode.NON_FINITE, e.message);
|
|
296
296
|
}
|
|
297
|
+
// Mirrors non-finite handling above: an integer past the safe binary64
|
|
298
|
+
// range is a malformed claim, not merely a non-canonical byte form — it
|
|
299
|
+
// cannot be represented at all, safely, so it is rejected before
|
|
300
|
+
// verification rather than compared byte-for-byte.
|
|
301
|
+
if (e instanceof UnsafeIntegerError) {
|
|
302
|
+
throw new WireError(WireReasonCode.MALFORMED, e.message);
|
|
303
|
+
}
|
|
297
304
|
if (e instanceof CanonicalizationError) {
|
|
298
305
|
throw new WireError(WireReasonCode.NON_CANONICAL, e.message);
|
|
299
306
|
}
|