Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@great-detail/whatsapp

Package Overview
Dependencies
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@great-detail/whatsapp - npm Package Compare versions

Comparing version 6.5.2 to 6.6.0

dist/CloudAPI/CloudAPIInvalidParameterError.d.ts

8

dist/API/AbstractAPI.d.ts

@@ -13,3 +13,3 @@ /// <reference types="node" resolution-mode="require"/>

import type { Logger } from "winston";
export interface WhatsAppAPICreateVerifyTokenParams {
export interface WhatsAppAPICreateVerifyTokenParameters {
/**

@@ -37,3 +37,3 @@ * The length of the verify token.

}
export interface AbstractAPIParams {
export interface AbstractAPIParameters {
businessID?: AccountID;

@@ -70,3 +70,3 @@ logger?: Logger;

protected _logger?: Logger;
constructor({ logger, businessID }: AbstractAPIParams);
constructor({ logger, businessID }: AbstractAPIParameters);
/**

@@ -80,3 +80,3 @@ * Create a new Verify Token.

*/
static createVerifyToken({ length, encoding, random, }?: WhatsAppAPICreateVerifyTokenParams): string;
static createVerifyToken({ length, encoding, random, }?: WhatsAppAPICreateVerifyTokenParameters): string;
}

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

import{randomBytes as t}from"crypto";export default class E{static{this.DEFAULT_VERIFY_TOKEN_LENGTH=16}static{this.DEFAULT_VERIFY_TOKEN_ENCODING="hex"}constructor({logger:t,businessID:E}){this._logger=t,this._businessID=E}static createVerifyToken({length:E=this.DEFAULT_VERIFY_TOKEN_LENGTH,encoding:s=this.DEFAULT_VERIFY_TOKEN_ENCODING,random:_=t}={}){return _(E).toString(s)}}
import{randomBytes as t}from"node:crypto";export default class E{static{this.DEFAULT_VERIFY_TOKEN_LENGTH=16}static{this.DEFAULT_VERIFY_TOKEN_ENCODING="hex"}constructor({logger:t,businessID:E}){this._logger=t,this._businessID=E}static createVerifyToken({length:E=this.DEFAULT_VERIFY_TOKEN_LENGTH,encoding:s=this.DEFAULT_VERIFY_TOKEN_ENCODING,random:_=t}={}){return _(E).toString(s)}}
//# sourceMappingURL=AbstractAPI.js.map

@@ -9,5 +9,5 @@ /**

*/
import AbstractAPI, { AbstractAPIParams } from "../../API/AbstractAPI.js";
import AbstractAPI, { AbstractAPIParameters } from "../../API/AbstractAPI.js";
import EndpointType from "../../API/EndpointType.js";
import GraphRequest, { GraphRequestCreateParams } from "../../GraphRequest/index.js";
import GraphRequest, { GraphRequestCreateParameters } from "../../GraphRequest/index.js";
import CloudOutgoingMessageContact from "../../Message/Contact/MessageContact/CloudOutgoingMessageContact.js";

@@ -19,3 +19,3 @@ import CloudOutgoingMessageInteractive from "../../Message/Interactive/MessageInteractive/Outgoing/CloudOutgoingMessageInteractive.js";

import { CloudOutgoingMessageResponse } from "../../Message/OutgoingMessage/CloudOutgoingMessage.js";
import CloudOutgoingMessageStatus from "../../Message/Status/MessageStatus/Outgoing/CloudOutgoingMessageStatus.js";
import CloudOutgoingMessageStatus, { CloudOutgoingMessageStatusResponse } from "../../Message/Status/MessageStatus/Outgoing/CloudOutgoingMessageStatus.js";
import CloudOutgoingMessageTemplate from "../../Message/Template/MessageTemplate/Outgoing/CloudOutgoingMessageTemplate.js";

@@ -27,5 +27,5 @@ import CloudOutgoingMessageText from "../../Message/Text/MessageText/Outgoing/CloudOutgoingMessageText.js";

replyMessageId?: string;
requestProps?: GraphRequestCreateParams;
requestOptions?: GraphRequestCreateParameters;
};
export interface CloudAPIMessageParams extends AbstractAPIParams {
export interface CloudAPIMessageParameters extends AbstractAPIParameters {
businessID: string;

@@ -40,3 +40,3 @@ }

export default class CloudAPIMessage extends AbstractAPI {
constructor(params: CloudAPIMessageParams);
constructor(parameters: CloudAPIMessageParameters);
protected getEndpoint(): EndpointType;

@@ -49,3 +49,3 @@ /**

*/
createStatus(payload: CloudOutgoingMessageStatus, requestProps?: GraphRequestCreateParams): GraphRequest<CloudOutgoingMessageResponse>;
createStatus(payload: CloudOutgoingMessageStatus, requestOptions?: GraphRequestCreateParameters): GraphRequest<CloudOutgoingMessageStatusResponse>;
/**

@@ -57,3 +57,3 @@ * Create Message.

*/
createMessage<T extends OutgoingMessageType>(type: T, payload: CreateMessagePayload, { toNumber, replyMessageId, requestProps }: CreateMessageOptionsType): GraphRequest<CloudOutgoingMessageResponse>;
createMessage<T extends OutgoingMessageType>(type: T, payload: CreateMessagePayload, { toNumber, replyMessageId, requestOptions }: CreateMessageOptionsType): GraphRequest<CloudOutgoingMessageResponse>;
protected _shorthandAlias<T extends OutgoingMessageType, P extends CreateMessagePayload>(type: T): (payload: P, options: CreateMessageOptionsType) => GraphRequest<CloudOutgoingMessageResponse>;

@@ -60,0 +60,0 @@ audio: (payload: CreateMessagePayload, options: CreateMessageOptionsType) => GraphRequest<CloudOutgoingMessageResponse>;

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

import t from"../../API/AbstractAPI.js";import s from"../../GraphRequest/index.js";import e from"../../Message/MessageType/OutgoingMessageType.js";export default class i extends t{constructor(t){super(t),this.audio=this._shorthandAlias(e.Audio),this.contacts=this._shorthandAlias(e.Contacts),this.document=this._shorthandAlias(e.Document),this.image=this._shorthandAlias(e.Image),this.interactive=this._shorthandAlias(e.Interactive),this.location=this._shorthandAlias(e.Location),this.sticker=this._shorthandAlias(e.Sticker),this.template=this._shorthandAlias(e.Template),this.text=this._shorthandAlias(e.Text),this.video=this._shorthandAlias(e.Video)}getEndpoint(){return`/${this._businessID}/messages`}createStatus(t,e={}){let i={messaging_product:"whatsapp",...t};return new s(this.getEndpoint(),{logger:this._logger,...e,method:"POST",body:JSON.stringify(i),headers:{...e.headers,"Content-Type":"application/json"}})}createMessage(t,e,{toNumber:i,replyMessageId:a,requestProps:h={}}){let n={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:t,[t]:e};return a&&(n.context={message_id:a}),new s(this.getEndpoint(),{logger:this._logger,...h,method:"POST",body:JSON.stringify(n),headers:{...h.headers,"Content-Type":"application/json"}})}_shorthandAlias(t){return(function(s,e){return this.createMessage(t,s,e)}).bind(this)}}
import t from"../../API/AbstractAPI.js";import s from"../../GraphRequest/index.js";import e from"../../Message/MessageType/OutgoingMessageType.js";export default class i extends t{constructor(t){super(t),this.audio=this._shorthandAlias(e.Audio),this.contacts=this._shorthandAlias(e.Contacts),this.document=this._shorthandAlias(e.Document),this.image=this._shorthandAlias(e.Image),this.interactive=this._shorthandAlias(e.Interactive),this.location=this._shorthandAlias(e.Location),this.sticker=this._shorthandAlias(e.Sticker),this.template=this._shorthandAlias(e.Template),this.text=this._shorthandAlias(e.Text),this.video=this._shorthandAlias(e.Video)}getEndpoint(){return`/${this._businessID}/messages`}createStatus(t,e={}){let i={messaging_product:"whatsapp",...t};return new s(this.getEndpoint(),{logger:this._logger,...e,method:"POST",body:JSON.stringify(i),headers:{...e.headers,"Content-Type":"application/json"}})}createMessage(t,e,{toNumber:i,replyMessageId:a,requestOptions:h={}}){let n={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:t,[t]:e};return a&&(n.context={message_id:a}),new s(this.getEndpoint(),{logger:this._logger,...h,method:"POST",body:JSON.stringify(n),headers:{...h.headers,"Content-Type":"application/json"}})}_shorthandAlias(t){return(function(s,e){return this.createMessage(t,s,e)}).bind(this)}}
//# sourceMappingURL=index.js.map

@@ -130,3 +130,3 @@ /// <reference types="node" resolution-mode="require"/>

*/
register(req: IncomingMessage, res: ServerResponse): Promise<WebhookAPIRegisterReturn>;
register(request: IncomingMessage, response: ServerResponse): Promise<WebhookAPIRegisterReturn>;
/**

@@ -153,3 +153,3 @@ * Handle an Event Notification Webhook Request.

*/
eventNotification(req: IncomingMessage, res: ServerResponse): Promise<WebhookAPIEventNotificationReturn>;
eventNotification(request: IncomingMessage, response: ServerResponse): Promise<WebhookAPIEventNotificationReturn>;
}

@@ -9,8 +9,8 @@ /**

*/
import AbstractAPI, { AbstractAPIParams } from "../API/AbstractAPI.js";
import CloudAPIMessage, { CloudAPIMessageParams as BaseCloudAPIMessageParams } from "./CloudAPIMessage/index.js";
import AbstractAPI, { AbstractAPIParameters } from "../API/AbstractAPI.js";
import CloudAPIMessage, { CloudAPIMessageParameters as BaseCloudAPIMessageParameters } from "./CloudAPIMessage/index.js";
import CloudAPIWebhook from "./CloudAPIWebhook/index.js";
export interface WhatsAppAPIParams extends AbstractAPIParams {
export interface WhatsAppAPIParameters extends AbstractAPIParameters {
}
export interface CloudAPIMessageParams extends Partial<BaseCloudAPIMessageParams> {
export interface CloudAPIMessageParameters extends Partial<BaseCloudAPIMessageParameters> {
}

@@ -34,3 +34,3 @@ /**

webhook: CloudAPIWebhook;
constructor(params: WhatsAppAPIParams);
constructor(parameters: WhatsAppAPIParameters);
/**

@@ -47,3 +47,3 @@ * Message API.

*/
message({ businessID: overrideBusinessID, logger, ...params }?: CloudAPIMessageParams): CloudAPIMessage;
message({ businessID: overrideBusinessID, logger, ...parameters }?: CloudAPIMessageParameters): CloudAPIMessage;
}

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

import s from"../API/AbstractAPI.js";import e from"./CloudAPIInvalidParamError.js";import r from"./CloudAPIMessage/index.js";import o from"./CloudAPIWebhook/index.js";export default class t extends s{constructor(s){super(s),this.webhook=new o(s)}message({businessID:s,logger:o,...t}={}){let i=s??this._businessID;if(!i)throw new e("Business ID is required");return new r({logger:o??this._logger,businessID:i,...t})}}
import e from"../API/AbstractAPI.js";import s from"./CloudAPIInvalidParameterError.js";import r from"./CloudAPIMessage/index.js";import o from"./CloudAPIWebhook/index.js";export default class t extends e{constructor(e){super(e),this.webhook=new o(e)}message({businessID:e,logger:o,...t}={}){let i=e??this._businessID;if(!i)throw new s("Business ID is required");return new r({logger:o??this._logger,businessID:i,...t})}}
//# sourceMappingURL=index.js.map

@@ -13,4 +13,2 @@ /**

* Error code title.
*
* @since 4.2.0
*/

@@ -21,3 +19,3 @@ title: ErrorMessage;

*
* @since 4.2.0, Graph API v16.0
* @since Graph API v16.0
*/

@@ -28,3 +26,3 @@ error_data?: {

*
* @since 4.2.0, Graph API v16.0
* @since Graph API v16.0
*/

@@ -31,0 +29,0 @@ details: string;

@@ -13,4 +13,2 @@ /**

* Error code title.
*
* @since 4.2.0
*/

@@ -21,3 +19,3 @@ title: ErrorMessage;

*
* @since 4.2.0, Graph API v16.0
* @since Graph API v16.0
*/

@@ -28,3 +26,3 @@ error_data?: {

*
* @since 4.2.0, Graph API v16.0
* @since Graph API v16.0
*/

@@ -31,0 +29,0 @@ details: string;

@@ -155,4 +155,2 @@ /**

* Base Error Object.
*
* @since 5.0.0
*/

@@ -162,4 +160,2 @@ export default interface Error {

* Error code.
*
* @since 4.2.0
*/

@@ -170,5 +166,5 @@ code: ErrorCode;

*
* @since 4.2.0, Graph API v16.0
* @since Graph API v16.0
*/
message?: string;
}

@@ -13,4 +13,2 @@ /**

* Error type.
*
* @since 4.2.0
*/

@@ -21,4 +19,3 @@ type: string;

*
* @since 4.2.0
* @deprecated since Graph API v16.0
* @deprecated Since Graph API v16.0
*/

@@ -32,4 +29,2 @@ error_subcode?: number;

* which parameter is invalid or what values are acceptable.
*
* @since 4.2.0
*/

@@ -41,6 +36,4 @@ details: string;

* support to debug the error.
*
* @since 4.2.0
*/
fbtrace_id: string;
}

@@ -17,5 +17,5 @@ /**

}
export interface GraphRequestCreateParams extends GraphRequestParameters {
export interface GraphRequestCreateParameters extends GraphRequestParameters {
}
export interface GraphRequestSendParams {
export interface GraphRequestSendParameters {
/**

@@ -84,3 +84,3 @@ * Fetch provider.

*/
send({ fetch: fetchAlternative, ...requestInit }?: GraphRequestSendParams): Promise<GraphResponse<T>>;
send({ fetch: fetchAlternative, ...requestInit }?: GraphRequestSendParameters): Promise<GraphResponse<T>>;
}

@@ -9,6 +9,4 @@ /**

*/
import CloudAPI from "./CloudAPI/index.js";
import IncomingMessageType from "./Message/MessageType/IncomingMessageType.js";
import OutgoingMessageType from "./Message/MessageType/OutgoingMessageType.js";
export default CloudAPI;
export { CloudAPI, OutgoingMessageType, IncomingMessageType };
export { default, default as CloudAPI } from "./CloudAPI/index.js";
export { default as IncomingMessageType } from "./Message/MessageType/IncomingMessageType.js";
export { default as OutgoingMessageType } from "./Message/MessageType/OutgoingMessageType.js";

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

import e from"./CloudAPI/index.js";import s from"./Message/MessageType/IncomingMessageType.js";import g from"./Message/MessageType/OutgoingMessageType.js";export default e;export{e as CloudAPI,g as OutgoingMessageType,s as IncomingMessageType};
export{default,default as CloudAPI}from"./CloudAPI/index.js";export{default as IncomingMessageType}from"./Message/MessageType/IncomingMessageType.js";export{default as OutgoingMessageType}from"./Message/MessageType/OutgoingMessageType.js";
//# sourceMappingURL=index.js.map

@@ -12,6 +12,4 @@ /**

* TODO: Implement This Interface.
*
* @since 4.2.0
*/
export default interface CloudOutgoingMessageInteractive extends OutgoingMessageInteractive {
}

@@ -12,6 +12,4 @@ /**

* TODO: Implement This Interface.
*
* @since 4.2.0
*/
export default interface OutgoingMessageInteractive extends MessageInteractive {
}

@@ -15,4 +15,2 @@ /**

* this URL takes you to the ad viewed by your customer.
*
* @since 4.2.0
*/

@@ -22,4 +20,2 @@ source_url: string;

* The type of the ad's source.
*
* @since 4.2.0
*/

@@ -29,4 +25,2 @@ source_type: IncomingMessageReferralSourceType;

* Meta ID for an ad or a post.
*
* @since 4.2.0
*/

@@ -36,4 +30,2 @@ source_id: string;

* Headline used in the ad or post.
*
* @since 4.2.0
*/

@@ -43,4 +35,2 @@ headline: string;

* Body for the ad or post.
*
* @since 4.2.0
*/

@@ -50,4 +40,2 @@ body: string;

* Media present in the ad or post.
*
* @since 4.2.0
*/

@@ -57,4 +45,2 @@ media_type: IncomingMessageReferralMediaType;

* URL of the image, when media_type is an image.
*
* @since 4.2.0
*/

@@ -64,4 +50,2 @@ image_url: URL;

* URL of the video, when media_type is a video.
*
* @since 4.2.0
*/

@@ -71,4 +55,2 @@ video_url: URL;

* URL for the thumbnail, when media_type is a video.
*
* @since 4.2.0
*/

@@ -79,5 +61,5 @@ thumbnail_url: URL;

*
* @since 4.2.0
* @since September 27, 2023
*/
ctwa_clid?: string;
}

@@ -9,5 +9,7 @@ /**

*/
import OutgoingMessageError from "../../Error/OutgoingMessageError.js";
import { AccountID, MessageID } from "../../ID.js";
import OutgoingMessageType from "../MessageType/OutgoingMessageType.js";
import OutgoingMessage from "./index.js";
export type CloudOutgoingMessageResponseMessagesMessageStatus = "accepted" | "held_for_quality_assessment";
export interface CloudOutgoingMessageResponse {

@@ -26,3 +28,14 @@ /**

id: MessageID;
/**
* Message Pacing & Quality Control Status.
*
* @since August 28, 2023
* @todo determine whether this field will **always** be defined.
*/
message_status?: CloudOutgoingMessageResponseMessagesMessageStatus;
}[];
/**
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/support/error-codes}
*/
error?: OutgoingMessageError;
}

