@whiskeysockets/baileys
Advanced tools
Comparing version 6.7.4 to 6.7.5
@@ -196,2 +196,3 @@ "use strict"; | ||
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => { | ||
var _a; | ||
key = typeof key === 'string' ? { remoteJid: key } : key; | ||
@@ -228,3 +229,3 @@ const results = await groupQuery(inviteMessage.groupJid, 'set', [{ | ||
remoteJid: inviteMessage.groupJid, | ||
id: (0, Utils_1.generateMessageID)(), | ||
id: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id), | ||
fromMe: false, | ||
@@ -231,0 +232,0 @@ participant: key.remoteJid, |
@@ -250,2 +250,3 @@ "use strict"; | ||
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }) => { | ||
var _a; | ||
const meId = authState.creds.me.id; | ||
@@ -258,3 +259,3 @@ let shouldIncludeDeviceIdentity = false; | ||
const isLid = server === 'lid'; | ||
msgId = msgId || (0, Utils_1.generateMessageID)(); | ||
msgId = msgId || (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id); | ||
useUserDevicesCache = useUserDevicesCache !== false; | ||
@@ -606,3 +607,3 @@ const participants = []; | ||
sendMessage: async (jid, content, options = {}) => { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
const userJid = authState.creds.me.id; | ||
@@ -637,2 +638,3 @@ if (typeof content === 'object' && | ||
options: config.options, | ||
messageId: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id), | ||
...options, | ||
@@ -646,3 +648,3 @@ }); | ||
// if the chat is a group, and I am not the author, then delete the message as an admin | ||
if ((0, WABinary_1.isJidGroup)((_a = content.delete) === null || _a === void 0 ? void 0 : _a.remoteJid) && !((_b = content.delete) === null || _b === void 0 ? void 0 : _b.fromMe)) { | ||
if ((0, WABinary_1.isJidGroup)((_b = content.delete) === null || _b === void 0 ? void 0 : _b.remoteJid) && !((_c = content.delete) === null || _c === void 0 ? void 0 : _c.fromMe)) { | ||
additionalAttributes.edit = '8'; | ||
@@ -649,0 +651,0 @@ } |
@@ -43,5 +43,2 @@ /// <reference types="node" /> | ||
groupLeave: (id: string) => Promise<void>; | ||
/** the network code of your mobile network | ||
* @see {@link https://de.wikipedia.org/wiki/Mobile_Network_Code} | ||
*/ | ||
groupUpdateSubject: (jid: string, subject: string) => Promise<void>; | ||
@@ -48,0 +45,0 @@ groupRequestParticipantsList: (jid: string) => Promise<{ |
@@ -41,2 +41,3 @@ /// <reference types="node" /> | ||
export declare function promiseTimeout<T>(ms: number | undefined, promise: (resolve: (v: T) => void, reject: (error: any) => void) => void): Promise<T>; | ||
export declare const generateMessageIDV2: (userId?: string) => string; | ||
export declare const generateMessageID: () => string; | ||
@@ -43,0 +44,0 @@ export declare function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEventEmitter, event: T): (check: (u: BaileysEventMap[T]) => boolean | undefined, timeoutMs?: number) => Promise<void>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bytesToCrockford = exports.trimUndefined = exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.bindWaitForEvent = exports.generateMessageID = exports.promiseTimeout = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.Browsers = void 0; | ||
exports.bytesToCrockford = exports.trimUndefined = exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.bindWaitForEvent = exports.generateMessageID = exports.generateMessageIDV2 = exports.promiseTimeout = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.Browsers = void 0; | ||
const boom_1 = require("@hapi/boom"); | ||
@@ -151,4 +151,22 @@ const axios_1 = __importDefault(require("axios")); | ||
exports.promiseTimeout = promiseTimeout; | ||
// inspired from whatsmeow code | ||
// https://github.com/tulir/whatsmeow/blob/64bc969fbe78d31ae0dd443b8d4c80a5d026d07a/send.go#L42 | ||
const generateMessageIDV2 = (userId) => { | ||
const data = Buffer.alloc(8 + 20 + 16); | ||
data.writeBigUInt64BE(BigInt(Math.floor(Date.now() / 1000))); | ||
if (userId) { | ||
const id = (0, WABinary_1.jidDecode)(userId); | ||
if (id === null || id === void 0 ? void 0 : id.user) { | ||
data.write(id.user, 8); | ||
data.write('@c.us', 8 + id.user.length); | ||
} | ||
} | ||
const random = (0, crypto_1.randomBytes)(16); | ||
random.copy(data, 28); | ||
const hash = (0, crypto_1.createHash)('sha256').update(data).digest(); | ||
return '3EB0' + hash.toString('hex').toUpperCase().substring(0, 18); | ||
}; | ||
exports.generateMessageIDV2 = generateMessageIDV2; | ||
// generate a random ID to attach to a message | ||
const generateMessageID = () => 'BAE5' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase(); | ||
const generateMessageID = () => '3EB0' + (0, crypto_1.randomBytes)(18).toString('hex').toUpperCase(); | ||
exports.generateMessageID = generateMessageID; | ||
@@ -155,0 +173,0 @@ function bindWaitForEvent(ev, event) { |
@@ -329,2 +329,6 @@ "use strict"; | ||
} | ||
else if ('ptv' in message && message.ptv) { | ||
const { videoMessage } = await (0, exports.prepareWAMessageMedia)({ video: message.video }, options); | ||
m.ptvMessage = videoMessage; | ||
} | ||
else if ('product' in message) { | ||
@@ -331,0 +335,0 @@ const { imageMessage } = await (0, exports.prepareWAMessageMedia)({ image: message.product.productImage }, options); |
{ | ||
"name": "@whiskeysockets/baileys", | ||
"version": "6.7.4", | ||
"version": "6.7.5", | ||
"description": "WhatsApp API", | ||
@@ -59,3 +59,3 @@ "keywords": [ | ||
"protobufjs": "^7.2.4", | ||
"uuid": "^9.0.0", | ||
"uuid": "^10.0.0", | ||
"ws": "^8.13.0" | ||
@@ -62,0 +62,0 @@ }, |
@@ -425,3 +425,4 @@ # Baileys - Typescript/Javascript WhatsApp Web API | ||
caption: "hello!", | ||
gifPlayback: true | ||
gifPlayback: true, | ||
ptv: false // if set to true, will send as a `video note` | ||
} | ||
@@ -428,0 +429,0 @@ ) |
8219390
63178
900
+ Addeduuid@10.0.0(transitive)
- Removeduuid@9.0.1(transitive)
Updateduuid@^10.0.0