Coder Social home page Coder Social logo

eltonjhsouza / wwebjs-aws-s3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arbisyarifudin/wwebjs-aws-s3

0.0 0.0 0.0 11 KB

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

License: MIT License

JavaScript 100.00%

wwebjs-aws-s3's Introduction

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 { 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'});

wwebjs-aws-s3's People

Contributors

arbisyarifudin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.