sanka-baileyss 2.3.2 → 2.3.3
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/BotMetadata/BotMetadata.d.ts +594 -1
- package/WAProto/BotMetadata/BotMetadata.js +1910 -148
- package/WAProto/BotMetadata/BotMetadata.proto +36 -0
- package/WAProto/E2E/E2E.d.ts +570 -6
- package/WAProto/E2E/E2E.js +1591 -26
- package/WAProto/E2E/E2E.proto +10 -1
- package/WAProto/HistorySync/HistorySync.d.ts +806 -6
- package/WAProto/HistorySync/HistorySync.js +2193 -29
- package/WAProto/HistorySync/HistorySync.proto +2 -1
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +570 -6
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +1591 -26
- package/WAProto/StatusAttributions/StatusAttributions.d.ts +2 -1
- package/WAProto/StatusAttributions/StatusAttributions.js +7 -0
- package/WAProto/StatusAttributions/StatusAttributions.proto +1 -0
- package/WAProto/SyncAction/SyncAction.d.ts +230 -0
- package/WAProto/SyncAction/SyncAction.js +578 -2
- package/WAProto/SyncAction/SyncAction.proto +13 -1
- package/WAProto/Web/Web.d.ts +570 -6
- package/WAProto/Web/Web.js +1591 -26
- package/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/index.d.ts +42 -25
- package/lib/Defaults/index.js +6 -2
- package/lib/Signal/libsignal.d.ts +1 -0
- package/lib/Socket/Client/index.js +13 -9
- package/lib/Socket/Client/types.d.ts +11 -10
- package/lib/Socket/Client/types.js +11 -7
- package/lib/Socket/Client/websocket.d.ts +9 -8
- package/lib/Socket/Client/websocket.js +52 -47
- package/lib/Socket/business.d.ts +185 -182
- package/lib/Socket/business.js +258 -249
- package/lib/Socket/chats.d.ts +90 -87
- package/lib/Socket/chats.js +1095 -888
- package/lib/Socket/community.d.ts +131 -0
- package/lib/Socket/community.js +369 -0
- package/lib/Socket/groups.d.ts +50 -41
- package/lib/Socket/groups.js +10 -3
- package/lib/Socket/index.d.ts +5 -1
- package/lib/Socket/index.js +19 -5
- package/lib/Socket/messages-recv.d.ts +6 -2
- package/lib/Socket/messages-recv.js +31 -8
- package/lib/Socket/messages-send.d.ts +5 -1
- package/lib/Socket/messages-send.js +1293 -1351
- package/lib/Socket/newsletter.d.ts +142 -135
- package/lib/Socket/newsletter.js +274 -230
- package/lib/Socket/socket.d.ts +37 -35
- package/lib/Socket/usync.d.ts +31 -30
- package/lib/Socket/usync.js +74 -62
- package/lib/Types/Auth.d.ts +89 -72
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Call.d.ts +11 -10
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +85 -62
- package/lib/Types/Chat.js +4 -1
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +209 -191
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +12 -27
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +41 -39
- package/lib/Types/Label.js +24 -21
- package/lib/Types/LabelAssociation.d.ts +18 -12
- package/lib/Types/LabelAssociation.js +6 -3
- package/lib/Types/Message.d.ts +3 -2
- package/lib/Types/Message.js +7 -3
- package/lib/Types/MexUpdates.d.ts +9 -0
- package/lib/Types/MexUpdates.js +18 -0
- package/lib/Types/Newsletter.d.ts +84 -67
- package/lib/Types/Newsletter.js +30 -23
- package/lib/Types/Product.d.ts +70 -56
- package/lib/Types/Product.js +1 -0
- package/lib/Types/Signal.d.ts +46 -35
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +105 -101
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +37 -23
- package/lib/Types/State.js +13 -1
- package/lib/Types/USync.d.ts +21 -20
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +51 -42
- package/lib/Types/index.js +25 -19
- package/lib/Utils/auth-utils.d.ts +14 -11
- package/lib/Utils/auth-utils.js +189 -182
- package/lib/Utils/baileys-event-stream.d.ts +12 -10
- package/lib/Utils/baileys-event-stream.js +52 -46
- package/lib/Utils/business.d.ts +15 -8
- package/lib/Utils/business.js +229 -217
- package/lib/Utils/chat-utils.d.ts +22 -12
- package/lib/Utils/chat-utils.js +57 -27
- package/lib/Utils/crypto.d.ts +31 -15
- package/lib/Utils/crypto.js +136 -107
- package/lib/Utils/decode-wa-message.d.ts +34 -245
- package/lib/Utils/decode-wa-message.js +205 -217
- package/lib/Utils/event-buffer.d.ts +30 -26
- package/lib/Utils/event-buffer.js +519 -515
- package/lib/Utils/history.d.ts +2 -8
- package/lib/Utils/index.js +13 -9
- package/lib/Utils/link-preview.d.ts +16 -14
- package/lib/Utils/link-preview.js +100 -92
- package/lib/Utils/logger.d.ts +9 -7
- package/lib/Utils/logger.js +1 -1
- package/lib/Utils/lt-hash.d.ts +10 -8
- package/lib/Utils/lt-hash.js +49 -44
- package/lib/Utils/make-mutex.d.ts +4 -2
- package/lib/Utils/make-mutex.js +43 -39
- package/lib/Utils/messages-media.d.ts +75 -50
- package/lib/Utils/messages.d.ts +60 -35
- package/lib/Utils/messages.js +87 -8
- package/lib/Utils/noise-handler.d.ts +13 -12
- package/lib/Utils/noise-handler.js +143 -138
- package/lib/Utils/process-message.d.ts +32 -24
- package/lib/Utils/process-message.js +387 -367
- package/lib/Utils/signal.d.ts +24 -15
- package/lib/Utils/signal.js +143 -131
- package/lib/Utils/use-mongo-file-auth-state.d.ts +3 -2
- package/lib/Utils/use-mongo-file-auth-state.js +72 -63
- package/lib/Utils/use-multi-file-auth-state.d.ts +9 -8
- package/lib/Utils/use-multi-file-auth-state.js +110 -102
- package/lib/Utils/use-single-file-auth-state.d.ts +8 -7
- package/lib/Utils/use-single-file-auth-state.js +66 -61
- package/lib/Utils/validate-connection.d.ts +5 -2
- package/lib/Utils/validate-connection.js +7 -6
- package/lib/WABinary/constants.d.ts +24 -21
- package/lib/WABinary/constants.js +1302 -31
- package/lib/WABinary/decode.d.ts +4 -1
- package/lib/WABinary/decode.js +267 -234
- package/lib/WABinary/encode.d.ts +1 -0
- package/lib/WABinary/encode.js +248 -226
- package/lib/WABinary/generic-utils.d.ts +13 -1
- package/lib/WABinary/generic-utils.js +113 -96
- package/lib/WABinary/index.js +13 -9
- package/lib/WABinary/jid-utils.d.ts +23 -4
- package/lib/WABinary/jid-utils.js +58 -39
- package/lib/WABinary/types.d.ts +15 -11
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +14 -14
- package/lib/WAM/BinaryInfo.js +11 -8
- package/lib/WAM/constants.d.ts +34 -26
- package/lib/WAM/constants.js +15358 -15349
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +153 -144
- package/lib/WAM/index.js +13 -9
- package/lib/index.js +11 -11
- package/package.json +1 -2
- package/WASignalGroup/GroupProtocol.js +0 -1771
- package/WASignalGroup/ciphertext_message.js +0 -10
- package/WASignalGroup/group_cipher.js +0 -103
- package/WASignalGroup/group_session_builder.js +0 -39
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -17
- package/WASignalGroup/protobufs.js +0 -2
- package/WASignalGroup/queue_job.js +0 -64
- package/WASignalGroup/sender_chain_key.js +0 -38
- package/WASignalGroup/sender_key_distribution_message.js +0 -68
- package/WASignalGroup/sender_key_message.js +0 -79
- package/WASignalGroup/sender_key_name.js +0 -59
- package/WASignalGroup/sender_key_record.js +0 -47
- package/WASignalGroup/sender_key_state.js +0 -110
- package/WASignalGroup/sender_message_key.js +0 -30
|
@@ -6,99 +6,124 @@ import { proto } from '../../WAProto'
|
|
|
6
6
|
import { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types'
|
|
7
7
|
import { BinaryNode } from '../WABinary'
|
|
8
8
|
import { ILogger } from './logger'
|
|
9
|
+
|
|
9
10
|
export declare const hkdfInfoKey: (type: MediaType) => string
|
|
11
|
+
|
|
10
12
|
/** generates all the keys required to encrypt/decrypt & sign a media message */
|
|
11
13
|
export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): MediaDecryptionKeyInfo
|
|
14
|
+
|
|
12
15
|
export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
|
|
13
|
-
buffer: Buffer
|
|
14
|
-
original: {
|
|
15
|
-
width: number | undefined
|
|
16
|
-
height: number | undefined
|
|
17
|
-
}
|
|
16
|
+
buffer: Buffer
|
|
17
|
+
original: {
|
|
18
|
+
width: number | undefined
|
|
19
|
+
height: number | undefined
|
|
20
|
+
}
|
|
18
21
|
}>
|
|
22
|
+
|
|
19
23
|
export declare const encodeBase64EncodedStringForUpload: (b64: string) => string
|
|
24
|
+
|
|
20
25
|
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
|
|
21
|
-
img: Buffer
|
|
26
|
+
img: Buffer
|
|
22
27
|
}>
|
|
28
|
+
|
|
23
29
|
/** gets the SHA256 of the given media message */
|
|
24
30
|
export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined
|
|
31
|
+
|
|
25
32
|
export declare function getAudioDuration(buffer: Buffer | string | Readable): Promise<number | undefined>
|
|
33
|
+
|
|
26
34
|
/**
|
|
27
|
-
referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
|
|
28
|
-
*/
|
|
35
|
+
referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
|
|
36
|
+
*/
|
|
29
37
|
export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: ILogger): Promise<Uint8Array | undefined>
|
|
38
|
+
|
|
30
39
|
export declare const toReadable: (buffer: Buffer) => Readable
|
|
40
|
+
|
|
31
41
|
export declare const toBuffer: (stream: Readable) => Promise<Buffer>
|
|
42
|
+
|
|
32
43
|
export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
|
|
33
|
-
readonly stream: Readable
|
|
34
|
-
readonly type: "buffer"
|
|
44
|
+
readonly stream: Readable
|
|
45
|
+
readonly type: "buffer"
|
|
35
46
|
} | {
|
|
36
|
-
readonly stream: Readable
|
|
37
|
-
readonly type: "readable"
|
|
47
|
+
readonly stream: Readable
|
|
48
|
+
readonly type: "readable"
|
|
38
49
|
} | {
|
|
39
|
-
readonly stream: Readable
|
|
40
|
-
readonly type: "remote"
|
|
50
|
+
readonly stream: Readable
|
|
51
|
+
readonly type: "remote"
|
|
41
52
|
} | {
|
|
42
|
-
readonly stream: import("fs").ReadStream
|
|
43
|
-
readonly type: "file"
|
|
53
|
+
readonly stream: import("fs").ReadStream
|
|
54
|
+
readonly type: "file"
|
|
44
55
|
}>
|
|
56
|
+
|
|
45
57
|
/** generates a thumbnail for a given media, if required */
|
|
46
58
|
export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
|
|
47
|
-
logger?: Logger
|
|
59
|
+
logger?: Logger
|
|
48
60
|
}): Promise<{
|
|
49
|
-
thumbnail: string | undefined
|
|
50
|
-
originalImageDimensions: {
|
|
51
|
-
width: number
|
|
52
|
-
height: number
|
|
53
|
-
} | undefined
|
|
61
|
+
thumbnail: string | undefined
|
|
62
|
+
originalImageDimensions: {
|
|
63
|
+
width: number
|
|
64
|
+
height: number
|
|
65
|
+
} | undefined
|
|
54
66
|
}>
|
|
67
|
+
|
|
55
68
|
export declare const getHttpStream: (url: string | URL, options?: AxiosRequestConfig & {
|
|
56
|
-
isStream?: true
|
|
69
|
+
isStream?: true
|
|
57
70
|
}) => Promise<Readable>
|
|
71
|
+
|
|
58
72
|
type EncryptedStreamOptions = {
|
|
59
|
-
saveOriginalFileIfRequired?: boolean
|
|
60
|
-
logger?: Logger
|
|
61
|
-
opts?: AxiosRequestConfig
|
|
73
|
+
saveOriginalFileIfRequired?: boolean
|
|
74
|
+
logger?: Logger
|
|
75
|
+
opts?: AxiosRequestConfig
|
|
62
76
|
}
|
|
77
|
+
|
|
63
78
|
export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
|
|
64
|
-
mediaKey: Buffer
|
|
65
|
-
encWriteStream: Readable
|
|
66
|
-
bodyPath: string | undefined
|
|
67
|
-
mac: Buffer
|
|
68
|
-
fileEncSha256: Buffer
|
|
69
|
-
fileSha256: Buffer
|
|
70
|
-
fileLength: number
|
|
71
|
-
didSaveToTmpPath: boolean
|
|
79
|
+
mediaKey: Buffer
|
|
80
|
+
encWriteStream: Readable
|
|
81
|
+
bodyPath: string | undefined
|
|
82
|
+
mac: Buffer
|
|
83
|
+
fileEncSha256: Buffer
|
|
84
|
+
fileSha256: Buffer
|
|
85
|
+
fileLength: number
|
|
86
|
+
didSaveToTmpPath: boolean
|
|
72
87
|
}>
|
|
88
|
+
|
|
73
89
|
export type MediaDownloadOptions = {
|
|
74
|
-
startByte?: number
|
|
75
|
-
endByte?: number
|
|
76
|
-
options?: AxiosRequestConfig<{}>
|
|
90
|
+
startByte?: number
|
|
91
|
+
endByte?: number
|
|
92
|
+
options?: AxiosRequestConfig<{}>
|
|
77
93
|
}
|
|
94
|
+
|
|
78
95
|
export declare const getUrlFromDirectPath: (directPath: string) => string
|
|
96
|
+
|
|
79
97
|
export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<Transform>
|
|
98
|
+
|
|
80
99
|
/**
|
|
81
|
-
* Decrypts and downloads an AES256-CBC encrypted file given the keys.
|
|
82
|
-
* Assumes the SHA256 of the plaintext is appended to the end of the ciphertext
|
|
83
|
-
* */
|
|
100
|
+
* Decrypts and downloads an AES256-CBC encrypted file given the keys.
|
|
101
|
+
* Assumes the SHA256 of the plaintext is appended to the end of the ciphertext
|
|
102
|
+
* */
|
|
84
103
|
export declare const downloadEncryptedContent: (downloadUrl: string, { cipherKey, iv }: MediaDecryptionKeyInfo, { startByte, endByte, options }?: MediaDownloadOptions) => Promise<Transform>
|
|
104
|
+
|
|
85
105
|
export declare function extensionForMediaMessage(message: WAMessageContent): string
|
|
106
|
+
|
|
86
107
|
export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logger, options }: SocketConfig, refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>) => WAMediaUploadFunction
|
|
87
108
|
/**
|
|
88
|
-
* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
|
|
89
|
-
*/
|
|
109
|
+
* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
|
|
110
|
+
*/
|
|
90
111
|
export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode
|
|
112
|
+
|
|
91
113
|
export declare const decodeMediaRetryNode: (node: BinaryNode) => {
|
|
92
|
-
key: proto.IMessageKey
|
|
93
|
-
media?: {
|
|
94
|
-
ciphertext: Uint8Array
|
|
95
|
-
iv: Uint8Array
|
|
96
|
-
} | undefined
|
|
97
|
-
error?: Boom<any> | undefined
|
|
114
|
+
key: proto.IMessageKey
|
|
115
|
+
media?: {
|
|
116
|
+
ciphertext: Uint8Array
|
|
117
|
+
iv: Uint8Array
|
|
118
|
+
} | undefined
|
|
119
|
+
error?: Boom<any> | undefined
|
|
98
120
|
}
|
|
121
|
+
|
|
99
122
|
export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
|
|
100
|
-
ciphertext: Uint8Array
|
|
101
|
-
iv: Uint8Array
|
|
123
|
+
ciphertext: Uint8Array
|
|
124
|
+
iv: Uint8Array
|
|
102
125
|
}, mediaKey: Uint8Array, msgId: string) => Promise<proto.MediaRetryNotification>
|
|
126
|
+
|
|
103
127
|
export declare const getStatusCodeForMediaRetry: (code: number) => any
|
|
128
|
+
|
|
104
129
|
export {}
|
package/lib/Utils/messages.d.ts
CHANGED
|
@@ -3,78 +3,103 @@ import { type Transform } from 'stream'
|
|
|
3
3
|
import { proto } from '../../WAProto'
|
|
4
4
|
import { AnyMediaMessageContent, AnyMessageContent, MediaGenerationOptions, MessageContentGenerationOptions, MessageGenerationOptions, MessageGenerationOptionsFromContent, MessageUserReceipt, WAMessage, WAMessageContent, WAProto } from '../Types'
|
|
5
5
|
import { MediaDownloadOptions } from './messages-media'
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
|
-
* Uses a regex to test whether the string contains a URL, and returns the URL if it does.
|
|
8
|
-
* @param text eg. hello https://google.com
|
|
9
|
-
* @returns the URL, eg. https://google.com
|
|
10
|
-
*/
|
|
8
|
+
* Uses a regex to test whether the string contains a URL, and returns the URL if it does.
|
|
9
|
+
* @param text eg. hello https://google.com
|
|
10
|
+
* @returns the URL, eg. https://google.com
|
|
11
|
+
*/
|
|
11
12
|
export declare const extractUrlFromText: (text: string) => string | undefined
|
|
13
|
+
|
|
12
14
|
export declare const generateLinkPreviewIfRequired: (text: string, getUrlInfo: MessageGenerationOptions['getUrlInfo'], logger: MessageGenerationOptions['logger']) => Promise<import("../Types").WAUrlInfo | undefined>
|
|
15
|
+
|
|
13
16
|
export declare const prepareWAMessageMedia: (message: AnyMediaMessageContent, options: MediaGenerationOptions) => Promise<proto.Message>
|
|
17
|
+
|
|
18
|
+
export declare const prepareAlbumMessageContent: (jid: string, albums: WAProto.IMessage, options: MessageContentGenerationOptions) => Promise<proto.Message[]>
|
|
19
|
+
|
|
14
20
|
export declare const prepareDisappearingMessageSettingContent: (ephemeralExpiration?: number) => proto.Message
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
|
-
* Generate forwarded message content like WA does
|
|
17
|
-
* @param message the message to forward
|
|
18
|
-
* @param options.forceForward will show the message as forwarded even if it is from you
|
|
19
|
-
*/
|
|
23
|
+
* Generate forwarded message content like WA does
|
|
24
|
+
* @param message the message to forward
|
|
25
|
+
* @param options.forceForward will show the message as forwarded even if it is from you
|
|
26
|
+
*/
|
|
20
27
|
export declare const generateForwardMessageContent: (message: WAMessage, forceForward?: boolean) => proto.IMessage
|
|
28
|
+
|
|
21
29
|
export declare const generateWAMessageContent: (message: AnyMessageContent, options: MessageContentGenerationOptions) => Promise<proto.Message>
|
|
30
|
+
|
|
22
31
|
export declare const generateWAMessageFromContent: (jid: string, message: WAMessageContent, options: MessageGenerationOptionsFromContent) => proto.WebMessageInfo
|
|
32
|
+
|
|
23
33
|
export declare const generateWAMessage: (jid: string, content: AnyMessageContent, options: MessageGenerationOptions) => Promise<proto.WebMessageInfo>
|
|
34
|
+
|
|
24
35
|
/** Get the key to access the true type of content */
|
|
25
36
|
export declare const getContentType: (content: WAProto.IMessage | undefined) => keyof proto.IMessage | undefined
|
|
37
|
+
|
|
26
38
|
/**
|
|
27
|
-
* Normalizes ephemeral, view once messages to regular message content
|
|
28
|
-
* Eg. image messages in ephemeral messages, in view once messages etc.
|
|
29
|
-
* @param content
|
|
30
|
-
* @returns
|
|
31
|
-
*/
|
|
39
|
+
* Normalizes ephemeral, view once messages to regular message content
|
|
40
|
+
* Eg. image messages in ephemeral messages, in view once messages etc.
|
|
41
|
+
* @param content
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
32
44
|
export declare const normalizeMessageContent: (content: WAMessageContent | null | undefined) => WAMessageContent | undefined
|
|
45
|
+
|
|
33
46
|
/**
|
|
34
|
-
* Extract the true message content from a message
|
|
35
|
-
* Eg. extracts the inner message from a disappearing message/view once message
|
|
36
|
-
*/
|
|
47
|
+
* Extract the true message content from a message
|
|
48
|
+
* Eg. extracts the inner message from a disappearing message/view once message
|
|
49
|
+
*/
|
|
37
50
|
export declare const extractMessageContent: (content: WAMessageContent | undefined | null) => WAMessageContent | undefined
|
|
51
|
+
|
|
38
52
|
/**
|
|
39
|
-
* Returns the device predicted by message ID
|
|
40
|
-
*/
|
|
53
|
+
* Returns the device predicted by message ID
|
|
54
|
+
*/
|
|
41
55
|
export declare const getDevice: (id: string) => "android" | "unknown" | "web" | "ios" | "desktop"
|
|
56
|
+
|
|
42
57
|
/** Upserts a receipt in the message */
|
|
43
58
|
export declare const updateMessageWithReceipt: (msg: Pick<WAMessage, 'userReceipt'>, receipt: MessageUserReceipt) => void
|
|
59
|
+
|
|
44
60
|
/** Update the message with a new reaction */
|
|
45
61
|
export declare const updateMessageWithReaction: (msg: Pick<WAMessage, 'reactions'>, reaction: proto.IReaction) => void
|
|
62
|
+
|
|
46
63
|
/** Update the message with a new poll update */
|
|
47
64
|
export declare const updateMessageWithPollUpdate: (msg: Pick<WAMessage, 'pollUpdates'>, update: proto.IPollUpdate) => void
|
|
65
|
+
|
|
48
66
|
type VoteAggregation = {
|
|
49
|
-
name: string
|
|
50
|
-
voters: string[]
|
|
67
|
+
name: string
|
|
68
|
+
voters: string[]
|
|
51
69
|
}
|
|
70
|
+
|
|
52
71
|
/**
|
|
53
|
-
* Aggregates all poll updates in a poll.
|
|
54
|
-
* @param msg the poll creation message
|
|
55
|
-
* @param meId your jid
|
|
56
|
-
* @returns A list of options & their voters
|
|
57
|
-
*/
|
|
72
|
+
* Aggregates all poll updates in a poll.
|
|
73
|
+
* @param msg the poll creation message
|
|
74
|
+
* @param meId your jid
|
|
75
|
+
* @returns A list of options & their voters
|
|
76
|
+
*/
|
|
58
77
|
export declare function getAggregateVotesInPollMessage({ message, pollUpdates }: Pick<WAMessage, 'pollUpdates' | 'message'>, meId?: string): VoteAggregation[]
|
|
78
|
+
|
|
59
79
|
/** Given a list of message keys, aggregates them by chat & sender. Useful for sending read receipts in bulk */
|
|
60
80
|
export declare const aggregateMessageKeysNotFromMe: (keys: proto.IMessageKey[]) => {
|
|
61
|
-
jid: string
|
|
62
|
-
participant: string | undefined
|
|
63
|
-
messageIds: string[]
|
|
81
|
+
jid: string
|
|
82
|
+
participant: string | undefined
|
|
83
|
+
messageIds: string[]
|
|
64
84
|
}[]
|
|
85
|
+
|
|
65
86
|
type DownloadMediaMessageContext = {
|
|
66
|
-
reuploadRequest: (msg: WAMessage) => Promise<WAMessage>
|
|
67
|
-
logger: ILogger
|
|
87
|
+
reuploadRequest: (msg: WAMessage) => Promise<WAMessage>
|
|
88
|
+
logger: ILogger
|
|
68
89
|
}
|
|
90
|
+
|
|
69
91
|
/**
|
|
70
|
-
* Downloads the given message. Throws an error if it's not a media message
|
|
71
|
-
*/
|
|
92
|
+
* Downloads the given message. Throws an error if it's not a media message
|
|
93
|
+
*/
|
|
72
94
|
export declare const downloadMediaMessage: <Type extends "stream" | "buffer">(message: WAMessage, type: Type, options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext) => Promise<Type extends "buffer" ? Buffer : Transform>
|
|
95
|
+
|
|
73
96
|
/** Checks whether the given message is a media message if it is returns the inner content */
|
|
74
97
|
export declare const assertMediaContent: (content: proto.IMessage | null | undefined) => proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage
|
|
98
|
+
|
|
75
99
|
/**
|
|
76
|
-
* this is an experimental patch to make buttons work
|
|
77
|
-
* Don't know how it works, but it does for now
|
|
78
|
-
*/
|
|
100
|
+
* this is an experimental patch to make buttons work
|
|
101
|
+
* Don't know how it works, but it does for now
|
|
102
|
+
*/
|
|
79
103
|
export declare const patchMessageForMdIfRequired: (message: proto.IMessage) => proto.IMessage
|
|
104
|
+
|
|
80
105
|
export {}
|
package/lib/Utils/messages.js
CHANGED
|
@@ -340,6 +340,71 @@ if (!mediaType) {
|
|
|
340
340
|
return obj
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
const prepareAlbumMessageContent = async (jid, albums, options) => {
|
|
344
|
+
let mediaHandle
|
|
345
|
+
let mediaMsg
|
|
346
|
+
let message = []
|
|
347
|
+
|
|
348
|
+
const albumMsg = generateWAMessageFromContent(jid, {
|
|
349
|
+
albumMessage: {
|
|
350
|
+
expectedImageCount: albums.filter(item => 'image' in item).length,
|
|
351
|
+
expectedVideoCount: albums.filter(item => 'video' in item).length
|
|
352
|
+
}
|
|
353
|
+
}, options)
|
|
354
|
+
|
|
355
|
+
await options.suki.relayMessage(jid, albumMsg.message, {
|
|
356
|
+
messageId: albumMsg.key.id
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
for (const i in albums) {
|
|
360
|
+
const media = albums[i]
|
|
361
|
+
|
|
362
|
+
if ('image' in media) {
|
|
363
|
+
mediaMsg = await generateWAMessage(jid, {
|
|
364
|
+
image: media.image,
|
|
365
|
+
...media,
|
|
366
|
+
...options
|
|
367
|
+
}, {
|
|
368
|
+
userJid: options.userJid,
|
|
369
|
+
upload: async (encFilePath, opts) => {
|
|
370
|
+
const up = await options.suki.waUploadToServer(encFilePath, { ...opts, newsletter: WABinary_1.isJidNewsletter(jid) })
|
|
371
|
+
mediaHandle = up.handle
|
|
372
|
+
return up
|
|
373
|
+
},
|
|
374
|
+
...options
|
|
375
|
+
})
|
|
376
|
+
} else if ('video' in message) {
|
|
377
|
+
mediaMsg = await generateWAMessage(jid, {
|
|
378
|
+
video: media.video,
|
|
379
|
+
...media,
|
|
380
|
+
...options
|
|
381
|
+
}, {
|
|
382
|
+
userJid: options.userJid,
|
|
383
|
+
upload: async (encFilePath, opts) => {
|
|
384
|
+
const up = await options.suki.waUploadToServer(encFilePath, { ...opts, newsletter: WABinary_1.isJidNewsletter(jid) })
|
|
385
|
+
mediaHandle = up.handle
|
|
386
|
+
return up
|
|
387
|
+
},
|
|
388
|
+
...options
|
|
389
|
+
})
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (mediaMsg) {
|
|
393
|
+
mediaMsg.message.messageContextInfo = {
|
|
394
|
+
messageSecret: crypto_1.randomBytes(32),
|
|
395
|
+
messageAssociation: {
|
|
396
|
+
associationType: 1,
|
|
397
|
+
parentMessageKey: albumMsg.key
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
message.push(mediaMsg)
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return message
|
|
406
|
+
}
|
|
407
|
+
|
|
343
408
|
const prepareDisappearingMessageSettingContent = (expiration) => {
|
|
344
409
|
const content = {
|
|
345
410
|
ephemeralMessage: {
|
|
@@ -534,7 +599,6 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
534
599
|
}
|
|
535
600
|
|
|
536
601
|
else if ('groupInvite' in message) {
|
|
537
|
-
m.messageContextInfo = {}
|
|
538
602
|
m.groupInviteMessage = {}
|
|
539
603
|
|
|
540
604
|
m.groupInviteMessage.inviteCode = message.groupInvite.code
|
|
@@ -557,7 +621,6 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
557
621
|
}
|
|
558
622
|
|
|
559
623
|
else if ('adminInvite' in message) {
|
|
560
|
-
m.messageContextInfo = {}
|
|
561
624
|
m.newsletterAdminInviteMessage = {}
|
|
562
625
|
|
|
563
626
|
m.newsletterAdminInviteMessage.newsletterJid = message.adminInvite.jid
|
|
@@ -598,7 +661,6 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
598
661
|
}
|
|
599
662
|
|
|
600
663
|
else if ('call' in message) {
|
|
601
|
-
m.messageContextInfo = {}
|
|
602
664
|
m.scheduledCallCreationMessage = {}
|
|
603
665
|
|
|
604
666
|
m.scheduledCallCreationMessage.scheduledTimestampMs = message.call?.time || Date.now()
|
|
@@ -672,6 +734,16 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
672
734
|
m.ptvMessage = videoMessage
|
|
673
735
|
}
|
|
674
736
|
|
|
737
|
+
else if ('album' in message) {
|
|
738
|
+
const imageMessages = message.album.filter(item => 'image' in item)
|
|
739
|
+
const videoMessages = message.album.filter(item => 'video' in item)
|
|
740
|
+
|
|
741
|
+
m.albumMessage = Types_1.WAProto.Message.AlbumMessage.fromObject({
|
|
742
|
+
expectedImageCount: imageMessages.length,
|
|
743
|
+
expectedVideoCount: videoMessages.length
|
|
744
|
+
})
|
|
745
|
+
}
|
|
746
|
+
|
|
675
747
|
else if ('order' in message) {
|
|
676
748
|
m.orderMessage = Types_1.WAProto.Message.OrderMessage.fromObject(message.order)
|
|
677
749
|
|
|
@@ -681,13 +753,19 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
681
753
|
}
|
|
682
754
|
}
|
|
683
755
|
|
|
684
|
-
else if ('event' in message) {
|
|
756
|
+
else if ('event' in message) {
|
|
685
757
|
m.eventMessage = Types_1.WAProto.Message.EventMessage.fromObject(message.event)
|
|
686
|
-
|
|
758
|
+
|
|
687
759
|
if (!message.event.startTime) {
|
|
688
|
-
|
|
689
|
-
}
|
|
690
|
-
|
|
760
|
+
m.eventMessage.startTime = generics_1.unixTimestampSeconds() + 86400
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
if (options.getCallLink && message.event.call) {
|
|
764
|
+
const link = await options.getCallLink(message.event.call, m.eventMessage.startTime)
|
|
765
|
+
m.eventMessage.joinLink = link
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
|
|
691
769
|
m.eventMessage.contextInfo = {
|
|
692
770
|
...(message.contextInfo || {}),
|
|
693
771
|
...(message.mentions ? { mentionedJid: message.mentions } : {})
|
|
@@ -1706,6 +1784,7 @@ module.exports = {
|
|
|
1706
1784
|
extractUrlFromText,
|
|
1707
1785
|
generateLinkPreviewIfRequired,
|
|
1708
1786
|
prepareWAMessageMedia,
|
|
1787
|
+
prepareAlbumMessageContent,
|
|
1709
1788
|
prepareDisappearingMessageSettingContent,
|
|
1710
1789
|
generateForwardMessageContent,
|
|
1711
1790
|
generateWAMessageContent,
|
|
@@ -2,18 +2,19 @@ import { proto } from '../../WAProto'
|
|
|
2
2
|
import { KeyPair } from '../Types'
|
|
3
3
|
import { BinaryNode } from '../WABinary'
|
|
4
4
|
import { ILogger } from './logger'
|
|
5
|
+
|
|
5
6
|
export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }: {
|
|
6
|
-
keyPair: KeyPair
|
|
7
|
-
NOISE_HEADER: Uint8Array
|
|
8
|
-
logger: ILogger
|
|
9
|
-
routingInfo?: Buffer | undefined
|
|
7
|
+
keyPair: KeyPair
|
|
8
|
+
NOISE_HEADER: Uint8Array
|
|
9
|
+
logger: ILogger
|
|
10
|
+
routingInfo?: Buffer | undefined
|
|
10
11
|
}) => {
|
|
11
|
-
encrypt: (plaintext: Uint8Array) => Buffer
|
|
12
|
-
decrypt: (ciphertext: Uint8Array) => Buffer
|
|
13
|
-
authenticate: (data: Uint8Array) => void
|
|
14
|
-
mixIntoKey: (data: Uint8Array) => Promise<void>
|
|
15
|
-
finishInit: () => Promise<void>
|
|
16
|
-
processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => Promise<Buffer>
|
|
17
|
-
encodeFrame: (data: Buffer | Uint8Array) => Buffer
|
|
18
|
-
decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => Promise<void>
|
|
12
|
+
encrypt: (plaintext: Uint8Array) => Buffer
|
|
13
|
+
decrypt: (ciphertext: Uint8Array) => Buffer
|
|
14
|
+
authenticate: (data: Uint8Array) => void
|
|
15
|
+
mixIntoKey: (data: Uint8Array) => Promise<void>
|
|
16
|
+
finishInit: () => Promise<void>
|
|
17
|
+
processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => Promise<Buffer>
|
|
18
|
+
encodeFrame: (data: Buffer | Uint8Array) => Buffer
|
|
19
|
+
decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => Promise<void>
|
|
19
20
|
}
|