project: Move to ESM Modules
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { assertNodeErrorFree, BinaryNode } from '../../WABinary'
|
||||
import type { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { assertNodeErrorFree, type BinaryNode } from '../../WABinary'
|
||||
import { USyncUser } from '../USyncUser'
|
||||
|
||||
export class USyncContactProtocol implements USyncQueryProtocol {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { assertNodeErrorFree, BinaryNode, getBinaryNodeChild } from '../../WABinary'
|
||||
import type { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { assertNodeErrorFree, type BinaryNode, getBinaryNodeChild } from '../../WABinary'
|
||||
//import { USyncUser } from '../USyncUser'
|
||||
|
||||
export type KeyIndexData = {
|
||||
@@ -49,8 +49,8 @@ export class USyncDeviceProtocol implements USyncQueryProtocol {
|
||||
|
||||
if (Array.isArray(deviceListNode?.content)) {
|
||||
for (const { tag, attrs } of deviceListNode.content) {
|
||||
const id = +attrs.id
|
||||
const keyIndex = +attrs['key-index']
|
||||
const id = +attrs.id!
|
||||
const keyIndex = +attrs['key-index']!
|
||||
if (tag === 'device') {
|
||||
deviceList.push({
|
||||
id,
|
||||
@@ -63,7 +63,7 @@ export class USyncDeviceProtocol implements USyncQueryProtocol {
|
||||
|
||||
if (keyIndexNode?.tag === 'key-index-list') {
|
||||
keyIndex = {
|
||||
timestamp: +keyIndexNode.attrs['ts'],
|
||||
timestamp: +keyIndexNode.attrs['ts']!,
|
||||
signedKeyIndex: keyIndexNode?.content as Uint8Array,
|
||||
expectedTimestamp: keyIndexNode.attrs['expected_ts'] ? +keyIndexNode.attrs['expected_ts'] : undefined
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { assertNodeErrorFree, BinaryNode } from '../../WABinary'
|
||||
import type { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { assertNodeErrorFree, type BinaryNode } from '../../WABinary'
|
||||
|
||||
export type DisappearingModeData = {
|
||||
duration: number
|
||||
@@ -23,7 +23,7 @@ export class USyncDisappearingModeProtocol implements USyncQueryProtocol {
|
||||
parser(node: BinaryNode): DisappearingModeData | undefined {
|
||||
if (node.tag === 'disappearing_mode') {
|
||||
assertNodeErrorFree(node)
|
||||
const duration: number = +node?.attrs.duration
|
||||
const duration: number = +node?.attrs.duration!
|
||||
const setAt = new Date(+(node?.attrs.t || 0) * 1000)
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { assertNodeErrorFree, BinaryNode } from '../../WABinary'
|
||||
import type { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { assertNodeErrorFree, type BinaryNode } from '../../WABinary'
|
||||
|
||||
export type StatusData = {
|
||||
status?: string | null
|
||||
@@ -26,7 +26,7 @@ export class USyncStatusProtocol implements USyncQueryProtocol {
|
||||
let status: string | null = node?.content?.toString() ?? null
|
||||
const setAt = new Date(+(node?.attrs.t || 0) * 1000)
|
||||
if (!status) {
|
||||
if (+node.attrs?.code === 401) {
|
||||
if (node.attrs?.code && +node.attrs.code === 401) {
|
||||
status = ''
|
||||
} else {
|
||||
status = null
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from '../../WABinary'
|
||||
import type { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { type BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from '../../WABinary'
|
||||
import { USyncUser } from '../USyncUser'
|
||||
|
||||
export type BotProfileCommand = {
|
||||
@@ -35,7 +35,7 @@ export class USyncBotProfileProtocol implements USyncQueryProtocol {
|
||||
return {
|
||||
tag: 'bot',
|
||||
attrs: {},
|
||||
content: [{ tag: 'profile', attrs: { persona_id: user.personaId } }]
|
||||
content: [{ tag: 'profile', attrs: { persona_id: user.personaId! } }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,12 +62,12 @@ export class USyncBotProfileProtocol implements USyncQueryProtocol {
|
||||
|
||||
return {
|
||||
isDefault: !!getBinaryNodeChild(profile, 'default'),
|
||||
jid: node.attrs.jid,
|
||||
jid: node.attrs.jid!,
|
||||
name: getBinaryNodeChildString(profile, 'name')!,
|
||||
attributes: getBinaryNodeChildString(profile, 'attributes')!,
|
||||
description: getBinaryNodeChildString(profile, 'description')!,
|
||||
category: getBinaryNodeChildString(profile, 'category')!,
|
||||
personaId: profile!.attrs['persona_id'],
|
||||
personaId: profile!.attrs['persona_id']!,
|
||||
commandsDescription: getBinaryNodeChildString(commandsNode, 'description')!,
|
||||
commands,
|
||||
prompts
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { BinaryNode } from '../../WABinary'
|
||||
import type { USyncQueryProtocol } from '../../Types/USync'
|
||||
import type { BinaryNode } from '../../WABinary'
|
||||
|
||||
export class USyncLIDProtocol implements USyncQueryProtocol {
|
||||
name = 'lid'
|
||||
@@ -17,7 +17,7 @@ export class USyncLIDProtocol implements USyncQueryProtocol {
|
||||
|
||||
parser(node: BinaryNode): string | null {
|
||||
if (node.tag === 'lid') {
|
||||
return node.attrs.val
|
||||
return node.attrs.val!
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user