@cedar-policy/cedar-wasm 4.2.0 → 4.2.2

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.
@@ -1,106 +1,128 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Get valid request environment
5
- * @param {Template} t
6
- * @param {Schema} s
7
- * @returns {GetValidRequestEnvsResult}
8
- */
4
+ * Get valid request environment
5
+ * @param {Template} t
6
+ * @param {Schema} s
7
+ * @returns {GetValidRequestEnvsResult}
8
+ */
9
9
  export function getValidRequestEnvsTemplate(t: Template, s: Schema): GetValidRequestEnvsResult;
10
10
  /**
11
- * Get valid request environment
12
- * @param {Policy} t
13
- * @param {Schema} s
14
- * @returns {GetValidRequestEnvsResult}
15
- */
11
+ * Get valid request environment
12
+ * @param {Policy} t
13
+ * @param {Schema} s
14
+ * @returns {GetValidRequestEnvsResult}
15
+ */
16
16
  export function getValidRequestEnvsPolicy(t: Policy, s: Schema): GetValidRequestEnvsResult;
17
17
  /**
18
- * @returns {string}
19
- */
18
+ * @returns {string}
19
+ */
20
20
  export function getCedarVersion(): string;
21
21
  /**
22
- * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
23
- * @param {AuthorizationCall} call
24
- * @returns {AuthorizationAnswer}
25
- */
26
- export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
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
- */
35
- export function validate(call: ValidationCall): ValidationAnswer;
36
- /**
37
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
38
- * @param {FormattingCall} call
39
- * @returns {FormattingAnswer}
40
- */
22
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
23
+ * @param {FormattingCall} call
24
+ * @returns {FormattingAnswer}
25
+ */
41
26
  export function formatPolicies(call: FormattingCall): FormattingAnswer;
42
27
  /**
43
- * Return the Cedar (textual) representation of a policy.
44
- * @param {Policy} policy
45
- * @returns {PolicyToTextAnswer}
46
- */
28
+ * Return the Cedar (textual) representation of a policy.
29
+ * @param {Policy} policy
30
+ * @returns {PolicyToTextAnswer}
31
+ */
47
32
  export function policyToText(policy: Policy): PolicyToTextAnswer;
48
33
  /**
49
- * Return the Cedar (textual) representation of a template.
50
- * @param {Template} template
51
- * @returns {PolicyToTextAnswer}
52
- */
34
+ * Return the Cedar (textual) representation of a template.
35
+ * @param {Template} template
36
+ * @returns {PolicyToTextAnswer}
37
+ */
53
38
  export function templateToText(template: Template): PolicyToTextAnswer;
54
39
  /**
55
- * Return the JSON representation of a policy.
56
- * @param {Policy} policy
57
- * @returns {PolicyToJsonAnswer}
58
- */
40
+ * Return the JSON representation of a policy.
41
+ * @param {Policy} policy
42
+ * @returns {PolicyToJsonAnswer}
43
+ */
59
44
  export function policyToJson(policy: Policy): PolicyToJsonAnswer;
60
45
  /**
61
- * Return the JSON representation of a template.
62
- * @param {Template} template
63
- * @returns {PolicyToJsonAnswer}
64
- */
46
+ * Return the JSON representation of a template.
47
+ * @param {Template} template
48
+ * @returns {PolicyToJsonAnswer}
49
+ */
65
50
  export function templateToJson(template: Template): PolicyToJsonAnswer;
66
51
  /**
67
- * Return the Cedar (textual) representation of a schema.
68
- * @param {Schema} schema
69
- * @returns {SchemaToTextAnswer}
70
- */
52
+ * Return the Cedar (textual) representation of a schema.
53
+ * @param {Schema} schema
54
+ * @returns {SchemaToTextAnswer}
55
+ */
71
56
  export function schemaToText(schema: Schema): SchemaToTextAnswer;
