Socket
Socket
Sign inDemoInstall

chat-bridge

Package Overview
Dependencies
62
Maintainers
1
Versions
9
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

.changeset/config.json

31

CODE_OF_CONDUCT.md

@@ -20,20 +20,20 @@ ## Contributor Covenant Code of Conduct

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall
community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery, and sexual attention or advances of
any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address,
without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

@@ -134,2 +134,1 @@ ### Enforcement Responsibilities

[translations]: https://www.contributor-covenant.org/translations

@@ -17,24 +17,24 @@ ## Contributing to Chat Bridge

```bash
git clone https://github.com/BadEnd777/Chat-Bridge.git
```
```bash
git clone https://github.com/BadEnd777/Chat-Bridge.git
```
3. Create a new branch for your changes:
```bash
git checkout -b feature-or-fix-branch
```
```bash
git checkout -b feature-or-fix-branch
```
4. Make your changes and commit them:
```bash
git add .
git commit -m "Description of your changes"
```
```bash
git add .
git commit -m "Description of your changes"
```
5. Push your changes to your fork:
```bash
git push origin feature-or-fix-branch
```
```bash
git push origin feature-or-fix-branch
```

@@ -49,5 +49,5 @@ 6. Open a pull request (PR) against the `main` branch of the original repository.

```bash
npm install
```
```bash
npm install
```

@@ -58,5 +58,5 @@ 2. Create a new bot on Facebook and get your access token.

```bash
node path/to/your/entry/file
```
```bash
node path/to/your/entry/file
```

@@ -75,6 +75,6 @@ ### Code Style

- Provide a clear and concise description of the changes.
- Reference the related issue if applicable.
- Ensure that your changes pass all tests.
- Keep the pull request focused on a single issue or feature.
- Provide a clear and concise description of the changes.
- Reference the related issue if applicable.
- Ensure that your changes pass all tests.
- Keep the pull request focused on a single issue or feature.

@@ -87,2 +87,2 @@ ### Code Review

We appreciate your contribution to Chat Bridge. You're awesome! 🎉
We appreciate your contribution to Chat Bridge. You're awesome! 🎉

@@ -0,22 +1,20 @@

