jagproject 26.3.23 → 26.3.26

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 (209) hide show
  1. package/WAProto/GenerateStatics.sh +3 -4
  2. package/WAProto/WAProto.proto +1215 -511
  3. package/WAProto/fix-imports.js +73 -0
  4. package/WAProto/index.d.ts +14017 -0
  5. package/WAProto/index.js +64857 -145167
  6. package/engine-requirements.js +4 -7
  7. package/lib/Defaults/index.d.ts +74 -0
  8. package/lib/Defaults/index.js +49 -35
  9. package/lib/Defaults/phonenumber-mcc.json +223 -0
  10. package/lib/Defaults/wileys-version.json +2 -2
  11. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  12. package/lib/Signal/Group/group-session-builder.d.ts +15 -0
  13. package/lib/Signal/Group/group-session-builder.js +5 -3
  14. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  15. package/lib/Signal/Group/group_cipher.js +35 -46
  16. package/lib/Signal/Group/index.d.ts +12 -0
  17. package/lib/Signal/Group/index.js +21 -21
  18. package/lib/Signal/Group/keyhelper.d.ts +11 -0
  19. package/lib/Signal/Group/keyhelper.js +2 -2
  20. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  21. package/lib/Signal/Group/sender-chain-key.js +5 -10
  22. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  23. package/lib/Signal/Group/sender-key-distribution-message.js +7 -7
  24. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  25. package/lib/Signal/Group/sender-key-message.js +8 -8
  26. package/lib/Signal/Group/sender-key-name.d.ts +18 -0
  27. package/lib/Signal/Group/sender-key-record.d.ts +31 -0
  28. package/lib/Signal/Group/sender-key-record.js +7 -16
  29. package/lib/Signal/Group/sender-key-state.d.ts +39 -0
  30. package/lib/Signal/Group/sender-key-state.js +25 -37
  31. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  32. package/lib/Signal/Group/sender-message-key.js +2 -2
  33. package/lib/Signal/libsignal.d.ts +5 -0
  34. package/lib/Signal/libsignal.js +358 -54
  35. package/lib/Signal/lid-mapping.d.ts +19 -0
  36. package/lib/Signal/lid-mapping.js +274 -0
  37. package/lib/Socket/Client/index.d.ts +3 -0
  38. package/lib/Socket/Client/index.js +2 -2
  39. package/lib/Socket/Client/types.d.ts +16 -0
  40. package/lib/Socket/Client/types.js +1 -0
  41. package/lib/Socket/Client/websocket.d.ts +13 -0
  42. package/lib/Socket/Client/websocket.js +18 -30
  43. package/lib/Socket/business.d.ts +202 -0
  44. package/lib/Socket/business.js +160 -38
  45. package/lib/Socket/chats.d.ts +111 -0
  46. package/lib/Socket/chats.js +497 -314
  47. package/lib/Socket/communities.d.ts +258 -0
  48. package/lib/Socket/communities.js +438 -0
  49. package/lib/Socket/community.js +333 -0
  50. package/lib/Socket/groups.d.ts +150 -0
  51. package/lib/Socket/groups.js +229 -91
  52. package/lib/Socket/index.d.ts +245 -0
  53. package/lib/Socket/index.js +9 -6
  54. package/lib/Socket/messages-recv.d.ts +187 -0
  55. package/lib/Socket/messages-recv.js +1105 -501
  56. package/lib/Socket/messages-send.d.ts +183 -0
  57. package/lib/Socket/messages-send.js +1181 -501
  58. package/lib/Socket/mex.d.ts +3 -0
  59. package/lib/Socket/mex.js +45 -0
  60. package/lib/Socket/newsletter.d.ts +160 -0
  61. package/lib/Socket/newsletter.js +227 -200
  62. package/lib/Socket/socket.d.ts +55 -0
  63. package/lib/Socket/socket.js +507 -206
  64. package/lib/Socket/usync.js +6 -6
  65. package/lib/Store/index.js +17 -5
  66. package/lib/Store/make-cache-manager-store.js +83 -0
  67. package/lib/Store/make-in-memory-store.js +48 -89
  68. package/lib/Store/make-ordered-dictionary.js +1 -1
  69. package/lib/Types/Auth.d.ts +116 -0
  70. package/lib/Types/Bussines.d.ts +25 -0
  71. package/lib/Types/Bussines.js +2 -0
  72. package/lib/Types/Call.d.ts +15 -0
  73. package/lib/Types/Chat.d.ts +123 -0
  74. package/lib/Types/Chat.js +7 -1
  75. package/lib/Types/Contact.d.ts +24 -0
  76. package/lib/Types/Events.d.ts +237 -0
  77. package/lib/Types/Events.js +1 -0
  78. package/lib/Types/GroupMetadata.d.ts +67 -0
  79. package/lib/Types/Label.d.ts +47 -0
  80. package/lib/Types/Label.js +1 -3
  81. package/lib/Types/LabelAssociation.d.ts +30 -0
  82. package/lib/Types/LabelAssociation.js +1 -3
  83. package/lib/Types/Message.d.ts +305 -0
  84. package/lib/Types/Message.js +9 -5
  85. package/lib/Types/MexUpdates.js +11 -0
  86. package/lib/Types/Newsletter.d.ts +135 -0
  87. package/lib/Types/Newsletter.js +36 -11
  88. package/lib/Types/Product.d.ts +79 -0
  89. package/lib/Types/Signal.d.ts +76 -0
  90. package/lib/Types/Signal.js +1 -0
  91. package/lib/Types/Socket.d.ts +133 -0
  92. package/lib/Types/Socket.js +1 -0
  93. package/lib/Types/State.d.ts +39 -0
  94. package/lib/Types/State.js +12 -0
  95. package/lib/Types/USync.d.ts +26 -0
  96. package/lib/Types/USync.js +1 -0
  97. package/lib/Types/index.d.ts +65 -0
  98. package/lib/Types/index.js +14 -14
  99. package/lib/Utils/audioToBuffer.js +31 -0
  100. package/lib/Utils/auth-utils.d.ts +19 -0
  101. package/lib/Utils/auth-utils.js +222 -123
  102. package/lib/Utils/baileys-event-stream.js +60 -0
  103. package/lib/Utils/bridge-runtime.d.ts +1 -0
  104. package/lib/Utils/bridge-runtime.js +14 -0
  105. package/lib/Utils/browser-utils.d.ts +4 -0
  106. package/lib/Utils/browser-utils.js +38 -29
  107. package/lib/Utils/business.d.ts +23 -0
  108. package/lib/Utils/business.js +54 -48
  109. package/lib/Utils/chat-utils.d.ts +70 -0
  110. package/lib/Utils/chat-utils.js +284 -189
  111. package/lib/Utils/crypto.d.ts +37 -0
  112. package/lib/Utils/crypto.js +16 -41
  113. package/lib/Utils/decode-wa-message.d.ts +48 -0
  114. package/lib/Utils/decode-wa-message.js +128 -48
  115. package/lib/Utils/event-buffer.d.ts +34 -0
  116. package/lib/Utils/event-buffer.js +124 -62
  117. package/lib/Utils/generics.d.ts +91 -0
  118. package/lib/Utils/generics.js +154 -138
  119. package/lib/Utils/history.d.ts +22 -0
  120. package/lib/Utils/history.js +77 -34
  121. package/lib/Utils/identity-change-handler.d.ts +37 -0
  122. package/lib/Utils/identity-change-handler.js +54 -0
  123. package/lib/Utils/index.d.ts +22 -0
  124. package/lib/Utils/index.js +32 -19
  125. package/lib/Utils/link-preview.d.ts +21 -0
  126. package/lib/Utils/link-preview.js +12 -17
  127. package/lib/Utils/logger.d.ts +13 -0
  128. package/lib/Utils/lt-hash.d.ts +8 -0
  129. package/lib/Utils/lt-hash.js +2 -43
  130. package/lib/Utils/make-mutex.d.ts +9 -0
  131. package/lib/Utils/make-mutex.js +21 -27
  132. package/lib/Utils/message-retry-manager.d.ts +110 -0
  133. package/lib/Utils/message-retry-manager.js +143 -45
  134. package/lib/Utils/messages-media.d.ts +130 -0
  135. package/lib/Utils/messages-media.js +429 -502
  136. package/lib/Utils/messages-newsletter.d.ts +84 -0
  137. package/lib/Utils/messages-newsletter.js +295 -0
  138. package/lib/Utils/messages.d.ts +92 -0
  139. package/lib/Utils/messages.js +1025 -674
  140. package/lib/Utils/noise-handler.d.ts +20 -0
  141. package/lib/Utils/noise-handler.js +145 -91
  142. package/lib/Utils/pre-key-manager.d.ts +28 -0
  143. package/lib/Utils/pre-key-manager.js +112 -0
  144. package/lib/Utils/process-message.d.ts +60 -0
  145. package/lib/Utils/process-message.js +316 -184
  146. package/lib/Utils/reporting-utils.d.ts +11 -0
  147. package/lib/Utils/reporting-utils.js +262 -0
  148. package/lib/Utils/resolve-jid.d.ts +43 -0
  149. package/lib/Utils/resolve-jid.js +95 -0
  150. package/lib/Utils/rust-bridge-shim.d.ts +22 -0
  151. package/lib/Utils/rust-bridge-shim.js +70 -0
  152. package/lib/Utils/serial-task-queue.js +29 -0
  153. package/lib/Utils/signal.d.ts +34 -0
  154. package/lib/Utils/signal.js +56 -39
  155. package/lib/Utils/streamToBuffer.js +17 -0
  156. package/lib/Utils/sync-action-utils.d.ts +19 -0
  157. package/lib/Utils/sync-action-utils.js +52 -0
  158. package/lib/Utils/tc-token-utils.d.ts +12 -0
  159. package/lib/Utils/tc-token-utils.js +20 -0
  160. package/lib/Utils/use-mongo-file-auth-state.js +71 -0
  161. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  162. package/lib/Utils/use-multi-file-auth-state.js +11 -12
  163. package/lib/Utils/use-single-file-auth-state.js +73 -0
  164. package/lib/Utils/validate-connection.d.ts +11 -0
  165. package/lib/Utils/validate-connection.js +59 -82
  166. package/lib/Utils/wileys-event-stream.js +1 -61
  167. package/lib/WABinary/constants.d.ts +28 -0
  168. package/lib/WABinary/decode.d.ts +7 -0
  169. package/lib/WABinary/decode.js +39 -4
  170. package/lib/WABinary/encode.d.ts +3 -0
  171. package/lib/WABinary/encode.js +17 -11
  172. package/lib/WABinary/generic-utils.d.ts +15 -0
  173. package/lib/WABinary/generic-utils.js +46 -18
  174. package/lib/WABinary/index.d.ts +6 -0
  175. package/lib/WABinary/index.js +9 -5
  176. package/lib/WABinary/jid-utils.d.ts +48 -0
  177. package/lib/WABinary/jid-utils.js +67 -37
  178. package/lib/WABinary/types.d.ts +19 -0
  179. package/lib/WABinary/types.js +34 -0
  180. package/lib/WAM/BinaryInfo.d.ts +9 -0
  181. package/lib/WAM/constants.d.ts +40 -0
  182. package/lib/WAM/constants.js +19183 -11678
  183. package/lib/WAM/encode.d.ts +3 -0
  184. package/lib/WAM/encode.js +15 -17
  185. package/lib/WAM/index.d.ts +4 -0
  186. package/lib/WAM/index.js +3 -3
  187. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
  188. package/lib/WAUSync/Protocols/USyncContactProtocol.js +6 -6
  189. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  190. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +9 -9
  191. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  192. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +6 -6
  193. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  194. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -8
  195. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
  196. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +18 -17
  197. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
  198. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +11 -3
  199. package/lib/WAUSync/Protocols/index.d.ts +5 -0
  200. package/lib/WAUSync/Protocols/index.js +6 -4
  201. package/lib/WAUSync/USyncQuery.d.ts +29 -0
  202. package/lib/WAUSync/USyncQuery.js +38 -30
  203. package/lib/WAUSync/USyncUser.d.ts +13 -0
  204. package/lib/WAUSync/index.d.ts +4 -0
  205. package/lib/WAUSync/index.js +3 -3
  206. package/lib/index.d.ts +12 -0
  207. package/lib/index.js +3 -5
  208. package/package.json +7 -4
  209. package/LICENSE +0 -21
