@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/nodejs/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?:
|
|
256
|
+
annotations?: Annotations;
|
|
284
257
|
}
|
|
285
258
|
|
|
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>;
|
|
295
|
-
}
|
|
296
|
-
|
|
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,5 +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
|
type SmolStr = string;
|
|
341
320
|
export type TypeOfAttribute<N> = Type<N> & { required?: boolean };
|
|
321
|
+
export type CommonType<N> = Type<N> & { annotations?: Annotations };
|
package/nodejs/cedar_wasm.js
CHANGED
|
@@ -2,14 +2,30 @@
|
|
|
2
2
|
let imports = {};
|
|
3
3
|
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
4
|
let wasm;
|
|
5
|
-
const {
|
|
5
|
+
const { TextDecoder, TextEncoder } = require(`util`);
|
|
6
|
+
|
|
7
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
8
|
+
|
|
9
|
+
cachedTextDecoder.decode();
|
|
10
|
+
|
|
11
|
+
let cachedUint8ArrayMemory0 = null;
|
|
12
|
+
|
|
13
|
+
function getUint8ArrayMemory0() {
|
|
14
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
15
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
16
|
+
}
|
|
17
|
+
return cachedUint8ArrayMemory0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getStringFromWasm0(ptr, len) {
|
|
21
|
+
ptr = ptr >>> 0;
|
|
22
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
23
|
+
}
|
|
6
24
|
|
|
7
25
|
const heap = new Array(128).fill(undefined);
|
|
8
26
|
|
|
9
27
|
heap.push(undefined, null, true, false);
|
|
10
28
|
|
|
11
|
-
function getObject(idx) { return heap[idx]; }
|
|
12
|
-
|
|
13
29
|
let heap_next = heap.length;
|
|
14
30
|
|
|
15
31
|
function addHeapObject(obj) {
|
|
@@ -21,6 +37,16 @@ function addHeapObject(obj) {
|
|
|
21
37
|
return idx;
|
|
22
38
|
}
|
|
23
39
|
|
|
40
|
+
function handleError(f, args) {
|
|
41
|
+
try {
|
|
42
|
+
return f.apply(this, args);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getObject(idx) { return heap[idx]; }
|
|
49
|
+
|
|
24
50
|
function dropObject(idx) {
|
|
25
51
|
if (idx < 132) return;
|
|
26
52
|
heap[idx] = heap_next;
|
|
@@ -35,15 +61,6 @@ function takeObject(idx) {
|
|
|
35
61
|
|
|
36
62
|
let WASM_VECTOR_LEN = 0;
|
|
37
63
|
|
|
38
|
-
let cachedUint8ArrayMemory0 = null;
|
|
39
|
-
|
|
40
|
-
function getUint8ArrayMemory0() {
|
|
41
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
42
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
43
|
-
}
|
|
44
|
-
return cachedUint8ArrayMemory0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
64
|
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
48
65
|
|
|
49
66
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
@@ -110,15 +127,6 @@ function getDataViewMemory0() {
|
|
|
110
127
|
}
|
|
111
128
|
return cachedDataViewMemory0;
|
|
112
129
|
}
|
|
113
|
-
|
|
114
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
115
|
-
|
|
116
|
-
cachedTextDecoder.decode();
|
|
117
|
-
|
|
118
|
-
function getStringFromWasm0(ptr, len) {
|
|
119
|
-
ptr = ptr >>> 0;
|
|
120
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
121
|
-
}
|
|
122
130
|
/**
|
|
123
131
|
* Get valid request environment
|
|
124
132
|
* @param {Template} t
|
|
@@ -149,7 +157,7 @@ module.exports.getCedarVersion = function() {
|
|
|
149
157
|
let deferred1_1;
|
|
150
158
|
try {
|
|
151
159
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
152
|
-
wasm.
|
|
160
|
+
wasm.getCedarSDKVersion(retptr);
|
|
153
161
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
154
162
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
155
163
|
deferred1_0 = r0;
|
|
@@ -162,15 +170,59 @@ module.exports.getCedarVersion = function() {
|
|
|
162
170
|
};
|
|
163
171
|
|
|
164
172
|
/**
|
|
165
|
-
*
|
|
166
|
-
* @param {FormattingCall} call
|
|
167
|
-
* @returns {FormattingAnswer}
|
|
173
|
+
* @returns {string}
|
|
168
174
|
*/
|
|
169
|
-
module.exports.
|
|
170
|
-
|
|
175
|
+
module.exports.getCedarSDKVersion = function() {
|
|
176
|
+
let deferred1_0;
|
|
177
|
+
let deferred1_1;
|
|
178
|
+
try {
|
|
179
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
180
|
+
wasm.getCedarSDKVersion(retptr);
|
|
181
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
182
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
183
|
+
deferred1_0 = r0;
|
|
184
|
+
deferred1_1 = r1;
|
|
185
|
+
return getStringFromWasm0(r0, r1);
|
|
186
|
+
} finally {
|
|
187
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
188
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Parse a policy set and optionally validate it against a provided schema
|
|
194
|
+
*
|
|
195
|
+
* This is the basic validator interface, using [`ValidationCall`] and
|
|
196
|
+
* [`ValidationAnswer`] types
|
|
197
|
+
* @param {ValidationCall} call
|
|
198
|
+
* @returns {ValidationAnswer}
|
|
199
|
+
*/
|
|
200
|
+
module.exports.validate = function(call) {
|
|
201
|
+
const ret = wasm.validate(addHeapObject(call));
|
|
171
202
|
return takeObject(ret);
|
|
172
203
|
};
|
|
173
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Get language version of Cedar
|
|
207
|
+
* @returns {string}
|
|
208
|
+
*/
|
|
209
|
+
module.exports.getCedarLangVersion = function() {
|
|
210
|
+
let deferred1_0;
|
|
211
|
+
let deferred1_1;
|
|
212
|
+
try {
|
|
213
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
214
|
+
wasm.getCedarLangVersion(retptr);
|
|
215
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
216
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
217
|
+
deferred1_0 = r0;
|
|
218
|
+
deferred1_1 = r1;
|
|
219
|
+
return getStringFromWasm0(r0, r1);
|
|
220
|
+
} finally {
|
|
221
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
222
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
174
226
|
/**
|
|
175
227
|
* Return the Cedar (textual) representation of a policy.
|
|
176
228
|
* @param {Policy} policy
|
|
@@ -231,29 +283,6 @@ module.exports.schemaToJson = function(schema) {
|
|
|
231
283
|
return takeObject(ret);
|
|
232
284
|
};
|
|
233
285
|
|
|
234
|
-
/**
|
|
235
|
-
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
236
|
-
* @param {AuthorizationCall} call
|
|
237
|
-
* @returns {AuthorizationAnswer}
|
|
238
|
-
*/
|
|
239
|
-
module.exports.isAuthorized = function(call) {
|
|
240
|
-
const ret = wasm.isAuthorized(addHeapObject(call));
|
|
241
|
-
return takeObject(ret);
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Parse a policy set and optionally validate it against a provided schema
|
|
246
|
-
*
|
|
247
|
-
* This is the basic validator interface, using [`ValidationCall`] and
|
|
248
|
-
* [`ValidationAnswer`] types
|
|
249
|
-
* @param {ValidationCall} call
|
|
250
|
-
* @returns {ValidationAnswer}
|
|
251
|
-
*/
|
|
252
|
-
module.exports.validate = function(call) {
|
|
253
|
-
const ret = wasm.validate(addHeapObject(call));
|
|
254
|
-
return takeObject(ret);
|
|
255
|
-
};
|
|
256
|
-
|
|
257
286
|
/**
|
|
258
287
|
* Check whether a policy set successfully parses.
|
|
259
288
|
* @param {PolicySet} policies
|
|
@@ -294,13 +323,40 @@ module.exports.checkParseContext = function(call) {
|
|
|
294
323
|
return takeObject(ret);
|
|
295
324
|
};
|
|
296
325
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
326
|
+
/**
|
|
327
|
+
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
328
|
+
* @param {AuthorizationCall} call
|
|
329
|
+
* @returns {AuthorizationAnswer}
|
|
330
|
+
*/
|
|
331
|
+
module.exports.isAuthorized = function(call) {
|
|
332
|
+
const ret = wasm.isAuthorized(addHeapObject(call));
|
|
333
|
+
return takeObject(ret);
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
338
|
+
* @param {FormattingCall} call
|
|
339
|
+
* @returns {FormattingAnswer}
|
|
340
|
+
*/
|
|
341
|
+
module.exports.formatPolicies = function(call) {
|
|
342
|
+
const ret = wasm.formatPolicies(addHeapObject(call));
|
|
343
|
+
return takeObject(ret);
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
module.exports.__wbg_parse_def2e24ef1252aff = function() { return handleError(function (arg0, arg1) {
|
|
347
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
348
|
+
return addHeapObject(ret);
|
|
349
|
+
}, arguments) };
|
|
350
|
+
|
|
351
|
+
module.exports.__wbg_stringify_f7ed6987935b4a24 = function() { return handleError(function (arg0) {
|
|
352
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
353
|
+
return addHeapObject(ret);
|
|
354
|
+
}, arguments) };
|
|
355
|
+
|
|
356
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
357
|
+
const ret = getObject(arg0) === undefined;
|
|
358
|
+
return ret;
|
|
359
|
+
};
|
|
304
360
|
|
|
305
361
|
module.exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
306
362
|
const ret = getObject(arg0);
|
|
@@ -311,11 +367,6 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
311
367
|
takeObject(arg0);
|
|
312
368
|
};
|
|
313
369
|
|
|
314
|
-
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
315
|
-
const ret = getObject(arg0) === undefined;
|
|
316
|
-
return ret;
|
|
317
|
-
};
|
|
318
|
-
|
|
319
370
|
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
320
371
|
const obj = getObject(arg1);
|
|
321
372
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
@@ -325,16 +376,6 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
|
325
376
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
326
377
|
};
|
|
327
378
|
|
|
328
|
-
module.exports.__wbg_parse_51ee5409072379d3 = function() { return handleError(function (arg0, arg1) {
|
|
329
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
330
|
-
return addHeapObject(ret);
|
|
331
|
-
}, arguments) };
|
|
332
|
-
|
|
333
|
-
module.exports.__wbg_stringify_eead5648c09faaf8 = function() { return handleError(function (arg0) {
|
|
334
|
-
const ret = JSON.stringify(getObject(arg0));
|
|
335
|
-
return addHeapObject(ret);
|
|
336
|
-
}, arguments) };
|
|
337
|
-
|
|
338
379
|
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
339
380
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
340
381
|
};
|
|
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;
|
package/nodejs/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedar-policy/cedar-wasm",
|
|
3
|
-
"type": "module",
|
|
4
3
|
"description": "Wasm bindings and typescript types for Cedar lib",
|
|
5
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.3",
|
|
6
5
|
"license": "Apache-2.0",
|
|
7
6
|
"files": [
|
|
8
7
|
"esm/package.json",
|
|
@@ -25,12 +24,11 @@
|
|
|
25
24
|
"web/cedar_wasm.js",
|
|
26
25
|
"web/cedar_wasm.d.ts"
|
|
27
26
|
],
|
|
28
|
-
"
|
|
27
|
+
"module": "esm/cedar_wasm.js",
|
|
29
28
|
"types": "esm/cedar_wasm.d.ts",
|
|
30
29
|
"sideEffects": [
|
|
31
30
|
"./snippets/*"
|
|
32
31
|
],
|
|
33
|
-
"module": "esm/cedar_wasm.js",
|
|
34
32
|
"exports": {
|
|
35
33
|
".": {
|
|
36
34
|
"import": "./esm/cedar_wasm.js",
|