@zetagoaurum-socket/wasocket 3.1.0 → 3.2.7

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 (96) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +81 -60
  3. package/WAProto/index.js +56886 -17506
  4. package/engine-requirements.js +10 -0
  5. package/lib/Defaults/baileys-version.json +1 -1
  6. package/lib/Defaults/index.js +50 -9
  7. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  8. package/lib/Signal/Group/ciphertext-message.js +15 -0
  9. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  10. package/lib/Signal/Group/group-session-builder.js +64 -0
  11. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  12. package/lib/Signal/Group/group_cipher.js +96 -0
  13. package/lib/Signal/Group/index.d.ts +11 -0
  14. package/lib/Signal/Group/index.js +57 -0
  15. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  16. package/lib/Signal/Group/keyhelper.js +55 -0
  17. package/lib/Signal/Group/queue-job.d.ts +1 -0
  18. package/lib/Signal/Group/queue-job.js +57 -0
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  20. package/lib/Signal/Group/sender-chain-key.js +34 -0
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  22. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  24. package/lib/Signal/Group/sender-key-message.js +69 -0
  25. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-name.js +51 -0
  27. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  28. package/lib/Signal/Group/sender-key-record.js +53 -0
  29. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  30. package/lib/Signal/Group/sender-key-state.js +99 -0
  31. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  32. package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
  33. package/lib/Signal/libsignal.js +51 -29
  34. package/lib/Socket/business.d.ts +3 -2
  35. package/lib/Socket/chats.d.ts +215 -28
  36. package/lib/Socket/chats.js +185 -70
  37. package/lib/Socket/chats.js.bak +981 -0
  38. package/lib/Socket/dugong.d.ts +254 -0
  39. package/lib/Socket/dugong.js +432 -141
  40. package/lib/Socket/groups.js +20 -23
  41. package/lib/Socket/index.js +2 -15
  42. package/lib/Socket/messages-recv.d.ts +56 -55
  43. package/lib/Socket/messages-recv.js +370 -112
  44. package/lib/Socket/messages-send.d.ts +3 -2
  45. package/lib/Socket/messages-send.js +464 -377
  46. package/lib/Socket/newsletter.js +175 -28
  47. package/lib/Socket/socket.js +204 -176
  48. package/lib/Socket/usync.d.ts +3 -3
  49. package/lib/Types/GroupMetadata.d.ts +1 -0
  50. package/lib/Types/Newsletter.d.ts +97 -86
  51. package/lib/Types/Newsletter.js +38 -32
  52. package/lib/Types/USync.d.ts +25 -0
  53. package/lib/Types/USync.js +2 -0
  54. package/lib/Utils/anti-crash.js +20 -0
  55. package/lib/Utils/auto-contact.js +74 -0
  56. package/lib/Utils/chat-utils.js +17 -3
  57. package/lib/Utils/generics.js +68 -31
  58. package/lib/Utils/generics.js.bak +433 -0
  59. package/lib/Utils/history.js +6 -1
  60. package/lib/Utils/index.js +0 -1
  61. package/lib/Utils/link-preview.js +4 -2
  62. package/lib/Utils/messages-media.js +145 -57
  63. package/lib/Utils/messages.js +89 -305
  64. package/lib/Utils/signal.js +48 -46
  65. package/lib/Utils/use-multi-file-auth-state.js +45 -6
  66. package/lib/Utils/validate-connection.js +91 -65
  67. package/lib/Utils/validate-connection.js.bak +237 -0
  68. package/lib/WABinary/constants.d.ts +27 -24
  69. package/lib/WABinary/encode.js +160 -123
  70. package/lib/WABinary/generic-utils.d.ts +2 -0
  71. package/lib/WABinary/generic-utils.js +124 -36
  72. package/lib/WABinary/jid-utils.js +5 -26
  73. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  74. package/lib/index.d.ts +1 -0
  75. package/lib/index.js +9 -0
  76. package/package.json +105 -100
  77. package/WAProto/GenerateStatics.sh +0 -4
  78. package/WAProto/WAProto.proto +0 -3344
  79. package/WAProto/index.d.ts +0 -37016
  80. package/WASignalGroup/GroupProtocol.js +0 -1697
  81. package/WASignalGroup/ciphertext_message.js +0 -16
  82. package/WASignalGroup/group_cipher.js +0 -120
  83. package/WASignalGroup/group_session_builder.js +0 -46
  84. package/WASignalGroup/index.js +0 -5
  85. package/WASignalGroup/keyhelper.js +0 -21
  86. package/WASignalGroup/protobufs.js +0 -3
  87. package/WASignalGroup/queue_job.js +0 -69
  88. package/WASignalGroup/sender_chain_key.js +0 -50
  89. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  90. package/WASignalGroup/sender_key_message.js +0 -92
  91. package/WASignalGroup/sender_key_name.js +0 -70
  92. package/WASignalGroup/sender_key_record.js +0 -56
  93. package/WASignalGroup/sender_key_state.js +0 -129
  94. package/lib/Utils/rate-limiter.js +0 -55
  95. package/lib/WAUSync/Fall +0 -1
  96. package/lib/WAUSync/Protocols/Fal +0 -1
