@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.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export class AuthorizeResult {
|
|
|
19
19
|
/**
|
|
20
20
|
* Convert `AuthorizeResult` to json string value
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
jsonString(): string;
|
|
23
23
|
/**
|
|
24
24
|
* Result of authorization
|
|
25
25
|
* true means `ALLOW`
|
|
@@ -186,14 +186,17 @@ export class Cedarling {
|
|
|
186
186
|
* # Example
|
|
187
187
|
*
|
|
188
188
|
* ```javascript
|
|
189
|
-
* const redirects = cedarling.
|
|
189
|
+
* const redirects = cedarling.annotationValues(
|
|
190
|
+
* result.response.diagnostics.reason,
|
|
191
|
+
* "redirect",
|
|
192
|
+
* );
|
|
190
193
|
* // ["/upgrade"]
|
|
191
194
|
* ```
|
|
192
195
|
*/
|
|
193
|
-
|
|
196
|
+
annotationValues(policy_ids: string[], key: string): string[];
|
|
194
197
|
/**
|
|
195
|
-
* Return the annotations of each given policy, grouped by policy ID
|
|
196
|
-
* the loss-free companion to `
|
|
198
|
+
* Return the annotations of each given policy, grouped by policy ID. It is
|
|
199
|
+
* the loss-free companion to `annotationsMap`. Unknown policy IDs are
|
|
197
200
|
* silently skipped.
|
|
198
201
|
*
|
|
199
202
|
* # Arguments
|
|
@@ -205,11 +208,11 @@ export class Cedarling {
|
|
|
205
208
|
* # Example
|
|
206
209
|
*
|
|
207
210
|
* ```javascript
|
|
208
|
-
* const byPolicy = cedarling.
|
|
211
|
+
* const byPolicy = cedarling.annotationsByPolicy(result.response.diagnostics.reason);
|
|
209
212
|
* // { "5": { redirect: "/upgrade", tier: "premium" } }
|
|
210
213
|
* ```
|
|
211
214
|
*/
|
|
212
|
-
|
|
215
|
+
annotationsByPolicy(policy_ids: string[]): any;
|
|
213
216
|
/**
|
|
214
217
|
* Merge the annotations (`@key("value")`) of the given policies into a single object.
|
|
215
218
|
*
|
|
@@ -217,7 +220,7 @@ export class Cedarling {
|
|
|
217
220
|
* pass `result.response.diagnostics.reason`.
|
|
218
221
|
*
|
|
219
222
|
* Lossy: if the same annotation key appears on several policies, one value wins
|
|
220
|
-
* arbitrarily. Use `
|
|
223
|
+
* arbitrarily. Use `annotationValues` / `annotationsByPolicy` when duplicates
|
|
221
224
|
* matter. Unknown policy IDs are silently skipped.
|
|
222
225
|
*
|
|
223
226
|
* # Arguments
|
|
@@ -229,11 +232,11 @@ export class Cedarling {
|
|
|
229
232
|
* # Example
|
|
230
233
|
*
|
|
231
234
|
* ```javascript
|
|
232
|
-
* const annotations = cedarling.
|
|
235
|
+
* const annotations = cedarling.annotationsMap(result.response.diagnostics.reason);
|
|
233
236
|
* // { redirect: "/upgrade", tier: "premium" }
|
|
234
237
|
* ```
|
|
235
238
|
*/
|
|
236
|
-
|
|
239
|
+
annotationsMap(policy_ids: string[]): any;
|
|
237
240
|
/**
|
|
238
241
|
* Authorize multi-issuer request.
|
|
239
242
|
* Makes authorization decision based on multiple JWT tokens from different issuers.
|
|
@@ -245,10 +248,10 @@ export class Cedarling {
|
|
|
245
248
|
* # Example
|
|
246
249
|
*
|
|
247
250
|
* ```javascript
|
|
248
|
-
* const result = await cedarling.
|
|
251
|
+
* const result = await cedarling.authorizeMultiIssuer(JSON.stringify(request));
|
|
249
252
|
* ```
|
|
250
253
|
*/
|
|
251
|
-
|
|
254
|
+
authorizeMultiIssuer(request: string): Promise<MultiIssuerAuthorizeResult>;
|
|
252
255
|
/**
|
|
253
256
|
* Authorize a batch of multi-issuer requests against one shared token set.
|
|
254
257
|
*
|
|
@@ -266,10 +269,10 @@ export class Cedarling {
|
|
|
266
269
|
* # Example
|
|
267
270
|
*
|
|
268
271
|
* ```javascript
|
|
269
|
-
* const result = await cedarling.
|
|
272
|
+
* const result = await cedarling.authorizeMultiIssuerBatch(JSON.stringify(batchRequest));
|
|
270
273
|
* ```
|
|
271
274
|
*/
|
|
272
|
-
|
|
275
|
+
authorizeMultiIssuerBatch(request: string): Promise<BatchAuthorizeMultiIssuerResponse>;
|
|
273
276
|
/**
|
|
274
277
|
* Authorize an unsigned request carrying an optional single principal.
|
|
275
278
|
* Makes an authorization decision based on the [`RequestUnsigned`].
|
|
@@ -286,10 +289,10 @@ export class Cedarling {
|
|
|
286
289
|
* # Example
|
|
287
290
|
*
|
|
288
291
|
* ```javascript
|
|
289
|
-
* const result = await cedarling.
|
|
292
|
+
* const result = await cedarling.authorizeUnsigned(JSON.stringify(request));
|
|
290
293
|
* ```
|
|
291
294
|
*/
|
|
292
|
-
|
|
295
|
+
authorizeUnsigned(request: string): Promise<AuthorizeResult>;
|
|
293
296
|
/**
|
|
294
297
|
* Authorize a batch of unsigned requests against one shared principal.
|
|
295
298
|
*
|
|
@@ -307,31 +310,39 @@ export class Cedarling {
|
|
|
307
310
|
* # Example
|
|
308
311
|
*
|
|
309
312
|
* ```javascript
|
|
310
|
-
* const result = await cedarling.
|
|
313
|
+
* const result = await cedarling.authorizeUnsignedBatch(JSON.stringify(batchRequest));
|
|
311
314
|
* ```
|
|
312
315
|
*/
|
|
313
|
-
|
|
316
|
+
authorizeUnsignedBatch(request: string): Promise<BatchAuthorizeUnsignedResponse>;
|
|
314
317
|
/**
|
|
315
318
|
* Clear all entries from the data store.
|
|
316
319
|
*
|
|
320
|
+
* # Arguments
|
|
321
|
+
*
|
|
322
|
+
* None.
|
|
323
|
+
*
|
|
317
324
|
* # Example
|
|
318
325
|
*
|
|
319
326
|
* ```javascript
|
|
320
|
-
* cedarling.
|
|
327
|
+
* cedarling.clearDataCtx();
|
|
321
328
|
* console.log("All data entries cleared");
|
|
322
329
|
* ```
|
|
323
330
|
*/
|
|
324
|
-
|
|
331
|
+
clearDataCtx(): void;
|
|
325
332
|
/**
|
|
326
333
|
* Get trusted issuer identifiers that failed to load.
|
|
327
334
|
*
|
|
335
|
+
* # Arguments
|
|
336
|
+
*
|
|
337
|
+
* None.
|
|
338
|
+
*
|
|
328
339
|
* # Example
|
|
329
340
|
*
|
|
330
341
|
* ```javascript
|
|
331
|
-
* const ids = cedarling.
|
|
342
|
+
* const ids = cedarling.failedTrustedIssuerIds();
|
|
332
343
|
* ```
|
|
333
344
|
*/
|
|
334
|
-
|
|
345
|
+
failedTrustedIssuerIds(): Array<any>;
|
|
335
346
|
/**
|
|
336
347
|
* Get a value from the data store by key.
|
|
337
348
|
* Returns null if the key doesn't exist or the entry has expired.
|
|
@@ -343,16 +354,16 @@ export class Cedarling {
|
|
|
343
354
|
* # Example
|
|
344
355
|
*
|
|
345
356
|
* ```javascript
|
|
346
|
-
* const value = cedarling.
|
|
357
|
+
* const value = cedarling.getDataCtx("user:123");
|
|
347
358
|
* if (value !== null) {
|
|
348
359
|
* console.log(value.name); // "John"
|
|
349
360
|
* }
|
|
350
361
|
* ```
|
|
351
362
|
*/
|
|
352
|
-
|
|
363
|
+
getDataCtx(key: string): any;
|
|
353
364
|
/**
|
|
354
365
|
* Get a data entry with full metadata by key.
|
|
355
|
-
* Returns
|
|
366
|
+
* Returns undefined if the key doesn't exist or the entry has expired.
|
|
356
367
|
*
|
|
357
368
|
* # Arguments
|
|
358
369
|
*
|
|
@@ -361,56 +372,107 @@ export class Cedarling {
|
|
|
361
372
|
* # Example
|
|
362
373
|
*
|
|
363
374
|
* ```javascript
|
|
364
|
-
* const entry = cedarling.
|
|
365
|
-
* if (entry !==
|
|
375
|
+
* const entry = cedarling.getDataEntryCtx("user:123");
|
|
376
|
+
* if (entry !== undefined) {
|
|
366
377
|
* console.log(entry.key); // "user:123"
|
|
367
|
-
* console.log(entry.value); // { name: "John", age: 30 }
|
|
378
|
+
* console.log(entry.value()); // { name: "John", age: 30 }
|
|
368
379
|
* console.log(entry.data_type); // "Record"
|
|
369
380
|
* console.log(entry.created_at); // "2024-01-01T12:00:00Z"
|
|
370
381
|
* console.log(entry.access_count); // 5
|
|
371
382
|
* }
|
|
372
383
|
* ```
|
|
373
384
|
*/
|
|
374
|
-
|
|
385
|
+
getDataEntryCtx(key: string): DataEntry | undefined;
|
|
375
386
|
/**
|
|
376
|
-
*
|
|
377
|
-
*
|
|
387
|
+
* Returns one retained memory log by ID, or `null` when it is not retained.
|
|
388
|
+
*
|
|
389
|
+
* # Arguments
|
|
390
|
+
*
|
|
391
|
+
* * `id` - The retained log identifier.
|
|
392
|
+
*
|
|
393
|
+
* # Example
|
|
394
|
+
*
|
|
395
|
+
* ```javascript
|
|
396
|
+
* const log = cedarling.getLogById("request-id");
|
|
397
|
+
* ```
|
|
378
398
|
*/
|
|
379
|
-
|
|
399
|
+
getLogById(id: string): any;
|
|
380
400
|
/**
|
|
381
|
-
* Returns
|
|
382
|
-
*
|
|
401
|
+
* Returns identifiers for all retained memory logs.
|
|
402
|
+
*
|
|
403
|
+
* # Arguments
|
|
404
|
+
*
|
|
405
|
+
* None.
|
|
406
|
+
*
|
|
407
|
+
* # Example
|
|
408
|
+
*
|
|
409
|
+
* ```javascript
|
|
410
|
+
* const ids = cedarling.getLogIds();
|
|
411
|
+
* ```
|
|
383
412
|
*/
|
|
384
|
-
|
|
413
|
+
getLogIds(): Array<any>;
|
|
385
414
|
/**
|
|
386
|
-
*
|
|
387
|
-
*
|
|
415
|
+
* Returns retained memory logs for one request ID.
|
|
416
|
+
*
|
|
417
|
+
* # Arguments
|
|
418
|
+
*
|
|
419
|
+
* * `requestId` - The request identifier to match.
|
|
420
|
+
*
|
|
421
|
+
* # Example
|
|
422
|
+
*
|
|
423
|
+
* ```javascript
|
|
424
|
+
* const logs = cedarling.getLogsByRequestId("request-id");
|
|
425
|
+
* ```
|
|
388
426
|
*/
|
|
389
|
-
|
|
427
|
+
getLogsByRequestId(request_id: string): any[];
|
|
390
428
|
/**
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
429
|
+
* Returns retained memory logs matching one request ID and indexed value.
|
|
430
|
+
*
|
|
431
|
+
* # Arguments
|
|
432
|
+
*
|
|
433
|
+
* * `requestId` - The request identifier to match.
|
|
434
|
+
* * `tag` - A log kind (`"System"`, `"Decision"`, or `"Metric"`) or a
|
|
435
|
+
* system-log level such as `"DEBUG"`.
|
|
436
|
+
*
|
|
437
|
+
* # Example
|
|
438
|
+
*
|
|
439
|
+
* ```javascript
|
|
440
|
+
* const logs = cedarling.getLogsByRequestIdAndTag("request-id", "System");
|
|
441
|
+
* ```
|
|
394
442
|
*/
|
|
395
|
-
|
|
443
|
+
getLogsByRequestIdAndTag(request_id: string, tag: string): any[];
|
|
396
444
|
/**
|
|
397
|
-
*
|
|
398
|
-
*
|
|
445
|
+
* Returns retained memory logs matching an indexed value.
|
|
446
|
+
*
|
|
447
|
+
* # Arguments
|
|
448
|
+
*
|
|
449
|
+
* * `tag` - A log kind (`"System"`, `"Decision"`, or `"Metric"`) or a
|
|
450
|
+
* system-log level such as `"DEBUG"`.
|
|
451
|
+
*
|
|
452
|
+
* # Example
|
|
453
|
+
*
|
|
454
|
+
* ```javascript
|
|
455
|
+
* const logs = cedarling.getLogsByTag("System");
|
|
456
|
+
* ```
|
|
399
457
|
*/
|
|
400
|
-
|
|
458
|
+
getLogsByTag(tag: string): any[];
|
|
401
459
|
/**
|
|
402
460
|
* Get statistics about the data store.
|
|
403
461
|
*
|
|
462
|
+
* # Arguments
|
|
463
|
+
*
|
|
464
|
+
* None.
|
|
465
|
+
*
|
|
404
466
|
* # Example
|
|
405
467
|
*
|
|
406
468
|
* ```javascript
|
|
407
|
-
* const stats = cedarling.
|
|
469
|
+
* const stats = cedarling.getStatsCtx();
|
|
408
470
|
* console.log(`Entries: ${stats.entry_count}/${stats.max_entries || 'unlimited'}`);
|
|
409
471
|
* console.log(`Capacity: ${stats.capacity_usage_percent.toFixed(2)}%`);
|
|
410
472
|
* console.log(`Total size: ${stats.total_size_bytes} bytes`);
|
|
411
473
|
* ```
|
|
412
474
|
*/
|
|
413
|
-
|
|
475
|
+
getStatsCtx(): DataStoreStats;
|
|
414
476
|
/**
|
|
415
477
|
* Check whether a trusted issuer was loaded by `iss` claim.
|
|
416
478
|
*
|
|
@@ -421,10 +483,10 @@ export class Cedarling {
|
|
|
421
483
|
* # Example
|
|
422
484
|
*
|
|
423
485
|
* ```javascript
|
|
424
|
-
* const ok = cedarling.
|
|
486
|
+
* const ok = cedarling.isTrustedIssuerLoadedByIss("https://issuer.example.org");
|
|
425
487
|
* ```
|
|
426
488
|
*/
|
|
427
|
-
|
|
489
|
+
isTrustedIssuerLoadedByIss(iss_claim: string): boolean;
|
|
428
490
|
/**
|
|
429
491
|
* Check whether a trusted issuer was loaded by issuer identifier.
|
|
430
492
|
*
|
|
@@ -435,59 +497,111 @@ export class Cedarling {
|
|
|
435
497
|
* # Example
|
|
436
498
|
*
|
|
437
499
|
* ```javascript
|
|
438
|
-
* const ok = cedarling.
|
|
500
|
+
* const ok = cedarling.isTrustedIssuerLoadedByName("issuer_id");
|
|
439
501
|
* ```
|
|
440
502
|
*/
|
|
441
|
-
|
|
503
|
+
isTrustedIssuerLoadedByName(issuer_id: string): boolean;
|
|
442
504
|
/**
|
|
443
505
|
* List all entries with their metadata.
|
|
444
506
|
* Returns an array of DataEntry objects.
|
|
445
507
|
*
|
|
508
|
+
* # Arguments
|
|
509
|
+
*
|
|
510
|
+
* None.
|
|
511
|
+
*
|
|
446
512
|
* # Example
|
|
447
513
|
*
|
|
448
514
|
* ```javascript
|
|
449
|
-
* const entries = cedarling.
|
|
515
|
+
* const entries = cedarling.listDataCtx();
|
|
450
516
|
* entries.forEach(entry => {
|
|
451
517
|
* console.log(`${entry.key}: ${entry.data_type} (accessed ${entry.access_count} times)`);
|
|
452
518
|
* });
|
|
453
519
|
* ```
|
|
454
520
|
*/
|
|
455
|
-
|
|
521
|
+
listDataCtx(): Array<any>;
|
|
456
522
|
/**
|
|
457
523
|
* Get trusted issuer identifiers loaded successfully.
|
|
458
524
|
*
|
|
525
|
+
* # Arguments
|
|
526
|
+
*
|
|
527
|
+
* None.
|
|
528
|
+
*
|
|
459
529
|
* # Example
|
|
460
530
|
*
|
|
461
531
|
* ```javascript
|
|
462
|
-
* const ids = cedarling.
|
|
532
|
+
* const ids = cedarling.loadedTrustedIssuerIds();
|
|
463
533
|
* ```
|
|
464
534
|
*/
|
|
465
|
-
|
|
535
|
+
loadedTrustedIssuerIds(): Array<any>;
|
|
466
536
|
/**
|
|
467
537
|
* Get the number of trusted issuers loaded successfully.
|
|
468
538
|
*
|
|
539
|
+
* # Arguments
|
|
540
|
+
*
|
|
541
|
+
* None.
|
|
542
|
+
*
|
|
469
543
|
* # Example
|
|
470
544
|
*
|
|
471
545
|
* ```javascript
|
|
472
|
-
* const loadedCount = cedarling.
|
|
546
|
+
* const loadedCount = cedarling.loadedTrustedIssuersCount();
|
|
473
547
|
* ```
|
|
474
548
|
*/
|
|
475
|
-
|
|
549
|
+
loadedTrustedIssuersCount(): number;
|
|
476
550
|
/**
|
|
477
|
-
*
|
|
478
|
-
*
|
|
551
|
+
* Creates a Cedarling application from bootstrap properties.
|
|
552
|
+
*
|
|
553
|
+
* # Arguments
|
|
554
|
+
*
|
|
555
|
+
* * `config` - A plain object of Cedarling bootstrap-property names and values.
|
|
556
|
+
*
|
|
557
|
+
* # Example
|
|
558
|
+
*
|
|
559
|
+
* ```javascript
|
|
560
|
+
* await initWasm();
|
|
561
|
+
* const cedarling = await Cedarling.new({
|
|
562
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
563
|
+
* CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
|
|
564
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
565
|
+
* CEDARLING_LOG_TTL: 120,
|
|
566
|
+
* });
|
|
567
|
+
* ```
|
|
479
568
|
*/
|
|
480
569
|
static new(config: object): Promise<Cedarling>;
|
|
481
570
|
/**
|
|
482
|
-
*
|
|
483
|
-
*
|
|
571
|
+
* Creates a new Cedarling application from a JavaScript `Map`.
|
|
572
|
+
*
|
|
573
|
+
* # Arguments
|
|
574
|
+
*
|
|
575
|
+
* * `config` - A `Map` of Cedarling bootstrap-property names and values.
|
|
576
|
+
*
|
|
577
|
+
* # Example
|
|
578
|
+
*
|
|
579
|
+
* ```javascript
|
|
580
|
+
* await initWasm();
|
|
581
|
+
* const cedarling = await Cedarling.newFromMap(new Map([
|
|
582
|
+
* ["CEDARLING_APPLICATION_NAME", "task-api"],
|
|
583
|
+
* ["CEDARLING_POLICY_STORE_URI", "https://example.com/policy-store.cjar"],
|
|
584
|
+
* ["CEDARLING_LOG_TYPE", "memory"],
|
|
585
|
+
* ["CEDARLING_LOG_TTL", 120],
|
|
586
|
+
* ]));
|
|
587
|
+
* ```
|
|
484
588
|
*/
|
|
485
|
-
static
|
|
589
|
+
static newFromMap(config: Map<any, any>): Promise<Cedarling>;
|
|
486
590
|
/**
|
|
487
|
-
*
|
|
488
|
-
*
|
|
591
|
+
* Returns all retained memory logs and removes them from storage.
|
|
592
|
+
* Other log configurations return an empty array.
|
|
593
|
+
*
|
|
594
|
+
* # Arguments
|
|
595
|
+
*
|
|
596
|
+
* None.
|
|
597
|
+
*
|
|
598
|
+
* # Example
|
|
599
|
+
*
|
|
600
|
+
* ```javascript
|
|
601
|
+
* const logs = cedarling.popLogs();
|
|
602
|
+
* ```
|
|
489
603
|
*/
|
|
490
|
-
|
|
604
|
+
popLogs(): Array<any>;
|
|
491
605
|
/**
|
|
492
606
|
* Push a value into the data store with an optional TTL.
|
|
493
607
|
* If the key already exists, the value will be replaced.
|
|
@@ -502,11 +616,11 @@ export class Cedarling {
|
|
|
502
616
|
* # Example
|
|
503
617
|
*
|
|
504
618
|
* ```javascript
|
|
505
|
-
* cedarling.
|
|
506
|
-
* cedarling.
|
|
619
|
+
* cedarling.pushDataCtx("user:123", { name: "John", age: 30 }, 3600);
|
|
620
|
+
* cedarling.pushDataCtx("config", { setting: "value" }); // Uses default TTL
|
|
507
621
|
* ```
|
|
508
622
|
*/
|
|
509
|
-
|
|
623
|
+
pushDataCtx(key: string, value: any, ttl_secs?: bigint | null): void;
|
|
510
624
|
/**
|
|
511
625
|
* Remove a value from the data store by key.
|
|
512
626
|
* Returns true if the key existed and was removed, false otherwise.
|
|
@@ -518,27 +632,41 @@ export class Cedarling {
|
|
|
518
632
|
* # Example
|
|
519
633
|
*
|
|
520
634
|
* ```javascript
|
|
521
|
-
* const removed = cedarling.
|
|
635
|
+
* const removed = cedarling.removeDataCtx("user:123");
|
|
522
636
|
* if (removed) {
|
|
523
637
|
* console.log("Entry was successfully removed");
|
|
524
638
|
* }
|
|
525
639
|
* ```
|
|
526
640
|
*/
|
|
527
|
-
|
|
641
|
+
removeDataCtx(key: string): boolean;
|
|
528
642
|
/**
|
|
529
|
-
* Closes
|
|
643
|
+
* Closes Lock Server connections and pushes all available logs.
|
|
644
|
+
*
|
|
645
|
+
* # Arguments
|
|
646
|
+
*
|
|
647
|
+
* None.
|
|
648
|
+
*
|
|
649
|
+
* # Example
|
|
650
|
+
*
|
|
651
|
+
* ```javascript
|
|
652
|
+
* await cedarling.shutDown();
|
|
653
|
+
* ```
|
|
530
654
|
*/
|
|
531
|
-
|
|
655
|
+
shutDown(): Promise<void>;
|
|
532
656
|
/**
|
|
533
657
|
* Get the total number of trusted issuer entries discovered.
|
|
534
658
|
*
|
|
659
|
+
* # Arguments
|
|
660
|
+
*
|
|
661
|
+
* None.
|
|
662
|
+
*
|
|
535
663
|
* # Example
|
|
536
664
|
*
|
|
537
665
|
* ```javascript
|
|
538
|
-
* const total = cedarling.
|
|
666
|
+
* const total = cedarling.totalIssuers();
|
|
539
667
|
* ```
|
|
540
668
|
*/
|
|
541
|
-
|
|
669
|
+
totalIssuers(): number;
|
|
542
670
|
}
|
|
543
671
|
|
|
544
672
|
/**
|
|
@@ -552,7 +680,7 @@ export class DataEntry {
|
|
|
552
680
|
/**
|
|
553
681
|
* Convert `DataEntry` to json string value
|
|
554
682
|
*/
|
|
555
|
-
|
|
683
|
+
jsonString(): string;
|
|
556
684
|
/**
|
|
557
685
|
* Get the value stored in this entry as a JavaScript object
|
|
558
686
|
*/
|
|
@@ -570,11 +698,11 @@ export class DataEntry {
|
|
|
570
698
|
*/
|
|
571
699
|
data_type: string;
|
|
572
700
|
/**
|
|
573
|
-
* Timestamp when this entry expires (RFC 3339 format)
|
|
701
|
+
* Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
|
|
574
702
|
*/
|
|
575
703
|
get expires_at(): string | undefined;
|
|
576
704
|
/**
|
|
577
|
-
* Timestamp when this entry expires (RFC 3339 format)
|
|
705
|
+
* Timestamp when this entry expires (RFC 3339 format). The getter returns undefined if no TTL.
|
|
578
706
|
*/
|
|
579
707
|
set expires_at(value: string | null | undefined);
|
|
580
708
|
/**
|
|
@@ -594,7 +722,7 @@ export class DataStoreStats {
|
|
|
594
722
|
/**
|
|
595
723
|
* Convert `DataStoreStats` to json string value
|
|
596
724
|
*/
|
|
597
|
-
|
|
725
|
+
jsonString(): string;
|
|
598
726
|
/**
|
|
599
727
|
* Average size per entry in bytes (0 if no entries)
|
|
600
728
|
*/
|
|
@@ -696,7 +824,7 @@ export class MultiIssuerAuthorizeResult {
|
|
|
696
824
|
/**
|
|
697
825
|
* Convert `MultiIssuerAuthorizeResult` to json string value
|
|
698
826
|
*/
|
|
699
|
-
|
|
827
|
+
jsonString(): string;
|
|
700
828
|
/**
|
|
701
829
|
* Result of authorization
|
|
702
830
|
* true means `ALLOW`
|
|
@@ -734,8 +862,24 @@ export class PolicyEvaluationError {
|
|
|
734
862
|
}
|
|
735
863
|
|
|
736
864
|
/**
|
|
737
|
-
*
|
|
738
|
-
*
|
|
865
|
+
* Creates a Cedarling application from bootstrap properties.
|
|
866
|
+
*
|
|
867
|
+
* # Arguments
|
|
868
|
+
*
|
|
869
|
+
* * `config` - A JavaScript `Map` or plain object of Cedarling
|
|
870
|
+
* bootstrap-property names and values.
|
|
871
|
+
*
|
|
872
|
+
* # Example
|
|
873
|
+
*
|
|
874
|
+
* ```javascript
|
|
875
|
+
* await initWasm();
|
|
876
|
+
* const cedarling = await init({
|
|
877
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
878
|
+
* CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
|
|
879
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
880
|
+
* CEDARLING_LOG_TTL: 120,
|
|
881
|
+
* });
|
|
882
|
+
* ```
|
|
739
883
|
*/
|
|
740
884
|
export function init(config: any): Promise<Cedarling>;
|
|
741
885
|
|
|
@@ -746,181 +890,24 @@ export function init(config: any): Promise<Cedarling>;
|
|
|
746
890
|
* that was fetched with custom logic (e.g., with authentication headers).
|
|
747
891
|
*
|
|
748
892
|
* # Arguments
|
|
749
|
-
* * `config` - Bootstrap configuration (Map or Object)
|
|
893
|
+
* * `config` - Bootstrap configuration (Map or Object) without a policy-store
|
|
894
|
+
* source property. The archive bytes provide the policy store.
|
|
750
895
|
* * `archive_bytes` - The .cjar archive bytes (Uint8Array)
|
|
751
896
|
*
|
|
752
897
|
* # Example
|
|
753
898
|
* ```javascript
|
|
754
|
-
*
|
|
755
|
-
* const
|
|
756
|
-
*
|
|
899
|
+
* await initWasm();
|
|
900
|
+
* const config = {
|
|
901
|
+
* CEDARLING_APPLICATION_NAME: "task-api",
|
|
902
|
+
* CEDARLING_LOG_TYPE: "memory",
|
|
903
|
+
* CEDARLING_LOG_TTL: 120,
|
|
904
|
+
* };
|
|
905
|
+
* const response = await fetch("https://example.com/policy-store.cjar", {
|
|
906
|
+
* headers: { Authorization: "Bearer <token>" },
|
|
907
|
+
* });
|
|
908
|
+
* if (!response.ok) throw new Error("Unable to fetch policy store");
|
|
909
|
+
* const archiveBytes = new Uint8Array(await response.arrayBuffer());
|
|
910
|
+
* const cedarling = await initFromArchiveBytes(config, archiveBytes);
|
|
757
911
|
* ```
|
|
758
912
|
*/
|
|
759
|
-
export function
|
|
760
|
-
|
|
761
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
762
|
-
|
|
763
|
-
export interface InitOutput {
|
|
764
|
-
readonly memory: WebAssembly.Memory;
|
|
765
|
-
readonly __wbg_authorizeresult_free: (a: number, b: number) => void;
|
|
766
|
-
readonly __wbg_authorizeresultresponse_free: (a: number, b: number) => void;
|
|
767
|
-
readonly __wbg_batchauthorizemultiissuerresponse_free: (a: number, b: number) => void;
|
|
768
|
-
readonly __wbg_batchitemerror_free: (a: number, b: number) => void;
|
|
769
|
-
readonly __wbg_batchitemmultiissuerresult_free: (a: number, b: number) => void;
|
|
770
|
-
readonly __wbg_cedarling_free: (a: number, b: number) => void;
|
|
771
|
-
readonly __wbg_dataentry_free: (a: number, b: number) => void;
|
|
772
|
-
readonly __wbg_datastorestats_free: (a: number, b: number) => void;
|
|
773
|
-
readonly __wbg_diagnostics_free: (a: number, b: number) => void;
|
|
774
|
-
readonly __wbg_get_authorizeresult_decision: (a: number) => number;
|
|
775
|
-
readonly __wbg_get_authorizeresult_request_id: (a: number, b: number) => void;
|
|
776
|
-
readonly __wbg_get_authorizeresult_response: (a: number) => number;
|
|
777
|
-
readonly __wbg_get_dataentry_access_count: (a: number) => bigint;
|
|
778
|
-
readonly __wbg_get_dataentry_created_at: (a: number, b: number) => void;
|
|
779
|
-
readonly __wbg_get_dataentry_data_type: (a: number, b: number) => void;
|
|
780
|
-
readonly __wbg_get_dataentry_expires_at: (a: number, b: number) => void;
|
|
781
|
-
readonly __wbg_get_dataentry_key: (a: number, b: number) => void;
|
|
782
|
-
readonly __wbg_get_datastorestats_avg_entry_size_bytes: (a: number) => number;
|
|
783
|
-
readonly __wbg_get_datastorestats_capacity_usage_percent: (a: number) => number;
|
|
784
|
-
readonly __wbg_get_datastorestats_entry_count: (a: number) => number;
|
|
785
|
-
readonly __wbg_get_datastorestats_max_entries: (a: number) => number;
|
|
786
|
-
readonly __wbg_get_datastorestats_max_entry_size: (a: number) => number;
|
|
787
|
-
readonly __wbg_get_datastorestats_memory_alert_threshold: (a: number) => number;
|
|
788
|
-
readonly __wbg_get_datastorestats_memory_alert_triggered: (a: number) => number;
|
|
789
|
-
readonly __wbg_get_datastorestats_metrics_enabled: (a: number) => number;
|
|
790
|
-
readonly __wbg_get_datastorestats_total_size_bytes: (a: number) => number;
|
|
791
|
-
readonly __wbg_policyevaluationerror_free: (a: number, b: number) => void;
|
|
792
|
-
readonly __wbg_set_authorizeresult_decision: (a: number, b: number) => void;
|
|
793
|
-
readonly __wbg_set_authorizeresult_request_id: (a: number, b: number, c: number) => void;
|
|
794
|
-
readonly __wbg_set_authorizeresult_response: (a: number, b: number) => void;
|
|
795
|
-
readonly __wbg_set_dataentry_access_count: (a: number, b: bigint) => void;
|
|
796
|
-
readonly __wbg_set_dataentry_created_at: (a: number, b: number, c: number) => void;
|
|
797
|
-
readonly __wbg_set_dataentry_data_type: (a: number, b: number, c: number) => void;
|
|
798
|
-
readonly __wbg_set_dataentry_expires_at: (a: number, b: number, c: number) => void;
|
|
799
|
-
readonly __wbg_set_dataentry_key: (a: number, b: number, c: number) => void;
|
|
800
|
-
readonly __wbg_set_datastorestats_avg_entry_size_bytes: (a: number, b: number) => void;
|
|
801
|
-
readonly __wbg_set_datastorestats_capacity_usage_percent: (a: number, b: number) => void;
|
|
802
|
-
readonly __wbg_set_datastorestats_entry_count: (a: number, b: number) => void;
|
|
803
|
-
readonly __wbg_set_datastorestats_max_entries: (a: number, b: number) => void;
|
|
804
|
-
readonly __wbg_set_datastorestats_max_entry_size: (a: number, b: number) => void;
|
|
805
|
-
readonly __wbg_set_datastorestats_memory_alert_threshold: (a: number, b: number) => void;
|
|
806
|
-
readonly __wbg_set_datastorestats_memory_alert_triggered: (a: number, b: number) => void;
|
|
807
|
-
readonly __wbg_set_datastorestats_metrics_enabled: (a: number, b: number) => void;
|
|
808
|
-
readonly __wbg_set_datastorestats_total_size_bytes: (a: number, b: number) => void;
|
|
809
|
-
readonly authorizeresult_json_string: (a: number, b: number) => void;
|
|
810
|
-
readonly authorizeresultresponse_decision: (a: number) => number;
|
|
811
|
-
readonly authorizeresultresponse_diagnostics: (a: number) => number;
|
|
812
|
-
readonly batchauthorizemultiissuerresponse_batch_id: (a: number, b: number) => void;
|
|
813
|
-
readonly batchauthorizemultiissuerresponse_results: (a: number, b: number) => void;
|
|
814
|
-
readonly batchauthorizeunsignedresponse_results: (a: number, b: number) => void;
|
|
815
|
-
readonly batchitemerror_category: (a: number, b: number) => void;
|
|
816
|
-
readonly batchitemerror_item_index: (a: number) => number;
|
|
817
|
-
readonly batchitemerror_message: (a: number, b: number) => void;
|
|
818
|
-
readonly batchitemmultiissuerresult_error: (a: number) => number;
|
|
819
|
-
readonly batchitemmultiissuerresult_is_ok: (a: number) => number;
|
|
820
|
-
readonly batchitemmultiissuerresult_unwrap: (a: number, b: number) => void;
|
|
821
|
-
readonly batchitemunsignedresult_unwrap: (a: number, b: number) => void;
|
|
822
|
-
readonly cedarling_annotation_values: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
823
|
-
readonly cedarling_annotations_by_policy: (a: number, b: number, c: number, d: number) => void;
|
|
824
|
-
readonly cedarling_annotations_map: (a: number, b: number, c: number, d: number) => void;
|
|
825
|
-
readonly cedarling_authorize_multi_issuer: (a: number, b: number, c: number) => number;
|
|
826
|
-
readonly cedarling_authorize_multi_issuer_batch: (a: number, b: number, c: number) => number;
|
|
827
|
-
readonly cedarling_authorize_unsigned: (a: number, b: number, c: number) => number;
|
|
828
|
-
readonly cedarling_authorize_unsigned_batch: (a: number, b: number, c: number) => number;
|
|
829
|
-
readonly cedarling_clear_data_ctx: (a: number, b: number) => void;
|
|
830
|
-
readonly cedarling_failed_trusted_issuer_ids: (a: number) => number;
|
|
831
|
-
readonly cedarling_get_data_ctx: (a: number, b: number, c: number, d: number) => void;
|
|
832
|
-
readonly cedarling_get_data_entry_ctx: (a: number, b: number, c: number, d: number) => void;
|
|
833
|
-
readonly cedarling_get_log_by_id: (a: number, b: number, c: number, d: number) => void;
|
|
834
|
-
readonly cedarling_get_log_ids: (a: number) => number;
|
|
835
|
-
readonly cedarling_get_logs_by_request_id: (a: number, b: number, c: number, d: number) => void;
|
|
836
|
-
readonly cedarling_get_logs_by_request_id_and_tag: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
837
|
-
readonly cedarling_get_stats_ctx: (a: number, b: number) => void;
|
|
838
|
-
readonly cedarling_is_trusted_issuer_loaded_by_iss: (a: number, b: number, c: number) => number;
|
|
839
|
-
readonly cedarling_is_trusted_issuer_loaded_by_name: (a: number, b: number, c: number) => number;
|
|
840
|
-
readonly cedarling_list_data_ctx: (a: number, b: number) => void;
|
|
841
|
-
readonly cedarling_loaded_trusted_issuer_ids: (a: number) => number;
|
|
842
|
-
readonly cedarling_loaded_trusted_issuers_count: (a: number) => number;
|
|
843
|
-
readonly cedarling_new: (a: number) => number;
|
|
844
|
-
readonly cedarling_new_from_map: (a: number) => number;
|
|
845
|
-
readonly cedarling_pop_logs: (a: number, b: number) => void;
|
|
846
|
-
readonly cedarling_push_data_ctx: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
|
|
847
|
-
readonly cedarling_remove_data_ctx: (a: number, b: number, c: number, d: number) => void;
|
|
848
|
-
readonly cedarling_shut_down: (a: number) => number;
|
|
849
|
-
readonly cedarling_total_issuers: (a: number) => number;
|
|
850
|
-
readonly dataentry_json_string: (a: number, b: number) => void;
|
|
851
|
-
readonly dataentry_value: (a: number, b: number) => void;
|
|
852
|
-
readonly datastorestats_json_string: (a: number, b: number) => void;
|
|
853
|
-
readonly diagnostics_errors: (a: number, b: number) => void;
|
|
854
|
-
readonly diagnostics_reason: (a: number, b: number) => void;
|
|
855
|
-
readonly init: (a: number) => number;
|
|
856
|
-
readonly init_from_archive_bytes: (a: number, b: number) => number;
|
|
857
|
-
readonly multiissuerauthorizeresult_json_string: (a: number, b: number) => void;
|
|
858
|
-
readonly policyevaluationerror_error: (a: number, b: number) => void;
|
|
859
|
-
readonly policyevaluationerror_id: (a: number, b: number) => void;
|
|
860
|
-
readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
|
|
861
|
-
readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
|
|
862
|
-
readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
|
|
863
|
-
readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
|
|
864
|
-
readonly intounderlyingbytesource_cancel: (a: number) => void;
|
|
865
|
-
readonly intounderlyingbytesource_pull: (a: number, b: number) => number;
|
|
866
|
-
readonly intounderlyingbytesource_start: (a: number, b: number) => void;
|
|
867
|
-
readonly intounderlyingbytesource_type: (a: number) => number;
|
|
868
|
-
readonly intounderlyingsink_abort: (a: number, b: number) => number;
|
|
869
|
-
readonly intounderlyingsink_close: (a: number) => number;
|
|
870
|
-
readonly intounderlyingsink_write: (a: number, b: number) => number;
|
|
871
|
-
readonly intounderlyingsource_cancel: (a: number) => void;
|
|
872
|
-
readonly intounderlyingsource_pull: (a: number, b: number) => number;
|
|
873
|
-
readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
874
|
-
readonly rust_zstd_wasm_shim_free: (a: number) => void;
|
|
875
|
-
readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
|
|
876
|
-
readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
|
|
877
|
-
readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
|
|
878
|
-
readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
|
|
879
|
-
readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
|
|
880
|
-
readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
|
|
881
|
-
readonly __wbg_get_multiissuerauthorizeresult_decision: (a: number) => number;
|
|
882
|
-
readonly __wbg_set_multiissuerauthorizeresult_response: (a: number, b: number) => void;
|
|
883
|
-
readonly __wbg_set_multiissuerauthorizeresult_request_id: (a: number, b: number, c: number) => void;
|
|
884
|
-
readonly __wbg_set_multiissuerauthorizeresult_decision: (a: number, b: number) => void;
|
|
885
|
-
readonly __wbg_get_multiissuerauthorizeresult_response: (a: number) => number;
|
|
886
|
-
readonly __wbg_get_multiissuerauthorizeresult_request_id: (a: number, b: number) => void;
|
|
887
|
-
readonly __wbg_multiissuerauthorizeresult_free: (a: number, b: number) => void;
|
|
888
|
-
readonly __wbg_batchitemunsignedresult_free: (a: number, b: number) => void;
|
|
889
|
-
readonly __wbg_batchauthorizeunsignedresponse_free: (a: number, b: number) => void;
|
|
890
|
-
readonly batchitemunsignedresult_is_ok: (a: number) => number;
|
|
891
|
-
readonly batchitemunsignedresult_error: (a: number) => number;
|
|
892
|
-
readonly batchauthorizeunsignedresponse_batch_id: (a: number, b: number) => void;
|
|
893
|
-
readonly cedarling_get_logs_by_tag: (a: number, b: number, c: number, d: number) => void;
|
|
894
|
-
readonly __wasm_bindgen_func_elem_8913: (a: number, b: number, c: number, d: number) => void;
|
|
895
|
-
readonly __wasm_bindgen_func_elem_8979: (a: number, b: number, c: number, d: number) => void;
|
|
896
|
-
readonly __wasm_bindgen_func_elem_12464: (a: number, b: number, c: number) => void;
|
|
897
|
-
readonly __wasm_bindgen_func_elem_8748: (a: number, b: number) => void;
|
|
898
|
-
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
899
|
-
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
900
|
-
readonly __wbindgen_export3: (a: number) => void;
|
|
901
|
-
readonly __wbindgen_export4: (a: number, b: number) => void;
|
|
902
|
-
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
903
|
-
readonly __wbindgen_export5: (a: number, b: number, c: number) => void;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
907
|
-
|
|
908
|
-
/**
|
|
909
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
910
|
-
* a precompiled `WebAssembly.Module`.
|
|
911
|
-
*
|
|
912
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
913
|
-
*
|
|
914
|
-
* @returns {InitOutput}
|
|
915
|
-
*/
|
|
916
|
-
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
917
|
-
|
|
918
|
-
/**
|
|
919
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
920
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
921
|
-
*
|
|
922
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
923
|
-
*
|
|
924
|
-
* @returns {Promise<InitOutput>}
|
|
925
|
-
*/
|
|
926
|
-
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
913
|
+
export function initFromArchiveBytes(config: any, archive_bytes: Uint8Array): Promise<Cedarling>;
|