@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.
@@ -0,0 +1,313 @@
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
+
267
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
268
+
269
+ export interface InitOutput {
270
+ readonly memory: WebAssembly.Memory;
271
+ readonly policyTextFromJson: (a: number, b: number) => number;
272
+ readonly policyTextToJson: (a: number, b: number) => number;
273
+ readonly checkParsePolicySet: (a: number, b: number) => number;
274
+ readonly checkParseTemplate: (a: number, b: number) => number;
275
+ readonly checkParseSchema: (a: number, b: number) => number;
276
+ readonly checkParseEntities: (a: number, b: number, c: number, d: number) => number;
277
+ readonly checkParseContext: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
278
+ readonly formatPolicies: (a: number, b: number, c: number, d: number) => number;
279
+ readonly getCedarVersion: (a: number) => void;
280
+ readonly isAuthorized: (a: number) => number;
281
+ readonly validate: (a: number) => number;
282
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
283
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
284
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
285
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
286
+ readonly __wbindgen_exn_store: (a: number) => void;
287
+ }
288
+
289
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
290
+ /**
291
+ * Instantiates the given `module`, which can either be bytes or
292
+ * a precompiled `WebAssembly.Module`.
293
+ *
294
+ * @param {SyncInitInput} module
295
+ *
296
+ * @returns {InitOutput}
297
+ */
298
+ export function initSync(module: SyncInitInput): InitOutput;
299
+
300
+ /**
301
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
302
+ * for everything else, calls `WebAssembly.instantiate` directly.
303
+ *
304
+ * @param {InitInput | Promise<InitInput>} module_or_path
305
+ *
306
+ * @returns {Promise<InitOutput>}
307
+ */
308
+ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
309
+ type SmolStr = string;
310
+ type Name = string;
311
+ type Id = string;
312
+ export type TypeOfAttribute = SchemaType & { required?: boolean };
313
+ export type Context = Record<string, CedarValueJson>;
@@ -0,0 +1,381 @@
1
+ let wasm;
2
+
3
+ const heap = new Array(128).fill(undefined);
4
+
5
+ heap.push(undefined, null, true, false);
6
+
7
+ function getObject(idx) { return heap[idx]; }
8
+
9
+ let heap_next = heap.length;
10
+
11
+ function addHeapObject(obj) {
12
+ if (heap_next === heap.length) heap.push(heap.length + 1);
13
+ const idx = heap_next;
14
+ heap_next = heap[idx];
15
+
16
+ heap[idx] = obj;
17
+ return idx;
18
+ }
19
+
20
+ function dropObject(idx) {
21
+ if (idx < 132) return;
22
+ heap[idx] = heap_next;
23
+ heap_next = idx;
24
+ }
25
+
26
+ function takeObject(idx) {
27
+ const ret = getObject(idx);
28
+ dropObject(idx);
29
+ return ret;
30
+ }
31
+
32
+ let WASM_VECTOR_LEN = 0;
33
+
34
+ let cachedUint8Memory0 = null;
35
+
36
+ function getUint8Memory0() {
37
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
38
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
39
+ }
40
+ return cachedUint8Memory0;
41
+ }
42
+
43
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
44
+
45
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
46
+ ? function (arg, view) {
47
+ return cachedTextEncoder.encodeInto(arg, view);
48
+ }
49
+ : function (arg, view) {
50
+ const buf = cachedTextEncoder.encode(arg);
51
+ view.set(buf);
52
+ return {
53
+ read: arg.length,
54
+ written: buf.length
55
+ };
56
+ });
57
+
58
+ function passStringToWasm0(arg, malloc, realloc) {
59
+
60
+ if (realloc === undefined) {
61
+ const buf = cachedTextEncoder.encode(arg);
62
+ const ptr = malloc(buf.length, 1) >>> 0;
63
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
64
+ WASM_VECTOR_LEN = buf.length;
65
+ return ptr;
66
+ }
67
+
68
+ let len = arg.length;
69
+ let ptr = malloc(len, 1) >>> 0;
70
+
71
+ const mem = getUint8Memory0();
72
+
73
+ let offset = 0;
74
+
75
+ for (; offset < len; offset++) {
76
+ const code = arg.charCodeAt(offset);
77
+ if (code > 0x7F) break;
78
+ mem[ptr + offset] = code;
79
+ }
80
+
81
+ if (offset !== len) {
82
+ if (offset !== 0) {
83
+ arg = arg.slice(offset);
84
+ }
85
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
86
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
87
+ const ret = encodeString(arg, view);
88
+
89
+ offset += ret.written;
90
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
91
+ }
92
+
93
+ WASM_VECTOR_LEN = offset;
94
+ return ptr;
95
+ }
96
+
97
+ function isLikeNone(x) {
98
+ return x === undefined || x === null;
99
+ }
100
+
101
+ let cachedInt32Memory0 = null;
102
+
103
+ function getInt32Memory0() {
104
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
105
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
106
+ }
107
+ return cachedInt32Memory0;
108
+ }
109
+
110
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
111
+
112
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
113
+
114
+ function getStringFromWasm0(ptr, len) {
115
+ ptr = ptr >>> 0;
116
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
117
+ }
118
+ /**
119
+ * @param {string} json_str
120
+ * @returns {JsonToPolicyResult}
121
+ */
122
+ export function policyTextFromJson(json_str) {
123
+ const ptr0 = passStringToWasm0(json_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
124
+ const len0 = WASM_VECTOR_LEN;
125
+ const ret = wasm.policyTextFromJson(ptr0, len0);
126
+ return takeObject(ret);
127
+ }
128
+
129
+ /**
130
+ * @param {string} cedar_str
131
+ * @returns {PolicyToJsonResult}
132
+ */
133
+ export function policyTextToJson(cedar_str) {
134
+ const ptr0 = passStringToWasm0(cedar_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
135
+ const len0 = WASM_VECTOR_LEN;
136
+ const ret = wasm.policyTextToJson(ptr0, len0);
137
+ return takeObject(ret);
138
+ }
139
+
140
+ /**
141
+ * @param {string} input_policies_str
142
+ * @returns {CheckParsePolicySetResult}
143
+ */
144
+ export function checkParsePolicySet(input_policies_str) {
145
+ const ptr0 = passStringToWasm0(input_policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
146
+ const len0 = WASM_VECTOR_LEN;
147
+ const ret = wasm.checkParsePolicySet(ptr0, len0);
148
+ return takeObject(ret);
149
+ }
150
+
151
+ /**
152
+ * @param {string} template_str
153
+ * @returns {CheckParseTemplateResult}
154
+ */
155
+ export function checkParseTemplate(template_str) {
156
+ const ptr0 = passStringToWasm0(template_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
157
+ const len0 = WASM_VECTOR_LEN;
158
+ const ret = wasm.checkParseTemplate(ptr0, len0);
159
+ return takeObject(ret);
160
+ }
161
+
162
+ /**
163
+ * @param {string} input_schema
164
+ * @returns {CheckParseResult}
165
+ */
166
+ export function checkParseSchema(input_schema) {
167
+ const ptr0 = passStringToWasm0(input_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
168
+ const len0 = WASM_VECTOR_LEN;
169
+ const ret = wasm.checkParseSchema(ptr0, len0);
170
+ return takeObject(ret);
171
+ }
172
+
173
+ /**
174
+ * @param {string} entities_str
175
+ * @param {string} schema_str
176
+ * @returns {CheckParseResult}
177
+ */
178
+ export function checkParseEntities(entities_str, schema_str) {
179
+ const ptr0 = passStringToWasm0(entities_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
180
+ const len0 = WASM_VECTOR_LEN;
181
+ const ptr1 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
182
+ const len1 = WASM_VECTOR_LEN;
183
+ const ret = wasm.checkParseEntities(ptr0, len0, ptr1, len1);
184
+ return takeObject(ret);
185
+ }
186
+
187
+ /**
188
+ * @param {string} context_str
189
+ * @param {string} action_str
190
+ * @param {string} schema_str
191
+ * @returns {CheckParseResult}
192
+ */
193
+ export function checkParseContext(context_str, action_str, schema_str) {
194
+ const ptr0 = passStringToWasm0(context_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
195
+ const len0 = WASM_VECTOR_LEN;
196
+ const ptr1 = passStringToWasm0(action_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
197
+ const len1 = WASM_VECTOR_LEN;
198
+ const ptr2 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
199
+ const len2 = WASM_VECTOR_LEN;
200
+ const ret = wasm.checkParseContext(ptr0, len0, ptr1, len1, ptr2, len2);
201
+ return takeObject(ret);
202
+ }
203
+
204
+ /**
205
+ * @param {string} policies_str
206
+ * @param {number} line_width
207
+ * @param {number} indent_width
208
+ * @returns {FormattingResult}
209
+ */
210
+ export function formatPolicies(policies_str, line_width, indent_width) {
211
+ const ptr0 = passStringToWasm0(policies_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
212
+ const len0 = WASM_VECTOR_LEN;
213
+ const ret = wasm.formatPolicies(ptr0, len0, line_width, indent_width);
214
+ return takeObject(ret);
215
+ }
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
+ /**
238
+ * @param {AuthorizationCall} call
239
+ * @returns {AuthorizationAnswer}
240
+ */
241
+ export function isAuthorized(call) {
242
+ const ret = wasm.isAuthorized(addHeapObject(call));
243
+ return takeObject(ret);
244
+ }
245
+
246
+ /**
247
+ * @param {ValidationCall} call
248
+ * @returns {ValidationAnswer}
249
+ */
250
+ export function validate(call) {
251
+ const ret = wasm.validate(addHeapObject(call));
252
+ return takeObject(ret);
253
+ }
254
+
255
+ function handleError(f, args) {
256
+ try {
257
+ return f.apply(this, args);
258
+ } catch (e) {
259
+ wasm.__wbindgen_exn_store(addHeapObject(e));
260
+ }
261
+ }
262
+
263
+ async function __wbg_load(module, imports) {
264
+ if (typeof Response === 'function' && module instanceof Response) {
265
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
266
+ try {
267
+ return await WebAssembly.instantiateStreaming(module, imports);
268
+
269
+ } catch (e) {
270
+ if (module.headers.get('Content-Type') != 'application/wasm') {
271
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
272
+
273
+ } else {
274
+ throw e;
275
+ }
276
+ }
277
+ }
278
+
279
+ const bytes = await module.arrayBuffer();
280
+ return await WebAssembly.instantiate(bytes, imports);
281
+
282
+ } else {
283
+ const instance = await WebAssembly.instantiate(module, imports);
284
+
285
+ if (instance instanceof WebAssembly.Instance) {
286
+ return { instance, module };
287
+
288
+ } else {
289
+ return instance;
290
+ }
291
+ }
292
+ }
293
+
294
+ function __wbg_get_imports() {
295
+ const imports = {};
296
+ imports.wbg = {};
297
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
298
+ const ret = getObject(arg0) === undefined;
299
+ return ret;
300
+ };
301
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
302
+ const ret = getObject(arg0);
303
+ return addHeapObject(ret);
304
+ };
305
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
306
+ takeObject(arg0);
307
+ };
308
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
309
+ const obj = getObject(arg1);
310
+ const ret = typeof(obj) === 'string' ? obj : undefined;
311
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
312
+ var len1 = WASM_VECTOR_LEN;
313
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
314
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
315
+ };
316
+ imports.wbg.__wbg_parse_66d1801634e099ac = function() { return handleError(function (arg0, arg1) {
317
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
318
+ return addHeapObject(ret);
319
+ }, arguments) };
320
+ imports.wbg.__wbg_stringify_8887fe74e1c50d81 = function() { return handleError(function (arg0) {
321
+ const ret = JSON.stringify(getObject(arg0));
322
+ return addHeapObject(ret);
323
+ }, arguments) };
324
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
325
+ throw new Error(getStringFromWasm0(arg0, arg1));
326
+ };
327
+
328
+ return imports;
329
+ }
330
+
331
+ function __wbg_init_memory(imports, maybe_memory) {
332
+
333
+ }
334
+
335
+ function __wbg_finalize_init(instance, module) {
336
+ wasm = instance.exports;
337
+ __wbg_init.__wbindgen_wasm_module = module;
338
+ cachedInt32Memory0 = null;
339
+ cachedUint8Memory0 = null;
340
+
341
+
342
+ return wasm;
343
+ }
344
+
345
+ function initSync(module) {
346
+ if (wasm !== undefined) return wasm;
347
+
348
+ const imports = __wbg_get_imports();
349
+
350
+ __wbg_init_memory(imports);
351
+
352
+ if (!(module instanceof WebAssembly.Module)) {
353
+ module = new WebAssembly.Module(module);
354
+ }
355
+
356
+ const instance = new WebAssembly.Instance(module, imports);
357
+
358
+ return __wbg_finalize_init(instance, module);
359
+ }
360
+
361
+ async function __wbg_init(input) {
362
+ if (wasm !== undefined) return wasm;
363
+
364
+ if (typeof input === 'undefined') {
365
+ input = new URL('cedar_wasm_bg.wasm', import.meta.url);
366
+ }
367
+ const imports = __wbg_get_imports();
368
+
369
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
370
+ input = fetch(input);
371
+ }
372
+
373
+ __wbg_init_memory(imports);
374
+
375
+ const { instance, module } = await __wbg_load(await input, imports);
376
+
377
+ return __wbg_finalize_init(instance, module);
378
+ }
379
+
380
+ export { initSync }
381
+ export default __wbg_init;
Binary file