mod-baileys 1.0.1 → 1.0.3
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 +21 -0
- package/README.md +13 -60
- package/lib/Defaults/index.d.ts +53 -0
- package/lib/Defaults/index.js +6 -6
- 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/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +5 -5
- package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +3 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +1 -1
- package/lib/Socket/Client/web-socket-client.d.ts +12 -0
- package/lib/Socket/Client/web-socket-client.js +2 -2
- package/lib/Socket/business.d.ts +171 -0
- package/lib/Socket/chats.d.ts +267 -0
- package/lib/Socket/groups.d.ts +115 -0
- package/lib/Socket/groups.js +6 -6
- package/lib/Socket/index.d.ts +173 -0
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/luxu.d.ts +268 -0
- package/lib/Socket/{dew.js → luxu.js} +11 -11
- package/lib/Socket/messages-recv.d.ts +161 -0
- package/lib/Socket/messages-send.d.ts +149 -0
- package/lib/Socket/messages-send.js +10 -10
- package/lib/Socket/newsletter.d.ts +134 -0
- package/lib/Socket/newsletter.js +5 -8
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +4 -4
- package/lib/Socket/socket.d.ts +43 -0
- package/lib/Socket/socket.js +10 -9
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +2 -2
- package/lib/Store/make-cache-manager-store.d.ts +13 -0
- package/lib/Store/make-cache-manager-store.js +3 -3
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +7 -7
- 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/Message.js +1 -1
- 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/Types/index.js +12 -12
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +3 -3
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +2 -2
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/chat-utils.d.ts +71 -0
- package/lib/Utils/chat-utils.js +7 -7
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +1 -1
- package/lib/Utils/decode-wa-message.d.ts +19 -0
- package/lib/Utils/decode-wa-message.js +3 -3
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +4 -4
- package/lib/Utils/generics.d.ts +92 -0
- package/lib/Utils/generics.js +5 -5
- package/lib/Utils/history.d.ts +15 -0
- package/lib/Utils/history.js +6 -6
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/index.js +17 -17
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +2 -2
- package/lib/Utils/logger.d.ts +4 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +1 -1
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/messages-media.d.ts +116 -0
- package/lib/Utils/messages-media.js +80 -30
- package/lib/Utils/messages.d.ts +77 -0
- package/lib/Utils/messages.js +8 -8
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/noise-handler.js +4 -4
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/process-message.js +7 -7
- package/lib/Utils/signal.d.ts +32 -0
- package/lib/Utils/signal.js +4 -4
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.js +3 -3
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +6 -6
- package/lib/WABinary/constants.d.ts +30 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.js +2 -2
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +2 -2
- package/lib/WABinary/generic-utils.d.ts +17 -0
- package/lib/WABinary/generic-utils.js +2 -2
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -5
- 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/encode.js +1 -1
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +3 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/index.d.ts +4 -4
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncQuery.js +4 -4
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/index.js +3 -3
- package/lib/index.d.ts +12 -0
- package/lib/index.js +10 -18
- package/lib/temp +1 -0
- package/package.json +4 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dew-Coders
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<img src="https://capsule-render.vercel.app/api?type=speech&height=300&color=gradient&text=DEW%20BAIYLES&animation=blinking" width="100%">
|
|
3
5
|
</div>
|
|
4
6
|
<br>
|
|
5
|
-
|
|
7
|
+
|
|
6
8
|
<div style="background: linear-gradient(90deg, #6366F1, #3B82F6, #2DD4BF); padding: 8px; border-radius: 10px; margin: 15px 0;">
|
|
7
9
|
<span style="font-size: 18px; font-weight: bold; color: white;"><b>🔥Ultimate WhatsApp Web API<b></span>
|
|
8
10
|
</div>
|
|
@@ -11,71 +13,22 @@
|
|
|
11
13
|

|
|
12
14
|

|
|
13
15
|

