meta-cloud-api 3.11.1 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/api/flow/types/common.ts","../../src/api/waba/types/common.ts","../../src/types/constants.ts"],"sourcesContent":["// Docs: https://developers.facebook.com/documentation/business-messaging/whatsapp/flows/\n\nimport type { IncomingHttpHeaders, IncomingMessage } from 'node:http';\nimport type { ResponseSuccess } from '../../../types';\n\n/**\n * Enum for Flow Status\n */\nexport enum FlowStatusEnum {\n Draft = 'DRAFT',\n Published = 'PUBLISHED',\n Throttled = 'THROTTLED',\n Blocked = 'BLOCKED',\n Deprecated = 'DEPRECATED',\n}\n\n/**\n * Enum for Flow Categories\n */\nexport enum FlowCategoryEnum {\n SignUp = 'SIGN_UP',\n SignIn = 'SIGN_IN',\n AppointmentBooking = 'APPOINTMENT_BOOKING',\n LeadGeneration = 'LEAD_GENERATION',\n ContactUs = 'CONTACT_US',\n CustomerSupport = 'CUSTOMER_SUPPORT',\n Survey = 'SURVEY',\n Other = 'OTHER',\n}\n\nexport enum FlowActionEnum {\n INIT = 'INIT',\n BACK = 'BACK',\n DATA_EXCHANGE = 'data_exchange',\n}\n\n/**\n * Enum for Flow Types in webhook handlers\n * Used to register handlers for specific flow events\n */\nexport enum FlowTypeEnum {\n /** Health check/ping requests */\n Ping = 'ping',\n /** Data exchange requests */\n Change = 'data_exchange',\n /** Error notification requests */\n Error = 'error',\n /** Match all flow action types */\n All = '*',\n}\n\nexport type FlowType = (typeof FlowTypeEnum)[keyof typeof FlowTypeEnum];\n\n/**\n * Flow Validation Error Pointer\n */\nexport interface FlowValidationErrorPointer {\n line_start: number;\n line_end: number;\n column_start: number;\n column_end: number;\n path: string;\n}\n\n/**\n * Flow Validation Error\n */\nexport interface FlowValidationError {\n error: string;\n error_type: string;\n message: string;\n line_start: number;\n line_end: number;\n column_start: number;\n column_end: number;\n pointers: FlowValidationErrorPointer[];\n}\n\n/**\n * Flow Item\n */\nexport interface Flow {\n id: string;\n name: string;\n status: FlowStatusEnum;\n categories: FlowCategoryEnum[];\n validation_errors: FlowValidationError[];\n}\n\n/**\n * Pagination Cursors\n */\nexport interface PaginationCursors {\n before: string;\n after: string;\n}\n\n/**\n * Pagination Object\n */\nexport interface Pagination {\n cursors: PaginationCursors;\n}\n\n/**\n * Flows List Response\n */\nexport interface FlowsListResponse {\n data: Flow[];\n paging: Pagination;\n}\n\n/**\n * Flow Asset\n */\nexport interface FlowAsset {\n name: string;\n asset_type: string;\n download_url: string;\n}\n\n/**\n * Flow Assets Response\n */\nexport interface FlowAssetsResponse {\n data: FlowAsset[];\n paging: Pagination;\n}\n\n/**\n * Flow Preview\n */\nexport interface FlowPreview {\n preview_url: string;\n expires_at: string;\n}\n\n/**\n * Flow Preview Response\n */\nexport interface FlowPreviewResponse {\n preview: FlowPreview;\n id: string;\n}\n\n/**\n * Flow Migration Result\n */\nexport interface FlowMigrationResult {\n source_name: string;\n source_id: string;\n migrated_id: string;\n}\n\n/**\n * Flow Migration Failure\n */\nexport interface FlowMigrationFailure {\n source_name: string;\n error_code: string;\n error_message: string;\n}\n\n/**\n * Create Flow Response\n */\nexport interface CreateFlowResponse {\n id: string;\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * Update Flow Response\n */\nexport interface UpdateFlowResponse {\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * Flow Migration Response\n */\nexport interface FlowMigrationResponse {\n migrated_flows: FlowMigrationResult[];\n failed_flows: FlowMigrationFailure[];\n}\n\n/**\n * Validate Flow JSON Response\n */\nexport interface ValidateFlowJsonResponse {\n valid: boolean;\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * WhatsApp Flow Endpoint - Encrypted Request Payload\n * Represents the raw encrypted data received from WhatsApp\n */\nexport interface FlowEncryptedRequestPayload {\n encrypted_aes_key: string;\n encrypted_flow_data: string;\n initial_vector: string;\n}\n\n/**\n * WhatsApp Flow Endpoint - Decrypted Request Response\n * Represents the successfully decrypted data and encryption keys\n */\nexport interface FlowDecryptedRequestResponse {\n decryptedBody: any;\n aesKeyBuffer: Buffer;\n initialVectorBuffer: Buffer;\n}\n\n/**\n * WhatsApp Flow Endpoint - HTTP Request with Body\n * Represents an HTTP request with the encrypted payload\n */\nexport interface FlowHttpRequest extends IncomingMessage {\n body: FlowEncryptedRequestPayload;\n headers: IncomingHttpHeaders;\n}\n\n/**\n * WhatsApp Flow Endpoint - Health Check Request\n * Represents the structure of a health check request\n */\nexport interface FlowHealthCheckRequest {\n action: 'ping';\n version: '3.0';\n}\n\n/**\n * WhatsApp Flow Endpoint - Health Check Response\n * The expected response structure for health check requests\n */\nexport interface FlowHealthCheckResponse {\n data: {\n status: 'active';\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Data Exchange Request\n * Represents the structure of a data exchange request\n */\nexport interface FlowDataExchangeRequest {\n version: '3.0';\n action: FlowActionEnum;\n screen: string;\n flow_token: string;\n data?: Record<string, any> & { error_message?: string };\n}\n\n/**\n * WhatsApp Flow Endpoint - Data Exchange Response\n * The expected response structure for data exchange requests\n */\nexport interface FlowDataExchangeResponse {\n screen?: string;\n data?: Record<string, any | { error_message?: string }>;\n}\n\n/**\n * WhatsApp Flow Endpoint - Success Screen Response\n * The expected response structure for success screen requests\n */\nexport interface FlowSuccessScreenResponse {\n screen: 'SUCCESS';\n data: {\n extension_message_response?: {\n params?: {\n flow_token: string;\n [key: string]: string;\n };\n };\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Error Notification Request\n * Represents the structure of an error notification request\n */\nexport interface FlowErrorNotificationRequest {\n version: '3.0';\n action: Exclude<FlowActionEnum, FlowActionEnum.BACK>;\n screen: string;\n flow_token: string;\n data: {\n error: string;\n error_message: string;\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Error Notification Response\n * The expected response structure for error notification requests\n */\nexport interface FlowErrorNotificationResponse {\n acknowledged: boolean;\n}\n\n/**\n * WhatsApp Flow Endpoint - Comprehensive Request Object\n * A combined type that includes all possible fields from different request types\n * with all fields being optional for flexibility\n */\nexport interface FlowEndpointRequest {\n // Common fields\n version?: '3.0';\n action?: 'ping' | FlowActionEnum;\n\n screen?: string;\n flow_token?: string;\n\n data?: Record<string, any> & {\n error_key?: string;\n error_message?: string;\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Response\n * Union type for all possible response types from a Flow endpoint\n */\nexport type FlowEndpointResponse =\n | FlowHealthCheckResponse\n | FlowDataExchangeResponse\n | FlowErrorNotificationResponse\n | FlowSuccessScreenResponse;\n\nexport interface FlowClass {\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n listFlows(wabaId: string): Promise<FlowsListResponse>;\n\n /**\n * Create Flow\n *\n * @param wabaId - The WABA ID\n * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id\n * @returns Promise with the created flow ID\n */\n createFlow(\n wabaId: string,\n data: {\n name: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n clone_flow_id?: string;\n flow_json?: string;\n publish?: boolean;\n },\n ): Promise<CreateFlowResponse>;\n\n /**\n * Get Flow\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details\n */\n getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update\n * @returns Promise with the success status\n */\n updateFlowMetadata(\n flowId: string,\n data: {\n name?: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n application_id?: string;\n },\n ): Promise<ResponseSuccess>;\n\n /**\n * Delete Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n deleteFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * List Assets (Get Flow JSON URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n listAssets(flowId: string): Promise<FlowAssetsResponse>;\n\n /**\n * Update Flow JSON\n *\n * @param flowId - The flow ID\n * @param data - The asset data including asset_type, file, and name\n * @returns Promise with the success status and validation errors\n */\n updateFlowJson(\n flowId: string,\n data: {\n file: Blob | Uint8Array | object;\n name?: string;\n },\n ): Promise<UpdateFlowResponse>;\n\n /**\n * Validate Flow JSON by attempting an update without publishing.\n * This is a convenience method; the API doesn't have a dedicated validation endpoint.\n *\n * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).\n * @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.\n * @returns Promise indicating if the JSON is valid and includes validation errors if any.\n */\n validateFlowJson(flowId: string, flowJsonData: Blob | Uint8Array | object): Promise<ValidateFlowJsonResponse>;\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n publishFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n deprecateFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * Migrate Flows\n *\n * @param wabaId - The destination WABA ID\n * @param data - The migration data including source_waba_id and optional source_flow_names\n * @returns Promise with migration results\n */\n migrateFlows(\n wabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<FlowMigrationResponse>;\n}\n","// Docs: https://developers.facebook.com/documentation/business-messaging/whatsapp/whatsapp-business-accounts/\n\nimport type { Paging, ResponseSuccess } from '../../../types/request';\n\n/**\n * WhatsApp Business Account subscription configuration\n */\nexport type WabaSubscription = {\n whatsapp_business_api_data: {\n id: string;\n link: string;\n name: string;\n category: string;\n };\n override_callback_uri?: string;\n};\n\n/**\n * Parameters for updating WABA subscription\n */\nexport interface UpdateWabaSubscription {\n override_callback_uri: string;\n verify_token: string;\n}\n\n/**\n * Response containing all WABA subscriptions\n */\nexport interface WabaSubscriptions {\n data: Array<WabaSubscription>;\n}\n\n/**\n * WABA account review status enumeration\n */\nexport enum WabaAccountReviewStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\n/**\n * WABA health status for message sending capability\n */\nexport enum WabaHealthStatusCanSendMessage {\n Blocked = 'BLOCKED',\n Limited = 'LIMITED',\n Available = 'AVAILABLE',\n}\n\n/**\n * WABA account status enumeration\n */\nexport enum WabaAccountStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\n/**\n * Business verification status enumeration\n */\nexport enum WabaBusinessVerificationStatus {\n Verified = 'verified',\n PendingSubmission = 'pending_submission',\n Unverified = 'unverified',\n Rejected = 'rejected',\n}\n\n/**\n * WABA health status error details\n */\nexport interface WabaHealthStatusError {\n error_code?: number;\n error_description?: string;\n possible_solution?: string;\n}\n\n/**\n * WABA health status entity information\n */\nexport interface WabaHealthStatusEntity {\n entity_type?: string;\n id?: string;\n can_send_message?: string;\n errors?: WabaHealthStatusError[];\n}\n\n/**\n * Overall WABA health status\n */\nexport interface WabaHealthStatus {\n can_send_message?: WabaHealthStatusCanSendMessage;\n entities?: WabaHealthStatusEntity[];\n}\n\n/**\n * WhatsApp Business Account information\n */\nexport interface WabaAccount {\n account_review_status?: WabaAccountReviewStatus;\n id?: string;\n health_status?: WabaHealthStatus;\n status?: WabaAccountStatus;\n business_verification_status?: WabaBusinessVerificationStatus;\n message_template_namespace?: string;\n name?: string;\n ownership_type?: string;\n timezone_id?: string;\n primary_business_location?: Record<string, unknown> | string;\n currency?: string;\n country?: string;\n analytics?: Record<string, unknown>;\n is_enabled_for_insights?: boolean;\n is_shared_with_partners?: boolean;\n marketing_messages_lite_api_status?: string;\n marketing_messages_onboarding_status?: string;\n on_behalf_of_business_info?: Record<string, unknown>;\n primary_funding_id?: string;\n purchase_order_number?: string;\n whatsapp_business_manager_messaging_limit?: string;\n}\n\n/**\n * Available fields for WABA account queries\n */\nexport type WabaAccountFields =\n | 'id'\n | 'name'\n | 'timezone_id'\n | 'account_review_status'\n | 'auth_international_rate_eligibility'\n | 'business_verification_status'\n | 'country'\n | 'currency'\n | 'health_status'\n | 'status'\n | 'ownership_type'\n | 'message_template_namespace'\n | 'primary_business_location'\n | 'analytics'\n | 'is_enabled_for_insights'\n | 'is_shared_with_partners'\n | 'marketing_messages_lite_api_status'\n | 'marketing_messages_onboarding_status'\n | 'on_behalf_of_business_info'\n | 'primary_funding_id'\n | 'purchase_order_number'\n | 'whatsapp_business_manager_messaging_limit';\n\n/**\n * Parameter type for specifying which WABA account fields to retrieve\n */\nexport type WabaAccountFieldsParam = WabaAccountFields[];\n\nexport type WabaGraphObject = Record<string, unknown>;\n\nexport type WabaFieldsParam = string[] | string;\n\nexport type WabaListParams = {\n fields?: WabaFieldsParam;\n filtering?: WabaGraphObject[] | string;\n sort?: string;\n limit?: number;\n after?: string;\n before?: string;\n};\n\nexport type WabaListResponse<T = WabaGraphObject> = {\n data: T[];\n paging?: Paging;\n summary?: WabaGraphObject;\n};\n\nexport type UpdateWabaAccountRequest = {\n name?: string;\n timezone_id?: string;\n [key: string]: unknown;\n};\n\nexport type AssignedUsersListParams = WabaListParams & {\n business: string;\n};\n\nexport type AssignedUserRequest = {\n user: string;\n tasks: string[];\n};\n\nexport type RemoveAssignedUserRequest = {\n user: string;\n [key: string]: unknown;\n};\n\nexport type CreateOBOMobilityIntentRequest = {\n intent?: string;\n [key: string]: unknown;\n};\n\nexport type SetOBOMobilityIntentRequest = {\n [key: string]: unknown;\n};\n\nexport type CreateScheduleRequest = {\n name?: string;\n schedule_type?: string;\n [key: string]: unknown;\n};\n\nexport type UpdateWhatsAppBusinessProfileRequest = {\n [key: string]: unknown;\n};\n\n/**\n * Interface defining all WABA API methods\n */\nexport interface WABAClass {\n getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;\n updateWabaAccount(params: UpdateWabaAccountRequest): Promise<ResponseSuccess>;\n getWabaActivities(params?: WabaListParams): Promise<WabaListResponse>;\n getAllWabaSubscriptions(): Promise<WabaSubscriptions>;\n updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;\n unsubscribeFromWaba(): Promise<ResponseSuccess>;\n getAssignedUsers(params: AssignedUsersListParams, wabaId?: string): Promise<WabaListResponse>;\n addAssignedUser(params: AssignedUserRequest, wabaId?: string): Promise<ResponseSuccess>;\n removeAssignedUser(params: RemoveAssignedUserRequest, wabaId?: string): Promise<ResponseSuccess>;\n getInProgressOnBehalfRequests(params?: WabaListParams, wabaId?: string): Promise<WabaListResponse>;\n getOBOMobilityIntent(oboMobilityIntentId: string, fields?: WabaFieldsParam): Promise<WabaGraphObject>;\n createOBOMobilityIntent(params: CreateOBOMobilityIntentRequest, wabaId?: string): Promise<WabaGraphObject>;\n setOBOMobilityIntent(params: SetOBOMobilityIntentRequest, wabaId?: string): Promise<WabaGraphObject>;\n getWabaSchedules(params?: WabaListParams, wabaId?: string): Promise<WabaListResponse>;\n createWabaSchedule(params: CreateScheduleRequest, wabaId?: string): Promise<WabaGraphObject>;\n getWhatsAppBusinessBotDetails(botId: string, fields?: WabaFieldsParam): Promise<WabaGraphObject>;\n getWhatsAppBusinessProfileDetails(profileId: string, fields?: WabaFieldsParam): Promise<WabaGraphObject>;\n updateWhatsAppBusinessProfile(\n profileId: string,\n params: UpdateWhatsAppBusinessProfileRequest,\n ): Promise<ResponseSuccess>;\n}\n","/**\n * As-const alternatives to enums.\n *\n * Every enum in enums.ts gets a matching `as const` object and a union type here.\n * Use whichever style you prefer:\n * - Enum: CategoryEnum.Marketing\n * - Const: Category.Marketing (value: 'MARKETING')\n * - Type: CategoryType (union: 'AUTHENTICATION' | 'MARKETING' | 'UTILITY')\n */\n\n// ---- Category ----\nexport const Category = {\n Authentication: 'AUTHENTICATION',\n Marketing: 'MARKETING',\n Utility: 'UTILITY',\n} as const;\nexport type CategoryType = (typeof Category)[keyof typeof Category];\n\n// ---- MessageCategory (Direct Send) ----\nexport const MessageCategory = {\n Authentication: 'authentication',\n Service: 'service',\n Utility: 'utility',\n} as const;\nexport type MessageCategoryType = (typeof MessageCategory)[keyof typeof MessageCategory];\n\n// ---- TemplateStatus ----\nexport const TemplateStatus = {\n Approved: 'APPROVED',\n Pending: 'PENDING',\n Rejected: 'REJECTED',\n} as const;\nexport type TemplateStatusType = (typeof TemplateStatus)[keyof typeof TemplateStatus];\n\n// ---- HttpMethods ----\nexport const HttpMethods = {\n Get: 'GET',\n Post: 'POST',\n Put: 'PUT',\n Delete: 'DELETE',\n} as const;\nexport type HttpMethodsType = (typeof HttpMethods)[keyof typeof HttpMethods];\n\n// ---- MessageTypes ----\nexport const MessageTypes = {\n Audio: 'audio',\n Contacts: 'contacts',\n Document: 'document',\n Image: 'image',\n Interactive: 'interactive',\n Location: 'location',\n Reaction: 'reaction',\n Sticker: 'sticker',\n Template: 'template',\n Text: 'text',\n Video: 'video',\n Button: 'button',\n Order: 'order',\n System: 'system',\n Unsupported: 'unsupported',\n Unknown: 'unknown',\n /** @deprecated Use WebhookProcessor.onStatus() instead */\n Statuses: 'statuses',\n All: '*',\n} as const;\nexport type MessageTypesType = (typeof MessageTypes)[keyof typeof MessageTypes];\n\n// ---- ParametersTypes ----\nexport const ParametersTypes = {\n Action: 'ACTION',\n CouponCode: 'COUPON_CODE',\n Currency: 'CURRENCY',\n DateTime: 'DATE_TIME',\n Document: 'DOCUMENT',\n ExpirationTimeMs: 'EXPIRATION_TIME_MS',\n Image: 'IMAGE',\n LimitedTimeOffer: 'LIMITED_TIME_OFFER',\n Location: 'LOCATION',\n OrderStatus: 'ORDER_STATUS',\n Payload: 'PAYLOAD',\n Product: 'PRODUCT',\n Text: 'TEXT',\n TtlMinutes: 'TTL_MINUTES',\n Video: 'VIDEO',\n WebviewInteraction: 'WEBVIEW_INTERACTION',\n WebviewPresentation: 'WEBVIEW_PRESENTATION',\n} as const;\nexport type ParametersTypesType = (typeof ParametersTypes)[keyof typeof ParametersTypes];\n\n// ---- InteractiveTypes ----\nexport const InteractiveTypes = {\n Button: 'button',\n List: 'list',\n Product: 'product',\n ProductList: 'product_list',\n CtaUrl: 'cta_url',\n Carousel: 'carousel',\n LocationRequest: 'location_request_message',\n AddressMessage: 'address_message',\n Flow: 'flow',\n VoiceCall: 'voice_call',\n} as const;\nexport type InteractiveTypesType = (typeof InteractiveTypes)[keyof typeof InteractiveTypes];\n\n// ---- ButtonPosition ----\nexport const ButtonPosition = {\n First: 1,\n Second: 2,\n Third: 3,\n Fourth: 4,\n Fifth: 5,\n} as const;\nexport type ButtonPositionType = (typeof ButtonPosition)[keyof typeof ButtonPosition];\n\n// ---- SubType ----\nexport const SubType = {\n Catalog: 'CATALOG',\n CopyCode: 'COPY_CODE',\n Flow: 'FLOW',\n Mpm: 'MPM',\n OrderDetails: 'ORDER_DETAILS',\n QuickReply: 'QUICK_REPLY',\n Reminder: 'REMINDER',\n Url: 'URL',\n VoiceCall: 'VOICE_CALL',\n} as const;\nexport type SubTypeType = (typeof SubType)[keyof typeof SubType];\n\n// ---- ComponentTypes (template) ----\nexport const ComponentType = {\n Header: 'HEADER',\n Body: 'BODY',\n Button: 'BUTTON',\n Footer: 'FOOTER',\n} as const;\nexport type ComponentTypeType = (typeof ComponentType)[keyof typeof ComponentType];\n\n// ---- ConversationTypes ----\nexport const ConversationTypes = {\n BusinessInitiated: 'business_initiated',\n CustomerInitiated: 'customer_initiated',\n ReferralConversion: 'referral_conversion',\n} as const;\nexport type ConversationTypesType = (typeof ConversationTypes)[keyof typeof ConversationTypes];\n\n// ---- Status ----\nexport const Status = {\n Delivered: 'delivered',\n Read: 'read',\n Sent: 'sent',\n} as const;\nexport type StatusType = (typeof Status)[keyof typeof Status];\n\n// ---- VideoMediaTypes ----\nexport const VideoMediaTypes = {\n Mp4: 'video/mp4',\n Threegp: 'video/3gp',\n} as const;\nexport type VideoMediaTypesType = (typeof VideoMediaTypes)[keyof typeof VideoMediaTypes];\n\n// ---- StickerMediaTypes ----\nexport const StickerMediaTypes = {\n Webp: 'image/webp',\n} as const;\nexport type StickerMediaTypesType = (typeof StickerMediaTypes)[keyof typeof StickerMediaTypes];\n\n// ---- ImageMediaTypes ----\nexport const ImageMediaTypes = {\n Jpeg: 'image/jpeg',\n Png: 'image/png',\n} as const;\nexport type ImageMediaTypesType = (typeof ImageMediaTypes)[keyof typeof ImageMediaTypes];\n\n// ---- DocumentMediaTypes ----\nexport const DocumentMediaTypes = {\n Text: 'text/plain',\n Pdf: 'application/pdf',\n Ppt: 'application/vnd.ms-powerpoint',\n Word: 'application/msword',\n Excel: 'application/vnd.ms-excel',\n OpenDoc: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n OpenPres: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n OpenSheet: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n} as const;\nexport type DocumentMediaTypesType = (typeof DocumentMediaTypes)[keyof typeof DocumentMediaTypes];\n\n// ---- AudioMediaTypes ----\nexport const AudioMediaTypes = {\n Aac: 'audio/aac',\n Mp4: 'audio/mp4',\n Mpeg: 'audio/mpeg',\n Amr: 'audio/amr',\n Ogg: 'audio/ogg',\n} as const;\nexport type AudioMediaTypesType = (typeof AudioMediaTypes)[keyof typeof AudioMediaTypes];\n\n// ---- WebhookTypes ----\nexport const WebhookTypes = {\n Audio: 'audio',\n Button: 'button',\n Document: 'document',\n Text: 'text',\n Image: 'image',\n Interactive: 'interactive',\n Order: 'order',\n Sticker: 'sticker',\n System: 'system',\n Unknown: 'unknown',\n Video: 'video',\n} as const;\nexport type WebhookTypesType = (typeof WebhookTypes)[keyof typeof WebhookTypes];\n\n// ---- SystemChangeTypes ----\nexport const SystemChangeTypes = {\n /** @deprecated Meta renamed this to `user_changed_number`. Use `UserChangedNumber`. */\n CustomerChangedNumber: 'customer_changed_number',\n /** @deprecated Meta renamed this to `user_identity_changed`. Use `UserIdentityChanged`. */\n CustomerIdentityChanged: 'customer_identity_changed',\n UserChangedNumber: 'user_changed_number',\n UserIdentityChanged: 'user_identity_changed',\n /** The user's business-scoped user ID (BSUID) changed. */\n UserChangedUserId: 'user_changed_user_id',\n} as const;\nexport type SystemChangeTypesType = (typeof SystemChangeTypes)[keyof typeof SystemChangeTypes];\n\n// ---- ReferralSourceTypes ----\nexport const ReferralSourceTypes = {\n Ad: 'ad',\n Post: 'post',\n} as const;\nexport type ReferralSourceTypesType = (typeof ReferralSourceTypes)[keyof typeof ReferralSourceTypes];\n\n// ---- RequestCodeMethods ----\nexport const RequestCodeMethods = {\n Sms: 'SMS',\n Voice: 'VOICE',\n} as const;\nexport type RequestCodeMethodsType = (typeof RequestCodeMethods)[keyof typeof RequestCodeMethods];\n\n// ---- Languages ----\nexport const Languages = {\n Afrikaans: 'af',\n Albanian: 'sq',\n Arabic: 'ar',\n Azerbaijani: 'az',\n Bengali: 'bn',\n Bulgarian: 'bg',\n Catalan: 'ca',\n Chinese_CHN: 'zh_CN',\n Chinese_HKG: 'zh_HK',\n Chinese_TAI: 'zh_TW',\n Croatian: 'hr',\n Czech: 'cs',\n Danish: 'da',\n Dutch: 'nl',\n English: 'en',\n English_UK: 'en_GB',\n English_US: 'en_US',\n Estonian: 'et',\n Filipino: 'fil',\n Finnish: 'fi',\n French: 'fr',\n Georgian: 'ka',\n German: 'de',\n Greek: 'el',\n Gujarati: 'gu',\n Hausa: 'ha',\n Hebrew: 'he',\n Hindi: 'hi',\n Hungarian: 'hu',\n Indonesian: 'id',\n Irish: 'ga',\n Italian: 'it',\n Japanese: 'ja',\n Kannada: 'kn',\n Kazakh: 'kk',\n Kinyarwanda: 'rw_RW',\n Korean: 'ko',\n Kyrgyz_Kyrgyzstan: 'ky_KG',\n Lao: 'lo',\n Latvian: 'lv',\n Lithuanian: 'lt',\n Macedonian: 'mk',\n Malay: 'ms',\n Malayalam: 'ml',\n Marathi: 'mr',\n Norwegian: 'nb',\n Persian: 'fa',\n Polish: 'pl',\n Portuguese_BR: 'pt_BR',\n Portuguese_POR: 'pt_PT',\n Punjabi: 'pa',\n Romanian: 'ro',\n Russian: 'ru',\n Serbian: 'sr',\n Slovak: 'sk',\n Slovenian: 'sl',\n Spanish: 'es',\n Spanish_ARG: 'es_AR',\n Spanish_SPA: 'es_ES',\n Spanish_MEX: 'es_MX',\n Swahili: 'sw',\n Swedish: 'sv',\n Tamil: 'ta',\n Telugu: 'te',\n Thai: 'th',\n Turkish: 'tr',\n Ukrainian: 'uk',\n Urdu: 'ur',\n Uzbek: 'uz',\n Vietnamese: 'vi',\n Zulu: 'zu',\n} as const;\nexport type LanguagesType = (typeof Languages)[keyof typeof Languages];\n\n// ---- DataLocalizationRegion ----\nexport const DataLocalizationRegion = {\n AU: 'AU',\n ID: 'ID',\n IN: 'IN',\n JP: 'JP',\n SG: 'SG',\n KR: 'KR',\n DE: 'DE',\n CH: 'CH',\n GB: 'GB',\n BR: 'BR',\n BH: 'BH',\n ZA: 'ZA',\n AE: 'AE',\n CA: 'CA',\n} as const;\nexport type DataLocalizationRegionType = (typeof DataLocalizationRegion)[keyof typeof DataLocalizationRegion];\n"],"mappings":"yoBAQA,IAAY,EAAL,SAAA,EAAA,OACH,GAAA,MAAA,QACA,EAAA,UAAA,YACA,EAAA,UAAA,YACA,EAAA,QAAA,UACA,EAAA,WAAA,cACJ,EAAA,CAAA,CAAA,EAKY,EAAL,SAAA,EAAA,OACH,GAAA,OAAA,UACA,EAAA,OAAA,UACA,EAAA,mBAAA,sBACA,EAAA,eAAA,kBACA,EAAA,UAAA,aACA,EAAA,gBAAA,mBACA,EAAA,OAAA,SACA,EAAA,MAAA,SACJ,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OACH,GAAA,KAAA,OACA,EAAA,KAAA,OACA,EAAA,cAAA,iBACJ,EAAA,CAAA,CAAA,EAMY,EAAL,SAAA,EAAA,OAEH,GAAA,KAAA,OAEA,EAAA,OAAA,gBAEA,EAAA,MAAA,QAEA,EAAA,IAAA,KACJ,EAAA,CAAA,CAAA,ECdY,EAAL,S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ACZ,SAAU,KACV,SAAU,MACV,QAAS,KACT,OAAQ,KACR,SAAU,KACV,OAAQ,KACR,MAAO,KACP,SAAU,KACV,MAAO,KACP,OAAQ,KACR,MAAO,KACP,UAAW,KACX,WAAY,KACZ,MAAO,KACP,QAAS,KACT,SAAU,KACV,QAAS,KACT,OAAQ,KACR,YAAa,QACb,OAAQ,KACR,kBAAmB,QACnB,IAAK,KACL,QAAS,KACT,WAAY,KACZ,WAAY,KACZ,MAAO,KACP,UAAW,KACX,QAAS,KACT,UAAW,KACX,QAAS,KACT,OAAQ,KACR,cAAe,QACf,eAAgB,QAChB,QAAS,KACT,SAAU,KACV,QAAS,KACT,QAAS,KACT,OAAQ,KACR,UAAW,KACX,QAAS,KACT,YAAa,QACb,YAAa,QACb,YAAa,QACb,QAAS,KACT,QAAS,KACT,MAAO,KACP,OAAQ,KACR,KAAM,KACN,QAAS,KACT,UAAW,KACX,KAAM,KACN,MAAO,KACP,WAAY,KACZ,KAAM,IACV,EAIa,GAAyB,CAClC,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,IACR"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/api/flow/types/common.ts","../../src/api/waba/types/common.ts","../../src/types/constants.ts"],"sourcesContent":["// Docs: https://developers.facebook.com/documentation/business-messaging/whatsapp/flows/\n\nimport type { IncomingHttpHeaders, IncomingMessage } from 'node:http';\nimport type { ResponseSuccess } from '../../../types';\n\n/**\n * Enum for Flow Status\n */\nexport enum FlowStatusEnum {\n Draft = 'DRAFT',\n Published = 'PUBLISHED',\n Throttled = 'THROTTLED',\n Blocked = 'BLOCKED',\n Deprecated = 'DEPRECATED',\n}\n\n/**\n * Enum for Flow Categories\n */\nexport enum FlowCategoryEnum {\n SignUp = 'SIGN_UP',\n SignIn = 'SIGN_IN',\n AppointmentBooking = 'APPOINTMENT_BOOKING',\n LeadGeneration = 'LEAD_GENERATION',\n ContactUs = 'CONTACT_US',\n CustomerSupport = 'CUSTOMER_SUPPORT',\n Survey = 'SURVEY',\n Other = 'OTHER',\n}\n\nexport enum FlowActionEnum {\n INIT = 'INIT',\n BACK = 'BACK',\n DATA_EXCHANGE = 'data_exchange',\n}\n\n/**\n * Enum for Flow Types in webhook handlers\n * Used to register handlers for specific flow events\n */\nexport enum FlowTypeEnum {\n /** Health check/ping requests */\n Ping = 'ping',\n /** Data exchange requests */\n Change = 'data_exchange',\n /** Error notification requests */\n Error = 'error',\n /** Match all flow action types */\n All = '*',\n}\n\nexport type FlowType = (typeof FlowTypeEnum)[keyof typeof FlowTypeEnum];\n\n/**\n * Flow Validation Error Pointer\n */\nexport interface FlowValidationErrorPointer {\n line_start: number;\n line_end: number;\n column_start: number;\n column_end: number;\n path: string;\n}\n\n/**\n * Flow Validation Error\n */\nexport interface FlowValidationError {\n error: string;\n error_type: string;\n message: string;\n line_start: number;\n line_end: number;\n column_start: number;\n column_end: number;\n pointers: FlowValidationErrorPointer[];\n}\n\n/**\n * Flow Item\n */\nexport interface Flow {\n id: string;\n name: string;\n status: FlowStatusEnum;\n categories: FlowCategoryEnum[];\n validation_errors: FlowValidationError[];\n}\n\n/**\n * Pagination Cursors\n */\nexport interface PaginationCursors {\n before: string;\n after: string;\n}\n\n/**\n * Pagination Object\n */\nexport interface Pagination {\n cursors: PaginationCursors;\n}\n\n/**\n * Flows List Response\n */\nexport interface FlowsListResponse {\n data: Flow[];\n paging: Pagination;\n}\n\n/**\n * Flow Asset\n */\nexport interface FlowAsset {\n name: string;\n asset_type: string;\n download_url: string;\n}\n\n/**\n * Flow Assets Response\n */\nexport interface FlowAssetsResponse {\n data: FlowAsset[];\n paging: Pagination;\n}\n\n/**\n * Flow Preview\n */\nexport interface FlowPreview {\n preview_url: string;\n expires_at: string;\n}\n\n/**\n * Flow Preview Response\n */\nexport interface FlowPreviewResponse {\n preview: FlowPreview;\n id: string;\n}\n\n/**\n * Flow Migration Result\n */\nexport interface FlowMigrationResult {\n source_name: string;\n source_id: string;\n migrated_id: string;\n}\n\n/**\n * Flow Migration Failure\n */\nexport interface FlowMigrationFailure {\n source_name: string;\n error_code: string;\n error_message: string;\n}\n\n/**\n * Create Flow Response\n */\nexport interface CreateFlowResponse {\n id: string;\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * Update Flow Response\n */\nexport interface UpdateFlowResponse {\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * Flow Migration Response\n */\nexport interface FlowMigrationResponse {\n migrated_flows: FlowMigrationResult[];\n failed_flows: FlowMigrationFailure[];\n}\n\n/**\n * Validate Flow JSON Response\n */\nexport interface ValidateFlowJsonResponse {\n valid: boolean;\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * WhatsApp Flow Endpoint - Encrypted Request Payload\n * Represents the raw encrypted data received from WhatsApp\n */\nexport interface FlowEncryptedRequestPayload {\n encrypted_aes_key: string;\n encrypted_flow_data: string;\n initial_vector: string;\n}\n\n/**\n * WhatsApp Flow Endpoint - Decrypted Request Response\n * Represents the successfully decrypted data and encryption keys\n */\nexport interface FlowDecryptedRequestResponse {\n decryptedBody: any;\n aesKeyBuffer: Buffer;\n initialVectorBuffer: Buffer;\n}\n\n/**\n * WhatsApp Flow Endpoint - HTTP Request with Body\n * Represents an HTTP request with the encrypted payload\n */\nexport interface FlowHttpRequest extends IncomingMessage {\n body: FlowEncryptedRequestPayload;\n headers: IncomingHttpHeaders;\n}\n\n/**\n * WhatsApp Flow Endpoint - Health Check Request\n * Represents the structure of a health check request\n */\nexport interface FlowHealthCheckRequest {\n action: 'ping';\n version: '3.0';\n}\n\n/**\n * WhatsApp Flow Endpoint - Health Check Response\n * The expected response structure for health check requests\n */\nexport interface FlowHealthCheckResponse {\n data: {\n status: 'active';\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Data Exchange Request\n * Represents the structure of a data exchange request\n */\nexport interface FlowDataExchangeRequest {\n version: '3.0';\n action: FlowActionEnum;\n screen: string;\n flow_token: string;\n data?: Record<string, any> & { error_message?: string };\n}\n\n/**\n * WhatsApp Flow Endpoint - Data Exchange Response\n * The expected response structure for data exchange requests\n */\nexport interface FlowDataExchangeResponse {\n screen?: string;\n data?: Record<string, any | { error_message?: string }>;\n}\n\n/**\n * WhatsApp Flow Endpoint - Success Screen Response\n * The expected response structure for success screen requests\n */\nexport interface FlowSuccessScreenResponse {\n screen: 'SUCCESS';\n data: {\n extension_message_response?: {\n params?: {\n flow_token: string;\n [key: string]: string;\n };\n };\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Error Notification Request\n * Represents the structure of an error notification request\n */\nexport interface FlowErrorNotificationRequest {\n version: '3.0';\n action: Exclude<FlowActionEnum, FlowActionEnum.BACK>;\n screen: string;\n flow_token: string;\n data: {\n error: string;\n error_message: string;\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Error Notification Response\n * The expected response structure for error notification requests\n */\nexport interface FlowErrorNotificationResponse {\n acknowledged: boolean;\n}\n\n/**\n * WhatsApp Flow Endpoint - Comprehensive Request Object\n * A combined type that includes all possible fields from different request types\n * with all fields being optional for flexibility\n */\nexport interface FlowEndpointRequest {\n // Common fields\n version?: '3.0';\n action?: 'ping' | FlowActionEnum;\n\n screen?: string;\n flow_token?: string;\n\n data?: Record<string, any> & {\n error_key?: string;\n error_message?: string;\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Response\n * Union type for all possible response types from a Flow endpoint\n */\nexport type FlowEndpointResponse =\n | FlowHealthCheckResponse\n | FlowDataExchangeResponse\n | FlowErrorNotificationResponse\n | FlowSuccessScreenResponse;\n\nexport interface FlowClass {\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n listFlows(wabaId: string): Promise<FlowsListResponse>;\n\n /**\n * Create Flow\n *\n * @param wabaId - The WABA ID\n * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id\n * @returns Promise with the created flow ID\n */\n createFlow(\n wabaId: string,\n data: {\n name: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n clone_flow_id?: string;\n flow_json?: string;\n publish?: boolean;\n },\n ): Promise<CreateFlowResponse>;\n\n /**\n * Get Flow\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details\n */\n getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update\n * @returns Promise with the success status\n */\n updateFlowMetadata(\n flowId: string,\n data: {\n name?: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n application_id?: string;\n },\n ): Promise<ResponseSuccess>;\n\n /**\n * Delete Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n deleteFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * List Assets (Get Flow JSON URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n listAssets(flowId: string): Promise<FlowAssetsResponse>;\n\n /**\n * Update Flow JSON\n *\n * @param flowId - The flow ID\n * @param data - The asset data including asset_type, file, and name\n * @returns Promise with the success status and validation errors\n */\n updateFlowJson(\n flowId: string,\n data: {\n file: Blob | Uint8Array | object;\n name?: string;\n },\n ): Promise<UpdateFlowResponse>;\n\n /**\n * Validate Flow JSON by attempting an update without publishing.\n * This is a convenience method; the API doesn't have a dedicated validation endpoint.\n *\n * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).\n * @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.\n * @returns Promise indicating if the JSON is valid and includes validation errors if any.\n */\n validateFlowJson(flowId: string, flowJsonData: Blob | Uint8Array | object): Promise<ValidateFlowJsonResponse>;\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n publishFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n deprecateFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * Migrate Flows\n *\n * @param wabaId - The destination WABA ID\n * @param data - The migration data including source_waba_id and optional source_flow_names\n * @returns Promise with migration results\n */\n migrateFlows(\n wabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<FlowMigrationResponse>;\n}\n","// Docs: https://developers.facebook.com/documentation/business-messaging/whatsapp/whatsapp-business-accounts/\n\nimport type { Paging, ResponseSuccess } from '../../../types/request';\n\n/**\n * WhatsApp Business Account subscription configuration\n */\nexport type WabaSubscription = {\n whatsapp_business_api_data: {\n id: string;\n link: string;\n name: string;\n category: string;\n };\n override_callback_uri?: string;\n};\n\n/**\n * Parameters for updating WABA subscription\n */\nexport interface UpdateWabaSubscription {\n override_callback_uri: string;\n verify_token: string;\n}\n\n/**\n * Response containing all WABA subscriptions\n */\nexport interface WabaSubscriptions {\n data: Array<WabaSubscription>;\n}\n\n/**\n * WABA account review status enumeration\n */\nexport enum WabaAccountReviewStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\n/**\n * WABA health status for message sending capability\n */\nexport enum WabaHealthStatusCanSendMessage {\n Blocked = 'BLOCKED',\n Limited = 'LIMITED',\n Available = 'AVAILABLE',\n}\n\n/**\n * WABA account status enumeration\n */\nexport enum WabaAccountStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\n/**\n * Business verification status enumeration\n */\nexport enum WabaBusinessVerificationStatus {\n Verified = 'verified',\n PendingSubmission = 'pending_submission',\n Unverified = 'unverified',\n Rejected = 'rejected',\n}\n\n/**\n * Service pricing policy coverage for a WABA (added October 30, 2026).\n * `PAID_EXEMPT` means the account is covered by the service pricing policy\n * for eligible governments and non-profits.\n */\nexport type WabaServicePricingPolicy = 'PAID_EXEMPT' | 'REGULAR' | 'UNKNOWN';\n\n/**\n * WABA health status error details\n */\nexport interface WabaHealthStatusError {\n error_code?: number;\n error_description?: string;\n possible_solution?: string;\n}\n\n/**\n * WABA health status entity information\n */\nexport interface WabaHealthStatusEntity {\n entity_type?: string;\n id?: string;\n can_send_message?: string;\n errors?: WabaHealthStatusError[];\n}\n\n/**\n * Overall WABA health status\n */\nexport interface WabaHealthStatus {\n can_send_message?: WabaHealthStatusCanSendMessage;\n entities?: WabaHealthStatusEntity[];\n}\n\n/**\n * WhatsApp Business Account information\n */\nexport interface WabaAccount {\n account_review_status?: WabaAccountReviewStatus;\n id?: string;\n health_status?: WabaHealthStatus;\n status?: WabaAccountStatus;\n business_verification_status?: WabaBusinessVerificationStatus;\n message_template_namespace?: string;\n name?: string;\n ownership_type?: string;\n timezone_id?: string;\n primary_business_location?: Record<string, unknown> | string;\n currency?: string;\n country?: string;\n analytics?: Record<string, unknown>;\n is_enabled_for_insights?: boolean;\n is_shared_with_partners?: boolean;\n marketing_messages_lite_api_status?: string;\n marketing_messages_onboarding_status?: string;\n on_behalf_of_business_info?: Record<string, unknown>;\n primary_funding_id?: string;\n purchase_order_number?: string;\n whatsapp_business_manager_messaging_limit?: string;\n service_pricing_policy?: WabaServicePricingPolicy;\n}\n\n/**\n * Available fields for WABA account queries\n */\nexport type WabaAccountFields =\n | 'id'\n | 'name'\n | 'timezone_id'\n | 'account_review_status'\n | 'auth_international_rate_eligibility'\n | 'business_verification_status'\n | 'country'\n | 'currency'\n | 'health_status'\n | 'status'\n | 'ownership_type'\n | 'message_template_namespace'\n | 'primary_business_location'\n | 'analytics'\n | 'is_enabled_for_insights'\n | 'is_shared_with_partners'\n | 'marketing_messages_lite_api_status'\n | 'marketing_messages_onboarding_status'\n | 'on_behalf_of_business_info'\n | 'primary_funding_id'\n | 'purchase_order_number'\n | 'whatsapp_business_manager_messaging_limit'\n | 'service_pricing_policy';\n\n/**\n * Parameter type for specifying which WABA account fields to retrieve\n */\nexport type WabaAccountFieldsParam = WabaAccountFields[];\n\nexport type WabaGraphObject = Record<string, unknown>;\n\nexport type WabaFieldsParam = string[] | string;\n\nexport type WabaListParams = {\n fields?: WabaFieldsParam;\n filtering?: WabaGraphObject[] | string;\n sort?: string;\n limit?: number;\n after?: string;\n before?: string;\n};\n\nexport type WabaListResponse<T = WabaGraphObject> = {\n data: T[];\n paging?: Paging;\n summary?: WabaGraphObject;\n};\n\nexport type UpdateWabaAccountRequest = {\n name?: string;\n timezone_id?: string;\n [key: string]: unknown;\n};\n\nexport type AssignedUsersListParams = WabaListParams & {\n business: string;\n};\n\nexport type AssignedUserRequest = {\n user: string;\n tasks: string[];\n};\n\nexport type RemoveAssignedUserRequest = {\n user: string;\n [key: string]: unknown;\n};\n\nexport type CreateOBOMobilityIntentRequest = {\n intent?: string;\n [key: string]: unknown;\n};\n\nexport type SetOBOMobilityIntentRequest = {\n [key: string]: unknown;\n};\n\nexport type CreateScheduleRequest = {\n name?: string;\n schedule_type?: string;\n [key: string]: unknown;\n};\n\nexport type UpdateWhatsAppBusinessProfileRequest = {\n [key: string]: unknown;\n};\n\n/**\n * Interface defining all WABA API methods\n */\nexport interface WABAClass {\n getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;\n updateWabaAccount(params: UpdateWabaAccountRequest): Promise<ResponseSuccess>;\n getWabaActivities(params?: WabaListParams): Promise<WabaListResponse>;\n getAllWabaSubscriptions(): Promise<WabaSubscriptions>;\n updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;\n unsubscribeFromWaba(): Promise<ResponseSuccess>;\n getAssignedUsers(params: AssignedUsersListParams, wabaId?: string): Promise<WabaListResponse>;\n addAssignedUser(params: AssignedUserRequest, wabaId?: string): Promise<ResponseSuccess>;\n removeAssignedUser(params: RemoveAssignedUserRequest, wabaId?: string): Promise<ResponseSuccess>;\n getInProgressOnBehalfRequests(params?: WabaListParams, wabaId?: string): Promise<WabaListResponse>;\n getOBOMobilityIntent(oboMobilityIntentId: string, fields?: WabaFieldsParam): Promise<WabaGraphObject>;\n createOBOMobilityIntent(params: CreateOBOMobilityIntentRequest, wabaId?: string): Promise<WabaGraphObject>;\n setOBOMobilityIntent(params: SetOBOMobilityIntentRequest, wabaId?: string): Promise<WabaGraphObject>;\n getWabaSchedules(params?: WabaListParams, wabaId?: string): Promise<WabaListResponse>;\n createWabaSchedule(params: CreateScheduleRequest, wabaId?: string): Promise<WabaGraphObject>;\n getWhatsAppBusinessBotDetails(botId: string, fields?: WabaFieldsParam): Promise<WabaGraphObject>;\n getWhatsAppBusinessProfileDetails(profileId: string, fields?: WabaFieldsParam): Promise<WabaGraphObject>;\n updateWhatsAppBusinessProfile(\n profileId: string,\n params: UpdateWhatsAppBusinessProfileRequest,\n ): Promise<ResponseSuccess>;\n}\n","/**\n * As-const alternatives to enums.\n *\n * Every enum in enums.ts gets a matching `as const` object and a union type here.\n * Use whichever style you prefer:\n * - Enum: CategoryEnum.Marketing\n * - Const: Category.Marketing (value: 'MARKETING')\n * - Type: CategoryType (union: 'AUTHENTICATION' | 'MARKETING' | 'UTILITY')\n */\n\n// ---- Category ----\nexport const Category = {\n Authentication: 'AUTHENTICATION',\n Marketing: 'MARKETING',\n Utility: 'UTILITY',\n} as const;\nexport type CategoryType = (typeof Category)[keyof typeof Category];\n\n// ---- MessageCategory (Direct Send) ----\nexport const MessageCategory = {\n Authentication: 'authentication',\n Service: 'service',\n Utility: 'utility',\n} as const;\nexport type MessageCategoryType = (typeof MessageCategory)[keyof typeof MessageCategory];\n\n// ---- TemplateStatus ----\nexport const TemplateStatus = {\n Approved: 'APPROVED',\n Pending: 'PENDING',\n Rejected: 'REJECTED',\n} as const;\nexport type TemplateStatusType = (typeof TemplateStatus)[keyof typeof TemplateStatus];\n\n// ---- HttpMethods ----\nexport const HttpMethods = {\n Get: 'GET',\n Post: 'POST',\n Put: 'PUT',\n Delete: 'DELETE',\n} as const;\nexport type HttpMethodsType = (typeof HttpMethods)[keyof typeof HttpMethods];\n\n// ---- MessageTypes ----\nexport const MessageTypes = {\n Audio: 'audio',\n Contacts: 'contacts',\n Document: 'document',\n Image: 'image',\n Interactive: 'interactive',\n Location: 'location',\n Reaction: 'reaction',\n Sticker: 'sticker',\n Template: 'template',\n Text: 'text',\n Video: 'video',\n Button: 'button',\n Order: 'order',\n System: 'system',\n Unsupported: 'unsupported',\n Unknown: 'unknown',\n /** @deprecated Use WebhookProcessor.onStatus() instead */\n Statuses: 'statuses',\n All: '*',\n} as const;\nexport type MessageTypesType = (typeof MessageTypes)[keyof typeof MessageTypes];\n\n// ---- ParametersTypes ----\nexport const ParametersTypes = {\n Action: 'ACTION',\n CouponCode: 'COUPON_CODE',\n Currency: 'CURRENCY',\n DateTime: 'DATE_TIME',\n Document: 'DOCUMENT',\n ExpirationTimeMs: 'EXPIRATION_TIME_MS',\n Image: 'IMAGE',\n LimitedTimeOffer: 'LIMITED_TIME_OFFER',\n Location: 'LOCATION',\n OrderStatus: 'ORDER_STATUS',\n Payload: 'PAYLOAD',\n Product: 'PRODUCT',\n Text: 'TEXT',\n TtlMinutes: 'TTL_MINUTES',\n Video: 'VIDEO',\n WebviewInteraction: 'WEBVIEW_INTERACTION',\n WebviewPresentation: 'WEBVIEW_PRESENTATION',\n} as const;\nexport type ParametersTypesType = (typeof ParametersTypes)[keyof typeof ParametersTypes];\n\n// ---- InteractiveTypes ----\nexport const InteractiveTypes = {\n Button: 'button',\n List: 'list',\n Product: 'product',\n ProductList: 'product_list',\n CtaUrl: 'cta_url',\n Carousel: 'carousel',\n LocationRequest: 'location_request_message',\n AddressMessage: 'address_message',\n Flow: 'flow',\n VoiceCall: 'voice_call',\n} as const;\nexport type InteractiveTypesType = (typeof InteractiveTypes)[keyof typeof InteractiveTypes];\n\n// ---- ButtonPosition ----\nexport const ButtonPosition = {\n First: 1,\n Second: 2,\n Third: 3,\n Fourth: 4,\n Fifth: 5,\n} as const;\nexport type ButtonPositionType = (typeof ButtonPosition)[keyof typeof ButtonPosition];\n\n// ---- SubType ----\nexport const SubType = {\n Catalog: 'CATALOG',\n CopyCode: 'COPY_CODE',\n Flow: 'FLOW',\n Mpm: 'MPM',\n OrderDetails: 'ORDER_DETAILS',\n QuickReply: 'QUICK_REPLY',\n Reminder: 'REMINDER',\n Url: 'URL',\n VoiceCall: 'VOICE_CALL',\n} as const;\nexport type SubTypeType = (typeof SubType)[keyof typeof SubType];\n\n// ---- ComponentTypes (template) ----\nexport const ComponentType = {\n Header: 'HEADER',\n Body: 'BODY',\n Button: 'BUTTON',\n Footer: 'FOOTER',\n} as const;\nexport type ComponentTypeType = (typeof ComponentType)[keyof typeof ComponentType];\n\n// ---- ConversationTypes ----\nexport const ConversationTypes = {\n BusinessInitiated: 'business_initiated',\n CustomerInitiated: 'customer_initiated',\n ReferralConversion: 'referral_conversion',\n} as const;\nexport type ConversationTypesType = (typeof ConversationTypes)[keyof typeof ConversationTypes];\n\n// ---- Status ----\nexport const Status = {\n Delivered: 'delivered',\n Read: 'read',\n Sent: 'sent',\n} as const;\nexport type StatusType = (typeof Status)[keyof typeof Status];\n\n// ---- VideoMediaTypes ----\nexport const VideoMediaTypes = {\n Mp4: 'video/mp4',\n Threegp: 'video/3gp',\n} as const;\nexport type VideoMediaTypesType = (typeof VideoMediaTypes)[keyof typeof VideoMediaTypes];\n\n// ---- StickerMediaTypes ----\nexport const StickerMediaTypes = {\n Webp: 'image/webp',\n} as const;\nexport type StickerMediaTypesType = (typeof StickerMediaTypes)[keyof typeof StickerMediaTypes];\n\n// ---- ImageMediaTypes ----\nexport const ImageMediaTypes = {\n Jpeg: 'image/jpeg',\n Png: 'image/png',\n} as const;\nexport type ImageMediaTypesType = (typeof ImageMediaTypes)[keyof typeof ImageMediaTypes];\n\n// ---- DocumentMediaTypes ----\nexport const DocumentMediaTypes = {\n Text: 'text/plain',\n Pdf: 'application/pdf',\n Ppt: 'application/vnd.ms-powerpoint',\n Word: 'application/msword',\n Excel: 'application/vnd.ms-excel',\n OpenDoc: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n OpenPres: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n OpenSheet: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n} as const;\nexport type DocumentMediaTypesType = (typeof DocumentMediaTypes)[keyof typeof DocumentMediaTypes];\n\n// ---- AudioMediaTypes ----\nexport const AudioMediaTypes = {\n Aac: 'audio/aac',\n Mp4: 'audio/mp4',\n Mpeg: 'audio/mpeg',\n Amr: 'audio/amr',\n Ogg: 'audio/ogg',\n} as const;\nexport type AudioMediaTypesType = (typeof AudioMediaTypes)[keyof typeof AudioMediaTypes];\n\n// ---- WebhookTypes ----\nexport const WebhookTypes = {\n Audio: 'audio',\n Button: 'button',\n Document: 'document',\n Text: 'text',\n Image: 'image',\n Interactive: 'interactive',\n Order: 'order',\n Sticker: 'sticker',\n System: 'system',\n Unknown: 'unknown',\n Video: 'video',\n} as const;\nexport type WebhookTypesType = (typeof WebhookTypes)[keyof typeof WebhookTypes];\n\n// ---- SystemChangeTypes ----\nexport const SystemChangeTypes = {\n /** @deprecated Meta renamed this to `user_changed_number`. Use `UserChangedNumber`. */\n CustomerChangedNumber: 'customer_changed_number',\n /** @deprecated Meta renamed this to `user_identity_changed`. Use `UserIdentityChanged`. */\n CustomerIdentityChanged: 'customer_identity_changed',\n UserChangedNumber: 'user_changed_number',\n UserIdentityChanged: 'user_identity_changed',\n /** The user's business-scoped user ID (BSUID) changed. */\n UserChangedUserId: 'user_changed_user_id',\n} as const;\nexport type SystemChangeTypesType = (typeof SystemChangeTypes)[keyof typeof SystemChangeTypes];\n\n// ---- ReferralSourceTypes ----\nexport const ReferralSourceTypes = {\n Ad: 'ad',\n Post: 'post',\n} as const;\nexport type ReferralSourceTypesType = (typeof ReferralSourceTypes)[keyof typeof ReferralSourceTypes];\n\n// ---- RequestCodeMethods ----\nexport const RequestCodeMethods = {\n Sms: 'SMS',\n Voice: 'VOICE',\n} as const;\nexport type RequestCodeMethodsType = (typeof RequestCodeMethods)[keyof typeof RequestCodeMethods];\n\n// ---- Languages ----\nexport const Languages = {\n Afrikaans: 'af',\n Albanian: 'sq',\n Arabic: 'ar',\n Azerbaijani: 'az',\n Bengali: 'bn',\n Bulgarian: 'bg',\n Catalan: 'ca',\n Chinese_CHN: 'zh_CN',\n Chinese_HKG: 'zh_HK',\n Chinese_TAI: 'zh_TW',\n Croatian: 'hr',\n Czech: 'cs',\n Danish: 'da',\n Dutch: 'nl',\n English: 'en',\n English_UK: 'en_GB',\n English_US: 'en_US',\n Estonian: 'et',\n Filipino: 'fil',\n Finnish: 'fi',\n French: 'fr',\n Georgian: 'ka',\n German: 'de',\n Greek: 'el',\n Gujarati: 'gu',\n Hausa: 'ha',\n Hebrew: 'he',\n Hindi: 'hi',\n Hungarian: 'hu',\n Indonesian: 'id',\n Irish: 'ga',\n Italian: 'it',\n Japanese: 'ja',\n Kannada: 'kn',\n Kazakh: 'kk',\n Kinyarwanda: 'rw_RW',\n Korean: 'ko',\n Kyrgyz_Kyrgyzstan: 'ky_KG',\n Lao: 'lo',\n Latvian: 'lv',\n Lithuanian: 'lt',\n Macedonian: 'mk',\n Malay: 'ms',\n Malayalam: 'ml',\n Marathi: 'mr',\n Norwegian: 'nb',\n Persian: 'fa',\n Polish: 'pl',\n Portuguese_BR: 'pt_BR',\n Portuguese_POR: 'pt_PT',\n Punjabi: 'pa',\n Romanian: 'ro',\n Russian: 'ru',\n Serbian: 'sr',\n Slovak: 'sk',\n Slovenian: 'sl',\n Spanish: 'es',\n Spanish_ARG: 'es_AR',\n Spanish_SPA: 'es_ES',\n Spanish_MEX: 'es_MX',\n Swahili: 'sw',\n Swedish: 'sv',\n Tamil: 'ta',\n Telugu: 'te',\n Thai: 'th',\n Turkish: 'tr',\n Ukrainian: 'uk',\n Urdu: 'ur',\n Uzbek: 'uz',\n Vietnamese: 'vi',\n Zulu: 'zu',\n} as const;\nexport type LanguagesType = (typeof Languages)[keyof typeof Languages];\n\n// ---- DataLocalizationRegion ----\nexport const DataLocalizationRegion = {\n AU: 'AU',\n ID: 'ID',\n IN: 'IN',\n JP: 'JP',\n SG: 'SG',\n KR: 'KR',\n DE: 'DE',\n CH: 'CH',\n GB: 'GB',\n BR: 'BR',\n BH: 'BH',\n ZA: 'ZA',\n AE: 'AE',\n CA: 'CA',\n} as const;\nexport type DataLocalizationRegionType = (typeof DataLocalizationRegion)[keyof typeof DataLocalizationRegion];\n"],"mappings":"yoBAQA,IAAY,EAAL,SAAA,EAAA,OACH,GAAA,MAAA,QACA,EAAA,UAAA,YACA,EAAA,UAAA,YACA,EAAA,QAAA,UACA,EAAA,WAAA,cACJ,EAAA,CAAA,CAAA,EAKY,EAAL,SAAA,EAAA,OACH,GAAA,OAAA,UACA,EAAA,OAAA,UACA,EAAA,mBAAA,sBACA,EAAA,eAAA,kBACA,EAAA,UAAA,aACA,EAAA,gBAAA,mBACA,EAAA,OAAA,SACA,EAAA,MAAA,SACJ,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OACH,GAAA,KAAA,OACA,EAAA,KAAA,OACA,EAAA,cAAA,iBACJ,EAAA,CAAA,CAAA,EAMY,EAAL,SAAA,EAAA,OAEH,GAAA,KAAA,OAEA,EAAA,OAAA,gBAEA,EAAA,MAAA,QAEA,EAAA,IAAA,KACJ,EAAA,CAAA,CAAA,ECdY,EAAL,SAAA,EAAA,OACH,GAAA,SAAA,WACA,EAAA,OAAA,SACA,EAAA,SAAA,WACA,EAAA,SAAA,YACJ,EAAA,CAAA,CAAA,EAKY,EAAL,SAAA,EAAA,OACH,GAAA,QAAA,UACA,EAAA,QAAA,UACA,EAAA,UAAA,aACJ,EAAA,CAAA,CAAA,EAKY,EAAL,SAAA,EAAA,OACH,GAAA,SAAA,WACA,EAAA,OAAA,SACA,EAAA,SAAA,WACA,EAAA,SAAA,YACJ,EAAA,CAAA,CAAA,EAKY,EAAL,SAAA,EAAA,OACH,GAAA,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ACR,cAAe,QACf,eAAgB,QAChB,QAAS,KACT,SAAU,KACV,QAAS,KACT,QAAS,KACT,OAAQ,KACR,UAAW,KACX,QAAS,KACT,YAAa,QACb,YAAa,QACb,YAAa,QACb,QAAS,KACT,QAAS,KACT,MAAO,KACP,OAAQ,KACR,KAAM,KACN,QAAS,KACT,UAAW,KACX,KAAM,KACN,MAAO,KACP,WAAY,KACZ,KAAM,IACV,EAIa,GAAyB,CAClC,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,IACR"}
@@ -157,6 +157,32 @@ interface RateLimitInfoContext {
157
157
  }
