frida-fs 5.2.4 → 6.0.0

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/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
3
  /// <reference types="frida-gum" />
4
- /// <reference types="node" />
4
+ /// <reference types="node" resolution-mode="require"/>
5
+ /// <reference types="node" resolution-mode="require"/>
5
6
  import { Buffer } from "buffer";
6
7
  import stream from "stream";
7
8
  declare const constants: {
package/dist/index.js CHANGED
@@ -1,15 +1,3 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _ReadStream_input, _ReadStream_readRequest, _WriteStream_output, _WriteStream_writeRequest;
13
1
  import { Buffer } from "buffer";
14
2
  import fsPath from "path";
15
3
  import process from "process";
@@ -119,12 +107,12 @@ const SEEK_CUR = 1;
119
107
  const SEEK_END = 2;
120
108
  const EINTR = 4;
121
109
  class ReadStream extends stream.Readable {
110
+ #input = null;
111
+ #readRequest = null;
122
112
  constructor(path) {
123
113
  super({
124
114
  highWaterMark: 4 * 1024 * 1024
125
115
  });
126
- _ReadStream_input.set(this, null);
127
- _ReadStream_readRequest.set(this, null);
128
116
  if (isWindows) {
129
117
  const api = getWindowsApi();
130
118
  const result = api.CreateFileW(Memory.allocUtf16String(path), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
@@ -135,7 +123,7 @@ class ReadStream extends stream.Readable {
135
123
  });
136
124
  return;
137
125
  }
138
- __classPrivateFieldSet(this, _ReadStream_input, new Win32InputStream(handle, { autoClose: true }), "f");
126
+ this.#input = new Win32InputStream(handle, { autoClose: true });
139
127
  }
140
128
  else {
141
129
  const api = getPosixApi();
@@ -147,20 +135,20 @@ class ReadStream extends stream.Readable {
147
135
  });
148
136
  return;
149
137
  }
150
- __classPrivateFieldSet(this, _ReadStream_input, new UnixInputStream(fd, { autoClose: true }), "f");
138
+ this.#input = new UnixInputStream(fd, { autoClose: true });
151
139
  }
152
140
  }
153
141
  _destroy(error, callback) {
154
- __classPrivateFieldGet(this, _ReadStream_input, "f")?.close();
155
- __classPrivateFieldSet(this, _ReadStream_input, null, "f");
142
+ this.#input?.close();
143
+ this.#input = null;
156
144
  callback(error);
157
145
  }
158
146
  _read(size) {
159
- if (__classPrivateFieldGet(this, _ReadStream_readRequest, "f") !== null)
147
+ if (this.#readRequest !== null)
160
148
  return;
161
- __classPrivateFieldSet(this, _ReadStream_readRequest, __classPrivateFieldGet(this, _ReadStream_input, "f").read(size)
149
+ this.#readRequest = this.#input.read(size)
162
150
  .then(buffer => {
163
- __classPrivateFieldSet(this, _ReadStream_readRequest, null, "f");
151
+ this.#readRequest = null;
164
152
  if (buffer.byteLength === 0) {
165
153
  this.push(null);
166
154
  return;
@@ -169,19 +157,18 @@ class ReadStream extends stream.Readable {
169
157
  this._read(size);
170
158
  })
171
159
  .catch(error => {
172
- __classPrivateFieldSet(this, _ReadStream_readRequest, null, "f");
160
+ this.#readRequest = null;
173
161
  this.destroy(error);
174
- }), "f");
162
+ });
175
163
  }
176
164
  }
177
- _ReadStream_input = new WeakMap(), _ReadStream_readRequest = new WeakMap();
178
165
  class WriteStream extends stream.Writable {
166
+ #output = null;
167
+ #writeRequest = null;
179
168
  constructor(path) {
180
169
  super({
181
170
  highWaterMark: 4 * 1024 * 1024
182
171
  });
183
- _WriteStream_output.set(this, null);
184
- _WriteStream_writeRequest.set(this, null);
185
172
  if (isWindows) {
186
173
  const api = getWindowsApi();
187
174
  const result = api.CreateFileW(Memory.allocUtf16String(path), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
@@ -192,7 +179,7 @@ class WriteStream extends stream.Writable {
192
179
  });
193
180
  return;
194
181
  }
195
- __classPrivateFieldSet(this, _WriteStream_output, new Win32OutputStream(handle, { autoClose: true }), "f");
182
+ this.#output = new Win32OutputStream(handle, { autoClose: true });
196
183
  }
197
184
  else {
198
185
  const api = getPosixApi();
@@ -207,29 +194,28 @@ class WriteStream extends stream.Writable {
207
194
  });
208
195
  return;
209
196
  }
