meta-cloud-api 1.1.3 → 1.1.4
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/dist/WebhookProcessor-BUZFeZD_.js +3 -0
- package/dist/WebhookProcessor-BUZFeZD_.js.map +1 -0
- package/dist/WebhookProcessor-Dq2Pa2cY.d.ts +718 -0
- package/dist/WebhookProcessor-Dq2Pa2cY.d.ts.map +1 -0
- package/dist/api/encryption/index.d.ts +3 -10
- package/dist/api/encryption/index.js +1 -2
- package/dist/api/flow/index.d.ts +5 -11
- package/dist/api/flow/index.js +1 -2
- package/dist/api/index.d.ts +17 -18
- package/dist/api/index.js +1 -2
- package/dist/api/media/index.d.ts +3 -10
- package/dist/api/media/index.js +1 -2
- package/dist/api/messages/builders/index.d.ts +442 -439
- package/dist/api/messages/builders/index.d.ts.map +1 -0
- package/dist/api/messages/builders/index.js +1 -3
- package/dist/api/messages/builders/index.js.map +1 -1
- package/dist/api/messages/index.d.ts +4 -10
- package/dist/api/messages/index.js +1 -2
- package/dist/api/phone/index.d.ts +3 -10
- package/dist/api/phone/index.js +1 -2
- package/dist/api/profile/index.d.ts +3 -10
- package/dist/api/profile/index.js +1 -2
- package/dist/api/qrCode/index.d.ts +3 -10
- package/dist/api/qrCode/index.js +1 -2
- package/dist/api/registration/index.d.ts +3 -10
- package/dist/api/registration/index.js +1 -2
- package/dist/api/template/index.d.ts +3 -21
- package/dist/api/template/index.js +1 -2
- package/dist/api/twoStepVerification/index.d.ts +3 -10
- package/dist/api/twoStepVerification/index.js +1 -2
- package/dist/api/waba/index.d.ts +3 -10
- package/dist/api/waba/index.js +1 -2
- package/dist/api-8hRAOyaL.js +1 -0
- package/dist/base-CfDkvT1x.d.ts +807 -0
- package/dist/base-CfDkvT1x.d.ts.map +1 -0
- package/dist/base-D-cXu_lA.js +2 -0
- package/dist/base-D-cXu_lA.js.map +1 -0
- package/dist/buildFieldsQueryString-Cr-jz3p0.js +2 -0
- package/dist/buildFieldsQueryString-Cr-jz3p0.js.map +1 -0
- package/dist/chunk-CTAAG5j7.js +1 -0
- package/dist/common-C6FXBDm7.js +2 -0
- package/dist/common-C6FXBDm7.js.map +1 -0
- package/dist/common-CVbsmD26.d.ts +426 -0
- package/dist/common-CVbsmD26.d.ts.map +1 -0
- package/dist/common-CvPVD1o6.d.ts +406 -0
- package/dist/common-CvPVD1o6.d.ts.map +1 -0
- package/dist/core/webhook/frameworks/express.d.ts +20 -53
- package/dist/core/webhook/frameworks/express.js +1 -2
- package/dist/core/webhook/frameworks/nextjs-app.d.ts +36 -39
- package/dist/core/webhook/frameworks/nextjs-app.d.ts.map +1 -0
- package/dist/core/webhook/frameworks/nextjs-app.js +1 -1
- package/dist/core/webhook/frameworks/nextjs-app.js.map +1 -1
- package/dist/core/webhook/frameworks/nextjs.d.ts +20 -49
- package/dist/core/webhook/frameworks/nextjs.js +1 -2
- package/dist/core/webhook/index.d.ts +20 -29
- package/dist/core/webhook/index.js +1 -2
- package/dist/core/whatsapp/index.d.ts +18 -42
- package/dist/core/whatsapp/index.js +1 -2
- package/dist/encryption-Cwc0xcVL.js +2 -0
- package/dist/encryption-Cwc0xcVL.js.map +1 -0
- package/dist/enums-CSUpFXb8.js +2 -0
- package/dist/enums-CSUpFXb8.js.map +1 -0
- package/dist/express-B6fQdflY.d.ts +78 -0
- package/dist/express-B6fQdflY.d.ts.map +1 -0
- package/dist/express-CrfNLYMM.js +2 -0
- package/dist/express-CrfNLYMM.js.map +1 -0
- package/dist/flow-CVes0Qus.js +2 -0
- package/dist/flow-CVes0Qus.js.map +1 -0
- package/dist/flowTypeGuards-Gn3-slCW.js +2 -0
- package/dist/flowTypeGuards-Gn3-slCW.js.map +1 -0
- package/dist/handler-BGqjZ0xg.js +2 -0
- package/dist/handler-BGqjZ0xg.js.map +1 -0
- package/dist/index-3KglHVAg.d.ts +354 -0
- package/dist/index-3KglHVAg.d.ts.map +1 -0
- package/dist/index-BNeg6hHx.d.ts +99 -0
- package/dist/index-BNeg6hHx.d.ts.map +1 -0
- package/dist/index-BiTq23oi.d.ts +34 -0
- package/dist/index-BiTq23oi.d.ts.map +1 -0
- package/dist/index-BmfnREgM.d.ts +47 -0
- package/dist/index-BmfnREgM.d.ts.map +1 -0
- package/dist/index-CaGffSja.d.ts +24 -0
- package/dist/index-CaGffSja.d.ts.map +1 -0
- package/dist/index-CeTmbIXi.d.ts +180 -0
- package/dist/index-CeTmbIXi.d.ts.map +1 -0
- package/dist/index-CoyByMuM.d.ts +137 -0
- package/dist/index-CoyByMuM.d.ts.map +1 -0
- package/dist/index-CwujtcvH.d.ts +370 -0
- package/dist/index-CwujtcvH.d.ts.map +1 -0
- package/dist/index-DQ7z58xp.d.ts +104 -0
- package/dist/index-DQ7z58xp.d.ts.map +1 -0
- package/dist/index-DQkgkiB6.d.ts +30 -0
- package/dist/index-DQkgkiB6.d.ts.map +1 -0
- package/dist/index-LKrIp3Oo.d.ts +1 -0
- package/dist/index-_-06JPan.d.ts +143 -0
- package/dist/index-_-06JPan.d.ts.map +1 -0
- package/dist/index-a_YS40Iv.d.ts +91 -0
- package/dist/index-a_YS40Iv.d.ts.map +1 -0
- package/dist/index-d7TLqtYh.d.ts +171 -0
- package/dist/index-d7TLqtYh.d.ts.map +1 -0
- package/dist/index.d.ts +21 -27
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{isMetaError-CQLXyEL4.d.ts → isMetaError-B3AglYeY.d.ts} +28 -25
- package/dist/isMetaError-B3AglYeY.d.ts.map +1 -0
- package/dist/media-Dw5OGzDD.js +2 -0
- package/dist/media-Dw5OGzDD.js.map +1 -0
- package/dist/messages-h5-NW8QO.js +2 -0
- package/dist/messages-h5-NW8QO.js.map +1 -0
- package/dist/nextjs-DxRCL4t3.js +2 -0
- package/dist/nextjs-DxRCL4t3.js.map +1 -0
- package/dist/objectToQueryString-CAHI0qTs.js +2 -0
- package/dist/objectToQueryString-CAHI0qTs.js.map +1 -0
- package/dist/phone-CZyWLyWB.js +2 -0
- package/dist/phone-CZyWLyWB.js.map +1 -0
- package/dist/profile-Bb7GDP0n.js +2 -0
- package/dist/profile-Bb7GDP0n.js.map +1 -0
- package/dist/qrCode-CeZEtX9J.js +2 -0
- package/dist/qrCode-CeZEtX9J.js.map +1 -0
- package/dist/registration-BkjhC3xw.js +2 -0
- package/dist/registration-BkjhC3xw.js.map +1 -0
- package/dist/template-Bgy-BCXJ.js +2 -0
- package/dist/template-Bgy-BCXJ.js.map +1 -0
- package/dist/twoStepVerification-DYlYF_P5.js +2 -0
- package/dist/twoStepVerification-DYlYF_P5.js.map +1 -0
- package/dist/types/index.d.ts +3 -6
- package/dist/types/index.js +1 -2
- package/dist/utils/index.d.ts +23 -20
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +1 -2
- package/dist/version-BUuqrHc6.js +3 -0
- package/dist/version-BUuqrHc6.js.map +1 -0
- package/dist/waba-SF2W3z2U.js +2 -0
- package/dist/waba-SF2W3z2U.js.map +1 -0
- package/dist/webhook-D4DQ01Xq.js +2 -0
- package/dist/webhook-D4DQ01Xq.js.map +1 -0
- package/dist/whatsapp-B85mxH5f.js +10 -0
- package/dist/whatsapp-B85mxH5f.js.map +1 -0
- package/package.json +27 -125
- package/dist/BusinessProfileApi-C_sEOrWM.d.ts +0 -353
- package/dist/EncryptionApi-CcCfeK2b.d.ts +0 -22
- package/dist/FlowApi-DDHrFT_Q.d.ts +0 -136
- package/dist/MediaApi-CY9RVo7u.d.ts +0 -90
- package/dist/MessageApi-CX_jN8da.d.ts +0 -171
- package/dist/PhoneNumberApi-B-hY7g1M.d.ts +0 -142
- package/dist/QrCodeApi-DRICKN04.d.ts +0 -98
- package/dist/RegistrationApi-CFPzU1Vw.d.ts +0 -47
- package/dist/TemplateApi-fCIlzBtK.d.ts +0 -161
- package/dist/TwoStepVerificationApi-C0jpAKfu.d.ts +0 -33
- package/dist/WabaApi-x5PhsLT3.d.ts +0 -175
- package/dist/WebhookProcessor-DEIZ2PRU.d.ts +0 -707
- package/dist/WhatsApp-BFsBgjJO.d.ts +0 -82
- package/dist/api/encryption/index.js.map +0 -1
- package/dist/api/flow/index.js.map +0 -1
- package/dist/api/index.js.map +0 -1
- package/dist/api/media/index.js.map +0 -1
- package/dist/api/messages/index.js.map +0 -1
- package/dist/api/phone/index.js.map +0 -1
- package/dist/api/profile/index.js.map +0 -1
- package/dist/api/qrCode/index.js.map +0 -1
- package/dist/api/registration/index.js.map +0 -1
- package/dist/api/template/index.js.map +0 -1
- package/dist/api/twoStepVerification/index.js.map +0 -1
- package/dist/api/waba/index.js.map +0 -1
- package/dist/base-BV6DyzGS.d.ts +0 -18
- package/dist/chunk-5577QQ7V.js +0 -2
- package/dist/chunk-5577QQ7V.js.map +0 -1
- package/dist/chunk-6DFC5L3X.js +0 -2
- package/dist/chunk-6DFC5L3X.js.map +0 -1
- package/dist/chunk-7QBIZCJ4.js +0 -2
- package/dist/chunk-7QBIZCJ4.js.map +0 -1
- package/dist/chunk-AMHQGG6Z.js +0 -2
- package/dist/chunk-AMHQGG6Z.js.map +0 -1
- package/dist/chunk-BAOZ4U74.js +0 -10
- package/dist/chunk-BAOZ4U74.js.map +0 -1
- package/dist/chunk-CRZ7EUYR.js +0 -2
- package/dist/chunk-CRZ7EUYR.js.map +0 -1
- package/dist/chunk-FKXSL2JK.js +0 -3
- package/dist/chunk-FKXSL2JK.js.map +0 -1
- package/dist/chunk-FSKBLPGE.js +0 -2
- package/dist/chunk-FSKBLPGE.js.map +0 -1
- package/dist/chunk-GM63NGNV.js +0 -2
- package/dist/chunk-GM63NGNV.js.map +0 -1
- package/dist/chunk-IYSR44P6.js +0 -2
- package/dist/chunk-IYSR44P6.js.map +0 -1
- package/dist/chunk-J2JPTKU6.js +0 -2
- package/dist/chunk-J2JPTKU6.js.map +0 -1
- package/dist/chunk-JC6YMVID.js +0 -2
- package/dist/chunk-JC6YMVID.js.map +0 -1
- package/dist/chunk-JPAV644F.js +0 -2
- package/dist/chunk-JPAV644F.js.map +0 -1
- package/dist/chunk-JXCLRKQ7.js +0 -2
- package/dist/chunk-JXCLRKQ7.js.map +0 -1
- package/dist/chunk-KMAH6636.js +0 -2
- package/dist/chunk-KMAH6636.js.map +0 -1
- package/dist/chunk-L4ESAO2S.js +0 -2
- package/dist/chunk-L4ESAO2S.js.map +0 -1
- package/dist/chunk-LV3TULSI.js +0 -2
- package/dist/chunk-LV3TULSI.js.map +0 -1
- package/dist/chunk-MJEG3K4V.js +0 -2
- package/dist/chunk-MJEG3K4V.js.map +0 -1
- package/dist/chunk-PHPQ5HP3.js +0 -2
- package/dist/chunk-PHPQ5HP3.js.map +0 -1
- package/dist/chunk-RIL6QABY.js +0 -2
- package/dist/chunk-RIL6QABY.js.map +0 -1
- package/dist/chunk-RWCVPWRC.js +0 -2
- package/dist/chunk-RWCVPWRC.js.map +0 -1
- package/dist/chunk-SNNRWNGZ.js +0 -2
- package/dist/chunk-SNNRWNGZ.js.map +0 -1
- package/dist/chunk-U5FBZ6UB.js +0 -3
- package/dist/chunk-U5FBZ6UB.js.map +0 -1
- package/dist/chunk-VHAODWCN.js +0 -2
- package/dist/chunk-VHAODWCN.js.map +0 -1
- package/dist/chunk-ZMNXRMWK.js +0 -2
- package/dist/chunk-ZMNXRMWK.js.map +0 -1
- package/dist/common-B8kp4RdL.d.ts +0 -403
- package/dist/common-CGbls9Y8.d.ts +0 -425
- package/dist/core/webhook/frameworks/express.js.map +0 -1
- package/dist/core/webhook/frameworks/nextjs.js.map +0 -1
- package/dist/core/webhook/index.js.map +0 -1
- package/dist/core/whatsapp/index.js.map +0 -1
- package/dist/enums-DIimUG6s.d.ts +0 -707
- package/dist/factory-kNha6WaY.d.ts +0 -200
- package/dist/handler-DbySwF0E.d.ts +0 -20
- package/dist/httpsClient-Cbd2Y6mg.d.ts +0 -19
- package/dist/logger-BdE0Vyim.d.ts +0 -9
- package/dist/request-CUjrMn8R.d.ts +0 -50
- package/dist/types/config.d.ts +0 -78
- package/dist/types/config.js +0 -2
- package/dist/types/config.js.map +0 -1
- package/dist/types/enums.d.ts +0 -1
- package/dist/types/enums.js +0 -2
- package/dist/types/enums.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/utils/index.js.map +0 -1
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { WabaConfigType } from
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import '../common-B8kp4RdL.js';
|
|
6
|
-
import '../request-CUjrMn8R.js';
|
|
7
|
-
import 'http';
|
|
1
|
+
import { WabaConfigType } from "../base-CfDkvT1x.js";
|
|
2
|
+
import { LoggerInterface } from "../index-DQkgkiB6.js";
|
|
3
|
+
import "../common-CvPVD1o6.js";
|
|
4
|
+
import { MetaError, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, isMetaError } from "../isMetaError-B3AglYeY.js";
|
|
8
5
|
|
|
6
|
+
//#region src/utils/buildFieldsQueryString.d.ts
|
|
9
7
|
declare function buildFieldsQueryString(fields?: string[] | string): string;
|
|
10
|
-
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/utils/configTable.d.ts
|
|
11
10
|
/**
|
|
12
11
|
* Formats configuration as a terminal table
|
|
13
12
|
* @param config - The WABA configuration object
|
|
@@ -15,19 +14,22 @@ declare function buildFieldsQueryString(fields?: string[] | string): string;
|
|
|
15
14
|
* @returns Formatted table string
|
|
16
15
|
*/
|
|
17
16
|
declare function formatConfigTable(config: WabaConfigType): string;
|
|
18
|
-
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/utils/logger.d.ts
|
|
19
19
|
declare class Logger implements LoggerInterface {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
private name;
|
|
21
|
+
private debug;
|
|
22
|
+
constructor(name: string, debug?: boolean);
|
|
23
|
+
log(...data: any[]): void;
|
|
24
|
+
error(...data: any[]): void;
|
|
25
|
+
warn(...data: any[]): void;
|
|
26
|
+
info(...data: any[]): void;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/utils/objectToQueryString.d.ts
|
|
29
30
|
declare const objectToQueryString: (params: Record<string, any>) => string;
|
|
30
|
-
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/utils/version.d.ts
|
|
31
33
|
/**
|
|
32
34
|
* Get SDK version from package.json
|
|
33
35
|
*/
|
|
@@ -36,5 +38,6 @@ declare function getVersion(): string;
|
|
|
36
38
|
* Generate User-Agent string following official SDK pattern
|
|
37
39
|
*/
|
|
38
40
|
declare function getUserAgent(): string;
|
|
39
|
-
|
|
40
|
-
export { Logger, buildFieldsQueryString, formatConfigTable, getUserAgent, getVersion, objectToQueryString };
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Logger, type MetaError, buildFieldsQueryString, formatConfigTable, getUserAgent, getVersion, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, isMetaError, objectToQueryString };
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/buildFieldsQueryString.ts","../../src/utils/configTable.ts","../../src/utils/logger.ts","../../src/utils/objectToQueryString.ts","../../src/utils/version.ts"],"sourcesContent":[],"mappings":";;;;;;iBAAgB,sBAAA;;;;;;;;AAAhB;iBCSgB,iBAAA,SAA0B;;;cCNrB,MAAA,YAAkB;;;;;EFHvB,KAAA,CAAA,GAAA,IAAA,EAAA,GAAA,EAAA,CAAA,EAAA,IAAsB;;;;;;cGAzB,8BAA+B;;;;;;iBCM5B,UAAA,CAAA;;;AJNhB;iBImBgB,YAAA,CAAA"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import"../enums-CSUpFXb8.js";import{Logger as e,formatConfigTable as t,getUserAgent as n,getVersion as r,isMetaError as i}from"../version-BUuqrHc6.js";import"../common-C6FXBDm7.js";import{objectToQueryString as a}from"../objectToQueryString-CAHI0qTs.js";import{buildFieldsQueryString as o}from"../buildFieldsQueryString-Cr-jz3p0.js";import{isFlowDataExchangeRequest as s,isFlowErrorRequest as c,isFlowPingRequest as l}from"../flowTypeGuards-Gn3-slCW.js";export{e as Logger,o as buildFieldsQueryString,t as formatConfigTable,n as getUserAgent,r as getVersion,s as isFlowDataExchangeRequest,c as isFlowErrorRequest,l as isFlowPingRequest,i as isMetaError,a as objectToQueryString};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{WabaConfigEnum as e}from"./enums-CSUpFXb8.js";import{readFileSync as t}from"fs";import{join as n}from"path";var r=class{name;debug;constructor(e,t=!1){this.name=e,this.debug=t}log(...e){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,`: `,...e])}}error(...e){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,`: `,...e])}warn(...e){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,`: `,...e])}info(...e){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,`: `,...e])}};function i(t){let n=[[`App ID`,t[e.AppId]||`Not Set`],[`Phone Number ID`,t[e.PhoneNumberId]?.toString()||`Not Set`],[`Business Account ID`,t[e.BusinessAcctId]||`Not Set`],[`API Version`,t[e.APIVersion]||`Not Set`],[`Access Token`,t[e.AccessToken]?`${t[e.AccessToken].substring(0,20)}...`:`Not Set`],[`Webhook Endpoint`,t[e.WebhookEndpoint]||`Not Set`],[`Webhook Verification Token`,t[e.WebhookVerificationToken]?`${t[e.WebhookVerificationToken].substring(0,10)}...`:`Not Set`],[`Listener Port`,t[e.ListenerPort]?.toString()||`Not Set`],[`Debug Mode`,t[e.Debug]?`Enabled`:`Disabled`],[`Max Retries`,t[e.MaxRetriesAfterWait]?.toString()||`Not Set`],[`Request Timeout`,t[e.RequestTimeout]?`${t[e.RequestTimeout]}ms`:`Not Set`],[`Private PEM`,t[e.PrivatePem]?`Configured`:`Not Set`],[`Passphrase`,t[e.Passphrase]?`Configured`:`Not Set`]],r=Math.max(...n.map(([e])=>e?.length||0)),i=Math.max(...n.map(([,e])=>e?.length||0)),a=Math.max(r,20),o=Math.max(i,30),s=`┌${`─`.repeat(a+2)}┬${`─`.repeat(o+2)}┐`,c=`├${`─`.repeat(a+2)}┼${`─`.repeat(o+2)}┤`,l=`└${`─`.repeat(a+2)}┴${`─`.repeat(o+2)}┘`,u=`│ ${`Configuration`.padEnd(a)} │ ${`Value`.padEnd(o)} │`,d=n.map(([e,t])=>`│ ${e?.padEnd(a)} │ ${t?.padEnd(o)} │`);return[s,u,c,...d,l].join(`
|
|
2
|
+
`)}function a(e){return typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!=null&&`message`in e.error&&typeof e.error.message==`string`&&`type`in e.error&&typeof e.error.type==`string`&&`code`in e.error&&typeof e.error.code==`number`&&`fbtrace_id`in e.error&&typeof e.error.fbtrace_id==`string`&&(!(`error_data`in e.error)||typeof e.error.error_data==`object`&&e.error.error_data!=null&&`messaging_product`in e.error.error_data&&e.error.error_data.messaging_product===`whatsapp`&&`details`in e.error.error_data&&typeof e.error.error_data.details==`string`)&&(!(`error_subcode`in e.error)||typeof e.error.error_subcode==`number`)}function o(){try{let e=n(__dirname,`../../package.json`);return JSON.parse(t(e,`utf-8`)).version}catch{return`unknown`}}function s(){let e=o(),t=process.version;return`WhatsApp-Nodejs-SDK/${e} (Node.js ${t})`}export{r as Logger,i as formatConfigTable,s as getUserAgent,o as getVersion,a as isMetaError};
|
|
3
|
+
//# sourceMappingURL=version-BUuqrHc6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-BUuqrHc6.js","names":[],"sources":["../src/utils/logger.ts","../src/utils/configTable.ts","../src/utils/isMetaError.ts","../src/utils/version.ts"],"sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\n\n/**\n * Formats configuration as a terminal table\n * @param config - The WABA configuration object\n * @param apiName - The name of the API being initialized\n * @returns Formatted table string\n */\nexport function formatConfigTable(config: WabaConfigType): string {\n const configData = [\n ['App ID', config[WabaConfigEnum.AppId] || 'Not Set'],\n ['Phone Number ID', config[WabaConfigEnum.PhoneNumberId]?.toString() || 'Not Set'],\n ['Business Account ID', config[WabaConfigEnum.BusinessAcctId] || 'Not Set'],\n ['API Version', config[WabaConfigEnum.APIVersion] || 'Not Set'],\n [\n 'Access Token',\n config[WabaConfigEnum.AccessToken]\n ? `${config[WabaConfigEnum.AccessToken].substring(0, 20)}...`\n : 'Not Set',\n ],\n ['Webhook Endpoint', config[WabaConfigEnum.WebhookEndpoint] || 'Not Set'],\n [\n 'Webhook Verification Token',\n config[WabaConfigEnum.WebhookVerificationToken]\n ? `${config[WabaConfigEnum.WebhookVerificationToken].substring(0, 10)}...`\n : 'Not Set',\n ],\n ['Listener Port', config[WabaConfigEnum.ListenerPort]?.toString() || 'Not Set'],\n ['Debug Mode', config[WabaConfigEnum.Debug] ? 'Enabled' : 'Disabled'],\n ['Max Retries', config[WabaConfigEnum.MaxRetriesAfterWait]?.toString() || 'Not Set'],\n [\n 'Request Timeout',\n config[WabaConfigEnum.RequestTimeout] ? `${config[WabaConfigEnum.RequestTimeout]}ms` : 'Not Set',\n ],\n ['Private PEM', config[WabaConfigEnum.PrivatePem] ? 'Configured' : 'Not Set'],\n ['Passphrase', config[WabaConfigEnum.Passphrase] ? 'Configured' : 'Not Set'],\n ];\n\n // Calculate column widths\n const maxKeyLength = Math.max(...configData.map(([key]) => key?.length || 0));\n const maxValueLength = Math.max(...configData.map(([, value]) => value?.length || 0));\n\n const keyWidth = Math.max(maxKeyLength, 20);\n const valueWidth = Math.max(maxValueLength, 30);\n\n // Create table\n const horizontalLine = `┌${'─'.repeat(keyWidth + 2)}┬${'─'.repeat(valueWidth + 2)}┐`;\n const separator = `├${'─'.repeat(keyWidth + 2)}┼${'─'.repeat(valueWidth + 2)}┤`;\n const bottomLine = `└${'─'.repeat(keyWidth + 2)}┴${'─'.repeat(valueWidth + 2)}┘`;\n\n const header = `│ ${'Configuration'.padEnd(keyWidth)} │ ${'Value'.padEnd(valueWidth)} │`;\n\n const rows = configData.map(([key, value]) => `│ ${key?.padEnd(keyWidth)} │ ${value?.padEnd(valueWidth)} │`);\n\n return [horizontalLine, header, separator, ...rows, bottomLine].join('\\n');\n}\n","export interface MetaError extends Error {\n error: {\n message: string;\n type: string;\n code: number;\n error_data?: {\n messaging_product: 'whatsapp';\n details: string;\n };\n error_subcode?: number;\n fbtrace_id: string;\n };\n}\n\n/**\n * Determines if the error is a Meta API error response\n * @param error Any error object to check\n * @returns Type guard indicating if error is a Meta API error\n */\nexport function isMetaError(error: any): error is MetaError {\n return (\n error != null &&\n typeof error === 'object' &&\n 'error' in error &&\n typeof error.error === 'object' &&\n error.error != null &&\n 'message' in error.error &&\n typeof error.error.message === 'string' &&\n 'type' in error.error &&\n typeof error.error.type === 'string' &&\n 'code' in error.error &&\n typeof error.error.code === 'number' &&\n 'fbtrace_id' in error.error &&\n typeof error.error.fbtrace_id === 'string' &&\n (!('error_data' in error.error) ||\n (typeof error.error.error_data === 'object' &&\n error.error.error_data != null &&\n 'messaging_product' in error.error.error_data &&\n error.error.error_data.messaging_product === 'whatsapp' &&\n 'details' in error.error.error_data &&\n typeof error.error.error_data.details === 'string')) &&\n (!('error_subcode' in error.error) || typeof error.error.error_subcode === 'number')\n );\n}\n","import { readFileSync } from 'fs';\nimport { join } from 'path';\n\n/**\n * Get SDK version from package.json\n */\nexport function getVersion(): string {\n try {\n const packagePath = join(__dirname, '../../package.json');\n const packageJson = JSON.parse(readFileSync(packagePath, 'utf-8'));\n return packageJson.version;\n } catch (error) {\n return 'unknown';\n }\n}\n\n/**\n * Generate User-Agent string following official SDK pattern\n */\nexport function getUserAgent(): string {\n const version = getVersion();\n const nodeVersion = process.version;\n return `WhatsApp-Nodejs-SDK/${version} (Node.js ${nodeVersion})`;\n}\n"],"mappings":"mHAGA,IAAqB,EAArB,KAAuD,CACnD,KACA,MAEA,YAAY,EAAc,EAAiB,GAAO,CAC9C,KAAK,KAAO,EACZ,KAAK,MAAQ,EAGjB,IAAI,GAAG,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAI,EAAS,KAAK,KAAK,KAAK,CAAC,IACzB,KAAK,OACL,GAAU,MAAM,KAAK,QAEzB,QAAQ,IAAI,MAAM,QAAS,CAAC,EAAQ,KAAM,GAAG,EAAK,CAAC,EAI3D,MAAM,GAAG,EAAa,CAClB,IAAI,EAAS,KAAK,KAAK,KAAK,CAAC,YACzB,KAAK,OACL,GAAU,MAAM,KAAK,QAEzB,QAAQ,MAAM,MAAM,QAAS,CAAC,EAAQ,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,EAAM,QAAU,OAAO,EAAM,MAAM,eAAkB,UCnCnF,SAAgB,GAAqB,CACjC,GAAI,CACA,IAAM,EAAc,EAAK,UAAW,qBAAqB,CAEzD,OADoB,KAAK,MAAM,EAAa,EAAa,QAAQ,CAAC,CAC/C,aACP,CACZ,MAAO,WAOf,SAAgB,GAAuB,CACnC,IAAM,EAAU,GAAY,CACtB,EAAc,QAAQ,QAC5B,MAAO,uBAAuB,EAAQ,YAAY,EAAY"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";import{buildFieldsQueryString as r}from"./buildFieldsQueryString-Cr-jz3p0.js";var i=class extends n{constructor(e,t){super(e,t)}async getWabaAccount(n){let i=r(n)?.replace(/,/g,`%2C`);return this.sendJson(e.Get,`${this.config[t.BusinessAcctId]}${i}`,this.config[t.RequestTimeout],null)}async getAllWabaSubscriptions(){return this.sendJson(e.Get,`${this.config[t.BusinessAcctId]}/subscribed_apps`,this.config[t.RequestTimeout],null)}async updateWabaSubscription({override_callback_uri:n,verify_token:r}){let i={override_callback_uri:n,verify_token:r};return this.sendJson(e.Post,`${this.config[t.BusinessAcctId]}/subscribed_apps`,this.config[t.RequestTimeout],JSON.stringify(i))}async unsubscribeFromWaba(){return this.sendJson(e.Delete,`${this.config[t.BusinessAcctId]}/subscribed_apps`,this.config[t.RequestTimeout],null)}},a=i;export{i as WabaApi,a as waba_default};
|
|
2
|
+
//# sourceMappingURL=waba-SF2W3z2U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waba-SF2W3z2U.js","names":[],"sources":["../src/api/waba/WabaApi.ts","../src/api/waba/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\nimport { buildFieldsQueryString } from '../../utils/buildFieldsQueryString';\n\nimport type * as waba from './types';\n\n/**\n * API for managing WhatsApp Business Account (WABA).\n *\n * This API allows you to:\n * - Get WABA account information\n * - Manage WABA subscriptions\n * - Subscribe/unsubscribe from WABA webhooks\n * - Update subscription settings\n */\nexport default class WabaApi extends BaseAPI implements waba.WABAClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Retrieve WhatsApp Business Account information.\n *\n * @param fields Optional array of specific fields to retrieve\n * @returns WABA account information including status, health, verification status, etc.\n *\n * @example\n * const account = await whatsappClient.waba.getWabaAccount(['id', 'name', 'status']);\n */\n async getWabaAccount(fields?: waba.WabaAccountFieldsParam): Promise<waba.WabaAccount> {\n const queryString = buildFieldsQueryString(fields)?.replace(/,/g, '%2C');\n\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Get all WABA subscriptions for the business account.\n *\n * @returns List of all subscribed apps and their configurations\n *\n * @example\n * const subscriptions = await whatsappClient.waba.getAllWabaSubscriptions();\n */\n async getAllWabaSubscriptions(): Promise<waba.WabaSubscriptions> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update WABA subscription configuration.\n *\n * @param params Configuration parameters including callback URI and verify token\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.waba.updateWabaSubscription({\n * override_callback_uri: 'https://example.com/webhook',\n * verify_token: 'your_verify_token'\n * });\n */\n async updateWabaSubscription({\n override_callback_uri,\n verify_token,\n }: waba.UpdateWabaSubscription): Promise<ResponseSuccess> {\n const body = {\n override_callback_uri,\n verify_token,\n };\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n\n /**\n * Unsubscribe from WABA webhooks.\n *\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.waba.unsubscribeFromWaba();\n */\n async unsubscribeFromWaba(): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import WabaApi from './WabaApi';\n\nexport default WabaApi;\n\nexport { WabaApi };\n\nexport type { UpdateWabaSubscription, WABAClass, WabaAccount, WabaSubscriptions } from './types';\n"],"mappings":"qMAiBA,IAAqB,EAArB,cAAqC,CAAkC,CACnE,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAYzB,MAAM,eAAe,EAAiE,CAClF,IAAM,EAAc,EAAuB,EAAO,EAAE,QAAQ,KAAM,MAAM,CAExE,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,kBAAkB,IAChD,KAAK,OAAO,EAAe,gBAC3B,KACH,CAWL,MAAM,yBAA2D,CAC7D,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,gBAAgB,kBAC9C,KAAK,OAAO,EAAe,gBAC3B,KACH,CAeL,MAAM,uBAAuB,CACzB,wBACA,gBACsD,CACtD,IAAM,EAAO,CACT,wBACA,eACH,CACD,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,gBAAgB,kBAC9C,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAK,CACvB,CAWL,MAAM,qBAAgD,CAClD,OAAO,KAAK,SACR,EAAgB,OAChB,GAAG,KAAK,OAAO,EAAe,gBAAgB,kBAC9C,KAAK,OAAO,EAAe,gBAC3B,KACH,GCnGT,EAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-D4DQ01Xq.js","names":["crypto"],"sources":["../src/core/webhook/utils/generateXHub256Sig.ts"],"sourcesContent":["import * as crypto from 'crypto';\n\nexport const generateXHub256Sig = (body: string, appSecret: string) => {\n return crypto.createHmac('sha256', appSecret).update(body, 'utf-8').digest('hex');\n};\n"],"mappings":"yBAEA,MAAa,GAAsB,EAAc,IACtCA,EAAO,WAAW,SAAU,EAAU,CAAC,OAAO,EAAM,QAAQ,CAAC,OAAO,MAAM"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{WabaConfigEnum as e,enums_exports as t}from"./enums-CSUpFXb8.js";import{Logger as n,formatConfigTable as r,getUserAgent as i,getVersion as a,isMetaError as o}from"./version-BUuqrHc6.js";import{encryption_default as s}from"./encryption-Cwc0xcVL.js";import{flow_default as c}from"./flow-CVes0Qus.js";import{media_default as l}from"./media-Dw5OGzDD.js";import{messages_default as u}from"./messages-h5-NW8QO.js";import{phone_default as d}from"./phone-CZyWLyWB.js";import{profile_default as f}from"./profile-Bb7GDP0n.js";import{qrCode_default as p}from"./qrCode-CeZEtX9J.js";import{registration_default as m}from"./registration-BkjhC3xw.js";import{TemplateApi as h}from"./template-Bgy-BCXJ.js";import{twoStepVerification_default as g}from"./twoStepVerification-DYlYF_P5.js";import{waba_default as _}from"./waba-SF2W3z2U.js";import{Agent as v}from"https";const y=new n(`UTILS`,process.env.DEBUG===`true`||!1),b=t=>{if(!process.env[e.AccessToken]&&!t?.accessToken)throw y.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`),Error(`Missing WhatsApp access token.`)},x=t=>(b(t),{[e.AppId]:t?.appId||process.env.M4D_APP_ID||``,[e.AppSecret]:t?.appSecret||process.env.M4D_APP_SECRET||``,[e.PhoneNumberId]:t?.phoneNumberId||Number(process.env.WA_PHONE_NUMBER_ID),[e.BusinessAcctId]:t?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||``,[e.APIVersion]:t?.apiVersion||process.env.CLOUD_API_VERSION||``,[e.AccessToken]:t?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||``,[e.WebhookEndpoint]:t?.webhookEndpoint||process.env.WEBHOOK_ENDPOINT||``,[e.WebhookVerificationToken]:t?.webhookVerificationToken||process.env.WEBHOOK_VERIFICATION_TOKEN||``,[e.ListenerPort]:t?.listenerPort||parseInt(process.env.LISTENER_PORT||``)||3e3,[e.MaxRetriesAfterWait]:t?.maxRetriesAfterWait||parseInt(process.env.MAX_RETRIES_AFTER_WAIT||``)||30,[e.RequestTimeout]:t?.requestTimeout||parseInt(process.env.REQUEST_TIMEOUT||``)||2e4,[e.Debug]:t?.debug||process.env.DEBUG===`true`,[e.PrivatePem]:t?.privatePem||process.env.FLOW_API_PRIVATE_PEM||``,[e.Passphrase]:t?.passphrase||process.env.FLOW_API_PASSPHRASE||``}),S=new n(`HttpsClient`,process.env.DEBUG===`true`||!1);var C=class{agent;constructor(){this.agent=new v({keepAlive:!0})}clearSockets(){return this.agent.destroy(),!0}async sendRequest(e,t,n,r,i,a){let o=`https://${e}/${t}`,s=new AbortController,c=setTimeout(()=>s.abort(),i);try{let e=await fetch(o,{method:n,headers:r,body:a,signal:s.signal});return S.log(`${n} : ${o} - ${JSON.stringify(e)}`),clearTimeout(c),new w(e)}catch(e){throw S.error(`${n} : ${o} - ${JSON.stringify(e)}`),e}}},w=class{res;respStatusCode;respHeaders;constructor(e){this.res=e,this.respStatusCode=e.status,this.respHeaders=Object.fromEntries(e.headers.entries())}statusCode(){return this.respStatusCode}headers(){return this.respHeaders}rawResponse(){return this.res}async json(){try{return await this.res.json()}catch(e){throw Error(`Failed to parse response body to JSON: `+e.message)}}};const T=new n(`REQUESTER`,process.env.DEBUG===`true`||!1);var E=class{client;accessToken;phoneNumberId;businessAcctId;apiVersion;userAgent;host;protocol=`https:`;constructor(e,t,n,r,i){this.client=new C,this.host=`graph.facebook.com`,this.apiVersion=e||`22`,this.phoneNumberId=t,this.accessToken=n,this.businessAcctId=r,this.userAgent=i}buildHeader(e,t){let n={Authorization:`Bearer ${this.accessToken}`,"User-Agent":this.userAgent};return e!==`multipart/form-data`&&(n[`Content-Type`]=e),t&&Object.assign(n,t),n}buildCAPIPath(e){return`v${this.apiVersion}.0/${e}`}async sendRequest(e,t,n,r,i=`application/json`,a){let s=i;r instanceof FormData?s=`multipart/form-data`:typeof r==`string`&&r.startsWith(`<?xml`)&&(s=`application/xml`);let c=`${this.protocol.toLowerCase()}//${this.host}/${this.buildCAPIPath(t)}`;T.log(`${e} : ${c} (${s})`);try{let i=await this.client.sendRequest(this.host,this.buildCAPIPath(t),e,this.buildHeader(s,a),n,e===`POST`||e===`PUT`?r:void 0);if(!i.rawResponse().ok){let e=await i.json();throw o(e)?e:{name:`MetaError`,message:`Unknown error occurred`,error:{message:e.message||`Unknown error occurred`,type:`UnknownError`,code:i.statusCode(),fbtrace_id:``}}}return i}catch(e){throw o(e)?e:{name:`MetaError`,message:e instanceof Error?e.message:`Network error occurred`,error:{message:e instanceof Error?e.message:`Network error occurred`,type:`NetworkError`,code:500,fbtrace_id:``}}}}async getJson(e,t,n,r,i){return await(await this.sendRequest(e,t,n,r,`application/json`,i)).json()}async sendFormData(e,t,n,r,i){return await(await this.sendRequest(e,t,n,r,`multipart/form-data`,i)).json()}async sendUrlEncodedForm(e,t,n,r,i){let a=new URLSearchParams(r).toString();return await(await this.sendRequest(e,t,n,a,`application/x-www-form-urlencoded`,i)).json()}};function D(){process.env.NODE_ENV===`test`||process.env.VITEST===`true`||typeof global<`u`&&global.__VITEST__||console.log(`\x1B[36m%s\x1B[0m`,`
|
|
2
|
+
██████╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ █████╗ ██████╗ ██╗
|
|
3
|
+
██╔════╝ ██║ ██╔═══██╗ ██║ ██║ ██╔══██╗ ██╔══██╗ ██╔══██╗ ██║
|
|
4
|
+
██║ ██║ ██║ ██║ ██║ ██║ ██║ ██║ ███████║ ██████╔╝ ██║
|
|
5
|
+
██║ ██║ ██║ ██║ ██║ ██║ ██║ ██║ ██╔══██║ ██╔═══╝ ██║
|
|
6
|
+
╚██████╗ ███████╗ ╚██████╔╝ ╚██████╔╝ ██████╔╝ ██║ ██║ ██║ ██║
|
|
7
|
+
╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
|
|
8
|
+
`)}const O=new n(`WHATSAPP`,process.env.DEBUG===`true`);var k=class{config;requester;messages;media;phoneNumbers;twoStepVerification;flows;businessProfile;templates;encryption;qrCode;registration;waba;constructor(t){D(),this.config=x(t),this.requester=new E(this.config[e.APIVersion],this.config[e.PhoneNumberId],this.config[e.AccessToken],this.config[e.BusinessAcctId],this.getUserAgent()),this.messages=new u(this.config,this.requester),this.media=new l(this.config,this.requester),this.phoneNumbers=new d(this.config,this.requester),this.twoStepVerification=new g(this.config,this.requester),this.flows=new c(this.config,this.requester),this.businessProfile=new f(this.config,this.requester),this.templates=new h(this.config,this.requester),this.encryption=new s(this.config,this.requester),this.qrCode=new p(this.config,this.requester),this.registration=new m(this.config,this.requester),this.waba=new _(this.config,this.requester),O.log(`
|
|
9
|
+
`+r(this.config))}updateTimeout(t){this.config[e.RequestTimeout]=t,`updateTimeout`in this.requester&&this.requester.updateTimeout(t),O.log(`Timeout updated to ${t}ms`)}updateSenderNumberId(t){this.config[e.PhoneNumberId]=t,O.log(`Sender number ID updated to ${t}`)}updateAccessToken(t){this.config[e.AccessToken]=t,`updateAccessToken`in this.requester&&this.requester.updateAccessToken(t),O.log(`Access token updated`)}version(){return a()}static get Enums(){return t}getUserAgent(){return i()}};export{k as WhatsApp,x as importConfig};
|
|
10
|
+
//# sourceMappingURL=whatsapp-B85mxH5f.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-B85mxH5f.js","names":["LOGGER","LOGGER","LOGGER","headers: HeadersInit","MessagesApi","MediaApi","PhoneNumberApi","TwoStepVerificationApi","FlowApi","BusinessProfileApi","EncryptionApi","QrCodeApi","RegistrationApi","WabaApi","SDKEnums"],"sources":["../src/config/importConfig.ts","../src/utils/http/httpsClient.ts","../src/utils/http/request.ts","../src/utils/logoConsole.ts","../src/core/whatsapp/WhatsApp.ts"],"sourcesContent":["import type { WabaConfigType, WhatsAppConfig } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from '../utils/logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (config: WhatsAppConfig | undefined) => {\n if (!process.env[WabaConfigEnum.AccessToken] && !config?.accessToken) {\n LOGGER.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`);\n throw new Error('Missing WhatsApp access token.');\n }\n};\n\nexport const importConfig = (inputConfig?: WhatsAppConfig) => {\n emptyConfigChecker(inputConfig);\n\n const wabaConfig: WabaConfigType = {\n [WabaConfigEnum.AppId]: inputConfig?.appId || process.env.M4D_APP_ID || '',\n [WabaConfigEnum.AppSecret]: inputConfig?.appSecret || process.env.M4D_APP_SECRET || '',\n [WabaConfigEnum.PhoneNumberId]: inputConfig?.phoneNumberId || Number(process.env.WA_PHONE_NUMBER_ID),\n [WabaConfigEnum.BusinessAcctId]: inputConfig?.businessAcctId || process.env.WA_BUSINESS_ACCOUNT_ID || '',\n [WabaConfigEnum.APIVersion]: inputConfig?.apiVersion || process.env.CLOUD_API_VERSION || '',\n [WabaConfigEnum.AccessToken]: inputConfig?.accessToken || process.env.CLOUD_API_ACCESS_TOKEN || '',\n [WabaConfigEnum.WebhookEndpoint]: inputConfig?.webhookEndpoint || process.env.WEBHOOK_ENDPOINT || '',\n [WabaConfigEnum.WebhookVerificationToken]:\n inputConfig?.webhookVerificationToken || process.env.WEBHOOK_VERIFICATION_TOKEN || '',\n [WabaConfigEnum.ListenerPort]:\n inputConfig?.listenerPort || parseInt(process.env.LISTENER_PORT || '') || DEFAULT_LISTENER_PORT,\n [WabaConfigEnum.MaxRetriesAfterWait]:\n inputConfig?.maxRetriesAfterWait ||\n parseInt(process.env.MAX_RETRIES_AFTER_WAIT || '') ||\n DEFAULT_MAX_RETRIES_AFTER_WAIT,\n [WabaConfigEnum.RequestTimeout]:\n inputConfig?.requestTimeout || parseInt(process.env.REQUEST_TIMEOUT || '') || DEFAULT_REQUEST_TIMEOUT,\n [WabaConfigEnum.Debug]: inputConfig?.debug || process.env.DEBUG === 'true',\n [WabaConfigEnum.PrivatePem]: inputConfig?.privatePem || process.env.FLOW_API_PRIVATE_PEM || '',\n [WabaConfigEnum.Passphrase]: inputConfig?.passphrase || process.env.FLOW_API_PASSPHRASE || '',\n };\n\n return wabaConfig;\n};\n","import { Agent } from 'https';\n\nimport { HttpMethodsEnum } from '../../types/enums';\nimport { HttpsClientClass, HttpsClientResponseClass, ResponseHeaders, ResponseJSONBody } from '../../types/httpsClient';\nimport Logger from '../logger';\n\nconst LIB_NAME = 'HttpsClient';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class HttpsClient implements HttpsClientClass {\n agent: Agent;\n\n constructor() {\n this.agent = new Agent({ keepAlive: true });\n }\n\n clearSockets(): boolean {\n this.agent.destroy();\n return true;\n }\n\n async sendRequest(\n hostname: string,\n path: string,\n method: HttpMethodsEnum,\n headers: HeadersInit,\n timeout: number,\n body?: BodyInit | null,\n ): Promise<HttpsClientResponseClass> {\n const url = `https://${hostname}/${path}`;\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n try {\n const response = await fetch(url, {\n method,\n headers,\n body,\n signal: controller.signal,\n });\n LOGGER.log(`${method} : ${url} - ${JSON.stringify(response)}`);\n\n clearTimeout(timeoutId);\n return new HttpsClientResponse(response);\n } catch (error) {\n LOGGER.error(`${method} : ${url} - ${JSON.stringify(error)}`);\n throw error;\n }\n }\n}\n\nexport class HttpsClientResponse implements HttpsClientResponseClass {\n res: Response;\n respStatusCode: number;\n respHeaders: ResponseHeaders;\n\n constructor(resp: Response) {\n this.res = resp;\n this.respStatusCode = resp.status;\n this.respHeaders = Object.fromEntries(resp.headers.entries());\n }\n\n statusCode(): number {\n return this.respStatusCode;\n }\n\n headers(): ResponseHeaders {\n return this.respHeaders;\n }\n\n rawResponse(): Response {\n return this.res;\n }\n\n async json(): Promise<ResponseJSONBody> {\n try {\n return (await this.res.json()) as ResponseJSONBody;\n } catch (err) {\n // TODO Error Handling\n throw new Error('Failed to parse response body to JSON: ' + (err as Error).message);\n }\n }\n}\n","import type { HttpMethodsEnum } from '../../types/enums';\nimport type { RequesterClass } from '../../types/request';\nimport { isMetaError, MetaError } from '../isMetaError';\nimport Logger from '../logger';\nimport HttpsClient from './httpsClient';\n\nconst LIB_NAME = 'REQUESTER';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class Requester implements RequesterClass {\n client: Readonly<HttpsClient>;\n accessToken: Readonly<string>;\n phoneNumberId: Readonly<number>;\n businessAcctId: Readonly<string>;\n apiVersion: Readonly<string>;\n userAgent: Readonly<string>;\n host: Readonly<string>;\n protocol: Readonly<string> = 'https:';\n\n constructor(\n apiVersion: string,\n phoneNumberId: number,\n accessToken: string,\n businessAcctId: string,\n userAgent: string,\n ) {\n this.client = new HttpsClient();\n this.host = 'graph.facebook.com';\n this.apiVersion = apiVersion || '22';\n this.phoneNumberId = phoneNumberId;\n this.accessToken = accessToken;\n this.businessAcctId = businessAcctId;\n this.userAgent = userAgent;\n }\n\n buildHeader(contentType: string, additionalHeaders?: Record<string, string>): HeadersInit {\n const headers: HeadersInit = {\n Authorization: `Bearer ${this.accessToken}`,\n 'User-Agent': this.userAgent,\n };\n\n if (contentType !== 'multipart/form-data') {\n headers['Content-Type'] = contentType;\n }\n\n if (additionalHeaders) {\n Object.assign(headers, additionalHeaders);\n }\n\n return headers;\n }\n\n buildCAPIPath(endpoint: string): string {\n return `v${this.apiVersion}.0/${endpoint}`;\n }\n\n async sendRequest(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n body?: any,\n contentType: string = 'application/json',\n additionalHeaders?: Record<string, string>,\n ) {\n let effectiveContentType = contentType;\n\n if (body instanceof FormData) {\n effectiveContentType = 'multipart/form-data';\n } else if (typeof body === 'string' && body.startsWith('<?xml')) {\n effectiveContentType = 'application/xml';\n }\n\n const path = `${this.protocol.toLowerCase()}//${this.host}/${this.buildCAPIPath(endpoint)}`;\n\n LOGGER.log(`${method} : ${path} (${effectiveContentType})`);\n\n try {\n const response = await this.client.sendRequest(\n this.host,\n this.buildCAPIPath(endpoint),\n method,\n this.buildHeader(effectiveContentType, additionalHeaders),\n timeout,\n method === 'POST' || method === 'PUT' ? body : undefined,\n );\n\n if (!response.rawResponse().ok) {\n const errorData = await response.json();\n if (isMetaError(errorData)) {\n throw errorData;\n }\n // If the error doesn't match Meta's format, create a generic MetaError\n throw {\n name: 'MetaError',\n message: 'Unknown error occurred',\n error: {\n message: errorData.message || 'Unknown error occurred',\n type: 'UnknownError',\n code: response.statusCode(),\n fbtrace_id: '',\n },\n } as MetaError;\n }\n\n return response;\n } catch (error) {\n if (isMetaError(error)) {\n throw error;\n }\n // Handle network errors or other unexpected errors\n throw {\n name: 'MetaError',\n message: error instanceof Error ? error.message : 'Network error occurred',\n error: {\n message: error instanceof Error ? error.message : 'Network error occurred',\n type: 'NetworkError',\n code: 500,\n fbtrace_id: '',\n },\n } as MetaError;\n }\n }\n\n async getJson<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n body?: any,\n additionalHeaders?: Record<string, string>,\n ): Promise<T> {\n const res = await this.sendRequest(method, endpoint, timeout, body, 'application/json', additionalHeaders);\n return (await res.json()) as T;\n }\n\n async sendFormData<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n formData: FormData,\n additionalHeaders?: Record<string, string>,\n ): Promise<T> {\n const res = await this.sendRequest(\n method,\n endpoint,\n timeout,\n formData,\n 'multipart/form-data',\n additionalHeaders,\n );\n return (await res.json()) as T;\n }\n\n async sendUrlEncodedForm<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n formData: Record<string, string>,\n additionalHeaders?: Record<string, string>,\n ): Promise<T> {\n const urlEncodedBody = new URLSearchParams(formData).toString();\n const res = await this.sendRequest(\n method,\n endpoint,\n timeout,\n urlEncodedBody,\n 'application/x-www-form-urlencoded',\n additionalHeaders,\n );\n return (await res.json()) as T;\n }\n}\n","export function printLogo() {\n // 테스트 환경에서는 로고를 출력하지 않음\n if (\n process.env.NODE_ENV === 'test' ||\n process.env.VITEST === 'true' ||\n (typeof global !== 'undefined' && (global as any).__VITEST__)\n ) {\n return;\n }\n\n console.log(\n '\\x1b[36m%s\\x1b[0m',\n `\n██████╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ █████╗ ██████╗ ██╗\n██╔════╝ ██║ ██╔═══██╗ ██║ ██║ ██╔══██╗ ██╔══██╗ ██╔══██╗ ██║\n██║ ██║ ██║ ██║ ██║ ██║ ██║ ██║ ███████║ ██████╔╝ ██║\n██║ ██║ ██║ ██║ ██║ ██║ ██║ ██║ ██╔══██║ ██╔═══╝ ██║\n╚██████╗ ███████╗ ╚██████╔╝ ╚██████╔╝ ██████╔╝ ██║ ██║ ██║ ██║\n ╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n`,\n );\n}\n","import { importConfig } from '../../config/importConfig';\nimport { WabaConfigType, WhatsAppConfig } from '../../types/config';\nimport * as SDKEnums from '../../types/enums';\nimport { formatConfigTable } from '../../utils/configTable';\nimport Requester from '../../utils/http/request';\nimport Logger from '../../utils/logger';\nimport { getUserAgent, getVersion } from '../../utils/version';\n\nimport {\n BusinessProfileApi,\n EncryptionApi,\n FlowApi,\n MediaApi,\n MessagesApi,\n PhoneNumberApi,\n QrCodeApi,\n RegistrationApi,\n TemplateApi,\n TwoStepVerificationApi,\n WabaApi,\n} from '../../api';\nimport { printLogo } from '../../utils/logoConsole';\n\nconst LIB_NAME = 'WHATSAPP';\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true');\n\n/**\n * WhatsApp SDK Main Class following official patterns\n * Provides unified access to WhatsApp Cloud API and Flows API\n */\nexport default class WhatsApp {\n config: WabaConfigType;\n requester: Readonly<Requester>;\n messages: MessagesApi;\n media: MediaApi;\n phoneNumbers: PhoneNumberApi;\n twoStepVerification: TwoStepVerificationApi;\n flows: FlowApi;\n businessProfile: BusinessProfileApi;\n templates: TemplateApi;\n encryption: EncryptionApi;\n qrCode: QrCodeApi;\n registration: RegistrationApi;\n waba: WabaApi;\n\n constructor(config?: WhatsAppConfig) {\n printLogo();\n this.config = importConfig(config);\n\n this.requester = new Requester(\n this.config[SDKEnums.WabaConfigEnum.APIVersion],\n this.config[SDKEnums.WabaConfigEnum.PhoneNumberId],\n this.config[SDKEnums.WabaConfigEnum.AccessToken],\n this.config[SDKEnums.WabaConfigEnum.BusinessAcctId],\n this.getUserAgent(),\n );\n\n this.messages = new MessagesApi(this.config, this.requester);\n this.media = new MediaApi(this.config, this.requester);\n this.phoneNumbers = new PhoneNumberApi(this.config, this.requester);\n this.twoStepVerification = new TwoStepVerificationApi(this.config, this.requester);\n this.flows = new FlowApi(this.config, this.requester);\n this.businessProfile = new BusinessProfileApi(this.config, this.requester);\n this.templates = new TemplateApi(this.config, this.requester);\n this.encryption = new EncryptionApi(this.config, this.requester);\n this.qrCode = new QrCodeApi(this.config, this.requester);\n this.registration = new RegistrationApi(this.config, this.requester);\n this.waba = new WabaApi(this.config, this.requester);\n\n LOGGER.log('\\n' + formatConfigTable(this.config));\n }\n\n /**\n * Runtime configuration updates following official patterns\n */\n updateTimeout(timeout: number): void {\n this.config[SDKEnums.WabaConfigEnum.RequestTimeout] = timeout;\n if ('updateTimeout' in this.requester) {\n (this.requester as any).updateTimeout(timeout);\n }\n LOGGER.log(`Timeout updated to ${timeout}ms`);\n }\n\n updateSenderNumberId(phoneNumberId: number): void {\n this.config[SDKEnums.WabaConfigEnum.PhoneNumberId] = phoneNumberId;\n LOGGER.log(`Sender number ID updated to ${phoneNumberId}`);\n }\n\n updateAccessToken(accessToken: string): void {\n this.config[SDKEnums.WabaConfigEnum.AccessToken] = accessToken;\n if ('updateAccessToken' in this.requester) {\n (this.requester as any).updateAccessToken(accessToken);\n }\n LOGGER.log('Access token updated');\n }\n\n /**\n * Get SDK version\n */\n version(): string {\n return getVersion();\n }\n\n /**\n * Static enums access\n */\n static get Enums() {\n return SDKEnums;\n }\n\n /**\n * Get User-Agent string\n */\n getUserAgent(): string {\n return getUserAgent();\n }\n}\n"],"mappings":"w1BAMA,MAAME,EAAS,IAAI,EAFF,QAEmB,QAAQ,IAAI,QAAU,QADxC,GAC4D,CAKxE,EAAsB,GAAuC,CAC/D,GAAI,CAAC,QAAQ,IAAI,EAAe,cAAgB,CAAC,GAAQ,YAErD,MADA,EAAO,IAAI,4FAA4F,CAC7F,MAAM,iCAAiC,EAI5C,EAAgB,IACzB,EAAmB,EAAY,CAEI,EAC9B,EAAe,OAAQ,GAAa,OAAS,QAAQ,IAAI,YAAc,IACvE,EAAe,WAAY,GAAa,WAAa,QAAQ,IAAI,gBAAkB,IACnF,EAAe,eAAgB,GAAa,eAAiB,OAAO,QAAQ,IAAI,mBAAmB,EACnG,EAAe,gBAAiB,GAAa,gBAAkB,QAAQ,IAAI,wBAA0B,IACrG,EAAe,YAAa,GAAa,YAAc,QAAQ,IAAI,mBAAqB,IACxF,EAAe,aAAc,GAAa,aAAe,QAAQ,IAAI,wBAA0B,IAC/F,EAAe,iBAAkB,GAAa,iBAAmB,QAAQ,IAAI,kBAAoB,IACjG,EAAe,0BACZ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E1D,EAAO,IAAI,uBAAuB,CAMtC,SAAkB,CACd,OAAO,GAAY,CAMvB,WAAW,OAAQ,CACf,OAAOC,EAMX,cAAuB,CACnB,OAAO,GAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meta-cloud-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "TypeScript wrapper for Meta's Cloud API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"prepublishOnly": "pnpm build",
|
|
11
11
|
"prepare": "husky",
|
|
12
12
|
"cz": "cz",
|
|
13
|
-
"dev": "
|
|
14
|
-
"build": "
|
|
13
|
+
"dev": "tsdown --watch",
|
|
14
|
+
"build": "tsdown --clean",
|
|
15
15
|
"format": "prettier .",
|
|
16
16
|
"lint": "eslint .",
|
|
17
17
|
"clean": "rm -rf dist node_modules",
|
|
@@ -27,126 +27,27 @@
|
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"exports": {
|
|
30
|
-
".":
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"./api":
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"./api/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"./
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"./
|
|
51
|
-
"types": "./dist/api/media/index.d.ts",
|
|
52
|
-
"import": "./dist/api/media/index.js",
|
|
53
|
-
"default": "./dist/api/media/index.js"
|
|
54
|
-
},
|
|
55
|
-
"./api/flow": {
|
|
56
|
-
"types": "./dist/api/flow/index.d.ts",
|
|
57
|
-
"import": "./dist/api/flow/index.js",
|
|
58
|
-
"default": "./dist/api/flow/index.js"
|
|
59
|
-
},
|
|
60
|
-
"./api/phone": {
|
|
61
|
-
"types": "./dist/api/phone/index.d.ts",
|
|
62
|
-
"import": "./dist/api/phone/index.js",
|
|
63
|
-
"default": "./dist/api/phone/index.js"
|
|
64
|
-
},
|
|
65
|
-
"./api/profile": {
|
|
66
|
-
"types": "./dist/api/profile/index.d.ts",
|
|
67
|
-
"import": "./dist/api/profile/index.js",
|
|
68
|
-
"default": "./dist/api/profile/index.js"
|
|
69
|
-
},
|
|
70
|
-
"./api/template": {
|
|
71
|
-
"types": "./dist/api/template/index.d.ts",
|
|
72
|
-
"import": "./dist/api/template/index.js",
|
|
73
|
-
"default": "./dist/api/template/index.js"
|
|
74
|
-
},
|
|
75
|
-
"./api/qrCode": {
|
|
76
|
-
"types": "./dist/api/qrCode/index.d.ts",
|
|
77
|
-
"import": "./dist/api/qrCode/index.js",
|
|
78
|
-
"default": "./dist/api/qrCode/index.js"
|
|
79
|
-
},
|
|
80
|
-
"./api/registration": {
|
|
81
|
-
"types": "./dist/api/registration/index.d.ts",
|
|
82
|
-
"import": "./dist/api/registration/index.js",
|
|
83
|
-
"default": "./dist/api/registration/index.js"
|
|
84
|
-
},
|
|
85
|
-
"./api/encryption": {
|
|
86
|
-
"types": "./dist/api/encryption/index.d.ts",
|
|
87
|
-
"import": "./dist/api/encryption/index.js",
|
|
88
|
-
"default": "./dist/api/encryption/index.js"
|
|
89
|
-
},
|
|
90
|
-
"./api/twoStepVerification": {
|
|
91
|
-
"types": "./dist/api/twoStepVerification/index.d.ts",
|
|
92
|
-
"import": "./dist/api/twoStepVerification/index.js",
|
|
93
|
-
"default": "./dist/api/twoStepVerification/index.js"
|
|
94
|
-
},
|
|
95
|
-
"./api/waba": {
|
|
96
|
-
"types": "./dist/api/waba/index.d.ts",
|
|
97
|
-
"import": "./dist/api/waba/index.js",
|
|
98
|
-
"default": "./dist/api/waba/index.js"
|
|
99
|
-
},
|
|
100
|
-
"./utils": {
|
|
101
|
-
"types": "./dist/utils/index.d.ts",
|
|
102
|
-
"import": "./dist/utils/index.js",
|
|
103
|
-
"default": "./dist/utils/index.js"
|
|
104
|
-
},
|
|
105
|
-
"./webhook": {
|
|
106
|
-
"types": "./dist/core/webhook/index.d.ts",
|
|
107
|
-
"import": "./dist/core/webhook/index.js",
|
|
108
|
-
"default": "./dist/core/webhook/index.js"
|
|
109
|
-
},
|
|
110
|
-
"./webhook/express": {
|
|
111
|
-
"types": "./dist/core/webhook/frameworks/express.d.ts",
|
|
112
|
-
"import": "./dist/core/webhook/frameworks/express.js",
|
|
113
|
-
"default": "./dist/core/webhook/frameworks/express.js"
|
|
114
|
-
},
|
|
115
|
-
"./webhook/nextjs": {
|
|
116
|
-
"types": "./dist/core/webhook/frameworks/nextjs.d.ts",
|
|
117
|
-
"import": "./dist/core/webhook/frameworks/nextjs.js",
|
|
118
|
-
"default": "./dist/core/webhook/frameworks/nextjs.js"
|
|
119
|
-
},
|
|
120
|
-
"./webhook/nextjs-app": {
|
|
121
|
-
"types": "./dist/core/webhook/frameworks/nextjs-app.d.ts",
|
|
122
|
-
"import": "./dist/core/webhook/frameworks/nextjs-app.js",
|
|
123
|
-
"default": "./dist/core/webhook/frameworks/nextjs-app.js"
|
|
124
|
-
},
|
|
125
|
-
"./types": {
|
|
126
|
-
"types": "./dist/types/index.d.ts",
|
|
127
|
-
"import": "./dist/types/index.js",
|
|
128
|
-
"default": "./dist/types/index.js"
|
|
129
|
-
},
|
|
130
|
-
"./types/enums": {
|
|
131
|
-
"types": "./dist/types/enums.d.ts",
|
|
132
|
-
"import": "./dist/types/enums.js",
|
|
133
|
-
"default": "./dist/types/enums.js"
|
|
134
|
-
},
|
|
135
|
-
"./types/config": {
|
|
136
|
-
"types": "./dist/types/config.d.ts",
|
|
137
|
-
"import": "./dist/types/config.js",
|
|
138
|
-
"default": "./dist/types/config.js"
|
|
139
|
-
},
|
|
140
|
-
"./core/webhook": {
|
|
141
|
-
"types": "./dist/core/webhook/index.d.ts",
|
|
142
|
-
"import": "./dist/core/webhook/index.js",
|
|
143
|
-
"default": "./dist/core/webhook/index.js"
|
|
144
|
-
},
|
|
145
|
-
"./core/whatsapp": {
|
|
146
|
-
"types": "./dist/core/whatsapp/index.d.ts",
|
|
147
|
-
"import": "./dist/core/whatsapp/index.js",
|
|
148
|
-
"default": "./dist/core/whatsapp/index.js"
|
|
149
|
-
},
|
|
30
|
+
".": "./dist/index.js",
|
|
31
|
+
"./api": "./dist/api/index.js",
|
|
32
|
+
"./api/encryption": "./dist/api/encryption/index.js",
|
|
33
|
+
"./api/flow": "./dist/api/flow/index.js",
|
|
34
|
+
"./api/media": "./dist/api/media/index.js",
|
|
35
|
+
"./api/messages": "./dist/api/messages/index.js",
|
|
36
|
+
"./api/messages/builders": "./dist/api/messages/builders/index.js",
|
|
37
|
+
"./api/phone": "./dist/api/phone/index.js",
|
|
38
|
+
"./api/profile": "./dist/api/profile/index.js",
|
|
39
|
+
"./api/qrCode": "./dist/api/qrCode/index.js",
|
|
40
|
+
"./api/registration": "./dist/api/registration/index.js",
|
|
41
|
+
"./api/template": "./dist/api/template/index.js",
|
|
42
|
+
"./api/twoStepVerification": "./dist/api/twoStepVerification/index.js",
|
|
43
|
+
"./api/waba": "./dist/api/waba/index.js",
|
|
44
|
+
"./core/webhook": "./dist/core/webhook/index.js",
|
|
45
|
+
"./core/webhook/frameworks/express": "./dist/core/webhook/frameworks/express.js",
|
|
46
|
+
"./core/webhook/frameworks/nextjs": "./dist/core/webhook/frameworks/nextjs.js",
|
|
47
|
+
"./core/webhook/frameworks/nextjs-app": "./dist/core/webhook/frameworks/nextjs-app.js",
|
|
48
|
+
"./core/whatsapp": "./dist/core/whatsapp/index.js",
|
|
49
|
+
"./types": "./dist/types/index.js",
|
|
50
|
+
"./utils": "./dist/utils/index.js",
|
|
150
51
|
"./package.json": "./package.json"
|
|
151
52
|
},
|
|
152
53
|
"keywords": [
|
|
@@ -215,7 +116,7 @@
|
|
|
215
116
|
"lint-staged": "^15.3.0",
|
|
216
117
|
"next": "^15.3.5",
|
|
217
118
|
"prettier": "^3.5.0",
|
|
218
|
-
"
|
|
119
|
+
"tsdown": "^0.15.0",
|
|
219
120
|
"typescript": "^5.7.3",
|
|
220
121
|
"typescript-eslint": "^8.23.0",
|
|
221
122
|
"vitest": "^2.1.8"
|
|
@@ -230,5 +131,6 @@
|
|
|
230
131
|
"commitizen": {
|
|
231
132
|
"path": "@commitlint/cz-commitlint"
|
|
232
133
|
}
|
|
233
|
-
}
|
|
134
|
+
},
|
|
135
|
+
"module": "./dist/index.js"
|
|
234
136
|
}
|