kage-baileys 25.3.12 → 25.3.13
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/lib/Defaults/connection.js +49 -108
- package/lib/Defaults/constants.js +71 -153
- package/lib/Defaults/index.js +0 -199
- package/lib/Defaults/media.js +0 -60
- package/lib/Defaults/prefix.js +17 -43
- package/lib/Modded/message_builder.js +0 -2355
- package/lib/Signal/Group/ciphertext-message.js +0 -54
- package/lib/Signal/Group/group-session-builder.js +0 -124
- package/lib/Signal/Group/group_cipher.js +0 -230
- package/lib/Signal/Group/index.js +0 -124
- package/lib/Signal/Group/keyhelper.js +0 -108
- package/lib/Signal/Group/sender-chain-key.js +0 -88
- package/lib/Signal/Group/sender-key-distribution-message.js +0 -157
- package/lib/Signal/Group/sender-key-message.js +0 -166
- package/lib/Signal/Group/sender-key-name.js +0 -130
- package/lib/Signal/Group/sender-key-record.js +0 -122
- package/lib/Signal/Group/sender-key-state.js +0 -220
- package/lib/Signal/Group/sender-message-key.js +0 -82
- package/lib/Signal/libsignal.js +0 -646
- package/lib/Signal/lid-mapping.js +0 -537
- package/lib/Socket/Client/index.js +0 -60
- package/lib/Socket/Client/types.js +0 -51
- package/lib/Socket/Client/websocket.js +0 -164
- package/lib/Socket/business.js +0 -708
- package/lib/Socket/chats.js +0 -2253
- package/lib/Socket/communities.js +0 -441
- package/lib/Socket/community.js +504 -1019
- package/lib/Socket/groups.js +0 -727
- package/lib/Socket/messages-recv.js +0 -2780
- package/lib/Socket/messages-send.js +0 -2640
- package/lib/Socket/mex.js +0 -128
- package/lib/Socket/newsletter.js +0 -486
- package/lib/Socket/socket.js +0 -1899
- package/lib/Store/index.js +0 -68
- package/lib/Store/make-cache-manager-store.js +0 -97
- package/lib/Store/make-in-memory-store.js +0 -908
- package/lib/Store/make-ordered-dictionary.js +0 -187
- package/lib/Store/object-repository.js +0 -78
- package/lib/Types/Bussines.js +2 -2
- package/lib/Types/Chat.js +0 -33
- package/lib/Types/Label.js +0 -78
- package/lib/Types/LabelAssociation.js +0 -42
- package/lib/Types/Message.js +0 -46
- package/lib/Types/Mex.js +0 -53
- package/lib/Types/MexUpdates.js +16 -43
- package/lib/Types/Newsletter.js +0 -27
- package/lib/Types/State.js +0 -42
- package/lib/Types/index.js +0 -134
- package/lib/Utils/auth-utils.js +0 -579
- package/lib/Utils/baileys-event-stream.js +65 -142
- package/lib/Utils/browser-utils.js +0 -104
- package/lib/Utils/business.js +0 -519
- package/lib/Utils/chat-utils.js +0 -1702
- package/lib/Utils/companion-reg-client-utils.js +0 -45
- package/lib/Utils/crypto.js +0 -382
- package/lib/Utils/decode-wa-message.js +0 -605
- package/lib/Utils/event-buffer.js +0 -1207
- package/lib/Utils/generics.js +0 -1020
- package/lib/Utils/history.js +0 -231
- package/lib/Utils/identity-change-handler.js +0 -59
- package/lib/Utils/index.js +0 -133
- package/lib/Utils/link-preview.js +0 -228
- package/lib/Utils/logger.js +0 -35
- package/lib/Utils/lt-hash.js +0 -60
- package/lib/Utils/make-mutex.js +0 -110
- package/lib/Utils/message-retry-manager.js +0 -429
- package/lib/Utils/messages-media.js +0 -1899
- package/lib/Utils/messages.js +0 -2950
- package/lib/Utils/noise-handler.js +0 -369
- package/lib/Utils/offline-node-processor.js +0 -50
- package/lib/Utils/pre-key-manager.js +0 -251
- package/lib/Utils/process-message.js +0 -1239
- package/lib/Utils/reporting-utils.js +0 -268
- package/lib/Utils/signal.js +0 -377
- package/lib/Utils/stanza-ack.js +0 -48
- package/lib/Utils/sync-action-utils.js +0 -58
- package/lib/Utils/tc-token-utils.js +0 -28
- package/lib/Utils/validate-connection.js +0 -508
- package/lib/VoIP/audio-feeder.js +0 -146
- package/lib/VoIP/index.js +0 -292
- package/lib/VoIP/relay-transport.js +0 -569
- package/lib/VoIP/signaling.js +0 -613
- package/lib/VoIP/types.js +0 -27
- package/lib/VoIP/wasm-engine.js +0 -1222
- package/lib/VoIP/worker-bootstrap.js +0 -1785
- package/lib/WABinary/constants.js +0 -2639
- package/lib/WABinary/decode.js +0 -612
- package/lib/WABinary/encode.js +0 -556
- package/lib/WABinary/generic-utils.js +0 -272
- package/lib/WABinary/index.js +0 -82
- package/lib/WABinary/jid-utils.js +0 -262
- package/lib/WAM/BinaryInfo.js +0 -50
- package/lib/WAM/constants.js +0 -38242
- package/lib/WAM/encode.js +0 -396
- package/lib/WAM/index.js +0 -78
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +47 -109
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -88
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -142
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -85
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -63
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -114
- package/lib/WAUSync/Protocols/index.js +0 -82
- package/lib/WAUSync/index.js +0 -78
- package/lib/assets/wasm/loader.js +0 -13
- package/lib/assets/wasm/worker-modules.js +0 -283
- package/lib/index.js +0 -93
- package/package.json +2 -3
- package/WAProto/index.d.ts +0 -46
- package/lib/Defaults/index.d.ts.map +0 -1
- package/lib/Defaults/index.js.map +0 -1
- package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
- package/lib/Signal/Group/ciphertext-message.js.map +0 -1
- package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
- package/lib/Signal/Group/group-session-builder.js.map +0 -1
- package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
- package/lib/Signal/Group/group_cipher.js.map +0 -1
- package/lib/Signal/Group/index.d.ts.map +0 -1
- package/lib/Signal/Group/index.js.map +0 -1
- package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
- package/lib/Signal/Group/keyhelper.js.map +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-chain-key.js.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-name.js.map +0 -1
- package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-record.js.map +0 -1
- package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-state.js.map +0 -1
- package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-message-key.js.map +0 -1
- package/lib/Signal/libsignal.d.ts.map +0 -1
- package/lib/Signal/libsignal.js.map +0 -1
- package/lib/Signal/lid-mapping.d.ts.map +0 -1
- package/lib/Signal/lid-mapping.js.map +0 -1
- package/lib/Socket/Client/index.d.ts.map +0 -1
- package/lib/Socket/Client/index.js.map +0 -1
- package/lib/Socket/Client/types.d.ts.map +0 -1
- package/lib/Socket/Client/types.js.map +0 -1
- package/lib/Socket/Client/websocket.d.ts.map +0 -1
- package/lib/Socket/Client/websocket.js.map +0 -1
- package/lib/Socket/business.d.ts.map +0 -1
- package/lib/Socket/business.js.map +0 -1
- package/lib/Socket/chats.d.ts.map +0 -1
- package/lib/Socket/chats.js.map +0 -1
- package/lib/Socket/communities.d.ts.map +0 -1
- package/lib/Socket/communities.js.map +0 -1
- package/lib/Socket/groups.d.ts.map +0 -1
- package/lib/Socket/groups.js.map +0 -1
- package/lib/Socket/index.d.ts.map +0 -1
- package/lib/Socket/index.js.map +0 -1
- package/lib/Socket/messages-recv.d.ts.map +0 -1
- package/lib/Socket/messages-recv.js.map +0 -1
- package/lib/Socket/messages-send.d.ts.map +0 -1
- package/lib/Socket/messages-send.js.map +0 -1
- package/lib/Socket/mex.d.ts.map +0 -1
- package/lib/Socket/mex.js.map +0 -1
- package/lib/Socket/newsletter.d.ts.map +0 -1
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Store/index.d.ts.map +0 -1
- package/lib/Store/index.js.map +0 -1
- package/lib/Store/make-in-memory-store.d.ts.map +0 -1
- package/lib/Store/make-in-memory-store.js.map +0 -1
- package/lib/Store/make-ordered-dictionary.d.ts.map +0 -1
- package/lib/Store/make-ordered-dictionary.js.map +0 -1
- package/lib/Store/object-repository.d.ts.map +0 -1
- package/lib/Store/object-repository.js.map +0 -1
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Bussines.d.ts.map +0 -1
- package/lib/Types/Call.d.ts.map +0 -1
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Mex.d.ts.map +0 -1
- package/lib/Types/Product.d.ts.map +0 -1
- package/lib/Types/RichType.d.ts.map +0 -1
- package/lib/Types/Signal.d.ts.map +0 -1
- package/lib/Types/Socket.d.ts.map +0 -1
- package/lib/Types/State.d.ts.map +0 -1
- package/lib/Types/USync.d.ts.map +0 -1
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Utils/auth-utils.d.ts.map +0 -1
- package/lib/Utils/auth-utils.js.map +0 -1
- package/lib/Utils/browser-utils.d.ts.map +0 -1
- package/lib/Utils/browser-utils.js.map +0 -1
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/chat-utils.d.ts.map +0 -1
- package/lib/Utils/chat-utils.js.map +0 -1
- package/lib/Utils/companion-reg-client-utils.d.ts.map +0 -1
- package/lib/Utils/companion-reg-client-utils.js.map +0 -1
- package/lib/Utils/crypto.d.ts.map +0 -1
- package/lib/Utils/crypto.js.map +0 -1
- package/lib/Utils/decode-wa-message.d.ts.map +0 -1
- package/lib/Utils/decode-wa-message.js.map +0 -1
- package/lib/Utils/event-buffer.d.ts.map +0 -1
- package/lib/Utils/event-buffer.js.map +0 -1
- package/lib/Utils/generics.d.ts.map +0 -1
- package/lib/Utils/generics.js.map +0 -1
- package/lib/Utils/history.d.ts.map +0 -1
- package/lib/Utils/history.js.map +0 -1
- package/lib/Utils/identity-change-handler.d.ts.map +0 -1
- package/lib/Utils/identity-change-handler.js.map +0 -1
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- package/lib/Utils/link-preview.d.ts.map +0 -1
- package/lib/Utils/link-preview.js.map +0 -1
- package/lib/Utils/logger.d.ts.map +0 -1
- package/lib/Utils/logger.js.map +0 -1
- package/lib/Utils/lt-hash.d.ts.map +0 -1
- package/lib/Utils/lt-hash.js.map +0 -1
- package/lib/Utils/make-mutex.d.ts.map +0 -1
- package/lib/Utils/make-mutex.js.map +0 -1
- package/lib/Utils/message-retry-manager.d.ts.map +0 -1
- package/lib/Utils/message-retry-manager.js.map +0 -1
- package/lib/Utils/messages-media.d.ts.map +0 -1
- package/lib/Utils/messages-media.js.map +0 -1
- package/lib/Utils/messages.d.ts.map +0 -1
- package/lib/Utils/messages.js.map +0 -1
- package/lib/Utils/noise-handler.d.ts.map +0 -1
- package/lib/Utils/noise-handler.js.map +0 -1
- package/lib/Utils/offline-node-processor.d.ts.map +0 -1
- package/lib/Utils/offline-node-processor.js.map +0 -1
- package/lib/Utils/pre-key-manager.d.ts.map +0 -1
- package/lib/Utils/pre-key-manager.js.map +0 -1
- package/lib/Utils/process-message.d.ts.map +0 -1
- package/lib/Utils/process-message.js.map +0 -1
- package/lib/Utils/reporting-utils.d.ts.map +0 -1
- package/lib/Utils/reporting-utils.js.map +0 -1
- package/lib/Utils/rich-message-utils.d.ts.map +0 -1
- package/lib/Utils/rich-message-utils.js.map +0 -1
- package/lib/Utils/signal.d.ts.map +0 -1
- package/lib/Utils/signal.js.map +0 -1
- package/lib/Utils/stanza-ack.d.ts.map +0 -1
- package/lib/Utils/stanza-ack.js.map +0 -1
- package/lib/Utils/sync-action-utils.d.ts.map +0 -1
- package/lib/Utils/sync-action-utils.js.map +0 -1
- package/lib/Utils/tc-token-utils.d.ts.map +0 -1
- package/lib/Utils/tc-token-utils.js.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
- package/lib/Utils/use-single-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-single-file-auth-state.js.map +0 -1
- package/lib/Utils/use-sqlite-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-sqlite-auth-state.js.map +0 -1
- package/lib/Utils/validate-connection.d.ts.map +0 -1
- package/lib/Utils/validate-connection.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/Utils/logger.js
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
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()}"` });
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const __kageModule69 = (() => {
|
|
11
|
-
const module = { exports: {} }; const exports = module.exports;
|
|
12
|
-
"use strict"
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
15
|
-
|
|
16
|
-
const pino = require("pino")
|
|
17
|
-
|
|
18
|
-
exports.default = pino({ timestamp: () => `,"time":"${new Date().toJSON()}"` })
|
|
19
|
-
|
|
20
|
-
return module.exports;
|
|
21
|
-
})();
|
|
22
|
-
for (const key of Object.keys(__kageModule69)) {
|
|
23
|
-
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule69[key]});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const __kageModule174 = (() => {
|
|
28
|
-
const module = { exports: {} }; const exports = module.exports;
|
|
29
|
-
"use strict";
|
|
30
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
3
|
const SILENT_LOGGER = Object.freeze({
|
|
32
4
|
level: 'silent',
|
|
@@ -40,10 +12,3 @@ const SILENT_LOGGER = Object.freeze({
|
|
|
40
12
|
isLevelEnabled: () => false
|
|
41
13
|
});
|
|
42
14
|
exports.default = SILENT_LOGGER;
|
|
43
|
-
|
|
44
|
-
return module.exports;
|
|
45
|
-
})();
|
|
46
|
-
for (const key of Object.keys(__kageModule174)) {
|
|
47
|
-
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule174[key]});
|
|
48
|
-
}
|
|
49
|
-
Object.defineProperty(exports, Symbol.for('kage.advanced'), {value:__kageModule174, configurable:true});
|
package/lib/Utils/lt-hash.js
CHANGED
|
@@ -1,58 +1,3 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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');
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const __kageModule70 = (() => {
|
|
55
|
-
const module = { exports: {} }; const exports = module.exports;
|
|
56
1
|
"use strict"
|
|
57
2
|
|
|
58
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
@@ -117,8 +62,3 @@ const LT_HASH_ANTI_TAMPERING = new LTHash('WhatsApp Patch Integrity')
|
|
|
117
62
|
module.exports = {
|
|
118
63
|
LT_HASH_ANTI_TAMPERING
|
|
119
64
|
}
|
|
120
|
-
return module.exports;
|
|
121
|
-
})();
|
|
122
|
-
for (const key of Object.keys(__kageModule70)) {
|
|
123
|
-
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule70[key]});
|
|
124
|
-
}
|
package/lib/Utils/make-mutex.js
CHANGED
|
@@ -1,109 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
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
|
-
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
await task;
|
|
14
|
-
}
|
|
15
|
-
catch (_a) { }
|
|
16
|
-
try {
|
|
17
|
-
|
|
18
|
-
const result = await code();
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
finally {
|
|
22
|
-
clearTimeout(taskTimeout);
|
|
23
|
-
}
|
|
24
|
-
})();
|
|
25
|
-
|
|
26
|
-
|
|
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;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const __kageModule71 = (() => {
|
|
47
|
-
const module = { exports: {} }; const exports = module.exports;
|
|
48
|
-
"use strict"
|
|
49
|
-
|
|
50
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
51
|
-
|
|
52
|
-
const { Mutex: AsyncMutex } = require("async-mutex")
|
|
53
|
-
|
|
54
|
-
const makeMutex = () => {
|
|
55
|
-
const mutex = new AsyncMutex()
|
|
56
|
-
return {
|
|
57
|
-
mutex(code) {
|
|
58
|
-
return mutex.runExclusive(code)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const makeKeyedMutex = () => {
|
|
64
|
-
const map = new Map()
|
|
65
|
-
return {
|
|
66
|
-
async mutex(key, task) {
|
|
67
|
-
let entry = map.get(key)
|
|
68
|
-
|
|
69
|
-
if (!entry) {
|
|
70
|
-
entry = { mutex: new AsyncMutex(), refCount: 0 }
|
|
71
|
-
map.set(key, entry)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
entry.refCount++
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
return await entry.mutex.runExclusive(task)
|
|
78
|
-
}
|
|
79
|
-
finally {
|
|
80
|
-
entry.refCount--
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (entry.refCount === 0 && map.get(key) === entry) {
|
|
84
|
-
map.delete(key)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
module.exports = {
|
|
92
|
-
makeMutex,
|
|
93
|
-
makeKeyedMutex
|
|
94
|
-
}
|
|
95
|
-
return module.exports;
|
|
96
|
-
})();
|
|
97
|
-
for (const key of Object.keys(__kageModule71)) {
|
|
98
|
-
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule71[key]});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const __kageModule175 = (() => {
|
|
103
|
-
const module = { exports: {} }; const exports = module.exports;
|
|
104
|
-
"use strict";
|
|
105
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106
|
-
exports.makeKeyedMutex = exports.makeMutex = void 0;
|
|
107
4
|
const index_js_1 = require("../Addon/index.js");
|
|
108
5
|
const makeMutex = () => {
|
|
109
6
|
const mutex = (0, index_js_1.createMutex)();
|
|
@@ -138,10 +35,3 @@ const makeKeyedMutex = () => {
|
|
|
138
35
|
};
|
|
139
36
|
};
|
|
140
37
|
exports.makeKeyedMutex = makeKeyedMutex;
|
|
141
|
-
|
|
142
|
-
return module.exports;
|
|
143
|
-
})();
|
|
144
|
-
for (const key of Object.keys(__kageModule175)) {
|
|
145
|
-
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule175[key]});
|
|
146
|
-
}
|
|
147
|
-
Object.defineProperty(exports, Symbol.for('kage.advanced'), {value:__kageModule175, configurable:true});
|
|
@@ -1,428 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MessageRetryManager = exports.RetryReason = void 0;
|
|
4
|
-
|
|
5
|
-
const lru_cache_1 = require("lru-cache");
|
|
6
|
-
|
|
7
|
-
const RECENT_MESSAGES_SIZE = 1000;
|
|
8
|
-
const MESSAGE_KEY_SEPARATOR = '\u0000';
|
|
9
|
-
const RECREATE_SESSION_TIMEOUT = 60 * 60 * 1000;
|
|
10
|
-
|
|
11
|
-
var RetryReason;
|
|
12
|
-
(function (RetryReason) {
|
|
13
|
-
RetryReason[RetryReason["UnknownError"] = 0] = "UnknownError";
|
|
14
|
-
RetryReason[RetryReason["SignalErrorNoSession"] = 1] = "SignalErrorNoSession";
|
|
15
|
-
RetryReason[RetryReason["SignalErrorInvalidKey"] = 2] = "SignalErrorInvalidKey";
|
|
16
|
-
RetryReason[RetryReason["SignalErrorInvalidKeyId"] = 3] = "SignalErrorInvalidKeyId";
|
|
17
|
-
RetryReason[RetryReason["SignalErrorInvalidMessage"] = 4] = "SignalErrorInvalidMessage";
|
|
18
|
-
RetryReason[RetryReason["SignalErrorInvalidSignature"] = 5] = "SignalErrorInvalidSignature";
|
|
19
|
-
RetryReason[RetryReason["SignalErrorFutureMessage"] = 6] = "SignalErrorFutureMessage";
|
|
20
|
-
RetryReason[RetryReason["SignalErrorBadMac"] = 7] = "SignalErrorBadMac";
|
|
21
|
-
RetryReason[RetryReason["SignalErrorInvalidSession"] = 8] = "SignalErrorInvalidSession";
|
|
22
|
-
RetryReason[RetryReason["SignalErrorInvalidMsgKey"] = 9] = "SignalErrorInvalidMsgKey";
|
|
23
|
-
RetryReason[RetryReason["BadBroadcastEphemeralSetting"] = 10] = "BadBroadcastEphemeralSetting";
|
|
24
|
-
RetryReason[RetryReason["UnknownCompanionNoPrekey"] = 11] = "UnknownCompanionNoPrekey";
|
|
25
|
-
RetryReason[RetryReason["AdvFailure"] = 12] = "AdvFailure";
|
|
26
|
-
RetryReason[RetryReason["StatusRevokeDelay"] = 13] = "StatusRevokeDelay";
|
|
27
|
-
})(RetryReason = exports.RetryReason || (exports.RetryReason = {}));
|
|
28
|
-
|
|
29
|
-
const MAC_ERROR_CODES = new Set([RetryReason.SignalErrorInvalidMessage, RetryReason.SignalErrorBadMac]);
|
|
30
|
-
|
|
31
|
-
class MessageRetryManager {
|
|
32
|
-
constructor(logger, maxMsgRetryCount = 5) {
|
|
33
|
-
this.logger = logger;
|
|
34
|
-
this.maxMsgRetryCount = maxMsgRetryCount;
|
|
35
|
-
this.messageKeyIndex = new Map();
|
|
36
|
-
this.pendingPhoneRequests = {};
|
|
37
|
-
this.statistics = {
|
|
38
|
-
totalRetries: 0,
|
|
39
|
-
successfulRetries: 0,
|
|
40
|
-
failedRetries: 0,
|
|
41
|
-
mediaRetries: 0,
|
|
42
|
-
sessionRecreations: 0,
|
|
43
|
-
phoneRequests: 0
|
|
44
|
-
};
|
|
45
|
-
this.recentMessagesMap = new lru_cache_1.LRUCache({
|
|
46
|
-
max: RECENT_MESSAGES_SIZE,
|
|
47
|
-
ttl: 5 * 60 * 1000,
|
|
48
|
-
ttlAutopurge: true,
|
|
49
|
-
dispose: (_value, key) => {
|
|
50
|
-
const separatorIndex = key.lastIndexOf(MESSAGE_KEY_SEPARATOR);
|
|
51
|
-
if (separatorIndex > -1) {
|
|
52
|
-
const messageId = key.slice(separatorIndex + MESSAGE_KEY_SEPARATOR.length);
|
|
53
|
-
this.messageKeyIndex.delete(messageId);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
this.sessionRecreateHistory = new lru_cache_1.LRUCache({
|
|
58
|
-
max: 10000,
|
|
59
|
-
ttl: RECREATE_SESSION_TIMEOUT,
|
|
60
|
-
ttlAutopurge: true
|
|
61
|
-
});
|
|
62
|
-
this.retryCounters = new lru_cache_1.LRUCache({
|
|
63
|
-
max: 5000,
|
|
64
|
-
ttl: 15 * 60 * 1000,
|
|
65
|
-
ttlAutopurge: true
|
|
66
|
-
});
|
|
67
|
-
this.baseKeys = new lru_cache_1.LRUCache({
|
|
68
|
-
max: 1024,
|
|
69
|
-
ttl: 15 * 60 * 1000,
|
|
70
|
-
ttlAutopurge: true
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
addRecentMessage(key, message, content) {
|
|
75
|
-
if (typeof key === 'string') { key = { to: key, id: message }; message = content; }
|
|
76
|
-
const id = key.id;
|
|
77
|
-
if (!id) return;
|
|
78
|
-
const keyStr = this.keyToString(key);
|
|
79
|
-
this.recentMessagesMap.set(keyStr, { message, timestamp: Date.now() });
|
|
80
|
-
this.messageKeyIndex.set(id, keyStr);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
getRecentMessage(key, id) {
|
|
84
|
-
if (typeof key === 'string') key = { to: key, id };
|
|
85
|
-
const keyStr = this.keyToString(key);
|
|
86
|
-
return this.recentMessagesMap.get(keyStr);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
shouldRecreateSession(jid, hasSession, errorCode) {
|
|
90
|
-
|
|
91
|
-
if (typeof hasSession === 'number' && typeof errorCode === 'boolean') { hasSession = errorCode; errorCode = undefined; }
|
|
92
|
-
if (!hasSession) {
|
|
93
|
-
this.sessionRecreateHistory.set(jid, Date.now());
|
|
94
|
-
this.statistics.sessionRecreations++;
|
|
95
|
-
return { reason: 'no existing session', recreate: true };
|
|
96
|
-
}
|
|
97
|
-
if (errorCode !== undefined && MAC_ERROR_CODES.has(errorCode)) {
|
|
98
|
-
this.sessionRecreateHistory.set(jid, Date.now());
|
|
99
|
-
this.statistics.sessionRecreations++;
|
|
100
|
-
this.logger.warn({ jid, errorCode: RetryReason[errorCode] }, 'MAC error detected, forcing immediate session recreation');
|
|
101
|
-
return {
|
|
102
|
-
reason: `MAC error (code ${errorCode}: ${RetryReason[errorCode]}), immediate session recreation`,
|
|
103
|
-
recreate: true
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
const now = Date.now();
|
|
107
|
-
const prevTime = this.sessionRecreateHistory.get(jid);
|
|
108
|
-
if (!prevTime || now - prevTime > RECREATE_SESSION_TIMEOUT) {
|
|
109
|
-
this.sessionRecreateHistory.set(jid, now);
|
|
110
|
-
this.statistics.sessionRecreations++;
|
|
111
|
-
return { reason: 'session recreation timeout window expired', recreate: true };
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
reason: `session recreated recently at ${new Date(prevTime).toISOString()}, skipping`,
|
|
115
|
-
recreate: false
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
parseRetryErrorCode(errorAttr) {
|
|
120
|
-
if (errorAttr === undefined || errorAttr === '') return undefined;
|
|
121
|
-
const code = parseInt(errorAttr, 10);
|
|
122
|
-
if (Number.isNaN(code)) return undefined;
|
|
123
|
-
if (code >= RetryReason.UnknownError && code <= RetryReason.StatusRevokeDelay) return code;
|
|
124
|
-
return RetryReason.UnknownError;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
isMacError(errorCode) {
|
|
128
|
-
return errorCode !== undefined && MAC_ERROR_CODES.has(errorCode);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
incrementRetryCount(messageId) {
|
|
132
|
-
this.retryCounters.set(messageId, (this.retryCounters.get(messageId) || 0) + 1);
|
|
133
|
-
this.statistics.totalRetries++;
|
|
134
|
-
return this.retryCounters.get(messageId);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
getRetryCount(messageId) {
|
|
138
|
-
return this.retryCounters.get(messageId) || 0;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
hasExceededMaxRetries(messageId) {
|
|
142
|
-
return this.getRetryCount(messageId) >= this.maxMsgRetryCount;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
markRetrySuccess(messageId) {
|
|
146
|
-
this.statistics.successfulRetries++;
|
|
147
|
-
this.retryCounters.delete(messageId);
|
|
148
|
-
this.cancelPendingPhoneRequest(messageId);
|
|
149
|
-
this.removeRecentMessage(messageId);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
markRetryFailed(messageId) {
|
|
153
|
-
this.statistics.failedRetries++;
|
|
154
|
-
this.retryCounters.delete(messageId);
|
|
155
|
-
this.cancelPendingPhoneRequest(messageId);
|
|
156
|
-
this.removeRecentMessage(messageId);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
schedulePhoneRequest(messageId, callback, delayMs = 3000) {
|
|
160
|
-
this.cancelPendingPhoneRequest(messageId);
|
|
161
|
-
this.pendingPhoneRequests[messageId] = setTimeout(() => {
|
|
162
|
-
delete this.pendingPhoneRequests[messageId];
|
|
163
|
-
this.statistics.phoneRequests++;
|
|
164
|
-
callback();
|
|
165
|
-
}, delayMs);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
cancelPendingPhoneRequest(messageId) {
|
|
169
|
-
const timeout = this.pendingPhoneRequests[messageId];
|
|
170
|
-
if (timeout) {
|
|
171
|
-
clearTimeout(timeout);
|
|
172
|
-
delete this.pendingPhoneRequests[messageId];
|
|
173
|
-
this.logger.debug(`Cancelled pending phone request for message ${messageId}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
clear() {
|
|
178
|
-
for (const cache of [this.recentMessagesMap, this.sessionRecreateHistory, this.retryCounters, this.baseKeys]) cache.clear();
|
|
179
|
-
this.messageKeyIndex.clear();
|
|
180
|
-
for (const id of Object.keys(this.pendingPhoneRequests)) this.cancelPendingPhoneRequest(id);
|
|
181
|
-
for (const key of Object.keys(this.statistics)) this.statistics[key] = 0;
|
|
182
|
-
}
|
|
183
|
-
saveBaseKey(addr, msgId, baseKey) { this.baseKeys.set(addr + ':' + msgId, Buffer.from(baseKey)); }
|
|
184
|
-
hasSameBaseKey(addr, msgId, baseKey) {
|
|
185
|
-
const stored = this.baseKeys.get(addr + ':' + msgId);
|
|
186
|
-
return !!stored && baseKey != null && Buffer.from(stored).equals(Buffer.from(baseKey));
|
|
187
|
-
}
|
|
188
|
-
deleteBaseKey(addr, msgId) { this.baseKeys.delete(addr + ':' + msgId); }
|
|
189
|
-
keyToString(key) {
|
|
190
|
-
return `${key.to}${MESSAGE_KEY_SEPARATOR}${key.id}`;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
removeRecentMessage(messageId) {
|
|
194
|
-
const keyStr = this.messageKeyIndex.get(messageId);
|
|
195
|
-
if (!keyStr) return;
|
|
196
|
-
this.recentMessagesMap.delete(keyStr);
|
|
197
|
-
this.messageKeyIndex.delete(messageId);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
exports.MessageRetryManager = MessageRetryManager;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const __kageModule72 = (() => {
|
|
205
|
-
const module = { exports: {} }; const exports = module.exports;
|
|
206
|
-
"use strict"
|
|
207
|
-
|
|
208
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
209
|
-
|
|
210
|
-
const { LRUCache } = require("lru-cache")
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const RECENT_MESSAGES_SIZE = 512
|
|
214
|
-
|
|
215
|
-
const MESSAGE_KEY_SEPARATOR = '\u0000'
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const RECREATE_SESSION_TIMEOUT = 60 * 60 * 1000
|
|
219
|
-
|
|
220
|
-
const PHONE_REQUEST_DELAY = 3000
|
|
221
|
-
|
|
222
|
-
class MessageRetryManager {
|
|
223
|
-
constructor(logger, maxMsgRetryCount) {
|
|
224
|
-
this.logger = logger
|
|
225
|
-
this.recentMessagesMap = new LRUCache({
|
|
226
|
-
max: RECENT_MESSAGES_SIZE,
|
|
227
|
-
ttl: 5 * 60 * 1000,
|
|
228
|
-
ttlAutopurge: true,
|
|
229
|
-
dispose: (_value, key) => {
|
|
230
|
-
const separatorIndex = key.lastIndexOf(MESSAGE_KEY_SEPARATOR)
|
|
231
|
-
if (separatorIndex > -1) {
|
|
232
|
-
const messageId = key.slice(separatorIndex + MESSAGE_KEY_SEPARATOR.length)
|
|
233
|
-
this.messageKeyIndex.delete(messageId)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
})
|
|
237
|
-
this.messageKeyIndex = new Map()
|
|
238
|
-
this.sessionRecreateHistory = new LRUCache({
|
|
239
|
-
ttl: RECREATE_SESSION_TIMEOUT * 2,
|
|
240
|
-
ttlAutopurge: true
|
|
241
|
-
})
|
|
242
|
-
this.retryCounters = new LRUCache({
|
|
243
|
-
ttl: 15 * 60 * 1000,
|
|
244
|
-
ttlAutopurge: true,
|
|
245
|
-
updateAgeOnGet: true
|
|
246
|
-
})
|
|
247
|
-
this.pendingPhoneRequests = {}
|
|
248
|
-
this.maxMsgRetryCount = 5
|
|
249
|
-
this.statistics = {
|
|
250
|
-
totalRetries: 0,
|
|
251
|
-
successfulRetries: 0,
|
|
252
|
-
failedRetries: 0,
|
|
253
|
-
mediaRetries: 0,
|
|
254
|
-
sessionRecreations: 0,
|
|
255
|
-
phoneRequests: 0
|
|
256
|
-
}
|
|
257
|
-
this.maxMsgRetryCount = maxMsgRetryCount
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
addRecentMessage(to, id, message) {
|
|
264
|
-
const key = { to, id }
|
|
265
|
-
const keyStr = this.keyToString(key)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
this.recentMessagesMap.set(keyStr, {
|
|
269
|
-
message,
|
|
270
|
-
timestamp: Date.now()
|
|
271
|
-
})
|
|
272
|
-
this.messageKeyIndex.set(id, keyStr)
|
|
273
|
-
this.logger.debug(`Added message to retry cache: ${to}/${id}`)
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
getRecentMessage(to, id) {
|
|
280
|
-
const key = { to, id }
|
|
281
|
-
const keyStr = this.keyToString(key)
|
|
282
|
-
|
|
283
|
-
return this.recentMessagesMap.get(keyStr)
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
shouldRecreateSession(jid, retryCount, hasSession) {
|
|
290
|
-
|
|
291
|
-
if (!hasSession) {
|
|
292
|
-
this.sessionRecreateHistory.set(jid, Date.now())
|
|
293
|
-
this.statistics.sessionRecreations++
|
|
294
|
-
return {
|
|
295
|
-
reason: "we don't have a Signal session with them",
|
|
296
|
-
recreate: true
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (retryCount < 2) {
|
|
302
|
-
return { reason: '', recreate: false }
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const now = Date.now()
|
|
306
|
-
const prevTime = this.sessionRecreateHistory.get(jid)
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (!prevTime || now - prevTime > RECREATE_SESSION_TIMEOUT) {
|
|
310
|
-
this.sessionRecreateHistory.set(jid, now)
|
|
311
|
-
this.statistics.sessionRecreations++
|
|
312
|
-
|
|
313
|
-
return {
|
|
314
|
-
reason: 'retry count > 1 and over an hour since last recreation',
|
|
315
|
-
recreate: true
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
return { reason: '', recreate: false }
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
incrementRetryCount(messageId) {
|
|
325
|
-
this.retryCounters.set(messageId, (this.retryCounters.get(messageId) || 0) + 1)
|
|
326
|
-
this.statistics.totalRetries++
|
|
327
|
-
|
|
328
|
-
return this.retryCounters.get(messageId)
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
getRetryCount(messageId) {
|
|
335
|
-
return this.retryCounters.get(messageId) || 0
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
hasExceededMaxRetries(messageId) {
|
|
342
|
-
return this.getRetryCount(messageId) >= this.maxMsgRetryCount
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
markRetrySuccess(messageId) {
|
|
349
|
-
this.statistics.successfulRetries++
|
|
350
|
-
|
|
351
|
-
this.retryCounters.delete(messageId)
|
|
352
|
-
this.cancelPendingPhoneRequest(messageId)
|
|
353
|
-
this.removeRecentMessage(messageId)
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
markRetryFailed(messageId) {
|
|
360
|
-
this.statistics.failedRetries++
|
|
361
|
-
this.retryCounters.delete(messageId)
|
|
362
|
-
this.cancelPendingPhoneRequest(messageId)
|
|
363
|
-
this.removeRecentMessage(messageId)
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
schedulePhoneRequest(messageId, callback, delay = PHONE_REQUEST_DELAY) {
|
|
370
|
-
|
|
371
|
-
this.cancelPendingPhoneRequest(messageId)
|
|
372
|
-
this.pendingPhoneRequests[messageId] = setTimeout(() => {
|
|
373
|
-
delete this.pendingPhoneRequests[messageId]
|
|
374
|
-
|
|
375
|
-
this.statistics.phoneRequests++
|
|
376
|
-
|
|
377
|
-
callback()
|
|
378
|
-
}, delay)
|
|
379
|
-
this.logger.debug(`Scheduled phone request for message ${messageId} with ${delay}ms delay`);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
cancelPendingPhoneRequest(messageId) {
|
|
386
|
-
const timeout = this.pendingPhoneRequests[messageId]
|
|
387
|
-
|
|
388
|
-
if (timeout) {
|
|
389
|
-
clearTimeout(timeout)
|
|
390
|
-
|
|
391
|
-
delete this.pendingPhoneRequests[messageId]
|
|
392
|
-
|
|
393
|
-
this.logger.debug(`Cancelled pending phone request for message ${messageId}`)
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
keyToString(key) {
|
|
398
|
-
return `${key.to}${MESSAGE_KEY_SEPARATOR}${key.id}`
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
removeRecentMessage(messageId) {
|
|
402
|
-
const keyStr = this.messageKeyIndex.get(messageId)
|
|
403
|
-
|
|
404
|
-
if (!keyStr) return
|
|
405
|
-
|
|
406
|
-
this.recentMessagesMap.delete(keyStr)
|
|
407
|
-
this.messageKeyIndex.delete(messageId)
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
module.exports = {
|
|
412
|
-
MessageRetryManager
|
|
413
|
-
}
|
|
414
|
-
return module.exports;
|
|
415
|
-
})();
|
|
416
|
-
for (const key of Object.keys(__kageModule72)) {
|
|
417
|
-
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule72[key]});
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
const __kageModule176 = (() => {
|
|
422
|
-
const module = { exports: {} }; const exports = module.exports;
|
|
423
|
-
"use strict";
|
|
424
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
425
|
-
exports.MessageRetryManager = exports.RetryReason = void 0;
|
|
426
4
|
const index_js_1 = require("../Addon/index.js");
|
|
427
5
|
|
|
428
6
|
const RECENT_MESSAGES_SIZE = 1024;
|
|
@@ -681,10 +259,3 @@ class MessageRetryManager {
|
|
|
681
259
|
}
|
|
682
260
|
}
|
|
683
261
|
exports.MessageRetryManager = MessageRetryManager;
|
|
684
|
-
|
|
685
|
-
return module.exports;
|
|
686
|
-
})();
|
|
687
|
-
for (const key of Object.keys(__kageModule176)) {
|
|
688
|
-
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule176[key]});
|
|
689
|
-
}
|
|
690
|
-
Object.defineProperty(exports, Symbol.for('kage.advanced'), {value:__kageModule176, configurable:true});
|