Socket
Socket
Sign inDemoInstall

@allisondsantos/baileys-md

Package Overview
Dependencies
234
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.0.1

20

lib/Socket/business.d.ts

@@ -0,8 +1,10 @@

/// <reference types="node" />
/// <reference types="ws" />
/// <reference types="node" />
import { ProductCreate, ProductUpdate, SocketConfig } from '../Types';
import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
import { BinaryNode } from '../WABinary';
export declare const makeBusinessSocket: (config: SocketConfig) => {
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
getCatalog: (jid?: string, limit?: number) => Promise<{
getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
products: import("../Types").Product[];
nextPageCursor: string | undefined;
}>;

@@ -17,6 +19,6 @@ getCollections: (jid?: string, limit?: number) => Promise<{

productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>;
sendMessageAck: ({ tag, attrs }: import("../WABinary").BinaryNode) => Promise<void>;
sendRetryRequest: (node: import("../WABinary").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
sendMessageAck: ({ tag, attrs }: BinaryNode) => Promise<void>;
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
rejectCall: (callId: string, callFrom: string) => Promise<void>;
getPrivacyTokens: (jids: string[]) => Promise<import("../WABinary").BinaryNode>;
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;

@@ -59,3 +61,3 @@ relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata }: import("../Types").MessageRelayOptions) => Promise<string>;

sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
presenceSubscribe: (toJid: string) => Promise<void>;
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;

@@ -93,7 +95,7 @@ onWhatsApp: (...jids: string[]) => Promise<{

generateMessageTag: () => string;
query: (node: import("../WABinary").BinaryNode, timeoutMs?: number | undefined) => Promise<import("../WABinary").BinaryNode>;
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
waitForMessage: (msgId: string, timeoutMs?: number | undefined) => Promise<any>;
waitForSocketOpen: () => Promise<void>;
sendRawMessage: (data: Buffer | Uint8Array) => Promise<void>;
sendNode: (frame: import("../WABinary").BinaryNode) => Promise<void>;
sendNode: (frame: BinaryNode) => Promise<void>;
logout: (msg?: string | undefined) => Promise<void>;

@@ -100,0 +102,0 @@ end: (error: Error | undefined) => void;

@@ -11,6 +11,30 @@ "use strict";

const { authState, query, waUploadToServer } = sock;
const getCatalog = async (jid, limit = 10) => {
const getCatalog = async ({ jid, limit, cursor }) => {
var _a;
jid = jid || ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
jid = (0, WABinary_1.jidNormalizedUser)(jid);
const queryParamNodes = [
{
tag: 'limit',
attrs: {},
content: Buffer.from((limit || 10).toString())
},
{
tag: 'width',
attrs: {},
content: Buffer.from('100')
},
{
tag: 'height',
attrs: {},
content: Buffer.from('100')
},
];
if (cursor) {
queryParamNodes.push({
tag: 'after',
attrs: {},
content: cursor
});
}
const result = await query({

@@ -30,19 +54,3 @@ tag: 'iq',

},
content: [
{
tag: 'limit',
attrs: {},
content: Buffer.from(limit.toString())
},
{
tag: 'width',
attrs: {},
content: Buffer.from('100')
},
{
tag: 'height',
attrs: {},
content: Buffer.from('100')
}
]
content: queryParamNodes
}

@@ -49,0 +57,0 @@ ]

@@ -0,3 +1,3 @@

/// <reference types="node" />
/// <reference types="ws" />
/// <reference types="node" />
import { proto } from '../../WAProto';

@@ -16,3 +16,3 @@ import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence } from '../Types';

sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>;
presenceSubscribe: (toJid: string) => Promise<void>;
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
profilePictureUrl: (jid: string, type?: 'preview' | 'image', timeoutMs?: number) => Promise<string | undefined>;

@@ -35,3 +35,2 @@ onWhatsApp: (...jids: string[]) => Promise<{

chatModify: (mod: ChatModification, jid: string) => Promise<void>;
/** sending abt props may fix QR scan fail if server expects */
type: "md";

@@ -38,0 +37,0 @@ ws: import("ws");

@@ -416,3 +416,7 @@ "use strict";

};
const presenceSubscribe = (toJid) => (sendNode({
/**
* @param toJid the jid to subscribe to
* @param tcToken token for subscription, use if present
*/
const presenceSubscribe = (toJid, tcToken) => (sendNode({
tag: 'presence',

@@ -423,3 +427,12 @@ attrs: {

type: 'subscribe'
}
},
content: tcToken
? [
{
tag: 'tctoken',
attrs: {},
content: tcToken
}
]
: undefined
}));

@@ -599,3 +612,3 @@ const handlePresenceUpdate = ({ tag, attrs, content }) => {

: false;
if (shouldProcessHistoryMsg && !authState.creds.myAppStateKeyId) {
if (historyMsg && !authState.creds.myAppStateKeyId) {
logger.warn('skipping app state sync, as myAppStateKeyId is not set');

@@ -606,3 +619,3 @@ pendingAppStateSync = true;

(async () => {
if (shouldProcessHistoryMsg
if (historyMsg
&& authState.creds.myAppStateKeyId) {

@@ -609,0 +622,0 @@ pendingAppStateSync = false;

@@ -0,3 +1,3 @@

/// <reference types="node" />
/// <reference types="ws" />
/// <reference types="node" />
import { proto } from '../../WAProto';

@@ -40,3 +40,3 @@ import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';

sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
presenceSubscribe: (toJid: string) => Promise<void>;
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;

@@ -43,0 +43,0 @@ onWhatsApp: (...jids: string[]) => Promise<{

@@ -0,8 +1,9 @@

/// <reference types="node" />
/// <reference types="ws" />
/// <reference types="node" />
import { UserFacingSocketConfig } from '../Types';
declare const makeWASocket: (config: UserFacingSocketConfig) => {
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
getCatalog: (jid?: string | undefined, limit?: number) => Promise<{
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
products: import("../Types").Product[];
nextPageCursor: string | undefined;
}>;

@@ -58,3 +59,3 @@ getCollections: (jid?: string | undefined, limit?: number) => Promise<{

sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
presenceSubscribe: (toJid: string) => Promise<void>;
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;

@@ -61,0 +62,0 @@ onWhatsApp: (...jids: string[]) => Promise<{

@@ -0,3 +1,3 @@

/// <reference types="node" />
/// <reference types="ws" />
/// <reference types="node" />
import { proto } from '../../WAProto';

@@ -48,3 +48,3 @@ import { MessageReceiptType, MessageRelayOptions, SocketConfig } from '../Types';

sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
presenceSubscribe: (toJid: string) => Promise<void>;
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;

@@ -51,0 +51,0 @@ onWhatsApp: (...jids: string[]) => Promise<{

@@ -216,2 +216,15 @@ "use strict";

switch (nodeType) {
case 'privacy_token':
const tokenList = (0, WABinary_1.getBinaryNodeChildren)(child, 'token');
for (const { attrs, content } of tokenList) {
const jid = attrs.jid;
ev.emit('chats.update', [
{
id: jid,
tcToken: content
}
]);
logger.debug({ jid }, 'got privacy token update');
}
break;
case 'w:gp2':

@@ -218,0 +231,0 @@ handleGroupNotification(node.attrs.participant, child, result);

@@ -0,3 +1,3 @@

/// <reference types="node" />
/// <reference types="ws" />
/// <reference types="node" />
import { proto } from '../../WAProto';

@@ -45,3 +45,3 @@ import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptions, MiscMessageGenerationOptions, SocketConfig, WAMessageKey } from '../Types';

sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
presenceSubscribe: (toJid: string) => Promise<void>;
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;

@@ -48,0 +48,0 @@ onWhatsApp: (...jids: string[]) => Promise<{

@@ -71,1 +71,9 @@ import { WAMediaUpload } from './Message';

};
export declare type CatalogCursor = string;
export declare type GetCatalogOptions = {
/** cursor to start from */
cursor?: CatalogCursor;
/** number of products to fetch */
limit?: number;
jid?: string;
};

@@ -5,2 +5,3 @@ import { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate, WAMediaUpload, WAMediaUploadFunction } from '../Types';

products: Product[];
nextPageCursor: string | undefined;
};

@@ -7,0 +8,0 @@ export declare const parseCollectionsNode: (node: BinaryNode) => {

@@ -11,3 +11,9 @@ "use strict";

const products = (0, WABinary_1.getBinaryNodeChildren)(catalogNode, 'product').map(exports.parseProductNode);
return { products };
const paging = (0, WABinary_1.getBinaryNodeChild)(catalogNode, 'paging');
return {
products,
nextPageCursor: paging
? (0, WABinary_1.getBinaryNodeChildString)(paging, 'after')
: undefined
};
};

@@ -14,0 +20,0 @@ exports.parseCatalogNode = parseCatalogNode;

@@ -454,10 +454,21 @@ "use strict";

const normalizeMessageContent = (content) => {
var _a, _b, _c, _d, _e, _f;
content = ((_c = (_b = (_a = content === null || content === void 0 ? void 0 : content.ephemeralMessage) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.viewOnceMessage) === null || _c === void 0 ? void 0 : _c.message) ||
((_d = content === null || content === void 0 ? void 0 : content.ephemeralMessage) === null || _d === void 0 ? void 0 : _d.message) ||
((_e = content === null || content === void 0 ? void 0 : content.viewOnceMessage) === null || _e === void 0 ? void 0 : _e.message) ||
((_f = content === null || content === void 0 ? void 0 : content.documentWithCaptionMessage) === null || _f === void 0 ? void 0 : _f.message) ||
content ||
undefined;
if (!content) {
return undefined;
}
// set max iterations to prevent an infinite loop
for (let i = 0; i < 5; i++) {
const inner = getFutureProofMessage(content);
if (!inner) {
break;
}
content = inner.message;
}
return content;
function getFutureProofMessage(message) {
return ((message === null || message === void 0 ? void 0 : message.ephemeralMessage)
|| (message === null || message === void 0 ? void 0 : message.viewOnceMessage)
|| (message === null || message === void 0 ? void 0 : message.documentWithCaptionMessage)
|| (message === null || message === void 0 ? void 0 : message.viewOnceMessageV2)
|| (message === null || message === void 0 ? void 0 : message.editedMessage));
}
};

@@ -464,0 +475,0 @@ exports.normalizeMessageContent = normalizeMessageContent;

{
"name": "@allisondsantos/baileys-md",
"version": "2.0.0",
"version": "2.0.1",
"description": "WhatsApp API Multi Device",

@@ -94,2 +94,2 @@ "homepage": "https://github.com/allisondsantos/Baileys",

}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc