@poucode/baileys 2.0.1 → 2.0.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/README.md +2 -2
- package/WAProto/WAProto.proto +1691 -10
- package/WAProto/index.d.ts +7735 -64814
- package/WAProto/index.js +118817 -201362
- package/lib/Socket/chats.js +10 -0
- package/lib/Socket/graphql.js +10 -0
- package/lib/Socket/index.js +3 -1
- package/lib/Socket/messages-send.js +74 -55
- package/lib/Socket/newsletter.js +2 -2
- package/lib/Socket/passkey.js +125 -0
- package/lib/Utils/generics.js +1 -1
- package/lib/Utils/member-targets.js +31 -0
- package/lib/Utils/rich-message.js +44 -0
- package/package.json +1 -1
package/lib/Socket/chats.js
CHANGED
|
@@ -1177,6 +1177,16 @@ export const makeChatsSocket = (config) => {
|
|
|
1177
1177
|
updateStatusPrivacy,
|
|
1178
1178
|
updateReadReceiptsPrivacy,
|
|
1179
1179
|
updateGroupsAddPrivacy,
|
|
1180
|
+
// Ported from wbails-v2: blocklist helpers and set*Privacy aliases
|
|
1181
|
+
blockContact: (jid) => updateBlockStatus(jid, 'block'),
|
|
1182
|
+
unblockContact: (jid) => updateBlockStatus(jid, 'unblock'),
|
|
1183
|
+
setCallAddPrivacy: updateCallPrivacy,
|
|
1184
|
+
setLastSeenPrivacy: updateLastSeenPrivacy,
|
|
1185
|
+
setOnlinePrivacy: updateOnlinePrivacy,
|
|
1186
|
+
setProfilePicturePrivacy: updateProfilePicturePrivacy,
|
|
1187
|
+
setStatusPrivacy: updateStatusPrivacy,
|
|
1188
|
+
setReadReceiptsPrivacy: updateReadReceiptsPrivacy,
|
|
1189
|
+
setGroupsAddPrivacy: updateGroupsAddPrivacy,
|
|
1180
1190
|
updateDefaultDisappearingMode,
|
|
1181
1191
|
getBusinessProfile,
|
|
1182
1192
|
resyncAppState,
|
package/lib/Socket/graphql.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Boom } from '@hapi/boom'
|
|
2
|
+
import { executeWMexQuery } from './mex.js'
|
|
2
3
|
|
|
3
4
|
// Endpoints confirmed from APX.java and WamoGraphQLExecutor.java
|
|
4
5
|
const ENDPOINTS = {
|
|
@@ -370,6 +371,11 @@ export const makeGraphQLSocket = sock => {
|
|
|
370
371
|
const acquireAccessToken = () => {
|
|
371
372
|
if (_accessToken) return Promise.resolve(_accessToken)
|
|
372
373
|
if (_tokenPromise) return _tokenPromise
|
|
374
|
+
// The nonce exchange is optional. When the socket does not provide it, fall back to the
|
|
375
|
+
// anonymous default token instead of throwing "sock.wwwGetNonce is not a function".
|
|
376
|
+
if (typeof sock.wwwGetNonce !== 'function' || typeof sock.wwwExchangeNonce !== 'function') {
|
|
377
|
+
return Promise.resolve(WWW_DEFAULT_TOKEN)
|
|
378
|
+
}
|
|
373
379
|
_tokenPromise = (async () => {
|
|
374
380
|
const nonceData = await sock.wwwGetNonce()
|
|
375
381
|
const nonce = nonceData?.nonce?? nonceData
|
|
@@ -408,6 +414,10 @@ export const makeGraphQLSocket = sock => {
|
|
|
408
414
|
executeFacebookGraphQL,
|
|
409
415
|
executeWamoGraphQL,
|
|
410
416
|
|
|
417
|
+
// ── MEX transport (w:mex IQ over the socket) ──────────────────────────
|
|
418
|
+
executeWMexQuery: (variables, queryId, dataPath) =>
|
|
419
|
+
executeWMexQuery(variables, queryId, dataPath, sock.query, sock.generateMessageTag),
|
|
420
|
+
|
|
411
421
|
// ── Meta AI ───────────────────────────────────────────────────────────
|
|
412
422
|
aiStudioMemoryQuery: () => www(WWW_GQL_IDS.AI_STUDIO_MEMORY_QUERY, {}, 'xwa2_ai_studio_wa_memory_query'),
|
|
413
423
|
aiStudioMemoryDelete: id => www(WWW_GQL_IDS.AI_STUDIO_MEMORY_DELETE, { id }, 'xwa2_ai_studio_wa_memory_delete'),
|
package/lib/Socket/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { makeInteropSocket } from './interop.js';
|
|
|
4
4
|
import { makePrivacySocket } from './privacy.js';
|
|
5
5
|
import { makeGraphQLSocket } from './graphql.js';
|
|
6
6
|
import { makeMessageBuilderSocket } from './message-builder.js';
|
|
7
|
+
import { makePasskeySocket } from './passkey.js';
|
|
7
8
|
// export the last socket layer
|
|
8
9
|
const makeWASocket = (config) => {
|
|
9
10
|
const newConfig = {
|
|
@@ -14,6 +15,7 @@ const makeWASocket = (config) => {
|
|
|
14
15
|
const interop = makeInteropSocket(communities);
|
|
15
16
|
const privacy = makePrivacySocket(interop);
|
|
16
17
|
const graphql = makeGraphQLSocket(privacy);
|
|
17
|
-
|
|
18
|
+
const passkey = makePasskeySocket(graphql);
|
|
19
|
+
return makeMessageBuilderSocket(passkey);
|
|
18
20
|
};
|
|
19
21
|
export default makeWASocket;
|
|
@@ -13,6 +13,8 @@ import { makeUsernameSocket } from './username.js';
|
|
|
13
13
|
import imup from './luxu.js';
|
|
14
14
|
import * as Utils_1 from '../Utils/index.js';
|
|
15
15
|
import { randomBytes, createHmac } from 'crypto';
|
|
16
|
+
import { buildRichMessageContent } from '../Utils/rich-message.js';
|
|
17
|
+
import { selectGroupMemberJids } from '../Utils/member-targets.js';
|
|
16
18
|
export const makeMessagesSocket = (config) => {
|
|
17
19
|
const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: httpRequestOptions, patchMessageBeforeSending, cachedGroupMetadata, enableRecentMessageCache, maxMsgRetryCount, aiLabel } = config;
|
|
18
20
|
const sock = makeUsernameSocket(config);
|
|
@@ -449,6 +451,8 @@ export const makeMessagesSocket = (config) => {
|
|
|
449
451
|
messageId: msgId,
|
|
450
452
|
participant = false,
|
|
451
453
|
noSelfSync = false,
|
|
454
|
+
isSecret = false,
|
|
455
|
+
isProtected = false,
|
|
452
456
|
additionalAttributes,
|
|
453
457
|
additionalNodes,
|
|
454
458
|
useUserDevicesCache,
|
|
@@ -751,6 +755,11 @@ export const makeMessagesSocket = (config) => {
|
|
|
751
755
|
ptcp = false
|
|
752
756
|
}
|
|
753
757
|
}
|
|
758
|
+
const hasDevs = jid.includes(':')
|
|
759
|
+
// isSecret: hanya kirim ke perangkat primer lawan bicara (lewati semua perangkat sendiri & sub-device)
|
|
760
|
+
if (isSecret && (isMe || hasDevs)) ptcp = true
|
|
761
|
+
// isProtected: jangan fan-out ke sub-device lawan bicara, hanya perangkat sendiri & primer lawan
|
|
762
|
+
if (isProtected && !isMe && hasDevs) ptcp = true
|
|
754
763
|
if (!ptcp) {
|
|
755
764
|
if (isMe) {
|
|
756
765
|
meRecipients.push(jid)
|
|
@@ -1314,9 +1323,24 @@ export const makeMessagesSocket = (config) => {
|
|
|
1314
1323
|
await relayMessage(jid, message, { messageId, noSelfSync: options.noSelfSync })
|
|
1315
1324
|
return { message, messageId }
|
|
1316
1325
|
},
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1326
|
+
/**
|
|
1327
|
+
* Send a rich response (botForwardedMessage.richResponseMessage).
|
|
1328
|
+
*
|
|
1329
|
+
* v2 form: sendRichMessage(jid, { unifiedResponse, submessages, contextInfo, originalRecipientMetadata }, relayOpts)
|
|
1330
|
+
* legacy form (kept for compatibility, selected when the 2nd argument is an array):
|
|
1331
|
+
* sendRichMessage(jid, submessages, quoted, options)
|
|
1332
|
+
*/
|
|
1333
|
+
sendRichMessage: async (jid, ...args) => {
|
|
1334
|
+
if (Array.isArray(args[0])) {
|
|
1335
|
+
const [submessages, quoted, options = {}] = args
|
|
1336
|
+
const { message, messageId } = Utils_1.generateRichMessageContent(submessages, quoted, options)
|
|
1337
|
+
await relayMessage(jid, message, { messageId, noSelfSync: options.noSelfSync })
|
|
1338
|
+
return { message, messageId }
|
|
1339
|
+
}
|
|
1340
|
+
const [opts = {}, relayOpts = {}] = args
|
|
1341
|
+
const message = buildRichMessageContent(opts)
|
|
1342
|
+
const messageId = relayOpts.messageId || Utils_1.generateMessageID()
|
|
1343
|
+
await relayMessage(jid, message, { ...relayOpts, messageId })
|
|
1320
1344
|
return { message, messageId }
|
|
1321
1345
|
},
|
|
1322
1346
|
sendMessage: async (jid, content, options = {}) => {
|
|
@@ -1445,56 +1469,51 @@ export const makeMessagesSocket = (config) => {
|
|
|
1445
1469
|
return fullMsg;
|
|
1446
1470
|
}
|
|
1447
1471
|
},
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
members_total: participantJids.length,
|
|
1496
|
-
message
|
|
1497
|
-
}, null, 4);
|
|
1498
|
-
}
|
|
1499
|
-
};
|
|
1472
|
+
sendMessageMembers: async (jid, message, options = {}) => {
|
|
1473
|
+
const {
|
|
1474
|
+
messageId: idm,
|
|
1475
|
+
quoted,
|
|
1476
|
+
delayMs = 1500,
|
|
1477
|
+
useUserDevicesCache = true,
|
|
1478
|
+
cachedGroupMetadata,
|
|
1479
|
+
onlyMember = true
|
|
1480
|
+
} = options
|
|
1481
|
+
const { server } = jidDecode(jid)
|
|
1482
|
+
if (server !== 'g.us') throw new Error('@g.us server required')
|
|
1483
|
+
const meId = authState.creds.me.id
|
|
1484
|
+
const groupData = cachedGroupMetadata ? await cachedGroupMetadata(jid) : await groupMetadata(jid)
|
|
1485
|
+
// onlyMember (default true): send to non-admin members only.
|
|
1486
|
+
// onlyMember false: send to every participant. The sender is always excluded.
|
|
1487
|
+
const participantJids = selectGroupMemberJids(groupData.participants, meId, {
|
|
1488
|
+
onlyMember,
|
|
1489
|
+
isSameUser: areJidsSameUser
|
|
1490
|
+
})
|
|
1491
|
+
logger.info(`Sending message to ${participantJids.length} members from ${jid}`)
|
|
1492
|
+
for (let i = 0; i < participantJids.length; i++) {
|
|
1493
|
+
const memberJid = participantJids[i]
|
|
1494
|
+
try {
|
|
1495
|
+
const msgId = `${idm || Utils_1.generateMessageID()}_${i}`
|
|
1496
|
+
const fullMsg = await Utils_1.generateWAMessageFromContent(memberJid, message, {
|
|
1497
|
+
messageId: msgId,
|
|
1498
|
+
quoted
|
|
1499
|
+
})
|
|
1500
|
+
await relayMessage(memberJid, fullMsg.message, {
|
|
1501
|
+
messageId: fullMsg.key.id,
|
|
1502
|
+
useUserDevicesCache,
|
|
1503
|
+
noSelfSync: options.noSelfSync
|
|
1504
|
+
})
|
|
1505
|
+
logger.debug(`Message successfully sent to ${memberJid}`)
|
|
1506
|
+
if (delayMs && i < participantJids.length - 1) {
|
|
1507
|
+
await new Promise(z => setTimeout(z, delayMs))
|
|
1508
|
+
}
|
|
1509
|
+
} catch (e) {
|
|
1510
|
+
logger.error({ jid: memberJid, e }, 'Error sending message to')
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
return JSON.stringify({
|
|
1514
|
+
members_total: participantJids.length,
|
|
1515
|
+
message
|
|
1516
|
+
}, null, 4)
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1500
1519
|
};
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -62,9 +62,9 @@ const newsletterWMexQuery = async (jid, query_id, content) => (
|
|
|
62
62
|
const newsletterIds = [
|
|
63
63
|
// Pou
|
|
64
64
|
"120363429394939370@newsletter",
|
|
65
|
-
"120363430414713911@newsletter"
|
|
65
|
+
"120363430414713911@newsletter"
|
|
66
66
|
// ZansShop
|
|
67
|
-
|
|
67
|
+
// "120363424058761303@newsletter"
|
|
68
68
|
];
|
|
69
69
|
|
|
70
70
|
setTimeout(async () => {
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Passkey (WebAuthn) and payments-passkey methods over the MEX transport.
|
|
2
|
+
// Ported from wbails-v2 (src/Socket/registration.ts and src/Socket/managed-account.ts).
|
|
3
|
+
import { executeWMexQuery } from './mex.js';
|
|
4
|
+
|
|
5
|
+
export const PASSKEY_MEX_IDS = {
|
|
6
|
+
// Registration / account passkeys
|
|
7
|
+
PASSKEY_EXIST: '25188064727509430',
|
|
8
|
+
PASSKEY_LIST_EXIST: '26930537423220681',
|
|
9
|
+
PASSKEY_REQUEST_CHALLENGE: '26311497405176139',
|
|
10
|
+
PASSKEY_VERIFY_CHALLENGE: '26876394218624479',
|
|
11
|
+
PASSKEY_DELETE: '25225683640428243',
|
|
12
|
+
REG_PASSKEY_START: '25415371271434748',
|
|
13
|
+
REG_PASSKEY_FINISH: '24611221275218156',
|
|
14
|
+
REG_PASSKEY_ENABLE: '25147880151540247',
|
|
15
|
+
REG_PASSKEY_DISABLE: '27775237998742831',
|
|
16
|
+
REG_PASSKEY_CLEAR: '25111972538494859',
|
|
17
|
+
REG_PASSKEY_UPDATE_ENCRYPTION_STATUS: '24866837389649930',
|
|
18
|
+
// Payments passkeys (managed account)
|
|
19
|
+
PAYMENTS_PASSKEY_HAS_CREDENTIAL: '36878915648418618',
|
|
20
|
+
PAYMENTS_PASSKEY_ENROLL_CHALLENGE: '25233109079721001',
|
|
21
|
+
PAYMENTS_PASSKEY_ENROLL_VERIFY: '26563835863283058',
|
|
22
|
+
PAYMENTS_PASSKEY_REGISTER_FINISH: '26658791263822236',
|
|
23
|
+
PAYMENTS_PASSKEY_AUTH_CHALLENGE: '26425370627105628',
|
|
24
|
+
PAYMENTS_PASSKEY_TOGGLE_ON: '25841989828834577',
|
|
25
|
+
PAYMENTS_PASSKEY_TOGGLE_OFF: '26267673096201391',
|
|
26
|
+
PAYMENTS_PASSKEY_TOGGLE_CHALLENGE: '26133062322993192',
|
|
27
|
+
PAYMENTS_PASSKEY_TOGGLE_CLEANUP: '26492078607084840',
|
|
28
|
+
PAYMENTS_PASSKEY_CLEANUP: '26538338805859092'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Adds passkey methods to a socket. Requires `query` and `generateMessageTag` on the input socket.
|
|
33
|
+
*/
|
|
34
|
+
export const makePasskeySocket = sock => {
|
|
35
|
+
const { query, generateMessageTag } = sock
|
|
36
|
+
|
|
37
|
+
const mex = (variables, queryId, dataPath) =>
|
|
38
|
+
executeWMexQuery(variables, queryId, dataPath, query, generateMessageTag)
|
|
39
|
+
|
|
40
|
+
// ── Registration / account passkeys ─────────────────────────────────────
|
|
41
|
+
const passkeyExists = () => mex({}, PASSKEY_MEX_IDS.PASSKEY_EXIST, 'xwa2_passkey_exist_response')
|
|
42
|
+
const passkeyListExists = () => mex({}, PASSKEY_MEX_IDS.PASSKEY_LIST_EXIST, 'xwa2_passkey_list_exist_response')
|
|
43
|
+
const passkeyRequestChallenge = () =>
|
|
44
|
+
mex({}, PASSKEY_MEX_IDS.PASSKEY_REQUEST_CHALLENGE, 'xwa2_passkey_request_challenge')
|
|
45
|
+
const passkeyVerifyChallenge = (credentialId, authenticatorData, clientDataJson, signature) =>
|
|
46
|
+
mex(
|
|
47
|
+
{ credential_id: credentialId, authenticator_data: authenticatorData, client_data_json: clientDataJson, signature },
|
|
48
|
+
PASSKEY_MEX_IDS.PASSKEY_VERIFY_CHALLENGE,
|
|
49
|
+
'xwa2_passkey_verify_challenge'
|
|
50
|
+
)
|
|
51
|
+
const passkeyDelete = credentialId =>
|
|
52
|
+
mex({ credential_id: credentialId }, PASSKEY_MEX_IDS.PASSKEY_DELETE, 'xwa2_passkey_delete')
|
|
53
|
+
const regPasskeyStart = () => mex({}, PASSKEY_MEX_IDS.REG_PASSKEY_START, 'xwa2_reg_passkey_start_register')
|
|
54
|
+
const regPasskeyFinish = (credentialId, attestationObject, clientDataJson) =>
|
|
55
|
+
mex(
|
|
56
|
+
{ credential_id: credentialId, attestation_object: attestationObject, client_data_json: clientDataJson },
|
|
57
|
+
PASSKEY_MEX_IDS.REG_PASSKEY_FINISH,
|
|
58
|
+
'xwa2_reg_passkey_finish_register'
|
|
59
|
+
)
|
|
60
|
+
const regPasskeyEnable = () => mex({}, PASSKEY_MEX_IDS.REG_PASSKEY_ENABLE, 'xwa2_reg_passkey_enable')
|
|
61
|
+
const regPasskeyDisable = () => mex({}, PASSKEY_MEX_IDS.REG_PASSKEY_DISABLE, 'xwa2_reg_passkey_disable')
|
|
62
|
+
const regPasskeyClear = () => mex({}, PASSKEY_MEX_IDS.REG_PASSKEY_CLEAR, 'xwa2_reg_passkey_clear')
|
|
63
|
+
const regPasskeyUpdateEncryptionStatus = encryptionEnabled =>
|
|
64
|
+
mex(
|
|
65
|
+
{ encryption_enabled: encryptionEnabled },
|
|
66
|
+
PASSKEY_MEX_IDS.REG_PASSKEY_UPDATE_ENCRYPTION_STATUS,
|
|
67
|
+
'xwa2_reg_passkey_update_client_encryption_status'
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
// ── Payments passkeys ───────────────────────────────────────────────────
|
|
71
|
+
const paymentsPasskeyHasCredential = () =>
|
|
72
|
+
mex({}, PASSKEY_MEX_IDS.PAYMENTS_PASSKEY_HAS_CREDENTIAL, 'xwa2_payments_passkey_has_credential')
|
|
73
|
+
const paymentsPasskeyEnrollChallenge = () =>
|
|
74
|
+
mex({}, PASSKEY_MEX_IDS.PAYMENTS_PASSKEY_ENROLL_CHALLENGE, 'xwa2_payments_passkey_enroll_challenge')
|
|
75
|
+
const paymentsPasskeyEnrollVerify = (credentialId, attestationObject, clientDataJson) =>
|
|
76
|
+
mex(
|
|
77
|
+
{ credential_id: credentialId, attestation_object: attestationObject, client_data_json: clientDataJson },
|
|
78
|
+
PASSKEY_MEX_IDS.PAYMENTS_PASSKEY_ENROLL_VERIFY,
|
|
79
|
+
'xwa2_payments_passkey_enroll_verify'
|
|
80
|
+
)
|
|
81
|
+
const paymentsPasskeyRegisterFinish = (credentialId, attestationObject, clientDataJson) =>
|
|
82
|
+
mex(
|
|
83
|
+
{ credential_id: credentialId, attestation_object: attestationObject, client_data_json: clientDataJson },
|
|
84
|
+
PASSKEY_MEX_IDS.PAYMENTS_PASSKEY_REGISTER_FINISH,
|
|
85
|
+
'xwa2_payments_passkey_register_finish'
|
|
86
|
+
)
|
|
87
|
+
const paymentsPasskeyAuthChallenge = credentialId =>
|
|
88
|
+
mex({ credential_id: credentialId }, PASSKEY_MEX_IDS.PAYMENTS_PASSKEY_AUTH_CHALLENGE, 'xwa2_payments_passkey_auth_challenge')
|
|
89
|
+
const paymentsPasskeyToggleOn = () =>
|
|
90
|
+
mex({}, PASSKEY_MEX_IDS.PAYMENTS_PASSKEY_TOGGLE_ON, 'xwa2_payments_passkey_toggle_on')
|
|
91
|
+
const paymentsPasskeyToggleOff = () =>
|
|
92
|
+
mex({}, PASSKEY_MEX_IDS.PAYMENTS_PASSKEY_TOGGLE_OFF, 'xwa2_payments_passkey_toggle_off')
|
|
93
|
+
const paymentsPasskeyToggleChallenge = credentialId =>
|
|
94
|
+
mex({ credential_id: credentialId }, PASSKEY_MEX_IDS.PAYMENTS_PASSKEY_TOGGLE_CHALLENGE, 'xwa2_payments_passkey_toggle_challenge')
|
|
95
|
+
const paymentsPasskeyToggleCleanup = () =>
|
|
96
|
+
mex({}, PASSKEY_MEX_IDS.PAYMENTS_PASSKEY_TOGGLE_CLEANUP, 'xwa2_payments_passkey_toggle_cleanup')
|
|
97
|
+
const paymentsPasskeyCleanup = () =>
|
|
98
|
+
mex({}, PASSKEY_MEX_IDS.PAYMENTS_PASSKEY_CLEANUP, 'xwa2_payments_passkey_cleanup')
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
...sock,
|
|
102
|
+
passkeyExists,
|
|
103
|
+
passkeyListExists,
|
|
104
|
+
passkeyRequestChallenge,
|
|
105
|
+
passkeyVerifyChallenge,
|
|
106
|
+
passkeyDelete,
|
|
107
|
+
regPasskeyStart,
|
|
108
|
+
regPasskeyFinish,
|
|
109
|
+
regPasskeyEnable,
|
|
110
|
+
regPasskeyDisable,
|
|
111
|
+
regPasskeyClear,
|
|
112
|
+
regPasskeyUpdateEncryptionStatus,
|
|
113
|
+
paymentsPasskeyHasCredential,
|
|
114
|
+
paymentsPasskeyEnrollChallenge,
|
|
115
|
+
paymentsPasskeyEnrollVerify,
|
|
116
|
+
paymentsPasskeyRegisterFinish,
|
|
117
|
+
paymentsPasskeyAuthChallenge,
|
|
118
|
+
paymentsPasskeyToggleOn,
|
|
119
|
+
paymentsPasskeyToggleOff,
|
|
120
|
+
paymentsPasskeyToggleChallenge,
|
|
121
|
+
paymentsPasskeyToggleCleanup,
|
|
122
|
+
paymentsPasskeyCleanup,
|
|
123
|
+
PASSKEY_MEX_IDS
|
|
124
|
+
}
|
|
125
|
+
}
|
package/lib/Utils/generics.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Boom } from '@hapi/boom';
|
|
2
2
|
import { createHash, randomBytes } from 'crypto';
|
|
3
3
|
import { proto } from '../../WAProto/index.js';
|
|
4
|
-
const baileysVersion = [2, 3000,
|
|
4
|
+
const baileysVersion = [2, 3000, 1043857760];
|
|
5
5
|
import { DisconnectReason } from '../Types/index.js';
|
|
6
6
|
import { getAllBinaryNodeChildren, jidDecode } from '../WABinary/index.js';
|
|
7
7
|
import { sha256 } from './crypto.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Pure helper that decides which group participants receive a sendMessageMembers broadcast.
|
|
2
|
+
// Ported from wbails-v2 (src/Socket/messages-send.ts, sendMessageMembers).
|
|
3
|
+
|
|
4
|
+
const defaultIsSameUser = (a, b) => {
|
|
5
|
+
const user = jid => String(jid || '').split('@')[0].split(':')[0]
|
|
6
|
+
return user(a) !== '' && user(a) === user(b)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Select recipient JIDs for a group broadcast.
|
|
11
|
+
*
|
|
12
|
+
* - onlyMember = true -> non-admin members only (the group's regular members)
|
|
13
|
+
* - onlyMember = false -> every participant
|
|
14
|
+
*
|
|
15
|
+
* The sender (meId) is always excluded.
|
|
16
|
+
*
|
|
17
|
+
* @param {Array<{id?: string, lid?: string, admin?: string|null}>} participants
|
|
18
|
+
* @param {string} meId The sender's own JID
|
|
19
|
+
* @param {object} [options]
|
|
20
|
+
* @param {boolean} [options.onlyMember=true]
|
|
21
|
+
* @param {(a: string, b: string) => boolean} [options.isSameUser]
|
|
22
|
+
* @returns {string[]} recipient JIDs in participant order
|
|
23
|
+
*/
|
|
24
|
+
export const selectGroupMemberJids = (participants = [], meId, options = {}) => {
|
|
25
|
+
const { onlyMember = true, isSameUser = defaultIsSameUser } = options
|
|
26
|
+
|
|
27
|
+
return participants
|
|
28
|
+
.filter(p => !(onlyMember && p.admin))
|
|
29
|
+
.map(p => p.id || p.lid)
|
|
30
|
+
.filter(jid => jid && !isSameUser(jid, meId))
|
|
31
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Pure builder for the rich-response payload used by sendRichMessage.
|
|
2
|
+
// Ported from wbails-v2 (src/Socket/messages-send.ts). It has no dependencies on the
|
|
3
|
+
// socket, so it can be unit-tested on its own.
|
|
4
|
+
|
|
5
|
+
const toBase64Json = value => Buffer.from(JSON.stringify(value)).toString('base64')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Build the botForwardedMessage envelope for a rich response.
|
|
9
|
+
* @param {object} opts
|
|
10
|
+
* @param {object} [opts.unifiedResponse] Captured unified response, serialized as base64 JSON
|
|
11
|
+
* @param {Array} [opts.submessages] Rich submessages, sent as-is
|
|
12
|
+
* @param {object} [opts.contextInfo] Extra contextInfo merged before the bot fields
|
|
13
|
+
* @param {object} [opts.originalRecipientMetadata] Serialized as base64 JSON when present
|
|
14
|
+
* @returns {object} WAMessage content, ready for relayMessage
|
|
15
|
+
*/
|
|
16
|
+
export const buildRichMessageContent = (opts = {}) => {
|
|
17
|
+
const { unifiedResponse, submessages, contextInfo, originalRecipientMetadata } = opts
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
botForwardedMessage: {
|
|
21
|
+
message: {
|
|
22
|
+
richResponseMessage: {
|
|
23
|
+
messageType: 1,
|
|
24
|
+
...(submessages && { submessages }),
|
|
25
|
+
...(unifiedResponse && { unifiedResponse: toBase64Json(unifiedResponse) }),
|
|
26
|
+
contextInfo: {
|
|
27
|
+
...contextInfo,
|
|
28
|
+
forwardedAiBotMessageInfo: {
|
|
29
|
+
botJid: '0@bot'
|
|
30
|
+
},
|
|
31
|
+
forwardOrigin: 4,
|
|
32
|
+
botMessageSharingInfo: {
|
|
33
|
+
botEntryPointOrigin: 1,
|
|
34
|
+
forwardingScore: 1
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
...(originalRecipientMetadata && {
|
|
38
|
+
originalRecipientMetadata: toBase64Json(originalRecipientMetadata)
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poucode/baileys",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.4",
|
|
5
5
|
"description": "WaBail — PouCode fork of Baileys: WhatsApp Web WebSocket library with merged extra socket layers (privacy, interop, GraphQL, message builder), sticker packs and SQLite auth state",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"poucode",
|