@janssenproject/cedarling_wasm 2.4.0 → 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.
@@ -1,3 +1,4 @@
1
+ /// <reference lib="esnext.disposable" />
1
2
  /* tslint:disable */
2
3
  /* eslint-disable */
3
4
  /**
@@ -19,7 +20,7 @@ export class AuthorizeResult {
19
20
  /**
20
21
  * Convert `AuthorizeResult` to json string value
21
22
  */
22
- json_string(): string;
23
+ jsonString(): string;
23
24
  /**
24
25
  * Result of authorization
25
26
  * true means `ALLOW`
@@ -186,14 +187,17 @@ export class Cedarling {
186
187
  * # Example
187
188
  *
188
189
  * ```javascript
189
- * const redirects = cedarling.annotation_values(result.response.diagnostics.reason, "redirect");
190
+ * const redirects = cedarling.annotationValues(
191
+ * result.response.diagnostics.reason,
192
+ * "redirect",
193
+ * );
190
194
  * // ["/upgrade"]
191
195
  * ```
192
196
  */
193
- annotation_values(policy_ids: string[], key: string): string[];
197
+ annotationValues(policy_ids: string[], key: string): string[];
194
198
  /**
195
- * Return the annotations of each given policy, grouped by policy ID
196
- * the loss-free companion to `annotations_map`. Unknown policy IDs are
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
197
201
  * silently skipped.
198
202
  *
199
203
  * # Arguments
@@ -205,11 +209,11 @@ export class Cedarling {
205
209
  * # Example
206
210
  *
207
211
  * ```javascript
208
- * const byPolicy = cedarling.annotations_by_policy(result.response.diagnostics.reason);
212
+ * const byPolicy = cedarling.annotationsByPolicy(result.response.diagnostics.reason);
209
213
  * // { "5": { redirect: "/upgrade", tier: "premium" } }
210
214
  * ```
211
215
  */
212
- annotations_by_policy(policy_ids: string[]): any;
216
+ annotationsByPolicy(policy_ids: string[]): any;
213
217
  /**
214
218
  * Merge the annotations (`@key("value")`) of the given policies into a single object.
215
219
  *
@@ -217,7 +221,7 @@ export class Cedarling {
217
221
  * pass `result.response.diagnostics.reason`.
218
222
  *
219
223
  * Lossy: if the same annotation key appears on several policies, one value wins
220
- * arbitrarily. Use `annotation_values` / `annotations_by_policy` when duplicates
224
+ * arbitrarily. Use `annotationValues` / `annotationsByPolicy` when duplicates
221
225
  * matter. Unknown policy IDs are silently skipped.
222
226
  *
223
227
  * # Arguments
@@ -229,11 +233,32 @@ export class Cedarling {
229
233
  * # Example
230
234
  *
231
235
  * ```javascript
232
- * const annotations = cedarling.annotations_map(result.response.diagnostics.reason);
236
+ * const annotations = cedarling.annotationsMap(result.response.diagnostics.reason);
233
237
  * // { redirect: "/upgrade", tier: "premium" }
234
238
  * ```
235
239
  */
236
- annotations_map(policy_ids: string[]): any;
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>;
237
262
  /**
238
263
  * Authorize multi-issuer request.
239
264
  * Makes authorization decision based on multiple JWT tokens from different issuers.
@@ -245,31 +270,31 @@ export class Cedarling {
245
270
  * # Example
246
271
  *
247
272
  * ```javascript
248
- * const result = await cedarling.authorize_multi_issuer(JSON.stringify(request));
273
+ * const result = await cedarling.authorizeMultiIssuer(JSON.stringify(request));
249
274
  * ```
250
275
  */