72
57
  /**
73
- * Return the JSON representation of a schema.
74
- * @param {Schema} schema
75
- * @returns {SchemaToJsonAnswer}
76
- */
58
+ * Return the JSON representation of a schema.
59
+ * @param {Schema} schema
60
+ * @returns {SchemaToJsonAnswer}
61
+ */
77
62
  export function schemaToJson(schema: Schema): SchemaToJsonAnswer;
78
63
  /**
79
- * Check whether a policy set successfully parses.
80
- * @param {PolicySet} policies
81
- * @returns {CheckParseAnswer}
82
- */
64
+ * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
65
+ * @param {AuthorizationCall} call
66
+ * @returns {AuthorizationAnswer}
67
+ */
68
+ export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
69
+ /**
70
+ * Parse a policy set and optionally validate it against a provided schema
71
+ *
72
+ * This is the basic validator interface, using [`ValidationCall`] and
73
+ * [`ValidationAnswer`] types
74
+ * @param {ValidationCall} call
75
+ * @returns {ValidationAnswer}
76
+ */
77
+ export function validate(call: ValidationCall): ValidationAnswer;
78
+ /**
79
+ * Check whether a policy set successfully parses.
80
+ * @param {PolicySet} policies
81
+ * @returns {CheckParseAnswer}
82
+ */
83
83
  export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
84
84
  /**
85
- * Check whether a schema successfully parses.
86
- * @param {Schema} schema
87
- * @returns {CheckParseAnswer}
88
- */
85
+ * Check whether a schema successfully parses.
86
+ * @param {Schema} schema
87
+ * @returns {CheckParseAnswer}
88
+ */
89
89
  export function checkParseSchema(schema: Schema): CheckParseAnswer;
90
90
  /**
91
- * Check whether a set of entities successfully parses.
92
- * @param {EntitiesParsingCall} call
93
- * @returns {CheckParseAnswer}
94
- */
91
+ * Check whether a set of entities successfully parses.
92
+ * @param {EntitiesParsingCall} call
93
+ * @returns {CheckParseAnswer}
94
+ */
95
95
  export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
96
96
  /**
97
- * Check whether a context successfully parses.
98
- * @param {ContextParsingCall} call
99
- * @returns {CheckParseAnswer}
100
- */
97
+ * Check whether a context successfully parses.
98
+ * @param {ContextParsingCall} call
99
+ * @returns {CheckParseAnswer}
100
+ */
101
101
  export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
102
102
  export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
103
103
 