import { EventEmitter } from 'events';
import { FastifyInstance } from 'fastify';
import { EventEmitter } from 'events';
interface ClientOptions {
accessToken: string;
verifyToken: string;
endpoint?: string;
port?: number;
host?: string;
loggers?: boolean;
}
interface PageInformation {
name: string;
id: string;
}
/**
* Represents a persistent menu for a specific user.
*/
declare class PersistentMenu {
private psid;
private persistentMenu;
/**
* Creates a new instance of PersistentMenu.
* @param psid - The PSID (Page Scoped ID) of the user.
* @param persistentMenu - The array of persistent menu items.
*/
constructor(psid: string, persistentMenu: PersistentMenuItem[]);
/**
* Converts the PersistentMenu object to a JSON representation.
* @returns The JSON representation of the PersistentMenu object.
*/
toJSON(): {

@@ -27,2 +25,5 @@ psid: string;

}
/**
* Represents a persistent menu item.
*/
declare class PersistentMenuItem {

@@ -32,3 +33,13 @@ private locale;

private callToActions;
/**
* Creates a new instance of PersistentMenuItem.
* @param locale The locale of the menu item.
* @param composerInputDisabled Indicates whether the composer input is disabled for this menu item.
* @param callToActions The call to actions associated with this menu item.
*/
constructor(locale: string, composerInputDisabled: boolean, callToActions: CallToAction[]);
/**
* Converts the persistent menu item to JSON format.
* @returns The JSON representation of the persistent menu item.
*/
toJSON(): {

@@ -40,2 +51,5 @@ locale: string;

}
/**
* Represents a call to action in the persistent menu.
*/
declare class CallToAction {

@@ -47,3 +61,15 @@ private type;

private webviewHeightRatio;
/**
* Creates a new instance of the CallToAction class.
* @param type - The type of the call to action.
* @param title - The title of the call to action.
* @param payload - The payload of the call to action.
* @param url - The URL of the call to action.
* @param webviewHeightRatio - The webview height ratio of the call to action.
*/
constructor(type: string, title: string, payload: string, url: string, webviewHeightRatio: string);
/**
* Converts the CallToAction object to a JSON representation.
* @returns The JSON representation of the CallToAction object.
*/
toJSON(): {

@@ -59,14 +85,49 @@ type: string;

/**
* @type {Client}
* @example
* const { Client } = require('@badend/chatbridge');
*
* const client = new Client({
* accessToken: "YOUR_ACCESS_TOKEN", // required
* verifyToken: "YOUR_VERIFY_TOKEN", // required
* // webHookPath: "/webhook", // default
* // port: 8080, // default
* // host: "localhost", // default (only for development) or 0.0.0.0 (for production)
* });
* Represents the options for configuring a client.
*/
interface ClientOptions {
/**
* The access token for authentication.
*/
accessToken: string;
/**
* The verify token for authentication.
*/
verifyToken: string;
/**
* The endpoint URL for the client.
*/
endpoint?: string;
/**
* The port number for the client.
*/
port?: number;
/**
* The host address for the client.
*/
host?: string;
/**
* Specifies whether to enable logging.
*/
loggers?: boolean;
}
/**
* Represents information about a page.
*/
interface PageInformation {
/**
* The name of the page.
*/
name: string;
/**
* The ID of the page.
*/
id: string;
}
/**
* Represents a client for interacting with a chat service.
* Extends EventEmitter for event handling.
*/
declare class Client extends EventEmitter {

@@ -79,171 +140,134 @@ server: FastifyInstance;

host: string;
/**
* Information about the page associated with the client.
*/
page: PageInformation;
/**
* Creates a new instance of the Client class.
* @param options - The options for configuring the client.
*/
constructor(options: ClientOptions);
/**
* Handles the verification request from the chat service.
* @param request - The Fastify request object.
* @param reply - The Fastify reply object.
* @returns The verification response.
*/
private handleVerifyRequest;
/**
* Handles the webhook request from the chat service.
* @param request - The Fastify request object.
* @param reply - The Fastify reply object.
* @returns The webhook response.
*/
private handleWebhookRequest;
/**
* Start the server
* @memberof Client
* @example
* client.start(async () => console.log(`Listening on ${client.page.name} (${client.page.id})`));
* @param {Function} [callback]
* Starts the client and listens for incoming requests.
* @param callback - An optional callback function to be called when the server starts.
*/
start(callback?: () => void): Promise<void>;
/**
* Register a plugin
* @memberof Client
* @example
* client.register(require('fastify-cors'), {
* origin: '*',
* });
* @param {Function} ...args
* Registers a plugin with the client's server.
* @param args - The arguments to pass to the Fastify register method.
* @returns A promise that resolves when the plugin is registered.
*/
register(...args: Parameters<FastifyInstance['register']>): Promise<undefined>;
/**
* Sends a request to the specified path with the given method and body.
* @param options - The options for the request.
* @returns The response body of the request.
* @throws Error if the request fails or the status code is not 200.
*/
private sendRequest;
/**
* Send an API message
* @memberof Client
* @example
* client.sendApiMessage("USER_ID", {
* text: "Hello, World!",
* quick_replies: [
* {
* content_type: "text",
* title: "Hello",
* payload: "HELLO",
* }
* ]
* });
* @param {string} recipientId
* @param {object} message
* Sends an API message to a recipient.
* @param recipientId - The ID of the recipient.
* @param message - The message to send.
* @returns A promise that resolves with the API response.
*/
sendApiMessage(recipientId: string, message: object): Promise<unknown>;
/**
* Send a message
* @memberof Client
* @example
* client.send("USER_ID", {
* text: "Hello, World!",
* quick_replies: [
* {
* content_type: "text",
* title: "Hello",
* payload: "HELLO",
* }
* ]
* });
* @param {string} recipientId
* @param {object} message
* Sends a message to a recipient.
* @param recipientId - The ID of the recipient.
* @param message - The message to send.
* @returns A promise that resolves with the API response.
*/
send(recipientId: string, message: object): Promise<unknown>;
/**
* Get page information
* @memberof Client
* @example
* const pageInformation = await client.getPageInfo();
* console.log(pageInformation);
* @returns
* { name: "Page Name", id: "PAGE_ID" }
* Retrieves information about the page associated with the client.
* @returns A promise that resolves with the page information.
*/
getPageInfo(): Promise<Pick<PageInformation, 'name' | 'id'>>;
/**
* Send a text message
* @memberof Client
* @example
* client.sendTextMessage("USER_ID", "Hello World!");
* @param {string} recipientId
* @param {string} text
* Sends a text message to a recipient.
* @param recipientId - The ID of the recipient.
* @param text - The text message to send.
* @returns A promise that resolves with the API response.
*/
sendTextMessage(recipientId: string, text: string): Promise<unknown>;
/**
* Send an attachment
* @memberof Client
* @example
* client.sendAttachment("USER_ID", "image", "https://example.com/image.png");
* @param {string} recipientId
* @param {string} type - image, audio, video, file
* @param {string} url
* @param {boolean} [isReusable=false]
* Sends an attachment to a recipient.
* @param recipientId - The ID of the recipient.
* @param type - The type of the attachment (image, audio, video, file).
* @param url - The URL of the attachment.
* @param isReusable - Indicates whether the attachment is reusable.
* @returns A promise that resolves with the API response.
*/
sendAttachment(recipientId: string, type: string, url: string, isReusable?: boolean): Promise<unknown>;
/**
* Send an image
* @memberof Client
* @example
* client.sendImage("USER_ID", "https://example.com/image.png");
* @param {string} recipientId
* @param {string} url
* @param {boolean} [isReusable=false]
* Sends an image attachment to a recipient.
* @param recipientId - The ID of the recipient.
* @param url - The URL of the image.
* @param isReusable - Indicates whether the image is reusable.
* @returns A promise that resolves with the API response.
*/
sendImage(recipientId: string, url: string, isReusable?: boolean): Promise<unknown>;
/**
* Send an audio
* @memberof Client
* @example
* client.sendAudio("USER_ID", "https://example.com/audio.mp3");
* @param {string} recipientId
* @param {string} url
* @param {boolean} [isReusable=false]
* Sends an audio attachment to a recipient.
* @param recipientId - The ID of the recipient.
* @param url - The URL of the audio.
* @param isReusable - Indicates whether the audio is reusable.
* @returns A promise that resolves with the API response.
*/
sendAudio(recipientId: string, url: string, isReusable?: boolean): Promise<unknown>;
/**
* Send a video
* @memberof Client
* @example
* client.sendVideo("USER_ID", "https://example.com/video.mp4");
* @param {string} recipientId
* @param {string} url
* @param {boolean} [isReusable=false]
* Sends a video attachment to a recipient.
* @param recipientId - The ID of the recipient.
* @param url - The URL of the video.
* @param isReusable - Indicates whether the video is reusable.
* @returns A promise that resolves with the API response.
*/
sendVideo(recipientId: string, url: string, isReusable?: boolean): Promise<unknown>;
/**
* Send a file
* @memberof Client
* @example
* client.sendFile("USER_ID", "https://example.com/file.pdf");
* @param {string} recipientId
* @param {string} url
* @param {boolean} [isReusable=false]
* Sends a file attachment to a recipient.
* @param recipientId - The ID of the recipient.
* @param url - The URL of the file.
* @param isReusable - Indicates whether the file is reusable.
* @returns A promise that resolves with the API response.
*/
sendFile(recipientId: string, url: string, isReusable?: boolean): Promise<unknown>;
/**
* Set typing indicator
* @memberof Client
* @example
* client.setTyping("USER_ID", true);
* @param {string} recipientId
* @param {boolean} typing
* Sets the typing indicator for a recipient.
* @param recipientId - The ID of the recipient.
* @param typing - Indicates whether the typing indicator should be turned on or off.
* @returns A promise that resolves with the API response.
*/
setTyping(recipientId: string, typing: boolean): Promise<unknown>;
/**
* Set persistent menu
* @memberof Client
* @example
* const { PersistentMenu, PersistentMenuItem, CallToAction } = require('chat-bridge');
*
* const persistentMenu = new PersistentMenu('12345', [
* new PersistentMenuItem('default', false, [
* new CallToAction('postback', 'Help', 'HELP_PAYLOAD', '', ''),
* new CallToAction('postback', 'Start', 'START_PAYLOAD', '', '')
* ])
* ]);
*
* client.setPersistentMenu(persistentMenu);
* @param {PersistentMenu} persistentMenu
* Sets the persistent menu for a user.
* @param psid - The ID of the user.
* @param persistentMenu - The persistent menu items.
* @returns A promise that resolves with the API response.
*/
setPersistentMenu(psid: string, persistentMenu: PersistentMenuItem[]): Promise<unknown>;
/**
* Get persistent menu
* @memberof Client
* @example
* client.getPersistentMenu("12345");
* @param {string} psid
* Retrieves the persistent menu for a user.
* @param psid - The ID of the user.
* @returns A promise that resolves with the API response.
*/
getPersistentMenu(psid: string): Promise<unknown>;
/**
* Delete persistent menu
* @memberof Client
* @example
* client.deletePersistentMenu("12345");
* @param {string} psid
* Deletes the persistent menu for a user.
* @param psid - The ID of the user.
* @returns A promise that resolves with the API response.
*/

@@ -254,20 +278,17 @@ deletePersistentMenu(psid: string): Promise<unknown>;

/**
* Collections class
* @class
* @classdesc A class to manage collections
* @property {Array} items - An array to store items
* @method add - A method to add an item to the collection
* @method get - A method to get an item from the collection
* @example
* const collections = new Collections();
*
* collections.add({ name: 'item1', value: 1 });
* collections.add({ name: 'item2', value: 2 });
* collections.get('item1'); // { name: 'item1', value: 1 }
* collections.get('item2'); // { name: 'item2', value: 2 }
* */
* Represents a collection of items.
*/
declare class Collections {
private items;
constructor();
/**
* Adds an item to the collection.
* @param item - The item to add.
*/
add(item: any): void;
/**
* Retrieves an item from the collection by name.
* @param name - The name of the item to retrieve.
* @returns The item with the specified name, or undefined if not found.
*/
get(name: string): any;

@@ -277,8 +298,3 @@ }

/**
* Constants
* @example
* const { Constants } = require('chat-bridge');
*
* console.log(Constants.BASE_URL); // https://graph.facebook.com/
* console.log(Constants.MESSAGE_URL); // https://graph.facebook.com/v18.0/me/
* Constants object containing base URL and message URL.
*/

@@ -290,6 +306,18 @@ declare const Constants: {

/**
* Represents a call button that can be used in a chat interface.
*/
declare class CallButton {
private title;
private phoneNumber;
/**
* Creates a new instance of the CallButton class.
* @param title The title of the call button.
* @param payload The phone number associated with the call button.
*/
constructor(title: string, payload: string);
/**
* Converts the CallButton object to a JSON representation.
* @returns The JSON representation of the CallButton object.
*/
toJSON(): {

@@ -302,6 +330,18 @@ type: string;

/**
* Represents a postback button.
*/
declare class PostbackButton {
private title;
private payload;
/**
* Creates a new instance of the PostbackButton class.
* @param title The title of the button.
* @param payload The payload associated with the button.
*/
constructor(title: string, payload: string);
/**
* Converts the PostbackButton instance to a JSON object.
* @returns The JSON representation of the button.
*/
toJSON(): {

@@ -314,6 +354,18 @@ type: string;

/**
* Represents a URL button.
*/
declare class UrlButton {
private title;
private url;
/**
* Creates a new instance of the UrlButton class.
* @param title The title of the button.
* @param url The URL associated with the button.
*/
constructor(title: string, url: string);
/**
* Converts the UrlButton instance to JSON format.
* @returns The JSON representation of the UrlButton.
*/
toJSON(): {

@@ -326,2 +378,5 @@ type: string;

/**
* Represents a generic element used in a chat message.
*/
declare class GenericElement {

@@ -333,5 +388,25 @@ private title;

private buttons;
/**
* Creates a new instance of GenericElement.
* @param title - The title of the element.
* @param subtitle - The subtitle of the element.
* @param imageUrl - The URL of the image associated with the element.
*/
constructor(title: string, subtitle: string, imageUrl: string);
/**
* Sets the URL of the item associated with the element.
* @param itemUrl - The URL of the item.
* @returns The updated GenericElement instance.
*/
setItemUrl(itemUrl: string): GenericElement;
/**
* Adds buttons to the element.
* @param buttons - An array of buttons to be added.
* @returns The updated GenericElement instance.
*/
addButtons(buttons: Array<CallButton | PostbackButton | UrlButton>): GenericElement;
/**
* Converts the GenericElement instance to JSON format.
* @returns The JSON representation of the GenericElement instance.
*/
toJSON(): {

@@ -346,6 +421,18 @@ title: string;

/**
* Represents a greeting message.
*/
declare class Greeting {
private locale;
private text;
/**
* Creates a new instance of the Greeting class.
* @param locale The locale of the greeting.
* @param text The text of the greeting.
*/
constructor(locale: string, text: string);
/**
* Converts the Greeting object to JSON format.
* @returns The JSON representation of the Greeting object.
*/
toJSON(): {

@@ -357,2 +444,5 @@ locale: string;

/**
* Represents a media element used in a chat message.
*/
declare class MediaElement {

@@ -363,4 +453,18 @@ private mediaType;

private buttons;
/**
* Creates a new MediaElement instance.
* @param mediaType The type of media (e.g., 'image', 'video').
* @param media The media content (either a URL or an attachment ID).
*/
constructor(mediaType: string, media: string);
/**
* Adds buttons to the media element.
* @param buttons The buttons to add.
* @returns The updated MediaElement instance.
*/
addButtons(buttons: Array<CallButton | PostbackButton | UrlButton>): MediaElement;
/**
* Converts the MediaElement instance to a JSON object.
* @returns The JSON representation of the MediaElement.
*/
toJSON(): {

@@ -374,5 +478,16 @@ media_type: string;

/**
* Represents a product element.
*/
declare class ProductElement {
private id;
/**
* Creates a new instance of the ProductElement class.
* @param id - The ID of the product element.
*/
constructor(id: string);
/**
* Converts the product element to JSON format.
* @returns The JSON representation of the product element.
*/
toJSON(): {

@@ -383,2 +498,5 @@ id: string;

/**
* Represents a receipt element.
*/
declare class ReceiptElement {

@@ -391,3 +509,16 @@ private title;

private imageUrl;
/**
* Creates a new instance of ReceiptElement.
* @param title - The title of the element.
* @param subtitle - The subtitle of the element.
* @param quantity - The quantity of the element.
* @param price - The price of the element.
* @param currency - The currency of the element.
* @param imageUrl - The URL of the image associated with the element.
*/
constructor(title: string, subtitle: string, quantity: number, price: number, currency: string, imageUrl: string);
/**
* Converts the receipt element to JSON format.
* @returns The JSON representation of the receipt element.
*/
toJSON(): {

@@ -403,7 +534,23 @@ title: string;

/**
* Represents a button template for a chat message.
*/
declare class ButtonTemplate {
private text;
private buttons;
/**
* Creates a new instance of ButtonTemplate.
* @param text The text to be displayed in the template.
*/
constructor(text: string);
/**
* Adds buttons to the template.
* @param buttons The buttons to be added.
* @returns The updated ButtonTemplate instance.
*/
addButtons(buttons: Array<CallButton | PostbackButton | UrlButton>): ButtonTemplate;
/**
* Converts the ButtonTemplate instance to JSON format.
* @returns The JSON representation of the ButtonTemplate.
*/
toJSON(): {

@@ -421,2 +568,5 @@ attachment: {

/**
* Represents a coupon template.
*/
declare class CouponTemplate {

@@ -431,11 +581,61 @@ private title;

private payload?;
/**
* Creates a new instance of the CouponTemplate class.
* @param title - The title of the coupon template.
* @param couponCode - The coupon code.
* @param couponUrl - The URL associated with the coupon.
*/
constructor(title: string, couponCode: string, couponUrl: string);
/**
* Sets the title of the coupon template.
* @param title - The title of the coupon template.
* @returns The updated CouponTemplate instance.
*/
setTitle(title: string): CouponTemplate;
/**
* Sets the subtitle of the coupon template.
* @param subtitle - The subtitle of the coupon template.
* @returns The updated CouponTemplate instance.
*/
setSubtitle(subtitle: string): CouponTemplate;
/**
* Sets the coupon code.
* @param couponCode - The coupon code.
* @returns The updated CouponTemplate instance.
*/
setCouponCode(couponCode: string): CouponTemplate;
/**
* Sets the URL associated with the coupon.
* @param couponUrl - The URL associated with the coupon.
* @returns The updated CouponTemplate instance.
*/
setCouponUrl(couponUrl: string): CouponTemplate;
/**
* Sets the button title for the coupon URL.
* @param couponUrlButtonTitle - The button title for the coupon URL.
* @returns The updated CouponTemplate instance.
*/
setCouponUrlButtonTitle(couponUrlButtonTitle: string): CouponTemplate;
/**
* Sets the pre-message for the coupon.
* @param couponPreMessage - The pre-message for the coupon.
* @returns The updated CouponTemplate instance.
*/
setCouponPreMessage(couponPreMessage: string): CouponTemplate;
/**
* Sets the image URL for the coupon.
* @param imageUrl - The image URL for the coupon.
* @returns The updated CouponTemplate instance.
*/
setImageUrl(imageUrl: string): CouponTemplate;
/**
* Sets the payload for the coupon.
* @param payload - The payload for the coupon.
* @returns The updated CouponTemplate instance.
*/
setPayload(payload: string): CouponTemplate;
/**
* Converts the CouponTemplate instance to JSON format.
* @returns The JSON representation of the CouponTemplate instance.
*/
toJSON(): {

@@ -459,2 +659,5 @@ attachment: {

/**
* Enum representing the types of feedback questions.
*/
declare enum FeedbackQuestionType {

@@ -465,2 +668,5 @@ CSAT = "csat",

}
/**
* Represents a feedback template for a chat application.
*/
declare class FeedbackTemplate {

@@ -473,6 +679,31 @@ private title;

private expiresInDays?;
/**
* Creates a new instance of FeedbackTemplate.
* @param title - The title of the feedback template.
* @param subtitle - The subtitle of the feedback template.
* @param buttonTitle - The title of the button in the feedback template.
*/
constructor(title: string, subtitle: string, buttonTitle: string);
/**
* Adds feedback screens to the feedback template.
* @param feedbackScreens - An array of feedback screens to be added.
* @returns The updated FeedbackTemplate instance.
*/
addFeedbackScreens(feedbackScreens: Array<FeedbackScreen>): FeedbackTemplate;
/**
* Sets the business privacy URL for the feedback template.
* @param url - The URL of the business privacy policy.
* @returns The updated FeedbackTemplate instance.
*/
setBusinessPrivacy(url: string): FeedbackTemplate;
/**
* Sets the expiration period in days for the feedback template.
* @param expiresInDays - The number of days until the feedback template expires.
* @returns The updated FeedbackTemplate instance.
*/
setExpiresInDays(expiresInDays: number): FeedbackTemplate;
/**
* Converts the FeedbackTemplate instance to a JSON object.
* @returns The JSON representation of the FeedbackTemplate instance.
*/
toJSON(): {

@@ -495,5 +726,17 @@ attachment: {

}
/**
* Represents a feedback screen that contains a list of feedback questions.
*/
declare class FeedbackScreen {
private questions;
/**
* Adds an array of feedback questions to the feedback screen.
* @param questions - The array of feedback questions to add.
* @returns The updated feedback screen.
*/
addQuestions(questions: Array<FeedbackQuestion>): FeedbackScreen;
/**
* Converts the feedback screen object to JSON format.
* @returns The JSON representation of the feedback screen.
*/
toJSON(): {

@@ -503,2 +746,5 @@ questions: FeedbackQuestion[];

}
/**
* Represents a feedback question.
*/
declare class FeedbackQuestion {

@@ -511,7 +757,36 @@ private id;

private followUp?;
/**
* Creates a new instance of FeedbackQuestion.
* @param id - The ID of the question.
* @param type - The type of the question.
*/
constructor(id: string, type: FeedbackQuestionType);
/**
* Sets the title of the question.
* @param title - The title of the question.
* @returns The updated FeedbackQuestion instance.
*/
setTitle(title: string): FeedbackQuestion;
/**
* Sets the score label of the question.
* @param scoreLabel - The score label of the question.
* @returns The updated FeedbackQuestion instance.
*/
setScoreLabel(scoreLabel: string): FeedbackQuestion;
/**
* Sets the score option of the question.
* @param scoreOption - The score option of the question.
* @returns The updated FeedbackQuestion instance.
*/
setScoreOption(scoreOption: string): FeedbackQuestion;
/**
* Sets the follow-up of the question.
* @param followUp - The follow-up of the question.
* @returns The updated FeedbackQuestion instance.
*/
setFollowUp(followUp: FollowUp): FeedbackQuestion;
/**
* Converts the FeedbackQuestion instance to JSON format.
* @returns The JSON representation of the FeedbackQuestion instance.
*/
toJSON(): {

@@ -526,7 +801,23 @@ id: string;

}
/**
* Represents a follow-up question in a feedback template.
*/
declare class FollowUp {
private type;
private placeholder?;
/**
* Creates a new instance of the FollowUp class.
* @param type The type of the follow-up question.
*/
constructor(type: string);
/**
* Sets the placeholder text for the follow-up question.
* @param placeholder The placeholder text.
* @returns The updated FollowUp instance.
*/
setPlaceholder(placeholder: string): FollowUp;
/**
* Converts the FollowUp instance to a JSON object.
* @returns The JSON representation of the FollowUp instance.
*/
toJSON(): {

@@ -538,5 +829,17 @@ type: string;

/**
* Represents a generic template for creating structured messages.
*/
declare class GenericTemplate {
private elements;
/**
* Adds an element to the generic template.
* @param element The element to add.
* @returns The updated GenericTemplate instance.
*/
addElement(element: GenericElement): GenericTemplate;
/**
* Converts the GenericTemplate instance to a JSON object.
* @returns The JSON representation of the GenericTemplate.
*/
toJSON(): {

@@ -553,5 +856,17 @@ attachment: {

/**
* Represents a media template for creating rich media attachments.
*/
declare class MediaTemplate {
private elements;
/**
* Adds a media element to the media template.
* @param element The media element to add.
* @returns The updated media template.
*/
addElement(element: MediaElement): MediaTemplate;
/**
* Converts the media template to a JSON object.
* @returns The JSON representation of the media template.
*/
toJSON(): {

@@ -568,5 +883,17 @@ attachment: {

/**
* Represents a product template.
*/
declare class ProductTemplate {
private elements;
/**
* Adds an element to the product template.
* @param element The element to add.
* @returns The updated product template.
*/
addElement(element: ProductElement): ProductTemplate;
/**
* Converts the product template to JSON format.
* @returns The JSON representation of the product template.
*/
toJSON(): {

@@ -583,7 +910,23 @@ attachment: {

/**
* Represents a collection of quick replies for a chat message.
*/
declare class QuickReplies {
private title;
private quickReplies;
/**
* Creates a new instance of QuickReplies.
* @param title The title of the quick replies.
*/
constructor(title: string);
/**
* Adds an array of quick replies to the collection.
* @param quickReplies The quick replies to add.
* @returns The updated QuickReplies instance.
*/
addQuickReply(quickReplies: QuickReply[]): QuickReplies;
/**
* Converts the QuickReplies instance to a JSON object.
* @returns The JSON representation of the QuickReplies instance.
*/
toJSON(): {

@@ -594,2 +937,5 @@ text: string;

}
/**
* Represents a quick reply option for a chat message.
*/
declare class QuickReply {

@@ -599,5 +945,23 @@ private title;

private imageUrl?;
/**
* Creates a new QuickReply instance with the specified title.
* @param title The title of the quick reply.
*/
constructor(title: string);
/**
* Sets the payload for the quick reply.
* @param payload The payload to be sent when the quick reply is selected.
* @returns The updated QuickReply instance.
*/
setPayload(payload: string): QuickReply;
/**
* Sets the image URL for the quick reply.
* @param imageUrl The URL of the image to be displayed with the quick reply.
* @returns The updated QuickReply instance.
*/
setImageUrl(imageUrl: string): QuickReply;
/**
* Converts the QuickReply instance to a JSON object.
* @returns The JSON representation of the QuickReply instance.
*/
toJSON(): {

@@ -611,2 +975,5 @@ content_type: string;

/**
* Represents a receipt template.
*/
declare class ReceiptTemplate {

@@ -622,7 +989,39 @@ private recipientName;

private adjustments;
/**
* Creates a new instance of the ReceiptTemplate class.
* @param recipientName - The name of the recipient.
* @param orderNumber - The order number.
* @param currency - The currency.
* @param paymentMethod - The payment method.
* @param timestamp - The timestamp.
*/
constructor(recipientName: string, orderNumber: string, currency: string, paymentMethod: string, timestamp: string);
/**
* Adds an element to the receipt template.
* @param element - The element to add.
* @returns The updated ReceiptTemplate instance.
*/
addElement(element: ReceiptElement): ReceiptTemplate;
/**
* Sets the address for the receipt template.
* @param address - The address to set.
* @returns The updated ReceiptTemplate instance.
*/
setAddress(address: Address): ReceiptTemplate;
/**
* Sets the summary for the receipt template.
* @param summary - The summary to set.
* @returns The updated ReceiptTemplate instance.
*/
setSummary(summary: Summary): ReceiptTemplate;
/**
* Adds adjustments to the receipt template.
* @param adjustments - The adjustments to add.
* @returns The updated ReceiptTemplate instance.
*/
addAdjustments(adjustments: Array<Adjustment>): ReceiptTemplate;
/**
* Converts the ReceiptTemplate instance to JSON format.
* @returns The JSON representation of the ReceiptTemplate instance.
*/
toJSON(): {

@@ -646,2 +1045,5 @@ attachment: {

}
/**
* Represents an address.
*/
declare class Address {

@@ -654,4 +1056,21 @@ private street1;

private country;
/**
* Creates a new instance of the Address class.
* @param street1 - The first line of the street address.
* @param city - The city name.
* @param postalCode - The postal code.
* @param state - The state or province.
* @param country - The country.
*/
constructor(street1: string, city: string, postalCode: string, state: string, country: string);
/**
* Sets the second line of the street address.
* @param street2 - The second line of the street address.
* @returns The updated Address object.
*/
setStreet2(street2: string): Address;
/**
* Converts the Address object to a JSON representation.
* @returns The JSON representation of the Address object.
*/
toJSON(): {

@@ -666,2 +1085,5 @@ street_1: string;

}
/**
* Represents a summary of a receipt.
*/
declare class Summary {

@@ -672,3 +1094,14 @@ private subtotal;

private totalCost;
/**
* Creates a new Summary instance.
* @param subtotal - The subtotal amount.
* @param shippingCost - The shipping cost amount.
* @param totalTax - The total tax amount.
* @param totalCost - The total cost amount.
*/
constructor(subtotal: number, shippingCost: number, totalTax: number, totalCost: number);
/**
* Converts the Summary object to a JSON representation.
* @returns The JSON representation of the Summary object.
*/
toJSON(): {

@@ -681,6 +1114,18 @@ subtotal: number;

}
/**
* Represents an adjustment in a receipt.
*/
declare class Adjustment {
private name;
private amount;
/**
* Creates a new instance of the Adjustment class.
* @param name - The name of the adjustment.
* @param amount - The amount of the adjustment.
*/
constructor(name: string, amount: number);
/**
* Converts the Adjustment object to a JSON representation.
* @returns The JSON representation of the Adjustment object.
*/
toJSON(): {

@@ -687,0 +1132,0 @@ name: string;

{
"name": "chat-bridge",
"version": "2.0.0",
"version": "2.0.1",
"description": "Chat Bridge simplifies the integration of Facebook Messenger webhook handling into your Node.js applications.",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"author": {
"name": "BadEnd777",
"email": "badend777@proton.me"
},
"homepage": "https://chat-bridge.pages.dev/",
"repository": {

@@ -17,5 +9,14 @@ "type": "git",

},
"homepage": "https://chat-bridge.pages.dev/",
"bugs": {
"url": "https:/github.com/BadEnd777/Chat-Bridge/issues"
},
"author": {
"name": "BadEnd777",
"email": "badend777@proton.me"
},
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"keywords": [

@@ -35,7 +36,32 @@ "facebook",

],
"license": "MIT",
"dependencies": {
"fastify": "^4.25.2",
"undici": "^6.2.1"
"fastify": "^4.26.2",
"undici": "^6.7.0"
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
"@swc/core": "^1.4.2",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.24",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"eslint": "^8.57.0",
"prettier": "^3.2.5",
"prettier-plugin-pkg": "^0.18.1",
"tsup": "^8.0.2",
"typescript": "^5.3.3",
"unimported": "^1.31.1",
"validate-branch-name": "^1.3.0",
"yalc": "1.0.0-pre.53"
},
"scripts": {
"build": "tsup",
"format:fix": "prettier --write . --list-different",
"fotmat": "prettier --check .",
"lint": "eslint --ext .ts src",
"prerelease": "pnpm build && changeset add && changeset version && pnpm format:fix",
"release": "pnpm build && changeset publish",
"unimported": "unimported"
}
}
<div align="center" id="about">
<img src="https://cdn.discordapp.com/attachments/1082890782471639091/1194113658201047130/logo-png.png" alt="Chat Bridge Logo" width="200px">
<img src="https://raw.githubusercontent.com/BadEnd777/Chat-Bridge/main/.github/assets/logo.png" alt="Chat Bridge Logo" style="width: 200px; height: 200px; border-radius: 50%;">
<h1>Chat Bridge</h1>

@@ -24,20 +24,20 @@ <a href="https://www.npmjs.com/package/chat-bridge">

- [Table of Contents](#table-of-contents)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [Acknowledgments](#acknowledgments)
- [License](#license)
- [Table of Contents](#table-of-contents)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [Acknowledgments](#acknowledgments)
- [License](#license)
### Features
- **Easy Integration**: Simplifies the integration of Facebook Messenger webhook handling into your Node.js applications.
- **Incoming Events Handling**: Provides a convenient way to handle incoming events from users.
- **Customizable**: Offers flexibility for customization according to specific application needs.
- **Event Driven**: Built on an event-driven architecture, making it easy to listen for and respond to various events.
- **Simple API**: Provides a straightforward API for sending messages and interacting with users.
- **Scalable**: Designed to scale with your application, handling high volumes of incoming messages efficiently.
- **Open Source**: Licensed under the [MIT License](LICENSE), Chat Bridge is open source and free to use.
- **Easy Integration**: Simplifies the integration of Facebook Messenger webhook handling into your Node.js applications.
- **Incoming Events Handling**: Provides a convenient way to handle incoming events from users.
- **Customizable**: Offers flexibility for customization according to specific application needs.
- **Event Driven**: Built on an event-driven architecture, making it easy to listen for and respond to various events.
- **Simple API**: Provides a straightforward API for sending messages and interacting with users.
- **Scalable**: Designed to scale with your application, handling high volumes of incoming messages efficiently.
- **Open Source**: Licensed under the [MIT License](LICENSE), Chat Bridge is open source and free to use.

@@ -58,6 +58,6 @@ ### Installation

// Import the Client class
const { Client } = require("chat-bridge");
const { Client } = require('chat-bridge');
// Create a new client instance
const client = new Client({
const client = new Client({
accessToken: 'YOUR_ACCESS_TOKEN',

@@ -68,3 +68,3 @@ verifyToken: 'YOUR_VERIFY_TOKEN'

// Listen for incoming messages events
client.on("message", (event) => {
client.on('message', (event) => {
const { sender, message } = event;

@@ -96,4 +96,4 @@

- [fastify](https://www.fastify.io/) — Fast and low overhead web framework, for Node.js
- [undici](https://undici.nodejs.org/) — HTTP/1.1 client, written from scratch for Node.js
- [fastify](https://www.fastify.io/) — Fast and low overhead web framework, for Node.js
- [undici](https://undici.nodejs.org/) — HTTP/1.1 client, written from scratch for Node.js

@@ -100,0 +100,0 @@ ### License

@@ -7,3 +7,3 @@ # Security Policy

- Latest stable release
- Latest stable release

@@ -10,0 +10,0 @@ ## Reporting a Vulnerability

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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