@@ -33,3 +46,3 @@ export interface CloudOutgoingMessageContext {

*
* @since 4.2.0
* @since July 21, 2022
*/

@@ -48,2 +61,3 @@ message_id: MessageID;

* @default 'whatsapp'
* @since Graph API v12.0
*/

@@ -53,4 +67,2 @@ messaging_product: "whatsapp";

* Required if replying to any message in the conversation.
*
* @since 4.2.0
*/

@@ -71,5 +83,5 @@ context?: CloudOutgoingMessageContext;

*
* @since 4.2.0
* @since November 14, 2023
*/
biz_opaque_callback_data?: string;
}

@@ -12,3 +12,3 @@ /**

import Message from "../index.js";
export type OutgoingMessageRecipientType = "individual" | (string & NonNullable<unknown>);
export type OutgoingMessageRecipientType = "individual" | "group" | (string & NonNullable<unknown>);
/**

@@ -28,4 +28,2 @@ * Base Outgoing Message.

* WhatsApp ID or phone number of the customer you want to send a message to.
*
* @since 4.2.0
*/

@@ -36,6 +34,6 @@ to: AccountID | PhoneNumber;

*
* @since 4.2.0
* @default "individual"
* @see {@link https://developers.facebook.com/docs/graph-api/reference/whats-app-business-account-to-number-current-status/messages/#parameters}
*/
recipient_type?: OutgoingMessageRecipientType;
}

