@zetagoaurum-socket/wasocket 3.0.0 → 3.2.7

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.
Files changed (94) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +67 -84
  3. package/WAProto/index.js +56886 -17506
  4. package/engine-requirements.js +10 -0
  5. package/lib/Defaults/baileys-version.json +1 -1
  6. package/lib/Defaults/index.js +50 -9
  7. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  8. package/lib/Signal/Group/ciphertext-message.js +15 -0
  9. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  10. package/lib/Signal/Group/group-session-builder.js +64 -0
  11. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  12. package/lib/Signal/Group/group_cipher.js +96 -0
  13. package/lib/Signal/Group/index.d.ts +11 -0
  14. package/lib/Signal/Group/index.js +57 -0
  15. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  16. package/lib/Signal/Group/keyhelper.js +55 -0
  17. package/lib/Signal/Group/queue-job.d.ts +1 -0
  18. package/lib/Signal/Group/queue-job.js +57 -0
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  20. package/lib/Signal/Group/sender-chain-key.js +34 -0
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  22. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  24. package/lib/Signal/Group/sender-key-message.js +69 -0
  25. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-name.js +51 -0
  27. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  28. package/lib/Signal/Group/sender-key-record.js +53 -0
  29. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  30. package/lib/Signal/Group/sender-key-state.js +99 -0
  31. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  32. package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
  33. package/lib/Signal/libsignal.js +51 -29
  34. package/lib/Socket/business.d.ts +3 -2
  35. package/lib/Socket/chats.d.ts +215 -28
  36. package/lib/Socket/chats.js +185 -70
  37. package/lib/Socket/chats.js.bak +981 -0
  38. package/lib/Socket/dugong.d.ts +254 -0
  39. package/lib/Socket/dugong.js +432 -141
  40. package/lib/Socket/groups.js +20 -23
  41. package/lib/Socket/index.js +2 -15
  42. package/lib/Socket/messages-recv.d.ts +56 -55
  43. package/lib/Socket/messages-recv.js +370 -112
  44. package/lib/Socket/messages-send.d.ts +3 -2
  45. package/lib/Socket/messages-send.js +465 -368
  46. package/lib/Socket/newsletter.js +175 -28
  47. package/lib/Socket/socket.js +203 -174
  48. package/lib/Socket/usync.d.ts +3 -3
  49. package/lib/Types/GroupMetadata.d.ts +1 -0
  50. package/lib/Types/Newsletter.d.ts +97 -86
  51. package/lib/Types/Newsletter.js +38 -32
  52. package/lib/Types/USync.d.ts +25 -0
  53. package/lib/Types/USync.js +2 -0
  54. package/lib/Utils/anti-crash.js +20 -0
  55. package/lib/Utils/auto-contact.js +74 -0
  56. package/lib/Utils/chat-utils.js +17 -3
  57. package/lib/Utils/generics.js +68 -31
  58. package/lib/Utils/generics.js.bak +433 -0
  59. package/lib/Utils/history.js +6 -1
  60. package/lib/Utils/link-preview.js +4 -2
  61. package/lib/Utils/messages-media.js +145 -57
  62. package/lib/Utils/messages.js +89 -305
  63. package/lib/Utils/signal.js +48 -46
  64. package/lib/Utils/use-multi-file-auth-state.js +45 -6
  65. package/lib/Utils/validate-connection.js +91 -65
  66. package/lib/Utils/validate-connection.js.bak +237 -0
  67. package/lib/WABinary/constants.d.ts +27 -24
  68. package/lib/WABinary/encode.js +160 -123
  69. package/lib/WABinary/generic-utils.d.ts +2 -0
  70. package/lib/WABinary/generic-utils.js +124 -36
  71. package/lib/WABinary/jid-utils.js +5 -26
  72. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  73. package/lib/index.d.ts +1 -0
  74. package/lib/index.js +9 -0
  75. package/package.json +105 -100
  76. package/WAProto/GenerateStatics.sh +0 -4
  77. package/WAProto/WAProto.proto +0 -3344
  78. package/WAProto/index.d.ts +0 -37016
  79. package/WASignalGroup/GroupProtocol.js +0 -1697
  80. package/WASignalGroup/ciphertext_message.js +0 -16
  81. package/WASignalGroup/group_cipher.js +0 -120
  82. package/WASignalGroup/group_session_builder.js +0 -46
  83. package/WASignalGroup/index.js +0 -5
  84. package/WASignalGroup/keyhelper.js +0 -21
  85. package/WASignalGroup/protobufs.js +0 -3
  86. package/WASignalGroup/queue_job.js +0 -69
  87. package/WASignalGroup/sender_chain_key.js +0 -50
  88. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  89. package/WASignalGroup/sender_key_message.js +0 -92
  90. package/WASignalGroup/sender_key_name.js +0 -70
  91. package/WASignalGroup/sender_key_record.js +0 -56
  92. package/WASignalGroup/sender_key_state.js +0 -129
  93. package/lib/WAUSync/Fall +0 -1
  94. package/lib/WAUSync/Protocols/Fal +0 -1
