meta-cloud-api 0.2.33 → 0.2.35

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.
Files changed (69) hide show
  1. package/dist/{BusinessProfileApi-DDkv2WQK.d.ts → BusinessProfileApi-BJ9zy6c2.d.ts} +3 -3
  2. package/dist/{EncryptionApi-CwxQlC-2.d.ts → EncryptionApi-1aZ13Qyh.d.ts} +1 -1
  3. package/dist/{FlowApi-C5-2BGAw.d.ts → FlowApi-QDjrvCLp.d.ts} +2 -2
  4. package/dist/{MediaApi-VqxndaBJ.d.ts → MediaApi-V44kQnsN.d.ts} +1 -1
  5. package/dist/{MessageApi-CHc6bn3g.d.ts → MessageApi-BhSK0pfd.d.ts} +2 -2
  6. package/dist/{PhoneNumberApi-C-bs6YAe.d.ts → PhoneNumberApi-CPAIS17R.d.ts} +2 -2
  7. package/dist/{QrCodeApi-BjlyPUXV.d.ts → QrCodeApi-BjPYQIWF.d.ts} +1 -1
  8. package/dist/{RegistrationApi-D7Bg8BUz.d.ts → RegistrationApi-CGlvAgaz.d.ts} +2 -2
  9. package/dist/{TemplateApi-dmZbvMkO.d.ts → TemplateApi-D_23Ys02.d.ts} +3 -3
  10. package/dist/{TwoStepVerificationApi-DaYWPjY_.d.ts → TwoStepVerificationApi-CXMjxkUl.d.ts} +1 -1
  11. package/dist/{WabaApi-CMoTCWiH.d.ts → WabaApi-BwnBkMPm.d.ts} +1 -1
  12. package/dist/WebhookHandler-Dn1NlyGm.d.ts +733 -0
  13. package/dist/{base-BG2gtoDs.d.ts → base-DtfdeScM.d.ts} +2 -2
  14. package/dist/{chunk-FFOE5YKT.js → chunk-GT3XQN7Y.js} +2 -2
  15. package/dist/chunk-GT3XQN7Y.js.map +1 -0
  16. package/dist/chunk-H55VIWDI.js +2 -0
  17. package/dist/chunk-H55VIWDI.js.map +1 -0
  18. package/dist/chunk-I222VSWK.js +2 -0
  19. package/dist/chunk-I222VSWK.js.map +1 -0
  20. package/dist/{chunk-AQTZR5SI.js → chunk-LGLRGXCE.js} +2 -2
  21. package/dist/{chunk-AQTZR5SI.js.map → chunk-LGLRGXCE.js.map} +1 -1
  22. package/dist/chunk-LYB4T5PE.js +3 -0
  23. package/dist/chunk-LYB4T5PE.js.map +1 -0
  24. package/dist/{chunk-XIIJD6SG.js → chunk-R36L2XYO.js} +2 -2
  25. package/dist/chunk-R36L2XYO.js.map +1 -0
  26. package/dist/chunk-SMHCU5MN.js +2 -0
  27. package/dist/chunk-SMHCU5MN.js.map +1 -0
  28. package/dist/chunk-YJWNS2MK.js +3 -0
  29. package/dist/chunk-YJWNS2MK.js.map +1 -0
  30. package/dist/core/webhook/index.d.ts +21 -0
  31. package/dist/core/webhook/index.js +2 -0
  32. package/dist/core/webhook/index.js.map +1 -0
  33. package/dist/core/whatsapp/index.d.ts +100 -0
  34. package/dist/core/whatsapp/index.js +2 -0
  35. package/dist/core/whatsapp/index.js.map +1 -0
  36. package/dist/{enums-Z1f7QuVx.d.ts → enums-DcRC4vFO.d.ts} +2 -1
  37. package/dist/features/encryption/index.d.ts +4 -4
  38. package/dist/features/encryption/index.js +1 -1
  39. package/dist/features/flow/index.d.ts +4 -4
  40. package/dist/features/flow/index.js +1 -1
  41. package/dist/features/media/index.d.ts +4 -4
  42. package/dist/features/media/index.js +1 -1
  43. package/dist/features/messages/index.d.ts +4 -4
  44. package/dist/features/messages/index.js +1 -1
  45. package/dist/features/phone/index.d.ts +4 -4
  46. package/dist/features/phone/index.js +1 -1
  47. package/dist/features/profile/index.d.ts +4 -4
  48. package/dist/features/profile/index.js +1 -1
  49. package/dist/features/qrCode/index.d.ts +4 -4
  50. package/dist/features/qrCode/index.js +1 -1
  51. package/dist/features/registration/index.d.ts +4 -4
  52. package/dist/features/registration/index.js +1 -1
  53. package/dist/features/template/index.d.ts +4 -4
  54. package/dist/features/template/index.js +1 -1
  55. package/dist/features/twoStepVerification/index.d.ts +4 -4
  56. package/dist/features/twoStepVerification/index.js +1 -1
  57. package/dist/features/waba/index.d.ts +4 -4
  58. package/dist/features/waba/index.js +1 -1
  59. package/dist/index.d.ts +35 -671
  60. package/dist/index.js +1 -2
  61. package/dist/index.js.map +1 -1
  62. package/dist/shared/types/config.d.ts +1 -1
  63. package/dist/shared/types/enums.d.ts +1 -1
  64. package/dist/shared/types/enums.js +1 -1
  65. package/package.json +2 -2
  66. package/dist/chunk-EYGUX4EA.js +0 -2
  67. package/dist/chunk-EYGUX4EA.js.map +0 -1
  68. package/dist/chunk-FFOE5YKT.js.map +0 -1
  69. package/dist/chunk-XIIJD6SG.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,533 +1,44 @@
