@sanzoffc/baileys 3.0.1 → 3.0.2

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 (114) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/WAProto.proto +769 -233
  3. package/WAProto/index.js +65801 -141371
  4. package/lib/Defaults/index.js +117 -114
  5. package/lib/Defaults/index.js.bak +123 -0
  6. package/lib/KeyDB/BinarySearch.js +20 -0
  7. package/lib/KeyDB/KeyedDB.js +167 -0
  8. package/lib/KeyDB/index.js +4 -0
  9. package/lib/Signal/Group/ciphertext-message.js +12 -14
  10. package/lib/Signal/Group/group-session-builder.js +10 -42
  11. package/lib/Signal/Group/group_cipher.js +75 -87
  12. package/lib/Signal/Group/index.js +13 -57
  13. package/lib/Signal/Group/keyhelper.js +17 -52
  14. package/lib/Signal/Group/sender-chain-key.js +27 -33
  15. package/lib/Signal/Group/sender-key-distribution-message.js +62 -63
  16. package/lib/Signal/Group/sender-key-message.js +65 -66
  17. package/lib/Signal/Group/sender-key-name.js +45 -44
  18. package/lib/Signal/Group/sender-key-record.js +39 -49
  19. package/lib/Signal/Group/sender-key-state.js +80 -93
  20. package/lib/Signal/Group/sender-message-key.js +27 -28
  21. package/lib/Signal/libsignal.js +313 -163
  22. package/lib/Signal/lid-mapping.js +155 -0
  23. package/lib/Socket/Client/index.js +4 -18
  24. package/lib/Socket/Client/types.js +12 -12
  25. package/lib/Socket/Client/websocket.js +51 -71
  26. package/lib/Socket/Client/websocket.js.bak +53 -0
  27. package/lib/Socket/business.js +359 -242
  28. package/lib/Socket/chats.js +858 -945
  29. package/lib/Socket/communities.js +413 -0
  30. package/lib/Socket/groups.js +304 -324
  31. package/lib/Socket/index.js +15 -9
  32. package/lib/Socket/messages-recv.js +1105 -1046
  33. package/lib/Socket/messages-send.js +615 -389
  34. package/lib/Socket/mex.js +45 -0
  35. package/lib/Socket/newsletter.js +224 -227
  36. package/lib/Socket/socket.js +795 -621
  37. package/lib/Store/index.js +6 -8
  38. package/lib/Store/make-cache-manager-store.js +75 -0
  39. package/lib/Store/make-in-memory-store.js +286 -435
  40. package/lib/Store/make-ordered-dictionary.js +77 -79
  41. package/lib/Store/object-repository.js +24 -26
  42. package/lib/Types/Auth.js +3 -2
  43. package/lib/Types/Bussines.js +3 -0
  44. package/lib/Types/Call.js +3 -2
  45. package/lib/Types/Chat.js +9 -4
  46. package/lib/Types/Contact.js +3 -2
  47. package/lib/Types/Events.js +3 -2
  48. package/lib/Types/GroupMetadata.js +3 -2
  49. package/lib/Types/Label.js +24 -26
  50. package/lib/Types/LabelAssociation.js +6 -8
  51. package/lib/Types/Message.js +12 -7
  52. package/lib/Types/Newsletter.js +32 -17
  53. package/lib/Types/Newsletter.js.bak +33 -0
  54. package/lib/Types/Product.js +3 -2
  55. package/lib/Types/Signal.js +3 -2
  56. package/lib/Types/Socket.js +4 -2
  57. package/lib/Types/State.js +11 -2
  58. package/lib/Types/USync.js +3 -2
  59. package/lib/Types/index.js +27 -41
  60. package/lib/Utils/auth-utils.js +211 -191
  61. package/lib/Utils/baileys-event-stream.js +44 -0
  62. package/lib/Utils/browser-utils.js +21 -31
  63. package/lib/Utils/business.js +213 -214
  64. package/lib/Utils/chat-utils.js +711 -689
  65. package/lib/Utils/crypto.js +112 -175
  66. package/lib/Utils/decode-wa-message.js +254 -194
  67. package/lib/Utils/event-buffer.js +510 -500
  68. package/lib/Utils/generics.js +318 -430
  69. package/lib/Utils/history.js +83 -90
  70. package/lib/Utils/index.js +21 -35
  71. package/lib/Utils/link-preview.js +71 -116
  72. package/lib/Utils/logger.js +5 -7
  73. package/lib/Utils/lt-hash.js +40 -46
  74. package/lib/Utils/make-mutex.js +34 -41
  75. package/lib/Utils/message-retry-manager.js +33 -48
  76. package/lib/Utils/messages-media.js +573 -825
  77. package/lib/Utils/messages.js +349 -489
  78. package/lib/Utils/noise-handler.js +138 -144
  79. package/lib/Utils/pre-key-manager.js +85 -0
  80. package/lib/Utils/process-message.js +321 -384
  81. package/lib/Utils/signal.js +147 -139
  82. package/lib/Utils/use-multi-file-auth-state.js +95 -109
  83. package/lib/Utils/validate-connection.js +183 -212
  84. package/lib/WABinary/constants.js +1298 -1298
  85. package/lib/WABinary/decode.js +231 -256
  86. package/lib/WABinary/encode.js +207 -239
  87. package/lib/WABinary/generic-utils.js +119 -40
  88. package/lib/WABinary/index.js +7 -21
  89. package/lib/WABinary/jid-utils.js +87 -79
  90. package/lib/WABinary/types.js +3 -2
  91. package/lib/WAM/BinaryInfo.js +10 -12
  92. package/lib/WAM/constants.js +22851 -15348
  93. package/lib/WAM/encode.js +135 -136
  94. package/lib/WAM/index.js +5 -19
  95. package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -30
  96. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +49 -53
  97. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -28
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +36 -39
  99. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
  100. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +26 -20
  101. package/lib/WAUSync/Protocols/index.js +6 -20
  102. package/lib/WAUSync/USyncQuery.js +86 -85
  103. package/lib/WAUSync/USyncUser.js +23 -25
  104. package/lib/WAUSync/index.js +5 -19
  105. package/lib/index.js +18 -49
  106. package/package.json +65 -78
  107. package/README.MD +0 -1295
  108. package/WAProto/GenerateStatics.sh +0 -4
  109. package/WAProto/p.html +0 -1
  110. package/engine-requirements.js +0 -10
  111. package/lib/Defaults/wileys-version.json +0 -3
  112. package/lib/Signal/Group/queue-job.js +0 -57
  113. package/lib/Socket/usync.js +0 -70
  114. package/lib/Utils/wileys-event-stream.js +0 -63
