@janssenproject/cedarling_wasm 0.0.415-nodejs → 0.0.416-nodejs
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/cedarling_wasm.d.ts +61 -0
- package/cedarling_wasm.js +138 -12
- package/cedarling_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/cedarling_wasm.d.ts
CHANGED
|
@@ -63,6 +63,67 @@ export class Cedarling {
|
|
|
63
63
|
private constructor();
|
|
64
64
|
free(): void;
|
|
65
65
|
[Symbol.dispose](): void;
|
|
66
|
+
/**
|
|
67
|
+
* Collect every value of the annotation `key` across the given policies,
|
|
68
|
+
* preserving duplicates. Unknown policy IDs are silently skipped.
|
|
69
|
+
*
|
|
70
|
+
* # Arguments
|
|
71
|
+
*
|
|
72
|
+
* * `policy_ids` - List of policy IDs to search. Typically
|
|
73
|
+
* `result.response.diagnostics.reason` from an authorization result.
|
|
74
|
+
* * `key` - The annotation key to collect values for (e.g. `"redirect"`).
|
|
75
|
+
*
|
|
76
|
+
* # Example
|
|
77
|
+
*
|
|
78
|
+
* ```javascript
|
|
79
|
+
* const redirects = cedarling.annotation_values(result.response.diagnostics.reason, "redirect");
|
|
80
|
+
* // ["/upgrade"]
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
annotation_values(policy_ids: string[], key: string): string[];
|
|
84
|
+
/**
|
|
85
|
+
* Return the annotations of each given policy, grouped by policy ID
|
|
86
|
+
* the loss-free companion to `annotations_map`. Unknown policy IDs are
|
|
87
|
+
* silently skipped.
|
|
88
|
+
*
|
|
89
|
+
* # Arguments
|
|
90
|
+
*
|
|
91
|
+
* * `policy_ids` - List of policy IDs whose annotations should be returned
|
|
92
|
+
* grouped by policy ID. Typically `result.response.diagnostics.reason` from
|
|
93
|
+
* an authorization result.
|
|
94
|
+
*
|
|
95
|
+
* # Example
|
|
96
|
+
*
|
|
97
|
+
* ```javascript
|
|
98
|
+
* const byPolicy = cedarling.annotations_by_policy(result.response.diagnostics.reason);
|
|
99
|
+
* // { "5": { redirect: "/upgrade", tier: "premium" } }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
annotations_by_policy(policy_ids: string[]): any;
|
|
103
|
+
/**
|
|
104
|
+
* Merge the annotations (`@key("value")`) of the given policies into a single object.
|
|
105
|
+
*
|
|
106
|
+
* Intended for resolving the determining policies of an authorization decision:
|
|
107
|
+
* pass `result.response.diagnostics.reason`.
|
|
108
|
+
*
|
|
109
|
+
* Lossy: if the same annotation key appears on several policies, one value wins
|
|
110
|
+
* arbitrarily. Use `annotation_values` / `annotations_by_policy` when duplicates
|
|
111
|
+
* matter. Unknown policy IDs are silently skipped.
|
|
112
|
+
*
|
|
113
|
+
* # Arguments
|
|
114
|
+
*
|
|
115
|
+
* * `policy_ids` - List of policy IDs whose annotations should be merged into
|
|
116
|
+
* a single object. Typically `result.response.diagnostics.reason` from an
|
|
117
|
+
* authorization result.
|
|
118
|
+
*
|
|
119
|
+
* # Example
|
|
120
|
+
*
|
|
121
|
+
* ```javascript
|
|
122
|
+
* const annotations = cedarling.annotations_map(result.response.diagnostics.reason);
|
|
123
|
+
* // { redirect: "/upgrade", tier: "premium" }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
annotations_map(policy_ids: string[]): any;
|
|
66
127
|
/**
|
|
67
128
|
* Authorize multi-issuer request.
|
|
68
129
|
* Makes authorization decision based on multiple JWT tokens from different issuers.
|
package/cedarling_wasm.js
CHANGED
|
@@ -175,6 +175,122 @@ class Cedarling {
|
|
|
175
175
|
const ptr = this.__destroy_into_raw();
|
|
176
176
|
wasm.__wbg_cedarling_free(ptr, 0);
|
|
177
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Collect every value of the annotation `key` across the given policies,
|
|
180
|
+
* preserving duplicates. Unknown policy IDs are silently skipped.
|
|
181
|
+
*
|
|
182
|
+
* # Arguments
|
|
183
|
+
*
|
|
184
|
+
* * `policy_ids` - List of policy IDs to search. Typically
|
|
185
|
+
* `result.response.diagnostics.reason` from an authorization result.
|
|
186
|
+
* * `key` - The annotation key to collect values for (e.g. `"redirect"`).
|
|
187
|
+
*
|
|
188
|
+
* # Example
|
|
189
|
+
*
|
|
190
|
+
* ```javascript
|
|
191
|
+
* const redirects = cedarling.annotation_values(result.response.diagnostics.reason, "redirect");
|
|
192
|
+
* // ["/upgrade"]
|
|
193
|
+
* ```
|
|
194
|
+
* @param {string[]} policy_ids
|
|
195
|
+
* @param {string} key
|
|
196
|
+
* @returns {string[]}
|
|
197
|
+
*/
|
|
198
|
+
annotation_values(policy_ids, key) {
|
|
199
|
+
try {
|
|
200
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
201
|
+
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
202
|
+
const len0 = WASM_VECTOR_LEN;
|
|
203
|
+
const ptr1 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
204
|
+
const len1 = WASM_VECTOR_LEN;
|
|
205
|
+
wasm.cedarling_annotation_values(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
206
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
207
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
208
|
+
var v3 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
209
|
+
wasm.__wbindgen_export5(r0, r1 * 4, 4);
|
|
210
|
+
return v3;
|
|
211
|
+
} finally {
|
|
212
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Return the annotations of each given policy, grouped by policy ID
|
|
217
|
+
* the loss-free companion to `annotations_map`. Unknown policy IDs are
|
|
218
|
+
* silently skipped.
|
|
219
|
+
*
|
|
220
|
+
* # Arguments
|
|
221
|
+
*
|
|
222
|
+
* * `policy_ids` - List of policy IDs whose annotations should be returned
|
|
223
|
+
* grouped by policy ID. Typically `result.response.diagnostics.reason` from
|
|
224
|
+
* an authorization result.
|
|
225
|
+
*
|
|
226
|
+
* # Example
|
|
227
|
+
*
|
|
228
|
+
* ```javascript
|
|
229
|
+
* const byPolicy = cedarling.annotations_by_policy(result.response.diagnostics.reason);
|
|
230
|
+
* // { "5": { redirect: "/upgrade", tier: "premium" } }
|
|
231
|
+
* ```
|
|
232
|
+
* @param {string[]} policy_ids
|
|
233
|
+
* @returns {any}
|
|
234
|
+
*/
|
|
235
|
+
annotations_by_policy(policy_ids) {
|
|
236
|
+
try {
|
|
237
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
238
|
+
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
239
|
+
const len0 = WASM_VECTOR_LEN;
|
|
240
|
+
wasm.cedarling_annotations_by_policy(retptr, this.__wbg_ptr, ptr0, len0);
|
|
241
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
242
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
243
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
244
|
+
if (r2) {
|
|
245
|
+
throw takeObject(r1);
|
|
246
|
+
}
|
|
247
|
+
return takeObject(r0);
|
|
248
|
+
} finally {
|
|
249
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Merge the annotations (`@key("value")`) of the given policies into a single object.
|
|
254
|
+
*
|
|
255
|
+
* Intended for resolving the determining policies of an authorization decision:
|
|
256
|
+
* pass `result.response.diagnostics.reason`.
|
|
257
|
+
*
|
|
258
|
+
* Lossy: if the same annotation key appears on several policies, one value wins
|
|
259
|
+
* arbitrarily. Use `annotation_values` / `annotations_by_policy` when duplicates
|
|
260
|
+
* matter. Unknown policy IDs are silently skipped.
|
|
261
|
+
*
|
|
262
|
+
* # Arguments
|
|
263
|
+
*
|
|
264
|
+
* * `policy_ids` - List of policy IDs whose annotations should be merged into
|
|
265
|
+
* a single object. Typically `result.response.diagnostics.reason` from an
|
|
266
|
+
* authorization result.
|
|
267
|
+
*
|
|
268
|
+
* # Example
|
|
269
|
+
*
|
|
270
|
+
* ```javascript
|
|
271
|
+
* const annotations = cedarling.annotations_map(result.response.diagnostics.reason);
|
|
272
|
+
* // { redirect: "/upgrade", tier: "premium" }
|
|
273
|
+
* ```
|
|
274
|
+
* @param {string[]} policy_ids
|
|
275
|
+
* @returns {any}
|
|
276
|
+
*/
|
|
277
|
+
annotations_map(policy_ids) {
|
|
278
|
+
try {
|
|
279
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
280
|
+
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
281
|
+
const len0 = WASM_VECTOR_LEN;
|
|
282
|
+
wasm.cedarling_annotations_map(retptr, this.__wbg_ptr, ptr0, len0);
|
|
283
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
284
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
285
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
286
|
+
if (r2) {
|
|
287
|
+
throw takeObject(r1);
|
|
288
|
+
}
|
|
289
|
+
return takeObject(r0);
|
|
290
|
+
} finally {
|
|
291
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
178
294
|
/**
|
|
179
295
|
* Authorize multi-issuer request.
|
|
180
296
|
* Makes authorization decision based on multiple JWT tokens from different issuers.
|
|
@@ -1883,7 +1999,7 @@ function __wbg_get_imports() {
|
|
|
1883
1999
|
const a = state0.a;
|
|
1884
2000
|
state0.a = 0;
|
|
1885
2001
|
try {
|
|
1886
|
-
return
|
|
2002
|
+
return __wasm_bindgen_func_elem_8746(a, state0.b, arg0, arg1);
|
|
1887
2003
|
} finally {
|
|
1888
2004
|
state0.a = a;
|
|
1889
2005
|
}
|
|
@@ -2093,17 +2209,17 @@ function __wbg_get_imports() {
|
|
|
2093
2209
|
},
|
|
2094
2210
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
2095
2211
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1196, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2096
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2212
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12170);
|
|
2097
2213
|
return addHeapObject(ret);
|
|
2098
2214
|
},
|
|
2099
2215
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
2100
2216
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 995, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
2101
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2217
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8691);
|
|
2102
2218
|
return addHeapObject(ret);
|
|
2103
2219
|
},
|
|
2104
2220
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
2105
2221
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 883, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2106
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2222
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8526);
|
|
2107
2223
|
return addHeapObject(ret);
|
|
2108
2224
|
},
|
|
2109
2225
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
@@ -2145,18 +2261,18 @@ function __wbg_get_imports() {
|
|
|
2145
2261
|
};
|
|
2146
2262
|
}
|
|
2147
2263
|
|
|
2148
|
-
function
|
|
2149
|
-
wasm.
|
|
2264
|
+
function __wasm_bindgen_func_elem_8526(arg0, arg1) {
|
|
2265
|
+
wasm.__wasm_bindgen_func_elem_8526(arg0, arg1);
|
|
2150
2266
|
}
|
|
2151
2267
|
|
|
2152
|
-
function
|
|
2153
|
-
wasm.
|
|
2268
|
+
function __wasm_bindgen_func_elem_12170(arg0, arg1, arg2) {
|
|
2269
|
+
wasm.__wasm_bindgen_func_elem_12170(arg0, arg1, addHeapObject(arg2));
|
|
2154
2270
|
}
|
|
2155
2271
|
|
|
2156
|
-
function
|
|
2272
|
+
function __wasm_bindgen_func_elem_8691(arg0, arg1, arg2) {
|
|
2157
2273
|
try {
|
|
2158
2274
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2159
|
-
wasm.
|
|
2275
|
+
wasm.__wasm_bindgen_func_elem_8691(retptr, arg0, arg1, addHeapObject(arg2));
|
|
2160
2276
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2161
2277
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2162
2278
|
if (r1) {
|
|
@@ -2167,8 +2283,8 @@ function __wasm_bindgen_func_elem_8668(arg0, arg1, arg2) {
|
|
|
2167
2283
|
}
|
|
2168
2284
|
}
|
|
2169
2285
|
|
|
2170
|
-
function
|
|
2171
|
-
wasm.
|
|
2286
|
+
function __wasm_bindgen_func_elem_8746(arg0, arg1, arg2, arg3) {
|
|
2287
|
+
wasm.__wasm_bindgen_func_elem_8746(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
2172
2288
|
}
|
|
2173
2289
|
|
|
2174
2290
|
|
|
@@ -2394,6 +2510,16 @@ function makeMutClosure(arg0, arg1, f) {
|
|
|
2394
2510
|
return real;
|
|
2395
2511
|
}
|
|
2396
2512
|
|
|
2513
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
2514
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
2515
|
+
const mem = getDataViewMemory0();
|
|
2516
|
+
for (let i = 0; i < array.length; i++) {
|
|
2517
|
+
mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
|
|
2518
|
+
}
|
|
2519
|
+
WASM_VECTOR_LEN = array.length;
|
|
2520
|
+
return ptr;
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2397
2523
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
2398
2524
|
if (realloc === undefined) {
|
|
2399
2525
|
const buf = cachedTextEncoder.encode(arg);
|
package/cedarling_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@janssenproject/cedarling_wasm",
|
|
3
3
|
"description": "The Cedarling is a performant local authorization service that runs the Rust Cedar Engine",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.416-nodejs",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|