@open-wa/wa-automate 4.27.7 → 4.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/open-wa/wa-automate-nodejs.svg)](http://isitmaintained.com/project/open-wa/wa-automate-nodejs "Average time to resolve an issue")
14
14
  [![Percentage of issues still open](http://isitmaintained.com/badge/open/open-wa/wa-automate-nodejs.svg)](http://isitmaintained.com/project/open-wa/wa-automate-nodejs "Percentage of issues still open")
15
15
 
16
- <a href="https://discord.gg/dnpp72a"><img src="https://img.shields.io/discord/661438166758195211?color=blueviolet&label=discord&style=flat" /></a> ![WhatsApp_Web 2.2108.8](https://img.shields.io/badge/WhatsApp_Web-2.2108.8-brightgreen.svg)<img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/openwadev?label=Follow%20%40openwadev%20for%20updates&logo=twitter&style=social">
16
+ <a href="https://discord.gg/dnpp72a"><img src="https://img.shields.io/discord/661438166758195211?color=blueviolet&label=discord&style=flat" /></a> ![WhatsApp_Web 2.2147.16](https://img.shields.io/badge/WhatsApp_Web-2.2147.16-brightgreen.svg)<img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/openwadev?label=Follow%20%40openwadev%20for%20updates&logo=twitter&style=social">
17
17
 
18
18
  <a href="https://cloud.digitalocean.com/apps/new?repo=https://github.com/open-wa/wa-automate-nodejs/tree/deploy&refcode=4b093f6ecd3a&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge">
19
19
  <img style="max-height:200px" src="https://raw.githubusercontent.com/open-wa/wa-automate-deploy-heroku/main/assets/do_deploy.png" alt="Deploy to DO">
@@ -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"},{"env":"WA_QR_MAX","p":"qr-max","type":"number","description":"Automatically kill the process after a set amount of qr codes","key":"qrMax"},{"env":"WA_EZQR","p":"ezqr","type":"boolean","description":"Expose a URL where you can easily scan the qr code","key":"ezqr"}]
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"},{"env":"WA_EZQR","p":"ezqr","type":"boolean","description":"Expose a URL where you can easily scan the qr code","key":"ezqr"},{"env":"WA_LOGGING","p":"logging","type":"array","items":{"$ref":"#/definitions/ConfigLogTransport"},"description":"An array of [winston](https://github.com/winstonjs/winston/blob/master/docs/transports.md#additional-transports) logging transport configurations.\n\n[Check this discussion to see how to set up logging](https://github.com/open-wa/wa-automate-nodejs/discussions/2373)","key":"logging"}]
@@ -37,7 +37,6 @@ export declare class Client {
37
37
  private _page;
38
38
  private _currentlyBeingKilled;
39
39
  private _refreshing;
40
- private _l;
41
40
  private _prio;
42
41
  private _pageListeners;
43
42
  private _registeredPageListeners;
@@ -54,7 +54,6 @@ const uuid_1 = require("uuid");
54
54
  const parse_function_1 = __importDefault(require("parse-function"));
55
55
  const fs = __importStar(require("fs"));
56
56
  const datauri_1 = __importDefault(require("datauri"));
57
- const pino_1 = __importDefault(require("pino"));
58
57
  const is_url_superb_1 = __importDefault(require("is-url-superb"));
59
58
  const fs_extra_1 = require("fs-extra");
60
59
  const tree_kill_1 = __importDefault(require("tree-kill"));
@@ -69,24 +68,9 @@ const MessageCollector_1 = require("../structures/MessageCollector");
69
68
  const init_patch_1 = require("../controllers/init_patch");
70
69
  const preProcessors_1 = require("../structures/preProcessors");
71
70
  const tools_1 = require("../utils/tools");
71
+ const logging_1 = require("../logging/logging");
72
72
  /** @ignore */
73
- const pkg = fs_extra_1.readJsonSync(path.join(__dirname, '../../package.json')), createLogger = (sessionId, sessionInfo, config) => {
74
- const p = path.join(path.resolve(process.cwd()), `/logs/${sessionId || 'session'}/${sessionInfo.START_TS}.log`);
75
- if (!fs.existsSync(p)) {
76
- fs.mkdirSync(path.join(path.resolve(process.cwd()), `/logs/${sessionId || 'session'}`), {
77
- recursive: true
78
- });
79
- }
80
- const logger = pino_1.default({
81
- redact: ['file', 'base64', 'image', 'webpBase64', 'base64', 'durl', 'thumbnail'],
82
- }, pino_1.default.destination(p));
83
- logger.child({
84
- "STAGE": "LAUNCH",
85
- sessionInfo,
86
- config
87
- }).info("");
88
- return logger;
89
- };
73
+ const pkg = (0, fs_extra_1.readJsonSync)(path.join(__dirname, '../../package.json'));
90
74
  var namespace;
91
75
  (function (namespace) {
92
76
  namespace["Chat"] = "Chat";
@@ -201,7 +185,7 @@ class Client {
201
185
  const m = (rb === null || rb === void 0 ? void 0 : rb.method) || this._createConfig.sessionId && this._createConfig.sessionId !== 'session' && req.path.includes(this._createConfig.sessionId) ? req.path.replace(`/${this._createConfig.sessionId}/`, '') : req.path.replace('/', '');
202
186
  let methodRequiresArgs = false;
203
187
  if (args && !Array.isArray(args)) {
204
- const methodArgs = parse_function_1.default().parse(this[m]).args;
188
+ const methodArgs = (0, parse_function_1.default)().parse(this[m]).args;
205
189
  if ((methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.length) > 0)
206
190
  methodRequiresArgs = true;
207
191
  args = methodArgs.map(argName => args[argName]);
@@ -241,7 +225,7 @@ class Client {
241
225
  this._createConfig = createConfig || {};
242
226
  this._loadedModules = [];
243
227
  this._sessionInfo = sessionInfo;
244
- this._sessionInfo.INSTANCE_ID = uuid_1.v4();
228
+ this._sessionInfo.INSTANCE_ID = (0, uuid_1.v4)();
245
229
  this._listeners = {};
246
230
  if (this._createConfig.stickerServerEndpoint !== false)
247
231
  this._createConfig.stickerServerEndpoint = true;
@@ -261,9 +245,9 @@ class Client {
261
245
  yield this.registerAllSimpleListenersOnEv();
262
246
  }
263
247
  this._sessionInfo.PHONE_VERSION = (_c = (_b = (yield this.getMe())) === null || _b === void 0 ? void 0 : _b.phone) === null || _c === void 0 ? void 0 : _c.wa_version;
264
- this.logger().child({
248
+ logging_1.log.info('LOADED', {
265
249
  PHONE_VERSION: this._sessionInfo.PHONE_VERSION
266
- }).info();
250
+ });
267
251
  if (((_d = this._createConfig) === null || _d === void 0 ? void 0 : _d.autoEmoji) === undefined || ((_e = this._createConfig) === null || _e === void 0 ? void 0 : _e.autoEmoji)) {
268
252
  const ident = typeof ((_f = this._createConfig) === null || _f === void 0 ? void 0 : _f.autoEmoji) === "string" ? (_g = this._createConfig) === null || _g === void 0 ? void 0 : _g.autoEmoji : ":";
269
253
  this.onMessage((message) => __awaiter(this, void 0, void 0, function* () {
@@ -279,9 +263,10 @@ class Client {
279
263
  this.onLogout(() => {
280
264
  var _a, _b;
281
265
  if ((_a = this._createConfig) === null || _a === void 0 ? void 0 : _a.deleteSessionDataOnLogout)
282
- browser_1.deleteSessionData(this._createConfig);
266
+ (0, browser_1.deleteSessionData)(this._createConfig);
283
267
  if ((_b = this._createConfig) === null || _b === void 0 ? void 0 : _b.killClientOnLogout) {
284
268
  console.log("Session logged out. Killing client");
269
+ logging_1.log.warn("Session logged out. Killing client");
285
270
  this.kill();
286
271
  }
287
272
  });
@@ -304,6 +289,7 @@ class Client {
304
289
  var _a;
305
290
  if (!this._refreshing) {
306
291
  console.log("Browser page has closed. Killing client");
292
+ logging_1.log.warn("Browser page has closed. Killing client");
307
293
  this.kill();
308
294
  if ((_a = this._createConfig) === null || _a === void 0 ? void 0 : _a.killProcessOnBrowserClose)
309
295
  process.exit();
@@ -312,7 +298,7 @@ class Client {
312
298
  }
313
299
  _reInjectWapi(newTab) {
314
300
  return __awaiter(this, void 0, void 0, function* () {
315
- yield browser_1.injectApi(newTab || this._page);
301
+ yield (0, browser_1.injectApi)(newTab || this._page);
316
302
  });
317
303
  }
318
304
  _reRegisterListeners() {
@@ -328,16 +314,14 @@ class Client {
328
314
  */
329
315
  download(url, optionsOverride = {}) {
330
316
  return __awaiter(this, void 0, void 0, function* () {
331
- return yield tools_1.getDUrl(url, optionsOverride);
317
+ return yield (0, tools_1.getDUrl)(url, optionsOverride);
332
318
  });
333
319
  }
334
320
  /**
335
321
  * Grab the logger for this session/process
336
322
  */
337
323
  logger() {
338
- if (!this._l)
339
- this._l = createLogger(this.getSessionId(), this.getSessionInfo(), this.getConfig());
340
- return this._l;
324
+ return logging_1.log;
341
325
  }
342
326
  /**
343
327
  * Refreshes the page and reinjects all necessary files. This may be useful for when trying to save memory
@@ -352,12 +336,12 @@ class Client {
352
336
  /**
353
337
  * preload license
354
338
  */
355
- const preloadlicense = ((_c = this._createConfig) === null || _c === void 0 ? void 0 : _c.licenseKey) ? yield patch_manager_1.getLicense(this._createConfig, me, this._sessionInfo, spinner) : false;
339
+ const preloadlicense = ((_c = this._createConfig) === null || _c === void 0 ? void 0 : _c.licenseKey) ? yield (0, patch_manager_1.getLicense)(this._createConfig, me, this._sessionInfo, spinner) : false;
356
340
  spinner.info('Refreshing session');
357
341
  const START_TIME = Date.now();
358
342
  spinner.info("Opening session in new tab");
359
343
  const newTab = yield this._page.browser().newPage();
360
- yield browser_1.initPage(this.getSessionId(), this._createConfig, this._createConfig.customUserAgent, spinner, newTab, true);
344
+ yield (0, browser_1.initPage)(this.getSessionId(), this._createConfig, this._createConfig.customUserAgent, spinner, newTab, true);
361
345
  // await newTab.goto(puppeteerConfig.WAUrl);
362
346
  //Two promises. One that closes the previous page, one that sets up the new page
363
347
  const closePageOnConflict = () => __awaiter(this, void 0, void 0, function* () {
@@ -375,9 +359,9 @@ class Client {
375
359
  /**
376
360
  * Wait for the new page to be loaded up before closing existing page
377
361
  */
378
- yield patch_manager_1.earlyInjectionCheck(newTab);
362
+ yield (0, patch_manager_1.earlyInjectionCheck)(newTab);
379
363
  spinner.info("Checking if fresh session is authenticated...");
380
- if (yield auth_1.isAuthenticated(newTab)) {
364
+ if (yield (0, auth_1.isAuthenticated)(newTab)) {
381
365
  /**
382
366
  * Reset all listeners
383
367
  */
@@ -386,7 +370,7 @@ class Client {
386
370
  if ((_e = this._createConfig) === null || _e === void 0 ? void 0 : _e.waitForRipeSession) {
387
371
  yield this._reInjectWapi(newTab);
388
372
  spinner.start("Waiting for ripe session...");
389
- if (yield auth_1.waitForRipeSession(newTab))
373
+ if (yield (0, auth_1.waitForRipeSession)(newTab))
390
374
  spinner.succeed("Session ready for injection");
391
375
  else
392
376
  spinner.fail("You may experience issues in headless mode. Continuing...");
@@ -396,13 +380,13 @@ class Client {
396
380
  /**
397
381
  * patch
398
382
  */
399
- yield patch_manager_1.getAndInjectLivePatch(newTab, spinner, null, this._createConfig, this._sessionInfo);
383
+ yield (0, patch_manager_1.getAndInjectLivePatch)(newTab, spinner, null, this._createConfig, this._sessionInfo);
400
384
  if ((_f = this._createConfig) === null || _f === void 0 ? void 0 : _f.licenseKey)
401
- yield patch_manager_1.getAndInjectLicense(newTab, this._createConfig, me, this._sessionInfo, spinner, preloadlicense);
385
+ yield (0, patch_manager_1.getAndInjectLicense)(newTab, this._createConfig, me, this._sessionInfo, spinner, preloadlicense);
402
386
  /**
403
387
  * init patch
404
388
  */
405
- yield init_patch_1.injectInitPatch(newTab);
389
+ yield (0, init_patch_1.injectInitPatch)(newTab);
406
390
  }
407
391
  else
408
392
  throw new Error("Session Logged Out. Cannot refresh. Please restart the process and scan the qr code.");
@@ -445,7 +429,8 @@ class Client {
445
429
  pup(pageFunction, ...args) {
446
430
  var _a, _b;
447
431
  return __awaiter(this, void 0, void 0, function* () {
448
- const { safeMode, callTimeout, idChecking, logFile } = this._createConfig;
432
+ const { safeMode, callTimeout, idChecking, logFile, logging } = this._createConfig;
433
+ let _t;
449
434
  if (safeMode) {
450
435
  if (!this._page || this._page.isClosed())
451
436
  throw new errors_1.CustomError(errors_1.ERROR_NAME.PAGE_CLOSED, 'page closed');
@@ -464,13 +449,17 @@ class Client {
464
449
  }
465
450
  });
466
451
  }
467
- if (logFile) {
452
+ if (logging) {
468
453
  const wapis = (_b = (((_a = pageFunction === null || pageFunction === void 0 ? void 0 : pageFunction.toString()) === null || _a === void 0 ? void 0 : _a.match(/WAPI\.(\w*)\(/g)) || [])) === null || _b === void 0 ? void 0 : _b.map(s => s.replace(/WAPI|\.|\(/g, ''));
469
- this.logger().child(Object.assign({ _method: (wapis === null || wapis === void 0 ? void 0 : wapis.length) === 1 ? wapis[0] : wapis }, args[0])).info();
454
+ _t = Date.now();
455
+ logging_1.log.info(`Request ${_t}`, Object.assign({ _method: (wapis === null || wapis === void 0 ? void 0 : wapis.length) === 1 ? wapis[0] : wapis }, args[0]));
470
456
  }
471
457
  if (callTimeout)
472
458
  return yield Promise.race([this._page.evaluate(pageFunction, ...args), new Promise((resolve, reject) => { var _a; return setTimeout(reject, (_a = this._createConfig) === null || _a === void 0 ? void 0 : _a.callTimeout, new errors_1.PageEvaluationTimeout()); })]);
473
459
  const res = yield this._page.evaluate(pageFunction, ...args);
460
+ if (_t && logging) {
461
+ logging_1.log.info(`Response ${_t}: ${Date.now() - _t}ms`, { res });
462
+ }
474
463
  if (this._createConfig.onError && typeof res == "string" && (res.startsWith("Error") || res.startsWith("ERROR"))) {
475
464
  const e = this._createConfig.onError;
476
465
  /**
@@ -543,7 +532,6 @@ class Client {
543
532
  return window[funcName] ? WAPI[`${funcName}`](obj => window[funcName](obj)) : false;
544
533
  }, { funcName });
545
534
  if (this._listeners[funcName] && !this._refreshing) {
546
- // console.log('listener already set');
547
535
  return true;
548
536
  }
549
537
  this._listeners[funcName] = fn;
@@ -581,6 +569,7 @@ class Client {
581
569
  this.registerPageEventListener('framenavigated', (frame) => __awaiter(this, void 0, void 0, function* () {
582
570
  if (frame.url().includes('post_logout=1')) {
583
571
  console.log("LOGGED OUT");
572
+ logging_1.log.warn("LOGGED OUT");
584
573
  yield fn(true);
585
574
  }
586
575
  }), priority);
@@ -1055,7 +1044,8 @@ class Client {
1055
1044
  if (this._currentlyBeingKilled)
1056
1045
  return;
1057
1046
  this._currentlyBeingKilled = true;
1058
- console.log('Shutting Down');
1047
+ console.log('Killing client. Shutting Down');
1048
+ logging_1.log.info('Killing client. Shutting Down');
1059
1049
  const browser = yield ((_a = this === null || this === void 0 ? void 0 : this._page) === null || _a === void 0 ? void 0 : _a.browser());
1060
1050
  const pid = (browser === null || browser === void 0 ? void 0 : browser.process()) ? (_b = browser === null || browser === void 0 ? void 0 : browser.process()) === null || _b === void 0 ? void 0 : _b.pid : null;
1061
1051
  try {
@@ -1064,7 +1054,7 @@ class Client {
1064
1054
  if (this._page && ((_e = this._page) === null || _e === void 0 ? void 0 : _e.browser))
1065
1055
  yield ((_g = (_f = this._page) === null || _f === void 0 ? void 0 : _f.browser()) === null || _g === void 0 ? void 0 : _g.close());
1066
1056
  if (pid)
1067
- tree_kill_1.default(pid, 'SIGKILL');
1057
+ (0, tree_kill_1.default)(pid, 'SIGKILL');
1068
1058
  }
1069
1059
  catch (error) {
1070
1060
  //ignore error
@@ -1348,7 +1338,7 @@ class Client {
1348
1338
  console.error(`\nUnable to decrypt sticker. Unlock this feature and support open-wa by getting a license: ${yield this.link("v=i")}\n`);
1349
1339
  throw new errors_1.CustomError(errors_1.ERROR_NAME.STICKER_NOT_DECRYPTED, 'Sticker not decrypted');
1350
1340
  }
1351
- const mediaData = yield wa_decrypt_1.decryptMedia(m);
1341
+ const mediaData = yield (0, wa_decrypt_1.decryptMedia)(m);
1352
1342
  return `data:${m.mimetype};base64,${mediaData.toString('base64')}`;
1353
1343
  });
1354
1344
  }
@@ -1365,13 +1355,13 @@ class Client {
1365
1355
  sendImage(to, file, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags, viewOnce) {
1366
1356
  return __awaiter(this, void 0, void 0, function* () {
1367
1357
  //check if the 'base64' file exists
1368
- if (!tools_1.isDataURL(file) && !tools_1.isBase64(file) && !file.includes("data:")) {
1358
+ if (!(0, tools_1.isDataURL)(file) && !(0, tools_1.isBase64)(file) && !file.includes("data:")) {
1369
1359
  //must be a file then
1370
1360
  const relativePath = path.join(path.resolve(process.cwd(), file || ''));
1371
1361
  if (fs.existsSync(file) || fs.existsSync(relativePath)) {
1372
- file = yield datauri_1.default(fs.existsSync(file) ? file : relativePath);
1362
+ file = yield (0, datauri_1.default)(fs.existsSync(file) ? file : relativePath);
1373
1363
  }
1374
- else if (is_url_superb_1.default(file)) {
1364
+ else if ((0, is_url_superb_1.default)(file)) {
1375
1365
  return yield this.sendFileFromUrl(to, file, filename, caption, quotedMsgId, {}, waitForId, ptt, withoutPreview, hideTags, viewOnce);
1376
1366
  }
1377
1367
  else
@@ -1527,14 +1517,14 @@ class Client {
1527
1517
  sendVideoAsGif(to, file, filename, caption, quotedMsgId, requestConfig = {}) {
1528
1518
  return __awaiter(this, void 0, void 0, function* () {
1529
1519
  //check if the 'base64' file exists
1530
- if (!tools_1.isDataURL(file)) {
1520
+ if (!(0, tools_1.isDataURL)(file)) {
1531
1521
  //must be a file then
1532
1522
  const relativePath = path.join(path.resolve(process.cwd(), file || ''));
1533
1523
  if (fs.existsSync(file) || fs.existsSync(relativePath)) {
1534
- file = yield datauri_1.default(fs.existsSync(file) ? file : relativePath);
1524
+ file = yield (0, datauri_1.default)(fs.existsSync(file) ? file : relativePath);
1535
1525
  }
1536
- else if (is_url_superb_1.default(file)) {
1537
- file = yield tools_1.getDUrl(file, requestConfig);
1526
+ else if ((0, is_url_superb_1.default)(file)) {
1527
+ file = yield (0, tools_1.getDUrl)(file, requestConfig);
1538
1528
  }
1539
1529
  else
1540
1530
  throw new errors_1.CustomError(errors_1.ERROR_NAME.FILE_NOT_FOUND, 'Cannot find file. Make sure the file reference is relative, a valid URL or a valid DataURL');
@@ -1557,13 +1547,14 @@ class Client {
1557
1547
  if (n) {
1558
1548
  const r = `https://i.giphy.com/${n[1]}.mp4`;
1559
1549
  const filename = `${n[1]}.mp4`;
1560
- const dUrl = yield tools_1.getDUrl(r);
1550
+ const dUrl = yield (0, tools_1.getDUrl)(r);
1561
1551
  return yield this.pup(({ to, dUrl, filename, caption }) => {
1562
1552
  WAPI.sendVideoAsGif(dUrl, to, filename, caption);
1563
1553
  }, { to, dUrl, filename, caption });
1564
1554
  }
1565
1555
  else {
1566
1556
  console.log('something is wrong with this giphy link');
1557
+ logging_1.log.error('something is wrong with this giphy link', giphyMediaUrl);
1567
1558
  return;
1568
1559
  }
1569
1560
  });
@@ -1582,7 +1573,7 @@ class Client {
1582
1573
  */
1583
1574
  sendFileFromUrl(to, url, filename, caption, quotedMsgId, requestConfig = {}, waitForId, ptt, withoutPreview, hideTags, viewOnce) {
1584
1575
  return __awaiter(this, void 0, void 0, function* () {
1585
- const base64 = yield tools_1.getDUrl(url, requestConfig);
1576
+ const base64 = yield (0, tools_1.getDUrl)(url, requestConfig);
1586
1577
  return yield this.sendFile(to, base64, filename, caption, quotedMsgId, waitForId, ptt, withoutPreview, hideTags, viewOnce);
1587
1578
  });
1588
1579
  }
@@ -2170,7 +2161,7 @@ class Client {
2170
2161
  const m = yield this.pup(messageId => WAPI.getStickerDecryptable(messageId), messageId);
2171
2162
  if (!m)
2172
2163
  return false;
2173
- return Object.assign({ t: m.t, id: m.id }, wa_decrypt_1.bleachMessage(m));
2164
+ return Object.assign({ t: m.t, id: m.id }, (0, wa_decrypt_1.bleachMessage)(m));
2174
2165
  });
2175
2166
  }
2176
2167
  /**
@@ -2189,7 +2180,7 @@ class Client {
2189
2180
  const m = yield this.pup(messageId => WAPI.forceStaleMediaUpdate(messageId), messageId);
2190
2181
  if (!m)
2191
2182
  return false;
2192
- return Object.assign({}, wa_decrypt_1.bleachMessage(m));
2183
+ return Object.assign({}, (0, wa_decrypt_1.bleachMessage)(m));
2193
2184
  });
2194
2185
  }
2195
2186
  /**
@@ -2532,8 +2523,7 @@ class Client {
2532
2523
  */
2533
2524
  setGroupIcon(groupId, image) {
2534
2525
  return __awaiter(this, void 0, void 0, function* () {
2535
- const mimeInfo = tools_1.base64MimeType(image);
2536
- console.log("setGroupIcon -> mimeInfo", mimeInfo);
2526
+ const mimeInfo = (0, tools_1.base64MimeType)(image);
2537
2527
  if (!mimeInfo || mimeInfo.includes("image")) {
2538
2528
  let imgData;
2539
2529
  if (this._createConfig.stickerServerEndpoint) {
@@ -2555,7 +2545,7 @@ class Client {
2555
2545
  return __awaiter(this, void 0, void 0, function* () {
2556
2546
  // eslint-disable-next-line no-useless-catch
2557
2547
  try {
2558
- const base64 = yield tools_1.getDUrl(url, requestConfig);
2548
+ const base64 = yield (0, tools_1.getDUrl)(url, requestConfig);
2559
2549
  return yield this.setGroupIcon(groupId, base64);
2560
2550
  }
2561
2551
  catch (error) {
@@ -2739,7 +2729,7 @@ class Client {
2739
2729
  */
2740
2730
  sendStickerfromUrl(to, url, requestConfig = {}, stickerMetadata) {
2741
2731
  return __awaiter(this, void 0, void 0, function* () {
2742
- const base64 = yield tools_1.getDUrl(url, requestConfig);
2732
+ const base64 = yield (0, tools_1.getDUrl)(url, requestConfig);
2743
2733
  return yield this.sendImageAsSticker(to, base64, stickerMetadata);
2744
2734
  });
2745
2735
  }
@@ -2756,7 +2746,7 @@ class Client {
2756
2746
  */
2757
2747
  sendStickerfromUrlAsReply(to, url, messageId, requestConfig = {}, stickerMetadata) {
2758
2748
  return __awaiter(this, void 0, void 0, function* () {
2759
- const dUrl = yield tools_1.getDUrl(url, requestConfig);
2749
+ const dUrl = yield (0, tools_1.getDUrl)(url, requestConfig);
2760
2750
  const processingResponse = yield this.prepareWebp(dUrl, stickerMetadata);
2761
2751
  if (!processingResponse)
2762
2752
  return false;
@@ -2782,15 +2772,15 @@ class Client {
2782
2772
  image = image.toString('base64');
2783
2773
  }
2784
2774
  else if (typeof image === 'string') {
2785
- if (!tools_1.isDataURL(image) && !tools_1.isBase64(image)) {
2775
+ if (!(0, tools_1.isDataURL)(image) && !(0, tools_1.isBase64)(image)) {
2786
2776
  //must be a file then
2787
- if (is_url_superb_1.default(image)) {
2788
- image = yield tools_1.getDUrl(image);
2777
+ if ((0, is_url_superb_1.default)(image)) {
2778
+ image = yield (0, tools_1.getDUrl)(image);
2789
2779
  }
2790
2780
  else {
2791
2781
  const relativePath = path.join(path.resolve(process.cwd(), image || ''));
2792
2782
  if (fs.existsSync(image) || fs.existsSync(relativePath)) {
2793
- image = yield datauri_1.default(fs.existsSync(image) ? image : relativePath);
2783
+ image = yield (0, datauri_1.default)(fs.existsSync(image) ? image : relativePath);
2794
2784
  }
2795
2785
  else
2796
2786
  return 'FILE_NOT_FOUND';
@@ -2835,10 +2825,10 @@ class Client {
2835
2825
  if (!a.emojiId) {
2836
2826
  //check if its a local file:
2837
2827
  const key = a.file ? 'file' : 'image';
2838
- if (!tools_1.isDataURL(a[key]) && !is_url_superb_1.default(a[key]) && !tools_1.isBase64(a[key])) {
2828
+ if (!(0, tools_1.isDataURL)(a[key]) && !(0, is_url_superb_1.default)(a[key]) && !(0, tools_1.isBase64)(a[key])) {
2839
2829
  const relativePath = path.join(path.resolve(process.cwd(), a[key] || ''));
2840
2830
  if (fs.existsSync(a[key]) || fs.existsSync(relativePath)) {
2841
- a[key] = yield datauri_1.default(fs.existsSync(a[key]) ? a[key] : relativePath);
2831
+ a[key] = yield (0, datauri_1.default)(fs.existsSync(a[key]) ? a[key] : relativePath);
2842
2832
  }
2843
2833
  else {
2844
2834
  console.error('FILE_NOT_FOUND');
@@ -2878,8 +2868,7 @@ class Client {
2878
2868
  }
2879
2869
  prepareWebp(image, stickerMetadata) {
2880
2870
  return __awaiter(this, void 0, void 0, function* () {
2881
- // console.log("prepareWebp", image.slice(0,25))
2882
- if (tools_1.isDataURL(image) && !image.includes("image")) {
2871
+ if ((0, tools_1.isDataURL)(image) && !image.includes("image")) {
2883
2872
  console.error("Not an image. Please use convertMp4BufferToWebpDataUrl to process video stickers");
2884
2873
  return false;
2885
2874
  }
@@ -2904,15 +2893,15 @@ class Client {
2904
2893
  image = image.toString('base64');
2905
2894
  }
2906
2895
  else if (typeof image === 'string') {
2907
- if (!tools_1.isDataURL(image) && !tools_1.isBase64(image)) {
2896
+ if (!(0, tools_1.isDataURL)(image) && !(0, tools_1.isBase64)(image)) {
2908
2897
  //must be a file then
2909
- if (is_url_superb_1.default(image)) {
2910
- image = yield tools_1.getDUrl(image);
2898
+ if ((0, is_url_superb_1.default)(image)) {
2899
+ image = yield (0, tools_1.getDUrl)(image);
2911
2900
  }
2912
2901
  else {
2913
2902
  const relativePath = path.join(path.resolve(process.cwd(), image || ''));
2914
2903
  if (fs.existsSync(image) || fs.existsSync(relativePath)) {
2915
- image = yield datauri_1.default(fs.existsSync(image) ? image : relativePath);
2904
+ image = yield (0, datauri_1.default)(fs.existsSync(image) ? image : relativePath);
2916
2905
  }
2917
2906
  else
2918
2907
  return 'FILE_NOT_FOUND';
@@ -2940,15 +2929,15 @@ class Client {
2940
2929
  file = file.toString('base64');
2941
2930
  }
2942
2931
  if (typeof file === 'string') {
2943
- if (!tools_1.isDataURL(file) && !tools_1.isBase64(file)) {
2932
+ if (!(0, tools_1.isDataURL)(file) && !(0, tools_1.isBase64)(file)) {
2944
2933
  //must be a file then
2945
- if (is_url_superb_1.default(file)) {
2946
- file = yield tools_1.getDUrl(file);
2934
+ if ((0, is_url_superb_1.default)(file)) {
2935
+ file = yield (0, tools_1.getDUrl)(file);
2947
2936
  }
2948
2937
  else {
2949
2938
  const relativePath = path.join(path.resolve(process.cwd(), file || ''));
2950
2939
  if (fs.existsSync(file) || fs.existsSync(relativePath)) {
2951
- file = yield datauri_1.default(fs.existsSync(file) ? file : relativePath);
2940
+ file = yield (0, datauri_1.default)(fs.existsSync(file) ? file : relativePath);
2952
2941
  }
2953
2942
  else
2954
2943
  return 'FILE_NOT_FOUND';
@@ -2971,6 +2960,7 @@ class Client {
2971
2960
  catch (error) {
2972
2961
  const msg = 'Stickers have to be less than 1MB. Please lower the fps or shorten the duration using the processOptions parameter: https://open-wa.github.io/wa-automate-nodejs/classes/client.html#sendmp4assticker';
2973
2962
  console.log(msg);
2963
+ logging_1.log.warn(msg);
2974
2964
  throw new errors_1.CustomError(errors_1.ERROR_NAME.STICKER_TOO_LARGE, msg);
2975
2965
  }
2976
2966
  });
@@ -3331,7 +3321,7 @@ class Client {
3331
3321
  return yield this._webhookQueue.add(() => __awaiter(this, void 0, void 0, function* () {
3332
3322
  return yield Promise.all([
3333
3323
  ...Object.keys(this._registeredWebhooks).map(webhookId => this._registeredWebhooks[webhookId]).filter(webhookEntry => webhookEntry.events.includes(event))
3334
- ].map(({ id, url, requestConfig }) => axios_1.default(Object.assign({ method: 'post', url, data: this.prepEventData(_data, event, { webhook_id: id }) }, requestConfig)).catch(err => console.error(`WEBHOOK ERROR: `, url, err.message))));
3324
+ ].map(({ id, url, requestConfig }) => (0, axios_1.default)(Object.assign({ method: 'post', url, data: this.prepEventData(_data, event, { webhook_id: id }) }, requestConfig)).catch(err => console.error(`WEBHOOK ERROR: `, url, err.message))));
3335
3325
  }));
3336
3326
  }), 10000);
3337
3327
  }
@@ -3354,7 +3344,7 @@ class Client {
3354
3344
  if (!this._webhookQueue)
3355
3345
  this._webhookQueue = new p_queue_1.default({ concurrency });
3356
3346
  const validListeners = yield this._setupWebhooksOnListeners(events);
3357
- const id = uuid_1.v4();
3347
+ const id = (0, uuid_1.v4)();
3358
3348
  if (validListeners.length) {
3359
3349
  this._registeredWebhooks[id] = {
3360
3350
  id,
@@ -3366,12 +3356,13 @@ class Client {
3366
3356
  return this._registeredWebhooks[id];
3367
3357
  }
3368
3358
  console.log('Invalid listener(s)', events);
3359
+ logging_1.log.warn('Invalid listener(s)', events);
3369
3360
  return false;
3370
3361
  });
3371
3362
  }
3372
3363
  prepEventData(data, event, extras) {
3373
3364
  const sessionId = this.getSessionId();
3374
- return Object.assign({ ts: Date.now(), sessionId, id: uuid_1.v4(), event,
3365
+ return Object.assign({ ts: Date.now(), sessionId, id: (0, uuid_1.v4)(), event,
3375
3366
  data }, extras);
3376
3367
  }
3377
3368
  getEventSignature(simpleListener) {
@@ -3384,12 +3375,14 @@ class Client {
3384
3375
  this._registeredEvListeners = {};
3385
3376
  if (this._registeredEvListeners[simpleListener]) {
3386
3377
  console.log('Listener already registered');
3378
+ logging_1.log.warn('Listener already registered');
3387
3379
  return false;
3388
3380
  }
3389
3381
  this._registeredEvListeners[simpleListener] = yield this[simpleListener](data => events_1.ev.emit(this.getEventSignature(simpleListener), this.prepEventData(data, simpleListener)));
3390
3382
  return true;
3391
3383
  }
3392
3384
  console.log('Invalid lisetner', simpleListener);
3385
+ logging_1.log.warn('Invalid lisetner', simpleListener);
3393
3386
  return false;
3394
3387
  });
3395
3388
  }
@@ -1,5 +1,6 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import { PREPROCESSORS } from '../../structures/preProcessors';
3
+ import { ConfigLogTransport } from '../../logging/logging';
3
4
  import { Base64 } from "./aliases";
4
5
  import { SimpleListener } from './events';
5
6
  /**
@@ -741,6 +742,12 @@ export interface ConfigObject {
741
742
  * Expose a URL where you can easily scan the qr code
742
743
  */
743
744
  ezqr?: boolean;
745
+ /**
746
+ * An array of [winston](https://github.com/winstonjs/winston/blob/master/docs/transports.md#additional-transports) logging transport configurations.
747
+ *
748
+ * [Check this discussion to see how to set up logging](https://github.com/open-wa/wa-automate-nodejs/discussions/2373)
749
+ */
750
+ logging?: ConfigLogTransport[];
744
751
  /**@internal */
745
752
  [x: string]: any;
746
753
  }