New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

whatsapp-business

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whatsapp-business - npm Package Compare versions

Comparing version 1.5.2 to 1.6.0

40

dist/package.json
{
"name": "whatsapp-business",
"author": "MarcosNicolau",
"version": "1.5.2",
"version": "1.6.0",
"description": "Node.js connector for the WhatsApp Business APIs with TypeScript support, integration tests and more.",

@@ -38,3 +38,3 @@ "license": "MIT",

"dependencies": {
"axios": "^0.27.2",
"axios": "^1.4.0",
"express": "^4.18.2",

@@ -44,25 +44,25 @@ "form-data": "^4.0.0"

"devDependencies": {
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@semantic-release/changelog": "^6.0.1",
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^9.0.1",
"@types/express": "^4.17.14",
"@types/express-serve-static-core": "^4.17.31",
"@semantic-release/npm": "^10.0.4",
"@types/express": "^4.17.17",
"@types/express-serve-static-core": "^4.17.35",
"@types/jest": "^27.5.1",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"commitizen": "^4.2.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "3.3.0",
"devmoji": "^2.3.0",
"dotenv": "^16.0.1",
"eslint": "^8.16.0",
"eslint-plugin-import": "^2.26.0",
"husky": "^8.0.1",
"dotenv": "^16.3.1",
"eslint": "^8.45.0",
"eslint-plugin-import": "^2.27.5",
"husky": "^8.0.3",
"jest": "^28.1.0",
"lint-staged": "^12.4.1",
"prettier": "^2.6.2",
"semantic-release": "^19.0.2",
"ts-jest": "^28.0.2",
"typescript": "^4.6.4"
"lint-staged": "^13.2.3",
"prettier": "^3.0.0",
"semantic-release": "^21.0.7",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},

@@ -69,0 +69,0 @@ "config": {

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

export declare type BusinessVertical = "UNDEFINED" | "OTHER" | "AUTO" | "BEAUTY" | "APPAREL" | "EDU" | "ENTERTAIN" | "EVENT_PLAN" | "FINANCE" | "GROCERY" | "GOVT" | "HOTEL" | "HEALTH" | "NONPROFIT" | "PROF_SERVICES" | "RETAIL" | "TRAVEL" | "RESTAURANT" | "NOT_A_BIZ";
export declare type BusinessProfileFields = {
export type BusinessVertical = "UNDEFINED" | "OTHER" | "AUTO" | "BEAUTY" | "APPAREL" | "EDU" | "ENTERTAIN" | "EVENT_PLAN" | "FINANCE" | "GROCERY" | "GOVT" | "HOTEL" | "HEALTH" | "NONPROFIT" | "PROF_SERVICES" | "RETAIL" | "TRAVEL" | "RESTAURANT" | "NOT_A_BIZ";
export type BusinessProfileFields = {
messaging_product: string;

@@ -12,6 +12,6 @@ address: string;

};
export declare type BusinessProfile = {
export type BusinessProfile = {
data: BusinessProfileFields[];
};
export declare type BusinessProfileFieldsQuery = (keyof BusinessProfileFields)[];
export declare type UpdateBusinessProfilePayload = Partial<Omit<BusinessProfileFields, "messaging_product" | "id">>;
export type BusinessProfileFieldsQuery = (keyof BusinessProfileFields)[];
export type UpdateBusinessProfilePayload = Partial<Omit<BusinessProfileFields, "messaging_product" | "id">>;

@@ -53,4 +53,4 @@ /**

};
export declare type WABAErrorCodes = keyof typeof ERROR_CODES;
export declare type WABAErrorMessages = typeof ERROR_CODES[keyof typeof ERROR_CODES];
export type WABAErrorCodes = keyof typeof ERROR_CODES;
export type WABAErrorMessages = typeof ERROR_CODES[keyof typeof ERROR_CODES];
/**

@@ -60,3 +60,3 @@ * For more detailed descriptions about the API errors go here:

*/
export declare type WABAErrorAPI = {
export type WABAErrorAPI = {
message: WABAErrorMessages;

@@ -75,4 +75,4 @@ type: string;

};
export declare type DefaultWABAErrorAPI = {
export type DefaultWABAErrorAPI = {
error: WABAErrorAPI;
};

@@ -102,2 +102,2 @@ export declare const SUPPORTED_LANGUAGES_CODE: {

};
export declare type SupportedLanguagesCodeUnion = typeof SUPPORTED_LANGUAGES_CODE[keyof typeof SUPPORTED_LANGUAGES_CODE];
export type SupportedLanguagesCodeUnion = typeof SUPPORTED_LANGUAGES_CODE[keyof typeof SUPPORTED_LANGUAGES_CODE];

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

export declare type MediaAcceptedFileTypes = "image/jpeg" | "image/png" | "text/plain" | "application/pdf" | "application/vnd.ms-powerpoint" | "application/msword" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "audio/aac" | "audio/mp4" | "audio/mpeg" | "audio/amr" | "audio/ogg" | "audio/opus" | "video/mp4" | "video/3gp" | "image/webp";
export declare type UploadMediaPayload = {
export type MediaAcceptedFileTypes = "image/jpeg" | "image/png" | "text/plain" | "application/pdf" | "application/vnd.ms-powerpoint" | "application/msword" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "audio/aac" | "audio/mp4" | "audio/mpeg" | "audio/amr" | "audio/ogg" | "audio/opus" | "video/mp4" | "video/3gp" | "image/webp";
export type UploadMediaPayload = {
/**

@@ -10,6 +10,6 @@ * Path to the file stored in your local directory. For example: "@/local/path/file.jpg".

};
export declare type UploadMediaResponse = {
export type UploadMediaResponse = {
id: string;
};
export declare type GetMediaResponse = {
export type GetMediaResponse = {
messaging_product: "whatsapp";

@@ -16,0 +16,0 @@ url: string;

import { SupportedLanguagesCodeUnion } from "./languageCodes";
import { GenerateMappedNever, LiteralUnion } from "./utils";
export declare type SendMessageResponse = {
export type SendMessageResponse = {
messaging_product: "whatsapp";

@@ -20,3 +20,3 @@ contacts: [

};
export declare type MarkMessageAsReadPayload = {
export type MarkMessageAsReadPayload = {
messaging_product: "whatsapp";

@@ -26,4 +26,4 @@ status: "read";

};
export declare type MessageType = "audio" | "contacts" | "document" | "image" | "interactive" | "location" | "sticker" | "template" | "text" | "video" | "reaction";
export declare type MessageContext = {
export type MessageType = "audio" | "contacts" | "document" | "image" | "interactive" | "location" | "sticker" | "template" | "text" | "video" | "reaction";
export type MessageContext = {
/**

@@ -34,3 +34,3 @@ * The message id you receive on the webhooks

};
export declare type Message = {
export type Message = {
/**

@@ -96,3 +96,3 @@ * Defaults to text

};
export declare type MediaObject = {
export type MediaObject = {
/**

@@ -127,3 +127,3 @@ * Required when type is audio, document, or image and you are not using a link.

};
export declare type ContactMessageAddress = {
export type ContactMessageAddress = {
street?: string;

@@ -137,7 +137,7 @@ city?: string;

};
export declare type ContactMessageEmail = {
export type ContactMessageEmail = {
email?: string;
type?: LiteralUnion<"HOME" | "WORK">;
};
export declare type ContactMessageName = {
export type ContactMessageName = {
formatted_name: string;

@@ -150,3 +150,3 @@ first_name?: string;

};
export declare type ContactMessageOrg = {
export type ContactMessageOrg = {
company?: string;

@@ -156,3 +156,3 @@ department?: string;

};
export declare type ContactMessagePhone = {
export type ContactMessagePhone = {
/**

@@ -165,7 +165,7 @@ * Automatically populated with the wa_id value as a formatted phone number.

};
export declare type ContactMessageUrl = {
export type ContactMessageUrl = {
url?: string;
type?: LiteralUnion<"HOME" | "WORK">;
};
export declare type InteractiveActionSection = {
export type InteractiveActionSection = {
/**

@@ -207,4 +207,16 @@ * Required for Multi-Product Messages.

};
export declare type InteractiveMessageAction = {
export type InteractiveMessageAction = {
/**
* Required for catalog_messages
*/
name?: string;
/**
* Item SKU number. Labeled as Content ID in the Commerce Manager.
* The thumbnail of this item will be used as the message's header image.
* If the parameters object is omitted, the product image of the first item in your catalog will be used.
*/
parameters?: {
thumbnail_product_retailer_id?: string;
};
/**
* Required for List Messages.

@@ -255,3 +267,3 @@ * Button content. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not.

};
export declare type InteractiveMessageBody = {
export type InteractiveMessageBody = {
/**

@@ -262,3 +274,3 @@ * Required if body is present. The content of the message. Emojis and markdown are supported. Maximum length: 1024 characters.

};
export declare type InteractiveMessageFooter = {
export type InteractiveMessageFooter = {
/**

@@ -269,3 +281,3 @@ * Required if footer is present. The footer content. Emojis, markdown, and links are supported. Maximum length: 60 characters.

};
export declare type InteractiveMessageHeader = {
export type InteractiveMessageHeader = {
/**

@@ -280,3 +292,3 @@ * The header type you would like to use. Supported values:

*/
type: "text" | "video" | "message" | "document";
type: "text" | "video" | "image" | "document";
/**

@@ -304,3 +316,3 @@ * Required if type is set to text.

};
export declare type InteractiveMessage = {
export type InteractiveMessage = {
/**

@@ -324,5 +336,5 @@ * Action you want the user to perform after reading the message.

header?: InteractiveMessageHeader;
type: "list" | "button" | "product" | "product_list";
type: "list" | "button" | "product" | "product_list" | "catalog_message";
};
export declare type ContactMessage = {
export type ContactMessage = {
addresses?: ContactMessageAddress[];

@@ -339,3 +351,3 @@ /**

};
export declare type LocationMessage = {
export type LocationMessage = {
longitude: string;

@@ -349,3 +361,3 @@ latitude: string;

};
export declare type TemplateMessageParameter = {
export type TemplateMessageParameter = {
type: "text" | "currency" | "date_time" | "image" | "document" | "video";

@@ -377,4 +389,4 @@ /**

};
export declare type TemplateMessageButtonParameter = GenerateMappedNever<TemplateMessageParameter> & {
type: "payload" | "text";
export type TemplateMessageButtonParameter = GenerateMappedNever<TemplateMessageParameter> & {
type: "payload" | "text" | "catalog";
/**

@@ -390,3 +402,3 @@ * required for quick_reply buttons

};
export declare type TemplateMessageComponent = {
export type TemplateMessageComponent = {
type: "header" | "body" | "button";

@@ -406,3 +418,3 @@ /**

};
export declare type TemplateMessageLanguage = {
export type TemplateMessageLanguage = {
/**

@@ -417,8 +429,9 @@ * The language policy the message should follow. See Language Policy Options for more information.

};
export declare type TemplateMessage = {
export type TemplateMessage = {
name: string;
language: TemplateMessageLanguage;
category: LiteralUnion<"AUTHENTICATION" | "MARKETING " | "UTILITY">;
components: TemplateMessageComponent[];
};
export declare type TextMessage = {
export type TextMessage = {
/**

@@ -445,3 +458,3 @@ *

};
export declare type ReactionMessage = {
export type ReactionMessage = {
/**

@@ -448,0 +461,0 @@ * The WhatsApp Message ID (wamid) of the message on which the reaction should appear. The reaction will not be sent if:

@@ -1,2 +0,2 @@

export declare type BusinessPhoneNumber = {
export type BusinessPhoneNumber = {
verified_name: string;

@@ -8,3 +8,3 @@ display_phone_number: string;

};
export declare type GetBusinessPhoneNumberResponse = {
export type GetBusinessPhoneNumberResponse = {
data: BusinessPhoneNumber[];

@@ -18,3 +18,3 @@ paging: {

};
export declare type RequestPhoneNumberVerificationCodePayload = {
export type RequestPhoneNumberVerificationCodePayload = {
code_method: "SMS" | "VOICE";

@@ -26,8 +26,8 @@ /**

};
export declare type RequestPhoneNumberVerificationCodeArgs = RequestPhoneNumberVerificationCodePayload & {
export type RequestPhoneNumberVerificationCodeArgs = RequestPhoneNumberVerificationCodePayload & {
phoneNumberId: string;
};
export declare type VerifyPhoneNumberArgs = {
export type VerifyPhoneNumberArgs = {
phoneNumberId: string;
code: string;
};

@@ -1,2 +0,2 @@

export declare type RegisterPhonePayload = {
export type RegisterPhonePayload = {
messaging_product: "whatsapp";

@@ -8,10 +8,10 @@ /**

};
export declare type RegisterPhoneArgs = Omit<RegisterPhonePayload, "messaging_product"> & {
export type RegisterPhoneArgs = Omit<RegisterPhonePayload, "messaging_product"> & {
phoneNumberId: string;
};
export declare type SetUpTwoFactorAuthPayload = {
export type SetUpTwoFactorAuthPayload = {
pin: string;
};
export declare type SetUpTwoFactorAuthArgs = SetUpTwoFactorAuthPayload & {
export type SetUpTwoFactorAuthArgs = SetUpTwoFactorAuthPayload & {
phoneNumberId: string;
};

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

export declare type DefaultResponse = {
export type DefaultResponse = {
success: boolean;
};

@@ -10,3 +10,3 @@ /**

*/
export declare type LiteralUnion<T extends string> = T | (string & {});
export type LiteralUnion<T extends string> = T | (string & {});
/**

@@ -21,3 +21,3 @@ * Adds number autocompletion as if it was a union, but allows other number values

*/
export declare type LiteralNumberUnion<T extends number> = T | (number & {});
export type LiteralNumberUnion<T extends number> = T | (number & {});
/**

@@ -42,4 +42,4 @@ * Takes a type and maps all its values to never

*/
export declare type GenerateMappedNever<T> = {
export type GenerateMappedNever<T> = {
[key in keyof T]: never;
};
import { WABAErrorCodes } from "./error";
import { MessageType, ReactionMessage } from "./messages";
import { LiteralUnion } from "./utils";
import { MessageType, ReactionMessage } from "./messages";
/**
* The information for the customer who sent a message to the business
*/
export declare type WebhookContact = {
export type WebhookContact = {
/**

@@ -16,7 +16,7 @@ * The customer's WhatsApp ID. A business can respond to a message using this ID.

};
export declare type WebhookError = {
export type WebhookError = {
code: WABAErrorCodes;
title: string;
};
export declare type WebhookMedia = {
export type WebhookMedia = {
/**

@@ -40,3 +40,3 @@ * Caption for the file, if provided

*/
export declare type WebhookMessage = {
export type WebhookMessage = {
/**

@@ -250,3 +250,3 @@ * The type of message that has been received by the business that has subscribed to Webhooks.

*/
export declare type WebhookStatus = {
export type WebhookStatus = {
/**

@@ -324,9 +324,10 @@ * The ID for the message that the business that is subscribed to the webhooks sent to a customer

};
export declare type WebhookChange = {
export type WebhookMetadata = {
display_phone_number: string;
phone_number_id: string;
};
export type WebhookChange = {
value: {
messaging_product: "whatsapp";
metadata: {
display_phone_number: string;
phone_number_id: string;
};
metadata: WebhookMetadata;
errors: WebhookError[];

@@ -344,3 +345,3 @@ contacts: WebhookContact[];

*/
export declare type Webhook = {
export type Webhook = {
object: string;

@@ -354,3 +355,3 @@ entry: [

};
export declare type WebhookEvents = {
export type WebhookEvents = {
/**

@@ -363,7 +364,7 @@ * Gets fired when the server starts listening

*/
onMessageReceived?: (payload: WebhookMessage, contact: WebhookContact) => void;
onMessageReceived?: (payload: WebhookMessage, contact: WebhookContact, metadata?: WebhookMetadata) => void;
/**
* Gets fired when the received message is type of text
*/
onTextMessageReceived?: (textMessage: Pick<WebhookMessage, "type" | "timestamp" | "text" | "from" | "id">, contact: WebhookContact) => void;
onTextMessageReceived?: (textMessage: Pick<WebhookMessage, "type" | "timestamp" | "text" | "from" | "id">, contact: WebhookContact, metadata?: WebhookMetadata) => void;
/**

@@ -373,3 +374,3 @@ * Gets triggered when a message is sent or delivered to a customer

*/
onStatusReceived?: (payload: WebhookStatus) => void;
onStatusReceived?: (payload: WebhookStatus, metadata?: WebhookMetadata) => void;
/**

@@ -376,0 +377,0 @@ * Gets fired whenever there is an err

@@ -9,7 +9,7 @@ import { AxiosRequestConfig } from "axios";

fetch: import("axios").AxiosInstance;
get: <Response_1 = any, Params = Record<string, string>>(endpoint: string, params?: Params | undefined, config?: AxiosRequestConfig<any> | undefined) => Promise<Response_1>;
post: <Response_2 = any, Payload = Record<string, any>>(endpoint: string, payload?: Payload | undefined, config?: AxiosRequestConfig<any> | undefined) => Promise<Response_2>;
put: <Response_3 = any, Payload_1 = Record<string, any>>(endpoint: string, payload?: Payload_1 | undefined, config?: AxiosRequestConfig<any> | undefined) => Promise<Response_3>;
delete: <Response_4 = any, Params_1 = Record<string, any>>(endpoint: string, params?: Params_1 | undefined, config?: AxiosRequestConfig<any> | undefined) => Promise<Response_4>;
get: <Response_1 = any, Params = Record<string, string>>(endpoint: string, params?: Params | undefined, config?: AxiosRequestConfig) => Promise<Response_1>;
post: <Response_2 = any, Payload = Record<string, any>>(endpoint: string, payload?: Payload | undefined, config?: AxiosRequestConfig) => Promise<Response_2>;
put: <Response_3 = any, Payload_1 = Record<string, any>>(endpoint: string, payload?: Payload_1 | undefined, config?: AxiosRequestConfig) => Promise<Response_3>;
delete: <Response_4 = any, Params_1 = Record<string, any>>(endpoint: string, params?: Params_1 | undefined, config?: AxiosRequestConfig) => Promise<Response_4>;
};
export {};

@@ -28,3 +28,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -31,0 +31,0 @@ if (y = 0, t) op = [op[0] & 2, t.value];

@@ -35,2 +35,7 @@ import { Message, SendMessageResponse, GetBusinessPhoneNumberResponse, RequestPhoneNumberVerificationCodeArgs, VerifyPhoneNumberArgs, RegisterPhoneArgs, SetUpTwoFactorAuthArgs, DefaultResponse, BusinessProfile, BusinessProfileFieldsQuery, UpdateBusinessProfilePayload, GetMediaResponse, UploadMediaPayload, UploadMediaResponse, BusinessPhoneNumber } from "./types";

getSingleBusinessPhoneNumber(phoneNumberId: string): Promise<BusinessPhoneNumber>;
/**
* You may want us to verify a customer's identity before we deliver your message to them.
* You can have us do this by enabling the identity change check setting on your business phone number.
*/
updateIdentityCheckState(enable: boolean): Promise<DefaultResponse>;
requestPhoneNumberVerificationCode({ phoneNumberId, ...payload }: RequestPhoneNumberVerificationCodeArgs): Promise<DefaultResponse>;

@@ -37,0 +42,0 @@ verifyPhoneNumberCode({ phoneNumberId, ...payload }: VerifyPhoneNumberArgs): Promise<DefaultResponse>;

@@ -28,3 +28,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -77,3 +77,3 @@ if (y = 0, t) op = [op[0] & 2, t.value];

apiToken: apiToken,
baseURL: "https://graph.facebook.com/v16.0",
baseURL: "https://graph.facebook.com/v17.0",
errorHandler: function (error) { var _a; return (0, errorHandler_1.WABAErrorHandler)(((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) || error); },

@@ -190,2 +190,17 @@ });

};
/**
* You may want us to verify a customer's identity before we deliver your message to them.
* You can have us do this by enabling the identity change check setting on your business phone number.
*/
WABAClient.prototype.updateIdentityCheckState = function (enable) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.restClient.post("".concat(this.phoneId, "/settings"), {
user_identity_change: {
enable_identity_check: enable,
},
})];
});
});
};
WABAClient.prototype.requestPhoneNumberVerificationCode = function (_a) {

@@ -192,0 +207,0 @@ var phoneNumberId = _a.phoneNumberId, payload = __rest(_a, ["phoneNumberId"]);

@@ -14,7 +14,7 @@ "use strict";

(_b = (_a = change === null || change === void 0 ? void 0 : change.value) === null || _a === void 0 ? void 0 : _a.messages) === null || _b === void 0 ? void 0 : _b.forEach(function (message) {
var _a;
var _a, _b, _c;
//The contact is always the 0 and it is only received when there the messages field is present
var contact = (_a = change === null || change === void 0 ? void 0 : change.value) === null || _a === void 0 ? void 0 : _a.contacts[0];
//Call message event
onMessageReceived && onMessageReceived(message, contact);
onMessageReceived && onMessageReceived(message, contact, (_b = change === null || change === void 0 ? void 0 : change.value) === null || _b === void 0 ? void 0 : _b.metadata);
//If the message is type of text, then call the respective event

@@ -29,7 +29,8 @@ if (message.type === "text" && message.text)

timestamp: message.timestamp,
}, contact);
}, contact, (_c = change === null || change === void 0 ? void 0 : change.value) === null || _c === void 0 ? void 0 : _c.metadata);
});
//Call status event
(_d = (_c = change === null || change === void 0 ? void 0 : change.value) === null || _c === void 0 ? void 0 : _c.statuses) === null || _d === void 0 ? void 0 : _d.forEach(function (status) {
onStatusReceived && onStatusReceived(status);
var _a;
onStatusReceived && onStatusReceived(status, (_a = change === null || change === void 0 ? void 0 : change.value) === null || _a === void 0 ? void 0 : _a.metadata);
});

@@ -36,0 +37,0 @@ //Call error event

{
"name": "whatsapp-business",
"author": "MarcosNicolau",
"version": "1.5.2",
"version": "1.6.0",
"description": "Node.js connector for the WhatsApp Business APIs with TypeScript support, integration tests and more.",

@@ -38,3 +38,3 @@ "license": "MIT",

"dependencies": {
"axios": "^0.27.2",
"axios": "^1.4.0",
"express": "^4.18.2",

@@ -44,25 +44,25 @@ "form-data": "^4.0.0"

"devDependencies": {
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@semantic-release/changelog": "^6.0.1",
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^9.0.1",
"@types/express": "^4.17.14",
"@types/express-serve-static-core": "^4.17.31",
"@semantic-release/npm": "^10.0.4",
"@types/express": "^4.17.17",
"@types/express-serve-static-core": "^4.17.35",
"@types/jest": "^27.5.1",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"commitizen": "^4.2.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "3.3.0",
"devmoji": "^2.3.0",
"dotenv": "^16.0.1",
"eslint": "^8.16.0",
"eslint-plugin-import": "^2.26.0",
"husky": "^8.0.1",
"dotenv": "^16.3.1",
"eslint": "^8.45.0",
"eslint-plugin-import": "^2.27.5",
"husky": "^8.0.3",
"jest": "^28.1.0",
"lint-staged": "^12.4.1",
"prettier": "^2.6.2",
"semantic-release": "^19.0.2",
"ts-jest": "^28.0.2",
"typescript": "^4.6.4"
"lint-staged": "^13.2.3",
"prettier": "^3.0.0",
"semantic-release": "^21.0.7",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},

@@ -69,0 +69,0 @@ "config": {

@@ -37,5 +37,5 @@ ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/MarcosNicolau/whatsapp-business-sdk/npm_publish.yml?branch=main)

const client = new WABAClient({
accountId: "YOUR_ACCOUNT_ID",
apiToken: "YOUR_API_TOKEN",
phoneId: "YOUR_BUSINESS_PHONE_ID",
accountId: "<YOUR_ACCOUNT_ID>",
apiToken: "<YOUR_API_TOKEN>",
phoneId: "<YOUR_BUSINESS_PHONE_ID>",
});

@@ -95,3 +95,3 @@

For more info, checks the docs [here](https://developers.facebook.com/docs/whatsapp/business-management-api/guides/set-up-webhooks)
For more info, checks the docs [here](https://developers.facebook.com/docs/whatsapp/business-management-api/guides/set-up-webhooks).

@@ -103,12 +103,14 @@ ```typescript

const webhookClient = new WebhookClient({
token: "YOUR_VALIDATION_TOKEN",
path: "/whatsapp/business",
token: "<YOUR_VALIDATION_TOKEN>",
path: "/whatsapp/webhook",
port: 8080,
});
const wabaClient = new WABAClient({
accountId: "ACCOUNT_ID",
phoneId: "PHONE_ID",
apiToken: "API_TOKEN",
accountId: "<ACCOUNT_ID>",
phoneId: "<PHONE_ID>",
apiToken: "<API_TOKEN>",
});
//init webhooks takes an object of functions that will be triggered based on the received webhook event type
//Starts a server and triggers the received functions based on the webhook event type
webhookClient.initWebhook({

@@ -147,2 +149,48 @@ onStartListening: () => {

You can also provide your own express app:
```typescript
import { WebhookClient } from "./index";
import express from "express";
const myApp = express();
const webhookClient = new WebhookClient({
token: "<YOUR_VALIDATION_TOKEN>",
path: "/whatsapp/webhook",
expressApp: {
//Set to false if you want to initialize the server yourself
//Otherwise, it will start listening when firing initWebhook()
shouldStartListening: false,
app: myApp,
},
});
myApp.listen(8080, () => {
console.log("My server nows listens to whatsapp webhooks");
});
```
If you don't provide a express app the client will create a default app on its own, which you can later access:
```typescript
import { WebhookClient } from "./index";
const webhookClient = new WebhookClient({
token: "<YOUR_VALIDATION_TOKEN>",
path: "/whatsapp/webhook",
port: 8080,
});
const app = webhookClient.expressApp.app;
//Your configuration...
app.set("trust proxy", true);
webhookClient.initWebhook({
onStartListening: () => {
console.log("Server started listening");
},
});
```
## Support

@@ -186,10 +234,2 @@

### Donations
If you found this project interesting or useful, you can give this project a star. Thank you!
Or buy me a coffee using any of these:
- BTC: `1MjRd2YNNjEx3ze1Y71UNSgbAF9XECKTP1`
- ETH: `0xde25d72e9e87513b9c8dad8de11e2d8332276c7e`
- USDC:`0xde25d72e9e87513b9c8dad8de11e2d8332276c7e`
If you found this project interesting or useful, you would help so much by giving this project a star. Thank you!

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc