Files
InfiniteAPI/src/Utils/tc-token-utils.ts
T
Rajeh Taher b62cb40a70 chore: lint
2026-01-18 17:16:28 +02:00

35 lines
758 B
TypeScript

import type { SignalKeyStoreWithTransaction } from '../Types'
import type { BinaryNode } from '../WABinary'
type TcTokenParams = {
jid: string
baseContent?: BinaryNode[]
authState: {
keys: SignalKeyStoreWithTransaction
}
}
export async function buildTcTokenFromJid({
authState,
jid,
baseContent = []
}: TcTokenParams): Promise<BinaryNode[] | undefined> {
try {
const tcTokenData = await authState.keys.get('tctoken', [jid])
const tcTokenBuffer = tcTokenData?.[jid]?.token
if (!tcTokenBuffer) return baseContent.length > 0 ? baseContent : undefined
baseContent.push({
tag: 'tctoken',
attrs: {},
content: tcTokenBuffer
})
return baseContent
} catch (error) {
return baseContent.length > 0 ? baseContent : undefined
}
}