@cedar-policy/cedar-wasm 4.3.3 → 4.5.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.
@@ -18,9 +18,34 @@ export function getCedarSDKVersion(): string;
18
18
  */
19
19
  export function validate(call: ValidationCall): ValidationAnswer;
20
20
  /**
21
- * Get language version of Cedar
21
+ * Check whether a policy set successfully parses.
22
22
  */
23
- export function getCedarLangVersion(): string;
23
+ export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
24
+ /**
25
+ * Check whether a schema successfully parses.
26
+ */
27
+ export function checkParseSchema(schema: Schema): CheckParseAnswer;
28
+ /**
29
+ * Check whether a set of entities successfully parses.
30
+ */
31
+ export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
32
+ /**
33
+ * Check whether a context successfully parses.
34
+ */
35
+ export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
36
+ /**
37
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
38
+ */
39
+ export function formatPolicies(call: FormattingCall): FormattingAnswer;
40
+ /**
41
+ * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
42
+ */
43
+ export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
44
+ /**
45
+ * Takes a PolicySet represented as string and return the policies
46
+ * and templates split into vecs and sorted by id.
47
+ */
48
+ export function policySetTextToParts(policyset_str: string): PolicySetTextToPartsAnswer;
24
49
  /**
25
50
  * Return the Cedar (textual) representation of a policy.
26
51
  */
@@ -46,29 +71,9 @@ export function schemaToText(schema: Schema): SchemaToTextAnswer;
46
71
  */
47
72
  export function schemaToJson(schema: Schema): SchemaToJsonAnswer;
48
73
  /**
49
- * Check whether a policy set successfully parses.
50
- */
51
- export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
52
- /**
53
- * Check whether a schema successfully parses.
54
- */
55
- export function checkParseSchema(schema: Schema): CheckParseAnswer;
56
- /**
57
- * Check whether a set of entities successfully parses.
58
- */
59
- export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
60
- /**
61
- * Check whether a context successfully parses.
62
- */
63
- export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
64
- /**
65
- * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
66
- */
67
- export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
68
- /**
69
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
74
+ * Get language version of Cedar
70
75
  */
71
- export function formatPolicies(call: FormattingCall): FormattingAnswer;
76
+ export function getCedarLangVersion(): string;
72
77
  export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
73
78
 
