@cedar-policy/cedar-wasm 3.2.1 → 3.2.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.
- package/esm/cedar_wasm.d.ts +270 -0
- package/esm/cedar_wasm.js +4 -0
- package/esm/cedar_wasm_bg.js +307 -0
- package/esm/cedar_wasm_bg.wasm +0 -0
- package/esm/cedar_wasm_bg.wasm.d.ts +19 -0
- package/esm/package.json +20 -0
- package/nodejs/cedar_wasm.d.ts +270 -0
- package/nodejs/cedar_wasm.js +310 -0
- package/nodejs/cedar_wasm_bg.wasm +0 -0
- package/nodejs/cedar_wasm_bg.wasm.d.ts +19 -0
- package/nodejs/package.json +15 -0
- package/package.json +21 -5
- package/web/cedar_wasm.d.ts +313 -0
- package/web/cedar_wasm.js +381 -0
- package/web/cedar_wasm_bg.wasm +0 -0
- package/web/cedar_wasm_bg.wasm.d.ts +19 -0
- package/web/package.json +18 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} json_str
|
|
5
|
+
* @returns {JsonToPolicyResult}
|
|
6
|
+
*/
|
|
7
|
+
export function policyTextFromJson(json_str: string): JsonToPolicyResult;
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} cedar_str
|
|
10
|
+
* @returns {PolicyToJsonResult}
|
|
11
|
+
*/
|
|
12
|
+
export function policyTextToJson(cedar_str: string): PolicyToJsonResult;
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} input_policies_str
|
|
15
|
+
* @returns {CheckParsePolicySetResult}
|
|
16
|
+
*/
|
|
17
|
+
export function checkParsePolicySet(input_policies_str: string): CheckParsePolicySetResult;
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} template_str
|
|
20
|
+
* @returns {CheckParseTemplateResult}
|
|
21
|
+
*/
|
|
22
|
+
export function checkParseTemplate(template_str: string): CheckParseTemplateResult;
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} input_schema
|
|
25
|
+
* @returns {CheckParseResult}
|
|
26
|
+
*/
|
|
27
|
+
export function checkParseSchema(input_schema: string): CheckParseResult;
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} entities_str
|
|
30
|
+
* @param {string} schema_str
|
|
31
|
+
* @returns {CheckParseResult}
|
|
32
|
+
*/
|
|
33
|
+
export function checkParseEntities(entities_str: string, schema_str: string): CheckParseResult;
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} context_str
|
|
36
|
+
* @param {string} action_str
|
|
37
|
+
* @param {string} schema_str
|
|
38
|
+
* @returns {CheckParseResult}
|
|
39
|
+
*/
|
|
40
|
+
export function checkParseContext(context_str: string, action_str: string, schema_str: string): CheckParseResult;
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} policies_str
|
|
43
|
+
* @param {number} line_width
|
|
44
|
+
* @param {number} indent_width
|
|
45
|
+
* @returns {FormattingResult}
|
|
46
|
+
*/
|
|
47
|
+
export function formatPolicies(policies_str: string, line_width: number, indent_width: number): FormattingResult;
|
|
48
|
+
/**
|
|
49
|
+
* @returns {string}
|
|
50
|
+
*/
|
|
51
|
+
export function getCedarVersion(): string;
|
|
52
|
+
/**
|
|
53
|
+
* @param {AuthorizationCall} call
|
|
54
|
+
* @returns {AuthorizationAnswer}
|
|
55
|
+
*/
|
|
56
|
+
export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
57
|
+
/**
|
|
58
|
+
* @param {ValidationCall} call
|
|
59
|
+
* @returns {ValidationAnswer}
|
|
60
|
+
*/
|
|
61
|
+
export function validate(call: ValidationCall): ValidationAnswer;
|
|
62
|
+
export type JsonToPolicyResult = { type: "success"; policyText: string } | { type: "error"; errors: string[] };
|
|
63
|
+
|
|
64
|
+
export type PolicyToJsonResult = { type: "success"; policy: Policy } | { type: "error"; errors: string[] };
|
|
65
|
+
|
|
66
|
+
export type CheckParsePolicySetResult = { type: "success"; policies: number; templates: number } | { type: "error"; errors: string[] };
|
|
67
|
+
|
|
68
|
+
export type CheckParseTemplateResult = { type: "success"; slots: string[] } | { type: "error"; errors: string[] };
|
|
69
|
+
|
|
70
|
+
export type CheckParseResult = { type: "success" } | { type: "error"; errors: string[] };
|
|
71
|
+
|
|
72
|
+
export type FormattingResult = { type: "success"; formatted_policy: string } | { type: "error"; errors: string[] };
|
|
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
|
+
export interface RecvdSlice {
|
|
119
|
+
policies: PolicySet;
|
|
120
|
+
entities: Array<EntityJson>;
|
|
121
|
+
templates?: Record<string, string> | null;
|
|
122
|
+
templateInstantiations: TemplateLink[] | null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type Links = Link[];
|
|
126
|
+
|
|
127
|
+
export interface TemplateLink {
|
|
128
|
+
templateId: string;
|
|
129
|
+
resultPolicyId: string;
|
|
130
|
+
instantiations: Links;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface Link {
|
|
134
|
+
slot: string;
|
|
135
|
+
value: EntityUIDStrings;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface EntityUIDStrings {
|
|
139
|
+
ty: string;
|
|
140
|
+
eid: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface AuthorizationCall {
|
|
144
|
+
principal: {type: string, id: string};
|
|
145
|
+
action: {type: string, id: string};
|
|
146
|
+
resource: {type: string, id: string};
|
|
147
|
+
context: Record<string, CedarValueJson>;
|
|
148
|
+
schema?: Schema;
|
|
149
|
+
enableRequestValidation?: boolean;
|
|
150
|
+
slice: RecvdSlice;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type AuthorizationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; response: Response; warnings: DetailedError[] };
|
|
154
|
+
|
|
155
|
+
export interface AuthorizationError {
|
|
156
|
+
policyId: SmolStr;
|
|
157
|
+
error: DetailedError;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface Diagnostics {
|
|
161
|
+
reason: Set<String>;
|
|
162
|
+
errors: AuthorizationError[];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface Response {
|
|
166
|
+
decision: Decision;
|
|
167
|
+
diagnostics: Diagnostics;
|
|
168
|
+
}
|
|
169
|
+
|
|
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
|
+
|
|
172
|
+
export type SchemaType = SchemaTypeVariant | { type: Name };
|
|
173
|
+
|
|
174
|
+
export interface ActionEntityUID {
|
|
175
|
+
id: SmolStr;
|
|
176
|
+
type?: Name;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface ApplySpec {
|
|
180
|
+
resourceTypes?: Name[];
|
|
181
|
+
principalTypes?: Name[];
|
|
182
|
+
context?: AttributesOrContext;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface ActionType {
|
|
186
|
+
attributes?: Record<SmolStr, CedarValueJson>;
|
|
187
|
+
appliesTo?: ApplySpec;
|
|
188
|
+
memberOf?: ActionEntityUID[];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export type AttributesOrContext = SchemaType;
|
|
192
|
+
|
|
193
|
+
export interface EntityType {
|
|
194
|
+
memberOfTypes?: Name[];
|
|
195
|
+
shape?: AttributesOrContext;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface NamespaceDefinition {
|
|
199
|
+
commonTypes?: Record<Id, SchemaType>;
|
|
200
|
+
entityTypes: Record<Id, EntityType>;
|
|
201
|
+
actions: Record<SmolStr, ActionType>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export type SchemaJson = Record<string, NamespaceDefinition>;
|
|
205
|
+
|
|
206
|
+
export type EntityUidJson = { __expr: string } | { __entity: TypeAndId } | TypeAndId;
|
|
207
|
+
|
|
208
|
+
export interface FnAndArg {
|
|
209
|
+
fn: string;
|
|
210
|
+
arg: CedarValueJson;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface TypeAndId {
|
|
214
|
+
type: string;
|
|
215
|
+
id: string;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export type CedarValueJson = { __expr: string } | { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
219
|
+
|
|
220
|
+
export type Var = "principal" | "action" | "resource" | "context";
|
|
221
|
+
|
|
222
|
+
export type Effect = "permit" | "forbid";
|
|
223
|
+
|
|
224
|
+
export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
|
|
225
|
+
|
|
226
|
+
export interface Policy {
|
|
227
|
+
effect: Effect;
|
|
228
|
+
principal: PrincipalConstraint;
|
|
229
|
+
action: ActionConstraint;
|
|
230
|
+
resource: ResourceConstraint;
|
|
231
|
+
conditions: Clause[];
|
|
232
|
+
annotations?: Record<string, string>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface EntityJson {
|
|
236
|
+
uid: EntityUidJson;
|
|
237
|
+
attrs: Record<string, CedarValueJson>;
|
|
238
|
+
parents: EntityUidJson[];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export type Decision = "Allow" | "Deny";
|
|
242
|
+
|
|
243
|
+
export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
|
|
244
|
+
|
|
245
|
+
export interface PrincipalOrResourceIsConstraint {
|
|
246
|
+
entity_type: string;
|
|
247
|
+
in?: PrincipalOrResourceInConstraint;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
|
|
251
|
+
|
|
252
|
+
export type EqConstraint = { entity: EntityUidJson } | { slot: string };
|
|
253
|
+
|
|
254
|
+
export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
255
|
+
|
|
256
|
+
export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
|
|
257
|
+
|
|
258
|
+
export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
259
|
+
|
|
260
|
+
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
261
|
+
|
|
262
|
+
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> };
|
|
263
|
+
|
|
264
|
+
export type Expr = ExprNoExt | ExtFuncCall;
|
|
265
|
+
|
|
266
|
+
type SmolStr = string;
|
|
267
|
+
type Name = string;
|
|
268
|
+
type Id = string;
|
|
269
|
+
export type TypeOfAttribute = SchemaType & { required?: boolean };
|
|
270
|
+
export type Context = Record<string, CedarValueJson>;
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
export function __wbg_set_wasm(val) {
|
|
3
|
+
wasm = val;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const heap = new Array(128).fill(undefined);
|
|
8
|
+
|
|
9
|
+
heap.push(undefined, null, true, false);
|
|
10
|
+
|
|
11
|
+
function getObject(idx) { return heap[idx]; }
|
|
12
|
+
|
|
13
|
+
let heap_next = heap.length;
|
|
14
|
+
|
|
15
|
+
function addHeapObject(obj) {
|
|
16
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
17
|
+
const idx = heap_next;
|
|
18
|
+
heap_next = heap[idx];
|
|
19
|
+
|
|
20
|
+
heap[idx] = obj;
|
|
21
|
+
return idx;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function dropObject(idx) {
|
|
25
|
+
if (idx < 132) return;
|
|
26
|
+
heap[idx] = heap_next;
|
|
27
|
+
heap_next = idx;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function takeObject(idx) {
|
|
31
|
+
const ret = getObject(idx);
|
|
32
|
+
dropObject(idx);
|
|
33
|
+
return ret;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let WASM_VECTOR_LEN = 0;
|
|
37
|
+
|
|
38
|
+
let cachedUint8Memory0 = null;
|
|
39
|
+
|
|
40
|
+
function getUint8Memory0() {
|
|
41
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
42
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
43
|
+
}
|
|
44
|
+
return cachedUint8Memory0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
48
|
+
|
|
49
|
+
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
50
|
+
|
|
51
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
52
|
+
? function (arg, view) {
|
|
53
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
54
|
+
}
|
|
55
|
+
: function (arg, view) {
|
|
56
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
57
|
+
view.set(buf);
|
|
58
|
+
return {
|
|
59
|
+
read: arg.length,
|
|
60
|
+
written: buf.length
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
65
|
+
|
|
66
|
+
if (realloc === undefined) {
|
|
67
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
68
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
69
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
70
|
+
WASM_VECTOR_LEN = buf.length;
|
|
71
|
+
return ptr;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let len = arg.length;
|
|
75
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
76
|
+
|
|
77
|
+
const mem = getUint8Memory0();
|
|
78
|
+
|
|
79
|
+
let offset = 0;
|
|
80
|
+
|
|
81
|
+
for (; offset < len; offset++) {
|
|
82
|
+
const code = arg.charCodeAt(offset);
|
|
83
|
+
if (code > 0x7F) break;
|
|
84
|
+
mem[ptr + offset] = code;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (offset !== len) {
|
|
88
|
+
if (offset !== 0) {
|
|
89
|
+
arg = arg.slice(offset);
|
|
90
|
+
}
|
|
91
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
92
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
93
|
+
const ret = encodeString(arg, view);
|
|
94
|
+
|
|
95
|
+
offset += ret.written;
|
|
96
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
WASM_VECTOR_LEN = offset;
|
|
100
|
+
return ptr;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function isLikeNone(x) {
|
|
104
|
+
return x === undefined || x === null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let cachedInt32Memory0 = null;
|
|
108
|
+
|
|
109
|
+
function getInt32Memory0() {
|
|
110
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
111
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
112
|
+
}
|
|
113
|
+
return cachedInt32Memory0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
117
|
+
|
|
118
|
+
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
119
|
+
|
|
120
|
+
cachedTextDecoder.decode();
|
|
121
|
+
|
|
122
|
+
function getStringFromWasm0(ptr, len) {
|
|
123
|
+
ptr = ptr >>> 0;
|
|
124
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @param {string} json_str
|
|
128
|
+
* @returns {JsonToPolicyResult}
|
|
129
|
+
*/
|
|
130
|
+
export function policyTextFromJson(json_str) {
|
|
131
|
+
const ptr0 = passStringToWasm0(json_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
132
|
+
const len0 = WASM_VECTOR_LEN;
|
|
133
|
+
const ret = wasm.policyTextFromJson(ptr0, len0);
|
|
134
|
+
return takeObject(ret);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @param {string} cedar_str
|
|
139
|
+
* @returns {PolicyToJsonResult}
|
|
140
|
+
*/
|
|
141
|
+
export function policyTextToJson(cedar_str) {
|
|
142
|
+
const ptr0 = passStringToWasm0(cedar_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
143
|
+
const len0 = WASM_VECTOR_LEN;
|
|
144
|
+
const ret = wasm.policyTextToJson(ptr0, len0);
|
|
145
|
+
return takeObject(ret);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @param {string} input_policies_str
|
|
150
|
+
* @returns {CheckParsePolicySetResult}
|
|
151
|
+
*/
|
|
152
|
+
export function checkParsePolicySet(input_policies_str) {
|
|
153
|
+
const ptr0 = passStringToWasm0(input_policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
154
|
+
const len0 = WASM_VECTOR_LEN;
|
|
155
|
+
const ret = wasm.checkParsePolicySet(ptr0, len0);
|
|
156
|
+
return takeObject(ret);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @param {string} template_str
|
|
161
|
+
* @returns {CheckParseTemplateResult}
|
|
162
|
+
*/
|
|
163
|
+
export function checkParseTemplate(template_str) {
|
|
164
|
+
const ptr0 = passStringToWasm0(template_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
165
|
+
const len0 = WASM_VECTOR_LEN;
|
|
166
|
+
const ret = wasm.checkParseTemplate(ptr0, len0);
|
|
167
|
+
return takeObject(ret);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @param {string} input_schema
|
|
172
|
+
* @returns {CheckParseResult}
|
|
173
|
+
*/
|
|
174
|
+
export function checkParseSchema(input_schema) {
|
|
175
|
+
const ptr0 = passStringToWasm0(input_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
176
|
+
const len0 = WASM_VECTOR_LEN;
|
|
177
|
+
const ret = wasm.checkParseSchema(ptr0, len0);
|
|
178
|
+
return takeObject(ret);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @param {string} entities_str
|
|
183
|
+
* @param {string} schema_str
|
|
184
|
+
* @returns {CheckParseResult}
|
|
185
|
+
*/
|
|
186
|
+
export function checkParseEntities(entities_str, schema_str) {
|
|
187
|
+
const ptr0 = passStringToWasm0(entities_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
188
|
+
const len0 = WASM_VECTOR_LEN;
|
|
189
|
+
const ptr1 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
190
|
+
const len1 = WASM_VECTOR_LEN;
|
|
191
|
+
const ret = wasm.checkParseEntities(ptr0, len0, ptr1, len1);
|
|
192
|
+
return takeObject(ret);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @param {string} context_str
|
|
197
|
+
* @param {string} action_str
|
|
198
|
+
* @param {string} schema_str
|
|
199
|
+
* @returns {CheckParseResult}
|
|
200
|
+
*/
|
|
201
|
+
export function checkParseContext(context_str, action_str, schema_str) {
|
|
202
|
+
const ptr0 = passStringToWasm0(context_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
203
|
+
const len0 = WASM_VECTOR_LEN;
|
|
204
|
+
const ptr1 = passStringToWasm0(action_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
205
|
+
const len1 = WASM_VECTOR_LEN;
|
|
206
|
+
const ptr2 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
207
|
+
const len2 = WASM_VECTOR_LEN;
|
|
208
|
+
const ret = wasm.checkParseContext(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
209
|
+
return takeObject(ret);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @param {string} policies_str
|
|
214
|
+
* @param {number} line_width
|
|
215
|
+
* @param {number} indent_width
|
|
216
|
+
* @returns {FormattingResult}
|
|
217
|
+
*/
|
|
218
|
+
export function formatPolicies(policies_str, line_width, indent_width) {
|
|
219
|
+
const ptr0 = passStringToWasm0(policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
220
|
+
const len0 = WASM_VECTOR_LEN;
|
|
221
|
+
const ret = wasm.formatPolicies(ptr0, len0, line_width, indent_width);
|
|
222
|
+
return takeObject(ret);
|
|
223
|
+
}
|
|
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
|
+
/**
|
|
246
|
+
* @param {AuthorizationCall} call
|
|
247
|
+
* @returns {AuthorizationAnswer}
|
|
248
|
+
*/
|
|
249
|
+
export function isAuthorized(call) {
|
|
250
|
+
const ret = wasm.isAuthorized(addHeapObject(call));
|
|
251
|
+
return takeObject(ret);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @param {ValidationCall} call
|
|
256
|
+
* @returns {ValidationAnswer}
|
|
257
|
+
*/
|
|
258
|
+
export function validate(call) {
|
|
259
|
+
const ret = wasm.validate(addHeapObject(call));
|
|
260
|
+
return takeObject(ret);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function handleError(f, args) {
|
|
264
|
+
try {
|
|
265
|
+
return f.apply(this, args);
|
|
266
|
+
} catch (e) {
|
|
267
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function __wbindgen_is_undefined(arg0) {
|
|
272
|
+
const ret = getObject(arg0) === undefined;
|
|
273
|
+
return ret;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export function __wbindgen_object_clone_ref(arg0) {
|
|
277
|
+
const ret = getObject(arg0);
|
|
278
|
+
return addHeapObject(ret);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export function __wbindgen_object_drop_ref(arg0) {
|
|
282
|
+
takeObject(arg0);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export function __wbindgen_string_get(arg0, arg1) {
|
|
286
|
+
const obj = getObject(arg1);
|
|
287
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
288
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
289
|
+
var len1 = WASM_VECTOR_LEN;
|
|
290
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
291
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export function __wbg_parse_66d1801634e099ac() { return handleError(function (arg0, arg1) {
|
|
295
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
296
|
+
return addHeapObject(ret);
|
|
297
|
+
}, arguments) };
|
|
298
|
+
|
|
299
|
+
export function __wbg_stringify_8887fe74e1c50d81() { return handleError(function (arg0) {
|
|
300
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
301
|
+
return addHeapObject(ret);
|
|
302
|
+
}, arguments) };
|
|
303
|
+
|
|
304
|
+
export function __wbindgen_throw(arg0, arg1) {
|
|
305
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
306
|
+
};
|
|
307
|
+
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function policyTextFromJson(a: number, b: number): number;
|
|
5
|
+
export function policyTextToJson(a: number, b: number): number;
|
|
6
|
+
export function checkParsePolicySet(a: number, b: number): number;
|
|
7
|
+
export function checkParseTemplate(a: number, b: number): number;
|
|
8
|
+
export function checkParseSchema(a: number, b: number): number;
|
|
9
|
+
export function checkParseEntities(a: number, b: number, c: number, d: number): number;
|
|
10
|
+
export function checkParseContext(a: number, b: number, c: number, d: number, e: number, f: number): number;
|
|
11
|
+
export function formatPolicies(a: number, b: number, c: number, d: number): number;
|
|
12
|
+
export function getCedarVersion(a: number): void;
|
|
13
|
+
export function isAuthorized(a: number): number;
|
|
14
|
+
export function validate(a: number): number;
|
|
15
|
+
export function __wbindgen_malloc(a: number, b: number): number;
|
|
16
|
+
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
|
|
17
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
18
|
+
export function __wbindgen_free(a: number, b: number, c: number): void;
|
|
19
|
+
export function __wbindgen_exn_store(a: number): void;
|
package/esm/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cedar-policy/cedar-wasm",
|
|
3
|
+
"description": "Wasm bindings and typescript types for Cedar lib",
|
|
4
|
+
"version": "3.2.2",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"files": [
|
|
7
|
+
"cedar_wasm_bg.wasm",
|
|
8
|
+
"cedar_wasm_bg.wasm.d.ts",
|
|
9
|
+
"cedar_wasm.js",
|
|
10
|
+
"cedar_wasm_bg.js",
|
|
11
|
+
"cedar_wasm.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"module": "cedar_wasm.js",
|
|
14
|
+
"types": "cedar_wasm.d.ts",
|
|
15
|
+
"sideEffects": [
|
|
16
|
+
"./cedar_wasm.js",
|
|
17
|
+
"./snippets/*"
|
|
18
|
+
],
|
|
19
|
+
"type": "module"
|
|
20
|
+
}
|