aunubaileys 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/README.md CHANGED
@@ -59,6 +59,13 @@ sock.ev.on('creds.update', saveCreds)
59
59
  Everything else is pure upstream. When upstream moves, we rebase the patch layer — that discipline is the whole point of this fork.
60
60
 
61
61
 
62
+
63
+ ### 🆕 What's new in 1.0.3 / Baru di 1.0.3
64
+
65
+ - ⚡ **Modern core** — latest WA version `2.3000.1035194821`, 812 pre-keys, tuned WebSocket (no per-message deflate, 100 MB payload).
66
+ - 🧩 **More message types** — quiz polls (newsletter), poll result snapshots, poll updates, payment invites, order messages.
67
+ - 🛠️ **Developer API** — `sock.aunuHandler` (send/reply/react helpers), `fetchAccountReachoutTimelock()`, `fetchNewChatMessageCap()`, `registerSocketEndHandler()`, `newsletterId()` helper.
68
+
62
69
  ### 🆕 What's new in 1.0.2 / Baru di 1.0.2
63
70
 
64
71
  - 📦 **Sticker packs** — send full sticker packs with `stickerPack` (cover + up to 60 stickers).
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": [2, 3000, 1043857760]
2
+ "version": [2, 3000, 1035194821]
3
3
  }
@@ -93,7 +93,7 @@ export const MEDIA_HKDF_KEY_MAPPING = {
93
93
  };
94
94
  export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
95
95
  export const MIN_PREKEY_COUNT = 5;