1
- import { M as MessageTypesEnum, H as HttpMethodsEnum, S as SDKEnums } from './enums-Z1f7QuVx.js';
2
- export { a as StatusEnum, W as WebhookTypesEnum } from './enums-Z1f7QuVx.js';
3
- import { WhatsAppConfig, WabaConfigType } from './shared/types/config.js';
4
- import { IncomingMessage } from 'http';
5
- import { F as FlowApi, a as FlowEndpointRequest, b as FlowDataExchangeRequest, c as FlowActionEnum, d as FlowErrorNotificationRequest, e as FlowHealthCheckRequest, f as FlowType } from './FlowApi-C5-2BGAw.js';
6
- export { g as Flow, h as FlowClass, i as FlowEndpointResponse, j as FlowTypeEnum } from './FlowApi-C5-2BGAw.js';
7
- import { E as EncryptionApi } from './EncryptionApi-CwxQlC-2.js';
8
- import { M as MediaApi } from './MediaApi-VqxndaBJ.js';
9
- export { a as MediaClass, b as MediaResponse, c as MediasResponse, U as UploadMediaResponse } from './MediaApi-VqxndaBJ.js';
10
- import { M as MessagesApi } from './MessageApi-CHc6bn3g.js';
11
- export { A as AudioMediaObject, C as ContactObject, D as DocumentMediaObject, I as ImageMediaObject, a as InteractiveObject, L as LocationObject, b as MessageRequestParams, d as MessageTemplateObject, c as MessagesResponse, R as ReactionParams, S as StatusParams, e as StickerMediaObject, T as TextMessageParams, f as TextObject, V as VideoMediaObject } from './MessageApi-CHc6bn3g.js';
12
- import { P as PhoneNumberApi } from './PhoneNumberApi-C-bs6YAe.js';
13
- export { a as PhoneNumberClass, b as PhoneNumberResponse } from './PhoneNumberApi-C-bs6YAe.js';
14
- import { B as BusinessProfileApi } from './BusinessProfileApi-DDkv2WQK.js';
15
- export { a as BusinessProfileClass, b as BusinessProfileResponse } from './BusinessProfileApi-DDkv2WQK.js';
16
- import { Q as QrCodeApi } from './QrCodeApi-BjlyPUXV.js';
17
- export { a as QrCodeClass, b as QrCodeResponse } from './QrCodeApi-BjlyPUXV.js';
18
- import { R as RegistrationApi } from './RegistrationApi-D7Bg8BUz.js';
19
- export { a as RegistrationClass } from './RegistrationApi-D7Bg8BUz.js';
20
- import { T as TemplateApi } from './TemplateApi-dmZbvMkO.js';
21
- export { a as TemplateClass, b as TemplateResponse } from './TemplateApi-dmZbvMkO.js';
22
- import { T as TwoStepVerificationApi } from './TwoStepVerificationApi-DaYWPjY_.js';
23
- import { W as WabaApi } from './WabaApi-CMoTCWiH.js';
24
- export { b as WABAClass, a as WabaAccount } from './WabaApi-CMoTCWiH.js';
25
- import { Agent } from 'https';
26
- import { R as RequesterClass } from './base-BG2gtoDs.js';
1
+ export { W as WebhookContact, a as WebhookEvent, c as WebhookHandler, b as WebhookMessage } from './WebhookHandler-Dn1NlyGm.js';
2
+ import { g as FlowEndpointRequest, o as FlowDataExchangeRequest, c as FlowActionEnum, p as FlowErrorNotificationRequest, q as FlowHealthCheckRequest } from './FlowApi-QDjrvCLp.js';
3
+ export { a as Flow, F as FlowApi, f as FlowClass, h as FlowEndpointResponse, b as FlowType, n as FlowTypeEnum } from './FlowApi-QDjrvCLp.js';
4
+ export { WabaConfigType, WhatsAppConfig } from './shared/types/config.js';
5
+ export { A as AudioMediaTypesEnum, B as BusinessVerticalEnum, a as ButtonPositionEnum, b as ButtonTypesEnum, C as CategoryEnum, c as ComponentTypesEnum, d as ConversationTypesEnum, e as CurrencyCodesEnum, D as DataLocalizationRegionEnum, f as DocumentMediaTypesEnum, H as HttpMethodsEnum, I as ImageMediaTypesEnum, g as InteractiveTypesEnum, L as LanguagesEnum, M as MessageTypesEnum, P as ParametersTypesEnum, R as ReferralSourceTypesEnum, h as RequestCodeMethodsEnum, S as StatusEnum, i as StickerMediaTypesEnum, j as SystemChangeTypesEnum, T as TemplateStatusEnum, V as VideoMediaTypesEnum, W as WabaConfigEnum, k as WebhookTypesEnum } from './enums-DcRC4vFO.js';
6
+ export { E as EncryptionApi } from './EncryptionApi-1aZ13Qyh.js';
7
+ export { a as MediaClass, b as MediaResponse, c as MediasResponse, U as UploadMediaResponse } from './MediaApi-V44kQnsN.js';
8
+ export { A as AudioMediaObject, C as ContactObject, D as DocumentMediaObject, I as ImageMediaObject, a as InteractiveObject, L as LocationObject, b as MessageRequestParams, d as MessageTemplateObject, M as MessagesApi, c as MessagesResponse, R as ReactionParams, S as StatusParams, e as StickerMediaObject, T as TextMessageParams, f as TextObject, V as VideoMediaObject } from './MessageApi-BhSK0pfd.js';
9
+ export { P as PhoneNumberApi, c as PhoneNumberClass, d as PhoneNumberResponse } from './PhoneNumberApi-CPAIS17R.js';
10
+ export { B as BusinessProfileApi, a as BusinessProfileClass, e as BusinessProfileResponse } from './BusinessProfileApi-BJ9zy6c2.js';
11
+ export { Q as QrCodeApi, a as QrCodeClass, b as QrCodeResponse } from './QrCodeApi-BjPYQIWF.js';
12
+ export { R as RegistrationApi, a as RegistrationClass } from './RegistrationApi-CGlvAgaz.js';
13
+ export { T as TemplateApi, a as TemplateClass, e as TemplateResponse } from './TemplateApi-D_23Ys02.js';
14
+ export { T as TwoStepVerificationApi } from './TwoStepVerificationApi-CXMjxkUl.js';
15
+ export { b as WABAClass, a as WabaAccount, W as WabaApi } from './WabaApi-BwnBkMPm.js';
16
+ export { WhatsApp } from './core/whatsapp/index.js';
27
17
  export { MetaError, isMetaError } from './shared/utils/isMetaError.js';
