@open-wa/wa-automate 4.26.1 → 4.27.3

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.
@@ -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_GH_PATCH","p":"gh-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":"ghPatch"},{"env":"WA_CACHED_PATCH","p":"cached-patch","type":"boolean","description":"Setting this to `true` will save a local copy of the patches.json file (as patches.ignore.data.json) which will be used in subsequent instantiations of the session. While the rest of the launch procedure is running, the library will fetch and save a recent version of the patches to ensure your patches don't go stale. This will be ignored if the cached patches are more than a day old.","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","description":"wait for a valid headful session. Not required in recent versions.","key":"waitForRipeSession"}]
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_GH_PATCH","p":"gh-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":"ghPatch"},{"env":"WA_CACHED_PATCH","p":"cached-patch","type":"boolean","description":"Setting this to `true` will save a local copy of the patches.json file (as patches.ignore.data.json) which will be used in subsequent instantiations of the session. While the rest of the launch procedure is running, the library will fetch and save a recent version of the patches to ensure your patches don't go stale. This will be ignored if the cached patches are more than a day old.","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","description":"wait for a valid headful session. Not required in recent versions.","key":"waitForRipeSession"},{"env":"WA_QR_MAX","p":"qr-max","type":"number","description":"Automatically kill the process after a set amount of qr codes","key":"qrMax"}]
@@ -733,6 +733,10 @@ export interface ConfigObject {
733
733
  * wait for a valid headful session. Not required in recent versions.
734
734
  */
735
735
  waitForRipeSession?: boolean;
736
+ /**
737
+ * Automatically kill the process after a set amount of qr codes
738
+ */
739
+ qrMax?: number;
736
740
  /**@internal */
737
741
  [x: string]: any;
738
742
  }
@@ -140,7 +140,7 @@ const setupChatwootOutgoingMessageHandler = (cliConfig, client) => __awaiter(voi
140
140
  contact_id,
141
141
  "inbox_id": resolvedInbox
142
142
  });
143
- return data.payload;
143
+ return data;
144
144
  }
145
145
  catch (error) {
146
146
  return;
@@ -3,6 +3,7 @@ import { Merge, JsonObject } from 'type-fest';
3
3
  import { ConfigObject } from '../api/model/config';
4
4
  import { Spin } from '../controllers/events';
5
5
  export declare const optionKeys: string[];
6
+ export declare const optionKeysWithDefalts: string[];
6
7
  export declare const PrimitiveConverter: {
7
8
  Number: number;
8
9
  Boolean: boolean;
package/dist/cli/setup.js CHANGED
@@ -31,7 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
31
31
  return (mod && mod.__esModule) ? mod : { "default": mod };
32
32
  };
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.cli = exports.configFile = exports.envArgs = exports.helptext = exports.meowFlags = exports.cliOptionNames = exports.PrimitiveConverter = exports.optionKeys = void 0;
34
+ exports.cli = exports.configFile = exports.envArgs = exports.helptext = exports.meowFlags = exports.cliOptionNames = exports.PrimitiveConverter = exports.optionKeysWithDefalts = exports.optionKeys = void 0;
35
35
  const tools_1 = require("./../utils/tools");
36
36
  const command_line_usage_1 = __importDefault(require("command-line-usage"));
37
37
  const meow_1 = __importDefault(require("meow"));
@@ -272,6 +272,7 @@ const optionList = [{
272
272
  }
273
273
  ];
274
274
  exports.optionKeys = optionList.map(({ name }) => tools_1.camelize(name));
275
+ exports.optionKeysWithDefalts = optionList.filter(o => o.hasOwnProperty('default')).map(({ name }) => tools_1.camelize(name));
275
276
  exports.PrimitiveConverter = {
276
277
  Number: 1,
277
278
  Boolean: true,
@@ -373,7 +374,16 @@ const cli = () => {
373
374
  } }),
374
375
  booleanDefault: undefined
375
376
  });
376
- const cliConfig = Object.assign(Object.assign(Object.assign({ sessionId: "session" }, _cli.flags), (exports.configFile(_cli.flags.config) || {})), exports.envArgs());
377
+ /**
378
+ * Config order should follow airmanship rules. Least maneuverable to most maneuverable.
379
+ *
380
+ * 1. ENV VARS
381
+ * 2. Config file
382
+ * 3. CLI flags
383
+ */
384
+ const nonCliConfigs = Object.assign(Object.assign({}, exports.envArgs()), (exports.configFile(_cli.flags.config) || {}));
385
+ optionList.filter(option => option.default);
386
+ const cliConfig = Object.assign(Object.assign(Object.assign({ sessionId: "session" }, nonCliConfigs), _cli.flags), exports.optionKeysWithDefalts.reduce((p, c) => nonCliConfigs.hasOwnProperty(c) ? Object.assign(Object.assign({}, p), { [c]: nonCliConfigs[c] }) : p, {}));
377
387
  const PORT = Number(cliConfig.port || process.env.PORT || 8080);