251
- authorize_multi_issuer(request: string): Promise<MultiIssuerAuthorizeResult>;
276
+ authorizeMultiIssuer(request: string): Promise<MultiIssuerAuthorizeResult>;
252
277
  /**
253
- * Authorize a batch of multi-issuer requests against one shared token set.
254
- *
255
- * Tokens are validated and token/issuer entities are built once, then
256
- * each item is evaluated in input order. Batch-level failures (validation,
257
- * JWT verification, status-list refresh) reject the whole call; per-item
258
- * failures are returned as `BatchItemError` results and exposed by WASM
259
- * with `is_ok=false` and `error`, while genuine Cedar denials remain
260
- * `AuthorizeResult` values with `decision=false`.
278
+ * Authorize a batch of unsigned requests against one shared principal.
261
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`.
262
287
  * # Arguments
263
288
  *
264
- * * `request` - JSON string representation of [`BatchAuthorizeMultiIssuerRequest`].
289
+ * * `request` - JSON string representation of [`BatchAuthorizeUnsignedRequest`].
265
290
  *
266
291
  * # Example
267
292
  *
268
293
  * ```javascript
269
- * const result = await cedarling.authorize_multi_issuer_batch(JSON.stringify(batchRequest));
294
+ * const result = await cedarling.authorizeUnsignedBatch(JSON.stringify(batchRequest));
270
295
  * ```
271
296
  */
272
- authorize_multi_issuer_batch(request: string): Promise<BatchAuthorizeMultiIssuerResponse>;
297
+ authorizeUnsignedBatch(request: string): Promise<BatchAuthorizeUnsignedResponse>;
273
298
  /**
274
299
  * Authorize an unsigned request carrying an optional single principal.
275
300
  * Makes an authorization decision based on the [`RequestUnsigned`].
@@ -286,52 +311,56 @@ export class Cedarling {
286
311
  * # Example
287
312
  *
288
313
  * ```javascript
289
- * const result = await cedarling.authorize_unsigned(JSON.stringify(request));
314
+ * const result = await cedarling.authorizeUnsigned(JSON.stringify(request));
290
315
  * ```
291
316
  */
292
- authorize_unsigned(request: string): Promise<AuthorizeResult>;
317
+ authorizeUnsigned(request: string): Promise<AuthorizeResult>;
293
318
  /**
294
- * Authorize a batch of unsigned requests against one shared principal.
319
+ * Clear all entries from the data store.
295
320
  *
296
- * Setup work (principal build + pushed-data snapshot) runs once and each
297
- * item is evaluated in input order. Results are returned inside a
298
- * [`BatchAuthorizeUnsignedResponse`] carrying the shared `batch_id`.
299
- * Batch-level failures (validation, principal parse) reject the whole
300
- * call; per-item failures are returned as `BatchItemError` results and
301
- * exposed by WASM with `is_ok=false` and `error`, while genuine Cedar
302
- * denials remain `AuthorizeResult` values with `decision=false`.
303
321
  * # Arguments
304
322
  *
305
- * * `request` - JSON string representation of [`BatchAuthorizeUnsignedRequest`].
323
+ * None.
306
324
  *
307
325
  * # Example
308
326
  *
309
327
  * ```javascript
310
- * const result = await cedarling.authorize_unsigned_batch(JSON.stringify(batchRequest));
328
+ * cedarling.clearDataCtx();
329
+ * console.log("All data entries cleared");
311
330
  * ```
312
331
  */
313
- authorize_unsigned_batch(request: string): Promise<BatchAuthorizeUnsignedResponse>;
332
+ clearDataCtx(): void;
314
333
  /**
315
- * Clear all entries from the data store.
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.
316
341
  *
317
342
  * # Example
318
343
  *
319
344
  * ```javascript
320
- * cedarling.clear_data_ctx();
321
- * console.log("All data entries cleared");
345
+ * const snapshot = cedarling.drainMetrics();
346
+ * console.log(`Requests: ${snapshot.operational_stats.get("authz.requests_total")}`);
322
347
  * ```
323
348
  */
324
- clear_data_ctx(): void;
349
+ drainMetrics(): MetricsSnapshot;
325
350
  /**
326
351
  * Get trusted issuer identifiers that failed to load.
327
352
  *
353
+ * # Arguments
354
+ *
355
+ * None.
356
+ *
328
357
  * # Example
329
358
  *
330
359
  * ```javascript
331
- * const ids = cedarling.failed_trusted_issuer_ids();
360
+ * const ids = cedarling.failedTrustedIssuerIds();
332
361
  * ```
333
362
  */
