gifted-baileys 1.5.4 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/WAProto/WAProto.proto +88 -969
- package/WAProto/index.d.ts +1256 -13195
- package/WAProto/index.js +74730 -125106
- package/package.json +9 -27
- package/src/Defaults/baileys-version.json +3 -0
- package/{lib → src}/Defaults/index.js +14 -7
- package/src/Defaults/index.ts +131 -0
- package/src/README.md +1 -0
- package/src/Signal/libsignal.js +180 -0
- package/src/Signal/libsignal.ts +141 -0
- package/src/Socket/Client/abstract-socket-client.ts +19 -0
- package/{lib → src}/Socket/Client/index.js +3 -2
- package/src/Socket/Client/index.ts +3 -0
- package/src/Socket/Client/mobile-socket-client.js +78 -0
- package/src/Socket/Client/mobile-socket-client.ts +66 -0
- package/src/Socket/Client/web-socket-client.js +75 -0
- package/src/Socket/Client/web-socket-client.ts +57 -0
- package/{lib → src}/Socket/business.js +33 -28
- package/src/Socket/business.ts +281 -0
- package/{lib → src}/Socket/chats.js +176 -174
- package/src/Socket/chats.ts +1030 -0
- package/{lib → src}/Socket/groups.js +68 -80
- package/src/Socket/groups.ts +356 -0
- package/{lib → src}/Socket/index.js +1 -4
- package/src/Socket/index.ts +13 -0
- package/{lib → src}/Socket/messages-recv.js +211 -378
- package/src/Socket/messages-recv.ts +985 -0
- package/{lib → src}/Socket/messages-send.js +177 -452
- package/src/Socket/messages-send.ts +871 -0
- package/{lib → src}/Socket/newsletter.js +98 -107
- package/src/Socket/newsletter.ts +282 -0
- package/{lib → src}/Socket/registration.js +48 -56
- package/src/Socket/registration.ts +250 -0
- package/{lib → src}/Socket/socket.js +77 -77
- package/src/Socket/socket.ts +777 -0
- package/src/Store/index.ts +3 -0
- package/{lib → src}/Store/make-cache-manager-store.js +34 -25
- package/src/Store/make-cache-manager-store.ts +100 -0
- package/{lib → src}/Store/make-in-memory-store.js +32 -36
- package/src/Store/make-in-memory-store.ts +475 -0
- package/src/Store/make-ordered-dictionary.ts +86 -0
- package/{lib → src}/Store/object-repository.js +1 -1
- package/src/Store/object-repository.ts +32 -0
- package/src/Tests/test.app-state-sync.js +204 -0
- package/src/Tests/test.app-state-sync.ts +207 -0
- package/src/Tests/test.event-buffer.js +270 -0
- package/src/Tests/test.event-buffer.ts +319 -0
- package/src/Tests/test.key-store.js +76 -0
- package/src/Tests/test.key-store.ts +92 -0
- package/src/Tests/test.libsignal.js +141 -0
- package/src/Tests/test.libsignal.ts +186 -0
- package/src/Tests/test.media-download.js +93 -0
- package/src/Tests/test.media-download.ts +76 -0
- package/src/Tests/test.messages.js +33 -0
- package/src/Tests/test.messages.ts +37 -0
- package/src/Tests/utils.js +34 -0
- package/src/Tests/utils.ts +36 -0
- package/src/Types/Auth.ts +113 -0
- package/src/Types/Call.ts +15 -0
- package/src/Types/Chat.ts +106 -0
- package/{lib/Types/Contact.d.ts → src/Types/Contact.ts} +9 -8
- package/src/Types/Events.ts +93 -0
- package/src/Types/GroupMetadata.ts +53 -0
- package/src/Types/Label.ts +36 -0
- package/{lib/Types/LabelAssociation.d.ts → src/Types/LabelAssociation.ts} +22 -16
- package/src/Types/Message.ts +288 -0
- package/src/Types/Newsletter.ts +98 -0
- package/src/Types/Product.ts +85 -0
- package/src/Types/Signal.ts +68 -0
- package/{lib/Types/Socket.d.ts → src/Types/Socket.ts} +68 -61
- package/src/Types/State.ts +29 -0
- package/src/Types/index.ts +59 -0
- package/{lib → src}/Utils/auth-utils.js +90 -73
- package/src/Utils/auth-utils.ts +222 -0
- package/src/Utils/baileys-event-stream.js +92 -0
- package/src/Utils/baileys-event-stream.ts +66 -0
- package/{lib → src}/Utils/business.js +43 -15
- package/src/Utils/business.ts +275 -0
- package/{lib → src}/Utils/chat-utils.js +94 -87
- package/src/Utils/chat-utils.ts +860 -0
- package/{lib → src}/Utils/crypto.js +2 -4
- package/src/Utils/crypto.ts +131 -0
- package/src/Utils/decode-wa-message.js +211 -0
- package/src/Utils/decode-wa-message.ts +228 -0
- package/{lib → src}/Utils/event-buffer.js +13 -4
- package/src/Utils/event-buffer.ts +613 -0
- package/{lib → src}/Utils/generics.js +86 -67
- package/src/Utils/generics.ts +434 -0
- package/{lib → src}/Utils/history.js +39 -13
- package/src/Utils/history.ts +112 -0
- package/src/Utils/index.ts +17 -0
- package/{lib → src}/Utils/link-preview.js +54 -17
- package/src/Utils/link-preview.ts +122 -0
- package/src/Utils/logger.ts +3 -0
- package/src/Utils/lt-hash.ts +61 -0
- package/{lib → src}/Utils/make-mutex.js +13 -4
- package/src/Utils/make-mutex.ts +44 -0
- package/{lib → src}/Utils/messages-media.js +255 -193
- package/src/Utils/messages-media.ts +847 -0
- package/{lib → src}/Utils/messages.js +118 -588
- package/src/Utils/messages.ts +956 -0
- package/src/Utils/noise-handler.ts +197 -0
- package/{lib → src}/Utils/process-message.js +30 -27
- package/src/Utils/process-message.ts +414 -0
- package/{lib → src}/Utils/signal.js +42 -25
- package/src/Utils/signal.ts +177 -0
- package/{lib → src}/Utils/use-multi-file-auth-state.js +28 -27
- package/src/Utils/use-multi-file-auth-state.ts +90 -0
- package/{lib → src}/Utils/validate-connection.js +9 -40
- package/src/Utils/validate-connection.ts +238 -0
- package/src/WABinary/constants.ts +42 -0
- package/src/WABinary/decode.ts +265 -0
- package/{lib → src}/WABinary/encode.js +10 -16
- package/src/WABinary/encode.ts +236 -0
- package/src/WABinary/generic-utils.ts +121 -0
- package/src/WABinary/index.ts +5 -0
- package/src/WABinary/jid-utils.ts +68 -0
- package/src/WABinary/types.ts +17 -0
- package/src/WAM/BinaryInfo.ts +12 -0
- package/src/WAM/constants.ts +15382 -0
- package/src/WAM/encode.ts +174 -0
- package/src/WAM/index.ts +3 -0
- package/{lib → src}/index.js +0 -1
- package/src/index.ts +13 -0
- package/README.md +0 -1645
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/index.d.ts +0 -284
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Signal/libsignal.js +0 -161
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -15
- package/lib/Socket/Client/index.d.ts +0 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -12
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/types.d.ts +0 -17
- package/lib/Socket/Client/types.js +0 -13
- package/lib/Socket/Client/websocket.d.ts +0 -12
- package/lib/Socket/Client/websocket.js +0 -62
- package/lib/Socket/business.d.ts +0 -170
- package/lib/Socket/chats.d.ts +0 -81
- package/lib/Socket/groups.d.ts +0 -115
- package/lib/Socket/index.d.ts +0 -172
- package/lib/Socket/messages-recv.d.ts +0 -158
- package/lib/Socket/messages-send.d.ts +0 -155
- package/lib/Socket/newsletter.d.ts +0 -132
- package/lib/Socket/registration.d.ts +0 -264
- package/lib/Socket/socket.d.ts +0 -44
- package/lib/Socket/usync.d.ts +0 -37
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -109
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -107
- package/lib/Types/Events.d.ts +0 -172
- package/lib/Types/GroupMetadata.d.ts +0 -56
- package/lib/Types/Label.d.ts +0 -46
- package/lib/Types/Message.d.ts +0 -433
- package/lib/Types/Newsletter.d.ts +0 -92
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Types/USync.js +0 -2
- package/lib/Types/index.d.ts +0 -66
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/baileys-event-stream.js +0 -63
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/chat-utils.d.ts +0 -70
- package/lib/Utils/crypto.d.ts +0 -40
- package/lib/Utils/decode-wa-message.d.ts +0 -36
- package/lib/Utils/decode-wa-message.js +0 -226
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/generics.d.ts +0 -88
- package/lib/Utils/history.d.ts +0 -19
- package/lib/Utils/index.d.ts +0 -17
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -2
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/messages-media.d.ts +0 -113
- package/lib/Utils/messages.d.ts +0 -77
- package/lib/Utils/noise-handler.d.ts +0 -20
- package/lib/Utils/process-message.d.ts +0 -41
- package/lib/Utils/signal.d.ts +0 -33
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/WABinary/constants.d.ts +0 -27
- package/lib/WABinary/decode.d.ts +0 -6
- package/lib/WABinary/encode.d.ts +0 -2
- package/lib/WABinary/generic-utils.d.ts +0 -14
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -31
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -8
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -2
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -32
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -57
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -30
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/Protocols/index.js +0 -20
- package/lib/WAUSync/USyncQuery.d.ts +0 -26
- package/lib/WAUSync/USyncQuery.js +0 -79
- package/lib/WAUSync/USyncUser.d.ts +0 -10
- package/lib/WAUSync/USyncUser.js +0 -22
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/WAUSync/index.js +0 -19
- /package/{lib → src}/Defaults/phonenumber-mcc.json +0 -0
- /package/{lib → src}/Socket/Client/abstract-socket-client.js +0 -0
- /package/{lib → src}/Store/index.js +0 -0
- /package/{lib → src}/Store/make-ordered-dictionary.js +0 -0
- /package/{lib → src}/Types/Auth.js +0 -0
- /package/{lib → src}/Types/Call.js +0 -0
- /package/{lib → src}/Types/Chat.js +0 -0
- /package/{lib → src}/Types/Contact.js +0 -0
- /package/{lib → src}/Types/Events.js +0 -0
- /package/{lib → src}/Types/GroupMetadata.js +0 -0
- /package/{lib → src}/Types/Label.js +0 -0
- /package/{lib → src}/Types/LabelAssociation.js +0 -0
- /package/{lib → src}/Types/Message.js +0 -0
- /package/{lib → src}/Types/Newsletter.js +0 -0
- /package/{lib → src}/Types/Product.js +0 -0
- /package/{lib → src}/Types/Signal.js +0 -0
- /package/{lib → src}/Types/Socket.js +0 -0
- /package/{lib → src}/Types/State.js +0 -0
- /package/{lib → src}/Types/index.js +0 -0
- /package/{lib → src}/Utils/index.js +0 -0
- /package/{lib → src}/Utils/logger.js +0 -0
- /package/{lib → src}/Utils/lt-hash.js +0 -0
- /package/{lib → src}/Utils/noise-handler.js +0 -0
- /package/{lib → src}/WABinary/constants.js +0 -0
- /package/{lib → src}/WABinary/decode.js +0 -0
- /package/{lib → src}/WABinary/generic-utils.js +0 -0
- /package/{lib → src}/WABinary/index.js +0 -0
- /package/{lib → src}/WABinary/jid-utils.js +0 -0
- /package/{lib → src}/WABinary/types.js +0 -0
- /package/{lib → src}/WAM/BinaryInfo.js +0 -0
- /package/{lib → src}/WAM/constants.js +0 -0
- /package/{lib → src}/WAM/encode.js +0 -0
- /package/{lib → src}/WAM/index.js +0 -0
- /package/{lib → src}/gifted +0 -0
package/lib/Types/USync.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { BinaryNode } from '../WABinary';
|
|
2
|
-
import { USyncUser } from '../WAUSync';
|
|
3
|
-
/**
|
|
4
|
-
* Defines the interface for a USyncQuery protocol
|
|
5
|
-
*/
|
|
6
|
-
export interface USyncQueryProtocol {
|
|
7
|
-
/**
|
|
8
|
-
* The name of the protocol
|
|
9
|
-
*/
|
|
10
|
-
name: string;
|
|
11
|
-
/**
|
|
12
|
-
* Defines what goes inside the query part of a USyncQuery
|
|
13
|
-
*/
|
|
14
|
-
getQueryElement: () => BinaryNode;
|
|
15
|
-
/**
|
|
16
|
-
* Defines what goes inside the user part of a USyncQuery
|
|
17
|
-
*/
|
|
18
|
-
getUserElement: (user: USyncUser) => BinaryNode | null;
|
|
19
|
-
/**
|
|
20
|
-
* Parse the result of the query
|
|
21
|
-
* @param data Data from the result
|
|
22
|
-
* @returns Whatever the protocol is supposed to return
|
|
23
|
-
*/
|
|
24
|
-
parser: (data: BinaryNode) => unknown;
|
|
25
|
-
}
|
package/lib/Types/USync.js
DELETED
package/lib/Types/index.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export * from './Auth';
|
|
2
|
-
export * from './GroupMetadata';
|
|
3
|
-
export * from './Chat';
|
|
4
|
-
export * from './Contact';
|
|
5
|
-
export * from './State';
|
|
6
|
-
export * from './Message';
|
|
7
|
-
export * from './Newsletter';
|
|
8
|
-
export * from './Socket';
|
|
9
|
-
export * from './Events';
|
|
10
|
-
export * from './Product';
|
|
11
|
-
export * from './Call';
|
|
12
|
-
export * from './Signal';
|
|
13
|
-
import { AuthenticationState } from './Auth';
|
|
14
|
-
import { SocketConfig } from './Socket';
|
|
15
|
-
export type UserFacingSocketConfig = Partial<SocketConfig> & {
|
|
16
|
-
auth: AuthenticationState;
|
|
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
|
-
export declare enum DisconnectReason {
|
|
28
|
-
connectionClosed = 428,
|
|
29
|
-
connectionLost = 408,
|
|
30
|
-
connectionReplaced = 440,
|
|
31
|
-
timedOut = 408,
|
|
32
|
-
loggedOut = 401,
|
|
33
|
-
badSession = 500,
|
|
34
|
-
restartRequired = 515,
|
|
35
|
-
multideviceMismatch = 411,
|
|
36
|
-
forbidden = 403,
|
|
37
|
-
unavailableService = 503
|
|
38
|
-
}
|
|
39
|
-
export type WAInitResponse = {
|
|
40
|
-
ref: string;
|
|
41
|
-
ttl: number;
|
|
42
|
-
status: 200;
|
|
43
|
-
};
|
|
44
|
-
export type WABusinessHoursConfig = {
|
|
45
|
-
day_of_week: string;
|
|
46
|
-
mode: string;
|
|
47
|
-
open_time?: number;
|
|
48
|
-
close_time?: number;
|
|
49
|
-
};
|
|
50
|
-
export type WABusinessProfile = {
|
|
51
|
-
description: string;
|
|
52
|
-
email: string | undefined;
|
|
53
|
-
business_hours: {
|
|
54
|
-
timezone?: string;
|
|
55
|
-
config?: WABusinessHoursConfig[];
|
|
56
|
-
business_config?: WABusinessHoursConfig[];
|
|
57
|
-
};
|
|
58
|
-
website: string[];
|
|
59
|
-
category?: string;
|
|
60
|
-
wid?: string;
|
|
61
|
-
address?: string;
|
|
62
|
-
};
|
|
63
|
-
export type CurveKeyPair = {
|
|
64
|
-
private: Uint8Array;
|
|
65
|
-
public: Uint8Array;
|
|
66
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Logger } from 'pino';
|
|
2
|
-
import type { AuthenticationCreds, CacheStore, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types';
|
|
3
|
-
/**
|
|
4
|
-
* Adds caching capability to a SignalKeyStore
|
|
5
|
-
* @param store the store to add caching to
|
|
6
|
-
* @param logger to log trace events
|
|
7
|
-
* @param _cache cache store to use
|
|
8
|
-
*/
|
|
9
|
-
export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger: Logger, _cache?: CacheStore): SignalKeyStore;
|
|
10
|
-
/**
|
|
11
|
-
* Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
|
|
12
|
-
* this allows batch read & write operations & improves the performance of the lib
|
|
13
|
-
* @param state the key store to apply this capability to
|
|
14
|
-
* @param logger logger to log events
|
|
15
|
-
* @returns SignalKeyStore with transaction capability
|
|
16
|
-
*/
|
|
17
|
-
export declare const addTransactionCapability: (state: SignalKeyStore, logger: Logger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
|
|
18
|
-
export declare const initAuthCreds: () => AuthenticationCreds;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { BaileysEventEmitter } from '../Types';
|
|
2
|
-
/**
|
|
3
|
-
* Captures events from a baileys event emitter & stores them in a file
|
|
4
|
-
* @param ev The event emitter to read events from
|
|
5
|
-
* @param filename File to save to
|
|
6
|
-
*/
|
|
7
|
-
export declare const captureEventStream: (ev: BaileysEventEmitter, filename: string) => void;
|
|
8
|
-
/**
|
|
9
|
-
* Read event file and emit events from there
|
|
10
|
-
* @param filename filename containing event data
|
|
11
|
-
* @param delayIntervalMs delay between each event emit
|
|
12
|
-
*/
|
|
13
|
-
export declare const readAndEmitEventStream: (filename: string, delayIntervalMs?: number) => {
|
|
14
|
-
ev: BaileysEventEmitter;
|
|
15
|
-
task: Promise<void>;
|
|
16
|
-
};
|
|
@@ -1,63 +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.readAndEmitEventStream = exports.captureEventStream = void 0;
|
|
7
|
-
const events_1 = __importDefault(require("events"));
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const promises_1 = require("fs/promises");
|
|
10
|
-
const readline_1 = require("readline");
|
|
11
|
-
const generics_1 = require("./generics");
|
|
12
|
-
const make_mutex_1 = require("./make-mutex");
|
|
13
|
-
/**
|
|
14
|
-
* Captures events from a baileys event emitter & stores them in a file
|
|
15
|
-
* @param ev The event emitter to read events from
|
|
16
|
-
* @param filename File to save to
|
|
17
|
-
*/
|
|
18
|
-
const captureEventStream = (ev, filename) => {
|
|
19
|
-
const oldEmit = ev.emit;
|
|
20
|
-
// write mutex so data is appended in order
|
|
21
|
-
const writeMutex = (0, make_mutex_1.makeMutex)();
|
|
22
|
-
// monkey patch eventemitter to capture all events
|
|
23
|
-
ev.emit = function (...args) {
|
|
24
|
-
const content = JSON.stringify({ timestamp: Date.now(), event: args[0], data: args[1] }) + '\n';
|
|
25
|
-
const result = oldEmit.apply(ev, args);
|
|
26
|
-
writeMutex.mutex(async () => {
|
|
27
|
-
await (0, promises_1.writeFile)(filename, content, { flag: 'a' });
|
|
28
|
-
});
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.captureEventStream = captureEventStream;
|
|
33
|
-
/**
|
|
34
|
-
* Read event file and emit events from there
|
|
35
|
-
* @param filename filename containing event data
|
|
36
|
-
* @param delayIntervalMs delay between each event emit
|
|
37
|
-
*/
|
|
38
|
-
const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
|
|
39
|
-
const ev = new events_1.default();
|
|
40
|
-
const fireEvents = async () => {
|
|
41
|
-
// from: https://stackoverflow.com/questions/6156501/read-a-file-one-line-at-a-time-in-node-js
|
|
42
|
-
const fileStream = (0, fs_1.createReadStream)(filename);
|
|
43
|
-
const rl = (0, readline_1.createInterface)({
|
|
44
|
-
input: fileStream,
|
|
45
|
-
crlfDelay: Infinity
|
|
46
|
-
});
|
|
47
|
-
// Note: we use the crlfDelay option to recognize all instances of CR LF
|
|
48
|
-
// ('\r\n') in input.txt as a single line break.
|
|
49
|
-
for await (const line of rl) {
|
|
50
|
-
if (line) {
|
|
51
|
-
const { event, data } = JSON.parse(line);
|
|
52
|
-
ev.emit(event, data);
|
|
53
|
-
delayIntervalMs && await (0, generics_1.delay)(delayIntervalMs);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
fileStream.close();
|
|
57
|
-
};
|
|
58
|
-
return {
|
|
59
|
-
ev,
|
|
60
|
-
task: fireEvents()
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
exports.readAndEmitEventStream = readAndEmitEventStream;
|
package/lib/Utils/business.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate, WAMediaUpload, WAMediaUploadFunction } from '../Types';
|
|
2
|
-
import { BinaryNode } from '../WABinary';
|
|
3
|
-
export declare const parseCatalogNode: (node: BinaryNode) => {
|
|
4
|
-
products: Product[];
|
|
5
|
-
nextPageCursor: any;
|
|
6
|
-
};
|
|
7
|
-
export declare const parseCollectionsNode: (node: BinaryNode) => {
|
|
8
|
-
collections: CatalogCollection[];
|
|
9
|
-
};
|
|
10
|
-
export declare const parseOrderDetailsNode: (node: BinaryNode) => OrderDetails;
|
|
11
|
-
export declare const toProductNode: (productId: string | undefined, product: ProductCreate | ProductUpdate) => BinaryNode;
|
|
12
|
-
export declare const parseProductNode: (productNode: BinaryNode) => Product;
|
|
13
|
-
/**
|
|
14
|
-
* Uploads images not already uploaded to WA's servers
|
|
15
|
-
*/
|
|
16
|
-
export declare function uploadingNecessaryImagesOfProduct<T extends ProductUpdate | ProductCreate>(product: T, waUploadToServer: WAMediaUploadFunction, timeoutMs?: number): Promise<T>;
|
|
17
|
-
/**
|
|
18
|
-
* Uploads images not already uploaded to WA's servers
|
|
19
|
-
*/
|
|
20
|
-
export declare const uploadingNecessaryImages: (images: WAMediaUpload[], waUploadToServer: WAMediaUploadFunction, timeoutMs?: number) => Promise<{
|
|
21
|
-
url: string;
|
|
22
|
-
}[]>;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import type { Logger } from 'pino';
|
|
3
|
-
import { proto } from '../../WAProto';
|
|
4
|
-
import { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types';
|
|
5
|
-
import { BinaryNode } from '../WABinary';
|
|
6
|
-
type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
|
|
7
|
-
export type ChatMutationMap = {
|
|
8
|
-
[index: string]: ChatMutation;
|
|
9
|
-
};
|
|
10
|
-
export declare const newLTHashState: () => LTHashState;
|
|
11
|
-
export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, operation }: WAPatchCreate, myAppStateKeyId: string, state: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey) => Promise<{
|
|
12
|
-
patch: proto.ISyncdPatch;
|
|
13
|
-
state: LTHashState;
|
|
14
|
-
}>;
|
|
15
|
-
export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
|
16
|
-
hash: any;
|
|
17
|
-
indexValueMap: {
|
|
18
|
-
[indexMacBase64: string]: {
|
|
19
|
-
valueMac: Uint8Array | Buffer;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
}>;
|
|
23
|
-
export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
|
24
|
-
hash: any;
|
|
25
|
-
indexValueMap: {
|
|
26
|
-
[indexMacBase64: string]: {
|
|
27
|
-
valueMac: Uint8Array | Buffer;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
}>;
|
|
31
|
-
export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<{}>) => Promise<{
|
|
32
|
-
critical_block: {
|
|
33
|
-
patches: proto.ISyncdPatch[];
|
|
34
|
-
hasMorePatches: boolean;
|
|
35
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
36
|
-
};
|
|
37
|
-
critical_unblock_low: {
|
|
38
|
-
patches: proto.ISyncdPatch[];
|
|
39
|
-
hasMorePatches: boolean;
|
|
40
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
41
|
-
};
|
|
42
|
-
regular_high: {
|
|
43
|
-
patches: proto.ISyncdPatch[];
|
|
44
|
-
hasMorePatches: boolean;
|
|
45
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
46
|
-
};
|
|
47
|
-
regular_low: {
|
|
48
|
-
patches: proto.ISyncdPatch[];
|
|
49
|
-
hasMorePatches: boolean;
|
|
50
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
51
|
-
};
|
|
52
|
-
regular: {
|
|
53
|
-
patches: proto.ISyncdPatch[];
|
|
54
|
-
hasMorePatches: boolean;
|
|
55
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
56
|
-
};
|
|
57
|
-
}>;
|
|
58
|
-
export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<any>;
|
|
59
|
-
export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<proto.SyncdMutations>;
|
|
60
|
-
export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
|
|
61
|
-
state: LTHashState;
|
|
62
|
-
mutationMap: ChatMutationMap;
|
|
63
|
-
}>;
|
|
64
|
-
export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<{}>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
|
|
65
|
-
state: LTHashState;
|
|
66
|
-
mutationMap: ChatMutationMap;
|
|
67
|
-
}>;
|
|
68
|
-
export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
|
|
69
|
-
export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: Logger) => void;
|
|
70
|
-
export {};
|
package/lib/Utils/crypto.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { KeyPair } from '../Types';
|
|
2
|
-
/** prefix version byte to the pub keys, required for some curve crypto functions */
|
|
3
|
-
export declare const generateSignalPubKey: (pubKey: Uint8Array | Buffer) => any;
|
|
4
|
-
export declare const Curve: {
|
|
5
|
-
generateKeyPair: () => KeyPair;
|
|
6
|
-
sharedKey: (privateKey: Uint8Array, publicKey: Uint8Array) => any;
|
|
7
|
-
sign: (privateKey: Uint8Array, buf: Uint8Array) => any;
|
|
8
|
-
verify: (pubKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare const signedKeyPair: (identityKeyPair: KeyPair, keyId: number) => {
|
|
11
|
-
keyPair: KeyPair;
|
|
12
|
-
signature: any;
|
|
13
|
-
keyId: number;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* encrypt AES 256 GCM;
|
|
17
|
-
* where the tag tag is suffixed to the ciphertext
|
|
18
|
-
* */
|
|
19
|
-
export declare function aesEncryptGCM(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): any;
|
|
20
|
-
/**
|
|
21
|
-
* decrypt AES 256 GCM;
|
|
22
|
-
* where the auth tag is suffixed to the ciphertext
|
|
23
|
-
* */
|
|
24
|
-
export declare function aesDecryptGCM(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): any;
|
|
25
|
-
export declare function aesEncryptCTR(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array): any;
|
|
26
|
-
export declare function aesDecryptCTR(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array): any;
|
|
27
|
-
/** decrypt AES 256 CBC; where the IV is prefixed to the buffer */
|
|
28
|
-
export declare function aesDecrypt(buffer: Buffer, key: Buffer): any;
|
|
29
|
-
/** decrypt AES 256 CBC */
|
|
30
|
-
export declare function aesDecryptWithIV(buffer: Buffer, key: Buffer, IV: Buffer): any;
|
|
31
|
-
export declare function aesEncrypt(buffer: Buffer | Uint8Array, key: Buffer): any;
|
|
32
|
-
export declare function aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer): any;
|
|
33
|
-
export declare function hmacSign(buffer: Buffer | Uint8Array, key: Buffer | Uint8Array, variant?: 'sha256' | 'sha512'): any;
|
|
34
|
-
export declare function sha256(buffer: Buffer): any;
|
|
35
|
-
export declare function md5(buffer: Buffer): any;
|
|
36
|
-
export declare function hkdf(buffer: Uint8Array | Buffer, expandedLength: number, info: {
|
|
37
|
-
salt?: Buffer;
|
|
38
|
-
info?: string;
|
|
39
|
-
}): any;
|
|
40
|
-
export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer): Promise<any>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Logger } from 'pino';
|
|
2
|
-
import { proto } from '../../WAProto';
|
|
3
|
-
import { SignalRepository } from '../Types';
|
|
4
|
-
import { BinaryNode } from '../WABinary';
|
|
5
|
-
export declare const NO_MESSAGE_FOUND_ERROR_TEXT = "Message absent from node";
|
|
6
|
-
export declare const MISSING_KEYS_ERROR_TEXT = "Key used already or never filled";
|
|
7
|
-
export declare const NACK_REASONS: {
|
|
8
|
-
ParsingError: number;
|
|
9
|
-
UnrecognizedStanza: number;
|
|
10
|
-
UnrecognizedStanzaClass: number;
|
|
11
|
-
UnrecognizedStanzaType: number;
|
|
12
|
-
InvalidProtobuf: number;
|
|
13
|
-
InvalidHostedCompanionStanza: number;
|
|
14
|
-
MissingMessageSecret: number;
|
|
15
|
-
SignalErrorOldCounter: number;
|
|
16
|
-
MessageDeletedOnPeer: number;
|
|
17
|
-
UnhandledError: number;
|
|
18
|
-
UnsupportedAdminRevoke: number;
|
|
19
|
-
UnsupportedLIDGroup: number;
|
|
20
|
-
DBOperationFailed: number;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Decode the received node as a message.
|
|
24
|
-
* @note this will only parse the message, not decrypt it
|
|
25
|
-
*/
|
|
26
|
-
export declare function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: string): {
|
|
27
|
-
fullMessage: proto.IWebMessageInfo;
|
|
28
|
-
author: string;
|
|
29
|
-
sender: string;
|
|
30
|
-
};
|
|
31
|
-
export declare const decryptMessageNode: (stanza: BinaryNode, meId: string, meLid: string, repository: SignalRepository, logger: Logger) => {
|
|
32
|
-
fullMessage: proto.IWebMessageInfo;
|
|
33
|
-
category: string;
|
|
34
|
-
author: string;
|
|
35
|
-
decrypt(): Promise<void>;
|
|
36
|
-
};
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decryptMessageNode = exports.NACK_REASONS = exports.MISSING_KEYS_ERROR_TEXT = exports.NO_MESSAGE_FOUND_ERROR_TEXT = void 0;
|
|
4
|
-
exports.decodeMessageNode = decodeMessageNode;
|
|
5
|
-
const boom_1 = require("@hapi/boom");
|
|
6
|
-
const WAProto_1 = require("../../WAProto");
|
|
7
|
-
const WABinary_1 = require("../WABinary");
|
|
8
|
-
const generics_1 = require("./generics");
|
|
9
|
-
exports.NO_MESSAGE_FOUND_ERROR_TEXT = 'Message absent from node';
|
|
10
|
-
exports.MISSING_KEYS_ERROR_TEXT = 'Key used already or never filled';
|
|
11
|
-
exports.NACK_REASONS = {
|
|
12
|
-
ParsingError: 487,
|
|
13
|
-
UnrecognizedStanza: 488,
|
|
14
|
-
UnrecognizedStanzaClass: 489,
|
|
15
|
-
UnrecognizedStanzaType: 490,
|
|
16
|
-
InvalidProtobuf: 491,
|
|
17
|
-
InvalidHostedCompanionStanza: 493,
|
|
18
|
-
MissingMessageSecret: 495,
|
|
19
|
-
SignalErrorOldCounter: 496,
|
|
20
|
-
MessageDeletedOnPeer: 499,
|
|
21
|
-
UnhandledError: 500,
|
|
22
|
-
UnsupportedAdminRevoke: 550,
|
|
23
|
-
UnsupportedLIDGroup: 551,
|
|
24
|
-
DBOperationFailed: 552
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Decode the received node as a message.
|
|
28
|
-
* @note this will only parse the message, not decrypt it
|
|
29
|
-
*/
|
|
30
|
-
function decodeMessageNode(stanza, meId, meLid) {
|
|
31
|
-
var _a, _b;
|
|
32
|
-
let msgType;
|
|
33
|
-
let chatId;
|
|
34
|
-
let author;
|
|
35
|
-
const msgId = stanza.attrs.id;
|
|
36
|
-
const from = stanza.attrs.from;
|
|
37
|
-
const participant = stanza.attrs.participant;
|
|
38
|
-
const recipient = stanza.attrs.recipient;
|
|
39
|
-
const isMe = (jid) => (0, WABinary_1.areJidsSameUser)(jid, meId);
|
|
40
|
-
const isMeLid = (jid) => (0, WABinary_1.areJidsSameUser)(jid, meLid);
|
|
41
|
-
if ((0, WABinary_1.isJidUser)(from)) {
|
|
42
|
-
if (recipient) {
|
|
43
|
-
if (!isMe(from)) {
|
|
44
|
-
throw new boom_1.Boom('receipient present, but msg not from me', { data: stanza });
|
|
45
|
-
}
|
|
46
|
-
chatId = recipient;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
chatId = from;
|
|
50
|
-
}
|
|
51
|
-
msgType = 'chat';
|
|
52
|
-
author = from;
|
|
53
|
-
}
|
|
54
|
-
else if ((0, WABinary_1.isLidUser)(from)) {
|
|
55
|
-
if (recipient) {
|
|
56
|
-
if (!isMeLid(from)) {
|
|
57
|
-
throw new boom_1.Boom('receipient present, but msg not from me', { data: stanza });
|
|
58
|
-
}
|
|
59
|
-
chatId = recipient;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
chatId = from;
|
|
63
|
-
}
|
|
64
|
-
msgType = 'chat';
|
|
65
|
-
author = from;
|
|
66
|
-
}
|
|
67
|
-
else if ((0, WABinary_1.isJidGroup)(from)) {
|
|
68
|
-
if (!participant) {
|
|
69
|
-
throw new boom_1.Boom('No participant in group message');
|
|
70
|
-
}
|
|
71
|
-
msgType = 'group';
|
|
72
|
-
author = participant;
|
|
73
|
-
chatId = from;
|
|
74
|
-
}
|
|
75
|
-
else if ((0, WABinary_1.isJidBroadcast)(from)) {
|
|
76
|
-
if (!participant) {
|
|
77
|
-
throw new boom_1.Boom('No participant in group message');
|
|
78
|
-
}
|
|
79
|
-
const isParticipantMe = isMe(participant);
|
|
80
|
-
if ((0, WABinary_1.isJidStatusBroadcast)(from)) {
|
|
81
|
-
msgType = isParticipantMe ? 'direct_peer_status' : 'other_status';
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
msgType = isParticipantMe ? 'peer_broadcast' : 'other_broadcast';
|
|
85
|
-
}
|
|
86
|
-
chatId = from;
|
|
87
|
-
author = participant;
|
|
88
|
-
}
|
|
89
|
-
else if ((0, WABinary_1.isJidNewsLetter)(from)) {
|
|
90
|
-
msgType = 'newsletter';
|
|
91
|
-
author = from;
|
|
92
|
-
chatId = from;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
throw new boom_1.Boom('Unknown message type', { data: stanza });
|
|
96
|
-
}
|
|
97
|
-
const fromMe = (0, WABinary_1.isJidNewsLetter)(from) ? !!((_a = stanza.attrs) === null || _a === void 0 ? void 0 : _a.is_sender) : ((0, WABinary_1.isLidUser)(from) ? isMeLid : isMe)(stanza.attrs.participant || stanza.attrs.from);
|
|
98
|
-
const pushname = stanza.attrs.notify;
|
|
99
|
-
const key = {
|
|
100
|
-
remoteJid: chatId,
|
|
101
|
-
fromMe,
|
|
102
|
-
id: msgId,
|
|
103
|
-
participant
|
|
104
|
-
};
|
|
105
|
-
const fullMessage = {
|
|
106
|
-
key,
|
|
107
|
-
messageTimestamp: +stanza.attrs.t,
|
|
108
|
-
pushName: pushname,
|
|
109
|
-
broadcast: (0, WABinary_1.isJidBroadcast)(from)
|
|
110
|
-
};
|
|
111
|
-
if (msgType === 'newsletter') {
|
|
112
|
-
fullMessage.newsletterServerId = +((_b = stanza.attrs) === null || _b === void 0 ? void 0 : _b.server_id);
|
|
113
|
-
}
|
|
114
|
-
if (key.fromMe) {
|
|
115
|
-
fullMessage.status = WAProto_1.proto.WebMessageInfo.Status.SERVER_ACK;
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
fullMessage,
|
|
119
|
-
author,
|
|
120
|
-
sender: msgType === 'chat' ? author : chatId
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
124
|
-
const { fullMessage, author, sender } = decodeMessageNode(stanza, meId, meLid);
|
|
125
|
-
return {
|
|
126
|
-
fullMessage,
|
|
127
|
-
category: stanza.attrs.category,
|
|
128
|
-
author,
|
|
129
|
-
async decrypt() {
|
|
130
|
-
var _a;
|
|
131
|
-
let decryptables = 0;
|
|
132
|
-
if ((0, WABinary_1.isJidNewsLetter)(fullMessage.key.remoteJid)) {
|
|
133
|
-
const node = (0, WABinary_1.getBinaryNodeChild)(stanza, 'plaintext');
|
|
134
|
-
const msg = WAProto_1.proto.Message.decode(node === null || node === void 0 ? void 0 : node.content);
|
|
135
|
-
if (msg.senderKeyDistributionMessage) {
|
|
136
|
-
//eslint-disable-next-line max-depth
|
|
137
|
-
try {
|
|
138
|
-
await repository.processSenderKeyDistributionMessage({
|
|
139
|
-
authorJid: author,
|
|
140
|
-
item: msg.senderKeyDistributionMessage
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
catch (err) {
|
|
144
|
-
logger.error({ key: fullMessage.key, err }, 'failed to decrypt message');
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
fullMessage.message = msg;
|
|
148
|
-
decryptables += 1;
|
|
149
|
-
}
|
|
150
|
-
else if (Array.isArray(stanza.content)) {
|
|
151
|
-
for (const { tag, attrs, content } of stanza.content) {
|
|
152
|
-
if (tag === 'verified_name' && content instanceof Uint8Array) {
|
|
153
|
-
const cert = WAProto_1.proto.VerifiedNameCertificate.decode(content);
|
|
154
|
-
const details = WAProto_1.proto.VerifiedNameCertificate.Details.decode(cert.details);
|
|
155
|
-
fullMessage.verifiedBizName = details.verifiedName;
|
|
156
|
-
}
|
|
157
|
-
if (tag !== 'enc' && tag !== 'plaintext') {
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
if (!(content instanceof Uint8Array)) {
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
decryptables += 1;
|
|
164
|
-
let msgBuffer;
|
|
165
|
-
try {
|
|
166
|
-
const e2eType = tag === 'plaintext' ? 'plaintext' : attrs.type;
|
|
167
|
-
switch (e2eType) {
|
|
168
|
-
case 'skmsg':
|
|
169
|
-
msgBuffer = await repository.decryptGroupMessage({
|
|
170
|
-
group: sender,
|
|
171
|
-
authorJid: author,
|
|
172
|
-
msg: content
|
|
173
|
-
});
|
|
174
|
-
break;
|
|
175
|
-
case 'pkmsg':
|
|
176
|
-
case 'msg':
|
|
177
|
-
const user = (0, WABinary_1.isJidUser)(sender) ? sender : author;
|
|
178
|
-
msgBuffer = await repository.decryptMessage({
|
|
179
|
-
jid: user,
|
|
180
|
-
type: e2eType,
|
|
181
|
-
ciphertext: content
|
|
182
|
-
});
|
|
183
|
-
break;
|
|
184
|
-
case 'plaintext':
|
|
185
|
-
msgBuffer = content;
|
|
186
|
-
break;
|
|
187
|
-
default:
|
|
188
|
-
throw new Error(`Unknown e2e type: ${e2eType}`);
|
|
189
|
-
}
|
|
190
|
-
let msg = WAProto_1.proto.Message.decode(e2eType !== 'plaintext' ? (0, generics_1.unpadRandomMax16)(msgBuffer) : msgBuffer);
|
|
191
|
-
msg = ((_a = msg.deviceSentMessage) === null || _a === void 0 ? void 0 : _a.message) || msg;
|
|
192
|
-
if (msg.senderKeyDistributionMessage) {
|
|
193
|
-
//eslint-disable-next-line max-depth
|
|
194
|
-
try {
|
|
195
|
-
await repository.processSenderKeyDistributionMessage({
|
|
196
|
-
authorJid: author,
|
|
197
|
-
item: msg.senderKeyDistributionMessage
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
catch (err) {
|
|
201
|
-
logger.error({ key: fullMessage.key, err }, 'failed to decrypt message');
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (fullMessage.message) {
|
|
205
|
-
Object.assign(fullMessage.message, msg);
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
fullMessage.message = msg;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
catch (err) {
|
|
212
|
-
logger.error({ key: fullMessage.key, err }, 'failed to decrypt message');
|
|
213
|
-
fullMessage.messageStubType = WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT;
|
|
214
|
-
fullMessage.messageStubParameters = [err.message];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
// if nothing was found to decrypt
|
|
219
|
-
if (!decryptables) {
|
|
220
|
-
fullMessage.messageStubType = WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT;
|
|
221
|
-
fullMessage.messageStubParameters = [exports.NO_MESSAGE_FOUND_ERROR_TEXT];
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
};
|
|
226
|
-
exports.decryptMessageNode = decryptMessageNode;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Logger } from 'pino';
|
|
2
|
-
import { BaileysEventEmitter, BaileysEventMap } from '../Types';
|
|
3
|
-
/**
|
|
4
|
-
* A map that contains a list of all events that have been triggered
|
|
5
|
-
*
|
|
6
|
-
* Note, this can contain different type of events
|
|
7
|
-
* this can make processing events extremely efficient -- since everything
|
|
8
|
-
* can be done in a single transaction
|
|
9
|
-
*/
|
|
10
|
-
type BaileysEventData = Partial<BaileysEventMap>;
|
|
11
|
-
type BaileysBufferableEventEmitter = BaileysEventEmitter & {
|
|
12
|
-
/** Use to process events in a batch */
|
|
13
|
-
process(handler: (events: BaileysEventData) => void | Promise<void>): (() => void);
|
|
14
|
-
/**
|
|
15
|
-
* starts buffering events, call flush() to release them
|
|
16
|
-
* */
|
|
17
|
-
buffer(): void;
|
|
18
|
-
/** buffers all events till the promise completes */
|
|
19
|
-
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
20
|
-
/**
|
|
21
|
-
* flushes all buffered events
|
|
22
|
-
* @param force if true, will flush all data regardless of any pending buffers
|
|
23
|
-
* @returns returns true if the flush actually happened, otherwise false
|
|
24
|
-
*/
|
|
25
|
-
flush(force?: boolean): boolean;
|
|
26
|
-
/** is there an ongoing buffer */
|
|
27
|
-
isBuffering(): boolean;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* The event buffer logically consolidates different events into a single event
|
|
31
|
-
* making the data processing more efficient.
|
|
32
|
-
* @param ev the baileys event emitter
|
|
33
|
-
*/
|
|
34
|
-
export declare const makeEventBuffer: (logger: Logger) => BaileysBufferableEventEmitter;
|
|
35
|
-
export {};
|