Skip to content

Commit

Permalink
fix(master): error in init queries
Browse files Browse the repository at this point in the history
  • Loading branch information
PurpShell committed May 6, 2024
1 parent 27d4265 commit fbbb511
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
37 changes: 8 additions & 29 deletions src/Socket/chats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,32 +715,6 @@ export const makeChatsSocket = (config: SocketConfig) => {
}
}

/** sending abt props may fix QR scan fail if server expects */
const fetchAbt = async() => {
const abtNode = await query({
tag: 'iq',
attrs: {
to: S_WHATSAPP_NET,
xmlns: 'abt',
type: 'get',
},
content: [
{ tag: 'props', attrs: { protocol: '1' } }
]
})

const propsNode = getBinaryNodeChild(abtNode, 'props')

let props: { [_: string]: string } = {}
if(propsNode) {
props = reduceBinaryNodeToDictionary(propsNode, 'prop')
}

logger.debug('fetched abt')

return props
}

/** sending non-abt props may fix QR scan fail if server expects */
const fetchProps = async() => {
const resultNode = await query({
Expand All @@ -751,14 +725,20 @@ export const makeChatsSocket = (config: SocketConfig) => {
type: 'get',
},
content: [
{ tag: 'props', attrs: {} }
{ tag: 'props', attrs: {
protocol: 2,

Check failure on line 729 in src/Socket/chats.ts

View workflow job for this annotation

GitHub Actions / update-nightly

Type 'number' is not assignable to type 'string'.
hash: authState?.creds?.lastPropHash || ""
} }
]
})

const propsNode = getBinaryNodeChild(resultNode, 'props')



let props: { [_: string]: string } = {}
if(propsNode) {
authState?.creds?.lastPropHash = propsNode?.attrs?.hash

Check failure on line 740 in src/Socket/chats.ts

View workflow job for this annotation

GitHub Actions / update-nightly

The left-hand side of an assignment expression may not be an optional property access.
ev.emit('creds.update', authState.creds)
props = reduceBinaryNodeToDictionary(propsNode, 'prop')
}

Expand Down Expand Up @@ -841,7 +821,6 @@ export const makeChatsSocket = (config: SocketConfig) => {
* */
const executeInitQueries = async() => {
await Promise.all([
fetchAbt(),
fetchProps(),
fetchBlocklist(),
fetchPrivacySettings(),
Expand Down
1 change: 1 addition & 0 deletions src/Types/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type AuthenticationCreds = SignalCreds & {
backupToken: Buffer
registration: RegistrationOptions
pairingCode: string | undefined
lastPropHash: string | undefined
}

export type SignalDataTypeMap = {
Expand Down
1 change: 1 addition & 0 deletions src/Utils/auth-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,6 @@ export const initAuthCreds = (): AuthenticationCreds => {
backupToken: randomBytes(20),
registration: {} as never,
pairingCode: undefined,
lastPropHash: undefined,
}
}

0 comments on commit fbbb511

Please sign in to comment.