sender-key: credit original fix and fix key handling
This commit is contained in:
@@ -11,11 +11,13 @@ export class SenderChainKey {
|
|||||||
constructor(iteration: number, chainKey: any) {
|
constructor(iteration: number, chainKey: any) {
|
||||||
this.iteration = iteration
|
this.iteration = iteration
|
||||||
if (Buffer.isBuffer(chainKey)) {
|
if (Buffer.isBuffer(chainKey)) {
|
||||||
|
// backported from @MartinSchere's PR
|
||||||
this.chainKey = chainKey
|
this.chainKey = chainKey
|
||||||
} else if (chainKey instanceof Uint8Array) {
|
} else if (chainKey instanceof Uint8Array) {
|
||||||
this.chainKey = Buffer.from(chainKey)
|
this.chainKey = Buffer.from(chainKey)
|
||||||
} else if (chainKey && typeof chainKey === 'object') {
|
} else if (chainKey && typeof chainKey === 'object') {
|
||||||
this.chainKey = Buffer.from(Object.values(chainKey))
|
// backported from @MartinSchere (#1741)
|
||||||
|
this.chainKey = Buffer.from(Object.values(chainKey)) // temp fix // backported from @MartinSchere (#1741)
|
||||||
} else {
|
} else {
|
||||||
this.chainKey = Buffer.alloc(0)
|
this.chainKey = Buffer.alloc(0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,11 +99,13 @@ export class SenderKeyState {
|
|||||||
let key = this.senderKeyStateStructure.senderSigningKey.public
|
let key = this.senderKeyStateStructure.senderSigningKey.public
|
||||||
|
|
||||||
// normalize into Buffer
|
// normalize into Buffer
|
||||||
if (!(key instanceof Buffer)) {
|
if (!Buffer.isBuffer(key)) {
|
||||||
if (key instanceof Uint8Array) {
|
if (key instanceof Uint8Array) {
|
||||||
key = Buffer.from(key)
|
key = Buffer.from(key)
|
||||||
} else if (typeof key === 'string') {
|
} else if (typeof key === 'string') {
|
||||||
key = Buffer.from(key, 'base64')
|
key = Buffer.from(key, 'base64')
|
||||||
|
} else if (key && typeof key === 'object') {
|
||||||
|
return Buffer.from(Object.values(key)) // temp fix // inspired by @MartinSchere 's #1741
|
||||||
} else {
|
} else {
|
||||||
key = Buffer.from(key || [])
|
key = Buffer.from(key || [])
|
||||||
}
|
}
|
||||||
@@ -127,10 +129,12 @@ export class SenderKeyState {
|
|||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
if (privateKey instanceof Buffer) {
|
if (Buffer.isBuffer(privateKey)) {
|
||||||
return privateKey
|
return privateKey
|
||||||
} else if (privateKey instanceof Uint8Array) {
|
} else if (privateKey instanceof Uint8Array) {
|
||||||
return Buffer.from(privateKey)
|
return Buffer.from(privateKey)
|
||||||
|
} else if (privateKey && typeof privateKey === 'object') {
|
||||||
|
return Buffer.from(Object.values(privateKey)) // temp fix // inspired by @MartinSchere 's #1741
|
||||||
} else if (typeof privateKey === 'string') {
|
} else if (typeof privateKey === 'string') {
|
||||||
return Buffer.from(privateKey, 'base64')
|
return Buffer.from(privateKey, 'base64')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1120,7 +1120,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
if (getBinaryNodeChild(node, 'unavailable') && !encNode) {
|
if (getBinaryNodeChild(node, 'unavailable') && !encNode) {
|
||||||
await sendMessageAck(node)
|
await sendMessageAck(node)
|
||||||
const { key } = decodeMessageNode(node, authState.creds.me!.id, authState.creds.me!.lid || '').fullMessage
|
const { key } = decodeMessageNode(node, authState.creds.me!.id, authState.creds.me!.lid || '').fullMessage
|
||||||
response = await requestPlaceholderResend(key)
|
response = await requestPlaceholderResend(key) // TODO: DEPRECATE THIS LOGIC AND PASS IT OFF TO THE RETRY MANAGER
|
||||||
if (response === 'RESOLVED') {
|
if (response === 'RESOLVED') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user