diff --git a/src/Socket/index.ts b/src/Socket/index.ts index 455034f..7efebf0 100644 --- a/src/Socket/index.ts +++ b/src/Socket/index.ts @@ -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) => ( +const makeWASocket = (config: UserFacingSocketConfig) => ( _makeSocket({ ...DEFAULT_CONNECTION_CONFIG, ...config diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts index 68ce521..bdd8b7b 100644 --- a/src/Socket/socket.ts +++ b/src/Socket/socket.ts @@ -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 diff --git a/src/Types/index.ts b/src/Types/index.ts index dcae594..297b49c 100644 --- a/src/Types/index.ts +++ b/src/Types/index.ts @@ -37,6 +37,8 @@ export type SocketConfig = CommonSocketConfig & { getMessage: (key: proto.IMessageKey) => Promise } +export type UserFacingSocketConfig = Partial & { auth: AuthenticationState } + export enum DisconnectReason { connectionClosed = 428, connectionLost = 408,