meta-cloud-api 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -9
- package/dist/index.d.ts +589 -276
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/types/{enums-Dx5yD3dt.d.ts → enums-DEu7hLmx.d.ts} +4 -1
- package/dist/types/enums-DEu7hLmx.d.ts.map +1 -0
- package/dist/types/{enums-DR1DVLAK.js → enums-U752Hos7.js} +1 -1
- package/dist/types/enums-U752Hos7.js.map +1 -0
- package/dist/types/enums.d.ts +1 -1
- package/dist/types/enums.js +1 -1
- package/dist/types/index.d.ts +14 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/utils/index.d.ts +43 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/types/enums-DR1DVLAK.js.map +0 -1
- package/dist/types/enums-Dx5yD3dt.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,9 @@ declare enum MessageTypesEnum {
|
|
|
38
38
|
System = "system",
|
|
39
39
|
Unsupported = "unsupported",
|
|
40
40
|
Unknown = "unknown",
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use WebhookProcessor.onStatus() instead of onMessage(MessageTypesEnum.Statuses)
|
|
43
|
+
*/
|
|
41
44
|
Statuses = "statuses",
|
|
42
45
|
'*' = "*",
|
|
43
46
|
}
|
|
@@ -806,50 +809,6 @@ declare class RequesterClass {
|
|
|
806
809
|
sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
807
810
|
}
|
|
808
811
|
//#endregion
|
|
809
|
-
//#region src/types/httpsClient.d.ts
|
|
810
|
-
type ResponseHeaderValue = string | string[] | undefined;
|
|
811
|
-
type ResponseHeaders = Record<string, ResponseHeaderValue>;
|
|
812
|
-
type ResponseJSONBody = Record<string, unknown>;
|
|
813
|
-
declare class HttpsClientResponseClass {
|
|
814
|
-
constructor(resp: Response);
|
|
815
|
-
statusCode: () => number;
|
|
816
|
-
headers: () => ResponseHeaders;
|
|
817
|
-
rawResponse: () => Response;
|
|
818
|
-
json: () => Promise<ResponseJSONBody>;
|
|
819
|
-
}
|
|
820
|
-
declare class HttpsClientClass {
|
|
821
|
-
constructor();
|
|
822
|
-
clearSockets: () => boolean;
|
|
823
|
-
sendRequest: (host: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null) => Promise<HttpsClientResponseClass>;
|
|
824
|
-
}
|
|
825
|
-
//#endregion
|
|
826
|
-
//#region src/utils/http/httpsClient.d.ts
|
|
827
|
-
declare class HttpsClient implements HttpsClientClass {
|
|
828
|
-
agent: Agent;
|
|
829
|
-
constructor();
|
|
830
|
-
clearSockets(): boolean;
|
|
831
|
-
sendRequest(hostname: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null): Promise<HttpsClientResponseClass>;
|
|
832
|
-
}
|
|
833
|
-
//#endregion
|
|
834
|
-
//#region src/utils/http/request.d.ts
|
|
835
|
-
declare class Requester implements RequesterClass {
|
|
836
|
-
client: Readonly<HttpsClient>;
|
|
837
|
-
accessToken: Readonly<string>;
|
|
838
|
-
phoneNumberId: Readonly<number>;
|
|
839
|
-
businessAcctId: Readonly<string>;
|
|
840
|
-
apiVersion: Readonly<string>;
|
|
841
|
-
userAgent: Readonly<string>;
|
|
842
|
-
host: Readonly<string>;
|
|
843
|
-
protocol: Readonly<string>;
|
|
844
|
-
constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
|
|
845
|
-
buildHeader(contentType: string, additionalHeaders?: Record<string, string>): HeadersInit;
|
|
846
|
-
buildCAPIPath(endpoint: string): string;
|
|
847
|
-
sendRequest(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, contentType?: string, additionalHeaders?: Record<string, string>): Promise<HttpsClientResponseClass>;
|
|
848
|
-
getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
849
|
-
sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
850
|
-
sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
851
|
-
}
|
|
852
|
-
//#endregion
|
|
853
812
|
//#region src/types/base.d.ts
|
|
854
813
|
declare class BaseClass {
|
|
855
814
|
constructor(config: WabaConfigType);
|
|
@@ -863,216 +822,6 @@ declare class BaseAPI implements BaseClass {
|
|
|
863
822
|
protected sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
|
|
864
823
|
}
|
|
865
824
|
//#endregion
|
|
866
|
-
//#region src/api/blockUsers/types/blockUsers.d.ts
|
|
867
|
-
/**
|
|
868
|
-
* Block Users API Types
|
|
869
|
-
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users
|
|
870
|
-
*/
|
|
871
|
-
/**
|
|
872
|
-
* User object for blocking/unblocking operations
|
|
873
|
-
*/
|
|
874
|
-
type BlockUserObject = {
|
|
875
|
-
user: string;
|
|
876
|
-
};
|
|
877
|
-
/**
|
|
878
|
-
* Blocked user information in response
|
|
879
|
-
*/
|
|
880
|
-
type BlockedUserInfo = {
|
|
881
|
-
input: string;
|
|
882
|
-
wa_id: string;
|
|
883
|
-
};
|
|
884
|
-
/**
|
|
885
|
-
* Failed user information with error details
|
|
886
|
-
* Uses common MetaErrorDetail type for consistency across APIs
|
|
887
|
-
*/
|
|
888
|
-
type FailedUserInfo = BlockedUserInfo & {
|
|
889
|
-
errors?: MetaErrorDetail[];
|
|
890
|
-
};
|
|
891
|
-
/**
|
|
892
|
-
* Request body for blocking users
|
|
893
|
-
*/
|
|
894
|
-
type BlockUsersRequest = {
|
|
895
|
-
messaging_product: 'whatsapp';
|
|
896
|
-
block_users: BlockUserObject[];
|
|
897
|
-
};
|
|
898
|
-
/**
|
|
899
|
-
* Request body for unblocking users
|
|
900
|
-
*/
|
|
901
|
-
type UnblockUsersRequest = {
|
|
902
|
-
messaging_product: 'whatsapp';
|
|
903
|
-
block_users: BlockUserObject[];
|
|
904
|
-
};
|
|
905
|
-
/**
|
|
906
|
-
* Response for block/unblock operations
|
|
907
|
-
*/
|
|
908
|
-
type BlockUsersResponse = {
|
|
909
|
-
messaging_product: 'whatsapp';
|
|
910
|
-
block_users: {
|
|
911
|
-
added_users?: BlockedUserInfo[];
|
|
912
|
-
failed_users?: FailedUserInfo[];
|
|
913
|
-
};
|
|
914
|
-
};
|
|
915
|
-
/**
|
|
916
|
-
* Pagination cursors for list operations
|
|
917
|
-
*/
|
|
918
|
-
type PagingCursors = {
|
|
919
|
-
after?: string;
|
|
920
|
-
before?: string;
|
|
921
|
-
};
|
|
922
|
-
/**
|
|
923
|
-
* Pagination information
|
|
924
|
-
*/
|
|
925
|
-
type PagingInfo = {
|
|
926
|
-
cursors?: PagingCursors;
|
|
927
|
-
previous?: string;
|
|
928
|
-
next?: string;
|
|
929
|
-
};
|
|
930
|
-
/**
|
|
931
|
-
* List blocked users response
|
|
932
|
-
*/
|
|
933
|
-
type ListBlockedUsersResponse = {
|
|
934
|
-
data: Array<{
|
|
935
|
-
block_users: BlockedUserInfo[];
|
|
936
|
-
}>;
|
|
937
|
-
paging?: PagingInfo;
|
|
938
|
-
};
|
|
939
|
-
/**
|
|
940
|
-
* Query parameters for listing blocked users
|
|
941
|
-
*/
|
|
942
|
-
type ListBlockedUsersParams = {
|
|
943
|
-
limit?: number;
|
|
944
|
-
after?: string;
|
|
945
|
-
before?: string;
|
|
946
|
-
};
|
|
947
|
-
/**
|
|
948
|
-
* Block Users API Interface
|
|
949
|
-
*/
|
|
950
|
-
interface BlockUsersClass {
|
|
951
|
-
/**
|
|
952
|
-
* Block one or more WhatsApp users
|
|
953
|
-
* @param users - Array of phone numbers or WhatsApp IDs to block
|
|
954
|
-
* @returns Response with successfully blocked and failed users
|
|
955
|
-
* @throws Error if users have not messaged in last 24 hours
|
|
956
|
-
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
|
|
957
|
-
*/
|
|
958
|
-
block(users: string[]): Promise<BlockUsersResponse>;
|
|
959
|
-
/**
|
|
960
|
-
* Unblock one or more WhatsApp users
|
|
961
|
-
* @param users - Array of phone numbers or WhatsApp IDs to unblock
|
|
962
|
-
* @returns Response with successfully unblocked and failed users
|
|
963
|
-
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
|
|
964
|
-
*/
|
|
965
|
-
unblock(users: string[]): Promise<BlockUsersResponse>;
|
|
966
|
-
/**
|
|
967
|
-
* Get list of blocked WhatsApp users with pagination
|
|
968
|
-
* @param params - Optional pagination parameters
|
|
969
|
-
* @returns List of blocked users with pagination info
|
|
970
|
-
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
|
|
971
|
-
*/
|
|
972
|
-
listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
|
|
973
|
-
}
|
|
974
|
-
//#endregion
|
|
975
|
-
//#region src/api/blockUsers/BlockUsersApi.d.ts
|
|
976
|
-
/**
|
|
977
|
-
* Block Users API
|
|
978
|
-
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users
|
|
979
|
-
*
|
|
980
|
-
* Limitations:
|
|
981
|
-
* - Can only block users that have messaged your business in the last 24 hours
|
|
982
|
-
* - 64k blocklist limit
|
|
983
|
-
*/
|
|
984
|
-
declare class BlockUsersApi extends BaseAPI implements BlockUsersClass {
|
|
985
|
-
private readonly endpoint;
|
|
986
|
-
constructor(config: WabaConfigType, client: RequesterClass);
|
|
987
|
-
/**
|
|
988
|
-
* Build request body for block/unblock operations
|
|
989
|
-
*/
|
|
990
|
-
private buildBlockUsersBody;
|
|
991
|
-
/**
|
|
992
|
-
* Block one or more WhatsApp users
|
|
993
|
-
* @param users - Array of phone numbers or WhatsApp IDs to block
|
|
994
|
-
* @returns Response with successfully blocked and failed users
|
|
995
|
-
* @throws Error if users have not messaged in last 24 hours
|
|
996
|
-
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
|
|
997
|
-
*
|
|
998
|
-
* @example
|
|
999
|
-
* ```typescript
|
|
1000
|
-
* // Block single user
|
|
1001
|
-
* const result = await client.blockUsers.block(['1234567890']);
|
|
1002
|
-
*
|
|
1003
|
-
* // Block multiple users
|
|
1004
|
-
* const result = await client.blockUsers.block(['1234567890', '0987654321']);
|
|
1005
|
-
*
|
|
1006
|
-
* // Check results
|
|
1007
|
-
* console.log('Blocked:', result.block_users.added_users);
|
|
1008
|
-
* console.log('Failed:', result.block_users.failed_users);
|
|
1009
|
-
* ```
|
|
1010
|
-
*/
|
|
1011
|
-
block(users: string[]): Promise<BlockUsersResponse>;
|
|
1012
|
-
/**
|
|
1013
|
-
* Unblock one or more WhatsApp users
|
|
1014
|
-
* @param users - Array of phone numbers or WhatsApp IDs to unblock
|
|
1015
|
-
* @returns Response with successfully unblocked and failed users
|
|
1016
|
-
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
|
|
1017
|
-
*
|
|
1018
|
-
* @example
|
|
1019
|
-
* ```typescript
|
|
1020
|
-
* // Unblock single user
|
|
1021
|
-
* const result = await client.blockUsers.unblock(['1234567890']);
|
|
1022
|
-
*
|
|
1023
|
-
* // Unblock multiple users
|
|
1024
|
-
* const result = await client.blockUsers.unblock(['1234567890', '0987654321']);
|
|
1025
|
-
*
|
|
1026
|
-
* // Check results
|
|
1027
|
-
* console.log('Unblocked:', result.block_users.added_users);
|
|
1028
|
-
* console.log('Failed:', result.block_users.failed_users);
|
|
1029
|
-
* ```
|
|
1030
|
-
*/
|
|
1031
|
-
unblock(users: string[]): Promise<BlockUsersResponse>;
|
|
1032
|
-
/**
|
|
1033
|
-
* Get list of blocked WhatsApp users with pagination
|
|
1034
|
-
* @param params - Optional pagination parameters
|
|
1035
|
-
* @returns List of blocked users with pagination info
|
|
1036
|
-
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
|
|
1037
|
-
*
|
|
1038
|
-
* @example
|
|
1039
|
-
* ```typescript
|
|
1040
|
-
* // Get first 10 blocked users
|
|
1041
|
-
* const result = await client.blockUsers.listBlockedUsers({ limit: 10 });
|
|
1042
|
-
*
|
|
1043
|
-
* // Pagination with cursor
|
|
1044
|
-
* const nextPage = await client.blockUsers.listBlockedUsers({
|
|
1045
|
-
* limit: 10,
|
|
1046
|
-
* after: result.paging?.cursors?.after
|
|
1047
|
-
* });
|
|
1048
|
-
*
|
|
1049
|
-
* // Get all blocked users
|
|
1050
|
-
* const allBlocked = await client.blockUsers.listBlockedUsers();
|
|
1051
|
-
* ```
|
|
1052
|
-
*/
|
|
1053
|
-
listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
|
|
1054
|
-
}
|
|
1055
|
-
//#endregion
|
|
1056
|
-
//#region src/api/encryption/types/publicKey.d.ts
|
|
1057
|
-
type EncryptionPublicKeyResponse = ResponseData<{
|
|
1058
|
-
business_public_key: string;
|
|
1059
|
-
business_public_key_signature_status: 'VALID' | 'MISMATCH';
|
|
1060
|
-
}>;
|
|
1061
|
-
//#endregion
|
|
1062
|
-
//#region src/api/encryption/types/common.d.ts
|
|
1063
|
-
interface EncryptionClass {
|
|
1064
|
-
getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
|
|
1065
|
-
setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
|
|
1066
|
-
}
|
|
1067
|
-
//#endregion
|
|
1068
|
-
//#region src/api/encryption/EncryptionApi.d.ts
|
|
1069
|
-
declare class EncryptionApi extends BaseAPI implements EncryptionClass {
|
|
1070
|
-
private readonly endpoint;
|
|
1071
|
-
constructor(config: WabaConfigType, client: RequesterClass);
|
|
1072
|
-
getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
|
|
1073
|
-
setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
|
|
1074
|
-
}
|
|
1075
|
-
//#endregion
|
|
1076
825
|
//#region src/core/webhook/types.d.ts
|
|
1077
826
|
/**
|
|
1078
827
|
* WhatsApp contact information
|
|
@@ -1243,7 +992,19 @@ interface InteractiveButtonReplyMessage extends BaseMessage {
|
|
|
1243
992
|
};
|
|
1244
993
|
};
|
|
1245
994
|
}
|
|
1246
|
-
|
|
995
|
+
interface InteractiveNfmReplyMessage extends BaseMessage {
|
|
996
|
+
type: MessageTypesEnum.Interactive;
|
|
997
|
+
context: ReplyContext;
|
|
998
|
+
interactive: {
|
|
999
|
+
type: 'nfm_reply';
|
|
1000
|
+
nfm_reply: {
|
|
1001
|
+
name: string;
|
|
1002
|
+
body: string;
|
|
1003
|
+
response_json: string;
|
|
1004
|
+
};
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
type InteractiveMessage = InteractiveListReplyMessage | InteractiveButtonReplyMessage | InteractiveNfmReplyMessage;
|
|
1247
1008
|
interface ButtonMessage extends BaseMessage {
|
|
1248
1009
|
type: MessageTypesEnum.Button;
|
|
1249
1010
|
context: ReplyContext;
|
|
@@ -1460,6 +1221,23 @@ interface LoggerInterface {
|
|
|
1460
1221
|
debug(...data: any[]): void;
|
|
1461
1222
|
}
|
|
1462
1223
|
//#endregion
|
|
1224
|
+
//#region src/types/httpsClient.d.ts
|
|
1225
|
+
type ResponseHeaderValue = string | string[] | undefined;
|
|
1226
|
+
type ResponseHeaders = Record<string, ResponseHeaderValue>;
|
|
1227
|
+
type ResponseJSONBody = Record<string, unknown>;
|
|
1228
|
+
declare class HttpsClientResponseClass {
|
|
1229
|
+
constructor(resp: Response);
|
|
1230
|
+
statusCode: () => number;
|
|
1231
|
+
headers: () => ResponseHeaders;
|
|
1232
|
+
rawResponse: () => Response;
|
|
1233
|
+
json: () => Promise<ResponseJSONBody>;
|
|
1234
|
+
}
|
|
1235
|
+
declare class HttpsClientClass {
|
|
1236
|
+
constructor();
|
|
1237
|
+
clearSockets: () => boolean;
|
|
1238
|
+
sendRequest: (host: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null) => Promise<HttpsClientResponseClass>;
|
|
1239
|
+
}
|
|
1240
|
+
//#endregion
|
|
1463
1241
|
//#region src/api/profile/types/upload.d.ts
|
|
1464
1242
|
/**
|
|
1465
1243
|
* Upload session information for creating upload sessions.
|
|
@@ -2742,6 +2520,127 @@ interface TwoStepVerificationClass {
|
|
|
2742
2520
|
setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;
|
|
2743
2521
|
}
|
|
2744
2522
|
//#endregion
|
|
2523
|
+
//#region src/api/encryption/types/publicKey.d.ts
|
|
2524
|
+
type EncryptionPublicKeyResponse = ResponseData<{
|
|
2525
|
+
business_public_key: string;
|
|
2526
|
+
business_public_key_signature_status: 'VALID' | 'MISMATCH';
|
|
2527
|
+
}>;
|
|
2528
|
+
//#endregion
|
|
2529
|
+
//#region src/api/encryption/types/common.d.ts
|
|
2530
|
+
interface EncryptionClass {
|
|
2531
|
+
getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
|
|
2532
|
+
setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
|
|
2533
|
+
}
|
|
2534
|
+
//#endregion
|
|
2535
|
+
//#region src/api/blockUsers/types/blockUsers.d.ts
|
|
2536
|
+
/**
|
|
2537
|
+
* Block Users API Types
|
|
2538
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users
|
|
2539
|
+
*/
|
|
2540
|
+
/**
|
|
2541
|
+
* User object for blocking/unblocking operations
|
|
2542
|
+
*/
|
|
2543
|
+
type BlockUserObject = {
|
|
2544
|
+
user: string;
|
|
2545
|
+
};
|
|
2546
|
+
/**
|
|
2547
|
+
* Blocked user information in response
|
|
2548
|
+
*/
|
|
2549
|
+
type BlockedUserInfo = {
|
|
2550
|
+
input: string;
|
|
2551
|
+
wa_id: string;
|
|
2552
|
+
};
|
|
2553
|
+
/**
|
|
2554
|
+
* Failed user information with error details
|
|
2555
|
+
* Uses common MetaErrorDetail type for consistency across APIs
|
|
2556
|
+
*/
|
|
2557
|
+
type FailedUserInfo = BlockedUserInfo & {
|
|
2558
|
+
errors?: MetaErrorDetail[];
|
|
2559
|
+
};
|
|
2560
|
+
/**
|
|
2561
|
+
* Request body for blocking users
|
|
2562
|
+
*/
|
|
2563
|
+
type BlockUsersRequest = {
|
|
2564
|
+
messaging_product: 'whatsapp';
|
|
2565
|
+
block_users: BlockUserObject[];
|
|
2566
|
+
};
|
|
2567
|
+
/**
|
|
2568
|
+
* Request body for unblocking users
|
|
2569
|
+
*/
|
|
2570
|
+
type UnblockUsersRequest = {
|
|
2571
|
+
messaging_product: 'whatsapp';
|
|
2572
|
+
block_users: BlockUserObject[];
|
|
2573
|
+
};
|
|
2574
|
+
/**
|
|
2575
|
+
* Response for block/unblock operations
|
|
2576
|
+
*/
|
|
2577
|
+
type BlockUsersResponse = {
|
|
2578
|
+
messaging_product: 'whatsapp';
|
|
2579
|
+
block_users: {
|
|
2580
|
+
added_users?: BlockedUserInfo[];
|
|
2581
|
+
failed_users?: FailedUserInfo[];
|
|
2582
|
+
};
|
|
2583
|
+
};
|
|
2584
|
+
/**
|
|
2585
|
+
* Pagination cursors for list operations
|
|
2586
|
+
*/
|
|
2587
|
+
type PagingCursors = {
|
|
2588
|
+
after?: string;
|
|
2589
|
+
before?: string;
|
|
2590
|
+
};
|
|
2591
|
+
/**
|
|
2592
|
+
* Pagination information
|
|
2593
|
+
*/
|
|
2594
|
+
type PagingInfo = {
|
|
2595
|
+
cursors?: PagingCursors;
|
|
2596
|
+
previous?: string;
|
|
2597
|
+
next?: string;
|
|
2598
|
+
};
|
|
2599
|
+
/**
|
|
2600
|
+
* List blocked users response
|
|
2601
|
+
*/
|
|
2602
|
+
type ListBlockedUsersResponse = {
|
|
2603
|
+
data: Array<{
|
|
2604
|
+
block_users: BlockedUserInfo[];
|
|
2605
|
+
}>;
|
|
2606
|
+
paging?: PagingInfo;
|
|
2607
|
+
};
|
|
2608
|
+
/**
|
|
2609
|
+
* Query parameters for listing blocked users
|
|
2610
|
+
*/
|
|
2611
|
+
type ListBlockedUsersParams = {
|
|
2612
|
+
limit?: number;
|
|
2613
|
+
after?: string;
|
|
2614
|
+
before?: string;
|
|
2615
|
+
};
|
|
2616
|
+
/**
|
|
2617
|
+
* Block Users API Interface
|
|
2618
|
+
*/
|
|
2619
|
+
interface BlockUsersClass {
|
|
2620
|
+
/**
|
|
2621
|
+
* Block one or more WhatsApp users
|
|
2622
|
+
* @param users - Array of phone numbers or WhatsApp IDs to block
|
|
2623
|
+
* @returns Response with successfully blocked and failed users
|
|
2624
|
+
* @throws Error if users have not messaged in last 24 hours
|
|
2625
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
|
|
2626
|
+
*/
|
|
2627
|
+
block(users: string[]): Promise<BlockUsersResponse>;
|
|
2628
|
+
/**
|
|
2629
|
+
* Unblock one or more WhatsApp users
|
|
2630
|
+
* @param users - Array of phone numbers or WhatsApp IDs to unblock
|
|
2631
|
+
* @returns Response with successfully unblocked and failed users
|
|
2632
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
|
|
2633
|
+
*/
|
|
2634
|
+
unblock(users: string[]): Promise<BlockUsersResponse>;
|
|
2635
|
+
/**
|
|
2636
|
+
* Get list of blocked WhatsApp users with pagination
|
|
2637
|
+
* @param params - Optional pagination parameters
|
|
2638
|
+
* @returns List of blocked users with pagination info
|
|
2639
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
|
|
2640
|
+
*/
|
|
2641
|
+
listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
|
|
2642
|
+
}
|
|
2643
|
+
//#endregion
|
|
2745
2644
|
//#region src/utils/isMetaError.d.ts
|
|
2746
2645
|
interface MetaError extends Error {
|
|
2747
2646
|
error: {
|
|
@@ -2756,6 +2655,12 @@ interface MetaError extends Error {
|
|
|
2756
2655
|
fbtrace_id: string;
|
|
2757
2656
|
};
|
|
2758
2657
|
}
|
|
2658
|
+
/**
|
|
2659
|
+
* Determines if the error is a Meta API error response
|
|
2660
|
+
* @param error Any error object to check
|
|
2661
|
+
* @returns Type guard indicating if error is a Meta API error
|
|
2662
|
+
*/
|
|
2663
|
+
declare function isMetaError(error: any): error is MetaError;
|
|
2759
2664
|
//#endregion
|
|
2760
2665
|
//#region src/api/flow/types/common.d.ts
|
|
2761
2666
|
/**
|
|
@@ -3288,6 +3193,164 @@ declare class FlowApi extends BaseAPI implements FlowClass {
|
|
|
3288
3193
|
}): Promise<FlowMigrationResponse>;
|
|
3289
3194
|
}
|
|
3290
3195
|
//#endregion
|
|
3196
|
+
//#region src/utils/flowEncryptionUtils.d.ts
|
|
3197
|
+
/**
|
|
3198
|
+
* Environment model for encryption keys
|
|
3199
|
+
*/
|
|
3200
|
+
type EncryptionKeyPair = {
|
|
3201
|
+
passphrase: string;
|
|
3202
|
+
privateKey: string;
|
|
3203
|
+
publicKey: string;
|
|
3204
|
+
};
|
|
3205
|
+
/**
|
|
3206
|
+
* Generates RSA key pair for WhatsApp Business Flow API encryption
|
|
3207
|
+
*
|
|
3208
|
+
* This function generates a 2048-bit RSA key pair with:
|
|
3209
|
+
* - Public key in SPKI format (PEM)
|
|
3210
|
+
* - Private key in PKCS#8 format (PEM) encrypted with AES-256-CBC
|
|
3211
|
+
*
|
|
3212
|
+
* @param passphrase - Passphrase to encrypt the private key. If not provided, uses FLOW_API_PASSPHRASE from environment
|
|
3213
|
+
* @returns Object containing passphrase, privateKey, and publicKey
|
|
3214
|
+
* @throws {Error} If passphrase is empty or key generation fails
|
|
3215
|
+
* @throws {Error} If not running in Node.js environment
|
|
3216
|
+
*
|
|
3217
|
+
* @example
|
|
3218
|
+
* ```typescript
|
|
3219
|
+
* import { WhatsApp } from 'meta-cloud-api';
|
|
3220
|
+
*
|
|
3221
|
+
* const wa = new WhatsApp();
|
|
3222
|
+
*
|
|
3223
|
+
* try {
|
|
3224
|
+
* // Uses FLOW_API_PASSPHRASE from environment
|
|
3225
|
+
* const keys = wa.generateEncryption();
|
|
3226
|
+
* console.log('Public Key:', keys.publicKey);
|
|
3227
|
+
* console.log('Private Key:', keys.privateKey);
|
|
3228
|
+
*
|
|
3229
|
+
* // Or provide custom passphrase
|
|
3230
|
+
* const customKeys = wa.generateEncryption('my-secret-passphrase');
|
|
3231
|
+
* } catch (error) {
|
|
3232
|
+
* console.error('Failed to generate keys:', error.message);
|
|
3233
|
+
* }
|
|
3234
|
+
* ```
|
|
3235
|
+
*/
|
|
3236
|
+
declare function generateEncryption(passphrase?: string): EncryptionKeyPair;
|
|
3237
|
+
//#endregion
|
|
3238
|
+
//#region src/utils/http/httpsClient.d.ts
|
|
3239
|
+
declare class HttpsClient implements HttpsClientClass {
|
|
3240
|
+
agent: Agent;
|
|
3241
|
+
constructor();
|
|
3242
|
+
clearSockets(): boolean;
|
|
3243
|
+
sendRequest(hostname: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null): Promise<HttpsClientResponseClass>;
|
|
3244
|
+
}
|
|
3245
|
+
//#endregion
|
|
3246
|
+
//#region src/utils/http/request.d.ts
|
|
3247
|
+
declare class Requester implements RequesterClass {
|
|
3248
|
+
client: Readonly<HttpsClient>;
|
|
3249
|
+
accessToken: Readonly<string>;
|
|
3250
|
+
phoneNumberId: Readonly<number>;
|
|
3251
|
+
businessAcctId: Readonly<string>;
|
|
3252
|
+
apiVersion: Readonly<string>;
|
|
3253
|
+
userAgent: Readonly<string>;
|
|
3254
|
+
host: Readonly<string>;
|
|
3255
|
+
protocol: Readonly<string>;
|
|
3256
|
+
constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
|
|
3257
|
+
buildHeader(contentType: string, additionalHeaders?: Record<string, string>): HeadersInit;
|
|
3258
|
+
buildCAPIPath(endpoint: string): string;
|
|
3259
|
+
sendRequest(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, contentType?: string, additionalHeaders?: Record<string, string>): Promise<HttpsClientResponseClass>;
|
|
3260
|
+
getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
3261
|
+
sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
3262
|
+
sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
3263
|
+
}
|
|
3264
|
+
//#endregion
|
|
3265
|
+
//#region src/api/blockUsers/BlockUsersApi.d.ts
|
|
3266
|
+
/**
|
|
3267
|
+
* Block Users API
|
|
3268
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users
|
|
3269
|
+
*
|
|
3270
|
+
* Limitations:
|
|
3271
|
+
* - Can only block users that have messaged your business in the last 24 hours
|
|
3272
|
+
* - 64k blocklist limit
|
|
3273
|
+
*/
|
|
3274
|
+
declare class BlockUsersApi extends BaseAPI implements BlockUsersClass {
|
|
3275
|
+
private readonly endpoint;
|
|
3276
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
3277
|
+
/**
|
|
3278
|
+
* Build request body for block/unblock operations
|
|
3279
|
+
*/
|
|
3280
|
+
private buildBlockUsersBody;
|
|
3281
|
+
/**
|
|
3282
|
+
* Block one or more WhatsApp users
|
|
3283
|
+
* @param users - Array of phone numbers or WhatsApp IDs to block
|
|
3284
|
+
* @returns Response with successfully blocked and failed users
|
|
3285
|
+
* @throws Error if users have not messaged in last 24 hours
|
|
3286
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
|
|
3287
|
+
*
|
|
3288
|
+
* @example
|
|
3289
|
+
* ```typescript
|
|
3290
|
+
* // Block single user
|
|
3291
|
+
* const result = await client.blockUsers.block(['1234567890']);
|
|
3292
|
+
*
|
|
3293
|
+
* // Block multiple users
|
|
3294
|
+
* const result = await client.blockUsers.block(['1234567890', '0987654321']);
|
|
3295
|
+
*
|
|
3296
|
+
* // Check results
|
|
3297
|
+
* console.log('Blocked:', result.block_users.added_users);
|
|
3298
|
+
* console.log('Failed:', result.block_users.failed_users);
|
|
3299
|
+
* ```
|
|
3300
|
+
*/
|
|
3301
|
+
block(users: string[]): Promise<BlockUsersResponse>;
|
|
3302
|
+
/**
|
|
3303
|
+
* Unblock one or more WhatsApp users
|
|
3304
|
+
* @param users - Array of phone numbers or WhatsApp IDs to unblock
|
|
3305
|
+
* @returns Response with successfully unblocked and failed users
|
|
3306
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
|
|
3307
|
+
*
|
|
3308
|
+
* @example
|
|
3309
|
+
* ```typescript
|
|
3310
|
+
* // Unblock single user
|
|
3311
|
+
* const result = await client.blockUsers.unblock(['1234567890']);
|
|
3312
|
+
*
|
|
3313
|
+
* // Unblock multiple users
|
|
3314
|
+
* const result = await client.blockUsers.unblock(['1234567890', '0987654321']);
|
|
3315
|
+
*
|
|
3316
|
+
* // Check results
|
|
3317
|
+
* console.log('Unblocked:', result.block_users.added_users);
|
|
3318
|
+
* console.log('Failed:', result.block_users.failed_users);
|
|
3319
|
+
* ```
|
|
3320
|
+
*/
|
|
3321
|
+
unblock(users: string[]): Promise<BlockUsersResponse>;
|
|
3322
|
+
/**
|
|
3323
|
+
* Get list of blocked WhatsApp users with pagination
|
|
3324
|
+
* @param params - Optional pagination parameters
|
|
3325
|
+
* @returns List of blocked users with pagination info
|
|
3326
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
|
|
3327
|
+
*
|
|
3328
|
+
* @example
|
|
3329
|
+
* ```typescript
|
|
3330
|
+
* // Get first 10 blocked users
|
|
3331
|
+
* const result = await client.blockUsers.listBlockedUsers({ limit: 10 });
|
|
3332
|
+
*
|
|
3333
|
+
* // Pagination with cursor
|
|
3334
|
+
* const nextPage = await client.blockUsers.listBlockedUsers({
|
|
3335
|
+
* limit: 10,
|
|
3336
|
+
* after: result.paging?.cursors?.after
|
|
3337
|
+
* });
|
|
3338
|
+
*
|
|
3339
|
+
* // Get all blocked users
|
|
3340
|
+
* const allBlocked = await client.blockUsers.listBlockedUsers();
|
|
3341
|
+
* ```
|
|
3342
|
+
*/
|
|
3343
|
+
listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
|
|
3344
|
+
}
|
|
3345
|
+
//#endregion
|
|
3346
|
+
//#region src/api/encryption/EncryptionApi.d.ts
|
|
3347
|
+
declare class EncryptionApi extends BaseAPI implements EncryptionClass {
|
|
3348
|
+
private readonly endpoint;
|
|
3349
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
3350
|
+
getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
|
|
3351
|
+
setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
|
|
3352
|
+
}
|
|
3353
|
+
//#endregion
|
|
3291
3354
|
//#region src/api/media/MediaApi.d.ts
|
|
3292
3355
|
/**
|
|
3293
3356
|
* API for managing WhatsApp Media.
|
|
@@ -4020,38 +4083,153 @@ declare class WhatsApp {
|
|
|
4020
4083
|
* Get User-Agent string
|
|
4021
4084
|
*/
|
|
4022
4085
|
getUserAgent(): string;
|
|
4086
|
+
/**
|
|
4087
|
+
* Generate RSA encryption key pair for WhatsApp Business Flow API
|
|
4088
|
+
*
|
|
4089
|
+
* This method generates a 2048-bit RSA key pair with:
|
|
4090
|
+
* - Public key in SPKI format (PEM)
|
|
4091
|
+
* - Private key in PKCS#8 format (PEM) encrypted with AES-256-CBC
|
|
4092
|
+
*
|
|
4093
|
+
* @param passphrase - Optional passphrase to encrypt the private key. If not provided, uses FLOW_API_PASSPHRASE from config
|
|
4094
|
+
* @returns Object containing passphrase, privateKey, and publicKey
|
|
4095
|
+
* @throws {Error} If passphrase is empty or key generation fails
|
|
4096
|
+
* @throws {Error} If not running in Node.js environment
|
|
4097
|
+
*
|
|
4098
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/reference/whatsapp-business-encryption/
|
|
4099
|
+
*
|
|
4100
|
+
* @example
|
|
4101
|
+
* ```typescript
|
|
4102
|
+
* const wa = new WhatsApp();
|
|
4103
|
+
*
|
|
4104
|
+
* // Uses FLOW_API_PASSPHRASE from environment/config
|
|
4105
|
+
* const keys = wa.generateEncryption();
|
|
4106
|
+
*
|
|
4107
|
+
* // Or provide custom passphrase
|
|
4108
|
+
* const customKeys = wa.generateEncryption('my-secret-passphrase');
|
|
4109
|
+
*
|
|
4110
|
+
* console.log('Public Key:', keys.publicKey);
|
|
4111
|
+
* console.log('Private Key:', keys.privateKey);
|
|
4112
|
+
* ```
|
|
4113
|
+
*/
|
|
4114
|
+
generateEncryption(passphrase?: string): EncryptionKeyPair;
|
|
4023
4115
|
}
|
|
4024
4116
|
//#endregion
|
|
4025
4117
|
//#region src/core/webhook/utils/webhookUtils.d.ts
|
|
4026
|
-
|
|
4118
|
+
/**
|
|
4119
|
+
* Processed message with metadata for handlers
|
|
4120
|
+
*/
|
|
4121
|
+
type ProcessedMessage = {
|
|
4122
|
+
wabaId: string;
|
|
4123
|
+
phoneNumberId: string;
|
|
4124
|
+
displayPhoneNumber: string;
|
|
4125
|
+
profileName: string;
|
|
4126
|
+
message: WhatsAppMessage;
|
|
4127
|
+
/**
|
|
4128
|
+
* The message ID extracted from the appropriate location based on message type.
|
|
4129
|
+
* For most messages, this comes from message.id
|
|
4130
|
+
* For certain types like nfm_reply, this comes from message.context.id
|
|
4131
|
+
*/
|
|
4132
|
+
messageId: string;
|
|
4133
|
+
};
|
|
4134
|
+
/**
|
|
4135
|
+
* Processed status with metadata for handlers
|
|
4136
|
+
*/
|
|
4137
|
+
type ProcessedStatus = {
|
|
4138
|
+
wabaId: string;
|
|
4139
|
+
phoneNumberId: string;
|
|
4140
|
+
displayPhoneNumber: string;
|
|
4141
|
+
status: StatusWebhook;
|
|
4142
|
+
};
|
|
4143
|
+
type TextProcessedMessage = ProcessedMessage & {
|
|
4144
|
+
message: Extract<WhatsAppMessage, {
|
|
4145
|
+
type: MessageTypesEnum.Text;
|
|
4146
|
+
}>;
|
|
4147
|
+
};
|
|
4148
|
+
type ImageProcessedMessage = ProcessedMessage & {
|
|
4149
|
+
message: Extract<WhatsAppMessage, {
|
|
4150
|
+
type: MessageTypesEnum.Image;
|
|
4151
|
+
}>;
|
|
4152
|
+
};
|
|
4153
|
+
type VideoProcessedMessage = ProcessedMessage & {
|
|
4154
|
+
message: Extract<WhatsAppMessage, {
|
|
4155
|
+
type: MessageTypesEnum.Video;
|
|
4156
|
+
}>;
|
|
4157
|
+
};
|
|
4158
|
+
type AudioProcessedMessage = ProcessedMessage & {
|
|
4159
|
+
message: Extract<WhatsAppMessage, {
|
|
4160
|
+
type: MessageTypesEnum.Audio;
|
|
4161
|
+
}>;
|
|
4162
|
+
};
|
|
4163
|
+
type DocumentProcessedMessage = ProcessedMessage & {
|
|
4164
|
+
message: Extract<WhatsAppMessage, {
|
|
4165
|
+
type: MessageTypesEnum.Document;
|
|
4166
|
+
}>;
|
|
4167
|
+
};
|
|
4168
|
+
type StickerProcessedMessage = ProcessedMessage & {
|
|
4169
|
+
message: Extract<WhatsAppMessage, {
|
|
4170
|
+
type: MessageTypesEnum.Sticker;
|
|
4171
|
+
}>;
|
|
4172
|
+
};
|
|
4173
|
+
type InteractiveProcessedMessage = ProcessedMessage & {
|
|
4174
|
+
message: Extract<WhatsAppMessage, {
|
|
4175
|
+
type: MessageTypesEnum.Interactive;
|
|
4176
|
+
}>;
|
|
4177
|
+
};
|
|
4178
|
+
type ButtonProcessedMessage = ProcessedMessage & {
|
|
4179
|
+
message: Extract<WhatsAppMessage, {
|
|
4180
|
+
type: MessageTypesEnum.Button;
|
|
4181
|
+
}>;
|
|
4182
|
+
};
|
|
4183
|
+
type LocationProcessedMessage = ProcessedMessage & {
|
|
4184
|
+
message: Extract<WhatsAppMessage, {
|
|
4185
|
+
type: MessageTypesEnum.Location;
|
|
4186
|
+
}>;
|
|
4187
|
+
};
|
|
4188
|
+
type ContactsProcessedMessage = ProcessedMessage & {
|
|
4189
|
+
message: Extract<WhatsAppMessage, {
|
|
4190
|
+
type: MessageTypesEnum.Contacts;
|
|
4191
|
+
}>;
|
|
4192
|
+
};
|
|
4193
|
+
type ReactionProcessedMessage = ProcessedMessage & {
|
|
4194
|
+
message: Extract<WhatsAppMessage, {
|
|
4195
|
+
type: MessageTypesEnum.Reaction;
|
|
4196
|
+
}>;
|
|
4197
|
+
};
|
|
4198
|
+
type OrderProcessedMessage = ProcessedMessage & {
|
|
4199
|
+
message: Extract<WhatsAppMessage, {
|
|
4200
|
+
type: MessageTypesEnum.Order;
|
|
4201
|
+
}>;
|
|
4202
|
+
};
|
|
4203
|
+
type SystemProcessedMessage = ProcessedMessage & {
|
|
4204
|
+
message: Extract<WhatsAppMessage, {
|
|
4205
|
+
type: MessageTypesEnum.System;
|
|
4206
|
+
}>;
|
|
4207
|
+
};
|
|
4208
|
+
type MessageHandler = (whatsapp: WhatsApp, processed: ProcessedMessage) => void | Promise<void>;
|
|
4209
|
+
type StatusHandler = (whatsapp: WhatsApp, processed: ProcessedStatus) => void | Promise<void>;
|
|
4027
4210
|
type FlowHandler = (whatsapp: WhatsApp, request: FlowEndpointRequest) => any | Promise<any>;
|
|
4211
|
+
type TextMessageHandler = (whatsapp: WhatsApp, processed: TextProcessedMessage) => void | Promise<void>;
|
|
4212
|
+
type ImageMessageHandler = (whatsapp: WhatsApp, processed: ImageProcessedMessage) => void | Promise<void>;
|
|
4213
|
+
type VideoMessageHandler = (whatsapp: WhatsApp, processed: VideoProcessedMessage) => void | Promise<void>;
|
|
4214
|
+
type AudioMessageHandler = (whatsapp: WhatsApp, processed: AudioProcessedMessage) => void | Promise<void>;
|
|
4215
|
+
type DocumentMessageHandler = (whatsapp: WhatsApp, processed: DocumentProcessedMessage) => void | Promise<void>;
|
|
4216
|
+
type StickerMessageHandler = (whatsapp: WhatsApp, processed: StickerProcessedMessage) => void | Promise<void>;
|
|
4217
|
+
type InteractiveMessageHandler = (whatsapp: WhatsApp, processed: InteractiveProcessedMessage) => void | Promise<void>;
|
|
4218
|
+
type ButtonMessageHandler = (whatsapp: WhatsApp, processed: ButtonProcessedMessage) => void | Promise<void>;
|
|
4219
|
+
type LocationMessageHandler = (whatsapp: WhatsApp, processed: LocationProcessedMessage) => void | Promise<void>;
|
|
4220
|
+
type ContactsMessageHandler = (whatsapp: WhatsApp, processed: ContactsProcessedMessage) => void | Promise<void>;
|
|
4221
|
+
type ReactionMessageHandler = (whatsapp: WhatsApp, processed: ReactionProcessedMessage) => void | Promise<void>;
|
|
4222
|
+
type OrderMessageHandler = (whatsapp: WhatsApp, processed: OrderProcessedMessage) => void | Promise<void>;
|
|
4223
|
+
type SystemMessageHandler = (whatsapp: WhatsApp, processed: SystemProcessedMessage) => void | Promise<void>;
|
|
4028
4224
|
/**
|
|
4029
4225
|
* Process webhook messages
|
|
4030
4226
|
*/
|
|
4031
4227
|
declare function processWebhookMessages(request: Request, whatsapp: WhatsApp, handlers: {
|
|
4032
4228
|
messageHandlers: Map<MessageTypesEnum, MessageHandler>;
|
|
4229
|
+
statusHandler?: StatusHandler;
|
|
4033
4230
|
preProcessHandler?: MessageHandler;
|
|
4034
4231
|
postProcessHandler?: MessageHandler;
|
|
4035
4232
|
}): Promise<Response>;
|
|
4036
|
-
/**
|
|
4037
|
-
* Create a standard ping response for WhatsApp Flow health checks
|
|
4038
|
-
* @returns Flow ping response object
|
|
4039
|
-
*/
|
|
4040
|
-
declare function createFlowPingResponse(): {
|
|
4041
|
-
version: string;
|
|
4042
|
-
data: {
|
|
4043
|
-
status: string;
|
|
4044
|
-
};
|
|
4045
|
-
};
|
|
4046
|
-
/**
|
|
4047
|
-
* Create a standard error response for WhatsApp Flow error notifications
|
|
4048
|
-
* @returns Acknowledgement response for error notification
|
|
4049
|
-
*/
|
|
4050
|
-
declare function createFlowErrorResponse(): {
|
|
4051
|
-
data: {
|
|
4052
|
-
acknowledged: boolean;
|
|
4053
|
-
};
|
|
4054
|
-
};
|
|
4055
4233
|
/**
|
|
4056
4234
|
* Handle flow requests
|
|
4057
4235
|
*/
|
|
@@ -4074,6 +4252,7 @@ declare class WebhookProcessor {
|
|
|
4074
4252
|
private config;
|
|
4075
4253
|
private client;
|
|
4076
4254
|
private messageHandlers;
|
|
4255
|
+
private statusHandler;
|
|
4077
4256
|
private preProcessHandler;
|
|
4078
4257
|
private postProcessHandler;
|
|
4079
4258
|
private flowHandlers;
|
|
@@ -4082,9 +4261,75 @@ declare class WebhookProcessor {
|
|
|
4082
4261
|
processWebhook(request: Request): Promise<WebhookResponse>;
|
|
4083
4262
|
processFlow(request: Request): Promise<WebhookResponse>;
|
|
4084
4263
|
onMessage(type: MessageTypesEnum, handler: MessageHandler): void;
|
|
4264
|
+
onStatus(handler: StatusHandler): void;
|
|
4085
4265
|
onMessagePreProcess(handler: MessageHandler): void;
|
|
4086
4266
|
onMessagePostProcess(handler: MessageHandler): void;
|
|
4087
4267
|
onFlow(type: FlowTypeEnum, handler: FlowHandler): void;
|
|
4268
|
+
/**
|
|
4269
|
+
* Register a handler for text messages
|
|
4270
|
+
* @param handler Type-safe handler that receives text messages with guaranteed text field
|
|
4271
|
+
*/
|
|
4272
|
+
onText(handler: TextMessageHandler): void;
|
|
4273
|
+
/**
|
|
4274
|
+
* Register a handler for image messages
|
|
4275
|
+
* @param handler Type-safe handler that receives image messages with guaranteed image field
|
|
4276
|
+
*/
|
|
4277
|
+
onImage(handler: ImageMessageHandler): void;
|
|
4278
|
+
/**
|
|
4279
|
+
* Register a handler for video messages
|
|
4280
|
+
* @param handler Type-safe handler that receives video messages with guaranteed video field
|
|
4281
|
+
*/
|
|
4282
|
+
onVideo(handler: VideoMessageHandler): void;
|
|
4283
|
+
/**
|
|
4284
|
+
* Register a handler for audio messages
|
|
4285
|
+
* @param handler Type-safe handler that receives audio messages with guaranteed audio field
|
|
4286
|
+
*/
|
|
4287
|
+
onAudio(handler: AudioMessageHandler): void;
|
|
4288
|
+
/**
|
|
4289
|
+
* Register a handler for document messages
|
|
4290
|
+
* @param handler Type-safe handler that receives document messages with guaranteed document field
|
|
4291
|
+
*/
|
|
4292
|
+
onDocument(handler: DocumentMessageHandler): void;
|
|
4293
|
+
/**
|
|
4294
|
+
* Register a handler for sticker messages
|
|
4295
|
+
* @param handler Type-safe handler that receives sticker messages with guaranteed sticker field
|
|
4296
|
+
*/
|
|
4297
|
+
onSticker(handler: StickerMessageHandler): void;
|
|
4298
|
+
/**
|
|
4299
|
+
* Register a handler for interactive messages (buttons, lists, flows)
|
|
4300
|
+
* @param handler Type-safe handler that receives interactive messages with guaranteed interactive field
|
|
4301
|
+
*/
|
|
4302
|
+
onInteractive(handler: InteractiveMessageHandler): void;
|
|
4303
|
+
/**
|
|
4304
|
+
* Register a handler for button messages
|
|
4305
|
+
* @param handler Type-safe handler that receives button messages with guaranteed button field
|
|
4306
|
+
*/
|
|
4307
|
+
onButton(handler: ButtonMessageHandler): void;
|
|
4308
|
+
/**
|
|
4309
|
+
* Register a handler for location messages
|
|
4310
|
+
* @param handler Type-safe handler that receives location messages with guaranteed location field
|
|
4311
|
+
*/
|
|
4312
|
+
onLocation(handler: LocationMessageHandler): void;
|
|
4313
|
+
/**
|
|
4314
|
+
* Register a handler for contact messages
|
|
4315
|
+
* @param handler Type-safe handler that receives contact messages with guaranteed contacts field
|
|
4316
|
+
*/
|
|
4317
|
+
onContacts(handler: ContactsMessageHandler): void;
|
|
4318
|
+
/**
|
|
4319
|
+
* Register a handler for reaction messages
|
|
4320
|
+
* @param handler Type-safe handler that receives reaction messages with guaranteed reaction field
|
|
4321
|
+
*/
|
|
4322
|
+
onReaction(handler: ReactionMessageHandler): void;
|
|
4323
|
+
/**
|
|
4324
|
+
* Register a handler for order messages
|
|
4325
|
+
* @param handler Type-safe handler that receives order messages with guaranteed order field
|
|
4326
|
+
*/
|
|
4327
|
+
onOrder(handler: OrderMessageHandler): void;
|
|
4328
|
+
/**
|
|
4329
|
+
* Register a handler for system messages
|
|
4330
|
+
* @param handler Type-safe handler that receives system messages with guaranteed system field
|
|
4331
|
+
*/
|
|
4332
|
+
onSystem(handler: SystemMessageHandler): void;
|
|
4088
4333
|
getClient(): WhatsApp;
|
|
4089
4334
|
getConfig(): WabaConfigType;
|
|
4090
4335
|
}
|
|
@@ -4183,5 +4428,73 @@ declare function nextjsAppWebhookHandler(config: NextJsAppWebhookConfig): {
|
|
|
4183
4428
|
//#region src/core/webhook/utils/generateXHub256Sig.d.ts
|
|
4184
4429
|
declare const generateXHub256Sig: (body: string, appSecret: string) => string;
|
|
4185
4430
|
//#endregion
|
|
4186
|
-
|
|
4431
|
+
//#region src/utils/buildFieldsQueryString.d.ts
|
|
4432
|
+
declare function buildFieldsQueryString(fields?: string[] | string): string;
|
|
4433
|
+
//#endregion
|
|
4434
|
+
//#region src/utils/configTable.d.ts
|
|
4435
|
+
/**
|
|
4436
|
+
* Formats configuration as a terminal table
|
|
4437
|
+
* @param config - The WABA configuration object
|
|
4438
|
+
* @param apiName - The name of the API being initialized
|
|
4439
|
+
* @returns Formatted table string
|
|
4440
|
+
*/
|
|
4441
|
+
declare function formatConfigTable(config: WabaConfigType): string;
|
|
4442
|
+
//#endregion
|
|
4443
|
+
//#region src/utils/logger.d.ts
|
|
4444
|
+
declare class Logger implements LoggerInterface {
|
|
4445
|
+
private name;
|
|
4446
|
+
private debug;
|
|
4447
|
+
constructor(name: string, debug?: boolean);
|
|
4448
|
+
private formatData;
|
|
4449
|
+
log(...data: any[]): void;
|
|
4450
|
+
error(...data: any[]): void;
|
|
4451
|
+
warn(...data: any[]): void;
|
|
4452
|
+
info(...data: any[]): void;
|
|
4453
|
+
}
|
|
4454
|
+
//#endregion
|
|
4455
|
+
//#region src/utils/objectToQueryString.d.ts
|
|
4456
|
+
declare const objectToQueryString: (params: Record<string, any>) => string;
|
|
4457
|
+
//#endregion
|
|
4458
|
+
//#region src/utils/flowTypeGuards.d.ts
|
|
4459
|
+
declare const DATA_EXCHANGE_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK];
|
|
4460
|
+
declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT];
|
|
4461
|
+
/**
|
|
4462
|
+
* Type guard to check if a request is a Data Exchange request
|
|
4463
|
+
* Validates the request structure according to the Flow API specifications
|
|
4464
|
+
*
|
|
4465
|
+
* @param request The Flow endpoint request to check
|
|
4466
|
+
* @returns True if the request is a valid Data Exchange request, false otherwise
|
|
4467
|
+
*/
|
|
4468
|
+
declare function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {
|
|
4469
|
+
action: (typeof DATA_EXCHANGE_ACTIONS)[number];
|
|
4470
|
+
screen?: string;
|
|
4471
|
+
flow_token: string;
|
|
4472
|
+
data?: Record<string, any>;
|
|
4473
|
+
};
|
|
4474
|
+
/**
|
|
4475
|
+
* Type guard to check if a request is an Error Notification request
|
|
4476
|
+
* Validates the request structure according to the Flow API error specifications
|
|
4477
|
+
*
|
|
4478
|
+
* @param request The Flow endpoint request to check
|
|
4479
|
+
* @returns True if the request is a valid Error Notification request, false otherwise
|
|
4480
|
+
*/
|
|
4481
|
+
declare function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {
|
|
4482
|
+
action: (typeof ERROR_ACTIONS)[number];
|
|
4483
|
+
screen: string;
|
|
4484
|
+
flow_token: string;
|
|
4485
|
+
data: {
|
|
4486
|
+
error: string;
|
|
4487
|
+
error_message: string;
|
|
4488
|
+
};
|
|
4489
|
+
};
|
|
4490
|
+
/**
|
|
4491
|
+
* Type guard to check if a request is a Ping (health check) request
|
|
4492
|
+
* Simple validation for health check endpoints in the Flow API
|
|
4493
|
+
*
|
|
4494
|
+
* @param request The Flow endpoint request to check
|
|
4495
|
+
* @returns True if the request is a Ping request, false otherwise
|
|
4496
|
+
*/
|
|
4497
|
+
declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
|
|
4498
|
+
//#endregion
|
|
4499
|
+
export { AccountMode, AudioMediaObject, AudioMediaTypesEnum, AudioMessage, AudioMessageHandler, AudioProcessedMessage, AuthenticationTemplateOptions, BaseClass, BlockUserObject, BlockUsersApi, BlockUsersClass, BlockUsersRequest, BlockUsersResponse, BlockedUserInfo, BodyOptions, BusinessProfileApi, BusinessProfileClass, BusinessProfileData, BusinessProfileField, BusinessProfileFieldsParam, BusinessProfileResponse, BusinessVerticalEnum, ButtonMessage, ButtonMessageHandler, ButtonOptions, ButtonPositionEnum, ButtonProcessedMessage, CarouselCard, CarouselOptions, CatalogButton, CatalogTemplateOptions, CategoryEnum, CodeVerificationStatus, ComponentTypes, ComponentTypesEnum, ContactObject, ContactsMessage, ContactsMessageHandler, ContactsProcessedMessage, ConversationTypesEnum, CopyCodeButton, CouponTemplateOptions, CreateFlowResponse, CreateQrCodeRequest, CreateUploadSessionParams, CurrencyCodesEnum, CurrencyParameter, Cursors, DataLocalizationRegionEnum, DateTimeParameter, DocumentMediaObject, DocumentMediaTypesEnum, DocumentMessage, DocumentMessageHandler, DocumentProcessedMessage, EncryptionApi, EncryptionClass, EncryptionKeyPair, EncryptionPublicKeyResponse, ErrorWebhookValue, ExpressRequest, ExpressResponse, ExpressWebhookConfig, FailedUserInfo, Flow, FlowActionEnum, FlowApi, FlowAsset, FlowAssetsResponse, FlowButton, FlowCategoryEnum, FlowClass, FlowDataExchangeRequest, FlowDataExchangeResponse, FlowDecryptedRequestResponse, FlowEncryptedRequestPayload, FlowEndpointRequest, FlowEndpointResponse, FlowErrorNotificationRequest, FlowErrorNotificationResponse, FlowHandler, FlowHealthCheckRequest, FlowHealthCheckResponse, FlowHttpRequest, FlowMigrationFailure, FlowMigrationResponse, FlowMigrationResult, FlowPreview, FlowPreviewResponse, FlowStatusEnum, FlowSuccessScreenResponse, FlowType, FlowTypeEnum, FlowValidationError, FlowValidationErrorPointer, FlowsListResponse, FooterOptions, GeneralHeaderInterface, GeneralMessageBody, GeneralRequestBody, GetUploadHandleParams, GroupMessage, HeaderOptions, HealthStatus, HealthStatusEntity, HttpMethodsEnum, HttpsClientClass, HttpsClientResponseClass, ImageMediaObject, ImageMediaTypesEnum, ImageMessage, ImageMessageHandler, ImageProcessedMessage, InteractiveButtonReplyMessage, InteractiveListReplyMessage, InteractiveMessage, InteractiveMessageHandler, InteractiveObject, InteractiveProcessedMessage, InteractiveTypesEnum, LanguagesEnum, LimitedTimeOfferOptions, LimitedTimeOfferTemplateOptions, ListBlockedUsersParams, ListBlockedUsersResponse, LocationMessage, LocationMessageHandler, LocationObject, LocationParameter, LocationProcessedMessage, Logger, LoggerInterface, MPMButton, MPMTemplateOptions, MediaApi, MediaCardCarouselTemplateOptions, MediaCarouselCard, MediaClass, MediaParameter, MediaResponse, MediasResponse, MessagesApi as MessageApi, MessagesApi, MessageHandler, MessageRequestBody, MessageRequestParams, MessageStatus, MessageTemplateObject, MessageTypesEnum, MessageWebhookValue, MessagesClass, MessagesResponse, MessagingLimitTier, MetaError, MetaErrorDetail, NextFunction, NextJsAppWebhookConfig, NextJsWebhookConfig, OTPButton, OTPTemplateOptions, OrderMessage, OrderMessageHandler, OrderProcessedMessage, Pagination, PaginationCursors, Paging, PagingCursors, PagingInfo, ParametersTypesEnum, PhoneNumberApi, PhoneNumberButton, PhoneNumberClass, PhoneNumberResponse, PhoneNumbersResponse, PlatformType, ProcessedMessage, ProcessedStatus, ProductCardCarouselTemplateOptions, ProductCarouselCard, ProductParameter, ProductSection, QrCodeApi, QrCodeClass, QrCodeResponse, QrCodesResponse, QualityRating, QualityScore, QuickReplyButton, ReactionMessage, ReactionMessageHandler, ReactionParams, ReactionProcessedMessage, ReferralSourceTypesEnum, RegistrationApi, RegistrationClass, RegistrationRequest, RequestCodeMethodsEnum, RequestVerificationCodeRequest, RequesterClass, RequesterResponseInterface, ResponseData, ResponseHeaderValue, ResponseHeaders, ResponseJSONBody, ResponsePagination, ResponseSuccess, SPMButton, SPMTemplateOptions, StatusEnum, StatusHandler, StatusParams, StatusWebhook, StatusWebhookValue, StickerMediaObject, StickerMediaTypesEnum, StickerMessage, StickerMessageHandler, StickerProcessedMessage, SubTypeEnum, SystemChangeTypesEnum, SystemMessage, SystemMessageHandler, SystemProcessedMessage, TemplateApi, TemplateBody, TemplateButton, TemplateButtons, TemplateCarousel, TemplateClass, TemplateDeleteParams, TemplateFooter, TemplateFormat, TemplateGetParams, TemplateHeader, TemplateHeaderExample, TemplateLimitedTimeOffer, TemplateOptions, TemplateParameter, TemplateRequestBody, TemplateResponse, TemplateStatusEnum, TextMessage, TextMessageHandler, TextMessageParams, TextObject, TextParameter, TextProcessedMessage, Throughput, ThroughputLevel, TwoStepVerificationApi, TwoStepVerificationClass, TwoStepVerificationParams, TwoStepVerificationRequest, URLButton, UnblockUsersRequest, UnsupportedMessage, UpdateBusinessProfileRequest, UpdateFlowResponse, UpdateQrCodeRequest, UpdateWabaSubscription, UploadBusinessProfileResponse, UploadHandle, UploadMediaParams, UploadMediaResponse, UploadSession, UploadSessionResponse, ValidateFlowJsonResponse, VerifyCodeRequest, VideoMediaObject, VideoMediaTypesEnum, VideoMessage, VideoMessageHandler, VideoProcessedMessage, WABAClass, WabaAccount, WabaAccountFields, WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaApi, WabaBusinessVerificationStatus, WabaConfigEnum, WabaConfigType, WabaHealthStatus, WabaHealthStatusCanSendMessage, WabaHealthStatusEntity, WabaHealthStatusError, WabaSubscription, WabaSubscriptions, WebhookContact, WebhookEvent, WebhookMessage, WebhookPayload, WebhookProcessor, WebhookResponse, WebhookTypesEnum, WebhookValue, WhatsApp, WhatsAppConfig, WhatsAppMessage, buildFieldsQueryString, constructFullUrl, createAuthenticationTemplate, createCatalogTemplate, createCouponTemplate, createLimitedTimeOfferTemplate, createMPMTemplate, createMediaCardCarouselTemplate, createOTPTemplate, createProductCardCarouselTemplate, createSPMTemplate, createTemplate, expressWebhookHandler, formatConfigTable, generateEncryption, generateXHub256Sig, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, isMetaError, nextjsAppWebhookHandler, nextjsPagesWebhookHandler, objectToQueryString, processFlowRequest, processWebhookMessages };
|
|
4187
4500
|
//# sourceMappingURL=index.d.ts.map
|