cleanup: remove string lid / jid refs and improve hosted support
This commit is contained in:
@@ -19,8 +19,8 @@ import {
|
||||
import { unpadRandomMax16 } from './generics'
|
||||
import type { ILogger } from './logger'
|
||||
|
||||
const getDecryptionJid = async (sender: string, repository: SignalRepositoryWithLIDStore): Promise<string> => {
|
||||
if (sender.includes('@lid')) {
|
||||
export const getDecryptionJid = async (sender: string, repository: SignalRepositoryWithLIDStore): Promise<string> => {
|
||||
if (isLidUser(sender) || isHostedLidUser(sender)) {
|
||||
return sender
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ const storeMappingFromEnvelope = async (
|
||||
decryptionJid: string,
|
||||
logger: ILogger
|
||||
): Promise<void> => {
|
||||
// TODO: Handle hosted IDs
|
||||
const { senderAlt } = extractAddressingContext(stanza)
|
||||
|
||||
if (senderAlt && isLidUser(senderAlt) && isPnUser(sender) && decryptionJid === sender) {
|
||||
@@ -259,12 +260,11 @@ export const decryptMessageNode = (
|
||||
|
||||
let msgBuffer: Uint8Array
|
||||
|
||||
const user = isPnUser(sender) ? sender : author // TODO: flaky logic
|
||||
|
||||
const decryptionJid = await getDecryptionJid(user, repository)
|
||||
const decryptionJid = await getDecryptionJid(author, repository)
|
||||
|
||||
if (tag !== 'plaintext') {
|
||||
await storeMappingFromEnvelope(stanza, user, repository, decryptionJid, logger)
|
||||
// TODO: Handle hosted devices
|
||||
await storeMappingFromEnvelope(stanza, author, repository, decryptionJid, logger)
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -112,8 +112,8 @@ export const makeNoiseHandler = ({
|
||||
|
||||
const certDecoded = decrypt(serverHello!.payload!)
|
||||
|
||||
const { intermediate: certIntermediate } = 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!)
|
||||
|
||||
if (issuerSerial !== WA_CERT_DETAILS.SERIAL) {
|
||||
|
||||
Reference in New Issue
Block a user