@bytecodealliance/preview2-shim 0.18.0 → 0.18.1

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.
@@ -43,6 +43,22 @@ const timeZero = {
43
43
  nanoseconds: 0,
44
44
  };
45
45
 
46
+ /** Coerce the given object to a safe integer */
47
+ function coerceToSafeIntegerNumber(obj) {
48
+ let n;
49
+ if (typeof obj === "number") {
50
+ n = obj;
51
+ } else if (typeof obj == "bigint") {
52
+ n = Number(obj);
53
+ } else {
54
+ throw new TypeError(`unexpected non-numeric type: ${obj}`);
55
+ }
56
+ if (n > Number.MAX_SAFE_INTEGER) {
57
+ throw new TypeError(`excessively large number: ${n}`);
58
+ }
59
+ return n;
60
+ }
61
+
46
62
  function getChildEntry(parentEntry, subpath, openFlags) {
47
63
  if (subpath === "." && _rootPreopen && descriptorGetEntry(_rootPreopen[0]) === parentEntry) {
48
64
  subpath = _getCwd();
@@ -188,7 +204,9 @@ class Descriptor {
188
204
 
189
205
  read(length, offset) {
190
206
  const source = getSource(this.#entry);
191
- return [source.slice(offset, offset + length), offset + length >= source.byteLength];
207
+ const off = coerceToSafeIntegerNumber(offset);
208
+ const len = coerceToSafeIntegerNumber(length);
209
+ return [source.slice(off, off + len), off + len >= source.byteLength];
192
210
  }
193
211
 
194
212
  write(buffer, offset) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytecodealliance/preview2-shim",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "WASI Preview2 shim for JS environments",
5
5
  "homepage": "https://github.com/bytecodealliance/jco#readme",
6
6
  "bugs": {
@@ -52,7 +52,7 @@
52
52
  "@bytecodealliance/componentize-js": "0.21.0",
53
53
  "@bytecodealliance/jco": "1.15.2",
54
54
  "mime": "^4.0.7",
55
- "puppeteer": "^24.43.1"
55
+ "puppeteer": "^25.1.0"
56
56
  },
57
57
  "scripts": {
58
58
  "types:check": "tsc --noEmit",