@coderifts/agent-guard 10.0.0 → 11.0.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/dist/cjs/enforcement-gate.d.ts +22 -2
- package/dist/cjs/enforcement-gate.d.ts.map +1 -1
- package/dist/cjs/enforcement-gate.js +23 -6
- package/dist/cjs/enforcement-gate.js.map +1 -1
- package/dist/esm/enforcement-gate.d.ts +22 -2
- package/dist/esm/enforcement-gate.d.ts.map +1 -1
- package/dist/esm/enforcement-gate.js +23 -6
- package/dist/esm/enforcement-gate.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,11 +14,31 @@
|
|
|
14
14
|
* itself; receipt-binding authenticates the envelope the decision rides on.
|
|
15
15
|
*/
|
|
16
16
|
import type { IntegrityCause, Artifact } from './types.js';
|
|
17
|
+
import { type BundleFingerprintContext } from './execution-time-fingerprint.js';
|
|
17
18
|
type Action = 'CONTINUE' | 'CONTINUE_WITH_MONITORING' | 'REQUEST_APPROVAL' | 'STOP';
|
|
18
19
|
/** Local artifact_digest — byte-identical to the server change-set.js algorithm (sorted by type,id). */
|
|
19
20
|
export declare function computeArtifactDigest(artifacts: Artifact[]): string;
|
|
20
|
-
/**
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Local crbundle.v1 bundle fingerprint — byte-identical to the server producer
|
|
23
|
+
* (coderifts-app change-set.js computeBundleFingerprint).
|
|
24
|
+
*
|
|
25
|
+
* THIS WAS WRONG AND SHIPPED WRONG. Until now this function took only `artifacts` and built its
|
|
26
|
+
* OWN preimage, which omitted two elements the server includes: the artifact COUNT, and the whole
|
|
27
|
+
* trailing context block (operation, environment, repository, branch, pull_request,
|
|
28
|
+
* policy_profile). On identical inputs it returned sha256:1a0e7470… where the server returned
|
|
29
|
+
* sha256:049650f2… — so any third party who used it to check a receipt's `fp` against their own
|
|
30
|
+
* change set got a mismatch, with nothing to tell them the verifier was at fault rather than the
|
|
31
|
+
* receipt. A verifier that is quietly wrong is worse than one that is honestly absent.
|
|
32
|
+
*
|
|
33
|
+
* The root cause was a SECOND PREIMAGE in this package: execution-time-fingerprint.ts already
|
|
34
|
+
* carried a faithful mirror, under the comment "Do NOT invent a second preimage". This function
|
|
35
|
+
* was that second preimage. It is now a thin delegation, so the package has exactly one.
|
|
36
|
+
*
|
|
37
|
+
* `context` is optional to keep the call signature source-compatible, but omitting it produces a
|
|
38
|
+
* DIFFERENT (and, for any request that carried a context, still non-matching) digest — the server
|
|
39
|
+
* folds the context in unconditionally. Pass the same context you sent with the request.
|
|
40
|
+
*/
|
|
41
|
+
export declare function computeBundleFingerprint(artifacts: Artifact[], context?: BundleFingerprintContext | null): string;
|
|
22
42
|
export type GateResult = {
|
|
23
43
|
verdict: 'allow';
|
|
24
44
|
kind: 'ALLOW' | 'MONITOR';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforcement-gate.d.ts","sourceRoot":"","sources":["../../src/enforcement-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"enforcement-gate.d.ts","sourceRoot":"","sources":["../../src/enforcement-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,iCAAiC,CAAC;AAGzC,KAAK,MAAM,GAAG,UAAU,GAAG,0BAA0B,GAAG,kBAAkB,GAAG,MAAM,CAAC;AAoBpF,wGAAwG;AACxG,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAMnE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,QAAQ,EAAE,EACrB,OAAO,CAAC,EAAE,wBAAwB,GAAG,IAAI,GACxC,MAAM,CAER;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,GAC/C;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB,CAAA;CAAE,GACnE;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,cAAc,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,eAAe,EAAE,MAAM,GAAG,MAAM,EAChC,aAAa,EAAE,QAAQ,EAAE,GACxB,UAAU,CAqEZ"}
|
|
@@ -19,6 +19,7 @@ exports.computeArtifactDigest = computeArtifactDigest;
|
|
|
19
19
|
exports.computeBundleFingerprint = computeBundleFingerprint;
|
|
20
20
|
exports.evaluateEnvelope = evaluateEnvelope;
|
|
21
21
|
const node_crypto_1 = require("node:crypto");
|
|
22
|
+
const execution_time_fingerprint_js_1 = require("./execution-time-fingerprint.js");
|
|
22
23
|
const DECISION_RANK = { ALLOW: 0, WARN: 1, REQUIRE_APPROVAL: 2, BLOCK: 3 };
|
|
23
24
|
const ACTION_TO_DECISION = {
|
|
24
25
|
CONTINUE: 'ALLOW', CONTINUE_WITH_MONITORING: 'WARN', REQUEST_APPROVAL: 'REQUIRE_APPROVAL', STOP: 'BLOCK',
|
|
@@ -43,12 +44,28 @@ function computeArtifactDigest(artifacts) {
|
|
|
43
44
|
.join(NUL);
|
|
44
45
|
return `sha256:${sha256hex(preimage)}`;
|
|
45
46
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Local crbundle.v1 bundle fingerprint — byte-identical to the server producer
|
|
49
|
+
* (coderifts-app change-set.js computeBundleFingerprint).
|
|
50
|
+
*
|
|
51
|
+
* THIS WAS WRONG AND SHIPPED WRONG. Until now this function took only `artifacts` and built its
|
|
52
|
+
* OWN preimage, which omitted two elements the server includes: the artifact COUNT, and the whole
|
|
53
|
+
* trailing context block (operation, environment, repository, branch, pull_request,
|
|
54
|
+
* policy_profile). On identical inputs it returned sha256:1a0e7470… where the server returned
|
|
55
|
+
* sha256:049650f2… — so any third party who used it to check a receipt's `fp` against their own
|
|
56
|
+
* change set got a mismatch, with nothing to tell them the verifier was at fault rather than the
|
|
57
|
+
* receipt. A verifier that is quietly wrong is worse than one that is honestly absent.
|
|
58
|
+
*
|
|
59
|
+
* The root cause was a SECOND PREIMAGE in this package: execution-time-fingerprint.ts already
|
|
60
|
+
* carried a faithful mirror, under the comment "Do NOT invent a second preimage". This function
|
|
61
|
+
* was that second preimage. It is now a thin delegation, so the package has exactly one.
|
|
62
|
+
*
|
|
63
|
+
* `context` is optional to keep the call signature source-compatible, but omitting it produces a
|
|
64
|
+
* DIFFERENT (and, for any request that carried a context, still non-matching) digest — the server
|
|
65
|
+
* folds the context in unconditionally. Pass the same context you sent with the request.
|
|
66
|
+
*/
|
|
67
|
+
function computeBundleFingerprint(artifacts, context) {
|
|
68
|
+
return (0, execution_time_fingerprint_js_1.computeCanonicalBundleFingerprint)(artifacts, context);
|
|
52
69
|
}
|
|
53
70
|
/**
|
|
54
71
|
* Reconcile an envelope's decision fail-closed. Order:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforcement-gate.js","sourceRoot":"","sources":["../../src/enforcement-gate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;
|
|
1
|
+
{"version":3,"file":"enforcement-gate.js","sourceRoot":"","sources":["../../src/enforcement-gate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AA+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,qBAAqB,CAAC,aAAa,CAAC,EAAE,CAAC;QACzE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,+DAA+D,EAAE,CAAC;IACzI,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACjF,CAAC"}
|
|
@@ -14,11 +14,31 @@
|
|
|
14
14
|
* itself; receipt-binding authenticates the envelope the decision rides on.
|
|
15
15
|
*/
|
|
16
16
|
import type { IntegrityCause, Artifact } from './types.js';
|
|
17
|
+
import { type BundleFingerprintContext } from './execution-time-fingerprint.js';
|
|
17
18
|
type Action = 'CONTINUE' | 'CONTINUE_WITH_MONITORING' | 'REQUEST_APPROVAL' | 'STOP';
|
|
18
19
|
/** Local artifact_digest — byte-identical to the server change-set.js algorithm (sorted by type,id). */
|
|
19
20
|
export declare function computeArtifactDigest(artifacts: Artifact[]): string;
|
|
20
|
-
/**
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Local crbundle.v1 bundle fingerprint — byte-identical to the server producer
|
|
23
|
+
* (coderifts-app change-set.js computeBundleFingerprint).
|
|
24
|
+
*
|
|
25
|
+
* THIS WAS WRONG AND SHIPPED WRONG. Until now this function took only `artifacts` and built its
|
|
26
|
+
* OWN preimage, which omitted two elements the server includes: the artifact COUNT, and the whole
|
|
27
|
+
* trailing context block (operation, environment, repository, branch, pull_request,
|
|
28
|
+
* policy_profile). On identical inputs it returned sha256:1a0e7470… where the server returned
|
|
29
|
+
* sha256:049650f2… — so any third party who used it to check a receipt's `fp` against their own
|
|
30
|
+
* change set got a mismatch, with nothing to tell them the verifier was at fault rather than the
|
|
31
|
+
* receipt. A verifier that is quietly wrong is worse than one that is honestly absent.
|
|
32
|
+
*
|
|
33
|
+
* The root cause was a SECOND PREIMAGE in this package: execution-time-fingerprint.ts already
|
|
34
|
+
* carried a faithful mirror, under the comment "Do NOT invent a second preimage". This function
|
|
35
|
+
* was that second preimage. It is now a thin delegation, so the package has exactly one.
|
|
36
|
+
*
|
|
37
|
+
* `context` is optional to keep the call signature source-compatible, but omitting it produces a
|
|
38
|
+
* DIFFERENT (and, for any request that carried a context, still non-matching) digest — the server
|
|
39
|
+
* folds the context in unconditionally. Pass the same context you sent with the request.
|
|
40
|
+
*/
|
|
41
|
+
export declare function computeBundleFingerprint(artifacts: Artifact[], context?: BundleFingerprintContext | null): string;
|
|
22
42
|
export type GateResult = {
|
|
23
43
|
verdict: 'allow';
|
|
24
44
|
kind: 'ALLOW' | 'MONITOR';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforcement-gate.d.ts","sourceRoot":"","sources":["../../src/enforcement-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"enforcement-gate.d.ts","sourceRoot":"","sources":["../../src/enforcement-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,iCAAiC,CAAC;AAGzC,KAAK,MAAM,GAAG,UAAU,GAAG,0BAA0B,GAAG,kBAAkB,GAAG,MAAM,CAAC;AAoBpF,wGAAwG;AACxG,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAMnE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,QAAQ,EAAE,EACrB,OAAO,CAAC,EAAE,wBAAwB,GAAG,IAAI,GACxC,MAAM,CAER;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,GAC/C;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB,CAAA;CAAE,GACnE;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,cAAc,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,eAAe,EAAE,MAAM,GAAG,MAAM,EAChC,aAAa,EAAE,QAAQ,EAAE,GACxB,UAAU,CAqEZ"}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* itself; receipt-binding authenticates the envelope the decision rides on.
|
|
15
15
|
*/
|
|
16
16
|
import { createHash } from 'node:crypto';
|
|
17
|
+
import { computeCanonicalBundleFingerprint, } from './execution-time-fingerprint.js';
|
|
17
18
|
const DECISION_RANK = { ALLOW: 0, WARN: 1, REQUIRE_APPROVAL: 2, BLOCK: 3 };
|
|
18
19
|
const ACTION_TO_DECISION = {
|
|
19
20
|
CONTINUE: 'ALLOW', CONTINUE_WITH_MONITORING: 'WARN', REQUEST_APPROVAL: 'REQUIRE_APPROVAL', STOP: 'BLOCK',
|
|
@@ -38,12 +39,28 @@ export function computeArtifactDigest(artifacts) {
|
|
|
38
39
|
.join(NUL);
|
|
39
40
|
return `sha256:${sha256hex(preimage)}`;
|
|
40
41
|
}
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Local crbundle.v1 bundle fingerprint — byte-identical to the server producer
|
|
44
|
+
* (coderifts-app change-set.js computeBundleFingerprint).
|
|
45
|
+
*
|
|
46
|
+
* THIS WAS WRONG AND SHIPPED WRONG. Until now this function took only `artifacts` and built its
|
|
47
|
+
* OWN preimage, which omitted two elements the server includes: the artifact COUNT, and the whole
|
|
48
|
+
* trailing context block (operation, environment, repository, branch, pull_request,
|
|
49
|
+
* policy_profile). On identical inputs it returned sha256:1a0e7470… where the server returned
|
|
50
|
+
* sha256:049650f2… — so any third party who used it to check a receipt's `fp` against their own
|
|
51
|
+
* change set got a mismatch, with nothing to tell them the verifier was at fault rather than the
|
|
52
|
+
* receipt. A verifier that is quietly wrong is worse than one that is honestly absent.
|
|
53
|
+
*
|
|
54
|
+
* The root cause was a SECOND PREIMAGE in this package: execution-time-fingerprint.ts already
|
|
55
|
+
* carried a faithful mirror, under the comment "Do NOT invent a second preimage". This function
|
|
56
|
+
* was that second preimage. It is now a thin delegation, so the package has exactly one.
|
|
57
|
+
*
|
|
58
|
+
* `context` is optional to keep the call signature source-compatible, but omitting it produces a
|
|
59
|
+
* DIFFERENT (and, for any request that carried a context, still non-matching) digest — the server
|
|
60
|
+
* folds the context in unconditionally. Pass the same context you sent with the request.
|
|
61
|
+
*/
|
|
62
|
+
export function computeBundleFingerprint(artifacts, context) {
|
|
63
|
+
return computeCanonicalBundleFingerprint(artifacts, context);
|
|
47
64
|
}
|
|
48
65
|
/**
|
|
49
66
|
* Reconcile an envelope's decision fail-closed. Order:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforcement-gate.js","sourceRoot":"","sources":["../../src/enforcement-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"enforcement-gate.js","sourceRoot":"","sources":["../../src/enforcement-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,iCAAiC,GAElC,MAAM,iCAAiC,CAAC;AAKzC,MAAM,aAAa,GA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,mBAAmB,EAAE,MAAM,EAAE,+DAA+D,EAAE,CAAC;IACzI,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACjF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderifts/agent-guard",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Fail-closed guard for AI agent tool calls — preflight contract changes before they execute. Security core frozen (agent-guard-api v1.0); v1.1 adds client-side enforcement: receipt→envelope binding, decision↔action reconciliation, safe_for_agent + degraded fail-closed, and enforced⟺executed (P0 client-enforcement pack).",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|