remove all files

This commit is contained in:
Adhiraj Singh
2021-07-07 23:20:11 +05:30
parent d4189c3d00
commit 5be4a9cc2c
41 changed files with 2256 additions and 4591 deletions

22
src/Types/Auth.ts Normal file
View File

@@ -0,0 +1,22 @@
export interface AuthenticationCredentials {
clientID: string
serverToken: string
clientToken: string
encKey: Buffer
macKey: Buffer
}
export interface AuthenticationCredentialsBase64 {
clientID: string
serverToken: string
clientToken: string
encKey: string
macKey: string
}
export interface AuthenticationCredentialsBrowser {
WABrowserId: string
WASecretBundle: {encKey: string, macKey: string} | string
WAToken1: string
WAToken2: string
}
export type AnyAuthenticationCredentials = AuthenticationCredentialsBrowser | AuthenticationCredentialsBase64 | AuthenticationCredentials

44
src/Types/Chat.ts Normal file
View File

@@ -0,0 +1,44 @@
import type KeyedDB from "@adiwajshing/keyed-db";
import type { proto } from '../../WAMessage/WAMessage'
import type { GroupMetadata } from "./GroupMetadata";
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
export enum Presence {
unavailable = 'unavailable', // "offline"
available = 'available', // "online"
composing = 'composing', // "typing..."
recording = 'recording', // "recording..."
paused = 'paused', // stop typing
}
export interface PresenceData {
lastKnownPresence?: Presence
lastSeen?: number
name?: string
}
export interface Chat {
jid: string
t: number
/** number of unread messages, is < 0 if the chat is manually marked unread */
count: number
archive?: 'true' | 'false'
clear?: 'true' | 'false'
read_only?: 'true' | 'false'
mute?: string
pin?: string
spam?: 'false' | 'true'
modify_tag?: string
name?: string
/** when ephemeral messages were toggled on */
eph_setting_ts?: string
/** how long each message lasts for */
ephemeral?: string
// Baileys added properties
messages: KeyedDB<proto.IWebMessageInfo, string>
imgUrl?: string
presences?: { [k: string]: PresenceData }
metadata?: GroupMetadata
}

15
src/Types/Contact.ts Normal file
View File

@@ -0,0 +1,15 @@
export interface Contact {
verify?: string
/** name of the contact, the contact has set on their own on WA */
notify?: string
jid: string
/** I have no idea */
vname?: string
/** name of the contact, you have saved on your WA */
name?: string
index?: string
/** short name for the contact */
short?: string
// Baileys Added
imgUrl?: string
}

View File

@@ -0,0 +1,19 @@
import { Contact } from "./Contact";
export type GroupParticipant = (Contact & { isAdmin: boolean; isSuperAdmin: boolean })
export interface GroupMetadata {
id: string
owner: string
subject: string
creation: number
desc?: string
descOwner?: string
descId?: string
/** is set when the group only allows admins to change group settings */
restrict?: 'true' | 'false'
/** is set when the group only allows admins to write messages */
announce?: 'true' | 'false'
// Baileys modified array
participants: GroupParticipant[]
}

25
src/Types/Store.ts Normal file
View File

@@ -0,0 +1,25 @@
import type KeyedDB from '@adiwajshing/keyed-db'
import type { Chat } from './Chat'
import type { Contact } from './Contact'
export type WAConnectionState = 'open' | 'connecting' | 'close'
export type ConnectionState = {
user?: Contact
phoneConnected: boolean
phoneInfo?: any
connection: WAConnectionState
lastDisconnect?: {
error: Error,
date: Date
},
isNewLogin?: boolean
connectionTriesLeft?: number
qr?: string
}
export type BaileysState = {
connection: ConnectionState
chats: KeyedDB<Chat, string>
contacts: { [jid: string]: Contact }
}

147
src/Types/index.ts Normal file
View File

