@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.
package/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'),
package/esm/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,4 @@
1
+ import * as wasm from "./cedar_wasm_bg.wasm";
2
+ import { __wbg_set_wasm } from "./cedar_wasm_bg.js";
3
+ __wbg_set_wasm(wasm);
4
+ export * from "./cedar_wasm_bg.js";
@@ -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} policies_str
172
+ * @param {number} line_width
173
+ * @param {number} indent_width
174
+ * @returns {FormattingResult}
175
+ */
176
+ export function formatPolicies(policies_str, line_width, indent_width) {
177
+ const ptr0 = passStringToWasm0(policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
178
+ const len0 = WASM_VECTOR_LEN;
179
+ const ret = wasm.formatPolicies(ptr0, len0, line_width, indent_width);
180
+ return takeObject(ret);
181
+ }
182
+
183
+ /**
184
+ * @param {string} input_schema
185
+ * @returns {CheckParseResult}
186
+ */
187
+ export function checkParseSchema(input_schema) {
188
+ const ptr0 = passStringToWasm0(input_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
189
+ const len0 = WASM_VECTOR_LEN;
190
+ const ret = wasm.checkParseSchema(ptr0, len0);
191
+ return takeObject(ret);
192
+ }
193
+
194
+ /**
195
+ * @param {string} entities_str
196
+ * @param {string} schema_str
197
+ * @returns {CheckParseResult}
198
+ */
199
+ export function checkParseEntities(entities_str, schema_str) {
200
+ const ptr0 = passStringToWasm0(entities_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
201
+ const len0 = WASM_VECTOR_LEN;
202
+ const ptr1 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
203
+ const len1 = WASM_VECTOR_LEN;
204
+ const ret = wasm.checkParseEntities(ptr0, len0, ptr1, len1);
205
+ return takeObject(ret);
206
+ }
207
+
208
+ /**
209
+ * @param {string} context_str
210
+ * @param {string} action_str
211
+ * @param {string} schema_str
212
+ * @returns {CheckParseResult}
213
+ */
214
+ export function checkParseContext(context_str, action_str, schema_str) {
215
+ const ptr0 = passStringToWasm0(context_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
216
+ const len0 = WASM_VECTOR_LEN;
217
+ const ptr1 = passStringToWasm0(action_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
218
+ const len1 = WASM_VECTOR_LEN;
219
+ const ptr2 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
+ const len2 = WASM_VECTOR_LEN;
221
+ const ret = wasm.checkParseContext(ptr0, len0, ptr1, len1, ptr2, len2);
222
+ return takeObject(ret);
223
+ }
224
+
225
+ /**
226
+ * @param {AuthorizationCall} call
227
+ * @returns {AuthorizationAnswer}
228
+ */
229
+ export function isAuthorized(call) {
230
+ const ret = wasm.isAuthorized(addHeapObject(call));
231
+ return takeObject(ret);
232
+ }
233
+
234
+ /**
235
+ * @param {ValidationCall} call
236
+ * @returns {ValidationAnswer}
237
+ */
238
+ export function validate(call) {
239
+ const ret = wasm.validate(addHeapObject(call));
240
+ return takeObject(ret);
241
+ }
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 = getInt32Memory0()[retptr / 4 + 0];
253
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
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
+ 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