feat: add signal repository + tests

This commit is contained in:
Adhiraj Singh
2023-03-18 12:25:47 +05:30
parent 2eea17fe9f
commit fe1d0649b5
21 changed files with 500 additions and 206 deletions

View File

@@ -1,5 +1,6 @@
import { proto } from '../../WAProto'
import type { MediaType, SocketConfig } from '../Types'
import { makeLibSignalRepository } from '../Signal/libsignal'
import type { AuthenticationState, MediaType, SocketConfig, WAVersion } from '../Types'
import { Browsers } from '../Utils'
import logger from '../Utils/logger'
import { version } from './baileys-version.json'
@@ -35,7 +36,7 @@ export const PROCESSABLE_HISTORY_TYPES = [
]
export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {
version: version as any,
version: version as WAVersion,
browser: Browsers.baileys('Chrome'),
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
connectTimeoutMs: 20_000,
@@ -47,7 +48,7 @@ export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {
customUploadHosts: [],
retryRequestDelayMs: 250,
fireInitQueries: true,
auth: undefined as any,
auth: undefined as unknown as AuthenticationState,
markOnlineOnConnect: true,
syncFullHistory: false,
patchMessageBeforeSending: msg => msg,
@@ -61,7 +62,8 @@ export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {
patch: false,
snapshot: false,
},
getMessage: async() => undefined
getMessage: async() => undefined,
makeSignalRepository: makeLibSignalRepository
}
export const MEDIA_PATH_MAP: { [T in MediaType]?: string } = {