@x4r1s3/baileys 0.0.0-stage → 1.0.1
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.
- package/LICENSE +21 -0
- package/README.md +1245 -2
- package/SECURITY.md +47 -0
- package/WAProto/V +1 -0
- package/WAProto/WAProto.proto +8892 -0
- package/WAProto/index.d.ts +104128 -0
- package/WAProto/index.js +334920 -0
- package/assets/rolling-circle.svg +133 -0
- package/assets/x4r1s3-banner.svg +32 -0
- package/engine-requirements.js +27 -0
- package/lib/Builders/A2UI.js +245 -0
- package/lib/Builders/AIRich.js +179 -0
- package/lib/Builders/Button.js +108 -0
- package/lib/Builders/CFC.js +284 -0
- package/lib/Builders/Carousel.js +81 -0
- package/lib/Call/THIRD_PARTY_LICENSE.txt +21 -0
- package/lib/Call/astralena-v3.mjs +96 -0
- package/lib/Call/audio-feeder.mjs +201 -0
- package/lib/Call/audio-recorder.mjs +250 -0
- package/lib/Call/fetch-wasm-resources.mjs +104 -0
- package/lib/Call/index.mjs +707 -0
- package/lib/Call/relay-transport.mjs +563 -0
- package/lib/Call/signaling.mjs +660 -0
- package/lib/Call/types.mjs +17 -0
- package/lib/Call/video-feeder.mjs +94 -0
- package/lib/Call/voip-resources.mjs +259 -0
- package/lib/Call/wasm-engine.mjs +1372 -0
- package/lib/Call/worker-bootstrap.mjs +1042 -0
- package/lib/Defaults/ban-checker.js +56 -0
- package/lib/Defaults/index.js +170 -0
- package/lib/Signal/Group/ciphertext-message.js +23 -0
- package/lib/Signal/Group/group-session-builder.js +41 -0
- package/lib/Signal/Group/group_cipher.js +93 -0
- package/lib/Signal/Group/index.js +23 -0
- package/lib/Signal/Group/keyhelper.js +29 -0
- package/lib/Signal/Group/sender-chain-key.js +37 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +74 -0
- package/lib/Signal/Group/sender-key-message.js +77 -0
- package/lib/Signal/Group/sender-key-name.js +59 -0
- package/lib/Signal/Group/sender-key-record.js +52 -0
- package/lib/Signal/Group/sender-key-state.js +95 -0
- package/lib/Signal/Group/sender-message-key.js +37 -0
- package/lib/Signal/libsignal.js +440 -0
- package/lib/Signal/lid-mapping.js +292 -0
- package/lib/Socket/Client/index.js +14 -0
- package/lib/Socket/Client/types.js +22 -0
- package/lib/Socket/Client/websocket.js +65 -0
- package/lib/Socket/aigroups.js +327 -0
- package/lib/Socket/ban-checker.js +165 -0
- package/lib/Socket/business.js +419 -0
- package/lib/Socket/chats.js +1921 -0
- package/lib/Socket/communities.js +443 -0
- package/lib/Socket/graphql.js +911 -0
- package/lib/Socket/groups.js +561 -0
- package/lib/Socket/index.js +49 -0
- package/lib/Socket/interactive-handler.js +612 -0
- package/lib/Socket/interop.js +575 -0
- package/lib/Socket/managed-account.js +220 -0
- package/lib/Socket/messages-recv.js +2193 -0
- package/lib/Socket/messages-send.js +4141 -0
- package/lib/Socket/mex.js +53 -0
- package/lib/Socket/newsletter.js +291 -0
- package/lib/Socket/privacy.js +458 -0
- package/lib/Socket/registration.js +440 -0
- package/lib/Socket/socket.js +1042 -0
- package/lib/Socket/status-actions.js +287 -0
- package/lib/Socket/username.js +241 -0
- package/lib/Store/index.js +16 -0
- package/lib/Store/make-cache-manager-store.js +101 -0
- package/lib/Store/make-in-memory-store.js +432 -0
- package/lib/Store/make-ordered-dictionary.js +90 -0
- package/lib/Store/object-repository.js +35 -0
- package/lib/Types/Auth.js +13 -0
- package/lib/Types/Bussines.js +13 -0
- package/lib/Types/Call.js +13 -0
- package/lib/Types/Chat.js +19 -0
- package/lib/Types/Contact.js +13 -0
- package/lib/Types/Events.js +13 -0
- package/lib/Types/GroupMetadata.js +13 -0
- package/lib/Types/Label.js +36 -0
- package/lib/Types/LabelAssociation.js +18 -0
- package/lib/Types/Message.js +30 -0
- package/lib/Types/Mex.js +53 -0
- package/lib/Types/Product.js +13 -0
- package/lib/Types/RichType.js +34 -0
- package/lib/Types/Signal.js +13 -0
- package/lib/Types/Socket.js +14 -0
- package/lib/Types/State.js +60 -0
- package/lib/Types/USync.js +13 -0
- package/lib/Types/index.js +37 -0
- package/lib/Utils/auth-utils.js +313 -0
- package/lib/Utils/ban-checker.js +48 -0
- package/lib/Utils/bot-capabilities.js +96 -0
- package/lib/Utils/bot-planning-replay.js +177 -0
- package/lib/Utils/browser-utils.js +40 -0
- package/lib/Utils/business.js +242 -0
- package/lib/Utils/c2582.js +147 -0
- package/lib/Utils/chat-utils.js +905 -0
- package/lib/Utils/companion-reg-client-utils.js +104 -0
- package/lib/Utils/consumer-application.js +114 -0
- package/lib/Utils/crypto.js +129 -0
- package/lib/Utils/decode-wa-message.js +496 -0
- package/lib/Utils/direct-chat-theme.js +164 -0
- package/lib/Utils/event-buffer.js +601 -0
- package/lib/Utils/experimental-proto.js +206 -0
- package/lib/Utils/games/miniapp.js +17 -0
- package/lib/Utils/games/slot-machine.js +270 -0
- package/lib/Utils/games/website-preview.js +306 -0
- package/lib/Utils/generics.js +402 -0
- package/lib/Utils/group-history.js +68 -0
- package/lib/Utils/group-wallpaper.js +168 -0
- package/lib/Utils/history.js +162 -0
- package/lib/Utils/identity-change-handler.js +60 -0
- package/lib/Utils/index.js +61 -0
- package/lib/Utils/jid-display-normalization.js +221 -0
- package/lib/Utils/link-preview.js +96 -0
- package/lib/Utils/logger.js +14 -0
- package/lib/Utils/lt-hash.js +19 -0
- package/lib/Utils/make-mutex.js +44 -0
- package/lib/Utils/message-composer.js +709 -0
- package/lib/Utils/message-inspect.js +79 -0
- package/lib/Utils/message-retry-manager.js +253 -0
- package/lib/Utils/message-security.js +167 -0
- package/lib/Utils/messages-media.js +1027 -0
- package/lib/Utils/messages.js +2467 -0
- package/lib/Utils/meta-ai-msmsg.js +215 -0
- package/lib/Utils/meta-compositing.js +239 -0
- package/lib/Utils/native-flow.js +158 -0
- package/lib/Utils/newsletter-live-update-utils.js +74 -0
- package/lib/Utils/newsletter-status-utils.js +152 -0
- package/lib/Utils/noise-handler.js +212 -0
- package/lib/Utils/offline-node-processor.js +51 -0
- package/lib/Utils/poll-manager.js +206 -0
- package/lib/Utils/portable-compat.js +12 -0
- package/lib/Utils/pre-key-manager.js +117 -0
- package/lib/Utils/process-message.js +610 -0
- package/lib/Utils/reporting-utils.js +269 -0
- package/lib/Utils/rich-message-utils.js +2841 -0
- package/lib/Utils/scheduled-message.js +107 -0
- package/lib/Utils/signal.js +212 -0
- package/lib/Utils/source-grep.js +57 -0
- package/lib/Utils/stanza-ack.js +49 -0
- package/lib/Utils/sticker-annotation.js +87 -0
- package/lib/Utils/sync-action-utils.js +59 -0
- package/lib/Utils/tc-token-utils.js +174 -0
- package/lib/Utils/use-multi-file-auth-state.js +132 -0
- package/lib/Utils/use-single-file-auth-state.js +108 -0
- package/lib/Utils/use-sqlite-auth-state.js +120 -0
- package/lib/Utils/validate-connection.js +221 -0
- package/lib/Utils/view-once-utils.js +218 -0
- package/lib/Utils/voip-rekey.js +32 -0
- package/lib/Utils/website-preview.js +27 -0
- package/lib/Utils/welcome-flow.js +228 -0
- package/lib/Utils/x4r1s3.js +144 -0
- package/lib/WABinary/constants.js +1475 -0
- package/lib/WABinary/decode.js +273 -0
- package/lib/WABinary/encode.js +231 -0
- package/lib/WABinary/generic-utils.js +242 -0
- package/lib/WABinary/index.js +17 -0
- package/lib/WABinary/jid-utils.js +107 -0
- package/lib/WABinary/types.js +13 -0
- package/lib/WAM/BinaryInfo.js +21 -0
- package/lib/WAM/constants.js +22864 -0
- package/lib/WAM/encode.js +161 -0
- package/lib/WAM/index.js +15 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +108 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +68 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +65 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +82 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +40 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +49 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +46 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +36 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +62 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +40 -0
- package/lib/WAUSync/Protocols/index.js +24 -0
- package/lib/WAUSync/USyncQuery.js +213 -0
- package/lib/WAUSync/USyncUser.js +66 -0
- package/lib/WAUSync/index.js +15 -0
- package/lib/antiban.cjs +4726 -0
- package/lib/index.d.ts +1895 -0
- package/lib/index.js +41 -0
- package/package.json +125 -4
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 X4R1S3x — @X4R1S3/baileys
|
|
3
|
+
*/
|
|
4
|
+
import { proto } from '../../WAProto/index.js';
|
|
5
|
+
import { jidDecode } from '../WABinary/jid-utils.js';
|
|
6
|
+
|
|
7
|
+
const supportedDestinationServers = new Set([
|
|
8
|
+
'c.us',
|
|
9
|
+
's.whatsapp.net',
|
|
10
|
+
'lid',
|
|
11
|
+
'hosted',
|
|
12
|
+
'hosted.lid',
|
|
13
|
+
'g.us'
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const getTargetId = target => {
|
|
17
|
+
const targetId = typeof target === 'string'
|
|
18
|
+
? target
|
|
19
|
+
: (target?.id || target?.stanzaId);
|
|
20
|
+
|
|
21
|
+
if (targetId === undefined || targetId === null || targetId === '') {
|
|
22
|
+
throw new Error('Missing message id to vanish');
|
|
23
|
+
}
|
|
24
|
+
if (typeof targetId !== 'string' || targetId.length > 256 || targetId.trim() !== targetId || /[\s\u0000-\u001f\u007f]/u.test(targetId)) {
|
|
25
|
+
throw new Error('Invalid target message id');
|
|
26
|
+
}
|
|
27
|
+
return targetId;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const isValidDestinationJid = jid => {
|
|
31
|
+
if (typeof jid !== 'string' || jid.length > 256 || jid.trim() !== jid || /[\s\u0000-\u001f\u007f]/u.test(jid)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const decoded = jidDecode(jid);
|
|
36
|
+
return Boolean(
|
|
37
|
+
decoded?.user &&
|
|
38
|
+
/^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(jid.slice(0, jid.indexOf('@'))) &&
|
|
39
|
+
supportedDestinationServers.has(decoded.server)
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const isMessageId = value => typeof value === 'string' && value.length > 0 && value.length <= 256 && value.trim() === value && !/[\s\u0000-\u001f\u007f]/u.test(value);
|
|
44
|
+
|
|
45
|
+
const groupStatusMessage = () => ({
|
|
46
|
+
groupStatusMessageV2: {
|
|
47
|
+
message: {
|
|
48
|
+
extendedTextMessage: {
|
|
49
|
+
text: '',
|
|
50
|
+
contextInfo: {
|
|
51
|
+
isGroupStatus: true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Relay the experimental C2582 protocol sequence for a target message.
|
|
60
|
+
* The connection's network methods are called directly, making the helper
|
|
61
|
+
* straightforward to exercise with mocks and safe to use with a socket.
|
|
62
|
+
*/
|
|
63
|
+
export const C2582 = async (conn, jid, target) => {
|
|
64
|
+
if (!isValidDestinationJid(jid)) {
|
|
65
|
+
throw new Error('Invalid destination JID for C2582');
|
|
66
|
+
}
|
|
67
|
+
const targetId = getTargetId(target);
|
|
68
|
+
if (!conn || typeof conn.relayMessage !== 'function' || typeof conn.sendMessage !== 'function') {
|
|
69
|
+
throw new TypeError('C2582 requires a connection with relayMessage and sendMessage methods');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const temporaryIds = [];
|
|
73
|
+
let relayError;
|
|
74
|
+
let relaysSucceeded = false;
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const tempId = await conn.relayMessage(jid, groupStatusMessage(), {});
|
|
78
|
+
if (!isMessageId(tempId)) {
|
|
79
|
+
throw new Error('C2582 first relay did not return a valid temporary message id');
|
|
80
|
+
}
|
|
81
|
+
temporaryIds.push(tempId);
|
|
82
|
+
|
|
83
|
+
const tempId2 = await conn.relayMessage(jid, {
|
|
84
|
+
protocolMessage: {
|
|
85
|
+
key: {
|
|
86
|
+
jid,
|
|
87
|
+
fromMe: true,
|
|
88
|
+
id: tempId
|
|
89
|
+
},
|
|
90
|
+
type: proto.Message.ProtocolMessage.Type.MESSAGE_EDIT,
|
|
91
|
+
editedMessage: groupStatusMessage()
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
messageId: targetId
|
|
95
|
+
});
|
|
96
|
+
if (!isMessageId(tempId2)) {
|
|
97
|
+
throw new Error('C2582 second relay did not return a valid temporary message id');
|
|
98
|
+
}
|
|
99
|
+
temporaryIds.push(tempId2);
|
|
100
|
+
relaysSucceeded = true;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
relayError = error;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (relaysSucceeded) {
|
|
107
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const cleanupResults = await Promise.allSettled(temporaryIds.map(id => Promise.resolve().then(() => conn.sendMessage(jid, {
|
|
111
|
+
delete: {
|
|
112
|
+
remoteJid: jid,
|
|
113
|
+
id,
|
|
114
|
+
fromMe: true
|
|
115
|
+
}
|
|
116
|
+
}))));
|
|
117
|
+
const cleanupErrors = cleanupResults
|
|
118
|
+
.filter(result => result.status === 'rejected')
|
|
119
|
+
.map(result => result.reason);
|
|
120
|
+
|
|
121
|
+
if (relayError) {
|
|
122
|
+
if (cleanupErrors.length > 0) {
|
|
123
|
+
throw new AggregateError(
|
|
124
|
+
[relayError, ...cleanupErrors],
|
|
125
|
+
'C2582 relay failed and temporary-message cleanup also failed',
|
|
126
|
+
{ cause: relayError }
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
throw relayError;
|
|
130
|
+
}
|
|
131
|
+
if (cleanupErrors.length > 0) {
|
|
132
|
+
throw new AggregateError(
|
|
133
|
+
cleanupErrors,
|
|
134
|
+
'C2582 protocol relays succeeded but temporary-message cleanup failed'
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
key: {
|
|
140
|
+
remoteJid: jid,
|
|
141
|
+
id: targetId
|
|
142
|
+
},
|
|
143
|
+
status: 'vanished'
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export default C2582;
|