@queenanya/baileys 8.3.1 → 8.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Defaults/index.d.ts +0 -231
- package/lib/Defaults/index.js +1 -17
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
- package/lib/Signal/libsignal.js +33 -20
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -0
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +2 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +12 -2
- package/lib/Socket/business.d.ts +3 -3
- package/lib/Socket/chat-set.d.ts +3 -0
- package/lib/Socket/chat-set.js +63 -0
- package/lib/Socket/chats.d.ts +1 -1
- package/lib/Socket/chats.js +11 -8
- package/lib/Socket/groups.d.ts +1 -1
- package/lib/Socket/index.d.ts +3 -5
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +3 -3
- package/lib/Socket/messages-recv.js +16 -8
- package/lib/Socket/messages-send.d.ts +2 -2
- package/lib/Socket/messages-send.js +75 -9
- package/lib/Socket/newsletter.d.ts +1 -1
- package/lib/Socket/socket.d.ts +2 -1
- package/lib/Socket/socket.js +71 -14
- package/lib/Socket/usync.d.ts +1 -1
- package/lib/Store/make-in-memory-store.js +8 -10
- package/lib/Types/Auth.d.ts +0 -6
- package/lib/Types/Message.d.ts +16 -3
- package/lib/Types/Socket.d.ts +3 -3
- package/lib/Utils/auth-utils.js +0 -7
- package/lib/Utils/event-buffer.js +4 -6
- package/lib/Utils/index.d.ts +1 -0
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/messages-media.js +11 -10
- package/lib/Utils/messages.js +10 -2
- package/lib/Utils/midea-msg.d.ts +14 -0
- package/lib/Utils/midea-msg.js +72 -0
- package/lib/Utils/noise-handler.d.ts +1 -2
- package/lib/Utils/noise-handler.js +5 -10
- package/lib/Utils/use-single-file-auth-state.d.ts +5 -0
- package/lib/Utils/use-single-file-auth-state.js +66 -0
- package/lib/Utils/validate-connection.d.ts +0 -1
- package/lib/Utils/validate-connection.js +10 -44
- package/lib/WABinary/jid-utils.d.ts +1 -1
- package/lib/WABinary/jid-utils.js +1 -1
- package/package.json +2 -1
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -12
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/registration.d.ts +0 -266
- package/lib/Socket/registration.js +0 -166
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
package/lib/Signal/libsignal.js
CHANGED
|
@@ -35,24 +35,30 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.makeLibSignalRepository = makeLibSignalRepository;
|
|
37
37
|
const libsignal = __importStar(require("libsignal"));
|
|
38
|
-
const WASignalGroup_1 = require("../../WASignalGroup");
|
|
39
38
|
const Utils_1 = require("../Utils");
|
|
40
39
|
const WABinary_1 = require("../WABinary");
|
|
40
|
+
const sender_key_name_1 = require("./Group/sender-key-name");
|
|
41
|
+
const sender_key_record_1 = require("./Group/sender-key-record");
|
|
42
|
+
const Group_1 = require("./Group");
|
|
41
43
|
function makeLibSignalRepository(auth) {
|
|
42
44
|
const storage = signalStorage(auth);
|
|
43
45
|
return {
|
|
44
46
|
decryptGroupMessage({ group, authorJid, msg }) {
|
|
45
47
|
const senderName = jidToSignalSenderKeyName(group, authorJid);
|
|
46
|
-
const cipher = new
|
|
48
|
+
const cipher = new Group_1.GroupCipher(storage, senderName);
|
|
47
49
|
return cipher.decrypt(msg);
|
|
48
50
|
},
|
|
49
51
|
async processSenderKeyDistributionMessage({ item, authorJid }) {
|
|
50
|
-
const builder = new
|
|
52
|
+
const builder = new Group_1.GroupSessionBuilder(storage);
|
|
53
|
+
if (!item.groupId) {
|
|
54
|
+
throw new Error('Group ID is required for sender key distribution message');
|
|
55
|
+
}
|
|
51
56
|
const senderName = jidToSignalSenderKeyName(item.groupId, authorJid);
|
|
52
|
-
const senderMsg = new
|
|
53
|
-
const
|
|
57
|
+
const senderMsg = new Group_1.SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage);
|
|
58
|
+
const senderNameStr = senderName.toString();
|
|
59
|
+
const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr]);
|
|
54
60
|
if (!senderKey) {
|
|
55
|
-
await storage.storeSenderKey(senderName, new
|
|
61
|
+
await storage.storeSenderKey(senderName, new sender_key_record_1.SenderKeyRecord());
|
|
56
62
|
}
|
|
57
63
|
await builder.process(senderName, senderMsg);
|
|
58
64
|
},
|
|
@@ -67,6 +73,8 @@ function makeLibSignalRepository(auth) {
|
|
|
67
73
|
case 'msg':
|
|
68
74
|
result = await session.decryptWhisperMessage(ciphertext);
|
|
69
75
|
break;
|
|
76
|
+
default:
|
|
77
|
+
throw new Error(`Unknown message type: ${type}`);
|
|
70
78
|
}
|
|
71
79
|
return result;
|
|
72
80
|
},
|
|
@@ -79,17 +87,18 @@ function makeLibSignalRepository(auth) {
|
|
|
79
87
|
},
|
|
80
88
|
async encryptGroupMessage({ group, meId, data }) {
|
|
81
89
|
const senderName = jidToSignalSenderKeyName(group, meId);
|
|
82
|
-
const builder = new
|
|
83
|
-
const
|
|
90
|
+
const builder = new Group_1.GroupSessionBuilder(storage);
|
|
91
|
+
const senderNameStr = senderName.toString();
|
|
92
|
+
const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr]);
|
|
84
93
|
if (!senderKey) {
|
|
85
|
-
await storage.storeSenderKey(senderName, new
|
|
94
|
+
await storage.storeSenderKey(senderName, new sender_key_record_1.SenderKeyRecord());
|
|
86
95
|
}
|
|
87
96
|
const senderKeyDistributionMessage = await builder.create(senderName);
|
|
88
|
-
const session = new
|
|
97
|
+
const session = new Group_1.GroupCipher(storage, senderName);
|
|
89
98
|
const ciphertext = await session.encrypt(data);
|
|
90
99
|
return {
|
|
91
100
|
ciphertext,
|
|
92
|
-
senderKeyDistributionMessage: senderKeyDistributionMessage.serialize()
|
|
101
|
+
senderKeyDistributionMessage: senderKeyDistributionMessage.serialize()
|
|
93
102
|
};
|
|
94
103
|
},
|
|
95
104
|
async injectE2ESession({ jid, session }) {
|
|
@@ -98,7 +107,7 @@ function makeLibSignalRepository(auth) {
|
|
|
98
107
|
},
|
|
99
108
|
jidToSignalProtocolAddress(jid) {
|
|
100
109
|
return jidToSignalProtocolAddress(jid).toString();
|
|
101
|
-
}
|
|
110
|
+
}
|
|
102
111
|
};
|
|
103
112
|
}
|
|
104
113
|
const jidToSignalProtocolAddress = (jid) => {
|
|
@@ -106,7 +115,7 @@ const jidToSignalProtocolAddress = (jid) => {
|
|
|
106
115
|
return new libsignal.ProtocolAddress(user, device || 0);
|
|
107
116
|
};
|
|
108
117
|
const jidToSignalSenderKeyName = (group, user) => {
|
|
109
|
-
return new
|
|
118
|
+
return new sender_key_name_1.SenderKeyName(group, jidToSignalProtocolAddress(user));
|
|
110
119
|
};
|
|
111
120
|
function signalStorage({ creds, keys }) {
|
|
112
121
|
return {
|
|
@@ -117,7 +126,7 @@ function signalStorage({ creds, keys }) {
|
|
|
117
126
|
}
|
|
118
127
|
},
|
|
119
128
|
storeSession: async (id, session) => {
|
|
120
|
-
await keys.set({
|
|
129
|
+
await keys.set({ session: { [id]: session.serialize() } });
|
|
121
130
|
},
|
|
122
131
|
isTrustedIdentity: () => {
|
|
123
132
|
return true;
|
|
@@ -140,21 +149,25 @@ function signalStorage({ creds, keys }) {
|
|
|
140
149
|
pubKey: Buffer.from(key.keyPair.public)
|
|
141
150
|
};
|
|
142
151
|
},
|
|
143
|
-
loadSenderKey: async (
|
|
152
|
+
loadSenderKey: async (senderKeyName) => {
|
|
153
|
+
const keyId = senderKeyName.toString();
|
|
144
154
|
const { [keyId]: key } = await keys.get('sender-key', [keyId]);
|
|
145
155
|
if (key) {
|
|
146
|
-
return
|
|
156
|
+
return sender_key_record_1.SenderKeyRecord.deserialize(key);
|
|
147
157
|
}
|
|
158
|
+
return new sender_key_record_1.SenderKeyRecord();
|
|
148
159
|
},
|
|
149
|
-
storeSenderKey: async (
|
|
150
|
-
|
|
160
|
+
storeSenderKey: async (senderKeyName, key) => {
|
|
161
|
+
const keyId = senderKeyName.toString();
|
|
162
|
+
const serialized = JSON.stringify(key.serialize());
|
|
163
|
+
await keys.set({ 'sender-key': { [keyId]: Buffer.from(serialized, 'utf-8') } });
|
|
151
164
|
},
|
|
152
|
-
getOurRegistrationId: () =>
|
|
165
|
+
getOurRegistrationId: () => creds.registrationId,
|
|
153
166
|
getOurIdentity: () => {
|
|
154
167
|
const { signedIdentityKey } = creds;
|
|
155
168
|
return {
|
|
156
169
|
privKey: Buffer.from(signedIdentityKey.private),
|
|
157
|
-
pubKey: (0, Utils_1.generateSignalPubKey)(signedIdentityKey.public)
|
|
170
|
+
pubKey: (0, Utils_1.generateSignalPubKey)(signedIdentityKey.public)
|
|
158
171
|
};
|
|
159
172
|
}
|
|
160
173
|
};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './web-socket-client';
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './websocket';
|
|
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./web-socket-client"), exports);
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./websocket"), exports);
|
|
@@ -11,5 +11,6 @@ export declare abstract class AbstractSocketClient extends EventEmitter {
|
|
|
11
11
|
constructor(url: URL, config: SocketConfig);
|
|
12
12
|
abstract connect(): Promise<void>;
|
|
13
13
|
abstract close(): Promise<void>;
|
|
14
|
+
abstract restart(): Promise<void>;
|
|
14
15
|
abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
|
15
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import WebSocket from 'ws';
|
|
2
|
-
import { AbstractSocketClient } from './
|
|
2
|
+
import { AbstractSocketClient } from './types';
|
|
3
3
|
export declare class WebSocketClient extends AbstractSocketClient {
|
|
4
4
|
protected socket: WebSocket | null;
|
|
5
5
|
get isOpen(): boolean;
|
|
@@ -8,5 +8,6 @@ export declare class WebSocketClient extends AbstractSocketClient {
|
|
|
8
8
|
get isConnecting(): boolean;
|
|
9
9
|
connect(): Promise<void>;
|
|
10
10
|
close(): Promise<void>;
|
|
11
|
+
restart(): Promise<void>;
|
|
11
12
|
send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean;
|
|
12
13
|
}
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.WebSocketClient = void 0;
|
|
7
7
|
const ws_1 = __importDefault(require("ws"));
|
|
8
8
|
const Defaults_1 = require("../../Defaults");
|
|
9
|
-
const
|
|
10
|
-
class WebSocketClient extends
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
class WebSocketClient extends types_1.AbstractSocketClient {
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.socket = null;
|
|
@@ -53,6 +53,16 @@ class WebSocketClient extends abstract_socket_client_1.AbstractSocketClient {
|
|
|
53
53
|
this.socket.close();
|
|
54
54
|
this.socket = null;
|
|
55
55
|
}
|
|
56
|
+
async restart() {
|
|
57
|
+
if (this.socket) {
|
|
58
|
+
await new Promise(resolve => {
|
|
59
|
+
this.socket.once('close', resolve);
|
|
60
|
+
this.socket.terminate();
|
|
61
|
+
});
|
|
62
|
+
this.socket = null;
|
|
63
|
+
}
|
|
64
|
+
await this.connect();
|
|
65
|
+
}
|
|
56
66
|
send(str, cb) {
|
|
57
67
|
var _a;
|
|
58
68
|
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(str, cb);
|
package/lib/Socket/business.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
24
24
|
isVideo: boolean;
|
|
25
25
|
}>;
|
|
26
26
|
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
27
|
-
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<
|
|
27
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
28
28
|
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
29
29
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
30
30
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
@@ -43,7 +43,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
43
43
|
}>;
|
|
44
44
|
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
45
45
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
46
|
-
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo
|
|
46
|
+
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
|
|
47
47
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
48
48
|
duration: string;
|
|
49
49
|
}>;
|
|
@@ -141,7 +141,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
141
141
|
}[], star: boolean) => Promise<void>;
|
|
142
142
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
143
143
|
type: "md";
|
|
144
|
-
ws:
|
|
144
|
+
ws: import("./Client").WebSocketClient;
|
|
145
145
|
ev: import("../Types").BaileysEventEmitter & {
|
|
146
146
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
147
147
|
buffer(): void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateProfilePictureFull2 = exports.updateProfilePictureFull = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const WABinary_1 = require("../WABinary");
|
|
6
|
+
const Utils_1 = require("../Utils");
|
|
7
|
+
/** update the profile picture for yourself or a group as Full */
|
|
8
|
+
const updateProfilePictureFull = async (jid, content, sock) => {
|
|
9
|
+
const { authState, query } = sock;
|
|
10
|
+
let targetJid;
|
|
11
|
+
if (!jid) {
|
|
12
|
+
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
13
|
+
}
|
|
14
|
+
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
15
|
+
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
16
|
+
}
|
|
17
|
+
const { img } = await (0, Utils_1.generateProfilePictureFull)(content);
|
|
18
|
+
await query({
|
|
19
|
+
tag: 'iq',
|
|
20
|
+
attrs: {
|
|
21
|
+
target: targetJid,
|
|
22
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
23
|
+
type: 'set',
|
|
24
|
+
xmlns: 'w:profile:picture'
|
|
25
|
+
},
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
tag: 'picture',
|
|
29
|
+
attrs: { type: 'image' },
|
|
30
|
+
content: img
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.updateProfilePictureFull = updateProfilePictureFull;
|
|
36
|
+
const updateProfilePictureFull2 = async (jid, content, sock) => {
|
|
37
|
+
const { authState, query } = sock;
|
|
38
|
+
let targetJid;
|
|
39
|
+
if (!jid) {
|
|
40
|
+
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
41
|
+
}
|
|
42
|
+
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
43
|
+
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
44
|
+
}
|
|
45
|
+
const { preview } = await (0, Utils_1.generateProfilePictureFP)(content);
|
|
46
|
+
await query({
|
|
47
|
+
tag: 'iq',
|
|
48
|
+
attrs: {
|
|
49
|
+
target: targetJid,
|
|
50
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
51
|
+
type: 'set',
|
|
52
|
+
xmlns: 'w:profile:picture'
|
|
53
|
+
},
|
|
54
|
+
content: [
|
|
55
|
+
{
|
|
56
|
+
tag: 'picture',
|
|
57
|
+
attrs: { type: 'image' },
|
|
58
|
+
content: preview
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
exports.updateProfilePictureFull2 = updateProfilePictureFull2;
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
52
52
|
}[], star: boolean) => Promise<void>;
|
|
53
53
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
54
54
|
type: "md";
|
|
55
|
-
ws:
|
|
55
|
+
ws: import("./Client").WebSocketClient;
|
|
56
56
|
ev: import("../Types").BaileysEventEmitter & {
|
|
57
57
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
58
58
|
buffer(): void;
|
package/lib/Socket/chats.js
CHANGED
|
@@ -10,6 +10,7 @@ const WAProto_1 = require("../../WAProto");
|
|
|
10
10
|
const Defaults_1 = require("../Defaults");
|
|
11
11
|
const Types_1 = require("../Types");
|
|
12
12
|
const Utils_1 = require("../Utils");
|
|
13
|
+
// import { updateProfilePictureFull, updateProfilePictureFull2 } from './chat-set'
|
|
13
14
|
const make_mutex_1 = require("../Utils/make-mutex");
|
|
14
15
|
const process_message_1 = __importDefault(require("../Utils/process-message"));
|
|
15
16
|
const WABinary_1 = require("../WABinary");
|
|
@@ -490,16 +491,18 @@ const makeChatsSocket = (config) => {
|
|
|
490
491
|
await sendNode({
|
|
491
492
|
tag: 'presence',
|
|
492
493
|
attrs: {
|
|
493
|
-
name: me.name,
|
|
494
|
+
name: me.name.replace(/@/g, ''),
|
|
494
495
|
type
|
|
495
496
|
}
|
|
496
497
|
});
|
|
497
498
|
}
|
|
498
499
|
else {
|
|
500
|
+
const { server } = (0, WABinary_1.jidDecode)(toJid);
|
|
501
|
+
const isLid = server === 'lid';
|
|
499
502
|
await sendNode({
|
|
500
503
|
tag: 'chatstate',
|
|
501
504
|
attrs: {
|
|
502
|
-
from: me.id,
|
|
505
|
+
from: isLid ? me.lid : me.id,
|
|
503
506
|
to: toJid,
|
|
504
507
|
},
|
|
505
508
|
content: [
|
|
@@ -819,14 +822,12 @@ const makeChatsSocket = (config) => {
|
|
|
819
822
|
sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
|
|
820
823
|
.catch(error => onUnexpectedError(error, 'presence update requests'));
|
|
821
824
|
}
|
|
822
|
-
if (receivedPendingNotifications
|
|
823
|
-
// if we don't have the app state key
|
|
825
|
+
if (receivedPendingNotifications && // if we don't have the app state key
|
|
824
826
|
// we keep buffering events until we finally have
|
|
825
827
|
// the key and can sync the messages
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}
|
|
828
|
+
!((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId)) {
|
|
829
|
+
ev.buffer();
|
|
830
|
+
needToFlushWithAppStateSync = true;
|
|
830
831
|
}
|
|
831
832
|
});
|
|
832
833
|
return {
|
|
@@ -844,6 +845,8 @@ const makeChatsSocket = (config) => {
|
|
|
844
845
|
fetchDisappearingDuration,
|
|
845
846
|
fetchStatus,
|
|
846
847
|
updateProfilePicture,
|
|
848
|
+
//updateProfilePictureFull,
|
|
849
|
+
//updateProfilePictureFull2,
|
|
847
850
|
removeProfilePicture,
|
|
848
851
|
updateProfileStatus,
|
|
849
852
|
updateProfileName,
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
92
92
|
}[], star: boolean) => Promise<void>;
|
|
93
93
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
94
94
|
type: "md";
|
|
95
|
-
ws:
|
|
95
|
+
ws: import("./Client").WebSocketClient;
|
|
96
96
|
ev: import("../Types").BaileysEventEmitter & {
|
|
97
97
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
98
98
|
buffer(): void;
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { UserFacingSocketConfig } from '../Types';
|
|
2
2
|
declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
3
|
-
register: (code: string) => Promise<import("./registration").ExistsResponse>;
|
|
4
|
-
requestRegistrationCode: (registrationOptions?: import("./registration").RegistrationOptions) => Promise<import("./registration").ExistsResponse>;
|
|
5
3
|
logger: import("../Utils/logger").ILogger;
|
|
6
4
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
7
5
|
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
|
@@ -25,7 +23,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
25
23
|
isVideo: boolean;
|
|
26
24
|
}>;
|
|
27
25
|
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
28
|
-
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<
|
|
26
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
29
27
|
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
30
28
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
31
29
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
@@ -44,7 +42,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
44
42
|
}>;
|
|
45
43
|
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
46
44
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
47
|
-
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo
|
|
45
|
+
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
|
|
48
46
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
49
47
|
duration: string;
|
|
50
48
|
}>;
|
|
@@ -142,7 +140,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
142
140
|
}[], star: boolean) => Promise<void>;
|
|
143
141
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
144
142
|
type: "md";
|
|
145
|
-
ws:
|
|
143
|
+
ws: import("./Client").WebSocketClient;
|
|
146
144
|
ev: import("../Types").BaileysEventEmitter & {
|
|
147
145
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
148
146
|
buffer(): void;
|
package/lib/Socket/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const Defaults_1 = require("../Defaults");
|
|
4
|
-
const
|
|
4
|
+
const business_1 = require("./business");
|
|
5
5
|
// export the last socket layer
|
|
6
|
-
const makeWASocket = (config) => ((0,
|
|
6
|
+
const makeWASocket = (config) => ((0, business_1.makeBusinessSocket)({
|
|
7
7
|
...Defaults_1.DEFAULT_CONNECTION_CONFIG,
|
|
8
8
|
...config
|
|
9
9
|
}));
|
|
@@ -13,7 +13,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
13
13
|
isVideo: boolean;
|
|
14
14
|
}>;
|
|
15
15
|
fetchMessageHistory: (count: number, oldestMsgKey: WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
16
|
-
requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<
|
|
16
|
+
requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<string | undefined>;
|
|
17
17
|
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
18
18
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
19
19
|
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
@@ -32,7 +32,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
32
32
|
}>;
|
|
33
33
|
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
34
34
|
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
35
|
-
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo
|
|
35
|
+
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
|
|
36
36
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
37
37
|
duration: string;
|
|
38
38
|
}>;
|
|
@@ -130,7 +130,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
130
130
|
}[], star: boolean) => Promise<void>;
|
|
131
131
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
132
132
|
type: "md";
|
|
133
|
-
ws:
|
|
133
|
+
ws: import("./Client").WebSocketClient;
|
|
134
134
|
ev: import("../Types").BaileysEventEmitter & {
|
|
135
135
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
136
136
|
buffer(): void;
|
|
@@ -18,7 +18,7 @@ const messages_send_1 = require("./messages-send");
|
|
|
18
18
|
const makeMessagesRecvSocket = (config) => {
|
|
19
19
|
const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config;
|
|
20
20
|
const sock = (0, messages_send_1.makeMessagesSocket)(config);
|
|
21
|
-
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, createParticipantNodes, getUSyncDevices, sendPeerDataOperationMessage, } = sock;
|
|
21
|
+
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, groupMetadata, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, createParticipantNodes, getUSyncDevices, sendPeerDataOperationMessage, } = sock;
|
|
22
22
|
/** this mutex ensures that each retryRequest will wait for the previous one to finish */
|
|
23
23
|
const retryMutex = (0, make_mutex_1.makeMutex)();
|
|
24
24
|
const msgRetryCache = config.msgRetryCounterCache || new node_cache_1.default({
|
|
@@ -574,8 +574,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
574
574
|
await authState.keys.set({ 'sender-key-memory': { [remoteJid]: null } });
|
|
575
575
|
}
|
|
576
576
|
logger.debug({ participant, sendToAll }, 'forced new session for retry recp');
|
|
577
|
-
for (
|
|
578
|
-
const msg = msgs[i];
|
|
577
|
+
for (const [i, msg] of msgs.entries()) {
|
|
579
578
|
if (msg) {
|
|
580
579
|
updateSendMessageAgainCount(ids[i], participant);
|
|
581
580
|
const msgRelayOpts = { messageId: ids[i] };
|
|
@@ -742,15 +741,13 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
742
741
|
if (response && ((_a = msg === null || msg === void 0 ? void 0 : msg.messageStubParameters) === null || _a === void 0 ? void 0 : _a[0]) === Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT) {
|
|
743
742
|
msg.messageStubParameters = [Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT, response];
|
|
744
743
|
}
|
|
745
|
-
if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER) {
|
|
746
|
-
|
|
747
|
-
ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
|
|
748
|
-
}
|
|
744
|
+
if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER && node.attrs.sender_pn) {
|
|
745
|
+
ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
|
|
749
746
|
}
|
|
750
747
|
try {
|
|
751
748
|
await Promise.all([
|
|
752
749
|
processingMutex.mutex(async () => {
|
|
753
|
-
var _a, _b;
|
|
750
|
+
var _a, _b, _c, _d, _e, _f;
|
|
754
751
|
await decrypt();
|
|
755
752
|
// message failed to decrypt
|
|
756
753
|
if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
|
|
@@ -779,6 +776,17 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
779
776
|
if ((_b = msg.key.participant) === null || _b === void 0 ? void 0 : _b.endsWith('@lid')) {
|
|
780
777
|
msg.key.participant = node.attrs.participant_pn || authState.creds.me.id;
|
|
781
778
|
}
|
|
779
|
+
if ((0, WABinary_1.isJidGroup)(msg.key.remoteJid) && ((_f = (_e = (_d = (_c = msg.message) === null || _c === void 0 ? void 0 : _c.extendedTextMessage) === null || _d === void 0 ? void 0 : _d.contextInfo) === null || _e === void 0 ? void 0 : _e.participant) === null || _f === void 0 ? void 0 : _f.endsWith('@lid'))) {
|
|
780
|
+
if (msg.message.extendedTextMessage.contextInfo) {
|
|
781
|
+
const metadata = await groupMetadata(msg.key.remoteJid);
|
|
782
|
+
const sender = msg.message.extendedTextMessage.contextInfo.participant;
|
|
783
|
+
const found = metadata.participants.find(p => p.id === sender);
|
|
784
|
+
msg.message.extendedTextMessage.contextInfo.participant = (found === null || found === void 0 ? void 0 : found.jid) || sender;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
if (!(0, WABinary_1.isJidGroup)(msg.key.remoteJid) && (0, WABinary_1.isLidUser)(msg.key.remoteJid)) {
|
|
788
|
+
msg.key.remoteJid = node.attrs.sender_pn || node.attrs.peer_recipient_pn;
|
|
789
|
+
}
|
|
782
790
|
let participant = msg.key.participant;
|
|
783
791
|
if (category === 'peer') { // special peer message
|
|
784
792
|
type = 'peer_msg';
|
|
@@ -22,7 +22,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
22
22
|
}>;
|
|
23
23
|
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
24
24
|
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
25
|
-
sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo
|
|
25
|
+
sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
|
|
26
26
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
27
27
|
duration: string;
|
|
28
28
|
}>;
|
|
@@ -120,7 +120,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
120
120
|
}[], star: boolean) => Promise<void>;
|
|
121
121
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
122
122
|
type: "md";
|
|
123
|
-
ws:
|
|
123
|
+
ws: import("./Client").WebSocketClient;
|
|
124
124
|
ev: import("../Types").BaileysEventEmitter & {
|
|
125
125
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
126
126
|
buffer(): void;
|