Socket
Socket
Sign inDemoInstall

facebook-messenjs

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

facebook-messenjs - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

test.js

2

package.json
{
"name": "facebook-messenjs",
"version": "0.1.1",
"version": "0.1.2",
"description": "API wrapper for Facebook Messenger inspired by discord.js",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -40,3 +40,6 @@ # Facebook MessenJS

Use quick replies:
Create text quick replies:
```js
const { Client, TextQuickReply } = require('facebook-messenjs');
```
``` js

@@ -68,4 +71,5 @@ bot.on('messages', message => {

``` js
const { PostbackButton } = require('facebook-messenjs');
const { Client, PostbackButton } = require('facebook-messenjs');
```
``` js
bot.on('messagingPostback', postback => {

@@ -83,4 +87,5 @@ if (postback.payload === "GET_STARTED") {

``` js
const { BaseAttachment } = require('facebook-messenjs');
const { Client, BaseAttachment } = require('facebook-messenjs');
```
``` js
const picture = new BaseAttachment(bot, "image", {

@@ -87,0 +92,0 @@ content: "./picture.png",

@@ -13,4 +13,4 @@ module.exports = {

ProfileManager: require('./client/ProfileManager'),
QuickReplies: require('./structures/message/quickReplies/QuickReplies'),
TextQuickReply: require('./structures/message/quickReplies/QuickReplies').Text,
Templates: require('./structures/message/template/Templates')
}

@@ -22,2 +22,3 @@ const crypto = require('crypto');

* @param {Object} options - Options for BaseAPI
* @param {boolean} [options.validation] - option for turining off/on webhook validation
* @property {Boolean} validation - If API should only receive calls from Facebook

@@ -58,17 +59,18 @@ */

this.app.post(route, (req, res) => {
if (!("x-hub-signature" in req.headers)) {
sendUnauthorized(res);
return;
}
if (req.body) {
if (this.validation) {
let hubSignature = req.headers["x-hub-signature"];
let expectedSignature = `sha1=${
crypto.createHmac('sha1', this.client.appSecret)
.update(JSON.stringify(req.body))
.digest("hex")
}`;
if (!("x-hub-signature-256" in req.headers)) {
sendUnauthorized(res);
return;
};
let signature = req.headers["x-hub-signature-256"];
let signatureHash = signature.split("=")[1];
let expectedHash = crypto
.createHmac("sha256", this.client.appSecret)
.update(JSON.stringify(req.body))
.digest("hex");
if (hubSignature !== expectedSignature) {
if (signatureHash !== expectedHash) {
sendUnauthorized(res);

@@ -75,0 +77,0 @@ return;

@@ -38,3 +38,3 @@ const fetch = require('make-fetch-happen');

if (options.content.toLowerCase().startsWith("http")) {
this.url = url;
this.url = options.content;

@@ -41,0 +41,0 @@ fetchPostJSON({

class BaseQuickReply {
/**
* @param {String} contentType Type of quick reply (can be text, user_phone_number, or user_email)
* @property {String} contentType Type of quick reply (can be text, user_phone_number, or user_email)
* @param {string} contentType Type of quick reply (can be text, user_phone_number, or user_email)
* @property {string} contentType Type of quick reply (can be text, user_phone_number, or user_email)
*/

@@ -6,0 +6,0 @@ constructor(contentType) {

const BaseQuickReply = require('./BaseQuickReply');
class TextQuickReply extends BaseQuickReply{
class TextQuickReply extends BaseQuickReply {
/**

@@ -5,0 +5,0 @@ * @param {String} title Text in quick reply

@@ -13,5 +13,8 @@ const fetch = require('make-fetch-happen');

* @param {Client} client
* @param {String} id - ID of Profile
* @param {string} id - ID of Profile
* @property {Client} client
* @property {String} id
* @property {string} id
* @property {string} [firstName]
* @property {string} [lastName]
* @property {*} [profilePic]
*/

@@ -18,0 +21,0 @@ constructor(client, id) {

@@ -5,2 +5,17 @@ import { EventEmitter } from "node:events";

export class BaseQuickReply {
public constructor(contentType: string);
public contentType: string;
public getJSON(): object;
}
export class TextQuickReply extends BaseQuickReply {
public constructor(title: string, payload: string, imageURL?: string);
public title: string;
public payload: string;
public imageURL: string;
}
export interface BaseAttachmentTypes {

@@ -7,0 +22,0 @@ IMAGE: "image";

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