@ryuu-reinzz/baileys 3.0.0-beta.13 → 3.0.0-beta.15

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 (38) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -0
  3. package/WAProto/fix-imports.js +70 -18
  4. package/WAProto/index.js +197 -160
  5. package/lib/Defaults/index.js +17 -4
  6. package/lib/Signal/libsignal.js +63 -2
  7. package/lib/Signal/lid-mapping.js +170 -70
  8. package/lib/Socket/Client/websocket.js +5 -1
  9. package/lib/Socket/business.js +11 -8
  10. package/lib/Socket/chats.js +55 -28
  11. package/lib/Socket/index.js +0 -6
  12. package/lib/Socket/messages-recv.js +153 -80
  13. package/lib/Socket/messages-send.js +229 -144
  14. package/lib/Socket/socket.js +69 -15
  15. package/lib/Utils/auth-utils.js +53 -20
  16. package/lib/Utils/chat-utils.js +100 -51
  17. package/lib/Utils/crypto.js +2 -26
  18. package/lib/Utils/event-buffer.js +33 -7
  19. package/lib/Utils/generics.js +4 -1
  20. package/lib/Utils/history.js +46 -5
  21. package/lib/Utils/identity-change-handler.js +49 -0
  22. package/lib/Utils/index.js +2 -1
  23. package/lib/Utils/lt-hash.js +2 -42
  24. package/lib/Utils/make-mutex.js +20 -27
  25. package/lib/Utils/message-retry-manager.js +58 -5
  26. package/lib/Utils/messages-media.js +151 -40
  27. package/lib/Utils/messages.js +43 -23
  28. package/lib/Utils/noise-handler.js +139 -85
  29. package/lib/Utils/process-message.js +57 -14
  30. package/lib/Utils/reporting-utils.js +258 -0
  31. package/lib/Utils/sync-action-utils.js +48 -0
  32. package/lib/Utils/tc-token-utils.js +18 -0
  33. package/lib/Utils/use-sqlite-auth-state.js +0 -2
  34. package/lib/WABinary/decode.js +24 -0
  35. package/lib/WABinary/encode.js +5 -1
  36. package/lib/WABinary/generic-utils.js +19 -8
  37. package/package.json +5 -2
  38. package/lib/Socket/listening.js +0 -61
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Rajeh Taher/WhiskeySockets
3
+ Copyright (c) 2026 RyuuReinzz
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -15,6 +15,12 @@ This is a temporary README.md, the new guide is in development and will this fil
15
15
 
16
16
  New guide link: https://baileys.wiki
17
17
 
18
+ # Get Support
19
+
20
+ If you'd like business to enterprise-level support from Rajeh, the current maintainer of Baileys, you can book a video chat. Book a 1 hour time slot by contacting him on Discord or pre-ordering [here](https://purpshell.dev/book). The earlier you pre-order the better, as his time slots usually fill up very quickly. He offers immense value per hour and will answer all your questions before the time runs out.
21
+
22
+ If you are a business, we encourage you to contribute back to the high development costs of the project and to feed the maintainers who dump tens of hours a week on this. You can do so by booking meetings or sponsoring below. All support, even in bona fide / contribution hours, is welcome by businesses of all sizes. This is not condoning or endorsing businesses to use the library. See the Disclaimer below.
23
+
18
24
  # Sponsor
19
25
  If you'd like to financially support this project, you can do so by supporting the current maintainer [here](https://purpshell.dev/sponsor).
20
26
 
@@ -1,29 +1,81 @@
1
1
  import { readFileSync, writeFileSync } from 'fs';
2
2
  import { exit } from 'process';
3
3
 
4
- const filePath = './index.js';
4
+ const filePath = './index.js'
5
5
 