@@ -1,10 +1,7 @@
1
1
  const major = parseInt(process.versions.node.split('.')[0], 10);
2
-
3
2
  if (major < 20) {
4
- console.error(
5
- `\n❌ This package requires Node.js 20+ to run reliably.\n` +
6
- ` You are using Node.js ${process.versions.node}.\n` +
7
- ` Please upgrade to Node.js 20+ to proceed.\n`
8
- );
9
- process.exit(1);
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);
10
7
  }
@@ -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
@@ -3,13 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- 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.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.UNAUTHORIZED_CODES = exports.version = void 0;
7
- const WAProto_1 = require("../../WAProto");
8
- const libsignal_1 = require("../Signal/libsignal");
9
- const browser_utils_1 = require("../Utils/browser-utils");
10
- const logger_1 = __importDefault(require("../Utils/logger"));
11
- const waVer = require("./wileys-version.json");
12
- exports.version = waVer?.version || [2, 3000, 1036687490];
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('./wileys-version.json');
14
+ exports.version = waVer?.version || [2, 3000, 1036804474];
13
15
  exports.UNAUTHORIZED_CODES = [401, 403, 419];
14
16
  exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
15
17
  exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
@@ -22,32 +24,39 @@ exports.WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
22
24
  exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
23
25
  exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
