@janssenproject/cedarling_wasm 2.4.0-nodejs → 2.5.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/LICENSE +201 -0
- package/README.md +411 -517
- package/dist/browser/index.js +3346 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/cjs/index.cjs +3327 -0
- package/dist/cjs/index.cjs.map +7 -0
- package/dist/edge/index.js +3276 -0
- package/dist/edge/index.js.map +7 -0
- package/dist/esm/index.js +3341 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/manual/index.js +3292 -0
- package/dist/manual/index.js.map +7 -0
- package/dist/types/cjs/generated.d.ts +1166 -0
- package/dist/types/cjs/index.d.ts +6 -0
- package/dist/types/cjs/package.json +1 -0
- package/dist/types/esm/edge.d.ts +7 -0
- package/dist/types/esm/generated.d.ts +1166 -0
- package/dist/types/esm/index.d.ts +6 -0
- package/dist/types/esm/manual.d.ts +2 -0
- package/dist/types/esm/wasm.d.ts +2 -0
- package/{cedarling_wasm_bg.wasm → dist/wasm/cedarling_wasm_bg.wasm} +0 -0
- package/package.json +81 -8
- package/cedarling_wasm.d.ts +0 -759
- package/cedarling_wasm.js +0 -3003
|
@@ -0,0 +1,1166 @@
|
|
|
1
|
+
/// <reference lib="esnext.disposable" />
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* The `ReadableStreamType` enum.
|
|
6
|
+
*
|
|
7
|
+
* *This API requires the following crate features to be activated: `ReadableStreamType`*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type ReadableStreamType = "bytes";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A WASM wrapper for the Rust `cedarling::AuthorizeResult` struct.
|
|
14
|
+
* Represents the result of an authorization request.
|
|
15
|
+
*/
|
|
16
|
+
export class AuthorizeResult {
|
|
17
|
+
private constructor();
|
|
18
|
+
free(): void;
|
|
19
|
+
[Symbol.dispose](): void;
|
|
20
|
+
/**
|
|
21
|
+
* Convert `AuthorizeResult` to json string value
|
|
22
|
+
*/
|
|
23
|
+
jsonString(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Result of authorization
|
|
26
|
+
* true means `ALLOW`
|
|
27
|
+
* false means `Deny`
|
|
28
|
+
*
|
|
29
|
+
* this field is [`bool`] type to be compatible with [authzen Access Evaluation Decision](https://openid.github.io/authzen/#section-6.2.1).
|
|
30
|
+
*/
|
|
31
|
+
decision: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Request ID of the authorization request
|
|
34
|
+
*/
|
|
35
|
+
request_id: string;
|
|
36
|
+
/**
|
|
37
|
+
* Cedar authorization response for the request.
|
|
38
|
+
*/
|
|
39
|
+
response: AuthorizeResultResponse;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A WASM wrapper for the Rust `cedar_policy::Response` struct.
|
|
44
|
+
* Represents the result of an authorization request.
|
|
45
|
+
*/
|
|
46
|
+
export class AuthorizeResultResponse {
|
|
47
|
+
private constructor();
|
|
48
|
+
free(): void;
|
|
49
|
+
[Symbol.dispose](): void;
|
|
50
|
+
/**
|
|
51
|
+
* Authorization decision
|
|
52
|
+
*/
|
|
53
|
+
readonly decision: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Diagnostics providing more information on how this decision was reached
|
|
56
|
+
*/
|
|
57
|
+
readonly diagnostics: Diagnostics;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* WASM wrapper for
|
|
62
|
+
* `cedarling::BatchAuthorizeResponse<Result<MultiIssuerAuthorizeResult, BatchItemError>>`.
|
|
63
|
+
* Same shape as [`BatchAuthorizeUnsignedResponse`] with multi-issuer results.
|
|
64
|
+
*/
|
|
65
|
+
export class BatchAuthorizeMultiIssuerResponse {
|
|
66
|
+
private constructor();
|
|
67
|
+
free(): void;
|
|
68
|
+
[Symbol.dispose](): void;
|
|
69
|
+
/**
|
|
70
|
+
* Shared correlation id stamped on every per-item decision log entry.
|
|
71
|
+
*/
|
|
72
|
+
readonly batch_id: string;
|
|
73
|
+
/**
|
|
74
|
+
* Per-item results in input order — each slot is a
|
|
75
|
+
* [`BatchItemMultiIssuerResult`].
|
|
76
|
+
*/
|
|
77
|
+
readonly results: BatchItemMultiIssuerResult[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* WASM wrapper for `cedarling::BatchAuthorizeResponse<Result<AuthorizeResult, BatchItemError>>`.
|
|
82
|
+
*
|
|
83
|
+
* Carries a shared `batch_id` (UUIDv7) alongside per-item results. Each result
|
|
84
|
+
* is a [`BatchItemUnsignedResult`] — Cedar decision on `is_ok()`, per-item
|
|
85
|
+
* build failure on `error`. `results[i]` corresponds to `items[i]`.
|
|
86
|
+
*/
|
|
87
|
+
export class BatchAuthorizeUnsignedResponse {
|
|
88
|
+
private constructor();
|
|
89
|
+
free(): void;
|
|
90
|
+
[Symbol.dispose](): void;
|
|
91
|
+
/**
|
|
92
|
+
* Shared correlation id stamped on every per-item decision log entry.
|
|
93
|
+
*/
|
|
94
|
+
readonly batch_id: string;
|
|
95
|
+
/**
|
|
96
|
+
* Per-item results in input order — each slot is a
|
|
97
|
+
* [`BatchItemUnsignedResult`].
|
|
98
|
+
*/
|
|
99
|
+
readonly results: BatchItemUnsignedResult[];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Per-item build failure surfaced inside a batch response at `results[i]`
|
|
104
|
+
* when Cedar couldn't be reached for that item.
|
|
105
|
+
*/
|
|
106
|
+
export class BatchItemError {
|
|
107
|
+
private constructor();
|
|
108
|
+
free(): void;
|
|
109
|
+
[Symbol.dispose](): void;
|
|
110
|
+
/**
|
|
111
|
+
* Stable variant slug — `action_parse`, `resource_build`, `context_build`,
|
|
112
|
+
* `principal_build`, `schema_validation`, `multi_issuer_entity`,
|
|
113
|
+
* `request_validation`.
|
|
114
|
+
*/
|
|
115
|
+
readonly category: string;
|
|
116
|
+
/**
|
|
117
|
+
* Position of the failing item in the original `items` vector.
|
|
118
|
+
*/
|
|
119
|
+
readonly item_index: number;
|
|
120
|
+
/**
|
|
121
|
+
* Human-readable diagnostic. Safe to log.
|
|
122
|
+
*/
|
|
123
|
+
readonly message: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Multi-issuer analog of [`BatchItemUnsignedResult`].
|
|
128
|
+
*/
|
|
129
|
+
export class BatchItemMultiIssuerResult {
|
|
130
|
+
private constructor();
|
|
131
|
+
free(): void;
|
|
132
|
+
[Symbol.dispose](): void;
|
|
133
|
+
/**
|
|
134
|
+
* The multi-issuer decision if `is_ok()`; throws otherwise.
|
|
135
|
+
*/
|
|
136
|
+
unwrap(): MultiIssuerAuthorizeResult;
|
|
137
|
+
/**
|
|
138
|
+
* The per-item error if `!is_ok()`; `undefined` otherwise.
|
|
139
|
+
*/
|
|
140
|
+
readonly error: BatchItemError | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* `true` when Cedar evaluated this item.
|
|
143
|
+
*/
|
|
144
|
+
readonly is_ok: boolean;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* One slot in a batch response's `results` array. Callers switch on
|
|
149
|
+
* `is_ok()` — on `true`, read `unwrap()`; on `false`, read `error()`.
|
|
150
|
+
*/
|
|
151
|
+
export class BatchItemUnsignedResult {
|
|
152
|
+
private constructor();
|
|
153
|
+
free(): void;
|
|
154
|
+
[Symbol.dispose](): void;
|
|
155
|
+
/**
|
|
156
|
+
* The Cedar decision if `is_ok()`; throws otherwise.
|
|
157
|
+
*/
|
|
158
|
+
unwrap(): AuthorizeResult;
|
|
159
|
+
/**
|
|
160
|
+
* The per-item error if `!is_ok()`; `undefined` otherwise.
|
|
161
|
+
*/
|
|
162
|
+
readonly error: BatchItemError | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* `true` when Cedar evaluated this item (Allow or Deny); `false` when it
|
|
165
|
+
* failed to build.
|
|
166
|
+
*/
|
|
167
|
+
readonly is_ok: boolean;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The instance of the Cedarling application.
|
|
172
|
+
*/
|
|
173
|
+
export class Cedarling {
|
|
174
|
+
private constructor();
|
|
175
|
+
free(): void;
|
|
176
|
+
[Symbol.dispose](): void;
|
|
177
|
+
/**
|
|
178
|
+
* Collect every value of the annotation `key` across the given policies,
|
|
179
|
+
* preserving duplicates. Unknown policy IDs are silently skipped.
|
|
180
|
+
*
|
|
181
|
+
* # Arguments
|
|
182
|
+
*
|
|
183
|
+
* * `policy_ids` - List of policy IDs to search. Typically
|
|
184
|
+
* `result.response.diagnostics.reason` from an authorization result.
|
|
185
|
+
* * `key` - The annotation key to collect values for (e.g. `"redirect"`).
|
|
186
|
+
*
|
|
187
|
+
* # Example
|
|
188
|
+
*
|
|
189
|
+
* ```javascript
|
|
190
|
+
* const redirects = cedarling.annotationValues(
|
|
191
|
+
* result.response.diagnostics.reason,
|
|
192
|
+
* "redirect",
|
|
193
|
+
* );
|
|
194
|
+
* // ["/upgrade"]
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
annotationValues(policy_ids: string[], key: string): string[];
|
|
198
|
+
/**
|
|
199
|
+
* Return the annotations of each given policy, grouped by policy ID. It is
|
|
200
|
+
* the loss-free companion to `annotationsMap`. Unknown policy IDs are
|
|
201
|
+
* silently skipped.
|
|
202
|
+
*
|
|
203
|
+
* # Arguments
|
|
204
|
+
*
|
|
205
|
+
* * `policy_ids` - List of policy IDs whose annotations should be returned
|
|
206
|
+
* grouped by policy ID. Typically `result.response.diagnostics.reason` from
|
|
207
|
+
* an authorization result.
|
|
208
|
+
*
|
|
209
|
+
* # Example
|
|
210
|
+
*
|
|
211
|
+
* ```javascript
|
|
212
|
+
* const byPolicy = cedarling.annotationsByPolicy(result.response.diagnostics.reason);
|
|
213
|
+
* // { "5": { redirect: "/upgrade", tier: "premium" } }
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
annotationsByPolicy(policy_ids: string[]): any;
|
|
217
|
+
/**
|
|
218
|
+
* Merge the annotations (`@key("value")`) of the given policies into a single object.
|
|
219
|
+
*
|
|
220
|
+
* Intended for resolving the determining policies of an authorization decision:
|
|
221
|
+
* pass `result.response.diagnostics.reason`.
|
|
222
|
+
*
|
|
223
|
+
* Lossy: if the same annotation key appears on several policies, one value wins
|
|
224
|
+
* arbitrarily. Use `annotationValues` / `annotationsByPolicy` when duplicates
|
|
225
|
+
* matter. Unknown policy IDs are silently skipped.
|
|
226
|
+
*
|
|
227
|
+
* # Arguments
|
|
228
|
+
*
|
|
229
|
+
* * `policy_ids` - List of policy IDs whose annotations should be merged into
|
|
230
|
+
* a single object. Typically `result.response.diagnostics.reason` from an
|
|
231
|
+
* authorization result.
|
|
232
|
+
*
|
|
233
|
+
* # Example
|
|
234
|
+
*
|
|
235
|
+
* ```javascript
|
|
236
|
+
* const annotations = cedarling.annotationsMap(result.response.diagnostics.reason);
|
|
237
|
+
* // { redirect: "/upgrade", tier: "premium" }
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
annotationsMap(policy_ids: string[]): any;
|
|
241
|
+
/**
|
|
242
|
+
* Authorize a batch of multi-issuer requests against one shared token set.
|
|
243
|
+
*
|
|
244
|
+
* Tokens are validated and token/issuer entities are built once, then
|
|
245
|
+
* each item is evaluated in input order. Batch-level failures (validation,
|
|
246
|
+
* JWT verification, status-list refresh) reject the whole call; per-item
|
|
247
|
+
* failures are returned as `BatchItemError` results and exposed by WASM
|
|
248
|
+
* with `is_ok=false` and `error`, while genuine Cedar denials remain
|
|
249
|
+
* `AuthorizeResult` values with `decision=false`.
|
|
250
|
+
*
|
|
251
|
+
* # Arguments
|
|
252
|
+
*
|
|
253
|
+
* * `request` - JSON string representation of [`BatchAuthorizeMultiIssuerRequest`].
|
|
254
|
+
*
|
|
255
|
+
* # Example
|
|
256
|
+
*
|
|
257
|
+
* ```javascript
|
|
258
|
+
* const result = await cedarling.authorizeMultiIssuerBatch(JSON.stringify(batchRequest));
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
authorizeMultiIssuerBatch(request: string): Promise<BatchAuthorizeMultiIssuerResponse>;
|
|
262
|
+
/**
|
|
263
|
+
* Authorize multi-issuer request.
|
|
264
|
+
* Makes authorization decision based on multiple JWT tokens from different issuers.
|
|
265
|
+
*
|
|
266
|
+
* # Arguments
|
|
267
|
+
*
|
|
268
|
+
* * `request` - JSON string representation of [`AuthorizeMultiIssuerRequest`].
|
|
269
|
+
*
|
|
270
|
+
* # Example
|
|
271
|
+
*
|
|
272
|
+
* ```javascript
|
|
273
|
+
* const result = await cedarling.authorizeMultiIssuer(JSON.stringify(request));
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
authorizeMultiIssuer(request: string): Promise<MultiIssuerAuthorizeResult>;
|
|
277
|
+
/**
|
|
278
|
+
* Authorize a batch of unsigned requests against one shared principal.
|
|
279
|
+
*
|
|
280
|
+
* Setup work (principal build + pushed-data snapshot) runs once and each
|
|
281
|
+
* item is evaluated in input order. Results are returned inside a
|
|
282
|
+
* [`BatchAuthorizeUnsignedResponse`] carrying the shared `batch_id`.
|
|
283
|
+
* Batch-level failures (validation, principal parse) reject the whole
|
|
284
|
+
* call; per-item failures are returned as `BatchItemError` results and
|
|
285
|
+
* exposed by WASM with `is_ok=false` and `error`, while genuine Cedar
|
|
286
|
+
* denials remain `AuthorizeResult` values with `decision=false`.
|
|
287
|
+
* # Arguments
|
|
288
|
+
*
|
|
289
|
+
* * `request` - JSON string representation of [`BatchAuthorizeUnsignedRequest`].
|
|
290
|
+
*
|
|
291
|
+
* # Example
|
|
292
|
+
*
|
|
293
|
+
* ```javascript
|
|
294
|
+
* const result = await cedarling.authorizeUnsignedBatch(JSON.stringify(batchRequest));
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
authorizeUnsignedBatch(request: string): Promise<BatchAuthorizeUnsignedResponse>;
|
|
298
|
+
/**
|
|
299
|
+
* Authorize an unsigned request carrying an optional single principal.
|
|
300
|
+
* Makes an authorization decision based on the [`RequestUnsigned`].
|
|
301
|
+
*
|
|
302
|
+
* When `principal` is omitted / `null` on the JS side the core uses Cedar
|
|
303
|
+
* partial evaluation; residual-dependent requests fail closed with
|
|
304
|
+
* `Decision::Deny` and surface residual policy ids in
|
|
305
|
+
* `response.diagnostics.reason`.
|
|
306
|
+
*
|
|
307
|
+
* # Arguments
|
|
308
|
+
*
|
|
309
|
+
* * `request` - JSON string representation of [`RequestUnsigned`].
|
|
310
|
+
*
|
|
311
|
+
* # Example
|
|
312
|
+
*
|
|
313
|
+
* ```javascript
|
|
314
|
+
* const result = await cedarling.authorizeUnsigned(JSON.stringify(request));
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
authorizeUnsigned(request: string): Promise<AuthorizeResult>;
|
|
318
|
+
/**
|
|
319
|
+
* Clear all entries from the data store.
|
|
320
|
+
*
|
|
321
|
+
* # Arguments
|
|
322
|
+
*
|
|
323
|
+
* None.
|
|
324
|
+
*
|
|
325
|
+
* # Example
|
|
326
|
+
*
|
|
327
|
+
* ```javascript
|
|
328
|
+
* cedarling.clearDataCtx();
|
|
329
|
+
* console.log("All data entries cleared");
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
clearDataCtx(): void;
|
|
333
|
+
/**
|
|
334
|
+
* Destructive read: returns the telemetry metrics snapshot and resets
|
|
335
|
+
* the counters for the next interval.
|
|
336
|
+
*
|
|
337
|
+
* Fails when `CEDARLING_METRICS_COLLECTION` is disabled or whenever
|
|
338
|
+
* `CEDARLING_LOCK_TELEMETRY_INTERVAL` is set (even if the Lock server
|
|
339
|
+
* has no telemetry endpoint). `interval_secs` is fractional seconds,
|
|
340
|
+
* so sub-second intervals are reported exactly.
|
|
341
|
+
*
|
|
342
|
+
* # Example
|
|
343
|
+
*
|
|
344
|
+
* ```javascript
|
|
345
|
+
* const snapshot = cedarling.drainMetrics();
|
|
346
|
+
* console.log(`Requests: ${snapshot.operational_stats.get("authz.requests_total")}`);
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
drainMetrics(): MetricsSnapshot;
|
|
350
|
+
/**
|
|
351
|
+
* Get trusted issuer identifiers that failed to load.
|
|
352
|
+
*
|
|
353
|
+
* # Arguments
|
|
354
|
+
*
|
|
355
|
+
* None.
|
|
356
|
+
*
|
|
357
|
+
* # Example
|
|
358
|
+
*
|
|
359
|
+
* ```javascript
|
|
360
|
+
* const ids = cedarling.failedTrustedIssuerIds();
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
failedTrustedIssuerIds(): Array<any>;
|
|
364
|
+
/**
|
|
365
|
+
* Get a value from the data store by key.
|
|
366
|
+
* Returns null if the key doesn't exist or the entry has expired.
|
|
367
|
+
*
|
|
368
|
+
* # Arguments
|
|
369
|
+
*
|
|
370
|
+
* * `key` - A string key for the data entry to retrieve
|
|
371
|
+
*
|
|
372
|
+
* # Example
|
|
373
|
+
*
|
|
374
|
+
* ```javascript
|
|
375
|
+
* const value = cedarling.getDataCtx("user:123");
|
|
376
|
+
* if (value !== null) {
|
|
377
|
+
* console.log(value.name); // "John"
|
|
378
|
+
* }
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
getDataCtx(key: string): any;
|
|
382
|
+
/**
|
|
383
|
+
* Get a data entry with full metadata by key.
|
|
384
|
+
* Returns undefined if the key doesn't exist or the entry has expired.
|
|
385
|
+
*
|
|
386
|
+
* # Arguments
|
|
387
|
+
*
|
|
388
|
+
* * `key` - A string key for the data entry to retrieve
|
|
389
|
+
*
|
|
390
|
+
* # Example
|
|
391
|
+
*
|
|
392
|
+
* ```javascript
|
|
393
|
+
* const entry = cedarling.getDataEntryCtx("user:123");
|
|
394
|
+
* if (entry !== undefined) {
|
|
395
|
+
* console.log(entry.key); // "user:123"
|
|
396
|
+
* console.log(entry.value()); // { name: "John", age: 30 }
|
|
397
|
+
* console.log(entry.data_type); // "Record"
|
|
398
|
+
* console.log(entry.created_at); // "2024-01-01T12:00:00Z"
|
|
399
|
+
* console.log(entry.access_count); // 5
|
|
400
|
+
* }
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
getDataEntryCtx(key: string): DataEntry | undefined;
|
|
404
|
+
/**
|
|
405
|
+
* Returns one retained memory log by ID, or `null` when it is not retained.
|
|
406
|
+
*
|
|
407
|
+
* # Arguments
|
|
408
|
+
*
|
|
409
|
+
* * `id` - The retained log identifier.
|
|
410
|
+
*
|
|
411
|
+
* # Example
|
|
412
|
+
*
|
|
413
|
+
* ```javascript
|
|
414
|
+
* const log = cedarling.getLogById("request-id");
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
getLogById(id: string): any;
|
|
418
|
+
/**
|
|
419
|
+
* Returns identifiers for all retained memory logs.
|
|
420
|
+
*
|
|
421
|
+
* # Arguments
|
|
422
|
+
*
|
|
423
|
+
* None.
|
|
424
|
+
*
|
|
425
|
+
* # Example
|
|
426
|
+
*
|
|
427
|
+
* ```javascript
|
|
428
|
+
* const ids = cedarling.getLogIds();
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
getLogIds(): Array<any>;
|
|
432
|
+
/**
|
|
433
|
+
* Returns retained memory logs matching one request ID and indexed value.
|
|
434
|
+
*
|
|
435
|
+
* # Arguments
|
|
436
|
+
*
|
|
437
|
+
* * `requestId` - The request identifier to match.
|
|
438
|
+
* * `tag` - A log kind (`"System"`, `"Decision"`, or `"Metric"`) or a
|
|
439
|
+
* system-log level such as `"DEBUG"`.
|
|
440
|
+
*
|
|
441
|
+
* # Example
|
|
442
|
+
*
|
|
443
|
+
* ```javascript
|
|
444
|
+
* const logs = cedarling.getLogsByRequestIdAndTag("request-id", "System");
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
getLogsByRequestIdAndTag(request_id: string, tag: string): any[];
|
|
448
|
+
/**
|
|
449
|
+
* Returns retained memory logs for one request ID.
|
|
450
|
+
*
|
|
451
|
+
* # Arguments
|
|
452
|
+
*
|
|
453
|
+
* * `requestId` - The request identifier to match.
|
|
454
|
+
*
|
|
455
|
+
* # Example
|
|
456
|
+
*
|
|
457
|
+
* ```javascript
|
|
458
|
+
* const logs = cedarling.getLogsByRequestId("request-id");
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
getLogsByRequestId(request_id: string): any[];
|
|
462
|
+
/**
|
|
463
|
+
* Returns retained memory logs matching an indexed value.
|
|
464
|
+
*
|
|
465
|
+
* # Arguments
|
|
466
|
+
*
|
|
467
|
+
* * `tag` - A log kind (`"System"`, `"Decision"`, or `"Metric"`) or a
|
|
468
|
+
* system-log level such as `"DEBUG"`.
|
|
469
|
+
*
|
|
470
|
+
* # Example
|
|
471
|
+
*
|
|
472
|
+
* ```javascript
|
|
473
|
+
* const logs = cedarling.getLogsByTag("System");
|
|
474
|
+
* ```
|
|
475
|
+
*/
|
|
476
|
+
getLogsByTag(tag: string): any[];
|
|
477
|
+
/**
|
|
478
|
+
* Get statistics about the data store.
|
|
479
|
+
*
|
|
480
|
+
* # Arguments
|
|
481
|
+
*
|
|
482
|
+
* None.
|
|
483
|
+
*
|
|
484
|
+
* # Example
|
|
485
|
+
*
|
|
486
|
+
* ```javascript
|
|
487
|
+
* const stats = cedarling.getStatsCtx();
|
|
488
|
+
* console.log(`Entries: ${stats.entry_count}/${stats.max_entries || 'unlimited'}`);
|
|
489
|
+
* console.log(`Capacity: ${stats.capacity_usage_percent.toFixed(2)}%`);
|
|
490
|
+
* console.log(`Total size: ${stats.total_size_bytes} bytes`);
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
getStatsCtx(): DataStoreStats;
|
|
494
|
+
/**
|
|
495
|
+
* Check whether a trusted issuer was loaded by `iss` claim.
|
|
496
|
+
*
|
|
497
|
+
* # Arguments
|
|
498
|
+
*
|
|
499
|
+
* * `iss_claim` - Issuer `iss` claim value to check.
|
|
500
|
+
*
|
|
501
|
+
* # Example
|
|
502
|
+
*
|
|
503
|
+
* ```javascript
|
|
504
|
+
* const ok = cedarling.isTrustedIssuerLoadedByIss("https://issuer.example.org");
|
|
505
|
+
* ```
|
|
506
|
+
*/
|
|
507
|
+
isTrustedIssuerLoadedByIss(iss_claim: string): boolean;
|
|
508
|
+
/**
|
|
509
|
+
* Check whether a trusted issuer was loaded by issuer identifier.
|
|
510
|
+
*
|
|
511
|
+
* # Arguments
|
|
512
|
+
*
|
|
513
|
+
* * `issuer_id` - Trusted issuer identifier to check.
|
|
514
|
+
*
|
|
515
|
+
* # Example
|
|
516
|
+
*
|
|
517
|
+
* ```javascript
|
|
518
|
+
* const ok = cedarling.isTrustedIssuerLoadedByName("issuer_id");
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
isTrustedIssuerLoadedByName(issuer_id: string): boolean;
|
|
522
|
+
/**
|
|
523
|
+
* List all entries with their metadata.
|
|
524
|
+
* Returns an array of DataEntry objects.
|
|
525
|
+
*
|
|
526
|
+
* # Arguments
|
|
527
|
+
*
|
|
528
|
+
* None.
|
|
529
|
+
*
|
|
530
|
+
* # Example
|
|
531
|
+
*
|
|
532
|
+
* ```javascript
|
|
533
|
+
* const entries = cedarling.listDataCtx();
|
|
534
|
+
* entries.forEach(entry => {
|
|
535
|
+
* console.log(`${entry.key}: ${entry.data_type} (accessed ${entry.access_count} times)`);
|
|
536
|
+
* });
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
listDataCtx(): Array<any>;
|
|
540
|
+
/**
|
|
541
|
+
* Get trusted issuer identifiers loaded successfully.
|
|
542
|
+
*
|
|
543
|
+
* # Arguments
|
|
544
|
+
*
|
|
545
|
+
* None.
|
|
546
|
+
*
|
|
547
|
+
* # Example
|
|
548
|
+
*
|
|
549
|
+
* ```javascript
|
|
550
|
+
* const ids = cedarling.loadedTrustedIssuerIds();
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
loadedTrustedIssuerIds(): Array<any>;
|
|
554
|
+
/**
|
|
555
|
+
* Get the number of trusted issuers loaded successfully.
|
|
556
|
+
*
|
|
557
|
+
* # Arguments
|
|
558
|
+
*
|
|
559
|
+
* None.
|
|
560
|
+
*
|
|
561
|
+
* # Example
|
|
562
|
+
*
|
|
563
|
+
* ```javascript
|
|
564
|
+
* const loadedCount = cedarling.loadedTrustedIssuersCount();
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
567
|
+
loadedTrustedIssuersCount(): number;
|
|
568
|
+
/**
|
|
569
|
+
* Creates a new Cedarling application from a JavaScript `Map`.
|
|
570
|
+
*
|
|
571
|
+
* # Arguments
|
|
572
|
+
*
|
|
573
|
+
* * `config` - A `Map` of Cedarling bootstrap-property names and values.
|
|
574
|
+
*
|
|
575
|
+
* # Example
|
|
576
|
+
*
|
|
577
|
+
* ```javascript
|
|
578
|
+
* await initWasm();
|
|
579
|
+
* const cedarling = await Cedarling.newFromMap(new Map([
|
|
580
|
+
* ["CEDARLING_APPLICATION_NAME", "task-api"],
|
|
581
|
+
* ["CEDARLING_POLICY_STORE_URI", "https://example.com/policy-store.cjar"],
|
|
582
|
+
* ["CEDARLING_LOG_TYPE", "memory"],
|
|
583
|
+
* ["CEDARLING_LOG_TTL", 120],
|
|
584
|
+
* ]));
|
|
585
|
+
* ```
|
|
586
|
+
*/
|
|
587
|
+
static newFromMap(config: Map<any, any>): Promise<Cedarling>;
|
|
588
|
+
/**
|
|
589
|
+
* Creates a Cedarling application from bootstrap properties.
|
|
590
|
+
*
|
|
591
|
+
* # Arguments
|
|
592
|
+
*
|
|
593
|
+
* * `config` - A plain object of Cedarling bootstrap-property names and values.
|
|
594
|
+
*
|
|
595
|
+
* # Example
|
|
596
|
+
*
|
|
597
|
+
* ```javascript
|
|
598
|
+
* await initWasm();
|
|
599
|
+
* const cedarling = await Cedarling.new({
|
|
600
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
601
|
+
* CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
|
|
602
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
603
|
+
* CEDARLING_LOG_TTL: 120,
|
|
604
|
+
* });
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
static new(config: object): Promise<Cedarling>;
|
|
608
|
+
/**
|
|
609
|
+
* Get the ID of the currently published policy store, if it carries one.
|
|
610
|
+
*
|
|
611
|
+
* `undefined` means the store carries no ID. The value is an opaque,
|
|
612
|
+
* source-dependent string; it may change after a background refresh.
|
|
613
|
+
*
|
|
614
|
+
* # Arguments
|
|
615
|
+
*
|
|
616
|
+
* None.
|
|
617
|
+
*
|
|
618
|
+
* # Example
|
|
619
|
+
*
|
|
620
|
+
* ```javascript
|
|
621
|
+
* const id = cedarling.policyStoreId();
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
policyStoreId(): string | undefined;
|
|
625
|
+
/**
|
|
626
|
+
* Returns all retained memory logs and removes them from storage.
|
|
627
|
+
* Other log configurations return an empty array.
|
|
628
|
+
*
|
|
629
|
+
* # Arguments
|
|
630
|
+
*
|
|
631
|
+
* None.
|
|
632
|
+
*
|
|
633
|
+
* # Example
|
|
634
|
+
*
|
|
635
|
+
* ```javascript
|
|
636
|
+
* const logs = cedarling.popLogs();
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
popLogs(): Array<any>;
|
|
640
|
+
/**
|
|
641
|
+
* Push a value into the data store with an optional TTL.
|
|
642
|
+
* If the key already exists, the value will be replaced.
|
|
643
|
+
* If TTL is not provided, the default TTL from configuration is used.
|
|
644
|
+
*
|
|
645
|
+
* # Arguments
|
|
646
|
+
*
|
|
647
|
+
* * `key` - A string key for the data entry (must not be empty)
|
|
648
|
+
* * `value` - The value to store (any JSON-serializable JavaScript value: object, array, string, number, boolean)
|
|
649
|
+
* * `ttl_secs` - Optional TTL in seconds (undefined/null uses default from config)
|
|
650
|
+
*
|
|
651
|
+
* # Example
|
|
652
|
+
*
|
|
653
|
+
* ```javascript
|
|
654
|
+
* cedarling.pushDataCtx("user:123", { name: "John", age: 30 }, 3600);
|
|
655
|
+
* cedarling.pushDataCtx("config", { setting: "value" }); // Uses default TTL
|
|
656
|
+
* ```
|
|
657
|
+
*/
|
|
658
|
+
pushDataCtx(key: string, value: any, ttl_secs?: bigint | null): void;
|
|
659
|
+
/**
|
|
660
|
+
* Remove a value from the data store by key.
|
|
661
|
+
* Returns true if the key existed and was removed, false otherwise.
|
|
662
|
+
*
|
|
663
|
+
* # Arguments
|
|
664
|
+
*
|
|
665
|
+
* * `key` - A string key for the data entry to remove
|
|
666
|
+
*
|
|
667
|
+
* # Example
|
|
668
|
+
*
|
|
669
|
+
* ```javascript
|
|
670
|
+
* const removed = cedarling.removeDataCtx("user:123");
|
|
671
|
+
* if (removed) {
|
|
672
|
+
* console.log("Entry was successfully removed");
|
|
673
|
+
* }
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
676
|
+
removeDataCtx(key: string): boolean;
|
|
677
|
+
/**
|
|
678
|
+
* Closes Lock Server connections and pushes all available logs.
|
|
679
|
+
*
|
|
680
|
+
* # Arguments
|
|
681
|
+
*
|
|
682
|
+
* None.
|
|
683
|
+
*
|
|
684
|
+
* # Example
|
|
685
|
+
*
|
|
686
|
+
* ```javascript
|
|
687
|
+
* await cedarling.shutDown();
|
|
688
|
+
* ```
|
|
689
|
+
*/
|
|
690
|
+
shutDown(): Promise<void>;
|
|
691
|
+
/**
|
|
692
|
+
* Get the total number of trusted issuer entries discovered.
|
|
693
|
+
*
|
|
694
|
+
* # Arguments
|
|
695
|
+
*
|
|
696
|
+
* None.
|
|
697
|
+
*
|
|
698
|
+
* # Example
|
|
699
|
+
*
|
|
700
|
+
* ```javascript
|
|
701
|
+
* const total = cedarling.totalIssuers();
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
704
|
+
totalIssuers(): number;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* A WASM wrapper for the Rust `cedarling::DataEntry` struct.
|
|
709
|
+
* Represents a data entry in the DataStore with value and metadata.
|
|
710
|
+
*/
|
|
711
|
+
export class DataEntry {
|
|
712
|
+
private constructor();
|
|
713
|
+
free(): void;
|
|
714
|
+
[Symbol.dispose](): void;
|
|
715
|
+
/**
|
|
716
|
+
* Convert `DataEntry` to json string value
|
|
717
|
+
*/
|
|
718
|
+
jsonString(): string;
|
|
719
|
+
/**
|
|
720
|
+
* Get the value stored in this entry as a JavaScript object
|
|
721
|
+
*/
|
|
722
|
+
value(): any;
|
|
723
|
+
/**
|
|
724
|
+
* Number of times this entry has been accessed
|
|
725
|
+
*/
|
|
726
|
+
access_count: bigint;
|
|
727
|
+
/**
|
|
728
|
+
* Timestamp when this entry was created (RFC 3339 format)
|
|
729
|
+
*/
|
|
730
|
+
created_at: string;
|
|
731
|
+
/**
|
|
732
|
+
* The inferred Cedar type of the value
|
|
733
|
+
*/
|
|
734
|
+
data_type: string;
|
|
735
|
+
/**
|
|
736
|
+
* Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
|
|
737
|
+
*/
|
|
738
|
+
get expires_at(): string | undefined;
|
|
739
|
+
/**
|
|
740
|
+
* Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
|
|
741
|
+
*/
|
|
742
|
+
set expires_at(value: string | null | undefined);
|
|
743
|
+
/**
|
|
744
|
+
* The key for this entry
|
|
745
|
+
*/
|
|
746
|
+
key: string;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* A WASM wrapper for the Rust `cedarling::DataStoreStats` struct.
|
|
751
|
+
* Statistics about the DataStore.
|
|
752
|
+
*/
|
|
753
|
+
export class DataStoreStats {
|
|
754
|
+
private constructor();
|
|
755
|
+
free(): void;
|
|
756
|
+
[Symbol.dispose](): void;
|
|
757
|
+
/**
|
|
758
|
+
* Convert `DataStoreStats` to json string value
|
|
759
|
+
*/
|
|
760
|
+
jsonString(): string;
|
|
761
|
+
/**
|
|
762
|
+
* Average size per entry in bytes (0 if no entries)
|
|
763
|
+
*/
|
|
764
|
+
avg_entry_size_bytes: number;
|
|
765
|
+
/**
|
|
766
|
+
* Percentage of capacity used (0.0-100.0, based on entry count)
|
|
767
|
+
*/
|
|
768
|
+
capacity_usage_percent: number;
|
|
769
|
+
/**
|
|
770
|
+
* Number of entries currently stored
|
|
771
|
+
*/
|
|
772
|
+
entry_count: number;
|
|
773
|
+
/**
|
|
774
|
+
* Maximum number of entries allowed (0 = unlimited)
|
|
775
|
+
*/
|
|
776
|
+
max_entries: number;
|
|
777
|
+
/**
|
|
778
|
+
* Maximum size per entry in bytes (0 = unlimited)
|
|
779
|
+
*/
|
|
780
|
+
max_entry_size: number;
|
|
781
|
+
/**
|
|
782
|
+
* Memory usage threshold percentage (from config)
|
|
783
|
+
*/
|
|
784
|
+
memory_alert_threshold: number;
|
|
785
|
+
/**
|
|
786
|
+
* Whether memory usage exceeds the alert threshold
|
|
787
|
+
*/
|
|
788
|
+
memory_alert_triggered: boolean;
|
|
789
|
+
/**
|
|
790
|
+
* Whether metrics tracking is enabled
|
|
791
|
+
*/
|
|
792
|
+
metrics_enabled: boolean;
|
|
793
|
+
/**
|
|
794
|
+
* Total size of all entries in bytes (approximate, based on JSON serialization)
|
|
795
|
+
*/
|
|
796
|
+
total_size_bytes: number;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Diagnostics
|
|
801
|
+
* ===========
|
|
802
|
+
*
|
|
803
|
+
* Provides detailed information about how a policy decision was made, including policies that contributed to the decision and any errors encountered during evaluation.
|
|
804
|
+
*/
|
|
805
|
+
export class Diagnostics {
|
|
806
|
+
private constructor();
|
|
807
|
+
free(): void;
|
|
808
|
+
[Symbol.dispose](): void;
|
|
809
|
+
/**
|
|
810
|
+
* Errors that occurred during authorization. The errors should be
|
|
811
|
+
* treated as unordered, since policies may be evaluated in any order.
|
|
812
|
+
*/
|
|
813
|
+
readonly errors: PolicyEvaluationError[];
|
|
814
|
+
/**
|
|
815
|
+
* `PolicyId`s of the policies that contributed to the decision.
|
|
816
|
+
* If no policies applied to the request, this set will be empty.
|
|
817
|
+
*
|
|
818
|
+
* The ids should be treated as unordered,
|
|
819
|
+
*/
|
|
820
|
+
readonly reason: string[];
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
declare class IntoUnderlyingByteSource {
|
|
824
|
+
private constructor();
|
|
825
|
+
free(): void;
|
|
826
|
+
[Symbol.dispose](): void;
|
|
827
|
+
cancel(): void;
|
|
828
|
+
pull(controller: ReadableByteStreamController): Promise<any>;
|
|
829
|
+
start(controller: ReadableByteStreamController): void;
|
|
830
|
+
readonly autoAllocateChunkSize: number;
|
|
831
|
+
readonly type: ReadableStreamType;
|
|
832
|
+
}
|
|
833
|
+
export type { IntoUnderlyingByteSource };
|
|
834
|
+
|
|
835
|
+
declare class IntoUnderlyingSink {
|
|
836
|
+
private constructor();
|
|
837
|
+
free(): void;
|
|
838
|
+
[Symbol.dispose](): void;
|
|
839
|
+
abort(reason: any): Promise<any>;
|
|
840
|
+
close(): Promise<any>;
|
|
841
|
+
write(chunk: any): Promise<any>;
|
|
842
|
+
}
|
|
843
|
+
export type { IntoUnderlyingSink };
|
|
844
|
+
|
|
845
|
+
declare class IntoUnderlyingSource {
|
|
846
|
+
private constructor();
|
|
847
|
+
free(): void;
|
|
848
|
+
[Symbol.dispose](): void;
|
|
849
|
+
cancel(): void;
|
|
850
|
+
pull(controller: ReadableStreamDefaultController): Promise<any>;
|
|
851
|
+
}
|
|
852
|
+
export type { IntoUnderlyingSource };
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* A WASM wrapper for the Rust `cedarling::MetricsSnapshot` struct.
|
|
856
|
+
* Represents a snapshot of the collected telemetry metrics for the current
|
|
857
|
+
* interval. Destructive read: taking a snapshot resets the collected
|
|
858
|
+
* metrics, so use a single consumer.
|
|
859
|
+
*/
|
|
860
|
+
export class MetricsSnapshot {
|
|
861
|
+
private constructor();
|
|
862
|
+
free(): void;
|
|
863
|
+
[Symbol.dispose](): void;
|
|
864
|
+
/**
|
|
865
|
+
* Convert `MetricsSnapshot` to json string value.
|
|
866
|
+
*
|
|
867
|
+
* `policy_stats`, `error_counters` and `operational_stats` are converted
|
|
868
|
+
* from `Map` to plain objects so `JSON.stringify` emits their entries.
|
|
869
|
+
*/
|
|
870
|
+
jsonString(): string;
|
|
871
|
+
/**
|
|
872
|
+
* Classified error counters keyed by error metric key.
|
|
873
|
+
*/
|
|
874
|
+
error_counters: Map<any, any>;
|
|
875
|
+
/**
|
|
876
|
+
* Duration of the snapshot interval in fractional seconds.
|
|
877
|
+
* Exposed as `Number` (not `BigInt`) so plain JS arithmetic works.
|
|
878
|
+
*/
|
|
879
|
+
interval_secs: number;
|
|
880
|
+
/**
|
|
881
|
+
* Operational counters and gauges (authorization, cache, JWT, data, lock).
|
|
882
|
+
*/
|
|
883
|
+
operational_stats: Map<any, any>;
|
|
884
|
+
/**
|
|
885
|
+
* Per-policy evaluation counts (`policy_id`, `policy_id.allow`, `policy_id.deny`).
|
|
886
|
+
*/
|
|
887
|
+
policy_stats: Map<any, any>;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* A WASM wrapper for the Rust `cedarling::MultiIssuerAuthorizeResult` struct.
|
|
892
|
+
* Represents the result of a multi-issuer authorization request.
|
|
893
|
+
*/
|
|
894
|
+
export class MultiIssuerAuthorizeResult {
|
|
895
|
+
private constructor();
|
|
896
|
+
free(): void;
|
|
897
|
+
[Symbol.dispose](): void;
|
|
898
|
+
/**
|
|
899
|
+
* Convert `MultiIssuerAuthorizeResult` to json string value
|
|
900
|
+
*/
|
|
901
|
+
jsonString(): string;
|
|
902
|
+
/**
|
|
903
|
+
* Result of authorization
|
|
904
|
+
* true means `ALLOW`
|
|
905
|
+
* false means `Deny`
|
|
906
|
+
*/
|
|
907
|
+
decision: boolean;
|
|
908
|
+
/**
|
|
909
|
+
* Request ID of the authorization request
|
|
910
|
+
*/
|
|
911
|
+
request_id: string;
|
|
912
|
+
/**
|
|
913
|
+
* Result of Cedar policy authorization
|
|
914
|
+
*/
|
|
915
|
+
response: AuthorizeResultResponse;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* PolicyEvaluationError
|
|
920
|
+
* =====================
|
|
921
|
+
*
|
|
922
|
+
* Represents an error that occurred when evaluating a Cedar policy.
|
|
923
|
+
*/
|
|
924
|
+
export class PolicyEvaluationError {
|
|
925
|
+
private constructor();
|
|
926
|
+
free(): void;
|
|
927
|
+
[Symbol.dispose](): void;
|
|
928
|
+
/**
|
|
929
|
+
* Underlying evaluation error string representation
|
|
930
|
+
*/
|
|
931
|
+
readonly error: string;
|
|
932
|
+
/**
|
|
933
|
+
* Id of the policy with an error
|
|
934
|
+
*/
|
|
935
|
+
readonly id: string;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Creates a Cedarling application from bootstrap properties.
|
|
940
|
+
*
|
|
941
|
+
* # Arguments
|
|
942
|
+
*
|
|
943
|
+
* * `config` - A JavaScript `Map` or plain object of Cedarling
|
|
944
|
+
* bootstrap-property names and values.
|
|
945
|
+
*
|
|
946
|
+
* # Example
|
|
947
|
+
*
|
|
948
|
+
* ```javascript
|
|
949
|
+
* await initWasm();
|
|
950
|
+
* const cedarling = await init({
|
|
951
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
952
|
+
* CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
|
|
953
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
954
|
+
* CEDARLING_LOG_TTL: 120,
|
|
955
|
+
* });
|
|
956
|
+
* ```
|
|
957
|
+
*/
|
|
958
|
+
export function init(config: any): Promise<Cedarling>;
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Create a new instance of the Cedarling application from archive bytes.
|
|
962
|
+
*
|
|
963
|
+
* This function allows loading a policy store from a Cedar Archive (.cjar)
|
|
964
|
+
* that was fetched with custom logic (e.g., with authentication headers).
|
|
965
|
+
*
|
|
966
|
+
* # Arguments
|
|
967
|
+
* * `config` - Bootstrap configuration (Map or Object) without a policy-store
|
|
968
|
+
* source property. The archive bytes provide the policy store.
|
|
969
|
+
* * `archive_bytes` - The .cjar archive bytes (Uint8Array)
|
|
970
|
+
*
|
|
971
|
+
* # Example
|
|
972
|
+
* ```javascript
|
|
973
|
+
* await initWasm();
|
|
974
|
+
* const config = {
|
|
975
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
976
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
977
|
+
* CEDARLING_LOG_TTL: 120,
|
|
978
|
+
* };
|
|
979
|
+
* const response = await fetch("https://example.com/policy-store.cjar", {
|
|
980
|
+
* headers: { Authorization: "Bearer <token>" },
|
|
981
|
+
* });
|
|
982
|
+
* if (!response.ok) throw new Error("Unable to fetch policy store");
|
|
983
|
+
* const archiveBytes = new Uint8Array(await response.arrayBuffer());
|
|
984
|
+
* const cedarling = await initFromArchiveBytes(config, archiveBytes);
|
|
985
|
+
* ```
|
|
986
|
+
*/
|
|
987
|
+
export function initFromArchiveBytes(config: any, archive_bytes: Uint8Array): Promise<Cedarling>;
|
|
988
|
+
|
|
989
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
990
|
+
|
|
991
|
+
export interface InitOutput {
|
|
992
|
+
readonly memory: WebAssembly.Memory;
|
|
993
|
+
readonly __wbg_authorizeresult_free: (a: number, b: number) => void;
|
|
994
|
+
readonly __wbg_authorizeresultresponse_free: (a: number, b: number) => void;
|
|
995
|
+
readonly __wbg_batchauthorizemultiissuerresponse_free: (a: number, b: number) => void;
|
|
996
|
+
readonly __wbg_batchauthorizeunsignedresponse_free: (a: number, b: number) => void;
|
|
997
|
+
readonly __wbg_batchitemerror_free: (a: number, b: number) => void;
|
|
998
|
+
readonly __wbg_batchitemmultiissuerresult_free: (a: number, b: number) => void;
|
|
999
|
+
readonly __wbg_batchitemunsignedresult_free: (a: number, b: number) => void;
|
|
1000
|
+
readonly __wbg_cedarling_free: (a: number, b: number) => void;
|
|
1001
|
+
readonly __wbg_dataentry_free: (a: number, b: number) => void;
|
|
1002
|
+
readonly __wbg_datastorestats_free: (a: number, b: number) => void;
|
|
1003
|
+
readonly __wbg_diagnostics_free: (a: number, b: number) => void;
|
|
1004
|
+
readonly __wbg_get_authorizeresult_decision: (a: number) => number;
|
|
1005
|
+
readonly __wbg_get_authorizeresult_request_id: (a: number, b: number) => void;
|
|
1006
|
+
readonly __wbg_get_authorizeresult_response: (a: number) => number;
|
|
1007
|
+
readonly __wbg_get_dataentry_access_count: (a: number) => bigint;
|
|
1008
|
+
readonly __wbg_get_dataentry_created_at: (a: number, b: number) => void;
|
|
1009
|
+
readonly __wbg_get_dataentry_data_type: (a: number, b: number) => void;
|
|
1010
|
+
readonly __wbg_get_dataentry_expires_at: (a: number, b: number) => void;
|
|
1011
|
+
readonly __wbg_get_dataentry_key: (a: number, b: number) => void;
|
|
1012
|
+
readonly __wbg_get_datastorestats_avg_entry_size_bytes: (a: number) => number;
|
|
1013
|
+
readonly __wbg_get_datastorestats_capacity_usage_percent: (a: number) => number;
|
|
1014
|
+
readonly __wbg_get_datastorestats_entry_count: (a: number) => number;
|
|
1015
|
+
readonly __wbg_get_datastorestats_max_entries: (a: number) => number;
|
|
1016
|
+
readonly __wbg_get_datastorestats_max_entry_size: (a: number) => number;
|
|
1017
|
+
readonly __wbg_get_datastorestats_memory_alert_threshold: (a: number) => number;
|
|
1018
|
+
readonly __wbg_get_datastorestats_memory_alert_triggered: (a: number) => number;
|
|
1019
|
+
readonly __wbg_get_datastorestats_metrics_enabled: (a: number) => number;
|
|
1020
|
+
readonly __wbg_get_datastorestats_total_size_bytes: (a: number) => number;
|
|
1021
|
+
readonly __wbg_get_metricssnapshot_error_counters: (a: number) => number;
|
|
1022
|
+
readonly __wbg_get_metricssnapshot_interval_secs: (a: number) => number;
|
|
1023
|
+
readonly __wbg_get_metricssnapshot_operational_stats: (a: number) => number;
|
|
1024
|
+
readonly __wbg_get_metricssnapshot_policy_stats: (a: number) => number;
|
|
1025
|
+
readonly __wbg_get_multiissuerauthorizeresult_decision: (a: number) => number;
|
|
1026
|
+
readonly __wbg_get_multiissuerauthorizeresult_request_id: (a: number, b: number) => void;
|
|
1027
|
+
readonly __wbg_get_multiissuerauthorizeresult_response: (a: number) => number;
|
|
1028
|
+
readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
|
|
1029
|
+
readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
|
|
1030
|
+
readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
|
|
1031
|
+
readonly __wbg_metricssnapshot_free: (a: number, b: number) => void;
|
|
1032
|
+
readonly __wbg_multiissuerauthorizeresult_free: (a: number, b: number) => void;
|
|
1033
|
+
readonly __wbg_policyevaluationerror_free: (a: number, b: number) => void;
|
|
1034
|
+
readonly __wbg_set_authorizeresult_decision: (a: number, b: number) => void;
|
|
1035
|
+
readonly __wbg_set_authorizeresult_request_id: (a: number, b: number, c: number) => void;
|
|
1036
|
+
readonly __wbg_set_authorizeresult_response: (a: number, b: number) => void;
|
|
1037
|
+
readonly __wbg_set_dataentry_access_count: (a: number, b: bigint) => void;
|
|
1038
|
+
readonly __wbg_set_dataentry_created_at: (a: number, b: number, c: number) => void;
|
|
1039
|
+
readonly __wbg_set_dataentry_data_type: (a: number, b: number, c: number) => void;
|
|
1040
|
+
readonly __wbg_set_dataentry_expires_at: (a: number, b: number, c: number) => void;
|
|
1041
|
+
readonly __wbg_set_dataentry_key: (a: number, b: number, c: number) => void;
|
|
1042
|
+
readonly __wbg_set_datastorestats_avg_entry_size_bytes: (a: number, b: number) => void;
|
|
1043
|
+
readonly __wbg_set_datastorestats_capacity_usage_percent: (a: number, b: number) => void;
|
|
1044
|
+
readonly __wbg_set_datastorestats_entry_count: (a: number, b: number) => void;
|
|
1045
|
+
readonly __wbg_set_datastorestats_max_entries: (a: number, b: number) => void;
|
|
1046
|
+
readonly __wbg_set_datastorestats_max_entry_size: (a: number, b: number) => void;
|
|
1047
|
+
readonly __wbg_set_datastorestats_memory_alert_threshold: (a: number, b: number) => void;
|
|
1048
|
+
readonly __wbg_set_datastorestats_memory_alert_triggered: (a: number, b: number) => void;
|
|
1049
|
+
readonly __wbg_set_datastorestats_metrics_enabled: (a: number, b: number) => void;
|
|
1050
|
+
readonly __wbg_set_datastorestats_total_size_bytes: (a: number, b: number) => void;
|
|
1051
|
+
readonly __wbg_set_metricssnapshot_error_counters: (a: number, b: number) => void;
|
|
1052
|
+
readonly __wbg_set_metricssnapshot_interval_secs: (a: number, b: number) => void;
|
|
1053
|
+
readonly __wbg_set_metricssnapshot_operational_stats: (a: number, b: number) => void;
|
|
1054
|
+
readonly __wbg_set_metricssnapshot_policy_stats: (a: number, b: number) => void;
|
|
1055
|
+
readonly __wbg_set_multiissuerauthorizeresult_decision: (a: number, b: number) => void;
|
|
1056
|
+
readonly __wbg_set_multiissuerauthorizeresult_request_id: (a: number, b: number, c: number) => void;
|
|
1057
|
+
readonly __wbg_set_multiissuerauthorizeresult_response: (a: number, b: number) => void;
|
|
1058
|
+
readonly authorizeresult_jsonString: (a: number, b: number) => void;
|
|
1059
|
+
readonly authorizeresultresponse_decision: (a: number) => number;
|
|
1060
|
+
readonly authorizeresultresponse_diagnostics: (a: number) => number;
|
|
1061
|
+
readonly batchauthorizemultiissuerresponse_batch_id: (a: number, b: number) => void;
|
|
1062
|
+
readonly batchauthorizemultiissuerresponse_results: (a: number, b: number) => void;
|
|
1063
|
+
readonly batchauthorizeunsignedresponse_batch_id: (a: number, b: number) => void;
|
|
1064
|
+
readonly batchauthorizeunsignedresponse_results: (a: number, b: number) => void;
|
|
1065
|
+
readonly batchitemerror_category: (a: number, b: number) => void;
|
|
1066
|
+
readonly batchitemerror_item_index: (a: number) => number;
|
|
1067
|
+
readonly batchitemerror_message: (a: number, b: number) => void;
|
|
1068
|
+
readonly batchitemmultiissuerresult_error: (a: number) => number;
|
|
1069
|
+
readonly batchitemmultiissuerresult_is_ok: (a: number) => number;
|
|
1070
|
+
readonly batchitemmultiissuerresult_unwrap: (a: number, b: number) => void;
|
|
1071
|
+
readonly batchitemunsignedresult_error: (a: number) => number;
|
|
1072
|
+
readonly batchitemunsignedresult_is_ok: (a: number) => number;
|
|
1073
|
+
readonly batchitemunsignedresult_unwrap: (a: number, b: number) => void;
|
|
1074
|
+
readonly cedarling_annotationValues: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
1075
|
+
readonly cedarling_annotationsByPolicy: (a: number, b: number, c: number, d: number) => void;
|
|
1076
|
+
readonly cedarling_annotationsMap: (a: number, b: number, c: number, d: number) => void;
|
|
1077
|
+
readonly cedarling_authorizeMultiIssuer: (a: number, b: number, c: number) => number;
|
|
1078
|
+
readonly cedarling_authorizeMultiIssuerBatch: (a: number, b: number, c: number) => number;
|
|
1079
|
+
readonly cedarling_authorizeUnsigned: (a: number, b: number, c: number) => number;
|
|
1080
|
+
readonly cedarling_authorizeUnsignedBatch: (a: number, b: number, c: number) => number;
|
|
1081
|
+
readonly cedarling_clearDataCtx: (a: number, b: number) => void;
|
|
1082
|
+
readonly cedarling_drainMetrics: (a: number, b: number) => void;
|
|
1083
|
+
readonly cedarling_failedTrustedIssuerIds: (a: number) => number;
|
|
1084
|
+
readonly cedarling_getDataCtx: (a: number, b: number, c: number, d: number) => void;
|
|
1085
|
+
readonly cedarling_getDataEntryCtx: (a: number, b: number, c: number, d: number) => void;
|
|
1086
|
+
readonly cedarling_getLogById: (a: number, b: number, c: number, d: number) => void;
|
|
1087
|
+
readonly cedarling_getLogIds: (a: number) => number;
|
|
1088
|
+
readonly cedarling_getLogsByRequestId: (a: number, b: number, c: number, d: number) => void;
|
|
1089
|
+
readonly cedarling_getLogsByRequestIdAndTag: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
1090
|
+
readonly cedarling_getLogsByTag: (a: number, b: number, c: number, d: number) => void;
|
|
1091
|
+
readonly cedarling_getStatsCtx: (a: number, b: number) => void;
|
|
1092
|
+
readonly cedarling_isTrustedIssuerLoadedByIss: (a: number, b: number, c: number) => number;
|
|
1093
|
+
readonly cedarling_isTrustedIssuerLoadedByName: (a: number, b: number, c: number) => number;
|
|
1094
|
+
readonly cedarling_listDataCtx: (a: number, b: number) => void;
|
|
1095
|
+
readonly cedarling_loadedTrustedIssuerIds: (a: number) => number;
|
|
1096
|
+
readonly cedarling_loadedTrustedIssuersCount: (a: number) => number;
|
|
1097
|
+
readonly cedarling_new: (a: number) => number;
|
|
1098
|
+
readonly cedarling_newFromMap: (a: number) => number;
|
|
1099
|
+
readonly cedarling_policyStoreId: (a: number, b: number) => void;
|
|
1100
|
+
readonly cedarling_popLogs: (a: number, b: number) => void;
|
|
1101
|
+
readonly cedarling_pushDataCtx: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
|
|
1102
|
+
readonly cedarling_removeDataCtx: (a: number, b: number, c: number, d: number) => void;
|
|
1103
|
+
readonly cedarling_shutDown: (a: number) => number;
|
|
1104
|
+
readonly cedarling_totalIssuers: (a: number) => number;
|
|
1105
|
+
readonly dataentry_jsonString: (a: number, b: number) => void;
|
|
1106
|
+
readonly dataentry_value: (a: number, b: number) => void;
|
|
1107
|
+
readonly datastorestats_jsonString: (a: number, b: number) => void;
|
|
1108
|
+
readonly diagnostics_errors: (a: number, b: number) => void;
|
|
1109
|
+
readonly diagnostics_reason: (a: number, b: number) => void;
|
|
1110
|
+
readonly init: (a: number) => number;
|
|
1111
|
+
readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
1112
|
+
readonly rust_zstd_wasm_shim_free: (a: number) => void;
|
|
1113
|
+
readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
|
|
1114
|
+
readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
|
|
1115
|
+
readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
|
|
1116
|
+
readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
|
|
1117
|
+
readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
|
|
1118
|
+
readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
|
|
1119
|
+
readonly initFromArchiveBytes: (a: number, b: number) => number;
|
|
1120
|
+
readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
|
|
1121
|
+
readonly intounderlyingbytesource_cancel: (a: number) => void;
|
|
1122
|
+
readonly intounderlyingbytesource_pull: (a: number, b: number) => number;
|
|
1123
|
+
readonly intounderlyingbytesource_start: (a: number, b: number) => void;
|
|
1124
|
+
readonly intounderlyingbytesource_type: (a: number) => number;
|
|
1125
|
+
readonly intounderlyingsink_abort: (a: number, b: number) => number;
|
|
1126
|
+
readonly intounderlyingsink_close: (a: number) => number;
|
|
1127
|
+
readonly intounderlyingsink_write: (a: number, b: number) => number;
|
|
1128
|
+
readonly intounderlyingsource_cancel: (a: number) => void;
|
|
1129
|
+
readonly intounderlyingsource_pull: (a: number, b: number) => number;
|
|
1130
|
+
readonly metricssnapshot_jsonString: (a: number, b: number) => void;
|
|
1131
|
+
readonly multiissuerauthorizeresult_jsonString: (a: number, b: number) => void;
|
|
1132
|
+
readonly policyevaluationerror_error: (a: number, b: number) => void;
|
|
1133
|
+
readonly policyevaluationerror_id: (a: number, b: number) => void;
|
|
1134
|
+
readonly __wasm_bindgen_func_elem_8937: (a: number, b: number, c: number, d: number) => void;
|
|
1135
|
+
readonly __wasm_bindgen_func_elem_8992: (a: number, b: number, c: number, d: number) => void;
|
|
1136
|
+
readonly __wasm_bindgen_func_elem_12497: (a: number, b: number, c: number) => void;
|
|
1137
|
+
readonly __wasm_bindgen_func_elem_8771: (a: number, b: number) => void;
|
|
1138
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
1139
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
1140
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
1141
|
+
readonly __wbindgen_export4: (a: number, b: number) => void;
|
|
1142
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
1143
|
+
readonly __wbindgen_export5: (a: number, b: number, c: number) => void;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
1150
|
+
* a precompiled `WebAssembly.Module`.
|
|
1151
|
+
*
|
|
1152
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
1153
|
+
*
|
|
1154
|
+
* @returns {InitOutput}
|
|
1155
|
+
*/
|
|
1156
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
1160
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
1161
|
+
*
|
|
1162
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
1163
|
+
*
|
|
1164
|
+
* @returns {Promise<InitOutput>}
|
|
1165
|
+
*/
|
|
1166
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|