@nexustechpro/baileys 2.0.5 → 2.0.6

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.
@@ -10,4 +10,47 @@ export var SyncState;
10
10
  /** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
11
11
  SyncState[SyncState["Online"] = 3] = "Online";
12
12
  })(SyncState || (SyncState = {}));
13
+ export var ReachoutTimelockEnforcementType;
14
+ (function (ReachoutTimelockEnforcementType) {
15
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_ALCOHOL"] = "BIZ_COMMERCE_VIOLATION_ALCOHOL";
16
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_ADULT"] = "BIZ_COMMERCE_VIOLATION_ADULT";
17
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_ANIMALS"] = "BIZ_COMMERCE_VIOLATION_ANIMALS";
18
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_BODY_PARTS_FLUIDS"] = "BIZ_COMMERCE_VIOLATION_BODY_PARTS_FLUIDS";
19
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DATING"] = "BIZ_COMMERCE_VIOLATION_DATING";
20
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DIGITAL_SERVICES_PRODUCTS"] = "BIZ_COMMERCE_VIOLATION_DIGITAL_SERVICES_PRODUCTS";
21
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DRUGS"] = "BIZ_COMMERCE_VIOLATION_DRUGS";
22
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DRUGS_ONLY_OTC"] = "BIZ_COMMERCE_VIOLATION_DRUGS_ONLY_OTC";
23
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_GAMBLING"] = "BIZ_COMMERCE_VIOLATION_GAMBLING";
24
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_HEALTHCARE"] = "BIZ_COMMERCE_VIOLATION_HEALTHCARE";
25
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_REAL_FAKE_CURRENCY"] = "BIZ_COMMERCE_VIOLATION_REAL_FAKE_CURRENCY";
26
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_SUPPLEMENTS"] = "BIZ_COMMERCE_VIOLATION_SUPPLEMENTS";
27
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_TOBACCO"] = "BIZ_COMMERCE_VIOLATION_TOBACCO";
28
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_VIOLENT_CONTENT"] = "BIZ_COMMERCE_VIOLATION_VIOLENT_CONTENT";
29
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_WEAPONS"] = "BIZ_COMMERCE_VIOLATION_WEAPONS";
30
+ ReachoutTimelockEnforcementType["BIZ_QUALITY"] = "BIZ_QUALITY";
31
+ /** This means there is no restriction */
32
+ ReachoutTimelockEnforcementType["DEFAULT"] = "DEFAULT";
33
+ ReachoutTimelockEnforcementType["WEB_COMPANION_ONLY"] = "WEB_COMPANION_ONLY";
34
+ })(ReachoutTimelockEnforcementType || (ReachoutTimelockEnforcementType = {}));
35
+ export var NewChatMessageCappingStatusType;
36
+ (function (NewChatMessageCappingStatusType) {
37
+ NewChatMessageCappingStatusType["NONE"] = "NONE";
38
+ NewChatMessageCappingStatusType["FIRST_WARNING"] = "FIRST_WARNING";
39
+ NewChatMessageCappingStatusType["SECOND_WARNING"] = "SECOND_WARNING";
40
+ NewChatMessageCappingStatusType["CAPPED"] = "CAPPED";
41
+ })(NewChatMessageCappingStatusType || (NewChatMessageCappingStatusType = {}));
42
+ export var NewChatMessageCappingMVStatusType;
43
+ (function (NewChatMessageCappingMVStatusType) {
44
+ NewChatMessageCappingMVStatusType["NOT_ELIGIBLE"] = "NOT_ELIGIBLE";
45
+ NewChatMessageCappingMVStatusType["NOT_ACTIVE"] = "NOT_ACTIVE";
46
+ NewChatMessageCappingMVStatusType["ACTIVE"] = "ACTIVE";
47
+ NewChatMessageCappingMVStatusType["ACTIVE_UPGRADE_AVAILABLE"] = "ACTIVE_UPGRADE_AVAILABLE";
48
+ })(NewChatMessageCappingMVStatusType || (NewChatMessageCappingMVStatusType = {}));
49
+ export var NewChatMessageCappingOTEStatusType;
50
+ (function (NewChatMessageCappingOTEStatusType) {
51
+ NewChatMessageCappingOTEStatusType["NOT_ELIGIBLE"] = "NOT_ELIGIBLE";
52
+ NewChatMessageCappingOTEStatusType["ELIGIBLE"] = "ELIGIBLE";
53
+ NewChatMessageCappingOTEStatusType["ACTIVE_IN_CURRENT_CYCLE"] = "ACTIVE_IN_CURRENT_CYCLE";
54
+ NewChatMessageCappingOTEStatusType["EXHAUSTED"] = "EXHAUSTED";
55
+ })(NewChatMessageCappingOTEStatusType || (NewChatMessageCappingOTEStatusType = {}));
13
56
  //# sourceMappingURL=State.js.map