96
- export const INITIAL_PREKEY_COUNT = 30;
96
+ export const INITIAL_PREKEY_COUNT = 812;
97
97
  export const DEFAULT_CACHE_TTLS = {
98
98
  SIGNAL_STORE: 5 * 60, // 5 minutes
99
99
  MSG_RETRY: 60 * 60, // 1 hour
@@ -23,6 +23,9 @@ export class WebSocketClient extends AbstractSocketClient {
23
23
  return;
24
24
  }
25
25
  this.socket = new WebSocket(this.url, {
26
+ // AunuBaileys: stabilitas WS — tanpa kompresi per-message, payload besar aman
27
+ perMessageDeflate: false,
28
+ maxPayload: 100 * 1024 * 1024,
26
29
  origin: DEFAULT_ORIGIN,
27
30
  headers: this.config.options?.headers,
28
31
  handshakeTimeout: this.config.connectTimeoutMs,
@@ -1,5 +1,6 @@
1
1
  import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
2
2
  import { makeCommunitiesSocket } from './communities.js';
3
+ import { AunuHandler } from '../Utils/aunu-handler.js';
3
4
  // export the last socket layer
4
5
  const makeWASocket = (config) => {
5
6
  const newConfig = {
@@ -11,7 +12,9 @@ const makeWASocket = (config) => {
11
12
  if (config.shouldSyncHistoryMessage === undefined) {
12
13
  newConfig.shouldSyncHistoryMessage = () => !!newConfig.syncFullHistory;
13
14
  }
14
- return makeCommunitiesSocket(newConfig);
15
+ const sock = makeCommunitiesSocket(newConfig);
16
+ sock.aunuHandler = new AunuHandler(sock);
17
+ return sock;
15
18
  };
16
19
  export default makeWASocket;
17
20
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,4 @@
1
+ import Boom from '@hapi/boom';
1
2
  import { QueryIds, XWAPaths } from '../Types/index.js';
2
3
  import { generateProfilePicture } from '../Utils/messages-media.js';
3
4
  import { getBinaryNodeChild } from '../WABinary/index.js';
@@ -49,6 +50,13 @@ export const makeNewsletterSocket = (sock) => {
49
50
  };
50
51
  return {
51
52
  ...sock,
53
+ // AunuBaileys: ambil ID numerik dari JID newsletter
54
+ newsletterId: (jid) => {
55
+ if (!jid || !jid.endsWith('@newsletter')) {
56
+ throw new Boom('Invalid newsletter jid', { statusCode: 400 });
57
+ }
58
+ return jid.split('@')[0];
59
+ },
52
60
  newsletterCreate: async (name, description) => {
53
61
  const variables = {
54
62
  input: {
@@ -4,7 +4,9 @@ import { URL } from 'url';
4
4
  import { promisify } from 'util';
5
5
  import { proto } from '../../WAProto/index.js';
6
6
  import { DEF_CALLBACK_PREFIX, DEF_TAG_PREFIX, INITIAL_PREKEY_COUNT, MIN_PREKEY_COUNT, NOISE_WA_HEADER } from '../Defaults/index.js';
7
- import { DisconnectReason } from '../Types/index.js';
7
+ import { DisconnectReason } from '../Types/index.js'
8
+ import { executeWMexQuery } from './mex.js';
9
+ import { QueryIds, XWAPaths } from '../Types/index.js';
8
10
  import { addTransactionCapability, aesEncryptCTR, bindWaitForConnectionUpdate, bytesToCrockford, configureSuccessfulPairing, Curve, derivePairingCodeKey, generateLoginNode, generateMdTagPrefix, generateRegistrationNode, getCodeFromWSError, getErrorCodeFromStreamError, getNextPreKeysNode, getPlatformId, makeEventBuffer, makeNoiseHandler, promiseTimeout } from '../Utils/index.js';
9
11
  import { assertNodeErrorFree, binaryNodeToString, encodeBinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidEncode, S_WHATSAPP_NET } from '../WABinary/index.js';
10
12
  import { WebSocketClient } from './Client/index.js';
@@ -242,6 +244,11 @@ export const makeSocket = (config) => {
242
244
  }
243
245
  });
244
246
  };
247
+ // AunuBaileys: socket end handlers (pola v7) + fetch Mex (dari @itsliaaa/baileys)
248
+ const socketEndHandlers = [];
249
+ const registerSocketEndHandler = (handler) => {
250
+ socketEndHandlers.push(handler);
251
+ };
245
252
  const end = (error) => {
246
253
  if (closed) {
247
254
  logger.trace({ trace: error?.stack }, 'connection already closed');
@@ -267,6 +274,12 @@ export const makeSocket = (config) => {
267
274
  date: new Date()
268
275
  }
269
276
  });
277
+ for (const handler of socketEndHandlers) {
278
+ try {
279
+ handler();
280
+ }
281
+ catch { }
282
+ }
270
283
  ev.removeAllListeners('connection.update');
271
284
  };
272
285
  const waitForSocketOpen = async () => {
@@ -577,6 +590,21 @@ export const makeSocket = (config) => {
577
590
  }
578
591
  Object.assign(creds, update);
579
592
  });
593
+ const fetchAccountReachoutTimelock = async () => {
594
+ const queryResult = await executeWMexQuery({}, QueryIds.REACHOUT_TIMELOCK, XWAPaths.xwa2_fetch_account_reachout_timelock, query, generateMessageTag);
595
+ const result = {
596
+ isActive: !!queryResult?.is_active,
597
+ timeEnforcementEnds: queryResult?.time_enforcement_ends && queryResult?.time_enforcement_ends !== '0'
598
+ ? new Date(parseInt(queryResult.time_enforcement_ends, 10) * 1000)
599
+ : undefined,
600
+ enforcementType: queryResult?.enforcement_type ?? 'DEFAULT'
601
+ };
602
+ ev.emit('connection.update', { reachoutTimeLock: result });
603
+ return result;
604
+ };
605
+ const fetchNewChatMessageCap = async () => {
606
+ return executeWMexQuery({ input: { type: 'INDIVIDUAL_NEW_CHAT_MSG' } }, QueryIds.MESSAGE_CAPPING_INFO, XWAPaths.xwa2_message_capping_info, query, generateMessageTag);
607
+ };
580
608
  return {
581
609
  type: 'md',
582
610
  ws,
@@ -594,6 +622,9 @@ export const makeSocket = (config) => {
594
622
  sendNode,
595
623
  logout,
596
624
  end,
625
+ registerSocketEndHandler,
626
+ fetchAccountReachoutTimelock,
627
+ fetchNewChatMessageCap,
597
628
  onUnexpectedError,
598
629
  uploadPreKeys,
599
630
  uploadPreKeysToServerIfRequired,
@@ -12,6 +12,8 @@ export var XWAPaths;
12
12
  XWAPaths["xwa2_newsletter_change_owner"] = "xwa2_newsletter_change_owner";
13
13
  XWAPaths["xwa2_newsletter_demote"] = "xwa2_newsletter_demote";
14
14
  XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
15
+ XWAPaths["xwa2_fetch_account_reachout_timelock"] = "xwa2_fetch_account_reachout_timelock";
16
+ XWAPaths["xwa2_message_capping_info"] = "xwa2_message_capping_info";
15
17
  })(XWAPaths || (XWAPaths = {}));
16
18
  export var QueryIds;
17
19
  (function (QueryIds) {
@@ -27,5 +29,7 @@ export var QueryIds;
27
29
  QueryIds["CHANGE_OWNER"] = "7341777602580933";
28
30
  QueryIds["DEMOTE"] = "6551828931592903";
29
31
  QueryIds["DELETE"] = "30062808666639665";
32
+ QueryIds["REACHOUT_TIMELOCK"] = "23983697327930364";
33
+ QueryIds["MESSAGE_CAPPING_INFO"] = "24503548349331633";
30
34
  })(QueryIds || (QueryIds = {}));
31
35
  //# sourceMappingURL=Newsletter.js.map
@@ -0,0 +1,11 @@
1
+ import type { AnyMessageContent, MiscMessageGenerationOptions, WAMessage, WASocket } from '../Types';
2
+ export declare class AunuHandler {
3
+ sock: WASocket;
4
+ readonly name: string;
5
+ readonly brand: string;
6
+ constructor(sock: WASocket);
7
+ send(jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions): Promise<WAMessage | undefined>;
8
+ reply(jid: string, content: AnyMessageContent, quoted: WAMessage, options?: MiscMessageGenerationOptions): Promise<WAMessage | undefined>;
9
+ react(jid: string, emoji: string, key: WAMessage['key']): Promise<WAMessage | undefined>;
10
+ newsletterId(jid: string): string;
11
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * AunuHandler — lapisan kenyamanan khas AunuBaileys di atas socket.
3
+ * Diekspos sebagai `sock.aunuHandler` dan diekspor sebagai kelas dari paket.
4
+ */
5
+ export class AunuHandler {
6
+ constructor(sock) {
7
+ this.sock = sock;
8
+ this.name = 'AunuBaileys';
9
+ this.brand = 'AunuCore Creative Network';
10
+ }
11
+ /** Kirim pesan apa pun (delegate ke sock.sendMessage). */
12
+ async send(jid, content, options) {
13
+ return this.sock.sendMessage(jid, content, options);
14
+ }
15
+ /** Balas sebuah pesan (quote). */
16
+ async reply(jid, content, quoted, options = {}) {
17
+ return this.sock.sendMessage(jid, content, { ...options, quoted });
18
+ }
19
+ /** Beri reaksi emoji ke sebuah pesan. */
20
+ async react(jid, emoji, key) {
21
+ return this.sock.sendMessage(jid, { react: { text: emoji, key } });
22
+ }
23
+ /** ID numerik dari JID newsletter. */
24
+ newsletterId(jid) {
25
+ return this.sock.newsletterId(jid);
26
+ }
27
+ }
@@ -615,6 +615,23 @@ export const generateWAMessageContent = async (message, options) => {
615
615
  // poll v2 is for community announcement groups (single select and multiple)
616
616
  m.pollCreationMessageV2 = pollCreationMessage;
617
617
  }
618
+ else if (message.poll.pollType === 1) {
619
+ // AunuBaileys: kuis (dari @itsliaaa/baileys) — untuk newsletter
620
+ if (!message.poll.correctAnswer) {
621
+ throw new Boom('No "correctAnswer" provided for quiz', { statusCode: 400 });
622
+ }
623
+ // proto 6.7.24: V5 adalah FutureProofMessage — konten dibungkus di .message
624
+ m.pollCreationMessageV5 = {
625
+ message: {
626
+ pollCreationMessage: {
627
+ ...pollCreationMessage,
628
+ correctAnswer: { optionName: message.poll.correctAnswer.toString() },
629
+ pollType: 1,
630
+ selectableOptionsCount: 1
631
+ }
632
+ }
633
+ };
634
+ }
618
635
  else {
619
636
  if (message.poll.selectableCount === 1) {
620
637
  //poll v3 is for single select polls
@@ -626,6 +643,62 @@ export const generateWAMessageContent = async (message, options) => {
626
643
  }
627
644
  }
628
645
  }
646
+ else if ('pollResult' in message) {
647
+ // AunuBaileys: poll result snapshot (dari @itsliaaa/baileys)
648
+ const pollResultSnapshotMessage = {
649
+ name: message.pollResult.name,
650
+ pollVotes: message.pollResult.votes.map(vote => ({
651
+ optionName: vote.name,
652
+ optionVoteCount: parseInt(vote.voteCount)
653
+ }))
654
+ };
655
+ if (message.pollResult.pollType === 1) {
656
+ pollResultSnapshotMessage.pollType = proto.Message.PollCreationMessage.PollType.QUIZ;
657
+ m.pollResultSnapshotMessageV3 = pollResultSnapshotMessage;
658
+ }
659
+ else {
660
+ pollResultSnapshotMessage.pollType = proto.Message.PollCreationMessage.PollType.POLL;
661
+ m.pollResultSnapshotMessage = pollResultSnapshotMessage;
662
+ }
663
+ }
664
+ else if ('pollUpdate' in message) {
665
+ if (!message.pollUpdate.key) {
666
+ throw new Boom('Message key is required', { statusCode: 400 });
667
+ }
668
+ if (!message.pollUpdate.vote) {
669
+ throw new Boom('Encrypted vote payload is required', { statusCode: 400 });
670
+ }
671
+ m.pollUpdateMessage = {
672
+ metadata: message.pollUpdate.metadata,
673
+ pollCreationMessageKey: message.pollUpdate.key,
674
+ senderTimestampMs: Date.now(),
675
+ vote: message.pollUpdate.vote
676
+ };
677
+ }
678
+ else if ('paymentInviteServiceType' in message) {
679
+ // AunuBaileys: payment invite (dari @itsliaaa/baileys)
680
+ m.paymentInviteMessage = {
681
+ expiryTimestamp: Date.now(),
682
+ serviceType: message.paymentInviteServiceType
683
+ };
684
+ }
685
+ else if ('orderText' in message) {
686
+ // AunuBaileys: order message (dari @itsliaaa/baileys)
687
+ if (message.thumbnail !== undefined && !Buffer.isBuffer(message.thumbnail)) {
688
+ throw new Boom('Must provide thumbnail buffer in order message', { statusCode: 400 });
689
+ }
690
+ m.orderMessage = {
691
+ itemCount: message.itemCount || 1,
692
+ messageVersion: 1,
693
+ orderTitle: message.orderTitle || 'AunuBaileys',
694
+ status: proto.Message.OrderMessage.OrderStatus.INQUIRY,
695
+ surface: proto.Message.OrderMessage.OrderSurface.CATALOG,
696
+ totalAmount1000: message.totalAmount1000 || 1000,
697
+ totalCurrencyCode: message.currency || 'IDR',
698
+ thumbnail: message.thumbnail,
699
+ message: message.orderText
700
+ };
701
+ }
629
702
  else if ('sharePhoneNumber' in message) {
630
703
  m.protocolMessage = {
631
704
  type: proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER
package/lib/index.d.ts CHANGED
@@ -13,3 +13,4 @@ export default makeWASocket;
13
13
  export * from './Store/index.js';
14
14
  export { processedMessages, initInMemoryKeyStore } from './Utils/fork-compat.js';
15
15
  export { PHONENUMBER_MCC } from './Utils/phonenumber-mcc.js';
16
+ export * from './Utils/aunu-handler';
package/lib/index.js CHANGED
@@ -12,3 +12,4 @@ export default makeWASocket;
12
12
  export * from './Store/index.js';
13
13
  export { processedMessages, initInMemoryKeyStore } from './Utils/fork-compat.js';
14
14
  export { PHONENUMBER_MCC } from './Utils/phonenumber-mcc.js';
15
+ export * from './Utils/aunu-handler.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aunubaileys",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "description": "AunuBaileys \u2014 a WhatsApp Web API for bots that never sleep. Full upstream power with the beloved in-memory store restored and pairing that just works. Forged by AunuCore.",
6
6
  "keywords": [
7
7
  "whatsapp",