@@ -1,92 +1,103 @@
1
- import { proto } from '../../WAProto';
2
- export type NewsletterReactionMode = 'ALL' | 'BASIC' | 'NONE';
3
- export type NewsletterState = 'ACTIVE' | 'GEOSUSPENDED' | 'SUSPENDED';
4
- export type NewsletterVerification = 'VERIFIED' | 'UNVERIFIED';
5
- export type NewsletterMute = 'ON' | 'OFF' | 'UNDEFINED';
6
- export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER';
1
+ import { proto } from "../../WAProto"
2
+
3
+ export type NewsletterReactionMode = "ALL" | "BASIC" | "NONE"
4
+ export type NewsletterState = "ACTIVE" | "GEOSUSPENDED" | "SUSPENDED"
5
+ export type NewsletterVerification = "VERIFIED" | "UNVERIFIED"
6
+ export type NewsletterMute = "ON" | "OFF" | "UNDEFINED"
7
+ export type NewsletterViewRole = "ADMIN" | "GUEST" | "OWNER" | "SUBSCRIBER"
8
+
7
9
  export type NewsletterViewerMetadata = {
8
- mute: NewsletterMute;
9
- view_role: NewsletterViewRole;
10
- };
10
+ mute: NewsletterMute
11
+ view_role: NewsletterViewRole
12
+ }
13
+
11
14
  export type NewsletterMetadata = {
12
- /**jid of newsletter */
13
- id: string;
14
- /**state of newsletter */
15
- state: NewsletterState;
16
- /**creation timestamp of newsletter */
17
- creation_time: number;
18
- /**name of newsletter */
19
- name: string;
20
- /**timestamp of last name modification of newsletter */
21
- nameTime: number;
22
- /**description of newsletter */
23
- description: string;
24
- /**timestamp of last description modification of newsletter */
25
- descriptionTime: number;
26
- /**invite code of newsletter */
27
- invite: string;
28
- /**i dont know */
29
- handle: null;
30
- /**direct path of picture */
31
- picture: string | null;
32
- /**direct path of picture preview (lower quality) */
33
- preview: string | null;
34
- /**reaction mode of newsletter */
35
- reaction_codes?: NewsletterReactionMode;
36
- /**subscribers count of newsletter */
37
- subscribers: number;
38
- /**verification state of newsletter */
39
- verification: NewsletterVerification;
40
- /**viewer metadata */
41
- viewer_metadata: NewsletterViewerMetadata;
42
- };
43
- export type SubscriberAction = 'promote' | 'demote';
15
+ /** jid of newsletter */
16
+ id: string
17
+ /** state of newsletter */
18
+ state: NewsletterState
19
+ /** creation timestamp of newsletter */
20
+ creation_time: number
21
+ /** name of newsletter */
22
+ name: string
23
+ /** timestamp of last name modification of newsletter */
24
+ nameTime: number
25
+ /** description of newsletter */
26
+ description: string
27
+ /** timestamp of last description modification of newsletter */
28
+ descriptionTime: number
29
+ /** invite code of newsletter */
30
+ invite: string
31
+ /** direct path of picture */
32
+ picture: string | null
33
+ /** direct path of picture preview (lower quality) */
34
+ preview: string | null
35
+ /** reaction mode of newsletter */
36
+ reaction_codes?: NewsletterReactionMode
37
+ /** subscribers count of newsletter */
38
+ subscribers: number
39
+ /** verification state of newsletter */
40
+ verification: NewsletterVerification
41
+ /** viewer metadata */
42
+ viewer_metadata: NewsletterViewerMetadata
43
+ }
44
+
45
+ export type SubscriberAction = "promote" | "demote"
46
+
44
47
  export type ReactionModeUpdate = {
45
- reaction_codes: {
46
- blocked_codes: null;
47
- enabled_ts_sec: null;
48
- value: NewsletterReactionMode;
49
- };
50
- };
51
- /**only exists reaction mode update */
52
- export type NewsletterSettingsUpdate = ReactionModeUpdate;
53
- export type NewsletterReaction = {
54
- count: number;
55
- code: string;
56
- };
57
- export type NewsletterFetchedUpdate = {
58
- /**id of message in newsletter, starts from 100 */
59
- server_id: string;
60
- /**count of views in this message */
61
- views?: number;
62
- /**reactions in this message */
63
- reactions: NewsletterReaction[];
64
- /**the message, if you requested only updates, you will not receive message */
65
- message?: proto.IWebMessageInfo;
66
- };
67
- export declare enum MexOperations {
68
- PROMOTE = "NotificationNewsletterAdminPromote",
69
- DEMOTE = "NotificationNewsletterAdminDemote",
70
- UPDATE = "NotificationNewsletterUpdate"
48
+ reaction_codes: {
49
+ blocked_codes: null
50
+ enabled_ts_sec: null
51
+ value: NewsletterReactionMode
52
+ }
71
53
  }
