@janssenproject/cedarling_wasm 0.0.313 → 0.0.314-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.
@@ -227,96 +227,3 @@ export function init(config: any): Promise<Cedarling>;
227
227
  * ```
228
228
  */
229
229
  export function init_from_archive_bytes(config: any, archive_bytes: Uint8Array): Promise<Cedarling>;
230
-
231
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
232
-
233
- export interface InitOutput {
234
- readonly memory: WebAssembly.Memory;
235
- readonly __wbg_cedarling_free: (a: number, b: number) => void;
236
- readonly __wbg_multiissuerauthorizeresult_free: (a: number, b: number) => void;
237
- readonly __wbg_get_multiissuerauthorizeresult_response: (a: number) => number;
238
- readonly __wbg_set_multiissuerauthorizeresult_response: (a: number, b: number) => void;
239
- readonly __wbg_get_multiissuerauthorizeresult_decision: (a: number) => number;
240
- readonly __wbg_set_multiissuerauthorizeresult_decision: (a: number, b: number) => void;
241
- readonly __wbg_get_multiissuerauthorizeresult_request_id: (a: number) => [number, number];
242
- readonly __wbg_set_multiissuerauthorizeresult_request_id: (a: number, b: number, c: number) => void;
243
- readonly multiissuerauthorizeresult_json_string: (a: number) => [number, number];
244
- readonly init: (a: any) => any;
245
- readonly init_from_archive_bytes: (a: any, b: any) => any;
246
- readonly cedarling_new: (a: any) => any;
247
- readonly cedarling_new_from_map: (a: any) => any;
248
- readonly cedarling_authorize: (a: number, b: any) => any;
249
- readonly cedarling_authorize_unsigned: (a: number, b: any) => any;
250
- readonly cedarling_authorize_multi_issuer: (a: number, b: any) => any;
251
- readonly cedarling_pop_logs: (a: number) => [number, number, number];
252
- readonly cedarling_get_log_by_id: (a: number, b: number, c: number) => [number, number, number];
253
- readonly cedarling_get_log_ids: (a: number) => any;
254
- readonly cedarling_get_logs_by_tag: (a: number, b: number, c: number) => [number, number, number, number];
255
- readonly cedarling_get_logs_by_request_id: (a: number, b: number, c: number) => [number, number, number, number];
256
- readonly cedarling_get_logs_by_request_id_and_tag: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
257
- readonly cedarling_shut_down: (a: number) => any;
258
- readonly __wbg_authorizeresult_free: (a: number, b: number) => void;
259
- readonly __wbg_get_authorizeresult_workload: (a: number) => number;
260
- readonly __wbg_set_authorizeresult_workload: (a: number, b: number) => void;
261
- readonly __wbg_get_authorizeresult_person: (a: number) => number;
262
- readonly __wbg_set_authorizeresult_person: (a: number, b: number) => void;
263
- readonly __wbg_get_authorizeresult_decision: (a: number) => number;
264
- readonly __wbg_set_authorizeresult_decision: (a: number, b: number) => void;
265
- readonly __wbg_get_authorizeresult_request_id: (a: number) => [number, number];
266
- readonly __wbg_set_authorizeresult_request_id: (a: number, b: number, c: number) => void;
267
- readonly authorizeresult_json_string: (a: number) => [number, number];
268
- readonly authorizeresult_principal: (a: number, b: number, c: number) => number;
269
- readonly __wbg_authorizeresultresponse_free: (a: number, b: number) => void;
270
- readonly authorizeresultresponse_decision: (a: number) => number;
271
- readonly authorizeresultresponse_diagnostics: (a: number) => number;
272
- readonly __wbg_diagnostics_free: (a: number, b: number) => void;
273
- readonly diagnostics_reason: (a: number) => [number, number];
274
- readonly diagnostics_errors: (a: number) => [number, number];
275
- readonly __wbg_policyevaluationerror_free: (a: number, b: number) => void;
276
- readonly policyevaluationerror_id: (a: number) => [number, number];
277
- readonly policyevaluationerror_error: (a: number) => [number, number];
278
- readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
279
- readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
280
- readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
281
- readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
282
- readonly rust_zstd_wasm_shim_free: (a: number) => void;
283
- readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
284
- readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
285
- readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
286
- readonly wasm_bindgen__closure__destroy__hd529f22c34389d0f: (a: number, b: number) => void;
287
- readonly wasm_bindgen__closure__destroy__h0bd98a3a1d60a5b1: (a: number, b: number) => void;
288
- readonly wasm_bindgen__convert__closures_____invoke__h826419d66d164abb: (a: number, b: number, c: any) => [number, number];
289
- readonly wasm_bindgen__convert__closures_____invoke__h494d783032f4344f: (a: number, b: number, c: any, d: any) => void;
290
- readonly wasm_bindgen__convert__closures_____invoke__hbf3e188fe995424e: (a: number, b: number) => void;
291
- readonly __wbindgen_malloc: (a: number, b: number) => number;
292
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
293
- readonly __wbindgen_exn_store: (a: number) => void;
294
- readonly __externref_table_alloc: () => number;
295
- readonly __wbindgen_externrefs: WebAssembly.Table;
296
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
297
- readonly __externref_table_dealloc: (a: number) => void;
298
- readonly __externref_drop_slice: (a: number, b: number) => void;
299
- readonly __wbindgen_start: () => void;
300
- }
301
-
302
- export type SyncInitInput = BufferSource | WebAssembly.Module;
303
-
304
- /**
305
- * Instantiates the given `module`, which can either be bytes or
306
- * a precompiled `WebAssembly.Module`.
307
- *
308
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
309
- *
310
- * @returns {InitOutput}
311
- */
312
- export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
313
-
314
- /**
315
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
316
- * for everything else, calls `WebAssembly.instantiate` directly.
317
- *
318
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
319
- *
320
- * @returns {Promise<InitOutput>}
321
- */
322
- 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,12 +406,13 @@ 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
411
  /**
408
412
  * A WASM wrapper for the Rust `cedarling::MultiIssuerAuthorizeResult` struct.
409
413
  * Represents the result of a multi-issuer authorization request.
410
414
  */
411
- export class MultiIssuerAuthorizeResult {
415
+ class MultiIssuerAuthorizeResult {
412
416
  static __wrap(ptr) {
413
417
  ptr = ptr >>> 0;
414
418
  const obj = Object.create(MultiIssuerAuthorizeResult.prototype);
@@ -505,6 +509,7 @@ export class MultiIssuerAuthorizeResult {
505
509
  }
506
510
  }
507
511
  if (Symbol.dispose) MultiIssuerAuthorizeResult.prototype[Symbol.dispose] = MultiIssuerAuthorizeResult.prototype.free;
512
+ exports.MultiIssuerAuthorizeResult = MultiIssuerAuthorizeResult;
508
513
 
509
514
  /**
510
515
  * PolicyEvaluationError
@@ -512,7 +517,7 @@ if (Symbol.dispose) MultiIssuerAuthorizeResult.prototype[Symbol.dispose] = Multi
512
517
  *
513
518
  * Represents an error that occurred when evaluating a Cedar policy.
514
519
  */
515
- export class PolicyEvaluationError {
520
+ class PolicyEvaluationError {
516
521
  static __wrap(ptr) {
517
522
  ptr = ptr >>> 0;
518
523
  const obj = Object.create(PolicyEvaluationError.prototype);
@@ -564,6 +569,7 @@ export class PolicyEvaluationError {
564
569
  }
565
570
  }
566
571
  if (Symbol.dispose) PolicyEvaluationError.prototype[Symbol.dispose] = PolicyEvaluationError.prototype.free;
572
+ exports.PolicyEvaluationError = PolicyEvaluationError;
567
573
 
568
574
  /**
569
575
  * Create a new instance of the Cedarling application.
@@ -571,10 +577,11 @@ if (Symbol.dispose) PolicyEvaluationError.prototype[Symbol.dispose] = PolicyEval
571
577
  * @param {any} config
572
578
  * @returns {Promise<Cedarling>}
573
579
  */
574
- export function init(config) {
580
+ function init(config) {
575
581
  const ret = wasm.init(config);
576
582
  return ret;
577
583
  }
584
+ exports.init = init;
578
585
 
579
586
  /**
580
587
  * Create a new instance of the Cedarling application from archive bytes.
@@ -596,10 +603,11 @@ export function init(config) {
596
603
  * @param {Uint8Array} archive_bytes
597
604
  * @returns {Promise<Cedarling>}
598
605
  */
599
- export function init_from_archive_bytes(config, archive_bytes) {
606
+ function init_from_archive_bytes(config, archive_bytes) {
600
607
  const ret = wasm.init_from_archive_bytes(config, archive_bytes);
601
608
  return ret;
602
609
  }
610
+ exports.init_from_archive_bytes = init_from_archive_bytes;
603
611
 
604
612
  function __wbg_get_imports() {
605
613
  const import0 = {
@@ -1388,15 +1396,7 @@ function takeFromExternrefTable0(idx) {
1388
1396
 
1389
1397
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1390
1398
  cachedTextDecoder.decode();
1391
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
1392
- let numBytesDecoded = 0;
1393
1399
  function decodeText(ptr, len) {
1394
- numBytesDecoded += len;
1395
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1396
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1397
- cachedTextDecoder.decode();
1398
- numBytesDecoded = len;
1399
- }
1400
1400
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1401
1401
  }
1402
1402
 
@@ -1415,95 +1415,8 @@ if (!('encodeInto' in cachedTextEncoder)) {
1415
1415
 
1416
1416
  let WASM_VECTOR_LEN = 0;
1417
1417
 
1418
- let wasmModule, wasm;
1419
- function __wbg_finalize_init(instance, module) {
1420
- wasm = instance.exports;
1421
- wasmModule = module;
1422
- cachedDataViewMemory0 = null;
1423
- cachedUint8ArrayMemory0 = null;
1424
- wasm.__wbindgen_start();
1425
- return wasm;
1426
- }
1427
-
1428
- async function __wbg_load(module, imports) {
1429
- if (typeof Response === 'function' && module instanceof Response) {
1430
- if (typeof WebAssembly.instantiateStreaming === 'function') {
1431
- try {
1432
- return await WebAssembly.instantiateStreaming(module, imports);
1433
- } catch (e) {
1434
- const validResponse = module.ok && expectedResponseType(module.type);
1435
-
1436
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1437
- 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);
1438
-
1439
- } else { throw e; }
1440
- }
1441
- }
1442
-
1443
- const bytes = await module.arrayBuffer();
1444
- return await WebAssembly.instantiate(bytes, imports);
1445
- } else {
1446
- const instance = await WebAssembly.instantiate(module, imports);
1447
-
1448
- if (instance instanceof WebAssembly.Instance) {
1449
- return { instance, module };
1450
- } else {
1451
- return instance;
1452
- }
1453
- }
1454
-
1455
- function expectedResponseType(type) {
1456
- switch (type) {
1457
- case 'basic': case 'cors': case 'default': return true;
1458
- }
1459
- return false;
1460
- }
1461
- }
1462
-
1463
- function initSync(module) {
1464
- if (wasm !== undefined) return wasm;
1465
-
1466
-
1467
- if (module !== undefined) {
1468
- if (Object.getPrototypeOf(module) === Object.prototype) {
1469
- ({module} = module)
1470
- } else {
1471
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1472
- }
1473
- }
1474
-
1475
- const imports = __wbg_get_imports();
1476
- if (!(module instanceof WebAssembly.Module)) {
1477
- module = new WebAssembly.Module(module);
1478
- }
1479
- const instance = new WebAssembly.Instance(module, imports);
1480
- return __wbg_finalize_init(instance, module);
1481
- }
1482
-
1483
- async function __wbg_init(module_or_path) {
1484
- if (wasm !== undefined) return wasm;
1485
-
1486
-
1487
- if (module_or_path !== undefined) {
1488
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1489
- ({module_or_path} = module_or_path)
1490
- } else {
1491
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1492
- }
1493
- }
1494
-
1495
- if (module_or_path === undefined) {
1496
- module_or_path = new URL('cedarling_wasm_bg.wasm', import.meta.url);
1497
- }
1498
- const imports = __wbg_get_imports();
1499
-
1500
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1501
- module_or_path = fetch(module_or_path);
1502
- }
1503
-
1504
- const { instance, module } = await __wbg_load(await module_or_path, imports);
1505
-
1506
- return __wbg_finalize_init(instance, module);
1507
- }
1508
-
1509
- export { initSync, __wbg_init as default };
1418
+ const wasmPath = `${__dirname}/cedarling_wasm_bg.wasm`;
1419
+ const wasmBytes = require('fs').readFileSync(wasmPath);
1420
+ const wasmModule = new WebAssembly.Module(wasmBytes);
1421
+ let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
1422
+ 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.313",
4
+ "version": "0.0.314-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
  }