@janssenproject/cedarling_wasm 0.0.466-nodejs → 0.0.467-nodejs
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 +23 -553
- package/cedarling_wasm.d.ts +240 -86
- package/cedarling_wasm.js +286 -132
- package/cedarling_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/cedarling_wasm.js
CHANGED
|
@@ -25,12 +25,12 @@ class AuthorizeResult {
|
|
|
25
25
|
* Convert `AuthorizeResult` to json string value
|
|
26
26
|
* @returns {string}
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
jsonString() {
|
|
29
29
|
let deferred1_0;
|
|
30
30
|
let deferred1_1;
|
|
31
31
|
try {
|
|
32
32
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
33
|
-
wasm.
|
|
33
|
+
wasm.authorizeresult_jsonString(retptr, this.__wbg_ptr);
|
|
34
34
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
35
35
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
36
36
|
deferred1_0 = r0;
|
|
@@ -513,21 +513,24 @@ class Cedarling {
|
|
|
513
513
|
* # Example
|
|
514
514
|
*
|
|
515
515
|
* ```javascript
|
|
516
|
-
* const redirects = cedarling.
|
|
516
|
+
* const redirects = cedarling.annotationValues(
|
|
517
|
+
* result.response.diagnostics.reason,
|
|
518
|
+
* "redirect",
|
|
519
|
+
* );
|
|
517
520
|
* // ["/upgrade"]
|
|
518
521
|
* ```
|
|
519
522
|
* @param {string[]} policy_ids
|
|
520
523
|
* @param {string} key
|
|
521
524
|
* @returns {string[]}
|
|
522
525
|
*/
|
|
523
|
-
|
|
526
|
+
annotationValues(policy_ids, key) {
|
|
524
527
|
try {
|
|
525
528
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
526
529
|
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
527
530
|
const len0 = WASM_VECTOR_LEN;
|
|
528
531
|
const ptr1 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
529
532
|
const len1 = WASM_VECTOR_LEN;
|
|
530
|
-
wasm.
|
|
533
|
+
wasm.cedarling_annotationValues(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
531
534
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
532
535
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
533
536
|
var v3 = getArrayJsValueFromWasm0(r0, r1);
|
|
@@ -538,8 +541,8 @@ class Cedarling {
|
|
|
538
541
|
}
|
|
539
542
|
}
|
|
540
543
|
/**
|
|
541
|
-
* Return the annotations of each given policy, grouped by policy ID
|
|
542
|
-
* the loss-free companion to `
|
|
544
|
+
* Return the annotations of each given policy, grouped by policy ID. It is
|
|
545
|
+
* the loss-free companion to `annotationsMap`. Unknown policy IDs are
|
|
543
546
|
* silently skipped.
|
|
544
547
|
*
|
|
545
548
|
* # Arguments
|
|
@@ -551,18 +554,18 @@ class Cedarling {
|
|
|
551
554
|
* # Example
|
|
552
555
|
*
|
|
553
556
|
* ```javascript
|
|
554
|
-
* const byPolicy = cedarling.
|
|
557
|
+
* const byPolicy = cedarling.annotationsByPolicy(result.response.diagnostics.reason);
|
|
555
558
|
* // { "5": { redirect: "/upgrade", tier: "premium" } }
|
|
556
559
|
* ```
|
|
557
560
|
* @param {string[]} policy_ids
|
|
558
561
|
* @returns {any}
|
|
559
562
|
*/
|
|
560
|
-
|
|
563
|
+
annotationsByPolicy(policy_ids) {
|
|
561
564
|
try {
|
|
562
565
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
563
566
|
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
564
567
|
const len0 = WASM_VECTOR_LEN;
|
|
565
|
-
wasm.
|
|
568
|
+
wasm.cedarling_annotationsByPolicy(retptr, this.__wbg_ptr, ptr0, len0);
|
|
566
569
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
567
570
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
568
571
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -581,7 +584,7 @@ class Cedarling {
|
|
|
581
584
|
* pass `result.response.diagnostics.reason`.
|
|
582
585
|
*
|
|
583
586
|
* Lossy: if the same annotation key appears on several policies, one value wins
|
|
584
|
-
* arbitrarily. Use `
|
|
587
|
+
* arbitrarily. Use `annotationValues` / `annotationsByPolicy` when duplicates
|
|
585
588
|
* matter. Unknown policy IDs are silently skipped.
|
|
586
589
|
*
|
|
587
590
|
* # Arguments
|
|
@@ -593,18 +596,18 @@ class Cedarling {
|
|
|
593
596
|
* # Example
|
|
594
597
|
*
|
|
595
598
|
* ```javascript
|
|
596
|
-
* const annotations = cedarling.
|
|
599
|
+
* const annotations = cedarling.annotationsMap(result.response.diagnostics.reason);
|
|
597
600
|
* // { redirect: "/upgrade", tier: "premium" }
|
|
598
601
|
* ```
|
|
599
602
|
* @param {string[]} policy_ids
|
|
600
603
|
* @returns {any}
|
|
601
604
|
*/
|
|
602
|
-
|
|
605
|
+
annotationsMap(policy_ids) {
|
|
603
606
|
try {
|
|
604
607
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
605
608
|
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
606
609
|
const len0 = WASM_VECTOR_LEN;
|
|
607
|
-
wasm.
|
|
610
|
+
wasm.cedarling_annotationsMap(retptr, this.__wbg_ptr, ptr0, len0);
|
|
608
611
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
609
612
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
610
613
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -627,15 +630,15 @@ class Cedarling {
|
|
|
627
630
|
* # Example
|
|
628
631
|
*
|
|
629
632
|
* ```javascript
|
|
630
|
-
* const result = await cedarling.
|
|
633
|
+
* const result = await cedarling.authorizeMultiIssuer(JSON.stringify(request));
|
|
631
634
|
* ```
|
|
632
635
|
* @param {string} request
|
|
633
636
|
* @returns {Promise<MultiIssuerAuthorizeResult>}
|
|
634
637
|
*/
|
|
635
|
-
|
|
638
|
+
authorizeMultiIssuer(request) {
|
|
636
639
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
637
640
|
const len0 = WASM_VECTOR_LEN;
|
|
638
|
-
const ret = wasm.
|
|
641
|
+
const ret = wasm.cedarling_authorizeMultiIssuer(this.__wbg_ptr, ptr0, len0);
|
|
639
642
|
return takeObject(ret);
|
|
640
643
|
}
|
|
641
644
|
/**
|
|
@@ -655,15 +658,15 @@ class Cedarling {
|
|
|
655
658
|
* # Example
|
|
656
659
|
*
|
|
657
660
|
* ```javascript
|
|
658
|
-
* const result = await cedarling.
|
|
661
|
+
* const result = await cedarling.authorizeMultiIssuerBatch(JSON.stringify(batchRequest));
|
|
659
662
|
* ```
|
|
660
663
|
* @param {string} request
|
|
661
664
|
* @returns {Promise<BatchAuthorizeMultiIssuerResponse>}
|
|
662
665
|
*/
|
|
663
|
-
|
|
666
|
+
authorizeMultiIssuerBatch(request) {
|
|
664
667
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
665
668
|
const len0 = WASM_VECTOR_LEN;
|
|
666
|
-
const ret = wasm.
|
|
669
|
+
const ret = wasm.cedarling_authorizeMultiIssuerBatch(this.__wbg_ptr, ptr0, len0);
|
|
667
670
|
return takeObject(ret);
|
|
668
671
|
}
|
|
669
672
|
/**
|
|
@@ -682,15 +685,15 @@ class Cedarling {
|
|
|
682
685
|
* # Example
|
|
683
686
|
*
|
|
684
687
|
* ```javascript
|
|
685
|
-
* const result = await cedarling.
|
|
688
|
+
* const result = await cedarling.authorizeUnsigned(JSON.stringify(request));
|
|
686
689
|
* ```
|
|
687
690
|
* @param {string} request
|
|
688
691
|
* @returns {Promise<AuthorizeResult>}
|
|
689
692
|
*/
|
|
690
|
-
|
|
693
|
+
authorizeUnsigned(request) {
|
|
691
694
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
692
695
|
const len0 = WASM_VECTOR_LEN;
|
|
693
|
-
const ret = wasm.
|
|
696
|
+
const ret = wasm.cedarling_authorizeUnsigned(this.__wbg_ptr, ptr0, len0);
|
|
694
697
|
return takeObject(ret);
|
|
695
698
|
}
|
|
696
699
|
/**
|
|
@@ -710,31 +713,35 @@ class Cedarling {
|
|
|
710
713
|
* # Example
|
|
711
714
|
*
|
|
712
715
|
* ```javascript
|
|
713
|
-
* const result = await cedarling.
|
|
716
|
+
* const result = await cedarling.authorizeUnsignedBatch(JSON.stringify(batchRequest));
|
|
714
717
|
* ```
|
|
715
718
|
* @param {string} request
|
|
716
719
|
* @returns {Promise<BatchAuthorizeUnsignedResponse>}
|
|
717
720
|
*/
|
|
718
|
-
|
|
721
|
+
authorizeUnsignedBatch(request) {
|
|
719
722
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
720
723
|
const len0 = WASM_VECTOR_LEN;
|
|
721
|
-
const ret = wasm.
|
|
724
|
+
const ret = wasm.cedarling_authorizeUnsignedBatch(this.__wbg_ptr, ptr0, len0);
|
|
722
725
|
return takeObject(ret);
|
|
723
726
|
}
|
|
724
727
|
/**
|
|
725
728
|
* Clear all entries from the data store.
|
|
726
729
|
*
|
|
730
|
+
* # Arguments
|
|
731
|
+
*
|
|
732
|
+
* None.
|
|
733
|
+
*
|
|
727
734
|
* # Example
|
|
728
735
|
*
|
|
729
736
|
* ```javascript
|
|
730
|
-
* cedarling.
|
|
737
|
+
* cedarling.clearDataCtx();
|
|
731
738
|
* console.log("All data entries cleared");
|
|
732
739
|
* ```
|
|
733
740
|
*/
|
|
734
|
-
|
|
741
|
+
clearDataCtx() {
|
|
735
742
|
try {
|
|
736
743
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
737
|
-
wasm.
|
|
744
|
+
wasm.cedarling_clearDataCtx(retptr, this.__wbg_ptr);
|
|
738
745
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
739
746
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
740
747
|
if (r1) {
|
|
@@ -747,15 +754,19 @@ class Cedarling {
|
|
|
747
754
|
/**
|
|
748
755
|
* Get trusted issuer identifiers that failed to load.
|
|
749
756
|
*
|
|
757
|
+
* # Arguments
|
|
758
|
+
*
|
|
759
|
+
* None.
|
|
760
|
+
*
|
|
750
761
|
* # Example
|
|
751
762
|
*
|
|
752
763
|
* ```javascript
|
|
753
|
-
* const ids = cedarling.
|
|
764
|
+
* const ids = cedarling.failedTrustedIssuerIds();
|
|
754
765
|
* ```
|
|
755
766
|
* @returns {Array<any>}
|
|
756
767
|
*/
|
|
757
|
-
|
|
758
|
-
const ret = wasm.
|
|
768
|
+
failedTrustedIssuerIds() {
|
|
769
|
+
const ret = wasm.cedarling_failedTrustedIssuerIds(this.__wbg_ptr);
|
|
759
770
|
return takeObject(ret);
|
|
760
771
|
}
|
|
761
772
|
/**
|
|
@@ -769,7 +780,7 @@ class Cedarling {
|
|
|
769
780
|
* # Example
|
|
770
781
|
*
|
|
771
782
|
* ```javascript
|
|
772
|
-
* const value = cedarling.
|
|
783
|
+
* const value = cedarling.getDataCtx("user:123");
|
|
773
784
|
* if (value !== null) {
|
|
774
785
|
* console.log(value.name); // "John"
|
|
775
786
|
* }
|
|
@@ -777,12 +788,12 @@ class Cedarling {
|
|
|
777
788
|
* @param {string} key
|
|
778
789
|
* @returns {any}
|
|
779
790
|
*/
|
|
780
|
-
|
|
791
|
+
getDataCtx(key) {
|
|
781
792
|
try {
|
|
782
793
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
783
794
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
784
795
|
const len0 = WASM_VECTOR_LEN;
|
|
785
|
-
wasm.
|
|
796
|
+
wasm.cedarling_getDataCtx(retptr, this.__wbg_ptr, ptr0, len0);
|
|
786
797
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
787
798
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
788
799
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -796,7 +807,7 @@ class Cedarling {
|
|
|
796
807
|
}
|
|
797
808
|
/**
|
|
798
809
|
* Get a data entry with full metadata by key.
|
|
799
|
-
* Returns
|
|
810
|
+
* Returns undefined if the key doesn't exist or the entry has expired.
|
|
800
811
|
*
|
|
801
812
|
* # Arguments
|
|
802
813
|
*
|
|
@@ -805,10 +816,10 @@ class Cedarling {
|
|
|
805
816
|
* # Example
|
|
806
817
|
*
|
|
807
818
|
* ```javascript
|
|
808
|
-
* const entry = cedarling.
|
|
809
|
-
* if (entry !==
|
|
819
|
+
* const entry = cedarling.getDataEntryCtx("user:123");
|
|
820
|
+
* if (entry !== undefined) {
|
|
810
821
|
* console.log(entry.key); // "user:123"
|
|
811
|
-
* console.log(entry.value); // { name: "John", age: 30 }
|
|
822
|
+
* console.log(entry.value()); // { name: "John", age: 30 }
|
|
812
823
|
* console.log(entry.data_type); // "Record"
|
|
813
824
|
* console.log(entry.created_at); // "2024-01-01T12:00:00Z"
|
|
814
825
|
* console.log(entry.access_count); // 5
|
|
@@ -817,12 +828,12 @@ class Cedarling {
|
|
|
817
828
|
* @param {string} key
|
|
818
829
|
* @returns {DataEntry | undefined}
|
|
819
830
|
*/
|
|
820
|
-
|
|
831
|
+
getDataEntryCtx(key) {
|
|
821
832
|
try {
|
|
822
833
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
823
834
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
824
835
|
const len0 = WASM_VECTOR_LEN;
|
|
825
|
-
wasm.
|
|
836
|
+
wasm.cedarling_getDataEntryCtx(retptr, this.__wbg_ptr, ptr0, len0);
|
|
826
837
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
827
838
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
828
839
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -835,17 +846,26 @@ class Cedarling {
|
|
|
835
846
|
}
|
|
836
847
|
}
|
|
837
848
|
/**
|
|
838
|
-
*
|
|
839
|
-
*
|
|
849
|
+
* Returns one retained memory log by ID, or `null` when it is not retained.
|
|
850
|
+
*
|
|
851
|
+
* # Arguments
|
|
852
|
+
*
|
|
853
|
+
* * `id` - The retained log identifier.
|
|
854
|
+
*
|
|
855
|
+
* # Example
|
|
856
|
+
*
|
|
857
|
+
* ```javascript
|
|
858
|
+
* const log = cedarling.getLogById("request-id");
|
|
859
|
+
* ```
|
|
840
860
|
* @param {string} id
|
|
841
861
|
* @returns {any}
|
|
842
862
|
*/
|
|
843
|
-
|
|
863
|
+
getLogById(id) {
|
|
844
864
|
try {
|
|
845
865
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
846
866
|
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
847
867
|
const len0 = WASM_VECTOR_LEN;
|
|
848
|
-
wasm.
|
|
868
|
+
wasm.cedarling_getLogById(retptr, this.__wbg_ptr, ptr0, len0);
|
|
849
869
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
850
870
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
851
871
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -858,26 +878,44 @@ class Cedarling {
|
|
|
858
878
|
}
|
|
859
879
|
}
|
|
860
880
|
/**
|
|
861
|
-
* Returns
|
|
862
|
-
*
|
|
881
|
+
* Returns identifiers for all retained memory logs.
|
|
882
|
+
*
|
|
883
|
+
* # Arguments
|
|
884
|
+
*
|
|
885
|
+
* None.
|
|
886
|
+
*
|
|
887
|
+
* # Example
|
|
888
|
+
*
|
|
889
|
+
* ```javascript
|
|
890
|
+
* const ids = cedarling.getLogIds();
|
|
891
|
+
* ```
|
|
863
892
|
* @returns {Array<any>}
|
|
864
893
|
*/
|
|
865
|
-
|
|
866
|
-
const ret = wasm.
|
|
894
|
+
getLogIds() {
|
|
895
|
+
const ret = wasm.cedarling_getLogIds(this.__wbg_ptr);
|
|
867
896
|
return takeObject(ret);
|
|
868
897
|
}
|
|
869
898
|
/**
|
|
870
|
-
*
|
|
871
|
-
*
|
|
899
|
+
* Returns retained memory logs for one request ID.
|
|
900
|
+
*
|
|
901
|
+
* # Arguments
|
|
902
|
+
*
|
|
903
|
+
* * `requestId` - The request identifier to match.
|
|
904
|
+
*
|
|
905
|
+
* # Example
|
|
906
|
+
*
|
|
907
|
+
* ```javascript
|
|
908
|
+
* const logs = cedarling.getLogsByRequestId("request-id");
|
|
909
|
+
* ```
|
|
872
910
|
* @param {string} request_id
|
|
873
911
|
* @returns {any[]}
|
|
874
912
|
*/
|
|
875
|
-
|
|
913
|
+
getLogsByRequestId(request_id) {
|
|
876
914
|
try {
|
|
877
915
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
878
916
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
879
917
|
const len0 = WASM_VECTOR_LEN;
|
|
880
|
-
wasm.
|
|
918
|
+
wasm.cedarling_getLogsByRequestId(retptr, this.__wbg_ptr, ptr0, len0);
|
|
881
919
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
882
920
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
883
921
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -893,21 +931,31 @@ class Cedarling {
|
|
|
893
931
|
}
|
|
894
932
|
}
|
|
895
933
|
/**
|
|
896
|
-
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
934
|
+
* Returns retained memory logs matching one request ID and indexed value.
|
|
935
|
+
*
|
|
936
|
+
* # Arguments
|
|
937
|
+
*
|
|
938
|
+
* * `requestId` - The request identifier to match.
|
|
939
|
+
* * `tag` - A log kind (`"System"`, `"Decision"`, or `"Metric"`) or a
|
|
940
|
+
* system-log level such as `"DEBUG"`.
|
|
941
|
+
*
|
|
942
|
+
* # Example
|
|
943
|
+
*
|
|
944
|
+
* ```javascript
|
|
945
|
+
* const logs = cedarling.getLogsByRequestIdAndTag("request-id", "System");
|
|
946
|
+
* ```
|
|
899
947
|
* @param {string} request_id
|
|
900
948
|
* @param {string} tag
|
|
901
949
|
* @returns {any[]}
|
|
902
950
|
*/
|
|
903
|
-
|
|
951
|
+
getLogsByRequestIdAndTag(request_id, tag) {
|
|
904
952
|
try {
|
|
905
953
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
906
954
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
907
955
|
const len0 = WASM_VECTOR_LEN;
|
|
908
956
|
const ptr1 = passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
909
957
|
const len1 = WASM_VECTOR_LEN;
|
|
910
|
-
wasm.
|
|
958
|
+
wasm.cedarling_getLogsByRequestIdAndTag(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
911
959
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
912
960
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
913
961
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -923,17 +971,27 @@ class Cedarling {
|
|
|
923
971
|
}
|
|
924
972
|
}
|
|
925
973
|
/**
|
|
926
|
-
*
|
|
927
|
-
*
|
|
974
|
+
* Returns retained memory logs matching an indexed value.
|
|
975
|
+
*
|
|
976
|
+
* # Arguments
|
|
977
|
+
*
|
|
978
|
+
* * `tag` - A log kind (`"System"`, `"Decision"`, or `"Metric"`) or a
|
|
979
|
+
* system-log level such as `"DEBUG"`.
|
|
980
|
+
*
|
|
981
|
+
* # Example
|
|
982
|
+
*
|
|
983
|
+
* ```javascript
|
|
984
|
+
* const logs = cedarling.getLogsByTag("System");
|
|
985
|
+
* ```
|
|
928
986
|
* @param {string} tag
|
|
929
987
|
* @returns {any[]}
|
|
930
988
|
*/
|
|
931
|
-
|
|
989
|
+
getLogsByTag(tag) {
|
|
932
990
|
try {
|
|
933
991
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
934
992
|
const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
935
993
|
const len0 = WASM_VECTOR_LEN;
|
|
936
|
-
wasm.
|
|
994
|
+
wasm.cedarling_getLogsByTag(retptr, this.__wbg_ptr, ptr0, len0);
|
|
937
995
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
938
996
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
939
997
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -951,20 +1009,24 @@ class Cedarling {
|
|
|
951
1009
|
/**
|
|
952
1010
|
* Get statistics about the data store.
|
|
953
1011
|
*
|
|
1012
|
+
* # Arguments
|
|
1013
|
+
*
|
|
1014
|
+
* None.
|
|
1015
|
+
*
|
|
954
1016
|
* # Example
|
|
955
1017
|
*
|
|
956
1018
|
* ```javascript
|
|
957
|
-
* const stats = cedarling.
|
|
1019
|
+
* const stats = cedarling.getStatsCtx();
|
|
958
1020
|
* console.log(`Entries: ${stats.entry_count}/${stats.max_entries || 'unlimited'}`);
|
|
959
1021
|
* console.log(`Capacity: ${stats.capacity_usage_percent.toFixed(2)}%`);
|
|
960
1022
|
* console.log(`Total size: ${stats.total_size_bytes} bytes`);
|
|
961
1023
|
* ```
|
|
962
1024
|
* @returns {DataStoreStats}
|
|
963
1025
|
*/
|
|
964
|
-
|
|
1026
|
+
getStatsCtx() {
|
|
965
1027
|
try {
|
|
966
1028
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
967
|
-
wasm.
|
|
1029
|
+
wasm.cedarling_getStatsCtx(retptr, this.__wbg_ptr);
|
|
968
1030
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
969
1031
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
970
1032
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -986,15 +1048,15 @@ class Cedarling {
|
|
|
986
1048
|
* # Example
|
|
987
1049
|
*
|
|
988
1050
|
* ```javascript
|
|
989
|
-
* const ok = cedarling.
|
|
1051
|
+
* const ok = cedarling.isTrustedIssuerLoadedByIss("https://issuer.example.org");
|
|
990
1052
|
* ```
|
|
991
1053
|
* @param {string} iss_claim
|
|
992
1054
|
* @returns {boolean}
|
|
993
1055
|
*/
|
|
994
|
-
|
|
1056
|
+
isTrustedIssuerLoadedByIss(iss_claim) {
|
|
995
1057
|
const ptr0 = passStringToWasm0(iss_claim, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
996
1058
|
const len0 = WASM_VECTOR_LEN;
|
|
997
|
-
const ret = wasm.
|
|
1059
|
+
const ret = wasm.cedarling_isTrustedIssuerLoadedByIss(this.__wbg_ptr, ptr0, len0);
|
|
998
1060
|
return ret !== 0;
|
|
999
1061
|
}
|
|
1000
1062
|
/**
|
|
@@ -1007,35 +1069,39 @@ class Cedarling {
|
|
|
1007
1069
|
* # Example
|
|
1008
1070
|
*
|
|
1009
1071
|
* ```javascript
|
|
1010
|
-
* const ok = cedarling.
|
|
1072
|
+
* const ok = cedarling.isTrustedIssuerLoadedByName("issuer_id");
|
|
1011
1073
|
* ```
|
|
1012
1074
|
* @param {string} issuer_id
|
|
1013
1075
|
* @returns {boolean}
|
|
1014
1076
|
*/
|
|
1015
|
-
|
|
1077
|
+
isTrustedIssuerLoadedByName(issuer_id) {
|
|
1016
1078
|
const ptr0 = passStringToWasm0(issuer_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1017
1079
|
const len0 = WASM_VECTOR_LEN;
|
|
1018
|
-
const ret = wasm.
|
|
1080
|
+
const ret = wasm.cedarling_isTrustedIssuerLoadedByName(this.__wbg_ptr, ptr0, len0);
|
|
1019
1081
|
return ret !== 0;
|
|
1020
1082
|
}
|
|
1021
1083
|
/**
|
|
1022
1084
|
* List all entries with their metadata.
|
|
1023
1085
|
* Returns an array of DataEntry objects.
|
|
1024
1086
|
*
|
|
1087
|
+
* # Arguments
|
|
1088
|
+
*
|
|
1089
|
+
* None.
|
|
1090
|
+
*
|
|
1025
1091
|
* # Example
|
|
1026
1092
|
*
|
|
1027
1093
|
* ```javascript
|
|
1028
|
-
* const entries = cedarling.
|
|
1094
|
+
* const entries = cedarling.listDataCtx();
|
|
1029
1095
|
* entries.forEach(entry => {
|
|
1030
1096
|
* console.log(`${entry.key}: ${entry.data_type} (accessed ${entry.access_count} times)`);
|
|
1031
1097
|
* });
|
|
1032
1098
|
* ```
|
|
1033
1099
|
* @returns {Array<any>}
|
|
1034
1100
|
*/
|
|
1035
|
-
|
|
1101
|
+
listDataCtx() {
|
|
1036
1102
|
try {
|
|
1037
1103
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1038
|
-
wasm.
|
|
1104
|
+
wasm.cedarling_listDataCtx(retptr, this.__wbg_ptr);
|
|
1039
1105
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1040
1106
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1041
1107
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1050,34 +1116,57 @@ class Cedarling {
|
|
|
1050
1116
|
/**
|
|
1051
1117
|
* Get trusted issuer identifiers loaded successfully.
|
|
1052
1118
|
*
|
|
1119
|
+
* # Arguments
|
|
1120
|
+
*
|
|
1121
|
+
* None.
|
|
1122
|
+
*
|
|
1053
1123
|
* # Example
|
|
1054
1124
|
*
|
|
1055
1125
|
* ```javascript
|
|
1056
|
-
* const ids = cedarling.
|
|
1126
|
+
* const ids = cedarling.loadedTrustedIssuerIds();
|
|
1057
1127
|
* ```
|
|
1058
1128
|
* @returns {Array<any>}
|
|
1059
1129
|
*/
|
|
1060
|
-
|
|
1061
|
-
const ret = wasm.
|
|
1130
|
+
loadedTrustedIssuerIds() {
|
|
1131
|
+
const ret = wasm.cedarling_loadedTrustedIssuerIds(this.__wbg_ptr);
|
|
1062
1132
|
return takeObject(ret);
|
|
1063
1133
|
}
|
|
1064
1134
|
/**
|
|
1065
1135
|
* Get the number of trusted issuers loaded successfully.
|
|
1066
1136
|
*
|
|
1137
|
+
* # Arguments
|
|
1138
|
+
*
|
|
1139
|
+
* None.
|
|
1140
|
+
*
|
|
1067
1141
|
* # Example
|
|
1068
1142
|
*
|
|
1069
1143
|
* ```javascript
|
|
1070
|
-
* const loadedCount = cedarling.
|
|
1144
|
+
* const loadedCount = cedarling.loadedTrustedIssuersCount();
|
|
1071
1145
|
* ```
|
|
1072
1146
|
* @returns {number}
|
|
1073
1147
|
*/
|
|
1074
|
-
|
|
1075
|
-
const ret = wasm.
|
|
1148
|
+
loadedTrustedIssuersCount() {
|
|
1149
|
+
const ret = wasm.cedarling_loadedTrustedIssuersCount(this.__wbg_ptr);
|
|
1076
1150
|
return ret >>> 0;
|
|
1077
1151
|
}
|
|
1078
1152
|
/**
|
|
1079
|
-
*
|
|
1080
|
-
*
|
|
1153
|
+
* Creates a Cedarling application from bootstrap properties.
|
|
1154
|
+
*
|
|
1155
|
+
* # Arguments
|
|
1156
|
+
*
|
|
1157
|
+
* * `config` - A plain object of Cedarling bootstrap-property names and values.
|
|
1158
|
+
*
|
|
1159
|
+
* # Example
|
|
1160
|
+
*
|
|
1161
|
+
* ```javascript
|
|
1162
|
+
* await initWasm();
|
|
1163
|
+
* const cedarling = await Cedarling.new({
|
|
1164
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
1165
|
+
* CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
|
|
1166
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
1167
|
+
* CEDARLING_LOG_TTL: 120,
|
|
1168
|
+
* });
|
|
1169
|
+
* ```
|
|
1081
1170
|
* @param {object} config
|
|
1082
1171
|
* @returns {Promise<Cedarling>}
|
|
1083
1172
|
*/
|
|
@@ -1086,24 +1175,49 @@ class Cedarling {
|
|
|
1086
1175
|
return takeObject(ret);
|
|
1087
1176
|
}
|
|
1088
1177
|
/**
|
|
1089
|
-
*
|
|
1090
|
-
*
|
|
1178
|
+
* Creates a new Cedarling application from a JavaScript `Map`.
|
|
1179
|
+
*
|
|
1180
|
+
* # Arguments
|
|
1181
|
+
*
|
|
1182
|
+
* * `config` - A `Map` of Cedarling bootstrap-property names and values.
|
|
1183
|
+
*
|
|
1184
|
+
* # Example
|
|
1185
|
+
*
|
|
1186
|
+
* ```javascript
|
|
1187
|
+
* await initWasm();
|
|
1188
|
+
* const cedarling = await Cedarling.newFromMap(new Map([
|
|
1189
|
+
* ["CEDARLING_APPLICATION_NAME", "task-api"],
|
|
1190
|
+
* ["CEDARLING_POLICY_STORE_URI", "https://example.com/policy-store.cjar"],
|
|
1191
|
+
* ["CEDARLING_LOG_TYPE", "memory"],
|
|
1192
|
+
* ["CEDARLING_LOG_TTL", 120],
|
|
1193
|
+
* ]));
|
|
1194
|
+
* ```
|
|
1091
1195
|
* @param {Map<any, any>} config
|
|
1092
1196
|
* @returns {Promise<Cedarling>}
|
|
1093
1197
|
*/
|
|
1094
|
-
static
|
|
1095
|
-
const ret = wasm.
|
|
1198
|
+
static newFromMap(config) {
|
|
1199
|
+
const ret = wasm.cedarling_newFromMap(addHeapObject(config));
|
|
1096
1200
|
return takeObject(ret);
|
|
1097
1201
|
}
|
|
1098
1202
|
/**
|
|
1099
|
-
*
|
|
1100
|
-
*
|
|
1203
|
+
* Returns all retained memory logs and removes them from storage.
|
|
1204
|
+
* Other log configurations return an empty array.
|
|
1205
|
+
*
|
|
1206
|
+
* # Arguments
|
|
1207
|
+
*
|
|
1208
|
+
* None.
|
|
1209
|
+
*
|
|
1210
|
+
* # Example
|
|
1211
|
+
*
|
|
1212
|
+
* ```javascript
|
|
1213
|
+
* const logs = cedarling.popLogs();
|
|
1214
|
+
* ```
|
|
1101
1215
|
* @returns {Array<any>}
|
|
1102
1216
|
*/
|
|
1103
|
-
|
|
1217
|
+
popLogs() {
|
|
1104
1218
|
try {
|
|
1105
1219
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1106
|
-
wasm.
|
|
1220
|
+
wasm.cedarling_popLogs(retptr, this.__wbg_ptr);
|
|
1107
1221
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1108
1222
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1109
1223
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1129,19 +1243,19 @@ class Cedarling {
|
|
|
1129
1243
|
* # Example
|
|
1130
1244
|
*
|
|
1131
1245
|
* ```javascript
|
|
1132
|
-
* cedarling.
|
|
1133
|
-
* cedarling.
|
|
1246
|
+
* cedarling.pushDataCtx("user:123", { name: "John", age: 30 }, 3600);
|
|
1247
|
+
* cedarling.pushDataCtx("config", { setting: "value" }); // Uses default TTL
|
|
1134
1248
|
* ```
|
|
1135
1249
|
* @param {string} key
|
|
1136
1250
|
* @param {any} value
|
|
1137
1251
|
* @param {bigint | null} [ttl_secs]
|
|
1138
1252
|
*/
|
|
1139
|
-
|
|
1253
|
+
pushDataCtx(key, value, ttl_secs) {
|
|
1140
1254
|
try {
|
|
1141
1255
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1142
1256
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1143
1257
|
const len0 = WASM_VECTOR_LEN;
|
|
1144
|
-
wasm.
|
|
1258
|
+
wasm.cedarling_pushDataCtx(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value), !isLikeNone(ttl_secs), isLikeNone(ttl_secs) ? BigInt(0) : ttl_secs);
|
|
1145
1259
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1146
1260
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1147
1261
|
if (r1) {
|
|
@@ -1162,7 +1276,7 @@ class Cedarling {
|
|
|
1162
1276
|
* # Example
|
|
1163
1277
|
*
|
|
1164
1278
|
* ```javascript
|
|
1165
|
-
* const removed = cedarling.
|
|
1279
|
+
* const removed = cedarling.removeDataCtx("user:123");
|
|
1166
1280
|
* if (removed) {
|
|
1167
1281
|
* console.log("Entry was successfully removed");
|
|
1168
1282
|
* }
|
|
@@ -1170,12 +1284,12 @@ class Cedarling {
|
|
|
1170
1284
|
* @param {string} key
|
|
1171
1285
|
* @returns {boolean}
|
|
1172
1286
|
*/
|
|
1173
|
-
|
|
1287
|
+
removeDataCtx(key) {
|
|
1174
1288
|
try {
|
|
1175
1289
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1176
1290
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1177
1291
|
const len0 = WASM_VECTOR_LEN;
|
|
1178
|
-
wasm.
|
|
1292
|
+
wasm.cedarling_removeDataCtx(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1179
1293
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1180
1294
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1181
1295
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1188,25 +1302,39 @@ class Cedarling {
|
|
|
1188
1302
|
}
|
|
1189
1303
|
}
|
|
1190
1304
|
/**
|
|
1191
|
-
* Closes
|
|
1305
|
+
* Closes Lock Server connections and pushes all available logs.
|
|
1306
|
+
*
|
|
1307
|
+
* # Arguments
|
|
1308
|
+
*
|
|
1309
|
+
* None.
|
|
1310
|
+
*
|
|
1311
|
+
* # Example
|
|
1312
|
+
*
|
|
1313
|
+
* ```javascript
|
|
1314
|
+
* await cedarling.shutDown();
|
|
1315
|
+
* ```
|
|
1192
1316
|
* @returns {Promise<void>}
|
|
1193
1317
|
*/
|
|
1194
|
-
|
|
1195
|
-
const ret = wasm.
|
|
1318
|
+
shutDown() {
|
|
1319
|
+
const ret = wasm.cedarling_shutDown(this.__wbg_ptr);
|
|
1196
1320
|
return takeObject(ret);
|
|
1197
1321
|
}
|
|
1198
1322
|
/**
|
|
1199
1323
|
* Get the total number of trusted issuer entries discovered.
|
|
1200
1324
|
*
|
|
1325
|
+
* # Arguments
|
|
1326
|
+
*
|
|
1327
|
+
* None.
|
|
1328
|
+
*
|
|
1201
1329
|
* # Example
|
|
1202
1330
|
*
|
|
1203
1331
|
* ```javascript
|
|
1204
|
-
* const total = cedarling.
|
|
1332
|
+
* const total = cedarling.totalIssuers();
|
|
1205
1333
|
* ```
|
|
1206
1334
|
* @returns {number}
|
|
1207
1335
|
*/
|
|
1208
|
-
|
|
1209
|
-
const ret = wasm.
|
|
1336
|
+
totalIssuers() {
|
|
1337
|
+
const ret = wasm.cedarling_totalIssuers(this.__wbg_ptr);
|
|
1210
1338
|
return ret >>> 0;
|
|
1211
1339
|
}
|
|
1212
1340
|
}
|
|
@@ -1238,12 +1366,12 @@ class DataEntry {
|
|
|
1238
1366
|
* Convert `DataEntry` to json string value
|
|
1239
1367
|
* @returns {string}
|
|
1240
1368
|
*/
|
|
1241
|
-
|
|
1369
|
+
jsonString() {
|
|
1242
1370
|
let deferred1_0;
|
|
1243
1371
|
let deferred1_1;
|
|
1244
1372
|
try {
|
|
1245
1373
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1246
|
-
wasm.
|
|
1374
|
+
wasm.dataentry_jsonString(retptr, this.__wbg_ptr);
|
|
1247
1375
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1248
1376
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1249
1377
|
deferred1_0 = r0;
|
|
@@ -1322,7 +1450,7 @@ class DataEntry {
|
|
|
1322
1450
|
}
|
|
1323
1451
|
}
|
|
1324
1452
|
/**
|
|
1325
|
-
* Timestamp when this entry expires (RFC 3339 format)
|
|
1453
|
+
* Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
|
|
1326
1454
|
* @returns {string | undefined}
|
|
1327
1455
|
*/
|
|
1328
1456
|
get expires_at() {
|
|
@@ -1387,7 +1515,7 @@ class DataEntry {
|
|
|
1387
1515
|
wasm.__wbg_set_dataentry_data_type(this.__wbg_ptr, ptr0, len0);
|
|
1388
1516
|
}
|
|
1389
1517
|
/**
|
|
1390
|
-
* Timestamp when this entry expires (RFC 3339 format)
|
|
1518
|
+
* Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
|
|
1391
1519
|
* @param {string | null} [arg0]
|
|
1392
1520
|
*/
|
|
1393
1521
|
set expires_at(arg0) {
|
|
@@ -1433,12 +1561,12 @@ class DataStoreStats {
|
|
|
1433
1561
|
* Convert `DataStoreStats` to json string value
|
|
1434
1562
|
* @returns {string}
|
|
1435
1563
|
*/
|
|
1436
|
-
|
|
1564
|
+
jsonString() {
|
|
1437
1565
|
let deferred1_0;
|
|
1438
1566
|
let deferred1_1;
|
|
1439
1567
|
try {
|
|
1440
1568
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1441
|
-
wasm.
|
|
1569
|
+
wasm.datastorestats_jsonString(retptr, this.__wbg_ptr);
|
|
1442
1570
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1443
1571
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1444
1572
|
deferred1_0 = r0;
|
|
@@ -1830,12 +1958,12 @@ class MultiIssuerAuthorizeResult {
|
|
|
1830
1958
|
* Convert `MultiIssuerAuthorizeResult` to json string value
|
|
1831
1959
|
* @returns {string}
|
|
1832
1960
|
*/
|
|
1833
|
-
|
|
1961
|
+
jsonString() {
|
|
1834
1962
|
let deferred1_0;
|
|
1835
1963
|
let deferred1_1;
|
|
1836
1964
|
try {
|
|
1837
1965
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1838
|
-
wasm.
|
|
1966
|
+
wasm.multiissuerauthorizeresult_jsonString(retptr, this.__wbg_ptr);
|
|
1839
1967
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1840
1968
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1841
1969
|
deferred1_0 = r0;
|
|
@@ -1945,8 +2073,24 @@ if (Symbol.dispose) PolicyEvaluationError.prototype[Symbol.dispose] = PolicyEval
|
|
|
1945
2073
|
exports.PolicyEvaluationError = PolicyEvaluationError;
|
|
1946
2074
|
|
|
1947
2075
|
/**
|
|
1948
|
-
*
|
|
1949
|
-
*
|
|
2076
|
+
* Creates a Cedarling application from bootstrap properties.
|
|
2077
|
+
*
|
|
2078
|
+
* # Arguments
|
|
2079
|
+
*
|
|
2080
|
+
* * `config` - A JavaScript `Map` or plain object of Cedarling
|
|
2081
|
+
* bootstrap-property names and values.
|
|
2082
|
+
*
|
|
2083
|
+
* # Example
|
|
2084
|
+
*
|
|
2085
|
+
* ```javascript
|
|
2086
|
+
* await initWasm();
|
|
2087
|
+
* const cedarling = await init({
|
|
2088
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
2089
|
+
* CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
|
|
2090
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
2091
|
+
* CEDARLING_LOG_TTL: 120,
|
|
2092
|
+
* });
|
|
2093
|
+
* ```
|
|
1950
2094
|
* @param {any} config
|
|
1951
2095
|
* @returns {Promise<Cedarling>}
|
|
1952
2096
|
*/
|
|
@@ -1963,24 +2107,34 @@ exports.init = init;
|
|
|
1963
2107
|
* that was fetched with custom logic (e.g., with authentication headers).
|
|
1964
2108
|
*
|
|
1965
2109
|
* # Arguments
|
|
1966
|
-
* * `config` - Bootstrap configuration (Map or Object)
|
|
2110
|
+
* * `config` - Bootstrap configuration (Map or Object) without a policy-store
|
|
2111
|
+
* source property. The archive bytes provide the policy store.
|
|
1967
2112
|
* * `archive_bytes` - The .cjar archive bytes (Uint8Array)
|
|
1968
2113
|
*
|
|
1969
2114
|
* # Example
|
|
1970
2115
|
* ```javascript
|
|
1971
|
-
*
|
|
1972
|
-
* const
|
|
1973
|
-
*
|
|
2116
|
+
* await initWasm();
|
|
2117
|
+
* const config = {
|
|
2118
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
2119
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
2120
|
+
* CEDARLING_LOG_TTL: 120,
|
|
2121
|
+
* };
|
|
2122
|
+
* const response = await fetch("https://example.com/policy-store.cjar", {
|
|
2123
|
+
* headers: { Authorization: "Bearer <token>" },
|
|
2124
|
+
* });
|
|
2125
|
+
* if (!response.ok) throw new Error("Unable to fetch policy store");
|
|
2126
|
+
* const archiveBytes = new Uint8Array(await response.arrayBuffer());
|
|
2127
|
+
* const cedarling = await initFromArchiveBytes(config, archiveBytes);
|
|
1974
2128
|
* ```
|
|
1975
2129
|
* @param {any} config
|
|
1976
2130
|
* @param {Uint8Array} archive_bytes
|
|
1977
2131
|
* @returns {Promise<Cedarling>}
|
|
1978
2132
|
*/
|
|
1979
|
-
function
|
|
1980
|
-
const ret = wasm.
|
|
2133
|
+
function initFromArchiveBytes(config, archive_bytes) {
|
|
2134
|
+
const ret = wasm.initFromArchiveBytes(addHeapObject(config), addHeapObject(archive_bytes));
|
|
1981
2135
|
return takeObject(ret);
|
|
1982
2136
|
}
|
|
1983
|
-
exports.
|
|
2137
|
+
exports.initFromArchiveBytes = initFromArchiveBytes;
|
|
1984
2138
|
function __wbg_get_imports() {
|
|
1985
2139
|
const import0 = {
|
|
1986
2140
|
__proto__: null,
|
|
@@ -2396,7 +2550,7 @@ function __wbg_get_imports() {
|
|
|
2396
2550
|
const a = state0.a;
|
|
2397
2551
|
state0.a = 0;
|
|
2398
2552
|
try {
|
|
2399
|
-
return
|
|
2553
|
+
return __wasm_bindgen_func_elem_8970(a, state0.b, arg0, arg1);
|
|
2400
2554
|
} finally {
|
|
2401
2555
|
state0.a = a;
|
|
2402
2556
|
}
|
|
@@ -2606,17 +2760,17 @@ function __wbg_get_imports() {
|
|
|
2606
2760
|
},
|
|
2607
2761
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
2608
2762
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1010, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
2609
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2763
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8904);
|
|
2610
2764
|
return addHeapObject(ret);
|
|
2611
2765
|
},
|
|
2612
2766
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
2613
2767
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1206, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2614
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2768
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12454);
|
|
2615
2769
|
return addHeapObject(ret);
|
|
2616
2770
|
},
|
|
2617
2771
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
2618
2772
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1003, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2619
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2773
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8739);
|
|
2620
2774
|
return addHeapObject(ret);
|
|
2621
2775
|
},
|
|
2622
2776
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
@@ -2658,18 +2812,18 @@ function __wbg_get_imports() {
|
|
|
2658
2812
|
};
|
|
2659
2813
|
}
|
|
2660
2814
|
|
|
2661
|
-
function
|
|
2662
|
-
wasm.
|
|
2815
|
+
function __wasm_bindgen_func_elem_8739(arg0, arg1) {
|
|
2816
|
+
wasm.__wasm_bindgen_func_elem_8739(arg0, arg1);
|
|
2663
2817
|
}
|
|
2664
2818
|
|
|
2665
|
-
function
|
|
2666
|
-
wasm.
|
|
2819
|
+
function __wasm_bindgen_func_elem_12454(arg0, arg1, arg2) {
|
|
2820
|
+
wasm.__wasm_bindgen_func_elem_12454(arg0, arg1, addHeapObject(arg2));
|
|
2667
2821
|
}
|
|
2668
2822
|
|
|
2669
|
-
function
|
|
2823
|
+
function __wasm_bindgen_func_elem_8904(arg0, arg1, arg2) {
|
|
2670
2824
|
try {
|
|
2671
2825
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2672
|
-
wasm.
|
|
2826
|
+
wasm.__wasm_bindgen_func_elem_8904(retptr, arg0, arg1, addHeapObject(arg2));
|
|
2673
2827
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2674
2828
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2675
2829
|
if (r1) {
|
|
@@ -2680,8 +2834,8 @@ function __wasm_bindgen_func_elem_8915(arg0, arg1, arg2) {
|
|
|
2680
2834
|
}
|
|
2681
2835
|
}
|
|
2682
2836
|
|
|
2683
|
-
function
|
|
2684
|
-
wasm.
|
|
2837
|
+
function __wasm_bindgen_func_elem_8970(arg0, arg1, arg2, arg3) {
|
|
2838
|
+
wasm.__wasm_bindgen_func_elem_8970(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
2685
2839
|
}
|
|
2686
2840
|
|
|
2687
2841
|
|