@@ -1,199 +1,219 @@
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
- exports.initAuthCreds = exports.addTransactionCapability = void 0;
7
- exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
8
- const crypto_1 = require("crypto");
9
- const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
10
- const Defaults_1 = require("../Defaults");
11
- const crypto_2 = require("./crypto");
12
- const generics_1 = require("./generics");
13
- /**
14
- * Adds caching capability to a SignalKeyStore
15
- * @param store the store to add caching to
16
- * @param logger to log trace events
17
- * @param _cache cache store to use
18
- */
19
- function makeCacheableSignalKeyStore(store, logger, _cache) {
20
- const cache = _cache || new node_cache_1.default({
21
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes
22
- useClones: false,
23
- deleteOnExpire: true,
1
+ //=======================================================//
2
+ import { delay, generateRegistrationId } from "./generics.js";
3
+ import { DEFAULT_CACHE_TTLS } from "../Defaults/index.js";
4
+ import { PreKeyManager } from "./pre-key-manager.js";
5
+ import { Curve, signedKeyPair } from "./crypto.js";
6
+ import { AsyncLocalStorage } from "async_hooks";
7
+ import NodeCache from "@cacheable/node-cache";
8
+ import { randomBytes } from "crypto";
9
+ import { Mutex } from "async-mutex";
10
+ import PQueue from "p-queue";
11
+ //=======================================================//
12
+ export function makeCacheableSignalKeyStore(store, logger, _cache) {
13
+ const cache = _cache ||
14
+ new NodeCache({
15
+ stdTTL: DEFAULT_CACHE_TTLS.SIGNAL_STORE,
16
+ useClones: false,
17
+ deleteOnExpire: true
24
18
  });
25
- function getUniqueId(type, id) {
26
- return `${type}.${id}`;
27
- }
28
- return {
29
- async get(type, ids) {
30
- const data = {};
31
- const idsToFetch = [];
32
- for (const id of ids) {
33
- const item = cache.get(getUniqueId(type, id));
34
- if (typeof item !== 'undefined') {
35
- data[id] = item;
36
- }
37
- else {
38
- idsToFetch.push(id);
39
- }
40
- }
41
- if (idsToFetch.length) {
42
- logger === null || logger === void 0 ? void 0 : logger.trace({ items: idsToFetch.length }, 'loading from store');
43
- const fetched = await store.get(type, idsToFetch);
44
- for (const id of idsToFetch) {
45
- const item = fetched[id];
46
- if (item) {
47
- data[id] = item;
48
- cache.set(getUniqueId(type, id), item);
49
- }
50
- }
51
- }
52
- return data;
53
- },
54
- async set(data) {
55
- let keys = 0;
56
- for (const type in data) {
57
- for (const id in data[type]) {
58
- cache.set(getUniqueId(type, id), data[type][id]);
59
- keys += 1;
60
- }
19
+ const cacheMutex = new Mutex();
20
+ function getUniqueId(type, id) {
21
+ return `${type}.${id}`;
22
+ }
23
+ return {
24
+ async get(type, ids) {
25
+ return cacheMutex.runExclusive(async () => {
26
+ const data = {};
27
+ const idsToFetch = [];
28
+ for (const id of ids) {
29
+ const item = (await cache.get(getUniqueId(type, id)));
30
+ if (typeof item !== "undefined") {
31
+ data[id] = item;
32
+ }
33
+ else {
34
+ idsToFetch.push(id);
35
+ }
36
+ }
37
+ if (idsToFetch.length) {
38
+ logger?.trace({ items: idsToFetch.length }, "loading from store");
39
+ const fetched = await store.get(type, idsToFetch);
40
+ for (const id of idsToFetch) {
41
+ const item = fetched[id];
42
+ if (item) {
43
+ data[id] = item;
44
+ cache.set(getUniqueId(type, id), item);
61
45
  }
62
- logger === null || logger === void 0 ? void 0 : logger.trace({ keys }, 'updated cache');
63
- await store.set(data);
64
- },
65
- async clear() {
66
- var _a;
67
- cache.flushAll();
68
- await ((_a = store.clear) === null || _a === void 0 ? void 0 : _a.call(store));
46
+ }
47
+ }
48
+ return data;
49
+ });
50
+ },
51
+ async set(data) {
52
+ return cacheMutex.runExclusive(async () => {
53
+ let keys = 0;
54
+ for (const type in data) {
55
+ for (const id in data[type]) {
56
+ await cache.set(getUniqueId(type, id), data[type][id]);
57
+ keys += 1;
58
+ }
69
59
  }
70
- };
60
+ logger?.trace({ keys }, "updated cache");
61
+ await store.set(data);
62
+ });
63
+ },
64
+ async clear() {
65
+ await cache.flushAll();
66
+ await store.clear?.();
67
+ }
68
+ };
71
69
  }
72
- /**
73
- * Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
74
- * this allows batch read & write operations & improves the performance of the lib
75
- * @param state the key store to apply this capability to
76
- * @param logger logger to log events
77
- * @returns SignalKeyStore with transaction capability
78
- */
79
- const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetweenTriesMs }) => {
80
- // number of queries made to the DB during the transaction
81
- // only there for logging purposes
82
- let dbQueriesInTransaction = 0;
83
- let transactionCache = {};
84
- let mutations = {};
85
- let transactionsInProgress = 0;
86
- return {
87
- get: async (type, ids) => {
88
- if (isInTransaction()) {
89
- const dict = transactionCache[type];
90
- const idsRequiringFetch = dict
91
- ? ids.filter(item => typeof dict[item] === 'undefined')
92
- : ids;
93
- // only fetch if there are any items to fetch
94
- if (idsRequiringFetch.length) {
95
- dbQueriesInTransaction += 1;
96
- const result = await state.get(type, idsRequiringFetch);
97
- transactionCache[type] || (transactionCache[type] = {});
98
- Object.assign(transactionCache[type], result);
99
- }
100
- return ids.reduce((dict, id) => {
101
- var _a;
102
- const value = (_a = transactionCache[type]) === null || _a === void 0 ? void 0 : _a[id];
103
- if (value) {
104
- dict[id] = value;
105
- }
106
- return dict;
107
- }, {});
108
- }
109
- else {
110
- return state.get(type, ids);
111
- }
112
- },
113
- set: data => {
114
- if (isInTransaction()) {
115
- logger.trace({ types: Object.keys(data) }, 'caching in transaction');
116
- for (const key in data) {
117
- transactionCache[key] = transactionCache[key] || {};
118
- Object.assign(transactionCache[key], data[key]);
119
- mutations[key] = mutations[key] || {};
120
- Object.assign(mutations[key], data[key]);
121
- }
122
- }
123
- else {
124
- return state.set(data);
125
- }
126
- },
127
- isInTransaction,
128
- async transaction(work) {
129
- let result;
130
- transactionsInProgress += 1;
131
- if (transactionsInProgress === 1) {
132
- logger.trace('entering transaction');
133
- }
134
- try {
135
- result = await work();
136
- // commit if this is the outermost transaction
137
- if (transactionsInProgress === 1) {
138
- if (Object.keys(mutations).length) {
139
- logger.trace('committing transaction');
140
- // retry mechanism to ensure we've some recovery
141
- // in case a transaction fails in the first attempt
142
- let tries = maxCommitRetries;
143
- while (tries) {
144
- tries -= 1;
145
- try {
146
- await state.set(mutations);
147
- logger.trace({ dbQueriesInTransaction }, 'committed transaction');
148
- break;
149
- }
150
- catch (error) {
151
- logger.warn(`failed to commit ${Object.keys(mutations).length} mutations, tries left=${tries}`);
152
- await (0, generics_1.delay)(delayBetweenTriesMs);
153
- }
154
- }
155
- }
156
- else {
157
- logger.trace('no mutations in transaction');
158
- }
159
- }
160
- }
161
- finally {
162
- transactionsInProgress -= 1;
163
- if (transactionsInProgress === 0) {
164
- transactionCache = {};
165
- mutations = {};
166
- dbQueriesInTransaction = 0;
167
- }
168
- }
169
- return result;
70
+ //=======================================================//
71
+ export const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetweenTriesMs }) => {
72
+ const txStorage = new AsyncLocalStorage();
73
+ const keyQueues = new Map();
74
+ const txMutexes = new Map();
75
+ const preKeyManager = new PreKeyManager(state, logger);
76
+ function getQueue(key) {
77
+ if (!keyQueues.has(key)) {
78
+ keyQueues.set(key, new PQueue({ concurrency: 1 }));
79
+ }
80
+ return keyQueues.get(key);
81
+ }
82
+ function getTxMutex(key) {
83
+ if (!txMutexes.has(key)) {
84
+ txMutexes.set(key, new Mutex());
85
+ }
86
+ return txMutexes.get(key);
87
+ }
88
+ function isInTransaction() {
89
+ return !!txStorage.getStore();
90
+ }
91
+ async function commitWithRetry(mutations) {
92
+ if (Object.keys(mutations).length === 0) {
93
+ logger.trace("no mutations in transaction");
94
+ return;
95
+ }
96
+ logger.trace("committing transaction");
97
+ for (let attempt = 0; attempt < maxCommitRetries; attempt++) {
98
+ try {
99
+ await state.set(mutations);
100
+ logger.trace({ mutationCount: Object.keys(mutations).length }, "committed transaction");
101
+ return;
102
+ }
103
+ catch (error) {
104
+ const retriesLeft = maxCommitRetries - attempt - 1;
105
+ logger.warn(`failed to commit mutations, retries left=${retriesLeft}`);
106
+ if (retriesLeft === 0) {
107
+ throw error;
108
+ }
109
+ await delay(delayBetweenTriesMs);
110
+ }
111
+ }
112
+ }
113
+ return {
114
+ get: async (type, ids) => {
115
+ const ctx = txStorage.getStore();
116
+ if (!ctx) {
117
+ return state.get(type, ids);
118
+ }
119
+ const cached = ctx.cache[type] || {};
120
+ const missing = ids.filter(id => !(id in cached));
121
+ if (missing.length > 0) {
122
+ ctx.dbQueries++;
123
+ logger.trace({ type, count: missing.length }, "fetching missing keys in transaction");
124
+ const fetched = await getTxMutex(type).runExclusive(() => state.get(type, missing));
125
+ ctx.cache[type] = ctx.cache[type] || {};
126
+ Object.assign(ctx.cache[type], fetched);
127
+ }
128
+ const result = {};
129
+ for (const id of ids) {
130
+ const value = ctx.cache[type]?.[id];
131
+ if (value !== undefined && value !== null) {
132
+ result[id] = value;
133
+ }
134
+ }
135
+ return result;
136
+ },
137
+ set: async (data) => {
138
+ const ctx = txStorage.getStore();
139
+ if (!ctx) {
140
+ const types = Object.keys(data);
141
+ for (const type_ of types) {
142
+ const type = type_;
143
+ if (type === "pre-key") {
144
+ await preKeyManager.validateDeletions(data, type);
145
+ }
146
+ }
147
+ await Promise.all(types.map(type => getQueue(type).add(async () => {
148
+ const typeData = { [type]: data[type] };
149
+ await state.set(typeData);
150
+ })));
151
+ return;
152
+ }
153
+ logger.trace({ types: Object.keys(data) }, "caching in transaction");
154
+ for (const key_ in data) {
155
+ const key = key_;
156
+ ctx.cache[key] = ctx.cache[key] || {};
157
+ ctx.mutations[key] = ctx.mutations[key] || {};
158
+ if (key === "pre-key") {
159
+ await preKeyManager.processOperations(data, key, ctx.cache, ctx.mutations, true);
160
+ }
161
+ else {
162
+ Object.assign(ctx.cache[key], data[key]);
163
+ Object.assign(ctx.mutations[key], data[key]);
164
+ }
165
+ }
166
+ },
167
+ isInTransaction,
168
+ transaction: async (work, key) => {
169
+ const existing = txStorage.getStore();
170
+ if (existing) {
171
+ logger.trace("reusing existing transaction context");
172
+ return work();
173
+ }
174
+ return getTxMutex(key).runExclusive(async () => {
175
+ const ctx = {
176
+ cache: {},
177
+ mutations: {},
178
+ dbQueries: 0
179
+ };
180
+ logger.trace("entering transaction");
181
+ try {
182
+ const result = await txStorage.run(ctx, work);
183
+ await commitWithRetry(ctx.mutations);
184
+ logger.trace({ dbQueries: ctx.dbQueries }, "transaction completed");
185
+ return result;
186
+ }
187
+ catch (error) {
188
+ logger.error({ error }, "transaction failed, rolling back");
189
+ throw error;
170
190
  }
171
- };
172
- function isInTransaction() {
173
- return transactionsInProgress > 0;
191
+ });
174
192
  }
193
+ };
175
194
  };
176
- exports.addTransactionCapability = addTransactionCapability;
177
- const initAuthCreds = () => {
178
- const identityKey = crypto_2.Curve.generateKeyPair();
179
- return {
180
- noiseKey: crypto_2.Curve.generateKeyPair(),
181
- pairingEphemeralKeyPair: crypto_2.Curve.generateKeyPair(),
182
- signedIdentityKey: identityKey,
183
- signedPreKey: (0, crypto_2.signedKeyPair)(identityKey, 1),
184
- registrationId: (0, generics_1.generateRegistrationId)(),
185
- advSecretKey: (0, crypto_1.randomBytes)(32).toString('base64'),
186
- processedHistoryMessages: [],
187
- nextPreKeyId: 1,
188
- firstUnuploadedPreKeyId: 1,
189
- accountSyncCounter: 0,
190
- accountSettings: {
191
- unarchiveChats: false
192
- },
193
- registered: false,
194
- pairingCode: undefined,
195
- lastPropHash: undefined,
196
- routingInfo: undefined,
197
- };
195
+ //=======================================================//
196
+ export const initAuthCreds = () => {
197
+ const identityKey = Curve.generateKeyPair();
198
+ return {
199
+ "noiseKey": Curve.generateKeyPair(),
200
+ "pairingEphemeralKeyPair": Curve.generateKeyPair(),
201
+ "signedIdentityKey": identityKey,
202
+ "signedPreKey": signedKeyPair(identityKey, 1),
203
+ "registrationId": generateRegistrationId(),
204
+ "advSecretKey": randomBytes(32).toString("base64"),
205
+ "processedHistoryMessages": [],
206
+ "nextPreKeyId": 1,
207
+ "firstUnuploadedPreKeyId": 1,
208
+ "accountSyncCounter": 0,
209
+ "accountSettings": {
210
+ "unarchiveChats": false
211
+ },
212
+ "registered": false,
213
+ "pairingCode": undefined,
214
+ "lastPropHash": undefined,
215
+ "routingInfo": undefined,
216
+ "additionalData": undefined
217
+ };
198
218
  };
199
- exports.initAuthCreds = initAuthCreds;
219
+ //=======================================================//
@@ -0,0 +1,44 @@
1
+ //=======================================================//
2
+ import { makeMutex } from "./make-mutex.js";
3
+ import { createInterface } from "readline";
4
+ import { writeFile } from "fs/promises";
5
+ import { delay } from "./generics.js";
6
+ import { createReadStream } from "fs";
7
+ import EventEmitter from "events";
8
+ //=======================================================//
9
+ export const captureEventStream = (ev, filename) => {
10
+ const oldEmit = ev.emit;
11
+ const writeMutex = makeMutex();
12
+ ev.emit = function (...args) {
13
+ const content = JSON.stringify({ timestamp: Date.now(), event: args[0], data: args[1] }) + "\n";
14
+ const result = oldEmit.apply(ev, args);
15
+ writeMutex.mutex(async () => {
16
+ await writeFile(filename, content, { flag: "a" });
17
+ });
18
+ return result;
19
+ };
20
+ };
21
+ //=======================================================//
22
+ export const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
23
+ const ev = new EventEmitter();
24
+ const fireEvents = async () => {
25
+ const fileStream = createReadStream(filename);
26
+ const rl = createInterface({
27
+ input: fileStream,
28
+ crlfDelay: Infinity
29
+ });
30
+ for await (const line of rl) {
31
+ if (line) {
32
+ const { event, data } = JSON.parse(line);
33
+ ev.emit(event, data);
34
+ delayIntervalMs && (await delay(delayIntervalMs));
35
+ }
36
+ }
37
+ fileStream.close();
38
+ };
39
+ return {
40
+ ev,
41
+ task: fireEvents()
42
+ };
43
+ };
44
+ //=======================================================//
@@ -1,35 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPlatformId = exports.Browsers = void 0;
4
-
5
- const os = require("os");
6
- const { proto } = require("../../WAProto/index.js");
7
-
1
+ //=======================================================//
2
+ import { proto } from "../../WAProto/index.js";
3
+ import { platform, release } from "os";
4
+ //=======================================================//
8
5
  const PLATFORM_MAP = {
9
- 'aix': 'AIX',
10
- 'darwin': 'Mac OS',
11
- 'win32': 'Windows',
12
- 'android': 'Android',
13
- 'freebsd': 'FreeBSD',
14
- 'openbsd': 'OpenBSD',
15
- 'sunos': 'Solaris',
16
- 'linux': undefined, // Default ke Ubuntu untuk Linux
17
- 'haiku': undefined,
18
- 'cygwin': undefined,
19
- 'netbsd': undefined
6
+ 'Chrome': '49',
7
+ 'Edge': '50',
8
+ 'Firefox': '51',
9
+ 'Opera': '53',
10
+ 'Safari': '54'
20
11
  };
21
-
22
- // Fixed: Browsers sekarang fungsi yang return array [platform, browser, version]
23
- // Ini kompatibel dengan pemanggilan Browsers('Chrome') di Defaults/index.js
24
- exports.Browsers = (browser) => {
25
- const osName = PLATFORM_MAP[os.platform()] || 'Ubuntu'; // Default Ubuntu kalau undefined
26
- const osRelease = os.release(); // Ambil versi OS real-time
27
- return [osName, browser, osRelease];
12
+ //=======================================================//
13
+ export const Browsers = {
14
+ iOS: (browser) => ["ios", browser, "18.2"],
15
+ ubuntu: (browser) => ['Ubuntu', browser, '22.04.4'],
16
+ macOS: (browser) => ['Mac OS', browser, '14.4.1'],
17
+ baileys: (browser) => ['Baileys', browser, '6.5.0'],
18
+ windows: (browser) => ['Windows', browser, '10.0.22631']
28
19
  };
29
-
30
- const getPlatformId = (browser) => {
31
- const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase()];
32
- return platformType ? platformType.toString() : '1'; // Default Chrome
20
+ //=======================================================//
21
+ export const getPlatformId = (browser) => {
22
+ const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase()];
23
+ return platformType ? platformType.toString() : "1";
33
24
  };
34
-
35
- exports.getPlatformId = getPlatformId;
25
+ //=======================================================//