@open-wa/wa-automate 4.51.4 → 4.51.6

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.
@@ -446,7 +446,7 @@ function initBrowser(sessionId, config = {}, spinner) {
446
446
  let args = [...puppeteer_config_1.puppeteerConfig.chromiumArgs, ...((config === null || config === void 0 ? void 0 : config.chromiumArgs) || [])];
447
447
  if (config === null || config === void 0 ? void 0 : config.multiDevice) {
448
448
  args = args.filter(x => x != '--incognito');
449
- config["userDataDir"] = config["userDataDir"] || `${(config === null || config === void 0 ? void 0 : config.sessionDataPath) || (config === null || config === void 0 ? void 0 : config.inDocker) ? '/sessions' : (config === null || config === void 0 ? void 0 : config.sessionDataPath) || '.'}/_IGNORE_${(config === null || config === void 0 ? void 0 : config.sessionId) || 'session'}`;
449
+ config["userDataDir"] = config["userDataDir"] || `${(config === null || config === void 0 ? void 0 : config.sessionDataPath) || ((config === null || config === void 0 ? void 0 : config.inDocker) ? '/sessions' : (config === null || config === void 0 ? void 0 : config.sessionDataPath) || '.')}/_IGNORE_${(config === null || config === void 0 ? void 0 : config.sessionId) || 'session'}`;
450
450
  spinner === null || spinner === void 0 ? void 0 : spinner.info('MD Enabled, turning off incognito mode.');
451
451
  spinner === null || spinner === void 0 ? void 0 : spinner.info(`Data dir: ${config["userDataDir"]}`);
452
452
  }
@@ -170,7 +170,7 @@ function create(config = {}) {
170
170
  /**
171
171
  * Check if the IGNORE folder exists, therefore, assume that the session is MD.
172
172
  */
173
- const mdDir = config["userDataDir"] || `${(config === null || config === void 0 ? void 0 : config.inDocker) ? '/sessions' : (config === null || config === void 0 ? void 0 : config.sessionDataPath) || '.'}/_IGNORE_${(config === null || config === void 0 ? void 0 : config.sessionId) || 'session'}`;
173
+ const mdDir = config["userDataDir"] || `${(config === null || config === void 0 ? void 0 : config.sessionDataPath) || ((config === null || config === void 0 ? void 0 : config.inDocker) ? '/sessions' : (config === null || config === void 0 ? void 0 : config.sessionDataPath) || '.')}/_IGNORE_${(config === null || config === void 0 ? void 0 : config.sessionId) || 'session'}`;
174
174
  if (process.env.AUTO_MD && fs.existsSync(mdDir) && !(config === null || config === void 0 ? void 0 : config.multiDevice)) {
175
175
  spinner.info(`Multi-Device directory detected. multiDevice set to true.`);
176
176
  config.multiDevice = true;
@@ -37,7 +37,7 @@ const AUTO_DECRYPT = (message, client) => __awaiter(void 0, void 0, void 0, func
37
37
  });
38
38
  const AUTO_DECRYPT_SAVE = (message, client) => __awaiter(void 0, void 0, void 0, function* () {
39
39
  if (message.deprecatedMms3Url && message.mimetype) {
40
- const filename = `${message.mId}.${mime_1.default.extension(message.mimetype)}`;
40
+ const filename = `${message.mId}.${mime_1.default.getExtension(message.mimetype)}`;
41
41
  const filePath = `media/${filename}`;
42
42
  try {
43
43
  const mediaData = yield client.decryptMedia(message);
@@ -59,7 +59,7 @@ const UPLOAD_CLOUD = (message, client) => __awaiter(void 0, void 0, void 0, func
59
59
  if (!uploadQueue) {
60
60
  uploadQueue = new p_queue_1.default({ concurrency: 2, interval: 1000, carryoverConcurrencyCount: true, intervalCap: 2 });
61
61
  }
62
- const filename = `${message.mId || `${Date.now()}`}.${mime_1.default.extension(message.mimetype)}`;
62
+ const filename = `${message.mId || `${Date.now()}`}.${mime_1.default.getExtension(message.mimetype)}`;
63
63
  const mediaData = yield client.decryptMedia(message);
64
64
  if (!cloudUploadOptions)
65
65
  return message;
@@ -315,7 +315,7 @@ const ensureDUrl = (file, requestConfig = {}, filename) => __awaiter(void 0, voi
315
315
  const { ext } = yield (yield ft()).fileTypeFromBuffer(file);
316
316
  filename = `file.${ext}`;
317
317
  }
318
- return `data:${mime_1.default.lookup(filename)};base64,${file.toString('base64').split(',')[1]}`;
318
+ return `data:${mime_1.default.getType(filename)};base64,${file.toString('base64').split(',')[1]}`;
319
319
  }
320
320
  else if (!(0, exports.isDataURL)(file) && !(0, exports.isBase64)(file)) {
321
321
  //must be a file then
@@ -333,8 +333,8 @@ const ensureDUrl = (file, requestConfig = {}, filename) => __awaiter(void 0, voi
333
333
  const { ext } = yield (yield ft()).fileTypeFromBuffer(Buffer.from(file.split(',')[1], 'base64'));
334
334
  filename = `file.${ext}`;
335
335
  }
336
- if (file.includes("data:") && file.includes("undefined") || file.includes("application/octet-stream") && filename && mime_1.default.lookup(filename)) {
337
- file = `data:${mime_1.default.lookup(filename)};base64,${file.split(',')[1]}`;
336
+ if (file.includes("data:") && file.includes("undefined") || file.includes("application/octet-stream") && filename && mime_1.default.getType(filename)) {
337
+ file = `data:${mime_1.default.getType(filename)};base64,${file.split(',')[1]}`;
338
338
  }
339
339
  return file;
340
340
  });
@@ -419,7 +419,7 @@ const assertFile = (file, outfileName, desiredOutputType, requestConfig) => __aw
419
419
  let tfn = `${crypto_1.default.randomBytes(6).readUIntLE(0, 6).toString(36)}.${outfileName}`;
420
420
  if (inputType != exports.FileInputTypes.BUFFER) {
421
421
  file = yield (0, exports.ensureDUrl)(file, requestConfig, outfileName);
422
- const ext = mime_1.default.extension(file.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)[0]);
422
+ const ext = mime_1.default.getExtension(file.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)[0]);
423
423
  if (ext && !IGNORE_FILE_EXTS.includes(ext) && !tfn.endsWith(ext))
424
424
  tfn = `${tfn}.${ext}`;
425
425
  file = Buffer.from(file.split(',')[1], 'base64');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.51.4",
3
+ "version": "4.51.6",
4
4
  "licenseCheckUrl": "https://funcs.openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://funcs.openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",
@@ -16,6 +16,7 @@
16
16
  "build:skipmid": "tsc && npm run build:lib",
17
17
  "build:lib": "ts-node prebuild.ts",
18
18
  "docs": "npm run --prefix docs-v3 deploy_with_ssh_ci",
19
+ "types:publish": "npm run --prefix types-only pub",
19
20
  "watch": "npm run build && tsc-watch ./src/index.ts --outDir ./dist --onSuccess \"node ./dist/index.js\" --onFailure \"echo Error while compiling\" --compiler typescript/bin/tsc",
20
21
  "clean": "rm -rf session && rm -rf dist",
21
22
  "clean:full": "rm -rf node_modules && npm run clean",
@@ -73,7 +74,7 @@
73
74
  "@types/line-reader": "0.0.34",
74
75
  "@types/localtunnel": "^2.0.1",
75
76
  "@types/marked": "^4.0.2",
76
- "@types/mime-types": "^2.1.0",
77
+ "@types/mime": "^3.0.1",
77
78
  "@types/node": "^18.7.6",
78
79
  "@types/puppeteer": "^5.4.0",
79
80
  "@types/shelljs": "^0.8.5",
@@ -141,6 +142,7 @@
141
142
  "localtunnel": "^2.0.2",
142
143
  "lodash.uniq": "^4.5.0",
143
144
  "meow": "^9.0.0",
145
+ "mime": "^3.0.0",
144
146
  "node-persist": "^3.1.0",
145
147
  "open": "^8.0.2",
146
148
  "os-name": "^4.0.0",