@apostlejs/whatsapp 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2025] [Fernando Coelho]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e=require("zod");function t(e){return e&&e.__esModule?e:{default:e}}var a=t(require("node:crypto")),r=Object.defineProperty,n=(e,t)=>{for(var a in t)r(e,a,{get:t[a],enumerable:!0})},o={create:{url:"/{waba_id}/flows",method:"post",headers:{"Content-Type":"application/json"},request:{body:null},response:null},updateMetadata:{url:"/{flow_id}",method:"post",headers:{"Content-Type":"application/json"},request:{body:null},response:null},readMany:{url:"/{waba_id}/flows",method:"get",response:null},delete:{url:"/{flow_id}",method:"delete",response:null},read:{url:"/{flow_id}",method:"get",request:{query:null},response:null},updateJson:{url:"/{flow_id}/assets",method:"post",request:{body:null},response:null},getPreview:{url:"/{flow_id}?fields=preview.invalidate(false)",method:"get",response:null},publish:{url:"/{flow_id}/publish",method:"post",response:null}},s={send:{url:"/{number_id}/messages",method:"post",headers:{"Content-Type":"application/json"},request:{body:null},response:null}},i={updateEncryption:{url:"/{number_id}/whatsapp_business_encryption",method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},request:{body:null}},registerNumber:{url:"/{number_id}/register",method:"post",headers:{"Content-Type":"application/json"},request:{body:null}}},c={flows:o,messages:s,waba:i},l=e.z.enum(["INIT","BACK","data_exchange","navigate","ping"]),p=e.z.enum(["SIGN_UP","SIGN_IN","APPOINTMENT_BOOKING","LEAD_GENERATION","CONTACT_US","CUSTOMER_SUPPORT","SURVEY","OTHER"]),u=e.z.object({media_id:e.z.string(),cdn_url:e.z.string(),file_name:e.z.string(),encryption_metadata:e.z.object({encrypted_hash:e.z.string(),iv:e.z.string(),encryption_key:e.z.string(),hmac_key:e.z.string(),plaintext_hash:e.z.string()})}),d=e.z.object({name:e.z.string(),categories:e.z.array(p),application_id:e.z.string().optional(),endpoint_uri:e.z.string().optional()}),f=e.z.union([e.z.literal("SUCCESS"),e.z.string()]),m=e.z.enum(["DRAFT","PUBLISHED","DEPRECATED","BLOCKED","THROTTLED"]),y=e.z.enum(["AVAILABLE","LIMITED","BLOCKED"]),_=e.z.object({error:e.z.string(),error_type:e.z.string(),message:e.z.string(),line_start:e.z.number(),line_end:e.z.number(),column_start:e.z.number(),column_end:e.z.number()}),h={},w={setup:e=>{Object.assign(h,e)},get:e=>{const t=h[e]??process.env[e];if(!t)throw new Error(`Missing environment variable: ${e}`);return t}},g={};n(g,{actions:()=>H,flows:()=>U,parsers:()=>q,security:()=>K,utils:()=>j});var b={};async function v(e,t,a){const r=`https://graph.facebook.com/v${w.get("GRAPH_API_VERSION")}`,n={Authorization:`Bearer ${w.get("META_APP_ACCESS_TOKEN")}`};let o=e.url;const s={...n,...e.headers,...t.headers},i=new URLSearchParams(t.query).toString();"/"===o[0]&&(o=o.slice(1)),o=`${r}/${o}`,i&&(o=`${o}?${i}`);const c={waba_id:w.get("WHATSAPP_ACCOUNT_ID"),number_id:w.get("WHATSAPP_NUMBER_ID"),...t.params};for(const e in c)o=o.replace(`{${e}}`,c[e]);const l=t.body;let p;if(l&&a?.asFormData){const e=new FormData;for(const t in l)e.append(t,l[t]);p=e}else l&&a?.asUrlEncoded?p=new URLSearchParams(l).toString():l&&(p=JSON.stringify(l));return await fetch(o,{method:e.method,headers:s,body:p}).then((e=>e.json())).then((e=>{if("error"in e)throw{response:{data:e.error}};return e})).catch((async e=>{throw e.response.data}))}async function E(e){return v(c.flows.create,{body:e})}async function S(e,t){const a=c.flows.updateMetadata;return await v(a,{body:t,params:{flow_id:e}})}async function A(e,t){return v(c.flows.updateJson,{params:{flow_id:e},body:{name:"flow.json",asset_type:"FLOW_JSON",file:new Blob([JSON.stringify(t,null,2)],{type:"application/json"})}},{asFormData:!0})}async function I(e,t){const a=c.flows.getPreview,{preview:r}=await v(a,{params:{flow_id:e}}),n=r.preview_url.replaceAll("\\",""),o=Object.entries(t??{}).reduce(((e,[t,a])=>(e[t]="flow_action_payload"===t?encodeURIComponent(JSON.stringify(a)):a.toString(),e)),{});return`${n}&${new URLSearchParams(o).toString()}`}async function P(e){return v(c.flows.delete,{params:{flow_id:e}})}async function N(e,t){return v(c.flows.read,{params:{flow_id:e},query:{fields:t?.fields.join(",")??""}})}async function T(){return v(c.flows.readMany,{})}async function x(e){return v(c.flows.publish,{params:{flow_id:e}})}n(b,{create:()=>E,delete:()=>P,get:()=>N,getMany:()=>T,getPreview:()=>I,publish:()=>x,updateJson:()=>A,updateMetadata:()=>S});var C={};async function O(e){const t=w.get("WHATSAPP_UNNOFICIAL_AUTHENTICATION_STRING"),a=await async function(e){const t=w.get("WHATSAPP_UNNOFICIAL_AUTHENTICATION_STRING");return await fetch("https://business.facebook.com/latest/whatsapp_manager/flows?flow_id="+e,{headers:{accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8","accept-language":"en-US,en;q=0.5","cache-control":"no-cache",pragma:"no-cache",priority:"u=0, i","sec-ch-ua":'"Brave";v="131", "Chromium";v="131", "Not_A Brand";v="24"',"sec-ch-ua-full-version-list":'"Brave";v="131.0.0.0", "Chromium";v="131.0.0.0", "Not_A Brand";v="24.0.0.0"',"sec-ch-ua-mobile":"?0","sec-ch-ua-model":'""',"sec-ch-ua-platform":'"Linux"',"sec-ch-ua-platform-version":'"6.11.9"',"sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"same-origin","sec-fetch-user":"?1","sec-gpc":"1","upgrade-insecure-requests":"1",cookie:t},referrerPolicy:"strict-origin-when-cross-origin",body:null,method:"GET"}).then((e=>e.text())).then((e=>{const t=/<script\b[^>]*\bid=["']__eqmc["'][^>]*>(.*?)<\/script>/is.exec(e);if(!t)throw new Error("No matching <script> tag found.");const{f:a}=JSON.parse(t[1]);return a}))}(e),r={__aaid:"0",__bid:"250887754468924",__user:"100072333227027",__a:"1",__req:"m",dpr:"1",__ccg:"EXCELLENT",__rev:"1019090278",__comet_req:"11",fb_dtsg:a,__spin_b:"trunk",__jssesw:"1",fb_api_caller_class:"RelayModern",fb_api_req_friendly_name:"WAMFlowsBuilderDynamicSetupHealthCheckQuery",variables:JSON.stringify({flowID:e}),server_timestamps:"true",doc_id:" 7983200618385332"},n=new URLSearchParams(r).toString();return await fetch("https://business.facebook.com/api/graphql",{headers:{accept:"*/*","accept-language":"en-US,en;q=0.5","cache-control":"no-cache","content-type":"application/x-www-form-urlencoded",pragma:"no-cache",priority:"u=1, i","sec-ch-ua":'"Brave";v="131", "Chromium";v="131", "Not_A Brand";v="24"',"sec-ch-ua-full-version-list":'"Brave";v="131.0.0.0", "Chromium";v="131.0.0.0", "Not_A Brand";v="24.0.0.0"',"sec-ch-ua-mobile":"?0","sec-ch-ua-model":'""',"sec-ch-ua-platform":'"Linux"',"sec-ch-ua-platform-version":'"6.11.9"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","sec-gpc":"1","x-fb-friendly-name":"WAMFlowsBuilderDynamicSetupHealthCheckQuery",cookie:t,Referer:"https://business.facebook.com/latest/whatsapp_manager/flows?flow_id=1137578314629992","Referrer-Policy":"strict-origin-when-cross-origin"},body:n,method:"POST"}).then((e=>e.text())).then((e=>e)).catch((e=>{console.error(e)}))}n(C,{verifyFlowIntegrity:()=>O});var B=e=>e.split("?")[0],U={createToken:({flow_name:e,flow_parameters:t,chatId:a})=>{const r=new URLSearchParams({chat_id:a});if(r.set("flow_identifier",crypto.randomUUID()),t)for(const[e,a]of Object.entries(t))r.set(e,a.toString());return`${e}?${decodeURIComponent(r.toString())}`},getName:B,destructureFlowToken:e=>{const t=B(e);let a=e.split("?")?.[1];"&"===a?.[0]&&(a=a.slice(1));const r=new URLSearchParams(a),n=r.get("chat_id")||r.get("chatId"),o=r.get("flow_identifier")||r.get("flowIdentifier"),s={};for(const[e,t]of r.entries())"chat_id"!==e&&"chatId"!==e&&"flow_identifier"!==e&&"flowIdentifier"!==e&&(s[e]=t);return{paramsString:a,flowName:t,chatId:n,flowIdentifier:o,flowParameters:s}}},R=e=>{const t={to:e.to,messaging_product:"whatsapp",recipient_type:"individual"};return e.reply&&(t.context=e.reply),e.showUrlPreviewImage&&(t.preview_url=e.showUrlPreviewImage),t},k={flow:e=>{if("flow"!==e.message.type)throw new Error("Invalid type");const{message:t,...a}=e,{flow:r,...n}=t,o=R(a);r.mode||(r.mode=w.get("WHATSAPP_FLOWS_MODE"));const s=U.createToken({chatId:o.to,flow_name:r.name,flow_parameters:r.parameters});return{type:"interactive",...o,interactive:{...n,type:"flow",action:{name:"flow",parameters:{flow_name:r.name,flow_token:s,flow_message_version:"3",flow_cta:r.buttonText,flow_action:r.action??"navigate",mode:r.mode,...r.payload&&{flow_action_payload:{...r.payload,screen:r.payload.screen.toUpperCase()}}}}}}},text:e=>{if("text"!==e.message.type)throw new Error("Invalid type");const{message:t,...a}=e,r=R(a),n={type:"text",text:{body:t.text},...r};return e.message.previewUrl&&n.text&&(n.text.preview_url=e.message.previewUrl),n},list:e=>{if("list"!==e.message.type)throw new Error("Invalid type");const{message:t,...a}=e,{list:r,type:n,...o}=t;return{...R(a),type:"interactive",interactive:{...o,type:n,action:{button:r.buttonText,sections:r.sections}}}},button:e=>{if("button"!==e.message.type)throw new Error("Invalid type");const{message:t,...a}=e,{buttons:r,type:n,...o}=t;return{...R(a),type:"interactive",interactive:{...o,type:n,action:{buttons:r.map((e=>({id:e.id,title:e.text,type:"reply"})))}}}},template:e=>{if("template"!==e.message.type)throw new Error("Invalid type");const{message:{type:t,...a},...r}=e,n={...R(r),type:t,template:{...a,language:{code:a.language}}};return n.template&&(n.template.namespace=process.env.WHATSAPP_MESSAGE_NAMESPACE),n},media:e=>{if("media"!==e.message.type)throw new Error("Invalid type");const{message:{type:t,...a},...r}=e,n=Object.entries(a)[0],[o,{ref:s,...i}]=n,c=i,l=R(r);return Number.isNaN(Number(s))?c.link=s:c.id=s,{type:o,[o]:c,...l}}};function z(e){const{encrypted_aes_key:t,encrypted_flow_data:r,initial_vector:n}=e,o=a.default.createPrivateKey({key:w.get("WHATSAPP_ACCOUNT_ENCRYPTION_PRIVATE_KEY"),passphrase:w.get("WHATSAPP_ACCOUNT_ENCRYPTION_PASSPHRASE")}),s=a.default.privateDecrypt({key:o,padding:a.default.constants.RSA_PKCS1_OAEP_PADDING,oaepHash:"sha256"},Buffer.from(t,"base64")),i=Buffer.from(r,"base64"),c=Buffer.from(n,"base64"),l=i.subarray(0,-16),p=i.subarray(-16),u=a.default.createDecipheriv("aes-128-gcm",s,c);u.setAuthTag(p);const d=Buffer.concat([u.update(l),u.final()]).toString("utf-8");return{payload:JSON.parse(d),encryptionMetadata:{aesKeyBuffer:s,initialVectorBuffer:c}}}function M(e){const t=new URL(e.url).searchParams,a=t.get("hub.verify_token"),r=t.get("hub.challenge");return!(!a||!r)&&a===w.get("WHATSAPP_WEBHOOK_KEY")&&r}async function D(e,t){const r=e.headers.get("x-hub-signature-256");if(!r)return!1;const n=r.replace("sha256=",""),o=a.default.createHmac("sha256",w.get("WHATSAPP_WEBHOOK_KEY")).update(t,"utf-8").digest("hex");return!!a.default.timingSafeEqual(Buffer.from(n),Buffer.from(o))}var q={toGraph:{sendMessage:e=>k[e.message.type](e),flowResponse:(e,t)=>{if(!t.data)throw new Error("Missing data in flow response");if(!t.screen)throw new Error("Missing screen in flow response");if(t.screen=t.screen.toUpperCase(),"SUCCESS"===t.screen){const a=t.data??{};t.data={extension_message_response:{params:{flow_token:e,...a}}}}return t}},toSDK:{webhook:async function(e){if("GET"===e.method){const t=M(e);if(!t)throw new Error("Invalid request");return{type:"healthCheck",payload:t}}const t=await e.text(),a=JSON.parse(t);if("entry"in a){if(!D(e,t))throw new Error("Invalid request");const n=a.entry.flatMap((e=>e.changes)).filter((e=>"messages"===e.field)).flatMap((e=>e.value.messages)).filter(Boolean).map((e=>function(e){const t=e.from,a={id:e.id,type:e.type,timestamp:e.timestamp,metadata:{forwarded:e.context?.forwarded,frequentlyForwarded:e.context?.frequently_forwarded}},r=function(e){if(!(e.audio||e.document||e.video||e.image))return null;const t=e.audio?.id??e.document?.id??e.image?.id??e.video?.id,a=e.audio?.mime_type??e.document?.mime_type??e.image?.mime_type??e.video?.mime_type,r=["audio","document","image","video"].find((t=>e[t])),n=e.image?.sha256??e.document?.sha256??e.video?.sha256;return{id:t,type:r,caption:e.document?.caption??e.image?.caption??e.video?.caption??null,mime_type:a,sha256:n,filename:e.document?.filename??e.video?.filename}}(e),n=function(e){return e.text?.body??e.button?.text??e.interactive?.button_reply?.title??e.interactive?.list_reply?.title??e.document?.caption??null}(e),o=function(e){return e.interactive?{...e.interactive?.button_reply||e.button?{button:{id:e.interactive?.button_reply?.id??null,title:e.button?.text??e.interactive.button_reply?.title,payload:e.button?.payload??null}}:{},...e.interactive.list_reply?{selectedOption:{id:e.interactive.list_reply.id,title:e.interactive.list_reply.title,description:e.interactive.list_reply.description}}:{},...e.interactive.nfm_reply?{flowResponse:JSON.parse(e.interactive.nfm_reply.response_json)}:{}}:null}(e);return{...a,...o&&{interaction:o},...r&&{media:r},text:n,chatId:t}}(e)));return{type:"application",payload:{messageReceived:(r=n,r.length?r:void 0)}}}var r;if("encrypted_flow_data"in a)return{type:"flowExchange",payload:{...z(a),pingResponse:{data:{status:"active"}}}};throw new Error("Invalid request")}}},H={messages:{send:async function(e){const t=q.toGraph.sendMessage(e),a=c.messages.send;return await v(a,{body:t})}},flows:{...b,unnoficial:C},waba:{registerNumber:async function({dataRegion:e,pin:t}){const a=c.waba.registerNumber,r={messaging_product:"whatsapp",pin:t};return e&&(r.data_localization_region=e),await v(a,{body:r},{asUrlEncoded:!0})},encryption:{upload:async function(e){const t=c.waba.updateEncryption,a={business_public_key:e};return await v(t,{body:a},{asUrlEncoded:!0})}}}};async function L(e){return await fetch(e).then((async e=>{const t=await e.arrayBuffer();return Buffer.from(t)}))}var K={verifyHub:M,verifySignature:D,generateWabaEncryption:async function(){const e=a.default.randomUUID(),{publicKey:t,privateKey:r}=a.default.generateKeyPairSync("rsa",{modulusLength:2048,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem",cipher:"aes-256-cbc",passphrase:e}});return{passphrase:e,publicKey:t,privateKey:r}},decryptFlowBody:z,encryptFlowResponse:function(e,t){const r=[];for(const e of Buffer.from(t.initialVectorBuffer).entries())r.push(~e[1]);const n=a.default.createCipheriv("aes-128-gcm",Buffer.from(t.aesKeyBuffer),Buffer.from(r));return Buffer.concat([n.update(JSON.stringify(e),"utf-8"),n.final(),n.getAuthTag()]).toString("base64")},decryptFlowMedia:async function(e){const t=[];for(const r of e){let{cdn_url:e,encryption_metadata:n}=r;if("EXAMPLE_DATA__CDN_URL_WILL_COME_IN_THIS_FIELD"===e){e="https://picsum.photos/seed/picsum/200";const a=await L(e);t.push(a);continue}const o=await L(e),{iv:s,encryption_key:i,hmac_key:c,encrypted_hash:l,plaintext_hash:p}=n,u={iv:Buffer.from(s,"base64"),encryption_key:Buffer.from(i,"base64"),hmac_key:Buffer.from(c,"base64")};if(a.default.createHash("sha256").update(o).digest("base64")!==l)throw new Error("Encrypted hash validation failed");const d=o.subarray(0,o.length-10),f=o.subarray(-10);if(!a.default.createHmac("sha256",u.hmac_key).update(Buffer.concat([u.iv,d])).digest().subarray(0,10).equals(f))throw new Error("HMAC validation failed");const m=a.default.createDecipheriv("aes-256-cbc",u.encryption_key,u.iv),y=m.update(d),_=Buffer.concat([y,m.final()]);if(a.default.createHash("sha256").update(_).digest("base64")!==p)throw new Error("Decrypted media hash validation failed");t.push(_)}return t}},j={flows:U},W={graph:{endpoints:c},settings:w,sdk:g};exports.actions=H,exports.endpoints=c,exports.flowAction=l,exports.flowCanSendMessageStatus=y,exports.flowCategory=p,exports.flowMediaData=u,exports.flowMetadata=d,exports.flowScreen=f,exports.flowStatus=m,exports.flowValidationError=_,exports.flows=U,exports.flowsEndpoints=o,exports.messagesEndpoints=s,exports.parsers=q,exports.security=K,exports.utils=j,exports.wabaEndpoints=i,exports.whatsapp=W;
@@ -0,0 +1,1185 @@
1
+ import { z } from 'zod';
2
+
3
+ type WhatsappSDKSettings = {
4
+ GRAPH_API_VERSION: string;
5
+ META_APP_ACCESS_TOKEN: string;
6
+ META_APP_ID: string;
7
+ META_APP_SECRET: string;
8
+ WHATSAPP_MESSAGE_NAMESPACE: string;
9
+ WHATSAPP_WEBHOOK_KEY: string;
10
+ WHATSAPP_NUMBER_ID: string;
11
+ WHATSAPP_ACCOUNT_ID: string;
12
+ WHATSAPP_ACCOUNT_ENCRYPTION_PUBLIC_KEY: string;
13
+ WHATSAPP_ACCOUNT_ENCRYPTION_PRIVATE_KEY: string;
14
+ WHATSAPP_ACCOUNT_ENCRYPTION_PASSPHRASE: string;
15
+ WHATSAPP_FLOWS_MODE: string;
16
+ WHATSAPP_UNNOFICIAL_AUTHENTICATION_STRING: string;
17
+ };
18
+
19
+ type AnyType = any;
20
+ type Defined<T> = Exclude<T, undefined>;
21
+
22
+ type HttpMethod = "get" | "post" | "put" | "delete" | "patch";
23
+ type RequestData = Record<string, AnyType>;
24
+ type IRequest = {
25
+ body?: RequestData;
26
+ query?: RequestData;
27
+ headers?: RequestData;
28
+ };
29
+ type IResponse = AnyType;
30
+ type Endpoint<Url extends string, Method extends HttpMethod, Req extends IRequest, Res extends IResponse = AnyType> = {
31
+ url: Url;
32
+ method: Method;
33
+ headers?: RequestData;
34
+ request?: Req;
35
+ response?: Res;
36
+ };
37
+
38
+ declare const endpoints: {
39
+ flows: {
40
+ create: Endpoint<"/{waba_id}/flows", "post", {
41
+ body: WhatsappCreateFlowRequestBody;
42
+ }, WhatsappCreateFlowResponse>;
43
+ updateMetadata: Endpoint<"/{flow_id}", "post", {
44
+ body: WhatsappFlowUpdateMetadataRequestBody;
45
+ }, WhatsappFlowUpdateMetadataResponse>;
46
+ readMany: Endpoint<"/{waba_id}/flows", "get", IRequest, WhatsappGetManyFlowsRequestResponse>;
47
+ delete: Endpoint<"/{flow_id}", "delete", IRequest, WhatsappDeleteFlowResponse>;
48
+ read: Endpoint<"/{flow_id}", "get", {
49
+ query: WhatsappGetFlowsRequestQuery;
50
+ }, WhatsappGetManyFlowsRequestResponse>;
51
+ updateJson: Endpoint<"/{flow_id}/assets", "post", {
52
+ body: WhatsappUpdateFlowJsonRequestBody;
53
+ }, WhatsappUpdateFlowJsonResponse>;
54
+ getPreview: Endpoint<"/{flow_id}?fields=preview.invalidate(false)", "get", IRequest, WhatsappGetFlowWebPreviewURLResponse>;
55
+ publish: Endpoint<"/{flow_id}/publish", "post", IRequest, WhatsappPublishFlowResponse>;
56
+ };
57
+ messages: {
58
+ send: Endpoint<"/{number_id}/messages", "post", {
59
+ body: WhatsappSendMessageRequestBody<any>;
60
+ }, WhatsappSendMessageResponse>;
61
+ };
62
+ waba: {
63
+ updateEncryption: Endpoint<"/{number_id}/whatsapp_business_encryption", "post", {
64
+ body: WhatsappWabaUploadEncryptionRequestBody;
65
+ }, unknown>;
66
+ registerNumber: Endpoint<"/{number_id}/register", "post", {
67
+ body: WhatsappRegisterPhoneNumberRequestBody;
68
+ }, unknown>;
69
+ };
70
+ };
71
+
72
+ declare const flowCategory: z.ZodEnum<["SIGN_UP", "SIGN_IN", "APPOINTMENT_BOOKING", "LEAD_GENERATION", "CONTACT_US", "CUSTOMER_SUPPORT", "SURVEY", "OTHER"]>;
73
+ type FlowCategory = z.infer<typeof flowCategory>;
74
+
75
+ type WhatsappCreateFlowRequestBody = {
76
+ name: string;
77
+ categories: FlowCategory[];
78
+ clone_flow_id?: string;
79
+ endpoint_uri?: string;
80
+ flow_json?: string;
81
+ publish?: boolean;
82
+ };
83
+ type WhatsappCreateFlowResponse = {
84
+ id: string;
85
+ };
86
+
87
+ type WhatsappDeleteFlowResponse = {
88
+ success: boolean;
89
+ };
90
+
91
+ declare const flowStatus: z.ZodEnum<["DRAFT", "PUBLISHED", "DEPRECATED", "BLOCKED", "THROTTLED"]>;
92
+ type FlowStatus = z.infer<typeof flowStatus>;
93
+ declare const flowCanSendMessageStatus: z.ZodEnum<["AVAILABLE", "LIMITED", "BLOCKED"]>;
94
+ type FlowCanSendMessageStatus = z.infer<typeof flowCanSendMessageStatus>;
95
+
96
+ declare const flowValidationError: z.ZodObject<{
97
+ error: z.ZodString;
98
+ error_type: z.ZodString;
99
+ message: z.ZodString;
100
+ line_start: z.ZodNumber;
101
+ line_end: z.ZodNumber;
102
+ column_start: z.ZodNumber;
103
+ column_end: z.ZodNumber;
104
+ }, "strip", z.ZodTypeAny, {
105
+ message: string;
106
+ error: string;
107
+ error_type: string;
108
+ line_start: number;
109
+ line_end: number;
110
+ column_start: number;
111
+ column_end: number;
112
+ }, {
113
+ message: string;
114
+ error: string;
115
+ error_type: string;
116
+ line_start: number;
117
+ line_end: number;
118
+ column_start: number;
119
+ column_end: number;
120
+ }>;
121
+ type FlowValidationError = z.infer<typeof flowValidationError>;
122
+
123
+ type WhatsappGetManyFlowsRequestResponse = {
124
+ data: Array<{
125
+ id: string;
126
+ name: string;
127
+ status: FlowStatus;
128
+ categories: FlowCategory[];
129
+ validation_errors: FlowValidationError[];
130
+ }>;
131
+ paging: {
132
+ cursors: {
133
+ before: string;
134
+ after: string;
135
+ };
136
+ };
137
+ };
138
+
139
+ type WhatsappGetFlowWebPreviewPageRequestQuery = {
140
+ flow_token: string;
141
+ flow_action: "data_exchange" | "navigate";
142
+ phone_number: string;
143
+ flow_action_payload?: {
144
+ screen: string;
145
+ data: Record<string, AnyType>;
146
+ };
147
+ interactive?: boolean;
148
+ };
149
+ type WhatsappGetFlowWebPreviewURLResponse = {
150
+ id: string;
151
+ preview: {
152
+ preview_url: string;
153
+ expires_at: string;
154
+ };
155
+ };
156
+
157
+ type WhatsappGetFlowsRequestQuery = {
158
+ fields: string;
159
+ };
160
+ type WhatsappGetFlowsRequestResponse = {
161
+ id: string;
162
+ name: string;
163
+ status: FlowStatus;
164
+ categories: FlowCategory[];
165
+ validation_errors: FlowValidationError[];
166
+ json_version: string;
167
+ data_api_version: string;
168
+ endpoint_uri: string;
169
+ preview: WhatsappGetFlowWebPreviewURLResponse;
170
+ whatsapp_business_account: AnyType;
171
+ application: AnyType;
172
+ health_status: {
173
+ can_send_message: FlowCanSendMessageStatus;
174
+ };
175
+ };
176
+
177
+ type WhatsappPublishFlowResponse = {
178
+ success: boolean;
179
+ };
180
+
181
+ type WhatsappUpdateFlowJsonRequestBody = {
182
+ name: "flow.json";
183
+ asset_type: "FLOW_JSON";
184
+ file: AnyType;
185
+ };
186
+ type WhatsappUpdateFlowJsonResponse = {
187
+ success: boolean;
188
+ validation_errors: FlowValidationError[];
189
+ };
190
+
191
+ type WhatsappFlowUpdateMetadataRequestBody = {
192
+ name?: string;
193
+ categories?: FlowCategory[];
194
+ endpoint_uri?: string;
195
+ application_id?: string;
196
+ };
197
+ type WhatsappFlowUpdateMetadataResponse = {
198
+ success: boolean;
199
+ };
200
+
201
+ declare const flowsEndpoints: {
202
+ create: Endpoint<"/{waba_id}/flows", "post", {
203
+ body: WhatsappCreateFlowRequestBody;
204
+ }, WhatsappCreateFlowResponse>;
205
+ updateMetadata: Endpoint<"/{flow_id}", "post", {
206
+ body: WhatsappFlowUpdateMetadataRequestBody;
207
+ }, WhatsappFlowUpdateMetadataResponse>;
208
+ readMany: Endpoint<"/{waba_id}/flows", "get", IRequest, WhatsappGetManyFlowsRequestResponse>;
209
+ delete: Endpoint<"/{flow_id}", "delete", IRequest, WhatsappDeleteFlowResponse>;
210
+ read: Endpoint<"/{flow_id}", "get", {
211
+ query: WhatsappGetFlowsRequestQuery;
212
+ }, WhatsappGetManyFlowsRequestResponse>;
213
+ updateJson: Endpoint<"/{flow_id}/assets", "post", {
214
+ body: WhatsappUpdateFlowJsonRequestBody;
215
+ }, WhatsappUpdateFlowJsonResponse>;
216
+ getPreview: Endpoint<"/{flow_id}?fields=preview.invalidate(false)", "get", IRequest, WhatsappGetFlowWebPreviewURLResponse>;
217
+ publish: Endpoint<"/{flow_id}/publish", "post", IRequest, WhatsappPublishFlowResponse>;
218
+ };
219
+
220
+ declare const flowAction: z.ZodEnum<["INIT", "BACK", "data_exchange", "navigate", "ping"]>;
221
+ type FlowAction = z.infer<typeof flowAction>;
222
+
223
+ type FlowData<K extends string = string> = Record<K, AnyType>;
224
+
225
+ declare const flowMediaData: z.ZodObject<{
226
+ media_id: z.ZodString;
227
+ cdn_url: z.ZodString;
228
+ file_name: z.ZodString;
229
+ encryption_metadata: z.ZodObject<{
230
+ encrypted_hash: z.ZodString;
231
+ iv: z.ZodString;
232
+ encryption_key: z.ZodString;
233
+ hmac_key: z.ZodString;
234
+ plaintext_hash: z.ZodString;
235
+ }, "strip", z.ZodTypeAny, {
236
+ encrypted_hash: string;
237
+ iv: string;
238
+ encryption_key: string;
239
+ hmac_key: string;
240
+ plaintext_hash: string;
241
+ }, {
242
+ encrypted_hash: string;
243
+ iv: string;
244
+ encryption_key: string;
245
+ hmac_key: string;
246
+ plaintext_hash: string;
247
+ }>;
248
+ }, "strip", z.ZodTypeAny, {
249
+ media_id: string;
250
+ cdn_url: string;
251
+ file_name: string;
252
+ encryption_metadata: {
253
+ encrypted_hash: string;
254
+ iv: string;
255
+ encryption_key: string;
256
+ hmac_key: string;
257
+ plaintext_hash: string;
258
+ };
259
+ }, {
260
+ media_id: string;
261
+ cdn_url: string;
262
+ file_name: string;
263
+ encryption_metadata: {
264
+ encrypted_hash: string;
265
+ iv: string;
266
+ encryption_key: string;
267
+ hmac_key: string;
268
+ plaintext_hash: string;
269
+ };
270
+ }>;
271
+ type FlowMediaData = z.infer<typeof flowMediaData>;
272
+
273
+ declare const flowMetadata: z.ZodObject<{
274
+ name: z.ZodString;
275
+ categories: z.ZodArray<z.ZodEnum<["SIGN_UP", "SIGN_IN", "APPOINTMENT_BOOKING", "LEAD_GENERATION", "CONTACT_US", "CUSTOMER_SUPPORT", "SURVEY", "OTHER"]>, "many">;
276
+ application_id: z.ZodOptional<z.ZodString>;
277
+ endpoint_uri: z.ZodOptional<z.ZodString>;
278
+ }, "strip", z.ZodTypeAny, {
279
+ name: string;
280
+ categories: ("SIGN_UP" | "SIGN_IN" | "APPOINTMENT_BOOKING" | "LEAD_GENERATION" | "CONTACT_US" | "CUSTOMER_SUPPORT" | "SURVEY" | "OTHER")[];
281
+ application_id?: string | undefined;
282
+ endpoint_uri?: string | undefined;
283
+ }, {
284
+ name: string;
285
+ categories: ("SIGN_UP" | "SIGN_IN" | "APPOINTMENT_BOOKING" | "LEAD_GENERATION" | "CONTACT_US" | "CUSTOMER_SUPPORT" | "SURVEY" | "OTHER")[];
286
+ application_id?: string | undefined;
287
+ endpoint_uri?: string | undefined;
288
+ }>;
289
+ type FlowMetadata = z.infer<typeof flowMetadata>;
290
+
291
+ declare const flowScreen: z.ZodUnion<[z.ZodLiteral<"SUCCESS">, z.ZodString]>;
292
+ type FlowScreen = z.infer<typeof flowScreen>;
293
+
294
+ type WaOutgoingContactsMessage = Array<{
295
+ addresses: Array<Partial<{
296
+ street: string;
297
+ city: string;
298
+ state: string;
299
+ zip: string;
300
+ country: string;
301
+ country_code: string;
302
+ type: string;
303
+ }>>;
304
+ birthday: `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
305
+ emails: Array<Partial<{
306
+ email: string;
307
+ type: string;
308
+ }>>;
309
+ name: {
310
+ formatted_name: string;
311
+ first_name?: string;
312
+ last_name?: string;
313
+ middle_name?: string;
314
+ prefix?: string;
315
+ suffix?: string;
316
+ };
317
+ org: Partial<{
318
+ company: string;
319
+ department: string;
320
+ title: string;
321
+ }>;
322
+ phones: Array<Partial<{
323
+ phone: string;
324
+ type: string;
325
+ wa_id: string;
326
+ }>>;
327
+ urls: Array<Partial<{
328
+ url: string;
329
+ type: string;
330
+ }>>;
331
+ }>;
332
+
333
+ type MediaTypes = "sticker" | "audio" | "document" | "image" | "video";
334
+ type WaOutgoingImageMessage = {
335
+ id: string;
336
+ caption?: string;
337
+ } | {
338
+ link: string;
339
+ caption?: string;
340
+ };
341
+ type WaOutgoingDocumentMessage = {
342
+ id: string;
343
+ caption?: string;
344
+ filename?: string;
345
+ } | {
346
+ link: string;
347
+ caption?: string;
348
+ filename?: string;
349
+ };
350
+ type WaOutgoingAudioMessage = {
351
+ id: string;
352
+ caption?: string;
353
+ } | {
354
+ link: string;
355
+ caption?: string;
356
+ };
357
+ type WaOutgoingVideoMessage = {
358
+ id: string;
359
+ caption?: string;
360
+ } | {
361
+ link: string;
362
+ caption?: string;
363
+ };
364
+ type WaOutgoingStickerMessage = {
365
+ id: string;
366
+ } | {
367
+ link: string;
368
+ };
369
+
370
+ interface WaInteractiveAction {
371
+ name?: "flow";
372
+ parameters?: {
373
+ flow_message_version?: "3";
374
+ flow_token?: string;
375
+ flow_name?: string;
376
+ flow_cta?: string;
377
+ flow_action?: "navigate" | "data_exchange";
378
+ flow_action_payload?: {
379
+ screen: string;
380
+ data?: Record<string, AnyType>;
381
+ };
382
+ mode: "draft" | "published";
383
+ };
384
+ button?: string;
385
+ buttons?: Array<{
386
+ type: "reply";
387
+ title: string;
388
+ id: string;
389
+ }>;
390
+ catalog_id?: string;
391
+ product_retailer_id?: string;
392
+ sections?: Array<{
393
+ product_items?: Array<{
394
+ product_retailer_id: string;
395
+ }>;
396
+ rows: Array<{
397
+ id: string;
398
+ title: string;
399
+ description?: string;
400
+ }>;
401
+ title: string;
402
+ }>;
403
+ mode?: "draft" | "published";
404
+ }
405
+ interface WaInteractiveBody {
406
+ text: string;
407
+ }
408
+ interface WaInteractiveFooter {
409
+ text: string;
410
+ }
411
+ interface WaInteractiveHeader {
412
+ document?: WaOutgoingDocumentMessage;
413
+ image?: WaOutgoingImageMessage;
414
+ video?: WaOutgoingVideoMessage;
415
+ text: string;
416
+ type: "text" | "video" | "image" | "document";
417
+ }
418
+ type WaInteractiveActionType = "button" | "catalog_message" | "list" | "product" | "product_list" | "flow";
419
+ declare class WaInteractiveBase {
420
+ constructor({ type, body, footer, header, }: {
421
+ type: WaInteractiveActionType;
422
+ body?: WaInteractiveBody;
423
+ footer?: WaInteractiveFooter;
424
+ header?: WaInteractiveHeader;
425
+ });
426
+ type: WaInteractiveActionType;
427
+ body?: WaInteractiveBody;
428
+ footer?: WaInteractiveFooter;
429
+ header?: WaInteractiveHeader;
430
+ }
431
+ type WaOutgoingInteractiveMessage = WaInteractiveBase & {
432
+ action: WaInteractiveAction;
433
+ };
434
+
435
+ interface WaOutgoingLocationMessage {
436
+ latitude: number;
437
+ longitude: number;
438
+ name: string;
439
+ address: string;
440
+ }
441
+
442
+ interface WaOutgoingReactionMessage {
443
+ message_id: string;
444
+ emoji: string;
445
+ }
446
+
447
+ type WaOutgoingTemplateMessage = {
448
+ name: string;
449
+ language: {
450
+ code: string;
451
+ };
452
+ namespace?: string;
453
+ components?: Array<{
454
+ type: "header" | "body" | "footer";
455
+ parameters: Array<{
456
+ type: "text" | "image" | "video" | "document";
457
+ text?: string;
458
+ image?: WaOutgoingImageMessage;
459
+ video?: WaOutgoingDocumentMessage;
460
+ document?: WaOutgoingVideoMessage;
461
+ }>;
462
+ } | {
463
+ type: "button";
464
+ sub_type: "quick_reply" | "url" | "copy_code";
465
+ index: string;
466
+ parameters: Array<{
467
+ type: "payload" | "text" | "coupon_code";
468
+ payload?: string;
469
+ text?: string;
470
+ coupon_code?: string;
471
+ }>;
472
+ }>;
473
+ };
474
+
475
+ interface WaOutgoingTextMessage {
476
+ body: string;
477
+ preview_url?: boolean;
478
+ }
479
+
480
+ interface WaOutgoingMessage {
481
+ text?: WaOutgoingTextMessage;
482
+ contacts?: WaOutgoingContactsMessage;
483
+ reaction?: WaOutgoingReactionMessage;
484
+ location?: WaOutgoingLocationMessage;
485
+ audio?: WaOutgoingAudioMessage;
486
+ document?: WaOutgoingDocumentMessage;
487
+ image?: WaOutgoingImageMessage;
488
+ video?: WaOutgoingVideoMessage;
489
+ sticker?: WaOutgoingStickerMessage;
490
+ interactive?: WaOutgoingInteractiveMessage;
491
+ template?: WaOutgoingTemplateMessage;
492
+ }
493
+ type WaMessageType = keyof WaOutgoingMessage;
494
+
495
+ interface WaIncomingContactObject {
496
+ wa_id: string;
497
+ profile: {
498
+ name: string;
499
+ };
500
+ }
501
+ type WaIncomingContacts = Array<WaIncomingContactObject>;
502
+
503
+ type WhatsappSendMessageRequestConfig = {
504
+ to: string;
505
+ preview_url?: boolean;
506
+ context?: string;
507
+ biz_opaque_callback_data?: string;
508
+ recipient_type?: "individual";
509
+ messaging_product?: "whatsapp";
510
+ };
511
+ type WhatsappSendMessageRequestBody<T extends keyof WaOutgoingMessage> = {
512
+ type: T;
513
+ } & WhatsappSendMessageRequestConfig & Record<T, WaOutgoingMessage[T]>;
514
+ type WhatsappSendMessageResponse = {
515
+ messaging_product: "whatsapp";
516
+ contacts: WaIncomingContactObject[];
517
+ messages: Array<{
518
+ id: string;
519
+ }>;
520
+ };
521
+
522
+ declare const messagesEndpoints: {
523
+ send: Endpoint<"/{number_id}/messages", "post", {
524
+ body: WhatsappSendMessageRequestBody<any>;
525
+ }, WhatsappSendMessageResponse>;
526
+ };
527
+
528
+ type ISOCountryCode = "AU" | "ID" | "IN" | "JP" | "SG" | "KR" | "DE" | "CH" | "GB" | "BR" | "BH" | "ZA" | "AE" | "CA";
529
+
530
+ type WhatsappRegisterPhoneNumberRequestBody = {
531
+ messaging_product: "whatsapp";
532
+ pin: string;
533
+ data_localization_region?: ISOCountryCode;
534
+ };
535
+
536
+ type WhatsappWabaUploadEncryptionRequestBody = {
537
+ business_public_key: string;
538
+ };
539
+
540
+ declare const wabaEndpoints: {
541
+ updateEncryption: Endpoint<"/{number_id}/whatsapp_business_encryption", "post", {
542
+ body: WhatsappWabaUploadEncryptionRequestBody;
543
+ }, unknown>;
544
+ registerNumber: Endpoint<"/{number_id}/register", "post", {
545
+ body: WhatsappRegisterPhoneNumberRequestBody;
546
+ }, unknown>;
547
+ };
548
+
549
+ type WaIncomingErrorObject = {
550
+ code: number;
551
+ title: string;
552
+ message: string;
553
+ error_data: {
554
+ details: string;
555
+ };
556
+ };
557
+ type WaIncomingErrors = Array<WaIncomingErrorObject>;
558
+
559
+ type ConversationType = "authentication" | "service" | "utility" | "marketing" | "referral_conversation";
560
+ type WaIncomingMessageStatus = "delivered" | "read" | "sent";
561
+ type WaIncomingMessageStatuses = Array<{
562
+ id: string;
563
+ biz_opaque_callback_data: string;
564
+ conversation: {
565
+ id: string;
566
+ origin: {
567
+ type: ConversationType;
568
+ };
569
+ expiration_timestamp: number;
570
+ };
571
+ errors: WaIncomingErrors;
572
+ pricing: {
573
+ category: ConversationType;
574
+ pricing_model: "CBP";
575
+ };
576
+ recipient_id: string;
577
+ status: WaIncomingMessageStatus;
578
+ timestamp: number;
579
+ }>;
580
+
581
+ interface WaIncomingInteractiveObject {
582
+ type: "button_reply" | "list_reply" | "nfm_reply";
583
+ button_reply?: {
584
+ id: string;
585
+ title: string;
586
+ };
587
+ list_reply?: {
588
+ id: string;
589
+ title: string;
590
+ description: string;
591
+ };
592
+ nfm_reply?: {
593
+ response_json: string;
594
+ body: string;
595
+ name: "flow";
596
+ };
597
+ }
598
+ interface WaIncomingOrderObject {
599
+ catalog_id: string;
600
+ text: string;
601
+ product_items: Array<{
602
+ product_retailer_id: string;
603
+ quantity: number;
604
+ item_price: string;
605
+ currency: string;
606
+ }>;
607
+ }
608
+ interface WaIncomingReferralObject {
609
+ source_url: string;
610
+ source_type: string;
611
+ source_id: string;
612
+ headline: string;
613
+ body: string;
614
+ media_type: string;
615
+ image_url: string;
616
+ video_url: string;
617
+ thumbnail_url: string;
618
+ ctwa_clid: string;
619
+ }
620
+ interface WaIncomingStickerObject {
621
+ mime_type: string;
622
+ sha256: string;
623
+ id: string;
624
+ animated: string;
625
+ }
626
+ interface WaIncomingSystemObject {
627
+ body: string;
628
+ identity: string;
629
+ new_wa_id: string;
630
+ wa_id: string;
631
+ type: {
632
+ customer_changed_number: string;
633
+ customer_identity_changed: string;
634
+ };
635
+ customer_changed_number: string;
636
+ customer_identity_changed: string;
637
+ customer: string;
638
+ }
639
+ interface WaIncomingContextObject {
640
+ forwarded: boolean;
641
+ frequently_forwarded: boolean;
642
+ from: string;
643
+ id: string;
644
+ referred_product?: {
645
+ catalog_id: string;
646
+ product_retailer_id: string;
647
+ };
648
+ }
649
+ interface WaIncomingButtonObject {
650
+ payload: string;
651
+ text: string;
652
+ }
653
+ interface WaIncomingDocumentObject {
654
+ caption: string | null;
655
+ filename: string;
656
+ sha256: string;
657
+ mime_type: string;
658
+ id: string;
659
+ }
660
+ interface WaIncomingImageObject {
661
+ caption: string | null;
662
+ sha256: string;
663
+ id: string;
664
+ mime_type: string;
665
+ }
666
+ interface WaIncomingVideoObject {
667
+ id: string;
668
+ caption: string | null;
669
+ filename: string;
670
+ sha256: string;
671
+ mime_type: string;
672
+ }
673
+ interface WaIncomingAudioObject {
674
+ id: string;
675
+ mime_type: string;
676
+ }
677
+ interface WaIncomingIdentityObject {
678
+ acknowledged: boolean;
679
+ created_timestamp: number;
680
+ hash: string;
681
+ }
682
+ interface WaIncomingTextObject {
683
+ body: string;
684
+ }
685
+ type WaIncomingMessageType = "audio" | "button" | "document" | "text" | "image" | "interactive" | "order" | "sticker" | "system" | "unknown" | "video";
686
+ type WaIncomingMessages = Array<{
687
+ id: string;
688
+ from: string;
689
+ timestamp: number;
690
+ type: WaIncomingMessageType;
691
+ context?: WaIncomingContextObject;
692
+ image?: WaIncomingImageObject;
693
+ video?: WaIncomingVideoObject;
694
+ interactive?: WaIncomingInteractiveObject;
695
+ order?: WaIncomingOrderObject;
696
+ referral?: WaIncomingReferralObject;
697
+ sticker?: WaIncomingStickerObject;
698
+ /**
699
+ * Sent when a customer changes their phone number or profile information.
700
+ */
701
+ system?: WaIncomingSystemObject;
702
+ text?: WaIncomingTextObject;
703
+ identity?: WaIncomingIdentityObject;
704
+ audio?: WaIncomingAudioObject;
705
+ button?: WaIncomingButtonObject;
706
+ document?: WaIncomingDocumentObject;
707
+ errors?: WaIncomingErrors;
708
+ }>;
709
+
710
+ interface MetadataObject {
711
+ /**
712
+ * Customer phone number
713
+ */
714
+ display_phone_number: string;
715
+ /**
716
+ * Customer phone number id
717
+ */
718
+ phone_number_id: string;
719
+ }
720
+ type MessageField = {
721
+ value: {
722
+ messaging_product: "whatsapp";
723
+ metadata: MetadataObject;
724
+ contacts: WaIncomingContacts;
725
+ errors?: WaIncomingErrors;
726
+ messages?: WaIncomingMessages;
727
+ statuses?: WaIncomingMessageStatuses;
728
+ };
729
+ field: "messages";
730
+ };
731
+
732
+ type WhatsappApplicationWebhookBody = {
733
+ /**
734
+ * Value will always be "whatsapp_business_account"
735
+ */
736
+ object: "whatsapp_business_account";
737
+ /**
738
+ * An array of entry objects. Each entry object contains an array of changes objects. Meta will send multiple entries in case there's a big load on their systems.
739
+ */
740
+ entry: Array<{
741
+ /**
742
+ * The WABA account id that is subscribed to the webhook. Useful when dealing with multiple numbers within the same company.
743
+ */
744
+ id: string;
745
+ /**
746
+ * An array of changes objects. Each changes object contains the value of the change and the field that was changed. Meta will send multiple changes in case there's a big load on their systems.
747
+ */
748
+ changes: Array<MessageField>;
749
+ }>;
750
+ };
751
+
752
+ interface WhatsappFlowDecryptedWebhookBody {
753
+ version: "3.0";
754
+ screen: FlowScreen;
755
+ action: FlowAction;
756
+ data: Record<string, AnyType>;
757
+ flow_token: string;
758
+ }
759
+ interface WhatsappFlowResponse {
760
+ screen: FlowScreen;
761
+ data: Record<string, AnyType>;
762
+ }
763
+ interface WhatsappFlowPingResponse {
764
+ data: {
765
+ status: "active";
766
+ };
767
+ }
768
+ interface WhatsappFlowEncryptionData {
769
+ aesKeyBuffer: Buffer;
770
+ initialVectorBuffer: Buffer;
771
+ }
772
+ interface WhatsappFlowEncryptedWebhookBody {
773
+ encrypted_aes_key: string;
774
+ encrypted_flow_data: string;
775
+ initial_vector: string;
776
+ }
777
+ type WhatsappFlowErrorMessages<T> = Partial<Record<keyof T, string>>;
778
+ interface WhatsappFlowInfo {
779
+ id: string;
780
+ mode: "draft" | "published";
781
+ name: string;
782
+ }
783
+
784
+ declare function _delete(flow_id: string): Promise<WhatsappDeleteFlowResponse>;
785
+
786
+ declare function verifyFlowIntegrity(flowID: string): Promise<string | void>;
787
+
788
+ declare const unnoficial_verifyFlowIntegrity: typeof verifyFlowIntegrity;
789
+ declare namespace unnoficial {
790
+ export { unnoficial_verifyFlowIntegrity as verifyFlowIntegrity };
791
+ }
792
+
793
+ type WaSDKButtonMessage = Omit<WaInteractiveBase, "type"> & {
794
+ type: "button";
795
+ buttons: Array<{
796
+ id: string;
797
+ text: string;
798
+ }>;
799
+ };
800
+
801
+ interface FlowPayload {
802
+ screen: string;
803
+ data?: Record<string, AnyType>;
804
+ }
805
+ interface BaseFlowConfig {
806
+ name: string;
807
+ buttonText: string;
808
+ parameters?: Record<string, string | number>;
809
+ mode?: "draft" | "published";
810
+ }
811
+ interface NavigateFlowConfig extends BaseFlowConfig {
812
+ action?: "navigate";
813
+ payload: FlowPayload;
814
+ }
815
+ interface DataExchangeFlowConfig extends BaseFlowConfig {
816
+ action?: "data_exchange";
817
+ payload?: FlowPayload;
818
+ }
819
+ type FlowConfig = NavigateFlowConfig | DataExchangeFlowConfig;
820
+ type WaSDKOutgoingFlowMessage = Omit<WaInteractiveBase, "type"> & {
821
+ type: "flow";
822
+ flow: FlowConfig;
823
+ };
824
+
825
+ type WaSDKOutgoingListMessage = Omit<WaInteractiveBase, "type"> & {
826
+ type: "list";
827
+ list: {
828
+ buttonText: string;
829
+ sections: Array<{
830
+ rows: Array<{
831
+ id: string;
832
+ title: string;
833
+ description?: string;
834
+ }>;
835
+ title: string;
836
+ }>;
837
+ };
838
+ };
839
+
840
+ type WaSDKOutgoingMediaMessage = {
841
+ type: "media";
842
+ sticker: {
843
+ ref: string;
844
+ };
845
+ } | {
846
+ type: "media";
847
+ image: {
848
+ ref: string;
849
+ caption?: string;
850
+ };
851
+ } | {
852
+ type: "media";
853
+ document: {
854
+ ref: string;
855
+ caption?: string;
856
+ filename?: string;
857
+ };
858
+ } | {
859
+ type: "media";
860
+ audio: {
861
+ ref: string;
862
+ caption?: string;
863
+ };
864
+ } | {
865
+ type: "media";
866
+ video: {
867
+ ref: string;
868
+ caption?: string;
869
+ };
870
+ };
871
+
872
+ type WaSDKOutgoingTemplateMessage = Omit<WaOutgoingTemplateMessage, "namespace" | "language"> & {
873
+ type: "template";
874
+ language: string;
875
+ };
876
+
877
+ type WaSDKOutgoingTextMessage = {
878
+ type: "text";
879
+ text: string;
880
+ previewUrl?: boolean;
881
+ };
882
+
883
+ type WaSDKSendMessageData = WaSDKButtonMessage | WaSDKOutgoingFlowMessage | WaSDKOutgoingListMessage | WaSDKOutgoingTextMessage | WaSDKOutgoingTemplateMessage | WaSDKOutgoingMediaMessage;
884
+
885
+ interface WaSDKSendMessageConfig {
886
+ showUrlPreviewImage?: boolean;
887
+ metadata?: string;
888
+ to: string;
889
+ reply?: string;
890
+ }
891
+ type WaSDKSendMessageBody = WaSDKSendMessageConfig & {
892
+ message: WaSDKSendMessageData;
893
+ };
894
+
895
+ declare function send(body: WaSDKSendMessageBody): Promise<WhatsappSendMessageResponse>;
896
+
897
+ declare function uploadWabaEncryption(publicKey: string): Promise<unknown>;
898
+
899
+ interface Payload {
900
+ pin: string;
901
+ dataRegion?: ISOCountryCode;
902
+ }
903
+ declare function registerNumber({ dataRegion, pin }: Payload): Promise<unknown>;
904
+
905
+ declare const actions: {
906
+ messages: {
907
+ send: typeof send;
908
+ };
909
+ flows: {
910
+ unnoficial: typeof unnoficial;
911
+ create(body: WhatsappCreateFlowRequestBody): Promise<WhatsappCreateFlowResponse>;
912
+ updateMetadata(flow_id: string, body: WhatsappFlowUpdateMetadataRequestBody): Promise<WhatsappFlowUpdateMetadataResponse>;
913
+ updateJson(flow_id: string, json: Record<string, AnyType>): Promise<WhatsappUpdateFlowJsonResponse>;
914
+ getPreview(flow_id: string, query?: WhatsappGetFlowWebPreviewPageRequestQuery): Promise<string>;
915
+ get(flow_id: string, query?: {
916
+ fields: Array<keyof WhatsappGetFlowsRequestResponse>;
917
+ }): Promise<WhatsappGetManyFlowsRequestResponse>;
918
+ getMany(): Promise<WhatsappGetManyFlowsRequestResponse>;
919
+ publish(flow_id: string): Promise<WhatsappPublishFlowResponse>;
920
+ delete: typeof _delete;
921
+ };
922
+ waba: {
923
+ registerNumber: typeof registerNumber;
924
+ encryption: {
925
+ upload: typeof uploadWabaEncryption;
926
+ };
927
+ };
928
+ };
929
+
930
+ interface BaseMessageReceivedEventPayload {
931
+ id: string;
932
+ type: WaIncomingMessageType;
933
+ timestamp: number;
934
+ metadata: {
935
+ forwarded?: boolean;
936
+ frequentlyForwarded?: boolean;
937
+ };
938
+ }
939
+ type MessageReceivedEventPayload = BaseMessageReceivedEventPayload & {
940
+ chatId: string;
941
+ text: string | null;
942
+ reply?: string;
943
+ interaction?: {
944
+ button?: {
945
+ id: string | null;
946
+ title: string;
947
+ payload: string | null;
948
+ };
949
+ selectedOption?: {
950
+ id: string;
951
+ title: string;
952
+ description: string;
953
+ };
954
+ flowResponse?: {
955
+ flow_token: string;
956
+ intent: string | null;
957
+ } & {
958
+ [key: string]: AnyType;
959
+ };
960
+ };
961
+ media?: {
962
+ id: string;
963
+ caption: string | null;
964
+ mime_type: string;
965
+ type: "audio" | "document" | "image" | "video";
966
+ filename?: string;
967
+ sha256?: string;
968
+ };
969
+ };
970
+
971
+ interface MessageStatusUpdateEvent {
972
+ messageId: string;
973
+ metadata: string;
974
+ timestamp: number;
975
+ errors: WaIncomingErrors;
976
+ status: WaIncomingMessageStatuses;
977
+ }
978
+
979
+ type WaSDKFlowPayload = WhatsappFlowDecryptedWebhookBody;
980
+ type WaSDKFlowDecryptedWebhookBody = {
981
+ payload: WaSDKFlowPayload;
982
+ encryptionMetadata: WhatsappFlowEncryptionData;
983
+ };
984
+ type WaSDKFlowExchangeEventPayload = WaSDKFlowDecryptedWebhookBody & {
985
+ pingResponse: WhatsappFlowPingResponse;
986
+ };
987
+
988
+ type FlowUpdateEventPayload = {
989
+ event: string;
990
+ message: string;
991
+ flow_id: string;
992
+ };
993
+
994
+ interface WaSDKEventPayload {
995
+ healthCheck: string;
996
+ flowExchange: WaSDKFlowExchangeEventPayload;
997
+ application: {
998
+ errors?: WaIncomingErrors[];
999
+ profileUpdate?: BaseMessageReceivedEventPayload & {
1000
+ identity: WaIncomingIdentityObject;
1001
+ system: WaIncomingSystemObject;
1002
+ }[];
1003
+ messageStatusUpdate?: MessageStatusUpdateEvent[];
1004
+ messageReceived?: MessageReceivedEventPayload[];
1005
+ flowUpdate?: FlowUpdateEventPayload[];
1006
+ };
1007
+ }
1008
+ type WaSDKEventType = keyof WaSDKEventPayload;
1009
+ interface WaSDKEvent<T extends WaSDKEventType = WaSDKEventType> {
1010
+ type: T;
1011
+ payload: WaSDKEventPayload[T];
1012
+ }
1013
+
1014
+ declare function webhook(request: Request): Promise<WaSDKEvent<"healthCheck"> | WaSDKEvent<"application"> | WaSDKEvent<"flowExchange">>;
1015
+
1016
+ declare const parsers: {
1017
+ toGraph: {
1018
+ sendMessage: (body: WaSDKSendMessageBody) => WhatsappSendMessageRequestBody<any> | WhatsappSendMessageRequestBody<"interactive"> | WhatsappSendMessageRequestBody<"text"> | WhatsappSendMessageRequestBody<"template">;
1019
+ flowResponse: (flow_token: string, response: WhatsappFlowResponse) => WhatsappFlowResponse;
1020
+ };
1021
+ toSDK: {
1022
+ webhook: typeof webhook;
1023
+ };
1024
+ };
1025
+
1026
+ type MessageReceivedEvent = Defined<WaSDKEventPayload["application"]["messageReceived"]>[0];
1027
+
1028
+ type WaSDKGetFlowWebPreviewPageRequestQuery = {
1029
+ flow_action: "data_exchange" | "navigate";
1030
+ phone_number: string;
1031
+ interactive?: boolean;
1032
+ recipient_id?: string;
1033
+ flow_action_payload?: {
1034
+ screen: string;
1035
+ data: Record<string, AnyType>;
1036
+ };
1037
+ flow_parameters?: FlowParameters;
1038
+ };
1039
+ type FlowParameters = Record<string, string | number>;
1040
+
1041
+ declare function decryptFlowBody(body: WhatsappFlowEncryptedWebhookBody): WaSDKFlowDecryptedWebhookBody;
1042
+
1043
+ declare function decryptFlowMedia(media: FlowMediaData[]): Promise<Buffer<ArrayBufferLike>[]>;
1044
+
1045
+ declare function encryptFlowResponse(data: AnyType, encryptionMetadata: {
1046
+ aesKeyBuffer: Buffer;
1047
+ initialVectorBuffer: Buffer;
1048
+ }): string;
1049
+
1050
+ declare function generateWabaEncryption(): Promise<{
1051
+ passphrase: `${string}-${string}-${string}-${string}-${string}`;
1052
+ publicKey: string;
1053
+ privateKey: string;
1054
+ }>;
1055
+
1056
+ declare function verifyHub(request: Request): string | false;
1057
+
1058
+ type WebhookSignatureChallengeArguments = {
1059
+ rawBody: string;
1060
+ untrustedSignature: string;
1061
+ };
1062
+ declare function verifySignature(request: Request, rawBody: string): Promise<boolean>;
1063
+
1064
+ declare const security: {
1065
+ verifyHub: typeof verifyHub;
1066
+ verifySignature: typeof verifySignature;
1067
+ generateWabaEncryption: typeof generateWabaEncryption;
1068
+ decryptFlowBody: typeof decryptFlowBody;
1069
+ encryptFlowResponse: typeof encryptFlowResponse;
1070
+ decryptFlowMedia: typeof decryptFlowMedia;
1071
+ };
1072
+
1073
+ declare const flows: {
1074
+ createToken: ({ flow_name, flow_parameters, chatId, }: {
1075
+ flow_name: string;
1076
+ flow_parameters?: Record<string, string | number>;
1077
+ chatId: string;
1078
+ }) => string;
1079
+ getName: (token: string) => string;
1080
+ destructureFlowToken: (token: string) => {
1081
+ paramsString: string;
1082
+ flowName: string;
1083
+ chatId: string;
1084
+ flowIdentifier: string;
1085
+ flowParameters: Record<string, string>;
1086
+ };
1087
+ };
1088
+
1089
+ declare const utils: {
1090
+ flows: {
1091
+ createToken: ({ flow_name, flow_parameters, chatId, }: {
1092
+ flow_name: string;
1093
+ flow_parameters?: Record<string, string | number>;
1094
+ chatId: string;
1095
+ }) => string;
1096
+ getName: (token: string) => string;
1097
+ destructureFlowToken: (token: string) => {
1098
+ paramsString: string;
1099
+ flowName: string;
1100
+ chatId: string;
1101
+ flowIdentifier: string;
1102
+ flowParameters: Record<string, string>;
1103
+ };
1104
+ };
1105
+ };
1106
+
1107
+ type sdk_BaseMessageReceivedEventPayload = BaseMessageReceivedEventPayload;
1108
+ type sdk_DataExchangeFlowConfig = DataExchangeFlowConfig;
1109
+ type sdk_FlowConfig = FlowConfig;
1110
+ type sdk_FlowParameters = FlowParameters;
1111
+ type sdk_FlowUpdateEventPayload = FlowUpdateEventPayload;
1112
+ type sdk_MessageReceivedEvent = MessageReceivedEvent;
1113
+ type sdk_MessageReceivedEventPayload = MessageReceivedEventPayload;
1114
+ type sdk_MessageStatusUpdateEvent = MessageStatusUpdateEvent;
1115
+ type sdk_NavigateFlowConfig = NavigateFlowConfig;
1116
+ type sdk_WaSDKButtonMessage = WaSDKButtonMessage;
1117
+ type sdk_WaSDKEvent<T extends WaSDKEventType = WaSDKEventType> = WaSDKEvent<T>;
1118
+ type sdk_WaSDKEventPayload = WaSDKEventPayload;
1119
+ type sdk_WaSDKEventType = WaSDKEventType;
1120
+ type sdk_WaSDKFlowDecryptedWebhookBody = WaSDKFlowDecryptedWebhookBody;
1121
+ type sdk_WaSDKFlowExchangeEventPayload = WaSDKFlowExchangeEventPayload;
1122
+ type sdk_WaSDKFlowPayload = WaSDKFlowPayload;
1123
+ type sdk_WaSDKGetFlowWebPreviewPageRequestQuery = WaSDKGetFlowWebPreviewPageRequestQuery;
1124
+ type sdk_WaSDKOutgoingFlowMessage = WaSDKOutgoingFlowMessage;
1125
+ type sdk_WaSDKOutgoingListMessage = WaSDKOutgoingListMessage;
1126
+ type sdk_WaSDKOutgoingMediaMessage = WaSDKOutgoingMediaMessage;
1127
+ type sdk_WaSDKOutgoingTemplateMessage = WaSDKOutgoingTemplateMessage;
1128
+ type sdk_WaSDKOutgoingTextMessage = WaSDKOutgoingTextMessage;
1129
+ type sdk_WaSDKSendMessageBody = WaSDKSendMessageBody;
1130
+ type sdk_WaSDKSendMessageConfig = WaSDKSendMessageConfig;
1131
+ type sdk_WaSDKSendMessageData = WaSDKSendMessageData;
1132
+ type sdk_WebhookSignatureChallengeArguments = WebhookSignatureChallengeArguments;
1133
+ declare const sdk_actions: typeof actions;
1134
+ declare const sdk_flows: typeof flows;
1135
+ declare const sdk_parsers: typeof parsers;
1136
+ declare const sdk_security: typeof security;
1137
+ declare const sdk_utils: typeof utils;
1138
+ declare namespace sdk {
1139
+ export { type sdk_BaseMessageReceivedEventPayload as BaseMessageReceivedEventPayload, type sdk_DataExchangeFlowConfig as DataExchangeFlowConfig, type sdk_FlowConfig as FlowConfig, type sdk_FlowParameters as FlowParameters, type sdk_FlowUpdateEventPayload as FlowUpdateEventPayload, type sdk_MessageReceivedEvent as MessageReceivedEvent, type sdk_MessageReceivedEventPayload as MessageReceivedEventPayload, type sdk_MessageStatusUpdateEvent as MessageStatusUpdateEvent, type sdk_NavigateFlowConfig as NavigateFlowConfig, type sdk_WaSDKButtonMessage as WaSDKButtonMessage, type sdk_WaSDKEvent as WaSDKEvent, type sdk_WaSDKEventPayload as WaSDKEventPayload, type sdk_WaSDKEventType as WaSDKEventType, type sdk_WaSDKFlowDecryptedWebhookBody as WaSDKFlowDecryptedWebhookBody, type sdk_WaSDKFlowExchangeEventPayload as WaSDKFlowExchangeEventPayload, type sdk_WaSDKFlowPayload as WaSDKFlowPayload, type sdk_WaSDKGetFlowWebPreviewPageRequestQuery as WaSDKGetFlowWebPreviewPageRequestQuery, type sdk_WaSDKOutgoingFlowMessage as WaSDKOutgoingFlowMessage, type sdk_WaSDKOutgoingListMessage as WaSDKOutgoingListMessage, type sdk_WaSDKOutgoingMediaMessage as WaSDKOutgoingMediaMessage, type sdk_WaSDKOutgoingTemplateMessage as WaSDKOutgoingTemplateMessage, type sdk_WaSDKOutgoingTextMessage as WaSDKOutgoingTextMessage, type sdk_WaSDKSendMessageBody as WaSDKSendMessageBody, type sdk_WaSDKSendMessageConfig as WaSDKSendMessageConfig, type sdk_WaSDKSendMessageData as WaSDKSendMessageData, type sdk_WebhookSignatureChallengeArguments as WebhookSignatureChallengeArguments, sdk_actions as actions, sdk_flows as flows, sdk_parsers as parsers, sdk_security as security, sdk_utils as utils };
1140
+ }
1141
+
1142
+ declare const whatsapp: {
1143
+ graph: {
1144
+ endpoints: {
1145
+ flows: {
1146
+ create: Endpoint<"/{waba_id}/flows", "post", {
1147
+ body: WhatsappCreateFlowRequestBody;
1148
+ }, WhatsappCreateFlowResponse>;
1149
+ updateMetadata: Endpoint<"/{flow_id}", "post", {
1150
+ body: WhatsappFlowUpdateMetadataRequestBody;
1151
+ }, WhatsappFlowUpdateMetadataResponse>;
1152
+ readMany: Endpoint<"/{waba_id}/flows", "get", IRequest, WhatsappGetManyFlowsRequestResponse>;
1153
+ delete: Endpoint<"/{flow_id}", "delete", IRequest, WhatsappDeleteFlowResponse>;
1154
+ read: Endpoint<"/{flow_id}", "get", {
1155
+ query: WhatsappGetFlowsRequestQuery;
1156
+ }, WhatsappGetManyFlowsRequestResponse>;
1157
+ updateJson: Endpoint<"/{flow_id}/assets", "post", {
1158
+ body: WhatsappUpdateFlowJsonRequestBody;
1159
+ }, WhatsappUpdateFlowJsonResponse>;
1160
+ getPreview: Endpoint<"/{flow_id}?fields=preview.invalidate(false)", "get", IRequest, WhatsappGetFlowWebPreviewURLResponse>;
1161
+ publish: Endpoint<"/{flow_id}/publish", "post", IRequest, WhatsappPublishFlowResponse>;
1162
+ };
1163
+ messages: {
1164
+ send: Endpoint<"/{number_id}/messages", "post", {
1165
+ body: WhatsappSendMessageRequestBody<any>;
1166
+ }, WhatsappSendMessageResponse>;
1167
+ };
1168
+ waba: {
1169
+ updateEncryption: Endpoint<"/{number_id}/whatsapp_business_encryption", "post", {
1170
+ body: WhatsappWabaUploadEncryptionRequestBody;
1171
+ }, unknown>;
1172
+ registerNumber: Endpoint<"/{number_id}/register", "post", {
1173
+ body: WhatsappRegisterPhoneNumberRequestBody;
1174
+ }, unknown>;
1175
+ };
1176
+ };
1177
+ };
1178
+ settings: {
1179
+ setup: (stg?: Partial<WhatsappSDKSettings>) => void;
1180
+ get: (key: keyof WhatsappSDKSettings) => string;
1181
+ };
1182
+ sdk: typeof sdk;
1183
+ };
1184
+
1185
+ export { type BaseMessageReceivedEventPayload, type ConversationType, type DataExchangeFlowConfig, type FlowAction, type FlowCanSendMessageStatus, type FlowCategory, type FlowConfig, type FlowData, type FlowMediaData, type FlowMetadata, type FlowParameters, type FlowScreen, type FlowStatus, type FlowUpdateEventPayload, type FlowValidationError, type ISOCountryCode, type MediaTypes, type MessageField, type MessageReceivedEvent, type MessageReceivedEventPayload, type MessageStatusUpdateEvent, type MetadataObject, type NavigateFlowConfig, type WaIncomingAudioObject, type WaIncomingButtonObject, type WaIncomingContactObject, type WaIncomingContacts, type WaIncomingContextObject, type WaIncomingDocumentObject, type WaIncomingErrorObject, type WaIncomingErrors, type WaIncomingIdentityObject, type WaIncomingImageObject, type WaIncomingInteractiveObject, type WaIncomingMessageStatus, type WaIncomingMessageStatuses, type WaIncomingMessageType, type WaIncomingMessages, type WaIncomingOrderObject, type WaIncomingReferralObject, type WaIncomingStickerObject, type WaIncomingSystemObject, type WaIncomingTextObject, type WaIncomingVideoObject, type WaInteractiveAction, type WaInteractiveActionType, WaInteractiveBase, type WaInteractiveBody, type WaInteractiveFooter, type WaInteractiveHeader, type WaMessageType, type WaOutgoingAudioMessage, type WaOutgoingContactsMessage, type WaOutgoingDocumentMessage, type WaOutgoingImageMessage, type WaOutgoingInteractiveMessage, type WaOutgoingLocationMessage, type WaOutgoingMessage, type WaOutgoingReactionMessage, type WaOutgoingStickerMessage, type WaOutgoingTemplateMessage, type WaOutgoingTextMessage, type WaOutgoingVideoMessage, type WaSDKButtonMessage, type WaSDKEvent, type WaSDKEventPayload, type WaSDKEventType, type WaSDKFlowDecryptedWebhookBody, type WaSDKFlowExchangeEventPayload, type WaSDKFlowPayload, type WaSDKGetFlowWebPreviewPageRequestQuery, type WaSDKOutgoingFlowMessage, type WaSDKOutgoingListMessage, type WaSDKOutgoingMediaMessage, type WaSDKOutgoingTemplateMessage, type WaSDKOutgoingTextMessage, type WaSDKSendMessageBody, type WaSDKSendMessageConfig, type WaSDKSendMessageData, type WebhookSignatureChallengeArguments, type WhatsappApplicationWebhookBody, type WhatsappCreateFlowRequestBody, type WhatsappCreateFlowResponse, type WhatsappDeleteFlowResponse, type WhatsappFlowDecryptedWebhookBody, type WhatsappFlowEncryptedWebhookBody, type WhatsappFlowEncryptionData, type WhatsappFlowErrorMessages, type WhatsappFlowInfo, type WhatsappFlowPingResponse, type WhatsappFlowResponse, type WhatsappFlowUpdateMetadataRequestBody, type WhatsappFlowUpdateMetadataResponse, type WhatsappGetFlowWebPreviewPageRequestQuery, type WhatsappGetFlowWebPreviewURLResponse, type WhatsappGetFlowsRequestQuery, type WhatsappGetFlowsRequestResponse, type WhatsappGetManyFlowsRequestResponse, type WhatsappPublishFlowResponse, type WhatsappRegisterPhoneNumberRequestBody, type WhatsappSendMessageRequestBody, type WhatsappSendMessageRequestConfig, type WhatsappSendMessageResponse, type WhatsappUpdateFlowJsonRequestBody, type WhatsappUpdateFlowJsonResponse, type WhatsappWabaUploadEncryptionRequestBody, actions, endpoints, flowAction, flowCanSendMessageStatus, flowCategory, flowMediaData, flowMetadata, flowScreen, flowStatus, flowValidationError, flows, flowsEndpoints, messagesEndpoints, parsers, security, utils, wabaEndpoints, whatsapp };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@apostlejs/whatsapp",
3
+ "license": "MIT",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "version": "0.0.0",
8
+ "type": "module",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "main": "./dist/index.cjs",
13
+ "types": "./dist/index.d.cts",
14
+ "exports": {
15
+ ".": "./dist/index.cjs"
16
+ },
17
+ "typesVersions": {
18
+ "*": {
19
+ ".": [
20
+ "./dist/index.d.cts"
21
+ ]
22
+ }
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^22.9.1",
26
+ "barrelsmith": "0.0.6",
27
+ "concurrently": "9.1.1",
28
+ "terser": "^5.39.0",
29
+ "tsup": "8.4.0",
30
+ "tsx": "^4.19.3",
31
+ "typescript": "5.8.2",
32
+ "@apostlejs/config": "1.0.0"
33
+ },
34
+ "dependencies": {
35
+ "dotenv": "16.4.7",
36
+ "zod": "3.24.2"
37
+ },
38
+ "scripts": {
39
+ "------------- toolchain -------------": "-------------",
40
+ "format": "biome format --write",
41
+ "lint": "biome lint --error-on-warnings",
42
+ "typecheck": "tsc --noEmit",
43
+ "------------- dev -------------": "-------------",
44
+ "dev:barrelsmith": "barrelsmith --watch",
45
+ "dev:watch": "pnpm tsup --env.mode dev",
46
+ "dev": "concurrently --raw pnpm:dev:*",
47
+ "------------- build -------------": "-------------",
48
+ "build": "rm -rf dist && barrelsmith && pnpm tsup --env.mode release",
49
+ "bundlesize": "pnpm build --metafile && npm pack --dry-run",
50
+ "bundlesize:dev": "pnpm tsup --metafile && npm pack --dry-run",
51
+ "------------- publishing -------------": "-------------",
52
+ "change": "changeset",
53
+ "bump": "pnpm changeset version",
54
+ "release": "pnpm typecheck && pnpm build && pnpm publish --no-git-checks",
55
+ "release:rc": "pnpm typecheck && pnpm build && pnpm version prerelease --preid=rc"
56
+ }
57
+ }