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

whatsapp-api-js

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whatsapp-api-js - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

2

package.json
{
"name": "whatsapp-api-js",
"version": "0.2.2",
"version": "0.2.3",
"description": "A Whatsapp Official API helper for Node.js",

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

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

* @returns {String} The challenge string, it must be the http response body
* @throws {Number} 400 if the request is missing data
* @throws {Number} 403 if the verification tokens don't match

@@ -28,2 +29,5 @@ */

}
// Responds with "400 Bad Request" if it's missing data
throw 400;
}

@@ -30,0 +34,0 @@

@@ -18,3 +18,3 @@ const Text = require("./text");

* @param {(String|Language)} language The code of the language or locale to use. Accepts both language and language_locale formats (e.g., en and en_US).
* @param {...(HeaderComponent|BodyComponent|ButtonComponent)} components Components objects containing the parameters of the message. For text-based templates, the only supported component is BodyComponent.
* @param {...(HeaderComponent|BodyComponent|ButtonComponent)} [components] Components objects containing the parameters of the message. For text-based templates, the only supported component is BodyComponent.
* @throws {Error} If name is not provided

@@ -29,3 +29,3 @@ * @throws {Error} If language is not provided

this.language = language instanceof Language ? language : new Language(language);
if (components) this.components = components.map(c => c.build ? c.build() : c).flat();;
if (components) this.components = components.map(c => typeof c.build === "function" ? c.build() : c).flat();

@@ -47,3 +47,3 @@ this._ = "template";

* @param {String} code The code of the language or locale to use. Accepts both language and language_locale formats (e.g., en and en_US).
* @param {String} policy The language policy the message should follow. The only supported option is 'deterministic'. The variable isn't even read by my code :)
* @param {String} [policy] The language policy the message should follow. The only supported option is 'deterministic'. The variable isn't even read by my code :)
* @throws {Error} If code is not provided

@@ -171,3 +171,3 @@ */

if (!param) throw new Error("UrlButton must have a param");
if (!["text", "payload"].includes(type)) throw new Error("UrlButton must be either 'text' or 'payload'");
if (!["text", "payload"].includes(type)) throw new Error("UrlButton type must be either 'text' or 'payload'");

@@ -189,3 +189,3 @@ this.type = type;

*
* @param {...(Text|Currency|DateTime|Image|Document|Video|Parameter)} parameters Parameters of the body component
* @param {...(Text|Currency|DateTime|Image|Document|Video|Parameter)} [parameters] Parameters of the body component
*/

@@ -208,3 +208,3 @@ constructor(...parameters) {

*
* @param {...(Text|Currency|DateTime|Image|Document|Video|Parameter)} parameters Parameters of the body component
* @param {...(Text|Currency|DateTime|Image|Document|Video|Parameter)} [parameters] Parameters of the body component
*/

@@ -235,3 +235,3 @@ constructor(...parameters) {

* @param {(Text|Currency|DateTime|Image|Document|Video)} parameter The parameter to be used in the template
* @param {String} whoami The parent component, used to check if a Text object is too long. Can be either 'header' or 'body'
* @param {String} [whoami] The parent component, used to check if a Text object is too long. Can be either 'header' or 'body'
* @throws {Error} If parameter is not provided

@@ -242,3 +242,3 @@ * @throws {Error} If parameter is a Text and the parent component (whoami) is "header" and the text over 60 characters

constructor(parameter, whoami) {
if (!parameter) throw new Error("Parameter object must have a parameter parameter");
if (!parameter) throw new Error("Parameter object must have a parameter parameter :)");
this.type = parameter._;

@@ -249,6 +249,6 @@ delete parameter._;

if (this.type === "text") {
if (whoami === "header" && object.body > 60) throw new Error("Header text must be 60 characters or less");
if (whoami === "body" && object.body > 1024) throw new Error("Body text must be 1024 characters or less");
this[this.type] = object.body;
} else this[this.type] = object;
if (whoami === "header" && parameter.body > 60) throw new Error("Header text must be 60 characters or less");
if (whoami === "body" && parameter.body > 1024) throw new Error("Body text must be 1024 characters or less");
this[this.type] = parameter.body;
} else this[this.type] = parameter;
}

@@ -255,0 +255,0 @@ }

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