@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/nodejs/cedar_wasm.js
CHANGED
|
@@ -1,141 +1,111 @@
|
|
|
1
|
+
/* @ts-self-types="./cedar_wasm.d.ts" */
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
11
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
12
|
-
}
|
|
13
|
-
return cachedUint8ArrayMemory0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const cachedTextEncoder = new TextEncoder();
|
|
17
|
-
|
|
18
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
19
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
20
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
21
|
-
view.set(buf);
|
|
22
|
-
return {
|
|
23
|
-
read: arg.length,
|
|
24
|
-
written: buf.length
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
30
|
-
|
|
31
|
-
if (realloc === undefined) {
|
|
32
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
33
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
34
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
35
|
-
WASM_VECTOR_LEN = buf.length;
|
|
36
|
-
return ptr;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let len = arg.length;
|
|
40
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
41
|
-
|
|
42
|
-
const mem = getUint8ArrayMemory0();
|
|
43
|
-
|
|
44
|
-
let offset = 0;
|
|
45
|
-
|
|
46
|
-
for (; offset < len; offset++) {
|
|
47
|
-
const code = arg.charCodeAt(offset);
|
|
48
|
-
if (code > 0x7F) break;
|
|
49
|
-
mem[ptr + offset] = code;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (offset !== len) {
|
|
53
|
-
if (offset !== 0) {
|
|
54
|
-
arg = arg.slice(offset);
|
|
55
|
-
}
|
|
56
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
57
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
58
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
59
|
-
|
|
60
|
-
offset += ret.written;
|
|
61
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
WASM_VECTOR_LEN = offset;
|
|
65
|
-
return ptr;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function isLikeNone(x) {
|
|
69
|
-
return x === undefined || x === null;
|
|
3
|
+
/**
|
|
4
|
+
* Check whether a context successfully parses.
|
|
5
|
+
* @param {ContextParsingCall} call
|
|
6
|
+
* @returns {CheckParseAnswer}
|
|
7
|
+
*/
|
|
8
|
+
function checkParseContext(call) {
|
|
9
|
+
const ret = wasm.checkParseContext(call);
|
|
10
|
+
return ret;
|
|
70
11
|
}
|
|
12
|
+
exports.checkParseContext = checkParseContext;
|
|
71
13
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Check whether a set of entities successfully parses.
|
|
16
|
+
* @param {EntitiesParsingCall} call
|
|
17
|
+
* @returns {CheckParseAnswer}
|
|
18
|
+
*/
|
|
19
|
+
function checkParseEntities(call) {
|
|
20
|
+
const ret = wasm.checkParseEntities(call);
|
|
21
|
+
return ret;
|
|
79
22
|
}
|
|
23
|
+
exports.checkParseEntities = checkParseEntities;
|
|
80
24
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Check whether a policy set successfully parses.
|
|
27
|
+
* @param {PolicySet} policies
|
|
28
|
+
* @returns {CheckParseAnswer}
|
|
29
|
+
*/
|
|
30
|
+
function checkParsePolicySet(policies) {
|
|
31
|
+
const ret = wasm.checkParsePolicySet(policies);
|
|
32
|
+
return ret;
|
|
87
33
|
}
|
|
34
|
+
exports.checkParsePolicySet = checkParsePolicySet;
|
|
88
35
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Check whether a schema successfully parses.
|
|
38
|
+
* @param {Schema} schema
|
|
39
|
+
* @returns {CheckParseAnswer}
|
|
40
|
+
*/
|
|
41
|
+
function checkParseSchema(schema) {
|
|
42
|
+
const ret = wasm.checkParseSchema(schema);
|
|
43
|
+
return ret;
|
|
92
44
|
}
|
|
45
|
+
exports.checkParseSchema = checkParseSchema;
|
|
93
46
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
49
|
+
* @param {FormattingCall} call
|
|
50
|
+
* @returns {FormattingAnswer}
|
|
51
|
+
*/
|
|
52
|
+
function formatPolicies(call) {
|
|
53
|
+
const ret = wasm.formatPolicies(call);
|
|
54
|
+
return ret;
|
|
98
55
|
}
|
|
56
|
+
exports.formatPolicies = formatPolicies;
|
|
99
57
|
|
|
100
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Get language version of Cedar
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
function getCedarLangVersion() {
|
|
63
|
+
let deferred1_0;
|
|
64
|
+
let deferred1_1;
|
|
101
65
|
try {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
66
|
+
const ret = wasm.getCedarLangVersion();
|
|
67
|
+
deferred1_0 = ret[0];
|
|
68
|
+
deferred1_1 = ret[1];
|
|
69
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
70
|
+
} finally {
|
|
71
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
106
72
|
}
|
|
107
73
|
}
|
|
74
|
+
exports.getCedarLangVersion = getCedarLangVersion;
|
|
75
|
+
|
|
108
76
|
/**
|
|
109
77
|
* @returns {string}
|
|
110
78
|
*/
|
|
111
|
-
|
|
79
|
+
function getCedarSDKVersion() {
|
|
112
80
|
let deferred1_0;
|
|
113
81
|
let deferred1_1;
|
|
114
82
|
try {
|
|
115
|
-
const ret = wasm.
|
|
83
|
+
const ret = wasm.getCedarSDKVersion();
|
|
116
84
|
deferred1_0 = ret[0];
|
|
117
85
|
deferred1_1 = ret[1];
|
|
118
86
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
119
87
|
} finally {
|
|
120
88
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
121
89
|
}
|
|
122
|
-
}
|
|
90
|
+
}
|
|
91
|
+
exports.getCedarSDKVersion = getCedarSDKVersion;
|
|
123
92
|
|
|
124
93
|
/**
|
|
125
94
|
* @returns {string}
|
|
126
95
|
*/
|
|
127
|
-
|
|
96
|
+
function getCedarVersion() {
|
|
128
97
|
let deferred1_0;
|
|
129
98
|
let deferred1_1;
|
|
130
99
|
try {
|
|
131
|
-
const ret = wasm.
|
|
100
|
+
const ret = wasm.getCedarVersion();
|
|
132
101
|
deferred1_0 = ret[0];
|
|
133
102
|
deferred1_1 = ret[1];
|
|
134
103
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
135
104
|
} finally {
|
|
136
105
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
137
106
|
}
|
|
138
|
-
}
|
|
107
|
+
}
|
|
108
|
+
exports.getCedarVersion = getCedarVersion;
|
|
139
109
|
|
|
140
110
|
/**
|
|
141
111
|
* Get valid request environment
|
|
@@ -143,10 +113,11 @@ exports.getCedarSDKVersion = function() {
|
|
|
143
113
|
* @param {Schema} s
|
|
144
114
|
* @returns {GetValidRequestEnvsResult}
|
|
145
115
|
*/
|
|
146
|
-
|
|
116
|
+
function getValidRequestEnvsPolicy(t, s) {
|
|
147
117
|
const ret = wasm.getValidRequestEnvsPolicy(t, s);
|
|
148
118
|
return ret;
|
|
149
|
-
}
|
|
119
|
+
}
|
|
120
|
+
exports.getValidRequestEnvsPolicy = getValidRequestEnvsPolicy;
|
|
150
121
|
|
|
151
122
|
/**
|
|
152
123
|
* Get valid request environment
|
|
@@ -154,264 +125,327 @@ exports.getValidRequestEnvsPolicy = function(t, s) {
|
|
|
154
125
|
* @param {Schema} s
|
|
155
126
|
* @returns {GetValidRequestEnvsResult}
|
|
156
127
|
*/
|
|
157
|
-
|
|
128
|
+
function getValidRequestEnvsTemplate(t, s) {
|
|
158
129
|
const ret = wasm.getValidRequestEnvsTemplate(t, s);
|
|
159
130
|
return ret;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Preparse and cache a schema in thread-local storage
|
|
164
|
-
*
|
|
165
|
-
* # Errors
|
|
166
|
-
*
|
|
167
|
-
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
168
|
-
* @param {string} schema_name
|
|
169
|
-
* @param {Schema} schema
|
|
170
|
-
* @returns {CheckParseAnswer}
|
|
171
|
-
*/
|
|
172
|
-
exports.preparseSchema = function(schema_name, schema) {
|
|
173
|
-
const ptr0 = passStringToWasm0(schema_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
174
|
-
const len0 = WASM_VECTOR_LEN;
|
|
175
|
-
const ret = wasm.preparseSchema(ptr0, len0, schema);
|
|
176
|
-
return ret;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Preparse and cache a policy set in thread-local storage
|
|
181
|
-
*
|
|
182
|
-
* # Errors
|
|
183
|
-
*
|
|
184
|
-
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
185
|
-
* @param {string} pset_id
|
|
186
|
-
* @param {PolicySet} policies
|
|
187
|
-
* @returns {CheckParseAnswer}
|
|
188
|
-
*/
|
|
189
|
-
exports.preparsePolicySet = function(pset_id, policies) {
|
|
190
|
-
const ptr0 = passStringToWasm0(pset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
191
|
-
const len0 = WASM_VECTOR_LEN;
|
|
192
|
-
const ret = wasm.preparsePolicySet(ptr0, len0, policies);
|
|
193
|
-
return ret;
|
|
194
|
-
};
|
|
131
|
+
}
|
|
132
|
+
exports.getValidRequestEnvsTemplate = getValidRequestEnvsTemplate;
|
|
195
133
|
|
|
196
134
|
/**
|
|
197
135
|
* Basic interface, using [`AuthorizationCall`] and [`AuthorizationAnswer`] types
|
|
198
136
|
* @param {AuthorizationCall} call
|
|
199
137
|
* @returns {AuthorizationAnswer}
|
|
200
138
|
*/
|
|
201
|
-
|
|
139
|
+
function isAuthorized(call) {
|
|
202
140
|
const ret = wasm.isAuthorized(call);
|
|
203
141
|
return ret;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Stateful authorization using preparsed schemas and policy sets.
|
|
208
|
-
*
|
|
209
|
-
* This function works like [`is_authorized`] but retrieves schemas and policy sets
|
|
210
|
-
* from thread-local cache instead of parsing them on each call.
|
|
211
|
-
* @param {StatefulAuthorizationCall} call
|
|
212
|
-
* @returns {AuthorizationAnswer}
|
|
213
|
-
*/
|
|
214
|
-
exports.statefulIsAuthorized = function(call) {
|
|
215
|
-
const ret = wasm.statefulIsAuthorized(call);
|
|
216
|
-
return ret;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Get language version of Cedar
|
|
221
|
-
* @returns {string}
|
|
222
|
-
*/
|
|
223
|
-
exports.getCedarLangVersion = function() {
|
|
224
|
-
let deferred1_0;
|
|
225
|
-
let deferred1_1;
|
|
226
|
-
try {
|
|
227
|
-
const ret = wasm.getCedarLangVersion();
|
|
228
|
-
deferred1_0 = ret[0];
|
|
229
|
-
deferred1_1 = ret[1];
|
|
230
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
231
|
-
} finally {
|
|
232
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Apply the Cedar policy formatter to a policy set in the Cedar policy format
|
|
238
|
-
* @param {FormattingCall} call
|
|
239
|
-
* @returns {FormattingAnswer}
|
|
240
|
-
*/
|
|
241
|
-
exports.formatPolicies = function(call) {
|
|
242
|
-
const ret = wasm.formatPolicies(call);
|
|
243
|
-
return ret;
|
|
244
|
-
};
|
|
142
|
+
}
|
|
143
|
+
exports.isAuthorized = isAuthorized;
|
|
245
144
|
|
|
246
145
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* @param {ValidationCall} call
|
|
252
|
-
* @returns {ValidationAnswer}
|
|
146
|
+
* Takes a `PolicySet` represented as string and return the policies
|
|
147
|
+
* and templates split into vecs and sorted by id.
|
|
148
|
+
* @param {string} policyset_str
|
|
149
|
+
* @returns {PolicySetTextToPartsAnswer}
|
|
253
150
|
*/
|
|
254
|
-
|
|
255
|
-
const
|
|
151
|
+
function policySetTextToParts(policyset_str) {
|
|
152
|
+
const ptr0 = passStringToWasm0(policyset_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
153
|
+
const len0 = WASM_VECTOR_LEN;
|
|
154
|
+
const ret = wasm.policySetTextToParts(ptr0, len0);
|
|
256
155
|
return ret;
|
|
257
|
-
}
|
|
156
|
+
}
|
|
157
|
+
exports.policySetTextToParts = policySetTextToParts;
|
|
258
158
|
|
|
259
159
|
/**
|
|
260
|
-
*
|
|
261
|
-
* @param {
|
|
262
|
-
* @returns {
|
|
160
|
+
* Return the JSON representation of a policy.
|
|
161
|
+
* @param {Policy} policy
|
|
162
|
+
* @returns {PolicyToJsonAnswer}
|
|
263
163
|
*/
|
|
264
|
-
|
|
265
|
-
const ret = wasm.
|
|
164
|
+
function policyToJson(policy) {
|
|
165
|
+
const ret = wasm.policyToJson(policy);
|
|
266
166
|
return ret;
|
|
267
|
-
}
|
|
167
|
+
}
|
|
168
|
+
exports.policyToJson = policyToJson;
|
|
268
169
|
|
|
269
170
|
/**
|
|
270
|
-
*
|
|
271
|
-
* @param {
|
|
272
|
-
* @returns {
|
|
171
|
+
* Return the Cedar (textual) representation of a policy.
|
|
172
|
+
* @param {Policy} policy
|
|
173
|
+
* @returns {PolicyToTextAnswer}
|
|
273
174
|
*/
|
|
274
|
-
|
|
275
|
-
const ret = wasm.
|
|
175
|
+
function policyToText(policy) {
|
|
176
|
+
const ret = wasm.policyToText(policy);
|
|
276
177
|
return ret;
|
|
277
|
-
}
|
|
178
|
+
}
|
|
179
|
+
exports.policyToText = policyToText;
|
|
278
180
|
|
|
279
181
|
/**
|
|
280
|
-
*
|
|
182
|
+
* Preparse and cache a policy set in thread-local storage
|
|
183
|
+
*
|
|
184
|
+
* # Errors
|
|
185
|
+
*
|
|
186
|
+
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
187
|
+
* @param {string} pset_id
|
|
281
188
|
* @param {PolicySet} policies
|
|
282
189
|
* @returns {CheckParseAnswer}
|
|
283
190
|
*/
|
|
284
|
-
|
|
285
|
-
const
|
|
191
|
+
function preparsePolicySet(pset_id, policies) {
|
|
192
|
+
const ptr0 = passStringToWasm0(pset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
193
|
+
const len0 = WASM_VECTOR_LEN;
|
|
194
|
+
const ret = wasm.preparsePolicySet(ptr0, len0, policies);
|
|
286
195
|
return ret;
|
|
287
|
-
}
|
|
196
|
+
}
|
|
197
|
+
exports.preparsePolicySet = preparsePolicySet;
|
|
288
198
|
|
|
289
199
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
200
|
+
* Preparse and cache a schema in thread-local storage
|
|
201
|
+
*
|
|
202
|
+
* # Errors
|
|
203
|
+
*
|
|
204
|
+
* Will return `Err` if the input cannot be parsed. Side-effect free on error.
|
|
205
|
+
* @param {string} schema_name
|
|
206
|
+
* @param {Schema} schema
|
|
292
207
|
* @returns {CheckParseAnswer}
|
|
293
208
|
*/
|
|
294
|
-
|
|
295
|
-
const
|
|
209
|
+
function preparseSchema(schema_name, schema) {
|
|
210
|
+
const ptr0 = passStringToWasm0(schema_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
211
|
+
const len0 = WASM_VECTOR_LEN;
|
|
212
|
+
const ret = wasm.preparseSchema(ptr0, len0, schema);
|
|
296
213
|
return ret;
|
|
297
|
-
}
|
|
214
|
+
}
|
|
215
|
+
exports.preparseSchema = preparseSchema;
|
|
298
216
|
|
|
299
217
|
/**
|
|
300
218
|
* Return the JSON representation of a schema.
|
|
301
219
|
* @param {Schema} schema
|
|
302
220
|
* @returns {SchemaToJsonAnswer}
|
|
303
221
|
*/
|
|
304
|
-
|
|
222
|
+
function schemaToJson(schema) {
|
|
305
223
|
const ret = wasm.schemaToJson(schema);
|
|
306
224
|
return ret;
|
|
307
|
-
}
|
|
225
|
+
}
|
|
226
|
+
exports.schemaToJson = schemaToJson;
|
|
308
227
|
|
|
309
228
|
/**
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
229
|
+
* Convert a Cedar schema string to JSON format with resolved types.
|
|
230
|
+
*
|
|
231
|
+
* This function resolves ambiguous "`EntityOrCommon`" types to their specific
|
|
232
|
+
* Entity or `CommonType` classifications using the schema's type definitions.
|
|
233
|
+
* This is primarily meant to be used when working with schemas programmatically,
|
|
234
|
+
* for example when creating a schema building UI.
|
|
235
|
+
* @param {string} schema_str
|
|
236
|
+
* @returns {SchemaToJsonWithResolvedTypesAnswer}
|
|
313
237
|
*/
|
|
314
|
-
|
|
315
|
-
const
|
|
238
|
+
function schemaToJsonWithResolvedTypes(schema_str) {
|
|
239
|
+
const ptr0 = passStringToWasm0(schema_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
240
|
+
const len0 = WASM_VECTOR_LEN;
|
|
241
|
+
const ret = wasm.schemaToJsonWithResolvedTypes(ptr0, len0);
|
|
316
242
|
return ret;
|
|
317
|
-
}
|
|
243
|
+
}
|
|
244
|
+
exports.schemaToJsonWithResolvedTypes = schemaToJsonWithResolvedTypes;
|
|
318
245
|
|
|
319
246
|
/**
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
* @
|
|
323
|
-
* @returns {PolicySetTextToPartsAnswer}
|
|
247
|
+
* Return the Cedar (textual) representation of a schema.
|
|
248
|
+
* @param {Schema} schema
|
|
249
|
+
* @returns {SchemaToTextAnswer}
|
|
324
250
|
*/
|
|
325
|
-
|
|
326
|
-
const
|
|
327
|
-
const len0 = WASM_VECTOR_LEN;
|
|
328
|
-
const ret = wasm.policySetTextToParts(ptr0, len0);
|
|
251
|
+
function schemaToText(schema) {
|
|
252
|
+
const ret = wasm.schemaToText(schema);
|
|
329
253
|
return ret;
|
|
330
|
-
}
|
|
254
|
+
}
|
|
255
|
+
exports.schemaToText = schemaToText;
|
|
331
256
|
|
|
332
257
|
/**
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
258
|
+
* Stateful authorization using preparsed schemas and policy sets.
|
|
259
|
+
*
|
|
260
|
+
* This function works like [`is_authorized`] but retrieves schemas and policy sets
|
|
261
|
+
* from thread-local cache instead of parsing them on each call.
|
|
262
|
+
* @param {StatefulAuthorizationCall} call
|
|
263
|
+
* @returns {AuthorizationAnswer}
|
|
336
264
|
*/
|
|
337
|
-
|
|
338
|
-
const ret = wasm.
|
|
265
|
+
function statefulIsAuthorized(call) {
|
|
266
|
+
const ret = wasm.statefulIsAuthorized(call);
|
|
339
267
|
return ret;
|
|
340
|
-
}
|
|
268
|
+
}
|
|
269
|
+
exports.statefulIsAuthorized = statefulIsAuthorized;
|
|
341
270
|
|
|
342
271
|
/**
|
|
343
|
-
* Return the JSON representation of a
|
|
344
|
-
* @param {
|
|
272
|
+
* Return the JSON representation of a template.
|
|
273
|
+
* @param {Template} template
|
|
345
274
|
* @returns {PolicyToJsonAnswer}
|
|
346
275
|
*/
|
|
347
|
-
|
|
348
|
-
const ret = wasm.
|
|
276
|
+
function templateToJson(template) {
|
|
277
|
+
const ret = wasm.templateToJson(template);
|
|
349
278
|
return ret;
|
|
350
|
-
}
|
|
279
|
+
}
|
|
280
|
+
exports.templateToJson = templateToJson;
|
|
351
281
|
|
|
352
282
|
/**
|
|
353
283
|
* Return the Cedar (textual) representation of a template.
|
|
354
284
|
* @param {Template} template
|
|
355
285
|
* @returns {PolicyToTextAnswer}
|
|
356
286
|
*/
|
|
357
|
-
|
|
287
|
+
function templateToText(template) {
|
|
358
288
|
const ret = wasm.templateToText(template);
|
|
359
289
|
return ret;
|
|
360
|
-
}
|
|
290
|
+
}
|
|
291
|
+
exports.templateToText = templateToText;
|
|
361
292
|
|
|
362
293
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
294
|
+
* Parse a policy set and optionally validate it against a provided schema
|
|
295
|
+
*
|
|
296
|
+
* This is the basic validator interface, using [`ValidationCall`] and
|
|
297
|
+
* [`ValidationAnswer`] types
|
|
298
|
+
* @param {ValidationCall} call
|
|
299
|
+
* @returns {ValidationAnswer}
|
|
366
300
|
*/
|
|
367
|
-
|
|
368
|
-
const ret = wasm.
|
|
301
|
+
function validate(call) {
|
|
302
|
+
const ret = wasm.validate(call);
|
|
369
303
|
return ret;
|
|
370
|
-
}
|
|
304
|
+
}
|
|
305
|
+
exports.validate = validate;
|
|
306
|
+
|
|
307
|
+
function __wbg_get_imports() {
|
|
308
|
+
const import0 = {
|
|
309
|
+
__proto__: null,
|
|
310
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
311
|
+
const ret = arg0 === undefined;
|
|
312
|
+
return ret;
|
|
313
|
+
},
|
|
314
|
+
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
315
|
+
const obj = arg1;
|
|
316
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
317
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
318
|
+
var len1 = WASM_VECTOR_LEN;
|
|
319
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
320
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
321
|
+
},
|
|
322
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
323
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
324
|
+
},
|
|
325
|
+
__wbg_parse_708461a1feddfb38: function() { return handleError(function (arg0, arg1) {
|
|
326
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
327
|
+
return ret;
|
|
328
|
+
}, arguments); },
|
|
329
|
+
__wbg_stringify_8d1cc6ff383e8bae: function() { return handleError(function (arg0) {
|
|
330
|
+
const ret = JSON.stringify(arg0);
|
|
331
|
+
return ret;
|
|
332
|
+
}, arguments); },
|
|
333
|
+
__wbindgen_init_externref_table: function() {
|
|
334
|
+
const table = wasm.__wbindgen_externrefs;
|
|
335
|
+
const offset = table.grow(4);
|
|
336
|
+
table.set(0, undefined);
|
|
337
|
+
table.set(offset + 0, undefined);
|
|
338
|
+
table.set(offset + 1, null);
|
|
339
|
+
table.set(offset + 2, true);
|
|
340
|
+
table.set(offset + 3, false);
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
return {
|
|
344
|
+
__proto__: null,
|
|
345
|
+
"./cedar_wasm_bg.js": import0,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
371
348
|
|
|
372
|
-
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
exports.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) {
|
|
378
|
-
const obj = arg1;
|
|
379
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
380
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
381
|
-
var len1 = WASM_VECTOR_LEN;
|
|
382
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
383
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
exports.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
|
|
387
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
exports.__wbg_parse_2a704d6b78abb2b8 = function() { return handleError(function (arg0, arg1) {
|
|
391
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
392
|
-
return ret;
|
|
393
|
-
}, arguments) };
|
|
349
|
+
function addToExternrefTable0(obj) {
|
|
350
|
+
const idx = wasm.__externref_table_alloc();
|
|
351
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
352
|
+
return idx;
|
|
353
|
+
}
|
|
394
354
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
355
|
+
let cachedDataViewMemory0 = null;
|
|
356
|
+
function getDataViewMemory0() {
|
|
357
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
358
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
359
|
+
}
|
|
360
|
+
return cachedDataViewMemory0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function getStringFromWasm0(ptr, len) {
|
|
364
|
+
ptr = ptr >>> 0;
|
|
365
|
+
return decodeText(ptr, len);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
let cachedUint8ArrayMemory0 = null;
|
|
369
|
+
function getUint8ArrayMemory0() {
|
|
370
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
371
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
372
|
+
}
|
|
373
|
+
return cachedUint8ArrayMemory0;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function handleError(f, args) {
|
|
377
|
+
try {
|
|
378
|
+
return f.apply(this, args);
|
|
379
|
+
} catch (e) {
|
|
380
|
+
const idx = addToExternrefTable0(e);
|
|
381
|
+
wasm.__wbindgen_exn_store(idx);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function isLikeNone(x) {
|
|
386
|
+
return x === undefined || x === null;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
390
|
+
if (realloc === undefined) {
|
|
391
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
392
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
393
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
394
|
+
WASM_VECTOR_LEN = buf.length;
|
|
395
|
+
return ptr;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
let len = arg.length;
|
|
399
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
400
|
+
|
|
401
|
+
const mem = getUint8ArrayMemory0();
|
|
402
|
+
|
|
403
|
+
let offset = 0;
|
|
404
|
+
|
|
405
|
+
for (; offset < len; offset++) {
|
|
406
|
+
const code = arg.charCodeAt(offset);
|
|
407
|
+
if (code > 0x7F) break;
|
|
408
|
+
mem[ptr + offset] = code;
|
|
409
|
+
}
|
|
410
|
+
if (offset !== len) {
|
|
411
|
+
if (offset !== 0) {
|
|
412
|
+
arg = arg.slice(offset);
|
|
413
|
+
}
|
|
414
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
415
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
416
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
417
|
+
|
|
418
|
+
offset += ret.written;
|
|
419
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
WASM_VECTOR_LEN = offset;
|
|
423
|
+
return ptr;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
427
|
+
cachedTextDecoder.decode();
|
|
428
|
+
function decodeText(ptr, len) {
|
|
429
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const cachedTextEncoder = new TextEncoder();
|
|
433
|
+
|
|
434
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
435
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
436
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
437
|
+
view.set(buf);
|
|
438
|
+
return {
|
|
439
|
+
read: arg.length,
|
|
440
|
+
written: buf.length
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
let WASM_VECTOR_LEN = 0;
|
|
410
446
|
|
|
411
447
|
const wasmPath = `${__dirname}/cedar_wasm_bg.wasm`;
|
|
412
448
|
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
413
449
|
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
414
|
-
const wasm =
|
|
415
|
-
|
|
450
|
+
const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
416
451
|
wasm.__wbindgen_start();
|
|
417
|
-
|