rixleys 1.0.0
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 +21 -0
- package/README.MD +2969 -0
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +5479 -0
- package/WAProto/index.js +97692 -0
- package/WAProto/p.html +1 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.js +120 -0
- package/lib/Defaults/rixleys-version.json +3 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.js +29 -0
- package/lib/Signal/core/.eslintrc.json +31 -0
- package/lib/Signal/core/CODE_OF_CONDUCT.md +102 -0
- package/lib/Signal/core/LICENSE +621 -0
- package/lib/Signal/core/README.md +64 -0
- package/lib/Signal/core/SECURITY.md +78 -0
- package/lib/Signal/core/generate-proto.sh +1 -0
- package/lib/Signal/core/index.d.ts +55 -0
- package/lib/Signal/core/index.js +10 -0
- package/lib/Signal/core/protos/WhisperTextProtocol.proto +28 -0
- package/lib/Signal/core/src/.eslintrc.json +31 -0
- package/lib/Signal/core/src/WhisperTextProtocol.js +933 -0
- package/lib/Signal/core/src/base_key_type.js +7 -0
- package/lib/Signal/core/src/chain_type.js +6 -0
- package/lib/Signal/core/src/crypto.d.ts +19 -0
- package/lib/Signal/core/src/crypto.js +98 -0
- package/lib/Signal/core/src/curve.d.ts +22 -0
- package/lib/Signal/core/src/curve.js +142 -0
- package/lib/Signal/core/src/errors.js +33 -0
- package/lib/Signal/core/src/keyhelper.js +45 -0
- package/lib/Signal/core/src/numeric_fingerprint.js +72 -0
- package/lib/Signal/core/src/protobufs.js +10 -0
- package/lib/Signal/core/src/protocol_address.js +40 -0
- package/lib/Signal/core/src/queue_job.js +69 -0
- package/lib/Signal/core/src/session_builder.js +164 -0
- package/lib/Signal/core/src/session_cipher.js +336 -0
- package/lib/Signal/core/src/session_record.js +316 -0
- package/lib/Signal/libsignal.js +184 -0
- package/lib/Socket/Client/index.js +18 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +72 -0
- package/lib/Socket/business.js +260 -0
- package/lib/Socket/chats.js +997 -0
- package/lib/Socket/groups.js +418 -0
- package/lib/Socket/index.js +238 -0
- package/lib/Socket/messages-recv.js +1106 -0
- package/lib/Socket/messages-send.js +882 -0
- package/lib/Socket/newsletter.js +250 -0
- package/lib/Socket/socket.js +646 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.js +8 -0
- package/lib/Store/make-in-memory-store.js +439 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.js +7 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +42 -0
- package/lib/Utils/auth-utils.js +199 -0
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/business.js +234 -0
- package/lib/Utils/chat-utils.js +730 -0
- package/lib/Utils/crypto.js +193 -0
- package/lib/Utils/decode-wa-message.js +217 -0
- package/lib/Utils/event-buffer.js +518 -0
- package/lib/Utils/generics.js +467 -0
- package/lib/Utils/history.js +94 -0
- package/lib/Utils/index.js +36 -0
- package/lib/Utils/link-preview.js +151 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.js +51 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/message-retry-manager.js +185 -0
- package/lib/Utils/messages-media.js +879 -0
- package/lib/Utils/messages.js +1049 -0
- package/lib/Utils/noise-handler.js +150 -0
- package/lib/Utils/process-message.js +404 -0
- package/lib/Utils/rixleys-event-stream.js +63 -0
- package/lib/Utils/serializer.js +238 -0
- package/lib/Utils/signal.js +153 -0
- package/lib/Utils/use-multi-file-auth-state.js +124 -0
- package/lib/Utils/validate-connection.js +229 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.js +265 -0
- package/lib/WABinary/encode.js +250 -0
- package/lib/WABinary/generic-utils.js +110 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.js +85 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.js +89 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.js +54 -0
- package/package.json +113 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeSignedDeviceIdentity = exports.configureSuccessfulPairing = exports.generateRegistrationNode = exports.generateLoginNode = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const WAProto_1 = require("../../WAProto");
|
|
7
|
+
const Defaults_1 = require("../Defaults");
|
|
8
|
+
const WABinary_1 = require("../WABinary");
|
|
9
|
+
const crypto_2 = require("./crypto");
|
|
10
|
+
const generics_1 = require("./generics");
|
|
11
|
+
const signal_1 = require("./signal");
|
|
12
|
+
|
|
13
|
+
const getUserAgent = (config) => {
|
|
14
|
+
return {
|
|
15
|
+
appVersion: {
|
|
16
|
+
primary: config.version[0],
|
|
17
|
+
secondary: config.version[1],
|
|
18
|
+
tertiary: config.version[2],
|
|
19
|
+
},
|
|
20
|
+
platform: WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB,
|
|
21
|
+
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
22
|
+
osVersion: '0.1',
|
|
23
|
+
device: 'Desktop',
|
|
24
|
+
osBuildNumber: '0.1',
|
|
25
|
+
localeLanguageIso6391: 'en',
|
|
26
|
+
mnc: '000',
|
|
27
|
+
mcc: '000',
|
|
28
|
+
localeCountryIso31661Alpha2: config.countryCode || 'US'
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const PLATFORM_MAP = {
|
|
33
|
+
'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
34
|
+
'Windows': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const getWebInfo = (config) => {
|
|
38
|
+
let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
39
|
+
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]] && config.browser[1] === 'Desktop') {
|
|
40
|
+
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
41
|
+
}
|
|
42
|
+
return { webSubPlatform };
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getClientPayload = (config) => {
|
|
46
|
+
const payload = {
|
|
47
|
+
connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
48
|
+
connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
49
|
+
userAgent: getUserAgent(config),
|
|
50
|
+
};
|
|
51
|
+
payload.webInfo = getWebInfo(config);
|
|
52
|
+
return payload;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const generateLoginNode = (userJid, config) => {
|
|
56
|
+
const { user, device } = (0, WABinary_1.jidDecode)(userJid);
|
|
57
|
+
const payload = {
|
|
58
|
+
...getClientPayload(config),
|
|
59
|
+
passive: true,
|
|
60
|
+
pull: true,
|
|
61
|
+
username: +user,
|
|
62
|
+
device: device,
|
|
63
|
+
lidDbMigrated: false
|
|
64
|
+
};
|
|
65
|
+
return WAProto_1.proto.ClientPayload.fromObject(payload);
|
|
66
|
+
};
|
|
67
|
+
exports.generateLoginNode = generateLoginNode;
|
|
68
|
+
|
|
69
|
+
const getPlatformType = (platform) => {
|
|
70
|
+
const platformType = platform.toUpperCase();
|
|
71
|
+
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.CHROME;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
75
|
+
const appVersionBuf = (0, crypto_1.createHash)('md5')
|
|
76
|
+
.update(config.version.join('.'))
|
|
77
|
+
.digest();
|
|
78
|
+
|
|
79
|
+
const companion = {
|
|
80
|
+
os: config.browser[0],
|
|
81
|
+
platformType: getPlatformType(config.browser[1]),
|
|
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
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish();
|
|
108
|
+
|
|
109
|
+
const registerPayload = {
|
|
110
|
+
...getClientPayload(config),
|
|
111
|
+
passive: false,
|
|
112
|
+
pull: false,
|
|
113
|
+
devicePairingData: {
|
|
114
|
+
buildHash: appVersionBuf,
|
|
115
|
+
deviceProps: companionProto,
|
|
116
|
+
eRegid: (0, generics_1.encodeBigEndian)(registrationId),
|
|
117
|
+
eKeytype: Defaults_1.KEY_BUNDLE_TYPE,
|
|
118
|
+
eIdent: signedIdentityKey.public,
|
|
119
|
+
eSkeyId: (0, generics_1.encodeBigEndian)(signedPreKey.keyId, 3),
|
|
120
|
+
eSkeyVal: signedPreKey.keyPair.public,
|
|
121
|
+
eSkeySig: signedPreKey.signature,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
return WAProto_1.proto.ClientPayload.fromObject(registerPayload);
|
|
125
|
+
};
|
|
126
|
+
exports.generateRegistrationNode = generateRegistrationNode;
|
|
127
|
+
|
|
128
|
+
const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
129
|
+
const msgId = stanza.attrs.id;
|
|
130
|
+
const pairSuccessNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-success');
|
|
131
|
+
const deviceIdentityNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device-identity');
|
|
132
|
+
const platformNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'platform');
|
|
133
|
+
const deviceNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device');
|
|
134
|
+
const businessNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'biz');
|
|
135
|
+
|
|
136
|
+
if (!deviceIdentityNode || !deviceNode) {
|
|
137
|
+
throw new boom_1.Boom('Missing device-identity or device in pair success node', { data: stanza });
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const bizName = businessNode?.attrs.name;
|
|
141
|
+
const jid = deviceNode.attrs.jid;
|
|
142
|
+
const lid = deviceNode.attrs.lid;
|
|
143
|
+
|
|
144
|
+
const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
145
|
+
|
|
146
|
+
let hmacPrefix = Buffer.from([]);
|
|
147
|
+
if (accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED) {
|
|
148
|
+
hmacPrefix = Buffer.from([0x06, 0x05]);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const advSign = (0, crypto_2.hmacSign)(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
152
|
+
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
153
|
+
throw new boom_1.Boom('Invalid account signature');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details);
|
|
157
|
+
const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
|
|
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
|
+
|
|
166
|
+
if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
167
|
+
throw new boom_1.Boom('Failed to verify account signature');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const deviceMsg = Buffer.concat([
|
|
171
|
+
Buffer.from([0x06, 0x01]),
|
|
172
|
+
deviceDetails,
|
|
173
|
+
signedIdentityKey.public,
|
|
174
|
+
accountSignatureKey
|
|
175
|
+
]);
|
|
176
|
+
account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
177
|
+
|
|
178
|
+
const identity = (0, signal_1.createSignalIdentity)(jid, accountSignatureKey);
|
|
179
|
+
const accountEnc = (0, exports.encodeSignedDeviceIdentity)(account, false);
|
|
180
|
+
|
|
181
|
+
const reply = {
|
|
182
|
+
tag: 'iq',
|
|
183
|
+
attrs: {
|
|
184
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
185
|
+
type: 'result',
|
|
186
|
+
id: msgId,
|
|
187
|
+
},
|
|
188
|
+
content: [
|
|
189
|
+
{
|
|
190
|
+
tag: 'pair-device-sign',
|
|
191
|
+
attrs: {},
|
|
192
|
+
content: [
|
|
193
|
+
{
|
|
194
|
+
tag: 'device-identity',
|
|
195
|
+
attrs: { 'key-index': deviceIdentity.keyIndex.toString() },
|
|
196
|
+
content: accountEnc
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const authUpdate = {
|
|
204
|
+
account,
|
|
205
|
+
me: { id: jid, name: bizName, lid },
|
|
206
|
+
signalIdentities: [
|
|
207
|
+
...(signalIdentities || []),
|
|
208
|
+
identity
|
|
209
|
+
],
|
|
210
|
+
platform: platformNode?.attrs.name
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
creds: authUpdate,
|
|
215
|
+
reply
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
exports.configureSuccessfulPairing = configureSuccessfulPairing;
|
|
219
|
+
|
|
220
|
+
const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
221
|
+
account = { ...account };
|
|
222
|
+
if (!includeSignatureKey || !account.accountSignatureKey?.length) {
|
|
223
|
+
account.accountSignatureKey = null;
|
|
224
|
+
}
|
|
225
|
+
return WAProto_1.proto.ADVSignedDeviceIdentity
|
|
226
|
+
.encode(account)
|
|
227
|
+
.finish();
|
|
228
|
+
};
|
|
229
|
+
exports.encodeSignedDeviceIdentity = encodeSignedDeviceIdentity;
|