astrabail 1.0.8 → 1.0.10
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/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +3 -0
- package/WAProto/fix-imports.js +3 -0
- package/WAProto/index.d.ts +3 -0
- package/WAProto/index.js +3 -0
- package/WAProto/p.html +3 -0
- package/lib/Defaults/astrabail-version.json +3 -0
- package/lib/Defaults/index.d.ts +3 -1
- package/lib/Defaults/index.js +10 -3
- package/lib/Defaults/phonenumber-mcc.json +3 -0
- package/lib/Defaults/update-wa-version.js +3 -1
- package/lib/Signal/Group/ciphertext-message.d.ts +3 -1
- package/lib/Signal/Group/ciphertext-message.js +3 -0
- package/lib/Signal/Group/group-session-builder.d.ts +3 -1
- package/lib/Signal/Group/group-session-builder.js +3 -0
- package/lib/Signal/Group/group_cipher.d.ts +3 -1
- package/lib/Signal/Group/group_cipher.js +3 -0
- package/lib/Signal/Group/index.d.ts +3 -1
- package/lib/Signal/Group/index.js +3 -0
- package/lib/Signal/Group/keyhelper.d.ts +3 -1
- package/lib/Signal/Group/keyhelper.js +3 -0
- package/lib/Signal/Group/queue-job.js +3 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +3 -1
- package/lib/Signal/Group/sender-chain-key.js +3 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +3 -1
- package/lib/Signal/Group/sender-key-distribution-message.js +3 -0
- package/lib/Signal/Group/sender-key-message.d.ts +3 -1
- package/lib/Signal/Group/sender-key-message.js +3 -0
- package/lib/Signal/Group/sender-key-name.d.ts +3 -1
- package/lib/Signal/Group/sender-key-name.js +3 -0
- package/lib/Signal/Group/sender-key-record.d.ts +3 -1
- package/lib/Signal/Group/sender-key-record.js +3 -0
- package/lib/Signal/Group/sender-key-state.d.ts +3 -1
- package/lib/Signal/Group/sender-key-state.js +3 -0
- package/lib/Signal/Group/sender-message-key.d.ts +3 -1
- package/lib/Signal/Group/sender-message-key.js +3 -0
- package/lib/Signal/libsignal.d.ts +3 -1
- package/lib/Signal/libsignal.js +3 -0
- package/lib/Signal/lid-mapping.d.ts +3 -1
- package/lib/Signal/lid-mapping.js +3 -0
- package/lib/Socket/Client/index.d.ts +3 -1
- package/lib/Socket/Client/index.js +3 -0
- package/lib/Socket/Client/types.d.ts +3 -1
- package/lib/Socket/Client/types.js +3 -0
- package/lib/Socket/Client/websocket.d.ts +3 -1
- package/lib/Socket/Client/websocket.js +3 -0
- package/lib/Socket/business.d.ts +5 -3
- package/lib/Socket/business.js +3 -0
- package/lib/Socket/chats.d.ts +5 -3
- package/lib/Socket/chats.js +4 -1
- package/lib/Socket/communities.d.ts +5 -3
- package/lib/Socket/communities.js +3 -0
- package/lib/Socket/community.js +3 -0
- package/lib/Socket/groups.d.ts +5 -3
- package/lib/Socket/groups.js +3 -0
- package/lib/Socket/index.d.ts +5 -3
- package/lib/Socket/index.js +3 -0
- package/lib/Socket/messages-recv.d.ts +5 -3
- package/lib/Socket/messages-recv.js +3 -0
- package/lib/Socket/messages-send.d.ts +5 -3
- package/lib/Socket/messages-send.js +111 -1
- package/lib/Socket/mex.d.ts +3 -1
- package/lib/Socket/mex.js +3 -0
- package/lib/Socket/newsletter.d.ts +5 -3
- package/lib/Socket/newsletter.js +3 -0
- package/lib/Socket/socket.d.ts +5 -3
- package/lib/Socket/socket.js +4 -1
- package/lib/Socket/usync.js +3 -0
- package/lib/Store/index.js +3 -0
- package/lib/Store/make-cache-manager-store.js +3 -0
- package/lib/Store/make-in-memory-store.js +4 -1
- package/lib/Store/make-ordered-dictionary.js +3 -0
- package/lib/Store/object-repository.js +3 -0
- package/lib/Types/Auth.d.ts +3 -1
- package/lib/Types/Auth.js +3 -0
- package/lib/Types/Bussines.d.ts +3 -1
- package/lib/Types/Bussines.js +3 -0
- package/lib/Types/Call.d.ts +3 -1
- package/lib/Types/Call.js +3 -0
- package/lib/Types/Chat.d.ts +3 -1
- package/lib/Types/Chat.js +3 -0
- package/lib/Types/Contact.d.ts +3 -1
- package/lib/Types/Contact.js +3 -0
- package/lib/Types/Events.d.ts +10 -8
- package/lib/Types/Events.js +3 -0
- package/lib/Types/GroupMetadata.d.ts +3 -1
- package/lib/Types/GroupMetadata.js +3 -0
- package/lib/Types/Label.d.ts +3 -1
- package/lib/Types/Label.js +3 -0
- package/lib/Types/LabelAssociation.d.ts +3 -1
- package/lib/Types/LabelAssociation.js +3 -0
- package/lib/Types/Message.d.ts +3 -1
- package/lib/Types/Message.js +3 -0
- package/lib/Types/MexUpdates.js +3 -0
- package/lib/Types/Newsletter.d.ts +3 -1
- package/lib/Types/Newsletter.js +3 -0
- package/lib/Types/Product.d.ts +3 -1
- package/lib/Types/Product.js +3 -0
- package/lib/Types/Signal.d.ts +3 -1
- package/lib/Types/Signal.js +3 -0
- package/lib/Types/Socket.d.ts +6 -4
- package/lib/Types/Socket.js +3 -0
- package/lib/Types/State.d.ts +3 -1
- package/lib/Types/State.js +3 -0
- package/lib/Types/USync.d.ts +3 -1
- package/lib/Types/USync.js +3 -0
- package/lib/Types/index.d.ts +4 -2
- package/lib/Types/index.js +3 -0
- package/lib/Utils/astrabail-event-stream.js +61 -1
- package/lib/Utils/audioToBuffer.js +3 -0
- package/lib/Utils/auth-utils.d.ts +3 -1
- package/lib/Utils/auth-utils.js +3 -0
- package/lib/Utils/bridge-runtime.d.ts +3 -0
- package/lib/Utils/bridge-runtime.js +3 -0
- package/lib/Utils/browser-utils.d.ts +3 -1
- package/lib/Utils/browser-utils.js +6 -3
- package/lib/Utils/business.d.ts +3 -1
- package/lib/Utils/business.js +3 -0
- package/lib/Utils/chat-utils.d.ts +5 -3
- package/lib/Utils/chat-utils.js +3 -0
- package/lib/Utils/crypto.d.ts +3 -1
- package/lib/Utils/crypto.js +3 -0
- package/lib/Utils/decode-wa-message.d.ts +3 -1
- package/lib/Utils/decode-wa-message.js +3 -0
- package/lib/Utils/event-buffer.d.ts +8 -6
- package/lib/Utils/event-buffer.js +4 -1
- package/lib/Utils/generics.d.ts +10 -7
- package/lib/Utils/generics.js +15 -12
- package/lib/Utils/history.d.ts +3 -1
- package/lib/Utils/history.js +3 -0
- package/lib/Utils/identity-change-handler.d.ts +3 -1
- package/lib/Utils/identity-change-handler.js +3 -0
- package/lib/Utils/index.d.ts +3 -1
- package/lib/Utils/index.js +3 -1
- package/lib/Utils/link-preview.d.ts +3 -1
- package/lib/Utils/link-preview.js +3 -0
- package/lib/Utils/logger.d.ts +3 -1
- package/lib/Utils/logger.js +3 -0
- package/lib/Utils/lt-hash.d.ts +3 -1
- package/lib/Utils/lt-hash.js +3 -0
- package/lib/Utils/make-mutex.d.ts +3 -1
- package/lib/Utils/make-mutex.js +3 -0
- package/lib/Utils/message-retry-manager.d.ts +3 -1
- package/lib/Utils/message-retry-manager.js +3 -0
- package/lib/Utils/messages-media.d.ts +3 -1
- package/lib/Utils/messages-media.js +4 -1
- package/lib/Utils/messages-newsletter.d.ts +3 -0
- package/lib/Utils/messages-newsletter.js +3 -0
- package/lib/Utils/messages.d.ts +3 -1
- package/lib/Utils/messages.js +4 -1
- package/lib/Utils/noise-handler.d.ts +3 -1
- package/lib/Utils/noise-handler.js +3 -0
- package/lib/Utils/pre-key-manager.d.ts +3 -1
- package/lib/Utils/pre-key-manager.js +3 -0
- package/lib/Utils/process-message.d.ts +5 -3
- package/lib/Utils/process-message.js +3 -0
- package/lib/Utils/reporting-utils.d.ts +3 -1
- package/lib/Utils/reporting-utils.js +3 -0
- package/lib/Utils/resolve-jid.d.ts +3 -0
- package/lib/Utils/resolve-jid.js +3 -0
- package/lib/Utils/rust-bridge-shim.d.ts +3 -0
- package/lib/Utils/rust-bridge-shim.js +3 -0
- package/lib/Utils/serial-task-queue.js +3 -0
- package/lib/Utils/signal.d.ts +3 -1
- package/lib/Utils/signal.js +3 -0
- package/lib/Utils/streamToBuffer.js +3 -0
- package/lib/Utils/sync-action-utils.d.ts +6 -4
- package/lib/Utils/sync-action-utils.js +3 -0
- package/lib/Utils/tc-token-utils.d.ts +3 -1
- package/lib/Utils/tc-token-utils.js +3 -0
- package/lib/Utils/use-mongo-file-auth-state.js +3 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +3 -1
- package/lib/Utils/use-multi-file-auth-state.js +4 -1
- package/lib/Utils/use-single-file-auth-state.js +3 -0
- package/lib/Utils/validate-connection.d.ts +3 -1
- package/lib/Utils/validate-connection.js +3 -0
- package/lib/WABinary/constants.d.ts +3 -1
- package/lib/WABinary/constants.js +3 -0
- package/lib/WABinary/decode.d.ts +3 -1
- package/lib/WABinary/decode.js +3 -0
- package/lib/WABinary/encode.d.ts +3 -1
- package/lib/WABinary/encode.js +3 -0
- package/lib/WABinary/generic-utils.d.ts +3 -1
- package/lib/WABinary/generic-utils.js +3 -0
- package/lib/WABinary/index.d.ts +3 -1
- package/lib/WABinary/index.js +3 -0
- package/lib/WABinary/jid-utils.d.ts +3 -1
- package/lib/WABinary/jid-utils.js +3 -0
- package/lib/WABinary/types.d.ts +3 -1
- package/lib/WABinary/types.js +3 -0
- package/lib/WAM/BinaryInfo.d.ts +3 -1
- package/lib/WAM/BinaryInfo.js +3 -0
- package/lib/WAM/constants.d.ts +3 -1
- package/lib/WAM/constants.js +3 -0
- package/lib/WAM/encode.d.ts +3 -1
- package/lib/WAM/encode.js +3 -0
- package/lib/WAM/index.d.ts +3 -1
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +3 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +3 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +3 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +3 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +3 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +3 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -0
- package/lib/WAUSync/Protocols/index.d.ts +3 -1
- package/lib/WAUSync/Protocols/index.js +3 -0
- package/lib/WAUSync/USyncQuery.d.ts +3 -1
- package/lib/WAUSync/USyncQuery.js +3 -0
- package/lib/WAUSync/USyncUser.d.ts +3 -1
- package/lib/WAUSync/USyncUser.js +3 -0
- package/lib/WAUSync/index.d.ts +3 -1
- package/lib/WAUSync/index.js +3 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/package.json +3 -3
- package/readme.md +1956 -1956
- package/lib/Utils/baileys-event-stream.js +0 -60
|
@@ -1,3 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
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_js_1 = require("./generics.js");
|
|
12
|
+
const make_mutex_js_1 = require("./make-mutex.js");
|
|
13
|
+
/**
|
|
14
|
+
* Captures events from a AstraBail 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_js_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
|
+
const fileStream = (0, fs_1.createReadStream)(filename);
|
|
42
|
+
const rl = (0, readline_1.createInterface)({
|
|
43
|
+
input: fileStream,
|
|
44
|
+
crlfDelay: Infinity
|
|
45
|
+
});
|
|
46
|
+
for await (const line of rl) {
|
|
47
|
+
if (line) {
|
|
48
|
+
const { event, data } = JSON.parse(line);
|
|
49
|
+
ev.emit(event, data);
|
|
50
|
+
delayIntervalMs && await (0, generics_js_1.delay)(delayIntervalMs);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
fileStream.close();
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
ev,
|
|
57
|
+
task: fireEvents()
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
exports.readAndEmitEventStream = readAndEmitEventStream;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
@@ -16,4 +16,6 @@ export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logge
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const addTransactionCapability: (state: SignalKeyStore, logger: ILogger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
|
|
18
18
|
export declare const initAuthCreds: () => AuthenticationCreds;
|
|
19
|
-
//# sourceMappingURL=auth-utils.d.ts.map
|
|
19
|
+
//# sourceMappingURL=auth-utils.d.ts.map
|
|
20
|
+
|
|
21
|
+
|
package/lib/Utils/auth-utils.js
CHANGED
|
@@ -6,7 +6,7 @@ const index_js_1 = require("../../WAProto/index.js");
|
|
|
6
6
|
exports.PLATFORM_MAP = {
|
|
7
7
|
'aix': 'AIX', 'darwin': 'Mac OS', 'win32': 'Windows', 'android': 'Android',
|
|
8
8
|
'freebsd': 'FreeBSD', 'openbsd': 'OpenBSD', 'sunos': 'Solaris', 'linux': 'Linux',
|
|
9
|
-
'ubuntu': 'Ubuntu', 'ios': 'iOS', '
|
|
9
|
+
'ubuntu': 'Ubuntu', 'ios': 'iOS', 'astrabail': 'AstraBail', 'chromeos': 'Chrome OS',
|
|
10
10
|
'tizen': 'Tizen', 'watchos': 'watchOS', 'wearos': 'Wear OS', 'harmonyos': 'HarmonyOS',
|
|
11
11
|
'kaios': 'KaiOS', 'smarttv': 'Smart TV', 'raspberrypi': 'Raspberry Pi OS',
|
|
12
12
|
'symbian': 'Symbian', 'blackberry': 'Blackberry OS', 'windowsphone': 'Windows Phone'
|
|
@@ -14,7 +14,7 @@ exports.PLATFORM_MAP = {
|
|
|
14
14
|
exports.PLATFORM_VERSIONS = {
|
|
15
15
|
'ubuntu': '22.04.4', 'darwin': '18.5', 'win32': '10.0.22631', 'android': '14.0.0',
|
|
16
16
|
'freebsd': '13.2', 'openbsd': '7.3', 'sunos': '11', 'linux': '6.5', 'ios': '18.2',
|
|
17
|
-
'
|
|
17
|
+
'astrabail': '6.5.0', 'chromeos': '117.0.5938.132', 'tizen': '6.5', 'watchos': '10.1',
|
|
18
18
|
'wearos': '4.1', 'harmonyos': '4.0.0', 'kaios': '3.1', 'smarttv': '23.3.1',
|
|
19
19
|
'raspberrypi': '11 (Bullseye)', 'symbian': '3', 'blackberry': '10.3.3', 'windowsphone': '8.1'
|
|
20
20
|
};
|
|
@@ -24,7 +24,7 @@ exports.Browsers = {
|
|
|
24
24
|
windows: (browser) => [exports.PLATFORM_MAP['win32'], browser, exports.PLATFORM_VERSIONS['win32']],
|
|
25
25
|
linux: (browser) => [exports.PLATFORM_MAP['linux'], browser, exports.PLATFORM_VERSIONS['linux']],
|
|
26
26
|
solaris: (browser) => [exports.PLATFORM_MAP['sunos'], browser, exports.PLATFORM_VERSIONS['sunos']],
|
|
27
|
-
|
|
27
|
+
astrabail: (browser) => [exports.PLATFORM_MAP['astrabail'], browser, exports.PLATFORM_VERSIONS['astrabail']],
|
|
28
28
|
android: (browser) => [exports.PLATFORM_MAP['android'], browser, exports.PLATFORM_VERSIONS['android']],
|
|
29
29
|
iOS: (browser) => [exports.PLATFORM_MAP['ios'], browser, exports.PLATFORM_VERSIONS['ios']],
|
|
30
30
|
kaiOS: (browser) => [exports.PLATFORM_MAP['kaios'], browser, exports.PLATFORM_VERSIONS['kaios']],
|
|
@@ -42,3 +42,6 @@ const getPlatformId = (browser) => {
|
|
|
42
42
|
return platformType ? platformType.toString() : '1';
|
|
43
43
|
};
|
|
44
44
|
exports.getPlatformId = getPlatformId;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
package/lib/Utils/business.d.ts
CHANGED
|
@@ -20,4 +20,6 @@ export declare function uploadingNecessaryImagesOfProduct<T extends ProductUpdat
|
|
|
20
20
|
export declare const uploadingNecessaryImages: (images: WAMediaUpload[], waUploadToServer: WAMediaUploadFunction, timeoutMs?: number) => Promise<{
|
|
21
21
|
url: string;
|
|
22
22
|
}[]>;
|
|
23
|
-
//# sourceMappingURL=business.d.ts.map
|
|
23
|
+
//# sourceMappingURL=business.d.ts.map
|
|
24
|
+
|
|
25
|
+
|
package/lib/Utils/business.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proto } from '../../WAProto/index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AstraBailEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types/index.js';
|
|
3
3
|
import { type BinaryNode } from '../WABinary/index.js';
|
|
4
4
|
import type { ILogger } from './logger.js';
|
|
5
5
|
type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
|
|
@@ -65,6 +65,8 @@ export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatc
|
|
|
65
65
|
mutationMap: ChatMutationMap;
|
|
66
66
|
}>;
|
|
67
67
|
export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
|
|
68
|
-
export declare const processSyncAction: (syncAction: ChatMutation, ev:
|
|
68
|
+
export declare const processSyncAction: (syncAction: ChatMutation, ev: AstraBailEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: ILogger) => void;
|
|
69
69
|
export {};
|
|
70
|
-
//# sourceMappingURL=chat-utils.d.ts.map
|
|
70
|
+
//# sourceMappingURL=chat-utils.d.ts.map
|
|
71
|
+
|
|
72
|
+
|
package/lib/Utils/chat-utils.js
CHANGED
package/lib/Utils/crypto.d.ts
CHANGED
|
@@ -34,4 +34,6 @@ export declare function aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer)
|
|
|
34
34
|
export declare function hmacSign(buffer: Buffer | Uint8Array, key: Buffer | Uint8Array, variant?: 'sha256' | 'sha512'): NonSharedBuffer;
|
|
35
35
|
export declare function sha256(buffer: Buffer): NonSharedBuffer;
|
|
36
36
|
export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer): Promise<Buffer>;
|
|
37
|
-
//# sourceMappingURL=crypto.d.ts.map
|
|
37
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
38
|
+
|
|
39
|
+
|
package/lib/Utils/crypto.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AstraBailEventEmitter, AstraBailEventMap } from '../Types/index.js';
|
|
2
2
|
import type { ILogger } from './logger.js';
|
|
3
3
|
/**
|
|
4
4
|
* A map that contains a list of all events that have been triggered
|
|
@@ -7,10 +7,10 @@ import type { ILogger } from './logger.js';
|
|
|
7
7
|
* this can make processing events extremely efficient -- since everything
|
|
8
8
|
* can be done in a single transaction
|
|
9
9
|
*/
|
|
10
|
-
type
|
|
11
|
-
type
|
|
10
|
+
type AstraBailEventData = Partial<AstraBailEventMap>;
|
|
11
|
+
type AstraBailBufferableEventEmitter = AstraBailEventEmitter & {
|
|
12
12
|
/** Use to process events in a batch */
|
|
13
|
-
process(handler: (events:
|
|
13
|
+
process(handler: (events: AstraBailEventData) => void | Promise<void>): () => void;
|
|
14
14
|
/**
|
|
15
15
|
* starts buffering events, call flush() to release them
|
|
16
16
|
* */
|
|
@@ -29,6 +29,8 @@ type BaileysBufferableEventEmitter = BaileysEventEmitter & {
|
|
|
29
29
|
* The event buffer logically consolidates different events into a single event
|
|
30
30
|
* making the data processing more efficient.
|
|
31
31
|
*/
|
|
32
|
-
export declare const makeEventBuffer: (logger: ILogger) =>
|
|
32
|
+
export declare const makeEventBuffer: (logger: ILogger) => AstraBailBufferableEventEmitter;
|
|
33
33
|
export {};
|
|
34
|
-
//# sourceMappingURL=event-buffer.d.ts.map
|
|
34
|
+
//# sourceMappingURL=event-buffer.d.ts.map
|
|
35
|
+
|
|
36
|
+
|
|
@@ -38,7 +38,7 @@ const makeEventBuffer = (logger) => {
|
|
|
38
38
|
let bufferCount = 0;
|
|
39
39
|
const MAX_HISTORY_CACHE_SIZE = 10000; // Limit the history cache size to prevent memory bloat
|
|
40
40
|
const BUFFER_TIMEOUT_MS = 30000; // 30 seconds
|
|
41
|
-
// take the generic event and fire it as a
|
|
41
|
+
// take the generic event and fire it as a AstraBail event
|
|
42
42
|
ev.on('event', (map) => {
|
|
43
43
|
for (const event in map) {
|
|
44
44
|
ev.emit(event, map[event]);
|
|
@@ -578,3 +578,6 @@ function concatChats(a, b) {
|
|
|
578
578
|
return Object.assign(a, b);
|
|
579
579
|
}
|
|
580
580
|
const stringifyMessageKey = (key) => `${key.remoteJid},${key.id},${key.fromMe ? '1' : '0'}`;
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
package/lib/Utils/generics.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proto } from '../../WAProto/index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AstraBailEventEmitter, AstraBailEventMap, ConnectionState, WACallUpdateType, WAMessageKey, WAVersion } from '../Types/index.js';
|
|
3
3
|
import { type BinaryNode } from '../WABinary/index.js';
|
|
4
4
|
export declare const BufferJSON: {
|
|
5
5
|
replacer: (k: any, value: any) => any;
|
|
@@ -31,13 +31,13 @@ export declare const delayCancellable: (ms: number) => {
|
|
|
31
31
|
export declare function promiseTimeout<T>(ms: number | undefined, promise: (resolve: (v: T) => void, reject: (error: any) => void) => void): Promise<T>;
|
|
32
32
|
export declare const generateMessageIDV2: (userId?: string) => string;
|
|
33
33
|
export declare const generateMessageID: () => string;
|
|
34
|
-
export declare function bindWaitForEvent<T extends keyof
|
|
35
|
-
export declare const bindWaitForConnectionUpdate: (ev:
|
|
34
|
+
export declare function bindWaitForEvent<T extends keyof AstraBailEventMap>(ev: AstraBailEventEmitter, event: T): (check: (u: AstraBailEventMap[T]) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
35
|
+
export declare const bindWaitForConnectionUpdate: (ev: AstraBailEventEmitter) => (check: (u: Partial<ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
36
36
|
/**
|
|
37
|
-
* utility that fetches latest
|
|
37
|
+
* utility that fetches latest AstraBail version from the master branch.
|
|
38
38
|
* Use to ensure your WA connection is always on the latest version
|
|
39
39
|
*/
|
|
40
|
-
export declare const
|
|
40
|
+
export declare const fetchLatestAstraBailVersion: (options?: RequestInit) => Promise<{
|
|
41
41
|
version: WAVersion;
|
|
42
42
|
isLatest: boolean;
|
|
43
43
|
error?: undefined;
|
|
@@ -67,7 +67,7 @@ export declare const generateMdTagPrefix: () => string;
|
|
|
67
67
|
*/
|
|
68
68
|
export declare const getStatusFromReceiptType: (type: string | undefined) => proto.WebMessageInfo.Status | undefined;
|
|
69
69
|
/**
|
|
70
|
-
* Stream errors generally provide a reason, map that to a
|
|
70
|
+
* Stream errors generally provide a reason, map that to a AstraBail DisconnectReason
|
|
71
71
|
* @param reason the string reason given, eg. "conflict"
|
|
72
72
|
*/
|
|
73
73
|
export declare const getErrorCodeFromStreamError: (node: BinaryNode) => {
|
|
@@ -88,4 +88,7 @@ export declare function trimUndefined(obj: {
|
|
|
88
88
|
};
|
|
89
89
|
export declare function bytesToCrockford(buffer: Buffer): string;
|
|
90
90
|
export declare function encodeNewsletterMessage(message: proto.IMessage): Uint8Array;
|
|
91
|
-
|
|
91
|
+
export declare const fetchLatestBaileysVersion: typeof fetchLatestAstraBailVersion;
|
|
92
|
+
//# sourceMappingURL=generics.d.ts.map
|
|
93
|
+
|
|
94
|
+
|
package/lib/Utils/generics.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.fetchLatestAstraVersion = exports.asciiDecode = exports.asciiEncode = exports.fromUnicodeEscape = exports.toUnicodeEscape = exports.printQRIfNecessaryListener = exports.COMPANION_PLATFORM_MAP = exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.
|
|
39
|
+
exports.fetchLatestAstraVersion = exports.asciiDecode = exports.asciiEncode = exports.fromUnicodeEscape = exports.toUnicodeEscape = exports.printQRIfNecessaryListener = exports.COMPANION_PLATFORM_MAP = exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestAstraBailVersion = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeWAMessage = exports.generateParticipantHashV2 = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.isStringNullOrEmpty = exports.getKeyAuthor = exports.BufferJSON = void 0;
|
|
40
40
|
exports.promiseTimeout = promiseTimeout;
|
|
41
41
|
exports.bindWaitForEvent = bindWaitForEvent;
|
|
42
42
|
exports.trimUndefined = trimUndefined;
|
|
@@ -47,7 +47,7 @@ const crypto_1 = require("crypto");
|
|
|
47
47
|
const axios_1 = __importDefault(require("axios"));
|
|
48
48
|
const index_js_1 = require("../../WAProto/index.js");
|
|
49
49
|
const waVer = require('../Defaults/astrabail-version.json');
|
|
50
|
-
const
|
|
50
|
+
const AstraBailVersion = waVer?.version || [2, 3000, 1036687490];
|
|
51
51
|
const index_js_2 = require("../Types/index.js");
|
|
52
52
|
const index_js_3 = require("../WABinary/index.js");
|
|
53
53
|
const crypto_js_1 = require("./crypto.js");
|
|
@@ -235,11 +235,11 @@ function bindWaitForEvent(ev, event) {
|
|
|
235
235
|
const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, 'connection.update');
|
|
236
236
|
exports.bindWaitForConnectionUpdate = bindWaitForConnectionUpdate;
|
|
237
237
|
/**
|
|
238
|
-
* utility that fetches latest
|
|
238
|
+
* utility that fetches latest AstraBail version from the master branch.
|
|
239
239
|
* Use to ensure your WA connection is always on the latest version
|
|
240
240
|
*/
|
|
241
|
-
const
|
|
242
|
-
const URL = 'https://raw.githubusercontent.com/
|
|
241
|
+
const fetchLatestAstraBailVersion = async (options = {}) => {
|
|
242
|
+
const URL = 'https://raw.githubusercontent.com/Danimaru-ze/AstraBail/main/src/Defaults/index.ts';
|
|
243
243
|
try {
|
|
244
244
|
const response = await fetch(URL, {
|
|
245
245
|
dispatcher: options.dispatcher,
|
|
@@ -247,7 +247,7 @@ const fetchLatestBaileysVersion = async (options = {}) => {
|
|
|
247
247
|
headers: options.headers
|
|
248
248
|
});
|
|
249
249
|
if (!response.ok) {
|
|
250
|
-
throw new boom_1.Boom(`Failed to fetch latest
|
|
250
|
+
throw new boom_1.Boom(`Failed to fetch latest AstraBail version: ${response.statusText}`, { statusCode: response.status });
|
|
251
251
|
}
|
|
252
252
|
const text = await response.text();
|
|
253
253
|
// Extract version from line 7 (const version = [...])
|
|
@@ -267,13 +267,13 @@ const fetchLatestBaileysVersion = async (options = {}) => {
|
|
|
267
267
|
}
|
|
268
268
|
catch (error) {
|
|
269
269
|
return {
|
|
270
|
-
version:
|
|
270
|
+
version: AstraBailVersion,
|
|
271
271
|
isLatest: false,
|
|
272
272
|
error
|
|
273
273
|
};
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
|
-
exports.
|
|
276
|
+
exports.fetchLatestAstraBailVersion = fetchLatestAstraBailVersion;
|
|
277
277
|
/**
|
|
278
278
|
* A utility that fetches the latest web version of whatsapp.
|
|
279
279
|
* Use to ensure your WA connection is always on the latest version
|
|
@@ -299,7 +299,7 @@ const fetchLatestWaWebVersion = async (options = {}) => {
|
|
|
299
299
|
const match = data.match(regex);
|
|
300
300
|
if (!match?.[1]) {
|
|
301
301
|
return {
|
|
302
|
-
version:
|
|
302
|
+
version: AstraBailVersion,
|
|
303
303
|
isLatest: false,
|
|
304
304
|
error: {
|
|
305
305
|
message: 'Could not find client revision in the fetched content'
|
|
@@ -314,7 +314,7 @@ const fetchLatestWaWebVersion = async (options = {}) => {
|
|
|
314
314
|
}
|
|
315
315
|
catch (error) {
|
|
316
316
|
return {
|
|
317
|
-
version:
|
|
317
|
+
version: AstraBailVersion,
|
|
318
318
|
isLatest: false,
|
|
319
319
|
error
|
|
320
320
|
};
|
|
@@ -349,7 +349,7 @@ const CODE_MAP = {
|
|
|
349
349
|
conflict: index_js_2.DisconnectReason.connectionReplaced
|
|
350
350
|
};
|
|
351
351
|
/**
|
|
352
|
-
* Stream errors generally provide a reason, map that to a
|
|
352
|
+
* Stream errors generally provide a reason, map that to a AstraBail DisconnectReason
|
|
353
353
|
* @param reason the string reason given, eg. "conflict"
|
|
354
354
|
*/
|
|
355
355
|
const getErrorCodeFromStreamError = (node) => {
|
|
@@ -480,4 +480,7 @@ const asciiDecode = (...codes) => {
|
|
|
480
480
|
};
|
|
481
481
|
exports.asciiDecode = asciiDecode;
|
|
482
482
|
|
|
483
|
-
exports.fetchLatestAstraVersion = exports.
|
|
483
|
+
exports.fetchLatestBaileysVersion = exports.fetchLatestAstraVersion = exports.fetchLatestAstraBailVersion;
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
package/lib/Utils/history.d.ts
CHANGED
|
@@ -19,4 +19,6 @@ export declare const downloadAndProcessHistorySyncNotification: (msg: proto.Mess
|
|
|
19
19
|
progress: number | null | undefined;
|
|
20
20
|
}>;
|
|
21
21
|
export declare const getHistoryMsg: (message: proto.IMessage) => proto.Message.IHistorySyncNotification;
|
|
22
|
-
//# sourceMappingURL=history.d.ts.map
|
|
22
|
+
//# sourceMappingURL=history.d.ts.map
|
|
23
|
+
|
|
24
|
+
|
package/lib/Utils/history.js
CHANGED
|
@@ -34,4 +34,6 @@ export type IdentityChangeContext = {
|
|
|
34
34
|
logger: ILogger;
|
|
35
35
|
};
|
|
36
36
|
export declare function handleIdentityChange(node: BinaryNode, ctx: IdentityChangeContext): Promise<IdentityChangeResult>;
|
|
37
|
-
//# sourceMappingURL=identity-change-handler.d.ts.map
|
|
37
|
+
//# sourceMappingURL=identity-change-handler.d.ts.map
|
|
38
|
+
|
|
39
|
+
|
package/lib/Utils/index.d.ts
CHANGED
package/lib/Utils/index.js
CHANGED
|
@@ -35,7 +35,6 @@ __exportStar(require("./use-multi-file-auth-state.js"), exports);
|
|
|
35
35
|
__exportStar(require("./use-single-file-auth-state.js"), exports);
|
|
36
36
|
__exportStar(require("./use-mongo-file-auth-state.js"), exports);
|
|
37
37
|
__exportStar(require("./astrabail-event-stream.js"), exports);
|
|
38
|
-
__exportStar(require("./baileys-event-stream.js"), exports);
|
|
39
38
|
__exportStar(require("./link-preview.js"), exports);
|
|
40
39
|
__exportStar(require("./event-buffer.js"), exports);
|
|
41
40
|
__exportStar(require("./process-message.js"), exports);
|
|
@@ -46,3 +45,6 @@ __exportStar(require("./resolve-jid.js"), exports);
|
|
|
46
45
|
__exportStar(require("./reporting-utils.js"), exports);
|
|
47
46
|
__exportStar(require("./sync-action-utils.js"), exports);
|
|
48
47
|
__exportStar(require("./tc-token-utils.js"), exports);
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
@@ -18,4 +18,6 @@ export type URLGenerationOptions = {
|
|
|
18
18
|
* @returns the URL info required to generate link preview
|
|
19
19
|
*/
|
|
20
20
|
export declare const getUrlInfo: (text: string, opts?: URLGenerationOptions) => Promise<WAUrlInfo | undefined>;
|
|
21
|
-
//# sourceMappingURL=link-preview.d.ts.map
|
|
21
|
+
//# sourceMappingURL=link-preview.d.ts.map
|
|
22
|
+
|
|
23
|
+
|
package/lib/Utils/logger.d.ts
CHANGED
package/lib/Utils/logger.js
CHANGED
|
@@ -5,3 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const pino_1 = __importDefault(require("pino"));
|
|
7
7
|
exports.default = (0, pino_1.default)({ timestamp: () => `,"time":"${new Date().toJSON()}"` });
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
package/lib/Utils/lt-hash.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ import { LTHashAntiTampering } from './bridge-runtime.js';
|
|
|
5
5
|
* if the same series of mutations was made sequentially.
|
|
6
6
|
*/
|
|
7
7
|
export declare const LT_HASH_ANTI_TAMPERING: LTHashAntiTampering;
|
|
8
|
-
//# sourceMappingURL=lt-hash.d.ts.map
|
|
8
|
+
//# sourceMappingURL=lt-hash.d.ts.map
|
|
9
|
+
|
|
10
|
+
|
package/lib/Utils/lt-hash.js
CHANGED
package/lib/Utils/make-mutex.js
CHANGED
|
@@ -127,4 +127,6 @@ export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
|
|
|
127
127
|
}, mediaKey: Uint8Array, msgId: string) => proto.MediaRetryNotification;
|
|
128
128
|
export declare const getStatusCodeForMediaRetry: (code: number) => 200 | 412 | 404 | 418;
|
|
129
129
|
export {};
|
|
130
|
-
//# sourceMappingURL=messages-media.d.ts.map
|
|
130
|
+
//# sourceMappingURL=messages-media.d.ts.map
|
|
131
|
+
|
|
132
|
+
|
|
@@ -712,7 +712,7 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
|
|
|
712
712
|
const url = `https://${hostname}${mediaPath}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`;
|
|
713
713
|
let result;
|
|
714
714
|
try {
|
|
715
|
-
// Upload buffer directly
|
|
715
|
+
// Upload buffer directly (AstraBail optimization avoids file I/O issues)
|
|
716
716
|
const axios = (await Promise.resolve().then(() => __importStar(require('axios')))).default;
|
|
717
717
|
const body = await axios.post(url, reqBuffer, {
|
|
718
718
|
...options,
|
|
@@ -885,3 +885,6 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
|
|
|
885
885
|
}
|
|
886
886
|
};
|
|
887
887
|
exports.prepareStream = prepareStream;
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
package/lib/Utils/messages.d.ts
CHANGED
|
@@ -89,4 +89,6 @@ export declare const downloadMediaMessage: <Type extends "buffer" | "stream">(me
|
|
|
89
89
|
/** Checks whether the given message is a media message; if it is returns the inner content */
|
|
90
90
|
export declare const assertMediaContent: (content: proto.IMessage | null | undefined) => proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
91
91
|
export {};
|
|
92
|
-
//# sourceMappingURL=messages.d.ts.map
|
|
92
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
93
|
+
|
|
94
|
+
|
package/lib/Utils/messages.js
CHANGED
|
@@ -1315,7 +1315,7 @@ exports.generateWAMessageFromContent = generateWAMessageFromContent;
|
|
|
1315
1315
|
const generateWAMessage = async (jid, content, options) => {
|
|
1316
1316
|
// ensure msg ID is with every log
|
|
1317
1317
|
options.logger = options?.logger?.child({ msgId: options.messageId });
|
|
1318
|
-
// Pass jid + newsletter flag to generateWAMessageContent (
|
|
1318
|
+
// Pass jid + newsletter flag to generateWAMessageContent (astrabail patch)
|
|
1319
1319
|
const _isNewsletter = typeof jid === 'string' && jid.endsWith('@newsletter');
|
|
1320
1320
|
return (0, exports.generateWAMessageFromContent)(jid, await (0, exports.generateWAMessageContent)(content, { newsletter: _isNewsletter, ...options, jid }), options);
|
|
1321
1321
|
};
|
|
@@ -1750,3 +1750,6 @@ const getQuotedMsg = (msg, options = {}) => {
|
|
|
1750
1750
|
return result;
|
|
1751
1751
|
};
|
|
1752
1752
|
exports.getQuotedMsg = getQuotedMsg;
|
|
1753
|
+
|
|
1754
|
+
|
|
1755
|
+
|
|
@@ -17,4 +17,6 @@ export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public
|
|
|
17
17
|
encodeFrame: (data: Buffer | Uint8Array) => Buffer<ArrayBuffer>;
|
|
18
18
|
decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => Promise<void>;
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=noise-handler.d.ts.map
|
|
20
|
+
//# sourceMappingURL=noise-handler.d.ts.map
|
|
21
|
+
|
|
22
|
+
|