@cedar-policy/cedar-wasm 4.1.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.
package/README.md CHANGED
@@ -28,7 +28,7 @@ console.log(cedar.getCedarVersion());
28
28
  Importing the esm version using esm async import:
29
29
 
30
30
  ```
31
- import('@cedar-policy/cedar-wasm')
31
+ import('@cedar-policy/cedar-wasm/nodejs')
32
32
  .then(cedar => console.log(cedar.getCedarVersion()));
33
33
  ```
34
34
 
package/esm/README.md CHANGED
@@ -28,7 +28,7 @@ console.log(cedar.getCedarVersion());
28
28
  Importing the esm version using esm async import:
29
29
 
30
30
  ```
31
- import('@cedar-policy/cedar-wasm')
31
+ import('@cedar-policy/cedar-wasm/nodejs')
32
32
  .then(cedar => console.log(cedar.getCedarVersion()));
33
33
  ```
34
34
 
@@ -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
- * Check whether a policy set successfully parses.
38
- * @param {PolicySet} policies
39
- * @returns {CheckParseAnswer}
40
- */
41
- export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
42
- /**
43
- * Check whether a schema successfully parses.
44
- * @param {Schema} schema
45
- * @returns {CheckParseAnswer}
46
- */
47
- export function checkParseSchema(schema: Schema): CheckParseAnswer;
48
- /**
49
- * Check whether a set of entities successfully parses.
50
- * @param {EntitiesParsingCall} call
51
- * @returns {CheckParseAnswer}
52
- */
53
- export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
54
- /**
55
- * Check whether a context successfully parses.
56
- * @param {ContextParsingCall} call
57
- * @returns {CheckParseAnswer}
58
- */
59
- export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
60
- /**
61
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
62
- * @param {FormattingCall} call
63
- * @returns {FormattingAnswer}
64
- */
22
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
23
+ * @param {FormattingCall} call
24
+ * @returns {FormattingAnswer}
25
+ */
65
26
  export function formatPolicies(call: FormattingCall): FormattingAnswer;
66
27
  /**
67
- * Return the Cedar (textual) representation of a policy.
68
- * @param {Policy} policy
69
- * @returns {PolicyToTextAnswer}
70
- */
28
+ * Return the Cedar (textual) representation of a policy.
29
+ * @param {Policy} policy
30
+ * @returns {PolicyToTextAnswer}
31
+ */
71
32
  export function policyToText(policy: Policy): PolicyToTextAnswer;
72
33
  /**
73
- * Return the Cedar (textual) representation of a template.
74
- * @param {Template} template
75
- * @returns {PolicyToTextAnswer}
76
- */
34
+ * Return the Cedar (textual) representation of a template.
35
+ * @param {Template} template
36
+ * @returns {PolicyToTextAnswer}
37
+ */
77
38
  export function templateToText(template: Template): PolicyToTextAnswer;
78
39
  /**
79
- * Return the JSON representation of a policy.
80
- * @param {Policy} policy
81
- * @returns {PolicyToJsonAnswer}
82
- */
40
+ * Return the JSON representation of a policy.
41
+ * @param {Policy} policy
42
+ * @returns {PolicyToJsonAnswer}
43
+ */
83
44
  export function policyToJson(policy: Policy): PolicyToJsonAnswer;
84
45
  /**
85
- * Return the JSON representation of a template.
86
- * @param {Template} template
87
- * @returns {PolicyToJsonAnswer}
88
- */
46
+ * Return the JSON representation of a template.
47
+ * @param {Template} template
48
+ * @returns {PolicyToJsonAnswer}
49
+ */
89
50
  export function templateToJson(template: Template): PolicyToJsonAnswer;
90
51
  /**
91
- * Return the Cedar (textual) representation of a schema.
92
- * @param {Schema} schema
93
- * @returns {SchemaToTextAnswer}
94
- */
52
+ * Return the Cedar (textual) representation of a schema.
53
+ * @param {Schema} schema
54
+ * @returns {SchemaToTextAnswer}
55
+ */
95
56
  export function schemaToText(schema: Schema): SchemaToTextAnswer;
