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