@aml-org/amf-custom-validator 1.3.0-SNAPSHOT.85 → 1.3.0-SNAPSHOT.87

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/index.js CHANGED
@@ -66,7 +66,7 @@ const initialize = function(cb) {
66
66
  go.run(result.instance);
67
67
  initialized = true;
68
68
  cb(undefined);
69
- });
69
+ }).catch(rejection => console.log(rejection));
70
70
  } else {
71
71
  cb(new Error("WebAssembly is not supported in your JS environment"));
72
72
  }
package/lib/main.wasm.gz CHANGED
Binary file
package/lib/wasm_exec.js CHANGED
@@ -2,47 +2,18 @@
2
2
  // Use of this source code is governed by a BSD-style
3
3
  // license that can be found in the LICENSE file.
4
4
 
5
- (() => {
6
- // Map multiple JavaScript environments to a single common API,
7
- // preferring web standards over Node.js API.
8
- //
9
- // Environments considered:
10
- // - Browsers
11
- // - Node.js
12
- // - Electron
13
- // - Parcel
14
- // - Webpack
15
-
16
- if (typeof global !== "undefined") {
17
- // global already exists
18
- } else if (typeof window !== "undefined") {
19
- window.global = window;
20
- } else if (typeof self !== "undefined") {
21
- self.global = self;
22
- } else {
23
- throw new Error("cannot export Go (neither global, window nor self is defined)");
24
- }
25
-
26
- if (!global.require && typeof require !== "undefined") {
27
- global.require = require;
28
- }
29
-
30
- if (!global.fs && global.require) {
31
- const fs = require("fs");
32
- if (typeof fs === "object" && fs !== null && Object.keys(fs).length !== 0) {
33
- global.fs = fs;
34
- }
35
- }
5
+ "use strict";
36
6
 
7
+ (() => {
37
8
  const enosys = () => {
38
9
  const err = new Error("not implemented");
39
10
  err.code = "ENOSYS";
40
11
  return err;
41
12
  };
42
13
 
43
- if (!global.fs) {
14
+ if (!globalThis.fs) {
44
15
  let outputBuf = "";
45
- global.fs = {
16
+ globalThis.fs = {
46
17
  constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused
47
18
  writeSync(fd, buf) {
48
19
  outputBuf += decoder.decode(buf);
@@ -87,8 +58,8 @@
87
58
  };
88
59
  }
89
60
 
90
- if (!global.process) {
91
- global.process = {
61
+ if (!globalThis.process) {
62
+ globalThis.process = {
92
63
  getuid() { return -1; },
93
64
  getgid() { return -1; },
94
65
  geteuid() { return -1; },
@@ -102,47 +73,26 @@
102
73
  }
103
74
  }
104
75
 
105
- if (!global.crypto && global.require) {
106
- const nodeCrypto = require("crypto");
107
- global.crypto = {
108
- getRandomValues(b) {
109
- nodeCrypto.randomFillSync(b);
110
- },
111
- };
112
- }
113
- if (!global.crypto) {
114
- throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");
76
+ if (!globalThis.crypto) {
77
+ throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");
115
78
  }
116
79
 
117
- if (!global.performance) {
118
- global.performance = {
119
- now() {
120
- const [sec, nsec] = process.hrtime();
121
- return sec * 1000 + nsec / 1000000;
122
- },
123
- };
80
+ if (!globalThis.performance) {
81
+ throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");
124
82
  }
125
83
 
126
- if (!global.TextEncoder && global.require) {
127
- global.TextEncoder = require("util").TextEncoder;
128
- }
129
- if (!global.TextEncoder) {
130
- throw new Error("global.TextEncoder is not available, polyfill required");
84
+ if (!globalThis.TextEncoder) {
85
+ throw new Error("globalThis.TextEncoder is not available, polyfill required");
131
86
  }
132
87
 
133
- if (!global.TextDecoder && global.require) {
134
- global.TextDecoder = require("util").TextDecoder;
135
- }
136
- if (!global.TextDecoder) {
137
- throw new Error("global.TextDecoder is not available, polyfill required");
88
+ if (!globalThis.TextDecoder) {
89
+ throw new Error("globalThis.TextDecoder is not available, polyfill required");
138
90
  }
139
91
 
140
- // End of polyfills for common API.
141
-
142
92
  const encoder = new TextEncoder("utf-8");
143
93
  const decoder = new TextDecoder("utf-8");
144
94
 
145
- global.Go = class {
95
+ globalThis.Go = class {
146
96
  constructor() {
147
97
  this.argv = ["js"];
148
98
  this.env = {};
@@ -296,8 +246,8 @@
296
246
  setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);
297
247
  },
298
248
 
299
- // func walltime1() (sec int64, nsec int32)
300
- "runtime.walltime1": (sp) => {
249
+ // func walltime() (sec int64, nsec int32)
250
+ "runtime.walltime": (sp) => {
301
251
  sp >>>= 0;
302
252
  const msec = (new Date).getTime();
303
253
  setInt64(sp + 8, msec / 1000);
@@ -401,6 +351,7 @@
401
351
  storeValue(sp + 56, result);
402
352
  this.mem.setUint8(sp + 64, 1);
403
353
  } catch (err) {
354
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
404
355
  storeValue(sp + 56, err);
405
356
  this.mem.setUint8(sp + 64, 0);
406
357
  }
@@ -417,6 +368,7 @@
417
368
  storeValue(sp + 40, result);
418
369
  this.mem.setUint8(sp + 48, 1);
419
370
  } catch (err) {
371
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
420
372
  storeValue(sp + 40, err);
421
373
  this.mem.setUint8(sp + 48, 0);
422
374
  }
@@ -433,6 +385,7 @@
433
385
  storeValue(sp + 40, result);
434
386
  this.mem.setUint8(sp + 48, 1);
435
387
  } catch (err) {
388
+ sp = this._inst.exports.getsp() >>> 0; // see comment above
436
389
  storeValue(sp + 40, err);
437
390
  this.mem.setUint8(sp + 48, 0);
438
391
  }
@@ -514,7 +467,7 @@
514
467
  null,
515
468
  true,
516
469
  false,
517
- global,
470
+ globalThis,
518
471
  this,
519
472
  ];
520
473
  this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id
@@ -523,7 +476,7 @@
523
476
  [null, 2],
524
477
  [true, 3],
525
478
  [false, 4],
526
- [global, 5],
479
+ [globalThis, 5],
527
480
  [this, 6],
528
481
  ]);
529
482
  this._idPool = []; // unused ids that have been garbage collected
@@ -598,36 +551,4 @@
598
551
  };
599
552
  }
600
553
  }
601
-
602
- if (
603
- typeof module !== "undefined" &&
604
- global.require &&
605
- global.require.main === module &&
606
- global.process &&
607
- global.process.versions &&
608
- !global.process.versions.electron
609
- ) {
610
- if (process.argv.length < 3) {
611
- console.error("usage: go_js_wasm_exec [wasm binary] [arguments]");
612
- process.exit(1);
613
- }
614
-
615
- const go = new Go();
616
- go.argv = process.argv.slice(2);
617
- go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env);
618
- go.exit = process.exit;
619
- WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => {
620
- process.on("exit", (code) => { // Node.js exits if no event handler is pending
621
- if (code === 0 && !go.exited) {
622
- // deadlock, make Go print error and stack traces
623
- go._pendingEvent = { id: 0 };
624
- go._resume();
625
- }
626
- });
627
- return go.run(result.instance);
628
- }).catch((err) => {
629
- console.error(err);
630
- process.exit(1);
631
- });
632
- }
633
554
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aml-org/amf-custom-validator",
3
- "version": "1.3.0-SNAPSHOT.85",
3
+ "version": "1.3.0-SNAPSHOT.87",
4
4
  "description": "AMF validator backed by OPA Rego",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,6 +8,9 @@
8
8
  },
9
9
  "author": "Antonio Garrote",
10
10
  "license": "ISC",
11
+ "engines": {
12
+ "node": ">=19.2.0"
13
+ },
11
14
  "devDependencies": {
12
15
  "mocha": "^8.4.0"
13
16
  },