@janssenproject/cedarling_wasm 0.0.466 → 0.0.467
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 +277 -123
- package/cedarling_wasm.js +285 -131
- package/cedarling_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/cedarling_wasm.js
CHANGED
|
@@ -25,12 +25,12 @@ export 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;
|
|
@@ -506,21 +506,24 @@ export class Cedarling {
|
|
|
506
506
|
* # Example
|
|
507
507
|
*
|
|
508
508
|
* ```javascript
|
|
509
|
-
* const redirects = cedarling.
|
|
509
|
+
* const redirects = cedarling.annotationValues(
|
|
510
|
+
* result.response.diagnostics.reason,
|
|
511
|
+
* "redirect",
|
|
512
|
+
* );
|
|
510
513
|
* // ["/upgrade"]
|
|
511
514
|
* ```
|
|
512
515
|
* @param {string[]} policy_ids
|
|
513
516
|
* @param {string} key
|
|
514
517
|
* @returns {string[]}
|
|
515
518
|
*/
|
|
516
|
-
|
|
519
|
+
annotationValues(policy_ids, key) {
|
|
517
520
|
try {
|
|
518
521
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
519
522
|
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
520
523
|
const len0 = WASM_VECTOR_LEN;
|
|
521
524
|
const ptr1 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
522
525
|
const len1 = WASM_VECTOR_LEN;
|
|
523
|
-
wasm.
|
|
526
|
+
wasm.cedarling_annotationValues(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
524
527
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
525
528
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
526
529
|
var v3 = getArrayJsValueFromWasm0(r0, r1);
|
|
@@ -531,8 +534,8 @@ export class Cedarling {
|
|
|
531
534
|
}
|
|
532
535
|
}
|
|
533
536
|
/**
|
|
534
|
-
* Return the annotations of each given policy, grouped by policy ID
|
|
535
|
-
* the loss-free companion to `
|
|
537
|
+
* Return the annotations of each given policy, grouped by policy ID. It is
|
|
538
|
+
* the loss-free companion to `annotationsMap`. Unknown policy IDs are
|
|
536
539
|
* silently skipped.
|
|
537
540
|
*
|
|
538
541
|
* # Arguments
|
|
@@ -544,18 +547,18 @@ export class Cedarling {
|
|
|
544
547
|
* # Example
|
|
545
548
|
*
|
|
546
549
|
* ```javascript
|
|
547
|
-
* const byPolicy = cedarling.
|
|
550
|
+
* const byPolicy = cedarling.annotationsByPolicy(result.response.diagnostics.reason);
|
|
548
551
|
* // { "5": { redirect: "/upgrade", tier: "premium" } }
|
|
549
552
|
* ```
|
|
550
553
|
* @param {string[]} policy_ids
|
|
551
554
|
* @returns {any}
|
|
552
555
|
*/
|
|
553
|
-
|
|
556
|
+
annotationsByPolicy(policy_ids) {
|
|
554
557
|
try {
|
|
555
558
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
556
559
|
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
557
560
|
const len0 = WASM_VECTOR_LEN;
|
|
558
|
-
wasm.
|
|
561
|
+
wasm.cedarling_annotationsByPolicy(retptr, this.__wbg_ptr, ptr0, len0);
|
|
559
562
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
560
563
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
561
564
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -574,7 +577,7 @@ export class Cedarling {
|
|
|
574
577
|
* pass `result.response.diagnostics.reason`.
|
|
575
578
|
*
|
|
576
579
|
* Lossy: if the same annotation key appears on several policies, one value wins
|
|
577
|
-
* arbitrarily. Use `
|
|
580
|
+
* arbitrarily. Use `annotationValues` / `annotationsByPolicy` when duplicates
|
|
578
581
|
* matter. Unknown policy IDs are silently skipped.
|
|
579
582
|
*
|
|
580
583
|
* # Arguments
|
|
@@ -586,18 +589,18 @@ export class Cedarling {
|
|
|
586
589
|
* # Example
|
|
587
590
|
*
|
|
588
591
|
* ```javascript
|
|
589
|
-
* const annotations = cedarling.
|
|
592
|
+
* const annotations = cedarling.annotationsMap(result.response.diagnostics.reason);
|
|
590
593
|
* // { redirect: "/upgrade", tier: "premium" }
|
|
591
594
|
* ```
|
|
592
595
|
* @param {string[]} policy_ids
|
|
593
596
|
* @returns {any}
|
|
594
597
|
*/
|
|
595
|
-
|
|
598
|
+
annotationsMap(policy_ids) {
|
|
596
599
|
try {
|
|
597
600
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
598
601
|
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
599
602
|
const len0 = WASM_VECTOR_LEN;
|
|
600
|
-
wasm.
|
|
603
|
+
wasm.cedarling_annotationsMap(retptr, this.__wbg_ptr, ptr0, len0);
|
|
601
604
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
602
605
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
603
606
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -620,15 +623,15 @@ export class Cedarling {
|
|
|
620
623
|
* # Example
|
|
621
624
|
*
|
|
622
625
|
* ```javascript
|
|
623
|
-
* const result = await cedarling.
|
|
626
|
+
* const result = await cedarling.authorizeMultiIssuer(JSON.stringify(request));
|
|
624
627
|
* ```
|
|
625
628
|
* @param {string} request
|
|
626
629
|
* @returns {Promise<MultiIssuerAuthorizeResult>}
|
|
627
630
|
*/
|
|
628
|
-
|
|
631
|
+
authorizeMultiIssuer(request) {
|
|
629
632
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
630
633
|
const len0 = WASM_VECTOR_LEN;
|
|
631
|
-
const ret = wasm.
|
|
634
|
+
const ret = wasm.cedarling_authorizeMultiIssuer(this.__wbg_ptr, ptr0, len0);
|
|
632
635
|
return takeObject(ret);
|
|
633
636
|
}
|
|
634
637
|
/**
|
|
@@ -648,15 +651,15 @@ export class Cedarling {
|
|
|
648
651
|
* # Example
|
|
649
652
|
*
|
|
650
653
|
* ```javascript
|
|
651
|
-
* const result = await cedarling.
|
|
654
|
+
* const result = await cedarling.authorizeMultiIssuerBatch(JSON.stringify(batchRequest));
|
|
652
655
|
* ```
|
|
653
656
|
* @param {string} request
|
|
654
657
|
* @returns {Promise<BatchAuthorizeMultiIssuerResponse>}
|
|
655
658
|
*/
|
|
656
|
-
|
|
659
|
+
authorizeMultiIssuerBatch(request) {
|
|
657
660
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
658
661
|
const len0 = WASM_VECTOR_LEN;
|
|
659
|
-
const ret = wasm.
|
|
662
|
+
const ret = wasm.cedarling_authorizeMultiIssuerBatch(this.__wbg_ptr, ptr0, len0);
|
|
660
663
|
return takeObject(ret);
|
|
661
664
|
}
|
|
662
665
|
/**
|
|
@@ -675,15 +678,15 @@ export class Cedarling {
|
|
|
675
678
|
* # Example
|
|
676
679
|
*
|
|
677
680
|
* ```javascript
|
|
678
|
-
* const result = await cedarling.
|
|
681
|
+
* const result = await cedarling.authorizeUnsigned(JSON.stringify(request));
|
|
679
682
|
* ```
|
|
680
683
|
* @param {string} request
|
|
681
684
|
* @returns {Promise<AuthorizeResult>}
|
|
682
685
|
*/
|
|
683
|
-
|
|
686
|
+
authorizeUnsigned(request) {
|
|
684
687
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
685
688
|
const len0 = WASM_VECTOR_LEN;
|
|
686
|
-
const ret = wasm.
|
|
689
|
+
const ret = wasm.cedarling_authorizeUnsigned(this.__wbg_ptr, ptr0, len0);
|
|
687
690
|
return takeObject(ret);
|
|
688
691
|
}
|
|
689
692
|
/**
|
|
@@ -703,31 +706,35 @@ export class Cedarling {
|
|
|
703
706
|
* # Example
|
|
704
707
|
*
|
|
705
708
|
* ```javascript
|
|
706
|
-
* const result = await cedarling.
|
|
709
|
+
* const result = await cedarling.authorizeUnsignedBatch(JSON.stringify(batchRequest));
|
|
707
710
|
* ```
|
|
708
711
|
* @param {string} request
|
|
709
712
|
* @returns {Promise<BatchAuthorizeUnsignedResponse>}
|
|
710
713
|
*/
|
|
711
|
-
|
|
714
|
+
authorizeUnsignedBatch(request) {
|
|
712
715
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
713
716
|
const len0 = WASM_VECTOR_LEN;
|
|
714
|
-
const ret = wasm.
|
|
717
|
+
const ret = wasm.cedarling_authorizeUnsignedBatch(this.__wbg_ptr, ptr0, len0);
|
|
715
718
|
return takeObject(ret);
|
|
716
719
|
}
|
|
717
720
|
/**
|
|
718
721
|
* Clear all entries from the data store.
|
|
719
722
|
*
|
|
723
|
+
* # Arguments
|
|
724
|
+
*
|
|
725
|
+
* None.
|
|
726
|
+
*
|
|
720
727
|
* # Example
|
|
721
728
|
*
|
|
722
729
|
* ```javascript
|
|
723
|
-
* cedarling.
|
|
730
|
+
* cedarling.clearDataCtx();
|
|
724
731
|
* console.log("All data entries cleared");
|
|
725
732
|
* ```
|
|
726
733
|
*/
|
|
727
|
-
|
|
734
|
+
clearDataCtx() {
|
|
728
735
|
try {
|
|
729
736
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
730
|
-
wasm.
|
|
737
|
+
wasm.cedarling_clearDataCtx(retptr, this.__wbg_ptr);
|
|
731
738
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
732
739
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
733
740
|
if (r1) {
|
|
@@ -740,15 +747,19 @@ export class Cedarling {
|
|
|
740
747
|
/**
|
|
741
748
|
* Get trusted issuer identifiers that failed to load.
|
|
742
749
|
*
|
|
750
|
+
* # Arguments
|
|
751
|
+
*
|
|
752
|
+
* None.
|
|
753
|
+
*
|
|
743
754
|
* # Example
|
|
744
755
|
*
|
|
745
756
|
* ```javascript
|
|
746
|
-
* const ids = cedarling.
|
|
757
|
+
* const ids = cedarling.failedTrustedIssuerIds();
|
|
747
758
|
* ```
|
|
748
759
|
* @returns {Array<any>}
|
|
749
760
|
*/
|
|
750
|
-
|
|
751
|
-
const ret = wasm.
|
|
761
|
+
failedTrustedIssuerIds() {
|
|
762
|
+
const ret = wasm.cedarling_failedTrustedIssuerIds(this.__wbg_ptr);
|
|
752
763
|
return takeObject(ret);
|
|
753
764
|
}
|
|
754
765
|
/**
|
|
@@ -762,7 +773,7 @@ export class Cedarling {
|
|
|
762
773
|
* # Example
|
|
763
774
|
*
|
|
764
775
|
* ```javascript
|
|
765
|
-
* const value = cedarling.
|
|
776
|
+
* const value = cedarling.getDataCtx("user:123");
|
|
766
777
|
* if (value !== null) {
|
|
767
778
|
* console.log(value.name); // "John"
|
|
768
779
|
* }
|
|
@@ -770,12 +781,12 @@ export class Cedarling {
|
|
|
770
781
|
* @param {string} key
|
|
771
782
|
* @returns {any}
|
|
772
783
|
*/
|
|
773
|
-
|
|
784
|
+
getDataCtx(key) {
|
|
774
785
|
try {
|
|
775
786
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
776
787
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
777
788
|
const len0 = WASM_VECTOR_LEN;
|
|
778
|
-
wasm.
|
|
789
|
+
wasm.cedarling_getDataCtx(retptr, this.__wbg_ptr, ptr0, len0);
|
|
779
790
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
780
791
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
781
792
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -789,7 +800,7 @@ export class Cedarling {
|
|
|
789
800
|
}
|
|
790
801
|
/**
|
|
791
802
|
* Get a data entry with full metadata by key.
|
|
792
|
-
* Returns
|
|
803
|
+
* Returns undefined if the key doesn't exist or the entry has expired.
|
|
793
804
|
*
|
|
794
805
|
* # Arguments
|
|
795
806
|
*
|
|
@@ -798,10 +809,10 @@ export class Cedarling {
|
|
|
798
809
|
* # Example
|
|
799
810
|
*
|
|
800
811
|
* ```javascript
|
|
801
|
-
* const entry = cedarling.
|
|
802
|
-
* if (entry !==
|
|
812
|
+
* const entry = cedarling.getDataEntryCtx("user:123");
|
|
813
|
+
* if (entry !== undefined) {
|
|
803
814
|
* console.log(entry.key); // "user:123"
|
|
804
|
-
* console.log(entry.value); // { name: "John", age: 30 }
|
|
815
|
+
* console.log(entry.value()); // { name: "John", age: 30 }
|
|
805
816
|
* console.log(entry.data_type); // "Record"
|
|
806
817
|
* console.log(entry.created_at); // "2024-01-01T12:00:00Z"
|
|
807
818
|
* console.log(entry.access_count); // 5
|
|
@@ -810,12 +821,12 @@ export class Cedarling {
|
|
|
810
821
|
* @param {string} key
|
|
811
822
|
* @returns {DataEntry | undefined}
|
|
812
823
|
*/
|
|
813
|
-
|
|
824
|
+
getDataEntryCtx(key) {
|
|
814
825
|
try {
|
|
815
826
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
816
827
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
817
828
|
const len0 = WASM_VECTOR_LEN;
|
|
818
|
-
wasm.
|
|
829
|
+
wasm.cedarling_getDataEntryCtx(retptr, this.__wbg_ptr, ptr0, len0);
|
|
819
830
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
820
831
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
821
832
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -828,17 +839,26 @@ export class Cedarling {
|
|
|
828
839
|
}
|
|
829
840
|
}
|
|
830
841
|
/**
|
|
831
|
-
*
|
|
832
|
-
*
|
|
842
|
+
* Returns one retained memory log by ID, or `null` when it is not retained.
|
|
843
|
+
*
|
|
844
|
+
* # Arguments
|
|
845
|
+
*
|
|
846
|
+
* * `id` - The retained log identifier.
|
|
847
|
+
*
|
|
848
|
+
* # Example
|
|
849
|
+
*
|
|
850
|
+
* ```javascript
|
|
851
|
+
* const log = cedarling.getLogById("request-id");
|
|
852
|
+
* ```
|
|
833
853
|
* @param {string} id
|
|
834
854
|
* @returns {any}
|
|
835
855
|
*/
|
|
836
|
-
|
|
856
|
+
getLogById(id) {
|
|
837
857
|
try {
|
|
838
858
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
839
859
|
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
840
860
|
const len0 = WASM_VECTOR_LEN;
|
|
841
|
-
wasm.
|
|
861
|
+
wasm.cedarling_getLogById(retptr, this.__wbg_ptr, ptr0, len0);
|
|
842
862
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
843
863
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
844
864
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -851,26 +871,44 @@ export class Cedarling {
|
|
|
851
871
|
}
|
|
852
872
|
}
|
|
853
873
|
/**
|
|
854
|
-
* Returns
|
|
855
|
-
*
|
|
874
|
+
* Returns identifiers for all retained memory logs.
|
|
875
|
+
*
|
|
876
|
+
* # Arguments
|
|
877
|
+
*
|
|
878
|
+
* None.
|
|
879
|
+
*
|
|
880
|
+
* # Example
|
|
881
|
+
*
|
|
882
|
+
* ```javascript
|
|
883
|
+
* const ids = cedarling.getLogIds();
|
|
884
|
+
* ```
|
|
856
885
|
* @returns {Array<any>}
|
|
857
886
|
*/
|
|
858
|
-
|
|
859
|
-
const ret = wasm.
|
|
887
|
+
getLogIds() {
|
|
888
|
+
const ret = wasm.cedarling_getLogIds(this.__wbg_ptr);
|
|
860
889
|
return takeObject(ret);
|
|
861
890
|
}
|
|
862
891
|
/**
|
|
863
|
-
*
|
|
864
|
-
*
|
|
892
|
+
* Returns retained memory logs for one request ID.
|
|
893
|
+
*
|
|
894
|
+
* # Arguments
|
|
895
|
+
*
|
|
896
|
+
* * `requestId` - The request identifier to match.
|
|
897
|
+
*
|
|
898
|
+
* # Example
|
|
899
|
+
*
|
|
900
|
+
* ```javascript
|
|
901
|
+
* const logs = cedarling.getLogsByRequestId("request-id");
|
|
902
|
+
* ```
|
|
865
903
|
* @param {string} request_id
|
|
866
904
|
* @returns {any[]}
|
|
867
905
|
*/
|
|
868
|
-
|
|
906
|
+
getLogsByRequestId(request_id) {
|
|
869
907
|
try {
|
|
870
908
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
871
909
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
872
910
|
const len0 = WASM_VECTOR_LEN;
|
|
873
|
-
wasm.
|
|
911
|
+
wasm.cedarling_getLogsByRequestId(retptr, this.__wbg_ptr, ptr0, len0);
|
|
874
912
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
875
913
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
876
914
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -886,21 +924,31 @@ export class Cedarling {
|
|
|
886
924
|
}
|
|
887
925
|
}
|
|
888
926
|
/**
|
|
889
|
-
*
|
|
890
|
-
*
|
|
891
|
-
*
|
|
927
|
+
* Returns retained memory logs matching one request ID and indexed value.
|
|
928
|
+
*
|
|
929
|
+
* # Arguments
|
|
930
|
+
*
|
|
931
|
+
* * `requestId` - The request identifier to match.
|
|
932
|
+
* * `tag` - A log kind (`"System"`, `"Decision"`, or `"Metric"`) or a
|
|
933
|
+
* system-log level such as `"DEBUG"`.
|
|
934
|
+
*
|
|
935
|
+
* # Example
|
|
936
|
+
*
|
|
937
|
+
* ```javascript
|
|
938
|
+
* const logs = cedarling.getLogsByRequestIdAndTag("request-id", "System");
|
|
939
|
+
* ```
|
|
892
940
|
* @param {string} request_id
|
|
893
941
|
* @param {string} tag
|
|
894
942
|
* @returns {any[]}
|
|
895
943
|
*/
|
|
896
|
-
|
|
944
|
+
getLogsByRequestIdAndTag(request_id, tag) {
|
|
897
945
|
try {
|
|
898
946
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
899
947
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
900
948
|
const len0 = WASM_VECTOR_LEN;
|
|
901
949
|
const ptr1 = passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
902
950
|
const len1 = WASM_VECTOR_LEN;
|
|
903
|
-
wasm.
|
|
951
|
+
wasm.cedarling_getLogsByRequestIdAndTag(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
904
952
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
905
953
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
906
954
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -916,17 +964,27 @@ export class Cedarling {
|
|
|
916
964
|
}
|
|
917
965
|
}
|
|
918
966
|
/**
|
|
919
|
-
*
|
|
920
|
-
*
|
|
967
|
+
* Returns retained memory logs matching an indexed value.
|
|
968
|
+
*
|
|
969
|
+
* # Arguments
|
|
970
|
+
*
|
|
971
|
+
* * `tag` - A log kind (`"System"`, `"Decision"`, or `"Metric"`) or a
|
|
972
|
+
* system-log level such as `"DEBUG"`.
|
|
973
|
+
*
|
|
974
|
+
* # Example
|
|
975
|
+
*
|
|
976
|
+
* ```javascript
|
|
977
|
+
* const logs = cedarling.getLogsByTag("System");
|
|
978
|
+
* ```
|
|
921
979
|
* @param {string} tag
|
|
922
980
|
* @returns {any[]}
|
|
923
981
|
*/
|
|
924
|
-
|
|
982
|
+
getLogsByTag(tag) {
|
|
925
983
|
try {
|
|
926
984
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
927
985
|
const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
928
986
|
const len0 = WASM_VECTOR_LEN;
|
|
929
|
-
wasm.
|
|
987
|
+
wasm.cedarling_getLogsByTag(retptr, this.__wbg_ptr, ptr0, len0);
|
|
930
988
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
931
989
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
932
990
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -944,20 +1002,24 @@ export class Cedarling {
|
|
|
944
1002
|
/**
|
|
945
1003
|
* Get statistics about the data store.
|
|
946
1004
|
*
|
|
1005
|
+
* # Arguments
|
|
1006
|
+
*
|
|
1007
|
+
* None.
|
|
1008
|
+
*
|
|
947
1009
|
* # Example
|
|
948
1010
|
*
|
|
949
1011
|
* ```javascript
|
|
950
|
-
* const stats = cedarling.
|
|
1012
|
+
* const stats = cedarling.getStatsCtx();
|
|
951
1013
|
* console.log(`Entries: ${stats.entry_count}/${stats.max_entries || 'unlimited'}`);
|
|
952
1014
|
* console.log(`Capacity: ${stats.capacity_usage_percent.toFixed(2)}%`);
|
|
953
1015
|
* console.log(`Total size: ${stats.total_size_bytes} bytes`);
|
|
954
1016
|
* ```
|
|
955
1017
|
* @returns {DataStoreStats}
|
|
956
1018
|
*/
|
|
957
|
-
|
|
1019
|
+
getStatsCtx() {
|
|
958
1020
|
try {
|
|
959
1021
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
960
|
-
wasm.
|
|
1022
|
+
wasm.cedarling_getStatsCtx(retptr, this.__wbg_ptr);
|
|
961
1023
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
962
1024
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
963
1025
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -979,15 +1041,15 @@ export class Cedarling {
|
|
|
979
1041
|
* # Example
|
|
980
1042
|
*
|
|
981
1043
|
* ```javascript
|
|
982
|
-
* const ok = cedarling.
|
|
1044
|
+
* const ok = cedarling.isTrustedIssuerLoadedByIss("https://issuer.example.org");
|
|
983
1045
|
* ```
|
|
984
1046
|
* @param {string} iss_claim
|
|
985
1047
|
* @returns {boolean}
|
|
986
1048
|
*/
|
|
987
|
-
|
|
1049
|
+
isTrustedIssuerLoadedByIss(iss_claim) {
|
|
988
1050
|
const ptr0 = passStringToWasm0(iss_claim, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
989
1051
|
const len0 = WASM_VECTOR_LEN;
|
|
990
|
-
const ret = wasm.
|
|
1052
|
+
const ret = wasm.cedarling_isTrustedIssuerLoadedByIss(this.__wbg_ptr, ptr0, len0);
|
|
991
1053
|
return ret !== 0;
|
|
992
1054
|
}
|
|
993
1055
|
/**
|
|
@@ -1000,35 +1062,39 @@ export class Cedarling {
|
|
|
1000
1062
|
* # Example
|
|
1001
1063
|
*
|
|
1002
1064
|
* ```javascript
|
|
1003
|
-
* const ok = cedarling.
|
|
1065
|
+
* const ok = cedarling.isTrustedIssuerLoadedByName("issuer_id");
|
|
1004
1066
|
* ```
|
|
1005
1067
|
* @param {string} issuer_id
|
|
1006
1068
|
* @returns {boolean}
|
|
1007
1069
|
*/
|
|
1008
|
-
|
|
1070
|
+
isTrustedIssuerLoadedByName(issuer_id) {
|
|
1009
1071
|
const ptr0 = passStringToWasm0(issuer_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1010
1072
|
const len0 = WASM_VECTOR_LEN;
|
|
1011
|
-
const ret = wasm.
|
|
1073
|
+
const ret = wasm.cedarling_isTrustedIssuerLoadedByName(this.__wbg_ptr, ptr0, len0);
|
|
1012
1074
|
return ret !== 0;
|
|
1013
1075
|
}
|
|
1014
1076
|
/**
|
|
1015
1077
|
* List all entries with their metadata.
|
|
1016
1078
|
* Returns an array of DataEntry objects.
|
|
1017
1079
|
*
|
|
1080
|
+
* # Arguments
|
|
1081
|
+
*
|
|
1082
|
+
* None.
|
|
1083
|
+
*
|
|
1018
1084
|
* # Example
|
|
1019
1085
|
*
|
|
1020
1086
|
* ```javascript
|
|
1021
|
-
* const entries = cedarling.
|
|
1087
|
+
* const entries = cedarling.listDataCtx();
|
|
1022
1088
|
* entries.forEach(entry => {
|
|
1023
1089
|
* console.log(`${entry.key}: ${entry.data_type} (accessed ${entry.access_count} times)`);
|
|
1024
1090
|
* });
|
|
1025
1091
|
* ```
|
|
1026
1092
|
* @returns {Array<any>}
|
|
1027
1093
|
*/
|
|
1028
|
-
|
|
1094
|
+
listDataCtx() {
|
|
1029
1095
|
try {
|
|
1030
1096
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1031
|
-
wasm.
|
|
1097
|
+
wasm.cedarling_listDataCtx(retptr, this.__wbg_ptr);
|
|
1032
1098
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1033
1099
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1034
1100
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1043,34 +1109,57 @@ export class Cedarling {
|
|
|
1043
1109
|
/**
|
|
1044
1110
|
* Get trusted issuer identifiers loaded successfully.
|
|
1045
1111
|
*
|
|
1112
|
+
* # Arguments
|
|
1113
|
+
*
|
|
1114
|
+
* None.
|
|
1115
|
+
*
|
|
1046
1116
|
* # Example
|
|
1047
1117
|
*
|
|
1048
1118
|
* ```javascript
|
|
1049
|
-
* const ids = cedarling.
|
|
1119
|
+
* const ids = cedarling.loadedTrustedIssuerIds();
|
|
1050
1120
|
* ```
|
|
1051
1121
|
* @returns {Array<any>}
|
|
1052
1122
|
*/
|
|
1053
|
-
|
|
1054
|
-
const ret = wasm.
|
|
1123
|
+
loadedTrustedIssuerIds() {
|
|
1124
|
+
const ret = wasm.cedarling_loadedTrustedIssuerIds(this.__wbg_ptr);
|
|
1055
1125
|
return takeObject(ret);
|
|
1056
1126
|
}
|
|
1057
1127
|
/**
|
|
1058
1128
|
* Get the number of trusted issuers loaded successfully.
|
|
1059
1129
|
*
|
|
1130
|
+
* # Arguments
|
|
1131
|
+
*
|
|
1132
|
+
* None.
|
|
1133
|
+
*
|
|
1060
1134
|
* # Example
|
|
1061
1135
|
*
|
|
1062
1136
|
* ```javascript
|
|
1063
|
-
* const loadedCount = cedarling.
|
|
1137
|
+
* const loadedCount = cedarling.loadedTrustedIssuersCount();
|
|
1064
1138
|
* ```
|
|
1065
1139
|
* @returns {number}
|
|
1066
1140
|
*/
|
|
1067
|
-
|
|
1068
|
-
const ret = wasm.
|
|
1141
|
+
loadedTrustedIssuersCount() {
|
|
1142
|
+
const ret = wasm.cedarling_loadedTrustedIssuersCount(this.__wbg_ptr);
|
|
1069
1143
|
return ret >>> 0;
|
|
1070
1144
|
}
|
|
1071
1145
|
/**
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1146
|
+
* Creates a Cedarling application from bootstrap properties.
|
|
1147
|
+
*
|
|
1148
|
+
* # Arguments
|
|
1149
|
+
*
|
|
1150
|
+
* * `config` - A plain object of Cedarling bootstrap-property names and values.
|
|
1151
|
+
*
|
|
1152
|
+
* # Example
|
|
1153
|
+
*
|
|
1154
|
+
* ```javascript
|
|
1155
|
+
* await initWasm();
|
|
1156
|
+
* const cedarling = await Cedarling.new({
|
|
1157
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
1158
|
+
* CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
|
|
1159
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
1160
|
+
* CEDARLING_LOG_TTL: 120,
|
|
1161
|
+
* });
|
|
1162
|
+
* ```
|
|
1074
1163
|
* @param {object} config
|
|
1075
1164
|
* @returns {Promise<Cedarling>}
|
|
1076
1165
|
*/
|
|
@@ -1079,24 +1168,49 @@ export class Cedarling {
|
|
|
1079
1168
|
return takeObject(ret);
|
|
1080
1169
|
}
|
|
1081
1170
|
/**
|
|
1082
|
-
*
|
|
1083
|
-
*
|
|
1171
|
+
* Creates a new Cedarling application from a JavaScript `Map`.
|
|
1172
|
+
*
|
|
1173
|
+
* # Arguments
|
|
1174
|
+
*
|
|
1175
|
+
* * `config` - A `Map` of Cedarling bootstrap-property names and values.
|
|
1176
|
+
*
|
|
1177
|
+
* # Example
|
|
1178
|
+
*
|
|
1179
|
+
* ```javascript
|
|
1180
|
+
* await initWasm();
|
|
1181
|
+
* const cedarling = await Cedarling.newFromMap(new Map([
|
|
1182
|
+
* ["CEDARLING_APPLICATION_NAME", "task-api"],
|
|
1183
|
+
* ["CEDARLING_POLICY_STORE_URI", "https://example.com/policy-store.cjar"],
|
|
1184
|
+
* ["CEDARLING_LOG_TYPE", "memory"],
|
|
1185
|
+
* ["CEDARLING_LOG_TTL", 120],
|
|
1186
|
+
* ]));
|
|
1187
|
+
* ```
|
|
1084
1188
|
* @param {Map<any, any>} config
|
|
1085
1189
|
* @returns {Promise<Cedarling>}
|
|
1086
1190
|
*/
|
|
1087
|
-
static
|
|
1088
|
-
const ret = wasm.
|
|
1191
|
+
static newFromMap(config) {
|
|
1192
|
+
const ret = wasm.cedarling_newFromMap(addHeapObject(config));
|
|
1089
1193
|
return takeObject(ret);
|
|
1090
1194
|
}
|
|
1091
1195
|
/**
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1196
|
+
* Returns all retained memory logs and removes them from storage.
|
|
1197
|
+
* Other log configurations return an empty array.
|
|
1198
|
+
*
|
|
1199
|
+
* # Arguments
|
|
1200
|
+
*
|
|
1201
|
+
* None.
|
|
1202
|
+
*
|
|
1203
|
+
* # Example
|
|
1204
|
+
*
|
|
1205
|
+
* ```javascript
|
|
1206
|
+
* const logs = cedarling.popLogs();
|
|
1207
|
+
* ```
|
|
1094
1208
|
* @returns {Array<any>}
|
|
1095
1209
|
*/
|
|
1096
|
-
|
|
1210
|
+
popLogs() {
|
|
1097
1211
|
try {
|
|
1098
1212
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1099
|
-
wasm.
|
|
1213
|
+
wasm.cedarling_popLogs(retptr, this.__wbg_ptr);
|
|
1100
1214
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1101
1215
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1102
1216
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1122,19 +1236,19 @@ export class Cedarling {
|
|
|
1122
1236
|
* # Example
|
|
1123
1237
|
*
|
|
1124
1238
|
* ```javascript
|
|
1125
|
-
* cedarling.
|
|
1126
|
-
* cedarling.
|
|
1239
|
+
* cedarling.pushDataCtx("user:123", { name: "John", age: 30 }, 3600);
|
|
1240
|
+
* cedarling.pushDataCtx("config", { setting: "value" }); // Uses default TTL
|
|
1127
1241
|
* ```
|
|
1128
1242
|
* @param {string} key
|
|
1129
1243
|
* @param {any} value
|
|
1130
1244
|
* @param {bigint | null} [ttl_secs]
|
|
1131
1245
|
*/
|
|
1132
|
-
|
|
1246
|
+
pushDataCtx(key, value, ttl_secs) {
|
|
1133
1247
|
try {
|
|
1134
1248
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1135
1249
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1136
1250
|
const len0 = WASM_VECTOR_LEN;
|
|
1137
|
-
wasm.
|
|
1251
|
+
wasm.cedarling_pushDataCtx(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value), !isLikeNone(ttl_secs), isLikeNone(ttl_secs) ? BigInt(0) : ttl_secs);
|
|
1138
1252
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1139
1253
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1140
1254
|
if (r1) {
|
|
@@ -1155,7 +1269,7 @@ export class Cedarling {
|
|
|
1155
1269
|
* # Example
|
|
1156
1270
|
*
|
|
1157
1271
|
* ```javascript
|
|
1158
|
-
* const removed = cedarling.
|
|
1272
|
+
* const removed = cedarling.removeDataCtx("user:123");
|
|
1159
1273
|
* if (removed) {
|
|
1160
1274
|
* console.log("Entry was successfully removed");
|
|
1161
1275
|
* }
|
|
@@ -1163,12 +1277,12 @@ export class Cedarling {
|
|
|
1163
1277
|
* @param {string} key
|
|
1164
1278
|
* @returns {boolean}
|
|
1165
1279
|
*/
|
|
1166
|
-
|
|
1280
|
+
removeDataCtx(key) {
|
|
1167
1281
|
try {
|
|
1168
1282
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1169
1283
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1170
1284
|
const len0 = WASM_VECTOR_LEN;
|
|
1171
|
-
wasm.
|
|
1285
|
+
wasm.cedarling_removeDataCtx(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1172
1286
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1173
1287
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1174
1288
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1181,25 +1295,39 @@ export class Cedarling {
|
|
|
1181
1295
|
}
|
|
1182
1296
|
}
|
|
1183
1297
|
/**
|
|
1184
|
-
* Closes
|
|
1298
|
+
* Closes Lock Server connections and pushes all available logs.
|
|
1299
|
+
*
|
|
1300
|
+
* # Arguments
|
|
1301
|
+
*
|
|
1302
|
+
* None.
|
|
1303
|
+
*
|
|
1304
|
+
* # Example
|
|
1305
|
+
*
|
|
1306
|
+
* ```javascript
|
|
1307
|
+
* await cedarling.shutDown();
|
|
1308
|
+
* ```
|
|
1185
1309
|
* @returns {Promise<void>}
|
|
1186
1310
|
*/
|
|
1187
|
-
|
|
1188
|
-
const ret = wasm.
|
|
1311
|
+
shutDown() {
|
|
1312
|
+
const ret = wasm.cedarling_shutDown(this.__wbg_ptr);
|
|
1189
1313
|
return takeObject(ret);
|
|
1190
1314
|
}
|
|
1191
1315
|
/**
|
|
1192
1316
|
* Get the total number of trusted issuer entries discovered.
|
|
1193
1317
|
*
|
|
1318
|
+
* # Arguments
|
|
1319
|
+
*
|
|
1320
|
+
* None.
|
|
1321
|
+
*
|
|
1194
1322
|
* # Example
|
|
1195
1323
|
*
|
|
1196
1324
|
* ```javascript
|
|
1197
|
-
* const total = cedarling.
|
|
1325
|
+
* const total = cedarling.totalIssuers();
|
|
1198
1326
|
* ```
|
|
1199
1327
|
* @returns {number}
|
|
1200
1328
|
*/
|
|
1201
|
-
|
|
1202
|
-
const ret = wasm.
|
|
1329
|
+
totalIssuers() {
|
|
1330
|
+
const ret = wasm.cedarling_totalIssuers(this.__wbg_ptr);
|
|
1203
1331
|
return ret >>> 0;
|
|
1204
1332
|
}
|
|
1205
1333
|
}
|
|
@@ -1230,12 +1358,12 @@ export class DataEntry {
|
|
|
1230
1358
|
* Convert `DataEntry` to json string value
|
|
1231
1359
|
* @returns {string}
|
|
1232
1360
|
*/
|
|
1233
|
-
|
|
1361
|
+
jsonString() {
|
|
1234
1362
|
let deferred1_0;
|
|
1235
1363
|
let deferred1_1;
|
|
1236
1364
|
try {
|
|
1237
1365
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1238
|
-
wasm.
|
|
1366
|
+
wasm.dataentry_jsonString(retptr, this.__wbg_ptr);
|
|
1239
1367
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1240
1368
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1241
1369
|
deferred1_0 = r0;
|
|
@@ -1314,7 +1442,7 @@ export class DataEntry {
|
|
|
1314
1442
|
}
|
|
1315
1443
|
}
|
|
1316
1444
|
/**
|
|
1317
|
-
* Timestamp when this entry expires (RFC 3339 format)
|
|
1445
|
+
* Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
|
|
1318
1446
|
* @returns {string | undefined}
|
|
1319
1447
|
*/
|
|
1320
1448
|
get expires_at() {
|
|
@@ -1379,7 +1507,7 @@ export class DataEntry {
|
|
|
1379
1507
|
wasm.__wbg_set_dataentry_data_type(this.__wbg_ptr, ptr0, len0);
|
|
1380
1508
|
}
|
|
1381
1509
|
/**
|
|
1382
|
-
* Timestamp when this entry expires (RFC 3339 format)
|
|
1510
|
+
* Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
|
|
1383
1511
|
* @param {string | null} [arg0]
|
|
1384
1512
|
*/
|
|
1385
1513
|
set expires_at(arg0) {
|
|
@@ -1424,12 +1552,12 @@ export class DataStoreStats {
|
|
|
1424
1552
|
* Convert `DataStoreStats` to json string value
|
|
1425
1553
|
* @returns {string}
|
|
1426
1554
|
*/
|
|
1427
|
-
|
|
1555
|
+
jsonString() {
|
|
1428
1556
|
let deferred1_0;
|
|
1429
1557
|
let deferred1_1;
|
|
1430
1558
|
try {
|
|
1431
1559
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1432
|
-
wasm.
|
|
1560
|
+
wasm.datastorestats_jsonString(retptr, this.__wbg_ptr);
|
|
1433
1561
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1434
1562
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1435
1563
|
deferred1_0 = r0;
|
|
@@ -1816,12 +1944,12 @@ export class MultiIssuerAuthorizeResult {
|
|
|
1816
1944
|
* Convert `MultiIssuerAuthorizeResult` to json string value
|
|
1817
1945
|
* @returns {string}
|
|
1818
1946
|
*/
|
|
1819
|
-
|
|
1947
|
+
jsonString() {
|
|
1820
1948
|
let deferred1_0;
|
|
1821
1949
|
let deferred1_1;
|
|
1822
1950
|
try {
|
|
1823
1951
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1824
|
-
wasm.
|
|
1952
|
+
wasm.multiissuerauthorizeresult_jsonString(retptr, this.__wbg_ptr);
|
|
1825
1953
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1826
1954
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1827
1955
|
deferred1_0 = r0;
|
|
@@ -1929,8 +2057,24 @@ export class PolicyEvaluationError {
|
|
|
1929
2057
|
if (Symbol.dispose) PolicyEvaluationError.prototype[Symbol.dispose] = PolicyEvaluationError.prototype.free;
|
|
1930
2058
|
|
|
1931
2059
|
/**
|
|
1932
|
-
*
|
|
1933
|
-
*
|
|
2060
|
+
* Creates a Cedarling application from bootstrap properties.
|
|
2061
|
+
*
|
|
2062
|
+
* # Arguments
|
|
2063
|
+
*
|
|
2064
|
+
* * `config` - A JavaScript `Map` or plain object of Cedarling
|
|
2065
|
+
* bootstrap-property names and values.
|
|
2066
|
+
*
|
|
2067
|
+
* # Example
|
|
2068
|
+
*
|
|
2069
|
+
* ```javascript
|
|
2070
|
+
* await initWasm();
|
|
2071
|
+
* const cedarling = await init({
|
|
2072
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
2073
|
+
* CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
|
|
2074
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
2075
|
+
* CEDARLING_LOG_TTL: 120,
|
|
2076
|
+
* });
|
|
2077
|
+
* ```
|
|
1934
2078
|
* @param {any} config
|
|
1935
2079
|
* @returns {Promise<Cedarling>}
|
|
1936
2080
|
*/
|
|
@@ -1946,21 +2090,31 @@ export function init(config) {
|
|
|
1946
2090
|
* that was fetched with custom logic (e.g., with authentication headers).
|
|
1947
2091
|
*
|
|
1948
2092
|
* # Arguments
|
|
1949
|
-
* * `config` - Bootstrap configuration (Map or Object)
|
|
2093
|
+
* * `config` - Bootstrap configuration (Map or Object) without a policy-store
|
|
2094
|
+
* source property. The archive bytes provide the policy store.
|
|
1950
2095
|
* * `archive_bytes` - The .cjar archive bytes (Uint8Array)
|
|
1951
2096
|
*
|
|
1952
2097
|
* # Example
|
|
1953
2098
|
* ```javascript
|
|
1954
|
-
*
|
|
1955
|
-
* const
|
|
1956
|
-
*
|
|
2099
|
+
* await initWasm();
|
|
2100
|
+
* const config = {
|
|
2101
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
2102
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
2103
|
+
* CEDARLING_LOG_TTL: 120,
|
|
2104
|
+
* };
|
|
2105
|
+
* const response = await fetch("https://example.com/policy-store.cjar", {
|
|
2106
|
+
* headers: { Authorization: "Bearer <token>" },
|
|
2107
|
+
* });
|
|
2108
|
+
* if (!response.ok) throw new Error("Unable to fetch policy store");
|
|
2109
|
+
* const archiveBytes = new Uint8Array(await response.arrayBuffer());
|
|
2110
|
+
* const cedarling = await initFromArchiveBytes(config, archiveBytes);
|
|
1957
2111
|
* ```
|
|
1958
2112
|
* @param {any} config
|
|
1959
2113
|
* @param {Uint8Array} archive_bytes
|
|
1960
2114
|
* @returns {Promise<Cedarling>}
|
|
1961
2115
|
*/
|
|
1962
|
-
export function
|
|
1963
|
-
const ret = wasm.
|
|
2116
|
+
export function initFromArchiveBytes(config, archive_bytes) {
|
|
2117
|
+
const ret = wasm.initFromArchiveBytes(addHeapObject(config), addHeapObject(archive_bytes));
|
|
1964
2118
|
return takeObject(ret);
|
|
1965
2119
|
}
|
|
1966
2120
|
function __wbg_get_imports() {
|
|
@@ -2378,7 +2532,7 @@ function __wbg_get_imports() {
|
|
|
2378
2532
|
const a = state0.a;
|
|
2379
2533
|
state0.a = 0;
|
|
2380
2534
|
try {
|
|
2381
|
-
return
|
|
2535
|
+
return __wasm_bindgen_func_elem_8968(a, state0.b, arg0, arg1);
|
|
2382
2536
|
} finally {
|
|
2383
2537
|
state0.a = a;
|
|
2384
2538
|
}
|
|
@@ -2588,17 +2742,17 @@ function __wbg_get_imports() {
|
|
|
2588
2742
|
},
|
|
2589
2743
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
2590
2744
|
// 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`.
|
|
2591
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2745
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8902);
|
|
2592
2746
|
return addHeapObject(ret);
|
|
2593
2747
|
},
|
|
2594
2748
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
2595
2749
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1206, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2596
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2750
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12454);
|
|
2597
2751
|
return addHeapObject(ret);
|
|
2598
2752
|
},
|
|
2599
2753
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
2600
2754
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1003, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2601
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2755
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8737);
|
|
2602
2756
|
return addHeapObject(ret);
|
|
2603
2757
|
},
|
|
2604
2758
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
@@ -2640,18 +2794,18 @@ function __wbg_get_imports() {
|
|
|
2640
2794
|
};
|
|
2641
2795
|
}
|
|
2642
2796
|
|
|
2643
|
-
function
|
|
2644
|
-
wasm.
|
|
2797
|
+
function __wasm_bindgen_func_elem_8737(arg0, arg1) {
|
|
2798
|
+
wasm.__wasm_bindgen_func_elem_8737(arg0, arg1);
|
|
2645
2799
|
}
|
|
2646
2800
|
|
|
2647
|
-
function
|
|
2648
|
-
wasm.
|
|
2801
|
+
function __wasm_bindgen_func_elem_12454(arg0, arg1, arg2) {
|
|
2802
|
+
wasm.__wasm_bindgen_func_elem_12454(arg0, arg1, addHeapObject(arg2));
|
|
2649
2803
|
}
|
|
2650
2804
|
|
|
2651
|
-
function
|
|
2805
|
+
function __wasm_bindgen_func_elem_8902(arg0, arg1, arg2) {
|
|
2652
2806
|
try {
|
|
2653
2807
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2654
|
-
wasm.
|
|
2808
|
+
wasm.__wasm_bindgen_func_elem_8902(retptr, arg0, arg1, addHeapObject(arg2));
|
|
2655
2809
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2656
2810
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2657
2811
|
if (r1) {
|
|
@@ -2662,8 +2816,8 @@ function __wasm_bindgen_func_elem_8913(arg0, arg1, arg2) {
|
|
|
2662
2816
|
}
|
|
2663
2817
|
}
|
|
2664
2818
|
|
|
2665
|
-
function
|
|
2666
|
-
wasm.
|
|
2819
|
+
function __wasm_bindgen_func_elem_8968(arg0, arg1, arg2, arg3) {
|
|
2820
|
+
wasm.__wasm_bindgen_func_elem_8968(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
2667
2821
|
}
|
|
2668
2822
|
|
|
2669
2823
|
|