project: Move to ESM Modules
This commit is contained in:
+10
-9
@@ -10,7 +10,8 @@ import {
|
||||
MIN_PREKEY_COUNT,
|
||||
NOISE_WA_HEADER
|
||||
} from '../Defaults'
|
||||
import { DisconnectReason, SocketConfig } from '../Types'
|
||||
import type { SocketConfig } from '../Types'
|
||||
import { DisconnectReason } from '../Types'
|
||||
import {
|
||||
addTransactionCapability,
|
||||
aesEncryptCTR,
|
||||
@@ -32,7 +33,7 @@ import {
|
||||
} from '../Utils'
|
||||
import {
|
||||
assertNodeErrorFree,
|
||||
BinaryNode,
|
||||
type BinaryNode,
|
||||
binaryNodeToString,
|
||||
encodeBinaryNode,
|
||||
getBinaryNodeChild,
|
||||
@@ -178,8 +179,8 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
* @param timeoutMs timeout after which the promise will reject
|
||||
*/
|
||||
const waitForMessage = async <T>(msgId: string, timeoutMs = defaultQueryTimeoutMs) => {
|
||||
let onRecv: (json) => void
|
||||
let onErr: (err) => void
|
||||
let onRecv: (json: any) => void
|
||||
let onErr: (err: Boom | Error) => void
|
||||
try {
|
||||
const result = await promiseTimeout<T>(timeoutMs, (resolve, reject) => {
|
||||
onRecv = resolve
|
||||
@@ -268,8 +269,8 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
},
|
||||
content: [{ tag: 'count', attrs: {} }]
|
||||
})
|
||||
const countChild = getBinaryNodeChild(result, 'count')
|
||||
return +countChild!.attrs.value
|
||||
const countChild = getBinaryNodeChild(result, 'count')!
|
||||
return +countChild.attrs.value!
|
||||
}
|
||||
|
||||
/** generates and uploads a set of pre-keys to the server */
|
||||
@@ -553,7 +554,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
ws.on('open', async () => {
|
||||
try {
|
||||
await validateConnection()
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
logger.error({ err }, 'error in validating connection')
|
||||
end(err)
|
||||
}
|
||||
@@ -571,7 +572,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
attrs: {
|
||||
to: S_WHATSAPP_NET,
|
||||
type: 'result',
|
||||
id: stanza.attrs.id
|
||||
id: stanza.attrs.id!
|
||||
}
|
||||
}
|
||||
await sendNode(iq)
|
||||
@@ -621,7 +622,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
ev.emit('connection.update', { isNewLogin: true, qr: undefined })
|
||||
|
||||
await sendNode(reply)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
logger.info({ trace: error.stack }, 'error in pairing')
|
||||
end(error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user