Skip to content

A remote authentication plugin for whatsapp-web.js. Use the AWS S3 to keep your WhatsApp MultiDevice session data safe and secure.

License

Notifications You must be signed in to change notification settings

arbisyarifudin/wwebjs-aws-s3

Repository files navigation

wwebjs-aws-s3

A remote authentication plugin for whatsapp-web.js. Use the AWS S3 to keep your WhatsApp MultiDevice session data safe and secure.

GitHub license npm version npm downloads GitHub issues

Quick Links

Installation

The module is now available on npm! npm i wwebjs-aws-s3

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 { AwsS3Store, S3Client } = require('../src/AwsS3Store');
const { Client, RemoteAuth } = require('whatsapp-web.js');
const qrcode = require('qrcode-terminal');

const s3 = new S3Client({
    region: 'AWS_REGION',
    credentials: {
        accessKeyId: 'AWS_ACCESS_KEY_ID',
        secretAccessKey: 'AWS_SECRET_ACCESS_KEY'
    },
    httpOptions: {
        timeout: 600000, // 10 minutes <-- increase this value for large file uploads
    },
});

const store = new AwsS3Store({
    bucketName: 'example-bucket',
    remoteDataPath: 'example/dir',
    s3Client: s3
});

const client = new Client({
    authStrategy: new RemoteAuth({
        clientId: 'yourSessionName',
        dataPath: './.wwebjs_auth',
        store: store,
        backupSyncIntervalMs: 600000 // in milliseconds (10 minutes) <-- decrease this value if you want to test the backup feature
    })
});


client.on('qr', (qr) => {
    // Generate and scan this code with your phone
    console.log('QR RECEIVED', qr);
    qrcode.generate(qr, { small: true });
});

client.on('ready', () => {
    console.log('Client is ready!');

    // trigger whatsapp client is started and ready
});

client.on('message', msg => {
    if (msg.body == '!ping') {
        msg.reply('pong');
    }
});

// it will done early (so use event 'ready' listener to know when the whatsapp client is ready & started)
client.initialize();

Delete Remote Session

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

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

About

A remote authentication plugin for whatsapp-web.js. Use the AWS S3 to keep your WhatsApp MultiDevice session data safe and secure.

Topics

Resources

License

Stars

Watchers

Forks