@cedar-policy/cedar-wasm 4.2.2 → 4.3.3

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.
@@ -2,118 +2,91 @@
2
2
  /* eslint-disable */
3
3
  /**
4
4
  * Get valid request environment
5
- * @param {Template} t
6
- * @param {Schema} s
7
- * @returns {GetValidRequestEnvsResult}
8
5
  */
9
6
  export function getValidRequestEnvsTemplate(t: Template, s: Schema): GetValidRequestEnvsResult;
10
7
  /**
11
8
  * Get valid request environment
12
- * @param {Policy} t
13
- * @param {Schema} s
14
- * @returns {GetValidRequestEnvsResult}
15
9
  */
16
10
  export function getValidRequestEnvsPolicy(t: Policy, s: Schema): GetValidRequestEnvsResult;
11
+ export function getCedarVersion(): string;
12
+ export function getCedarSDKVersion(): string;
17
13
  /**
18
- * @returns {string}
14
+ * Parse a policy set and optionally validate it against a provided schema
15
+ *
16
+ * This is the basic validator interface, using [`ValidationCall`] and
17
+ * [`ValidationAnswer`] types
19
18
  */
20
- export function getCedarVersion(): string;
19
+ export function validate(call: ValidationCall): ValidationAnswer;
21
20
  /**
22
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
23
- * @param {FormattingCall} call
24
- * @returns {FormattingAnswer}
21
+ * Get language version of Cedar
25
22
  */
26
- export function formatPolicies(call: FormattingCall): FormattingAnswer;
23
+ export function getCedarLangVersion(): string;
27
24
  /**
28
25
  * Return the Cedar (textual) representation of a policy.
29
- * @param {Policy} policy
30
- * @returns {PolicyToTextAnswer}
31
26
  */
32
27
  export function policyToText(policy: Policy): PolicyToTextAnswer;
33
28
  /**
34
29
  * Return the Cedar (textual) representation of a template.
35
- * @param {Template} template
36
- * @returns {PolicyToTextAnswer}
37
30
  */
38
31
  export function templateToText(template: Template): PolicyToTextAnswer;
39
32
  /**
40
33
  * Return the JSON representation of a policy.
41
- * @param {Policy} policy
42
- * @returns {PolicyToJsonAnswer}
43
34
  */
44
35
  export function policyToJson(policy: Policy): PolicyToJsonAnswer;
45
36
  /**
46
37
  * Return the JSON representation of a template.
47
- * @param {Template} template
48
- * @returns {PolicyToJsonAnswer}
49
38
  */
50
39
  export function templateToJson(template: Template): PolicyToJsonAnswer;
51
40
  /**
52
41
  * Return the Cedar (textual) representation of a schema.
53
- * @param {Schema} schema
54
- * @returns {SchemaToTextAnswer}
55
42
  */
56
43
  export function schemaToText(schema: Schema): SchemaToTextAnswer;
57
44
  /**
58
45
  * Return the JSON representation of a schema.
59
- * @param {Schema} schema
60
- * @returns {SchemaToJsonAnswer}
61
46
  */
62
47
  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
48
  /**
79
49
  * Check whether a policy set successfully parses.
80
- * @param {PolicySet} policies
81
- * @returns {CheckParseAnswer}
82
50
  */
83
51
  export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
84
52
  /**
85
53
  * Check whether a schema successfully parses.
86
- * @param {Schema} schema
87
- * @returns {CheckParseAnswer}
88
54
  */
89
55
  export function checkParseSchema(schema: Schema): CheckParseAnswer;
90
56
  /**
91
57
  * Check whether a set of entities successfully parses.
92
- * @param {EntitiesParsingCall} call
93
- * @returns {CheckParseAnswer}
94
58
  */
95
59
  export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
96
60
  /**
97
61
  * Check whether a context successfully parses.
98
- * @param {ContextParsingCall} call
99
- * @returns {CheckParseAnswer}
100
62
  */
101
63
  export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
64
+ /**
65
+ * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
66
+ */
67
+ export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
68
+ /**
69
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
70
+ */
71
+ export function formatPolicies(call: FormattingCall): FormattingAnswer;
102
72
  export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
103
73
 
