@intentius/chant-lexicon-cedar 0.44.8
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 +190 -0
- package/dist/avp/ambient.d.ts +54 -0
- package/dist/avp/ambient.d.ts.map +1 -0
- package/dist/avp/client.d.ts +127 -0
- package/dist/avp/client.d.ts.map +1 -0
- package/dist/avp/describe-resources.d.ts +42 -0
- package/dist/avp/describe-resources.d.ts.map +1 -0
- package/dist/avp/embed.d.ts +120 -0
- package/dist/avp/embed.d.ts.map +1 -0
- package/dist/avp/live-export.d.ts +94 -0
- package/dist/avp/live-export.d.ts.map +1 -0
- package/dist/avp/ownership.d.ts +97 -0
- package/dist/avp/ownership.d.ts.map +1 -0
- package/dist/avp/statement.d.ts +22 -0
- package/dist/avp/statement.d.ts.map +1 -0
- package/dist/avp/store.d.ts +82 -0
- package/dist/avp/store.d.ts.map +1 -0
- package/dist/avp/testdata/mock-transport.d.ts +55 -0
- package/dist/avp/testdata/mock-transport.d.ts.map +1 -0
- package/dist/codegen/docs-cli.d.ts +3 -0
- package/dist/codegen/docs-cli.d.ts.map +1 -0
- package/dist/codegen/docs.d.ts +26 -0
- package/dist/codegen/docs.d.ts.map +1 -0
- package/dist/codegen/emit.d.ts +85 -0
- package/dist/codegen/emit.d.ts.map +1 -0
- package/dist/codegen/generate-cli.d.ts +3 -0
- package/dist/codegen/generate-cli.d.ts.map +1 -0
- package/dist/codegen/generate.d.ts +37 -0
- package/dist/codegen/generate.d.ts.map +1 -0
- package/dist/codegen/naming.d.ts +48 -0
- package/dist/codegen/naming.d.ts.map +1 -0
- package/dist/codegen/package.d.ts +10 -0
- package/dist/codegen/package.d.ts.map +1 -0
- package/dist/composites/deny-by-default-set.d.ts +58 -0
- package/dist/composites/deny-by-default-set.d.ts.map +1 -0
- package/dist/composites/index.d.ts +12 -0
- package/dist/composites/index.d.ts.map +1 -0
- package/dist/composites/owner-can-manage.d.ts +48 -0
- package/dist/composites/owner-can-manage.d.ts.map +1 -0
- package/dist/config.d.ts +102 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/coverage.d.ts +59 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/detect.d.ts +18 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/generated/index.d.ts +251 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/runtime.d.ts +2 -0
- package/dist/generated/runtime.d.ts.map +1 -0
- package/dist/import/adapter.d.ts +21 -0
- package/dist/import/adapter.d.ts.map +1 -0
- package/dist/import/clause-text.d.ts +38 -0
- package/dist/import/clause-text.d.ts.map +1 -0
- package/dist/import/generator.d.ts +53 -0
- package/dist/import/generator.d.ts.map +1 -0
- package/dist/import/parser.d.ts +57 -0
- package/dist/import/parser.d.ts.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/init-templates.d.ts +32 -0
- package/dist/init-templates.d.ts.map +1 -0
- package/dist/integrity.json +22 -0
- package/dist/lint/audit-catalog.d.ts +29 -0
- package/dist/lint/audit-catalog.d.ts.map +1 -0
- package/dist/lint/post-synth/cedar-helpers.d.ts +97 -0
- package/dist/lint/post-synth/cedar-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/cedc010.d.ts +17 -0
- package/dist/lint/post-synth/cedc010.d.ts.map +1 -0
- package/dist/lint/post-synth/cedc011.d.ts +17 -0
- package/dist/lint/post-synth/cedc011.d.ts.map +1 -0
- package/dist/lint/post-synth/cedc012.d.ts +21 -0
- package/dist/lint/post-synth/cedc012.d.ts.map +1 -0
- package/dist/lint/post-synth/cedc013.d.ts +20 -0
- package/dist/lint/post-synth/cedc013.d.ts.map +1 -0
- package/dist/lint/post-synth/cedc014.d.ts +19 -0
- package/dist/lint/post-synth/cedc014.d.ts.map +1 -0
- package/dist/lint/post-synth/cede010.d.ts +34 -0
- package/dist/lint/post-synth/cede010.d.ts.map +1 -0
- package/dist/lint/post-synth/cede011.d.ts +22 -0
- package/dist/lint/post-synth/cede011.d.ts.map +1 -0
- package/dist/lint/post-synth/ceds010.d.ts +24 -0
- package/dist/lint/post-synth/ceds010.d.ts.map +1 -0
- package/dist/lint/post-synth/ceds011.d.ts +19 -0
- package/dist/lint/post-synth/ceds011.d.ts.map +1 -0
- package/dist/lint/post-synth/ceds012.d.ts +17 -0
- package/dist/lint/post-synth/ceds012.d.ts.map +1 -0
- package/dist/lint/post-synth/index.d.ts +3 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -0
- package/dist/lint/post-synth/wasm-helpers.d.ts +108 -0
- package/dist/lint/post-synth/wasm-helpers.d.ts.map +1 -0
- package/dist/lint/rules/index.d.ts +10 -0
- package/dist/lint/rules/index.d.ts.map +1 -0
- package/dist/lint/rules/policy-shape.d.ts +31 -0
- package/dist/lint/rules/policy-shape.d.ts.map +1 -0
- package/dist/lsp/completions.d.ts +24 -0
- package/dist/lsp/completions.d.ts.map +1 -0
- package/dist/lsp/hover.d.ts +11 -0
- package/dist/lsp/hover.d.ts.map +1 -0
- package/dist/lsp/registry.d.ts +45 -0
- package/dist/lsp/registry.d.ts.map +1 -0
- package/dist/manifest.json +8 -0
- package/dist/mcp/index.d.ts +34 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/policy-coverage.d.ts +81 -0
- package/dist/mcp/policy-coverage.d.ts.map +1 -0
- package/dist/meta.json +699 -0
- package/dist/okf/index.md +37 -0
- package/dist/okf/rules/CEDC001.md +11 -0
- package/dist/okf/rules/CEDC010.md +11 -0
- package/dist/okf/rules/CEDC011.md +15 -0
- package/dist/okf/rules/CEDC012.md +11 -0
- package/dist/okf/rules/CEDC013.md +15 -0
- package/dist/okf/rules/CEDC014.md +15 -0
- package/dist/okf/rules/CEDE010.md +15 -0
- package/dist/okf/rules/CEDE011.md +15 -0
- package/dist/okf/rules/CEDS010.md +15 -0
- package/dist/okf/rules/CEDS011.md +11 -0
- package/dist/okf/rules/CEDS012.md +15 -0
- package/dist/okf/types/AdminAction.md +14 -0
- package/dist/okf/types/Application.md +14 -0
- package/dist/okf/types/ApproveAction.md +13 -0
- package/dist/okf/types/CommentAction.md +14 -0
- package/dist/okf/types/CreateAction.md +14 -0
- package/dist/okf/types/DeleteAction.md +14 -0
- package/dist/okf/types/Document.md +18 -0
- package/dist/okf/types/Folder.md +15 -0
- package/dist/okf/types/Group.md +14 -0
- package/dist/okf/types/ListAction.md +14 -0
- package/dist/okf/types/Policy.md +29 -0
- package/dist/okf/types/ReadAction.md +14 -0
- package/dist/okf/types/ServiceAccount.md +15 -0
- package/dist/okf/types/ShareAction.md +14 -0
- package/dist/okf/types/Team.md +14 -0
- package/dist/okf/types/User.md +18 -0
- package/dist/okf/types/WriteAction.md +14 -0
- package/dist/package-cli.d.ts +3 -0
- package/dist/package-cli.d.ts.map +1 -0
- package/dist/plugin.d.ts +8 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/rules/cedar-helpers.ts +209 -0
- package/dist/rules/cedc010.ts +80 -0
- package/dist/rules/cedc011.ts +47 -0
- package/dist/rules/cedc012.ts +64 -0
- package/dist/rules/cedc013.ts +68 -0
- package/dist/rules/cedc014.ts +73 -0
- package/dist/rules/cede010.ts +89 -0
- package/dist/rules/cede011.ts +58 -0
- package/dist/rules/ceds010.ts +57 -0
- package/dist/rules/ceds011.ts +42 -0
- package/dist/rules/ceds012.ts +50 -0
- package/dist/rules/policy-shape.ts +148 -0
- package/dist/rules/wasm-helpers.ts +315 -0
- package/dist/serializer.d.ts +138 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/spec/fetch.d.ts +71 -0
- package/dist/spec/fetch.d.ts.map +1 -0
- package/dist/spec/parse.d.ts +113 -0
- package/dist/spec/parse.d.ts.map +1 -0
- package/dist/spec/pin.d.ts +116 -0
- package/dist/spec/pin.d.ts.map +1 -0
- package/dist/spec/pinned-names.json +18 -0
- package/dist/spec/wasm.d.ts +143 -0
- package/dist/spec/wasm.d.ts.map +1 -0
- package/dist/types/index.d.ts +219 -0
- package/dist/validate-cli.d.ts +3 -0
- package/dist/validate-cli.d.ts.map +1 -0
- package/dist/validate.d.ts +25 -0
- package/dist/validate.d.ts.map +1 -0
- package/package.json +75 -0
- package/src/avp/OWNERSHIP.md +125 -0
- package/src/avp/ambient.test.ts +113 -0
- package/src/avp/ambient.ts +124 -0
- package/src/avp/client.ts +310 -0
- package/src/avp/describe-resources.test.ts +316 -0
- package/src/avp/describe-resources.ts +215 -0
- package/src/avp/embed.test.ts +114 -0
- package/src/avp/embed.ts +190 -0
- package/src/avp/live-export.test.ts +232 -0
- package/src/avp/live-export.ts +185 -0
- package/src/avp/ownership.test.ts +101 -0
- package/src/avp/ownership.ts +170 -0
- package/src/avp/statement.ts +50 -0
- package/src/avp/store.ts +152 -0
- package/src/avp/testdata/mock-transport.ts +147 -0
- package/src/codegen/docs-cli.ts +7 -0
- package/src/codegen/docs.ts +873 -0
- package/src/codegen/emit.ts +496 -0
- package/src/codegen/generate-cli.ts +18 -0
- package/src/codegen/generate.test.ts +128 -0
- package/src/codegen/generate.ts +123 -0
- package/src/codegen/naming.ts +101 -0
- package/src/codegen/package.ts +52 -0
- package/src/composites/composites.test.ts +206 -0
- package/src/composites/deny-by-default-set.ts +98 -0
- package/src/composites/index.ts +13 -0
- package/src/composites/owner-can-manage.ts +80 -0
- package/src/config-namespace.test.ts +44 -0
- package/src/config.test.ts +82 -0
- package/src/config.ts +119 -0
- package/src/coverage.test.ts +61 -0
- package/src/coverage.ts +166 -0
- package/src/detect.test.ts +64 -0
- package/src/detect.ts +59 -0
- package/src/generated/index.d.ts +219 -0
- package/src/generated/index.ts +279 -0
- package/src/generated/lexicon-cedar.json +699 -0
- package/src/generated/runtime.ts +2 -0
- package/src/import/adapter.ts +63 -0
- package/src/import/clause-text.ts +178 -0
- package/src/import/generator.test.ts +133 -0
- package/src/import/generator.ts +219 -0
- package/src/import/parser.test.ts +265 -0
- package/src/import/parser.ts +352 -0
- package/src/import/roundtrip.test.ts +127 -0
- package/src/import/testdata/full.cedar +36 -0
- package/src/import/testdata/full.cedar.json +238 -0
- package/src/import/testdata/realistic.cedar +35 -0
- package/src/import/testdata/simple.cedar +6 -0
- package/src/index.ts +94 -0
- package/src/init-templates.test.ts +158 -0
- package/src/init-templates.ts +358 -0
- package/src/lint/audit-catalog.ts +130 -0
- package/src/lint/post-synth/cedar-helpers.ts +209 -0
- package/src/lint/post-synth/cedc010.ts +80 -0
- package/src/lint/post-synth/cedc011.ts +47 -0
- package/src/lint/post-synth/cedc012.ts +64 -0
- package/src/lint/post-synth/cedc013.ts +68 -0
- package/src/lint/post-synth/cedc014.ts +73 -0
- package/src/lint/post-synth/cede010.ts +89 -0
- package/src/lint/post-synth/cede011.ts +58 -0
- package/src/lint/post-synth/ceds010.ts +57 -0
- package/src/lint/post-synth/ceds011.ts +42 -0
- package/src/lint/post-synth/ceds012.ts +50 -0
- package/src/lint/post-synth/index.ts +25 -0
- package/src/lint/post-synth/post-synth.test.ts +474 -0
- package/src/lint/post-synth/wasm-helpers.ts +315 -0
- package/src/lint/rules/index.ts +12 -0
- package/src/lint/rules/policy-shape.test.ts +90 -0
- package/src/lint/rules/policy-shape.ts +148 -0
- package/src/lsp/completions.test.ts +111 -0
- package/src/lsp/completions.ts +55 -0
- package/src/lsp/hover.test.ts +82 -0
- package/src/lsp/hover.ts +75 -0
- package/src/lsp/registry.ts +74 -0
- package/src/mcp/index.ts +103 -0
- package/src/mcp/policy-coverage.test.ts +176 -0
- package/src/mcp/policy-coverage.ts +205 -0
- package/src/package-cli.ts +22 -0
- package/src/plugin.test.ts +115 -0
- package/src/plugin.ts +312 -0
- package/src/serializer.test.ts +502 -0
- package/src/serializer.ts +335 -0
- package/src/skills/chant-cedar-authoring.md +180 -0
- package/src/skills/chant-cedar-avp-embedding.md +125 -0
- package/src/skills/chant-cedar-meta-policy.md +119 -0
- package/src/spec/default-schema.cedarschema +108 -0
- package/src/spec/fetch.ts +107 -0
- package/src/spec/parse.test.ts +123 -0
- package/src/spec/parse.ts +253 -0
- package/src/spec/pin.test.ts +88 -0
- package/src/spec/pin.ts +243 -0
- package/src/spec/pinned-names.json +18 -0
- package/src/spec/wasm.ts +283 -0
- package/src/validate-cli.ts +8 -0
- package/src/validate.ts +85 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ownership channel for Amazon Verified Permissions (#1652).
|
|
3
|
+
*
|
|
4
|
+
* AVP is the one target in chant where the obvious channel does not exist. A
|
|
5
|
+
* policy *store* is taggable — `TagResource` takes the same key/value map every
|
|
6
|
+
* other AWS resource does. An individual policy is not: `CreatePolicy` accepts
|
|
7
|
+
* a policy store id, a definition, and a client token, and there is no tag
|
|
8
|
+
* surface on it at all. So the store-level tags can say "this store is chant's"
|
|
9
|
+
* and nothing native can say "this policy is chant's" — which is the granularity
|
|
10
|
+
* `delete` needs, because a store holds policies from more than one source the
|
|
11
|
+
* moment somebody uses the console.
|
|
12
|
+
*
|
|
13
|
+
* The one durable, writable, readable per-policy field AVP has is
|
|
14
|
+
* `Definition.Static.Description`. That is the channel: chant's marker is
|
|
15
|
+
* encoded into a trailing bracketed segment of the description, ahead of which
|
|
16
|
+
* the author's own text is preserved. It is read back on `describeResources`
|
|
17
|
+
* and on `exportResources`, which is exactly what `ownershipChannel.reads`
|
|
18
|
+
* declares (chant #1348) — no third path claims a verdict it cannot resolve.
|
|
19
|
+
*
|
|
20
|
+
* See ./OWNERSHIP.md for the design record, including what this channel costs
|
|
21
|
+
* and the two alternatives that were rejected.
|
|
22
|
+
*/
|
|
23
|
+
import type { ChannelKeys, OwnershipMarker } from "@intentius/chant/ownership";
|
|
24
|
+
/**
|
|
25
|
+
* The marker keys, shared by both AVP channels.
|
|
26
|
+
*
|
|
27
|
+
* The same three names serve the store's tag map and the per-policy description
|
|
28
|
+
* marker, because `ownershipChannel` declares one {@link ChannelKeys} and a
|
|
29
|
+
* lexicon whose two channels disagreed on key names would be two conventions
|
|
30
|
+
* wearing one declaration. AWS tag keys permit `:`, and the description
|
|
31
|
+
* encoding below quotes its values, so neither channel constrains the other.
|
|
32
|
+
*/
|
|
33
|
+
export declare const AVP_OWNERSHIP_KEYS: ChannelKeys;
|
|
34
|
+
/**
|
|
35
|
+
* The Cedar policy id this AVP policy carries, recorded beside the marker.
|
|
36
|
+
*
|
|
37
|
+
* Deliberately *not* part of {@link AVP_OWNERSHIP_KEYS}: it is not an ownership
|
|
38
|
+
* claim and `hasOwnershipMarker` must not consult it. It is here because
|
|
39
|
+
* `ListPolicies` returns descriptions but not statements, so without it every
|
|
40
|
+
* live policy needs a second `GetPolicy` round trip just to learn which chant
|
|
41
|
+
* entity it belongs to.
|
|
42
|
+
*/
|
|
43
|
+
export declare const AVP_POLICY_ID_KEY = "chant:policy-id";
|
|
44
|
+
/**
|
|
45
|
+
* AVP caps `Definition.Static.Description` at 150 characters.
|
|
46
|
+
*
|
|
47
|
+
* The marker is what makes a policy deletable, so when the author's own text
|
|
48
|
+
* plus the marker exceed the cap, the *text* is truncated and the marker is
|
|
49
|
+
* kept whole. Silently dropping the marker would turn an owned policy into a
|
|
50
|
+
* foreign one, and a foreign policy is never deleted — the estate would grow
|
|
51
|
+
* undeletable policies with no error anywhere.
|
|
52
|
+
*/
|
|
53
|
+
export declare const AVP_DESCRIPTION_MAX = 150;
|
|
54
|
+
/** What {@link decodeOwnershipDescription} recovers from a live description. */
|
|
55
|
+
export interface DecodedDescription {
|
|
56
|
+
/** The author's own description, marker segment removed. */
|
|
57
|
+
text: string;
|
|
58
|
+
/** Marker entries, keyed by {@link AVP_OWNERSHIP_KEYS} names, for the core ownership helpers. */
|
|
59
|
+
tags: Record<string, string>;
|
|
60
|
+
/** The Cedar policy id the marker recorded, when it carried one. */
|
|
61
|
+
policyId?: string;
|
|
62
|
+
/** Whether a marker segment was present at all. */
|
|
63
|
+
marked: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Encode the marker into a description.
|
|
67
|
+
*
|
|
68
|
+
* Values are percent-encoded, so a stack named `my stack` or an id holding a
|
|
69
|
+
* `]` round-trips instead of corrupting the segment. Reversed by
|
|
70
|
+
* {@link decodeOwnershipDescription}.
|
|
71
|
+
*/
|
|
72
|
+
export declare function encodeOwnershipDescription(text: string | undefined, marker: OwnershipMarker, policyId?: string): string;
|
|
73
|
+
/** Recover the author's text and chant's marker from a live description. */
|
|
74
|
+
export declare function decodeOwnershipDescription(description: string | undefined): DecodedDescription;
|
|
75
|
+
/**
|
|
76
|
+
* The per-policy verdict, read off a live description.
|
|
77
|
+
*
|
|
78
|
+
* Two-valued on purpose: this function is only ever called where the
|
|
79
|
+
* description was actually read, and `unknown` is reserved for the paths that
|
|
80
|
+
* could not read it at all (the contract in core's `ownership.ts`).
|
|
81
|
+
*/
|
|
82
|
+
export declare function ownershipFromDescription(description: string | undefined): "owned" | "foreign";
|
|
83
|
+
/** True when a live description carries chant's marker. */
|
|
84
|
+
export declare function descriptionIsOwned(description: string | undefined): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* The store-level verdict, read off a policy store's tag map.
|
|
87
|
+
*
|
|
88
|
+
* The coarse channel: it answers "is this store chant's" and says nothing about
|
|
89
|
+
* any individual policy in it. Kept separate from
|
|
90
|
+
* {@link ownershipFromDescription} so a caller cannot accidentally treat a
|
|
91
|
+
* store's tags as a policy's marker — the mistake the whole design exists to
|
|
92
|
+
* avoid.
|
|
93
|
+
*/
|
|
94
|
+
export declare function ownershipFromStoreTags(tags: Record<string, unknown> | undefined): "owned" | "foreign";
|
|
95
|
+
/** The tag entries to stamp onto a policy store. */
|
|
96
|
+
export declare function storeOwnershipTags(marker: OwnershipMarker): Record<string, string>;
|
|
97
|
+
//# sourceMappingURL=ownership.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../../src/avp/ownership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG/E;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAIhC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,iGAAiG;IACjG,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,MAAM,EAAE,OAAO,CAAC;CACjB;AAID;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,MAAM,EAAE,eAAe,EACvB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAeR;AAED,4EAA4E;AAC5E,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,kBAAkB,CA6B9F;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAE7F;AAED,2DAA2D;AAC3D,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAErG;AAED,oDAAoD;AACpD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAElF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two text-level facts the observation needs from a live Cedar statement
|
|
3
|
+
* (#1652): which `@id` it carries — the link back to a chant entity — and
|
|
4
|
+
* whether it permits or forbids.
|
|
5
|
+
*
|
|
6
|
+
* Both by regex, with no parser behind them, and that is the point. Reading a
|
|
7
|
+
* policy *properly* is `src/import/parser.ts`'s job and it goes through
|
|
8
|
+
* `cedar-wasm`, which is a 12 MB module; the observation path must not load it,
|
|
9
|
+
* because `plugin.ts` imports `ambientKinds()` eagerly and every `chant`
|
|
10
|
+
* invocation would pay for it. Live export, which is allowed to be slow and
|
|
11
|
+
* needs real fidelity, uses the import parser instead of anything here.
|
|
12
|
+
*
|
|
13
|
+
* Neither function is a judgement. `observeAmbient` reports the effect and
|
|
14
|
+
* stops; whether an ambient `permit` is a standing grant worth acting on is the
|
|
15
|
+
* consumer's call.
|
|
16
|
+
*/
|
|
17
|
+
import type { CedarEffect } from "../serializer.js";
|
|
18
|
+
/** The `@id("…")` a chant-emitted statement always carries, or undefined. */
|
|
19
|
+
export declare function policyIdFromStatement(statement: string): string | undefined;
|
|
20
|
+
/** `permit` or `forbid`, scanned past any annotations. */
|
|
21
|
+
export declare function effectFromStatement(statement: string): CedarEffect | undefined;
|
|
22
|
+
//# sourceMappingURL=statement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statement.d.ts","sourceRoot":"","sources":["../../src/avp/statement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,6EAA6E;AAC7E,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI3E;AAED,0DAA0D;AAC1D,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAG9E"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binding a chant environment to an AVP policy store, and reading it (#1652).
|
|
3
|
+
*
|
|
4
|
+
* Everything that talks to a store needs the same two things first: which store
|
|
5
|
+
* this environment means, and the store's policies indexed by the Cedar id a
|
|
6
|
+
* chant entity resolves to. Both live here so `describeResources`,
|
|
7
|
+
* `observeAmbient` and `exportResources` cannot disagree about either.
|
|
8
|
+
*/
|
|
9
|
+
import { type AvpClientOptions, type AvpPolicySummary } from "./client.js";
|
|
10
|
+
/** The env var an environment's policy store is named in when config does not name it. */
|
|
11
|
+
export declare const AVP_POLICY_STORE_ENV = "CEDAR_AVP_POLICY_STORE_ID";
|
|
12
|
+
/** Per-environment override: `CEDAR_AVP_POLICY_STORE_ID_PROD`. */
|
|
13
|
+
export declare function policyStoreEnvKey(environment: string): string;
|
|
14
|
+
export interface StoreBindingOptions {
|
|
15
|
+
environment: string;
|
|
16
|
+
/** Explicit store id from the caller — wins over everything. */
|
|
17
|
+
policyStoreId?: string;
|
|
18
|
+
/** Declared entities, read for a `policyStoreId` prop (the entity-prop pass-through). */
|
|
19
|
+
entities?: Map<string, {
|
|
20
|
+
entityType: string;
|
|
21
|
+
props: Record<string, unknown>;
|
|
22
|
+
}>;
|
|
23
|
+
env?: Record<string, string | undefined>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Which policy store this environment means.
|
|
27
|
+
*
|
|
28
|
+
* Resolution order, most specific first:
|
|
29
|
+
*
|
|
30
|
+
* 1. an explicit `policyStoreId` from the caller;
|
|
31
|
+
* 2. a `policyStoreId` prop on a declared policy — the entity-prop
|
|
32
|
+
* pass-through the observation guide recommends for finding the cloud-side
|
|
33
|
+
* identifier, and the form a project uses when it declares the store in the
|
|
34
|
+
* same build;
|
|
35
|
+
* 3. `CEDAR_AVP_POLICY_STORE_ID_<ENV>`, then `CEDAR_AVP_POLICY_STORE_ID`.
|
|
36
|
+
*
|
|
37
|
+
* `undefined` means no binding, and every caller turns that into `no-binding`
|
|
38
|
+
* rather than an empty read. An empty read would say the store holds nothing,
|
|
39
|
+
* which is a claim about an estate nobody looked at.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolvePolicyStoreId(options: StoreBindingOptions): string | undefined;
|
|
42
|
+
/** One live policy, with whatever chant could learn about which entity it belongs to. */
|
|
43
|
+
export interface AvpLivePolicy extends AvpPolicySummary {
|
|
44
|
+
/** The Cedar `@id` — the link back to a chant entity. Undefined when unrecoverable. */
|
|
45
|
+
cedarPolicyId?: string;
|
|
46
|
+
/** The policy text, when it was fetched (see `withStatements`). */
|
|
47
|
+
statement?: string;
|
|
48
|
+
/** The author's description, marker segment removed. */
|
|
49
|
+
authoredDescription: string;
|
|
50
|
+
/** Whether the description carried chant's ownership marker. */
|
|
51
|
+
marked: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface LoadPoliciesOptions {
|
|
54
|
+
policyStoreId: string;
|
|
55
|
+
client?: AvpClientOptions;
|
|
56
|
+
/**
|
|
57
|
+
* Fetch each policy's statement.
|
|
58
|
+
*
|
|
59
|
+
* The thin observation does not need one: a marked policy's description
|
|
60
|
+
* already names its Cedar id, and `describeResources` returns scrubbed
|
|
61
|
+
* metadata rather than config. Ambient discovery and live export both do, so
|
|
62
|
+
* they ask for them.
|
|
63
|
+
*/
|
|
64
|
+
withStatements?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Every policy in the store, each resolved to its Cedar id where possible.
|
|
68
|
+
*
|
|
69
|
+
* The marker is the cheap path: `ListPolicies` returns descriptions, so a
|
|
70
|
+
* chant-stamped policy is identified in the enumeration itself. Anything
|
|
71
|
+
* unmarked — a console edit, another tool's policy — costs one `GetPolicy` to
|
|
72
|
+
* read the `@id` out of its statement, run through the shared bounded pool so a
|
|
73
|
+
* store of two hundred policies is not two hundred serial round trips.
|
|
74
|
+
*
|
|
75
|
+
* A per-policy `GetPolicy` failure leaves that policy without a statement and
|
|
76
|
+
* without a Cedar id rather than sinking the enumeration: the caller then treats
|
|
77
|
+
* the entity it would have matched as not-observed, which is the honest verdict.
|
|
78
|
+
*/
|
|
79
|
+
export declare function loadLivePolicies(options: LoadPoliciesOptions): Promise<AvpLivePolicy[]>;
|
|
80
|
+
/** Index live policies by the Cedar id a chant entity resolves to. */
|
|
81
|
+
export declare function indexByCedarId(policies: readonly AvpLivePolicy[]): Map<string, AvpLivePolicy>;
|
|
82
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/avp/store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAIlB,0FAA0F;AAC1F,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAEhE,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAYrF;AAED,yFAAyF;AACzF,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,uFAAuF;IACvF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gEAAgE;IAChE,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAiC7F;AAED,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAU7F"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A fake AVP wire, for the tests of every reader in ../ .
|
|
3
|
+
*
|
|
4
|
+
* Mocks the *client layer*, never the network: it implements {@link AvpHttp},
|
|
5
|
+
* the same injection point `lexicons/aws/src/api/read-client.ts` exposes, so a
|
|
6
|
+
* test drives real `avpCall` / `listPolicies` / `getPolicy` code — the
|
|
7
|
+
* pagination loop, the `__type` error mapping, the description decoding — with
|
|
8
|
+
* only the socket replaced.
|
|
9
|
+
*/
|
|
10
|
+
import type { AvpHttp } from "../client.js";
|
|
11
|
+
/** One policy the fake store holds. */
|
|
12
|
+
export interface MockPolicy {
|
|
13
|
+
policyId: string;
|
|
14
|
+
statement: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
policyType?: string;
|
|
17
|
+
createdDate?: string;
|
|
18
|
+
lastUpdatedDate?: string;
|
|
19
|
+
/** Make `GetPolicy` fail for this one, to exercise a per-policy hole. */
|
|
20
|
+
getFails?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface MockStore {
|
|
23
|
+
policyStoreId: string;
|
|
24
|
+
policies: MockPolicy[];
|
|
25
|
+
/** Page size, so the pagination loop is actually exercised. */
|
|
26
|
+
pageSize?: number;
|
|
27
|
+
/** Fail `ListPolicies` with this AWS error code. */
|
|
28
|
+
listFails?: {
|
|
29
|
+
code: string;
|
|
30
|
+
message: string;
|
|
31
|
+
status?: number;
|
|
32
|
+
};
|
|
33
|
+
tags?: Record<string, string>;
|
|
34
|
+
arn?: string;
|
|
35
|
+
}
|
|
36
|
+
/** A chant-stamped description for a policy the fake store should read as owned. */
|
|
37
|
+
export declare function markedDescription(policyId: string, text?: string, marker?: {
|
|
38
|
+
stack: string;
|
|
39
|
+
env?: string;
|
|
40
|
+
}): string;
|
|
41
|
+
/** A statement carrying the `@id` a chant entity resolves to. */
|
|
42
|
+
export declare function statementFor(policyId: string, body?: string): string;
|
|
43
|
+
export interface MockTransport {
|
|
44
|
+
http: AvpHttp;
|
|
45
|
+
/** Every operation issued, in order — for asserting round-trip counts. */
|
|
46
|
+
calls: Array<{
|
|
47
|
+
operation: string;
|
|
48
|
+
payload: Record<string, unknown>;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
/** Build an {@link AvpHttp} over one fake store. */
|
|
52
|
+
export declare function mockAvpTransport(store: MockStore): MockTransport;
|
|
53
|
+
/** The env a reader needs to consider itself credentialed against a fake endpoint. */
|
|
54
|
+
export declare const MOCK_ENV: Record<string, string | undefined>;
|
|
55
|
+
//# sourceMappingURL=mock-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-transport.d.ts","sourceRoot":"","sources":["../../../src/avp/testdata/mock-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,uCAAuC;AACvC,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,oFAAoF;AACpF,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,IAAI,SAAK,EACT,MAAM,GAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAoC,GACxE,MAAM,CAER;AAED,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,SAAqD,GAAG,MAAM,CAEhH;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,0EAA0E;IAC1E,KAAK,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CACvE;AAED,oDAAoD;AACpD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,aAAa,CAoFhE;AAED,sFAAsF;AACtF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAEvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-cli.d.ts","sourceRoot":"","sources":["../../src/codegen/docs-cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cedar lexicon's Starlight site.
|
|
3
|
+
*
|
|
4
|
+
* Pages are declared as `extraPages` rather than left as hand-written files in
|
|
5
|
+
* docs/. The pipeline rebuilds the sidebar from the pages it knows about on
|
|
6
|
+
* every run, and Starlight does not auto-discover, so a page the config has
|
|
7
|
+
* never heard of exists on disk and is reachable only by typing its URL
|
|
8
|
+
* (chant #1312).
|
|
9
|
+
*
|
|
10
|
+
* Two more pages come out of the pipeline itself: the generated rules table
|
|
11
|
+
* (`rules`) and the serialization reference. Both are linked from the sidebar
|
|
12
|
+
* automatically.
|
|
13
|
+
*
|
|
14
|
+
* Cross-namespace links are written as full `/chant/...` paths. This site's
|
|
15
|
+
* base is `/chant/lexicons/cedar/`, so a bare `/guide/...` would be rewritten
|
|
16
|
+
* to `/chant/lexicons/cedar/guide/...`; the rehype plugin's idempotency check
|
|
17
|
+
* leaves an already-project-rooted path alone. Sibling pages use `../slug/`,
|
|
18
|
+
* because `./slug` from an MDX body resolves as a child.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Generate the docs site for the cedar lexicon.
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateDocs(options?: {
|
|
24
|
+
verbose?: boolean;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAuwBH;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA4EjF"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three generated artifacts, all built from one model.
|
|
3
|
+
*
|
|
4
|
+
* `lexicon-cedar.json`, `index.ts` and `index.d.ts` describe the same set of
|
|
5
|
+
* declarations, and the only way they cannot skew is if they are derived from
|
|
6
|
+
* the same pass — which is what {@link buildEmitModel} is for. Nothing here
|
|
7
|
+
* reads the clock or a random source: keys come out of the resolved schema
|
|
8
|
+
* already sorted (Rust `BTreeMap`, #1648 §5.2), everything else is sorted
|
|
9
|
+
* explicitly, so regenerating twice produces identical bytes.
|
|
10
|
+
*/
|
|
11
|
+
import type { NamingStrategy } from "@intentius/chant/codegen/naming";
|
|
12
|
+
import type { CedarAttribute, CedarDecl, CedarTypeRef } from "../spec/parse.js";
|
|
13
|
+
export declare const LEXICON_NAME = "cedar";
|
|
14
|
+
export interface EmitEntity {
|
|
15
|
+
tsName: string;
|
|
16
|
+
/** `App::User` */
|
|
17
|
+
typeName: string;
|
|
18
|
+
namespace: string;
|
|
19
|
+
/** TS name of the attribute-record property class, e.g. `UserAttributes`. */
|
|
20
|
+
attributesTsName: string;
|
|
21
|
+
/** TS name of the entity-UID string type, e.g. `UserUid`. */
|
|
22
|
+
uidTsName: string;
|
|
23
|
+
memberOfTypes: string[];
|
|
24
|
+
attributes: CedarAttribute[];
|
|
25
|
+
enumValues?: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface EmitAction {
|
|
28
|
+
tsName: string;
|
|
29
|
+
/** `App::Action::"read"` */
|
|
30
|
+
typeName: string;
|
|
31
|
+
namespace: string;
|
|
32
|
+
actionId: string;
|
|
33
|
+
/** TS name of the context-record property class, e.g. `ReadContext`. */
|
|
34
|
+
contextTsName: string;
|
|
35
|
+
principalTypes: string[];
|
|
36
|
+
resourceTypes: string[];
|
|
37
|
+
context: CedarAttribute[];
|
|
38
|
+
}
|
|
39
|
+
export interface EmitModel {
|
|
40
|
+
entities: EmitEntity[];
|
|
41
|
+
actions: EmitAction[];
|
|
42
|
+
/** entityType → the UID type name, for rendering `{type:"Entity"}` references. */
|
|
43
|
+
uidTypeByEntityType: Map<string, string>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Assign every generated name, once.
|
|
47
|
+
*
|
|
48
|
+
* `NamingStrategy` names the primary declarations; the derived record names
|
|
49
|
+
* are de-duplicated against the same pool so a `UserAttributes` entity type in
|
|
50
|
+
* the schema cannot quietly take the name `User`'s attribute record wants.
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildEmitModel(decls: CedarDecl[], naming: NamingStrategy): EmitModel;
|
|
53
|
+
/**
|
|
54
|
+
* Render one Cedar type as a TypeScript type expression.
|
|
55
|
+
*
|
|
56
|
+
* Extension types (`ipaddr`, `decimal`, `datetime`, `duration`) render as
|
|
57
|
+
* `string`: Cedar constructs them from string literals in policy text, and
|
|
58
|
+
* inventing branded TS types for values chant never evaluates would be
|
|
59
|
+
* decoration.
|
|
60
|
+
*/
|
|
61
|
+
export declare function renderType(type: CedarTypeRef, model: EmitModel): string;
|
|
62
|
+
/** Quote an attribute name that is not a bare identifier — Cedar allows both. */
|
|
63
|
+
export declare function propertyKey(name: string): string;
|
|
64
|
+
/** The Cedar surface syntax for a type, for doc comments and the registry. */
|
|
65
|
+
export declare function cedarTypeText(type: CedarTypeRef): string;
|
|
66
|
+
/** `App::User` → `App::User.Attributes`, the record type's own spec name. */
|
|
67
|
+
export declare function attributesTypeName(entityTypeName: string): string;
|
|
68
|
+
/** `App::Action::"read"` → `App::Action::"read".Context`. */
|
|
69
|
+
export declare function contextTypeName(actionTypeName: string): string;
|
|
70
|
+
/** Build `lexicon-cedar.json`. */
|
|
71
|
+
export declare function generateRegistry(model: EmitModel): string;
|
|
72
|
+
/** Build the runtime `index.ts`. */
|
|
73
|
+
export declare function generateRuntimeIndex(model: EmitModel): string;
|
|
74
|
+
/**
|
|
75
|
+
* Build the declaration-only `index.d.ts`.
|
|
76
|
+
*
|
|
77
|
+
* It is validated standalone by core's `typecheckDTS`, which runs tsc in a
|
|
78
|
+
* temp directory with no `node_modules` beyond a stub for
|
|
79
|
+
* `@intentius/chant/declarable` — so this file may import that and nothing
|
|
80
|
+
* else, and every other type it uses has to be declared here.
|
|
81
|
+
*/
|
|
82
|
+
export declare function generateTypes(model: EmitModel): string;
|
|
83
|
+
/** The tiny re-export module `index.ts` imports its factories from. */
|
|
84
|
+
export declare const RUNTIME_TS = "// Code generated by chant generate. DO NOT EDIT.\nexport { createProperty, createResource } from \"@intentius/chant/runtime\";\n";
|
|
85
|
+
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/codegen/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7E,eAAO,MAAM,YAAY,UAAU,CAAC;AAIpC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,kFAAkF;IAClF,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,cAAc,GAAG,SAAS,CA4DpF;AAWD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAmBvE;AAID,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAexD;AAWD,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAE9D;AAUD,kCAAkC;AAClC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CA6DzD;AAmHD,oCAAoC;AACpC,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAqD7D;AAID;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAiCtD;AAID,uEAAuE;AACvE,eAAO,MAAM,UAAU,sIAEtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-cli.d.ts","sourceRoot":"","sources":["../../src/codegen/generate-cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-driven code generation for the cedar lexicon (#1650).
|
|
3
|
+
*
|
|
4
|
+
* The pipeline is core's; what is unusual is its input. Every other lexicon
|
|
5
|
+
* fetches one global upstream spec, so `fetchSchemas` is an HTTP call and a
|
|
6
|
+
* cache. Cedar's spec-of-interest is the project's own `.cedarschema` (epic
|
|
7
|
+
* #1645), so `fetchSchemas` is a file read with a fallback, and the pinned
|
|
8
|
+
* upstream is the *grammar* — `@cedar-policy/cedar-wasm`, whose language
|
|
9
|
+
* version is asserted before anything is emitted.
|
|
10
|
+
*
|
|
11
|
+
* Order matters in {@link generate}: the language-version assert runs before
|
|
12
|
+
* the schema is resolved, because resolution is the thing whose output shape a
|
|
13
|
+
* grammar change would move.
|
|
14
|
+
*/
|
|
15
|
+
import type { GenerateOptions, GenerateResult } from "@intentius/chant/codegen/generate";
|
|
16
|
+
/** Filename of the generated registry. */
|
|
17
|
+
export declare const LEXICON_JSON_FILENAME = "lexicon-cedar.json";
|
|
18
|
+
export interface CedarGenerateOptions extends GenerateOptions {
|
|
19
|
+
/** Project root the `cedar.schema` path is resolved against. Defaults to `process.cwd()`. */
|
|
20
|
+
projectRoot?: string;
|
|
21
|
+
/** The `cedar` config namespace, when the caller has already loaded it. */
|
|
22
|
+
config?: {
|
|
23
|
+
schema?: string;
|
|
24
|
+
validation?: {
|
|
25
|
+
requireProjectSchema?: boolean;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run the code generation pipeline.
|
|
31
|
+
*/
|
|
32
|
+
export declare function generate(options?: CedarGenerateOptions): Promise<GenerateResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Write generated files to the package directory.
|
|
35
|
+
*/
|
|
36
|
+
export declare function writeGeneratedFiles(result: GenerateResult, pkgDir?: string): void;
|
|
37
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/codegen/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAiBzF,0CAA0C;AAC1C,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAE1D,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,6FAA6F;IAC7F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,MAAM,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE;YAAE,oBAAoB,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAC;CAC/E;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,cAAc,CAAC,CA0D1F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAajF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { NamingStrategy, type NamingConfig, type NamingInput } from "@intentius/chant/codegen/naming";
|
|
2
|
+
/**
|
|
3
|
+
* The name of the policy resource every generated bundle carries.
|
|
4
|
+
*
|
|
5
|
+
* It is not schema-derived — a Cedar schema declares entity types and actions,
|
|
6
|
+
* never policies — so it is claimed as a priority name before any schema type
|
|
7
|
+
* gets to contest a short name. A project whose schema declares its own
|
|
8
|
+
* `Policy` entity type therefore gets `AppPolicy` (or whatever its namespace
|
|
9
|
+
* is), and the authoring class keeps the name users import.
|
|
10
|
+
*/
|
|
11
|
+
export declare const POLICY_TS_NAME = "Policy";
|
|
12
|
+
/** The `entityType` of the policy resource, matching the serializer. */
|
|
13
|
+
export declare const POLICY_TYPE = "Cedar::Policy";
|
|
14
|
+
/** `read` → `Read`; `service-account` → `ServiceAccount`. */
|
|
15
|
+
export declare function pascalCase(value: string): string;
|
|
16
|
+
/** Split `App::Action::"read"` into its action id, or null for a non-action. */
|
|
17
|
+
export declare function actionIdOf(typeName: string): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Naming configuration for the cedar lexicon.
|
|
20
|
+
*
|
|
21
|
+
* Two shapes go through this rather than one: `App::User` (an entity type) and
|
|
22
|
+
* `App::Action::"read"` (an action). Both are entities in Cedar's model, so
|
|
23
|
+
* both are contested in the same pool — a schema with an entity type called
|
|
24
|
+
* `Read` and an action called `read` collides, and phase 4 qualifies the loser
|
|
25
|
+
* with its namespace rather than one silently overwriting the other.
|
|
26
|
+
*/
|
|
27
|
+
export declare const namingConfig: NamingConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Create a NamingStrategy instance from parsed results.
|
|
30
|
+
*
|
|
31
|
+
* `Cedar::Policy` is injected as an input because it has to be *in* the contest
|
|
32
|
+
* to win it: `priorityNames` is applied over the input type names, so a policy
|
|
33
|
+
* type that never appears there cannot claim `Policy` before a schema's own
|
|
34
|
+
* `Policy` entity type takes it in the short-name phase.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createNaming(inputs: NamingInput[]): NamingStrategy;
|
|
37
|
+
/**
|
|
38
|
+
* The names derived from a primary name — the entity's attribute record and
|
|
39
|
+
* the action's context record.
|
|
40
|
+
*
|
|
41
|
+
* These are not contested by `NamingStrategy` (it only names the primary
|
|
42
|
+
* declarations), so they are de-duplicated against everything already taken.
|
|
43
|
+
* The suffix loop is deliberately boring: a schema that manages to collide
|
|
44
|
+
* `UserAttributes` twice gets `UserAttributes2`, which is ugly and correct,
|
|
45
|
+
* rather than one entry silently overwriting the other in the registry.
|
|
46
|
+
*/
|
|
47
|
+
export declare function deriveName(base: string, suffix: string, taken: Set<string>): string;
|
|
48
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/codegen/naming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEtG;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,WAAW,CAAC;AAEvC,wEAAwE;AACxE,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAE3C,6DAA6D;AAC7D,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1D;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,YA2B1B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,CAElE;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CASnF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cedar lexicon packaging — delegates to core's packagePipeline.
|
|
3
|
+
*/
|
|
4
|
+
import { type PackageOptions, type PackageResult } from "@intentius/chant/codegen/package";
|
|
5
|
+
export type { PackageOptions, PackageResult };
|
|
6
|
+
/**
|
|
7
|
+
* Package the Cedar lexicon into a distributable BundleSpec.
|
|
8
|
+
*/
|
|
9
|
+
export declare function packageLexicon(opts?: PackageOptions): Promise<PackageResult>;
|
|
10
|
+
//# sourceMappingURL=package.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/codegen/package.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,kCAAkC,CAAC;AAG1C,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAI9C;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CA8BtF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DenyByDefaultSet — a forbid floor under a group of permits.
|
|
3
|
+
*
|
|
4
|
+
* Cedar is already default-deny, so a floor is not about the absence of a
|
|
5
|
+
* permit; it is about the presence of a bad one. A `forbid` beats every
|
|
6
|
+
* `permit` in the same set unconditionally, which makes a forbid the only
|
|
7
|
+
* construct that survives a later, wider grant. The pattern teams write by hand
|
|
8
|
+
* is a guarded forbid at the top of a file and a pile of permits under it, with
|
|
9
|
+
* nothing tying the two together — delete the forbid and the permits keep
|
|
10
|
+
* working, wider than anyone intended.
|
|
11
|
+
*
|
|
12
|
+
* This composite returns both halves from one call, so the floor cannot be
|
|
13
|
+
* dropped without dropping the members with it.
|
|
14
|
+
*/
|
|
15
|
+
import type { Declarable } from "@intentius/chant/declarable";
|
|
16
|
+
import type { EntityTypeName, PolicyRef, PolicyScope } from "../generated/index.js";
|
|
17
|
+
export interface DenyByDefaultSetOpts {
|
|
18
|
+
/**
|
|
19
|
+
* The permits the floor sits under. They are returned unchanged — the floor
|
|
20
|
+
* constrains them at evaluation time, not at construction time.
|
|
21
|
+
*/
|
|
22
|
+
policies: Declarable[];
|
|
23
|
+
/**
|
|
24
|
+
* The entity type the floor covers. Omit to make it apply to every resource,
|
|
25
|
+
* which is the strongest form and worth stating deliberately.
|
|
26
|
+
*/
|
|
27
|
+
entityType?: EntityTypeName;
|
|
28
|
+
/**
|
|
29
|
+
* Actions the floor forbids. Defaults to every action, i.e. an unconstrained
|
|
30
|
+
* action position.
|
|
31
|
+
*/
|
|
32
|
+
actions?: PolicyRef | PolicyRef[];
|
|
33
|
+
/**
|
|
34
|
+
* The conditions under which the denial applies. Required: a forbid with no
|
|
35
|
+
* guard denies everything unconditionally and no permit can lift it, which
|
|
36
|
+
* is a policy set that authorizes nothing.
|
|
37
|
+
*/
|
|
38
|
+
when: string[];
|
|
39
|
+
/** Carve-outs from the denial. The break-glass principal usually lives here. */
|
|
40
|
+
unless?: string[];
|
|
41
|
+
/** Narrow the floor's principal. A bare entity type becomes `principal is T`. */
|
|
42
|
+
principal?: EntityTypeName | PolicyScope;
|
|
43
|
+
/** Merged over the generated annotations; an explicit `id` wins. */
|
|
44
|
+
annotations?: Record<string, string>;
|
|
45
|
+
}
|
|
46
|
+
export interface DenyByDefaultSetResources {
|
|
47
|
+
/** The `forbid` policy. Emitted first in declaration order. */
|
|
48
|
+
floor: Declarable;
|
|
49
|
+
/** The permits, unchanged and in the order given. */
|
|
50
|
+
members: Declarable[];
|
|
51
|
+
/** `[floor, ...members]`, for `export const … = DenyByDefaultSet(…).all`. */
|
|
52
|
+
all: Declarable[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A guarded `forbid` plus the permits it governs.
|
|
56
|
+
*/
|
|
57
|
+
export declare function DenyByDefaultSet(opts: DenyByDefaultSetOpts): DenyByDefaultSetResources;
|
|
58
|
+
//# sourceMappingURL=deny-by-default-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deny-by-default-set.d.ts","sourceRoot":"","sources":["../../src/composites/deny-by-default-set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjF,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;IAClC;;;;OAIG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,iFAAiF;IACjF,SAAS,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC;IACzC,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,yBAAyB;IACxC,+DAA+D;IAC/D,KAAK,EAAE,UAAU,CAAC;IAClB,qDAAqD;IACrD,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,6EAA6E;IAC7E,GAAG,EAAE,UAAU,EAAE,CAAC;CACnB;AAeD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,yBAAyB,CAuBtF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cedar lexicon composites.
|
|
3
|
+
*
|
|
4
|
+
* Cedar has no functions, no modules, no loops, and templates with exactly two
|
|
5
|
+
* slots — so every repeated policy shape is copy-paste in `.cedar` text. These
|
|
6
|
+
* factories are where that repetition goes instead.
|
|
7
|
+
*/
|
|
8
|
+
export { OwnerCanManage } from "./owner-can-manage.js";
|
|
9
|
+
export type { OwnerCanManageOpts } from "./owner-can-manage.js";
|
|
10
|
+
export { DenyByDefaultSet } from "./deny-by-default-set.js";
|
|
11
|
+
export type { DenyByDefaultSetOpts, DenyByDefaultSetResources } from "./deny-by-default-set.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composites/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC"}
|