@cedar-policy/cedar-wasm 4.8.2 → 4.9.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.
@@ -1,104 +1,4 @@
1
-
2
- let imports = {};
3
- imports['__wbindgen_placeholder__'] = module.exports;
4
-
5
- function addToExternrefTable0(obj) {
6
- const idx = wasm.__externref_table_alloc();
7
- wasm.__wbindgen_externrefs.set(idx, obj);
8
- return idx;
9
- }
10
-
11
- let cachedDataViewMemory0 = null;
12
- function getDataViewMemory0() {
13
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
14
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
15
- }
16
- return cachedDataViewMemory0;
17
- }
18
-
19
- function getStringFromWasm0(ptr, len) {
20
- ptr = ptr >>> 0;
21
- return decodeText(ptr, len);
22
- }
23
-
24
- let cachedUint8ArrayMemory0 = null;
25
- function getUint8ArrayMemory0() {
26
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
27
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
28
- }
29
- return cachedUint8ArrayMemory0;
30
- }
31
-
32
- function handleError(f, args) {
33
- try {
34
- return f.apply(this, args);
35
- } catch (e) {
36
- const idx = addToExternrefTable0(e);
37
- wasm.__wbindgen_exn_store(idx);
38
- }
39
- }
40
-
41
- function isLikeNone(x) {
42
- return x === undefined || x === null;
43
- }
44
-
45
- function passStringToWasm0(arg, malloc, realloc) {
46
- if (realloc === undefined) {
47
- const buf = cachedTextEncoder.encode(arg);
48
- const ptr = malloc(buf.length, 1) >>> 0;
49
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
50
- WASM_VECTOR_LEN = buf.length;
51
- return ptr;
52
- }
53
-
54
- let len = arg.length;
55
- let ptr = malloc(len, 1) >>> 0;
56
-
57
- const mem = getUint8ArrayMemory0();
58
-
59
- let offset = 0;
60
-
61
- for (; offset < len; offset++) {
62
- const code = arg.charCodeAt(offset);
63
- if (code > 0x7F) break;
64
- mem[ptr + offset] = code;
65
- }
66
- if (offset !== len) {
67
- if (offset !== 0) {
68
- arg = arg.slice(offset);
69
- }
70
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
71
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
72
- const ret = cachedTextEncoder.encodeInto(arg, view);
73
-
74
- offset += ret.written;
75
- ptr = realloc(ptr, len, offset, 1) >>> 0;
76
- }
77
-
78
- WASM_VECTOR_LEN = offset;
79
- return ptr;
80
- }
81
-
82
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
83
- cachedTextDecoder.decode();
84
- function decodeText(ptr, len) {
85
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
86
- }
87
-
88
- const cachedTextEncoder = new TextEncoder();
89
-
90
- if (!('encodeInto' in cachedTextEncoder)) {
91
- cachedTextEncoder.encodeInto = function (arg, view) {
92
- const buf = cachedTextEncoder.encode(arg);
93
- view.set(buf);
94
- return {
95
- read: arg.length,
96
- written: buf.length
97
- };
98
- }
99
- }
100
-
101
- let WASM_VECTOR_LEN = 0;
1
+ /* @ts-self-types="./cedar_wasm.d.ts" */
102
2
 
