@o3co/auth.policy-verifier.cedar-wasm 0.11.0 → 0.13.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 +37 -0
- package/dist/wasmEngine.d.mts +9 -0
- package/dist/wasmEngine.d.mts.map +1 -1
- package/dist/wasmEngine.mjs +18 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @o3co/auth.policy-verifier.cedar-wasm
|
|
2
2
|
|
|
3
|
+
Last updated: 2026-09-23
|
|
4
|
+
|
|
3
5
|
The in-process Cedar engine for
|
|
4
6
|
[`@o3co/auth.policy-verifier.cedar`](../cedar/README.md): the official
|
|
5
7
|
[`@cedar-policy/cedar-wasm`](https://www.npmjs.com/package/@cedar-policy/cedar-wasm)
|
|
@@ -18,6 +20,41 @@ same choice out — that setting refuses to start when this package was not
|
|
|
18
20
|
imported, naming it. Nothing else about the collector's config changes with the
|
|
19
21
|
engine; see cedar's README for the whole of it.
|
|
20
22
|
|
|
23
|
+
It also vouches for the policy revision behind every answer
|
|
24
|
+
(`confirmsRevision`, #244): the set is compiled in this process, from the files
|
|
25
|
+
the revision was computed over, under an id nothing else holds — so an answer
|
|
26
|
+
cannot have come from any other policies. It is the engine
|
|
27
|
+
`requireConfirmedRevision = true` boots over; see cedar's [Policy
|
|
28
|
+
revision](../cedar/README.md#policy-revision-which-policies-decided).
|
|
29
|
+
|
|
30
|
+
## Responsibility
|
|
31
|
+
|
|
32
|
+
**Role.** One engine behind cedar's `CedarEngine` port
|
|
33
|
+
([`engine.mts`](../cedar/src/engine.mts)). It depends on
|
|
34
|
+
`@o3co/auth.policy-verifier.cedar` and on `@cedar-policy/cedar-wasm`. No
|
|
35
|
+
package in this repository depends on it (only the integration tests do); a
|
|
36
|
+
deployment imports it.
|
|
37
|
+
|
|
38
|
+
**Owns** ([`src/wasmEngine.mts`](src/wasmEngine.mts)):
|
|
39
|
+
|
|
40
|
+
- Parse-checking each policy file at boot, so a syntax error names its file,
|
|
41
|
+
and compiling the set once into wasm memory under an id minted per load.
|
|
42
|
+
- Evaluating each request against that compiled set, synchronously, and
|
|
43
|
+
rendering the bindings' answer as a `CedarDecision`.
|
|
44
|
+
- Naming the revision of the source it compiled on every answer.
|
|
45
|
+
- The exact version of `@cedar-policy/cedar-wasm`.
|
|
46
|
+
- Registering itself as `"wasm"` when imported
|
|
47
|
+
([`src/index.mts`](src/index.mts)).
|
|
48
|
+
|
|
49
|
+
**Does not own.** Policy loading, the policy revision itself, the
|
|
50
|
+
attribute-to-request mapping, what an answer means (the answer table,
|
|
51
|
+
`onNoDeterminingPolicy`, the revision check) and which engine is selected. All
|
|
52
|
+
of that is cedar's, and is identical whichever engine runs.
|
|
53
|
+
|
|
54
|
+
**Why a separate package.** The cost below: about 12 MB of wasm instantiated
|
|
55
|
+
on import. Kept out of cedar, it is carried only by a deployment that
|
|
56
|
+
evaluates in-process; one that runs cedar's `http` engine never loads it.
|
|
57
|
+
|
|
21
58
|
## What it costs, and when to choose it
|
|
22
59
|
|
|
23
60
|
The policy set is compiled once, at boot, into wasm memory; each request
|
package/dist/wasmEngine.d.mts
CHANGED
|
@@ -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":"
|
|
1
|
+
{"version":3,"file":"wasmEngine.d.mts","sourceRoot":"","sources":["../src/wasmEngine.mts"],"names":[],"mappings":"AAeA,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"}
|
package/dist/wasmEngine.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 1o1 Co. Ltd.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/*
|
|
4
|
+
* The `wasm` engine: evaluates the policy set in process through the official
|
|
5
|
+
* `@cedar-policy/cedar-wasm` bindings, compiling it once at load and answering
|
|
6
|
+
* synchronously. The package index registers it.
|
|
7
|
+
*/
|
|
3
8
|
import { checkParsePolicySet, preparsePolicySet, statefulIsAuthorized, } from "@cedar-policy/cedar-wasm/nodejs";
|
|
4
9
|
import { CedarEngineError, } from "@o3co/auth.policy-verifier.cedar";
|
|
5
10
|
/** The name this engine registers under, and the config value that selects it. */
|
|
@@ -19,10 +24,20 @@ let policySetCounter = 0;
|
|
|
19
24
|
* What this engine costs is paid at import: the wasm module (about 12 MB on
|
|
20
25
|
* disk) is instantiated when the bindings load. That is why it lives in its
|
|
21
26
|
* own package — a deployment that evaluates out of process never carries it.
|
|
27
|
+
*
|
|
28
|
+
* It vouches for the revision it evaluated (`confirmsRevision`, #244), and can:
|
|
29
|
+
* the set is compiled here, from the source `load` was handed, under an id
|
|
30
|
+
* minted here and known to nothing else. An answer through that id cannot have
|
|
31
|
+
* come from any other policies, so every answer names the revision of that
|
|
32
|
+
* source — read once, at `load`, beside the compile. `PolicySource` is a plain
|
|
33
|
+
* object the caller still holds; reading `source.revision` when answering would
|
|
34
|
+
* be reading "the current revision", which is a claim about the object and not
|
|
35
|
+
* about the policies that were compiled.
|
|
22
36
|
*/
|
|
23
37
|
export const cedarWasmEngine = {
|
|
24
38
|
name: CEDAR_WASM_ENGINE_NAME,
|
|
25
39
|
async: false,
|
|
40
|
+
confirmsRevision: true,
|
|
26
41
|
load(source) {
|
|
27
42
|
for (const file of source.files) {
|
|
28
43
|
const answer = checkParsePolicySet({ staticPolicies: file.text });
|
|
@@ -30,6 +45,8 @@ export const cedarWasmEngine = {
|
|
|
30
45
|
throw new CedarEngineError(`${file.source} failed to parse: ${details(answer.errors)}`);
|
|
31
46
|
}
|
|
32
47
|
}
|
|
48
|
+
// Captured with the compile below, not read per answer — see the doc comment.
|
|
49
|
+
const { revision } = source;
|
|
33
50
|
const policySetId = `auth.policy-verifier.cedar-wasm:${policySetCounter++}`;
|
|
34
51
|
const compiled = preparsePolicySet(policySetId, { staticPolicies: source.text });
|
|
35
52
|
if (compiled.type === "failure") {
|
|
@@ -47,6 +64,7 @@ export const cedarWasmEngine = {
|
|
|
47
64
|
decision,
|
|
48
65
|
reason: diagnostics.reason,
|
|
49
66
|
errors: diagnostics.errors.map((error) => `${error.policyId}: ${error.error.message}`),
|
|
67
|
+
revision,
|
|
50
68
|
};
|
|
51
69
|
},
|
|
52
70
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3co/auth.policy-verifier.cedar-wasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"directory": "packages/cedar-wasm"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@cedar-policy/cedar-wasm": "4.
|
|
29
|
-
"@o3co/auth.policy-verifier.cedar": "0.
|
|
28
|
+
"@cedar-policy/cedar-wasm": "4.13.0",
|
|
29
|
+
"@o3co/auth.policy-verifier.cedar": "0.13.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^26.
|
|
33
|
-
"@vitest/coverage-v8": "^5.0.
|
|
34
|
-
"vitest": "^5.0.
|
|
35
|
-
"@o3co/auth.policy-verifier.core": "0.
|
|
32
|
+
"@types/node": "^26.6.2",
|
|
33
|
+
"@vitest/coverage-v8": "^5.0.1",
|
|
34
|
+
"vitest": "^5.0.1",
|
|
35
|
+
"@o3co/auth.policy-verifier.core": "0.13.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"prebuild": "rimraf dist",
|