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