103
3
  /**
104
4
  * Check whether a context successfully parses.
@@ -325,6 +225,24 @@ function schemaToJson(schema) {
325
225
  }
326
226
  exports.schemaToJson = schemaToJson;
327
227
 
228
+ /**
229
+ * Convert a Cedar schema string to JSON format with resolved types.
230
+ *
231
+ * This function resolves ambiguous "`EntityOrCommon`" types to their specific
232
+ * Entity or `CommonType` classifications using the schema's type definitions.
233
+ * This is primarily meant to be used when working with schemas programmatically,
234
+ * for example when creating a schema building UI.
235
+ * @param {string} schema_str
236
+ * @returns {SchemaToJsonWithResolvedTypesAnswer}
237
+ */
238
+ function schemaToJsonWithResolvedTypes(schema_str) {
239
+ const ptr0 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
240
+ const len0 = WASM_VECTOR_LEN;
241
+ const ret = wasm.schemaToJsonWithResolvedTypes(ptr0, len0);
242
+ return ret;
243
+ }
244
+ exports.schemaToJsonWithResolvedTypes = schemaToJsonWithResolvedTypes;
245
+
328
246
  /**
329
247
  * Return the Cedar (textual) representation of a schema.
330
248
  * @param {Schema} schema
@@ -386,47 +304,148 @@ function validate(call) {
386
304
  }
387
305
  exports.validate = validate;
388
306
 
389
- exports.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
390
- const ret = arg0 === undefined;
391
- return ret;
392
- };
393
-
394
- exports.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
395
- const obj = arg1;
396
- const ret = typeof(obj) === 'string' ? obj : undefined;
397
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
398
- var len1 = WASM_VECTOR_LEN;
399
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
400
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
401
- };
402
-
403
- exports.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
404
- throw new Error(getStringFromWasm0(arg0, arg1));
405
- };
406
-
407
- exports.__wbg_parse_a09a54cf72639456 = function() { return handleError(function (arg0, arg1) {
408
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
409
- return ret;
410
- }, arguments) };
307
+ function __wbg_get_imports() {
308
+ const import0 = {
309
+ __proto__: null,
310
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
311
+ const ret = arg0 === undefined;
312
+ return ret;
313
+ },
314
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
315
+ const obj = arg1;
316
+ const ret = typeof(obj) === 'string' ? obj : undefined;
317
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
318
+ var len1 = WASM_VECTOR_LEN;
319
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
320
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
321
+ },
322
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
323
+ throw new Error(getStringFromWasm0(arg0, arg1));
324
+ },
325
+ __wbg_parse_708461a1feddfb38: function() { return handleError(function (arg0, arg1) {
326
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
327
+ return ret;
328
+ }, arguments); },
329
+ __wbg_stringify_8d1cc6ff383e8bae: function() { return handleError(function (arg0) {
330
+ const ret = JSON.stringify(arg0);
331
+ return ret;
332
+ }, arguments); },
333
+ __wbindgen_init_externref_table: function() {
334
+ const table = wasm.__wbindgen_externrefs;
335
+ const offset = table.grow(4);
336
+ table.set(0, undefined);
337
+ table.set(offset + 0, undefined);
338
+ table.set(offset + 1, null);
339
+ table.set(offset + 2, true);
340
+ table.set(offset + 3, false);
341
+ },
342
+ };
343
+ return {
344
+ __proto__: null,
345
+ "./cedar_wasm_bg.js": import0,
346
+ };
347
+ }
411
348
 
412
- exports.__wbg_stringify_655a6390e1f5eb6b = function() { return handleError(function (arg0) {
413
- const ret = JSON.stringify(arg0);
414
- return ret;
415
- }, arguments) };
416
-
417
- exports.__wbindgen_init_externref_table = function() {
418
- const table = wasm.__wbindgen_externrefs;
419
- const offset = table.grow(4);
420
- table.set(0, undefined);
421
- table.set(offset + 0, undefined);
422
- table.set(offset + 1, null);
423
- table.set(offset + 2, true);
424
- table.set(offset + 3, false);
425
- };
349
+ function addToExternrefTable0(obj) {
350
+ const idx = wasm.__externref_table_alloc();
351
+ wasm.__wbindgen_externrefs.set(idx, obj);
352
+ return idx;
353
+ }
354
+
355
+ let cachedDataViewMemory0 = null;
356
+ function getDataViewMemory0() {
357
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
358
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
359
+ }
360
+ return cachedDataViewMemory0;
361
+ }
362
+
363
+ function getStringFromWasm0(ptr, len) {
364
+ ptr = ptr >>> 0;
365
+ return decodeText(ptr, len);
366
+ }
367
+
368
+ let cachedUint8ArrayMemory0 = null;
369
+ function getUint8ArrayMemory0() {
370
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
371
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
372
+ }
373
+ return cachedUint8ArrayMemory0;
374
+ }
375
+
376
+ function handleError(f, args) {
377
+ try {
378
+ return f.apply(this, args);
379
+ } catch (e) {
380
+ const idx = addToExternrefTable0(e);
381
+ wasm.__wbindgen_exn_store(idx);
382
+ }
383
+ }
384
+
385
+ function isLikeNone(x) {
386
+ return x === undefined || x === null;
387
+ }
388
+
389
+ function passStringToWasm0(arg, malloc, realloc) {
390
+ if (realloc === undefined) {
391
+ const buf = cachedTextEncoder.encode(arg);
392
+ const ptr = malloc(buf.length, 1) >>> 0;
393
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
394
+ WASM_VECTOR_LEN = buf.length;
395
+ return ptr;
396
+ }
397
+
398
+ let len = arg.length;
399
+ let ptr = malloc(len, 1) >>> 0;
400
+
401
+ const mem = getUint8ArrayMemory0();
402
+
403
+ let offset = 0;
404
+
405
+ for (; offset < len; offset++) {
406
+ const code = arg.charCodeAt(offset);
407
+ if (code > 0x7F) break;
408
+ mem[ptr + offset] = code;
409
+ }
410
+ if (offset !== len) {
411
+ if (offset !== 0) {
412
+ arg = arg.slice(offset);
413
+ }
414
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
415
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
416
+ const ret = cachedTextEncoder.encodeInto(arg, view);
417
+
418
+ offset += ret.written;
419
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
420
+ }
421
+
422
+ WASM_VECTOR_LEN = offset;
423
+ return ptr;
424
+ }
425
+
426
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
427
+ cachedTextDecoder.decode();
428
+ function decodeText(ptr, len) {
429
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
430
+ }
431
+
432
+ const cachedTextEncoder = new TextEncoder();
433
+
434
+ if (!('encodeInto' in cachedTextEncoder)) {
435
+ cachedTextEncoder.encodeInto = function (arg, view) {
436
+ const buf = cachedTextEncoder.encode(arg);
437
+ view.set(buf);
438
+ return {
439
+ read: arg.length,
440
+ written: buf.length
441
+ };
442
+ };
443
+ }
444
+
445
+ let WASM_VECTOR_LEN = 0;
426
446
 
427
447
  const wasmPath = `${__dirname}/cedar_wasm_bg.wasm`;
428
448
  const wasmBytes = require('fs').readFileSync(wasmPath);
429
449
  const wasmModule = new WebAssembly.Module(wasmBytes);
430
- const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
431
-
450
+ const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
432
451
  wasm.__wbindgen_start();
Binary file
@@ -5,24 +5,25 @@ export const getCedarSDKVersion: () => [number, number];
5
5
  export const getValidRequestEnvsPolicy: (a: any, b: any) => any;
6
6
  export const getValidRequestEnvsTemplate: (a: any, b: any) => any;
7
7
  export const getCedarVersion: () => [number, number];
8
- export const formatPolicies: (a: any) => any;
9
- export const isAuthorized: (a: any) => any;
10
- export const preparsePolicySet: (a: number, b: number, c: any) => any;
11
- export const preparseSchema: (a: number, b: number, c: any) => any;
12
- export const statefulIsAuthorized: (a: any) => any;
13
- export const validate: (a: any) => any;
14
8
  export const checkParseContext: (a: any) => any;
15
9
  export const checkParseEntities: (a: any) => any;
16
10
  export const checkParsePolicySet: (a: any) => any;
17
11
  export const checkParseSchema: (a: any) => any;
12
+ export const validate: (a: any) => any;
18
13
  export const policySetTextToParts: (a: number, b: number) => any;
19
14
  export const policyToJson: (a: any) => any;
20
15
  export const policyToText: (a: any) => any;
21
16
  export const schemaToJson: (a: any) => any;
17
+ export const schemaToJsonWithResolvedTypes: (a: number, b: number) => any;
22
18
  export const schemaToText: (a: any) => any;
23
19
  export const templateToJson: (a: any) => any;
24
20
  export const templateToText: (a: any) => any;
25
21
  export const getCedarLangVersion: () => [number, number];
22
+ export const formatPolicies: (a: any) => any;
23
+ export const isAuthorized: (a: any) => any;
24
+ export const preparsePolicySet: (a: number, b: number, c: any) => any;
25
+ export const preparseSchema: (a: number, b: number, c: any) => any;
26
+ export const statefulIsAuthorized: (a: any) => any;
26
27
  export const __wbindgen_malloc: (a: number, b: number) => number;
27
28
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
29
  export const __wbindgen_exn_store: (a: number) => void;
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
3
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "4.8.2",
4
+ "version": "4.9.0",
5
5
  "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/cedar-policy/cedar"
9
+ },
6
10
  "files": [
7
11
  "cedar_wasm_bg.wasm",
8
12
  "cedar_wasm.js",
package/package.json CHANGED
@@ -2,8 +2,12 @@
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.8.2",
5
+ "version": "4.9.0",
6
6
  "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/cedar-policy/cedar"
10
+ },
7
11
  "files": [
8
12
  "esm/package.json",
9
13
  "esm/README.md",