334
- failed_trusted_issuer_ids(): Array<any>;
363
+ failedTrustedIssuerIds(): Array<any>;
335
364
  /**
336
365
  * Get a value from the data store by key.
337
366
  * Returns null if the key doesn't exist or the entry has expired.
@@ -343,16 +372,16 @@ export class Cedarling {
343
372
  * # Example
344
373
  *
345
374
  * ```javascript
346
- * const value = cedarling.get_data_ctx("user:123");
375
+ * const value = cedarling.getDataCtx("user:123");
347
376
  * if (value !== null) {
348
377
  * console.log(value.name); // "John"
349
378
  * }
350
379
  * ```
351
380
  */
352
- get_data_ctx(key: string): any;
381
+ getDataCtx(key: string): any;
353
382
  /**
354
383
  * Get a data entry with full metadata by key.
355
- * Returns null if the key doesn't exist or the entry has expired.
384
+ * Returns undefined if the key doesn't exist or the entry has expired.
356
385
  *
357
386
  * # Arguments
358
387
  *
@@ -361,56 +390,107 @@ export class Cedarling {
361
390
  * # Example
362
391
  *
363
392
  * ```javascript
364
- * const entry = cedarling.get_data_entry_ctx("user:123");
365
- * if (entry !== null) {
393
+ * const entry = cedarling.getDataEntryCtx("user:123");
394
+ * if (entry !== undefined) {
366
395
  * console.log(entry.key); // "user:123"
367
- * console.log(entry.value); // { name: "John", age: 30 }
396
+ * console.log(entry.value()); // { name: "John", age: 30 }
368
397
  * console.log(entry.data_type); // "Record"
369
398
  * console.log(entry.created_at); // "2024-01-01T12:00:00Z"
370
399
  * console.log(entry.access_count); // 5
371
400
  * }
372
401
  * ```
373
402
  */
374
- get_data_entry_ctx(key: string): DataEntry | undefined;
403
+ getDataEntryCtx(key: string): DataEntry | undefined;
375
404
  /**
376
- * Get specific log entry.
377
- * Returns `Map` with values or `null`.
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
+ * ```
378
416
  */
379
- get_log_by_id(id: string): any;
417
+ getLogById(id: string): any;
380
418
  /**
381
- * Returns a list of all log ids.
382
- * Returns `Array` of `String`
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
+ * ```
383
430
  */
384
- get_log_ids(): Array<any>;
431
+ getLogIds(): Array<any>;
385
432
  /**
386
- * Get logs by request_id.
387
- * Return log entries that match the given request_id.
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
+ * ```
388
446
  */
389
- get_logs_by_request_id(request_id: string): any[];
447
+ getLogsByRequestIdAndTag(request_id: string, tag: string): any[];
390
448
  /**
391
- * Get log by request_id and tag, like composite key `request_id` + `log_kind`.
392
- * Tag can be `log_kind`, `log_level`.
393
- * Return log entries that match the given request_id and tag.
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
+ * ```
394
460
  */
395
- get_logs_by_request_id_and_tag(request_id: string, tag: string): any[];
461
+ getLogsByRequestId(request_id: string): any[];
396
462
  /**
397
- * Get logs by tag, like `log_kind` or `log level`.
398
- * Tag can be `log_kind`, `log_level`.
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
+ * ```
399
475
  */
400
- get_logs_by_tag(tag: string): any[];
476
+ getLogsByTag(tag: string): any[];
401
477
  /**
402
478
  * Get statistics about the data store.
403
479
  *
480
+ * # Arguments
481
+ *
482
+ * None.
483
+ *
404
484
  * # Example
405
485
  *
406
486
  * ```javascript
407
- * const stats = cedarling.get_stats_ctx();
487
+ * const stats = cedarling.getStatsCtx();
408
488
  * console.log(`Entries: ${stats.entry_count}/${stats.max_entries || 'unlimited'}`);
409
489
  * console.log(`Capacity: ${stats.capacity_usage_percent.toFixed(2)}%`);
410
490
  * console.log(`Total size: ${stats.total_size_bytes} bytes`);
411
491
  * ```
412
492
  */
