@areumtecnologia/wasockets 1.1.6 → 2.0.0-alpha.1
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/README.md +742 -34
- package/WAProto/index.d.ts +17 -0
- package/lib/Defaults/connection.js +34 -2
- package/lib/Defaults/index.d.ts +6 -0
- package/lib/Plugins/index.d.ts +33 -0
- package/lib/Plugins/index.js +125 -0
- package/lib/Socket/business.js +33 -0
- package/lib/Socket/chats.js +103 -2
- package/lib/Socket/community.js +126 -69
- package/lib/Socket/groups.js +103 -26
- package/lib/Socket/index.js +27 -3
- package/lib/Socket/messages-send.js +111 -0
- package/lib/Socket/newsletter.js +125 -3
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/make-in-memory-store.js +294 -25
- package/lib/Types/index.d.ts +199 -0
- package/lib/Utils/index.d.ts +33 -0
- package/lib/Utils/index.js +2 -1
- package/lib/Utils/messages.js +14 -3
- package/lib/Utils/reconnect.js +136 -0
- package/lib/Utils/validate-connection.js +5 -5
- package/lib/WABinary/index.d.ts +17 -0
- package/lib/index.d.ts +274 -0
- package/lib/index.js +1 -0
- package/package.json +19 -5
package/lib/Utils/messages.js
CHANGED
|
@@ -189,9 +189,12 @@ const prepareWAMessageMedia = async (message, options) => {
|
|
|
189
189
|
return obj
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
if (uploadData.waveform && !(uploadData.waveform instanceof Uint8Array)) {
|
|
193
|
+
uploadData.waveform = new Uint8Array(uploadData.waveform)
|
|
194
|
+
}
|
|
192
195
|
const requiresDurationComputation = mediaType === 'audio' && typeof uploadData.seconds === 'undefined'
|
|
193
196
|
const requiresThumbnailComputation = (mediaType === 'image' || mediaType === 'video') && typeof uploadData['jpegThumbnail'] === 'undefined'
|
|
194
|
-
const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true
|
|
197
|
+
const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true && !uploadData.waveform
|
|
195
198
|
const requiresAudioBackground = options.backgroundColor && mediaType === 'audio' && uploadData.ptt === true
|
|
196
199
|
const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation
|
|
197
200
|
const { mediaKey, encFilePath, originalFilePath, fileEncSha256, fileSha256, fileLength } = await encryptedStream(uploadData.media, options.mediaTypeOverride || mediaType, {
|
|
@@ -316,6 +319,7 @@ const prepareAlbumMessageContent = async (jid, albums, options) => {
|
|
|
316
319
|
messageId: albumMsg.key.id
|
|
317
320
|
})
|
|
318
321
|
|
|
322
|
+
let idx = 0
|
|
319
323
|
for (const media of albums) {
|
|
320
324
|
let content = {}
|
|
321
325
|
if ('image' in media) {
|
|
@@ -347,16 +351,19 @@ const prepareAlbumMessageContent = async (jid, albums, options) => {
|
|
|
347
351
|
)
|
|
348
352
|
|
|
349
353
|
if (mediaMsg) {
|
|
354
|
+
const albumAssociationType = proto.MessageAssociation?.AssociationType?.MEDIA_ALBUM || WAProto.MessageAssociation?.AssociationType?.MEDIA_ALBUM || 1
|
|
350
355
|
mediaMsg.message.messageContextInfo = {
|
|
351
356
|
messageSecret: randomBytes(32),
|
|
352
357
|
messageAssociation: {
|
|
353
|
-
associationType:
|
|
354
|
-
parentMessageKey: albumMsg.key
|
|
358
|
+
associationType: albumAssociationType,
|
|
359
|
+
parentMessageKey: albumMsg.key,
|
|
360
|
+
messageIndex: idx
|
|
355
361
|
}
|
|
356
362
|
}
|
|
357
363
|
}
|
|
358
364
|
|
|
359
365
|
message.push(mediaMsg)
|
|
366
|
+
idx++
|
|
360
367
|
}
|
|
361
368
|
|
|
362
369
|
return message
|
|
@@ -1317,6 +1324,10 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
1317
1324
|
m = { interactiveMessage }
|
|
1318
1325
|
}
|
|
1319
1326
|
|
|
1327
|
+
if (hasOptionalProperty(message, "viewOnce") && message.viewOnce) {
|
|
1328
|
+
m = { viewOnceMessageV2: { message: m } }
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1320
1331
|
if (hasOptionalProperty(message, "ephemeral")) {
|
|
1321
1332
|
m = { ephemeralMessage: { message: m } }
|
|
1322
1333
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const { DisconnectReason } = require("../Types")
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Categorizes an error or status code into reconnectable vs fatal
|
|
9
|
+
*/
|
|
10
|
+
const shouldReconnect = (error) => {
|
|
11
|
+
const statusCode = error?.output?.statusCode || error?.statusCode || error?.status || error
|
|
12
|
+
|
|
13
|
+
// Non-recoverable fatal errors (user logged out or account unlinked)
|
|
14
|
+
if (
|
|
15
|
+
statusCode === DisconnectReason.loggedOut ||
|
|
16
|
+
statusCode === DisconnectReason.multideviceMismatch ||
|
|
17
|
+
statusCode === DisconnectReason.forbidden
|
|
18
|
+
) {
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Calculate exponential backoff delay with full jitter
|
|
27
|
+
* @param {number} attempt Attempt count (0-indexed or 1-indexed)
|
|
28
|
+
* @param {object} options Configuration options
|
|
29
|
+
*/
|
|
30
|
+
const getReconnectDelay = (attempt = 0, options = {}) => {
|
|
31
|
+
const {
|
|
32
|
+
baseDelayMs = 1000,
|
|
33
|
+
maxDelayMs = 45000,
|
|
34
|
+
factor = 1.8,
|
|
35
|
+
jitter = true,
|
|
36
|
+
statusCode
|
|
37
|
+
} = options
|
|
38
|
+
|
|
39
|
+
// Special case for WhatsApp restartRequired (515) - fast restart
|
|
40
|
+
if (statusCode === DisconnectReason.restartRequired) {
|
|
41
|
+
return Math.floor(Math.random() * 500) + 250 // 250-750ms
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const calculatedDelay = Math.min(maxDelayMs, baseDelayMs * Math.pow(factor, Math.max(0, attempt)))
|
|
45
|
+
|
|
46
|
+
if (jitter) {
|
|
47
|
+
// Decorrelated jitter: uniformly distributed between 50% and 100% of calculated backoff
|
|
48
|
+
const minJitter = calculatedDelay * 0.5
|
|
49
|
+
const randomSpread = Math.random() * (calculatedDelay - minJitter)
|
|
50
|
+
return Math.floor(minJitter + randomSpread)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return Math.floor(calculatedDelay)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Creates an Adaptive Reconnection Manager instance
|
|
58
|
+
*/
|
|
59
|
+
const makeReconnectManager = (config = {}) => {
|
|
60
|
+
const {
|
|
61
|
+
logger,
|
|
62
|
+
maxAttempts = 15,
|
|
63
|
+
baseDelayMs = 1000,
|
|
64
|
+
maxDelayMs = 45000,
|
|
65
|
+
onReconnect
|
|
66
|
+
} = config
|
|
67
|
+
|
|
68
|
+
let attempts = 0
|
|
69
|
+
let reconnectTimeout = null
|
|
70
|
+
let isReconnecting = false
|
|
71
|
+
|
|
72
|
+
const reset = () => {
|
|
73
|
+
attempts = 0
|
|
74
|
+
isReconnecting = false
|
|
75
|
+
if (reconnectTimeout) {
|
|
76
|
+
clearTimeout(reconnectTimeout)
|
|
77
|
+
reconnectTimeout = null
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const handleDisconnect = async (error) => {
|
|
82
|
+
const canReconnect = shouldReconnect(error)
|
|
83
|
+
const statusCode = error?.output?.statusCode || error?.statusCode || error?.status
|
|
84
|
+
|
|
85
|
+
if (!canReconnect) {
|
|
86
|
+
logger?.info({ statusCode }, 'reconnection skipped: fatal disconnect reason')
|
|
87
|
+
reset()
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (attempts >= maxAttempts) {
|
|
92
|
+
logger?.warn({ attempts, maxAttempts }, 'maximum reconnection attempts reached')
|
|
93
|
+
reset()
|
|
94
|
+
return false
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
attempts++
|
|
98
|
+
const delay = getReconnectDelay(attempts, { baseDelayMs, maxDelayMs, statusCode })
|
|
99
|
+
logger?.info({ attempt: attempts, delay, statusCode }, 'scheduling adaptive reconnection')
|
|
100
|
+
|
|
101
|
+
isReconnecting = true
|
|
102
|
+
if (reconnectTimeout) {
|
|
103
|
+
clearTimeout(reconnectTimeout)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return new Promise((resolve) => {
|
|
107
|
+
reconnectTimeout = setTimeout(async () => {
|
|
108
|
+
reconnectTimeout = null
|
|
109
|
+
try {
|
|
110
|
+
if (typeof onReconnect === 'function') {
|
|
111
|
+
await onReconnect(attempts)
|
|
112
|
+
}
|
|
113
|
+
resolve(true)
|
|
114
|
+
} catch (err) {
|
|
115
|
+
logger?.error({ err }, 'error during reconnection callback')
|
|
116
|
+
resolve(false)
|
|
117
|
+
}
|
|
118
|
+
}, delay)
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
get attempts() { return attempts },
|
|
124
|
+
get isReconnecting() { return isReconnecting },
|
|
125
|
+
shouldReconnect,
|
|
126
|
+
getReconnectDelay,
|
|
127
|
+
handleDisconnect,
|
|
128
|
+
reset
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = {
|
|
133
|
+
shouldReconnect,
|
|
134
|
+
getReconnectDelay,
|
|
135
|
+
makeReconnectManager
|
|
136
|
+
}
|
|
@@ -34,9 +34,9 @@ const getUserAgent = (config) => {
|
|
|
34
34
|
? proto.ClientPayload.UserAgent.Platform.ANDROID
|
|
35
35
|
:*/ proto.ClientPayload.UserAgent.Platform.WEB,
|
|
36
36
|
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
37
|
-
osVersion: '0.
|
|
37
|
+
osVersion: config.browser?.[2] || '10.0.22631',
|
|
38
38
|
device: 'Desktop',
|
|
39
|
-
osBuildNumber: '0.
|
|
39
|
+
osBuildNumber: config.browser?.[2] || '10.0.22631',
|
|
40
40
|
localeLanguageIso6391: 'en',
|
|
41
41
|
mnc: '000',
|
|
42
42
|
mcc: '000',
|
|
@@ -128,9 +128,9 @@ const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentity
|
|
|
128
128
|
supportGuestChat: undefined
|
|
129
129
|
},
|
|
130
130
|
version: {
|
|
131
|
-
primary:
|
|
132
|
-
secondary:
|
|
133
|
-
tertiary:
|
|
131
|
+
primary: config.version?.[0] || 2,
|
|
132
|
+
secondary: config.version?.[1] || 3000,
|
|
133
|
+
tertiary: config.version?.[2] || 1047214234
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface BinaryNodeAttributes {
|
|
2
|
+
[key: string]: string | undefined
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface BinaryNode {
|
|
6
|
+
tag: string
|
|
7
|
+
attrs: BinaryNodeAttributes
|
|
8
|
+
content?: BinaryNode[] | string | Uint8Array
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export declare function jidEncode(user: string | null | undefined, server: string, device?: number, agent?: number): string
|
|
12
|
+
export declare function encodeBinaryNode(node: BinaryNode): Uint8Array
|
|
13
|
+
export declare function decodeBinaryNode(data: Uint8Array): BinaryNode
|
|
14
|
+
export declare const S_WHATSAPP_NET: string
|
|
15
|
+
export declare const STORIES_JID: string
|
|
16
|
+
export declare const OFFICIAL_BIZ_JID: string
|
|
17
|
+
export declare const SERVER_JID: string
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
import { proto } from '../WAProto'
|
|
4
|
+
import { AuthenticationState, BaileysEventEmitter, ConnectionState, Contact, GroupMetadata, WACallEvent, WAMessage, WAMessageKey, WAMessageContent, AnyMessageContent, MiscMessageGenerationOptions } from './Types'
|
|
5
|
+
import { PluginManager } from './Plugins'
|
|
6
|
+
|
|
7
|
+
export * from './Types'
|
|
8
|
+
export * from './Utils'
|
|
9
|
+
export * from './Defaults'
|
|
10
|
+
export * from './Store'
|
|
11
|
+
export * from './WABinary'
|
|
12
|
+
export * from './Plugins'
|
|
13
|
+
export { proto }
|
|
14
|
+
|
|
15
|
+
export interface GroupPermissionsPolicies {
|
|
16
|
+
announce?: boolean
|
|
17
|
+
restrict?: boolean
|
|
18
|
+
memberAddMode?: 'admin_add' | 'all_member_add'
|
|
19
|
+
approvalMode?: boolean | 'on' | 'off'
|
|
20
|
+
ephemeral?: number | false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface GroupSubGroupsResult {
|
|
24
|
+
communityJid: string
|
|
25
|
+
isCommunity: boolean
|
|
26
|
+
defaultSubGroup: any | null
|
|
27
|
+
subGroups: any[]
|
|
28
|
+
linkedGroups: any[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SendAlbumMediaItem {
|
|
32
|
+
image?: any
|
|
33
|
+
video?: any
|
|
34
|
+
caption?: string
|
|
35
|
+
[key: string]: any
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface UserFacingSocketConfig {
|
|
39
|
+
version?: [number, number, number]
|
|
40
|
+
browser?: [string, string, string]
|
|
41
|
+
waWebSocketUrl?: string
|
|
42
|
+
connectTimeoutMs?: number
|
|
43
|
+
keepAliveIntervalMs?: number
|
|
44
|
+
logger?: any
|
|
45
|
+
printQRInTerminal?: boolean
|
|
46
|
+
emitOwnEvents?: boolean
|
|
47
|
+
defaultQueryTimeoutMs?: number
|
|
48
|
+
customUploadHosts?: string[]
|
|
49
|
+
retryRequestDelayMs?: number
|
|
50
|
+
maxMsgRetryCount?: number
|
|
51
|
+
fireInitQueries?: boolean
|
|
52
|
+
auth?: AuthenticationState
|
|
53
|
+
markOnlineOnConnect?: boolean
|
|
54
|
+
syncFullHistory?: boolean
|
|
55
|
+
patchMessageBeforeSending?: (msg: proto.IMessage) => proto.IMessage | Promise<proto.IMessage>
|
|
56
|
+
shouldSyncHistoryMessage?: (msg: proto.IHistorySyncNotification) => boolean
|
|
57
|
+
shouldIgnoreJid?: (jid: string) => boolean
|
|
58
|
+
linkPreviewImageThumbnailWidth?: number
|
|
59
|
+
transactionOpts?: { maxCommitRetries: number; delayBetweenTriesMs: number }
|
|
60
|
+
generateHighQualityLinkPreview?: boolean
|
|
61
|
+
enableAutoSessionRecreation?: boolean
|
|
62
|
+
enableRecentMessageCache?: boolean
|
|
63
|
+
enableMessageQueue?: boolean
|
|
64
|
+
messageQueueTtlMs?: number
|
|
65
|
+
maxReconnectAttempts?: number
|
|
66
|
+
enableGroupCache?: boolean
|
|
67
|
+
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadata | undefined>
|
|
68
|
+
plugins?: any[]
|
|
69
|
+
[key: string]: any
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface WASocket {
|
|
73
|
+
type: 'md'
|
|
74
|
+
ws: any
|
|
75
|
+
ev: BaileysEventEmitter
|
|
76
|
+
authState: AuthenticationState
|
|
77
|
+
user: Contact | undefined
|
|
78
|
+
plugins: PluginManager
|
|
79
|
+
|
|
80
|
+
// Plugin & Middleware system
|
|
81
|
+
use(plugin: any, options?: any): WASocket
|
|
82
|
+
registerMiddleware(hook: 'beforeSendMessage' | 'afterSendMessage' | 'beforeRecvMessage' | 'afterRecvMessage' | 'connectionUpdate', fn: Function): () => void
|
|
83
|
+
hasPlugin(name: string): boolean
|
|
84
|
+
listPlugins(): Array<{ name: string; registeredAt: number; version: string; description: string }>
|
|
85
|
+
|
|
86
|
+
// Connection & Auth
|
|
87
|
+
waitForConnectionUpdate(check: (u: Partial<ConnectionState>) => boolean | undefined, timeoutMs?: number): Promise<void>
|
|
88
|
+
end(error: Error | undefined): void
|
|
89
|
+
logout(msg?: string): Promise<void>
|
|
90
|
+
requestPairingCode(phoneNumber: string): Promise<string>
|
|
91
|
+
repairSession(jid: string): Promise<void>
|
|
92
|
+
onWhatsApp(...phoneNumber: string[]): Promise<{ jid: string; exists: boolean }[] | undefined>
|
|
93
|
+
|
|
94
|
+
// Presence & Status
|
|
95
|
+
sendPresenceUpdate(type: 'available' | 'unavailable' | 'composing' | 'recording' | 'paused', toJid?: string): Promise<void>
|
|
96
|
+
presenceSubscribe(toJid: string): Promise<void>
|
|
97
|
+
|
|
98
|
+
// Profile & User
|
|
99
|
+
profilePictureUrl(jid: string, type?: 'image' | 'preview', timeoutMs?: number): Promise<string | undefined>
|
|
100
|
+
updateProfilePicture(jid: string, content: any): Promise<void>
|
|
101
|
+
removeProfilePicture(jid: string): Promise<void>
|
|
102
|
+
fetchStatus(jid: string): Promise<{ status: string | undefined; setAt: Date } | undefined>
|
|
103
|
+
updateProfileStatus(status: string): Promise<void>
|
|
104
|
+
updateProfileName(name: string): Promise<void>
|
|
105
|
+
|
|
106
|
+
// Cross-JID / LID Architecture
|
|
107
|
+
toPn(jid: string, fetchIfMissing?: boolean): Promise<string | null>
|
|
108
|
+
toLid(jid: string, fetchIfMissing?: boolean): Promise<string | null>
|
|
109
|
+
resolveJid(jid: string, fetchIfMissing?: boolean): Promise<{ pn: string | null; lid: string | null; jid: string | null }>
|
|
110
|
+
storeLidPnMapping(pn: string, lid: string): Promise<boolean>
|
|
111
|
+
|
|
112
|
+
// Messaging
|
|
113
|
+
sendMessage(jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions & { mentionAll?: boolean; adminsOnly?: boolean; excludeMe?: boolean }): Promise<WAMessage | undefined>
|
|
114
|
+
sendAlbumMessage(jid: string, medias: SendAlbumMediaItem[], options?: MiscMessageGenerationOptions): Promise<WAMessage[]>
|
|
115
|
+
groupSendMentionAll(jid: string, content: string | AnyMessageContent, options?: { adminsOnly?: boolean; excludeMe?: boolean }): Promise<WAMessage | undefined>
|
|
116
|
+
relayMessage(jid: string, message: proto.IMessage, options: any): Promise<string>
|
|
117
|
+
readMessages(keys: WAMessageKey[]): Promise<void>
|
|
118
|
+
star(jid: string, messages: { id: string; fromMe?: boolean }[], star: boolean): Promise<void>
|
|
119
|
+
sendStatusMentions(content: any, jids?: string[]): Promise<WAMessage>
|
|
120
|
+
reactToStatus(key: WAMessageKey, reaction?: string): Promise<string>
|
|
121
|
+
sendEventResponse(jid: string, eventCreationMessageKey: WAMessageKey, response: string | number, extraGuestCount?: number): Promise<WAMessage | undefined>
|
|
122
|
+
cancelEvent(jid: string, eventKey: WAMessageKey): Promise<WAMessage | undefined>
|
|
123
|
+
|
|
124
|
+
// Calls (Web Calling)
|
|
125
|
+
offerCall(toJid: string, isVideo?: boolean): Promise<any>
|
|
126
|
+
acceptCall(callId: string, callFrom: string): Promise<void>
|
|
127
|
+
rejectCall(callId: string, callFrom: string): Promise<void>
|
|
128
|
+
terminateCall(callId: string, callFrom: string): Promise<void>
|
|
129
|
+
|
|
130
|
+
// Chats & Contacts
|
|
131
|
+
chatModify(mod: any, jid: string): Promise<void>
|
|
132
|
+
updateFavorite(jid: string, favorite: boolean): Promise<void>
|
|
133
|
+
updateChatNote(jid: string, note: string): Promise<void>
|
|
134
|
+
removeChatNote(jid: string): Promise<void>
|
|
135
|
+
addOrEditContact(contact: any): Promise<void>
|
|
136
|
+
removeContact(jid: string): Promise<void>
|
|
137
|
+
|
|
138
|
+
// Groups
|
|
139
|
+
groupMetadata(jid: string): Promise<GroupMetadata>
|
|
140
|
+
groupCreate(subject: string, participants: string[]): Promise<GroupMetadata>
|
|
141
|
+
groupLeave(id: string): Promise<void>
|
|
142
|
+
groupUpdateSubject(jid: string, subject: string): Promise<void>
|
|
143
|
+
groupUpdateDescription(jid: string, description: string): Promise<void>
|
|
144
|
+
groupInviteCode(jid: string): Promise<string | undefined>
|
|
145
|
+
groupRevokeInvite(jid: string): Promise<string | undefined>
|
|
146
|
+
groupAcceptInvite(code: string): Promise<string | undefined>
|
|
147
|
+
groupGetInviteInfo(code: string): Promise<GroupMetadata>
|
|
148
|
+
groupParticipantsUpdate(jid: string, participants: string[], action: 'add' | 'remove' | 'demote' | 'promote'): Promise<any[]>
|
|
149
|
+
groupSettingUpdate(jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked'): Promise<void>
|
|
150
|
+
groupMemberAddMode(jid: string, mode: 'admin_add' | 'all_member_add'): Promise<void>
|
|
151
|
+
groupJoinApprovalMode(jid: string, mode: 'on' | 'off' | boolean): Promise<void>
|
|
152
|
+
groupMembershipApprovalMode(jid: string, mode: 'on' | 'off' | boolean): Promise<void>
|
|
153
|
+
groupRequestParticipantsList(jid: string): Promise<any[]>
|
|
154
|
+
groupRequestParticipantsUpdate(jid: string, participants: string[], action: 'approve' | 'reject'): Promise<any[]>
|
|
155
|
+
groupApprovePendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
|
|
156
|
+
groupRejectPendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
|
|
157
|
+
groupUpdatePermissions(jid: string, policies: GroupPermissionsPolicies): Promise<Record<string, any>>
|
|
158
|
+
groupGetAdminJids(jid: string): Promise<string[]>
|
|
159
|
+
groupGetParticipants(jid: string): Promise<any[]>
|
|
160
|
+
groupToggleEphemeral(jid: string, ephemeralExpiration: number): Promise<void>
|
|
161
|
+
|
|
162
|
+
// Communities v2
|
|
163
|
+
communityCreate(subject: string, body?: string): Promise<GroupMetadata | null>
|
|
164
|
+
communityCreateGroup(subject: string, participants: string[], parentCommunityJid: string): Promise<GroupMetadata | null>
|
|
165
|
+
communityLinkGroup(groupJid: string, parentCommunityJid: string): Promise<void>
|
|
166
|
+
communityUnlinkGroup(groupJid: string, parentCommunityJid: string): Promise<void>
|
|
167
|
+
communityFetchLinkedGroups(jid: string): Promise<any>
|
|
168
|
+
communityFetchSubGroups(jid: string): Promise<GroupSubGroupsResult>
|
|
169
|
+
communityMembershipApprovalMode(jid: string, mode: 'on' | 'off' | boolean): Promise<void>
|
|
170
|
+
communityApprovePendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
|
|
171
|
+
communityRejectPendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
|
|
172
|
+
communityUpdatePermissions(jid: string, policies: GroupPermissionsPolicies): Promise<Record<string, any>>
|
|
173
|
+
|
|
174
|
+
// Newsletters v2
|
|
175
|
+
newsletterCreate(name: string, description?: string, picture?: Buffer): Promise<any>
|
|
176
|
+
newsletterMetadata(type: 'invite' | 'jid', key: string): Promise<any>
|
|
177
|
+
newsletterFetchMessages(jid: string, count: number, since?: number): Promise<any[]>
|
|
178
|
+
newsletterFetchMessage(jid: string, messageServerId: string | number): Promise<any>
|
|
179
|
+
newsletterFetchReactions(jid: string, messageServerId: string | number): Promise<any[]>
|
|
180
|
+
newsletterToggleMute(jid: string, mute: boolean): Promise<void>
|
|
181
|
+
newsletterFollow(jid: string): Promise<void>
|
|
182
|
+
newsletterUnfollow(jid: string): Promise<void>
|
|
183
|
+
newsletterSubscribers(jid: string): Promise<any>
|
|
184
|
+
newsletterSubscribed(): Promise<any[]>
|
|
185
|
+
newsletterUpdate(jid: string, updates: any): Promise<any>
|
|
186
|
+
newsletterUpdateName(jid: string, name: string): Promise<any>
|
|
187
|
+
newsletterUpdateDescription(jid: string, description: string): Promise<any>
|
|
188
|
+
newsletterUpdatePicture(jid: string, content: any): Promise<any>
|
|
189
|
+
newsletterRemovePicture(jid: string): Promise<any>
|
|
190
|
+
newsletterReactMessage(jid: string, serverId: string | number, reaction?: string): Promise<void>
|
|
191
|
+
newsletterAdminCount(jid: string): Promise<number>
|
|
192
|
+
newsletterChangeOwner(jid: string, newOwnerJid: string): Promise<void>
|
|
193
|
+
newsletterDelete(jid: string): Promise<void>
|
|
194
|
+
|
|
195
|
+
// Labels & Quick Replies
|
|
196
|
+
createLabel(name: string, color?: number): Promise<any>
|
|
197
|
+
updateLabel(labelId: string, name: string, color?: number): Promise<any>
|
|
198
|
+
deleteLabel(labelId: string): Promise<any>
|
|
199
|
+
addChatLabel(jid: string, labelId: string): Promise<void>
|
|
200
|
+
removeChatLabel(jid: string, labelId: string): Promise<void>
|
|
201
|
+
addMessageLabel(jid: string, messageId: string, labelId: string): Promise<void>
|
|
202
|
+
removeMessageLabel(jid: string, messageId: string, labelId: string): Promise<void>
|
|
203
|
+
addOrEditQuickReply(quickReply: any): Promise<void>
|
|
204
|
+
removeQuickReply(id: string): Promise<void>
|
|
205
|
+
|
|
206
|
+
// Privacy
|
|
207
|
+
fetchBlocklist(): Promise<string[]>
|
|
208
|
+
updateBlockStatus(jid: string, action: 'block' | 'unblock'): Promise<void>
|
|
209
|
+
fetchPrivacySettings(force?: boolean): Promise<any>
|
|
210
|
+
updateLastSeenPrivacy(value: 'all' | 'contacts' | 'contact_blacklist' | 'none'): Promise<void>
|
|
211
|
+
updateOnlinePrivacy(value: 'all' | 'match_last_seen'): Promise<void>
|
|
212
|
+
updateReadReceiptsPrivacy(value: 'all' | 'none'): Promise<void>
|
|
213
|
+
updateProfilePicturePrivacy(value: 'all' | 'contacts' | 'contact_blacklist' | 'none'): Promise<void>
|
|
214
|
+
updateStatusPrivacy(value: 'all' | 'contacts' | 'contact_blacklist' | 'none'): Promise<void>
|
|
215
|
+
updateGroupsAddPrivacy(value: 'all' | 'contacts' | 'contact_blacklist'): Promise<void>
|
|
216
|
+
updateCallPrivacy(value: 'all' | 'known'): Promise<void>
|
|
217
|
+
|
|
218
|
+
// Business
|
|
219
|
+
getCatalog(opts: { jid?: string; limit?: number; cursor?: string }): Promise<any>
|
|
220
|
+
getCollections(jid?: string, limit?: number): Promise<any>
|
|
221
|
+
getOrderDetails(orderId: string, tokenBase64: string): Promise<any>
|
|
222
|
+
getProduct(jid: string, productId: string): Promise<any>
|
|
223
|
+
productCreate(create: any): Promise<any>
|
|
224
|
+
productUpdate(productId: string, update: any): Promise<any>
|
|
225
|
+
productDelete(productIds: string[]): Promise<{ deleted: number }>
|
|
226
|
+
updateBussinesProfile(args: any): Promise<void>
|
|
227
|
+
updateCoverPhoto(file: any): Promise<string>
|
|
228
|
+
removeCoverPhoto(id: string): Promise<void>
|
|
229
|
+
|
|
230
|
+
[key: string]: any
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface InMemoryStoreConfig {
|
|
234
|
+
logger?: any
|
|
235
|
+
chatKey?: any
|
|
236
|
+
labelAssociationKey?: any
|
|
237
|
+
maxMessagesPerChat?: number
|
|
238
|
+
[key: string]: any
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface InMemoryStore {
|
|
242
|
+
chats: any
|
|
243
|
+
messages: Record<string, any>
|
|
244
|
+
contacts: Record<string, Contact>
|
|
245
|
+
groupMetadata: Record<string, GroupMetadata>
|
|
246
|
+
presences: Record<string, any>
|
|
247
|
+
state: Partial<ConnectionState>
|
|
248
|
+
labels: any
|
|
249
|
+
labelAssociations: any
|
|
250
|
+
bind(ev: BaileysEventEmitter): void
|
|
251
|
+
loadMessage(jid: string, id: string): Promise<WAMessage | undefined>
|
|
252
|
+
loadMessages(jid: string, count: number, cursor?: any): Promise<WAMessage[]>
|
|
253
|
+
mostRecentMessage(jid: string): Promise<WAMessage | undefined>
|
|
254
|
+
getContact(jid: string): Contact | undefined
|
|
255
|
+
getChat(jid: string): any | undefined
|
|
256
|
+
pruneMessages(jid?: string, keepLastN?: number): number
|
|
257
|
+
clear(chatId?: string): void
|
|
258
|
+
getMessageCount(jid?: string): number
|
|
259
|
+
writeToFile(path: string): void
|
|
260
|
+
readFromFile(path: string): void
|
|
261
|
+
toJSON(): any
|
|
262
|
+
fromJSON(json: any): void
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export declare function makeInMemoryStore(config?: InMemoryStoreConfig): InMemoryStore
|
|
266
|
+
export declare function createGroupMetadataCache(ttlMs?: number, maxSize?: number): {
|
|
267
|
+
(jid: string): Promise<GroupMetadata | undefined>
|
|
268
|
+
set(jid: string, metadata: GroupMetadata): void
|
|
269
|
+
delete(jid: string): boolean
|
|
270
|
+
clear(): void
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export declare function makeWASocket(config?: UserFacingSocketConfig): WASocket
|
|
274
|
+
export default makeWASocket
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@areumtecnologia/wasockets",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "WhatsApp API Modification By areumtecnologia",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -20,9 +20,21 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"author": "areumtecnologia",
|
|
22
22
|
"main": "lib/index.js",
|
|
23
|
+
"types": "lib/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./lib/index.d.ts",
|
|
27
|
+
"require": "./lib/index.js",
|
|
28
|
+
"default": "./lib/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
23
35
|
"files": [
|
|
24
|
-
"lib
|
|
25
|
-
"WAProto
|
|
36
|
+
"lib",
|
|
37
|
+
"WAProto",
|
|
26
38
|
"engine-requirements.js"
|
|
27
39
|
],
|
|
28
40
|
"scripts": {
|
|
@@ -33,7 +45,7 @@
|
|
|
33
45
|
"lint:fix": "yarn lint --fix",
|
|
34
46
|
"preinstall": "node ./engine-requirements.js",
|
|
35
47
|
"release": "release-it",
|
|
36
|
-
"test": "jest"
|
|
48
|
+
"test": "jest --passWithNoTests"
|
|
37
49
|
},
|
|
38
50
|
"dependencies": {
|
|
39
51
|
"@hapi/boom": "^10.0.1",
|
|
@@ -64,7 +76,6 @@
|
|
|
64
76
|
"jest": "^30.1.1",
|
|
65
77
|
"jimp": "^0.22.12",
|
|
66
78
|
"json": "^11.0.0",
|
|
67
|
-
"unfurl.js": "^6.4.0",
|
|
68
79
|
"open": "^8.4.2",
|
|
69
80
|
"release-it": "^20.2.0",
|
|
70
81
|
"ts-jest": "^29.4.1",
|
|
@@ -80,6 +91,9 @@
|
|
|
80
91
|
"peerDependenciesMeta": {
|
|
81
92
|
"jimp": {
|
|
82
93
|
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"sharp": {
|
|
96
|
+
"optional": true
|
|
83
97
|
}
|
|
84
98
|
},
|
|
85
99
|
"packageManager": "yarn@1.22.19",
|