@cedar-policy/cedar-wasm 4.8.2 → 4.9.1
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/esm/cedar_wasm.d.ts +183 -142
- package/esm/cedar_wasm.js +5 -1
- package/esm/cedar_wasm_bg.js +150 -128
- package/esm/cedar_wasm_bg.wasm +0 -0
- package/esm/cedar_wasm_bg.wasm.d.ts +4 -2
- package/esm/package.json +5 -1
- package/nodejs/cedar_wasm.d.ts +183 -142
- package/nodejs/cedar_wasm.js +170 -139
- package/nodejs/cedar_wasm_bg.wasm +0 -0
- package/nodejs/cedar_wasm_bg.wasm.d.ts +4 -2
- package/nodejs/package.json +5 -1
- package/package.json +5 -1
- package/web/cedar_wasm.d.ts +229 -186
- package/web/cedar_wasm.js +198 -166
- package/web/cedar_wasm_bg.wasm +0 -0
- package/web/cedar_wasm_bg.wasm.d.ts +4 -2
- package/web/package.json +5 -1
package/nodejs/cedar_wasm.js
CHANGED
|
@@ -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.
|
|
@@ -242,6 +142,18 @@ function isAuthorized(call) {
|
|
|
242
142
|
}
|
|
243
143
|
exports.isAuthorized = isAuthorized;
|
|
244
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Basic interface for partial evaluation, using [`AuthorizationCall`] and
|
|
147
|
+
* [`PartialAuthorizationAnswer`] types
|
|
148
|
+
* @param {PartialAuthorizationCall} call
|
|
149
|
+
* @returns {PartialAuthorizationAnswer}
|
|
150
|
+
*/
|
|
151
|
+
function isAuthorizedPartial(call) {
|
|
152
|
+
const ret = wasm.isAuthorizedPartial(call);
|
|
153
|
+
return ret;
|
|
154
|
+
}
|
|
155
|
+
exports.isAuthorizedPartial = isAuthorizedPartial;
|
|
156
|
+
|
|
245
157
|
/**
|
|
246
158
|
* Takes a `PolicySet` represented as string and return the policies
|
|
247
159
|
* and templates split into vecs and sorted by id.
|
|
@@ -325,6 +237,24 @@ function schemaToJson(schema) {
|
|
|
325
237
|
}
|
|
326
238
|
exports.schemaToJson = schemaToJson;
|
|
327
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Convert a Cedar schema string to JSON format with resolved types.
|
|
242
|
+
*
|
|
243
|
+
* This function resolves ambiguous "`EntityOrCommon`" types to their specific
|
|
244
|
+
* Entity or `CommonType` classifications using the schema's type definitions.
|
|
245
|
+
* This is primarily meant to be used when working with schemas programmatically,
|
|
246
|
+
* for example when creating a schema building UI.
|
|
247
|
+
* @param {string} schema_str
|
|
248
|
+
* @returns {SchemaToJsonWithResolvedTypesAnswer}
|
|
249
|
+
*/
|
|
250
|
+
function schemaToJsonWithResolvedTypes(schema_str) {
|
|
251
|
+
const ptr0 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
252
|
+
const len0 = WASM_VECTOR_LEN;
|
|
253
|
+
const ret = wasm.schemaToJsonWithResolvedTypes(ptr0, len0);
|
|
254
|
+
return ret;
|
|
255
|
+
}
|
|
256
|
+
exports.schemaToJsonWithResolvedTypes = schemaToJsonWithResolvedTypes;
|
|
257
|
+
|
|
328
258
|
/**
|
|
329
259
|
* Return the Cedar (textual) representation of a schema.
|
|
330
260
|
* @param {Schema} schema
|
|
@@ -386,47 +316,148 @@ function validate(call) {
|
|
|
386
316
|
}
|
|
387
317
|
exports.validate = validate;
|
|
388
318
|
|
|
389
|
-
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}, arguments) }
|
|
319
|
+
function __wbg_get_imports() {
|
|
320
|
+
const import0 = {
|
|
321
|
+
__proto__: null,
|
|
322
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
323
|
+
const ret = arg0 === undefined;
|
|
324
|
+
return ret;
|
|
325
|
+
},
|
|
326
|
+
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
327
|
+
const obj = arg1;
|
|
328
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
329
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
330
|
+
var len1 = WASM_VECTOR_LEN;
|
|
331
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
332
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
333
|
+
},
|
|
334
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
335
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
336
|
+
},
|
|
337
|
+
__wbg_parse_708461a1feddfb38: function() { return handleError(function (arg0, arg1) {
|
|
338
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
339
|
+
return ret;
|
|
340
|
+
}, arguments); },
|
|
341
|
+
__wbg_stringify_8d1cc6ff383e8bae: function() { return handleError(function (arg0) {
|
|
342
|
+
const ret = JSON.stringify(arg0);
|
|
343
|
+
return ret;
|
|
344
|
+
}, arguments); },
|
|
345
|
+
__wbindgen_init_externref_table: function() {
|
|
346
|
+
const table = wasm.__wbindgen_externrefs;
|
|
347
|
+
const offset = table.grow(4);
|
|
348
|
+
table.set(0, undefined);
|
|
349
|
+
table.set(offset + 0, undefined);
|
|
350
|
+
table.set(offset + 1, null);
|
|
351
|
+
table.set(offset + 2, true);
|
|
352
|
+
table.set(offset + 3, false);
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
return {
|
|
356
|
+
__proto__: null,
|
|
357
|
+
"./cedar_wasm_bg.js": import0,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
411
360
|
|
|
412
|
-
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
361
|
+
function addToExternrefTable0(obj) {
|
|
362
|
+
const idx = wasm.__externref_table_alloc();
|
|
363
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
364
|
+
return idx;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
let cachedDataViewMemory0 = null;
|
|
368
|
+
function getDataViewMemory0() {
|
|
369
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
370
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
371
|
+
}
|
|
372
|
+
return cachedDataViewMemory0;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function getStringFromWasm0(ptr, len) {
|
|
376
|
+
ptr = ptr >>> 0;
|
|
377
|
+
return decodeText(ptr, len);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
let cachedUint8ArrayMemory0 = null;
|
|
381
|
+
function getUint8ArrayMemory0() {
|
|
382
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
383
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
384
|
+
}
|
|
385
|
+
return cachedUint8ArrayMemory0;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function handleError(f, args) {
|
|
389
|
+
try {
|
|
390
|
+
return f.apply(this, args);
|
|
391
|
+
} catch (e) {
|
|
392
|
+
const idx = addToExternrefTable0(e);
|
|
393
|
+
wasm.__wbindgen_exn_store(idx);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function isLikeNone(x) {
|
|
398
|
+
return x === undefined || x === null;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
402
|
+
if (realloc === undefined) {
|
|
403
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
404
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
405
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
406
|
+
WASM_VECTOR_LEN = buf.length;
|
|
407
|
+
return ptr;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
let len = arg.length;
|
|
411
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
412
|
+
|
|
413
|
+
const mem = getUint8ArrayMemory0();
|
|
414
|
+
|
|
415
|
+
let offset = 0;
|
|
416
|
+
|
|
417
|
+
for (; offset < len; offset++) {
|
|
418
|
+
const code = arg.charCodeAt(offset);
|
|
419
|
+
if (code > 0x7F) break;
|
|
420
|
+
mem[ptr + offset] = code;
|
|
421
|
+
}
|
|
422
|
+
if (offset !== len) {
|
|
423
|
+
if (offset !== 0) {
|
|
424
|
+
arg = arg.slice(offset);
|
|
425
|
+
}
|
|
426
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
427
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
428
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
429
|
+
|
|
430
|
+
offset += ret.written;
|
|
431
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
WASM_VECTOR_LEN = offset;
|
|
435
|
+
return ptr;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
439
|
+
cachedTextDecoder.decode();
|
|
440
|
+
function decodeText(ptr, len) {
|
|
441
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const cachedTextEncoder = new TextEncoder();
|
|
445
|
+
|
|
446
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
447
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
448
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
449
|
+
view.set(buf);
|
|
450
|
+
return {
|
|
451
|
+
read: arg.length,
|
|
452
|
+
written: buf.length
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
let WASM_VECTOR_LEN = 0;
|
|
426
458
|
|
|
427
459
|
const wasmPath = `${__dirname}/cedar_wasm_bg.wasm`;
|
|
428
460
|
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
429
461
|
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
430
|
-
const wasm =
|
|
431
|
-
|
|
462
|
+
const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
432
463
|
wasm.__wbindgen_start();
|
|
Binary file
|
|
@@ -5,20 +5,22 @@ 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
8
|
export const isAuthorized: (a: any) => any;
|
|
9
|
+
export const isAuthorizedPartial: (a: any) => any;
|
|
10
10
|
export const preparsePolicySet: (a: number, b: number, c: any) => any;
|
|
11
11
|
export const preparseSchema: (a: number, b: number, c: any) => any;
|
|
12
12
|
export const statefulIsAuthorized: (a: any) => any;
|
|
13
|
-
export const validate: (a: any) => any;
|
|
14
13
|
export const checkParseContext: (a: any) => any;
|
|
15
14
|
export const checkParseEntities: (a: any) => any;
|
|
16
15
|
export const checkParsePolicySet: (a: any) => any;
|
|
17
16
|
export const checkParseSchema: (a: any) => any;
|
|
17
|
+
export const formatPolicies: (a: any) => any;
|
|
18
|
+
export const validate: (a: any) => any;
|
|
18
19
|
export const policySetTextToParts: (a: number, b: number) => any;
|
|
19
20
|
export const policyToJson: (a: any) => any;
|
|
20
21
|
export const policyToText: (a: any) => any;
|
|
21
22
|
export const schemaToJson: (a: any) => any;
|
|
23
|
+
export const schemaToJsonWithResolvedTypes: (a: number, b: number) => any;
|
|
22
24
|
export const schemaToText: (a: any) => any;
|
|
23
25
|
export const templateToJson: (a: any) => any;
|
|
24
26
|
export const templateToText: (a: any) => any;
|
package/nodejs/package.json
CHANGED
|
@@ -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.
|
|
4
|
+
"version": "4.9.1",
|
|
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.
|
|
5
|
+
"version": "4.9.1",
|
|
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",
|