18
+ import './base-DtfdeScM.js';
19
+ import 'https';
28
20
 
29
- /**
30
- * Represents a message received through the webhook
31
- * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
32
- */
33
- interface WebhookMessage {
34
- /**
35
- * The message ID
36
- */
37
- id: string;
38
- /**
39
- * The sender's phone number
40
- */
41
- from: string;
42
- /**
43
- * The timestamp of the message
44
- */
45
- timestamp: string;
46
- /**
47
- * The type of message (text, image, etc.)
48
- */
49
- type: MessageTypesEnum;
50
- /**
51
- * The phone number ID that received the message
52
- */
53
- phoneNumberId: string;
54
- /**
55
- * The display phone number that received the message
56
- */
57
- displayPhoneNumber: string;
58
- /**
59
- * The profile name of the sender
60
- */
61
- profileName: string;
62
- /**
63
- * Text object for text messages
64
- */
65
- text?: {
66
- /**
67
- * The text content of the message
68
- */
69
- body: string;
70
- };
71
- /**
72
- * Image object for image messages
73
- */
74
- image?: {
75
- /**
76
- * The image caption (if provided)
77
- */
78
- caption?: string;
79
- /**
80
- * The SHA256 hash of the image
81
- */
82
- sha256?: string;
83
- /**
84
- * The ID for the image
85
- */
86
- id: string;
87
- /**
88
- * The MIME type of the image
89
- */
90
- mime_type: string;
91
- };
92
- /**
93
- * Video object for video messages
94
- */
95
- video?: {
96
- /**
97
- * The video caption (if provided)
98
- */
99
- caption?: string;
100
- /**
101
- * The SHA256 hash of the video
102
- */
103
- sha256?: string;
104
- /**
105
- * The ID for the video
106
- */
107
- id: string;
108
- /**
109
- * The MIME type of the video
110
- */
111
- mime_type: string;
112
- };
113
- /**
114
- * Audio object for audio messages
115
- */
116
- audio?: {
117
- /**
118
- * The ID for the audio file
119
- */
120
- id: string;
121
- /**
122
- * The MIME type of the audio file
123
- */
124
- mime_type: string;
125
- /**
126
- * Whether the audio is a voice message
127
- */
128
- voice?: boolean;
129
- };
130
- /**
131
- * Document object for document messages
132
- */
133
- document?: {
134
- /**
135
- * The document caption (if provided)
136
- */
137
- caption?: string;
138
- /**
139
- * The document filename
140
- */
141
- filename: string;
142
- /**
143
- * The SHA256 hash of the document
144
- */
145
- sha256?: string;
146
- /**
147
- * The ID for the document
148
- */
149
- id: string;
150
- /**
151
- * The MIME type of the document
152
- */
153
- mime_type: string;
154
- };
155
- /**
156
- * Sticker object for sticker messages
157
- */
158
- sticker?: {
159
- /**
160
- * The ID for the sticker
161
- */
162
- id: string;
163
- /**
164
- * Whether this is an animated sticker
165
- */
166
- animated: boolean;
167
- /**
168
- * The MIME type of the sticker
169
- */
170
- mime_type: string;
171
- };
172
- /**
173
- * Reaction object for reaction messages
174
- */
175
- reaction?: {
176
- /**
177
- * The ID of the message being reacted to
178
- */
179
- message_id: string;
180
- /**
181
- * Emoji used for the reaction
182
- */
183
- emoji: string;
184
- };
185
- /**
186
- * Contacts object for contact messages
187
- */
188
- contacts?: Array<{
189
- /**
190
- * The contact's name
191
- */
192
- name: {
193
- /**
194
- * The formatted name
195
- */
196
- formatted_name: string;
197
- /**
198
- * The first name
199
- */
200
- first_name?: string;
201
- /**
202
- * The last name
203
- */
204
- last_name?: string;
205
- /**
206
- * The middle name
207
- */
208
- middle_name?: string;
209
- /**
210
- * The suffix
211
- */
212
- suffix?: string;
213
- /**
214
- * The prefix
215
- */
216
- prefix?: string;
217
- };
218
- /**
219
- * The contact's phone numbers
220
- */
221
- phones?: Array<{
222
- phone: string;
223
- type?: string;
224
- wa_id?: string;
225
- }>;
226
- /**
227
- * The contact's emails
228
- */
229
- emails?: Array<{
230
- email: string;
231
- type?: string;
232
- }>;
233
- /**
234
- * The contact's addresses
235
- */
236
- addresses?: Array<{
237
- street?: string;
238
- city?: string;
239
- state?: string;
240
- zip?: string;
241
- country?: string;
242
- country_code?: string;
243
- type?: string;
244
- }>;
245
- /**
246
- * The contact's organizations
247
- */
248
- org?: {
249
- company?: string;
250
- department?: string;
251
- title?: string;
252
- };
253
- /**
254
- * The contact's URLs
255
- */
256
- urls?: Array<{
257
- url: string;
258
- type?: string;
259
- }>;
260
- /**
261
- * The contact's birthday (YYYY-MM-DD format)
262
- */
263
- birthday?: string;
264
- }>;
265
- /**
266
- * Location object for location messages
267
- */
268
- location?: {
269
- /**
270
- * Latitude of the location
271
- */
272
- latitude: number;
273
- /**
274
- * Longitude of the location
275
- */
276
- longitude: number;
277
- /**
278
- * Name of the location
279
- */
280
- name?: string;
281
- /**
282
- * Address of the location
283
- */
284
- address?: string;
285
- };
286
- /**
287
- * Interactive object for interactive messages
288
- */
289
- interactive?: {
290
- /**
291
- * Type of the interactive message
292
- * Can be: button_reply, list_reply, flow, nfm_reply, etc.
293
- */
294
- type: string;
295
- /**
296
- * ID for the button that was clicked
297
- */
298
- button_reply?: {
299
- id: string;
300
- title: string;
301
- };
302
- /**
303
- * ID for the list item that was selected
304
- */
305
- list_reply?: {
306
- id: string;
307
- title: string;
308
- description?: string;
309
- };
310
- /**
311
- * NFM (No-Code Flow Message) reply data
312
- */
313
- nfm_reply?: {
314
- /**
315
- * Response data in JSON format
316
- */
317
- response_json: string;
318
- /**
319
- * Body text of the reply
320
- */
321
- body: string;
322
- /**
323
- * Name of the flow
324
- */
325
- name: string;
326
- };
327
- };
328
- /**
329
- * System object for system messages (like user phone number changes)
330
- */
331
- system?: {
332
- /**
333
- * The type of system update
334
- */
335
- type: string;
336
- /**
337
- * User's identity if the update is a customer identity change
338
- */
339
- identity?: string;
340
- /**
341
- * Old and new phone numbers if the update is a phone number change
342
- */
343
- customer?: {
344
- /**
345
- * The previous phone number
346
- */
347
- previous_wa_id: string;
348
- /**
349
- * The new phone number
350
- */
351
- wa_id: string;
352
- };
353
- };
354
- /**
355
- * Order object for order messages
356
- */
357
- order?: {
358
- /**
359
- * Catalog ID
360
- */
361
- catalog_id: string;
362
- /**
363
- * Product items in the order
364
- */
365
- product_items: Array<{
366
- /**
367
- * Product ID
368
- */
369
- product_retailer_id: string;
370
- /**
371
- * Quantity of the product
372
- */
373
- quantity: number;
374
- /**
375
- * Item price
376
- */
377
- item_price: number;
378
- /**
379
- * Currency code
380
- */
381
- currency: string;
382
- }>;
383
- /**
384
- * Text message included with the order
385
- */
386
- text?: string;
387
- };
388
- /**
389
- * Context object, included when a user replies or interacts
390
- */
391
- context?: {
392
- /**
393
- * ID of the message
394
- */
395
- id?: string;
396
- /**
397
- * ID of the sender
398
- */
399
- from?: string;
400
- /**
401
- * ID of the message being replied to or interacted with
402
- */
403
- message_id: string;
404
- /**
405
- * ID of the forwarded message, if applicable
406
- */
407
- forwarded?: boolean;
408
- /**
409
- * Frequently forwarded status
410
- */
411
- frequently_forwarded?: boolean;
412
- /**
413
- * Original message information if the message was referred
414
- */
415
- referred_product?: {
416
- /**
417
- * Catalog ID
418
- */
419
- catalog_id: string;
420
- /**
421
- * Product ID
422
- */
423
- product_retailer_id: string;
424
- };
425
- };
426
- /**
427
- * Errors array, if the message had errors
428
- */
429
- errors?: Array<{
430
- /**
431
- * Error code
432
- */
433
- code: number;
434
- /**
435
- * Error title
436
- */
437
- title: string;
438
- /**
439
- * Error message
440
- */
441
- message: string;
442
- /**
443
- * Error details object
444
- */
445
- error_data?: {
446
- /**
447
- * Describes the error details
448
- */
449
- details: string;
450
- };
451
- }>;
452
- /**
453
- * Button object for button messages
454
- */
455
- button?: {
456
- /**
457
- * The payload for the button
458
- */
459
- payload: string;
460
- /**
461
- * Button text
462
- */
463
- text: string;
464
- };
465
- /**
466
- * The original message data as received from the webhook
467
- */
468
- originalData: any;
469
- }
470
- /**
471
- * Webhook event received from WhatsApp
472
- */
473
- interface WebhookEvent {
474
- /**
475
- * The field type of the event
476
- */
477
- field: string;
478
- /**
479
- * The event data
480
- */
481
- value: any;
482
- /**
483
- * The timestamp when the event was received
484
- */
485
- timestamp: number;
486
- }
487
-
488
- type ResponseHeaderValue = string | string[] | undefined;
489
- type ResponseHeaders = Record<string, ResponseHeaderValue>;
490
- type ResponseJSONBody = Record<string, unknown>;
491
- declare class HttpsClientResponseClass {
492
- constructor(resp: Response);
493
- statusCode: () => number;
494
- headers: () => ResponseHeaders;
495
- rawResponse: () => Response;
496
- json: () => Promise<ResponseJSONBody>;
497
- }
498
- declare class HttpsClientClass {
499
- constructor();
500
- clearSockets: () => boolean;
501
- sendRequest: (host: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null) => Promise<HttpsClientResponseClass>;
21
+ interface LoggerInterface {
22
+ log(...data: any[]): void;
23
+ error(...data: any[]): void;
24
+ warn(...data: any[]): void;
25
+ info(...data: any[]): void;
26
+ debug(...data: any[]): void;
502
27
  }
503
28
 
504
- declare class WhatsAppClass {
505
- constructor(config?: WhatsAppConfig);
506
- readonly messages: MessagesApi;
507
- readonly templates: TemplateApi;
508
- readonly phoneNumber: PhoneNumberApi;
509
- readonly qrCode: QrCodeApi;
510
- readonly encryption: EncryptionApi;
511
- readonly twoStepVerification: TwoStepVerificationApi;
512
- readonly registration: RegistrationApi;
513
- readonly media: MediaApi;
514
- readonly waba: WabaApi;
515
- readonly flow: FlowApi;
516
- readonly businessProfile: BusinessProfileApi;
517
- updateTimeout(ms: number): boolean;
518
- updatePhoneNumberId(phoneNumberId: number): boolean;
519
- updateAccessToken(accessToken: string): boolean;
520
- updateWabaId(wabaId: string): boolean;
521
- }
29
+ declare function buildFieldsQueryString(fields?: string[] | string): string;
522
30
 
523
- declare class HttpsClient implements HttpsClientClass {
524
- agent: Agent;
525
- constructor();
526
- clearSockets(): boolean;
527
- sendRequest(hostname: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null): Promise<HttpsClientResponseClass>;
31
+ declare class Logger implements LoggerInterface {
32
+ private name;
33
+ private debug;
34
+ constructor(name: string, debug?: boolean);
35
+ log(...data: any[]): void;
36
+ error(...data: any[]): void;
37
+ warn(...data: any[]): void;
38
+ info(...data: any[]): void;
528
39
  }
529
40
 
530
- declare const importConfig: (inputConfig?: WhatsAppConfig) => WabaConfigType;
41
+ declare const objectToQueryString: (params: Record<string, any>) => string;
531
42
 
532
43
  declare const DATA_EXCHANGE_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK];
533
44
  declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT];