24
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;
25
31
  exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
26
32
  exports.DICT_VERSION = 3;
27
33
  exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
28
- exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
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 */
29
36
  exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
30
37
  exports.WA_CERT_DETAILS = {
31
- SERIAL: 0
38
+ SERIAL: 0,
39
+ ISSUER: 'WhatsAppLongTerm1',
40
+ PUBLIC_KEY: Buffer.from('142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b', 'hex')
32
41
  };
33
42
  exports.PROCESSABLE_HISTORY_TYPES = [
34
- WAProto_1.proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
35
- WAProto_1.proto.HistorySync.HistorySyncType.PUSH_NAME,
36
- WAProto_1.proto.HistorySync.HistorySyncType.RECENT,
37
- WAProto_1.proto.HistorySync.HistorySyncType.FULL,
38
- WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND,
39
- WAProto_1.proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
40
- WAProto_1.proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3,
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
41
50
  ];
42
51
  exports.DEFAULT_CONNECTION_CONFIG = {
43
52
  version: exports.version,
44
- browser: (0, browser_utils_1.Browsers)('Chrome'),
53
+ browser: browser_utils_js_1.Browsers.macOS('Chrome'),
45
54
  waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
46
- connectTimeoutMs: 20_000,
47
- keepAliveIntervalMs: 30_000,
48
- logger: logger_1.default.child({ class: 'baileys' }),
55
+ connectTimeoutMs: 20000,
56
+ keepAliveIntervalMs: 30000,
57
+ logger: logger_js_1.default.child({ class: 'wileys' }),
49
58
  emitOwnEvents: true,
50
- defaultQueryTimeoutMs: 60_000,
59
+ defaultQueryTimeoutMs: 60000,
51
60
  customUploadHosts: [],
52
61
  retryRequestDelayMs: 250,
53
62
  maxMsgRetryCount: 5,
@@ -56,11 +65,11 @@ exports.DEFAULT_CONNECTION_CONFIG = {
56
65
  markOnlineOnConnect: true,
57
66
  syncFullHistory: true,
58
67
  patchMessageBeforeSending: msg => msg,
59
- shouldSyncHistoryMessage: () => true,
68
+ shouldSyncHistoryMessage: ({ syncType }) => {
69
+ return syncType !== index_js_1.proto.HistorySync.HistorySyncType.FULL;
70
+ },
60
71
  shouldIgnoreJid: () => false,
61
72
  linkPreviewImageThumbnailWidth: 192,
62
- // no forced delay between album items by default, to avoid slow perceived delivery
63
- albumMessageItemDelayMs: 0,
64
73
  transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
65
74
  generateHighQualityLinkPreview: false,
66
75
  enableAutoSessionRecreation: true,
@@ -73,7 +82,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
73
82
  countryCode: 'US',
74
83
  getMessage: async () => undefined,
75
84
  cachedGroupMetadata: async () => undefined,
76
- makeSignalRepository: libsignal_1.makeLibSignalRepository
85
+ makeSignalRepository: libsignal_js_1.makeLibSignalRepository
77
86
  };
78
87
  exports.MEDIA_PATH_MAP = {
79
88
  image: '/mms/image',
@@ -86,8 +95,7 @@ exports.MEDIA_PATH_MAP = {
86
95
  'md-app-state': '',
87
96
  'md-msg-hist': '/mms/md-app-state',
88
97
  'biz-cover-photo': '/pps/biz-cover-photo',
89
- 'sticker-pack': '/mms/sticker',
90
- 'thumbnail-sticker-pack': '/mms/image'
98
+ 'sticker-pack': '/mms/sticker'
91
99
  };
92
100
  exports.MEDIA_HKDF_KEY_MAPPING = {
93
101
  audio: 'Audio',
@@ -109,17 +117,23 @@ exports.MEDIA_HKDF_KEY_MAPPING = {
109
117
  'payment-bg-image': 'Payment Background',
110
118
  ptv: 'Video',
111
119
  'biz-cover-photo': 'Image',
112
- 'sticker-pack': 'Sticker Pack',
113
- 'thumbnail-sticker-pack': 'Image Thumbnail'
120
+ 'sticker-pack': 'Sticker Pack'
114
121
  };
115
122
  exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
116
123
  exports.MIN_PREKEY_COUNT = 5;
117
124
  exports.INITIAL_PREKEY_COUNT = 812;
118
- exports.UPLOAD_TIMEOUT = 30000;
119
- exports.MIN_UPLOAD_INTERVAL = 5000;
125
+ exports.UPLOAD_TIMEOUT = 30000; // 30 seconds
126
+ exports.MIN_UPLOAD_INTERVAL = 5000; // 5 seconds minimum between uploads
120
127
  exports.DEFAULT_CACHE_TTLS = {
121
- SIGNAL_STORE: 5 * 60,
122
- MSG_RETRY: 60 * 60,
123
- CALL_OFFER: 5 * 60,
124
- USER_DEVICES: 5 * 60
128
+ SIGNAL_STORE: 5 * 60, // 5 minutes
129
+ MSG_RETRY: 60 * 60, // 1 hour
130
+ CALL_OFFER: 5 * 60, // 5 minutes
131
+ USER_DEVICES: 5 * 60 // 5 minutes
132
+ };
133
+ exports.TimeMs = {
134
+ Minute: 60 * 1000,
135
+ Hour: 60 * 60 * 1000,
136
+ Day: 24 * 60 * 60 * 1000,
137
+ Week: 7 * 24 * 60 * 60 * 1000
125
138
  };
139
+ 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
+ }
@@ -2,7 +2,7 @@
2
2
  "version": [
3
3
  2,
4
4
  3000,
5
- 1036687490
5
+ 1036804474
6
6
  ],
7
- "raw": "2.3000.1036687490"
7
+ "raw": "2.3000.1036804474"
8
8
  }
@@ -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
+ 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
@@ -34,8 +34,10 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.GroupSessionBuilder = void 0;
37
- const keyhelper = __importStar(require("./keyhelper"));
38
- const sender_key_distribution_message_1 = require("./sender-key-distribution-message");
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");
39
41
  class GroupSessionBuilder {
40
42
  constructor(senderKeyStore) {
41
43
  this.senderKeyStore = senderKeyStore;
@@ -58,7 +60,7 @@ class GroupSessionBuilder {
58
60
  if (!state) {
59
61
  throw new Error('No session state available');
60
62
  }
61
- return new sender_key_distribution_message_1.SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic());
63
+ return new sender_key_distribution_message_js_1.SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic());
62
64
  }
63
65
  }
