@cedar-policy/cedar-wasm 4.2.0 → 4.3.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 +122 -142
- package/esm/cedar_wasm.js +2 -3
- package/esm/cedar_wasm_bg.js +158 -117
- package/esm/cedar_wasm_bg.wasm +0 -0
- package/esm/cedar_wasm_bg.wasm.d.ts +23 -21
- package/esm/package.json +4 -4
- package/nodejs/cedar_wasm.d.ts +122 -142
- package/nodejs/cedar_wasm.js +158 -117
- package/nodejs/cedar_wasm_bg.wasm +0 -0
- package/nodejs/cedar_wasm_bg.wasm.d.ts +23 -21
- package/nodejs/package.json +1 -1
- package/package.json +2 -4
- package/web/cedar_wasm.d.ts +127 -145
- package/web/cedar_wasm.js +168 -121
- package/web/cedar_wasm_bg.wasm +0 -0
- package/web/cedar_wasm_bg.wasm.d.ts +23 -21
- package/web/package.json +4 -4
package/esm/cedar_wasm.d.ts
CHANGED
|
@@ -1,134 +1,76 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
* Get valid request environment
|
|
5
|
-
|
|
6
|
-
* @param {Schema} s
|
|
7
|
-
* @returns {GetValidRequestEnvsResult}
|
|
8
|
-
*/
|
|
4
|
+
* Get valid request environment
|
|
5
|
+
*/
|
|
9
6
|
export function getValidRequestEnvsTemplate(t: Template, s: Schema): GetValidRequestEnvsResult;
|
|
10
7
|
/**
|
|
11
|
-
* Get valid request environment
|
|
12
|
-
|
|
13
|
-
* @param {Schema} s
|
|
14
|
-
* @returns {GetValidRequestEnvsResult}
|
|
15
|
-
*/
|
|
8
|
+
* Get valid request environment
|
|
9
|
+
*/
|
|
16
10
|
export function getValidRequestEnvsPolicy(t: Policy, s: Schema): GetValidRequestEnvsResult;
|
|
17
|
-
/**
|
|
18
|
-
* @returns {string}
|
|
19
|
-
*/
|
|
20
11
|
export function getCedarVersion(): string;
|
|
12
|
+
export function getCedarSDKVersion(): string;
|
|
21
13
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Parse a policy set and optionally validate it against a provided schema
|
|
29
|
-
*
|
|
30
|
-
* This is the basic validator interface, using [`ValidationCall`] and
|
|
31
|
-
* [`ValidationAnswer`] types
|
|
32
|
-
* @param {ValidationCall} call
|
|
33
|
-
* @returns {ValidationAnswer}
|
|
34
|
-
*/
|
|
14
|
+
* Parse a policy set and optionally validate it against a provided schema
|
|
15
|
+
*
|
|
16
|
+
* This is the basic validator interface, using [`ValidationCall`] and
|
|
17
|
+
* [`ValidationAnswer`] types
|
|
18
|
+
*/
|
|
35
19
|
export function validate(call: ValidationCall): ValidationAnswer;
|
|
36
20
|
/**
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*/
|
|
41
|
-
export function formatPolicies(call: FormattingCall): FormattingAnswer;
|
|
21
|
+
* Get language version of Cedar
|
|
22
|
+
*/
|
|
23
|
+
export function getCedarLangVersion(): string;
|
|
42
24
|
/**
|
|
43
|
-
* Return the Cedar (textual) representation of a policy.
|
|
44
|
-
|
|
45
|
-
* @returns {PolicyToTextAnswer}
|
|
46
|
-
*/
|
|
25
|
+
* Return the Cedar (textual) representation of a policy.
|
|
26
|
+
*/
|
|
47
27
|
export function policyToText(policy: Policy): PolicyToTextAnswer;
|
|
48
28
|
/**
|
|
49
|
-
* Return the Cedar (textual) representation of a template.
|
|
50
|
-
|
|
51
|
-
* @returns {PolicyToTextAnswer}
|
|
52
|
-
*/
|
|
29
|
+
* Return the Cedar (textual) representation of a template.
|
|
30
|
+
*/
|
|
53
31
|
export function templateToText(template: Template): PolicyToTextAnswer;
|
|
54
32
|
/**
|
|
55
|
-
* Return the JSON representation of a policy.
|
|
56
|
-
|
|
57
|
-
* @returns {PolicyToJsonAnswer}
|
|
58
|
-
*/
|
|
33
|
+
* Return the JSON representation of a policy.
|
|
34
|
+
*/
|
|
59
35
|
export function policyToJson(policy: Policy): PolicyToJsonAnswer;
|
|
60
36
|
/**
|
|
61
|
-
* Return the JSON representation of a template.
|
|
62
|
-
|
|
63
|
-
* @returns {PolicyToJsonAnswer}
|
|
64
|
-
*/
|
|
37
|
+
* Return the JSON representation of a template.
|
|
38
|
+
*/
|
|
65
39
|
export function templateToJson(template: Template): PolicyToJsonAnswer;
|
|
66
40
|
/**
|
|
67
|
-
* Return the Cedar (textual) representation of a schema.
|
|
68
|
-
|
|
69
|
-
* @returns {SchemaToTextAnswer}
|
|
70
|
-
*/
|
|
41
|
+
* Return the Cedar (textual) representation of a schema.
|
|
42
|
+
*/
|
|
71
43
|
export function schemaToText(schema: Schema): SchemaToTextAnswer;
|
|
72
44
|
/**
|
|
73
|
-
* Return the JSON representation of a schema.
|
|
74
|
-
|
|
75
|
-
* @returns {SchemaToJsonAnswer}
|
|
76
|
-
*/
|
|
45
|
+
* Return the JSON representation of a schema.
|
|
46
|
+
*/
|
|
77
47
|
export function schemaToJson(schema: Schema): SchemaToJsonAnswer;
|
|
78
48
|
/**
|
|
79
|
-
* Check whether a policy set successfully parses.
|
|
80
|
-
|
|
81
|
-
* @returns {CheckParseAnswer}
|
|
82
|
-
*/
|
|
49
|
+
* Check whether a policy set successfully parses.
|
|
50
|
+
*/
|
|
83
51
|
export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
|
|
84
52
|
/**
|
|
85
|
-
* Check whether a schema successfully parses.
|
|
86
|
-
|
|
87
|
-
* @returns {CheckParseAnswer}
|
|
88
|
-
*/
|
|
53
|
+
* Check whether a schema successfully parses.
|
|
54
|
+
*/
|
|
89
55
|
export function checkParseSchema(schema: Schema): CheckParseAnswer;
|
|
90
56
|
/**
|
|
91
|
-
* Check whether a set of entities successfully parses.
|
|
92
|
-
|
|
93
|
-
* @returns {CheckParseAnswer}
|
|
94
|
-
*/
|
|
57
|
+
* Check whether a set of entities successfully parses.
|
|
58
|
+
*/
|
|
95
59
|
export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
|
|
96
60
|
/**
|
|
97
|
-
* Check whether a context successfully parses.
|
|
98
|
-
|
|
99
|
-
* @returns {CheckParseAnswer}
|
|
100
|
-
*/
|
|
61
|
+
* Check whether a context successfully parses.
|
|
62
|
+
*/
|
|
101
63
|
export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
|
|
64
|
+
/**
|
|
65
|
+
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
66
|
+
*/
|
|
67
|
+
export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
68
|
+
/**
|
|
69
|
+
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
70
|
+
*/
|
|
71
|
+
export function formatPolicies(call: FormattingCall): FormattingAnswer;
|
|
102
72
|
export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
|
|
103
73
|
|
|
104
|
-
export interface Response {
|
|
105
|
-
decision: Decision;
|
|
106
|
-
diagnostics: Diagnostics;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface Diagnostics {
|
|
110
|
-
reason: PolicyId[];
|
|
111
|
-
errors: AuthorizationError[];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface AuthorizationError {
|
|
115
|
-
policyId: string;
|
|
116
|
-
error: DetailedError;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export type AuthorizationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; response: Response; warnings: DetailedError[] };
|
|
120
|
-
|
|
121
|
-
export interface AuthorizationCall {
|
|
122
|
-
principal: EntityUid;
|
|
123
|
-
action: EntityUid;
|
|
124
|
-
resource: EntityUid;
|
|
125
|
-
context: Context;
|
|
126
|
-
schema?: Schema;
|
|
127
|
-
validateRequest?: boolean;
|
|
128
|
-
policies: PolicySet;
|
|
129
|
-
entities: Entities;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
74
|
export interface ValidationCall {
|
|
133
75
|
validationSettings?: ValidationSettings;
|
|
134
76
|
schema: Schema;
|
|
@@ -146,14 +88,6 @@ export interface ValidationError {
|
|
|
146
88
|
|
|
147
89
|
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
148
90
|
|
|
149
|
-
export interface FormattingCall {
|
|
150
|
-
policyText: string;
|
|
151
|
-
lineWidth?: number;
|
|
152
|
-
indentWidth?: number;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
|
|
156
|
-
|
|
157
91
|
export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
|
|
158
92
|
|
|
159
93
|
export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
|
|
@@ -162,7 +96,9 @@ export type SchemaToTextAnswer = { type: "success"; text: string; warnings: Deta
|
|
|
162
96
|
|
|
163
97
|
export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
|
|
164
98
|
|
|
165
|
-
export type
|
|
99
|
+
export type SlotId = string;
|
|
100
|
+
|
|
101
|
+
export type PolicyId = string;
|
|
166
102
|
|
|
167
103
|
export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
|
|
168
104
|
|
|
@@ -177,9 +113,41 @@ export interface ContextParsingCall {
|
|
|
177
113
|
action?: EntityUid | null;
|
|
178
114
|
}
|
|
179
115
|
|
|
180
|
-
export
|
|
116
|
+
export interface Response {
|
|
117
|
+
decision: Decision;
|
|
118
|
+
diagnostics: Diagnostics;
|
|
119
|
+
}
|
|
181
120
|
|
|
182
|
-
export
|
|
121
|
+
export interface Diagnostics {
|
|
122
|
+
reason: PolicyId[];
|
|
123
|
+
errors: AuthorizationError[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface AuthorizationError {
|
|
127
|
+
policyId: string;
|
|
128
|
+
error: DetailedError;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type AuthorizationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; response: Response; warnings: DetailedError[] };
|
|
132
|
+
|
|
133
|
+
export interface AuthorizationCall {
|
|
134
|
+
principal: EntityUid;
|
|
135
|
+
action: EntityUid;
|
|
136
|
+
resource: EntityUid;
|
|
137
|
+
context: Context;
|
|
138
|
+
schema?: Schema;
|
|
139
|
+
validateRequest?: boolean;
|
|
140
|
+
policies: PolicySet;
|
|
141
|
+
entities: Entities;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface FormattingCall {
|
|
145
|
+
policyText: string;
|
|
146
|
+
lineWidth?: number;
|
|
147
|
+
indentWidth?: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
|
|
183
151
|
|
|
184
152
|
export type Schema = string | SchemaJson<string>;
|
|
185
153
|
|
|
@@ -228,6 +196,8 @@ export interface DetailedError {
|
|
|
228
196
|
related?: DetailedError[];
|
|
229
197
|
}
|
|
230
198
|
|
|
199
|
+
export type ValidationMode = "strict";
|
|
200
|
+
|
|
231
201
|
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 };
|
|
232
202
|
|
|
233
203
|
export interface RecordType<N> {
|
|
@@ -235,7 +205,7 @@ export interface RecordType<N> {
|
|
|
235
205
|
additionalAttributes?: boolean;
|
|
236
206
|
}
|
|
237
207
|
|
|
238
|
-
export type Type<N> = TypeVariant<N> | { type: N };
|
|
208
|
+
export type Type<N> = ({} & TypeVariant<N>) | { type: N };
|
|
239
209
|
|
|
240
210
|
export interface ActionEntityUID<N> {
|
|
241
211
|
id: SmolStr;
|
|
@@ -252,6 +222,7 @@ export interface ActionType<N> {
|
|
|
252
222
|
attributes?: Record<SmolStr, CedarValueJson>;
|
|
253
223
|
appliesTo?: ApplySpec<N>;
|
|
254
224
|
memberOf?: ActionEntityUID<N>[];
|
|
225
|
+
annotations?: Annotations;
|
|
255
226
|
}
|
|
256
227
|
|
|
257
228
|
export type AttributesOrContext<N> = Type<N>;
|
|
@@ -260,41 +231,20 @@ export interface EntityType<N> {
|
|
|
260
231
|
memberOfTypes?: N[];
|
|
261
232
|
shape?: AttributesOrContext<N>;
|
|
262
233
|
tags?: Type<N>;
|
|
234
|
+
annotations?: Annotations;
|
|
263
235
|
}
|
|
264
236
|
|
|
265
237
|
export interface NamespaceDefinition<N> {
|
|
266
|
-
commonTypes?: Record<CommonTypeId,
|
|
238
|
+
commonTypes?: Record<CommonTypeId, CommonType<N>>;
|
|
267
239
|
entityTypes: Record<UnreservedId, EntityType<N>>;
|
|
268
240
|
actions: Record<SmolStr, ActionType<N>>;
|
|
241
|
+
annotations?: Annotations;
|
|
269
242
|
}
|
|
270
243
|
|
|
271
244
|
export type CommonTypeId = string;
|
|
272
245
|
|
|
273
246
|
export type SchemaJson<N> = Record<string, NamespaceDefinition<N>>;
|
|
274
247
|
|
|
275
|
-
export type Decision = "allow" | "deny";
|
|
276
|
-
|
|
277
|
-
export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
|
|
278
|
-
|
|
279
|
-
export interface PolicyJson {
|
|
280
|
-
effect: Effect;
|
|
281
|
-
principal: PrincipalConstraint;
|
|
282
|
-
action: ActionConstraint;
|
|
283
|
-
resource: ResourceConstraint;
|
|
284
|
-
conditions: Clause[];
|
|
285
|
-
annotations?: Record<string, string>;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
289
|
-
|
|
290
|
-
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 } } | { 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> };
|
|
291
|
-
|
|
292
|
-
export type PatternElem = "Wildcard" | { Literal: SmolStr };
|
|
293
|
-
|
|
294
|
-
export type Expr = ExprNoExt | ExtFuncCall;
|
|
295
|
-
|
|
296
|
-
export type Effect = "permit" | "forbid";
|
|
297
|
-
|
|
298
248
|
export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
|
|
299
249
|
|
|
300
250
|
export interface PrincipalOrResourceIsConstraint {
|
|
@@ -312,12 +262,7 @@ export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | (
|
|
|
312
262
|
|
|
313
263
|
export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
314
264
|
|
|
315
|
-
export
|
|
316
|
-
uid: EntityUidJson;
|
|
317
|
-
attrs: Record<string, CedarValueJson>;
|
|
318
|
-
parents: EntityUidJson[];
|
|
319
|
-
tags?: Record<string, CedarValueJson>;
|
|
320
|
-
}
|
|
265
|
+
export type Var = "principal" | "action" | "resource" | "context";
|
|
321
266
|
|
|
322
267
|
export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
|
|
323
268
|
|
|
@@ -333,9 +278,44 @@ export interface TypeAndId {
|
|
|
333
278
|
|
|
334
279
|
export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
335
280
|
|
|
281
|
+
export type Annotations = Record<string, Annotation>;
|
|
282
|
+
|
|
283
|
+
export interface EntityJson {
|
|
284
|
+
uid: EntityUidJson;
|
|
285
|
+
attrs: Record<string, CedarValueJson>;
|
|
286
|
+
parents: EntityUidJson[];
|
|
287
|
+
tags?: Record<string, CedarValueJson>;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export type Decision = "allow" | "deny";
|
|
291
|
+
|
|
292
|
+
export type Annotation = SmolStr;
|
|
293
|
+
|
|
294
|
+
export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
|
|
295
|
+
|
|
296
|
+
export interface PolicyJson {
|
|
297
|
+
effect: Effect;
|
|
298
|
+
principal: PrincipalConstraint;
|
|
299
|
+
action: ActionConstraint;
|
|
300
|
+
resource: ResourceConstraint;
|
|
301
|
+
conditions: Clause[];
|
|
302
|
+
annotations?: Annotations;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
306
|
+
|
|
307
|
+
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> };
|
|
308
|
+
|
|
309
|
+
export type PatternElem = "Wildcard" | { Literal: SmolStr };
|
|
310
|
+
|
|
311
|
+
export type Expr = ExprNoExt | ExtFuncCall;
|
|
312
|
+
|
|
313
|
+
export type AnyId = SmolStr;
|
|
314
|
+
|
|
336
315
|
export type UnreservedId = string;
|
|
337
316
|
|
|
338
|
-
export type
|
|
317
|
+
export type Effect = "permit" | "forbid";
|
|
339
318
|
|
|
340
319
|
type SmolStr = string;
|
|
341
320
|
export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
|
|
321
|
+
export type CommonType<N> = Type<N> & { annotations?: Annotations };
|
package/esm/cedar_wasm.js
CHANGED