158
158
  /** Callback receiving rate limit information parsed from every response that carries it. */
159
159
  type RateLimitInfoListener = (info: RateLimitInfo, context: RateLimitInfoContext) => void | Promise<void>;
160
+ /** Details of an outgoing request passed to {@link WhatsAppConfig.onRequest}. */
161
+ interface RequestHookContext {
162
+ /** HTTP method of the request. */
163
+ method: string;
164
+ /** Absolute URL the request is sent to. */
165
+ url: string;
166
+ /** Request headers. `Authorization` is redacted to `Bearer ***`. */
167
+ headers: Record<string, string>;
168
+ /** Request body as handed to `fetch`: a JSON string, a `FormData`, a URL-encoded string, or undefined. */
169
+ body: BodyInit | undefined;
170
+ /** 1-based attempt number; above 1 only when a throttled request is retried. */
171
+ attempt: number;
172
+ }
173
+ /** Details of a received response passed to {@link WhatsAppConfig.onResponse}. */
174
+ interface ResponseHookContext extends RequestHookContext {
175
+ /** HTTP status code of the response. */
176
+ statusCode: number;
177
+ /** Response headers, lower-cased names. */
178
+ responseHeaders: Record<string, string | string[] | undefined>;
179
+ /** Milliseconds between sending the request and receiving the response headers. */
180
+ durationMs: number;
181
+ }
182
+ /** Called before every request is sent. */
183
+ type RequestHook = (context: RequestHookContext) => void | Promise<void>;
184
+ /** Called after every response is received, whatever its status code. */
185
+ type ResponseHook = (context: ResponseHookContext) => void | Promise<void>;
160
186
  type WabaConfigType = {
161
187
  /**
162
188
  * The Meta for Developers business application Id for this registered application.
@@ -223,6 +249,18 @@ type WabaConfigType = {
223
249
  * Rate limit header listener. Passed through from WhatsAppConfig.
224
250
  */
225
251
  onRateLimitInfo?: RateLimitInfoListener;
252
+ /**
253
+ * Custom fetch implementation. Passed through from WhatsAppConfig.
254
+ */
255
+ fetch?: typeof fetch;
256
+ /**
257
+ * Request lifecycle hook. Passed through from WhatsAppConfig.
258
+ */
259
+ onRequest?: RequestHook;
260
+ /**
261
+ * Response lifecycle hook. Passed through from WhatsAppConfig.
262
+ */
263
+ onResponse?: ResponseHook;
226
264
  };
