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.10.0 to 6.10.1

dist/chunk-KDS6MCMJ.js

2

dist/cli.js
#!/usr/bin/env node
import{b as p}from"./chunk-HTTF6AES.js";import{program as m}from"commander";import E from"get-stdin";import{oraPromise as a}from"ora";var t={spinner:"simpleDotsScrolling"},i=process.env.WHATSAPP_ACCESS_TOKEN,r=process.env.WHATSAPP_PHONE_NUMBER_ID,s=new p;m.name("whatsapp").description("WhatsApp SDK CLI");var d=m.command("media").description("Media");d.command("download").description("Download Media").argument("<MEDIA_URL>","Media URL").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let c=await(await a(()=>s.media.download(n).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Downloading media"})).response.arrayBuffer(),l=Buffer.from(c);process.stdout.write(l)});d.command("delete").description("Delete Media").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.media.delete(n,{phoneNumberID:e.phoneNumberId}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Deleting media"});console.log(await o.json())});d.command("get-url").description("Get Media URL").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.media.getURL(n,{phoneNumberID:e.phoneNumberId}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Getting media URL"});console.log(await o.json())});d.command("upload").description("Upload Media").option("--filename <FILENAME>","Filename").requiredOption("--mime-type <MIME_TYPE>","MIME Type").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async n=>{let e=await E.buffer(),o=new Blob([e],{type:n.mimeType}),c=await a(()=>s.media.upload(o,{phoneNumberID:n.phoneNumberId,mimeType:n.mimeType,filename:n.filename}).send({headers:{Authorization:`Bearer ${n.accessToken}`}}),{...t,text:"Uploading media"});console.log(await c.json())});var A=m.command("message").description("Message"),u=A.command("send");u.command("image").description("Send a media message").argument("<TO_NUMBER>","To Number").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).requiredOption("--media-id <MEDIA_ID>","Media ID").option("--filename <FILENAME>","Filename").option("--caption <CAPTION>","Caption").action(async(n,e)=>{let o=await a(()=>s.message({phoneNumberID:e.phoneNumberId}).image({id:e.mediaId,filename:e.filename,caption:e.caption},{toNumber:n}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Sending image"});console.log(await o.json())});u.command("text").description("Send a text message").argument("<TO_NUMBER>","To Number").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--body <MESSAGE_TEXT_BODY>","Message Body").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.message({phoneNumberID:e.phoneNumberId}).text({body:e.body},{toNumber:n}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Sending text message"});console.log(await o.json())});m.parseAsync();
import{b as p}from"./chunk-KDS6MCMJ.js";import{program as m}from"commander";import E from"get-stdin";import{oraPromise as a}from"ora";var t={spinner:"simpleDotsScrolling"},i=process.env.WHATSAPP_ACCESS_TOKEN,r=process.env.WHATSAPP_PHONE_NUMBER_ID,s=new p;m.name("whatsapp").description("WhatsApp SDK CLI");var d=m.command("media").description("Media");d.command("download").description("Download Media").argument("<MEDIA_URL>","Media URL").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let c=await(await a(()=>s.media.download(n).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Downloading media"})).response.arrayBuffer(),l=Buffer.from(c);process.stdout.write(l)});d.command("delete").description("Delete Media").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.media.delete(n,{phoneNumberID:e.phoneNumberId}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Deleting media"});console.log(await o.json())});d.command("get-url").description("Get Media URL").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.media.getURL(n,{phoneNumberID:e.phoneNumberId}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Getting media URL"});console.log(await o.json())});d.command("upload").description("Upload Media").option("--filename <FILENAME>","Filename").requiredOption("--mime-type <MIME_TYPE>","MIME Type").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async n=>{let e=await E.buffer(),o=new Blob([e],{type:n.mimeType}),c=await a(()=>s.media.upload(o,{phoneNumberID:n.phoneNumberId,mimeType:n.mimeType,filename:n.filename}).send({headers:{Authorization:`Bearer ${n.accessToken}`}}),{...t,text:"Uploading media"});console.log(await c.json())});var A=m.command("message").description("Message"),u=A.command("send");u.command("image").description("Send a media message").argument("<TO_NUMBER>","To Number").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).requiredOption("--media-id <MEDIA_ID>","Media ID").option("--filename <FILENAME>","Filename").option("--caption <CAPTION>","Caption").action(async(n,e)=>{let o=await a(()=>s.message({phoneNumberID:e.phoneNumberId}).image({id:e.mediaId,filename:e.filename,caption:e.caption},{toNumber:n}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Sending image"});console.log(await o.json())});u.command("text").description("Send a text message").argument("<TO_NUMBER>","To Number").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--body <MESSAGE_TEXT_BODY>","Message Body").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.message({phoneNumberID:e.phoneNumberId}).text({body:e.body},{toNumber:n}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Sending text message"});console.log(await o.json())});m.parseAsync();

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

