@janssenproject/cedarling_wasm 0.0.473 → 0.0.475

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/dist/esm/index.js CHANGED
@@ -702,6 +702,38 @@ var Cedarling = class _Cedarling {
702
702
  wasm.__wbindgen_add_to_stack_pointer(16);
703
703
  }
704
704
  }
705
+ /**
706
+ * Destructive read: returns the telemetry metrics snapshot and resets
707
+ * the counters for the next interval.
708
+ *
709
+ * Fails when `CEDARLING_METRICS_COLLECTION` is disabled or whenever
710
+ * `CEDARLING_LOCK_TELEMETRY_INTERVAL` is set (even if the Lock server
711
+ * has no telemetry endpoint). `interval_secs` is fractional seconds,
712
+ * so sub-second intervals are reported exactly.
713
+ *
714
+ * # Example
715
+ *
716
+ * ```javascript
717
+ * const snapshot = cedarling.drainMetrics();
718
+ * console.log(`Requests: ${snapshot.operational_stats.get("authz.requests_total")}`);
719
+ * ```
720
+ * @returns {MetricsSnapshot}
721
+ */
722
+ drainMetrics() {
723
+ try {
724
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
725
+ wasm.cedarling_drainMetrics(retptr, this.__wbg_ptr);
726
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
727
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
728
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
729
+ if (r2) {
730
+ throw takeObject(r1);
731
+ }
732
+ return MetricsSnapshot.__wrap(r0);
733
+ } finally {
734
+ wasm.__wbindgen_add_to_stack_pointer(16);
735
+ }
736
+ }
705
737
  /**
706
738
  * Get trusted issuer identifiers that failed to load.
707
739
  *
@@ -1818,6 +1850,119 @@ var IntoUnderlyingSource = class {
1818
1850
  }
1819
1851
  };
1820
1852
  if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free;
1853
+ var MetricsSnapshot = class _MetricsSnapshot {
1854
+ static __wrap(ptr) {
1855
+ const obj = Object.create(_MetricsSnapshot.prototype);
1856
+ obj.__wbg_ptr = ptr;
1857
+ MetricsSnapshotFinalization.register(obj, obj.__wbg_ptr, obj);
1858
+ return obj;
1859
+ }
1860
+ __destroy_into_raw() {
1861
+ const ptr = this.__wbg_ptr;
1862
+ this.__wbg_ptr = 0;
1863
+ MetricsSnapshotFinalization.unregister(this);
1864
+ return ptr;
1865
+ }
1866
+ free() {
1867
+ const ptr = this.__destroy_into_raw();
1868
+ wasm.__wbg_metricssnapshot_free(ptr, 0);
1869
+ }
1870
+ /**
1871
+ * Classified error counters keyed by error metric key.
1872
+ * @returns {Map<any, any>}
1873
+ */
1874
+ get error_counters() {
1875
+ const ret = wasm.__wbg_get_metricssnapshot_error_counters(this.__wbg_ptr);
1876
+ return takeObject(ret);
1877
+ }
1878
+ /**
1879
+ * Duration of the snapshot interval in fractional seconds.
1880
+ * Exposed as `Number` (not `BigInt`) so plain JS arithmetic works.
1881
+ * @returns {number}
1882
+ */
1883
+ get interval_secs() {
1884
+ const ret = wasm.__wbg_get_metricssnapshot_interval_secs(this.__wbg_ptr);
1885
+ return ret;
1886
+ }
1887
+ /**
1888
+ * Operational counters and gauges (authorization, cache, JWT, data, lock).
1889
+ * @returns {Map<any, any>}
1890
+ */
1891
+ get operational_stats() {
1892
+ const ret = wasm.__wbg_get_metricssnapshot_operational_stats(this.__wbg_ptr);
1893
+ return takeObject(ret);
1894
+ }
1895
+ /**
1896
+ * Per-policy evaluation counts (`policy_id`, `policy_id.allow`, `policy_id.deny`).
1897
+ * @returns {Map<any, any>}
1898
+ */
1899
+ get policy_stats() {
1900
+ const ret = wasm.__wbg_get_metricssnapshot_policy_stats(this.__wbg_ptr);
1901
+ return takeObject(ret);
1902
+ }
1903
+ /**
1904
+ * Convert `MetricsSnapshot` to json string value.
1905
+ *
1906
+ * `policy_stats`, `error_counters` and `operational_stats` are converted
1907
+ * from `Map` to plain objects so `JSON.stringify` emits their entries.
1908
+ * @returns {string}
1909
+ */
1910
+ jsonString() {
1911
+ let deferred2_0;
1912
+ let deferred2_1;
1913
+ try {
1914
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1915
+ wasm.metricssnapshot_jsonString(retptr, this.__wbg_ptr);
1916
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1917
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1918
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1919
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1920
+ var ptr1 = r0;
1921
+ var len1 = r1;
1922
+ if (r3) {
1923
+ ptr1 = 0;
1924
+ len1 = 0;
1925
+ throw takeObject(r2);
1926
+ }
1927
+ deferred2_0 = ptr1;
1928
+ deferred2_1 = len1;
1929
+ return getStringFromWasm0(ptr1, len1);
1930
+ } finally {
1931
+ wasm.__wbindgen_add_to_stack_pointer(16);
1932
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
1933
+ }
1934
+ }
1935
+ /**
1936
+ * Classified error counters keyed by error metric key.
1937
+ * @param {Map<any, any>} arg0
1938
+ */
1939
+ set error_counters(arg0) {
1940
+ wasm.__wbg_set_metricssnapshot_error_counters(this.__wbg_ptr, addHeapObject(arg0));
1941
+ }
1942
+ /**
1943
+ * Duration of the snapshot interval in fractional seconds.
1944
+ * Exposed as `Number` (not `BigInt`) so plain JS arithmetic works.
1945
+ * @param {number} arg0
1946
+ */
1947
+ set interval_secs(arg0) {
1948
+ wasm.__wbg_set_metricssnapshot_interval_secs(this.__wbg_ptr, arg0);
1949
+ }
1950
+ /**
1951
+ * Operational counters and gauges (authorization, cache, JWT, data, lock).
1952
+ * @param {Map<any, any>} arg0
1953
+ */
1954
+ set operational_stats(arg0) {
1955
+ wasm.__wbg_set_metricssnapshot_operational_stats(this.__wbg_ptr, addHeapObject(arg0));
1956
+ }
1957
+ /**
1958
+ * Per-policy evaluation counts (`policy_id`, `policy_id.allow`, `policy_id.deny`).
1959
+ * @param {Map<any, any>} arg0
1960
+ */
1961
+ set policy_stats(arg0) {
1962
+ wasm.__wbg_set_metricssnapshot_policy_stats(this.__wbg_ptr, addHeapObject(arg0));
1963
+ }
1964
+ };
1965
+ if (Symbol.dispose) MetricsSnapshot.prototype[Symbol.dispose] = MetricsSnapshot.prototype.free;
1821
1966
  var MultiIssuerAuthorizeResult = class _MultiIssuerAuthorizeResult {
1822
1967
  static __wrap(ptr) {
1823
1968
  const obj = Object.create(_MultiIssuerAuthorizeResult.prototype);
@@ -2436,7 +2581,7 @@ function __wbg_get_imports() {
2436
2581
  const a = state0.a;
2437
2582
  state0.a = 0;
2438
2583
  try {
2439
- return __wasm_bindgen_func_elem_8962(a, state0.b, arg02, arg12);
2584
+ return __wasm_bindgen_func_elem_8982(a, state0.b, arg02, arg12);
2440
2585
  } finally {
2441
2586
  state0.a = a;
2442
2587
  }
@@ -2619,6 +2764,12 @@ function __wbg_get_imports() {
2619
2764
  const ret = getObject(arg0).status;
2620
2765
  return ret;
2621
2766
  },
2767
+ __wbg_stringify_54b3d9b61602aee6: function() {
2768
+ return handleError(function(arg0) {
2769
+ const ret = JSON.stringify(getObject(arg0));
2770
+ return addHeapObject(ret);
2771
+ }, arguments);
2772
+ },
2622
2773
  __wbg_subarray_1daff70dde20c145: function(arg0, arg1, arg2) {
2623
2774
  const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
2624
2775
  return addHeapObject(ret);
@@ -2661,15 +2812,15 @@ function __wbg_get_imports() {
2661
2812
  console.warn(...getObject(arg0));
2662
2813
  },
2663
2814
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
2664
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8907);
2815
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8927);
2665
2816
  return addHeapObject(ret);
2666
2817
  },
2667
2818
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
2668
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12467);
2819
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12488);
2669
2820
  return addHeapObject(ret);
