store-s3-aws 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Arbi Syarifudin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # wwebjs-aws-s3
2
+ A remote authentication plugin for [whatsapp-web.js](https://wwebjs.dev/). Use the AWS S3 to keep your WhatsApp MultiDevice session data safe and secure.
3
+
4
+ ![GitHub license](https://img.shields.io/github/license/arbisyarifudin/wwebjs-aws-s3.svg) [![npm version](https://badge.fury.io/js/wwebjs-aws-s3.svg)](https://badge.fury.io/js/wwebjs-aws-s3)
5
+ [![npm downloads](https://img.shields.io/npm/dm/wwebjs-aws-s3.svg)](https://npm-stat.com/charts.html?package=wwebjs-aws-s3)
6
+ ![GitHub issues](https://img.shields.io/github/issues/arbisyarifudin/wwebjs-aws-s3.svg)
7
+
8
+ ## Quick Links
9
+
10
+ * [Whatsapp-web JS](https://wwebjs.dev/guide/authentication.html)
11
+ * [GitHub](https://github.com/arbisyarifudin/wwebjs-aws-s3)
12
+ * [npm](https://www.npmjs.com/package/wwebjs-aws-s3)
13
+
14
+ ## Installation
15
+
16
+ The module is now available on npm! `npm i wwebjs-aws-s3`
17
+
18
+ ## DEBUG mode
19
+
20
+ To see detailed logs about object health, set the environment variable STORE_DEBUG to "true".
21
+
22
+ ```bash
23
+ # linux
24
+ $ export STORE_DEBUG=true
25
+
26
+ # windows
27
+ $ SET STORE_DEBUG=true
28
+ ```
29
+
30
+ ## Example usage
31
+
32
+ ```js
33
+ const { Client, RemoteAuth } = require('whatsapp-web.js');
34
+ const { AwsS3Store } = require('wwebjs-aws-s3');
35
+ const { S3Client, PutObjectCommand, HeadObjectCommand, GetObjectCommand, DeleteObjectCommand } = require('@aws-sdk/client-s3');
36
+
37
+
38
+ const s3 = new S3Client({
39
+ region: 'AWS_REGION',
40
+ credentials: {
41
+ accessKeyId: 'AWS_ACCESS_KEY_ID',
42
+ secretAccessKey: 'AWS_SECRET_ACCESS_KEY'
43
+ }
44
+ });
45
+
46
+ const putObjectCommand = PutObjectCommand;
47
+ const headObjectCommand = HeadObjectCommand;
48
+ const getObjectCommand = GetObjectCommand;
49
+ const deleteObjectCommand = DeleteObjectCommand;
50
+
51
+ const store = new AwsS3Store({
52
+ bucketName: 'example-bucket',
53
+ remoteDataPath: 'example/path/',
54
+ s3Client: s3,
55
+ putObjectCommand,
56
+ headObjectCommand,
57
+ getObjectCommand,
58
+ deleteObjectCommand
59
+ });
60
+
61
+
62
+ const client = new Client({
63
+ authStrategy: new RemoteAuth({
64
+ clientId: 'yourSessionName',
65
+ dataPath: './.wwebjs_auth',
66
+ store: store,
67
+ backupSyncIntervalMs: 600000
68
+ })
69
+ });
70
+
71
+ client.on('qr', (qr) => {
72
+ // Generate and scan this code with your phone
73
+ console.log('QR RECEIVED', qr);
74
+ qrcode.generate(qr, { small: true });
75
+ });
76
+
77
+ client.on('ready', () => {
78
+ console.log('Client is ready!');
79
+ });
80
+
81
+ client.on('message', msg => {
82
+ if (msg.body == '!ping') {
83
+ msg.reply('pong');
84
+ }
85
+ });
86
+
87
+ client.initialize();
88
+ ```
89
+
90
+ ## Delete Remote Session
91
+
92
+ How to force delete a specific remote session on the Database:
93
+
94
+ ```js
95
+ await store.delete({session: 'yourSessionName'});
96
+ ```
@@ -0,0 +1,10 @@
1
+ const AwsS3Store = require('../src/AwsS3Store');
2
+ require('dotenv').config();
3
+
4
+ const store = new AwsS3Store({
5
+ bucketName: 'whatsapp-remote-sessions',
6
+ remoteDataPath: 'sessions',
7
+ clientConfig: {region: 'sa-east-1'}
8
+ });
9
+
10
+ store.save({session: "123"})
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "example",
3
+ "version": "1.0.0",
4
+ "description": "Example project for wwebjs remote auth with AWS S3",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "arbisyarifudin",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "@aws-sdk/client-s3": "^3.369.0",
13
+ "dotenv": "^16.4.7",
14
+ "qrcode-terminal": "^0.12.0",
15
+ "whatsapp-web.js": "^1.21.0"
16
+ }
17
+ }
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export const AwsS3Store: typeof import("./src/AwsS3Store");
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ AwsS3Store: require('./src/AwsS3Store')
5
+ };
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "store-s3-aws",
3
+ "version": "1.0.0",
4
+ "description": "Lib to store files in AWS S3",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [
10
+ "files",
11
+ "aws",
12
+ "s3"
13
+ ],
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "@aws-sdk/client-s3": "^3.777.0",
17
+ "@aws-sdk/lib-storage": "^3.779.0"
18
+ }
19
+ }