|
|
14
|
-
|
|
15
|
-
<p>
|
|
16
|
-
<!-- NPM Version -->
|
|
17
|
-
<a href="https://www.npmjs.com/package/mod-baileys">
|
|
18
|
-
<img src="https://img.shields.io/npm/v/mod-baileys?color=blueviolet&label=version&logo=npm" alt="npm version" />
|
|
19
|
-
</a>
|
|
20
|
-
|
|
21
|
-
<!-- NPM Downloads -->
|
|
22
|
-
<a href="https://www.npmjs.com/package/mod-baileys">
|
|
23
|
-
<img src="https://img.shields.io/npm/dt/mod-baileys?color=blueviolet&label=downloads&logo=npm" alt="npm downloads" />
|
|
24
|
-
</a>
|
|
25
|
-
|
|
26
|
-
<!-- License -->
|
|
27
|
-
<a href="https://www.npmjs.com/package/mod-baileys">
|
|
28
|
-
<img src="https://img.shields.io/npm/l/mod-baileys?color=success&label=license" alt="license" />
|
|
29
|
-
</a>
|
|
30
|
-
|
|
31
|
-
<!-- Bundle Size -->
|
|
32
|
-
<a href="https://bundlephobia.com/package/mod-baileys">
|
|
33
|
-
<img src="https://img.shields.io/bundlephobia/min/mod-baileys?label=minified%20size&color=orange" alt="bundle size" />
|
|
34
|
-
</a>
|
|
35
|
-
|
|
36
|
-
<!-- Gzip Bundle Size -->
|
|
37
|
-
<a href="https://bundlephobia.com/package/mod-baileys">
|
|
38
|
-
<img src="https://img.shields.io/bundlephobia/minzip/mod-baileys?label=minzip%20size&color=orange" alt="gzip bundle size" />
|
|
39
|
-
</a>
|
|
40
|
-
|
|
41
|
-
<!-- PackagePhobia Install Size -->
|
|
42
|
-
<a href="https://packagephobia.com/result?p=mod-baileys">
|
|
43
|
-
<img src="https://packagephobia.com/badge?p=mod-baileys" alt="install size" />
|
|
44
|
-
</a>
|
|
45
|
-
|
|
46
|
-
<!-- Code Quality (Codacy) -->
|
|
47
|
-
<a href="https://app.codacy.com">
|
|
48
|
-
<img src="https://img.shields.io/badge/Codacy-Quality%20Check-blue?logo=codacy" alt="Codacy quality" />
|
|
49
|
-
</a>
|
|
50
|
-
|
|
51
|
-
<!-- Security Scan (Snyk) -->
|
|
52
|
-
<a href="https://snyk.io">
|
|
53
|
-
<img src="https://img.shields.io/badge/Snyk-Security%20Scan-purple?logo=snyk" alt="Snyk security" />
|
|
54
|
-
</a>
|
|
55
|
-
|
|
56
|
-
<!-- Node Engine Support -->
|
|
57
|
-
<img src="https://img.shields.io/node/v/mod-baileys?label=node%21engine" alt="node engine" />
|
|
58
|
-
|
|
59
|
-
<!-- Types -->
|
|
60
|
-
<img src="https://img.shields.io/npm/types/mod-baileys?label=types" alt="types" />
|
|
61
|
-
</p>
|
|
62
|
-
|
|
63
16
|
</div>
|
|
64
17
|
|
|
18
|
+
<br>
|
|
65
19
|
|
|
66
20
|
<div align="center">
|
|
67
21
|
<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&height=60§ion=header" width="100%">
|
|
68
22
|
</div>
|
|
69
|
-
|
|
23
|
+
|
|
70
24
|
<div style="border-left: 4px solid #3B82F6; padding-left: 15px; margin: 25px 0;">
|
|
71
|
-
<h2
|
|
25
|
+
<h2>⚡️ Supercharged WhatsApp API 🌟</h2>
|
|
72
26
|
<p><i>Elevate your messaging experience with the most advanced WhatsApp Web API solution available</i></p>
|
|
73
|
-
</div
|
|
74
|
-
|
|
27
|
+
</div>
|
|
75
28
|
|
|
76
29
|
---
|
|
77
30
|
|
|
78
|
-
## ❓️ | WHY
|
|
31
|
+
## ❓️ | WHY DEW-BAILEYS?
|
|
79
32
|
|
|
80
33
|
<div style="display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; margin: 20px 0;">
|
|
81
34
|
<div style="background: rgba(45, 212, 191, 0.1); border-radius: 10px; padding: 15px; width: 180px; text-align: center;">
|
|
@@ -105,21 +58,21 @@
|
|
|
105
58
|
### 📂 In package.json:
|
|
106
59
|
```json
|
|
107
60
|
"dependencies": {
|
|
108
|
-
"
|
|
61
|
+
"dew-baileys": "*"
|
|
109
62
|
}
|
|
110
63
|
```
|
|
111
64
|
or option2
|
|
112
65
|
### 📂 In package.json:
|
|
113
66
|
```json
|
|
114
67
|
"dependencies": {
|
|
115
|
-
"@whiskeysockets/baileys": "github:dew-coders/
|
|
68
|
+
"@whiskeysockets/baileys": "github:dew-coders/Dew-Baileys"
|
|
116
69
|
}
|
|
117
70
|
```
|
|
118
71
|
|
|
119
72
|
|
|
120
73
|
### ⚙️ Terminal Installation:
|
|
121
74
|
```bash
|
|
122
|
-
npm install
|
|
75
|
+
npm install dew-baileys
|
|
123
76
|
```
|
|
124
77
|
|
|
125
78
|
### 🔌 Import:
|
|
@@ -510,4 +463,4 @@ if(usePairingCode && !sock.authState.creds.registered) {
|
|
|
510
463
|
</div>
|
|
511
464
|
<div align="center">
|
|
512
465
|
<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&height=100§ion=footer" width="100%">
|
|
513
|
-
</div>
|
|
466
|
+
</div>
|
|
@@ -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
|
@@ -27,12 +27,12 @@ exports.DEFAULT_CACHE_TTLS =
|
|
|
27
27
|
void 0;
|
|
28
28
|
|
|
29
29
|
const crypto_1 = require("crypto");
|
|
30
|
-
const WAProto_1 = require("
|
|
31
|
-
libsignal_1 = require("
|
|
32
|
-
Utils_1 = require("
|
|
33
|
-
logger_1 = __importDefault(require("
|
|
34
|
-
baileys_version_json_1 = require("
|
|
35
|
-
phonenumber_mcc_json_1 = __importDefault(require("
|
|
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
36
|
|
|
37
37
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
38
38
|
exports.version = [2, 3000, 1027934701];
|
|
@@ -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
|
+
}
|
package/lib/Signal/libsignal.js
CHANGED
|
@@ -35,11 +35,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.makeLibSignalRepository = makeLibSignalRepository;
|
|
37
37
|
const libsignal = __importStar(require("libsignal"));
|
|
38
|
-
const Utils_1 = require("
|
|
39
|
-
const WABinary_1 = require("
|
|
40
|
-
const sender_key_name_1 = require("
|
|
41
|
-
const sender_key_record_1 = require("
|
|
42
|
-
const Group_1 = require("
|
|
38
|
+
const Utils_1 = require("../Utils");
|
|
39
|
+
const WABinary_1 = require("../WABinary");
|
|
40
|
+
const sender_key_name_1 = require("./Group/sender-key-name");
|
|
41
|
+
const sender_key_record_1 = require("./Group/sender-key-record");
|
|
42
|
+
const Group_1 = require("./Group");
|
|
43
43
|
function makeLibSignalRepository(auth) {
|
|
44
44
|
const storage = signalStorage(auth);
|
|
45
45
|
return {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
import { URL } from 'url';
|
|
5
|
+
import { SocketConfig } from '../../Types';
|
|
6
|
+
export declare abstract class AbstractSocketClient extends EventEmitter {
|
|
7
|
+
url: URL;
|
|
8
|
+
config: SocketConfig;
|
|
9
|
+
abstract get isOpen(): boolean;
|
|
10
|
+
abstract get isClosed(): boolean;
|
|
11
|
+
abstract get isClosing(): boolean;
|
|
12
|
+
abstract get isConnecting(): boolean;
|
|
13
|
+
constructor(url: URL, config: SocketConfig);
|
|
14
|
+
abstract connect(): Promise<void>;
|
|
15
|
+
abstract close(): Promise<void>;
|
|
16
|
+
abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
|
17
|
+
}
|
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("
|
|
18
|
-
__exportStar(require("
|
|
19
|
-
__exportStar(require("
|
|
17
|
+
__exportStar(require("./abstract-socket-client"), exports);
|
|
18
|
+
__exportStar(require("./mobile-socket-client"), exports);
|
|
19
|
+
__exportStar(require("./web-socket-client"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Socket } from 'net';
|
|
3
|
+
import { AbstractSocketClient } from './abstract-socket-client';
|
|
4
|
+
export declare class MobileSocketClient extends AbstractSocketClient {
|
|
5
|
+
protected socket: Socket | null;
|
|
6
|
+
get isOpen(): boolean;
|
|
7
|
+
get isClosed(): boolean;
|
|
8
|
+
get isClosing(): boolean;
|
|
9
|
+
get isConnecting(): boolean;
|
|
10
|
+
connect(): Promise<void>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean;
|
|
13
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MobileSocketClient = void 0;
|
|
4
4
|
const net_1 = require("net");
|
|
5
|
-
const abstract_socket_client_1 = require("
|
|
5
|
+
const abstract_socket_client_1 = require("./abstract-socket-client");
|
|
6
6
|
class MobileSocketClient extends abstract_socket_client_1.AbstractSocketClient {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import WebSocket from 'ws';
|
|
2
|
+
import { AbstractSocketClient } from './abstract-socket-client';
|
|
3
|
+
export declare class WebSocketClient extends AbstractSocketClient {
|
|
4
|
+
protected socket: WebSocket | null;
|
|
5
|
+
get isOpen(): boolean;
|
|
6
|
+
get isClosed(): boolean;
|
|
7
|
+
get isClosing(): boolean;
|
|
8
|
+
get isConnecting(): boolean;
|
|
9
|
+
connect(): Promise<void>;
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean;
|
|
12
|
+
}
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WebSocketClient = void 0;
|
|
7
7
|
const ws_1 = __importDefault(require("ws"));
|
|
8
|
-
const Defaults_1 = require("
|
|
9
|
-
const abstract_socket_client_1 = require("
|
|
8
|
+
const Defaults_1 = require("../../Defaults");
|
|
9
|
+
const abstract_socket_client_1 = require("./abstract-socket-client");
|
|
10
10
|
class WebSocketClient extends abstract_socket_client_1.AbstractSocketClient {
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|