@cedar-policy/cedar-wasm 3.3.0 → 3.4.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.
@@ -21,13 +21,6 @@ export function checkParsePolicySet(input_policies_str: string): CheckParsePolic
21
21
  */
22
22
  export function checkParseTemplate(template_str: string): CheckParseTemplateResult;
23
23
  /**
24
- * @param {string} policies_str
25
- * @param {number} line_width
26
- * @param {number} indent_width
27
- * @returns {FormattingResult}
28
- */
29
- export function formatPolicies(policies_str: string, line_width: number, indent_width: number): FormattingResult;
30
- /**
31
24
  * @param {string} input_schema
32
25
  * @returns {CheckParseResult}
33
26
  */
@@ -46,6 +39,18 @@ export function checkParseEntities(entities_str: string, schema_str: string): Ch
46
39
  */
47
40
  export function checkParseContext(context_str: string, action_str: string, schema_str: string): CheckParseResult;
48
41
  /**
42
+ * @param {string} policies_str
43
+ * @param {number} line_width
44
+ * @param {number} indent_width
45
+ * @returns {FormattingResult}
46
+ */
47
+ export function formatPolicies(policies_str: string, line_width: number, indent_width: number): FormattingResult;
48
+ /**
49
+ * @param {ValidationCall} call
50
+ * @returns {ValidationAnswer}
51
+ */
52
+ export function validate(call: ValidationCall): ValidationAnswer;
53
+ /**
49
54
  * @returns {string}
50
55
  */
51
56
  export function getCedarVersion(): string;
@@ -54,11 +59,6 @@ export function getCedarVersion(): string;
54
59
  * @returns {AuthorizationAnswer}
55
60
  */
56
61
  export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
57
- /**
58
- * @param {ValidationCall} call
59
- * @returns {ValidationAnswer}
60
- */
61
- export function validate(call: ValidationCall): ValidationAnswer;
62
62
  export type JsonToPolicyResult = { type: "success"; policyText: string } | { type: "error"; errors: string[] };
63
63
 
64
64
  export type PolicyToJsonResult = { type: "success"; policy: Policy } | { type: "error"; errors: string[] };
@@ -67,34 +67,9 @@ export type CheckParsePolicySetResult = { type: "success"; policies: number; tem
67
67
 
68
68
  export type CheckParseTemplateResult = { type: "success"; slots: string[] } | { type: "error"; errors: string[] };
69
69
 
70
- export type FormattingResult = { type: "success"; formatted_policy: string } | { type: "error"; errors: string[] };
71
-
72
70
  export type CheckParseResult = { type: "success" } | { type: "error"; errors: string[] };
73
71
 
74
- export type Schema = { human: string } | { json: SchemaJson };
75
-
76
- export type PolicySet = string | Record<string, string>;
77
-
78
- export interface SourceLocation {
79
- start: number;
80
- end: number;
81
- }
82
-
83
- export interface SourceLabel extends SourceLocation {
84
- label: string | null;
85
- }
86
-
87
- export type Severity = "advice" | "warning" | "error";
88
-
89
- export interface DetailedError {
90
- message: string;
91
- help: string | null;
92
- code: string | null;
93
- url: string | null;
94
- severity: Severity | null;
95
- sourceLocations?: SourceLabel[];
96
- related?: DetailedError[];
97
- }
72
+ export type FormattingResult = { type: "success"; formatted_policy: string } | { type: "error"; errors: string[] };
98
73
 
99
74
  export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
100
75
 
@@ -167,6 +142,31 @@ export interface Response {
167
142
  diagnostics: Diagnostics;
168
143
  }
169
144
 
145
+ export type Schema = { human: string } | { json: SchemaJson };
146
+
147
+ export type PolicySet = string | Record<string, string>;
148
+
149
+ export interface SourceLocation {
150
+ start: number;
151
+ end: number;
152
+ }
153
+
154
+ export interface SourceLabel extends SourceLocation {
155
+ label: string | null;
156
+ }
157
+
158
+ export type Severity = "advice" | "warning" | "error";
159
+
160
+ export interface DetailedError {
161
+ message: string;
162
+ help: string | null;
163
+ code: string | null;
164
+ url: string | null;
165
+ severity: Severity | null;
166
+ sourceLocations?: SourceLabel[];
167
+ related?: DetailedError[];
168
+ }
169
+
170
170
  export type SchemaTypeVariant = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: SchemaType } | { type: "Record"; attributes: Record<SmolStr, TypeOfAttribute>; additionalAttributes: boolean } | { type: "Entity"; name: Name } | { type: "Extension"; name: Id };
