sanka-baileyss 1.9.4 → 1.9.7
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/WAProto/CompanionReg/CompanionReg.d.ts +6 -0
- package/WAProto/CompanionReg/CompanionReg.js +36 -0
- package/WAProto/CompanionReg/CompanionReg.proto +1 -0
- package/WAProto/E2E/E2E.d.ts +434 -6
- package/WAProto/E2E/E2E.js +1427 -2
- package/WAProto/E2E/E2E.proto +33 -0
- package/WAProto/HistorySync/HistorySync.d.ts +434 -6
- package/WAProto/HistorySync/HistorySync.js +1427 -2
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +434 -6
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +1427 -2
- package/WAProto/StatusAttributions/StatusAttributions.d.ts +95 -3
- package/WAProto/StatusAttributions/StatusAttributions.js +270 -2
- package/WAProto/StatusAttributions/StatusAttributions.proto +8 -0
- package/WAProto/Web/Web.d.ts +434 -6
- package/WAProto/Web/Web.js +1427 -2
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +1 -1
- package/lib/Socket/business.js +3 -3
- package/lib/Socket/chats.js +7 -7
- package/lib/Socket/groups.d.ts +117 -123
- package/lib/Socket/groups.js +355 -303
- package/lib/Socket/messages-recv.js +31 -30
- package/lib/Socket/messages-send.js +981 -981
- package/lib/Socket/newsletter.js +3 -3
- package/lib/Socket/socket.js +748 -621
- package/lib/Socket/usync.js +3 -3
- package/lib/Store/make-cache-manager-store.js +9 -17
- package/lib/Store/make-in-memory-store.d.ts +2 -2
- package/lib/Store/make-in-memory-store.js +5 -5
- package/lib/Types/Contact.d.ts +35 -24
- package/lib/Types/GroupMetadata.d.ts +70 -47
- package/lib/Types/Message.d.ts +348 -259
- package/lib/Utils/business.js +4 -0
- package/lib/Utils/chat-utils.d.ts +47 -45
- package/lib/Utils/chat-utils.js +731 -723
- package/lib/Utils/decode-wa-message.d.ts +250 -34
- package/lib/Utils/decode-wa-message.js +4 -0
- package/lib/Utils/generics.js +6 -6
- package/lib/Utils/history.d.ts +20 -10
- package/lib/Utils/history.js +88 -72
- package/lib/Utils/messages.js +1657 -1370
- package/lib/Utils/process-message.js +14 -1
- package/lib/index.js +13 -53
- package/package.json +1 -1
- package/lib/Socket/messages-recv.js.bak +0 -1072
package/lib/Socket/usync.js
CHANGED
|
@@ -4,8 +4,8 @@ const boom_1 = require("@hapi/boom")
|
|
|
4
4
|
const WABinary_1 = require("../WABinary")
|
|
5
5
|
const socket_1 = require("./socket")
|
|
6
6
|
const makeUSyncSocket = (config) => {
|
|
7
|
-
const
|
|
8
|
-
const { generateMessageTag, query, } =
|
|
7
|
+
const sock = socket_1.makeSocket(config)
|
|
8
|
+
const { generateMessageTag, query, } = sock
|
|
9
9
|
const executeUSyncQuery = async (usyncQuery) => {
|
|
10
10
|
if (usyncQuery.protocols.length === 0) {
|
|
11
11
|
throw new boom_1.Boom('USyncQuery must have at least one protocol')
|
|
@@ -62,7 +62,7 @@ const result = await query(iq)
|
|
|
62
62
|
return usyncQuery.parseUSyncQueryResult(result)
|
|
63
63
|
}
|
|
64
64
|
return {
|
|
65
|
-
...
|
|
65
|
+
...sock,
|
|
66
66
|
executeUSyncQuery
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -3,29 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod }
|
|
4
4
|
}
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
6
|
-
const cache_manager_1 = require("cache-manager")
|
|
7
6
|
const WAProto_1 = require("../../WAProto")
|
|
8
7
|
const Utils_1 = require("../Utils")
|
|
9
8
|
const logger_1 = __importDefault(require("../Utils/logger"))
|
|
10
9
|
const makeCacheManagerAuthState = async (store, sessionKey) => {
|
|
10
|
+
const { createCache } = await import('cache-manager')
|
|
11
11
|
const defaultKey = (file) => `${sessionKey}:${file}`
|
|
12
|
-
const databaseConn =
|
|
12
|
+
const databaseConn = createCache()
|
|
13
13
|
const writeData = async (file, data) => {
|
|
14
14
|
let ttl = undefined
|
|
15
15
|
if (file === 'creds') {
|
|
16
|
-
ttl = 63115200
|
|
16
|
+
ttl = 63115200
|
|
17
17
|
}
|
|
18
18
|
await databaseConn.set(defaultKey(file), JSON.stringify(data, Utils_1.BufferJSON.replacer), ttl)
|
|
19
19
|
}
|
|
20
20
|
const readData = async (file) => {
|
|
21
21
|
try {
|
|
22
22
|
const data = await databaseConn.get(defaultKey(file))
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
return null
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
23
|
+
return data ? JSON.parse(data, Utils_1.BufferJSON.reviver) : null
|
|
24
|
+
} catch (error) {
|
|
29
25
|
logger_1.default.error(error)
|
|
30
26
|
return null
|
|
31
27
|
}
|
|
@@ -33,18 +29,15 @@ return null
|
|
|
33
29
|
const removeData = async (file) => {
|
|
34
30
|
try {
|
|
35
31
|
return await databaseConn.del(defaultKey(file))
|
|
36
|
-
}
|
|
37
|
-
catch (_a) {
|
|
32
|
+
} catch {
|
|
38
33
|
logger_1.default.error(`Error removing ${file} from session ${sessionKey}`)
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
36
|
const clearState = async () => {
|
|
42
37
|
try {
|
|
43
38
|
const result = await databaseConn.store.keys(`${sessionKey}*`)
|
|
44
|
-
await Promise.all(result.map(
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
}
|
|
39
|
+
await Promise.all(result.map((key) => databaseConn.del(key)))
|
|
40
|
+
} catch {}
|
|
48
41
|
}
|
|
49
42
|
const creds = (await readData('creds')) || (0, Utils_1.initAuthCreds)()
|
|
50
43
|
return {
|
|
@@ -65,7 +58,6 @@ data[id] = value
|
|
|
65
58
|
return data
|
|
66
59
|
},
|
|
67
60
|
set: async (data) => {
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
61
|
const tasks = []
|
|
70
62
|
for (const category in data) {
|
|
71
63
|
for (const id in data[category]) {
|
|
@@ -75,7 +67,7 @@ tasks.push(value ? writeData(key, value) : removeData(key))
|
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
69
|
await Promise.all(tasks)
|
|
78
|
-
}
|
|
70
|
+
}
|
|
79
71
|
}
|
|
80
72
|
}
|
|
81
73
|
}
|
|
@@ -74,8 +74,8 @@ getChatLabels: (chatId: string) => LabelAssociation[]
|
|
|
74
74
|
getMessageLabels: (messageId: string) => string[]
|
|
75
75
|
loadMessage: (jid: string, id: string) => Promise<proto.IWebMessageInfo | undefined>
|
|
76
76
|
mostRecentMessage: (jid: string) => Promise<proto.IWebMessageInfo>
|
|
77
|
-
fetchImageUrl: (jid: string,
|
|
78
|
-
fetchGroupMetadata: (jid: string,
|
|
77
|
+
fetchImageUrl: (jid: string, sock: WASocket | undefined) => Promise<string | null | undefined>
|
|
78
|
+
fetchGroupMetadata: (jid: string, sock: WASocket | undefined) => Promise<GroupMetadata>
|
|
79
79
|
fetchMessageReceipts: ({ remoteJid, id }: WAMessageKey) => Promise<proto.IUserReceipt[] | null | undefined>
|
|
80
80
|
toJSON: () => {
|
|
81
81
|
chats: KeyedDB<Chat, string>
|
|
@@ -360,19 +360,19 @@ mostRecentMessage: async (jid) => {
|
|
|
360
360
|
const message = messages[jid]?.array.slice(-1)[0]
|
|
361
361
|
return message
|
|
362
362
|
},
|
|
363
|
-
fetchImageUrl: async (jid,
|
|
363
|
+
fetchImageUrl: async (jid, sock) => {
|
|
364
364
|
const contact = contacts[jid]
|
|
365
365
|
if (!contact) {
|
|
366
|
-
return
|
|
366
|
+
return sock?.profilePictureUrl(jid)
|
|
367
367
|
}
|
|
368
368
|
if (typeof contact.imgUrl === 'undefined') {
|
|
369
|
-
contact.imgUrl = await
|
|
369
|
+
contact.imgUrl = await sock?.profilePictureUrl(jid)
|
|
370
370
|
}
|
|
371
371
|
return contact.imgUrl
|
|
372
372
|
},
|
|
373
|
-
fetchGroupMetadata: async (jid,
|
|
373
|
+
fetchGroupMetadata: async (jid, sock) => {
|
|
374
374
|
if (!groupMetadata[jid]) {
|
|
375
|
-
const metadata = await
|
|
375
|
+
const metadata = await sock?.groupMetadata(jid)
|
|
376
376
|
if (metadata) {
|
|
377
377
|
groupMetadata[jid] = metadata
|
|
378
378
|
}
|
package/lib/Types/Contact.d.ts
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContactAction = exports.Contact = void 0;
|
|
4
|
+
|
|
5
|
+
const Contact = {
|
|
6
|
+
/** ID either in lid or jid format */
|
|
7
|
+
id: '',
|
|
8
|
+
/** ID in Lid (anonymous) format (@lid) */
|
|
9
|
+
lid: undefined,
|
|
10
|
+
/** ID in Phone Number format (@s.whatsapp.net) */
|
|
11
|
+
jid: undefined,
|
|
12
|
+
/** name of the contact, you have saved on your WA */
|
|
13
|
+
name: undefined,
|
|
14
|
+
/** name of the contact, the contact has set on their own on WA */
|
|
15
|
+
notify: undefined,
|
|
16
|
+
/** I have no idea */
|
|
17
|
+
verifiedName: undefined,
|
|
18
|
+
/**
|
|
19
|
+
* Url of the profile picture of the contact
|
|
20
|
+
*
|
|
21
|
+
* 'changed' => if the profile picture has changed
|
|
22
|
+
* null => if the profile picture has not been set (default profile picture)
|
|
23
|
+
* any other string => url of the profile picture
|
|
24
|
+
*/
|
|
25
|
+
imgUrl: undefined,
|
|
26
|
+
status: undefined
|
|
27
|
+
};
|
|
28
|
+
exports.Contact = Contact;
|
|
29
|
+
|
|
30
|
+
const ContactAction = {
|
|
31
|
+
firstName: '',
|
|
32
|
+
fullName: '',
|
|
33
|
+
saveOnPrimaryAddressbook: false
|
|
34
|
+
};
|
|
35
|
+
exports.ContactAction = ContactAction;
|
|
@@ -1,58 +1,81 @@
|
|
|
1
1
|
import { Contact } from './Contact'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
|
|
3
|
+
export type GroupParticipant = Contact & {
|
|
4
|
+
isAdmin?: boolean
|
|
5
|
+
isSuperAdmin?: boolean
|
|
6
|
+
admin?: 'admin' | 'superadmin' | 'member' | null
|
|
7
|
+
lid?: string // Added for lid support
|
|
8
|
+
}
|
|
9
|
+
|
|
7
10
|
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify'
|
|
11
|
+
|
|
8
12
|
export type RequestJoinAction = 'created' | 'revoked' | 'rejected'
|
|
13
|
+
|
|
9
14
|
export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined
|
|
15
|
+
|
|
10
16
|
export interface GroupMetadata {
|
|
11
|
-
id: string
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** group subject
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
id: string
|
|
18
|
+
/** group uses 'lid' or 'pn' to send messages */
|
|
19
|
+
addressingMode: 'pn' | 'lid'
|
|
20
|
+
owner: string | undefined
|
|
21
|
+
ownerJid?: string | undefined
|
|
22
|
+
subject: string
|
|
23
|
+
/** group subject owner */
|
|
24
|
+
subjectOwner?: string
|
|
25
|
+
subjectOwnerJid?: string
|
|
26
|
+
/** group subject modification date */
|
|
27
|
+
subjectTime?: number
|
|
28
|
+
creation?: number
|
|
29
|
+
desc?: string
|
|
30
|
+
descOwner?: string
|
|
31
|
+
descOwnerJid?: string
|
|
32
|
+
descId?: string
|
|
33
|
+
descTime?: number
|
|
34
|
+
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
|
35
|
+
linkedParent?: string
|
|
36
|
+
/** is set when the group only allows admins to change group settings */
|
|
37
|
+
restrict?: boolean
|
|
38
|
+
/** is set when the group only allows admins to write messages */
|
|
39
|
+
announce?: boolean
|
|
40
|
+
/** is set when the group also allows members to add participants */
|
|
41
|
+
memberAddMode?: boolean
|
|
42
|
+
/** Request approval to join the group */
|
|
43
|
+
joinApprovalMode?: boolean
|
|
44
|
+
/** is this a community */
|
|
45
|
+
isCommunity?: boolean
|
|
46
|
+
/** is this the announce of a community */
|
|
47
|
+
isCommunityAnnounce?: boolean
|
|
48
|
+
/** number of group participants */
|
|
49
|
+
size?: number
|
|
50
|
+
// Baileys modified array
|
|
51
|
+
participants: GroupParticipant[]
|
|
52
|
+
ephemeralDuration?: number
|
|
53
|
+
inviteCode?: string
|
|
54
|
+
/** the person who added you to group or changed some setting in group */
|
|
55
|
+
author?: string
|
|
56
|
+
// New properties added for lid support
|
|
57
|
+
ownerCountry?: string
|
|
58
|
+
picture?: string
|
|
45
59
|
}
|
|
60
|
+
|
|
46
61
|
export interface WAGroupCreateResponse {
|
|
47
|
-
status: number
|
|
48
|
-
gid?: string
|
|
49
|
-
participants?: [{
|
|
50
|
-
[key: string]: {}
|
|
51
|
-
}]
|
|
62
|
+
status: number
|
|
63
|
+
gid?: string
|
|
64
|
+
participants?: [{ [key: string]: {} }]
|
|
52
65
|
}
|
|
66
|
+
|
|
53
67
|
export interface GroupModificationResponse {
|
|
54
|
-
status: number
|
|
55
|
-
participants?: {
|
|
56
|
-
|
|
68
|
+
status: number
|
|
69
|
+
participants?: { [key: string]: {} }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Additional types for better lid support
|
|
73
|
+
export interface GroupMetadataLid extends GroupMetadata {
|
|
74
|
+
addressingMode: 'lid'
|
|
75
|
+
ownerJid: string
|
|
76
|
+
participants: (GroupParticipant & { lid: string })[]
|
|
57
77
|
}
|
|
78
|
+
|
|
79
|
+
export interface GroupMetadataPn extends GroupMetadata {
|
|
80
|
+
addressingMode: 'pn'
|
|
58
81
|
}
|