wwebjs-aws-s3
v1.0.2
Published
A plugin for remote authentication on whatsapp-web.js and store session data on AWS S3.
Downloads
8,917
Maintainers
Readme
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.
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 { Client, RemoteAuth } = require('whatsapp-web.js');
const { AwsS3Store } = require('wwebjs-aws-s3');
const { S3Client, PutObjectCommand, HeadObjectCommand, GetObjectCommand, DeleteObjectCommand } = require('@aws-sdk/client-s3');
const s3 = new S3Client({
region: 'AWS_REGION',
credentials: {
accessKeyId: 'AWS_ACCESS_KEY_ID',
secretAccessKey: 'AWS_SECRET_ACCESS_KEY'
}
});
const putObjectCommand = PutObjectCommand;
const headObjectCommand = HeadObjectCommand;
const getObjectCommand = GetObjectCommand;
const deleteObjectCommand = DeleteObjectCommand;
const store = new AwsS3Store({
bucketName: 'example-bucket',
remoteDataPath: 'example/path/',
s3Client: s3,
putObjectCommand,
headObjectCommand,
getObjectCommand,
deleteObjectCommand
});
const client = new Client({
authStrategy: new RemoteAuth({
clientId: 'yourSessionName',
dataPath: './.wwebjs_auth',
store: store,
backupSyncIntervalMs: 600000
})
});
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!');
});
client.on('message', msg => {
if (msg.body == '!ping') {
msg.reply('pong');
}
});
client.initialize();
Delete Remote Session
How to force delete a specific remote session on the Database:
await store.delete({session: 'yourSessionName'});