6
6
  try {
7
- // Read the file
8
- let content = readFileSync(filePath, 'utf8');
7
+ let content = readFileSync(filePath, 'utf8')
9
8
 
10
- // Fix the import statement
11
- content = content.replace(
12
- /import \* as (\$protobuf) from/g,
13
- 'import $1 from'
14
- );
9
+ content = content.replace(/import \* as (\$protobuf) from/g, 'import $1 from')
10
+ content = content.replace(/(['"])protobufjs\/minimal(['"])/g, '$1protobufjs/minimal.js$2')
15
11
 
16
- // add missing extension to the import
17
- content = content.replace(
18
- /(['"])protobufjs\/minimal(['"])/g,
19
- '$1protobufjs/minimal.js$2'
20
- );
12
+ const marker = 'const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});\n\n'
13
+ const longToStringHelper =
14
+ 'function longToString(value, unsigned) {\n' +
15
+ '\tif (typeof value === "string") {\n' +
16
+ '\t\treturn value;\n' +
17
+ '\t}\n' +
18
+ '\tif (typeof value === "number") {\n' +
19
+ '\t\treturn String(value);\n' +
20
+ '\t}\n' +
21
+ '\tif (!$util.Long) {\n' +
22
+ '\t\treturn String(value);\n' +
23
+ '\t}\n' +
24
+ '\tconst normalized = $util.Long.fromValue(value);\n' +
25
+ '\tconst prepared = unsigned && normalized && typeof normalized.toUnsigned === "function"\n' +
26
+ '\t\t? normalized.toUnsigned()\n' +
27
+ '\t\t: normalized;\n' +
28
+ '\treturn prepared.toString();\n' +
29
+ '}\n\n'
30
+ const longToNumberHelper =
31
+ 'function longToNumber(value, unsigned) {\n' +
32
+ '\tif (typeof value === "number") {\n' +
33
+ '\t\treturn value;\n' +
34
+ '\t}\n' +
35
+ '\tif (typeof value === "string") {\n' +
36
+ '\t\tconst numeric = Number(value);\n' +
37
+ '\t\treturn numeric;\n' +
38
+ '\t}\n' +
39
+ '\tif (!$util.Long) {\n' +
40
+ '\t\treturn Number(value);\n' +
41
+ '\t}\n' +
42
+ '\tconst normalized = $util.Long.fromValue(value);\n' +
43
+ '\tconst prepared = unsigned && normalized && typeof normalized.toUnsigned === "function"\n' +
44
+ '\t\t? normalized.toUnsigned()\n' +
45
+ '\t\t: typeof normalized.toSigned === "function"\n' +
46
+ '\t\t\t? normalized.toSigned()\n' +
47
+ '\t\t\t: normalized;\n' +
48
+ '\treturn prepared.toNumber();\n' +
49
+ '}\n\n'
21
50
 
22
- // Write back
23
- writeFileSync(filePath, content, 'utf8');
51
+ if (!content.includes('function longToString(')) {
52
+ const markerIndex = content.indexOf(marker)
53
+ if (markerIndex === -1) {
54
+ throw new Error('Unable to inject Long helpers: marker not found in WAProto index output')
55
+ }
24
56
 
25
- console.log(`✅ Fixed imports in ${filePath}`);
57
+ content = content.replace(marker, `${marker}${longToStringHelper}${longToNumberHelper}`)
58
+ } else {
59
+ const longToStringRegex = /function longToString\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
60
+ const longToNumberRegex = /function longToNumber\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
61
+
62
+ if (!longToStringRegex.test(content) || !longToNumberRegex.test(content)) {
63
+ throw new Error('Unable to update Long helpers: existing definitions not found')
64
+ }
65
+
66
+ content = content.replace(longToStringRegex, longToStringHelper)
67
+ content = content.replace(longToNumberRegex, longToNumberHelper)
68
+ }
69
+
70
+ const longPattern = /([ \t]+d\.(\w+) = )o\.longs === String \? \$util\.Long\.prototype\.toString\.call\(m\.\2\) : o\.longs === Number \? new \$util\.LongBits\(m\.\2\.low >>> 0, m\.\2\.high >>> 0\)\.toNumber\((true)?\) : m\.\2;/g
71
+ content = content.replace(longPattern, (_match, prefix, field, unsignedFlag) => {
72
+ const unsignedArg = unsignedFlag ? ', true' : ''
73
+ return `${prefix}o.longs === String ? longToString(m.${field}${unsignedArg}) : o.longs === Number ? longToNumber(m.${field}${unsignedArg}) : m.${field};`
74
+ })
75
+
76
+ writeFileSync(filePath, content, 'utf8')
77
+ console.log(`✅ Fixed imports in ${filePath}`)
26
78
  } catch (error) {
27
- console.error(`❌ Error fixing imports: ${error.message}`);
28
- exit(1);
79
+ console.error(`❌ Error fixing imports: ${error.message}`)
80
+ exit(1)
29
81
  }