@rexxhayanasi/elaina-baileys 1.1.0-rc.7 → 1.1.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.
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.useSQLiteAuth = void 0;
5
5
 
6
- const better_sqlite3_1 = require("better-sqlite3");
7
- const baileys_1 = require("../index");
6
+ const BetterSqlite = require("better-sqlite3");
7
+ const { BufferJSON } = require("../index");
8
+ const { initAuthCreds } = require("../Utils");
8
9
 
9
- const BetterSqlite = better_sqlite3_1.default || better_sqlite3_1;
10
10
  const db = new BetterSqlite("./session.db");
11
11
 
12
12
  db.exec(`
@@ -19,23 +19,22 @@ db.exec(`
19
19
  const useSQLiteAuth = () => {
20
20
  const readData = (id) => {
21
21
  const row = db.prepare("SELECT data FROM auth WHERE id=?").get(id);
22
- return row ? JSON.parse(row.data, baileys_1.BufferJSON.reviver) : null;
22
+ return row ? JSON.parse(row.data, BufferJSON.reviver) : null;
23
23
  };
24
24
 
25
25
  const writeData = (id, data) => {
26
26
  db.prepare("INSERT OR REPLACE INTO auth VALUES (?, ?)")
27
- .run(id, JSON.stringify(data, baileys_1.BufferJSON.replacer));
27
+ .run(id, JSON.stringify(data, BufferJSON.replacer));
28
28
  };
29
29
 
30
30
  const state = {
31
- creds: readData("creds") || {},
31
+ creds: readData("creds") || initAuthCreds(),
32
32
  keys: {
33
33
  get(type, ids) {
34
34
  const data = {};
35
35
  for (const id of ids) {
36
- const v = readData(`${type}-${id}`);
37
- if (v)
38
- data[id] = v;
36
+ const value = readData(`${type}-${id}`);
37
+ if (value) data[id] = value;
39
38
  }
40
39
  return data;
41
40
  },
@@ -429,8 +429,12 @@ const end = (error) => {
429
429
  authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5))
430
430
  }
431
431
 
432
- authState.creds.pairingPhone = phoneNumber
433
- ev.emit('creds.update', authState.creds)
432
+ authState.creds.me = {
433
+ id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
434
+ name: '~'
435
+ }
436
+
437
+ ev.emit('creds.update', authState.creds)
434
438
 
435
439
  await sendNode({
436
440
  tag: 'iq',
@@ -444,8 +448,9 @@ ev.emit('creds.update', authState.creds)
444
448
  {
445
449
  tag: 'link_code_companion_reg',
446
450
  attrs: {
447
- stage: 'companion_hello',
448
- should_show_push_notification: 'true'
451
+ jid: authState.creds.me.id,
452
+ stage: 'companion_hello',
453
+ should_show_push_notification: 'true'
449
454
  },
450
455
  content: [
451
456
  {
@@ -525,19 +530,14 @@ ev.emit('creds.update', authState.creds)
525
530
  };
526
531
  ws.on('message', onMessageReceived);
527
532
  ws.on('open', async () => {
528
- try {
529
- if (!authState.creds.isConnecting) {
530
- authState.creds.isConnecting = true;
531
- ev.emit('creds.update', authState.creds);
533
+ try {
534
+ await validateConnection();
532
535
  }
533
-
534
- await validateConnection();
535
- }
536
- catch (err) {
537
- logger.error({ err }, 'error in validating connection');
538
- end(err);
539
- }
540
- });
536
+ catch (err) {
537
+ logger.error({ err }, 'error in validating connection');
538
+ end(err);
539
+ }
540
+ });
541
541
  ws.on('error', mapWebSocketError(end));
542
542
  ws.on('close', () => end(new boom_1.Boom('Connection Terminated', { statusCode: Types_1.DisconnectReason.connectionClosed })));
543
543
  // the server terminated the connection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexxhayanasi/elaina-baileys",
3
- "version": "1.1.0-rc.7",
3
+ "version": "1.1.0",
4
4
  "description": "Custom Baileys WhatsApp API",
5
5
  "keywords": [
6
6
  "baileys",
@@ -12,7 +12,8 @@
12
12
  "whatsapp-web",
13
13
  "whatsapp-bot",
14
14
  "automation",
15
- "multi-device"
15
+ "multi-device",
16
+ "RexxHayanasi"
16
17
  ],
17
18
  "homepage": "https://whatsapp.com/channel/0029Vb70uHbD8SE2w5Q9M107",
18
19
  "license": "MIT",
@@ -46,8 +47,8 @@
46
47
  "@cacheable/node-cache": "^1.4.0",
47
48
  "@hapi/boom": "^9.1.3",
48
49
  "async-mutex": "^0.5.0",
50
+ "audio-decode": "^2.1.3",
49
51
  "axios": "^1.6.0",
50
- "better-sqlite3": "^12.5.0",
51
52
  "chalk": "^4.1.2",
52
53
  "gradient-string": "^2.0.2",
53
54
  "cache-manager": "^5.7.6",
@@ -84,16 +85,13 @@
84
85
  "typescript": "^5.8.2"
85
86
  },
86
87
  "peerDependencies": {
87
- "audio-decode": "^2.1.3",
88
88
  "jimp": "^0.22.10",
89
89
  "link-preview-js": "^3.0.0",
90
90
  "qrcode-terminal": "^0.12.0",
91
- "sharp": "^0.34.1"
91
+ "sharp": "^0.34.1",
92
+ "better-sqlite3": "^12.5.0"
92
93
  },
93
- "peerDependenciesMeta": {
94
- "audio-decode": {
95
- "optional": true
96
- },
94
+ "peerDependenciesMeta": {
97
95
  "jimp": {
98
96
  "optional": true
99
97
  },