meta-cloud-api 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/dist/base.d.ts +19 -0
  2. package/dist/base.d.ts.map +1 -0
  3. package/dist/chunk-PECeCxCb.js +15 -0
  4. package/dist/config.d.ts +80 -0
  5. package/dist/config.d.ts.map +1 -0
  6. package/dist/enums.d.ts +668 -0
  7. package/dist/enums.d.ts.map +1 -0
  8. package/dist/enums.js +681 -0
  9. package/dist/enums.js.map +1 -0
  10. package/dist/httpsClient.d.ts +21 -0
  11. package/dist/httpsClient.d.ts.map +1 -0
  12. package/dist/index.d.ts +4386 -27
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +3436 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/logger.d.ts +11 -0
  17. package/dist/logger.d.ts.map +1 -0
  18. package/dist/request.d.ts +52 -0
  19. package/dist/request.d.ts.map +1 -0
  20. package/package.json +11 -118
  21. package/dist/BusinessProfileApi-C_sEOrWM.d.ts +0 -353
  22. package/dist/EncryptionApi-CcCfeK2b.d.ts +0 -22
  23. package/dist/FlowApi-DDHrFT_Q.d.ts +0 -136
  24. package/dist/MediaApi-CY9RVo7u.d.ts +0 -90
  25. package/dist/MessageApi-CX_jN8da.d.ts +0 -171
  26. package/dist/PhoneNumberApi-B-hY7g1M.d.ts +0 -142
  27. package/dist/QrCodeApi-DRICKN04.d.ts +0 -98
  28. package/dist/RegistrationApi-CFPzU1Vw.d.ts +0 -47
  29. package/dist/TemplateApi-fCIlzBtK.d.ts +0 -161
  30. package/dist/TwoStepVerificationApi-C0jpAKfu.d.ts +0 -33
  31. package/dist/WabaApi-x5PhsLT3.d.ts +0 -175
  32. package/dist/WebhookProcessor-DEIZ2PRU.d.ts +0 -707
  33. package/dist/WhatsApp-BFsBgjJO.d.ts +0 -82
  34. package/dist/api/encryption/index.d.ts +0 -10
  35. package/dist/api/encryption/index.js +0 -2
  36. package/dist/api/encryption/index.js.map +0 -1
  37. package/dist/api/flow/index.d.ts +0 -11
  38. package/dist/api/flow/index.js +0 -2
  39. package/dist/api/flow/index.js.map +0 -1
  40. package/dist/api/index.d.ts +0 -18
  41. package/dist/api/index.js +0 -2
  42. package/dist/api/index.js.map +0 -1
  43. package/dist/api/media/index.d.ts +0 -10
  44. package/dist/api/media/index.js +0 -2
  45. package/dist/api/media/index.js.map +0 -1
  46. package/dist/api/messages/builders/index.d.ts +0 -536
  47. package/dist/api/messages/builders/index.js +0 -4
  48. package/dist/api/messages/builders/index.js.map +0 -1
  49. package/dist/api/messages/index.d.ts +0 -10
  50. package/dist/api/messages/index.js +0 -2
  51. package/dist/api/messages/index.js.map +0 -1
  52. package/dist/api/phone/index.d.ts +0 -10
  53. package/dist/api/phone/index.js +0 -2
  54. package/dist/api/phone/index.js.map +0 -1
  55. package/dist/api/profile/index.d.ts +0 -10
  56. package/dist/api/profile/index.js +0 -2
  57. package/dist/api/profile/index.js.map +0 -1
  58. package/dist/api/qrCode/index.d.ts +0 -10
  59. package/dist/api/qrCode/index.js +0 -2
  60. package/dist/api/qrCode/index.js.map +0 -1
  61. package/dist/api/registration/index.d.ts +0 -10
  62. package/dist/api/registration/index.js +0 -2
  63. package/dist/api/registration/index.js.map +0 -1
  64. package/dist/api/template/index.d.ts +0 -21
  65. package/dist/api/template/index.js +0 -2
  66. package/dist/api/template/index.js.map +0 -1
  67. package/dist/api/twoStepVerification/index.d.ts +0 -10
  68. package/dist/api/twoStepVerification/index.js +0 -2
  69. package/dist/api/twoStepVerification/index.js.map +0 -1
  70. package/dist/api/waba/index.d.ts +0 -10
  71. package/dist/api/waba/index.js +0 -2
  72. package/dist/api/waba/index.js.map +0 -1
  73. package/dist/base-BV6DyzGS.d.ts +0 -18
  74. package/dist/chunk-5577QQ7V.js +0 -2
  75. package/dist/chunk-5577QQ7V.js.map +0 -1
  76. package/dist/chunk-6DFC5L3X.js +0 -2
  77. package/dist/chunk-6DFC5L3X.js.map +0 -1
  78. package/dist/chunk-7QBIZCJ4.js +0 -2
  79. package/dist/chunk-7QBIZCJ4.js.map +0 -1
  80. package/dist/chunk-AMHQGG6Z.js +0 -2
  81. package/dist/chunk-AMHQGG6Z.js.map +0 -1
  82. package/dist/chunk-BAOZ4U74.js +0 -10
  83. package/dist/chunk-BAOZ4U74.js.map +0 -1
  84. package/dist/chunk-CRZ7EUYR.js +0 -2
  85. package/dist/chunk-CRZ7EUYR.js.map +0 -1
  86. package/dist/chunk-FKXSL2JK.js +0 -3
  87. package/dist/chunk-FKXSL2JK.js.map +0 -1
  88. package/dist/chunk-FSKBLPGE.js +0 -2
  89. package/dist/chunk-FSKBLPGE.js.map +0 -1
  90. package/dist/chunk-GM63NGNV.js +0 -2
  91. package/dist/chunk-GM63NGNV.js.map +0 -1
  92. package/dist/chunk-IYSR44P6.js +0 -2
  93. package/dist/chunk-IYSR44P6.js.map +0 -1
  94. package/dist/chunk-J2JPTKU6.js +0 -2
  95. package/dist/chunk-J2JPTKU6.js.map +0 -1
  96. package/dist/chunk-JC6YMVID.js +0 -2
  97. package/dist/chunk-JC6YMVID.js.map +0 -1
  98. package/dist/chunk-JPAV644F.js +0 -2
  99. package/dist/chunk-JPAV644F.js.map +0 -1
  100. package/dist/chunk-JXCLRKQ7.js +0 -2
  101. package/dist/chunk-JXCLRKQ7.js.map +0 -1
  102. package/dist/chunk-KMAH6636.js +0 -2
  103. package/dist/chunk-KMAH6636.js.map +0 -1
  104. package/dist/chunk-L4ESAO2S.js +0 -2
  105. package/dist/chunk-L4ESAO2S.js.map +0 -1
  106. package/dist/chunk-LV3TULSI.js +0 -2
  107. package/dist/chunk-LV3TULSI.js.map +0 -1
  108. package/dist/chunk-MJEG3K4V.js +0 -2
  109. package/dist/chunk-MJEG3K4V.js.map +0 -1
  110. package/dist/chunk-PHPQ5HP3.js +0 -2
  111. package/dist/chunk-PHPQ5HP3.js.map +0 -1
  112. package/dist/chunk-RIL6QABY.js +0 -2
  113. package/dist/chunk-RIL6QABY.js.map +0 -1
  114. package/dist/chunk-RWCVPWRC.js +0 -2
  115. package/dist/chunk-RWCVPWRC.js.map +0 -1
  116. package/dist/chunk-SNNRWNGZ.js +0 -2
  117. package/dist/chunk-SNNRWNGZ.js.map +0 -1
  118. package/dist/chunk-U5FBZ6UB.js +0 -3
  119. package/dist/chunk-U5FBZ6UB.js.map +0 -1
  120. package/dist/chunk-VHAODWCN.js +0 -2
  121. package/dist/chunk-VHAODWCN.js.map +0 -1
  122. package/dist/chunk-ZMNXRMWK.js +0 -2
  123. package/dist/chunk-ZMNXRMWK.js.map +0 -1
  124. package/dist/common-B8kp4RdL.d.ts +0 -403
  125. package/dist/common-CGbls9Y8.d.ts +0 -425
  126. package/dist/core/webhook/frameworks/express.d.ts +0 -53
  127. package/dist/core/webhook/frameworks/express.js +0 -2
  128. package/dist/core/webhook/frameworks/express.js.map +0 -1
  129. package/dist/core/webhook/frameworks/nextjs-app.d.ts +0 -48
  130. package/dist/core/webhook/frameworks/nextjs-app.js +0 -2
  131. package/dist/core/webhook/frameworks/nextjs-app.js.map +0 -1
  132. package/dist/core/webhook/frameworks/nextjs.d.ts +0 -49
  133. package/dist/core/webhook/frameworks/nextjs.js +0 -2
  134. package/dist/core/webhook/frameworks/nextjs.js.map +0 -1
  135. package/dist/core/webhook/index.d.ts +0 -29
  136. package/dist/core/webhook/index.js +0 -2
  137. package/dist/core/webhook/index.js.map +0 -1
  138. package/dist/core/whatsapp/index.d.ts +0 -42
  139. package/dist/core/whatsapp/index.js +0 -2
  140. package/dist/core/whatsapp/index.js.map +0 -1
  141. package/dist/enums-DIimUG6s.d.ts +0 -707
  142. package/dist/factory-kNha6WaY.d.ts +0 -200
  143. package/dist/handler-DbySwF0E.d.ts +0 -20
  144. package/dist/httpsClient-Cbd2Y6mg.d.ts +0 -19
  145. package/dist/isMetaError-CQLXyEL4.d.ts +0 -63
  146. package/dist/logger-BdE0Vyim.d.ts +0 -9
  147. package/dist/request-CUjrMn8R.d.ts +0 -50
  148. package/dist/types/config.d.ts +0 -78
  149. package/dist/types/config.js +0 -2
  150. package/dist/types/config.js.map +0 -1
  151. package/dist/types/enums.d.ts +0 -1
  152. package/dist/types/enums.js +0 -2
  153. package/dist/types/enums.js.map +0 -1
  154. package/dist/types/index.d.ts +0 -6
  155. package/dist/types/index.js +0 -2
  156. package/dist/types/index.js.map +0 -1
  157. package/dist/utils/index.d.ts +0 -40
  158. package/dist/utils/index.js +0 -2
  159. package/dist/utils/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/webhook/utils/webhookUtils.ts","../src/core/webhook/WebhookProcessor.ts"],"names":["LIB_NAME","LOGGER","Logger","processWebhookMessages","request","whatsapp","handlers","body","errorMsg","errors","entry","changes","change","processMessages","error","processFlowRequest","config","flowHandlers","signature","verifySignature","data","decryptedBody","decryptFlowRequest","handler","isFlowPingRequest","isFlowErrorRequest","isFlowDataExchangeRequest","result","encryptedResponse","encryptFlowResponse","verificationToken","expectedSignature","crypto","constructFullUrl","headers","url","protocol","host","waba_id","value","metadata","contacts","wabaId","displayPhoneNumber","phoneNumberId","profileName","statuses","status","processedStatus","executeHandler","messages","message","messageType","processedMessage","handlerType","encrypted_aes_key","encrypted_flow_data","initial_vector","privatePem","passphrase","privateKey","decryptedAesKey","flowDataBuffer","initialVectorBuffer","encrypted_flow_data_body","encrypted_flow_data_tag","decipher","decryptedJSONString","response","aesKeyBuffer","flipped_iv","pair","cipher","WebhookProcessor","importConfig","WhatsApp","mode","token","challenge","webResponse","contentType","type"],"mappings":"6JAUA,IAAMA,CAAAA,CAAW,eAAA,CACXC,CAAAA,CAAS,IAAIC,CAAAA,CAAOF,CAAAA,CAAU,OAAA,CAAQ,GAAA,CAAI,KAAA,GAAU,MAAM,EAQhE,eAAsBG,CAAAA,CAClBC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAKiB,CACjB,GAAI,CACAL,CAAAA,CAAO,IAAA,CAAK,qCAAqC,CAA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AAAxE,CAAAA,CACA,OAAA,CAAS,CAAE,cAAA,CAAgByE,CAAY,CAC3C,CACJ,CAAA,MAASlE,CAAAA,CAAO,CACZ,OAAAb,CAAAA,CAAO,GAAA,CAAI,CAAA,uBAAA,EAA0Ba,CAAK,CAAA,CAAE,CAAA,CACrC,CACH,MAAA,CAAQ,GAAA,CACR,IAAA,CAAM,IAAA,CAAK,SAAA,CAAU,CAAE,KAAA,CAAO,uBAAwB,CAAC,CAAA,CACvD,OAAA,CAAS,CAAE,cAAA,CAAgB,kBAAmB,CAClD,CACJ,CACJ,CAEA,SAAA,CAAUmE,CAAAA,CAAwB1D,CAAAA,CAA+B,CAC7D,IAAA,CAAK,eAAA,CAAgB,GAAA,CAAI0D,CAAAA,CAAM1D,CAAO,CAAA,CACtCtB,CAAAA,CAAO,GAAA,CAAI,CAAA,+BAAA,EAAkCgF,CAAI,CAAA,CAAE,EACvD,CAEA,mBAAA,CAAoB1D,CAAAA,CAA+B,CAC/C,IAAA,CAAK,iBAAA,CAAoBA,CAAAA,CACzBtB,CAAAA,CAAO,GAAA,CAAI,gCAAgC,EAC/C,CAEA,oBAAA,CAAqBsB,CAAAA,CAA+B,CAChD,IAAA,CAAK,mBAAqBA,CAAAA,CAC1BtB,CAAAA,CAAO,GAAA,CAAI,iCAAiC,EAChD,CAEA,MAAA,CAAOgF,CAAAA,CAAoB1D,CAAAA,CAA4B,CACnD,IAAA,CAAK,YAAA,CAAa,GAAA,CAAI0D,CAAAA,CAAM1D,CAAO,CAAA,CACnCtB,EAAO,GAAA,CAAI,CAAA,4BAAA,EAA+BgF,CAAI,CAAA,CAAE,EACpD,CAEA,SAAA,EAAsB,CAClB,OAAO,IAAA,CAAK,MAChB,CAEA,SAAA,EAA4B,CACxB,OAAO,IAAA,CAAK,MAChB,CACJ","file":"chunk-U5FBZ6UB.js","sourcesContent":["import crypto from 'crypto';\nimport { FlowEndpointRequest } from '../../../api/flow';\nimport { FlowTypeEnum } from '../../../api/flow/types';\nimport { WabaConfigType } from '../../../types/config';\nimport { MessageTypesEnum } from '../../../types/enums';\nimport { isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest } from '../../../utils/flowTypeGuards';\nimport Logger from '../../../utils/logger';\nimport { WhatsApp } from '../../whatsapp';\nimport { WebhookMessage, WebhookMessageValue } from '../types';\n\nconst LIB_NAME = 'WEBHOOK_UTILS';\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true');\n\nexport type MessageHandler = (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>;\nexport type FlowHandler = (whatsapp: WhatsApp, request: FlowEndpointRequest) => any | Promise<any>;\n\n/**\n * Process webhook messages\n */\nexport async function processWebhookMessages(\n request: Request,\n whatsapp: WhatsApp,\n handlers: {\n messageHandlers: Map<MessageTypesEnum, MessageHandler>;\n preProcessHandler?: MessageHandler;\n postProcessHandler?: MessageHandler;\n },\n): Promise<Response> {\n try {\n LOGGER.info('Processing webhook messages request');\n const body = await request.json();\n LOGGER.info('Webhook request body:', body);\n\n // Check this is a WhatsApp Business Account webhook\n if (body.object !== 'whatsapp_business_account') {\n const errorMsg = 'Received webhook for non-WhatsApp event';\n LOGGER.warn(errorMsg, { body });\n return new Response(JSON.stringify({ error: errorMsg }), { status: 404 });\n }\n\n const errors: string[] = [];\n\n // Process each entry\n for (const entry of body.entry) {\n try {\n LOGGER.info('Processing webhook entry:', { entryId: entry.id });\n const changes = entry.changes;\n for (const change of changes) {\n if (change.field === 'messages') {\n LOGGER.info('Processing messages change:', { change });\n await processMessages(entry.id, change.value, whatsapp, handlers);\n }\n }\n } catch (error) {\n const errorMsg = `Error processing webhook: ${error}`;\n LOGGER.error(errorMsg, { entry, error });\n errors.push(errorMsg);\n }\n }\n\n LOGGER.info('Webhook processing complete', { errorCount: errors.length });\n return new Response(errors.length > 0 ? JSON.stringify({ errors }) : null, { status: 200 });\n } catch (error) {\n LOGGER.error('Error processing webhook:', error);\n return new Response(JSON.stringify({ error: 'Internal Server Error' }), { status: 500 });\n }\n}\n\n/**\n * Handle flow requests\n */\nexport async function processFlowRequest(\n request: Request,\n config: WabaConfigType,\n whatsapp: WhatsApp,\n flowHandlers: Map<FlowTypeEnum, FlowHandler>,\n): Promise<Response> {\n try {\n LOGGER.info('Processing flow request');\n const body = await request.text();\n const signature = request.headers.get('x-hub-signature-256');\n LOGGER.info('Flow request signature:', { signature });\n\n // Validate request signature\n if (!verifySignature(body, signature, config.WEBHOOK_VERIFICATION_TOKEN || '')) {\n LOGGER.warn('Invalid request signature', { signature });\n return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 });\n }\n\n const data = JSON.parse(body);\n LOGGER.info('Flow request data:', data);\n\n // Decrypt the request\n const { decryptedBody } = decryptFlowRequest(data, config);\n LOGGER.info('Decrypted flow request:', decryptedBody);\n\n // Get the flow handler\n const handler = flowHandlers.get(FlowTypeEnum.All);\n if (!handler) {\n LOGGER.warn('No handler registered for flow action:', { action: decryptedBody.action });\n return new Response(JSON.stringify({ error: 'Handler not found' }), { status: 404 });\n }\n\n // Handle different flow types\n if (isFlowPingRequest(decryptedBody)) {\n LOGGER.info('Handling flow ping request');\n return new Response(\n JSON.stringify({\n version: '3.0',\n data: { status: 'active' },\n }),\n { status: 200 },\n );\n }\n\n if (isFlowErrorRequest(decryptedBody)) {\n LOGGER.warn('Flow error request received:', decryptedBody);\n return new Response(null, { status: 200 });\n }\n\n if (isFlowDataExchangeRequest(decryptedBody)) {\n LOGGER.info('Processing flow data exchange request');\n const result = await handler(whatsapp, decryptedBody);\n LOGGER.info('Flow handler result:', result);\n\n const encryptedResponse = encryptFlowResponse(\n result,\n Buffer.from(data.aes_key, 'base64'),\n Buffer.from(data.initial_vector, 'base64'),\n );\n LOGGER.info('Encrypted flow response generated');\n\n return new Response(JSON.stringify(encryptedResponse), { status: 200 });\n }\n\n LOGGER.warn('Unknown flow request type:', decryptedBody);\n return new Response(JSON.stringify({ error: 'Unknown request type' }), { status: 400 });\n } catch (error) {\n LOGGER.error('Error handling flow request:', error);\n return new Response(JSON.stringify({ error: 'Internal server error' }), { status: 500 });\n }\n}\n\n/**\n * Verify webhook signature\n */\nfunction verifySignature(body: string, signature: string | null, verificationToken: string): boolean {\n if (!signature) {\n LOGGER.warn('Missing signature in request');\n return false;\n }\n\n LOGGER.info('Signature verification details:', {\n bodyLength: body.length,\n verificationTokenLength: verificationToken.length,\n rawSignature: signature,\n cleanedSignature: signature.replace('sha256=', ''),\n });\n\n const expectedSignature = crypto.createHmac('sha256', verificationToken).update(body).digest('hex');\n LOGGER.info('Signature verification:', {\n received: signature.replace('sha256=', ''),\n expected: expectedSignature,\n });\n\n return crypto.timingSafeEqual(Buffer.from(signature.replace('sha256=', '')), Buffer.from(expectedSignature));\n}\n\n/**\n * Constructs a full URL from framework-specific request headers and URL\n * @param headers - Request headers containing host and protocol information\n * @param url - Relative URL path\n * @returns Full URL string\n */\nexport function constructFullUrl(headers: Record<string, string | string[] | undefined>, url?: string): string {\n const protocol = headers['x-forwarded-proto'] || 'http';\n const host = headers.host || 'localhost';\n const path = url || '/';\n return `${protocol}://${host}${path}`;\n}\n\n/**\n * Private helper functions\n */\nasync function processMessages(\n waba_id: string,\n value: WebhookMessageValue,\n whatsapp: WhatsApp,\n handlers: {\n messageHandlers: Map<MessageTypesEnum, MessageHandler>;\n preProcessHandler?: MessageHandler;\n postProcessHandler?: MessageHandler;\n },\n): Promise<void> {\n LOGGER.info('Processing messages:', { waba_id, value });\n\n const metadata = value.metadata;\n const contacts = value.contacts;\n const wabaId = waba_id;\n const displayPhoneNumber = metadata?.display_phone_number || '';\n const phoneNumberId = metadata?.phone_number_id || '';\n const profileName = contacts?.[0]?.profile?.name || '';\n\n if (value.statuses && value.statuses.length > 0) {\n LOGGER.info('Processing statuses:', { statusCount: value.statuses.length });\n const statuses = value.statuses;\n for (const status of statuses) {\n const processedStatus: WebhookMessage = {\n wabaId,\n id: status.id,\n from: status.recipient_id,\n timestamp: status.timestamp,\n type: MessageTypesEnum.Statuses,\n phoneNumberId,\n displayPhoneNumber,\n profileName,\n statuses: value.statuses[0],\n originalData: status,\n };\n\n LOGGER.info('Processing status:', processedStatus);\n await executeHandler(\n handlers.messageHandlers.get(MessageTypesEnum.Statuses),\n whatsapp,\n processedStatus,\n MessageTypesEnum.Statuses,\n );\n }\n return;\n }\n\n if (value.messages && value.messages.length > 0) {\n LOGGER.info('Processing messages:', { messageCount: value.messages.length });\n const messages = value.messages;\n\n for (const message of messages) {\n const messageType = message.type;\n LOGGER.info('Processing message:', { messageType, messageId: message.id });\n\n const processedMessage: WebhookMessage = {\n wabaId,\n id: message.id,\n from: message.from,\n timestamp: message.timestamp,\n type: message.type,\n phoneNumberId,\n displayPhoneNumber,\n profileName,\n originalData: message,\n };\n\n switch (messageType) {\n case MessageTypesEnum.Text:\n processedMessage.text = message.text;\n break;\n case MessageTypesEnum.Image:\n processedMessage.image = message.image;\n break;\n case MessageTypesEnum.Video:\n processedMessage.video = message.video;\n break;\n case MessageTypesEnum.Audio:\n processedMessage.audio = message.audio;\n break;\n case MessageTypesEnum.Document:\n processedMessage.document = message.document;\n break;\n case MessageTypesEnum.Sticker:\n processedMessage.sticker = message.sticker;\n break;\n case MessageTypesEnum.Location:\n processedMessage.location = message.location;\n break;\n case MessageTypesEnum.Contacts:\n processedMessage.contacts = message.contacts;\n break;\n case MessageTypesEnum.Interactive:\n processedMessage.interactive = message.interactive;\n break;\n case MessageTypesEnum.Button:\n processedMessage.button = message.button;\n break;\n case MessageTypesEnum.Order:\n processedMessage.order = message.order;\n break;\n case MessageTypesEnum.System:\n processedMessage.system = message.system;\n break;\n case MessageTypesEnum.Reaction:\n processedMessage.reaction = message.reaction;\n break;\n default:\n LOGGER.warn('Unknown message type:', { messageType });\n break;\n }\n\n // Execute handlers in sequence\n LOGGER.info('Executing message handlers');\n await executeHandler(handlers.preProcessHandler, whatsapp, processedMessage, 'pre-process');\n await executeHandler(handlers.messageHandlers.get(messageType), whatsapp, processedMessage, messageType);\n await executeHandler(handlers.postProcessHandler, whatsapp, processedMessage, 'post-process');\n }\n }\n}\n\nasync function executeHandler(\n handler: MessageHandler | undefined,\n whatsapp: WhatsApp,\n message: WebhookMessage,\n handlerType: string,\n): Promise<void> {\n if (handler) {\n try {\n LOGGER.info('Executing handler:', { handlerType, messageId: message.id });\n await handler(whatsapp, message);\n LOGGER.info('Handler execution complete:', { handlerType, messageId: message.id });\n } catch (error) {\n LOGGER.error(`Error in ${handlerType} handler:`, { error, messageId: message.id });\n }\n } else {\n LOGGER.info('No handler registered:', { handlerType });\n }\n}\n\nfunction decryptFlowRequest(\n body: any,\n config: WabaConfigType,\n): {\n decryptedBody: FlowEndpointRequest;\n aesKeyBuffer: Buffer;\n initialVectorBuffer: Buffer;\n} {\n LOGGER.info('Decrypting flow request');\n const { encrypted_aes_key, encrypted_flow_data, initial_vector } = body;\n\n if (!encrypted_aes_key || !encrypted_flow_data || !initial_vector) {\n LOGGER.error('Missing required encryption properties');\n throw new Error('Missing required encryption properties');\n }\n\n const privatePem = config.FLOW_API_PRIVATE_PEM.replace(/\\\\n/g, '\\n');\n const passphrase = config.FLOW_API_PASSPHRASE;\n\n const privateKey = crypto.createPrivateKey({ key: privatePem, passphrase });\n let decryptedAesKey: Buffer;\n\n try {\n LOGGER.info('Decrypting AES key');\n decryptedAesKey = crypto.privateDecrypt(\n {\n key: privateKey,\n padding: crypto.constants.RSA_PKCS1_OAEP_PADDING,\n oaepHash: 'sha256',\n },\n Buffer.from(encrypted_aes_key, 'base64'),\n );\n } catch (error) {\n LOGGER.error('Failed to decrypt AES key:', error);\n throw new Error('Failed to decrypt the request. Please verify your private key.');\n }\n\n const flowDataBuffer = Buffer.from(encrypted_flow_data, 'base64');\n const initialVectorBuffer = Buffer.from(initial_vector, 'base64');\n\n const TAG_LENGTH = 16;\n const encrypted_flow_data_body = flowDataBuffer.subarray(0, -TAG_LENGTH);\n const encrypted_flow_data_tag = flowDataBuffer.subarray(-TAG_LENGTH);\n\n LOGGER.info('Decrypting flow data');\n const decipher = crypto.createDecipheriv('aes-128-gcm', decryptedAesKey, initialVectorBuffer);\n decipher.setAuthTag(encrypted_flow_data_tag);\n\n const decryptedJSONString = Buffer.concat([decipher.update(encrypted_flow_data_body), decipher.final()]).toString(\n 'utf-8',\n );\n\n LOGGER.info('Flow request decryption complete');\n return {\n decryptedBody: JSON.parse(decryptedJSONString),\n aesKeyBuffer: decryptedAesKey,\n initialVectorBuffer,\n };\n}\n\nfunction encryptFlowResponse(response: any, aesKeyBuffer: Buffer, initialVectorBuffer: Buffer): string {\n LOGGER.info('Encrypting flow response');\n const flipped_iv: number[] = [];\n for (const pair of Array.from(initialVectorBuffer.entries())) {\n flipped_iv.push(~pair[1]);\n }\n\n try {\n const cipher = crypto.createCipheriv('aes-128-gcm', aesKeyBuffer, Buffer.from(flipped_iv));\n const encryptedResponse = Buffer.concat([\n cipher.update(JSON.stringify(response || {}), 'utf-8'),\n cipher.final(),\n cipher.getAuthTag(),\n ]).toString('base64');\n\n LOGGER.info('Flow response encryption complete');\n return encryptedResponse;\n } catch (error) {\n LOGGER.error('Response encryption error:', error);\n throw new Error('Failed to encrypt response. Internal server error.');\n }\n}\n","import { FlowTypeEnum } from '../../api/flow/types';\nimport { importConfig } from '../../config/importConfig';\nimport { WabaConfigType, WhatsAppConfig } from '../../types/config';\nimport { MessageTypesEnum } from '../../types/enums';\nimport Logger from '../../utils/logger';\nimport { WhatsApp } from '../whatsapp';\nimport { FlowHandler, MessageHandler, processFlowRequest, processWebhookMessages } from './utils/webhookUtils';\n\nconst LOGGER = new Logger('WEBHOOK_PROCESSOR', process.env.DEBUG === 'true');\n\nexport interface WebhookResponse {\n status: number;\n body: string;\n headers: Record<string, string>;\n}\n\nexport class WebhookProcessor {\n private config: WabaConfigType;\n private client: WhatsApp;\n private messageHandlers: Map<MessageTypesEnum, MessageHandler> = new Map();\n private preProcessHandler: MessageHandler | undefined = undefined;\n private postProcessHandler: MessageHandler | undefined = undefined;\n private flowHandlers: Map<FlowTypeEnum, FlowHandler> = new Map();\n\n constructor(config: WhatsAppConfig) {\n this.config = importConfig(config);\n this.client = new WhatsApp(config);\n LOGGER.log('WebhookProcessor instantiated');\n }\n\n async processVerification(\n mode: string | null,\n token: string | null,\n challenge: string | null,\n ): Promise<WebhookResponse> {\n if (mode === 'subscribe' && token === this.config.WEBHOOK_VERIFICATION_TOKEN) {\n return {\n status: 200,\n body: challenge || '',\n headers: { 'Content-Type': 'text/plain' },\n };\n }\n\n return {\n status: 403,\n body: JSON.stringify({ error: 'Forbidden' }),\n headers: { 'Content-Type': 'application/json' },\n };\n }\n\n async processWebhook(request: Request): Promise<WebhookResponse> {\n try {\n const webResponse = await processWebhookMessages(request, this.client, {\n messageHandlers: this.messageHandlers,\n preProcessHandler: this.preProcessHandler,\n postProcessHandler: this.postProcessHandler,\n });\n\n const body = await webResponse.text();\n const contentType = webResponse.headers.get('content-type') || 'application/json';\n\n return {\n status: webResponse.status,\n body,\n headers: { 'Content-Type': contentType },\n };\n } catch (error) {\n LOGGER.log(`Error processing webhook: ${error}`);\n return {\n status: 500,\n body: JSON.stringify({ error: 'Internal Server Error' }),\n headers: { 'Content-Type': 'application/json' },\n };\n }\n }\n\n async processFlow(request: Request): Promise<WebhookResponse> {\n try {\n const webResponse = await processFlowRequest(request, this.config, this.client, this.flowHandlers);\n const body = await webResponse.text();\n const contentType = webResponse.headers.get('content-type') || 'application/json';\n\n return {\n status: webResponse.status,\n body,\n headers: { 'Content-Type': contentType },\n };\n } catch (error) {\n LOGGER.log(`Error processing flow: ${error}`);\n return {\n status: 500,\n body: JSON.stringify({ error: 'Internal Server Error' }),\n headers: { 'Content-Type': 'application/json' },\n };\n }\n }\n\n onMessage(type: MessageTypesEnum, handler: MessageHandler): void {\n this.messageHandlers.set(type, handler);\n LOGGER.log(`Registered message handler for ${type}`);\n }\n\n onMessagePreProcess(handler: MessageHandler): void {\n this.preProcessHandler = handler;\n LOGGER.log('Registered pre-process handler');\n }\n\n onMessagePostProcess(handler: MessageHandler): void {\n this.postProcessHandler = handler;\n LOGGER.log('Registered post-process handler');\n }\n\n onFlow(type: FlowTypeEnum, handler: FlowHandler): void {\n this.flowHandlers.set(type, handler);\n LOGGER.log(`Registered flow handler for ${type}`);\n }\n\n getClient(): WhatsApp {\n return this.client;\n }\n\n getConfig(): WabaConfigType {\n return this.config;\n }\n}\n"]}
