mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
chore: format everything
This commit is contained in:
@@ -2,12 +2,12 @@ import type { proto } from '../../WAProto'
|
||||
import type { Contact } from './Contact'
|
||||
import type { MinimalMessage } from './Message'
|
||||
|
||||
export type KeyPair = { public: Uint8Array, private: Uint8Array }
|
||||
export type KeyPair = { public: Uint8Array; private: Uint8Array }
|
||||
export type SignedKeyPair = {
|
||||
keyPair: KeyPair
|
||||
signature: Uint8Array
|
||||
keyId: number
|
||||
timestampS?: number
|
||||
keyPair: KeyPair
|
||||
signature: Uint8Array
|
||||
keyId: number
|
||||
timestampS?: number
|
||||
}
|
||||
|
||||
export type ProtocolAddress = {
|
||||
@@ -20,58 +20,58 @@ export type SignalIdentity = {
|
||||
}
|
||||
|
||||
export type LTHashState = {
|
||||
version: number
|
||||
hash: Buffer
|
||||
indexValueMap: {
|
||||
[indexMacBase64: string]: { valueMac: Uint8Array | Buffer }
|
||||
}
|
||||
version: number
|
||||
hash: Buffer
|
||||
indexValueMap: {
|
||||
[indexMacBase64: string]: { valueMac: Uint8Array | Buffer }
|
||||
}
|
||||
}
|
||||
|
||||
export type SignalCreds = {
|
||||
readonly signedIdentityKey: KeyPair
|
||||
readonly signedPreKey: SignedKeyPair
|
||||
readonly registrationId: number
|
||||
readonly signedIdentityKey: KeyPair
|
||||
readonly signedPreKey: SignedKeyPair
|
||||
readonly registrationId: number
|
||||
}
|
||||
|
||||
export type AccountSettings = {
|
||||
/** unarchive chats when a new message is received */
|
||||
unarchiveChats: boolean
|
||||
/** the default mode to start new conversations with */
|
||||
defaultDisappearingMode?: Pick<proto.IConversation, 'ephemeralExpiration' | 'ephemeralSettingTimestamp'>
|
||||
/** unarchive chats when a new message is received */
|
||||
unarchiveChats: boolean
|
||||
/** the default mode to start new conversations with */
|
||||
defaultDisappearingMode?: Pick<proto.IConversation, 'ephemeralExpiration' | 'ephemeralSettingTimestamp'>
|
||||
}
|
||||
|
||||
export type AuthenticationCreds = SignalCreds & {
|
||||
readonly noiseKey: KeyPair
|
||||
readonly pairingEphemeralKeyPair: KeyPair
|
||||
advSecretKey: string
|
||||
readonly noiseKey: KeyPair
|
||||
readonly pairingEphemeralKeyPair: KeyPair
|
||||
advSecretKey: string
|
||||
|
||||
me?: Contact
|
||||
account?: proto.IADVSignedDeviceIdentity
|
||||
signalIdentities?: SignalIdentity[]
|
||||
myAppStateKeyId?: string
|
||||
firstUnuploadedPreKeyId: number
|
||||
nextPreKeyId: number
|
||||
me?: Contact
|
||||
account?: proto.IADVSignedDeviceIdentity
|
||||
signalIdentities?: SignalIdentity[]
|
||||
myAppStateKeyId?: string
|
||||
firstUnuploadedPreKeyId: number
|
||||
nextPreKeyId: number
|
||||
|
||||
lastAccountSyncTimestamp?: number
|
||||
platform?: string
|
||||
lastAccountSyncTimestamp?: number
|
||||
platform?: string
|
||||
|
||||
processedHistoryMessages: MinimalMessage[]
|
||||
/** number of times history & app state has been synced */
|
||||
accountSyncCounter: number
|
||||
accountSettings: AccountSettings
|
||||
registered: boolean
|
||||
pairingCode: string | undefined
|
||||
lastPropHash: string | undefined
|
||||
routingInfo: Buffer | undefined
|
||||
processedHistoryMessages: MinimalMessage[]
|
||||
/** number of times history & app state has been synced */
|
||||
accountSyncCounter: number
|
||||
accountSettings: AccountSettings
|
||||
registered: boolean
|
||||
pairingCode: string | undefined
|
||||
lastPropHash: string | undefined
|
||||
routingInfo: Buffer | undefined
|
||||
}
|
||||
|
||||
export type SignalDataTypeMap = {
|
||||
'pre-key': KeyPair
|
||||
'session': Uint8Array
|
||||
'sender-key': Uint8Array
|
||||
'sender-key-memory': { [jid: string]: boolean }
|
||||
'app-state-sync-key': proto.Message.IAppStateSyncKeyData
|
||||
'app-state-sync-version': LTHashState
|
||||
'pre-key': KeyPair
|
||||
session: Uint8Array
|
||||
'sender-key': Uint8Array
|
||||
'sender-key-memory': { [jid: string]: boolean }
|
||||
'app-state-sync-key': proto.Message.IAppStateSyncKeyData
|
||||
'app-state-sync-version': LTHashState
|
||||
}
|
||||
|
||||
export type SignalDataSet = { [T in keyof SignalDataTypeMap]?: { [id: string]: SignalDataTypeMap[T] | null } }
|
||||
@@ -79,15 +79,15 @@ export type SignalDataSet = { [T in keyof SignalDataTypeMap]?: { [id: string]: S
|
||||
type Awaitable<T> = T | Promise<T>
|
||||
|
||||
export type SignalKeyStore = {
|
||||
get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{ [id: string]: SignalDataTypeMap[T] }>
|
||||
set(data: SignalDataSet): Awaitable<void>
|
||||
/** clear all the data in the store */
|
||||
clear?(): Awaitable<void>
|
||||
get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{ [id: string]: SignalDataTypeMap[T] }>
|
||||
set(data: SignalDataSet): Awaitable<void>
|
||||
/** clear all the data in the store */
|
||||
clear?(): Awaitable<void>
|
||||
}
|
||||
|
||||
export type SignalKeyStoreWithTransaction = SignalKeyStore & {
|
||||
isInTransaction: () => boolean
|
||||
transaction<T>(exec: () => Promise<T>): Promise<T>
|
||||
isInTransaction: () => boolean
|
||||
transaction<T>(exec: () => Promise<T>): Promise<T>
|
||||
}
|
||||
|
||||
export type TransactionCapabilityOptions = {
|
||||
@@ -96,11 +96,11 @@ export type TransactionCapabilityOptions = {
|
||||
}
|
||||
|
||||
export type SignalAuthState = {
|
||||
creds: SignalCreds
|
||||
keys: SignalKeyStore | SignalKeyStoreWithTransaction
|
||||
creds: SignalCreds
|
||||
keys: SignalKeyStore | SignalKeyStoreWithTransaction
|
||||
}
|
||||
|
||||
export type AuthenticationState = {
|
||||
creds: AuthenticationCreds
|
||||
keys: SignalKeyStore
|
||||
}
|
||||
creds: AuthenticationCreds
|
||||
keys: SignalKeyStore
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate'
|
||||
|
||||
export type WACallEvent = {
|
||||
|
||||
@@ -22,50 +22,58 @@ export type WAPrivacyMessagesValue = 'all' | 'contacts'
|
||||
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
||||
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
|
||||
|
||||
export const ALL_WA_PATCH_NAMES = ['critical_block', 'critical_unblock_low', 'regular_high', 'regular_low', 'regular'] as const
|
||||
export const ALL_WA_PATCH_NAMES = [
|
||||
'critical_block',
|
||||
'critical_unblock_low',
|
||||
'regular_high',
|
||||
'regular_low',
|
||||
'regular'
|
||||
] as const
|
||||
|
||||
export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number]
|
||||
export type WAPatchName = (typeof ALL_WA_PATCH_NAMES)[number]
|
||||
|
||||
export interface PresenceData {
|
||||
lastKnownPresence: WAPresence
|
||||
lastSeen?: number
|
||||
lastKnownPresence: WAPresence
|
||||
lastSeen?: number
|
||||
}
|
||||
|
||||
export type BotListInfo = {
|
||||
jid: string
|
||||
personaId: string
|
||||
jid: string
|
||||
personaId: string
|
||||
}
|
||||
|
||||
export type ChatMutation = {
|
||||
syncAction: proto.ISyncActionData
|
||||
index: string[]
|
||||
syncAction: proto.ISyncActionData
|
||||
index: string[]
|
||||
}
|
||||
|
||||
export type WAPatchCreate = {
|
||||
syncAction: proto.ISyncActionValue
|
||||
index: string[]
|
||||
type: WAPatchName
|
||||
apiVersion: number
|
||||
operation: proto.SyncdMutation.SyncdOperation
|
||||
syncAction: proto.ISyncActionValue
|
||||
index: string[]
|
||||
type: WAPatchName
|
||||
apiVersion: number
|
||||
operation: proto.SyncdMutation.SyncdOperation
|
||||
}
|
||||
|
||||
export type Chat = proto.IConversation & {
|
||||
/** unix timestamp of when the last message was received in the chat */
|
||||
lastMessageRecvTimestamp?: number
|
||||
/** unix timestamp of when the last message was received in the chat */
|
||||
lastMessageRecvTimestamp?: number
|
||||
}
|
||||
|
||||
export type ChatUpdate = Partial<Chat & {
|
||||
/**
|
||||
* if specified in the update,
|
||||
* the EV buffer will check if the condition gets fulfilled before applying the update
|
||||
* Right now, used to determine when to release an app state sync event
|
||||
*
|
||||
* @returns true, if the update should be applied;
|
||||
* false if it can be discarded;
|
||||
* undefined if the condition is not yet fulfilled
|
||||
* */
|
||||
conditional: (bufferedData: BufferedEventData) => boolean | undefined
|
||||
}>
|
||||
export type ChatUpdate = Partial<
|
||||
Chat & {
|
||||
/**
|
||||
* if specified in the update,
|
||||
* the EV buffer will check if the condition gets fulfilled before applying the update
|
||||
* Right now, used to determine when to release an app state sync event
|
||||
*
|
||||
* @returns true, if the update should be applied;
|
||||
* false if it can be discarded;
|
||||
* undefined if the condition is not yet fulfilled
|
||||
* */
|
||||
conditional: (bufferedData: BufferedEventData) => boolean | undefined
|
||||
}
|
||||
>
|
||||
|
||||
/**
|
||||
* the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
|
||||
@@ -74,49 +82,50 @@ export type ChatUpdate = Partial<Chat & {
|
||||
export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange
|
||||
|
||||
export type ChatModification =
|
||||
{
|
||||
archive: boolean
|
||||
lastMessages: LastMessageList
|
||||
}
|
||||
| { pushNameSetting: string }
|
||||
| { pin: boolean }
|
||||
| {
|
||||
/** mute for duration, or provide timestamp of mute to remove*/
|
||||
mute: number | null
|
||||
}
|
||||
| {
|
||||
clear: boolean
|
||||
} | {
|
||||
deleteForMe: { deleteMedia: boolean, key: WAMessageKey, timestamp: number }
|
||||
}
|
||||
| {
|
||||
star: {
|
||||
messages: { id: string, fromMe?: boolean }[]
|
||||
star: boolean
|
||||
}
|
||||
}
|
||||
| {
|
||||
markRead: boolean
|
||||
lastMessages: LastMessageList
|
||||
}
|
||||
| { delete: true, lastMessages: LastMessageList }
|
||||
// Label
|
||||
| { addLabel: LabelActionBody }
|
||||
// Label assosiation
|
||||
| { addChatLabel: ChatLabelAssociationActionBody }
|
||||
| { removeChatLabel: ChatLabelAssociationActionBody }
|
||||
| { addMessageLabel: MessageLabelAssociationActionBody }
|
||||
| { removeMessageLabel: MessageLabelAssociationActionBody }
|
||||
| {
|
||||
archive: boolean
|
||||
lastMessages: LastMessageList
|
||||
}
|
||||
| { pushNameSetting: string }
|
||||
| { pin: boolean }
|
||||
| {
|
||||
/** mute for duration, or provide timestamp of mute to remove*/
|
||||
mute: number | null
|
||||
}
|
||||
| {
|
||||
clear: boolean
|
||||
}
|
||||
| {
|
||||
deleteForMe: { deleteMedia: boolean; key: WAMessageKey; timestamp: number }
|
||||
}
|
||||
| {
|
||||
star: {
|
||||
messages: { id: string; fromMe?: boolean }[]
|
||||
star: boolean
|
||||
}
|
||||
}
|
||||
| {
|
||||
markRead: boolean
|
||||
lastMessages: LastMessageList
|
||||
}
|
||||
| { delete: true; lastMessages: LastMessageList }
|
||||
// Label
|
||||
| { addLabel: LabelActionBody }
|
||||
// Label assosiation
|
||||
| { addChatLabel: ChatLabelAssociationActionBody }
|
||||
| { removeChatLabel: ChatLabelAssociationActionBody }
|
||||
| { addMessageLabel: MessageLabelAssociationActionBody }
|
||||
| { removeMessageLabel: MessageLabelAssociationActionBody }
|
||||
|
||||
export type InitialReceivedChatsState = {
|
||||
[jid: string]: {
|
||||
/** the last message received from the other party */
|
||||
lastMsgRecvTimestamp?: number
|
||||
/** the absolute last message in the chat */
|
||||
lastMsgTimestamp: number
|
||||
}
|
||||
[jid: string]: {
|
||||
/** the last message received from the other party */
|
||||
lastMsgRecvTimestamp?: number
|
||||
/** the absolute last message in the chat */
|
||||
lastMsgTimestamp: number
|
||||
}
|
||||
}
|
||||
|
||||
export type InitialAppStateSyncOptions = {
|
||||
accountSettings: AccountSettings
|
||||
accountSettings: AccountSettings
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
export interface Contact {
|
||||
id: string
|
||||
lid?: string
|
||||
/** name of the contact, you have saved on your WA */
|
||||
name?: string
|
||||
/** name of the contact, the contact has set on their own on WA */
|
||||
notify?: string
|
||||
/** I have no idea */
|
||||
verifiedName?: string
|
||||
// Baileys Added
|
||||
/**
|
||||
* Url of the profile picture of the contact
|
||||
*
|
||||
* 'changed' => if the profile picture has changed
|
||||
* null => if the profile picture has not been set (default profile picture)
|
||||
* any other string => url of the profile picture
|
||||
*/
|
||||
imgUrl?: string | null
|
||||
status?: string
|
||||
}
|
||||
id: string
|
||||
lid?: string
|
||||
/** name of the contact, you have saved on your WA */
|
||||
name?: string
|
||||
/** name of the contact, the contact has set on their own on WA */
|
||||
notify?: string
|
||||
/** I have no idea */
|
||||
verifiedName?: string
|
||||
// Baileys Added
|
||||
/**
|
||||
* Url of the profile picture of the contact
|
||||
*
|
||||
* 'changed' => if the profile picture has changed
|
||||
* null => if the profile picture has not been set (default profile picture)
|
||||
* any other string => url of the profile picture
|
||||
*/
|
||||
imgUrl?: string | null
|
||||
status?: string
|
||||
}
|
||||
|
||||
@@ -11,91 +11,97 @@ import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, W
|
||||
import { ConnectionState } from './State'
|
||||
|
||||
export type BaileysEventMap = {
|
||||
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
||||
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
||||
'connection.update': Partial<ConnectionState>
|
||||
/** credentials updated -- some metadata, keys or something */
|
||||
'creds.update': Partial<AuthenticationCreds>
|
||||
/** set chats (history sync), everything is reverse chronologically sorted */
|
||||
'messaging-history.set': {
|
||||
chats: Chat[]
|
||||
contacts: Contact[]
|
||||
messages: WAMessage[]
|
||||
isLatest?: boolean
|
||||
progress?: number | null
|
||||
syncType?: proto.HistorySync.HistorySyncType
|
||||
peerDataRequestSessionId?: string | null
|
||||
}
|
||||
/** upsert chats */
|
||||
'chats.upsert': Chat[]
|
||||
/** update the given chats */
|
||||
'chats.update': ChatUpdate[]
|
||||
'chats.phoneNumberShare': {lid: string, jid: string}
|
||||
/** delete chats with given ID */
|
||||
'chats.delete': string[]
|
||||
/** presence of contact in a chat updated */
|
||||
'presence.update': { id: string, presences: { [participant: string]: PresenceData } }
|
||||
/** credentials updated -- some metadata, keys or something */
|
||||
'creds.update': Partial<AuthenticationCreds>
|
||||
/** set chats (history sync), everything is reverse chronologically sorted */
|
||||
'messaging-history.set': {
|
||||
chats: Chat[]
|
||||
contacts: Contact[]
|
||||
messages: WAMessage[]
|
||||
isLatest?: boolean
|
||||
progress?: number | null
|
||||
syncType?: proto.HistorySync.HistorySyncType
|
||||
peerDataRequestSessionId?: string | null
|
||||
}
|
||||
/** upsert chats */
|
||||
'chats.upsert': Chat[]
|
||||
/** update the given chats */
|
||||
'chats.update': ChatUpdate[]
|
||||
'chats.phoneNumberShare': { lid: string; jid: string }
|
||||
/** delete chats with given ID */
|
||||
'chats.delete': string[]
|
||||
/** presence of contact in a chat updated */
|
||||
'presence.update': { id: string; presences: { [participant: string]: PresenceData } }
|
||||
|
||||
'contacts.upsert': Contact[]
|
||||
'contacts.update': Partial<Contact>[]
|
||||
'contacts.upsert': Contact[]
|
||||
'contacts.update': Partial<Contact>[]
|
||||
|
||||
'messages.delete': { keys: WAMessageKey[] } | { jid: string, all: true }
|
||||
'messages.update': WAMessageUpdate[]
|
||||
'messages.media-update': { key: WAMessageKey, media?: { ciphertext: Uint8Array, iv: Uint8Array }, error?: Boom }[]
|
||||
/**
|
||||
* add/update the given messages. If they were received while the connection was online,
|
||||
* the update will have type: "notify"
|
||||
* if requestId is provided, then the messages was received from the phone due to it being unavailable
|
||||
* */
|
||||
'messages.upsert': { messages: WAMessage[], type: MessageUpsertType, requestId?: string }
|
||||
/** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
|
||||
'messages.reaction': { key: WAMessageKey, reaction: proto.IReaction }[]
|
||||
'messages.delete': { keys: WAMessageKey[] } | { jid: string; all: true }
|
||||
'messages.update': WAMessageUpdate[]
|
||||
'messages.media-update': { key: WAMessageKey; media?: { ciphertext: Uint8Array; iv: Uint8Array }; error?: Boom }[]
|
||||
/**
|
||||
* add/update the given messages. If they were received while the connection was online,
|
||||
* the update will have type: "notify"
|
||||
* if requestId is provided, then the messages was received from the phone due to it being unavailable
|
||||
* */
|
||||
'messages.upsert': { messages: WAMessage[]; type: MessageUpsertType; requestId?: string }
|
||||
/** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
|
||||
'messages.reaction': { key: WAMessageKey; reaction: proto.IReaction }[]
|
||||
|
||||
'message-receipt.update': MessageUserReceiptUpdate[]
|
||||
'message-receipt.update': MessageUserReceiptUpdate[]
|
||||
|
||||
'groups.upsert': GroupMetadata[]
|
||||
'groups.update': Partial<GroupMetadata>[]
|
||||
/** apply an action to participants in a group */
|
||||
'group-participants.update': { id: string, author: string, participants: string[], action: ParticipantAction }
|
||||
'group.join-request': { id: string, author: string, participant: string, action: RequestJoinAction, method: RequestJoinMethod }
|
||||
'groups.upsert': GroupMetadata[]
|
||||
'groups.update': Partial<GroupMetadata>[]
|
||||
/** apply an action to participants in a group */
|
||||
'group-participants.update': { id: string; author: string; participants: string[]; action: ParticipantAction }
|
||||
'group.join-request': {
|
||||
id: string
|
||||
author: string
|
||||
participant: string
|
||||
action: RequestJoinAction
|
||||
method: RequestJoinMethod
|
||||
}
|
||||
|
||||
'blocklist.set': { blocklist: string[] }
|
||||
'blocklist.update': { blocklist: string[], type: 'add' | 'remove' }
|
||||
'blocklist.set': { blocklist: string[] }
|
||||
'blocklist.update': { blocklist: string[]; type: 'add' | 'remove' }
|
||||
|
||||
/** Receive an update on a call, including when the call was received, rejected, accepted */
|
||||
'call': WACallEvent[]
|
||||
'labels.edit': Label
|
||||
'labels.association': { association: LabelAssociation, type: 'add' | 'remove' }
|
||||
/** Receive an update on a call, including when the call was received, rejected, accepted */
|
||||
call: WACallEvent[]
|
||||
'labels.edit': Label
|
||||
'labels.association': { association: LabelAssociation; type: 'add' | 'remove' }
|
||||
}
|
||||
|
||||
export type BufferedEventData = {
|
||||
historySets: {
|
||||
chats: { [jid: string]: Chat }
|
||||
contacts: { [jid: string]: Contact }
|
||||
messages: { [uqId: string]: WAMessage }
|
||||
empty: boolean
|
||||
isLatest: boolean
|
||||
progress?: number | null
|
||||
syncType?: proto.HistorySync.HistorySyncType
|
||||
peerDataRequestSessionId?: string
|
||||
}
|
||||
chatUpserts: { [jid: string]: Chat }
|
||||
chatUpdates: { [jid: string]: ChatUpdate }
|
||||
chatDeletes: Set<string>
|
||||
contactUpserts: { [jid: string]: Contact }
|
||||
contactUpdates: { [jid: string]: Partial<Contact> }
|
||||
messageUpserts: { [key: string]: { type: MessageUpsertType, message: WAMessage } }
|
||||
messageUpdates: { [key: string]: WAMessageUpdate }
|
||||
messageDeletes: { [key: string]: WAMessageKey }
|
||||
messageReactions: { [key: string]: { key: WAMessageKey, reactions: proto.IReaction[] } }
|
||||
messageReceipts: { [key: string]: { key: WAMessageKey, userReceipt: proto.IUserReceipt[] } }
|
||||
groupUpdates: { [jid: string]: Partial<GroupMetadata> }
|
||||
historySets: {
|
||||
chats: { [jid: string]: Chat }
|
||||
contacts: { [jid: string]: Contact }
|
||||
messages: { [uqId: string]: WAMessage }
|
||||
empty: boolean
|
||||
isLatest: boolean
|
||||
progress?: number | null
|
||||
syncType?: proto.HistorySync.HistorySyncType
|
||||
peerDataRequestSessionId?: string
|
||||
}
|
||||
chatUpserts: { [jid: string]: Chat }
|
||||
chatUpdates: { [jid: string]: ChatUpdate }
|
||||
chatDeletes: Set<string>
|
||||
contactUpserts: { [jid: string]: Contact }
|
||||
contactUpdates: { [jid: string]: Partial<Contact> }
|
||||
messageUpserts: { [key: string]: { type: MessageUpsertType; message: WAMessage } }
|
||||
messageUpdates: { [key: string]: WAMessageUpdate }
|
||||
messageDeletes: { [key: string]: WAMessageKey }
|
||||
messageReactions: { [key: string]: { key: WAMessageKey; reactions: proto.IReaction[] } }
|
||||
messageReceipts: { [key: string]: { key: WAMessageKey; userReceipt: proto.IUserReceipt[] } }
|
||||
groupUpdates: { [jid: string]: Partial<GroupMetadata> }
|
||||
}
|
||||
|
||||
export type BaileysEvent = keyof BaileysEventMap
|
||||
|
||||
export interface BaileysEventEmitter {
|
||||
on<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void
|
||||
off<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void
|
||||
removeAllListeners<T extends keyof BaileysEventMap>(event: T): void
|
||||
off<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void
|
||||
removeAllListeners<T extends keyof BaileysEventMap>(event: T): void
|
||||
emit<T extends keyof BaileysEventMap>(event: T, arg: BaileysEventMap[T]): boolean
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { Contact } from './Contact'
|
||||
|
||||
export type GroupParticipant = (Contact & { isAdmin?: boolean, isSuperAdmin?: boolean, admin?: 'admin' | 'superadmin' | null })
|
||||
export type GroupParticipant = Contact & {
|
||||
isAdmin?: boolean
|
||||
isSuperAdmin?: boolean
|
||||
admin?: 'admin' | 'superadmin' | null
|
||||
}
|
||||
|
||||
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify'
|
||||
|
||||
@@ -9,51 +13,50 @@ export type RequestJoinAction = 'created' | 'revoked' | 'rejected'
|
||||
export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined
|
||||
|
||||
export interface GroupMetadata {
|
||||
id: string
|
||||
/** group uses 'lid' or 'pn' to send messages */
|
||||
addressingMode: string
|
||||
owner: string | undefined
|
||||
subject: string
|
||||
/** group subject owner */
|
||||
subjectOwner?: string
|
||||
/** group subject modification date */
|
||||
subjectTime?: number
|
||||
creation?: number
|
||||
desc?: string
|
||||
descOwner?: string
|
||||
descId?: string
|
||||
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
||||
linkedParent?: string
|
||||
/** is set when the group only allows admins to change group settings */
|
||||
restrict?: boolean
|
||||
/** is set when the group only allows admins to write messages */
|
||||
announce?: boolean
|
||||
/** is set when the group also allows members to add participants */
|
||||
memberAddMode?: boolean
|
||||
/** Request approval to join the group */
|
||||
joinApprovalMode?: boolean
|
||||
/** is this a community */
|
||||
isCommunity?: boolean
|
||||
/** is this the announce of a community */
|
||||
isCommunityAnnounce?: boolean
|
||||
/** number of group participants */
|
||||
size?: number
|
||||
// Baileys modified array
|
||||
participants: GroupParticipant[]
|
||||
ephemeralDuration?: number
|
||||
inviteCode?: string
|
||||
/** the person who added you to group or changed some setting in group */
|
||||
author?: string
|
||||
id: string
|
||||
/** group uses 'lid' or 'pn' to send messages */
|
||||
addressingMode: string
|
||||
owner: string | undefined
|
||||
subject: string
|
||||
/** group subject owner */
|
||||
subjectOwner?: string
|
||||
/** group subject modification date */
|
||||
subjectTime?: number
|
||||
creation?: number
|
||||
desc?: string
|
||||
descOwner?: string
|
||||
descId?: string
|
||||
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
||||
linkedParent?: string
|
||||
/** is set when the group only allows admins to change group settings */
|
||||
restrict?: boolean
|
||||
/** is set when the group only allows admins to write messages */
|
||||
announce?: boolean
|
||||
/** is set when the group also allows members to add participants */
|
||||
memberAddMode?: boolean
|
||||
/** Request approval to join the group */
|
||||
joinApprovalMode?: boolean
|
||||
/** is this a community */
|
||||
isCommunity?: boolean
|
||||
/** is this the announce of a community */
|
||||
isCommunityAnnounce?: boolean
|
||||
/** number of group participants */
|
||||
size?: number
|
||||
// Baileys modified array
|
||||
participants: GroupParticipant[]
|
||||
ephemeralDuration?: number
|
||||
inviteCode?: string
|
||||
/** the person who added you to group or changed some setting in group */
|
||||
author?: string
|
||||
}
|
||||
|
||||
|
||||
export interface WAGroupCreateResponse {
|
||||
status: number
|
||||
gid?: string
|
||||
participants?: [{ [key: string]: {} }]
|
||||
status: number
|
||||
gid?: string
|
||||
participants?: [{ [key: string]: {} }]
|
||||
}
|
||||
|
||||
export interface GroupModificationResponse {
|
||||
status: number
|
||||
participants?: { [key: string]: {} }
|
||||
status: number
|
||||
participants?: { [key: string]: {} }
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
export interface Label {
|
||||
/** Label uniq ID */
|
||||
id: string
|
||||
/** Label name */
|
||||
name: string
|
||||
/** Label color ID */
|
||||
color: number
|
||||
/** Is label has been deleted */
|
||||
deleted: boolean
|
||||
/** WhatsApp has 5 predefined labels (New customer, New order & etc) */
|
||||
predefinedId?: string
|
||||
/** Label uniq ID */
|
||||
id: string
|
||||
/** Label name */
|
||||
name: string
|
||||
/** Label color ID */
|
||||
color: number
|
||||
/** Is label has been deleted */
|
||||
deleted: boolean
|
||||
/** WhatsApp has 5 predefined labels (New customer, New order & etc) */
|
||||
predefinedId?: string
|
||||
}
|
||||
|
||||
export interface LabelActionBody {
|
||||
id: string
|
||||
/** Label name */
|
||||
name?: string
|
||||
/** Label color ID */
|
||||
color?: number
|
||||
/** Is label has been deleted */
|
||||
deleted?: boolean
|
||||
/** WhatsApp has 5 predefined labels (New customer, New order & etc) */
|
||||
predefinedId?: number
|
||||
id: string
|
||||
/** Label name */
|
||||
name?: string
|
||||
/** Label color ID */
|
||||
color?: number
|
||||
/** Is label has been deleted */
|
||||
deleted?: boolean
|
||||
/** WhatsApp has 5 predefined labels (New customer, New order & etc) */
|
||||
predefinedId?: number
|
||||
}
|
||||
|
||||
/** WhatsApp has 20 predefined colors */
|
||||
export enum LabelColor {
|
||||
Color1 = 0,
|
||||
Color2,
|
||||
Color3,
|
||||
Color4,
|
||||
Color5,
|
||||
Color6,
|
||||
Color7,
|
||||
Color8,
|
||||
Color9,
|
||||
Color10,
|
||||
Color11,
|
||||
Color12,
|
||||
Color13,
|
||||
Color14,
|
||||
Color15,
|
||||
Color16,
|
||||
Color17,
|
||||
Color18,
|
||||
Color19,
|
||||
Color20,
|
||||
}
|
||||
Color1 = 0,
|
||||
Color2,
|
||||
Color3,
|
||||
Color4,
|
||||
Color5,
|
||||
Color6,
|
||||
Color7,
|
||||
Color8,
|
||||
Color9,
|
||||
Color10,
|
||||
Color11,
|
||||
Color12,
|
||||
Color13,
|
||||
Color14,
|
||||
Color15,
|
||||
Color16,
|
||||
Color17,
|
||||
Color18,
|
||||
Color19,
|
||||
Color20
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
/** Association type */
|
||||
export enum LabelAssociationType {
|
||||
Chat = 'label_jid',
|
||||
Message = 'label_message'
|
||||
Chat = 'label_jid',
|
||||
Message = 'label_message'
|
||||
}
|
||||
|
||||
export type LabelAssociationTypes = `${LabelAssociationType}`
|
||||
|
||||
/** Association for chat */
|
||||
export interface ChatLabelAssociation {
|
||||
type: LabelAssociationType.Chat
|
||||
chatId: string
|
||||
labelId: string
|
||||
type: LabelAssociationType.Chat
|
||||
chatId: string
|
||||
labelId: string
|
||||
}
|
||||
|
||||
/** Association for message */
|
||||
export interface MessageLabelAssociation {
|
||||
type: LabelAssociationType.Message
|
||||
chatId: string
|
||||
messageId: string
|
||||
labelId: string
|
||||
type: LabelAssociationType.Message
|
||||
chatId: string
|
||||
messageId: string
|
||||
labelId: string
|
||||
}
|
||||
|
||||
export type LabelAssociation = ChatLabelAssociation | MessageLabelAssociation
|
||||
|
||||
/** Body for add/remove chat label association action */
|
||||
export interface ChatLabelAssociationActionBody {
|
||||
labelId: string
|
||||
labelId: string
|
||||
}
|
||||
|
||||
/** body for add/remove message label association action */
|
||||
export interface MessageLabelAssociationActionBody {
|
||||
labelId: string
|
||||
messageId: string
|
||||
}
|
||||
labelId: string
|
||||
messageId: string
|
||||
}
|
||||
|
||||
@@ -17,7 +17,12 @@ export type WAMessageKey = proto.IMessageKey
|
||||
export type WATextMessage = proto.Message.IExtendedTextMessage
|
||||
export type WAContextInfo = proto.IContextInfo
|
||||
export type WALocationMessage = proto.Message.ILocationMessage
|
||||
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage
|
||||
export type WAGenericMediaMessage =
|
||||
| proto.Message.IVideoMessage
|
||||
| proto.Message.IImageMessage
|
||||
| proto.Message.IAudioMessage
|
||||
| proto.Message.IDocumentMessage
|
||||
| proto.Message.IStickerMessage
|
||||
export const WAMessageStubType = proto.WebMessageInfo.StubType
|
||||
export const WAMessageStatus = proto.WebMessageInfo.Status
|
||||
import { ILogger } from '../Utils/logger'
|
||||
@@ -27,235 +32,261 @@ export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL
|
||||
/** Set of message types that are supported by the library */
|
||||
export type MessageType = keyof proto.Message
|
||||
|
||||
export type DownloadableMessage = { mediaKey?: Uint8Array | null, directPath?: string | null, url?: string | null }
|
||||
export type DownloadableMessage = { mediaKey?: Uint8Array | null; directPath?: string | null; url?: string | null }
|
||||
|
||||
export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined
|
||||
export type MessageReceiptType =
|
||||
| 'read'
|
||||
| 'read-self'
|
||||
| 'hist_sync'
|
||||
| 'peer_msg'
|
||||
| 'sender'
|
||||
| 'inactive'
|
||||
| 'played'
|
||||
| undefined
|
||||
|
||||
export type MediaConnInfo = {
|
||||
auth: string
|
||||
ttl: number
|
||||
hosts: { hostname: string, maxContentLengthBytes: number }[]
|
||||
fetchDate: Date
|
||||
auth: string
|
||||
ttl: number
|
||||
hosts: { hostname: string; maxContentLengthBytes: number }[]
|
||||
fetchDate: Date
|
||||
}
|
||||
|
||||
export interface WAUrlInfo {
|
||||
'canonical-url': string
|
||||
'matched-text': string
|
||||
title: string
|
||||
description?: string
|
||||
jpegThumbnail?: Buffer
|
||||
highQualityThumbnail?: proto.Message.IImageMessage
|
||||
originalThumbnailUrl?: string
|
||||
'canonical-url': string
|
||||
'matched-text': string
|
||||
title: string
|
||||
description?: string
|
||||
jpegThumbnail?: Buffer
|
||||
highQualityThumbnail?: proto.Message.IImageMessage
|
||||
originalThumbnailUrl?: string
|
||||
}
|
||||
|
||||
// types to generate WA messages
|
||||
type Mentionable = {
|
||||
/** list of jids that are mentioned in the accompanying text */
|
||||
mentions?: string[]
|
||||
/** list of jids that are mentioned in the accompanying text */
|
||||
mentions?: string[]
|
||||
}
|
||||
type Contextable = {
|
||||
/** add contextInfo to the message */
|
||||
contextInfo?: proto.IContextInfo
|
||||
/** add contextInfo to the message */
|
||||
contextInfo?: proto.IContextInfo
|
||||
}
|
||||
type ViewOnce = {
|
||||
viewOnce?: boolean
|
||||
viewOnce?: boolean
|
||||
}
|
||||
|
||||
type Editable = {
|
||||
edit?: WAMessageKey
|
||||
edit?: WAMessageKey
|
||||
}
|
||||
type WithDimensions = {
|
||||
width?: number
|
||||
height?: number
|
||||
width?: number
|
||||
height?: number
|
||||
}
|
||||
|
||||
export type PollMessageOptions = {
|
||||
name: string
|
||||
selectableCount?: number
|
||||
values: string[]
|
||||
/** 32 byte message secret to encrypt poll selections */
|
||||
messageSecret?: Uint8Array
|
||||
toAnnouncementGroup?: boolean
|
||||
name: string
|
||||
selectableCount?: number
|
||||
values: string[]
|
||||
/** 32 byte message secret to encrypt poll selections */
|
||||
messageSecret?: Uint8Array
|
||||
toAnnouncementGroup?: boolean
|
||||
}
|
||||
|
||||
type SharePhoneNumber = {
|
||||
sharePhoneNumber: boolean
|
||||
sharePhoneNumber: boolean
|
||||
}
|
||||
|
||||
type RequestPhoneNumber = {
|
||||
requestPhoneNumber: boolean
|
||||
requestPhoneNumber: boolean
|
||||
}
|
||||
|
||||
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING
|
||||
export type AnyMediaMessageContent = (
|
||||
({
|
||||
image: WAMediaUpload
|
||||
caption?: string
|
||||
jpegThumbnail?: string
|
||||
} & Mentionable & Contextable & WithDimensions)
|
||||
| ({
|
||||
video: WAMediaUpload
|
||||
caption?: string
|
||||
gifPlayback?: boolean
|
||||
jpegThumbnail?: string
|
||||
/** if set to true, will send as a `video note` */
|
||||
ptv?: boolean
|
||||
} & Mentionable & Contextable & WithDimensions)
|
||||
| {
|
||||
audio: WAMediaUpload
|
||||
/** if set to true, will send as a `voice note` */
|
||||
ptt?: boolean
|
||||
/** optionally tell the duration of the audio */
|
||||
seconds?: number
|
||||
}
|
||||
| ({
|
||||
sticker: WAMediaUpload
|
||||
isAnimated?: boolean
|
||||
} & WithDimensions) | ({
|
||||
document: WAMediaUpload
|
||||
mimetype: string
|
||||
fileName?: string
|
||||
caption?: string
|
||||
} & Contextable))
|
||||
& { mimetype?: string } & Editable
|
||||
| ({
|
||||
image: WAMediaUpload
|
||||
caption?: string
|
||||
jpegThumbnail?: string
|
||||
} & Mentionable &
|
||||
Contextable &
|
||||
WithDimensions)
|
||||
| ({
|
||||
video: WAMediaUpload
|
||||
caption?: string
|
||||
gifPlayback?: boolean
|
||||
jpegThumbnail?: string
|
||||
/** if set to true, will send as a `video note` */
|
||||
ptv?: boolean
|
||||
} & Mentionable &
|
||||
Contextable &
|
||||
WithDimensions)
|
||||
| {
|
||||
audio: WAMediaUpload
|
||||
/** if set to true, will send as a `voice note` */
|
||||
ptt?: boolean
|
||||
/** optionally tell the duration of the audio */
|
||||
seconds?: number
|
||||
}
|
||||
| ({
|
||||
sticker: WAMediaUpload
|
||||
isAnimated?: boolean
|
||||
} & WithDimensions)
|
||||
| ({
|
||||
document: WAMediaUpload
|
||||
mimetype: string
|
||||
fileName?: string
|
||||
caption?: string
|
||||
} & Contextable)
|
||||
) & { mimetype?: string } & Editable
|
||||
|
||||
export type ButtonReplyInfo = {
|
||||
displayText: string
|
||||
id: string
|
||||
index: number
|
||||
displayText: string
|
||||
id: string
|
||||
index: number
|
||||
}
|
||||
|
||||
export type GroupInviteInfo = {
|
||||
inviteCode: string
|
||||
inviteExpiration: number
|
||||
text: string
|
||||
jid: string
|
||||
subject: string
|
||||
inviteCode: string
|
||||
inviteExpiration: number
|
||||
text: string
|
||||
jid: string
|
||||
subject: string
|
||||
}
|
||||
|
||||
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
||||
productImage: WAMediaUpload
|
||||
productImage: WAMediaUpload
|
||||
}
|
||||
|
||||
export type AnyRegularMessageContent = (
|
||||
({
|
||||
text: string
|
||||
linkPreview?: WAUrlInfo | null
|
||||
}
|
||||
& Mentionable & Contextable & Editable)
|
||||
| AnyMediaMessageContent
|
||||
| ({
|
||||
poll: PollMessageOptions
|
||||
} & Mentionable & Contextable & Editable)
|
||||
| {
|
||||
contacts: {
|
||||
displayName?: string
|
||||
contacts: proto.Message.IContactMessage[]
|
||||
}
|
||||
}
|
||||
| {
|
||||
location: WALocationMessage
|
||||
}
|
||||
| { react: proto.Message.IReactionMessage }
|
||||
| {
|
||||
buttonReply: ButtonReplyInfo
|
||||
type: 'template' | 'plain'
|
||||
}
|
||||
| {
|
||||
groupInvite: GroupInviteInfo
|
||||
}
|
||||
| {
|
||||
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>
|
||||
}
|
||||
| {
|
||||
pin: WAMessageKey
|
||||
type: proto.PinInChat.Type
|
||||
/**
|
||||
* 24 hours, 7 days, 30 days
|
||||
*/
|
||||
time?: 86400 | 604800 | 2592000
|
||||
}
|
||||
| {
|
||||
product: WASendableProduct
|
||||
businessOwnerJid?: string
|
||||
body?: string
|
||||
footer?: string
|
||||
} | SharePhoneNumber | RequestPhoneNumber
|
||||
) & ViewOnce
|
||||
| ({
|
||||
text: string
|
||||
linkPreview?: WAUrlInfo | null
|
||||
} & Mentionable &
|
||||
Contextable &
|
||||
Editable)
|
||||
| AnyMediaMessageContent
|
||||
| ({
|
||||
poll: PollMessageOptions
|
||||
} & Mentionable &
|
||||
Contextable &
|
||||
Editable)
|
||||
| {
|
||||
contacts: {
|
||||
displayName?: string
|
||||
contacts: proto.Message.IContactMessage[]
|
||||
}
|
||||
}
|
||||
| {
|
||||
location: WALocationMessage
|
||||
}
|
||||
| { react: proto.Message.IReactionMessage }
|
||||
| {
|
||||
buttonReply: ButtonReplyInfo
|
||||
type: 'template' | 'plain'
|
||||
}
|
||||
| {
|
||||
groupInvite: GroupInviteInfo
|
||||
}
|
||||
| {
|
||||
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>
|
||||
}
|
||||
| {
|
||||
pin: WAMessageKey
|
||||
type: proto.PinInChat.Type
|
||||
/**
|
||||
* 24 hours, 7 days, 30 days
|
||||
*/
|
||||
time?: 86400 | 604800 | 2592000
|
||||
}
|
||||
| {
|
||||
product: WASendableProduct
|
||||
businessOwnerJid?: string
|
||||
body?: string
|
||||
footer?: string
|
||||
}
|
||||
| SharePhoneNumber
|
||||
| RequestPhoneNumber
|
||||
) &
|
||||
ViewOnce
|
||||
|
||||
export type AnyMessageContent = AnyRegularMessageContent | {
|
||||
forward: WAMessage
|
||||
force?: boolean
|
||||
} | {
|
||||
/** Delete your message or anyone's message in a group (admin required) */
|
||||
delete: WAMessageKey
|
||||
} | {
|
||||
disappearingMessagesInChat: boolean | number
|
||||
}
|
||||
export type AnyMessageContent =
|
||||
| AnyRegularMessageContent
|
||||
| {
|
||||
forward: WAMessage
|
||||
force?: boolean
|
||||
}
|
||||
| {
|
||||
/** Delete your message or anyone's message in a group (admin required) */
|
||||
delete: WAMessageKey
|
||||
}
|
||||
| {
|
||||
disappearingMessagesInChat: boolean | number
|
||||
}
|
||||
|
||||
export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>
|
||||
|
||||
type MinimalRelayOptions = {
|
||||
/** override the message ID with a custom provided string */
|
||||
messageId?: string
|
||||
/** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
|
||||
useCachedGroupMetadata?: boolean
|
||||
/** override the message ID with a custom provided string */
|
||||
messageId?: string
|
||||
/** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
|
||||
useCachedGroupMetadata?: boolean
|
||||
}
|
||||
|
||||
export type MessageRelayOptions = MinimalRelayOptions & {
|
||||
/** only send to a specific participant; used when a message decryption fails for a single user */
|
||||
participant?: { jid: string, count: number }
|
||||
/** additional attributes to add to the WA binary node */
|
||||
additionalAttributes?: { [_: string]: string }
|
||||
additionalNodes?: BinaryNode[]
|
||||
/** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
|
||||
useUserDevicesCache?: boolean
|
||||
/** jid list of participants for status@broadcast */
|
||||
statusJidList?: string[]
|
||||
/** only send to a specific participant; used when a message decryption fails for a single user */
|
||||
participant?: { jid: string; count: number }
|
||||
/** additional attributes to add to the WA binary node */
|
||||
additionalAttributes?: { [_: string]: string }
|
||||
additionalNodes?: BinaryNode[]
|
||||
/** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
|
||||
useUserDevicesCache?: boolean
|
||||
/** jid list of participants for status@broadcast */
|
||||
statusJidList?: string[]
|
||||
}
|
||||
|
||||
export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
||||
/** optional, if you want to manually set the timestamp of the message */
|
||||
/** optional, if you want to manually set the timestamp of the message */
|
||||
timestamp?: Date
|
||||
/** the message you want to quote */
|
||||
/** the message you want to quote */
|
||||
quoted?: WAMessage
|
||||
/** disappearing messages settings */
|
||||
ephemeralExpiration?: number | string
|
||||
/** timeout for media upload to WA server */
|
||||
mediaUploadTimeoutMs?: number
|
||||
/** jid list of participants for status@broadcast */
|
||||
statusJidList?: string[]
|
||||
/** backgroundcolor for status */
|
||||
backgroundColor?: string
|
||||
/** font type for status */
|
||||
font?: number
|
||||
/** if it is broadcast */
|
||||
broadcast?: boolean
|
||||
/** disappearing messages settings */
|
||||
ephemeralExpiration?: number | string
|
||||
/** timeout for media upload to WA server */
|
||||
mediaUploadTimeoutMs?: number
|
||||
/** jid list of participants for status@broadcast */
|
||||
statusJidList?: string[]
|
||||
/** backgroundcolor for status */
|
||||
backgroundColor?: string
|
||||
/** font type for status */
|
||||
font?: number
|
||||
/** if it is broadcast */
|
||||
broadcast?: boolean
|
||||
}
|
||||
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
||||
userJid: string
|
||||
}
|
||||
|
||||
export type WAMediaUploadFunction = (readStream: Readable, opts: { fileEncSha256B64: string, mediaType: MediaType, timeoutMs?: number }) => Promise<{ mediaUrl: string, directPath: string }>
|
||||
export type WAMediaUploadFunction = (
|
||||
readStream: Readable,
|
||||
opts: { fileEncSha256B64: string; mediaType: MediaType; timeoutMs?: number }
|
||||
) => Promise<{ mediaUrl: string; directPath: string }>
|
||||
|
||||
export type MediaGenerationOptions = {
|
||||
logger?: ILogger
|
||||
mediaTypeOverride?: MediaType
|
||||
upload: WAMediaUploadFunction
|
||||
/** cache media so it does not have to be uploaded again */
|
||||
mediaCache?: CacheStore
|
||||
mediaTypeOverride?: MediaType
|
||||
upload: WAMediaUploadFunction
|
||||
/** cache media so it does not have to be uploaded again */
|
||||
mediaCache?: CacheStore
|
||||
|
||||
mediaUploadTimeoutMs?: number
|
||||
mediaUploadTimeoutMs?: number
|
||||
|
||||
options?: AxiosRequestConfig
|
||||
options?: AxiosRequestConfig
|
||||
|
||||
backgroundColor?: string
|
||||
backgroundColor?: string
|
||||
|
||||
font?: number
|
||||
font?: number
|
||||
}
|
||||
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
||||
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>
|
||||
getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>
|
||||
getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>
|
||||
}
|
||||
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent
|
||||
|
||||
@@ -268,16 +299,16 @@ export type MessageUpsertType = 'append' | 'notify'
|
||||
|
||||
export type MessageUserReceipt = proto.IUserReceipt
|
||||
|
||||
export type WAMessageUpdate = { update: Partial<WAMessage>, key: proto.IMessageKey }
|
||||
export type WAMessageUpdate = { update: Partial<WAMessage>; key: proto.IMessageKey }
|
||||
|
||||
export type WAMessageCursor = { before: WAMessageKey | undefined } | { after: WAMessageKey | undefined }
|
||||
|
||||
export type MessageUserReceiptUpdate = { key: proto.IMessageKey, receipt: MessageUserReceipt }
|
||||
export type MessageUserReceiptUpdate = { key: proto.IMessageKey; receipt: MessageUserReceipt }
|
||||
|
||||
export type MediaDecryptionKeyInfo = {
|
||||
iv: Buffer
|
||||
cipherKey: Buffer
|
||||
macKey?: Buffer
|
||||
iv: Buffer
|
||||
cipherKey: Buffer
|
||||
macKey?: Buffer
|
||||
}
|
||||
|
||||
export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { WAMediaUpload } from './Message'
|
||||
|
||||
export type CatalogResult = {
|
||||
data: {
|
||||
paging: { cursors: { before: string, after: string } }
|
||||
paging: { cursors: { before: string; after: string } }
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
data: any[]
|
||||
}
|
||||
@@ -82,4 +82,4 @@ export type GetCatalogOptions = {
|
||||
limit?: number
|
||||
|
||||
jid?: string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,9 +51,7 @@ type E2ESessionOpts = {
|
||||
|
||||
export type SignalRepository = {
|
||||
decryptGroupMessage(opts: DecryptGroupSignalOpts): Promise<Uint8Array>
|
||||
processSenderKeyDistributionMessage(
|
||||
opts: ProcessSenderKeyDistributionMessageOpts
|
||||
): Promise<void>
|
||||
processSenderKeyDistributionMessage(opts: ProcessSenderKeyDistributionMessageOpts): Promise<void>
|
||||
decryptMessage(opts: DecryptSignalProtoOpts): Promise<Uint8Array>
|
||||
encryptMessage(opts: EncryptMessageOpts): Promise<{
|
||||
type: 'pkmsg' | 'msg'
|
||||
@@ -65,4 +63,4 @@ export type SignalRepository = {
|
||||
}>
|
||||
injectE2ESession(opts: E2ESessionOpts): Promise<void>
|
||||
jidToSignalProtocolAddress(jid: string): string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import { AxiosRequestConfig } from 'axios'
|
||||
import type { Agent } from 'https'
|
||||
import type { URL } from 'url'
|
||||
@@ -13,121 +12,124 @@ export type WAVersion = [number, number, number]
|
||||
export type WABrowserDescription = [string, string, string]
|
||||
|
||||
export type CacheStore = {
|
||||
/** get a cached key and change the stats */
|
||||
get<T>(key: string): T | undefined
|
||||
/** set a key in the cache */
|
||||
set<T>(key: string, value: T): void
|
||||
/** delete a key from the cache */
|
||||
del(key: string): void
|
||||
/** flush all data */
|
||||
flushAll(): void
|
||||
/** get a cached key and change the stats */
|
||||
get<T>(key: string): T | undefined
|
||||
/** set a key in the cache */
|
||||
set<T>(key: string, value: T): void
|
||||
/** delete a key from the cache */
|
||||
del(key: string): void
|
||||
/** flush all data */
|
||||
flushAll(): void
|
||||
}
|
||||
|
||||
export type PatchedMessageWithRecipientJID = proto.IMessage & {recipientJid?: string}
|
||||
export type PatchedMessageWithRecipientJID = proto.IMessage & { recipientJid?: string }
|
||||
|
||||
export type SocketConfig = {
|
||||
/** the WS url to connect to WA */
|
||||
waWebSocketUrl: string | URL
|
||||
/** Fails the connection if the socket times out in this interval */
|
||||
connectTimeoutMs: number
|
||||
/** Default timeout for queries, undefined for no timeout */
|
||||
defaultQueryTimeoutMs: number | undefined
|
||||
/** ping-pong interval for WS connection */
|
||||
keepAliveIntervalMs: number
|
||||
/** the WS url to connect to WA */
|
||||
waWebSocketUrl: string | URL
|
||||
/** Fails the connection if the socket times out in this interval */
|
||||
connectTimeoutMs: number
|
||||
/** Default timeout for queries, undefined for no timeout */
|
||||
defaultQueryTimeoutMs: number | undefined
|
||||
/** ping-pong interval for WS connection */
|
||||
keepAliveIntervalMs: number
|
||||
/** should baileys use the mobile api instead of the multi device api
|
||||
* @deprecated This feature has been removed
|
||||
*/
|
||||
* @deprecated This feature has been removed
|
||||
*/
|
||||
mobile?: boolean
|
||||
/** proxy agent */
|
||||
agent?: Agent
|
||||
/** logger */
|
||||
logger: ILogger
|
||||
/** version to connect with */
|
||||
version: WAVersion
|
||||
/** override browser config */
|
||||
browser: WABrowserDescription
|
||||
/** agent used for fetch requests -- uploading/downloading media */
|
||||
fetchAgent?: Agent
|
||||
/** should the QR be printed in the terminal
|
||||
* @deprecated This feature has been removed
|
||||
*/
|
||||
printQRInTerminal?: boolean
|
||||
/** should events be emitted for actions done by this socket connection */
|
||||
emitOwnEvents: boolean
|
||||
/** custom upload hosts to upload media to */
|
||||
customUploadHosts: MediaConnInfo['hosts']
|
||||
/** time to wait between sending new retry requests */
|
||||
retryRequestDelayMs: number
|
||||
/** max retry count */
|
||||
maxMsgRetryCount: number
|
||||
/** time to wait for the generation of the next QR in ms */
|
||||
qrTimeout?: number
|
||||
/** provide an auth state object to maintain the auth state */
|
||||
auth: AuthenticationState
|
||||
/** manage history processing with this control; by default will sync up everything */
|
||||
shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean
|
||||
/** transaction capability options for SignalKeyStore */
|
||||
transactionOpts: TransactionCapabilityOptions
|
||||
/** marks the client as online whenever the socket successfully connects */
|
||||
markOnlineOnConnect: boolean
|
||||
/** alphanumeric country code (USA -> US) for the number used */
|
||||
countryCode: string
|
||||
/** provide a cache to store media, so does not have to be re-uploaded */
|
||||
mediaCache?: CacheStore
|
||||
/**
|
||||
* map to store the retry counts for failed messages;
|
||||
* used to determine whether to retry a message or not */
|
||||
msgRetryCounterCache?: CacheStore
|
||||
/** provide a cache to store a user's device list */
|
||||
userDevicesCache?: CacheStore
|
||||
/** cache to store call offers */
|
||||
callOfferCache?: CacheStore
|
||||
/** cache to track placeholder resends */
|
||||
placeholderResendCache?: CacheStore
|
||||
/** width for link preview images */
|
||||
linkPreviewImageThumbnailWidth: number
|
||||
/** Should Baileys ask the phone for full history, will be received async */
|
||||
syncFullHistory: boolean
|
||||
/** Should baileys fire init queries automatically, default true */
|
||||
fireInitQueries: boolean
|
||||
/**
|
||||
* generate a high quality link preview,
|
||||
* entails uploading the jpegThumbnail to WA
|
||||
* */
|
||||
generateHighQualityLinkPreview: boolean
|
||||
/** proxy agent */
|
||||
agent?: Agent
|
||||
/** logger */
|
||||
logger: ILogger
|
||||
/** version to connect with */
|
||||
version: WAVersion
|
||||
/** override browser config */
|
||||
browser: WABrowserDescription
|
||||
/** agent used for fetch requests -- uploading/downloading media */
|
||||
fetchAgent?: Agent
|
||||
/** should the QR be printed in the terminal
|
||||
* @deprecated This feature has been removed
|
||||
*/
|
||||
printQRInTerminal?: boolean
|
||||
/** should events be emitted for actions done by this socket connection */
|
||||
emitOwnEvents: boolean
|
||||
/** custom upload hosts to upload media to */
|
||||
customUploadHosts: MediaConnInfo['hosts']
|
||||
/** time to wait between sending new retry requests */
|
||||
retryRequestDelayMs: number
|
||||
/** max retry count */
|
||||
maxMsgRetryCount: number
|
||||
/** time to wait for the generation of the next QR in ms */
|
||||
qrTimeout?: number
|
||||
/** provide an auth state object to maintain the auth state */
|
||||
auth: AuthenticationState
|
||||
/** manage history processing with this control; by default will sync up everything */
|
||||
shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean
|
||||
/** transaction capability options for SignalKeyStore */
|
||||
transactionOpts: TransactionCapabilityOptions
|
||||
/** marks the client as online whenever the socket successfully connects */
|
||||
markOnlineOnConnect: boolean
|
||||
/** alphanumeric country code (USA -> US) for the number used */
|
||||
countryCode: string
|
||||
/** provide a cache to store media, so does not have to be re-uploaded */
|
||||
mediaCache?: CacheStore
|
||||
/**
|
||||
* map to store the retry counts for failed messages;
|
||||
* used to determine whether to retry a message or not */
|
||||
msgRetryCounterCache?: CacheStore
|
||||
/** provide a cache to store a user's device list */
|
||||
userDevicesCache?: CacheStore
|
||||
/** cache to store call offers */
|
||||
callOfferCache?: CacheStore
|
||||
/** cache to track placeholder resends */
|
||||
placeholderResendCache?: CacheStore
|
||||
/** width for link preview images */
|
||||
linkPreviewImageThumbnailWidth: number
|
||||
/** Should Baileys ask the phone for full history, will be received async */
|
||||
syncFullHistory: boolean
|
||||
/** Should baileys fire init queries automatically, default true */
|
||||
fireInitQueries: boolean
|
||||
/**
|
||||
* generate a high quality link preview,
|
||||
* entails uploading the jpegThumbnail to WA
|
||||
* */
|
||||
generateHighQualityLinkPreview: boolean
|
||||
|
||||
/**
|
||||
* Returns if a jid should be ignored,
|
||||
* no event for that jid will be triggered.
|
||||
* Messages from that jid will also not be decrypted
|
||||
* */
|
||||
shouldIgnoreJid: (jid: string) => boolean | undefined
|
||||
/**
|
||||
* Returns if a jid should be ignored,
|
||||
* no event for that jid will be triggered.
|
||||
* Messages from that jid will also not be decrypted
|
||||
* */
|
||||
shouldIgnoreJid: (jid: string) => boolean | undefined
|
||||
|
||||
/**
|
||||
* Optionally patch the message before sending out
|
||||
* */
|
||||
patchMessageBeforeSending: (
|
||||
msg: proto.IMessage,
|
||||
recipientJids?: string[],
|
||||
) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID
|
||||
/**
|
||||
* Optionally patch the message before sending out
|
||||
* */
|
||||
patchMessageBeforeSending: (
|
||||
msg: proto.IMessage,
|
||||
recipientJids?: string[]
|
||||
) =>
|
||||
| Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID>
|
||||
| PatchedMessageWithRecipientJID[]
|
||||
| PatchedMessageWithRecipientJID
|
||||
|
||||
/** verify app state MACs */
|
||||
appStateMacVerification: {
|
||||
patch: boolean
|
||||
snapshot: boolean
|
||||
}
|
||||
/** verify app state MACs */
|
||||
appStateMacVerification: {
|
||||
patch: boolean
|
||||
snapshot: boolean
|
||||
}
|
||||
|
||||
/** options for axios */
|
||||
options: AxiosRequestConfig<{}>
|
||||
/**
|
||||
* fetch a message from your store
|
||||
* implement this so that messages failed to send
|
||||
* (solves the "this message can take a while" issue) can be retried
|
||||
* */
|
||||
getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>
|
||||
/** options for axios */
|
||||
options: AxiosRequestConfig<{}>
|
||||
/**
|
||||
* fetch a message from your store
|
||||
* implement this so that messages failed to send
|
||||
* (solves the "this message can take a while" issue) can be retried
|
||||
* */
|
||||
getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>
|
||||
|
||||
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
||||
cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>
|
||||
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
||||
cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>
|
||||
|
||||
makeSignalRepository: (auth: SignalAuthState) => SignalRepository
|
||||
makeSignalRepository: (auth: SignalAuthState) => SignalRepository
|
||||
}
|
||||
|
||||
@@ -26,4 +26,4 @@ export type ConnectionState = {
|
||||
* If this is false, the primary phone and other devices will receive notifs
|
||||
* */
|
||||
isOnline?: boolean
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,23 +5,23 @@ import { USyncUser } from '../WAUSync'
|
||||
* Defines the interface for a USyncQuery protocol
|
||||
*/
|
||||
export interface USyncQueryProtocol {
|
||||
/**
|
||||
* The name of the protocol
|
||||
*/
|
||||
name: string
|
||||
/**
|
||||
* Defines what goes inside the query part of a USyncQuery
|
||||
*/
|
||||
getQueryElement: () => BinaryNode
|
||||
/**
|
||||
* Defines what goes inside the user part of a USyncQuery
|
||||
*/
|
||||
getUserElement: (user: USyncUser) => BinaryNode | null
|
||||
/**
|
||||
* The name of the protocol
|
||||
*/
|
||||
name: string
|
||||
/**
|
||||
* Defines what goes inside the query part of a USyncQuery
|
||||
*/
|
||||
getQueryElement: () => BinaryNode
|
||||
/**
|
||||
* Defines what goes inside the user part of a USyncQuery
|
||||
*/
|
||||
getUserElement: (user: USyncUser) => BinaryNode | null
|
||||
|
||||
/**
|
||||
* Parse the result of the query
|
||||
* @param data Data from the result
|
||||
* @returns Whatever the protocol is supposed to return
|
||||
*/
|
||||
parser: (data: BinaryNode) => unknown
|
||||
}
|
||||
/**
|
||||
* Parse the result of the query
|
||||
* @param data Data from the result
|
||||
* @returns Whatever the protocol is supposed to return
|
||||
*/
|
||||
parser: (data: BinaryNode) => unknown
|
||||
}
|
||||
|
||||
@@ -16,51 +16,51 @@ import { SocketConfig } from './Socket'
|
||||
export type UserFacingSocketConfig = Partial<SocketConfig> & { auth: AuthenticationState }
|
||||
|
||||
export type BrowsersMap = {
|
||||
ubuntu(browser: string): [string, string, string]
|
||||
macOS(browser: string): [string, string, string]
|
||||
baileys(browser: string): [string, string, string]
|
||||
windows(browser: string): [string, string, string]
|
||||
appropriate(browser: string): [string, string, string]
|
||||
ubuntu(browser: string): [string, string, string]
|
||||
macOS(browser: string): [string, string, string]
|
||||
baileys(browser: string): [string, string, string]
|
||||
windows(browser: string): [string, string, string]
|
||||
appropriate(browser: string): [string, string, string]
|
||||
}
|
||||
|
||||
export enum DisconnectReason {
|
||||
connectionClosed = 428,
|
||||
connectionLost = 408,
|
||||
connectionReplaced = 440,
|
||||
timedOut = 408,
|
||||
loggedOut = 401,
|
||||
badSession = 500,
|
||||
restartRequired = 515,
|
||||
multideviceMismatch = 411,
|
||||
forbidden = 403,
|
||||
unavailableService = 503
|
||||
connectionClosed = 428,
|
||||
connectionLost = 408,
|
||||
connectionReplaced = 440,
|
||||
timedOut = 408,
|
||||
loggedOut = 401,
|
||||
badSession = 500,
|
||||
restartRequired = 515,
|
||||
multideviceMismatch = 411,
|
||||
forbidden = 403,
|
||||
unavailableService = 503
|
||||
}
|
||||
|
||||
export type WAInitResponse = {
|
||||
ref: string
|
||||
ttl: number
|
||||
status: 200
|
||||
ref: string
|
||||
ttl: number
|
||||
status: 200
|
||||
}
|
||||
|
||||
export type WABusinessHoursConfig = {
|
||||
day_of_week: string
|
||||
mode: string
|
||||
open_time?: number
|
||||
close_time?: number
|
||||
day_of_week: string
|
||||
mode: string
|
||||
open_time?: number
|
||||
close_time?: number
|
||||
}
|
||||
|
||||
export type WABusinessProfile = {
|
||||
description: string
|
||||
email: string | undefined
|
||||
business_hours: {
|
||||
timezone?: string
|
||||
config?: WABusinessHoursConfig[]
|
||||
business_config?: WABusinessHoursConfig[]
|
||||
}
|
||||
website: string[]
|
||||
category?: string
|
||||
wid?: string
|
||||
address?: string
|
||||
description: string
|
||||
email: string | undefined
|
||||
business_hours: {
|
||||
timezone?: string
|
||||
config?: WABusinessHoursConfig[]
|
||||
business_config?: WABusinessHoursConfig[]
|
||||
}
|
||||
website: string[]
|
||||
category?: string
|
||||
wid?: string
|
||||
address?: string
|
||||
}
|
||||
|
||||
export type CurveKeyPair = { private: Uint8Array, public: Uint8Array }
|
||||
export type CurveKeyPair = { private: Uint8Array; public: Uint8Array }
|
||||
|
||||
Reference in New Issue
Block a user