@janssenproject/cedarling_wasm 0.0.310 → 0.0.311-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.
@@ -234,100 +234,3 @@ export function init(config: any): Promise<Cedarling>;
234
234
  * ```
235
235
  */
236
236
  export function init_from_archive_bytes(config: any, archive_bytes: Uint8Array): Promise<Cedarling>;
237
-
238
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
239
-
240
- export interface InitOutput {
241
- readonly memory: WebAssembly.Memory;
242
- readonly __wbg_cedarling_free: (a: number, b: number) => void;
243
- readonly __wbg_multiissuerauthorizeresult_free: (a: number, b: number) => void;
244
- readonly __wbg_get_multiissuerauthorizeresult_response: (a: number) => number;
245
- readonly __wbg_set_multiissuerauthorizeresult_response: (a: number, b: number) => void;
246
- readonly __wbg_get_multiissuerauthorizeresult_decision: (a: number) => number;
247
- readonly __wbg_set_multiissuerauthorizeresult_decision: (a: number, b: number) => void;
248
- readonly __wbg_get_multiissuerauthorizeresult_request_id: (a: number) => [number, number];
249
- readonly __wbg_set_multiissuerauthorizeresult_request_id: (a: number, b: number, c: number) => void;
250
- readonly multiissuerauthorizeresult_json_string: (a: number) => [number, number];
251
- readonly init: (a: any) => any;
252
- readonly init_from_archive_bytes: (a: any, b: any) => any;
253
- readonly cedarling_new: (a: any) => any;
254
- readonly cedarling_new_from_map: (a: any) => any;
255
- readonly cedarling_authorize: (a: number, b: any) => any;
256
- readonly cedarling_authorize_unsigned: (a: number, b: any) => any;
257
- readonly cedarling_authorize_multi_issuer: (a: number, b: any) => any;
258
- readonly cedarling_pop_logs: (a: number) => [number, number, number];
259
- readonly cedarling_get_log_by_id: (a: number, b: number, c: number) => [number, number, number];
260
- readonly cedarling_get_log_ids: (a: number) => any;
261
- readonly cedarling_get_logs_by_tag: (a: number, b: number, c: number) => [number, number, number, number];
262
- readonly cedarling_get_logs_by_request_id: (a: number, b: number, c: number) => [number, number, number, number];
263
- readonly cedarling_get_logs_by_request_id_and_tag: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
264
- readonly cedarling_shut_down: (a: number) => any;
265
- readonly __wbg_authorizeresult_free: (a: number, b: number) => void;
266
- readonly __wbg_get_authorizeresult_workload: (a: number) => number;
267
- readonly __wbg_set_authorizeresult_workload: (a: number, b: number) => void;
268
- readonly __wbg_get_authorizeresult_person: (a: number) => number;
269
- readonly __wbg_set_authorizeresult_person: (a: number, b: number) => void;
270
- readonly __wbg_get_authorizeresult_decision: (a: number) => number;
271
- readonly __wbg_set_authorizeresult_decision: (a: number, b: number) => void;
272
- readonly __wbg_get_authorizeresult_request_id: (a: number) => [number, number];
273
- readonly __wbg_set_authorizeresult_request_id: (a: number, b: number, c: number) => void;
274
- readonly authorizeresult_json_string: (a: number) => [number, number];
275
- readonly authorizeresult_principal: (a: number, b: number, c: number) => number;
276
- readonly __wbg_authorizeresultresponse_free: (a: number, b: number) => void;
277
- readonly authorizeresultresponse_decision: (a: number) => number;
278
- readonly authorizeresultresponse_diagnostics: (a: number) => number;
279
- readonly __wbg_diagnostics_free: (a: number, b: number) => void;
280
- readonly diagnostics_reason: (a: number) => [number, number];
281
- readonly diagnostics_errors: (a: number) => [number, number];
282
- readonly __wbg_policyevaluationerror_free: (a: number, b: number) => void;
283
- readonly policyevaluationerror_id: (a: number) => [number, number];
284
- readonly policyevaluationerror_error: (a: number) => [number, number];
285
- readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
286
- readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
287
- readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
288
- readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
289
- readonly rust_zstd_wasm_shim_free: (a: number) => void;
290
- readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
291
- readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
292
- readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
293
- readonly __wbg_jsjsonlogic_free: (a: number, b: number) => void;
294
- readonly jsjsonlogic_new: () => number;
295
- readonly jsjsonlogic_apply: (a: number, b: any, c: any) => [number, number, number];
296
- readonly ring_core_0_17_14__bn_mul_mont: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
297
- readonly wasm_bindgen__closure__destroy__h9729aad38f8f1d61: (a: number, b: number) => void;
298
- readonly wasm_bindgen__closure__destroy__he0504cf30b514912: (a: number, b: number) => void;
299
- readonly wasm_bindgen__convert__closures_____invoke__h14a188697013a9c5: (a: number, b: number, c: any, d: any) => void;
300
- readonly wasm_bindgen__convert__closures_____invoke__h15fe5b7296be5bd5: (a: number, b: number, c: any) => void;
301
- readonly wasm_bindgen__convert__closures_____invoke__hb09a75d48dabdadf: (a: number, b: number) => void;
302
- readonly __wbindgen_malloc: (a: number, b: number) => number;
303
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
304
- readonly __wbindgen_exn_store: (a: number) => void;
305
- readonly __externref_table_alloc: () => number;
306
- readonly __wbindgen_externrefs: WebAssembly.Table;
307
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
308
- readonly __externref_table_dealloc: (a: number) => void;
309
- readonly __externref_drop_slice: (a: number, b: number) => void;
310
- readonly __wbindgen_start: () => void;
311
- }
312
-
313
- export type SyncInitInput = BufferSource | WebAssembly.Module;
314
-
315
- /**
316
- * Instantiates the given `module`, which can either be bytes or
317
- * a precompiled `WebAssembly.Module`.
318
- *
319
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
320
- *
321
- * @returns {InitOutput}
322
- */
323
- export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
324
-
325
- /**
326
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
327
- * for everything else, calls `WebAssembly.instantiate` directly.
328
- *
329
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
330
- *
331
- * @returns {Promise<InitOutput>}
332
- */
333
- export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
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
- export class AuthorizeResult {
7
+ class AuthorizeResult {
8
8
  static __wrap(ptr) {
9
9
  ptr = ptr >>> 0;
10
10
  const obj = Object.create(AuthorizeResult.prototype);
@@ -138,12 +138,13 @@ export class AuthorizeResult {
138
138
  }
139
139
  }
140
140
  if (Symbol.dispose) AuthorizeResult.prototype[Symbol.dispose] = AuthorizeResult.prototype.free;
141
+ exports.AuthorizeResult = AuthorizeResult;
141
142
 
142
143
  /**
143
144
  * A WASM wrapper for the Rust `cedar_policy::Response` struct.
144
145
  * Represents the result of an authorization request.
145
146
  */
146
- export class AuthorizeResultResponse {
147
+ class AuthorizeResultResponse {
147
148
  static __wrap(ptr) {
148
149
  ptr = ptr >>> 0;
149
150
  const obj = Object.create(AuthorizeResultResponse.prototype);
@@ -179,11 +180,12 @@ export class AuthorizeResultResponse {
179
180
  }
180
181
  }
181
182
  if (Symbol.dispose) AuthorizeResultResponse.prototype[Symbol.dispose] = AuthorizeResultResponse.prototype.free;
183
+ exports.AuthorizeResultResponse = AuthorizeResultResponse;
182
184
 
183
185
  /**
184
186
  * The instance of the Cedarling application.
185
187
  */
186
- export class Cedarling {
188
+ class Cedarling {
187
189
  static __wrap(ptr) {
188
190
  ptr = ptr >>> 0;
189
191
  const obj = Object.create(Cedarling.prototype);
@@ -352,6 +354,7 @@ export class Cedarling {
352
354
  }
353
355
  }
354
356
  if (Symbol.dispose) Cedarling.prototype[Symbol.dispose] = Cedarling.prototype.free;
357
+ exports.Cedarling = Cedarling;
355
358
 
356
359
  /**
357
360
  * Diagnostics
@@ -359,7 +362,7 @@ if (Symbol.dispose) Cedarling.prototype[Symbol.dispose] = Cedarling.prototype.fr
359
362
  *
360
363
  * Provides detailed information about how a policy decision was made, including policies that contributed to the decision and any errors encountered during evaluation.
361
364
  */
362
- export class Diagnostics {
365
+ class Diagnostics {
363
366
  static __wrap(ptr) {
364
367
  ptr = ptr >>> 0;
365
368
  const obj = Object.create(Diagnostics.prototype);
@@ -403,8 +406,9 @@ export class Diagnostics {
403
406
  }
404
407
  }
405
408
  if (Symbol.dispose) Diagnostics.prototype[Symbol.dispose] = Diagnostics.prototype.free;
409
+ exports.Diagnostics = Diagnostics;
406
410
 
407
- export class JsJsonLogic {
411
+ class JsJsonLogic {
408
412
  __destroy_into_raw() {
409
413
  const ptr = this.__wbg_ptr;
410
414
  this.__wbg_ptr = 0;
@@ -435,12 +439,13 @@ export class JsJsonLogic {
435
439
  }
436
440
  }
437
441
  if (Symbol.dispose) JsJsonLogic.prototype[Symbol.dispose] = JsJsonLogic.prototype.free;
442
+ exports.JsJsonLogic = JsJsonLogic;
438
443
 
439
444
  /**
440
445
  * A WASM wrapper for the Rust `cedarling::MultiIssuerAuthorizeResult` struct.
441
446
  * Represents the result of a multi-issuer authorization request.
442
447
  */
443
- export class MultiIssuerAuthorizeResult {
448
+ class MultiIssuerAuthorizeResult {
444
449
  static __wrap(ptr) {
445
450
  ptr = ptr >>> 0;
446
451
  const obj = Object.create(MultiIssuerAuthorizeResult.prototype);
@@ -537,6 +542,7 @@ export class MultiIssuerAuthorizeResult {
537
542
  }
538
543
  }
539
544
  if (Symbol.dispose) MultiIssuerAuthorizeResult.prototype[Symbol.dispose] = MultiIssuerAuthorizeResult.prototype.free;
545
+ exports.MultiIssuerAuthorizeResult = MultiIssuerAuthorizeResult;
540
546
 
541
547
  /**
542
548
  * PolicyEvaluationError
@@ -544,7 +550,7 @@ if (Symbol.dispose) MultiIssuerAuthorizeResult.prototype[Symbol.dispose] = Multi
544
550
  *
545
551
  * Represents an error that occurred when evaluating a Cedar policy.
546
552
  */
547
- export class PolicyEvaluationError {
553
+ class PolicyEvaluationError {
548
554
  static __wrap(ptr) {
549
555
  ptr = ptr >>> 0;
550
556
  const obj = Object.create(PolicyEvaluationError.prototype);
@@ -596,6 +602,7 @@ export class PolicyEvaluationError {
596
602
  }
597
603
  }
598
604
  if (Symbol.dispose) PolicyEvaluationError.prototype[Symbol.dispose] = PolicyEvaluationError.prototype.free;
605
+ exports.PolicyEvaluationError = PolicyEvaluationError;
599
606
 
600
607
  /**
601
608
  * Create a new instance of the Cedarling application.
@@ -603,10 +610,11 @@ if (Symbol.dispose) PolicyEvaluationError.prototype[Symbol.dispose] = PolicyEval
603
610
  * @param {any} config
604
611
  * @returns {Promise<Cedarling>}
605
612
  */
606
- export function init(config) {
613
+ function init(config) {
607
614
  const ret = wasm.init(config);
608
615
  return ret;
609
616
  }
617
+ exports.init = init;
610
618
 
611
619
  /**
612
620
  * Create a new instance of the Cedarling application from archive bytes.
@@ -628,10 +636,11 @@ export function init(config) {
628
636
  * @param {Uint8Array} archive_bytes
629
637
  * @returns {Promise<Cedarling>}
630
638
  */
631
- export function init_from_archive_bytes(config, archive_bytes) {
639
+ function init_from_archive_bytes(config, archive_bytes) {
632
640
  const ret = wasm.init_from_archive_bytes(config, archive_bytes);
633
641
  return ret;
634
642
  }
643
+ exports.init_from_archive_bytes = init_from_archive_bytes;
635
644
 
636
645
  function __wbg_get_imports() {
637
646
  const import0 = {
@@ -938,7 +947,7 @@ function __wbg_get_imports() {
938
947
  const a = state0.a;
939
948
  state0.a = 0;
940
949
  try {
941
- return wasm_bindgen__convert__closures_____invoke__h14a188697013a9c5(a, state0.b, arg0, arg1);
950
+ return wasm_bindgen__convert__closures_____invoke__h5ea28dde88fe4fc5(a, state0.b, arg0, arg1);
942
951
  } finally {
943
952
  state0.a = a;
944
953
  }
@@ -1132,12 +1141,12 @@ function __wbg_get_imports() {
1132
1141
  },
1133
1142
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1134
1143
  // Cast intrinsic for `Closure(Closure { dtor_idx: 553, function: Function { arguments: [], shim_idx: 554, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1135
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h9729aad38f8f1d61, wasm_bindgen__convert__closures_____invoke__hb09a75d48dabdadf);
1144
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h81df99cf5fb23bb4, wasm_bindgen__convert__closures_____invoke__h06cf10571db3fb4b);
1136
1145
  return ret;
1137
1146
  },
