@rizzkezik/bails 6.1.0

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 (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +535 -0
  3. package/WAProto/GenerateStatics.sh +3 -0
  4. package/WAProto/WAProto.proto +6902 -0
  5. package/WAProto/fix-imports.js +85 -0
  6. package/WAProto/index.d.ts +79257 -0
  7. package/WAProto/index.js +242946 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/index.js +130 -0
  10. package/lib/Signal/Group/ciphertext-message.js +12 -0
  11. package/lib/Signal/Group/group-session-builder.js +30 -0
  12. package/lib/Signal/Group/group_cipher.js +82 -0
  13. package/lib/Signal/Group/index.js +12 -0
  14. package/lib/Signal/Group/keyhelper.js +18 -0
  15. package/lib/Signal/Group/sender-chain-key.js +26 -0
  16. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  17. package/lib/Signal/Group/sender-key-message.js +66 -0
  18. package/lib/Signal/Group/sender-key-name.js +48 -0
  19. package/lib/Signal/Group/sender-key-record.js +41 -0
  20. package/lib/Signal/Group/sender-key-state.js +84 -0
  21. package/lib/Signal/Group/sender-message-key.js +26 -0
  22. package/lib/Signal/libsignal.js +431 -0
  23. package/lib/Signal/lid-mapping.js +277 -0
  24. package/lib/Socket/Client/index.js +3 -0
  25. package/lib/Socket/Client/types.js +11 -0
  26. package/lib/Socket/Client/websocket.js +54 -0
  27. package/lib/Socket/business.js +379 -0
  28. package/lib/Socket/chats.js +1193 -0
  29. package/lib/Socket/communities.js +431 -0
  30. package/lib/Socket/groups.js +374 -0
  31. package/lib/Socket/index.js +12 -0
  32. package/lib/Socket/luxu.js +387 -0
  33. package/lib/Socket/messages-recv.js +1916 -0
  34. package/lib/Socket/messages-send.js +1435 -0
  35. package/lib/Socket/mex.js +42 -0
  36. package/lib/Socket/newsletter.js +270 -0
  37. package/lib/Socket/socket.js +967 -0
  38. package/lib/Store/index.js +10 -0
  39. package/lib/Store/keyed-db.js +108 -0
  40. package/lib/Store/make-cache-manager-store.js +85 -0
  41. package/lib/Store/make-in-memory-store.js +198 -0
  42. package/lib/Store/make-ordered-dictionary.js +75 -0
  43. package/lib/Store/object-repository.js +32 -0
  44. package/lib/Types/Auth.js +2 -0
  45. package/lib/Types/Bussines.js +2 -0
  46. package/lib/Types/Call.js +2 -0
  47. package/lib/Types/Chat.js +8 -0
  48. package/lib/Types/Contact.js +2 -0
  49. package/lib/Types/Events.js +2 -0
  50. package/lib/Types/GroupMetadata.js +2 -0
  51. package/lib/Types/Label.js +25 -0
  52. package/lib/Types/LabelAssociation.js +7 -0
  53. package/lib/Types/Message.js +11 -0
  54. package/lib/Types/Mex.js +37 -0
  55. package/lib/Types/Product.js +2 -0
  56. package/lib/Types/Signal.js +2 -0
  57. package/lib/Types/Socket.js +3 -0
  58. package/lib/Types/State.js +56 -0
  59. package/lib/Types/USync.js +2 -0
  60. package/lib/Types/index.js +26 -0
  61. package/lib/Utils/auth-utils.js +302 -0
  62. package/lib/Utils/browser-utils.js +48 -0
  63. package/lib/Utils/business.js +231 -0
  64. package/lib/Utils/chat-utils.js +872 -0
  65. package/lib/Utils/companion-reg-client-utils.js +35 -0
  66. package/lib/Utils/crypto.js +118 -0
  67. package/lib/Utils/decode-wa-message.js +350 -0
  68. package/lib/Utils/event-buffer.js +622 -0
  69. package/lib/Utils/generics.js +403 -0
  70. package/lib/Utils/history.js +134 -0
  71. package/lib/Utils/identity-change-handler.js +50 -0
  72. package/lib/Utils/index.js +23 -0
  73. package/lib/Utils/link-preview.js +85 -0
  74. package/lib/Utils/logger.js +3 -0
  75. package/lib/Utils/lt-hash.js +8 -0
  76. package/lib/Utils/make-mutex.js +33 -0
  77. package/lib/Utils/message-composer.js +273 -0
  78. package/lib/Utils/message-retry-manager.js +265 -0
  79. package/lib/Utils/messages-media.js +788 -0
  80. package/lib/Utils/messages.js +1253 -0
  81. package/lib/Utils/noise-handler.js +201 -0
  82. package/lib/Utils/offline-node-processor.js +40 -0
  83. package/lib/Utils/pre-key-manager.js +106 -0
  84. package/lib/Utils/process-message.js +630 -0
  85. package/lib/Utils/reporting-utils.js +258 -0
  86. package/lib/Utils/signal.js +201 -0
  87. package/lib/Utils/stanza-ack.js +38 -0
  88. package/lib/Utils/sync-action-utils.js +49 -0
  89. package/lib/Utils/tc-token-utils.js +163 -0
  90. package/lib/Utils/use-multi-file-auth-state.js +121 -0
  91. package/lib/Utils/validate-connection.js +203 -0
  92. package/lib/WABinary/constants.js +1301 -0
  93. package/lib/WABinary/decode.js +262 -0
  94. package/lib/WABinary/encode.js +220 -0
  95. package/lib/WABinary/generic-utils.js +204 -0
  96. package/lib/WABinary/index.js +6 -0
  97. package/lib/WABinary/jid-utils.js +98 -0
  98. package/lib/WABinary/types.js +2 -0
  99. package/lib/WAM/BinaryInfo.js +10 -0
  100. package/lib/WAM/constants.js +22853 -0
  101. package/lib/WAM/encode.js +150 -0
  102. package/lib/WAM/index.js +4 -0
  103. package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -0
  104. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
  105. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  106. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  107. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  108. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  109. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  110. package/lib/WAUSync/Protocols/index.js +6 -0
  111. package/lib/WAUSync/USyncQuery.js +98 -0
  112. package/lib/WAUSync/USyncUser.js +31 -0
  113. package/lib/WAUSync/index.js +4 -0
  114. package/lib/index.js +31 -0
  115. package/package.json +143 -0
@@ -0,0 +1,85 @@
1
+ import { readFileSync, writeFileSync } from 'fs';
2
+ import { exit } from 'process';
3
+
4
+ const filePath = './index.js'
5
+
6
+ try {
7
+ let content = readFileSync(filePath, 'utf8')
8
+
9
+ content = content.replace(/import \* as (\$protobuf) from/g, 'import $1 from')
10
+ content = content.replace(/(['"])protobufjs\/minimal(['"])/g, '$1protobufjs/minimal.js$2')
11
+
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
+ '\t// Fast path: convert Long {low, high} directly via native BigInt\n' +
22
+ '\t// BigInt.toString() is a native C++ operation, much faster than Long\'s pure JS division loops\n' +
23
+ '\tif (value && typeof value.low === "number" && typeof value.high === "number") {\n' +
24
+ '\t\tconst lo = BigInt(value.low >>> 0);\n' +
25
+ '\t\tconst hi = BigInt(value.high >>> 0);\n' +
26
+ '\t\tconst combined = (hi << 32n) | lo;\n' +
27
+ '\t\tif (!unsigned && value.high < 0) {\n' +
28
+ '\t\t\treturn (combined - (1n << 64n)).toString();\n' +
29
+ '\t\t}\n' +
30
+ '\t\treturn combined.toString();\n' +
31
+ '\t}\n' +
32
+ '\treturn String(value);\n' +
33
+ '}\n\n'
34
+ const longToNumberHelper =
35
+ 'function longToNumber(value, unsigned) {\n' +
36
+ '\tif (typeof value === "number") {\n' +
37
+ '\t\treturn value;\n' +
38
+ '\t}\n' +
39
+ '\tif (typeof value === "string") {\n' +
40
+ '\t\treturn Number(value);\n' +
41
+ '\t}\n' +
42
+ '\t// Fast path: convert Long {low, high} directly via native BigInt\n' +
43
+ '\tif (value && typeof value.low === "number" && typeof value.high === "number") {\n' +
44
+ '\t\tconst lo = BigInt(value.low >>> 0);\n' +
45
+ '\t\tconst hi = BigInt(value.high >>> 0);\n' +
46
+ '\t\tconst combined = (hi << 32n) | lo;\n' +
47
+ '\t\tif (!unsigned && value.high < 0) {\n' +
48
+ '\t\t\treturn Number(combined - (1n << 64n));\n' +
49
+ '\t\t}\n' +
50
+ '\t\treturn Number(combined);\n' +
51
+ '\t}\n' +
52
+ '\treturn Number(value);\n' +
53
+ '}\n\n'
54
+
55
+ if (!content.includes('function longToString(')) {
56
+ const markerIndex = content.indexOf(marker)
57
+ if (markerIndex === -1) {
58
+ throw new Error('Unable to inject Long helpers: marker not found in WAProto index output')
59
+ }
60
+
61
+ content = content.replace(marker, `${marker}${longToStringHelper}${longToNumberHelper}`)
62
+ } else {
63
+ const longToStringRegex = /function longToString\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
64
+ const longToNumberRegex = /function longToNumber\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
65
+
66
+ if (!longToStringRegex.test(content) || !longToNumberRegex.test(content)) {
67
+ throw new Error('Unable to update Long helpers: existing definitions not found')
68
+ }
69
+
70
+ content = content.replace(longToStringRegex, longToStringHelper)
71
+ content = content.replace(longToNumberRegex, longToNumberHelper)
72
+ }
73
+
74
+ 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
75
+ content = content.replace(longPattern, (_match, prefix, field, unsignedFlag) => {
76
+ const unsignedArg = unsignedFlag ? ', true' : ''
77
+ return `${prefix}o.longs === String ? longToString(m.${field}${unsignedArg}) : o.longs === Number ? longToNumber(m.${field}${unsignedArg}) : m.${field};`
78
+ })
79
+
80
+ writeFileSync(filePath, content, 'utf8')
81
+ console.log(`✅ Fixed imports in ${filePath}`)
82
+ } catch (error) {
83
+ console.error(`❌ Error fixing imports: ${error.message}`)
84
+ exit(1)
85
+ }