lordceaser-baileys 1.0.15 → 1.0.16
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.js +5 -5
- package/lib/Socket/chats.js +1 -1
- package/lib/Socket/messages-recv.js +3 -3
- package/lib/Socket/messages-send.js +1 -1
- package/lib/Socket/socket.js +2 -2
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/crypto.js +1 -1
- package/lib/Utils/messages.js +2 -3
- package/lib/WAM/encode.js +1 -1
- package/package.json +6 -13
- package/lib/lib/Defaults/index.d.ts +0 -73
- package/lib/lib/Defaults/index.js +0 -135
- package/lib/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/lib/Signal/Group/ciphertext-message.js +0 -16
- package/lib/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/lib/Signal/Group/group-session-builder.js +0 -65
- package/lib/lib/Signal/Group/group_cipher.d.ts +0 -16
- package/lib/lib/Signal/Group/group_cipher.js +0 -83
- package/lib/lib/Signal/Group/index.d.ts +0 -11
- package/lib/lib/Signal/Group/index.js +0 -58
- package/lib/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/lib/Signal/Group/keyhelper.js +0 -56
- package/lib/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/lib/Signal/Group/sender-chain-key.js +0 -30
- package/lib/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/lib/Signal/Group/sender-key-distribution-message.js +0 -67
- package/lib/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/lib/Signal/Group/sender-key-message.js +0 -70
- package/lib/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/lib/Signal/Group/sender-key-name.js +0 -51
- package/lib/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/lib/Signal/Group/sender-key-record.js +0 -45
- package/lib/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/lib/Signal/Group/sender-key-state.js +0 -88
- package/lib/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/lib/Signal/Group/sender-message-key.js +0 -30
- package/lib/lib/Signal/libsignal.d.ts +0 -4
- package/lib/lib/Signal/libsignal.js +0 -470
- package/lib/lib/Signal/lid-mapping.d.ts +0 -22
- package/lib/lib/Signal/lid-mapping.js +0 -284
- package/lib/lib/Socket/Client/index.d.ts +0 -2
- package/lib/lib/Socket/Client/index.js +0 -19
- package/lib/lib/Socket/Client/types.d.ts +0 -15
- package/lib/lib/Socket/Client/types.js +0 -14
- package/lib/lib/Socket/Client/websocket.d.ts +0 -12
- package/lib/lib/Socket/Client/websocket.js +0 -61
- package/lib/lib/Socket/business.d.ts +0 -216
- package/lib/lib/Socket/business.js +0 -382
- package/lib/lib/Socket/chats.d.ts +0 -124
- package/lib/lib/Socket/chats.js +0 -1206
- package/lib/lib/Socket/communities.d.ts +0 -266
- package/lib/lib/Socket/communities.js +0 -439
- package/lib/lib/Socket/groups.d.ts +0 -160
- package/lib/lib/Socket/groups.js +0 -352
- package/lib/lib/Socket/index.d.ts +0 -253
- package/lib/lib/Socket/index.js +0 -14
- package/lib/lib/Socket/messages-recv.d.ts +0 -202
- package/lib/lib/Socket/messages-recv.js +0 -1778
- package/lib/lib/Socket/messages-send.d.ts +0 -198
- package/lib/lib/Socket/messages-send.js +0 -1152
- package/lib/lib/Socket/mex.d.ts +0 -2
- package/lib/lib/Socket/mex.js +0 -46
- package/lib/lib/Socket/newsletter.d.ts +0 -169
- package/lib/lib/Socket/newsletter.js +0 -184
- package/lib/lib/Socket/socket.d.ts +0 -58
- package/lib/lib/Socket/socket.js +0 -974
- package/lib/lib/Types/Auth.d.ts +0 -116
- package/lib/lib/Types/Auth.js +0 -2
- package/lib/lib/Types/Bussines.d.ts +0 -24
- package/lib/lib/Types/Bussines.js +0 -2
- package/lib/lib/Types/Call.d.ts +0 -14
- package/lib/lib/Types/Call.js +0 -2
- package/lib/lib/Types/Chat.d.ts +0 -123
- package/lib/lib/Types/Chat.js +0 -10
- package/lib/lib/Types/Contact.d.ts +0 -25
- package/lib/lib/Types/Contact.js +0 -2
- package/lib/lib/Types/Events.d.ts +0 -255
- package/lib/lib/Types/Events.js +0 -2
- package/lib/lib/Types/GroupMetadata.d.ts +0 -70
- package/lib/lib/Types/GroupMetadata.js +0 -2
- package/lib/lib/Types/Label.d.ts +0 -46
- package/lib/lib/Types/Label.js +0 -27
- package/lib/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/lib/Types/LabelAssociation.js +0 -10
- package/lib/lib/Types/Message.d.ts +0 -319
- package/lib/lib/Types/Message.js +0 -12
- package/lib/lib/Types/Mex.d.ts +0 -140
- package/lib/lib/Types/Mex.js +0 -40
- package/lib/lib/Types/Product.d.ts +0 -78
- package/lib/lib/Types/Product.js +0 -2
- package/lib/lib/Types/Signal.d.ts +0 -86
- package/lib/lib/Types/Signal.js +0 -2
- package/lib/lib/Types/Socket.d.ts +0 -135
- package/lib/lib/Types/Socket.js +0 -2
- package/lib/lib/Types/State.d.ts +0 -96
- package/lib/lib/Types/State.js +0 -57
- package/lib/lib/Types/USync.d.ts +0 -25
- package/lib/lib/Types/USync.js +0 -2
- package/lib/lib/Types/index.d.ts +0 -65
- package/lib/lib/Types/index.js +0 -43
- package/lib/lib/Utils/auth-utils.d.ts +0 -23
- package/lib/lib/Utils/auth-utils.js +0 -312
- package/lib/lib/Utils/browser-utils.d.ts +0 -3
- package/lib/lib/Utils/browser-utils.js +0 -33
- package/lib/lib/Utils/business.d.ts +0 -22
- package/lib/lib/Utils/business.js +0 -241
- package/lib/lib/Utils/chat-utils.d.ts +0 -99
- package/lib/lib/Utils/chat-utils.js +0 -890
- package/lib/lib/Utils/companion-reg-client-utils.d.ts +0 -16
- package/lib/lib/Utils/companion-reg-client-utils.js +0 -40
- package/lib/lib/Utils/crypto.d.ts +0 -36
- package/lib/lib/Utils/crypto.js +0 -169
- package/lib/lib/Utils/decode-wa-message.d.ts +0 -64
- package/lib/lib/Utils/decode-wa-message.js +0 -322
- package/lib/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/lib/Utils/event-buffer.js +0 -629
- package/lib/lib/Utils/generics.d.ts +0 -91
- package/lib/lib/Utils/generics.js +0 -425
- package/lib/lib/Utils/history.d.ts +0 -23
- package/lib/lib/Utils/history.js +0 -141
- package/lib/lib/Utils/identity-change-handler.d.ts +0 -43
- package/lib/lib/Utils/identity-change-handler.js +0 -51
- package/lib/lib/Utils/index.d.ts +0 -21
- package/lib/lib/Utils/index.js +0 -38
- package/lib/lib/Utils/link-preview.d.ts +0 -20
- package/lib/lib/Utils/link-preview.js +0 -121
- package/lib/lib/Utils/logger.d.ts +0 -11
- package/lib/lib/Utils/logger.js +0 -8
- package/lib/lib/Utils/lt-hash.d.ts +0 -6
- package/lib/lib/Utils/lt-hash.js +0 -11
- package/lib/lib/Utils/make-mutex.d.ts +0 -8
- package/lib/lib/Utils/make-mutex.js +0 -38
- package/lib/lib/Utils/message-retry-manager.d.ts +0 -114
- package/lib/lib/Utils/message-retry-manager.js +0 -272
- package/lib/lib/Utils/messages-media.d.ts +0 -131
- package/lib/lib/Utils/messages-media.js +0 -849
- package/lib/lib/Utils/messages.d.ts +0 -86
- package/lib/lib/Utils/messages.js +0 -916
- package/lib/lib/Utils/noise-handler.d.ts +0 -19
- package/lib/lib/Utils/noise-handler.js +0 -205
- package/lib/lib/Utils/offline-node-processor.d.ts +0 -16
- package/lib/lib/Utils/offline-node-processor.js +0 -42
- package/lib/lib/Utils/pre-key-manager.d.ts +0 -27
- package/lib/lib/Utils/pre-key-manager.js +0 -113
- package/lib/lib/Utils/process-message.d.ts +0 -59
- package/lib/lib/Utils/process-message.js +0 -639
- package/lib/lib/Utils/reporting-utils.d.ts +0 -10
- package/lib/lib/Utils/reporting-utils.js +0 -262
- package/lib/lib/Utils/signal.d.ts +0 -46
- package/lib/lib/Utils/signal.js +0 -214
- package/lib/lib/Utils/stanza-ack.d.ts +0 -10
- package/lib/lib/Utils/stanza-ack.js +0 -40
- package/lib/lib/Utils/sync-action-utils.d.ts +0 -18
- package/lib/lib/Utils/sync-action-utils.js +0 -52
- package/lib/lib/Utils/tc-token-utils.d.ts +0 -36
- package/lib/lib/Utils/tc-token-utils.js +0 -174
- package/lib/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
- package/lib/lib/Utils/use-multi-file-auth-state.js +0 -125
- package/lib/lib/Utils/validate-connection.d.ts +0 -10
- package/lib/lib/Utils/validate-connection.js +0 -217
- package/lib/lib/WABinary/constants.d.ts +0 -27
- package/lib/lib/WABinary/constants.js +0 -1304
- package/lib/lib/WABinary/decode.d.ts +0 -6
- package/lib/lib/WABinary/decode.js +0 -301
- package/lib/lib/WABinary/encode.d.ts +0 -2
- package/lib/lib/WABinary/encode.js +0 -257
- package/lib/lib/WABinary/generic-utils.d.ts +0 -13
- package/lib/lib/WABinary/generic-utils.js +0 -125
- package/lib/lib/WABinary/index.d.ts +0 -5
- package/lib/lib/WABinary/index.js +0 -22
- package/lib/lib/WABinary/jid-utils.d.ts +0 -47
- package/lib/lib/WABinary/jid-utils.js +0 -115
- package/lib/lib/WABinary/types.d.ts +0 -18
- package/lib/lib/WABinary/types.js +0 -2
- package/lib/lib/WAM/BinaryInfo.d.ts +0 -8
- package/lib/lib/WAM/BinaryInfo.js +0 -13
- package/lib/lib/WAM/constants.d.ts +0 -39
- package/lib/lib/WAM/constants.js +0 -22856
- package/lib/lib/WAM/encode.d.ts +0 -2
- package/lib/lib/WAM/encode.js +0 -152
- package/lib/lib/WAM/index.d.ts +0 -3
- package/lib/lib/WAM/index.js +0 -20
- package/lib/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -54
- package/lib/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -57
- package/lib/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -30
- package/lib/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -41
- package/lib/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -9
- package/lib/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -27
- package/lib/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -53
- package/lib/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -9
- package/lib/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -32
- package/lib/lib/WAUSync/Protocols/index.d.ts +0 -5
- package/lib/lib/WAUSync/Protocols/index.js +0 -22
- package/lib/lib/WAUSync/USyncQuery.d.ts +0 -29
- package/lib/lib/WAUSync/USyncQuery.js +0 -100
- package/lib/lib/WAUSync/USyncUser.d.ts +0 -16
- package/lib/lib/WAUSync/USyncUser.js +0 -35
- package/lib/lib/WAUSync/index.d.ts +0 -3
- package/lib/lib/WAUSync/index.js +0 -20
- package/lib/lib/index.d.ts +0 -11
- package/lib/lib/index.js +0 -31
package/lib/Defaults/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TimeMs = exports.UPLOAD_TIMEOUT = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.HISTORY_SYNC_PAUSED_TIMEOUT_MS = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.DEFAULT_CACHE_TTLS = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.PLACEHOLDER_MAX_AGE_SECONDS = exports.STATUS_EXPIRY_SECONDS = exports.WA_DEFAULT_EPHEMERAL = exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = exports.WA_ADV_DEVICE_SIG_PREFIX = exports.WA_ADV_ACCOUNT_SIG_PREFIX = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.CALL_AUDIO_PREFIX = exports.CALL_VIDEO_PREFIX = exports.DEFAULT_ORIGIN = exports.UNAUTHORIZED_CODES = void 0;
|
|
7
7
|
// @ts-nocheck
|
|
8
|
-
const index_js_1 = require(
|
|
8
|
+
const index_js_1 = require('../WAProto/index.js');
|
|
9
9
|
const libsignal_1 = require("../Signal/libsignal");
|
|
10
10
|
const browser_utils_1 = require("../Utils/browser-utils");
|
|
11
11
|
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
@@ -56,11 +56,11 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
56
56
|
version: version,
|
|
57
57
|
browser: browser_utils_1.Browsers.macOS('Chrome'),
|
|
58
58
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
59
|
-
connectTimeoutMs:
|
|
60
|
-
keepAliveIntervalMs:
|
|
59
|
+
connectTimeoutMs: 20_000,
|
|
60
|
+
keepAliveIntervalMs: 30_000,
|
|
61
61
|
logger: logger_1.default.child({ class: 'baileys' }),
|
|
62
62
|
emitOwnEvents: true,
|
|
63
|
-
defaultQueryTimeoutMs:
|
|
63
|
+
defaultQueryTimeoutMs: 60_000,
|
|
64
64
|
customUploadHosts: [],
|
|
65
65
|
retryRequestDelayMs: 250,
|
|
66
66
|
maxMsgRetryCount: 5,
|
|
@@ -123,7 +123,7 @@ exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
|
123
123
|
};
|
|
124
124
|
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
|
|
125
125
|
/** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
|
|
126
|
-
exports.HISTORY_SYNC_PAUSED_TIMEOUT_MS =
|
|
126
|
+
exports.HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120_000;
|
|
127
127
|
exports.MIN_PREKEY_COUNT = 5;
|
|
128
128
|
exports.INITIAL_PREKEY_COUNT = 812;
|
|
129
129
|
exports.UPLOAD_TIMEOUT = 30000; // 30 seconds
|
package/lib/Socket/chats.js
CHANGED
|
@@ -1115,7 +1115,7 @@ const makeChatsSocket = (config) => {
|
|
|
1115
1115
|
const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
|
|
1116
1116
|
ev.emit('creds.update', { accountSyncCounter });
|
|
1117
1117
|
}
|
|
1118
|
-
},
|
|
1118
|
+
}, 20_000);
|
|
1119
1119
|
});
|
|
1120
1120
|
// When an app state sync key arrives (myAppStateKeyId is set) and there are
|
|
1121
1121
|
// collections blocked on a missing key, trigger a re-sync for just those collections.
|
|
@@ -90,7 +90,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
90
90
|
logger.debug({ messageKey }, 'PDO message without response after 8 seconds. Phone possibly offline');
|
|
91
91
|
await placeholderResendCache.del(messageKey?.id);
|
|
92
92
|
}
|
|
93
|
-
},
|
|
93
|
+
}, 8_000);
|
|
94
94
|
return sendPeerDataOperationMessage(pdoMessage);
|
|
95
95
|
};
|
|
96
96
|
const handleMexNotification = async (node) => {
|
|
@@ -173,7 +173,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
173
173
|
// WA Web defaults to now+60s when the server omits the expiry
|
|
174
174
|
const timeEnforcementEnds = payload.time_enforcement_ends
|
|
175
175
|
? new Date(parseInt(payload.time_enforcement_ends, 10) * 1000)
|
|
176
|
-
: new Date(Date.now() +
|
|
176
|
+
: new Date(Date.now() + 60_000);
|
|
177
177
|
const enforcementType = isValidEnforcementType(payload.enforcement_type)
|
|
178
178
|
? payload.enforcement_type
|
|
179
179
|
: Types_1.ReachoutTimelockEnforcementType.DEFAULT;
|
|
@@ -1257,7 +1257,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1257
1257
|
id: node.attrs.id,
|
|
1258
1258
|
...(msg.key || {})
|
|
1259
1259
|
};
|
|
1260
|
-
msg.participant
|
|
1260
|
+
msg.participant ??= node.attrs.participant;
|
|
1261
1261
|
msg.messageTimestamp = +node.attrs.t;
|
|
1262
1262
|
const fullMsg = index_js_1.proto.WebMessageInfo.fromObject(msg);
|
|
1263
1263
|
await upsertMessage(fullMsg, 'append');
|
|
@@ -1078,7 +1078,7 @@ const makeMessagesSocket = (config) => {
|
|
|
1078
1078
|
getUrlInfo: text => (0, link_preview_1.getUrlInfo)(text, {
|
|
1079
1079
|
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
1080
1080
|
fetchOpts: {
|
|
1081
|
-
timeout:
|
|
1081
|
+
timeout: 3_000,
|
|
1082
1082
|
...(httpRequestOptions || {})
|
|
1083
1083
|
},
|
|
1084
1084
|
logger,
|
package/lib/Socket/socket.js
CHANGED
|
@@ -710,7 +710,7 @@ const makeSocket = (config) => {
|
|
|
710
710
|
const noiseKeyB64 = Buffer.from(creds.noiseKey.public).toString('base64');
|
|
711
711
|
const identityKeyB64 = Buffer.from(creds.signedIdentityKey.public).toString('base64');
|
|
712
712
|
const advB64 = creds.advSecretKey;
|
|
713
|
-
let qrMs = qrTimeout ||
|
|
713
|
+
let qrMs = qrTimeout || 60_000; // time to let a QR live
|
|
714
714
|
const genPairQR = () => {
|
|
715
715
|
if (!ws.isOpen) {
|
|
716
716
|
return;
|
|
@@ -724,7 +724,7 @@ const makeSocket = (config) => {
|
|
|
724
724
|
const qr = (0, Utils_1.buildPairingQRData)(ref, noiseKeyB64, identityKeyB64, advB64, browser);
|
|
725
725
|
ev.emit('connection.update', { qr });
|
|
726
726
|
qrTimer = setTimeout(genPairQR, qrMs);
|
|
727
|
-
qrMs = qrTimeout ||
|
|
727
|
+
qrMs = qrTimeout || 20_000; // shorter subsequent qrs
|
|
728
728
|
};
|
|
729
729
|
genPairQR();
|
|
730
730
|
});
|
package/lib/Utils/business.js
CHANGED
|
@@ -185,7 +185,7 @@ exports.parseProductNode = parseProductNode;
|
|
|
185
185
|
/**
|
|
186
186
|
* Uploads images not already uploaded to WA's servers
|
|
187
187
|
*/
|
|
188
|
-
async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, timeoutMs =
|
|
188
|
+
async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, timeoutMs = 30_000) {
|
|
189
189
|
product = {
|
|
190
190
|
...product,
|
|
191
191
|
images: product.images
|
|
@@ -197,7 +197,7 @@ async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, time
|
|
|
197
197
|
/**
|
|
198
198
|
* Uploads images not already uploaded to WA's servers
|
|
199
199
|
*/
|
|
200
|
-
const uploadingNecessaryImages = async (images, waUploadToServer, timeoutMs =
|
|
200
|
+
const uploadingNecessaryImages = async (images, waUploadToServer, timeoutMs = 30_000) => {
|
|
201
201
|
const results = await Promise.all(images.map(async (img) => {
|
|
202
202
|
if ('url' in img) {
|
|
203
203
|
const url = img.url.toString();
|
package/lib/Utils/crypto.js
CHANGED
|
@@ -49,7 +49,7 @@ exports.derivePairingCodeKey = derivePairingCodeKey;
|
|
|
49
49
|
const crypto_1 = require("crypto");
|
|
50
50
|
const curve = __importStar(require("libsignal/src/curve"));
|
|
51
51
|
const Defaults_1 = require("../Defaults");
|
|
52
|
-
var whatsapp_rust_bridge_1 = require(
|
|
52
|
+
var whatsapp_rust_bridge_1 = (() => { try { return require('whatsapp-rust-bridge'); } catch(e) { return { generateSignalPubKey: () => { throw new Error('rust-bridge not needed'); } }; } })();
|
|
53
53
|
Object.defineProperty(exports, "md5", { enumerable: true, get: function () { return whatsapp_rust_bridge_1.md5; } });
|
|
54
54
|
Object.defineProperty(exports, "hkdf", { enumerable: true, get: function () { return whatsapp_rust_bridge_1.hkdf; } });
|
|
55
55
|
// insure browser & node compatibility
|
package/lib/Utils/messages.js
CHANGED
|
@@ -282,7 +282,6 @@ function hasOptionalProperty(obj, key) {
|
|
|
282
282
|
return typeof obj === 'object' && obj !== null && key in obj && obj[key] !== null;
|
|
283
283
|
}
|
|
284
284
|
const generateWAMessageContent = async (message, options) => {
|
|
285
|
-
var _a, _b;
|
|
286
285
|
let m = {};
|
|
287
286
|
if ((0, exports.hasNonNullishProperty)(message, 'text')) {
|
|
288
287
|
const extContent = { text: message.text };
|
|
@@ -437,8 +436,8 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
437
436
|
m.eventMessage.location = message.event.location;
|
|
438
437
|
}
|
|
439
438
|
else if ((0, exports.hasNonNullishProperty)(message, 'poll')) {
|
|
440
|
-
|
|
441
|
-
|
|
439
|
+
message.poll.selectableCount ||= 0;
|
|
440
|
+
message.poll.toAnnouncementGroup ||= false;
|
|
442
441
|
if (!Array.isArray(message.poll.values)) {
|
|
443
442
|
throw new boom_1.Boom('Invalid poll values', { statusCode: 400 });
|
|
444
443
|
}
|
package/lib/WAM/encode.js
CHANGED
|
@@ -43,7 +43,7 @@ function encodeEvents(binaryInfo) {
|
|
|
43
43
|
const props_ = Object.entries(props);
|
|
44
44
|
let extended = false;
|
|
45
45
|
for (const [, value] of props_) {
|
|
46
|
-
extended
|
|
46
|
+
extended ||= value !== null;
|
|
47
47
|
}
|
|
48
48
|
const eventFlag = extended ? constants_1.FLAG_EVENT : constants_1.FLAG_EVENT | constants_1.FLAG_EXTENDED;
|
|
49
49
|
binaryInfo.buffer.push(serializeData(event.id, -event.weight, eventFlag));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lordceaser-baileys",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "LordCeaser Baileys v1.0.15 -
|
|
3
|
+
"version": "1.0.16",
|
|
4
|
+
"description": "LordCeaser Baileys v1.0.15 - CLEAN FIX, NO payload, NO git, NO rust-bridge, Pterodactyl ready",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"author": "Lord Ceaser",
|
|
@@ -11,19 +11,13 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/Sammyodg123/lordceaser-baileys.git"
|
|
13
13
|
},
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/Sammyodg123/lordceaser-baileys/issues"
|
|
16
|
-
},
|
|
17
14
|
"keywords": [
|
|
18
15
|
"whatsapp",
|
|
19
16
|
"baileys",
|
|
20
17
|
"lordceaser",
|
|
21
|
-
"gstatus",
|
|
22
|
-
"thumbnail",
|
|
23
|
-
"payload",
|
|
24
18
|
"pterodactyl",
|
|
25
19
|
"fixed",
|
|
26
|
-
"
|
|
20
|
+
"clean"
|
|
27
21
|
],
|
|
28
22
|
"engines": {
|
|
29
23
|
"node": ">=18.0.0"
|
|
@@ -35,10 +29,8 @@
|
|
|
35
29
|
"lib/",
|
|
36
30
|
"WAProto/",
|
|
37
31
|
"src/WAProto/",
|
|
38
|
-
"README.md"
|
|
39
|
-
"LICENSE"
|
|
32
|
+
"README.md"
|
|
40
33
|
],
|
|
41
|
-
"scripts": {},
|
|
42
34
|
"dependencies": {
|
|
43
35
|
"@hapi/boom": "^10.0.1",
|
|
44
36
|
"axios": "^1.6.7",
|
|
@@ -49,5 +41,6 @@
|
|
|
49
41
|
"pino": "^8.19.0",
|
|
50
42
|
"qrcode-terminal": "^0.12.0",
|
|
51
43
|
"ws": "^8.14.2"
|
|
52
|
-
}
|
|
44
|
+
},
|
|
45
|
+
"scripts": {}
|
|
53
46
|
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { SocketConfig } from '../Types';
|
|
2
|
-
export declare const UNAUTHORIZED_CODES: number[];
|
|
3
|
-
export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
4
|
-
export declare const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
|
|
5
|
-
export declare const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
|
|
6
|
-
export declare const DEF_CALLBACK_PREFIX = "CB:";
|
|
7
|
-
export declare const DEF_TAG_PREFIX = "TAG:";
|
|
8
|
-
export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
9
|
-
export declare const WA_ADV_ACCOUNT_SIG_PREFIX: Buffer<ArrayBuffer>;
|
|
10
|
-
export declare const WA_ADV_DEVICE_SIG_PREFIX: Buffer<ArrayBuffer>;
|
|
11
|
-
export declare const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: Buffer<ArrayBuffer>;
|
|
12
|
-
export declare const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: Buffer<ArrayBuffer>;
|
|
13
|
-
export declare const WA_DEFAULT_EPHEMERAL: number;
|
|
14
|
-
/** Status messages older than 24 hours are considered expired */
|
|
15
|
-
export declare const STATUS_EXPIRY_SECONDS: number;
|
|
16
|
-
/** WA Web enforces a 14-day maximum age for placeholder resend requests */
|
|
17
|
-
export declare const PLACEHOLDER_MAX_AGE_SECONDS: number;
|
|
18
|
-
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
19
|
-
export declare const DICT_VERSION = 3;
|
|
20
|
-
export declare const KEY_BUNDLE_TYPE: Buffer<ArrayBuffer>;
|
|
21
|
-
export declare const NOISE_WA_HEADER: Buffer<ArrayBuffer>;
|
|
22
|
-
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
23
|
-
export declare const URL_REGEX: RegExp;
|
|
24
|
-
export declare const WA_CERT_DETAILS: {
|
|
25
|
-
SERIAL: number;
|
|
26
|
-
ISSUER: string;
|
|
27
|
-
PUBLIC_KEY: Buffer<ArrayBuffer>;
|
|
28
|
-
};
|
|
29
|
-
export declare const PROCESSABLE_HISTORY_TYPES: any[];
|
|
30
|
-
export declare const DEFAULT_CACHE_TTLS: {
|
|
31
|
-
SIGNAL_STORE: number;
|
|
32
|
-
MSG_RETRY: number;
|
|
33
|
-
CALL_OFFER: number;
|
|
34
|
-
USER_DEVICES: number;
|
|
35
|
-
};
|
|
36
|
-
export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
|
|
37
|
-
export declare const MEDIA_PATH_MAP: {
|
|
38
|
-
[T in MediaType]?: string;
|
|
39
|
-
};
|
|
40
|
-
export declare const MEDIA_HKDF_KEY_MAPPING: {
|
|
41
|
-
audio: string;
|
|
42
|
-
document: string;
|
|
43
|
-
gif: string;
|
|
44
|
-
image: string;
|
|
45
|
-
ppic: string;
|
|
46
|
-
product: string;
|
|
47
|
-
ptt: string;
|
|
48
|
-
sticker: string;
|
|
49
|
-
video: string;
|
|
50
|
-
'thumbnail-document': string;
|
|
51
|
-
'thumbnail-image': string;
|
|
52
|
-
'thumbnail-video': string;
|
|
53
|
-
'thumbnail-link': string;
|
|
54
|
-
'md-msg-hist': string;
|
|
55
|
-
'md-app-state': string;
|
|
56
|
-
'product-catalog-image': string;
|
|
57
|
-
'payment-bg-image': string;
|
|
58
|
-
ptv: string;
|
|
59
|
-
'biz-cover-photo': string;
|
|
60
|
-
};
|
|
61
|
-
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
|
|
62
|
-
export declare const MEDIA_KEYS: MediaType[];
|
|
63
|
-
/** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
|
|
64
|
-
export declare const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120000;
|
|
65
|
-
export declare const MIN_PREKEY_COUNT = 5;
|
|
66
|
-
export declare const INITIAL_PREKEY_COUNT = 812;
|
|
67
|
-
export declare const UPLOAD_TIMEOUT = 30000;
|
|
68
|
-
export declare const TimeMs: {
|
|
69
|
-
Minute: number;
|
|
70
|
-
Hour: number;
|
|
71
|
-
Day: number;
|
|
72
|
-
Week: number;
|
|
73
|
-
};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TimeMs = exports.UPLOAD_TIMEOUT = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.HISTORY_SYNC_PAUSED_TIMEOUT_MS = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.DEFAULT_CACHE_TTLS = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.PLACEHOLDER_MAX_AGE_SECONDS = exports.STATUS_EXPIRY_SECONDS = exports.WA_DEFAULT_EPHEMERAL = exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = exports.WA_ADV_DEVICE_SIG_PREFIX = exports.WA_ADV_ACCOUNT_SIG_PREFIX = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.CALL_AUDIO_PREFIX = exports.CALL_VIDEO_PREFIX = exports.DEFAULT_ORIGIN = exports.UNAUTHORIZED_CODES = void 0;
|
|
7
|
-
// @ts-nocheck
|
|
8
|
-
const index_js_1 = require('../WAProto/index.js');
|
|
9
|
-
const libsignal_1 = require("../Signal/libsignal");
|
|
10
|
-
const browser_utils_1 = require("../Utils/browser-utils");
|
|
11
|
-
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
12
|
-
const version = [2, 3000, 1043857760];
|
|
13
|
-
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
14
|
-
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
15
|
-
exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
|
16
|
-
exports.CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
|
|
17
|
-
exports.DEF_CALLBACK_PREFIX = 'CB:';
|
|
18
|
-
exports.DEF_TAG_PREFIX = 'TAG:';
|
|
19
|
-
exports.PHONE_CONNECTION_CB = 'CB:Pong';
|
|
20
|
-
exports.WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
21
|
-
exports.WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
22
|
-
exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
23
|
-
exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
24
|
-
exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
25
|
-
/** Status messages older than 24 hours are considered expired */
|
|
26
|
-
exports.STATUS_EXPIRY_SECONDS = 24 * 60 * 60;
|
|
27
|
-
/** WA Web enforces a 14-day maximum age for placeholder resend requests */
|
|
28
|
-
exports.PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60;
|
|
29
|
-
exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
|
|
30
|
-
exports.DICT_VERSION = 3;
|
|
31
|
-
exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
32
|
-
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]); // last is "DICT_VERSION"
|
|
33
|
-
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
34
|
-
exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
35
|
-
exports.WA_CERT_DETAILS = {
|
|
36
|
-
SERIAL: 0,
|
|
37
|
-
ISSUER: 'WhatsAppLongTerm1',
|
|
38
|
-
PUBLIC_KEY: Buffer.from('142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b', 'hex')
|
|
39
|
-
};
|
|
40
|
-
exports.PROCESSABLE_HISTORY_TYPES = [
|
|
41
|
-
index_js_1.proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
42
|
-
index_js_1.proto.HistorySync.HistorySyncType.PUSH_NAME,
|
|
43
|
-
index_js_1.proto.HistorySync.HistorySyncType.RECENT,
|
|
44
|
-
index_js_1.proto.HistorySync.HistorySyncType.FULL,
|
|
45
|
-
index_js_1.proto.HistorySync.HistorySyncType.ON_DEMAND,
|
|
46
|
-
index_js_1.proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
|
|
47
|
-
index_js_1.proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3
|
|
48
|
-
];
|
|
49
|
-
exports.DEFAULT_CACHE_TTLS = {
|
|
50
|
-
SIGNAL_STORE: 5 * 60, // 5 minutes
|
|
51
|
-
MSG_RETRY: 60 * 60, // 1 hour
|
|
52
|
-
CALL_OFFER: 5 * 60, // 5 minutes
|
|
53
|
-
USER_DEVICES: 5 * 60 // 5 minutes
|
|
54
|
-
};
|
|
55
|
-
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
56
|
-
version: version,
|
|
57
|
-
browser: browser_utils_1.Browsers.macOS('Chrome'),
|
|
58
|
-
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
59
|
-
connectTimeoutMs: 20_000,
|
|
60
|
-
keepAliveIntervalMs: 30_000,
|
|
61
|
-
logger: logger_1.default.child({ class: 'baileys' }),
|
|
62
|
-
emitOwnEvents: true,
|
|
63
|
-
defaultQueryTimeoutMs: 60_000,
|
|
64
|
-
customUploadHosts: [],
|
|
65
|
-
retryRequestDelayMs: 250,
|
|
66
|
-
maxMsgRetryCount: 5,
|
|
67
|
-
fireInitQueries: true,
|
|
68
|
-
auth: undefined,
|
|
69
|
-
markOnlineOnConnect: true,
|
|
70
|
-
syncFullHistory: true,
|
|
71
|
-
patchMessageBeforeSending: msg => msg,
|
|
72
|
-
shouldSyncHistoryMessage: ({ syncType }) => {
|
|
73
|
-
return syncType !== index_js_1.proto.HistorySync.HistorySyncType.FULL;
|
|
74
|
-
},
|
|
75
|
-
shouldIgnoreJid: () => false,
|
|
76
|
-
linkPreviewImageThumbnailWidth: 192,
|
|
77
|
-
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
78
|
-
generateHighQualityLinkPreview: false,
|
|
79
|
-
enableAutoSessionRecreation: true,
|
|
80
|
-
enableRecentMessageCache: true,
|
|
81
|
-
options: {},
|
|
82
|
-
appStateMacVerification: {
|
|
83
|
-
patch: false,
|
|
84
|
-
snapshot: false
|
|
85
|
-
},
|
|
86
|
-
countryCode: 'US',
|
|
87
|
-
getMessage: async () => undefined,
|
|
88
|
-
cachedGroupMetadata: async () => undefined,
|
|
89
|
-
makeSignalRepository: libsignal_1.makeLibSignalRepository
|
|
90
|
-
};
|
|
91
|
-
exports.MEDIA_PATH_MAP = {
|
|
92
|
-
image: '/mms/image',
|
|
93
|
-
video: '/mms/video',
|
|
94
|
-
document: '/mms/document',
|
|
95
|
-
audio: '/mms/audio',
|
|
96
|
-
sticker: '/mms/image',
|
|
97
|
-
'thumbnail-link': '/mms/image',
|
|
98
|
-
'product-catalog-image': '/product/image',
|
|
99
|
-
'md-app-state': '',
|
|
100
|
-
'md-msg-hist': '/mms/md-app-state',
|
|
101
|
-
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
102
|
-
};
|
|
103
|
-
exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
104
|
-
audio: 'Audio',
|
|
105
|
-
document: 'Document',
|
|
106
|
-
gif: 'Video',
|
|
107
|
-
image: 'Image',
|
|
108
|
-
ppic: '',
|
|
109
|
-
product: 'Image',
|
|
110
|
-
ptt: 'Audio',
|
|
111
|
-
sticker: 'Image',
|
|
112
|
-
video: 'Video',
|
|
113
|
-
'thumbnail-document': 'Document Thumbnail',
|
|
114
|
-
'thumbnail-image': 'Image Thumbnail',
|
|
115
|
-
'thumbnail-video': 'Video Thumbnail',
|
|
116
|
-
'thumbnail-link': 'Link Thumbnail',
|
|
117
|
-
'md-msg-hist': 'History',
|
|
118
|
-
'md-app-state': 'App State',
|
|
119
|
-
'product-catalog-image': '',
|
|
120
|
-
'payment-bg-image': 'Payment Background',
|
|
121
|
-
ptv: 'Video',
|
|
122
|
-
'biz-cover-photo': 'Image'
|
|
123
|
-
};
|
|
124
|
-
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
|
|
125
|
-
/** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
|
|
126
|
-
exports.HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120_000;
|
|
127
|
-
exports.MIN_PREKEY_COUNT = 5;
|
|
128
|
-
exports.INITIAL_PREKEY_COUNT = 812;
|
|
129
|
-
exports.UPLOAD_TIMEOUT = 30000; // 30 seconds
|
|
130
|
-
exports.TimeMs = {
|
|
131
|
-
Minute: 60 * 1000,
|
|
132
|
-
Hour: 60 * 60 * 1000,
|
|
133
|
-
Day: 24 * 60 * 60 * 1000,
|
|
134
|
-
Week: 7 * 24 * 60 * 60 * 1000
|
|
135
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class CiphertextMessage {
|
|
2
|
-
readonly UNSUPPORTED_VERSION: number;
|
|
3
|
-
readonly CURRENT_VERSION: number;
|
|
4
|
-
readonly WHISPER_TYPE: number;
|
|
5
|
-
readonly PREKEY_TYPE: number;
|
|
6
|
-
readonly SENDERKEY_TYPE: number;
|
|
7
|
-
readonly SENDERKEY_DISTRIBUTION_TYPE: number;
|
|
8
|
-
readonly ENCRYPTED_MESSAGE_OVERHEAD: number;
|
|
9
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CiphertextMessage = void 0;
|
|
4
|
-
// @ts-nocheck
|
|
5
|
-
class CiphertextMessage {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.UNSUPPORTED_VERSION = 1;
|
|
8
|
-
this.CURRENT_VERSION = 3;
|
|
9
|
-
this.WHISPER_TYPE = 2;
|
|
10
|
-
this.PREKEY_TYPE = 3;
|
|
11
|
-
this.SENDERKEY_TYPE = 4;
|
|
12
|
-
this.SENDERKEY_DISTRIBUTION_TYPE = 5;
|
|
13
|
-
this.ENCRYPTED_MESSAGE_OVERHEAD = 53;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.CiphertextMessage = CiphertextMessage;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SenderKeyDistributionMessage } from './sender-key-distribution-message';
|
|
2
|
-
import { SenderKeyName } from './sender-key-name';
|
|
3
|
-
import { SenderKeyRecord } from './sender-key-record';
|
|
4
|
-
interface SenderKeyStore {
|
|
5
|
-
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
|
|
6
|
-
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
export declare class GroupSessionBuilder {
|
|
9
|
-
private readonly senderKeyStore;
|
|
10
|
-
constructor(senderKeyStore: SenderKeyStore);
|
|
11
|
-
process(senderKeyName: SenderKeyName, senderKeyDistributionMessage: SenderKeyDistributionMessage): Promise<void>;
|
|
12
|
-
create(senderKeyName: SenderKeyName): Promise<SenderKeyDistributionMessage>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.GroupSessionBuilder = void 0;
|
|
37
|
-
// @ts-nocheck
|
|
38
|
-
const keyhelper = __importStar(require("./keyhelper"));
|
|
39
|
-
const sender_key_distribution_message_1 = require("./sender-key-distribution-message");
|
|
40
|
-
class GroupSessionBuilder {
|
|
41
|
-
constructor(senderKeyStore) {
|
|
42
|
-
this.senderKeyStore = senderKeyStore;
|
|
43
|
-
}
|
|
44
|
-
async process(senderKeyName, senderKeyDistributionMessage) {
|
|
45
|
-
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName);
|
|
46
|
-
senderKeyRecord.addSenderKeyState(senderKeyDistributionMessage.getId(), senderKeyDistributionMessage.getIteration(), senderKeyDistributionMessage.getChainKey(), senderKeyDistributionMessage.getSignatureKey());
|
|
47
|
-
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
|
|
48
|
-
}
|
|
49
|
-
async create(senderKeyName) {
|
|
50
|
-
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName);
|
|
51
|
-
if (senderKeyRecord.isEmpty()) {
|
|
52
|
-
const keyId = keyhelper.generateSenderKeyId();
|
|
53
|
-
const senderKey = keyhelper.generateSenderKey();
|
|
54
|
-
const signingKey = keyhelper.generateSenderSigningKey();
|
|
55
|
-
senderKeyRecord.setSenderKeyState(keyId, 0, senderKey, signingKey);
|
|
56
|
-
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
|
|
57
|
-
}
|
|
58
|
-
const state = senderKeyRecord.getSenderKeyState();
|
|
59
|
-
if (!state) {
|
|
60
|
-
throw new Error('No session state available');
|
|
61
|
-
}
|
|
62
|
-
return new sender_key_distribution_message_1.SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic());
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.GroupSessionBuilder = GroupSessionBuilder;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { SenderKeyName } from './sender-key-name';
|
|
2
|
-
import { SenderKeyRecord } from './sender-key-record';
|
|
3
|
-
export interface SenderKeyStore {
|
|
4
|
-
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
|
|
5
|
-
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export declare class GroupCipher {
|
|
8
|
-
private readonly senderKeyStore;
|
|
9
|
-
private readonly senderKeyName;
|
|
10
|
-
constructor(senderKeyStore: SenderKeyStore, senderKeyName: SenderKeyName);
|
|
11
|
-
encrypt(paddedPlaintext: Uint8Array): Promise<Uint8Array>;
|
|
12
|
-
decrypt(senderKeyMessageBytes: Uint8Array): Promise<Uint8Array>;
|
|
13
|
-
private getSenderKey;
|
|
14
|
-
private getPlainText;
|
|
15
|
-
private getCipherText;
|
|
16
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GroupCipher = void 0;
|
|
4
|
-
// @ts-nocheck
|
|
5
|
-
const crypto_1 = require("libsignal/src/crypto");
|
|
6
|
-
const sender_key_message_1 = require("./sender-key-message");
|
|
7
|
-
class GroupCipher {
|
|
8
|
-
constructor(senderKeyStore, senderKeyName) {
|
|
9
|
-
this.senderKeyStore = senderKeyStore;
|
|
10
|
-
this.senderKeyName = senderKeyName;
|
|
11
|
-
}
|
|
12
|
-
async encrypt(paddedPlaintext) {
|
|
13
|
-
const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
|
|
14
|
-
if (!record) {
|
|
15
|
-
throw new Error('No SenderKeyRecord found for encryption');
|
|
16
|
-
}
|
|
17
|
-
const senderKeyState = record.getSenderKeyState();
|
|
18
|
-
if (!senderKeyState) {
|
|
19
|
-
throw new Error('No session to encrypt message');
|
|
20
|
-
}
|
|
21
|
-
const iteration = senderKeyState.getSenderChainKey().getIteration();
|
|
22
|
-
const senderKey = this.getSenderKey(senderKeyState, iteration === 0 ? 0 : iteration + 1);
|
|
23
|
-
const ciphertext = await this.getCipherText(senderKey.getIv(), senderKey.getCipherKey(), paddedPlaintext);
|
|
24
|
-
const senderKeyMessage = new sender_key_message_1.SenderKeyMessage(senderKeyState.getKeyId(), senderKey.getIteration(), ciphertext, senderKeyState.getSigningKeyPrivate());
|
|
25
|
-
await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
|
|
26
|
-
return senderKeyMessage.serialize();
|
|
27
|
-
}
|
|
28
|
-
async decrypt(senderKeyMessageBytes) {
|
|
29
|
-
const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
|
|
30
|
-
if (!record) {
|
|
31
|
-
throw new Error('No SenderKeyRecord found for decryption');
|
|
32
|
-
}
|
|
33
|
-
const senderKeyMessage = new sender_key_message_1.SenderKeyMessage(null, null, null, null, senderKeyMessageBytes);
|
|
34
|
-
const senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId());
|
|
35
|
-
if (!senderKeyState) {
|
|
36
|
-
throw new Error('No session found to decrypt message');
|
|
37
|
-
}
|
|
38
|
-
senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic());
|
|
39
|
-
const senderKey = this.getSenderKey(senderKeyState, senderKeyMessage.getIteration());
|
|
40
|
-
const plaintext = await this.getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText());
|
|
41
|
-
await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
|
|
42
|
-
return plaintext;
|
|
43
|
-
}
|
|
44
|
-
getSenderKey(senderKeyState, iteration) {
|
|
45
|
-
let senderChainKey = senderKeyState.getSenderChainKey();
|
|
46
|
-
if (senderChainKey.getIteration() > iteration) {
|
|
47
|
-
if (senderKeyState.hasSenderMessageKey(iteration)) {
|
|
48
|
-
const messageKey = senderKeyState.removeSenderMessageKey(iteration);
|
|
49
|
-
if (!messageKey) {
|
|
50
|
-
throw new Error('No sender message key found for iteration');
|
|
51
|
-
}
|
|
52
|
-
return messageKey;
|
|
53
|
-
}
|
|
54
|
-
throw new Error(`Received message with old counter: ${senderChainKey.getIteration()}, ${iteration}`);
|
|
55
|
-
}
|
|
56
|
-
if (iteration - senderChainKey.getIteration() > 2000) {
|
|
57
|
-
throw new Error('Over 2000 messages into the future!');
|
|
58
|
-
}
|
|
59
|
-
while (senderChainKey.getIteration() < iteration) {
|
|
60
|
-
senderKeyState.addSenderMessageKey(senderChainKey.getSenderMessageKey());
|
|
61
|
-
senderChainKey = senderChainKey.getNext();
|
|
62
|
-
}
|
|
63
|
-
senderKeyState.setSenderChainKey(senderChainKey.getNext());
|
|
64
|
-
return senderChainKey.getSenderMessageKey();
|
|
65
|
-
}
|
|
66
|
-
async getPlainText(iv, key, ciphertext) {
|
|
67
|
-
try {
|
|
68
|
-
return (0, crypto_1.decrypt)(key, ciphertext, iv);
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
throw new Error('InvalidMessageException');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async getCipherText(iv, key, plaintext) {
|
|
75
|
-
try {
|
|
76
|
-
return (0, crypto_1.encrypt)(key, plaintext, iv);
|
|
77
|
-
}
|
|
78
|
-
catch (e) {
|
|
79
|
-
throw new Error('InvalidMessageException');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.GroupCipher = GroupCipher;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { GroupSessionBuilder } from './group-session-builder';
|
|
2
|
-
export { SenderKeyDistributionMessage } from './sender-key-distribution-message';
|
|
3
|
-
export { SenderKeyRecord } from './sender-key-record';
|
|
4
|
-
export { SenderKeyName } from './sender-key-name';
|
|
5
|
-
export { GroupCipher } from './group_cipher';
|
|
6
|
-
export { SenderKeyState } from './sender-key-state';
|
|
7
|
-
export { SenderKeyMessage } from './sender-key-message';
|
|
8
|
-
export { SenderMessageKey } from './sender-message-key';
|
|
9
|
-
export { SenderChainKey } from './sender-chain-key';
|
|
10
|
-
export { CiphertextMessage } from './ciphertext-message';
|
|
11
|
-
export * as keyhelper from './keyhelper';
|