@cedar-policy/cedar-wasm 3.2.1 → 3.2.3

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.
@@ -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 formatPolicies(a: number, b: number, c: number, d: number): number;
9
+ export function checkParseSchema(a: number, b: number): number;
10
+ export function checkParseEntities(a: number, b: number, c: number, d: number): number;
11
+ export function checkParseContext(a: number, b: number, c: number, d: number, e: number, f: number): number;
12
+ export function isAuthorized(a: number): number;
13
+ export function validate(a: number): number;
14
+ export function getCedarVersion(a: number): void;
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;
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@cedar-policy/cedar-wasm",
3
+ "description": "Wasm bindings and typescript types for Cedar lib",
4
+ "version": "3.2.3",
5
+ "license": "Apache-2.0",
6
+ "files": [
7
+ "cedar_wasm_bg.wasm",
8
+ "cedar_wasm.js",
9
+ "cedar_wasm_bg.js",
10
+ "cedar_wasm.d.ts"
11
+ ],
12
+ "module": "cedar_wasm.js",
13
+ "types": "cedar_wasm.d.ts",
14
+ "sideEffects": [
15
+ "./cedar_wasm.js",
16
+ "./snippets/*"
17
+ ],
18
+ "type": "module"
19
+ }
package/nodejs/README.md CHANGED
@@ -6,6 +6,33 @@ An implementation of various cedar functions to enable developers to write types
6
6
 
7
7
  Installing is simple, just run `npm i @cedar-policy/cedar-wasm --save` or install with whatever your favorite package manager is.
8
8
 
9
+ Loading is much more complicated. It depends on your environment. We offer three subpackages:
10
+
11
+ * es modules (default). It loads wasm in a way that will be bundled into a single file if you use dynamic imports, or embedded into your main bundle if you use regular imports.
12
+ * commonjs (for node). It loads wasm using node's `fs` module, synchronously. Not really designed for bundling or shipping to the browser.
13
+ * web: more customizable. This one is for when you need to load the wasm in some totally custom way. More details in the "alternate loading strategies" section.
14
+
15
+ These sub-packages are named `@cedar-policy/cedar-wasm`, `@cedar-policy/cedar-wasm/nodejs`, and `@cedar-policy/cedar-wasm/web`, respectively.
16
+
17
+ ## Loading in bare nodeJs without a bundler
18
+
19
+ Node uses CommonJs so you have to import with require, or with dynamic `import()`.
20
+
21
+ Importing the CJS export:
22
+
23
+ ```
24
+ const cedar = require('@cedar-policy/cedar-wasm/nodejs');
25
+ console.log(cedar.getCedarVersion());
26
+ ```
27
+
28
+ Importing the esm version using esm async import:
29
+
30
+ ```
31
+ import('@cedar-policy/cedar-wasm')
32
+ .then(cedar => console.log(cedar.getCedarVersion()));
33
+ ```
34
+
35
+
9
36
  ## Loading in webpack 5:
10
37
 
11
38
  Minimal package.json for webpack including dev server:
@@ -32,7 +59,8 @@ Minimal package.json for webpack including dev server:
32
59
  "typescript": "^5.4.5",
33
60
  "webpack": "^5.91.0",
34
61
  "webpack-cli": "^5.1.4",
35
- "webpack-dev-server": "^5.0.4"
62
+ "webpack-dev-server": "^5.0.4",
63
+ "html-webpack-plugin": "^5.6.0"
36
64
  }
37
65
  }
38
66
  ```
@@ -57,6 +85,7 @@ Configure webpack.config.js:
57
85
 
58
86
  ```
59
87
  const path = require('path');
88
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
60
89
 