64
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
@@ -1,55 +1,47 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.GroupCipher = void 0;
7
- const crypto_1 = require("libsignal/src/crypto");
8
- const queue_job_1 = __importDefault(require("./queue-job"));
9
- const sender_key_message_1 = require("./sender-key-message");
4
+ const crypto_js_1 = require("libsignal/src/crypto.js");
5
+ const sender_key_message_js_1 = require("./sender-key-message.js");
6
+ const sender_key_name_js_1 = require("./sender-key-name.js");
7
+ const sender_key_record_js_1 = require("./sender-key-record.js");
8
+ const sender_key_state_js_1 = require("./sender-key-state.js");
10
9
  class GroupCipher {
11
10
  constructor(senderKeyStore, senderKeyName) {
12
11
  this.senderKeyStore = senderKeyStore;
13
12
  this.senderKeyName = senderKeyName;
14
13
  }
15
- queueJob(awaitable) {
16
- return (0, queue_job_1.default)(this.senderKeyName.toString(), awaitable);
17
- }
18
14
  async encrypt(paddedPlaintext) {
19
- return await this.queueJob(async () => {
20
- const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
21
- if (!record) {
22
- throw new Error('No SenderKeyRecord found for encryption');
23
- }
24
- const senderKeyState = record.getSenderKeyState();
25
- if (!senderKeyState) {
26
- throw new Error('No session to encrypt message');
27
- }
28
- const iteration = senderKeyState.getSenderChainKey().getIteration();
29
- const senderKey = this.getSenderKey(senderKeyState, iteration === 0 ? 0 : iteration + 1);
30
- const ciphertext = await this.getCipherText(senderKey.getIv(), senderKey.getCipherKey(), paddedPlaintext);
31
- const senderKeyMessage = new sender_key_message_1.SenderKeyMessage(senderKeyState.getKeyId(), senderKey.getIteration(), ciphertext, senderKeyState.getSigningKeyPrivate());
32
- await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
33
- return senderKeyMessage.serialize();
34
- });
15
+ const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
16
+ if (!record) {
17
+ throw new Error('No SenderKeyRecord found for encryption');
18
+ }
19
+ const senderKeyState = record.getSenderKeyState();
20
+ if (!senderKeyState) {
21
+ throw new Error('No session to encrypt message');
22
+ }
23
+ const iteration = senderKeyState.getSenderChainKey().getIteration();
24
+ const senderKey = this.getSenderKey(senderKeyState, iteration === 0 ? 0 : iteration + 1);
25
+ const ciphertext = await this.getCipherText(senderKey.getIv(), senderKey.getCipherKey(), paddedPlaintext);
26
+ const senderKeyMessage = new sender_key_message_js_1.SenderKeyMessage(senderKeyState.getKeyId(), senderKey.getIteration(), ciphertext, senderKeyState.getSigningKeyPrivate());
27
+ await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
28
+ return senderKeyMessage.serialize();
35
29
  }
36
30
  async decrypt(senderKeyMessageBytes) {
37
- return await this.queueJob(async () => {
38
- const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
39
- if (!record) {
40
- throw new Error('No SenderKeyRecord found for decryption');
41
- }
42
- const senderKeyMessage = new sender_key_message_1.SenderKeyMessage(null, null, null, null, senderKeyMessageBytes);
43
- const senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId());
44
- if (!senderKeyState) {
45
- throw new Error('No session found to decrypt message');
46
- }
47
- senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic());
48
- const senderKey = this.getSenderKey(senderKeyState, senderKeyMessage.getIteration());
49
- const plaintext = await this.getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText());
50
- await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
51
- return plaintext;
52
- });
31
+ const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
32
+ if (!record) {
33
+ throw new Error('No SenderKeyRecord found for decryption');
34
+ }
35
+ const senderKeyMessage = new sender_key_message_js_1.SenderKeyMessage(null, null, null, null, senderKeyMessageBytes);
36
+ const senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId());
37
+ if (!senderKeyState) {
38
+ throw new Error('No session found to decrypt message');
39
+ }
40
+ senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic());
41
+ const senderKey = this.getSenderKey(senderKeyState, senderKeyMessage.getIteration());
42
+ const plaintext = await this.getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText());
43
+ await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
44
+ return plaintext;
53
45
  }
