feat: implement getAuthenticationCredsType

This commit is contained in:
Adhiraj Singh
2022-01-08 11:27:19 +05:30
parent a0003f0fe9
commit 127e21b920

View File

@@ -3,7 +3,7 @@ import { randomBytes } from 'crypto'
import { decodeBinaryNodeLegacy, jidNormalizedUser } from "../WABinary"
import { aesDecrypt, hmacSign, hkdf, Curve } from "./crypto"
import { BufferJSON } from './generics'
import { DisconnectReason, WATag, LegacyAuthenticationCreds, CurveKeyPair, Contact } from "../Types"
import { DisconnectReason, WATag, LegacyAuthenticationCreds, AuthenticationCreds, CurveKeyPair, Contact } from "../Types"
export const newLegacyAuthCreds = () => ({
clientID: randomBytes(16).toString('base64')
@@ -173,4 +173,13 @@ export const useSingleFileLegacyAuthState = (file: string) => {
writeFileSync(file, str)
}
}
}
export const getAuthenticationCredsType = (creds: LegacyAuthenticationCreds | AuthenticationCreds) => {
if('clientID' in creds && !!creds.clientID) {
return 'legacy'
}
if('noiseKey' in creds && !!creds.noiseKey) {
return 'md'
}
}