@cedar-policy/cedar-wasm 4.5.1 → 4.7.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 +191 -157
- package/esm/cedar_wasm_bg.js +160 -107
- package/esm/cedar_wasm_bg.wasm +0 -0
- package/esm/cedar_wasm_bg.wasm.d.ts +6 -3
- package/esm/package.json +1 -1
- package/nodejs/cedar_wasm.d.ts +191 -157
- package/nodejs/cedar_wasm.js +159 -115
- package/nodejs/cedar_wasm_bg.wasm +0 -0
- package/nodejs/cedar_wasm_bg.wasm.d.ts +6 -3
- package/nodejs/package.json +1 -1
- package/package.json +1 -1
- package/web/cedar_wasm.d.ts +197 -160
- package/web/cedar_wasm.js +164 -103
- package/web/cedar_wasm_bg.wasm +0 -0
- package/web/cedar_wasm_bg.wasm.d.ts +6 -3
- package/web/package.json +1 -1
package/esm/cedar_wasm_bg.js
CHANGED
|
@@ -4,12 +4,6 @@ export function __wbg_set_wasm(val) {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
8
|
-
|
|
9
|
-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
10
|
-
|
|
11
|
-
cachedTextDecoder.decode();
|
|
12
|
-
|
|
13
7
|
let cachedUint8ArrayMemory0 = null;
|
|
14
8
|
|
|
15
9
|
function getUint8ArrayMemory0() {
|
|
@@ -19,9 +13,25 @@ function getUint8ArrayMemory0() {
|
|
|
19
13
|
return cachedUint8ArrayMemory0;
|
|
20
14
|
}
|
|
21
15
|
|
|
16
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
17
|
+
|
|
18
|
+
cachedTextDecoder.decode();
|
|
19
|
+
|
|
20
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
21
|
+
let numBytesDecoded = 0;
|
|
22
|
+
function decodeText(ptr, len) {
|
|
23
|
+
numBytesDecoded += len;
|
|
24
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
25
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
26
|
+
cachedTextDecoder.decode();
|
|
27
|
+
numBytesDecoded = len;
|
|
28
|
+
}
|
|
29
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
function getStringFromWasm0(ptr, len) {
|
|
23
33
|
ptr = ptr >>> 0;
|
|
24
|
-
return
|
|
34
|
+
return decodeText(ptr, len);
|
|
25
35
|
}
|
|
26
36
|
|
|
27
37
|
function addToExternrefTable0(obj) {
|
|
@@ -41,22 +51,18 @@ function handleError(f, args) {
|
|
|
41
51
|
|
|
42
52
|
let WASM_VECTOR_LEN = 0;
|
|
43
53
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
54
|
+
const cachedTextEncoder = new TextEncoder();
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
57
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
58
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
59
|
+
view.set(buf);
|
|
60
|
+
return {
|
|
61
|
+
read: arg.length,
|
|
62
|
+
written: buf.length
|
|
63
|
+
};
|
|
64
|
+
}
|
|
51
65
|
}
|
|
52
|
-
: function (arg, view) {
|
|
53
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
54
|
-
view.set(buf);
|
|
55
|
-
return {
|
|
56
|
-
read: arg.length,
|
|
57
|
-
written: buf.length
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
66
|
|
|
61
67
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
62
68
|
|
|
@@ -87,7 +93,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
87
93
|
}
|
|
88
94
|
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
89
95
|
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
90
|
-
const ret =
|
|
96
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
91
97
|
|
|
92
98
|
offset += ret.written;
|
|
93
99
|
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
@@ -112,11 +118,11 @@ function getDataViewMemory0() {
|
|
|
112
118
|
/**
|
|
113
119
|
* @returns {string}
|
|
114
120
|
*/
|
|
115
|
-
export function
|
|
121
|
+
export function getCedarSDKVersion() {
|
|
116
122
|
let deferred1_0;
|
|
117
123
|
let deferred1_1;
|
|
118
124
|
try {
|
|
119
|
-
const ret = wasm.
|
|
125
|
+
const ret = wasm.getCedarSDKVersion();
|
|
120
126
|
deferred1_0 = ret[0];
|
|
121
127
|
deferred1_1 = ret[1];
|
|
122
128
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
@@ -128,11 +134,11 @@ export function getCedarVersion() {
|
|
|
128
134
|
/**
|
|
129
135
|
* @returns {string}
|
|
130
136
|
*/
|
|
131
|
-
export function
|
|
137
|
+
export function getCedarVersion() {
|
|
132
138
|
let deferred1_0;
|
|
133
139
|
let deferred1_1;
|
|
134
140
|
try {
|
|
135
|
-
const ret = wasm.
|
|
141
|
+
const ret = wasm.getCedarVersion();
|
|
136
142
|
deferred1_0 = ret[0];
|
|
137
143
|
deferred1_1 = ret[1];
|
|
138
144
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
@@ -143,43 +149,80 @@ export function getCedarSDKVersion() {
|
|
|
143
149
|
|
|
144
150
|
/**
|
|
145
151
|
* Get valid request environment
|
|
146
|
-
* @param {
|
|
152
|
+
* @param {Policy} t
|
|
147
153
|
* @param {Schema} s
|
|
148
154
|
* @returns {GetValidRequestEnvsResult}
|
|
149
155
|
*/
|
|
150
|
-
export function
|
|
151
|
-
const ret = wasm.
|
|
156
|
+
export function getValidRequestEnvsPolicy(t, s) {
|
|
157
|
+
const ret = wasm.getValidRequestEnvsPolicy(t, s);
|
|
152
158
|
return ret;
|
|
153
159
|
}
|
|
154
160
|
|
|
155
161
|
/**
|
|
156
162
|
* Get valid request environment
|
|
157
|
-
* @param {
|
|
163
|
+
* @param {Template} t
|
|
158
164
|
* @param {Schema} s
|
|
159
165
|
* @returns {GetValidRequestEnvsResult}
|
|
160
166
|
*/
|
|
161
|
-
export function
|
|
162
|
-
const ret = wasm.
|
|
167
|
+
export function getValidRequestEnvsTemplate(t, s) {
|
|
168
|
+
const ret = wasm.getValidRequestEnvsTemplate(t, s);
|
|
163
169
|
return ret;
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
173
|
+
* Stateful authorization using preparsed schemas and policy sets.
|
|
174
|
+
*
|
|
175
|
+
* This function works like [`is_authorized`] but retrieves schemas and policy sets
|
|
176
|
+
* from thread-local cache instead of parsing them on each call.
|
|
177
|
+
* @param {StatefulAuthorizationCall} call
|
|
178
|
+
* @returns {AuthorizationAnswer}
|
|
179
|
+
*/
|
|
180
|
+
export function statefulIsAuthorized(call) {
|
|
181
|
+
const ret = wasm.statefulIsAuthorized(call);
|
|
182
|
+
return ret;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
187
|
+
* @param {AuthorizationCall} call
|
|
188
|
+
* @returns {AuthorizationAnswer}
|
|
189
|
+
*/
|
|
190
|
+
export function isAuthorized(call) {
|
|
191
|
+
const ret = wasm.isAuthorized(call);
|
|
192
|
+
return ret;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Preparse and cache a policy set in thread-local storage
|
|
197
|
+
*
|
|
198
|
+
* # Errors
|
|
199
|
+
*
|
|
200
|
+
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
201
|
+
* @param {string} pset_id
|
|
202
|
+
* @param {PolicySet} policies
|
|
169
203
|
* @returns {CheckParseAnswer}
|
|
170
204
|
*/
|
|
171
|
-
export function
|
|
172
|
-
const
|
|
205
|
+
export function preparsePolicySet(pset_id, policies) {
|
|
206
|
+
const ptr0 = passStringToWasm0(pset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
207
|
+
const len0 = WASM_VECTOR_LEN;
|
|
208
|
+
const ret = wasm.preparsePolicySet(ptr0, len0, policies);
|
|
173
209
|
return ret;
|
|
174
210
|
}
|
|
175
211
|
|
|
176
212
|
/**
|
|
177
|
-
*
|
|
213
|
+
* Preparse and cache a schema in thread-local storage
|
|
214
|
+
*
|
|
215
|
+
* # Errors
|
|
216
|
+
*
|
|
217
|
+
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
218
|
+
* @param {string} schema_name
|
|
178
219
|
* @param {Schema} schema
|
|
179
220
|
* @returns {CheckParseAnswer}
|
|
180
221
|
*/
|
|
181
|
-
export function
|
|
182
|
-
const
|
|
222
|
+
export function preparseSchema(schema_name, schema) {
|
|
223
|
+
const ptr0 = passStringToWasm0(schema_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
224
|
+
const len0 = WASM_VECTOR_LEN;
|
|
225
|
+
const ret = wasm.preparseSchema(ptr0, len0, schema);
|
|
183
226
|
return ret;
|
|
184
227
|
}
|
|
185
228
|
|
|
@@ -204,32 +247,22 @@ export function checkParseContext(call) {
|
|
|
204
247
|
}
|
|
205
248
|
|
|
206
249
|
/**
|
|
207
|
-
*
|
|
208
|
-
* @param {
|
|
209
|
-
* @returns {
|
|
210
|
-
*/
|
|
211
|
-
export function formatPolicies(call) {
|
|
212
|
-
const ret = wasm.formatPolicies(call);
|
|
213
|
-
return ret;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Return the Cedar (textual) representation of a template.
|
|
218
|
-
* @param {Template} template
|
|
219
|
-
* @returns {PolicyToTextAnswer}
|
|
250
|
+
* Check whether a schema successfully parses.
|
|
251
|
+
* @param {Schema} schema
|
|
252
|
+
* @returns {CheckParseAnswer}
|
|
220
253
|
*/
|
|
221
|
-
export function
|
|
222
|
-
const ret = wasm.
|
|
254
|
+
export function checkParseSchema(schema) {
|
|
255
|
+
const ret = wasm.checkParseSchema(schema);
|
|
223
256
|
return ret;
|
|
224
257
|
}
|
|
225
258
|
|
|
226
259
|
/**
|
|
227
|
-
*
|
|
228
|
-
* @param {
|
|
229
|
-
* @returns {
|
|
260
|
+
* Check whether a set of entities successfully parses.
|
|
261
|
+
* @param {EntitiesParsingCall} call
|
|
262
|
+
* @returns {CheckParseAnswer}
|
|
230
263
|
*/
|
|
231
|
-
export function
|
|
232
|
-
const ret = wasm.
|
|
264
|
+
export function checkParseEntities(call) {
|
|
265
|
+
const ret = wasm.checkParseEntities(call);
|
|
233
266
|
return ret;
|
|
234
267
|
}
|
|
235
268
|
|
|
@@ -247,22 +280,12 @@ export function policySetTextToParts(policyset_str) {
|
|
|
247
280
|
}
|
|
248
281
|
|
|
249
282
|
/**
|
|
250
|
-
* Return the JSON representation of a
|
|
251
|
-
* @param {
|
|
252
|
-
* @returns {
|
|
253
|
-
*/
|
|
254
|
-
export function schemaToJson(schema) {
|
|
255
|
-
const ret = wasm.schemaToJson(schema);
|
|
256
|
-
return ret;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Return the Cedar (textual) representation of a schema.
|
|
261
|
-
* @param {Schema} schema
|
|
262
|
-
* @returns {SchemaToTextAnswer}
|
|
283
|
+
* Return the JSON representation of a template.
|
|
284
|
+
* @param {Template} template
|
|
285
|
+
* @returns {PolicyToJsonAnswer}
|
|
263
286
|
*/
|
|
264
|
-
export function
|
|
265
|
-
const ret = wasm.
|
|
287
|
+
export function templateToJson(template) {
|
|
288
|
+
const ret = wasm.templateToJson(template);
|
|
266
289
|
return ret;
|
|
267
290
|
}
|
|
268
291
|
|
|
@@ -277,35 +300,42 @@ export function policyToText(policy) {
|
|
|
277
300
|
}
|
|
278
301
|
|
|
279
302
|
/**
|
|
280
|
-
* Return the JSON representation of a
|
|
303
|
+
* Return the JSON representation of a schema.
|
|
304
|
+
* @param {Schema} schema
|
|
305
|
+
* @returns {SchemaToJsonAnswer}
|
|
306
|
+
*/
|
|
307
|
+
export function schemaToJson(schema) {
|
|
308
|
+
const ret = wasm.schemaToJson(schema);
|
|
309
|
+
return ret;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Return the Cedar (textual) representation of a template.
|
|
281
314
|
* @param {Template} template
|
|
282
|
-
* @returns {
|
|
315
|
+
* @returns {PolicyToTextAnswer}
|
|
283
316
|
*/
|
|
284
|
-
export function
|
|
285
|
-
const ret = wasm.
|
|
317
|
+
export function templateToText(template) {
|
|
318
|
+
const ret = wasm.templateToText(template);
|
|
286
319
|
return ret;
|
|
287
320
|
}
|
|
288
321
|
|
|
289
322
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
* [`ValidationAnswer`] types
|
|
294
|
-
* @param {ValidationCall} call
|
|
295
|
-
* @returns {ValidationAnswer}
|
|
323
|
+
* Return the JSON representation of a policy.
|
|
324
|
+
* @param {Policy} policy
|
|
325
|
+
* @returns {PolicyToJsonAnswer}
|
|
296
326
|
*/
|
|
297
|
-
export function
|
|
298
|
-
const ret = wasm.
|
|
327
|
+
export function policyToJson(policy) {
|
|
328
|
+
const ret = wasm.policyToJson(policy);
|
|
299
329
|
return ret;
|
|
300
330
|
}
|
|
301
331
|
|
|
302
332
|
/**
|
|
303
|
-
*
|
|
304
|
-
* @param {
|
|
305
|
-
* @returns {
|
|
333
|
+
* Return the Cedar (textual) representation of a schema.
|
|
334
|
+
* @param {Schema} schema
|
|
335
|
+
* @returns {SchemaToTextAnswer}
|
|
306
336
|
*/
|
|
307
|
-
export function
|
|
308
|
-
const ret = wasm.
|
|
337
|
+
export function schemaToText(schema) {
|
|
338
|
+
const ret = wasm.schemaToText(schema);
|
|
309
339
|
return ret;
|
|
310
340
|
}
|
|
311
341
|
|
|
@@ -326,33 +356,45 @@ export function getCedarLangVersion() {
|
|
|
326
356
|
}
|
|
327
357
|
}
|
|
328
358
|
|
|
329
|
-
|
|
359
|
+
/**
|
|
360
|
+
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
361
|
+
* @param {FormattingCall} call
|
|
362
|
+
* @returns {FormattingAnswer}
|
|
363
|
+
*/
|
|
364
|
+
export function formatPolicies(call) {
|
|
365
|
+
const ret = wasm.formatPolicies(call);
|
|
366
|
+
return ret;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Parse a policy set and optionally validate it against a provided schema
|
|
371
|
+
*
|
|
372
|
+
* This is the basic validator interface, using [`ValidationCall`] and
|
|
373
|
+
* [`ValidationAnswer`] types
|
|
374
|
+
* @param {ValidationCall} call
|
|
375
|
+
* @returns {ValidationAnswer}
|
|
376
|
+
*/
|
|
377
|
+
export function validate(call) {
|
|
378
|
+
const ret = wasm.validate(call);
|
|
379
|
+
return ret;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export function __wbg_parse_442f5ba02e5eaf8b() { return handleError(function (arg0, arg1) {
|
|
330
383
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
331
384
|
return ret;
|
|
332
385
|
}, arguments) };
|
|
333
386
|
|
|
334
|
-
export function
|
|
387
|
+
export function __wbg_stringify_b98c93d0a190446a() { return handleError(function (arg0) {
|
|
335
388
|
const ret = JSON.stringify(arg0);
|
|
336
389
|
return ret;
|
|
337
390
|
}, arguments) };
|
|
338
391
|
|
|
339
|
-
export function
|
|
340
|
-
const table = wasm.__wbindgen_export_2;
|
|
341
|
-
const offset = table.grow(4);
|
|
342
|
-
table.set(0, undefined);
|
|
343
|
-
table.set(offset + 0, undefined);
|
|
344
|
-
table.set(offset + 1, null);
|
|
345
|
-
table.set(offset + 2, true);
|
|
346
|
-
table.set(offset + 3, false);
|
|
347
|
-
;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
export function __wbindgen_is_undefined(arg0) {
|
|
392
|
+
export function __wbg_wbindgenisundefined_c4b71d073b92f3c5(arg0) {
|
|
351
393
|
const ret = arg0 === undefined;
|
|
352
394
|
return ret;
|
|
353
395
|
};
|
|
354
396
|
|
|
355
|
-
export function
|
|
397
|
+
export function __wbg_wbindgenstringget_0f16a6ddddef376f(arg0, arg1) {
|
|
356
398
|
const obj = arg1;
|
|
357
399
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
358
400
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -361,7 +403,18 @@ export function __wbindgen_string_get(arg0, arg1) {
|
|
|
361
403
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
362
404
|
};
|
|
363
405
|
|
|
364
|
-
export function
|
|
406
|
+
export function __wbg_wbindgenthrow_451ec1a8469d7eb6(arg0, arg1) {
|
|
365
407
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
366
408
|
};
|
|
367
409
|
|
|
410
|
+
export function __wbindgen_init_externref_table() {
|
|
411
|
+
const table = wasm.__wbindgen_export_2;
|
|
412
|
+
const offset = table.grow(4);
|
|
413
|
+
table.set(0, undefined);
|
|
414
|
+
table.set(offset + 0, undefined);
|
|
415
|
+
table.set(offset + 1, null);
|
|
416
|
+
table.set(offset + 2, true);
|
|
417
|
+
table.set(offset + 3, false);
|
|
418
|
+
;
|
|
419
|
+
};
|
|
420
|
+
|
package/esm/cedar_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -5,11 +5,15 @@ export const getCedarSDKVersion: () => [number, number];
|
|
|
5
5
|
export const getValidRequestEnvsPolicy: (a: any, b: any) => any;
|
|
6
6
|
export const getValidRequestEnvsTemplate: (a: any, b: any) => any;
|
|
7
7
|
export const getCedarVersion: () => [number, number];
|
|
8
|
+
export const isAuthorized: (a: any) => any;
|
|
9
|
+
export const preparsePolicySet: (a: number, b: number, c: any) => any;
|
|
10
|
+
export const preparseSchema: (a: number, b: number, c: any) => any;
|
|
11
|
+
export const statefulIsAuthorized: (a: any) => any;
|
|
8
12
|
export const checkParseContext: (a: any) => any;
|
|
9
13
|
export const checkParseEntities: (a: any) => any;
|
|
10
14
|
export const checkParsePolicySet: (a: any) => any;
|
|
11
15
|
export const checkParseSchema: (a: any) => any;
|
|
12
|
-
export const
|
|
16
|
+
export const getCedarLangVersion: () => [number, number];
|
|
13
17
|
export const policySetTextToParts: (a: number, b: number) => any;
|
|
14
18
|
export const policyToJson: (a: any) => any;
|
|
15
19
|
export const policyToText: (a: any) => any;
|
|
@@ -17,9 +21,8 @@ export const schemaToJson: (a: any) => any;
|
|
|
17
21
|
export const schemaToText: (a: any) => any;
|
|
18
22
|
export const templateToJson: (a: any) => any;
|
|
19
23
|
export const templateToText: (a: any) => any;
|
|
24
|
+
export const formatPolicies: (a: any) => any;
|
|
20
25
|
export const validate: (a: any) => any;
|
|
21
|
-
export const isAuthorized: (a: any) => any;
|
|
22
|
-
export const getCedarLangVersion: () => [number, number];
|
|
23
26
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
24
27
|
export const __externref_table_alloc: () => number;
|
|
25
28
|
export const __wbindgen_export_2: WebAssembly.Table;
|