@@ -569,151 +80,4 @@ declare function isFlowErrorRequest(request: FlowEndpointRequest): request is Fl
569
80
  */
570
81
  declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
571
82
 
572
- declare class Requester implements RequesterClass {
573
- client: Readonly<HttpsClient>;
574
- accessToken: Readonly<string>;
575
- phoneNumberId: Readonly<number>;
576
- businessAcctId: Readonly<string>;
577
- apiVersion: Readonly<string>;
578
- userAgent: Readonly<string>;
579
- host: Readonly<string>;
580
- protocol: Readonly<string>;
581
- constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
582
- buildHeader(contentType: string, additionalHeaders?: Record<string, string>): HeadersInit;
583
- buildCAPIPath(endpoint: string): string;
584
- sendRequest(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, contentType?: string, additionalHeaders?: Record<string, string>): Promise<HttpsClientResponseClass>;
585
- getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, additionalHeaders?: Record<string, string>): Promise<T>;
586
- sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
587
- sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
588
- }
589
-
590
- declare class WhatsApp implements WhatsAppClass {
591
- config: WabaConfigType;
592
- requester: Readonly<Requester>;
593
- readonly messages: MessagesApi;
594
- readonly templates: TemplateApi;
595
- readonly phoneNumber: PhoneNumberApi;
596
- readonly qrCode: QrCodeApi;
597
- readonly encryption: EncryptionApi;
598
- readonly twoStepVerification: TwoStepVerificationApi;
599
- readonly registration: RegistrationApi;
600
- readonly media: MediaApi;
601
- readonly waba: WabaApi;
602
- readonly flow: FlowApi;
603
- readonly businessProfile: BusinessProfileApi;
604
- static readonly Enums: typeof SDKEnums;
605
- constructor(config?: WhatsAppConfig);
606
- private userAgent;
607
- updateTimeout(ms: number): boolean;
608
- updatePhoneNumberId(phoneNumberId: number): boolean;
609
- updateAccessToken(accessToken: string): boolean;
610
- updateWabaId(wabaId: string): boolean;
611
- }
612
-
613
- interface IRequest extends IncomingMessage {
614
- body: any;
615
- query: Record<string, any>;
616
- method?: string;
617
- }
618
- interface IResponse {
619
- status: (code: number) => IResponse;
620
- send: (body: any) => IResponse | void;
621
- json: (body: any) => IResponse | void;
622
- end: () => void;
623
- }
624
- /**
625
- * Webhook handler for WhatsApp Cloud API
626
- */
627
- declare class WebhookHandler {
628
- private config;
629
- private client;
630
- private messageHandlers;
631
- private eventHandlers;
632
- private preProcessHandler;
633
- private postProcessHandler;
634
- private flowHandlers;
635
- /**
636
- * Create a new WebhookHandler
637
- * @param config The WhatsApp configuration
638
- */
639
- constructor(config: WhatsAppConfig);
640
- /**
641
- * Handle a GET request for webhook verification
642
- */
643
- handleVerificationRequest<Req extends IRequest, Res extends IResponse>(req: Req, res: Res): void;
644
- handleVerificationRequest<Req extends IRequest>(req: Req): string;
645
- /**
646
- * Handle a POST request for webhook events
647
- */
648
- handleWebhookRequest<Req extends IRequest, Res extends IResponse>(req: Req, res: Res): Promise<void>;
649
- handleWebhookRequest<Req extends IRequest>(req: Req): Promise<{
650
- success: boolean;
651
- errors?: string[];
652
- }>;
653
- /**
654
- * Handle webhook requests (both verification and events)
655
- */
656
- handleRequest<Req extends IRequest, Res extends IResponse>(req: Req, res: Res): void | Promise<void>;
657
- handleRequest<Req extends IRequest>(req: Req): string | Promise<{
658
- success: boolean;
659
- errors?: string[];
660
- }>;
661
- /**
662
- * Process incoming messages
663
- */
664
- private processMessages;
665
- /**
666
- * Process other webhook events
667
- */
668
- private processEvent;
669
- /**
670
- * Register a message handler for a specific message type
671
- */
672
- onMessage(type: MessageTypesEnum, handler: (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>): void;
673
- /**
674
- * Register an event handler for a specific field
675
- */
676
- onEvent(field: string, handler: (event: WebhookEvent) => void | Promise<void>): void;
677
- /**
678
- * Register a pre-process handler that runs before all message handlers
679
- */
680
- onMessagePreProcess(handler: (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>): void;
681
- /**
682
- * Register a post-process handler that runs after all message handlers
683
- */
684
- onMessagePostProcess(handler: (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>): void;
685
- handleFlowRequest<Req extends IRequest & {
686
- rawBody: string;
687
- }, Res extends IResponse>(req: Req, res: Res): Promise<void>;
688
- handleFlowRequest<Req extends IRequest & {
689
- rawBody: string;
690
- }>(req: Req): Promise<{
691
- statusCode: number;
692
- body: any;
693
- headers?: Record<string, string>;
694
- }>;
695
- /**
696
- * Validate the request signature
697
- */
698
- isRequestSignatureValid(req: IRequest & {
699
- rawBody: string;
700
- }): boolean;
701
- /**
702
- * Decrypt a flow request
703
- */
704
- decryptRequest(body: any): {
705
- decryptedBody: FlowEndpointRequest;
706
- aesKeyBuffer: Buffer;
707
- initialVectorBuffer: Buffer;
708
- };
709
- /**
710
- * Encrypt a flow response
711
- */
712
- private encryptResponse;
713
- /**
714
- * Register a flow handler for a specific flow type
715
- */
716
- onFlow(type: FlowType, handler: (whatsapp: WhatsApp, request: FlowEndpointRequest) => any | Promise<any>): void;
717
- }
718
-
719
- export { BusinessProfileApi, EncryptionApi, FlowApi, FlowEndpointRequest, FlowType, HttpMethodsEnum, type IRequest, type IResponse, MessageTypesEnum, MessagesApi, PhoneNumberApi, QrCodeApi, RegistrationApi, TemplateApi, TwoStepVerificationApi, WabaApi, WabaConfigType, WebhookHandler, importConfig, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest };
83
+ export { FlowEndpointRequest, Logger, buildFieldsQueryString, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, objectToQueryString };