@janssenproject/cedarling_wasm 0.0.473 → 0.0.474
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 +21 -0
- package/dist/browser/index.js +166 -12
- package/dist/browser/index.js.map +2 -2
- package/dist/cjs/index.cjs +166 -12
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/edge/index.js +166 -12
- package/dist/edge/index.js.map +2 -2
- package/dist/esm/index.js +166 -12
- package/dist/esm/index.js.map +2 -2
- package/dist/manual/index.js +167 -12
- package/dist/manual/index.js.map +2 -2
- package/dist/types/cjs/generated.d.ts +69 -5
- package/dist/types/esm/generated.d.ts +69 -5
- package/dist/wasm/cedarling_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -357,6 +357,27 @@ try {
|
|
|
357
357
|
The optional TTL is a `bigint` number of seconds; omitting it uses the configured
|
|
358
358
|
default. Retrieval returns `null` when a value is absent or expired.
|
|
359
359
|
|
|
360
|
+
### Metrics Snapshot
|
|
361
|
+
|
|
362
|
+
Destructive read: returns a metrics snapshot and resets the counters.
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
try {
|
|
366
|
+
const snapshot = cedarling.drainMetrics();
|
|
367
|
+
console.log(snapshot.operational_stats.get("authz.requests_total"));
|
|
368
|
+
console.log(snapshot.interval_secs);
|
|
369
|
+
} catch (error) {
|
|
370
|
+
console.error("Metrics snapshot failed", error);
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Requires `CEDARLING_METRICS_COLLECTION: "enabled"`. Fails whenever
|
|
375
|
+
`CEDARLING_LOCK_TELEMETRY_INTERVAL` is set, even if the Lock server has no
|
|
376
|
+
telemetry endpoint. `interval_secs` is a plain `Number` (not `BigInt`), so
|
|
377
|
+
`snapshot.interval_secs + 1` works. It carries fractional seconds, so
|
|
378
|
+
sub-second intervals are reported exactly. Use `snapshot.jsonString()` for a
|
|
379
|
+
JSON-serializable form with plain objects.
|
|
380
|
+
|
|
360
381
|
### Trusted Issuer Readiness
|
|
361
382
|
|
|
362
383
|
Before token-based authorization, inspect which configured issuers loaded and
|
package/dist/browser/index.js
CHANGED
|
@@ -704,6 +704,38 @@ var Cedarling = class _Cedarling {
|
|
|
704
704
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
|
+
/**
|
|
708
|
+
* Destructive read: returns the telemetry metrics snapshot and resets
|
|
709
|
+
* the counters for the next interval.
|
|
710
|
+
*
|
|
711
|
+
* Fails when `CEDARLING_METRICS_COLLECTION` is disabled or whenever
|
|
712
|
+
* `CEDARLING_LOCK_TELEMETRY_INTERVAL` is set (even if the Lock server
|
|
713
|
+
* has no telemetry endpoint). `interval_secs` is fractional seconds,
|
|
714
|
+
* so sub-second intervals are reported exactly.
|
|
715
|
+
*
|
|
716
|
+
* # Example
|
|
717
|
+
*
|
|
718
|
+
* ```javascript
|
|
719
|
+
* const snapshot = cedarling.drainMetrics();
|
|
720
|
+
* console.log(`Requests: ${snapshot.operational_stats.get("authz.requests_total")}`);
|
|
721
|
+
* ```
|
|
722
|
+
* @returns {MetricsSnapshot}
|
|
723
|
+
*/
|
|
724
|
+
drainMetrics() {
|
|
725
|
+
try {
|
|
726
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
727
|
+
wasm.cedarling_drainMetrics(retptr, this.__wbg_ptr);
|
|
728
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
729
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
730
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
731
|
+
if (r2) {
|
|
732
|
+
throw takeObject(r1);
|
|
733
|
+
}
|
|
734
|
+
return MetricsSnapshot.__wrap(r0);
|
|
735
|
+
} finally {
|
|
736
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
707
739
|
/**
|
|
708
740
|
* Get trusted issuer identifiers that failed to load.
|
|
709
741
|
*
|
|
@@ -1820,6 +1852,119 @@ var IntoUnderlyingSource = class {
|
|
|
1820
1852
|
}
|
|
1821
1853
|
};
|
|
1822
1854
|
if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free;
|
|
1855
|
+
var MetricsSnapshot = class _MetricsSnapshot {
|
|
1856
|
+
static __wrap(ptr) {
|
|
1857
|
+
const obj = Object.create(_MetricsSnapshot.prototype);
|
|
1858
|
+
obj.__wbg_ptr = ptr;
|
|
1859
|
+
MetricsSnapshotFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1860
|
+
return obj;
|
|
1861
|
+
}
|
|
1862
|
+
__destroy_into_raw() {
|
|
1863
|
+
const ptr = this.__wbg_ptr;
|
|
1864
|
+
this.__wbg_ptr = 0;
|
|
1865
|
+
MetricsSnapshotFinalization.unregister(this);
|
|
1866
|
+
return ptr;
|
|
1867
|
+
}
|
|
1868
|
+
free() {
|
|
1869
|
+
const ptr = this.__destroy_into_raw();
|
|
1870
|
+
wasm.__wbg_metricssnapshot_free(ptr, 0);
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Classified error counters keyed by error metric key.
|
|
1874
|
+
* @returns {Map<any, any>}
|
|
1875
|
+
*/
|
|
1876
|
+
get error_counters() {
|
|
1877
|
+
const ret = wasm.__wbg_get_metricssnapshot_error_counters(this.__wbg_ptr);
|
|
1878
|
+
return takeObject(ret);
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* Duration of the snapshot interval in fractional seconds.
|
|
1882
|
+
* Exposed as `Number` (not `BigInt`) so plain JS arithmetic works.
|
|
1883
|
+
* @returns {number}
|
|
1884
|
+
*/
|
|
1885
|
+
get interval_secs() {
|
|
1886
|
+
const ret = wasm.__wbg_get_metricssnapshot_interval_secs(this.__wbg_ptr);
|
|
1887
|
+
return ret;
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Operational counters and gauges (authorization, cache, JWT, data, lock).
|
|
1891
|
+
* @returns {Map<any, any>}
|
|
1892
|
+
*/
|
|
1893
|
+
get operational_stats() {
|
|
1894
|
+
const ret = wasm.__wbg_get_metricssnapshot_operational_stats(this.__wbg_ptr);
|
|
1895
|
+
return takeObject(ret);
|
|
1896
|
+
}
|
|
1897
|
+
/**
|
|
1898
|
+
* Per-policy evaluation counts (`policy_id`, `policy_id.allow`, `policy_id.deny`).
|
|
1899
|
+
* @returns {Map<any, any>}
|
|
1900
|
+
*/
|
|
1901
|
+
get policy_stats() {
|
|
1902
|
+
const ret = wasm.__wbg_get_metricssnapshot_policy_stats(this.__wbg_ptr);
|
|
1903
|
+
return takeObject(ret);
|
|
1904
|
+
}
|
|
1905
|
+
/**
|
|
1906
|
+
* Convert `MetricsSnapshot` to json string value.
|
|
1907
|
+
*
|
|
1908
|
+
* `policy_stats`, `error_counters` and `operational_stats` are converted
|
|
1909
|
+
* from `Map` to plain objects so `JSON.stringify` emits their entries.
|
|
1910
|
+
* @returns {string}
|
|
1911
|
+
*/
|
|
1912
|
+
jsonString() {
|
|
1913
|
+
let deferred2_0;
|
|
1914
|
+
let deferred2_1;
|
|
1915
|
+
try {
|
|
1916
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1917
|
+
wasm.metricssnapshot_jsonString(retptr, this.__wbg_ptr);
|
|
1918
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1919
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1920
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1921
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1922
|
+
var ptr1 = r0;
|
|
1923
|
+
var len1 = r1;
|
|
1924
|
+
if (r3) {
|
|
1925
|
+
ptr1 = 0;
|
|
1926
|
+
len1 = 0;
|
|
1927
|
+
throw takeObject(r2);
|
|
1928
|
+
}
|
|
1929
|
+
deferred2_0 = ptr1;
|
|
1930
|
+
deferred2_1 = len1;
|
|
1931
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1932
|
+
} finally {
|
|
1933
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1934
|
+
wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
/**
|
|
1938
|
+
* Classified error counters keyed by error metric key.
|
|
1939
|
+
* @param {Map<any, any>} arg0
|
|
1940
|
+
*/
|
|
1941
|
+
set error_counters(arg0) {
|
|
1942
|
+
wasm.__wbg_set_metricssnapshot_error_counters(this.__wbg_ptr, addHeapObject(arg0));
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* Duration of the snapshot interval in fractional seconds.
|
|
1946
|
+
* Exposed as `Number` (not `BigInt`) so plain JS arithmetic works.
|
|
1947
|
+
* @param {number} arg0
|
|
1948
|
+
*/
|
|
1949
|
+
set interval_secs(arg0) {
|
|
1950
|
+
wasm.__wbg_set_metricssnapshot_interval_secs(this.__wbg_ptr, arg0);
|
|
1951
|
+
}
|
|
1952
|
+
/**
|
|
1953
|
+
* Operational counters and gauges (authorization, cache, JWT, data, lock).
|
|
1954
|
+
* @param {Map<any, any>} arg0
|
|
1955
|
+
*/
|
|
1956
|
+
set operational_stats(arg0) {
|
|
1957
|
+
wasm.__wbg_set_metricssnapshot_operational_stats(this.__wbg_ptr, addHeapObject(arg0));
|
|
1958
|
+
}
|
|
1959
|
+
/**
|
|
1960
|
+
* Per-policy evaluation counts (`policy_id`, `policy_id.allow`, `policy_id.deny`).
|
|
1961
|
+
* @param {Map<any, any>} arg0
|
|
1962
|
+
*/
|
|
1963
|
+
set policy_stats(arg0) {
|
|
1964
|
+
wasm.__wbg_set_metricssnapshot_policy_stats(this.__wbg_ptr, addHeapObject(arg0));
|
|
1965
|
+
}
|
|
1966
|
+
};
|
|
1967
|
+
if (Symbol.dispose) MetricsSnapshot.prototype[Symbol.dispose] = MetricsSnapshot.prototype.free;
|
|
1823
1968
|
var MultiIssuerAuthorizeResult = class _MultiIssuerAuthorizeResult {
|
|
1824
1969
|
static __wrap(ptr) {
|
|
1825
1970
|
const obj = Object.create(_MultiIssuerAuthorizeResult.prototype);
|
|
@@ -2438,7 +2583,7 @@ function __wbg_get_imports() {
|
|
|
2438
2583
|
const a = state0.a;
|
|
2439
2584
|
state0.a = 0;
|
|
2440
2585
|
try {
|
|
2441
|
-
return
|
|
2586
|
+
return __wasm_bindgen_func_elem_8982(a, state0.b, arg02, arg12);
|
|
2442
2587
|
} finally {
|
|
2443
2588
|
state0.a = a;
|
|
2444
2589
|
}
|
|
@@ -2621,6 +2766,12 @@ function __wbg_get_imports() {
|
|
|
2621
2766
|
const ret = getObject(arg0).status;
|
|
2622
2767
|
return ret;
|
|
2623
2768
|
},
|
|
2769
|
+
__wbg_stringify_54b3d9b61602aee6: function() {
|
|
2770
|
+
return handleError(function(arg0) {
|
|
2771
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
2772
|
+
return addHeapObject(ret);
|
|
2773
|
+
}, arguments);
|
|
2774
|
+
},
|
|
2624
2775
|
__wbg_subarray_1daff70dde20c145: function(arg0, arg1, arg2) {
|
|
2625
2776
|
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
2626
2777
|
return addHeapObject(ret);
|
|
@@ -2663,15 +2814,15 @@ function __wbg_get_imports() {
|
|
|
2663
2814
|
console.warn(...getObject(arg0));
|
|
2664
2815
|
},
|
|
2665
2816
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
2666
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2817
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8927);
|
|
2667
2818
|
return addHeapObject(ret);
|
|
2668
2819
|
},
|
|
2669
2820
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
2670
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2821
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12488);
|
|
2671
2822
|
return addHeapObject(ret);
|
|
2672
2823
|
},
|
|
2673
2824
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
2674
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2825
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8761);
|
|
2675
2826
|
return addHeapObject(ret);
|
|
2676
2827
|
},
|
|
2677
2828
|
__wbindgen_generic_0000000000000004: function(arg0) {
|
|
@@ -2707,19 +2858,19 @@ function __wbg_get_imports() {
|
|
|
2707
2858
|
"./cedarling_wasm_bg.js": import0
|
|
2708
2859
|
};
|
|
2709
2860
|
}
|
|
2710
|
-
function
|
|
2711
|
-
wasm.
|
|
2861
|
+
function __wasm_bindgen_func_elem_8761(arg0, arg1) {
|
|
2862
|
+
wasm.__wasm_bindgen_func_elem_8761(arg0, arg1);
|
|
2712
2863
|
}
|
|
2713
|
-
function
|
|
2714
|
-
wasm.
|
|
2864
|
+
function __wasm_bindgen_func_elem_12488(arg0, arg1, arg2) {
|
|
2865
|
+
wasm.__wasm_bindgen_func_elem_12488(arg0, arg1, addHeapObject(arg2));
|
|
2715
2866
|
}
|
|
2716
|
-
function
|
|
2717
|
-
wasm.
|
|
2867
|
+
function __wasm_bindgen_func_elem_8982(arg0, arg1, arg2, arg3) {
|
|
2868
|
+
wasm.__wasm_bindgen_func_elem_8982(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
2718
2869
|
}
|
|
2719
|
-
function
|
|
2870
|
+
function __wasm_bindgen_func_elem_8927(arg0, arg1, arg2) {
|
|
2720
2871
|
try {
|
|
2721
2872
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2722
|
-
wasm.
|
|
2873
|
+
wasm.__wasm_bindgen_func_elem_8927(retptr, arg0, arg1, addHeapObject(arg2));
|
|
2723
2874
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2724
2875
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2725
2876
|
if (r1) {
|
|
@@ -2777,6 +2928,9 @@ var IntoUnderlyingSinkFinalization = typeof FinalizationRegistry === "undefined"
|
|
|
2777
2928
|
var IntoUnderlyingSourceFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
2778
2929
|
}, unregister: () => {
|
|
2779
2930
|
} } : new FinalizationRegistry((ptr) => wasm.__wbg_intounderlyingsource_free(ptr, 1));
|
|
2931
|
+
var MetricsSnapshotFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
2932
|
+
}, unregister: () => {
|
|
2933
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_metricssnapshot_free(ptr, 1));
|
|
2780
2934
|
var MultiIssuerAuthorizeResultFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
2781
2935
|
}, unregister: () => {
|
|
2782
2936
|
} } : new FinalizationRegistry((ptr) => wasm.__wbg_multiissuerauthorizeresult_free(ptr, 1));
|