@cedar-policy/cedar-wasm 4.8.0 → 4.8.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.
- package/esm/cedar_wasm.d.ts +245 -223
- package/esm/cedar_wasm_bg.js +170 -178
- package/esm/cedar_wasm_bg.wasm +0 -0
- package/esm/cedar_wasm_bg.wasm.d.ts +2 -2
- package/esm/package.json +1 -1
- package/nodejs/cedar_wasm.d.ts +245 -223
- package/nodejs/cedar_wasm.js +211 -196
- package/nodejs/cedar_wasm_bg.wasm +0 -0
- package/nodejs/cedar_wasm_bg.wasm.d.ts +2 -2
- package/nodejs/package.json +1 -1
- package/package.json +1 -1
- package/web/cedar_wasm.d.ts +248 -225
- package/web/cedar_wasm.js +171 -183
- package/web/cedar_wasm_bg.wasm +0 -0
- package/web/cedar_wasm_bg.wasm.d.ts +2 -2
- package/web/package.json +1 -1
package/esm/cedar_wasm.d.ts
CHANGED
|
@@ -1,125 +1,55 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export function getCedarVersion(): string;
|
|
4
|
-
export function getCedarSDKVersion(): string;
|
|
5
|
-
/**
|
|
6
|
-
* Get valid request environment
|
|
7
|
-
*/
|
|
8
|
-
export function getValidRequestEnvsPolicy(t: Policy, s: Schema): GetValidRequestEnvsResult;
|
|
9
|
-
/**
|
|
10
|
-
* Get valid request environment
|
|
11
|
-
*/
|
|
12
|
-
export function getValidRequestEnvsTemplate(t: Template, s: Schema): GetValidRequestEnvsResult;
|
|
13
|
-
/**
|
|
14
|
-
* Preparse and cache a schema in thread-local storage
|
|
15
|
-
*
|
|
16
|
-
* # Errors
|
|
17
|
-
*
|
|
18
|
-
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
19
|
-
*/
|
|
20
|
-
export function preparseSchema(schema_name: string, schema: Schema): CheckParseAnswer;
|
|
21
|
-
/**
|
|
22
|
-
* Preparse and cache a policy set in thread-local storage
|
|
23
|
-
*
|
|
24
|
-
* # Errors
|
|
25
|
-
*
|
|
26
|
-
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
27
|
-
*/
|
|
28
|
-
export function preparsePolicySet(pset_id: string, policies: PolicySet): CheckParseAnswer;
|
|
29
|
-
/**
|
|
30
|
-
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
31
|
-
*/
|
|
32
|
-
export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
33
|
-
/**
|
|
34
|
-
* Stateful authorization using preparsed schemas and policy sets.
|
|
35
|
-
*
|
|
36
|
-
* This function works like [`is_authorized`] but retrieves schemas and policy sets
|
|
37
|
-
* from thread-local cache instead of parsing them on each call.
|
|
38
|
-
*/
|
|
39
|
-
export function statefulIsAuthorized(call: StatefulAuthorizationCall): AuthorizationAnswer;
|
|
40
|
-
/**
|
|
41
|
-
* Get language version of Cedar
|
|
42
|
-
*/
|
|
43
|
-
export function getCedarLangVersion(): string;
|
|
44
|
-
/**
|
|
45
|
-
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
46
|
-
*/
|
|
47
|
-
export function formatPolicies(call: FormattingCall): FormattingAnswer;
|
|
48
|
-
/**
|
|
49
|
-
* Parse a policy set and optionally validate it against a provided schema
|
|
50
|
-
*
|
|
51
|
-
* This is the basic validator interface, using [`ValidationCall`] and
|
|
52
|
-
* [`ValidationAnswer`] types
|
|
53
|
-
*/
|
|
54
|
-
export function validate(call: ValidationCall): ValidationAnswer;
|
|
55
|
-
/**
|
|
56
|
-
* Check whether a context successfully parses.
|
|
57
|
-
*/
|
|
58
|
-
export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
|
|
59
|
-
/**
|
|
60
|
-
* Check whether a schema successfully parses.
|
|
61
|
-
*/
|
|
62
|
-
export function checkParseSchema(schema: Schema): CheckParseAnswer;
|
|
63
|
-
/**
|
|
64
|
-
* Check whether a policy set successfully parses.
|
|
65
|
-
*/
|
|
66
|
-
export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
|
|
67
|
-
/**
|
|
68
|
-
* Check whether a set of entities successfully parses.
|
|
69
|
-
*/
|
|
70
|
-
export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
|
|
71
|
-
/**
|
|
72
|
-
* Return the JSON representation of a schema.
|
|
73
|
-
*/
|
|
74
|
-
export function schemaToJson(schema: Schema): SchemaToJsonAnswer;
|
|
75
|
-
/**
|
|
76
|
-
* Return the Cedar (textual) representation of a schema.
|
|
77
|
-
*/
|
|
78
|
-
export function schemaToText(schema: Schema): SchemaToTextAnswer;
|
|
79
|
-
/**
|
|
80
|
-
* Takes a `PolicySet` represented as string and return the policies
|
|
81
|
-
* and templates split into vecs and sorted by id.
|
|
82
|
-
*/
|
|
83
|
-
export function policySetTextToParts(policyset_str: string): PolicySetTextToPartsAnswer;
|
|
84
|
-
/**
|
|
85
|
-
* Return the Cedar (textual) representation of a policy.
|
|
86
|
-
*/
|
|
87
|
-
export function policyToText(policy: Policy): PolicyToTextAnswer;
|
|
88
|
-
/**
|
|
89
|
-
* Return the JSON representation of a policy.
|
|
90
|
-
*/
|
|
91
|
-
export function policyToJson(policy: Policy): PolicyToJsonAnswer;
|
|
92
|
-
/**
|
|
93
|
-
* Return the Cedar (textual) representation of a template.
|
|
94
|
-
*/
|
|
95
|
-
export function templateToText(template: Template): PolicyToTextAnswer;
|
|
96
|
-
/**
|
|
97
|
-
* Return the JSON representation of a template.
|
|
98
|
-
*/
|
|
99
|
-
export function templateToJson(template: Template): PolicyToJsonAnswer;
|
|
100
3
|
export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
|
|
101
4
|
|
|
102
|
-
export type
|
|
5
|
+
export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
|
|
103
6
|
|
|
104
|
-
export
|
|
7
|
+
export interface FormattingCall {
|
|
8
|
+
policyText: string;
|
|
9
|
+
lineWidth?: number;
|
|
10
|
+
indentWidth?: number;
|
|
11
|
+
}
|
|
105
12
|
|
|
106
|
-
export type
|
|
13
|
+
export type ValidationMode = "strict";
|
|
107
14
|
|
|
108
|
-
export
|
|
15
|
+
export interface AuthorizationCall {
|
|
16
|
+
principal: EntityUid;
|
|
17
|
+
action: EntityUid;
|
|
18
|
+
resource: EntityUid;
|
|
19
|
+
context: Context;
|
|
20
|
+
schema?: Schema;
|
|
21
|
+
validateRequest?: boolean;
|
|
22
|
+
policies: PolicySet;
|
|
23
|
+
entities: Entities;
|
|
24
|
+
}
|
|
109
25
|
|
|
110
|
-
export
|
|
111
|
-
|
|
26
|
+
export type AuthorizationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; response: Response; warnings: DetailedError[] };
|
|
27
|
+
|
|
28
|
+
export interface AuthorizationError {
|
|
29
|
+
policyId: string;
|
|
30
|
+
error: DetailedError;
|
|
112
31
|
}
|
|
113
32
|
|
|
114
|
-
export
|
|
33
|
+
export interface StatefulAuthorizationCall {
|
|
34
|
+
principal: EntityUid;
|
|
35
|
+
action: EntityUid;
|
|
36
|
+
resource: EntityUid;
|
|
37
|
+
context: Context;
|
|
38
|
+
preparsedSchemaName?: string;
|
|
39
|
+
validateRequest?: boolean;
|
|
40
|
+
preparsedPolicySetId: string;
|
|
41
|
+
entities: Entities;
|
|
42
|
+
}
|
|
115
43
|
|
|
116
|
-
export interface
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
templateLinks?: TemplateLink[];
|
|
44
|
+
export interface Diagnostics {
|
|
45
|
+
reason: PolicyId[];
|
|
46
|
+
errors: AuthorizationError[];
|
|
120
47
|
}
|
|
121
48
|
|
|
122
|
-
export
|
|
49
|
+
export interface Response {
|
|
50
|
+
decision: Decision;
|
|
51
|
+
diagnostics: Diagnostics;
|
|
52
|
+
}
|
|
123
53
|
|
|
124
54
|
export interface DetailedError {
|
|
125
55
|
message: string;
|
|
@@ -131,10 +61,16 @@ export interface DetailedError {
|
|
|
131
61
|
related?: DetailedError[];
|
|
132
62
|
}
|
|
133
63
|
|
|
134
|
-
export type
|
|
64
|
+
export type StaticPolicySet = string | Policy[] | Record<PolicyId, Policy>;
|
|
135
65
|
|
|
136
66
|
export type Entities = Array<EntityJson>;
|
|
137
67
|
|
|
68
|
+
export interface PolicySet {
|
|
69
|
+
staticPolicies?: StaticPolicySet;
|
|
70
|
+
templates?: Record<PolicyId, Template>;
|
|
71
|
+
templateLinks?: TemplateLink[];
|
|
72
|
+
}
|
|
73
|
+
|
|
138
74
|
export interface SourceLocation {
|
|
139
75
|
start: number;
|
|
140
76
|
end: number;
|
|
@@ -146,64 +82,21 @@ export interface TemplateLink {
|
|
|
146
82
|
values: Record<SlotId, EntityUid>;
|
|
147
83
|
}
|
|
148
84
|
|
|
149
|
-
export type
|
|
150
|
-
|
|
151
|
-
export type StaticPolicySet = string | Policy[] | Record<PolicyId, Policy>;
|
|
152
|
-
|
|
153
|
-
export interface StatefulAuthorizationCall {
|
|
154
|
-
principal: EntityUid;
|
|
155
|
-
action: EntityUid;
|
|
156
|
-
resource: EntityUid;
|
|
157
|
-
context: Context;
|
|
158
|
-
preparsedSchemaName?: string;
|
|
159
|
-
validateRequest?: boolean;
|
|
160
|
-
preparsedPolicySetId: string;
|
|
161
|
-
entities: Entities;
|
|
162
|
-
}
|
|
85
|
+
export type Severity = "advice" | "warning" | "error";
|
|
163
86
|
|
|
164
|
-
export
|
|
165
|
-
policyId: string;
|
|
166
|
-
error: DetailedError;
|
|
167
|
-
}
|
|
87
|
+
export type Schema = string | SchemaJson<string>;
|
|
168
88
|
|
|
169
|
-
export
|
|
170
|
-
reason: PolicyId[];
|
|
171
|
-
errors: AuthorizationError[];
|
|
172
|
-
}
|
|
89
|
+
export type Context = Record<string, CedarValueJson>;
|
|
173
90
|
|
|
174
|
-
export
|
|
175
|
-
decision: Decision;
|
|
176
|
-
diagnostics: Diagnostics;
|
|
177
|
-
}
|
|
91
|
+
export type Policy = string | PolicyJson;
|
|
178
92
|
|
|
179
|
-
export interface
|
|
180
|
-
|
|
181
|
-
action: EntityUid;
|
|
182
|
-
resource: EntityUid;
|
|
183
|
-
context: Context;
|
|
184
|
-
schema?: Schema;
|
|
185
|
-
validateRequest?: boolean;
|
|
186
|
-
policies: PolicySet;
|
|
187
|
-
entities: Entities;
|
|
93
|
+
export interface SourceLabel extends SourceLocation {
|
|
94
|
+
label: string | null;
|
|
188
95
|
}
|
|
189
96
|
|
|
190
|
-
export type
|
|
191
|
-
|
|
192
|
-
export type ValidationMode = "strict";
|
|
193
|
-
|
|
194
|
-
export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
|
|
195
|
-
|
|
196
|
-
export interface FormattingCall {
|
|
197
|
-
policyText: string;
|
|
198
|
-
lineWidth?: number;
|
|
199
|
-
indentWidth?: number;
|
|
200
|
-
}
|
|
97
|
+
export type EntityUid = EntityUidJson;
|
|
201
98
|
|
|
202
|
-
export
|
|
203
|
-
validationSettings?: ValidationSettings;
|
|
204
|
-
schema: Schema;
|
|
205
|
-
policies: PolicySet;
|
|
206
|
-
}
|
|
99
|
+
export type Template = string | PolicyJson;
|
|
207
100
|
|
|
208
101
|
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
209
102
|
|
|
@@ -216,6 +109,12 @@ export interface ValidationSettings {
|
|
|
216
109
|
mode: ValidationMode;
|
|
217
110
|
}
|
|
218
111
|
|
|
112
|
+
export interface ValidationCall {
|
|
113
|
+
validationSettings?: ValidationSettings;
|
|
114
|
+
schema: Schema;
|
|
115
|
+
policies: PolicySet;
|
|
116
|
+
}
|
|
117
|
+
|
|
219
118
|
export interface ContextParsingCall {
|
|
220
119
|
context: Context;
|
|
221
120
|
schema?: Schema | null;
|
|
@@ -229,49 +128,23 @@ export interface EntitiesParsingCall {
|
|
|
229
128
|
|
|
230
129
|
export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
|
|
231
130
|
|
|
232
|
-
export type
|
|
131
|
+
export type PolicyId = string;
|
|
233
132
|
|
|
234
|
-
export type
|
|
133
|
+
export type SlotId = string;
|
|
235
134
|
|
|
236
135
|
export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
|
|
237
136
|
|
|
238
|
-
export type
|
|
137
|
+
export type PolicyToJsonAnswer = { type: "success"; json: PolicyJson } | { type: "failure"; errors: DetailedError[] };
|
|
239
138
|
|
|
240
139
|
export type PolicySetTextToPartsAnswer = { type: "success"; policies: string[]; policy_templates: string[] } | { type: "failure"; errors: DetailedError[] };
|
|
241
140
|
|
|
242
|
-
export type
|
|
243
|
-
|
|
244
|
-
export type Decision = "allow" | "deny";
|
|
245
|
-
|
|
246
|
-
export type Effect = "permit" | "forbid";
|
|
247
|
-
|
|
248
|
-
export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
|
|
249
|
-
|
|
250
|
-
export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
|
|
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 PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
257
|
-
|
|
258
|
-
export interface PrincipalOrResourceIsConstraint {
|
|
259
|
-
entity_type: string;
|
|
260
|
-
in?: PrincipalOrResourceInConstraint;
|
|
261
|
-
}
|
|
141
|
+
export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
|
|
262
142
|
|
|
263
|
-
export type
|
|
143
|
+
export type SchemaToTextAnswer = { type: "success"; text: string; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
|
|
264
144
|
|
|
265
|
-
export type
|
|
145
|
+
export type Annotation = SmolStr;
|
|
266
146
|
|
|
267
|
-
export
|
|
268
|
-
effect: Effect;
|
|
269
|
-
principal: PrincipalConstraint;
|
|
270
|
-
action: ActionConstraint;
|
|
271
|
-
resource: ResourceConstraint;
|
|
272
|
-
conditions: Clause[];
|
|
273
|
-
annotations?: Annotations;
|
|
274
|
-
}
|
|
147
|
+
export type Annotations = Record<string, Annotation>;
|
|
275
148
|
|
|
276
149
|
export interface EntityJson {
|
|
277
150
|
uid: EntityUidJson;
|
|
@@ -280,30 +153,26 @@ export interface EntityJson {
|
|
|
280
153
|
tags?: Record<string, CedarValueJson>;
|
|
281
154
|
}
|
|
282
155
|
|
|
283
|
-
export type
|
|
156
|
+
export type Var = "principal" | "action" | "resource" | "context";
|
|
284
157
|
|
|
285
|
-
export type
|
|
158
|
+
export type Decision = "allow" | "deny";
|
|
286
159
|
|
|
287
|
-
export type
|
|
160
|
+
export type AnyId = SmolStr;
|
|
288
161
|
|
|
289
|
-
export type
|
|
162
|
+
export type UnreservedId = string;
|
|
290
163
|
|
|
291
|
-
export type
|
|
164
|
+
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 };
|
|
292
165
|
|
|
293
|
-
export type
|
|
166
|
+
export type Type<N> = ({} & TypeVariant<N>) | { type: N };
|
|
294
167
|
|
|
295
|
-
export interface
|
|
296
|
-
|
|
297
|
-
|
|
168
|
+
export interface RecordType<N> {
|
|
169
|
+
attributes: Record<SmolStr, TypeOfAttribute<N>>;
|
|
170
|
+
additionalAttributes?: boolean;
|
|
298
171
|
}
|
|
299
172
|
|
|
300
|
-
export type
|
|
301
|
-
|
|
302
|
-
export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArgs } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
303
|
-
|
|
304
|
-
export type AnyId = SmolStr;
|
|
173
|
+
export type CommonTypeId = string;
|
|
305
174
|
|
|
306
|
-
export type
|
|
175
|
+
export type AttributesOrContext<N> = Type<N>;
|
|
307
176
|
|
|
308
177
|
export interface ActionEntityUID<N> {
|
|
309
178
|
id: SmolStr;
|
|
@@ -317,7 +186,9 @@ export interface ActionType<N> {
|
|
|
317
186
|
annotations?: Annotations;
|
|
318
187
|
}
|
|
319
188
|
|
|
320
|
-
export type
|
|
189
|
+
export type SchemaJson<N> = Record<string, NamespaceDefinition<N>>;
|
|
190
|
+
|
|
191
|
+
export type EntityTypeKind<N> = StandardEntityType<N> | { enum: NonEmpty<SmolStr> };
|
|
321
192
|
|
|
322
193
|
export interface NamespaceDefinition<N> {
|
|
323
194
|
commonTypes?: Record<CommonTypeId, CommonType<N>>;
|
|
@@ -326,7 +197,11 @@ export interface NamespaceDefinition<N> {
|
|
|
326
197
|
annotations?: Annotations;
|
|
327
198
|
}
|
|
328
199
|
|
|
329
|
-
export
|
|
200
|
+
export interface StandardEntityType<N> {
|
|
201
|
+
memberOfTypes?: N[];
|
|
202
|
+
shape?: AttributesOrContext<N>;
|
|
203
|
+
tags?: Type<N>;
|
|
204
|
+
}
|
|
330
205
|
|
|
331
206
|
export interface ApplySpec<N> {
|
|
332
207
|
resourceTypes: N[];
|
|
@@ -334,27 +209,174 @@ export interface ApplySpec<N> {
|
|
|
334
209
|
context?: AttributesOrContext<N>;
|
|
335
210
|
}
|
|
336
211
|
|
|
337
|
-
export type
|
|
212
|
+
export type Effect = "permit" | "forbid";
|
|
338
213
|
|
|
339
|
-
export type
|
|
214
|
+
export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
340
215
|
|
|
341
|
-
export interface
|
|
342
|
-
|
|
343
|
-
|
|
216
|
+
export interface PrincipalOrResourceIsConstraint {
|
|
217
|
+
entity_type: string;
|
|
218
|
+
in?: PrincipalOrResourceInConstraint;
|
|
344
219
|
}
|
|
345
220
|
|
|
346
|
-
export type
|
|
221
|
+
export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & ActionInConstraint);
|
|
347
222
|
|
|
348
|
-
export type
|
|
223
|
+
export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
|
|
349
224
|
|
|
350
|
-
export
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
225
|
+
export type PrincipalOrResourceInConstraint = { entity: EntityUidJson } | { slot: string };
|
|
226
|
+
|
|
227
|
+
export type ResourceConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
228
|
+
|
|
229
|
+
export type EqConstraint = { entity: EntityUidJson } | { slot: string };
|
|
230
|
+
|
|
231
|
+
export type Clause = { kind: "when"; body: Expr } | { kind: "unless"; body: Expr };
|
|
232
|
+
|
|
233
|
+
export interface PolicyJson {
|
|
234
|
+
effect: Effect;
|
|
235
|
+
principal: PrincipalConstraint;
|
|
236
|
+
action: ActionConstraint;
|
|
237
|
+
resource: ResourceConstraint;
|
|
238
|
+
conditions: Clause[];
|
|
239
|
+
annotations?: Annotations;
|
|
354
240
|
}
|
|
355
241
|
|
|
356
|
-
export type
|
|
242
|
+
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
243
|
+
|
|
244
|
+
export type Expr = ExprNoExt | ExtFuncCall;
|
|
245
|
+
|
|
246
|
+
export type PatternElem = "Wildcard" | { Literal: SmolStr };
|
|
247
|
+
|
|
248
|
+
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> };
|
|
249
|
+
|
|
250
|
+
export interface TypeAndId {
|
|
251
|
+
type: string;
|
|
252
|
+
id: string;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArgs } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
256
|
+
|
|
257
|
+
export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
|
|
258
|
+
|
|
259
|
+
export type FnAndArgs = { fn: string; arg: CedarValueJson } | { fn: string; args: CedarValueJson[] };
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Check whether a context successfully parses.
|
|
264
|
+
*/
|
|
265
|
+
export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Check whether a set of entities successfully parses.
|
|
269
|
+
*/
|
|
270
|
+
export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Check whether a policy set successfully parses.
|
|
274
|
+
*/
|
|
275
|
+
export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Check whether a schema successfully parses.
|
|
279
|
+
*/
|
|
280
|
+
export function checkParseSchema(schema: Schema): CheckParseAnswer;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
284
|
+
*/
|
|
285
|
+
export function formatPolicies(call: FormattingCall): FormattingAnswer;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Get language version of Cedar
|
|
289
|
+
*/
|
|
290
|
+
export function getCedarLangVersion(): string;
|
|
291
|
+
|
|
292
|
+
export function getCedarSDKVersion(): string;
|
|
293
|
+
|
|
294
|
+
export function getCedarVersion(): string;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Get valid request environment
|
|
298
|
+
*/
|
|
299
|
+
export function getValidRequestEnvsPolicy(t: Policy, s: Schema): GetValidRequestEnvsResult;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Get valid request environment
|
|
303
|
+
*/
|
|
304
|
+
export function getValidRequestEnvsTemplate(t: Template, s: Schema): GetValidRequestEnvsResult;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
308
|
+
*/
|
|
309
|
+
export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Takes a `PolicySet` represented as string and return the policies
|
|
313
|
+
* and templates split into vecs and sorted by id.
|
|
314
|
+
*/
|
|
315
|
+
export function policySetTextToParts(policyset_str: string): PolicySetTextToPartsAnswer;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Return the JSON representation of a policy.
|
|
319
|
+
*/
|
|
320
|
+
export function policyToJson(policy: Policy): PolicyToJsonAnswer;
|
|
357
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Return the Cedar (textual) representation of a policy.
|
|
324
|
+
*/
|
|
325
|
+
export function policyToText(policy: Policy): PolicyToTextAnswer;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Preparse and cache a policy set in thread-local storage
|
|
329
|
+
*
|
|
330
|
+
* # Errors
|
|
331
|
+
*
|
|
332
|
+
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
333
|
+
*/
|
|
334
|
+
export function preparsePolicySet(pset_id: string, policies: PolicySet): CheckParseAnswer;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Preparse and cache a schema in thread-local storage
|
|
338
|
+
*
|
|
339
|
+
* # Errors
|
|
340
|
+
*
|
|
341
|
+
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
342
|
+
*/
|
|
343
|
+
export function preparseSchema(schema_name: string, schema: Schema): CheckParseAnswer;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Return the JSON representation of a schema.
|
|
347
|
+
*/
|
|
348
|
+
export function schemaToJson(schema: Schema): SchemaToJsonAnswer;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Return the Cedar (textual) representation of a schema.
|
|
352
|
+
*/
|
|
353
|
+
export function schemaToText(schema: Schema): SchemaToTextAnswer;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Stateful authorization using preparsed schemas and policy sets.
|
|
357
|
+
*
|
|
358
|
+
* This function works like [`is_authorized`] but retrieves schemas and policy sets
|
|
359
|
+
* from thread-local cache instead of parsing them on each call.
|
|
360
|
+
*/
|
|
361
|
+
export function statefulIsAuthorized(call: StatefulAuthorizationCall): AuthorizationAnswer;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Return the JSON representation of a template.
|
|
365
|
+
*/
|
|
366
|
+
export function templateToJson(template: Template): PolicyToJsonAnswer;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Return the Cedar (textual) representation of a template.
|
|
370
|
+
*/
|
|
371
|
+
export function templateToText(template: Template): PolicyToTextAnswer;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Parse a policy set and optionally validate it against a provided schema
|
|
375
|
+
*
|
|
376
|
+
* This is the basic validator interface, using [`ValidationCall`] and
|
|
377
|
+
* [`ValidationAnswer`] types
|
|
378
|
+
*/
|
|
379
|
+
export function validate(call: ValidationCall): ValidationAnswer;
|
|
358
380
|
type SmolStr = string;
|
|
359
381
|
export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
|
|
360
382
|
export type CommonType<N> = Type<N> & { annotations?: Annotations };
|