@rexxhayanasi/elaina-baileys 1.1.0-rc.3 → 1.1.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +55 -14
- package/WAProto/WAProto.proto +1013 -169
- package/lib/Socket/Rhandler.js +158 -240
- package/lib/Socket/chats.js +52 -2
- package/lib/Socket/messages-send.js +12 -10
- package/lib/Socket/socket.js +34 -15
- package/package.json +1 -1
package/lib/Socket/chats.js
CHANGED
|
@@ -24,7 +24,14 @@ const SyncState = {
|
|
|
24
24
|
Online: 'online'
|
|
25
25
|
};
|
|
26
26
|
const makeChatsSocket = (config) => {
|
|
27
|
-
const
|
|
27
|
+
const {
|
|
28
|
+
logger,
|
|
29
|
+
markOnlineOnConnect,
|
|
30
|
+
fireInitQueries,
|
|
31
|
+
appStateMacVerification,
|
|
32
|
+
shouldIgnoreJid,
|
|
33
|
+
shouldSyncHistoryMessage,
|
|
34
|
+
relayMessage, } = config;
|
|
28
35
|
const sock = (0, usync_1.makeUSyncSocket)(config);
|
|
29
36
|
const { ev, ws, authState, generateMessageTag, sendNode, query, signalRepository, onUnexpectedError, } = sock;
|
|
30
37
|
let privacySettings;
|
|
@@ -857,6 +864,47 @@ const getBusinessProfile = async (jid) => {
|
|
|
857
864
|
const removeContact = (jid) => {
|
|
858
865
|
return chatModify({ contact: null }, jid);
|
|
859
866
|
};
|
|
867
|
+
|
|
868
|
+
const addLabelMember = async (jid, label, timestamp = Date.now()) => {
|
|
869
|
+
try {
|
|
870
|
+
return await relayMessage(
|
|
871
|
+
jid,
|
|
872
|
+
{
|
|
873
|
+
protocolMessage: {
|
|
874
|
+
type: 30,
|
|
875
|
+
memberLabel: {
|
|
876
|
+
label,
|
|
877
|
+
labelTimestamp: timestamp
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
},
|
|
881
|
+
{}
|
|
882
|
+
)
|
|
883
|
+
} catch (e) {
|
|
884
|
+
logger.error('Failed addLabelMember: ' + e)
|
|
885
|
+
throw e
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
const removeLabelMember = async (jid) => {
|
|
890
|
+
try {
|
|
891
|
+
return await relayMessage(
|
|
892
|
+
jid,
|
|
893
|
+
{
|
|
894
|
+
protocolMessage: {
|
|
895
|
+
type: 30,
|
|
896
|
+
memberLabel: {
|
|
897
|
+
label: ''
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
},
|
|
901
|
+
{}
|
|
902
|
+
)
|
|
903
|
+
} catch (e) {
|
|
904
|
+
logger.error('Failed removeLabelMember: ' + e)
|
|
905
|
+
throw e
|
|
906
|
+
}
|
|
907
|
+
}
|
|
860
908
|
const addLabel = (jid, labels) => {
|
|
861
909
|
return chatModify({ addLabel: { ...labels } }, jid);
|
|
862
910
|
};
|
|
@@ -1079,7 +1127,9 @@ const getBusinessProfile = async (jid) => {
|
|
|
1079
1127
|
removeChatLabel,
|
|
1080
1128
|
addMessageLabel,
|
|
1081
1129
|
removeMessageLabel,
|
|
1082
|
-
star
|
|
1130
|
+
star,
|
|
1131
|
+
addLabelMember,
|
|
1132
|
+
removeLabelMember
|
|
1083
1133
|
};
|
|
1084
1134
|
};
|
|
1085
1135
|
exports.makeChatsSocket = makeChatsSocket;
|
|
@@ -780,10 +780,10 @@ const makeMessagesSocket = (config) => {
|
|
|
780
780
|
}
|
|
781
781
|
return albumMsg;
|
|
782
782
|
}
|
|
783
|
-
else if (
|
|
784
|
-
|
|
783
|
+
else if (content.groupStatusMessage) {
|
|
784
|
+
const { quoted } = options;
|
|
785
785
|
return await rexx.handleGroupStory(content, jid, quoted);
|
|
786
|
-
}
|
|
786
|
+
}
|
|
787
787
|
else {
|
|
788
788
|
let mediaHandle;
|
|
789
789
|
const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
|
|
@@ -816,7 +816,7 @@ const makeMessagesSocket = (config) => {
|
|
|
816
816
|
const isPinMsg = 'pin' in content && !!content.pin;
|
|
817
817
|
const isKeepMsg = 'keep' in content && content.keep;
|
|
818
818
|
const isPollMessage = 'poll' in content && !!content.poll;
|
|
819
|
-
const isAiMsg =
|
|
819
|
+
const isAiMsg = content && content.ai === true;
|
|
820
820
|
const additionalAttributes = {};
|
|
821
821
|
const additionalNodes = [];
|
|
822
822
|
// required for delete
|
|
@@ -851,13 +851,15 @@ const makeMessagesSocket = (config) => {
|
|
|
851
851
|
});
|
|
852
852
|
// required to display AI icon on message
|
|
853
853
|
}
|
|
854
|
+
|
|
854
855
|
else if (isAiMsg) {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
856
|
+
msg.messageContextInfo = {
|
|
857
|
+
...(msg.messageContextInfo || {}),
|
|
858
|
+
businessMessageType: 3,
|
|
859
|
+
aiMessageMetadata: {
|
|
860
|
+
isAiMessage: true
|
|
861
|
+
}
|
|
862
|
+
};
|
|
861
863
|
}
|
|
862
864
|
if (mediaHandle) {
|
|
863
865
|
additionalAttributes['media_id'] = mediaHandle;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -40,6 +40,19 @@ const makeSocket = (config) => {
|
|
|
40
40
|
routingInfo: (_b = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _b === void 0 ? void 0 : _b.routingInfo
|
|
41
41
|
});
|
|
42
42
|
const { creds } = authState;
|
|
43
|
+
if (!creds.noiseKey?.public) {
|
|
44
|
+
creds.noiseKey = Utils_1.Curve.generateKeyPair()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!creds.signedIdentityKey?.public) {
|
|
48
|
+
creds.signedIdentityKey = Utils_1.Curve.generateKeyPair()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!creds.advSecretKey) {
|
|
52
|
+
creds.advSecretKey = (0, crypto_1.randomBytes)(32).toString('base64')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
ev.emit('creds.update', creds)
|
|
43
56
|
// add transaction capability
|
|
44
57
|
const keys = (0, Utils_1.addTransactionCapability)(authState.keys, logger, transactionOpts);
|
|
45
58
|
const signalRepository = makeSignalRepository({ creds, keys });
|
|
@@ -53,20 +66,26 @@ const makeSocket = (config) => {
|
|
|
53
66
|
const sendPromise = (0, util_1.promisify)(ws.send);
|
|
54
67
|
/** send a raw buffer */
|
|
55
68
|
const sendRawMessage = async (data) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
if (!ws || ws.isClosed || ws.isClosing || !ws.isOpen) {
|
|
70
|
+
throw new boom_1.Boom('Connection Closed', {
|
|
71
|
+
statusCode: Types_1.DisconnectReason.connectionClosed
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const bytes = noise.encodeFrame(data)
|
|
76
|
+
|
|
77
|
+
await (0, Utils_1.promiseTimeout)(
|
|
78
|
+
connectTimeoutMs,
|
|
79
|
+
async (resolve, reject) => {
|
|
61
80
|
try {
|
|
62
|
-
await sendPromise.call(ws, bytes)
|
|
63
|
-
resolve()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
reject(error);
|
|
81
|
+
await sendPromise.call(ws, bytes)
|
|
82
|
+
resolve()
|
|
83
|
+
} catch (error) {
|
|
84
|
+
reject(error)
|
|
67
85
|
}
|
|
68
|
-
}
|
|
69
|
-
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
};
|
|
70
89
|
/** send a binary node */
|
|
71
90
|
const sendNode = (frame) => {
|
|
72
91
|
if (logger.level === 'trace') {
|
|
@@ -467,12 +486,12 @@ const end = (error) => {
|
|
|
467
486
|
return authState.creds.pairingCode
|
|
468
487
|
}
|
|
469
488
|
async function generatePairingKey() {
|
|
470
|
-
if (!authState
|
|
471
|
-
authState.creds.pairingEphemeralKeyPair =
|
|
489
|
+
if (!authState.creds.pairingEphemeralKeyPair?.public) {
|
|
490
|
+
authState.creds.pairingEphemeralKeyPair = Utils_1.Curve.generateKeyPair()
|
|
472
491
|
ev.emit('creds.update', authState.creds)
|
|
473
492
|
}
|
|
474
493
|
|
|
475
|
-
if (!authState
|
|
494
|
+
if (!authState.creds.pairingCode) {
|
|
476
495
|
throw new Error("Pairing code belum tersedia")
|
|
477
496
|
}
|
|
478
497
|
|