210
- __classPrivateFieldSet(this, _WriteStream_output, new UnixOutputStream(fd, { autoClose: true }), "f");
197
+ this.#output = new UnixOutputStream(fd, { autoClose: true });
211
198
  }
212
199
  }
213
200
  _destroy(error, callback) {
214
- __classPrivateFieldGet(this, _WriteStream_output, "f")?.close();
215
- __classPrivateFieldSet(this, _WriteStream_output, null, "f");
201
+ this.#output?.close();
202
+ this.#output = null;
216
203
  callback(error);
217
204
  }
218
205
  _write(chunk, encoding, callback) {
219
- if (__classPrivateFieldGet(this, _WriteStream_writeRequest, "f") !== null)
206
+ if (this.#writeRequest !== null)
220
207
  return;
221
- __classPrivateFieldSet(this, _WriteStream_writeRequest, __classPrivateFieldGet(this, _WriteStream_output, "f").writeAll(chunk)
208
+ this.#writeRequest = this.#output.writeAll(chunk)
222
209
  .then(size => {
223
- __classPrivateFieldSet(this, _WriteStream_writeRequest, null, "f");
210
+ this.#writeRequest = null;
224
211
  callback();
225
212
  })
226
213
  .catch(error => {
227
- __classPrivateFieldSet(this, _WriteStream_writeRequest, null, "f");
214
+ this.#writeRequest = null;
228
215
  callback(error);
229
- }), "f");
216
+ });
230
217
  }
231
218
  }
232
- _WriteStream_output = new WeakMap(), _WriteStream_writeRequest = new WeakMap();
233
219
  const windowsBackend = {
234
220
  enumerateDirectoryEntries(path, callback) {
235
221
  enumerateWindowsDirectoryEntriesMatching(path + "\\*", callback);
@@ -728,6 +714,25 @@ function getStatSpec() {
728
714
  return statSpec;
729
715
  }
730
716
  class Stats {
717
+ dev;
718
+ mode;
719
+ nlink;
720
+ uid;
721
+ gid;
722
+ rdev;
723
+ blksize;
724
+ ino;
725
+ size;
726
+ blocks;
727
+ atimeMs;
728
+ mtimeMs;
729
+ ctimeMs;
730
+ birthtimeMs;
731
+ atime;
732
+ mtime;
733
+ ctime;
734
+ birthtime;
735
+ buffer;
731
736
  isFile() {
732
737
  return (this.mode & S_IFMT) === S_IFREG;
733
738
  }
@@ -770,10 +775,13 @@ function makeStatsProxy(path, buf) {
770
775
  return receiver;
771
776
  case "buffer":
772
777
  return buf;
773
- default:
774
- if (typeof property === "symbol" || property in target)
775
- return target[property];
778
+ default: {
779
+ let val;
780
+ if (typeof property === "symbol" || (val = target[property]) !== undefined) {
781
+ return val;
782
+ }
776
783
  return statsReadField.call(receiver, property, path);
784
+ }
777
785
  }
778
786
  },
779
787
  set(target, property, value, receiver) {
@@ -956,6 +964,7 @@ function makeApi(spec) {
956
964
  return api;
957
965
  }, {});
958
966
  }
967
+ const kernel32 = isWindows ? Process.getModuleByName("kernel32.dll") : null;
959
968
  const nativeOpts = (isWindows && pointerSize === 4) ? { abi: "stdcall" } : {};
960
969
  function addApiPlaceholder(api, entry) {
961
970
  const [name] = entry;
@@ -965,8 +974,8 @@ function addApiPlaceholder(api, entry) {
965
974
  const [, Ctor, retType, argTypes, wrapper] = entry;
966
975
  let impl = null;
967
976
  const address = isWindows
968
- ? Module.findExportByName("kernel32.dll", name)
969
- : Module.findExportByName(null, name);
977
+ ? kernel32.findExportByName(name)
978
+ : Module.findGlobalExportByName(name);
970
979
  if (address !== null)
971
980
  impl = new Ctor(address, retType, argTypes, nativeOpts);
972
981
  if (wrapper !== undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frida-fs",
3
- "version": "5.2.4",
3
+ "version": "6.0.0",
4
4
  "description": "Create a stream from a filesystem resource",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "homepage": "https://github.com/nowsecure/frida-fs#readme",
25
25
  "devDependencies": {
26
- "@types/frida-gum": "^18.3.2",
27
- "@types/node": "^20.3.1",
26
+ "@types/frida-gum": "^19.0.0",
27
+ "@types/node": "^18.15.3",
28
28
  "typescript": "^5.1.3"
29
29
  }
30
30
  }