@cedar-policy/cedar-wasm 4.2.0 → 4.3.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.
@@ -2,14 +2,30 @@
2
2
  let imports = {};
3
3
  imports['__wbindgen_placeholder__'] = module.exports;
4
4
  let wasm;
5
- const { TextEncoder, TextDecoder } = require(`util`);
5
+ const { TextDecoder, TextEncoder } = require(`util`);
6
+
7
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
8
+
9
+ cachedTextDecoder.decode();
10
+
11
+ let cachedUint8ArrayMemory0 = null;
12
+
13
+ function getUint8ArrayMemory0() {
14
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
15
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
16
+ }
17
+ return cachedUint8ArrayMemory0;
18
+ }
19
+
20
+ function getStringFromWasm0(ptr, len) {
21
+ ptr = ptr >>> 0;
22
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
23
+ }
6
24
 
7
25
  const heap = new Array(128).fill(undefined);
8
26
 
9
27
  heap.push(undefined, null, true, false);
10
28
 
11
- function getObject(idx) { return heap[idx]; }
12
-
13
29
  let heap_next = heap.length;
14
30
 
15
31
  function addHeapObject(obj) {
@@ -21,6 +37,16 @@ function addHeapObject(obj) {
21
37
  return idx;
22
38
  }
23
39
 
40
+ function handleError(f, args) {
41
+ try {
42
+ return f.apply(this, args);
43
+ } catch (e) {
44
+ wasm.__wbindgen_exn_store(addHeapObject(e));
45
+ }
46
+ }
47
+
48
+ function getObject(idx) { return heap[idx]; }
49
+
24
50
  function dropObject(idx) {
25
51
  if (idx < 132) return;
26
52
  heap[idx] = heap_next;
@@ -35,15 +61,6 @@ function takeObject(idx) {
35
61
 
36
62
  let WASM_VECTOR_LEN = 0;
37
63
 
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
64
  let cachedTextEncoder = new TextEncoder('utf-8');
48
65
 
49
66
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -110,46 +127,37 @@ function getDataViewMemory0() {
110
127
  }
111
128
  return cachedDataViewMemory0;
112
129
  }
113
-
114
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
115
-
116
- cachedTextDecoder.decode();
117
-
118
- function getStringFromWasm0(ptr, len) {
119
- ptr = ptr >>> 0;
120
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
121
- }
122
130
  /**
123
- * Get valid request environment
124
- * @param {Template} t
125
- * @param {Schema} s
126
- * @returns {GetValidRequestEnvsResult}
127
- */
131
+ * Get valid request environment
132
+ * @param {Template} t
133
+ * @param {Schema} s
134
+ * @returns {GetValidRequestEnvsResult}
135
+ */
128
136
  module.exports.getValidRequestEnvsTemplate = function(t, s) {
129
137
  const ret = wasm.getValidRequestEnvsTemplate(addHeapObject(t), addHeapObject(s));
130
138
  return takeObject(ret);
131
139
  };
132
140
 
133
141
  /**
134
- * Get valid request environment
135
- * @param {Policy} t
136
- * @param {Schema} s
137
- * @returns {GetValidRequestEnvsResult}
138
- */
142
+ * Get valid request environment
143
+ * @param {Policy} t
144
+ * @param {Schema} s
145
+ * @returns {GetValidRequestEnvsResult}
146
+ */
139
147
  module.exports.getValidRequestEnvsPolicy = function(t, s) {
140
148
  const ret = wasm.getValidRequestEnvsPolicy(addHeapObject(t), addHeapObject(s));
141
149
  return takeObject(ret);
142
150
  };
143
151
 
144
152
  /**
145
- * @returns {string}
146
- */
153
+ * @returns {string}
154
+ */
147
155
  module.exports.getCedarVersion = function() {
148
156
  let deferred1_0;
149
157
  let deferred1_1;
150
158
  try {
151
159
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
152
- wasm.getCedarVersion(retptr);
160
+ wasm.getCedarSDKVersion(retptr);
153
161
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
154
162
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
155
163
  deferred1_0 = r0;
@@ -162,145 +170,193 @@ module.exports.getCedarVersion = function() {
162
170
  };
163
171
 
164
172
  /**
165
- * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
166
- * @param {AuthorizationCall} call
167
- * @returns {AuthorizationAnswer}
168
- */
169
- module.exports.isAuthorized = function(call) {
170
- const ret = wasm.isAuthorized(addHeapObject(call));
171
- return takeObject(ret);
173
+ * @returns {string}
174
+ */
175
+ module.exports.getCedarSDKVersion = function() {
176
+ let deferred1_0;
177
+ let deferred1_1;
178
+ try {
179
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
180
+ wasm.getCedarSDKVersion(retptr);
181
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
182
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
183
+ deferred1_0 = r0;
184
+ deferred1_1 = r1;
185
+ return getStringFromWasm0(r0, r1);
186
+ } finally {
187
+ wasm.__wbindgen_add_to_stack_pointer(16);
188
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
189
+ }
172
190
  };
173
191
 
174
192
  /**
175
- * Parse a policy set and optionally validate it against a provided schema
176
- *
177
- * This is the basic validator interface, using [`ValidationCall`] and
178
- * [`ValidationAnswer`] types
179
- * @param {ValidationCall} call
180
- * @returns {ValidationAnswer}
181
- */
193
+ * Parse a policy set and optionally validate it against a provided schema
194
+ *
195
+ * This is the basic validator interface, using [`ValidationCall`] and
196
+ * [`ValidationAnswer`] types
197
+ * @param {ValidationCall} call
198
+ * @returns {ValidationAnswer}
199
+ */
182
200
  module.exports.validate = function(call) {
183
201
  const ret = wasm.validate(addHeapObject(call));
184
202
  return takeObject(ret);
185
203
  };
186
204
 
187
205
  /**
188
- * Apply the Cedar policy formatter to a policy set in the Cedar policy format
189
- * @param {FormattingCall} call
190
- * @returns {FormattingAnswer}
191
- */
192
- module.exports.formatPolicies = function(call) {
193
- const ret = wasm.formatPolicies(addHeapObject(call));
194
- return takeObject(ret);
206
+ * Get language version of Cedar
207
+ * @returns {string}
208
+ */
209
+ module.exports.getCedarLangVersion = function() {
210
+ let deferred1_0;
211
+ let deferred1_1;
212
+ try {
213
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
214
+ wasm.getCedarLangVersion(retptr);
215
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
216
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
217
+ deferred1_0 = r0;
218
+ deferred1_1 = r1;
219
+ return getStringFromWasm0(r0, r1);
220
+ } finally {
221
+ wasm.__wbindgen_add_to_stack_pointer(16);
222
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
223
+ }
195
224
  };
196
225
 
197
226
  /**
198
- * Return the Cedar (textual) representation of a policy.
199
- * @param {Policy} policy
200
- * @returns {PolicyToTextAnswer}
201
- */
227
+ * Return the Cedar (textual) representation of a policy.
228
+ * @param {Policy} policy
229
+ * @returns {PolicyToTextAnswer}
230
+ */
202
231
  module.exports.policyToText = function(policy) {
203
232
  const ret = wasm.policyToText(addHeapObject(policy));
204
233
  return takeObject(ret);
205
234
  };
206
235
 
207
236
  /**
208
- * Return the Cedar (textual) representation of a template.
209
- * @param {Template} template
210
- * @returns {PolicyToTextAnswer}
211
- */
237
+ * Return the Cedar (textual) representation of a template.
238
+ * @param {Template} template
239
+ * @returns {PolicyToTextAnswer}
240
+ */
212
241
  module.exports.templateToText = function(template) {
213
242
  const ret = wasm.templateToText(addHeapObject(template));
214
243
  return takeObject(ret);
215
244
  };
216
245
 
217
246
  /**
218
- * Return the JSON representation of a policy.
219
- * @param {Policy} policy
220
- * @returns {PolicyToJsonAnswer}
221
- */
247
+ * Return the JSON representation of a policy.
248
+ * @param {Policy} policy
249
+ * @returns {PolicyToJsonAnswer}
250
+ */
222
251
  module.exports.policyToJson = function(policy) {
223
252
  const ret = wasm.policyToJson(addHeapObject(policy));
224
253
  return takeObject(ret);
225
254
  };
226
255
 
227
256
  /**
228
- * Return the JSON representation of a template.
229
- * @param {Template} template
230
- * @returns {PolicyToJsonAnswer}
231
- */
257
+ * Return the JSON representation of a template.
258
+ * @param {Template} template
259
+ * @returns {PolicyToJsonAnswer}
260
+ */
232
261
  module.exports.templateToJson = function(template) {
233
262
  const ret = wasm.templateToJson(addHeapObject(template));
234
263
  return takeObject(ret);
235
264
  };
236
265
 
237
266
  /**
238
- * Return the Cedar (textual) representation of a schema.
239
- * @param {Schema} schema
240
- * @returns {SchemaToTextAnswer}
241
- */
267
+ * Return the Cedar (textual) representation of a schema.
268
+ * @param {Schema} schema
269
+ * @returns {SchemaToTextAnswer}
270
+ */
242
271
  module.exports.schemaToText = function(schema) {
243
272
  const ret = wasm.schemaToText(addHeapObject(schema));
244
273
  return takeObject(ret);
245
274
  };
246
275
 
247
276
  /**
248
- * Return the JSON representation of a schema.
249
- * @param {Schema} schema
250
- * @returns {SchemaToJsonAnswer}
251
- */
277
+ * Return the JSON representation of a schema.
278
+ * @param {Schema} schema
279
+ * @returns {SchemaToJsonAnswer}
280
+ */
252
281
  module.exports.schemaToJson = function(schema) {
253
282
  const ret = wasm.schemaToJson(addHeapObject(schema));
254
283
  return takeObject(ret);
255
284
  };
256
285
 
257
286
  /**
258
- * Check whether a policy set successfully parses.
259
- * @param {PolicySet} policies
260
- * @returns {CheckParseAnswer}
261
- */
287
+ * Check whether a policy set successfully parses.
288
+ * @param {PolicySet} policies
289
+ * @returns {CheckParseAnswer}
290
+ */
262
291
  module.exports.checkParsePolicySet = function(policies) {
263
292
  const ret = wasm.checkParsePolicySet(addHeapObject(policies));
264
293
  return takeObject(ret);
265
294
  };
266
295
 
267
296
  /**
268
- * Check whether a schema successfully parses.
269
- * @param {Schema} schema
270
- * @returns {CheckParseAnswer}
271
- */
297
+ * Check whether a schema successfully parses.
298
+ * @param {Schema} schema
299
+ * @returns {CheckParseAnswer}
300
+ */
272
301
  module.exports.checkParseSchema = function(schema) {
273
302
  const ret = wasm.checkParseSchema(addHeapObject(schema));
274
303
  return takeObject(ret);
275
304
  };
276
305
 
277
306
  /**
278
- * Check whether a set of entities successfully parses.
279
- * @param {EntitiesParsingCall} call
280
- * @returns {CheckParseAnswer}
281
- */
307
+ * Check whether a set of entities successfully parses.
308
+ * @param {EntitiesParsingCall} call
309
+ * @returns {CheckParseAnswer}
310
+ */
282
311
  module.exports.checkParseEntities = function(call) {
283
312
  const ret = wasm.checkParseEntities(addHeapObject(call));
284
313
  return takeObject(ret);
285
314
  };
286
315
 
287
316
  /**
288
- * Check whether a context successfully parses.
289
- * @param {ContextParsingCall} call
290
- * @returns {CheckParseAnswer}
291
- */
317
+ * Check whether a context successfully parses.
318
+ * @param {ContextParsingCall} call
319
+ * @returns {CheckParseAnswer}
320
+ */
292
321
  module.exports.checkParseContext = function(call) {
293
322
  const ret = wasm.checkParseContext(addHeapObject(call));
294
323
  return takeObject(ret);
295
324
  };
296
325
 
297
- function handleError(f, args) {
298
- try {
299
- return f.apply(this, args);
300
- } catch (e) {
301
- wasm.__wbindgen_exn_store(addHeapObject(e));
302
- }
303
- }
326
+ /**
327
+ * Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
328
+ * @param {AuthorizationCall} call
329
+ * @returns {AuthorizationAnswer}
330
+ */
331
+ module.exports.isAuthorized = function(call) {
332
+ const ret = wasm.isAuthorized(addHeapObject(call));
333
+ return takeObject(ret);
334
+ };
335
+
336
+ /**
337
+ * Apply the Cedar policy formatter to a policy set in the Cedar policy format
338
+ * @param {FormattingCall} call
339
+ * @returns {FormattingAnswer}
340
+ */
341
+ module.exports.formatPolicies = function(call) {
342
+ const ret = wasm.formatPolicies(addHeapObject(call));
343
+ return takeObject(ret);
344
+ };
345
+
346
+ module.exports.__wbg_parse_def2e24ef1252aff = function() { return handleError(function (arg0, arg1) {
347
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
348
+ return addHeapObject(ret);
349
+ }, arguments) };
350
+
351
+ module.exports.__wbg_stringify_f7ed6987935b4a24 = function() { return handleError(function (arg0) {
352
+ const ret = JSON.stringify(getObject(arg0));
353
+ return addHeapObject(ret);
354
+ }, arguments) };
355
+
356
+ module.exports.__wbindgen_is_undefined = function(arg0) {
357
+ const ret = getObject(arg0) === undefined;
358
+ return ret;
359
+ };
304
360
 
305
361
  module.exports.__wbindgen_object_clone_ref = function(arg0) {
306
362
  const ret = getObject(arg0);
@@ -311,11 +367,6 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
311
367
  takeObject(arg0);
312
368
  };
313
369
 
314
- module.exports.__wbindgen_is_undefined = function(arg0) {
315
- const ret = getObject(arg0) === undefined;
316
- return ret;
317
- };
318
-
319
370
  module.exports.__wbindgen_string_get = function(arg0, arg1) {
320
371
  const obj = getObject(arg1);
321
372
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -325,16 +376,6 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
325
376
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
326
377
  };
327
378
 
328
- module.exports.__wbg_parse_52202f117ec9ecfa = function() { return handleError(function (arg0, arg1) {
329
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
330
- return addHeapObject(ret);
331
- }, arguments) };
332
-
333
- module.exports.__wbg_stringify_bbf45426c92a6bf5 = function() { return handleError(function (arg0) {
334
- const ret = JSON.stringify(getObject(arg0));
335
- return addHeapObject(ret);
336
- }, arguments) };
337
-
338
379
  module.exports.__wbindgen_throw = function(arg0, arg1) {
339
380
  throw new Error(getStringFromWasm0(arg0, arg1));
340
381
  };
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 isAuthorized(a: number): number;
8
- export function validate(a: number): number;
9
- export function formatPolicies(a: number): number;
10
- export function policyToText(a: number): number;
11
- export function templateToText(a: number): number;
12
- export function policyToJson(a: number): number;
13
- export function templateToJson(a: number): number;
14
- export function schemaToText(a: number): number;
15
- export function schemaToJson(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;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
3
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "4.2.0",
4
+ "version": "4.3.0",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
7
  "cedar_wasm_bg.wasm",
package/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.0",
4
+ "version": "4.3.0",
6
5
  "license": "Apache-2.0",
7
6
  "files": [
8
7
  "esm/package.json",
@@ -25,12 +24,11 @@
25
24
  "web/cedar_wasm.js",
26
25
  "web/cedar_wasm.d.ts"
27
26
  ],
28
- "main": "cedar_wasm.js",
27
+ "module": "esm/cedar_wasm.js",
29
28
  "types": "esm/cedar_wasm.d.ts",
30
29
  "sideEffects": [
31
30
  "./snippets/*"
32
31
  ],
33
- "module": "esm/cedar_wasm.js",
34
32
  "exports": {
35
33
  ".": {
36
34
  "import": "./esm/cedar_wasm.js",