@prototypevip/baileys 0.1.1 → 0.1.2
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/index.js +3 -3
- package/lib/Defaults/index.js.bak-1788476907801 +187 -0
- package/lib/Defaults/index.js.bak-1788479166288 +187 -0
- package/lib/Socket/groups.js.bak-1788476973954 +475 -0
- package/lib/Socket/index.js +33 -1
- package/lib/Socket/index.js.bak-1788479281092 +38 -0
- package/lib/Socket/messages-send.js +61 -7
- package/lib/Store/prototype-store.js +34 -22
- package/lib/Store/prototype-store.js.bak-1788477006895 +983 -0
- package/lib/Utils/index.js +2 -0
- package/lib/Utils/integrity-guard.js +281 -0
- package/lib/Utils/interactive-message-handler.js +28 -8
- package/lib/Utils/interactive-message-handler.js.bak-1788476898661 +478 -0
- package/lib/Utils/socket-guard.js +154 -0
- package/package.json +1 -1
package/lib/Defaults/index.js
CHANGED
|
@@ -95,7 +95,7 @@ export const DEFAULT_CONNECTION_CONFIG = {
|
|
|
95
95
|
},
|
|
96
96
|
makeSignalRepository: makeLibSignalRepository,
|
|
97
97
|
generateMessageID: () =>
|
|
98
|
-
"
|
|
98
|
+
"PROTO" + randomBytes(11).toString("hex").toUpperCase(),
|
|
99
99
|
generateMessageIDV2: (userId) => {
|
|
100
100
|
if (!userId) {
|
|
101
101
|
userId = randomBytes(32).toString("hex");
|
|
@@ -111,7 +111,7 @@ export const DEFAULT_CONNECTION_CONFIG = {
|
|
|
111
111
|
const randomIndex = randomBytes(1)[0] % combined.length;
|
|
112
112
|
result += combined[randomIndex];
|
|
113
113
|
}
|
|
114
|
-
return "
|
|
114
|
+
return "PROTO" + result;
|
|
115
115
|
},
|
|
116
116
|
};
|
|
117
117
|
|
|
@@ -184,4 +184,4 @@ export const TimeMs = {
|
|
|
184
184
|
Hour: 60 * 60 * 1000,
|
|
185
185
|
Day: 24 * 60 * 60 * 1000,
|
|
186
186
|
Week: 7 * 24 * 60 * 60 * 1000,
|
|
187
|
-
};
|
|
187
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { createHash, randomBytes } from "crypto";
|
|
2
|
+
import { proto } from "../../WAProto/index.js";
|
|
3
|
+
import { makeLibSignalRepository } from "../Signal/libsignal.js";
|
|
4
|
+
import { Browsers } from "../Utils/browser-utils.js";
|
|
5
|
+
import logger from "../Utils/logger.js";
|
|
6
|
+
const version = [2, 3000, 1035194821];
|
|
7
|
+
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
8
|
+
// === مضافة من مكتبة itsliaaa: لازمة لميزة Rich Response (Meta AI) ===
|
|
9
|
+
export const DONATE_URL = "https://whatsapp.com";
|
|
10
|
+
export const LIBRARY_NAME = "@prototypevip/baileys";
|
|
11
|
+
export const LEXER_REGEX =
|
|
12
|
+
/(\/\/.*|\/\*[\s\S]*?\*\/|#.*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`[\s\S]*?`)|(\b[a-zA-Z_]\w*\b)(?=\s*\()|(\b[a-zA-Z_]\w*\b)|(\b\d+(?:\.\d+)?\b)|(\s+|[^\w\s]+)/g;
|
|
13
|
+
export const BIZ_BOT_SUPPORT_PAYLOAD =
|
|
14
|
+
'{"version":1,"is_ai_message":true,"should_upload_client_logs":false,"should_show_system_message":false,"ticket_id":"7004947587700716","citation_items":[],"ticket_locale":"us"}';
|
|
15
|
+
export const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
16
|
+
export const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
|
|
17
|
+
export const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
|
|
18
|
+
export const DEF_CALLBACK_PREFIX = "CB:";
|
|
19
|
+
export const DEF_TAG_PREFIX = "TAG:";
|
|
20
|
+
export const PHONE_CONNECTION_CB = "CB:Pong";
|
|
21
|
+
export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
22
|
+
export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
23
|
+
export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
24
|
+
export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
25
|
+
export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
26
|
+
export const STATUS_EXPIRY_SECONDS = 24 * 60 * 60;
|
|
27
|
+
export const PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60;
|
|
28
|
+
export const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
29
|
+
export const DICT_VERSION = 3;
|
|
30
|
+
export const KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
31
|
+
export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]);
|
|
32
|
+
export const URL_REGEX =
|
|
33
|
+
/https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
34
|
+
export const WA_CERT_DETAILS = {
|
|
35
|
+
SERIAL: 0,
|
|
36
|
+
ISSUER: "WhatsAppLongTerm1",
|
|
37
|
+
PUBLIC_KEY: Buffer.from(
|
|
38
|
+
"142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b",
|
|
39
|
+
"hex",
|
|
40
|
+
),
|
|
41
|
+
};
|
|
42
|
+
export const PROCESSABLE_HISTORY_TYPES = [
|
|
43
|
+
proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
44
|
+
proto.HistorySync.HistorySyncType.PUSH_NAME,
|
|
45
|
+
proto.HistorySync.HistorySyncType.RECENT,
|
|
46
|
+
proto.HistorySync.HistorySyncType.FULL,
|
|
47
|
+
proto.HistorySync.HistorySyncType.ON_DEMAND,
|
|
48
|
+
proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
|
|
49
|
+
proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3,
|
|
50
|
+
];
|
|
51
|
+
export const DEFAULT_CACHE_TTLS = {
|
|
52
|
+
SIGNAL_STORE: 5 * 60,
|
|
53
|
+
MSG_RETRY: 60 * 60,
|
|
54
|
+
CALL_OFFER: 5 * 60,
|
|
55
|
+
USER_DEVICES: 5 * 60,
|
|
56
|
+
};
|
|
57
|
+
export const DEFAULT_CONNECTION_CONFIG = {
|
|
58
|
+
version: version,
|
|
59
|
+
browser: Browsers.macOS("Chrome"),
|
|
60
|
+
waWebSocketUrl: "wss://web.whatsapp.com/ws/chat",
|
|
61
|
+
connectTimeoutMs: 20000,
|
|
62
|
+
keepAliveIntervalMs: 30000,
|
|
63
|
+
logger: logger.child({ class: "baileys" }),
|
|
64
|
+
emitOwnEvents: true,
|
|
65
|
+
defaultQueryTimeoutMs: 60000,
|
|
66
|
+
customUploadHosts: [],
|
|
67
|
+
retryRequestDelayMs: 250,
|
|
68
|
+
maxMsgRetryCount: 5,
|
|
69
|
+
fireInitQueries: true,
|
|
70
|
+
auth: undefined,
|
|
71
|
+
markOnlineOnConnect: true,
|
|
72
|
+
syncFullHistory: true,
|
|
73
|
+
patchMessageBeforeSending: (msg) => msg,
|
|
74
|
+
shouldSyncHistoryMessage: ({ syncType }) => {
|
|
75
|
+
return syncType !== proto.HistorySync.HistorySyncType.FULL;
|
|
76
|
+
},
|
|
77
|
+
shouldIgnoreJid: () => false,
|
|
78
|
+
linkPreviewImageThumbnailWidth: 192,
|
|
79
|
+
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
80
|
+
generateHighQualityLinkPreview: false,
|
|
81
|
+
enableAutoSessionRecreation: true,
|
|
82
|
+
enableRecentMessageCache: true,
|
|
83
|
+
options: {},
|
|
84
|
+
appStateMacVerification: {
|
|
85
|
+
patch: false,
|
|
86
|
+
snapshot: false,
|
|
87
|
+
},
|
|
88
|
+
countryCode: "US",
|
|
89
|
+
getMessage: async function (key) {
|
|
90
|
+
const store = this?.store;
|
|
91
|
+
if (store) {
|
|
92
|
+
return this.loadMessage(key.id) || undefined;
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
},
|
|
96
|
+
makeSignalRepository: makeLibSignalRepository,
|
|
97
|
+
generateMessageID: () =>
|
|
98
|
+
"GIN4B0T" + randomBytes(11).toString("hex").toUpperCase(),
|
|
99
|
+
generateMessageIDV2: (userId) => {
|
|
100
|
+
if (!userId) {
|
|
101
|
+
userId = randomBytes(32).toString("hex");
|
|
102
|
+
}
|
|
103
|
+
const hash = createHash("sha256")
|
|
104
|
+
.update(userId)
|
|
105
|
+
.digest("hex")
|
|
106
|
+
.toUpperCase();
|
|
107
|
+
const randomPart = randomBytes(11).toString("hex").toUpperCase();
|
|
108
|
+
const combined = hash + randomPart;
|
|
109
|
+
let result = "";
|
|
110
|
+
for (let i = 0; i < 25; i++) {
|
|
111
|
+
const randomIndex = randomBytes(1)[0] % combined.length;
|
|
112
|
+
result += combined[randomIndex];
|
|
113
|
+
}
|
|
114
|
+
return "G1N4B0T" + result;
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Default getMessage implementation using an optional store.
|
|
120
|
+
* Professional fallback for library-level state management.
|
|
121
|
+
*/
|
|
122
|
+
export const getMessageFromStore = async (key, store) => {
|
|
123
|
+
if (!store) return undefined;
|
|
124
|
+
const chatId = key.remoteJid;
|
|
125
|
+
const msgKey = `${chatId}:${key.participant || "me"}:${key.id}`;
|
|
126
|
+
return store.chats[chatId]?.messages[msgKey]?.message || undefined;
|
|
127
|
+
};
|
|
128
|
+
export const MEDIA_PATH_MAP = {
|
|
129
|
+
image: "/mms/image",
|
|
130
|
+
video: "/mms/video",
|
|
131
|
+
document: "/mms/document",
|
|
132
|
+
audio: "/mms/audio",
|
|
133
|
+
sticker: "/mms/image",
|
|
134
|
+
"sticker-pack": "/mms/sticker-pack",
|
|
135
|
+
"thumbnail-sticker-pack": "/mms/thumbnail-sticker-pack",
|
|
136
|
+
"thumbnail-link": "/mms/thumbnail-link",
|
|
137
|
+
"product-catalog-image": "/product/image",
|
|
138
|
+
"md-app-state": "",
|
|
139
|
+
"md-msg-hist": "/mms/md-app-state",
|
|
140
|
+
"biz-cover-photo": "/pps/biz-cover-photo",
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const NEWSLETTER_MEDIA_PATH_MAP = {
|
|
144
|
+
image: "/newsletter/newsletter-image",
|
|
145
|
+
video: "/newsletter/newsletter-video",
|
|
146
|
+
document: "/newsletter/newsletter-document",
|
|
147
|
+
audio: "/newsletter/newsletter-audio",
|
|
148
|
+
sticker: "/newsletter/newsletter-image",
|
|
149
|
+
"thumbnail-link": "/newsletter/newsletter-thumbnail-link",
|
|
150
|
+
};
|
|
151
|
+
export const MEDIA_HKDF_KEY_MAPPING = {
|
|
152
|
+
audio: "Audio",
|
|
153
|
+
document: "Document",
|
|
154
|
+
gif: "Video",
|
|
155
|
+
image: "Image",
|
|
156
|
+
ppic: "",
|
|
157
|
+
product: "Image",
|
|
158
|
+
ptt: "Audio",
|
|
159
|
+
"sticker-pack": "Sticker Pack",
|
|
160
|
+
"thumbnail-sticker-pack": "Sticker Pack Thumbnail",
|
|
161
|
+
sticker: "Image",
|
|
162
|
+
video: "Video",
|
|
163
|
+
"thumbnail-document": "Document Thumbnail",
|
|
164
|
+
"thumbnail-image": "Image Thumbnail",
|
|
165
|
+
"thumbnail-video": "Video Thumbnail",
|
|
166
|
+
"thumbnail-link": "Link Thumbnail",
|
|
167
|
+
"md-msg-hist": "History",
|
|
168
|
+
"md-app-state": "App State",
|
|
169
|
+
"product-catalog-image": "",
|
|
170
|
+
"payment-bg-image": "Payment Background",
|
|
171
|
+
ptv: "Video",
|
|
172
|
+
"biz-cover-photo": "Image",
|
|
173
|
+
};
|
|
174
|
+
export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
|
|
175
|
+
export const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120000;
|
|
176
|
+
export const MIN_PREKEY_COUNT = 5;
|
|
177
|
+
export const INITIAL_PREKEY_COUNT = 812;
|
|
178
|
+
export const UPLOAD_TIMEOUT = 30000;
|
|
179
|
+
export const MIN_UPLOAD_INTERVAL = 5000;
|
|
180
|
+
export const INITIAL_PREKEY_COUNT_VAL = 30;
|
|
181
|
+
export const PROCESSABLE_HISTORY_TYPES_VAL = PROCESSABLE_HISTORY_TYPES;
|
|
182
|
+
export const TimeMs = {
|
|
183
|
+
Minute: 60 * 1000,
|
|
184
|
+
Hour: 60 * 60 * 1000,
|
|
185
|
+
Day: 24 * 60 * 60 * 1000,
|
|
186
|
+
Week: 7 * 24 * 60 * 60 * 1000,
|
|
187
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { createHash, randomBytes } from "crypto";
|
|
2
|
+
import { proto } from "../../WAProto/index.js";
|
|
3
|
+
import { makeLibSignalRepository } from "../Signal/libsignal.js";
|
|
4
|
+
import { Browsers } from "../Utils/browser-utils.js";
|
|
5
|
+
import logger from "../Utils/logger.js";
|
|
6
|
+
const version = [2, 3000, 1035194821];
|
|
7
|
+
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
8
|
+
// === مضافة من مكتبة itsliaaa: لازمة لميزة Rich Response (Meta AI) ===
|
|
9
|
+
export const DONATE_URL = "https://whatsapp.com";
|
|
10
|
+
export const LIBRARY_NAME = "@prototypevip/baileys";
|
|
11
|
+
export const LEXER_REGEX =
|
|
12
|
+
/(\/\/.*|\/\*[\s\S]*?\*\/|#.*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`[\s\S]*?`)|(\b[a-zA-Z_]\w*\b)(?=\s*\()|(\b[a-zA-Z_]\w*\b)|(\b\d+(?:\.\d+)?\b)|(\s+|[^\w\s]+)/g;
|
|
13
|
+
export const BIZ_BOT_SUPPORT_PAYLOAD =
|
|
14
|
+
'{"version":1,"is_ai_message":true,"should_upload_client_logs":false,"should_show_system_message":false,"ticket_id":"7004947587700716","citation_items":[],"ticket_locale":"us"}';
|
|
15
|
+
export const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
16
|
+
export const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
|
|
17
|
+
export const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
|
|
18
|
+
export const DEF_CALLBACK_PREFIX = "CB:";
|
|
19
|
+
export const DEF_TAG_PREFIX = "TAG:";
|
|
20
|
+
export const PHONE_CONNECTION_CB = "CB:Pong";
|
|
21
|
+
export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
22
|
+
export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
23
|
+
export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
24
|
+
export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
25
|
+
export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
26
|
+
export const STATUS_EXPIRY_SECONDS = 24 * 60 * 60;
|
|
27
|
+
export const PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60;
|
|
28
|
+
export const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
29
|
+
export const DICT_VERSION = 3;
|
|
30
|
+
export const KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
31
|
+
export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]);
|
|
32
|
+
export const URL_REGEX =
|
|
33
|
+
/https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
34
|
+
export const WA_CERT_DETAILS = {
|
|
35
|
+
SERIAL: 0,
|
|
36
|
+
ISSUER: "WhatsAppLongTerm1",
|
|
37
|
+
PUBLIC_KEY: Buffer.from(
|
|
38
|
+
"142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b",
|
|
39
|
+
"hex",
|
|
40
|
+
),
|
|
41
|
+
};
|
|
42
|
+
export const PROCESSABLE_HISTORY_TYPES = [
|
|
43
|
+
proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
44
|
+
proto.HistorySync.HistorySyncType.PUSH_NAME,
|
|
45
|
+
proto.HistorySync.HistorySyncType.RECENT,
|
|
46
|
+
proto.HistorySync.HistorySyncType.FULL,
|
|
47
|
+
proto.HistorySync.HistorySyncType.ON_DEMAND,
|
|
48
|
+
proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
|
|
49
|
+
proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3,
|
|
50
|
+
];
|
|
51
|
+
export const DEFAULT_CACHE_TTLS = {
|
|
52
|
+
SIGNAL_STORE: 5 * 60,
|
|
53
|
+
MSG_RETRY: 60 * 60,
|
|
54
|
+
CALL_OFFER: 5 * 60,
|
|
55
|
+
USER_DEVICES: 5 * 60,
|
|
56
|
+
};
|
|
57
|
+
export const DEFAULT_CONNECTION_CONFIG = {
|
|
58
|
+
version: version,
|
|
59
|
+
browser: Browsers.macOS("Chrome"),
|
|
60
|
+
waWebSocketUrl: "wss://web.whatsapp.com/ws/chat",
|
|
61
|
+
connectTimeoutMs: 20000,
|
|
62
|
+
keepAliveIntervalMs: 30000,
|
|
63
|
+
logger: logger.child({ class: "baileys" }),
|
|
64
|
+
emitOwnEvents: true,
|
|
65
|
+
defaultQueryTimeoutMs: 60000,
|
|
66
|
+
customUploadHosts: [],
|
|
67
|
+
retryRequestDelayMs: 250,
|
|
68
|
+
maxMsgRetryCount: 5,
|
|
69
|
+
fireInitQueries: true,
|
|
70
|
+
auth: undefined,
|
|
71
|
+
markOnlineOnConnect: true,
|
|
72
|
+
syncFullHistory: true,
|
|
73
|
+
patchMessageBeforeSending: (msg) => msg,
|
|
74
|
+
shouldSyncHistoryMessage: ({ syncType }) => {
|
|
75
|
+
return syncType !== proto.HistorySync.HistorySyncType.FULL;
|
|
76
|
+
},
|
|
77
|
+
shouldIgnoreJid: () => false,
|
|
78
|
+
linkPreviewImageThumbnailWidth: 192,
|
|
79
|
+
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
80
|
+
generateHighQualityLinkPreview: false,
|
|
81
|
+
enableAutoSessionRecreation: true,
|
|
82
|
+
enableRecentMessageCache: true,
|
|
83
|
+
options: {},
|
|
84
|
+
appStateMacVerification: {
|
|
85
|
+
patch: false,
|
|
86
|
+
snapshot: false,
|
|
87
|
+
},
|
|
88
|
+
countryCode: "US",
|
|
89
|
+
getMessage: async function (key) {
|
|
90
|
+
const store = this?.store;
|
|
91
|
+
if (store) {
|
|
92
|
+
return this.loadMessage(key.id) || undefined;
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
},
|
|
96
|
+
makeSignalRepository: makeLibSignalRepository,
|
|
97
|
+
generateMessageID: () =>
|
|
98
|
+
"PROTO" + randomBytes(11).toString("hex").toUpperCase(),
|
|
99
|
+
generateMessageIDV2: (userId) => {
|
|
100
|
+
if (!userId) {
|
|
101
|
+
userId = randomBytes(32).toString("hex");
|
|
102
|
+
}
|
|
103
|
+
const hash = createHash("sha256")
|
|
104
|
+
.update(userId)
|
|
105
|
+
.digest("hex")
|
|
106
|
+
.toUpperCase();
|
|
107
|
+
const randomPart = randomBytes(11).toString("hex").toUpperCase();
|
|
108
|
+
const combined = hash + randomPart;
|
|
109
|
+
let result = "";
|
|
110
|
+
for (let i = 0; i < 25; i++) {
|
|
111
|
+
const randomIndex = randomBytes(1)[0] % combined.length;
|
|
112
|
+
result += combined[randomIndex];
|
|
113
|
+
}
|
|
114
|
+
return "G1N4B0T" + result;
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Default getMessage implementation using an optional store.
|
|
120
|
+
* Professional fallback for library-level state management.
|
|
121
|
+
*/
|
|
122
|
+
export const getMessageFromStore = async (key, store) => {
|
|
123
|
+
if (!store) return undefined;
|
|
124
|
+
const chatId = key.remoteJid;
|
|
125
|
+
const msgKey = `${chatId}:${key.participant || "me"}:${key.id}`;
|
|
126
|
+
return store.chats[chatId]?.messages[msgKey]?.message || undefined;
|
|
127
|
+
};
|
|
128
|
+
export const MEDIA_PATH_MAP = {
|
|
129
|
+
image: "/mms/image",
|
|
130
|
+
video: "/mms/video",
|
|
131
|
+
document: "/mms/document",
|
|
132
|
+
audio: "/mms/audio",
|
|
133
|
+
sticker: "/mms/image",
|
|
134
|
+
"sticker-pack": "/mms/sticker-pack",
|
|
135
|
+
"thumbnail-sticker-pack": "/mms/thumbnail-sticker-pack",
|
|
136
|
+
"thumbnail-link": "/mms/thumbnail-link",
|
|
137
|
+
"product-catalog-image": "/product/image",
|
|
138
|
+
"md-app-state": "",
|
|
139
|
+
"md-msg-hist": "/mms/md-app-state",
|
|
140
|
+
"biz-cover-photo": "/pps/biz-cover-photo",
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const NEWSLETTER_MEDIA_PATH_MAP = {
|
|
144
|
+
image: "/newsletter/newsletter-image",
|
|
145
|
+
video: "/newsletter/newsletter-video",
|
|
146
|
+
document: "/newsletter/newsletter-document",
|
|
147
|
+
audio: "/newsletter/newsletter-audio",
|
|
148
|
+
sticker: "/newsletter/newsletter-image",
|
|
149
|
+
"thumbnail-link": "/newsletter/newsletter-thumbnail-link",
|
|
150
|
+
};
|
|
151
|
+
export const MEDIA_HKDF_KEY_MAPPING = {
|
|
152
|
+
audio: "Audio",
|
|
153
|
+
document: "Document",
|
|
154
|
+
gif: "Video",
|
|
155
|
+
image: "Image",
|
|
156
|
+
ppic: "",
|
|
157
|
+
product: "Image",
|
|
158
|
+
ptt: "Audio",
|
|
159
|
+
"sticker-pack": "Sticker Pack",
|
|
160
|
+
"thumbnail-sticker-pack": "Sticker Pack Thumbnail",
|
|
161
|
+
sticker: "Image",
|
|
162
|
+
video: "Video",
|
|
163
|
+
"thumbnail-document": "Document Thumbnail",
|
|
164
|
+
"thumbnail-image": "Image Thumbnail",
|
|
165
|
+
"thumbnail-video": "Video Thumbnail",
|
|
166
|
+
"thumbnail-link": "Link Thumbnail",
|
|
167
|
+
"md-msg-hist": "History",
|
|
168
|
+
"md-app-state": "App State",
|
|
169
|
+
"product-catalog-image": "",
|
|
170
|
+
"payment-bg-image": "Payment Background",
|
|
171
|
+
ptv: "Video",
|
|
172
|
+
"biz-cover-photo": "Image",
|
|
173
|
+
};
|
|
174
|
+
export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
|
|
175
|
+
export const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120000;
|
|
176
|
+
export const MIN_PREKEY_COUNT = 5;
|
|
177
|
+
export const INITIAL_PREKEY_COUNT = 812;
|
|
178
|
+
export const UPLOAD_TIMEOUT = 30000;
|
|
179
|
+
export const MIN_UPLOAD_INTERVAL = 5000;
|
|
180
|
+
export const INITIAL_PREKEY_COUNT_VAL = 30;
|
|
181
|
+
export const PROCESSABLE_HISTORY_TYPES_VAL = PROCESSABLE_HISTORY_TYPES;
|
|
182
|
+
export const TimeMs = {
|
|
183
|
+
Minute: 60 * 1000,
|
|
184
|
+
Hour: 60 * 60 * 1000,
|
|
185
|
+
Day: 24 * 60 * 60 * 1000,
|
|
186
|
+
Week: 7 * 24 * 60 * 60 * 1000,
|
|
187
|
+
};
|