( status: Record<string, unknown>, metadata?: Record<string, unknown> )
| 83 | } |
| 84 | |
| 85 | function normalizeWhatsAppStatus( |
| 86 | status: Record<string, unknown>, |
| 87 | metadata?: Record<string, unknown> |
| 88 | ) { |
| 89 | return { |
| 90 | messageId: typeof status.id === 'string' ? status.id : undefined, |
| 91 | recipientId: typeof status.recipient_id === 'string' ? status.recipient_id : undefined, |
| 92 | phoneNumberId: |
| 93 | typeof metadata?.phone_number_id === 'string' ? metadata.phone_number_id : undefined, |
| 94 | displayPhoneNumber: |
| 95 | typeof metadata?.display_phone_number === 'string' |
| 96 | ? metadata.display_phone_number |
| 97 | : undefined, |
| 98 | status: typeof status.status === 'string' ? status.status : undefined, |
| 99 | timestamp: typeof status.timestamp === 'string' ? status.timestamp : undefined, |
| 100 | conversation: isRecord(status.conversation) ? status.conversation : undefined, |
| 101 | pricing: isRecord(status.pricing) ? status.pricing : undefined, |
| 102 | raw: status, |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | function validateWhatsAppSignature(secret: string, signature: string, body: string): boolean { |
| 107 | try { |
no test coverage detected