@cedar-policy/cedar-wasm 3.3.0 → 3.4.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 +57 -57
- package/esm/cedar_wasm.js +1 -0
- package/esm/cedar_wasm_bg.js +38 -38
- package/esm/cedar_wasm_bg.wasm +0 -0
- package/esm/cedar_wasm_bg.wasm.d.ts +1 -1
- package/esm/package.json +4 -4
- package/nodejs/cedar_wasm.d.ts +57 -57
- package/nodejs/cedar_wasm.js +39 -38
- package/nodejs/cedar_wasm_bg.wasm +0 -0
- package/nodejs/cedar_wasm_bg.wasm.d.ts +1 -1
- package/nodejs/package.json +1 -1
- package/package.json +4 -2
- package/web/cedar_wasm.d.ts +62 -62
- package/web/cedar_wasm.js +61 -48
- package/web/cedar_wasm_bg.wasm +0 -0
- package/web/cedar_wasm_bg.wasm.d.ts +1 -1
- package/web/package.json +4 -4
package/esm/cedar_wasm.d.ts
CHANGED
|
@@ -46,10 +46,6 @@ export function checkParseEntities(entities_str: string, schema_str: string): Ch
|
|
|
46
46
|
*/
|
|
47
47
|
export function checkParseContext(context_str: string, action_str: string, schema_str: string): CheckParseResult;
|
|
48
48
|
/**
|
|
49
|
-
* @returns {string}
|
|
50
|
-
*/
|
|
51
|
-
export function getCedarVersion(): string;
|
|
52
|
-
/**
|
|
53
49
|
* @param {AuthorizationCall} call
|
|
54
50
|
* @returns {AuthorizationAnswer}
|
|
55
51
|
*/
|
|
@@ -59,6 +55,10 @@ export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
|
59
55
|
* @returns {ValidationAnswer}
|
|
60
56
|
*/
|
|
61
57
|
export function validate(call: ValidationCall): ValidationAnswer;
|
|
58
|
+
/**
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
export function getCedarVersion(): string;
|
|
62
62
|
export type JsonToPolicyResult = { type: "success"; policyText: string } | { type: "error"; errors: string[] };
|
|
63
63
|
|
|
64
64
|
export type PolicyToJsonResult = { type: "success"; policy: Policy } | { type: "error"; errors: string[] };
|
|
@@ -71,50 +71,6 @@ export type FormattingResult = { type: "success"; formatted_policy: string } | {
|
|
|
71
71
|
|
|
72
72
|
export type CheckParseResult = { type: "success" } | { type: "error"; errors: string[] };
|
|
73
73
|
|
|
74
|
-
export type Schema = { human: string } | { json: SchemaJson };
|
|
75
|
-
|
|
76
|
-
export type PolicySet = string | Record<string, string>;
|
|
77
|
-
|
|
78
|
-
export interface SourceLocation {
|
|
79
|
-
start: number;
|
|
80
|
-
end: number;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface SourceLabel extends SourceLocation {
|
|
84
|
-
label: string | null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export type Severity = "advice" | "warning" | "error";
|
|
88
|
-
|
|
89
|
-
export interface DetailedError {
|
|
90
|
-
message: string;
|
|
91
|
-
help: string | null;
|
|
92
|
-
code: string | null;
|
|
93
|
-
url: string | null;
|
|
94
|
-
severity: Severity | null;
|
|
95
|
-
sourceLocations?: SourceLabel[];
|
|
96
|
-
related?: DetailedError[];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
100
|
-
|
|
101
|
-
export interface ValidationError {
|
|
102
|
-
policyId: SmolStr;
|
|
103
|
-
error: DetailedError;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export type ValidationEnabled = "on" | "off";
|
|
107
|
-
|
|
108
|
-
export interface ValidationSettings {
|
|
109
|
-
enabled: ValidationEnabled;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface ValidationCall {
|
|
113
|
-
validationSettings?: ValidationSettings;
|
|
114
|
-
schema: Schema;
|
|
115
|
-
policySet: PolicySet;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
74
|
export interface RecvdSlice {
|
|
119
75
|
policies: PolicySet;
|
|
120
76
|
entities: Array<EntityJson>;
|
|
@@ -167,6 +123,50 @@ export interface Response {
|
|
|
167
123
|
diagnostics: Diagnostics;
|
|
168
124
|
}
|
|
169
125
|
|
|
126
|
+
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
127
|
+
|
|
128
|
+
export interface ValidationError {
|
|
129
|
+
policyId: SmolStr;
|
|
130
|
+
error: DetailedError;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type ValidationEnabled = "on" | "off";
|
|
134
|
+
|
|
135
|
+
export interface ValidationSettings {
|
|
136
|
+
enabled: ValidationEnabled;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface ValidationCall {
|
|
140
|
+
validationSettings?: ValidationSettings;
|
|
141
|
+
schema: Schema;
|
|
142
|
+
policySet: PolicySet;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type Schema = { human: string } | { json: SchemaJson };
|
|
146
|
+
|
|
147
|
+
export type PolicySet = string | Record<string, string>;
|
|
148
|
+
|
|
149
|
+
export interface SourceLocation {
|
|
150
|
+
start: number;
|
|
151
|
+
end: number;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface SourceLabel extends SourceLocation {
|
|
155
|
+
label: string | null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export type Severity = "advice" | "warning" | "error";
|
|
159
|
+
|
|
160
|
+
export interface DetailedError {
|
|
161
|
+
message: string;
|
|
162
|
+
help: string | null;
|
|
163
|
+
code: string | null;
|
|
164
|
+
url: string | null;
|
|
165
|
+
severity: Severity | null;
|
|
166
|
+
sourceLocations?: SourceLabel[];
|
|
167
|
+
related?: DetailedError[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
170
|
export type SchemaTypeVariant = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: SchemaType } | { type: "Record"; attributes: Record<SmolStr, TypeOfAttribute>; additionalAttributes: boolean } | { type: "Entity"; name: Name } | { type: "Extension"; name: Id };
|
|
171
171
|
|
|
172
172
|
export type SchemaType = SchemaTypeVariant | { type: Name };
|
|
@@ -234,16 +234,10 @@ export interface TypeAndId {
|
|
|
234
234
|
|
|
235
235
|
export type CedarValueJson = { __expr: string } | { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
236
236
|
|
|
237
|
-
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
238
|
-
|
|
239
|
-
export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: string } } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
|
|
240
|
-
|
|
241
|
-
export type Expr = ExprNoExt | ExtFuncCall;
|
|
242
|
-
|
|
243
|
-
export type Decision = "Allow" | "Deny";
|
|
244
|
-
|
|
245
237
|
export type Effect = "permit" | "forbid";
|
|
246
238
|
|
|
239
|
+
export type Var = "principal" | "action" | "resource" | "context";
|
|
240
|
+
|
|
247
241
|
export interface EntityJson {
|
|
248
242
|
uid: EntityUidJson;
|
|
249
243
|
attrs: Record<string, CedarValueJson>;
|
|
@@ -261,7 +255,13 @@ export interface Policy {
|
|
|
261
255
|
annotations?: Record<string, string>;
|
|
262
256
|
}
|
|
263
257
|
|
|
264
|
-
export type
|
|
258
|
+
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
259
|
+
|
|
260
|
+
export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: string } } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
|
|
261
|
+
|
|
262
|
+
export type Expr = ExprNoExt | ExtFuncCall;
|
|
263
|
+
|
|
264
|
+
export type Decision = "Allow" | "Deny";
|
|
265
265
|
|
|
266
266
|
type SmolStr = string;
|
|
267
267
|
type Name = string;
|
package/esm/cedar_wasm.js
CHANGED
package/esm/cedar_wasm_bg.js
CHANGED
|
@@ -35,13 +35,13 @@ function takeObject(idx) {
|
|
|
35
35
|
|
|
36
36
|
let WASM_VECTOR_LEN = 0;
|
|
37
37
|
|
|
38
|
-
let
|
|
38
|
+
let cachedUint8ArrayMemory0 = null;
|
|
39
39
|
|
|
40
|
-
function
|
|
41
|
-
if (
|
|
42
|
-
|
|
40
|
+
function getUint8ArrayMemory0() {
|
|
41
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
42
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
43
43
|
}
|
|
44
|
-
return
|
|
44
|
+
return cachedUint8ArrayMemory0;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
@@ -66,7 +66,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
66
66
|
if (realloc === undefined) {
|
|
67
67
|
const buf = cachedTextEncoder.encode(arg);
|
|
68
68
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
69
|
-
|
|
69
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
70
70
|
WASM_VECTOR_LEN = buf.length;
|
|
71
71
|
return ptr;
|
|
72
72
|
}
|
|
@@ -74,7 +74,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
74
74
|
let len = arg.length;
|
|
75
75
|
let ptr = malloc(len, 1) >>> 0;
|
|
76
76
|
|
|
77
|
-
const mem =
|
|
77
|
+
const mem = getUint8ArrayMemory0();
|
|
78
78
|
|
|
79
79
|
let offset = 0;
|
|
80
80
|
|
|
@@ -89,7 +89,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
89
89
|
arg = arg.slice(offset);
|
|
90
90
|
}
|
|
91
91
|
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
92
|
-
const view =
|
|
92
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
93
93
|
const ret = encodeString(arg, view);
|
|
94
94
|
|
|
95
95
|
offset += ret.written;
|
|
@@ -104,13 +104,13 @@ function isLikeNone(x) {
|
|
|
104
104
|
return x === undefined || x === null;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
let
|
|
107
|
+
let cachedDataViewMemory0 = null;
|
|
108
108
|
|
|
109
|
-
function
|
|
110
|
-
if (
|
|
111
|
-
|
|
109
|
+
function getDataViewMemory0() {
|
|
110
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
111
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
112
112
|
}
|
|
113
|
-
return
|
|
113
|
+
return cachedDataViewMemory0;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
@@ -121,7 +121,7 @@ cachedTextDecoder.decode();
|
|
|
121
121
|
|
|
122
122
|
function getStringFromWasm0(ptr, len) {
|
|
123
123
|
ptr = ptr >>> 0;
|
|
124
|
-
return cachedTextDecoder.decode(
|
|
124
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
127
|
* @param {string} json_str
|
|
@@ -222,26 +222,6 @@ export function checkParseContext(context_str, action_str, schema_str) {
|
|
|
222
222
|
return takeObject(ret);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
/**
|
|
226
|
-
* @returns {string}
|
|
227
|
-
*/
|
|
228
|
-
export function getCedarVersion() {
|
|
229
|
-
let deferred1_0;
|
|
230
|
-
let deferred1_1;
|
|
231
|
-
try {
|
|
232
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
233
|
-
wasm.getCedarVersion(retptr);
|
|
234
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
235
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
236
|
-
deferred1_0 = r0;
|
|
237
|
-
deferred1_1 = r1;
|
|
238
|
-
return getStringFromWasm0(r0, r1);
|
|
239
|
-
} finally {
|
|
240
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
241
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
225
|
/**
|
|
246
226
|
* @param {AuthorizationCall} call
|
|
247
227
|
* @returns {AuthorizationAnswer}
|
|
@@ -260,6 +240,26 @@ export function validate(call) {
|
|
|
260
240
|
return takeObject(ret);
|
|
261
241
|
}
|
|
262
242
|
|
|
243
|
+
/**
|
|
244
|
+
* @returns {string}
|
|
245
|
+
*/
|
|
246
|
+
export function getCedarVersion() {
|
|
247
|
+
let deferred1_0;
|
|
248
|
+
let deferred1_1;
|
|
249
|
+
try {
|
|
250
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
251
|
+
wasm.getCedarVersion(retptr);
|
|
252
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
253
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
254
|
+
deferred1_0 = r0;
|
|
255
|
+
deferred1_1 = r1;
|
|
256
|
+
return getStringFromWasm0(r0, r1);
|
|
257
|
+
} finally {
|
|
258
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
259
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
263
|
function handleError(f, args) {
|
|
264
264
|
try {
|
|
265
265
|
return f.apply(this, args);
|
|
@@ -287,16 +287,16 @@ export function __wbindgen_string_get(arg0, arg1) {
|
|
|
287
287
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
288
288
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
289
289
|
var len1 = WASM_VECTOR_LEN;
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
291
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
292
292
|
};
|
|
293
293
|
|
|
294
|
-
export function
|
|
294
|
+
export function __wbg_parse_52202f117ec9ecfa() { return handleError(function (arg0, arg1) {
|
|
295
295
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
296
296
|
return addHeapObject(ret);
|
|
297
297
|
}, arguments) };
|
|
298
298
|
|
|
299
|
-
export function
|
|
299
|
+
export function __wbg_stringify_bbf45426c92a6bf5() { return handleError(function (arg0) {
|
|
300
300
|
const ret = JSON.stringify(getObject(arg0));
|
|
301
301
|
return addHeapObject(ret);
|
|
302
302
|
}, arguments) };
|
package/esm/cedar_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -9,9 +9,9 @@ export function formatPolicies(a: number, b: number, c: number, d: number): numb
|
|
|
9
9
|
export function checkParseSchema(a: number, b: number): number;
|
|
10
10
|
export function checkParseEntities(a: number, b: number, c: number, d: number): number;
|
|
11
11
|
export function checkParseContext(a: number, b: number, c: number, d: number, e: number, f: number): number;
|
|
12
|
-
export function getCedarVersion(a: number): void;
|
|
13
12
|
export function isAuthorized(a: number): number;
|
|
14
13
|
export function validate(a: number): number;
|
|
14
|
+
export function getCedarVersion(a: number): void;
|
|
15
15
|
export function __wbindgen_malloc(a: number, b: number): number;
|
|
16
16
|
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
|
|
17
17
|
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
package/esm/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedar-policy/cedar-wasm",
|
|
3
|
+
"type": "module",
|
|
3
4
|
"description": "Wasm bindings and typescript types for Cedar lib",
|
|
4
|
-
"version": "3.
|
|
5
|
+
"version": "3.4.1",
|
|
5
6
|
"license": "Apache-2.0",
|
|
6
7
|
"files": [
|
|
7
8
|
"cedar_wasm_bg.wasm",
|
|
@@ -9,11 +10,10 @@
|
|
|
9
10
|
"cedar_wasm_bg.js",
|
|
10
11
|
"cedar_wasm.d.ts"
|
|
11
12
|
],
|
|
12
|
-
"
|
|
13
|
+
"main": "cedar_wasm.js",
|
|
13
14
|
"types": "cedar_wasm.d.ts",
|
|
14
15
|
"sideEffects": [
|
|
15
16
|
"./cedar_wasm.js",
|
|
16
17
|
"./snippets/*"
|
|
17
|
-
]
|
|
18
|
-
"type": "module"
|
|
18
|
+
]
|
|
19
19
|
}
|
package/nodejs/cedar_wasm.d.ts
CHANGED
|
@@ -46,10 +46,6 @@ export function checkParseEntities(entities_str: string, schema_str: string): Ch
|
|
|
46
46
|
*/
|
|
47
47
|
export function checkParseContext(context_str: string, action_str: string, schema_str: string): CheckParseResult;
|
|
48
48
|
/**
|
|
49
|
-
* @returns {string}
|
|
50
|
-
*/
|
|
51
|
-
export function getCedarVersion(): string;
|
|
52
|
-
/**
|
|
53
49
|
* @param {AuthorizationCall} call
|
|
54
50
|
* @returns {AuthorizationAnswer}
|
|
55
51
|
*/
|
|
@@ -59,6 +55,10 @@ export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
|
59
55
|
* @returns {ValidationAnswer}
|
|
60
56
|
*/
|
|
61
57
|
export function validate(call: ValidationCall): ValidationAnswer;
|
|
58
|
+
/**
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
export function getCedarVersion(): string;
|
|
62
62
|
export type JsonToPolicyResult = { type: "success"; policyText: string } | { type: "error"; errors: string[] };
|
|
63
63
|
|
|
64
64
|
export type PolicyToJsonResult = { type: "success"; policy: Policy } | { type: "error"; errors: string[] };
|
|
@@ -71,50 +71,6 @@ export type FormattingResult = { type: "success"; formatted_policy: string } | {
|
|
|
71
71
|
|
|
72
72
|
export type CheckParseResult = { type: "success" } | { type: "error"; errors: string[] };
|
|
73
73
|
|
|
74
|
-
export type Schema = { human: string } | { json: SchemaJson };
|
|
75
|
-
|
|
76
|
-
export type PolicySet = string | Record<string, string>;
|
|
77
|
-
|
|
78
|
-
export interface SourceLocation {
|
|
79
|
-
start: number;
|
|
80
|
-
end: number;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface SourceLabel extends SourceLocation {
|
|
84
|
-
label: string | null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export type Severity = "advice" | "warning" | "error";
|
|
88
|
-
|
|
89
|
-
export interface DetailedError {
|
|
90
|
-
message: string;
|
|
91
|
-
help: string | null;
|
|
92
|
-
code: string | null;
|
|
93
|
-
url: string | null;
|
|
94
|
-
severity: Severity | null;
|
|
95
|
-
sourceLocations?: SourceLabel[];
|
|
96
|
-
related?: DetailedError[];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
100
|
-
|
|
101
|
-
export interface ValidationError {
|
|
102
|
-
policyId: SmolStr;
|
|
103
|
-
error: DetailedError;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export type ValidationEnabled = "on" | "off";
|
|
107
|
-
|
|
108
|
-
export interface ValidationSettings {
|
|
109
|
-
enabled: ValidationEnabled;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface ValidationCall {
|
|
113
|
-
validationSettings?: ValidationSettings;
|
|
114
|
-
schema: Schema;
|
|
115
|
-
policySet: PolicySet;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
74
|
export interface RecvdSlice {
|
|
119
75
|
policies: PolicySet;
|
|
120
76
|
entities: Array<EntityJson>;
|
|
@@ -167,6 +123,50 @@ export interface Response {
|
|
|
167
123
|
diagnostics: Diagnostics;
|
|
168
124
|
}
|
|
169
125
|
|
|
126
|
+
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
127
|
+
|
|
128
|
+
export interface ValidationError {
|
|
129
|
+
policyId: SmolStr;
|
|
130
|
+
error: DetailedError;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type ValidationEnabled = "on" | "off";
|
|
134
|
+
|
|
135
|
+
export interface ValidationSettings {
|
|
136
|
+
enabled: ValidationEnabled;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface ValidationCall {
|
|
140
|
+
validationSettings?: ValidationSettings;
|
|
141
|
+
schema: Schema;
|
|
142
|
+
policySet: PolicySet;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type Schema = { human: string } | { json: SchemaJson };
|
|
146
|
+
|
|
147
|
+
export type PolicySet = string | Record<string, string>;
|
|
148
|
+
|
|
149
|
+
export interface SourceLocation {
|
|
150
|
+
start: number;
|
|
151
|
+
end: number;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface SourceLabel extends SourceLocation {
|
|
155
|
+
label: string | null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export type Severity = "advice" | "warning" | "error";
|
|
159
|
+
|
|
160
|
+
export interface DetailedError {
|
|
161
|
+
message: string;
|
|
162
|
+
help: string | null;
|
|
163
|
+
code: string | null;
|
|
164
|
+
url: string | null;
|
|
165
|
+
severity: Severity | null;
|
|
166
|
+
sourceLocations?: SourceLabel[];
|
|
167
|
+
related?: DetailedError[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
170
|
export type SchemaTypeVariant = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: SchemaType } | { type: "Record"; attributes: Record<SmolStr, TypeOfAttribute>; additionalAttributes: boolean } | { type: "Entity"; name: Name } | { type: "Extension"; name: Id };
|
|
171
171
|
|
|
172
172
|
export type SchemaType = SchemaTypeVariant | { type: Name };
|
|
@@ -234,16 +234,10 @@ export interface TypeAndId {
|
|
|
234
234
|
|
|
235
235
|
export type CedarValueJson = { __expr: string } | { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
236
236
|
|
|
237
|
-
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
238
|
-
|
|
239
|
-
export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: string } } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
|
|
240
|
-
|
|
241
|
-
export type Expr = ExprNoExt | ExtFuncCall;
|
|
242
|
-
|
|
243
|
-
export type Decision = "Allow" | "Deny";
|
|
244
|
-
|
|
245
237
|
export type Effect = "permit" | "forbid";
|
|
246
238
|
|
|
239
|
+
export type Var = "principal" | "action" | "resource" | "context";
|
|
240
|
+
|
|
247
241
|
export interface EntityJson {
|
|
248
242
|
uid: EntityUidJson;
|
|
249
243
|
attrs: Record<string, CedarValueJson>;
|
|
@@ -261,7 +255,13 @@ export interface Policy {
|
|
|
261
255
|
annotations?: Record<string, string>;
|
|
262
256
|
}
|
|
263
257
|
|
|
264
|
-
export type
|
|
258
|
+
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
259
|
+
|
|
260
|
+
export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: string } } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
|
|
261
|
+
|
|
262
|
+
export type Expr = ExprNoExt | ExtFuncCall;
|
|
263
|
+
|
|
264
|
+
export type Decision = "Allow" | "Deny";
|
|
265
265
|
|
|
266
266
|
type SmolStr = string;
|
|
267
267
|
type Name = string;
|
package/nodejs/cedar_wasm.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
let imports = {};
|
|
2
3
|
imports['__wbindgen_placeholder__'] = module.exports;
|
|
3
4
|
let wasm;
|
|
@@ -34,13 +35,13 @@ function takeObject(idx) {
|
|
|
34
35
|
|
|
35
36
|
let WASM_VECTOR_LEN = 0;
|
|
36
37
|
|
|
37
|
-
let
|
|
38
|
+
let cachedUint8ArrayMemory0 = null;
|
|
38
39
|
|
|
39
|
-
function
|
|
40
|
-
if (
|
|
41
|
-
|
|
40
|
+
function getUint8ArrayMemory0() {
|
|
41
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
42
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
42
43
|
}
|
|
43
|
-
return
|
|
44
|
+
return cachedUint8ArrayMemory0;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
@@ -63,7 +64,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
63
64
|
if (realloc === undefined) {
|
|
64
65
|
const buf = cachedTextEncoder.encode(arg);
|
|
65
66
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
66
|
-
|
|
67
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
67
68
|
WASM_VECTOR_LEN = buf.length;
|
|
68
69
|
return ptr;
|
|
69
70
|
}
|
|
@@ -71,7 +72,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
71
72
|
let len = arg.length;
|
|
72
73
|
let ptr = malloc(len, 1) >>> 0;
|
|
73
74
|
|
|
74
|
-
const mem =
|
|
75
|
+
const mem = getUint8ArrayMemory0();
|
|
75
76
|
|
|
76
77
|
let offset = 0;
|
|
77
78
|
|
|
@@ -86,7 +87,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
86
87
|
arg = arg.slice(offset);
|
|
87
88
|
}
|
|
88
89
|
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
89
|
-
const view =
|
|
90
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
90
91
|
const ret = encodeString(arg, view);
|
|
91
92
|
|
|
92
93
|
offset += ret.written;
|
|
@@ -101,13 +102,13 @@ function isLikeNone(x) {
|
|
|
101
102
|
return x === undefined || x === null;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
let
|
|
105
|
+
let cachedDataViewMemory0 = null;
|
|
105
106
|
|
|
106
|
-
function
|
|
107
|
-
if (
|
|
108
|
-
|
|
107
|
+
function getDataViewMemory0() {
|
|
108
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
109
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
109
110
|
}
|
|
110
|
-
return
|
|
111
|
+
return cachedDataViewMemory0;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
@@ -116,7 +117,7 @@ cachedTextDecoder.decode();
|
|
|
116
117
|
|
|
117
118
|
function getStringFromWasm0(ptr, len) {
|
|
118
119
|
ptr = ptr >>> 0;
|
|
119
|
-
return cachedTextDecoder.decode(
|
|
120
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
120
121
|
}
|
|
121
122
|
/**
|
|
122
123
|
* @param {string} json_str
|
|
@@ -217,26 +218,6 @@ module.exports.checkParseContext = function(context_str, action_str, schema_str)
|
|
|
217
218
|
return takeObject(ret);
|
|
218
219
|
};
|
|
219
220
|
|
|
220
|
-
/**
|
|
221
|
-
* @returns {string}
|
|
222
|
-
*/
|
|
223
|
-
module.exports.getCedarVersion = function() {
|
|
224
|
-
let deferred1_0;
|
|
225
|
-
let deferred1_1;
|
|
226
|
-
try {
|
|
227
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
228
|
-
wasm.getCedarVersion(retptr);
|
|
229
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
230
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
231
|
-
deferred1_0 = r0;
|
|
232
|
-
deferred1_1 = r1;
|
|
233
|
-
return getStringFromWasm0(r0, r1);
|
|
234
|
-
} finally {
|
|
235
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
236
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
|
|
240
221
|
/**
|
|
241
222
|
* @param {AuthorizationCall} call
|
|
242
223
|
* @returns {AuthorizationAnswer}
|
|
@@ -255,6 +236,26 @@ module.exports.validate = function(call) {
|
|
|
255
236
|
return takeObject(ret);
|
|
256
237
|
};
|
|
257
238
|
|
|
239
|
+
/**
|
|
240
|
+
* @returns {string}
|
|
241
|
+
*/
|
|
242
|
+
module.exports.getCedarVersion = function() {
|
|
243
|
+
let deferred1_0;
|
|
244
|
+
let deferred1_1;
|
|
245
|
+
try {
|
|
246
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
247
|
+
wasm.getCedarVersion(retptr);
|
|
248
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
249
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
250
|
+
deferred1_0 = r0;
|
|
251
|
+
deferred1_1 = r1;
|
|
252
|
+
return getStringFromWasm0(r0, r1);
|
|
253
|
+
} finally {
|
|
254
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
255
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
258
259
|
function handleError(f, args) {
|
|
259
260
|
try {
|
|
260
261
|
return f.apply(this, args);
|
|
@@ -282,16 +283,16 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
|
282
283
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
283
284
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
284
285
|
var len1 = WASM_VECTOR_LEN;
|
|
285
|
-
|
|
286
|
-
|
|
286
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
287
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
287
288
|
};
|
|
288
289
|
|
|
289
|
-
module.exports.
|
|
290
|
+
module.exports.__wbg_parse_52202f117ec9ecfa = function() { return handleError(function (arg0, arg1) {
|
|
290
291
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
291
292
|
return addHeapObject(ret);
|
|
292
293
|
}, arguments) };
|
|
293
294
|
|
|
294
|
-
module.exports.
|
|
295
|
+
module.exports.__wbg_stringify_bbf45426c92a6bf5 = function() { return handleError(function (arg0) {
|
|
295
296
|
const ret = JSON.stringify(getObject(arg0));
|
|
296
297
|
return addHeapObject(ret);
|
|
297
298
|
}, arguments) };
|
|
Binary file
|
|
@@ -9,9 +9,9 @@ export function formatPolicies(a: number, b: number, c: number, d: number): numb
|
|
|
9
9
|
export function checkParseSchema(a: number, b: number): number;
|
|
10
10
|
export function checkParseEntities(a: number, b: number, c: number, d: number): number;
|
|
11
11
|
export function checkParseContext(a: number, b: number, c: number, d: number, e: number, f: number): number;
|
|
12
|
-
export function getCedarVersion(a: number): void;
|
|
13
12
|
export function isAuthorized(a: number): number;
|
|
14
13
|
export function validate(a: number): number;
|
|
14
|
+
export function getCedarVersion(a: number): void;
|
|
15
15
|
export function __wbindgen_malloc(a: number, b: number): number;
|
|
16
16
|
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
|
|
17
17
|
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
package/nodejs/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedar-policy/cedar-wasm",
|
|
3
|
+
"type": "module",
|
|
3
4
|
"description": "Wasm bindings and typescript types for Cedar lib",
|
|
4
|
-
"version": "3.
|
|
5
|
+
"version": "3.4.1",
|
|
5
6
|
"license": "Apache-2.0",
|
|
6
7
|
"files": [
|
|
7
8
|
"esm/package.json",
|
|
@@ -24,11 +25,12 @@
|
|
|
24
25
|
"web/cedar_wasm.js",
|
|
25
26
|
"web/cedar_wasm.d.ts"
|
|
26
27
|
],
|
|
27
|
-
"
|
|
28
|
+
"main": "cedar_wasm.js",
|
|
28
29
|
"types": "esm/cedar_wasm.d.ts",
|
|
29
30
|
"sideEffects": [
|
|
30
31
|
"./snippets/*"
|
|
31
32
|
],
|
|
33
|
+
"module": "esm/cedar_wasm.js",
|
|
32
34
|
"exports": {
|
|
33
35
|
".": {
|
|
34
36
|
"import": "./esm/cedar_wasm.js",
|
package/web/cedar_wasm.d.ts
CHANGED
|
@@ -46,10 +46,6 @@ export function checkParseEntities(entities_str: string, schema_str: string): Ch
|
|
|
46
46
|
*/
|
|
47
47
|
export function checkParseContext(context_str: string, action_str: string, schema_str: string): CheckParseResult;
|
|
48
48
|
/**
|
|
49
|
-
* @returns {string}
|
|
50
|
-
*/
|
|
51
|
-
export function getCedarVersion(): string;
|
|
52
|
-
/**
|
|
53
49
|
* @param {AuthorizationCall} call
|
|
54
50
|
* @returns {AuthorizationAnswer}
|
|
55
51
|
*/
|
|
@@ -59,6 +55,10 @@ export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
|
59
55
|
* @returns {ValidationAnswer}
|
|
60
56
|
*/
|
|
61
57
|
export function validate(call: ValidationCall): ValidationAnswer;
|
|
58
|
+
/**
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
export function getCedarVersion(): string;
|
|
62
62
|
export type JsonToPolicyResult = { type: "success"; policyText: string } | { type: "error"; errors: string[] };
|
|
63
63
|
|
|
64
64
|
export type PolicyToJsonResult = { type: "success"; policy: Policy } | { type: "error"; errors: string[] };
|
|
@@ -71,50 +71,6 @@ export type FormattingResult = { type: "success"; formatted_policy: string } | {
|
|
|
71
71
|
|
|
72
72
|
export type CheckParseResult = { type: "success" } | { type: "error"; errors: string[] };
|
|
73
73
|
|
|
74
|
-
export type Schema = { human: string } | { json: SchemaJson };
|
|
75
|
-
|
|
76
|
-
export type PolicySet = string | Record<string, string>;
|
|
77
|
-
|
|
78
|
-
export interface SourceLocation {
|
|
79
|
-
start: number;
|
|
80
|
-
end: number;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface SourceLabel extends SourceLocation {
|
|
84
|
-
label: string | null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export type Severity = "advice" | "warning" | "error";
|
|
88
|
-
|
|
89
|
-
export interface DetailedError {
|
|
90
|
-
message: string;
|
|
91
|
-
help: string | null;
|
|
92
|
-
code: string | null;
|
|
93
|
-
url: string | null;
|
|
94
|
-
severity: Severity | null;
|
|
95
|
-
sourceLocations?: SourceLabel[];
|
|
96
|
-
related?: DetailedError[];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
100
|
-
|
|
101
|
-
export interface ValidationError {
|
|
102
|
-
policyId: SmolStr;
|
|
103
|
-
error: DetailedError;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export type ValidationEnabled = "on" | "off";
|
|
107
|
-
|
|
108
|
-
export interface ValidationSettings {
|
|
109
|
-
enabled: ValidationEnabled;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface ValidationCall {
|
|
113
|
-
validationSettings?: ValidationSettings;
|
|
114
|
-
schema: Schema;
|
|
115
|
-
policySet: PolicySet;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
74
|
export interface RecvdSlice {
|
|
119
75
|
policies: PolicySet;
|
|
120
76
|
entities: Array<EntityJson>;
|
|
@@ -167,6 +123,50 @@ export interface Response {
|
|
|
167
123
|
diagnostics: Diagnostics;
|
|
168
124
|
}
|
|
169
125
|
|
|
126
|
+
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
127
|
+
|
|
128
|
+
export interface ValidationError {
|
|
129
|
+
policyId: SmolStr;
|
|
130
|
+
error: DetailedError;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type ValidationEnabled = "on" | "off";
|
|
134
|
+
|
|
135
|
+
export interface ValidationSettings {
|
|
136
|
+
enabled: ValidationEnabled;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface ValidationCall {
|
|
140
|
+
validationSettings?: ValidationSettings;
|
|
141
|
+
schema: Schema;
|
|
142
|
+
policySet: PolicySet;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type Schema = { human: string } | { json: SchemaJson };
|
|
146
|
+
|
|
147
|
+
export type PolicySet = string | Record<string, string>;
|
|
148
|
+
|
|
149
|
+
export interface SourceLocation {
|
|
150
|
+
start: number;
|
|
151
|
+
end: number;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface SourceLabel extends SourceLocation {
|
|
155
|
+
label: string | null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export type Severity = "advice" | "warning" | "error";
|
|
159
|
+
|
|
160
|
+
export interface DetailedError {
|
|
161
|
+
message: string;
|
|
162
|
+
help: string | null;
|
|
163
|
+
code: string | null;
|
|
164
|
+
url: string | null;
|
|
165
|
+
severity: Severity | null;
|
|
166
|
+
sourceLocations?: SourceLabel[];
|
|
167
|
+
related?: DetailedError[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
170
|
export type SchemaTypeVariant = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: SchemaType } | { type: "Record"; attributes: Record<SmolStr, TypeOfAttribute>; additionalAttributes: boolean } | { type: "Entity"; name: Name } | { type: "Extension"; name: Id };
|
|
171
171
|
|
|
172
172
|
export type SchemaType = SchemaTypeVariant | { type: Name };
|
|
@@ -234,16 +234,10 @@ export interface TypeAndId {
|
|
|
234
234
|
|
|
235
235
|
export type CedarValueJson = { __expr: string } | { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
236
236
|
|
|
237
|
-
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
238
|
-
|
|
239
|
-
export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: string } } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
|
|
240
|
-
|
|
241
|
-
export type Expr = ExprNoExt | ExtFuncCall;
|
|
242
|
-
|
|
243
|
-
export type Decision = "Allow" | "Deny";
|
|
244
|
-
|
|
245
237
|
export type Effect = "permit" | "forbid";
|
|
246
238
|
|
|
239
|
+
export type Var = "principal" | "action" | "resource" | "context";
|
|
240
|
+
|
|
247
241
|
export interface EntityJson {
|
|
248
242
|
uid: EntityUidJson;
|
|
249
243
|
attrs: Record<string, CedarValueJson>;
|
|
@@ -261,7 +255,13 @@ export interface Policy {
|
|
|
261
255
|
annotations?: Record<string, string>;
|
|
262
256
|
}
|
|
263
257
|
|
|
264
|
-
export type
|
|
258
|
+
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
259
|
+
|
|
260
|
+
export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { Unknown: { name: string } } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: SmolStr } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
|
|
261
|
+
|
|
262
|
+
export type Expr = ExprNoExt | ExtFuncCall;
|
|
263
|
+
|
|
264
|
+
export type Decision = "Allow" | "Deny";
|
|
265
265
|
|
|
266
266
|
|
|
267
267
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
@@ -276,9 +276,9 @@ export interface InitOutput {
|
|
|
276
276
|
readonly checkParseSchema: (a: number, b: number) => number;
|
|
277
277
|
readonly checkParseEntities: (a: number, b: number, c: number, d: number) => number;
|
|
278
278
|
readonly checkParseContext: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
279
|
-
readonly getCedarVersion: (a: number) => void;
|
|
280
279
|
readonly isAuthorized: (a: number) => number;
|
|
281
280
|
readonly validate: (a: number) => number;
|
|
281
|
+
readonly getCedarVersion: (a: number) => void;
|
|
282
282
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
283
283
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
284
284
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
@@ -291,21 +291,21 @@ export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
|
291
291
|
* Instantiates the given `module`, which can either be bytes or
|
|
292
292
|
* a precompiled `WebAssembly.Module`.
|
|
293
293
|
*
|
|
294
|
-
* @param {SyncInitInput} module
|
|
294
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
295
295
|
*
|
|
296
296
|
* @returns {InitOutput}
|
|
297
297
|
*/
|
|
298
|
-
export function initSync(module: SyncInitInput): InitOutput;
|
|
298
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
299
299
|
|
|
300
300
|
/**
|
|
301
301
|
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
302
302
|
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
303
303
|
*
|
|
304
|
-
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
304
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
305
305
|
*
|
|
306
306
|
* @returns {Promise<InitOutput>}
|
|
307
307
|
*/
|
|
308
|
-
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
308
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
309
309
|
type SmolStr = string;
|
|
310
310
|
type Name = string;
|
|
311
311
|
type Id = string;
|
package/web/cedar_wasm.js
CHANGED
|
@@ -31,13 +31,13 @@ function takeObject(idx) {
|
|
|
31
31
|
|
|
32
32
|
let WASM_VECTOR_LEN = 0;
|
|
33
33
|
|
|
34
|
-
let
|
|
34
|
+
let cachedUint8ArrayMemory0 = null;
|
|
35
35
|
|
|
36
|
-
function
|
|
37
|
-
if (
|
|
38
|
-
|
|
36
|
+
function getUint8ArrayMemory0() {
|
|
37
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
38
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
39
39
|
}
|
|
40
|
-
return
|
|
40
|
+
return cachedUint8ArrayMemory0;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
@@ -60,7 +60,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
60
60
|
if (realloc === undefined) {
|
|
61
61
|
const buf = cachedTextEncoder.encode(arg);
|
|
62
62
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
63
|
-
|
|
63
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
64
64
|
WASM_VECTOR_LEN = buf.length;
|
|
65
65
|
return ptr;
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
68
68
|
let len = arg.length;
|
|
69
69
|
let ptr = malloc(len, 1) >>> 0;
|
|
70
70
|
|
|
71
|
-
const mem =
|
|
71
|
+
const mem = getUint8ArrayMemory0();
|
|
72
72
|
|
|
73
73
|
let offset = 0;
|
|
74
74
|
|
|
@@ -83,7 +83,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
83
83
|
arg = arg.slice(offset);
|
|
84
84
|
}
|
|
85
85
|
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
86
|
-
const view =
|
|
86
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
87
87
|
const ret = encodeString(arg, view);
|
|
88
88
|
|
|
89
89
|
offset += ret.written;
|
|
@@ -98,13 +98,13 @@ function isLikeNone(x) {
|
|
|
98
98
|
return x === undefined || x === null;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
let
|
|
101
|
+
let cachedDataViewMemory0 = null;
|
|
102
102
|
|
|
103
|
-
function
|
|
104
|
-
if (
|
|
105
|
-
|
|
103
|
+
function getDataViewMemory0() {
|
|
104
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
105
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
106
106
|
}
|
|
107
|
-
return
|
|
107
|
+
return cachedDataViewMemory0;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
@@ -113,7 +113,7 @@ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
|
113
113
|
|
|
114
114
|
function getStringFromWasm0(ptr, len) {
|
|
115
115
|
ptr = ptr >>> 0;
|
|
116
|
-
return cachedTextDecoder.decode(
|
|
116
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* @param {string} json_str
|
|
@@ -214,26 +214,6 @@ export function checkParseContext(context_str, action_str, schema_str) {
|
|
|
214
214
|
return takeObject(ret);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
/**
|
|
218
|
-
* @returns {string}
|
|
219
|
-
*/
|
|
220
|
-
export function getCedarVersion() {
|
|
221
|
-
let deferred1_0;
|
|
222
|
-
let deferred1_1;
|
|
223
|
-
try {
|
|
224
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
225
|
-
wasm.getCedarVersion(retptr);
|
|
226
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
227
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
228
|
-
deferred1_0 = r0;
|
|
229
|
-
deferred1_1 = r1;
|
|
230
|
-
return getStringFromWasm0(r0, r1);
|
|
231
|
-
} finally {
|
|
232
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
233
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
217
|
/**
|
|
238
218
|
* @param {AuthorizationCall} call
|
|
239
219
|
* @returns {AuthorizationAnswer}
|
|
@@ -252,6 +232,26 @@ export function validate(call) {
|
|
|
252
232
|
return takeObject(ret);
|
|
253
233
|
}
|
|
254
234
|
|
|
235
|
+
/**
|
|
236
|
+
* @returns {string}
|
|
237
|
+
*/
|
|
238
|
+
export function getCedarVersion() {
|
|
239
|
+
let deferred1_0;
|
|
240
|
+
let deferred1_1;
|
|
241
|
+
try {
|
|
242
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
243
|
+
wasm.getCedarVersion(retptr);
|
|
244
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
245
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
246
|
+
deferred1_0 = r0;
|
|
247
|
+
deferred1_1 = r1;
|
|
248
|
+
return getStringFromWasm0(r0, r1);
|
|
249
|
+
} finally {
|
|
250
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
251
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
255
|
function handleError(f, args) {
|
|
256
256
|
try {
|
|
257
257
|
return f.apply(this, args);
|
|
@@ -310,14 +310,14 @@ function __wbg_get_imports() {
|
|
|
310
310
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
311
311
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
312
312
|
var len1 = WASM_VECTOR_LEN;
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
314
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
315
315
|
};
|
|
316
|
-
imports.wbg.
|
|
316
|
+
imports.wbg.__wbg_parse_52202f117ec9ecfa = function() { return handleError(function (arg0, arg1) {
|
|
317
317
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
318
318
|
return addHeapObject(ret);
|
|
319
319
|
}, arguments) };
|
|
320
|
-
imports.wbg.
|
|
320
|
+
imports.wbg.__wbg_stringify_bbf45426c92a6bf5 = function() { return handleError(function (arg0) {
|
|
321
321
|
const ret = JSON.stringify(getObject(arg0));
|
|
322
322
|
return addHeapObject(ret);
|
|
323
323
|
}, arguments) };
|
|
@@ -328,15 +328,16 @@ function __wbg_get_imports() {
|
|
|
328
328
|
return imports;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
function __wbg_init_memory(imports,
|
|
331
|
+
function __wbg_init_memory(imports, memory) {
|
|
332
332
|
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
function __wbg_finalize_init(instance, module) {
|
|
336
336
|
wasm = instance.exports;
|
|
337
337
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
338
|
-
|
|
339
|
-
|
|
338
|
+
cachedDataViewMemory0 = null;
|
|
339
|
+
cachedUint8ArrayMemory0 = null;
|
|
340
|
+
|
|
340
341
|
|
|
341
342
|
|
|
342
343
|
return wasm;
|
|
@@ -345,6 +346,12 @@ function __wbg_finalize_init(instance, module) {
|
|
|
345
346
|
function initSync(module) {
|
|
346
347
|
if (wasm !== undefined) return wasm;
|
|
347
348
|
|
|
349
|
+
|
|
350
|
+
if (typeof module !== 'undefined' && Object.getPrototypeOf(module) === Object.prototype)
|
|
351
|
+
({module} = module)
|
|
352
|
+
else
|
|
353
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
354
|
+
|
|
348
355
|
const imports = __wbg_get_imports();
|
|
349
356
|
|
|
350
357
|
__wbg_init_memory(imports);
|
|
@@ -358,24 +365,30 @@ function initSync(module) {
|
|
|
358
365
|
return __wbg_finalize_init(instance, module);
|
|
359
366
|
}
|
|
360
367
|
|
|
361
|
-
async function __wbg_init(
|
|
368
|
+
async function __wbg_init(module_or_path) {
|
|
362
369
|
if (wasm !== undefined) return wasm;
|
|
363
370
|
|
|
364
|
-
|
|
365
|
-
|
|
371
|
+
|
|
372
|
+
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
|
|
373
|
+
({module_or_path} = module_or_path)
|
|
374
|
+
else
|
|
375
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
376
|
+
|
|
377
|
+
if (typeof module_or_path === 'undefined') {
|
|
378
|
+
module_or_path = new URL('cedar_wasm_bg.wasm', import.meta.url);
|
|
366
379
|
}
|
|
367
380
|
const imports = __wbg_get_imports();
|
|
368
381
|
|
|
369
|
-
if (typeof
|
|
370
|
-
|
|
382
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
383
|
+
module_or_path = fetch(module_or_path);
|
|
371
384
|
}
|
|
372
385
|
|
|
373
386
|
__wbg_init_memory(imports);
|
|
374
387
|
|
|
375
|
-
const { instance, module } = await __wbg_load(await
|
|
388
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
376
389
|
|
|
377
390
|
return __wbg_finalize_init(instance, module);
|
|
378
391
|
}
|
|
379
392
|
|
|
380
|
-
export { initSync }
|
|
393
|
+
export { initSync };
|
|
381
394
|
export default __wbg_init;
|
package/web/cedar_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -9,9 +9,9 @@ export function formatPolicies(a: number, b: number, c: number, d: number): numb
|
|
|
9
9
|
export function checkParseSchema(a: number, b: number): number;
|
|
10
10
|
export function checkParseEntities(a: number, b: number, c: number, d: number): number;
|
|
11
11
|
export function checkParseContext(a: number, b: number, c: number, d: number, e: number, f: number): number;
|
|
12
|
-
export function getCedarVersion(a: number): void;
|
|
13
12
|
export function isAuthorized(a: number): number;
|
|
14
13
|
export function validate(a: number): number;
|
|
14
|
+
export function getCedarVersion(a: number): void;
|
|
15
15
|
export function __wbindgen_malloc(a: number, b: number): number;
|
|
16
16
|
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
|
|
17
17
|
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
package/web/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedar-policy/cedar-wasm",
|
|
3
|
+
"type": "module",
|
|
3
4
|
"description": "Wasm bindings and typescript types for Cedar lib",
|
|
4
|
-
"version": "3.
|
|
5
|
+
"version": "3.4.1",
|
|
5
6
|
"license": "Apache-2.0",
|
|
6
7
|
"files": [
|
|
7
8
|
"cedar_wasm_bg.wasm",
|
|
8
9
|
"cedar_wasm.js",
|
|
9
10
|
"cedar_wasm.d.ts"
|
|
10
11
|
],
|
|
11
|
-
"
|
|
12
|
+
"main": "cedar_wasm.js",
|
|
12
13
|
"types": "cedar_wasm.d.ts",
|
|
13
14
|
"sideEffects": [
|
|
14
15
|
"./snippets/*"
|
|
15
|
-
]
|
|
16
|
-
"type": "module"
|
|
16
|
+
]
|
|
17
17
|
}
|