2670
2821
  },
2671
2822
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
2672
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8741);
2823
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8761);
2673
2824
  return addHeapObject(ret);
2674
2825
  },
2675
2826
  __wbindgen_generic_0000000000000004: function(arg0) {
@@ -2705,19 +2856,19 @@ function __wbg_get_imports() {
2705
2856
  "./cedarling_wasm_bg.js": import0
2706
2857
  };
2707
2858
  }
2708
- function __wasm_bindgen_func_elem_8741(arg0, arg1) {
2709
- wasm.__wasm_bindgen_func_elem_8741(arg0, arg1);
2859
+ function __wasm_bindgen_func_elem_8761(arg0, arg1) {
2860
+ wasm.__wasm_bindgen_func_elem_8761(arg0, arg1);
2710
2861
  }
2711
- function __wasm_bindgen_func_elem_12467(arg0, arg1, arg2) {
2712
- wasm.__wasm_bindgen_func_elem_12467(arg0, arg1, addHeapObject(arg2));
2862
+ function __wasm_bindgen_func_elem_12488(arg0, arg1, arg2) {
2863
+ wasm.__wasm_bindgen_func_elem_12488(arg0, arg1, addHeapObject(arg2));
2713
2864
  }
2714
- function __wasm_bindgen_func_elem_8962(arg0, arg1, arg2, arg3) {
2715
- wasm.__wasm_bindgen_func_elem_8962(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2865
+ function __wasm_bindgen_func_elem_8982(arg0, arg1, arg2, arg3) {
2866
+ wasm.__wasm_bindgen_func_elem_8982(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2716
2867
  }
2717
- function __wasm_bindgen_func_elem_8907(arg0, arg1, arg2) {
2868
+ function __wasm_bindgen_func_elem_8927(arg0, arg1, arg2) {
2718
2869
  try {
2719
2870
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2720
- wasm.__wasm_bindgen_func_elem_8907(retptr, arg0, arg1, addHeapObject(arg2));
2871
+ wasm.__wasm_bindgen_func_elem_8927(retptr, arg0, arg1, addHeapObject(arg2));
2721
2872
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2722
2873
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2723
2874
  if (r1) {
@@ -2775,6 +2926,9 @@ var IntoUnderlyingSinkFinalization = typeof FinalizationRegistry === "undefined"
2775
2926
  var IntoUnderlyingSourceFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2776
2927
  }, unregister: () => {
2777
2928
  } } : new FinalizationRegistry((ptr) => wasm.__wbg_intounderlyingsource_free(ptr, 1));
2929
+ var MetricsSnapshotFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2930
+ }, unregister: () => {
2931
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_metricssnapshot_free(ptr, 1));
2778
2932
  var MultiIssuerAuthorizeResultFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2779
2933
  }, unregister: () => {
2780
2934
  } } : new FinalizationRegistry((ptr) => wasm.__wbg_multiissuerauthorizeresult_free(ptr, 1));