@@ -128,7 +128,7 @@ export const addTransactionCapability = (state, logger, { maxCommitRetries, dela
128
128
  }
129
129
  catch (error) {
130
130
  const msg = error?.message || (typeof error === 'string' ? error : '') || ''
131
- const isExpected = msg.includes('InvalidPreKeyId') || msg.includes('SessionNotFound') || msg.includes('InvalidMessage') || msg.includes('no sender key state') || msg.includes('old counter') || msg.includes('DuplicatedMessage') || msg.includes('Connection Closed')
131
+ const isExpected = msg.includes('InvalidPreKeyId') || msg.includes('SessionNotFound') || msg.includes('InvalidMessage') || msg.includes('no sender key state') || msg.includes('invalid sender key session') || msg.includes('memory access out of bounds') || msg.includes('old counter') || msg.includes('DuplicatedMessage') || msg.includes('BadMac') || msg.includes('Connection Closed')
132
132
  if (isExpected) { logger?.debug?.({ error: msg }, 'transaction skipped — expected decrypt error, message dropped silently'); return undefined } // skip, no retry
133
133
  logger?.error?.({ error: msg || error }, 'transaction failed, rolling back')
134
134
  throw error
@@ -225,7 +225,7 @@ export const addTransactionCapability = (state, logger, { maxCommitRetries, dela
225
225
  }
226
226
  catch (error) {
227
227
  const msg = error?.message || (typeof error === 'string' ? error : '') || ''
228
- const isExpected = msg.includes('InvalidPreKeyId') || msg.includes('SessionNotFound') || msg.includes('InvalidMessage') || msg.includes('no sender key state') || msg.includes('old counter')
228
+ const isExpected = msg.includes('InvalidPreKeyId') || msg.includes('SessionNotFound') || msg.includes('InvalidMessage') || msg.includes('no sender key state') || msg.includes('invalid sender key session') || msg.includes('memory access out of bounds') || msg.includes('old counter') || msg.includes('DuplicatedMessage') || msg.includes('BadMac')
229
229
  ; (isExpected ? logger?.debug?.bind(logger) : logger?.error?.bind(logger))?.({ error: msg || error }, 'transaction failed, rolling back')
230
230
  throw error
231
231
  }
@@ -1,6 +1,7 @@
1
1
  import { Boom } from '@hapi/boom';
2
2
  import { proto } from '../../WAProto/index.js';
3
3
  import { LabelAssociationType } from '../Types/LabelAssociation.js';
4
+ import { processContactAction, emitSyncActionResults } from './sync-action-utils.js'
4
5
  import { getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, jidNormalizedUser, isJidUser } from '../WABinary/index.js';
5
6
  import { aesDecrypt, aesEncrypt, hkdf, hmacSign } from './crypto.js';
6
7
  import { toNumber } from './generics.js';
@@ -155,6 +156,7 @@ export const encodeSyncdPatch = async ({ type, index, syncAction, apiVersion, op
155
156
 
156
157
  export const decodeSyncdMutations = async (msgMutations, initialState, getAppStateSyncKey, onMutation, validateMacs, logger) => {
157
158
  const ltGenerator = makeLtHashGenerator(initialState);
159
+ const derivedKeyCache = new Map()
158
160
  let skippedMutations = 0;
159
161
  for (const msgMutation of msgMutations) {
160
162
  const operation = 'operation' in msgMutation ? msgMutation.operation : proto.SyncdMutation.SyncdOperation.SET;
@@ -201,15 +203,14 @@ export const decodeSyncdMutations = async (msgMutations, initialState, getAppSta
201
203
  return await ltGenerator.finish();
202
204
 
203
205
  async function getKey(keyId) {
204
- const base64Key = Buffer.from(keyId).toString('base64');
205
- const keyEnc = await getAppStateSyncKey(base64Key);
206
- if (!keyEnc) {
207
- throw new Boom(`failed to find key "${base64Key}" to decode mutation`, {
208
- statusCode: 404,
209
- data: { isMissingKey: true, msgMutations }
210
- });
211
- }
212
- return mutationKeys(keyEnc.keyData);
206
+ const base64Key = Buffer.from(keyId).toString('base64')
207
+ const cached = derivedKeyCache.get(base64Key)
208
+ if (cached) return cached
209
+ const keyEnc = await getAppStateSyncKey(base64Key)
210
+ if (!keyEnc) throw new Boom(`failed to find key "${base64Key}" to decode mutation`, { statusCode: 404, data: { isMissingKey: true, msgMutations } })
211
+ const keys = await mutationKeys(keyEnc.keyData)
212
+ derivedKeyCache.set(base64Key, keys)
213
+ return keys
213
214
  }
214
215
  };
215
216
 
@@ -609,13 +610,8 @@ export const processSyncAction = (syncAction, ev, me, initialSyncOpts, logger) =
609
610
  });
610
611
  }
611
612
  else if (action?.contactAction) {
612
- ev.emit('contacts.upsert', [{
613
- id: id,
614
- name: action.contactAction.fullName,
615
- lid: action.contactAction.lidJid || undefined,
616
- phoneNumber: action.contactAction.pnJid || undefined,
617
- jid: isJidUser(id) ? id : undefined
618
- }]);
613
+ const results = processContactAction(action.contactAction, id, logger)
614
+ emitSyncActionResults(ev, results)
619
615
  }
620
616
  else if (action?.pushNameSetting) {
621
617
  const name = action?.pushNameSetting?.name;
@@ -671,6 +667,42 @@ export const processSyncAction = (syncAction, ev, me, initialSyncOpts, logger) =
671
667
  : { type: LabelAssociationType.Message, chatId: syncAction.index[2], messageId: syncAction.index[3], labelId: syncAction.index[1] }
672
668
  });
673
669
  }
670
+ else if (action?.localeSetting?.locale) {
671
+ ev.emit('settings.update', { setting: 'locale', value: action.localeSetting.locale })
672
+ }
673
+ else if (action?.timeFormatAction) {
674
+ ev.emit('settings.update', { setting: 'timeFormat', value: action.timeFormatAction })
675
+ }
676
+ else if (action?.pnForLidChatAction) {
677
+ if (action.pnForLidChatAction.pnJid) ev.emit('lid-mapping.update', { lid: id, pn: action.pnForLidChatAction.pnJid })
678
+ }
679
+ else if (action?.privacySettingRelayAllCalls) {
680
+ ev.emit('settings.update', { setting: 'privacySettingRelayAllCalls', value: action.privacySettingRelayAllCalls })
681
+ }
682
+ else if (action?.statusPrivacy) {
683
+ ev.emit('settings.update', { setting: 'statusPrivacy', value: action.statusPrivacy })
684
+ }
685
+ else if (action?.lockChatAction) {
686
+ ev.emit('chats.lock', { id, locked: !!action.lockChatAction.locked })
687
+ }
688
+ else if (action?.privacySettingDisableLinkPreviewsAction) {
689
+ ev.emit('settings.update', { setting: 'disableLinkPreviews', value: action.privacySettingDisableLinkPreviewsAction })
690
+ }
691
+ else if (action?.notificationActivitySettingAction?.notificationActivitySetting) {
692
+ ev.emit('settings.update', { setting: 'notificationActivitySetting', value: action.notificationActivitySettingAction.notificationActivitySetting })
693
+ }
694
+ else if (action?.lidContactAction) {
695
+ ev.emit('contacts.upsert', [{
696
+ id,
697
+ name: action.lidContactAction.fullName || action.lidContactAction.firstName || action.lidContactAction.username || undefined,
698
+ username: action.lidContactAction.username || undefined,
699
+ lid: id,
700
+ phoneNumber: undefined
701
+ }])
702
+ }
703
+ else if (action?.privacySettingChannelsPersonalisedRecommendationAction) {
704
+ ev.emit('settings.update', { setting: 'channelsPersonalisedRecommendation', value: action.privacySettingChannelsPersonalisedRecommendationAction })
705
+ }
674
706
  else {
675
707
  logger?.debug({ syncAction, id }, 'unprocessable update');
676
708
  }
@@ -0,0 +1,34 @@
1
+ export var CompanionWebClientType;
2
+ (function (CompanionWebClientType) {
3
+ CompanionWebClientType[CompanionWebClientType["UNKNOWN"] = 0] = "UNKNOWN";
4
+ CompanionWebClientType[CompanionWebClientType["CHROME"] = 1] = "CHROME";
5
+ CompanionWebClientType[CompanionWebClientType["EDGE"] = 2] = "EDGE";
6
+ CompanionWebClientType[CompanionWebClientType["FIREFOX"] = 3] = "FIREFOX";
7
+ CompanionWebClientType[CompanionWebClientType["IE"] = 4] = "IE";
8
+ CompanionWebClientType[CompanionWebClientType["OPERA"] = 5] = "OPERA";
9
+ CompanionWebClientType[CompanionWebClientType["SAFARI"] = 6] = "SAFARI";
10
+ CompanionWebClientType[CompanionWebClientType["ELECTRON"] = 7] = "ELECTRON";
11
+ CompanionWebClientType[CompanionWebClientType["UWP"] = 8] = "UWP";
12
+ CompanionWebClientType[CompanionWebClientType["OTHER_WEB_CLIENT"] = 9] = "OTHER_WEB_CLIENT";
13
+ })(CompanionWebClientType || (CompanionWebClientType = {}));
14
+ const BROWSER_TO_COMPANION_WEB_CLIENT = {
15
+ Chrome: CompanionWebClientType.CHROME,
16
+ Edge: CompanionWebClientType.EDGE,
17
+ Firefox: CompanionWebClientType.FIREFOX,
18
+ IE: CompanionWebClientType.IE,
19
+ Opera: CompanionWebClientType.OPERA,
20
+ Safari: CompanionWebClientType.SAFARI
21
+ };
22
+ export const getCompanionWebClientType = ([os, browserName]) => {
23
+ if (browserName === 'Desktop') {
24
+ return os === 'Windows' ? CompanionWebClientType.UWP : CompanionWebClientType.ELECTRON;
25
+ }
26
+ return BROWSER_TO_COMPANION_WEB_CLIENT[browserName] || CompanionWebClientType.OTHER_WEB_CLIENT;
27
+ };
28
+ export const getCompanionPlatformId = (browser) => {
29
+ return getCompanionWebClientType(browser).toString();
30
+ };
31
+ export const buildPairingQRData = (ref, noiseKeyB64, identityKeyB64, advB64, browser) => {
32
+ return ('https://wa.me/settings/linked_devices#' +
33
+ [ref, noiseKeyB64, identityKeyB64, advB64, getCompanionPlatformId(browser)].join(','));
34
+ };
@@ -55,6 +55,7 @@ const storeMappingFromEnvelope = async (stanza, sender, repository, decryptionJi
55
55
  }
56
56
  export const NO_MESSAGE_FOUND_ERROR_TEXT = "Message absent from node"
57
57
  export const MISSING_KEYS_ERROR_TEXT = "Key used already or never filled"
58
+ export const ACCOUNT_RESTRICTED_TEXT = 'Your account has been restricted';
58
59
  // Retry configuration for failed decryption
59
60
  export const DECRYPTION_RETRY_CONFIG = {
60
61
  maxRetries: 3,
@@ -102,6 +103,21 @@ export const extractAddressingContext = (stanza) => {
102
103
  recipientAlt,
103
104
  }
104
105
  }
106
+ /**
107
+ * Server-side error codes returned in ack stanzas (server → client) that we
108
+ * currently have dedicated handlers for. Extend as more handlers are added.
109
+ * Distinct from the client-side NackReason enum (WAWebCreateNackFromStanza).
110
+ */
111
+ export const SERVER_ERROR_CODES = {
112
+ /**
113
+ * 1:1 message missing privacy token (tctoken). Usually means the account is
114
+ * restricted: WhatsApp blocks starting new chats but preserves existing ones,
115
+ * since established chats already carry a tctoken.
116
+ */
117
+ MessageAccountRestriction: '463',
118
+ /** Stanza validation failure (SMAX_INVALID) — likely stale device session */
119
+ SmaxInvalid: '479'
120
+ };
105
121
  /**
106
122
  * Decode the received node as a message.
107
123
  * @note this will only parse the message, not decrypt it
@@ -230,20 +246,36 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
230
246
  const e2eType = tag === "plaintext" ? "plaintext" : attrs.type
231
247
  switch (e2eType) {
232
248
  case "skmsg":
233
- msgBuffer = await repository.decryptGroupMessage({
234
- group: sender,
235
- authorJid: author,
236
- msg: content,
237
- })
249
+ try {
250
+ msgBuffer = await repository.decryptGroupMessage({
251
+ group: sender,
252
+ authorJid: author,
253
+ msg: content,
254
+ })
255
+ } catch (decryptErr) {
256
+ const errMsg = decryptErr?.message || decryptErr?.toString() || ''
257
+ if (errMsg.includes('invalid sender key session') || errMsg.includes('memory access out of bounds')) {
258
+ logger?.debug?.({ group: sender, author: author, errMsg }, '[Signal] Stale/corrupt sender key session, deleting')
259
+ try {
260
+ await repository.deleteSenderKey(sender, author)
261
+ } catch (e) {
262
+ logger?.warn?.({ err: e }, 'Failed to delete sender key')
263
+ }
264
+ }
265
+ throw decryptErr
266
+ }
238
267
  break
239
268
  case "pkmsg":
240
269
  case "msg":
241
270
  try {
242
271
  msgBuffer = await repository.decryptMessage({ jid: decryptionJid, type: e2eType, ciphertext: content })
272
+ if (msgBuffer === null) {
273
+ throw new Error("DuplicatedMessage")
274
+ }
243
275
  } catch (decryptErr) {
244
276
  const errMsg = decryptErr?.message || decryptErr?.toString() || ''
245
- if (errMsg.includes('InvalidMessage') && e2eType === 'msg') {
246
- logger?.debug?.({ jid: decryptionJid }, '[Signal] InvalidMessage stale session, deleting')
277
+ if ((errMsg.includes('InvalidMessage') || errMsg.includes('BadMac')) && e2eType === 'msg') {
278
+ logger?.debug?.({ jid: decryptionJid, errMsg }, '[Signal] Stale session (InvalidMessage/BadMac), deleting')
247
279
  try {
248
280
  const toDelete = [decryptionJid]
249
281
  await repository.deleteSession(toDelete)
@@ -292,7 +324,7 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
292
324
  } catch (err) {
293
325
  const errorMessage = err?.message || err?.toString() || ""
294
326
  const errStr = err?.message || (typeof err === "string" ? err : "") || ""
295
- const isExpectedDecryptErr = errStr.includes("InvalidPreKeyId") || errStr.includes("SessionNotFound") || errStr.includes("InvalidMessage") || errStr.includes("no sender key state") || errStr.includes("old counter")
327
+ const isExpectedDecryptErr = errStr.includes("InvalidPreKeyId") || errStr.includes("SessionNotFound") || errStr.includes("InvalidMessage") || errStr.includes("no sender key state") || errStr.includes("invalid sender key session") || errStr.includes("memory access out of bounds") || errStr.includes("old counter") || errStr.includes("DuplicatedMessage") || errStr.includes("BadMac")
296
328
  ; (isExpectedDecryptErr ? logger?.debug?.bind(logger) : logger?.error?.bind(logger))?.({ key: fullMessage.key, err, errorMessage, messageType: tag === "plaintext" ? "plaintext" : attrs.type, sender, author }, "failed to decrypt message")
297
329
  fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
298
330
  fullMessage.messageStubParameters = [errorMessage]
@@ -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, 1036200034]
4
+ const baileysVersion = [2, 3000, 1040069233]
5
5
  import { DisconnectReason } from '../Types/index.js'
6
6
  import { getAllBinaryNodeChildren, jidDecode } from '../WABinary/index.js'
7
7
  import { sha256 } from './crypto.js'
@@ -149,10 +149,10 @@ export const generateMessageIDV2 = (userId) => {
149
149
  const random = randomBytes(16)
150
150
  random.copy(data, 28)
151
151
  const hash = createHash('sha256').update(data).digest()
152
- return '3EB0' + hash.toString('hex').toUpperCase().substring(0, 18)
152
+ return 'NEXUSTECHPRO' + hash.toString('hex').toUpperCase().substring(0, 18)
153
153
  }
154
154
 
155
- export const generateMessageID = () => '3EB0' + randomBytes(18).toString('hex').toUpperCase()
155
+ export const generateMessageID = () => 'NEXUSTECHPRO' + randomBytes(18).toString('hex').toUpperCase()
156
156
 
157
157
  export function bindWaitForEvent(ev, event) {
158
158
  return async (check, timeoutMs) => {
@@ -177,14 +177,12 @@ export function bindWaitForEvent(ev, event) {
177
177
  export const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, 'connection.update')
178
178
 
179
179
  export const fetchLatestBaileysVersion = async (options = {}) => {
180
- const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/index.ts'
180
+ const URL = 'https://raw.githubusercontent.com/nexustechpro2/baileys/master/lib/Defaults/index.js'
181
181
  try {
182
182
  const response = await fetch(URL, { dispatcher: options.dispatcher, method: 'GET', headers: options.headers })
183
183
  if (!response.ok) throw new Boom(`Failed to fetch latest Baileys version: ${response.statusText}`, { statusCode: response.status })
184
184
  const text = await response.text()
185
- const lines = text.split('\n')
186
- const versionLine = lines[6]
187
- const versionMatch = versionLine.match(/const version = \[(\d+),\s*(\d+),\s*(\d+)\]/)
185
+ const versionMatch = text.match(/const version = \[(\d+),\s*(\d+),\s*(\d+)\]/)
188
186
  if (versionMatch) {
189
187
  const version = [parseInt(versionMatch[1]), parseInt(versionMatch[2]), parseInt(versionMatch[3])]
190
188
  return { version, isLatest: true }
@@ -5,6 +5,7 @@ export * from './messages-media.js';
5
5
  export * from './validate-connection.js';
6
6
  export * from './crypto.js';
7
7
  export * from './signal.js';
8
+ export * from './make-mutex.js';
8
9
  export * from './noise-handler.js';
9
10
  export * from './history.js';
10
11
  export * from './chat-utils.js';
@@ -19,4 +20,7 @@ export * from './message-retry-manager.js';
19
20
  export * from './browser-utils.js';
20
21
  export * from './identity-chnage-handler.js';
21
22
  export * from './key-store.js';
23
+ export * from './reporting-utils.js';
24
+ export * from './companion-reg-client-utils.js';
25
+ export * from './tc-token-utils.js';
22
26
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,4 @@
1
+ import { promises as dnsPromises } from 'dns'
1
2
  import { getLinkPreview } from 'link-preview-js'
2
3
  import { prepareWAMessageMedia } from './messages.js'
3
4
  import { extractImageThumb, getHttpStream } from './messages-media.js'
@@ -75,6 +76,15 @@ export const getUrlInfo = (text, opts = {}) => _enqueue(async () => {
75
76
  if (sameHost) { retries++; return true }
76
77
  return false
77
78
  },
79
+ resolveDNSHost: async (url) => {
80
+ const hostname = new URL(url).hostname
81
+ try {
82
+ const { address } = await dnsPromises.lookup(hostname)
83
+ return address
84
+ } catch {
85
+ return hostname
86
+ }
87
+ },
78
88
  headers: fetchOpts.headers
79
89
  })
80
90
  if (!info || !('title' in info) || !info.title) return undefined