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.
Files changed (45) hide show
  1. package/WAProto/CompanionReg/CompanionReg.d.ts +6 -0
  2. package/WAProto/CompanionReg/CompanionReg.js +36 -0
  3. package/WAProto/CompanionReg/CompanionReg.proto +1 -0
  4. package/WAProto/E2E/E2E.d.ts +434 -6
  5. package/WAProto/E2E/E2E.js +1427 -2
  6. package/WAProto/E2E/E2E.proto +33 -0
  7. package/WAProto/HistorySync/HistorySync.d.ts +434 -6
  8. package/WAProto/HistorySync/HistorySync.js +1427 -2
  9. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +434 -6
  10. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +1427 -2
  11. package/WAProto/StatusAttributions/StatusAttributions.d.ts +95 -3
  12. package/WAProto/StatusAttributions/StatusAttributions.js +270 -2
  13. package/WAProto/StatusAttributions/StatusAttributions.proto +8 -0
  14. package/WAProto/Web/Web.d.ts +434 -6
  15. package/WAProto/Web/Web.js +1427 -2
  16. package/lib/Defaults/baileys-version.json +1 -1
  17. package/lib/Defaults/index.js +1 -1
  18. package/lib/Socket/business.js +3 -3
  19. package/lib/Socket/chats.js +7 -7
  20. package/lib/Socket/groups.d.ts +117 -123
  21. package/lib/Socket/groups.js +355 -303
  22. package/lib/Socket/messages-recv.js +31 -30
  23. package/lib/Socket/messages-send.js +981 -981
  24. package/lib/Socket/newsletter.js +3 -3
  25. package/lib/Socket/socket.js +748 -621
  26. package/lib/Socket/usync.js +3 -3
  27. package/lib/Store/make-cache-manager-store.js +9 -17
  28. package/lib/Store/make-in-memory-store.d.ts +2 -2
  29. package/lib/Store/make-in-memory-store.js +5 -5
  30. package/lib/Types/Contact.d.ts +35 -24
  31. package/lib/Types/GroupMetadata.d.ts +70 -47
  32. package/lib/Types/Message.d.ts +348 -259
  33. package/lib/Utils/business.js +4 -0
  34. package/lib/Utils/chat-utils.d.ts +47 -45
  35. package/lib/Utils/chat-utils.js +731 -723
  36. package/lib/Utils/decode-wa-message.d.ts +250 -34
  37. package/lib/Utils/decode-wa-message.js +4 -0
  38. package/lib/Utils/generics.js +6 -6
  39. package/lib/Utils/history.d.ts +20 -10
  40. package/lib/Utils/history.js +88 -72
  41. package/lib/Utils/messages.js +1657 -1370
  42. package/lib/Utils/process-message.js +14 -1
  43. package/lib/index.js +13 -53
  44. package/package.json +1 -1
  45. package/lib/Socket/messages-recv.js.bak +0 -1072
@@ -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 suki = socket_1.makeSocket(config)
8
- const { generateMessageTag, query, } = suki
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
- ...suki,
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 = await cache_manager_1.caching(store)
12
+ const databaseConn = createCache()
13
13
  const writeData = async (file, data) => {
14
14
  let ttl = undefined
15
15
  if (file === 'creds') {
16
- ttl = 63115200 // 2 years
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
- if (data) {
24
- return JSON.parse(data, Utils_1.BufferJSON.reviver)
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(async (key) => await databaseConn.del(key)))
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, suki: WASocket | undefined) => Promise<string | null | undefined>
78
- fetchGroupMetadata: (jid: string, suki: WASocket | undefined) => Promise<GroupMetadata>
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, suki) => {
363
+ fetchImageUrl: async (jid, sock) => {
364
364
  const contact = contacts[jid]
365
365
  if (!contact) {
366
- return suki?.profilePictureUrl(jid)
366
+ return sock?.profilePictureUrl(jid)
367
367
  }
368
368
  if (typeof contact.imgUrl === 'undefined') {
369
- contact.imgUrl = await suki?.profilePictureUrl(jid)
369
+ contact.imgUrl = await sock?.profilePictureUrl(jid)
370
370
  }
371
371
  return contact.imgUrl
372
372
  },
373
- fetchGroupMetadata: async (jid, suki) => {
373
+ fetchGroupMetadata: async (jid, sock) => {
374
374
  if (!groupMetadata[jid]) {
375
- const metadata = await suki?.groupMetadata(jid)
375
+ const metadata = await sock?.groupMetadata(jid)
376
376
  if (metadata) {
377
377
  groupMetadata[jid] = metadata
378
378
  }
@@ -1,24 +1,35 @@
1
- export interface Contact {
2
- id: string
3
- lid?: string
4
- /** name of the contact, you have saved on your WA */
5
- name?: string
6
- /** name of the contact, the contact has set on their own on WA */
7
- notify?: string
8
- /** I have no idea */
9
- verifiedName?: string
10
- /**
11
- * Url of the profile picture of the contact
12
- *
13
- * 'changed' => if the profile picture has changed
14
- * null => if the profile picture has not been set (default profile picture)
15
- * any other string => url of the profile picture
16
- */
17
- imgUrl?: string | null
18
- status?: string
19
- }
20
- export type ContactAction = {
21
- firstName: string
22
- fullName: string
23
- saveOnPrimaryAddressbook: boolean
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
- export type GroupParticipant = (Contact & {
3
- isAdmin?: boolean
4
- isSuperAdmin?: boolean
5
- admin?: 'admin' | 'superadmin' | null
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
- addressingMode: string
13
- owner: string | undefined
14
- subject: string
15
- /** group subject owner */
16
- subjectOwner?: string
17
- /** group subject modification date */
18
- subjectTime?: number
19
- creation?: number
20
- desc?: string
21
- descOwner?: string
22
- descId?: string
23
- /** if this group is part of a community, it returns the jid of the community to which it belongs */
24
- linkedParent?: string
25
- /** is set when the group only allows admins to change group settings */
26
- restrict?: boolean
27
- /** is set when the group only allows admins to write messages */
28
- announce?: boolean
29
- /** is set when the group also allows members to add participants */
30
- memberAddMode?: boolean
31
- /** Request approval to join the group */
32
- joinApprovalMode?: boolean
33
- /** is this a community */
34
- isCommunity?: boolean
35
- /** is this the announce of a community */
36
- isCommunityAnnounce?: boolean
37
- /** number of group participants */
38
- size?: number
39
- participants: GroupParticipant[]
40
- picture?: string
41
- ephemeralDuration?: number
42
- inviteCode?: string
43
- /** the person who added you to group or changed some setting in group */
44
- author?: string
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
- [key: string]: {}
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
  }