@jkt48connect-corp/baileys 7.2.9 → 7.3.1
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.d.ts +48955 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +284 -0
- package/lib/Defaults/index.js +5 -5
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +15 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -0
- package/lib/Socket/Client/types.d.ts +17 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
- package/lib/Socket/business.d.ts +170 -0
- package/lib/Socket/chats.d.ts +81 -0
- package/lib/Socket/chats.js +51 -48
- package/lib/Socket/groups.d.ts +115 -0
- package/lib/Socket/groups.js +1 -0
- package/lib/Socket/index.d.ts +172 -0
- package/lib/Socket/messages-recv.d.ts +158 -0
- package/lib/Socket/messages-send.d.ts +155 -0
- package/lib/Socket/messages-send.js +105 -77
- package/lib/Socket/newsletter.d.ts +132 -0
- package/lib/Socket/registration.d.ts +264 -0
- package/lib/Socket/socket.d.ts +44 -0
- package/lib/Socket/socket.js +15 -8
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +24 -13
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Types/Auth.d.ts +109 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Chat.d.ts +107 -0
- package/lib/Types/Contact.d.ts +19 -0
- package/lib/Types/Events.d.ts +172 -0
- package/lib/Types/GroupMetadata.d.ts +56 -0
- package/lib/Types/Label.d.ts +46 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/Message.d.ts +433 -0
- package/lib/Types/Newsletter.d.ts +92 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Socket.d.ts +116 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/crypto.d.ts +40 -0
- package/lib/Utils/decode-wa-message.d.ts +36 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/generics.d.ts +88 -0
- package/lib/Utils/generics.js +2 -2
- package/lib/Utils/history.d.ts +19 -0
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/logger.d.ts +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/messages-media.d.ts +113 -0
- package/lib/Utils/messages.d.ts +77 -0
- package/lib/Utils/messages.js +73 -12
- package/lib/Utils/messages.js.bak +1249 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/signal.d.ts +33 -0
- package/lib/Utils/signal.js +11 -19
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-multi-file-auth-state.js +1 -7
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +23 -12
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/decode.d.ts +6 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/generic-utils.d.ts +14 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/jid-utils.d.ts +31 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/USyncQuery.d.ts +26 -0
- package/lib/WAUSync/USyncUser.d.ts +10 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/index.js +1 -3
- package/package.json +7 -4
- package/LICENSE +0 -21
@@ -0,0 +1,20 @@
|
|
1
|
+
import { Logger } from 'pino';
|
2
|
+
import { proto } from '../../WAProto';
|
3
|
+
import { KeyPair } from '../Types';
|
4
|
+
import { BinaryNode } from '../WABinary';
|
5
|
+
export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, mobile, logger, routingInfo }: {
|
6
|
+
keyPair: KeyPair;
|
7
|
+
NOISE_HEADER: Uint8Array;
|
8
|
+
mobile: boolean;
|
9
|
+
logger: Logger;
|
10
|
+
routingInfo?: Buffer | undefined;
|
11
|
+
}) => {
|
12
|
+
encrypt: (plaintext: Uint8Array) => any;
|
13
|
+
decrypt: (ciphertext: Uint8Array) => any;
|
14
|
+
authenticate: (data: Uint8Array) => void;
|
15
|
+
mixIntoKey: (data: Uint8Array) => void;
|
16
|
+
finishInit: () => void;
|
17
|
+
processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => any;
|
18
|
+
encodeFrame: (data: Buffer | Uint8Array) => any;
|
19
|
+
decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => void;
|
20
|
+
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
2
|
+
import type { Logger } from 'pino';
|
3
|
+
import { proto } from '../../WAProto';
|
4
|
+
import { AuthenticationCreds, BaileysEventEmitter, SignalKeyStoreWithTransaction, SocketConfig } from '../Types';
|
5
|
+
type ProcessMessageContext = {
|
6
|
+
shouldProcessHistoryMsg: boolean;
|
7
|
+
creds: AuthenticationCreds;
|
8
|
+
keyStore: SignalKeyStoreWithTransaction;
|
9
|
+
ev: BaileysEventEmitter;
|
10
|
+
getMessage: SocketConfig['getMessage'];
|
11
|
+
logger?: Logger;
|
12
|
+
options: AxiosRequestConfig<{}>;
|
13
|
+
};
|
14
|
+
/** Cleans a received message to further processing */
|
15
|
+
export declare const cleanMessage: (message: proto.IWebMessageInfo, meId: string) => void;
|
16
|
+
export declare const isRealMessage: (message: proto.IWebMessageInfo, meId: string) => boolean | undefined;
|
17
|
+
export declare const shouldIncrementChatUnread: (message: proto.IWebMessageInfo) => boolean;
|
18
|
+
/**
|
19
|
+
* Get the ID of the chat from the given key.
|
20
|
+
* Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
|
21
|
+
*/
|
22
|
+
export declare const getChatId: ({ remoteJid, participant, fromMe }: proto.IMessageKey) => string;
|
23
|
+
type PollContext = {
|
24
|
+
/** normalised jid of the person that created the poll */
|
25
|
+
pollCreatorJid: string;
|
26
|
+
/** ID of the poll creation message */
|
27
|
+
pollMsgId: string;
|
28
|
+
/** poll creation message enc key */
|
29
|
+
pollEncKey: Uint8Array;
|
30
|
+
/** jid of the person that voted */
|
31
|
+
voterJid: string;
|
32
|
+
};
|
33
|
+
/**
|
34
|
+
* Decrypt a poll vote
|
35
|
+
* @param vote encrypted vote
|
36
|
+
* @param ctx additional info about the poll required for decryption
|
37
|
+
* @returns list of SHA256 options
|
38
|
+
*/
|
39
|
+
export declare function decryptPollVote({ encPayload, encIv }: proto.Message.IPollEncValue, { pollCreatorJid, pollMsgId, pollEncKey, voterJid, }: PollContext): proto.Message.PollVoteMessage;
|
40
|
+
declare const processMessage: (message: proto.IWebMessageInfo, { shouldProcessHistoryMsg, ev, creds, keyStore, logger, options, getMessage }: ProcessMessageContext) => Promise<void>;
|
41
|
+
export default processMessage;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { SignalRepository } from '../Types';
|
2
|
+
import { AuthenticationCreds, AuthenticationState, KeyPair, SignalIdentity, SignalKeyStore, SignedKeyPair } from '../Types/Auth';
|
3
|
+
import { BinaryNode, JidWithDevice } from '../WABinary';
|
4
|
+
import { USyncQueryResultList } from '../WAUSync';
|
5
|
+
export declare const createSignalIdentity: (wid: string, accountSignatureKey: Uint8Array) => SignalIdentity;
|
6
|
+
export declare const getPreKeys: ({ get }: SignalKeyStore, min: number, limit: number) => Promise<{
|
7
|
+
[id: string]: KeyPair;
|
8
|
+
}>;
|
9
|
+
export declare const generateOrGetPreKeys: (creds: AuthenticationCreds, range: number) => {
|
10
|
+
newPreKeys: {
|
11
|
+
[id: number]: KeyPair;
|
12
|
+
};
|
13
|
+
lastPreKeyId: number;
|
14
|
+
preKeysRange: readonly [number, number];
|
15
|
+
};
|
16
|
+
export declare const xmppSignedPreKey: (key: SignedKeyPair) => BinaryNode;
|
17
|
+
export declare const xmppPreKey: (pair: KeyPair, id: number) => BinaryNode;
|
18
|
+
export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository: SignalRepository) => Promise<void>;
|
19
|
+
export declare const extractDeviceJids: (result: USyncQueryResultList[], myJid: string, excludeZeroDevices: boolean) => JidWithDevice[];
|
20
|
+
/**
|
21
|
+
* get the next N keys for upload or processing
|
22
|
+
* @param count number of pre-keys to get or generate
|
23
|
+
*/
|
24
|
+
export declare const getNextPreKeys: ({ creds, keys }: AuthenticationState, count: number) => Promise<{
|
25
|
+
update: Partial<AuthenticationCreds>;
|
26
|
+
preKeys: {
|
27
|
+
[id: string]: KeyPair;
|
28
|
+
};
|
29
|
+
}>;
|
30
|
+
export declare const getNextPreKeysNode: (state: AuthenticationState, count: number) => Promise<{
|
31
|
+
update: Partial<AuthenticationCreds>;
|
32
|
+
node: BinaryNode;
|
33
|
+
}>;
|
package/lib/Utils/signal.js
CHANGED
@@ -85,27 +85,19 @@ const parseAndInjectE2ESessions = async (node, repository) => {
|
|
85
85
|
};
|
86
86
|
exports.parseAndInjectE2ESessions = parseAndInjectE2ESessions;
|
87
87
|
const extractDeviceJids = (result, myJid, excludeZeroDevices) => {
|
88
|
-
var _a;
|
89
88
|
const { user: myUser, device: myDevice } = (0, WABinary_1.jidDecode)(myJid);
|
90
89
|
const extracted = [];
|
91
|
-
for (const
|
92
|
-
const
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
for
|
100
|
-
|
101
|
-
|
102
|
-
(!excludeZeroDevices || device !== 0) && // if zero devices are not-excluded, or device is non zero
|
103
|
-
(myUser !== user || myDevice !== device) && // either different user or if me user, not this device
|
104
|
-
(device === 0 || !!attrs['key-index']) // ensure that "key-index" is specified for "non-zero" devices, produces a bad req otherwise
|
105
|
-
) {
|
106
|
-
extracted.push({ user, device });
|
107
|
-
}
|
108
|
-
}
|
90
|
+
for (const userResult of result) {
|
91
|
+
const { devices, id } = userResult;
|
92
|
+
const { user } = (0, WABinary_1.jidDecode)(id);
|
93
|
+
const deviceList = devices === null || devices === void 0 ? void 0 : devices.deviceList;
|
94
|
+
if (Array.isArray(deviceList)) {
|
95
|
+
for (const { id: device, keyIndex } of deviceList) {
|
96
|
+
if ((!excludeZeroDevices || device !== 0) && // if zero devices are not-excluded, or device is non zero
|
97
|
+
(myUser !== user || myDevice !== device) && // either different user or if me user, not this device
|
98
|
+
(device === 0 || !!keyIndex) // ensure that "key-index" is specified for "non-zero" devices, produces a bad req otherwise
|
99
|
+
) {
|
100
|
+
extracted.push({ user, device });
|
109
101
|
}
|
110
102
|
}
|
111
103
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { AuthenticationState } from '../Types';
|
2
|
+
/**
|
3
|
+
* stores the full authentication state in a single folder.
|
4
|
+
* Far more efficient than singlefileauthstate
|
5
|
+
*
|
6
|
+
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
7
|
+
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
8
|
+
* */
|
9
|
+
export declare const useMultiFileAuthState: (folder: string) => Promise<{
|
10
|
+
state: AuthenticationState;
|
11
|
+
saveCreds: () => Promise<void>;
|
12
|
+
}>;
|
@@ -4,17 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.useMultiFileAuthState = void 0;
|
7
|
-
const async_lock_1 = __importDefault(require("async-lock"));
|
8
7
|
const promises_1 = require("fs/promises");
|
9
8
|
const path_1 = require("path");
|
10
9
|
const WAProto_1 = require("../../WAProto");
|
11
10
|
const auth_utils_1 = require("./auth-utils");
|
12
11
|
const generics_1 = require("./generics");
|
13
|
-
|
14
|
-
// https://github.com/WhiskeySockets/Baileys/issues/794
|
15
|
-
// https://github.com/nodejs/node/issues/26338
|
16
|
-
// Default pending is 1000, set it to infinity
|
17
|
-
// https://github.com/rogierschouten/async-lock/issues/63
|
12
|
+
const async_lock_1 = __importDefault(require("async-lock"));
|
18
13
|
const fileLock = new async_lock_1.default({ maxPending: Infinity });
|
19
14
|
/**
|
20
15
|
* stores the full authentication state in a single folder.
|
@@ -24,7 +19,6 @@ const fileLock = new async_lock_1.default({ maxPending: Infinity });
|
|
24
19
|
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
25
20
|
* */
|
26
21
|
const useMultiFileAuthState = async (folder) => {
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
28
22
|
const writeData = (data, file) => {
|
29
23
|
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
30
24
|
return fileLock.acquire(filePath, () => (0, promises_1.writeFile)((0, path_1.join)(filePath), JSON.stringify(data, generics_1.BufferJSON.replacer)));
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { proto } from '../../WAProto';
|
2
|
+
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types';
|
3
|
+
import { BinaryNode } from '../WABinary';
|
4
|
+
export declare const generateMobileNode: (config: SocketConfig) => proto.IClientPayload;
|
5
|
+
export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload;
|
6
|
+
export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload;
|
7
|
+
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, 'advSecretKey' | 'signedIdentityKey' | 'signalIdentities'>) => {
|
8
|
+
creds: Partial<AuthenticationCreds>;
|
9
|
+
reply: BinaryNode;
|
10
|
+
};
|
11
|
+
export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array;
|
@@ -10,21 +10,30 @@ const crypto_2 = require("./crypto");
|
|
10
10
|
const generics_1 = require("./generics");
|
11
11
|
const signal_1 = require("./signal");
|
12
12
|
const getUserAgent = (config) => {
|
13
|
+
var _a, _b;
|
14
|
+
const osVersion = config.mobile ? '15.3.1' : '0.1';
|
15
|
+
const version = config.mobile ? [2, 24, 6] : config.version;
|
16
|
+
const device = config.mobile ? 'iPhone_7' : 'Desktop';
|
17
|
+
const manufacturer = config.mobile ? 'Apple' : '';
|
18
|
+
const platform = config.mobile ? WAProto_1.proto.ClientPayload.UserAgent.Platform.IOS : WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB;
|
19
|
+
const phoneId = config.mobile ? { phoneId: config.auth.creds.phoneId } : {};
|
13
20
|
return {
|
14
21
|
appVersion: {
|
15
|
-
primary:
|
16
|
-
secondary:
|
17
|
-
tertiary:
|
22
|
+
primary: version[0],
|
23
|
+
secondary: version[1],
|
24
|
+
tertiary: version[2],
|
18
25
|
},
|
19
|
-
platform
|
26
|
+
platform,
|
20
27
|
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
21
|
-
|
22
|
-
|
23
|
-
|
28
|
+
mcc: ((_a = config.auth.creds.registration) === null || _a === void 0 ? void 0 : _a.phoneNumberMobileCountryCode) || '000',
|
29
|
+
mnc: ((_b = config.auth.creds.registration) === null || _b === void 0 ? void 0 : _b.phoneNumberMobileNetworkCode) || '000',
|
30
|
+
osVersion: osVersion,
|
31
|
+
manufacturer,
|
32
|
+
device,
|
33
|
+
osBuildNumber: osVersion,
|
24
34
|
localeLanguageIso6391: 'en',
|
25
|
-
|
26
|
-
|
27
|
-
localeCountryIso31661Alpha2: config.countryCode,
|
35
|
+
localeCountryIso31661Alpha2: 'US',
|
36
|
+
...phoneId
|
28
37
|
};
|
29
38
|
};
|
30
39
|
const PLATFORM_MAP = {
|
@@ -44,7 +53,9 @@ const getClientPayload = (config) => {
|
|
44
53
|
connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
45
54
|
userAgent: getUserAgent(config),
|
46
55
|
};
|
47
|
-
|
56
|
+
if (!config.mobile) {
|
57
|
+
payload.webInfo = getWebInfo(config);
|
58
|
+
}
|
48
59
|
return payload;
|
49
60
|
};
|
50
61
|
const generateMobileNode = (config) => {
|
@@ -61,7 +72,7 @@ const generateMobileNode = (config) => {
|
|
61
72
|
appCached: false,
|
62
73
|
dnsMethod: WAProto_1.proto.ClientPayload.DNSSource.DNSResolutionMethod.SYSTEM,
|
63
74
|
},
|
64
|
-
passive: false,
|
75
|
+
passive: false,
|
65
76
|
pushName: 'test',
|
66
77
|
username: Number(`${config.auth.creds.registration.phoneNumberCountryCode}${config.auth.creds.registration.phoneNumberNationalNumber}`),
|
67
78
|
};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
export declare const TAGS: {
|
2
|
+
LIST_EMPTY: number;
|
3
|
+
DICTIONARY_0: number;
|
4
|
+
DICTIONARY_1: number;
|
5
|
+
DICTIONARY_2: number;
|
6
|
+
DICTIONARY_3: number;
|
7
|
+
AD_JID: number;
|
8
|
+
LIST_8: number;
|
9
|
+
LIST_16: number;
|
10
|
+
JID_PAIR: number;
|
11
|
+
HEX_8: number;
|
12
|
+
BINARY_8: number;
|
13
|
+
BINARY_20: number;
|
14
|
+
BINARY_32: number;
|
15
|
+
NIBBLE_8: number;
|
16
|
+
PACKED_MAX: number;
|
17
|
+
SINGLE_BYTE_MAX: number;
|
18
|
+
STREAM_END: number;
|
19
|
+
};
|
20
|
+
export declare const DOUBLE_BYTE_TOKENS: string[][];
|
21
|
+
export declare const SINGLE_BYTE_TOKENS: (string | null)[];
|
22
|
+
export declare const TOKEN_MAP: {
|
23
|
+
[token: string]: {
|
24
|
+
dict?: number;
|
25
|
+
index: number;
|
26
|
+
};
|
27
|
+
};
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { BinaryNode, BinaryNodeCodingOptions } from './types';
|
2
|
+
export declare const decompressingIfRequired: (buffer: Buffer) => Buffer;
|
3
|
+
export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, "DOUBLE_BYTE_TOKENS" | "SINGLE_BYTE_TOKENS" | "TAGS">, indexRef?: {
|
4
|
+
index: number;
|
5
|
+
}) => BinaryNode;
|
6
|
+
export declare const decodeBinaryNode: (buff: Buffer) => BinaryNode;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { proto } from '../../WAProto';
|
2
|
+
import { BinaryNode } from './types';
|
3
|
+
export declare const getBinaryNodeChildren: (node: BinaryNode | undefined, childTag: string) => BinaryNode[];
|
4
|
+
export declare const getAllBinaryNodeChildren: ({ content }: BinaryNode) => BinaryNode[];
|
5
|
+
export declare const getBinaryNodeChild: (node: BinaryNode | undefined, childTag: string) => BinaryNode | undefined;
|
6
|
+
export declare const getBinaryNodeChildBuffer: (node: BinaryNode | undefined, childTag: string) => string | Uint8Array<ArrayBufferLike> | BinaryNode[] | undefined;
|
7
|
+
export declare const getBinaryNodeChildString: (node: BinaryNode | undefined, childTag: string) => any;
|
8
|
+
export declare const getBinaryNodeChildUInt: (node: BinaryNode, childTag: string, length: number) => number | undefined;
|
9
|
+
export declare const assertNodeErrorFree: (node: BinaryNode) => void;
|
10
|
+
export declare const reduceBinaryNodeToDictionary: (node: BinaryNode, tag: string) => {
|
11
|
+
[_: string]: string;
|
12
|
+
};
|
13
|
+
export declare const getBinaryNodeMessages: ({ content }: BinaryNode) => proto.WebMessageInfo[];
|
14
|
+
export declare function binaryNodeToString(node: BinaryNode | BinaryNode['content'], i?: number): any;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
export declare const S_WHATSAPP_NET = "@s.whatsapp.net";
|
2
|
+
export declare const OFFICIAL_BIZ_JID = "16505361212@c.us";
|
3
|
+
export declare const SERVER_JID = "server@c.us";
|
4
|
+
export declare const PSA_WID = "0@c.us";
|
5
|
+
export declare const STORIES_JID = "status@broadcast";
|
6
|
+
export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter';
|
7
|
+
export type JidWithDevice = {
|
8
|
+
user: string;
|
9
|
+
device?: number;
|
10
|
+
};
|
11
|
+
export type FullJid = JidWithDevice & {
|
12
|
+
server: JidServer | string;
|
13
|
+
domainType?: number;
|
14
|
+
};
|
15
|
+
export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;
|
16
|
+
export declare const jidDecode: (jid: string | undefined) => FullJid | undefined;
|
17
|
+
/** is the jid a user */
|
18
|
+
export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean;
|
19
|
+
/** is the jid a user */
|
20
|
+
export declare const isJidUser: (jid: string | undefined) => boolean | undefined;
|
21
|
+
/** is the jid a group */
|
22
|
+
export declare const isLidUser: (jid: string | undefined) => boolean | undefined;
|
23
|
+
/** is the jid a broadcast */
|
24
|
+
export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined;
|
25
|
+
/** is the jid a group */
|
26
|
+
export declare const isJidGroup: (jid: string | undefined) => boolean | undefined;
|
27
|
+
/** is the jid the status broadcast */
|
28
|
+
export declare const isJidStatusBroadcast: (jid: string) => jid is "status@broadcast";
|
29
|
+
/** is the jid the newsletter */
|
30
|
+
export declare const isJidNewsLetter: (jid: string | undefined) => boolean | undefined;
|
31
|
+
export declare const jidNormalizedUser: (jid: string | undefined) => string;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import * as constants from './constants';
|
2
|
+
/**
|
3
|
+
* the binary node WA uses internally for communication
|
4
|
+
*
|
5
|
+
* this is manipulated soley as an object and it does not have any functions.
|
6
|
+
* This is done for easy serialization, to prevent running into issues with prototypes &
|
7
|
+
* to maintain functional code structure
|
8
|
+
* */
|
9
|
+
export type BinaryNode = {
|
10
|
+
tag: string;
|
11
|
+
attrs: {
|
12
|
+
[key: string]: string;
|
13
|
+
};
|
14
|
+
content?: BinaryNode[] | string | Uint8Array;
|
15
|
+
};
|
16
|
+
export type BinaryNodeAttributes = BinaryNode['attrs'];
|
17
|
+
export type BinaryNodeData = BinaryNode['content'];
|
18
|
+
export type BinaryNodeCodingOptions = typeof constants;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
export declare const WEB_EVENTS: Event[];
|
2
|
+
export declare const WEB_GLOBALS: Global[];
|
3
|
+
export declare const FLAG_BYTE = 8, FLAG_GLOBAL = 0, FLAG_EVENT = 1, FLAG_FIELD = 2, FLAG_EXTENDED = 4;
|
4
|
+
export type Event = {
|
5
|
+
name: string;
|
6
|
+
id: number;
|
7
|
+
props: {
|
8
|
+
[key: string]: [number, string | {
|
9
|
+
[key: string]: number;
|
10
|
+
}];
|
11
|
+
};
|
12
|
+
weight: number;
|
13
|
+
wamChannel: string;
|
14
|
+
privateStatsIdInt: number;
|
15
|
+
};
|
16
|
+
export type Global = {
|
17
|
+
name: string;
|
18
|
+
id: number;
|
19
|
+
type: string | {
|
20
|
+
[key: string]: number;
|
21
|
+
};
|
22
|
+
validator?: string;
|
23
|
+
channels: string[];
|
24
|
+
};
|
25
|
+
type EventByName<T extends Event['name']> = Extract<Event, {
|
26
|
+
name: T;
|
27
|
+
}>;
|
28
|
+
export type EventInputType = {
|
29
|
+
[key in Event['name']]: {
|
30
|
+
props: {
|
31
|
+
[k in keyof EventByName<key>['props']]: any;
|
32
|
+
};
|
33
|
+
globals: {
|
34
|
+
[x: string]: any;
|
35
|
+
};
|
36
|
+
};
|
37
|
+
} & {};
|
38
|
+
export {};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync';
|
2
|
+
import { BinaryNode } from '../../WABinary';
|
3
|
+
import { USyncUser } from '../USyncUser';
|
4
|
+
export declare class USyncContactProtocol implements USyncQueryProtocol {
|
5
|
+
name: string;
|
6
|
+
getQueryElement(): BinaryNode;
|
7
|
+
getUserElement(user: USyncUser): BinaryNode;
|
8
|
+
parser(node: BinaryNode): boolean;
|
9
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync';
|
2
|
+
import { BinaryNode } from '../../WABinary';
|
3
|
+
export type KeyIndexData = {
|
4
|
+
timestamp: number;
|
5
|
+
signedKeyIndex?: Uint8Array;
|
6
|
+
expectedTimestamp?: number;
|
7
|
+
};
|
8
|
+
export type DeviceListData = {
|
9
|
+
id: number;
|
10
|
+
keyIndex?: number;
|
11
|
+
isHosted?: boolean;
|
12
|
+
};
|
13
|
+
export type ParsedDeviceInfo = {
|
14
|
+
deviceList?: DeviceListData[];
|
15
|
+
keyIndex?: KeyIndexData;
|
16
|
+
};
|
17
|
+
export declare class USyncDeviceProtocol implements USyncQueryProtocol {
|
18
|
+
name: string;
|
19
|
+
getQueryElement(): BinaryNode;
|
20
|
+
getUserElement(): BinaryNode | null;
|
21
|
+
parser(node: BinaryNode): ParsedDeviceInfo;
|
22
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync';
|
2
|
+
import { BinaryNode } from '../../WABinary';
|
3
|
+
export type DisappearingModeData = {
|
4
|
+
duration: number;
|
5
|
+
setAt?: Date;
|
6
|
+
};
|
7
|
+
export declare class USyncDisappearingModeProtocol implements USyncQueryProtocol {
|
8
|
+
name: string;
|
9
|
+
getQueryElement(): BinaryNode;
|
10
|
+
getUserElement(): null;
|
11
|
+
parser(node: BinaryNode): DisappearingModeData | undefined;
|
12
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync';
|
2
|
+
import { BinaryNode } from '../../WABinary';
|
3
|
+
export type StatusData = {
|
4
|
+
status?: string | null;
|
5
|
+
setAt?: Date;
|
6
|
+
};
|
7
|
+
export declare class USyncStatusProtocol implements USyncQueryProtocol {
|
8
|
+
name: string;
|
9
|
+
getQueryElement(): BinaryNode;
|
10
|
+
getUserElement(): null;
|
11
|
+
parser(node: BinaryNode): StatusData | undefined;
|
12
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { USyncQueryProtocol } from '../Types/USync';
|
2
|
+
import { BinaryNode } from '../WABinary';
|
3
|
+
import { USyncUser } from './USyncUser';
|
4
|
+
export type USyncQueryResultList = {
|
5
|
+
[protocol: string]: unknown;
|
6
|
+
id: string;
|
7
|
+
};
|
8
|
+
export type USyncQueryResult = {
|
9
|
+
list: USyncQueryResultList[];
|
10
|
+
sideList: USyncQueryResultList[];
|
11
|
+
};
|
12
|
+
export declare class USyncQuery {
|
13
|
+
protocols: USyncQueryProtocol[];
|
14
|
+
users: USyncUser[];
|
15
|
+
context: string;
|
16
|
+
mode: string;
|
17
|
+
constructor();
|
18
|
+
withMode(mode: string): this;
|
19
|
+
withContext(context: string): this;
|
20
|
+
withUser(user: USyncUser): this;
|
21
|
+
parseUSyncQueryResult(result: BinaryNode): USyncQueryResult | undefined;
|
22
|
+
withDeviceProtocol(): this;
|
23
|
+
withContactProtocol(): this;
|
24
|
+
withStatusProtocol(): this;
|
25
|
+
withDisappearingModeProtocol(): this;
|
26
|
+
}
|
package/lib/index.js
CHANGED
@@ -17,9 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
18
|
};
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
-
exports.
|
21
|
-
const WAProto_1 = require("../WAProto");
|
22
|
-
Object.defineProperty(exports, "proto", { enumerable: true, get: function () { return WAProto_1.proto; } });
|
20
|
+
exports.makeWASocket = void 0;
|
23
21
|
const Socket_1 = __importDefault(require("./Socket"));
|
24
22
|
exports.makeWASocket = Socket_1.default;
|
25
23
|
__exportStar(require("../WAProto"), exports);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jkt48connect-corp/baileys",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.3.1",
|
4
4
|
"description": "WhatsApp API",
|
5
5
|
"keywords": [
|
6
6
|
"Baileys",
|
@@ -19,11 +19,12 @@
|
|
19
19
|
"multi-device",
|
20
20
|
"modder"
|
21
21
|
],
|
22
|
+
"homepage": "https://docs.jkt48connect.my.id",
|
22
23
|
"repository": {
|
23
24
|
"url": ""
|
24
25
|
},
|
25
26
|
"license": "MIT",
|
26
|
-
"author": "
|
27
|
+
"author": "Adhiraj Singh",
|
27
28
|
"main": "lib/index.js",
|
28
29
|
"types": "lib/index.d.ts",
|
29
30
|
"files": [
|
@@ -43,6 +44,8 @@
|
|
43
44
|
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
44
45
|
"lint": "eslint src --ext .js,.ts,.jsx,.tsx",
|
45
46
|
"lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
|
47
|
+
"prepack": "tsc",
|
48
|
+
"prepare": "tsc",
|
46
49
|
"release": "release-it",
|
47
50
|
"test": "jest"
|
48
51
|
},
|
@@ -55,7 +58,7 @@
|
|
55
58
|
"cache-manager": "4.0.1",
|
56
59
|
"futoin-hkdf": "^1.5.1",
|
57
60
|
"libphonenumber-js": "^1.10.20",
|
58
|
-
"libsignal": "github:
|
61
|
+
"libsignal": "github:WhiskeySockets/libsignal-node",
|
59
62
|
"music-metadata": "^7.12.3",
|
60
63
|
"node-cache": "^5.1.2",
|
61
64
|
"pino": "^7.0.0",
|
@@ -64,7 +67,7 @@
|
|
64
67
|
"ws": "^8.13.0"
|
65
68
|
},
|
66
69
|
"devDependencies": {
|
67
|
-
"@adiwajshing/eslint-config": "github:
|
70
|
+
"@adiwajshing/eslint-config": "github:whiskeysockets/eslint-config",
|
68
71
|
"@types/got": "^9.6.11",
|
69
72
|
"@types/jest": "^27.5.1",
|
70
73
|
"@types/node": "^16.0.0",
|
package/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2024 Indraazy
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|