import{a,b,c}from"./chunk-HTTF6AES.js";export{b as CloudAPI,c as IncomingMessageType,a as OutgoingMessageType,b as default};
import{a,b,c}from"./chunk-KDS6MCMJ.js";export{b as CloudAPI,c as IncomingMessageType,a as OutgoingMessageType,b as default};
{
"name": "@great-detail/whatsapp",
"version": "6.10.0",
"version": "6.10.1",
"type": "module",

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

@@ -24,3 +24,3 @@ /**

// Assert
expect(graphRequest.url).toBe(
expect(graphRequest.request.url).toBe(
`https://graph.facebook.com/v19.0${endpoint}`,

@@ -38,3 +38,3 @@ );

// Assert
expect(graphRequest.url).toBe(
expect(graphRequest.request.url).toBe(
`https://graph.facebook.com/v19.0${endpoint}`,

@@ -53,3 +53,3 @@ );

// Assert
expect(graphRequest.url).toBe(
expect(graphRequest.request.url).toBe(
`https://graph.facebook.com/${version}/path/to/something`,

@@ -68,3 +68,3 @@ );

// Assert
expect(graphRequest.url).toBe(`${baseUrl}/v19.0${endpoint}`);
expect(graphRequest.request.url).toBe(`${baseUrl}/v19.0${endpoint}`);
});

@@ -84,3 +84,3 @@

// Assert
expect(graphRequest.headers.get(headerName)).toBe(headerValue);
expect(graphRequest.request.headers.get(headerName)).toBe(headerValue);
});

@@ -106,3 +106,6 @@ });

expect(mockFetch).toHaveBeenCalled();
expect(mockFetch).toHaveBeenCalledWith(graphRequest.url, graphRequest);
expect(mockFetch).toHaveBeenCalledWith(
graphRequest.request.url,
graphRequest.request,
);
expect(responseText).toBe(body);

@@ -136,7 +139,9 @@ expect(response.request).toBe(graphRequest);

expect(response.request).toBe(graphRequest);
expect(response.request?.headers.get("Content-Type")).toBe(
expect(response.request?.request.headers.get("Content-Type")).toBe(
"application/xml",
);
expect(response.request?.headers.get("x-will-merge")).toBe("willMerge");
expect(response.request?.headers.get("x-will-also-merge")).toBe(
expect(response.request?.request.headers.get("x-will-merge")).toBe(
"willMerge",
);
expect(response.request?.request.headers.get("x-will-also-merge")).toBe(
"willAlsoMerge",

@@ -143,0 +148,0 @@ );

@@ -52,3 +52,3 @@ /**

*/
export default class GraphRequest<T = unknown> extends Request {
export default class GraphRequest<T = unknown> {
/**

@@ -74,2 +74,3 @@ * Default base URL for the Facebook Graph API.

public readonly version?: string;
public request: Request;

@@ -80,5 +81,4 @@ public constructor(

) {
super(url, requestInit);
this.request = new Request(url, requestInit);
this.version = version;
logger?.http(`${url.toString()} ${JSON.stringify(requestInit)}`);

@@ -116,3 +116,3 @@ }

for (const [key, value] of parsedHeaders) {
this.headers.set(key, value);
this.request.headers.set(key, value);
}

@@ -122,3 +122,3 @@ }

// See: https://github.com/node-fetch/node-fetch/issues/481#issuecomment-592491825
return await fetchAlternative(this.url, this).then(
return await fetchAlternative(this.request.url, this.request).then(
(response) => new GraphResponse(response, { request: this }),

@@ -125,0 +125,0 @@ );

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 too big to display

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