96
57
  /**
97
- * Return the JSON representation of a schema.
98
- * @param {Schema} schema
99
- * @returns {SchemaToJsonAnswer}
100
- */
58
+ * Return the JSON representation of a schema.
59
+ * @param {Schema} schema
60
+ * @returns {SchemaToJsonAnswer}
61
+ */
101
62
  export function schemaToJson(schema: Schema): SchemaToJsonAnswer;
63
+ /**
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
+ export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
84
+ /**
85
+ * Check whether a schema successfully parses.
86
+ * @param {Schema} schema
87
+ * @returns {CheckParseAnswer}
88
+ */
89
+ export function checkParseSchema(schema: Schema): CheckParseAnswer;
90
+ /**
91
+ * Check whether a set of entities successfully parses.
92
+ * @param {EntitiesParsingCall} call
93
+ * @returns {CheckParseAnswer}
94
+ */
95
+ export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
96
+ /**
97
+ * Check whether a context successfully parses.
98
+ * @param {ContextParsingCall} call
99
+ * @returns {CheckParseAnswer}
100
+ */
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;
@@ -159,22 +181,6 @@ export interface ContextParsingCall {
159
181
  action?: EntityUid | null;
160
182
  }
161
183
 
162
- export interface FormattingCall {
163
- policyText: string;
164
- lineWidth?: number;
165
- indentWidth?: number;
166
- }
167
-
168
- export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
169
-
170
- export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
171
-
172
- export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
173
-
174
- export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
175
-
176
- export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
177
-
178
184
  export type Schema = string | SchemaJson<string>;
179
185
 
