@cedar-policy/cedar-wasm 4.6.1 → 4.8.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/esm/cedar_wasm.d.ts +168 -168
- package/esm/cedar_wasm_bg.js +126 -126
- package/esm/cedar_wasm_bg.wasm +0 -0
- package/esm/cedar_wasm_bg.wasm.d.ts +6 -6
- package/esm/package.json +1 -1
- package/nodejs/cedar_wasm.d.ts +168 -168
- package/nodejs/cedar_wasm.js +118 -118
- package/nodejs/cedar_wasm_bg.wasm +0 -0
- package/nodejs/cedar_wasm_bg.wasm.d.ts +6 -6
- package/nodejs/package.json +1 -1
- package/package.json +1 -1
- package/web/cedar_wasm.d.ts +174 -174
- package/web/cedar_wasm.js +124 -132
- package/web/cedar_wasm_bg.wasm +0 -0
- package/web/cedar_wasm_bg.wasm.d.ts +6 -6
- package/web/package.json +1 -1
package/esm/cedar_wasm.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ export function getValidRequestEnvsPolicy(t: Policy, s: Schema): GetValidRequest
|
|
|
10
10
|
* Get valid request environment
|
|
11
11
|
*/
|
|
12
12
|
export function getValidRequestEnvsTemplate(t: Template, s: Schema): GetValidRequestEnvsResult;
|
|
13
|
+
/**
|
|
14
|
+
* Preparse and cache a schema in thread-local storage
|
|
15
|
+
*
|
|
16
|
+
* # Errors
|
|
17
|
+
*
|
|
18
|
+
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
19
|
+
*/
|
|
20
|
+
export function preparseSchema(schema_name: string, schema: Schema): CheckParseAnswer;
|
|
13
21
|
/**
|
|
14
22
|
* Preparse and cache a policy set in thread-local storage
|
|
15
23
|
*
|
|
@@ -30,17 +38,24 @@ export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
|
30
38
|
*/
|
|
31
39
|
export function statefulIsAuthorized(call: StatefulAuthorizationCall): AuthorizationAnswer;
|
|
32
40
|
/**
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
* Get language version of Cedar
|
|
42
|
+
*/
|
|
43
|
+
export function getCedarLangVersion(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
46
|
+
*/
|
|
47
|
+
export function formatPolicies(call: FormattingCall): FormattingAnswer;
|
|
48
|
+
/**
|
|
49
|
+
* Parse a policy set and optionally validate it against a provided schema
|
|
36
50
|
*
|
|
37
|
-
*
|
|
51
|
+
* This is the basic validator interface, using [`ValidationCall`] and
|
|
52
|
+
* [`ValidationAnswer`] types
|
|
38
53
|
*/
|
|
39
|
-
export function
|
|
54
|
+
export function validate(call: ValidationCall): ValidationAnswer;
|
|
40
55
|
/**
|
|
41
|
-
* Check whether a
|
|
56
|
+
* Check whether a context successfully parses.
|
|
42
57
|
*/
|
|
43
|
-
export function
|
|
58
|
+
export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
|
|
44
59
|
/**
|
|
45
60
|
* Check whether a schema successfully parses.
|
|
46
61
|
*/
|
|
@@ -50,30 +65,26 @@ export function checkParseSchema(schema: Schema): CheckParseAnswer;
|
|
|
50
65
|
*/
|
|
51
66
|
export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
|
|
52
67
|
/**
|
|
53
|
-
* Check whether a
|
|
68
|
+
* Check whether a set of entities successfully parses.
|
|
54
69
|
*/
|
|
55
|
-
export function
|
|
70
|
+
export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
|
|
56
71
|
/**
|
|
57
|
-
* Return the
|
|
72
|
+
* Return the JSON representation of a schema.
|
|
58
73
|
*/
|
|
59
|
-
export function
|
|
74
|
+
export function schemaToJson(schema: Schema): SchemaToJsonAnswer;
|
|
60
75
|
/**
|
|
61
76
|
* Return the Cedar (textual) representation of a schema.
|
|
62
77
|
*/
|
|
63
78
|
export function schemaToText(schema: Schema): SchemaToTextAnswer;
|
|
64
|
-
/**
|
|
65
|
-
* Return the JSON representation of a template.
|
|
66
|
-
*/
|
|
67
|
-
export function templateToJson(template: Template): PolicyToJsonAnswer;
|
|
68
79
|
/**
|
|
69
80
|
* Takes a `PolicySet` represented as string and return the policies
|
|
70
81
|
* and templates split into vecs and sorted by id.
|
|
71
82
|
*/
|
|
72
83
|
export function policySetTextToParts(policyset_str: string): PolicySetTextToPartsAnswer;
|
|
73
84
|
/**
|
|
74
|
-
* Return the
|
|
85
|
+
* Return the Cedar (textual) representation of a policy.
|
|
75
86
|
*/
|
|
76
|
-
export function
|
|
87
|
+
export function policyToText(policy: Policy): PolicyToTextAnswer;
|
|
77
88
|
/**
|
|
78
89
|
* Return the JSON representation of a policy.
|
|
79
90
|
*/
|
|
@@ -83,37 +94,61 @@ export function policyToJson(policy: Policy): PolicyToJsonAnswer;
|
|
|
83
94
|
*/
|
|
84
95
|
export function templateToText(template: Template): PolicyToTextAnswer;
|
|
85
96
|
/**
|
|
86
|
-
*
|
|
87
|
-
*/
|
|
88
|
-
export function getCedarLangVersion(): string;
|
|
89
|
-
/**
|
|
90
|
-
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
91
|
-
*/
|
|
92
|
-
export function formatPolicies(call: FormattingCall): FormattingAnswer;
|
|
93
|
-
/**
|
|
94
|
-
* Parse a policy set and optionally validate it against a provided schema
|
|
95
|
-
*
|
|
96
|
-
* This is the basic validator interface, using [`ValidationCall`] and
|
|
97
|
-
* [`ValidationAnswer`] types
|
|
97
|
+
* Return the JSON representation of a template.
|
|
98
98
|
*/
|
|
99
|
-
export function
|
|
99
|
+
export function templateToJson(template: Template): PolicyToJsonAnswer;
|
|
100
100
|
export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
|
|
101
101
|
|
|
102
102
|
export type SlotId = string;
|
|
103
103
|
|
|
104
104
|
export type PolicyId = string;
|
|
105
105
|
|
|
106
|
-
export
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
export type EntityUid = EntityUidJson;
|
|
107
|
+
|
|
108
|
+
export type Schema = string | SchemaJson<string>;
|
|
109
|
+
|
|
110
|
+
export interface SourceLabel extends SourceLocation {
|
|
111
|
+
label: string | null;
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
export
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
export type Context = Record<string, CedarValueJson>;
|
|
115
|
+
|
|
116
|
+
export interface PolicySet {
|
|
117
|
+
staticPolicies?: StaticPolicySet;
|
|
118
|
+
templates?: Record<PolicyId, Template>;
|
|
119
|
+
templateLinks?: TemplateLink[];
|
|
114
120
|
}
|
|
115
121
|
|
|
116
|
-
export type
|
|
122
|
+
export type Policy = string | PolicyJson;
|
|
123
|
+
|
|
124
|
+
export interface DetailedError {
|
|
125
|
+
message: string;
|
|
126
|
+
help: string | null;
|
|
127
|
+
code: string | null;
|
|
128
|
+
url: string | null;
|
|
129
|
+
severity: Severity | null;
|
|
130
|
+
sourceLocations?: SourceLabel[];
|
|
131
|
+
related?: DetailedError[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type Severity = "advice" | "warning" | "error";
|
|
135
|
+
|
|
136
|
+
export type Entities = Array<EntityJson>;
|
|
137
|
+
|
|
138
|
+
export interface SourceLocation {
|
|
139
|
+
start: number;
|
|
140
|
+
end: number;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface TemplateLink {
|
|
144
|
+
templateId: PolicyId;
|
|
145
|
+
newId: PolicyId;
|
|
146
|
+
values: Record<SlotId, EntityUid>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export type Template = string | PolicyJson;
|
|
150
|
+
|
|
151
|
+
export type StaticPolicySet = string | Policy[] | Record<PolicyId, Policy>;
|
|
117
152
|
|
|
118
153
|
export interface StatefulAuthorizationCall {
|
|
119
154
|
principal: EntityUid;
|
|
@@ -126,6 +161,21 @@ export interface StatefulAuthorizationCall {
|
|
|
126
161
|
entities: Entities;
|
|
127
162
|
}
|
|
128
163
|
|
|
164
|
+
export interface AuthorizationError {
|
|
165
|
+
policyId: string;
|
|
166
|
+
error: DetailedError;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface Diagnostics {
|
|
170
|
+
reason: PolicyId[];
|
|
171
|
+
errors: AuthorizationError[];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface Response {
|
|
175
|
+
decision: Decision;
|
|
176
|
+
diagnostics: Diagnostics;
|
|
177
|
+
}
|
|
178
|
+
|
|
129
179
|
export interface AuthorizationCall {
|
|
130
180
|
principal: EntityUid;
|
|
131
181
|
action: EntityUid;
|
|
@@ -137,63 +187,33 @@ export interface AuthorizationCall {
|
|
|
137
187
|
entities: Entities;
|
|
138
188
|
}
|
|
139
189
|
|
|
140
|
-
export
|
|
141
|
-
reason: PolicyId[];
|
|
142
|
-
errors: AuthorizationError[];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export type Severity = "advice" | "warning" | "error";
|
|
146
|
-
|
|
147
|
-
export interface TemplateLink {
|
|
148
|
-
templateId: PolicyId;
|
|
149
|
-
newId: PolicyId;
|
|
150
|
-
values: Record<SlotId, EntityUid>;
|
|
151
|
-
}
|
|
190
|
+
export type AuthorizationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; response: Response; warnings: DetailedError[] };
|
|
152
191
|
|
|
153
|
-
export type
|
|
192
|
+
export type ValidationMode = "strict";
|
|
154
193
|
|
|
155
|
-
export
|
|
156
|
-
start: number;
|
|
157
|
-
end: number;
|
|
158
|
-
}
|
|
194
|
+
export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
|
|
159
195
|
|
|
160
|
-
export interface
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
url: string | null;
|
|
165
|
-
severity: Severity | null;
|
|
166
|
-
sourceLocations?: SourceLabel[];
|
|
167
|
-
related?: DetailedError[];
|
|
196
|
+
export interface FormattingCall {
|
|
197
|
+
policyText: string;
|
|
198
|
+
lineWidth?: number;
|
|
199
|
+
indentWidth?: number;
|
|
168
200
|
}
|
|
169
201
|
|
|
170
|
-
export interface
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
202
|
+
export interface ValidationCall {
|
|
203
|
+
validationSettings?: ValidationSettings;
|
|
204
|
+
schema: Schema;
|
|
205
|
+
policies: PolicySet;
|
|
174
206
|
}
|
|
175
207
|
|
|
176
|
-
export type
|
|
177
|
-
|
|
178
|
-
export type Policy = string | PolicyJson;
|
|
179
|
-
|
|
180
|
-
export type StaticPolicySet = string | Policy[] | Record<PolicyId, Policy>;
|
|
181
|
-
|
|
182
|
-
export type Context = Record<string, CedarValueJson>;
|
|
183
|
-
|
|
184
|
-
export type Entities = Array<EntityJson>;
|
|
208
|
+
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
185
209
|
|
|
186
|
-
export interface
|
|
187
|
-
|
|
210
|
+
export interface ValidationError {
|
|
211
|
+
policyId: string;
|
|
212
|
+
error: DetailedError;
|
|
188
213
|
}
|
|
189
214
|
|
|
190
|
-
export
|
|
191
|
-
|
|
192
|
-
export type ValidationMode = "strict";
|
|
193
|
-
|
|
194
|
-
export interface EntitiesParsingCall {
|
|
195
|
-
entities: Entities;
|
|
196
|
-
schema?: Schema | null;
|
|
215
|
+
export interface ValidationSettings {
|
|
216
|
+
mode: ValidationMode;
|
|
197
217
|
}
|
|
198
218
|
|
|
199
219
|
export interface ContextParsingCall {
|
|
@@ -202,42 +222,56 @@ export interface ContextParsingCall {
|
|
|
202
222
|
action?: EntityUid | null;
|
|
203
223
|
}
|
|
204
224
|
|
|
225
|
+
export interface EntitiesParsingCall {
|
|
226
|
+
entities: Entities;
|
|
227
|
+
schema?: Schema | null;
|
|
228
|
+
}
|
|
229
|
+
|
|
205
230
|
export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
|
|
206
231
|
|
|
207
232
|
export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
|
|
208
233
|
|
|
234
|
+
export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
|
|
235
|
+
|
|
236
|
+
export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
|
|
237
|
+
|
|
209
238
|
export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
|
|
210
239
|
|
|
211
240
|
export type PolicySetTextToPartsAnswer = { type: "success"; policies: string[]; policy_templates: string[] } | { type: "failure"; errors: DetailedError[] };
|
|
212
241
|
|
|
213
|
-
export type
|
|
242
|
+
export type Annotations = Record<string, Annotation>;
|
|
214
243
|
|
|
215
|
-
export type
|
|
244
|
+
export type Decision = "allow" | "deny";
|
|
216
245
|
|
|
217
|
-
export type
|
|
246
|
+
export type Effect = "permit" | "forbid";
|
|
218
247
|
|
|
219
|
-
export
|
|
220
|
-
policyText: string;
|
|
221
|
-
lineWidth?: number;
|
|
222
|
-
indentWidth?: number;
|
|
223
|
-
}
|
|
248
|
+
export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
|
|
224
249
|
|
|
225
|
-
export
|
|
226
|
-
mode: ValidationMode;
|
|
227
|
-
}
|
|
250
|
+
export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
|
|
228
251
|
|
|
229
|
-
export
|
|
230
|
-
policyId: string;
|
|
231
|
-
error: DetailedError;
|
|
232
|
-
}
|
|
252
|
+
export type EqConstraint = { entity: EntityUidJson } | { slot: string };
|
|
233
253
|
|
|
234
|
-
export
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
254
|
+
export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
255
|
+
|
|
256
|
+
export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
257
|
+
|
|
258
|
+
export interface PrincipalOrResourceIsConstraint {
|
|
259
|
+
entity_type: string;
|
|
260
|
+
in?: PrincipalOrResourceInConstraint;
|
|
238
261
|
}
|
|
239
262
|
|
|
240
|
-
export type
|
|
263
|
+
export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
|
|
264
|
+
|
|
265
|
+
export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
|
|
266
|
+
|
|
267
|
+
export interface PolicyJson {
|
|
268
|
+
effect: Effect;
|
|
269
|
+
principal: PrincipalConstraint;
|
|
270
|
+
action: ActionConstraint;
|
|
271
|
+
resource: ResourceConstraint;
|
|
272
|
+
conditions: Clause[];
|
|
273
|
+
annotations?: Annotations;
|
|
274
|
+
}
|
|
241
275
|
|
|
242
276
|
export interface EntityJson {
|
|
243
277
|
uid: EntityUidJson;
|
|
@@ -246,36 +280,30 @@ export interface EntityJson {
|
|
|
246
280
|
tags?: Record<string, CedarValueJson>;
|
|
247
281
|
}
|
|
248
282
|
|
|
249
|
-
export type
|
|
250
|
-
|
|
251
|
-
export type UnreservedId = string;
|
|
283
|
+
export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { isEmpty: { arg: Expr } } | { getTag: { left: Expr; right: Expr } } | { hasTag: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
|
|
252
284
|
|
|
253
|
-
export type
|
|
285
|
+
export type PatternElem = "Wildcard" | { Literal: SmolStr };
|
|
254
286
|
|
|
255
|
-
export type
|
|
287
|
+
export type Expr = ExprNoExt | ExtFuncCall;
|
|
256
288
|
|
|
257
|
-
export type
|
|
289
|
+
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
258
290
|
|
|
259
|
-
export type
|
|
291
|
+
export type Var = "principal" | "action" | "resource" | "context";
|
|
260
292
|
|
|
261
|
-
export type
|
|
293
|
+
export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
|
|
262
294
|
|
|
263
|
-
export interface
|
|
264
|
-
|
|
265
|
-
|
|
295
|
+
export interface TypeAndId {
|
|
296
|
+
type: string;
|
|
297
|
+
id: string;
|
|
266
298
|
}
|
|
267
299
|
|
|
268
|
-
export type
|
|
269
|
-
|
|
270
|
-
export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
|
|
271
|
-
|
|
272
|
-
export type AttributesOrContext<N> = Type<N>;
|
|
300
|
+
export type FnAndArgs = { fn: string; arg: CedarValueJson } | { fn: string; args: CedarValueJson[] };
|
|
273
301
|
|
|
274
|
-
export type
|
|
302
|
+
export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArgs } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
275
303
|
|
|
276
|
-
export type
|
|
304
|
+
export type AnyId = SmolStr;
|
|
277
305
|
|
|
278
|
-
export type
|
|
306
|
+
export type UnreservedId = string;
|
|
279
307
|
|
|
280
308
|
export interface ActionEntityUID<N> {
|
|
281
309
|
id: SmolStr;
|
|
@@ -289,13 +317,7 @@ export interface ActionType<N> {
|
|
|
289
317
|
annotations?: Annotations;
|
|
290
318
|
}
|
|
291
319
|
|
|
292
|
-
export
|
|
293
|
-
resourceTypes: N[];
|
|
294
|
-
principalTypes: N[];
|
|
295
|
-
context?: AttributesOrContext<N>;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
export type SchemaJson<N> = Record<string, NamespaceDefinition<N>>;
|
|
320
|
+
export type Type<N> = ({} & TypeVariant<N>) | { type: N };
|
|
299
321
|
|
|
300
322
|
export interface NamespaceDefinition<N> {
|
|
301
323
|
commonTypes?: Record<CommonTypeId, CommonType<N>>;
|
|
@@ -304,57 +326,35 @@ export interface NamespaceDefinition<N> {
|
|
|
304
326
|
annotations?: Annotations;
|
|
305
327
|
}
|
|
306
328
|
|
|
329
|
+
export type AttributesOrContext<N> = Type<N>;
|
|
330
|
+
|
|
331
|
+
export interface ApplySpec<N> {
|
|
332
|
+
resourceTypes: N[];
|
|
333
|
+
principalTypes: N[];
|
|
334
|
+
context?: AttributesOrContext<N>;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export type TypeVariant<N> = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: Type<N> } | ({ type: "Record" } & RecordType<N>) | { type: "Entity"; name: N } | { type: "EntityOrCommon"; name: N } | { type: "Extension"; name: UnreservedId };
|
|
338
|
+
|
|
339
|
+
export type SchemaJson<N> = Record<string, NamespaceDefinition<N>>;
|
|
340
|
+
|
|
307
341
|
export interface RecordType<N> {
|
|
308
342
|
attributes: Record<SmolStr, TypeOfAttribute<N>>;
|
|
309
343
|
additionalAttributes?: boolean;
|
|
310
344
|
}
|
|
311
345
|
|
|
346
|
+
export type CommonTypeId = string;
|
|
347
|
+
|
|
348
|
+
export type EntityTypeKind<N> = StandardEntityType<N> | { enum: NonEmpty<SmolStr> };
|
|
349
|
+
|
|
312
350
|
export interface StandardEntityType<N> {
|
|
313
351
|
memberOfTypes?: N[];
|
|
314
352
|
shape?: AttributesOrContext<N>;
|
|
315
353
|
tags?: Type<N>;
|
|
316
354
|
}
|
|
317
355
|
|
|
318
|
-
export type CommonTypeId = string;
|
|
319
|
-
|
|
320
|
-
export type Decision = "allow" | "deny";
|
|
321
|
-
|
|
322
|
-
export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
|
|
323
|
-
|
|
324
|
-
export interface PolicyJson {
|
|
325
|
-
effect: Effect;
|
|
326
|
-
principal: PrincipalConstraint;
|
|
327
|
-
action: ActionConstraint;
|
|
328
|
-
resource: ResourceConstraint;
|
|
329
|
-
conditions: Clause[];
|
|
330
|
-
annotations?: Annotations;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
334
|
-
|
|
335
|
-
export type Expr = ExprNoExt | ExtFuncCall;
|
|
336
|
-
|
|
337
|
-
export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { isEmpty: { arg: Expr } } | { getTag: { left: Expr; right: Expr } } | { hasTag: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
|
|
338
|
-
|
|
339
|
-
export type PatternElem = "Wildcard" | { Literal: SmolStr };
|
|
340
|
-
|
|
341
356
|
export type Annotation = SmolStr;
|
|
342
357
|
|
|
343
|
-
export type Annotations = Record<string, Annotation>;
|
|
344
|
-
|
|
345
|
-
export type Var = "principal" | "action" | "resource" | "context";
|
|
346
|
-
|
|
347
|
-
export interface TypeAndId {
|
|
348
|
-
type: string;
|
|
349
|
-
id: string;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
export type FnAndArgs = { fn: string; arg: CedarValueJson } | { fn: string; args: CedarValueJson[] };
|
|
353
|
-
|
|
354
|
-
export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
|
|
355
|
-
|
|
356
|
-
export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArgs } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
357
|
-
|
|
358
358
|
type SmolStr = string;
|
|
359
359
|
export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
|
|
360
360
|
export type CommonType<N> = Type<N> & { annotations?: Annotations };
|