@open-wa/wa-automate 4.23.11 → 4.23.15

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/README.md CHANGED
@@ -36,24 +36,17 @@
36
36
  Use this command to install the library for the first time and to keep the library up to date.
37
37
 
38
38
  ```bash
39
- > npm i --save @open-wa/wa-automate@latest --multi-device
39
+ > npm i --save @open-wa/wa-automate@latest
40
40
  ```
41
41
 
42
42
  ## Usage
43
43
 
44
- ```javascript
45
- // import { create, Client } from '@open-wa/wa-automate';
46
- const wa = require('@open-wa/wa-automate');
44
+ ## CLI
47
45
 
48
- wa.create().then(client => start(client));
46
+ Want to convert your WA account to an API instantly? You can now with the CLI. For more details see [Easy API](https://docs.openwa.dev/pages/Getting%20Started/quick-run.html)
49
47
 
50
- function start(client) {
51
- client.onMessage(async message => {
52
- if (message.body === 'Hi') {
53
- await client.sendText(message.from, '👋 Hello!');
54
- }
55
- });
56
- }
48
+ ```bash
49
+ > npx @open-wa/wa-automate --help
57
50
  ```
58
51
 
59
52
  ## Custom Setup
@@ -90,13 +83,6 @@ function start(client) {
90
83
 
91
84
  ###### @open-wa/wa-automate will remember the session so there is no need to authenticate every time
92
85
 
93
- ## CLI
94
-
95
- Want to convert your WA account to an API instantly? You can now with the CLI. For more details see [Easy API](https://docs.openwa.dev/pages/Getting%20Started/quick-run.html)
96
-
97
- ```bash
98
- > npx @open-wa/wa-automate --help
99
- ```
100
86
 
101
87
  ## Multi Device Support
102
88
 
@@ -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"},{"env":"WA_WAIT_FOR_RIPE_SESSION","p":"wait-for-ripe-session","type":"boolean","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_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","description":"wait for a valid headful session. Not required in recent versions.","key":"waitForRipeSession"}]
@@ -1198,6 +1198,12 @@ export declare class Client {
1198
1198
  * @returns list of messages
1199
1199
  */
1200
1200
  getIndicatedNewMessages(): Promise<Message[]>;
1201
+ /**
1202
+ * Fires all unread messages to the onMessage listener.
1203
+ * Make sure to call this AFTER setting your listeners.
1204
+ * @returns array of message IDs
1205
+ */
1206
+ emitUnreadMessages(): Promise<MessageId[]>;
1201
1207
  /**
1202
1208
  * Retrieves all Messages in a chat that have been loaded within the WA web instance.
1203
1209
  *
@@ -2410,6 +2410,16 @@ class Client {
2410
2410
  return JSON.parse(yield this.pup(() => WAPI.getIndicatedNewMessages()));
2411
2411
  });
2412
2412
  }
2413
+ /**
2414
+ * Fires all unread messages to the onMessage listener.
2415
+ * Make sure to call this AFTER setting your listeners.
2416
+ * @returns array of message IDs
2417
+ */
2418
+ emitUnreadMessages() {
2419
+ return __awaiter(this, void 0, void 0, function* () {
2420
+ return yield this.pup(() => WAPI.emitUnreadMessages());
2421
+ });
2422
+ }
2413
2423
  /**
2414
2424
  * Retrieves all Messages in a chat that have been loaded within the WA web instance.
2415
2425
  *
@@ -725,7 +725,6 @@ export interface ConfigObject {
725
725
  */
726
726
  ensureHeadfulIntegrity?: boolean;
727
727
  /**
728
- * @deprecated
729
728
  * wait for a valid headful session. Not required in recent versions.
730
729
  */
731
730
  waitForRipeSession?: boolean;
@@ -97,6 +97,10 @@ export declare enum STATE {
97
97
  */
98
98
  DISCONNECTED = "DISCONNECTED"
99
99
  }
100
+ export declare type EasyApiResponse = {
101
+ success: boolean;
102
+ response: any;
103
+ };
100
104
  export * from './config';
101
105
  export * from './media';
102
106
  export * from './aliases';
@@ -115,7 +115,6 @@ var STATE;
115
115
  */
116
116
  STATE["DISCONNECTED"] = "DISCONNECTED";
117
117
  })(STATE = exports.STATE || (exports.STATE = {}));
118
- ;
119
118
  __exportStar(require("./config"), exports);
120
119
  __exportStar(require("./media"), exports);
121
120
  __exportStar(require("./aliases"), exports);
@@ -1,2 +1,3 @@
1
1
  export declare const collections: {};
2
2
  export declare const generateCollections: any;
3
+ export declare const getTypeSchemas: any;
@@ -1,4 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
22
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
23
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -12,14 +31,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
31
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
32
  };
14
33
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.generateCollections = exports.collections = void 0;
34
+ exports.getTypeSchemas = exports.generateCollections = exports.collections = void 0;
16
35
  const __1 = require("..");
17
36
  const postman_2_swagger_1 = __importDefault(require("postman-2-swagger"));
18
37
  const fs_extra_1 = require("fs-extra");
38
+ const typeconv_1 = require("typeconv");
39
+ const fs = __importStar(require("fs"));
40
+ const glob_promise_1 = __importDefault(require("glob-promise"));
19
41
  exports.collections = {};
20
42
  const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void 0, function* () {
21
43
  let swCol = null;
22
44
  let pmCol = null;
45
+ const _types = yield exports.getTypeSchemas();
23
46
  spinner.info('Generating Swagger Spec');
24
47
  pmCol = yield __1.generatePostmanJson(config);
25
48
  spinner.succeed(`Postman collection generated: open-wa-${config.sessionId}.postman_collection.json`);
@@ -40,6 +63,9 @@ const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void
40
63
  "description": "Documentation",
41
64
  "url": swCol.paths[p].post.documentationUrl
42
65
  };
66
+ swCol.paths[p].post.responses['200'].schema = {
67
+ "$ref": "#/components/schemas/EasyApiResponse"
68
+ };
43
69
  swCol.paths[p].post.requestBody = {
44
70
  "description": path.summary,
45
71
  "content": {
@@ -55,20 +81,20 @@ const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void
55
81
  });
56
82
  delete swCol.swagger;
57
83
  swCol.openapi = "3.0.3";
84
+ swCol.components = {};
85
+ swCol.components.schemas = _types;
58
86
  swCol.externalDocs = {
59
87
  "description": "Find more info here",
60
88
  "url": "https://openwa.dev/"
61
89
  };
62
90
  if (config.key) {
63
- swCol.components = {
64
- "securitySchemes": {
91
+ swCol.components = Object.assign(Object.assign({}, swCol.components), { "securitySchemes": {
65
92
  "api_key": {
66
93
  "type": "apiKey",
67
94
  "name": "api_key",
68
95
  "in": "header"
69
96
  }
70
- }
71
- };
97
+ } });
72
98
  swCol.security = [
73
99
  {
74
100
  "api_key": []
@@ -86,3 +112,22 @@ const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void
86
112
  return;
87
113
  });
88
114
  exports.generateCollections = generateCollections;
115
+ const getTypeSchemas = () => __awaiter(void 0, void 0, void 0, function* () {
116
+ const reader = typeconv_1.getTypeScriptReader();
117
+ const writer = typeconv_1.getOpenApiWriter({ format: 'json', title: 'My API', version: 'v3.0.3' });
118
+ const { convert } = typeconv_1.makeConverter(reader, writer, {
119
+ simplify: true
120
+ });
121
+ const s = (yield Promise.all([...(yield glob_promise_1.default('../**/*.d.ts')), ...(yield glob_promise_1.default('../**/message.js')), ...(yield glob_promise_1.default('../**/chat.js'))])).filter(f => !f.includes('node_modules'));
122
+ const res = {};
123
+ yield Promise.all(s.map((x) => __awaiter(void 0, void 0, void 0, function* () {
124
+ var _a, _b;
125
+ const { data } = yield convert({ data: fs.readFileSync(x, 'utf8') });
126
+ const schemas = (_b = (_a = JSON.parse(data)) === null || _a === void 0 ? void 0 : _a.components) === null || _b === void 0 ? void 0 : _b.schemas;
127
+ Object.keys(schemas).forEach(k => {
128
+ res[k] = schemas[k];
129
+ });
130
+ })));
131
+ return res;
132
+ });
133
+ exports.getTypeSchemas = getTypeSchemas;
package/dist/cli/index.js CHANGED
@@ -188,6 +188,9 @@ function start() {
188
188
  }
189
189
  else
190
190
  ready(Object.assign(Object.assign(Object.assign(Object.assign({}, cliConfig), createConfig), client.getSessionInfo()), { hostAccountNumber: yield client.getHostNumber() }));
191
+ if (cliConfig.emitUnread) {
192
+ yield client.emitUnreadMessages();
193
+ }
191
194
  }
192
195
  catch (e) {
193
196
  spinner.fail(`Error ${e.message} ${e}`);
package/dist/cli/setup.js CHANGED
@@ -240,6 +240,12 @@ const optionList = [{
240
240
  type: Boolean,
241
241
  description: "Automatically reject incoming phone and video calls to the host account."
242
242
  },
243
+ {
244
+ name: 'emit-unread',
245
+ type: Boolean,
246
+ description: "Emit all unread messages via onMessage webhooks on launch.",
247
+ default: false
248
+ },
243
249
  {
244
250
  name: 'skip-url-check',
245
251
  type: Boolean,
@@ -13,4 +13,4 @@ export declare const isInsideChat: (waPage: Page) => Observable<boolean>;
13
13
  export declare const waitForRipeSession: (waPage: Page) => Promise<boolean>;
14
14
  export declare const sessionDataInvalid: (waPage: Page) => Promise<string>;
15
15
  export declare const phoneIsOutOfReach: (waPage: Page) => Promise<boolean>;
16
- export declare function smartQr(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<boolean | void>;
16
+ export declare function smartQr(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<boolean | void | string>;
@@ -129,11 +129,16 @@ function smartQr(waPage, config, spinner) {
129
129
  }
130
130
  return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
131
131
  const funcName = '_smartQr';
132
+ const md = "MULTI_DEVICE_DETECTED";
132
133
  let gotResult = false;
133
134
  const fn = (qrData) => __awaiter(this, void 0, void 0, function* () {
134
- if (!gotResult && (qrData === 'QR_CODE_SUCCESS' || qrData === 'MULTI_DEVICE_DETECTED')) {
135
+ if (qrData.length > 200 && !(config === null || config === void 0 ? void 0 : config.multiDevice)) {
136
+ spinner.fail(`Multi-Device detected, please set multiDevice to true in your config or add the --multi-device flag`);
137
+ return resolve(md);
138
+ }
139
+ if (!gotResult && (qrData === 'QR_CODE_SUCCESS' || qrData === md)) {
135
140
  gotResult = true;
136
- spinner === null || spinner === void 0 ? void 0 : spinner.succeed(qrData === 'MULTI_DEVICE_DETECTED' ? "Multi device support for this project is EXPERIMENTAL. Some things may not work...." : "QR code scanned. Loading session...");
141
+ spinner === null || spinner === void 0 ? void 0 : spinner.succeed(qrData === md ? "Multi device support for this project is EXPERIMENTAL. Some things may not work...." : "QR code scanned. Loading session...");
137
142
  return resolve(yield exports.isInsideChat(waPage).toPromise());
138
143
  }
139
144
  if (!gotResult)
@@ -145,6 +145,7 @@ function initPage(sessionId, config, customUserAgent, spinner) {
145
145
  Object.keys(session).forEach(key => localStorage.setItem(key, session[key]));
146
146
  }, {
147
147
  "md-opted-in": "true",
148
+ "MdUpgradeWamFlag": "true",
148
149
  "remember-me": "true"
149
150
  });
150
151
  }
@@ -304,14 +305,15 @@ function initBrowser(sessionId, config = {}) {
304
305
  let args = [...puppeteer_config_1.puppeteerConfig.chromiumArgs, ...((config === null || config === void 0 ? void 0 : config.chromiumArgs) || [])];
305
306
  if (config === null || config === void 0 ? void 0 : config.multiDevice) {
306
307
  args = args.filter(x => x != '--incognito');
307
- config["userDataDir"] = `./_IGNORE_${(config === null || config === void 0 ? void 0 : config.sessionId) || 'session'}`;
308
+ config["userDataDir"] = config["userDataDir"] || `${(config === null || config === void 0 ? void 0 : config.inDocker) ? '/sessions' : (config === null || config === void 0 ? void 0 : config.sessionDataPath) || '.'}/_IGNORE_${(config === null || config === void 0 ? void 0 : config.sessionId) || 'session'}`;
308
309
  }
309
310
  if (config === null || config === void 0 ? void 0 : config.corsFix)
310
311
  args.push('--disable-web-security');
311
312
  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 }));
312
313
  //devtools
313
314
  if (config === null || config === void 0 ? void 0 : config.devtools) {
314
- const devtools = (yield Promise.resolve().then(() => __importStar(require('puppeteer-extra-plugin-devtools'))))();
315
+ const _dt = yield Promise.resolve().then(() => __importStar(require('puppeteer-extra-plugin-devtools')));
316
+ const devtools = _dt.default();
315
317
  if (config.devtools !== 'local' && !((_b = config === null || config === void 0 ? void 0 : config.devtools) === null || _b === void 0 ? void 0 : _b.user) && !((_c = config === null || config === void 0 ? void 0 : config.devtools) === null || _c === void 0 ? void 0 : _c.pass)) {
316
318
  config.devtools = {};
317
319
  config.devtools.user = 'dev';
@@ -321,6 +323,7 @@ function initBrowser(sessionId, config = {}) {
321
323
  if (config.devtools.user && config.devtools.pass) {
322
324
  devtools.setAuthCredentials(config.devtools.user, config.devtools.pass);
323
325
  }
326
+ puppeteer.use(devtools);
324
327
  try {
325
328
  // const tunnel = await devtools.createTunnel(browser);
326
329
  const tunnel = config.devtools == 'local' ? devtools.getLocalDevToolsUrl(browser) : (yield devtools.createTunnel(browser)).url;
@@ -154,6 +154,14 @@ function create(config = {}) {
154
154
  spinner.start('Starting');
155
155
  spinner.succeed(`Version: ${pkg.version}`);
156
156
  spinner.info(`Initializing WA`);
157
+ /**
158
+ * Check if the IGNORE folder exists, therefore, assume that the session is MD.
159
+ */
160
+ const mdDir = config["userDataDir"] || `${(config === null || config === void 0 ? void 0 : config.inDocker) ? '/sessions' : (config === null || config === void 0 ? void 0 : config.sessionDataPath) || '.'}/_IGNORE_${(config === null || config === void 0 ? void 0 : config.sessionId) || 'session'}`;
161
+ if (fs.existsSync(mdDir) && !(config === null || config === void 0 ? void 0 : config.multiDevice)) {
162
+ spinner.info(`Multi-Device directory detected. multiDevice set to true.`);
163
+ config.multiDevice = true;
164
+ }
157
165
  if ((config === null || config === void 0 ? void 0 : config.multiDevice) && (config === null || config === void 0 ? void 0 : config.chromiumArgs))
158
166
  spinner.info(`Using custom chromium args with multi device will cause issues! Please remove themm`);
159
167
  if ((config === null || config === void 0 ? void 0 : config.multiDevice) && !(config === null || config === void 0 ? void 0 : config.useChrome))
@@ -264,6 +272,10 @@ function create(config = {}) {
264
272
  race.push(timeout(((config === null || config === void 0 ? void 0 : config.qrTimeout) || 60) * 1000));
265
273
  }
266
274
  const result = yield Promise.race(race);
275
+ if (result === "MULTI_DEVICE_DETECTED" && !(config === null || config === void 0 ? void 0 : config.multiDevice)) {
276
+ yield kill(waPage);
277
+ return create(Object.assign(Object.assign({}, config), { multiDevice: true }));
278
+ }
267
279
  if (result == 'timeout') {
268
280
  spinner.emit('qrTimeout');
269
281
  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');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.23.11",
3
+ "version": "4.23.15",
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",
@@ -120,6 +120,7 @@
120
120
  "find-up": "^5.0.0",
121
121
  "fs-extra": "^10.0.0",
122
122
  "get-port": "^5.1.1",
123
+ "glob-promise": "^4.2.2",
123
124
  "hasha": "^5.2.0",
124
125
  "image-type": "^4.1.0",
125
126
  "is-url-superb": "^5.0.0",
@@ -139,7 +140,7 @@
139
140
  "puppeteer": "10.4.0",
140
141
  "puppeteer-extra": "^3.1.9",
141
142
  "puppeteer-extra-plugin-block-resources": "^2.2.7",
142
- "puppeteer-extra-plugin-devtools": "^2.2.8",
143
+ "puppeteer-extra-plugin-devtools": "^2.3.3",
143
144
  "puppeteer-extra-plugin-stealth": "^2.4.9",
144
145
  "puppeteer-page-proxy": "^1.2.8",
145
146
  "qrcode-terminal": "^0.12.0",
@@ -157,6 +158,7 @@
157
158
  "ts-json-schema-generator": "^0.95.0",
158
159
  "ts-morph": "^12.0.0",
159
160
  "type-fest": "^1.1.1",
161
+ "typeconv": "^1.7.0",
160
162
  "update-notifier": "^5.0.0",
161
163
  "uuid": "^8.3.2",
162
164
  "uuid-apikey": "^1.4.6",