mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Cleanup + add remaining utils
This commit is contained in:
5
src/Utils/index.ts
Normal file
5
src/Utils/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './decode-wa-message'
|
||||
export * from './generics'
|
||||
export * from './messages'
|
||||
export * from './messages-media'
|
||||
export * from './validate-connection'
|
||||
@@ -220,9 +220,6 @@ export const generateWAMessageContent = async(
|
||||
options: MessageContentGenerationOptions
|
||||
) => {
|
||||
let m: WAMessageContent = {}
|
||||
if(typeof message === 'string') {
|
||||
message = { text: message }
|
||||
}
|
||||
if('text' in message) {
|
||||
const extContent = { ...message } as WATextMessage
|
||||
if (!!options.getUrlInfo && message.text.match(URL_REGEX)) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Boom} from '@hapi/boom'
|
||||
import * as Curve from 'curve25519-js'
|
||||
import type { Contact } from '../Types/Contact'
|
||||
import type { AnyAuthenticationCredentials, AuthenticationCredentials, CurveKeyPair } from "../Types"
|
||||
import type { AnyAuthenticationCredentials, AuthenticationCredentials, AuthenticationCredentialsBase64, CurveKeyPair } from "../Types"
|
||||
import { aesDecrypt, hkdf, hmacSign, whatsappID } from './generics'
|
||||
import { readFileSync } from 'fs'
|
||||
|
||||
@@ -32,6 +32,16 @@ export const normalizedAuthInfo = (authInfo: AnyAuthenticationCredentials | stri
|
||||
}
|
||||
return authInfo as AuthenticationCredentials
|
||||
}
|
||||
|
||||
export const base64EncodedAuthenticationCredentials = (creds: AnyAuthenticationCredentials) => {
|
||||
const normalized = normalizedAuthInfo(creds)
|
||||
return {
|
||||
...normalized,
|
||||
encKey: normalized.encKey.toString('base64'),
|
||||
macKey: normalized.macKey.toString('base64')
|
||||
} as AuthenticationCredentialsBase64
|
||||
}
|
||||
|
||||
/**
|
||||
* Once the QR code is scanned and we can validate our connection, or we resolved the challenge when logging back in
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user