@@ -1,129 +0,0 @@
1
- const SenderChainKey = require('./sender_chain_key');
2
- const SenderMessageKey = require('./sender_message_key');
3
-
4
- const protobufs = require('./protobufs');
5
-
6
- class SenderKeyState {
7
- MAX_MESSAGE_KEYS = 2000;
8
-
9
- constructor(
10
- id = null,
11
- iteration = null,
12
- chainKey = null,
13
- signatureKeyPair = null,
14
- signatureKeyPublic = null,
15
- signatureKeyPrivate = null,
16
- senderKeyStateStructure = null
17
- ) {
18
- if (senderKeyStateStructure) {
19
- this.senderKeyStateStructure = senderKeyStateStructure;
20
- } else {
21
- if (signatureKeyPair) {
22
- signatureKeyPublic = signatureKeyPair.public;
23
- signatureKeyPrivate = signatureKeyPair.private;
24
- }
25
-
26
- chainKey = typeof chainKey === 'string' ? Buffer.from(chainKey, 'base64') : chainKey;
27
- this.senderKeyStateStructure = protobufs.SenderKeyStateStructure.create();
28
- const senderChainKeyStructure = protobufs.SenderChainKey.create();
29
- senderChainKeyStructure.iteration = iteration;
30
- senderChainKeyStructure.seed = chainKey;
31
- this.senderKeyStateStructure.senderChainKey = senderChainKeyStructure;
32
-
33
- const signingKeyStructure = protobufs.SenderSigningKey.create();
34
- signingKeyStructure.public =
35
- typeof signatureKeyPublic === 'string' ?
36
- Buffer.from(signatureKeyPublic, 'base64') :
37
- signatureKeyPublic;
38
- if (signatureKeyPrivate) {
39
- signingKeyStructure.private =
40
- typeof signatureKeyPrivate === 'string' ?
41
- Buffer.from(signatureKeyPrivate, 'base64') :
42
- signatureKeyPrivate;
43
- }
44
- this.senderKeyStateStructure.senderKeyId = id;
45
- this.senderChainKey = senderChainKeyStructure;
46
- this.senderKeyStateStructure.senderSigningKey = signingKeyStructure;
47
- }
48
- this.senderKeyStateStructure.senderMessageKeys =
49
- this.senderKeyStateStructure.senderMessageKeys || [];
50
- }
51
-
52
- SenderKeyState(senderKeyStateStructure) {
53
- this.senderKeyStateStructure = senderKeyStateStructure;
54
- }
55
-
56
- getKeyId() {
57
- return this.senderKeyStateStructure.senderKeyId;
58
- }
59
-
60
- getSenderChainKey() {
61
- return new SenderChainKey(
62
- this.senderKeyStateStructure.senderChainKey.iteration,
63
- this.senderKeyStateStructure.senderChainKey.seed
64
- );
65
- }
66
-
67
- setSenderChainKey(chainKey) {
68
- const senderChainKeyStructure = protobufs.SenderChainKey.create({
69
- iteration: chainKey.getIteration(),
70
- seed: chainKey.getSeed(),
71
- });
72
- this.senderKeyStateStructure.senderChainKey = senderChainKeyStructure;
73
- }
74
-
75
- getSigningKeyPublic() {
76
- return typeof this.senderKeyStateStructure.senderSigningKey.public === 'string' ?
77
- Buffer.from(this.senderKeyStateStructure.senderSigningKey.public, 'base64') :
78
- this.senderKeyStateStructure.senderSigningKey.public;
79
- }
80
-
81
- getSigningKeyPrivate() {
82
- return typeof this.senderKeyStateStructure.senderSigningKey.private === 'string' ?
83
- Buffer.from(this.senderKeyStateStructure.senderSigningKey.private, 'base64') :
84
- this.senderKeyStateStructure.senderSigningKey.private;
85
- }
86
-
87
- hasSenderMessageKey(iteration) {
88
- const list = this.senderKeyStateStructure.senderMessageKeys;
89
- for (let o = 0; o < list.length; o++) {
90
- const senderMessageKey = list[o];
91
- if (senderMessageKey.iteration === iteration) return true;
92
- }
93
- return false;
94
- }
95
-
96
- addSenderMessageKey(senderMessageKey) {
97
- const senderMessageKeyStructure = protobufs.SenderKeyStateStructure.create({
98
- iteration: senderMessageKey.getIteration(),
99
- seed: senderMessageKey.getSeed(),
100
- });
101
- this.senderKeyStateStructure.senderMessageKeys.push(senderMessageKeyStructure);
102
-
103
- if (this.senderKeyStateStructure.senderMessageKeys.length > this.MAX_MESSAGE_KEYS) {
104
- this.senderKeyStateStructure.senderMessageKeys.shift();
105
- }
106
- }
107
-
108
- removeSenderMessageKey(iteration) {
109
- let result = null;
110
-
111
- this.senderKeyStateStructure.senderMessageKeys = this.senderKeyStateStructure.senderMessageKeys.filter(
112
- senderMessageKey => {
113
- if (senderMessageKey.iteration === iteration) result = senderMessageKey;
114
- return senderMessageKey.iteration !== iteration;
115
- }
116
- );
117
-
118
- if (result != null) {
119
- return new SenderMessageKey(result.iteration, result.seed);
120
- }
121
- return null;
122
- }
123
-
124
- getStructure() {
125
- return this.senderKeyStateStructure;
126
- }
127
- }
128
-
129
- module.exports = SenderKeyState;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RateLimiter = void 0;
4
- const Utils_1 = require("./");
5
- /**
6
- * Smart Rate Limiter (Token Bucket Algorithm)
7
- * Ensures stability and security ("Anti-Neko-Neko")
8
- */
9
- class RateLimiter {
10
- constructor(config = {}) {
11
- this.tokens = config.maxTokens || 10;
12
- this.maxTokens = config.maxTokens || 10;
13
- this.refillRate = config.refillRate || 2; // Tokens per second
14
- this.lastRefill = Date.now();
15
- this.queue = [];
16
- this.processing = false;
17
- }
18
- refill() {
19
- const now = Date.now();
20
- const elapsed = (now - this.lastRefill) / 1000;
21
- if (elapsed > 0) {
22
- const newTokens = elapsed * this.refillRate;
23
- this.tokens = Math.min(this.maxTokens, this.tokens + newTokens);
24
- this.lastRefill = now;
25
- }
26
- }
27
- async consume(cost = 1) {
28
- return new Promise((resolve) => {
29
- this.queue.push({ cost, resolve });
30
- this.processQueue();
31
- });
32
- }
33
- async processQueue() {
34
- if (this.processing)
35
- return;
36
- this.processing = true;
37
- while (this.queue.length > 0) {
38
- this.refill();
39
- const { cost, resolve } = this.queue[0];
40
- if (this.tokens >= cost) {
41
- this.tokens -= cost;
42
- this.queue.shift();
43
- resolve();
44
- }
45
- else {
46
- // Wait for enough tokens
47
- const missing = cost - this.tokens;
48
- const waitTime = (missing / this.refillRate) * 1000;
49
- await (0, Utils_1.delay)(Math.max(waitTime, 100)); // Min 100ms wait
50
- }
51
- }
52
- this.processing = false;
53
- }
54
- }
55
- exports.RateLimiter = RateLimiter;
package/lib/WAUSync/Fall DELETED
@@ -1 +0,0 @@
1
-
@@ -1 +0,0 @@
1
-