54
46
  getSenderKey(senderKeyState, iteration) {
55
47
  let senderChainKey = senderKeyState.getSenderChainKey();
@@ -75,7 +67,7 @@ class GroupCipher {
75
67
  }
76
68
  async getPlainText(iv, key, ciphertext) {
77
69
  try {
78
- return (0, crypto_1.decrypt)(key, ciphertext, iv);
70
+ return (0, crypto_js_1.decrypt)(key, ciphertext, iv);
79
71
  }
80
72
  catch (e) {
81
73
  throw new Error('InvalidMessageException');
@@ -83,10 +75,7 @@ class GroupCipher {
83
75
  }
84
76
  async getCipherText(iv, key, plaintext) {
85
77
  try {
86
- const ivBuffer = typeof iv === 'string' ? Buffer.from(iv, 'base64') : iv;
87
- const keyBuffer = typeof key === 'string' ? Buffer.from(key, 'base64') : key;
88
- const plaintextBuffer = typeof plaintext === 'string' ? Buffer.from(plaintext) : plaintext;
89
- return (0, crypto_1.encrypt)(keyBuffer, plaintextBuffer, ivBuffer);
78
+ return (0, crypto_js_1.encrypt)(key, plaintext, iv);
90
79
  }
91
80
  catch (e) {
92
81
  throw new Error('InvalidMessageException');
@@ -0,0 +1,12 @@
1
+ export { GroupSessionBuilder } from './group-session-builder.js';
2
+ export { SenderKeyDistributionMessage } from './sender-key-distribution-message.js';
3
+ export { SenderKeyRecord } from './sender-key-record.js';
4
+ export { SenderKeyName } from './sender-key-name.js';
5
+ export { GroupCipher } from './group_cipher.js';
6
+ export { SenderKeyState } from './sender-key-state.js';
7
+ export { SenderKeyMessage } from './sender-key-message.js';
8
+ export { SenderMessageKey } from './sender-message-key.js';
9
+ export { SenderChainKey } from './sender-chain-key.js';
10
+ export { CiphertextMessage } from './ciphertext-message.js';
11
+ export * as keyhelper from './keyhelper.js';
12
+ //# sourceMappingURL=index.d.ts.map