@ryuhan/baileys 1.0.1 → 1.0.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/LICENSE +1 -1
- package/{README.md → README.MD} +16 -30
- package/lib/Defaults/index.js +47 -35
- package/lib/Defaults/ryuhan-version.json +3 -0
- package/lib/Socket/chats.js +131 -87
- package/lib/Socket/messages-recv.js +1 -1
- package/lib/Socket/socket.js +1 -1
- package/lib/Store/make-in-memory-store.js +1 -1
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/event-buffer.js +2 -2
- package/lib/Utils/generics.js +36 -10
- package/lib/Utils/index.js +3 -1
- package/lib/Utils/message-retry-manager.js +128 -0
- package/lib/Utils/{baileys-event-stream.js → ryuhan-event-stream.js} +1 -1
- package/lib/Utils/use-multi-file-auth-state.js +0 -2
- package/lib/Utils/validate-connection.js +77 -21
- package/lib/index.js +30 -2
- package/package.json +11 -10
- package/WAProto/index.d.ts +0 -55057
- package/WAProto/index.ts.ts +0 -53473
- package/WAProto/p.html +0 -1
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/index.d.ts +0 -51
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -3
- 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 -172
- package/lib/Socket/chats.d.ts +0 -82
- package/lib/Socket/groups.d.ts +0 -124
- package/lib/Socket/index.d.ts +0 -172
- package/lib/Socket/messages-recv.d.ts +0 -161
- package/lib/Socket/messages-send.d.ts +0 -151
- package/lib/Socket/newsletter.d.ts +0 -136
- package/lib/Socket/socket.d.ts +0 -43
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Store/index.d.ts +0 -2
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -103
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -109
- package/lib/Types/Contact.d.ts +0 -23
- package/lib/Types/Events.d.ts +0 -199
- package/lib/Types/GroupMetadata.d.ts +0 -64
- package/lib/Types/Label.d.ts +0 -35
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/Message.d.ts +0 -400
- package/lib/Types/Newsletter.d.ts +0 -79
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/Socket.d.ts +0 -119
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Types/index.d.ts +0 -64
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/chat-utils.d.ts +0 -70
- package/lib/Utils/crypto.d.ts +0 -40
- package/lib/Utils/decode-wa-message.d.ts +0 -35
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/generics.d.ts +0 -89
- package/lib/Utils/history.d.ts +0 -19
- package/lib/Utils/index.d.ts +0 -17
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -11
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/messages-media.d.ts +0 -120
- package/lib/Utils/messages.d.ts +0 -80
- package/lib/Utils/noise-handler.d.ts +0 -19
- package/lib/Utils/process-message.d.ts +0 -42
- package/lib/Utils/signal.d.ts +0 -33
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
- package/lib/Utils/validate-connection.d.ts +0 -10
- package/lib/WABinary/constants.d.ts +0 -27
- package/lib/WABinary/decode.d.ts +0 -6
- package/lib/WABinary/encode.d.ts +0 -2
- package/lib/WABinary/generic-utils.d.ts +0 -14
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -37
- package/lib/WABinary/jid-utils.js.bak +0 -83
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -8
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -2
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/USyncQuery.d.ts +0 -28
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -16
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageRetryManager = void 0;
|
|
4
|
+
|
|
5
|
+
const lru_cache_1 = require("lru-cache");
|
|
6
|
+
|
|
7
|
+
const RECENT_MESSAGES_SIZE = 512;
|
|
8
|
+
|
|
9
|
+
const RECREATE_SESSION_TIMEOUT = 60 * 60 * 1000;
|
|
10
|
+
|
|
11
|
+
const PHONE_REQUEST_DELAY = 3000;
|
|
12
|
+
|
|
13
|
+
class MessageRetryManager {
|
|
14
|
+
constructor(logger, maxMsgRetryCount) {
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
this.maxMsgRetryCount = maxMsgRetryCount;
|
|
17
|
+
this._recentMessagesMap = new lru_cache_1.LRUCache({
|
|
18
|
+
max: RECENT_MESSAGES_SIZE
|
|
19
|
+
});
|
|
20
|
+
this._sessionRecreateHistory = new lru_cache_1.LRUCache({
|
|
21
|
+
ttl: RECREATE_SESSION_TIMEOUT * 2,
|
|
22
|
+
ttlAutopurge: true
|
|
23
|
+
});
|
|
24
|
+
this._retryCounters = new lru_cache_1.LRUCache({
|
|
25
|
+
ttl: 15 * 60 * 1000,
|
|
26
|
+
ttlAutopurge: true,
|
|
27
|
+
updateAgeOnGet: true
|
|
28
|
+
});
|
|
29
|
+
this._pendingPhoneRequests = {};
|
|
30
|
+
this.statistics = {
|
|
31
|
+
totalRetries: 0,
|
|
32
|
+
successfulRetries: 0,
|
|
33
|
+
failedRetries: 0,
|
|
34
|
+
mediaRetries: 0,
|
|
35
|
+
sessionRecreations: 0,
|
|
36
|
+
phoneRequests: 0
|
|
37
|
+
};
|
|
38
|
+
this.maxMsgRetryCount = maxMsgRetryCount;
|
|
39
|
+
}
|
|
40
|
+
addRecentMessage(to, id, message) {
|
|
41
|
+
const key = { to, id };
|
|
42
|
+
const keyStr = this._keyToString(key);
|
|
43
|
+
this._recentMessagesMap.set(keyStr, {
|
|
44
|
+
message,
|
|
45
|
+
timestamp: Date.now()
|
|
46
|
+
});
|
|
47
|
+
this.logger.debug(`Added message to retry cache: ${to}/${id}`);
|
|
48
|
+
}
|
|
49
|
+
getRecentMessage(to, id) {
|
|
50
|
+
const key = { to, id };
|
|
51
|
+
const keyStr = this._keyToString(key);
|
|
52
|
+
return this._recentMessagesMap.get(keyStr);
|
|
53
|
+
}
|
|
54
|
+
shouldRecreateSession(jid, retryCount, hasSession) {
|
|
55
|
+
if (!hasSession) {
|
|
56
|
+
this._sessionRecreateHistory.set(jid, Date.now());
|
|
57
|
+
this.statistics.sessionRecreations++;
|
|
58
|
+
return {
|
|
59
|
+
reason: "we don't have a Signal session with them",
|
|
60
|
+
recreate: true
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (retryCount < 2) {
|
|
64
|
+
return { reason: '', recreate: false };
|
|
65
|
+
}
|
|
66
|
+
const now = Date.now();
|
|
67
|
+
const prevTime = this._sessionRecreateHistory.get(jid);
|
|
68
|
+
if (!prevTime || now - prevTime > RECREATE_SESSION_TIMEOUT) {
|
|
69
|
+
this._sessionRecreateHistory.set(jid, now);
|
|
70
|
+
this.statistics.sessionRecreations++;
|
|
71
|
+
return {
|
|
72
|
+
reason: 'retry count > 1 and over an hour since last recreation',
|
|
73
|
+
recreate: true
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return { reason: '', recreate: false };
|
|
77
|
+
}
|
|
78
|
+
incrementRetryCount(messageId) {
|
|
79
|
+
this._retryCounters.set(messageId, (this._retryCounters.get(messageId) || 0) + 1);
|
|
80
|
+
this.statistics.totalRetries++;
|
|
81
|
+
return this._retryCounters.get(messageId);
|
|
82
|
+
}
|
|
83
|
+
getRetryCount(messageId) {
|
|
84
|
+
return this._retryCounters.get(messageId) || 0;
|
|
85
|
+
}
|
|
86
|
+
hasExceededMaxRetries(messageId) {
|
|
87
|
+
return this.getRetryCount(messageId) >= this.maxMsgRetryCount;
|
|
88
|
+
}
|
|
89
|
+
markRetrySuccess(messageId) {
|
|
90
|
+
this.statistics.successfulRetries++;
|
|
91
|
+
this._retryCounters.delete(messageId);
|
|
92
|
+
this._cancelPendingPhoneRequest(messageId);
|
|
93
|
+
}
|
|
94
|
+
markRetryFailed(messageId) {
|
|
95
|
+
this.statistics.failedRetries++;
|
|
96
|
+
this._retryCounters.delete(messageId);
|
|
97
|
+
}
|
|
98
|
+
schedulePhoneRequest(messageId, callback, delay = PHONE_REQUEST_DELAY) {
|
|
99
|
+
this._cancelPendingPhoneRequest(messageId);
|
|
100
|
+
this._pendingPhoneRequests[messageId] = setTimeout(() => {
|
|
101
|
+
delete this._pendingPhoneRequests[messageId];
|
|
102
|
+
this.statistics.phoneRequests++;
|
|
103
|
+
callback();
|
|
104
|
+
}, delay);
|
|
105
|
+
this.logger.debug(`Scheduled phone request for message ${messageId} with ${delay}ms delay`);
|
|
106
|
+
}
|
|
107
|
+
cancelPendingPhoneRequest(messageId) {
|
|
108
|
+
const timeout = this._pendingPhoneRequests[messageId];
|
|
109
|
+
if (timeout) {
|
|
110
|
+
clearTimeout(timeout);
|
|
111
|
+
delete this._pendingPhoneRequests[messageId];
|
|
112
|
+
this.logger.debug(`Cancelled pending phone request for message ${messageId}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_keyToString(key) {
|
|
116
|
+
return `${key.to}:${key.id}`;
|
|
117
|
+
}
|
|
118
|
+
_cancelPendingPhoneRequest(messageId) {
|
|
119
|
+
const timeout = this._pendingPhoneRequests[messageId];
|
|
120
|
+
if (timeout) {
|
|
121
|
+
clearTimeout(timeout);
|
|
122
|
+
delete this._pendingPhoneRequests[messageId];
|
|
123
|
+
this.logger.debug(`Cancelled pending phone request for message ${messageId}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
exports.MessageRetryManager = MessageRetryManager;
|
|
@@ -11,7 +11,7 @@ const readline_1 = require("readline");
|
|
|
11
11
|
const generics_1 = require("./generics");
|
|
12
12
|
const make_mutex_1 = require("./make-mutex");
|
|
13
13
|
/**
|
|
14
|
-
* Captures events from a
|
|
14
|
+
* Captures events from a ryuhan event emitter & stores them in a file
|
|
15
15
|
* @param ev The event emitter to read events from
|
|
16
16
|
* @param filename File to save to
|
|
17
17
|
*/
|
|
@@ -8,8 +8,6 @@ const WAProto_1 = require("../../WAProto");
|
|
|
8
8
|
const auth_utils_1 = require("./auth-utils");
|
|
9
9
|
const generics_1 = require("./generics");
|
|
10
10
|
// We need to lock files due to the fact that we are using async functions to read and write files
|
|
11
|
-
// https://github.com/WhiskeySockets/Baileys/issues/794
|
|
12
|
-
// https://github.com/nodejs/node/issues/26338
|
|
13
11
|
// Use a Map to store mutexes for each file path
|
|
14
12
|
const fileLocks = new Map();
|
|
15
13
|
// Get or create a mutex for a specific file path
|
|
@@ -9,6 +9,7 @@ const WABinary_1 = require("../WABinary");
|
|
|
9
9
|
const crypto_2 = require("./crypto");
|
|
10
10
|
const generics_1 = require("./generics");
|
|
11
11
|
const signal_1 = require("./signal");
|
|
12
|
+
|
|
12
13
|
const getUserAgent = (config) => {
|
|
13
14
|
return {
|
|
14
15
|
appVersion: {
|
|
@@ -22,20 +23,25 @@ const getUserAgent = (config) => {
|
|
|
22
23
|
device: 'Desktop',
|
|
23
24
|
osBuildNumber: '0.1',
|
|
24
25
|
localeLanguageIso6391: 'en',
|
|
25
|
-
|
|
26
|
+
mnc: '000',
|
|
27
|
+
mcc: '000',
|
|
28
|
+
localeCountryIso31661Alpha2: config.countryCode || 'US'
|
|
26
29
|
};
|
|
27
30
|
};
|
|
31
|
+
|
|
28
32
|
const PLATFORM_MAP = {
|
|
29
33
|
'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
30
34
|
'Windows': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
31
35
|
};
|
|
36
|
+
|
|
32
37
|
const getWebInfo = (config) => {
|
|
33
38
|
let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
34
|
-
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
|
|
39
|
+
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]] && config.browser[1] === 'Desktop') {
|
|
35
40
|
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
36
41
|
}
|
|
37
42
|
return { webSubPlatform };
|
|
38
43
|
};
|
|
44
|
+
|
|
39
45
|
const getClientPayload = (config) => {
|
|
40
46
|
const payload = {
|
|
41
47
|
connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
@@ -45,34 +51,61 @@ const getClientPayload = (config) => {
|
|
|
45
51
|
payload.webInfo = getWebInfo(config);
|
|
46
52
|
return payload;
|
|
47
53
|
};
|
|
54
|
+
|
|
48
55
|
const generateLoginNode = (userJid, config) => {
|
|
49
56
|
const { user, device } = (0, WABinary_1.jidDecode)(userJid);
|
|
50
57
|
const payload = {
|
|
51
58
|
...getClientPayload(config),
|
|
52
|
-
passive:
|
|
59
|
+
passive: true,
|
|
53
60
|
pull: true,
|
|
54
61
|
username: +user,
|
|
55
62
|
device: device,
|
|
63
|
+
lidDbMigrated: false
|
|
56
64
|
};
|
|
57
65
|
return WAProto_1.proto.ClientPayload.fromObject(payload);
|
|
58
66
|
};
|
|
59
67
|
exports.generateLoginNode = generateLoginNode;
|
|
68
|
+
|
|
60
69
|
const getPlatformType = (platform) => {
|
|
61
70
|
const platformType = platform.toUpperCase();
|
|
62
|
-
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.
|
|
71
|
+
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.CHROME;
|
|
63
72
|
};
|
|
73
|
+
|
|
64
74
|
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
65
|
-
// the app version needs to be md5 hashed
|
|
66
|
-
// and passed in
|
|
67
75
|
const appVersionBuf = (0, crypto_1.createHash)('md5')
|
|
68
|
-
.update(config.version.join('.'))
|
|
76
|
+
.update(config.version.join('.'))
|
|
69
77
|
.digest();
|
|
78
|
+
|
|
70
79
|
const companion = {
|
|
71
80
|
os: config.browser[0],
|
|
72
81
|
platformType: getPlatformType(config.browser[1]),
|
|
73
82
|
requireFullSync: config.syncFullHistory,
|
|
83
|
+
historySyncConfig: {
|
|
84
|
+
storageQuotaMb: 10240,
|
|
85
|
+
inlineInitialPayloadInE2EeMsg: true,
|
|
86
|
+
recentSyncDaysLimit: undefined,
|
|
87
|
+
supportCallLogHistory: false,
|
|
88
|
+
supportBotUserAgentChatHistory: true,
|
|
89
|
+
supportCagReactionsAndPolls: true,
|
|
90
|
+
supportBizHostedMsg: true,
|
|
91
|
+
supportRecentSyncChunkMessageCountTuning: true,
|
|
92
|
+
supportHostedGroupMsg: true,
|
|
93
|
+
supportFbidBotChatHistory: true,
|
|
94
|
+
supportAddOnHistorySyncMigration: undefined,
|
|
95
|
+
supportMessageAssociation: true,
|
|
96
|
+
supportGroupHistory: false,
|
|
97
|
+
onDemandReady: undefined,
|
|
98
|
+
supportGuestChat: undefined
|
|
99
|
+
},
|
|
100
|
+
version: {
|
|
101
|
+
primary: 10,
|
|
102
|
+
secondary: 15,
|
|
103
|
+
tertiary: 7
|
|
104
|
+
}
|
|
74
105
|
};
|
|
106
|
+
|
|
75
107
|
const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish();
|
|
108
|
+
|
|
76
109
|
const registerPayload = {
|
|
77
110
|
...getClientPayload(config),
|
|
78
111
|
passive: false,
|
|
@@ -91,6 +124,7 @@ const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentity
|
|
|
91
124
|
return WAProto_1.proto.ClientPayload.fromObject(registerPayload);
|
|
92
125
|
};
|
|
93
126
|
exports.generateRegistrationNode = generateRegistrationNode;
|
|
127
|
+
|
|
94
128
|
const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
95
129
|
const msgId = stanza.attrs.id;
|
|
96
130
|
const pairSuccessNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-success');
|
|
@@ -98,30 +132,52 @@ const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, s
|
|
|
98
132
|
const platformNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'platform');
|
|
99
133
|
const deviceNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device');
|
|
100
134
|
const businessNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'biz');
|
|
135
|
+
|
|
101
136
|
if (!deviceIdentityNode || !deviceNode) {
|
|
102
137
|
throw new boom_1.Boom('Missing device-identity or device in pair success node', { data: stanza });
|
|
103
138
|
}
|
|
104
|
-
|
|
139
|
+
|
|
140
|
+
const bizName = businessNode?.attrs.name;
|
|
105
141
|
const jid = deviceNode.attrs.jid;
|
|
142
|
+
const lid = deviceNode.attrs.lid;
|
|
143
|
+
|
|
106
144
|
const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
107
|
-
|
|
108
|
-
|
|
145
|
+
|
|
146
|
+
let hmacPrefix = Buffer.from([]);
|
|
147
|
+
if (accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED) {
|
|
148
|
+
hmacPrefix = Buffer.from([0x06, 0x05]);
|
|
149
|
+
}
|
|
150
|
+
|
|
109
151
|
const advSign = (0, crypto_2.hmacSign)(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
110
152
|
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
111
153
|
throw new boom_1.Boom('Invalid account signature');
|
|
112
154
|
}
|
|
155
|
+
|
|
113
156
|
const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details);
|
|
114
157
|
const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
|
|
115
|
-
|
|
158
|
+
|
|
159
|
+
const deviceIdentity = WAProto_1.proto.ADVDeviceIdentity.decode(deviceDetails);
|
|
160
|
+
|
|
161
|
+
const accountSignaturePrefix = deviceIdentity.deviceType === WAProto_1.proto.ADVEncryptionType.HOSTED
|
|
162
|
+
? Buffer.from([0x06, 0x05])
|
|
163
|
+
: Buffer.from([0x06, 0x00]);
|
|
164
|
+
const accountMsg = Buffer.concat([accountSignaturePrefix, deviceDetails, signedIdentityKey.public]);
|
|
165
|
+
|
|
116
166
|
if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
117
167
|
throw new boom_1.Boom('Failed to verify account signature');
|
|
118
168
|
}
|
|
119
|
-
|
|
120
|
-
const deviceMsg = Buffer.concat([
|
|
169
|
+
|
|
170
|
+
const deviceMsg = Buffer.concat([
|
|
171
|
+
Buffer.from([0x06, 0x01]),
|
|
172
|
+
deviceDetails,
|
|
173
|
+
signedIdentityKey.public,
|
|
174
|
+
accountSignatureKey
|
|
175
|
+
]);
|
|
121
176
|
account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
177
|
+
|
|
122
178
|
const identity = (0, signal_1.createSignalIdentity)(jid, accountSignatureKey);
|
|
123
179
|
const accountEnc = (0, exports.encodeSignedDeviceIdentity)(account, false);
|
|
124
|
-
|
|
180
|
+
|
|
125
181
|
const reply = {
|
|
126
182
|
tag: 'iq',
|
|
127
183
|
attrs: {
|
|
@@ -143,31 +199,31 @@ const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, s
|
|
|
143
199
|
}
|
|
144
200
|
]
|
|
145
201
|
};
|
|
202
|
+
|
|
146
203
|
const authUpdate = {
|
|
147
204
|
account,
|
|
148
|
-
me: { id: jid, name: bizName },
|
|
205
|
+
me: { id: jid, name: bizName, lid },
|
|
149
206
|
signalIdentities: [
|
|
150
207
|
...(signalIdentities || []),
|
|
151
208
|
identity
|
|
152
209
|
],
|
|
153
|
-
platform: platformNode
|
|
210
|
+
platform: platformNode?.attrs.name
|
|
154
211
|
};
|
|
212
|
+
|
|
155
213
|
return {
|
|
156
214
|
creds: authUpdate,
|
|
157
215
|
reply
|
|
158
216
|
};
|
|
159
217
|
};
|
|
160
218
|
exports.configureSuccessfulPairing = configureSuccessfulPairing;
|
|
219
|
+
|
|
161
220
|
const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
162
|
-
var _a;
|
|
163
221
|
account = { ...account };
|
|
164
|
-
|
|
165
|
-
// or if we are including the signature key but it is empty
|
|
166
|
-
if (!includeSignatureKey || !((_a = account.accountSignatureKey) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
222
|
+
if (!includeSignatureKey || !account.accountSignatureKey?.length) {
|
|
167
223
|
account.accountSignatureKey = null;
|
|
168
224
|
}
|
|
169
225
|
return WAProto_1.proto.ADVSignedDeviceIdentity
|
|
170
226
|
.encode(account)
|
|
171
227
|
.finish();
|
|
172
228
|
};
|
|
173
|
-
exports.encodeSignedDeviceIdentity = encodeSignedDeviceIdentity;
|
|
229
|
+
exports.encodeSignedDeviceIdentity = encodeSignedDeviceIdentity;
|
package/lib/index.js
CHANGED
|
@@ -4,10 +4,38 @@ const chalk = require("chalk");
|
|
|
4
4
|
const gradient = require("gradient-string");
|
|
5
5
|
|
|
6
6
|
console.log();
|
|
7
|
+
|
|
8
|
+
const rimuru =
|
|
9
|
+
chalk.bold.blue("Ri") +
|
|
10
|
+
chalk.bold.cyan("mu") +
|
|
11
|
+
chalk.bold.magenta("ru");
|
|
12
|
+
|
|
13
|
+
console.log(chalk.bold("╔══════════════════════════════╗"));
|
|
14
|
+
console.log(chalk.bold("║ ") + rimuru + chalk.bold(" ║"));
|
|
15
|
+
console.log(chalk.bold("╚══════════════════════════════╝"));
|
|
16
|
+
|
|
17
|
+
console.log();
|
|
18
|
+
|
|
19
|
+
const devWatermark = gradient(["cyan", "magenta"])(
|
|
20
|
+
" Github: github.com/ryuhandev "
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
console.log(
|
|
24
|
+
chalk.bold(
|
|
25
|
+
chalk.bgBlack("╭────────────────────────────────────────╮")
|
|
26
|
+
)
|
|
27
|
+
);
|
|
7
28
|
console.log(
|
|
8
|
-
chalk.bold
|
|
29
|
+
chalk.bold(
|
|
30
|
+
chalk.bgBlack("│") + devWatermark + chalk.bold(chalk.bgBlack("│"))
|
|
31
|
+
)
|
|
9
32
|
);
|
|
10
|
-
console.log(
|
|
33
|
+
console.log(
|
|
34
|
+
chalk.bold(
|
|
35
|
+
chalk.bgBlack("╰────────────────────────────────────────╯")
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
|
|
11
39
|
console.log();
|
|
12
40
|
|
|
13
41
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
package/package.json
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryuhan/baileys",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Rimuru Baileys",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"baileys",
|
|
7
|
-
"ryuhan",
|
|
8
7
|
"whatsapp",
|
|
9
8
|
"whatsapp-api",
|
|
10
9
|
"whatsapp-web",
|
|
11
10
|
"whatsapp-bot",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
11
|
+
"tensura",
|
|
12
|
+
"rimuru",
|
|
13
|
+
"multi-device",
|
|
14
|
+
"ryuhan"
|
|
14
15
|
],
|
|
15
|
-
"homepage": "https://
|
|
16
|
+
"homepage": "https://www.npmjs.com/package/@ryuhan/baileys",
|
|
16
17
|
"repository": {
|
|
17
18
|
"type": "git",
|
|
18
19
|
"url": "https://github.com/ryuhandev/rimuru-baileys.git"
|
|
19
20
|
},
|
|
20
21
|
"license": "MIT",
|
|
21
|
-
"author": "ryuhan",
|
|
22
|
+
"author": "ryuhan <ryuhandev@users.noreply.github.com>",
|
|
22
23
|
"main": "lib/index.js",
|
|
23
24
|
"types": "lib/index.d.ts",
|
|
24
25
|
"files": [
|
|
@@ -37,8 +38,8 @@
|
|
|
37
38
|
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
|
38
39
|
"lint": "eslint src --ext .js,.ts,.jsx,.tsx",
|
|
39
40
|
"lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
|
|
40
|
-
"prepack": "echo 'Ryuhan
|
|
41
|
-
"prepare": "echo 'Ryuhan
|
|
41
|
+
"prepack": "echo 'Tensura Interactive WhatsApp Library by Ryuhan'",
|
|
42
|
+
"prepare": "echo 'Tensura Interactive Library by Ryuhan'",
|
|
42
43
|
"preinstall": "node ./engine-requirements.js",
|
|
43
44
|
"release": "release-it",
|
|
44
45
|
"test": "jest"
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"cache-manager": "^5.7.6",
|
|
55
56
|
"cheerio": "^1.0.0-rc.10",
|
|
56
57
|
"libphonenumber-js": "^1.10.20",
|
|
57
|
-
"libsignal": "github:
|
|
58
|
+
"libsignal": "github:ryuhandev/libsignal-node",
|
|
58
59
|
"lodash": "^4.17.21",
|
|
59
60
|
"music-metadata": "^7.12.3",
|
|
60
61
|
"pino": "^9.6",
|