@fhynella/baileys 1.2.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/LICENSE +21 -0
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.js +169661 -0
- package/WAProto/p.html +1 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.js +118 -0
- package/lib/Defaults/wileys-version.json +3 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.js +29 -0
- package/lib/Signal/libsignal.js +174 -0
- package/lib/Socket/Client/index.js +18 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +111 -0
- package/lib/Socket/business.js +260 -0
- package/lib/Socket/chats.js +915 -0
- package/lib/Socket/groups.js +332 -0
- package/lib/Socket/index.js +10 -0
- package/lib/Socket/messages-recv.js +1054 -0
- package/lib/Socket/messages-send.js +949 -0
- package/lib/Socket/newsletter.js +250 -0
- package/lib/Socket/socket.js +654 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.js +8 -0
- package/lib/Store/make-in-memory-store.js +439 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.js +7 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +42 -0
- package/lib/Utils/auth-utils.js +199 -0
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/business.js +234 -0
- package/lib/Utils/chat-utils.js +730 -0
- package/lib/Utils/crypto.js +193 -0
- package/lib/Utils/decode-wa-message.js +207 -0
- package/lib/Utils/event-buffer.js +518 -0
- package/lib/Utils/generics.js +467 -0
- package/lib/Utils/history.js +94 -0
- package/lib/Utils/index.js +35 -0
- package/lib/Utils/link-preview.js +126 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.js +51 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/message-retry-manager.js +128 -0
- package/lib/Utils/messages-media.js +957 -0
- package/lib/Utils/messages.js +1049 -0
- package/lib/Utils/noise-handler.js +150 -0
- package/lib/Utils/process-message.js +404 -0
- package/lib/Utils/signal.js +153 -0
- package/lib/Utils/use-multi-file-auth-state.js +125 -0
- package/lib/Utils/validate-connection.js +229 -0
- package/lib/Utils/wileys-event-stream.js +63 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.js +265 -0
- package/lib/WABinary/encode.js +250 -0
- package/lib/WABinary/generic-utils.js +110 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.js +85 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.js +89 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.js +49 -0
- package/package.json +115 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getUrlInfo = void 0;
|
|
37
|
+
const messages_1 = require("./messages");
|
|
38
|
+
const messages_media_1 = require("./messages-media");
|
|
39
|
+
const THUMBNAIL_WIDTH_PX = 192;
|
|
40
|
+
/** Fetches an image and generates a thumbnail for it */
|
|
41
|
+
const getCompressedJpegThumbnail = async (url, { thumbnailWidth, fetchOpts }) => {
|
|
42
|
+
const stream = await (0, messages_media_1.getHttpStream)(url, fetchOpts);
|
|
43
|
+
const result = await (0, messages_media_1.extractImageThumb)(stream, thumbnailWidth);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Given a piece of text, checks for any URL present, generates link preview for the same and returns it
|
|
48
|
+
* Return undefined if the fetch failed or no URL was found
|
|
49
|
+
* @param text first matched URL in text
|
|
50
|
+
* @returns the URL info required to generate link preview
|
|
51
|
+
*/
|
|
52
|
+
const getUrlInfo = async (text, opts = {
|
|
53
|
+
thumbnailWidth: THUMBNAIL_WIDTH_PX,
|
|
54
|
+
fetchOpts: { timeout: 3000 }
|
|
55
|
+
}) => {
|
|
56
|
+
var _a;
|
|
57
|
+
try {
|
|
58
|
+
// retries
|
|
59
|
+
const retries = 0;
|
|
60
|
+
const maxRetry = 5;
|
|
61
|
+
const { getLinkPreview } = await Promise.resolve().then(() => __importStar(require('link-preview-js')));
|
|
62
|
+
let previewLink = text;
|
|
63
|
+
if (!text.startsWith('https://') && !text.startsWith('http://')) {
|
|
64
|
+
previewLink = 'https://' + previewLink;
|
|
65
|
+
}
|
|
66
|
+
const info = await getLinkPreview(previewLink, {
|
|
67
|
+
...opts.fetchOpts,
|
|
68
|
+
followRedirects: 'follow',
|
|
69
|
+
handleRedirects: (baseURL, forwardedURL) => {
|
|
70
|
+
const urlObj = new URL(baseURL);
|
|
71
|
+
const forwardedURLObj = new URL(forwardedURL);
|
|
72
|
+
if (retries >= maxRetry) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (forwardedURLObj.hostname === urlObj.hostname
|
|
76
|
+
|| forwardedURLObj.hostname === 'www.' + urlObj.hostname
|
|
77
|
+
|| 'www.' + forwardedURLObj.hostname === urlObj.hostname) {
|
|
78
|
+
retries + 1;
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
headers: opts.fetchOpts
|
|
86
|
+
});
|
|
87
|
+
if (info && 'title' in info && info.title) {
|
|
88
|
+
const [image] = info.images;
|
|
89
|
+
const urlInfo = {
|
|
90
|
+
'canonical-url': info.url,
|
|
91
|
+
'matched-text': text,
|
|
92
|
+
title: info.title,
|
|
93
|
+
description: info.description,
|
|
94
|
+
originalThumbnailUrl: image
|
|
95
|
+
};
|
|
96
|
+
if (opts.uploadImage) {
|
|
97
|
+
const { imageMessage } = await (0, messages_1.prepareWAMessageMedia)({ image: { url: image } }, {
|
|
98
|
+
upload: opts.uploadImage,
|
|
99
|
+
mediaTypeOverride: 'thumbnail-link',
|
|
100
|
+
options: opts.fetchOpts
|
|
101
|
+
});
|
|
102
|
+
urlInfo.jpegThumbnail = (imageMessage === null || imageMessage === void 0 ? void 0 : imageMessage.jpegThumbnail)
|
|
103
|
+
? Buffer.from(imageMessage.jpegThumbnail)
|
|
104
|
+
: undefined;
|
|
105
|
+
urlInfo.highQualityThumbnail = imageMessage || undefined;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
try {
|
|
109
|
+
urlInfo.jpegThumbnail = image
|
|
110
|
+
? (await getCompressedJpegThumbnail(image, opts)).buffer
|
|
111
|
+
: undefined;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
(_a = opts.logger) === null || _a === void 0 ? void 0 : _a.debug({ err: error.stack, url: previewLink }, 'error in generating thumbnail');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return urlInfo;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (!error.message.includes('receive a valid')) {
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
exports.getUrlInfo = getUrlInfo;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const pino_1 = __importDefault(require("pino"));
|
|
7
|
+
exports.default = (0, pino_1.default)({ timestamp: () => `,"time":"${new Date().toJSON()}"` });
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LT_HASH_ANTI_TAMPERING = void 0;
|
|
4
|
+
const crypto_1 = require("./crypto");
|
|
5
|
+
/**
|
|
6
|
+
* LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
|
|
7
|
+
* over a series of mutations. You can add/remove mutations and it'll return a hash equal to
|
|
8
|
+
* if the same series of mutations was made sequentially.
|
|
9
|
+
*/
|
|
10
|
+
const o = 128;
|
|
11
|
+
class d {
|
|
12
|
+
constructor(e) {
|
|
13
|
+
this.salt = e;
|
|
14
|
+
}
|
|
15
|
+
add(e, t) {
|
|
16
|
+
var r = this;
|
|
17
|
+
for (const item of t) {
|
|
18
|
+
e = r._addSingle(e, item);
|
|
19
|
+
}
|
|
20
|
+
return e;
|
|
21
|
+
}
|
|
22
|
+
subtract(e, t) {
|
|
23
|
+
var r = this;
|
|
24
|
+
for (const item of t) {
|
|
25
|
+
e = r._subtractSingle(e, item);
|
|
26
|
+
}
|
|
27
|
+
return e;
|
|
28
|
+
}
|
|
29
|
+
subtractThenAdd(e, t, r) {
|
|
30
|
+
var n = this;
|
|
31
|
+
return n.add(n.subtract(e, r), t);
|
|
32
|
+
}
|
|
33
|
+
async _addSingle(e, t) {
|
|
34
|
+
var r = this;
|
|
35
|
+
const n = new Uint8Array(await (0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
|
|
36
|
+
return r.performPointwiseWithOverflow(await e, n, ((e, t) => e + t));
|
|
37
|
+
}
|
|
38
|
+
async _subtractSingle(e, t) {
|
|
39
|
+
var r = this;
|
|
40
|
+
const n = new Uint8Array(await (0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
|
|
41
|
+
return r.performPointwiseWithOverflow(await e, n, ((e, t) => e - t));
|
|
42
|
+
}
|
|
43
|
+
performPointwiseWithOverflow(e, t, r) {
|
|
44
|
+
const n = new DataView(e), i = new DataView(t), a = new ArrayBuffer(n.byteLength), s = new DataView(a);
|
|
45
|
+
for (let e = 0; e < n.byteLength; e += 2) {
|
|
46
|
+
s.setUint16(e, r(n.getUint16(e, !0), i.getUint16(e, !0)), !0);
|
|
47
|
+
}
|
|
48
|
+
return a;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.LT_HASH_ANTI_TAMPERING = new d('WhatsApp Patch Integrity');
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeKeyedMutex = exports.makeMutex = void 0;
|
|
4
|
+
const makeMutex = () => {
|
|
5
|
+
let task = Promise.resolve();
|
|
6
|
+
let taskTimeout;
|
|
7
|
+
return {
|
|
8
|
+
mutex(code) {
|
|
9
|
+
task = (async () => {
|
|
10
|
+
// wait for the previous task to complete
|
|
11
|
+
// if there is an error, we swallow so as to not block the queue
|
|
12
|
+
try {
|
|
13
|
+
await task;
|
|
14
|
+
}
|
|
15
|
+
catch (_a) { }
|
|
16
|
+
try {
|
|
17
|
+
// execute the current task
|
|
18
|
+
const result = await code();
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
clearTimeout(taskTimeout);
|
|
23
|
+
}
|
|
24
|
+
})();
|
|
25
|
+
// we replace the existing task, appending the new piece of execution to it
|
|
26
|
+
// so the next task will have to wait for this one to finish
|
|
27
|
+
return task;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.makeMutex = makeMutex;
|
|
32
|
+
const makeKeyedMutex = () => {
|
|
33
|
+
const map = {};
|
|
34
|
+
return {
|
|
35
|
+
mutex(key, task) {
|
|
36
|
+
if (!map[key]) {
|
|
37
|
+
map[key] = (0, exports.makeMutex)();
|
|
38
|
+
}
|
|
39
|
+
return map[key].mutex(task);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
exports.makeKeyedMutex = makeKeyedMutex;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageRetryManager = void 0;
|
|
4
|
+
|
|
5
|
+
const lru_cache_1 = require("lru-cache");
|
|
6
|
+
|
|
7
|
+
const RECENT_MESSAGES_SIZE = 512;
|
|
8
|
+
|
|
9
|
+
const RECREATE_SESSION_TIMEOUT = 60 * 60 * 1000;
|
|
10
|
+
|
|
11
|
+
const PHONE_REQUEST_DELAY = 3000;
|
|
12
|
+
|
|
13
|
+
class MessageRetryManager {
|
|
14
|
+
constructor(logger, maxMsgRetryCount) {
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
this.maxMsgRetryCount = maxMsgRetryCount;
|
|
17
|
+
this._recentMessagesMap = new lru_cache_1.LRUCache({
|
|
18
|
+
max: RECENT_MESSAGES_SIZE
|
|
19
|
+
});
|
|
20
|
+
this._sessionRecreateHistory = new lru_cache_1.LRUCache({
|
|
21
|
+
ttl: RECREATE_SESSION_TIMEOUT * 2,
|
|
22
|
+
ttlAutopurge: true
|
|
23
|
+
});
|
|
24
|
+
this._retryCounters = new lru_cache_1.LRUCache({
|
|
25
|
+
ttl: 15 * 60 * 1000,
|
|
26
|
+
ttlAutopurge: true,
|
|
27
|
+
updateAgeOnGet: true
|
|
28
|
+
});
|
|
29
|
+
this._pendingPhoneRequests = {};
|
|
30
|
+
this.statistics = {
|
|
31
|
+
totalRetries: 0,
|
|
32
|
+
successfulRetries: 0,
|
|
33
|
+
failedRetries: 0,
|
|
34
|
+
mediaRetries: 0,
|
|
35
|
+
sessionRecreations: 0,
|
|
36
|
+
phoneRequests: 0
|
|
37
|
+
};
|
|
38
|
+
this.maxMsgRetryCount = maxMsgRetryCount;
|
|
39
|
+
}
|
|
40
|
+
addRecentMessage(to, id, message) {
|
|
41
|
+
const key = { to, id };
|
|
42
|
+
const keyStr = this._keyToString(key);
|
|
43
|
+
this._recentMessagesMap.set(keyStr, {
|
|
44
|
+
message,
|
|
45
|
+
timestamp: Date.now()
|
|
46
|
+
});
|
|
47
|
+
this.logger.debug(`Added message to retry cache: ${to}/${id}`);
|
|
48
|
+
}
|
|
49
|
+
getRecentMessage(to, id) {
|
|
50
|
+
const key = { to, id };
|
|
51
|
+
const keyStr = this._keyToString(key);
|
|
52
|
+
return this._recentMessagesMap.get(keyStr);
|
|
53
|
+
}
|
|
54
|
+
shouldRecreateSession(jid, retryCount, hasSession) {
|
|
55
|
+
if (!hasSession) {
|
|
56
|
+
this._sessionRecreateHistory.set(jid, Date.now());
|
|
57
|
+
this.statistics.sessionRecreations++;
|
|
58
|
+
return {
|
|
59
|
+
reason: "we don't have a Signal session with them",
|
|
60
|
+
recreate: true
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (retryCount < 2) {
|
|
64
|
+
return { reason: '', recreate: false };
|
|
65
|
+
}
|
|
66
|
+
const now = Date.now();
|
|
67
|
+
const prevTime = this._sessionRecreateHistory.get(jid);
|
|
68
|
+
if (!prevTime || now - prevTime > RECREATE_SESSION_TIMEOUT) {
|
|
69
|
+
this._sessionRecreateHistory.set(jid, now);
|
|
70
|
+
this.statistics.sessionRecreations++;
|
|
71
|
+
return {
|
|
72
|
+
reason: 'retry count > 1 and over an hour since last recreation',
|
|
73
|
+
recreate: true
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return { reason: '', recreate: false };
|
|
77
|
+
}
|
|
78
|
+
incrementRetryCount(messageId) {
|
|
79
|
+
this._retryCounters.set(messageId, (this._retryCounters.get(messageId) || 0) + 1);
|
|
80
|
+
this.statistics.totalRetries++;
|
|
81
|
+
return this._retryCounters.get(messageId);
|
|
82
|
+
}
|
|
83
|
+
getRetryCount(messageId) {
|
|
84
|
+
return this._retryCounters.get(messageId) || 0;
|
|
85
|
+
}
|
|
86
|
+
hasExceededMaxRetries(messageId) {
|
|
87
|
+
return this.getRetryCount(messageId) >= this.maxMsgRetryCount;
|
|
88
|
+
}
|
|
89
|
+
markRetrySuccess(messageId) {
|
|
90
|
+
this.statistics.successfulRetries++;
|
|
91
|
+
this._retryCounters.delete(messageId);
|
|
92
|
+
this._cancelPendingPhoneRequest(messageId);
|
|
93
|
+
}
|
|
94
|
+
markRetryFailed(messageId) {
|
|
95
|
+
this.statistics.failedRetries++;
|
|
96
|
+
this._retryCounters.delete(messageId);
|
|
97
|
+
}
|
|
98
|
+
schedulePhoneRequest(messageId, callback, delay = PHONE_REQUEST_DELAY) {
|
|
99
|
+
this._cancelPendingPhoneRequest(messageId);
|
|
100
|
+
this._pendingPhoneRequests[messageId] = setTimeout(() => {
|
|
101
|
+
delete this._pendingPhoneRequests[messageId];
|
|
102
|
+
this.statistics.phoneRequests++;
|
|
103
|
+
callback();
|
|
104
|
+
}, delay);
|
|
105
|
+
this.logger.debug(`Scheduled phone request for message ${messageId} with ${delay}ms delay`);
|
|
106
|
+
}
|
|
107
|
+
cancelPendingPhoneRequest(messageId) {
|
|
108
|
+
const timeout = this._pendingPhoneRequests[messageId];
|
|
109
|
+
if (timeout) {
|
|
110
|
+
clearTimeout(timeout);
|
|
111
|
+
delete this._pendingPhoneRequests[messageId];
|
|
112
|
+
this.logger.debug(`Cancelled pending phone request for message ${messageId}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_keyToString(key) {
|
|
116
|
+
return `${key.to}:${key.id}`;
|
|
117
|
+
}
|
|
118
|
+
_cancelPendingPhoneRequest(messageId) {
|
|
119
|
+
const timeout = this._pendingPhoneRequests[messageId];
|
|
120
|
+
if (timeout) {
|
|
121
|
+
clearTimeout(timeout);
|
|
122
|
+
delete this._pendingPhoneRequests[messageId];
|
|
123
|
+
this.logger.debug(`Cancelled pending phone request for message ${messageId}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
exports.MessageRetryManager = MessageRetryManager;
|