meta-cloud-api 0.0.1-beta.0 → 0.0.2
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/api/base.d.mts +12 -0
- package/dist/api/base.d.ts +12 -0
- package/dist/api/base.js +2 -0
- package/dist/api/base.js.map +1 -0
- package/dist/api/base.mjs +2 -0
- package/dist/api/base.mjs.map +1 -0
- package/dist/api/encryption.d.mts +15 -0
- package/dist/api/encryption.d.ts +15 -0
- package/dist/api/encryption.js +2 -0
- package/dist/api/encryption.js.map +1 -0
- package/dist/api/encryption.mjs +2 -0
- package/dist/api/encryption.mjs.map +1 -0
- package/dist/api/flow.d.mts +114 -0
- package/dist/api/flow.d.ts +114 -0
- package/dist/api/flow.js +2 -0
- package/dist/api/flow.js.map +1 -0
- package/dist/api/flow.mjs +2 -0
- package/dist/api/flow.mjs.map +1 -0
- package/dist/api/index.d.mts +25 -0
- package/dist/api/index.d.ts +25 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.mjs +2 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/api/media.d.mts +17 -0
- package/dist/api/media.d.ts +17 -0
- package/dist/api/media.js +2 -0
- package/dist/api/media.js.map +1 -0
- package/dist/api/media.mjs +2 -0
- package/dist/api/media.mjs.map +1 -0
- package/dist/api/messages.d.mts +27 -0
- package/dist/api/messages.d.ts +27 -0
- package/dist/api/messages.js +2 -0
- package/dist/api/messages.js.map +1 -0
- package/dist/api/messages.mjs +2 -0
- package/dist/api/messages.mjs.map +1 -0
- package/dist/api/phoneNumber.d.mts +17 -0
- package/dist/api/phoneNumber.d.ts +17 -0
- package/dist/api/phoneNumber.js +2 -0
- package/dist/api/phoneNumber.js.map +1 -0
- package/dist/api/phoneNumber.mjs +2 -0
- package/dist/api/phoneNumber.mjs.map +1 -0
- package/dist/api/qrCode.d.mts +18 -0
- package/dist/api/qrCode.d.ts +18 -0
- package/dist/api/qrCode.js +2 -0
- package/dist/api/qrCode.js.map +1 -0
- package/dist/api/qrCode.mjs +2 -0
- package/dist/api/qrCode.mjs.map +1 -0
- package/dist/api/registration.d.mts +14 -0
- package/dist/api/registration.d.ts +14 -0
- package/dist/api/registration.js +2 -0
- package/dist/api/registration.js.map +1 -0
- package/dist/api/registration.mjs +2 -0
- package/dist/api/registration.mjs.map +1 -0
- package/dist/api/template.d.mts +18 -0
- package/dist/api/template.d.ts +18 -0
- package/dist/api/template.js +2 -0
- package/dist/api/template.js.map +1 -0
- package/dist/api/template.mjs +2 -0
- package/dist/api/template.mjs.map +1 -0
- package/dist/api/twoStepVerification.d.mts +13 -0
- package/dist/api/twoStepVerification.d.ts +13 -0
- package/dist/api/twoStepVerification.js +2 -0
- package/dist/api/twoStepVerification.js.map +1 -0
- package/dist/api/twoStepVerification.mjs +2 -0
- package/dist/api/twoStepVerification.mjs.map +1 -0
- package/dist/api/waba.d.mts +16 -0
- package/dist/api/waba.d.ts +16 -0
- package/dist/api/waba.js +2 -0
- package/dist/api/waba.js.map +1 -0
- package/dist/api/waba.mjs +2 -0
- package/dist/api/waba.mjs.map +1 -0
- package/dist/enums-D6WRUWH9.d.mts +585 -0
- package/dist/enums-D6WRUWH9.d.ts +585 -0
- package/dist/httpsClient.d.mts +22 -0
- package/dist/httpsClient.d.ts +22 -0
- package/dist/httpsClient.js +2 -0
- package/dist/httpsClient.js.map +1 -0
- package/dist/httpsClient.mjs +2 -0
- package/dist/httpsClient.mjs.map +1 -0
- package/dist/index.d.mts +35 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/request.d.mts +22 -0
- package/dist/request.d.ts +22 -0
- package/dist/request.js +2 -0
- package/dist/request.js.map +1 -0
- package/dist/request.mjs +2 -0
- package/dist/request.mjs.map +1 -0
- package/dist/types/base.d.mts +8 -0
- package/dist/types/base.d.ts +8 -0
- package/dist/types/base.js +2 -0
- package/dist/types/base.js.map +1 -0
- package/dist/types/base.mjs +1 -0
- package/dist/types/base.mjs.map +1 -0
- package/dist/types/config.d.mts +59 -0
- package/dist/types/config.d.ts +59 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/config.mjs +1 -0
- package/dist/types/config.mjs.map +1 -0
- package/dist/types/encryption.d.mts +13 -0
- package/dist/types/encryption.d.ts +13 -0
- package/dist/types/encryption.js +2 -0
- package/dist/types/encryption.js.map +1 -0
- package/dist/types/encryption.mjs +1 -0
- package/dist/types/encryption.mjs.map +1 -0
- package/dist/types/enums.d.mts +1 -0
- package/dist/types/enums.d.ts +1 -0
- package/dist/types/enums.js +2 -0
- package/dist/types/enums.js.map +1 -0
- package/dist/types/enums.mjs +2 -0
- package/dist/types/enums.mjs.map +1 -0
- package/dist/types/flow.d.mts +245 -0
- package/dist/types/flow.d.ts +245 -0
- package/dist/types/flow.js +2 -0
- package/dist/types/flow.js.map +1 -0
- package/dist/types/flow.mjs +2 -0
- package/dist/types/flow.mjs.map +1 -0
- package/dist/types/httpsClient.d.mts +19 -0
- package/dist/types/httpsClient.d.ts +19 -0
- package/dist/types/httpsClient.js +2 -0
- package/dist/types/httpsClient.js.map +1 -0
- package/dist/types/httpsClient.mjs +1 -0
- package/dist/types/httpsClient.mjs.map +1 -0
- package/dist/types/index.d.mts +16 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/logger.d.mts +9 -0
- package/dist/types/logger.d.ts +9 -0
- package/dist/types/logger.js +2 -0
- package/dist/types/logger.js.map +1 -0
- package/dist/types/logger.mjs +1 -0
- package/dist/types/logger.mjs.map +1 -0
- package/dist/types/media.d.mts +31 -0
- package/dist/types/media.d.ts +31 -0
- package/dist/types/media.js +2 -0
- package/dist/types/media.js.map +1 -0
- package/dist/types/media.mjs +1 -0
- package/dist/types/media.mjs.map +1 -0
- package/dist/types/messages.d.mts +322 -0
- package/dist/types/messages.d.ts +322 -0
- package/dist/types/messages.js +2 -0
- package/dist/types/messages.js.map +1 -0
- package/dist/types/messages.mjs +1 -0
- package/dist/types/messages.mjs.map +1 -0
- package/dist/types/phoneNumber.d.mts +82 -0
- package/dist/types/phoneNumber.d.ts +82 -0
- package/dist/types/phoneNumber.js +2 -0
- package/dist/types/phoneNumber.js.map +1 -0
- package/dist/types/phoneNumber.mjs +1 -0
- package/dist/types/phoneNumber.mjs.map +1 -0
- package/dist/types/qrCode.d.mts +27 -0
- package/dist/types/qrCode.d.ts +27 -0
- package/dist/types/qrCode.js +2 -0
- package/dist/types/qrCode.js.map +1 -0
- package/dist/types/qrCode.mjs +1 -0
- package/dist/types/qrCode.mjs.map +1 -0
- package/dist/types/registration.d.mts +14 -0
- package/dist/types/registration.d.ts +14 -0
- package/dist/types/registration.js +2 -0
- package/dist/types/registration.js.map +1 -0
- package/dist/types/registration.mjs +1 -0
- package/dist/types/registration.mjs.map +1 -0
- package/dist/types/request.d.mts +47 -0
- package/dist/types/request.d.ts +47 -0
- package/dist/types/request.js +2 -0
- package/dist/types/request.js.map +1 -0
- package/dist/types/request.mjs +1 -0
- package/dist/types/request.mjs.map +1 -0
- package/dist/types/template.d.mts +106 -0
- package/dist/types/template.d.ts +106 -0
- package/dist/types/template.js +2 -0
- package/dist/types/template.js.map +1 -0
- package/dist/types/template.mjs +1 -0
- package/dist/types/template.mjs.map +1 -0
- package/dist/types/twoStepVerification.d.mts +11 -0
- package/dist/types/twoStepVerification.d.ts +11 -0
- package/dist/types/twoStepVerification.js +2 -0
- package/dist/types/twoStepVerification.js.map +1 -0
- package/dist/types/twoStepVerification.mjs +1 -0
- package/dist/types/twoStepVerification.mjs.map +1 -0
- package/dist/types/waba.d.mts +19 -0
- package/dist/types/waba.d.ts +19 -0
- package/dist/types/waba.js +2 -0
- package/dist/types/waba.js.map +1 -0
- package/dist/types/waba.mjs +1 -0
- package/dist/types/waba.mjs.map +1 -0
- package/dist/types/whatsapp.d.mts +31 -0
- package/dist/types/whatsapp.d.ts +31 -0
- package/dist/types/whatsapp.js +2 -0
- package/dist/types/whatsapp.js.map +1 -0
- package/dist/types/whatsapp.mjs +1 -0
- package/dist/types/whatsapp.mjs.map +1 -0
- package/dist/utils/generateXHub256Sig.d.mts +3 -0
- package/dist/utils/generateXHub256Sig.d.ts +3 -0
- package/dist/utils/generateXHub256Sig.js +2 -0
- package/dist/utils/generateXHub256Sig.js.map +1 -0
- package/dist/utils/generateXHub256Sig.mjs +2 -0
- package/dist/utils/generateXHub256Sig.mjs.map +1 -0
- package/dist/utils/importConfig.d.mts +7 -0
- package/dist/utils/importConfig.d.ts +7 -0
- package/dist/utils/importConfig.js +2 -0
- package/dist/utils/importConfig.js.map +1 -0
- package/dist/utils/importConfig.mjs +2 -0
- package/dist/utils/importConfig.mjs.map +1 -0
- package/dist/utils/index.d.mts +5 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +2 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/isMetaError.d.mts +21 -0
- package/dist/utils/isMetaError.d.ts +21 -0
- package/dist/utils/isMetaError.js +2 -0
- package/dist/utils/isMetaError.js.map +1 -0
- package/dist/utils/isMetaError.mjs +2 -0
- package/dist/utils/isMetaError.mjs.map +1 -0
- package/dist/utils/logger.d.mts +13 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.js +2 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/logger.mjs +2 -0
- package/dist/utils/logger.mjs.map +1 -0
- package/dist/utils/objectToQueryString.d.mts +3 -0
- package/dist/utils/objectToQueryString.d.ts +3 -0
- package/dist/utils/objectToQueryString.js +2 -0
- package/dist/utils/objectToQueryString.js.map +1 -0
- package/dist/utils/objectToQueryString.mjs +2 -0
- package/dist/utils/objectToQueryString.mjs.map +1 -0
- package/dist/whatsapp.d.mts +54 -0
- package/dist/whatsapp.d.ts +54 -0
- package/dist/whatsapp.js +2 -0
- package/dist/whatsapp.js.map +1 -0
- package/dist/whatsapp.mjs +2 -0
- package/dist/whatsapp.mjs.map +1 -0
- package/package.json +51 -7
- package/src/api/base.ts +19 -0
- package/src/api/encryption.ts +34 -0
- package/src/api/flow.ts +253 -0
- package/src/api/index.ts +24 -0
- package/src/api/media.ts +52 -0
- package/src/api/messages.ts +160 -0
- package/src/api/phoneNumber.ts +59 -0
- package/src/api/qrCode.ts +64 -0
- package/src/api/registration.ts +38 -0
- package/src/api/template.ts +70 -0
- package/src/api/twoStepVerification.ts +24 -0
- package/src/api/waba.ts +55 -0
- package/src/httpsClient.ts +83 -0
- package/src/index.ts +3 -0
- package/src/request.ts +104 -0
- package/src/types/base.ts +5 -0
- package/src/types/config.ts +68 -0
- package/src/types/encryption.ts +11 -0
- package/src/types/enums.ts +563 -0
- package/src/types/flow.ts +274 -0
- package/src/types/httpsClient.ts +28 -0
- package/src/types/index.ts +16 -0
- package/src/types/logger.ts +7 -0
- package/src/types/media.ts +31 -0
- package/src/types/messages.ts +453 -0
- package/src/types/phoneNumber.ts +111 -0
- package/src/types/qrCode.ts +30 -0
- package/src/types/registration.ts +17 -0
- package/src/types/request.ts +66 -0
- package/src/types/template.ts +134 -0
- package/src/types/twoStepVerification.ts +9 -0
- package/src/types/waba.ts +18 -0
- package/src/types/whatsapp.ts +31 -0
- package/src/utils/.gitkeep +0 -0
- package/src/utils/generateXHub256Sig.ts +5 -0
- package/src/utils/importConfig.ts +55 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/isMetaError.ts +44 -0
- package/src/utils/logger.ts +46 -0
- package/src/utils/objectToQueryString.ts +16 -0
- package/src/whatsapp.ts +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { H as HttpMethodsEnum } from '../enums-D6WRUWH9.mjs';
|
|
2
|
+
|
|
3
|
+
type GeneralRequestBody = Record<string, any>;
|
|
4
|
+
interface GeneralHeaderInterface {
|
|
5
|
+
/**
|
|
6
|
+
* Authorization token. This is required for all HTTP requests made to the graph API.
|
|
7
|
+
* @default 'Bearer '
|
|
8
|
+
*/
|
|
9
|
+
Authorization: string;
|
|
10
|
+
/**
|
|
11
|
+
* Content type of the message being sent. This is required for all HTTP requests made to the graph API.
|
|
12
|
+
* @default 'application/json'
|
|
13
|
+
*/
|
|
14
|
+
'Content-Type': string;
|
|
15
|
+
/**
|
|
16
|
+
* User agent field sent in all requests. This is used to gather SDK usage metrics and help
|
|
17
|
+
* better triage support requests.
|
|
18
|
+
* @default `WA_SDK/${ SDK_version } (Node.js ${ process.version })`
|
|
19
|
+
*/
|
|
20
|
+
'User-Agent': string;
|
|
21
|
+
}
|
|
22
|
+
interface RequesterResponseInterface<T> {
|
|
23
|
+
json: () => Promise<T>;
|
|
24
|
+
}
|
|
25
|
+
interface ResponseSuccess {
|
|
26
|
+
success: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface ResponseData<T> {
|
|
29
|
+
data: T;
|
|
30
|
+
}
|
|
31
|
+
interface ResponsePagination<T> {
|
|
32
|
+
data: T[];
|
|
33
|
+
paging: Paging;
|
|
34
|
+
}
|
|
35
|
+
interface Paging {
|
|
36
|
+
cursors: {
|
|
37
|
+
before: string;
|
|
38
|
+
after: string;
|
|
39
|
+
};
|
|
40
|
+
next: string;
|
|
41
|
+
}
|
|
42
|
+
declare class RequesterClass {
|
|
43
|
+
constructor(host: string, apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
|
|
44
|
+
sendRequest: (method: HttpMethodsEnum, path: string, timeout: number, body?: any) => Promise<RequesterResponseInterface<any>>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { type GeneralHeaderInterface, type GeneralRequestBody, type Paging, RequesterClass, type RequesterResponseInterface, type ResponseData, type ResponsePagination, type ResponseSuccess };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { H as HttpMethodsEnum } from '../enums-D6WRUWH9.js';
|
|
2
|
+
|
|
3
|
+
type GeneralRequestBody = Record<string, any>;
|
|
4
|
+
interface GeneralHeaderInterface {
|
|
5
|
+
/**
|
|
6
|
+
* Authorization token. This is required for all HTTP requests made to the graph API.
|
|
7
|
+
* @default 'Bearer '
|
|
8
|
+
*/
|
|
9
|
+
Authorization: string;
|
|
10
|
+
/**
|
|
11
|
+
* Content type of the message being sent. This is required for all HTTP requests made to the graph API.
|
|
12
|
+
* @default 'application/json'
|
|
13
|
+
*/
|
|
14
|
+
'Content-Type': string;
|
|
15
|
+
/**
|
|
16
|
+
* User agent field sent in all requests. This is used to gather SDK usage metrics and help
|
|
17
|
+
* better triage support requests.
|
|
18
|
+
* @default `WA_SDK/${ SDK_version } (Node.js ${ process.version })`
|
|
19
|
+
*/
|
|
20
|
+
'User-Agent': string;
|
|
21
|
+
}
|
|
22
|
+
interface RequesterResponseInterface<T> {
|
|
23
|
+
json: () => Promise<T>;
|
|
24
|
+
}
|
|
25
|
+
interface ResponseSuccess {
|
|
26
|
+
success: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface ResponseData<T> {
|
|
29
|
+
data: T;
|
|
30
|
+
}
|
|
31
|
+
interface ResponsePagination<T> {
|
|
32
|
+
data: T[];
|
|
33
|
+
paging: Paging;
|
|
34
|
+
}
|
|
35
|
+
interface Paging {
|
|
36
|
+
cursors: {
|
|
37
|
+
before: string;
|
|
38
|
+
after: string;
|
|
39
|
+
};
|
|
40
|
+
next: string;
|
|
41
|
+
}
|
|
42
|
+
declare class RequesterClass {
|
|
43
|
+
constructor(host: string, apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
|
|
44
|
+
sendRequest: (method: HttpMethodsEnum, path: string, timeout: number, body?: any) => Promise<RequesterResponseInterface<any>>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { type GeneralHeaderInterface, type GeneralRequestBody, type Paging, RequesterClass, type RequesterResponseInterface, type ResponseData, type ResponsePagination, type ResponseSuccess };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var g=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!c.call(t,n)&&n!==o&&s(t,n,{get:()=>e[n],enumerable:!(r=a(e,n))||r.enumerable});return t};var p=t=>g(s({},"__esModule",{value:!0}),t);var u={};module.exports=p(u);
|
|
2
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/request.ts"],"sourcesContent":["import { HttpMethodsEnum } from './enums';\n\nexport type GeneralRequestBody = Record<string, any>;\n\nexport interface GeneralHeaderInterface {\n /**\n * Authorization token. This is required for all HTTP requests made to the graph API.\n * @default 'Bearer '\n */\n Authorization: string;\n\n /**\n * Content type of the message being sent. This is required for all HTTP requests made to the graph API.\n * @default 'application/json'\n */\n 'Content-Type': string;\n\n /**\n * User agent field sent in all requests. This is used to gather SDK usage metrics and help\n * better triage support requests.\n * @default `WA_SDK/${ SDK_version } (Node.js ${ process.version })`\n */\n 'User-Agent': string;\n}\n\nexport interface RequesterResponseInterface<T> {\n json: () => Promise<T>;\n}\n\nexport interface ResponseSuccess {\n success: boolean;\n}\n\nexport interface ResponseData<T> {\n data: T;\n}\n\nexport interface ResponsePagination<T> {\n data: T[];\n paging: Paging;\n}\n\nexport interface Paging {\n cursors: {\n before: string;\n after: string;\n };\n next: string;\n}\n\nexport declare class RequesterClass {\n constructor(\n host: string,\n apiVersion: string,\n phoneNumberId: number,\n accessToken: string,\n businessAcctId: string,\n userAgent: string,\n );\n sendRequest: (\n method: HttpMethodsEnum,\n path: string,\n timeout: number,\n body?: any,\n ) => Promise<RequesterResponseInterface<any>>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["request_exports","__toCommonJS"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=request.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-D6WRUWH9.mjs';
|
|
2
|
+
import { RequesterResponseInterface, GeneralRequestBody, ResponseSuccess, ResponsePagination } from './request.mjs';
|
|
3
|
+
|
|
4
|
+
type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION';
|
|
5
|
+
type PhoneNumberButton = {
|
|
6
|
+
type: 'PHONE_NUMBER';
|
|
7
|
+
text: string;
|
|
8
|
+
phone_number: string;
|
|
9
|
+
};
|
|
10
|
+
type URLButton = {
|
|
11
|
+
type: 'URL';
|
|
12
|
+
text: string;
|
|
13
|
+
url: string;
|
|
14
|
+
example?: string[];
|
|
15
|
+
};
|
|
16
|
+
type QuickReplyButton = {
|
|
17
|
+
type: 'QUICK_REPLY';
|
|
18
|
+
text: string;
|
|
19
|
+
};
|
|
20
|
+
type CopyCodeButton = {
|
|
21
|
+
type: 'COPY_CODE';
|
|
22
|
+
example: string;
|
|
23
|
+
};
|
|
24
|
+
type FlowButton = {
|
|
25
|
+
type: 'FLOW';
|
|
26
|
+
text: string;
|
|
27
|
+
flow_id?: string;
|
|
28
|
+
flow_name?: string;
|
|
29
|
+
flow_json?: string;
|
|
30
|
+
flow_action?: 'navigate' | 'data_exchange';
|
|
31
|
+
navigate_screen?: string;
|
|
32
|
+
};
|
|
33
|
+
type MPMButton = {
|
|
34
|
+
type: 'MPM';
|
|
35
|
+
};
|
|
36
|
+
type OTPButton = {
|
|
37
|
+
type: 'OTP';
|
|
38
|
+
};
|
|
39
|
+
type SPMButton = {
|
|
40
|
+
type: 'SPM';
|
|
41
|
+
};
|
|
42
|
+
type TemplateButton = PhoneNumberButton | URLButton | QuickReplyButton | CopyCodeButton | FlowButton | MPMButton | OTPButton | SPMButton;
|
|
43
|
+
type TemplateHeaderExample = {
|
|
44
|
+
header_text?: string[];
|
|
45
|
+
header_text_named_params?: Array<{
|
|
46
|
+
param_name: string;
|
|
47
|
+
example: string;
|
|
48
|
+
}>;
|
|
49
|
+
header_handle?: string[];
|
|
50
|
+
};
|
|
51
|
+
type TemplateHeader = {
|
|
52
|
+
type: 'HEADER';
|
|
53
|
+
format: TemplateFormat;
|
|
54
|
+
text?: string;
|
|
55
|
+
example?: TemplateHeaderExample;
|
|
56
|
+
};
|
|
57
|
+
type TemplateBody = {
|
|
58
|
+
type: 'BODY';
|
|
59
|
+
text: string;
|
|
60
|
+
example?: {
|
|
61
|
+
body_text?: Array<Array<string>>;
|
|
62
|
+
body_text_named_params?: Array<{
|
|
63
|
+
param_name: string;
|
|
64
|
+
example: string;
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
type TemplateFooter = {
|
|
69
|
+
type: 'FOOTER';
|
|
70
|
+
text: string;
|
|
71
|
+
};
|
|
72
|
+
type ComponentTypes = TemplateHeader | TemplateBody | TemplateFooter | TemplateButton;
|
|
73
|
+
type TemplateRequestBody = GeneralRequestBody & {
|
|
74
|
+
name: string;
|
|
75
|
+
language: LanguagesEnum;
|
|
76
|
+
category?: CategoryEnum;
|
|
77
|
+
components?: ComponentTypes[];
|
|
78
|
+
};
|
|
79
|
+
type TemplateResponse = {
|
|
80
|
+
id: string;
|
|
81
|
+
status: string;
|
|
82
|
+
language: LanguagesEnum;
|
|
83
|
+
category: CategoryEnum;
|
|
84
|
+
name: string;
|
|
85
|
+
components: ComponentTypes[];
|
|
86
|
+
};
|
|
87
|
+
type TemplateGetParams = {
|
|
88
|
+
limit?: number;
|
|
89
|
+
name?: string;
|
|
90
|
+
language?: LanguagesEnum;
|
|
91
|
+
category?: CategoryEnum;
|
|
92
|
+
status?: TemplateStatusEnum;
|
|
93
|
+
};
|
|
94
|
+
type TemplateDeleteParams = {
|
|
95
|
+
hsm_id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
};
|
|
98
|
+
declare class TemplateClass {
|
|
99
|
+
getTemplate(templateId: string): Promise<RequesterResponseInterface<TemplateResponse>>;
|
|
100
|
+
updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
101
|
+
getTemplates(params: TemplateGetParams): Promise<RequesterResponseInterface<ResponsePagination<TemplateResponse>>>;
|
|
102
|
+
createTemplate(template: TemplateRequestBody): Promise<RequesterResponseInterface<TemplateResponse>>;
|
|
103
|
+
deleteTemplate(params: TemplateDeleteParams): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { type ComponentTypes, type CopyCodeButton, type FlowButton, type MPMButton, type OTPButton, type PhoneNumberButton, type QuickReplyButton, type SPMButton, type TemplateBody, type TemplateButton, TemplateClass, type TemplateDeleteParams, type TemplateFooter, type TemplateFormat, type TemplateGetParams, type TemplateHeader, type TemplateHeaderExample, type TemplateRequestBody, type TemplateResponse, type URLButton };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-D6WRUWH9.js';
|
|
2
|
+
import { RequesterResponseInterface, GeneralRequestBody, ResponseSuccess, ResponsePagination } from './request.js';
|
|
3
|
+
|
|
4
|
+
type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION';
|
|
5
|
+
type PhoneNumberButton = {
|
|
6
|
+
type: 'PHONE_NUMBER';
|
|
7
|
+
text: string;
|
|
8
|
+
phone_number: string;
|
|
9
|
+
};
|
|
10
|
+
type URLButton = {
|
|
11
|
+
type: 'URL';
|
|
12
|
+
text: string;
|
|
13
|
+
url: string;
|
|
14
|
+
example?: string[];
|
|
15
|
+
};
|
|
16
|
+
type QuickReplyButton = {
|
|
17
|
+
type: 'QUICK_REPLY';
|
|
18
|
+
text: string;
|
|
19
|
+
};
|
|
20
|
+
type CopyCodeButton = {
|
|
21
|
+
type: 'COPY_CODE';
|
|
22
|
+
example: string;
|
|
23
|
+
};
|
|
24
|
+
type FlowButton = {
|
|
25
|
+
type: 'FLOW';
|
|
26
|
+
text: string;
|
|
27
|
+
flow_id?: string;
|
|
28
|
+
flow_name?: string;
|
|
29
|
+
flow_json?: string;
|
|
30
|
+
flow_action?: 'navigate' | 'data_exchange';
|
|
31
|
+
navigate_screen?: string;
|
|
32
|
+
};
|
|
33
|
+
type MPMButton = {
|
|
34
|
+
type: 'MPM';
|
|
35
|
+
};
|
|
36
|
+
type OTPButton = {
|
|
37
|
+
type: 'OTP';
|
|
38
|
+
};
|
|
39
|
+
type SPMButton = {
|
|
40
|
+
type: 'SPM';
|
|
41
|
+
};
|
|
42
|
+
type TemplateButton = PhoneNumberButton | URLButton | QuickReplyButton | CopyCodeButton | FlowButton | MPMButton | OTPButton | SPMButton;
|
|
43
|
+
type TemplateHeaderExample = {
|
|
44
|
+
header_text?: string[];
|
|
45
|
+
header_text_named_params?: Array<{
|
|
46
|
+
param_name: string;
|
|
47
|
+
example: string;
|
|
48
|
+
}>;
|
|
49
|
+
header_handle?: string[];
|
|
50
|
+
};
|
|
51
|
+
type TemplateHeader = {
|
|
52
|
+
type: 'HEADER';
|
|
53
|
+
format: TemplateFormat;
|
|
54
|
+
text?: string;
|
|
55
|
+
example?: TemplateHeaderExample;
|
|
56
|
+
};
|
|
57
|
+
type TemplateBody = {
|
|
58
|
+
type: 'BODY';
|
|
59
|
+
text: string;
|
|
60
|
+
example?: {
|
|
61
|
+
body_text?: Array<Array<string>>;
|
|
62
|
+
body_text_named_params?: Array<{
|
|
63
|
+
param_name: string;
|
|
64
|
+
example: string;
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
type TemplateFooter = {
|
|
69
|
+
type: 'FOOTER';
|
|
70
|
+
text: string;
|
|
71
|
+
};
|
|
72
|
+
type ComponentTypes = TemplateHeader | TemplateBody | TemplateFooter | TemplateButton;
|
|
73
|
+
type TemplateRequestBody = GeneralRequestBody & {
|
|
74
|
+
name: string;
|
|
75
|
+
language: LanguagesEnum;
|
|
76
|
+
category?: CategoryEnum;
|
|
77
|
+
components?: ComponentTypes[];
|
|
78
|
+
};
|
|
79
|
+
type TemplateResponse = {
|
|
80
|
+
id: string;
|
|
81
|
+
status: string;
|
|
82
|
+
language: LanguagesEnum;
|
|
83
|
+
category: CategoryEnum;
|
|
84
|
+
name: string;
|
|
85
|
+
components: ComponentTypes[];
|
|
86
|
+
};
|
|
87
|
+
type TemplateGetParams = {
|
|
88
|
+
limit?: number;
|
|
89
|
+
name?: string;
|
|
90
|
+
language?: LanguagesEnum;
|
|
91
|
+
category?: CategoryEnum;
|
|
92
|
+
status?: TemplateStatusEnum;
|
|
93
|
+
};
|
|
94
|
+
type TemplateDeleteParams = {
|
|
95
|
+
hsm_id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
};
|
|
98
|
+
declare class TemplateClass {
|
|
99
|
+
getTemplate(templateId: string): Promise<RequesterResponseInterface<TemplateResponse>>;
|
|
100
|
+
updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
101
|
+
getTemplates(params: TemplateGetParams): Promise<RequesterResponseInterface<ResponsePagination<TemplateResponse>>>;
|
|
102
|
+
createTemplate(template: TemplateRequestBody): Promise<RequesterResponseInterface<TemplateResponse>>;
|
|
103
|
+
deleteTemplate(params: TemplateDeleteParams): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { type ComponentTypes, type CopyCodeButton, type FlowButton, type MPMButton, type OTPButton, type PhoneNumberButton, type QuickReplyButton, type SPMButton, type TemplateBody, type TemplateButton, TemplateClass, type TemplateDeleteParams, type TemplateFooter, type TemplateFormat, type TemplateGetParams, type TemplateHeader, type TemplateHeaderExample, type TemplateRequestBody, type TemplateResponse, type URLButton };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var l=(t,e,r,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of o(e))!m.call(t,a)&&a!==r&&n(t,a,{get:()=>e[a],enumerable:!(p=s(e,a))||p.enumerable});return t};var u=t=>l(n({},"__esModule",{value:!0}),t);var g={};module.exports=u(g);
|
|
2
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/template.ts"],"sourcesContent":["import { CategoryEnum, LanguagesEnum, TemplateStatusEnum } from './enums';\nimport { GeneralRequestBody, RequesterResponseInterface, ResponsePagination, ResponseSuccess } from './request';\n\nexport type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION';\n\nexport type PhoneNumberButton = {\n type: 'PHONE_NUMBER';\n text: string; // max 25 chars\n phone_number: string; // max 20 chars\n};\n\nexport type URLButton = {\n type: 'URL';\n text: string; // max 25 chars\n url: string; // max 2000 chars\n example?: string[]; // Required if url contains variable\n};\n\nexport type QuickReplyButton = {\n type: 'QUICK_REPLY';\n text: string; // max 25 chars\n};\n\nexport type CopyCodeButton = {\n type: 'COPY_CODE';\n example: string; // max 15 chars\n};\n\nexport type FlowButton = {\n type: 'FLOW';\n text: string; // max 25 chars\n flow_id?: string;\n flow_name?: string;\n flow_json?: string;\n flow_action?: 'navigate' | 'data_exchange';\n navigate_screen?: string;\n};\n\nexport type MPMButton = {\n type: 'MPM';\n};\n\nexport type OTPButton = {\n type: 'OTP';\n};\n\nexport type SPMButton = {\n type: 'SPM';\n};\n\nexport type TemplateButton =\n | PhoneNumberButton\n | URLButton\n | QuickReplyButton\n | CopyCodeButton\n | FlowButton\n | MPMButton\n | OTPButton\n | SPMButton;\n\nexport type TemplateHeaderExample = {\n header_text?: string[];\n header_text_named_params?: Array<{\n param_name: string;\n example: string;\n }>;\n header_handle?: string[];\n};\n\nexport type TemplateHeader = {\n type: 'HEADER';\n format: TemplateFormat;\n text?: string; // max 60 chars\n example?: TemplateHeaderExample;\n};\n\nexport type TemplateBody = {\n type: 'BODY';\n text: string; // max 1024 chars\n example?: {\n body_text?: Array<Array<string>>; // For positional parameters\n body_text_named_params?: Array<{\n param_name: string; // lowercase letters and underscores only\n example: string;\n }>; // For named parameters\n };\n};\n\nexport type TemplateFooter = {\n type: 'FOOTER';\n text: string; // max 60 chars\n};\n\nexport type ComponentTypes = TemplateHeader | TemplateBody | TemplateFooter | TemplateButton;\n\nexport type TemplateRequestBody = GeneralRequestBody & {\n name: string;\n language: LanguagesEnum;\n category?: CategoryEnum;\n components?: ComponentTypes[];\n};\n\nexport type TemplateResponse = {\n id: string;\n status: string;\n language: LanguagesEnum;\n category: CategoryEnum;\n name: string;\n components: ComponentTypes[];\n};\n\nexport type TemplateGetParams = {\n limit?: number;\n name?: string;\n language?: LanguagesEnum;\n category?: CategoryEnum;\n status?: TemplateStatusEnum;\n};\n\nexport type TemplateDeleteParams = {\n hsm_id: string;\n name: string;\n};\n\nexport declare class TemplateClass {\n getTemplate(templateId: string): Promise<RequesterResponseInterface<TemplateResponse>>;\n updateTemplate(\n templateId: string,\n template: Partial<TemplateRequestBody>,\n ): Promise<RequesterResponseInterface<ResponseSuccess>>;\n getTemplates(params: TemplateGetParams): Promise<RequesterResponseInterface<ResponsePagination<TemplateResponse>>>;\n createTemplate(template: TemplateRequestBody): Promise<RequesterResponseInterface<TemplateResponse>>;\n deleteTemplate(params: TemplateDeleteParams): Promise<RequesterResponseInterface<ResponseSuccess>>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["template_exports","__toCommonJS"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=template.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RequesterResponseInterface, ResponseSuccess } from './request.mjs';
|
|
2
|
+
import '../enums-D6WRUWH9.mjs';
|
|
3
|
+
|
|
4
|
+
type TwoStepVerificationRequest = {
|
|
5
|
+
pin: string;
|
|
6
|
+
};
|
|
7
|
+
interface TwoStepVerificationClass {
|
|
8
|
+
setTwoStepVerificationCode(pin: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type { TwoStepVerificationClass, TwoStepVerificationRequest };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RequesterResponseInterface, ResponseSuccess } from './request.js';
|
|
2
|
+
import '../enums-D6WRUWH9.js';
|
|
3
|
+
|
|
4
|
+
type TwoStepVerificationRequest = {
|
|
5
|
+
pin: string;
|
|
6
|
+
};
|
|
7
|
+
interface TwoStepVerificationClass {
|
|
8
|
+
setTwoStepVerificationCode(pin: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type { TwoStepVerificationClass, TwoStepVerificationRequest };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var a=(s,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!c.call(s,t)&&t!==r&&o(s,t,{get:()=>e[t],enumerable:!(i=n(e,t))||i.enumerable});return s};var f=s=>a(o({},"__esModule",{value:!0}),s);var R={};module.exports=f(R);
|
|
2
|
+
//# sourceMappingURL=twoStepVerification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/twoStepVerification.ts"],"sourcesContent":["import { RequesterResponseInterface, ResponseSuccess } from './request';\n\nexport type TwoStepVerificationRequest = {\n pin: string;\n};\n\nexport interface TwoStepVerificationClass {\n setTwoStepVerificationCode(pin: string): Promise<RequesterResponseInterface<ResponseSuccess>>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["twoStepVerification_exports","__toCommonJS"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=twoStepVerification.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequesterResponseInterface, ResponseData, ResponseSuccess } from './request.mjs';
|
|
2
|
+
import '../enums-D6WRUWH9.mjs';
|
|
3
|
+
|
|
4
|
+
type WabaSubscription = {
|
|
5
|
+
whatsapp_business_api_data: {
|
|
6
|
+
id: string;
|
|
7
|
+
link: string;
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type WabaSubscriptions = ResponseData<Array<WabaSubscription>>;
|
|
12
|
+
declare class WABAClass {
|
|
13
|
+
getAllWabaSubscriptions(): Promise<RequesterResponseInterface<WabaSubscriptions>>;
|
|
14
|
+
subscribeToWaba(): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
15
|
+
unsubscribeFromWaba(): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
16
|
+
overrideWabaWebhook(webhookUrl: string, verifyToken: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { WABAClass, type WabaSubscription, type WabaSubscriptions };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequesterResponseInterface, ResponseData, ResponseSuccess } from './request.js';
|
|
2
|
+
import '../enums-D6WRUWH9.js';
|
|
3
|
+
|
|
4
|
+
type WabaSubscription = {
|
|
5
|
+
whatsapp_business_api_data: {
|
|
6
|
+
id: string;
|
|
7
|
+
link: string;
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type WabaSubscriptions = ResponseData<Array<WabaSubscription>>;
|
|
12
|
+
declare class WABAClass {
|
|
13
|
+
getAllWabaSubscriptions(): Promise<RequesterResponseInterface<WabaSubscriptions>>;
|
|
14
|
+
subscribeToWaba(): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
15
|
+
unsubscribeFromWaba(): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
16
|
+
overrideWabaWebhook(webhookUrl: string, verifyToken: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { WABAClass, type WabaSubscription, type WabaSubscriptions };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var c=(s,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of i(e))!p.call(s,r)&&r!==n&&o(s,r,{get:()=>e[r],enumerable:!(a=t(e,r))||a.enumerable});return s};var b=s=>c(o({},"__esModule",{value:!0}),s);var u={};module.exports=b(u);
|
|
2
|
+
//# sourceMappingURL=waba.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/waba.ts"],"sourcesContent":["import { RequesterResponseInterface, ResponseData, ResponseSuccess } from './request';\n\nexport type WabaSubscription = {\n whatsapp_business_api_data: {\n id: string;\n link: string;\n name: string;\n };\n};\n\nexport type WabaSubscriptions = ResponseData<Array<WabaSubscription>>;\n\nexport declare class WABAClass {\n getAllWabaSubscriptions(): Promise<RequesterResponseInterface<WabaSubscriptions>>;\n subscribeToWaba(): Promise<RequesterResponseInterface<ResponseSuccess>>;\n unsubscribeFromWaba(): Promise<RequesterResponseInterface<ResponseSuccess>>;\n overrideWabaWebhook(webhookUrl: string, verifyToken: string): Promise<RequesterResponseInterface<ResponseSuccess>>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["waba_exports","__toCommonJS"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=waba.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
type WhatsAppConfig = {
|
|
9
|
+
accessToken: string;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
appId?: string;
|
|
12
|
+
appSecret?: string;
|
|
13
|
+
phoneNumberId?: number;
|
|
14
|
+
businessAcctId?: string;
|
|
15
|
+
apiVersion?: string;
|
|
16
|
+
webhookEndpoint?: string;
|
|
17
|
+
webhookVerificationToken?: string;
|
|
18
|
+
listenerPort?: number;
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
maxRetriesAfterWait?: number;
|
|
21
|
+
requestTimeout?: number;
|
|
22
|
+
};
|
|
23
|
+
declare class WhatsAppClass {
|
|
24
|
+
constructor(config?: WhatsAppConfig);
|
|
25
|
+
updateTimeout(ms: number): boolean;
|
|
26
|
+
updatePhoneNumberId(phoneNumberId: number): boolean;
|
|
27
|
+
updateAccessToken(accessToken: string): boolean;
|
|
28
|
+
updateWabaId(wabaId: string): boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { WhatsAppClass, type WhatsAppConfig };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
type WhatsAppConfig = {
|
|
9
|
+
accessToken: string;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
appId?: string;
|
|
12
|
+
appSecret?: string;
|
|
13
|
+
phoneNumberId?: number;
|
|
14
|
+
businessAcctId?: string;
|
|
15
|
+
apiVersion?: string;
|
|
16
|
+
webhookEndpoint?: string;
|
|
17
|
+
webhookVerificationToken?: string;
|
|
18
|
+
listenerPort?: number;
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
maxRetriesAfterWait?: number;
|
|
21
|
+
requestTimeout?: number;
|
|
22
|
+
};
|
|
23
|
+
declare class WhatsAppClass {
|
|
24
|
+
constructor(config?: WhatsAppConfig);
|
|
25
|
+
updateTimeout(ms: number): boolean;
|
|
26
|
+
updatePhoneNumberId(phoneNumberId: number): boolean;
|
|
27
|
+
updateAccessToken(accessToken: string): boolean;
|
|
28
|
+
updateWabaId(wabaId: string): boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { WhatsAppClass, type WhatsAppConfig };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var p=(n,e,s,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of i(e))!b.call(n,o)&&o!==s&&r(n,o,{get:()=>e[o],enumerable:!(t=a(e,o))||t.enumerable});return n};var u=n=>p(r({},"__esModule",{value:!0}),n);var c={};module.exports=u(c);
|
|
2
|
+
//# sourceMappingURL=whatsapp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/whatsapp.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport type WhatsAppConfig = {\n accessToken: string;\n baseUrl?: string;\n appId?: string;\n appSecret?: string;\n phoneNumberId?: number;\n businessAcctId?: string;\n apiVersion?: string;\n webhookEndpoint?: string;\n webhookVerificationToken?: string;\n listenerPort?: number;\n debug?: boolean;\n maxRetriesAfterWait?: number;\n requestTimeout?: number;\n};\n\nexport declare class WhatsAppClass {\n constructor(config?: WhatsAppConfig);\n updateTimeout(ms: number): boolean;\n updatePhoneNumberId(phoneNumberId: number): boolean;\n updateAccessToken(accessToken: string): boolean;\n updateWabaId(wabaId: string): boolean;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["whatsapp_exports","__toCommonJS"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=whatsapp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.create;var o=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var d=(t,r)=>{for(var e in r)o(t,e,{get:r[e],enumerable:!0})},c=(t,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of p(r))!m.call(t,a)&&a!==e&&o(t,a,{get:()=>r[a],enumerable:!(s=n(r,a))||s.enumerable});return t};var f=(t,r,e)=>(e=t!=null?i(u(t)):{},c(r||!t||!t.__esModule?o(e,"default",{value:t,enumerable:!0}):e,t)),h=t=>c(o({},"__esModule",{value:!0}),t);var y={};d(y,{generateXHub256Sig:()=>x});module.exports=h(y);var g=f(require("crypto")),x=(t,r)=>g.createHmac("sha256",r).update(t,"utf-8").digest("hex");0&&(module.exports={generateXHub256Sig});
|
|
2
|
+
//# sourceMappingURL=generateXHub256Sig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/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":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAwB,qBAEXF,EAAqB,CAACG,EAAcC,IAC/B,aAAW,SAAUA,CAAS,EAAE,OAAOD,EAAM,OAAO,EAAE,OAAO,KAAK","names":["generateXHub256Sig_exports","__export","generateXHub256Sig","__toCommonJS","crypto","body","appSecret"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/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":"AAAA,UAAYA,MAAY,SAEjB,IAAMC,EAAqB,CAACC,EAAcC,IAC/B,aAAW,SAAUA,CAAS,EAAE,OAAOD,EAAM,OAAO,EAAE,OAAO,KAAK","names":["crypto","generateXHub256Sig","body","appSecret"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var _=(t,A)=>{for(var R in A)i(t,R,{get:A[R],enumerable:!0})},O=(t,A,R,B)=>{if(A&&typeof A=="object"||typeof A=="function")for(let D of U(A))!I.call(t,D)&&D!==R&&i(t,D,{get:()=>A[D],enumerable:!(B=N(A,D))||B.enumerable});return t};var G=t=>O(i({},"__esModule",{value:!0}),t);var Z={};_(Z,{importConfig:()=>h});module.exports=G(Z);var S=class{name;debug;constructor(A,R=!1){this.name=A,this.debug=R}log(...A){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...A])}}error(...A){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...A])}warn(...A){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...A])}info(...A){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...A])}};var K="UTILS",T=!1,P=new S(K,process.env.DEBUG==="true"||T),p="graph.facebook.com",M="v22.0",l=3e3,F=30,H=2e4,X=(t,A)=>{if(!process.env.WA_PHONE_NUMBER_ID&&!t)throw P.log("Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined."),new Error("Missing WhatsApp sender phone number Id.");if(!process.env.CLOUD_API_ACCESS_TOKEN&&!A)throw P.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.");if(!process.env.CLOUD_API_VERSION)throw P.log("Environmental variable: CLOUD_API_VERSION is undefined."),new Error("Missing WhatsApp API version.")},h=t=>{X(t?.phoneNumberId,t?.accessToken);let A={WA_BASE_URL:process.env.WA_BASE_URL||p,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:t?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||M,CLOUD_API_ACCESS_TOKEN:t?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||l,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||F,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||H,DEBUG:process.env.DEBUG==="true"};return P.log(`Configuration loaded for App Id ${A.M4D_APP_ID}`),A};0&&(module.exports={importConfig});
|
|
2
|
+
//# sourceMappingURL=importConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/importConfig.ts","../../src/utils/logger.ts"],"sourcesContent":["import Logger from './logger';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport { WhatsAppConfig } from 'src/types/whatsapp';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_BASE_URL = 'graph.facebook.com';\nconst DEFAULT_APIVersion = 'v22.0';\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (phoneNumberId?: number, accessToken?: string) => {\n if (!process.env[WabaConfigEnum.PhoneNumberId] && !phoneNumberId) {\n LOGGER.log(`Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined.`);\n throw new Error('Missing WhatsApp sender phone number Id.');\n }\n\n if (!process.env[WabaConfigEnum.AccessToken] && !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 if (!process.env[WabaConfigEnum.APIVersion]) {\n LOGGER.log(`Environmental variable: CLOUD_API_VERSION is undefined.`);\n throw new Error('Missing WhatsApp API version.');\n }\n};\n\nexport const importConfig = (inputConfig?: WhatsAppConfig) => {\n emptyConfigChecker(inputConfig?.phoneNumberId, inputConfig?.accessToken);\n\n const wabaConfig: WabaConfigType = {\n [WabaConfigEnum.BaseURL]: process.env.WA_BASE_URL || DEFAULT_BASE_URL,\n [WabaConfigEnum.AppId]: process.env.M4D_APP_ID || '',\n [WabaConfigEnum.AppSecret]: process.env.M4D_APP_SECRET || '',\n [WabaConfigEnum.PhoneNumberId]: inputConfig?.phoneNumberId || parseInt(process.env.WA_PHONE_NUMBER_ID || ''),\n [WabaConfigEnum.BusinessAcctId]: process.env.WA_BUSINESS_ACCOUNT_ID || '',\n [WabaConfigEnum.APIVersion]: process.env.CLOUD_API_VERSION || DEFAULT_APIVersion,\n [WabaConfigEnum.AccessToken]: inputConfig?.accessToken || process.env.CLOUD_API_ACCESS_TOKEN || '',\n [WabaConfigEnum.WebhookEndpoint]: process.env.WEBHOOK_ENDPOINT || '',\n [WabaConfigEnum.WebhookVerificationToken]: process.env.WEBHOOK_VERIFICATION_TOKEN || '',\n [WabaConfigEnum.ListenerPort]: parseInt(process.env.LISTENER_PORT || '') || DEFAULT_LISTENER_PORT,\n [WabaConfigEnum.MaxRetriesAfterWait]:\n parseInt(process.env.MAX_RETRIES_AFTER_WAIT || '') || DEFAULT_MAX_RETRIES_AFTER_WAIT,\n [WabaConfigEnum.RequestTimeout]: parseInt(process.env.REQUEST_TIMEOUT || '') || DEFAULT_REQUEST_TIMEOUT,\n [WabaConfigEnum.Debug]: process.env.DEBUG === 'true',\n };\n\n LOGGER.log(`Configuration loaded for App Id ${wabaConfig[WabaConfigEnum.AppId]}`);\n\n return wabaConfig;\n};\n","// @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"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GCGA,IAAqBI,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,EDxCA,IAAME,EAAW,QACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EACvEG,EAAmB,qBACnBC,EAAqB,QACrBC,EAAwB,IACxBC,EAAiC,GACjCC,EAA0B,IAE1BC,EAAqB,CAACC,EAAwBC,IAAyB,CACzE,GAAI,CAAC,QAAQ,IAAI,oBAAiC,CAACD,EAC/C,MAAAR,EAAO,IAAI,iGAAiG,EACtG,IAAI,MAAM,0CAA0C,EAG9D,GAAI,CAAC,QAAQ,IAAI,wBAA+B,CAACS,EAC7C,MAAAT,EAAO,IAAI,2FAA2F,EAChG,IAAI,MAAM,gCAAgC,EAGpD,GAAI,CAAC,QAAQ,IAAI,kBACb,MAAAA,EAAO,IAAI,yDAAyD,EAC9D,IAAI,MAAM,+BAA+B,CAEvD,EAEaU,EAAgBC,GAAiC,CAC1DJ,EAAmBI,GAAa,cAAeA,GAAa,WAAW,EAEvE,IAAMC,EAA6B,CAC9B,YAAyB,QAAQ,IAAI,aAAeV,EACpD,WAAuB,QAAQ,IAAI,YAAc,GACjD,eAA2B,QAAQ,IAAI,gBAAkB,GACzD,mBAA+BS,GAAa,eAAiB,SAAS,QAAQ,IAAI,oBAAsB,EAAE,EAC1G,uBAAgC,QAAQ,IAAI,wBAA0B,GACtE,kBAA4B,QAAQ,IAAI,mBAAqBR,EAC7D,uBAA6BQ,GAAa,aAAe,QAAQ,IAAI,wBAA0B,GAC/F,iBAAiC,QAAQ,IAAI,kBAAoB,GACjE,2BAA0C,QAAQ,IAAI,4BAA8B,GACpF,cAA8B,SAAS,QAAQ,IAAI,eAAiB,EAAE,GAAKP,EAC3E,uBACG,SAAS,QAAQ,IAAI,wBAA0B,EAAE,GAAKC,EACzD,gBAAgC,SAAS,QAAQ,IAAI,iBAAmB,EAAE,GAAKC,EAC/E,MAAuB,QAAQ,IAAI,QAAU,MAClD,EAEA,OAAAN,EAAO,IAAI,mCAAmCY,EAAW,UAAqB,EAAE,EAEzEA,CACX","names":["importConfig_exports","__export","importConfig","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","DEFAULT_BASE_URL","DEFAULT_APIVersion","DEFAULT_LISTENER_PORT","DEFAULT_MAX_RETRIES_AFTER_WAIT","DEFAULT_REQUEST_TIMEOUT","emptyConfigChecker","phoneNumberId","accessToken","importConfig","inputConfig","wabaConfig"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var D=class{name;debug;constructor(A,R=!1){this.name=A,this.debug=R}log(...A){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...A])}}error(...A){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...A])}warn(...A){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...A])}info(...A){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...A])}};var P="UTILS",i=!1,S=new D(P,process.env.DEBUG==="true"||i),B="graph.facebook.com",N="v22.0",U=3e3,I=30,_=2e4,O=(t,A)=>{if(!process.env.WA_PHONE_NUMBER_ID&&!t)throw S.log("Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined."),new Error("Missing WhatsApp sender phone number Id.");if(!process.env.CLOUD_API_ACCESS_TOKEN&&!A)throw S.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.");if(!process.env.CLOUD_API_VERSION)throw S.log("Environmental variable: CLOUD_API_VERSION is undefined."),new Error("Missing WhatsApp API version.")},l=t=>{O(t?.phoneNumberId,t?.accessToken);let A={WA_BASE_URL:process.env.WA_BASE_URL||B,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:t?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||N,CLOUD_API_ACCESS_TOKEN:t?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||U,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||I,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||_,DEBUG:process.env.DEBUG==="true"};return S.log(`Configuration loaded for App Id ${A.M4D_APP_ID}`),A};export{l as importConfig};
|
|
2
|
+
//# sourceMappingURL=importConfig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/logger.ts","../../src/utils/importConfig.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 Logger from './logger';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport { WhatsAppConfig } from 'src/types/whatsapp';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_BASE_URL = 'graph.facebook.com';\nconst DEFAULT_APIVersion = 'v22.0';\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (phoneNumberId?: number, accessToken?: string) => {\n if (!process.env[WabaConfigEnum.PhoneNumberId] && !phoneNumberId) {\n LOGGER.log(`Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined.`);\n throw new Error('Missing WhatsApp sender phone number Id.');\n }\n\n if (!process.env[WabaConfigEnum.AccessToken] && !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 if (!process.env[WabaConfigEnum.APIVersion]) {\n LOGGER.log(`Environmental variable: CLOUD_API_VERSION is undefined.`);\n throw new Error('Missing WhatsApp API version.');\n }\n};\n\nexport const importConfig = (inputConfig?: WhatsAppConfig) => {\n emptyConfigChecker(inputConfig?.phoneNumberId, inputConfig?.accessToken);\n\n const wabaConfig: WabaConfigType = {\n [WabaConfigEnum.BaseURL]: process.env.WA_BASE_URL || DEFAULT_BASE_URL,\n [WabaConfigEnum.AppId]: process.env.M4D_APP_ID || '',\n [WabaConfigEnum.AppSecret]: process.env.M4D_APP_SECRET || '',\n [WabaConfigEnum.PhoneNumberId]: inputConfig?.phoneNumberId || parseInt(process.env.WA_PHONE_NUMBER_ID || ''),\n [WabaConfigEnum.BusinessAcctId]: process.env.WA_BUSINESS_ACCOUNT_ID || '',\n [WabaConfigEnum.APIVersion]: process.env.CLOUD_API_VERSION || DEFAULT_APIVersion,\n [WabaConfigEnum.AccessToken]: inputConfig?.accessToken || process.env.CLOUD_API_ACCESS_TOKEN || '',\n [WabaConfigEnum.WebhookEndpoint]: process.env.WEBHOOK_ENDPOINT || '',\n [WabaConfigEnum.WebhookVerificationToken]: process.env.WEBHOOK_VERIFICATION_TOKEN || '',\n [WabaConfigEnum.ListenerPort]: parseInt(process.env.LISTENER_PORT || '') || DEFAULT_LISTENER_PORT,\n [WabaConfigEnum.MaxRetriesAfterWait]:\n parseInt(process.env.MAX_RETRIES_AFTER_WAIT || '') || DEFAULT_MAX_RETRIES_AFTER_WAIT,\n [WabaConfigEnum.RequestTimeout]: parseInt(process.env.REQUEST_TIMEOUT || '') || DEFAULT_REQUEST_TIMEOUT,\n [WabaConfigEnum.Debug]: process.env.DEBUG === 'true',\n };\n\n LOGGER.log(`Configuration loaded for App Id ${wabaConfig[WabaConfigEnum.AppId]}`);\n\n return wabaConfig;\n};\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,ECxCA,IAAME,EAAW,QACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EACvEG,EAAmB,qBACnBC,EAAqB,QACrBC,EAAwB,IACxBC,EAAiC,GACjCC,EAA0B,IAE1BC,EAAqB,CAACC,EAAwBC,IAAyB,CACzE,GAAI,CAAC,QAAQ,IAAI,oBAAiC,CAACD,EAC/C,MAAAR,EAAO,IAAI,iGAAiG,EACtG,IAAI,MAAM,0CAA0C,EAG9D,GAAI,CAAC,QAAQ,IAAI,wBAA+B,CAACS,EAC7C,MAAAT,EAAO,IAAI,2FAA2F,EAChG,IAAI,MAAM,gCAAgC,EAGpD,GAAI,CAAC,QAAQ,IAAI,kBACb,MAAAA,EAAO,IAAI,yDAAyD,EAC9D,IAAI,MAAM,+BAA+B,CAEvD,EAEaU,EAAgBC,GAAiC,CAC1DJ,EAAmBI,GAAa,cAAeA,GAAa,WAAW,EAEvE,IAAMC,EAA6B,CAC9B,YAAyB,QAAQ,IAAI,aAAeV,EACpD,WAAuB,QAAQ,IAAI,YAAc,GACjD,eAA2B,QAAQ,IAAI,gBAAkB,GACzD,mBAA+BS,GAAa,eAAiB,SAAS,QAAQ,IAAI,oBAAsB,EAAE,EAC1G,uBAAgC,QAAQ,IAAI,wBAA0B,GACtE,kBAA4B,QAAQ,IAAI,mBAAqBR,EAC7D,uBAA6BQ,GAAa,aAAe,QAAQ,IAAI,wBAA0B,GAC/F,iBAAiC,QAAQ,IAAI,kBAAoB,GACjE,2BAA0C,QAAQ,IAAI,4BAA8B,GACpF,cAA8B,SAAS,QAAQ,IAAI,eAAiB,EAAE,GAAKP,EAC3E,uBACG,SAAS,QAAQ,IAAI,wBAA0B,EAAE,GAAKC,EACzD,gBAAgC,SAAS,QAAQ,IAAI,iBAAmB,EAAE,GAAKC,EAC/E,MAAuB,QAAQ,IAAI,QAAU,MAClD,EAEA,OAAAN,EAAO,IAAI,mCAAmCY,EAAW,UAAqB,EAAE,EAEzEA,CACX","names":["Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","DEFAULT_BASE_URL","DEFAULT_APIVersion","DEFAULT_LISTENER_PORT","DEFAULT_MAX_RETRIES_AFTER_WAIT","DEFAULT_REQUEST_TIMEOUT","emptyConfigChecker","phoneNumberId","accessToken","importConfig","inputConfig","wabaConfig"]}
|