@cedar-policy/cedar-wasm 4.6.1 → 4.8.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
@@ -1,5 +1,7 @@
1
1
  let wasm;
2
2
 
3
+ let WASM_VECTOR_LEN = 0;
4
+
3
5
  let cachedUint8ArrayMemory0 = null;
4
6
 
5
7
  function getUint8ArrayMemory0() {
@@ -9,44 +11,6 @@ function getUint8ArrayMemory0() {
9
11
  return cachedUint8ArrayMemory0;
10
12
  }
11
13
 
12
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
-
14
- cachedTextDecoder.decode();
15
-
16
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
- let numBytesDecoded = 0;
18
- function decodeText(ptr, len) {
19
- numBytesDecoded += len;
20
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
- cachedTextDecoder.decode();
23
- numBytesDecoded = len;
24
- }
25
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
- }
27
-
28
- function getStringFromWasm0(ptr, len) {
29
- ptr = ptr >>> 0;
30
- return decodeText(ptr, len);
31
- }
32
-
33
- function addToExternrefTable0(obj) {
34
- const idx = wasm.__externref_table_alloc();
35
- wasm.__wbindgen_export_2.set(idx, obj);
36
- return idx;
37
- }
38
-
39
- function handleError(f, args) {
40
- try {
41
- return f.apply(this, args);
42
- } catch (e) {
43
- const idx = addToExternrefTable0(e);
44
- wasm.__wbindgen_exn_store(idx);
45
- }
46
- }
47
-
48
- let WASM_VECTOR_LEN = 0;
49
-
50
14
  const cachedTextEncoder = new TextEncoder();
51
15
 
52
16
  if (!('encodeInto' in cachedTextEncoder)) {
@@ -111,6 +75,42 @@ function getDataViewMemory0() {
111
75
  }
112
76
  return cachedDataViewMemory0;
113
77
  }
78
+
79
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
80
+
81
+ cachedTextDecoder.decode();
82
+
83
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
84
+ let numBytesDecoded = 0;
85
+ function decodeText(ptr, len) {
86
+ numBytesDecoded += len;
87
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
88
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
89
+ cachedTextDecoder.decode();
90
+ numBytesDecoded = len;
91
+ }
92
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
93
+ }
94
+
95
+ function getStringFromWasm0(ptr, len) {
96
+ ptr = ptr >>> 0;
97
+ return decodeText(ptr, len);
98
+ }
99
+
100
+ function addToExternrefTable0(obj) {
101
+ const idx = wasm.__externref_table_alloc();
102
+ wasm.__wbindgen_externrefs.set(idx, obj);
103
+ return idx;
104
+ }
105
+
106
+ function handleError(f, args) {
107
+ try {
108
+ return f.apply(this, args);
109
+ } catch (e) {
110
+ const idx = addToExternrefTable0(e);
111
+ wasm.__wbindgen_exn_store(idx);
112
+ }
113
+ }
114
114
  /**
115
115
  * @returns {string}
116
116
  */
@@ -165,6 +165,23 @@ export function getValidRequestEnvsTemplate(t, s) {
165
165
  return ret;
166
166
  }
167
167
 
