astrabail 1.0.6

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.
Files changed (224) hide show
  1. package/WAProto/GenerateStatics.sh +3 -0
  2. package/WAProto/WAProto.proto +5479 -0
  3. package/WAProto/fix-imports.js +73 -0
  4. package/WAProto/index.d.ts +14017 -0
  5. package/WAProto/index.js +89351 -0
  6. package/WAProto/p.html +1 -0
  7. package/engine-requirements.js +7 -0
  8. package/lib/Defaults/astrabail-version.json +8 -0
  9. package/lib/Defaults/index.d.ts +74 -0
  10. package/lib/Defaults/index.js +166 -0
  11. package/lib/Defaults/phonenumber-mcc.json +223 -0
  12. package/lib/Defaults/update-wa-version.js +75 -0
  13. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  14. package/lib/Signal/Group/ciphertext-message.js +15 -0
  15. package/lib/Signal/Group/group-session-builder.d.ts +15 -0
  16. package/lib/Signal/Group/group-session-builder.js +66 -0
  17. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  18. package/lib/Signal/Group/group_cipher.js +85 -0
  19. package/lib/Signal/Group/index.d.ts +12 -0
  20. package/lib/Signal/Group/index.js +57 -0
  21. package/lib/Signal/Group/keyhelper.d.ts +11 -0
  22. package/lib/Signal/Group/keyhelper.js +55 -0
  23. package/lib/Signal/Group/queue-job.js +57 -0
  24. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  25. package/lib/Signal/Group/sender-chain-key.js +29 -0
  26. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  27. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  28. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  29. package/lib/Signal/Group/sender-key-message.js +69 -0
  30. package/lib/Signal/Group/sender-key-name.d.ts +18 -0
  31. package/lib/Signal/Group/sender-key-name.js +51 -0
  32. package/lib/Signal/Group/sender-key-record.d.ts +31 -0
  33. package/lib/Signal/Group/sender-key-record.js +44 -0
  34. package/lib/Signal/Group/sender-key-state.d.ts +39 -0
  35. package/lib/Signal/Group/sender-key-state.js +87 -0
  36. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  37. package/lib/Signal/Group/sender-message-key.js +29 -0
  38. package/lib/Signal/libsignal.d.ts +5 -0
  39. package/lib/Signal/libsignal.js +478 -0
  40. package/lib/Signal/lid-mapping.d.ts +19 -0
  41. package/lib/Signal/lid-mapping.js +274 -0
  42. package/lib/Socket/Client/index.d.ts +3 -0
  43. package/lib/Socket/Client/index.js +18 -0
  44. package/lib/Socket/Client/types.d.ts +16 -0
  45. package/lib/Socket/Client/types.js +14 -0
  46. package/lib/Socket/Client/websocket.d.ts +13 -0
  47. package/lib/Socket/Client/websocket.js +60 -0
  48. package/lib/Socket/business.d.ts +202 -0
  49. package/lib/Socket/business.js +382 -0
  50. package/lib/Socket/chats.d.ts +111 -0
  51. package/lib/Socket/chats.js +1155 -0
  52. package/lib/Socket/communities.d.ts +258 -0
  53. package/lib/Socket/communities.js +438 -0
  54. package/lib/Socket/community.js +333 -0
  55. package/lib/Socket/groups.d.ts +150 -0
  56. package/lib/Socket/groups.js +470 -0
  57. package/lib/Socket/index.d.ts +245 -0
  58. package/lib/Socket/index.js +13 -0
  59. package/lib/Socket/messages-recv.d.ts +187 -0
  60. package/lib/Socket/messages-recv.js +1708 -0
  61. package/lib/Socket/messages-send.d.ts +183 -0
  62. package/lib/Socket/messages-send.js +1692 -0
  63. package/lib/Socket/mex.d.ts +3 -0
  64. package/lib/Socket/mex.js +45 -0
  65. package/lib/Socket/newsletter.d.ts +160 -0
  66. package/lib/Socket/newsletter.js +293 -0
  67. package/lib/Socket/socket.d.ts +55 -0
  68. package/lib/Socket/socket.js +947 -0
  69. package/lib/Socket/usync.js +70 -0
  70. package/lib/Store/index.js +20 -0
  71. package/lib/Store/make-cache-manager-store.js +83 -0
  72. package/lib/Store/make-in-memory-store.js +398 -0
  73. package/lib/Store/make-ordered-dictionary.js +81 -0
  74. package/lib/Store/object-repository.js +27 -0
  75. package/lib/Types/Auth.d.ts +116 -0
  76. package/lib/Types/Auth.js +2 -0
  77. package/lib/Types/Bussines.d.ts +25 -0
  78. package/lib/Types/Bussines.js +2 -0
  79. package/lib/Types/Call.d.ts +15 -0
  80. package/lib/Types/Call.js +2 -0
  81. package/lib/Types/Chat.d.ts +123 -0
  82. package/lib/Types/Chat.js +10 -0
  83. package/lib/Types/Contact.d.ts +24 -0
  84. package/lib/Types/Contact.js +2 -0
  85. package/lib/Types/Events.d.ts +237 -0
  86. package/lib/Types/Events.js +3 -0
  87. package/lib/Types/GroupMetadata.d.ts +67 -0
  88. package/lib/Types/GroupMetadata.js +2 -0
  89. package/lib/Types/Label.d.ts +47 -0
  90. package/lib/Types/Label.js +25 -0
  91. package/lib/Types/LabelAssociation.d.ts +30 -0
  92. package/lib/Types/LabelAssociation.js +7 -0
  93. package/lib/Types/Message.d.ts +305 -0
  94. package/lib/Types/Message.js +11 -0
  95. package/lib/Types/MexUpdates.js +11 -0
  96. package/lib/Types/Newsletter.d.ts +135 -0
  97. package/lib/Types/Newsletter.js +43 -0
  98. package/lib/Types/Product.d.ts +79 -0
  99. package/lib/Types/Product.js +2 -0
  100. package/lib/Types/Signal.d.ts +76 -0
  101. package/lib/Types/Signal.js +3 -0
  102. package/lib/Types/Socket.d.ts +133 -0
  103. package/lib/Types/Socket.js +3 -0
  104. package/lib/Types/State.d.ts +39 -0
  105. package/lib/Types/State.js +14 -0
  106. package/lib/Types/USync.d.ts +26 -0
  107. package/lib/Types/USync.js +3 -0
  108. package/lib/Types/index.d.ts +65 -0
  109. package/lib/Types/index.js +42 -0
  110. package/lib/Utils/astrabail-event-stream.js +3 -0
  111. package/lib/Utils/audioToBuffer.js +31 -0
  112. package/lib/Utils/auth-utils.d.ts +19 -0
  113. package/lib/Utils/auth-utils.js +298 -0
  114. package/lib/Utils/baileys-event-stream.js +60 -0
  115. package/lib/Utils/bridge-runtime.d.ts +1 -0
  116. package/lib/Utils/bridge-runtime.js +14 -0
  117. package/lib/Utils/browser-utils.d.ts +4 -0
  118. package/lib/Utils/browser-utils.js +44 -0
  119. package/lib/Utils/business.d.ts +23 -0
  120. package/lib/Utils/business.js +240 -0
  121. package/lib/Utils/chat-utils.d.ts +70 -0
  122. package/lib/Utils/chat-utils.js +825 -0
  123. package/lib/Utils/crypto.d.ts +37 -0
  124. package/lib/Utils/crypto.js +168 -0
  125. package/lib/Utils/decode-wa-message.d.ts +48 -0
  126. package/lib/Utils/decode-wa-message.js +287 -0
  127. package/lib/Utils/event-buffer.d.ts +34 -0
  128. package/lib/Utils/event-buffer.js +580 -0
  129. package/lib/Utils/generics.d.ts +91 -0
  130. package/lib/Utils/generics.js +483 -0
  131. package/lib/Utils/history.d.ts +22 -0
  132. package/lib/Utils/history.js +137 -0
  133. package/lib/Utils/identity-change-handler.d.ts +37 -0
  134. package/lib/Utils/identity-change-handler.js +54 -0
  135. package/lib/Utils/index.d.ts +22 -0
  136. package/lib/Utils/index.js +48 -0
  137. package/lib/Utils/link-preview.d.ts +21 -0
  138. package/lib/Utils/link-preview.js +121 -0
  139. package/lib/Utils/logger.d.ts +13 -0
  140. package/lib/Utils/logger.js +7 -0
  141. package/lib/Utils/lt-hash.d.ts +8 -0
  142. package/lib/Utils/lt-hash.js +10 -0
  143. package/lib/Utils/make-mutex.d.ts +9 -0
  144. package/lib/Utils/make-mutex.js +37 -0
  145. package/lib/Utils/message-retry-manager.d.ts +110 -0
  146. package/lib/Utils/message-retry-manager.js +226 -0
  147. package/lib/Utils/messages-media.d.ts +130 -0
  148. package/lib/Utils/messages-media.js +887 -0
  149. package/lib/Utils/messages-newsletter.d.ts +84 -0
  150. package/lib/Utils/messages-newsletter.js +295 -0
  151. package/lib/Utils/messages.d.ts +92 -0
  152. package/lib/Utils/messages.js +1752 -0
  153. package/lib/Utils/noise-handler.d.ts +20 -0
  154. package/lib/Utils/noise-handler.js +204 -0
  155. package/lib/Utils/pre-key-manager.d.ts +28 -0
  156. package/lib/Utils/pre-key-manager.js +112 -0
  157. package/lib/Utils/process-message.d.ts +60 -0
  158. package/lib/Utils/process-message.js +536 -0
  159. package/lib/Utils/reporting-utils.d.ts +11 -0
  160. package/lib/Utils/reporting-utils.js +262 -0
  161. package/lib/Utils/resolve-jid.d.ts +43 -0
  162. package/lib/Utils/resolve-jid.js +95 -0
  163. package/lib/Utils/rust-bridge-shim.d.ts +22 -0
  164. package/lib/Utils/rust-bridge-shim.js +70 -0
  165. package/lib/Utils/serial-task-queue.js +29 -0
  166. package/lib/Utils/signal.d.ts +34 -0
  167. package/lib/Utils/signal.js +170 -0
  168. package/lib/Utils/streamToBuffer.js +17 -0
  169. package/lib/Utils/sync-action-utils.d.ts +19 -0
  170. package/lib/Utils/sync-action-utils.js +52 -0
  171. package/lib/Utils/tc-token-utils.d.ts +12 -0
  172. package/lib/Utils/tc-token-utils.js +20 -0
  173. package/lib/Utils/use-mongo-file-auth-state.js +71 -0
  174. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  175. package/lib/Utils/use-multi-file-auth-state.js +124 -0
  176. package/lib/Utils/use-single-file-auth-state.js +73 -0
  177. package/lib/Utils/validate-connection.d.ts +11 -0
  178. package/lib/Utils/validate-connection.js +206 -0
  179. package/lib/WABinary/constants.d.ts +28 -0
  180. package/lib/WABinary/constants.js +1303 -0
  181. package/lib/WABinary/decode.d.ts +7 -0
  182. package/lib/WABinary/decode.js +300 -0
  183. package/lib/WABinary/encode.d.ts +3 -0
  184. package/lib/WABinary/encode.js +256 -0
  185. package/lib/WABinary/generic-utils.d.ts +15 -0
  186. package/lib/WABinary/generic-utils.js +138 -0
  187. package/lib/WABinary/index.d.ts +6 -0
  188. package/lib/WABinary/index.js +25 -0
  189. package/lib/WABinary/jid-utils.d.ts +48 -0
  190. package/lib/WABinary/jid-utils.js +115 -0
  191. package/lib/WABinary/types.d.ts +19 -0
  192. package/lib/WABinary/types.js +36 -0
  193. package/lib/WAM/BinaryInfo.d.ts +9 -0
  194. package/lib/WAM/BinaryInfo.js +13 -0
  195. package/lib/WAM/constants.d.ts +40 -0
  196. package/lib/WAM/constants.js +22855 -0
  197. package/lib/WAM/encode.d.ts +3 -0
  198. package/lib/WAM/encode.js +153 -0
  199. package/lib/WAM/index.d.ts +4 -0
  200. package/lib/WAM/index.js +19 -0
  201. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
  202. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  203. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  204. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  205. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  206. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  207. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  208. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +41 -0
  209. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
  210. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +54 -0
  211. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
  212. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +32 -0
  213. package/lib/WAUSync/Protocols/index.d.ts +5 -0
  214. package/lib/WAUSync/Protocols/index.js +22 -0
  215. package/lib/WAUSync/USyncQuery.d.ts +29 -0
  216. package/lib/WAUSync/USyncQuery.js +97 -0
  217. package/lib/WAUSync/USyncUser.d.ts +13 -0
  218. package/lib/WAUSync/USyncUser.js +26 -0
  219. package/lib/WAUSync/index.d.ts +4 -0
  220. package/lib/WAUSync/index.js +19 -0
  221. package/lib/index.d.ts +12 -0
  222. package/lib/index.js +124 -0
  223. package/package.json +120 -0
  224. package/readme.md +1956 -0
