whatsapp-web.js 1.26.1-alpha.3 → 1.28.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/index.d.ts
CHANGED
|
@@ -538,7 +538,8 @@ declare namespace WAWebJS {
|
|
|
538
538
|
public dataPath?: string;
|
|
539
539
|
constructor(options?: {
|
|
540
540
|
clientId?: string,
|
|
541
|
-
dataPath?: string
|
|
541
|
+
dataPath?: string,
|
|
542
|
+
rmMaxRetries?: number
|
|
542
543
|
})
|
|
543
544
|
}
|
|
544
545
|
|
|
@@ -552,7 +553,8 @@ declare namespace WAWebJS {
|
|
|
552
553
|
store: Store,
|
|
553
554
|
clientId?: string,
|
|
554
555
|
dataPath?: string,
|
|
555
|
-
backupSyncIntervalMs: number
|
|
556
|
+
backupSyncIntervalMs: number,
|
|
557
|
+
rmMaxRetries?: number
|
|
556
558
|
})
|
|
557
559
|
}
|
|
558
560
|
|
|
@@ -1156,7 +1158,10 @@ declare namespace WAWebJS {
|
|
|
1156
1158
|
/** Sticker author, if sendMediaAsSticker is true */
|
|
1157
1159
|
stickerAuthor?: string
|
|
1158
1160
|
/** Sticker categories, if sendMediaAsSticker is true */
|
|
1159
|
-
stickerCategories?: string[]
|
|
1161
|
+
stickerCategories?: string[],
|
|
1162
|
+
/** Should the bot send a quoted message without the quoted message if it fails to get the quote?
|
|
1163
|
+
* @default false (disabled) */
|
|
1164
|
+
ignoreQuoteErrors?: boolean
|
|
1160
1165
|
}
|
|
1161
1166
|
|
|
1162
1167
|
/** Options for editing a message */
|
package/package.json
CHANGED
|
@@ -9,9 +9,10 @@ const BaseAuthStrategy = require('./BaseAuthStrategy');
|
|
|
9
9
|
* @param {object} options - options
|
|
10
10
|
* @param {string} options.clientId - Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance
|
|
11
11
|
* @param {string} options.dataPath - Change the default path for saving session files, default is: "./.wwebjs_auth/"
|
|
12
|
+
* @param {number} options.rmMaxRetries - Sets the maximum number of retries for removing the session directory
|
|
12
13
|
*/
|
|
13
14
|
class LocalAuth extends BaseAuthStrategy {
|
|
14
|
-
constructor({ clientId, dataPath }={}) {
|
|
15
|
+
constructor({ clientId, dataPath, rmMaxRetries }={}) {
|
|
15
16
|
super();
|
|
16
17
|
|
|
17
18
|
const idRegex = /^[-_\w]+$/i;
|
|
@@ -21,6 +22,7 @@ class LocalAuth extends BaseAuthStrategy {
|
|
|
21
22
|
|
|
22
23
|
this.dataPath = path.resolve(dataPath || './.wwebjs_auth/');
|
|
23
24
|
this.clientId = clientId;
|
|
25
|
+
this.rmMaxRetries = rmMaxRetries ?? 4;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
async beforeBrowserInitialized() {
|
|
@@ -44,7 +46,7 @@ class LocalAuth extends BaseAuthStrategy {
|
|
|
44
46
|
|
|
45
47
|
async logout() {
|
|
46
48
|
if (this.userDataDir) {
|
|
47
|
-
await fs.promises.rm(this.userDataDir, { recursive: true, force: true })
|
|
49
|
+
await fs.promises.rm(this.userDataDir, { recursive: true, force: true, maxRetries: this.rmMaxRetries })
|
|
48
50
|
.catch((e) => {
|
|
49
51
|
throw new Error(e);
|
|
50
52
|
});
|
|
@@ -22,9 +22,10 @@ const BaseAuthStrategy = require('./BaseAuthStrategy');
|
|
|
22
22
|
* @param {string} options.clientId - Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance
|
|
23
23
|
* @param {string} options.dataPath - Change the default path for saving session files, default is: "./.wwebjs_auth/"
|
|
24
24
|
* @param {number} options.backupSyncIntervalMs - Sets the time interval for periodic session backups. Accepts values starting from 60000ms {1 minute}
|
|
25
|
+
* @param {number} options.rmMaxRetries - Sets the maximum number of retries for removing the session directory
|
|
25
26
|
*/
|
|
26
27
|
class RemoteAuth extends BaseAuthStrategy {
|
|
27
|
-
constructor({ clientId, dataPath, store, backupSyncIntervalMs } = {}) {
|
|
28
|
+
constructor({ clientId, dataPath, store, backupSyncIntervalMs, rmMaxRetries } = {}) {
|
|
28
29
|
if (!fs && !unzipper && !archiver) throw new Error('Optional Dependencies [fs-extra, unzipper, archiver] are required to use RemoteAuth. Make sure to run npm install correctly and remove the --no-optional flag');
|
|
29
30
|
super();
|
|
30
31
|
|
|
@@ -43,6 +44,7 @@ class RemoteAuth extends BaseAuthStrategy {
|
|
|
43
44
|
this.dataPath = path.resolve(dataPath || './.wwebjs_auth/');
|
|
44
45
|
this.tempDir = `${this.dataPath}/wwebjs_temp_session_${this.clientId}`;
|
|
45
46
|
this.requiredDirs = ['Default', 'IndexedDB', 'Local Storage']; /* => Required Files & Dirs in WWebJS to restore session */
|
|
47
|
+
this.rmMaxRetries = rmMaxRetries ?? 4;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
async beforeBrowserInitialized() {
|
|
@@ -80,7 +82,8 @@ class RemoteAuth extends BaseAuthStrategy {
|
|
|
80
82
|
if (pathExists) {
|
|
81
83
|
await fs.promises.rm(this.userDataDir, {
|
|
82
84
|
recursive: true,
|
|
83
|
-
force: true
|
|
85
|
+
force: true,
|
|
86
|
+
maxRetries: this.rmMaxRetries,
|
|
84
87
|
}).catch(() => {});
|
|
85
88
|
}
|
|
86
89
|
clearInterval(this.backupSync);
|
|
@@ -107,7 +110,8 @@ class RemoteAuth extends BaseAuthStrategy {
|
|
|
107
110
|
await fs.promises.unlink(`${this.sessionName}.zip`);
|
|
108
111
|
await fs.promises.rm(`${this.tempDir}`, {
|
|
109
112
|
recursive: true,
|
|
110
|
-
force: true
|
|
113
|
+
force: true,
|
|
114
|
+
maxRetries: this.rmMaxRetries,
|
|
111
115
|
}).catch(() => {});
|
|
112
116
|
if(options && options.emit) this.client.emit(Events.REMOTE_SESSION_SAVED);
|
|
113
117
|
}
|
|
@@ -120,7 +124,8 @@ class RemoteAuth extends BaseAuthStrategy {
|
|
|
120
124
|
if (pathExists) {
|
|
121
125
|
await fs.promises.rm(this.userDataDir, {
|
|
122
126
|
recursive: true,
|
|
123
|
-
force: true
|
|
127
|
+
force: true,
|
|
128
|
+
maxRetries: this.rmMaxRetries,
|
|
124
129
|
}).catch(() => {});
|
|
125
130
|
}
|
|
126
131
|
if (sessionExists) {
|
|
@@ -177,7 +182,8 @@ class RemoteAuth extends BaseAuthStrategy {
|
|
|
177
182
|
if (stats.isDirectory()) {
|
|
178
183
|
await fs.promises.rm(dirElement, {
|
|
179
184
|
recursive: true,
|
|
180
|
-
force: true
|
|
185
|
+
force: true,
|
|
186
|
+
maxRetries: this.rmMaxRetries,
|
|
181
187
|
}).catch(() => {});
|
|
182
188
|
} else {
|
|
183
189
|
await fs.promises.unlink(dirElement).catch(() => {});
|
|
@@ -98,7 +98,7 @@ class GroupChat extends Chat {
|
|
|
98
98
|
419: 'The participant can\'t be added because the group is full'
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
await window.Store.GroupQueryAndUpdate(
|
|
101
|
+
await window.Store.GroupQueryAndUpdate({ id: groupId });
|
|
102
102
|
const groupMetadata = group.groupMetadata;
|
|
103
103
|
const groupParticipants = groupMetadata?.participants;
|
|
104
104
|
|
|
@@ -381,9 +381,9 @@ class GroupChat extends Chat {
|
|
|
381
381
|
const codeRes = await this.client.pupPage.evaluate(async chatId => {
|
|
382
382
|
const chatWid = window.Store.WidFactory.createWid(chatId);
|
|
383
383
|
try {
|
|
384
|
-
return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.
|
|
385
|
-
? await window.Store.GroupInvite.
|
|
386
|
-
: await window.Store.GroupInvite.queryGroupInviteCode(chatWid);
|
|
384
|
+
return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.1020730154')
|
|
385
|
+
? await window.Store.GroupInvite.fetchMexGroupInviteCode(chatId)
|
|
386
|
+
: await window.Store.GroupInvite.queryGroupInviteCode(chatWid, true);
|
|
387
387
|
}
|
|
388
388
|
catch (err) {
|
|
389
389
|
if(err.name === 'ServerStatusCodeError') return undefined;
|
|
@@ -391,7 +391,9 @@ class GroupChat extends Chat {
|
|
|
391
391
|
}
|
|
392
392
|
}, this.id._serialized);
|
|
393
393
|
|
|
394
|
-
return codeRes?.code
|
|
394
|
+
return codeRes?.code
|
|
395
|
+
? codeRes?.code
|
|
396
|
+
: codeRes;
|
|
395
397
|
}
|
|
396
398
|
|
|
397
399
|
/**
|
|
@@ -55,7 +55,6 @@ exports.ExposeStore = () => {
|
|
|
55
55
|
window.Store.MediaTypes = window.require('WAWebMmsMediaTypes');
|
|
56
56
|
window.Store.MediaUpload = window.require('WAWebMediaMmsV4Upload');
|
|
57
57
|
window.Store.MsgKey = window.require('WAWebMsgKey');
|
|
58
|
-
window.Store.NumberInfo = window.require('WAPhoneUtils');
|
|
59
58
|
window.Store.OpaqueData = window.require('WAWebMediaOpaqueData');
|
|
60
59
|
window.Store.QueryProduct = window.require('WAWebBizProductCatalogBridge');
|
|
61
60
|
window.Store.QueryOrder = window.require('WAWebBizOrderBridge');
|
|
@@ -102,6 +101,11 @@ exports.ExposeStore = () => {
|
|
|
102
101
|
if (window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.1014111620'))
|
|
103
102
|
window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
|
|
104
103
|
|
|
104
|
+
window.Store.NumberInfo = {
|
|
105
|
+
...window.require('WAPhoneUtils'),
|
|
106
|
+
...window.require('WAPhoneFindCC')
|
|
107
|
+
};
|
|
108
|
+
|
|
105
109
|
window.Store.ForwardUtils = {
|
|
106
110
|
...window.require('WAWebForwardMessagesToChat')
|
|
107
111
|
};
|
|
@@ -122,7 +126,8 @@ exports.ExposeStore = () => {
|
|
|
122
126
|
};
|
|
123
127
|
window.Store.GroupInvite = {
|
|
124
128
|
...window.require('WAWebGroupInviteJob'),
|
|
125
|
-
...window.require('WAWebGroupQueryJob')
|
|
129
|
+
...window.require('WAWebGroupQueryJob'),
|
|
130
|
+
...window.require('WAWebMexFetchGroupInviteCodeJob')
|
|
126
131
|
};
|
|
127
132
|
window.Store.GroupInviteV4 = {
|
|
128
133
|
...window.require('WAWebGroupInviteV4Job'),
|
|
@@ -46,20 +46,24 @@ exports.LoadUtils = () => {
|
|
|
46
46
|
if (options.quotedMessageId) {
|
|
47
47
|
let quotedMessage = await window.Store.Msg.getMessagesById([options.quotedMessageId]);
|
|
48
48
|
|
|
49
|
-
if (quotedMessage['messages'].length
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
quotedMessage = quotedMessage['messages'][0];
|
|
49
|
+
if (quotedMessage['messages'].length == 1) {
|
|
50
|
+
quotedMessage = quotedMessage['messages'][0];
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
// TODO remove .canReply() once all clients are updated to >= v2.2241.6
|
|
53
|
+
const canReply = window.Store.ReplyUtils ?
|
|
54
|
+
window.Store.ReplyUtils.canReplyMsg(quotedMessage.unsafe()) :
|
|
55
|
+
quotedMessage.canReply();
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
if (canReply) {
|
|
58
|
+
quotedMsgOptions = quotedMessage.msgContextInfo(chat);
|
|
59
|
+
}
|
|
60
|
+
}else{
|
|
61
|
+
if(!options.ignoreQuoteErrors) {
|
|
62
|
+
throw new Error('Could not get the quoted message.');
|
|
63
|
+
}
|
|
62
64
|
}
|
|
65
|
+
|
|
66
|
+
delete options.ignoreQuoteErrors;
|
|
63
67
|
delete options.quotedMessageId;
|
|
64
68
|
}
|
|
65
69
|
|
|
@@ -921,7 +925,7 @@ exports.LoadUtils = () => {
|
|
|
921
925
|
let response;
|
|
922
926
|
let result = [];
|
|
923
927
|
|
|
924
|
-
await window.Store.GroupQueryAndUpdate(
|
|
928
|
+
await window.Store.GroupQueryAndUpdate({ id: groupId });
|
|
925
929
|
|
|
926
930
|
if (!requesterIds?.length) {
|
|
927
931
|
membershipRequests = group.groupMetadata.membershipApprovalRequests._models.map(({ id }) => id);
|