413
- get_stats_ctx(): DataStoreStats;
493
+ getStatsCtx(): DataStoreStats;
414
494
  /**
415
495
  * Check whether a trusted issuer was loaded by `iss` claim.
416
496
  *
@@ -421,10 +501,10 @@ export class Cedarling {
421
501
  * # Example
422
502
  *
423
503
  * ```javascript
424
- * const ok = cedarling.is_trusted_issuer_loaded_by_iss("https://issuer.example.org");
504
+ * const ok = cedarling.isTrustedIssuerLoadedByIss("https://issuer.example.org");
425
505
  * ```
426
506
  */
427
- is_trusted_issuer_loaded_by_iss(iss_claim: string): boolean;
507
+ isTrustedIssuerLoadedByIss(iss_claim: string): boolean;
428
508
  /**
429
509
  * Check whether a trusted issuer was loaded by issuer identifier.
430
510
  *
@@ -435,59 +515,128 @@ export class Cedarling {
435
515
  * # Example
436
516
  *
437
517
  * ```javascript
438
- * const ok = cedarling.is_trusted_issuer_loaded_by_name("issuer_id");
518
+ * const ok = cedarling.isTrustedIssuerLoadedByName("issuer_id");
439
519
  * ```
440
520
  */
441
- is_trusted_issuer_loaded_by_name(issuer_id: string): boolean;
521
+ isTrustedIssuerLoadedByName(issuer_id: string): boolean;
442
522
  /**
443
523
  * List all entries with their metadata.
444
524
  * Returns an array of DataEntry objects.
445
525
  *
526
+ * # Arguments
527
+ *
528
+ * None.
529
+ *
446
530
  * # Example
447
531
  *
448
532
  * ```javascript
449
- * const entries = cedarling.list_data_ctx();
533
+ * const entries = cedarling.listDataCtx();
450
534
  * entries.forEach(entry => {
451
535
  * console.log(`${entry.key}: ${entry.data_type} (accessed ${entry.access_count} times)`);
452
536
  * });
453
537
  * ```
454
538
  */
455
- list_data_ctx(): Array<any>;
539
+ listDataCtx(): Array<any>;
456
540
  /**
457
541
  * Get trusted issuer identifiers loaded successfully.
458
542
  *
543
+ * # Arguments
544
+ *
545
+ * None.
546
+ *
459
547
  * # Example
460
548
  *
461
549
  * ```javascript
462
- * const ids = cedarling.loaded_trusted_issuer_ids();
550
+ * const ids = cedarling.loadedTrustedIssuerIds();
463
551
  * ```
464
552
  */
465
- loaded_trusted_issuer_ids(): Array<any>;
553
+ loadedTrustedIssuerIds(): Array<any>;
466
554
  /**
467
555
  * Get the number of trusted issuers loaded successfully.
468
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
+ *
469
575
  * # Example
470
576
  *
471
577
  * ```javascript
472
- * const loadedCount = cedarling.loaded_trusted_issuers_count();
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
+ * ]));
473
585
  * ```
474
586
  */
475
- loaded_trusted_issuers_count(): number;
587
+ static newFromMap(config: Map<any, any>): Promise<Cedarling>;
476
588
  /**
477
- * Create a new instance of the Cedarling application.
478
- * Assume that config is `Object`
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
+ * ```
479
606
  */
480
607
  static new(config: object): Promise<Cedarling>;
481
608
  /**
482
- * Create a new instance of the Cedarling application.
483
- * Assume that config is `Map`
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
+ * ```
484
623
  */
485
- static new_from_map(config: Map<any, any>): Promise<Cedarling>;
624
+ policyStoreId(): string | undefined;
486
625
  /**
487
- * Get logs and remove them from the storage.
488
- * Returns `Array` of `Map`
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
+ * ```
489
638
  */
