1.0.1 • Published 2 years ago

wwebjs-sftp v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

wwebjs-sftp

A SFTP plugin for whatsapp-web.js (used to "RemoteAuth").

Use the SFTP protocol to keep your WhatsApp MultiDevice session on a SFTP server.

Quick Links

Installation

The module is now available on npm! npm i wwebjs-sftp

DEBUG mode

To see detailed logs about object health, set the environment variable STORE_DEBUG to "true".

# linux
$ export STORE_DEBUG=true

# windows
$ SET STORE_DEBUG=true

Example usage

const { Client, RemoteAuth } = require('whatsapp-web.js');
const { SftpStore } = require('wwebjs-sftp');
const SftpClient = require('ssh2-sftp-client');
const sftp = new SftpClient();

sftp.connect({
  host: '<server.example.com>',
  port: '21', // the sftp server service port
  username: '<user name>',
  password: '<user password>'
}).then(() => {
  const store = new SftpStore({ remoteDataPath: '/example/remote/dir', sftp: sftp })
  const client = new Client({
    authStrategy: new RemoteAuth({
      store: store,
      backupSyncIntervalMs: 150000
    })
  });

  client.initialize();
});

Delete Remote Session

How to force delete a specific remote session on the Database:

await store.delete({session: 'yourSessionName'});