-
-
Notifications
You must be signed in to change notification settings - Fork 300
/
create-config.ts
197 lines (184 loc) · 5.3 KB
/
create-config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
* This file is part of WPPConnect.
*
* WPPConnect is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WPPConnect is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
*/
import { Browser, BrowserContext, Page, launch } from 'puppeteer';
import { Logger } from 'winston';
import { SessionToken, TokenStore } from '../token-store';
import { defaultLogger } from '../utils/logger';
// Server config
export interface CreateConfig {
/**
* Headless chrome
* @default true
*/
headless?: boolean;
/**
* Open devtools by default
* @default false
*/
devtools?: boolean;
/**
* If false will use Chromium instance
* @default true
*/
useChrome?: boolean;
/**
* Opens a debug session
* @default false
*/
debug?: boolean;
/**
* If you want to use browserWSEndpoint
*/
browserWS?: string;
/**
* Parameters to be added into the chrome browser instance
*/
browserArgs?: string[];
/**
* Will be passed to puppeteer.launch
*/
puppeteerOptions?: Parameters<typeof launch>[0];
/**
* Pass a external browser instance, can be used with electron
*/
browser?: Browser | BrowserContext;
/**
* Pass a external page instance, can be used with electron
*/
page?: Page;
/**
* Logs QR automatically in terminal
* @default true
*/
logQR?: boolean;
/**
* Will disable the welcoming message which appears in the beginning
* @default false
*/
disableWelcome?: boolean;
/**
* Logs info updates automatically in terminal
* @default true
*/
updatesLog?: boolean;
/**
* Automatically closes the wppconnect only when scanning the QR code (default 60000 miliseconds, if you want to turn it off, assign 0 or false)
* @default 60000
*/
autoClose?: number;
/**
* Automatically closes the wppconnect only when is syncing the device (default 180000 miliseconds, 3 minutes, if you want to turn it off, assign 0 or false)
* @default 180000 (3 minutes)
*/
deviceSyncTimeout?: number;
/**
* Wait for in chat to return a instance of {@link Whatsapp}
* @default false
*/
waitForLogin?: boolean;
/**
* Wait for in chat to return a instance of {@link Whatsapp}
* @default false
*/
logger?: Logger;
/**
* Initial token to log in in WhatsApp.
* If not passed, the client will get it from {@link tokenStore}.
* @deprecated
*/
sessionToken?: SessionToken;
/**
* Token store used to manage token {@link tokenStore}
* @default 'file'
* @deprecated
*/
tokenStore?: TokenStore | string;
/** Folder name when saving tokens if {@link tokenStore} is 'file'.
* @default 'tokens'
*/
folderNameToken?: string;
/**
* folder directory tokens, just inside the wppconnect folder, example: { mkdirFolderToken: '/node_modules', } //will save the tokens folder in the node_modules directory
* @deprecated See {@link tokenStore}
*/
mkdirFolderToken?: string;
/**
* Creates a folder when inserting an object in the client's browser, to work it is necessary to pass the parameters in the function create browserSessionToken
* @deprecated See {@link tokenStore}
* @default true
*/
createPathFileToken?: boolean;
/**
* Quando definido, essa opção força o carregamento de uma versão específica do WhatsApp WEB
* Normalmente, versões mais antigas continuam funcionando por mais um tempo,
* assim, com essa opção, é possível ter uma janela de tempo maior para se preparar para atualizações.
* Caso seja definido vazio ou null, será usado a versão atual, ou seja, sem forçar versão específica.
* @default 2.2134.x
*/
whatsappVersion?: string;
/**
* Define the connected device name in WhatsApp app
* @default 'WPPConnect'
*/
deviceName?: string | false;
/**
* Set custom Link Preview API servers
* @default null
*/
linkPreviewApiServers?: string[] | null;
/**
* Disable custom Google Analytics
* @default true
*/
disableGoogleAnalytics?: boolean;
/**
* Custom Google Analytics Tracker Id, like 'G-XXXXXXXXXX'
* collect analytics data to your GA account
* @default null
*/
googleAnalyticsId?: string | null;
/**
* Custom variable for Google Analytics
* @default 'WPPConnect'
*/
poweredBy?: string;
}
export const defaultOptions: CreateConfig = {
folderNameToken: './tokens',
headless: true,
devtools: false,
useChrome: true,
debug: false,
logQR: true,
browserWS: '',
browserArgs: [''],
puppeteerOptions: {},
disableWelcome: false,
updatesLog: true,
autoClose: 60000,
deviceSyncTimeout: 180000,
createPathFileToken: true,
waitForLogin: true,
logger: defaultLogger,
tokenStore: 'file',
whatsappVersion: '2.2307.x',
deviceName: false,
linkPreviewApiServers: null,
disableGoogleAnalytics: true,
googleAnalyticsId: null,
poweredBy: 'WPPConnect',
};