180
186
  export interface PolicySet {
@@ -222,12 +228,6 @@ export interface DetailedError {
222
228
  related?: DetailedError[];
223
229
  }
224
230
 
225
- export type ValidationMode = "strict";
226
-
227
- export type SlotId = string;
228
-
229
- export type PolicyId = string;
230
-
231
231
  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
232
 
233
233
  export interface RecordType<N> {
@@ -283,6 +283,10 @@ export interface PolicyJson {
283
283
  annotations?: Record<string, string>;
284
284
  }
285
285
 
286
+ export type Effect = "permit" | "forbid";
287
+
288
+ export type UnreservedId = string;
289
+
286
290
  export interface EntityJson {
287
291
  uid: EntityUidJson;
288
292
  attrs: Record<string, CedarValueJson>;
@@ -290,28 +294,17 @@ export interface EntityJson {
290
294
  tags?: Record<string, CedarValueJson>;
291
295
  }
292
296
 
293
- export type UnreservedId = string;
297
+ export type Decision = "allow" | "deny";
294
298
 
295
299
  export type Var = "principal" | "action" | "resource" | "context";
296
300
 
297
- export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
298
-
299
- export interface PrincipalOrResourceIsConstraint {
300
- entity_type: string;
301
- in?: PrincipalOrResourceInConstraint;
302
- }
303
-
304
- export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
305
-
306
- export type EqConstraint = { entity: EntityUidJson } | { slot: string };
307
-
308
- export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
301
+ export type ExtFuncCall = {} & Record<string, Array<Expr>>;
309
302
 
310
- 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> };
311
304
 
312
- export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
305
+ export type PatternElem = "Wildcard" | { Literal: SmolStr };
313
306
 
314
- export type Decision = "allow" | "deny";
307
+ export type Expr = ExprNoExt | ExtFuncCall;
315
308
 
316
309
  export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
317
310
 
@@ -327,15 +320,22 @@ export interface TypeAndId {
327
320
 
328
321
  export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
329
322
 
330
- export type ExtFuncCall = {} & Record<string, Array<Expr>>;
323
+ export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
331
324
 
332
- 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> };
325
+ export interface PrincipalOrResourceIsConstraint {
326
+ entity_type: string;
327
+ in?: PrincipalOrResourceInConstraint;
328
+ }
333
329
 
334
- export type PatternElem = "Wildcard" | { Literal: SmolStr };
330
+ export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
335
331
 
336
- export type Expr = ExprNoExt | ExtFuncCall;
332
+ export type EqConstraint = { entity: EntityUidJson } | { slot: string };
337
333
 
338
- export type Effect = "permit" | "forbid";
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
  type SmolStr = string;
341
341
  export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
package/esm/cedar_wasm.js CHANGED
@@ -1,5 +1,4 @@
1
-
2
1
  import * as wasm from "./cedar_wasm_bg.wasm";
3
- import { __wbg_set_wasm } from "./cedar_wasm_bg.js";
4
- __wbg_set_wasm(wasm);
5
2
  export * from "./cedar_wasm_bg.js";
3
+ import { __wbg_set_wasm } from "./cedar_wasm_bg.js";
4
+ __wbg_set_wasm(wasm);
@@ -124,30 +124,30 @@ function getStringFromWasm0(ptr, len) {
124
124
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
125
125
  }
126
126
  /**
127
- * Get valid request environment
128
- * @param {Template} t
129
- * @param {Schema} s
130
- * @returns {GetValidRequestEnvsResult}
131
- */
127
+ * Get valid request environment
128
+ * @param {Template} t
129
+ * @param {Schema} s
130
+ * @returns {GetValidRequestEnvsResult}
131
+ */
132
132
  export function getValidRequestEnvsTemplate(t, s) {
133
133
  const ret = wasm.getValidRequestEnvsTemplate(addHeapObject(t), addHeapObject(s));
134
134
  return takeObject(ret);
135
135
  }
136
136
 
137
137
  /**
138
- * Get valid request environment
139
- * @param {Policy} t
140
- * @param {Schema} s
141
- * @returns {GetValidRequestEnvsResult}
142
- */
138
+ * Get valid request environment
139
+ * @param {Policy} t
140
+ * @param {Schema} s
141
+ * @returns {GetValidRequestEnvsResult}
142
+ */
143
143
  export function getValidRequestEnvsPolicy(t, s) {
144
144
  const ret = wasm.getValidRequestEnvsPolicy(addHeapObject(t), addHeapObject(s));
145
145
  return takeObject(ret);
146
146
  }
147
147
 
148
148
  /**
149
- * @returns {string}
150
- */
149
+ * @returns {string}
150
+ */
151
151
  export function getCedarVersion() {
152
152
  let deferred1_0;
153
153
  let deferred1_1;
@@ -166,135 +166,135 @@ export function getCedarVersion() {
166
166
  }
167
167
 
168
168
  /**
169
- * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
170
- * @param {AuthorizationCall} call
171
- * @returns {AuthorizationAnswer}
172
- */
173
- export function isAuthorized(call) {
174
- const ret = wasm.isAuthorized(addHeapObject(call));
169
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
170
+ * @param {FormattingCall} call
171
+ * @returns {FormattingAnswer}
172
+ */
173
+ export function formatPolicies(call) {
174
+ const ret = wasm.formatPolicies(addHeapObject(call));
175
175
  return takeObject(ret);
176
176
  }
177
177
 
178
178
  /**
179
- * Parse a policy set and optionally validate it against a provided schema
180
- *
181
- * This is the basic validator interface, using [`ValidationCall`] and
182
- * [`ValidationAnswer`] types
183
- * @param {ValidationCall} call
184
- * @returns {ValidationAnswer}
185
- */
186
- export function validate(call) {
187
- const ret = wasm.validate(addHeapObject(call));
179
+ * Return the Cedar (textual) representation of a policy.
180
+ * @param {Policy} policy
181
+ * @returns {PolicyToTextAnswer}
182
+ */
183
+ export function policyToText(policy) {
184
+ const ret = wasm.policyToText(addHeapObject(policy));
188
185
  return takeObject(ret);
189
186
  }
190
187
 
191
188
  /**
192
- * Check whether a policy set successfully parses.
193
- * @param {PolicySet} policies
194
- * @returns {CheckParseAnswer}
195
- */
196
- export function checkParsePolicySet(policies) {
197
- const ret = wasm.checkParsePolicySet(addHeapObject(policies));
189
+ * Return the Cedar (textual) representation of a template.
190
+ * @param {Template} template
191
+ * @returns {PolicyToTextAnswer}
192
+ */
193
+ export function templateToText(template) {
194
+ const ret = wasm.templateToText(addHeapObject(template));
198
195
  return takeObject(ret);
199
196
  }
200
197
 
201
198
  /**
202
- * Check whether a schema successfully parses.
203
- * @param {Schema} schema
204
- * @returns {CheckParseAnswer}
205
- */
206
- export function checkParseSchema(schema) {
207
- const ret = wasm.checkParseSchema(addHeapObject(schema));
199
+ * Return the JSON representation of a policy.
200
+ * @param {Policy} policy
201
+ * @returns {PolicyToJsonAnswer}
202
+ */
203
+ export function policyToJson(policy) {
204
+ const ret = wasm.policyToJson(addHeapObject(policy));
208
205
  return takeObject(ret);
209
206
  }
210
207
 
211
208
  /**
212
- * Check whether a set of entities successfully parses.
213
- * @param {EntitiesParsingCall} call
214
- * @returns {CheckParseAnswer}
215
- */
216
- export function checkParseEntities(call) {
217
- const ret = wasm.checkParseEntities(addHeapObject(call));
209
+ * Return the JSON representation of a template.
210
+ * @param {Template} template
211
+ * @returns {PolicyToJsonAnswer}
212
+ */
213
+ export function templateToJson(template) {
214
+ const ret = wasm.templateToJson(addHeapObject(template));
218
215
  return takeObject(ret);
219
216
  }
220
217
 
221
218
  /**
222
- * Check whether a context successfully parses.
223
- * @param {ContextParsingCall} call
224
- * @returns {CheckParseAnswer}
225
- */
226
- export function checkParseContext(call) {
227
- const ret = wasm.checkParseContext(addHeapObject(call));
219
+ * Return the Cedar (textual) representation of a schema.
220
+ * @param {Schema} schema
221
+ * @returns {SchemaToTextAnswer}
222
+ */
223
+ export function schemaToText(schema) {
224
+ const ret = wasm.schemaToText(addHeapObject(schema));
228
225
  return takeObject(ret);
229
226
  }
230
227
 
231
228
  /**
232
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
233
- * @param {FormattingCall} call
234
- * @returns {FormattingAnswer}
235
- */
236
- export function formatPolicies(call) {
237
- const ret = wasm.formatPolicies(addHeapObject(call));
229
+ * Return the JSON representation of a schema.
230
+ * @param {Schema} schema
231
+ * @returns {SchemaToJsonAnswer}
232
+ */
233
+ export function schemaToJson(schema) {
234
+ const ret = wasm.schemaToJson(addHeapObject(schema));
238
235
  return takeObject(ret);
239
236
  }
240
237
 
241
238
  /**
242
- * Return the Cedar (textual) representation of a policy.
243
- * @param {Policy} policy
244
- * @returns {PolicyToTextAnswer}
245
- */
246
- export function policyToText(policy) {
247
- const ret = wasm.policyToText(addHeapObject(policy));
239
+ * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
240
+ * @param {AuthorizationCall} call
241
+ * @returns {AuthorizationAnswer}
242
+ */
243
+ export function isAuthorized(call) {
244
+ const ret = wasm.isAuthorized(addHeapObject(call));
248
245
  return takeObject(ret);
249
246
  }
250
247
 
251
248
  /**
252
- * Return the Cedar (textual) representation of a template.
253
- * @param {Template} template
254
- * @returns {PolicyToTextAnswer}
255
- */
256
- export function templateToText(template) {
257
- const ret = wasm.templateToText(addHeapObject(template));
249
+ * Parse a policy set and optionally validate it against a provided schema
250
+ *
251
+ * This is the basic validator interface, using [`ValidationCall`] and
252
+ * [`ValidationAnswer`] types
253
+ * @param {ValidationCall} call
254
+ * @returns {ValidationAnswer}
255
+ */
256
+ export function validate(call) {
257
+ const ret = wasm.validate(addHeapObject(call));
258
258
  return takeObject(ret);
259
259
  }
260
260
 
261
261
  /**
262
- * Return the JSON representation of a policy.
263
- * @param {Policy} policy
264
- * @returns {PolicyToJsonAnswer}
265
- */
266
- export function policyToJson(policy) {
267
- const ret = wasm.policyToJson(addHeapObject(policy));
262
+ * Check whether a policy set successfully parses.
263
+ * @param {PolicySet} policies
264
+ * @returns {CheckParseAnswer}
265
+ */
266
+ export function checkParsePolicySet(policies) {
267
+ const ret = wasm.checkParsePolicySet(addHeapObject(policies));
268
268
  return takeObject(ret);
269
269
  }
270
270
 
271
271
  /**
272
- * Return the JSON representation of a template.
273
- * @param {Template} template
274
- * @returns {PolicyToJsonAnswer}
275
- */
276
- export function templateToJson(template) {
277
- const ret = wasm.templateToJson(addHeapObject(template));
272
+ * Check whether a schema successfully parses.
273
+ * @param {Schema} schema
274
+ * @returns {CheckParseAnswer}
275
+ */
276
+ export function checkParseSchema(schema) {
277
+ const ret = wasm.checkParseSchema(addHeapObject(schema));
278
278
  return takeObject(ret);
279
279
  }
280
280
 
281
281
  /**
282
- * Return the Cedar (textual) representation of a schema.
283
- * @param {Schema} schema
284
- * @returns {SchemaToTextAnswer}
285
- */
286
- export function schemaToText(schema) {
287
- const ret = wasm.schemaToText(addHeapObject(schema));
282
+ * Check whether a set of entities successfully parses.
283
+ * @param {EntitiesParsingCall} call
284
+ * @returns {CheckParseAnswer}
285
+ */
286
+ export function checkParseEntities(call) {
287
+ const ret = wasm.checkParseEntities(addHeapObject(call));
288
288
  return takeObject(ret);
289
289
  }
290
290
 
291
291
  /**
292
- * Return the JSON representation of a schema.
293
- * @param {Schema} schema
294
- * @returns {SchemaToJsonAnswer}
295
- */
296
- export function schemaToJson(schema) {
297
- const ret = wasm.schemaToJson(addHeapObject(schema));
292
+ * Check whether a context successfully parses.
293
+ * @param {ContextParsingCall} call
294
+ * @returns {CheckParseAnswer}
295
+ */
296
+ export function checkParseContext(call) {
297
+ const ret = wasm.checkParseContext(addHeapObject(call));
298
298
  return takeObject(ret);
299
299
  }
300
300
 
@@ -329,12 +329,12 @@ export function __wbindgen_string_get(arg0, arg1) {
329
329
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
330
330
  };
331
331
 
332
- export function __wbg_parse_52202f117ec9ecfa() { return handleError(function (arg0, arg1) {
332
+ export function __wbg_parse_51ee5409072379d3() { return handleError(function (arg0, arg1) {
333
333
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
334
334
  return addHeapObject(ret);
335
335
  }, arguments) };
336
336
 
337
- export function __wbg_stringify_bbf45426c92a6bf5() { return handleError(function (arg0) {
337
+ export function __wbg_stringify_eead5648c09faaf8() { return handleError(function (arg0) {
338
338
  const ret = JSON.stringify(getObject(arg0));
339
339
  return addHeapObject(ret);
340
340
  }, arguments) };
Binary file
@@ -4,12 +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
- export function checkParsePolicySet(a: number): number;
10
- export function checkParseSchema(a: number): number;
11
- export function checkParseEntities(a: number): number;
12
- export function checkParseContext(a: number): number;
13
7
  export function formatPolicies(a: number): number;
14
8
  export function policyToText(a: number): number;
15
9
  export function templateToText(a: number): number;
@@ -17,6 +11,12 @@ export function policyToJson(a: number): number;
17
11
  export function templateToJson(a: number): number;
18
12
  export function schemaToText(a: number): number;
19
13
  export function schemaToJson(a: number): number;
14
+ export function isAuthorized(a: number): number;
15
+ export function validate(a: number): number;
16
+ export function checkParsePolicySet(a: number): number;
17
+ export function checkParseSchema(a: number): number;
18
+ export function checkParseEntities(a: number): number;
19
+ export function checkParseContext(a: number): number;
20
20
  export function __wbindgen_malloc(a: number, b: number): number;
21
21
  export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
22
22
  export function __wbindgen_add_to_stack_pointer(a: number): number;