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