@open-wa/wa-automate 4.22.3 → 4.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +7 -2
- package/bin/config-schema.json +1 -1
- package/dist/api/Client.d.ts +3 -3
- package/dist/api/Client.js +16 -14
- package/dist/api/model/config.d.ts +5 -0
- package/dist/cli/server.js +15 -1
- package/dist/controllers/initializer.js +14 -5
- package/dist/controllers/popup/index.html +4 -3
- package/package.json +2 -2
package/LICENSE.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### Copyright (c) 2020 Mohammed Shah
|
2
2
|
|
3
|
-
# Hippocratic + Do Not Harm (H-DNH) Version 1.
|
3
|
+
# Hippocratic + Do Not Harm (H-DNH) Version 1.1
|
4
4
|
|
5
5
|
## Preamble
|
6
6
|
|
@@ -34,6 +34,11 @@ Licensor hereby grants permission by this license ("License"), free of charge,
|
|
34
34
|
* warfare
|
35
35
|
* weapons manufacturing
|
36
36
|
* war crimes
|
37
|
+
* settler colonialism
|
38
|
+
* apartheid
|
39
|
+
* vaccine misinformation
|
40
|
+
* climate misinformation
|
41
|
+
* child endangerment
|
37
42
|
* violence (except when required to protect public safety)
|
38
43
|
* burning of forests
|
39
44
|
* deforestation
|
@@ -59,4 +64,4 @@ Licensor hereby grants permission by this license ("License"), free of charge,
|
|
59
64
|
|
60
65
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
61
66
|
|
62
|
-
This license is an extension of the Hippocratic License - an Ethical Source license (https://ethicalsource.dev) and the Do Not Harm License - (https://github.com/raisely/NoHarm)
|
67
|
+
This license is an extension of the Hippocratic License - an Ethical Source license (https://ethicalsource.dev) and the Do Not Harm License - (https://github.com/raisely/NoHarm)
|
package/bin/config-schema.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[{"env":"WA_SESSION_DATA","p":"session-data","description":"The base64 encoded sessionData used to restore a session.","type":"string","key":"sessionData"},{"env":"WA_BROWSER_WS_ENDPOINT","p":"browser-ws-endpoint","type":"string","description":"ALPHA EXPERIMENTAL FEATURE! DO NOT USE IN PRODUCTION, REQUIRES TESTING.\n\nLearn more:\n\nhttps://pptr.dev/#?product=Puppeteer&version=v3.1.0&show=api-puppeteerconnectoptions\n\nhttps://medium.com/@jaredpotter1/connecting-puppeteer-to-existing-chrome-window-8a10828149e0","key":"browserWSEndpoint"},{"env":"WA_SESSION_DATA_PATH","p":"session-data-path","type":"string","description":"The path relative to the current working directory (i.e where you run the command to start your process). This will be used to store and read your `.data.json` files. defualt to ''","key":"sessionDataPath"},{"env":"WA_SKIP_UPDATE_CHECK","p":"skip-update-check","type":"boolean","description":"If set to true, `skipUpdateCheck` will bypass the latest version check. This saves some time on boot (around 150 ms).","key":"skipUpdateCheck"},{"env":"WA_SESSION_ID","p":"session-id","type":"string","description":"This is the name of the session. You have to make sure that this is unique for every session.","key":"sessionId"},{"env":"WA_LICENSE_KEY","p":"license-key","description":"The license key to use with the session.","type":"string","key":"licenseKey"},{"env":"WA_CUSTOM_USER_AGENT","p":"custom-user-agent","type":"string","description":"You may set a custom user agent. However, due to recent developments, this is not really neccessary any more.","key":"customUserAgent"},{"env":"WA_BLOCK_CRASH_LOGS","p":"block-crash-logs","type":"boolean","description":"Setting this to true will block any network calls to crash log servers. This should keep anything you do under the radar.","key":"blockCrashLogs"},{"env":"WA_CACHE_ENABLED","p":"cache-enabled","type":"boolean","description":"Setting this to false turn off the cache. This may improve memory usage.","key":"cacheEnabled"},{"env":"WA_BROWSER_REVISION","p":"browser-revision","type":"string","description":"This is the specific browser revision to be downlaoded and used. You can find browser revision strings here: http://omahaproxy.appspot.com/ Learn more about it here: https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-browserfetcher If you're having trouble with sending images, try '737027'. If you go too far back things will start breaking !!!!!! NOTE: THIS WILL OVERRIDE useChrome and executablePath. ONLY USE THIS IF YOU KNOW WHAT YOU ARE DOING.","key":"browserRevision"},{"env":"WA_HEADLESS","p":"headless","type":"boolean","description":"By default, all instances of @open-wa/wa-automate are headless (i.e you don't see a chrome window open), you can set this to false to show the chrome/chromium window.","key":"headless"},{"env":"WA_QR_TIMEOUT","p":"qr-timeout","type":"number","description":"This determines how long the process should wait for a QR code to be scanned before killing the process entirely. To have the system wait continuously, set this to `0`.","default":60,"key":"qrTimeout"},{"env":"WA_USE_CHROME","p":"use-chrome","type":"boolean","description":"If true, the program will automatically try to detect the instance of chorme on the machine. Please note this DOES NOT override executablePath.","key":"useChrome"},{"env":"WA_QR_LOG_SKIP","p":"qr-log-skip","type":"boolean","description":"If true, skips logging the QR Code to the console.","key":"qrLogSkip"},{"env":"WA_DISABLE_SPINS","p":"disable-spins","type":"boolean","description":"Setting this to true will simplify logs for use within docker containers by disabling spins (will still print raw messages).","key":"disableSpins"},{"env":"WA_LOG_CONSOLE","p":"log-console","type":"boolean","description":"If true, this will log any console messages from the browser.","key":"logConsole"},{"env":"WA_LOG_CONSOLE_ERRORS","p":"log-console-errors","type":"boolean","description":"If true, this will log any error messages from the browser instance","key":"logConsoleErrors"},{"env":"WA_AUTH_TIMEOUT","p":"auth-timeout","type":"number","description":"This determines how long the process should wait for the session authentication. If exceeded, checks if phone is out of reach (turned of or without internet connection) and throws an error. It does not relate to the amount of time spent waiting for a qr code scan (see [[qrTimeout]]). To have the system wait continuously, set this to `0`.","key":"authTimeout"},{"env":"WA_SAFE_MODE","p":"safe-mode","type":"boolean","description":"If true, client will check if the page is valid before each command. If page is not valid, it will throw an error.","key":"safeMode"},{"env":"WA_SKIP_SESSION_SAVE","p":"skip-session-save","type":"boolean","description":"If true, the process will not save a data.json file. This means that sessions will not be saved and you will need to pass sessionData as a config param or create the session data.json file yourself","key":"skipSessionSave"},{"env":"WA_POPUP","p":"popup","type":["boolean","number"],"description":"If true, the process will open a browser window where you will see basic event logs and QR codes to authenticate the session. Usually it will open on port 3000. It can also be set to a preferred port.\n\nYou can also get the QR code png at (if localhost and port 3000):\n\n`http://localhost:3000/qr`\n\nor if you have multiple session:\n\n `http://localhost:3000/qr?sessionId=[sessionId]`","key":"popup"},{"env":"WA_QR_POP_UP_ONLY","p":"qr-pop-up-only","type":"boolean","description":"This needs to be used in conjuction with `popup`, if `popup` is not true or a number (representing a desired port) then this will not work.\n\nSetting this to true will make sure that only the qr code png is served via the web server. This is useful if you do not need the whole status page.\n\nAs mentioned in [popup](#popup), the url for the qr code is `http://localhost:3000/qr` if the port is 3000.","key":"qrPopUpOnly"},{"env":"WA_BLOCK_ASSETS","p":"block-assets","type":"boolean","description":"Setting this to true will block all assets from loading onto the page. This may result in some load time improvements but also increases instability.","key":"blockAssets"},{"env":"WA_KEEP_UPDATED","p":"keep-updated","type":"boolean","description":"[ALPHA FEATURE - ONLY IMPLEMENTED FOR TESTING - DO NOT USE IN PRODUCTION YET] Setting this to true will result in the library making sure it is always starting with the latest version of itself. This overrides `skipUpdateCheck`.","key":"keepUpdated"},{"env":"WA_RESIZABLE","p":"resizable","type":"boolean","description":"Syncs the viewport size with the window size which is how normal browsers act. Only relevant when `headless: false` and this overrides `viewport` config.","key":"resizable"},{"env":"WA_VIEWPORT","p":"viewport","type":"object","properties":{"width":{"type":"number","description":"Page width in pixels"},"height":{"type":"number","description":"Page height in pixels"}},"additionalProperties":false,"description":"Set the desired viewport height and width. For CLI, use [width]x[height] format. E.g `--viewport 1920x1080`.","key":"viewport"},{"env":"WA_LEGACY","p":"legacy","type":"boolean","description":"As the library is constantly evolving, some parts will be replaced with more efficient and improved code. In some of the infinite edge cases these new changes may not work for you. Set this to true to roll back on 'late beta' features. The reason why legacy is false by default is that in order for features to be tested they have to be released and used by everyone to find the edge cases and fix them.","key":"legacy"},{"env":"WA_DELETE_SESSION_DATA_ON_LOGOUT","p":"delete-session-data-on-logout","type":"boolean","description":"Deletes the session data file (if found) on logout event. This results in a quicker login when you restart the process.","key":"deleteSessionDataOnLogout"},{"env":"WA_KILL_PROCESS_ON_TIMEOUT","p":"kill-process-on-timeout","type":"boolean","description":"If set to true, the system will kill the whole node process when either an [[authTimeout]] or a [[qrTimeout]] has been reached. This is useful to prevent hanging processes.","key":"killProcessOnTimeout"},{"env":"WA_CORS_FIX","p":"cors-fix","type":"boolean","description":"Setting this to true will bypass web security. DO NOT DO THIS IF YOU DO NOT HAVE TO. CORS issue may arise when using a proxy.","key":"corsFix"},{"env":"WA_CALL_TIMEOUT","p":"call-timeout","type":"number","description":"Amount of time (in ms) to wait for a client method (specifically methods that interact with the WA web session) to resolve. If a client method results takes longer than the timout value then it will result in a [[PageEvaluationTimeout]] error.\n\nIf you get this error, it does not automatically mean that the method failed - it just stops your program from waiting for a client method to resolve.\n\nThis is useful if you do not rely on the results of a client method (e.g the message ID).\n\nIf set to `0`, the process will wait indefinitely for a client method to resolve.","default":0,"key":"callTimeout"},{"env":"WA_SCREENSHOT_ON_INITIALIZATION_BROWSER_ERROR","p":"screenshot-on-initialization-browser-error","type":"boolean","description":"When true, this option will take a screenshot of the browser when an unexpected error occurs within the browser during `create` initialization. The path will be `[working directory]/logs/[session ID]/[start timestamp]/[timestamp].jpg`","key":"screenshotOnInitializationBrowserError"},{"env":"WA_EVENT_MODE","p":"event-mode","type":"boolean","description":"Setting listeners may not be your cup of tea. With eventMode, all [[SimpleListener]] events will be registered automatically and be filed via the built in Events Listener.\n\nThis is useful because you can register/deregister the event listener as needed whereas the legacy method of setting callbacks are only be set once","key":"eventMode"},{"env":"WA_LOG_FILE","p":"log-file","type":"boolean","description":"If true, the system will automatically create a log of all processes relating to actions sent to the web session.\n\nThe location of the file will be relative to the process directory (pd)\n\n`[pd]/[sessionId]/[start timestamp].log`","default":false,"key":"logFile"},{"env":"WA_ID_CORRECTION","p":"id-correction","type":"boolean","description":"When true, the system will attempt to correct chatIds and groupChatIds. This means you can ignore `@c.us` and `@g.us` distinctions in some parameters.","default":false,"key":"idCorrection"},{"env":"WA_STICKER_SERVER_ENDPOINT","p":"sticker-server-endpoint","type":["string","boolean"],"description":"Redundant until self-hostable sticker server is available.","key":"stickerServerEndpoint"},{"env":"WA_CACHED_PATCH","p":"cached-patch","type":"boolean","description":"This will force the library to use the default cached raw github link for patches to shave a few hundred milliseconds from your launch time. If you use this option, you will need to wait about 5 minutes before trying out new patches.","key":"cachedPatch"},{"env":"WA_LOG_DEBUG_INFO_AS_OBJECT","p":"log-debug-info-as-object","type":"boolean","description":"Setting `this` to true will replace the `console.table` with a stringified logging of the debug info object instead. This would be useful to set for smaller terminal windows. If `disableSpins` is `true` then this will also be `true`.","key":"logDebugInfoAsObject"},{"env":"WA_KILL_CLIENT_ON_LOGOUT","p":"kill-client-on-logout","type":"boolean","description":"Kill the client when a logout is detected","key":"killClientOnLogout"},{"env":"WA_THROW_ON_EXPIRED_SESSION_DATA","p":"throw-on-expired-session-data","type":"boolean","description":"This will make the `create` command return `false` if the detected session data is expired.\n\nThis will mean, the process will not attempt to automatically get a new QR code.","key":"throwOnExpiredSessionData"},{"env":"WA_USE_NATIVE_PROXY","p":"use-native-proxy","type":"boolean","description":"Some sessions may experience issues with sending media when using proxies. Using the native proxy system instead of the recommended 3rd party library may fix these issues.","key":"useNativeProxy"},{"env":"WA_RASPI","p":"raspi","type":"boolean","description":"Set this to `true` to make the library work on Raspberry Pi OS.\n\nMake sure to run the following command before running the library the first time:\n\n``` > sudo apt update -y && sudo apt install chromium-browser chromium-codecs-ffmpeg -y && sudo apt upgrade ```\n\nIf you're using the CLI, you can set this value to `true` by adding the following flag to the CLI command\n\n``` > npx @open-wa/wa-automate ... --raspi ```","key":"raspi"},{"env":"WA_MULTI_DEVICE","p":"multi-device","type":"boolean","description":"Please note that multi-device is still in beta so a lot of things may not work. It is HIGHLY suggested to NOT use this in production!!!!\n\nSet this to true if you're using the multidevice beta.","key":"multiDevice"},{"env":"WA_SESSION_DATA_BUCKET_AUTH","p":"session-data-bucket-auth","type":"string","description":"Base64 encoded S3 Bucket & Authentication object for session data files. The object should be in the same format as cloudUploadOptions.","key":"sessionDataBucketAuth"},{"env":"WA_AUTO_EMOJI","p":"auto-emoji","type":"string","description":"Set the automatic emoji detection character. Set this to false to disable auto emoji. Default is `:`.","key":"autoEmoji"},{"env":"WA_MAX_CHATS","p":"max-chats","type":"number","description":"Set the maximum amount of chats to be present in a session.","key":"maxChats"},{"env":"WA_MAX_MESSAGES","p":"max-messages","type":"number","description":"Set the maximum amount of messages to be present in a session.","key":"maxMessages"},{"env":"WA_DISCORD","p":"discord","type":"string","description":"Your Discord ID to get onto the sticker leaderboard!","key":"discord"},{"env":"WA_IGNORE_NUKE","p":"ignore-nuke","type":"boolean","description":"Don't implicitly determine if the host logged out.","key":"ignoreNuke"},{"env":"WA_ENSURE_HEADFUL_INTEGRITY","p":"ensure-headful-integrity","type":"boolean","description":"Makes sure the headless session is usable even on first login. Headful sessions are ususally only usable on reauthentication.","key":"ensureHeadfulIntegrity"}]
|
1
|
+
[{"env":"WA_SESSION_DATA","p":"session-data","description":"The base64 encoded sessionData used to restore a session.","type":"string","key":"sessionData"},{"env":"WA_BROWSER_WS_ENDPOINT","p":"browser-ws-endpoint","type":"string","description":"ALPHA EXPERIMENTAL FEATURE! DO NOT USE IN PRODUCTION, REQUIRES TESTING.\n\nLearn more:\n\nhttps://pptr.dev/#?product=Puppeteer&version=v3.1.0&show=api-puppeteerconnectoptions\n\nhttps://medium.com/@jaredpotter1/connecting-puppeteer-to-existing-chrome-window-8a10828149e0","key":"browserWSEndpoint"},{"env":"WA_SESSION_DATA_PATH","p":"session-data-path","type":"string","description":"The path relative to the current working directory (i.e where you run the command to start your process). This will be used to store and read your `.data.json` files. defualt to ''","key":"sessionDataPath"},{"env":"WA_SKIP_UPDATE_CHECK","p":"skip-update-check","type":"boolean","description":"If set to true, `skipUpdateCheck` will bypass the latest version check. This saves some time on boot (around 150 ms).","key":"skipUpdateCheck"},{"env":"WA_SESSION_ID","p":"session-id","type":"string","description":"This is the name of the session. You have to make sure that this is unique for every session.","key":"sessionId"},{"env":"WA_LICENSE_KEY","p":"license-key","description":"The license key to use with the session.","type":"string","key":"licenseKey"},{"env":"WA_CUSTOM_USER_AGENT","p":"custom-user-agent","type":"string","description":"You may set a custom user agent. However, due to recent developments, this is not really neccessary any more.","key":"customUserAgent"},{"env":"WA_BLOCK_CRASH_LOGS","p":"block-crash-logs","type":"boolean","description":"Setting this to true will block any network calls to crash log servers. This should keep anything you do under the radar.","key":"blockCrashLogs"},{"env":"WA_CACHE_ENABLED","p":"cache-enabled","type":"boolean","description":"Setting this to false turn off the cache. This may improve memory usage.","key":"cacheEnabled"},{"env":"WA_BROWSER_REVISION","p":"browser-revision","type":"string","description":"This is the specific browser revision to be downlaoded and used. You can find browser revision strings here: http://omahaproxy.appspot.com/ Learn more about it here: https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-browserfetcher If you're having trouble with sending images, try '737027'. If you go too far back things will start breaking !!!!!! NOTE: THIS WILL OVERRIDE useChrome and executablePath. ONLY USE THIS IF YOU KNOW WHAT YOU ARE DOING.","key":"browserRevision"},{"env":"WA_HEADLESS","p":"headless","type":"boolean","description":"By default, all instances of @open-wa/wa-automate are headless (i.e you don't see a chrome window open), you can set this to false to show the chrome/chromium window.","key":"headless"},{"env":"WA_QR_TIMEOUT","p":"qr-timeout","type":"number","description":"This determines how long the process should wait for a QR code to be scanned before killing the process entirely. To have the system wait continuously, set this to `0`.","default":60,"key":"qrTimeout"},{"env":"WA_USE_CHROME","p":"use-chrome","type":"boolean","description":"If true, the program will automatically try to detect the instance of chorme on the machine. Please note this DOES NOT override executablePath.","key":"useChrome"},{"env":"WA_QR_LOG_SKIP","p":"qr-log-skip","type":"boolean","description":"If true, skips logging the QR Code to the console.","key":"qrLogSkip"},{"env":"WA_DISABLE_SPINS","p":"disable-spins","type":"boolean","description":"Setting this to true will simplify logs for use within docker containers by disabling spins (will still print raw messages).","key":"disableSpins"},{"env":"WA_LOG_CONSOLE","p":"log-console","type":"boolean","description":"If true, this will log any console messages from the browser.","key":"logConsole"},{"env":"WA_LOG_CONSOLE_ERRORS","p":"log-console-errors","type":"boolean","description":"If true, this will log any error messages from the browser instance","key":"logConsoleErrors"},{"env":"WA_AUTH_TIMEOUT","p":"auth-timeout","type":"number","description":"This determines how long the process should wait for the session authentication. If exceeded, checks if phone is out of reach (turned of or without internet connection) and throws an error. It does not relate to the amount of time spent waiting for a qr code scan (see [[qrTimeout]]). To have the system wait continuously, set this to `0`.","key":"authTimeout"},{"env":"WA_SAFE_MODE","p":"safe-mode","type":"boolean","description":"If true, client will check if the page is valid before each command. If page is not valid, it will throw an error.","key":"safeMode"},{"env":"WA_SKIP_SESSION_SAVE","p":"skip-session-save","type":"boolean","description":"If true, the process will not save a data.json file. This means that sessions will not be saved and you will need to pass sessionData as a config param or create the session data.json file yourself","key":"skipSessionSave"},{"env":"WA_POPUP","p":"popup","type":["boolean","number"],"description":"If true, the process will open a browser window where you will see basic event logs and QR codes to authenticate the session. Usually it will open on port 3000. It can also be set to a preferred port.\n\nYou can also get the QR code png at (if localhost and port 3000):\n\n`http://localhost:3000/qr`\n\nor if you have multiple session:\n\n `http://localhost:3000/qr?sessionId=[sessionId]`","key":"popup"},{"env":"WA_QR_POP_UP_ONLY","p":"qr-pop-up-only","type":"boolean","description":"This needs to be used in conjuction with `popup`, if `popup` is not true or a number (representing a desired port) then this will not work.\n\nSetting this to true will make sure that only the qr code png is served via the web server. This is useful if you do not need the whole status page.\n\nAs mentioned in [popup](#popup), the url for the qr code is `http://localhost:3000/qr` if the port is 3000.","key":"qrPopUpOnly"},{"env":"WA_BLOCK_ASSETS","p":"block-assets","type":"boolean","description":"Setting this to true will block all assets from loading onto the page. This may result in some load time improvements but also increases instability.","key":"blockAssets"},{"env":"WA_KEEP_UPDATED","p":"keep-updated","type":"boolean","description":"[ALPHA FEATURE - ONLY IMPLEMENTED FOR TESTING - DO NOT USE IN PRODUCTION YET] Setting this to true will result in the library making sure it is always starting with the latest version of itself. This overrides `skipUpdateCheck`.","key":"keepUpdated"},{"env":"WA_RESIZABLE","p":"resizable","type":"boolean","description":"Syncs the viewport size with the window size which is how normal browsers act. Only relevant when `headless: false` and this overrides `viewport` config.","key":"resizable"},{"env":"WA_VIEWPORT","p":"viewport","type":"object","properties":{"width":{"type":"number","description":"Page width in pixels"},"height":{"type":"number","description":"Page height in pixels"}},"additionalProperties":false,"description":"Set the desired viewport height and width. For CLI, use [width]x[height] format. E.g `--viewport 1920x1080`.","key":"viewport"},{"env":"WA_LEGACY","p":"legacy","type":"boolean","description":"As the library is constantly evolving, some parts will be replaced with more efficient and improved code. In some of the infinite edge cases these new changes may not work for you. Set this to true to roll back on 'late beta' features. The reason why legacy is false by default is that in order for features to be tested they have to be released and used by everyone to find the edge cases and fix them.","key":"legacy"},{"env":"WA_DELETE_SESSION_DATA_ON_LOGOUT","p":"delete-session-data-on-logout","type":"boolean","description":"Deletes the session data file (if found) on logout event. This results in a quicker login when you restart the process.","key":"deleteSessionDataOnLogout"},{"env":"WA_KILL_PROCESS_ON_TIMEOUT","p":"kill-process-on-timeout","type":"boolean","description":"If set to true, the system will kill the whole node process when either an [[authTimeout]] or a [[qrTimeout]] has been reached. This is useful to prevent hanging processes.","key":"killProcessOnTimeout"},{"env":"WA_CORS_FIX","p":"cors-fix","type":"boolean","description":"Setting this to true will bypass web security. DO NOT DO THIS IF YOU DO NOT HAVE TO. CORS issue may arise when using a proxy.","key":"corsFix"},{"env":"WA_CALL_TIMEOUT","p":"call-timeout","type":"number","description":"Amount of time (in ms) to wait for a client method (specifically methods that interact with the WA web session) to resolve. If a client method results takes longer than the timout value then it will result in a [[PageEvaluationTimeout]] error.\n\nIf you get this error, it does not automatically mean that the method failed - it just stops your program from waiting for a client method to resolve.\n\nThis is useful if you do not rely on the results of a client method (e.g the message ID).\n\nIf set to `0`, the process will wait indefinitely for a client method to resolve.","default":0,"key":"callTimeout"},{"env":"WA_SCREENSHOT_ON_INITIALIZATION_BROWSER_ERROR","p":"screenshot-on-initialization-browser-error","type":"boolean","description":"When true, this option will take a screenshot of the browser when an unexpected error occurs within the browser during `create` initialization. The path will be `[working directory]/logs/[session ID]/[start timestamp]/[timestamp].jpg`","key":"screenshotOnInitializationBrowserError"},{"env":"WA_EVENT_MODE","p":"event-mode","type":"boolean","description":"Setting listeners may not be your cup of tea. With eventMode, all [[SimpleListener]] events will be registered automatically and be filed via the built in Events Listener.\n\nThis is useful because you can register/deregister the event listener as needed whereas the legacy method of setting callbacks are only be set once","key":"eventMode"},{"env":"WA_LOG_FILE","p":"log-file","type":"boolean","description":"If true, the system will automatically create a log of all processes relating to actions sent to the web session.\n\nThe location of the file will be relative to the process directory (pd)\n\n`[pd]/[sessionId]/[start timestamp].log`","default":false,"key":"logFile"},{"env":"WA_ID_CORRECTION","p":"id-correction","type":"boolean","description":"When true, the system will attempt to correct chatIds and groupChatIds. This means you can ignore `@c.us` and `@g.us` distinctions in some parameters.","default":false,"key":"idCorrection"},{"env":"WA_STICKER_SERVER_ENDPOINT","p":"sticker-server-endpoint","type":["string","boolean"],"description":"Redundant until self-hostable sticker server is available.","key":"stickerServerEndpoint"},{"env":"WA_CACHED_PATCH","p":"cached-patch","type":"boolean","description":"This will force the library to use the default cached raw github link for patches to shave a few hundred milliseconds from your launch time. If you use this option, you will need to wait about 5 minutes before trying out new patches.","key":"cachedPatch"},{"env":"WA_LOG_DEBUG_INFO_AS_OBJECT","p":"log-debug-info-as-object","type":"boolean","description":"Setting `this` to true will replace the `console.table` with a stringified logging of the debug info object instead. This would be useful to set for smaller terminal windows. If `disableSpins` is `true` then this will also be `true`.","key":"logDebugInfoAsObject"},{"env":"WA_KILL_CLIENT_ON_LOGOUT","p":"kill-client-on-logout","type":"boolean","description":"Kill the client when a logout is detected","key":"killClientOnLogout"},{"env":"WA_THROW_ON_EXPIRED_SESSION_DATA","p":"throw-on-expired-session-data","type":"boolean","description":"This will make the `create` command return `false` if the detected session data is expired.\n\nThis will mean, the process will not attempt to automatically get a new QR code.","key":"throwOnExpiredSessionData"},{"env":"WA_USE_NATIVE_PROXY","p":"use-native-proxy","type":"boolean","description":"Some sessions may experience issues with sending media when using proxies. Using the native proxy system instead of the recommended 3rd party library may fix these issues.","key":"useNativeProxy"},{"env":"WA_RASPI","p":"raspi","type":"boolean","description":"Set this to `true` to make the library work on Raspberry Pi OS.\n\nMake sure to run the following command before running the library the first time:\n\n``` > sudo apt update -y && sudo apt install chromium-browser chromium-codecs-ffmpeg -y && sudo apt upgrade ```\n\nIf you're using the CLI, you can set this value to `true` by adding the following flag to the CLI command\n\n``` > npx @open-wa/wa-automate ... --raspi ```","key":"raspi"},{"env":"WA_MULTI_DEVICE","p":"multi-device","type":"boolean","description":"Please note that multi-device is still in beta so a lot of things may not work. It is HIGHLY suggested to NOT use this in production!!!!\n\nSet this to true if you're using the multidevice beta.","key":"multiDevice"},{"env":"WA_SESSION_DATA_BUCKET_AUTH","p":"session-data-bucket-auth","type":"string","description":"Base64 encoded S3 Bucket & Authentication object for session data files. The object should be in the same format as cloudUploadOptions.","key":"sessionDataBucketAuth"},{"env":"WA_AUTO_EMOJI","p":"auto-emoji","type":"string","description":"Set the automatic emoji detection character. Set this to false to disable auto emoji. Default is `:`.","key":"autoEmoji"},{"env":"WA_MAX_CHATS","p":"max-chats","type":"number","description":"Set the maximum amount of chats to be present in a session.","key":"maxChats"},{"env":"WA_MAX_MESSAGES","p":"max-messages","type":"number","description":"Set the maximum amount of messages to be present in a session.","key":"maxMessages"},{"env":"WA_DISCORD","p":"discord","type":"string","description":"Your Discord ID to get onto the sticker leaderboard!","key":"discord"},{"env":"WA_IGNORE_NUKE","p":"ignore-nuke","type":"boolean","description":"Don't implicitly determine if the host logged out.","key":"ignoreNuke"},{"env":"WA_ENSURE_HEADFUL_INTEGRITY","p":"ensure-headful-integrity","type":"boolean","description":"Makes sure the headless session is usable even on first login. Headful sessions are ususally only usable on reauthentication.","key":"ensureHeadfulIntegrity"},{"env":"WA_WAIT_FOR_RIPE_SESSION","p":"wait-for-ripe-session","type":"boolean","key":"waitForRipeSession"}]
|
package/dist/api/Client.d.ts
CHANGED
@@ -535,7 +535,7 @@ export declare class Client {
|
|
535
535
|
* @param hideTags boolean default: false [INSIDERS] set this to try silent tag someone in the caption
|
536
536
|
* @returns Promise <boolean | string> This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
|
537
537
|
*/
|
538
|
-
sendImage(to: ChatId, file: DataURL | FilePath, filename: string, caption: Content, quotedMsgId?: MessageId, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean): Promise<MessageId | boolean>;
|
538
|
+
sendImage(to: ChatId, file: DataURL | FilePath, filename: string, caption: Content, quotedMsgId?: MessageId, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean): Promise<MessageId | boolean>;
|
539
539
|
/**
|
540
540
|
* Automatically sends a youtube link with the auto generated link preview. You can also add a custom message.
|
541
541
|
* @param chatId
|
@@ -594,7 +594,7 @@ export declare class Client {
|
|
594
594
|
* @param hideTags boolean default: false [INSIDERS] set this to try silent tag someone in the caption
|
595
595
|
* @returns Promise <boolean | MessageId> This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
|
596
596
|
*/
|
597
|
-
sendFile(to: ChatId, file: DataURL | FilePath, filename: string, caption: Content, quotedMsgId?: MessageId, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean): Promise<MessageId | boolean>;
|
597
|
+
sendFile(to: ChatId, file: DataURL | FilePath, filename: string, caption: Content, quotedMsgId?: MessageId, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean): Promise<MessageId | boolean>;
|
598
598
|
/**
|
599
599
|
* [REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
|
600
600
|
*
|
@@ -647,7 +647,7 @@ export declare class Client {
|
|
647
647
|
* @param ptt boolean default: false set this to true if you want to send the file as a push to talk file.
|
648
648
|
* @param withoutPreview boolean default: false set this to true if you want to send the file without a preview (i.e as a file). This is useful for preventing auto downloads on recipient devices.
|
649
649
|
*/
|
650
|
-
sendFileFromUrl(to: ChatId, url: string, filename: string, caption: Content, quotedMsgId?: MessageId, requestConfig?: AxiosRequestConfig, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean): Promise<MessageId | boolean>;
|
650
|
+
sendFileFromUrl(to: ChatId, url: string, filename: string, caption: Content, quotedMsgId?: MessageId, requestConfig?: AxiosRequestConfig, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean): Promise<MessageId | boolean>;
|
651
651
|
/**
|
652
652
|
* Returns an object with all of your host device details
|
653
653
|
*/
|
package/dist/api/Client.js
CHANGED
@@ -365,7 +365,7 @@ class Client {
|
|
365
365
|
this._page = newTab;
|
366
366
|
});
|
367
367
|
const setupNewPage = () => __awaiter(this, void 0, void 0, function* () {
|
368
|
-
var _e;
|
368
|
+
var _e, _f;
|
369
369
|
/**
|
370
370
|
* Wait for the new page to be loaded up before closing existing page
|
371
371
|
*/
|
@@ -377,18 +377,20 @@ class Client {
|
|
377
377
|
*/
|
378
378
|
this._registeredEvListeners = {};
|
379
379
|
// this._listeners = {};
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
380
|
+
if ((_e = this._createConfig) === null || _e === void 0 ? void 0 : _e.waitForRipeSession) {
|
381
|
+
spinner.start("Waiting for ripe session...");
|
382
|
+
if (yield auth_1.waitForRipeSession(newTab))
|
383
|
+
spinner.succeed("Session ready for injection");
|
384
|
+
else
|
385
|
+
spinner.fail("You may experience issues in headless mode. Continuing...");
|
386
|
+
}
|
385
387
|
spinner.info("Injected new session...");
|
386
388
|
yield this._reInjectWapi(newTab);
|
387
389
|
/**
|
388
390
|
* patch
|
389
391
|
*/
|
390
392
|
yield initializer_1.getAndInjectLivePatch(newTab, spinner, null, this._createConfig, this._sessionInfo);
|
391
|
-
if ((
|
393
|
+
if ((_f = this._createConfig) === null || _f === void 0 ? void 0 : _f.licenseKey)
|
392
394
|
yield initializer_1.getAndInjectLicense(newTab, this._createConfig, me, this._sessionInfo, spinner, preloadlicense);
|
393
395
|
/**
|
394
396
|
* init patch
|
@@ -1311,7 +1313,7 @@ class Client {
|
|
1311
1313
|
* @param hideTags boolean default: false [INSIDERS] set this to try silent tag someone in the caption
|
1312
1314
|
* @returns Promise <boolean | string> This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
|
1313
1315
|
*/
|
1314
|
-
sendImage(to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags) {
|
1316
|
+
sendImage(to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags, viewOnce) {
|
1315
1317
|
return __awaiter(this, void 0, void 0, function* () {
|
1316
1318
|
//check if the 'base64' file exists
|
1317
1319
|
if (!tools_1.isDataURL(file) && !tools_1.isBase64(file) && !file.includes("data:")) {
|
@@ -1321,7 +1323,7 @@ class Client {
|
|
1321
1323
|
file = yield datauri_1.default(fs.existsSync(file) ? file : relativePath);
|
1322
1324
|
}
|
1323
1325
|
else if (is_url_superb_1.default(file)) {
|
1324
|
-
return yield this.sendFileFromUrl(to, file, filename, caption, quotedMsgId, {}, waitForId, ptt, withoutPreview, hideTags);
|
1326
|
+
return yield this.sendFileFromUrl(to, file, filename, caption, quotedMsgId, {}, waitForId, ptt, withoutPreview, hideTags, viewOnce);
|
1325
1327
|
}
|
1326
1328
|
else
|
1327
1329
|
throw new errors_1.CustomError(errors_1.ERROR_NAME.FILE_NOT_FOUND, `Cannot find file. Make sure the file reference is relative, a valid URL or a valid DataURL: ${file.slice(0, 25)}`);
|
@@ -1335,7 +1337,7 @@ class Client {
|
|
1335
1337
|
'Error: Number not linked to WhatsApp Account',
|
1336
1338
|
'ERROR: Please make sure you have at least one chat'
|
1337
1339
|
];
|
1338
|
-
const res = yield this.pup(({ to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags }) => WAPI.sendImage(file, to, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags), { to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags });
|
1340
|
+
const res = yield this.pup(({ to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags, viewOnce }) => WAPI.sendImage(file, to, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags, viewOnce), { to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags, viewOnce });
|
1339
1341
|
if (err.includes(res))
|
1340
1342
|
console.error(res);
|
1341
1343
|
return (err.includes(res) ? false : res);
|
@@ -1417,9 +1419,9 @@ class Client {
|
|
1417
1419
|
* @param hideTags boolean default: false [INSIDERS] set this to try silent tag someone in the caption
|
1418
1420
|
* @returns Promise <boolean | MessageId> This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
|
1419
1421
|
*/
|
1420
|
-
sendFile(to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags) {
|
1422
|
+
sendFile(to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags, viewOnce) {
|
1421
1423
|
return __awaiter(this, void 0, void 0, function* () {
|
1422
|
-
return this.sendImage(to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags);
|
1424
|
+
return this.sendImage(to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags, viewOnce);
|
1423
1425
|
});
|
1424
1426
|
}
|
1425
1427
|
/**
|
@@ -1529,10 +1531,10 @@ class Client {
|
|
1529
1531
|
* @param ptt boolean default: false set this to true if you want to send the file as a push to talk file.
|
1530
1532
|
* @param withoutPreview boolean default: false set this to true if you want to send the file without a preview (i.e as a file). This is useful for preventing auto downloads on recipient devices.
|
1531
1533
|
*/
|
1532
|
-
sendFileFromUrl(to, url, filename, caption, quotedMsgId, requestConfig = {}, waitForId, ptt, withoutPreview, hideTags) {
|
1534
|
+
sendFileFromUrl(to, url, filename, caption, quotedMsgId, requestConfig = {}, waitForId, ptt, withoutPreview, hideTags, viewOnce) {
|
1533
1535
|
return __awaiter(this, void 0, void 0, function* () {
|
1534
1536
|
const base64 = yield tools_1.getDUrl(url, requestConfig);
|
1535
|
-
return yield this.sendFile(to, base64, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags);
|
1537
|
+
return yield this.sendFile(to, base64, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags, viewOnce);
|
1536
1538
|
});
|
1537
1539
|
}
|
1538
1540
|
/**
|
@@ -724,6 +724,11 @@ export interface ConfigObject {
|
|
724
724
|
* Headful sessions are ususally only usable on reauthentication.
|
725
725
|
*/
|
726
726
|
ensureHeadfulIntegrity?: boolean;
|
727
|
+
/**
|
728
|
+
* @deprecated
|
729
|
+
* wait for a valid headful session. Not required in recent versions.
|
730
|
+
*/
|
731
|
+
waitForRipeSession?: boolean;
|
727
732
|
/**@internal */
|
728
733
|
[x: string]: any;
|
729
734
|
}
|
package/dist/cli/server.js
CHANGED
@@ -245,12 +245,26 @@ const setupBotPressHandler = (cliConfig, client) => {
|
|
245
245
|
const { responses } = data;
|
246
246
|
return yield Promise.all(responses.filter(({ type }) => type != "typing").map((response) => {
|
247
247
|
if (response.type == "text") {
|
248
|
+
response.text = response.variations ? (response.variations.concat(response.text))[Math.floor(Math.random() * (response.variations.length + 1))] : response.text;
|
248
249
|
return client.sendText(chatId, response.text);
|
249
250
|
}
|
250
251
|
if (response.type == "file") {
|
251
252
|
return client.sendFile(chatId, response.url, `file.${response.url.split(/[#?]/)[0].split('.').pop().trim()}`, response.title || "");
|
252
253
|
}
|
253
|
-
if (response.type == "
|
254
|
+
if (response.type == "image") {
|
255
|
+
return client.sendFile(chatId, response.image, `file.${response.image.split(/[#?]/)[0].split('.').pop().trim()}`, response.title || "");
|
256
|
+
}
|
257
|
+
if (response.type == "single-choice") {
|
258
|
+
if (response["choices"] && response["choices"].length >= 1 && response["choices"].length <= 3) {
|
259
|
+
return client.sendButtons(chatId, response.text, response["choices"].map(qr => {
|
260
|
+
return {
|
261
|
+
id: qr.value,
|
262
|
+
text: qr.title
|
263
|
+
};
|
264
|
+
}), "");
|
265
|
+
}
|
266
|
+
}
|
267
|
+
if (response.type == "quick_replies") {
|
254
268
|
if (response["quick_replies"] && response["quick_replies"].length >= 1 && response["quick_replies"].length <= 3) {
|
255
269
|
return client.sendButtons(chatId, response.wrapped.text, response["quick_replies"].map(qr => {
|
256
270
|
return {
|
@@ -154,6 +154,10 @@ function create(config = {}) {
|
|
154
154
|
spinner.start('Starting');
|
155
155
|
spinner.succeed(`Version: ${pkg.version}`);
|
156
156
|
spinner.info(`Initializing WA`);
|
157
|
+
if ((config === null || config === void 0 ? void 0 : config.multiDevice) && (config === null || config === void 0 ? void 0 : config.chromiumArgs))
|
158
|
+
spinner.info(`Using custom chromium args with multi device will cause issues! Please remove themm`);
|
159
|
+
if ((config === null || config === void 0 ? void 0 : config.multiDevice) && !(config === null || config === void 0 ? void 0 : config.useChrome))
|
160
|
+
spinner.info(`It is recommended to set useChrome: true or use the --use-chrome flag if you are experiencing issues with Multi device support`);
|
157
161
|
waPage = yield browser_1.initPage(sessionId, config, customUserAgent, spinner);
|
158
162
|
spinner.succeed('Browser Launched');
|
159
163
|
const throwOnError = config && config.throwErrorOnTosBlock == true;
|
@@ -273,11 +277,13 @@ function create(config = {}) {
|
|
273
277
|
}
|
274
278
|
if (attemptingReauth) {
|
275
279
|
yield waPage.evaluate("window.Store = undefined");
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
280
|
+
if (config === null || config === void 0 ? void 0 : config.waitForRipeSession) {
|
281
|
+
spinner.start("Waiting for ripe session...");
|
282
|
+
if (yield auth_1.waitForRipeSession(waPage))
|
283
|
+
spinner.succeed("Session ready for injection");
|
284
|
+
else
|
285
|
+
spinner.fail("You may experience issues in headless mode. Continuing...");
|
286
|
+
}
|
281
287
|
}
|
282
288
|
const pre = canInjectEarly ? 'Rei' : 'I';
|
283
289
|
spinner.start(`${pre}njecting api`);
|
@@ -392,6 +398,9 @@ function create(config = {}) {
|
|
392
398
|
catch (error) {
|
393
399
|
spinner.emit(error.message);
|
394
400
|
yield kill(waPage);
|
401
|
+
if (error.name === "TimeoutError" && (config === null || config === void 0 ? void 0 : config.multiDevice)) {
|
402
|
+
spinner.fail(`Please delete the ${config === null || config === void 0 ? void 0 : config.userDataDir} folder and any related data.json files and try again. It is highly suggested to set useChrome: true also.`);
|
403
|
+
}
|
395
404
|
if (error.name === "TimeoutError" && (config === null || config === void 0 ? void 0 : config.killProcessOnTimeout)) {
|
396
405
|
process.exit();
|
397
406
|
}
|
@@ -5,9 +5,10 @@
|
|
5
5
|
<title>open-wa</title>
|
6
6
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
7
|
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
|
8
|
-
|
9
|
-
integrity="sha512-
|
10
|
-
crossorigin="anonymous"></script>
|
8
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.2.0/socket.io.js"
|
9
|
+
integrity="sha512-WL6WGKMPBiM9PnHRYIn5YEtq0Z8XP4fkVb4qy7PP4vhmYQErJ/dySyXuFIMDf1eEYCXCrQrMJfkNwKc9gsjTjA=="
|
10
|
+
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
11
|
+
|
11
12
|
|
12
13
|
<style>
|
13
14
|
body {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@open-wa/wa-automate",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.23.1",
|
4
4
|
"licenseCheckUrl": "https://openwa.dev/license-check",
|
5
5
|
"brokenMethodReportUrl": "https://openwa.dev/report-bm",
|
6
6
|
"patches": "https://cdn.openwa.dev/patches.json",
|
@@ -136,7 +136,7 @@
|
|
136
136
|
"pico-s3": "^1.0.1",
|
137
137
|
"pino": "^6.11.1",
|
138
138
|
"postman-2-swagger": "^0.5.0",
|
139
|
-
"puppeteer": "10.
|
139
|
+
"puppeteer": "10.4.0",
|
140
140
|
"puppeteer-extra": "^3.1.9",
|
141
141
|
"puppeteer-extra-plugin-block-resources": "^2.2.7",
|
142
142
|
"puppeteer-extra-plugin-devtools": "^2.2.8",
|