@wppconnect-team/wppconnect 2.0.0 → 2.0.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.
- package/CHANGELOG.md +6 -0
- package/dist/api/helpers/base64-mimetype.js +2 -2
- package/dist/api/helpers/decrypt.js +65 -72
- package/dist/api/helpers/download-file.js +31 -81
- package/dist/api/helpers/evaluate-and-return.js +98 -93
- package/dist/api/helpers/file-to-base64.js +30 -81
- package/dist/api/helpers/filename-from-mimetype.js +4 -4
- package/dist/api/helpers/scrape-img-qr.js +37 -86
- package/dist/api/helpers/scrape-login.js +12 -57
- package/dist/api/helpers/select-sticker.js +35 -100
- package/dist/api/layers/business.layer.js +29 -134
- package/dist/api/layers/catalog.layer.js +59 -210
- package/dist/api/layers/community.layer.js +29 -120
- package/dist/api/layers/controls.layer.js +62 -262
- package/dist/api/layers/group.layer.js +126 -391
- package/dist/api/layers/host.layer.js +348 -702
- package/dist/api/layers/labels.layer.js +35 -131
- package/dist/api/layers/listener.layer.js +386 -504
- package/dist/api/layers/newsletter.layer.js +20 -89
- package/dist/api/layers/profile.layer.js +73 -184
- package/dist/api/layers/retriever.layer.js +161 -468
- package/dist/api/layers/sender.layer.js +554 -1094
- package/dist/api/layers/status.layer.js +80 -179
- package/dist/api/layers/ui.layer.js +32 -129
- package/dist/api/model/enum/definitions.js +1 -1
- package/dist/api/whatsapp.js +200 -437
- package/dist/config/WAuserAgente.js +1 -1
- package/dist/config/create-config.js +1 -1
- package/dist/config/puppeteer.config.js +1 -1
- package/dist/controllers/auth.js +42 -110
- package/dist/controllers/browser.js +251 -411
- package/dist/controllers/initializer.js +171 -265
- package/dist/controllers/websocket.js +29 -28
- package/dist/controllers/welcome.js +38 -88
- package/dist/token-store/fileTokenStore.js +83 -173
- package/dist/token-store/isValidSessionToken.js +2 -2
- package/dist/token-store/isValidTokenStore.js +2 -2
- package/dist/token-store/memoryTokenStore.js +11 -14
- package/dist/utils/ffmpeg.js +75 -131
- package/dist/utils/logger.js +5 -5
- package/dist/utils/semver.js +6 -6
- package/dist/utils/sleep.js +1 -1
- package/package.json +6 -6
package/dist/utils/ffmpeg.js
CHANGED
|
@@ -32,42 +32,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
-
function step(op) {
|
|
49
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
-
switch (op[0]) {
|
|
54
|
-
case 0: case 1: t = op; break;
|
|
55
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
-
default:
|
|
59
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
-
if (t[2]) _.ops.pop();
|
|
64
|
-
_.trys.pop(); continue;
|
|
65
|
-
}
|
|
66
|
-
op = body.call(thisArg, _);
|
|
67
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
72
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
73
37
|
};
|
|
@@ -90,15 +54,15 @@ exports.convertToMP4GIF = convertToMP4GIF;
|
|
|
90
54
|
* You should have received a copy of the GNU Lesser General Public License
|
|
91
55
|
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
|
|
92
56
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
process.on('exit',
|
|
57
|
+
const execa_1 = __importDefault(require("execa"));
|
|
58
|
+
const fs = __importStar(require("fs"));
|
|
59
|
+
const path = __importStar(require("path"));
|
|
60
|
+
const rimraf_1 = __importDefault(require("rimraf"));
|
|
61
|
+
const tmp = __importStar(require("tmp"));
|
|
62
|
+
const lookpath_1 = require("lookpath");
|
|
63
|
+
const tmpDir = tmp.dirSync({});
|
|
64
|
+
let i = 0;
|
|
65
|
+
process.on('exit', () => {
|
|
102
66
|
// Remove only on exit signal
|
|
103
67
|
try {
|
|
104
68
|
// Use rimraf because it is synchronous
|
|
@@ -106,97 +70,77 @@ process.on('exit', function () {
|
|
|
106
70
|
}
|
|
107
71
|
catch (error) { }
|
|
108
72
|
});
|
|
109
|
-
function getFfmpegPath() {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
case 2: return [4 /*yield*/, (0, lookpath_1.lookpath)('ffmpeg', {
|
|
128
|
-
include: [
|
|
129
|
-
'C:\\FFmpeg\\bin',
|
|
130
|
-
'C:\\FFmpeg\\FFmpeg\\bin',
|
|
131
|
-
'C:\\Program Files\\ffmpeg\\bin',
|
|
132
|
-
'C:\\Program Files (x86)\\ffmpeg\\bin',
|
|
133
|
-
],
|
|
134
|
-
})];
|
|
135
|
-
case 3:
|
|
136
|
-
ffmpegPath = _a.sent();
|
|
137
|
-
if (!ffmpegPath) {
|
|
138
|
-
try {
|
|
139
|
-
ffmpegPath = require('ffmpeg-static');
|
|
140
|
-
}
|
|
141
|
-
catch (error) { }
|
|
142
|
-
}
|
|
143
|
-
if (!ffmpegPath) {
|
|
144
|
-
throw new Error('Error: FFMPEG not found. Please install ffmpeg or define the env FFMPEG_PATH or install ffmpeg-static');
|
|
145
|
-
}
|
|
146
|
-
return [2 /*return*/, ffmpegPath];
|
|
147
|
-
}
|
|
148
|
-
});
|
|
73
|
+
async function getFfmpegPath() {
|
|
74
|
+
let ffmpegPath = process.env['FFMPEG_PATH'];
|
|
75
|
+
if (ffmpegPath) {
|
|
76
|
+
const isExecutable = await fs.promises
|
|
77
|
+
.access(ffmpegPath, fs.constants.X_OK)
|
|
78
|
+
.then(() => true)
|
|
79
|
+
.catch(() => false);
|
|
80
|
+
if (isExecutable) {
|
|
81
|
+
return ffmpegPath;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
ffmpegPath = await (0, lookpath_1.lookpath)('ffmpeg', {
|
|
85
|
+
include: [
|
|
86
|
+
'C:\\FFmpeg\\bin',
|
|
87
|
+
'C:\\FFmpeg\\FFmpeg\\bin',
|
|
88
|
+
'C:\\Program Files\\ffmpeg\\bin',
|
|
89
|
+
'C:\\Program Files (x86)\\ffmpeg\\bin',
|
|
90
|
+
],
|
|
149
91
|
});
|
|
92
|
+
if (!ffmpegPath) {
|
|
93
|
+
try {
|
|
94
|
+
ffmpegPath = require('ffmpeg-static');
|
|
95
|
+
}
|
|
96
|
+
catch (error) { }
|
|
97
|
+
}
|
|
98
|
+
if (!ffmpegPath) {
|
|
99
|
+
throw new Error('Error: FFMPEG not found. Please install ffmpeg or define the env FFMPEG_PATH or install ffmpeg-static');
|
|
100
|
+
}
|
|
101
|
+
return ffmpegPath;
|
|
150
102
|
}
|
|
151
103
|
/**
|
|
152
104
|
* Convert a file to a compatible MP4-GIF for WhatsApp
|
|
153
105
|
* @param inputBase64 Gif in base64 format
|
|
154
106
|
* @returns base64 of a MP4-GIF for WhatsApp
|
|
155
107
|
*/
|
|
156
|
-
function convertToMP4GIF(inputBase64) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
case 4:
|
|
195
|
-
(0, rimraf_1.default)(inputPath, function () { return null; });
|
|
196
|
-
(0, rimraf_1.default)(outputPath, function () { return null; });
|
|
197
|
-
return [7 /*endfinally*/];
|
|
198
|
-
case 5: return [2 /*return*/, ''];
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
});
|
|
108
|
+
async function convertToMP4GIF(inputBase64) {
|
|
109
|
+
const inputPath = path.join(tmpDir.name, `${i++}`);
|
|
110
|
+
const outputPath = path.join(tmpDir.name, `${i++}.mp4`);
|
|
111
|
+
if (inputBase64.includes(',')) {
|
|
112
|
+
inputBase64 = inputBase64.split(',')[1];
|
|
113
|
+
}
|
|
114
|
+
fs.writeFileSync(inputPath, Buffer.from(inputBase64, 'base64'));
|
|
115
|
+
/**
|
|
116
|
+
* fluent-ffmpeg is a good alternative,
|
|
117
|
+
* but to work with MP4 you must use fisical file or ffmpeg will not work
|
|
118
|
+
* Because of that, I made the choice to use temporary file
|
|
119
|
+
*/
|
|
120
|
+
const ffmpegPath = await getFfmpegPath();
|
|
121
|
+
try {
|
|
122
|
+
const out = await (0, execa_1.default)(ffmpegPath, [
|
|
123
|
+
'-i',
|
|
124
|
+
inputPath,
|
|
125
|
+
'-movflags',
|
|
126
|
+
'faststart',
|
|
127
|
+
'-pix_fmt',
|
|
128
|
+
'yuv420p',
|
|
129
|
+
'-vf',
|
|
130
|
+
'scale=trunc(iw/2)*2:trunc(ih/2)*2',
|
|
131
|
+
'-f',
|
|
132
|
+
'mp4',
|
|
133
|
+
outputPath,
|
|
134
|
+
]);
|
|
135
|
+
if (out.exitCode === 0) {
|
|
136
|
+
const outputBase64 = fs.readFileSync(outputPath);
|
|
137
|
+
return 'data:video/mp4;base64,' + outputBase64.toString('base64');
|
|
138
|
+
}
|
|
139
|
+
throw out.stderr;
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
(0, rimraf_1.default)(inputPath, () => null);
|
|
143
|
+
(0, rimraf_1.default)(outputPath, () => null);
|
|
144
|
+
}
|
|
145
|
+
return '';
|
|
202
146
|
}
|
package/dist/utils/logger.js
CHANGED
|
@@ -17,9 +17,9 @@ exports.defaultLogger = exports.formatLabelSession = void 0;
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
exports.formatLabelSession = (0, winston_1.format)(
|
|
22
|
-
|
|
20
|
+
const winston_1 = require("winston");
|
|
21
|
+
exports.formatLabelSession = (0, winston_1.format)((info, opts) => {
|
|
22
|
+
const parts = [];
|
|
23
23
|
if (info.session) {
|
|
24
24
|
parts.push(info.session);
|
|
25
25
|
delete info.session;
|
|
@@ -29,8 +29,8 @@ exports.formatLabelSession = (0, winston_1.format)(function (info, opts) {
|
|
|
29
29
|
delete info.type;
|
|
30
30
|
}
|
|
31
31
|
if (parts.length) {
|
|
32
|
-
|
|
33
|
-
info.message =
|
|
32
|
+
let prefix = parts.join(':');
|
|
33
|
+
info.message = `[${prefix}] ${info.message}`;
|
|
34
34
|
}
|
|
35
35
|
return info;
|
|
36
36
|
});
|
package/dist/utils/semver.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.upToDate = upToDate;
|
|
20
|
-
|
|
20
|
+
const VPAT = /^\d+(\.\d+){0,2}$/;
|
|
21
21
|
/**
|
|
22
22
|
* Compares two versions
|
|
23
23
|
* @return true if local is up to date, false otherwise
|
|
@@ -30,15 +30,15 @@ function upToDate(local, remote) {
|
|
|
30
30
|
if (local == remote)
|
|
31
31
|
return true;
|
|
32
32
|
if (VPAT.test(local) && VPAT.test(remote)) {
|
|
33
|
-
|
|
33
|
+
const lparts = local.split('.');
|
|
34
34
|
while (lparts.length < 3)
|
|
35
35
|
lparts.push('0');
|
|
36
|
-
|
|
36
|
+
const rparts = remote.split('.');
|
|
37
37
|
while (rparts.length < 3)
|
|
38
38
|
rparts.push('0');
|
|
39
|
-
for (
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
for (let i = 0; i < 3; i++) {
|
|
40
|
+
const l = parseInt(lparts[i], 10);
|
|
41
|
+
const r = parseInt(rparts[i], 10);
|
|
42
42
|
if (l === r)
|
|
43
43
|
continue;
|
|
44
44
|
return l > r;
|
package/dist/utils/sleep.js
CHANGED
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.sleep = sleep;
|
|
20
20
|
function sleep(time) {
|
|
21
|
-
return new Promise(
|
|
21
|
+
return new Promise((resolve) => setTimeout(resolve, time));
|
|
22
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wppconnect-team/wppconnect",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination... 😀🤔💭",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"@babel/core": "^7.29.0",
|
|
59
59
|
"@babel/eslint-parser": "^7.28.6",
|
|
60
60
|
"@babel/eslint-plugin": "^7.27.1",
|
|
61
|
-
"@babel/preset-env": "^7.29.
|
|
62
|
-
"@commitlint/cli": "^20.5.
|
|
63
|
-
"@commitlint/config-conventional": "^20.5.
|
|
64
|
-
"@commitlint/cz-commitlint": "^20.5.
|
|
61
|
+
"@babel/preset-env": "^7.29.3",
|
|
62
|
+
"@commitlint/cli": "^20.5.3",
|
|
63
|
+
"@commitlint/config-conventional": "^20.5.3",
|
|
64
|
+
"@commitlint/cz-commitlint": "^20.5.3",
|
|
65
65
|
"@eslint/js": "^10.0.1",
|
|
66
66
|
"@types/atob": "^2.1.4",
|
|
67
67
|
"@types/mime-types": "^3.0.1",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"conventional-changelog-cli": "^5.0.0",
|
|
77
77
|
"eslint": "10.2.1",
|
|
78
78
|
"eslint-config-prettier": "^10.1.8",
|
|
79
|
-
"@tony.ganchev/eslint-plugin-header": "^3.4.
|
|
79
|
+
"@tony.ganchev/eslint-plugin-header": "^3.4.4",
|
|
80
80
|
"eslint-plugin-prettier": "^5.5.5",
|
|
81
81
|
"globals": "^17.5.0",
|
|
82
82
|
"husky": "^9.1.7",
|