@janssenproject/cedarling_wasm 0.0.466 → 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 -253
- package/cedarling_wasm.js +325 -252
- package/cedarling_wasm_bg.wasm +0 -0
- package/package.json +2 -6
package/cedarling_wasm.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* A WASM wrapper for the Rust `cedarling::AuthorizeResult` struct.
|
|
5
5
|
* Represents the result of an authorization request.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
class AuthorizeResult {
|
|
8
8
|
static __wrap(ptr) {
|
|
9
9
|
const obj = Object.create(AuthorizeResult.prototype);
|
|
10
10
|
obj.__wbg_ptr = ptr;
|
|
@@ -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;
|
|
@@ -112,12 +112,13 @@ export class AuthorizeResult {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
if (Symbol.dispose) AuthorizeResult.prototype[Symbol.dispose] = AuthorizeResult.prototype.free;
|
|
115
|
+
exports.AuthorizeResult = AuthorizeResult;
|
|
115
116
|
|
|
116
117
|
/**
|
|
117
118
|
* A WASM wrapper for the Rust `cedar_policy::Response` struct.
|
|
118
119
|
* Represents the result of an authorization request.
|
|
119
120
|
*/
|
|
120
|
-
|
|
121
|
+
class AuthorizeResultResponse {
|
|
121
122
|
static __wrap(ptr) {
|
|
122
123
|
const obj = Object.create(AuthorizeResultResponse.prototype);
|
|
123
124
|
obj.__wbg_ptr = ptr;
|
|
@@ -152,13 +153,14 @@ export class AuthorizeResultResponse {
|
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
if (Symbol.dispose) AuthorizeResultResponse.prototype[Symbol.dispose] = AuthorizeResultResponse.prototype.free;
|
|
156
|
+
exports.AuthorizeResultResponse = AuthorizeResultResponse;
|
|
155
157
|
|
|
156
158
|
/**
|
|
157
159
|
* WASM wrapper for
|
|
158
160
|
* `cedarling::BatchAuthorizeResponse<Result<MultiIssuerAuthorizeResult, BatchItemError>>`.
|
|
159
161
|
* Same shape as [`BatchAuthorizeUnsignedResponse`] with multi-issuer results.
|
|
160
162
|
*/
|
|
161
|
-
|
|
163
|
+
class BatchAuthorizeMultiIssuerResponse {
|
|
162
164
|
static __wrap(ptr) {
|
|
163
165
|
const obj = Object.create(BatchAuthorizeMultiIssuerResponse.prototype);
|
|
164
166
|
obj.__wbg_ptr = ptr;
|
|
@@ -215,6 +217,7 @@ export class BatchAuthorizeMultiIssuerResponse {
|
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
219
|
if (Symbol.dispose) BatchAuthorizeMultiIssuerResponse.prototype[Symbol.dispose] = BatchAuthorizeMultiIssuerResponse.prototype.free;
|
|
220
|
+
exports.BatchAuthorizeMultiIssuerResponse = BatchAuthorizeMultiIssuerResponse;
|
|
218
221
|
|
|
219
222
|
/**
|
|
220
223
|
* WASM wrapper for `cedarling::BatchAuthorizeResponse<Result<AuthorizeResult, BatchItemError>>`.
|
|
@@ -223,7 +226,7 @@ if (Symbol.dispose) BatchAuthorizeMultiIssuerResponse.prototype[Symbol.dispose]
|
|
|
223
226
|
* is a [`BatchItemUnsignedResult`] — Cedar decision on `is_ok()`, per-item
|
|
224
227
|
* build failure on `error`. `results[i]` corresponds to `items[i]`.
|
|
225
228
|
*/
|
|
226
|
-
|
|
229
|
+
class BatchAuthorizeUnsignedResponse {
|
|
227
230
|
static __wrap(ptr) {
|
|
228
231
|
const obj = Object.create(BatchAuthorizeUnsignedResponse.prototype);
|
|
229
232
|
obj.__wbg_ptr = ptr;
|
|
@@ -280,12 +283,13 @@ export class BatchAuthorizeUnsignedResponse {
|
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
285
|
if (Symbol.dispose) BatchAuthorizeUnsignedResponse.prototype[Symbol.dispose] = BatchAuthorizeUnsignedResponse.prototype.free;
|
|
286
|
+
exports.BatchAuthorizeUnsignedResponse = BatchAuthorizeUnsignedResponse;
|
|
283
287
|
|
|
284
288
|
/**
|
|
285
289
|
* Per-item build failure surfaced inside a batch response at `results[i]`
|
|
286
290
|
* when Cedar couldn't be reached for that item.
|
|
287
291
|
*/
|
|
288
|
-
|
|
292
|
+
class BatchItemError {
|
|
289
293
|
static __wrap(ptr) {
|
|
290
294
|
const obj = Object.create(BatchItemError.prototype);
|
|
291
295
|
obj.__wbg_ptr = ptr;
|
|
@@ -354,11 +358,12 @@ export class BatchItemError {
|
|
|
354
358
|
}
|
|
355
359
|
}
|
|
356
360
|
if (Symbol.dispose) BatchItemError.prototype[Symbol.dispose] = BatchItemError.prototype.free;
|
|
361
|
+
exports.BatchItemError = BatchItemError;
|
|
357
362
|
|
|
358
363
|
/**
|
|
359
364
|
* Multi-issuer analog of [`BatchItemUnsignedResult`].
|
|
360
365
|
*/
|
|
361
|
-
|
|
366
|
+
class BatchItemMultiIssuerResult {
|
|
362
367
|
static __wrap(ptr) {
|
|
363
368
|
const obj = Object.create(BatchItemMultiIssuerResult.prototype);
|
|
364
369
|
obj.__wbg_ptr = ptr;
|
|
@@ -412,12 +417,13 @@ export class BatchItemMultiIssuerResult {
|
|
|
412
417
|
}
|
|
413
418
|
}
|
|
414
419
|
if (Symbol.dispose) BatchItemMultiIssuerResult.prototype[Symbol.dispose] = BatchItemMultiIssuerResult.prototype.free;
|
|
420
|
+
exports.BatchItemMultiIssuerResult = BatchItemMultiIssuerResult;
|
|
415
421
|
|
|
416
422
|
/**
|
|
417
423
|
* One slot in a batch response's `results` array. Callers switch on
|
|
418
424
|
* `is_ok()` — on `true`, read `unwrap()`; on `false`, read `error()`.
|
|
419
425
|
*/
|
|
420
|
-
|
|
426
|
+
class BatchItemUnsignedResult {
|
|
421
427
|
static __wrap(ptr) {
|
|
422
428
|
const obj = Object.create(BatchItemUnsignedResult.prototype);
|
|
423
429
|
obj.__wbg_ptr = ptr;
|
|
@@ -472,11 +478,12 @@ export class BatchItemUnsignedResult {
|
|
|
472
478
|
}
|
|
473
479
|
}
|
|
474
480
|
if (Symbol.dispose) BatchItemUnsignedResult.prototype[Symbol.dispose] = BatchItemUnsignedResult.prototype.free;
|
|
481
|
+
exports.BatchItemUnsignedResult = BatchItemUnsignedResult;
|
|
475
482
|
|
|
476
483
|
/**
|
|
477
484
|
* The instance of the Cedarling application.
|
|
478
485
|
*/
|
|
479
|
-
|
|
486
|
+
class Cedarling {
|
|
480
487
|
static __wrap(ptr) {
|
|
481
488
|
const obj = Object.create(Cedarling.prototype);
|
|
482
489
|
obj.__wbg_ptr = ptr;
|
|
@@ -506,21 +513,24 @@ export class Cedarling {
|
|
|
506
513
|
* # Example
|
|
507
514
|
*
|
|
508
515
|
* ```javascript
|
|
509
|
-
* const redirects = cedarling.
|
|
516
|
+
* const redirects = cedarling.annotationValues(
|
|
517
|
+
* result.response.diagnostics.reason,
|
|
518
|
+
* "redirect",
|
|
519
|
+
* );
|
|
510
520
|
* // ["/upgrade"]
|
|
511
521
|
* ```
|
|
512
522
|
* @param {string[]} policy_ids
|
|
513
523
|
* @param {string} key
|
|
514
524
|
* @returns {string[]}
|
|
515
525
|
*/
|
|
516
|
-
|
|
526
|
+
annotationValues(policy_ids, key) {
|
|
517
527
|
try {
|
|
518
528
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
519
529
|
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
520
530
|
const len0 = WASM_VECTOR_LEN;
|
|
521
531
|
const ptr1 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
522
532
|
const len1 = WASM_VECTOR_LEN;
|
|
523
|
-
wasm.
|
|
533
|
+
wasm.cedarling_annotationValues(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
524
534
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
525
535
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
526
536
|
var v3 = getArrayJsValueFromWasm0(r0, r1);
|
|
@@ -531,8 +541,8 @@ export class Cedarling {
|
|
|
531
541
|
}
|
|
532
542
|
}
|
|
533
543
|
/**
|
|
534
|
-
* Return the annotations of each given policy, grouped by policy ID
|
|
535
|
-
* 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
|
|
536
546
|
* silently skipped.
|
|
537
547
|
*
|
|
538
548
|
* # Arguments
|
|
@@ -544,18 +554,18 @@ export class Cedarling {
|
|
|
544
554
|
* # Example
|
|
545
555
|
*
|
|
546
556
|
* ```javascript
|
|
547
|
-
* const byPolicy = cedarling.
|
|
557
|
+
* const byPolicy = cedarling.annotationsByPolicy(result.response.diagnostics.reason);
|
|
548
558
|
* // { "5": { redirect: "/upgrade", tier: "premium" } }
|
|
549
559
|
* ```
|
|
550
560
|
* @param {string[]} policy_ids
|
|
551
561
|
* @returns {any}
|
|
552
562
|
*/
|
|
553
|
-
|
|
563
|
+
annotationsByPolicy(policy_ids) {
|
|
554
564
|
try {
|
|
555
565
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
556
566
|
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
557
567
|
const len0 = WASM_VECTOR_LEN;
|
|
558
|
-
wasm.
|
|
568
|
+
wasm.cedarling_annotationsByPolicy(retptr, this.__wbg_ptr, ptr0, len0);
|
|
559
569
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
560
570
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
561
571
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -574,7 +584,7 @@ export class Cedarling {
|
|
|
574
584
|
* pass `result.response.diagnostics.reason`.
|
|
575
585
|
*
|
|
576
586
|
* Lossy: if the same annotation key appears on several policies, one value wins
|
|
577
|
-
* arbitrarily. Use `
|
|
587
|
+
* arbitrarily. Use `annotationValues` / `annotationsByPolicy` when duplicates
|
|
578
588
|
* matter. Unknown policy IDs are silently skipped.
|
|
579
589
|
*
|
|
580
590
|
* # Arguments
|
|
@@ -586,18 +596,18 @@ export class Cedarling {
|
|
|
586
596
|
* # Example
|
|
587
597
|
*
|
|
588
598
|
* ```javascript
|
|
589
|
-
* const annotations = cedarling.
|
|
599
|
+
* const annotations = cedarling.annotationsMap(result.response.diagnostics.reason);
|
|
590
600
|
* // { redirect: "/upgrade", tier: "premium" }
|
|
591
601
|
* ```
|
|
592
602
|
* @param {string[]} policy_ids
|
|
593
603
|
* @returns {any}
|
|
594
604
|
*/
|
|
595
|
-
|
|
605
|
+
annotationsMap(policy_ids) {
|
|
596
606
|
try {
|
|
597
607
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
598
608
|
const ptr0 = passArrayJsValueToWasm0(policy_ids, wasm.__wbindgen_export);
|
|
599
609
|
const len0 = WASM_VECTOR_LEN;
|
|
600
|
-
wasm.
|
|
610
|
+
wasm.cedarling_annotationsMap(retptr, this.__wbg_ptr, ptr0, len0);
|
|
601
611
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
602
612
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
603
613
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -620,15 +630,15 @@ export class Cedarling {
|
|
|
620
630
|
* # Example
|
|
621
631
|
*
|
|
622
632
|
* ```javascript
|
|
623
|
-
* const result = await cedarling.
|
|
633
|
+
* const result = await cedarling.authorizeMultiIssuer(JSON.stringify(request));
|
|
624
634
|
* ```
|
|
625
635
|
* @param {string} request
|
|
626
636
|
* @returns {Promise<MultiIssuerAuthorizeResult>}
|
|
627
637
|
*/
|
|
628
|
-
|
|
638
|
+
authorizeMultiIssuer(request) {
|
|
629
639
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
630
640
|
const len0 = WASM_VECTOR_LEN;
|
|
631
|
-
const ret = wasm.
|
|
641
|
+
const ret = wasm.cedarling_authorizeMultiIssuer(this.__wbg_ptr, ptr0, len0);
|
|
632
642
|
return takeObject(ret);
|
|
633
643
|
}
|
|
634
644
|
/**
|
|
@@ -648,15 +658,15 @@ export class Cedarling {
|
|
|
648
658
|
* # Example
|
|
649
659
|
*
|
|
650
660
|
* ```javascript
|
|
651
|
-
* const result = await cedarling.
|
|
661
|
+
* const result = await cedarling.authorizeMultiIssuerBatch(JSON.stringify(batchRequest));
|
|
652
662
|
* ```
|
|
653
663
|
* @param {string} request
|
|
654
664
|
* @returns {Promise<BatchAuthorizeMultiIssuerResponse>}
|
|
655
665
|
*/
|
|
656
|
-
|
|
666
|
+
authorizeMultiIssuerBatch(request) {
|
|
657
667
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
658
668
|
const len0 = WASM_VECTOR_LEN;
|
|
659
|
-
const ret = wasm.
|
|
669
|
+
const ret = wasm.cedarling_authorizeMultiIssuerBatch(this.__wbg_ptr, ptr0, len0);
|
|
660
670
|
return takeObject(ret);
|
|
661
671
|
}
|
|
662
672
|
/**
|
|
@@ -675,15 +685,15 @@ export class Cedarling {
|
|
|
675
685
|
* # Example
|
|
676
686
|
*
|
|
677
687
|
* ```javascript
|
|
678
|
-
* const result = await cedarling.
|
|
688
|
+
* const result = await cedarling.authorizeUnsigned(JSON.stringify(request));
|
|
679
689
|
* ```
|
|
680
690
|
* @param {string} request
|
|
681
691
|
* @returns {Promise<AuthorizeResult>}
|
|
682
692
|
*/
|
|
683
|
-
|
|
693
|
+
authorizeUnsigned(request) {
|
|
684
694
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
685
695
|
const len0 = WASM_VECTOR_LEN;
|
|
686
|
-
const ret = wasm.
|
|
696
|
+
const ret = wasm.cedarling_authorizeUnsigned(this.__wbg_ptr, ptr0, len0);
|
|
687
697
|
return takeObject(ret);
|
|
688
698
|
}
|
|
689
699
|
/**
|
|
@@ -703,31 +713,35 @@ export class Cedarling {
|
|
|
703
713
|
* # Example
|
|
704
714
|
*
|
|
705
715
|
* ```javascript
|
|
706
|
-
* const result = await cedarling.
|
|
716
|
+
* const result = await cedarling.authorizeUnsignedBatch(JSON.stringify(batchRequest));
|
|
707
717
|
* ```
|
|
708
718
|
* @param {string} request
|
|
709
719
|
* @returns {Promise<BatchAuthorizeUnsignedResponse>}
|
|
710
720
|
*/
|
|
711
|
-
|
|
721
|
+
authorizeUnsignedBatch(request) {
|
|
712
722
|
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
713
723
|
const len0 = WASM_VECTOR_LEN;
|
|
714
|
-
const ret = wasm.
|
|
724
|
+
const ret = wasm.cedarling_authorizeUnsignedBatch(this.__wbg_ptr, ptr0, len0);
|
|
715
725
|
return takeObject(ret);
|
|
716
726
|
}
|
|
717
727
|
/**
|
|
718
728
|
* Clear all entries from the data store.
|
|
719
729
|
*
|
|
730
|
+
* # Arguments
|
|
731
|
+
*
|
|
732
|
+
* None.
|
|
733
|
+
*
|
|
720
734
|
* # Example
|
|
721
735
|
*
|
|
722
736
|
* ```javascript
|
|
723
|
-
* cedarling.
|
|
737
|
+
* cedarling.clearDataCtx();
|
|
724
738
|
* console.log("All data entries cleared");
|
|
725
739
|
* ```
|
|
726
740
|
*/
|
|
727
|
-
|
|
741
|
+
clearDataCtx() {
|
|
728
742
|
try {
|
|
729
743
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
730
|
-
wasm.
|
|
744
|
+
wasm.cedarling_clearDataCtx(retptr, this.__wbg_ptr);
|
|
731
745
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
732
746
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
733
747
|
if (r1) {
|
|
@@ -740,15 +754,19 @@ export class Cedarling {
|
|
|
740
754
|
/**
|
|
741
755
|
* Get trusted issuer identifiers that failed to load.
|
|
742
756
|
*
|
|
757
|
+
* # Arguments
|
|
758
|
+
*
|
|
759
|
+
* None.
|
|
760
|
+
*
|
|
743
761
|
* # Example
|
|
744
762
|
*
|
|
745
763
|
* ```javascript
|
|
746
|
-
* const ids = cedarling.
|
|
764
|
+
* const ids = cedarling.failedTrustedIssuerIds();
|
|
747
765
|
* ```
|
|
748
766
|
* @returns {Array<any>}
|
|
749
767
|
*/
|
|
750
|
-
|
|
751
|
-
const ret = wasm.
|
|
768
|
+
failedTrustedIssuerIds() {
|
|
769
|
+
const ret = wasm.cedarling_failedTrustedIssuerIds(this.__wbg_ptr);
|
|
752
770
|
return takeObject(ret);
|
|
753
771
|
}
|
|
754
772
|
/**
|
|
@@ -762,7 +780,7 @@ export class Cedarling {
|
|
|
762
780
|
* # Example
|
|
763
781
|
*
|
|
764
782
|
* ```javascript
|
|
765
|
-
* const value = cedarling.
|
|
783
|
+
* const value = cedarling.getDataCtx("user:123");
|
|
766
784
|
* if (value !== null) {
|
|
767
785
|
* console.log(value.name); // "John"
|
|
768
786
|
* }
|
|
@@ -770,12 +788,12 @@ export class Cedarling {
|
|
|
770
788
|
* @param {string} key
|
|
771
789
|
* @returns {any}
|
|
772
790
|
*/
|
|
773
|
-
|
|
791
|
+
getDataCtx(key) {
|
|
774
792
|
try {
|
|
775
793
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
776
794
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
777
795
|
const len0 = WASM_VECTOR_LEN;
|
|
778
|
-
wasm.
|
|
796
|
+
wasm.cedarling_getDataCtx(retptr, this.__wbg_ptr, ptr0, len0);
|
|
779
797
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
780
798
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
781
799
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -789,7 +807,7 @@ export class Cedarling {
|
|
|
789
807
|
}
|
|
790
808
|
/**
|
|
791
809
|
* Get a data entry with full metadata by key.
|
|
792
|
-
* Returns
|
|
810
|
+
* Returns undefined if the key doesn't exist or the entry has expired.
|
|
793
811
|
*
|
|
794
812
|
* # Arguments
|
|
795
813
|
*
|
|
@@ -798,10 +816,10 @@ export class Cedarling {
|
|
|
798
816
|
* # Example
|
|
799
817
|
*
|
|
800
818
|
* ```javascript
|
|
801
|
-
* const entry = cedarling.
|
|
802
|
-
* if (entry !==
|
|
819
|
+
* const entry = cedarling.getDataEntryCtx("user:123");
|
|
820
|
+
* if (entry !== undefined) {
|
|
803
821
|
* console.log(entry.key); // "user:123"
|
|
804
|
-
* console.log(entry.value); // { name: "John", age: 30 }
|
|
822
|
+
* console.log(entry.value()); // { name: "John", age: 30 }
|
|
805
823
|
* console.log(entry.data_type); // "Record"
|
|
806
824
|
* console.log(entry.created_at); // "2024-01-01T12:00:00Z"
|
|
807
825
|
* console.log(entry.access_count); // 5
|
|
@@ -810,12 +828,12 @@ export class Cedarling {
|
|
|
810
828
|
* @param {string} key
|
|
811
829
|
* @returns {DataEntry | undefined}
|
|
812
830
|
*/
|
|
813
|
-
|
|
831
|
+
getDataEntryCtx(key) {
|
|
814
832
|
try {
|
|
815
833
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
816
834
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
817
835
|
const len0 = WASM_VECTOR_LEN;
|
|
818
|
-
wasm.
|
|
836
|
+
wasm.cedarling_getDataEntryCtx(retptr, this.__wbg_ptr, ptr0, len0);
|
|
819
837
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
820
838
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
821
839
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -828,17 +846,26 @@ export class Cedarling {
|
|
|
828
846
|
}
|
|
829
847
|
}
|
|
830
848
|
/**
|
|
831
|
-
*
|
|
832
|
-
*
|
|
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
|
+
* ```
|
|
833
860
|
* @param {string} id
|
|
834
861
|
* @returns {any}
|
|
835
862
|
*/
|
|
836
|
-
|
|
863
|
+
getLogById(id) {
|
|
837
864
|
try {
|
|
838
865
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
839
866
|
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
840
867
|
const len0 = WASM_VECTOR_LEN;
|
|
841
|
-
wasm.
|
|
868
|
+
wasm.cedarling_getLogById(retptr, this.__wbg_ptr, ptr0, len0);
|
|
842
869
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
843
870
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
844
871
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -851,26 +878,44 @@ export class Cedarling {
|
|
|
851
878
|
}
|
|
852
879
|
}
|
|
853
880
|
/**
|
|
854
|
-
* Returns
|
|
855
|
-
*
|
|
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
|
+
* ```
|
|
856
892
|
* @returns {Array<any>}
|
|
857
893
|
*/
|
|
858
|
-
|
|
859
|
-
const ret = wasm.
|
|
894
|
+
getLogIds() {
|
|
895
|
+
const ret = wasm.cedarling_getLogIds(this.__wbg_ptr);
|
|
860
896
|
return takeObject(ret);
|
|
861
897
|
}
|
|
862
898
|
/**
|
|
863
|
-
*
|
|
864
|
-
*
|
|
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
|
+
* ```
|
|
865
910
|
* @param {string} request_id
|
|
866
911
|
* @returns {any[]}
|
|
867
912
|
*/
|
|
868
|
-
|
|
913
|
+
getLogsByRequestId(request_id) {
|
|
869
914
|
try {
|
|
870
915
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
871
916
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
872
917
|
const len0 = WASM_VECTOR_LEN;
|
|
873
|
-
wasm.
|
|
918
|
+
wasm.cedarling_getLogsByRequestId(retptr, this.__wbg_ptr, ptr0, len0);
|
|
874
919
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
875
920
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
876
921
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -886,21 +931,31 @@ export class Cedarling {
|
|
|
886
931
|
}
|
|
887
932
|
}
|
|
888
933
|
/**
|
|
889
|
-
*
|
|
890
|
-
*
|
|
891
|
-
*
|
|
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
|
+
* ```
|
|
892
947
|
* @param {string} request_id
|
|
893
948
|
* @param {string} tag
|
|
894
949
|
* @returns {any[]}
|
|
895
950
|
*/
|
|
896
|
-
|
|
951
|
+
getLogsByRequestIdAndTag(request_id, tag) {
|
|
897
952
|
try {
|
|
898
953
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
899
954
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
900
955
|
const len0 = WASM_VECTOR_LEN;
|
|
901
956
|
const ptr1 = passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
902
957
|
const len1 = WASM_VECTOR_LEN;
|
|
903
|
-
wasm.
|
|
958
|
+
wasm.cedarling_getLogsByRequestIdAndTag(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
904
959
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
905
960
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
906
961
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -916,17 +971,27 @@ export class Cedarling {
|
|
|
916
971
|
}
|
|
917
972
|
}
|
|
918
973
|
/**
|
|
919
|
-
*
|
|
920
|
-
*
|
|
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
|
+
* ```
|
|
921
986
|
* @param {string} tag
|
|
922
987
|
* @returns {any[]}
|
|
923
988
|
*/
|
|
924
|
-
|
|
989
|
+
getLogsByTag(tag) {
|
|
925
990
|
try {
|
|
926
991
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
927
992
|
const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
928
993
|
const len0 = WASM_VECTOR_LEN;
|
|
929
|
-
wasm.
|
|
994
|
+
wasm.cedarling_getLogsByTag(retptr, this.__wbg_ptr, ptr0, len0);
|
|
930
995
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
931
996
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
932
997
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -944,20 +1009,24 @@ export class Cedarling {
|
|
|
944
1009
|
/**
|
|
945
1010
|
* Get statistics about the data store.
|
|
946
1011
|
*
|
|
1012
|
+
* # Arguments
|
|
1013
|
+
*
|
|
1014
|
+
* None.
|
|
1015
|
+
*
|
|
947
1016
|
* # Example
|
|
948
1017
|
*
|
|
949
1018
|
* ```javascript
|
|
950
|
-
* const stats = cedarling.
|
|
1019
|
+
* const stats = cedarling.getStatsCtx();
|
|
951
1020
|
* console.log(`Entries: ${stats.entry_count}/${stats.max_entries || 'unlimited'}`);
|
|
952
1021
|
* console.log(`Capacity: ${stats.capacity_usage_percent.toFixed(2)}%`);
|
|
953
1022
|
* console.log(`Total size: ${stats.total_size_bytes} bytes`);
|
|
954
1023
|
* ```
|
|
955
1024
|
* @returns {DataStoreStats}
|
|
956
1025
|
*/
|
|
957
|
-
|
|
1026
|
+
getStatsCtx() {
|
|
958
1027
|
try {
|
|
959
1028
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
960
|
-
wasm.
|
|
1029
|
+
wasm.cedarling_getStatsCtx(retptr, this.__wbg_ptr);
|
|
961
1030
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
962
1031
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
963
1032
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -979,15 +1048,15 @@ export class Cedarling {
|
|
|
979
1048
|
* # Example
|
|
980
1049
|
*
|
|
981
1050
|
* ```javascript
|
|
982
|
-
* const ok = cedarling.
|
|
1051
|
+
* const ok = cedarling.isTrustedIssuerLoadedByIss("https://issuer.example.org");
|
|
983
1052
|
* ```
|
|
984
1053
|
* @param {string} iss_claim
|
|
985
1054
|
* @returns {boolean}
|
|
986
1055
|
*/
|
|
987
|
-
|
|
1056
|
+
isTrustedIssuerLoadedByIss(iss_claim) {
|
|
988
1057
|
const ptr0 = passStringToWasm0(iss_claim, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
989
1058
|
const len0 = WASM_VECTOR_LEN;
|
|
990
|
-
const ret = wasm.
|
|
1059
|
+
const ret = wasm.cedarling_isTrustedIssuerLoadedByIss(this.__wbg_ptr, ptr0, len0);
|
|
991
1060
|
return ret !== 0;
|
|
992
1061
|
}
|
|
993
1062
|
/**
|
|
@@ -1000,35 +1069,39 @@ export class Cedarling {
|
|
|
1000
1069
|
* # Example
|
|
1001
1070
|
*
|
|
1002
1071
|
* ```javascript
|
|
1003
|
-
* const ok = cedarling.
|
|
1072
|
+
* const ok = cedarling.isTrustedIssuerLoadedByName("issuer_id");
|
|
1004
1073
|
* ```
|
|
1005
1074
|
* @param {string} issuer_id
|
|
1006
1075
|
* @returns {boolean}
|
|
1007
1076
|
*/
|
|
1008
|
-
|
|
1077
|
+
isTrustedIssuerLoadedByName(issuer_id) {
|
|
1009
1078
|
const ptr0 = passStringToWasm0(issuer_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1010
1079
|
const len0 = WASM_VECTOR_LEN;
|
|
1011
|
-
const ret = wasm.
|
|
1080
|
+
const ret = wasm.cedarling_isTrustedIssuerLoadedByName(this.__wbg_ptr, ptr0, len0);
|
|
1012
1081
|
return ret !== 0;
|
|
1013
1082
|
}
|
|
1014
1083
|
/**
|
|
1015
1084
|
* List all entries with their metadata.
|
|
1016
1085
|
* Returns an array of DataEntry objects.
|
|
1017
1086
|
*
|
|
1087
|
+
* # Arguments
|
|
1088
|
+
*
|
|
1089
|
+
* None.
|
|
1090
|
+
*
|
|
1018
1091
|
* # Example
|
|
1019
1092
|
*
|
|
1020
1093
|
* ```javascript
|
|
1021
|
-
* const entries = cedarling.
|
|
1094
|
+
* const entries = cedarling.listDataCtx();
|
|
1022
1095
|
* entries.forEach(entry => {
|
|
1023
1096
|
* console.log(`${entry.key}: ${entry.data_type} (accessed ${entry.access_count} times)`);
|
|
1024
1097
|
* });
|
|
1025
1098
|
* ```
|
|
1026
1099
|
* @returns {Array<any>}
|
|
1027
1100
|
*/
|
|
1028
|
-
|
|
1101
|
+
listDataCtx() {
|
|
1029
1102
|
try {
|
|
1030
1103
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1031
|
-
wasm.
|
|
1104
|
+
wasm.cedarling_listDataCtx(retptr, this.__wbg_ptr);
|
|
1032
1105
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1033
1106
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1034
1107
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1043,34 +1116,57 @@ export class Cedarling {
|
|
|
1043
1116
|
/**
|
|
1044
1117
|
* Get trusted issuer identifiers loaded successfully.
|
|
1045
1118
|
*
|
|
1119
|
+
* # Arguments
|
|
1120
|
+
*
|
|
1121
|
+
* None.
|
|
1122
|
+
*
|
|
1046
1123
|
* # Example
|
|
1047
1124
|
*
|
|
1048
1125
|
* ```javascript
|
|
1049
|
-
* const ids = cedarling.
|
|
1126
|
+
* const ids = cedarling.loadedTrustedIssuerIds();
|
|
1050
1127
|
* ```
|
|
1051
1128
|
* @returns {Array<any>}
|
|
1052
1129
|
*/
|
|
1053
|
-
|
|
1054
|
-
const ret = wasm.
|
|
1130
|
+
loadedTrustedIssuerIds() {
|
|
1131
|
+
const ret = wasm.cedarling_loadedTrustedIssuerIds(this.__wbg_ptr);
|
|
1055
1132
|
return takeObject(ret);
|
|
1056
1133
|
}
|
|
1057
1134
|
/**
|
|
1058
1135
|
* Get the number of trusted issuers loaded successfully.
|
|
1059
1136
|
*
|
|
1137
|
+
* # Arguments
|
|
1138
|
+
*
|
|
1139
|
+
* None.
|
|
1140
|
+
*
|
|
1060
1141
|
* # Example
|
|
1061
1142
|
*
|
|
1062
1143
|
* ```javascript
|
|
1063
|
-
* const loadedCount = cedarling.
|
|
1144
|
+
* const loadedCount = cedarling.loadedTrustedIssuersCount();
|
|
1064
1145
|
* ```
|
|
1065
1146
|
* @returns {number}
|
|
1066
1147
|
*/
|
|
1067
|
-
|
|
1068
|
-
const ret = wasm.
|
|
1148
|
+
loadedTrustedIssuersCount() {
|
|
1149
|
+
const ret = wasm.cedarling_loadedTrustedIssuersCount(this.__wbg_ptr);
|
|
1069
1150
|
return ret >>> 0;
|
|
1070
1151
|
}
|
|
1071
1152
|
/**
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
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
|
+
* ```
|
|
1074
1170
|
* @param {object} config
|
|
1075
1171
|
* @returns {Promise<Cedarling>}
|
|
1076
1172
|
*/
|
|
@@ -1079,24 +1175,49 @@ export class Cedarling {
|
|
|
1079
1175
|
return takeObject(ret);
|
|
1080
1176
|
}
|
|
1081
1177
|
/**
|
|
1082
|
-
*
|
|
1083
|
-
*
|
|
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
|
+
* ```
|
|
1084
1195
|
* @param {Map<any, any>} config
|
|
1085
1196
|
* @returns {Promise<Cedarling>}
|
|
1086
1197
|
*/
|
|
1087
|
-
static
|
|
1088
|
-
const ret = wasm.
|
|
1198
|
+
static newFromMap(config) {
|
|
1199
|
+
const ret = wasm.cedarling_newFromMap(addHeapObject(config));
|
|
1089
1200
|
return takeObject(ret);
|
|
1090
1201
|
}
|
|
1091
1202
|
/**
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
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
|
+
* ```
|
|
1094
1215
|
* @returns {Array<any>}
|
|
1095
1216
|
*/
|
|
1096
|
-
|
|
1217
|
+
popLogs() {
|
|
1097
1218
|
try {
|
|
1098
1219
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1099
|
-
wasm.
|
|
1220
|
+
wasm.cedarling_popLogs(retptr, this.__wbg_ptr);
|
|
1100
1221
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1101
1222
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1102
1223
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1122,19 +1243,19 @@ export class Cedarling {
|
|
|
1122
1243
|
* # Example
|
|
1123
1244
|
*
|
|
1124
1245
|
* ```javascript
|
|
1125
|
-
* cedarling.
|
|
1126
|
-
* cedarling.
|
|
1246
|
+
* cedarling.pushDataCtx("user:123", { name: "John", age: 30 }, 3600);
|
|
1247
|
+
* cedarling.pushDataCtx("config", { setting: "value" }); // Uses default TTL
|
|
1127
1248
|
* ```
|
|
1128
1249
|
* @param {string} key
|
|
1129
1250
|
* @param {any} value
|
|
1130
1251
|
* @param {bigint | null} [ttl_secs]
|
|
1131
1252
|
*/
|
|
1132
|
-
|
|
1253
|
+
pushDataCtx(key, value, ttl_secs) {
|
|
1133
1254
|
try {
|
|
1134
1255
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1135
1256
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1136
1257
|
const len0 = WASM_VECTOR_LEN;
|
|
1137
|
-
wasm.
|
|
1258
|
+
wasm.cedarling_pushDataCtx(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value), !isLikeNone(ttl_secs), isLikeNone(ttl_secs) ? BigInt(0) : ttl_secs);
|
|
1138
1259
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1139
1260
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1140
1261
|
if (r1) {
|
|
@@ -1155,7 +1276,7 @@ export class Cedarling {
|
|
|
1155
1276
|
* # Example
|
|
1156
1277
|
*
|
|
1157
1278
|
* ```javascript
|
|
1158
|
-
* const removed = cedarling.
|
|
1279
|
+
* const removed = cedarling.removeDataCtx("user:123");
|
|
1159
1280
|
* if (removed) {
|
|
1160
1281
|
* console.log("Entry was successfully removed");
|
|
1161
1282
|
* }
|
|
@@ -1163,12 +1284,12 @@ export class Cedarling {
|
|
|
1163
1284
|
* @param {string} key
|
|
1164
1285
|
* @returns {boolean}
|
|
1165
1286
|
*/
|
|
1166
|
-
|
|
1287
|
+
removeDataCtx(key) {
|
|
1167
1288
|
try {
|
|
1168
1289
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1169
1290
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1170
1291
|
const len0 = WASM_VECTOR_LEN;
|
|
1171
|
-
wasm.
|
|
1292
|
+
wasm.cedarling_removeDataCtx(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1172
1293
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1173
1294
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1174
1295
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1181,35 +1302,50 @@ export class Cedarling {
|
|
|
1181
1302
|
}
|
|
1182
1303
|
}
|
|
1183
1304
|
/**
|
|
1184
|
-
* 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
|
+
* ```
|
|
1185
1316
|
* @returns {Promise<void>}
|
|
1186
1317
|
*/
|
|
1187
|
-
|
|
1188
|
-
const ret = wasm.
|
|
1318
|
+
shutDown() {
|
|
1319
|
+
const ret = wasm.cedarling_shutDown(this.__wbg_ptr);
|
|
1189
1320
|
return takeObject(ret);
|
|
1190
1321
|
}
|
|
1191
1322
|
/**
|
|
1192
1323
|
* Get the total number of trusted issuer entries discovered.
|
|
1193
1324
|
*
|
|
1325
|
+
* # Arguments
|
|
1326
|
+
*
|
|
1327
|
+
* None.
|
|
1328
|
+
*
|
|
1194
1329
|
* # Example
|
|
1195
1330
|
*
|
|
1196
1331
|
* ```javascript
|
|
1197
|
-
* const total = cedarling.
|
|
1332
|
+
* const total = cedarling.totalIssuers();
|
|
1198
1333
|
* ```
|
|
1199
1334
|
* @returns {number}
|
|
1200
1335
|
*/
|
|
1201
|
-
|
|
1202
|
-
const ret = wasm.
|
|
1336
|
+
totalIssuers() {
|
|
1337
|
+
const ret = wasm.cedarling_totalIssuers(this.__wbg_ptr);
|
|
1203
1338
|
return ret >>> 0;
|
|
1204
1339
|
}
|
|
1205
1340
|
}
|
|
1206
1341
|
if (Symbol.dispose) Cedarling.prototype[Symbol.dispose] = Cedarling.prototype.free;
|
|
1342
|
+
exports.Cedarling = Cedarling;
|
|
1207
1343
|
|
|
1208
1344
|
/**
|
|
1209
1345
|
* A WASM wrapper for the Rust `cedarling::DataEntry` struct.
|
|
1210
1346
|
* Represents a data entry in the DataStore with value and metadata.
|
|
1211
1347
|
*/
|
|
1212
|
-
|
|
1348
|
+
class DataEntry {
|
|
1213
1349
|
static __wrap(ptr) {
|
|
1214
1350
|
const obj = Object.create(DataEntry.prototype);
|
|
1215
1351
|
obj.__wbg_ptr = ptr;
|
|
@@ -1230,12 +1366,12 @@ export class DataEntry {
|
|
|
1230
1366
|
* Convert `DataEntry` to json string value
|
|
1231
1367
|
* @returns {string}
|
|
1232
1368
|
*/
|
|
1233
|
-
|
|
1369
|
+
jsonString() {
|
|
1234
1370
|
let deferred1_0;
|
|
1235
1371
|
let deferred1_1;
|
|
1236
1372
|
try {
|
|
1237
1373
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1238
|
-
wasm.
|
|
1374
|
+
wasm.dataentry_jsonString(retptr, this.__wbg_ptr);
|
|
1239
1375
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1240
1376
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1241
1377
|
deferred1_0 = r0;
|
|
@@ -1314,7 +1450,7 @@ export class DataEntry {
|
|
|
1314
1450
|
}
|
|
1315
1451
|
}
|
|
1316
1452
|
/**
|
|
1317
|
-
* Timestamp when this entry expires (RFC 3339 format)
|
|
1453
|
+
* Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
|
|
1318
1454
|
* @returns {string | undefined}
|
|
1319
1455
|
*/
|
|
1320
1456
|
get expires_at() {
|
|
@@ -1379,7 +1515,7 @@ export class DataEntry {
|
|
|
1379
1515
|
wasm.__wbg_set_dataentry_data_type(this.__wbg_ptr, ptr0, len0);
|
|
1380
1516
|
}
|
|
1381
1517
|
/**
|
|
1382
|
-
* Timestamp when this entry expires (RFC 3339 format)
|
|
1518
|
+
* Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
|
|
1383
1519
|
* @param {string | null} [arg0]
|
|
1384
1520
|
*/
|
|
1385
1521
|
set expires_at(arg0) {
|
|
@@ -1398,12 +1534,13 @@ export class DataEntry {
|
|
|
1398
1534
|
}
|
|
1399
1535
|
}
|
|
1400
1536
|
if (Symbol.dispose) DataEntry.prototype[Symbol.dispose] = DataEntry.prototype.free;
|
|
1537
|
+
exports.DataEntry = DataEntry;
|
|
1401
1538
|
|
|
1402
1539
|
/**
|
|
1403
1540
|
* A WASM wrapper for the Rust `cedarling::DataStoreStats` struct.
|
|
1404
1541
|
* Statistics about the DataStore.
|
|
1405
1542
|
*/
|
|
1406
|
-
|
|
1543
|
+
class DataStoreStats {
|
|
1407
1544
|
static __wrap(ptr) {
|
|
1408
1545
|
const obj = Object.create(DataStoreStats.prototype);
|
|
1409
1546
|
obj.__wbg_ptr = ptr;
|
|
@@ -1424,12 +1561,12 @@ export class DataStoreStats {
|
|
|
1424
1561
|
* Convert `DataStoreStats` to json string value
|
|
1425
1562
|
* @returns {string}
|
|
1426
1563
|
*/
|
|
1427
|
-
|
|
1564
|
+
jsonString() {
|
|
1428
1565
|
let deferred1_0;
|
|
1429
1566
|
let deferred1_1;
|
|
1430
1567
|
try {
|
|
1431
1568
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1432
|
-
wasm.
|
|
1569
|
+
wasm.datastorestats_jsonString(retptr, this.__wbg_ptr);
|
|
1433
1570
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1434
1571
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1435
1572
|
deferred1_0 = r0;
|
|
@@ -1577,6 +1714,7 @@ export class DataStoreStats {
|
|
|
1577
1714
|
}
|
|
1578
1715
|
}
|
|
1579
1716
|
if (Symbol.dispose) DataStoreStats.prototype[Symbol.dispose] = DataStoreStats.prototype.free;
|
|
1717
|
+
exports.DataStoreStats = DataStoreStats;
|
|
1580
1718
|
|
|
1581
1719
|
/**
|
|
1582
1720
|
* Diagnostics
|
|
@@ -1584,7 +1722,7 @@ if (Symbol.dispose) DataStoreStats.prototype[Symbol.dispose] = DataStoreStats.pr
|
|
|
1584
1722
|
*
|
|
1585
1723
|
* Provides detailed information about how a policy decision was made, including policies that contributed to the decision and any errors encountered during evaluation.
|
|
1586
1724
|
*/
|
|
1587
|
-
|
|
1725
|
+
class Diagnostics {
|
|
1588
1726
|
static __wrap(ptr) {
|
|
1589
1727
|
const obj = Object.create(Diagnostics.prototype);
|
|
1590
1728
|
obj.__wbg_ptr = ptr;
|
|
@@ -1641,8 +1779,9 @@ export class Diagnostics {
|
|
|
1641
1779
|
}
|
|
1642
1780
|
}
|
|
1643
1781
|
if (Symbol.dispose) Diagnostics.prototype[Symbol.dispose] = Diagnostics.prototype.free;
|
|
1782
|
+
exports.Diagnostics = Diagnostics;
|
|
1644
1783
|
|
|
1645
|
-
|
|
1784
|
+
class IntoUnderlyingByteSource {
|
|
1646
1785
|
__destroy_into_raw() {
|
|
1647
1786
|
const ptr = this.__wbg_ptr;
|
|
1648
1787
|
this.__wbg_ptr = 0;
|
|
@@ -1687,8 +1826,9 @@ export class IntoUnderlyingByteSource {
|
|
|
1687
1826
|
}
|
|
1688
1827
|
}
|
|
1689
1828
|
if (Symbol.dispose) IntoUnderlyingByteSource.prototype[Symbol.dispose] = IntoUnderlyingByteSource.prototype.free;
|
|
1829
|
+
exports.IntoUnderlyingByteSource = IntoUnderlyingByteSource;
|
|
1690
1830
|
|
|
1691
|
-
|
|
1831
|
+
class IntoUnderlyingSink {
|
|
1692
1832
|
__destroy_into_raw() {
|
|
1693
1833
|
const ptr = this.__wbg_ptr;
|
|
1694
1834
|
this.__wbg_ptr = 0;
|
|
@@ -1726,8 +1866,9 @@ export class IntoUnderlyingSink {
|
|
|
1726
1866
|
}
|
|
1727
1867
|
}
|
|
1728
1868
|
if (Symbol.dispose) IntoUnderlyingSink.prototype[Symbol.dispose] = IntoUnderlyingSink.prototype.free;
|
|
1869
|
+
exports.IntoUnderlyingSink = IntoUnderlyingSink;
|
|
1729
1870
|
|
|
1730
|
-
|
|
1871
|
+
class IntoUnderlyingSource {
|
|
1731
1872
|
__destroy_into_raw() {
|
|
1732
1873
|
const ptr = this.__wbg_ptr;
|
|
1733
1874
|
this.__wbg_ptr = 0;
|
|
@@ -1752,12 +1893,13 @@ export class IntoUnderlyingSource {
|
|
|
1752
1893
|
}
|
|
1753
1894
|
}
|
|
1754
1895
|
if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free;
|
|
1896
|
+
exports.IntoUnderlyingSource = IntoUnderlyingSource;
|
|
1755
1897
|
|
|
1756
1898
|
/**
|
|
1757
1899
|
* A WASM wrapper for the Rust `cedarling::MultiIssuerAuthorizeResult` struct.
|
|
1758
1900
|
* Represents the result of a multi-issuer authorization request.
|
|
1759
1901
|
*/
|
|
1760
|
-
|
|
1902
|
+
class MultiIssuerAuthorizeResult {
|
|
1761
1903
|
static __wrap(ptr) {
|
|
1762
1904
|
const obj = Object.create(MultiIssuerAuthorizeResult.prototype);
|
|
1763
1905
|
obj.__wbg_ptr = ptr;
|
|
@@ -1816,12 +1958,12 @@ export class MultiIssuerAuthorizeResult {
|
|
|
1816
1958
|
* Convert `MultiIssuerAuthorizeResult` to json string value
|
|
1817
1959
|
* @returns {string}
|
|
1818
1960
|
*/
|
|
1819
|
-
|
|
1961
|
+
jsonString() {
|
|
1820
1962
|
let deferred1_0;
|
|
1821
1963
|
let deferred1_1;
|
|
1822
1964
|
try {
|
|
1823
1965
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1824
|
-
wasm.
|
|
1966
|
+
wasm.multiissuerauthorizeresult_jsonString(retptr, this.__wbg_ptr);
|
|
1825
1967
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1826
1968
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1827
1969
|
deferred1_0 = r0;
|
|
@@ -1861,6 +2003,7 @@ export class MultiIssuerAuthorizeResult {
|
|
|
1861
2003
|
}
|
|
1862
2004
|
}
|
|
1863
2005
|
if (Symbol.dispose) MultiIssuerAuthorizeResult.prototype[Symbol.dispose] = MultiIssuerAuthorizeResult.prototype.free;
|
|
2006
|
+
exports.MultiIssuerAuthorizeResult = MultiIssuerAuthorizeResult;
|
|
1864
2007
|
|
|
1865
2008
|
/**
|
|
1866
2009
|
* PolicyEvaluationError
|
|
@@ -1868,7 +2011,7 @@ if (Symbol.dispose) MultiIssuerAuthorizeResult.prototype[Symbol.dispose] = Multi
|
|
|
1868
2011
|
*
|
|
1869
2012
|
* Represents an error that occurred when evaluating a Cedar policy.
|
|
1870
2013
|
*/
|
|
1871
|
-
|
|
2014
|
+
class PolicyEvaluationError {
|
|
1872
2015
|
static __wrap(ptr) {
|
|
1873
2016
|
const obj = Object.create(PolicyEvaluationError.prototype);
|
|
1874
2017
|
obj.__wbg_ptr = ptr;
|
|
@@ -1927,17 +2070,35 @@ export class PolicyEvaluationError {
|
|
|
1927
2070
|
}
|
|
1928
2071
|
}
|
|
1929
2072
|
if (Symbol.dispose) PolicyEvaluationError.prototype[Symbol.dispose] = PolicyEvaluationError.prototype.free;
|
|
2073
|
+
exports.PolicyEvaluationError = PolicyEvaluationError;
|
|
1930
2074
|
|
|
1931
2075
|
/**
|
|
1932
|
-
*
|
|
1933
|
-
*
|
|
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
|
+
* ```
|
|
1934
2094
|
* @param {any} config
|
|
1935
2095
|
* @returns {Promise<Cedarling>}
|
|
1936
2096
|
*/
|
|
1937
|
-
|
|
2097
|
+
function init(config) {
|
|
1938
2098
|
const ret = wasm.init(addHeapObject(config));
|
|
1939
2099
|
return takeObject(ret);
|
|
1940
2100
|
}
|
|
2101
|
+
exports.init = init;
|
|
1941
2102
|
|
|
1942
2103
|
/**
|
|
1943
2104
|
* Create a new instance of the Cedarling application from archive bytes.
|
|
@@ -1946,23 +2107,34 @@ export function init(config) {
|
|
|
1946
2107
|
* that was fetched with custom logic (e.g., with authentication headers).
|
|
1947
2108
|
*
|
|
1948
2109
|
* # Arguments
|
|
1949
|
-
* * `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.
|
|
1950
2112
|
* * `archive_bytes` - The .cjar archive bytes (Uint8Array)
|
|
1951
2113
|
*
|
|
1952
2114
|
* # Example
|
|
1953
2115
|
* ```javascript
|
|
1954
|
-
*
|
|
1955
|
-
* const
|
|
1956
|
-
*
|
|
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);
|
|
1957
2128
|
* ```
|
|
1958
2129
|
* @param {any} config
|
|
1959
2130
|
* @param {Uint8Array} archive_bytes
|
|
1960
2131
|
* @returns {Promise<Cedarling>}
|
|
1961
2132
|
*/
|
|
1962
|
-
|
|
1963
|
-
const ret = wasm.
|
|
2133
|
+
function initFromArchiveBytes(config, archive_bytes) {
|
|
2134
|
+
const ret = wasm.initFromArchiveBytes(addHeapObject(config), addHeapObject(archive_bytes));
|
|
1964
2135
|
return takeObject(ret);
|
|
1965
2136
|
}
|
|
2137
|
+
exports.initFromArchiveBytes = initFromArchiveBytes;
|
|
1966
2138
|
function __wbg_get_imports() {
|
|
1967
2139
|
const import0 = {
|
|
1968
2140
|
__proto__: null,
|
|
@@ -2378,7 +2550,7 @@ function __wbg_get_imports() {
|
|
|
2378
2550
|
const a = state0.a;
|
|
2379
2551
|
state0.a = 0;
|
|
2380
2552
|
try {
|
|
2381
|
-
return
|
|
2553
|
+
return __wasm_bindgen_func_elem_8970(a, state0.b, arg0, arg1);
|
|
2382
2554
|
} finally {
|
|
2383
2555
|
state0.a = a;
|
|
2384
2556
|
}
|
|
@@ -2588,17 +2760,17 @@ function __wbg_get_imports() {
|
|
|
2588
2760
|
},
|
|
2589
2761
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
2590
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`.
|
|
2591
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2763
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8904);
|
|
2592
2764
|
return addHeapObject(ret);
|
|
2593
2765
|
},
|
|
2594
2766
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
2595
2767
|
// 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,
|
|
2768
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12454);
|
|
2597
2769
|
return addHeapObject(ret);
|
|
2598
2770
|
},
|
|
2599
2771
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
2600
2772
|
// 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,
|
|
2773
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_8739);
|
|
2602
2774
|
return addHeapObject(ret);
|
|
2603
2775
|
},
|
|
2604
2776
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
@@ -2640,18 +2812,18 @@ function __wbg_get_imports() {
|
|
|
2640
2812
|
};
|
|
2641
2813
|
}
|
|
2642
2814
|
|
|
2643
|
-
function
|
|
2644
|
-
wasm.
|
|
2815
|
+
function __wasm_bindgen_func_elem_8739(arg0, arg1) {
|
|
2816
|
+
wasm.__wasm_bindgen_func_elem_8739(arg0, arg1);
|
|
2645
2817
|
}
|
|
2646
2818
|
|
|
2647
|
-
function
|
|
2648
|
-
wasm.
|
|
2819
|
+
function __wasm_bindgen_func_elem_12454(arg0, arg1, arg2) {
|
|
2820
|
+
wasm.__wasm_bindgen_func_elem_12454(arg0, arg1, addHeapObject(arg2));
|
|
2649
2821
|
}
|
|
2650
2822
|
|
|
2651
|
-
function
|
|
2823
|
+
function __wasm_bindgen_func_elem_8904(arg0, arg1, arg2) {
|
|
2652
2824
|
try {
|
|
2653
2825
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2654
|
-
wasm.
|
|
2826
|
+
wasm.__wasm_bindgen_func_elem_8904(retptr, arg0, arg1, addHeapObject(arg2));
|
|
2655
2827
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2656
2828
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2657
2829
|
if (r1) {
|
|
@@ -2662,8 +2834,8 @@ function __wasm_bindgen_func_elem_8913(arg0, arg1, arg2) {
|
|
|
2662
2834
|
}
|
|
2663
2835
|
}
|
|
2664
2836
|
|
|
2665
|
-
function
|
|
2666
|
-
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));
|
|
2667
2839
|
}
|
|
2668
2840
|
|
|
2669
2841
|
|
|
@@ -2959,15 +3131,7 @@ function takeObject(idx) {
|
|
|
2959
3131
|
|
|
2960
3132
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
2961
3133
|
cachedTextDecoder.decode();
|
|
2962
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
2963
|
-
let numBytesDecoded = 0;
|
|
2964
3134
|
function decodeText(ptr, len) {
|
|
2965
|
-
numBytesDecoded += len;
|
|
2966
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
2967
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
2968
|
-
cachedTextDecoder.decode();
|
|
2969
|
-
numBytesDecoded = len;
|
|
2970
|
-
}
|
|
2971
3135
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
2972
3136
|
}
|
|
2973
3137
|
|
|
@@ -2986,99 +3150,8 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
2986
3150
|
|
|
2987
3151
|
let WASM_VECTOR_LEN = 0;
|
|
2988
3152
|
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
cachedDataViewMemory0 = null;
|
|
2995
|
-
cachedUint8ArrayMemory0 = null;
|
|
2996
|
-
return wasm;
|
|
2997
|
-
}
|
|
2998
|
-
|
|
2999
|
-
async function __wbg_load(module, imports) {
|
|
3000
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
3001
|
-
if (!module.ok) {
|
|
3002
|
-
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
3003
|
-
}
|
|
3004
|
-
|
|
3005
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
3006
|
-
try {
|
|
3007
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
3008
|
-
} catch (e) {
|
|
3009
|
-
const validResponse = expectedResponseType(module.type);
|
|
3010
|
-
|
|
3011
|
-
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
3012
|
-
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
3013
|
-
|
|
3014
|
-
} else { throw e; }
|
|
3015
|
-
}
|
|
3016
|
-
}
|
|
3017
|
-
|
|
3018
|
-
const bytes = await module.arrayBuffer();
|
|
3019
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
3020
|
-
} else {
|
|
3021
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
3022
|
-
|
|
3023
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
3024
|
-
return { instance, module };
|
|
3025
|
-
} else {
|
|
3026
|
-
return instance;
|
|
3027
|
-
}
|
|
3028
|
-
}
|
|
3029
|
-
|
|
3030
|
-
function expectedResponseType(type) {
|
|
3031
|
-
switch (type) {
|
|
3032
|
-
case 'basic': case 'cors': case 'default': return true;
|
|
3033
|
-
}
|
|
3034
|
-
return false;
|
|
3035
|
-
}
|
|
3036
|
-
}
|
|
3037
|
-
|
|
3038
|
-
function initSync(module) {
|
|
3039
|
-
if (wasm !== undefined) return wasm;
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
if (module !== undefined) {
|
|
3043
|
-
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
3044
|
-
({module} = module)
|
|
3045
|
-
} else {
|
|
3046
|
-
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
3047
|
-
}
|
|
3048
|
-
}
|
|
3049
|
-
|
|
3050
|
-
const imports = __wbg_get_imports();
|
|
3051
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
3052
|
-
module = new WebAssembly.Module(module);
|
|
3053
|
-
}
|
|
3054
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
3055
|
-
return __wbg_finalize_init(instance, module);
|
|
3056
|
-
}
|
|
3057
|
-
|
|
3058
|
-
async function __wbg_init(module_or_path) {
|
|
3059
|
-
if (wasm !== undefined) return wasm;
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
if (module_or_path !== undefined) {
|
|
3063
|
-
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
3064
|
-
({module_or_path} = module_or_path)
|
|
3065
|
-
} else {
|
|
3066
|
-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
3067
|
-
}
|
|
3068
|
-
}
|
|
3069
|
-
|
|
3070
|
-
if (module_or_path === undefined) {
|
|
3071
|
-
module_or_path = new URL('cedarling_wasm_bg.wasm', import.meta.url);
|
|
3072
|
-
}
|
|
3073
|
-
const imports = __wbg_get_imports();
|
|
3074
|
-
|
|
3075
|
-
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
3076
|
-
module_or_path = fetch(module_or_path);
|
|
3077
|
-
}
|
|
3078
|
-
|
|
3079
|
-
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
3080
|
-
|
|
3081
|
-
return __wbg_finalize_init(instance, module);
|
|
3082
|
-
}
|
|
3083
|
-
|
|
3084
|
-
export { initSync, __wbg_init as default };
|
|
3153
|
+
const wasmPath = `${__dirname}/cedarling_wasm_bg.wasm`;
|
|
3154
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
3155
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
3156
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
3157
|
+
let wasm = wasmInstance.exports;
|