@@ -12,4 +12,2 @@ /**

* Base Message Status.
*
* @since 4.2.0
*/

@@ -16,0 +14,0 @@ export default interface MessageStatus {

@@ -9,2 +9,3 @@ /**

*/
import OutgoingMessageError from "../../../../Error/OutgoingMessageError.js";
import { MessageID } from "../../../../ID.js";

@@ -15,1 +16,8 @@ import OutgoingMessageStatus from "../Outgoing/OutgoingMessageStatus.js";

}
export interface CloudOutgoingMessageStatusResponse {
success?: boolean;
/**
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/support/error-codes}
*/
error?: OutgoingMessageError;
}

@@ -21,3 +21,3 @@ /**

*
* @since 4.2.0
* @since April 5, 2022 Static Stickers. August 25, 2022 Animated Stickers.
*/

@@ -24,0 +24,0 @@ [OutgoingMessageType.Sticker]: CloudOutgoingMessageMedia;

{
"name": "@great-detail/whatsapp",
"version": "6.5.2",
"version": "6.6.0",
"type": "module",

@@ -87,2 +87,3 @@ "description": "SDK for interfacing with WhatsApp Business Platform in Typescript or Node.js using the Cloud API, hosted by Meta.",

"eslint-plugin-jsdoc": "^47.0.1",
"eslint-plugin-unicorn": "^50.0.1",
"jest": "^29.7.0",

@@ -89,0 +90,0 @@ "nock": "^13.3.3",

@@ -11,6 +11,6 @@ /**

import APIInterface from "./APIInterface.js";
import { randomBytes } from "crypto";
import { randomBytes } from "node:crypto";
import type { Logger } from "winston";
export interface WhatsAppAPICreateVerifyTokenParams {
export interface WhatsAppAPICreateVerifyTokenParameters {
/**

@@ -41,3 +41,3 @@ * The length of the verify token.

export interface AbstractAPIParams {
export interface AbstractAPIParameters {
businessID?: AccountID;

@@ -78,3 +78,3 @@ logger?: Logger;

constructor({ logger, businessID }: AbstractAPIParams) {
constructor({ logger, businessID }: AbstractAPIParameters) {
this._logger = logger;

@@ -96,5 +96,5 @@ this._businessID = businessID;

random = randomBytes,
}: WhatsAppAPICreateVerifyTokenParams = {}): string {
}: WhatsAppAPICreateVerifyTokenParameters = {}): string {
return random(length).toString(encoding);
}
}

@@ -9,6 +9,6 @@ /**

*/
import AbstractAPI, { AbstractAPIParams } from "../../API/AbstractAPI.js";
import AbstractAPI, { AbstractAPIParameters } from "../../API/AbstractAPI.js";
import EndpointType from "../../API/EndpointType.js";
import GraphRequest, {
GraphRequestCreateParams,
GraphRequestCreateParameters,
} from "../../GraphRequest/index.js";

@@ -23,3 +23,5 @@ import CloudOutgoingMessageContact from "../../Message/Contact/MessageContact/CloudOutgoingMessageContact.js";

} from "../../Message/OutgoingMessage/CloudOutgoingMessage.js";
import CloudOutgoingMessageStatus from "../../Message/Status/MessageStatus/Outgoing/CloudOutgoingMessageStatus.js";
import CloudOutgoingMessageStatus, {
CloudOutgoingMessageStatusResponse,
} from "../../Message/Status/MessageStatus/Outgoing/CloudOutgoingMessageStatus.js";
import CloudOutgoingStatusMessage from "../../Message/Status/StatusMessage/CloudOutgoingStatusMessage.js";