104
+ export type SlotId = string;
105
+
106
+ export type PolicyId = string;
107
+
108
+ export type ValidationMode = "strict";
109
+
110
+ export interface FormattingCall {
111
+ policyText: string;
112
+ lineWidth?: number;
113
+ indentWidth?: number;
114
+ }
115
+
116
+ export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
117
+
118
+ export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
119
+
120
+ export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
121
+
122
+ export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
123
+
124
+ export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
125
+
104
126
  export interface Response {
105
127
  decision: Decision;
106
128
  diagnostics: Diagnostics;
@@ -146,24 +168,6 @@ export interface ValidationError {
146
168
 
147
169
  export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
148
170
 
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
- export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
158
-
159
- export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
160
-
161
- export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
162
-
163
- export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
164
-
165
- export type ValidationMode = "strict";
166
-
167
171
  export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
168
172
 
169
173
  export interface EntitiesParsingCall {
@@ -177,10 +181,6 @@ export interface ContextParsingCall {
177
181
  action?: EntityUid | null;
178
182
  }
179
183
 
180
- export type SlotId = string;
181
-
182
- export type PolicyId = string;
183
-
184
184
  export type Schema = string | SchemaJson<string>;
185
185
 
186
186
  export interface PolicySet {
@@ -272,8 +272,6 @@ export type CommonTypeId = string;
272
272
 
273
273
  export type SchemaJson<N> = Record<string, NamespaceDefinition<N>>;
274
274
 
275
- export type Decision = "allow" | "deny";
276
-
277
275
  export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
278
276
 
279
277
  export interface PolicyJson {
@@ -285,39 +283,28 @@ export interface PolicyJson {
285
283
  annotations?: Record<string, string>;
286
284
  }
287
285
 
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
286
  export type Effect = "permit" | "forbid";
297
287
 
298
- export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
288
+ export type UnreservedId = string;
299
289
 
300
- export interface PrincipalOrResourceIsConstraint {
301
- entity_type: string;
302
- in?: PrincipalOrResourceInConstraint;
290
+ export interface EntityJson {
291
+ uid: EntityUidJson;
292
+ attrs: Record<string, CedarValueJson>;
293
+ parents: EntityUidJson[];
294
+ tags?: Record<string, CedarValueJson>;
303
295
  }
304
296
 
305
- export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
297
+ export type Decision = "allow" | "deny";
306
298
 
307
- export type EqConstraint = { entity: EntityUidJson } | { slot: string };
299
+ export type Var = "principal" | "action" | "resource" | "context";
308
300
 
309
- export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
301
+ export type ExtFuncCall = {} & Record<string, Array<Expr>>;
310
302
 
311
- export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
303
+ 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> };
312
304
 
313
- export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
305
+ export type PatternElem = "Wildcard" | { Literal: SmolStr };
314
306
 
315
- export interface EntityJson {
316
- uid: EntityUidJson;
317
- attrs: Record<string, CedarValueJson>;
318
- parents: EntityUidJson[];
319
- tags?: Record<string, CedarValueJson>;
320
- }
307
+ export type Expr = ExprNoExt | ExtFuncCall;
321
308
 
322
309
  export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
323
310
 
@@ -333,9 +320,22 @@ export interface TypeAndId {
333
320
 
334
321
  export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
335
322
 
336
- export type UnreservedId = string;
323
+ export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
337
324
 
338
- export type Var = "principal" | "action" | "resource" | "context";
325
+ export interface PrincipalOrResourceIsConstraint {
326
+ entity_type: string;
327
+ in?: PrincipalOrResourceInConstraint;
328
+ }
329
+
330
+ export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
331
+
332
+ export type EqConstraint = { entity: EntityUidJson } | { slot: string };
333
+
334
+ export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
335
+
336
+ export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
337
+
338
+ export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
339
339
 
340
340
 
341
341
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -345,8 +345,6 @@ export interface InitOutput {
345
345
  readonly getValidRequestEnvsTemplate: (a: number, b: number) => number;
346
346
  readonly getValidRequestEnvsPolicy: (a: number, b: number) => number;
347
347
  readonly getCedarVersion: (a: number) => void;
348
- readonly isAuthorized: (a: number) => number;
349
- readonly validate: (a: number) => number;
350
348
  readonly formatPolicies: (a: number) => number;
351
349
  readonly policyToText: (a: number) => number;
352
350
  readonly templateToText: (a: number) => number;
@@ -354,6 +352,8 @@ export interface InitOutput {
354
352
  readonly templateToJson: (a: number) => number;
355
353
  readonly schemaToText: (a: number) => number;
356
354
  readonly schemaToJson: (a: number) => number;
355
+ readonly isAuthorized: (a: number) => number;
356
+ readonly validate: (a: number) => number;
357
357
  readonly checkParsePolicySet: (a: number) => number;
358
358
  readonly checkParseSchema: (a: number) => number;
359
359
  readonly checkParseEntities: (a: number) => number;
package/web/cedar_wasm.js CHANGED
@@ -116,30 +116,30 @@ function getStringFromWasm0(ptr, len) {
116
116
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
117
117
  }
118
118
  /**
119
- * Get valid request environment
120
- * @param {Template} t
121
- * @param {Schema} s
122
- * @returns {GetValidRequestEnvsResult}
123
- */
119
+ * Get valid request environment
120
+ * @param {Template} t
121
+ * @param {Schema} s
122
+ * @returns {GetValidRequestEnvsResult}
123
+ */
124
124
  export function getValidRequestEnvsTemplate(t, s) {
125
125
  const ret = wasm.getValidRequestEnvsTemplate(addHeapObject(t), addHeapObject(s));
126
126
  return takeObject(ret);
127
127
  }
128
128
 
129
129
  /**
130
- * Get valid request environment
131
- * @param {Policy} t
132
- * @param {Schema} s
133
- * @returns {GetValidRequestEnvsResult}
134
- */
130
+ * Get valid request environment
131
+ * @param {Policy} t
132
+ * @param {Schema} s
133
+ * @returns {GetValidRequestEnvsResult}
134
+ */
135
135
  export function getValidRequestEnvsPolicy(t, s) {
136
136
  const ret = wasm.getValidRequestEnvsPolicy(addHeapObject(t), addHeapObject(s));
137
137
  return takeObject(ret);
138
138
  }
139
139
 
140
140
  /**
141
- * @returns {string}
142
- */
141
+ * @returns {string}
142
+ */
143
143
  export function getCedarVersion() {
144
144
  let deferred1_0;
145
145
  let deferred1_1;
@@ -158,133 +158,133 @@ export function getCedarVersion() {
158
158
  }
159
159
 
160
160
  /**
161
- * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
162
- * @param {AuthorizationCall} call
163
- * @returns {AuthorizationAnswer}
164
- */
165
- export function isAuthorized(call) {
166
- const ret = wasm.isAuthorized(addHeapObject(call));
167
- return takeObject(ret);
168
- }
169
-
170
- /**
171
- * Parse a policy set and optionally validate it against a provided schema
172
- *
173
- * This is the basic validator interface, using [`ValidationCall`] and
174
- * [`ValidationAnswer`] types
175
- * @param {ValidationCall} call
176
- * @returns {ValidationAnswer}
177
- */
178
- export function validate(call) {
179
- const ret = wasm.validate(addHeapObject(call));
180
- return takeObject(ret);
181
- }
182
-
183
- /**
184
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
185
- * @param {FormattingCall} call
186
- * @returns {FormattingAnswer}
187
- */
161
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
162
+ * @param {FormattingCall} call
163
+ * @returns {FormattingAnswer}
164
+ */
188
165
  export function formatPolicies(call) {
189
166
  const ret = wasm.formatPolicies(addHeapObject(call));
190
167
  return takeObject(ret);
191
168
  }
192
169
 
193
170
  /**
194
- * Return the Cedar (textual) representation of a policy.
195
- * @param {Policy} policy
196
- * @returns {PolicyToTextAnswer}
197
- */
171
+ * Return the Cedar (textual) representation of a policy.
172
+ * @param {Policy} policy
173
+ * @returns {PolicyToTextAnswer}
174
+ */
198
175
  export function policyToText(policy) {
199
176
  const ret = wasm.policyToText(addHeapObject(policy));
200
177
  return takeObject(ret);
201
178
  }
202
179
 
203
180
  /**
204
- * Return the Cedar (textual) representation of a template.
205
- * @param {Template} template
206
- * @returns {PolicyToTextAnswer}
207
- */
181
+ * Return the Cedar (textual) representation of a template.
182
+ * @param {Template} template
183
+ * @returns {PolicyToTextAnswer}
184
+ */
208
185
  export function templateToText(template) {
209
186
  const ret = wasm.templateToText(addHeapObject(template));
210
187
  return takeObject(ret);
211
188
  }
212
189
 
213
190
  /**
214
- * Return the JSON representation of a policy.
215
- * @param {Policy} policy
216
- * @returns {PolicyToJsonAnswer}
217
- */
191
+ * Return the JSON representation of a policy.
192
+ * @param {Policy} policy
193
+ * @returns {PolicyToJsonAnswer}
194
+ */
218
195
  export function policyToJson(policy) {
219
196
  const ret = wasm.policyToJson(addHeapObject(policy));
220
197
  return takeObject(ret);
221
198
  }
222
199
 
223
200
  /**
224
- * Return the JSON representation of a template.
225
- * @param {Template} template
226
- * @returns {PolicyToJsonAnswer}
227
- */
201
+ * Return the JSON representation of a template.
202
+ * @param {Template} template
203
+ * @returns {PolicyToJsonAnswer}
204
+ */
228
205
  export function templateToJson(template) {
229
206
  const ret = wasm.templateToJson(addHeapObject(template));
230
207
  return takeObject(ret);
231
208
  }
232
209
 
233
210
  /**
234
- * Return the Cedar (textual) representation of a schema.
235
- * @param {Schema} schema
236
- * @returns {SchemaToTextAnswer}
237
- */
211
+ * Return the Cedar (textual) representation of a schema.
212
+ * @param {Schema} schema
213
+ * @returns {SchemaToTextAnswer}
214
+ */
238
215
  export function schemaToText(schema) {
239
216
  const ret = wasm.schemaToText(addHeapObject(schema));
240
217
  return takeObject(ret);
241
218
  }
242
219
 
243
220
  /**
244
- * Return the JSON representation of a schema.
245
- * @param {Schema} schema
246
- * @returns {SchemaToJsonAnswer}
247
- */
221
+ * Return the JSON representation of a schema.
222
+ * @param {Schema} schema
223
+ * @returns {SchemaToJsonAnswer}
224
+ */
248
225
  export function schemaToJson(schema) {
249
226
  const ret = wasm.schemaToJson(addHeapObject(schema));
250
227
  return takeObject(ret);
251
228
  }
252
229
 
253
230
  /**
254
- * Check whether a policy set successfully parses.
255
- * @param {PolicySet} policies
256
- * @returns {CheckParseAnswer}
257
- */
231
+ * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
232
+ * @param {AuthorizationCall} call
233
+ * @returns {AuthorizationAnswer}
234
+ */
235
+ export function isAuthorized(call) {
236
+ const ret = wasm.isAuthorized(addHeapObject(call));
237
+ return takeObject(ret);
238
+ }
239
+
240
+ /**
241
+ * Parse a policy set and optionally validate it against a provided schema
242
+ *
243
+ * This is the basic validator interface, using [`ValidationCall`] and
244
+ * [`ValidationAnswer`] types
245
+ * @param {ValidationCall} call
246
+ * @returns {ValidationAnswer}
247
+ */
248
+ export function validate(call) {
249
+ const ret = wasm.validate(addHeapObject(call));
250
+ return takeObject(ret);
251
+ }
252
+
253
+ /**
254
+ * Check whether a policy set successfully parses.
255
+ * @param {PolicySet} policies
256
+ * @returns {CheckParseAnswer}
257
+ */
258
258
  export function checkParsePolicySet(policies) {
259
259
  const ret = wasm.checkParsePolicySet(addHeapObject(policies));
260
260
  return takeObject(ret);
261
261
  }
262
262
 
263
263
  /**
264
- * Check whether a schema successfully parses.
265
- * @param {Schema} schema
266
- * @returns {CheckParseAnswer}
267
- */
264
+ * Check whether a schema successfully parses.
265
+ * @param {Schema} schema
266
+ * @returns {CheckParseAnswer}
267
+ */
268
268
  export function checkParseSchema(schema) {
269
269
  const ret = wasm.checkParseSchema(addHeapObject(schema));
270
270
  return takeObject(ret);
271
271
  }
272
272
 
273
273
  /**
274
- * Check whether a set of entities successfully parses.
275
- * @param {EntitiesParsingCall} call
276
- * @returns {CheckParseAnswer}
277
- */
274
+ * Check whether a set of entities successfully parses.
275
+ * @param {EntitiesParsingCall} call
276
+ * @returns {CheckParseAnswer}
277
+ */
278
278
  export function checkParseEntities(call) {
279
279
  const ret = wasm.checkParseEntities(addHeapObject(call));
280
280
  return takeObject(ret);
281
281
  }
282
282
 
283
283
  /**
284
- * Check whether a context successfully parses.
285
- * @param {ContextParsingCall} call
286
- * @returns {CheckParseAnswer}
287
- */
284
+ * Check whether a context successfully parses.
285
+ * @param {ContextParsingCall} call
286
+ * @returns {CheckParseAnswer}
287
+ */
288
288
  export function checkParseContext(call) {
289
289
  const ret = wasm.checkParseContext(addHeapObject(call));
290
290
  return takeObject(ret);
@@ -306,7 +306,7 @@ async function __wbg_load(module, imports) {
306
306
 
307
307
  } catch (e) {
308
308
  if (module.headers.get('Content-Type') != 'application/wasm') {
309
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
309
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
310
310
 
311
311
  } else {
312
312
  throw e;
@@ -351,11 +351,11 @@ function __wbg_get_imports() {
351
351
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
352
352
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
353
353
  };
354
- imports.wbg.__wbg_parse_52202f117ec9ecfa = function() { return handleError(function (arg0, arg1) {
354
+ imports.wbg.__wbg_parse_51ee5409072379d3 = function() { return handleError(function (arg0, arg1) {
355
355
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
356
356
  return addHeapObject(ret);
357
357
  }, arguments) };
358
- imports.wbg.__wbg_stringify_bbf45426c92a6bf5 = function() { return handleError(function (arg0) {
358
+ imports.wbg.__wbg_stringify_eead5648c09faaf8 = function() { return handleError(function (arg0) {
359
359
  const ret = JSON.stringify(getObject(arg0));
360
360
  return addHeapObject(ret);
361
361
  }, arguments) };
@@ -385,10 +385,13 @@ function initSync(module) {
385
385
  if (wasm !== undefined) return wasm;
386
386
 
387
387
 
388
- if (typeof module !== 'undefined' && Object.getPrototypeOf(module) === Object.prototype)
389
- ({module} = module)
390
- else
391
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
388
+ if (typeof module !== 'undefined') {
389
+ if (Object.getPrototypeOf(module) === Object.prototype) {
390
+ ({module} = module)
391
+ } else {
392
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
393
+ }
394
+ }
392
395
 
393
396
  const imports = __wbg_get_imports();
394
397
 
@@ -407,10 +410,13 @@ async function __wbg_init(module_or_path) {
407
410
  if (wasm !== undefined) return wasm;
408
411
 
409
412
 
410
- if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
411
- ({module_or_path} = module_or_path)
412
- else
413
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
413
+ if (typeof module_or_path !== 'undefined') {
414
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
415
+ ({module_or_path} = module_or_path)
416
+ } else {
417
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
418
+ }
419
+ }
414
420
 
415
421
  if (typeof module_or_path === 'undefined') {
416
422
  module_or_path = new URL('cedar_wasm_bg.wasm', import.meta.url);
Binary file
@@ -4,8 +4,6 @@ export const memory: WebAssembly.Memory;
4
4
  export function getValidRequestEnvsTemplate(a: number, b: number): number;
5
5
  export function getValidRequestEnvsPolicy(a: number, b: number): number;
6
6
  export function getCedarVersion(a: number): void;
7
- export function isAuthorized(a: number): number;
8
- export function validate(a: number): number;
9
7
  export function formatPolicies(a: number): number;
10
8
  export function policyToText(a: number): number;
11
9
  export function templateToText(a: number): number;
@@ -13,6 +11,8 @@ export function policyToJson(a: number): number;
13
11
  export function templateToJson(a: number): number;
14
12
  export function schemaToText(a: number): number;
15
13
  export function schemaToJson(a: number): number;
14
+ export function isAuthorized(a: number): number;
15
+ export function validate(a: number): number;
16
16
  export function checkParsePolicySet(a: number): number;
17
17
  export function checkParseSchema(a: number): number;
18
18
  export function checkParseEntities(a: number): number;
package/web/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@cedar-policy/cedar-wasm",
3
3
  "type": "module",
4
4
  "description": "Wasm bindings and typescript types for Cedar lib",
5
- "version": "4.2.0",
5
+ "version": "4.2.2",
6
6
  "license": "Apache-2.0",
7
7
  "files": [
8
8
  "cedar_wasm_bg.wasm",