chore: lint and re-organize
This commit is contained in:
+11
-2
@@ -5,7 +5,15 @@ import type { LIDMapping, SignalAuthState, SignalKeyStoreWithTransaction } from
|
||||
import type { SignalRepositoryWithLIDStore } from '../Types/Signal'
|
||||
import { generateSignalPubKey } from '../Utils'
|
||||
import type { ILogger } from '../Utils/logger'
|
||||
import { isHostedLidUser, isHostedPnUser, isLidUser, isPnUser, jidDecode, transferDevice, WAJIDDomains } from '../WABinary'
|
||||
import {
|
||||
isHostedLidUser,
|
||||
isHostedPnUser,
|
||||
isLidUser,
|
||||
isPnUser,
|
||||
jidDecode,
|
||||
transferDevice,
|
||||
WAJIDDomains
|
||||
} from '../WABinary'
|
||||
import type { SenderKeyStore } from './Group/group_cipher'
|
||||
import { SenderKeyName } from './Group/sender-key-name'
|
||||
import { SenderKeyRecord } from './Group/sender-key-record'
|
||||
@@ -223,9 +231,10 @@ export function makeLibSignalRepository(
|
||||
if (!deviceStr) continue
|
||||
const deviceNum = parseInt(deviceStr)
|
||||
let jid = deviceNum === 0 ? `${user}@s.whatsapp.net` : `${user}:${deviceNum}@s.whatsapp.net`
|
||||
if (deviceNum == 99) {
|
||||
if (deviceNum === 99) {
|
||||
jid = `${user}:99@hosted`
|
||||
}
|
||||
|
||||
deviceJids.push(jid)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
import { LRUCache } from 'lru-cache'
|
||||
import type { LIDMapping, SignalKeyStoreWithTransaction } from '../Types'
|
||||
import type { ILogger } from '../Utils/logger'
|
||||
import {
|
||||
isHostedLidUser,
|
||||
isHostedPnUser,
|
||||
isLidUser,
|
||||
isPnUser,
|
||||
jidDecode,
|
||||
jidNormalizedUser,
|
||||
WAJIDDomains
|
||||
} from '../WABinary'
|
||||
import { isHostedPnUser, isLidUser, isPnUser, jidDecode, jidNormalizedUser, WAJIDDomains } from '../WABinary'
|
||||
|
||||
export class LIDMappingStore {
|
||||
private readonly mappingCache = new LRUCache<string, string>({
|
||||
|
||||
@@ -11,7 +11,6 @@ import type {
|
||||
MessageUserReceipt,
|
||||
SocketConfig,
|
||||
WACallEvent,
|
||||
WACallUpdateType,
|
||||
WAMessage,
|
||||
WAMessageKey,
|
||||
WAPatchName
|
||||
@@ -1278,9 +1277,9 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
const handleCall = async (node: BinaryNode) => {
|
||||
let status: WACallUpdateType
|
||||
const { attrs } = node
|
||||
const [infoChild] = getAllBinaryNodeChildren(node)
|
||||
const status = getCallStatusFromNode(infoChild!)
|
||||
|
||||
if (!infoChild) {
|
||||
throw new Boom('Missing call info in call node')
|
||||
@@ -1288,7 +1287,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
|
||||
const callId = infoChild.attrs['call-id']!
|
||||
const from = infoChild.attrs.from! || infoChild.attrs['call-creator']!
|
||||
status = getCallStatusFromNode(infoChild)
|
||||
|
||||
const call: WACallEvent = {
|
||||
chatId: attrs.from!,
|
||||
|
||||
@@ -42,7 +42,6 @@ import {
|
||||
type FullJid,
|
||||
getBinaryNodeChild,
|
||||
getBinaryNodeChildren,
|
||||
getServerFromDomainType,
|
||||
isHostedLidUser,
|
||||
isHostedPnUser,
|
||||
isJidGroup,
|
||||
@@ -51,7 +50,6 @@ import {
|
||||
jidDecode,
|
||||
jidEncode,
|
||||
jidNormalizedUser,
|
||||
type JidServer,
|
||||
type JidWithDevice,
|
||||
S_WHATSAPP_NET
|
||||
} from '../WABinary'
|
||||
@@ -408,7 +406,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
...jidsRequiringFetch.filter(jid => !!isLidUser(jid) || !!isHostedLidUser(jid)),
|
||||
...(
|
||||
(await signalRepository.lidMapping.getLIDsForPNs(
|
||||
jidsRequiringFetch.filter(jid => !!isPnUser(jid) || !!isHostedPnUser(jid)
|
||||
jidsRequiringFetch.filter(jid => !!isPnUser(jid) || !!isHostedPnUser(jid))
|
||||
)) || []
|
||||
).map(a => a.lid)
|
||||
]
|
||||
|
||||
@@ -112,7 +112,7 @@ export const makeNoiseHandler = ({
|
||||
|
||||
const certDecoded = decrypt(serverHello!.payload!)
|
||||
|
||||
const { intermediate: certIntermediate, leaf } = proto.CertChain.decode(certDecoded)
|
||||
const { intermediate: certIntermediate /*leaf*/ } = proto.CertChain.decode(certDecoded)
|
||||
// TODO: handle this leaf stuff
|
||||
const { issuerSerial } = proto.CertChain.NoiseCertificate.Details.decode(certIntermediate!.details!)
|
||||
|
||||
|
||||
+19
-22
@@ -143,30 +143,27 @@ export const extractDeviceJids = (
|
||||
|
||||
for (const userResult of result) {
|
||||
const { devices, id } = userResult as { devices: ParsedDeviceInfo; id: string }
|
||||
let { user, domainType, server } = jidDecode(id)!
|
||||
const decoded = jidDecode(id)!,
|
||||
{ user, server } = decoded
|
||||
let { domainType } = decoded
|
||||
const deviceList = devices?.deviceList as DeviceListData[]
|
||||
if (Array.isArray(deviceList)) {
|
||||
for (const { id: device, keyIndex, isHosted } of deviceList) {
|
||||
if (
|
||||
(!excludeZeroDevices || device !== 0) && // if zero devices are not-excluded, or device is non zero
|
||||
((myUser !== user && myLid !== user) || myDevice !== device) && // either different user or if me user, not this device
|
||||
(device === 0 || !!keyIndex) // ensure that "key-index" is specified for "non-zero" devices, produces a bad req otherwise
|
||||
) {
|
||||
if (isHosted) {
|
||||
if (domainType === WAJIDDomains.LID) {
|
||||
domainType = WAJIDDomains.HOSTED_LID
|
||||
} else {
|
||||
domainType = WAJIDDomains.HOSTED
|
||||
}
|
||||
}
|
||||
|
||||
extracted.push({
|
||||
user,
|
||||
device,
|
||||
domainType,
|
||||
server: getServerFromDomainType(server, domainType)
|
||||
})
|
||||
if (!Array.isArray(deviceList)) continue
|
||||
for (const { id: device, keyIndex, isHosted } of deviceList) {
|
||||
if (
|
||||
(!excludeZeroDevices || device !== 0) && // if zero devices are not-excluded, or device is non zero
|
||||
((myUser !== user && myLid !== user) || myDevice !== device) && // either different user or if me user, not this device
|
||||
(device === 0 || !!keyIndex) // ensure that "key-index" is specified for "non-zero" devices, produces a bad req otherwise
|
||||
) {
|
||||
if (isHosted) {
|
||||
domainType = domainType === WAJIDDomains.LID ? WAJIDDomains.HOSTED_LID : WAJIDDomains.HOSTED
|
||||
}
|
||||
|
||||
extracted.push({
|
||||
user,
|
||||
device,
|
||||
domainType,
|
||||
server: getServerFromDomainType(server, domainType)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user