@cedar-policy/cedar-wasm 4.7.0 → 4.8.2

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.
@@ -3,30 +3,18 @@ export function __wbg_set_wasm(val) {
3
3
  wasm = val;
4
4
  }
5
5
 
6
-
7
- let cachedUint8ArrayMemory0 = null;
8
-
9
- function getUint8ArrayMemory0() {
10
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
- }
13
- return cachedUint8ArrayMemory0;
6
+ function addToExternrefTable0(obj) {
7
+ const idx = wasm.__externref_table_alloc();
8
+ wasm.__wbindgen_externrefs.set(idx, obj);
9
+ return idx;
14
10
  }
15
11
 
16
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
17
-
18
- cachedTextDecoder.decode();
19
-
20
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
21
- let numBytesDecoded = 0;
22
- function decodeText(ptr, len) {
23
- numBytesDecoded += len;
24
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
25
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
26
- cachedTextDecoder.decode();
27
- numBytesDecoded = len;
12
+ let cachedDataViewMemory0 = null;
13
+ function getDataViewMemory0() {
14
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
15
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
28
16
  }
29
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
17
+ return cachedDataViewMemory0;
30
18
  }
31
19
 
32
20
  function getStringFromWasm0(ptr, len) {
@@ -34,10 +22,12 @@ function getStringFromWasm0(ptr, len) {
34
22
  return decodeText(ptr, len);
35
23
  }
36
24
 
37
- function addToExternrefTable0(obj) {
38
- const idx = wasm.__externref_table_alloc();
39
- wasm.__wbindgen_export_2.set(idx, obj);
40
- return idx;
25
+ let cachedUint8ArrayMemory0 = null;
26
+ function getUint8ArrayMemory0() {
27
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
28
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
29
+ }
30
+ return cachedUint8ArrayMemory0;
41
31
  }
42
32
 
43
33
  function handleError(f, args) {
@@ -49,23 +39,11 @@ function handleError(f, args) {
49
39
  }
50
40
  }
51
41
 
52
- let WASM_VECTOR_LEN = 0;
53
-
54
- const cachedTextEncoder = new TextEncoder();
55
-
56
- if (!('encodeInto' in cachedTextEncoder)) {
57
- cachedTextEncoder.encodeInto = function (arg, view) {
58
- const buf = cachedTextEncoder.encode(arg);
59
- view.set(buf);
60
- return {
61
- read: arg.length,
62
- written: buf.length
63
- };
64
- }
42
+ function isLikeNone(x) {
43
+ return x === undefined || x === null;
65
44
  }
66
45
 
67
46
  function passStringToWasm0(arg, malloc, realloc) {
68
-
69
47
  if (realloc === undefined) {
70
48
  const buf = cachedTextEncoder.encode(arg);
71
49
  const ptr = malloc(buf.length, 1) >>> 0;
@@ -86,7 +64,6 @@ function passStringToWasm0(arg, malloc, realloc) {
86
64
  if (code > 0x7F) break;
87
65
  mem[ptr + offset] = code;
88
66
  }
89
-
90
67
  if (offset !== len) {
91
68
  if (offset !== 0) {
92
69
  arg = arg.slice(offset);
@@ -103,18 +80,102 @@ function passStringToWasm0(arg, malloc, realloc) {
103
80
  return ptr;
104
81
  }
105
82
 
106
- function isLikeNone(x) {
107
- return x === undefined || x === null;
83
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
84
+ cachedTextDecoder.decode();
85
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
86
+ let numBytesDecoded = 0;
87
+ function decodeText(ptr, len) {
88
+ numBytesDecoded += len;
89
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
90
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
91
+ cachedTextDecoder.decode();
92
+ numBytesDecoded = len;
93
+ }
94
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
108
95
  }
109
96
 
110
- let cachedDataViewMemory0 = null;
97
+ const cachedTextEncoder = new TextEncoder();
111
98
 
112
- function getDataViewMemory0() {
113
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
114
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
99
+ if (!('encodeInto' in cachedTextEncoder)) {
100
+ cachedTextEncoder.encodeInto = function (arg, view) {
101
+ const buf = cachedTextEncoder.encode(arg);
102
+ view.set(buf);
103
+ return {
104
+ read: arg.length,
105
+ written: buf.length
106
+ };
107
+ }
108
+ }
109
+
110
+ let WASM_VECTOR_LEN = 0;
111
+
112
+ /**
113
+ * Check whether a context successfully parses.
114
+ * @param {ContextParsingCall} call
115
+ * @returns {CheckParseAnswer}
116
+ */
117
+ export function checkParseContext(call) {
118
+ const ret = wasm.checkParseContext(call);
119
+ return ret;
120
+ }
121
+
122
+ /**
123
+ * Check whether a set of entities successfully parses.
124
+ * @param {EntitiesParsingCall} call
125
+ * @returns {CheckParseAnswer}
126
+ */
127
+ export function checkParseEntities(call) {
128
+ const ret = wasm.checkParseEntities(call);
129
+ return ret;
130
+ }
131
+
132
+ /**
133
+ * Check whether a policy set successfully parses.
134
+ * @param {PolicySet} policies
135
+ * @returns {CheckParseAnswer}
136
+ */
137
+ export function checkParsePolicySet(policies) {
138
+ const ret = wasm.checkParsePolicySet(policies);
139
+ return ret;
140
+ }
141
+
142
+ /**
143
+ * Check whether a schema successfully parses.
144
+ * @param {Schema} schema
145
+ * @returns {CheckParseAnswer}
146
+ */
147
+ export function checkParseSchema(schema) {
148
+ const ret = wasm.checkParseSchema(schema);
149
+ return ret;
150
+ }
151
+
152
+ /**
153
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
154
+ * @param {FormattingCall} call
155
+ * @returns {FormattingAnswer}
156
+ */
157
+ export function formatPolicies(call) {
158
+ const ret = wasm.formatPolicies(call);
159
+ return ret;
160
+ }
161
+
162
+ /**
163
+ * Get language version of Cedar
164
+ * @returns {string}
165
+ */
166
+ export function getCedarLangVersion() {
167
+ let deferred1_0;
168
+ let deferred1_1;
169
+ try {
170
+ const ret = wasm.getCedarLangVersion();
171
+ deferred1_0 = ret[0];
172
+ deferred1_1 = ret[1];
173
+ return getStringFromWasm0(ret[0], ret[1]);
174
+ } finally {
175
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
115
176
  }
116
- return cachedDataViewMemory0;
117
177
  }
178
+
118
179
  /**
119
180
  * @returns {string}
120
181
  */
@@ -170,25 +231,45 @@ export function getValidRequestEnvsTemplate(t, s) {
170
231
  }
171
232
 
172
233
  /**
173
- * Stateful authorization using preparsed schemas and policy sets.
174
- *
175
- * This function works like [`is_authorized`] but retrieves schemas and policy sets
176
- * from thread-local cache instead of parsing them on each call.
177
- * @param {StatefulAuthorizationCall} call
234
+ * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
235
+ * @param {AuthorizationCall} call
178
236
  * @returns {AuthorizationAnswer}
179
237
  */
180
- export function statefulIsAuthorized(call) {
181
- const ret = wasm.statefulIsAuthorized(call);
238
+ export function isAuthorized(call) {
239
+ const ret = wasm.isAuthorized(call);
182
240
  return ret;
183
241
  }
184
242
 
185
243
  /**
186
- * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
187
- * @param {AuthorizationCall} call
188
- * @returns {AuthorizationAnswer}
244
+ * Takes a `PolicySet` represented as string and return the policies
245
+ * and templates split into vecs and sorted by id.
246
+ * @param {string} policyset_str
247
+ * @returns {PolicySetTextToPartsAnswer}
189
248
  */
190
- export function isAuthorized(call) {
191
- const ret = wasm.isAuthorized(call);
249
+ export function policySetTextToParts(policyset_str) {
250
+ const ptr0 = passStringToWasm0(policyset_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
251
+ const len0 = WASM_VECTOR_LEN;
252
+ const ret = wasm.policySetTextToParts(ptr0, len0);
253
+ return ret;
254
+ }
255
+
256
+ /**
257
+ * Return the JSON representation of a policy.
258
+ * @param {Policy} policy
259
+ * @returns {PolicyToJsonAnswer}
260
+ */
261
+ export function policyToJson(policy) {
262
+ const ret = wasm.policyToJson(policy);
263
+ return ret;
264
+ }
265
+
266
+ /**
267
+ * Return the Cedar (textual) representation of a policy.
268
+ * @param {Policy} policy
269
+ * @returns {PolicyToTextAnswer}
270
+ */
271
+ export function policyToText(policy) {
272
+ const ret = wasm.policyToText(policy);
192
273
  return ret;
193
274
  }
194
275
 
@@ -227,55 +308,35 @@ export function preparseSchema(schema_name, schema) {
227
308
  }
228
309
 
229
310
  /**
230
- * Check whether a policy set successfully parses.
231
- * @param {PolicySet} policies
232
- * @returns {CheckParseAnswer}
233
- */
234
- export function checkParsePolicySet(policies) {
235
- const ret = wasm.checkParsePolicySet(policies);
236
- return ret;
237
- }
238
-
239
- /**
240
- * Check whether a context successfully parses.
241
- * @param {ContextParsingCall} call
242
- * @returns {CheckParseAnswer}
243
- */
244
- export function checkParseContext(call) {
245
- const ret = wasm.checkParseContext(call);
246
- return ret;
247
- }
248
-
249
- /**
250
- * Check whether a schema successfully parses.
311
+ * Return the JSON representation of a schema.
251
312
  * @param {Schema} schema
252
- * @returns {CheckParseAnswer}
313
+ * @returns {SchemaToJsonAnswer}
253
314
  */
254
- export function checkParseSchema(schema) {
255
- const ret = wasm.checkParseSchema(schema);
315
+ export function schemaToJson(schema) {
316
+ const ret = wasm.schemaToJson(schema);
256
317
  return ret;
257
318
  }
258
319
 
259
320
  /**
260
- * Check whether a set of entities successfully parses.
261
- * @param {EntitiesParsingCall} call
262
- * @returns {CheckParseAnswer}
321
+ * Return the Cedar (textual) representation of a schema.
322
+ * @param {Schema} schema
323
+ * @returns {SchemaToTextAnswer}
263
324
  */
264
- export function checkParseEntities(call) {
265
- const ret = wasm.checkParseEntities(call);
325
+ export function schemaToText(schema) {
326
+ const ret = wasm.schemaToText(schema);
266
327
  return ret;
267
328
  }
268
329
 
269
330
  /**
270
- * Takes a `PolicySet` represented as string and return the policies
271
- * and templates split into vecs and sorted by id.
272
- * @param {string} policyset_str
273
- * @returns {PolicySetTextToPartsAnswer}
331
+ * Stateful authorization using preparsed schemas and policy sets.
332
+ *
333
+ * This function works like [`is_authorized`] but retrieves schemas and policy sets
334
+ * from thread-local cache instead of parsing them on each call.
335
+ * @param {StatefulAuthorizationCall} call
336
+ * @returns {AuthorizationAnswer}
274
337
  */
275
- export function policySetTextToParts(policyset_str) {
276
- const ptr0 = passStringToWasm0(policyset_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
277
- const len0 = WASM_VECTOR_LEN;
278
- const ret = wasm.policySetTextToParts(ptr0, len0);
338
+ export function statefulIsAuthorized(call) {
339
+ const ret = wasm.statefulIsAuthorized(call);
279
340
  return ret;
280
341
  }
281
342
 
@@ -289,26 +350,6 @@ export function templateToJson(template) {
289
350
  return ret;
290
351
  }
291
352
 
292
- /**
293
- * Return the Cedar (textual) representation of a policy.
294
- * @param {Policy} policy
295
- * @returns {PolicyToTextAnswer}
296
- */
297
- export function policyToText(policy) {
298
- const ret = wasm.policyToText(policy);
299
- return ret;
300
- }
301
-
302
- /**
303
- * Return the JSON representation of a schema.
304
- * @param {Schema} schema
305
- * @returns {SchemaToJsonAnswer}
306
- */
307
- export function schemaToJson(schema) {
308
- const ret = wasm.schemaToJson(schema);
309
- return ret;
310
- }
311
-
312
353
  /**
313
354
  * Return the Cedar (textual) representation of a template.
314
355
  * @param {Template} template
@@ -319,53 +360,6 @@ export function templateToText(template) {
319
360
  return ret;
320
361
  }
321
362
 
322
- /**
323
- * Return the JSON representation of a policy.
324
- * @param {Policy} policy
325
- * @returns {PolicyToJsonAnswer}
326
- */
327
- export function policyToJson(policy) {
328
- const ret = wasm.policyToJson(policy);
329
- return ret;
330
- }
331
-
332
- /**
333
- * Return the Cedar (textual) representation of a schema.
334
- * @param {Schema} schema
335
- * @returns {SchemaToTextAnswer}
336
- */
337
- export function schemaToText(schema) {
338
- const ret = wasm.schemaToText(schema);
339
- return ret;
340
- }
341
-
342
- /**
343
- * Get language version of Cedar
344
- * @returns {string}
345
- */
346
- export function getCedarLangVersion() {
347
- let deferred1_0;
348
- let deferred1_1;
349
- try {
350
- const ret = wasm.getCedarLangVersion();
351
- deferred1_0 = ret[0];
352
- deferred1_1 = ret[1];
353
- return getStringFromWasm0(ret[0], ret[1]);
354
- } finally {
355
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
356
- }
357
- }
358
-
359
- /**
360
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
361
- * @param {FormattingCall} call
362
- * @returns {FormattingAnswer}
363
- */
364
- export function formatPolicies(call) {
365
- const ret = wasm.formatPolicies(call);
366
- return ret;
367
- }
368
-
369
363
  /**
370
364
  * Parse a policy set and optionally validate it against a provided schema
371
365
  *
@@ -379,22 +373,12 @@ export function validate(call) {
379
373
  return ret;
380
374
  }
381
375
 
382
- export function __wbg_parse_442f5ba02e5eaf8b() { return handleError(function (arg0, arg1) {
383
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
384
- return ret;
385
- }, arguments) };
386
-
387
- export function __wbg_stringify_b98c93d0a190446a() { return handleError(function (arg0) {
388
- const ret = JSON.stringify(arg0);
389
- return ret;
390
- }, arguments) };
391
-
392
- export function __wbg_wbindgenisundefined_c4b71d073b92f3c5(arg0) {
376
+ export function __wbg___wbindgen_is_undefined_f6b95eab589e0269(arg0) {
393
377
  const ret = arg0 === undefined;
394
378
  return ret;
395
379
  };
396
380
 
397
- export function __wbg_wbindgenstringget_0f16a6ddddef376f(arg0, arg1) {
381
+ export function __wbg___wbindgen_string_get_a2a31e16edf96e42(arg0, arg1) {
398
382
  const obj = arg1;
399
383
  const ret = typeof(obj) === 'string' ? obj : undefined;
400
384
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -403,18 +387,26 @@ export function __wbg_wbindgenstringget_0f16a6ddddef376f(arg0, arg1) {
403
387
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
404
388
  };
405
389
 
406
- export function __wbg_wbindgenthrow_451ec1a8469d7eb6(arg0, arg1) {
390
+ export function __wbg___wbindgen_throw_dd24417ed36fc46e(arg0, arg1) {
407
391
  throw new Error(getStringFromWasm0(arg0, arg1));
408
392
  };
409
393
 
394
+ export function __wbg_parse_a09a54cf72639456() { return handleError(function (arg0, arg1) {
395
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
396
+ return ret;
397
+ }, arguments) };
398
+
399
+ export function __wbg_stringify_655a6390e1f5eb6b() { return handleError(function (arg0) {
400
+ const ret = JSON.stringify(arg0);
401
+ return ret;
402
+ }, arguments) };
403
+
410
404
  export function __wbindgen_init_externref_table() {
411
- const table = wasm.__wbindgen_export_2;
405
+ const table = wasm.__wbindgen_externrefs;
412
406
  const offset = table.grow(4);
413
407
  table.set(0, undefined);
414
408
  table.set(offset + 0, undefined);
415
409
  table.set(offset + 1, null);
416
410
  table.set(offset + 2, true);
417
411
  table.set(offset + 3, false);
418
- ;
419
412
  };
420
-
Binary file
@@ -5,15 +5,16 @@ 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;
8
9
  export const isAuthorized: (a: any) => any;
9
10
  export const preparsePolicySet: (a: number, b: number, c: any) => any;
10
11
  export const preparseSchema: (a: number, b: number, c: any) => any;
11
12
  export const statefulIsAuthorized: (a: any) => any;
13
+ export const validate: (a: any) => any;
12
14
  export const checkParseContext: (a: any) => any;
13
15
  export const checkParseEntities: (a: any) => any;
14
16
  export const checkParsePolicySet: (a: any) => any;
15
17
  export const checkParseSchema: (a: any) => any;
16
- export const getCedarLangVersion: () => [number, number];
17
18
  export const policySetTextToParts: (a: number, b: number) => any;
18
19
  export const policyToJson: (a: any) => any;
19
20
  export const policyToText: (a: any) => any;
@@ -21,12 +22,11 @@ export const schemaToJson: (a: any) => any;
21
22
  export const schemaToText: (a: any) => any;
22
23
  export const templateToJson: (a: any) => any;
23
24
  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;
25
+ export const getCedarLangVersion: () => [number, number];
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/esm/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.7.0",
5
+ "version": "4.8.2",
6
6
  "license": "Apache-2.0",
7
7
  "files": [
8
8
  "cedar_wasm_bg.wasm",