490
- pop_logs(): Array<any>;
639
+ popLogs(): Array<any>;
491
640
  /**
492
641
  * Push a value into the data store with an optional TTL.
493
642
  * If the key already exists, the value will be replaced.
@@ -502,11 +651,11 @@ export class Cedarling {
502
651
  * # Example
503
652
  *
504
653
  * ```javascript
505
- * cedarling.push_data_ctx("user:123", { name: "John", age: 30 }, 3600);
506
- * cedarling.push_data_ctx("config", { setting: "value" }); // Uses default TTL
654
+ * cedarling.pushDataCtx("user:123", { name: "John", age: 30 }, 3600);
655
+ * cedarling.pushDataCtx("config", { setting: "value" }); // Uses default TTL
507
656
  * ```
508
657
  */
509
- push_data_ctx(key: string, value: any, ttl_secs?: bigint | null): void;
658
+ pushDataCtx(key: string, value: any, ttl_secs?: bigint | null): void;
510
659
  /**
511
660
  * Remove a value from the data store by key.
512
661
  * Returns true if the key existed and was removed, false otherwise.
@@ -518,27 +667,41 @@ export class Cedarling {
518
667
  * # Example
519
668
  *
520
669
  * ```javascript
521
- * const removed = cedarling.remove_data_ctx("user:123");
670
+ * const removed = cedarling.removeDataCtx("user:123");
522
671
  * if (removed) {
523
672
  * console.log("Entry was successfully removed");
524
673
  * }
525
674
  * ```
526
675
  */
527
- remove_data_ctx(key: string): boolean;
676
+ removeDataCtx(key: string): boolean;
528
677
  /**
529
- * Closes the connections to the Lock Server and pushes all available logs.
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
+ * ```
530
689
  */
531
- shut_down(): Promise<void>;
690
+ shutDown(): Promise<void>;
532
691
  /**
533
692
  * Get the total number of trusted issuer entries discovered.
534
693
  *
694
+ * # Arguments
695
+ *
696
+ * None.
697
+ *
535
698
  * # Example
536
699
  *
537
700
  * ```javascript
538
- * const total = cedarling.total_issuers();
701
+ * const total = cedarling.totalIssuers();
539
702
  * ```
540
703
  */
541
- total_issuers(): number;
704
+ totalIssuers(): number;
542
705
  }
543
706
 
544
707
  /**
@@ -552,7 +715,7 @@ export class DataEntry {
552
715
  /**
553
716
  * Convert `DataEntry` to json string value
554
717
  */
555
- json_string(): string;
718
+ jsonString(): string;
556
719
  /**
557
720
  * Get the value stored in this entry as a JavaScript object
558
721
  */
