@zelynskybail/baileys 0.0.0-stage → 2.6.28
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/BUILD_STATUS.md +21 -0
- package/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/NOTICE.md +9 -0
- package/README.md +165 -2
- package/THANKS.md +7 -0
- package/THIRD_PARTY_NOTICES.md +8 -0
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +6035 -0
- package/WAProto/fix-imports.js +81 -0
- package/WAProto/index.d.ts +2 -0
- package/WAProto/index.js +132326 -0
- package/lib/Builders/advanced.d.ts +14 -0
- package/lib/Builders/advanced.js +142 -0
- package/lib/Builders/group-status.d.ts +9 -0
- package/lib/Builders/group-status.js +19 -0
- package/lib/Builders/index.d.ts +62 -0
- package/lib/Builders/index.js +242 -0
- package/lib/Defaults/index.d.ts +74 -0
- package/lib/Defaults/index.js +136 -0
- package/lib/Modded/MessageBuilder.js +3222 -0
- package/lib/Modded/message_builder.d.ts +43 -0
- package/lib/Modded/message_builder.js +2 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +81 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.js +17 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.js +25 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.js +65 -0
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.js +83 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.js +25 -0
- package/lib/Signal/libsignal.d.ts +5 -0
- package/lib/Signal/libsignal.js +402 -0
- package/lib/Signal/lid-mapping.d.ts +19 -0
- package/lib/Signal/lid-mapping.js +270 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.d.ts +536 -0
- package/lib/Socket/business.js +421 -0
- package/lib/Socket/chats.d.ts +111 -0
- package/lib/Socket/chats.js +990 -0
- package/lib/Socket/communities.d.ts +645 -0
- package/lib/Socket/communities.js +430 -0
- package/lib/Socket/dugong.d.ts +130 -0
- package/lib/Socket/dugong.js +767 -0
- package/lib/Socket/groups.d.ts +150 -0
- package/lib/Socket/groups.js +326 -0
- package/lib/Socket/index.d.ts +657 -0
- package/lib/Socket/index.js +26 -0
- package/lib/Socket/messages-recv.d.ts +238 -0
- package/lib/Socket/messages-recv.js +1307 -0
- package/lib/Socket/messages-send.d.ts +579 -0
- package/lib/Socket/messages-send.js +1594 -0
- package/lib/Socket/mex.d.ts +3 -0
- package/lib/Socket/mex.js +47 -0
- package/lib/Socket/newsletter.d.ts +177 -0
- package/lib/Socket/newsletter.js +314 -0
- package/lib/Socket/socket.d.ts +55 -0
- package/lib/Socket/socket.js +935 -0
- package/lib/Types/Auth.d.ts +116 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.d.ts +37 -0
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +123 -0
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Contact.d.ts +24 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +237 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +68 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +47 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.d.ts +30 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.d.ts +422 -0
- package/lib/Types/Message.js +10 -0
- package/lib/Types/Newsletter.d.ts +135 -0
- package/lib/Types/Newsletter.js +30 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/Signal.d.ts +76 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +154 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.d.ts +39 -0
- package/lib/Types/State.js +12 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Types/index.js +32 -0
- package/lib/Utils/auth-utils.d.ts +19 -0
- package/lib/Utils/auth-utils.js +289 -0
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.js +27 -0
- package/lib/Utils/business.d.ts +23 -0
- package/lib/Utils/business.js +230 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/chat-utils.js +811 -0
- package/lib/Utils/crypto.d.ts +37 -0
- package/lib/Utils/crypto.js +117 -0
- package/lib/Utils/decode-wa-message.d.ts +48 -0
- package/lib/Utils/decode-wa-message.js +282 -0
- package/lib/Utils/event-buffer.d.ts +34 -0
- package/lib/Utils/event-buffer.js +573 -0
- package/lib/Utils/generics.d.ts +91 -0
- package/lib/Utils/generics.js +383 -0
- package/lib/Utils/history.d.ts +22 -0
- package/lib/Utils/history.js +130 -0
- package/lib/Utils/identity-change-handler.d.ts +37 -0
- package/lib/Utils/identity-change-handler.js +48 -0
- package/lib/Utils/index.d.ts +24 -0
- package/lib/Utils/index.js +24 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +84 -0
- package/lib/Utils/logger.d.ts +13 -0
- package/lib/Utils/logger.js +2 -0
- package/lib/Utils/lt-hash.d.ts +8 -0
- package/lib/Utils/lt-hash.js +7 -0
- package/lib/Utils/make-mutex.d.ts +9 -0
- package/lib/Utils/make-mutex.js +32 -0
- package/lib/Utils/message-retry-manager.d.ts +110 -0
- package/lib/Utils/message-retry-manager.js +224 -0
- package/lib/Utils/message-tools.d.ts +31 -0
- package/lib/Utils/message-tools.js +182 -0
- package/lib/Utils/messages-media.d.ts +130 -0
- package/lib/Utils/messages-media.js +781 -0
- package/lib/Utils/messages.d.ts +91 -0
- package/lib/Utils/messages.js +1239 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +200 -0
- package/lib/Utils/offline-node-processor.d.ts +17 -0
- package/lib/Utils/offline-node-processor.js +68 -0
- package/lib/Utils/performance.d.ts +3 -0
- package/lib/Utils/performance.js +35 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.d.ts +60 -0
- package/lib/Utils/process-message.js +527 -0
- package/lib/Utils/reporting-utils.d.ts +11 -0
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/rich-messages.d.ts +277 -0
- package/lib/Utils/rich-messages.js +1143 -0
- package/lib/Utils/signal.d.ts +34 -0
- package/lib/Utils/signal.js +158 -0
- package/lib/Utils/stanza-ack.d.ts +11 -0
- package/lib/Utils/stanza-ack.js +37 -0
- package/lib/Utils/sticker-pack.d.ts +10 -0
- package/lib/Utils/sticker-pack.js +111 -0
- package/lib/Utils/sync-action-utils.d.ts +19 -0
- package/lib/Utils/sync-action-utils.js +47 -0
- package/lib/Utils/tc-token-utils.d.ts +12 -0
- package/lib/Utils/tc-token-utils.js +17 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.js +120 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +199 -0
- package/lib/VoIP/index.d.ts +18 -0
- package/lib/VoIP/index.js +81 -0
- package/lib/WABinary/constants.d.ts +28 -0
- package/lib/WABinary/constants.js +1300 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.js +261 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +219 -0
- package/lib/WABinary/generic-utils.d.ts +17 -0
- package/lib/WABinary/generic-utils.js +190 -0
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.d.ts +48 -0
- package/lib/WABinary/jid-utils.js +95 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +9 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.d.ts +40 -0
- package/lib/WAM/constants.js +22852 -0
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -0
- package/lib/WAUSync/Protocols/index.js +4 -0
- package/lib/WAUSync/USyncQuery.d.ts +29 -0
- package/lib/WAUSync/USyncQuery.js +93 -0
- package/lib/WAUSync/USyncUser.d.ts +13 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.js +14 -0
- package/package.json +128 -4
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { proto } from "../../WAProto/index.js";
|
|
2
|
+
import { makeLibSignalRepository } from "../Signal/libsignal.js";
|
|
3
|
+
import { Browsers } from "../Utils/browser-utils.js";
|
|
4
|
+
import logger from "../Utils/logger.js";
|
|
5
|
+
const version = [2, 3000, 1035194821];
|
|
6
|
+
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
7
|
+
export const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
8
|
+
export const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
|
|
9
|
+
export const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
|
|
10
|
+
export const DEF_CALLBACK_PREFIX = "CB:";
|
|
11
|
+
export const DEF_TAG_PREFIX = "TAG:";
|
|
12
|
+
export const PHONE_CONNECTION_CB = "CB:Pong";
|
|
13
|
+
export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
14
|
+
export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
15
|
+
export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
16
|
+
export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
17
|
+
export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
18
|
+
/** Status messages older than 24 hours are considered expired */
|
|
19
|
+
export const STATUS_EXPIRY_SECONDS = 24 * 60 * 60;
|
|
20
|
+
/** WA Web enforces a 14-day maximum age for placeholder resend requests */
|
|
21
|
+
export const PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60;
|
|
22
|
+
export const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
23
|
+
export const DICT_VERSION = 3;
|
|
24
|
+
export const KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
25
|
+
export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]); // last is "DICT_VERSION"
|
|
26
|
+
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
27
|
+
export const URL_REGEX =
|
|
28
|
+
/https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
29
|
+
export const WA_CERT_DETAILS = {
|
|
30
|
+
SERIAL: 0,
|
|
31
|
+
ISSUER: "WhatsAppLongTerm1",
|
|
32
|
+
PUBLIC_KEY: Buffer.from(
|
|
33
|
+
"142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b",
|
|
34
|
+
"hex",
|
|
35
|
+
),
|
|
36
|
+
};
|
|
37
|
+
export const PROCESSABLE_HISTORY_TYPES = [
|
|
38
|
+
proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
39
|
+
proto.HistorySync.HistorySyncType.PUSH_NAME,
|
|
40
|
+
proto.HistorySync.HistorySyncType.RECENT,
|
|
41
|
+
proto.HistorySync.HistorySyncType.FULL,
|
|
42
|
+
proto.HistorySync.HistorySyncType.ON_DEMAND,
|
|
43
|
+
proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
|
|
44
|
+
proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3,
|
|
45
|
+
];
|
|
46
|
+
export const DEFAULT_CONNECTION_CONFIG = {
|
|
47
|
+
version: version,
|
|
48
|
+
browser: Browsers.macOS("Chrome"),
|
|
49
|
+
waWebSocketUrl: "wss://web.whatsapp.com/ws/chat",
|
|
50
|
+
connectTimeoutMs: 20000,
|
|
51
|
+
keepAliveIntervalMs: 30000,
|
|
52
|
+
logger: logger.child({ class: "baileys" }),
|
|
53
|
+
emitOwnEvents: true,
|
|
54
|
+
defaultQueryTimeoutMs: 60000,
|
|
55
|
+
customUploadHosts: [],
|
|
56
|
+
retryRequestDelayMs: 250,
|
|
57
|
+
maxMsgRetryCount: 5,
|
|
58
|
+
fireInitQueries: true,
|
|
59
|
+
auth: undefined,
|
|
60
|
+
markOnlineOnConnect: true,
|
|
61
|
+
syncFullHistory: true,
|
|
62
|
+
patchMessageBeforeSending: (msg) => msg,
|
|
63
|
+
shouldSyncHistoryMessage: ({ syncType }) => {
|
|
64
|
+
return syncType !== proto.HistorySync.HistorySyncType.FULL;
|
|
65
|
+
},
|
|
66
|
+
shouldIgnoreJid: () => false,
|
|
67
|
+
linkPreviewImageThumbnailWidth: 192,
|
|
68
|
+
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
69
|
+
generateHighQualityLinkPreview: false,
|
|
70
|
+
enableAutoSessionRecreation: true,
|
|
71
|
+
enableRecentMessageCache: true,
|
|
72
|
+
options: {},
|
|
73
|
+
appStateMacVerification: {
|
|
74
|
+
patch: false,
|
|
75
|
+
snapshot: false,
|
|
76
|
+
},
|
|
77
|
+
countryCode: "US",
|
|
78
|
+
getMessage: async () => undefined,
|
|
79
|
+
cachedGroupMetadata: async () => undefined,
|
|
80
|
+
makeSignalRepository: makeLibSignalRepository,
|
|
81
|
+
};
|
|
82
|
+
export const MEDIA_PATH_MAP = {
|
|
83
|
+
image: "/mms/image",
|
|
84
|
+
video: "/mms/video",
|
|
85
|
+
document: "/mms/document",
|
|
86
|
+
audio: "/mms/audio",
|
|
87
|
+
sticker: "/mms/image",
|
|
88
|
+
"thumbnail-link": "/mms/image",
|
|
89
|
+
"product-catalog-image": "/product/image",
|
|
90
|
+
"md-app-state": "",
|
|
91
|
+
"md-msg-hist": "/mms/md-app-state",
|
|
92
|
+
"biz-cover-photo": "/pps/biz-cover-photo",
|
|
93
|
+
"sticker-pack": "/mms/document",
|
|
94
|
+
"thumbnail-image": "/mms/document",
|
|
95
|
+
"thumbnail-sticker-pack": "/mms/document",
|
|
96
|
+
};
|
|
97
|
+
export const MEDIA_HKDF_KEY_MAPPING = {
|
|
98
|
+
audio: "Audio",
|
|
99
|
+
document: "Document",
|
|
100
|
+
gif: "Video",
|
|
101
|
+
image: "Image",
|
|
102
|
+
ppic: "",
|
|
103
|
+
product: "Image",
|
|
104
|
+
ptt: "Audio",
|
|
105
|
+
sticker: "Image",
|
|
106
|
+
video: "Video",
|
|
107
|
+
"thumbnail-document": "Document Thumbnail",
|
|
108
|
+
"thumbnail-image": "Image Thumbnail",
|
|
109
|
+
"thumbnail-video": "Video Thumbnail",
|
|
110
|
+
"thumbnail-link": "Link Thumbnail",
|
|
111
|
+
"thumbnail-sticker-pack": "Image Thumbnail",
|
|
112
|
+
"md-msg-hist": "History",
|
|
113
|
+
"md-app-state": "App State",
|
|
114
|
+
"product-catalog-image": "",
|
|
115
|
+
"payment-bg-image": "Payment Background",
|
|
116
|
+
ptv: "Video",
|
|
117
|
+
"biz-cover-photo": "Image",
|
|
118
|
+
"sticker-pack": "Sticker Pack",
|
|
119
|
+
};
|
|
120
|
+
export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
|
|
121
|
+
export const MIN_PREKEY_COUNT = 5;
|
|
122
|
+
export const INITIAL_PREKEY_COUNT = 812;
|
|
123
|
+
export const UPLOAD_TIMEOUT = 30000; // 30 seconds
|
|
124
|
+
export const MIN_UPLOAD_INTERVAL = 5000; // 5 seconds minimum between uploads
|
|
125
|
+
export const DEFAULT_CACHE_TTLS = {
|
|
126
|
+
SIGNAL_STORE: 5 * 60, // 5 minutes
|
|
127
|
+
MSG_RETRY: 60 * 60, // 1 hour
|
|
128
|
+
CALL_OFFER: 5 * 60, // 5 minutes
|
|
129
|
+
USER_DEVICES: 5 * 60, // 5 minutes
|
|
130
|
+
};
|
|
131
|
+
export const TimeMs = {
|
|
132
|
+
Minute: 60 * 1000,
|
|
133
|
+
Hour: 60 * 60 * 1000,
|
|
134
|
+
Day: 24 * 60 * 60 * 1000,
|
|
135
|
+
Week: 7 * 24 * 60 * 60 * 1000,
|
|
136
|
+
};
|