@hansaka02/baileys 7.3.2 → 7.3.6
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/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/connection.js +51 -0
- package/lib/Defaults/constants.js +74 -0
- package/lib/Defaults/history.js +19 -0
- package/lib/Defaults/index.js +36 -142
- package/lib/Defaults/media.js +48 -0
- package/lib/Defaults/prefix.js +18 -0
- package/lib/Signal/Group/group-session-builder.js +10 -42
- package/lib/Signal/Group/group_cipher.js +9 -6
- package/lib/Signal/Group/index.js +39 -53
- package/lib/Signal/Group/keyhelper.js +8 -41
- package/lib/Signal/Group/sender-chain-key.js +5 -18
- package/lib/Signal/Group/sender-key-distribution-message.js +7 -7
- package/lib/Signal/Group/sender-key-message.js +12 -8
- package/lib/Signal/Group/sender-key-record.js +7 -16
- package/lib/Signal/Group/sender-key-state.js +15 -61
- package/lib/Signal/Group/sender-message-key.js +2 -2
- package/lib/Signal/libsignal.js +237 -177
- package/lib/Signal/lid-mapping.js +128 -71
- package/lib/Socket/Client/types.js +2 -2
- package/lib/Socket/Client/websocket.js +25 -16
- package/lib/Socket/business.js +46 -33
- package/lib/Socket/chats.js +286 -170
- package/lib/Socket/community.js +215 -77
- package/lib/Socket/groups.js +77 -61
- package/lib/Socket/index.js +4 -4
- package/lib/Socket/messages-recv.js +629 -457
- package/lib/Socket/messages-send.js +645 -656
- package/lib/Socket/mex.js +61 -0
- package/lib/Socket/newsletter.js +166 -245
- package/lib/Socket/socket.js +396 -170
- package/lib/Store/index.js +27 -11
- package/lib/Store/make-cache-manager-store.js +14 -15
- package/lib/Store/make-in-memory-store.js +28 -24
- package/lib/Types/LabelAssociation.js +2 -2
- package/lib/Types/Message.js +6 -6
- package/lib/Types/MexUpdates.js +5 -5
- package/lib/Types/Newsletter.js +32 -25
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +28 -12
- package/lib/Utils/auth-utils.js +212 -375
- package/lib/Utils/baileys-event-stream.js +68 -69
- package/lib/Utils/browser-utils.js +43 -0
- package/lib/Utils/business.js +63 -53
- package/lib/Utils/chat-utils.js +241 -106
- package/lib/Utils/crypto.js +25 -45
- package/lib/Utils/decode-wa-message.js +361 -311
- package/lib/Utils/event-buffer.js +97 -42
- package/lib/Utils/generics.js +90 -207
- package/lib/Utils/history.js +29 -27
- package/lib/Utils/index.js +28 -14
- package/lib/Utils/link-preview.js +24 -62
- package/lib/Utils/logger.js +5 -5
- package/lib/Utils/lt-hash.js +29 -23
- package/lib/Utils/make-mutex.js +26 -28
- package/lib/Utils/message-retry-manager.js +55 -7
- package/lib/Utils/messages-media.js +434 -247
- package/lib/Utils/messages.js +963 -917
- package/lib/Utils/noise-handler.js +60 -20
- package/lib/Utils/pre-key-manager.js +126 -0
- package/lib/Utils/process-message.js +216 -141
- package/lib/Utils/signal.js +75 -37
- package/lib/Utils/use-multi-file-auth-state.js +18 -22
- package/lib/Utils/validate-connection.js +96 -66
- package/lib/WABinary/constants.js +1268 -1268
- package/lib/WABinary/decode.js +62 -34
- package/lib/WABinary/encode.js +57 -36
- package/lib/WABinary/generic-utils.js +4 -4
- package/lib/WABinary/index.js +27 -11
- package/lib/WABinary/jid-utils.js +58 -11
- package/lib/WAM/constants.js +19064 -11563
- package/lib/WAM/encode.js +71 -14
- package/lib/WAM/index.js +27 -11
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +20 -16
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +7 -4
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
- package/lib/WAUSync/Protocols/index.js +27 -11
- package/lib/WAUSync/USyncQuery.js +51 -28
- package/lib/WAUSync/index.js +27 -11
- package/lib/index.js +60 -31
- package/package.json +12 -17
- package/WAProto/AICommon/AICommon.d.ts +0 -11702
- package/WAProto/Adv/Adv.d.ts +0 -643
- package/WAProto/BotMetadata/BotMetadata.d.ts +0 -5654
- package/WAProto/Cert/Cert.d.ts +0 -613
- package/WAProto/ChatLockSettings/ChatLockSettings.d.ts +0 -476
- package/WAProto/CompanionReg/CompanionReg.d.ts +0 -1361
- package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +0 -577
- package/WAProto/E2E/E2E.d.ts +0 -41724
- package/WAProto/Ephemeral/Ephemeral.d.ts +0 -114
- package/WAProto/HistorySync/HistorySync.d.ts +0 -51700
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +0 -229
- package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.d.ts +0 -583
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +0 -42897
- package/WAProto/MmsRetry/MmsRetry.d.ts +0 -243
- package/WAProto/Protocol/Protocol.d.ts +0 -270
- package/WAProto/Reporting/Reporting.d.ts +0 -371
- package/WAProto/ServerSync/ServerSync.d.ts +0 -1285
- package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.d.ts +0 -1868
- package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.d.ts +0 -767
- package/WAProto/StatusAttributions/StatusAttributions.d.ts +0 -1027
- package/WAProto/SyncAction/SyncAction.d.ts +0 -11193
- package/WAProto/UserPassword/UserPassword.d.ts +0 -363
- package/WAProto/VnameCert/VnameCert.d.ts +0 -821
- package/WAProto/Wa6/Wa6.d.ts +0 -2128
- package/WAProto/Web/Web.d.ts +0 -46383
- package/WAProto/index.d.ts +0 -55
- package/lib/Defaults/index.d.ts +0 -77
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -17
- package/lib/Signal/Group/group_cipher.d.ts +0 -19
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -16
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
- package/lib/Signal/Group/sender-key-message.d.ts +0 -19
- package/lib/Signal/Group/sender-key-name.d.ts +0 -19
- package/lib/Signal/Group/sender-key-record.d.ts +0 -32
- package/lib/Signal/Group/sender-key-state.d.ts +0 -44
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -8
- package/lib/Signal/lid-mapping.d.ts +0 -28
- package/lib/Socket/Client/index.d.ts +0 -2
- package/lib/Socket/Client/types.d.ts +0 -16
- package/lib/Socket/Client/websocket.d.ts +0 -13
- package/lib/Socket/business.d.ts +0 -187
- package/lib/Socket/chats.d.ts +0 -97
- package/lib/Socket/community.d.ts +0 -129
- package/lib/Socket/groups.d.ts +0 -129
- package/lib/Socket/index.d.ts +0 -191
- package/lib/Socket/messages-recv.d.ts +0 -174
- package/lib/Socket/messages-send.d.ts +0 -165
- package/lib/Socket/newsletter.d.ts +0 -145
- package/lib/Socket/socket.d.ts +0 -45
- package/lib/Socket/usync.d.ts +0 -37
- package/lib/Socket/usync.js +0 -83
- package/lib/Store/index.d.ts +0 -4
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-in-memory-store.d.ts +0 -123
- package/lib/Store/make-ordered-dictionary.d.ts +0 -12
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -121
- package/lib/Types/Bussiness.d.ts +0 -28
- package/lib/Types/Call.d.ts +0 -14
- package/lib/Types/Chat.d.ts +0 -143
- package/lib/Types/Contact.d.ts +0 -23
- package/lib/Types/Events.d.ts +0 -226
- package/lib/Types/GroupMetadata.d.ts +0 -66
- package/lib/Types/Label.d.ts +0 -48
- package/lib/Types/LabelAssociation.d.ts +0 -35
- package/lib/Types/Message.d.ts +0 -484
- package/lib/Types/MexUpdates.d.ts +0 -9
- package/lib/Types/Newsletter.d.ts +0 -109
- package/lib/Types/Product.d.ts +0 -92
- package/lib/Types/Signal.d.ts +0 -98
- package/lib/Types/Socket.d.ts +0 -141
- package/lib/Types/State.d.ts +0 -41
- package/lib/Types/USync.d.ts +0 -26
- package/lib/Types/index.d.ts +0 -80
- package/lib/Utils/auth-utils.d.ts +0 -21
- package/lib/Utils/baileys-event-stream.d.ts +0 -18
- package/lib/Utils/business.d.ts +0 -29
- package/lib/Utils/chat-utils.d.ts +0 -82
- package/lib/Utils/crypto.d.ts +0 -56
- package/lib/Utils/decode-wa-message.d.ts +0 -53
- package/lib/Utils/event-buffer.d.ts +0 -39
- package/lib/Utils/generics.d.ts +0 -117
- package/lib/Utils/history.d.ts +0 -23
- package/lib/Utils/index.d.ts +0 -20
- package/lib/Utils/link-preview.d.ts +0 -23
- package/lib/Utils/logger.d.ts +0 -13
- package/lib/Utils/lt-hash.d.ts +0 -14
- package/lib/Utils/make-mutex.d.ts +0 -9
- package/lib/Utils/message-retry-manager.d.ts +0 -88
- package/lib/Utils/messages-media.d.ts +0 -135
- package/lib/Utils/messages.d.ts +0 -105
- package/lib/Utils/noise-handler.d.ts +0 -20
- package/lib/Utils/process-message.d.ts +0 -49
- package/lib/Utils/signal.d.ts +0 -42
- package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
- package/lib/Utils/use-mongo-file-auth-state.js +0 -84
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
- package/lib/Utils/use-single-file-auth-state.js +0 -80
- package/lib/Utils/validate-connection.d.ts +0 -13
- package/lib/WABinary/constants.d.ts +0 -30
- package/lib/WABinary/decode.d.ts +0 -9
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -28
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -58
- package/lib/WABinary/types.d.ts +0 -22
- package/lib/WAM/BinaryInfo.d.ts +0 -16
- package/lib/WAM/constants.d.ts +0 -47
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -26
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -14
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -14
- package/lib/WAUSync/Protocols/index.d.ts +0 -6
- package/lib/WAUSync/USyncQuery.d.ts +0 -31
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -13
package/lib/Utils/signal.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { SignalRepository } from '../Types'
|
|
2
|
-
import { AuthenticationCreds, AuthenticationState, KeyPair, SignalIdentity, SignalKeyStore, SignedKeyPair } from '../Types/Auth'
|
|
3
|
-
import { BinaryNode, JidWithDevice } from '../WABinary'
|
|
4
|
-
import { USyncQueryResultList } from '../WAUSync'
|
|
5
|
-
|
|
6
|
-
export declare const createSignalIdentity: (wid: string, accountSignatureKey: Uint8Array) => SignalIdentity
|
|
7
|
-
|
|
8
|
-
export declare const getPreKeys: ({ get }: SignalKeyStore, min: number, limit: number) => Promise<{
|
|
9
|
-
[id: string]: KeyPair
|
|
10
|
-
}>
|
|
11
|
-
|
|
12
|
-
export declare const generateOrGetPreKeys: (creds: AuthenticationCreds, range: number) => {
|
|
13
|
-
newPreKeys: {
|
|
14
|
-
[id: number]: KeyPair
|
|
15
|
-
}
|
|
16
|
-
lastPreKeyId: number
|
|
17
|
-
preKeysRange: readonly [number, number]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export declare const xmppSignedPreKey: (key: SignedKeyPair) => BinaryNode
|
|
21
|
-
|
|
22
|
-
export declare const xmppPreKey: (pair: KeyPair, id: number) => BinaryNode
|
|
23
|
-
|
|
24
|
-
export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository: SignalRepository) => Promise<void>
|
|
25
|
-
|
|
26
|
-
export declare const extractDeviceJids: (result: USyncQueryResultList[], myJid: string, excludeZeroDevices: boolean) => JidWithDevice[]
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* get the next N keys for upload or processing
|
|
30
|
-
* @param count number of pre-keys to get or generate
|
|
31
|
-
*/
|
|
32
|
-
export declare const getNextPreKeys: ({ creds, keys }: AuthenticationState, count: number) => Promise<{
|
|
33
|
-
update: Partial<AuthenticationCreds>
|
|
34
|
-
preKeys: {
|
|
35
|
-
[id: string]: KeyPair
|
|
36
|
-
}
|
|
37
|
-
}>
|
|
38
|
-
|
|
39
|
-
export declare const getNextPreKeysNode: (state: AuthenticationState, count: number) => Promise<{
|
|
40
|
-
update: Partial<AuthenticationCreds>
|
|
41
|
-
node: BinaryNode
|
|
42
|
-
}>
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
-
|
|
5
|
-
const WAProto_1 = require("../../WAProto")
|
|
6
|
-
const auth_utils_1 = require("./auth-utils")
|
|
7
|
-
const generics_1 = require("./generics")
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
code from amiruldev readjusted by @irull2nd, don't delete WM!
|
|
11
|
-
*/
|
|
12
|
-
const useMongoFileAuthState = async (collection) => {
|
|
13
|
-
const writeData = (data,id) => {
|
|
14
|
-
const informationToStore = JSON.parse(
|
|
15
|
-
JSON.stringify(data, generics_1.BufferJSON.replacer)
|
|
16
|
-
)
|
|
17
|
-
const update = {
|
|
18
|
-
$set: {
|
|
19
|
-
...informationToStore,
|
|
20
|
-
},
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return collection.updateOne({_id: id},update, {upsert: true})
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const readData = async (id) => {
|
|
27
|
-
try {
|
|
28
|
-
const data = JSON.stringify(await collection.findOne({_id: id}))
|
|
29
|
-
return JSON.parse(data, generics_1.BufferJSON.reviver)
|
|
30
|
-
} catch (err) {
|
|
31
|
-
console.log(err)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const removeData = async (id) => {
|
|
36
|
-
try{
|
|
37
|
-
await collection.deleteOne({_id: id})
|
|
38
|
-
}catch(err){
|
|
39
|
-
console.log('error',err)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const creds = (await readData('creds')) || auth_utils_1.initAuthCreds()
|
|
44
|
-
|
|
45
|
-
return{
|
|
46
|
-
state:{
|
|
47
|
-
creds,
|
|
48
|
-
keys: {
|
|
49
|
-
get: async (type,ids)=> {
|
|
50
|
-
const data = {}
|
|
51
|
-
await Promise
|
|
52
|
-
.all(
|
|
53
|
-
ids.map(async (id) => {
|
|
54
|
-
let value = await readData(`${type}-${id}`)
|
|
55
|
-
if(type === "app-state-sync-key"){
|
|
56
|
-
value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(data)
|
|
57
|
-
}
|
|
58
|
-
data[id] = value
|
|
59
|
-
})
|
|
60
|
-
)
|
|
61
|
-
return data
|
|
62
|
-
},
|
|
63
|
-
set: async (data) => {
|
|
64
|
-
const tasks = []
|
|
65
|
-
for (const category of Object.keys(data)){
|
|
66
|
-
for (const id of Object.keys(data[category])){
|
|
67
|
-
const value = data[category][id]
|
|
68
|
-
const key = `${category}-${id}`
|
|
69
|
-
tasks.push(value? writeData(value,key) : removeData(key))
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
await Promise.all(tasks)
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
saveCreds: () => {
|
|
77
|
-
return writeData(creds, "creds")
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
module.exports = {
|
|
83
|
-
useMongoFileAuthState
|
|
84
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AuthenticationState } from '../Types'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* stores the full authentication state in a single folder.
|
|
5
|
-
* Far more efficient than singlefileauthstate
|
|
6
|
-
*
|
|
7
|
-
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
|
8
|
-
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
9
|
-
* */
|
|
10
|
-
export declare const useMultiFileAuthState: (folder: string) => Promise<{
|
|
11
|
-
state: AuthenticationState
|
|
12
|
-
saveCreds: () => Promise<void>
|
|
13
|
-
}>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ILogger } from './logger'
|
|
2
|
-
import type { AuthenticationState } from '../Types'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated use multi file auth state instead please
|
|
6
|
-
* stores the full authentication state in a single JSON file
|
|
7
|
-
*
|
|
8
|
-
* DO NOT USE IN A PROD ENVIRONMENT, only meant to serve as an example
|
|
9
|
-
* */
|
|
10
|
-
export declare const useSingleFileAuthState: (filename: string, logger?: ILogger) => {
|
|
11
|
-
state: AuthenticationState
|
|
12
|
-
saveState: () => void
|
|
13
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
-
|
|
5
|
-
const WAProto_1 = require("../../WAProto")
|
|
6
|
-
const auth_utils_1 = require("./auth-utils")
|
|
7
|
-
const generics_1 = require("./generics")
|
|
8
|
-
|
|
9
|
-
// useless key map only there to maintain backwards compatibility
|
|
10
|
-
// do not use in your own systems please
|
|
11
|
-
const KEY_MAP = {
|
|
12
|
-
'pre-key': 'preKeys',
|
|
13
|
-
'session': 'sessions',
|
|
14
|
-
'sender-key': 'senderKeys',
|
|
15
|
-
'app-state-sync-key': 'appStateSyncKeys',
|
|
16
|
-
'app-state-sync-version': 'appStateVersions',
|
|
17
|
-
'sender-key-memory': 'senderKeyMemory'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated use multi file auth state instead please
|
|
22
|
-
* stores the full authentication state in a single JSON file
|
|
23
|
-
*
|
|
24
|
-
* DO NOT USE IN A PROD ENVIRONMENT, only meant to serve as an example
|
|
25
|
-
* */
|
|
26
|
-
const useSingleFileAuthState = (filename, logger) => {
|
|
27
|
-
// require fs here so that in case "fs" is not available -- the app does not crash
|
|
28
|
-
const { readFileSync, writeFileSync, existsSync } = require('fs')
|
|
29
|
-
let creds
|
|
30
|
-
let keys = {}
|
|
31
|
-
// save the authentication state to a file
|
|
32
|
-
const saveState = () => {
|
|
33
|
-
logger && logger.trace('saving auth state')
|
|
34
|
-
writeFileSync(filename,
|
|
35
|
-
// BufferJSON replacer utility saves buffers nicely
|
|
36
|
-
JSON.stringify({ creds, keys }, generics_1.BufferJSON.replacer, 2))
|
|
37
|
-
}
|
|
38
|
-
if (existsSync(filename)) {
|
|
39
|
-
const result = JSON.parse(readFileSync(filename, { encoding: 'utf-8' }), generics_1.BufferJSON.reviver)
|
|
40
|
-
creds = result.creds
|
|
41
|
-
keys = result.keys
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
creds = auth_utils_1.initAuthCreds()
|
|
45
|
-
keys = {}
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
state: {
|
|
49
|
-
creds,
|
|
50
|
-
keys: {
|
|
51
|
-
get: (type, ids) => {
|
|
52
|
-
const key = KEY_MAP[type]
|
|
53
|
-
return ids.reduce((dict, id) => {
|
|
54
|
-
let value = keys[key]?.[id]
|
|
55
|
-
if (value) {
|
|
56
|
-
if (type === 'app-state-sync-key') {
|
|
57
|
-
value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value)
|
|
58
|
-
}
|
|
59
|
-
dict[id] = value
|
|
60
|
-
}
|
|
61
|
-
return dict
|
|
62
|
-
}, {})
|
|
63
|
-
},
|
|
64
|
-
set: (data) => {
|
|
65
|
-
for (const _key in data) {
|
|
66
|
-
const key = KEY_MAP[_key]
|
|
67
|
-
keys[key] = keys[key] || {}
|
|
68
|
-
Object.assign(keys[key], data[_key])
|
|
69
|
-
}
|
|
70
|
-
saveState()
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
saveState
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
module.exports = {
|
|
79
|
-
useSingleFileAuthState
|
|
80
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { proto } from '../../WAProto'
|
|
2
|
-
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types'
|
|
3
|
-
import { BinaryNode } from '../WABinary'
|
|
4
|
-
|
|
5
|
-
export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload
|
|
6
|
-
|
|
7
|
-
export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload
|
|
8
|
-
|
|
9
|
-
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, 'advSecretKey' | 'signedIdentityKey' | 'signalIdentities'>) => {
|
|
10
|
-
creds: Partial<AuthenticationCreds>
|
|
11
|
-
reply: BinaryNode
|
|
12
|
-
}
|
|
13
|
-
export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export declare const TAGS: {
|
|
2
|
-
LIST_EMPTY: number
|
|
3
|
-
DICTIONARY_0: number
|
|
4
|
-
DICTIONARY_1: number
|
|
5
|
-
DICTIONARY_2: number
|
|
6
|
-
DICTIONARY_3: number
|
|
7
|
-
INTEROP_JID: number
|
|
8
|
-
FB_JID: number
|
|
9
|
-
AD_JID: number
|
|
10
|
-
LIST_8: number
|
|
11
|
-
LIST_16: number
|
|
12
|
-
JID_PAIR: number
|
|
13
|
-
HEX_8: number
|
|
14
|
-
BINARY_8: number
|
|
15
|
-
BINARY_20: number
|
|
16
|
-
BINARY_32: number
|
|
17
|
-
NIBBLE_8: number
|
|
18
|
-
PACKED_MAX: number
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export declare const DOUBLE_BYTE_TOKENS: string[][]
|
|
22
|
-
|
|
23
|
-
export declare const SINGLE_BYTE_TOKENS: (string | null)[]
|
|
24
|
-
|
|
25
|
-
export declare const TOKEN_MAP: {
|
|
26
|
-
[token: string]: {
|
|
27
|
-
dict?: number
|
|
28
|
-
index: number
|
|
29
|
-
}
|
|
30
|
-
}
|
package/lib/WABinary/decode.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { BinaryNode, BinaryNodeCodingOptions } from './types'
|
|
2
|
-
|
|
3
|
-
export declare const decompressingIfRequired: (buffer: Buffer) => Promise<Buffer>
|
|
4
|
-
|
|
5
|
-
export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, 'DOUBLE_BYTE_TOKENS' | 'SINGLE_BYTE_TOKENS' | 'TAGS'>, indexRef?: {
|
|
6
|
-
index: number
|
|
7
|
-
}) => BinaryNode
|
|
8
|
-
|
|
9
|
-
export declare const decodeBinaryNode: (buff: Buffer) => Promise<BinaryNode>
|
package/lib/WABinary/encode.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { proto } from '../../WAProto'
|
|
2
|
-
import { BinaryNode } from './types'
|
|
3
|
-
|
|
4
|
-
export declare const getBinaryNodeChildren: (node: BinaryNode | undefined, childTag: string) => BinaryNode[]
|
|
5
|
-
|
|
6
|
-
export declare const getAllBinaryNodeChildren: ({ content }: BinaryNode) => BinaryNode[]
|
|
7
|
-
|
|
8
|
-
export declare const getBinaryNodeChild: (node: BinaryNode | undefined, childTag: string) => BinaryNode | undefined
|
|
9
|
-
|
|
10
|
-
export declare const getBinaryNodeChildBuffer: (node: BinaryNode | undefined, childTag: string) => Uint8Array | Buffer | undefined
|
|
11
|
-
|
|
12
|
-
export declare const getBinaryNodeChildString: (node: BinaryNode | undefined, childTag: string) => string | undefined
|
|
13
|
-
|
|
14
|
-
export declare const getBinaryNodeChildUInt: (node: BinaryNode, childTag: string, length: number) => number | undefined
|
|
15
|
-
|
|
16
|
-
export declare const assertNodeErrorFree: (node: BinaryNode) => void
|
|
17
|
-
|
|
18
|
-
export declare const reduceBinaryNodeToDictionary: (node: BinaryNode, tag: string) => {
|
|
19
|
-
[_: string]: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export declare const getBinaryNodeMessages: ({ content }: BinaryNode) => proto.WebMessageInfo[]
|
|
23
|
-
|
|
24
|
-
export declare const getBinaryFilteredButtons: (nodeContent: BinaryNode | BinaryNode['content']) => BinaryNode['content']
|
|
25
|
-
|
|
26
|
-
export declare const getBinaryFilteredBizBot: (nodeContent: BinaryNode | BinaryNode['content']) => BinaryNode['content']
|
|
27
|
-
|
|
28
|
-
export declare function binaryNodeToString(node: BinaryNode | BinaryNode['content'], i?: number): any
|
package/lib/WABinary/index.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export declare const S_WHATSAPP_NET = "@s.whatsapp.net"
|
|
2
|
-
|
|
3
|
-
export declare const OFFICIAL_BIZ_JID = "16505361212@c.us"
|
|
4
|
-
|
|
5
|
-
export declare const SERVER_JID = "server@c.us"
|
|
6
|
-
|
|
7
|
-
export declare const PSA_WID = "0@c.us"
|
|
8
|
-
|
|
9
|
-
export declare const STORIES_JID = "status@broadcast"
|
|
10
|
-
|
|
11
|
-
export declare const META_AI_JID = '13135550002@c.us'
|
|
12
|
-
|
|
13
|
-
export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter' | 'bot'
|
|
14
|
-
|
|
15
|
-
export type JidWithDevice = {
|
|
16
|
-
user: string
|
|
17
|
-
device?: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type FullJid = JidWithDevice & {
|
|
21
|
-
server: JidServer
|
|
22
|
-
domainType?: number
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string
|
|
26
|
-
|
|
27
|
-
export declare const jidDecode: (jid: string | undefined) => FullJid | undefined
|
|
28
|
-
|
|
29
|
-
/** is the jid Meta AI */
|
|
30
|
-
export declare const isJidMetaAI: (jid: string | undefined) => boolean | undefined
|
|
31
|
-
|
|
32
|
-
/** is the jid a user */
|
|
33
|
-
export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean
|
|
34
|
-
|
|
35
|
-
/** is the lid a user */
|
|
36
|
-
export declare const isJidUser: (jid: string | undefined) => boolean | undefined
|
|
37
|
-
|
|
38
|
-
/** is the jid a group */
|
|
39
|
-
export declare const isLidUser: (jid: string | undefined) => boolean | undefined
|
|
40
|
-
|
|
41
|
-
/** is the jid a broadcast */
|
|
42
|
-
export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined
|
|
43
|
-
|
|
44
|
-
/** is the jid a group */
|
|
45
|
-
export declare const isJidGroup: (jid: string | undefined) => boolean | undefined
|
|
46
|
-
|
|
47
|
-
/** is the jid the status broadcast */
|
|
48
|
-
export declare const isJidStatusBroadcast: (jid: string) => boolean
|
|
49
|
-
|
|
50
|
-
/** is the jid a newsletter */
|
|
51
|
-
export declare const isJidNewsletter: (jid: string | undefined) => boolean | undefined
|
|
52
|
-
|
|
53
|
-
/** is the jid a bot */
|
|
54
|
-
export declare const isJidBot: (jid: string | undefined) => boolean | undefined
|
|
55
|
-
|
|
56
|
-
export declare const jidNormalizedUser: (jid: string | undefined) => string
|
|
57
|
-
|
|
58
|
-
export declare const transferDevice: (fromJid: string, toJid: string) => string
|
package/lib/WABinary/types.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as constants from './constants'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* the binary node WA uses internally for communication
|
|
5
|
-
*
|
|
6
|
-
* this is manipulated soley as an object and it does not have any functions.
|
|
7
|
-
* This is done for easy serialization, to prevent running into issues with prototypes &
|
|
8
|
-
* to maintain functional code structure
|
|
9
|
-
* */
|
|
10
|
-
export type BinaryNode = {
|
|
11
|
-
tag: string
|
|
12
|
-
attrs: {
|
|
13
|
-
[key: string]: string
|
|
14
|
-
}
|
|
15
|
-
content?: BinaryNode[] | string | Uint8Array
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type BinaryNodeAttributes = BinaryNode['attrs']
|
|
19
|
-
|
|
20
|
-
export type BinaryNodeData = BinaryNode['content']
|
|
21
|
-
|
|
22
|
-
export type BinaryNodeCodingOptions = typeof constants
|
package/lib/WAM/BinaryInfo.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare class BinaryInfo {
|
|
2
|
-
protocolVersion: number
|
|
3
|
-
sequence: number
|
|
4
|
-
events: {
|
|
5
|
-
[x: string]: {
|
|
6
|
-
props: {
|
|
7
|
-
[x: string]: import("./constants").Value
|
|
8
|
-
}
|
|
9
|
-
globals: {
|
|
10
|
-
[x: string]: import("./constants").Value
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}[]
|
|
14
|
-
buffer: Buffer[]
|
|
15
|
-
constructor(options?: Partial<BinaryInfo>)
|
|
16
|
-
}
|
package/lib/WAM/constants.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export declare const WEB_EVENTS: Event[]
|
|
2
|
-
|
|
3
|
-
export declare const WEB_GLOBALS: Global[]
|
|
4
|
-
|
|
5
|
-
export declare const FLAG_BYTE = 8, FLAG_GLOBAL = 0, FLAG_EVENT = 1, FLAG_FIELD = 2, FLAG_EXTENDED = 4
|
|
6
|
-
|
|
7
|
-
export type Event = {
|
|
8
|
-
name: string
|
|
9
|
-
id: number
|
|
10
|
-
props: {
|
|
11
|
-
[key: string]: [number, string | {
|
|
12
|
-
[key: string]: number
|
|
13
|
-
}]
|
|
14
|
-
}
|
|
15
|
-
weight: number
|
|
16
|
-
wamChannel: string
|
|
17
|
-
privateStatsIdInt: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type Global = {
|
|
21
|
-
name: string
|
|
22
|
-
id: number
|
|
23
|
-
type: string | {
|
|
24
|
-
[key: string]: number
|
|
25
|
-
}
|
|
26
|
-
validator?: string
|
|
27
|
-
channels: string[]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
type EventByName<T extends Event['name']> = Extract<Event, {
|
|
31
|
-
name: T
|
|
32
|
-
}>
|
|
33
|
-
|
|
34
|
-
export type EventInputType = {
|
|
35
|
-
[key in Event['name']]: {
|
|
36
|
-
props: {
|
|
37
|
-
[k in keyof EventByName<key>['props']]: Value
|
|
38
|
-
}
|
|
39
|
-
globals: {
|
|
40
|
-
[x: string]: Value
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
} & {}
|
|
44
|
-
|
|
45
|
-
export type Value = number | null | string
|
|
46
|
-
|
|
47
|
-
export {}
|
package/lib/WAM/encode.d.ts
DELETED
package/lib/WAM/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { USyncQueryProtocol } from '../../Types/USync'
|
|
2
|
-
import { BinaryNode } from '../../WABinary'
|
|
3
|
-
import { USyncUser } from '../USyncUser'
|
|
4
|
-
|
|
5
|
-
export type BotProfileCommand = {
|
|
6
|
-
name: string
|
|
7
|
-
description: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type BotProfileInfo = {
|
|
11
|
-
jid: string
|
|
12
|
-
name: string
|
|
13
|
-
attributes: string
|
|
14
|
-
description: string
|
|
15
|
-
category: string
|
|
16
|
-
isDefault: boolean
|
|
17
|
-
prompts: string[]
|
|
18
|
-
personaId: string
|
|
19
|
-
commands: BotProfileCommand[]
|
|
20
|
-
commandsDescription: string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export declare class USyncBotProfileProtocol implements USyncQueryProtocol {
|
|
24
|
-
name: string
|
|
25
|
-
getQueryElement(): BinaryNode
|
|
26
|
-
getUserElement(user: USyncUser): BinaryNode
|
|
27
|
-
parser(node: BinaryNode): BotProfileInfo | undefined
|
|
28
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { USyncQueryProtocol } from '../../Types/USync'
|
|
2
|
-
import { BinaryNode } from '../../WABinary'
|
|
3
|
-
import { USyncUser } from '../USyncUser'
|
|
4
|
-
|
|
5
|
-
export declare class USyncContactProtocol implements USyncQueryProtocol {
|
|
6
|
-
name: string
|
|
7
|
-
getQueryElement(): BinaryNode
|
|
8
|
-
getUserElement(user: USyncUser): BinaryNode
|
|
9
|
-
parser(node: BinaryNode): boolean
|
|
10
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { USyncQueryProtocol } from '../../Types/USync'
|
|
2
|
-
import { BinaryNode } from '../../WABinary'
|
|
3
|
-
|
|
4
|
-
export type KeyIndexData = {
|
|
5
|
-
timestamp: number
|
|
6
|
-
signedKeyIndex?: Uint8Array
|
|
7
|
-
expectedTimestamp?: number
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type DeviceListData = {
|
|
11
|
-
id: number
|
|
12
|
-
keyIndex?: number
|
|
13
|
-
isHosted?: boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type ParsedDeviceInfo = {
|
|
17
|
-
deviceList?: DeviceListData[]
|
|
18
|
-
keyIndex?: KeyIndexData
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export declare class USyncDeviceProtocol implements USyncQueryProtocol {
|
|
22
|
-
name: string
|
|
23
|
-
getQueryElement(): BinaryNode
|
|
24
|
-
getUserElement(): BinaryNode | null
|
|
25
|
-
parser(node: BinaryNode): ParsedDeviceInfo
|
|
26
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { USyncQueryProtocol } from '../../Types/USync'
|
|
2
|
-
import { BinaryNode } from '../../WABinary'
|
|
3
|
-
|
|
4
|
-
export type DisappearingModeData = {
|
|
5
|
-
duration: number
|
|
6
|
-
setAt?: Date
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export declare class USyncDisappearingModeProtocol implements USyncQueryProtocol {
|
|
10
|
-
name: string
|
|
11
|
-
getQueryElement(): BinaryNode
|
|
12
|
-
getUserElement(): null
|
|
13
|
-
parser(node: BinaryNode): DisappearingModeData | undefined
|
|
14
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { USyncQueryProtocol } from '../../Types/USync'
|
|
2
|
-
import { BinaryNode } from '../../WABinary'
|
|
3
|
-
import { USyncUser } from '../USyncUser'
|
|
4
|
-
|
|
5
|
-
export declare class USyncLIDProtocol implements USyncQueryProtocol {
|
|
6
|
-
name: string
|
|
7
|
-
getQueryElement(): BinaryNode
|
|
8
|
-
getUserElement(user: USyncUser): BinaryNode | null
|
|
9
|
-
parser(node: BinaryNode): string | null
|
|
10
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { USyncQueryProtocol } from '../../Types/USync'
|
|
2
|
-
import { BinaryNode } from '../../WABinary'
|
|
3
|
-
|
|
4
|
-
export type StatusData = {
|
|
5
|
-
status?: string | null
|
|
6
|
-
setAt?: Date
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export declare class USyncStatusProtocol implements USyncQueryProtocol {
|
|
10
|
-
name: string
|
|
11
|
-
getQueryElement(): BinaryNode
|
|
12
|
-
getUserElement(): null
|
|
13
|
-
parser(node: BinaryNode): StatusData | undefined
|
|
14
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { USyncQueryProtocol } from '../Types/USync'
|
|
2
|
-
import { BinaryNode } from '../WABinary'
|
|
3
|
-
import { USyncUser } from './USyncUser'
|
|
4
|
-
|
|
5
|
-
export type USyncQueryResultList = {
|
|
6
|
-
[protocol: string]: unknown
|
|
7
|
-
id: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type USyncQueryResult = {
|
|
11
|
-
list: USyncQueryResultList[]
|
|
12
|
-
sideList: USyncQueryResultList[]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export declare class USyncQuery {
|
|
16
|
-
protocols: USyncQueryProtocol[]
|
|
17
|
-
users: USyncUser[]
|
|
18
|
-
context: string
|
|
19
|
-
mode: string
|
|
20
|
-
constructor()
|
|
21
|
-
withMode(mode: string): this
|
|
22
|
-
withContext(context: string): this
|
|
23
|
-
withUser(user: USyncUser): this
|
|
24
|
-
parseUSyncQueryResult(result: BinaryNode): USyncQueryResult | undefined
|
|
25
|
-
withLIDProtocol(): this
|
|
26
|
-
withDeviceProtocol(): this
|
|
27
|
-
withContactProtocol(): this
|
|
28
|
-
withStatusProtocol(): this
|
|
29
|
-
withBotProfileProtocol(): this
|
|
30
|
-
withDisappearingModeProtocol(): this
|
|
31
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare class USyncUser {
|
|
2
|
-
id: string
|
|
3
|
-
lid: string
|
|
4
|
-
phone: string
|
|
5
|
-
type: string
|
|
6
|
-
personaId: string
|
|
7
|
-
withId(id: string): this
|
|
8
|
-
withLid(lid: string): this
|
|
9
|
-
withPhone(phone: string): this
|
|
10
|
-
withType(type: string): this
|
|
11
|
-
withPersonaId(personaId: string): this
|
|
12
|
-
}
|
package/lib/WAUSync/index.d.ts
DELETED