104
- export type SlotId = string;
105
-
106
- export type PolicyId = string;
74
+ export interface ValidationCall {
75
+ validationSettings?: ValidationSettings;
76
+ schema: Schema;
77
+ policies: PolicySet;
78
+ }
107
79
 
108
- export type ValidationMode = "strict";
80
+ export interface ValidationSettings {
81
+ mode: ValidationMode;
82
+ }
109
83
 
110
- export interface FormattingCall {
111
- policyText: string;
112
- lineWidth?: number;
113
- indentWidth?: number;
84
+ export interface ValidationError {
85
+ policyId: string;
86
+ error: DetailedError;
114
87
  }
115
88
 
116
- export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
89
+ export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
117
90
 
118
91
  export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
119
92
 
@@ -123,6 +96,23 @@ export type SchemaToTextAnswer = { type: "success"; text: string; warnings: Deta
123
96
 
124
97
  export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
125
98
 
99
+ export type SlotId = string;
100
+
101
+ export type PolicyId = string;
102
+
103
+ export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
104
+
105
+ export interface EntitiesParsingCall {
106
+ entities: Entities;
107
+ schema?: Schema | null;
108
+ }
109
+
110
+ export interface ContextParsingCall {
111
+ context: Context;
112
+ schema?: Schema | null;
113
+ action?: EntityUid | null;
114
+ }
115
+
126
116
  export interface Response {
127
117
  decision: Decision;
128
118
  diagnostics: Diagnostics;
@@ -151,35 +141,13 @@ export interface AuthorizationCall {
151
141
  entities: Entities;
152
142
  }
153
143
 
154
- export interface ValidationCall {
155
- validationSettings?: ValidationSettings;
156
- schema: Schema;
157
- policies: PolicySet;
158
- }
159
-
160
- export interface ValidationSettings {
161
- mode: ValidationMode;
162
- }
163
-
164
- export interface ValidationError {
165
- policyId: string;
166
- error: DetailedError;
167
- }
168
-
169
- export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
170
-
171
- export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
172
-
173
- export interface EntitiesParsingCall {
174
- entities: Entities;
175
- schema?: Schema | null;
144
+ export interface FormattingCall {
145
+ policyText: string;
146
+ lineWidth?: number;
147
+ indentWidth?: number;
176
148
  }
177
149
 
178
- export interface ContextParsingCall {
179
- context: Context;
180
- schema?: Schema | null;
181
- action?: EntityUid | null;
182
- }
150
+ export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
183
151
 
184
152
  export type Schema = string | SchemaJson<string>;
185
153
 
@@ -228,6 +196,8 @@ export interface DetailedError {
228
196
  related?: DetailedError[];
229
197
  }
230
198
 
199
+ export type ValidationMode = "strict";
200
+
231
201
  export type TypeVariant<N> = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: Type<N> } | ({ type: "Record" } & RecordType<N>) | { type: "Entity"; name: N } | { type: "EntityOrCommon"; name: N } | { type: "Extension"; name: UnreservedId };
232
202
 
233
203
  export interface RecordType<N> {
@@ -235,7 +205,7 @@ export interface RecordType<N> {
235
205
  additionalAttributes?: boolean;
236
206
  }
237
207
 
238
- export type Type<N> = TypeVariant<N> | { type: N };
208
+ export type Type<N> = ({} & TypeVariant<N>) | { type: N };
239
209
 
240
210
  export interface ActionEntityUID<N> {
241
211
  id: SmolStr;
@@ -252,6 +222,7 @@ export interface ActionType<N> {
252
222
  attributes?: Record<SmolStr, CedarValueJson>;
253
223
  appliesTo?: ApplySpec<N>;
254
224
  memberOf?: ActionEntityUID<N>[];
225
+ annotations?: Annotations;
255
226
  }
256
227
 
257
228
  export type AttributesOrContext<N> = Type<N>;
@@ -260,12 +231,14 @@ export interface EntityType<N> {
260
231
  memberOfTypes?: N[];
261
232
  shape?: AttributesOrContext<N>;
262
233
  tags?: Type<N>;
234
+ annotations?: Annotations;
263
235
  }
264
236
 
265
237
  export interface NamespaceDefinition<N> {
266
- commonTypes?: Record<CommonTypeId, Type<N>>;
238
+ commonTypes?: Record<CommonTypeId, CommonType<N>>;
267
239
  entityTypes: Record<UnreservedId, EntityType<N>>;
268
240
  actions: Record<SmolStr, ActionType<N>>;
241
+ annotations?: Annotations;
269
242
  }
270
243
 
271
244
  export type CommonTypeId = string;
@@ -280,45 +253,28 @@ export interface PolicyJson {
280
253
  action: ActionConstraint;
281
254
  resource: ResourceConstraint;
282
255
  conditions: Clause[];
283
- annotations?: Record<string, string>;
256
+ annotations?: Annotations;
284
257
  }
285
258
 
286
- export type Effect = "permit" | "forbid";
287
-
288
- export type UnreservedId = string;
289
-
290
- export interface EntityJson {
291
- uid: EntityUidJson;
292
- attrs: Record<string, CedarValueJson>;
293
- parents: EntityUidJson[];
294
- tags?: Record<string, CedarValueJson>;
295
- }
296
-
297
- export type Decision = "allow" | "deny";
298
-
299
- export type Var = "principal" | "action" | "resource" | "context";
300
-
301
259
  export type ExtFuncCall = {} & Record<string, Array<Expr>>;
302
260
 
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> };
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> };
304
262
 
305
263
  export type PatternElem = "Wildcard" | { Literal: SmolStr };
306
264
 
307
265
  export type Expr = ExprNoExt | ExtFuncCall;
308
266
 
309
- export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
267
+ export type AnyId = SmolStr;
310
268
 
311
- export interface FnAndArg {
312
- fn: string;
313
- arg: CedarValueJson;
314
- }
269
+ export type UnreservedId = string;
315
270
 
316
- export interface TypeAndId {
317
- type: string;
318
- id: string;
319
- }
271
+ export type Effect = "permit" | "forbid";
320
272
 
321
- export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
273
+ export type Annotations = Record<string, Annotation>;
274
+
275
+ export type Decision = "allow" | "deny";
276
+
277
+ export type Annotation = SmolStr;
322
278
 
323
279
  export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
324
280
 
@@ -337,5 +293,29 @@ export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | (
337
293
 
338
294
  export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
339
295
 
296
+ export type Var = "principal" | "action" | "resource" | "context";
297
+
298
+ export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
299
+
300
+ export interface FnAndArg {
301
+ fn: string;
302
+ arg: CedarValueJson;
303
+ }
304
+
305
+ export interface TypeAndId {
306
+ type: string;
307
+ id: string;
308
+ }
309
+
310
+ export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
311
+
312
+ export interface EntityJson {
313
+ uid: EntityUidJson;
314
+ attrs: Record<string, CedarValueJson>;
315
+ parents: EntityUidJson[];
316
+ tags?: Record<string, CedarValueJson>;
317
+ }
318
+
340
319
  type SmolStr = string;
341
320
  export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
321
+ export type CommonType<N> = Type<N> & { annotations?: Annotations };
@@ -4,12 +4,30 @@ export function __wbg_set_wasm(val) {
4
4
  }
5
5
 
6
6
 
7
+ const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
8
+
9
+ let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
10
+
11
+ cachedTextDecoder.decode();
12
+
13
+ let cachedUint8ArrayMemory0 = null;
14
+
15
+ function getUint8ArrayMemory0() {
16
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
17
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
18
+ }
19
+ return cachedUint8ArrayMemory0;
20
+ }
21
+
22
+ function getStringFromWasm0(ptr, len) {
23
+ ptr = ptr >>> 0;
24
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
25
+ }
26
+
7
27
  const heap = new Array(128).fill(undefined);
8
28
 
9
29
  heap.push(undefined, null, true, false);
10
30
 
11
- function getObject(idx) { return heap[idx]; }
12
-
13
31
  let heap_next = heap.length;
14
32
 
15
33
  function addHeapObject(obj) {
@@ -21,6 +39,16 @@ function addHeapObject(obj) {
21
39
  return idx;
22
40
  }
23
41
 
42
+ function handleError(f, args) {
43
+ try {
44
+ return f.apply(this, args);
45
+ } catch (e) {
46
+ wasm.__wbindgen_exn_store(addHeapObject(e));
47
+ }
48
+ }
49
+
50
+ function getObject(idx) { return heap[idx]; }
51
+
24
52
  function dropObject(idx) {
25
53
  if (idx < 132) return;
26
54
  heap[idx] = heap_next;
@@ -35,15 +63,6 @@ function takeObject(idx) {
35
63
 
36
64
  let WASM_VECTOR_LEN = 0;
37
65
 
38
- let cachedUint8ArrayMemory0 = null;
39
-
40
- function getUint8ArrayMemory0() {
41
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
42
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
43
- }
44
- return cachedUint8ArrayMemory0;
45
- }
46
-
47
66
  const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
48
67
 
49
68
  let cachedTextEncoder = new lTextEncoder('utf-8');
@@ -112,17 +131,6 @@ function getDataViewMemory0() {
112
131
  }
113
132
  return cachedDataViewMemory0;
114
133
  }
115
-
116
- const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
117
-
118
- let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
119
-
120
- cachedTextDecoder.decode();
121
-
122
- function getStringFromWasm0(ptr, len) {
123
- ptr = ptr >>> 0;
124
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
125
- }
126
134
  /**
127
135
  * Get valid request environment
128
136
  * @param {Template} t
@@ -153,7 +161,7 @@ export function getCedarVersion() {
153
161
  let deferred1_1;
154
162
  try {
155
163
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
156
- wasm.getCedarVersion(retptr);
164
+ wasm.getCedarSDKVersion(retptr);
157
165
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
158
166
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
159
167
  deferred1_0 = r0;
@@ -166,15 +174,59 @@ export function getCedarVersion() {
166
174
  }
167
175
 
168
176
  /**
169
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
170
- * @param {FormattingCall} call
171
- * @returns {FormattingAnswer}
177
+ * @returns {string}
172
178
  */
173
- export function formatPolicies(call) {
174
- const ret = wasm.formatPolicies(addHeapObject(call));
179
+ export function getCedarSDKVersion() {
180
+ let deferred1_0;
181
+ let deferred1_1;
182
+ 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);
190
+ } finally {
191
+ wasm.__wbindgen_add_to_stack_pointer(16);
192
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Parse a policy set and optionally validate it against a provided schema
198
+ *
199
+ * This is the basic validator interface, using [`ValidationCall`] and
200
+ * [`ValidationAnswer`] types
201
+ * @param {ValidationCall} call
202
+ * @returns {ValidationAnswer}
203
+ */
204
+ export function validate(call) {
205
+ const ret = wasm.validate(addHeapObject(call));
175
206
  return takeObject(ret);
176
207
  }
177
208
 
209
+ /**
210
+ * Get language version of Cedar
211
+ * @returns {string}
212
+ */
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
+ }
228
+ }
229
+
178
230
  /**
179
231
  * Return the Cedar (textual) representation of a policy.
180
232
  * @param {Policy} policy
@@ -235,29 +287,6 @@ export function schemaToJson(schema) {
235
287
  return takeObject(ret);
236
288
  }
237
289
 
238
- /**
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));
245
- return takeObject(ret);
246
- }
247
-
248
- /**
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
- return takeObject(ret);
259
- }
260
-
261
290
  /**
262
291
  * Check whether a policy set successfully parses.
263
292
  * @param {PolicySet} policies
@@ -298,14 +327,41 @@ export function checkParseContext(call) {
298
327
  return takeObject(ret);
299
328
  }
300
329
 
301
- function handleError(f, args) {
302
- try {
303
- return f.apply(this, args);
304
- } catch (e) {
305
- wasm.__wbindgen_exn_store(addHeapObject(e));
306
- }
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);
338
+ }
339
+
340
+ /**
341
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
342
+ * @param {FormattingCall} call
343
+ * @returns {FormattingAnswer}
344
+ */
345
+ export function formatPolicies(call) {
346
+ const ret = wasm.formatPolicies(addHeapObject(call));
347
+ return takeObject(ret);
307
348
  }
308
349
 
350
+ export function __wbg_parse_def2e24ef1252aff() { return handleError(function (arg0, arg1) {
351
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
352
+ return addHeapObject(ret);
353
+ }, arguments) };
354
+
355
+ 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;
362
+ return ret;
363
+ };
364
+
309
365
  export function __wbindgen_object_clone_ref(arg0) {
310
366
  const ret = getObject(arg0);
311
367
  return addHeapObject(ret);
@@ -315,11 +371,6 @@ export function __wbindgen_object_drop_ref(arg0) {
315
371
  takeObject(arg0);
316
372
  };
317
373
 
318
- export function __wbindgen_is_undefined(arg0) {
319
- const ret = getObject(arg0) === undefined;
320
- return ret;
321
- };
322
-
323
374
  export function __wbindgen_string_get(arg0, arg1) {
324
375
  const obj = getObject(arg1);
325
376
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -329,16 +380,6 @@ export function __wbindgen_string_get(arg0, arg1) {
329
380
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
330
381
  };
331
382
 
332
- export function __wbg_parse_51ee5409072379d3() { return handleError(function (arg0, arg1) {
333
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
334
- return addHeapObject(ret);
335
- }, arguments) };
336
-
337
- export function __wbg_stringify_eead5648c09faaf8() { return handleError(function (arg0) {
338
- const ret = JSON.stringify(getObject(arg0));
339
- return addHeapObject(ret);
340
- }, arguments) };
341
-
342
383
  export function __wbindgen_throw(arg0, arg1) {
343
384
  throw new Error(getStringFromWasm0(arg0, arg1));
344
385
  };
Binary file
@@ -1,24 +1,26 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function getValidRequestEnvsTemplate(a: number, b: number): number;
5
- export function getValidRequestEnvsPolicy(a: number, b: number): number;
6
- export function getCedarVersion(a: number): void;
7
- export function formatPolicies(a: number): number;
8
- export function policyToText(a: number): number;
9
- export function templateToText(a: number): number;
10
- export function policyToJson(a: number): number;
11
- export function templateToJson(a: number): number;
12
- export function schemaToText(a: number): number;
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
- export function __wbindgen_malloc(a: number, b: number): number;
21
- export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
22
- export function __wbindgen_add_to_stack_pointer(a: number): number;
23
- export function __wbindgen_free(a: number, b: number, c: number): void;
24
- export function __wbindgen_exn_store(a: number): void;
4
+ export const getValidRequestEnvsTemplate: (a: number, b: number) => number;
5
+ export const getValidRequestEnvsPolicy: (a: number, b: number) => number;
6
+ export const getCedarSDKVersion: (a: number) => void;
7
+ export const getCedarVersion: (a: number) => void;
8
+ export const validate: (a: number) => number;
9
+ export const getCedarLangVersion: (a: number) => void;
10
+ export const policyToText: (a: number) => number;
11
+ export const templateToText: (a: number) => number;
12
+ export const policyToJson: (a: number) => number;
13
+ export const templateToJson: (a: number) => number;
14
+ export const schemaToText: (a: number) => number;
15
+ export const schemaToJson: (a: number) => number;
16
+ export const checkParsePolicySet: (a: number) => number;
17
+ export const checkParseSchema: (a: number) => number;
18
+ export const checkParseEntities: (a: number) => number;
19
+ export const checkParseContext: (a: number) => number;
20
+ export const isAuthorized: (a: number) => number;
21
+ export const formatPolicies: (a: number) => number;
22
+ export const __wbindgen_exn_store: (a: number) => void;
23
+ export const __wbindgen_malloc: (a: number, b: number) => number;
24
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
25
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
26
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
package/esm/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
- "type": "module",
4
3
  "description": "Wasm bindings and typescript types for Cedar lib",
5
- "version": "4.2.2",
4
+ "version": "4.3.3",
6
5
  "license": "Apache-2.0",
7
6
  "files": [
8
7
  "cedar_wasm_bg.wasm",
@@ -10,10 +9,11 @@
10
9
  "cedar_wasm_bg.js",
11
10
  "cedar_wasm.d.ts"
12
11
  ],
13
- "main": "cedar_wasm.js",
12
+ "module": "cedar_wasm.js",
14
13
  "types": "cedar_wasm.d.ts",
15
14
  "sideEffects": [
16
15
  "./cedar_wasm.js",
17
16
  "./snippets/*"
18
- ]
17
+ ],
18
+ "type": "module"
19
19
  }