1138
1147
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1139
1148
  // Cast intrinsic for `Closure(Closure { dtor_idx: 597, function: Function { arguments: [Externref], shim_idx: 598, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1140
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__he0504cf30b514912, wasm_bindgen__convert__closures_____invoke__h15fe5b7296be5bd5);
1149
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__he589cbad438baf01, wasm_bindgen__convert__closures_____invoke__h30e9622b2b4b0718);
1141
1150
  return ret;
1142
1151
  },
1143
1152
  __wbindgen_cast_0000000000000003: function(arg0) {
@@ -1181,16 +1190,16 @@ function __wbg_get_imports() {
1181
1190
  };
1182
1191
  }
1183
1192
 
1184
- function wasm_bindgen__convert__closures_____invoke__hb09a75d48dabdadf(arg0, arg1) {
1185
- wasm.wasm_bindgen__convert__closures_____invoke__hb09a75d48dabdadf(arg0, arg1);
1193
+ function wasm_bindgen__convert__closures_____invoke__h06cf10571db3fb4b(arg0, arg1) {
1194
+ wasm.wasm_bindgen__convert__closures_____invoke__h06cf10571db3fb4b(arg0, arg1);
1186
1195
  }
1187
1196
 
1188
- function wasm_bindgen__convert__closures_____invoke__h15fe5b7296be5bd5(arg0, arg1, arg2) {
1189
- wasm.wasm_bindgen__convert__closures_____invoke__h15fe5b7296be5bd5(arg0, arg1, arg2);
1197
+ function wasm_bindgen__convert__closures_____invoke__h30e9622b2b4b0718(arg0, arg1, arg2) {
1198
+ wasm.wasm_bindgen__convert__closures_____invoke__h30e9622b2b4b0718(arg0, arg1, arg2);
1190
1199
  }
1191
1200
 
1192
- function wasm_bindgen__convert__closures_____invoke__h14a188697013a9c5(arg0, arg1, arg2, arg3) {
1193
- wasm.wasm_bindgen__convert__closures_____invoke__h14a188697013a9c5(arg0, arg1, arg2, arg3);
1201
+ function wasm_bindgen__convert__closures_____invoke__h5ea28dde88fe4fc5(arg0, arg1, arg2, arg3) {
1202
+ wasm.wasm_bindgen__convert__closures_____invoke__h5ea28dde88fe4fc5(arg0, arg1, arg2, arg3);
1194
1203
  }
1195
1204
 
1196
1205
 
@@ -1427,15 +1436,7 @@ function takeFromExternrefTable0(idx) {
1427
1436
 
1428
1437
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1429
1438
  cachedTextDecoder.decode();
1430
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
1431
- let numBytesDecoded = 0;
1432
1439
  function decodeText(ptr, len) {
1433
- numBytesDecoded += len;
1434
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1435
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1436
- cachedTextDecoder.decode();
1437
- numBytesDecoded = len;
1438
- }
1439
1440
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1440
1441
  }
1441
1442
 
@@ -1454,95 +1455,8 @@ if (!('encodeInto' in cachedTextEncoder)) {
1454
1455
 
1455
1456
  let WASM_VECTOR_LEN = 0;
1456
1457
 
1457
- let wasmModule, wasm;
1458
- function __wbg_finalize_init(instance, module) {
1459
- wasm = instance.exports;
1460
- wasmModule = module;
1461
- cachedDataViewMemory0 = null;
1462
- cachedUint8ArrayMemory0 = null;
1463
- wasm.__wbindgen_start();
1464
- return wasm;
1465
- }
1466
-
1467
- async function __wbg_load(module, imports) {
1468
- if (typeof Response === 'function' && module instanceof Response) {
1469
- if (typeof WebAssembly.instantiateStreaming === 'function') {
1470
- try {
1471
- return await WebAssembly.instantiateStreaming(module, imports);
1472
- } catch (e) {
1473
- const validResponse = module.ok && expectedResponseType(module.type);
1474
-
1475
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1476
- 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);
1477
-
1478
- } else { throw e; }
1479
- }
1480
- }
1481
-
1482
- const bytes = await module.arrayBuffer();
1483
- return await WebAssembly.instantiate(bytes, imports);
1484
- } else {
1485
- const instance = await WebAssembly.instantiate(module, imports);
1486
-
1487
- if (instance instanceof WebAssembly.Instance) {
1488
- return { instance, module };
1489
- } else {
1490
- return instance;
1491
- }
1492
- }
1493
-
1494
- function expectedResponseType(type) {
1495
- switch (type) {
1496
- case 'basic': case 'cors': case 'default': return true;
1497
- }
1498
- return false;
1499
- }
1500
- }
1501
-
1502
- function initSync(module) {
1503
- if (wasm !== undefined) return wasm;
1504
-
1505
-
1506
- if (module !== undefined) {
1507
- if (Object.getPrototypeOf(module) === Object.prototype) {
1508
- ({module} = module)
1509
- } else {
1510
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1511
- }
1512
- }
1513
-
1514
- const imports = __wbg_get_imports();
1515
- if (!(module instanceof WebAssembly.Module)) {
1516
- module = new WebAssembly.Module(module);
1517
- }
1518
- const instance = new WebAssembly.Instance(module, imports);
1519
- return __wbg_finalize_init(instance, module);
1520
- }
1521
-
1522
- async function __wbg_init(module_or_path) {
1523
- if (wasm !== undefined) return wasm;
1524
-
1525
-
1526
- if (module_or_path !== undefined) {
1527
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1528
- ({module_or_path} = module_or_path)
1529
- } else {
1530
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1531
- }
1532
- }
1533
-
1534
- if (module_or_path === undefined) {
1535
- module_or_path = new URL('cedarling_wasm_bg.wasm', import.meta.url);
1536
- }
1537
- const imports = __wbg_get_imports();
1538
-
1539
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1540
- module_or_path = fetch(module_or_path);
1541
- }
1542
-
1543
- const { instance, module } = await __wbg_load(await module_or_path, imports);
1544
-
1545
- return __wbg_finalize_init(instance, module);
1546
- }
1547
-
1548
- export { initSync, __wbg_init as default };
1458
+ const wasmPath = `${__dirname}/cedarling_wasm_bg.wasm`;
1459
+ const wasmBytes = require('fs').readFileSync(wasmPath);
1460
+ const wasmModule = new WebAssembly.Module(wasmBytes);
1461
+ const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
1462
+ wasm.__wbindgen_start();
Binary file
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@janssenproject/cedarling_wasm",
3
- "type": "module",
4
3
  "description": "The Cedarling is a performant local authorization service that runs the Rust Cedar Engine",
5
- "version": "0.0.310",
4
+ "version": "0.0.311-nodejs",
6
5
  "license": "Apache-2.0",
7
6
  "repository": {
8
7
  "type": "git",
@@ -14,8 +13,5 @@
14
13
  "cedarling_wasm.d.ts"
15
14
  ],
16
15
  "main": "cedarling_wasm.js",
17
- "types": "cedarling_wasm.d.ts",
18
- "sideEffects": [
19
- "./snippets/*"
20
- ]
16
+ "types": "cedarling_wasm.d.ts"
21
17
  }