72
- export declare enum XWAPaths {
73
- PROMOTE = "xwa2_notify_newsletter_admin_promote",
74
- DEMOTE = "xwa2_notify_newsletter_admin_demote",
75
- ADMIN_COUNT = "xwa2_newsletter_admin",
76
- CREATE = "xwa2_newsletter_create",
77
- NEWSLETTER = "xwa2_newsletter",
78
- METADATA_UPDATE = "xwa2_notify_newsletter_on_metadata_update"
54
+
55
+ /** only exists reaction mode update */
56
+ export type NewsletterSettingsUpdate = ReactionModeUpdate
57
+
58
+ export type NewsletterReaction = {
59
+ count: number
60
+ code: string
79
61
  }
80
- export declare enum QueryIds {
81
- JOB_MUTATION = "7150902998257522",
82
- METADATA = "6620195908089573",
83
- UNFOLLOW = "7238632346214362",
84
- FOLLOW = "7871414976211147",
85
- UNMUTE = "7337137176362961",
86
- MUTE = "25151904754424642",
87
- CREATE = "6996806640408138",
88
- ADMIN_COUNT = "7130823597031706",
89
- CHANGE_OWNER = "7341777602580933",
90
- DELETE = "8316537688363079",
91
- DEMOTE = "6551828931592903"
62
+
63
+ export type NewsletterFetchedUpdate = {
64
+ /** id of message in newsletter, starts from 100 */
65
+ server_id: string
66
+ /** count of views in this message */
67
+ views?: number
68
+ /** reactions in this message */
69
+ reactions: NewsletterReaction[]
70
+ /** the message, if you requested only updates, you will not receive message */
71
+ message?: proto.IWebMessageInfo
92
72
  }
73
+
74
+ export const MexOperations = {
75
+ PROMOTE: "NotificationNewsletterAdminPromote",
76
+ DEMOTE: "NotificationNewsletterAdminDemote",
77
+ UPDATE: "NotificationNewsletterUpdate"
78
+ } as const
79
+
80
+ export const XWAPaths = {
81
+ PROMOTE: "xwa2_notify_newsletter_admin_promote",
82
+ DEMOTE: "xwa2_notify_newsletter_admin_demote",
83
+ ADMIN_COUNT: "xwa2_newsletter_admin",
84
+ CREATE: "xwa2_newsletter_create",
85
+ NEWSLETTER: "xwa2_newsletter",
86
+ SUBSCRIBED: "xwa2_newsletter_subscribed",
87
+ METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
88
+ } as const
89
+
90
+ export const QueryIds = {
91
+ JOB_MUTATION: "7150902998257522",
92
+ METADATA: "6620195908089573",
93
+ UNFOLLOW: "7238632346214362",
94
+ FOLLOW: "7871414976211147",
95
+ UNMUTE: "7337137176362961",
96
+ MUTE: "25151904754424642",
97
+ CREATE: "6996806640408138",
98
+ ADMIN_COUNT: "7130823597031706",
99
+ CHANGE_OWNER: "7341777602580933",
100
+ DELETE: "8316537688363079",
101
+ DEMOTE: "6551828931592903",
102
+ SUBSCRIBED: "6388546374527196"
103
+ } as const
@@ -1,32 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryIds = exports.XWAPaths = exports.MexOperations = void 0;
4
- var MexOperations;
5
- (function (MexOperations) {
6
- MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
7
- MexOperations["DEMOTE"] = "NotificationNewsletterAdminDemote";
8
- MexOperations["UPDATE"] = "NotificationNewsletterUpdate";
9
- })(MexOperations = exports.MexOperations || (exports.MexOperations = {}));
10
- var XWAPaths;
11
- (function (XWAPaths) {
12
- XWAPaths["PROMOTE"] = "xwa2_notify_newsletter_admin_promote";
13
- XWAPaths["DEMOTE"] = "xwa2_notify_newsletter_admin_demote";
14
- XWAPaths["ADMIN_COUNT"] = "xwa2_newsletter_admin";
15
- XWAPaths["CREATE"] = "xwa2_newsletter_create";
16
- XWAPaths["NEWSLETTER"] = "xwa2_newsletter";
17
- XWAPaths["METADATA_UPDATE"] = "xwa2_notify_newsletter_on_metadata_update";
18
- })(XWAPaths = exports.XWAPaths || (exports.XWAPaths = {}));
19
- var QueryIds;
20
- (function (QueryIds) {
21
- QueryIds["JOB_MUTATION"] = "7150902998257522";
22
- QueryIds["METADATA"] = "6620195908089573";
23
- QueryIds["UNFOLLOW"] = "7238632346214362";
24
- QueryIds["FOLLOW"] = "7871414976211147";
25
- QueryIds["UNMUTE"] = "7337137176362961";
26
- QueryIds["MUTE"] = "25151904754424642";
27
- QueryIds["CREATE"] = "6996806640408138";
28
- QueryIds["ADMIN_COUNT"] = "7130823597031706";
29
- QueryIds["CHANGE_OWNER"] = "7341777602580933";
30
- QueryIds["DELETE"] = "8316537688363079";
31
- QueryIds["DEMOTE"] = "6551828931592903";
32
- })(QueryIds = exports.QueryIds || (exports.QueryIds = {}));
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const MexOperations = {
6
+ PROMOTE: "NotificationNewsletterAdminPromote",
7
+ DEMOTE: "NotificationNewsletterAdminDemote",
8
+ UPDATE: "NotificationNewsletterUpdate"
9
+ }
10
+
11
+ const XWAPaths = {
12
+ PROMOTE: "xwa2_notify_newsletter_admin_promote",
13
+ DEMOTE: "xwa2_notify_newsletter_admin_demote",
14
+ ADMIN_COUNT: "xwa2_newsletter_admin",
15
+ CREATE: "xwa2_newsletter_create",
16
+ NEWSLETTER: "xwa2_newsletter",
17
+ SUBSCRIBED: "xwa2_newsletter_subscribed",
18
+ METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
19
+ }
20
+
21
+ const QueryIds = {
22
+ JOB_MUTATION: "7150902998257522",
23
+ METADATA: "6620195908089573",
24
+ UNFOLLOW: "7238632346214362",
25
+ FOLLOW: "7871414976211147",
26
+ UNMUTE: "7337137176362961",
27
+ MUTE: "25151904754424642",
28
+ CREATE: "6996806640408138",
29
+ ADMIN_COUNT: "7130823597031706",
30
+ CHANGE_OWNER: "7341777602580933",
31
+ DELETE: "8316537688363079",
32
+ DEMOTE: "6551828931592903",
33
+ SUBSCRIBED: "6388546374527196"
34
+ }
35
+
36
+ exports.MexOperations = MexOperations
37
+ exports.XWAPaths = XWAPaths
38
+ exports.QueryIds = QueryIds
@@ -0,0 +1,25 @@
1
+ import { BinaryNode } from '../WABinary';
2
+ import { USyncUser } from '../WAUSync';
3
+ /**
4
+ * Defines the interface for a USyncQuery protocol
5
+ */
6
+ export interface USyncQueryProtocol {
7
+ /**
8
+ * The name of the protocol
9
+ */
10
+ name: string;
11
+ /**
12
+ * Defines what goes inside the query part of a USyncQuery
13
+ */
14
+ getQueryElement: () => BinaryNode;
15
+ /**
16
+ * Defines what goes inside the user part of a USyncQuery
17
+ */
18
+ getUserElement: (user: USyncUser) => BinaryNode | null;
19
+ /**
20
+ * Parse the result of the query
21
+ * @param data Data from the result
22
+ * @returns Whatever the protocol is supposed to return
23
+ */
24
+ parser: (data: BinaryNode) => unknown;
25
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,20 @@
1
+ module.exports = () => {
2
+ const logger = require('./logger').default.child({ class: 'anti-crash' });
3
+
4
+ const chalk = require('chalk');
5
+
6
+ process.on('uncaughtException', (err) => {
7
+ console.log(chalk.red.bold('[\u274c ANTI-KILL] Uncaught Exception Detected!'));
8
+ console.log(chalk.yellow(`Reason: ${err.message}`));
9
+ console.log(chalk.gray(err.stack));
10
+ // Prevent exit
11
+ });
12
+
13
+ process.on('unhandledRejection', (reason, promise) => {
14
+ console.log(chalk.red.bold('[\u274c ANTI-KILL] Unhandled Rejection!'));
15
+ console.log(chalk.yellow(`Reason: ${reason}`));
16
+ // Prevent exit
17
+ });
18
+
19
+ console.log(chalk.cyan.bold('[ANTI-KILL] Protection Active \u2705'));
20
+ };
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContactManager = void 0;
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const CONTACT_FILE = path.join(process.cwd(), 'user_contact.json');
7
+ const COUNTER_FILE = path.join(process.cwd(), 'counter.json');
8
+ class ContactManager {
9
+ constructor() {
10
+ this.cache = new Set();
11
+ this.counter = 1;
12
+ this.contacts = {};
13
+ this.init();
14
+ }
15
+ init() {
16
+ if (!fs.existsSync(CONTACT_FILE)) {
17
+ fs.writeFileSync(CONTACT_FILE, JSON.stringify({}, null, 2));
18
+ }
19
+ if (!fs.existsSync(COUNTER_FILE)) {
20
+ fs.writeFileSync(COUNTER_FILE, JSON.stringify({ count: 1 }, null, 2));
21
+ }
22
+ try {
23
+ this.contacts = JSON.parse(fs.readFileSync(CONTACT_FILE, 'utf-8'));
24
+ const counterData = JSON.parse(fs.readFileSync(COUNTER_FILE, 'utf-8'));
25
+ this.counter = counterData.count || 1;
26
+ Object.keys(this.contacts).forEach(jid => this.cache.add(jid));
27
+ }
28
+ catch (error) {
29
+ console.error('[ContactManager] Error loading data:', error);
30
+ }
31
+ }
32
+ _save() {
33
+ try {
34
+ fs.writeFileSync(CONTACT_FILE, JSON.stringify(this.contacts, null, 2));
35
+ fs.writeFileSync(COUNTER_FILE, JSON.stringify({ count: this.counter }, null, 2));
36
+ }
37
+ catch (error) {
38
+ console.error('[ContactManager] Error saving data:', error);
39
+ }
40
+ }
41
+ checkAndSave(jid, sock) {
42
+ if (!jid || jid.includes('@g.us') || jid === 'status@broadcast')
43
+ return;
44
+ const normalizedJid = jid.split('@')[0] + '@s.whatsapp.net';
45
+
46
+ // Skip if already in cache
47
+ if (this.cache.has(normalizedJid)) {
48
+ return;
49
+ }
50
+
51
+ // Logic to skip owner and bot number (assuming they are in contacts or injected config)
52
+ // For now, we just rely on the existence check.
53
+ // If sock is provided, we can also check if it's the bot's own ID
54
+ if (sock && sock.user && sock.user.id) {
55
+ const botId = sock.user.id.split(':')[0] + '@s.whatsapp.net';
56
+ if (normalizedJid === botId) return;
57
+ }
58
+
59
+ const codename = `ZetaGo-user${this.counter}`;
60
+ this.contacts[normalizedJid] = {
61
+ id: normalizedJid,
62
+ name: codename,
63
+ savedAt: new Date().toISOString()
64
+ };
65
+ this.cache.add(normalizedJid);
66
+ this.counter++;
67
+ this._save();
68
+ console.log(`[AutoSafe] Saved new contact: ${normalizedJid} as ${codename}`);
69
+
70
+ // Optional: If we had access to full sock here, we could try to push a sync
71
+ // But the requirement is mainly about the internal list and counter.
72
+ }
73
+ }
74
+ exports.ContactManager = new ContactManager();
@@ -503,8 +503,17 @@ const chatModificationToAppPatch = (mod, jid) => {
503
503
  apiVersion: 3,
504
504
  operation: OP.SET,
505
505
  };
506
- }
507
- else if ('removeChatLabel' in mod) {
506
+ } else if ("contact" in mod) {
507
+ patch = {
508
+ syncAction: {
509
+ contactAction: mod.contact || {}
510
+ },
511
+ index: ["contact", jid],
512
+ type: "critical_unblock_low",
513
+ apiVersion: 2,
514
+ operation: mod.contact ? OP.SET : OP.REMOVE
515
+ };
516
+ } else if ('removeChatLabel' in mod) {
508
517
  patch = {
509
518
  syncAction: {
510
519
  labelAssociationAction: {
@@ -633,7 +642,12 @@ const processSyncAction = (syncAction, ev, me, initialSyncOpts, logger) => {
633
642
  });
634
643
  }
635
644
  else if (action === null || action === void 0 ? void 0 : action.contactAction) {
636
- ev.emit('contacts.upsert', [{ id, name: action.contactAction.fullName }]);
645
+ ev.emit('contacts.upsert', [{
646
+ id: id,
647
+ name: action.contactAction.fullName,
648
+ lid: action.contactAction.lidJid || undefined,
649
+ jid: (0, WABinary_1.isJidUser)(id) ? id : undefined
650
+ }]);
637
651
  }
638
652
  else if (action === null || action === void 0 ? void 0 : action.pushNameSetting) {
639
653
  const name = (_b = action === null || action === void 0 ? void 0 : action.pushNameSetting) === null || _b === void 0 ? void 0 : _b.name;
@@ -8,10 +8,12 @@ const boom_1 = require("@hapi/boom");
8
8
  const axios_1 = __importDefault(require("axios"));
9
9
  const crypto_1 = require("crypto");
10
10
  const os_1 = require("os");
11
+ const fetch_1 = require("node-fetch")
11
12
  const WAProto_1 = require("../../WAProto");
12
13
  const baileys_version_json_1 = require("../Defaults/baileys-version.json");
13
14
  const Types_1 = require("../Types");
14
15
  const WABinary_1 = require("../WABinary");
16
+ const baileysVersion = [2, 3000, 1027934701]
15
17
  const PLATFORM_MAP = {
16
18
  'aix': 'AIX',
17
19
  'darwin': 'Mac OS',
@@ -19,16 +21,23 @@ const PLATFORM_MAP = {
19
21
  'android': 'Android',
20
22
  'freebsd': 'FreeBSD',
21
23
  'openbsd': 'OpenBSD',
22
- 'sunos': 'Solaris'
24
+ 'sunos': 'Solaris',
25
+ 'linux': undefined,
26
+ 'haiku': undefined,
27
+ 'cygwin': undefined,
28
+ 'netbsd': undefined
23
29
  };
24
- exports.Browsers = {
30
+
31
+ const Browsers = {
32
+ iOS: (browser) => ["ios", browser, "18.2"],
25
33
  ubuntu: (browser) => ['Ubuntu', browser, '22.04.4'],
26
34
  macOS: (browser) => ['Mac OS', browser, '14.4.1'],
27
35
  baileys: (browser) => ['Baileys', browser, '6.5.0'],
28
- windows: (browser) => ['Windows', browser, '10.0.22631'],
29
- appropriate: (browser) => [PLATFORM_MAP[(0, os_1.platform)()] || 'Ubuntu', browser, (0, os_1.release)()]
36
+ windows: (browser) => ['Windows', browser, '10.0.22631']
30
37
  };
31
38
 
39
+ exports.Browsers = Browsers
40
+
32
41
  const getPlatformId = (browser) => {
33
42
  const platformType = WAProto_1.proto.DeviceProps.PlatformType[browser.toUpperCase()];
34
43
  return platformType ? platformType.toString() : '1'; //chrome
@@ -172,7 +181,7 @@ const generateMessageIDV2 = (userId) => {
172
181
  };
173
182
  exports.generateMessageIDV2 = generateMessageIDV2;
174
183
  // generate a random ID to attach to a message
175
- const generateMessageID = () => 'Laurine-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
184
+ const generateMessageID = () => 'ILSYM-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
176
185
  exports.generateMessageID = generateMessageID;
177
186
  function bindWaitForEvent(ev, event) {
178
187
  return async (check, timeoutMs) => {
@@ -215,12 +224,61 @@ const printQRIfNecessaryListener = (ev, logger) => {
215
224
  });
216
225
  };
217
226
  exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
227
+ /**
228
+ * utility that fetches latest baileys version from the master branch.
229
+ * Use to ensure your WA connection is always on the latest version
230
+ */
231
+ const fetchLatestWaWebVersion = async (options = {}) => {
232
+ try {
233
+ const defaultHeaders = {
234
+ 'User-Agent':
235
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
236
+ 'Accept': '*/*'
237
+ }
238
+
239
+ const headers = { ...defaultHeaders, ...options.headers }
240
+
241
+ const response = await fetch_1('https://web.whatsapp.com/sw.js', {
242
+ method: 'GET',
243
+ headers
244
+ })
245
+
246
+ if (!response.ok) {
247
+ throw new Error(`Failed to fetch sw.js: ${response.status} ${response.statusText}`)
248
+ }
249
+
250
+ const data = await response.text()
251
+ const regex = /"client_revision":\s*(\d+)/ // regex cukup begini untuk Node
252
+ const match = data.match(regex)
253
+
254
+ if (!match || !match[1]) {
255
+ return {
256
+ version: baileysVersion,
257
+ isLatest: false,
258
+ error: { message: 'Client revision not found' }
259
+ }
260
+ }
261
+
262
+ const clientRevision = match[1]
263
+ return {
264
+ version: [2, 3000, +clientRevision],
265
+ isLatest: true
266
+ }
267
+ } catch (error) {
268
+ return {
269
+ version: baileysVersion,
270
+ isLatest: false,
271
+ error
272
+ }
273
+ }
274
+ }
275
+ exports.fetchLatestWaWebVersion = fetchLatestWaWebVersion;
218
276
  /**
219
277
  * utility that fetches latest baileys version from the master branch.
220
278
  * Use to ensure your WA connection is always on the latest version
221
279
  */
222
280
  const fetchLatestBaileysVersion = async (options = {}) => {
223
- const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/baileys-version.json';
281
+ const URL = 'https://raw.githubusercontent.com/kiuur/bails/master/src/Defaults/baileys-version.json';
224
282
  try {
225
283
  const result = await axios_1.default.get(URL, {
226
284
  ...options,
@@ -240,31 +298,6 @@ const fetchLatestBaileysVersion = async (options = {}) => {
240
298
  }
241
299
  };
242
300
  exports.fetchLatestBaileysVersion = fetchLatestBaileysVersion;
243
- /**
244
- * A utility that fetches the latest web version of whatsapp.
245
- * Use to ensure your WA connection is always on the latest version
246
- */
247
- const fetchLatestWaWebVersion = async (options) => {
248
- try {
249
- const result = await axios_1.default.get('https://web.whatsapp.com/check-update?version=1&platform=web', {
250
- ...options,
251
- responseType: 'json'
252
- });
253
- const version = result.data.currentVersion.split('.');
254
- return {
255
- version: [+version[0], +version[1], +version[2]],
256
- isLatest: true
257
- };
258
- }
259
- catch (error) {
260
- return {
261
- version: baileys_version_json_1.version,
262
- isLatest: false,
263
- error
264
- };
265
- }
266
- };
267
- exports.fetchLatestWaWebVersion = fetchLatestWaWebVersion;
268
301
  /** unique message tag prefix for MD clients */
269
302
  const generateMdTagPrefix = () => {
270
303
  const bytes = (0, crypto_1.randomBytes)(4);
@@ -389,3 +422,7 @@ function bytesToCrockford(buffer) {
389
422
  return crockford.join('');
390
423
  }
391
424
  exports.bytesToCrockford = bytesToCrockford;
425
+ const encodeNewsletterMessage = (message) => {
426
+ return WAProto_1.proto.Message.encode(message).finish()
427
+ }
428
+ exports.encodeNewsletterMessage = encodeNewsletterMessage;