nrx-bails 0.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/LICENSE +21 -0
- package/README.md +1541 -0
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.d.ts +2 -0
- package/WAProto/index.js +169661 -0
- package/lib/Defaults/index.d.ts +113 -0
- package/lib/Defaults/index.js +156 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Defaults/ye-bail-version.json +3 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.js +41 -0
- package/lib/Signal/Group/group-session-builder.d.ts +8 -0
- package/lib/Signal/Group/group-session-builder.js +90 -0
- package/lib/Signal/Group/group_cipher.d.ts +12 -0
- package/lib/Signal/Group/group_cipher.js +122 -0
- package/lib/Signal/Group/index.d.ts +22 -0
- package/lib/Signal/Group/index.js +83 -0
- package/lib/Signal/Group/keyhelper.d.ts +7 -0
- package/lib/Signal/Group/keyhelper.js +81 -0
- package/lib/Signal/Group/queue-job.d.ts +3 -0
- package/lib/Signal/Group/queue-job.js +83 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.js +60 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +92 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.js +95 -0
- package/lib/Signal/Group/sender-key-name.d.ts +12 -0
- package/lib/Signal/Group/sender-key-name.js +77 -0
- package/lib/Signal/Group/sender-key-record.d.ts +13 -0
- package/lib/Signal/Group/sender-key-record.js +79 -0
- package/lib/Signal/Group/sender-key-state.d.ts +17 -0
- package/lib/Signal/Group/sender-key-state.js +125 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.js +55 -0
- package/lib/Signal/libsignal.d.ts +37 -0
- package/lib/Signal/libsignal.js +200 -0
- package/lib/Socket/Client/index.d.ts +1 -0
- package/lib/Socket/Client/index.js +44 -0
- package/lib/Socket/Client/types.d.ts +7 -0
- package/lib/Socket/Client/types.js +39 -0
- package/lib/Socket/Client/websocket.d.ts +19 -0
- package/lib/Socket/Client/websocket.js +137 -0
- package/lib/Socket/business.d.ts +329 -0
- package/lib/Socket/business.js +286 -0
- package/lib/Socket/chats.d.ts +84 -0
- package/lib/Socket/chats.js +1022 -0
- package/lib/Socket/groups.d.ts +216 -0
- package/lib/Socket/groups.js +358 -0
- package/lib/Socket/index.d.ts +330 -0
- package/lib/Socket/index.js +36 -0
- package/lib/Socket/messages-recv.d.ts +271 -0
- package/lib/Socket/messages-recv.js +1079 -0
- package/lib/Socket/messages-send.d.ts +258 -0
- package/lib/Socket/messages-send.js +1190 -0
- package/lib/Socket/newsletter.d.ts +253 -0
- package/lib/Socket/newsletter.js +362 -0
- package/lib/Socket/registration.d.ts +361 -0
- package/lib/Socket/registration.js +179 -0
- package/lib/Socket/socket.d.ts +33 -0
- package/lib/Socket/socket.js +699 -0
- package/lib/Socket/usync.d.ts +27 -0
- package/lib/Socket/usync.js +96 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +36 -0
- package/lib/Store/make-cache-manager-auth-state.d.ts +16 -0
- package/lib/Store/make-cache-manager-auth-state.js +118 -0
- package/lib/Store/make-in-memory-store.d.ts +64 -0
- package/lib/Store/make-in-memory-store.js +465 -0
- package/lib/Store/make-ordered-dictionary.d.ts +14 -0
- package/lib/Store/make-ordered-dictionary.js +107 -0
- package/lib/Store/object-repository.d.ts +11 -0
- package/lib/Store/object-repository.js +53 -0
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Auth.js +28 -0
- package/lib/Types/Call.d.ts +1 -0
- package/lib/Types/Call.js +28 -0
- package/lib/Types/Chat.d.ts +2 -0
- package/lib/Types/Chat.js +30 -0
- package/lib/Types/Contact.d.ts +1 -0
- package/lib/Types/Contact.js +28 -0
- package/lib/Types/Events.d.ts +1 -0
- package/lib/Types/Events.js +28 -0
- package/lib/Types/GroupMetadata.d.ts +1 -0
- package/lib/Types/GroupMetadata.js +28 -0
- package/lib/Types/Label.d.ts +2 -0
- package/lib/Types/Label.js +53 -0
- package/lib/Types/LabelAssociation.d.ts +2 -0
- package/lib/Types/LabelAssociation.js +35 -0
- package/lib/Types/Message.d.ts +2 -0
- package/lib/Types/Message.js +33 -0
- package/lib/Types/Newsletter.d.ts +4 -0
- package/lib/Types/Newsletter.js +62 -0
- package/lib/Types/Product.d.ts +1 -0
- package/lib/Types/Product.js +28 -0
- package/lib/Types/Signal.d.ts +1 -0
- package/lib/Types/Signal.js +28 -0
- package/lib/Types/Socket.d.ts +1 -0
- package/lib/Types/Socket.js +28 -0
- package/lib/Types/State.d.ts +1 -0
- package/lib/Types/State.js +28 -0
- package/lib/Types/USync.d.ts +1 -0
- package/lib/Types/USync.js +28 -0
- package/lib/Types/index.d.ts +2 -0
- package/lib/Types/index.js +68 -0
- package/lib/Utils/auth-utils.d.ts +63 -0
- package/lib/Utils/auth-utils.js +248 -0
- package/lib/Utils/browser-utils.d.ts +3 -0
- package/lib/Utils/browser-utils.js +61 -0
- package/lib/Utils/business.d.ts +53 -0
- package/lib/Utils/business.js +260 -0
- package/lib/Utils/chat-utils.d.ts +253 -0
- package/lib/Utils/chat-utils.js +756 -0
- package/lib/Utils/crypto.d.ts +43 -0
- package/lib/Utils/crypto.js +219 -0
- package/lib/Utils/decode-wa-message.d.ts +61 -0
- package/lib/Utils/decode-wa-message.js +233 -0
- package/lib/Utils/event-buffer.d.ts +17 -0
- package/lib/Utils/event-buffer.js +544 -0
- package/lib/Utils/generics.d.ts +89 -0
- package/lib/Utils/generics.js +471 -0
- package/lib/Utils/history.d.ts +59 -0
- package/lib/Utils/history.js +120 -0
- package/lib/Utils/index.d.ts +1 -0
- package/lib/Utils/index.js +61 -0
- package/lib/Utils/link-preview.d.ts +19 -0
- package/lib/Utils/link-preview.js +152 -0
- package/lib/Utils/logger.d.ts +3 -0
- package/lib/Utils/logger.js +33 -0
- package/lib/Utils/lt-hash.d.ts +13 -0
- package/lib/Utils/lt-hash.js +77 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.js +69 -0
- package/lib/Utils/message-retry-manager.d.ts +34 -0
- package/lib/Utils/message-retry-manager.js +154 -0
- package/lib/Utils/messages-media.d.ts +137 -0
- package/lib/Utils/messages-media.js +1024 -0
- package/lib/Utils/messages.d.ts +66 -0
- package/lib/Utils/messages.js +1407 -0
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/noise-handler.js +176 -0
- package/lib/Utils/pre-key-manager.d.ts +13 -0
- package/lib/Utils/pre-key-manager.js +93 -0
- package/lib/Utils/process-message.d.ts +40 -0
- package/lib/Utils/process-message.js +430 -0
- package/lib/Utils/signal.d.ts +72 -0
- package/lib/Utils/signal.js +179 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +18 -0
- package/lib/Utils/use-multi-file-auth-state.js +151 -0
- package/lib/Utils/validate-connection.d.ts +43 -0
- package/lib/Utils/validate-connection.js +255 -0
- package/lib/Utils/ye-bail-event-stream.d.ts +16 -0
- package/lib/Utils/ye-bail-event-stream.js +89 -0
- package/lib/WABinary/constants.d.ts +23 -0
- package/lib/WABinary/constants.js +1328 -0
- package/lib/WABinary/decode.d.ts +10 -0
- package/lib/WABinary/decode.js +291 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +276 -0
- package/lib/WABinary/generic-utils.d.ts +16 -0
- package/lib/WABinary/generic-utils.js +155 -0
- package/lib/WABinary/index.d.ts +1 -0
- package/lib/WABinary/index.js +47 -0
- package/lib/WABinary/jid-utils.d.ts +34 -0
- package/lib/WABinary/jid-utils.js +111 -0
- package/lib/WABinary/types.d.ts +1 -0
- package/lib/WABinary/types.js +28 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/BinaryInfo.js +39 -0
- package/lib/WAM/constants.d.ts +35374 -0
- package/lib/WAM/constants.js +15376 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/encode.js +181 -0
- package/lib/WAM/index.d.ts +1 -0
- package/lib/WAM/index.js +45 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +58 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +83 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +56 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +68 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +79 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +50 -0
- package/lib/WAUSync/Protocols/index.d.ts +1 -0
- package/lib/WAUSync/Protocols/index.js +46 -0
- package/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/lib/WAUSync/USyncQuery.js +115 -0
- package/lib/WAUSync/USyncUser.d.ts +13 -0
- package/lib/WAUSync/USyncUser.js +52 -0
- package/lib/WAUSync/index.d.ts +1 -0
- package/lib/WAUSync/index.js +45 -0
- package/lib/index.js +81 -0
- package/package.json +113 -0
- package/requirements.js +32 -0
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ╔═══════════════════════════════════════════════════════════╗
|
|
3
|
+
* ║ NEROX - WhatsApp API Library ║
|
|
4
|
+
* ║ Premium Edition ║
|
|
5
|
+
* ╚═══════════════════════════════════════════════════════════╝
|
|
6
|
+
*
|
|
7
|
+
* @package nerox-bails
|
|
8
|
+
* @version 0.1.0
|
|
9
|
+
* @author NEROX Development Team
|
|
10
|
+
* @copyright Copyright (c) 2025 NEROX. All rights reserved.
|
|
11
|
+
* @license MIT License
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
14
|
+
* a copy of this software and associated documentation files (the "Software"),
|
|
15
|
+
* to deal in the Software without restriction, including without limitation
|
|
16
|
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
17
|
+
* and/or sell copies of the Software, and to permit persons to whom the
|
|
18
|
+
* Software is furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included
|
|
21
|
+
* in all copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
24
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
26
|
+
*/
|
|
27
|
+
"use strict";
|
|
28
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
+
}) : function(o, v) {
|
|
42
|
+
o["default"] = v;
|
|
43
|
+
});
|
|
44
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
45
|
+
var ownKeys = function(o) {
|
|
46
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
49
|
+
return ar;
|
|
50
|
+
};
|
|
51
|
+
return ownKeys(o);
|
|
52
|
+
};
|
|
53
|
+
return function (mod) {
|
|
54
|
+
if (mod && mod.__esModule) return mod;
|
|
55
|
+
var result = {};
|
|
56
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
57
|
+
__setModuleDefault(result, mod);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
})();
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestYeBailVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeNewsletterMessage = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
|
|
66
|
+
exports.promiseTimeout = promiseTimeout;
|
|
67
|
+
exports.bindWaitForEvent = bindWaitForEvent;
|
|
68
|
+
exports.trimUndefined = trimUndefined;
|
|
69
|
+
exports.bytesToCrockford = bytesToCrockford;
|
|
70
|
+
const boom_1 = require("@hapi/boom");
|
|
71
|
+
const axios_1 = __importDefault(require("axios"));
|
|
72
|
+
const crypto_1 = require("crypto");
|
|
73
|
+
const os_1 = require("os");
|
|
74
|
+
const WAProto_1 = require("../../WAProto");
|
|
75
|
+
const ye_bail_version_json_1 = require("../Defaults/ye-bail-version.json");
|
|
76
|
+
const Types_1 = require("../Types");
|
|
77
|
+
const WABinary_1 = require("../WABinary");
|
|
78
|
+
const COMPANION_PLATFORM_MAP = {
|
|
79
|
+
'Chrome': '49',
|
|
80
|
+
'Edge': '50',
|
|
81
|
+
'Firefox': '51',
|
|
82
|
+
'Opera': '53',
|
|
83
|
+
'Safari': '54'
|
|
84
|
+
};
|
|
85
|
+
const PLATFORM_MAP = {
|
|
86
|
+
'aix': 'AIX',
|
|
87
|
+
'darwin': 'Mac OS',
|
|
88
|
+
'win32': 'Windows',
|
|
89
|
+
'android': 'Android',
|
|
90
|
+
'freebsd': 'FreeBSD',
|
|
91
|
+
'openbsd': 'OpenBSD',
|
|
92
|
+
'sunos': 'Solaris'
|
|
93
|
+
};
|
|
94
|
+
exports.Browsers = {
|
|
95
|
+
ubuntu: (browser) => ['Ubuntu', browser, '22.04.4'],
|
|
96
|
+
macOS: (browser) => ['Mac OS', browser, '14.4.1'],
|
|
97
|
+
yeBail: (browser) => ['YeBail', browser, '0.4.5'],
|
|
98
|
+
windows: (browser) => ['Windows', browser, '10.0.22631'],
|
|
99
|
+
/** The appropriate browser based on your OS & release */
|
|
100
|
+
appropriate: (browser) => [PLATFORM_MAP[(0, os_1.platform)()] || 'Ubuntu', browser, (0, os_1.release)()]
|
|
101
|
+
};
|
|
102
|
+
const getPlatformId = (browser) => {
|
|
103
|
+
const platformType = WAProto_1.proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
104
|
+
return platformType ? platformType.toString() : '49';
|
|
105
|
+
};
|
|
106
|
+
exports.getPlatformId = getPlatformId;
|
|
107
|
+
exports.BufferJSON = {
|
|
108
|
+
replacer: (k, value) => {
|
|
109
|
+
if (Buffer.isBuffer(value) || value instanceof Uint8Array || (value === null || value === void 0 ? void 0 : value.type) === 'Buffer') {
|
|
110
|
+
return { type: 'Buffer', data: Buffer.from((value === null || value === void 0 ? void 0 : value.data) || value).toString('base64') };
|
|
111
|
+
}
|
|
112
|
+
return value;
|
|
113
|
+
},
|
|
114
|
+
reviver: (_, value) => {
|
|
115
|
+
if (typeof value === 'object' && !!value && (value.buffer === true || value.type === 'Buffer')) {
|
|
116
|
+
const val = value.data || value.value;
|
|
117
|
+
return typeof val === 'string' ? Buffer.from(val, 'base64') : Buffer.from(val || []);
|
|
118
|
+
}
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const getKeyAuthor = (key, meId = 'me') => (((key === null || key === void 0 ? void 0 : key.fromMe) ? meId : (key === null || key === void 0 ? void 0 : key.participant) || (key === null || key === void 0 ? void 0 : key.remoteJid)) || '');
|
|
123
|
+
exports.getKeyAuthor = getKeyAuthor;
|
|
124
|
+
const writeRandomPadMax16 = (msg) => {
|
|
125
|
+
const pad = (0, crypto_1.randomBytes)(1);
|
|
126
|
+
pad[0] &= 0xf;
|
|
127
|
+
if (!pad[0]) {
|
|
128
|
+
pad[0] = 0xf;
|
|
129
|
+
}
|
|
130
|
+
return Buffer.concat([msg, Buffer.alloc(pad[0], pad[0])]);
|
|
131
|
+
};
|
|
132
|
+
exports.writeRandomPadMax16 = writeRandomPadMax16;
|
|
133
|
+
const unpadRandomMax16 = (e) => {
|
|
134
|
+
const t = new Uint8Array(e);
|
|
135
|
+
if (0 === t.length) {
|
|
136
|
+
throw new Error('unpadPkcs7 given empty bytes');
|
|
137
|
+
}
|
|
138
|
+
var r = t[t.length - 1];
|
|
139
|
+
if (r > t.length) {
|
|
140
|
+
throw new Error(`unpad given ${t.length} bytes, but pad is ${r}`);
|
|
141
|
+
}
|
|
142
|
+
return new Uint8Array(t.buffer, t.byteOffset, t.length - r);
|
|
143
|
+
};
|
|
144
|
+
exports.unpadRandomMax16 = unpadRandomMax16;
|
|
145
|
+
const encodeWAMessage = (message) => ((0, exports.writeRandomPadMax16)(WAProto_1.proto.Message.encode(message).finish()));
|
|
146
|
+
exports.encodeWAMessage = encodeWAMessage;
|
|
147
|
+
const encodeNewsletterMessage = (message) => (WAProto_1.proto.Message.encode(message).finish());
|
|
148
|
+
exports.encodeNewsletterMessage = encodeNewsletterMessage;
|
|
149
|
+
const generateRegistrationId = () => {
|
|
150
|
+
return Uint16Array.from((0, crypto_1.randomBytes)(2))[0] & 16383;
|
|
151
|
+
};
|
|
152
|
+
exports.generateRegistrationId = generateRegistrationId;
|
|
153
|
+
const encodeBigEndian = (e, t = 4) => {
|
|
154
|
+
let r = e;
|
|
155
|
+
const a = new Uint8Array(t);
|
|
156
|
+
for (let i = t - 1; i >= 0; i--) {
|
|
157
|
+
a[i] = 255 & r;
|
|
158
|
+
r >>>= 8;
|
|
159
|
+
}
|
|
160
|
+
return a;
|
|
161
|
+
};
|
|
162
|
+
exports.encodeBigEndian = encodeBigEndian;
|
|
163
|
+
const toNumber = (t) => ((typeof t === 'object' && t) ? ('toNumber' in t ? t.toNumber() : t.low) : t || 0);
|
|
164
|
+
exports.toNumber = toNumber;
|
|
165
|
+
/** unix timestamp of a date in seconds */
|
|
166
|
+
const unixTimestampSeconds = (date = new Date()) => Math.floor(date.getTime() / 1000);
|
|
167
|
+
exports.unixTimestampSeconds = unixTimestampSeconds;
|
|
168
|
+
const debouncedTimeout = (intervalMs = 1000, task) => {
|
|
169
|
+
let timeout;
|
|
170
|
+
return {
|
|
171
|
+
start: (newIntervalMs, newTask) => {
|
|
172
|
+
task = newTask || task;
|
|
173
|
+
intervalMs = newIntervalMs || intervalMs;
|
|
174
|
+
timeout && clearTimeout(timeout);
|
|
175
|
+
timeout = setTimeout(() => task === null || task === void 0 ? void 0 : task(), intervalMs);
|
|
176
|
+
},
|
|
177
|
+
cancel: () => {
|
|
178
|
+
timeout && clearTimeout(timeout);
|
|
179
|
+
timeout = undefined;
|
|
180
|
+
},
|
|
181
|
+
setTask: (newTask) => task = newTask,
|
|
182
|
+
setInterval: (newInterval) => intervalMs = newInterval
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
exports.debouncedTimeout = debouncedTimeout;
|
|
186
|
+
const delay = (ms) => (0, exports.delayCancellable)(ms).delay;
|
|
187
|
+
exports.delay = delay;
|
|
188
|
+
const delayCancellable = (ms) => {
|
|
189
|
+
const stack = new Error().stack;
|
|
190
|
+
let timeout;
|
|
191
|
+
let reject;
|
|
192
|
+
const delay = new Promise((resolve, _reject) => {
|
|
193
|
+
timeout = setTimeout(resolve, ms);
|
|
194
|
+
reject = _reject;
|
|
195
|
+
});
|
|
196
|
+
const cancel = () => {
|
|
197
|
+
clearTimeout(timeout);
|
|
198
|
+
reject(new boom_1.Boom('Cancelled', {
|
|
199
|
+
statusCode: 500,
|
|
200
|
+
data: {
|
|
201
|
+
stack
|
|
202
|
+
}
|
|
203
|
+
}));
|
|
204
|
+
};
|
|
205
|
+
return { delay, cancel };
|
|
206
|
+
};
|
|
207
|
+
exports.delayCancellable = delayCancellable;
|
|
208
|
+
async function promiseTimeout(ms, promise) {
|
|
209
|
+
if (!ms) {
|
|
210
|
+
return new Promise(promise);
|
|
211
|
+
}
|
|
212
|
+
const stack = new Error().stack;
|
|
213
|
+
|
|
214
|
+
const { delay, cancel } = (0, exports.delayCancellable)(ms);
|
|
215
|
+
const p = new Promise((resolve, reject) => {
|
|
216
|
+
delay
|
|
217
|
+
.then(() => reject(new boom_1.Boom('Timed Out', {
|
|
218
|
+
statusCode: Types_1.DisconnectReason.timedOut,
|
|
219
|
+
data: {
|
|
220
|
+
stack
|
|
221
|
+
}
|
|
222
|
+
})))
|
|
223
|
+
.catch(err => reject(err));
|
|
224
|
+
promise(resolve, reject);
|
|
225
|
+
})
|
|
226
|
+
.finally(cancel);
|
|
227
|
+
return p;
|
|
228
|
+
}
|
|
229
|
+
const generateMessageIDV2 = (userId) => {
|
|
230
|
+
const data = Buffer.alloc(8 + 20 + 16);
|
|
231
|
+
data.writeBigUInt64BE(BigInt(Math.floor(Date.now() / 1000)));
|
|
232
|
+
if (userId) {
|
|
233
|
+
const id = (0, WABinary_1.jidDecode)(userId);
|
|
234
|
+
if (id === null || id === void 0 ? void 0 : id.user) {
|
|
235
|
+
data.write(id.user, 8);
|
|
236
|
+
data.write('@c.us', 8 + id.user.length);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const random = (0, crypto_1.randomBytes)(16);
|
|
240
|
+
random.copy(data, 28);
|
|
241
|
+
const hash = (0, crypto_1.createHash)('sha256').update(data).digest();
|
|
242
|
+
return '3EB0' + hash.toString('hex').toUpperCase().substring(0, 18);
|
|
243
|
+
};
|
|
244
|
+
exports.generateMessageIDV2 = generateMessageIDV2;
|
|
245
|
+
|
|
246
|
+
const generateMessageID = () => '3EB0' + (0, crypto_1.randomBytes)(18).toString('hex').toUpperCase();
|
|
247
|
+
exports.generateMessageID = generateMessageID;
|
|
248
|
+
function bindWaitForEvent(ev, event) {
|
|
249
|
+
return async (check, timeoutMs) => {
|
|
250
|
+
let listener;
|
|
251
|
+
let closeListener;
|
|
252
|
+
await (promiseTimeout(timeoutMs, (resolve, reject) => {
|
|
253
|
+
closeListener = ({ connection, lastDisconnect }) => {
|
|
254
|
+
if (connection === 'close') {
|
|
255
|
+
reject((lastDisconnect === null || lastDisconnect === void 0 ? void 0 : lastDisconnect.error)
|
|
256
|
+
|| new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
ev.on('connection.update', closeListener);
|
|
260
|
+
listener = async (update) => {
|
|
261
|
+
if (await check(update)) {
|
|
262
|
+
resolve();
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
ev.on(event, listener);
|
|
266
|
+
})
|
|
267
|
+
.finally(() => {
|
|
268
|
+
ev.off(event, listener);
|
|
269
|
+
ev.off('connection.update', closeListener);
|
|
270
|
+
}));
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, 'connection.update');
|
|
274
|
+
exports.bindWaitForConnectionUpdate = bindWaitForConnectionUpdate;
|
|
275
|
+
const printQRIfNecessaryListener = (ev, logger) => {
|
|
276
|
+
ev.on('connection.update', async ({ qr }) => {
|
|
277
|
+
if (qr) {
|
|
278
|
+
const QR = await Promise.resolve().then(() => __importStar(require('qrcode-terminal'))).then(m => m.default || m)
|
|
279
|
+
.catch(() => {
|
|
280
|
+
logger.error('QR code terminal not added as dependency');
|
|
281
|
+
});
|
|
282
|
+
QR === null || QR === void 0 ? void 0 : QR.generate(qr, { small: true });
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
|
|
287
|
+
|
|
288
|
+
const fetchLatestYeBailVersion = async (options = {}) => {
|
|
289
|
+
try {
|
|
290
|
+
const { data } = await axios_1.default.get('https://registry.npmjs.org/ye-bail', {
|
|
291
|
+
...options,
|
|
292
|
+
responseType: 'json'
|
|
293
|
+
});
|
|
294
|
+
const versionStr = data.version;
|
|
295
|
+
const [major, minor, patch] = versionStr.split('.').map(Number);
|
|
296
|
+
return {
|
|
297
|
+
version: [major, minor, patch],
|
|
298
|
+
isLatest: true
|
|
299
|
+
};
|
|
300
|
+
} catch (error) {
|
|
301
|
+
return {
|
|
302
|
+
version: ye_bail_version_json_1.version,
|
|
303
|
+
isLatest: false,
|
|
304
|
+
error
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
exports.fetchLatestYeBailVersion = fetchLatestYeBailVersion;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* A utility that fetches the latest web version of whatsapp.
|
|
312
|
+
* Use to ensure your WA connection is always on the latest version
|
|
313
|
+
*/
|
|
314
|
+
const fetchLatestWaWebVersion = async (options) => {
|
|
315
|
+
try {
|
|
316
|
+
const { data } = await axios_1.default.get('https://web.whatsapp.com/sw.js', {
|
|
317
|
+
...options,
|
|
318
|
+
responseType: 'json'
|
|
319
|
+
});
|
|
320
|
+
const regex = /\\?"client_revision\\?":\s*(\d+)/;
|
|
321
|
+
const match = data.match(regex);
|
|
322
|
+
if (!(match === null || match === void 0 ? void 0 : match[1])) {
|
|
323
|
+
return {
|
|
324
|
+
version: ye_bail_version_json_1.version,
|
|
325
|
+
isLatest: false,
|
|
326
|
+
error: {
|
|
327
|
+
message: 'Could not find client revision in the fetched content'
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
const clientRevision = match[1];
|
|
332
|
+
return {
|
|
333
|
+
version: [2, 3000, +clientRevision],
|
|
334
|
+
isLatest: true
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
return {
|
|
339
|
+
version: ye_bail_version_json_1.version,
|
|
340
|
+
isLatest: false,
|
|
341
|
+
error
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
exports.fetchLatestWaWebVersion = fetchLatestWaWebVersion;
|
|
346
|
+
/** unique message tag prefix for MD clients */
|
|
347
|
+
const generateMdTagPrefix = () => {
|
|
348
|
+
const bytes = (0, crypto_1.randomBytes)(4);
|
|
349
|
+
return `${bytes.readUInt16BE()}.${bytes.readUInt16BE(2)}-`;
|
|
350
|
+
};
|
|
351
|
+
exports.generateMdTagPrefix = generateMdTagPrefix;
|
|
352
|
+
const STATUS_MAP = {
|
|
353
|
+
'sender': WAProto_1.proto.WebMessageInfo.Status.SERVER_ACK,
|
|
354
|
+
'played': WAProto_1.proto.WebMessageInfo.Status.PLAYED,
|
|
355
|
+
'read': WAProto_1.proto.WebMessageInfo.Status.READ,
|
|
356
|
+
'read-self': WAProto_1.proto.WebMessageInfo.Status.READ
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Given a type of receipt, returns what the new status of the message should be
|
|
360
|
+
* @param type type from receipt
|
|
361
|
+
*/
|
|
362
|
+
const getStatusFromReceiptType = (type) => {
|
|
363
|
+
const status = STATUS_MAP[type];
|
|
364
|
+
if (typeof type === 'undefined') {
|
|
365
|
+
return WAProto_1.proto.WebMessageInfo.Status.DELIVERY_ACK;
|
|
366
|
+
}
|
|
367
|
+
return status;
|
|
368
|
+
};
|
|
369
|
+
exports.getStatusFromReceiptType = getStatusFromReceiptType;
|
|
370
|
+
const CODE_MAP = {
|
|
371
|
+
conflict: Types_1.DisconnectReason.connectionReplaced
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Stream errors generally provide a reason, map that to a DisconnectReason
|
|
375
|
+
* @param reason the string reason given, eg. "conflict"
|
|
376
|
+
*/
|
|
377
|
+
const getErrorCodeFromStreamError = (node) => {
|
|
378
|
+
const [reasonNode] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
|
|
379
|
+
let reason = (reasonNode === null || reasonNode === void 0 ? void 0 : reasonNode.tag) || 'unknown';
|
|
380
|
+
const statusCode = +(node.attrs.code || CODE_MAP[reason] || Types_1.DisconnectReason.badSession);
|
|
381
|
+
if (statusCode === Types_1.DisconnectReason.restartRequired) {
|
|
382
|
+
reason = 'restart required';
|
|
383
|
+
}
|
|
384
|
+
return {
|
|
385
|
+
reason,
|
|
386
|
+
statusCode
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
exports.getErrorCodeFromStreamError = getErrorCodeFromStreamError;
|
|
390
|
+
const getCallStatusFromNode = ({ tag, attrs }) => {
|
|
391
|
+
let status;
|
|
392
|
+
switch (tag) {
|
|
393
|
+
case 'offer':
|
|
394
|
+
case 'offer_notice':
|
|
395
|
+
status = 'offer';
|
|
396
|
+
break;
|
|
397
|
+
case 'terminate':
|
|
398
|
+
if (attrs.reason === 'timeout') {
|
|
399
|
+
status = 'timeout';
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
|
|
403
|
+
status = 'terminate';
|
|
404
|
+
}
|
|
405
|
+
break;
|
|
406
|
+
case 'reject':
|
|
407
|
+
status = 'reject';
|
|
408
|
+
break;
|
|
409
|
+
case 'accept':
|
|
410
|
+
status = 'accept';
|
|
411
|
+
break;
|
|
412
|
+
default:
|
|
413
|
+
status = 'ringing';
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
return status;
|
|
417
|
+
};
|
|
418
|
+
exports.getCallStatusFromNode = getCallStatusFromNode;
|
|
419
|
+
const UNEXPECTED_SERVER_CODE_TEXT = 'Unexpected server response: ';
|
|
420
|
+
const getCodeFromWSError = (error) => {
|
|
421
|
+
var _a, _b, _c;
|
|
422
|
+
let statusCode = 500;
|
|
423
|
+
if ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes(UNEXPECTED_SERVER_CODE_TEXT)) {
|
|
424
|
+
const code = +(error === null || error === void 0 ? void 0 : error.message.slice(UNEXPECTED_SERVER_CODE_TEXT.length));
|
|
425
|
+
if (!Number.isNaN(code) && code >= 400) {
|
|
426
|
+
statusCode = code;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
else if (((_b = error === null || error === void 0 ? void 0 : error.code) === null || _b === void 0 ? void 0 : _b.startsWith('E'))
|
|
430
|
+
|| ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('timed out'))) {
|
|
431
|
+
statusCode = 408;
|
|
432
|
+
}
|
|
433
|
+
return statusCode;
|
|
434
|
+
};
|
|
435
|
+
exports.getCodeFromWSError = getCodeFromWSError;
|
|
436
|
+
/**
|
|
437
|
+
* Is the given platform WA business
|
|
438
|
+
* @param platform AuthenticationCreds.platform
|
|
439
|
+
*/
|
|
440
|
+
const isWABusinessPlatform = (platform) => {
|
|
441
|
+
return platform === 'smbi' || platform === 'smba';
|
|
442
|
+
};
|
|
443
|
+
exports.isWABusinessPlatform = isWABusinessPlatform;
|
|
444
|
+
function trimUndefined(obj) {
|
|
445
|
+
for (const key in obj) {
|
|
446
|
+
if (typeof obj[key] === 'undefined') {
|
|
447
|
+
delete obj[key];
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return obj;
|
|
451
|
+
}
|
|
452
|
+
const CROCKFORD_CHARACTERS = '123456789ABCDEFGHJKLMNPQRSTVWXYZ';
|
|
453
|
+
function bytesToCrockford(buffer) {
|
|
454
|
+
let value = 0;
|
|
455
|
+
let bitCount = 0;
|
|
456
|
+
const crockford = [];
|
|
457
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
458
|
+
value = (value << 8) | (buffer[i] & 0xff);
|
|
459
|
+
bitCount += 8;
|
|
460
|
+
while (bitCount >= 5) {
|
|
461
|
+
crockford.push(CROCKFORD_CHARACTERS.charAt((value >>> (bitCount - 5)) & 31));
|
|
462
|
+
bitCount -= 5;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (bitCount > 0) {
|
|
466
|
+
crockford.push(CROCKFORD_CHARACTERS.charAt((value << (5 - bitCount)) & 31));
|
|
467
|
+
}
|
|
468
|
+
return crockford.join('');
|
|
469
|
+
}
|
|
470
|
+
exports.trimUndefined = trimUndefined;
|
|
471
|
+
exports.bytesToCrockford = bytesToCrockford;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const __esModule: boolean;
|
|
2
|
+
export function downloadHistory(msg: any, options: any): Promise<any>;
|
|
3
|
+
export function processHistoryMessage(item: any): {
|
|
4
|
+
chats: any[];
|
|
5
|
+
contacts: ({
|
|
6
|
+
id: any;
|
|
7
|
+
name: any;
|
|
8
|
+
lid: any;
|
|
9
|
+
jid: any;
|
|
10
|
+
verifiedName?: undefined;
|
|
11
|
+
notify?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
id: any;
|
|
14
|
+
verifiedName: any;
|
|
15
|
+
name?: undefined;
|
|
16
|
+
lid?: undefined;
|
|
17
|
+
jid?: undefined;
|
|
18
|
+
notify?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
id: any;
|
|
21
|
+
notify: any;
|
|
22
|
+
name?: undefined;
|
|
23
|
+
lid?: undefined;
|
|
24
|
+
jid?: undefined;
|
|
25
|
+
verifiedName?: undefined;
|
|
26
|
+
})[];
|
|
27
|
+
messages: any[];
|
|
28
|
+
syncType: any;
|
|
29
|
+
progress: any;
|
|
30
|
+
};
|
|
31
|
+
export function downloadAndProcessHistorySyncNotification(msg: any, options: any): Promise<{
|
|
32
|
+
chats: any[];
|
|
33
|
+
contacts: ({
|
|
34
|
+
id: any;
|
|
35
|
+
name: any;
|
|
36
|
+
lid: any;
|
|
37
|
+
jid: any;
|
|
38
|
+
verifiedName?: undefined;
|
|
39
|
+
notify?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
id: any;
|
|
42
|
+
verifiedName: any;
|
|
43
|
+
name?: undefined;
|
|
44
|
+
lid?: undefined;
|
|
45
|
+
jid?: undefined;
|
|
46
|
+
notify?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
id: any;
|
|
49
|
+
notify: any;
|
|
50
|
+
name?: undefined;
|
|
51
|
+
lid?: undefined;
|
|
52
|
+
jid?: undefined;
|
|
53
|
+
verifiedName?: undefined;
|
|
54
|
+
})[];
|
|
55
|
+
messages: any[];
|
|
56
|
+
syncType: any;
|
|
57
|
+
progress: any;
|
|
58
|
+
}>;
|
|
59
|
+
export function getHistoryMsg(message: any): any;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ╔═══════════════════════════════════════════════════════════╗
|
|
3
|
+
* ║ NEROX - WhatsApp API Library ║
|
|
4
|
+
* ║ Premium Edition ║
|
|
5
|
+
* ╚═══════════════════════════════════════════════════════════╝
|
|
6
|
+
*
|
|
7
|
+
* @package nerox-bails
|
|
8
|
+
* @version 0.1.0
|
|
9
|
+
* @author NEROX Development Team
|
|
10
|
+
* @copyright Copyright (c) 2025 NEROX. All rights reserved.
|
|
11
|
+
* @license MIT License
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
14
|
+
* a copy of this software and associated documentation files (the "Software"),
|
|
15
|
+
* to deal in the Software without restriction, including without limitation
|
|
16
|
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
17
|
+
* and/or sell copies of the Software, and to permit persons to whom the
|
|
18
|
+
* Software is furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included
|
|
21
|
+
* in all copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
24
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
26
|
+
*/
|
|
27
|
+
"use strict";
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getHistoryMsg = exports.downloadAndProcessHistorySyncNotification = exports.processHistoryMessage = exports.downloadHistory = void 0;
|
|
30
|
+
const util_1 = require("util");
|
|
31
|
+
const zlib_1 = require("zlib");
|
|
32
|
+
const WAProto_1 = require("../../WAProto");
|
|
33
|
+
const Types_1 = require("../Types");
|
|
34
|
+
const WABinary_1 = require("../WABinary");
|
|
35
|
+
const generics_1 = require("./generics");
|
|
36
|
+
const messages_1 = require("./messages");
|
|
37
|
+
const messages_media_1 = require("./messages-media");
|
|
38
|
+
const inflatePromise = (0, util_1.promisify)(zlib_1.inflate);
|
|
39
|
+
const downloadHistory = async (msg, options) => {
|
|
40
|
+
const stream = await (0, messages_media_1.downloadContentFromMessage)(msg, 'md-msg-hist', { options });
|
|
41
|
+
const bufferArray = [];
|
|
42
|
+
for await (const chunk of stream) {
|
|
43
|
+
bufferArray.push(chunk);
|
|
44
|
+
}
|
|
45
|
+
let buffer = Buffer.concat(bufferArray);
|
|
46
|
+
|
|
47
|
+
buffer = await inflatePromise(buffer);
|
|
48
|
+
const syncData = WAProto_1.proto.HistorySync.decode(buffer);
|
|
49
|
+
return syncData;
|
|
50
|
+
};
|
|
51
|
+
exports.downloadHistory = downloadHistory;
|
|
52
|
+
const processHistoryMessage = (item) => {
|
|
53
|
+
var _a, _b, _c;
|
|
54
|
+
const messages = [];
|
|
55
|
+
const contacts = [];
|
|
56
|
+
const chats = [];
|
|
57
|
+
switch (item.syncType) {
|
|
58
|
+
case WAProto_1.proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
|
|
59
|
+
case WAProto_1.proto.HistorySync.HistorySyncType.RECENT:
|
|
60
|
+
case WAProto_1.proto.HistorySync.HistorySyncType.FULL:
|
|
61
|
+
case WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND:
|
|
62
|
+
for (const chat of item.conversations) {
|
|
63
|
+
contacts.push({ id: chat.id, name: chat.name || undefined, lid: chat.lidJid || undefined, jid: (0, WABinary_1.isJidUser)(chat.id) ? chat.id : chat.pnJid });
|
|
64
|
+
const msgs = chat.messages || [];
|
|
65
|
+
delete chat.messages;
|
|
66
|
+
delete chat.archived;
|
|
67
|
+
delete chat.muteEndTime;
|
|
68
|
+
delete chat.pinned;
|
|
69
|
+
for (const item of msgs) {
|
|
70
|
+
const message = item.message;
|
|
71
|
+
messages.push(message);
|
|
72
|
+
if (!((_a = chat.messages) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
73
|
+
|
|
74
|
+
chat.messages = [{ message }];
|
|
75
|
+
}
|
|
76
|
+
if (!message.key.fromMe && !chat.lastMessageRecvTimestamp) {
|
|
77
|
+
chat.lastMessageRecvTimestamp = (0, generics_1.toNumber)(message.messageTimestamp);
|
|
78
|
+
}
|
|
79
|
+
if ((message.messageStubType === Types_1.WAMessageStubType.BIZ_PRIVACY_MODE_TO_BSP
|
|
80
|
+
|| message.messageStubType === Types_1.WAMessageStubType.BIZ_PRIVACY_MODE_TO_FB)
|
|
81
|
+
&& ((_b = message.messageStubParameters) === null || _b === void 0 ? void 0 : _b[0])) {
|
|
82
|
+
contacts.push({
|
|
83
|
+
id: message.key.participant || message.key.remoteJid,
|
|
84
|
+
verifiedName: (_c = message.messageStubParameters) === null || _c === void 0 ? void 0 : _c[0],
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if ((0, WABinary_1.isJidUser)(chat.id) && chat.readOnly && chat.archived) {
|
|
89
|
+
delete chat.readOnly;
|
|
90
|
+
}
|
|
91
|
+
chats.push({ ...chat });
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case WAProto_1.proto.HistorySync.HistorySyncType.PUSH_NAME:
|
|
95
|
+
for (const c of item.pushnames) {
|
|
96
|
+
contacts.push({ id: c.id, notify: c.pushname });
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
chats,
|
|
102
|
+
contacts,
|
|
103
|
+
messages,
|
|
104
|
+
syncType: item.syncType,
|
|
105
|
+
progress: item.progress
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
exports.processHistoryMessage = processHistoryMessage;
|
|
109
|
+
const downloadAndProcessHistorySyncNotification = async (msg, options) => {
|
|
110
|
+
const historyMsg = await (0, exports.downloadHistory)(msg, options);
|
|
111
|
+
return (0, exports.processHistoryMessage)(historyMsg);
|
|
112
|
+
};
|
|
113
|
+
exports.downloadAndProcessHistorySyncNotification = downloadAndProcessHistorySyncNotification;
|
|
114
|
+
const getHistoryMsg = (message) => {
|
|
115
|
+
var _a;
|
|
116
|
+
const normalizedContent = !!message ? (0, messages_1.normalizeMessageContent)(message) : undefined;
|
|
117
|
+
const anyHistoryMsg = (_a = normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.protocolMessage) === null || _a === void 0 ? void 0 : _a.historySyncNotification;
|
|
118
|
+
return anyHistoryMsg;
|
|
119
|
+
};
|
|
120
|
+
exports.getHistoryMsg = getHistoryMsg;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __esModule: boolean;
|