@vanzxy/baileys 1.3.7 → 1.3.9
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.
Potentially problematic release.
This version of @vanzxy/baileys might be problematic. Click here for more details.
- package/NOTICE.md +41 -0
- package/README.md +1 -1
- package/WAProto/index.d.ts +9 -0
- package/lib/Defaults/index.d.ts +147 -0
- package/lib/Defaults/index.js +2 -2
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/group-session-builder.d.ts +7 -0
- package/lib/Signal/Group/group_cipher.d.ts +10 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +6 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts +11 -0
- package/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/lib/Signal/Group/sender-key-state.d.ts +16 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/libsignal.d.ts +54 -0
- package/lib/Signal/lid-mapping.d.ts +20 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/types.d.ts +5 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/business.d.ts +395 -0
- package/lib/Socket/chats.d.ts +136 -0
- package/lib/Socket/communities.d.ts +561 -0
- package/lib/Socket/communities.js +4 -2
- package/lib/Socket/dugong.d.ts +117 -0
- package/lib/Socket/dugong.js +26 -1
- package/lib/Socket/groups.d.ts +285 -0
- package/lib/Socket/index.d.ts +531 -0
- package/lib/Socket/messages-recv.d.ts +333 -0
- package/lib/Socket/messages-send.d.ts +329 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/newsletter.d.ts +281 -0
- package/lib/Socket/newsletter.js +19 -19
- package/lib/Socket/socket.d.ts +60 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/make-in-memory-store.d.ts +62 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Types/Auth.d.ts +117 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Chat.d.ts +124 -0
- package/lib/Types/Contact.d.ts +26 -0
- package/lib/Types/Events.d.ts +256 -0
- package/lib/Types/GroupMetadata.d.ts +71 -0
- package/lib/Types/Label.d.ts +2 -0
- package/lib/Types/LabelAssociation.d.ts +2 -0
- package/lib/Types/Message.d.ts +11 -0
- package/lib/Types/Mex.d.ts +2 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/RichType.d.ts +2 -0
- package/lib/Types/Signal.d.ts +87 -0
- package/lib/Types/Socket.d.ts +136 -0
- package/lib/Types/State.d.ts +5 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Utils/MessageBuilder.js +2297 -0
- package/lib/Utils/auth-utils.d.ts +57 -0
- package/lib/Utils/browser-utils.d.ts +8 -0
- package/lib/Utils/business.d.ts +49 -0
- package/lib/Utils/business.js +2 -1
- package/lib/Utils/chat-utils.d.ts +407 -0
- package/lib/Utils/chat-utils.js +15 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/decode-wa-message.d.ts +83 -0
- package/lib/Utils/decode-wa-message.js +1 -3
- package/lib/Utils/event-buffer.d.ts +12 -0
- package/lib/Utils/generics.d.ts +63 -0
- package/lib/Utils/generics.js +2 -4
- package/lib/Utils/history.d.ts +90 -0
- package/lib/Utils/identity-change-handler.d.ts +13 -0
- package/lib/Utils/index.d.ts +24 -0
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/link-preview.d.ts +12 -0
- package/lib/Utils/logger.d.ts +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +21 -2
- package/lib/Utils/make-mutex.d.ts +6 -0
- package/lib/Utils/message-retry-manager.d.ts +79 -0
- package/lib/Utils/messages-media.d.ts +135 -0
- package/lib/Utils/messages.d.ts +44 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/offline-node-processor.d.ts +9 -0
- package/lib/Utils/pre-key-manager.d.ts +25 -0
- package/lib/Utils/process-message.d.ts +82 -0
- package/lib/Utils/reporting-utils.d.ts +12 -0
- package/lib/Utils/rich-message-utils.d.ts +48 -0
- package/lib/Utils/rich-message-utils.js +32 -7
- package/lib/Utils/signal.d.ts +82 -0
- package/lib/Utils/stanza-ack.d.ts +16 -0
- package/lib/Utils/sync-action-utils.d.ts +2 -0
- package/lib/Utils/tc-token-utils.d.ts +29 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-single-file-auth-state.js +6 -1
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.js +12 -0
- package/lib/Utils/validate-connection.d.ts +42 -0
- package/lib/WABinary/constants.d.ts +61 -0
- package/lib/WABinary/decode.d.ts +9 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/generic-utils.d.ts +74 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/jid-utils.d.ts +28 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WAM/BinaryInfo.d.ts +7 -0
- package/lib/WAM/constants.d.ts +34926 -0
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/index.d.ts +7 -0
- package/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/lib/WAUSync/USyncUser.d.ts +16 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/index.d.ts +12 -0
- package/package.json +17 -7
- package/postinstall-banner.js +23 -0
- package/LICENSE +0 -23
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds caching capability to a SignalKeyStore
|
|
3
|
+
* @param store the store to add caching to
|
|
4
|
+
* @param logger to log trace events
|
|
5
|
+
* @param _cache cache store to use
|
|
6
|
+
*/
|
|
7
|
+
export function makeCacheableSignalKeyStore(store: any, logger: any, _cache: any): {
|
|
8
|
+
get(type: any, ids: any): Promise<any>;
|
|
9
|
+
set(data: any): Promise<any>;
|
|
10
|
+
clear(): Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export function addTransactionCapability(state: any, logger: any, { maxCommitRetries, delayBetweenTriesMs }: {
|
|
13
|
+
maxCommitRetries: any;
|
|
14
|
+
delayBetweenTriesMs: any;
|
|
15
|
+
}): {
|
|
16
|
+
get: (type: any, ids: any) => Promise<any>;
|
|
17
|
+
set: (data: any) => Promise<void>;
|
|
18
|
+
isInTransaction: () => boolean;
|
|
19
|
+
transaction: (work: any, key: any) => Promise<any>;
|
|
20
|
+
};
|
|
21
|
+
export function assertMeId(creds: any): any;
|
|
22
|
+
export function initAuthCreds(): {
|
|
23
|
+
noiseKey: {
|
|
24
|
+
private: any;
|
|
25
|
+
public: any;
|
|
26
|
+
};
|
|
27
|
+
pairingEphemeralKeyPair: {
|
|
28
|
+
private: any;
|
|
29
|
+
public: any;
|
|
30
|
+
};
|
|
31
|
+
signedIdentityKey: {
|
|
32
|
+
private: any;
|
|
33
|
+
public: any;
|
|
34
|
+
};
|
|
35
|
+
signedPreKey: {
|
|
36
|
+
keyPair: {
|
|
37
|
+
private: any;
|
|
38
|
+
public: any;
|
|
39
|
+
};
|
|
40
|
+
signature: any;
|
|
41
|
+
keyId: any;
|
|
42
|
+
};
|
|
43
|
+
registrationId: number;
|
|
44
|
+
advSecretKey: any;
|
|
45
|
+
processedHistoryMessages: never[];
|
|
46
|
+
nextPreKeyId: number;
|
|
47
|
+
firstUnuploadedPreKeyId: number;
|
|
48
|
+
accountSyncCounter: number;
|
|
49
|
+
accountSettings: {
|
|
50
|
+
unarchiveChats: boolean;
|
|
51
|
+
};
|
|
52
|
+
registered: boolean;
|
|
53
|
+
pairingCode: undefined;
|
|
54
|
+
lastPropHash: undefined;
|
|
55
|
+
routingInfo: undefined;
|
|
56
|
+
additionalData: undefined;
|
|
57
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export namespace Browsers {
|
|
2
|
+
function ubuntu(browser: any): any[];
|
|
3
|
+
function macOS(browser: any): any[];
|
|
4
|
+
function baileys(browser: any): any[];
|
|
5
|
+
function windows(browser: any): any[];
|
|
6
|
+
function appropriate(browser: any): any[];
|
|
7
|
+
}
|
|
8
|
+
export function getPlatformId(browser: any): any;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uploads images not already uploaded to WA's servers
|
|
3
|
+
*/
|
|
4
|
+
export function uploadingNecessaryImagesOfProduct(product: any, waUploadToServer: any, timeoutMs?: number): Promise<any>;
|
|
5
|
+
export function parseCatalogNode(node: any): {
|
|
6
|
+
products: any;
|
|
7
|
+
nextPageCursor: any;
|
|
8
|
+
};
|
|
9
|
+
export function parseCollectionsNode(node: any): {
|
|
10
|
+
collections: any;
|
|
11
|
+
};
|
|
12
|
+
export function parseOrderDetailsNode(node: any): {
|
|
13
|
+
price: {
|
|
14
|
+
total: number;
|
|
15
|
+
currency: any;
|
|
16
|
+
};
|
|
17
|
+
products: any;
|
|
18
|
+
};
|
|
19
|
+
export function toProductNode(productId: any, product: any): {
|
|
20
|
+
tag: string;
|
|
21
|
+
attrs: {
|
|
22
|
+
compliance_category: string;
|
|
23
|
+
is_hidden: any;
|
|
24
|
+
};
|
|
25
|
+
content: {
|
|
26
|
+
tag: string;
|
|
27
|
+
attrs: {};
|
|
28
|
+
content: any;
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
31
|
+
export function parseProductNode(productNode: any): {
|
|
32
|
+
id: any;
|
|
33
|
+
imageUrls: {
|
|
34
|
+
requested: any;
|
|
35
|
+
original: any;
|
|
36
|
+
};
|
|
37
|
+
reviewStatus: {
|
|
38
|
+
whatsapp: any;
|
|
39
|
+
};
|
|
40
|
+
availability: string;
|
|
41
|
+
name: any;
|
|
42
|
+
retailerId: any;
|
|
43
|
+
url: any;
|
|
44
|
+
description: any;
|
|
45
|
+
price: number;
|
|
46
|
+
currency: any;
|
|
47
|
+
isHidden: boolean;
|
|
48
|
+
};
|
|
49
|
+
export function uploadingNecessaryImages(images: any, waUploadToServer: any, timeoutMs?: number): Promise<any[]>;
|
package/lib/Utils/business.js
CHANGED
|
@@ -5,6 +5,7 @@ import { tmpdir } from 'os';
|
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from '../WABinary/index.js';
|
|
7
7
|
import { generateMessageIDV2 } from './generics.js';
|
|
8
|
+
import logger from './logger.js';
|
|
8
9
|
import { getStream, getUrlFromDirectPath } from './messages-media.js';
|
|
9
10
|
export const parseCatalogNode = (node) => {
|
|
10
11
|
const catalogNode = getBinaryNodeChild(node, 'product_catalog');
|
|
@@ -209,7 +210,7 @@ export const uploadingNecessaryImages = async (images, waUploadToServer, timeout
|
|
|
209
210
|
fileEncSha256B64: sha,
|
|
210
211
|
timeoutMs
|
|
211
212
|
});
|
|
212
|
-
await fs.unlink(filePath).catch(err =>
|
|
213
|
+
await fs.unlink(filePath).catch(err => logger.warn({ err, filePath }, 'Vanz@Fix (bug 57): error deleting temp file')); // was console.log
|
|
213
214
|
return { url: getUrlFromDirectPath(directPath) };
|
|
214
215
|
}));
|
|
215
216
|
return results;
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
export function makeLtHashGenerator({ indexValueMap, hash }: {
|
|
2
|
+
indexValueMap: any;
|
|
3
|
+
hash: any;
|
|
4
|
+
}): {
|
|
5
|
+
mix: ({ indexMac, valueMac, operation }: {
|
|
6
|
+
indexMac: any;
|
|
7
|
+
valueMac: any;
|
|
8
|
+
operation: any;
|
|
9
|
+
}) => void;
|
|
10
|
+
finish: () => {
|
|
11
|
+
hash: any;
|
|
12
|
+
indexValueMap: any;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export function newLTHashState(): {
|
|
16
|
+
version: number;
|
|
17
|
+
hash: any;
|
|
18
|
+
indexValueMap: {};
|
|
19
|
+
};
|
|
20
|
+
export function ensureLTHashStateVersion(state: any): any;
|
|
21
|
+
export const MAX_SYNC_ATTEMPTS: 2;
|
|
22
|
+
export function isMissingKeyError(error: any): boolean;
|
|
23
|
+
export function isAppStateSyncIrrecoverable(error: any, attempts: any): boolean;
|
|
24
|
+
export function encodeSyncdPatch({ type, index, syncAction, apiVersion, operation }: {
|
|
25
|
+
type: any;
|
|
26
|
+
index: any;
|
|
27
|
+
syncAction: any;
|
|
28
|
+
apiVersion: any;
|
|
29
|
+
operation: any;
|
|
30
|
+
}, myAppStateKeyId: any, state: any, getAppStateSyncKey: any): Promise<{
|
|
31
|
+
patch: {
|
|
32
|
+
patchMac: any;
|
|
33
|
+
snapshotMac: any;
|
|
34
|
+
keyId: {
|
|
35
|
+
id: any;
|
|
36
|
+
};
|
|
37
|
+
mutations: {
|
|
38
|
+
operation: any;
|
|
39
|
+
record: {
|
|
40
|
+
index: {
|
|
41
|
+
blob: any;
|
|
42
|
+
};
|
|
43
|
+
value: {
|
|
44
|
+
blob: any;
|
|
45
|
+
};
|
|
46
|
+
keyId: {
|
|
47
|
+
id: any;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}[];
|
|
51
|
+
};
|
|
52
|
+
state: any;
|
|
53
|
+
}>;
|
|
54
|
+
export function decodeSyncdMutations(msgMutations: any, initialState: any, getAppStateSyncKey: any, onMutation: any, validateMacs: any): Promise<{
|
|
55
|
+
hash: any;
|
|
56
|
+
indexValueMap: any;
|
|
57
|
+
}>;
|
|
58
|
+
export function decodeSyncdPatch(msg: any, name: any, initialState: any, getAppStateSyncKey: any, onMutation: any, validateMacs: any): Promise<{
|
|
59
|
+
hash: any;
|
|
60
|
+
indexValueMap: any;
|
|
61
|
+
}>;
|
|
62
|
+
export function extractSyncdPatches(result: any, options: any): Promise<{}>;
|
|
63
|
+
export function downloadExternalBlob(blob: any, options: any): Promise<any>;
|
|
64
|
+
export function downloadExternalPatch(blob: any, options: any): Promise<any>;
|
|
65
|
+
export function decodeSyncdSnapshot(name: any, snapshot: any, getAppStateSyncKey: any, minimumVersionNumber: any, validateMacs: boolean | undefined, logger: any): Promise<{
|
|
66
|
+
state: {
|
|
67
|
+
version: number;
|
|
68
|
+
hash: any;
|
|
69
|
+
indexValueMap: {};
|
|
70
|
+
};
|
|
71
|
+
mutationMap: {};
|
|
72
|
+
}>;
|
|
73
|
+
export function decodePatches(name: any, syncds: any, initial: any, getAppStateSyncKey: any, options: any, minimumVersionNumber: any, logger: any, validateMacs?: boolean): Promise<{
|
|
74
|
+
state: any;
|
|
75
|
+
mutationMap: {};
|
|
76
|
+
}>;
|
|
77
|
+
export function chatModificationToAppPatch(mod: any, jid: any): {
|
|
78
|
+
syncAction: {
|
|
79
|
+
muteAction: {
|
|
80
|
+
muted: boolean;
|
|
81
|
+
muteEndTimestamp: any;
|
|
82
|
+
};
|
|
83
|
+
archiveChatAction?: undefined;
|
|
84
|
+
markChatAsReadAction?: undefined;
|
|
85
|
+
deleteMessageForMeAction?: undefined;
|
|
86
|
+
clearChatAction?: undefined;
|
|
87
|
+
pinAction?: undefined;
|
|
88
|
+
contactAction?: undefined;
|
|
89
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
90
|
+
starAction?: undefined;
|
|
91
|
+
deleteChatAction?: undefined;
|
|
92
|
+
pushNameSetting?: undefined;
|
|
93
|
+
quickReplyAction?: undefined;
|
|
94
|
+
labelEditAction?: undefined;
|
|
95
|
+
labelAssociationAction?: undefined;
|
|
96
|
+
};
|
|
97
|
+
index: any[];
|
|
98
|
+
type: string;
|
|
99
|
+
apiVersion: number;
|
|
100
|
+
operation: any;
|
|
101
|
+
} | {
|
|
102
|
+
syncAction: {
|
|
103
|
+
archiveChatAction: {
|
|
104
|
+
archived: boolean;
|
|
105
|
+
messageRange: any;
|
|
106
|
+
};
|
|
107
|
+
muteAction?: undefined;
|
|
108
|
+
markChatAsReadAction?: undefined;
|
|
109
|
+
deleteMessageForMeAction?: undefined;
|
|
110
|
+
clearChatAction?: undefined;
|
|
111
|
+
pinAction?: undefined;
|
|
112
|
+
contactAction?: undefined;
|
|
113
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
114
|
+
starAction?: undefined;
|
|
115
|
+
deleteChatAction?: undefined;
|
|
116
|
+
pushNameSetting?: undefined;
|
|
117
|
+
quickReplyAction?: undefined;
|
|
118
|
+
labelEditAction?: undefined;
|
|
119
|
+
labelAssociationAction?: undefined;
|
|
120
|
+
};
|
|
121
|
+
index: any[];
|
|
122
|
+
type: string;
|
|
123
|
+
apiVersion: number;
|
|
124
|
+
operation: any;
|
|
125
|
+
} | {
|
|
126
|
+
syncAction: {
|
|
127
|
+
markChatAsReadAction: {
|
|
128
|
+
read: any;
|
|
129
|
+
messageRange: any;
|
|
130
|
+
};
|
|
131
|
+
muteAction?: undefined;
|
|
132
|
+
archiveChatAction?: undefined;
|
|
133
|
+
deleteMessageForMeAction?: undefined;
|
|
134
|
+
clearChatAction?: undefined;
|
|
135
|
+
pinAction?: undefined;
|
|
136
|
+
contactAction?: undefined;
|
|
137
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
138
|
+
starAction?: undefined;
|
|
139
|
+
deleteChatAction?: undefined;
|
|
140
|
+
pushNameSetting?: undefined;
|
|
141
|
+
quickReplyAction?: undefined;
|
|
142
|
+
labelEditAction?: undefined;
|
|
143
|
+
labelAssociationAction?: undefined;
|
|
144
|
+
};
|
|
145
|
+
index: any[];
|
|
146
|
+
type: string;
|
|
147
|
+
apiVersion: number;
|
|
148
|
+
operation: any;
|
|
149
|
+
} | {
|
|
150
|
+
syncAction: {
|
|
151
|
+
deleteMessageForMeAction: {
|
|
152
|
+
deleteMedia: any;
|
|
153
|
+
messageTimestamp: any;
|
|
154
|
+
};
|
|
155
|
+
muteAction?: undefined;
|
|
156
|
+
archiveChatAction?: undefined;
|
|
157
|
+
markChatAsReadAction?: undefined;
|
|
158
|
+
clearChatAction?: undefined;
|
|
159
|
+
pinAction?: undefined;
|
|
160
|
+
contactAction?: undefined;
|
|
161
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
162
|
+
starAction?: undefined;
|
|
163
|
+
deleteChatAction?: undefined;
|
|
164
|
+
pushNameSetting?: undefined;
|
|
165
|
+
quickReplyAction?: undefined;
|
|
166
|
+
labelEditAction?: undefined;
|
|
167
|
+
labelAssociationAction?: undefined;
|
|
168
|
+
};
|
|
169
|
+
index: any[];
|
|
170
|
+
type: string;
|
|
171
|
+
apiVersion: number;
|
|
172
|
+
operation: any;
|
|
173
|
+
} | {
|
|
174
|
+
syncAction: {
|
|
175
|
+
clearChatAction: {
|
|
176
|
+
messageRange: any;
|
|
177
|
+
};
|
|
178
|
+
muteAction?: undefined;
|
|
179
|
+
archiveChatAction?: undefined;
|
|
180
|
+
markChatAsReadAction?: undefined;
|
|
181
|
+
deleteMessageForMeAction?: undefined;
|
|
182
|
+
pinAction?: undefined;
|
|
183
|
+
contactAction?: undefined;
|
|
184
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
185
|
+
starAction?: undefined;
|
|
186
|
+
deleteChatAction?: undefined;
|
|
187
|
+
pushNameSetting?: undefined;
|
|
188
|
+
quickReplyAction?: undefined;
|
|
189
|
+
labelEditAction?: undefined;
|
|
190
|
+
labelAssociationAction?: undefined;
|
|
191
|
+
};
|
|
192
|
+
index: any[];
|
|
193
|
+
type: string;
|
|
194
|
+
apiVersion: number;
|
|
195
|
+
operation: any;
|
|
196
|
+
} | {
|
|
197
|
+
syncAction: {
|
|
198
|
+
pinAction: {
|
|
199
|
+
pinned: boolean;
|
|
200
|
+
};
|
|
201
|
+
muteAction?: undefined;
|
|
202
|
+
archiveChatAction?: undefined;
|
|
203
|
+
markChatAsReadAction?: undefined;
|
|
204
|
+
deleteMessageForMeAction?: undefined;
|
|
205
|
+
clearChatAction?: undefined;
|
|
206
|
+
contactAction?: undefined;
|
|
207
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
208
|
+
starAction?: undefined;
|
|
209
|
+
deleteChatAction?: undefined;
|
|
210
|
+
pushNameSetting?: undefined;
|
|
211
|
+
quickReplyAction?: undefined;
|
|
212
|
+
labelEditAction?: undefined;
|
|
213
|
+
labelAssociationAction?: undefined;
|
|
214
|
+
};
|
|
215
|
+
index: any[];
|
|
216
|
+
type: string;
|
|
217
|
+
apiVersion: number;
|
|
218
|
+
operation: any;
|
|
219
|
+
} | {
|
|
220
|
+
syncAction: {
|
|
221
|
+
contactAction: any;
|
|
222
|
+
muteAction?: undefined;
|
|
223
|
+
archiveChatAction?: undefined;
|
|
224
|
+
markChatAsReadAction?: undefined;
|
|
225
|
+
deleteMessageForMeAction?: undefined;
|
|
226
|
+
clearChatAction?: undefined;
|
|
227
|
+
pinAction?: undefined;
|
|
228
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
229
|
+
starAction?: undefined;
|
|
230
|
+
deleteChatAction?: undefined;
|
|
231
|
+
pushNameSetting?: undefined;
|
|
232
|
+
quickReplyAction?: undefined;
|
|
233
|
+
labelEditAction?: undefined;
|
|
234
|
+
labelAssociationAction?: undefined;
|
|
235
|
+
};
|
|
236
|
+
index: any[];
|
|
237
|
+
type: string;
|
|
238
|
+
apiVersion: number;
|
|
239
|
+
operation: any;
|
|
240
|
+
} | {
|
|
241
|
+
syncAction: {
|
|
242
|
+
privacySettingDisableLinkPreviewsAction: any;
|
|
243
|
+
muteAction?: undefined;
|
|
244
|
+
archiveChatAction?: undefined;
|
|
245
|
+
markChatAsReadAction?: undefined;
|
|
246
|
+
deleteMessageForMeAction?: undefined;
|
|
247
|
+
clearChatAction?: undefined;
|
|
248
|
+
pinAction?: undefined;
|
|
249
|
+
contactAction?: undefined;
|
|
250
|
+
starAction?: undefined;
|
|
251
|
+
deleteChatAction?: undefined;
|
|
252
|
+
pushNameSetting?: undefined;
|
|
253
|
+
quickReplyAction?: undefined;
|
|
254
|
+
labelEditAction?: undefined;
|
|
255
|
+
labelAssociationAction?: undefined;
|
|
256
|
+
};
|
|
257
|
+
index: string[];
|
|
258
|
+
type: string;
|
|
259
|
+
apiVersion: number;
|
|
260
|
+
operation: any;
|
|
261
|
+
} | {
|
|
262
|
+
syncAction: {
|
|
263
|
+
starAction: {
|
|
264
|
+
starred: boolean;
|
|
265
|
+
};
|
|
266
|
+
muteAction?: undefined;
|
|
267
|
+
archiveChatAction?: undefined;
|
|
268
|
+
markChatAsReadAction?: undefined;
|
|
269
|
+
deleteMessageForMeAction?: undefined;
|
|
270
|
+
clearChatAction?: undefined;
|
|
271
|
+
pinAction?: undefined;
|
|
272
|
+
contactAction?: undefined;
|
|
273
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
274
|
+
deleteChatAction?: undefined;
|
|
275
|
+
pushNameSetting?: undefined;
|
|
276
|
+
quickReplyAction?: undefined;
|
|
277
|
+
labelEditAction?: undefined;
|
|
278
|
+
labelAssociationAction?: undefined;
|
|
279
|
+
};
|
|
280
|
+
index: any[];
|
|
281
|
+
type: string;
|
|
282
|
+
apiVersion: number;
|
|
283
|
+
operation: any;
|
|
284
|
+
} | {
|
|
285
|
+
syncAction: {
|
|
286
|
+
deleteChatAction: {
|
|
287
|
+
messageRange: any;
|
|
288
|
+
};
|
|
289
|
+
muteAction?: undefined;
|
|
290
|
+
archiveChatAction?: undefined;
|
|
291
|
+
markChatAsReadAction?: undefined;
|
|
292
|
+
deleteMessageForMeAction?: undefined;
|
|
293
|
+
clearChatAction?: undefined;
|
|
294
|
+
pinAction?: undefined;
|
|
295
|
+
contactAction?: undefined;
|
|
296
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
297
|
+
starAction?: undefined;
|
|
298
|
+
pushNameSetting?: undefined;
|
|
299
|
+
quickReplyAction?: undefined;
|
|
300
|
+
labelEditAction?: undefined;
|
|
301
|
+
labelAssociationAction?: undefined;
|
|
302
|
+
};
|
|
303
|
+
index: any[];
|
|
304
|
+
type: string;
|
|
305
|
+
apiVersion: number;
|
|
306
|
+
operation: any;
|
|
307
|
+
} | {
|
|
308
|
+
syncAction: {
|
|
309
|
+
pushNameSetting: {
|
|
310
|
+
name: any;
|
|
311
|
+
};
|
|
312
|
+
muteAction?: undefined;
|
|
313
|
+
archiveChatAction?: undefined;
|
|
314
|
+
markChatAsReadAction?: undefined;
|
|
315
|
+
deleteMessageForMeAction?: undefined;
|
|
316
|
+
clearChatAction?: undefined;
|
|
317
|
+
pinAction?: undefined;
|
|
318
|
+
contactAction?: undefined;
|
|
319
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
320
|
+
starAction?: undefined;
|
|
321
|
+
deleteChatAction?: undefined;
|
|
322
|
+
quickReplyAction?: undefined;
|
|
323
|
+
labelEditAction?: undefined;
|
|
324
|
+
labelAssociationAction?: undefined;
|
|
325
|
+
};
|
|
326
|
+
index: string[];
|
|
327
|
+
type: string;
|
|
328
|
+
apiVersion: number;
|
|
329
|
+
operation: any;
|
|
330
|
+
} | {
|
|
331
|
+
syncAction: {
|
|
332
|
+
quickReplyAction: {
|
|
333
|
+
count: number;
|
|
334
|
+
deleted: any;
|
|
335
|
+
keywords: never[];
|
|
336
|
+
message: any;
|
|
337
|
+
shortcut: any;
|
|
338
|
+
};
|
|
339
|
+
muteAction?: undefined;
|
|
340
|
+
archiveChatAction?: undefined;
|
|
341
|
+
markChatAsReadAction?: undefined;
|
|
342
|
+
deleteMessageForMeAction?: undefined;
|
|
343
|
+
clearChatAction?: undefined;
|
|
344
|
+
pinAction?: undefined;
|
|
345
|
+
contactAction?: undefined;
|
|
346
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
347
|
+
starAction?: undefined;
|
|
348
|
+
deleteChatAction?: undefined;
|
|
349
|
+
pushNameSetting?: undefined;
|
|
350
|
+
labelEditAction?: undefined;
|
|
351
|
+
labelAssociationAction?: undefined;
|
|
352
|
+
};
|
|
353
|
+
index: any[];
|
|
354
|
+
type: string;
|
|
355
|
+
apiVersion: number;
|
|
356
|
+
operation: any;
|
|
357
|
+
} | {
|
|
358
|
+
syncAction: {
|
|
359
|
+
labelEditAction: {
|
|
360
|
+
name: any;
|
|
361
|
+
color: any;
|
|
362
|
+
predefinedId: any;
|
|
363
|
+
deleted: any;
|
|
364
|
+
};
|
|
365
|
+
muteAction?: undefined;
|
|
366
|
+
archiveChatAction?: undefined;
|
|
367
|
+
markChatAsReadAction?: undefined;
|
|
368
|
+
deleteMessageForMeAction?: undefined;
|
|
369
|
+
clearChatAction?: undefined;
|
|
370
|
+
pinAction?: undefined;
|
|
371
|
+
contactAction?: undefined;
|
|
372
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
373
|
+
starAction?: undefined;
|
|
374
|
+
deleteChatAction?: undefined;
|
|
375
|
+
pushNameSetting?: undefined;
|
|
376
|
+
quickReplyAction?: undefined;
|
|
377
|
+
labelAssociationAction?: undefined;
|
|
378
|
+
};
|
|
379
|
+
index: any[];
|
|
380
|
+
type: string;
|
|
381
|
+
apiVersion: number;
|
|
382
|
+
operation: any;
|
|
383
|
+
} | {
|
|
384
|
+
syncAction: {
|
|
385
|
+
labelAssociationAction: {
|
|
386
|
+
labeled: boolean;
|
|
387
|
+
};
|
|
388
|
+
muteAction?: undefined;
|
|
389
|
+
archiveChatAction?: undefined;
|
|
390
|
+
markChatAsReadAction?: undefined;
|
|
391
|
+
deleteMessageForMeAction?: undefined;
|
|
392
|
+
clearChatAction?: undefined;
|
|
393
|
+
pinAction?: undefined;
|
|
394
|
+
contactAction?: undefined;
|
|
395
|
+
privacySettingDisableLinkPreviewsAction?: undefined;
|
|
396
|
+
starAction?: undefined;
|
|
397
|
+
deleteChatAction?: undefined;
|
|
398
|
+
pushNameSetting?: undefined;
|
|
399
|
+
quickReplyAction?: undefined;
|
|
400
|
+
labelEditAction?: undefined;
|
|
401
|
+
};
|
|
402
|
+
index: any[];
|
|
403
|
+
type: string;
|
|
404
|
+
apiVersion: number;
|
|
405
|
+
operation: any;
|
|
406
|
+
};
|
|
407
|
+
export function processSyncAction(syncAction: any, ev: any, me: any, initialSyncOpts: any, logger: any): void;
|
package/lib/Utils/chat-utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Boom } from '@hapi/boom';
|
|
2
|
-
import { expandAppStateKeys } from 'whatsapp-rust-bridge';
|
|
3
2
|
import { proto } from '../../WAProto/index.js';
|
|
4
3
|
import { LabelAssociationType } from '../Types/LabelAssociation.js';
|
|
5
4
|
import { getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, jidNormalizedUser } from '../WABinary/index.js';
|
|
@@ -8,6 +7,21 @@ import { toNumber } from './generics.js';
|
|
|
8
7
|
import { LT_HASH_ANTI_TAMPERING } from './lt-hash.js';
|
|
9
8
|
import { downloadContentFromMessage } from './messages-media.js';
|
|
10
9
|
import { emitSyncActionResults, processContactAction } from './sync-action-utils.js';
|
|
10
|
+
// Vanz@Fix (bug 36 follow-up): same top-level-await try/catch treatment as crypto.js and
|
|
11
|
+
// lt-hash.js — avoid crashing the whole library at import time if the whatsapp-rust-bridge
|
|
12
|
+
// native binary is missing on this platform (ARM musl/Alpine/Termux/some Pterodactyl nodes);
|
|
13
|
+
// only throw when app-state sync actually needs it. Kept synchronous (not async) because
|
|
14
|
+
// mutationKeys() is called synchronously throughout this file — making it async would be
|
|
15
|
+
// a breaking change for those call sites.
|
|
16
|
+
let expandAppStateKeys;
|
|
17
|
+
try {
|
|
18
|
+
({ expandAppStateKeys } = await import('whatsapp-rust-bridge'));
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
const message = '`whatsapp-rust-bridge` failed to load (no prebuilt binary for this platform/arch). ' +
|
|
22
|
+
'App-state sync is unavailable here. Original error: ' + (err?.message || err);
|
|
23
|
+
expandAppStateKeys = () => { throw new Error(message); };
|
|
24
|
+
}
|
|
11
25
|
const mutationKeys = (keydata) => {
|
|
12
26
|
const keys = expandAppStateKeys(keydata);
|
|
13
27
|
return {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const CompanionWebClientType: any;
|
|
2
|
+
export function getCompanionWebClientType([os, browserName]: [any, any]): any;
|
|
3
|
+
export function getCompanionPlatformId(browser: any): any;
|
|
4
|
+
export function buildPairingQRData(ref: any, noiseKeyB64: any, identityKeyB64: any, advB64: any, browser: any): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* encrypt AES 256 GCM;
|
|
3
|
+
* where the tag tag is suffixed to the ciphertext
|
|
4
|
+
* */
|
|
5
|
+
export function aesEncryptGCM(plaintext: any, key: any, iv: any, additionalData: any): any;
|
|
6
|
+
/**
|
|
7
|
+
* decrypt AES 256 GCM;
|
|
8
|
+
* where the auth tag is suffixed to the ciphertext
|
|
9
|
+
* */
|
|
10
|
+
export function aesDecryptGCM(ciphertext: any, key: any, iv: any, additionalData: any): any;
|
|
11
|
+
export function aesEncryptCTR(plaintext: any, key: any, iv: any): any;
|
|
12
|
+
export function aesDecryptCTR(ciphertext: any, key: any, iv: any): any;
|
|
13
|
+
/** decrypt AES 256 CBC; where the IV is prefixed to the buffer */
|
|
14
|
+
export function aesDecrypt(buffer: any, key: any): any;
|
|
15
|
+
/** decrypt AES 256 CBC */
|
|
16
|
+
export function aesDecryptWithIV(buffer: any, key: any, IV: any): any;
|
|
17
|
+
export function aesEncrypt(buffer: any, key: any): any;
|
|
18
|
+
export function aesEncrypWithIV(buffer: any, key: any, IV: any): any;
|
|
19
|
+
export function hmacSign(buffer: any, key: any, variant?: string): any;
|
|
20
|
+
export function sha256(buffer: any): any;
|
|
21
|
+
export function derivePairingCodeKey(pairingCode: any, salt: any): Promise<any>;
|
|
22
|
+
export function generateSignalPubKey(pubKey: any): any;
|
|
23
|
+
export namespace Curve {
|
|
24
|
+
function generateKeyPair(): {
|
|
25
|
+
private: any;
|
|
26
|
+
public: any;
|
|
27
|
+
};
|
|
28
|
+
function sharedKey(privateKey: any, publicKey: any): any;
|
|
29
|
+
function sign(privateKey: any, buf: any): any;
|
|
30
|
+
function verify(pubKey: any, message: any, signature: any): boolean;
|
|
31
|
+
}
|
|
32
|
+
export function signedKeyPair(identityKeyPair: any, keyId: any): {
|
|
33
|
+
keyPair: {
|
|
34
|
+
private: any;
|
|
35
|
+
public: any;
|
|
36
|
+
};
|
|
37
|
+
signature: any;
|
|
38
|
+
keyId: any;
|
|
39
|
+
};
|
|
40
|
+
export let md5: any;
|
|
41
|
+
export let hkdf: any;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode the received node as a message.
|
|
3
|
+
* @note this will only parse the message, not decrypt it
|
|
4
|
+
*/
|
|
5
|
+
export function decodeMessageNode(stanza: any, meId: any, meLid: any): {
|
|
6
|
+
fullMessage: {
|
|
7
|
+
key: {
|
|
8
|
+
server_id?: any;
|
|
9
|
+
remoteJid: any;
|
|
10
|
+
remoteJidAlt: any;
|
|
11
|
+
remoteJidUsername: any;
|
|
12
|
+
fromMe: boolean;
|
|
13
|
+
id: any;
|
|
14
|
+
participant: any;
|
|
15
|
+
participantAlt: any;
|
|
16
|
+
participantUsername: any;
|
|
17
|
+
addressingMode: any;
|
|
18
|
+
};
|
|
19
|
+
category: any;
|
|
20
|
+
messageTimestamp: number;
|
|
21
|
+
pushName: any;
|
|
22
|
+
broadcast: any;
|
|
23
|
+
};
|
|
24
|
+
author: any;
|
|
25
|
+
sender: any;
|
|
26
|
+
};
|
|
27
|
+
export function getDecryptionJid(sender: any, repository: any): Promise<any>;
|
|
28
|
+
export const NO_MESSAGE_FOUND_ERROR_TEXT: "Message absent from node";
|
|
29
|
+
export const MISSING_KEYS_ERROR_TEXT: "Key used already or never filled";
|
|
30
|
+
export const ACCOUNT_RESTRICTED_TEXT: "Your account has been restricted";
|
|
31
|
+
export namespace DECRYPTION_RETRY_CONFIG {
|
|
32
|
+
let maxRetries: number;
|
|
33
|
+
let baseDelayMs: number;
|
|
34
|
+
let sessionRecordErrors: string[];
|
|
35
|
+
}
|
|
36
|
+
export namespace NACK_REASONS {
|
|
37
|
+
let SenderReachoutTimelocked: number;
|
|
38
|
+
let ParsingError: number;
|
|
39
|
+
let UnrecognizedStanza: number;
|
|
40
|
+
let UnrecognizedStanzaClass: number;
|
|
41
|
+
let UnrecognizedStanzaType: number;
|
|
42
|
+
let InvalidProtobuf: number;
|
|
43
|
+
let InvalidHostedCompanionStanza: number;
|
|
44
|
+
let MissingMessageSecret: number;
|
|
45
|
+
let SignalErrorOldCounter: number;
|
|
46
|
+
let MessageDeletedOnPeer: number;
|
|
47
|
+
let UnhandledError: number;
|
|
48
|
+
let UnsupportedAdminRevoke: number;
|
|
49
|
+
let UnsupportedLIDGroup: number;
|
|
50
|
+
let DBOperationFailed: number;
|
|
51
|
+
}
|
|
52
|
+
export namespace SERVER_ERROR_CODES {
|
|
53
|
+
let MessageAccountRestriction: string;
|
|
54
|
+
let SmaxInvalid: string;
|
|
55
|
+
}
|
|
56
|
+
export function extractAddressingContext(stanza: any): {
|
|
57
|
+
addressingMode: any;
|
|
58
|
+
senderAlt: any;
|
|
59
|
+
recipientAlt: any;
|
|
60
|
+
};
|
|
61
|
+
export function decryptMessageNode(stanza: any, meId: any, meLid: any, repository: any, logger: any): {
|
|
62
|
+
fullMessage: {
|
|
63
|
+
key: {
|
|
64
|
+
server_id?: any;
|
|
65
|
+
remoteJid: any;
|
|
66
|
+
remoteJidAlt: any;
|
|
67
|
+
remoteJidUsername: any;
|
|
68
|
+
fromMe: boolean;
|
|
69
|
+
id: any;
|
|
70
|
+
participant: any;
|
|
71
|
+
participantAlt: any;
|
|
72
|
+
participantUsername: any;
|
|
73
|
+
addressingMode: any;
|
|
74
|
+
};
|
|
75
|
+
category: any;
|
|
76
|
+
messageTimestamp: number;
|
|
77
|
+
pushName: any;
|
|
78
|
+
broadcast: any;
|
|
79
|
+
};
|
|
80
|
+
category: any;
|
|
81
|
+
author: any;
|
|
82
|
+
decrypt(): Promise<void>;
|
|
83
|
+
};
|