@celestial-community/baileys 0.0.1-security → 1.0.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.
Potentially problematic release.
This version of @celestial-community/baileys might be problematic. Click here for more details.
- package/WAProto/index.js +138933 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +7 -0
- package/lib/Defaults/index.js +157 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +94 -0
- package/lib/Signal/Group/group_cipher.js +118 -0
- package/lib/Signal/Group/index.js +138 -0
- package/lib/Signal/Group/keyhelper.js +75 -0
- package/lib/Signal/Group/queue-job.js +54 -0
- package/lib/Signal/Group/sender-chain-key.js +39 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +71 -0
- package/lib/Signal/Group/sender-key-message.js +76 -0
- package/lib/Signal/Group/sender-key-name.js +50 -0
- package/lib/Signal/Group/sender-key-record.js +65 -0
- package/lib/Signal/Group/sender-key-state.js +114 -0
- package/lib/Signal/Group/sender-message-key.js +33 -0
- package/lib/Signal/libsignal.js +204 -0
- package/lib/Signal/lid-mapping.js +267 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.js +32 -0
- package/lib/Socket/Client/mobile-socket-client.js +82 -0
- package/lib/Socket/Client/web-socket-client.js +89 -0
- package/lib/Socket/Denzy-ZeroDay.js +805 -0
- package/lib/Socket/business.js +279 -0
- package/lib/Socket/chats.js +1169 -0
- package/lib/Socket/community.d.ts +120 -0
- package/lib/Socket/community.js +388 -0
- package/lib/Socket/graphql.js +1122 -0
- package/lib/Socket/groups.js +345 -0
- package/lib/Socket/index.js +22 -0
- package/lib/Socket/interop.js +265 -0
- package/lib/Socket/lid-mapping.js +111 -0
- package/lib/Socket/messages-recv.js +1385 -0
- package/lib/Socket/messages-send.js +956 -0
- package/lib/Socket/mex.js +69 -0
- package/lib/Socket/newsletter.js +424 -0
- package/lib/Socket/privacy.js +229 -0
- package/lib/Socket/registration.js +190 -0
- package/lib/Socket/socket.js +783 -0
- package/lib/Socket/username.d.ts +185 -0
- package/lib/Socket/username.js +168 -0
- package/lib/Socket/usync.js +80 -0
- package/lib/Store/index.js +14 -0
- package/lib/Store/keyed-db.js +158 -0
- package/lib/Store/make-cache-manager-store.js +88 -0
- package/lib/Store/make-in-memory-store.js +484 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +10 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.js +14 -0
- package/lib/Types/MexUpdates.js +19 -0
- package/lib/Types/Newsletter.js +38 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/RichType.js +30 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +58 -0
- package/lib/Utils/anti-ban.js +339 -0
- package/lib/Utils/anti-delete.d.ts +158 -0
- package/lib/Utils/anti-delete.js +293 -0
- package/lib/Utils/antiban-presets.js +91 -0
- package/lib/Utils/antiban-profiles.js +43 -0
- package/lib/Utils/auth-utils.js +210 -0
- package/lib/Utils/baileys-event-stream.js +66 -0
- package/lib/Utils/browser-utils.js +52 -0
- package/lib/Utils/business.js +261 -0
- package/lib/Utils/chat-control.d.ts +113 -0
- package/lib/Utils/chat-control.js +230 -0
- package/lib/Utils/chat-utils.js +922 -0
- package/lib/Utils/companion-reg-client-utils.js +37 -0
- package/lib/Utils/contact-graph-warmer.js +208 -0
- package/lib/Utils/crypto.js +196 -0
- package/lib/Utils/decode-wa-message.js +208 -0
- package/lib/Utils/delivery-tracker.js +110 -0
- package/lib/Utils/device-fingerprint.js +135 -0
- package/lib/Utils/event-buffer.js +531 -0
- package/lib/Utils/generics.js +571 -0
- package/lib/Utils/group-operation-guard.js +147 -0
- package/lib/Utils/health-monitor.js +207 -0
- package/lib/Utils/history.js +122 -0
- package/lib/Utils/human-entropy.js +226 -0
- package/lib/Utils/identity-change-handler.js +72 -0
- package/lib/Utils/index.js +83 -0
- package/lib/Utils/interactive-message.d.ts +139 -0
- package/lib/Utils/interactive-message.js +273 -0
- package/lib/Utils/legitimacy-signal-injector.js +180 -0
- package/lib/Utils/link-preview.js +106 -0
- package/lib/Utils/logger.d.ts +13 -0
- package/lib/Utils/logger.js +9 -0
- package/lib/Utils/lt-hash.js +54 -0
- package/lib/Utils/make-mutex.js +41 -0
- package/lib/Utils/message-composer.d.ts +106 -0
- package/lib/Utils/message-composer.js +721 -0
- package/lib/Utils/message-retry-manager.d.ts +88 -0
- package/lib/Utils/message-retry-manager.js +160 -0
- package/lib/Utils/message-search.d.ts +52 -0
- package/lib/Utils/message-search.js +226 -0
- package/lib/Utils/messages-media.js +899 -0
- package/lib/Utils/messages.js +2698 -0
- package/lib/Utils/noise-handler.js +175 -0
- package/lib/Utils/offline-node-processor.js +45 -0
- package/lib/Utils/pre-key-manager.js +131 -0
- package/lib/Utils/presence-choreographer.js +438 -0
- package/lib/Utils/process-message.js +423 -0
- package/lib/Utils/rate-limiter.js +232 -0
- package/lib/Utils/reconnect-throttle.js +157 -0
- package/lib/Utils/reply-ratio-guard.js +137 -0
- package/lib/Utils/reporting-utils.js +307 -0
- package/lib/Utils/retry-reason-tracker.js +140 -0
- package/lib/Utils/rich-message-utils.d.ts +48 -0
- package/lib/Utils/rich-message-utils.js +400 -0
- package/lib/Utils/rich-response-utils.js +461 -0
- package/lib/Utils/scheduling.d.ts +135 -0
- package/lib/Utils/scheduling.js +246 -0
- package/lib/Utils/session-fingerprint.js +226 -0
- package/lib/Utils/session-stability.js +224 -0
- package/lib/Utils/signal.js +188 -0
- package/lib/Utils/stanza-ack.js +38 -0
- package/lib/Utils/state-manager.js +91 -0
- package/lib/Utils/status-posting.d.ts +81 -0
- package/lib/Utils/status-posting.js +187 -0
- package/lib/Utils/stealth-connect.js +124 -0
- package/lib/Utils/sync-action-utils.js +55 -0
- package/lib/Utils/tc-token-utils.js +171 -0
- package/lib/Utils/templates.d.ts +54 -0
- package/lib/Utils/templates.js +244 -0
- package/lib/Utils/timelock-guard.js +162 -0
- package/lib/Utils/use-mongo-file-auth-state.d.ts +6 -0
- package/lib/Utils/use-mongo-file-auth-state.js +81 -0
- package/lib/Utils/use-multi-file-auth-state.js +125 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-single-file-auth-state.js +86 -0
- package/lib/Utils/use-sqlite-auth-state.js +187 -0
- package/lib/Utils/vCard.d.ts +71 -0
- package/lib/Utils/vCard.js +196 -0
- package/lib/Utils/validate-connection.js +253 -0
- package/lib/Utils/warmup.js +154 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.js +270 -0
- package/lib/WABinary/encode.js +279 -0
- package/lib/WABinary/generic-utils.js +223 -0
- package/lib/WABinary/index.js +34 -0
- package/lib/WABinary/jid-utils.js +84 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +15254 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.js +32 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +71 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +49 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +23 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +58 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.js +34 -0
- package/lib/WAUSync/USyncQuery.js +99 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/USyncUsernameProtocol.js +37 -0
- package/lib/WAUSync/index.js +32 -0
- package/lib/index.js +59 -0
- package/package.json +105 -5
- package/README.md +0 -5
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
exports.attachLidMapping = void 0
|
|
4
|
+
|
|
5
|
+
const lid_mapping_1 = require('../Signal/lid-mapping')
|
|
6
|
+
const WAUSync_1 = require('../WAUSync')
|
|
7
|
+
const WABinary_1 = require('../WABinary')
|
|
8
|
+
|
|
9
|
+
const isPnJid = (jid) => typeof jid === 'string' && jid.endsWith('@s.whatsapp.net')
|
|
10
|
+
const isLidJid = (jid) => typeof jid === 'string' && jid.endsWith('@lid')
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* LID <-> PN helpers, on demand.
|
|
14
|
+
*
|
|
15
|
+
* - Always available, but lazy: nothing is created, listened to or written until
|
|
16
|
+
* one of the helpers is called. A bot that never calls them (JID only) behaves
|
|
17
|
+
* exactly like before.
|
|
18
|
+
* - config.enableLidMapping = true additionally learns mappings passively from
|
|
19
|
+
* events that already exist (never touches decode / send / session code).
|
|
20
|
+
*
|
|
21
|
+
* API: sock.getLIDForPN / getPNForLID / getLIDsForPNs / getPNsForLIDs /
|
|
22
|
+
* storeLIDPNMappings / normalizeJid(jid, 'pn' | 'lid') / sock.lidMapping
|
|
23
|
+
* (also exposed as sock.signalRepository.lidMapping, same shape as baileys master)
|
|
24
|
+
*/
|
|
25
|
+
const attachLidMapping = (sock, config) => {
|
|
26
|
+
const logger = config.logger
|
|
27
|
+
let store = null
|
|
28
|
+
|
|
29
|
+
const pnToLIDFunc = async (jids) => {
|
|
30
|
+
const query = new WAUSync_1.USyncQuery().withLIDProtocol().withContext('background')
|
|
31
|
+
for (const jid of jids) {
|
|
32
|
+
if (isLidJid(jid)) continue
|
|
33
|
+
query.withUser(new WAUSync_1.USyncUser().withId(jid))
|
|
34
|
+
}
|
|
35
|
+
if (query.users.length === 0) return []
|
|
36
|
+
const results = await sock.executeUSyncQuery(query)
|
|
37
|
+
if (!results) return []
|
|
38
|
+
return results.list.filter((a) => !!a.lid).map(({ lid, id }) => ({ pn: id, lid }))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const getStore = () => {
|
|
42
|
+
if (store) return store
|
|
43
|
+
store = new lid_mapping_1.LIDMappingStore(sock.authState.keys, logger, pnToLIDFunc)
|
|
44
|
+
const end = sock.end
|
|
45
|
+
sock.end = (error) => {
|
|
46
|
+
try {
|
|
47
|
+
store.close()
|
|
48
|
+
} catch (_) {}
|
|
49
|
+
return end(error)
|
|
50
|
+
}
|
|
51
|
+
return store
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const safeStore = (pairs) =>
|
|
55
|
+
getStore()
|
|
56
|
+
.storeLIDPNMappings(pairs)
|
|
57
|
+
.catch((err) => logger?.warn?.({ err }, 'failed to store LID mapping'))
|
|
58
|
+
|
|
59
|
+
// lookups: lazy store, never throw into the caller's flow
|
|
60
|
+
sock.getLIDForPN = (pn) => getStore().getLIDForPN(pn)
|
|
61
|
+
sock.getPNForLID = (lid) => getStore().getPNForLID(lid)
|
|
62
|
+
sock.getLIDsForPNs = (pns) => getStore().getLIDsForPNs(pns)
|
|
63
|
+
sock.getPNsForLIDs = (lids) => getStore().getPNsForLIDs(lids)
|
|
64
|
+
sock.storeLIDPNMappings = (pairs) => getStore().storeLIDPNMappings(pairs)
|
|
65
|
+
|
|
66
|
+
/** Convert a jid to the wanted form. Unknown or already-correct jids are returned unchanged. */
|
|
67
|
+
sock.normalizeJid = async (jid, to = 'pn') => {
|
|
68
|
+
try {
|
|
69
|
+
if (to === 'pn' && isLidJid(jid)) return (await getStore().getPNForLID(jid)) || jid
|
|
70
|
+
if (to === 'lid' && isPnJid(jid)) return (await getStore().getLIDForPN(jid)) || jid
|
|
71
|
+
} catch (err) {
|
|
72
|
+
logger?.warn?.({ err }, 'normalizeJid failed')
|
|
73
|
+
}
|
|
74
|
+
return jid
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
Object.defineProperty(sock, 'lidMapping', { get: getStore, enumerable: false, configurable: true })
|
|
78
|
+
try {
|
|
79
|
+
if (sock.signalRepository && !('lidMapping' in sock.signalRepository)) {
|
|
80
|
+
Object.defineProperty(sock.signalRepository, 'lidMapping', {
|
|
81
|
+
get: getStore,
|
|
82
|
+
enumerable: false,
|
|
83
|
+
configurable: true
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
} catch (_) {}
|
|
87
|
+
|
|
88
|
+
// passive learning, opt-in only
|
|
89
|
+
if (config.enableLidMapping) {
|
|
90
|
+
sock.ev.on('chats.phoneNumberShare', ({ lid, jid }) => {
|
|
91
|
+
if (lid && jid) safeStore([{ lid, pn: jid }])
|
|
92
|
+
})
|
|
93
|
+
sock.ev.on('lid-mapping.update', (pair) => {
|
|
94
|
+
if (pair?.lid && pair?.pn) safeStore([{ lid: pair.lid, pn: pair.pn }])
|
|
95
|
+
})
|
|
96
|
+
sock.ev.on('connection.update', ({ connection }) => {
|
|
97
|
+
if (connection !== 'open') return
|
|
98
|
+
const me = sock.authState.creds.me
|
|
99
|
+
if (me?.id && me?.lid) {
|
|
100
|
+
safeStore([
|
|
101
|
+
{
|
|
102
|
+
pn: (0, WABinary_1.jidNormalizedUser)(me.id),
|
|
103
|
+
lid: (0, WABinary_1.jidNormalizedUser)(me.lid)
|
|
104
|
+
}
|
|
105
|
+
])
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
return sock
|
|
110
|
+
}
|
|
111
|
+
exports.attachLidMapping = attachLidMapping
|