@@ -570,11 +733,11 @@ export class DataEntry {
570
733
  */
571
734
  data_type: string;
572
735
  /**
573
- * Timestamp when this entry expires (RFC 3339 format), or null if no TTL
736
+ * Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
574
737
  */
575
738
  get expires_at(): string | undefined;
576
739
  /**
577
- * Timestamp when this entry expires (RFC 3339 format), or null if no TTL
740
+ * Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
578
741
  */
579
742
  set expires_at(value: string | null | undefined);
580
743
  /**
@@ -594,7 +757,7 @@ export class DataStoreStats {
594
757
  /**
595
758
  * Convert `DataStoreStats` to json string value
596
759
  */
597
- json_string(): string;
760
+ jsonString(): string;
598
761
  /**
599
762
  * Average size per entry in bytes (0 if no entries)
600
763
  */
@@ -657,7 +820,7 @@ export class Diagnostics {
657
820
  readonly reason: string[];
658
821
  }
659
822
 
660
- export class IntoUnderlyingByteSource {
823
+ declare class IntoUnderlyingByteSource {
661
824
  private constructor();
662
825
  free(): void;
663
826
  [Symbol.dispose](): void;
@@ -667,8 +830,9 @@ export class IntoUnderlyingByteSource {
667
830
  readonly autoAllocateChunkSize: number;
668
831
  readonly type: ReadableStreamType;
669
832
  }
833
+ export type { IntoUnderlyingByteSource };
670
834
 
671
- export class IntoUnderlyingSink {
835
+ declare class IntoUnderlyingSink {
672
836
  private constructor();
673
837
  free(): void;
674
838
  [Symbol.dispose](): void;
@@ -676,14 +840,52 @@ export class IntoUnderlyingSink {
676
840
  close(): Promise<any>;
677
841
  write(chunk: any): Promise<any>;
678
842
  }
843
+ export type { IntoUnderlyingSink };
679
844
 
680
- export class IntoUnderlyingSource {
845
+ declare class IntoUnderlyingSource {
681
846
  private constructor();
682
847
  free(): void;
683
848
  [Symbol.dispose](): void;
684
849
  cancel(): void;
685
850
  pull(controller: ReadableStreamDefaultController): Promise<any>;
686
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
+ }
687
889
 
688
890
  /**
689
891
  * A WASM wrapper for the Rust `cedarling::MultiIssuerAuthorizeResult` struct.
@@ -696,7 +898,7 @@ export class MultiIssuerAuthorizeResult {
696
898
  /**
697
899
  * Convert `MultiIssuerAuthorizeResult` to json string value
698
900
  */
699
- json_string(): string;
901
+ jsonString(): string;
700
902
  /**
701
903
  * Result of authorization
702
904
  * true means `ALLOW`
@@ -734,8 +936,24 @@ export class PolicyEvaluationError {
734
936
  }
735
937
 
736
938
  /**
737
- * Create a new instance of the Cedarling application.
738
- * This function can take as config parameter the eather `Map` other `Object`
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
+ * ```
739
957
  */
740
958
  export function init(config: any): Promise<Cedarling>;
741
959
 
@@ -746,17 +964,27 @@ export function init(config: any): Promise<Cedarling>;
746
964
  * that was fetched with custom logic (e.g., with authentication headers).
747
965
  *
748
966
  * # Arguments
749
- * * `config` - Bootstrap configuration (Map or Object). Policy store config is ignored.
967
+ * * `config` - Bootstrap configuration (Map or Object) without a policy-store
968
+ * source property. The archive bytes provide the policy store.
750
969
  * * `archive_bytes` - The .cjar archive bytes (Uint8Array)
751
970
  *
752
971
  * # Example
753
972
  * ```javascript
754
- * const response = await fetch(url, { headers: { Authorization: 'Bearer ...' } });
755
- * const bytes = new Uint8Array(await response.arrayBuffer());
756
- * const cedarling = await init_from_archive_bytes(config, bytes);
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);
757
985
  * ```
758
986
  */
759
- export function init_from_archive_bytes(config: any, archive_bytes: Uint8Array): Promise<Cedarling>;
987
+ export function initFromArchiveBytes(config: any, archive_bytes: Uint8Array): Promise<Cedarling>;
760
988
 
761
989
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
762
990
 
@@ -765,8 +993,10 @@ export interface InitOutput {
765
993
  readonly __wbg_authorizeresult_free: (a: number, b: number) => void;
766
994
  readonly __wbg_authorizeresultresponse_free: (a: number, b: number) => void;
767
995
  readonly __wbg_batchauthorizemultiissuerresponse_free: (a: number, b: number) => void;
996
+ readonly __wbg_batchauthorizeunsignedresponse_free: (a: number, b: number) => void;
768
997
  readonly __wbg_batchitemerror_free: (a: number, b: number) => void;
769
998
  readonly __wbg_batchitemmultiissuerresult_free: (a: number, b: number) => void;
999
+ readonly __wbg_batchitemunsignedresult_free: (a: number, b: number) => void;
770
1000
  readonly __wbg_cedarling_free: (a: number, b: number) => void;
771
1001
  readonly __wbg_dataentry_free: (a: number, b: number) => void;
772
1002
  readonly __wbg_datastorestats_free: (a: number, b: number) => void;
@@ -788,6 +1018,18 @@ export interface InitOutput {
788
1018
  readonly __wbg_get_datastorestats_memory_alert_triggered: (a: number) => number;
789
1019
  readonly __wbg_get_datastorestats_metrics_enabled: (a: number) => number;
790
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;
791
1033
  readonly __wbg_policyevaluationerror_free: (a: number, b: number) => void;
792
1034
  readonly __wbg_set_authorizeresult_decision: (a: number, b: number) => void;
793
1035
  readonly __wbg_set_authorizeresult_request_id: (a: number, b: number, c: number) => void;
@@ -806,11 +1048,19 @@ export interface InitOutput {
806
1048
  readonly __wbg_set_datastorestats_memory_alert_triggered: (a: number, b: number) => void;
807
1049
  readonly __wbg_set_datastorestats_metrics_enabled: (a: number, b: number) => void;
808
1050
  readonly __wbg_set_datastorestats_total_size_bytes: (a: number, b: number) => void;
809
- readonly authorizeresult_json_string: (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;
810
1059
  readonly authorizeresultresponse_decision: (a: number) => number;
811
1060
  readonly authorizeresultresponse_diagnostics: (a: number) => number;
812
1061
  readonly batchauthorizemultiissuerresponse_batch_id: (a: number, b: number) => void;
813
1062
  readonly batchauthorizemultiissuerresponse_results: (a: number, b: number) => void;
1063
+ readonly batchauthorizeunsignedresponse_batch_id: (a: number, b: number) => void;
814
1064
  readonly batchauthorizeunsignedresponse_results: (a: number, b: number) => void;
815
1065
  readonly batchitemerror_category: (a: number, b: number) => void;
816
1066
  readonly batchitemerror_item_index: (a: number) => number;
@@ -818,48 +1068,55 @@ export interface InitOutput {
818
1068
  readonly batchitemmultiissuerresult_error: (a: number) => number;
819
1069
  readonly batchitemmultiissuerresult_is_ok: (a: number) => number;
820
1070
  readonly batchitemmultiissuerresult_unwrap: (a: number, b: number) => void;
1071
+ readonly batchitemunsignedresult_error: (a: number) => number;
1072
+ readonly batchitemunsignedresult_is_ok: (a: number) => number;
821
1073
  readonly batchitemunsignedresult_unwrap: (a: number, b: number) => void;
822
- readonly cedarling_annotation_values: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
823
- readonly cedarling_annotations_by_policy: (a: number, b: number, c: number, d: number) => void;
824
- readonly cedarling_annotations_map: (a: number, b: number, c: number, d: number) => void;
825
- readonly cedarling_authorize_multi_issuer: (a: number, b: number, c: number) => number;
826
- readonly cedarling_authorize_multi_issuer_batch: (a: number, b: number, c: number) => number;
827
- readonly cedarling_authorize_unsigned: (a: number, b: number, c: number) => number;
828
- readonly cedarling_authorize_unsigned_batch: (a: number, b: number, c: number) => number;
829
- readonly cedarling_clear_data_ctx: (a: number, b: number) => void;
830
- readonly cedarling_failed_trusted_issuer_ids: (a: number) => number;
831
- readonly cedarling_get_data_ctx: (a: number, b: number, c: number, d: number) => void;
832
- readonly cedarling_get_data_entry_ctx: (a: number, b: number, c: number, d: number) => void;
833
- readonly cedarling_get_log_by_id: (a: number, b: number, c: number, d: number) => void;
834
- readonly cedarling_get_log_ids: (a: number) => number;
835
- readonly cedarling_get_logs_by_request_id: (a: number, b: number, c: number, d: number) => void;
836
- readonly cedarling_get_logs_by_request_id_and_tag: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
837
- readonly cedarling_get_stats_ctx: (a: number, b: number) => void;
838
- readonly cedarling_is_trusted_issuer_loaded_by_iss: (a: number, b: number, c: number) => number;
839
- readonly cedarling_is_trusted_issuer_loaded_by_name: (a: number, b: number, c: number) => number;
840
- readonly cedarling_list_data_ctx: (a: number, b: number) => void;
841
- readonly cedarling_loaded_trusted_issuer_ids: (a: number) => number;
842
- readonly cedarling_loaded_trusted_issuers_count: (a: number) => number;
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;
843
1097
  readonly cedarling_new: (a: number) => number;
844
- readonly cedarling_new_from_map: (a: number) => number;
845
- readonly cedarling_pop_logs: (a: number, b: number) => void;
846
- readonly cedarling_push_data_ctx: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
847
- readonly cedarling_remove_data_ctx: (a: number, b: number, c: number, d: number) => void;
848
- readonly cedarling_shut_down: (a: number) => number;
849
- readonly cedarling_total_issuers: (a: number) => number;
850
- readonly dataentry_json_string: (a: number, b: number) => void;
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;
851
1106
  readonly dataentry_value: (a: number, b: number) => void;
852
- readonly datastorestats_json_string: (a: number, b: number) => void;
1107
+ readonly datastorestats_jsonString: (a: number, b: number) => void;
853
1108
  readonly diagnostics_errors: (a: number, b: number) => void;
854
1109
  readonly diagnostics_reason: (a: number, b: number) => void;
855
1110
  readonly init: (a: number) => number;
856
- readonly init_from_archive_bytes: (a: number, b: number) => number;
857
- readonly multiissuerauthorizeresult_json_string: (a: number, b: number) => void;
858
- readonly policyevaluationerror_error: (a: number, b: number) => void;
859
- readonly policyevaluationerror_id: (a: number, b: number) => void;
860
- readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
861
- readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
862
- readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
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;
863
1120
  readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
864
1121
  readonly intounderlyingbytesource_cancel: (a: number) => void;
865
1122
  readonly intounderlyingbytesource_pull: (a: number, b: number) => number;
@@ -870,31 +1127,14 @@ export interface InitOutput {
870
1127
  readonly intounderlyingsink_write: (a: number, b: number) => number;
871
1128
  readonly intounderlyingsource_cancel: (a: number) => void;
872
1129
  readonly intounderlyingsource_pull: (a: number, b: number) => number;
873
- readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
874
- readonly rust_zstd_wasm_shim_free: (a: number) => void;
875
- readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
876
- readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
877
- readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
878
- readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
879
- readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
880
- readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
881
- readonly __wbg_get_multiissuerauthorizeresult_decision: (a: number) => number;
882
- readonly __wbg_set_multiissuerauthorizeresult_response: (a: number, b: number) => void;
883
- readonly __wbg_set_multiissuerauthorizeresult_request_id: (a: number, b: number, c: number) => void;
884
- readonly __wbg_set_multiissuerauthorizeresult_decision: (a: number, b: number) => void;
885
- readonly __wbg_get_multiissuerauthorizeresult_response: (a: number) => number;
886
- readonly __wbg_get_multiissuerauthorizeresult_request_id: (a: number, b: number) => void;
887
- readonly __wbg_multiissuerauthorizeresult_free: (a: number, b: number) => void;
888
- readonly __wbg_batchitemunsignedresult_free: (a: number, b: number) => void;
889
- readonly __wbg_batchauthorizeunsignedresponse_free: (a: number, b: number) => void;
890
- readonly batchitemunsignedresult_is_ok: (a: number) => number;
891
- readonly batchitemunsignedresult_error: (a: number) => number;
892
- readonly batchauthorizeunsignedresponse_batch_id: (a: number, b: number) => void;
893
- readonly cedarling_get_logs_by_tag: (a: number, b: number, c: number, d: number) => void;
894
- readonly __wasm_bindgen_func_elem_8906: (a: number, b: number, c: number, d: number) => void;
895
- readonly __wasm_bindgen_func_elem_8972: (a: number, b: number, c: number, d: number) => void;
896
- readonly __wasm_bindgen_func_elem_12458: (a: number, b: number, c: number) => void;
897
- readonly __wasm_bindgen_func_elem_8741: (a: number, b: number) => void;
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;
898
1138
  readonly __wbindgen_export: (a: number, b: number) => number;
899
1139
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
900
1140
  readonly __wbindgen_export3: (a: number) => void;