@@ -0,0 +1,147 @@
export * from './Auth'
export * from './GroupMetadata'
export * from './Chat'
export * from './Contact'
export * from './Store'
import type EventEmitter from "events"
import type { Agent } from "https"
import type { Logger } from "pino"
import type { URL } from "url"
import type BinaryNode from "../BinaryNode"
import { AnyAuthenticationCredentials } from './Auth'
import { ConnectionState } from './Store'
/** used for binary messages */
export enum WAMetric {
debugLog = 1,
queryResume = 2,
liveLocation = 3,
queryMedia = 4,
queryChat = 5,
queryContact = 6,
queryMessages = 7,
presence = 8,
presenceSubscribe = 9,
group = 10,
read = 11,
chat = 12,
received = 13,
picture = 14,
status = 15,
message = 16,
queryActions = 17,
block = 18,
queryGroup = 19,
queryPreview = 20,
queryEmoji = 21,
queryRead = 22,
queryVCard = 29,
queryStatus = 30,
queryStatusUpdate = 31,
queryLiveLocation = 33,
queryLabel = 36,
queryQuickReply = 39
}
/** used for binary messages */
export enum WAFlag {
available = 160,
other = 136, // don't know this one
ignore = 1 << 7,
acknowledge = 1 << 6,
unavailable = 1 << 4,
expires = 1 << 3,
composing = 1 << 2,
recording = 1 << 2,
paused = 1 << 2
}
/** Tag used with binary queries */
export type WATag = [WAMetric, WAFlag]
export type SocketSendMessageOptions = {
json: BinaryNode | any[]
binaryTag?: WATag
tag?: string
longTag?: boolean
}
export type WAVersion = [number, number, number]
export type WABrowserDescription = [string, string, string]
export type ReconnectMode = 'no-reconnects' | 'on-any-error' | 'on-connection-error'
export type SocketConfig = {
/** the WS url to connect to WA */
waWebSocketUrl: string | URL
/** Fails the connection if the connection times out in this time interval or no data is received */
connectTimeoutMs: number
/** max time for the phone to respond to a connectivity test */
phoneResponseTimeMs: number
/** ping-pong interval for WS connection */
keepAliveIntervalMs: number
expectResponseTimeout: number
/** proxy agent */
agent?: Agent
logger: Logger
version: WAVersion
browser: WABrowserDescription
/** maximum attempts to connect */
maxRetries: number
connectCooldownMs: number
/** agent used for fetch requests -- uploading/downloading media */
fetchAgent?: Agent
/** credentials used to sign back in */
credentials?: AnyAuthenticationCredentials | string
/**
* Sometimes WA does not send the chats,
* this keeps pinging the phone to send the chats over
* */
queryChatsTillReceived?: boolean
/** */
pendingRequestTimeoutMs: number
reconnectMode: ReconnectMode
maxQRCodes: number
/** should the QR be printed in the terminal */
printQRInTerminal: boolean
phoneConnectionChanged: (connected: boolean) => void
}
export type SocketQueryOptions = SocketSendMessageOptions & {
timeoutMs?: number
expect200?: boolean
requiresPhoneConnection?: boolean
}
export enum DisconnectReason {
connectionClosedIntentionally = 428,
connectionReplaced = 440,
connectionLost = 408,
timedOut = 408,
credentialsInvalidated = 401,
badSession = 500
}
export type WAInitResponse = {
ref: string
ttl: number
status: 200
}
export type QueryOptions = SocketQueryOptions & {
waitForOpen?: boolean
maxRetries?: number
startDebouncedTimeout?: boolean
}
export type CurveKeyPair = { private: Uint8Array; public: Uint8Array }
export type BaileysEventMap = {
'connection.update': Partial<ConnectionState>
}
export interface BaileysEventEmitter extends EventEmitter {
on<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): this
emit<T extends keyof BaileysEventMap>(event: T, arg: BaileysEventMap[T]): boolean
}