@janssenproject/cedarling_wasm 0.0.404 → 0.0.405

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/README.md CHANGED
@@ -53,7 +53,9 @@ async function main() {
53
53
  await initWasm(); // Initialize the WebAssembly module
54
54
 
55
55
  let instance = await init(BOOTSTRAP_CONFIG);
56
- let result = await instance.authorize_unsigned(REQUEST_UNSIGNED);
56
+ // authorize calls take the request as a JSON string: it crosses the
57
+ // JS/WASM boundary as one string copy parsed by serde_json
58
+ let result = await instance.authorize_unsigned(JSON.stringify(REQUEST_UNSIGNED));
57
59
  console.log("result:", result);
58
60
  }
59
61
  main().catch(console.error);
@@ -110,12 +112,13 @@ export class Cedarling {
110
112
  * residual-dependent requests fail closed with `Decision::Deny` and surface
111
113
  * residual policy ids in `response.diagnostics.reason`.
112
114
  */
113
- authorize_unsigned(request: any): Promise<AuthorizeResult>;
115
+ authorize_unsigned(request: string): Promise<AuthorizeResult>;
114
116
  /**
115
117
  * Authorize multi-issuer request.
116
118
  * Makes authorization decision based on multiple JWT tokens from different issuers
119
+ * The request is passed as a JSON string.
117
120
  */
118
- authorize_multi_issuer(request: any): Promise<MultiIssuerAuthorizeResult>;
121
+ authorize_multi_issuer(request: string): Promise<MultiIssuerAuthorizeResult>;
119
122
  /**
120
123
  * Get logs and remove them from the storage.
121
124
  * Returns `Array` of `Map`
@@ -418,6 +421,10 @@ Cedarling supports multiple ways to load policy stores. **In WASM environments,
418
421
  // Option 1: Fetch policy store from URL (simple)
419
422
  const BOOTSTRAP_CONFIG = {
420
423
  CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
424
+ // Optional: re-fetch every 60s and atomically swap on change.
425
+ // Default is 0 (load-once-at-startup). See "Refreshing the policy store"
426
+ // in docs/cedarling/reference/cedarling-properties.md for details.
427
+ CEDARLING_POLICY_STORE_REFRESH_INTERVAL: 60,
421
428
  // ... other config
422
429
  };
423
430
  const cedarling = await init(BOOTSTRAP_CONFIG);
@@ -65,9 +65,19 @@ export class Cedarling {
65
65
  [Symbol.dispose](): void;
66
66
  /**
67
67
  * Authorize multi-issuer request.
68
- * Makes authorization decision based on multiple JWT tokens from different issuers
68
+ * Makes authorization decision based on multiple JWT tokens from different issuers.
69
+ *
70
+ * # Arguments
71
+ *
72
+ * * `request` - JSON string representation of [`AuthorizeMultiIssuerRequest`].
73
+ *
74
+ * # Example
75
+ *
76
+ * ```javascript
77
+ * const result = await cedarling.authorize_multi_issuer(JSON.stringify(request));
78
+ * ```
69
79
  */
70
- authorize_multi_issuer(request: any): Promise<MultiIssuerAuthorizeResult>;
80
+ authorize_multi_issuer(request: string): Promise<MultiIssuerAuthorizeResult>;
71
81
  /**
72
82
  * Authorize an unsigned request carrying an optional single principal.
73
83
  * Makes an authorization decision based on the [`RequestUnsigned`].
@@ -76,8 +86,18 @@ export class Cedarling {
76
86
  * partial evaluation; residual-dependent requests fail closed with
77
87
  * `Decision::Deny` and surface residual policy ids in
78
88
  * `response.diagnostics.reason`.
89
+ *
90
+ * # Arguments
91
+ *
92
+ * * `request` - JSON string representation of [`RequestUnsigned`].
93
+ *
94
+ * # Example
95
+ *
96
+ * ```javascript
97
+ * const result = await cedarling.authorize_unsigned(JSON.stringify(request));
98
+ * ```
79
99
  */
80
- authorize_unsigned(request: any): Promise<AuthorizeResult>;
100
+ authorize_unsigned(request: string): Promise<AuthorizeResult>;
81
101
  /**
82
102
  * Clear all entries from the data store.
83
103
  *
@@ -536,13 +556,13 @@ export interface InitOutput {
536
556
  readonly __wbg_datastorestats_free: (a: number, b: number) => void;
537
557
  readonly __wbg_diagnostics_free: (a: number, b: number) => void;
538
558
  readonly __wbg_get_authorizeresult_decision: (a: number) => number;
539
- readonly __wbg_get_authorizeresult_request_id: (a: number) => [number, number];
559
+ readonly __wbg_get_authorizeresult_request_id: (a: number, b: number) => void;
540
560
  readonly __wbg_get_authorizeresult_response: (a: number) => number;
541
561
  readonly __wbg_get_dataentry_access_count: (a: number) => bigint;
542
- readonly __wbg_get_dataentry_created_at: (a: number) => [number, number];
543
- readonly __wbg_get_dataentry_data_type: (a: number) => [number, number];
544
- readonly __wbg_get_dataentry_expires_at: (a: number) => [number, number];
545
- readonly __wbg_get_dataentry_key: (a: number) => [number, number];
562
+ readonly __wbg_get_dataentry_created_at: (a: number, b: number) => void;
563
+ readonly __wbg_get_dataentry_data_type: (a: number, b: number) => void;
564
+ readonly __wbg_get_dataentry_expires_at: (a: number, b: number) => void;
565
+ readonly __wbg_get_dataentry_key: (a: number, b: number) => void;
546
566
  readonly __wbg_get_datastorestats_avg_entry_size_bytes: (a: number) => number;
547
567
  readonly __wbg_get_datastorestats_capacity_usage_percent: (a: number) => number;
548
568
  readonly __wbg_get_datastorestats_entry_count: (a: number) => number;
@@ -570,63 +590,55 @@ export interface InitOutput {
570
590
  readonly __wbg_set_datastorestats_memory_alert_triggered: (a: number, b: number) => void;
571
591
  readonly __wbg_set_datastorestats_metrics_enabled: (a: number, b: number) => void;
572
592
  readonly __wbg_set_datastorestats_total_size_bytes: (a: number, b: number) => void;
573
- readonly authorizeresult_json_string: (a: number) => [number, number];
593
+ readonly authorizeresult_json_string: (a: number, b: number) => void;
574
594
  readonly authorizeresultresponse_decision: (a: number) => number;
575
595
  readonly authorizeresultresponse_diagnostics: (a: number) => number;
576
- readonly cedarling_authorize_multi_issuer: (a: number, b: any) => any;
577
- readonly cedarling_authorize_unsigned: (a: number, b: any) => any;
578
- readonly cedarling_clear_data_ctx: (a: number) => [number, number];
579
- readonly cedarling_failed_trusted_issuer_ids: (a: number) => any;
580
- readonly cedarling_get_data_ctx: (a: number, b: number, c: number) => [number, number, number];
581
- readonly cedarling_get_data_entry_ctx: (a: number, b: number, c: number) => [number, number, number];
582
- readonly cedarling_get_log_by_id: (a: number, b: number, c: number) => [number, number, number];
583
- readonly cedarling_get_log_ids: (a: number) => any;
584
- readonly cedarling_get_logs_by_request_id: (a: number, b: number, c: number) => [number, number, number, number];
585
- readonly cedarling_get_logs_by_request_id_and_tag: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
586
- readonly cedarling_get_logs_by_tag: (a: number, b: number, c: number) => [number, number, number, number];
587
- readonly cedarling_get_stats_ctx: (a: number) => [number, number, number];
596
+ readonly cedarling_authorize_multi_issuer: (a: number, b: number, c: number) => number;
597
+ readonly cedarling_authorize_unsigned: (a: number, b: number, c: number) => number;
598
+ readonly cedarling_clear_data_ctx: (a: number, b: number) => void;
599
+ readonly cedarling_failed_trusted_issuer_ids: (a: number) => number;
600
+ readonly cedarling_get_data_ctx: (a: number, b: number, c: number, d: number) => void;
601
+ readonly cedarling_get_data_entry_ctx: (a: number, b: number, c: number, d: number) => void;
602
+ readonly cedarling_get_log_by_id: (a: number, b: number, c: number, d: number) => void;
603
+ readonly cedarling_get_log_ids: (a: number) => number;
604
+ readonly cedarling_get_logs_by_request_id: (a: number, b: number, c: number, d: number) => void;
605
+ readonly cedarling_get_logs_by_request_id_and_tag: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
606
+ readonly cedarling_get_stats_ctx: (a: number, b: number) => void;
588
607
  readonly cedarling_is_trusted_issuer_loaded_by_iss: (a: number, b: number, c: number) => number;
589
608
  readonly cedarling_is_trusted_issuer_loaded_by_name: (a: number, b: number, c: number) => number;
590
- readonly cedarling_list_data_ctx: (a: number) => [number, number, number];
591
- readonly cedarling_loaded_trusted_issuer_ids: (a: number) => any;
609
+ readonly cedarling_list_data_ctx: (a: number, b: number) => void;
610
+ readonly cedarling_loaded_trusted_issuer_ids: (a: number) => number;
592
611
  readonly cedarling_loaded_trusted_issuers_count: (a: number) => number;
593
- readonly cedarling_new: (a: any) => any;
594
- readonly cedarling_new_from_map: (a: any) => any;
595
- readonly cedarling_pop_logs: (a: number) => [number, number, number];
596
- readonly cedarling_push_data_ctx: (a: number, b: number, c: number, d: any, e: number, f: bigint) => [number, number];
597
- readonly cedarling_remove_data_ctx: (a: number, b: number, c: number) => [number, number, number];
598
- readonly cedarling_shut_down: (a: number) => any;
612
+ readonly cedarling_new: (a: number) => number;
613
+ readonly cedarling_new_from_map: (a: number) => number;
614
+ readonly cedarling_pop_logs: (a: number, b: number) => void;
615
+ readonly cedarling_push_data_ctx: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
616
+ readonly cedarling_remove_data_ctx: (a: number, b: number, c: number, d: number) => void;
617
+ readonly cedarling_shut_down: (a: number) => number;
599
618
  readonly cedarling_total_issuers: (a: number) => number;
600
- readonly dataentry_json_string: (a: number) => [number, number];
601
- readonly dataentry_value: (a: number) => [number, number, number];
602
- readonly datastorestats_json_string: (a: number) => [number, number];
603
- readonly diagnostics_errors: (a: number) => [number, number];
604
- readonly diagnostics_reason: (a: number) => [number, number];
605
- readonly init: (a: any) => any;
606
- readonly init_from_archive_bytes: (a: any, b: any) => any;
607
- readonly multiissuerauthorizeresult_json_string: (a: number) => [number, number];
608
- readonly policyevaluationerror_error: (a: number) => [number, number];
609
- readonly policyevaluationerror_id: (a: number) => [number, number];
610
- readonly __wbg_get_multiissuerauthorizeresult_decision: (a: number) => number;
611
- readonly __wbg_set_multiissuerauthorizeresult_response: (a: number, b: number) => void;
612
- readonly __wbg_set_multiissuerauthorizeresult_request_id: (a: number, b: number, c: number) => void;
613
- readonly __wbg_set_multiissuerauthorizeresult_decision: (a: number, b: number) => void;
614
- readonly __wbg_get_multiissuerauthorizeresult_response: (a: number) => number;
615
- readonly __wbg_get_multiissuerauthorizeresult_request_id: (a: number) => [number, number];
616
- readonly __wbg_multiissuerauthorizeresult_free: (a: number, b: number) => void;
619
+ readonly dataentry_json_string: (a: number, b: number) => void;
620
+ readonly dataentry_value: (a: number, b: number) => void;
621
+ readonly datastorestats_json_string: (a: number, b: number) => void;
622
+ readonly diagnostics_errors: (a: number, b: number) => void;
623
+ readonly diagnostics_reason: (a: number, b: number) => void;
624
+ readonly init: (a: number) => number;
625
+ readonly init_from_archive_bytes: (a: number, b: number) => number;
626
+ readonly multiissuerauthorizeresult_json_string: (a: number, b: number) => void;
627
+ readonly policyevaluationerror_error: (a: number, b: number) => void;
628
+ readonly policyevaluationerror_id: (a: number, b: number) => void;
617
629
  readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
618
630
  readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
619
631
  readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
620
632
  readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
621
633
  readonly intounderlyingbytesource_cancel: (a: number) => void;
622
- readonly intounderlyingbytesource_pull: (a: number, b: any) => any;
623
- readonly intounderlyingbytesource_start: (a: number, b: any) => void;
634
+ readonly intounderlyingbytesource_pull: (a: number, b: number) => number;
635
+ readonly intounderlyingbytesource_start: (a: number, b: number) => void;
624
636
  readonly intounderlyingbytesource_type: (a: number) => number;
625
- readonly intounderlyingsink_abort: (a: number, b: any) => any;
626
- readonly intounderlyingsink_close: (a: number) => any;
627
- readonly intounderlyingsink_write: (a: number, b: any) => any;
637
+ readonly intounderlyingsink_abort: (a: number, b: number) => number;
638
+ readonly intounderlyingsink_close: (a: number) => number;
639
+ readonly intounderlyingsink_write: (a: number, b: number) => number;
628
640
  readonly intounderlyingsource_cancel: (a: number) => void;
629
- readonly intounderlyingsource_pull: (a: number, b: any) => any;
641
+ readonly intounderlyingsource_pull: (a: number, b: number) => number;
630
642
  readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
631
643
  readonly rust_zstd_wasm_shim_free: (a: number) => void;
632
644
  readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
@@ -635,22 +647,24 @@ export interface InitOutput {
635
647
  readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
636
648
  readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
637
649
  readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
638
- readonly wasm_bindgen__convert__closures_____invoke__he0d1df4f45812a75: (a: number, b: number, c: any) => [number, number];
639
- readonly wasm_bindgen__convert__closures_____invoke__h03fb46086606eb61: (a: number, b: number, c: any, d: any) => void;
640
- readonly wasm_bindgen__convert__closures_____invoke__hdd4256d54acb8ff1: (a: number, b: number, c: any) => void;
641
- readonly wasm_bindgen__convert__closures_____invoke__hc7b60e1a5fd69b6e: (a: number, b: number) => void;
642
- readonly wasm_bindgen__convert__closures_____invoke__h6f2d88ffbcba67ef: (a: number, b: number) => void;
643
- readonly wasm_bindgen__convert__closures_____invoke__h32cbe4603be323e5: (a: number, b: number) => void;
644
- readonly __wbindgen_malloc: (a: number, b: number) => number;
645
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
646
- readonly __wbindgen_exn_store: (a: number) => void;
647
- readonly __externref_table_alloc: () => number;
648
- readonly __wbindgen_externrefs: WebAssembly.Table;
649
- readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
650
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
651
- readonly __externref_table_dealloc: (a: number) => void;
652
- readonly __externref_drop_slice: (a: number, b: number) => void;
653
- readonly __wbindgen_start: () => void;
650
+ readonly __wbg_get_multiissuerauthorizeresult_decision: (a: number) => number;
651
+ readonly __wbg_set_multiissuerauthorizeresult_response: (a: number, b: number) => void;
652
+ readonly __wbg_set_multiissuerauthorizeresult_request_id: (a: number, b: number, c: number) => void;
653
+ readonly __wbg_set_multiissuerauthorizeresult_decision: (a: number, b: number) => void;
654
+ readonly __wbg_get_multiissuerauthorizeresult_response: (a: number) => number;
655
+ readonly __wbg_get_multiissuerauthorizeresult_request_id: (a: number, b: number) => void;
656
+ readonly __wbg_multiissuerauthorizeresult_free: (a: number, b: number) => void;
657
+ readonly cedarling_get_logs_by_tag: (a: number, b: number, c: number, d: number) => void;
658
+ readonly __wasm_bindgen_func_elem_8728: (a: number, b: number, c: number, d: number) => void;
659
+ readonly __wasm_bindgen_func_elem_8782: (a: number, b: number, c: number, d: number) => void;
660
+ readonly __wasm_bindgen_func_elem_12191: (a: number, b: number, c: number) => void;
661
+ readonly __wasm_bindgen_func_elem_8563: (a: number, b: number) => void;
662
+ readonly __wbindgen_export: (a: number, b: number) => number;
663
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
664
+ readonly __wbindgen_export3: (a: number) => void;
665
+ readonly __wbindgen_export4: (a: number, b: number) => void;
666
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
667
+ readonly __wbindgen_export5: (a: number, b: number, c: number) => void;
654
668
  }
655
669
 
656
670
  export type SyncInitInput = BufferSource | WebAssembly.Module;