378
388
  const spinner = new events_1.Spin(cliConfig.sessionId, 'STARTUP', cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.disableSpins);
379
389
  const createConfig = Object.assign({}, cliConfig);
@@ -34,6 +34,7 @@ const rxjs_1 = require("rxjs");
34
34
  const events_1 = require("./events");
35
35
  const initializer_1 = require("./initializer");
36
36
  const tools_1 = require("../utils/tools");
37
+ const browser_1 = require("./browser");
37
38
  const timeout = ms => new Promise(resolve => setTimeout(resolve, ms, 'timeout'));
38
39
  /**
39
40
  * Validates if client is authenticated
@@ -93,6 +94,7 @@ const phoneIsOutOfReach = (waPage) => __awaiter(void 0, void 0, void 0, function
93
94
  exports.phoneIsOutOfReach = phoneIsOutOfReach;
94
95
  function smartQr(waPage, config, spinner) {
95
96
  return __awaiter(this, void 0, void 0, function* () {
97
+ let qrNum = 0;
96
98
  const evalResult = yield waPage.evaluate("window.Store && window.Store.State");
97
99
  if (evalResult === false) {
98
100
  console.log('Seems as though you have been TOS_BLOCKed, unable to refresh QR Code. Please see https://github.com/open-wa/wa-automate-nodejs#best-practice for information on how to prevent this from happeing. You will most likely not get a QR Code');
@@ -113,11 +115,16 @@ function smartQr(waPage, config, spinner) {
113
115
  const qrPng = yield waPage.evaluate(`window.getQrPng()`);
114
116
  if (qrPng) {
115
117
  qrEv.emit(qrPng);
118
+ qrNum++;
119
+ tools_1.processSend('ready');
120
+ if (config.qrMax && qrNum >= config.qrMax) {
121
+ spinner.info('QR Code limit reached, exiting');
122
+ yield browser_1.kill(waPage, null, true);
123
+ }
116
124
  }
117
125
  else {
118
126
  spinner.info("Something went wrong while retreiving new the QR code but it should not affect the session launch procedure.");
119
127
  }
120
- tools_1.processSend('QR');
121
128
  }
122
129
  catch (error) {
123
130
  //@ts-ignore
@@ -1,4 +1,4 @@
1
- import { Page } from 'puppeteer';
1
+ import { Browser, Page } from 'puppeteer';
2
2
  import { Spin } from './events';
3
3
  import { ConfigObject } from '../api/model';
4
4
  export declare function initPage(sessionId?: string, config?: ConfigObject, customUserAgent?: string, spinner?: Spin, _page?: Page, skipAuth?: boolean): Promise<Page>;
@@ -6,3 +6,7 @@ export declare const deleteSessionData: (config: ConfigObject) => boolean;
6
6
  export declare const getSessionDataFilePath: (sessionId: string, config: ConfigObject) => string | boolean;
7
7
  export declare const addScript: (page: Page, js: string) => Promise<unknown>;
8
8
  export declare function injectApi(page: Page): Promise<Page>;
9
+ /**
10
+ * @internal
11
+ */
12
+ export declare const kill: (p: Page, b?: Browser, exit?: boolean, pid?: number) => Promise<void>;
@@ -31,7 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
31
31
  return (mod && mod.__esModule) ? mod : { "default": mod };
32
32
  };
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.injectApi = exports.addScript = exports.getSessionDataFilePath = exports.deleteSessionData = exports.initPage = void 0;
34
+ exports.kill = exports.injectApi = exports.addScript = exports.getSessionDataFilePath = exports.deleteSessionData = exports.initPage = void 0;
35
35
  const path = __importStar(require("path"));
36
36
  const fs = __importStar(require("fs"));
37
37
  const death_1 = __importDefault(require("death"));
@@ -41,6 +41,7 @@ const events_1 = require("./events");
41
41
  const pico_s3_1 = require("pico-s3");
42
42
  // eslint-disable-next-line @typescript-eslint/no-var-requires
43
43
  const puppeteer = require('puppeteer-extra');
44
+ const tree_kill_1 = __importDefault(require("tree-kill"));
44
45
  let browser;
