@cedar-policy/cedar-wasm 4.3.3 → 4.5.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/esm/cedar_wasm.d.ts +101 -91
- package/esm/cedar_wasm.js +2 -1
- package/esm/cedar_wasm_bg.js +129 -148
- package/esm/cedar_wasm_bg.wasm +0 -0
- package/esm/cedar_wasm_bg.wasm.d.ts +22 -19
- package/esm/package.json +4 -4
- package/nodejs/cedar_wasm.d.ts +101 -91
- package/nodejs/cedar_wasm.js +131 -148
- package/nodejs/cedar_wasm_bg.wasm +0 -0
- package/nodejs/cedar_wasm_bg.wasm.d.ts +22 -19
- package/nodejs/package.json +1 -1
- package/package.json +4 -2
- package/web/cedar_wasm.d.ts +123 -110
- package/web/cedar_wasm.js +129 -147
- package/web/cedar_wasm_bg.wasm +0 -0
- package/web/cedar_wasm_bg.wasm.d.ts +22 -19
- package/web/package.json +4 -4
package/web/cedar_wasm.d.ts
CHANGED
|
@@ -18,9 +18,34 @@ export function getCedarSDKVersion(): string;
|
|
|
18
18
|
*/
|
|
19
19
|
export function validate(call: ValidationCall): ValidationAnswer;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Check whether a policy set successfully parses.
|
|
22
22
|
*/
|
|
23
|
-
export function
|
|
23
|
+
export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
|
|
24
|
+
/**
|
|
25
|
+
* Check whether a schema successfully parses.
|
|
26
|
+
*/
|
|
27
|
+
export function checkParseSchema(schema: Schema): CheckParseAnswer;
|
|
28
|
+
/**
|
|
29
|
+
* Check whether a set of entities successfully parses.
|
|
30
|
+
*/
|
|
31
|
+
export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
|
|
32
|
+
/**
|
|
33
|
+
* Check whether a context successfully parses.
|
|
34
|
+
*/
|
|
35
|
+
export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
|
|
36
|
+
/**
|
|
37
|
+
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
38
|
+
*/
|
|
39
|
+
export function formatPolicies(call: FormattingCall): FormattingAnswer;
|
|
40
|
+
/**
|
|
41
|
+
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
42
|
+
*/
|
|
43
|
+
export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
44
|
+
/**
|
|
45
|
+
* Takes a PolicySet represented as string and return the policies
|
|
46
|
+
* and templates split into vecs and sorted by id.
|
|
47
|
+
*/
|
|
48
|
+
export function policySetTextToParts(policyset_str: string): PolicySetTextToPartsAnswer;
|
|
24
49
|
/**
|
|
25
50
|
* Return the Cedar (textual) representation of a policy.
|
|
26
51
|
*/
|
|
@@ -46,29 +71,9 @@ export function schemaToText(schema: Schema): SchemaToTextAnswer;
|
|
|
46
71
|
*/
|
|
47
72
|
export function schemaToJson(schema: Schema): SchemaToJsonAnswer;
|
|
48
73
|
/**
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
|
|
52
|
-
/**
|
|
53
|
-
* Check whether a schema successfully parses.
|
|
54
|
-
*/
|
|
55
|
-
export function checkParseSchema(schema: Schema): CheckParseAnswer;
|
|
56
|
-
/**
|
|
57
|
-
* Check whether a set of entities successfully parses.
|
|
58
|
-
*/
|
|
59
|
-
export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
|
|
60
|
-
/**
|
|
61
|
-
* Check whether a context successfully parses.
|
|
62
|
-
*/
|
|
63
|
-
export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
|
|
64
|
-
/**
|
|
65
|
-
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
66
|
-
*/
|
|
67
|
-
export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
68
|
-
/**
|
|
69
|
-
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
74
|
+
* Get language version of Cedar
|
|
70
75
|
*/
|
|
71
|
-
export function
|
|
76
|
+
export function getCedarLangVersion(): string;
|
|
72
77
|
export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
|
|
73
78
|
|
|
74
79
|
export interface ValidationCall {
|
|
@@ -88,18 +93,6 @@ export interface ValidationError {
|
|
|
88
93
|
|
|
89
94
|
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
90
95
|
|
|
91
|
-
export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
|
|
92
|
-
|
|
93
|
-
export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
|
|
94
|
-
|
|
95
|
-
export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
|
|
96
|
-
|
|
97
|
-
export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
|
|
98
|
-
|
|
99
|
-
export type SlotId = string;
|
|
100
|
-
|
|
101
|
-
export type PolicyId = string;
|
|
102
|
-
|
|
103
96
|
export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
|
|
104
97
|
|
|
105
98
|
export interface EntitiesParsingCall {
|
|
@@ -113,6 +106,14 @@ export interface ContextParsingCall {
|
|
|
113
106
|
action?: EntityUid | null;
|
|
114
107
|
}
|
|
115
108
|
|
|
109
|
+
export interface FormattingCall {
|
|
110
|
+
policyText: string;
|
|
111
|
+
lineWidth?: number;
|
|
112
|
+
indentWidth?: number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
|
|
116
|
+
|
|
116
117
|
export interface Response {
|
|
117
118
|
decision: Decision;
|
|
118
119
|
diagnostics: Diagnostics;
|
|
@@ -141,13 +142,15 @@ export interface AuthorizationCall {
|
|
|
141
142
|
entities: Entities;
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
export
|
|
145
|
-
policyText: string;
|
|
146
|
-
lineWidth?: number;
|
|
147
|
-
indentWidth?: number;
|
|
148
|
-
}
|
|
145
|
+
export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
|
|
149
146
|
|
|
150
|
-
export type
|
|
147
|
+
export type PolicySetTextToPartsAnswer = { type: "success"; policies: string[]; policy_templates: string[] } | { type: "failure"; errors: DetailedError[] };
|
|
148
|
+
|
|
149
|
+
export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
|
|
150
|
+
|
|
151
|
+
export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
|
|
152
|
+
|
|
153
|
+
export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
|
|
151
154
|
|
|
152
155
|
export type Schema = string | SchemaJson<string>;
|
|
153
156
|
|
|
@@ -196,8 +199,46 @@ export interface DetailedError {
|
|
|
196
199
|
related?: DetailedError[];
|
|
197
200
|
}
|
|
198
201
|
|
|
202
|
+
export type SlotId = string;
|
|
203
|
+
|
|
204
|
+
export type PolicyId = string;
|
|
205
|
+
|
|
199
206
|
export type ValidationMode = "strict";
|
|
200
207
|
|
|
208
|
+
export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
|
|
209
|
+
|
|
210
|
+
export interface PrincipalOrResourceIsConstraint {
|
|
211
|
+
entity_type: string;
|
|
212
|
+
in?: PrincipalOrResourceInConstraint;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
|
|
216
|
+
|
|
217
|
+
export type EqConstraint = { entity: EntityUidJson } | { slot: string };
|
|
218
|
+
|
|
219
|
+
export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
220
|
+
|
|
221
|
+
export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
|
|
222
|
+
|
|
223
|
+
export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
224
|
+
|
|
225
|
+
export type Effect = "permit" | "forbid";
|
|
226
|
+
|
|
227
|
+
export interface EntityJson {
|
|
228
|
+
uid: EntityUidJson;
|
|
229
|
+
attrs: Record<string, CedarValueJson>;
|
|
230
|
+
parents: EntityUidJson[];
|
|
231
|
+
tags?: Record<string, CedarValueJson>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
235
|
+
|
|
236
|
+
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 } } | { isEmpty: { arg: 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> };
|
|
237
|
+
|
|
238
|
+
export type PatternElem = "Wildcard" | { Literal: SmolStr };
|
|
239
|
+
|
|
240
|
+
export type Expr = ExprNoExt | ExtFuncCall;
|
|
241
|
+
|
|
201
242
|
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 };
|
|
202
243
|
|
|
203
244
|
export interface RecordType<N> {
|
|
@@ -227,13 +268,14 @@ export interface ActionType<N> {
|
|
|
227
268
|
|
|
228
269
|
export type AttributesOrContext<N> = Type<N>;
|
|
229
270
|
|
|
230
|
-
export interface
|
|
271
|
+
export interface StandardEntityType<N> {
|
|
231
272
|
memberOfTypes?: N[];
|
|
232
273
|
shape?: AttributesOrContext<N>;
|
|
233
274
|
tags?: Type<N>;
|
|
234
|
-
annotations?: Annotations;
|
|
235
275
|
}
|
|
236
276
|
|
|
277
|
+
export type EntityTypeKind<N> = StandardEntityType<N> | { enum: NonEmpty<SmolStr> };
|
|
278
|
+
|
|
237
279
|
export interface NamespaceDefinition<N> {
|
|
238
280
|
commonTypes?: Record<CommonTypeId, CommonType<N>>;
|
|
239
281
|
entityTypes: Record<UnreservedId, EntityType<N>>;
|
|
@@ -245,56 +287,14 @@ export type CommonTypeId = string;
|
|
|
245
287
|
|
|
246
288
|
export type SchemaJson<N> = Record<string, NamespaceDefinition<N>>;
|
|
247
289
|
|
|
248
|
-
export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
|
|
249
|
-
|
|
250
|
-
export interface PolicyJson {
|
|
251
|
-
effect: Effect;
|
|
252
|
-
principal: PrincipalConstraint;
|
|
253
|
-
action: ActionConstraint;
|
|
254
|
-
resource: ResourceConstraint;
|
|
255
|
-
conditions: Clause[];
|
|
256
|
-
annotations?: Annotations;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
260
|
-
|
|
261
|
-
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 } } | { isEmpty: { arg: 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> };
|
|
262
|
-
|
|
263
|
-
export type PatternElem = "Wildcard" | { Literal: SmolStr };
|
|
264
|
-
|
|
265
|
-
export type Expr = ExprNoExt | ExtFuncCall;
|
|
266
|
-
|
|
267
290
|
export type AnyId = SmolStr;
|
|
268
291
|
|
|
269
292
|
export type UnreservedId = string;
|
|
270
293
|
|
|
271
|
-
export type Effect = "permit" | "forbid";
|
|
272
|
-
|
|
273
294
|
export type Annotations = Record<string, Annotation>;
|
|
274
295
|
|
|
275
|
-
export type Decision = "allow" | "deny";
|
|
276
|
-
|
|
277
296
|
export type Annotation = SmolStr;
|
|
278
297
|
|
|
279
|
-
export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
|
|
280
|
-
|
|
281
|
-
export interface PrincipalOrResourceIsConstraint {
|
|
282
|
-
entity_type: string;
|
|
283
|
-
in?: PrincipalOrResourceInConstraint;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
|
|
287
|
-
|
|
288
|
-
export type EqConstraint = { entity: EntityUidJson } | { slot: string };
|
|
289
|
-
|
|
290
|
-
export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
291
|
-
|
|
292
|
-
export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
|
|
293
|
-
|
|
294
|
-
export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
295
|
-
|
|
296
|
-
export type Var = "principal" | "action" | "resource" | "context";
|
|
297
|
-
|
|
298
298
|
export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
|
|
299
299
|
|
|
300
300
|
export interface FnAndArg {
|
|
@@ -309,41 +309,52 @@ export interface TypeAndId {
|
|
|
309
309
|
|
|
310
310
|
export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
311
311
|
|
|
312
|
-
export
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
312
|
+
export type Var = "principal" | "action" | "resource" | "context";
|
|
313
|
+
|
|
314
|
+
export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
|
|
315
|
+
|
|
316
|
+
export interface PolicyJson {
|
|
317
|
+
effect: Effect;
|
|
318
|
+
principal: PrincipalConstraint;
|
|
319
|
+
action: ActionConstraint;
|
|
320
|
+
resource: ResourceConstraint;
|
|
321
|
+
conditions: Clause[];
|
|
322
|
+
annotations?: Annotations;
|
|
317
323
|
}
|
|
318
324
|
|
|
325
|
+
export type Decision = "allow" | "deny";
|
|
326
|
+
|
|
319
327
|
|
|
320
328
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
321
329
|
|
|
322
330
|
export interface InitOutput {
|
|
323
331
|
readonly memory: WebAssembly.Memory;
|
|
324
|
-
readonly getValidRequestEnvsTemplate: (a:
|
|
325
|
-
readonly getValidRequestEnvsPolicy: (a:
|
|
326
|
-
readonly getCedarSDKVersion: (
|
|
327
|
-
readonly getCedarVersion: (
|
|
328
|
-
readonly validate: (a:
|
|
329
|
-
readonly
|
|
330
|
-
readonly
|
|
331
|
-
readonly
|
|
332
|
-
readonly
|
|
333
|
-
readonly
|
|
334
|
-
readonly
|
|
335
|
-
readonly
|
|
336
|
-
readonly
|
|
337
|
-
readonly
|
|
338
|
-
readonly
|
|
339
|
-
readonly
|
|
340
|
-
readonly
|
|
341
|
-
readonly
|
|
332
|
+
readonly getValidRequestEnvsTemplate: (a: any, b: any) => any;
|
|
333
|
+
readonly getValidRequestEnvsPolicy: (a: any, b: any) => any;
|
|
334
|
+
readonly getCedarSDKVersion: () => [number, number];
|
|
335
|
+
readonly getCedarVersion: () => [number, number];
|
|
336
|
+
readonly validate: (a: any) => any;
|
|
337
|
+
readonly checkParsePolicySet: (a: any) => any;
|
|
338
|
+
readonly checkParseSchema: (a: any) => any;
|
|
339
|
+
readonly checkParseEntities: (a: any) => any;
|
|
340
|
+
readonly checkParseContext: (a: any) => any;
|
|
341
|
+
readonly formatPolicies: (a: any) => any;
|
|
342
|
+
readonly isAuthorized: (a: any) => any;
|
|
343
|
+
readonly policySetTextToParts: (a: number, b: number) => any;
|
|
344
|
+
readonly policyToText: (a: any) => any;
|
|
345
|
+
readonly templateToText: (a: any) => any;
|
|
346
|
+
readonly policyToJson: (a: any) => any;
|
|
347
|
+
readonly templateToJson: (a: any) => any;
|
|
348
|
+
readonly schemaToText: (a: any) => any;
|
|
349
|
+
readonly schemaToJson: (a: any) => any;
|
|
350
|
+
readonly getCedarLangVersion: () => [number, number];
|
|
342
351
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
352
|
+
readonly __externref_table_alloc: () => number;
|
|
353
|
+
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
343
354
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
344
355
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
345
|
-
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
346
356
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
357
|
+
readonly __wbindgen_start: () => void;
|
|
347
358
|
}
|
|
348
359
|
|
|
349
360
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
@@ -369,3 +380,5 @@ export default function __wbg_init (module_or_path?: { module_or_path: InitInput
|
|
|
369
380
|
type SmolStr = string;
|
|
370
381
|
export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
|
|
371
382
|
export type CommonType<N> = Type<N> & { annotations?: Annotations };
|
|
383
|
+
export type EntityType<N> = EntityTypeKind<N> & { annotations?: Annotations; };
|
|
384
|
+
export type NonEmpty<Type> = Array<Type>;
|