@budetzz/baileys 2.0.3

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 (103) hide show
  1. package/README.md +393 -0
  2. package/WAProto/index.js +169661 -0
  3. package/engine-requirements.js +10 -0
  4. package/lib/Defaults/baileys-version.json +3 -0
  5. package/lib/Defaults/index.js +147 -0
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Signal/Group/ciphertext-message.js +15 -0
  8. package/lib/Signal/Group/group-session-builder.js +64 -0
  9. package/lib/Signal/Group/group_cipher.js +96 -0
  10. package/lib/Signal/Group/index.js +57 -0
  11. package/lib/Signal/Group/keyhelper.js +55 -0
  12. package/lib/Signal/Group/queue-job.js +57 -0
  13. package/lib/Signal/Group/sender-chain-key.js +34 -0
  14. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  15. package/lib/Signal/Group/sender-key-message.js +69 -0
  16. package/lib/Signal/Group/sender-key-name.js +51 -0
  17. package/lib/Signal/Group/sender-key-record.js +53 -0
  18. package/lib/Signal/Group/sender-key-state.js +99 -0
  19. package/lib/Signal/Group/sender-message-key.js +29 -0
  20. package/lib/Signal/libsignal.js +174 -0
  21. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  22. package/lib/Socket/Client/index.js +19 -0
  23. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  24. package/lib/Socket/Client/web-socket-client.js +62 -0
  25. package/lib/Socket/business.js +260 -0
  26. package/lib/Socket/chats.js +983 -0
  27. package/lib/Socket/dugong.js +484 -0
  28. package/lib/Socket/groups.js +317 -0
  29. package/lib/Socket/index.js +11 -0
  30. package/lib/Socket/messages-recv.js +1110 -0
  31. package/lib/Socket/messages-send.js +909 -0
  32. package/lib/Socket/newsletter.js +404 -0
  33. package/lib/Socket/newsletter.js.bak +404 -0
  34. package/lib/Socket/registration.js +166 -0
  35. package/lib/Socket/socket.js +665 -0
  36. package/lib/Socket/usync.js +70 -0
  37. package/lib/Store/index.js +10 -0
  38. package/lib/Store/make-cache-manager-store.js +83 -0
  39. package/lib/Store/make-in-memory-store.js +427 -0
  40. package/lib/Store/make-ordered-dictionary.js +81 -0
  41. package/lib/Store/object-repository.js +27 -0
  42. package/lib/Store/p +1 -0
  43. package/lib/Types/Auth.js +2 -0
  44. package/lib/Types/Call.js +2 -0
  45. package/lib/Types/Chat.js +4 -0
  46. package/lib/Types/Contact.js +2 -0
  47. package/lib/Types/Events.js +2 -0
  48. package/lib/Types/GroupMetadata.js +2 -0
  49. package/lib/Types/Label.js +27 -0
  50. package/lib/Types/LabelAssociation.js +9 -0
  51. package/lib/Types/Message.js +9 -0
  52. package/lib/Types/Newsletter.js +38 -0
  53. package/lib/Types/Product.js +2 -0
  54. package/lib/Types/Signal.js +2 -0
  55. package/lib/Types/Socket.js +2 -0
  56. package/lib/Types/State.js +2 -0
  57. package/lib/Types/USync.js +2 -0
  58. package/lib/Types/index.js +42 -0
  59. package/lib/Utils/auth-utils.js +206 -0
  60. package/lib/Utils/baileys-event-stream.js +63 -0
  61. package/lib/Utils/business.js +234 -0
  62. package/lib/Utils/chat-utils.js +729 -0
  63. package/lib/Utils/crypto.js +151 -0
  64. package/lib/Utils/decode-wa-message.js +198 -0
  65. package/lib/Utils/event-buffer.js +514 -0
  66. package/lib/Utils/generics.js +423 -0
  67. package/lib/Utils/history.js +96 -0
  68. package/lib/Utils/index.js +33 -0
  69. package/lib/Utils/link-preview.js +93 -0
  70. package/lib/Utils/logger.js +7 -0
  71. package/lib/Utils/lt-hash.js +51 -0
  72. package/lib/Utils/make-mutex.js +43 -0
  73. package/lib/Utils/messages-media.js +819 -0
  74. package/lib/Utils/messages.js +784 -0
  75. package/lib/Utils/noise-handler.js +155 -0
  76. package/lib/Utils/p +1 -0
  77. package/lib/Utils/process-message.js +321 -0
  78. package/lib/Utils/signal.js +153 -0
  79. package/lib/Utils/use-multi-file-auth-state.js +119 -0
  80. package/lib/Utils/validate-connection.js +229 -0
  81. package/lib/WABinary/constants.js +40 -0
  82. package/lib/WABinary/decode.js +252 -0
  83. package/lib/WABinary/encode.js +265 -0
  84. package/lib/WABinary/generic-utils.js +198 -0
  85. package/lib/WABinary/index.js +21 -0
  86. package/lib/WABinary/jid-utils.js +62 -0
  87. package/lib/WABinary/types.js +2 -0
  88. package/lib/WAM/BinaryInfo.js +13 -0
  89. package/lib/WAM/constants.js +15350 -0
  90. package/lib/WAM/encode.js +155 -0
  91. package/lib/WAM/index.js +19 -0
  92. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  93. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  94. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  95. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  96. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  97. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  98. package/lib/WAUSync/Protocols/index.js +20 -0
  99. package/lib/WAUSync/USyncQuery.js +89 -0
  100. package/lib/WAUSync/USyncUser.js +26 -0
  101. package/lib/WAUSync/index.js +19 -0
  102. package/lib/index.js +43 -0
  103. package/package.json +93 -0
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LT_HASH_ANTI_TAMPERING = void 0;
4
+ const crypto_1 = require("./crypto");
5
+ /**
6
+ * LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
7
+ * over a series of mutations. You can add/remove mutations and it'll return a hash equal to
8
+ * if the same series of mutations was made sequentially.
9
+ */
10
+ const o = 128;
11
+ class d {
12
+ constructor(e) {
13
+ this.salt = e;
14
+ }
15
+ add(e, t) {
16
+ var r = this;
17
+ for (const item of t) {
18
+ e = r._addSingle(e, item);
19
+ }
20
+ return e;
21
+ }
22
+ subtract(e, t) {
23
+ var r = this;
24
+ for (const item of t) {
25
+ e = r._subtractSingle(e, item);
26
+ }
27
+ return e;
28
+ }
29
+ subtractThenAdd(e, t, r) {
30
+ var n = this;
31
+ return n.add(n.subtract(e, r), t);
32
+ }
33
+ _addSingle(e, t) {
34
+ var r = this;
35
+ const n = new Uint8Array((0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
36
+ return r.performPointwiseWithOverflow(e, n, ((e, t) => e + t));
37
+ }
38
+ _subtractSingle(e, t) {
39
+ var r = this;
40
+ const n = new Uint8Array((0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
41
+ return r.performPointwiseWithOverflow(e, n, ((e, t) => e - t));
42
+ }
43
+ performPointwiseWithOverflow(e, t, r) {
44
+ const n = new DataView(e), i = new DataView(t), a = new ArrayBuffer(n.byteLength), s = new DataView(a);
45
+ for (let e = 0; e < n.byteLength; e += 2) {
46
+ s.setUint16(e, r(n.getUint16(e, !0), i.getUint16(e, !0)), !0);
47
+ }
48
+ return a;
49
+ }
50
+ }
51
+ exports.LT_HASH_ANTI_TAMPERING = new d('WhatsApp Patch Integrity');
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeKeyedMutex = exports.makeMutex = void 0;
4
+ const makeMutex = () => {
5
+ let task = Promise.resolve();
6
+ let taskTimeout;
7
+ return {
8
+ mutex(code) {
9
+ task = (async () => {
10
+ // wait for the previous task to complete
11
+ // if there is an error, we swallow so as to not block the queue
12
+ try {
13
+ await task;
14
+ }
15
+ catch (_a) { }
16
+ try {
17
+ // execute the current task
18
+ const result = await code();
19
+ return result;
20
+ }
21
+ finally {
22
+ clearTimeout(taskTimeout);
23
+ }
24
+ })();
25
+ // we replace the existing task, appending the new piece of execution to it
26
+ // so the next task will have to wait for this one to finish
27
+ return task;
28
+ },
29
+ };
30
+ };
31
+ exports.makeMutex = makeMutex;
32
+ const makeKeyedMutex = () => {
33
+ const map = {};
34
+ return {
35
+ mutex(key, task) {
36
+ if (!map[key]) {
37
+ map[key] = (0, exports.makeMutex)();
38
+ }
39
+ return map[key].mutex(task);
40
+ }
41
+ };
42
+ };
43
+ exports.makeKeyedMutex = makeKeyedMutex;