227
265
  //#endregion
228
266
  //#region src/utils/configTable.d.ts
@@ -645,6 +683,34 @@ declare function resolveMessageStatus<T extends MessageDeliveryStatus | (string
645
683
  //#region src/utils/objectToQueryString.d.ts
646
684
  declare const objectToQueryString: (params: Record<string, any>) => string;
647
685
  //#endregion
686
+ //#region src/utils/textFormat.d.ts
687
+ /**
688
+ * Helpers that produce WhatsApp text formatting markup for message bodies.
689
+ *
690
+ * WhatsApp renders `*bold*`, `_italic_`, `~strikethrough~`, ```` ```monospace``` ````,
691
+ * `` `inline code` ``, `> quote`, `- bullet` and `1. numbered` lines. Inline markers must sit
692
+ * directly against the text they wrap and cannot span a line break, so the inline helpers apply
693
+ * their markers per line and keep leading and trailing whitespace outside the markers.
694
+ *
695
+ * @see {@link https://faq.whatsapp.com/539178204879377 | WhatsApp FAQ: How to format your messages}
696
+ */
697
+ /** Wrap text in `*` so WhatsApp renders it bold. Applied per line. */
698
+ declare function bold(text: string): string;
699
+ /** Wrap text in `_` so WhatsApp renders it italic. Applied per line. */
700
+ declare function italic(text: string): string;
701
+ /** Wrap text in `~` so WhatsApp renders it struck through. Applied per line. */
702
+ declare function strikethrough(text: string): string;
703
+ /** Wrap text in `` ` `` so WhatsApp renders it as inline code. Applied per line. */
704
+ declare function inlineCode(text: string): string;
705
+ /** Wrap text in triple backticks so WhatsApp renders it as a monospace block. May span lines. */
706
+ declare function monospace(text: string): string;
707
+ /** Prefix every line with `> ` so WhatsApp renders a block quote. */
708
+ declare function quote(text: string): string;
709
+ /** Render items as a WhatsApp bulleted list, one `- item` per line. */
710
+ declare function bulletList(items: readonly string[]): string;
711
+ /** Render items as a WhatsApp numbered list, `1. item`, `2. item`, and so on. */
712
+ declare function numberedList(items: readonly string[]): string;
713
+ //#endregion
648
714
  //#region src/api/flow/types/common.d.ts
649
715
  declare enum FlowActionEnum {
650
716
  INIT = "INIT",
@@ -835,5 +901,5 @@ declare function isFlowErrorRequest(request: FlowEndpointRequest): request is Fl
835
901
  */
836
902
  declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
837
903
  //#endregion
838
- export { AUTHORIZATION_ERROR_CODES, type ApiPermissionErrorCode, BLOCK_USER_ERROR_CODES, type BusinessUseCaseUsage, CALLING_ERROR_CODES, CUSTOMER_SERVICE_WINDOW_MS, type CustomerServiceWindowOptions, type DecryptedFlowRequest, type EncryptionKeyPair, FLOW_ERROR_CODES, FREE_ENTRY_POINT_WINDOW_MS, type FreeEntryPointWindowOptions, GROUP_ERROR_CODES, INTEGRITY_ERROR_CODES, Logger, MAX_FREE_ENTRY_POINT_WINDOW_MS, type MessageDeliveryStatus, type MessagingWindow, type MetaError, type MetaErrorData, type RateLimitHeadersInput, type RateLimitInfo, type RateLimitUsage, SEND_MESSAGE_ERROR_CODES, THROTTLING_ERROR_CODES, WHATSAPP_ERROR_CODES, WhatsAppApiError, WhatsAppAuthorizationError, WhatsAppBlockUserError, WhatsAppCallingError, WhatsAppError, type WhatsAppErrorCode, WhatsAppFlowError, WhatsAppGroupError, WhatsAppIntegrityError, WhatsAppNetworkError, WhatsAppSendMessageError, WhatsAppThrottlingError, WhatsAppUnknownError, WhatsAppValidationError, type WindowTimestamp, buildFieldsQueryString, canSendFreeformMessage, compareMessageStatus, createWhatsAppApiError, decryptFlowRequest, decryptFlowRequestAsync, encryptFlowResponse, encryptFlowResponseAsync, formatConfigTable, generateEncryption, getCustomerServiceWindow, getFreeEntryPointWindow, isApiPermissionErrorCode, isAuthorizationErrorCode, isBlockUserErrorCode, isCallingErrorCode, isFlowDataExchangeRequest, isFlowErrorCode, isFlowErrorRequest, isFlowPingRequest, isGroupErrorCode, isIntegrityErrorCode, isMessageStatusAdvance, isMetaError, isSendMessageErrorCode, isThrottlingErrorCode, isWhatsAppApiErrorResponse, isWhatsAppAuthorizationError, isWhatsAppBlockUserError, isWhatsAppCallingError, isWhatsAppErrorCode, isWhatsAppFlowError, isWhatsAppGroupError, isWhatsAppIntegrityError, isWhatsAppSendMessageError, isWhatsAppThrottlingError, normalizeMetaError, objectToQueryString, parseRateLimitHeaders, parseRetryAfter, resolveMessageStatus };
904
+ export { AUTHORIZATION_ERROR_CODES, type ApiPermissionErrorCode, BLOCK_USER_ERROR_CODES, type BusinessUseCaseUsage, CALLING_ERROR_CODES, CUSTOMER_SERVICE_WINDOW_MS, type CustomerServiceWindowOptions, type DecryptedFlowRequest, type EncryptionKeyPair, FLOW_ERROR_CODES, FREE_ENTRY_POINT_WINDOW_MS, type FreeEntryPointWindowOptions, GROUP_ERROR_CODES, INTEGRITY_ERROR_CODES, Logger, MAX_FREE_ENTRY_POINT_WINDOW_MS, type MessageDeliveryStatus, type MessagingWindow, type MetaError, type MetaErrorData, type RateLimitHeadersInput, type RateLimitInfo, type RateLimitUsage, SEND_MESSAGE_ERROR_CODES, THROTTLING_ERROR_CODES, WHATSAPP_ERROR_CODES, WhatsAppApiError, WhatsAppAuthorizationError, WhatsAppBlockUserError, WhatsAppCallingError, WhatsAppError, type WhatsAppErrorCode, WhatsAppFlowError, WhatsAppGroupError, WhatsAppIntegrityError, WhatsAppNetworkError, WhatsAppSendMessageError, WhatsAppThrottlingError, WhatsAppUnknownError, WhatsAppValidationError, type WindowTimestamp, bold, buildFieldsQueryString, bulletList, canSendFreeformMessage, compareMessageStatus, createWhatsAppApiError, decryptFlowRequest, decryptFlowRequestAsync, encryptFlowResponse, encryptFlowResponseAsync, formatConfigTable, generateEncryption, getCustomerServiceWindow, getFreeEntryPointWindow, inlineCode, isApiPermissionErrorCode, isAuthorizationErrorCode, isBlockUserErrorCode, isCallingErrorCode, isFlowDataExchangeRequest, isFlowErrorCode, isFlowErrorRequest, isFlowPingRequest, isGroupErrorCode, isIntegrityErrorCode, isMessageStatusAdvance, isMetaError, isSendMessageErrorCode, isThrottlingErrorCode, isWhatsAppApiErrorResponse, isWhatsAppAuthorizationError, isWhatsAppBlockUserError, isWhatsAppCallingError, isWhatsAppErrorCode, isWhatsAppFlowError, isWhatsAppGroupError, isWhatsAppIntegrityError, isWhatsAppSendMessageError, isWhatsAppThrottlingError, italic, monospace, normalizeMetaError, numberedList, objectToQueryString, parseRateLimitHeaders, parseRetryAfter, quote, resolveMessageStatus, strikethrough };
839
905
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/buildFieldsQueryString.ts","../../src/utils/rateLimit.ts","../../src/types/enums.ts","../../src/types/config.ts","../../src/utils/configTable.ts","../../src/utils/customerServiceWindow.ts","../../src/utils/isMetaError.ts","../../src/types/logger.ts","../../src/utils/logger.ts","../../src/core/webhook/types/common.ts","../../src/core/webhook/types/status.ts","../../src/utils/messageStatus.ts","../../src/utils/objectToQueryString.ts","../../src/api/flow/types/common.ts","../../src/utils/flowEncryptionUtils.ts","../../src/utils/flowTypeGuards.ts"],"mappings":";iBAAgB,sBAAA,CAAuB,MAA0B;;;;AAAjE;;;UCMiB,cAAA;EDNgD;ECQ7D,SAAA;;EAEA,YAAA;EAJa;EAMb,SAAA;AAAA;;UAIa,oBAAA,SAA6B,cAAc;EANxD;EAQA,UAAA;EANS;EAQT,IAAA;EAJa;;;;EASb,kCAAA;EAPA;EASA,gBAAA;AAAA;;;AAAgB;AAUpB;;;;UAAiB,aAAA;EAEF;EAAX,QAAA,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AA;IACA,aAAA;EAAA;AAAA;;;;;;;;iBAmCQ,iBAAA,CAAkB,OAAA,EAAS,mBAAA,GAAsB,OAAA,IAAW,sBAAsB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/buildFieldsQueryString.ts","../../src/utils/rateLimit.ts","../../src/types/enums.ts","../../src/types/config.ts","../../src/utils/configTable.ts","../../src/utils/customerServiceWindow.ts","../../src/utils/isMetaError.ts","../../src/types/logger.ts","../../src/utils/logger.ts","../../src/core/webhook/types/common.ts","../../src/core/webhook/types/status.ts","../../src/utils/messageStatus.ts","../../src/utils/objectToQueryString.ts","../../src/utils/textFormat.ts","../../src/api/flow/types/common.ts","../../src/utils/flowEncryptionUtils.ts","../../src/utils/flowTypeGuards.ts"],"mappings":";iBAAgB,sBAAA,CAAuB,MAA0B;;;;AAAjE;;;UCMiB,cAAA;EDNgD;ECQ7D,SAAA;;EAEA,YAAA;EAJa;EAMb,SAAA;AAAA;;UAIa,oBAAA,SAA6B,cAAc;EANxD;EAQA,UAAA;EANS;EAQT,IAAA;EAJa;;;;EASb,kCAAA;EAPA;EASA,gBAAA;AAAA;;;AAAgB;AAUpB;;;;UAAiB,aAAA;EAEF;EAAX,QAAA,GAAW,cAAA;EAEW;EAAtB,oBAAA,EAAsB,oBAAoB;EAO1C;EALA,YAAA;EAUY;AAAA;AAIhB;;EATI,eAAA;EAWQ;;;;EANR,YAAA;AAAA;AAOoB;AAAA,KAHZ,qBAAA,GACN,OAAA,GACA,MAAM;EACJ,GAAA,CAAI,IAAA;AAAA;;AAwE8E;AA0B1F;;iBA1BgB,eAAA,CAAgB,KAAA,6BAAkC,GAAwB;;;;;;AA0Ba;;;;AClCvG;;;;;iBDkCgB,qBAAA,CAAsB,OAAA,EAAS,qBAAA,sBAA2C,aAAa;;;aClC3F,cAAA;EACR,KAAA;EACA,IAAA;EACA,SAAA;EACA,aAAA;EACA,cAAA;EACA,UAAA;EACA,WAAA;EACA,eAAA;EACA,wBAAA;EACA,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,OAAA,IAAW,uBAAA;EAChF,MAAA,UAAgB,qBAAA;EAChB,MAAA;EACA,UAAA;EACA,IAAA,GAAO,MAAA;AAAA;;Af/BE;AAIb;;;;;iBe2DgB,kBAAA,CAAmB,OAAA,EAAS,mBAAA,GAAsB,OAAA,IAAW,4BAAA;EACzE,MAAA,UAAgB,aAAA;EAChB,MAAA;EACA,UAAA;EACA,IAAA;IACI,KAAA;IACA,aAAA;EAAA;AAAA;;;;;;;;iBAmCQ,iBAAA,CAAkB,OAAA,EAAS,mBAAA,GAAsB,OAAA,IAAW,sBAAsB"}
@@ -1,5 +1,11 @@
1
1
  function e(e){if(!e)return``;let t=``;return t=Array.isArray(e)?e.join(`,`):typeof e==`string`?e:Object.entries(e).filter(([e,t])=>t).map(([e])=>e).join(`,`),t?`?fields=${t}`:``}function t(e){let t=[[`App ID`,e.M4D_APP_ID||`Not Set`],[`Phone Number ID`,e.WA_PHONE_NUMBER_ID?.toString()||`Not Set`],[`Business Account ID`,e.WA_BUSINESS_ACCOUNT_ID||`Not Set`],[`API Version`,e.CLOUD_API_VERSION||`Not Set`],[`Access Token`,e.CLOUD_API_ACCESS_TOKEN?`${e.CLOUD_API_ACCESS_TOKEN.substring(0,20)}...`:`Not Set`],[`Webhook Endpoint`,e.WEBHOOK_ENDPOINT||`Not Set`],[`Webhook Verification Token`,e.WEBHOOK_VERIFICATION_TOKEN?`${e.WEBHOOK_VERIFICATION_TOKEN.substring(0,10)}...`:`Not Set`],[`Listener Port`,e.LISTENER_PORT?.toString()||`Not Set`],[`Debug Mode`,e.DEBUG?`Enabled`:`Disabled`],[`Max Retries`,e.MAX_RETRIES_AFTER_WAIT?.toString()||`Not Set`],[`Request Timeout`,e.REQUEST_TIMEOUT?`${e.REQUEST_TIMEOUT}ms`:`Not Set`],[`Private PEM`,e.FLOW_API_PRIVATE_PEM?`Configured`:`Not Set`],[`Passphrase`,e.FLOW_API_PASSPHRASE?`Configured`:`Not Set`]],n=Math.max(...t.map(([e])=>e?.length||0)),r=Math.max(...t.map(([,e])=>e?.length||0)),i=Math.max(n,20),a=Math.max(r,30),o=`┌${`─`.repeat(i+2)}┬${`─`.repeat(a+2)}┐`,s=`├${`─`.repeat(i+2)}┼${`─`.repeat(a+2)}┤`,c=`└${`─`.repeat(i+2)}┴${`─`.repeat(a+2)}┘`;return[o,`│ ${`Configuration`.padEnd(i)} │ ${`Value`.padEnd(a)} │`,s,...t.map(([e,t])=>`│ ${e?.padEnd(i)} │ ${t?.padEnd(a)} │`),c].join(`
2
- `)}const n=[0,1,2,3,4,10,33,100,190,200,299,368,613,80007,130429,130472,130497,131e3,131005,131008,131009,131016,131020,131021,131026,131030,131031,131037,131041,131042,131044,131045,131047,131048,131049,131050,131051,131052,131053,131055,131056,131057,131059,131061,131062,131063,131065,131070,131201,131202,131203,131204,131207,131208,131209,131210,131211,131212,131213,131214,131215,132e3,132001,132005,132007,132008,132012,132015,132016,132068,132069,133e3,133004,133005,133006,133008,133009,133010,133015,133016,134011,134100,134101,134102,135e3,137e3,138e3,138001,138002,138003,138004,138005,138006,138007,138009,138012,138013,138018,138038,139e3,139001,139002,139003,139004,139100,139101,139102,139103,147005,200005,200006,200007,1752041,2388001,2388012,2388019,2388040,2388047,2388072,2388073,2388091,2388093,2388103,2388293,2388299,2494100,2494191,2593079,2593085,2593107,2593108],r=new Set(n),i=[0,3,10,190],a=[4,80007,130429,131048,131056],o=[368,130497,131031],s=[130472,131e3,131005,131008,131009,131016,131021,131026,131030,131042,131044,131045,131047,131050,131051,131052,131053,131056,131057,131048,131061,131062,131063,131065,131070,132e3,132001,132005,132007,132008,132012,132015,132016,132068,132069,135e3,137e3],c=[139e3,139001,139002,139003,139004],l=[139100,139101,139102,139103],u=[138e3,138001,138002,138003,138004,138005,138006,138007,138009,138012,138013,138018,138038,613],d=[131020,131041,131059,131201,131202,131203,131204,131207,131208,131209,131210,131211,131212,131213,131214,131215],f=new Set(i),p=new Set(a),m=new Set(o),ee=new Set(s),h=new Set(c),g=new Set(l),te=new Set(u),ne=new Set(d);function re(e){return _(e)?!0:r.has(e)}function _(e){return e>=200&&e<300}function ie(e){return _(e)||f.has(e)}function ae(e){return p.has(e)}function oe(e){return m.has(e)}function se(e){return ee.has(e)}function ce(e){return h.has(e)}function v(e){return g.has(e)}function y(e){return te.has(e)}function b(e){return ne.has(e)}var x=class extends Error{constructor(e){super(e),this.name=`WhatsAppError`}},S=class extends x{error;statusCode;rateLimit;constructor(e,t,n){super(e),this.name=`WhatsAppApiError`,this.error=t,this.statusCode=n}},C=class extends S{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppAuthorizationError`}},w=class extends S{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppThrottlingError`}},T=class extends S{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppIntegrityError`}},E=class extends S{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppSendMessageError`}},D=class extends S{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppFlowError`}},O=class extends S{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppBlockUserError`}},k=class extends S{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppCallingError`}},A=class extends S{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppGroupError`}};function le(e,t){let n=e.code;return ie(n)?new C(e.message,e,t):ae(n)?new w(e.message,e,t):oe(n)?new T(e.message,e,t):se(n)?new E(e.message,e,t):ce(n)?new D(e.message,e,t):v(n)?new O(e.message,e,t):y(n)?new k(e.message,e,t):b(n)?new A(e.message,e,t):new S(e.message,e,t)}var ue=class extends x{cause;constructor(e,t){super(e),this.name=`WhatsAppNetworkError`,this.cause=t}},de=class extends x{cause;constructor(e,t){super(e),this.name=`WhatsAppUnknownError`,this.cause=t}},j=class extends Error{constructor(e){super(e),this.name=`WhatsAppValidationError`}};function M(e){if(typeof e!=`object`||!e||!(`error`in e)||typeof e.error!=`object`||e.error==null)return!1;let t=e.error;if(typeof t.message!=`string`||typeof t.type!=`string`||typeof t.code!=`number`||typeof t.fbtrace_id!=`string`)return!1;if(`error_data`in t&&t.error_data!=null){if(typeof t.error_data!=`object`)return!1;let e=t.error_data;if(`messaging_product`in e&&e.messaging_product!==`whatsapp`||`details`in e&&typeof e.details!=`string`)return!1}return!(`error_subcode`in t&&typeof t.error_subcode!=`number`)}function fe(e){return M(e)&&re(e.error.code)}function pe(e){return e instanceof C}function me(e){return e instanceof w}function he(e){return e instanceof T}function ge(e){return e instanceof E}function _e(e){return e instanceof D}function ve(e){return e instanceof O}function ye(e){return e instanceof k}function be(e){return e instanceof A}function xe(e,t){if(M(e))return e;let n=`Unknown error occurred`;if(e&&typeof e==`object`&&`message`in e){let t=e.message;typeof t==`string`&&(n=t)}return{name:`MetaError`,message:n,error:{message:n,type:`UnknownError`,code:typeof t==`number`?t:500,fbtrace_id:``}}}const N=3600*1e3,P=24*N,F=72*N,Se=168*N,I=1e11;function L(e,t){let n;if(e instanceof Date)n=e.getTime();else if(typeof e==`number`)n=Math.abs(e)<I?e*1e3:e;else if(typeof e==`string`){let t=e.trim();if(/^\d+(\.\d+)?$/.test(t)){let e=Number(t);n=e<I?e*1e3:e}else n=t===``?NaN:Date.parse(t)}else n=NaN;if(!Number.isFinite(n)||!Number.isFinite(new Date(n).getTime()))throw new j(`${t} is not a valid timestamp: ${String(e)}`);return n}function R(e,t,n){if(e===void 0)return n;if(typeof e!=`number`||!Number.isFinite(e)||e<0)throw new j(`${t} must be a non-negative number of milliseconds`);return e}function z(e,t,n,r){if(!Number.isFinite(new Date(t).getTime()))throw new j(`Window expiry is outside the supported timestamp range`);let i=Math.max(0,t-e),a=t-r,o=Math.min(Math.max(0,a-n),i);return{isOpen:o>0,expiresAt:new Date(t),remainingMs:o}}const B=Object.freeze({isOpen:!1,expiresAt:null,remainingMs:0});function V(e,t={}){let n=R(t.safetyMarginMs,`safetyMarginMs`,0),r=t.now===void 0?Date.now():L(t.now,`now`);if(e==null)return{...B};let i=L(e,`lastInboundAt`);return z(i,i+P,r,n)}function Ce(e,t={}){return V(e,t).isOpen}function we(e,t={}){let n=R(t.safetyMarginMs,`safetyMarginMs`,0),r=R(t.durationMs,`durationMs`,F),i=t.now===void 0?Date.now():L(t.now,`now`);if(e==null)return{...B};let a=L(e,`openedAt`);return z(a,t.expiresAt===void 0?a+r:L(t.expiresAt,`expiresAt`),i,n)}var H=class{name;debugEnabled;constructor(e,t=!1){this.name=e,this.debugEnabled=t}formatData(e){return e.map(e=>typeof e==`object`&&e?Te(e):e).join(` `)}log(...e){if(this.debugEnabled){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log(t,`: `,this.formatData(e))}}error(...e){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error(t,`: `,this.formatData(e))}warn(...e){if(this.debugEnabled){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn(t,`: `,this.formatData(e))}}info(...e){if(this.debugEnabled){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info(t,`: `,this.formatData(e))}}debug(...e){if(this.debugEnabled){let t=`[ ${Date.now()} ] - DEBUG`;this.name&&(t+=` - ${this.name}`),console.debug(t,`: `,this.formatData(e))}}};function Te(e){if(e instanceof Error)return e.stack||`${e.name}: ${e.message}`;let t=new WeakSet;try{return JSON.stringify(e,(e,n)=>{if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(typeof n==`bigint`)return n.toString();if(typeof n==`object`&&n){if(t.has(n))return`[Circular]`;t.add(n)}return n},2)}catch{return String(e)}}const Ee={sent:1,failed:2,delivered:3,read:4};function De(e){return e&&Object.hasOwn(Ee,e)?Ee[e]:0}function U(e,t){return De(e)-De(t)}function Oe(e,t){return e==null||e===``?!0:U(t,e)>0}function ke(e,t){return e==null||e===``||U(t,e)>0?t:e}const Ae=e=>{if(!e||Object.keys(e).length===0)return``;let t=[];for(let[n,r]of Object.entries(e))if(r!==void 0){let e=encodeURIComponent(n),i=encodeURIComponent(String(r));t.push(`${e}=${i}`)}return t.length>0?`?${t.join(`&`)}`:``};function W(e,t){if(typeof e.get==`function`)return e.get(t)??void 0;let n=e,r=Object.keys(n).find(e=>e.toLowerCase()===t);if(r===void 0)return;let i=n[r];return Array.isArray(i)?i[0]:i}function je(e){if(!(e===void 0||e.trim()===``))try{return JSON.parse(e)}catch{return}}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``&&Number.isFinite(Number(e)))return Number(e)}function Me(e){return typeof e==`string`?e:void 0}function Ne(e){let t={},n=K(e.call_count),r=K(e.total_cputime),i=K(e.total_time);return n!==void 0&&(t.callCount=n),r!==void 0&&(t.totalCputime=r),i!==void 0&&(t.totalTime=i),t}function Pe(e){if(!G(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r){if(!G(e))continue;let r={businessId:n,...Ne(e)},i=Me(e.type),a=K(e.estimated_time_to_regain_access),o=Me(e.ads_api_access_tier);i!==void 0&&(r.type=i),a!==void 0&&(r.estimatedTimeToRegainAccessMinutes=a),o!==void 0&&(r.adsApiAccessTier=o),t.push(r)}return t}function Fe(e,t=Date.now()){if(e==null)return;let n=e.trim();if(n===``)return;if(/^\d+(\.\d+)?$/.test(n))return Math.round(Number(n)*1e3);if(!/[a-z]/i.test(n))return;let r=Date.parse(n);if(Number.isFinite(r))return Math.max(0,r-t)}function Ie(e){if(!e)return;let t=W(e,`x-app-usage`),n=W(e,`x-business-use-case-usage`),r=W(e,`retry-after`);if(t===void 0&&n===void 0&&r===void 0)return;let i={businessUseCaseUsage:[]},a=je(t);G(a)&&(i.appUsage=Ne(a)),i.businessUseCaseUsage=Pe(je(n));let o=Fe(r);o!==void 0&&(i.retryAfterMs=o);let s=[...i.appUsage?[i.appUsage]:[],...i.businessUseCaseUsage].flatMap(e=>[e.callCount,e.totalCputime,e.totalTime].filter(e=>e!==void 0));s.length>0&&(i.maxUsagePercent=Math.max(...s));let c=[...o===void 0?[]:[o],...i.businessUseCaseUsage.map(e=>e.estimatedTimeToRegainAccessMinutes).filter(e=>e!==void 0&&e>0).map(e=>e*6e4)];return c.length>0&&(i.retryDelayMs=Math.max(...c)),i}function q(){let e=globalThis.process;return typeof e==`object`&&e?e:void 0}function Le(e){return q()?.env?.[e]}function Re(){return Le(`DEBUG`)===`true`}function J(){let e=q()?.getBuiltinModule;if(typeof e!=`function`)return q(),void 0;try{return e(`node:crypto`)}catch{return}}function ze(e){let t=J();if(!t)throw Error(`${e} needs the node:crypto module, which is not available in this runtime. Use the async Web Crypto variant instead, or run on Node.js >= 20.12, Bun or Deno.`);return t}function Y(){let e=globalThis.crypto?.subtle;if(!e)throw Error(`Web Crypto (globalThis.crypto.subtle) is not available in this runtime.`);return e}const Be=new TextEncoder,Ve=new TextDecoder;function He(e){return Be.encode(e)}function Ue(e){return Ve.decode(e)}function X(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function We(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}const Z=new H(`FLOW_ENCRYPTION_UTILS`,Re());function Ge(){let e=J();if(!e||typeof e.generateKeyPairSync!=`function`){let e=Error(`This utility requires Node.js environment with crypto module. It cannot be used in browser or edge runtime environments.`);throw Z.error(`Environment validation failed:`,e),e}if(typeof window<`u`){let e=Error(`This utility cannot run in a browser environment. Please use it in a Node.js server environment only.`);throw Z.error(`Browser environment detected:`,e),e}let t=globalThis.process?.versions?.node;if(t){let e=t.split(`.`).map(Number),n=e[0]??0,r=e[1]??0;if(n<10||n===10&&r<12){let e=Error(`Node.js version ${t} is not supported. Please upgrade to Node.js 10.12.0 or higher.`);throw Z.error(`Node.js version check failed:`,e),e}}return e}function Ke(e){Z.info(`[generateEncryption] Starting key pair generation`);let t=Ge(),n=e||Le(`FLOW_API_PASSPHRASE`);if(!n||n.trim().length===0){let e=Error(`Passphrase is empty. Please provide a passphrase as parameter or set FLOW_API_PASSPHRASE environment variable.`);throw Z.error(`[generateEncryption] Passphrase validation failed:`,e),e}n.length<8&&Z.warn(`[generateEncryption] Passphrase is shorter than 8 characters. Consider using a longer passphrase for better security.`);try{Z.info(`[generateEncryption] Generating 2048-bit RSA key pair`);let e=t.generateKeyPairSync(`rsa`,{modulusLength:2048,publicKeyEncoding:{type:`spki`,format:`pem`},privateKeyEncoding:{type:`pkcs8`,format:`pem`,cipher:`aes-256-cbc`,passphrase:n}});return Z.info(`[generateEncryption] Key pair generated successfully`),{passphrase:n,privateKey:e.privateKey,publicKey:e.publicKey}}catch(e){let t=e instanceof Error?e.message:String(e),n=Error(`Failed to generate key pair: ${t}`);throw Z.error(`[generateEncryption] Key generation failed:`,n),n}}function qe(e,t){Z.info(`[decryptFlowRequest] Starting Flow request decryption`);let n=ze(`decryptFlowRequest`);if(!t.FLOW_API_PRIVATE_PEM||t.FLOW_API_PRIVATE_PEM.trim()===``){let e=Error(`Missing FLOW_API_PRIVATE_PEM. Please set the FLOW_API_PRIVATE_PEM environment variable or pass privatePem via config.`);throw Z.error(`[decryptFlowRequest] Configuration error:`,e),e}if(!t.FLOW_API_PASSPHRASE||t.FLOW_API_PASSPHRASE.trim()===``){let e=Error(`Missing FLOW_API_PASSPHRASE. Please set the FLOW_API_PASSPHRASE environment variable or pass passphrase via config.`);throw Z.error(`[decryptFlowRequest] Configuration error:`,e),e}Z.info(`[decryptFlowRequest] Configuration validated`);let{encrypted_aes_key:r,encrypted_flow_data:i,initial_vector:a}=e;if(!r||!i||!a)throw Z.error(`[decryptFlowRequest] Missing required encryption properties in request body`),Error(`Missing required encryption properties`);Z.info(`[decryptFlowRequest] Request body validated`);let o=t.FLOW_API_PRIVATE_PEM;o.includes(`\\n`)&&(o=o.replace(/\\n/g,`
2
+ `)}const n=[0,1,2,3,4,10,33,100,190,200,299,368,613,80007,130429,130472,130497,131e3,131005,131008,131009,131016,131020,131021,131026,131030,131031,131037,131041,131042,131044,131045,131047,131048,131049,131050,131051,131052,131053,131055,131056,131057,131059,131061,131062,131063,131065,131070,131201,131202,131203,131204,131207,131208,131209,131210,131211,131212,131213,131214,131215,132e3,132001,132005,132007,132008,132012,132015,132016,132068,132069,133e3,133004,133005,133006,133008,133009,133010,133015,133016,134011,134100,134101,134102,135e3,137e3,138e3,138001,138002,138003,138004,138005,138006,138007,138009,138012,138013,138018,138038,139e3,139001,139002,139003,139004,139100,139101,139102,139103,147005,200005,200006,200007,1752041,2388001,2388012,2388019,2388040,2388047,2388072,2388073,2388091,2388093,2388103,2388293,2388299,2494100,2494191,2593079,2593085,2593107,2593108],r=new Set(n),i=[0,3,10,190],a=[4,80007,130429,131048,131056],o=[368,130497,131031],s=[130472,131e3,131005,131008,131009,131016,131021,131026,131030,131042,131044,131045,131047,131050,131051,131052,131053,131056,131057,131048,131061,131062,131063,131065,131070,132e3,132001,132005,132007,132008,132012,132015,132016,132068,132069,135e3,137e3],c=[139e3,139001,139002,139003,139004],l=[139100,139101,139102,139103],u=[138e3,138001,138002,138003,138004,138005,138006,138007,138009,138012,138013,138018,138038,613],d=[131020,131041,131059,131201,131202,131203,131204,131207,131208,131209,131210,131211,131212,131213,131214,131215],f=new Set(i),p=new Set(a),m=new Set(o),ee=new Set(s),h=new Set(c),te=new Set(l),ne=new Set(u),re=new Set(d);function ie(e){return g(e)?!0:r.has(e)}function g(e){return e>=200&&e<300}function ae(e){return g(e)||f.has(e)}function oe(e){return p.has(e)}function se(e){return m.has(e)}function ce(e){return ee.has(e)}function _(e){return h.has(e)}function le(e){return te.has(e)}function v(e){return ne.has(e)}function y(e){return re.has(e)}var b=class extends Error{constructor(e){super(e),this.name=`WhatsAppError`}},x=class extends b{error;statusCode;rateLimit;constructor(e,t,n){super(e),this.name=`WhatsAppApiError`,this.error=t,this.statusCode=n}},S=class extends x{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppAuthorizationError`}},C=class extends x{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppThrottlingError`}},w=class extends x{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppIntegrityError`}},T=class extends x{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppSendMessageError`}},E=class extends x{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppFlowError`}},D=class extends x{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppBlockUserError`}},O=class extends x{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppCallingError`}},k=class extends x{constructor(e,t,n){super(e,t,n),this.name=`WhatsAppGroupError`}};function ue(e,t){let n=e.code;return ae(n)?new S(e.message,e,t):oe(n)?new C(e.message,e,t):se(n)?new w(e.message,e,t):ce(n)?new T(e.message,e,t):_(n)?new E(e.message,e,t):le(n)?new D(e.message,e,t):v(n)?new O(e.message,e,t):y(n)?new k(e.message,e,t):new x(e.message,e,t)}var de=class extends b{cause;constructor(e,t){super(e),this.name=`WhatsAppNetworkError`,this.cause=t}},fe=class extends b{cause;constructor(e,t){super(e),this.name=`WhatsAppUnknownError`,this.cause=t}},A=class extends Error{constructor(e){super(e),this.name=`WhatsAppValidationError`}};function j(e){if(typeof e!=`object`||!e||!(`error`in e)||typeof e.error!=`object`||e.error==null)return!1;let t=e.error;if(typeof t.message!=`string`||typeof t.type!=`string`||typeof t.code!=`number`||typeof t.fbtrace_id!=`string`)return!1;if(`error_data`in t&&t.error_data!=null){if(typeof t.error_data!=`object`)return!1;let e=t.error_data;if(`messaging_product`in e&&e.messaging_product!==`whatsapp`||`details`in e&&typeof e.details!=`string`)return!1}return!(`error_subcode`in t&&typeof t.error_subcode!=`number`)}function pe(e){return j(e)&&ie(e.error.code)}function me(e){return e instanceof S}function he(e){return e instanceof C}function ge(e){return e instanceof w}function _e(e){return e instanceof T}function ve(e){return e instanceof E}function ye(e){return e instanceof D}function be(e){return e instanceof O}function xe(e){return e instanceof k}function Se(e,t){if(j(e))return e;let n=`Unknown error occurred`;if(e&&typeof e==`object`&&`message`in e){let t=e.message;typeof t==`string`&&(n=t)}return{name:`MetaError`,message:n,error:{message:n,type:`UnknownError`,code:typeof t==`number`?t:500,fbtrace_id:``}}}const M=3600*1e3,N=24*M,P=72*M,Ce=168*M,F=1e11;function I(e,t){let n;if(e instanceof Date)n=e.getTime();else if(typeof e==`number`)n=Math.abs(e)<F?e*1e3:e;else if(typeof e==`string`){let t=e.trim();if(/^\d+(\.\d+)?$/.test(t)){let e=Number(t);n=e<F?e*1e3:e}else n=t===``?NaN:Date.parse(t)}else n=NaN;if(!Number.isFinite(n)||!Number.isFinite(new Date(n).getTime()))throw new A(`${t} is not a valid timestamp: ${String(e)}`);return n}function L(e,t,n){if(e===void 0)return n;if(typeof e!=`number`||!Number.isFinite(e)||e<0)throw new A(`${t} must be a non-negative number of milliseconds`);return e}function R(e,t,n,r){if(!Number.isFinite(new Date(t).getTime()))throw new A(`Window expiry is outside the supported timestamp range`);let i=Math.max(0,t-e),a=t-r,o=Math.min(Math.max(0,a-n),i);return{isOpen:o>0,expiresAt:new Date(t),remainingMs:o}}const z=Object.freeze({isOpen:!1,expiresAt:null,remainingMs:0});function B(e,t={}){let n=L(t.safetyMarginMs,`safetyMarginMs`,0),r=t.now===void 0?Date.now():I(t.now,`now`);if(e==null)return{...z};let i=I(e,`lastInboundAt`);return R(i,i+N,r,n)}function we(e,t={}){return B(e,t).isOpen}function Te(e,t={}){let n=L(t.safetyMarginMs,`safetyMarginMs`,0),r=L(t.durationMs,`durationMs`,P),i=t.now===void 0?Date.now():I(t.now,`now`);if(e==null)return{...z};let a=I(e,`openedAt`);return R(a,t.expiresAt===void 0?a+r:I(t.expiresAt,`expiresAt`),i,n)}var V=class{name;debugEnabled;constructor(e,t=!1){this.name=e,this.debugEnabled=t}formatData(e){return e.map(e=>typeof e==`object`&&e?Ee(e):e).join(` `)}log(...e){if(this.debugEnabled){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log(t,`: `,this.formatData(e))}}error(...e){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error(t,`: `,this.formatData(e))}warn(...e){if(this.debugEnabled){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn(t,`: `,this.formatData(e))}}info(...e){if(this.debugEnabled){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info(t,`: `,this.formatData(e))}}debug(...e){if(this.debugEnabled){let t=`[ ${Date.now()} ] - DEBUG`;this.name&&(t+=` - ${this.name}`),console.debug(t,`: `,this.formatData(e))}}};function Ee(e){if(e instanceof Error)return e.stack||`${e.name}: ${e.message}`;let t=new WeakSet;try{return JSON.stringify(e,(e,n)=>{if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(typeof n==`bigint`)return n.toString();if(typeof n==`object`&&n){if(t.has(n))return`[Circular]`;t.add(n)}return n},2)}catch{return String(e)}}const De={sent:1,failed:2,delivered:3,read:4};function Oe(e){return e&&Object.hasOwn(De,e)?De[e]:0}function H(e,t){return Oe(e)-Oe(t)}function ke(e,t){return e==null||e===``?!0:H(t,e)>0}function Ae(e,t){return e==null||e===``||H(t,e)>0?t:e}const je=e=>{if(!e||Object.keys(e).length===0)return``;let t=[];for(let[n,r]of Object.entries(e))if(r!==void 0){let e=encodeURIComponent(n),i=encodeURIComponent(String(r));t.push(`${e}=${i}`)}return t.length>0?`?${t.join(`&`)}`:``};function U(e,t){if(typeof e.get==`function`)return e.get(t)??void 0;let n=e,r=Object.keys(n).find(e=>e.toLowerCase()===t);if(r===void 0)return;let i=n[r];return Array.isArray(i)?i[0]:i}function Me(e){if(!(e===void 0||e.trim()===``))try{return JSON.parse(e)}catch{return}}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``&&Number.isFinite(Number(e)))return Number(e)}function Ne(e){return typeof e==`string`?e:void 0}function Pe(e){let t={},n=G(e.call_count),r=G(e.total_cputime),i=G(e.total_time);return n!==void 0&&(t.callCount=n),r!==void 0&&(t.totalCputime=r),i!==void 0&&(t.totalTime=i),t}function Fe(e){if(!W(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r){if(!W(e))continue;let r={businessId:n,...Pe(e)},i=Ne(e.type),a=G(e.estimated_time_to_regain_access),o=Ne(e.ads_api_access_tier);i!==void 0&&(r.type=i),a!==void 0&&(r.estimatedTimeToRegainAccessMinutes=a),o!==void 0&&(r.adsApiAccessTier=o),t.push(r)}return t}function Ie(e,t=Date.now()){if(e==null)return;let n=e.trim();if(n===``)return;if(/^\d+(\.\d+)?$/.test(n))return Math.round(Number(n)*1e3);if(!/[a-z]/i.test(n))return;let r=Date.parse(n);if(Number.isFinite(r))return Math.max(0,r-t)}function Le(e){if(!e)return;let t=U(e,`x-app-usage`),n=U(e,`x-business-use-case-usage`),r=U(e,`retry-after`);if(t===void 0&&n===void 0&&r===void 0)return;let i={businessUseCaseUsage:[]},a=Me(t);W(a)&&(i.appUsage=Pe(a)),i.businessUseCaseUsage=Fe(Me(n));let o=Ie(r);o!==void 0&&(i.retryAfterMs=o);let s=[...i.appUsage?[i.appUsage]:[],...i.businessUseCaseUsage].flatMap(e=>[e.callCount,e.totalCputime,e.totalTime].filter(e=>e!==void 0));s.length>0&&(i.maxUsagePercent=Math.max(...s));let c=[...o===void 0?[]:[o],...i.businessUseCaseUsage.map(e=>e.estimatedTimeToRegainAccessMinutes).filter(e=>e!==void 0&&e>0).map(e=>e*6e4)];return c.length>0&&(i.retryDelayMs=Math.max(...c)),i}function K(e,t){return e.split(`
3
+ `).map(e=>{let n=/^(\s*)(.*?)(\s*)$/s.exec(e);if(!n)return e;let[,r,i,a]=n;return i?`${r}${t}${i}${t}${a}`:e}).join(`
4
+ `)}function Re(e){return K(e,`*`)}function ze(e){return K(e,`_`)}function Be(e){return K(e,`~`)}function Ve(e){return K(e,"`")}function He(e){return e.trim()===``?e:`\`\`\`${e}\`\`\``}function Ue(e){return e.split(`
5
+ `).map(e=>`> ${e}`).join(`
6
+ `)}function We(e){return e.map(e=>`- ${e}`).join(`
7
+ `)}function Ge(e){return e.map((e,t)=>`${t+1}. ${e}`).join(`
8
+ `)}function q(){let e=globalThis.process;return typeof e==`object`&&e?e:void 0}function Ke(e){return q()?.env?.[e]}function qe(){return Ke(`DEBUG`)===`true`}function J(){let e=q()?.getBuiltinModule;if(typeof e!=`function`)return q(),void 0;try{return e(`node:crypto`)}catch{return}}function Je(e){let t=J();if(!t)throw Error(`${e} needs the node:crypto module, which is not available in this runtime. Use the async Web Crypto variant instead, or run on Node.js >= 20.12, Bun or Deno.`);return t}function Y(){let e=globalThis.crypto?.subtle;if(!e)throw Error(`Web Crypto (globalThis.crypto.subtle) is not available in this runtime.`);return e}const Ye=new TextEncoder,Xe=new TextDecoder;function Ze(e){return Ye.encode(e)}function Qe(e){return Xe.decode(e)}function X(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function $e(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}const Z=new V(`FLOW_ENCRYPTION_UTILS`,qe());function et(){let e=J();if(!e||typeof e.generateKeyPairSync!=`function`){let e=Error(`This utility requires Node.js environment with crypto module. It cannot be used in browser or edge runtime environments.`);throw Z.error(`Environment validation failed:`,e),e}if(typeof window<`u`){let e=Error(`This utility cannot run in a browser environment. Please use it in a Node.js server environment only.`);throw Z.error(`Browser environment detected:`,e),e}let t=globalThis.process?.versions?.node;if(t){let e=t.split(`.`).map(Number),n=e[0]??0,r=e[1]??0;if(n<10||n===10&&r<12){let e=Error(`Node.js version ${t} is not supported. Please upgrade to Node.js 10.12.0 or higher.`);throw Z.error(`Node.js version check failed:`,e),e}}return e}function tt(e){Z.info(`[generateEncryption] Starting key pair generation`);let t=et(),n=e||Ke(`FLOW_API_PASSPHRASE`);if(!n||n.trim().length===0){let e=Error(`Passphrase is empty. Please provide a passphrase as parameter or set FLOW_API_PASSPHRASE environment variable.`);throw Z.error(`[generateEncryption] Passphrase validation failed:`,e),e}n.length<8&&Z.warn(`[generateEncryption] Passphrase is shorter than 8 characters. Consider using a longer passphrase for better security.`);try{Z.info(`[generateEncryption] Generating 2048-bit RSA key pair`);let e=t.generateKeyPairSync(`rsa`,{modulusLength:2048,publicKeyEncoding:{type:`spki`,format:`pem`},privateKeyEncoding:{type:`pkcs8`,format:`pem`,cipher:`aes-256-cbc`,passphrase:n}});return Z.info(`[generateEncryption] Key pair generated successfully`),{passphrase:n,privateKey:e.privateKey,publicKey:e.publicKey}}catch(e){let t=e instanceof Error?e.message:String(e),n=Error(`Failed to generate key pair: ${t}`);throw Z.error(`[generateEncryption] Key generation failed:`,n),n}}function nt(e,t){Z.info(`[decryptFlowRequest] Starting Flow request decryption`);let n=Je(`decryptFlowRequest`);if(!t.FLOW_API_PRIVATE_PEM||t.FLOW_API_PRIVATE_PEM.trim()===``){let e=Error(`Missing FLOW_API_PRIVATE_PEM. Please set the FLOW_API_PRIVATE_PEM environment variable or pass privatePem via config.`);throw Z.error(`[decryptFlowRequest] Configuration error:`,e),e}if(!t.FLOW_API_PASSPHRASE||t.FLOW_API_PASSPHRASE.trim()===``){let e=Error(`Missing FLOW_API_PASSPHRASE. Please set the FLOW_API_PASSPHRASE environment variable or pass passphrase via config.`);throw Z.error(`[decryptFlowRequest] Configuration error:`,e),e}Z.info(`[decryptFlowRequest] Configuration validated`);let{encrypted_aes_key:r,encrypted_flow_data:i,initial_vector:a}=e;if(!r||!i||!a)throw Z.error(`[decryptFlowRequest] Missing required encryption properties in request body`),Error(`Missing required encryption properties`);Z.info(`[decryptFlowRequest] Request body validated`);let o=t.FLOW_API_PRIVATE_PEM;o.includes(`\\n`)&&(o=o.replace(/\\n/g,`
3
9
  `));let s=t.FLOW_API_PASSPHRASE,c=o.includes(`-----BEGIN RSA PRIVATE KEY-----`),l=o.includes(`-----BEGIN PRIVATE KEY-----`)||o.includes(`-----BEGIN ENCRYPTED PRIVATE KEY-----`);Z.info(`[decryptFlowRequest] Loading private key`,{format:l?`PKCS#8`:c?`PKCS#1`:`Unknown`});let u;try{u=s?n.createPrivateKey({key:o,format:`pem`,passphrase:s}):n.createPrivateKey(o),Z.info(`[decryptFlowRequest] Private key loaded successfully`)}catch(e){if(Z.error(`[decryptFlowRequest] Failed to load private key (first attempt):`,{error:e instanceof Error?e.message:e,hasPassphrase:!!s,format:l?`PKCS#8`:c?`PKCS#1`:`Unknown`}),c&&s)try{Z.info(`[decryptFlowRequest] Attempting to convert PKCS#1 to PKCS#8 format`);let e=n.createPrivateKey({key:o,format:`pem`,passphrase:s}).export({type:`pkcs8`,format:`pem`,cipher:`aes-256-cbc`,passphrase:s});u=n.createPrivateKey({key:e,format:`pem`,passphrase:s}),Z.info(`[decryptFlowRequest] Successfully converted PKCS#1 to PKCS#8 and loaded private key`)}catch(t){Z.error(`[decryptFlowRequest] Failed to convert PKCS#1 to PKCS#8:`,{error:t instanceof Error?t.message:t});let n=`Failed to parse private key. Error: ${e instanceof Error?e.message:e}`;throw n+=`
4
10
 
5
11
  Your key is in PKCS#1 format with unsupported encryption (DES-EDE3-CBC).`,n+=`
@@ -10,7 +16,7 @@ Your key is in PKCS#1 format (-----BEGIN RSA PRIVATE KEY-----).`,t+=`
10
16
  Please convert it to PKCS#8 format using:`,t+=`
11
17
  openssl pkcs8 -topk8 -inform PEM -outform PEM -in old_key.pem -out new_key.pem`):l||(t+=`
12
18
 
13
- Your key format is not recognized. Please ensure it is in PKCS#8 format.`),Error(t)}}let d;try{Z.info(`[decryptFlowRequest] Decrypting AES key with RSA private key`),d=n.privateDecrypt({key:u,padding:n.constants.RSA_PKCS1_OAEP_PADDING,oaepHash:`sha256`},Buffer.from(r,`base64`)),Z.info(`[decryptFlowRequest] AES key decrypted successfully`)}catch(e){throw Z.error(`[decryptFlowRequest] Failed to decrypt AES key:`,e),Error(`Failed to decrypt the request. Please verify your private key.`)}let f=Buffer.from(i,`base64`),p=Buffer.from(a,`base64`),m=f.subarray(0,-16),ee=f.subarray(-16);Z.info(`[decryptFlowRequest] Decrypting flow data with AES-128-GCM`);let h=n.createDecipheriv(`aes-128-gcm`,d,p);h.setAuthTag(ee);let g=Buffer.concat([h.update(m),h.final()]).toString(`utf-8`);return Z.info(`[decryptFlowRequest] Flow request decrypted successfully`),{decryptedBody:JSON.parse(g),aesKeyBuffer:d,initialVectorBuffer:p}}function Je(e,t,n){Z.info(`[encryptFlowResponse] Starting Flow response encryption`);let r=ze(`encryptFlowResponse`),i=[];for(let e of Array.from(n.entries()))i.push(~e[1]);try{Z.info(`[encryptFlowResponse] Encrypting response with AES-128-GCM`);let n=r.createCipheriv(`aes-128-gcm`,t,Buffer.from(i)),a=Buffer.concat([n.update(JSON.stringify(e||{}),`utf-8`),n.final(),n.getAuthTag()]).toString(`base64`);return Z.info(`[encryptFlowResponse] Flow response encrypted successfully`),a}catch(e){throw Z.error(`[encryptFlowResponse] Response encryption failed:`,e),Error(`Failed to encrypt response. Internal server error.`)}}const Ye=/-----BEGIN ([A-Z ]+)-----([\s\S]*?)-----END \1-----/;let Q;function Xe(e,t){let n=Ye.exec(e);if(!n)throw Error(`Failed to parse private key. Expected a PEM encoded PKCS#8 private key.`);let r=n[1];if(r===`PRIVATE KEY`)return X((n[2]??``).replace(/\s+/g,``));let i=J();if(!i)throw Error(`Failed to parse private key. "${r}" keys need node:crypto, which this runtime lacks. Convert the key to an unencrypted PKCS#8 key and keep it in a secret store:
14
- openssl pkcs8 -topk8 -nocrypt -in private.pem -out private-pkcs8.pem`);try{let n=i.createPrivateKey({key:e,format:`pem`,passphrase:t||void 0}).export({type:`pkcs8`,format:`der`});return new Uint8Array(n)}catch(e){throw Error(`Failed to parse private key. Error: ${e instanceof Error?e.message:e}`)}}function Ze(e,t){if(Q&&Q.pem===e&&Q.passphrase===t)return Q.key;let n=(async()=>Y().importKey(`pkcs8`,Xe(e,t),{name:`RSA-OAEP`,hash:`SHA-256`},!1,[`decrypt`]))();return Q={pem:e,passphrase:t,key:n},n.catch(()=>{Q?.key===n&&(Q=void 0)}),n}async function Qe(e,t){if(!t.FLOW_API_PRIVATE_PEM||t.FLOW_API_PRIVATE_PEM.trim()===``)throw Error(`Missing FLOW_API_PRIVATE_PEM. Please set the FLOW_API_PRIVATE_PEM environment variable or pass privatePem via config.`);let{encrypted_aes_key:n,encrypted_flow_data:r,initial_vector:i}=e??{};if(!n||!r||!i)throw Error(`Missing required encryption properties`);let a=t.FLOW_API_PRIVATE_PEM;a.includes(`\\n`)&&(a=a.replace(/\\n/g,`
15
- `));let o=Y(),s=await Ze(a,t.FLOW_API_PASSPHRASE||``),c;try{c=new Uint8Array(await o.decrypt({name:`RSA-OAEP`},s,X(n)))}catch(e){throw Z.error(`[decryptFlowRequestAsync] Failed to decrypt AES key:`,e),Error(`Failed to decrypt the request. Please verify your private key.`)}let l=X(i),u=await o.importKey(`raw`,c,{name:`AES-GCM`},!1,[`decrypt`]),d=await o.decrypt({name:`AES-GCM`,iv:l,tagLength:128},u,X(r));return{decryptedBody:JSON.parse(Ue(new Uint8Array(d))),aesKeyBuffer:c,initialVectorBuffer:l}}async function $e(e,t,n){let r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=~(n[e]??0)&255;try{let n=Y(),i=await n.importKey(`raw`,new Uint8Array(t),{name:`AES-GCM`},!1,[`encrypt`]),a=await n.encrypt({name:`AES-GCM`,iv:r,tagLength:128},i,He(JSON.stringify(e||{})));return We(new Uint8Array(a))}catch(e){throw Z.error(`[encryptFlowResponseAsync] Response encryption failed:`,e),Error(`Failed to encrypt response. Internal server error.`)}}function et(e){return typeof e==`object`&&!!e}function $(e){return typeof e==`string`}const tt=[`data_exchange`,`INIT`,`BACK`],nt=[`data_exchange`,`INIT`];function rt(e){if(!(`flow_token`in e&&$(e.flow_token)&&`action`in e))return!1;let{action:t,version:n,screen:r,data:i}=e,a=n===`3.0`,o=tt.includes(t),s=r===void 0||$(r)&&r!==`SUCCESS`,c=t===`data_exchange`||et(i);return a&&o&&s&&c}function it(e){if(!(`flow_token`in e&&$(e.flow_token)&&`action`in e))return!1;let{action:t,screen:n,data:r}=e,i=nt.includes(t),a=$(n),o=et(r)&&`error_key`in r&&$(r.error)&&`error_message`in r&&$(r.error_message);return i&&a&&o}function at(e){return`action`in e&&e.action===`ping`}export{i as AUTHORIZATION_ERROR_CODES,l as BLOCK_USER_ERROR_CODES,u as CALLING_ERROR_CODES,P as CUSTOMER_SERVICE_WINDOW_MS,c as FLOW_ERROR_CODES,F as FREE_ENTRY_POINT_WINDOW_MS,d as GROUP_ERROR_CODES,o as INTEGRITY_ERROR_CODES,H as Logger,Se as MAX_FREE_ENTRY_POINT_WINDOW_MS,s as SEND_MESSAGE_ERROR_CODES,a as THROTTLING_ERROR_CODES,n as WHATSAPP_ERROR_CODES,S as WhatsAppApiError,C as WhatsAppAuthorizationError,O as WhatsAppBlockUserError,k as WhatsAppCallingError,x as WhatsAppError,D as WhatsAppFlowError,A as WhatsAppGroupError,T as WhatsAppIntegrityError,ue as WhatsAppNetworkError,E as WhatsAppSendMessageError,w as WhatsAppThrottlingError,de as WhatsAppUnknownError,j as WhatsAppValidationError,e as buildFieldsQueryString,Ce as canSendFreeformMessage,U as compareMessageStatus,le as createWhatsAppApiError,qe as decryptFlowRequest,Qe as decryptFlowRequestAsync,Je as encryptFlowResponse,$e as encryptFlowResponseAsync,t as formatConfigTable,Ke as generateEncryption,V as getCustomerServiceWindow,we as getFreeEntryPointWindow,_ as isApiPermissionErrorCode,ie as isAuthorizationErrorCode,v as isBlockUserErrorCode,y as isCallingErrorCode,rt as isFlowDataExchangeRequest,ce as isFlowErrorCode,it as isFlowErrorRequest,at as isFlowPingRequest,b as isGroupErrorCode,oe as isIntegrityErrorCode,Oe as isMessageStatusAdvance,M as isMetaError,se as isSendMessageErrorCode,ae as isThrottlingErrorCode,fe as isWhatsAppApiErrorResponse,pe as isWhatsAppAuthorizationError,ve as isWhatsAppBlockUserError,ye as isWhatsAppCallingError,re as isWhatsAppErrorCode,_e as isWhatsAppFlowError,be as isWhatsAppGroupError,he as isWhatsAppIntegrityError,ge as isWhatsAppSendMessageError,me as isWhatsAppThrottlingError,xe as normalizeMetaError,Ae as objectToQueryString,Ie as parseRateLimitHeaders,Fe as parseRetryAfter,ke as resolveMessageStatus};
19
+ Your key format is not recognized. Please ensure it is in PKCS#8 format.`),Error(t)}}let d;try{Z.info(`[decryptFlowRequest] Decrypting AES key with RSA private key`),d=n.privateDecrypt({key:u,padding:n.constants.RSA_PKCS1_OAEP_PADDING,oaepHash:`sha256`},Buffer.from(r,`base64`)),Z.info(`[decryptFlowRequest] AES key decrypted successfully`)}catch(e){throw Z.error(`[decryptFlowRequest] Failed to decrypt AES key:`,e),Error(`Failed to decrypt the request. Please verify your private key.`)}let f=Buffer.from(i,`base64`),p=Buffer.from(a,`base64`),m=f.subarray(0,-16),ee=f.subarray(-16);Z.info(`[decryptFlowRequest] Decrypting flow data with AES-128-GCM`);let h=n.createDecipheriv(`aes-128-gcm`,d,p);h.setAuthTag(ee);let te=Buffer.concat([h.update(m),h.final()]).toString(`utf-8`);return Z.info(`[decryptFlowRequest] Flow request decrypted successfully`),{decryptedBody:JSON.parse(te),aesKeyBuffer:d,initialVectorBuffer:p}}function rt(e,t,n){Z.info(`[encryptFlowResponse] Starting Flow response encryption`);let r=Je(`encryptFlowResponse`),i=[];for(let e of Array.from(n.entries()))i.push(~e[1]);try{Z.info(`[encryptFlowResponse] Encrypting response with AES-128-GCM`);let n=r.createCipheriv(`aes-128-gcm`,t,Buffer.from(i)),a=Buffer.concat([n.update(JSON.stringify(e||{}),`utf-8`),n.final(),n.getAuthTag()]).toString(`base64`);return Z.info(`[encryptFlowResponse] Flow response encrypted successfully`),a}catch(e){throw Z.error(`[encryptFlowResponse] Response encryption failed:`,e),Error(`Failed to encrypt response. Internal server error.`)}}const it=/-----BEGIN ([A-Z ]+)-----([\s\S]*?)-----END \1-----/;let Q;function at(e,t){let n=it.exec(e);if(!n)throw Error(`Failed to parse private key. Expected a PEM encoded PKCS#8 private key.`);let r=n[1];if(r===`PRIVATE KEY`)return X((n[2]??``).replace(/\s+/g,``));let i=J();if(!i)throw Error(`Failed to parse private key. "${r}" keys need node:crypto, which this runtime lacks. Convert the key to an unencrypted PKCS#8 key and keep it in a secret store:
20
+ openssl pkcs8 -topk8 -nocrypt -in private.pem -out private-pkcs8.pem`);try{let n=i.createPrivateKey({key:e,format:`pem`,passphrase:t||void 0}).export({type:`pkcs8`,format:`der`});return new Uint8Array(n)}catch(e){throw Error(`Failed to parse private key. Error: ${e instanceof Error?e.message:e}`)}}function ot(e,t){if(Q&&Q.pem===e&&Q.passphrase===t)return Q.key;let n=(async()=>Y().importKey(`pkcs8`,at(e,t),{name:`RSA-OAEP`,hash:`SHA-256`},!1,[`decrypt`]))();return Q={pem:e,passphrase:t,key:n},n.catch(()=>{Q?.key===n&&(Q=void 0)}),n}async function st(e,t){if(!t.FLOW_API_PRIVATE_PEM||t.FLOW_API_PRIVATE_PEM.trim()===``)throw Error(`Missing FLOW_API_PRIVATE_PEM. Please set the FLOW_API_PRIVATE_PEM environment variable or pass privatePem via config.`);let{encrypted_aes_key:n,encrypted_flow_data:r,initial_vector:i}=e??{};if(!n||!r||!i)throw Error(`Missing required encryption properties`);let a=t.FLOW_API_PRIVATE_PEM;a.includes(`\\n`)&&(a=a.replace(/\\n/g,`
21
+ `));let o=Y(),s=await ot(a,t.FLOW_API_PASSPHRASE||``),c;try{c=new Uint8Array(await o.decrypt({name:`RSA-OAEP`},s,X(n)))}catch(e){throw Z.error(`[decryptFlowRequestAsync] Failed to decrypt AES key:`,e),Error(`Failed to decrypt the request. Please verify your private key.`)}let l=X(i),u=await o.importKey(`raw`,c,{name:`AES-GCM`},!1,[`decrypt`]),d=await o.decrypt({name:`AES-GCM`,iv:l,tagLength:128},u,X(r));return{decryptedBody:JSON.parse(Qe(new Uint8Array(d))),aesKeyBuffer:c,initialVectorBuffer:l}}async function ct(e,t,n){let r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=~(n[e]??0)&255;try{let n=Y(),i=await n.importKey(`raw`,new Uint8Array(t),{name:`AES-GCM`},!1,[`encrypt`]),a=await n.encrypt({name:`AES-GCM`,iv:r,tagLength:128},i,Ze(JSON.stringify(e||{})));return $e(new Uint8Array(a))}catch(e){throw Z.error(`[encryptFlowResponseAsync] Response encryption failed:`,e),Error(`Failed to encrypt response. Internal server error.`)}}function lt(e){return typeof e==`object`&&!!e}function $(e){return typeof e==`string`}const ut=[`data_exchange`,`INIT`,`BACK`],dt=[`data_exchange`,`INIT`];function ft(e){if(!(`flow_token`in e&&$(e.flow_token)&&`action`in e))return!1;let{action:t,version:n,screen:r,data:i}=e,a=n===`3.0`,o=ut.includes(t),s=r===void 0||$(r)&&r!==`SUCCESS`,c=t===`data_exchange`||lt(i);return a&&o&&s&&c}function pt(e){if(!(`flow_token`in e&&$(e.flow_token)&&`action`in e))return!1;let{action:t,screen:n,data:r}=e,i=dt.includes(t),a=$(n),o=lt(r)&&`error_key`in r&&$(r.error)&&`error_message`in r&&$(r.error_message);return i&&a&&o}function mt(e){return`action`in e&&e.action===`ping`}export{i as AUTHORIZATION_ERROR_CODES,l as BLOCK_USER_ERROR_CODES,u as CALLING_ERROR_CODES,N as CUSTOMER_SERVICE_WINDOW_MS,c as FLOW_ERROR_CODES,P as FREE_ENTRY_POINT_WINDOW_MS,d as GROUP_ERROR_CODES,o as INTEGRITY_ERROR_CODES,V as Logger,Ce as MAX_FREE_ENTRY_POINT_WINDOW_MS,s as SEND_MESSAGE_ERROR_CODES,a as THROTTLING_ERROR_CODES,n as WHATSAPP_ERROR_CODES,x as WhatsAppApiError,S as WhatsAppAuthorizationError,D as WhatsAppBlockUserError,O as WhatsAppCallingError,b as WhatsAppError,E as WhatsAppFlowError,k as WhatsAppGroupError,w as WhatsAppIntegrityError,de as WhatsAppNetworkError,T as WhatsAppSendMessageError,C as WhatsAppThrottlingError,fe as WhatsAppUnknownError,A as WhatsAppValidationError,Re as bold,e as buildFieldsQueryString,We as bulletList,we as canSendFreeformMessage,H as compareMessageStatus,ue as createWhatsAppApiError,nt as decryptFlowRequest,st as decryptFlowRequestAsync,rt as encryptFlowResponse,ct as encryptFlowResponseAsync,t as formatConfigTable,tt as generateEncryption,B as getCustomerServiceWindow,Te as getFreeEntryPointWindow,Ve as inlineCode,g as isApiPermissionErrorCode,ae as isAuthorizationErrorCode,le as isBlockUserErrorCode,v as isCallingErrorCode,ft as isFlowDataExchangeRequest,_ as isFlowErrorCode,pt as isFlowErrorRequest,mt as isFlowPingRequest,y as isGroupErrorCode,se as isIntegrityErrorCode,ke as isMessageStatusAdvance,j as isMetaError,ce as isSendMessageErrorCode,oe as isThrottlingErrorCode,pe as isWhatsAppApiErrorResponse,me as isWhatsAppAuthorizationError,ye as isWhatsAppBlockUserError,be as isWhatsAppCallingError,ie as isWhatsAppErrorCode,ve as isWhatsAppFlowError,xe as isWhatsAppGroupError,ge as isWhatsAppIntegrityError,_e as isWhatsAppSendMessageError,he as isWhatsAppThrottlingError,ze as italic,He as monospace,Se as normalizeMetaError,Ge as numberedList,je as objectToQueryString,Le as parseRateLimitHeaders,Ie as parseRetryAfter,Ue as quote,Ae as resolveMessageStatus,Be as strikethrough};
16
22
  //# sourceMappingURL=index.js.map