mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
chore: make "auth" mandatory in SocketConfig
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { DEFAULT_CONNECTION_CONFIG } from '../Defaults'
|
||||
import { SocketConfig } from '../Types'
|
||||
import { UserFacingSocketConfig } from '../Types'
|
||||
import { makeBusinessSocket as _makeSocket } from './business'
|
||||
|
||||
// export the last socket layer
|
||||
const makeWASocket = (config: Partial<SocketConfig>) => (
|
||||
const makeWASocket = (config: UserFacingSocketConfig) => (
|
||||
_makeSocket({
|
||||
...DEFAULT_CONNECTION_CONFIG,
|
||||
...config
|
||||
|
||||
@@ -5,7 +5,7 @@ import WebSocket from 'ws'
|
||||
import { proto } from '../../WAProto'
|
||||
import { DEF_CALLBACK_PREFIX, DEF_TAG_PREFIX, DEFAULT_ORIGIN, INITIAL_PREKEY_COUNT, MIN_PREKEY_COUNT } from '../Defaults'
|
||||
import { AuthenticationCreds, BaileysEventEmitter, BaileysEventMap, DisconnectReason, SocketConfig } from '../Types'
|
||||
import { addTransactionCapability, bindWaitForConnectionUpdate, configureSuccessfulPairing, Curve, generateLoginNode, generateMdTagPrefix, generateRegistrationNode, getErrorCodeFromStreamError, getNextPreKeysNode, makeNoiseHandler, printQRIfNecessaryListener, promiseTimeout, useSingleFileAuthState } from '../Utils'
|
||||
import { addTransactionCapability, bindWaitForConnectionUpdate, configureSuccessfulPairing, Curve, generateLoginNode, generateMdTagPrefix, generateRegistrationNode, getErrorCodeFromStreamError, getNextPreKeysNode, makeNoiseHandler, printQRIfNecessaryListener, promiseTimeout } from '../Utils'
|
||||
import { assertNodeErrorFree, BinaryNode, encodeBinaryNode, getBinaryNodeChild, getBinaryNodeChildren, S_WHATSAPP_NET } from '../WABinary'
|
||||
|
||||
/**
|
||||
@@ -22,7 +22,7 @@ export const makeSocket = ({
|
||||
keepAliveIntervalMs,
|
||||
version,
|
||||
browser,
|
||||
auth: initialAuthState,
|
||||
auth: authState,
|
||||
printQRInTerminal,
|
||||
defaultQueryTimeoutMs,
|
||||
transactionOpts
|
||||
@@ -39,16 +39,6 @@ export const makeSocket = ({
|
||||
const ephemeralKeyPair = Curve.generateKeyPair()
|
||||
/** WA noise protocol wrapper */
|
||||
const noise = makeNoiseHandler(ephemeralKeyPair, logger)
|
||||
let authState = initialAuthState
|
||||
if(!authState) {
|
||||
authState = useSingleFileAuthState('./auth-info-multi.json').state
|
||||
|
||||
logger.warn(`
|
||||
Baileys just created a single file state for your credentials.
|
||||
This will not be supported soon.
|
||||
Please pass the credentials in the config itself
|
||||
`)
|
||||
}
|
||||
|
||||
const { creds } = authState
|
||||
// add transaction capability
|
||||
|
||||
@@ -37,6 +37,8 @@ export type SocketConfig = CommonSocketConfig<AuthenticationState> & {
|
||||
getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>
|
||||
}
|
||||
|
||||
export type UserFacingSocketConfig = Partial<SocketConfig> & { auth: AuthenticationState }
|
||||
|
||||
export enum DisconnectReason {
|
||||
connectionClosed = 428,
|
||||
connectionLost = 408,
|
||||
|
||||
Reference in New Issue
Block a user