61
90
  module.exports = {
62
91
  mode: 'development', // change this to suit you
@@ -79,7 +108,8 @@ module.exports = {
79
108
  },
80
109
  experiments: {
81
110
  asyncWebAssembly: true, // enables wasm support in webpack
82
- },
111
+ },
112
+ plugins: [new HtmlWebpackPlugin()],
83
113
  devServer: {
84
114
  static: {
85
115
  directory: path.join(__dirname, 'dist'),
@@ -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} policies_str
25
+ * @param {number} line_width
26
+ * @param {number} indent_width
27
+ * @returns {FormattingResult}
28
+ */
29
+ export function formatPolicies(policies_str: string, line_width: number, indent_width: number): FormattingResult;
30
+ /**
31
+ * @param {string} input_schema
32
+ * @returns {CheckParseResult}
33
+ */
34
+ export function checkParseSchema(input_schema: string): CheckParseResult;
35
+ /**
36
+ * @param {string} entities_str
37
+ * @param {string} schema_str
38
+ * @returns {CheckParseResult}
39
+ */
40
+ export function checkParseEntities(entities_str: string, schema_str: string): CheckParseResult;
41
+ /**
42
+ * @param {string} context_str
43
+ * @param {string} action_str
44
+ * @param {string} schema_str
45
+ * @returns {CheckParseResult}
46
+ */
47
+ export function checkParseContext(context_str: string, action_str: string, schema_str: string): CheckParseResult;
48
+ /**
49
+ * @param {AuthorizationCall} call
50
+ * @returns {AuthorizationAnswer}
51
+ */
52
+ export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
53
+ /**
54
+ * @param {ValidationCall} call
55
+ * @returns {ValidationAnswer}
56
+ */
57
+ export function validate(call: ValidationCall): ValidationAnswer;
58
+ /**
59
+ * @returns {string}
60
+ */
61
+ export function getCedarVersion(): string;
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 FormattingResult = { type: "success"; formatted_policy: string } | { type: "error"; errors: string[] };
71
+
72
+ export type CheckParseResult = { type: "success" } | { type: "error"; errors: string[] };
73
+
74
+ export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
75
+
76
+ export interface ValidationError {
77
+ policyId: SmolStr;
78
+ error: DetailedError;
79
+ }
80
+
81
+ export type ValidationEnabled = "on" | "off";
82
+
83
+ export interface ValidationSettings {
84
+ enabled: ValidationEnabled;
85
+ }
86
+
87
+ export interface ValidationCall {
88
+ validationSettings?: ValidationSettings;
89
+ schema: Schema;
90
+ policySet: PolicySet;
91
+ }
92
+
93
+ export interface RecvdSlice {
94
+ policies: PolicySet;
95
+ entities: Array<EntityJson>;
96
+ templates?: Record<string, string> | null;
97
+ templateInstantiations: TemplateLink[] | null;
98
+ }
99
+
100
+ export type Links = Link[];
101
+
102
+ export interface TemplateLink {
103
+ templateId: string;
104
+ resultPolicyId: string;
105
+ instantiations: Links;
106
+ }
107
+
108
+ export interface Link {
109
+ slot: string;
110
+ value: EntityUIDStrings;
111
+ }
112
+
113
+ export interface EntityUIDStrings {
114
+ ty: string;
115
+ eid: string;
116
+ }
117
+
118
+ export interface AuthorizationCall {
119
+ principal: {type: string, id: string};
120
+ action: {type: string, id: string};
121
+ resource: {type: string, id: string};
122
+ context: Record<string, CedarValueJson>;
123
+ schema?: Schema;
124
+ enableRequestValidation?: boolean;
125
+ slice: RecvdSlice;
126
+ }
127
+
128
+ export type AuthorizationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; response: Response; warnings: DetailedError[] };
129
+
130
+ export interface AuthorizationError {
131
+ policyId: SmolStr;
132
+ error: DetailedError;
133
+ }
134
+
135
+ export interface Diagnostics {
136
+ reason: Set<String>;
137
+ errors: AuthorizationError[];
138
+ }
139
+
140
+ export interface Response {
141
+ decision: Decision;
142
+ diagnostics: Diagnostics;
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
+ 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 ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
207
+
208
+ export interface PrincipalOrResourceIsConstraint {
209
+ entity_type: string;
210
+ in?: PrincipalOrResourceInConstraint;
211
+ }
212
+
213
+ export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
214
+
215
+ export type EqConstraint = { entity: EntityUidJson } | { slot: string };
216
+
217
+ export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
218
+
219
+ export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
220
+
221
+ export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
222
+
223
+ export interface EntityJson {
224
+ uid: EntityUidJson;
225
+ attrs: Record<string, CedarValueJson>;
226
+ parents: EntityUidJson[];
227
+ }
228
+
229
+ export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
230
+
231
+ export interface Policy {
232
+ effect: Effect;
233
+ principal: PrincipalConstraint;
234
+ action: ActionConstraint;
235
+ resource: ResourceConstraint;
236
+ conditions: Clause[];
237
+ annotations?: Record<string, string>;
238
+ }
239
+
240
+ export type Effect = "permit" | "forbid";
241
+
242
+ export type EntityUidJson = { __expr: string } | { __entity: TypeAndId } | TypeAndId;
243
+
244
+ export interface FnAndArg {
245
+ fn: string;
246
+ arg: CedarValueJson;
247
+ }
248
+
249
+ export interface TypeAndId {
250
+ type: string;
251
+ id: string;
252
+ }
253
+
254
+ export type CedarValueJson = { __expr: string } | { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
255
+
256
+ export type Decision = "Allow" | "Deny";
257
+
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 Var = "principal" | "action" | "resource" | "context";
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,310 @@
1
+ let imports = {};
2
+ imports['__wbindgen_placeholder__'] = module.exports;
3
+ let wasm;
4
+ const { TextEncoder, TextDecoder } = require(`util`);
5
+
6
+ const heap = new Array(128).fill(undefined);
7
+
8
+ heap.push(undefined, null, true, false);
9
+
10
+ function getObject(idx) { return heap[idx]; }
11
+
12
+ let heap_next = heap.length;
13
+
14
+ function addHeapObject(obj) {
15
+ if (heap_next === heap.length) heap.push(heap.length + 1);
16
+ const idx = heap_next;
17
+ heap_next = heap[idx];
18
+
19
+ heap[idx] = obj;
20
+ return idx;
21
+ }
22
+
23
+ function dropObject(idx) {
24
+ if (idx < 132) return;
25
+ heap[idx] = heap_next;
26
+ heap_next = idx;
27
+ }
28
+
29
+ function takeObject(idx) {
30
+ const ret = getObject(idx);
31
+ dropObject(idx);
32
+ return ret;
33
+ }
34
+
35
+ let WASM_VECTOR_LEN = 0;
36
+
37
+ let cachedUint8Memory0 = null;
38
+
39
+ function getUint8Memory0() {
40
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
41
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
42
+ }
43
+ return cachedUint8Memory0;
44
+ }
45
+
46
+ let cachedTextEncoder = new TextEncoder('utf-8');
47
+
48
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
49
+ ? function (arg, view) {
50
+ return cachedTextEncoder.encodeInto(arg, view);
51
+ }
52
+ : function (arg, view) {
53
+ const buf = cachedTextEncoder.encode(arg);
54
+ view.set(buf);
55
+ return {
56
+ read: arg.length,
57
+ written: buf.length
58
+ };
59
+ });
60
+
61
+ function passStringToWasm0(arg, malloc, realloc) {
62
+
63
+ if (realloc === undefined) {
64
+ const buf = cachedTextEncoder.encode(arg);
65
+ const ptr = malloc(buf.length, 1) >>> 0;
66
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
67
+ WASM_VECTOR_LEN = buf.length;
68
+ return ptr;
69
+ }
70
+
71
+ let len = arg.length;
72
+ let ptr = malloc(len, 1) >>> 0;
73
+
74
+ const mem = getUint8Memory0();
75
+
76
+ let offset = 0;
77
+
78
+ for (; offset < len; offset++) {
79
+ const code = arg.charCodeAt(offset);
80
+ if (code > 0x7F) break;
81
+ mem[ptr + offset] = code;
82
+ }
83
+
84
+ if (offset !== len) {
85
+ if (offset !== 0) {
86
+ arg = arg.slice(offset);
87
+ }
88
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
89
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
90
+ const ret = encodeString(arg, view);
91
+
92
+ offset += ret.written;
93
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
94
+ }
95
+
96
+ WASM_VECTOR_LEN = offset;
97
+ return ptr;
98
+ }
99
+
100
+ function isLikeNone(x) {
101
+ return x === undefined || x === null;
102
+ }
103
+
104
+ let cachedInt32Memory0 = null;
105
+
106
+ function getInt32Memory0() {
107
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
108
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
109
+ }
110
+ return cachedInt32Memory0;
111
+ }
112
+
113
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
114
+
115
+ cachedTextDecoder.decode();
116
+
117
+ function getStringFromWasm0(ptr, len) {
118
+ ptr = ptr >>> 0;
119
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
120
+ }
121
+ /**
122
+ * @param {string} json_str
123
+ * @returns {JsonToPolicyResult}
124
+ */
125
+ module.exports.policyTextFromJson = function(json_str) {
126
+ const ptr0 = passStringToWasm0(json_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
127
+ const len0 = WASM_VECTOR_LEN;
128
+ const ret = wasm.policyTextFromJson(ptr0, len0);
129
+ return takeObject(ret);
130
+ };
131
+
132
+ /**
133
+ * @param {string} cedar_str
134
+ * @returns {PolicyToJsonResult}
135
+ */
136
+ module.exports.policyTextToJson = function(cedar_str) {
137
+ const ptr0 = passStringToWasm0(cedar_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
138
+ const len0 = WASM_VECTOR_LEN;
139
+ const ret = wasm.policyTextToJson(ptr0, len0);
140
+ return takeObject(ret);
141
+ };
142
+
143
+ /**
144
+ * @param {string} input_policies_str
145
+ * @returns {CheckParsePolicySetResult}
146
+ */
147
+ module.exports.checkParsePolicySet = function(input_policies_str) {
148
+ const ptr0 = passStringToWasm0(input_policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
149
+ const len0 = WASM_VECTOR_LEN;
150
+ const ret = wasm.checkParsePolicySet(ptr0, len0);
151
+ return takeObject(ret);
152
+ };
153
+
154
+ /**
155
+ * @param {string} template_str
156
+ * @returns {CheckParseTemplateResult}
157
+ */
158
+ module.exports.checkParseTemplate = function(template_str) {
159
+ const ptr0 = passStringToWasm0(template_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
160
+ const len0 = WASM_VECTOR_LEN;
161
+ const ret = wasm.checkParseTemplate(ptr0, len0);
162
+ return takeObject(ret);
163
+ };
164
+
165
+ /**
166
+ * @param {string} policies_str
167
+ * @param {number} line_width
168
+ * @param {number} indent_width
169
+ * @returns {FormattingResult}
170
+ */
171
+ module.exports.formatPolicies = function(policies_str, line_width, indent_width) {
172
+ const ptr0 = passStringToWasm0(policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
173
+ const len0 = WASM_VECTOR_LEN;
174
+ const ret = wasm.formatPolicies(ptr0, len0, line_width, indent_width);
175
+ return takeObject(ret);
176
+ };
177
+
178
+ /**
179
+ * @param {string} input_schema
180
+ * @returns {CheckParseResult}
181
+ */
182
+ module.exports.checkParseSchema = function(input_schema) {
183
+ const ptr0 = passStringToWasm0(input_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
184
+ const len0 = WASM_VECTOR_LEN;
185
+ const ret = wasm.checkParseSchema(ptr0, len0);
186
+ return takeObject(ret);
187
+ };
188
+
189
+ /**
190
+ * @param {string} entities_str
191
+ * @param {string} schema_str
192
+ * @returns {CheckParseResult}
193
+ */
194
+ module.exports.checkParseEntities = function(entities_str, schema_str) {
195
+ const ptr0 = passStringToWasm0(entities_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
196
+ const len0 = WASM_VECTOR_LEN;
197
+ const ptr1 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
198
+ const len1 = WASM_VECTOR_LEN;
199
+ const ret = wasm.checkParseEntities(ptr0, len0, ptr1, len1);
200
+ return takeObject(ret);
201
+ };
202
+
203
+ /**
204
+ * @param {string} context_str
205
+ * @param {string} action_str
206
+ * @param {string} schema_str
207
+ * @returns {CheckParseResult}
208
+ */
209
+ module.exports.checkParseContext = function(context_str, action_str, schema_str) {
210
+ const ptr0 = passStringToWasm0(context_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
211
+ const len0 = WASM_VECTOR_LEN;
212
+ const ptr1 = passStringToWasm0(action_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
213
+ const len1 = WASM_VECTOR_LEN;
214
+ const ptr2 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
215
+ const len2 = WASM_VECTOR_LEN;
216
+ const ret = wasm.checkParseContext(ptr0, len0, ptr1, len1, ptr2, len2);
217
+ return takeObject(ret);
218
+ };
219
+
220
+ /**
221
+ * @param {AuthorizationCall} call
222
+ * @returns {AuthorizationAnswer}
223
+ */
224
+ module.exports.isAuthorized = function(call) {
225
+ const ret = wasm.isAuthorized(addHeapObject(call));
226
+ return takeObject(ret);
227
+ };
228
+
229
+ /**
230
+ * @param {ValidationCall} call
231
+ * @returns {ValidationAnswer}
232
+ */
233
+ module.exports.validate = function(call) {
234
+ const ret = wasm.validate(addHeapObject(call));
235
+ return takeObject(ret);
236
+ };
237
+
238
+ /**
239
+ * @returns {string}
240
+ */
241
+ module.exports.getCedarVersion = function() {
242
+ let deferred1_0;
243
+ let deferred1_1;
244
+ try {
245
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
246
+ wasm.getCedarVersion(retptr);
247
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
248
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
249
+ deferred1_0 = r0;
250
+ deferred1_1 = r1;
251
+ return getStringFromWasm0(r0, r1);
252
+ } finally {
253
+ wasm.__wbindgen_add_to_stack_pointer(16);
254
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
255
+ }
256
+ };
257
+
258
+ function handleError(f, args) {
259
+ try {
260
+ return f.apply(this, args);
261
+ } catch (e) {
262
+ wasm.__wbindgen_exn_store(addHeapObject(e));
263
+ }
264
+ }
265
+
266
+ module.exports.__wbindgen_is_undefined = function(arg0) {
267
+ const ret = getObject(arg0) === undefined;
268
+ return ret;
269
+ };
270
+
271
+ module.exports.__wbindgen_object_clone_ref = function(arg0) {
272
+ const ret = getObject(arg0);
273
+ return addHeapObject(ret);
274
+ };
275
+
276
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
277
+ takeObject(arg0);
278
+ };
279
+
280
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
281
+ const obj = getObject(arg1);
282
+ const ret = typeof(obj) === 'string' ? obj : undefined;
283
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
284
+ var len1 = WASM_VECTOR_LEN;
285
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
286
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
287
+ };
288
+
289
+ module.exports.__wbg_parse_66d1801634e099ac = function() { return handleError(function (arg0, arg1) {
290
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
291
+ return addHeapObject(ret);
292
+ }, arguments) };
293
+
294
+ module.exports.__wbg_stringify_8887fe74e1c50d81 = function() { return handleError(function (arg0) {
295
+ const ret = JSON.stringify(getObject(arg0));
296
+ return addHeapObject(ret);
297
+ }, arguments) };
298
+
299
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
300
+ throw new Error(getStringFromWasm0(arg0, arg1));
301
+ };
302
+
303
+ const path = require('path').join(__dirname, 'cedar_wasm_bg.wasm');
304
+ const bytes = require('fs').readFileSync(path);
305
+
306
+ const wasmModule = new WebAssembly.Module(bytes);
307
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
308
+ wasm = wasmInstance.exports;
309
+ module.exports.__wasm = wasm;
310
+
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 formatPolicies(a: number, b: number, c: number, d: number): number;
9
+ export function checkParseSchema(a: number, b: number): number;
10
+ export function checkParseEntities(a: number, b: number, c: number, d: number): number;
11
+ export function checkParseContext(a: number, b: number, c: number, d: number, e: number, f: number): number;
12
+ export function isAuthorized(a: number): number;
13
+ export function validate(a: number): number;
14
+ export function getCedarVersion(a: number): void;
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;