168
+ /**
169
+ * Preparse and cache a schema in thread-local storage
170
+ *
171
+ * # Errors
172
+ *
173
+ * Will return `Err` if the input cannot be parsed. Side-effect free on error.
174
+ * @param {string} schema_name
175
+ * @param {Schema} schema
176
+ * @returns {CheckParseAnswer}
177
+ */
178
+ export function preparseSchema(schema_name, schema) {
179
+ const ptr0 = passStringToWasm0(schema_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
180
+ const len0 = WASM_VECTOR_LEN;
181
+ const ret = wasm.preparseSchema(ptr0, len0, schema);
182
+ return ret;
183
+ }
184
+
168
185
  /**
169
186
  * Preparse and cache a policy set in thread-local storage
170
187
  *
@@ -206,29 +223,52 @@ export function statefulIsAuthorized(call) {
206
223
  }
207
224
 
208
225
  /**
209
- * Preparse and cache a schema in thread-local storage
210
- *
211
- * # Errors
226
+ * Get language version of Cedar
227
+ * @returns {string}
228
+ */
229
+ export function getCedarLangVersion() {
230
+ let deferred1_0;
231
+ let deferred1_1;
232
+ try {
233
+ const ret = wasm.getCedarLangVersion();
234
+ deferred1_0 = ret[0];
235
+ deferred1_1 = ret[1];
236
+ return getStringFromWasm0(ret[0], ret[1]);
237
+ } finally {
238
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
239
+ }
240
+ }
241
+
242
+ /**
243
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
244
+ * @param {FormattingCall} call
245
+ * @returns {FormattingAnswer}
246
+ */
247
+ export function formatPolicies(call) {
248
+ const ret = wasm.formatPolicies(call);
249
+ return ret;
250
+ }
251
+
252
+ /**
253
+ * Parse a policy set and optionally validate it against a provided schema
212
254
  *
213
- * Will return `Err` if the input cannot be parsed. Side-effect free on error.
214
- * @param {string} schema_name
215
- * @param {Schema} schema
216
- * @returns {CheckParseAnswer}
255
+ * This is the basic validator interface, using [`ValidationCall`] and
256
+ * [`ValidationAnswer`] types
257
+ * @param {ValidationCall} call
258
+ * @returns {ValidationAnswer}
217
259
  */
218
- export function preparseSchema(schema_name, schema) {
219
- const ptr0 = passStringToWasm0(schema_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
- const len0 = WASM_VECTOR_LEN;
221
- const ret = wasm.preparseSchema(ptr0, len0, schema);
260
+ export function validate(call) {
261
+ const ret = wasm.validate(call);
222
262
  return ret;
223
263
  }
224
264
 
225
265
  /**
226
- * Check whether a set of entities successfully parses.
227
- * @param {EntitiesParsingCall} call
266
+ * Check whether a context successfully parses.
267
+ * @param {ContextParsingCall} call
228
268
  * @returns {CheckParseAnswer}
229
269
  */
230
- export function checkParseEntities(call) {
231
- const ret = wasm.checkParseEntities(call);
270
+ export function checkParseContext(call) {
271
+ const ret = wasm.checkParseContext(call);
232
272
  return ret;
233
273
  }
234
274
 
@@ -253,22 +293,22 @@ export function checkParsePolicySet(policies) {
253
293
  }
254
294
 
255
295
  /**
256
- * Check whether a context successfully parses.
257
- * @param {ContextParsingCall} call
296
+ * Check whether a set of entities successfully parses.
297
+ * @param {EntitiesParsingCall} call
258
298
  * @returns {CheckParseAnswer}
259
299
  */
260
- export function checkParseContext(call) {
261
- const ret = wasm.checkParseContext(call);
300
+ export function checkParseEntities(call) {
301
+ const ret = wasm.checkParseEntities(call);
262
302
  return ret;
263
303
  }
264
304
 
265
305
  /**
266
- * Return the Cedar (textual) representation of a policy.
267
- * @param {Policy} policy
268
- * @returns {PolicyToTextAnswer}
306
+ * Return the JSON representation of a schema.
307
+ * @param {Schema} schema
308
+ * @returns {SchemaToJsonAnswer}
269
309
  */
270
- export function policyToText(policy) {
271
- const ret = wasm.policyToText(policy);
310
+ export function schemaToJson(schema) {
311
+ const ret = wasm.schemaToJson(schema);
272
312
  return ret;
273
313
  }
274
314
 
@@ -282,16 +322,6 @@ export function schemaToText(schema) {
282
322
  return ret;
283
323
  }
284
324
 
285
- /**
286
- * Return the JSON representation of a template.
287
- * @param {Template} template
288
- * @returns {PolicyToJsonAnswer}
289
- */
290
- export function templateToJson(template) {
291
- const ret = wasm.templateToJson(template);
292
- return ret;
293
- }
294
-
295
325
  /**
296
326
  * Takes a `PolicySet` represented as string and return the policies
297
327
  * and templates split into vecs and sorted by id.
@@ -306,12 +336,12 @@ export function policySetTextToParts(policyset_str) {
306
336
  }
307
337
 
308
338
  /**
309
- * Return the JSON representation of a schema.
310
- * @param {Schema} schema
311
- * @returns {SchemaToJsonAnswer}
339
+ * Return the Cedar (textual) representation of a policy.
340
+ * @param {Policy} policy
341
+ * @returns {PolicyToTextAnswer}
312
342
  */
313
- export function schemaToJson(schema) {
314
- const ret = wasm.schemaToJson(schema);
343
+ export function policyToText(policy) {
344
+ const ret = wasm.policyToText(policy);
315
345
  return ret;
316
346
  }
317
347
 
@@ -336,42 +366,12 @@ export function templateToText(template) {
336
366
  }
337
367
 
338
368
  /**
339
- * Get language version of Cedar
340
- * @returns {string}
341
- */
342
- export function getCedarLangVersion() {
343
- let deferred1_0;
344
- let deferred1_1;
345
- try {
346
- const ret = wasm.getCedarLangVersion();
347
- deferred1_0 = ret[0];
348
- deferred1_1 = ret[1];
349
- return getStringFromWasm0(ret[0], ret[1]);
350
- } finally {
351
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
352
- }
353
- }
354
-
355
- /**
356
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
357
- * @param {FormattingCall} call
358
- * @returns {FormattingAnswer}
359
- */
360
- export function formatPolicies(call) {
361
- const ret = wasm.formatPolicies(call);
362
- return ret;
363
- }
364
-
365
- /**
366
- * Parse a policy set and optionally validate it against a provided schema
367
- *
368
- * This is the basic validator interface, using [`ValidationCall`] and
369
- * [`ValidationAnswer`] types
370
- * @param {ValidationCall} call
371
- * @returns {ValidationAnswer}
369
+ * Return the JSON representation of a template.
370
+ * @param {Template} template
371
+ * @returns {PolicyToJsonAnswer}
372
372
  */
373
- export function validate(call) {
374
- const ret = wasm.validate(call);
373
+ export function templateToJson(template) {
374
+ const ret = wasm.templateToJson(template);
375
375
  return ret;
376
376
  }
377
377
 
@@ -413,19 +413,11 @@ async function __wbg_load(module, imports) {
413
413
  function __wbg_get_imports() {
414
414
  const imports = {};
415
415
  imports.wbg = {};
416
- imports.wbg.__wbg_parse_442f5ba02e5eaf8b = function() { return handleError(function (arg0, arg1) {
417
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
418
- return ret;
419
- }, arguments) };
420
- imports.wbg.__wbg_stringify_b98c93d0a190446a = function() { return handleError(function (arg0) {
421
- const ret = JSON.stringify(arg0);
422
- return ret;
423
- }, arguments) };
424
- imports.wbg.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
416
+ imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
425
417
  const ret = arg0 === undefined;
426
418
  return ret;
427
419
  };
428
- imports.wbg.__wbg_wbindgenstringget_0f16a6ddddef376f = function(arg0, arg1) {
420
+ imports.wbg.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) {
429
421
  const obj = arg1;
430
422
  const ret = typeof(obj) === 'string' ? obj : undefined;
431
423
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -433,11 +425,19 @@ function __wbg_get_imports() {
433
425
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
434
426
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
435
427
  };
436
- imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
428
+ imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
437
429
  throw new Error(getStringFromWasm0(arg0, arg1));
438
430
  };
431
+ imports.wbg.__wbg_parse_2a704d6b78abb2b8 = function() { return handleError(function (arg0, arg1) {
432
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
433
+ return ret;
434
+ }, arguments) };
435
+ imports.wbg.__wbg_stringify_b5fb28f6465d9c3e = function() { return handleError(function (arg0) {
436
+ const ret = JSON.stringify(arg0);
437
+ return ret;
438
+ }, arguments) };
439
439
  imports.wbg.__wbindgen_init_externref_table = function() {
440
- const table = wasm.__wbindgen_export_2;
440
+ const table = wasm.__wbindgen_externrefs;
441
441
  const offset = table.grow(4);
442
442
  table.set(0, undefined);
443
443
  table.set(offset + 0, undefined);
@@ -450,10 +450,6 @@ function __wbg_get_imports() {
450
450
  return imports;
451
451
  }
452
452
 
453
- function __wbg_init_memory(imports, memory) {
454
-
455
- }
456
-
457
453
  function __wbg_finalize_init(instance, module) {
458
454
  wasm = instance.exports;
459
455
  __wbg_init.__wbindgen_wasm_module = module;
@@ -479,8 +475,6 @@ function initSync(module) {
479
475
 
480
476
  const imports = __wbg_get_imports();
481
477
 
482
- __wbg_init_memory(imports);
483
-
484
478
  if (!(module instanceof WebAssembly.Module)) {
485
479
  module = new WebAssembly.Module(module);
486
480
  }
@@ -511,8 +505,6 @@ async function __wbg_init(module_or_path) {
511
505
  module_or_path = fetch(module_or_path);
512
506
  }
513
507
 
514
- __wbg_init_memory(imports);
515
-
516
508
  const { instance, module } = await __wbg_load(await module_or_path, imports);
517
509
 
518
510
  return __wbg_finalize_init(instance, module);
Binary file
@@ -9,11 +9,13 @@ export const isAuthorized: (a: any) => any;
9
9
  export const preparsePolicySet: (a: number, b: number, c: any) => any;
10
10
  export const preparseSchema: (a: number, b: number, c: any) => any;
11
11
  export const statefulIsAuthorized: (a: any) => any;
12
+ export const getCedarLangVersion: () => [number, number];
13
+ export const formatPolicies: (a: any) => any;
14
+ export const validate: (a: any) => any;
12
15
  export const checkParseContext: (a: any) => any;
13
16
  export const checkParseEntities: (a: any) => any;
14
17
  export const checkParsePolicySet: (a: any) => any;
15
18
  export const checkParseSchema: (a: any) => any;
16
- export const getCedarLangVersion: () => [number, number];
17
19
  export const policySetTextToParts: (a: number, b: number) => any;
18
20
  export const policyToJson: (a: any) => any;
19
21
  export const policyToText: (a: any) => any;
@@ -21,12 +23,10 @@ export const schemaToJson: (a: any) => any;
21
23
  export const schemaToText: (a: any) => any;
22
24
  export const templateToJson: (a: any) => any;
23
25
  export const templateToText: (a: any) => any;
24
- export const formatPolicies: (a: any) => any;
25
- export const validate: (a: any) => any;
26
- export const __wbindgen_exn_store: (a: number) => void;
27
- export const __externref_table_alloc: () => number;
28
- export const __wbindgen_export_2: WebAssembly.Table;
29
26
  export const __wbindgen_malloc: (a: number, b: number) => number;
30
27
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
+ export const __wbindgen_exn_store: (a: number) => void;
29
+ export const __externref_table_alloc: () => number;
30
+ export const __wbindgen_externrefs: WebAssembly.Table;
31
31
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
32
32
  export const __wbindgen_start: () => void;
package/web/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@cedar-policy/cedar-wasm",
3
3
  "type": "module",
4
4
  "description": "Wasm bindings and typescript types for Cedar lib",
5
- "version": "4.6.1",
5
+ "version": "4.8.0",
6
6
  "license": "Apache-2.0",
7
7
  "files": [
8
8
  "cedar_wasm_bg.wasm",