@@ -40,6 +42,6 @@ import CloudOutgoingMessageTemplate from "../../Message/Template/MessageTemplate/Outgoing/CloudOutgoingMessageTemplate.js";

replyMessageId?: string;
requestProps?: GraphRequestCreateParams;
requestOptions?: GraphRequestCreateParameters;
};
export interface CloudAPIMessageParams extends AbstractAPIParams {
export interface CloudAPIMessageParameters extends AbstractAPIParameters {
businessID: string;

@@ -55,4 +57,4 @@ }

export default class CloudAPIMessage extends AbstractAPI {
constructor(params: CloudAPIMessageParams) {
super(params);
constructor(parameters: CloudAPIMessageParameters) {
super(parameters);
}

@@ -72,3 +74,3 @@

payload: CloudOutgoingMessageStatus,
requestProps: GraphRequestCreateParams = {},
requestOptions: GraphRequestCreateParameters = {},
) {

@@ -80,12 +82,15 @@ const body: CloudOutgoingStatusMessage = {

return new GraphRequest<CloudOutgoingMessageResponse>(this.getEndpoint(), {
logger: this._logger,
...requestProps,
method: "POST",
body: JSON.stringify(body),
headers: {
...requestProps.headers,
"Content-Type": "application/json",
return new GraphRequest<CloudOutgoingMessageStatusResponse>(
this.getEndpoint(),
{
logger: this._logger,
...requestOptions,
method: "POST",
body: JSON.stringify(body),
headers: {
...requestOptions.headers,
"Content-Type": "application/json",
},
},
});
);
}

@@ -102,3 +107,3 @@

payload: CreateMessagePayload,
{ toNumber, replyMessageId, requestProps = {} }: CreateMessageOptionsType,
{ toNumber, replyMessageId, requestOptions = {} }: CreateMessageOptionsType,
) {

@@ -117,7 +122,7 @@ const body: CloudOutgoingMessage<T> = {

logger: this._logger,
...requestProps,
...requestOptions,
method: "POST",
body: JSON.stringify(body),
headers: {
...requestProps.headers,
...requestOptions.headers,
"Content-Type": "application/json",

@@ -124,0 +129,0 @@ },

@@ -141,9 +141,9 @@ /**

public async register(
req: IncomingMessage,
res: ServerResponse,
request: IncomingMessage,
response: ServerResponse,
): Promise<WebhookAPIRegisterReturn> {
this._logger?.http(`Received Webhook Registration: "${req.url}"`);
this._logger?.http(`Received Webhook Registration: "${request.url}"`);
const url = req.url
? new URL(req.url, `http://${req.headers.host}`)
const url = request.url
? new URL(request.url, `http://${request.headers.host}`)
: undefined;

@@ -186,3 +186,3 @@ if (!url) {

this._logger?.debug("Accepting Webhook Registration");
return res.end(hubChallenge);
return response.end(hubChallenge);
},

@@ -195,3 +195,3 @@

this._logger?.debug("Rejecting Webhook Registration");
return res.end();
return response.end();
},

@@ -223,8 +223,8 @@ };

public async eventNotification(
req: IncomingMessage,
res: ServerResponse,
request: IncomingMessage,
response: ServerResponse,
): Promise<WebhookAPIEventNotificationReturn> {
this._logger?.http(`Received Webhook Event Notification: "${req.url}"`);
this._logger?.http(`Received Webhook Event Notification: "${request.url}"`);
const xHubSignature = req.headers["x-hub-signature-256"]
const xHubSignature = request.headers["x-hub-signature-256"]
?.toString()

@@ -241,3 +241,3 @@ .replace("sha256=", "");

req
request
.on("data", (chunk) => {

@@ -298,3 +298,3 @@ bodyBufferChunks.push(chunk);

this._logger?.debug("Accepting Webhook Event Notification");
return res.end();
return response.end();
},

@@ -307,3 +307,3 @@

this._logger?.debug("Rejecting Webhook Event Notification");
return res.end();
return response.end();
},

@@ -310,0 +310,0 @@ };

@@ -9,13 +9,13 @@ /**

*/
import AbstractAPI, { AbstractAPIParams } from "../API/AbstractAPI.js";
import CloudAPIInvalidParamError from "./CloudAPIInvalidParamError.js";
import AbstractAPI, { AbstractAPIParameters } from "../API/AbstractAPI.js";
import CloudAPIInvalidParameterError from "./CloudAPIInvalidParameterError.js";
import CloudAPIMessage, {
CloudAPIMessageParams as BaseCloudAPIMessageParams,
CloudAPIMessageParameters as BaseCloudAPIMessageParameters,
} from "./CloudAPIMessage/index.js";
import CloudAPIWebhook from "./CloudAPIWebhook/index.js";
export interface WhatsAppAPIParams extends AbstractAPIParams {}
export interface WhatsAppAPIParameters extends AbstractAPIParameters {}
export interface CloudAPIMessageParams
extends Partial<BaseCloudAPIMessageParams> {}
export interface CloudAPIMessageParameters
extends Partial<BaseCloudAPIMessageParameters> {}

@@ -40,5 +40,5 @@ /**

constructor(params: WhatsAppAPIParams) {
super(params);
this.webhook = new CloudAPIWebhook(params);
constructor(parameters: WhatsAppAPIParameters) {
super(parameters);
this.webhook = new CloudAPIWebhook(parameters);
}

@@ -60,7 +60,7 @@

logger,
...params
}: CloudAPIMessageParams = {}) {
...parameters
}: CloudAPIMessageParameters = {}) {
const businessID = overrideBusinessID ?? this._businessID;
if (!businessID) {
throw new CloudAPIInvalidParamError("Business ID is required");
throw new CloudAPIInvalidParameterError("Business ID is required");
}

@@ -71,5 +71,5 @@

businessID,
...params,
...parameters,
});
}
}

@@ -14,4 +14,2 @@ /**

* Error code title.
*
* @since 4.2.0
*/

@@ -23,3 +21,3 @@ title: ErrorMessage;

*
* @since 4.2.0, Graph API v16.0
* @since Graph API v16.0
*/

@@ -30,3 +28,3 @@ error_data?: {

*
* @since 4.2.0, Graph API v16.0
* @since Graph API v16.0
*/

@@ -33,0 +31,0 @@ details: string;

@@ -14,4 +14,2 @@ /**

* Error code title.
*
* @since 4.2.0
*/

@@ -23,3 +21,3 @@ title: ErrorMessage;

*
* @since 4.2.0, Graph API v16.0
* @since Graph API v16.0
*/

@@ -30,3 +28,3 @@ error_data?: {

*
* @since 4.2.0, Graph API v16.0
* @since Graph API v16.0
*/

@@ -33,0 +31,0 @@ details: string;

@@ -21,11 +21,11 @@ /**

506: "Duplicate Post",
131043: "Message expired",
131001: "Message too long",
131002: "Invalid recipient type",
131006: "Resource not found",
133001: "Decryption Error",
133002: "Backup Blob Decryption Error",
133003: "Recovery Token Decryption Error",
133007: "Account Blocked",
136025: "Verify code error",
131_043: "Message expired",
131_001: "Message too long",
131_002: "Invalid recipient type",
131_006: "Resource not found",
133_001: "Decryption Error",
133_002: "Backup Blob Decryption Error",
133_003: "Recovery Token Decryption Error",
133_007: "Account Blocked",
136_025: "Verify code error",

@@ -41,8 +41,8 @@ 0: "AuthException",

4: "API Too Many Calls",
80007: "Rate limit issues",
130429: "Rate limit hit",
131048: "Spam Rate limit hit",
131056: "(Business Account, Consumer Account) pair rate limit hit",
80_007: "Rate limit issues",
130_429: "Rate limit hit",
131_048: "Spam Rate limit hit",
131_056: "(Business Account, Consumer Account) pair rate limit hit",
368: "Temporarily blocked for policies violations",
131031: "Account has been locked",
131_031: "Account has been locked",
1: "API Unknown",

@@ -52,35 +52,35 @@ 2: "API Service",

100: "Invalid parameter",
130472: "User's number is part of an experiment",
131000: "Something went wrong",
131005: "Access denied",
131008: "Required parameter is missing",
131009: "Parameter value is not valid",
131016: "Service unavailable",
131021: "Recipient cannot be sender",
131026: "Message Undeliverable",
131042: "Business eligibility payment issue",
131045: "Incorrect certificate",
131047: "Re-engagement message",
131051: "Unsupported message type",
131052: "Media download error",
131053: "Media upload error",
132000: "Template Param Count Mismatch",
132001: "Template does not exist",
132005: "Template Hydrated Text Too Long",
132007: "Template Format Character Policy Violated",
132012: "Template Parameter Format Mismatch",
132015: "Template is Paused",
132016: "Template is Disabled",
132068: "Flow is blocked",
132069: "Flow is throttled",
133000: "Incomplete Deregistration",
133004: "Server Temporarily Unavailable",
133005: "Two step verification PIN Mismatch",
133006: "Phone number re-verification needed",
133008: "Too Many two step verification PIN Guesses",
133009: "Two step verification PIN Guessed Too Fast",
133010: "Phone number Not Registered",
133015:
130_472: "User's number is part of an experiment",
131_000: "Something went wrong",
131_005: "Access denied",
131_008: "Required parameter is missing",
131_009: "Parameter value is not valid",
131_016: "Service unavailable",
131_021: "Recipient cannot be sender",
131_026: "Message Undeliverable",
131_042: "Business eligibility payment issue",
131_045: "Incorrect certificate",
131_047: "Re-engagement message",
131_051: "Unsupported message type",
131_052: "Media download error",
131_053: "Media upload error",
132_000: "Template Param Count Mismatch",
132_001: "Template does not exist",
132_005: "Template Hydrated Text Too Long",
132_007: "Template Format Character Policy Violated",
132_012: "Template Parameter Format Mismatch",
132_015: "Template is Paused",
132_016: "Template is Disabled",
132_068: "Flow is blocked",
132_069: "Flow is throttled",
133_000: "Incomplete Deregistration",
133_004: "Server Temporarily Unavailable",
133_005: "Two step verification PIN Mismatch",
133_006: "Phone number re-verification needed",
133_008: "Too Many two step verification PIN Guesses",
133_009: "Two step verification PIN Guessed Too Fast",
133_010: "Phone number Not Registered",
133_015:
"Please wait a few minutes before attempting to register this phone number",
135000: "Generic user error",
135_000: "Generic user error",

@@ -166,4 +166,2 @@ 400: "Media download error",

* Base Error Object.
*
* @since 5.0.0
*/

@@ -173,4 +171,2 @@ export default interface Error {

* Error code.
*
* @since 4.2.0
*/

@@ -182,5 +178,5 @@ code: ErrorCode;

*
* @since 4.2.0, Graph API v16.0
* @since Graph API v16.0
*/
message?: string;
}

@@ -14,4 +14,2 @@ /**

* Error type.
*
* @since 4.2.0
*/

@@ -23,4 +21,3 @@ type: string;

*
* @since 4.2.0
* @deprecated since Graph API v16.0
* @deprecated Since Graph API v16.0
*/

@@ -36,4 +33,2 @@ error_subcode?: number;

* which parameter is invalid or what values are acceptable.
*
* @since 4.2.0
*/

@@ -46,6 +41,4 @@ details: string;

* support to debug the error.
*
* @since 4.2.0
*/
fbtrace_id: string;
}

@@ -19,5 +19,5 @@ /**

export interface GraphRequestCreateParams extends GraphRequestParameters {}
export interface GraphRequestCreateParameters extends GraphRequestParameters {}
export interface GraphRequestSendParams {
export interface GraphRequestSendParameters {
/**

@@ -117,3 +117,3 @@ * Fetch provider.

...requestInit
}: GraphRequestSendParams = {}): Promise<GraphResponse<T>> {
}: GraphRequestSendParameters = {}): Promise<GraphResponse<T>> {
if (requestInit.headers) {

@@ -120,0 +120,0 @@ const parsedHeaders = new Headers(requestInit.headers);

@@ -9,7 +9,5 @@ /**

*/
import CloudAPI from "./CloudAPI/index.js";
import IncomingMessageType from "./Message/MessageType/IncomingMessageType.js";
import OutgoingMessageType from "./Message/MessageType/OutgoingMessageType.js";
export default CloudAPI;
export { CloudAPI, OutgoingMessageType, IncomingMessageType };
export { default, default as CloudAPI } from "./CloudAPI/index.js";
export { default as IncomingMessageType } from "./Message/MessageType/IncomingMessageType.js";
export { default as OutgoingMessageType } from "./Message/MessageType/OutgoingMessageType.js";

@@ -13,6 +13,4 @@ /**

* TODO: Implement This Interface.
*
* @since 4.2.0
*/
export default interface CloudOutgoingMessageInteractive
extends OutgoingMessageInteractive {}

@@ -13,6 +13,4 @@ /**

* TODO: Implement This Interface.
*
* @since 4.2.0
*/
export default interface OutgoingMessageInteractive
extends MessageInteractive {}

@@ -24,4 +24,2 @@ /**

* this URL takes you to the ad viewed by your customer.
*
* @since 4.2.0
*/

@@ -32,4 +30,2 @@ source_url: string;

* The type of the ad's source.
*
* @since 4.2.0
*/

@@ -40,4 +36,2 @@ source_type: IncomingMessageReferralSourceType;

* Meta ID for an ad or a post.
*
* @since 4.2.0
*/

@@ -48,4 +42,2 @@ source_id: string;

* Headline used in the ad or post.
*
* @since 4.2.0
*/

@@ -56,4 +48,2 @@ headline: string;

* Body for the ad or post.
*
* @since 4.2.0
*/

@@ -64,4 +54,2 @@ body: string;

* Media present in the ad or post.
*
* @since 4.2.0
*/

@@ -72,4 +60,2 @@ media_type: IncomingMessageReferralMediaType;

* URL of the image, when media_type is an image.
*
* @since 4.2.0
*/

@@ -80,4 +66,2 @@ image_url: URL;

* URL of the video, when media_type is a video.
*
* @since 4.2.0
*/

@@ -88,4 +72,2 @@ video_url: URL;

* URL for the thumbnail, when media_type is a video.
*
* @since 4.2.0
*/

@@ -97,5 +79,5 @@ thumbnail_url: URL;

*
* @since 4.2.0
* @since September 27, 2023
*/
ctwa_clid?: string;
}

@@ -9,2 +9,3 @@ /**

*/
import OutgoingMessageError from "../../Error/OutgoingMessageError.js";
import { AccountID, MessageID } from "../../ID.js";

@@ -14,2 +15,6 @@ import OutgoingMessageType from "../MessageType/OutgoingMessageType.js";

export type CloudOutgoingMessageResponseMessagesMessageStatus =
| "accepted"
| "held_for_quality_assessment";
export interface CloudOutgoingMessageResponse {

@@ -28,5 +33,19 @@ /**

}[];
messages: {
id: MessageID;
/**
* Message Pacing & Quality Control Status.
*
* @since August 28, 2023
* @todo determine whether this field will **always** be defined.
*/
message_status?: CloudOutgoingMessageResponseMessagesMessageStatus;
}[];
/**
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/support/error-codes}
*/
error?: OutgoingMessageError;
}

@@ -38,3 +57,3 @@

*
* @since 4.2.0
* @since July 21, 2022
*/

@@ -56,2 +75,3 @@ message_id: MessageID;

* @default 'whatsapp'
* @since Graph API v12.0
*/

@@ -62,4 +82,2 @@ messaging_product: "whatsapp";

* Required if replying to any message in the conversation.
*
* @since 4.2.0
*/

@@ -81,5 +99,5 @@ context?: CloudOutgoingMessageContext;

*
* @since 4.2.0
* @since November 14, 2023
*/
biz_opaque_callback_data?: string;
}

@@ -15,2 +15,3 @@ /**

| "individual"
| "group"
| (string & NonNullable<unknown>);

@@ -35,4 +36,2 @@

* WhatsApp ID or phone number of the customer you want to send a message to.
*
* @since 4.2.0
*/

@@ -44,6 +43,6 @@ to: AccountID | PhoneNumber;

*
* @since 4.2.0
* @default "individual"
* @see {@link https://developers.facebook.com/docs/graph-api/reference/whats-app-business-account-to-number-current-status/messages/#parameters}
*/
recipient_type?: OutgoingMessageRecipientType;
}

@@ -14,4 +14,2 @@ /**

* Base Message Status.
*
* @since 4.2.0
*/

@@ -18,0 +16,0 @@ export default interface MessageStatus {

@@ -9,2 +9,3 @@ /**

*/
import OutgoingMessageError from "../../../../Error/OutgoingMessageError.js";
import { MessageID } from "../../../../ID.js";

@@ -17,1 +18,10 @@ import OutgoingMessageStatus from "../Outgoing/OutgoingMessageStatus.js";

}
export interface CloudOutgoingMessageStatusResponse {
success?: boolean;
/**
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/support/error-codes}
*/
error?: OutgoingMessageError;
}

@@ -23,3 +23,3 @@ /**

*
* @since 4.2.0
* @since April 5, 2022 Static Stickers. August 25, 2022 Animated Stickers.
*/

@@ -26,0 +26,0 @@ [OutgoingMessageType.Sticker]: CloudOutgoingMessageMedia;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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