ndikzv1 26.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WAProto/index.d.ts +55057 -0
- package/WAProto/index.js +169661 -0
- package/WASignalGroup/GroupProtocol.js +1697 -0
- package/WASignalGroup/ciphertext_message.js +16 -0
- package/WASignalGroup/group_cipher.js +120 -0
- package/WASignalGroup/group_session_builder.js +46 -0
- package/WASignalGroup/index.js +5 -0
- package/WASignalGroup/keyhelper.js +21 -0
- package/WASignalGroup/protobufs.js +3 -0
- package/WASignalGroup/queue_job.js +69 -0
- package/WASignalGroup/sender_chain_key.js +50 -0
- package/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/WASignalGroup/sender_key_message.js +92 -0
- package/WASignalGroup/sender_key_name.js +70 -0
- package/WASignalGroup/sender_key_record.js +56 -0
- package/WASignalGroup/sender_key_state.js +129 -0
- package/WASignalGroup/sender_message_key.js +39 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +282 -0
- package/lib/Defaults/index.js +122 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +161 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +15 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +19 -0
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/web-socket-client.d.ts +12 -0
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/business.d.ts +172 -0
- package/lib/Socket/business.js +260 -0
- package/lib/Socket/chats.d.ts +83 -0
- package/lib/Socket/chats.js +871 -0
- package/lib/Socket/groups.d.ts +124 -0
- package/lib/Socket/groups.js +332 -0
- package/lib/Socket/index.d.ts +174 -0
- package/lib/Socket/index.js +10 -0
- package/lib/Socket/messages-recv.d.ts +161 -0
- package/lib/Socket/messages-recv.js +1046 -0
- package/lib/Socket/messages-send.d.ts +151 -0
- package/lib/Socket/messages-send.js +806 -0
- package/lib/Socket/newsletter.d.ts +136 -0
- package/lib/Socket/newsletter.js +250 -0
- package/lib/Socket/registration.d.ts +266 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +42 -0
- package/lib/Socket/socket.js +640 -0
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.d.ts +2 -0
- package/lib/Store/index.js +8 -0
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +431 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.d.ts +109 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.d.ts +109 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.d.ts +23 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.d.ts +199 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.d.ts +64 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.d.ts +35 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.d.ts +384 -0
- package/lib/Types/Message.js +7 -0
- package/lib/Types/Newsletter.d.ts +79 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.d.ts +119 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +64 -0
- package/lib/Types/index.js +42 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +206 -0
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/business.js +234 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/chat-utils.js +730 -0
- package/lib/Utils/crypto.d.ts +40 -0
- package/lib/Utils/crypto.js +193 -0
- package/lib/Utils/decode-wa-message.d.ts +36 -0
- package/lib/Utils/decode-wa-message.js +204 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +520 -0
- package/lib/Utils/generics.d.ts +89 -0
- package/lib/Utils/generics.js +445 -0
- package/lib/Utils/history.d.ts +19 -0
- package/lib/Utils/history.js +94 -0
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/index.js +33 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +126 -0
- package/lib/Utils/logger.d.ts +11 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +51 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/messages-media.d.ts +120 -0
- package/lib/Utils/messages-media.js +879 -0
- package/lib/Utils/messages.d.ts +75 -0
- package/lib/Utils/messages.js +1022 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +155 -0
- package/lib/Utils/process-message.d.ts +42 -0
- package/lib/Utils/process-message.js +372 -0
- package/lib/Utils/signal.d.ts +33 -0
- package/lib/Utils/signal.js +153 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-multi-file-auth-state.js +125 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +207 -0
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.d.ts +6 -0
- package/lib/WABinary/decode.js +265 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +250 -0
- package/lib/WABinary/generic-utils.d.ts +14 -0
- package/lib/WABinary/generic-utils.js +110 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.d.ts +36 -0
- package/lib/WABinary/jid-utils.js +83 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncQuery.js +89 -0
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +63 -0
- package/package.json +90 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
function makeOrderedDictionary(idGetter) {
|
4
|
+
const array = [];
|
5
|
+
const dict = {};
|
6
|
+
const get = (id) => dict[id];
|
7
|
+
const update = (item) => {
|
8
|
+
const id = idGetter(item);
|
9
|
+
const idx = array.findIndex(i => idGetter(i) === id);
|
10
|
+
if (idx >= 0) {
|
11
|
+
array[idx] = item;
|
12
|
+
dict[id] = item;
|
13
|
+
}
|
14
|
+
return false;
|
15
|
+
};
|
16
|
+
const upsert = (item, mode) => {
|
17
|
+
const id = idGetter(item);
|
18
|
+
if (get(id)) {
|
19
|
+
update(item);
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
if (mode === 'append') {
|
23
|
+
array.push(item);
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
array.splice(0, 0, item);
|
27
|
+
}
|
28
|
+
dict[id] = item;
|
29
|
+
}
|
30
|
+
};
|
31
|
+
const remove = (item) => {
|
32
|
+
const id = idGetter(item);
|
33
|
+
const idx = array.findIndex(i => idGetter(i) === id);
|
34
|
+
if (idx >= 0) {
|
35
|
+
array.splice(idx, 1);
|
36
|
+
delete dict[id];
|
37
|
+
return true;
|
38
|
+
}
|
39
|
+
return false;
|
40
|
+
};
|
41
|
+
return {
|
42
|
+
array,
|
43
|
+
get,
|
44
|
+
upsert,
|
45
|
+
update,
|
46
|
+
remove,
|
47
|
+
updateAssign: (id, update) => {
|
48
|
+
const item = get(id);
|
49
|
+
if (item) {
|
50
|
+
Object.assign(item, update);
|
51
|
+
delete dict[id];
|
52
|
+
dict[idGetter(item)] = item;
|
53
|
+
return true;
|
54
|
+
}
|
55
|
+
return false;
|
56
|
+
},
|
57
|
+
clear: () => {
|
58
|
+
array.splice(0, array.length);
|
59
|
+
for (const key of Object.keys(dict)) {
|
60
|
+
delete dict[key];
|
61
|
+
}
|
62
|
+
},
|
63
|
+
filter: (contain) => {
|
64
|
+
let i = 0;
|
65
|
+
while (i < array.length) {
|
66
|
+
if (!contain(array[i])) {
|
67
|
+
delete dict[idGetter(array[i])];
|
68
|
+
array.splice(i, 1);
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
i += 1;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
},
|
75
|
+
toJSON: () => array,
|
76
|
+
fromJSON: (newItems) => {
|
77
|
+
array.splice(0, array.length, ...newItems);
|
78
|
+
}
|
79
|
+
};
|
80
|
+
}
|
81
|
+
exports.default = makeOrderedDictionary;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare class ObjectRepository<T extends object> {
|
2
|
+
readonly entityMap: Map<string, T>;
|
3
|
+
constructor(entities?: Record<string, T>);
|
4
|
+
findById(id: string): T | undefined;
|
5
|
+
findAll(): T[];
|
6
|
+
upsertById(id: string, entity: T): Map<string, T>;
|
7
|
+
deleteById(id: string): boolean;
|
8
|
+
count(): number;
|
9
|
+
toJSON(): T[];
|
10
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ObjectRepository = void 0;
|
4
|
+
class ObjectRepository {
|
5
|
+
constructor(entities = {}) {
|
6
|
+
this.entityMap = new Map(Object.entries(entities));
|
7
|
+
}
|
8
|
+
findById(id) {
|
9
|
+
return this.entityMap.get(id);
|
10
|
+
}
|
11
|
+
findAll() {
|
12
|
+
return Array.from(this.entityMap.values());
|
13
|
+
}
|
14
|
+
upsertById(id, entity) {
|
15
|
+
return this.entityMap.set(id, { ...entity });
|
16
|
+
}
|
17
|
+
deleteById(id) {
|
18
|
+
return this.entityMap.delete(id);
|
19
|
+
}
|
20
|
+
count() {
|
21
|
+
return this.entityMap.size;
|
22
|
+
}
|
23
|
+
toJSON() {
|
24
|
+
return this.findAll();
|
25
|
+
}
|
26
|
+
}
|
27
|
+
exports.ObjectRepository = ObjectRepository;
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import type { proto } from '../../WAProto';
|
2
|
+
import { RegistrationOptions } from '../Socket/registration';
|
3
|
+
import type { Contact } from './Contact';
|
4
|
+
import type { MinimalMessage } from './Message';
|
5
|
+
export type KeyPair = {
|
6
|
+
public: Uint8Array;
|
7
|
+
private: Uint8Array;
|
8
|
+
};
|
9
|
+
export type SignedKeyPair = {
|
10
|
+
keyPair: KeyPair;
|
11
|
+
signature: Uint8Array;
|
12
|
+
keyId: number;
|
13
|
+
timestampS?: number;
|
14
|
+
};
|
15
|
+
export type ProtocolAddress = {
|
16
|
+
name: string;
|
17
|
+
deviceId: number;
|
18
|
+
};
|
19
|
+
export type SignalIdentity = {
|
20
|
+
identifier: ProtocolAddress;
|
21
|
+
identifierKey: Uint8Array;
|
22
|
+
};
|
23
|
+
export type LTHashState = {
|
24
|
+
version: number;
|
25
|
+
hash: Buffer;
|
26
|
+
indexValueMap: {
|
27
|
+
[indexMacBase64: string]: {
|
28
|
+
valueMac: Uint8Array | Buffer;
|
29
|
+
};
|
30
|
+
};
|
31
|
+
};
|
32
|
+
export type SignalCreds = {
|
33
|
+
readonly signedIdentityKey: KeyPair;
|
34
|
+
readonly signedPreKey: SignedKeyPair;
|
35
|
+
readonly registrationId: number;
|
36
|
+
};
|
37
|
+
export type AccountSettings = {
|
38
|
+
/** unarchive chats when a new message is received */
|
39
|
+
unarchiveChats: boolean;
|
40
|
+
/** the default mode to start new conversations with */
|
41
|
+
defaultDisappearingMode?: Pick<proto.IConversation, 'ephemeralExpiration' | 'ephemeralSettingTimestamp'>;
|
42
|
+
};
|
43
|
+
export type AuthenticationCreds = SignalCreds & {
|
44
|
+
readonly noiseKey: KeyPair;
|
45
|
+
readonly pairingEphemeralKeyPair: KeyPair;
|
46
|
+
advSecretKey: string;
|
47
|
+
me?: Contact;
|
48
|
+
account?: proto.IADVSignedDeviceIdentity;
|
49
|
+
signalIdentities?: SignalIdentity[];
|
50
|
+
myAppStateKeyId?: string;
|
51
|
+
firstUnuploadedPreKeyId: number;
|
52
|
+
nextPreKeyId: number;
|
53
|
+
lastAccountSyncTimestamp?: number;
|
54
|
+
platform?: string;
|
55
|
+
processedHistoryMessages: MinimalMessage[];
|
56
|
+
/** number of times history & app state has been synced */
|
57
|
+
accountSyncCounter: number;
|
58
|
+
accountSettings: AccountSettings;
|
59
|
+
deviceId: string;
|
60
|
+
phoneId: string;
|
61
|
+
identityId: Buffer;
|
62
|
+
registered: boolean;
|
63
|
+
backupToken: Buffer;
|
64
|
+
registration: RegistrationOptions;
|
65
|
+
pairingCode: string | undefined;
|
66
|
+
lastPropHash: string | undefined;
|
67
|
+
routingInfo: Buffer | undefined;
|
68
|
+
};
|
69
|
+
export type SignalDataTypeMap = {
|
70
|
+
'pre-key': KeyPair;
|
71
|
+
'session': Uint8Array;
|
72
|
+
'sender-key': Uint8Array;
|
73
|
+
'sender-key-memory': {
|
74
|
+
[jid: string]: boolean;
|
75
|
+
};
|
76
|
+
'app-state-sync-key': proto.Message.IAppStateSyncKeyData;
|
77
|
+
'app-state-sync-version': LTHashState;
|
78
|
+
};
|
79
|
+
export type SignalDataSet = {
|
80
|
+
[T in keyof SignalDataTypeMap]?: {
|
81
|
+
[id: string]: SignalDataTypeMap[T] | null;
|
82
|
+
};
|
83
|
+
};
|
84
|
+
type Awaitable<T> = T | Promise<T>;
|
85
|
+
export type SignalKeyStore = {
|
86
|
+
get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{
|
87
|
+
[id: string]: SignalDataTypeMap[T];
|
88
|
+
}>;
|
89
|
+
set(data: SignalDataSet): Awaitable<void>;
|
90
|
+
/** clear all the data in the store */
|
91
|
+
clear?(): Awaitable<void>;
|
92
|
+
};
|
93
|
+
export type SignalKeyStoreWithTransaction = SignalKeyStore & {
|
94
|
+
isInTransaction: () => boolean;
|
95
|
+
transaction<T>(exec: () => Promise<T>): Promise<T>;
|
96
|
+
};
|
97
|
+
export type TransactionCapabilityOptions = {
|
98
|
+
maxCommitRetries: number;
|
99
|
+
delayBetweenTriesMs: number;
|
100
|
+
};
|
101
|
+
export type SignalAuthState = {
|
102
|
+
creds: SignalCreds;
|
103
|
+
keys: SignalKeyStore | SignalKeyStoreWithTransaction;
|
104
|
+
};
|
105
|
+
export type AuthenticationState = {
|
106
|
+
creds: AuthenticationCreds;
|
107
|
+
keys: SignalKeyStore;
|
108
|
+
};
|
109
|
+
export {};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate';
|
2
|
+
export type WACallEvent = {
|
3
|
+
chatId: string;
|
4
|
+
from: string;
|
5
|
+
isGroup?: boolean;
|
6
|
+
groupJid?: string;
|
7
|
+
id: string;
|
8
|
+
date: Date;
|
9
|
+
isVideo?: boolean;
|
10
|
+
status: WACallUpdateType;
|
11
|
+
offline: boolean;
|
12
|
+
latencyMs?: number;
|
13
|
+
};
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import type { proto } from '../../WAProto';
|
2
|
+
import type { AccountSettings } from './Auth';
|
3
|
+
import type { BufferedEventData } from './Events';
|
4
|
+
import type { ChatLabelAssociationActionBody } from './LabelAssociation';
|
5
|
+
import type { MessageLabelAssociationActionBody } from './LabelAssociation';
|
6
|
+
import type { MinimalMessage, WAMessageKey } from './Message';
|
7
|
+
/** privacy settings in WhatsApp Web */
|
8
|
+
export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
|
9
|
+
export type WAPrivacyCallValue = 'all' | 'known';
|
10
|
+
export type WAPrivacyMessagesValue = 'all' | 'contacts';
|
11
|
+
export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
|
12
|
+
export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
|
13
|
+
export type WAReadReceiptsValue = 'all' | 'none';
|
14
|
+
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
15
|
+
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
|
16
|
+
export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
|
17
|
+
export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
|
18
|
+
export interface PresenceData {
|
19
|
+
lastKnownPresence: WAPresence;
|
20
|
+
lastSeen?: number;
|
21
|
+
}
|
22
|
+
export type BotListInfo = {
|
23
|
+
jid: string;
|
24
|
+
personaId: string;
|
25
|
+
};
|
26
|
+
export type ChatMutation = {
|
27
|
+
syncAction: proto.ISyncActionData;
|
28
|
+
index: string[];
|
29
|
+
};
|
30
|
+
export type WAPatchCreate = {
|
31
|
+
syncAction: proto.ISyncActionValue;
|
32
|
+
index: string[];
|
33
|
+
type: WAPatchName;
|
34
|
+
apiVersion: number;
|
35
|
+
operation: proto.SyncdMutation.SyncdOperation;
|
36
|
+
};
|
37
|
+
export type Chat = proto.IConversation & {
|
38
|
+
/** unix timestamp of when the last message was received in the chat */
|
39
|
+
lastMessageRecvTimestamp?: number;
|
40
|
+
};
|
41
|
+
export type ChatUpdate = Partial<Chat & {
|
42
|
+
/**
|
43
|
+
* if specified in the update,
|
44
|
+
* the EV buffer will check if the condition gets fulfilled before applying the update
|
45
|
+
* Right now, used to determine when to release an app state sync event
|
46
|
+
*
|
47
|
+
* @returns true, if the update should be applied;
|
48
|
+
* false if it can be discarded;
|
49
|
+
* undefined if the condition is not yet fulfilled
|
50
|
+
* */
|
51
|
+
conditional: (bufferedData: BufferedEventData) => boolean | undefined;
|
52
|
+
}>;
|
53
|
+
/**
|
54
|
+
* the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
|
55
|
+
* for MD modifications, the last message in the array (i.e. the earlist message) must be the last message recv in the chat
|
56
|
+
* */
|
57
|
+
export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange;
|
58
|
+
export type ChatModification = {
|
59
|
+
archive: boolean;
|
60
|
+
lastMessages: LastMessageList;
|
61
|
+
} | {
|
62
|
+
pushNameSetting: string;
|
63
|
+
} | {
|
64
|
+
pin: boolean;
|
65
|
+
} | {
|
66
|
+
/** mute for duration, or provide timestamp of mute to remove*/
|
67
|
+
mute: number | null;
|
68
|
+
} | {
|
69
|
+
clear: boolean;
|
70
|
+
} | {
|
71
|
+
deleteForMe: {
|
72
|
+
deleteMedia: boolean;
|
73
|
+
key: WAMessageKey;
|
74
|
+
timestamp: number;
|
75
|
+
};
|
76
|
+
} | {
|
77
|
+
star: {
|
78
|
+
messages: {
|
79
|
+
id: string;
|
80
|
+
fromMe?: boolean;
|
81
|
+
}[];
|
82
|
+
star: boolean;
|
83
|
+
};
|
84
|
+
} | {
|
85
|
+
markRead: boolean;
|
86
|
+
lastMessages: LastMessageList;
|
87
|
+
} | {
|
88
|
+
delete: true;
|
89
|
+
lastMessages: LastMessageList;
|
90
|
+
} | {
|
91
|
+
addChatLabel: ChatLabelAssociationActionBody;
|
92
|
+
} | {
|
93
|
+
removeChatLabel: ChatLabelAssociationActionBody;
|
94
|
+
} | {
|
95
|
+
addMessageLabel: MessageLabelAssociationActionBody;
|
96
|
+
} | {
|
97
|
+
removeMessageLabel: MessageLabelAssociationActionBody;
|
98
|
+
};
|
99
|
+
export type InitialReceivedChatsState = {
|
100
|
+
[jid: string]: {
|
101
|
+
/** the last message received from the other party */
|
102
|
+
lastMsgRecvTimestamp?: number;
|
103
|
+
/** the absolute last message in the chat */
|
104
|
+
lastMsgTimestamp: number;
|
105
|
+
};
|
106
|
+
};
|
107
|
+
export type InitialAppStateSyncOptions = {
|
108
|
+
accountSettings: AccountSettings;
|
109
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
export interface Contact {
|
2
|
+
/** ID either in lid or jid format **/
|
3
|
+
id: string;
|
4
|
+
/** ID in Lid (anonymous) format (@lid) **/
|
5
|
+
lid?: string;
|
6
|
+
/** ID in Phone Number format (@s.whatsapp.net) **/
|
7
|
+
jid?: string;
|
8
|
+
/** name of the contact, you have saved on your WA */
|
9
|
+
name?: string;
|
10
|
+
/** name of the contact, the contact has set on their own on WA */
|
11
|
+
notify?: string;
|
12
|
+
/** I have no idea */
|
13
|
+
verifiedName?: string;
|
14
|
+
/**
|
15
|
+
* Url of the profile picture of the contact
|
16
|
+
*
|
17
|
+
* 'changed' => if the profile picture has changed
|
18
|
+
* null => if the profile picture has not been set (default profile picture)
|
19
|
+
* any other string => url of the profile picture
|
20
|
+
*/
|
21
|
+
imgUrl?: string | null;
|
22
|
+
status?: string;
|
23
|
+
}
|
@@ -0,0 +1,199 @@
|
|
1
|
+
import type { Boom } from '@hapi/boom';
|
2
|
+
import { proto } from '../../WAProto';
|
3
|
+
import { AuthenticationCreds } from './Auth';
|
4
|
+
import { WACallEvent } from './Call';
|
5
|
+
import { Chat, ChatUpdate, PresenceData } from './Chat';
|
6
|
+
import { Contact } from './Contact';
|
7
|
+
import { GroupMetadata, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata';
|
8
|
+
import { Label } from './Label';
|
9
|
+
import { LabelAssociation } from './LabelAssociation';
|
10
|
+
import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
|
11
|
+
import { ConnectionState } from './State';
|
12
|
+
import { NewsletterSettingsUpdate, SubscriberAction, NewsletterViewRole } from './Newsletter';
|
13
|
+
export type BaileysEventMap = {
|
14
|
+
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
15
|
+
'connection.update': Partial<ConnectionState>;
|
16
|
+
/** credentials updated -- some metadata, keys or something */
|
17
|
+
'creds.update': Partial<AuthenticationCreds>;
|
18
|
+
/** set chats (history sync), everything is reverse chronologically sorted */
|
19
|
+
'messaging-history.set': {
|
20
|
+
chats: Chat[];
|
21
|
+
contacts: Contact[];
|
22
|
+
messages: WAMessage[];
|
23
|
+
isLatest?: boolean;
|
24
|
+
progress?: number | null;
|
25
|
+
syncType?: proto.HistorySync.HistorySyncType;
|
26
|
+
peerDataRequestSessionId?: string | null;
|
27
|
+
};
|
28
|
+
/** upsert chats */
|
29
|
+
'chats.upsert': Chat[];
|
30
|
+
/** update the given chats */
|
31
|
+
'chats.update': ChatUpdate[];
|
32
|
+
'chats.phoneNumberShare': {
|
33
|
+
lid: string;
|
34
|
+
jid: string;
|
35
|
+
};
|
36
|
+
/** delete chats with given ID */
|
37
|
+
'chats.delete': string[];
|
38
|
+
/** presence of contact in a chat updated */
|
39
|
+
'presence.update': {
|
40
|
+
id: string;
|
41
|
+
presences: {
|
42
|
+
[participant: string]: PresenceData;
|
43
|
+
};
|
44
|
+
};
|
45
|
+
'contacts.upsert': Contact[];
|
46
|
+
'contacts.update': Partial<Contact>[];
|
47
|
+
'messages.delete': {
|
48
|
+
keys: WAMessageKey[];
|
49
|
+
} | {
|
50
|
+
jid: string;
|
51
|
+
all: true;
|
52
|
+
};
|
53
|
+
'messages.update': WAMessageUpdate[];
|
54
|
+
'messages.media-update': {
|
55
|
+
key: WAMessageKey;
|
56
|
+
media?: {
|
57
|
+
ciphertext: Uint8Array;
|
58
|
+
iv: Uint8Array;
|
59
|
+
};
|
60
|
+
error?: Boom;
|
61
|
+
}[];
|
62
|
+
/**
|
63
|
+
* add/update the given messages. If they were received while the connection was online,
|
64
|
+
* the update will have type: "notify"
|
65
|
+
* if requestId is provided, then the messages was received from the phone due to it being unavailable
|
66
|
+
* */
|
67
|
+
'messages.upsert': {
|
68
|
+
messages: WAMessage[];
|
69
|
+
type: MessageUpsertType;
|
70
|
+
requestId?: string;
|
71
|
+
};
|
72
|
+
/** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
|
73
|
+
'messages.reaction': {
|
74
|
+
key: WAMessageKey;
|
75
|
+
reaction: proto.IReaction;
|
76
|
+
}[];
|
77
|
+
'message-receipt.update': MessageUserReceiptUpdate[];
|
78
|
+
'groups.upsert': GroupMetadata[];
|
79
|
+
'groups.update': Partial<GroupMetadata>[];
|
80
|
+
/** apply an action to participants in a group */
|
81
|
+
'group-participants.update': {
|
82
|
+
id: string;
|
83
|
+
author: string;
|
84
|
+
participants: string[];
|
85
|
+
action: ParticipantAction;
|
86
|
+
};
|
87
|
+
'group.join-request': {
|
88
|
+
id: string;
|
89
|
+
author: string;
|
90
|
+
participant: string;
|
91
|
+
action: RequestJoinAction;
|
92
|
+
method: RequestJoinMethod;
|
93
|
+
};
|
94
|
+
'newsletter.reaction': {
|
95
|
+
id: string;
|
96
|
+
server_id: string;
|
97
|
+
reaction: {
|
98
|
+
code?: string;
|
99
|
+
count?: number;
|
100
|
+
removed?: boolean;
|
101
|
+
};
|
102
|
+
};
|
103
|
+
'newsletter.view': {
|
104
|
+
id: string;
|
105
|
+
server_id: string;
|
106
|
+
count: number;
|
107
|
+
};
|
108
|
+
/**don't handles subscribe/unsubscribe actions */
|
109
|
+
'newsletter-participants.update': {
|
110
|
+
id: string;
|
111
|
+
author: string;
|
112
|
+
user: string;
|
113
|
+
new_role: NewsletterViewRole;
|
114
|
+
action: SubscriberAction;
|
115
|
+
};
|
116
|
+
'newsletter-settings.update': {
|
117
|
+
id: string;
|
118
|
+
update: NewsletterSettingsUpdate;
|
119
|
+
};
|
120
|
+
'blocklist.set': {
|
121
|
+
blocklist: string[];
|
122
|
+
};
|
123
|
+
'blocklist.update': {
|
124
|
+
blocklist: string[];
|
125
|
+
type: 'add' | 'remove';
|
126
|
+
};
|
127
|
+
/** Receive an update on a call, including when the call was received, rejected, accepted */
|
128
|
+
'call': WACallEvent[];
|
129
|
+
'labels.edit': Label;
|
130
|
+
'labels.association': {
|
131
|
+
association: LabelAssociation;
|
132
|
+
type: 'add' | 'remove';
|
133
|
+
};
|
134
|
+
};
|
135
|
+
export type BufferedEventData = {
|
136
|
+
historySets: {
|
137
|
+
chats: {
|
138
|
+
[jid: string]: Chat;
|
139
|
+
};
|
140
|
+
contacts: {
|
141
|
+
[jid: string]: Contact;
|
142
|
+
};
|
143
|
+
messages: {
|
144
|
+
[uqId: string]: WAMessage;
|
145
|
+
};
|
146
|
+
empty: boolean;
|
147
|
+
isLatest: boolean;
|
148
|
+
progress?: number | null;
|
149
|
+
syncType?: proto.HistorySync.HistorySyncType;
|
150
|
+
peerDataRequestSessionId?: string;
|
151
|
+
};
|
152
|
+
chatUpserts: {
|
153
|
+
[jid: string]: Chat;
|
154
|
+
};
|
155
|
+
chatUpdates: {
|
156
|
+
[jid: string]: ChatUpdate;
|
157
|
+
};
|
158
|
+
chatDeletes: Set<string>;
|
159
|
+
contactUpserts: {
|
160
|
+
[jid: string]: Contact;
|
161
|
+
};
|
162
|
+
contactUpdates: {
|
163
|
+
[jid: string]: Partial<Contact>;
|
164
|
+
};
|
165
|
+
messageUpserts: {
|
166
|
+
[key: string]: {
|
167
|
+
type: MessageUpsertType;
|
168
|
+
message: WAMessage;
|
169
|
+
};
|
170
|
+
};
|
171
|
+
messageUpdates: {
|
172
|
+
[key: string]: WAMessageUpdate;
|
173
|
+
};
|
174
|
+
messageDeletes: {
|
175
|
+
[key: string]: WAMessageKey;
|
176
|
+
};
|
177
|
+
messageReactions: {
|
178
|
+
[key: string]: {
|
179
|
+
key: WAMessageKey;
|
180
|
+
reactions: proto.IReaction[];
|
181
|
+
};
|
182
|
+
};
|
183
|
+
messageReceipts: {
|
184
|
+
[key: string]: {
|
185
|
+
key: WAMessageKey;
|
186
|
+
userReceipt: proto.IUserReceipt[];
|
187
|
+
};
|
188
|
+
};
|
189
|
+
groupUpdates: {
|
190
|
+
[jid: string]: Partial<GroupMetadata>;
|
191
|
+
};
|
192
|
+
};
|
193
|
+
export type BaileysEvent = keyof BaileysEventMap;
|
194
|
+
export interface BaileysEventEmitter {
|
195
|
+
on<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void;
|
196
|
+
off<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void;
|
197
|
+
removeAllListeners<T extends keyof BaileysEventMap>(event: T): void;
|
198
|
+
emit<T extends keyof BaileysEventMap>(event: T, arg: BaileysEventMap[T]): boolean;
|
199
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import { Contact } from './Contact';
|
2
|
+
export type GroupParticipant = (Contact & {
|
3
|
+
isAdmin?: boolean;
|
4
|
+
isSuperAdmin?: boolean;
|
5
|
+
admin?: 'admin' | 'superadmin' | null;
|
6
|
+
jid?: string;
|
7
|
+
lid?: string;
|
8
|
+
});
|
9
|
+
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
|
10
|
+
export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
|
11
|
+
export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
|
12
|
+
export interface GroupMetadata {
|
13
|
+
id: string;
|
14
|
+
/** group uses 'lid' or 'pn' to send messages */
|
15
|
+
addressingMode: 'pn' | 'lid';
|
16
|
+
owner: string | undefined;
|
17
|
+
ownerLid?: string | undefined;
|
18
|
+
subject: string;
|
19
|
+
/** group subject owner */
|
20
|
+
subjectOwner?: string;
|
21
|
+
subjectOwnerLid?: string;
|
22
|
+
/** group subject modification date */
|
23
|
+
subjectTime?: number;
|
24
|
+
creation?: number;
|
25
|
+
desc?: string;
|
26
|
+
descOwner?: string;
|
27
|
+
descOwnerLid?: string;
|
28
|
+
descId?: string;
|
29
|
+
descTime?: number;
|
30
|
+
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
31
|
+
linkedParent?: string;
|
32
|
+
/** is set when the group only allows admins to change group settings */
|
33
|
+
restrict?: boolean;
|
34
|
+
/** is set when the group only allows admins to write messages */
|
35
|
+
announce?: boolean;
|
36
|
+
/** is set when the group also allows members to add participants */
|
37
|
+
memberAddMode?: boolean;
|
38
|
+
/** Request approval to join the group */
|
39
|
+
joinApprovalMode?: boolean;
|
40
|
+
/** is this a community */
|
41
|
+
isCommunity?: boolean;
|
42
|
+
/** is this the announce of a community */
|
43
|
+
isCommunityAnnounce?: boolean;
|
44
|
+
/** number of group participants */
|
45
|
+
size?: number;
|
46
|
+
participants: GroupParticipant[];
|
47
|
+
ephemeralDuration?: number;
|
48
|
+
inviteCode?: string;
|
49
|
+
/** the person who added you to group or changed some setting in group */
|
50
|
+
author?: string;
|
51
|
+
}
|
52
|
+
export interface WAGroupCreateResponse {
|
53
|
+
status: number;
|
54
|
+
gid?: string;
|
55
|
+
participants?: [{
|
56
|
+
[key: string]: {};
|
57
|
+
}];
|
58
|
+
}
|
59
|
+
export interface GroupModificationResponse {
|
60
|
+
status: number;
|
61
|
+
participants?: {
|
62
|
+
[key: string]: {};
|
63
|
+
};
|
64
|
+
}
|