@@ -1,2 +0,0 @@
1
- import {a as a$1}from'./chunk-MJEG3K4V.js';import {a}from'./chunk-RIL6QABY.js';var p=class extends a{endpoint="message_templates";constructor(t,a){super(t,a);}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,a){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(a))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${a$1(t??{})}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${a$1(t)}`,this.config.REQUEST_TIMEOUT,null)}};function o(e){let t={type:"HEADER",format:e.format};return e.text&&(t.text=e.text),e.example&&(t.example=e.example),t}function n(e){let t={type:"BODY",text:e.text};return e.example&&(t.example=e.example),t}function m(e){return {type:"FOOTER",text:e.text}}function i(e){let t=[];if(e.phone_number&&t.push({type:"PHONE_NUMBER",text:e.phone_number.text,phone_number:e.phone_number.phone_number}),e.url){let a={type:"URL",text:e.url.text,url:e.url.url};e.url.example&&(a.example=[e.url.example]),t.push(a);}if(e.quick_reply&&e.quick_reply.forEach(a=>{t.push({type:"QUICK_REPLY",text:a.text});}),e.copy_code&&t.push({type:"COPY_CODE",example:e.copy_code.example}),e.flow){let a={type:"FLOW",text:e.flow.text};e.flow.flow_id&&(a.flow_id=e.flow.flow_id),e.flow.flow_name&&(a.flow_name=e.flow.flow_name),e.flow.flow_json&&(a.flow_json=e.flow.flow_json),e.flow.flow_action&&(a.flow_action=e.flow.flow_action),e.flow.navigate_screen&&(a.navigate_screen=e.flow.navigate_screen),t.push(a);}return e.mpm&&t.push({type:"MPM"}),e.otp&&t.push({type:"OTP"}),e.spm&&t.push({type:"SPM"}),t.length>0?[{type:"BUTTONS",buttons:t}]:[]}function f(e){return e.map(t=>{switch(t.type){case "text":return t.value;case "currency":return t.fallback_value;case "date_time":return t.fallback_value;case "image":case "video":case "document":return t.handle||t.link||"";case "location":return t.name||"";case "product":return t.product_retailer_id;default:return ""}})}function T(e){let t=[];if(e.header&&t.push(o(e.header)),e.body&&t.push(n(e.body)),e.footer&&t.push(m(e.footer)),e.buttons&&t.push(...i(e.buttons)),e.carousel){let a=[];e.carousel.cards.forEach((r,s)=>{if(r.image||r.video||r.product){let u=r.image?"IMAGE":r.video?"VIDEO":"DOCUMENT",d=r.image||r.video||r.product||"";a.push({type:"HEADER",format:u,example:{header_handle:[d]}});}r.body&&a.push({type:"BODY",text:r.body,example:r.bodyParameters?{body_text:[f(r.bodyParameters)]}:void 0}),r.buttons&&a.push(...i(r.buttons));}),t.push(...a);}return e.limitedTimeOffer&&t.push({type:"LIMITED_TIME_OFFER",limited_time_offer:{expiration_time_ms:e.limitedTimeOffer.expiration_time_ms}}),{name:e.name,language:e.language,category:e.category,components:t.length>0?t:void 0}}function y(e){let t=[],a="*{{1}}* is your verification code.";return e.add_security_recommendation&&(a+=" For your security, do not share this code."),e.code_expiration_minutes&&(a+=` This code expires in ${e.code_expiration_minutes} minutes.`),t.push({type:"BODY",text:a,example:{body_text:[["123456"]]}}),t.push({type:"BUTTONS",buttons:[{type:"OTP"}]}),{name:e.name,language:e.language,category:"AUTHENTICATION",components:t}}function h(e){let t=[],a="Your security code is *{{1}}*.";return e.add_security_recommendation&&(a+=" Do not share this code with anyone."),e.code_expiration_minutes&&(a+=` This code expires in ${e.code_expiration_minutes} minutes.`),t.push({type:"BODY",text:a,example:{body_text:[["ABCD1234"]]}}),e.copy_code_button&&t.push({type:"BUTTONS",buttons:[{type:"COPY_CODE",example:"ABCD1234"}]}),{name:e.name,language:e.language,category:"AUTHENTICATION",components:t}}function g(e){let t=[];return e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer)),t.push({type:"BUTTONS",buttons:[{type:"CATALOG",action:{thumbnail_product_retailer_id:e.thumbnail_product_retailer_id}}]}),{name:e.name,language:e.language,category:"MARKETING",components:t}}function _(e){let t=[];return e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer)),t.push({type:"BUTTONS",buttons:[{type:"COPY_CODE",example:e.coupon_code}]}),{name:e.name,language:e.language,category:"MARKETING",components:t}}function x(e){let t=[];return t.push({type:"LIMITED_TIME_OFFER",limited_time_offer:{expiration_time_ms:e.expiration_time_ms}}),e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer)),{name:e.name,language:e.language,category:"MARKETING",components:t}}function C(e){let t=[],a=[];return e.cards.forEach((r,s)=>{let u=[];u.push({type:"HEADER",format:r.header.format,example:r.header.example}),u.push(n(r.body)),r.buttons&&u.push(...i(r.buttons)),a.push({card_index:s,components:u});}),t.push({type:"CAROUSEL",cards:a}),{name:e.name,language:e.language,category:"MARKETING",components:t}}function O(e){let t=[];return e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer)),t.push({type:"BUTTONS",buttons:[{type:"MPM",action:{thumbnail_product_retailer_id:e.thumbnail_product_retailer_id,sections:e.sections}}]}),{name:e.name,language:e.language,category:"MARKETING",components:t}}function P(e){let t=[];e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer));let a=e.cards.map((r,s)=>({card_index:s,components:[{type:"HEADER",format:"PRODUCT",example:{header_handle:[r.product_retailer_id]}}]}));return t.push({type:"CAROUSEL",cards:a}),{name:e.name,language:e.language,category:"MARKETING",components:t}}function B(e){let t=[];return e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer)),t.push({type:"BUTTONS",buttons:[{type:"SPM",action:{product_retailer_id:e.product_retailer_id}}]}),{name:e.name,language:e.language,category:"MARKETING",components:t}}export{p as a,T as b,y as c,h as d,g as e,_ as f,x as g,C as h,O as i,P as j,B as k};//# sourceMappingURL=chunk-VHAODWCN.js.map
2
- //# sourceMappingURL=chunk-VHAODWCN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/api/template/TemplateApi.ts","../src/api/template/factories/index.ts"],"names":["TemplateApi","BaseAPI","config","client","templateId","template","params","objectToQueryString","createHeader","options","header","createBody","body","createFooter","createButtons","buttons","urlButton","qr","flowButton","formatParameterExamples","parameters","param","createTemplate","components","carouselComponents","card","index","format","handle","createOTPTemplate","bodyText","createAuthenticationTemplate","createCatalogTemplate","createCouponTemplate","createLimitedTimeOfferTemplate","createMediaCardCarouselTemplate","carouselCards","cardComponents","createMPMTemplate","createProductCardCarouselTemplate","createSPMTemplate"],"mappings":"+EAaA,IAAqBA,EAArB,cAAyCC,CAAiC,CACrD,QAAA,CAAW,oBAE5B,WAAA,CAAYC,CAAAA,CAAwBC,CAAAA,CAAwB,CACxD,MAAMD,CAAAA,CAAQC,CAAM,EACxB,CAEA,MAAM,WAAA,CAAYC,CAAAA,CAA+C,CAC7D,OAAO,KAAK,QAAA,CAAA,KAAA,CAA8B,CAAA,EAAGA,CAAU,CAAA,CAAA,CAAI,KAAK,MAAA,CAAO,eAAA,CAAgC,IAAI,CAC/G,CAEA,MAAM,cAAA,CAAeA,CAAAA,CAAoBC,CAAAA,CAAkE,CACvG,OAAO,IAAA,CAAK,QAAA,CAAA,MAAA,CAER,CAAA,EAAGD,CAAU,CAAA,CAAA,CACb,IAAA,CAAK,MAAA,CAAO,eAAA,CACZ,KAA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cesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponsePagination, ResponseSuccess } from '../../types/request';\nimport { objectToQueryString } from '../../utils/objectToQueryString';\nimport type {\n TemplateClass,\n TemplateDeleteParams,\n TemplateGetParams,\n TemplateRequestBody,\n TemplateResponse,\n} from './types';\n\nexport default class TemplateApi extends BaseAPI implements TemplateClass {\n private readonly endpoint = 'message_templates';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getTemplate(templateId: string): Promise<TemplateResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `${templateId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n async updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${templateId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async getTemplates(params?: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params ?? {})}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async createTemplate(template: TemplateRequestBody): Promise<TemplateResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { CategoryEnum } from '../../../types/enums';\nimport type {\n ComponentTypes,\n MediaCarouselCard,\n ProductCarouselCard,\n TemplateBody,\n TemplateButton,\n TemplateButtons,\n TemplateFooter,\n TemplateHeader,\n TemplateRequestBody,\n} from '../types';\nimport type {\n AuthenticationTemplateOptions,\n BodyOptions,\n ButtonOptions,\n CatalogTemplateOptions,\n CouponTemplateOptions,\n FooterOptions,\n HeaderOptions,\n LimitedTimeOfferTemplateOptions,\n MediaCardCarouselTemplateOptions,\n MPMTemplateOptions,\n OTPTemplateOptions,\n ProductCardCarouselTemplateOptions,\n SPMTemplateOptions,\n TemplateOptions,\n TemplateParameter,\n} from '../types';\n\n// Helper function to create header component\nfunction createHeader(options: HeaderOptions): TemplateHeader {\n const header: TemplateHeader = {\n type: 'HEADER',\n format: options.format,\n };\n\n if (options.text) {\n header.text = options.text;\n }\n\n if (options.example) {\n header.example = options.example;\n }\n\n return header;\n}\n\n// Helper function to create body component\nfunction createBody(options: BodyOptions): TemplateBody {\n const body: TemplateBody = {\n type: 'BODY',\n text: options.text,\n };\n\n if (options.example) {\n body.example = options.example;\n }\n\n return body;\n}\n\n// Helper function to create footer component\nfunction createFooter(options: FooterOptions): TemplateFooter {\n return {\n type: 'FOOTER',\n text: options.text,\n };\n}\n\n// Helper function to create buttons\nfunction createButtons(options: ButtonOptions): ComponentTypes[] {\n const buttons: TemplateButton[] = [];\n\n if (options.phone_number) {\n buttons.push({\n type: 'PHONE_NUMBER',\n text: options.phone_number.text,\n phone_number: options.phone_number.phone_number,\n });\n }\n\n if (options.url) {\n const urlButton: any = {\n type: 'URL',\n text: options.url.text,\n url: options.url.url,\n };\n if (options.url.example) {\n urlButton.example = [options.url.example];\n }\n buttons.push(urlButton);\n }\n\n if (options.quick_reply) {\n options.quick_reply.forEach((qr) => {\n buttons.push({\n type: 'QUICK_REPLY',\n text: qr.text,\n });\n });\n }\n\n if (options.copy_code) {\n buttons.push({\n type: 'COPY_CODE',\n example: options.copy_code.example,\n });\n }\n\n if (options.flow) {\n const flowButton: any = {\n type: 'FLOW',\n text: options.flow.text,\n };\n if (options.flow.flow_id) flowButton.flow_id = options.flow.flow_id;\n if (options.flow.flow_name) flowButton.flow_name = options.flow.flow_name;\n if (options.flow.flow_json) flowButton.flow_json = options.flow.flow_json;\n if (options.flow.flow_action) flowButton.flow_action = options.flow.flow_action;\n if (options.flow.navigate_screen) flowButton.navigate_screen = options.flow.navigate_screen;\n buttons.push(flowButton);\n }\n\n if (options.mpm) {\n buttons.push({ type: 'MPM' });\n }\n\n if (options.otp) {\n buttons.push({ type: 'OTP' });\n }\n\n if (options.spm) {\n buttons.push({ type: 'SPM' });\n }\n\n return buttons.length > 0\n ? [\n {\n type: 'BUTTONS',\n buttons: buttons,\n },\n ]\n : [];\n}\n\n// Helper function to format parameter examples\nfunction formatParameterExamples(parameters: TemplateParameter[]): string[] {\n return parameters.map((param) => {\n switch (param.type) {\n case 'text':\n return param.value;\n case 'currency':\n return param.fallback_value;\n case 'date_time':\n return param.fallback_value;\n case 'image':\n case 'video':\n case 'document':\n return param.handle || param.link || '';\n case 'location':\n return param.name || '';\n case 'product':\n return param.product_retailer_id;\n default:\n return '';\n }\n });\n}\n\n// Generic template factory\nexport function createTemplate(options: TemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader(options.header));\n }\n\n if (options.body) {\n components.push(createBody(options.body));\n }\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n if (options.buttons) {\n components.push(...createButtons(options.buttons));\n }\n\n if (options.carousel) {\n // Handle carousel components\n const carouselComponents: ComponentTypes[] = [];\n options.carousel.cards.forEach((card, index) => {\n if (card.image || card.video || card.product) {\n const format = card.image ? 'IMAGE' : card.video ? 'VIDEO' : 'DOCUMENT';\n const handle = card.image || card.video || card.product || '';\n carouselComponents.push({\n type: 'HEADER',\n format: format,\n example: {\n header_handle: [handle],\n },\n });\n }\n if (card.body) {\n carouselComponents.push({\n type: 'BODY',\n text: card.body,\n example: card.bodyParameters\n ? {\n body_text: [formatParameterExamples(card.bodyParameters)],\n }\n : undefined,\n });\n }\n if (card.buttons) {\n carouselComponents.push(...createButtons(card.buttons));\n }\n });\n components.push(...carouselComponents);\n }\n\n if (options.limitedTimeOffer) {\n components.push({\n type: 'LIMITED_TIME_OFFER',\n limited_time_offer: {\n expiration_time_ms: options.limitedTimeOffer.expiration_time_ms,\n },\n });\n }\n\n return {\n name: options.name,\n language: options.language,\n category: options.category,\n components: components.length > 0 ? components : undefined,\n };\n}\n\n// OTP Template Factory\nexport function createOTPTemplate(options: OTPTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add security recommendation if requested\n let bodyText = '*{{1}}* is your verification code.';\n if (options.add_security_recommendation) {\n bodyText += ' For your security, do not share this code.';\n }\n if (options.code_expiration_minutes) {\n bodyText += ` This code expires in ${options.code_expiration_minutes} minutes.`;\n }\n\n components.push({\n type: 'BODY',\n text: bodyText,\n example: {\n body_text: [['123456']], // Example OTP code\n },\n });\n\n // Add OTP button\n components.push({\n type: 'BUTTONS',\n buttons: [{ type: 'OTP' }],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Authentication,\n components,\n };\n}\n\n// Authentication Template Factory\nexport function createAuthenticationTemplate(options: AuthenticationTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add security message\n let bodyText = 'Your security code is *{{1}}*.';\n if (options.add_security_recommendation) {\n bodyText += ' Do not share this code with anyone.';\n }\n if (options.code_expiration_minutes) {\n bodyText += ` This code expires in ${options.code_expiration_minutes} minutes.`;\n }\n\n components.push({\n type: 'BODY',\n text: bodyText,\n example: {\n body_text: [['ABCD1234']], // Example auth code\n },\n });\n\n // Add copy code button if requested\n if (options.copy_code_button) {\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'COPY_CODE',\n example: 'ABCD1234',\n },\n ],\n });\n }\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Authentication,\n components,\n };\n}\n\n// Catalog Template Factory\nexport function createCatalogTemplate(options: CatalogTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add catalog button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'CATALOG',\n action: {\n thumbnail_product_retailer_id: options.thumbnail_product_retailer_id,\n },\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Coupon Template Factory\nexport function createCouponTemplate(options: CouponTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add copy code button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'COPY_CODE',\n example: options.coupon_code,\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Limited Time Offer Template Factory\nexport function createLimitedTimeOfferTemplate(options: LimitedTimeOfferTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add limited time offer component first\n components.push({\n type: 'LIMITED_TIME_OFFER',\n limited_time_offer: {\n expiration_time_ms: options.expiration_time_ms,\n },\n });\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Media Card Carousel Template Factory\nexport function createMediaCardCarouselTemplate(options: MediaCardCarouselTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add carousel component\n const carouselCards: MediaCarouselCard[] = [];\n options.cards.forEach((card, index) => {\n const cardComponents: (TemplateHeader | TemplateBody | TemplateButtons)[] = [];\n\n // Add header (media)\n cardComponents.push({\n type: 'HEADER' as const,\n format: card.header.format,\n example: card.header.example,\n });\n\n // Add body\n cardComponents.push(createBody(card.body));\n\n // Add buttons if any\n if (card.buttons) {\n cardComponents.push(...(createButtons(card.buttons) as TemplateButtons[]));\n }\n\n carouselCards.push({\n card_index: index,\n components: cardComponents,\n });\n });\n\n components.push({\n type: 'CAROUSEL',\n cards: carouselCards,\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// MPM (Multi-Product Message) Template Factory\nexport function createMPMTemplate(options: MPMTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add MPM button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'MPM',\n action: {\n thumbnail_product_retailer_id: options.thumbnail_product_retailer_id,\n sections: options.sections,\n },\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Product Card Carousel Template Factory\nexport function createProductCardCarouselTemplate(options: ProductCardCarouselTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add carousel with product cards\n const carouselCards: ProductCarouselCard[] = options.cards.map((card, index) => ({\n card_index: index,\n components: [\n {\n type: 'HEADER' as const,\n format: 'PRODUCT' as const,\n example: {\n header_handle: [card.product_retailer_id],\n },\n },\n ],\n }));\n\n components.push({\n type: 'CAROUSEL',\n cards: carouselCards,\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// SPM (Single-Product Message) Template Factory\nexport function createSPMTemplate(options: SPMTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add SPM button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'SPM',\n action: {\n product_retailer_id: options.product_retailer_id,\n },\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n"]}
@@ -1,2 +0,0 @@
1
- import {a}from'./chunk-5577QQ7V.js';var u=class extends a{constructor(e){super(e);}async handleGet(e,s,t){try{let{"hub.mode":n,"hub.verify_token":r,"hub.challenge":o}=e.query,a=await this.processVerification(n||null,r||null,o||null);return this.applyHeaders(a,s),s.status(a.status).send(a.body)}catch(n){return t(n),s}}async handlePost(e,s,t){try{let n=this.constructFullUrl(e.headers,e.url),r=new globalThis.Request(n,{method:e.method,headers:e.headers,body:JSON.stringify(e.body)}),o=await this.processWebhook(r);return this.applyHeaders(o,s),s.status(o.status).send(o.body)}catch(n){return t(n),s}}async handleFlow(e,s,t){try{let n=this.constructFullUrl(e.headers,e.url),r=new globalThis.Request(n,{method:e.method,headers:e.headers,body:e.method==="POST"?JSON.stringify(e.body):void 0}),o=await this.processFlow(r);return this.applyHeaders(o,s),s.status(o.status).send(o.body)}catch(n){return t(n),s}}getHandlers(){return {GET:(e,s,t)=>this.handleGet(e,s,t),POST:(e,s,t)=>this.handlePost(e,s,t),webhook:(e,s,t)=>this.autoRoute(e,s,t),flow:(e,s,t)=>this.handleFlow(e,s,t),processor:this.webhookProcessor}}};function x(i){return new u(i).getHandlers()}export{x as a};//# sourceMappingURL=chunk-ZMNXRMWK.js.map
2
- //# sourceMappingURL=chunk-ZMNXRMWK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/webhook/frameworks/express.ts"],"names":["ExpressWebhookHandler","BaseWebhookHandler","config","req","res","next","mode","token","challenge","result","error","fullUrl","webRequest","webhookHandler"],"mappings":"oCA8BA,IAAMA,CAAAA,CAAN,cAAoCC,CAAoD,CACpF,WAAA,CAAYC,CAAAA,CAA8B,CACtC,KAAA,CAAMA,CAAM,EAChB,CAEA,MAAgB,SAAA,CAAUC,CAAAA,CAAqBC,CAAAA,CAAsBC,CAAAA,CAA8C,CAC/G,GAAI,CACA,GAAM,CAAE,UAAA,CAAYC,CAAAA,CAAM,kBAAA,CAAoBC,CAAAA,CAAO,eAAA,CAAiBC,CAAU,CAAA,CAAIL,EAAI,KAAA,CAElFM,CAAAA,CAAS,MAAM,IAAA,CAAK,mBAAA,CACrBH,CAAAA,EAAmB,IAAA,CACnBC,CAAAA,EAAoB,IAAA,CACpBC,CAAAA,EAAwB,IAC7B,CAAA,CAEA,OAAA,IAAA,CAAK,YAAA,CAAaC,CAAAA,CAAQL,CAAG,EACtBA,CAAAA,CAAI,MAAA,CAAOK,CAAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAKA,CAAAA,CAAO,IAAI,CACrD,CAAA,MAASC,CAAAA,CAAO,CACZ,OAAAL,CAAAA,CAAKK,CAAK,CAAA,CACHN,CACX,CACJ,CAEA,MAAgB,UAAA,CACZD,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACwB,CACxB,GAAI,CACA,IAAMM,CAAAA,CAAU,IAAA,CAAK,gBAAA,CAAiBR,CAAAA,CAAI,OAAA,CAASA,EAAI,GAAG,CAAA,CACpDS,CAAAA,CAAa,IAAI,UAAA,CAAW,OAAA,CAAQD,CAAAA,CAAS,CAC/C,MAAA,CAAQR,CAAAA,CAAI,MAAA,CACZ,OAAA,CAASA,CAAAA,CAAI,OAAA,CACb,IAAA,CAAM,IAAA,CAAK,UAAUA,CAAAA,CAAI,IAAI,CACjC,CAAC,CAAA,CAEKM,CAAAA,CAAS,MAAM,IAAA,CAAK,cAAA,CAAeG,CAAU,CAAA,CACnD,OAAA,IAAA,CAAK,YAAA,CA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KC,CAAAA,CAAKC,CAAI,CAAA,CAGvG,OAAA,CAAS,CAACF,CAAAA,CAAqBC,EAAsBC,CAAAA,GAAuB,IAAA,CAAK,SAAA,CAAUF,CAAAA,CAAKC,CAAAA,CAAKC,CAAI,CAAA,CAGzG,IAAA,CAAM,CAACF,CAAAA,CAAqBC,CAAAA,CAAsBC,CAAAA,GAAuB,IAAA,CAAK,UAAA,CAAWF,CAAAA,CAAKC,CAAAA,CAAKC,CAAI,CAAA,CAGvG,SAAA,CAAW,IAAA,CAAK,gBACpB,CACJ,CACJ,CAAA,CAEO,SAASQ,CAAAA,CAAeX,CAAAA,CAA8B,CAEzD,OADgB,IAAIF,CAAAA,CAAsBE,CAAM,CAAA,CACjC,aACnB","file":"chunk-ZMNXRMWK.js","sourcesContent":["import { BaseRequest, BaseResponse, BaseWebhookConfig, BaseWebhookHandler } from './handler';\n\n// Express-like interfaces to avoid direct Express dependency\nexport interface ExpressRequest extends BaseRequest {\n method: string;\n url: string;\n headers: Record<string, string | string[] | undefined>;\n body?: any;\n query: Record<string, any>;\n rawBody?: any;\n}\n\nexport interface ExpressResponse extends BaseResponse<ExpressResponse> {\n status(code: number): ExpressResponse;\n json(data: any): ExpressResponse;\n send(data?: any): ExpressResponse;\n setHeader(name: string, value: string): void;\n}\n\nexport interface NextFunction {\n (error?: any): void;\n}\n\nexport interface ExpressWebhookConfig extends BaseWebhookConfig {\n path?: string;\n}\n\n/**\n * Express-specific webhook handler extending the base handler\n */\nclass ExpressWebhookHandler extends BaseWebhookHandler<ExpressRequest, ExpressResponse> {\n constructor(config: ExpressWebhookConfig) {\n super(config);\n }\n\n protected async handleGet(req: ExpressRequest, res: ExpressResponse, next: NextFunction): Promise<ExpressResponse> {\n try {\n const { 'hub.mode': mode, 'hub.verify_token': token, 'hub.challenge': challenge } = req.query;\n\n const result = await this.processVerification(\n (mode as string) || null,\n (token as string) || null,\n (challenge as string) || null,\n );\n\n this.applyHeaders(result, res);\n return res.status(result.status).send(result.body);\n } catch (error) {\n next(error);\n return res;\n }\n }\n\n protected async handlePost(\n req: ExpressRequest,\n res: ExpressResponse,\n next: NextFunction,\n ): Promise<ExpressResponse> {\n try {\n const fullUrl = this.constructFullUrl(req.headers, req.url);\n const webRequest = new globalThis.Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: JSON.stringify(req.body),\n });\n\n const result = await this.processWebhook(webRequest);\n this.applyHeaders(result, res);\n return res.status(result.status).send(result.body);\n } catch (error) {\n next(error);\n return res;\n }\n }\n\n protected async handleFlow(\n req: ExpressRequest,\n res: ExpressResponse,\n next: NextFunction,\n ): Promise<ExpressResponse> {\n try {\n const fullUrl = this.constructFullUrl(req.headers, req.url);\n const webRequest = new globalThis.Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: req.method === 'POST' ? JSON.stringify(req.body) : undefined,\n });\n\n const result = await this.processFlow(webRequest);\n this.applyHeaders(result, res);\n return res.status(result.status).send(result.body);\n } catch (error) {\n next(error);\n return res;\n }\n }\n\n getHandlers() {\n return {\n // Method handlers for clean destructuring\n GET: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => this.handleGet(req, res, next),\n POST: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => this.handlePost(req, res, next),\n\n // Auto-routing webhook handler\n webhook: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => this.autoRoute(req, res, next),\n\n // Flow handler\n flow: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => this.handleFlow(req, res, next),\n\n // Expose processor for handler registration\n processor: this.webhookProcessor,\n };\n }\n}\n\nexport function webhookHandler(config: ExpressWebhookConfig) {\n const handler = new ExpressWebhookHandler(config);\n return handler.getHandlers();\n}\n"]}
@@ -1,403 +0,0 @@
1
- import { d as ResponseSuccess } from './request-CUjrMn8R.js';
2
- import { IncomingMessage, IncomingHttpHeaders } from 'http';
3
-
4
- /**
5
- * Enum for Flow Status
6
- */
7
- declare enum FlowStatusEnum {
8
- Draft = "DRAFT",
9
- Published = "PUBLISHED",
10
- Throttled = "THROTTLED",
11
- Blocked = "BLOCKED",
12
- Deprecated = "DEPRECATED"
13
- }
14
- /**
15
- * Enum for Flow Categories
16
- */
17
- declare enum FlowCategoryEnum {
18
- SignUp = "SIGN_UP",
19
- SignIn = "SIGN_IN",
20
- AppointmentBooking = "APPOINTMENT_BOOKING",
21
- LeadGeneration = "LEAD_GENERATION",
22
- ContactUs = "CONTACT_US",
23
- CustomerSupport = "CUSTOMER_SUPPORT",
24
- Survey = "SURVEY",
25
- Other = "OTHER"
26
- }
27
- declare enum FlowActionEnum {
28
- INIT = "INIT",
29
- BACK = "BACK",
30
- DATA_EXCHANGE = "data_exchange"
31
- }
32
- /**
33
- * Enum for Flow Types in webhook handlers
34
- * Used to register handlers for specific flow events
35
- */
36
- declare enum FlowTypeEnum {
37
- /** Health check/ping requests */
38
- Ping = "ping",
39
- /** Data exchange requests */
40
- Change = "data_exchange",
41
- /** Error notification requests */
42
- Error = "error",
43
- /** Match all flow action types */
44
- All = "*"
45
- }
46
- type FlowType = (typeof FlowTypeEnum)[keyof typeof FlowTypeEnum];
47
- /**
48
- * Flow Validation Error Pointer
49
- */
50
- interface FlowValidationErrorPointer {
51
- line_start: number;
52
- line_end: number;
53
- column_start: number;
54
- column_end: number;
55
- path: string;
56
- }
57
- /**
58
- * Flow Validation Error
59
- */
60
- interface FlowValidationError {
61
- error: string;
62
- error_type: string;
63
- message: string;
64
- line_start: number;
65
- line_end: number;
66
- column_start: number;
67
- column_end: number;
68
- pointers: FlowValidationErrorPointer[];
69
- }
70
- /**
71
- * Flow Item
72
- */
73
- interface Flow {
74
- id: string;
75
- name: string;
76
- status: FlowStatusEnum;
77
- categories: FlowCategoryEnum[];
78
- validation_errors: FlowValidationError[];
79
- }
80
- /**
81
- * Pagination Cursors
82
- */
83
- interface PaginationCursors {
84
- before: string;
85
- after: string;
86
- }
87
- /**
88
- * Pagination Object
89
- */
90
- interface Pagination {
91
- cursors: PaginationCursors;
92
- }
93
- /**
94
- * Flows List Response
95
- */
96
- interface FlowsListResponse {
97
- data: Flow[];
98
- paging: Pagination;
99
- }
100
- /**
101
- * Flow Asset
102
- */
103
- interface FlowAsset {
104
- name: string;
105
- asset_type: string;
106
- download_url: string;
107
- }
108
- /**
109
- * Flow Assets Response
110
- */
111
- interface FlowAssetsResponse {
112
- data: FlowAsset[];
113
- paging: Pagination;
114
- }
115
- /**
116
- * Flow Preview
117
- */
118
- interface FlowPreview {
119
- preview_url: string;
120
- expires_at: string;
121
- }
122
- /**
123
- * Flow Preview Response
124
- */
125
- interface FlowPreviewResponse {
126
- preview: FlowPreview;
127
- id: string;
128
- }
129
- /**
130
- * Flow Migration Result
131
- */
132
- interface FlowMigrationResult {
133
- source_name: string;
134
- source_id: string;
135
- migrated_id: string;
136
- }
137
- /**
138
- * Flow Migration Failure
139
- */
140
- interface FlowMigrationFailure {
141
- source_name: string;
142
- error_code: string;
143
- error_message: string;
144
- }
145
- /**
146
- * Create Flow Response
147
- */
148
- interface CreateFlowResponse {
149
- id: string;
150
- success: boolean;
151
- validation_errors?: FlowValidationError[];
152
- }
153
- /**
154
- * Update Flow Response
155
- */
156
- interface UpdateFlowResponse {
157
- success: boolean;
158
- validation_errors?: FlowValidationError[];
159
- }
160
- /**
161
- * Flow Migration Response
162
- */
163
- interface FlowMigrationResponse {
164
- migrated_flows: FlowMigrationResult[];
165
- failed_flows: FlowMigrationFailure[];
166
- }
167
- /**
168
- * Validate Flow JSON Response
169
- */
170
- interface ValidateFlowJsonResponse {
171
- valid: boolean;
172
- success: boolean;
173
- validation_errors?: FlowValidationError[];
174
- }
175
- /**
176
- * WhatsApp Flow Endpoint - Encrypted Request Payload
177
- * Represents the raw encrypted data received from WhatsApp
178
- */
179
- interface FlowEncryptedRequestPayload {
180
- encrypted_aes_key: string;
181
- encrypted_flow_data: string;
182
- initial_vector: string;
183
- }
184
- /**
185
- * WhatsApp Flow Endpoint - Decrypted Request Response
186
- * Represents the successfully decrypted data and encryption keys
187
- */
188
- interface FlowDecryptedRequestResponse {
189
- decryptedBody: any;
190
- aesKeyBuffer: Buffer;
191
- initialVectorBuffer: Buffer;
192
- }
193
- /**
194
- * WhatsApp Flow Endpoint - HTTP Request with Body
195
- * Represents an HTTP request with the encrypted payload
196
- */
197
- interface FlowHttpRequest extends IncomingMessage {
198
- body: FlowEncryptedRequestPayload;
199
- headers: IncomingHttpHeaders;
200
- }
201
- /**
202
- * WhatsApp Flow Endpoint - Health Check Request
203
- * Represents the structure of a health check request
204
- */
205
- interface FlowHealthCheckRequest {
206
- action: 'ping';
207
- version: '3.0';
208
- }
209
- /**
210
- * WhatsApp Flow Endpoint - Health Check Response
211
- * The expected response structure for health check requests
212
- */
213
- interface FlowHealthCheckResponse {
214
- data: {
215
- status: 'active';
216
- };
217
- }
218
- /**
219
- * WhatsApp Flow Endpoint - Data Exchange Request
220
- * Represents the structure of a data exchange request
221
- */
222
- interface FlowDataExchangeRequest {
223
- version: '3.0';
224
- action: FlowActionEnum;
225
- screen: string;
226
- flow_token: string;
227
- data?: Record<string, any> & {
228
- error_message?: string;
229
- };
230
- }
231
- /**
232
- * WhatsApp Flow Endpoint - Data Exchange Response
233
- * The expected response structure for data exchange requests
234
- */
235
- interface FlowDataExchangeResponse {
236
- screen?: string;
237
- data?: Record<string, any | {
238
- error_message?: string;
239
- }>;
240
- }
241
- /**
242
- * WhatsApp Flow Endpoint - Success Screen Response
243
- * The expected response structure for success screen requests
244
- */
245
- interface FlowSuccessScreenResponse {
246
- screen: 'SUCCESS';
247
- data: {
248
- extension_message_response?: {
249
- params?: {
250
- flow_token: string;
251
- [key: string]: string;
252
- };
253
- };
254
- };
255
- }
256
- /**
257
- * WhatsApp Flow Endpoint - Error Notification Request
258
- * Represents the structure of an error notification request
259
- */
260
- interface FlowErrorNotificationRequest {
261
- version: '3.0';
262
- action: Exclude<FlowActionEnum, FlowActionEnum.BACK>;
263
- screen: string;
264
- flow_token: string;
265
- data: {
266
- error: string;
267
- error_message: string;
268
- };
269
- }
270
- /**
271
- * WhatsApp Flow Endpoint - Error Notification Response
272
- * The expected response structure for error notification requests
273
- */
274
- interface FlowErrorNotificationResponse {
275
- acknowledged: boolean;
276
- }
277
- /**
278
- * WhatsApp Flow Endpoint - Comprehensive Request Object
279
- * A combined type that includes all possible fields from different request types
280
- * with all fields being optional for flexibility
281
- */
282
- interface FlowEndpointRequest {
283
- version?: '3.0';
284
- action?: 'ping' | FlowActionEnum;
285
- screen?: string;
286
- flow_token?: string;
287
- data?: Record<string, any> & {
288
- error_key?: string;
289
- error_message?: string;
290
- };
291
- }
292
- /**
293
- * WhatsApp Flow Endpoint - Response
294
- * Union type for all possible response types from a Flow endpoint
295
- */
296
- type FlowEndpointResponse = FlowHealthCheckResponse | FlowDataExchangeResponse | FlowErrorNotificationResponse | FlowSuccessScreenResponse;
297
- interface FlowClass {
298
- /**
299
- * List Flows
300
- *
301
- * @param wabaId - The WABA ID
302
- * @returns Promise with the list of flows
303
- */
304
- listFlows(wabaId: string): Promise<FlowsListResponse>;
305
- /**
306
- * Create Flow
307
- *
308
- * @param wabaId - The WABA ID
309
- * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id
310
- * @returns Promise with the created flow ID
311
- */
312
- createFlow(wabaId: string, data: {
313
- name: string;
314
- categories?: FlowCategoryEnum[];
315
- endpoint_uri?: string;
316
- clone_flow_id?: string;
317
- flow_json?: string;
318
- publish?: boolean;
319
- }): Promise<CreateFlowResponse>;
320
- /**
321
- * Get Flow
322
- *
323
- * @param flowId - The flow ID
324
- * @param fields - Optional fields to return
325
- * @param dateFormat - Optional date format
326
- * @returns Promise with the flow details
327
- */
328
- getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;
329
- /**
330
- * Update Flow Metadata
331
- *
332
- * @param flowId - The flow ID
333
- * @param data - The flow metadata to update
334
- * @returns Promise with the success status
335
- */
336
- updateFlowMetadata(flowId: string, data: {
337
- name?: string;
338
- categories?: FlowCategoryEnum[];
339
- endpoint_uri?: string;
340
- application_id?: string;
341
- }): Promise<ResponseSuccess>;
342
- /**
343
- * Delete Flow
344
- *
345
- * @param flowId - The flow ID
346
- * @returns Promise with the success status
347
- */
348
- deleteFlow(flowId: string): Promise<ResponseSuccess>;
349
- /**
350
- * List Assets (Get Flow JSON URL)
351
- *
352
- * @param flowId - The flow ID
353
- * @returns Promise with the list of assets
354
- */
355
- listAssets(flowId: string): Promise<FlowAssetsResponse>;
356
- /**
357
- * Update Flow JSON
358
- *
359
- * @param flowId - The flow ID
360
- * @param data - The asset data including asset_type, file, and name
361
- * @returns Promise with the success status and validation errors
362
- */
363
- updateFlowJson(flowId: string, data: {
364
- file: Blob | Buffer | object;
365
- name?: string;
366
- }): Promise<UpdateFlowResponse>;
367
- /**
368
- * Validate Flow JSON by attempting an update without publishing.
369
- * This is a convenience method; the API doesn't have a dedicated validation endpoint.
370
- *
371
- * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).
372
- * @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.
373
- * @returns Promise indicating if the JSON is valid and includes validation errors if any.
374
- */
375
- validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;
376
- /**
377
- * Publish Flow
378
- *
379
- * @param flowId - The flow ID
380
- * @returns Promise with the success status
381
- */
382
- publishFlow(flowId: string): Promise<ResponseSuccess>;
383
- /**
384
- * Deprecate Flow
385
- *
386
- * @param flowId - The flow ID
387
- * @returns Promise with the success status
388
- */
389
- deprecateFlow(flowId: string): Promise<ResponseSuccess>;
390
- /**
391
- * Migrate Flows
392
- *
393
- * @param wabaId - The destination WABA ID
394
- * @param data - The migration data including source_waba_id and optional source_flow_names
395
- * @returns Promise with migration results
396
- */
397
- migrateFlows(wabaId: string, data: {
398
- source_waba_id: string;
399
- source_flow_names?: string[];
400
- }): Promise<FlowMigrationResponse>;
401
- }
402
-
403
- export { type FlowValidationError as A, type FlowValidationErrorPointer as B, type PaginationCursors as C, type CreateFlowResponse as D, FlowTypeEnum as F, type Pagination as P, type UpdateFlowResponse as U, type ValidateFlowJsonResponse as V, FlowActionEnum as a, FlowCategoryEnum as b, FlowStatusEnum as c, type Flow as d, type FlowAsset as e, type FlowAssetsResponse as f, type FlowClass as g, type FlowDataExchangeRequest as h, type FlowDataExchangeResponse as i, type FlowDecryptedRequestResponse as j, type FlowEncryptedRequestPayload as k, type FlowEndpointRequest as l, type FlowEndpointResponse as m, type FlowErrorNotificationRequest as n, type FlowErrorNotificationResponse as o, type FlowHealthCheckRequest as p, type FlowHealthCheckResponse as q, type FlowHttpRequest as r, type FlowMigrationFailure as s, type FlowMigrationResult as t, type FlowMigrationResponse as u, type FlowPreview as v, type FlowPreviewResponse as w, type FlowsListResponse as x, type FlowSuccessScreenResponse as y, type FlowType as z };