miaw-core 0.9.0 → 1.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.
@@ -0,0 +1,316 @@
1
+ # API Stability Review - v1.0.0
2
+
3
+ This document reviews the Miaw Core API surface for stability and readiness for v1.0.0 release.
4
+
5
+ **Review Date:** 2025-12-24
6
+ **Target Version:** v1.0.0
7
+ **Current Version:** v0.9.1
8
+
9
+ ---
10
+
11
+ ## API Surface Summary
12
+
13
+ | Category | Public Methods | Status | Notes |
14
+ |----------|---------------|--------|-------|
15
+ | Core Client | 7 | ✅ Stable | No breaking changes planned |
16
+ | Messaging | 6 | ✅ Stable | Well-tested |
17
+ | Media | 5 | ✅ Stable | Handles all media types |
18
+ | Contact Info | 5 | ✅ Stable | Good coverage |
19
+ | Group Management | 11 | ✅ Stable | Full admin capabilities |
20
+ | Profile Management | 4 | ✅ Stable | Complete feature set |
21
+ | Label Operations | 5 | ✅ Stable | Business only |
22
+ | Catalog Operations | 5 | ✅ Stable | Business only |
23
+ | Newsletter Operations | 17 | ✅ Stable | Comprehensive |
24
+ | Contact Management | 2 | ✅ Stable | Basic CRUD |
25
+ | LID Mapping | 6 | ✅ Stable | Enhanced with LRU cache |
26
+ | UX Features | 8 | ✅ Stable | Typing, presence, read receipts |
27
+ | **Total** | **81** | **✅ Stable** | |
28
+
29
+ ---
30
+
31
+ ## Detailed API Review
32
+
33
+ ### Core Client Methods
34
+
35
+ | Method | Signature | Stability | Breaking Changes Possible? |
36
+ |--------|-----------|-----------|---------------------------|
37
+ | `constructor` | `(options: MiawClientOptions)` | ✅ Stable | No |
38
+ | `connect` | `(): Promise<void>` | ✅ Stable | No |
39
+ | `disconnect` | `(): Promise<void>` | ✅ Stable | No |
40
+ | `dispose` | `(): Promise<void>` | ✅ Stable | No |
41
+ | `getConnectionState` | `(): ConnectionState` | ✅ Stable | No |
42
+ | `getInstanceId` | `(): string` | ✅ Stable | No |
43
+ | `isConnected` | `(): boolean` | ✅ Stable | No |
44
+
45
+ **Assessment:** All core methods are stable. `dispose()` is new in v0.9.1 and recommended for cleanup.
46
+
47
+ ---
48
+
49
+ ### Messaging Methods
50
+
51
+ | Method | Signature | Stability | Notes |
52
+ |--------|-----------|-----------|-------|
53
+ | `sendText` | `(to, text, options?)` | ✅ Stable | Supports quoting |
54
+ | `sendImage` | `(to, media, options?)` | ✅ Stable | Caption, view-once |
55
+ | `sendDocument` | `(to, media, options?)` | ✅ Stable | Auto-mimetype |
56
+ | `sendVideo` | `(to, media, options?)` | ✅ Stable | GIF, PTV support |
57
+ | `sendAudio` | `(to, media, options?)` | ✅ Stable | PTT support |
58
+ | `downloadMedia` | `(message)` | ✅ Stable | Returns Buffer |
59
+
60
+ **Assessment:** All messaging methods follow consistent patterns. Return types are stable.
61
+
62
+ ---
63
+
64
+ ### Reaction & Forward Methods
65
+
66
+ | Method | Signature | Stability | Notes |
67
+ |--------|-----------|-----------|-------|
68
+ | `sendReaction` | `(messageId, chatId, emoji)` | ✅ Stable | - |
69
+ | `removeReaction` | `(message)` | ✅ Stable | - |
70
+ | `forwardMessage` | `(to, message)` | ✅ Stable | - |
71
+ | `editMessage` | `(messageId, chatId, text)` | ✅ Stable | 15-min window |
72
+ | `deleteMessage` | `(message, chatId?)` | ✅ Stable | For everyone |
73
+ | `deleteMessageForMe` | `(messageId, chatId)` | ✅ Stable | Local only |
74
+
75
+ **Assessment:** All methods work as documented. No breaking changes expected.
76
+
77
+ ---
78
+
79
+ ### Contact & Group Info Methods
80
+
81
+ | Method | Signature | Stability | Notes |
82
+ |--------|-----------|-----------|-------|
83
+ | `checkNumber` | `(phone)` | ✅ Stable | - |
84
+ | `checkNumbers` | `(phones[])` | ✅ Stable | Batch check |
85
+ | `getContactInfo` | `(jidOrPhone)` | ✅ Stable | - |
86
+ | `getBusinessProfile` | `(jidOrPhone)` | ✅ Stable | Business only |
87
+ | `getProfilePicture` | `(jidOrPhone, type?)` | ✅ Stable | low/high res |
88
+ | `getGroupInfo` | `(groupJid)` | ✅ Stable | - |
89
+ | `getGroupParticipants` | `(groupJid)` | ✅ Stable | - |
90
+
91
+ **Assessment:** All info-getting methods are stable. Return types are well-defined.
92
+
93
+ ---
94
+
95
+ ### Group Management Methods
96
+
97
+ | Method | Signature | Stability | Notes |
98
+ |--------|-----------|-----------|-------|
99
+ | `createGroup` | `(name, participants[])` | ✅ Stable | Returns group JID |
100
+ | `addParticipants` | `(groupJid, phones[])` | ✅ Stable | Requires admin |
101
+ | `removeParticipants` | `(groupJid, phones[])` | ✅ Stable | Requires admin |
102
+ | `leaveGroup` | `(groupJid)` | ✅ Stable | - |
103
+ | `promoteToAdmin` | `(groupJid, phones[])` | ✅ Stable | Requires admin |
104
+ | `demoteFromAdmin` | `(groupJid, phones[])` | ✅ Stable | Requires admin |
105
+ | `updateGroupName` | `(groupJid, name)` | ✅ Stable | Requires admin |
106
+ | `updateGroupDescription` | `(groupJid, desc?)` | ✅ Stable | Requires admin |
107
+ | `updateGroupPicture` | `(groupJid, media)` | ✅ Stable | Requires admin |
108
+ | `getGroupInviteLink` | `(groupJid)` | ✅ Stable | Requires admin |
109
+ | `revokeGroupInvite` | `(groupJid)` | ✅ Stable | Requires admin |
110
+ | `acceptGroupInvite` | `(inviteCode)` | ✅ Stable | - |
111
+ | `getGroupInviteInfo` | `(inviteCode)` | ✅ Stable | Preview |
112
+
113
+ **Assessment:** All group methods are stable. Admin requirements are documented.
114
+
115
+ ---
116
+
117
+ ### Profile Management Methods
118
+
119
+ | Method | Signature | Stability | Notes |
120
+ |--------|-----------|-----------|-------|
121
+ | `updateProfilePicture` | `(media)` | ✅ Stable | path/URL/Buffer |
122
+ | `removeProfilePicture` | `()` | ✅ Stable | - |
123
+ | `updateProfileName` | `(name)` | ✅ Stable | Push name |
124
+ | `updateProfileStatus` | `(status)` | ✅ Stable | About text |
125
+
126
+ **Assessment:** All profile methods are stable.
127
+
128
+ ---
129
+
130
+ ### Label Methods (WhatsApp Business)
131
+
132
+ | Method | Signature | Stability | Notes |
133
+ |--------|-----------|-----------|-------|
134
+ | `addLabel` | `(label)` | ✅ Stable | - |
135
+ | `addChatLabel` | `(chatJid, labelId)` | ✅ Stable | - |
136
+ | `removeChatLabel` | `(chatJid, labelId)` | ✅ Stable | - |
137
+ | `addMessageLabel` | `(msgId, chatId, labelId)` | ✅ Stable | - |
138
+ | `removeMessageLabel` | `(msgId, chatId, labelId)` | ✅ Stable | - |
139
+
140
+ **Assessment:** All label methods are stable. Business account required.
141
+
142
+ ---
143
+
144
+ ### Catalog Methods (WhatsApp Business)
145
+
146
+ | Method | Signature | Stability | Notes |
147
+ |--------|-----------|-----------|-------|
148
+ | `getCatalog` | `(businessJid?, limit?, cursor?)` | ✅ Stable | Paginated |
149
+ | `getCollections` | `(businessJid?, limit?)` | ✅ Stable | - |
150
+ | `createProduct` | `(options)` | ✅ Stable | - |
151
+ | `updateProduct` | `(productId, options)` | ✅ Stable | - |
152
+ | `deleteProducts` | `(productIds[])` | ✅ Stable | Batch delete |
153
+
154
+ **Assessment:** All catalog methods are stable. Business account required.
155
+
156
+ ---
157
+
158
+ ### Newsletter Methods
159
+
160
+ | Method | Signature | Stability | Notes |
161
+ |--------|-----------|-----------|-------|
162
+ | `createNewsletter` | `(name, description?)` | ✅ Stable | - |
163
+ | `getNewsletterMetadata` | `(newsletterId)` | ✅ Stable | - |
164
+ | `followNewsletter` | `(newsletterId)` | ✅ Stable | - |
165
+ | `unfollowNewsletter` | `(newsletterId)` | ✅ Stable | - |
166
+ | `muteNewsletter` | `(newsletterId)` | ✅ Stable | - |
167
+ | `unmuteNewsletter` | `(newsletterId)` | ✅ Stable | - |
168
+ | `updateNewsletterName` | `(newsletterId, name)` | ✅ Stable | - |
169
+ | `updateNewsletterDescription` | `(newsletterId, desc)` | ✅ Stable | - |
170
+ | `updateNewsletterPicture` | `(newsletterId, media)` | ✅ Stable | - |
171
+ | `removeNewsletterPicture` | `(newsletterId)` | ✅ Stable | - |
172
+ | `reactToNewsletterMessage` | `(newsletterId, msgId, emoji)` | ✅ Stable | - |
173
+ | `fetchNewsletterMessages` | `(newsletterId, limit?, cursor?)` | ✅ Stable | Paginated |
174
+ | `subscribeNewsletterUpdates` | `(newsletterId)` | ✅ Stable | - |
175
+ | `getNewsletterSubscribers` | `(newsletterId)` | ✅ Stable | - |
176
+ | `getNewsletterAdminCount` | `(newsletterId)` | ✅ Stable | - |
177
+ | `changeNewsletterOwner` | `(newsletterId, newOwner)` | ✅ Stable | - |
178
+ | `demoteNewsletterAdmin` | `(newsletterId, adminJid)` | ✅ Stable | - |
179
+ | `deleteNewsletter` | `(newsletterId)` | ✅ Stable | - |
180
+
181
+ **Assessment:** All newsletter methods are stable. Comprehensive coverage.
182
+
183
+ ---
184
+
185
+ ### Contact Management Methods
186
+
187
+ | Method | Signature | Stability | Notes |
188
+ |--------|-----------|-----------|-------|
189
+ | `addOrEditContact` | `(contact)` | ✅ Stable | Upsert operation |
190
+ | `removeContact` | `(phone)` | ✅ Stable | - |
191
+
192
+ **Assessment:** Contact methods are stable and simple.
193
+
194
+ ---
195
+
196
+ ### LID Mapping Methods
197
+
198
+ | Method | Signature | Stability | Notes |
199
+ |--------|-----------|-----------|-------|
200
+ | `resolveLidToJid` | `(lid)` | ✅ Stable | - |
201
+ | `getPhoneFromJid` | `(jid)` | ✅ Stable | - |
202
+ | `registerLidMapping` | `(lid, phoneJid)` | ✅ Stable | - |
203
+ | `getLidMappings` | `()` | ⚠️ Changed | Returns Record instead of Map (v0.9.1) |
204
+ | `getLidCacheSize` | `()` | ✅ New (v0.9.1) | - |
205
+ | `clearLidCache` | `()` | ✅ New (v0.9.1) | - |
206
+
207
+ **Assessment:** Mostly stable. `getLidMappings()` return type changed in v0.9.1 - documented in migration guide.
208
+
209
+ ---
210
+
211
+ ### UX Feature Methods
212
+
213
+ | Method | Signature | Stability | Notes |
214
+ |--------|-----------|-----------|-------|
215
+ | `markAsRead` | `(message)` | ✅ Stable | - |
216
+ | `sendTyping` | `(to)` | ✅ Stable | - |
217
+ | `sendRecording` | `(to)` | ✅ Stable | - |
218
+ | `stopTyping` | `(to)` | ✅ Stable | - |
219
+ | `setPresence` | `(status)` | ✅ Stable | - |
220
+ | `subscribePresence` | `(jidOrPhone)` | ✅ Stable | - |
221
+
222
+ **Assessment:** All UX methods are stable.
223
+
224
+ ---
225
+
226
+ ## Events
227
+
228
+ | Event | Payload | Stability | Notes |
229
+ |-------|---------|-----------|-------|
230
+ | `qr` | `(qrCode: string)` | ✅ Stable | - |
231
+ | `ready` | `()` | ✅ Stable | - |
232
+ | `message` | `(MiawMessage)` | ✅ Stable | - |
233
+ | `message_edit` | `(MessageEdit)` | ✅ Stable | - |
234
+ | `message_delete` | `(MessageDelete)` | ✅ Stable | - |
235
+ | `message_reaction` | `(MessageReaction)` | ✅ Stable | - |
236
+ | `presence` | `(PresenceUpdate)` | ✅ Stable | - |
237
+ | `connection` | `(ConnectionState)` | ✅ Stable | - |
238
+ | `disconnected` | `(reason?)` | ✅ Stable | - |
239
+ | `reconnecting` | `(attempt: number)` | ✅ Stable | - |
240
+ | `error` | `(Error)` | ✅ Stable | - |
241
+ | `session_saved` | `()` | ✅ Stable | - |
242
+
243
+ **Assessment:** All events are stable. No breaking changes expected.
244
+
245
+ ---
246
+
247
+ ## Types
248
+
249
+ All exported types are stable:
250
+
251
+ - ✅ `MiawClientOptions`
252
+ - ✅ `MiawMessage`
253
+ - ✅ `MediaInfo`
254
+ - ✅ `ConnectionState`
255
+ - ✅ `SendTextOptions`, `SendImageOptions`, etc.
256
+ - ✅ `SendMessageResult`
257
+ - ✅ `CheckNumberResult`
258
+ - ✅ `ContactInfo`, `BusinessProfile`
259
+ - ✅ `GroupInfo`, `GroupParticipant`
260
+ - ✅ `MessageEdit`, `MessageDelete`, `MessageReaction`
261
+ - ✅ `PresenceStatus`, `PresenceUpdate`
262
+ - ✅ Group management types
263
+ - ✅ Profile management types
264
+ - ✅ Label types
265
+ - ✅ Catalog/Product types
266
+ - ✅ Newsletter types
267
+ - ✅ Contact types
268
+
269
+ ---
270
+
271
+ ## Breaking Changes History
272
+
273
+ | Version | Change | Migration Path |
274
+ |---------|--------|----------------|
275
+ | v0.9.1 | `getLidMappings()` returns `Record<string, string>` instead of `Map` | Use `Object.entries()` or Object methods |
276
+ | v1.0.0 | No breaking changes planned | N/A |
277
+
278
+ ---
279
+
280
+ ## Recommendations for v1.0.0
281
+
282
+ ### ✅ Approved for v1.0.0
283
+
284
+ 1. **API is stable** - 81 public methods, all well-tested
285
+ 2. **Types are comprehensive** - Full TypeScript coverage
286
+ 3. **Events are consistent** - No breaking changes expected
287
+ 4. **Documentation is complete** - USAGE.md, examples, migration guide
288
+ 5. **Tests are comprehensive** - 68 unit tests + integration tests
289
+
290
+ ### 📝 Minor Notes
291
+
292
+ 1. `getLidMappings()` return type changed in v0.9.1 - documented in migration guide
293
+ 2. `dispose()` is new and recommended for cleanup
294
+ 3. LRU cache max size is 1000 - could be made configurable in future
295
+
296
+ ### 🎯 v1.0.0 Stability Guarantee
297
+
298
+ Once v1.0.0 is released:
299
+ - **No breaking changes** in v1.x.x releases
300
+ - New features will be additive only
301
+ - Deprecations will be marked at least 1 minor version before removal
302
+ - Migration guides provided for any breaking changes in v2.x
303
+
304
+ ---
305
+
306
+ ## Conclusion
307
+
308
+ **Status:** ✅ **READY FOR v1.0.0**
309
+
310
+ The Miaw Core API is stable, well-tested, and ready for production use. All 81 public methods have consistent signatures, comprehensive type definitions, and documentation. No breaking changes are planned for v1.0.0.
311
+
312
+ **Recommended Actions:**
313
+ 1. Update version to 1.0.0
314
+ 2. Tag and release v1.0.0
315
+ 3. Mark as "Latest" and "Stable" in npm
316
+ 4. Update README with v1.0.0 announcement
@@ -0,0 +1,220 @@
1
+ # Baileys Migration Plan: v6.7.21 → v7.0.0-rc.9
2
+
3
+ ## Current Issue
4
+
5
+ After scanning QR code and app exits, the session cannot reconnect on restart and requires re-pairing. This is a known issue in v6.7.21 related to session/authentication state handling.
6
+
7
+ ## Recommended Solution
8
+
9
+ Upgrade to **Baileys v7.0.0-rc.9** (latest release candidate, November 2025). This version includes:
10
+
11
+ - Session recreation and improved message retry ([#1735](https://github.com/WhiskeySockets/Baileys/pull/1735))
12
+ - Fix for "No session found to decrypt message" errors ([#1822](https://github.com/WhiskeySockets/Baileys/issues/1822))
13
+ - Sync pre-keys on socket start ([#1663](https://github.com/WhiskeySockets/Baileys/pull/1663))
14
+ - Mutex-based transaction safety to Signal key store ([#1697](https://github.com/WhiskeySockets/Baileys/pull/1697))
15
+
16
+ ---
17
+
18
+ ## Breaking Changes in v7.0.0
19
+
20
+ ### 1. ESM-Only (No More CommonJS)
21
+
22
+ **Impact:** High - Miaw Core uses CommonJS currently.
23
+
24
+ **Changes Required:**
25
+
26
+ ```json
27
+ // package.json
28
+ {
29
+ "type": "module"
30
+ }
31
+ ```
32
+
33
+ ```typescript
34
+ // Change all require() to import
35
+ // Before: const { useMultiFileAuthState } = require('@whiskeysockets/baileys')
36
+ // After:
37
+ import { useMultiFileAuthState } from "@whiskeysockets/baileys";
38
+ ```
39
+
40
+ ### 2. LID (Local Identifier) Support
41
+
42
+ **Impact:** Medium - New auth state keys required.
43
+
44
+ WhatsApp now uses LIDs for user privacy. The auth state must support new keys:
45
+
46
+ - `lid-mapping` - Maps LID ↔ Phone Number
47
+ - `device-list` - Tracks user devices
48
+ - `tctoken` - Token for coexistence
49
+
50
+ **Changes Required in AuthHandler:**
51
+
52
+ ```typescript
53
+ // The useMultiFileAuthState should handle this automatically,
54
+ // but verify SignalDataTypeMap includes new keys
55
+ ```
56
+
57
+ ### 3. API Changes
58
+
59
+ | Old (v6.x) | New (v7.x) |
60
+ | -------------------- | ----------------------------------------------------- |
61
+ | `isJidUser(jid)` | `isPnUser(jid)` |
62
+ | `Contact.jid/lid` | `Contact.id` + `Contact.phoneNumber` or `Contact.lid` |
63
+ | `proto.fromObject()` | `proto.create()` |
64
+
65
+ ### 4. New Events
66
+
67
+ - `lid-mapping.update` - Emitted when LID/PN mapping is discovered
68
+
69
+ ---
70
+
71
+ ## Migration Steps
72
+
73
+ ### Step 1: Backup Current Sessions
74
+
75
+ ```bash
76
+ cp -r ./sessions ./sessions-backup-v6
77
+ ```
78
+
79
+ ### Step 2: Update package.json
80
+
81
+ ```json
82
+ {
83
+ "type": "module",
84
+ "dependencies": {
85
+ "@whiskeysockets/baileys": "^7.0.0-rc.9"
86
+ }
87
+ }
88
+ ```
89
+
90
+ ### Step 3: Update TypeScript Configuration
91
+
92
+ ```json
93
+ // tsconfig.json
94
+ {
95
+ "compilerOptions": {
96
+ "module": "ESNext",
97
+ "moduleResolution": "bundler",
98
+ "esModuleInterop": true
99
+ }
100
+ }
101
+ ```
102
+
103
+ ### Step 4: Update Imports in MiawClient.ts
104
+
105
+ ```typescript
106
+ // Before (CommonJS-style)
107
+ import makeWASocket, {
108
+ DisconnectReason,
109
+ WASocket,
110
+ // ...
111
+ } from "@whiskeysockets/baileys";
112
+
113
+ // After (ESM) - same syntax, but ensure package.json has "type": "module"
114
+ import makeWASocket, {
115
+ DisconnectReason,
116
+ WASocket,
117
+ isPnUser, // replaces isJidUser
118
+ // ...
119
+ } from "@whiskeysockets/baileys";
120
+ ```
121
+
122
+ ### Step 5: Update MessageHandler.ts
123
+
124
+ ```typescript
125
+ // Add LID support in formatPhoneToJid
126
+ static formatPhoneToJid(phoneNumber: string): string {
127
+ // Existing @lid handling is correct - keep as is
128
+ if (phoneNumber.includes('@lid')) {
129
+ return phoneNumber;
130
+ }
131
+ // ... rest unchanged
132
+ }
133
+ ```
134
+
135
+ ### Step 6: Update MiawClient for LID Mapping Store Access
136
+
137
+ ```typescript
138
+ // Access the internal LID mapping store (optional, for advanced use)
139
+ getLidMapping() {
140
+ return this.socket?.signalRepository?.lidMapping;
141
+ }
142
+ ```
143
+
144
+ ### Step 7: Handle New Auth State Keys
145
+
146
+ Verify `useMultiFileAuthState` in AuthHandler handles new keys automatically. If using custom auth storage, add:
147
+
148
+ ```typescript
149
+ type SignalDataTypeMap = {
150
+ // ... existing keys
151
+ "lid-mapping": LIDMapping[];
152
+ "device-list": { [user: string]: string[] };
153
+ tctoken: Buffer;
154
+ };
155
+ ```
156
+
157
+ ### Step 8: Update Protobuf Usage (if any)
158
+
159
+ ```typescript
160
+ // Before
161
+ const msg = proto.Message.fromObject({ ... });
162
+
163
+ // After
164
+ const msg = proto.Message.create({ ... });
165
+ ```
166
+
167
+ ### Step 9: Clear Old Sessions (Recommended)
168
+
169
+ Due to auth state changes, recommend users clear old sessions on first run with v7:
170
+
171
+ ```bash
172
+ rm -rf ./sessions/*
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Testing Checklist
178
+
179
+ - [ ] Fresh QR code scan and authentication
180
+ - [ ] App restart with existing session (critical fix)
181
+ - [ ] Multiple restart cycles
182
+ - [ ] Send/receive text messages
183
+ - [ ] Send/receive media
184
+ - [ ] Group operations
185
+ - [ ] LID contact handling
186
+
187
+ ---
188
+
189
+ ## Rollback Plan
190
+
191
+ If issues occur:
192
+
193
+ ```bash
194
+ # Restore v6 sessions
195
+ rm -rf ./sessions
196
+ cp -r ./sessions-backup-v6 ./sessions
197
+
198
+ # Downgrade
199
+ npm install @whiskeysockets/baileys@6.7.21
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Timeline Estimate
205
+
206
+ | Task | Effort |
207
+ | -------------------- | -------------- |
208
+ | ESM conversion | 2-4 hours |
209
+ | API updates | 1-2 hours |
210
+ | Testing | 4-8 hours |
211
+ | Documentation update | 1-2 hours |
212
+ | **Total** | **8-16 hours** |
213
+
214
+ ---
215
+
216
+ ## References
217
+
218
+ - [Migration Guide](https://baileys.wiki/docs/migration/to-v7.0.0)
219
+ - [GitHub Releases](https://github.com/WhiskeySockets/Baileys/releases)
220
+ - [v7.0.0-rc.9 Release Notes](https://github.com/WhiskeySockets/Baileys/releases/tag/v7.0.0-rc.9)