@yemo-dev/yebail 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.
- package/EXAMPLES.md +641 -0
- package/LICENSE +21 -0
- package/README.md +141 -0
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.js +116311 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.js +142 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Defaults/yebail-version.json +7 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.js +29 -0
- package/lib/Signal/libsignal.js +196 -0
- package/lib/Signal/lid-mapping.js +148 -0
- package/lib/Socket/Client/index.js +18 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +72 -0
- package/lib/Socket/business.js +368 -0
- package/lib/Socket/chats.js +992 -0
- package/lib/Socket/communities.js +430 -0
- package/lib/Socket/groups.js +323 -0
- package/lib/Socket/index.js +10 -0
- package/lib/Socket/messages-recv.js +1133 -0
- package/lib/Socket/messages-send.js +992 -0
- package/lib/Socket/newsletter.js +250 -0
- package/lib/Socket/socket.js +631 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.js +8 -0
- package/lib/Store/make-in-memory-store.js +421 -0
- package/lib/Store/make-ordered-dictionary.js +81 -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 +4 -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 +7 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Product.js +2 -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 +42 -0
- package/lib/Utils/auth-utils.js +188 -0
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/business.js +230 -0
- package/lib/Utils/chat-utils.js +763 -0
- package/lib/Utils/crypto.js +187 -0
- package/lib/Utils/decode-wa-message.js +293 -0
- package/lib/Utils/event-buffer.js +514 -0
- package/lib/Utils/generics.js +453 -0
- package/lib/Utils/history.js +94 -0
- package/lib/Utils/index.js +37 -0
- package/lib/Utils/link-preview.js +121 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.js +47 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/message-retry-manager.js +128 -0
- package/lib/Utils/messages-media.js +910 -0
- package/lib/Utils/messages.js +1129 -0
- package/lib/Utils/noise-handler.js +150 -0
- package/lib/Utils/process-message.js +448 -0
- package/lib/Utils/signal.js +150 -0
- package/lib/Utils/use-custom-auth-state.js +110 -0
- package/lib/Utils/use-multi-file-auth-state.js +43 -0
- package/lib/Utils/use-sqlite-auth-state.js +39 -0
- package/lib/Utils/validate-connection.js +237 -0
- package/lib/Utils/yebail-event-stream.js +55 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.js +275 -0
- package/lib/WABinary/encode.js +250 -0
- package/lib/WABinary/generic-utils.js +110 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.js +136 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.js +89 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.js +46 -0
- package/package.json +114 -0
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# yebail
|
|
2
|
+
|
|
3
|
+
**yebails** is a high-performance, WebSocket-based WhatsApp Web API library. It is a specialized distribution of Baileys, optimized for stability and automated version tracking.
|
|
4
|
+
|
|
5
|
+
> [!TIP]
|
|
6
|
+
> This version is maintained with an **Auto-Update** system that tracks the latest WhatsApp Web revisions to ensure continuous compatibility.
|
|
7
|
+
|
|
8
|
+
## Important Note
|
|
9
|
+
|
|
10
|
+
This README is temporary. A new guide is currently in development and this file will be replaced.
|
|
11
|
+
|
|
12
|
+
## Disclaimer
|
|
13
|
+
|
|
14
|
+
This project is not affiliated with WhatsApp. Do not spam or use the library in ways that violate WhatsApp terms. Use at your own discretion.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
From npm:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install yebails
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
From GitHub:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install github:yemo-dev/baileys
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Import
|
|
31
|
+
|
|
32
|
+
After installing from GitHub, const {
|
|
33
|
+
default: makeWASocket,
|
|
34
|
+
DisconnectReason,
|
|
35
|
+
useMultiFileAuthState,
|
|
36
|
+
fetchLatestWaWebVersion
|
|
37
|
+
} = require('@yemo-dev/yebail')
|
|
38
|
+
|
|
39
|
+
From a local clone:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
const makeWASocket = require('./lib').default
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
TypeScript / ESM depends on your bundler.
|
|
46
|
+
|
|
47
|
+
## Complete send-message examples per feature
|
|
48
|
+
|
|
49
|
+
See **[EXAMPLES.md](./EXAMPLES.md)** — text, buttons, list, templates, **interactive** (quick reply, URL, copy, call, catalog, **PIX `payment_info`**, **`review_and_pay`**, single select, webview), media, polls, location, contacts, orders/products, payments, pin/keep, and more.
|
|
50
|
+
|
|
51
|
+
## Quick start
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import makeWASocket from 'yebail'
|
|
55
|
+
|
|
56
|
+
const sock = makeWASocket({
|
|
57
|
+
printQRInTerminal: true
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
sock.ev.on('creds.update', () => {
|
|
61
|
+
/* persist auth */
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Authentication storage (filesystem, SQLite, cloud DB)
|
|
66
|
+
|
|
67
|
+
yebails does **not** mandate where session data lives. Credentials and Signal keys are exposed as JSON via the same `state` / `saveCreds` API whether you use files, SQLite, or a remote database.
|
|
68
|
+
|
|
69
|
+
| API | Use case |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `useMultiFileAuthState(folder)` | Default: one JSON file per key on local disk (same as classic Baileys). |
|
|
72
|
+
| `useSqliteAuthState(pathToDb)` | Single local `.db` file (requires optional `better-sqlite3`). |
|
|
73
|
+
| `useCustomAuthState(adapter)` | **Any** backend: implement `get` / `set` / `remove` for string keys and JSON string values — Redis, MongoDB, Postgres, Supabase, Firebase, your own HTTP API, etc. |
|
|
74
|
+
|
|
75
|
+
`useCustomAuthState` keys match logical filenames (`creds.json`, `session-….json`, …); `fixAuthStorageKey` applies the same `/` → `__` and `:` → `-` normalization as the file backend.
|
|
76
|
+
|
|
77
|
+
For **cloud** storage, encrypt sensitive payloads at rest and restrict access to the credential namespace. Longer examples (Redis, HTTP, SQLite install) are in **[EXAMPLES.md](./EXAMPLES.md#authentication--database-persistence)**.
|
|
78
|
+
|
|
79
|
+
## Index
|
|
80
|
+
|
|
81
|
+
- [Code examples](./EXAMPLES.md)
|
|
82
|
+
- [Authentication storage (filesystem, SQLite, cloud DB)](#authentication-storage-filesystem-sqlite-cloud-db)
|
|
83
|
+
- [Country code and MCC](#country-code-and-mcc-mobile-country-code)
|
|
84
|
+
- [LID and addressing](#lid-and-addressing)
|
|
85
|
+
- [Import](#import)
|
|
86
|
+
- [Events](#events)
|
|
87
|
+
- [Sending messages](#sending-messages)
|
|
88
|
+
- [Modify messages](#modify-messages)
|
|
89
|
+
- [Newsletter](#newsletter)
|
|
90
|
+
- [Communities](#communities)
|
|
91
|
+
|
|
92
|
+
### Country code and MCC (mobile country code)
|
|
93
|
+
|
|
94
|
+
`DEFAULT_CONNECTION_CONFIG` includes `countryCode` (ISO 3166-1 alpha-2, default `US`). The client `UserAgent` `mcc` field is filled using the bundled `phonenumber-mcc.json` mapping: the international calling code is resolved with `libphonenumber-js` (`getCountryCallingCode`), then the MCC is read from `PHONENUMBER_MCC`.
|
|
95
|
+
|
|
96
|
+
Override explicitly with socket config `mcc` (string or number, digits only normalized to 3 characters). Export `PHONENUMBER_MCC` and `getMccForCountryIso2(iso2)` from the package defaults for custom use.
|
|
97
|
+
|
|
98
|
+
### LID and addressing
|
|
99
|
+
|
|
100
|
+
Message keys expose LID-related fields for bots and middleware:
|
|
101
|
+
|
|
102
|
+
| Field | Role |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| `key.senderLid` | Sender LID from stanza when present |
|
|
105
|
+
| `key.participantLid` | Group participant LID when present |
|
|
106
|
+
| `key.lid` | Alias: `senderLid \|\| participantLid` |
|
|
107
|
+
| `key.addressingMode` | `lid` or `pn` derived from stanza |
|
|
108
|
+
| `key.remoteJidAlt` | Alternate JID for 1:1 (e.g. PN when chat is LID-addressed) |
|
|
109
|
+
| `key.participantAlt` | Alternate JID for groups (mapped PN/LID context) |
|
|
110
|
+
|
|
111
|
+
Decryption uses `signalRepository.lidMapping` when available: PN/LID pairs from envelopes and `LID_MIGRATION_MAPPING_SYNC` are stored, sessions can migrate PN to LID, and the event `lid-mapping.update` is emitted with `{ lid, pn }` after migration sync.
|
|
112
|
+
|
|
113
|
+
Hosted identifiers (`@hosted`, `@hosted.lid`) are recognized in JID utilities and binary decoding.
|
|
114
|
+
|
|
115
|
+
### Events
|
|
116
|
+
|
|
117
|
+
Common `sock.ev` events:
|
|
118
|
+
|
|
119
|
+
- `messages.upsert`, `messages.update`, `messages.reaction`
|
|
120
|
+
- `groups.update`, `group-participants.update`
|
|
121
|
+
- `creds.update`, `call`
|
|
122
|
+
- `lid-mapping.update`
|
|
123
|
+
- `messaging-history.set`, `chats.phoneNumberShare`
|
|
124
|
+
|
|
125
|
+
Placeholder resend (unavailable messages) caches metadata by message id, merges PDO responses without a delayed duplicate `messages.upsert`, and avoids the previous `PEER_DATA` / `MESSAGE_EDIT` switch fall-through bug.
|
|
126
|
+
|
|
127
|
+
### Sending messages
|
|
128
|
+
|
|
129
|
+
Use `sock.sendMessage(jid, content, options)`. Details and per-payload examples are in **[EXAMPLES.md](./EXAMPLES.md)**.
|
|
130
|
+
|
|
131
|
+
### Modify messages
|
|
132
|
+
|
|
133
|
+
Send payload keys: `delete`, `edit`, `pin`, `keep`.
|
|
134
|
+
|
|
135
|
+
### Newsletter
|
|
136
|
+
|
|
137
|
+
Socket methods include: `subscribeNewsletterUpdates`, `newsletterReactionMode`, `newsletterUpdateDescription`, `newsletterUpdateName`, `newsletterUpdatePicture`, `newsletterRemovePicture`, `newsletterFollow`, `newsletterUnfollow`, `newsletterMute`, `newsletterUnmute`, `newsletterCreate`, `newsletterMetadata`, `newsletterAdminCount`, `newsletterChangeOwner`, `newsletterDemote`, `newsletterDelete`, `newsletterReactMessage`, `newsletterFetchMessages`, `newsletterFetchUpdates`.
|
|
138
|
+
|
|
139
|
+
### Communities
|
|
140
|
+
|
|
141
|
+
Socket methods include: `communityMetadata`, `communityCreate`, `communityCreateGroup`, `communityLeave`, `communityUpdateSubject`, `communityLinkGroup`, `communityUnlinkGroup`, `communityFetchLinkedGroups`, `communityRequestParticipantsList`, `communityRequestParticipantsUpdate`, `communityParticipantsUpdate`, `communityUpdateDescription`, `communityInviteCode`, `communityRevokeInvite`, `communityAcceptInvite`, `communityRevokeInviteV4`, `communityAcceptInviteV4`, `communityGetInviteInfo`, `communityToggleEphemeral`, `communitySettingUpdate`, `communityMemberAddMode`, `communityJoinApprovalMode`.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
yarn pbjs -t static-module -w commonjs -o ./WAProto/index.js ./WAProto/WAProto.proto;
|
|
2
|
+
yarn pbts -o ./WAProto/index.d.ts ./WAProto/index.js;
|
|
3
|
+
|
|
4
|
+
#protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=env=node,useOptionals=true,forceLong=long --ts_proto_out=. ./src/Binary/WAMessage.proto;
|