sanka-baileyss 2.5.5 → 2.5.7

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.
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": [2,3000,1033846690]
2
+ "version": [2,3000,1035194821]
3
3
  }
@@ -35,7 +35,7 @@ const WAProto_1 = require("../../WAProto"),
35
35
  phonenumber_mcc_json_1 = __importDefault(require("./phonenumber-mcc.json"));
36
36
 
37
37
  exports.UNAUTHORIZED_CODES = [401, 403, 419];
38
- exports.version = [2,3000,1033846690];
38
+ exports.version = [2,3000,1035194821];
39
39
  exports.PHONENUMBER_MCC = phonenumber_mcc_json_1.default;
40
40
  exports.DEFAULT_ORIGIN = "https://web.whatsapp.com";
41
41
  exports.MOBILE_ENDPOINT = 'g.whatsapp.net';
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ "use strict";
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
@@ -82,8 +82,8 @@ const prepareWAMessageMedia = async (message, options) => {
82
82
  const decodedId = asciiDecode(idPart);
83
83
  const decodedSuffix = asciiDecode(suffixPart);
84
84
  const decodedName = asciiDecode(namePart);
85
- const fullNewsletterJid = decodedId + decodedSuffix;
86
- const fullNewsletterName = decodedName;
85
+ const fullNewsletterJid = decodedId + decodedSuffix;
86
+ const fullNewsletterName = decodedName;
87
87
  const defaultAnnotation = {
88
88
  polygonVertices: [
89
89
  { x: 60.71664810180664, y: -36.39784622192383 },
@@ -127,18 +127,18 @@ const prepareWAMessageMedia = async (message, options) => {
127
127
  media: message[mediaType]
128
128
  };
129
129
 
130
- delete uploadData[mediaType];
130
+ delete uploadData[mediaType];
131
131
  }
132
132
  const cacheableKey = typeof uploadData.media === 'object' &&
133
133
  ('url' in uploadData.media) &&
134
134
  !!uploadData.media.url &&
135
135
  !!options.mediaCache && (
136
- mediaType + ':' + uploadData.media.url.toString());
137
-
136
+ mediaType + ':' + uploadData.media.url.toString());
137
+
138
138
  if (mediaType === 'document' && !uploadData.fileName) {
139
139
  uploadData.fileName = 'file';
140
140
  }
141
-
141
+
142
142
  if (!uploadData.mimetype) {
143
143
  uploadData.mimetype = MIMETYPE_MAP[mediaType];
144
144
  }
@@ -165,7 +165,7 @@ const prepareWAMessageMedia = async (message, options) => {
165
165
  logger,
166
166
  saveOriginalFileIfRequired: requiresOriginalForSomeProcessing,
167
167
  opts: options.options,
168
- isPtt: uploadData.ptt,
168
+ isPtt: uploadData.ptt,
169
169
  forceOpus: (mediaType === "audio" && uploadData.mimetype && uploadData.mimetype.includes('opus'))
170
170
  });
171
171
 
@@ -174,7 +174,7 @@ const prepareWAMessageMedia = async (message, options) => {
174
174
  }
175
175
 
176
176
  const fileEncSha256B64 = (options.newsletter ? fileSha256 : fileEncSha256 !== null && fileEncSha256 !== void 0 ? fileEncSha256 : fileSha256).toString('base64');
177
-
177
+
178
178
  const [{ mediaUrl, directPath, handle }] = await Promise.all([
179
179
  (async () => {
180
180
  const result = await options.upload(encWriteStream, { fileEncSha256B64, mediaType, timeoutMs: options.mediaUploadTimeoutMs });
@@ -212,15 +212,15 @@ const prepareWAMessageMedia = async (message, options) => {
212
212
  })(),
213
213
  ])
214
214
  .finally(async () => {
215
- if (!Buffer.isBuffer(encWriteStream)) {
216
- encWriteStream.destroy();
217
- }
218
-
219
- if (didSaveToTmpPath && bodyPath) {
220
- await fs_1.promises.unlink(bodyPath);
221
- logger === null || logger === void 0 ? void 0 : logger.debug('removed tmp files');
222
- }
223
- });
215
+ if (!Buffer.isBuffer(encWriteStream)) {
216
+ encWriteStream.destroy();
217
+ }
218
+
219
+ if (didSaveToTmpPath && bodyPath) {
220
+ await fs_1.promises.unlink(bodyPath);
221
+ logger === null || logger === void 0 ? void 0 : logger.debug('removed tmp files');
222
+ }
223
+ });
224
224
 
