meta-cloud-api 3.8.0 → 3.9.1
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 +28 -10
- package/dist/index.d.mts +656 -238
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/dist/node/chunk.mjs +1 -0
- package/dist/node/index.d.mts +10398 -0
- package/dist/node/index.d.mts.map +1 -0
- package/dist/node/index.mjs +23 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/testing/index.d.ts +377 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +4 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/node/index.js +3 -0
- package/dist/types/index.d.ts +210 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +264 -4
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +6 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/node/index.d.ts +682 -0
- package/dist/utils/node/index.d.ts.map +1 -0
- package/dist/utils/node/index.js +16 -0
- package/dist/utils/node/index.js.map +1 -0
- package/package.json +31 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,81 @@
|
|
|
1
|
-
import { Agent } from "node:https";
|
|
2
1
|
import { IncomingHttpHeaders, IncomingMessage } from "node:http";
|
|
3
2
|
|
|
4
|
-
//#region src/
|
|
3
|
+
//#region src/utils/rateLimit.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Usage percentages reported by Meta. Each value is the share (0-100+) of the allowance used in the
|
|
6
|
+
* current rolling window.
|
|
7
|
+
*/
|
|
8
|
+
interface RateLimitUsage {
|
|
9
|
+
/** Percentage of calls made (`call_count`). */
|
|
10
|
+
callCount?: number;
|
|
11
|
+
/** Percentage of total CPU time used (`total_cputime`). */
|
|
12
|
+
totalCputime?: number;
|
|
13
|
+
/** Percentage of total time used (`total_time`). */
|
|
14
|
+
totalTime?: number;
|
|
15
|
+
}
|
|
16
|
+
/** One entry of the `X-Business-Use-Case-Usage` header. */
|
|
17
|
+
interface BusinessUseCaseUsage extends RateLimitUsage {
|
|
18
|
+
/** The business object the entry belongs to (for WhatsApp, usually the WABA or phone number ID). */
|
|
19
|
+
businessId: string;
|
|
20
|
+
/** Rate limit type, e.g. `whatsapp_business_management` or `whatsapp`. */
|
|
21
|
+
type?: string;
|
|
22
|
+
/**
|
|
23
|
+
* `estimated_time_to_regain_access`: "Time, in minutes, until calls will no longer be throttled."
|
|
24
|
+
* `0` when not throttled.
|
|
25
|
+
*/
|
|
26
|
+
estimatedTimeToRegainAccessMinutes?: number;
|
|
27
|
+
/** `ads_api_access_tier`, only sent for Marketing API use cases. */
|
|
28
|
+
adsApiAccessTier?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Rate limit information parsed from a Graph API response.
|
|
32
|
+
*
|
|
33
|
+
* WhatsApp Cloud API responses carry `x-business-use-case-usage` (types
|
|
34
|
+
* `whatsapp_business_management` and `whatsapp`) and `x-app-usage`; throttled responses may add
|
|
35
|
+
* `Retry-After` (seconds).
|
|
36
|
+
*/
|
|
37
|
+
interface RateLimitInfo {
|
|
38
|
+
/** Parsed `X-App-Usage` header (platform rate limits). */
|
|
39
|
+
appUsage?: RateLimitUsage;
|
|
40
|
+
/** Parsed `X-Business-Use-Case-Usage` header, flattened across business IDs. Empty when absent. */
|
|
41
|
+
businessUseCaseUsage: BusinessUseCaseUsage[];
|
|
42
|
+
/** Parsed `Retry-After` header in milliseconds (seconds or HTTP-date form). */
|
|
43
|
+
retryAfterMs?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Highest usage percentage across every parsed metric, handy for alerting before Meta starts
|
|
46
|
+
* throttling (it throttles at 100).
|
|
47
|
+
*/
|
|
48
|
+
maxUsagePercent?: number;
|
|
49
|
+
/**
|
|
50
|
+
* How long Meta asks you to wait, in milliseconds: the larger of `retryAfterMs` and the largest
|
|
51
|
+
* `estimatedTimeToRegainAccessMinutes`. Undefined when Meta gave no wait time.
|
|
52
|
+
*/
|
|
53
|
+
retryDelayMs?: number;
|
|
54
|
+
}
|
|
55
|
+
/** Headers accepted by {@link parseRateLimitHeaders}. */
|
|
56
|
+
type RateLimitHeadersInput = Headers | Record<string, string | string[] | undefined> | {
|
|
57
|
+
get(name: string): string | null;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Parses a `Retry-After` value (delta-seconds or HTTP-date) into milliseconds.
|
|
61
|
+
* Returns undefined for missing or malformed values.
|
|
62
|
+
*/
|
|
63
|
+
declare function parseRetryAfter(value: string | null | undefined, now?: number): number | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Parses Meta's rate limit headers (`X-App-Usage`, `X-Business-Use-Case-Usage`, `Retry-After`).
|
|
66
|
+
* Header names are matched case-insensitively. Malformed JSON or values are ignored, never thrown.
|
|
67
|
+
*
|
|
68
|
+
* Returns undefined when none of the headers are present.
|
|
69
|
+
*
|
|
70
|
+
* @see {@link https://developers.facebook.com/docs/graph-api/overview/rate-limiting/ | Graph API rate limiting}
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const info = parseRateLimitHeaders(response.headers);
|
|
75
|
+
* if ((info?.maxUsagePercent ?? 0) > 80) slowDown();
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
declare function parseRateLimitHeaders(headers: RateLimitHeadersInput | null | undefined): RateLimitInfo | undefined;
|
|
5
79
|
declare namespace enums_d_exports {
|
|
6
80
|
export { AudioMediaTypesEnum, BusinessVerticalEnum, ButtonPositionEnum, CategoryEnum, ComponentTypesEnum, ConversationTypesEnum, CurrencyCodesEnum, DataLocalizationRegionEnum, DocumentMediaTypesEnum, HttpMethodsEnum, ImageMediaTypesEnum, InteractiveTypesEnum, LanguagesEnum, MessageCategoryEnum, MessageTypesEnum, ParametersTypesEnum, ReferralSourceTypesEnum, RequestCodeMethodsEnum, StatusEnum, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, TemplateStatusEnum, VideoMediaTypesEnum, WabaConfigEnum, WebhookTypesEnum };
|
|
7
81
|
}
|
|
@@ -735,6 +809,68 @@ interface RetryConfig {
|
|
|
735
809
|
* Defaults to 1000 (1 second).
|
|
736
810
|
*/
|
|
737
811
|
initialDelayMs?: number;
|
|
812
|
+
/**
|
|
813
|
+
* Wait as long as Meta asks before retrying a throttled request. When a throttling response
|
|
814
|
+
* carries `Retry-After` (seconds) or `X-Business-Use-Case-Usage` with
|
|
815
|
+
* `estimated_time_to_regain_access` (minutes), the retry waits the larger of the backoff delay and
|
|
816
|
+
* that server delay, capped at {@link RetryConfig.maxServerDelayMs}. It never adds attempts.
|
|
817
|
+
* Defaults to `true`; set `false` to use the backoff delay only.
|
|
818
|
+
*/
|
|
819
|
+
respectServerDelay?: boolean;
|
|
820
|
+
/**
|
|
821
|
+
* Upper bound in milliseconds for a server-provided wait. A longer wait is shortened to this
|
|
822
|
+
* value, so the retry may still be throttled; inspect `error.rateLimit` to reschedule instead.
|
|
823
|
+
* Defaults to 30000 (30 seconds).
|
|
824
|
+
*/
|
|
825
|
+
maxServerDelayMs?: number;
|
|
826
|
+
}
|
|
827
|
+
/** Request details passed to {@link WhatsAppConfig.onRateLimitInfo}. */
|
|
828
|
+
interface RateLimitInfoContext {
|
|
829
|
+
/** HTTP method of the request. */
|
|
830
|
+
method: string;
|
|
831
|
+
/** Endpoint path or absolute URL as passed to the requester. */
|
|
832
|
+
endpoint: string;
|
|
833
|
+
/** HTTP status code of the response. */
|
|
834
|
+
statusCode: number;
|
|
835
|
+
}
|
|
836
|
+
/** Callback receiving rate limit information parsed from every response that carries it. */
|
|
837
|
+
type RateLimitInfoListener = (info: RateLimitInfo, context: RateLimitInfoContext) => void | Promise<void>;
|
|
838
|
+
/**
|
|
839
|
+
* Storage used to drop duplicate webhook deliveries. Meta retries deliveries,
|
|
840
|
+
* so the same message or status can arrive more than once.
|
|
841
|
+
*
|
|
842
|
+
* `setIfAbsent` must be atomic: store `key` for `ttlSeconds` only if it is not
|
|
843
|
+
* already there, and resolve `true` when it stored the key (first delivery) or
|
|
844
|
+
* `false` when the key already existed (duplicate). It maps 1:1 to Redis
|
|
845
|
+
* `SET key 1 NX EX ttlSeconds`, which replies `OK` only when the key was set.
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* ```typescript
|
|
849
|
+
* const store: DedupeStore = {
|
|
850
|
+
* async setIfAbsent(key, ttlSeconds) {
|
|
851
|
+
* return (await redis.set(`wa:${key}`, '1', { NX: true, EX: ttlSeconds })) === 'OK';
|
|
852
|
+
* },
|
|
853
|
+
* };
|
|
854
|
+
* ```
|
|
855
|
+
*/
|
|
856
|
+
interface DedupeStore {
|
|
857
|
+
/** Atomically store `key` for `ttlSeconds` if absent. Resolves `true` if stored, `false` if it existed. */
|
|
858
|
+
setIfAbsent(key: string, ttlSeconds: number): Promise<boolean>;
|
|
859
|
+
/** Optional read-only check. The webhook processor never calls it; it is there for inspection and tests. */
|
|
860
|
+
has?(key: string): Promise<boolean>;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Opt-in deduplication of webhook deliveries. See {@link DedupeStore}.
|
|
864
|
+
*/
|
|
865
|
+
interface WebhookDedupeConfig {
|
|
866
|
+
/**
|
|
867
|
+
* Where seen keys are kept. Defaults to an in-memory store that is bounded
|
|
868
|
+
* and only sees deliveries made to this process: with several instances
|
|
869
|
+
* behind a load balancer, pass a shared store such as Redis.
|
|
870
|
+
*/
|
|
871
|
+
store?: DedupeStore;
|
|
872
|
+
/** How long a key is remembered, in seconds. Defaults to 86400 (24 hours). */
|
|
873
|
+
ttlSeconds?: number;
|
|
738
874
|
}
|
|
739
875
|
type WhatsAppConfig = {
|
|
740
876
|
accessToken: string;
|
|
@@ -752,6 +888,12 @@ type WhatsAppConfig = {
|
|
|
752
888
|
privatePem?: string;
|
|
753
889
|
passphrase?: string; /** Automatic retry configuration for throttling errors. */
|
|
754
890
|
retry?: RetryConfig;
|
|
891
|
+
/**
|
|
892
|
+
* Called with the parsed `X-App-Usage` / `X-Business-Use-Case-Usage` / `Retry-After` headers of
|
|
893
|
+
* every response (successful or not) that carries at least one of them. Errors thrown by the
|
|
894
|
+
* callback are ignored. See also `whatsapp.getLastRateLimitInfo()`.
|
|
895
|
+
*/
|
|
896
|
+
onRateLimitInfo?: RateLimitInfoListener;
|
|
755
897
|
/**
|
|
756
898
|
* Reject webhook POSTs whose `X-Hub-Signature-256` header is not a valid
|
|
757
899
|
* HMAC-SHA256 of the raw body keyed with `appSecret`. Requires `appSecret`.
|
|
@@ -763,6 +905,19 @@ type WhatsAppConfig = {
|
|
|
763
905
|
* `app.use(express.json({ verify: (req, _res, buf) => { req.rawBody = buf.toString(); } }))`.
|
|
764
906
|
*/
|
|
765
907
|
verifyWebhookSignature?: boolean;
|
|
908
|
+
/**
|
|
909
|
+
* Skip handlers for webhook deliveries that were already seen (Meta retries
|
|
910
|
+
* deliveries). Duplicates still get a 200 response. Used by
|
|
911
|
+
* `WebhookProcessor` and the framework adapters only.
|
|
912
|
+
*
|
|
913
|
+
* Keys: `message:<id>` for messages, `status:<id>:<status>` for statuses,
|
|
914
|
+
* and the call or echo ids for `calls`, `smb_message_echoes` and
|
|
915
|
+
* `message_echoes`. Other fields have no natural id and are never deduped.
|
|
916
|
+
*
|
|
917
|
+
* `true` uses the defaults (in-memory store, single instance only, 24 hour TTL).
|
|
918
|
+
* Off by default.
|
|
919
|
+
*/
|
|
920
|
+
dedupe?: boolean | WebhookDedupeConfig;
|
|
766
921
|
};
|
|
767
922
|
type WabaConfigType = {
|
|
768
923
|
/**
|
|
@@ -826,6 +981,10 @@ type WabaConfigType = {
|
|
|
826
981
|
* Passed through from WhatsAppConfig.
|
|
827
982
|
*/
|
|
828
983
|
retry?: RetryConfig;
|
|
984
|
+
/**
|
|
985
|
+
* Rate limit header listener. Passed through from WhatsAppConfig.
|
|
986
|
+
*/
|
|
987
|
+
onRateLimitInfo?: RateLimitInfoListener;
|
|
829
988
|
};
|
|
830
989
|
//#endregion
|
|
831
990
|
//#region src/types/request.d.ts
|
|
@@ -851,6 +1010,8 @@ interface GeneralHeaderInterface {
|
|
|
851
1010
|
}
|
|
852
1011
|
interface RequesterResponseInterface<T> {
|
|
853
1012
|
json: () => Promise<T>;
|
|
1013
|
+
/** The underlying fetch `Response`, for non-JSON bodies such as media downloads. */
|
|
1014
|
+
rawResponse: () => Response;
|
|
854
1015
|
}
|
|
855
1016
|
interface ResponseSuccess {
|
|
856
1017
|
success: boolean;
|
|
@@ -899,6 +1060,8 @@ declare class BaseAPI implements BaseClass {
|
|
|
899
1060
|
protected client: RequesterClass;
|
|
900
1061
|
constructor(config: WabaConfigType, client: RequesterClass);
|
|
901
1062
|
protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
|
|
1063
|
+
/** Send a request and return the raw `Response` (for binary bodies). Errors still throw `WhatsAppError`s. */
|
|
1064
|
+
protected sendRaw(method: HttpMethodsEnum, endpoint: string, timeout: number): Promise<Response>;
|
|
902
1065
|
protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
|
|
903
1066
|
protected sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body: UrlEncodedFormBody): Promise<T>;
|
|
904
1067
|
}
|
|
@@ -1712,7 +1875,7 @@ type GroupParticipantsRequest = {
|
|
|
1712
1875
|
type UpdateGroupSettingsRequest = {
|
|
1713
1876
|
subject?: string;
|
|
1714
1877
|
description?: string;
|
|
1715
|
-
profilePictureFile?: Blob |
|
|
1878
|
+
profilePictureFile?: Blob | Uint8Array;
|
|
1716
1879
|
};
|
|
1717
1880
|
type GroupSettingsResponse = ResponseSuccess;
|
|
1718
1881
|
interface GroupsClass {
|
|
@@ -2398,9 +2561,29 @@ type MediasResponse = {
|
|
|
2398
2561
|
type UploadMediaResponse = {
|
|
2399
2562
|
id: string;
|
|
2400
2563
|
};
|
|
2564
|
+
/**
|
|
2565
|
+
* Media content accepted by `uploadMedia`.
|
|
2566
|
+
*
|
|
2567
|
+
* A `ReadableStream` is read fully into memory before the upload starts: Meta's endpoint takes
|
|
2568
|
+
* `multipart/form-data`, and `fetch` can only send a `FormData` part from a `Blob`.
|
|
2569
|
+
*/
|
|
2570
|
+
type UploadMediaInput = Blob | File | Uint8Array | ArrayBuffer | ReadableStream<Uint8Array>;
|
|
2571
|
+
interface UploadMediaOptions {
|
|
2572
|
+
/**
|
|
2573
|
+
* MIME type sent as the `type` field and as the file part's content type, e.g. `image/jpeg`.
|
|
2574
|
+
* Required for `Uint8Array`, `ArrayBuffer` and `ReadableStream` input, and for a `Blob` without a
|
|
2575
|
+
* `type`. Overrides the `type` of a `Blob`/`File`.
|
|
2576
|
+
*/
|
|
2577
|
+
type?: string;
|
|
2578
|
+
/** File name of the multipart part. Defaults to the `File` name, otherwise `file`. */
|
|
2579
|
+
filename?: string;
|
|
2580
|
+
/** Messaging product. Defaults to `'whatsapp'`. */
|
|
2581
|
+
messagingProduct?: string;
|
|
2582
|
+
}
|
|
2401
2583
|
interface MediaClass {
|
|
2402
2584
|
getMediaById(mediaId: string): Promise<MediaResponse>;
|
|
2403
2585
|
uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
|
|
2586
|
+
uploadMedia(file: UploadMediaInput, options?: UploadMediaOptions): Promise<UploadMediaResponse>;
|
|
2404
2587
|
deleteMedia(mediaId: string): Promise<ResponseSuccess>;
|
|
2405
2588
|
downloadMedia(mediaUrl: string): Promise<Blob>;
|
|
2406
2589
|
}
|
|
@@ -2762,9 +2945,9 @@ interface UploadMediaParams {
|
|
|
2762
2945
|
*/
|
|
2763
2946
|
uploadId: string;
|
|
2764
2947
|
/**
|
|
2765
|
-
* The binary data of the file (Buffer).
|
|
2948
|
+
* The binary data of the file (`Uint8Array`; a Node.js `Buffer` works).
|
|
2766
2949
|
*/
|
|
2767
|
-
file:
|
|
2950
|
+
file: Uint8Array;
|
|
2768
2951
|
}
|
|
2769
2952
|
/**
|
|
2770
2953
|
* Request parameters for getting upload handle.
|
|
@@ -2909,7 +3092,7 @@ declare class BusinessProfileClass extends BaseClass {
|
|
|
2909
3092
|
* @param uploadId The ID of the upload session.
|
|
2910
3093
|
* @param file The binary data of the file.
|
|
2911
3094
|
*/
|
|
2912
|
-
uploadMedia(uploadId: string, file:
|
|
3095
|
+
uploadMedia(uploadId: string, file: Uint8Array): Promise<UploadBusinessProfileResponse>;
|
|
2913
3096
|
/**
|
|
2914
3097
|
* Get the upload handle information.
|
|
2915
3098
|
* @param uploadId The ID of the upload session.
|
|
@@ -3542,7 +3725,7 @@ type WabaBanState = 'SCHEDULE_FOR_DISABLE' | 'DISABLE' | 'REINSTATE';
|
|
|
3542
3725
|
/**
|
|
3543
3726
|
* Restriction types imposed on WABA — present on ACCOUNT_RESTRICTION events.
|
|
3544
3727
|
*/
|
|
3545
|
-
type RestrictionType = 'RESTRICTION_ADD_PHONE_NUMBER_ACTION' | 'RESTRICTED_BIZ_INITIATED_MESSAGING' | 'RESTRICTED_CUSTOMER_INITIATED_MESSAGING';
|
|
3728
|
+
type RestrictionType = 'RESTRICTED_ADD_PHONE_NUMBER_ACTION' /** @deprecated Misspelled legacy value; Meta sends `RESTRICTED_ADD_PHONE_NUMBER_ACTION`. */ | 'RESTRICTION_ADD_PHONE_NUMBER_ACTION' | 'RESTRICTED_BIZ_INITIATED_MESSAGING' | 'RESTRICTED_CUSTOMER_INITIATED_MESSAGING' | 'RESTRICTED_BIZ_INITIATED_AND_USER_INITIATED_CALLING' | 'RESTRICTED_BUSINESS_INITIATED_CALLING' | 'RESTRICTED_USER_INITIATED_CALLING' | 'RESTRICTED_USER_INITIATED_CALLING_CALL_BUTTON_HIDDEN' | 'RESTRICTED_DIRECT_SEND_UTILITY_TEMPLATES' | 'RESTRICTED_UTILITY_TEMPLATES';
|
|
3546
3729
|
/**
|
|
3547
3730
|
* Reason for the disconnection — present on PARTNER_REMOVED events where
|
|
3548
3731
|
* the business used both WhatsApp Business app and Cloud API.
|
|
@@ -3630,7 +3813,12 @@ interface PartnerClientCertificationInfo {
|
|
|
3630
3813
|
rejection_reasons?: string[];
|
|
3631
3814
|
}
|
|
3632
3815
|
interface AccountUpdateValue {
|
|
3633
|
-
/**
|
|
3816
|
+
/**
|
|
3817
|
+
* Business display phone number the event applies to (e.g. "15550783881").
|
|
3818
|
+
* Only included for events about a single business phone number, such as
|
|
3819
|
+
* ACCOUNT_VIOLATION and calling-related ACCOUNT_RESTRICTION events.
|
|
3820
|
+
* Absent on WABA-wide events.
|
|
3821
|
+
*/
|
|
3634
3822
|
phone_number?: string;
|
|
3635
3823
|
/**
|
|
3636
3824
|
* Event type describing what changed.
|
|
@@ -5372,6 +5560,21 @@ type WebhookValue = MessageWebhookValue | StatusWebhookValue | ErrorWebhookValue
|
|
|
5372
5560
|
* Union type for all webhook field values
|
|
5373
5561
|
*/
|
|
5374
5562
|
type WebhookFieldValue = AccountUpdateWebhookValue | AccountReviewUpdateWebhookValue | AccountAlertsWebhookValue | AccountSettingsUpdateWebhookValue | AutomaticEventsWebhookValue | BusinessCapabilityUpdateWebhookValue | BusinessStatusUpdateWebhookValue | BusinessUsernameUpdatesWebhookValue | CallsWebhookValue | FlowsWebhookValue | GroupLifecycleUpdateWebhookValue | GroupParticipantsUpdateWebhookValue | GroupSettingsUpdateWebhookValue | GroupStatusUpdateWebhookValue | HistoryWebhookValue | MessageEchoesWebhookValue | MessageTemplateComponentsUpdateWebhookValue | MessageTemplateQualityUpdateWebhookValue | MessageTemplateStatusUpdateWebhookValue | MessagingHandoversWebhookValue | PartnerSolutionsWebhookValue | PaymentConfigurationUpdateWebhookValue | PhoneNumberNameUpdateWebhookValue | PhoneNumberQualityUpdateWebhookValue | SecurityWebhookValue | SmbAppStateSyncWebhookValue | SmbMessageEchoesWebhookValue | StandbyWebhookValue | TemplateCategoryUpdateWebhookValue | TemplateCorrectCategoryDetectionWebhookValue | TrackingEventsWebhookValue | UserPreferencesWebhookValue;
|
|
5563
|
+
/**
|
|
5564
|
+
* Maps every webhook field except `messages` to the type of its `value`.
|
|
5565
|
+
* `messages` is left out because the SDK splits it into messages, statuses and
|
|
5566
|
+
* user actions (see `onMessage`, `onStatus` and `onUserAction`).
|
|
5567
|
+
*
|
|
5568
|
+
* @example
|
|
5569
|
+
* ```typescript
|
|
5570
|
+
* type Calls = WebhookFieldValueMap['calls']; // CallsWebhookValue['value']
|
|
5571
|
+
* ```
|
|
5572
|
+
*/
|
|
5573
|
+
type WebhookFieldValueMap = { [F in WebhookFieldValue['field']]: Extract<WebhookFieldValue, {
|
|
5574
|
+
field: F;
|
|
5575
|
+
}>['value'] };
|
|
5576
|
+
/** Webhook field names accepted by `WebhookProcessor.on()`: every field except `messages`. */
|
|
5577
|
+
type NonMessageWebhookField = keyof WebhookFieldValueMap;
|
|
5375
5578
|
interface WebhookPayload {
|
|
5376
5579
|
object: 'whatsapp_business_account';
|
|
5377
5580
|
entry: Array<{
|
|
@@ -5462,6 +5665,11 @@ declare class WhatsAppError extends Error {
|
|
|
5462
5665
|
declare class WhatsAppApiError extends WhatsAppError {
|
|
5463
5666
|
readonly error: MetaErrorData;
|
|
5464
5667
|
readonly statusCode?: number;
|
|
5668
|
+
/**
|
|
5669
|
+
* Rate limit headers of the failed response, when it carried any. Set by the SDK's requester;
|
|
5670
|
+
* use `rateLimit.retryDelayMs` to reschedule a throttled call.
|
|
5671
|
+
*/
|
|
5672
|
+
rateLimit?: RateLimitInfo;
|
|
5465
5673
|
constructor(message: string, error: MetaErrorData, statusCode?: number);
|
|
5466
5674
|
}
|
|
5467
5675
|
declare class WhatsAppAuthorizationError extends WhatsAppApiError {
|
|
@@ -6197,7 +6405,7 @@ interface FlowClass {
|
|
|
6197
6405
|
* @returns Promise with the success status and validation errors
|
|
6198
6406
|
*/
|
|
6199
6407
|
updateFlowJson(flowId: string, data: {
|
|
6200
|
-
file: Blob |
|
|
6408
|
+
file: Blob | Uint8Array | object;
|
|
6201
6409
|
name?: string;
|
|
6202
6410
|
}): Promise<UpdateFlowResponse>;
|
|
6203
6411
|
/**
|
|
@@ -6208,7 +6416,7 @@ interface FlowClass {
|
|
|
6208
6416
|
* @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.
|
|
6209
6417
|
* @returns Promise indicating if the JSON is valid and includes validation errors if any.
|
|
6210
6418
|
*/
|
|
6211
|
-
validateFlowJson(flowId: string, flowJsonData: Blob |
|
|
6419
|
+
validateFlowJson(flowId: string, flowJsonData: Blob | Uint8Array | object): Promise<ValidateFlowJsonResponse>;
|
|
6212
6420
|
/**
|
|
6213
6421
|
* Publish Flow
|
|
6214
6422
|
*
|
|
@@ -6462,7 +6670,7 @@ declare class FlowApi extends BaseAPI implements FlowClass {
|
|
|
6462
6670
|
* ```
|
|
6463
6671
|
*/
|
|
6464
6672
|
updateFlowJson(flowId: string, data: {
|
|
6465
|
-
file: Blob |
|
|
6673
|
+
file: Blob | Uint8Array | object;
|
|
6466
6674
|
name?: string;
|
|
6467
6675
|
}): Promise<UpdateFlowResponse>;
|
|
6468
6676
|
/**
|
|
@@ -6492,7 +6700,7 @@ declare class FlowApi extends BaseAPI implements FlowClass {
|
|
|
6492
6700
|
* }
|
|
6493
6701
|
* ```
|
|
6494
6702
|
*/
|
|
6495
|
-
validateFlowJson(flowId: string, flowJsonData: Blob |
|
|
6703
|
+
validateFlowJson(flowId: string, flowJsonData: Blob | Uint8Array | object): Promise<ValidateFlowJsonResponse>;
|
|
6496
6704
|
/**
|
|
6497
6705
|
* Publish a flow.
|
|
6498
6706
|
*
|
|
@@ -6822,11 +7030,24 @@ declare class MediaApi extends BaseAPI implements MediaClass {
|
|
|
6822
7030
|
* messages containing that media. Media is automatically encrypted and stored
|
|
6823
7031
|
* on Meta's servers.
|
|
6824
7032
|
*
|
|
6825
|
-
* **Endpoint:** `POST /{PHONE_NUMBER_ID}/media`
|
|
7033
|
+
* **Endpoint:** `POST /{PHONE_NUMBER_ID}/media` (`multipart/form-data` with `file`, `type` and
|
|
7034
|
+
* `messaging_product`)
|
|
7035
|
+
*
|
|
7036
|
+
* Accepts a `File`, `Blob`, `Uint8Array` (including a Node.js `Buffer`), `ArrayBuffer` or web
|
|
7037
|
+
* `ReadableStream<Uint8Array>` on every runtime. Pass the MIME type in `options.type` unless the
|
|
7038
|
+
* input is a `Blob`/`File` that already has one.
|
|
6826
7039
|
*
|
|
6827
|
-
*
|
|
6828
|
-
*
|
|
7040
|
+
* **Memory:** a `ReadableStream` is read fully into a `Blob` before the request is sent. Meta
|
|
7041
|
+
* requires a multipart body and `fetch` only accepts `Blob` parts in `FormData`, so the upload is
|
|
7042
|
+
* not streamed end to end. Peak memory can exceed the file size (Meta caps media at 100 MB for
|
|
7043
|
+
* documents, 16 MB for audio/video, 5 MB for images). Buffering once also lets a throttled upload
|
|
7044
|
+
* be retried. Blob construction snapshots byte inputs; allow room for these copies.
|
|
7045
|
+
*
|
|
7046
|
+
* @param file - The content to upload
|
|
7047
|
+
* @param optionsOrMessagingProduct - Upload options, or the messaging product string (legacy form,
|
|
7048
|
+
* defaults to `'whatsapp'`)
|
|
6829
7049
|
* @returns A promise resolving to the upload response containing the assigned `id` (media ID)
|
|
7050
|
+
* @throws WhatsAppValidationError when no MIME type is available or the input type is unsupported
|
|
6830
7051
|
*
|
|
6831
7052
|
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#upload-media | Upload Media Reference}
|
|
6832
7053
|
*
|
|
@@ -6834,11 +7055,14 @@ declare class MediaApi extends BaseAPI implements MediaClass {
|
|
|
6834
7055
|
* ```ts
|
|
6835
7056
|
* const file = new File([buffer], 'image.jpg', { type: 'image/jpeg' });
|
|
6836
7057
|
* const { id } = await client.media.uploadMedia(file);
|
|
6837
|
-
*
|
|
6838
|
-
*
|
|
7058
|
+
*
|
|
7059
|
+
* // Bytes or a web stream (e.g. a fetch() body) need a MIME type
|
|
7060
|
+
* const res = await fetch('https://example.com/report.pdf');
|
|
7061
|
+
* await client.media.uploadMedia(res.body!, { type: 'application/pdf', filename: 'report.pdf' });
|
|
6839
7062
|
* ```
|
|
6840
7063
|
*/
|
|
6841
7064
|
uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
|
|
7065
|
+
uploadMedia(file: UploadMediaInput, options?: UploadMediaOptions): Promise<UploadMediaResponse>;
|
|
6842
7066
|
/**
|
|
6843
7067
|
* Deletes a media file from WhatsApp servers.
|
|
6844
7068
|
*
|
|
@@ -8119,7 +8343,7 @@ declare class BusinessProfileApi extends BaseAPI implements BusinessProfileClass
|
|
|
8119
8343
|
* );
|
|
8120
8344
|
* ```
|
|
8121
8345
|
*/
|
|
8122
|
-
uploadMedia(uploadId: string, file:
|
|
8346
|
+
uploadMedia(uploadId: string, file: Uint8Array): Promise<UploadBusinessProfileResponse>;
|
|
8123
8347
|
/**
|
|
8124
8348
|
* Get the upload handle for a completed upload.
|
|
8125
8349
|
*
|
|
@@ -8853,7 +9077,7 @@ type EncryptionKeyPair = {
|
|
|
8853
9077
|
*/
|
|
8854
9078
|
declare function generateEncryption(passphrase?: string): EncryptionKeyPair;
|
|
8855
9079
|
/**
|
|
8856
|
-
* Decrypt a WhatsApp Flow request
|
|
9080
|
+
* Decrypt a WhatsApp Flow request (Node.js only; see {@link decryptFlowRequestAsync} for every runtime)
|
|
8857
9081
|
* @param body - Encrypted request body containing encrypted_aes_key, encrypted_flow_data, and initial_vector
|
|
8858
9082
|
* @param config - WABA configuration containing FLOW_API_PRIVATE_PEM and FLOW_API_PASSPHRASE
|
|
8859
9083
|
* @returns Decrypted flow request body, AES key buffer, and initial vector buffer
|
|
@@ -8865,7 +9089,7 @@ declare function decryptFlowRequest(body: any, config: WabaConfigType): {
|
|
|
8865
9089
|
initialVectorBuffer: Buffer;
|
|
8866
9090
|
};
|
|
8867
9091
|
/**
|
|
8868
|
-
* Encrypt a WhatsApp Flow response
|
|
9092
|
+
* Encrypt a WhatsApp Flow response (Node.js only; see {@link encryptFlowResponseAsync} for every runtime)
|
|
8869
9093
|
* @param response - Response object to encrypt
|
|
8870
9094
|
* @param aesKeyBuffer - AES key buffer from the decrypted request
|
|
8871
9095
|
* @param initialVectorBuffer - Initial vector buffer from the decrypted request
|
|
@@ -8873,11 +9097,42 @@ declare function decryptFlowRequest(body: any, config: WabaConfigType): {
|
|
|
8873
9097
|
* @throws {Error} If encryption fails
|
|
8874
9098
|
*/
|
|
8875
9099
|
declare function encryptFlowResponse(response: any, aesKeyBuffer: Buffer, initialVectorBuffer: Buffer): string;
|
|
9100
|
+
/**
|
|
9101
|
+
* Result of {@link decryptFlowRequestAsync}. Pass `aesKeyBuffer` and
|
|
9102
|
+
* `initialVectorBuffer` to {@link encryptFlowResponseAsync}.
|
|
9103
|
+
*/
|
|
9104
|
+
type DecryptedFlowRequest = {
|
|
9105
|
+
decryptedBody: FlowEndpointRequest;
|
|
9106
|
+
aesKeyBuffer: Uint8Array<ArrayBuffer>;
|
|
9107
|
+
initialVectorBuffer: Uint8Array<ArrayBuffer>;
|
|
9108
|
+
};
|
|
9109
|
+
/**
|
|
9110
|
+
* Decrypt a WhatsApp Flow request with Web Crypto. Works on Node.js, Bun, Deno,
|
|
9111
|
+
* Cloudflare Workers and Vercel Edge.
|
|
9112
|
+
*
|
|
9113
|
+
* On runtimes without `node:crypto` the private key must be an unencrypted
|
|
9114
|
+
* PKCS#8 PEM (`-----BEGIN PRIVATE KEY-----`); the passphrase is then ignored.
|
|
9115
|
+
*
|
|
9116
|
+
* @param body - Encrypted request body containing encrypted_aes_key, encrypted_flow_data, and initial_vector
|
|
9117
|
+
* @param config - WABA configuration containing FLOW_API_PRIVATE_PEM and (for encrypted keys) FLOW_API_PASSPHRASE
|
|
9118
|
+
* @throws {Error} If required encryption properties are missing or decryption fails
|
|
9119
|
+
*/
|
|
9120
|
+
declare function decryptFlowRequestAsync(body: any, config: WabaConfigType): Promise<DecryptedFlowRequest>;
|
|
9121
|
+
/**
|
|
9122
|
+
* Encrypt a WhatsApp Flow response with Web Crypto. Works on every runtime.
|
|
9123
|
+
* @param response - Response object to encrypt
|
|
9124
|
+
* @param aesKeyBuffer - AES key from {@link decryptFlowRequestAsync} (a Node.js Buffer also works)
|
|
9125
|
+
* @param initialVectorBuffer - Initial vector from {@link decryptFlowRequestAsync} (a Node.js Buffer also works)
|
|
9126
|
+
* @returns Base64-encoded encrypted response
|
|
9127
|
+
*/
|
|
9128
|
+
declare function encryptFlowResponseAsync(response: any, aesKeyBuffer: Uint8Array, initialVectorBuffer: Uint8Array): Promise<string>;
|
|
8876
9129
|
//#endregion
|
|
8877
9130
|
//#region src/utils/http/httpsClient.d.ts
|
|
8878
9131
|
declare class HttpsClient implements HttpsClientClass {
|
|
8879
|
-
|
|
8880
|
-
|
|
9132
|
+
/**
|
|
9133
|
+
* Kept for backwards compatibility. Requests go through the global `fetch`,
|
|
9134
|
+
* which manages its own connection pool, so there is nothing to clear.
|
|
9135
|
+
*/
|
|
8881
9136
|
clearSockets(): boolean;
|
|
8882
9137
|
sendRequest(hostname: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null): Promise<HttpsClientResponseClass>;
|
|
8883
9138
|
}
|
|
@@ -8893,7 +9148,16 @@ declare class Requester implements RequesterClass {
|
|
|
8893
9148
|
host: Readonly<string>;
|
|
8894
9149
|
protocol: Readonly<string>;
|
|
8895
9150
|
private retryConfig;
|
|
8896
|
-
|
|
9151
|
+
private onRateLimitInfo;
|
|
9152
|
+
private lastRateLimitInfo;
|
|
9153
|
+
constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string, retryConfig?: RetryConfig, onRateLimitInfo?: RateLimitInfoListener);
|
|
9154
|
+
/**
|
|
9155
|
+
* Rate limit headers of the most recent response that carried any, or undefined.
|
|
9156
|
+
* With concurrent requests this is whichever response finished last; use the
|
|
9157
|
+
* `onRateLimitInfo` config callback to see every response.
|
|
9158
|
+
*/
|
|
9159
|
+
getLastRateLimitInfo(): RateLimitInfo | undefined;
|
|
9160
|
+
private captureRateLimitInfo;
|
|
8897
9161
|
buildHeader(contentType: string, additionalHeaders?: Record<string, string>): HeadersInit;
|
|
8898
9162
|
buildCAPIPath(endpoint: string): string;
|
|
8899
9163
|
private normalizeApiVersion;
|
|
@@ -8943,6 +9207,13 @@ declare class WhatsApp {
|
|
|
8943
9207
|
updateTimeout(timeout: number): void;
|
|
8944
9208
|
updateSenderNumberId(phoneNumberId: number): void;
|
|
8945
9209
|
updateAccessToken(accessToken: string): void;
|
|
9210
|
+
/**
|
|
9211
|
+
* Rate limit headers (`X-App-Usage`, `X-Business-Use-Case-Usage`, `Retry-After`) of the most
|
|
9212
|
+
* recent response that carried any, or undefined before the first such response. With
|
|
9213
|
+
* concurrent requests this reflects whichever finished last; pass `onRateLimitInfo` in the
|
|
9214
|
+
* config to observe every response.
|
|
9215
|
+
*/
|
|
9216
|
+
getLastRateLimitInfo(): RateLimitInfo | undefined;
|
|
8946
9217
|
/**
|
|
8947
9218
|
* Get SDK version
|
|
8948
9219
|
*/
|
|
@@ -8986,6 +9257,35 @@ declare class WhatsApp {
|
|
|
8986
9257
|
generateEncryption(passphrase?: string): EncryptionKeyPair;
|
|
8987
9258
|
}
|
|
8988
9259
|
//#endregion
|
|
9260
|
+
//#region src/core/webhook/dedupe.d.ts
|
|
9261
|
+
interface MemoryDedupeStoreOptions {
|
|
9262
|
+
/** Most keys kept at once; the least recently seen key is dropped first. Defaults to 10,000. */
|
|
9263
|
+
maxEntries?: number;
|
|
9264
|
+
}
|
|
9265
|
+
/**
|
|
9266
|
+
* Bounded in-memory {@link DedupeStore} with per-key TTL and least recently
|
|
9267
|
+
* seen eviction. This is the default store for `dedupe`.
|
|
9268
|
+
*
|
|
9269
|
+
* Single instance only: it lives in this process's memory, so it does not see
|
|
9270
|
+
* deliveries handled by other instances and forgets everything on restart (and
|
|
9271
|
+
* on each cold start of a serverless function). Use a shared store such as
|
|
9272
|
+
* Redis when you run more than one instance.
|
|
9273
|
+
*/
|
|
9274
|
+
declare class MemoryDedupeStore implements DedupeStore {
|
|
9275
|
+
private readonly maxEntries;
|
|
9276
|
+
/** key -> expiry time in ms. Map order doubles as recency order (oldest first). */
|
|
9277
|
+
private readonly entries;
|
|
9278
|
+
constructor(options?: MemoryDedupeStoreOptions);
|
|
9279
|
+
has(key: string): Promise<boolean>;
|
|
9280
|
+
setIfAbsent(key: string, ttlSeconds: number): Promise<boolean>;
|
|
9281
|
+
/** Number of keys currently held (expired keys may still be counted until evicted). */
|
|
9282
|
+
get size(): number;
|
|
9283
|
+
/** Forget every key. */
|
|
9284
|
+
clear(): void;
|
|
9285
|
+
private lookup;
|
|
9286
|
+
private evict;
|
|
9287
|
+
}
|
|
9288
|
+
//#endregion
|
|
8989
9289
|
//#region src/core/webhook/utils/webhookUtils.d.ts
|
|
8990
9290
|
/**
|
|
8991
9291
|
* Processed message with metadata for handlers
|
|
@@ -9030,135 +9330,12 @@ type ProcessedUserAction = {
|
|
|
9030
9330
|
action: UserAction;
|
|
9031
9331
|
};
|
|
9032
9332
|
/**
|
|
9033
|
-
*
|
|
9333
|
+
* What a handler for a non-`messages` webhook field receives: the WhatsApp
|
|
9334
|
+
* Business Account id and the change's `value`, typed by field name.
|
|
9034
9335
|
*/
|
|
9035
|
-
type
|
|
9036
|
-
wabaId: string;
|
|
9037
|
-
value: AccountUpdateWebhookValue['value'];
|
|
9038
|
-
};
|
|
9039
|
-
type ProcessedAccountReviewUpdate = {
|
|
9040
|
-
wabaId: string;
|
|
9041
|
-
value: AccountReviewUpdateWebhookValue['value'];
|
|
9042
|
-
};
|
|
9043
|
-
type ProcessedAccountAlerts = {
|
|
9044
|
-
wabaId: string;
|
|
9045
|
-
value: AccountAlertsWebhookValue['value'];
|
|
9046
|
-
};
|
|
9047
|
-
type ProcessedBusinessCapabilityUpdate = {
|
|
9048
|
-
wabaId: string;
|
|
9049
|
-
value: BusinessCapabilityUpdateWebhookValue['value'];
|
|
9050
|
-
};
|
|
9051
|
-
type ProcessedPhoneNumberNameUpdate = {
|
|
9052
|
-
wabaId: string;
|
|
9053
|
-
value: PhoneNumberNameUpdateWebhookValue['value'];
|
|
9054
|
-
};
|
|
9055
|
-
type ProcessedPhoneNumberQualityUpdate = {
|
|
9056
|
-
wabaId: string;
|
|
9057
|
-
value: PhoneNumberQualityUpdateWebhookValue['value'];
|
|
9058
|
-
};
|
|
9059
|
-
type ProcessedMessageTemplateStatusUpdate = {
|
|
9060
|
-
wabaId: string;
|
|
9061
|
-
value: MessageTemplateStatusUpdateWebhookValue['value'];
|
|
9062
|
-
};
|
|
9063
|
-
type ProcessedTemplateCategoryUpdate = {
|
|
9064
|
-
wabaId: string;
|
|
9065
|
-
value: TemplateCategoryUpdateWebhookValue['value'];
|
|
9066
|
-
};
|
|
9067
|
-
type ProcessedMessageTemplateQualityUpdate = {
|
|
9068
|
-
wabaId: string;
|
|
9069
|
-
value: MessageTemplateQualityUpdateWebhookValue['value'];
|
|
9070
|
-
};
|
|
9071
|
-
type ProcessedFlows = {
|
|
9072
|
-
wabaId: string;
|
|
9073
|
-
value: FlowsWebhookValue['value'];
|
|
9074
|
-
};
|
|
9075
|
-
type ProcessedSecurity = {
|
|
9076
|
-
wabaId: string;
|
|
9077
|
-
value: SecurityWebhookValue['value'];
|
|
9078
|
-
};
|
|
9079
|
-
type ProcessedHistory = {
|
|
9080
|
-
wabaId: string;
|
|
9081
|
-
value: HistoryWebhookValue['value'];
|
|
9082
|
-
};
|
|
9083
|
-
type ProcessedSmbMessageEchoes = {
|
|
9084
|
-
wabaId: string;
|
|
9085
|
-
value: SmbMessageEchoesWebhookValue['value'];
|
|
9086
|
-
};
|
|
9087
|
-
type ProcessedSmbAppStateSync = {
|
|
9088
|
-
wabaId: string;
|
|
9089
|
-
value: SmbAppStateSyncWebhookValue['value'];
|
|
9090
|
-
};
|
|
9091
|
-
type ProcessedAccountSettingsUpdate = {
|
|
9092
|
-
wabaId: string;
|
|
9093
|
-
value: AccountSettingsUpdateWebhookValue['value'];
|
|
9094
|
-
};
|
|
9095
|
-
type ProcessedAutomaticEvents = {
|
|
9096
|
-
wabaId: string;
|
|
9097
|
-
value: AutomaticEventsWebhookValue['value'];
|
|
9098
|
-
};
|
|
9099
|
-
type ProcessedBusinessStatusUpdate = {
|
|
9100
|
-
wabaId: string;
|
|
9101
|
-
value: BusinessStatusUpdateWebhookValue['value'];
|
|
9102
|
-
};
|
|
9103
|
-
type ProcessedBusinessUsernameUpdates = {
|
|
9104
|
-
wabaId: string;
|
|
9105
|
-
value: BusinessUsernameUpdatesWebhookValue['value'];
|
|
9106
|
-
};
|
|
9107
|
-
type ProcessedCalls = {
|
|
9108
|
-
wabaId: string;
|
|
9109
|
-
value: CallsWebhookValue['value'];
|
|
9110
|
-
};
|
|
9111
|
-
type ProcessedGroupLifecycleUpdate = {
|
|
9112
|
-
wabaId: string;
|
|
9113
|
-
value: GroupLifecycleUpdateWebhookValue['value'];
|
|
9114
|
-
};
|
|
9115
|
-
type ProcessedGroupParticipantsUpdate = {
|
|
9116
|
-
wabaId: string;
|
|
9117
|
-
value: GroupParticipantsUpdateWebhookValue['value'];
|
|
9118
|
-
};
|
|
9119
|
-
type ProcessedGroupSettingsUpdate = {
|
|
9336
|
+
type ProcessedWebhookField<F extends NonMessageWebhookField> = {
|
|
9120
9337
|
wabaId: string;
|
|
9121
|
-
value:
|
|
9122
|
-
};
|
|
9123
|
-
type ProcessedGroupStatusUpdate = {
|
|
9124
|
-
wabaId: string;
|
|
9125
|
-
value: GroupStatusUpdateWebhookValue['value'];
|
|
9126
|
-
};
|
|
9127
|
-
type ProcessedMessageEchoes = {
|
|
9128
|
-
wabaId: string;
|
|
9129
|
-
value: MessageEchoesWebhookValue['value'];
|
|
9130
|
-
};
|
|
9131
|
-
type ProcessedMessageTemplateComponentsUpdate = {
|
|
9132
|
-
wabaId: string;
|
|
9133
|
-
value: MessageTemplateComponentsUpdateWebhookValue['value'];
|
|
9134
|
-
};
|
|
9135
|
-
type ProcessedMessagingHandovers = {
|
|
9136
|
-
wabaId: string;
|
|
9137
|
-
value: MessagingHandoversWebhookValue['value'];
|
|
9138
|
-
};
|
|
9139
|
-
type ProcessedPartnerSolutions = {
|
|
9140
|
-
wabaId: string;
|
|
9141
|
-
value: PartnerSolutionsWebhookValue['value'];
|
|
9142
|
-
};
|
|
9143
|
-
type ProcessedPaymentConfigurationUpdate = {
|
|
9144
|
-
wabaId: string;
|
|
9145
|
-
value: PaymentConfigurationUpdateWebhookValue['value'];
|
|
9146
|
-
};
|
|
9147
|
-
type ProcessedStandby = {
|
|
9148
|
-
wabaId: string;
|
|
9149
|
-
value: StandbyWebhookValue['value'];
|
|
9150
|
-
};
|
|
9151
|
-
type ProcessedTemplateCorrectCategoryDetection = {
|
|
9152
|
-
wabaId: string;
|
|
9153
|
-
value: TemplateCorrectCategoryDetectionWebhookValue['value'];
|
|
9154
|
-
};
|
|
9155
|
-
type ProcessedTrackingEvents = {
|
|
9156
|
-
wabaId: string;
|
|
9157
|
-
value: TrackingEventsWebhookValue['value'];
|
|
9158
|
-
};
|
|
9159
|
-
type ProcessedUserPreferences = {
|
|
9160
|
-
wabaId: string;
|
|
9161
|
-
value: UserPreferencesWebhookValue['value'];
|
|
9338
|
+
value: WebhookFieldValueMap[F];
|
|
9162
9339
|
};
|
|
9163
9340
|
type TextProcessedMessage = ProcessedMessage & {
|
|
9164
9341
|
message: Extract<WhatsAppMessage, {
|
|
@@ -9245,38 +9422,50 @@ type StatusHandler = WebhookHandler<ProcessedStatus>;
|
|
|
9245
9422
|
type UserActionHandler = WebhookHandler<ProcessedUserAction>;
|
|
9246
9423
|
type FlowHandler = WebhookHandler<FlowEndpointRequest, any>;
|
|
9247
9424
|
type RawWebhookHandler = WebhookHandler<WebhookPayload>;
|
|
9248
|
-
|
|
9249
|
-
type
|
|
9250
|
-
|
|
9251
|
-
type
|
|
9252
|
-
|
|
9253
|
-
type
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
type
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
type
|
|
9261
|
-
type
|
|
9262
|
-
type
|
|
9263
|
-
type
|
|
9264
|
-
type
|
|
9265
|
-
type
|
|
9266
|
-
type
|
|
9267
|
-
type
|
|
9268
|
-
type
|
|
9269
|
-
type
|
|
9270
|
-
type
|
|
9271
|
-
type
|
|
9272
|
-
type
|
|
9273
|
-
type
|
|
9274
|
-
type
|
|
9275
|
-
type
|
|
9276
|
-
type
|
|
9277
|
-
type
|
|
9278
|
-
type
|
|
9279
|
-
type
|
|
9425
|
+
/** Handler for a non-`messages` webhook field; `processed.value` is typed by the field name. */
|
|
9426
|
+
type WebhookFieldHandler<F extends NonMessageWebhookField> = WebhookHandler<ProcessedWebhookField<F>>;
|
|
9427
|
+
/** Registered field handlers keyed by field name, as kept by `WebhookProcessor`. */
|
|
9428
|
+
type WebhookFieldHandlerMap = ReadonlyMap<NonMessageWebhookField, AnyWebhookFieldHandler>;
|
|
9429
|
+
/**
|
|
9430
|
+
* Field handler with the field type erased, for storage in a map. `on()`
|
|
9431
|
+
* guarantees each stored handler matches its key.
|
|
9432
|
+
*/
|
|
9433
|
+
type AnyWebhookFieldHandler = WebhookHandler<{
|
|
9434
|
+
wabaId: string;
|
|
9435
|
+
value: any;
|
|
9436
|
+
}>;
|
|
9437
|
+
type AccountUpdateHandler = WebhookFieldHandler<'account_update'>;
|
|
9438
|
+
type AccountReviewUpdateHandler = WebhookFieldHandler<'account_review_update'>;
|
|
9439
|
+
type AccountAlertsHandler = WebhookFieldHandler<'account_alerts'>;
|
|
9440
|
+
type BusinessCapabilityUpdateHandler = WebhookFieldHandler<'business_capability_update'>;
|
|
9441
|
+
type PhoneNumberNameUpdateHandler = WebhookFieldHandler<'phone_number_name_update'>;
|
|
9442
|
+
type PhoneNumberQualityUpdateHandler = WebhookFieldHandler<'phone_number_quality_update'>;
|
|
9443
|
+
type MessageTemplateStatusUpdateHandler = WebhookFieldHandler<'message_template_status_update'>;
|
|
9444
|
+
type TemplateCategoryUpdateHandler = WebhookFieldHandler<'template_category_update'>;
|
|
9445
|
+
type MessageTemplateQualityUpdateHandler = WebhookFieldHandler<'message_template_quality_update'>;
|
|
9446
|
+
type FlowsHandler = WebhookFieldHandler<'flows'>;
|
|
9447
|
+
type SecurityHandler = WebhookFieldHandler<'security'>;
|
|
9448
|
+
type HistoryHandler = WebhookFieldHandler<'history'>;
|
|
9449
|
+
type SmbMessageEchoesHandler = WebhookFieldHandler<'smb_message_echoes'>;
|
|
9450
|
+
type SmbAppStateSyncHandler = WebhookFieldHandler<'smb_app_state_sync'>;
|
|
9451
|
+
type AccountSettingsUpdateHandler = WebhookFieldHandler<'account_settings_update'>;
|
|
9452
|
+
type AutomaticEventsHandler = WebhookFieldHandler<'automatic_events'>;
|
|
9453
|
+
type BusinessStatusUpdateHandler = WebhookFieldHandler<'business_status_update'>;
|
|
9454
|
+
type BusinessUsernameUpdatesHandler = WebhookFieldHandler<'business_username_updates'>;
|
|
9455
|
+
type CallsHandler = WebhookFieldHandler<'calls'>;
|
|
9456
|
+
type GroupLifecycleUpdateHandler = WebhookFieldHandler<'group_lifecycle_update'>;
|
|
9457
|
+
type GroupParticipantsUpdateHandler = WebhookFieldHandler<'group_participants_update'>;
|
|
9458
|
+
type GroupSettingsUpdateHandler = WebhookFieldHandler<'group_settings_update'>;
|
|
9459
|
+
type GroupStatusUpdateHandler = WebhookFieldHandler<'group_status_update'>;
|
|
9460
|
+
type MessageEchoesHandler = WebhookFieldHandler<'message_echoes'>;
|
|
9461
|
+
type MessageTemplateComponentsUpdateHandler = WebhookFieldHandler<'message_template_components_update'>;
|
|
9462
|
+
type MessagingHandoversHandler = WebhookFieldHandler<'messaging_handovers'>;
|
|
9463
|
+
type PartnerSolutionsHandler = WebhookFieldHandler<'partner_solutions'>;
|
|
9464
|
+
type PaymentConfigurationUpdateHandler = WebhookFieldHandler<'payment_configuration_update'>;
|
|
9465
|
+
type StandbyHandler = WebhookFieldHandler<'standby'>;
|
|
9466
|
+
type TemplateCorrectCategoryDetectionHandler = WebhookFieldHandler<'template_correct_category_detection'>;
|
|
9467
|
+
type TrackingEventsHandler = WebhookFieldHandler<'tracking_events'>;
|
|
9468
|
+
type UserPreferencesHandler = WebhookFieldHandler<'user_preferences'>;
|
|
9280
9469
|
type TextMessageHandler = WebhookHandler<TextProcessedMessage>;
|
|
9281
9470
|
type ImageMessageHandler = WebhookHandler<ImageProcessedMessage>;
|
|
9282
9471
|
type VideoMessageHandler = WebhookHandler<VideoProcessedMessage>;
|
|
@@ -9291,16 +9480,11 @@ type ReactionMessageHandler = WebhookHandler<ReactionProcessedMessage>;
|
|
|
9291
9480
|
type OrderMessageHandler = WebhookHandler<OrderProcessedMessage>;
|
|
9292
9481
|
type SystemMessageHandler = WebhookHandler<SystemProcessedMessage>;
|
|
9293
9482
|
/**
|
|
9294
|
-
*
|
|
9483
|
+
* Named handler options accepted by {@link processWebhookMessages}, one per
|
|
9484
|
+
* webhook field except `messages`. Kept for backward compatibility; new code
|
|
9485
|
+
* can pass `fieldHandlers` instead.
|
|
9295
9486
|
*/
|
|
9296
|
-
|
|
9297
|
-
messageHandlers: Map<MessageTypesEnum, MessageHandler>;
|
|
9298
|
-
statusHandler?: StatusHandler;
|
|
9299
|
-
userActionHandler?: UserActionHandler;
|
|
9300
|
-
preProcessHandler?: MessageHandler;
|
|
9301
|
-
postProcessHandler?: MessageHandler;
|
|
9302
|
-
rawHandler?: RawWebhookHandler;
|
|
9303
|
-
rawHandlerFields?: WebhookFieldType[];
|
|
9487
|
+
type WebhookFieldHandlerOptions = {
|
|
9304
9488
|
accountUpdateHandler?: AccountUpdateHandler;
|
|
9305
9489
|
accountReviewUpdateHandler?: AccountReviewUpdateHandler;
|
|
9306
9490
|
accountAlertsHandler?: AccountAlertsHandler;
|
|
@@ -9333,7 +9517,33 @@ declare function processWebhookMessages(request: Request, whatsapp: WhatsApp, ha
|
|
|
9333
9517
|
templateCorrectCategoryDetectionHandler?: TemplateCorrectCategoryDetectionHandler;
|
|
9334
9518
|
trackingEventsHandler?: TrackingEventsHandler;
|
|
9335
9519
|
userPreferencesHandler?: UserPreferencesHandler;
|
|
9336
|
-
}
|
|
9520
|
+
};
|
|
9521
|
+
/** Dedupe settings for {@link processWebhookMessages}. */
|
|
9522
|
+
type WebhookDedupeOptions = {
|
|
9523
|
+
store: DedupeStore; /** Defaults to 86400 (24 hours). */
|
|
9524
|
+
ttlSeconds?: number;
|
|
9525
|
+
};
|
|
9526
|
+
/** Options for {@link processWebhookMessages}. */
|
|
9527
|
+
type ProcessWebhookOptions = WebhookSignatureOptions & {
|
|
9528
|
+
/** Skip handlers for deliveries already seen. Duplicates still get a 200 response. */dedupe?: WebhookDedupeOptions;
|
|
9529
|
+
};
|
|
9530
|
+
/**
|
|
9531
|
+
* Process webhook messages
|
|
9532
|
+
*/
|
|
9533
|
+
declare function processWebhookMessages(request: Request, whatsapp: WhatsApp, handlers: {
|
|
9534
|
+
messageHandlers: Map<MessageTypesEnum, MessageHandler>;
|
|
9535
|
+
statusHandler?: StatusHandler;
|
|
9536
|
+
userActionHandler?: UserActionHandler;
|
|
9537
|
+
preProcessHandler?: MessageHandler;
|
|
9538
|
+
postProcessHandler?: MessageHandler;
|
|
9539
|
+
rawHandler?: RawWebhookHandler;
|
|
9540
|
+
rawHandlerFields?: WebhookFieldType[];
|
|
9541
|
+
/**
|
|
9542
|
+
* Handlers for non-`messages` fields keyed by field name. Takes
|
|
9543
|
+
* precedence over the named `xxxHandler` option for the same field.
|
|
9544
|
+
*/
|
|
9545
|
+
fieldHandlers?: WebhookFieldHandlerMap;
|
|
9546
|
+
} & WebhookFieldHandlerOptions, options?: ProcessWebhookOptions): Promise<Response>;
|
|
9337
9547
|
/**
|
|
9338
9548
|
* Handle flow requests
|
|
9339
9549
|
*/
|
|
@@ -9344,8 +9554,13 @@ type WebhookSignatureOptions = {
|
|
|
9344
9554
|
};
|
|
9345
9555
|
/**
|
|
9346
9556
|
* Check an `X-Hub-Signature-256` header (`sha256=<hex>`) against the raw
|
|
9347
|
-
* request body
|
|
9348
|
-
* malformed or wrong-length input.
|
|
9557
|
+
* request body using Web Crypto, so it works on every runtime. Constant-time;
|
|
9558
|
+
* resolves to false instead of throwing on malformed or wrong-length input.
|
|
9559
|
+
*/
|
|
9560
|
+
declare function verifyWebhookSignature(rawBody: string, signatureHeader: string | null, appSecret: string): Promise<boolean>;
|
|
9561
|
+
/**
|
|
9562
|
+
* Synchronous variant of {@link verifyWebhookSignature}. Needs `node:crypto`
|
|
9563
|
+
* (Node.js >= 20.12, Bun, Deno); prefer the async variant on edge runtimes.
|
|
9349
9564
|
*/
|
|
9350
9565
|
declare function isValidWebhookSignature(rawBody: string, signatureHeader: string | null, appSecret: string): boolean;
|
|
9351
9566
|
/**
|
|
@@ -9372,39 +9587,10 @@ declare class WebhookProcessor {
|
|
|
9372
9587
|
private postProcessHandler;
|
|
9373
9588
|
private rawHandler;
|
|
9374
9589
|
private flowHandlers;
|
|
9375
|
-
|
|
9376
|
-
private
|
|
9377
|
-
private accountAlertsHandler;
|
|
9378
|
-
private businessCapabilityUpdateHandler;
|
|
9379
|
-
private phoneNumberNameUpdateHandler;
|
|
9380
|
-
private phoneNumberQualityUpdateHandler;
|
|
9381
|
-
private messageTemplateStatusUpdateHandler;
|
|
9382
|
-
private templateCategoryUpdateHandler;
|
|
9383
|
-
private messageTemplateQualityUpdateHandler;
|
|
9384
|
-
private flowsHandler;
|
|
9385
|
-
private securityHandler;
|
|
9386
|
-
private historyHandler;
|
|
9387
|
-
private smbMessageEchoesHandler;
|
|
9388
|
-
private smbAppStateSyncHandler;
|
|
9389
|
-
private accountSettingsUpdateHandler;
|
|
9390
|
-
private automaticEventsHandler;
|
|
9391
|
-
private businessStatusUpdateHandler;
|
|
9392
|
-
private businessUsernameUpdatesHandler;
|
|
9393
|
-
private callsHandler;
|
|
9394
|
-
private groupLifecycleUpdateHandler;
|
|
9395
|
-
private groupParticipantsUpdateHandler;
|
|
9396
|
-
private groupSettingsUpdateHandler;
|
|
9397
|
-
private groupStatusUpdateHandler;
|
|
9398
|
-
private messageEchoesHandler;
|
|
9399
|
-
private messageTemplateComponentsUpdateHandler;
|
|
9400
|
-
private messagingHandoversHandler;
|
|
9401
|
-
private partnerSolutionsHandler;
|
|
9402
|
-
private paymentConfigurationUpdateHandler;
|
|
9403
|
-
private standbyHandler;
|
|
9404
|
-
private templateCorrectCategoryDetectionHandler;
|
|
9405
|
-
private trackingEventsHandler;
|
|
9406
|
-
private userPreferencesHandler;
|
|
9590
|
+
/** Handlers for every webhook field except `messages`, keyed by field name. */
|
|
9591
|
+
private fieldHandlers;
|
|
9407
9592
|
private verifySignature;
|
|
9593
|
+
private dedupe;
|
|
9408
9594
|
constructor(config: WhatsAppConfig);
|
|
9409
9595
|
processVerification(mode: string | null, token: string | null, challenge: string | null): Promise<WebhookResponse>;
|
|
9410
9596
|
processWebhook(request: Request): Promise<WebhookResponse>;
|
|
@@ -9423,6 +9609,29 @@ declare class WebhookProcessor {
|
|
|
9423
9609
|
onMessagePostProcess(handler: MessageHandler): void;
|
|
9424
9610
|
onRaw(handler: RawWebhookHandler, fields?: WebhookFieldType[]): void;
|
|
9425
9611
|
onFlow(type: FlowTypeEnum, handler: FlowHandler): void;
|
|
9612
|
+
/**
|
|
9613
|
+
* Register a handler for any webhook field except `messages`. The type of
|
|
9614
|
+
* `processed.value` follows from the field name. Replaces any handler
|
|
9615
|
+
* already registered for that field, including one set with the matching
|
|
9616
|
+
* `onXxx` method (for example `onCalls` is `on('calls', handler)`).
|
|
9617
|
+
*
|
|
9618
|
+
* `messages` is not accepted: use `onMessage`, the typed message methods
|
|
9619
|
+
* (`onText`, ...), `onStatus` or `onUserAction`, which split that field
|
|
9620
|
+
* into messages, statuses and user actions.
|
|
9621
|
+
*
|
|
9622
|
+
* @example
|
|
9623
|
+
* ```typescript
|
|
9624
|
+
* processor.on('calls', async (whatsapp, { value }) => {
|
|
9625
|
+
* for (const call of value.calls) console.log(call.id, call.event);
|
|
9626
|
+
* });
|
|
9627
|
+
* ```
|
|
9628
|
+
*/
|
|
9629
|
+
on<F extends NonMessageWebhookField>(field: F, handler: WebhookFieldHandler<F>): void;
|
|
9630
|
+
/**
|
|
9631
|
+
* Remove the handler for a webhook field registered with `on()` or the
|
|
9632
|
+
* matching `onXxx` method. `messages` is not accepted (see {@link on}).
|
|
9633
|
+
*/
|
|
9634
|
+
off(field: NonMessageWebhookField): void;
|
|
9426
9635
|
/**
|
|
9427
9636
|
* Register a handler for text messages
|
|
9428
9637
|
* @param handler Type-safe handler that receives text messages with guaranteed text field
|
|
@@ -9720,26 +9929,108 @@ declare function expressWebhookHandler(config: ExpressWebhookConfig): {
|
|
|
9720
9929
|
destroy: () => void;
|
|
9721
9930
|
};
|
|
9722
9931
|
//#endregion
|
|
9723
|
-
//#region src/core/webhook/frameworks/
|
|
9724
|
-
interface
|
|
9725
|
-
|
|
9726
|
-
|
|
9932
|
+
//#region src/core/webhook/frameworks/fastify/fastify.d.ts
|
|
9933
|
+
interface FastifyWebhookRequest {
|
|
9934
|
+
method: string;
|
|
9935
|
+
url: string;
|
|
9936
|
+
headers: Record<string, string | string[] | undefined>;
|
|
9937
|
+
body?: unknown;
|
|
9938
|
+
query?: unknown;
|
|
9939
|
+
/**
|
|
9940
|
+
* The unparsed request body. Fastify does not keep it by default: set it in
|
|
9941
|
+
* a content-type parser or with the `fastify-raw-body` plugin. Required for
|
|
9942
|
+
* `verifyWebhookSignature: true`, because re-serializing the parsed body
|
|
9943
|
+
* does not reproduce the bytes Meta signed.
|
|
9944
|
+
*/
|
|
9945
|
+
rawBody?: string | Uint8Array;
|
|
9946
|
+
}
|
|
9947
|
+
interface FastifyWebhookReply {
|
|
9948
|
+
code(statusCode: number): FastifyWebhookReply;
|
|
9949
|
+
header(name: string, value: string): FastifyWebhookReply;
|
|
9950
|
+
send(payload?: any): FastifyWebhookReply;
|
|
9951
|
+
}
|
|
9952
|
+
interface FastifyWebhookConfig extends WhatsAppConfig {}
|
|
9953
|
+
/** The object returned by {@link fastifyWebhookHandler}. */
|
|
9954
|
+
type FastifyWebhookHandlers = ReturnType<typeof createHandlers$2>;
|
|
9955
|
+
/**
|
|
9956
|
+
* Fastify webhook handler.
|
|
9957
|
+
*
|
|
9958
|
+
* @example
|
|
9959
|
+
* const wa = fastifyWebhookHandler(config);
|
|
9960
|
+
* wa.processor.onText(async (whatsapp, { message }) => { ... });
|
|
9961
|
+
* app.get('/webhook', wa.GET);
|
|
9962
|
+
* app.post('/webhook', wa.POST);
|
|
9963
|
+
* app.post('/flow', wa.flow);
|
|
9964
|
+
*/
|
|
9965
|
+
declare function fastifyWebhookHandler(config: FastifyWebhookConfig): FastifyWebhookHandlers;
|
|
9966
|
+
declare function createHandlers$2(config: FastifyWebhookConfig, key: string): {
|
|
9967
|
+
GET: (request: FastifyWebhookRequest, reply: FastifyWebhookReply) => Promise<FastifyWebhookReply>;
|
|
9968
|
+
POST: (request: FastifyWebhookRequest, reply: FastifyWebhookReply) => Promise<FastifyWebhookReply>;
|
|
9969
|
+
webhook: (request: FastifyWebhookRequest, reply: FastifyWebhookReply) => Promise<FastifyWebhookReply>;
|
|
9970
|
+
flow: (request: FastifyWebhookRequest, reply: FastifyWebhookReply) => Promise<FastifyWebhookReply>;
|
|
9971
|
+
processor: WebhookProcessor;
|
|
9972
|
+
/**
|
|
9973
|
+
* Destroy this handler instance: removes all registered handlers
|
|
9974
|
+
* and clears it from the singleton cache so the next call creates a fresh instance.
|
|
9975
|
+
*/
|
|
9976
|
+
destroy: () => void;
|
|
9977
|
+
};
|
|
9978
|
+
//#endregion
|
|
9979
|
+
//#region src/core/webhook/frameworks/hono/hono.d.ts
|
|
9980
|
+
/**
|
|
9981
|
+
* The part of Hono's `Context` this adapter uses, typed locally so `hono` is
|
|
9982
|
+
* not a dependency. Any Hono `Context` satisfies it: `c.req.raw` is the
|
|
9983
|
+
* underlying web `Request`.
|
|
9984
|
+
*/
|
|
9985
|
+
interface HonoWebhookContext {
|
|
9986
|
+
req: {
|
|
9987
|
+
raw: Request; /** Hono's cached body reader, used when middleware already consumed `raw`. */
|
|
9988
|
+
text?: () => Promise<string>;
|
|
9727
9989
|
};
|
|
9728
9990
|
}
|
|
9991
|
+
interface HonoWebhookConfig extends WhatsAppConfig {}
|
|
9992
|
+
/** The object returned by {@link honoWebhookHandler}. */
|
|
9993
|
+
type HonoWebhookHandlers = ReturnType<typeof createHandlers$1>;
|
|
9994
|
+
/**
|
|
9995
|
+
* Hono webhook handler. Works on every runtime Hono runs on (Node.js, Bun,
|
|
9996
|
+
* Deno, Cloudflare Workers, Vercel Edge).
|
|
9997
|
+
*
|
|
9998
|
+
* @example
|
|
9999
|
+
* const wa = honoWebhookHandler(config);
|
|
10000
|
+
* wa.processor.onText(async (whatsapp, { message }) => { ... });
|
|
10001
|
+
* app.get('/webhook', wa.GET);
|
|
10002
|
+
* app.post('/webhook', wa.POST);
|
|
10003
|
+
* app.post('/flow', wa.flow);
|
|
10004
|
+
*/
|
|
10005
|
+
declare function honoWebhookHandler(config: HonoWebhookConfig): HonoWebhookHandlers;
|
|
10006
|
+
declare function createHandlers$1(config: HonoWebhookConfig, key: string): {
|
|
10007
|
+
GET: (c: HonoWebhookContext) => Promise<Response>;
|
|
10008
|
+
POST: (c: HonoWebhookContext) => Promise<Response>;
|
|
10009
|
+
webhook: (c: HonoWebhookContext) => Promise<Response>;
|
|
10010
|
+
flow: (c: HonoWebhookContext) => Promise<Response>;
|
|
10011
|
+
processor: WebhookProcessor;
|
|
10012
|
+
/**
|
|
10013
|
+
* Destroy this handler instance: removes all registered handlers
|
|
10014
|
+
* and clears it from the singleton cache so the next call creates a fresh instance.
|
|
10015
|
+
*/
|
|
10016
|
+
destroy: () => void;
|
|
10017
|
+
};
|
|
10018
|
+
//#endregion
|
|
10019
|
+
//#region src/core/webhook/frameworks/nextjs-app/nextjs-app.d.ts
|
|
9729
10020
|
interface NextJsAppWebhookConfig extends WhatsAppConfig {}
|
|
9730
10021
|
/** The object returned by {@link nextjsAppWebhookHandler}. */
|
|
9731
10022
|
type NextJsAppWebhookHandlers = ReturnType<typeof createHandlers>;
|
|
9732
10023
|
declare function nextjsAppWebhookHandler(config: NextJsAppWebhookConfig): NextJsAppWebhookHandlers;
|
|
9733
10024
|
declare function createHandlers(config: NextJsAppWebhookConfig, key: string): {
|
|
9734
|
-
GET: (request:
|
|
9735
|
-
POST: (request:
|
|
10025
|
+
GET: (request: Request) => Promise<Response>;
|
|
10026
|
+
POST: (request: Request) => Promise<Response>;
|
|
9736
10027
|
webhook: {
|
|
9737
|
-
GET: (request:
|
|
9738
|
-
POST: (request:
|
|
10028
|
+
GET: (request: Request) => Promise<Response>;
|
|
10029
|
+
POST: (request: Request) => Promise<Response>;
|
|
9739
10030
|
};
|
|
9740
10031
|
flow: {
|
|
9741
|
-
GET: (request:
|
|
9742
|
-
POST: (request:
|
|
10032
|
+
GET: (request: Request) => Promise<Response>;
|
|
10033
|
+
POST: (request: Request) => Promise<Response>;
|
|
9743
10034
|
};
|
|
9744
10035
|
processor: WebhookProcessor;
|
|
9745
10036
|
/**
|
|
@@ -9798,7 +10089,14 @@ declare function nextjsPagesWebhookHandler<TRequest extends BaseApiRequest, TRes
|
|
|
9798
10089
|
declare function extractMessageText(message: WhatsAppMessage): string;
|
|
9799
10090
|
//#endregion
|
|
9800
10091
|
//#region src/core/webhook/utils/generateXHub256Sig.d.ts
|
|
10092
|
+
/**
|
|
10093
|
+
* Compute the hex HMAC-SHA256 that Meta sends in `X-Hub-Signature-256`
|
|
10094
|
+
* (without the `sha256=` prefix). Needs `node:crypto`; use
|
|
10095
|
+
* {@link generateXHub256SigAsync} on edge runtimes.
|
|
10096
|
+
*/
|
|
9801
10097
|
declare const generateXHub256Sig: (body: string, appSecret: string) => string;
|
|
10098
|
+
/** Web Crypto variant of {@link generateXHub256Sig}; works on every runtime. */
|
|
10099
|
+
declare const generateXHub256SigAsync: (body: string, appSecret: string) => Promise<string>;
|
|
9802
10100
|
//#endregion
|
|
9803
10101
|
//#region src/core/webhook/utils/messageHelpers.d.ts
|
|
9804
10102
|
declare function isTextMessage(msg: WhatsAppMessage): msg is TextMessage;
|
|
@@ -9920,16 +10218,136 @@ declare function buildFieldsQueryString(fields?: string[] | string): string;
|
|
|
9920
10218
|
*/
|
|
9921
10219
|
declare function formatConfigTable(config: WabaConfigType): string;
|
|
9922
10220
|
//#endregion
|
|
10221
|
+
//#region src/utils/customerServiceWindow.d.ts
|
|
10222
|
+
/**
|
|
10223
|
+
* Length of the customer service window: 24 hours.
|
|
10224
|
+
*
|
|
10225
|
+
* "When a WhatsApp user messages you or calls you, a 24-hour timer called a customer service window
|
|
10226
|
+
* starts. If the user messages or calls you again before the timer expires, the timer resets to
|
|
10227
|
+
* 24 hours. [...] When the window closes, you can only send pre-approved template messages."
|
|
10228
|
+
*
|
|
10229
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/send-messages/ | Send messages: customer service windows}
|
|
10230
|
+
*/
|
|
10231
|
+
declare const CUSTOMER_SERVICE_WINDOW_MS: number;
|
|
10232
|
+
/**
|
|
10233
|
+
* SDK fallback length of a free entry point (FEP) window: 72 hours.
|
|
10234
|
+
* Prefer the expiry supplied by Meta; this fallback does not establish billing eligibility.
|
|
10235
|
+
*
|
|
10236
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/pricing/ | Pricing: free entry point windows}
|
|
10237
|
+
*/
|
|
10238
|
+
declare const FREE_ENTRY_POINT_WINDOW_MS: number;
|
|
10239
|
+
/**
|
|
10240
|
+
* Longest free entry point window Meta documents: up to 7 days for conversations started from an
|
|
10241
|
+
* ad that clicks to WhatsApp.
|
|
10242
|
+
*
|
|
10243
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/pricing/ | Pricing: free entry point windows}
|
|
10244
|
+
*/
|
|
10245
|
+
declare const MAX_FREE_ENTRY_POINT_WINDOW_MS: number;
|
|
10246
|
+
/**
|
|
10247
|
+
* A point in time accepted by the window helpers:
|
|
10248
|
+
* - `Date`
|
|
10249
|
+
* - `number`: Unix epoch in milliseconds, or in seconds when below `1e11` (before the year 5138 in
|
|
10250
|
+
* seconds, before March 1973 in milliseconds), so both `Date.now()` and webhook timestamps work
|
|
10251
|
+
* - `string`: a numeric string such as the webhook `messages[].timestamp` (`"1727856000"`, Unix
|
|
10252
|
+
* seconds, same rule as numbers), or any string `Date.parse` understands (ISO 8601)
|
|
10253
|
+
*/
|
|
10254
|
+
type WindowTimestamp = Date | number | string;
|
|
10255
|
+
/** State of a messaging window at a given instant. */
|
|
10256
|
+
interface MessagingWindow {
|
|
10257
|
+
/** True while the window is open (`now < expiresAt`). */
|
|
10258
|
+
isOpen: boolean;
|
|
10259
|
+
/** When the window closes, or `null` when there is no window (no inbound message yet). */
|
|
10260
|
+
expiresAt: Date | null;
|
|
10261
|
+
/** Milliseconds until the window closes, `0` once closed. Never more than the window length. */
|
|
10262
|
+
remainingMs: number;
|
|
10263
|
+
}
|
|
10264
|
+
interface CustomerServiceWindowOptions {
|
|
10265
|
+
/** The instant to evaluate. Defaults to `Date.now()`. */
|
|
10266
|
+
now?: WindowTimestamp;
|
|
10267
|
+
/**
|
|
10268
|
+
* Treat the window as closing this many milliseconds early. Use it to absorb clock drift between
|
|
10269
|
+
* your servers and Meta and the time a send spends in flight. Defaults to `0`.
|
|
10270
|
+
*/
|
|
10271
|
+
safetyMarginMs?: number;
|
|
10272
|
+
}
|
|
10273
|
+
interface FreeEntryPointWindowOptions extends CustomerServiceWindowOptions {
|
|
10274
|
+
/**
|
|
10275
|
+
* Window length. Defaults to {@link FREE_ENTRY_POINT_WINDOW_MS} (72 hours). Meta may keep a
|
|
10276
|
+
* click-to-WhatsApp ad window open for up to {@link MAX_FREE_ENTRY_POINT_WINDOW_MS} (7 days)
|
|
10277
|
+
* without saying how long a given window lasts, so prefer `expiresAt` when you have it.
|
|
10278
|
+
*/
|
|
10279
|
+
durationMs?: number;
|
|
10280
|
+
/**
|
|
10281
|
+
* Exact expiry when known, for example the status webhook's `conversation.expiration_timestamp`
|
|
10282
|
+
* (Unix seconds). Overrides `durationMs`.
|
|
10283
|
+
*/
|
|
10284
|
+
expiresAt?: WindowTimestamp;
|
|
10285
|
+
}
|
|
10286
|
+
/**
|
|
10287
|
+
* Returns the state of the 24-hour customer service window opened by the user's last inbound
|
|
10288
|
+
* message (or call).
|
|
10289
|
+
*
|
|
10290
|
+
* Free-form (non-template) messages can only be sent while it is open; outside it only approved
|
|
10291
|
+
* template messages are delivered (Meta rejects others with error `131047`). The window is exactly
|
|
10292
|
+
* 24 hours from the user's last message: at `lastInboundAt + 24h` it is closed.
|
|
10293
|
+
*
|
|
10294
|
+
* Pass the webhook message `timestamp` (Unix seconds string) of the latest message from the user.
|
|
10295
|
+
* Messages you send do not extend the window. Pass `null`/`undefined` when the user has never
|
|
10296
|
+
* messaged you; that returns a closed window with `expiresAt: null`.
|
|
10297
|
+
*
|
|
10298
|
+
* A free entry point window does not reopen this window: "the customer service window is independent
|
|
10299
|
+
* of the FEP window, so if the customer service window closes, you will only be able to send template
|
|
10300
|
+
* messages." Use {@link getFreeEntryPointWindow} for the pricing side.
|
|
10301
|
+
*
|
|
10302
|
+
* @throws WhatsAppValidationError when a timestamp or `safetyMarginMs` is malformed.
|
|
10303
|
+
*
|
|
10304
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/send-messages/ | Send messages: customer service windows}
|
|
10305
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/pricing/ | Pricing}
|
|
10306
|
+
*
|
|
10307
|
+
* @example
|
|
10308
|
+
* ```ts
|
|
10309
|
+
* const { isOpen, expiresAt } = getCustomerServiceWindow(message.timestamp);
|
|
10310
|
+
* if (!isOpen) await sendTemplateInstead();
|
|
10311
|
+
* ```
|
|
10312
|
+
*/
|
|
10313
|
+
declare function getCustomerServiceWindow(lastInboundAt: WindowTimestamp | null | undefined, options?: CustomerServiceWindowOptions): MessagingWindow;
|
|
10314
|
+
/**
|
|
10315
|
+
* True when a free-form (non-template) message can be sent: the customer service window opened by
|
|
10316
|
+
* the user's last inbound message is still open. See {@link getCustomerServiceWindow}.
|
|
10317
|
+
*
|
|
10318
|
+
* @throws WhatsAppValidationError when a timestamp or `safetyMarginMs` is malformed.
|
|
10319
|
+
*/
|
|
10320
|
+
declare function canSendFreeformMessage(lastInboundAt: WindowTimestamp | null | undefined, options?: CustomerServiceWindowOptions): boolean;
|
|
10321
|
+
/**
|
|
10322
|
+
* Returns the state of a free entry point (FEP) window.
|
|
10323
|
+
*
|
|
10324
|
+
* For eligible click-to-WhatsApp ad traffic, replying within the customer service window opens
|
|
10325
|
+
* a billing window from the time of your reply. Pass that first reply time as `openedAt`.
|
|
10326
|
+
*
|
|
10327
|
+
* Meta documents windows lasting up to 7 days for ads that click to WhatsApp. This helper uses
|
|
10328
|
+
* a 72-hour fallback estimate. Pass `expiresAt` (the status webhook's
|
|
10329
|
+
* `conversation.expiration_timestamp`) when you have it, or set `durationMs`.
|
|
10330
|
+
*
|
|
10331
|
+
* This is a billing window only. It does not allow free-form messages after the customer service
|
|
10332
|
+
* window closes; check {@link canSendFreeformMessage} for that.
|
|
10333
|
+
*
|
|
10334
|
+
* @throws WhatsAppValidationError when a timestamp, `durationMs` or `safetyMarginMs` is malformed.
|
|
10335
|
+
*
|
|
10336
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/pricing/ | Pricing: free entry point windows}
|
|
10337
|
+
*/
|
|
10338
|
+
declare function getFreeEntryPointWindow(openedAt: WindowTimestamp | null | undefined, options?: FreeEntryPointWindowOptions): MessagingWindow;
|
|
10339
|
+
//#endregion
|
|
9923
10340
|
//#region src/utils/logger.d.ts
|
|
9924
10341
|
declare class Logger implements LoggerInterface {
|
|
9925
10342
|
private name;
|
|
9926
|
-
private
|
|
10343
|
+
private debugEnabled;
|
|
9927
10344
|
constructor(name: string, debug?: boolean);
|
|
9928
10345
|
private formatData;
|
|
9929
10346
|
log(...data: any[]): void;
|
|
9930
10347
|
error(...data: any[]): void;
|
|
9931
10348
|
warn(...data: any[]): void;
|
|
9932
10349
|
info(...data: any[]): void;
|
|
10350
|
+
debug(...data: any[]): void;
|
|
9933
10351
|
}
|
|
9934
10352
|
//#endregion
|
|
9935
10353
|
//#region src/utils/objectToQueryString.d.ts
|
|
@@ -9976,5 +10394,5 @@ declare function isFlowErrorRequest(request: FlowEndpointRequest): request is Fl
|
|
|
9976
10394
|
*/
|
|
9977
10395
|
declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
|
|
9978
10396
|
//#endregion
|
|
9979
|
-
export { AUTHORIZATION_ERROR_CODES, type AcceptCallRequest, AcceptSolutionRequest, AccountMode, AddPhoneNumbersRequest, type ApiPermissionErrorCode, AssignedUserRequest, AssignedUsersListParams, type AudioMediaObject, AudioMediaTypes, AudioMediaTypesEnum, AudioMediaTypesType, type AudioMessage, type AudioMessageHandler, type AudioProcessedMessage, type AuthenticationTemplateOptions, BLOCK_USER_ERROR_CODES, type BaseApiRequest, type BaseApiResponse, type BaseClass, BlockUserObject, BlockUsersApi, BlockUsersClass, BlockUsersRequest, BlockUsersResponse, BlockedUserInfo, type BodyOptions, BusinessApi, BusinessClass, BusinessComplianceInfoResponse, BusinessFieldsParam, BusinessGraphListResponse, BusinessGraphObject, BusinessListParams, BusinessProfileApi, type BusinessProfileClass, type BusinessProfileData, type BusinessProfileField, type BusinessProfileFieldsParam, type BusinessProfileResponse, BusinessVerticalEnum, type ButtonMessage, type ButtonMessageHandler, type ButtonOptions, ButtonPosition, ButtonPositionEnum, ButtonPositionType, type ButtonProcessedMessage, CALLING_ERROR_CODES, type CallAction, type CallActionResponse, type CallAnnouncementLanguage, type CallCaptureStatus, type CallHours, type CallHoursDay, type CallHoursStatus, type CallIconVisibility, type CallPermission, type CallPermissionAction, type CallPermissionLimit, type CallPermissionsResponse, type CallRecordingConfig, type CallSdpType, type CallSession, type CallTranscriptionConfig, type CallbackPermissionStatus, CallingApi, type CallingClass, type CallingSettings, type CallingSettingsResponse, type CallingStatus, CarouselCard, type CarouselOptions, CatalogButton, type CatalogTemplateOptions, Category, CategoryEnum, CategoryType, CodeVerificationStatus, CommerceApi, type CommerceClass, type CommerceSetting, type CommerceSettingsResponse, ComponentType, ComponentTypeType, ComponentTypes, ComponentTypesEnum, ContactBookApi, ContactBookClass, type ContactInfo, type ContactObject, type ContactsMessage, type ContactsMessageHandler, type ContactsProcessedMessage, ConversationTypes, ConversationTypesEnum, ConversationTypesType, ConversationalAutomationRequest, ConversationalAutomationResponse, ConversationalCommand, ConversationalPrompt, CopyCodeButton, type CouponTemplateOptions, type CreateFlowResponse, CreateOBOMobilityIntentRequest, CreatePhoneNumberRequest, CreatePhoneNumberResponse, type CreateQrCodeRequest, CreateScheduleRequest, type CreateUploadSessionParams, CreateWhatsAppBusinessSolutionRequest, CurrencyCodesEnum, type CurrencyParameter, CursorPaginationParams, Cursors, DataLocalizationRegion, DataLocalizationRegionEnum, DataLocalizationRegionType, type DateTimeParameter, DeleteContactBookEntryParams, DeleteContactBookEntryResponse, type DirectSendCategory, type DirectSendConfig, type DirectSendOptions, type DocumentMediaObject, DocumentMediaTypes, DocumentMediaTypesEnum, DocumentMediaTypesType, type DocumentMessage, type DocumentMessageHandler, type DocumentProcessedMessage, type EncryptedMessageRequest, type EncryptedMessagesResponse, EncryptionApi, type EncryptionClass, type EncryptionKeyPair, type EncryptionPublicKeyResponse, type ErrorWebhookValue, type ExpressRequest, type ExpressResponse, type ExpressWebhookConfig, FLOW_ERROR_CODES, FailedUserInfo, type Flow, FlowActionEnum, FlowApi, type FlowAsset, type FlowAssetsResponse, FlowButton, FlowCategoryEnum, type FlowClass, type FlowDataExchangeRequest, type FlowDataExchangeResponse, type FlowDecryptedRequestResponse, type FlowEncryptedRequestPayload, type FlowEndpointRequest, type FlowEndpointResponse, type FlowErrorNotificationRequest, type FlowErrorNotificationResponse, type FlowHandler, type FlowHealthCheckRequest, type FlowHealthCheckResponse, type FlowHttpRequest, type FlowMigrationFailure, type FlowMigrationResponse, type FlowMigrationResult, type FlowPreview, type FlowPreviewResponse, FlowStatusEnum, type FlowSuccessScreenResponse, type FlowType, FlowTypeEnum, type FlowValidationError, type FlowValidationErrorPointer, type FlowsListResponse, type FooterOptions, GROUP_ERROR_CODES, type GeneralHeaderInterface, type GeneralMessageBody, type GeneralRequestBody, type GetUploadHandleParams, GraphObject, type GroupCreateRequest, type GroupCreateResponse, type GroupInfoField, type GroupInfoFieldsParam, type GroupInfoResponse, type GroupInviteLinkResponse, type GroupJoinApprovalMode, type GroupJoinRequest, type GroupJoinRequestError, type GroupJoinRequestFailure, type GroupJoinRequestsActionResponse, type GroupJoinRequestsResponse, type GroupListParams, type GroupListResponse, type GroupMessage, type GroupParticipant, type GroupParticipantInput, type GroupParticipantsRequest, type GroupSettingsResponse, GroupsApi, type GroupsClass, type HeaderOptions, HealthStatus, HealthStatusEntity, type HolidaySchedule, HostPlatform, HttpMethods, HttpMethodsEnum, HttpMethodsType, type HttpsClientClass, type HttpsClientResponseClass, INTEGRITY_ERROR_CODES, type ImageMediaObject, ImageMediaTypes, ImageMediaTypesEnum, ImageMediaTypesType, type ImageMessage, type ImageMessageHandler, type ImageProcessedMessage, type InitiateCallRequest, type InitiateCallResponse, type InteractiveButtonReplyMessage, type InteractiveListReplyMessage, type InteractiveMessage, type InteractiveMessageHandler, type InteractiveObject, type InteractiveProcessedMessage, type InteractiveReply, InteractiveTypes, InteractiveTypesEnum, InteractiveTypesType, Languages, LanguagesEnum, LanguagesType, type LimitedTimeOfferOptions, type LimitedTimeOfferTemplateOptions, ListBlockedUsersParams, ListBlockedUsersResponse, type LocationInfo, type LocationMessage, type LocationMessageHandler, type LocationObject, type LocationParameter, type LocationProcessedMessage, Logger, type LoggerInterface, MPMButton, type MPMTemplateOptions, type MarketingMessageBidSpec, type MarketingMessageRequest, MarketingMessagesApi, type MarketingMessagesClass, type MarketingMessagesLinkClickData, MediaApi, type MediaCardCarouselTemplateOptions, MediaCarouselCard, MediaClass, type MediaInfo, type MediaParameter, MediaResponse, MediasResponse, MessagesApi as MessageApi, MessagesApi, MessageCategory, MessageCategoryEnum, MessageCategoryType, type MessageHandler, MessageHistoryApi, MessageHistoryClass, MessageHistoryEventListParams, MessageHistoryFieldsParam, MessageHistoryItem, MessageHistoryListParams, MessageHistoryResponse, type MessageRecipientType, type MessageRequestBody, type MessageRequestParams, type MessageStatus, MessageTemplateObject, MessageTemplateRequestBody, MessageTypes, MessageTypesEnum, MessageTypesType, type MessageWebhookValue, type MessagesClass, type MessagesResponse, MessagingLimitTier, type MetaError, type MetaErrorData, type MetaErrorDetail, type NextFunction, type NextJsAppWebhookConfig, type NextJsAppWebhookHandlers, type NextJsWebhookConfig, OTPButton, type OTPTemplateOptions, OfficialBusinessAccountAction, OfficialBusinessAccountApplicationData, OfficialBusinessAccountStatusResponse, OnboardPartnersToMMLiteRequest, type OrderInfo, type OrderMessage, type OrderMessageHandler, type OrderProcessedMessage, type Pagination, type PaginationCursors, type Paging, PagingCursors, PagingInfo, ParametersTypes, ParametersTypesEnum, ParametersTypesType, PassThreadControlParams, type PaymentConfiguration, type PaymentConfigurationCode, type PaymentConfigurationCreateRequest, type PaymentConfigurationCreateResponse, type PaymentConfigurationDeleteRequest, type PaymentConfigurationOauthLinkRequest, type PaymentConfigurationOauthLinkResponse, type PaymentConfigurationProvider, type PaymentConfigurationStatus, type PaymentConfigurationUpdateRequest, type PaymentConfigurationUpdateResponse, type PaymentConfigurationsResponse, PaymentsApi, type PaymentsClass, PhoneNumberApi, PhoneNumberButton, PhoneNumberClass, PhoneNumberField, PhoneNumberFieldsParam, PhoneNumberFilter, PhoneNumberResponse, PhoneNumberSettingsFieldsParam, PhoneNumberSettingsParams, PhoneNumberSettingsResponse, PhoneNumberSort, PhoneNumberStatus, PhoneNumbersListParams, PhoneNumbersResponse, PlatformType, type PreAcceptCallRequest, type ProcessedMessage, type ProcessedStatus, type ProcessedUserAction, type ProductCardCarouselTemplateOptions, ProductCarouselCard, type ProductParameter, type ProductSection, QrCodeApi, type QrCodeClass, type QrCodeResponse, type QrCodesResponse, QualityRating, QualityScore, QuickReplyButton, type ReactionInfo, type ReactionMessage, type ReactionMessageHandler, type ReactionParams, type ReactionProcessedMessage, ReferralSourceTypes, ReferralSourceTypesEnum, ReferralSourceTypesType, RegistrationApi, type RegistrationClass, type RegistrationRequest, type RejectCallRequest, RejectSolutionRequest, ReleaseThreadControlParams, RemoveAssignedUserRequest, RequestCodeMethods, RequestCodeMethodsEnum, RequestCodeMethodsType, RequestPreVerifiedPhoneNumberCodeRequest, RequestVerificationCodeRequest, type RequesterClass, type RequesterResponseInterface, type ResponseData, type ResponseHeaderValue, type ResponseHeaders, type ResponseJSONBody, type ResponsePagination, type ResponseSuccess, SEND_MESSAGE_ERROR_CODES, SPMButton, type SPMTemplateOptions, SetOBOMobilityIntentRequest, SetSolutionMigrationIntentRequest, SharePreVerifiedPhoneNumberRequest, type SipServer, type SipSettings, type SipStatus, SolutionDeactivationRequest, SolutionFieldsParam, SolutionGraphObject, SolutionListParams, SolutionListResponse, SolutionMigrationIntent, SolutionsApi, SolutionsClass, Status, StatusEnum, type StatusHandler, type StatusParams, type StatusResponse, StatusType, type StatusWebhook, type StatusWebhookValue, type StickerMediaObject, StickerMediaTypes, StickerMediaTypesEnum, StickerMediaTypesType, type StickerMessage, type StickerMessageHandler, type StickerProcessedMessage, SubType, SubTypeEnum, SubTypeType, SystemChangeTypes, SystemChangeTypesEnum, SystemChangeTypesType, type SystemMessage, type SystemMessageHandler, type SystemProcessedMessage, THROTTLING_ERROR_CODES, TakeThreadControlParams, TemplateApi, TemplateBidSpec, TemplateBody, TemplateButton, TemplateButtons, TemplateCarousel, TemplateClass, TemplateDeleteParams, TemplateFooter, TemplateFormat, TemplateGetParams, TemplateHeader, TemplateHeaderExample, TemplateLimitedTimeOffer, TemplateOptimizationSpec, type TemplateOptions, type TemplateParameter, TemplateRequestBody, TemplateResponse, TemplateStatus, TemplateStatusEnum, TemplateStatusType, type TerminateCallRequest, type TextMessage, type TextMessageHandler, type TextMessageParams, type TextObject, type TextParameter, type TextProcessedMessage, ThreadControlApi, ThreadControlBaseParams, ThreadControlClass, ThreadControlResponse, ThreadControlRole, ThreadControlUserIdentifier, Throughput, ThroughputLevel, ThroughputResponse, TwoStepVerificationApi, type TwoStepVerificationClass, TwoStepVerificationParams, type TwoStepVerificationRequest, URLButton, UnblockUsersRequest, UnifiedCertStatus, type UnsupportedMessage, UpdateBusinessComplianceInfoRequest, type UpdateBusinessProfileRequest, type UpdateCallingSettingsRequest, type UpdateCommerceSettingsRequest, type UpdateFlowResponse, type UpdateGroupSettingsRequest, UpdateOfficialBusinessAccountStatusRequest, UpdatePhoneNumberSettingsRequest, UpdatePhoneNumberStatusRequest, type UpdateQrCodeRequest, UpdateUsernameRequest, UpdateWabaAccountRequest, UpdateWabaSubscription, UpdateWhatsAppBusinessProfileRequest, type UploadBusinessProfileResponse, type UploadHandle, type UploadMediaParams, UploadMediaResponse, type UploadSession, type UploadSessionResponse, type UserAction, type UserActionHandler, type UserActionType, type UserActionsWebhookValue, UsernameResponse, UsernameStatus, UsernameSuggestionsResponse, UsernameTransferAction, type ValidateFlowJsonResponse, VerifyCodeRequest, VerifyPreVerifiedPhoneNumberCodeRequest, type VideoMediaObject, VideoMediaTypes, VideoMediaTypesEnum, VideoMediaTypesType, type VideoMessage, type VideoMessageHandler, type VideoProcessedMessage, WABAClass, WHATSAPP_ERROR_CODES, WabaAccount, WabaAccountFields, WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaApi, WabaBusinessVerificationStatus, WabaConfigEnum, type WabaConfigType, WabaFieldsParam, WabaGraphObject, WabaHealthStatus, WabaHealthStatusCanSendMessage, WabaHealthStatusEntity, WabaHealthStatusError, WabaListParams, WabaListResponse, WabaSubscription, WabaSubscriptions, type WebhookContact, type WebhookEvent, type WebhookHandlerContext, type WebhookMessage, type WebhookPayload, WebhookProcessor, type WebhookResponse, type WebhookSignatureOptions, WebhookTypes, WebhookTypesEnum, WebhookTypesType, type WebhookValue, type WeeklyOperatingHours, WhatsApp, WhatsApp as default, WhatsAppApiError, WhatsAppAuthorizationError, WhatsAppBlockUserError, WhatsAppCallingError, type WhatsAppConfig, WhatsAppError, type WhatsAppErrorCode, WhatsAppFlowError, WhatsAppGroupError, WhatsAppIntegrityError, type WhatsAppMessage, WhatsAppNetworkError, WhatsAppSendMessageError, WhatsAppThrottlingError, WhatsAppUnknownError, WhatsAppValidationError, buildFieldsQueryString, constructFullUrl, createAuthenticationTemplate, createCatalogTemplate, createCouponTemplate, createLimitedTimeOfferTemplate, createMPMTemplate, createMediaCardCarouselTemplate, createOTPTemplate, createProductCardCarouselTemplate, createSPMTemplate, createTemplate, createWhatsAppApiError, decryptFlowRequest, encryptFlowResponse, expressWebhookHandler, extractMessageText, formatConfigTable, generateEncryption, generateXHub256Sig, getContactsInfo, getInteractiveReply, getLocationInfo, getMediaInfo, getOrderInfo, getReactionInfo, isApiPermissionErrorCode, isAudioMessage, isAuthorizationErrorCode, isBlockUserErrorCode, isButtonMessage, isButtonReply, isCallingErrorCode, isContactsMessage, isDocumentMessage, isFlowDataExchangeRequest, isFlowErrorCode, isFlowErrorRequest, isFlowPingRequest, isGroupErrorCode, isImageMessage, isIntegrityErrorCode, isInteractiveMessage, isListReply, isLocationMessage, isMetaError, isNfmReply, isOrderMessage, isReactionMessage, isSendMessageErrorCode, isStickerMessage, isSystemMessage, isTextMessage, isThrottlingErrorCode, isValidWebhookSignature, isVideoMessage, isWhatsAppApiErrorResponse, isWhatsAppAuthorizationError, isWhatsAppBlockUserError, isWhatsAppCallingError, isWhatsAppErrorCode, isWhatsAppFlowError, isWhatsAppGroupError, isWhatsAppIntegrityError, isWhatsAppSendMessageError, isWhatsAppThrottlingError, nextjsAppWebhookHandler, nextjsPagesWebhookHandler, normalizeMetaError, objectToQueryString, processFlowRequest, processWebhookMessages };
|
|
10397
|
+
export { AUTHORIZATION_ERROR_CODES, type AcceptCallRequest, AcceptSolutionRequest, AccountMode, AddPhoneNumbersRequest, type ApiPermissionErrorCode, AssignedUserRequest, AssignedUsersListParams, type AudioMediaObject, AudioMediaTypes, AudioMediaTypesEnum, AudioMediaTypesType, type AudioMessage, type AudioMessageHandler, type AudioProcessedMessage, type AuthenticationTemplateOptions, BLOCK_USER_ERROR_CODES, type BaseApiRequest, type BaseApiResponse, type BaseClass, BlockUserObject, BlockUsersApi, BlockUsersClass, BlockUsersRequest, BlockUsersResponse, BlockedUserInfo, type BodyOptions, BusinessApi, BusinessClass, BusinessComplianceInfoResponse, BusinessFieldsParam, BusinessGraphListResponse, BusinessGraphObject, BusinessListParams, BusinessProfileApi, type BusinessProfileClass, type BusinessProfileData, type BusinessProfileField, type BusinessProfileFieldsParam, type BusinessProfileResponse, type BusinessUseCaseUsage, BusinessVerticalEnum, type ButtonMessage, type ButtonMessageHandler, type ButtonOptions, ButtonPosition, ButtonPositionEnum, ButtonPositionType, type ButtonProcessedMessage, CALLING_ERROR_CODES, CUSTOMER_SERVICE_WINDOW_MS, type CallAction, type CallActionResponse, type CallAnnouncementLanguage, type CallCaptureStatus, type CallHours, type CallHoursDay, type CallHoursStatus, type CallIconVisibility, type CallPermission, type CallPermissionAction, type CallPermissionLimit, type CallPermissionsResponse, type CallRecordingConfig, type CallSdpType, type CallSession, type CallTranscriptionConfig, type CallbackPermissionStatus, CallingApi, type CallingClass, type CallingSettings, type CallingSettingsResponse, type CallingStatus, CarouselCard, type CarouselOptions, CatalogButton, type CatalogTemplateOptions, Category, CategoryEnum, CategoryType, CodeVerificationStatus, CommerceApi, type CommerceClass, type CommerceSetting, type CommerceSettingsResponse, ComponentType, ComponentTypeType, ComponentTypes, ComponentTypesEnum, ContactBookApi, ContactBookClass, type ContactInfo, type ContactObject, type ContactsMessage, type ContactsMessageHandler, type ContactsProcessedMessage, ConversationTypes, ConversationTypesEnum, ConversationTypesType, ConversationalAutomationRequest, ConversationalAutomationResponse, ConversationalCommand, ConversationalPrompt, CopyCodeButton, type CouponTemplateOptions, type CreateFlowResponse, CreateOBOMobilityIntentRequest, CreatePhoneNumberRequest, CreatePhoneNumberResponse, type CreateQrCodeRequest, CreateScheduleRequest, type CreateUploadSessionParams, CreateWhatsAppBusinessSolutionRequest, CurrencyCodesEnum, type CurrencyParameter, CursorPaginationParams, Cursors, type CustomerServiceWindowOptions, DataLocalizationRegion, DataLocalizationRegionEnum, DataLocalizationRegionType, type DateTimeParameter, type DecryptedFlowRequest, type DedupeStore, DeleteContactBookEntryParams, DeleteContactBookEntryResponse, type DirectSendCategory, type DirectSendConfig, type DirectSendOptions, type DocumentMediaObject, DocumentMediaTypes, DocumentMediaTypesEnum, DocumentMediaTypesType, type DocumentMessage, type DocumentMessageHandler, type DocumentProcessedMessage, type EncryptedMessageRequest, type EncryptedMessagesResponse, EncryptionApi, type EncryptionClass, type EncryptionKeyPair, type EncryptionPublicKeyResponse, type ErrorWebhookValue, type ExpressRequest, type ExpressResponse, type ExpressWebhookConfig, FLOW_ERROR_CODES, FREE_ENTRY_POINT_WINDOW_MS, FailedUserInfo, type FastifyWebhookConfig, type FastifyWebhookHandlers, type FastifyWebhookReply, type FastifyWebhookRequest, type Flow, FlowActionEnum, FlowApi, type FlowAsset, type FlowAssetsResponse, FlowButton, FlowCategoryEnum, type FlowClass, type FlowDataExchangeRequest, type FlowDataExchangeResponse, type FlowDecryptedRequestResponse, type FlowEncryptedRequestPayload, type FlowEndpointRequest, type FlowEndpointResponse, type FlowErrorNotificationRequest, type FlowErrorNotificationResponse, type FlowHandler, type FlowHealthCheckRequest, type FlowHealthCheckResponse, type FlowHttpRequest, type FlowMigrationFailure, type FlowMigrationResponse, type FlowMigrationResult, type FlowPreview, type FlowPreviewResponse, FlowStatusEnum, type FlowSuccessScreenResponse, type FlowType, FlowTypeEnum, type FlowValidationError, type FlowValidationErrorPointer, type FlowsListResponse, type FooterOptions, type FreeEntryPointWindowOptions, GROUP_ERROR_CODES, type GeneralHeaderInterface, type GeneralMessageBody, type GeneralRequestBody, type GetUploadHandleParams, GraphObject, type GroupCreateRequest, type GroupCreateResponse, type GroupInfoField, type GroupInfoFieldsParam, type GroupInfoResponse, type GroupInviteLinkResponse, type GroupJoinApprovalMode, type GroupJoinRequest, type GroupJoinRequestError, type GroupJoinRequestFailure, type GroupJoinRequestsActionResponse, type GroupJoinRequestsResponse, type GroupListParams, type GroupListResponse, type GroupMessage, type GroupParticipant, type GroupParticipantInput, type GroupParticipantsRequest, type GroupSettingsResponse, GroupsApi, type GroupsClass, type HeaderOptions, HealthStatus, HealthStatusEntity, type HolidaySchedule, type HonoWebhookConfig, type HonoWebhookContext, type HonoWebhookHandlers, HostPlatform, HttpMethods, HttpMethodsEnum, HttpMethodsType, type HttpsClientClass, type HttpsClientResponseClass, INTEGRITY_ERROR_CODES, type ImageMediaObject, ImageMediaTypes, ImageMediaTypesEnum, ImageMediaTypesType, type ImageMessage, type ImageMessageHandler, type ImageProcessedMessage, type InitiateCallRequest, type InitiateCallResponse, type InteractiveButtonReplyMessage, type InteractiveListReplyMessage, type InteractiveMessage, type InteractiveMessageHandler, type InteractiveObject, type InteractiveProcessedMessage, type InteractiveReply, InteractiveTypes, InteractiveTypesEnum, InteractiveTypesType, Languages, LanguagesEnum, LanguagesType, type LimitedTimeOfferOptions, type LimitedTimeOfferTemplateOptions, ListBlockedUsersParams, ListBlockedUsersResponse, type LocationInfo, type LocationMessage, type LocationMessageHandler, type LocationObject, type LocationParameter, type LocationProcessedMessage, Logger, type LoggerInterface, MAX_FREE_ENTRY_POINT_WINDOW_MS, MPMButton, type MPMTemplateOptions, type MarketingMessageBidSpec, type MarketingMessageRequest, MarketingMessagesApi, type MarketingMessagesClass, type MarketingMessagesLinkClickData, MediaApi, type MediaCardCarouselTemplateOptions, MediaCarouselCard, MediaClass, type MediaInfo, type MediaParameter, MediaResponse, MediasResponse, MemoryDedupeStore, type MemoryDedupeStoreOptions, MessagesApi as MessageApi, MessagesApi, MessageCategory, MessageCategoryEnum, MessageCategoryType, type MessageHandler, MessageHistoryApi, MessageHistoryClass, MessageHistoryEventListParams, MessageHistoryFieldsParam, MessageHistoryItem, MessageHistoryListParams, MessageHistoryResponse, type MessageRecipientType, type MessageRequestBody, type MessageRequestParams, type MessageStatus, MessageTemplateObject, MessageTemplateRequestBody, MessageTypes, MessageTypesEnum, MessageTypesType, type MessageWebhookValue, type MessagesClass, type MessagesResponse, MessagingLimitTier, type MessagingWindow, type MetaError, type MetaErrorData, type MetaErrorDetail, type NextFunction, type NextJsAppWebhookConfig, type NextJsAppWebhookHandlers, type NextJsWebhookConfig, type NonMessageWebhookField, OTPButton, type OTPTemplateOptions, OfficialBusinessAccountAction, OfficialBusinessAccountApplicationData, OfficialBusinessAccountStatusResponse, OnboardPartnersToMMLiteRequest, type OrderInfo, type OrderMessage, type OrderMessageHandler, type OrderProcessedMessage, type Pagination, type PaginationCursors, type Paging, PagingCursors, PagingInfo, ParametersTypes, ParametersTypesEnum, ParametersTypesType, PassThreadControlParams, type PaymentConfiguration, type PaymentConfigurationCode, type PaymentConfigurationCreateRequest, type PaymentConfigurationCreateResponse, type PaymentConfigurationDeleteRequest, type PaymentConfigurationOauthLinkRequest, type PaymentConfigurationOauthLinkResponse, type PaymentConfigurationProvider, type PaymentConfigurationStatus, type PaymentConfigurationUpdateRequest, type PaymentConfigurationUpdateResponse, type PaymentConfigurationsResponse, PaymentsApi, type PaymentsClass, PhoneNumberApi, PhoneNumberButton, PhoneNumberClass, PhoneNumberField, PhoneNumberFieldsParam, PhoneNumberFilter, PhoneNumberResponse, PhoneNumberSettingsFieldsParam, PhoneNumberSettingsParams, PhoneNumberSettingsResponse, PhoneNumberSort, PhoneNumberStatus, PhoneNumbersListParams, PhoneNumbersResponse, PlatformType, type PreAcceptCallRequest, type ProcessWebhookOptions, type ProcessedMessage, type ProcessedStatus, type ProcessedUserAction, type ProcessedWebhookField, type ProductCardCarouselTemplateOptions, ProductCarouselCard, type ProductParameter, type ProductSection, QrCodeApi, type QrCodeClass, type QrCodeResponse, type QrCodesResponse, QualityRating, QualityScore, QuickReplyButton, type RateLimitHeadersInput, type RateLimitInfo, type RateLimitInfoContext, type RateLimitInfoListener, type RateLimitUsage, type ReactionInfo, type ReactionMessage, type ReactionMessageHandler, type ReactionParams, type ReactionProcessedMessage, ReferralSourceTypes, ReferralSourceTypesEnum, ReferralSourceTypesType, RegistrationApi, type RegistrationClass, type RegistrationRequest, type RejectCallRequest, RejectSolutionRequest, ReleaseThreadControlParams, RemoveAssignedUserRequest, RequestCodeMethods, RequestCodeMethodsEnum, RequestCodeMethodsType, RequestPreVerifiedPhoneNumberCodeRequest, RequestVerificationCodeRequest, type RequesterClass, type RequesterResponseInterface, type ResponseData, type ResponseHeaderValue, type ResponseHeaders, type ResponseJSONBody, type ResponsePagination, type ResponseSuccess, type RetryConfig, SEND_MESSAGE_ERROR_CODES, SPMButton, type SPMTemplateOptions, SetOBOMobilityIntentRequest, SetSolutionMigrationIntentRequest, SharePreVerifiedPhoneNumberRequest, type SipServer, type SipSettings, type SipStatus, SolutionDeactivationRequest, SolutionFieldsParam, SolutionGraphObject, SolutionListParams, SolutionListResponse, SolutionMigrationIntent, SolutionsApi, SolutionsClass, Status, StatusEnum, type StatusHandler, type StatusParams, type StatusResponse, StatusType, type StatusWebhook, type StatusWebhookValue, type StickerMediaObject, StickerMediaTypes, StickerMediaTypesEnum, StickerMediaTypesType, type StickerMessage, type StickerMessageHandler, type StickerProcessedMessage, SubType, SubTypeEnum, SubTypeType, SystemChangeTypes, SystemChangeTypesEnum, SystemChangeTypesType, type SystemMessage, type SystemMessageHandler, type SystemProcessedMessage, THROTTLING_ERROR_CODES, TakeThreadControlParams, TemplateApi, TemplateBidSpec, TemplateBody, TemplateButton, TemplateButtons, TemplateCarousel, TemplateClass, TemplateDeleteParams, TemplateFooter, TemplateFormat, TemplateGetParams, TemplateHeader, TemplateHeaderExample, TemplateLimitedTimeOffer, TemplateOptimizationSpec, type TemplateOptions, type TemplateParameter, TemplateRequestBody, TemplateResponse, TemplateStatus, TemplateStatusEnum, TemplateStatusType, type TerminateCallRequest, type TextMessage, type TextMessageHandler, type TextMessageParams, type TextObject, type TextParameter, type TextProcessedMessage, ThreadControlApi, ThreadControlBaseParams, ThreadControlClass, ThreadControlResponse, ThreadControlRole, ThreadControlUserIdentifier, Throughput, ThroughputLevel, ThroughputResponse, TwoStepVerificationApi, type TwoStepVerificationClass, TwoStepVerificationParams, type TwoStepVerificationRequest, URLButton, UnblockUsersRequest, UnifiedCertStatus, type UnsupportedMessage, UpdateBusinessComplianceInfoRequest, type UpdateBusinessProfileRequest, type UpdateCallingSettingsRequest, type UpdateCommerceSettingsRequest, type UpdateFlowResponse, type UpdateGroupSettingsRequest, UpdateOfficialBusinessAccountStatusRequest, UpdatePhoneNumberSettingsRequest, UpdatePhoneNumberStatusRequest, type UpdateQrCodeRequest, UpdateUsernameRequest, UpdateWabaAccountRequest, UpdateWabaSubscription, UpdateWhatsAppBusinessProfileRequest, type UploadBusinessProfileResponse, type UploadHandle, UploadMediaInput, UploadMediaOptions, type UploadMediaParams, UploadMediaResponse, type UploadSession, type UploadSessionResponse, type UserAction, type UserActionHandler, type UserActionType, type UserActionsWebhookValue, UsernameResponse, UsernameStatus, UsernameSuggestionsResponse, UsernameTransferAction, type ValidateFlowJsonResponse, VerifyCodeRequest, VerifyPreVerifiedPhoneNumberCodeRequest, type VideoMediaObject, VideoMediaTypes, VideoMediaTypesEnum, VideoMediaTypesType, type VideoMessage, type VideoMessageHandler, type VideoProcessedMessage, WABAClass, WHATSAPP_ERROR_CODES, WabaAccount, WabaAccountFields, WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaApi, WabaBusinessVerificationStatus, WabaConfigEnum, type WabaConfigType, WabaFieldsParam, WabaGraphObject, WabaHealthStatus, WabaHealthStatusCanSendMessage, WabaHealthStatusEntity, WabaHealthStatusError, WabaListParams, WabaListResponse, WabaSubscription, WabaSubscriptions, type WebhookContact, type WebhookDedupeConfig, type WebhookDedupeOptions, type WebhookEvent, type WebhookFieldHandler, type WebhookFieldHandlerMap, type WebhookFieldHandlerOptions, type WebhookFieldType, type WebhookFieldValue, type WebhookFieldValueMap, type WebhookHandlerContext, type WebhookMessage, type WebhookPayload, WebhookProcessor, type WebhookResponse, type WebhookSignatureOptions, WebhookTypes, WebhookTypesEnum, WebhookTypesType, type WebhookValue, type WeeklyOperatingHours, WhatsApp, WhatsApp as default, WhatsAppApiError, WhatsAppAuthorizationError, WhatsAppBlockUserError, WhatsAppCallingError, type WhatsAppConfig, WhatsAppError, type WhatsAppErrorCode, WhatsAppFlowError, WhatsAppGroupError, WhatsAppIntegrityError, type WhatsAppMessage, WhatsAppNetworkError, WhatsAppSendMessageError, WhatsAppThrottlingError, WhatsAppUnknownError, WhatsAppValidationError, type WindowTimestamp, buildFieldsQueryString, canSendFreeformMessage, constructFullUrl, createAuthenticationTemplate, createCatalogTemplate, createCouponTemplate, createLimitedTimeOfferTemplate, createMPMTemplate, createMediaCardCarouselTemplate, createOTPTemplate, createProductCardCarouselTemplate, createSPMTemplate, createTemplate, createWhatsAppApiError, decryptFlowRequest, decryptFlowRequestAsync, encryptFlowResponse, encryptFlowResponseAsync, expressWebhookHandler, extractMessageText, fastifyWebhookHandler, formatConfigTable, generateEncryption, generateXHub256Sig, generateXHub256SigAsync, getContactsInfo, getCustomerServiceWindow, getFreeEntryPointWindow, getInteractiveReply, getLocationInfo, getMediaInfo, getOrderInfo, getReactionInfo, honoWebhookHandler, isApiPermissionErrorCode, isAudioMessage, isAuthorizationErrorCode, isBlockUserErrorCode, isButtonMessage, isButtonReply, isCallingErrorCode, isContactsMessage, isDocumentMessage, isFlowDataExchangeRequest, isFlowErrorCode, isFlowErrorRequest, isFlowPingRequest, isGroupErrorCode, isImageMessage, isIntegrityErrorCode, isInteractiveMessage, isListReply, isLocationMessage, isMetaError, isNfmReply, isOrderMessage, isReactionMessage, isSendMessageErrorCode, isStickerMessage, isSystemMessage, isTextMessage, isThrottlingErrorCode, isValidWebhookSignature, isVideoMessage, isWhatsAppApiErrorResponse, isWhatsAppAuthorizationError, isWhatsAppBlockUserError, isWhatsAppCallingError, isWhatsAppErrorCode, isWhatsAppFlowError, isWhatsAppGroupError, isWhatsAppIntegrityError, isWhatsAppSendMessageError, isWhatsAppThrottlingError, nextjsAppWebhookHandler, nextjsPagesWebhookHandler, normalizeMetaError, objectToQueryString, parseRateLimitHeaders, parseRetryAfter, processFlowRequest, processWebhookMessages, verifyWebhookSignature };
|
|
9980
10398
|
//# sourceMappingURL=index.d.mts.map
|