@cedar-policy/cedar-wasm 4.3.3 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/web/cedar_wasm.js CHANGED
@@ -18,18 +18,9 @@ function getStringFromWasm0(ptr, len) {
18
18
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
19
19
  }
20
20
 
21
- const heap = new Array(128).fill(undefined);
22
-
23
- heap.push(undefined, null, true, false);
24
-
25
- let heap_next = heap.length;
26
-
27
- function addHeapObject(obj) {
28
- if (heap_next === heap.length) heap.push(heap.length + 1);
29
- const idx = heap_next;
30
- heap_next = heap[idx];
31
-
32
- heap[idx] = obj;
21
+ function addToExternrefTable0(obj) {
22
+ const idx = wasm.__externref_table_alloc();
23
+ wasm.__wbindgen_export_2.set(idx, obj);
33
24
  return idx;
34
25
  }
35
26
 
@@ -37,24 +28,11 @@ function handleError(f, args) {
37
28
  try {
38
29
  return f.apply(this, args);
39
30
  } catch (e) {
40
- wasm.__wbindgen_exn_store(addHeapObject(e));
31
+ const idx = addToExternrefTable0(e);
32
+ wasm.__wbindgen_exn_store(idx);
41
33
  }
42
34
  }
43
35
 
44
- function getObject(idx) { return heap[idx]; }
45
-
46
- function dropObject(idx) {
47
- if (idx < 132) return;
48
- heap[idx] = heap_next;
49
- heap_next = idx;
50
- }
51
-
52
- function takeObject(idx) {
53
- const ret = getObject(idx);
54
- dropObject(idx);
55
- return ret;
56
- }
57
-
58
36
  let WASM_VECTOR_LEN = 0;
59
37
 
60
38
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
@@ -130,8 +108,8 @@ function getDataViewMemory0() {
130
108
  * @returns {GetValidRequestEnvsResult}
131
109
  */
132
110
  export function getValidRequestEnvsTemplate(t, s) {
133
- const ret = wasm.getValidRequestEnvsTemplate(addHeapObject(t), addHeapObject(s));
134
- return takeObject(ret);
111
+ const ret = wasm.getValidRequestEnvsTemplate(t, s);
112
+ return ret;
135
113
  }
136
114
 
137
115
  /**
@@ -141,8 +119,8 @@ export function getValidRequestEnvsTemplate(t, s) {
141
119
  * @returns {GetValidRequestEnvsResult}
142
120
  */
143
121
  export function getValidRequestEnvsPolicy(t, s) {
144
- const ret = wasm.getValidRequestEnvsPolicy(addHeapObject(t), addHeapObject(s));
145
- return takeObject(ret);
122
+ const ret = wasm.getValidRequestEnvsPolicy(t, s);
123
+ return ret;
146
124
  }
147
125
 
148
126
  /**
@@ -152,15 +130,11 @@ export function getCedarVersion() {
152
130
  let deferred1_0;
153
131
  let deferred1_1;
154
132
  try {
155
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
156
- wasm.getCedarSDKVersion(retptr);
157
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
158
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
159
- deferred1_0 = r0;
160
- deferred1_1 = r1;
161
- return getStringFromWasm0(r0, r1);
133
+ const ret = wasm.getCedarVersion();
134
+ deferred1_0 = ret[0];
135
+ deferred1_1 = ret[1];
136
+ return getStringFromWasm0(ret[0], ret[1]);
162
137
  } finally {
163
- wasm.__wbindgen_add_to_stack_pointer(16);
164
138
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
165
139
  }
166
140
  }
@@ -172,19 +146,65 @@ export function getCedarSDKVersion() {
172
146
  let deferred1_0;
173
147
  let deferred1_1;
174
148
  try {
175
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
176
- wasm.getCedarSDKVersion(retptr);
177
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
178
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
179
- deferred1_0 = r0;
180
- deferred1_1 = r1;
181
- return getStringFromWasm0(r0, r1);
149
+ const ret = wasm.getCedarSDKVersion();
150
+ deferred1_0 = ret[0];
151
+ deferred1_1 = ret[1];
152
+ return getStringFromWasm0(ret[0], ret[1]);
182
153
  } finally {
183
- wasm.__wbindgen_add_to_stack_pointer(16);
184
154
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
185
155
  }
186
156
  }
187
157
 
158
+ /**
159
+ * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
160
+ * @param {AuthorizationCall} call
161
+ * @returns {AuthorizationAnswer}
162
+ */
163
+ export function isAuthorized(call) {
164
+ const ret = wasm.isAuthorized(call);
165
+ return ret;
166
+ }
167
+
168
+ /**
169
+ * Check whether a policy set successfully parses.
170
+ * @param {PolicySet} policies
171
+ * @returns {CheckParseAnswer}
172
+ */
173
+ export function checkParsePolicySet(policies) {
174
+ const ret = wasm.checkParsePolicySet(policies);
175
+ return ret;
176
+ }
177
+
178
+ /**
179
+ * Check whether a schema successfully parses.
180
+ * @param {Schema} schema
181
+ * @returns {CheckParseAnswer}
182
+ */
183
+ export function checkParseSchema(schema) {
184
+ const ret = wasm.checkParseSchema(schema);
185
+ return ret;
186
+ }
187
+
188
+ /**
189
+ * Check whether a set of entities successfully parses.
190
+ * @param {EntitiesParsingCall} call
191
+ * @returns {CheckParseAnswer}
192
+ */
193
+ export function checkParseEntities(call) {
194
+ const ret = wasm.checkParseEntities(call);
195
+ return ret;
196
+ }
197
+
198
+ /**
199
+ * Check whether a context successfully parses.
200
+ * @param {ContextParsingCall} call
201
+ * @returns {CheckParseAnswer}
202
+ */
203
+ export function checkParseContext(call) {
204
+ const ret = wasm.checkParseContext(call);
205
+ return ret;
206
+ }
207
+
188
208
  /**
189
209
  * Parse a policy set and optionally validate it against a provided schema
190
210
  *
@@ -194,29 +214,18 @@ export function getCedarSDKVersion() {
194
214
  * @returns {ValidationAnswer}
195
215
  */
196
216
  export function validate(call) {
197
- const ret = wasm.validate(addHeapObject(call));
198
- return takeObject(ret);
217
+ const ret = wasm.validate(call);
218
+ return ret;
199
219
  }
200
220
 
201
221
  /**
202
- * Get language version of Cedar
203
- * @returns {string}
222
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
223
+ * @param {FormattingCall} call
224
+ * @returns {FormattingAnswer}
204
225
  */
205
- export function getCedarLangVersion() {
206
- let deferred1_0;
207
- let deferred1_1;
208
- try {
209
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
210
- wasm.getCedarLangVersion(retptr);
211
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
212
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
213
- deferred1_0 = r0;
214
- deferred1_1 = r1;
215
- return getStringFromWasm0(r0, r1);
216
- } finally {
217
- wasm.__wbindgen_add_to_stack_pointer(16);
218
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
219
- }
226
+ export function formatPolicies(call) {
227
+ const ret = wasm.formatPolicies(call);
228
+ return ret;
220
229
  }
221
230
 
222
231
  /**
@@ -225,8 +234,8 @@ export function getCedarLangVersion() {
225
234
  * @returns {PolicyToTextAnswer}
226
235
  */
227
236
  export function policyToText(policy) {
228
- const ret = wasm.policyToText(addHeapObject(policy));
229
- return takeObject(ret);
237
+ const ret = wasm.policyToText(policy);
238
+ return ret;
230
239
  }
231
240
 
232
241
  /**
@@ -235,8 +244,8 @@ export function policyToText(policy) {
235
244
  * @returns {PolicyToTextAnswer}
236
245
  */
237
246
  export function templateToText(template) {
238
- const ret = wasm.templateToText(addHeapObject(template));
239
- return takeObject(ret);
247
+ const ret = wasm.templateToText(template);
248
+ return ret;
240
249
  }
241
250
 
242
251
  /**
@@ -245,8 +254,8 @@ export function templateToText(template) {
245
254
  * @returns {PolicyToJsonAnswer}
246
255
  */
247
256
  export function policyToJson(policy) {
248
- const ret = wasm.policyToJson(addHeapObject(policy));
249
- return takeObject(ret);
257
+ const ret = wasm.policyToJson(policy);
258
+ return ret;
250
259
  }
251
260
 
252
261
  /**
@@ -255,8 +264,8 @@ export function policyToJson(policy) {
255
264
  * @returns {PolicyToJsonAnswer}
256
265
  */
257
266
  export function templateToJson(template) {
258
- const ret = wasm.templateToJson(addHeapObject(template));
259
- return takeObject(ret);
267
+ const ret = wasm.templateToJson(template);
268
+ return ret;
260
269
  }
261
270
 
262
271
  /**
@@ -265,8 +274,8 @@ export function templateToJson(template) {
265
274
  * @returns {SchemaToTextAnswer}
266
275
  */
267
276
  export function schemaToText(schema) {
268
- const ret = wasm.schemaToText(addHeapObject(schema));
269
- return takeObject(ret);
277
+ const ret = wasm.schemaToText(schema);
278
+ return ret;
270
279
  }
271
280
 
272
281
  /**
@@ -275,68 +284,25 @@ export function schemaToText(schema) {
275
284
  * @returns {SchemaToJsonAnswer}
276
285
  */
277
286
  export function schemaToJson(schema) {
278
- const ret = wasm.schemaToJson(addHeapObject(schema));
279
- return takeObject(ret);
280
- }
281
-
282
- /**
283
- * Check whether a policy set successfully parses.
284
- * @param {PolicySet} policies
285
- * @returns {CheckParseAnswer}
286
- */
287
- export function checkParsePolicySet(policies) {
288
- const ret = wasm.checkParsePolicySet(addHeapObject(policies));
289
- return takeObject(ret);
290
- }
291
-
292
- /**
293
- * Check whether a schema successfully parses.
294
- * @param {Schema} schema
295
- * @returns {CheckParseAnswer}
296
- */
297
- export function checkParseSchema(schema) {
298
- const ret = wasm.checkParseSchema(addHeapObject(schema));
299
- return takeObject(ret);
300
- }
301
-
302
- /**
303
- * Check whether a set of entities successfully parses.
304
- * @param {EntitiesParsingCall} call
305
- * @returns {CheckParseAnswer}
306
- */
307
- export function checkParseEntities(call) {
308
- const ret = wasm.checkParseEntities(addHeapObject(call));
309
- return takeObject(ret);
310
- }
311
-
312
- /**
313
- * Check whether a context successfully parses.
314
- * @param {ContextParsingCall} call
315
- * @returns {CheckParseAnswer}
316
- */
317
- export function checkParseContext(call) {
318
- const ret = wasm.checkParseContext(addHeapObject(call));
319
- return takeObject(ret);
320
- }
321
-
322
- /**
323
- * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
324
- * @param {AuthorizationCall} call
325
- * @returns {AuthorizationAnswer}
326
- */
327
- export function isAuthorized(call) {
328
- const ret = wasm.isAuthorized(addHeapObject(call));
329
- return takeObject(ret);
287
+ const ret = wasm.schemaToJson(schema);
288
+ return ret;
330
289
  }
331
290
 
332
291
  /**
333
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
334
- * @param {FormattingCall} call
335
- * @returns {FormattingAnswer}
292
+ * Get language version of Cedar
293
+ * @returns {string}
336
294
  */
337
- export function formatPolicies(call) {
338
- const ret = wasm.formatPolicies(addHeapObject(call));
339
- return takeObject(ret);
295
+ export function getCedarLangVersion() {
296
+ let deferred1_0;
297
+ let deferred1_1;
298
+ try {
299
+ const ret = wasm.getCedarLangVersion();
300
+ deferred1_0 = ret[0];
301
+ deferred1_1 = ret[1];
302
+ return getStringFromWasm0(ret[0], ret[1]);
303
+ } finally {
304
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
305
+ }
340
306
  }
341
307
 
342
308
  async function __wbg_load(module, imports) {
@@ -375,25 +341,28 @@ function __wbg_get_imports() {
375
341
  imports.wbg = {};
376
342
  imports.wbg.__wbg_parse_def2e24ef1252aff = function() { return handleError(function (arg0, arg1) {
377
343
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
378
- return addHeapObject(ret);
344
+ return ret;
379
345
  }, arguments) };
380
346
  imports.wbg.__wbg_stringify_f7ed6987935b4a24 = function() { return handleError(function (arg0) {
381
- const ret = JSON.stringify(getObject(arg0));
382
- return addHeapObject(ret);
347
+ const ret = JSON.stringify(arg0);
348
+ return ret;
383
349
  }, arguments) };
350
+ imports.wbg.__wbindgen_init_externref_table = function() {
351
+ const table = wasm.__wbindgen_export_2;
352
+ const offset = table.grow(4);
353
+ table.set(0, undefined);
354
+ table.set(offset + 0, undefined);
355
+ table.set(offset + 1, null);
356
+ table.set(offset + 2, true);
357
+ table.set(offset + 3, false);
358
+ ;
359
+ };
384
360
  imports.wbg.__wbindgen_is_undefined = function(arg0) {
385
- const ret = getObject(arg0) === undefined;
361
+ const ret = arg0 === undefined;
386
362
  return ret;
387
363
  };
388
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
389
- const ret = getObject(arg0);
390
- return addHeapObject(ret);
391
- };
392
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
393
- takeObject(arg0);
394
- };
395
364
  imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
396
- const obj = getObject(arg1);
365
+ const obj = arg1;
397
366
  const ret = typeof(obj) === 'string' ? obj : undefined;
398
367
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
399
368
  var len1 = WASM_VECTOR_LEN;
@@ -418,7 +387,7 @@ function __wbg_finalize_init(instance, module) {
418
387
  cachedUint8ArrayMemory0 = null;
419
388
 
420
389
 
421
-
390
+ wasm.__wbindgen_start();
422
391
  return wasm;
423
392
  }
424
393
 
Binary file
@@ -1,26 +1,28 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
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;
4
+ export const getValidRequestEnvsTemplate: (a: any, b: any) => any;
5
+ export const getValidRequestEnvsPolicy: (a: any, b: any) => any;
6
+ export const getCedarSDKVersion: () => [number, number];
7
+ export const getCedarVersion: () => [number, number];
8
+ export const isAuthorized: (a: any) => any;
9
+ export const checkParsePolicySet: (a: any) => any;
10
+ export const checkParseSchema: (a: any) => any;
11
+ export const checkParseEntities: (a: any) => any;
12
+ export const checkParseContext: (a: any) => any;
13
+ export const validate: (a: any) => any;
14
+ export const formatPolicies: (a: any) => any;
15
+ export const policyToText: (a: any) => any;
16
+ export const templateToText: (a: any) => any;
17
+ export const policyToJson: (a: any) => any;
18
+ export const templateToJson: (a: any) => any;
19
+ export const schemaToText: (a: any) => any;
20
+ export const schemaToJson: (a: any) => any;
21
+ export const getCedarLangVersion: () => [number, number];
22
22
  export const __wbindgen_exn_store: (a: number) => void;
23
+ export const __externref_table_alloc: () => number;
24
+ export const __wbindgen_export_2: WebAssembly.Table;
23
25
  export const __wbindgen_malloc: (a: number, b: number) => number;
24
26
  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
27
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
28
+ export const __wbindgen_start: () => void;
package/web/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
+ "type": "module",
3
4
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "4.3.3",
5
+ "version": "4.4.0",
5
6
  "license": "Apache-2.0",
6
7
  "files": [
7
8
  "cedar_wasm_bg.wasm",
8
9
  "cedar_wasm.js",
9
10
  "cedar_wasm.d.ts"
10
11
  ],
11
- "module": "cedar_wasm.js",
12
+ "main": "cedar_wasm.js",
12
13
  "types": "cedar_wasm.d.ts",
13
14
  "sideEffects": [
14
15
  "./snippets/*"
15
- ],
16
- "type": "module"
16
+ ]
17
17
  }