74
79
  export interface ValidationCall {
@@ -88,18 +93,6 @@ export interface ValidationError {
88
93
 
89
94
  export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
90
95
 
91
- export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
92
-
93
- export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
94
-
95
- export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
96
-
97
- export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
98
-
99
- export type SlotId = string;
100
-
101
- export type PolicyId = string;
102
-
103
96
  export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
104
97
 
105
98
  export interface EntitiesParsingCall {
@@ -113,6 +106,14 @@ export interface ContextParsingCall {
113
106
  action?: EntityUid | null;
114
107
  }
115
108
 
109
+ export interface FormattingCall {
110
+ policyText: string;
111
+ lineWidth?: number;
112
+ indentWidth?: number;
113
+ }
114
+
115
+ export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
116
+
116
117
  export interface Response {
117
118
  decision: Decision;
118
119
  diagnostics: Diagnostics;
@@ -141,13 +142,15 @@ export interface AuthorizationCall {
141
142
  entities: Entities;
142
143
  }
143
144
 
144
- export interface FormattingCall {
145
- policyText: string;
146
- lineWidth?: number;
147
- indentWidth?: number;
148
- }
145
+ export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
149
146
 
150
- export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
147
+ export type PolicySetTextToPartsAnswer = { type: "success"; policies: string[]; policy_templates: string[] } | { type: "failure"; errors: DetailedError[] };
148
+
149
+ export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
150
+
151
+ export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
152
+
153
+ export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
151
154
 
152
155
  export type Schema = string | SchemaJson<string>;
153
156
 
@@ -196,8 +199,46 @@ export interface DetailedError {
196
199
  related?: DetailedError[];
197
200
  }
198
201
 
202
+ export type SlotId = string;
203
+
204
+ export type PolicyId = string;
205
+
199
206
  export type ValidationMode = "strict";
200
207
 
208
+ export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
209
+
210
+ export interface PrincipalOrResourceIsConstraint {
211
+ entity_type: string;
212
+ in?: PrincipalOrResourceInConstraint;
213
+ }
214
+
215
+ export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
216
+
217
+ export type EqConstraint = { entity: EntityUidJson } | { slot: string };
218
+
219
+ export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
220
+
221
+ export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
222
+
223
+ export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
224
+
225
+ export type Effect = "permit" | "forbid";
226
+
227
+ export interface EntityJson {
228
+ uid: EntityUidJson;
229
+ attrs: Record<string, CedarValueJson>;
230
+ parents: EntityUidJson[];
231
+ tags?: Record<string, CedarValueJson>;
232
+ }
233
+
234
+ export type ExtFuncCall = {} & Record<string, Array<Expr>>;
235
+
236
+ export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { isEmpty: { arg: Expr } } | { getTag: { left: Expr; right: Expr } } | { hasTag: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
237
+
238
+ export type PatternElem = "Wildcard" | { Literal: SmolStr };
239
+
240
+ export type Expr = ExprNoExt | ExtFuncCall;
241
+
201
242
  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 };
202
243
 
203
244
  export interface RecordType<N> {
@@ -227,13 +268,14 @@ export interface ActionType<N> {
227
268
 
228
269
  export type AttributesOrContext<N> = Type<N>;
229
270
 
230
- export interface EntityType<N> {
271
+ export interface StandardEntityType<N> {
231
272
  memberOfTypes?: N[];
232
273
  shape?: AttributesOrContext<N>;
233
274
  tags?: Type<N>;
234
- annotations?: Annotations;
235
275
  }
236
276
 
277
+ export type EntityTypeKind<N> = StandardEntityType<N> | { enum: NonEmpty<SmolStr> };
278
+
237
279
  export interface NamespaceDefinition<N> {
238
280
  commonTypes?: Record<CommonTypeId, CommonType<N>>;
239
281
  entityTypes: Record<UnreservedId, EntityType<N>>;
@@ -245,56 +287,14 @@ export type CommonTypeId = string;
245
287
 
246
288
  export type SchemaJson<N> = Record<string, NamespaceDefinition<N>>;
247
289
 
248
- export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
249
-
250
- export interface PolicyJson {
251
- effect: Effect;
252
- principal: PrincipalConstraint;
253
- action: ActionConstraint;
254
- resource: ResourceConstraint;
255
- conditions: Clause[];
256
- annotations?: Annotations;
257
- }
258
-
259
- export type ExtFuncCall = {} & Record<string, Array<Expr>>;
260
-
261
- export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { isEmpty: { arg: Expr } } | { getTag: { left: Expr; right: Expr } } | { hasTag: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
262
-
263
- export type PatternElem = "Wildcard" | { Literal: SmolStr };
264
-
265
- export type Expr = ExprNoExt | ExtFuncCall;
266
-
267
290
  export type AnyId = SmolStr;
268
291
 
269
292
  export type UnreservedId = string;
270
293
 
271
- export type Effect = "permit" | "forbid";
272
-
273
294
  export type Annotations = Record<string, Annotation>;
274
295
 
275
- export type Decision = "allow" | "deny";
276
-
277
296
  export type Annotation = SmolStr;
278
297
 
279
- export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
280
-
281
- export interface PrincipalOrResourceIsConstraint {
282
- entity_type: string;
283
- in?: PrincipalOrResourceInConstraint;
284
- }
285
-
286
- export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
287
-
288
- export type EqConstraint = { entity: EntityUidJson } | { slot: string };
289
-
290
- export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
291
-
292
- export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
293
-
294
- export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
295
-
296
- export type Var = "principal" | "action" | "resource" | "context";
297
-
298
298
  export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
299
299
 
300
300
  export interface FnAndArg {
@@ -309,13 +309,23 @@ export interface TypeAndId {
309
309
 
310
310
  export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
311
311
 
312
- export interface EntityJson {
313
- uid: EntityUidJson;
314
- attrs: Record<string, CedarValueJson>;
315
- parents: EntityUidJson[];
316
- tags?: Record<string, CedarValueJson>;
312
+ export type Var = "principal" | "action" | "resource" | "context";
313
+
314
+ export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
315
+
316
+ export interface PolicyJson {
317
+ effect: Effect;
318
+ principal: PrincipalConstraint;
319
+ action: ActionConstraint;
320
+ resource: ResourceConstraint;
321
+ conditions: Clause[];
322
+ annotations?: Annotations;
317
323
  }
318
324
 
325
+ export type Decision = "allow" | "deny";
326
+
319
327
  type SmolStr = string;
320
328
  export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
321
329
  export type CommonType<N> = Type<N> & { annotations?: Annotations };
330
+ export type EntityType<N> = EntityTypeKind<N> & { annotations?: Annotations; };
331
+ export type NonEmpty<Type> = Array<Type>;
package/esm/cedar_wasm.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as wasm from "./cedar_wasm_bg.wasm";
2
2
  export * from "./cedar_wasm_bg.js";
3
3
  import { __wbg_set_wasm } from "./cedar_wasm_bg.js";
4
- __wbg_set_wasm(wasm);
4
+ __wbg_set_wasm(wasm);
5
+ wasm.__wbindgen_start();
@@ -24,18 +24,9 @@ function getStringFromWasm0(ptr, len) {
24
24
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
25
25
  }
26
26
 
27
- const heap = new Array(128).fill(undefined);
28
-
29
- heap.push(undefined, null, true, false);
30
-
31
- let heap_next = heap.length;
32
-
33
- function addHeapObject(obj) {
34
- if (heap_next === heap.length) heap.push(heap.length + 1);
35
- const idx = heap_next;
36
- heap_next = heap[idx];
37
-
38
- heap[idx] = obj;
27
+ function addToExternrefTable0(obj) {
28
+ const idx = wasm.__externref_table_alloc();
29
+ wasm.__wbindgen_export_2.set(idx, obj);
39
30
  return idx;
40
31
  }
41
32
 
@@ -43,24 +34,11 @@ function handleError(f, args) {
43
34
  try {
44
35
  return f.apply(this, args);
45
36
  } catch (e) {
46
- wasm.__wbindgen_exn_store(addHeapObject(e));
37
+ const idx = addToExternrefTable0(e);
38
+ wasm.__wbindgen_exn_store(idx);
47
39
  }
48
40
  }
49
41
 
50
- function getObject(idx) { return heap[idx]; }
51
-
52
- function dropObject(idx) {
53
- if (idx < 132) return;
54
- heap[idx] = heap_next;
55
- heap_next = idx;
56
- }
57
-
58
- function takeObject(idx) {
59
- const ret = getObject(idx);
60
- dropObject(idx);
61
- return ret;
62
- }
63
-
64
42
  let WASM_VECTOR_LEN = 0;
65
43
 
66
44
  const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
@@ -138,8 +116,8 @@ function getDataViewMemory0() {
138
116
  * @returns {GetValidRequestEnvsResult}
139
117
  */
140
118
  export function getValidRequestEnvsTemplate(t, s) {
141
- const ret = wasm.getValidRequestEnvsTemplate(addHeapObject(t), addHeapObject(s));
142
- return takeObject(ret);
119
+ const ret = wasm.getValidRequestEnvsTemplate(t, s);
120
+ return ret;
143
121
  }
144
122
 
145
123
  /**
@@ -149,8 +127,8 @@ export function getValidRequestEnvsTemplate(t, s) {
149
127
  * @returns {GetValidRequestEnvsResult}
150
128
  */
151
129
  export function getValidRequestEnvsPolicy(t, s) {
152
- const ret = wasm.getValidRequestEnvsPolicy(addHeapObject(t), addHeapObject(s));
153
- return takeObject(ret);
130
+ const ret = wasm.getValidRequestEnvsPolicy(t, s);
131
+ return ret;
154
132
  }
155
133
 
156
134
  /**
@@ -160,15 +138,11 @@ export function getCedarVersion() {
160
138
  let deferred1_0;
161
139
  let deferred1_1;
162
140
  try {
163
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
164
- wasm.getCedarSDKVersion(retptr);
165
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
166
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
167
- deferred1_0 = r0;
168
- deferred1_1 = r1;
169
- return getStringFromWasm0(r0, r1);
141
+ const ret = wasm.getCedarVersion();
142
+ deferred1_0 = ret[0];
143
+ deferred1_1 = ret[1];
144
+ return getStringFromWasm0(ret[0], ret[1]);
170
145
  } finally {
171
- wasm.__wbindgen_add_to_stack_pointer(16);
172
146
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
173
147
  }
174
148
  }
@@ -180,15 +154,11 @@ export function getCedarSDKVersion() {
180
154
  let deferred1_0;
181
155
  let deferred1_1;
182
156
  try {
183
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
184
- wasm.getCedarSDKVersion(retptr);
185
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
186
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
187
- deferred1_0 = r0;
188
- deferred1_1 = r1;
189
- return getStringFromWasm0(r0, r1);
157
+ const ret = wasm.getCedarSDKVersion();
158
+ deferred1_0 = ret[0];
159
+ deferred1_1 = ret[1];
160
+ return getStringFromWasm0(ret[0], ret[1]);
190
161
  } finally {
191
- wasm.__wbindgen_add_to_stack_pointer(16);
192
162
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
193
163
  }
194
164
  }
@@ -202,29 +172,81 @@ export function getCedarSDKVersion() {
202
172
  * @returns {ValidationAnswer}
203
173
  */
204
174
  export function validate(call) {
205
- const ret = wasm.validate(addHeapObject(call));
206
- return takeObject(ret);
175
+ const ret = wasm.validate(call);
176
+ return ret;
207
177
  }
208
178
 
209
179
  /**
210
- * Get language version of Cedar
211
- * @returns {string}
180
+ * Check whether a policy set successfully parses.
181
+ * @param {PolicySet} policies
182
+ * @returns {CheckParseAnswer}
212
183
  */
213
- export function getCedarLangVersion() {
214
- let deferred1_0;
215
- let deferred1_1;
216
- try {
217
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
218
- wasm.getCedarLangVersion(retptr);
219
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
220
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
221
- deferred1_0 = r0;
222
- deferred1_1 = r1;
223
- return getStringFromWasm0(r0, r1);
224
- } finally {
225
- wasm.__wbindgen_add_to_stack_pointer(16);
226
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
227
- }
184
+ export function checkParsePolicySet(policies) {
185
+ const ret = wasm.checkParsePolicySet(policies);
186
+ return ret;
187
+ }
188
+
189
+ /**
190
+ * Check whether a schema successfully parses.
191
+ * @param {Schema} schema
192
+ * @returns {CheckParseAnswer}
193
+ */
194
+ export function checkParseSchema(schema) {
195
+ const ret = wasm.checkParseSchema(schema);
196
+ return ret;
197
+ }
198
+
199
+ /**
200
+ * Check whether a set of entities successfully parses.
201
+ * @param {EntitiesParsingCall} call
202
+ * @returns {CheckParseAnswer}
203
+ */
204
+ export function checkParseEntities(call) {
205
+ const ret = wasm.checkParseEntities(call);
206
+ return ret;
207
+ }
208
+
209
+ /**
210
+ * Check whether a context successfully parses.
211
+ * @param {ContextParsingCall} call
212
+ * @returns {CheckParseAnswer}
213
+ */
214
+ export function checkParseContext(call) {
215
+ const ret = wasm.checkParseContext(call);
216
+ return ret;
217
+ }
218
+
219
+ /**
220
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
221
+ * @param {FormattingCall} call
222
+ * @returns {FormattingAnswer}
223
+ */
224
+ export function formatPolicies(call) {
225
+ const ret = wasm.formatPolicies(call);
226
+ return ret;
227
+ }
228
+
229
+ /**
230
+ * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
231
+ * @param {AuthorizationCall} call
232
+ * @returns {AuthorizationAnswer}
233
+ */
234
+ export function isAuthorized(call) {
235
+ const ret = wasm.isAuthorized(call);
236
+ return ret;
237
+ }
238
+
239
+ /**
240
+ * Takes a PolicySet represented as string and return the policies
241
+ * and templates split into vecs and sorted by id.
242
+ * @param {string} policyset_str
243
+ * @returns {PolicySetTextToPartsAnswer}
244
+ */
245
+ export function policySetTextToParts(policyset_str) {
246
+ const ptr0 = passStringToWasm0(policyset_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
247
+ const len0 = WASM_VECTOR_LEN;
248
+ const ret = wasm.policySetTextToParts(ptr0, len0);
249
+ return ret;
228
250
  }
229
251
 
230
252
  /**
@@ -233,8 +255,8 @@ export function getCedarLangVersion() {
233
255
  * @returns {PolicyToTextAnswer}
234
256
  */
235
257
  export function policyToText(policy) {
236
- const ret = wasm.policyToText(addHeapObject(policy));
237
- return takeObject(ret);
258
+ const ret = wasm.policyToText(policy);
259
+ return ret;
238
260
  }
239
261
 
240
262
  /**
@@ -243,8 +265,8 @@ export function policyToText(policy) {
243
265
  * @returns {PolicyToTextAnswer}
244
266
  */
245
267
  export function templateToText(template) {
246
- const ret = wasm.templateToText(addHeapObject(template));
247
- return takeObject(ret);
268
+ const ret = wasm.templateToText(template);
269
+ return ret;
248
270
  }
249
271
 
250
272
  /**
@@ -253,8 +275,8 @@ export function templateToText(template) {
253
275
  * @returns {PolicyToJsonAnswer}
254
276
  */
255
277
  export function policyToJson(policy) {
256
- const ret = wasm.policyToJson(addHeapObject(policy));
257
- return takeObject(ret);
278
+ const ret = wasm.policyToJson(policy);
279
+ return ret;
258
280
  }
259
281
 
260
282
  /**
@@ -263,8 +285,8 @@ export function policyToJson(policy) {
263
285
  * @returns {PolicyToJsonAnswer}
264
286
  */
265
287
  export function templateToJson(template) {
266
- const ret = wasm.templateToJson(addHeapObject(template));
267
- return takeObject(ret);
288
+ const ret = wasm.templateToJson(template);
289
+ return ret;
268
290
  }
269
291
 
270
292
  /**
@@ -273,8 +295,8 @@ export function templateToJson(template) {
273
295
  * @returns {SchemaToTextAnswer}
274
296
  */
275
297
  export function schemaToText(schema) {
276
- const ret = wasm.schemaToText(addHeapObject(schema));
277
- return takeObject(ret);
298
+ const ret = wasm.schemaToText(schema);
299
+ return ret;
278
300
  }
279
301
 
280
302
  /**
@@ -283,96 +305,55 @@ export function schemaToText(schema) {
283
305
  * @returns {SchemaToJsonAnswer}
284
306
  */
285
307
  export function schemaToJson(schema) {
286
- const ret = wasm.schemaToJson(addHeapObject(schema));
287
- return takeObject(ret);
288
- }
289
-
290
- /**
291
- * Check whether a policy set successfully parses.
292
- * @param {PolicySet} policies
293
- * @returns {CheckParseAnswer}
294
- */
295
- export function checkParsePolicySet(policies) {
296
- const ret = wasm.checkParsePolicySet(addHeapObject(policies));
297
- return takeObject(ret);
298
- }
299
-
300
- /**
301
- * Check whether a schema successfully parses.
302
- * @param {Schema} schema
303
- * @returns {CheckParseAnswer}
304
- */
305
- export function checkParseSchema(schema) {
306
- const ret = wasm.checkParseSchema(addHeapObject(schema));
307
- return takeObject(ret);
308
- }
309
-
310
- /**
311
- * Check whether a set of entities successfully parses.
312
- * @param {EntitiesParsingCall} call
313
- * @returns {CheckParseAnswer}
314
- */
315
- export function checkParseEntities(call) {
316
- const ret = wasm.checkParseEntities(addHeapObject(call));
317
- return takeObject(ret);
318
- }
319
-
320
- /**
321
- * Check whether a context successfully parses.
322
- * @param {ContextParsingCall} call
323
- * @returns {CheckParseAnswer}
324
- */
325
- export function checkParseContext(call) {
326
- const ret = wasm.checkParseContext(addHeapObject(call));
327
- return takeObject(ret);
328
- }
329
-
330
- /**
331
- * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
332
- * @param {AuthorizationCall} call
333
- * @returns {AuthorizationAnswer}
334
- */
335
- export function isAuthorized(call) {
336
- const ret = wasm.isAuthorized(addHeapObject(call));
337
- return takeObject(ret);
308
+ const ret = wasm.schemaToJson(schema);
309
+ return ret;
338
310
  }
339
311
 
340
312
  /**
341
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
342
- * @param {FormattingCall} call
343
- * @returns {FormattingAnswer}
313
+ * Get language version of Cedar
314
+ * @returns {string}
344
315
  */
345
- export function formatPolicies(call) {
346
- const ret = wasm.formatPolicies(addHeapObject(call));
347
- return takeObject(ret);
316
+ export function getCedarLangVersion() {
317
+ let deferred1_0;
318
+ let deferred1_1;
319
+ try {
320
+ const ret = wasm.getCedarLangVersion();
321
+ deferred1_0 = ret[0];
322
+ deferred1_1 = ret[1];
323
+ return getStringFromWasm0(ret[0], ret[1]);
324
+ } finally {
325
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
326
+ }
348
327
  }
349
328
 
350
329
  export function __wbg_parse_def2e24ef1252aff() { return handleError(function (arg0, arg1) {
351
330
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
352
- return addHeapObject(ret);
331
+ return ret;
353
332
  }, arguments) };
354
333
 
355
334
  export function __wbg_stringify_f7ed6987935b4a24() { return handleError(function (arg0) {
356
- const ret = JSON.stringify(getObject(arg0));
357
- return addHeapObject(ret);
358
- }, arguments) };
359
-
360
- export function __wbindgen_is_undefined(arg0) {
361
- const ret = getObject(arg0) === undefined;
335
+ const ret = JSON.stringify(arg0);
362
336
  return ret;
363
- };
337
+ }, arguments) };
364
338
 
365
- export function __wbindgen_object_clone_ref(arg0) {
366
- const ret = getObject(arg0);
367
- return addHeapObject(ret);
339
+ export function __wbindgen_init_externref_table() {
340
+ const table = wasm.__wbindgen_export_2;
341
+ const offset = table.grow(4);
342
+ table.set(0, undefined);
343
+ table.set(offset + 0, undefined);
344
+ table.set(offset + 1, null);
345
+ table.set(offset + 2, true);
346
+ table.set(offset + 3, false);
347
+ ;
368
348
  };
369
349
 
370
- export function __wbindgen_object_drop_ref(arg0) {
371
- takeObject(arg0);
350
+ export function __wbindgen_is_undefined(arg0) {
351
+ const ret = arg0 === undefined;
352
+ return ret;
372
353
  };
373
354
 
374
355
  export function __wbindgen_string_get(arg0, arg1) {
375
- const obj = getObject(arg1);
356
+ const obj = arg1;
376
357
  const ret = typeof(obj) === 'string' ? obj : undefined;
377
358
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
378
359
  var len1 = WASM_VECTOR_LEN;
Binary file