package/WAProto/p.html ADDED
@@ -0,0 +1 @@
1
+ astrabail
@@ -0,0 +1,7 @@
1
+ const major = parseInt(process.versions.node.split('.')[0], 10);
2
+ if (major < 20) {
3
+ console.error(`\n❌ This package requires Node.js 20+ to run reliably.\n` +
4
+ ` You are using Node.js ${process.versions.node}.\n` +
5
+ ` Please upgrade to Node.js 20+ to proceed.\n`);
6
+ process.exit(1);
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": [
3
+ 2,
4
+ 3000,
5
+ 1037925115
6
+ ],
7
+ "raw": "2.3000.1037925115"
8
+ }
@@ -0,0 +1,74 @@
1
+ import { proto } from '../../WAProto/index.js';
2
+ import type { SocketConfig } from '../Types/index.js';
3
+ export declare const UNAUTHORIZED_CODES: number[];
4
+ export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
5
+ export declare const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
6
+ export declare const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
7
+ export declare const DEF_CALLBACK_PREFIX = "CB:";
8
+ export declare const DEF_TAG_PREFIX = "TAG:";
9
+ export declare const PHONE_CONNECTION_CB = "CB:Pong";
10
+ export declare const WA_ADV_ACCOUNT_SIG_PREFIX: Buffer<ArrayBuffer>;
11
+ export declare const WA_ADV_DEVICE_SIG_PREFIX: Buffer<ArrayBuffer>;
12
+ export declare const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: Buffer<ArrayBuffer>;
13
+ export declare const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: Buffer<ArrayBuffer>;
14
+ export declare const WA_DEFAULT_EPHEMERAL: number;
15
+ /** Status messages older than 24 hours are considered expired */
16
+ export declare const STATUS_EXPIRY_SECONDS: number;
17
+ /** WA Web enforces a 14-day maximum age for placeholder resend requests */
18
+ export declare const PLACEHOLDER_MAX_AGE_SECONDS: number;
19
+ export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
20
+ export declare const DICT_VERSION = 3;
21
+ export declare const KEY_BUNDLE_TYPE: Buffer<ArrayBuffer>;
22
+ export declare const NOISE_WA_HEADER: Buffer<ArrayBuffer>;
23
+ /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
24
+ export declare const URL_REGEX: RegExp;
25
+ export declare const WA_CERT_DETAILS: {
26
+ SERIAL: number;
27
+ ISSUER: string;
28
+ PUBLIC_KEY: Buffer<ArrayBuffer>;
29
+ };
30
+ export declare const PROCESSABLE_HISTORY_TYPES: proto.HistorySync.HistorySyncType[];
31
+ export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
32
+ export declare const MEDIA_PATH_MAP: {
33
+ [T in MediaType]?: string;
34
+ };
35
+ export declare const MEDIA_HKDF_KEY_MAPPING: {
36
+ audio: string;
37
+ document: string;
38
+ gif: string;
39
+ image: string;
40
+ ppic: string;
41
+ product: string;
42
+ ptt: string;
43
+ sticker: string;
44
+ video: string;
45
+ 'thumbnail-document': string;
46
+ 'thumbnail-image': string;
47
+ 'thumbnail-video': string;
48
+ 'thumbnail-link': string;
49
+ 'md-msg-hist': string;
50
+ 'md-app-state': string;
51
+ 'product-catalog-image': string;
52
+ 'payment-bg-image': string;
53
+ ptv: string;
54
+ 'biz-cover-photo': string;
55
+ };
56
+ export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
57
+ export declare const MEDIA_KEYS: MediaType[];
58
+ export declare const MIN_PREKEY_COUNT = 5;
59
+ export declare const INITIAL_PREKEY_COUNT = 812;
60
+ export declare const UPLOAD_TIMEOUT = 30000;
61
+ export declare const MIN_UPLOAD_INTERVAL = 5000;
62
+ export declare const DEFAULT_CACHE_TTLS: {
63
+ SIGNAL_STORE: number;
64
+ MSG_RETRY: number;
65
+ CALL_OFFER: number;
66
+ USER_DEVICES: number;
67
+ };
68
+ export declare const TimeMs: {
69
+ Minute: number;
70
+ Hour: number;
71
+ Day: number;
72
+ Week: number;
73
+ };
74
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,166 @@
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
+ exports.PHONENUMBER_MCC = exports.TimeMs = exports.DEFAULT_CACHE_TTLS = exports.MIN_UPLOAD_INTERVAL = exports.UPLOAD_TIMEOUT = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.PLACEHOLDER_MAX_AGE_SECONDS = exports.STATUS_EXPIRY_SECONDS = exports.WA_DEFAULT_EPHEMERAL = exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = exports.WA_ADV_DEVICE_SIG_PREFIX = exports.WA_ADV_ACCOUNT_SIG_PREFIX = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.CALL_AUDIO_PREFIX = exports.CALL_VIDEO_PREFIX = exports.DEFAULT_ORIGIN = exports.UNAUTHORIZED_CODES = exports.version = void 0;
7
+ const index_js_1 = require("../../WAProto/index.js");
8
+ const node_fs_1 = require("node:fs");
9
+ const phoneNumberMcc = JSON.parse((0, node_fs_1.readFileSync)(require('path').join(__dirname, 'phonenumber-mcc.json')));
10
+ const libsignal_js_1 = require("../Signal/libsignal.js");
11
+ const browser_utils_js_1 = require("../Utils/browser-utils.js");
12
+ const logger_js_1 = __importDefault(require("../Utils/logger.js"));
13
+ const waVer = require('./astrabail-version.json');
14
+ exports.version = waVer?.version || [2, 3000, 1037925115];
15
+ exports.UNAUTHORIZED_CODES = [401, 403, 419];
16
+ exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
17
+ exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
18
+ exports.CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
19
+ exports.DEF_CALLBACK_PREFIX = 'CB:';
20
+ exports.DEF_TAG_PREFIX = 'TAG:';
21
+ exports.PHONE_CONNECTION_CB = 'CB:Pong';
22
+ exports.WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
23
+ exports.WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
24
+ exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
25
+ exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
26
+ exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
27
+ /** Status messages older than 24 hours are considered expired */
28
+ exports.STATUS_EXPIRY_SECONDS = 24 * 60 * 60;
29
+ /** WA Web enforces a 14-day maximum age for placeholder resend requests */
30
+ exports.PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60;
31
+ exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
32
+ exports.DICT_VERSION = 3;
33
+ exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
34
+ exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]); // last is "DICT_VERSION"
35
+ /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
36
+ exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
37
+ exports.WA_CERT_DETAILS = {
38
+ SERIAL: 0,
39
+ ISSUER: 'WhatsAppLongTerm1',
40
+ PUBLIC_KEY: Buffer.from('142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b', 'hex')
41
+ };
42
+ exports.PROCESSABLE_HISTORY_TYPES = [
43
+ index_js_1.proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
44
+ index_js_1.proto.HistorySync.HistorySyncType.PUSH_NAME,
45
+ index_js_1.proto.HistorySync.HistorySyncType.RECENT,
46
+ index_js_1.proto.HistorySync.HistorySyncType.FULL,
47
+ index_js_1.proto.HistorySync.HistorySyncType.ON_DEMAND,
48
+ index_js_1.proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
49
+ index_js_1.proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3
50
+ ];
51
+ exports.DEFAULT_CONNECTION_CONFIG = {
52
+ version: exports.version,
53
+ browser: browser_utils_js_1.Browsers.macOS('Chrome'),
54
+ waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
55
+ connectTimeoutMs: 20000,
56
+ keepAliveIntervalMs: 30000,
57
+ logger: logger_js_1.default.child({ class: 'astrabail' }),
58
+ emitOwnEvents: true,
59
+ defaultQueryTimeoutMs: 60000,
60
+ customUploadHosts: [],
61
+ retryRequestDelayMs: 250,
62
+ maxMsgRetryCount: 5,
63
+ fireInitQueries: true,
64
+ auth: undefined,
65
+ markOnlineOnConnect: true,
66
+ syncFullHistory: true,
67
+ patchMessageBeforeSending: msg => {
68
+ const content = msg?.viewOnceMessage?.message || msg?.viewOnceMessageV2?.message || msg?.viewOnceMessageV2Extension?.message || msg;
69
+ const requiresPatch = !!(content?.buttonsMessage || content?.templateMessage || content?.listMessage || content?.interactiveMessage);
70
+ if (!requiresPatch)
71
+ return msg;
72
+ const wrapped = msg?.viewOnceMessage || msg?.viewOnceMessageV2 || msg?.viewOnceMessageV2Extension
73
+ ? msg
74
+ : {
75
+ viewOnceMessage: {
76
+ message: {
77
+ messageContextInfo: {
78
+ deviceListMetadataVersion: 2,
79
+ deviceListMetadata: {}
80
+ },
81
+ ...msg
82
+ }
83
+ }
84
+ };
85
+ const inner = wrapped?.viewOnceMessage?.message || wrapped?.viewOnceMessageV2?.message || wrapped?.viewOnceMessageV2Extension?.message;
86
+ if (inner) {
87
+ inner.messageContextInfo = {
88
+ deviceListMetadataVersion: 2,
89
+ deviceListMetadata: {},
90
+ ...(inner.messageContextInfo || {})
91
+ };
92
+ }
93
+ return wrapped;
94
+ },
95
+ shouldSyncHistoryMessage: ({ syncType }) => {
96
+ return syncType !== index_js_1.proto.HistorySync.HistorySyncType.FULL;
97
+ },
98
+ shouldIgnoreJid: () => false,
99
+ linkPreviewImageThumbnailWidth: 192,
100
+ transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
101
+ generateHighQualityLinkPreview: false,
102
+ enableAutoSessionRecreation: true,
103
+ enableRecentMessageCache: true,
104
+ options: {},
105
+ appStateMacVerification: {
106
+ patch: false,
107
+ snapshot: false
108
+ },
109
+ countryCode: 'US',
110
+ getMessage: async () => undefined,
111
+ cachedGroupMetadata: async () => undefined,
112
+ makeSignalRepository: libsignal_js_1.makeLibSignalRepository
113
+ };
114
+ exports.MEDIA_PATH_MAP = {
115
+ image: '/mms/image',
116
+ video: '/mms/video',
117
+ document: '/mms/document',
118
+ audio: '/mms/audio',
119
+ sticker: '/mms/image',
120
+ 'thumbnail-link': '/mms/image',
121
+ 'product-catalog-image': '/product/image',
122
+ 'md-app-state': '',
123
+ 'md-msg-hist': '/mms/md-app-state',
124
+ 'biz-cover-photo': '/pps/biz-cover-photo',
125
+ 'sticker-pack': '/mms/sticker'
126
+ };
127
+ exports.MEDIA_HKDF_KEY_MAPPING = {
128
+ audio: 'Audio',
129
+ document: 'Document',
130
+ gif: 'Video',
131
+ image: 'Image',
132
+ ppic: '',
133
+ product: 'Image',
134
+ ptt: 'Audio',
135
+ sticker: 'Image',
136
+ video: 'Video',
137
+ 'thumbnail-document': 'Document Thumbnail',
138
+ 'thumbnail-image': 'Image Thumbnail',
139
+ 'thumbnail-video': 'Video Thumbnail',
140
+ 'thumbnail-link': 'Link Thumbnail',
141
+ 'md-msg-hist': 'History',
142
+ 'md-app-state': 'App State',
143
+ 'product-catalog-image': '',
144
+ 'payment-bg-image': 'Payment Background',
145
+ ptv: 'Video',
146
+ 'biz-cover-photo': 'Image',
147
+ 'sticker-pack': 'Sticker Pack'
148
+ };
149
+ exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
150
+ exports.MIN_PREKEY_COUNT = 5;
151
+ exports.INITIAL_PREKEY_COUNT = 812;
152
+ exports.UPLOAD_TIMEOUT = 30000; // 30 seconds
153
+ exports.MIN_UPLOAD_INTERVAL = 5000; // 5 seconds minimum between uploads
154
+ exports.DEFAULT_CACHE_TTLS = {
155
+ SIGNAL_STORE: 5 * 60, // 5 minutes
156
+ MSG_RETRY: 60 * 60, // 1 hour
157
+ CALL_OFFER: 5 * 60, // 5 minutes
158
+ USER_DEVICES: 5 * 60 // 5 minutes
159
+ };
160
+ exports.TimeMs = {
161
+ Minute: 60 * 1000,
162
+ Hour: 60 * 60 * 1000,
163
+ Day: 24 * 60 * 60 * 1000,
164
+ Week: 7 * 24 * 60 * 60 * 1000
165
+ };
166
+ exports.PHONENUMBER_MCC = phoneNumberMcc;
@@ -0,0 +1,223 @@
1
+ {
2
+ "93": 412,
3
+ "355": 276,
4
+ "213": 603,
5
+ "1-684": 544,
6
+ "376": 213,
7
+ "244": 631,
8
+ "1-264": 365,
9
+ "1-268": 344,
10
+ "54": 722,
11
+ "374": 283,
12
+ "297": 363,
13
+ "61": 505,
14
+ "43": 232,
15
+ "994": 400,
16
+ "1-242": 364,
17
+ "973": 426,
18
+ "880": 470,
19
+ "1-246": 342,
20
+ "375": 257,
21
+ "32": 206,
22
+ "501": 702,
23
+ "229": 616,
24
+ "1-441": 350,
25
+ "975": 402,
26
+ "591": 736,
27
+ "387": 218,
28
+ "267": 652,
29
+ "55": 724,
30
+ "1-284": 348,
31
+ "673": 528,
32
+ "359": 284,
33
+ "226": 613,
34
+ "257": 642,
35
+ "855": 456,
36
+ "237": 624,
37
+ "238": 625,
38
+ "1-345": 346,
39
+ "236": 623,
40
+ "235": 622,
41
+ "56": 730,
42
+ "86": 454,
43
+ "57": 732,
44
+ "269": 654,
45
+ "682": 548,
46
+ "506": 712,
47
+ "385": 219,
48
+ "53": 368,
49
+ "357": 280,
50
+ "420": 230,
51
+ "243": 630,
52
+ "45": 238,
53
+ "253": 638,
54
+ "1-767": 366,
55
+ "1-809": 370,
56
+ "1-849": 370,
57
+ "1-829": 370,
58
+ "593": 740,
59
+ "20": 602,
60
+ "503": 706,
61
+ "240": 627,
62
+ "291": 657,
63
+ "372": 248,
64
+ "251": 636,
65
+ "500": 750,
66
+ "298": 288,
67
+ "679": 542,
68
+ "358": 244,
69
+ "33": 208,
70
+ "689": 547,
71
+ "241": 628,
72
+ "220": 607,
73
+ "995": 282,
74
+ "49": 262,
75
+ "233": 620,
76
+ "350": 266,
77
+ "30": 202,
78
+ "299": 290,
79
+ "1-473": 352,
80
+ "1-671": 535,
81
+ "502": 704,
82
+ "224": 537,
83
+ "592": 738,
84
+ "509": 372,
85
+ "504": 708,
86
+ "852": 454,
87
+ "36": 216,
88
+ "354": 274,
89
+ "91": 404,
90
+ "62": 510,
91
+ "98": 432,
92
+ "964": 418,
93
+ "353": 234,
94
+ "972": 425,
95
+ "39": 222,
96
+ "225": 612,
97
+ "1-876": 338,
98
+ "81": 440,
99
+ "962": 416,
100
+ "254": 639,
101
+ "686": 545,
102
+ "383": 221,
103
+ "965": 419,
104
+ "371": 247,
105
+ "961": 415,
106
+ "266": 651,
107
+ "231": 618,
108
+ "218": 606,
109
+ "423": 295,
110
+ "370": 246,
111
+ "352": 270,
112
+ "389": 294,
113
+ "261": 646,
114
+ "265": 650,
115
+ "60": 502,
116
+ "960": 472,
117
+ "223": 610,
118
+ "356": 278,
119
+ "692": 551,
120
+ "222": 609,
121
+ "230": 617,
122
+ "52": 334,
123
+ "691": 550,
124
+ "373": 259,
125
+ "377": 212,
126
+ "976": 428,
127
+ "382": 297,
128
+ "1-664": 354,
129
+ "212": 604,
130
+ "258": 643,
131
+ "95": 414,
132
+ "264": 649,
133
+ "674": 536,
134
+ "977": 429,
135
+ "31": 204,
136
+ "687": 546,
137
+ "64": 530,
138
+ "505": 710,
139
+ "227": 614,
140
+ "234": 621,
141
+ "683": 555,
142
+ "1-670": 534,
143
+ "47": 242,
144
+ "968": 226,
145
+ "92": 410,
146
+ "680": 552,
147
+ "970": 423,
148
+ "507": 714,
149
+ "675": 537,
150
+ "595": 744,
151
+ "51": 716,
152
+ "63": 515,
153
+ "48": 260,
154
+ "351": 268,
155
+ "1-787, 1-939": 330,
156
+ "974": 427,
157
+ "242": 630,
158
+ "40": 226,
159
+ "7": 250,
160
+ "250": 635,
161
+ "290": 658,
162
+ "1-869": 356,
163
+ "1-758": 358,
164
+ "508": 308,
165
+ "1-784": 360,
166
+ "685": 544,
167
+ "378": 292,
168
+ "239": 626,
169
+ "966": 420,
170
+ "221": 608,
171
+ "381": 220,
172
+ "248": 633,
173
+ "232": 619,
174
+ "65": 525,
175
+ "386": 293,
176
+ "677": 540,
177
+ "27": 655,
178
+ "211": 659,
179
+ "34": 214,
180
+ "94": 413,
181
+ "249": 634,
182
+ "597": 746,
183
+ "268": 653,
184
+ "46": 240,
185
+ "41": 228,
186
+ "963": 417,
187
+ "886": 466,
188
+ "992": 436,
189
+ "255": 640,
190
+ "66": 520,
191
+ "228": 615,
192
+ "690": 554,
193
+ "676": 539,
194
+ "1-868": 374,
195
+ "216": 605,
196
+ "90": 286,
197
+ "993": 438,
198
+ "1-649": 376,
199
+ "688": 553,
200
+ "1-340": 332,
201
+ "256": 641,
202
+ "380": 255,
203
+ "971": 424,
204
+ "44": 234,
205
+ "1": 310,
206
+ "598": 748,
207
+ "998": 434,
208
+ "678": 541,
209
+ "379": 225,
210
+ "58": 734,
211
+ "681": 543,
212
+ "967": 421,
213
+ "260": 645,
214
+ "263": 648,
215
+ "670": 514,
216
+ "245": 632,
217
+ "856": 457,
218
+ "599": 362,
219
+ "850": 467,
220
+ "262": 647,
221
+ "82": 450,
222
+ "84": 452
223
+ }
@@ -0,0 +1,75 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+
4
+ const URL = 'https://wppconnect.io/whatsapp-versions/'
5
+
6
+ async function main() {
7
+ try {
8
+ const res = await fetch(URL, {
9
+ headers: {
10
+ 'user-agent': 'Mozilla/5.0'
11
+ }
12
+ })
13
+
14
+ if (!res.ok) {
15
+ throw new Error(`HTTP ${res.status} ${res.statusText}`)
16
+ }
17
+
18
+ const html = await res.text()
19
+
20
+ const match = html.match(/Current Version[\s\S]{0,1200}?\b(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?)\b/i)
21
+
22
+ if (!match) {
23
+ console.log('Skip update WA Web version: versi tidak ditemukan')
24
+ process.exit(0)
25
+ }
26
+
27
+ const rawWithSuffix = match[1].trim()
28
+
29
+ // buang suffix seperti -alpha, -beta, dll
30
+ const cleanRaw = rawWithSuffix.split('-')[0].trim()
31
+
32
+ const version = cleanRaw.split('.').map(Number)
33
+
34
+ if (version.length !== 3 || version.some(Number.isNaN)) {
35
+ throw new Error(`Format versi tidak valid: ${cleanRaw}`)
36
+ }
37
+
38
+ // 1) update astrabail-version.json
39
+ const jsonPath = path.join(__dirname, 'astrabail-version.json')
40
+ const jsonData = {
41
+ version,
42
+ raw: cleanRaw
43
+ }
44
+ fs.writeFileSync(jsonPath, JSON.stringify(jsonData, null, 2) + '\n', 'utf8')
45
+
46
+ // 2) update lib/Defaults/index.js
47
+ const indexPath = path.join(__dirname, 'index.js')
48
+ let indexContent = fs.readFileSync(indexPath, 'utf8')
49
+
50
+ const newVersionArray = `[${version.join(', ')}]`
51
+
52
+ const pattern = /exports\.version\s*=\s*waVer\?\.version\s*\|\|\s*\[[^\]]+\];?/
53
+
54
+ if (!pattern.test(indexContent)) {
55
+ throw new Error('Baris exports.version tidak ditemukan di lib/Defaults/index.js')
56
+ }
57
+
58
+ indexContent = indexContent.replace(
59
+ pattern,
60
+ `exports.version = waVer?.version || ${newVersionArray};`
61
+ )
62
+
63
+ fs.writeFileSync(indexPath, indexContent, 'utf8')
64
+
65
+ console.log('WA version updated:', {
66
+ version,
67
+ raw: cleanRaw
68
+ })
69
+ } catch (err) {
70
+ console.error('Gagal update WA version:', err.message)
71
+ process.exit(1)
72
+ }
73
+ }
74
+
75
+ main()
@@ -0,0 +1,10 @@
1
+ export declare class CiphertextMessage {
2
+ readonly UNSUPPORTED_VERSION: number;
3
+ readonly CURRENT_VERSION: number;
4
+ readonly WHISPER_TYPE: number;
5
+ readonly PREKEY_TYPE: number;
6
+ readonly SENDERKEY_TYPE: number;
7
+ readonly SENDERKEY_DISTRIBUTION_TYPE: number;
8
+ readonly ENCRYPTED_MESSAGE_OVERHEAD: number;
9
+ }
10
+ //# sourceMappingURL=ciphertext-message.d.ts.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CiphertextMessage = void 0;
4
+ class CiphertextMessage {
5
+ constructor() {
6
+ this.UNSUPPORTED_VERSION = 1;
7
+ this.CURRENT_VERSION = 3;
8
+ this.WHISPER_TYPE = 2;
9
+ this.PREKEY_TYPE = 3;
10
+ this.SENDERKEY_TYPE = 4;
11
+ this.SENDERKEY_DISTRIBUTION_TYPE = 5;
12
+ this.ENCRYPTED_MESSAGE_OVERHEAD = 53;
13
+ }
14
+ }
15
+ exports.CiphertextMessage = CiphertextMessage;
@@ -0,0 +1,15 @@
1
+ import { SenderKeyDistributionMessage } from './sender-key-distribution-message.js';
2
+ import { SenderKeyName } from './sender-key-name.js';
3
+ import { SenderKeyRecord } from './sender-key-record.js';
4
+ interface SenderKeyStore {
5
+ loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
6
+ storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
7
+ }
8
+ export declare class GroupSessionBuilder {
9
+ private readonly senderKeyStore;
10
+ constructor(senderKeyStore: SenderKeyStore);
11
+ process(senderKeyName: SenderKeyName, senderKeyDistributionMessage: SenderKeyDistributionMessage): Promise<void>;
12
+ create(senderKeyName: SenderKeyName): Promise<SenderKeyDistributionMessage>;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=group-session-builder.d.ts.map
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.GroupSessionBuilder = void 0;
37
+ const keyhelper = __importStar(require("./keyhelper.js"));
38
+ const sender_key_distribution_message_js_1 = require("./sender-key-distribution-message.js");
39
+ const sender_key_name_js_1 = require("./sender-key-name.js");
40
+ const sender_key_record_js_1 = require("./sender-key-record.js");
41
+ class GroupSessionBuilder {
42
+ constructor(senderKeyStore) {
43
+ this.senderKeyStore = senderKeyStore;
44
+ }
45
+ async process(senderKeyName, senderKeyDistributionMessage) {
46
+ const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName);
47
+ senderKeyRecord.addSenderKeyState(senderKeyDistributionMessage.getId(), senderKeyDistributionMessage.getIteration(), senderKeyDistributionMessage.getChainKey(), senderKeyDistributionMessage.getSignatureKey());
48
+ await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
49
+ }
50
+ async create(senderKeyName) {
51
+ const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName);
52
+ if (senderKeyRecord.isEmpty()) {
53
+ const keyId = keyhelper.generateSenderKeyId();
54
+ const senderKey = keyhelper.generateSenderKey();
55
+ const signingKey = keyhelper.generateSenderSigningKey();
56
+ senderKeyRecord.setSenderKeyState(keyId, 0, senderKey, signingKey);
57
+ await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
58
+ }
59
+ const state = senderKeyRecord.getSenderKeyState();
60
+ if (!state) {
61
+ throw new Error('No session state available');
62
+ }
63
+ return new sender_key_distribution_message_js_1.SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic());
64
+ }
65
+ }
66
+ exports.GroupSessionBuilder = GroupSessionBuilder;
@@ -0,0 +1,17 @@
1
+ import { SenderKeyName } from './sender-key-name.js';
2
+ import { SenderKeyRecord } from './sender-key-record.js';
3
+ export interface SenderKeyStore {
4
+ loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
5
+ storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
6
+ }
7
+ export declare class GroupCipher {
8
+ private readonly senderKeyStore;
9
+ private readonly senderKeyName;
10
+ constructor(senderKeyStore: SenderKeyStore, senderKeyName: SenderKeyName);
11
+ encrypt(paddedPlaintext: Uint8Array): Promise<Uint8Array>;
12
+ decrypt(senderKeyMessageBytes: Uint8Array): Promise<Uint8Array>;
13
+ private getSenderKey;
14
+ private getPlainText;
15
+ private getCipherText;
16
+ }
17
+ //# sourceMappingURL=group_cipher.d.ts.map