@denzy-official/baileys 1.1.3 → 1.1.4
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.js +77698 -117051
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +6 -5
- package/lib/Defaults/index.js +118 -79
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -1
- package/lib/Signal/Group/ciphertext-message.js +0 -1
- package/lib/Signal/Group/group-session-builder.d.ts +0 -1
- package/lib/Signal/Group/group-session-builder.js +0 -1
- package/lib/Signal/Group/group_cipher.d.ts +0 -1
- package/lib/Signal/Group/group_cipher.js +0 -1
- package/lib/Signal/Group/index.d.ts +0 -1
- package/lib/Signal/Group/index.js +0 -1
- package/lib/Signal/Group/keyhelper.d.ts +0 -1
- package/lib/Signal/Group/keyhelper.js +0 -1
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/queue-job.js +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -1
- package/lib/Signal/Group/sender-chain-key.js +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.js +0 -1
- package/lib/Signal/Group/sender-key-message.d.ts +0 -1
- package/lib/Signal/Group/sender-key-message.js +0 -1
- package/lib/Signal/Group/sender-key-name.d.ts +0 -1
- package/lib/Signal/Group/sender-key-name.js +0 -1
- package/lib/Signal/Group/sender-key-record.d.ts +0 -1
- package/lib/Signal/Group/sender-key-record.js +0 -1
- package/lib/Signal/Group/sender-key-state.d.ts +0 -1
- package/lib/Signal/Group/sender-key-state.js +0 -1
- package/lib/Signal/Group/sender-message-key.d.ts +0 -1
- package/lib/Signal/Group/sender-message-key.js +0 -1
- package/lib/Signal/libsignal.d.ts +0 -1
- package/lib/Signal/libsignal.js +0 -1
- package/lib/Store/index.d.ts +2 -2
- package/lib/Store/index.js +3 -2
- package/lib/Store/make-cache-manager-store.d.ts +13 -0
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/Store/make-in-memory-store.d.ts +24 -25
- package/lib/Store/make-in-memory-store.js +14 -27
- package/lib/Store/make-ordered-dictionary.d.ts +1 -2
- package/lib/Store/make-ordered-dictionary.js +2 -3
- package/lib/Store/object-repository.d.ts +0 -1
- package/lib/Store/object-repository.js +0 -1
- package/lib/Types/Auth.d.ts +7 -1
- package/lib/Types/Auth.js +0 -1
- package/lib/Types/Call.d.ts +1 -2
- package/lib/Types/Call.js +0 -1
- package/lib/Types/Chat.d.ts +7 -15
- package/lib/Types/Chat.js +0 -1
- package/lib/Types/Contact.d.ts +1 -6
- package/lib/Types/Contact.js +0 -1
- package/lib/Types/Events.d.ts +2 -45
- package/lib/Types/Events.js +0 -1
- package/lib/Types/GroupMetadata.d.ts +2 -12
- package/lib/Types/GroupMetadata.js +0 -1
- package/lib/Types/Label.d.ts +0 -1
- package/lib/Types/Label.js +1 -2
- package/lib/Types/LabelAssociation.d.ts +0 -1
- package/lib/Types/LabelAssociation.js +1 -2
- package/lib/Types/Message.d.ts +21 -149
- package/lib/Types/Message.js +2 -1
- package/lib/Types/Newsletter.d.ts +97 -74
- package/lib/Types/Newsletter.js +38 -19
- package/lib/Types/Socket.d.ts +9 -17
- package/lib/Types/index.d.ts +1 -9
- package/lib/Types/index.js +2 -3
- package/lib/WABinary/constants.d.ts +27 -25
- package/lib/WABinary/constants.js +13 -1277
- package/lib/WABinary/decode.d.ts +4 -4
- package/lib/WABinary/decode.js +13 -27
- package/lib/WABinary/encode.d.ts +2 -2
- package/lib/WABinary/encode.js +152 -138
- package/lib/WABinary/generic-utils.d.ts +4 -2
- package/lib/WABinary/generic-utils.js +125 -38
- package/lib/WABinary/index.d.ts +0 -1
- package/lib/WABinary/index.js +0 -1
- package/lib/WABinary/jid-utils.d.ts +5 -11
- package/lib/WABinary/jid-utils.js +5 -27
- package/lib/WABinary/types.d.ts +0 -1
- package/lib/WABinary/types.js +0 -1
- package/lib/WAM/BinaryInfo.d.ts +11 -3
- package/lib/WAM/BinaryInfo.js +0 -1
- package/lib/WAM/constants.d.ts +0 -1
- package/lib/WAM/constants.js +0 -1
- package/lib/WAM/encode.d.ts +2 -2
- package/lib/WAM/encode.js +0 -1
- package/lib/WAM/index.d.ts +0 -1
- package/lib/WAM/index.js +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/package.json +94 -97
- package/WAProto/GenerateStatics.sh +0 -5
- package/WAProto/WAProto.proto +0 -4775
- package/WAProto/bocah rename tolol, baileys by denzy +0 -0
- package/WAProto/index.d.ts +0 -55058
- package/WAProto/index.ts.ts +0 -53474
- package/WAProto/p.html +0 -1
package/lib/Store/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import makeCacheManagerAuthState from './make-cache-manager-store';
|
|
2
2
|
import makeInMemoryStore from './make-in-memory-store';
|
|
3
|
-
export { makeInMemoryStore };
|
|
3
|
+
export { makeInMemoryStore, makeCacheManagerAuthState };
|
package/lib/Store/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
"use strict";
|
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
4
|
};
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.makeInMemoryStore = void 0;
|
|
6
|
+
exports.makeCacheManagerAuthState = exports.makeInMemoryStore = void 0;
|
|
7
|
+
const make_cache_manager_store_1 = __importDefault(require("./make-cache-manager-store"));
|
|
8
|
+
exports.makeCacheManagerAuthState = make_cache_manager_store_1.default;
|
|
8
9
|
const make_in_memory_store_1 = __importDefault(require("./make-in-memory-store"));
|
|
9
10
|
exports.makeInMemoryStore = make_in_memory_store_1.default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuthenticationCreds } from '../Types';
|
|
2
|
+
declare const makeCacheManagerAuthState: (store: Storage, sessionKey: string) => Promise<{
|
|
3
|
+
clearState: () => Promise<void>;
|
|
4
|
+
saveCreds: () => Promise<void>;
|
|
5
|
+
state: {
|
|
6
|
+
creds: AuthenticationCreds;
|
|
7
|
+
keys: {
|
|
8
|
+
get: (type: string, ids: string[]) => Promise<{}>;
|
|
9
|
+
set: (data: any) => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export default makeCacheManagerAuthState;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const cache_manager_1 = require("cache-manager");
|
|
7
|
+
const WAProto_1 = require("../../WAProto");
|
|
8
|
+
const Utils_1 = require("../Utils");
|
|
9
|
+
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
10
|
+
const makeCacheManagerAuthState = async (store, sessionKey) => {
|
|
11
|
+
const defaultKey = (file) => `${sessionKey}:${file}`;
|
|
12
|
+
const databaseConn = await (0, cache_manager_1.caching)(store);
|
|
13
|
+
const writeData = async (file, data) => {
|
|
14
|
+
let ttl = undefined;
|
|
15
|
+
if (file === 'creds') {
|
|
16
|
+
ttl = 63115200; // 2 years
|
|
17
|
+
}
|
|
18
|
+
await databaseConn.set(defaultKey(file), JSON.stringify(data, Utils_1.BufferJSON.replacer), ttl);
|
|
19
|
+
};
|
|
20
|
+
const readData = async (file) => {
|
|
21
|
+
try {
|
|
22
|
+
const data = await databaseConn.get(defaultKey(file));
|
|
23
|
+
if (data) {
|
|
24
|
+
return JSON.parse(data, Utils_1.BufferJSON.reviver);
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
logger_1.default.error(error);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const removeData = async (file) => {
|
|
34
|
+
try {
|
|
35
|
+
return await databaseConn.del(defaultKey(file));
|
|
36
|
+
}
|
|
37
|
+
catch (_a) {
|
|
38
|
+
logger_1.default.error(`Error removing ${file} from session ${sessionKey}`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const clearState = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const result = await databaseConn.store.keys(`${sessionKey}*`);
|
|
44
|
+
await Promise.all(result.map(async (key) => await databaseConn.del(key)));
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const creds = (await readData('creds')) || (0, Utils_1.initAuthCreds)();
|
|
50
|
+
return {
|
|
51
|
+
clearState,
|
|
52
|
+
saveCreds: () => writeData('creds', creds),
|
|
53
|
+
state: {
|
|
54
|
+
creds,
|
|
55
|
+
keys: {
|
|
56
|
+
get: async (type, ids) => {
|
|
57
|
+
const data = {};
|
|
58
|
+
await Promise.all(ids.map(async (id) => {
|
|
59
|
+
let value = await readData(`${type}-${id}`);
|
|
60
|
+
if (type === 'app-state-sync-key' && value) {
|
|
61
|
+
value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
62
|
+
}
|
|
63
|
+
data[id] = value;
|
|
64
|
+
}));
|
|
65
|
+
return data;
|
|
66
|
+
},
|
|
67
|
+
set: async (data) => {
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
+
const tasks = [];
|
|
70
|
+
for (const category in data) {
|
|
71
|
+
for (const id in data[category]) {
|
|
72
|
+
const value = data[category][id];
|
|
73
|
+
const key = `${category}-${id}`;
|
|
74
|
+
tasks.push(value ? writeData(key, value) : removeData(key));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
await Promise.all(tasks);
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
exports.default = makeCacheManagerAuthState;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
import type KeyedDB from '@adiwajshing/keyed-db';
|
|
3
2
|
import type { Comparable } from '@adiwajshing/keyed-db/lib/Types';
|
|
3
|
+
import type { Logger } from 'pino';
|
|
4
4
|
import { proto } from '../../WAProto';
|
|
5
5
|
import type makeMDSocket from '../Socket';
|
|
6
6
|
import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
|
|
7
7
|
import { Label } from '../Types/Label';
|
|
8
8
|
import { LabelAssociation } from '../Types/LabelAssociation';
|
|
9
|
-
import { ILogger } from '../Utils/logger';
|
|
10
9
|
import { ObjectRepository } from './object-repository';
|
|
11
10
|
type WASocket = ReturnType<typeof makeMDSocket>;
|
|
12
11
|
export declare const waChatKey: (pin: boolean) => {
|
|
@@ -18,7 +17,7 @@ export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>
|
|
|
18
17
|
export type BaileysInMemoryStoreConfig = {
|
|
19
18
|
chatKey?: Comparable<Chat, string>;
|
|
20
19
|
labelAssociationKey?: Comparable<LabelAssociation, string>;
|
|
21
|
-
logger?:
|
|
20
|
+
logger?: Logger;
|
|
22
21
|
socket?: WASocket;
|
|
23
22
|
};
|
|
24
23
|
declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
@@ -28,16 +27,16 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
28
27
|
};
|
|
29
28
|
messages: {
|
|
30
29
|
[_: string]: {
|
|
31
|
-
array:
|
|
32
|
-
get: (id: string) =>
|
|
33
|
-
upsert: (item:
|
|
34
|
-
update: (item:
|
|
35
|
-
remove: (item:
|
|
36
|
-
updateAssign: (id: string, update: Partial<
|
|
30
|
+
array: proto.IWebMessageInfo[];
|
|
31
|
+
get: (id: string) => proto.IWebMessageInfo | undefined;
|
|
32
|
+
upsert: (item: proto.IWebMessageInfo, mode: "append" | "prepend") => void;
|
|
33
|
+
update: (item: proto.IWebMessageInfo) => boolean;
|
|
34
|
+
remove: (item: proto.IWebMessageInfo) => boolean;
|
|
35
|
+
updateAssign: (id: string, update: Partial<proto.IWebMessageInfo>) => boolean;
|
|
37
36
|
clear: () => void;
|
|
38
|
-
filter: (contain: (item:
|
|
39
|
-
toJSON: () =>
|
|
40
|
-
fromJSON: (newItems:
|
|
37
|
+
filter: (contain: (item: proto.IWebMessageInfo) => boolean) => void;
|
|
38
|
+
toJSON: () => proto.IWebMessageInfo[];
|
|
39
|
+
fromJSON: (newItems: proto.IWebMessageInfo[]) => void;
|
|
41
40
|
};
|
|
42
41
|
};
|
|
43
42
|
groupMetadata: {
|
|
@@ -53,7 +52,7 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
53
52
|
labelAssociations: KeyedDB<LabelAssociation, string>;
|
|
54
53
|
bind: (ev: BaileysEventEmitter) => void;
|
|
55
54
|
/** loads messages from the store, if not found -- uses the legacy connection */
|
|
56
|
-
loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<
|
|
55
|
+
loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<proto.IWebMessageInfo[]>;
|
|
57
56
|
/**
|
|
58
57
|
* Get all available labels for profile
|
|
59
58
|
*
|
|
@@ -73,8 +72,8 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
73
72
|
* @returns Label IDs
|
|
74
73
|
**/
|
|
75
74
|
getMessageLabels: (messageId: string) => string[];
|
|
76
|
-
loadMessage: (jid: string, id: string) => Promise<
|
|
77
|
-
mostRecentMessage: (jid: string) => Promise<
|
|
75
|
+
loadMessage: (jid: string, id: string) => Promise<proto.IWebMessageInfo | undefined>;
|
|
76
|
+
mostRecentMessage: (jid: string) => Promise<proto.IWebMessageInfo>;
|
|
78
77
|
fetchImageUrl: (jid: string, sock: WASocket | undefined) => Promise<string | null | undefined>;
|
|
79
78
|
fetchGroupMetadata: (jid: string, sock: WASocket | undefined) => Promise<GroupMetadata>;
|
|
80
79
|
fetchMessageReceipts: ({ remoteJid, id }: WAMessageKey) => Promise<proto.IUserReceipt[] | null | undefined>;
|
|
@@ -85,16 +84,16 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
85
84
|
};
|
|
86
85
|
messages: {
|
|
87
86
|
[_: string]: {
|
|
88
|
-
array:
|
|
89
|
-
get: (id: string) =>
|
|
90
|
-
upsert: (item:
|
|
91
|
-
update: (item:
|
|
92
|
-
remove: (item:
|
|
93
|
-
updateAssign: (id: string, update: Partial<
|
|
87
|
+
array: proto.IWebMessageInfo[];
|
|
88
|
+
get: (id: string) => proto.IWebMessageInfo | undefined;
|
|
89
|
+
upsert: (item: proto.IWebMessageInfo, mode: "append" | "prepend") => void;
|
|
90
|
+
update: (item: proto.IWebMessageInfo) => boolean;
|
|
91
|
+
remove: (item: proto.IWebMessageInfo) => boolean;
|
|
92
|
+
updateAssign: (id: string, update: Partial<proto.IWebMessageInfo>) => boolean;
|
|
94
93
|
clear: () => void;
|
|
95
|
-
filter: (contain: (item:
|
|
96
|
-
toJSON: () =>
|
|
97
|
-
fromJSON: (newItems:
|
|
94
|
+
filter: (contain: (item: proto.IWebMessageInfo) => boolean) => void;
|
|
95
|
+
toJSON: () => proto.IWebMessageInfo[];
|
|
96
|
+
fromJSON: (newItems: proto.IWebMessageInfo[]) => void;
|
|
98
97
|
};
|
|
99
98
|
};
|
|
100
99
|
labels: ObjectRepository<Label>;
|
|
@@ -106,7 +105,7 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
106
105
|
[id: string]: Contact;
|
|
107
106
|
};
|
|
108
107
|
messages: {
|
|
109
|
-
[id: string]:
|
|
108
|
+
[id: string]: proto.IWebMessageInfo[];
|
|
110
109
|
};
|
|
111
110
|
labels: {
|
|
112
111
|
[labelId: string]: Label;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
"use strict";
|
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -75,11 +74,7 @@ exports.default = (config) => {
|
|
|
75
74
|
ev.on('connection.update', update => {
|
|
76
75
|
Object.assign(state, update);
|
|
77
76
|
});
|
|
78
|
-
ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest
|
|
79
|
-
if (syncType === WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND) {
|
|
80
|
-
return; // FOR NOW,
|
|
81
|
-
//TODO: HANDLE
|
|
82
|
-
}
|
|
77
|
+
ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest }) => {
|
|
83
78
|
if (isLatest) {
|
|
84
79
|
chats.clear();
|
|
85
80
|
for (const id in messages) {
|
|
@@ -192,14 +187,16 @@ exports.default = (config) => {
|
|
|
192
187
|
const jid = (0, WABinary_1.jidNormalizedUser)(msg.key.remoteJid);
|
|
193
188
|
const list = assertMessageList(jid);
|
|
194
189
|
list.upsert(msg, 'append');
|
|
195
|
-
if (type === 'notify'
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
190
|
+
if (type === 'notify') {
|
|
191
|
+
if (!chats.get(jid)) {
|
|
192
|
+
ev.emit('chats.upsert', [
|
|
193
|
+
{
|
|
194
|
+
id: jid,
|
|
195
|
+
conversationTimestamp: (0, Utils_1.toNumber)(msg.messageTimestamp),
|
|
196
|
+
unreadCount: 1
|
|
197
|
+
}
|
|
198
|
+
]);
|
|
199
|
+
}
|
|
203
200
|
}
|
|
204
201
|
}
|
|
205
202
|
break;
|
|
@@ -421,19 +418,9 @@ exports.default = (config) => {
|
|
|
421
418
|
const { readFileSync, existsSync } = require('fs');
|
|
422
419
|
if (existsSync(path)) {
|
|
423
420
|
logger.debug({ path }, 'reading from file');
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
const json = JSON.parse(jsonStr);
|
|
428
|
-
fromJSON(json);
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
431
|
-
logger.warn({ path }, 'skipping empty json file');
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
catch (err) {
|
|
435
|
-
logger.warn({ path, err }, 'failed to parse json from file');
|
|
436
|
-
}
|
|
421
|
+
const jsonStr = readFileSync(path, { encoding: 'utf-8' });
|
|
422
|
+
const json = JSON.parse(jsonStr);
|
|
423
|
+
fromJSON(json);
|
|
437
424
|
}
|
|
438
425
|
}
|
|
439
426
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
declare function makeOrderedDictionary<T>(idGetter: (item: T) => string): {
|
|
3
2
|
array: T[];
|
|
4
3
|
get: (id: string) => T | undefined;
|
|
5
|
-
upsert: (item: T, mode:
|
|
4
|
+
upsert: (item: T, mode: 'append' | 'prepend') => void;
|
|
6
5
|
update: (item: T) => boolean;
|
|
7
6
|
remove: (item: T) => boolean;
|
|
8
7
|
updateAssign: (id: string, update: Partial<T>) => boolean;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
function makeOrderedDictionary(idGetter) {
|
|
@@ -57,9 +56,9 @@ function makeOrderedDictionary(idGetter) {
|
|
|
57
56
|
},
|
|
58
57
|
clear: () => {
|
|
59
58
|
array.splice(0, array.length);
|
|
60
|
-
|
|
59
|
+
Object.keys(dict).forEach(key => {
|
|
61
60
|
delete dict[key];
|
|
62
|
-
}
|
|
61
|
+
});
|
|
63
62
|
},
|
|
64
63
|
filter: (contain) => {
|
|
65
64
|
let i = 0;
|
package/lib/Types/Auth.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
2
|
import type { proto } from '../../WAProto';
|
|
3
|
+
import { RegistrationOptions } from '../Socket/registration';
|
|
3
4
|
import type { Contact } from './Contact';
|
|
4
5
|
import type { MinimalMessage } from './Message';
|
|
5
6
|
export type KeyPair = {
|
|
@@ -56,7 +57,12 @@ export type AuthenticationCreds = SignalCreds & {
|
|
|
56
57
|
/** number of times history & app state has been synced */
|
|
57
58
|
accountSyncCounter: number;
|
|
58
59
|
accountSettings: AccountSettings;
|
|
60
|
+
deviceId: string;
|
|
61
|
+
phoneId: string;
|
|
62
|
+
identityId: Buffer;
|
|
59
63
|
registered: boolean;
|
|
64
|
+
backupToken: Buffer;
|
|
65
|
+
registration: RegistrationOptions;
|
|
60
66
|
pairingCode: string | undefined;
|
|
61
67
|
lastPropHash: string | undefined;
|
|
62
68
|
routingInfo: Buffer | undefined;
|
package/lib/Types/Auth.js
CHANGED
package/lib/Types/Call.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate';
|
|
1
|
+
export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
|
|
3
2
|
export type WACallEvent = {
|
|
4
3
|
chatId: string;
|
|
5
4
|
from: string;
|
package/lib/Types/Call.js
CHANGED
package/lib/Types/Chat.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
import type { proto } from '../../WAProto';
|
|
3
2
|
import type { AccountSettings } from './Auth';
|
|
4
3
|
import type { BufferedEventData } from './Events';
|
|
5
4
|
import type { ChatLabelAssociationActionBody } from './LabelAssociation';
|
|
6
5
|
import type { MessageLabelAssociationActionBody } from './LabelAssociation';
|
|
7
|
-
import type { MinimalMessage
|
|
6
|
+
import type { MinimalMessage } from './Message';
|
|
8
7
|
/** privacy settings in WhatsApp Web */
|
|
9
8
|
export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
|
|
10
|
-
export type WAPrivacyCallValue = 'all' | 'known';
|
|
11
|
-
export type WAPrivacyMessagesValue = 'all' | 'contacts';
|
|
12
9
|
export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
|
|
13
|
-
export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
|
|
14
10
|
export type WAReadReceiptsValue = 'all' | 'none';
|
|
15
11
|
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
|
16
12
|
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
|
|
@@ -20,10 +16,6 @@ export interface PresenceData {
|
|
|
20
16
|
lastKnownPresence: WAPresence;
|
|
21
17
|
lastSeen?: number;
|
|
22
18
|
}
|
|
23
|
-
export type BotListInfo = {
|
|
24
|
-
jid: string;
|
|
25
|
-
personaId: string;
|
|
26
|
-
};
|
|
27
19
|
export type ChatMutation = {
|
|
28
20
|
syncAction: proto.ISyncActionData;
|
|
29
21
|
index: string[];
|
|
@@ -67,12 +59,12 @@ export type ChatModification = {
|
|
|
67
59
|
/** mute for duration, or provide timestamp of mute to remove*/
|
|
68
60
|
mute: number | null;
|
|
69
61
|
} | {
|
|
70
|
-
clear:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
clear: 'all' | {
|
|
63
|
+
messages: {
|
|
64
|
+
id: string;
|
|
65
|
+
fromMe?: boolean;
|
|
66
|
+
timestamp: number;
|
|
67
|
+
}[];
|
|
76
68
|
};
|
|
77
69
|
} | {
|
|
78
70
|
star: {
|
package/lib/Types/Chat.js
CHANGED
package/lib/Types/Contact.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
export interface Contact {
|
|
3
|
-
/** ID either in lid or jid format **/
|
|
4
2
|
id: string;
|
|
5
|
-
/** ID in Lid (anonymous) format (@lid) **/
|
|
6
3
|
lid?: string;
|
|
7
|
-
/** ID in Phone Number format (@s.whatsapp.net) **/
|
|
8
|
-
jid?: string;
|
|
9
4
|
/** name of the contact, you have saved on your WA */
|
|
10
5
|
name?: string;
|
|
11
6
|
/** name of the contact, the contact has set on their own on WA */
|
|
@@ -19,6 +14,6 @@ export interface Contact {
|
|
|
19
14
|
* null => if the profile picture has not been set (default profile picture)
|
|
20
15
|
* any other string => url of the profile picture
|
|
21
16
|
*/
|
|
22
|
-
imgUrl?: string | null;
|
|
17
|
+
imgUrl?: string | null | 'changed';
|
|
23
18
|
status?: string;
|
|
24
19
|
}
|
package/lib/Types/Contact.js
CHANGED
package/lib/Types/Events.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
import type { Boom } from '@hapi/boom';
|
|
3
2
|
import { proto } from '../../WAProto';
|
|
4
3
|
import { AuthenticationCreds } from './Auth';
|
|
5
4
|
import { WACallEvent } from './Call';
|
|
6
5
|
import { Chat, ChatUpdate, PresenceData } from './Chat';
|
|
7
6
|
import { Contact } from './Contact';
|
|
8
|
-
import { GroupMetadata, ParticipantAction
|
|
7
|
+
import { GroupMetadata, ParticipantAction } from './GroupMetadata';
|
|
9
8
|
import { Label } from './Label';
|
|
10
9
|
import { LabelAssociation } from './LabelAssociation';
|
|
11
10
|
import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
|
|
12
11
|
import { ConnectionState } from './State';
|
|
13
|
-
import { NewsletterSettingsUpdate, SubscriberAction, NewsletterViewRole } from './Newsletter';
|
|
14
12
|
export type BaileysEventMap = {
|
|
15
13
|
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
|
16
14
|
'connection.update': Partial<ConnectionState>;
|
|
@@ -21,10 +19,7 @@ export type BaileysEventMap = {
|
|
|
21
19
|
chats: Chat[];
|
|
22
20
|
contacts: Contact[];
|
|
23
21
|
messages: WAMessage[];
|
|
24
|
-
isLatest
|
|
25
|
-
progress?: number | null;
|
|
26
|
-
syncType?: proto.HistorySync.HistorySyncType;
|
|
27
|
-
peerDataRequestSessionId?: string | null;
|
|
22
|
+
isLatest: boolean;
|
|
28
23
|
};
|
|
29
24
|
/** upsert chats */
|
|
30
25
|
'chats.upsert': Chat[];
|
|
@@ -63,12 +58,10 @@ export type BaileysEventMap = {
|
|
|
63
58
|
/**
|
|
64
59
|
* add/update the given messages. If they were received while the connection was online,
|
|
65
60
|
* the update will have type: "notify"
|
|
66
|
-
* if requestId is provided, then the messages was received from the phone due to it being unavailable
|
|
67
61
|
* */
|
|
68
62
|
'messages.upsert': {
|
|
69
63
|
messages: WAMessage[];
|
|
70
64
|
type: MessageUpsertType;
|
|
71
|
-
requestId?: string;
|
|
72
65
|
};
|
|
73
66
|
/** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
|
|
74
67
|
'messages.reaction': {
|
|
@@ -85,39 +78,6 @@ export type BaileysEventMap = {
|
|
|
85
78
|
participants: string[];
|
|
86
79
|
action: ParticipantAction;
|
|
87
80
|
};
|
|
88
|
-
'group.join-request': {
|
|
89
|
-
id: string;
|
|
90
|
-
author: string;
|
|
91
|
-
participant: string;
|
|
92
|
-
action: RequestJoinAction;
|
|
93
|
-
method: RequestJoinMethod;
|
|
94
|
-
};
|
|
95
|
-
'newsletter.reaction': {
|
|
96
|
-
id: string;
|
|
97
|
-
server_id: string;
|
|
98
|
-
reaction: {
|
|
99
|
-
code?: string;
|
|
100
|
-
count?: number;
|
|
101
|
-
removed?: boolean;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
'newsletter.view': {
|
|
105
|
-
id: string;
|
|
106
|
-
server_id: string;
|
|
107
|
-
count: number;
|
|
108
|
-
};
|
|
109
|
-
/**don't handles subscribe/unsubscribe actions */
|
|
110
|
-
'newsletter-participants.update': {
|
|
111
|
-
id: string;
|
|
112
|
-
author: string;
|
|
113
|
-
user: string;
|
|
114
|
-
new_role: NewsletterViewRole;
|
|
115
|
-
action: SubscriberAction;
|
|
116
|
-
};
|
|
117
|
-
'newsletter-settings.update': {
|
|
118
|
-
id: string;
|
|
119
|
-
update: NewsletterSettingsUpdate;
|
|
120
|
-
};
|
|
121
81
|
'blocklist.set': {
|
|
122
82
|
blocklist: string[];
|
|
123
83
|
};
|
|
@@ -146,9 +106,6 @@ export type BufferedEventData = {
|
|
|
146
106
|
};
|
|
147
107
|
empty: boolean;
|
|
148
108
|
isLatest: boolean;
|
|
149
|
-
progress?: number | null;
|
|
150
|
-
syncType?: proto.HistorySync.HistorySyncType;
|
|
151
|
-
peerDataRequestSessionId?: string;
|
|
152
109
|
};
|
|
153
110
|
chatUpserts: {
|
|
154
111
|
[jid: string]: Chat;
|
package/lib/Types/Events.js
CHANGED
|
@@ -1,33 +1,23 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
import { Contact } from './Contact';
|
|
3
2
|
export type GroupParticipant = (Contact & {
|
|
4
3
|
isAdmin?: boolean;
|
|
5
4
|
isSuperAdmin?: boolean;
|
|
6
5
|
admin?: 'admin' | 'superadmin' | null;
|
|
7
|
-
jid?: string;
|
|
8
|
-
lid?: string;
|
|
9
6
|
});
|
|
10
|
-
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote'
|
|
11
|
-
export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
|
|
12
|
-
export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
|
|
7
|
+
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
|
|
13
8
|
export interface GroupMetadata {
|
|
14
9
|
id: string;
|
|
15
|
-
/** group uses 'lid' or 'pn' to send messages */
|
|
16
|
-
addressingMode: 'pn' | 'lid';
|
|
17
10
|
owner: string | undefined;
|
|
18
|
-
ownerLid?: string | undefined;
|
|
19
11
|
subject: string;
|
|
12
|
+
addressingMode: "pn" | "lid";
|
|
20
13
|
/** group subject owner */
|
|
21
14
|
subjectOwner?: string;
|
|
22
|
-
subjectOwnerLid?: string;
|
|
23
15
|
/** group subject modification date */
|
|
24
16
|
subjectTime?: number;
|
|
25
17
|
creation?: number;
|
|
26
18
|
desc?: string;
|
|
27
19
|
descOwner?: string;
|
|
28
|
-
descOwnerLid?: string;
|
|
29
20
|
descId?: string;
|
|
30
|
-
descTime?: number;
|
|
31
21
|
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
|
32
22
|
linkedParent?: string;
|
|
33
23
|
/** is set when the group only allows admins to change group settings */
|
package/lib/Types/Label.d.ts
CHANGED
package/lib/Types/Label.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.LabelColor = void 0;
|
|
@@ -25,4 +24,4 @@ var LabelColor;
|
|
|
25
24
|
LabelColor[LabelColor["Color18"] = 17] = "Color18";
|
|
26
25
|
LabelColor[LabelColor["Color19"] = 18] = "Color19";
|
|
27
26
|
LabelColor[LabelColor["Color20"] = 19] = "Color20";
|
|
28
|
-
})(LabelColor
|
|
27
|
+
})(LabelColor = exports.LabelColor || (exports.LabelColor = {}));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// baileys by denzy
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.LabelAssociationType = void 0;
|
|
@@ -7,4 +6,4 @@ var LabelAssociationType;
|
|
|
7
6
|
(function (LabelAssociationType) {
|
|
8
7
|
LabelAssociationType["Chat"] = "label_jid";
|
|
9
8
|
LabelAssociationType["Message"] = "label_message";
|
|
10
|
-
})(LabelAssociationType
|
|
9
|
+
})(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));
|