171
171
 
172
172
  export type SchemaType = SchemaTypeVariant | { type: Name };
@@ -234,16 +234,10 @@ export interface TypeAndId {
234
234
 
235
235
  export type CedarValueJson = { __expr: string } | { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
236
236
 
237
- export type ExtFuncCall = {} & Record<string, Array<Expr>>;
238
-
239
- export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: 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 } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
240
-
241
- export type Expr = ExprNoExt | ExtFuncCall;
242
-
243
- export type Decision = "Allow" | "Deny";
244
-
245
237
  export type Effect = "permit" | "forbid";
246
238
 
239
+ export type Var = "principal" | "action" | "resource" | "context";
240
+
247
241
  export interface EntityJson {
248
242
  uid: EntityUidJson;
249
243
  attrs: Record<string, CedarValueJson>;
@@ -261,7 +255,13 @@ export interface Policy {
261
255
  annotations?: Record<string, string>;
262
256
  }
263
257
 
264
- export type Var = "principal" | "action" | "resource" | "context";
258
+ export type ExtFuncCall = {} & Record<string, Array<Expr>>;
259
+
260
+ export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: 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 } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
261
+
262
+ export type Expr = ExprNoExt | ExtFuncCall;
263
+
264
+ export type Decision = "Allow" | "Deny";
265
265
 
266
266
  type SmolStr = string;
267
267
  type Name = string;
@@ -167,19 +167,6 @@ export function checkParseTemplate(template_str) {
167
167
  return takeObject(ret);
168
168
  }
169
169
 
170
- /**
171
- * @param {string} policies_str
172
- * @param {number} line_width
173
- * @param {number} indent_width
174
- * @returns {FormattingResult}
175
- */
176
- export function formatPolicies(policies_str, line_width, indent_width) {
177
- const ptr0 = passStringToWasm0(policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
178
- const len0 = WASM_VECTOR_LEN;
179
- const ret = wasm.formatPolicies(ptr0, len0, line_width, indent_width);
180
- return takeObject(ret);
181
- }
182
-
183
170
  /**
184
171
  * @param {string} input_schema
185
172
  * @returns {CheckParseResult}
@@ -222,6 +209,28 @@ export function checkParseContext(context_str, action_str, schema_str) {
222
209
  return takeObject(ret);
223
210
  }
224
211
 
212
+ /**
213
+ * @param {string} policies_str
214
+ * @param {number} line_width
215
+ * @param {number} indent_width
216
+ * @returns {FormattingResult}
217
+ */
218
+ export function formatPolicies(policies_str, line_width, indent_width) {
219
+ const ptr0 = passStringToWasm0(policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
+ const len0 = WASM_VECTOR_LEN;
221
+ const ret = wasm.formatPolicies(ptr0, len0, line_width, indent_width);
222
+ return takeObject(ret);
223
+ }
224
+
225
+ /**
226
+ * @param {ValidationCall} call
227
+ * @returns {ValidationAnswer}
228
+ */
229
+ export function validate(call) {
230
+ const ret = wasm.validate(addHeapObject(call));
231
+ return takeObject(ret);
232
+ }
233
+
225
234
  /**
226
235
  * @returns {string}
227
236
  */
@@ -251,15 +260,6 @@ export function isAuthorized(call) {
251
260
  return takeObject(ret);
252
261
  }
253
262
 
254
- /**
255
- * @param {ValidationCall} call
256
- * @returns {ValidationAnswer}
257
- */
258
- export function validate(call) {
259
- const ret = wasm.validate(addHeapObject(call));
260
- return takeObject(ret);
261
- }
262
-
263
263
  function handleError(f, args) {
264
264
  try {
265
265
  return f.apply(this, args);
Binary file
@@ -5,13 +5,13 @@ export function policyTextFromJson(a: number, b: number): number;
5
5
  export function policyTextToJson(a: number, b: number): number;
6
6
  export function checkParsePolicySet(a: number, b: number): number;
7
7
  export function checkParseTemplate(a: number, b: number): number;
8
- export function formatPolicies(a: number, b: number, c: number, d: number): number;
9
8
  export function checkParseSchema(a: number, b: number): number;
10
9
  export function checkParseEntities(a: number, b: number, c: number, d: number): number;
11
10
  export function checkParseContext(a: number, b: number, c: number, d: number, e: number, f: number): number;
11
+ export function formatPolicies(a: number, b: number, c: number, d: number): number;
12
+ export function validate(a: number): number;
12
13
  export function getCedarVersion(a: number): void;
13
14
  export function isAuthorized(a: number): number;
14
- export function validate(a: number): number;
15
15
  export function __wbindgen_malloc(a: number, b: number): number;
16
16
  export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
17
17
  export function __wbindgen_add_to_stack_pointer(a: number): number;
package/esm/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
3
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "3.3.0",
4
+ "version": "3.4.0",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
7
  "cedar_wasm_bg.wasm",
@@ -21,13 +21,6 @@ export function checkParsePolicySet(input_policies_str: string): CheckParsePolic
21
21
  */
22
22
  export function checkParseTemplate(template_str: string): CheckParseTemplateResult;
23
23
  /**
24
- * @param {string} policies_str
25
- * @param {number} line_width
26
- * @param {number} indent_width
27
- * @returns {FormattingResult}
28
- */
29
- export function formatPolicies(policies_str: string, line_width: number, indent_width: number): FormattingResult;
30
- /**
31
24
  * @param {string} input_schema
32
25
  * @returns {CheckParseResult}
33
26
  */
@@ -46,6 +39,18 @@ export function checkParseEntities(entities_str: string, schema_str: string): Ch
46
39
  */
47
40
  export function checkParseContext(context_str: string, action_str: string, schema_str: string): CheckParseResult;
48
41
  /**
42
+ * @param {string} policies_str
43
+ * @param {number} line_width
44
+ * @param {number} indent_width
45
+ * @returns {FormattingResult}
46
+ */
47
+ export function formatPolicies(policies_str: string, line_width: number, indent_width: number): FormattingResult;
48
+ /**
49
+ * @param {ValidationCall} call
50
+ * @returns {ValidationAnswer}
51
+ */
52
+ export function validate(call: ValidationCall): ValidationAnswer;
53
+ /**
49
54
  * @returns {string}
50
55
  */
51
56
  export function getCedarVersion(): string;
@@ -54,11 +59,6 @@ export function getCedarVersion(): string;
54
59
  * @returns {AuthorizationAnswer}
55
60
  */
56
61
  export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
57
- /**
58
- * @param {ValidationCall} call
59
- * @returns {ValidationAnswer}
60
- */
61
- export function validate(call: ValidationCall): ValidationAnswer;
62
62
  export type JsonToPolicyResult = { type: "success"; policyText: string } | { type: "error"; errors: string[] };
63
63
 
64
64
  export type PolicyToJsonResult = { type: "success"; policy: Policy } | { type: "error"; errors: string[] };
@@ -67,34 +67,9 @@ export type CheckParsePolicySetResult = { type: "success"; policies: number; tem
67
67
 
68
68
  export type CheckParseTemplateResult = { type: "success"; slots: string[] } | { type: "error"; errors: string[] };
69
69
 
70
- export type FormattingResult = { type: "success"; formatted_policy: string } | { type: "error"; errors: string[] };
71
-
72
70
  export type CheckParseResult = { type: "success" } | { type: "error"; errors: string[] };
73
71
 
74
- export type Schema = { human: string } | { json: SchemaJson };
75
-
76
- export type PolicySet = string | Record<string, string>;
77
-
78
- export interface SourceLocation {
79
- start: number;
80
- end: number;
81
- }
82
-
83
- export interface SourceLabel extends SourceLocation {
84
- label: string | null;
85
- }
86
-
87
- export type Severity = "advice" | "warning" | "error";
88
-
89
- export interface DetailedError {
90
- message: string;
91
- help: string | null;
92
- code: string | null;
93
- url: string | null;
94
- severity: Severity | null;
95
- sourceLocations?: SourceLabel[];
96
- related?: DetailedError[];
97
- }
72
+ export type FormattingResult = { type: "success"; formatted_policy: string } | { type: "error"; errors: string[] };
98
73
 
99
74
  export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
100
75
 
@@ -167,6 +142,31 @@ export interface Response {
167
142
  diagnostics: Diagnostics;
168
143
  }
169
144
 
145
+ export type Schema = { human: string } | { json: SchemaJson };
146
+
147
+ export type PolicySet = string | Record<string, string>;
148
+
149
+ export interface SourceLocation {
150
+ start: number;
151
+ end: number;
152
+ }
153
+
154
+ export interface SourceLabel extends SourceLocation {
155
+ label: string | null;
156
+ }
157
+
158
+ export type Severity = "advice" | "warning" | "error";
159
+
160
+ export interface DetailedError {
161
+ message: string;
162
+ help: string | null;
163
+ code: string | null;
164
+ url: string | null;
165
+ severity: Severity | null;
166
+ sourceLocations?: SourceLabel[];
167
+ related?: DetailedError[];
168
+ }
169
+
170
170
  export type SchemaTypeVariant = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: SchemaType } | { type: "Record"; attributes: Record<SmolStr, TypeOfAttribute>; additionalAttributes: boolean } | { type: "Entity"; name: Name } | { type: "Extension"; name: Id };
171
171
 
172
172
  export type SchemaType = SchemaTypeVariant | { type: Name };
@@ -234,16 +234,10 @@ export interface TypeAndId {
234
234
 
235
235
  export type CedarValueJson = { __expr: string } | { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
236
236
 
237
- export type ExtFuncCall = {} & Record<string, Array<Expr>>;
238
-
239
- export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: 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 } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
240
-
241
- export type Expr = ExprNoExt | ExtFuncCall;
242
-
243
- export type Decision = "Allow" | "Deny";
244
-
245
237
  export type Effect = "permit" | "forbid";
246
238
 
239
+ export type Var = "principal" | "action" | "resource" | "context";
240
+
247
241
  export interface EntityJson {
248
242
  uid: EntityUidJson;
249
243
  attrs: Record<string, CedarValueJson>;
@@ -261,7 +255,13 @@ export interface Policy {
261
255
  annotations?: Record<string, string>;
262
256
  }
263
257
 
264
- export type Var = "principal" | "action" | "resource" | "context";
258
+ export type ExtFuncCall = {} & Record<string, Array<Expr>>;
259
+
260
+ export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: 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 } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
261
+
262
+ export type Expr = ExprNoExt | ExtFuncCall;
263
+
264
+ export type Decision = "Allow" | "Deny";
265
265
 
266
266
  type SmolStr = string;
267
267
  type Name = string;
@@ -162,19 +162,6 @@ module.exports.checkParseTemplate = function(template_str) {
162
162
  return takeObject(ret);
163
163
  };
164
164
 
165
- /**
166
- * @param {string} policies_str
167
- * @param {number} line_width
168
- * @param {number} indent_width
169
- * @returns {FormattingResult}
170
- */
171
- module.exports.formatPolicies = function(policies_str, line_width, indent_width) {
172
- const ptr0 = passStringToWasm0(policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
173
- const len0 = WASM_VECTOR_LEN;
174
- const ret = wasm.formatPolicies(ptr0, len0, line_width, indent_width);
175
- return takeObject(ret);
176
- };
177
-
178
165
  /**
179
166
  * @param {string} input_schema
180
167
  * @returns {CheckParseResult}
@@ -217,6 +204,28 @@ module.exports.checkParseContext = function(context_str, action_str, schema_str)
217
204
  return takeObject(ret);
218
205
  };
219
206
 
207
+ /**
208
+ * @param {string} policies_str
209
+ * @param {number} line_width
210
+ * @param {number} indent_width
211
+ * @returns {FormattingResult}
212
+ */
213
+ module.exports.formatPolicies = function(policies_str, line_width, indent_width) {
214
+ const ptr0 = passStringToWasm0(policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
215
+ const len0 = WASM_VECTOR_LEN;
216
+ const ret = wasm.formatPolicies(ptr0, len0, line_width, indent_width);
217
+ return takeObject(ret);
218
+ };
219
+
220
+ /**
221
+ * @param {ValidationCall} call
222
+ * @returns {ValidationAnswer}
223
+ */
224
+ module.exports.validate = function(call) {
225
+ const ret = wasm.validate(addHeapObject(call));
226
+ return takeObject(ret);
227
+ };
228
+
220
229
  /**
221
230
  * @returns {string}
222
231
  */
@@ -246,15 +255,6 @@ module.exports.isAuthorized = function(call) {
246
255
  return takeObject(ret);
247
256
  };
248
257
 
249
- /**
250
- * @param {ValidationCall} call
251
- * @returns {ValidationAnswer}
252
- */
253
- module.exports.validate = function(call) {
254
- const ret = wasm.validate(addHeapObject(call));
255
- return takeObject(ret);
256
- };
257
-
258
258
  function handleError(f, args) {
259
259
  try {
260
260
  return f.apply(this, args);
Binary file
@@ -5,13 +5,13 @@ export function policyTextFromJson(a: number, b: number): number;
5
5
  export function policyTextToJson(a: number, b: number): number;
6
6
  export function checkParsePolicySet(a: number, b: number): number;
7
7
  export function checkParseTemplate(a: number, b: number): number;
8
- export function formatPolicies(a: number, b: number, c: number, d: number): number;
9
8
  export function checkParseSchema(a: number, b: number): number;
10
9
  export function checkParseEntities(a: number, b: number, c: number, d: number): number;
11
10
  export function checkParseContext(a: number, b: number, c: number, d: number, e: number, f: number): number;
11
+ export function formatPolicies(a: number, b: number, c: number, d: number): number;
12
+ export function validate(a: number): number;
12
13
  export function getCedarVersion(a: number): void;
13
14
  export function isAuthorized(a: number): number;
14
- export function validate(a: number): number;
15
15
  export function __wbindgen_malloc(a: number, b: number): number;
16
16
  export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
17
17
  export function __wbindgen_add_to_stack_pointer(a: number): number;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
3
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "3.3.0",
4
+ "version": "3.4.0",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
7
  "cedar_wasm_bg.wasm",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
3
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "3.3.0",
4
+ "version": "3.4.0",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
7
  "esm/package.json",
@@ -21,13 +21,6 @@ export function checkParsePolicySet(input_policies_str: string): CheckParsePolic
21
21
  */
22
22
  export function checkParseTemplate(template_str: string): CheckParseTemplateResult;
23
23
  /**
24
- * @param {string} policies_str
25
- * @param {number} line_width
26
- * @param {number} indent_width
27
- * @returns {FormattingResult}
28
- */
29
- export function formatPolicies(policies_str: string, line_width: number, indent_width: number): FormattingResult;
30
- /**
31
24
  * @param {string} input_schema
32
25
  * @returns {CheckParseResult}
33
26
  */
@@ -46,6 +39,18 @@ export function checkParseEntities(entities_str: string, schema_str: string): Ch
46
39
  */
47
40
  export function checkParseContext(context_str: string, action_str: string, schema_str: string): CheckParseResult;
48
41
  /**
42
+ * @param {string} policies_str
43
+ * @param {number} line_width
44
+ * @param {number} indent_width
45
+ * @returns {FormattingResult}
46
+ */
47
+ export function formatPolicies(policies_str: string, line_width: number, indent_width: number): FormattingResult;
48
+ /**
49
+ * @param {ValidationCall} call
50
+ * @returns {ValidationAnswer}
51
+ */
52
+ export function validate(call: ValidationCall): ValidationAnswer;
53
+ /**
49
54
  * @returns {string}
50
55
  */
51
56
  export function getCedarVersion(): string;
@@ -54,11 +59,6 @@ export function getCedarVersion(): string;
54
59
  * @returns {AuthorizationAnswer}
55
60
  */
56
61
  export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
57
- /**
58
- * @param {ValidationCall} call
59
- * @returns {ValidationAnswer}
60
- */
61
- export function validate(call: ValidationCall): ValidationAnswer;
62
62
  export type JsonToPolicyResult = { type: "success"; policyText: string } | { type: "error"; errors: string[] };
63
63
 
64
64
  export type PolicyToJsonResult = { type: "success"; policy: Policy } | { type: "error"; errors: string[] };
@@ -67,34 +67,9 @@ export type CheckParsePolicySetResult = { type: "success"; policies: number; tem
67
67
 
68
68
  export type CheckParseTemplateResult = { type: "success"; slots: string[] } | { type: "error"; errors: string[] };
69
69
 
70
- export type FormattingResult = { type: "success"; formatted_policy: string } | { type: "error"; errors: string[] };
71
-
72
70
  export type CheckParseResult = { type: "success" } | { type: "error"; errors: string[] };
73
71
 
74
- export type Schema = { human: string } | { json: SchemaJson };
75
-
76
- export type PolicySet = string | Record<string, string>;
77
-
78
- export interface SourceLocation {
79
- start: number;
80
- end: number;
81
- }
82
-
83
- export interface SourceLabel extends SourceLocation {
84
- label: string | null;
85
- }
86
-
87
- export type Severity = "advice" | "warning" | "error";
88
-
89
- export interface DetailedError {
90
- message: string;
91
- help: string | null;
92
- code: string | null;
93
- url: string | null;
94
- severity: Severity | null;
95
- sourceLocations?: SourceLabel[];
96
- related?: DetailedError[];
97
- }
72
+ export type FormattingResult = { type: "success"; formatted_policy: string } | { type: "error"; errors: string[] };
98
73
 
99
74
  export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
100
75
 
@@ -167,6 +142,31 @@ export interface Response {
167
142
  diagnostics: Diagnostics;
168
143
  }
169
144
 
145
+ export type Schema = { human: string } | { json: SchemaJson };
146
+
147
+ export type PolicySet = string | Record<string, string>;
148
+
149
+ export interface SourceLocation {
150
+ start: number;
151
+ end: number;
152
+ }
153
+
154
+ export interface SourceLabel extends SourceLocation {
155
+ label: string | null;
156
+ }
157
+
158
+ export type Severity = "advice" | "warning" | "error";
159
+
160
+ export interface DetailedError {
161
+ message: string;
162
+ help: string | null;
163
+ code: string | null;
164
+ url: string | null;
165
+ severity: Severity | null;
166
+ sourceLocations?: SourceLabel[];
167
+ related?: DetailedError[];
168
+ }
169
+
170
170
  export type SchemaTypeVariant = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: SchemaType } | { type: "Record"; attributes: Record<SmolStr, TypeOfAttribute>; additionalAttributes: boolean } | { type: "Entity"; name: Name } | { type: "Extension"; name: Id };
171
171
 
172
172
  export type SchemaType = SchemaTypeVariant | { type: Name };
@@ -234,16 +234,10 @@ export interface TypeAndId {
234
234
 
235
235
  export type CedarValueJson = { __expr: string } | { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
236
236
 
237
- export type ExtFuncCall = {} & Record<string, Array<Expr>>;
238
-
239
- export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: 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 } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
240
-
241
- export type Expr = ExprNoExt | ExtFuncCall;
242
-
243
- export type Decision = "Allow" | "Deny";
244
-
245
237
  export type Effect = "permit" | "forbid";
246
238
 
239
+ export type Var = "principal" | "action" | "resource" | "context";
240
+
247
241
  export interface EntityJson {
248
242
  uid: EntityUidJson;
249
243
  attrs: Record<string, CedarValueJson>;
@@ -261,7 +255,13 @@ export interface Policy {
261
255
  annotations?: Record<string, string>;
262
256
  }
263
257
 
264
- export type Var = "principal" | "action" | "resource" | "context";
258
+ export type ExtFuncCall = {} & Record<string, Array<Expr>>;
259
+
260
+ export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: 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 } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
261
+
262
+ export type Expr = ExprNoExt | ExtFuncCall;
263
+
264
+ export type Decision = "Allow" | "Deny";
265
265
 
266
266
 
267
267
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -272,13 +272,13 @@ export interface InitOutput {
272
272
  readonly policyTextToJson: (a: number, b: number) => number;
273
273
  readonly checkParsePolicySet: (a: number, b: number) => number;
274
274
  readonly checkParseTemplate: (a: number, b: number) => number;
275
- readonly formatPolicies: (a: number, b: number, c: number, d: number) => number;
276
275
  readonly checkParseSchema: (a: number, b: number) => number;
277
276
  readonly checkParseEntities: (a: number, b: number, c: number, d: number) => number;
278
277
  readonly checkParseContext: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
278
+ readonly formatPolicies: (a: number, b: number, c: number, d: number) => number;
279
+ readonly validate: (a: number) => number;
279
280
  readonly getCedarVersion: (a: number) => void;
280
281
  readonly isAuthorized: (a: number) => number;
281
- readonly validate: (a: number) => number;
282
282
  readonly __wbindgen_malloc: (a: number, b: number) => number;
283
283
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
284
284
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
package/web/cedar_wasm.js CHANGED
@@ -159,19 +159,6 @@ export function checkParseTemplate(template_str) {
159
159
  return takeObject(ret);
160
160
  }
161
161
 
162
- /**
163
- * @param {string} policies_str
164
- * @param {number} line_width
165
- * @param {number} indent_width
166
- * @returns {FormattingResult}
167
- */
168
- export function formatPolicies(policies_str, line_width, indent_width) {
169
- const ptr0 = passStringToWasm0(policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
170
- const len0 = WASM_VECTOR_LEN;
171
- const ret = wasm.formatPolicies(ptr0, len0, line_width, indent_width);
172
- return takeObject(ret);
173
- }
174
-
175
162
  /**
176
163
  * @param {string} input_schema
177
164
  * @returns {CheckParseResult}
@@ -214,6 +201,28 @@ export function checkParseContext(context_str, action_str, schema_str) {
214
201
  return takeObject(ret);
215
202
  }
216
203
 
204
+ /**
205
+ * @param {string} policies_str
206
+ * @param {number} line_width
207
+ * @param {number} indent_width
208
+ * @returns {FormattingResult}
209
+ */
210
+ export function formatPolicies(policies_str, line_width, indent_width) {
211
+ const ptr0 = passStringToWasm0(policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
212
+ const len0 = WASM_VECTOR_LEN;
213
+ const ret = wasm.formatPolicies(ptr0, len0, line_width, indent_width);
214
+ return takeObject(ret);
215
+ }
216
+
217
+ /**
218
+ * @param {ValidationCall} call
219
+ * @returns {ValidationAnswer}
220
+ */
221
+ export function validate(call) {
222
+ const ret = wasm.validate(addHeapObject(call));
223
+ return takeObject(ret);
224
+ }
225
+
217
226
  /**
218
227
  * @returns {string}
219
228
  */
@@ -243,15 +252,6 @@ export function isAuthorized(call) {
243
252
  return takeObject(ret);
244
253
  }
245
254
 
246
- /**
247
- * @param {ValidationCall} call
248
- * @returns {ValidationAnswer}
249
- */
250
- export function validate(call) {
251
- const ret = wasm.validate(addHeapObject(call));
252
- return takeObject(ret);
253
- }
254
-
255
255
  function handleError(f, args) {
256
256
  try {
257
257
  return f.apply(this, args);
Binary file
@@ -5,13 +5,13 @@ export function policyTextFromJson(a: number, b: number): number;
5
5
  export function policyTextToJson(a: number, b: number): number;
6
6
  export function checkParsePolicySet(a: number, b: number): number;
7
7
  export function checkParseTemplate(a: number, b: number): number;
8
- export function formatPolicies(a: number, b: number, c: number, d: number): number;
9
8
  export function checkParseSchema(a: number, b: number): number;
10
9
  export function checkParseEntities(a: number, b: number, c: number, d: number): number;
11
10
  export function checkParseContext(a: number, b: number, c: number, d: number, e: number, f: number): number;
11
+ export function formatPolicies(a: number, b: number, c: number, d: number): number;
12
+ export function validate(a: number): number;
12
13
  export function getCedarVersion(a: number): void;
13
14
  export function isAuthorized(a: number): number;
14
- export function validate(a: number): number;
15
15
  export function __wbindgen_malloc(a: number, b: number): number;
16
16
  export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
17
17
  export function __wbindgen_add_to_stack_pointer(a: number): number;
package/web/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
3
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "3.3.0",
4
+ "version": "3.4.0",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
7
  "cedar_wasm_bg.wasm",