@janssenproject/cedarling_wasm 0.0.467 → 0.0.469

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.
@@ -0,0 +1,1084 @@
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
+ * Get trusted issuer identifiers that failed to load.
335
+ *
336
+ * # Arguments
337
+ *
338
+ * None.
339
+ *
340
+ * # Example
341
+ *
342
+ * ```javascript
343
+ * const ids = cedarling.failedTrustedIssuerIds();
344
+ * ```
345
+ */
346
+ failedTrustedIssuerIds(): Array<any>;
347
+ /**
348
+ * Get a value from the data store by key.
349
+ * Returns null if the key doesn't exist or the entry has expired.
350
+ *
351
+ * # Arguments
352
+ *
353
+ * * `key` - A string key for the data entry to retrieve
354
+ *
355
+ * # Example
356
+ *
357
+ * ```javascript
358
+ * const value = cedarling.getDataCtx("user:123");
359
+ * if (value !== null) {
360
+ * console.log(value.name); // "John"
361
+ * }
362
+ * ```
363
+ */
364
+ getDataCtx(key: string): any;
365
+ /**
366
+ * Get a data entry with full metadata by key.
367
+ * Returns undefined if the key doesn't exist or the entry has expired.
368
+ *
369
+ * # Arguments
370
+ *
371
+ * * `key` - A string key for the data entry to retrieve
372
+ *
373
+ * # Example
374
+ *
375
+ * ```javascript
376
+ * const entry = cedarling.getDataEntryCtx("user:123");
377
+ * if (entry !== undefined) {
378
+ * console.log(entry.key); // "user:123"
379
+ * console.log(entry.value()); // { name: "John", age: 30 }
380
+ * console.log(entry.data_type); // "Record"
381
+ * console.log(entry.created_at); // "2024-01-01T12:00:00Z"
382
+ * console.log(entry.access_count); // 5
383
+ * }
384
+ * ```
385
+ */
386
+ getDataEntryCtx(key: string): DataEntry | undefined;
387
+ /**
388
+ * Returns one retained memory log by ID, or `null` when it is not retained.
389
+ *
390
+ * # Arguments
391
+ *
392
+ * * `id` - The retained log identifier.
393
+ *
394
+ * # Example
395
+ *
396
+ * ```javascript
397
+ * const log = cedarling.getLogById("request-id");
398
+ * ```
399
+ */
400
+ getLogById(id: string): any;
401
+ /**
402
+ * Returns identifiers for all retained memory logs.
403
+ *
404
+ * # Arguments
405
+ *
406
+ * None.
407
+ *
408
+ * # Example
409
+ *
410
+ * ```javascript
411
+ * const ids = cedarling.getLogIds();
412
+ * ```
413
+ */
414
+ getLogIds(): Array<any>;
415
+ /**
416
+ * Returns retained memory logs matching one request ID and indexed value.
417
+ *
418
+ * # Arguments
419
+ *
420
+ * * `requestId` - The request identifier to match.
421
+ * * `tag` - A log kind (`"System"`, `"Decision"`, or `"Metric"`) or a
422
+ * system-log level such as `"DEBUG"`.
423
+ *
424
+ * # Example
425
+ *
426
+ * ```javascript
427
+ * const logs = cedarling.getLogsByRequestIdAndTag("request-id", "System");
428
+ * ```
429
+ */
430
+ getLogsByRequestIdAndTag(request_id: string, tag: string): any[];
431
+ /**
432
+ * Returns retained memory logs for one request ID.
433
+ *
434
+ * # Arguments
435
+ *
436
+ * * `requestId` - The request identifier to match.
437
+ *
438
+ * # Example
439
+ *
440
+ * ```javascript
441
+ * const logs = cedarling.getLogsByRequestId("request-id");
442
+ * ```
443
+ */
444
+ getLogsByRequestId(request_id: string): any[];
445
+ /**
446
+ * Returns retained memory logs matching an indexed value.
447
+ *
448
+ * # Arguments
449
+ *
450
+ * * `tag` - A log kind (`"System"`, `"Decision"`, or `"Metric"`) or a
451
+ * system-log level such as `"DEBUG"`.
452
+ *
453
+ * # Example
454
+ *
455
+ * ```javascript
456
+ * const logs = cedarling.getLogsByTag("System");
457
+ * ```
458
+ */
459
+ getLogsByTag(tag: string): any[];
460
+ /**
461
+ * Get statistics about the data store.
462
+ *
463
+ * # Arguments
464
+ *
465
+ * None.
466
+ *
467
+ * # Example
468
+ *
469
+ * ```javascript
470
+ * const stats = cedarling.getStatsCtx();
471
+ * console.log(`Entries: ${stats.entry_count}/${stats.max_entries || 'unlimited'}`);
472
+ * console.log(`Capacity: ${stats.capacity_usage_percent.toFixed(2)}%`);
473
+ * console.log(`Total size: ${stats.total_size_bytes} bytes`);
474
+ * ```
475
+ */
476
+ getStatsCtx(): DataStoreStats;
477
+ /**
478
+ * Check whether a trusted issuer was loaded by `iss` claim.
479
+ *
480
+ * # Arguments
481
+ *
482
+ * * `iss_claim` - Issuer `iss` claim value to check.
483
+ *
484
+ * # Example
485
+ *
486
+ * ```javascript
487
+ * const ok = cedarling.isTrustedIssuerLoadedByIss("https://issuer.example.org");
488
+ * ```
489
+ */
490
+ isTrustedIssuerLoadedByIss(iss_claim: string): boolean;
491
+ /**
492
+ * Check whether a trusted issuer was loaded by issuer identifier.
493
+ *
494
+ * # Arguments
495
+ *
496
+ * * `issuer_id` - Trusted issuer identifier to check.
497
+ *
498
+ * # Example
499
+ *
500
+ * ```javascript
501
+ * const ok = cedarling.isTrustedIssuerLoadedByName("issuer_id");
502
+ * ```
503
+ */
504
+ isTrustedIssuerLoadedByName(issuer_id: string): boolean;
505
+ /**
506
+ * List all entries with their metadata.
507
+ * Returns an array of DataEntry objects.
508
+ *
509
+ * # Arguments
510
+ *
511
+ * None.
512
+ *
513
+ * # Example
514
+ *
515
+ * ```javascript
516
+ * const entries = cedarling.listDataCtx();
517
+ * entries.forEach(entry => {
518
+ * console.log(`${entry.key}: ${entry.data_type} (accessed ${entry.access_count} times)`);
519
+ * });
520
+ * ```
521
+ */
522
+ listDataCtx(): Array<any>;
523
+ /**
524
+ * Get trusted issuer identifiers loaded successfully.
525
+ *
526
+ * # Arguments
527
+ *
528
+ * None.
529
+ *
530
+ * # Example
531
+ *
532
+ * ```javascript
533
+ * const ids = cedarling.loadedTrustedIssuerIds();
534
+ * ```
535
+ */
536
+ loadedTrustedIssuerIds(): Array<any>;
537
+ /**
538
+ * Get the number of trusted issuers loaded successfully.
539
+ *
540
+ * # Arguments
541
+ *
542
+ * None.
543
+ *
544
+ * # Example
545
+ *
546
+ * ```javascript
547
+ * const loadedCount = cedarling.loadedTrustedIssuersCount();
548
+ * ```
549
+ */
550
+ loadedTrustedIssuersCount(): number;
551
+ /**
552
+ * Creates a new Cedarling application from a JavaScript `Map`.
553
+ *
554
+ * # Arguments
555
+ *
556
+ * * `config` - A `Map` of Cedarling bootstrap-property names and values.
557
+ *
558
+ * # Example
559
+ *
560
+ * ```javascript
561
+ * await initWasm();
562
+ * const cedarling = await Cedarling.newFromMap(new Map([
563
+ * ["CEDARLING_APPLICATION_NAME", "task-api"],
564
+ * ["CEDARLING_POLICY_STORE_URI", "https://example.com/policy-store.cjar"],
565
+ * ["CEDARLING_LOG_TYPE", "memory"],
566
+ * ["CEDARLING_LOG_TTL", 120],
567
+ * ]));
568
+ * ```
569
+ */
570
+ static newFromMap(config: Map<any, any>): Promise<Cedarling>;
571
+ /**
572
+ * Creates a Cedarling application from bootstrap properties.
573
+ *
574
+ * # Arguments
575
+ *
576
+ * * `config` - A plain object of Cedarling bootstrap-property names and values.
577
+ *
578
+ * # Example
579
+ *
580
+ * ```javascript
581
+ * await initWasm();
582
+ * const cedarling = await Cedarling.new({
583
+ * CEDARLING_APPLICATION_NAME: "task-api",
584
+ * CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
585
+ * CEDARLING_LOG_TYPE: "memory",
586
+ * CEDARLING_LOG_TTL: 120,
587
+ * });
588
+ * ```
589
+ */
590
+ static new(config: object): Promise<Cedarling>;
591
+ /**
592
+ * Returns all retained memory logs and removes them from storage.
593
+ * Other log configurations return an empty array.
594
+ *
595
+ * # Arguments
596
+ *
597
+ * None.
598
+ *
599
+ * # Example
600
+ *
601
+ * ```javascript
602
+ * const logs = cedarling.popLogs();
603
+ * ```
604
+ */
605
+ popLogs(): Array<any>;
606
+ /**
607
+ * Push a value into the data store with an optional TTL.
608
+ * If the key already exists, the value will be replaced.
609
+ * If TTL is not provided, the default TTL from configuration is used.
610
+ *
611
+ * # Arguments
612
+ *
613
+ * * `key` - A string key for the data entry (must not be empty)
614
+ * * `value` - The value to store (any JSON-serializable JavaScript value: object, array, string, number, boolean)
615
+ * * `ttl_secs` - Optional TTL in seconds (undefined/null uses default from config)
616
+ *
617
+ * # Example
618
+ *
619
+ * ```javascript
620
+ * cedarling.pushDataCtx("user:123", { name: "John", age: 30 }, 3600);
621
+ * cedarling.pushDataCtx("config", { setting: "value" }); // Uses default TTL
622
+ * ```
623
+ */
624
+ pushDataCtx(key: string, value: any, ttl_secs?: bigint | null): void;
625
+ /**
626
+ * Remove a value from the data store by key.
627
+ * Returns true if the key existed and was removed, false otherwise.
628
+ *
629
+ * # Arguments
630
+ *
631
+ * * `key` - A string key for the data entry to remove
632
+ *
633
+ * # Example
634
+ *
635
+ * ```javascript
636
+ * const removed = cedarling.removeDataCtx("user:123");
637
+ * if (removed) {
638
+ * console.log("Entry was successfully removed");
639
+ * }
640
+ * ```
641
+ */
642
+ removeDataCtx(key: string): boolean;
643
+ /**
644
+ * Closes Lock Server connections and pushes all available logs.
645
+ *
646
+ * # Arguments
647
+ *
648
+ * None.
649
+ *
650
+ * # Example
651
+ *
652
+ * ```javascript
653
+ * await cedarling.shutDown();
654
+ * ```
655
+ */
656
+ shutDown(): Promise<void>;
657
+ /**
658
+ * Get the total number of trusted issuer entries discovered.
659
+ *
660
+ * # Arguments
661
+ *
662
+ * None.
663
+ *
664
+ * # Example
665
+ *
666
+ * ```javascript
667
+ * const total = cedarling.totalIssuers();
668
+ * ```
669
+ */
670
+ totalIssuers(): number;
671
+ }
672
+
673
+ /**
674
+ * A WASM wrapper for the Rust `cedarling::DataEntry` struct.
675
+ * Represents a data entry in the DataStore with value and metadata.
676
+ */
677
+ export class DataEntry {
678
+ private constructor();
679
+ free(): void;
680
+ [Symbol.dispose](): void;
681
+ /**
682
+ * Convert `DataEntry` to json string value
683
+ */
684
+ jsonString(): string;
685
+ /**
686
+ * Get the value stored in this entry as a JavaScript object
687
+ */
688
+ value(): any;
689
+ /**
690
+ * Number of times this entry has been accessed
691
+ */
692
+ access_count: bigint;
693
+ /**
694
+ * Timestamp when this entry was created (RFC 3339 format)
695
+ */
696
+ created_at: string;
697
+ /**
698
+ * The inferred Cedar type of the value
699
+ */
700
+ data_type: string;
701
+ /**
702
+ * Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
703
+ */
704
+ get expires_at(): string | undefined;
705
+ /**
706
+ * Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
707
+ */
708
+ set expires_at(value: string | null | undefined);
709
+ /**
710
+ * The key for this entry
711
+ */
712
+ key: string;
713
+ }
714
+
715
+ /**
716
+ * A WASM wrapper for the Rust `cedarling::DataStoreStats` struct.
717
+ * Statistics about the DataStore.
718
+ */
719
+ export class DataStoreStats {
720
+ private constructor();
721
+ free(): void;
722
+ [Symbol.dispose](): void;
723
+ /**
724
+ * Convert `DataStoreStats` to json string value
725
+ */
726
+ jsonString(): string;
727
+ /**
728
+ * Average size per entry in bytes (0 if no entries)
729
+ */
730
+ avg_entry_size_bytes: number;
731
+ /**
732
+ * Percentage of capacity used (0.0-100.0, based on entry count)
733
+ */
734
+ capacity_usage_percent: number;
735
+ /**
736
+ * Number of entries currently stored
737
+ */
738
+ entry_count: number;
739
+ /**
740
+ * Maximum number of entries allowed (0 = unlimited)
741
+ */
742
+ max_entries: number;
743
+ /**
744
+ * Maximum size per entry in bytes (0 = unlimited)
745
+ */
746
+ max_entry_size: number;
747
+ /**
748
+ * Memory usage threshold percentage (from config)
749
+ */
750
+ memory_alert_threshold: number;
751
+ /**
752
+ * Whether memory usage exceeds the alert threshold
753
+ */
754
+ memory_alert_triggered: boolean;
755
+ /**
756
+ * Whether metrics tracking is enabled
757
+ */
758
+ metrics_enabled: boolean;
759
+ /**
760
+ * Total size of all entries in bytes (approximate, based on JSON serialization)
761
+ */
762
+ total_size_bytes: number;
763
+ }
764
+
765
+ /**
766
+ * Diagnostics
767
+ * ===========
768
+ *
769
+ * Provides detailed information about how a policy decision was made, including policies that contributed to the decision and any errors encountered during evaluation.
770
+ */
771
+ export class Diagnostics {
772
+ private constructor();
773
+ free(): void;
774
+ [Symbol.dispose](): void;
775
+ /**
776
+ * Errors that occurred during authorization. The errors should be
777
+ * treated as unordered, since policies may be evaluated in any order.
778
+ */
779
+ readonly errors: PolicyEvaluationError[];
780
+ /**
781
+ * `PolicyId`s of the policies that contributed to the decision.
782
+ * If no policies applied to the request, this set will be empty.
783
+ *
784
+ * The ids should be treated as unordered,
785
+ */
786
+ readonly reason: string[];
787
+ }
788
+
789
+ declare class IntoUnderlyingByteSource {
790
+ private constructor();
791
+ free(): void;
792
+ [Symbol.dispose](): void;
793
+ cancel(): void;
794
+ pull(controller: ReadableByteStreamController): Promise<any>;
795
+ start(controller: ReadableByteStreamController): void;
796
+ readonly autoAllocateChunkSize: number;
797
+ readonly type: ReadableStreamType;
798
+ }
799
+ export type { IntoUnderlyingByteSource };
800
+
801
+ declare class IntoUnderlyingSink {
802
+ private constructor();
803
+ free(): void;
804
+ [Symbol.dispose](): void;
805
+ abort(reason: any): Promise<any>;
806
+ close(): Promise<any>;
807
+ write(chunk: any): Promise<any>;
808
+ }
809
+ export type { IntoUnderlyingSink };
810
+
811
+ declare class IntoUnderlyingSource {
812
+ private constructor();
813
+ free(): void;
814
+ [Symbol.dispose](): void;
815
+ cancel(): void;
816
+ pull(controller: ReadableStreamDefaultController): Promise<any>;
817
+ }
818
+ export type { IntoUnderlyingSource };
819
+
820
+ /**
821
+ * A WASM wrapper for the Rust `cedarling::MultiIssuerAuthorizeResult` struct.
822
+ * Represents the result of a multi-issuer authorization request.
823
+ */
824
+ export class MultiIssuerAuthorizeResult {
825
+ private constructor();
826
+ free(): void;
827
+ [Symbol.dispose](): void;
828
+ /**
829
+ * Convert `MultiIssuerAuthorizeResult` to json string value
830
+ */
831
+ jsonString(): string;
832
+ /**
833
+ * Result of authorization
834
+ * true means `ALLOW`
835
+ * false means `Deny`
836
+ */
837
+ decision: boolean;
838
+ /**
839
+ * Request ID of the authorization request
840
+ */
841
+ request_id: string;
842
+ /**
843
+ * Result of Cedar policy authorization
844
+ */
845
+ response: AuthorizeResultResponse;
846
+ }
847
+
848
+ /**
849
+ * PolicyEvaluationError
850
+ * =====================
851
+ *
852
+ * Represents an error that occurred when evaluating a Cedar policy.
853
+ */
854
+ export class PolicyEvaluationError {
855
+ private constructor();
856
+ free(): void;
857
+ [Symbol.dispose](): void;
858
+ /**
859
+ * Underlying evaluation error string representation
860
+ */
861
+ readonly error: string;
862
+ /**
863
+ * Id of the policy with an error
864
+ */
865
+ readonly id: string;
866
+ }
867
+
868
+ /**
869
+ * Creates a Cedarling application from bootstrap properties.
870
+ *
871
+ * # Arguments
872
+ *
873
+ * * `config` - A JavaScript `Map` or plain object of Cedarling
874
+ * bootstrap-property names and values.
875
+ *
876
+ * # Example
877
+ *
878
+ * ```javascript
879
+ * await initWasm();
880
+ * const cedarling = await init({
881
+ * CEDARLING_APPLICATION_NAME: "task-api",
882
+ * CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
883
+ * CEDARLING_LOG_TYPE: "memory",
884
+ * CEDARLING_LOG_TTL: 120,
885
+ * });
886
+ * ```
887
+ */
888
+ export function init(config: any): Promise<Cedarling>;
889
+
890
+ /**
891
+ * Create a new instance of the Cedarling application from archive bytes.
892
+ *
893
+ * This function allows loading a policy store from a Cedar Archive (.cjar)
894
+ * that was fetched with custom logic (e.g., with authentication headers).
895
+ *
896
+ * # Arguments
897
+ * * `config` - Bootstrap configuration (Map or Object) without a policy-store
898
+ * source property. The archive bytes provide the policy store.
899
+ * * `archive_bytes` - The .cjar archive bytes (Uint8Array)
900
+ *
901
+ * # Example
902
+ * ```javascript
903
+ * await initWasm();
904
+ * const config = {
905
+ * CEDARLING_APPLICATION_NAME: "task-api",
906
+ * CEDARLING_LOG_TYPE: "memory",
907
+ * CEDARLING_LOG_TTL: 120,
908
+ * };
909
+ * const response = await fetch("https://example.com/policy-store.cjar", {
910
+ * headers: { Authorization: "Bearer <token>" },
911
+ * });
912
+ * if (!response.ok) throw new Error("Unable to fetch policy store");
913
+ * const archiveBytes = new Uint8Array(await response.arrayBuffer());
914
+ * const cedarling = await initFromArchiveBytes(config, archiveBytes);
915
+ * ```
916
+ */
917
+ export function initFromArchiveBytes(config: any, archive_bytes: Uint8Array): Promise<Cedarling>;
918
+
919
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
920
+
921
+ export interface InitOutput {
922
+ readonly memory: WebAssembly.Memory;
923
+ readonly __wbg_authorizeresult_free: (a: number, b: number) => void;
924
+ readonly __wbg_authorizeresultresponse_free: (a: number, b: number) => void;
925
+ readonly __wbg_batchauthorizemultiissuerresponse_free: (a: number, b: number) => void;
926
+ readonly __wbg_batchauthorizeunsignedresponse_free: (a: number, b: number) => void;
927
+ readonly __wbg_batchitemerror_free: (a: number, b: number) => void;
928
+ readonly __wbg_batchitemmultiissuerresult_free: (a: number, b: number) => void;
929
+ readonly __wbg_batchitemunsignedresult_free: (a: number, b: number) => void;
930
+ readonly __wbg_cedarling_free: (a: number, b: number) => void;
931
+ readonly __wbg_dataentry_free: (a: number, b: number) => void;
932
+ readonly __wbg_datastorestats_free: (a: number, b: number) => void;
933
+ readonly __wbg_diagnostics_free: (a: number, b: number) => void;
934
+ readonly __wbg_get_authorizeresult_decision: (a: number) => number;
935
+ readonly __wbg_get_authorizeresult_request_id: (a: number, b: number) => void;
936
+ readonly __wbg_get_authorizeresult_response: (a: number) => number;
937
+ readonly __wbg_get_dataentry_access_count: (a: number) => bigint;
938
+ readonly __wbg_get_dataentry_created_at: (a: number, b: number) => void;
939
+ readonly __wbg_get_dataentry_data_type: (a: number, b: number) => void;
940
+ readonly __wbg_get_dataentry_expires_at: (a: number, b: number) => void;
941
+ readonly __wbg_get_dataentry_key: (a: number, b: number) => void;
942
+ readonly __wbg_get_datastorestats_avg_entry_size_bytes: (a: number) => number;
943
+ readonly __wbg_get_datastorestats_capacity_usage_percent: (a: number) => number;
944
+ readonly __wbg_get_datastorestats_entry_count: (a: number) => number;
945
+ readonly __wbg_get_datastorestats_max_entries: (a: number) => number;
946
+ readonly __wbg_get_datastorestats_max_entry_size: (a: number) => number;
947
+ readonly __wbg_get_datastorestats_memory_alert_threshold: (a: number) => number;
948
+ readonly __wbg_get_datastorestats_memory_alert_triggered: (a: number) => number;
949
+ readonly __wbg_get_datastorestats_metrics_enabled: (a: number) => number;
950
+ readonly __wbg_get_datastorestats_total_size_bytes: (a: number) => number;
951
+ readonly __wbg_get_multiissuerauthorizeresult_decision: (a: number) => number;
952
+ readonly __wbg_get_multiissuerauthorizeresult_request_id: (a: number, b: number) => void;
953
+ readonly __wbg_get_multiissuerauthorizeresult_response: (a: number) => number;
954
+ readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
955
+ readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
956
+ readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
957
+ readonly __wbg_multiissuerauthorizeresult_free: (a: number, b: number) => void;
958
+ readonly __wbg_policyevaluationerror_free: (a: number, b: number) => void;
959
+ readonly __wbg_set_authorizeresult_decision: (a: number, b: number) => void;
960
+ readonly __wbg_set_authorizeresult_request_id: (a: number, b: number, c: number) => void;
961
+ readonly __wbg_set_authorizeresult_response: (a: number, b: number) => void;
962
+ readonly __wbg_set_dataentry_access_count: (a: number, b: bigint) => void;
963
+ readonly __wbg_set_dataentry_created_at: (a: number, b: number, c: number) => void;
964
+ readonly __wbg_set_dataentry_data_type: (a: number, b: number, c: number) => void;
965
+ readonly __wbg_set_dataentry_expires_at: (a: number, b: number, c: number) => void;
966
+ readonly __wbg_set_dataentry_key: (a: number, b: number, c: number) => void;
967
+ readonly __wbg_set_datastorestats_avg_entry_size_bytes: (a: number, b: number) => void;
968
+ readonly __wbg_set_datastorestats_capacity_usage_percent: (a: number, b: number) => void;
969
+ readonly __wbg_set_datastorestats_entry_count: (a: number, b: number) => void;
970
+ readonly __wbg_set_datastorestats_max_entries: (a: number, b: number) => void;
971
+ readonly __wbg_set_datastorestats_max_entry_size: (a: number, b: number) => void;
972
+ readonly __wbg_set_datastorestats_memory_alert_threshold: (a: number, b: number) => void;
973
+ readonly __wbg_set_datastorestats_memory_alert_triggered: (a: number, b: number) => void;
974
+ readonly __wbg_set_datastorestats_metrics_enabled: (a: number, b: number) => void;
975
+ readonly __wbg_set_datastorestats_total_size_bytes: (a: number, b: number) => void;
976
+ readonly __wbg_set_multiissuerauthorizeresult_decision: (a: number, b: number) => void;
977
+ readonly __wbg_set_multiissuerauthorizeresult_request_id: (a: number, b: number, c: number) => void;
978
+ readonly __wbg_set_multiissuerauthorizeresult_response: (a: number, b: number) => void;
979
+ readonly authorizeresult_jsonString: (a: number, b: number) => void;
980
+ readonly authorizeresultresponse_decision: (a: number) => number;
981
+ readonly authorizeresultresponse_diagnostics: (a: number) => number;
982
+ readonly batchauthorizemultiissuerresponse_batch_id: (a: number, b: number) => void;
983
+ readonly batchauthorizemultiissuerresponse_results: (a: number, b: number) => void;
984
+ readonly batchauthorizeunsignedresponse_batch_id: (a: number, b: number) => void;
985
+ readonly batchauthorizeunsignedresponse_results: (a: number, b: number) => void;
986
+ readonly batchitemerror_category: (a: number, b: number) => void;
987
+ readonly batchitemerror_item_index: (a: number) => number;
988
+ readonly batchitemerror_message: (a: number, b: number) => void;
989
+ readonly batchitemmultiissuerresult_error: (a: number) => number;
990
+ readonly batchitemmultiissuerresult_is_ok: (a: number) => number;
991
+ readonly batchitemmultiissuerresult_unwrap: (a: number, b: number) => void;
992
+ readonly batchitemunsignedresult_error: (a: number) => number;
993
+ readonly batchitemunsignedresult_is_ok: (a: number) => number;
994
+ readonly batchitemunsignedresult_unwrap: (a: number, b: number) => void;
995
+ readonly cedarling_annotationValues: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
996
+ readonly cedarling_annotationsByPolicy: (a: number, b: number, c: number, d: number) => void;
997
+ readonly cedarling_annotationsMap: (a: number, b: number, c: number, d: number) => void;
998
+ readonly cedarling_authorizeMultiIssuer: (a: number, b: number, c: number) => number;
999
+ readonly cedarling_authorizeMultiIssuerBatch: (a: number, b: number, c: number) => number;
1000
+ readonly cedarling_authorizeUnsigned: (a: number, b: number, c: number) => number;
1001
+ readonly cedarling_authorizeUnsignedBatch: (a: number, b: number, c: number) => number;
1002
+ readonly cedarling_clearDataCtx: (a: number, b: number) => void;
1003
+ readonly cedarling_failedTrustedIssuerIds: (a: number) => number;
1004
+ readonly cedarling_getDataCtx: (a: number, b: number, c: number, d: number) => void;
1005
+ readonly cedarling_getDataEntryCtx: (a: number, b: number, c: number, d: number) => void;
1006
+ readonly cedarling_getLogById: (a: number, b: number, c: number, d: number) => void;
1007
+ readonly cedarling_getLogIds: (a: number) => number;
1008
+ readonly cedarling_getLogsByRequestId: (a: number, b: number, c: number, d: number) => void;
1009
+ readonly cedarling_getLogsByRequestIdAndTag: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1010
+ readonly cedarling_getLogsByTag: (a: number, b: number, c: number, d: number) => void;
1011
+ readonly cedarling_getStatsCtx: (a: number, b: number) => void;
1012
+ readonly cedarling_isTrustedIssuerLoadedByIss: (a: number, b: number, c: number) => number;
1013
+ readonly cedarling_isTrustedIssuerLoadedByName: (a: number, b: number, c: number) => number;
1014
+ readonly cedarling_listDataCtx: (a: number, b: number) => void;
1015
+ readonly cedarling_loadedTrustedIssuerIds: (a: number) => number;
1016
+ readonly cedarling_loadedTrustedIssuersCount: (a: number) => number;
1017
+ readonly cedarling_new: (a: number) => number;
1018
+ readonly cedarling_newFromMap: (a: number) => number;
1019
+ readonly cedarling_popLogs: (a: number, b: number) => void;
1020
+ readonly cedarling_pushDataCtx: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
1021
+ readonly cedarling_removeDataCtx: (a: number, b: number, c: number, d: number) => void;
1022
+ readonly cedarling_shutDown: (a: number) => number;
1023
+ readonly cedarling_totalIssuers: (a: number) => number;
1024
+ readonly dataentry_jsonString: (a: number, b: number) => void;
1025
+ readonly dataentry_value: (a: number, b: number) => void;
1026
+ readonly datastorestats_jsonString: (a: number, b: number) => void;
1027
+ readonly diagnostics_errors: (a: number, b: number) => void;
1028
+ readonly diagnostics_reason: (a: number, b: number) => void;
1029
+ readonly init: (a: number) => number;
1030
+ readonly initFromArchiveBytes: (a: number, b: number) => number;
1031
+ readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
1032
+ readonly rust_zstd_wasm_shim_free: (a: number) => void;
1033
+ readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
1034
+ readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
1035
+ readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
1036
+ readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
1037
+ readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
1038
+ readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
1039
+ readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
1040
+ readonly intounderlyingbytesource_cancel: (a: number) => void;
1041
+ readonly intounderlyingbytesource_pull: (a: number, b: number) => number;
1042
+ readonly intounderlyingbytesource_start: (a: number, b: number) => void;
1043
+ readonly intounderlyingbytesource_type: (a: number) => number;
1044
+ readonly intounderlyingsink_abort: (a: number, b: number) => number;
1045
+ readonly intounderlyingsink_close: (a: number) => number;
1046
+ readonly intounderlyingsink_write: (a: number, b: number) => number;
1047
+ readonly intounderlyingsource_cancel: (a: number) => void;
1048
+ readonly intounderlyingsource_pull: (a: number, b: number) => number;
1049
+ readonly multiissuerauthorizeresult_jsonString: (a: number, b: number) => void;
1050
+ readonly policyevaluationerror_error: (a: number, b: number) => void;
1051
+ readonly policyevaluationerror_id: (a: number, b: number) => void;
1052
+ readonly __wasm_bindgen_func_elem_8900: (a: number, b: number, c: number, d: number) => void;
1053
+ readonly __wasm_bindgen_func_elem_8955: (a: number, b: number, c: number, d: number) => void;
1054
+ readonly __wasm_bindgen_func_elem_12460: (a: number, b: number, c: number) => void;
1055
+ readonly __wasm_bindgen_func_elem_8734: (a: number, b: number) => void;
1056
+ readonly __wbindgen_export: (a: number, b: number) => number;
1057
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
1058
+ readonly __wbindgen_export3: (a: number) => void;
1059
+ readonly __wbindgen_export4: (a: number, b: number) => void;
1060
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
1061
+ readonly __wbindgen_export5: (a: number, b: number, c: number) => void;
1062
+ }
1063
+
1064
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
1065
+
1066
+ /**
1067
+ * Instantiates the given `module`, which can either be bytes or
1068
+ * a precompiled `WebAssembly.Module`.
1069
+ *
1070
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
1071
+ *
1072
+ * @returns {InitOutput}
1073
+ */
1074
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
1075
+
1076
+ /**
1077
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
1078
+ * for everything else, calls `WebAssembly.instantiate` directly.
1079
+ *
1080
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
1081
+ *
1082
+ * @returns {Promise<InitOutput>}
1083
+ */
1084
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;