sauruslord-baileys 2.1.0 → 3.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/README.md +41 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +53 -0
- package/lib/Defaults/index.js +2 -4
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/baileys-version.json +3 -0
- package/lib/Signal/index.d.ts +53 -0
- package/lib/Signal/index.js +147 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/phonenumber-mcc.json +223 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/web-socket-client.d.ts +12 -0
- package/lib/Socket/business.d.ts +171 -0
- package/lib/Socket/chats.d.ts +267 -0
- package/lib/Socket/chats.js +3 -22
- package/lib/Socket/dugong.js +9 -148
- package/lib/Socket/groups.d.ts +115 -0
- package/lib/Socket/index.d.ts +173 -0
- package/lib/Socket/lordsaurus.d.ts +266 -0
- package/lib/Socket/lordsaurus.js +580 -0
- package/lib/Socket/messages-recv.d.ts +161 -0
- package/lib/Socket/messages-recv.js +1085 -1085
- package/lib/Socket/messages-send.d.ts +149 -0
- package/lib/Socket/messages-send.js +257 -391
- package/lib/Socket/newsletter.d.ts +134 -0
- package/lib/Socket/newsletter.js +53 -159
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/socket.d.ts +43 -0
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/make-cache-manager-store.d.ts +13 -0
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- 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 +110 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Chat.d.ts +102 -0
- package/lib/Types/Contact.d.ts +19 -0
- package/lib/Types/Events.d.ts +157 -0
- package/lib/Types/GroupMetadata.d.ts +55 -0
- package/lib/Types/Label.d.ts +35 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/Message.d.ts +273 -0
- package/lib/Types/Newsletter.d.ts +103 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Socket.d.ts +111 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/index.d.ts +57 -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 +71 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +7 -23
- package/lib/Utils/decode-wa-message.d.ts +19 -0
- package/lib/Utils/decode-wa-message.js +0 -1
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/generics.d.ts +92 -0
- package/lib/Utils/generics.js +47 -135
- package/lib/Utils/history.d.ts +15 -0
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/logger.d.ts +4 -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 +116 -0
- package/lib/Utils/messages-media.js +24 -70
- package/lib/Utils/messages.d.ts +77 -0
- package/lib/Utils/messages.js +4 -180
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/signal.d.ts +32 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/WABinary/constants.d.ts +30 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/generic-utils.d.ts +17 -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 +17 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/encode.d.ts +3 -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/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +40 -19
- package/package.json +9 -9
- package/LICENSE +0 -21
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Saurus WhatsApp Baileys
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://j.top4top.io/p_38138stxx1.jpg" width="300"/>
|
|
5
|
+
</p><p align="center">
|
|
6
|
+
<b>Pustaka Bot WhatsApp</b><br>
|
|
7
|
+
Wrapper Baileys berkinerja tinggi untuk otomatisasi bot WhatsApp kalian
|
|
8
|
+
</p><p align="center">
|
|
9
|
+
<img src="https://img.shields.io/badge/Node.js-v20+-green?style=flat-square">
|
|
10
|
+
<img src="https://img.shields.io/badge/Modified-Baileys-blue?style=flat-square">
|
|
11
|
+
<img src="https://img.shields.io/badge/License-MIT-yellow?style=flat-square">
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
# Overview
|
|
15
|
+
|
|
16
|
+
WhatsApp Baileys adalah library open source berbasis Baileys yang telah dimodifikasi untuk kebutuhan automation dan integrasi WhatsApp skala besar.
|
|
17
|
+
|
|
18
|
+
Dirancang agar ringan, cepat, dan mudah digunakan, serta mendukung berbagai fitur terbaru dari WhatsApp bot.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Features
|
|
23
|
+
|
|
24
|
+
- Custom & automatic pairing
|
|
25
|
+
- Interactive message & action buttons
|
|
26
|
+
- Album message (multiple images)
|
|
27
|
+
- Event message
|
|
28
|
+
- Poll result message
|
|
29
|
+
- Product message
|
|
30
|
+
- Payment request message
|
|
31
|
+
- Group & chat management
|
|
32
|
+
- Multi-device support
|
|
33
|
+
- Lightweight & scalable
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
# Installation
|
|
38
|
+
|
|
39
|
+
npm install sauruslord-baileys
|
|
40
|
+
|
|
41
|
+
---
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { proto } from '../../WAProto';
|
|
4
|
+
import type { MediaType, SocketConfig } from '../Types';
|
|
5
|
+
export declare const UNAUTHORIZED_CODES: number[];
|
|
6
|
+
export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
7
|
+
export declare const DEF_CALLBACK_PREFIX = "CB:";
|
|
8
|
+
export declare const DEF_TAG_PREFIX = "TAG:";
|
|
9
|
+
export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
10
|
+
export declare const WA_DEFAULT_EPHEMERAL: number;
|
|
11
|
+
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
12
|
+
export declare const DICT_VERSION = 2;
|
|
13
|
+
export declare const KEY_BUNDLE_TYPE: Buffer;
|
|
14
|
+
export declare const NOISE_WA_HEADER: Buffer;
|
|
15
|
+
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
16
|
+
export declare const URL_REGEX: RegExp;
|
|
17
|
+
export declare const WA_CERT_DETAILS: {
|
|
18
|
+
SERIAL: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const PROCESSABLE_HISTORY_TYPES: proto.Message.HistorySyncNotification.HistorySyncType[];
|
|
21
|
+
export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
|
|
22
|
+
export declare const MEDIA_PATH_MAP: {
|
|
23
|
+
[T in MediaType]?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const MEDIA_HKDF_KEY_MAPPING: {
|
|
26
|
+
audio: string;
|
|
27
|
+
document: string;
|
|
28
|
+
gif: string;
|
|
29
|
+
image: string;
|
|
30
|
+
ppic: string;
|
|
31
|
+
product: string;
|
|
32
|
+
ptt: string;
|
|
33
|
+
sticker: string;
|
|
34
|
+
video: string;
|
|
35
|
+
'thumbnail-document': string;
|
|
36
|
+
'thumbnail-image': string;
|
|
37
|
+
'thumbnail-video': string;
|
|
38
|
+
'thumbnail-link': string;
|
|
39
|
+
'md-msg-hist': string;
|
|
40
|
+
'md-app-state': string;
|
|
41
|
+
'product-catalog-image': string;
|
|
42
|
+
'payment-bg-image': string;
|
|
43
|
+
ptv: string;
|
|
44
|
+
};
|
|
45
|
+
export declare const MEDIA_KEYS: ("ppic" | "product" | "image" | "video" | "sticker" | "audio" | "gif" | "ptt" | "thumbnail-document" | "thumbnail-image" | "thumbnail-link" | "thumbnail-video" | "md-app-state" | "md-msg-hist" | "document" | "product-catalog-image" | "payment-bg-image" | "ptv")[];
|
|
46
|
+
export declare const MIN_PREKEY_COUNT = 5;
|
|
47
|
+
export declare const INITIAL_PREKEY_COUNT = 30;
|
|
48
|
+
export declare const DEFAULT_CACHE_TTLS: {
|
|
49
|
+
SIGNAL_STORE: number;
|
|
50
|
+
MSG_RETRY: number;
|
|
51
|
+
CALL_OFFER: number;
|
|
52
|
+
USER_DEVICES: number;
|
|
53
|
+
};
|
package/lib/Defaults/index.js
CHANGED
|
@@ -111,8 +111,7 @@ exports.MEDIA_PATH_MAP = {
|
|
|
111
111
|
"thumbnail-link": "/mms/image",
|
|
112
112
|
"product-catalog-image": "/product/image",
|
|
113
113
|
"md-app-state": "",
|
|
114
|
-
"md-msg-hist": "/mms/md-app-state"
|
|
115
|
-
"sticker-pack": "/mms/sticker"
|
|
114
|
+
"md-msg-hist": "/mms/md-app-state"
|
|
116
115
|
};
|
|
117
116
|
|
|
118
117
|
exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
@@ -133,8 +132,7 @@ exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
|
133
132
|
"md-app-state": "App State",
|
|
134
133
|
"product-catalog-image": "",
|
|
135
134
|
"payment-bg-image": "Payment Background",
|
|
136
|
-
ptv: "Video"
|
|
137
|
-
"sticker-pack": "Sticker Pack"
|
|
135
|
+
ptv: "Video"
|
|
138
136
|
};
|
|
139
137
|
|
|
140
138
|
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class CiphertextMessage {
|
|
2
|
+
readonly UNSUPPORTED_VERSION: number;
|
|
3
|
+
readonly CURRENT_VERSION: number;
|
|
4
|
+
readonly WHISPER_TYPE: number;
|
|
5
|
+
readonly PREKEY_TYPE: number;
|
|
6
|
+
readonly SENDERKEY_TYPE: number;
|
|
7
|
+
readonly SENDERKEY_DISTRIBUTION_TYPE: number;
|
|
8
|
+
readonly ENCRYPTED_MESSAGE_OVERHEAD: number;
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SenderKeyDistributionMessage } from './sender-key-distribution-message';
|
|
2
|
+
import { SenderKeyName } from './sender-key-name';
|
|
3
|
+
import { SenderKeyRecord } from './sender-key-record';
|
|
4
|
+
interface SenderKeyStore {
|
|
5
|
+
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
|
|
6
|
+
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class GroupSessionBuilder {
|
|
9
|
+
private readonly senderKeyStore;
|
|
10
|
+
constructor(senderKeyStore: SenderKeyStore);
|
|
11
|
+
process(senderKeyName: SenderKeyName, senderKeyDistributionMessage: SenderKeyDistributionMessage): Promise<void>;
|
|
12
|
+
create(senderKeyName: SenderKeyName): Promise<SenderKeyDistributionMessage>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SenderKeyName } from './sender-key-name';
|
|
2
|
+
import { SenderKeyRecord } from './sender-key-record';
|
|
3
|
+
export interface SenderKeyStore {
|
|
4
|
+
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
|
|
5
|
+
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare class GroupCipher {
|
|
8
|
+
private readonly senderKeyStore;
|
|
9
|
+
private readonly senderKeyName;
|
|
10
|
+
constructor(senderKeyStore: SenderKeyStore, senderKeyName: SenderKeyName);
|
|
11
|
+
private queueJob;
|
|
12
|
+
encrypt(paddedPlaintext: Uint8Array | string): Promise<Uint8Array>;
|
|
13
|
+
decrypt(senderKeyMessageBytes: Uint8Array): Promise<Uint8Array>;
|
|
14
|
+
private getSenderKey;
|
|
15
|
+
private getPlainText;
|
|
16
|
+
private getCipherText;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { GroupSessionBuilder } from './group-session-builder';
|
|
2
|
+
export { SenderKeyDistributionMessage } from './sender-key-distribution-message';
|
|
3
|
+
export { SenderKeyRecord } from './sender-key-record';
|
|
4
|
+
export { SenderKeyName } from './sender-key-name';
|
|
5
|
+
export { GroupCipher } from './group_cipher';
|
|
6
|
+
export { SenderKeyState } from './sender-key-state';
|
|
7
|
+
export { SenderKeyMessage } from './sender-key-message';
|
|
8
|
+
export { SenderMessageKey } from './sender-message-key';
|
|
9
|
+
export { SenderChainKey } from './sender-chain-key';
|
|
10
|
+
export { CiphertextMessage } from './ciphertext-message';
|
|
11
|
+
export * as keyhelper from './keyhelper';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { generateKeyPair } from 'libsignal/src/curve';
|
|
2
|
+
type KeyPairType = ReturnType<typeof generateKeyPair>;
|
|
3
|
+
export declare function generateSenderKey(): Buffer;
|
|
4
|
+
export declare function generateSenderKeyId(): number;
|
|
5
|
+
export interface SigningKeyPair {
|
|
6
|
+
public: Buffer;
|
|
7
|
+
private: Buffer;
|
|
8
|
+
}
|
|
9
|
+
export declare function generateSenderSigningKey(key?: KeyPairType): SigningKeyPair;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function queueJob<T>(bucket: string | number, awaitable: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SenderMessageKey } from './sender-message-key';
|
|
2
|
+
export declare class SenderChainKey {
|
|
3
|
+
private readonly MESSAGE_KEY_SEED;
|
|
4
|
+
private readonly CHAIN_KEY_SEED;
|
|
5
|
+
private readonly iteration;
|
|
6
|
+
private readonly chainKey;
|
|
7
|
+
constructor(iteration: number, chainKey: any);
|
|
8
|
+
getIteration(): number;
|
|
9
|
+
getSenderMessageKey(): SenderMessageKey;
|
|
10
|
+
getNext(): SenderChainKey;
|
|
11
|
+
getSeed(): Uint8Array;
|
|
12
|
+
private getDerivative;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CiphertextMessage } from './ciphertext-message';
|
|
2
|
+
export declare class SenderKeyDistributionMessage extends CiphertextMessage {
|
|
3
|
+
private readonly id;
|
|
4
|
+
private readonly iteration;
|
|
5
|
+
private readonly chainKey;
|
|
6
|
+
private readonly signatureKey;
|
|
7
|
+
private readonly serialized;
|
|
8
|
+
constructor(id?: number | null, iteration?: number | null, chainKey?: Uint8Array | null, signatureKey?: Uint8Array | null, serialized?: Uint8Array | null);
|
|
9
|
+
private intsToByteHighAndLow;
|
|
10
|
+
serialize(): Uint8Array;
|
|
11
|
+
getType(): number;
|
|
12
|
+
getIteration(): number;
|
|
13
|
+
getChainKey(): Uint8Array;
|
|
14
|
+
getSignatureKey(): Uint8Array;
|
|
15
|
+
getId(): number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CiphertextMessage } from './ciphertext-message';
|
|
2
|
+
export declare class SenderKeyMessage extends CiphertextMessage {
|
|
3
|
+
private readonly SIGNATURE_LENGTH;
|
|
4
|
+
private readonly messageVersion;
|
|
5
|
+
private readonly keyId;
|
|
6
|
+
private readonly iteration;
|
|
7
|
+
private readonly ciphertext;
|
|
8
|
+
private readonly signature;
|
|
9
|
+
private readonly serialized;
|
|
10
|
+
constructor(keyId?: number | null, iteration?: number | null, ciphertext?: Uint8Array | null, signatureKey?: Uint8Array | null, serialized?: Uint8Array | null);
|
|
11
|
+
getKeyId(): number;
|
|
12
|
+
getIteration(): number;
|
|
13
|
+
getCipherText(): Uint8Array;
|
|
14
|
+
verifySignature(signatureKey: Uint8Array): void;
|
|
15
|
+
private getSignature;
|
|
16
|
+
serialize(): Uint8Array;
|
|
17
|
+
getType(): number;
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface Sender {
|
|
2
|
+
id: string;
|
|
3
|
+
deviceId: number;
|
|
4
|
+
toString(): string;
|
|
5
|
+
}
|
|
6
|
+
export declare class SenderKeyName {
|
|
7
|
+
private readonly groupId;
|
|
8
|
+
private readonly sender;
|
|
9
|
+
constructor(groupId: string, sender: Sender);
|
|
10
|
+
getGroupId(): string;
|
|
11
|
+
getSender(): Sender;
|
|
12
|
+
serialize(): string;
|
|
13
|
+
toString(): string;
|
|
14
|
+
equals(other: SenderKeyName | null): boolean;
|
|
15
|
+
hashCode(): number;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SenderKeyState } from './sender-key-state';
|
|
2
|
+
export interface SenderKeyStateStructure {
|
|
3
|
+
senderKeyId: number;
|
|
4
|
+
senderChainKey: {
|
|
5
|
+
iteration: number;
|
|
6
|
+
seed: Uint8Array;
|
|
7
|
+
};
|
|
8
|
+
senderSigningKey: {
|
|
9
|
+
public: Uint8Array;
|
|
10
|
+
private?: Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
senderMessageKeys: Array<{
|
|
13
|
+
iteration: number;
|
|
14
|
+
seed: Uint8Array;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export declare class SenderKeyRecord {
|
|
18
|
+
private readonly MAX_STATES;
|
|
19
|
+
private readonly senderKeyStates;
|
|
20
|
+
constructor(serialized?: SenderKeyStateStructure[]);
|
|
21
|
+
isEmpty(): boolean;
|
|
22
|
+
getSenderKeyState(keyId?: number): SenderKeyState | undefined;
|
|
23
|
+
addSenderKeyState(id: number, iteration: number, chainKey: Uint8Array, signatureKey: Uint8Array): void;
|
|
24
|
+
setSenderKeyState(id: number, iteration: number, chainKey: Uint8Array, keyPair: {
|
|
25
|
+
public: Uint8Array;
|
|
26
|
+
private: Uint8Array;
|
|
27
|
+
}): void;
|
|
28
|
+
serialize(): SenderKeyStateStructure[];
|
|
29
|
+
static deserialize(data: Uint8Array | string | SenderKeyStateStructure[]): SenderKeyRecord;
|
|
30
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SenderChainKey } from './sender-chain-key';
|
|
2
|
+
import { SenderMessageKey } from './sender-message-key';
|
|
3
|
+
interface SenderChainKeyStructure {
|
|
4
|
+
iteration: number;
|
|
5
|
+
seed: Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
interface SenderSigningKeyStructure {
|
|
8
|
+
public: Uint8Array;
|
|
9
|
+
private?: Uint8Array;
|
|
10
|
+
}
|
|
11
|
+
interface SenderMessageKeyStructure {
|
|
12
|
+
iteration: number;
|
|
13
|
+
seed: Uint8Array;
|
|
14
|
+
}
|
|
15
|
+
interface SenderKeyStateStructure {
|
|
16
|
+
senderKeyId: number;
|
|
17
|
+
senderChainKey: SenderChainKeyStructure;
|
|
18
|
+
senderSigningKey: SenderSigningKeyStructure;
|
|
19
|
+
senderMessageKeys: SenderMessageKeyStructure[];
|
|
20
|
+
}
|
|
21
|
+
export declare class SenderKeyState {
|
|
22
|
+
private readonly MAX_MESSAGE_KEYS;
|
|
23
|
+
private readonly senderKeyStateStructure;
|
|
24
|
+
constructor(id?: number | null, iteration?: number | null, chainKey?: Uint8Array | null, signatureKeyPair?: {
|
|
25
|
+
public: Uint8Array;
|
|
26
|
+
private: Uint8Array;
|
|
27
|
+
} | null, signatureKeyPublic?: Uint8Array | null, signatureKeyPrivate?: Uint8Array | null, senderKeyStateStructure?: SenderKeyStateStructure | null);
|
|
28
|
+
getKeyId(): number;
|
|
29
|
+
getSenderChainKey(): SenderChainKey;
|
|
30
|
+
setSenderChainKey(chainKey: SenderChainKey): void;
|
|
31
|
+
getSigningKeyPublic(): Buffer;
|
|
32
|
+
getSigningKeyPrivate(): Buffer | undefined;
|
|
33
|
+
hasSenderMessageKey(iteration: number): boolean;
|
|
34
|
+
addSenderMessageKey(senderMessageKey: SenderMessageKey): void;
|
|
35
|
+
removeSenderMessageKey(iteration: number): SenderMessageKey | null;
|
|
36
|
+
getStructure(): SenderKeyStateStructure;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class SenderMessageKey {
|
|
2
|
+
private readonly iteration;
|
|
3
|
+
private readonly iv;
|
|
4
|
+
private readonly cipherKey;
|
|
5
|
+
private readonly seed;
|
|
6
|
+
constructor(iteration: number, seed: Uint8Array);
|
|
7
|
+
getIteration(): number;
|
|
8
|
+
getIv(): Uint8Array;
|
|
9
|
+
getCipherKey(): Uint8Array;
|
|
10
|
+
getSeed(): Uint8Array;
|
|
11
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { proto } from '../../WAProto';
|
|
4
|
+
import type { MediaType, SocketConfig } from '../Types';
|
|
5
|
+
export declare const UNAUTHORIZED_CODES: number[];
|
|
6
|
+
export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
7
|
+
export declare const DEF_CALLBACK_PREFIX = "CB:";
|
|
8
|
+
export declare const DEF_TAG_PREFIX = "TAG:";
|
|
9
|
+
export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
10
|
+
export declare const WA_DEFAULT_EPHEMERAL: number;
|
|
11
|
+
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
12
|
+
export declare const DICT_VERSION = 2;
|
|
13
|
+
export declare const KEY_BUNDLE_TYPE: Buffer;
|
|
14
|
+
export declare const NOISE_WA_HEADER: Buffer;
|
|
15
|
+
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
16
|
+
export declare const URL_REGEX: RegExp;
|
|
17
|
+
export declare const WA_CERT_DETAILS: {
|
|
18
|
+
SERIAL: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const PROCESSABLE_HISTORY_TYPES: proto.Message.HistorySyncNotification.HistorySyncType[];
|
|
21
|
+
export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
|
|
22
|
+
export declare const MEDIA_PATH_MAP: {
|
|
23
|
+
[T in MediaType]?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const MEDIA_HKDF_KEY_MAPPING: {
|
|
26
|
+
audio: string;
|
|
27
|
+
document: string;
|
|
28
|
+
gif: string;
|
|
29
|
+
image: string;
|
|
30
|
+
ppic: string;
|
|
31
|
+
product: string;
|
|
32
|
+
ptt: string;
|
|
33
|
+
sticker: string;
|
|
34
|
+
video: string;
|
|
35
|
+
'thumbnail-document': string;
|
|
36
|
+
'thumbnail-image': string;
|
|
37
|
+
'thumbnail-video': string;
|
|
38
|
+
'thumbnail-link': string;
|
|
39
|
+
'md-msg-hist': string;
|
|
40
|
+
'md-app-state': string;
|
|
41
|
+
'product-catalog-image': string;
|
|
42
|
+
'payment-bg-image': string;
|
|
43
|
+
ptv: string;
|
|
44
|
+
};
|
|
45
|
+
export declare const MEDIA_KEYS: ("ppic" | "product" | "image" | "video" | "sticker" | "audio" | "gif" | "ptt" | "thumbnail-document" | "thumbnail-image" | "thumbnail-link" | "thumbnail-video" | "md-app-state" | "md-msg-hist" | "document" | "product-catalog-image" | "payment-bg-image" | "ptv")[];
|
|
46
|
+
export declare const MIN_PREKEY_COUNT = 5;
|
|
47
|
+
export declare const INITIAL_PREKEY_COUNT = 30;
|
|
48
|
+
export declare const DEFAULT_CACHE_TTLS: {
|
|
49
|
+
SIGNAL_STORE: number;
|
|
50
|
+
MSG_RETRY: number;
|
|
51
|
+
CALL_OFFER: number;
|
|
52
|
+
USER_DEVICES: number;
|
|
53
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
var __importDefault = this && this.__importDefault || function (a) {
|
|
2
|
+
return a && a.__esModule ? a : { "default": a }
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
6
|
+
|
|
7
|
+
exports.DEFAULT_CACHE_TTLS =
|
|
8
|
+
exports.INITIAL_PREKEY_COUNT =
|
|
9
|
+
exports.MIN_PREKEY_COUNT =
|
|
10
|
+
exports.MEDIA_KEYS =
|
|
11
|
+
exports.MEDIA_HKDF_KEY_MAPPING =
|
|
12
|
+
exports.MEDIA_PATH_MAP =
|
|
13
|
+
exports.DEFAULT_CONNECTION_CONFIG =
|
|
14
|
+
exports.PROCESSABLE_HISTORY_TYPES =
|
|
15
|
+
exports.WA_CERT_DETAILS =
|
|
16
|
+
exports.URL_REGEX =
|
|
17
|
+
exports.NOISE_WA_HEADER =
|
|
18
|
+
exports.KEY_BUNDLE_TYPE =
|
|
19
|
+
exports.DICT_VERSION =
|
|
20
|
+
exports.NOISE_MODE =
|
|
21
|
+
exports.WA_DEFAULT_EPHEMERAL =
|
|
22
|
+
exports.PHONE_CONNECTION_CB =
|
|
23
|
+
exports.DEF_TAG_PREFIX =
|
|
24
|
+
exports.DEF_CALLBACK_PREFIX =
|
|
25
|
+
exports.DEFAULT_ORIGIN =
|
|
26
|
+
exports.UNAUTHORIZED_CODES =
|
|
27
|
+
void 0;
|
|
28
|
+
|
|
29
|
+
const crypto_1 = require("crypto");
|
|
30
|
+
const WAProto_1 = require("../../WAProto"),
|
|
31
|
+
libsignal_1 = require("../Signal/libsignal"),
|
|
32
|
+
Utils_1 = require("../Utils"),
|
|
33
|
+
logger_1 = __importDefault(require("../Utils/logger")),
|
|
34
|
+
baileys_version_json_1 = require("./baileys-version.json"),
|
|
35
|
+
phonenumber_mcc_json_1 = __importDefault(require("./phonenumber-mcc.json"));
|
|
36
|
+
|
|
37
|
+
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
38
|
+
exports.version = [2, 3000, 1027934701];
|
|
39
|
+
exports.PHONENUMBER_MCC = phonenumber_mcc_json_1.default;
|
|
40
|
+
exports.DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
41
|
+
exports.MOBILE_ENDPOINT = 'g.whatsapp.net';
|
|
42
|
+
exports.MOBILE_PORT = 443;
|
|
43
|
+
exports.DEF_CALLBACK_PREFIX = "CB:";
|
|
44
|
+
exports.DEF_TAG_PREFIX = "TAG:";
|
|
45
|
+
exports.PHONE_CONNECTION_CB = "CB:Pong";
|
|
46
|
+
exports.WA_DEFAULT_EPHEMERAL = 604800;
|
|
47
|
+
const WA_VERSION = '2.25.23.24';
|
|
48
|
+
const WA_VERSION_HASH = (0, crypto_1.createHash)('md5').update(WA_VERSION).digest('hex');
|
|
49
|
+
exports.MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM' + WA_VERSION_HASH);
|
|
50
|
+
exports.MOBILE_REGISTRATION_ENDPOINT = 'https://v.whatsapp.net/v2';
|
|
51
|
+
exports.MOBILE_USERAGENT = `WhatsApp/${WA_VERSION} iOS/17.5.1 Device/Apple-iPhone_13`;
|
|
52
|
+
exports.REGISTRATION_PUBLIC_KEY = Buffer.from([
|
|
53
|
+
5, 142, 140, 15, 116, 195, 235, 197, 215, 166, 134, 92, 108, 60, 132, 56, 86, 176, 97, 33, 204, 232, 234, 119, 77,
|
|
54
|
+
34, 251, 111, 18, 37, 18, 48, 45,
|
|
55
|
+
]);
|
|
56
|
+
exports.NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\x00\x00\x00\x00";
|
|
57
|
+
exports.DICT_VERSION = 2;
|
|
58
|
+
exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
59
|
+
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
|
|
60
|
+
exports.PROTOCOL_VERSION = [5, 2];
|
|
61
|
+
exports.MOBILE_NOISE_HEADER = Buffer.concat([Buffer.from('WA'), Buffer.from(exports.PROTOCOL_VERSION)]);
|
|
62
|
+
|
|
63
|
+
exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
64
|
+
exports.WA_CERT_DETAILS = { SERIAL: 0 };
|
|
65
|
+
|
|
66
|
+
exports.PROCESSABLE_HISTORY_TYPES = [
|
|
67
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
68
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
|
|
69
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
|
|
70
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL,
|
|
71
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
75
|
+
version: baileys_version_json_1.version,
|
|
76
|
+
browser: Utils_1.Browsers("Chrome"),
|
|
77
|
+
waWebSocketUrl: "wss://web.whatsapp.com/ws/chat",
|
|
78
|
+
connectTimeoutMs: 2E4,
|
|
79
|
+
keepAliveIntervalMs: 3E4,
|
|
80
|
+
logger: logger_1.default.child({ class: "baileys" }),
|
|
81
|
+
printQRInTerminal: !1,
|
|
82
|
+
emitOwnEvents: !0,
|
|
83
|
+
defaultQueryTimeoutMs: 6E4,
|
|
84
|
+
customUploadHosts: [],
|
|
85
|
+
retryRequestDelayMs: 250,
|
|
86
|
+
maxMsgRetryCount: 5,
|
|
87
|
+
fireInitQueries: !0,
|
|
88
|
+
auth: void 0,
|
|
89
|
+
markOnlineOnConnect: !0,
|
|
90
|
+
syncFullHistory: !1,
|
|
91
|
+
patchMessageBeforeSending: a => a,
|
|
92
|
+
shouldSyncHistoryMessage: () => !0,
|
|
93
|
+
shouldIgnoreJid: () => !1,
|
|
94
|
+
linkPreviewImageThumbnailWidth: 192,
|
|
95
|
+
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3E3 },
|
|
96
|
+
generateHighQualityLinkPreview: !1,
|
|
97
|
+
options: {},
|
|
98
|
+
appStateMacVerification: { patch: !1, snapshot: !1 },
|
|
99
|
+
countryCode: "US",
|
|
100
|
+
getMessage: async () => { },
|
|
101
|
+
cachedGroupMetadata: async () => { },
|
|
102
|
+
makeSignalRepository: libsignal_1.makeLibSignalRepository
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
exports.MEDIA_PATH_MAP = {
|
|
106
|
+
image: "/mms/image",
|
|
107
|
+
video: "/mms/video",
|
|
108
|
+
document: "/mms/document",
|
|
109
|
+
audio: "/mms/audio",
|
|
110
|
+
sticker: "/mms/image",
|
|
111
|
+
"thumbnail-link": "/mms/image",
|
|
112
|
+
"product-catalog-image": "/product/image",
|
|
113
|
+
"md-app-state": "",
|
|
114
|
+
"md-msg-hist": "/mms/md-app-state"
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
118
|
+
audio: "Audio",
|
|
119
|
+
document: "Document",
|
|
120
|
+
gif: "Video",
|
|
121
|
+
image: "Image",
|
|
122
|
+
ppic: "",
|
|
123
|
+
product: "Image",
|
|
124
|
+
ptt: "Audio",
|
|
125
|
+
sticker: "Image",
|
|
126
|
+
video: "Video",
|
|
127
|
+
"thumbnail-document": "Document Thumbnail",
|
|
128
|
+
"thumbnail-image": "Image Thumbnail",
|
|
129
|
+
"thumbnail-video": "Video Thumbnail",
|
|
130
|
+
"thumbnail-link": "Link Thumbnail",
|
|
131
|
+
"md-msg-hist": "History",
|
|
132
|
+
"md-app-state": "App State",
|
|
133
|
+
"product-catalog-image": "",
|
|
134
|
+
"payment-bg-image": "Payment Background",
|
|
135
|
+
ptv: "Video"
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
|
|
139
|
+
exports.MIN_PREKEY_COUNT = 5;
|
|
140
|
+
exports.INITIAL_PREKEY_COUNT = 30;
|
|
141
|
+
|
|
142
|
+
exports.DEFAULT_CACHE_TTLS = {
|
|
143
|
+
SIGNAL_STORE: 300,
|
|
144
|
+
MSG_RETRY: 3600,
|
|
145
|
+
CALL_OFFER: 300,
|
|
146
|
+
USER_DEVICES: 300
|
|
147
|
+
};
|