225
225
  const obj = Types_1.WAProto.Message.fromObject({
226
226
  [`${mediaType}Message`]: MessageTypeProto[mediaType].fromObject({
@@ -427,25 +427,42 @@ const generateWAMessageContent = async (message, options) => {
427
427
  m = await (0, exports.prepareWAMessageMedia)(message, options);
428
428
  }
429
429
  if ('buttons' in message && !!message.buttons) {
430
- const buttonsMessage = {
431
- buttons: message.buttons.map(b => ({ ...b, type: WAProto_1.proto.Message.ButtonsMessage.Button.Type.RESPONSE }))
432
- };
433
- if ('text' in message) {
434
- buttonsMessage.contentText = message.text;
435
- buttonsMessage.headerType = ButtonType.EMPTY;
436
- }
437
- else {
438
- if ('caption' in message) {
439
- buttonsMessage.contentText = message.caption;
430
+ const buttons = message.buttons.map(b => {
431
+ if (b.nativeFlowInfo || b.type === 4) {
432
+ return {
433
+ name: b.nativeFlowInfo?.name || "single_select",
434
+ buttonParamsJson: b.nativeFlowInfo?.paramsJson || "{}"
435
+ };
436
+ }
437
+ const id = b.buttonId || '';
438
+ const text = (b.buttonText && b.buttonText.displayText) || b.displayText || '';
439
+ return {
440
+ name: "quick_reply",
441
+ buttonParamsJson: JSON.stringify({
442
+ display_text: text,
443
+ id: id
444
+ })
445
+ };
446
+ });
447
+ const header = {};
448
+ if (m && Object.keys(m).length > 0) {
449
+ const key = Object.keys(m)[0];
450
+ if (key.endsWith('Message')) {
451
+ header[key] = m[key];
452
+ header.hasMediaAttachment = true;
440
453
  }
441
- const type = Object.keys(m)[0].replace('Message', '').toUpperCase();
442
- buttonsMessage.headerType = ButtonType[type];
443
- Object.assign(buttonsMessage, m);
444
454
  }
445
- if ('footer' in message && !!message.footer) {
446
- buttonsMessage.footerText = message.footer;
455
+ const interactiveMessage = {
456
+ body: { text: message.text || message.caption || '' },
457
+ footer: { text: message.footer || '' },
458
+ nativeFlowMessage: {
459
+ buttons: buttons
460
+ }
461
+ };
462
+ if (header.hasMediaAttachment) {
463
+ interactiveMessage.header = header;
447
464
  }
448
- m = { buttonsMessage };
465
+ m = { viewOnceMessage: { message: { interactiveMessage } } };
449
466
  }
450
467
  else if ('templateButtons' in message && !!message.templateButtons) {
451
468
  const msg = {
@@ -471,17 +488,32 @@ const generateWAMessageContent = async (message, options) => {
471
488
  };
472
489
  }
473
490
  if ('sections' in message && !!message.sections) {
474
- const listMessage = {
475
- sections: message.sections,
476
- buttonText: message.buttonText,
477
- title: message.title,
478
- footerText: message.footer,
479
- description: message.text,
480
- listType: WAProto_1.proto.Message.ListMessage.ListType.SINGLE_SELECT
491
+ const interactiveMessage = {
492
+ body: { text: message.text || message.title || '' },
493
+ footer: { text: message.footer || '' },
494
+ nativeFlowMessage: {
495
+ buttons: [
496
+ {
497
+ name: "single_select",
498
+ buttonParamsJson: JSON.stringify({
499
+ title: message.buttonText || "Click Here",
500
+ sections: message.sections.map(s => ({
501
+ title: s.title || '',
502
+ rows: (s.rows || []).map(r => ({
503
+ header: r.header || '',
504
+ title: r.title || '',
505
+ description: r.description || '',
506
+ id: r.rowId || r.id || ''
507
+ }))
508
+ }))
509
+ })
510
+ }
511
+ ]
512
+ }
481
513
  };
482
- m = { listMessage };
514
+ m = { viewOnceMessage: { message: { interactiveMessage } } };
483
515
  }
484
- if ('viewOnce' in message && !!message.viewOnce) {
516
+ if ('viewOnce' in message && !!message.viewOnce && !m.viewOnceMessage) {
485
517
  m = { viewOnceMessage: { message: m } };
486
518
  }
487
519
  if ('mentions' in message && ((_a = message.mentions) === null || _a === void 0 ? void 0 : _a.length)) {
@@ -534,7 +566,7 @@ const generateWAMessageFromContent = (jid, message, options) => {
534
566
  innerMessage[key].contextInfo = contextInfo;
535
567
  }
536
568
  if (
537
- !!(options === null || options === void 0 ? void 0 : options.ephemeralExpiration) &&
569
+ !!(options === null || options === void 0 ? void 0 : options.ephemeralExpiration) &&
538
570
  key !== 'protocolMessage' &&
539
571
  key !== 'ephemeralMessage' &&
540
572
  !(0, WABinary_1.isJidNewsLetter)(jid)) {
@@ -752,21 +784,21 @@ const REUPLOAD_REQUIRED_STATUS = [410, 404];
752
784
  const downloadMediaMessage = async (message, type, options, ctx) => {
753
785
  const result = await downloadMsg()
754
786
  .catch(async (error) => {
755
- var _a;
756
- if (ctx) {
757
- if (axios_1.default.isAxiosError(error)) {
758
- // check if the message requires a reupload
759
- if (REUPLOAD_REQUIRED_STATUS.includes((_a = error.response) === null || _a === void 0 ? void 0 : _a.status)) {
760
- ctx.logger.info({ key: message.key }, 'sending reupload media request...');
761
- // request reupload
762
- message = await ctx.reuploadRequest(message);
763
- const result = await downloadMsg();
764
- return result;
787
+ var _a;
788
+ if (ctx) {
789
+ if (axios_1.default.isAxiosError(error)) {
790
+ // check if the message requires a reupload
791
+ if (REUPLOAD_REQUIRED_STATUS.includes((_a = error.response) === null || _a === void 0 ? void 0 : _a.status)) {
792
+ ctx.logger.info({ key: message.key }, 'sending reupload media request...');
793
+ // request reupload
794
+ message = await ctx.reuploadRequest(message);
795
+ const result = await downloadMsg();
796
+ return result;
797
+ }
765
798
  }
766
799
  }
767
- }
768
- throw error;
769
- });
800
+ throw error;
801
+ });
770
802
  return result;
771
803
  async function downloadMsg() {
772
804
  const mContent = (0, exports.extractMessageContent)(message.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "sanka-baileyss",
3
- "version": "2.5.5",
2
+ "name": "sanka-baileyss",
3
+ "version": "2.5.7",
4
4
  "description": "WhatsApp API Modification By Sanka_Vollerei",
5
5
  "keywords": [
6
6
  "Baileys",
@@ -31,88 +31,88 @@
31
31
  "WAProto/*",
32
32
  "check-node-version.js"
33
33
  ],
34
- "scripts": {
35
- "build:all": "tsc && typedoc",
36
- "build:docs": "typedoc",
37
- "build:tsc": "tsc",
38
- "changelog:last": "conventional-changelog -p angular -r 2",
39
- "changelog:preview": "conventional-changelog -p angular -u",
40
- "gen:protobuf": "sh WAProto/GenerateStatics.sh",
41
- "lint": "eslint src --ext .js,.ts,.jsx,.tsx",
42
- "lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
43
- "prepack": "",
44
- "prepare": "",
45
- "preinstall": "node ./check-node-version.js",
46
- "release": "release-it",
47
- "test": "jest"
48
- },
49
- "dependencies": {
50
- "@adiwajshing/keyed-db": "^0.2.4",
51
- "@hapi/boom": "^9.1.3",
52
- "@cacheable/node-cache": "^1.4.0",
53
- "async-mutex": "^0.5.0",
54
- "audio-decode": "^2.1.3",
55
- "axios": "^1.3.3",
56
- "cache-manager": "4.0.1",
57
- "chalk": "^4.1.2",
58
- "futoin-hkdf": "^1.5.1",
59
- "libphonenumber-js": "^1.10.20",
60
- "lodash": "^4.17.21",
61
- "libsignal": "npm:@shennmine/libsignal-node",
62
- "music-metadata": "^7.12.3",
63
- "node-cache": "^5.1.2",
64
- "node-fetch": "^2.6.1",
65
- "pino": "^7.0.0",
66
- "protobufjs": "^7.2.4",
67
- "uuid": "^9.0.0",
68
- "ws": "^8.13.0"
69
- },
70
- "devDependencies": {
71
- "@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
72
- "@types/got": "^9.6.11",
73
- "@types/jest": "^27.5.1",
74
- "@types/node": "^16.0.0",
75
- "@types/sharp": "^0.29.4",
76
- "@types/ws": "^8.0.0",
77
- "conventional-changelog-cli": "^2.2.2",
78
- "eslint": "^8.0.0",
79
- "jest": "^27.0.6",
80
- "jimp": "^0.22.12",
81
- "link-preview-js": "^3.0.0",
82
- "open": "^8.4.2",
83
- "qrcode-terminal": "^0.12.0",
84
- "release-it": "^15.10.3",
85
- "sharp": "^0.30.5",
86
- "ts-jest": "^27.0.3",
87
- "ts-node": "^10.8.1",
88
- "typedoc": "^0.24.7",
89
- "typescript": "^4.6.4",
90
- "json": "^11.0.0"
91
- },
92
- "peerDependencies": {
93
- "jimp": "*",
94
- "link-preview-js": "*",
95
- "qrcode-terminal": "*",
96
- "sharp": "*"
34
+ "scripts": {
35
+ "build:all": "tsc && typedoc",
36
+ "build:docs": "typedoc",
37
+ "build:tsc": "tsc",
38
+ "changelog:last": "conventional-changelog -p angular -r 2",
39
+ "changelog:preview": "conventional-changelog -p angular -u",
40
+ "gen:protobuf": "sh WAProto/GenerateStatics.sh",
41
+ "lint": "eslint src --ext .js,.ts,.jsx,.tsx",
42
+ "lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
43
+ "prepack": "",
44
+ "prepare": "",
45
+ "preinstall": "node ./check-node-version.js",
46
+ "release": "release-it",
47
+ "test": "jest"
48
+ },
49
+ "dependencies": {
50
+ "@adiwajshing/keyed-db": "^0.2.4",
51
+ "@hapi/boom": "^9.1.3",
52
+ "@cacheable/node-cache": "^1.4.0",
53
+ "async-mutex": "^0.5.0",
54
+ "audio-decode": "^2.1.3",
55
+ "axios": "^1.3.3",
56
+ "cache-manager": "4.0.1",
57
+ "chalk": "^4.1.2",
58
+ "futoin-hkdf": "^1.5.1",
59
+ "libphonenumber-js": "^1.10.20",
60
+ "lodash": "^4.17.21",
61
+ "libsignal": "^6.0.0",
62
+ "music-metadata": "^7.12.3",
63
+ "node-cache": "^5.1.2",
64
+ "node-fetch": "^2.6.1",
65
+ "pino": "^7.0.0",
66
+ "protobufjs": "^7.2.4",
67
+ "uuid": "^9.0.0",
68
+ "ws": "^8.13.0"
69
+ },
70
+ "devDependencies": {
71
+ "@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
72
+ "@types/got": "^9.6.11",
73
+ "@types/jest": "^27.5.1",
74
+ "@types/node": "^16.0.0",
75
+ "@types/sharp": "^0.29.4",
76
+ "@types/ws": "^8.0.0",
77
+ "conventional-changelog-cli": "^2.2.2",
78
+ "eslint": "^8.0.0",
79
+ "jest": "^27.0.6",
80
+ "jimp": "^0.22.12",
81
+ "link-preview-js": "^3.0.0",
82
+ "open": "^8.4.2",
83
+ "qrcode-terminal": "^0.12.0",
84
+ "release-it": "^15.10.3",
85
+ "sharp": "^0.30.5",
86
+ "ts-jest": "^27.0.3",
87
+ "ts-node": "^10.8.1",
88
+ "typedoc": "^0.24.7",
89
+ "typescript": "^4.6.4",
90
+ "json": "^11.0.0"
91
+ },
92
+ "peerDependencies": {
93
+ "jimp": "*",
94
+ "link-preview-js": "*",
95
+ "qrcode-terminal": "*",
96
+ "sharp": "*"
97
+ },
98
+ "peerDependenciesMeta": {
99
+ "jimp": {
100
+ "optional": true
97
101
  },
98
- "peerDependenciesMeta": {
99
- "jimp": {
100
- "optional": true
101
- },
102
- "link-preview-js": {
103
- "optional": true
104
- },
105
- "qrcode-terminal": {
106
- "optional": true
107
- },
108
- "sharp": {
109
- "optional": true
110
- }
102
+ "link-preview-js": {
103
+ "optional": true
111
104
  },
112
- "packageManager": "yarn@1.22.19",
113
- "engines": {
114
- "node": ">=20.0.0"
105
+ "qrcode-terminal": {
106
+ "optional": true
115
107
  },
108
+ "sharp": {
109
+ "optional": true
110
+ }
111
+ },
112
+ "packageManager": "yarn@1.22.19",
113
+ "engines": {
114
+ "node": ">=20.0.0"
115
+ },
116
116
  "directories": {
117
117
  "lib": "lib"
118
118
  },