@o3co/auth.policy-verifier.cedar-wasm 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,6 +18,13 @@ same choice out — that setting refuses to start when this package was not
18
18
  imported, naming it. Nothing else about the collector's config changes with the
19
19
  engine; see cedar's README for the whole of it.
20
20
 
21
+ It also vouches for the policy revision behind every answer
22
+ (`confirmsRevision`, #244): the set is compiled in this process, from the files
23
+ the revision was computed over, under an id nothing else holds — so an answer
24
+ cannot have come from any other policies. It is the engine
25
+ `requireConfirmedRevision = true` boots over; see cedar's [Policy
26
+ revision](../cedar/README.md#policy-revision-which-policies-decided).
27
+
21
28
  ## What it costs, and when to choose it
22
29
 
23
30
  The policy set is compiled once, at boot, into wasm memory; each request
@@ -19,6 +19,15 @@ export interface CedarWasmEngine extends CedarEngine {
19
19
  * What this engine costs is paid at import: the wasm module (about 12 MB on
20
20
  * disk) is instantiated when the bindings load. That is why it lives in its
21
21
  * own package — a deployment that evaluates out of process never carries it.
22
+ *
23
+ * It vouches for the revision it evaluated (`confirmsRevision`, #244), and can:
24
+ * the set is compiled here, from the source `load` was handed, under an id
25
+ * minted here and known to nothing else. An answer through that id cannot have
26
+ * come from any other policies, so every answer names the revision of that
27
+ * source — read once, at `load`, beside the compile. `PolicySource` is a plain
28
+ * object the caller still holds; reading `source.revision` when answering would
29
+ * be reading "the current revision", which is a claim about the object and not
30
+ * about the policies that were compiled.
22
31
  */
23
32
  export declare const cedarWasmEngine: CedarWasmEngine;
24
33
  //# sourceMappingURL=wasmEngine.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wasmEngine.d.mts","sourceRoot":"","sources":["../src/wasmEngine.mts"],"names":[],"mappings":"AASA,OAAO,EAEN,KAAK,WAAW,EAGhB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,MAAM,kCAAkC,CAAC;AAE1C,kFAAkF;AAClF,eAAO,MAAM,sBAAsB,EAAG,MAAe,CAAC;AAEtD,oFAAoF;AACpF,MAAM,WAAW,eAAgB,SAAQ,WAAW;IACnD,QAAQ,CAAC,IAAI,EAAE,OAAO,sBAAsB,CAAC;IAC7C,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,kBAAkB,CAAC;CAC/C;AAKD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,EAAE,eAsC7B,CAAC"}
1
+ {"version":3,"file":"wasmEngine.d.mts","sourceRoot":"","sources":["../src/wasmEngine.mts"],"names":[],"mappings":"AASA,OAAO,EAEN,KAAK,WAAW,EAGhB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,MAAM,kCAAkC,CAAC;AAE1C,kFAAkF;AAClF,eAAO,MAAM,sBAAsB,EAAG,MAAe,CAAC;AAEtD,oFAAoF;AACpF,MAAM,WAAW,eAAgB,SAAQ,WAAW;IACnD,QAAQ,CAAC,IAAI,EAAE,OAAO,sBAAsB,CAAC;IAC7C,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,kBAAkB,CAAC;CAC/C;AAKD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,eAAe,EAAE,eA0C7B,CAAC"}
@@ -19,10 +19,20 @@ let policySetCounter = 0;
19
19
  * What this engine costs is paid at import: the wasm module (about 12 MB on
20
20
  * disk) is instantiated when the bindings load. That is why it lives in its
21
21
  * own package — a deployment that evaluates out of process never carries it.
22
+ *
23
+ * It vouches for the revision it evaluated (`confirmsRevision`, #244), and can:
24
+ * the set is compiled here, from the source `load` was handed, under an id
25
+ * minted here and known to nothing else. An answer through that id cannot have
26
+ * come from any other policies, so every answer names the revision of that
27
+ * source — read once, at `load`, beside the compile. `PolicySource` is a plain
28
+ * object the caller still holds; reading `source.revision` when answering would
29
+ * be reading "the current revision", which is a claim about the object and not
30
+ * about the policies that were compiled.
22
31
  */
23
32
  export const cedarWasmEngine = {
24
33
  name: CEDAR_WASM_ENGINE_NAME,
25
34
  async: false,
35
+ confirmsRevision: true,
26
36
  load(source) {
27
37
  for (const file of source.files) {
28
38
  const answer = checkParsePolicySet({ staticPolicies: file.text });
@@ -30,6 +40,8 @@ export const cedarWasmEngine = {
30
40
  throw new CedarEngineError(`${file.source} failed to parse: ${details(answer.errors)}`);
31
41
  }
32
42
  }
43
+ // Captured with the compile below, not read per answer — see the doc comment.
44
+ const { revision } = source;
33
45
  const policySetId = `auth.policy-verifier.cedar-wasm:${policySetCounter++}`;
34
46
  const compiled = preparsePolicySet(policySetId, { staticPolicies: source.text });
35
47
  if (compiled.type === "failure") {
@@ -47,6 +59,7 @@ export const cedarWasmEngine = {
47
59
  decision,
48
60
  reason: diagnostics.reason,
49
61
  errors: diagnostics.errors.map((error) => `${error.policyId}: ${error.error.message}`),
62
+ revision,
50
63
  };
51
64
  },
52
65
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3co/auth.policy-verifier.cedar-wasm",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -26,13 +26,13 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@cedar-policy/cedar-wasm": "4.12.0",
29
- "@o3co/auth.policy-verifier.cedar": "0.10.0"
29
+ "@o3co/auth.policy-verifier.cedar": "0.12.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^26.5.1",
33
33
  "@vitest/coverage-v8": "^5.0.0",
34
34
  "vitest": "^5.0.0",
35
- "@o3co/auth.policy-verifier.core": "0.10.0"
35
+ "@o3co/auth.policy-verifier.core": "0.12.0"
36
36
  },
37
37
  "scripts": {
38
38
  "prebuild": "rimraf dist",