@ruthless-imperium/baileys 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Socket/communities.js +437 -0
- package/lib/Socket/graphql.js +724 -0
- package/lib/Socket/index.js +25 -5
- package/lib/Socket/interop.js +468 -0
- package/lib/Socket/luxu.js +392 -0
- package/lib/Socket/message-builder-core.js +3737 -0
- package/lib/Socket/message-builder.js +561 -0
- package/lib/Socket/messages-send.js +2 -1
- package/lib/Socket/mex.js +59 -0
- package/lib/Socket/newsletter.js +650 -255
- package/lib/Socket/privacy.js +323 -0
- package/lib/Socket/username.js +241 -0
- package/lib/Store/index.js +3 -0
- package/lib/Store/keyed-db.js +113 -0
- package/lib/Store/make-cache-manager-store.js +89 -0
- package/lib/Types/Mex.js +117 -0
- package/lib/Types/index.js +1 -0
- package/lib/Utils/index.js +4 -1
- package/lib/Utils/message-composer.js +290 -0
- package/lib/Utils/sticker.js +143 -0
- package/lib/Utils/use-sqlite-auth-state.js +168 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +49 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +65 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +34 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +44 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +33 -0
- package/lib/WAUSync/Protocols/index.js +6 -0
- package/package.json +11 -48
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __def = (m) => (m && m.__esModule) ? m.default : m;
|
|
4
|
+
const __exportStar = (m, e) => { for (const k in m) if (k !== "default" && !Object.prototype.hasOwnProperty.call(e, k)) e[k] = m[k]; };
|
|
5
|
+
const { mkdir, readdir, readFile } = require("fs/promises");
|
|
6
|
+
const { dirname, join } = require("path");
|
|
7
|
+
const { proto } = require("../../WAProto/index.js");
|
|
8
|
+
const { initAuthCreds } = require("./auth-utils.js");
|
|
9
|
+
const useSqliteAuthState = async (pathOrFolder, options = {}) => {
|
|
10
|
+
const {
|
|
11
|
+
fileName = 'auth.db',
|
|
12
|
+
migrateFromFolder,
|
|
13
|
+
logger
|
|
14
|
+
} = options;
|
|
15
|
+
const dbPath = /\.(db|sqlite|sqlite3)$/i.test(pathOrFolder) ? pathOrFolder : join(pathOrFolder, fileName);
|
|
16
|
+
const bufReplacer = (_, value) => {
|
|
17
|
+
if (Buffer.isBuffer(value) || value instanceof Uint8Array || value?.type === 'Buffer') {
|
|
18
|
+
return {
|
|
19
|
+
type: 'Buffer',
|
|
20
|
+
data: Buffer.from(value?.data || value).toString('base64')
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
const bufReviver = (_, value) => {
|
|
26
|
+
if (value && typeof value === 'object' && value.type === 'Buffer' && typeof value.data === 'string') {
|
|
27
|
+
return Buffer.from(value.data, 'base64');
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
const encode = value => {
|
|
32
|
+
if (Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
33
|
+
return Buffer.concat([Buffer.from([1]), Buffer.from(value)]);
|
|
34
|
+
}
|
|
35
|
+
return Buffer.concat([Buffer.from([0]), Buffer.from(JSON.stringify(value, bufReplacer), 'utf8')]);
|
|
36
|
+
};
|
|
37
|
+
const decode = blob => {
|
|
38
|
+
if (!blob || blob.length === 0) return null;
|
|
39
|
+
if (blob[0] === 1) return Buffer.from(blob.subarray(1));
|
|
40
|
+
return JSON.parse(Buffer.from(blob.subarray(1)).toString('utf8'), bufReviver);
|
|
41
|
+
};
|
|
42
|
+
const fixName = s => s?.replace(/\//g, '__')?.replace(/:/g, '-');
|
|
43
|
+
const keyOf = (category, id) => fixName(`${category}-${id}`);
|
|
44
|
+
let DatabaseSync;
|
|
45
|
+
try {
|
|
46
|
+
({
|
|
47
|
+
DatabaseSync
|
|
48
|
+
} = await import('node:sqlite'));
|
|
49
|
+
} catch (err) {
|
|
50
|
+
throw new Error("useSqliteAuthState needs the built-in 'node:sqlite' module (Node 22.5+). Upgrade Node, or use useMultiFileAuthState instead.");
|
|
51
|
+
}
|
|
52
|
+
await mkdir(dirname(dbPath), {
|
|
53
|
+
recursive: true
|
|
54
|
+
}).catch(() => {});
|
|
55
|
+
const db = new DatabaseSync(dbPath);
|
|
56
|
+
db.exec('PRAGMA journal_mode = TRUNCATE');
|
|
57
|
+
db.exec('PRAGMA synchronous = NORMAL');
|
|
58
|
+
db.exec('PRAGMA busy_timeout = 5000');
|
|
59
|
+
db.exec('CREATE TABLE IF NOT EXISTS auth_state (k TEXT PRIMARY KEY, v BLOB NOT NULL) WITHOUT ROWID');
|
|
60
|
+
const qGet = db.prepare('SELECT v FROM auth_state WHERE k = ?');
|
|
61
|
+
const qUpsert = db.prepare('INSERT INTO auth_state(k,v) VALUES(?,?) ON CONFLICT(k) DO UPDATE SET v=excluded.v');
|
|
62
|
+
const qDelete = db.prepare('DELETE FROM auth_state WHERE k = ?');
|
|
63
|
+
const runTx = fn => {
|
|
64
|
+
db.exec('BEGIN');
|
|
65
|
+
try {
|
|
66
|
+
const r = fn();
|
|
67
|
+
db.exec('COMMIT');
|
|
68
|
+
return r;
|
|
69
|
+
} catch (err) {
|
|
70
|
+
db.exec('ROLLBACK');
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const readRaw = k => {
|
|
75
|
+
const row = qGet.get(k);
|
|
76
|
+
if (!row) return null;
|
|
77
|
+
try {
|
|
78
|
+
return decode(row.v);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
logger?.warn?.({
|
|
81
|
+
k,
|
|
82
|
+
err: err?.message
|
|
83
|
+
}, 'sqlite-auth: failed to decode row, treating as missing');
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const runMigration = async folder => {
|
|
88
|
+
let files;
|
|
89
|
+
try {
|
|
90
|
+
files = await readdir(folder);
|
|
91
|
+
} catch {
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
const rows = [];
|
|
95
|
+
for (const file of files) {
|
|
96
|
+
if (!file.endsWith('.json')) continue;
|
|
97
|
+
let value;
|
|
98
|
+
try {
|
|
99
|
+
value = JSON.parse(await readFile(join(folder, file), 'utf8'), bufReviver);
|
|
100
|
+
} catch {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (value === null || value === undefined) continue;
|
|
104
|
+
rows.push([file.slice(0, -'.json'.length), encode(value)]);
|
|
105
|
+
}
|
|
106
|
+
runTx(() => {
|
|
107
|
+
for (const [k, v] of rows) qUpsert.run(k, v);
|
|
108
|
+
});
|
|
109
|
+
return rows.length;
|
|
110
|
+
};
|
|
111
|
+
const hasCreds = () => !!qGet.get('creds');
|
|
112
|
+
if (migrateFromFolder && !hasCreds()) {
|
|
113
|
+
const n = await runMigration(migrateFromFolder);
|
|
114
|
+
if (n > 0) logger?.info?.({
|
|
115
|
+
count: n,
|
|
116
|
+
from: migrateFromFolder
|
|
117
|
+
}, 'sqlite-auth: migrated legacy auth state');
|
|
118
|
+
}
|
|
119
|
+
let creds = readRaw('creds');
|
|
120
|
+
if (!creds) {
|
|
121
|
+
creds = initAuthCreds();
|
|
122
|
+
qUpsert.run('creds', encode(creds));
|
|
123
|
+
}
|
|
124
|
+
const keys = {
|
|
125
|
+
get: async (type, ids) => {
|
|
126
|
+
const data = {};
|
|
127
|
+
for (const id of ids) {
|
|
128
|
+
let value = readRaw(keyOf(type, id));
|
|
129
|
+
if (type === 'app-state-sync-key' && value) {
|
|
130
|
+
value = proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
131
|
+
}
|
|
132
|
+
if (value !== null && value !== undefined) {
|
|
133
|
+
data[id] = value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return data;
|
|
137
|
+
},
|
|
138
|
+
set: async data => {
|
|
139
|
+
const ops = [];
|
|
140
|
+
for (const category in data) {
|
|
141
|
+
for (const id in data[category]) {
|
|
142
|
+
ops.push([keyOf(category, id), data[category][id]]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
runTx(() => {
|
|
146
|
+
for (const [k, value] of ops) {
|
|
147
|
+
if (value === null || value === undefined) qDelete.run(k);else qUpsert.run(k, encode(value));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
clear: async () => {
|
|
152
|
+
db.prepare("DELETE FROM auth_state WHERE k <> 'creds'").run();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
state: {
|
|
157
|
+
creds,
|
|
158
|
+
keys
|
|
159
|
+
},
|
|
160
|
+
saveCreds: async () => {
|
|
161
|
+
qUpsert.run('creds', encode(creds));
|
|
162
|
+
},
|
|
163
|
+
db,
|
|
164
|
+
close: () => db.close()
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
exports.useSqliteAuthState = useSqliteAuthState;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __def = (m) => (m && m.__esModule) ? m.default : m;
|
|
4
|
+
const __exportStar = (m, e) => { for (const k in m) if (k !== "default" && !Object.prototype.hasOwnProperty.call(e, k)) e[k] = m[k]; };
|
|
5
|
+
const { assertNodeErrorFree, getBinaryNodeChild } = require("../../WABinary/index.js");
|
|
6
|
+
|
|
7
|
+
class USyncBusinessProtocol {
|
|
8
|
+
constructor(profileVersion = '2') {
|
|
9
|
+
this.name = 'business'
|
|
10
|
+
this.profileVersion = profileVersion
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getQueryElement() {
|
|
14
|
+
return {
|
|
15
|
+
tag: 'business',
|
|
16
|
+
attrs: {},
|
|
17
|
+
content: [
|
|
18
|
+
{ tag: 'verified_name', attrs: {} },
|
|
19
|
+
{ tag: 'profile', attrs: { v: this.profileVersion } }
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getUserElement(user) {
|
|
25
|
+
const children = []
|
|
26
|
+
if (user.verifiedNameSerial) {
|
|
27
|
+
children.push({ tag: 'verified_name', attrs: { serial: user.verifiedNameSerial } })
|
|
28
|
+
}
|
|
29
|
+
if (user.businessProfileTag) {
|
|
30
|
+
children.push({ tag: 'profile', attrs: { tag: user.businessProfileTag } })
|
|
31
|
+
}
|
|
32
|
+
return children.length > 0 ? { tag: 'business', attrs: {}, content: children } : null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
parser(node) {
|
|
36
|
+
if (node.tag !== 'business') return null
|
|
37
|
+
assertNodeErrorFree(node)
|
|
38
|
+
const verifiedNameNode = getBinaryNodeChild(node, 'verified_name')
|
|
39
|
+
const profileNode = getBinaryNodeChild(node, 'profile')
|
|
40
|
+
return {
|
|
41
|
+
verifiedName: verifiedNameNode?.content ?? null,
|
|
42
|
+
verifiedLevel: verifiedNameNode?.attrs?.verified_level ?? null,
|
|
43
|
+
profileTag: profileNode?.attrs?.tag ?? null,
|
|
44
|
+
pnJid: node.attrs?.pn_jid ?? null
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
exports.USyncBusinessProtocol = USyncBusinessProtocol;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __def = (m) => (m && m.__esModule) ? m.default : m;
|
|
4
|
+
const __exportStar = (m, e) => { for (const k in m) if (k !== "default" && !Object.prototype.hasOwnProperty.call(e, k)) e[k] = m[k]; };
|
|
5
|
+
const { getBinaryNodeChild } = require("../../WABinary/index.js");
|
|
6
|
+
|
|
7
|
+
// Device feature flags that can be queried, ported from WhatsApp Web's
|
|
8
|
+
// WAWebUsyncFeature module.
|
|
9
|
+
const USYNC_FEATURES = [
|
|
10
|
+
'document',
|
|
11
|
+
'encrypt',
|
|
12
|
+
'encrypt_blist',
|
|
13
|
+
'encrypt_contact',
|
|
14
|
+
'encrypt_group_gen2',
|
|
15
|
+
'encrypt_image',
|
|
16
|
+
'encrypt_location',
|
|
17
|
+
'encrypt_url',
|
|
18
|
+
'encrypt_v2',
|
|
19
|
+
'voip',
|
|
20
|
+
'multi_agent'
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
class USyncFeatureProtocol {
|
|
24
|
+
/**
|
|
25
|
+
* @param {string[]} [features] feature names to query (defaults to all known)
|
|
26
|
+
*/
|
|
27
|
+
constructor(features) {
|
|
28
|
+
this.name = 'feature'
|
|
29
|
+
this.features = features && features.length ? features : USYNC_FEATURES
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getQueryElement() {
|
|
33
|
+
return {
|
|
34
|
+
tag: 'feature',
|
|
35
|
+
attrs: {},
|
|
36
|
+
content: this.features.map(feature => ({ tag: feature, attrs: {} }))
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getUserElement() {
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
parser(node) {
|
|
45
|
+
if (node.tag !== 'feature') return null
|
|
46
|
+
const errorNode = getBinaryNodeChild(node, 'error')
|
|
47
|
+
if (errorNode) {
|
|
48
|
+
return {
|
|
49
|
+
errorCode: errorNode.attrs?.code ? +errorNode.attrs.code : undefined,
|
|
50
|
+
errorText: errorNode.attrs?.text
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const features = {}
|
|
54
|
+
const children = Array.isArray(node.content) ? node.content : []
|
|
55
|
+
for (const child of children) {
|
|
56
|
+
if (child?.attrs && child.attrs.value !== undefined) {
|
|
57
|
+
features[child.tag] = child.attrs.value
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return features
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports.USYNC_FEATURES = USYNC_FEATURES;
|
|
65
|
+
exports.USyncFeatureProtocol = USyncFeatureProtocol;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __def = (m) => (m && m.__esModule) ? m.default : m;
|
|
4
|
+
const __exportStar = (m, e) => { for (const k in m) if (k !== "default" && !Object.prototype.hasOwnProperty.call(e, k)) e[k] = m[k]; };
|
|
5
|
+
const { assertNodeErrorFree } = require("../../WABinary/index.js");
|
|
6
|
+
|
|
7
|
+
class USyncPictureProtocol {
|
|
8
|
+
constructor(type = 'image') {
|
|
9
|
+
this.name = 'picture'
|
|
10
|
+
// "image" for full resolution, "preview" for thumbnail
|
|
11
|
+
this.type = type
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getQueryElement() {
|
|
15
|
+
return {
|
|
16
|
+
tag: 'picture',
|
|
17
|
+
attrs: { type: this.type }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getUserElement(user) {
|
|
22
|
+
const attrs = {}
|
|
23
|
+
if (user.pictureId != null) attrs.id = String(user.pictureId)
|
|
24
|
+
return Object.keys(attrs).length > 0 ? { tag: 'picture', attrs } : null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
parser(node) {
|
|
28
|
+
if (node.tag !== 'picture') return null
|
|
29
|
+
assertNodeErrorFree(node)
|
|
30
|
+
const id = node.attrs?.id ?? null
|
|
31
|
+
const directPath = node.attrs?.direct_path ?? null
|
|
32
|
+
const hash = node.attrs?.hash ?? null
|
|
33
|
+
if (!id && !directPath) return null
|
|
34
|
+
return { id, directPath, hash }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.USyncPictureProtocol = USyncPictureProtocol;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __def = (m) => (m && m.__esModule) ? m.default : m;
|
|
4
|
+
const __exportStar = (m, e) => { for (const k in m) if (k !== "default" && !Object.prototype.hasOwnProperty.call(e, k)) e[k] = m[k]; };
|
|
5
|
+
const { assertNodeErrorFree } = require("../../WABinary/index.js");
|
|
6
|
+
|
|
7
|
+
class USyncSidelistProtocol {
|
|
8
|
+
constructor(useLidAddressing = true) {
|
|
9
|
+
this.name = 'sidelist'
|
|
10
|
+
// When true, sends addressing_mode="lid" — required for interop/LID-mode contacts
|
|
11
|
+
this.useLidAddressing = useLidAddressing
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getQueryElement() {
|
|
15
|
+
const attrs = {}
|
|
16
|
+
if (this.useLidAddressing) attrs.addressing_mode = 'lid'
|
|
17
|
+
return { tag: 'sidelist', attrs }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getUserElement(user) {
|
|
21
|
+
if (user.sidelistDelete) {
|
|
22
|
+
return { tag: 'sidelist', attrs: { type: 'delete' } }
|
|
23
|
+
}
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
parser(node) {
|
|
28
|
+
if (node.tag !== 'sidelist' && node.tag !== 'side_list') return null
|
|
29
|
+
assertNodeErrorFree(node)
|
|
30
|
+
return { type: node.attrs?.type ?? null }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.USyncSidelistProtocol = USyncSidelistProtocol;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __def = (m) => (m && m.__esModule) ? m.default : m;
|
|
4
|
+
const __exportStar = (m, e) => { for (const k in m) if (k !== "default" && !Object.prototype.hasOwnProperty.call(e, k)) e[k] = m[k]; };
|
|
5
|
+
const { assertNodeErrorFree, getBinaryNodeChild } = require("../../WABinary/index.js");
|
|
6
|
+
|
|
7
|
+
class USyncTextStatusProtocol {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.name = 'text_status'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getQueryElement() {
|
|
13
|
+
return {
|
|
14
|
+
tag: 'text_status',
|
|
15
|
+
attrs: {}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getUserElement() {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
parser(node) {
|
|
24
|
+
if (node.tag !== 'text_status') return null
|
|
25
|
+
assertNodeErrorFree(node)
|
|
26
|
+
const lastUpdateTimeSec = node.attrs?.last_update_time ? +node.attrs.last_update_time : 0
|
|
27
|
+
const ephemeralDurationSec = node.attrs?.ephemeral_duration_sec ? +node.attrs.ephemeral_duration_sec : 0
|
|
28
|
+
const text = node.attrs?.text ?? null
|
|
29
|
+
const emojiNode = getBinaryNodeChild(node, 'emoji')
|
|
30
|
+
const emoji = emojiNode?.attrs?.content ?? null
|
|
31
|
+
// expiry is lastUpdateTime + ephemeralDuration (both in ms); 0 means no expiry
|
|
32
|
+
const expiresAt = ephemeralDurationSec > 0
|
|
33
|
+
? new Date((lastUpdateTimeSec + ephemeralDurationSec) * 1000)
|
|
34
|
+
: null
|
|
35
|
+
return {
|
|
36
|
+
text,
|
|
37
|
+
emoji,
|
|
38
|
+
setAt: new Date(lastUpdateTimeSec * 1000),
|
|
39
|
+
expiresAt
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.USyncTextStatusProtocol = USyncTextStatusProtocol;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __def = (m) => (m && m.__esModule) ? m.default : m;
|
|
4
|
+
const __exportStar = (m, e) => { for (const k in m) if (k !== "default" && !Object.prototype.hasOwnProperty.call(e, k)) e[k] = m[k]; };
|
|
5
|
+
const { assertNodeErrorFree } = require("../../WABinary/index.js");
|
|
6
|
+
|
|
7
|
+
class USyncUsernameProtocol {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.name = 'username'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getQueryElement() {
|
|
13
|
+
return {
|
|
14
|
+
tag: 'username',
|
|
15
|
+
attrs: {}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getUserElement(user) {
|
|
20
|
+
void user
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
parser(node) {
|
|
25
|
+
if (node.tag === 'username') {
|
|
26
|
+
assertNodeErrorFree(node)
|
|
27
|
+
return typeof node.content === 'string' ? node.content : null
|
|
28
|
+
}
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.USyncUsernameProtocol = USyncUsernameProtocol;
|
|
@@ -18,3 +18,9 @@ __exportStar(require("./USyncDeviceProtocol"), exports);
|
|
|
18
18
|
__exportStar(require("./USyncContactProtocol"), exports);
|
|
19
19
|
__exportStar(require("./USyncStatusProtocol"), exports);
|
|
20
20
|
__exportStar(require("./USyncDisappearingModeProtocol"), exports);
|
|
21
|
+
__exportStar(require("./USyncUsernameProtocol"), exports);
|
|
22
|
+
__exportStar(require("./USyncBusinessProtocol"), exports);
|
|
23
|
+
__exportStar(require("./USyncPictureProtocol"), exports);
|
|
24
|
+
__exportStar(require("./USyncTextStatusProtocol"), exports);
|
|
25
|
+
__exportStar(require("./USyncSidelistProtocol"), exports);
|
|
26
|
+
__exportStar(require("./USyncFeatureProtocol"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruthless-imperium/baileys",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "WhatsApp Web API Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"imperium",
|
|
@@ -54,69 +54,32 @@
|
|
|
54
54
|
"@cacheable/node-cache": "^1.4.0",
|
|
55
55
|
"@hapi/boom": "^9.1.3",
|
|
56
56
|
"async-mutex": "^0.5.0",
|
|
57
|
+
"audio-decode": "^2.1.3",
|
|
57
58
|
"axios": "^1.6.0",
|
|
58
59
|
"cache-manager": "^5.7.6",
|
|
59
60
|
"chalk": "^4.1.2",
|
|
60
61
|
"cheerio": "^1.0.0-rc.10",
|
|
62
|
+
"fflate": "^0.8.2",
|
|
63
|
+
"file-type": "^16.5.4",
|
|
64
|
+
"fluent-ffmpeg": "^2.1.3",
|
|
65
|
+
"form-data": "^4.0.0",
|
|
61
66
|
"gradient-string": "^2.0.2",
|
|
67
|
+
"jimp": "^0.22.12",
|
|
62
68
|
"libphonenumber-js": "^1.10.20",
|
|
63
69
|
"libsignal": "npm:@noxzaid/libsignal-node",
|
|
70
|
+
"link-preview-js": "^3.0.0",
|
|
64
71
|
"lodash": "^4.17.21",
|
|
65
72
|
"lru-cache": "^11.1.0",
|
|
66
73
|
"music-metadata": "^7.12.3",
|
|
67
74
|
"p-queue": "^9.0.0",
|
|
68
75
|
"pino": "^9.6",
|
|
69
76
|
"protobufjs": "^6.11.3",
|
|
70
|
-
"uuid": "^10.0.0",
|
|
71
|
-
"ws": "^8.13.0"
|
|
72
|
-
},
|
|
73
|
-
"devDependencies": {
|
|
74
|
-
"@adiwajshing/eslint-config": "npm:@noxzaid/eslint-config",
|
|
75
|
-
"@types/got": "^9.6.11",
|
|
76
|
-
"@types/jest": "^27.5.1",
|
|
77
|
-
"@types/node": "^16.18.126",
|
|
78
|
-
"@types/sharp": "^0.29.4",
|
|
79
|
-
"@types/ws": "^8.0.0",
|
|
80
|
-
"conventional-changelog-cli": "^2.2.2",
|
|
81
|
-
"eslint": "^8.0.0",
|
|
82
|
-
"jest": "^27.0.6",
|
|
83
|
-
"jimp": "^0.22.12",
|
|
84
|
-
"json": "^11.0.0",
|
|
85
|
-
"link-preview-js": "^3.0.0",
|
|
86
|
-
"open": "^8.4.2",
|
|
87
77
|
"qrcode-terminal": "^0.12.0",
|
|
88
|
-
"release-it": "^15.10.3",
|
|
89
78
|
"sharp": "^0.34.1",
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"typedoc": "^0.27.9",
|
|
93
|
-
"typescript": "^5.8.2"
|
|
94
|
-
},
|
|
95
|
-
"peerDependencies": {
|
|
96
|
-
"audio-decode": "^2.1.3",
|
|
97
|
-
"jimp": "^0.22.12",
|
|
98
|
-
"link-preview-js": "^3.0.0",
|
|
99
|
-
"qrcode-terminal": "^0.12.0",
|
|
100
|
-
"sharp": "^0.34.1"
|
|
101
|
-
},
|
|
102
|
-
"peerDependenciesMeta": {
|
|
103
|
-
"audio-decode": {
|
|
104
|
-
"optional": true
|
|
105
|
-
},
|
|
106
|
-
"jimp": {
|
|
107
|
-
"optional": true
|
|
108
|
-
},
|
|
109
|
-
"link-preview-js": {
|
|
110
|
-
"optional": true
|
|
111
|
-
},
|
|
112
|
-
"qrcode-terminal": {
|
|
113
|
-
"optional": true
|
|
114
|
-
},
|
|
115
|
-
"sharp": {
|
|
116
|
-
"optional": true
|
|
117
|
-
}
|
|
79
|
+
"uuid": "^10.0.0",
|
|
80
|
+
"ws": "^8.13.0"
|
|
118
81
|
},
|
|
119
82
|
"engines": {
|
|
120
83
|
"node": ">=20.0.0"
|
|
121
84
|
}
|
|
122
|
-
}
|
|
85
|
+
}
|