@sixcore/baileys 1.0.0 → 1.0.2
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/WAProto/index.js +14270 -302
- package/jessica.js +91 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +117 -79
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
- package/lib/Signal/libsignal.js +51 -29
- package/lib/Socket/business.d.ts +43 -42
- package/lib/Socket/chats.d.ts +222 -36
- package/lib/Socket/chats.js +173 -153
- package/lib/Socket/dugong.d.ts +254 -0
- package/lib/Socket/dugong.js +484 -0
- package/lib/Socket/groups.d.ts +7 -7
- package/lib/Socket/groups.js +37 -35
- package/lib/Socket/index.d.ts +52 -51
- package/lib/Socket/index.js +1 -0
- package/lib/Socket/messages-recv.d.ts +37 -34
- package/lib/Socket/messages-recv.js +175 -37
- package/lib/Socket/messages-send.d.ts +12 -18
- package/lib/Socket/messages-send.js +396 -574
- package/lib/Socket/newsletter.d.ts +28 -26
- package/lib/Socket/newsletter.js +132 -121
- package/lib/Socket/registration.d.ts +52 -49
- package/lib/Socket/registration.js +7 -7
- package/lib/Socket/socket.d.ts +0 -1
- package/lib/Socket/socket.js +49 -27
- package/lib/Socket/usync.d.ts +10 -11
- package/lib/Store/make-cache-manager-store.d.ts +1 -2
- package/lib/Store/make-in-memory-store.d.ts +2 -2
- package/lib/Store/make-in-memory-store.js +1 -5
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +7 -12
- package/lib/Types/Events.d.ts +2 -17
- package/lib/Types/GroupMetadata.d.ts +2 -3
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +10 -170
- package/lib/Types/Newsletter.d.ts +97 -86
- package/lib/Types/Newsletter.js +38 -32
- package/lib/Types/Socket.d.ts +2 -7
- package/lib/Types/index.d.ts +0 -9
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +14 -35
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +12 -11
- package/lib/Utils/chat-utils.js +36 -52
- package/lib/Utils/crypto.d.ts +16 -15
- package/lib/Utils/crypto.js +26 -74
- package/lib/Utils/decode-wa-message.d.ts +0 -17
- package/lib/Utils/decode-wa-message.js +17 -53
- package/lib/Utils/event-buffer.js +7 -10
- package/lib/Utils/generics.d.ts +17 -13
- package/lib/Utils/generics.js +79 -58
- package/lib/Utils/history.d.ts +2 -6
- package/lib/Utils/history.js +6 -4
- package/lib/Utils/logger.d.ts +3 -1
- package/lib/Utils/lt-hash.js +12 -12
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +28 -25
- package/lib/Utils/messages-media.js +733 -557
- package/lib/Utils/messages.js +68 -473
- package/lib/Utils/noise-handler.d.ts +5 -4
- package/lib/Utils/noise-handler.js +14 -19
- package/lib/Utils/process-message.d.ts +5 -5
- package/lib/Utils/process-message.js +23 -75
- package/lib/Utils/signal.d.ts +1 -2
- package/lib/Utils/signal.js +26 -32
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +66 -242
- package/lib/Utils/validate-connection.d.ts +1 -1
- package/lib/Utils/validate-connection.js +88 -64
- package/lib/WABinary/constants.d.ts +27 -24
- package/lib/WABinary/decode.d.ts +2 -1
- package/lib/WABinary/decode.js +11 -23
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +147 -134
- package/lib/WABinary/generic-utils.d.ts +5 -2
- package/lib/WABinary/generic-utils.js +125 -37
- package/lib/WABinary/jid-utils.d.ts +1 -1
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/USyncUser.d.ts +2 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +64 -1
- package/package.json +113 -51
- package/WAProto/GenerateStatics.sh +0 -4
- package/WAProto/WAProto.proto +0 -4357
- package/WAProto/index.d.ts +0 -50383
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/generate-proto.sh +0 -1
- package/WASignalGroup/group.proto +0 -42
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-state.js +0 -75
- package/src/Defaults/baileys-version.json +0 -3
- package/src/Defaults/index.ts +0 -133
- package/src/Signal/Group/ciphertext-message.ts +0 -9
- package/src/Signal/Group/group-session-builder.ts +0 -56
- package/src/Signal/Group/group_cipher.ts +0 -117
- package/src/Signal/Group/index.ts +0 -11
- package/src/Signal/Group/keyhelper.ts +0 -28
- package/src/Signal/Group/sender-chain-key.ts +0 -34
- package/src/Signal/Group/sender-key-distribution-message.ts +0 -95
- package/src/Signal/Group/sender-key-message.ts +0 -96
- package/src/Signal/Group/sender-key-name.ts +0 -66
- package/src/Signal/Group/sender-key-record.ts +0 -69
- package/src/Signal/Group/sender-key-state.ts +0 -134
- package/src/Signal/Group/sender-message-key.ts +0 -36
- package/src/Signal/libsignal.ts +0 -447
- package/src/Signal/lid-mapping.ts +0 -209
- package/src/Socket/Client/index.ts +0 -2
- package/src/Socket/Client/types.ts +0 -22
- package/src/Socket/Client/websocket.ts +0 -56
- package/src/Socket/business.ts +0 -421
- package/src/Socket/chats.ts +0 -1223
- package/src/Socket/communities.ts +0 -477
- package/src/Socket/groups.ts +0 -361
- package/src/Socket/index.ts +0 -22
- package/src/Socket/messages-recv.ts +0 -1563
- package/src/Socket/messages-send.ts +0 -1210
- package/src/Socket/mex.ts +0 -58
- package/src/Socket/newsletter.ts +0 -229
- package/src/Socket/socket.ts +0 -1072
- package/src/Types/Auth.ts +0 -115
- package/src/Types/Bussines.ts +0 -20
- package/src/Types/Call.ts +0 -14
- package/src/Types/Chat.ts +0 -138
- package/src/Types/Contact.ts +0 -24
- package/src/Types/Events.ts +0 -132
- package/src/Types/GroupMetadata.ts +0 -70
- package/src/Types/Label.ts +0 -48
- package/src/Types/LabelAssociation.ts +0 -35
- package/src/Types/Message.ts +0 -424
- package/src/Types/Newsletter.ts +0 -98
- package/src/Types/Product.ts +0 -85
- package/src/Types/Signal.ts +0 -76
- package/src/Types/Socket.ts +0 -150
- package/src/Types/State.ts +0 -43
- package/src/Types/USync.ts +0 -27
- package/src/Types/globals.d.ts +0 -8
- package/src/Types/index.ts +0 -67
- package/src/Utils/auth-utils.ts +0 -331
- package/src/Utils/browser-utils.ts +0 -31
- package/src/Utils/business.ts +0 -286
- package/src/Utils/chat-utils.ts +0 -933
- package/src/Utils/crypto.ts +0 -184
- package/src/Utils/decode-wa-message.ts +0 -355
- package/src/Utils/event-buffer.ts +0 -662
- package/src/Utils/generics.ts +0 -470
- package/src/Utils/history.ts +0 -114
- package/src/Utils/index.ts +0 -18
- package/src/Utils/link-preview.ts +0 -111
- package/src/Utils/logger.ts +0 -13
- package/src/Utils/lt-hash.ts +0 -65
- package/src/Utils/make-mutex.ts +0 -45
- package/src/Utils/message-retry-manager.ts +0 -229
- package/src/Utils/messages-media.ts +0 -820
- package/src/Utils/messages.ts +0 -1137
- package/src/Utils/noise-handler.ts +0 -192
- package/src/Utils/pre-key-manager.ts +0 -126
- package/src/Utils/process-message.ts +0 -622
- package/src/Utils/signal.ts +0 -214
- package/src/Utils/use-multi-file-auth-state.ts +0 -136
- package/src/Utils/validate-connection.ts +0 -253
- package/src/WABinary/constants.ts +0 -1305
- package/src/WABinary/decode.ts +0 -281
- package/src/WABinary/encode.ts +0 -253
- package/src/WABinary/generic-utils.ts +0 -127
- package/src/WABinary/index.ts +0 -5
- package/src/WABinary/jid-utils.ts +0 -128
- package/src/WABinary/types.ts +0 -17
- package/src/WAM/BinaryInfo.ts +0 -12
- package/src/WAM/constants.ts +0 -22889
- package/src/WAM/encode.ts +0 -169
- package/src/WAM/index.ts +0 -3
- package/src/WAUSync/Protocols/USyncContactProtocol.ts +0 -32
- package/src/WAUSync/Protocols/USyncDeviceProtocol.ts +0 -78
- package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.ts +0 -35
- package/src/WAUSync/Protocols/USyncStatusProtocol.ts +0 -44
- package/src/WAUSync/Protocols/UsyncBotProfileProtocol.ts +0 -76
- package/src/WAUSync/Protocols/UsyncLIDProtocol.ts +0 -33
- package/src/WAUSync/Protocols/index.ts +0 -4
- package/src/WAUSync/USyncQuery.ts +0 -133
- package/src/WAUSync/USyncUser.ts +0 -32
- package/src/WAUSync/index.ts +0 -3
- package/src/index.ts +0 -13
package/lib/Types/Newsletter.js
CHANGED
|
@@ -1,32 +1,38 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const MexOperations = {
|
|
6
|
+
PROMOTE: "NotificationNewsletterAdminPromote",
|
|
7
|
+
DEMOTE: "NotificationNewsletterAdminDemote",
|
|
8
|
+
UPDATE: "NotificationNewsletterUpdate"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const XWAPaths = {
|
|
12
|
+
PROMOTE: "xwa2_notify_newsletter_admin_promote",
|
|
13
|
+
DEMOTE: "xwa2_notify_newsletter_admin_demote",
|
|
14
|
+
ADMIN_COUNT: "xwa2_newsletter_admin",
|
|
15
|
+
CREATE: "xwa2_newsletter_create",
|
|
16
|
+
NEWSLETTER: "xwa2_newsletter",
|
|
17
|
+
SUBSCRIBED: "xwa2_newsletter_subscribed",
|
|
18
|
+
METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const QueryIds = {
|
|
22
|
+
JOB_MUTATION: "7150902998257522",
|
|
23
|
+
METADATA: "6620195908089573",
|
|
24
|
+
UNFOLLOW: "7238632346214362",
|
|
25
|
+
FOLLOW: "7871414976211147",
|
|
26
|
+
UNMUTE: "7337137176362961",
|
|
27
|
+
MUTE: "25151904754424642",
|
|
28
|
+
CREATE: "6996806640408138",
|
|
29
|
+
ADMIN_COUNT: "7130823597031706",
|
|
30
|
+
CHANGE_OWNER: "7341777602580933",
|
|
31
|
+
DELETE: "8316537688363079",
|
|
32
|
+
DEMOTE: "6551828931592903",
|
|
33
|
+
SUBSCRIBED: "6388546374527196"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.MexOperations = MexOperations
|
|
37
|
+
exports.XWAPaths = XWAPaths
|
|
38
|
+
exports.QueryIds = QueryIds
|
package/lib/Types/Socket.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
import { AxiosRequestConfig } from 'axios';
|
|
2
4
|
import type { Agent } from 'https';
|
|
3
5
|
import type { Logger } from 'pino';
|
|
4
6
|
import type { URL } from 'url';
|
|
5
7
|
import { proto } from '../../WAProto';
|
|
6
8
|
import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
|
|
7
|
-
import { GroupMetadata } from './GroupMetadata';
|
|
8
9
|
import { MediaConnInfo } from './Message';
|
|
9
10
|
import { SignalRepository } from './Signal';
|
|
10
11
|
export type WAVersion = [number, number, number];
|
|
@@ -60,8 +61,6 @@ export type SocketConfig = {
|
|
|
60
61
|
transactionOpts: TransactionCapabilityOptions;
|
|
61
62
|
/** marks the client as online whenever the socket successfully connects */
|
|
62
63
|
markOnlineOnConnect: boolean;
|
|
63
|
-
/** alphanumeric country code (USA -> US) for the number used */
|
|
64
|
-
countryCode: string;
|
|
65
64
|
/** provide a cache to store media, so does not have to be re-uploaded */
|
|
66
65
|
mediaCache?: CacheStore;
|
|
67
66
|
/**
|
|
@@ -72,8 +71,6 @@ export type SocketConfig = {
|
|
|
72
71
|
userDevicesCache?: CacheStore;
|
|
73
72
|
/** cache to store call offers */
|
|
74
73
|
callOfferCache?: CacheStore;
|
|
75
|
-
/** cache to track placeholder resends */
|
|
76
|
-
placeholderResendCache?: CacheStore;
|
|
77
74
|
/** width for link preview images */
|
|
78
75
|
linkPreviewImageThumbnailWidth: number;
|
|
79
76
|
/** Should Baileys ask the phone for full history, will be received async */
|
|
@@ -108,8 +105,6 @@ export type SocketConfig = {
|
|
|
108
105
|
* (solves the "this message can take a while" issue) can be retried
|
|
109
106
|
* */
|
|
110
107
|
getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
|
|
111
|
-
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
|
112
|
-
cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
|
|
113
108
|
makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
|
|
114
109
|
/** Socket passthrough */
|
|
115
110
|
socket?: any;
|
package/lib/Types/index.d.ts
CHANGED
|
@@ -15,15 +15,6 @@ import { SocketConfig } from './Socket';
|
|
|
15
15
|
export type UserFacingSocketConfig = Partial<SocketConfig> & {
|
|
16
16
|
auth: AuthenticationState;
|
|
17
17
|
};
|
|
18
|
-
export type BrowsersMap = {
|
|
19
|
-
ubuntu(browser: string): [string, string, string];
|
|
20
|
-
macOS(browser: string): [string, string, string];
|
|
21
|
-
baileys(browser: string): [string, string, string];
|
|
22
|
-
windows(browser: string): [string, string, string];
|
|
23
|
-
iOS(browser: string): [string, string, string];
|
|
24
|
-
linux(browser: string): [string, string, string];
|
|
25
|
-
appropriate(browser: string): [string, string, string];
|
|
26
|
-
};
|
|
27
18
|
export declare enum DisconnectReason {
|
|
28
19
|
connectionClosed = 428,
|
|
29
20
|
connectionLost = 408,
|
package/lib/Types/index.js
CHANGED
|
@@ -39,4 +39,4 @@ var DisconnectReason;
|
|
|
39
39
|
DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
|
|
40
40
|
DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
|
|
41
41
|
DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
|
|
42
|
-
})(DisconnectReason
|
|
42
|
+
})(DisconnectReason = exports.DisconnectReason || (exports.DisconnectReason = {}));
|
package/lib/Utils/auth-utils.js
CHANGED
|
@@ -3,8 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.initAuthCreds = exports.addTransactionCapability = void 0;
|
|
7
|
-
exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
|
|
6
|
+
exports.initAuthCreds = exports.addTransactionCapability = exports.makeCacheableSignalKeyStore = void 0;
|
|
8
7
|
const crypto_1 = require("crypto");
|
|
9
8
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
10
9
|
const uuid_1 = require("uuid");
|
|
@@ -19,30 +18,9 @@ const generics_1 = require("./generics");
|
|
|
19
18
|
*/
|
|
20
19
|
function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
21
20
|
const cache = _cache || new node_cache_1.default({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
checkperiod: 120
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
cache.on('expired', async (key) => {
|
|
29
|
-
const [type, id] = key.split('.');
|
|
30
|
-
const item = cache.get(key, { noUpdate: true });
|
|
31
|
-
if (item) {
|
|
32
|
-
try {
|
|
33
|
-
await store.set({
|
|
34
|
-
[type]: {
|
|
35
|
-
[id]: item
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
cache.del(key);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
logger?.error({
|
|
41
|
-
key
|
|
42
|
-
}, 'Failed to persist expired cache item');
|
|
43
|
-
cache.ttl(key, 60);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
21
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE,
|
|
22
|
+
useClones: false,
|
|
23
|
+
deleteOnExpire: true,
|
|
46
24
|
});
|
|
47
25
|
function getUniqueId(type, id) {
|
|
48
26
|
return `${type}.${id}`;
|
|
@@ -52,7 +30,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
|
52
30
|
const data = {};
|
|
53
31
|
const idsToFetch = [];
|
|
54
32
|
for (const id of ids) {
|
|
55
|
-
const item = cache.get(getUniqueId(type, id)
|
|
33
|
+
const item = cache.get(getUniqueId(type, id));
|
|
56
34
|
if (typeof item !== 'undefined') {
|
|
57
35
|
data[id] = item;
|
|
58
36
|
}
|
|
@@ -61,7 +39,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
|
61
39
|
}
|
|
62
40
|
}
|
|
63
41
|
if (idsToFetch.length) {
|
|
64
|
-
logger
|
|
42
|
+
logger.trace({ items: idsToFetch.length }, 'loading from store');
|
|
65
43
|
const fetched = await store.get(type, idsToFetch);
|
|
66
44
|
for (const id of idsToFetch) {
|
|
67
45
|
const item = fetched[id];
|
|
@@ -81,7 +59,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
|
81
59
|
keys += 1;
|
|
82
60
|
}
|
|
83
61
|
}
|
|
84
|
-
logger
|
|
62
|
+
logger.trace({ keys }, 'updated cache');
|
|
85
63
|
await store.set(data);
|
|
86
64
|
},
|
|
87
65
|
async clear() {
|
|
@@ -91,6 +69,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
|
91
69
|
}
|
|
92
70
|
};
|
|
93
71
|
}
|
|
72
|
+
exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
|
|
94
73
|
/**
|
|
95
74
|
* Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
|
|
96
75
|
* this allows batch read & write operations & improves the performance of the lib
|
|
@@ -134,7 +113,7 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
134
113
|
},
|
|
135
114
|
set: data => {
|
|
136
115
|
if (isInTransaction()) {
|
|
137
|
-
logger
|
|
116
|
+
logger.trace({ types: Object.keys(data) }, 'caching in transaction');
|
|
138
117
|
for (const key in data) {
|
|
139
118
|
transactionCache[key] = transactionCache[key] || {};
|
|
140
119
|
Object.assign(transactionCache[key], data[key]);
|
|
@@ -151,14 +130,14 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
151
130
|
let result;
|
|
152
131
|
transactionsInProgress += 1;
|
|
153
132
|
if (transactionsInProgress === 1) {
|
|
154
|
-
logger
|
|
133
|
+
logger.trace('entering transaction');
|
|
155
134
|
}
|
|
156
135
|
try {
|
|
157
136
|
result = await work();
|
|
158
137
|
// commit if this is the outermost transaction
|
|
159
138
|
if (transactionsInProgress === 1) {
|
|
160
139
|
if (Object.keys(mutations).length) {
|
|
161
|
-
logger
|
|
140
|
+
logger.trace('committing transaction');
|
|
162
141
|
// retry mechanism to ensure we've some recovery
|
|
163
142
|
// in case a transaction fails in the first attempt
|
|
164
143
|
let tries = maxCommitRetries;
|
|
@@ -166,17 +145,17 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
166
145
|
tries -= 1;
|
|
167
146
|
try {
|
|
168
147
|
await state.set(mutations);
|
|
169
|
-
logger
|
|
148
|
+
logger.trace({ dbQueriesInTransaction }, 'committed transaction');
|
|
170
149
|
break;
|
|
171
150
|
}
|
|
172
151
|
catch (error) {
|
|
173
|
-
logger
|
|
152
|
+
logger.warn(`failed to commit ${Object.keys(mutations).length} mutations, tries left=${tries}`);
|
|
174
153
|
await (0, generics_1.delay)(delayBetweenTriesMs);
|
|
175
154
|
}
|
|
176
155
|
}
|
|
177
156
|
}
|
|
178
157
|
else {
|
|
179
|
-
logger
|
|
158
|
+
logger.trace('no mutations in transaction');
|
|
180
159
|
}
|
|
181
160
|
}
|
|
182
161
|
}
|
package/lib/Utils/business.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate,
|
|
|
2
2
|
import { BinaryNode } from '../WABinary';
|
|
3
3
|
export declare const parseCatalogNode: (node: BinaryNode) => {
|
|
4
4
|
products: Product[];
|
|
5
|
-
nextPageCursor:
|
|
5
|
+
nextPageCursor: string | undefined;
|
|
6
6
|
};
|
|
7
7
|
export declare const parseCollectionsNode: (node: BinaryNode) => {
|
|
8
8
|
collections: CatalogCollection[];
|
package/lib/Utils/business.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uploadingNecessaryImages = exports.parseProductNode = exports.toProductNode = exports.parseOrderDetailsNode = exports.parseCollectionsNode = exports.parseCatalogNode = void 0;
|
|
4
|
-
exports.uploadingNecessaryImagesOfProduct = uploadingNecessaryImagesOfProduct;
|
|
3
|
+
exports.uploadingNecessaryImages = exports.uploadingNecessaryImagesOfProduct = exports.parseProductNode = exports.toProductNode = exports.parseOrderDetailsNode = exports.parseCollectionsNode = exports.parseCatalogNode = void 0;
|
|
5
4
|
const boom_1 = require("@hapi/boom");
|
|
6
5
|
const crypto_1 = require("crypto");
|
|
7
6
|
const WABinary_1 = require("../WABinary");
|
|
@@ -189,6 +188,7 @@ async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, time
|
|
|
189
188
|
};
|
|
190
189
|
return product;
|
|
191
190
|
}
|
|
191
|
+
exports.uploadingNecessaryImagesOfProduct = uploadingNecessaryImagesOfProduct;
|
|
192
192
|
/**
|
|
193
193
|
* Uploads images not already uploaded to WA's servers
|
|
194
194
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { AxiosRequestConfig } from 'axios';
|
|
2
3
|
import type { Logger } from 'pino';
|
|
3
4
|
import { proto } from '../../WAProto';
|
|
@@ -13,7 +14,7 @@ export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, o
|
|
|
13
14
|
state: LTHashState;
|
|
14
15
|
}>;
|
|
15
16
|
export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
|
16
|
-
hash:
|
|
17
|
+
hash: Buffer;
|
|
17
18
|
indexValueMap: {
|
|
18
19
|
[indexMacBase64: string]: {
|
|
19
20
|
valueMac: Uint8Array | Buffer;
|
|
@@ -21,47 +22,47 @@ export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation
|
|
|
21
22
|
};
|
|
22
23
|
}>;
|
|
23
24
|
export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
|
24
|
-
hash:
|
|
25
|
+
hash: Buffer;
|
|
25
26
|
indexValueMap: {
|
|
26
27
|
[indexMacBase64: string]: {
|
|
27
28
|
valueMac: Uint8Array | Buffer;
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
}>;
|
|
31
|
-
export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<
|
|
32
|
+
export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<any>) => Promise<{
|
|
32
33
|
critical_block: {
|
|
33
34
|
patches: proto.ISyncdPatch[];
|
|
34
35
|
hasMorePatches: boolean;
|
|
35
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
36
|
+
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
36
37
|
};
|
|
37
38
|
critical_unblock_low: {
|
|
38
39
|
patches: proto.ISyncdPatch[];
|
|
39
40
|
hasMorePatches: boolean;
|
|
40
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
41
|
+
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
41
42
|
};
|
|
42
43
|
regular_high: {
|
|
43
44
|
patches: proto.ISyncdPatch[];
|
|
44
45
|
hasMorePatches: boolean;
|
|
45
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
46
|
+
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
46
47
|
};
|
|
47
48
|
regular_low: {
|
|
48
49
|
patches: proto.ISyncdPatch[];
|
|
49
50
|
hasMorePatches: boolean;
|
|
50
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
51
|
+
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
51
52
|
};
|
|
52
53
|
regular: {
|
|
53
54
|
patches: proto.ISyncdPatch[];
|
|
54
55
|
hasMorePatches: boolean;
|
|
55
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
56
|
+
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
56
57
|
};
|
|
57
58
|
}>;
|
|
58
|
-
export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<
|
|
59
|
-
export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<
|
|
59
|
+
export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<Buffer>;
|
|
60
|
+
export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<proto.SyncdMutations>;
|
|
60
61
|
export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
|
|
61
62
|
state: LTHashState;
|
|
62
63
|
mutationMap: ChatMutationMap;
|
|
63
64
|
}>;
|
|
64
|
-
export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<
|
|
65
|
+
export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<any>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
|
|
65
66
|
state: LTHashState;
|
|
66
67
|
mutationMap: ChatMutationMap;
|
|
67
68
|
}>;
|
package/lib/Utils/chat-utils.js
CHANGED
|
@@ -9,8 +9,8 @@ const crypto_1 = require("./crypto");
|
|
|
9
9
|
const generics_1 = require("./generics");
|
|
10
10
|
const lt_hash_1 = require("./lt-hash");
|
|
11
11
|
const messages_media_1 = require("./messages-media");
|
|
12
|
-
const mutationKeys =
|
|
13
|
-
const expanded =
|
|
12
|
+
const mutationKeys = (keydata) => {
|
|
13
|
+
const expanded = (0, crypto_1.hkdf)(keydata, 160, { info: 'WhatsApp Mutation Keys' });
|
|
14
14
|
return {
|
|
15
15
|
indexKey: expanded.slice(0, 32),
|
|
16
16
|
valueEncryptionKey: expanded.slice(32, 64),
|
|
@@ -69,9 +69,9 @@ const makeLtHashGenerator = ({ indexValueMap, hash }) => {
|
|
|
69
69
|
subBuffs.push(new Uint8Array(prevOp.valueMac).buffer);
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
-
finish:
|
|
72
|
+
finish: () => {
|
|
73
73
|
const hashArrayBuffer = new Uint8Array(hash).buffer;
|
|
74
|
-
const result =
|
|
74
|
+
const result = lt_hash_1.LT_HASH_ANTI_TAMPERING.subtractThenAdd(hashArrayBuffer, addBuffs, subBuffs);
|
|
75
75
|
const buffer = Buffer.from(result);
|
|
76
76
|
return {
|
|
77
77
|
hash: buffer,
|
|
@@ -114,14 +114,14 @@ const encodeSyncdPatch = async ({ type, index, syncAction, apiVersion, operation
|
|
|
114
114
|
version: apiVersion
|
|
115
115
|
});
|
|
116
116
|
const encoded = WAProto_1.proto.SyncActionData.encode(dataProto).finish();
|
|
117
|
-
const keyValue =
|
|
117
|
+
const keyValue = mutationKeys(key.keyData);
|
|
118
118
|
const encValue = (0, crypto_1.aesEncrypt)(encoded, keyValue.valueEncryptionKey);
|
|
119
119
|
const valueMac = generateMac(operation, encValue, encKeyId, keyValue.valueMacKey);
|
|
120
120
|
const indexMac = (0, crypto_1.hmacSign)(indexBuffer, keyValue.indexKey);
|
|
121
121
|
// update LT hash
|
|
122
122
|
const generator = makeLtHashGenerator(state);
|
|
123
123
|
generator.mix({ indexMac, valueMac, operation });
|
|
124
|
-
Object.assign(state,
|
|
124
|
+
Object.assign(state, generator.finish());
|
|
125
125
|
state.version += 1;
|
|
126
126
|
const snapshotMac = generateSnapshotMac(state.hash, state.version, type, keyValue.snapshotMacKey);
|
|
127
127
|
const patch = {
|
|
@@ -184,7 +184,7 @@ const decodeSyncdMutations = async (msgMutations, initialState, getAppStateSyncK
|
|
|
184
184
|
operation: operation
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
return
|
|
187
|
+
return ltGenerator.finish();
|
|
188
188
|
async function getKey(keyId) {
|
|
189
189
|
const base64Key = Buffer.from(keyId).toString('base64');
|
|
190
190
|
const keyEnc = await getAppStateSyncKey(base64Key);
|
|
@@ -202,7 +202,7 @@ const decodeSyncdPatch = async (msg, name, initialState, getAppStateSyncKey, onM
|
|
|
202
202
|
if (!mainKeyObj) {
|
|
203
203
|
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode patch`, { statusCode: 404, data: { msg } });
|
|
204
204
|
}
|
|
205
|
-
const mainKey =
|
|
205
|
+
const mainKey = mutationKeys(mainKeyObj.keyData);
|
|
206
206
|
const mutationmacs = msg.mutations.map(mutation => mutation.record.value.blob.slice(-32));
|
|
207
207
|
const patchMac = generatePatchMac(msg.snapshotMac, mutationmacs, (0, generics_1.toNumber)(msg.version.version), name, mainKey.patchMacKey);
|
|
208
208
|
if (Buffer.compare(patchMac, msg.patchMac) !== 0) {
|
|
@@ -286,7 +286,7 @@ const decodeSyncdSnapshot = async (name, snapshot, getAppStateSyncKey, minimumVe
|
|
|
286
286
|
if (!keyEnc) {
|
|
287
287
|
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation`);
|
|
288
288
|
}
|
|
289
|
-
const result =
|
|
289
|
+
const result = mutationKeys(keyEnc.keyData);
|
|
290
290
|
const computedSnapshotMac = generateSnapshotMac(newState.hash, newState.version, name, result.snapshotMacKey);
|
|
291
291
|
if (Buffer.compare(snapshot.mac, computedSnapshotMac) !== 0) {
|
|
292
292
|
throw new boom_1.Boom(`failed to verify LTHash at ${newState.version} of ${name} from snapshot`);
|
|
@@ -305,7 +305,8 @@ const decodePatches = async (name, syncds, initial, getAppStateSyncKey, options,
|
|
|
305
305
|
indexValueMap: { ...initial.indexValueMap }
|
|
306
306
|
};
|
|
307
307
|
const mutationMap = {};
|
|
308
|
-
for (
|
|
308
|
+
for (let i = 0; i < syncds.length; i++) {
|
|
309
|
+
const syncd = syncds[i];
|
|
309
310
|
const { version, keyId, snapshotMac } = syncd;
|
|
310
311
|
if (syncd.externalMutations) {
|
|
311
312
|
logger === null || logger === void 0 ? void 0 : logger.trace({ name, version }, 'downloading external patch');
|
|
@@ -331,7 +332,7 @@ const decodePatches = async (name, syncds, initial, getAppStateSyncKey, options,
|
|
|
331
332
|
if (!keyEnc) {
|
|
332
333
|
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation`);
|
|
333
334
|
}
|
|
334
|
-
const result =
|
|
335
|
+
const result = mutationKeys(keyEnc.keyData);
|
|
335
336
|
const computedSnapshotMac = generateSnapshotMac(newState.hash, newState.version, name, result.snapshotMacKey);
|
|
336
337
|
if (Buffer.compare(snapshotMac, computedSnapshotMac) !== 0) {
|
|
337
338
|
throw new boom_1.Boom(`failed to verify LTHash at ${newState.version} of ${name}`);
|
|
@@ -417,31 +418,25 @@ const chatModificationToAppPatch = (mod, jid) => {
|
|
|
417
418
|
operation: OP.SET
|
|
418
419
|
};
|
|
419
420
|
}
|
|
420
|
-
else if ('deleteForMe' in mod) {
|
|
421
|
-
const { timestamp, key, deleteMedia } = mod.deleteForMe;
|
|
422
|
-
patch = {
|
|
423
|
-
syncAction: {
|
|
424
|
-
deleteMessageForMeAction: {
|
|
425
|
-
deleteMedia,
|
|
426
|
-
messageTimestamp: timestamp
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
index: ['deleteMessageForMe', jid, key.id, key.fromMe ? '1' : '0', '0'],
|
|
430
|
-
type: 'regular_high',
|
|
431
|
-
apiVersion: 3,
|
|
432
|
-
operation: OP.SET
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
421
|
else if ('clear' in mod) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
422
|
+
if (mod.clear === 'all') {
|
|
423
|
+
throw new boom_1.Boom('not supported');
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
const key = mod.clear.messages[0];
|
|
427
|
+
patch = {
|
|
428
|
+
syncAction: {
|
|
429
|
+
deleteMessageForMeAction: {
|
|
430
|
+
deleteMedia: false,
|
|
431
|
+
messageTimestamp: key.timestamp
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
index: ['deleteMessageForMe', jid, key.id, key.fromMe ? '1' : '0', '0'],
|
|
435
|
+
type: 'regular_high',
|
|
436
|
+
apiVersion: 3,
|
|
437
|
+
operation: OP.SET
|
|
438
|
+
};
|
|
439
|
+
}
|
|
445
440
|
}
|
|
446
441
|
else if ('pin' in mod) {
|
|
447
442
|
patch = {
|
|
@@ -496,22 +491,6 @@ const chatModificationToAppPatch = (mod, jid) => {
|
|
|
496
491
|
operation: OP.SET,
|
|
497
492
|
};
|
|
498
493
|
}
|
|
499
|
-
else if ('addLabel' in mod) {
|
|
500
|
-
patch = {
|
|
501
|
-
syncAction: {
|
|
502
|
-
labelEditAction: {
|
|
503
|
-
name: mod.addLabel.name,
|
|
504
|
-
color: mod.addLabel.color,
|
|
505
|
-
predefinedId: mod.addLabel.predefinedId,
|
|
506
|
-
deleted: mod.addLabel.deleted
|
|
507
|
-
}
|
|
508
|
-
},
|
|
509
|
-
index: ['label_edit', mod.addLabel.id],
|
|
510
|
-
type: 'regular',
|
|
511
|
-
apiVersion: 3,
|
|
512
|
-
operation: OP.SET,
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
494
|
else if ('addChatLabel' in mod) {
|
|
516
495
|
patch = {
|
|
517
496
|
syncAction: {
|
|
@@ -654,7 +633,12 @@ const processSyncAction = (syncAction, ev, me, initialSyncOpts, logger) => {
|
|
|
654
633
|
});
|
|
655
634
|
}
|
|
656
635
|
else if (action === null || action === void 0 ? void 0 : action.contactAction) {
|
|
657
|
-
ev.emit('contacts.upsert', [{
|
|
636
|
+
ev.emit('contacts.upsert', [{
|
|
637
|
+
id: id,
|
|
638
|
+
name: action.contactAction.fullName,
|
|
639
|
+
lid: action.contactAction.lidJid || undefined,
|
|
640
|
+
jid: (0, WABinary_1.isJidUser)(id) ? id : undefined
|
|
641
|
+
}]);
|
|
658
642
|
}
|
|
659
643
|
else if (action === null || action === void 0 ? void 0 : action.pushNameSetting) {
|
|
660
644
|
const name = (_b = action === null || action === void 0 ? void 0 : action.pushNameSetting) === null || _b === void 0 ? void 0 : _b.name;
|
package/lib/Utils/crypto.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { KeyPair } from '../Types';
|
|
2
3
|
/** prefix version byte to the pub keys, required for some curve crypto functions */
|
|
3
|
-
export declare const generateSignalPubKey: (pubKey: Uint8Array | Buffer) =>
|
|
4
|
+
export declare const generateSignalPubKey: (pubKey: Uint8Array | Buffer) => Uint8Array | Buffer;
|
|
4
5
|
export declare const Curve: {
|
|
5
6
|
generateKeyPair: () => KeyPair;
|
|
6
|
-
sharedKey: (privateKey: Uint8Array, publicKey: Uint8Array) =>
|
|
7
|
+
sharedKey: (privateKey: Uint8Array, publicKey: Uint8Array) => Buffer;
|
|
7
8
|
sign: (privateKey: Uint8Array, buf: Uint8Array) => any;
|
|
8
9
|
verify: (pubKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => boolean;
|
|
9
10
|
};
|
|
@@ -16,25 +17,25 @@ export declare const signedKeyPair: (identityKeyPair: KeyPair, keyId: number) =>
|
|
|
16
17
|
* encrypt AES 256 GCM;
|
|
17
18
|
* where the tag tag is suffixed to the ciphertext
|
|
18
19
|
* */
|
|
19
|
-
export declare function aesEncryptGCM(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array):
|
|
20
|
+
export declare function aesEncryptGCM(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): Buffer;
|
|
20
21
|
/**
|
|
21
22
|
* decrypt AES 256 GCM;
|
|
22
23
|
* where the auth tag is suffixed to the ciphertext
|
|
23
24
|
* */
|
|
24
|
-
export declare function aesDecryptGCM(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array):
|
|
25
|
-
export declare function aesEncryptCTR(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array):
|
|
26
|
-
export declare function aesDecryptCTR(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array):
|
|
25
|
+
export declare function aesDecryptGCM(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): Buffer;
|
|
26
|
+
export declare function aesEncryptCTR(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array): Buffer;
|
|
27
|
+
export declare function aesDecryptCTR(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array): Buffer;
|
|
27
28
|
/** decrypt AES 256 CBC; where the IV is prefixed to the buffer */
|
|
28
|
-
export declare function aesDecrypt(buffer: Buffer, key: Buffer):
|
|
29
|
+
export declare function aesDecrypt(buffer: Buffer, key: Buffer): Buffer;
|
|
29
30
|
/** decrypt AES 256 CBC */
|
|
30
|
-
export declare function aesDecryptWithIV(buffer: Buffer, key: Buffer, IV: Buffer):
|
|
31
|
-
export declare function aesEncrypt(buffer: Buffer | Uint8Array, key: Buffer):
|
|
32
|
-
export declare function aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer):
|
|
33
|
-
export declare function hmacSign(buffer: Buffer | Uint8Array, key: Buffer | Uint8Array, variant?: 'sha256' | 'sha512'):
|
|
34
|
-
export declare function sha256(buffer: Buffer):
|
|
35
|
-
export declare function md5(buffer: Buffer):
|
|
31
|
+
export declare function aesDecryptWithIV(buffer: Buffer, key: Buffer, IV: Buffer): Buffer;
|
|
32
|
+
export declare function aesEncrypt(buffer: Buffer | Uint8Array, key: Buffer): Buffer;
|
|
33
|
+
export declare function aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer): Buffer;
|
|
34
|
+
export declare function hmacSign(buffer: Buffer | Uint8Array, key: Buffer | Uint8Array, variant?: 'sha256' | 'sha512'): Buffer;
|
|
35
|
+
export declare function sha256(buffer: Buffer): Buffer;
|
|
36
|
+
export declare function md5(buffer: Buffer): Buffer;
|
|
36
37
|
export declare function hkdf(buffer: Uint8Array | Buffer, expandedLength: number, info: {
|
|
37
38
|
salt?: Buffer;
|
|
38
39
|
info?: string;
|
|
39
|
-
}):
|
|
40
|
-
export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer):
|
|
40
|
+
}): Buffer;
|
|
41
|
+
export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer): Buffer;
|