@cedar-policy/cedar-wasm 4.2.2 → 4.3.3
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 +92 -112
- package/esm/cedar_wasm_bg.js +113 -72
- package/esm/cedar_wasm_bg.wasm +0 -0
- package/esm/cedar_wasm_bg.wasm.d.ts +23 -21
- package/esm/package.json +4 -4
- package/nodejs/cedar_wasm.d.ts +92 -112
- package/nodejs/cedar_wasm.js +113 -72
- package/nodejs/cedar_wasm_bg.wasm +0 -0
- package/nodejs/cedar_wasm_bg.wasm.d.ts +23 -21
- package/nodejs/package.json +1 -1
- package/package.json +2 -4
- package/web/cedar_wasm.d.ts +98 -116
- package/web/cedar_wasm.js +108 -67
- package/web/cedar_wasm_bg.wasm +0 -0
- package/web/cedar_wasm_bg.wasm.d.ts +23 -21
- package/web/package.json +4 -4
package/web/cedar_wasm.d.ts
CHANGED
|
@@ -2,118 +2,91 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
4
|
* Get valid request environment
|
|
5
|
-
* @param {Template} t
|
|
6
|
-
* @param {Schema} s
|
|
7
|
-
* @returns {GetValidRequestEnvsResult}
|
|
8
5
|
*/
|
|
9
6
|
export function getValidRequestEnvsTemplate(t: Template, s: Schema): GetValidRequestEnvsResult;
|
|
10
7
|
/**
|
|
11
8
|
* Get valid request environment
|
|
12
|
-
* @param {Policy} t
|
|
13
|
-
* @param {Schema} s
|
|
14
|
-
* @returns {GetValidRequestEnvsResult}
|
|
15
9
|
*/
|
|
16
10
|
export function getValidRequestEnvsPolicy(t: Policy, s: Schema): GetValidRequestEnvsResult;
|
|
11
|
+
export function getCedarVersion(): string;
|
|
12
|
+
export function getCedarSDKVersion(): string;
|
|
17
13
|
/**
|
|
18
|
-
*
|
|
14
|
+
* Parse a policy set and optionally validate it against a provided schema
|
|
15
|
+
*
|
|
16
|
+
* This is the basic validator interface, using [`ValidationCall`] and
|
|
17
|
+
* [`ValidationAnswer`] types
|
|
19
18
|
*/
|
|
20
|
-
export function
|
|
19
|
+
export function validate(call: ValidationCall): ValidationAnswer;
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {FormattingCall} call
|
|
24
|
-
* @returns {FormattingAnswer}
|
|
21
|
+
* Get language version of Cedar
|
|
25
22
|
*/
|
|
26
|
-
export function
|
|
23
|
+
export function getCedarLangVersion(): string;
|
|
27
24
|
/**
|
|
28
25
|
* Return the Cedar (textual) representation of a policy.
|
|
29
|
-
* @param {Policy} policy
|
|
30
|
-
* @returns {PolicyToTextAnswer}
|
|
31
26
|
*/
|
|
32
27
|
export function policyToText(policy: Policy): PolicyToTextAnswer;
|
|
33
28
|
/**
|
|
34
29
|
* Return the Cedar (textual) representation of a template.
|
|
35
|
-
* @param {Template} template
|
|
36
|
-
* @returns {PolicyToTextAnswer}
|
|
37
30
|
*/
|
|
38
31
|
export function templateToText(template: Template): PolicyToTextAnswer;
|
|
39
32
|
/**
|
|
40
33
|
* Return the JSON representation of a policy.
|
|
41
|
-
* @param {Policy} policy
|
|
42
|
-
* @returns {PolicyToJsonAnswer}
|
|
43
34
|
*/
|
|
44
35
|
export function policyToJson(policy: Policy): PolicyToJsonAnswer;
|
|
45
36
|
/**
|
|
46
37
|
* Return the JSON representation of a template.
|
|
47
|
-
* @param {Template} template
|
|
48
|
-
* @returns {PolicyToJsonAnswer}
|
|
49
38
|
*/
|
|
50
39
|
export function templateToJson(template: Template): PolicyToJsonAnswer;
|
|
51
40
|
/**
|
|
52
41
|
* Return the Cedar (textual) representation of a schema.
|
|
53
|
-
* @param {Schema} schema
|
|
54
|
-
* @returns {SchemaToTextAnswer}
|
|
55
42
|
*/
|
|
56
43
|
export function schemaToText(schema: Schema): SchemaToTextAnswer;
|
|
57
44
|
/**
|
|
58
45
|
* Return the JSON representation of a schema.
|
|
59
|
-
* @param {Schema} schema
|
|
60
|
-
* @returns {SchemaToJsonAnswer}
|
|
61
46
|
*/
|
|
62
47
|
export function schemaToJson(schema: Schema): SchemaToJsonAnswer;
|
|
63
|
-
/**
|
|
64
|
-
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
65
|
-
* @param {AuthorizationCall} call
|
|
66
|
-
* @returns {AuthorizationAnswer}
|
|
67
|
-
*/
|
|
68
|
-
export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
69
|
-
/**
|
|
70
|
-
* Parse a policy set and optionally validate it against a provided schema
|
|
71
|
-
*
|
|
72
|
-
* This is the basic validator interface, using [`ValidationCall`] and
|
|
73
|
-
* [`ValidationAnswer`] types
|
|
74
|
-
* @param {ValidationCall} call
|
|
75
|
-
* @returns {ValidationAnswer}
|
|
76
|
-
*/
|
|
77
|
-
export function validate(call: ValidationCall): ValidationAnswer;
|
|
78
48
|
/**
|
|
79
49
|
* Check whether a policy set successfully parses.
|
|
80
|
-
* @param {PolicySet} policies
|
|
81
|
-
* @returns {CheckParseAnswer}
|
|
82
50
|
*/
|
|
83
51
|
export function checkParsePolicySet(policies: PolicySet): CheckParseAnswer;
|
|
84
52
|
/**
|
|
85
53
|
* Check whether a schema successfully parses.
|
|
86
|
-
* @param {Schema} schema
|
|
87
|
-
* @returns {CheckParseAnswer}
|
|
88
54
|
*/
|
|
89
55
|
export function checkParseSchema(schema: Schema): CheckParseAnswer;
|
|
90
56
|
/**
|
|
91
57
|
* Check whether a set of entities successfully parses.
|
|
92
|
-
* @param {EntitiesParsingCall} call
|
|
93
|
-
* @returns {CheckParseAnswer}
|
|
94
58
|
*/
|
|
95
59
|
export function checkParseEntities(call: EntitiesParsingCall): CheckParseAnswer;
|
|
96
60
|
/**
|
|
97
61
|
* Check whether a context successfully parses.
|
|
98
|
-
* @param {ContextParsingCall} call
|
|
99
|
-
* @returns {CheckParseAnswer}
|
|
100
62
|
*/
|
|
101
63
|
export function checkParseContext(call: ContextParsingCall): CheckParseAnswer;
|
|
64
|
+
/**
|
|
65
|
+
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
66
|
+
*/
|
|
67
|
+
export function isAuthorized(call: AuthorizationCall): AuthorizationAnswer;
|
|
68
|
+
/**
|
|
69
|
+
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
70
|
+
*/
|
|
71
|
+
export function formatPolicies(call: FormattingCall): FormattingAnswer;
|
|
102
72
|
export type GetValidRequestEnvsResult = { type: "success"; principals: string[]; actions: string[]; resources: string[] } | { type: "failure"; error: string };
|
|
103
73
|
|
|
104
|
-
export
|
|
105
|
-
|
|
106
|
-
|
|
74
|
+
export interface ValidationCall {
|
|
75
|
+
validationSettings?: ValidationSettings;
|
|
76
|
+
schema: Schema;
|
|
77
|
+
policies: PolicySet;
|
|
78
|
+
}
|
|
107
79
|
|
|
108
|
-
export
|
|
80
|
+
export interface ValidationSettings {
|
|
81
|
+
mode: ValidationMode;
|
|
82
|
+
}
|
|
109
83
|
|
|
110
|
-
export interface
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
indentWidth?: number;
|
|
84
|
+
export interface ValidationError {
|
|
85
|
+
policyId: string;
|
|
86
|
+
error: DetailedError;
|
|
114
87
|
}
|
|
115
88
|
|
|
116
|
-
export type
|
|
89
|
+
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
117
90
|
|
|
118
91
|
export type PolicyToTextAnswer = { type: "success"; text: string } | { type: "failure"; errors: DetailedError[] };
|
|
119
92
|
|
|
@@ -123,6 +96,23 @@ export type SchemaToTextAnswer = { type: "success"; text: string; warnings: Deta
|
|
|
123
96
|
|
|
124
97
|
export type SchemaToJsonAnswer = { type: "success"; json: SchemaJson<string>; warnings: DetailedError[] } | { type: "failure"; errors: DetailedError[] };
|
|
125
98
|
|
|
99
|
+
export type SlotId = string;
|
|
100
|
+
|
|
101
|
+
export type PolicyId = string;
|
|
102
|
+
|
|
103
|
+
export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
|
|
104
|
+
|
|
105
|
+
export interface EntitiesParsingCall {
|
|
106
|
+
entities: Entities;
|
|
107
|
+
schema?: Schema | null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface ContextParsingCall {
|
|
111
|
+
context: Context;
|
|
112
|
+
schema?: Schema | null;
|
|
113
|
+
action?: EntityUid | null;
|
|
114
|
+
}
|
|
115
|
+
|
|
126
116
|
export interface Response {
|
|
127
117
|
decision: Decision;
|
|
128
118
|
diagnostics: Diagnostics;
|
|
@@ -151,35 +141,13 @@ export interface AuthorizationCall {
|
|
|
151
141
|
entities: Entities;
|
|
152
142
|
}
|
|
153
143
|
|
|
154
|
-
export interface
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export interface ValidationSettings {
|
|
161
|
-
mode: ValidationMode;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export interface ValidationError {
|
|
165
|
-
policyId: string;
|
|
166
|
-
error: DetailedError;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export type ValidationAnswer = { type: "failure"; errors: DetailedError[]; warnings: DetailedError[] } | { type: "success"; validationErrors: ValidationError[]; validationWarnings: ValidationError[]; otherWarnings: DetailedError[] };
|
|
170
|
-
|
|
171
|
-
export type CheckParseAnswer = { type: "success" } | { type: "failure"; errors: DetailedError[] };
|
|
172
|
-
|
|
173
|
-
export interface EntitiesParsingCall {
|
|
174
|
-
entities: Entities;
|
|
175
|
-
schema?: Schema | null;
|
|
144
|
+
export interface FormattingCall {
|
|
145
|
+
policyText: string;
|
|
146
|
+
lineWidth?: number;
|
|
147
|
+
indentWidth?: number;
|
|
176
148
|
}
|
|
177
149
|
|
|
178
|
-
export
|
|
179
|
-
context: Context;
|
|
180
|
-
schema?: Schema | null;
|
|
181
|
-
action?: EntityUid | null;
|
|
182
|
-
}
|
|
150
|
+
export type FormattingAnswer = { type: "failure"; errors: DetailedError[] } | { type: "success"; formatted_policy: string };
|
|
183
151
|
|
|
184
152
|
export type Schema = string | SchemaJson<string>;
|
|
185
153
|
|
|
@@ -228,6 +196,8 @@ export interface DetailedError {
|
|
|
228
196
|
related?: DetailedError[];
|
|
229
197
|
}
|
|
230
198
|
|
|
199
|
+
export type ValidationMode = "strict";
|
|
200
|
+
|
|
231
201
|
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 };
|
|
232
202
|
|
|
233
203
|
export interface RecordType<N> {
|
|
@@ -235,7 +205,7 @@ export interface RecordType<N> {
|
|
|
235
205
|
additionalAttributes?: boolean;
|
|
236
206
|
}
|
|
237
207
|
|
|
238
|
-
export type Type<N> = TypeVariant<N> | { type: N };
|
|
208
|
+
export type Type<N> = ({} & TypeVariant<N>) | { type: N };
|
|
239
209
|
|
|
240
210
|
export interface ActionEntityUID<N> {
|
|
241
211
|
id: SmolStr;
|
|
@@ -252,6 +222,7 @@ export interface ActionType<N> {
|
|
|
252
222
|
attributes?: Record<SmolStr, CedarValueJson>;
|
|
253
223
|
appliesTo?: ApplySpec<N>;
|
|
254
224
|
memberOf?: ActionEntityUID<N>[];
|
|
225
|
+
annotations?: Annotations;
|
|
255
226
|
}
|
|
256
227
|
|
|
257
228
|
export type AttributesOrContext<N> = Type<N>;
|
|
@@ -260,12 +231,14 @@ export interface EntityType<N> {
|
|
|
260
231
|
memberOfTypes?: N[];
|
|
261
232
|
shape?: AttributesOrContext<N>;
|
|
262
233
|
tags?: Type<N>;
|
|
234
|
+
annotations?: Annotations;
|
|
263
235
|
}
|
|
264
236
|
|
|
265
237
|
export interface NamespaceDefinition<N> {
|
|
266
|
-
commonTypes?: Record<CommonTypeId,
|
|
238
|
+
commonTypes?: Record<CommonTypeId, CommonType<N>>;
|
|
267
239
|
entityTypes: Record<UnreservedId, EntityType<N>>;
|
|
268
240
|
actions: Record<SmolStr, ActionType<N>>;
|
|
241
|
+
annotations?: Annotations;
|
|
269
242
|
}
|
|
270
243
|
|
|
271
244
|
export type CommonTypeId = string;
|
|
@@ -280,45 +253,28 @@ export interface PolicyJson {
|
|
|
280
253
|
action: ActionConstraint;
|
|
281
254
|
resource: ResourceConstraint;
|
|
282
255
|
conditions: Clause[];
|
|
283
|
-
annotations?:
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export type Effect = "permit" | "forbid";
|
|
287
|
-
|
|
288
|
-
export type UnreservedId = string;
|
|
289
|
-
|
|
290
|
-
export interface EntityJson {
|
|
291
|
-
uid: EntityUidJson;
|
|
292
|
-
attrs: Record<string, CedarValueJson>;
|
|
293
|
-
parents: EntityUidJson[];
|
|
294
|
-
tags?: Record<string, CedarValueJson>;
|
|
256
|
+
annotations?: Annotations;
|
|
295
257
|
}
|
|
296
258
|
|
|
297
|
-
export type Decision = "allow" | "deny";
|
|
298
|
-
|
|
299
|
-
export type Var = "principal" | "action" | "resource" | "context";
|
|
300
|
-
|
|
301
259
|
export type ExtFuncCall = {} & Record<string, Array<Expr>>;
|
|
302
260
|
|
|
303
|
-
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 } } | { 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> };
|
|
261
|
+
export type ExprNoExt = { Value: CedarValueJson } | { Var: Var } | { Slot: string } | { "!": { arg: Expr } } | { neg: { arg: Expr } } | { "==": { left: Expr; right: Expr } } | { "!=": { left: Expr; right: Expr } } | { in: { left: Expr; right: Expr } } | { "<": { left: Expr; right: Expr } } | { "<=": { left: Expr; right: Expr } } | { ">": { left: Expr; right: Expr } } | { ">=": { left: Expr; right: Expr } } | { "&&": { left: Expr; right: Expr } } | { "||": { left: Expr; right: Expr } } | { "+": { left: Expr; right: Expr } } | { "-": { left: Expr; right: Expr } } | { "*": { left: Expr; right: Expr } } | { contains: { left: Expr; right: Expr } } | { containsAll: { left: Expr; right: Expr } } | { containsAny: { left: Expr; right: Expr } } | { isEmpty: { arg: Expr } } | { getTag: { left: Expr; right: Expr } } | { hasTag: { left: Expr; right: Expr } } | { ".": { left: Expr; attr: SmolStr } } | { has: { left: Expr; attr: SmolStr } } | { like: { left: Expr; pattern: PatternElem[] } } | { is: { left: Expr; entity_type: SmolStr; in?: Expr } } | { "if-then-else": { if: Expr; then: Expr; else: Expr } } | { Set: Expr[] } | { Record: Record<string, Expr> };
|
|
304
262
|
|
|
305
263
|
export type PatternElem = "Wildcard" | { Literal: SmolStr };
|
|
306
264
|
|
|
307
265
|
export type Expr = ExprNoExt | ExtFuncCall;
|
|
308
266
|
|
|
309
|
-
export type
|
|
267
|
+
export type AnyId = SmolStr;
|
|
310
268
|
|
|
311
|
-
export
|
|
312
|
-
fn: string;
|
|
313
|
-
arg: CedarValueJson;
|
|
314
|
-
}
|
|
269
|
+
export type UnreservedId = string;
|
|
315
270
|
|
|
316
|
-
export
|
|
317
|
-
type: string;
|
|
318
|
-
id: string;
|
|
319
|
-
}
|
|
271
|
+
export type Effect = "permit" | "forbid";
|
|
320
272
|
|
|
321
|
-
export type
|
|
273
|
+
export type Annotations = Record<string, Annotation>;
|
|
274
|
+
|
|
275
|
+
export type Decision = "allow" | "deny";
|
|
276
|
+
|
|
277
|
+
export type Annotation = SmolStr;
|
|
322
278
|
|
|
323
279
|
export type ActionInConstraint = { entity: EntityUidJson } | { entities: EntityUidJson[] };
|
|
324
280
|
|
|
@@ -337,6 +293,29 @@ export type ActionConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | (
|
|
|
337
293
|
|
|
338
294
|
export type PrincipalConstraint = { op: "All" } | ({ op: "==" } & EqConstraint) | ({ op: "in" } & PrincipalOrResourceInConstraint) | ({ op: "is" } & PrincipalOrResourceIsConstraint);
|
|
339
295
|
|
|
296
|
+
export type Var = "principal" | "action" | "resource" | "context";
|
|
297
|
+
|
|
298
|
+
export type EntityUidJson = { __entity: TypeAndId } | TypeAndId;
|
|
299
|
+
|
|
300
|
+
export interface FnAndArg {
|
|
301
|
+
fn: string;
|
|
302
|
+
arg: CedarValueJson;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export interface TypeAndId {
|
|
306
|
+
type: string;
|
|
307
|
+
id: string;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export type CedarValueJson = { __entity: TypeAndId } | { __extn: FnAndArg } | boolean | number | string | CedarValueJson[] | { [key: string]: CedarValueJson } | null;
|
|
311
|
+
|
|
312
|
+
export interface EntityJson {
|
|
313
|
+
uid: EntityUidJson;
|
|
314
|
+
attrs: Record<string, CedarValueJson>;
|
|
315
|
+
parents: EntityUidJson[];
|
|
316
|
+
tags?: Record<string, CedarValueJson>;
|
|
317
|
+
}
|
|
318
|
+
|
|
340
319
|
|
|
341
320
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
342
321
|
|
|
@@ -344,25 +323,27 @@ export interface InitOutput {
|
|
|
344
323
|
readonly memory: WebAssembly.Memory;
|
|
345
324
|
readonly getValidRequestEnvsTemplate: (a: number, b: number) => number;
|
|
346
325
|
readonly getValidRequestEnvsPolicy: (a: number, b: number) => number;
|
|
326
|
+
readonly getCedarSDKVersion: (a: number) => void;
|
|
347
327
|
readonly getCedarVersion: (a: number) => void;
|
|
348
|
-
readonly
|
|
328
|
+
readonly validate: (a: number) => number;
|
|
329
|
+
readonly getCedarLangVersion: (a: number) => void;
|
|
349
330
|
readonly policyToText: (a: number) => number;
|
|
350
331
|
readonly templateToText: (a: number) => number;
|
|
351
332
|
readonly policyToJson: (a: number) => number;
|
|
352
333
|
readonly templateToJson: (a: number) => number;
|
|
353
334
|
readonly schemaToText: (a: number) => number;
|
|
354
335
|
readonly schemaToJson: (a: number) => number;
|
|
355
|
-
readonly isAuthorized: (a: number) => number;
|
|
356
|
-
readonly validate: (a: number) => number;
|
|
357
336
|
readonly checkParsePolicySet: (a: number) => number;
|
|
358
337
|
readonly checkParseSchema: (a: number) => number;
|
|
359
338
|
readonly checkParseEntities: (a: number) => number;
|
|
360
339
|
readonly checkParseContext: (a: number) => number;
|
|
340
|
+
readonly isAuthorized: (a: number) => number;
|
|
341
|
+
readonly formatPolicies: (a: number) => number;
|
|
342
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
361
343
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
362
344
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
363
345
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
364
346
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
365
|
-
readonly __wbindgen_exn_store: (a: number) => void;
|
|
366
347
|
}
|
|
367
348
|
|
|
368
349
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
@@ -387,3 +368,4 @@ export function initSync(module: { module: SyncInitInput } | SyncInitInput): Ini
|
|
|
387
368
|
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
388
369
|
type SmolStr = string;
|
|
389
370
|
export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
|
|
371
|
+
export type CommonType<N> = Type<N> & { annotations?: Annotations };
|
package/web/cedar_wasm.js
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
let wasm;
|
|
2
2
|
|
|
3
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
4
|
+
|
|
5
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
6
|
+
|
|
7
|
+
let cachedUint8ArrayMemory0 = null;
|
|
8
|
+
|
|
9
|
+
function getUint8ArrayMemory0() {
|
|
10
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
11
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
12
|
+
}
|
|
13
|
+
return cachedUint8ArrayMemory0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getStringFromWasm0(ptr, len) {
|
|
17
|
+
ptr = ptr >>> 0;
|
|
18
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
19
|
+
}
|
|
20
|
+
|
|
3
21
|
const heap = new Array(128).fill(undefined);
|
|
4
22
|
|
|
5
23
|
heap.push(undefined, null, true, false);
|
|
6
24
|
|
|
7
|
-
function getObject(idx) { return heap[idx]; }
|
|
8
|
-
|
|
9
25
|
let heap_next = heap.length;
|
|
10
26
|
|
|
11
27
|
function addHeapObject(obj) {
|
|
@@ -17,6 +33,16 @@ function addHeapObject(obj) {
|
|
|
17
33
|
return idx;
|
|
18
34
|
}
|
|
19
35
|
|
|
36
|
+
function handleError(f, args) {
|
|
37
|
+
try {
|
|
38
|
+
return f.apply(this, args);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getObject(idx) { return heap[idx]; }
|
|
45
|
+
|
|
20
46
|
function dropObject(idx) {
|
|
21
47
|
if (idx < 132) return;
|
|
22
48
|
heap[idx] = heap_next;
|
|
@@ -31,15 +57,6 @@ function takeObject(idx) {
|
|
|
31
57
|
|
|
32
58
|
let WASM_VECTOR_LEN = 0;
|
|
33
59
|
|
|
34
|
-
let cachedUint8ArrayMemory0 = null;
|
|
35
|
-
|
|
36
|
-
function getUint8ArrayMemory0() {
|
|
37
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
38
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
39
|
-
}
|
|
40
|
-
return cachedUint8ArrayMemory0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
60
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
44
61
|
|
|
45
62
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
@@ -106,15 +123,6 @@ function getDataViewMemory0() {
|
|
|
106
123
|
}
|
|
107
124
|
return cachedDataViewMemory0;
|
|
108
125
|
}
|
|
109
|
-
|
|
110
|
-
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
111
|
-
|
|
112
|
-
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
113
|
-
|
|
114
|
-
function getStringFromWasm0(ptr, len) {
|
|
115
|
-
ptr = ptr >>> 0;
|
|
116
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
117
|
-
}
|
|
118
126
|
/**
|
|
119
127
|
* Get valid request environment
|
|
120
128
|
* @param {Template} t
|
|
@@ -145,7 +153,7 @@ export function getCedarVersion() {
|
|
|
145
153
|
let deferred1_1;
|
|
146
154
|
try {
|
|
147
155
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
148
|
-
wasm.
|
|
156
|
+
wasm.getCedarSDKVersion(retptr);
|
|
149
157
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
150
158
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
151
159
|
deferred1_0 = r0;
|
|
@@ -158,15 +166,59 @@ export function getCedarVersion() {
|
|
|
158
166
|
}
|
|
159
167
|
|
|
160
168
|
/**
|
|
161
|
-
*
|
|
162
|
-
* @param {FormattingCall} call
|
|
163
|
-
* @returns {FormattingAnswer}
|
|
169
|
+
* @returns {string}
|
|
164
170
|
*/
|
|
165
|
-
export function
|
|
166
|
-
|
|
171
|
+
export function getCedarSDKVersion() {
|
|
172
|
+
let deferred1_0;
|
|
173
|
+
let deferred1_1;
|
|
174
|
+
try {
|
|
175
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
176
|
+
wasm.getCedarSDKVersion(retptr);
|
|
177
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
178
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
179
|
+
deferred1_0 = r0;
|
|
180
|
+
deferred1_1 = r1;
|
|
181
|
+
return getStringFromWasm0(r0, r1);
|
|
182
|
+
} finally {
|
|
183
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
184
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Parse a policy set and optionally validate it against a provided schema
|
|
190
|
+
*
|
|
191
|
+
* This is the basic validator interface, using [`ValidationCall`] and
|
|
192
|
+
* [`ValidationAnswer`] types
|
|
193
|
+
* @param {ValidationCall} call
|
|
194
|
+
* @returns {ValidationAnswer}
|
|
195
|
+
*/
|
|
196
|
+
export function validate(call) {
|
|
197
|
+
const ret = wasm.validate(addHeapObject(call));
|
|
167
198
|
return takeObject(ret);
|
|
168
199
|
}
|
|
169
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Get language version of Cedar
|
|
203
|
+
* @returns {string}
|
|
204
|
+
*/
|
|
205
|
+
export function getCedarLangVersion() {
|
|
206
|
+
let deferred1_0;
|
|
207
|
+
let deferred1_1;
|
|
208
|
+
try {
|
|
209
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
210
|
+
wasm.getCedarLangVersion(retptr);
|
|
211
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
212
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
213
|
+
deferred1_0 = r0;
|
|
214
|
+
deferred1_1 = r1;
|
|
215
|
+
return getStringFromWasm0(r0, r1);
|
|
216
|
+
} finally {
|
|
217
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
218
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
170
222
|
/**
|
|
171
223
|
* Return the Cedar (textual) representation of a policy.
|
|
172
224
|
* @param {Policy} policy
|
|
@@ -227,29 +279,6 @@ export function schemaToJson(schema) {
|
|
|
227
279
|
return takeObject(ret);
|
|
228
280
|
}
|
|
229
281
|
|
|
230
|
-
/**
|
|
231
|
-
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
232
|
-
* @param {AuthorizationCall} call
|
|
233
|
-
* @returns {AuthorizationAnswer}
|
|
234
|
-
*/
|
|
235
|
-
export function isAuthorized(call) {
|
|
236
|
-
const ret = wasm.isAuthorized(addHeapObject(call));
|
|
237
|
-
return takeObject(ret);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Parse a policy set and optionally validate it against a provided schema
|
|
242
|
-
*
|
|
243
|
-
* This is the basic validator interface, using [`ValidationCall`] and
|
|
244
|
-
* [`ValidationAnswer`] types
|
|
245
|
-
* @param {ValidationCall} call
|
|
246
|
-
* @returns {ValidationAnswer}
|
|
247
|
-
*/
|
|
248
|
-
export function validate(call) {
|
|
249
|
-
const ret = wasm.validate(addHeapObject(call));
|
|
250
|
-
return takeObject(ret);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
282
|
/**
|
|
254
283
|
* Check whether a policy set successfully parses.
|
|
255
284
|
* @param {PolicySet} policies
|
|
@@ -290,12 +319,24 @@ export function checkParseContext(call) {
|
|
|
290
319
|
return takeObject(ret);
|
|
291
320
|
}
|
|
292
321
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
322
|
+
/**
|
|
323
|
+
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
324
|
+
* @param {AuthorizationCall} call
|
|
325
|
+
* @returns {AuthorizationAnswer}
|
|
326
|
+
*/
|
|
327
|
+
export function isAuthorized(call) {
|
|
328
|
+
const ret = wasm.isAuthorized(addHeapObject(call));
|
|
329
|
+
return takeObject(ret);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
334
|
+
* @param {FormattingCall} call
|
|
335
|
+
* @returns {FormattingAnswer}
|
|
336
|
+
*/
|
|
337
|
+
export function formatPolicies(call) {
|
|
338
|
+
const ret = wasm.formatPolicies(addHeapObject(call));
|
|
339
|
+
return takeObject(ret);
|
|
299
340
|
}
|
|
300
341
|
|
|
301
342
|
async function __wbg_load(module, imports) {
|
|
@@ -332,6 +373,18 @@ async function __wbg_load(module, imports) {
|
|
|
332
373
|
function __wbg_get_imports() {
|
|
333
374
|
const imports = {};
|
|
334
375
|
imports.wbg = {};
|
|
376
|
+
imports.wbg.__wbg_parse_def2e24ef1252aff = function() { return handleError(function (arg0, arg1) {
|
|
377
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
378
|
+
return addHeapObject(ret);
|
|
379
|
+
}, arguments) };
|
|
380
|
+
imports.wbg.__wbg_stringify_f7ed6987935b4a24 = function() { return handleError(function (arg0) {
|
|
381
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
382
|
+
return addHeapObject(ret);
|
|
383
|
+
}, arguments) };
|
|
384
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
385
|
+
const ret = getObject(arg0) === undefined;
|
|
386
|
+
return ret;
|
|
387
|
+
};
|
|
335
388
|
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
336
389
|
const ret = getObject(arg0);
|
|
337
390
|
return addHeapObject(ret);
|
|
@@ -339,10 +392,6 @@ function __wbg_get_imports() {
|
|
|
339
392
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
340
393
|
takeObject(arg0);
|
|
341
394
|
};
|
|
342
|
-
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
343
|
-
const ret = getObject(arg0) === undefined;
|
|
344
|
-
return ret;
|
|
345
|
-
};
|
|
346
395
|
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
347
396
|
const obj = getObject(arg1);
|
|
348
397
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
@@ -351,14 +400,6 @@ function __wbg_get_imports() {
|
|
|
351
400
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
352
401
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
353
402
|
};
|
|
354
|
-
imports.wbg.__wbg_parse_51ee5409072379d3 = function() { return handleError(function (arg0, arg1) {
|
|
355
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
356
|
-
return addHeapObject(ret);
|
|
357
|
-
}, arguments) };
|
|
358
|
-
imports.wbg.__wbg_stringify_eead5648c09faaf8 = function() { return handleError(function (arg0) {
|
|
359
|
-
const ret = JSON.stringify(getObject(arg0));
|
|
360
|
-
return addHeapObject(ret);
|
|
361
|
-
}, arguments) };
|
|
362
403
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
363
404
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
364
405
|
};
|
package/web/cedar_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
4
|
+
export const getValidRequestEnvsTemplate: (a: number, b: number) => number;
|
|
5
|
+
export const getValidRequestEnvsPolicy: (a: number, b: number) => number;
|
|
6
|
+
export const getCedarSDKVersion: (a: number) => void;
|
|
7
|
+
export const getCedarVersion: (a: number) => void;
|
|
8
|
+
export const validate: (a: number) => number;
|
|
9
|
+
export const getCedarLangVersion: (a: number) => void;
|
|
10
|
+
export const policyToText: (a: number) => number;
|
|
11
|
+
export const templateToText: (a: number) => number;
|
|
12
|
+
export const policyToJson: (a: number) => number;
|
|
13
|
+
export const templateToJson: (a: number) => number;
|
|
14
|
+
export const schemaToText: (a: number) => number;
|
|
15
|
+
export const schemaToJson: (a: number) => number;
|
|
16
|
+
export const checkParsePolicySet: (a: number) => number;
|
|
17
|
+
export const checkParseSchema: (a: number) => number;
|
|
18
|
+
export const checkParseEntities: (a: number) => number;
|
|
19
|
+
export const checkParseContext: (a: number) => number;
|
|
20
|
+
export const isAuthorized: (a: number) => number;
|
|
21
|
+
export const formatPolicies: (a: number) => number;
|
|
22
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
23
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
24
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
25
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
26
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|