@cedar-policy/cedar-wasm 4.0.1 → 4.2.0

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
@@ -28,7 +28,7 @@ console.log(cedar.getCedarVersion());
28
28
  Importing the esm version using esm async import:
29
29
 
30
30
  ```
31
- import('@cedar-policy/cedar-wasm')
31
+ import('@cedar-policy/cedar-wasm/nodejs')
32
32
  .then(cedar => console.log(cedar.getCedarVersion()));
33
33
  ```
34
34
 
package/esm/README.md CHANGED
@@ -28,7 +28,7 @@ console.log(cedar.getCedarVersion());
28
28
  Importing the esm version using esm async import:
29
29
 
30
30
  ```
31
- import('@cedar-policy/cedar-wasm')
31
+ import('@cedar-policy/cedar-wasm/nodejs')
32
32
  .then(cedar => console.log(cedar.getCedarVersion()));
33
33
  ```
34
34
 
@@ -101,10 +101,6 @@ export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
101
101
  export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
102
102
  export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
103
103
 
104
- export type SlotId = string;
105
-
106
- export type PolicyId = string;
107
-
108
104
  export interface Response {
109
105
  decision: Decision;
110
106
  diagnostics: Diagnostics;
@@ -150,6 +146,41 @@ export interface ValidationError {
150
146
 
151
147
  export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
152
148
 
149
+ export interface FormattingCall {
150
+ policyText: string;
151
+ lineWidth?: number;
152
+ indentWidth?: number;
153
+ }
154
+
155
+ export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
156
+
157
+ export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
158
+
159
+ export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
160
+
161
+ export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
162
+
163
+ export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
164
+
165
+ export type ValidationMode = "strict";
166
+
167
+ export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
168
+
169
+ export interface EntitiesParsingCall {
170
+ entities: Entities;
171
+ schema?: Schema | null;
172
+ }
173
+
174
+ export interface ContextParsingCall {
175
+ context: Context;
176
+ schema?: Schema | null;
177
+ action?: EntityUid | null;
178
+ }
179
+
180
+ export type SlotId = string;
181
+
182
+ export type PolicyId = string;
183
+
153
184
  export type Schema = string | SchemaJson<string>;
154
185
 
155
186
  export interface PolicySet {
@@ -197,47 +228,10 @@ export interface DetailedError {
197
228
  related?: DetailedError[];
198
229
  }
199
230
 
200
- export type ValidationMode = "strict";
201
-
202
- export interface FormattingCall {
203
- policyText: string;
204
- lineWidth?: number;
205
- indentWidth?: number;
206
- }
207
-
208
- export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
209
-
210
- export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
211
-
212
- export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
213
-
214
- export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
215
-
216
- export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
217
-
218
- export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
219
-
220
- export interface EntitiesParsingCall {
221
- entities: Entities;
222
- schema?: Schema | null;
223
- }
224
-
225
- export interface ContextParsingCall {
226
- context: Context;
227
- schema?: Schema | null;
228
- action?: EntityUid | null;
229
- }
230
-
231
- export type RecordAttributeType<N> = { required?: boolean } & Type<N>;
232
-
233
- export type EntityAttributeType<N> = { required?: boolean } & EntityAttributeTypeInternal<N>;
231
+ export type TypeVariant<N> = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: Type<N> } | ({ type: "Record" } & RecordType<N>) | { type: "Entity"; name: N } | { type: "EntityOrCommon"; name: N } | { type: "Extension"; name: UnreservedId };
234
232
 
235
- export type EntityAttributeTypeInternal<N> = { Type: Type<N> } | { EAMap: { value_type: Type<N> } };
236
-
237
- export type TypeVariant<N> = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: Type<N> } | ({ type: "Record" } & RecordType<RecordAttributeType<N>>) | { type: "Entity"; name: N } | { type: "EntityOrCommon"; name: N } | { type: "Extension"; name: UnreservedId };
238
-
239
- export interface RecordType<V> {
240
- attributes: Record<SmolStr, V>;
233
+ export interface RecordType<N> {
234
+ attributes: Record<SmolStr, TypeOfAttribute<N>>;
241
235
  additionalAttributes?: boolean;
242
236
  }
243
237
 
@@ -251,7 +245,7 @@ export interface ActionEntityUID<N> {
251
245
  export interface ApplySpec<N> {
252
246
  resourceTypes: N[];
253
247
  principalTypes: N[];
254
- context?: RecordOrContextAttributes<N>;
248
+ context?: AttributesOrContext<N>;
255
249
  }
256
250
 
257
251
  export interface ActionType<N> {
@@ -260,17 +254,12 @@ export interface ActionType<N> {
260
254
  memberOf?: ActionEntityUID<N>[];
261
255
  }
262
256
 
263
- export interface EntityAttributesInternal<N> extends RecordType<EntityAttributeType<N>> {
264
- type: "Record";
265
- }
266
-
267
- export type EntityAttributes<N> = RecordOrContextAttributes<N> | EntityAttributesInternal<N>;
268
-
269
- export type RecordOrContextAttributes<N> = Type<N>;
257
+ export type AttributesOrContext<N> = Type<N>;
270
258
 
271
259
  export interface EntityType<N> {
272
260
  memberOfTypes?: N[];
273
- shape?: EntityAttributes<N>;
261
+ shape?: AttributesOrContext<N>;
262
+ tags?: Type<N>;
274
263
  }
275
264
 
276
265
  export interface NamespaceDefinition<N> {
@@ -283,6 +272,8 @@ export type CommonTypeId = string;
283
272
 
284
273
  export type SchemaJson<N> = Record<string, NamespaceDefinition<N>>;
285
274
 
275
+ export type Decision = "allow" | "deny";
276
+
286
277
  export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
287
278
 
288
279
  export interface PolicyJson {
@@ -294,17 +285,15 @@ export interface PolicyJson {
294
285
  annotations?: Record<string, string>;
295
286
  }
296
287
 
297
- export type Decision = "allow" | "deny";
288
+ export type ExtFuncCall = {} & Record<string, Array<Expr>>;
298
289
 
299
- export interface EntityJson {
300
- uid: EntityUidJson;
301
- attrs: Record<string, CedarValueJson>;
302
- parents: EntityUidJson[];
303
- }
290
+ export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: 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 } } | { getTag: { left: Expr; right: Expr } } | { hasTag: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
304
291
 
305
- export type UnreservedId = string;
292
+ export type PatternElem = "Wildcard" | { Literal: SmolStr };
306
293
 
307
- export type Var = "principal" | "action" | "resource" | "context";
294
+ export type Expr = ExprNoExt | ExtFuncCall;
295
+
296
+ export type Effect = "permit" | "forbid";
308
297
 
309
298
  export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
310
299
 
@@ -323,6 +312,13 @@ export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | (
323
312
 
324
313
  export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
325
314
 
315
+ export interface EntityJson {
316
+ uid: EntityUidJson;
317
+ attrs: Record<string, CedarValueJson>;
318
+ parents: EntityUidJson[];
319
+ tags?: Record<string, CedarValueJson>;
320
+ }
321
+
326
322
  export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
327
323
 
328
324
  export interface FnAndArg {
@@ -337,14 +333,9 @@ export interface TypeAndId {
337
333
 
338
334
  export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
339
335
 
340
- export type ExtFuncCall = {} & Record<string, Array<Expr>>;
341
-
342
- export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: 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: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
343
-
344
- export type PatternElem = "Wildcard" | { Literal: SmolStr };
345
-
346
- export type Expr = ExprNoExt | ExtFuncCall;
336
+ export type UnreservedId = string;
347
337
 
348
- export type Effect = "permit" | "forbid";
338
+ export type Var = "principal" | "action" | "resource" | "context";
349
339
 
350
340
  type SmolStr = string;
341
+ export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
package/esm/cedar_wasm.js CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  import * as wasm from "./cedar_wasm_bg.wasm";
2
3
  import { __wbg_set_wasm } from "./cedar_wasm_bg.js";
3
4
  __wbg_set_wasm(wasm);
@@ -35,13 +35,13 @@ function takeObject(idx) {
35
35
 
36
36
  let WASM_VECTOR_LEN = 0;
37
37
 
38
- let cachedUint8Memory0 = null;
38
+ let cachedUint8ArrayMemory0 = null;
39
39
 
40
- function getUint8Memory0() {
41
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
42
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
40
+ function getUint8ArrayMemory0() {
41
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
42
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
43
43
  }
44
- return cachedUint8Memory0;
44
+ return cachedUint8ArrayMemory0;
45
45
  }
46
46
 
47
47
  const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
@@ -66,7 +66,7 @@ function passStringToWasm0(arg, malloc, realloc) {
66
66
  if (realloc === undefined) {
67
67
  const buf = cachedTextEncoder.encode(arg);
68
68
  const ptr = malloc(buf.length, 1) >>> 0;
69
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
69
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
70
70
  WASM_VECTOR_LEN = buf.length;
71
71
  return ptr;
72
72
  }
@@ -74,7 +74,7 @@ function passStringToWasm0(arg, malloc, realloc) {
74
74
  let len = arg.length;
75
75
  let ptr = malloc(len, 1) >>> 0;
76
76
 
77
- const mem = getUint8Memory0();
77
+ const mem = getUint8ArrayMemory0();
78
78
 
79
79
  let offset = 0;
80
80
 
@@ -89,7 +89,7 @@ function passStringToWasm0(arg, malloc, realloc) {
89
89
  arg = arg.slice(offset);
90
90
  }
91
91
  ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
92
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
92
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
93
93
  const ret = encodeString(arg, view);
94
94
 
95
95
  offset += ret.written;
@@ -104,13 +104,13 @@ function isLikeNone(x) {
104
104
  return x === undefined || x === null;
105
105
  }
106
106
 
107
- let cachedInt32Memory0 = null;
107
+ let cachedDataViewMemory0 = null;
108
108
 
109
- function getInt32Memory0() {
110
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
111
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
109
+ function getDataViewMemory0() {
110
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
111
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
112
112
  }
113
- return cachedInt32Memory0;
113
+ return cachedDataViewMemory0;
114
114
  }
115
115
 
116
116
  const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
@@ -121,7 +121,7 @@ cachedTextDecoder.decode();
121
121
 
122
122
  function getStringFromWasm0(ptr, len) {
123
123
  ptr = ptr >>> 0;
124
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
124
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
125
125
  }
126
126
  /**
127
127
  * Get valid request environment
@@ -154,8 +154,8 @@ export function getCedarVersion() {
154
154
  try {
155
155
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
156
156
  wasm.getCedarVersion(retptr);
157
- var r0 = getInt32Memory0()[retptr / 4 + 0];
158
- var r1 = getInt32Memory0()[retptr / 4 + 1];
157
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
158
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
159
159
  deferred1_0 = r0;
160
160
  deferred1_1 = r1;
161
161
  return getStringFromWasm0(r0, r1);
@@ -325,16 +325,16 @@ export function __wbindgen_string_get(arg0, arg1) {
325
325
  const ret = typeof(obj) === 'string' ? obj : undefined;
326
326
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
327
327
  var len1 = WASM_VECTOR_LEN;
328
- getInt32Memory0()[arg0 / 4 + 1] = len1;
329
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
328
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
329
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
330
330
  };
331
331
 
332
- export function __wbg_parse_66d1801634e099ac() { return handleError(function (arg0, arg1) {
332
+ export function __wbg_parse_52202f117ec9ecfa() { return handleError(function (arg0, arg1) {
333
333
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
334
334
  return addHeapObject(ret);
335
335
  }, arguments) };
336
336
 
337
- export function __wbg_stringify_8887fe74e1c50d81() { return handleError(function (arg0) {
337
+ export function __wbg_stringify_bbf45426c92a6bf5() { return handleError(function (arg0) {
338
338
  const ret = JSON.stringify(getObject(arg0));
339
339
  return addHeapObject(ret);
340
340
  }, arguments) };
Binary file
package/esm/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
+ "type": "module",
3
4
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "4.0.1",
5
+ "version": "4.2.0",
5
6
  "license": "Apache-2.0",
6
7
  "files": [
7
8
  "cedar_wasm_bg.wasm",
@@ -9,11 +10,10 @@
9
10
  "cedar_wasm_bg.js",
10
11
  "cedar_wasm.d.ts"
11
12
  ],
12
- "module": "cedar_wasm.js",
13
+ "main": "cedar_wasm.js",
13
14
  "types": "cedar_wasm.d.ts",
14
15
  "sideEffects": [
15
16
  "./cedar_wasm.js",
16
17
  "./snippets/*"
17
- ],
18
- "type": "module"
18
+ ]
19
19
  }
package/nodejs/README.md CHANGED
@@ -28,7 +28,7 @@ console.log(cedar.getCedarVersion());
28
28
  Importing the esm version using esm async import:
29
29
 
30
30
  ```
31
- import('@cedar-policy/cedar-wasm')
31
+ import('@cedar-policy/cedar-wasm/nodejs')
32
32
  .then(cedar => console.log(cedar.getCedarVersion()));
33
33
  ```
34
34
 
@@ -101,10 +101,6 @@ export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
101
101
  export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
102
102
  export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
103
103
 
104
- export type SlotId = string;
105
-
106
- export type PolicyId = string;
107
-
108
104
  export interface Response {
109
105
  decision: Decision;
110
106
  diagnostics: Diagnostics;
@@ -150,6 +146,41 @@ export interface ValidationError {
150
146
 
151
147
  export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
152
148
 
149
+ export interface FormattingCall {
150
+ policyText: string;
151
+ lineWidth?: number;
152
+ indentWidth?: number;
153
+ }
154
+
155
+ export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
156
+
157
+ export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
158
+
159
+ export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
160
+
161
+ export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
162
+
163
+ export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
164
+
165
+ export type ValidationMode = "strict";
166
+
167
+ export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
168
+
169
+ export interface EntitiesParsingCall {
170
+ entities: Entities;
171
+ schema?: Schema | null;
172
+ }
173
+
174
+ export interface ContextParsingCall {
175
+ context: Context;
176
+ schema?: Schema | null;
177
+ action?: EntityUid | null;
178
+ }
179
+
180
+ export type SlotId = string;
181
+
182
+ export type PolicyId = string;
183
+
153
184
  export type Schema = string | SchemaJson<string>;
154
185
 
155
186
  export interface PolicySet {
@@ -197,47 +228,10 @@ export interface DetailedError {
197
228
  related?: DetailedError[];
198
229
  }
199
230
 
200
- export type ValidationMode = "strict";
201
-
202
- export interface FormattingCall {
203
- policyText: string;
204
- lineWidth?: number;
205
- indentWidth?: number;
206
- }
207
-
208
- export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
209
-
210
- export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
211
-
212
- export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
213
-
214
- export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
215
-
216
- export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
217
-
218
- export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
219
-
220
- export interface EntitiesParsingCall {
221
- entities: Entities;
222
- schema?: Schema | null;
223
- }
224
-
225
- export interface ContextParsingCall {
226
- context: Context;
227
- schema?: Schema | null;
228
- action?: EntityUid | null;
229
- }
230
-
231
- export type RecordAttributeType<N> = { required?: boolean } & Type<N>;
232
-
233
- export type EntityAttributeType<N> = { required?: boolean } & EntityAttributeTypeInternal<N>;
231
+ export type TypeVariant<N> = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: Type<N> } | ({ type: "Record" } & RecordType<N>) | { type: "Entity"; name: N } | { type: "EntityOrCommon"; name: N } | { type: "Extension"; name: UnreservedId };
234
232
 
235
- export type EntityAttributeTypeInternal<N> = { Type: Type<N> } | { EAMap: { value_type: Type<N> } };
236
-
237
- export type TypeVariant<N> = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: Type<N> } | ({ type: "Record" } & RecordType<RecordAttributeType<N>>) | { type: "Entity"; name: N } | { type: "EntityOrCommon"; name: N } | { type: "Extension"; name: UnreservedId };
238
-
239
- export interface RecordType<V> {
240
- attributes: Record<SmolStr, V>;
233
+ export interface RecordType<N> {
234
+ attributes: Record<SmolStr, TypeOfAttribute<N>>;
241
235
  additionalAttributes?: boolean;
242
236
  }
243
237
 
@@ -251,7 +245,7 @@ export interface ActionEntityUID<N> {
251
245
  export interface ApplySpec<N> {
252
246
  resourceTypes: N[];
253
247
  principalTypes: N[];
254
- context?: RecordOrContextAttributes<N>;
248
+ context?: AttributesOrContext<N>;
255
249
  }
256
250
 
257
251
  export interface ActionType<N> {
@@ -260,17 +254,12 @@ export interface ActionType<N> {
260
254
  memberOf?: ActionEntityUID<N>[];
261
255
  }
262
256
 
263
- export interface EntityAttributesInternal<N> extends RecordType<EntityAttributeType<N>> {
264
- type: "Record";
265
- }
266
-
267
- export type EntityAttributes<N> = RecordOrContextAttributes<N> | EntityAttributesInternal<N>;
268
-
269
- export type RecordOrContextAttributes<N> = Type<N>;
257
+ export type AttributesOrContext<N> = Type<N>;
270
258
 
271
259
  export interface EntityType<N> {
272
260
  memberOfTypes?: N[];
273
- shape?: EntityAttributes<N>;
261
+ shape?: AttributesOrContext<N>;
262
+ tags?: Type<N>;
274
263
  }
275
264
 
276
265
  export interface NamespaceDefinition<N> {
@@ -283,6 +272,8 @@ export type CommonTypeId = string;
283
272
 
284
273
  export type SchemaJson<N> = Record<string, NamespaceDefinition<N>>;
285
274
 
275
+ export type Decision = "allow" | "deny";
276
+
286
277
  export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
287
278
 
288
279
  export interface PolicyJson {
@@ -294,17 +285,15 @@ export interface PolicyJson {
294
285
  annotations?: Record<string, string>;
295
286
  }
296
287
 
297
- export type Decision = "allow" | "deny";
288
+ export type ExtFuncCall = {} & Record<string, Array<Expr>>;
298
289
 
299
- export interface EntityJson {
300
- uid: EntityUidJson;
301
- attrs: Record<string, CedarValueJson>;
302
- parents: EntityUidJson[];
303
- }
290
+ export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: 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 } } | { getTag: { left: Expr; right: Expr } } | { hasTag: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
304
291
 
305
- export type UnreservedId = string;
292
+ export type PatternElem = "Wildcard" | { Literal: SmolStr };
306
293
 
307
- export type Var = "principal" | "action" | "resource" | "context";
294
+ export type Expr = ExprNoExt | ExtFuncCall;
295
+
296
+ export type Effect = "permit" | "forbid";
308
297
 
309
298
  export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
310
299
 
@@ -323,6 +312,13 @@ export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | (
323
312
 
324
313
  export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
325
314
 
315
+ export interface EntityJson {
316
+ uid: EntityUidJson;
317
+ attrs: Record<string, CedarValueJson>;
318
+ parents: EntityUidJson[];
319
+ tags?: Record<string, CedarValueJson>;
320
+ }
321
+
326
322
  export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
327
323
 
328
324
  export interface FnAndArg {
@@ -337,14 +333,9 @@ export interface TypeAndId {
337
333
 
338
334
  export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
339
335
 
340
- export type ExtFuncCall = {} & Record<string, Array<Expr>>;
341
-
342
- export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: 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: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
343
-
344
- export type PatternElem = "Wildcard" | { Literal: SmolStr };
345
-
346
- export type Expr = ExprNoExt | ExtFuncCall;
336
+ export type UnreservedId = string;
347
337
 
348
- export type Effect = "permit" | "forbid";
338
+ export type Var = "principal" | "action" | "resource" | "context";
349
339
 
350
340
  type SmolStr = string;
341
+ export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
@@ -1,3 +1,4 @@
1
+
1
2
  let imports = {};
2
3
  imports['__wbindgen_placeholder__'] = module.exports;
3
4
  let wasm;
@@ -34,13 +35,13 @@ function takeObject(idx) {
34
35
 
35
36
  let WASM_VECTOR_LEN = 0;
36
37
 
37
- let cachedUint8Memory0 = null;
38
+ let cachedUint8ArrayMemory0 = null;
38
39
 
39
- function getUint8Memory0() {
40
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
41
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
40
+ function getUint8ArrayMemory0() {
41
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
42
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
42
43
  }
43
- return cachedUint8Memory0;
44
+ return cachedUint8ArrayMemory0;
44
45
  }
45
46
 
46
47
  let cachedTextEncoder = new TextEncoder('utf-8');
@@ -63,7 +64,7 @@ function passStringToWasm0(arg, malloc, realloc) {
63
64
  if (realloc === undefined) {
64
65
  const buf = cachedTextEncoder.encode(arg);
65
66
  const ptr = malloc(buf.length, 1) >>> 0;
66
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
67
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
67
68
  WASM_VECTOR_LEN = buf.length;
68
69
  return ptr;
69
70
  }
@@ -71,7 +72,7 @@ function passStringToWasm0(arg, malloc, realloc) {
71
72
  let len = arg.length;
72
73
  let ptr = malloc(len, 1) >>> 0;
73
74
 
74
- const mem = getUint8Memory0();
75
+ const mem = getUint8ArrayMemory0();
75
76
 
76
77
  let offset = 0;
77
78
 
@@ -86,7 +87,7 @@ function passStringToWasm0(arg, malloc, realloc) {
86
87
  arg = arg.slice(offset);
87
88
  }
88
89
  ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
89
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
90
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
90
91
  const ret = encodeString(arg, view);
91
92
 
92
93
  offset += ret.written;
@@ -101,13 +102,13 @@ function isLikeNone(x) {
101
102
  return x === undefined || x === null;
102
103
  }
103
104
 
104
- let cachedInt32Memory0 = null;
105
+ let cachedDataViewMemory0 = null;
105
106
 
106
- function getInt32Memory0() {
107
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
108
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
107
+ function getDataViewMemory0() {
108
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
109
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
109
110
  }
110
- return cachedInt32Memory0;
111
+ return cachedDataViewMemory0;
111
112
  }
112
113
 
113
114
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
@@ -116,7 +117,7 @@ cachedTextDecoder.decode();
116
117
 
117
118
  function getStringFromWasm0(ptr, len) {
118
119
  ptr = ptr >>> 0;
119
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
120
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
120
121
  }
121
122
  /**
122
123
  * Get valid request environment
@@ -149,8 +150,8 @@ module.exports.getCedarVersion = function() {
149
150
  try {
150
151
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
151
152
  wasm.getCedarVersion(retptr);
152
- var r0 = getInt32Memory0()[retptr / 4 + 0];
153
- var r1 = getInt32Memory0()[retptr / 4 + 1];
153
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
154
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
154
155
  deferred1_0 = r0;
155
156
  deferred1_1 = r1;
156
157
  return getStringFromWasm0(r0, r1);
@@ -320,16 +321,16 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
320
321
  const ret = typeof(obj) === 'string' ? obj : undefined;
321
322
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
322
323
  var len1 = WASM_VECTOR_LEN;
323
- getInt32Memory0()[arg0 / 4 + 1] = len1;
324
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
324
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
325
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
325
326
  };
326
327
 
327
- module.exports.__wbg_parse_66d1801634e099ac = function() { return handleError(function (arg0, arg1) {
328
+ module.exports.__wbg_parse_52202f117ec9ecfa = function() { return handleError(function (arg0, arg1) {
328
329
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
329
330
  return addHeapObject(ret);
330
331
  }, arguments) };
331
332
 
332
- module.exports.__wbg_stringify_8887fe74e1c50d81 = function() { return handleError(function (arg0) {
333
+ module.exports.__wbg_stringify_bbf45426c92a6bf5 = function() { return handleError(function (arg0) {
333
334
  const ret = JSON.stringify(getObject(arg0));
334
335
  return addHeapObject(ret);
335
336
  }, arguments) };
Binary file
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
3
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "4.0.1",
4
+ "version": "4.2.0",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
7
  "cedar_wasm_bg.wasm",
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
+ "type": "module",
3
4
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "4.0.1",
5
+ "version": "4.2.0",
5
6
  "license": "Apache-2.0",
6
7
  "files": [
7
8
  "esm/package.json",
@@ -24,11 +25,12 @@
24
25
  "web/cedar_wasm.js",
25
26
  "web/cedar_wasm.d.ts"
26
27
  ],
27
- "module": "esm/cedar_wasm.js",
28
+ "main": "cedar_wasm.js",
28
29
  "types": "esm/cedar_wasm.d.ts",
29
30
  "sideEffects": [
30
31
  "./snippets/*"
31
32
  ],
33
+ "module": "esm/cedar_wasm.js",
32
34
  "exports": {
33
35
  ".": {
34
36
  "import": "./esm/cedar_wasm.js",
@@ -36,6 +38,7 @@
36
38
  },
37
39
  "./nodejs": {
38
40
  "require": "./nodejs/cedar_wasm.js",
41
+ "import": "./nodejs/cedar_wasm.js",
39
42
  "types": "./nodejs/cedar_wasm.d.ts"
40
43
  },
41
44
  "./web": {
package/web/README.md CHANGED
@@ -28,7 +28,7 @@ console.log(cedar.getCedarVersion());
28
28
  Importing the esm version using esm async import:
29
29
 
30
30
  ```
31
- import('@cedar-policy/cedar-wasm')
31
+ import('@cedar-policy/cedar-wasm/nodejs')
32
32
  .then(cedar => console.log(cedar.getCedarVersion()));
33
33
  ```
34
34
 
@@ -101,10 +101,6 @@ export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
101
101
  export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
102
102
  export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
103
103
 
104
- export type SlotId = string;
105
-
106
- export type PolicyId = string;
107
-
108
104
  export interface Response {
109
105
  decision: Decision;
110
106
  diagnostics: Diagnostics;
@@ -150,6 +146,41 @@ export interface ValidationError {
150
146
 
151
147
  export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
152
148
 
149
+ export interface FormattingCall {
150
+ policyText: string;
151
+ lineWidth?: number;
152
+ indentWidth?: number;
153
+ }
154
+
155
+ export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
156
+
157
+ export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
158
+
159
+ export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
160
+
161
+ export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
162
+
163
+ export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
164
+
165
+ export type ValidationMode = "strict";
166
+
167
+ export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
168
+
169
+ export interface EntitiesParsingCall {
170
+ entities: Entities;
171
+ schema?: Schema | null;
172
+ }
173
+
174
+ export interface ContextParsingCall {
175
+ context: Context;
176
+ schema?: Schema | null;
177
+ action?: EntityUid | null;
178
+ }
179
+
180
+ export type SlotId = string;
181
+
182
+ export type PolicyId = string;
183
+
153
184
  export type Schema = string | SchemaJson<string>;
154
185
 
155
186
  export interface PolicySet {
@@ -197,47 +228,10 @@ export interface DetailedError {
197
228
  related?: DetailedError[];
198
229
  }
199
230
 
200
- export type ValidationMode = "strict";
201
-
202
- export interface FormattingCall {
203
- policyText: string;
204
- lineWidth?: number;
205
- indentWidth?: number;
206
- }
207
-
208
- export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
209
-
210
- export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
211
-
212
- export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
213
-
214
- export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
215
-
216
- export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
217
-
218
- export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
219
-
220
- export interface EntitiesParsingCall {
221
- entities: Entities;
222
- schema?: Schema | null;
223
- }
224
-
225
- export interface ContextParsingCall {
226
- context: Context;
227
- schema?: Schema | null;
228
- action?: EntityUid | null;
229
- }
230
-
231
- export type RecordAttributeType<N> = { required?: boolean } & Type<N>;
232
-
233
- export type EntityAttributeType<N> = { required?: boolean } & EntityAttributeTypeInternal<N>;
231
+ export type TypeVariant<N> = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: Type<N> } | ({ type: "Record" } & RecordType<N>) | { type: "Entity"; name: N } | { type: "EntityOrCommon"; name: N } | { type: "Extension"; name: UnreservedId };
234
232
 
235
- export type EntityAttributeTypeInternal<N> = { Type: Type<N> } | { EAMap: { value_type: Type<N> } };
236
-
237
- export type TypeVariant<N> = { type: "String" } | { type: "Long" } | { type: "Boolean" } | { type: "Set"; element: Type<N> } | ({ type: "Record" } & RecordType<RecordAttributeType<N>>) | { type: "Entity"; name: N } | { type: "EntityOrCommon"; name: N } | { type: "Extension"; name: UnreservedId };
238
-
239
- export interface RecordType<V> {
240
- attributes: Record<SmolStr, V>;
233
+ export interface RecordType<N> {
234
+ attributes: Record<SmolStr, TypeOfAttribute<N>>;
241
235
  additionalAttributes?: boolean;
242
236
  }
243
237
 
@@ -251,7 +245,7 @@ export interface ActionEntityUID<N> {
251
245
  export interface ApplySpec<N> {
252
246
  resourceTypes: N[];
253
247
  principalTypes: N[];
254
- context?: RecordOrContextAttributes<N>;
248
+ context?: AttributesOrContext<N>;
255
249
  }
256
250
 
257
251
  export interface ActionType<N> {
@@ -260,17 +254,12 @@ export interface ActionType<N> {
260
254
  memberOf?: ActionEntityUID<N>[];
261
255
  }
262
256
 
263
- export interface EntityAttributesInternal<N> extends RecordType<EntityAttributeType<N>> {
264
- type: "Record";
265
- }
266
-
267
- export type EntityAttributes<N> = RecordOrContextAttributes<N> | EntityAttributesInternal<N>;
268
-
269
- export type RecordOrContextAttributes<N> = Type<N>;
257
+ export type AttributesOrContext<N> = Type<N>;
270
258
 
271
259
  export interface EntityType<N> {
272
260
  memberOfTypes?: N[];
273
- shape?: EntityAttributes<N>;
261
+ shape?: AttributesOrContext<N>;
262
+ tags?: Type<N>;
274
263
  }
275
264
 
276
265
  export interface NamespaceDefinition<N> {
@@ -283,6 +272,8 @@ export type CommonTypeId = string;
283
272
 
284
273
  export type SchemaJson<N> = Record<string, NamespaceDefinition<N>>;
285
274
 
275
+ export type Decision = "allow" | "deny";
276
+
286
277
  export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
287
278
 
288
279
  export interface PolicyJson {
@@ -294,17 +285,15 @@ export interface PolicyJson {
294
285
  annotations?: Record<string, string>;
295
286
  }
296
287
 
297
- export type Decision = "allow" | "deny";
288
+ export type ExtFuncCall = {} & Record<string, Array<Expr>>;
298
289
 
299
- export interface EntityJson {
300
- uid: EntityUidJson;
301
- attrs: Record<string, CedarValueJson>;
302
- parents: EntityUidJson[];
303
- }
290
+ export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: 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 } } | { getTag: { left: Expr; right: Expr } } | { hasTag: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
304
291
 
305
- export type UnreservedId = string;
292
+ export type PatternElem = "Wildcard" | { Literal: SmolStr };
306
293
 
307
- export type Var = "principal" | "action" | "resource" | "context";
294
+ export type Expr = ExprNoExt | ExtFuncCall;
295
+
296
+ export type Effect = "permit" | "forbid";
308
297
 
309
298
  export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
310
299
 
@@ -323,6 +312,13 @@ export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | (
323
312
 
324
313
  export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
325
314
 
315
+ export interface EntityJson {
316
+ uid: EntityUidJson;
317
+ attrs: Record<string, CedarValueJson>;
318
+ parents: EntityUidJson[];
319
+ tags?: Record<string, CedarValueJson>;
320
+ }
321
+
326
322
  export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
327
323
 
328
324
  export interface FnAndArg {
@@ -337,15 +333,9 @@ export interface TypeAndId {
337
333
 
338
334
  export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
339
335
 
340
- export type ExtFuncCall = {} & Record<string, Array<Expr>>;
341
-
342
- export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: 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: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
343
-
344
- export type PatternElem = "Wildcard" | { Literal: SmolStr };
345
-
346
- export type Expr = ExprNoExt | ExtFuncCall;
336
+ export type UnreservedId = string;
347
337
 
348
- export type Effect = "permit" | "forbid";
338
+ export type Var = "principal" | "action" | "resource" | "context";
349
339
 
350
340
 
351
341
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -380,19 +370,20 @@ export type SyncInitInput = BufferSource | WebAssembly.Module;
380
370
  * Instantiates the given `module`, which can either be bytes or
381
371
  * a precompiled `WebAssembly.Module`.
382
372
  *
383
- * @param {SyncInitInput} module
373
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
384
374
  *
385
375
  * @returns {InitOutput}
386
376
  */
387
- export function initSync(module: SyncInitInput): InitOutput;
377
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
388
378
 
389
379
  /**
390
380
  * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
391
381
  * for everything else, calls `WebAssembly.instantiate` directly.
392
382
  *
393
- * @param {InitInput | Promise<InitInput>} module_or_path
383
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
394
384
  *
395
385
  * @returns {Promise<InitOutput>}
396
386
  */
397
- export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
387
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
398
388
  type SmolStr = string;
389
+ export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
package/web/cedar_wasm.js CHANGED
@@ -31,13 +31,13 @@ function takeObject(idx) {
31
31
 
32
32
  let WASM_VECTOR_LEN = 0;
33
33
 
34
- let cachedUint8Memory0 = null;
34
+ let cachedUint8ArrayMemory0 = null;
35
35
 
36
- function getUint8Memory0() {
37
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
38
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
36
+ function getUint8ArrayMemory0() {
37
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
38
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
39
39
  }
40
- return cachedUint8Memory0;
40
+ return cachedUint8ArrayMemory0;
41
41
  }
42
42
 
43
43
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
@@ -60,7 +60,7 @@ function passStringToWasm0(arg, malloc, realloc) {
60
60
  if (realloc === undefined) {
61
61
  const buf = cachedTextEncoder.encode(arg);
62
62
  const ptr = malloc(buf.length, 1) >>> 0;
63
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
63
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
64
64
  WASM_VECTOR_LEN = buf.length;
65
65
  return ptr;
66
66
  }
@@ -68,7 +68,7 @@ function passStringToWasm0(arg, malloc, realloc) {
68
68
  let len = arg.length;
69
69
  let ptr = malloc(len, 1) >>> 0;
70
70
 
71
- const mem = getUint8Memory0();
71
+ const mem = getUint8ArrayMemory0();
72
72
 
73
73
  let offset = 0;
74
74
 
@@ -83,7 +83,7 @@ function passStringToWasm0(arg, malloc, realloc) {
83
83
  arg = arg.slice(offset);
84
84
  }
85
85
  ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
86
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
86
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
87
87
  const ret = encodeString(arg, view);
88
88
 
89
89
  offset += ret.written;
@@ -98,13 +98,13 @@ function isLikeNone(x) {
98
98
  return x === undefined || x === null;
99
99
  }
100
100
 
101
- let cachedInt32Memory0 = null;
101
+ let cachedDataViewMemory0 = null;
102
102
 
103
- function getInt32Memory0() {
104
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
105
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
103
+ function getDataViewMemory0() {
104
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
105
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
106
106
  }
107
- return cachedInt32Memory0;
107
+ return cachedDataViewMemory0;
108
108
  }
109
109
 
110
110
  const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
@@ -113,7 +113,7 @@ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
113
113
 
114
114
  function getStringFromWasm0(ptr, len) {
115
115
  ptr = ptr >>> 0;
116
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
116
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
117
117
  }
118
118
  /**
119
119
  * Get valid request environment
@@ -146,8 +146,8 @@ export function getCedarVersion() {
146
146
  try {
147
147
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
148
148
  wasm.getCedarVersion(retptr);
149
- var r0 = getInt32Memory0()[retptr / 4 + 0];
150
- var r1 = getInt32Memory0()[retptr / 4 + 1];
149
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
150
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
151
151
  deferred1_0 = r0;
152
152
  deferred1_1 = r1;
153
153
  return getStringFromWasm0(r0, r1);
@@ -348,14 +348,14 @@ function __wbg_get_imports() {
348
348
  const ret = typeof(obj) === 'string' ? obj : undefined;
349
349
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
350
350
  var len1 = WASM_VECTOR_LEN;
351
- getInt32Memory0()[arg0 / 4 + 1] = len1;
352
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
351
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
352
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
353
353
  };
354
- imports.wbg.__wbg_parse_66d1801634e099ac = function() { return handleError(function (arg0, arg1) {
354
+ imports.wbg.__wbg_parse_52202f117ec9ecfa = function() { return handleError(function (arg0, arg1) {
355
355
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
356
356
  return addHeapObject(ret);
357
357
  }, arguments) };
358
- imports.wbg.__wbg_stringify_8887fe74e1c50d81 = function() { return handleError(function (arg0) {
358
+ imports.wbg.__wbg_stringify_bbf45426c92a6bf5 = function() { return handleError(function (arg0) {
359
359
  const ret = JSON.stringify(getObject(arg0));
360
360
  return addHeapObject(ret);
361
361
  }, arguments) };
@@ -366,15 +366,16 @@ function __wbg_get_imports() {
366
366
  return imports;
367
367
  }
368
368
 
369
- function __wbg_init_memory(imports, maybe_memory) {
369
+ function __wbg_init_memory(imports, memory) {
370
370
 
371
371
  }
372
372
 
373
373
  function __wbg_finalize_init(instance, module) {
374
374
  wasm = instance.exports;
375
375
  __wbg_init.__wbindgen_wasm_module = module;
376
- cachedInt32Memory0 = null;
377
- cachedUint8Memory0 = null;
376
+ cachedDataViewMemory0 = null;
377
+ cachedUint8ArrayMemory0 = null;
378
+
378
379
 
379
380
 
380
381
  return wasm;
@@ -383,6 +384,12 @@ function __wbg_finalize_init(instance, module) {
383
384
  function initSync(module) {
384
385
  if (wasm !== undefined) return wasm;
385
386
 
387
+
388
+ if (typeof module !== 'undefined' && Object.getPrototypeOf(module) === Object.prototype)
389
+ ({module} = module)
390
+ else
391
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
392
+
386
393
  const imports = __wbg_get_imports();
387
394
 
388
395
  __wbg_init_memory(imports);
@@ -396,24 +403,30 @@ function initSync(module) {
396
403
  return __wbg_finalize_init(instance, module);
397
404
  }
398
405
 
399
- async function __wbg_init(input) {
406
+ async function __wbg_init(module_or_path) {
400
407
  if (wasm !== undefined) return wasm;
401
408
 
402
- if (typeof input === 'undefined') {
403
- input = new URL('cedar_wasm_bg.wasm', import.meta.url);
409
+
410
+ if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
411
+ ({module_or_path} = module_or_path)
412
+ else
413
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
414
+
415
+ if (typeof module_or_path === 'undefined') {
416
+ module_or_path = new URL('cedar_wasm_bg.wasm', import.meta.url);
404
417
  }
405
418
  const imports = __wbg_get_imports();
406
419
 
407
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
408
- input = fetch(input);
420
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
421
+ module_or_path = fetch(module_or_path);
409
422
  }
410
423
 
411
424
  __wbg_init_memory(imports);
412
425
 
413
- const { instance, module } = await __wbg_load(await input, imports);
426
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
414
427
 
415
428
  return __wbg_finalize_init(instance, module);
416
429
  }
417
430
 
418
- export { initSync }
431
+ export { initSync };
419
432
  export default __wbg_init;
Binary file
package/web/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@cedar-policy/cedar-wasm",
3
+ "type": "module",
3
4
  "description": "Wasm bindings and typescript types for Cedar lib",
4
- "version": "4.0.1",
5
+ "version": "4.2.0",
5
6
  "license": "Apache-2.0",
6
7
  "files": [
7
8
  "cedar_wasm_bg.wasm",
8
9
  "cedar_wasm.js",
9
10
  "cedar_wasm.d.ts"
10
11
  ],
11
- "module": "cedar_wasm.js",
12
+ "main": "cedar_wasm.js",
12
13
  "types": "cedar_wasm.d.ts",
13
14
  "sideEffects": [
14
15
  "./snippets/*"
15
- ],
16
- "type": "module"
16
+ ]
17
17
  }