@badzz88/baileys 8.5.6 → 8.5.7
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 +2 -2
- package/WAProto/WAProto.proto +75 -1256
- package/WAProto/fix-imports.js +79 -69
- package/WAProto/index.d.ts +71491 -15254
- package/WAProto/index.js +126432 -19810
- package/engine-requirements.js +4 -3
- package/lib/Defaults/index.js +187 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +92 -0
- package/lib/Signal/Group/group_cipher.js +89 -0
- package/lib/Signal/Group/index.js +136 -0
- package/lib/Signal/Group/keyhelper.js +73 -0
- package/lib/Signal/Group/sender-chain-key.js +32 -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 +50 -0
- package/lib/Signal/Group/sender-key-record.js +44 -0
- package/lib/Signal/Group/sender-key-state.js +97 -0
- package/lib/Signal/Group/sender-message-key.js +30 -0
- package/lib/Signal/libsignal.js +459 -0
- package/lib/Signal/lid-mapping.js +260 -0
- package/lib/Socket/Client/index.js +30 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +62 -0
- package/lib/Socket/aigroups.js +240 -0
- package/lib/Socket/business.js +422 -0
- package/lib/Socket/chats.js +1816 -0
- package/lib/Socket/communities.js +549 -0
- package/lib/Socket/graphql.js +656 -0
- package/lib/Socket/groups.js +764 -0
- package/lib/Socket/index.js +39 -0
- package/lib/Socket/interactive-handler.js +522 -0
- package/lib/Socket/interop.js +549 -0
- package/{src → lib}/Socket/luxu.js +120 -82
- package/lib/Socket/managed-account.js +183 -0
- package/lib/Socket/messages-recv.js +2442 -0
- package/lib/Socket/messages-send.js +1853 -0
- package/lib/Socket/mex.js +60 -0
- package/lib/Socket/newsletter.js +818 -0
- package/lib/Socket/privacy.js +449 -0
- package/lib/Socket/registration.js +427 -0
- package/lib/Socket/socket.js +1092 -0
- package/lib/Socket/text-router.js +83 -0
- package/lib/Socket/username.js +243 -0
- package/lib/Store/index.js +36 -0
- package/{src → lib}/Store/keyed-db.js +11 -21
- package/lib/Store/make-cache-manager-store.js +90 -0
- package/lib/Store/make-in-memory-store.js +604 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.js +29 -0
- package/lib/Types/Auth.js +38 -0
- package/lib/Types/Bussines.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 +95 -0
- package/lib/Types/Mex.js +112 -0
- package/lib/Types/Newsletter.js +121 -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 +70 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +55 -0
- package/lib/Utils/auth-utils.js +306 -0
- package/lib/Utils/browser-utils.js +114 -0
- package/lib/Utils/business.js +247 -0
- package/lib/Utils/chat-utils.js +1208 -0
- package/lib/Utils/command-loader.d.ts +31 -0
- package/lib/Utils/command-loader.js +100 -0
- package/lib/Utils/companion-reg-client-utils.js +42 -0
- package/lib/Utils/consumer-application.js +107 -0
- package/lib/Utils/crypto.js +155 -0
- package/lib/Utils/curve25519-js.js +275 -0
- package/lib/Utils/decode-wa-message.js +560 -0
- package/lib/Utils/event-buffer.js +607 -0
- package/lib/Utils/generics.js +563 -0
- package/lib/Utils/group-history.js +60 -0
- package/lib/Utils/history.js +244 -0
- package/lib/Utils/identity-change-handler.js +52 -0
- package/lib/Utils/index.js +57 -0
- package/lib/Utils/jid-display-normalization.js +218 -0
- package/lib/Utils/link-preview.js +143 -0
- package/lib/Utils/logger.js +9 -0
- package/lib/Utils/lt-hash.js +39 -0
- package/lib/Utils/make-mutex.js +36 -0
- package/lib/Utils/message-composer.js +479 -0
- package/lib/Utils/message-retry-manager.js +270 -0
- package/lib/Utils/messages-media.js +896 -0
- package/lib/Utils/messages.js +2904 -0
- package/lib/Utils/meta-ai-msmsg.js +262 -0
- package/lib/Utils/native-bridge.js +82 -0
- package/lib/Utils/noise-handler.js +196 -0
- package/lib/Utils/offline-node-processor.js +42 -0
- package/lib/Utils/pre-key-manager.js +107 -0
- package/lib/Utils/process-message.js +1048 -0
- package/lib/Utils/reporting-utils.js +262 -0
- package/lib/Utils/session-pool.d.ts +16 -0
- package/lib/Utils/session-pool.js +94 -0
- package/lib/Utils/signal.js +224 -0
- package/lib/Utils/stanza-ack.js +40 -0
- package/lib/Utils/sticker.d.ts +17 -0
- package/lib/Utils/sticker.js +145 -0
- package/lib/Utils/sync-action-utils.js +54 -0
- package/lib/Utils/tc-token-utils.js +161 -0
- package/lib/Utils/use-multi-file-auth-state.js +121 -0
- package/lib/Utils/validate-connection.js +219 -0
- package/lib/Utils/view-once-cache.d.ts +9 -0
- package/lib/Utils/view-once-cache.js +79 -0
- package/lib/Utils/voip-rekey.js +22 -0
- package/lib/WABinary/constants.js +1304 -0
- package/lib/WABinary/decode.js +343 -0
- package/{src → lib}/WABinary/encode.js +12 -9
- package/lib/WABinary/generic-utils.js +240 -0
- package/lib/WABinary/index.js +33 -0
- package/lib/WABinary/jid-utils.js +361 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +39486 -0
- package/lib/WAM/encode.js +142 -0
- package/lib/WAM/index.js +31 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +55 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +54 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +59 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +31 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +29 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +27 -0
- package/lib/WAUSync/Protocols/index.js +39 -0
- package/lib/WAUSync/USyncQuery.js +133 -0
- package/lib/WAUSync/USyncUser.js +50 -0
- package/lib/WAUSync/index.js +31 -0
- package/lib/antiban.js +4637 -0
- package/{src → lib}/index.js +49 -51
- package/package.json +4 -4
- package/src/Defaults/index.js +0 -186
- package/src/Signal/Group/ciphertext-message.js +0 -15
- package/src/Signal/Group/group-session-builder.js +0 -86
- package/src/Signal/Group/group_cipher.js +0 -82
- package/src/Signal/Group/index.js +0 -140
- package/src/Signal/Group/keyhelper.js +0 -77
- package/src/Signal/Group/sender-chain-key.js +0 -29
- package/src/Signal/Group/sender-key-distribution-message.js +0 -66
- package/src/Signal/Group/sender-key-message.js +0 -69
- package/src/Signal/Group/sender-key-name.js +0 -51
- package/src/Signal/Group/sender-key-record.js +0 -44
- package/src/Signal/Group/sender-key-state.js +0 -87
- package/src/Signal/Group/sender-message-key.js +0 -29
- package/src/Signal/libsignal.js +0 -455
- package/src/Signal/lid-mapping.js +0 -273
- package/src/Socket/Client/index.js +0 -31
- package/src/Socket/Client/types.js +0 -13
- package/src/Socket/Client/websocket.js +0 -61
- package/src/Socket/aigroups.js +0 -221
- package/src/Socket/business.js +0 -411
- package/src/Socket/chats.js +0 -1449
- package/src/Socket/communities.js +0 -463
- package/src/Socket/graphql.js +0 -523
- package/src/Socket/groups.js +0 -516
- package/src/Socket/index.js +0 -31
- package/src/Socket/interactive-handler.js +0 -527
- package/src/Socket/interop.js +0 -339
- package/src/Socket/managed-account.js +0 -98
- package/src/Socket/messages-recv.js +0 -2685
- package/src/Socket/messages-send.js +0 -2047
- package/src/Socket/mex.js +0 -57
- package/src/Socket/newsletter.js +0 -455
- package/src/Socket/privacy.js +0 -125
- package/src/Socket/registration.js +0 -236
- package/src/Socket/socket.js +0 -983
- package/src/Socket/text-router.js +0 -65
- package/src/Socket/username.js +0 -130
- package/src/Store/index.js +0 -33
- package/src/Store/make-cache-manager-store.js +0 -84
- package/src/Store/make-in-memory-store.js +0 -551
- package/src/Store/make-ordered-dictionary.js +0 -81
- package/src/Store/object-repository.js +0 -26
- package/src/Types/Auth.js +0 -31
- package/src/Types/Bussines.js +0 -2
- package/src/Types/Call.js +0 -2
- package/src/Types/Chat.js +0 -4
- package/src/Types/Contact.js +0 -2
- package/src/Types/Events.js +0 -2
- package/src/Types/GroupMetadata.js +0 -2
- package/src/Types/Label.js +0 -26
- package/src/Types/LabelAssociation.js +0 -8
- package/src/Types/Message.js +0 -93
- package/src/Types/Mex.js +0 -112
- package/src/Types/Newsletter.js +0 -109
- package/src/Types/Product.js +0 -2
- package/src/Types/Signal.js +0 -2
- package/src/Types/Socket.js +0 -2
- package/src/Types/State.js +0 -62
- package/src/Types/USync.js +0 -2
- package/src/Types/index.js +0 -56
- package/src/Utils/auth-utils.js +0 -254
- package/src/Utils/browser-utils.js +0 -112
- package/src/Utils/business.js +0 -240
- package/src/Utils/chat-utils.js +0 -1230
- package/src/Utils/command-loader.d.ts +0 -27
- package/src/Utils/command-loader.js +0 -89
- package/src/Utils/companion-reg-client-utils.js +0 -40
- package/src/Utils/consumer-application.js +0 -105
- package/src/Utils/crypto.js +0 -118
- package/src/Utils/curve25519-js.js +0 -242
- package/src/Utils/decode-wa-message.js +0 -529
- package/src/Utils/event-buffer.js +0 -580
- package/src/Utils/generics.js +0 -483
- package/src/Utils/group-history.js +0 -44
- package/src/Utils/history.js +0 -232
- package/src/Utils/identity-change-handler.js +0 -52
- package/src/Utils/index.js +0 -58
- package/src/Utils/jid-display-normalization.js +0 -195
- package/src/Utils/link-preview.js +0 -135
- package/src/Utils/logger.js +0 -8
- package/src/Utils/lt-hash.js +0 -25
- package/src/Utils/make-mutex.js +0 -36
- package/src/Utils/message-composer.js +0 -471
- package/src/Utils/message-retry-manager.js +0 -217
- package/src/Utils/messages-media.js +0 -843
- package/src/Utils/messages.js +0 -2817
- package/src/Utils/meta-ai-msmsg.js +0 -222
- package/src/Utils/native-bridge.js +0 -68
- package/src/Utils/noise-handler.js +0 -169
- package/src/Utils/offline-node-processor.js +0 -34
- package/src/Utils/pre-key-manager.js +0 -90
- package/src/Utils/process-message.js +0 -950
- package/src/Utils/reporting-utils.js +0 -261
- package/src/Utils/session-pool.d.ts +0 -14
- package/src/Utils/session-pool.js +0 -70
- package/src/Utils/signal.js +0 -217
- package/src/Utils/stanza-ack.js +0 -30
- package/src/Utils/sticker.d.ts +0 -13
- package/src/Utils/sticker.js +0 -123
- package/src/Utils/sync-action-utils.js +0 -45
- package/src/Utils/tc-token-utils.js +0 -158
- package/src/Utils/use-multi-file-auth-state.js +0 -111
- package/src/Utils/validate-connection.js +0 -209
- package/src/Utils/view-once-cache.d.ts +0 -12
- package/src/Utils/view-once-cache.js +0 -63
- package/src/Utils/voip-rekey.js +0 -22
- package/src/WABinary/constants.js +0 -1304
- package/src/WABinary/decode.js +0 -342
- package/src/WABinary/generic-utils.js +0 -238
- package/src/WABinary/index.js +0 -34
- package/src/WABinary/jid-utils.js +0 -351
- package/src/WABinary/types.js +0 -2
- package/src/WAM/BinaryInfo.js +0 -13
- package/src/WAM/constants.js +0 -39484
- package/src/WAM/encode.js +0 -149
- package/src/WAM/index.js +0 -32
- package/src/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -53
- package/src/WAUSync/Protocols/USyncBusinessProtocol.js +0 -44
- package/src/WAUSync/Protocols/USyncContactProtocol.js +0 -55
- package/src/WAUSync/Protocols/USyncDeviceProtocol.js +0 -55
- package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -31
- package/src/WAUSync/Protocols/USyncFeatureProtocol.js +0 -54
- package/src/WAUSync/Protocols/USyncLIDProtocol.js +0 -32
- package/src/WAUSync/Protocols/USyncNewsletterProtocol.js +0 -473
- package/src/WAUSync/Protocols/USyncPictureProtocol.js +0 -34
- package/src/WAUSync/Protocols/USyncSidelistProtocol.js +0 -29
- package/src/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
- package/src/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -38
- package/src/WAUSync/Protocols/USyncUsernameProtocol.js +0 -28
- package/src/WAUSync/Protocols/index.js +0 -40
- package/src/WAUSync/USyncQuery.js +0 -126
- package/src/WAUSync/USyncUser.js +0 -50
- package/src/WAUSync/index.js +0 -32
- package/src/antiban.js +0 -4152
- /package/{src → lib}/Defaults/phonenumber-mcc.json +0 -0
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.getMessageReportingToken = exports.shouldIncludeReportingToken = void 0;
|
|
4
|
-
const Crypto_1 = require('./crypto');
|
|
5
|
-
const crypto_2 = require('./crypto');
|
|
6
|
-
const reportingFields = [
|
|
7
|
-
{ f: 1 },
|
|
8
|
-
{
|
|
9
|
-
f: 3,
|
|
10
|
-
s: [{ f: 2 }, { f: 3 }, { f: 8 }, { f: 11 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 25 }]
|
|
11
|
-
},
|
|
12
|
-
{ f: 4, s: [{ f: 1 }, { f: 16 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
|
|
13
|
-
{ f: 5, s: [{ f: 3 }, { f: 4 }, { f: 5 }, { f: 16 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
|
|
14
|
-
{ f: 6, s: [{ f: 1 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 30 }] },
|
|
15
|
-
{ f: 7, s: [{ f: 2 }, { f: 7 }, { f: 10 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 20 }] },
|
|
16
|
-
{ f: 8, s: [{ f: 2 }, { f: 7 }, { f: 9 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 21 }] },
|
|
17
|
-
{ f: 9, s: [{ f: 2 }, { f: 6 }, { f: 7 }, { f: 13 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 20 }] },
|
|
18
|
-
{ f: 12, s: [{ f: 1 }, { f: 2 }, { f: 14, m: true }, { f: 15 }] },
|
|
19
|
-
{ f: 18, s: [{ f: 6 }, { f: 16 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
|
|
20
|
-
{ f: 26, s: [{ f: 4 }, { f: 5 }, { f: 8 }, { f: 13 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
|
|
21
|
-
{ f: 28, s: [{ f: 1 }, { f: 2 }, { f: 4 }, { f: 5 }, { f: 6 }, { f: 7, s: [{ f: 21 }, { f: 22 }] }] },
|
|
22
|
-
{ f: 37, s: [{ f: 1, m: true }] },
|
|
23
|
-
{
|
|
24
|
-
f: 49,
|
|
25
|
-
s: [
|
|
26
|
-
{ f: 2 },
|
|
27
|
-
{ f: 3, s: [{ f: 1 }, { f: 2 }] },
|
|
28
|
-
{ f: 5, s: [{ f: 21 }, { f: 22 }] },
|
|
29
|
-
{ f: 8, s: [{ f: 1 }, { f: 2 }] }
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
|
-
{ f: 53, s: [{ f: 1, m: true }] },
|
|
33
|
-
{ f: 55, s: [{ f: 1, m: true }] },
|
|
34
|
-
{ f: 58, s: [{ f: 1, m: true }] },
|
|
35
|
-
{ f: 59, s: [{ f: 1, m: true }] },
|
|
36
|
-
{
|
|
37
|
-
f: 60,
|
|
38
|
-
s: [
|
|
39
|
-
{ f: 2 },
|
|
40
|
-
{ f: 3, s: [{ f: 1 }, { f: 2 }] },
|
|
41
|
-
{ f: 5, s: [{ f: 21 }, { f: 22 }] },
|
|
42
|
-
{ f: 8, s: [{ f: 1 }, { f: 2 }] }
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
f: 64,
|
|
47
|
-
s: [
|
|
48
|
-
{ f: 2 },
|
|
49
|
-
{ f: 3, s: [{ f: 1 }, { f: 2 }] },
|
|
50
|
-
{ f: 5, s: [{ f: 21 }, { f: 22 }] },
|
|
51
|
-
{ f: 8, s: [{ f: 1 }, { f: 2 }] }
|
|
52
|
-
]
|
|
53
|
-
},
|
|
54
|
-
{ f: 66, s: [{ f: 2 }, { f: 6 }, { f: 7 }, { f: 13 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 20 }] },
|
|
55
|
-
{ f: 74, s: [{ f: 1, m: true }] },
|
|
56
|
-
{ f: 87, s: [{ f: 1, m: true }] },
|
|
57
|
-
{ f: 88, s: [{ f: 1 }, { f: 2, s: [{ f: 1 }] }, { f: 3, s: [{ f: 21 }, { f: 22 }] }] },
|
|
58
|
-
{ f: 92, s: [{ f: 1, m: true }] },
|
|
59
|
-
{ f: 93, s: [{ f: 1, m: true }] },
|
|
60
|
-
{ f: 94, s: [{ f: 1, m: true }] }
|
|
61
|
-
];
|
|
62
|
-
const compileReportingFields = fields => {
|
|
63
|
-
const map = new Map();
|
|
64
|
-
for (const f of fields) {
|
|
65
|
-
map.set(f.f, {
|
|
66
|
-
m: f.m,
|
|
67
|
-
children: f.s ? compileReportingFields(f.s) : undefined
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return map;
|
|
71
|
-
};
|
|
72
|
-
const compiledReportingFields = compileReportingFields(reportingFields);
|
|
73
|
-
const EMPTY_MAP = new Map();
|
|
74
|
-
const ENC_SECRET_REPORT_TOKEN = 'Report Token';
|
|
75
|
-
const WIRE = {
|
|
76
|
-
VARINT: 0,
|
|
77
|
-
FIXED64: 1,
|
|
78
|
-
BYTES: 2,
|
|
79
|
-
FIXED32: 5
|
|
80
|
-
};
|
|
81
|
-
const shouldIncludeReportingToken = message => !message.reactionMessage &&
|
|
82
|
-
!message.encReactionMessage &&
|
|
83
|
-
!message.encEventResponseMessage &&
|
|
84
|
-
!message.pollUpdateMessage;
|
|
85
|
-
exports.shouldIncludeReportingToken = shouldIncludeReportingToken;
|
|
86
|
-
const generateMsgSecretKey = (modificationType, origMsgId, origMsgSender, modificationSender, origMsgSecret) => {
|
|
87
|
-
const useCaseSecret = Buffer.concat([
|
|
88
|
-
Buffer.from(origMsgId, 'utf8'),
|
|
89
|
-
Buffer.from(origMsgSender, 'utf8'),
|
|
90
|
-
Buffer.from(modificationSender, 'utf8'),
|
|
91
|
-
Buffer.from(modificationType, 'utf8')
|
|
92
|
-
]);
|
|
93
|
-
return (0, crypto_2.hkdf)(origMsgSecret, 32, { info: useCaseSecret.toString('latin1') });
|
|
94
|
-
};
|
|
95
|
-
const extractReportingTokenContent = (data, cfg) => {
|
|
96
|
-
const out = [];
|
|
97
|
-
let i = 0;
|
|
98
|
-
while (i < data.length) {
|
|
99
|
-
const tag = decodeVarint(data, i);
|
|
100
|
-
if (!tag.ok) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
const fieldNum = tag.value >> 3;
|
|
104
|
-
const wireType = tag.value & 0x7;
|
|
105
|
-
const fieldStart = i;
|
|
106
|
-
i += tag.bytes;
|
|
107
|
-
const fieldCfg = cfg.get(fieldNum);
|
|
108
|
-
const pushSlice = end => {
|
|
109
|
-
if (end > data.length) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
out.push({ num: fieldNum, bytes: data.subarray(fieldStart, end) });
|
|
113
|
-
i = end;
|
|
114
|
-
return true;
|
|
115
|
-
};
|
|
116
|
-
const skip = end => {
|
|
117
|
-
if (end > data.length) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
i = end;
|
|
121
|
-
return true;
|
|
122
|
-
};
|
|
123
|
-
if (wireType === WIRE.VARINT) {
|
|
124
|
-
const v = decodeVarint(data, i);
|
|
125
|
-
if (!v.ok) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
const end = i + v.bytes;
|
|
129
|
-
if (!fieldCfg) {
|
|
130
|
-
if (!skip(end)) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (!pushSlice(end)) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
if (wireType === WIRE.FIXED64) {
|
|
141
|
-
const end = i + 8;
|
|
142
|
-
if (!fieldCfg) {
|
|
143
|
-
if (!skip(end)) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (!pushSlice(end)) {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
if (wireType === WIRE.FIXED32) {
|
|
154
|
-
const end = i + 4;
|
|
155
|
-
if (!fieldCfg) {
|
|
156
|
-
if (!skip(end)) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
if (!pushSlice(end)) {
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
if (wireType === WIRE.BYTES) {
|
|
167
|
-
const len = decodeVarint(data, i);
|
|
168
|
-
if (!len.ok) {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
const valStart = i + len.bytes;
|
|
172
|
-
const valEnd = valStart + len.value;
|
|
173
|
-
if (valEnd > data.length) {
|
|
174
|
-
return null;
|
|
175
|
-
}
|
|
176
|
-
if (!fieldCfg) {
|
|
177
|
-
i = valEnd;
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
if (fieldCfg.m || fieldCfg.children) {
|
|
181
|
-
const sub = extractReportingTokenContent(data.subarray(valStart, valEnd), fieldCfg.children ?? EMPTY_MAP);
|
|
182
|
-
if (sub === null) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
if (sub.length > 0) {
|
|
186
|
-
const newTag = encodeVarint(tag.value);
|
|
187
|
-
const newLen = encodeVarint(sub.length);
|
|
188
|
-
out.push({
|
|
189
|
-
num: fieldNum,
|
|
190
|
-
bytes: Buffer.concat([newTag, newLen, sub])
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
i = valEnd;
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
out.push({ num: fieldNum, bytes: data.subarray(fieldStart, valEnd) });
|
|
197
|
-
i = valEnd;
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
if (out.length === 0) {
|
|
203
|
-
return Buffer.alloc(0);
|
|
204
|
-
}
|
|
205
|
-
out.sort((a, b) => a.num - b.num);
|
|
206
|
-
return Buffer.concat(out.map(f => f.bytes));
|
|
207
|
-
};
|
|
208
|
-
const decodeVarint = (buffer, offset) => {
|
|
209
|
-
let value = 0;
|
|
210
|
-
let bytes = 0;
|
|
211
|
-
let shift = 0;
|
|
212
|
-
while (offset + bytes < buffer.length) {
|
|
213
|
-
const current = buffer[offset + bytes];
|
|
214
|
-
value |= (current & 0x7f) << shift;
|
|
215
|
-
bytes++;
|
|
216
|
-
if ((current & 0x80) === 0) {
|
|
217
|
-
return { value, bytes, ok: true };
|
|
218
|
-
}
|
|
219
|
-
shift += 7;
|
|
220
|
-
if (shift > 35) {
|
|
221
|
-
return { value: 0, bytes: 0, ok: false };
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return { value: 0, bytes: 0, ok: false };
|
|
225
|
-
};
|
|
226
|
-
const encodeVarint = value => {
|
|
227
|
-
const parts = [];
|
|
228
|
-
let remaining = value >>> 0;
|
|
229
|
-
while (remaining > 0x7f) {
|
|
230
|
-
parts.push((remaining & 0x7f) | 0x80);
|
|
231
|
-
remaining >>>= 7;
|
|
232
|
-
}
|
|
233
|
-
parts.push(remaining);
|
|
234
|
-
return Buffer.from(parts);
|
|
235
|
-
};
|
|
236
|
-
const getMessageReportingToken = async (msgProtobuf, message, key) => {
|
|
237
|
-
const msgSecret = message.messageContextInfo?.messageSecret;
|
|
238
|
-
if (!msgSecret || !key.id) {
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
const from = key.fromMe ? key.remoteJid : key.participant || key.remoteJid;
|
|
242
|
-
const to = key.fromMe ? key.participant || key.remoteJid : key.remoteJid;
|
|
243
|
-
const reportingSecret = generateMsgSecretKey(ENC_SECRET_REPORT_TOKEN, key.id, from, to, msgSecret);
|
|
244
|
-
const content = extractReportingTokenContent(msgProtobuf, compiledReportingFields);
|
|
245
|
-
if (!content || content.length === 0) {
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
const reportingToken = Buffer.from(Crypto_1.hmacSign(content, reportingSecret)).subarray(0, 16);
|
|
249
|
-
return {
|
|
250
|
-
tag: 'reporting',
|
|
251
|
-
attrs: {},
|
|
252
|
-
content: [
|
|
253
|
-
{
|
|
254
|
-
tag: 'reporting_token',
|
|
255
|
-
attrs: { v: '2' },
|
|
256
|
-
content: reportingToken
|
|
257
|
-
}
|
|
258
|
-
]
|
|
259
|
-
};
|
|
260
|
-
};
|
|
261
|
-
exports.getMessageReportingToken = getMessageReportingToken;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface SessionPoolOptions {
|
|
2
|
-
makeSocket: (sessionId: string) => Promise<any> | any;
|
|
3
|
-
logger?: any;
|
|
4
|
-
maxBackoffMs?: number;
|
|
5
|
-
onSessionUpdate?: (sessionId: string, sock: any) => void;
|
|
6
|
-
onLoggedOut?: (sessionId: string) => void;
|
|
7
|
-
}
|
|
8
|
-
export interface SessionPool {
|
|
9
|
-
add: (sessionId: string) => Promise<void>;
|
|
10
|
-
remove: (sessionId: string) => void;
|
|
11
|
-
get: (sessionId: string) => any;
|
|
12
|
-
list: () => string[];
|
|
13
|
-
}
|
|
14
|
-
export function createSessionPool(options: SessionPoolOptions): SessionPool;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.createSessionPool = void 0;
|
|
4
|
-
const DISCONNECT_REASON_LOGGED_OUT = 401;
|
|
5
|
-
const createSessionPool = options => {
|
|
6
|
-
const logger = options.logger;
|
|
7
|
-
const maxBackoffMs = options.maxBackoffMs ?? 60000;
|
|
8
|
-
const sessions = new Map();
|
|
9
|
-
const computeBackoffMs = attempts => {
|
|
10
|
-
const base = Math.min(1000 * 2 ** attempts, maxBackoffMs);
|
|
11
|
-
return base + Math.floor(Math.random() * (base * 0.2));
|
|
12
|
-
};
|
|
13
|
-
const start = async (sessionId) => {
|
|
14
|
-
const entry = sessions.get(sessionId) || { attempts: 0, stopped: false };
|
|
15
|
-
sessions.set(sessionId, entry);
|
|
16
|
-
if (entry.stopped)
|
|
17
|
-
return;
|
|
18
|
-
try {
|
|
19
|
-
const sock = await options.makeSocket(sessionId);
|
|
20
|
-
entry.sock = sock;
|
|
21
|
-
options.onSessionUpdate?.(sessionId, sock);
|
|
22
|
-
sock.ev.on('connection.update', update => {
|
|
23
|
-
if (update.connection === 'open') {
|
|
24
|
-
entry.attempts = 0;
|
|
25
|
-
}
|
|
26
|
-
if (update.connection === 'close') {
|
|
27
|
-
const statusCode = update.lastDisconnect?.error?.output?.statusCode;
|
|
28
|
-
if (statusCode === DISCONNECT_REASON_LOGGED_OUT) {
|
|
29
|
-
logger?.info?.({ sessionId }, 'session logged out, removing from pool');
|
|
30
|
-
sessions.delete(sessionId);
|
|
31
|
-
options.onLoggedOut?.(sessionId);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (entry.stopped)
|
|
35
|
-
return;
|
|
36
|
-
entry.attempts += 1;
|
|
37
|
-
const backoffMs = computeBackoffMs(entry.attempts);
|
|
38
|
-
logger?.warn?.({ sessionId, attempt: entry.attempts, backoffMs }, 'session disconnected, reconnecting with backoff');
|
|
39
|
-
setTimeout(() => start(sessionId), backoffMs);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
entry.attempts += 1;
|
|
45
|
-
const backoffMs = computeBackoffMs(entry.attempts);
|
|
46
|
-
logger?.error?.({ error, sessionId, backoffMs }, 'failed to start session, retrying with backoff');
|
|
47
|
-
if (!entry.stopped) {
|
|
48
|
-
setTimeout(() => start(sessionId), backoffMs);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const add = sessionId => start(sessionId);
|
|
53
|
-
const remove = sessionId => {
|
|
54
|
-
const entry = sessions.get(sessionId);
|
|
55
|
-
if (!entry)
|
|
56
|
-
return;
|
|
57
|
-
entry.stopped = true;
|
|
58
|
-
if (entry.sock?.end) {
|
|
59
|
-
try {
|
|
60
|
-
entry.sock.end(undefined);
|
|
61
|
-
}
|
|
62
|
-
catch { }
|
|
63
|
-
}
|
|
64
|
-
sessions.delete(sessionId);
|
|
65
|
-
};
|
|
66
|
-
const get = sessionId => sessions.get(sessionId)?.sock;
|
|
67
|
-
const list = () => [...sessions.keys()];
|
|
68
|
-
return { add, remove, get, list };
|
|
69
|
-
};
|
|
70
|
-
exports.createSessionPool = createSessionPool;
|
package/src/Utils/signal.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.getNextPreKeysNode =
|
|
4
|
-
exports.getNextPreKeys =
|
|
5
|
-
exports.extractDeviceJids =
|
|
6
|
-
exports.parseAndInjectE2ESessions =
|
|
7
|
-
exports.extractE2ESessionFromRetryReceipt =
|
|
8
|
-
exports.xmppPreKey =
|
|
9
|
-
exports.xmppSignedPreKey =
|
|
10
|
-
exports.generateOrGetPreKeys =
|
|
11
|
-
exports.getPreKeys =
|
|
12
|
-
exports.createSignalIdentity =
|
|
13
|
-
void 0;
|
|
14
|
-
const Defaults_1 = require('../Defaults');
|
|
15
|
-
const WABinary_1 = require('../WABinary');
|
|
16
|
-
const crypto_1 = require('./crypto');
|
|
17
|
-
const generics_1 = require('./generics');
|
|
18
|
-
function chunk(array, size) {
|
|
19
|
-
const chunks = [];
|
|
20
|
-
for (let i = 0; i < array.length; i += size) {
|
|
21
|
-
chunks.push(array.slice(i, i + size));
|
|
22
|
-
}
|
|
23
|
-
return chunks;
|
|
24
|
-
}
|
|
25
|
-
const createSignalIdentity = (wid, accountSignatureKey) => {
|
|
26
|
-
return {
|
|
27
|
-
identifier: { name: wid, deviceId: 0 },
|
|
28
|
-
identifierKey: (0, crypto_1.generateSignalPubKey)(accountSignatureKey)
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
exports.createSignalIdentity = createSignalIdentity;
|
|
32
|
-
const getPreKeys = async ({ get }, min, limit) => {
|
|
33
|
-
const idList = [];
|
|
34
|
-
for (let id = min; id < limit; id++) {
|
|
35
|
-
idList.push(id.toString());
|
|
36
|
-
}
|
|
37
|
-
return get('pre-key', idList);
|
|
38
|
-
};
|
|
39
|
-
exports.getPreKeys = getPreKeys;
|
|
40
|
-
const generateOrGetPreKeys = (creds, range) => {
|
|
41
|
-
const avaliable = creds.nextPreKeyId - creds.firstUnuploadedPreKeyId;
|
|
42
|
-
const remaining = range - avaliable;
|
|
43
|
-
const lastPreKeyId = creds.nextPreKeyId + remaining - 1;
|
|
44
|
-
const newPreKeys = {};
|
|
45
|
-
if (remaining > 0) {
|
|
46
|
-
for (let i = creds.nextPreKeyId; i <= lastPreKeyId; i++) {
|
|
47
|
-
newPreKeys[i] = crypto_1.Curve.generateKeyPair();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
newPreKeys,
|
|
52
|
-
lastPreKeyId,
|
|
53
|
-
preKeysRange: [creds.firstUnuploadedPreKeyId, range]
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
exports.generateOrGetPreKeys = generateOrGetPreKeys;
|
|
57
|
-
const xmppSignedPreKey = key => ({
|
|
58
|
-
tag: 'skey',
|
|
59
|
-
attrs: {},
|
|
60
|
-
content: [
|
|
61
|
-
{ tag: 'id', attrs: {}, content: (0, generics_1.encodeBigEndian)(key.keyId, 3) },
|
|
62
|
-
{ tag: 'value', attrs: {}, content: key.keyPair.public },
|
|
63
|
-
{ tag: 'signature', attrs: {}, content: key.signature }
|
|
64
|
-
]
|
|
65
|
-
});
|
|
66
|
-
exports.xmppSignedPreKey = xmppSignedPreKey;
|
|
67
|
-
const xmppPreKey = (pair, id) => ({
|
|
68
|
-
tag: 'key',
|
|
69
|
-
attrs: {},
|
|
70
|
-
content: [
|
|
71
|
-
{ tag: 'id', attrs: {}, content: (0, generics_1.encodeBigEndian)(id, 3) },
|
|
72
|
-
{ tag: 'value', attrs: {}, content: pair.public }
|
|
73
|
-
]
|
|
74
|
-
});
|
|
75
|
-
exports.xmppPreKey = xmppPreKey;
|
|
76
|
-
const isValidUInt = n => typeof n === 'number' && Number.isInteger(n);
|
|
77
|
-
const extractE2ESessionFromRetryReceipt = receipt => {
|
|
78
|
-
const keysNode = (0, WABinary_1.getBinaryNodeChild)(receipt, 'keys');
|
|
79
|
-
if (!keysNode)
|
|
80
|
-
return null;
|
|
81
|
-
const typeBuf = (0, WABinary_1.getBinaryNodeChildBuffer)(keysNode, 'type');
|
|
82
|
-
if (!typeBuf || typeBuf.length !== 1 || typeBuf[0] !== Defaults_1.KEY_BUNDLE_TYPE[0])
|
|
83
|
-
return null;
|
|
84
|
-
const identity = (0, WABinary_1.getBinaryNodeChildBuffer)(keysNode, 'identity');
|
|
85
|
-
const skey = (0, WABinary_1.getBinaryNodeChild)(keysNode, 'skey');
|
|
86
|
-
if (!identity || identity.length !== 32 || !skey)
|
|
87
|
-
return null;
|
|
88
|
-
const registrationId = (0, WABinary_1.getBinaryNodeChildUInt)(receipt, 'registration', 4);
|
|
89
|
-
if (!isValidUInt(registrationId))
|
|
90
|
-
return null;
|
|
91
|
-
const signedPubKey = (0, WABinary_1.getBinaryNodeChildBuffer)(skey, 'value');
|
|
92
|
-
const signedSig = (0, WABinary_1.getBinaryNodeChildBuffer)(skey, 'signature');
|
|
93
|
-
const signedKeyId = (0, WABinary_1.getBinaryNodeChildUInt)(skey, 'id', 3);
|
|
94
|
-
if (!signedPubKey || signedPubKey.length !== 32 || !signedSig || !isValidUInt(signedKeyId)) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
const preKeyNode = (0, WABinary_1.getBinaryNodeChild)(keysNode, 'key');
|
|
98
|
-
let preKey;
|
|
99
|
-
if (preKeyNode) {
|
|
100
|
-
const preKeyPub = (0, WABinary_1.getBinaryNodeChildBuffer)(preKeyNode, 'value');
|
|
101
|
-
const preKeyId = (0, WABinary_1.getBinaryNodeChildUInt)(preKeyNode, 'id', 3);
|
|
102
|
-
if (!preKeyPub || preKeyPub.length !== 32 || !isValidUInt(preKeyId)) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
preKey = { keyId: preKeyId, publicKey: (0, crypto_1.generateSignalPubKey)(preKeyPub) };
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
registrationId,
|
|
109
|
-
identityKey: (0, crypto_1.generateSignalPubKey)(identity),
|
|
110
|
-
signedPreKey: {
|
|
111
|
-
keyId: signedKeyId,
|
|
112
|
-
publicKey: (0, crypto_1.generateSignalPubKey)(signedPubKey),
|
|
113
|
-
signature: signedSig
|
|
114
|
-
},
|
|
115
|
-
preKey
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
exports.extractE2ESessionFromRetryReceipt = extractE2ESessionFromRetryReceipt;
|
|
119
|
-
const parseAndInjectE2ESessions = async (node, repository) => {
|
|
120
|
-
const extractKey = key => key
|
|
121
|
-
? {
|
|
122
|
-
keyId: (0, WABinary_1.getBinaryNodeChildUInt)(key, 'id', 3),
|
|
123
|
-
publicKey: (0, crypto_1.generateSignalPubKey)((0, WABinary_1.getBinaryNodeChildBuffer)(key, 'value')),
|
|
124
|
-
signature: (0, WABinary_1.getBinaryNodeChildBuffer)(key, 'signature')
|
|
125
|
-
}
|
|
126
|
-
: undefined;
|
|
127
|
-
const nodes = (0, WABinary_1.getBinaryNodeChildren)((0, WABinary_1.getBinaryNodeChild)(node, 'list'), 'user');
|
|
128
|
-
for (const node of nodes) {
|
|
129
|
-
;
|
|
130
|
-
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
131
|
-
}
|
|
132
|
-
const chunkSize = 100;
|
|
133
|
-
const chunks = chunk(nodes, chunkSize);
|
|
134
|
-
for (const nodesChunk of chunks) {
|
|
135
|
-
for (const node of nodesChunk) {
|
|
136
|
-
const signedKey = (0, WABinary_1.getBinaryNodeChild)(node, 'skey');
|
|
137
|
-
const key = (0, WABinary_1.getBinaryNodeChild)(node, 'key');
|
|
138
|
-
const identity = (0, WABinary_1.getBinaryNodeChildBuffer)(node, 'identity');
|
|
139
|
-
const jid = node.attrs.jid;
|
|
140
|
-
const registrationId = (0, WABinary_1.getBinaryNodeChildUInt)(node, 'registration', 4);
|
|
141
|
-
await repository.injectE2ESession({
|
|
142
|
-
jid,
|
|
143
|
-
session: {
|
|
144
|
-
registrationId: registrationId,
|
|
145
|
-
identityKey: (0, crypto_1.generateSignalPubKey)(identity),
|
|
146
|
-
signedPreKey: extractKey(signedKey),
|
|
147
|
-
preKey: extractKey(key)
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
exports.parseAndInjectE2ESessions = parseAndInjectE2ESessions;
|
|
154
|
-
const extractDeviceJids = (result, myJid, myLid, excludeZeroDevices) => {
|
|
155
|
-
const { user: myUser, device: myDevice } = (0, WABinary_1.jidDecode)(myJid);
|
|
156
|
-
const extracted = [];
|
|
157
|
-
for (const userResult of result) {
|
|
158
|
-
const { devices, id } = userResult;
|
|
159
|
-
const decoded = (0, WABinary_1.jidDecode)(id), { user, server } = decoded;
|
|
160
|
-
let { domainType } = decoded;
|
|
161
|
-
const deviceList = devices?.deviceList;
|
|
162
|
-
if (!Array.isArray(deviceList))
|
|
163
|
-
continue;
|
|
164
|
-
for (const { id: device, keyIndex, isHosted } of deviceList) {
|
|
165
|
-
if ((!excludeZeroDevices || device !== 0) &&
|
|
166
|
-
((myUser !== user && myLid !== user) || myDevice !== device) &&
|
|
167
|
-
(device === 0 || !!keyIndex)) {
|
|
168
|
-
if (isHosted) {
|
|
169
|
-
domainType =
|
|
170
|
-
domainType === WABinary_1.WAJIDDomains.LID
|
|
171
|
-
? WABinary_1.WAJIDDomains.HOSTED_LID
|
|
172
|
-
: WABinary_1.WAJIDDomains.HOSTED;
|
|
173
|
-
}
|
|
174
|
-
extracted.push({
|
|
175
|
-
user,
|
|
176
|
-
device,
|
|
177
|
-
domainType,
|
|
178
|
-
server: (0, WABinary_1.getServerFromDomainType)(server, domainType)
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return extracted;
|
|
184
|
-
};
|
|
185
|
-
exports.extractDeviceJids = extractDeviceJids;
|
|
186
|
-
const getNextPreKeys = async ({ creds, keys }, count) => {
|
|
187
|
-
const { newPreKeys, lastPreKeyId, preKeysRange } = (0, exports.generateOrGetPreKeys)(creds, count);
|
|
188
|
-
const update = {
|
|
189
|
-
nextPreKeyId: Math.max(lastPreKeyId + 1, creds.nextPreKeyId),
|
|
190
|
-
firstUnuploadedPreKeyId: Math.max(creds.firstUnuploadedPreKeyId, lastPreKeyId + 1)
|
|
191
|
-
};
|
|
192
|
-
await keys.set({ 'pre-key': newPreKeys });
|
|
193
|
-
const preKeys = await (0, exports.getPreKeys)(keys, preKeysRange[0], preKeysRange[0] + preKeysRange[1]);
|
|
194
|
-
return { update, preKeys };
|
|
195
|
-
};
|
|
196
|
-
exports.getNextPreKeys = getNextPreKeys;
|
|
197
|
-
const getNextPreKeysNode = async (state, count) => {
|
|
198
|
-
const { creds } = state;
|
|
199
|
-
const { update, preKeys } = await (0, exports.getNextPreKeys)(state, count);
|
|
200
|
-
const node = {
|
|
201
|
-
tag: 'iq',
|
|
202
|
-
attrs: {
|
|
203
|
-
xmlns: 'encrypt',
|
|
204
|
-
type: 'set',
|
|
205
|
-
to: WABinary_1.S_WHATSAPP_NET
|
|
206
|
-
},
|
|
207
|
-
content: [
|
|
208
|
-
{ tag: 'registration', attrs: {}, content: (0, generics_1.encodeBigEndian)(creds.registrationId) },
|
|
209
|
-
{ tag: 'type', attrs: {}, content: Defaults_1.KEY_BUNDLE_TYPE },
|
|
210
|
-
{ tag: 'identity', attrs: {}, content: creds.signedIdentityKey.public },
|
|
211
|
-
{ tag: 'list', attrs: {}, content: Object.keys(preKeys).map(k => (0, exports.xmppPreKey)(preKeys[+k], +k)) },
|
|
212
|
-
(0, exports.xmppSignedPreKey)(creds.signedPreKey)
|
|
213
|
-
]
|
|
214
|
-
};
|
|
215
|
-
return { update, node };
|
|
216
|
-
};
|
|
217
|
-
exports.getNextPreKeysNode = getNextPreKeysNode;
|
package/src/Utils/stanza-ack.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.buildAckStanza = buildAckStanza;
|
|
4
|
-
function buildAckStanza(node, errorCode, meId) {
|
|
5
|
-
const { tag, attrs } = node;
|
|
6
|
-
const stanza = {
|
|
7
|
-
tag: 'ack',
|
|
8
|
-
attrs: {
|
|
9
|
-
id: attrs.id,
|
|
10
|
-
to: attrs.from,
|
|
11
|
-
class: tag
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
if (errorCode) {
|
|
15
|
-
stanza.attrs.error = errorCode.toString();
|
|
16
|
-
}
|
|
17
|
-
if (attrs.participant) {
|
|
18
|
-
stanza.attrs.participant = attrs.participant;
|
|
19
|
-
}
|
|
20
|
-
if (attrs.recipient) {
|
|
21
|
-
stanza.attrs.recipient = attrs.recipient;
|
|
22
|
-
}
|
|
23
|
-
if (attrs.type) {
|
|
24
|
-
stanza.attrs.type = attrs.type;
|
|
25
|
-
}
|
|
26
|
-
if (tag === 'message' && meId) {
|
|
27
|
-
stanza.attrs.from = meId;
|
|
28
|
-
}
|
|
29
|
-
return stanza;
|
|
30
|
-
}
|
package/src/Utils/sticker.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface StickerMetaOptions {
|
|
2
|
-
packName?: string;
|
|
3
|
-
packPublisher?: string;
|
|
4
|
-
categories?: string[];
|
|
5
|
-
}
|
|
6
|
-
export function addExifToWebp(webpBuffer: Buffer, options?: StickerMetaOptions): Promise<Buffer>;
|
|
7
|
-
export function imageToWebpSticker(imageBuffer: Buffer, options?: StickerMetaOptions & {
|
|
8
|
-
quality?: number;
|
|
9
|
-
}): Promise<Buffer>;
|
|
10
|
-
export function videoToWebpSticker(videoBuffer: Buffer, options?: StickerMetaOptions & {
|
|
11
|
-
fps?: number;
|
|
12
|
-
seconds?: number;
|
|
13
|
-
}): Promise<Buffer>;
|