45
46
  function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth) {
46
47
  var _a, _b, _c, _d, _e;
@@ -323,6 +324,9 @@ function initBrowser(sessionId, config = {}) {
323
324
  }
324
325
  if (config === null || config === void 0 ? void 0 : config.corsFix)
325
326
  args.push('--disable-web-security');
327
+ if (config["userDataDir"] && !fs.existsSync(config["userDataDir"])) {
328
+ fs.mkdirSync(config["userDataDir"], { recursive: true });
329
+ }
326
330
  const browser = (config === null || config === void 0 ? void 0 : config.browserWSEndpoint) ? yield puppeteer.connect(Object.assign({}, config)) : yield puppeteer.launch(Object.assign(Object.assign({ headless: true, args }, config), { devtools: false }));
327
331
  //devtools
328
332
  if (config === null || config === void 0 ? void 0 : config.devtools) {
@@ -360,5 +364,34 @@ function getWAPage(browser) {
360
364
  death_1.default(() => __awaiter(void 0, void 0, void 0, function* () {
361
365
  //clean up code here
362
366
  if (browser)
363
- yield browser.close();
367
+ yield exports.kill(browser);
364
368
  }));
369
+ /**
370
+ * @internal
371
+ */
372
+ const kill = (p, b, exit, pid) => __awaiter(void 0, void 0, void 0, function* () {
373
+ const killBrowser = (browser) => __awaiter(void 0, void 0, void 0, function* () {
374
+ if (!browser)
375
+ return;
376
+ pid = (browser === null || browser === void 0 ? void 0 : browser.process()) ? browser === null || browser === void 0 ? void 0 : browser.process().pid : null;
377
+ if (!pid)
378
+ return;
379
+ if (!(p === null || p === void 0 ? void 0 : p.isClosed()))
380
+ yield (p === null || p === void 0 ? void 0 : p.close());
381
+ if (browser)
382
+ yield (browser === null || browser === void 0 ? void 0 : browser.close().catch(() => { }));
383
+ });
384
+ if (p) {
385
+ const browser = (p === null || p === void 0 ? void 0 : p.browser) && typeof (p === null || p === void 0 ? void 0 : p.browser) === 'function' && (p === null || p === void 0 ? void 0 : p.browser());
386
+ yield killBrowser(browser);
387
+ }
388
+ else if (b) {
389
+ yield killBrowser(b);
390
+ }
391
+ if (pid)
392
+ tree_kill_1.default(pid, 'SIGKILL');
393
+ if (exit)
394
+ process.exit();
395
+ return;
396
+ });
397
+ exports.kill = kill;
@@ -54,7 +54,6 @@ const auth_1 = require("./auth");
54
54
  const browser_1 = require("./browser");
55
55
  const events_1 = require("./events");
56
56
  const launch_checks_1 = require("./launch_checks");
57
- const tree_kill_1 = __importDefault(require("tree-kill"));
58
57
  const cfonts_1 = __importDefault(require("cfonts"));
59
58
  const tools_1 = require("../utils/tools");
60
59
  const crypto_1 = require("crypto");
@@ -235,7 +234,7 @@ function create(config = {}) {
235
234
  if (authenticated === 'NUKE' && !(config === null || config === void 0 ? void 0 : config.ignoreNuke)) {
236
235
  //kill the browser
237
236
  spinner.fail("Session data most likely expired due to manual host account logout. Please re-authenticate this session.");
238
- yield kill(waPage);
237
+ yield browser_1.kill(waPage);
239
238
  if (config === null || config === void 0 ? void 0 : config.deleteSessionDataOnLogout)
240
239
  browser_1.deleteSessionData(config);
241
240
  if (config === null || config === void 0 ? void 0 : config.throwOnExpiredSessionData) {
@@ -256,7 +255,7 @@ function create(config = {}) {
256
255
  const outOfReach = yield Promise.race([auth_1.phoneIsOutOfReach(waPage), exports.timeout(20 * 1000)]);
257
256
  spinner.emit(outOfReach && outOfReach !== 'timeout' ? 'appOffline' : 'authTimeout');
258
257
  spinner.fail(outOfReach && outOfReach !== 'timeout' ? 'Authentication timed out. Please open the app on the phone. Shutting down' : 'Authentication timed out. Shutting down. Consider increasing authTimeout config variable: https://open-wa.github.io/wa-automate-nodejs/interfaces/configobject.html#authtimeout');
259
- yield kill(waPage);
258
+ yield browser_1.kill(waPage);
260
259
  if (config === null || config === void 0 ? void 0 : config.killProcessOnTimeout)
261
260
  process.exit();
262
261
  throw new Error(outOfReach ? 'App Offline' : 'Auth Timeout. Consider increasing authTimeout config variable: https://open-wa.github.io/wa-automate-nodejs/interfaces/configobject.html#authtimeout');
@@ -276,13 +275,13 @@ function create(config = {}) {
276
275
  }
277
276
  const result = yield Promise.race(race);
278
277
  if (result === "MULTI_DEVICE_DETECTED" && !(config === null || config === void 0 ? void 0 : config.multiDevice)) {
279
- yield kill(waPage);
278
+ yield browser_1.kill(waPage);
280
279
  return create(Object.assign(Object.assign({}, config), { multiDevice: true }));
281
280
  }
282
281
  if (result == 'timeout') {
283
282
  spinner.emit('qrTimeout');
284
283
  spinner.fail('QR scan took too long. Session Timed Out. Shutting down. Consider increasing qrTimeout config variable: https://open-wa.github.io/wa-automate-nodejs/interfaces/configobject.html#qrtimeout');
285
- yield kill(waPage);
284
+ yield browser_1.kill(waPage);
286
285
  if (config === null || config === void 0 ? void 0 : config.killProcessOnTimeout)
287
286
  process.exit();
288
287
  throw new Error('QR Timeout');
@@ -358,7 +357,7 @@ function create(config = {}) {
358
357
  if (config === null || config === void 0 ? void 0 : config.restartOnCrash)
359
358
  waPage.on('error', (error) => __awaiter(this, void 0, void 0, function* () {
360
359
  console.error('Page Crashed! Restarting...', error);
361
- yield kill(waPage);
360
+ yield browser_1.kill(waPage);
362
361
  yield create(config).then(config.restartOnCrash);
363
362
  }));
364
363
  const pureWAPI = yield launch_checks_1.checkWAPIHash();
@@ -410,13 +409,13 @@ function create(config = {}) {
410
409
  }
411
410
  else {
412
411
  spinner.fail('The session is invalid. Retrying');
413
- yield kill(waPage);
412
+ yield browser_1.kill(waPage);
414
413
  return yield create(config);
415
414
  }
416
415
  }
417
416
  catch (error) {
418
417
  spinner.emit(error.message);
419
- yield kill(waPage);
418
+ yield browser_1.kill(waPage);
420
419
  if (error.name === "ProtocolError" && ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes("Target closed"))) {
421
420
  spinner.fail(error.message);
422
421
  process.exit();
@@ -435,22 +434,3 @@ function create(config = {}) {
435
434
  });
436
435
  }
437
436
  exports.create = create;
438
- /**
439
- * @internal
440
- */
441
- const kill = (p) => __awaiter(void 0, void 0, void 0, function* () {
442
- if (p) {
443
- const browser = yield (p === null || p === void 0 ? void 0 : p.browser());
444
- if (!browser)
445
- return;
446
- const pid = (browser === null || browser === void 0 ? void 0 : browser.process()) ? browser === null || browser === void 0 ? void 0 : browser.process().pid : null;
447
- if (!pid)
448
- return;
449
- if (!(p === null || p === void 0 ? void 0 : p.isClosed()))
450
- yield (p === null || p === void 0 ? void 0 : p.close());
451
- if (browser)
452
- yield (browser === null || browser === void 0 ? void 0 : browser.close().catch(() => { }));
453
- if (pid)
454
- tree_kill_1.default(pid, 'SIGKILL');
455
- }
456
- });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.26.1",
3
+ "version": "4.27.3",
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",
@@ -28,7 +28,7 @@
28
28
  "docwatch": "onchange 'src/**/*.ts' 'docs-source/**/*.md' -- typedoc",
29
29
  "build:config-for-bin": "cd build && ts-node build-config-json-for-bin.ts && cd ..",
30
30
  "postinstall": "patch-package",
31
- "install": "cross-env npm_config_yes=true npx ignore-check@latest -p '**.data.json' -p '**.node-persist**' --comment 'managed by open-wa'"
31
+ "install": "cross-env npm_config_yes=true npx ignore-check@latest -p '**.data.json' -p '**.node-persist**' -p '**_IGNORE_**' --comment 'managed by open-wa'"
32
32
  },
33
33
  "husky": {
34
34
  "hooks": {
@@ -138,11 +138,11 @@
138
138
  "pico-s3": "^1.0.1",
139
139
  "pino": "^6.11.1",
140
140
  "postman-2-swagger": "^0.5.0",
141
- "puppeteer": "10.4.0",
142
- "puppeteer-extra": "^3.1.9",
143
- "puppeteer-extra-plugin-block-resources": "^2.2.7",
141
+ "puppeteer": "^13.0.0",
142
+ "puppeteer-extra": "^3.2.3",
143
+ "puppeteer-extra-plugin-block-resources": "^2.3.0",
144
144
  "puppeteer-extra-plugin-devtools": "^2.3.3",
145
- "puppeteer-extra-plugin-stealth": "^2.4.9",
145
+ "puppeteer-extra-plugin-stealth": "^2.9.0",
146
146
  "puppeteer-page-proxy": "^1.2.8",
147
147
  "qrcode-terminal": "^0.12.0",
148
148
  "qs": "^6.10.1",