@warriorteam/messenger-sdk 1.4.2 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,8 @@ A modern TypeScript SDK for the Facebook Messenger Platform API, designed with s
9
9
  - 🔄 **Dual module support** - ESM and CommonJS
10
10
  - ✅ **Comprehensive validation** - Built-in message and template validation
11
11
  - 🛡️ **Error handling** - Detailed error types and messages
12
- - 📚 **Complete API coverage** - Send API, Templates, Attachments, Moderation, Profile
12
+ - 📚 **Complete API coverage** - Send API, Templates, Attachments, Moderation, Profile, Conversations
13
+ - 💬 **Conversations API** - Retrieve conversation history and messages for Messenger & Instagram
13
14
  - 🔐 **Webhook utilities** - Complete webhook type system and signature verification
14
15
  - 🎯 **Token override** - Per-method access token override support
15
16
  - 🔧 **Type-safe webhooks** - Discriminated unions for proper TypeScript narrowing
@@ -272,6 +273,137 @@ await messenger.send.message({
272
273
 
273
274
  **Note**: Profile API requires "Advanced User Profile Access" feature and user interaction to grant permissions.
274
275
 
276
+ ### Conversations API
277
+
278
+ Retrieve conversation history and messages between users and your Page or Instagram Business Account.
279
+
280
+ #### Permissions Required
281
+
282
+ **For Messenger conversations:**
283
+ - `pages_manage_metadata`
284
+ - `pages_read_engagement`
285
+ - `pages_messaging`
286
+
287
+ **For Instagram conversations:**
288
+ - `instagram_basic`
289
+ - `instagram_manage_messages`
290
+ - `pages_manage_metadata`
291
+ - Your app must be owned by a verified business
292
+
293
+ #### List Conversations
294
+
295
+ ```typescript
296
+ // List Messenger conversations
297
+ const conversations = await messenger.conversations.list('PAGE_ID', {
298
+ platform: 'messenger',
299
+ limit: 25
300
+ });
301
+
302
+ // List Instagram conversations
303
+ const igConversations = await messenger.conversations.list('PAGE_ID', {
304
+ platform: 'instagram',
305
+ limit: 25
306
+ });
307
+
308
+ // Find conversation with specific user
309
+ const conversationId = await messenger.conversations.findByUser(
310
+ 'PAGE_ID',
311
+ 'USER_INSTAGRAM_SCOPED_ID',
312
+ 'instagram'
313
+ );
314
+ ```
315
+
316
+ #### Get Conversation Details
317
+
318
+ ```typescript
319
+ // Get conversation with messages and participants
320
+ const conversation = await messenger.conversations.get('CONVERSATION_ID', {
321
+ fields: ['messages', 'participants'],
322
+ limit: 20
323
+ });
324
+
325
+ // Access participants
326
+ conversation.participants?.data.forEach(participant => {
327
+ console.log(`${participant.name || participant.username} (${participant.id})`);
328
+ });
329
+
330
+ // Access messages
331
+ conversation.messages?.data.forEach(msg => {
332
+ console.log(`Message ID: ${msg.id}, Created: ${msg.created_time}`);
333
+ });
334
+ ```
335
+
336
+ #### Get Message Details
337
+
338
+ ```typescript
339
+ // Get full message details
340
+ const message = await messenger.conversations.getMessage('MESSAGE_ID', {
341
+ fields: ['id', 'created_time', 'from', 'to', 'message', 'attachments', 'reactions', 'reply_to']
342
+ });
343
+
344
+ console.log(`From: ${message.from?.username}`);
345
+ console.log(`Text: ${message.message}`);
346
+
347
+ // Check attachments
348
+ if (message.attachments?.data) {
349
+ message.attachments.data.forEach(att => {
350
+ console.log(`Attachment: ${att.file_url || att.image_data?.url}`);
351
+ });
352
+ }
353
+
354
+ // Check reactions
355
+ if (message.reactions?.data) {
356
+ message.reactions.data.forEach(reaction => {
357
+ console.log(`${reaction.reaction} (${reaction.users.length} users)`);
358
+ });
359
+ }
360
+ ```
361
+
362
+ #### Get Recent Messages (Convenience Method)
363
+
364
+ ```typescript
365
+ // Get the 20 most recent messages with full details
366
+ const messages = await messenger.conversations.getRecentMessages('CONVERSATION_ID');
367
+
368
+ messages.forEach(msg => {
369
+ const sender = msg.from?.name || msg.from?.username;
370
+ const text = msg.message || '(attachment)';
371
+ console.log(`${sender}: ${text}`);
372
+ });
373
+ ```
374
+
375
+ #### Pagination
376
+
377
+ ```typescript
378
+ // Paginate through conversations
379
+ let after: string | undefined;
380
+ let hasMore = true;
381
+
382
+ while (hasMore) {
383
+ const conversations = await messenger.conversations.list('PAGE_ID', {
384
+ platform: 'messenger',
385
+ limit: 25,
386
+ after
387
+ });
388
+
389
+ // Process conversations
390
+ console.log(`Fetched ${conversations.data.length} conversations`);
391
+
392
+ // Check for next page
393
+ if (conversations.paging?.cursors?.after) {
394
+ after = conversations.paging.cursors.after;
395
+ } else {
396
+ hasMore = false;
397
+ }
398
+ }
399
+ ```
400
+
401
+ #### Important Limitations
402
+
403
+ - **20 Message Limit**: You can only retrieve full details for the **20 most recent messages** in a conversation. Older messages will return an error.
404
+ - **Pending Messages**: Conversations in the "pending" folder that are inactive for 30+ days are not returned.
405
+ - **Private Keys**: Accounts linked with private keys (email/phone) require Advanced Access approval to retrieve conversations.
406
+
275
407
  ## Webhook Support
276
408
 
277
409
  The SDK provides comprehensive webhook support with full TypeScript safety through discriminated unions.
@@ -410,6 +542,7 @@ function handleWebhookEvent(event: MessengerWebhookEvent) {
410
542
 
411
543
  ### Supported Webhook Event Types
412
544
 
545
+ #### Messenger Platform Events
413
546
  - `MESSAGE` - User sends a message
414
547
  - `MESSAGE_EDIT` - User edits a sent message
415
548
  - `MESSAGE_REACTION` - User reacts to a message
@@ -417,6 +550,188 @@ function handleWebhookEvent(event: MessengerWebhookEvent) {
417
550
  - `MESSAGING_FEEDBACK` - User submits feedback via templates
418
551
  - `MESSAGING_POSTBACK` - User clicks buttons/quick replies
419
552
 
553
+ #### Page Webhook Events
554
+ - `FEED` - Page feed changes (posts, photos, videos, status updates)
555
+ - `VIDEOS` - Video encoding status changes (processing, ready, error)
556
+ - `LIVE_VIDEOS` - Live video status changes (live, stopped, scheduled, VOD ready)
557
+
558
+ ### Page Webhook Type Helpers
559
+
560
+ The SDK provides specialized type guards and helpers for Page webhook events:
561
+
562
+ ```typescript
563
+ import {
564
+ isFeedEvent,
565
+ isVideoEvent,
566
+ isLiveVideoEvent,
567
+ isVideoProcessing,
568
+ isVideoReady,
569
+ isLiveVideoProcessing,
570
+ isLive,
571
+ extractVideoContext,
572
+ extractLiveVideoContext,
573
+ FeedActionVerb,
574
+ VideoStatus,
575
+ LiveVideoStatus
576
+ } from '@warriorteam/messenger-sdk';
577
+
578
+ // Handle Page webhooks
579
+ app.post('/webhook/page', express.json(), async (req, res) => {
580
+ const payload = req.body;
581
+
582
+ for (const entry of payload.entry) {
583
+ for (const change of entry.changes || []) {
584
+ // Feed events (posts, photos, videos, status)
585
+ if (isFeedEvent(change)) {
586
+ console.log(`Feed ${change.value.verb}: ${change.value.item} by ${change.value.from.id}`);
587
+ if (change.value.verb === FeedActionVerb.ADD) {
588
+ console.log('New post created!');
589
+ }
590
+ }
591
+
592
+ // Video encoding events
593
+ if (isVideoEvent(change)) {
594
+ const context = extractVideoContext(entry.id, entry.time, change);
595
+ if (context.isReady) {
596
+ console.log(`Video ${context.videoId} is ready!`);
597
+ } else if (context.isProcessing) {
598
+ console.log(`Video ${context.videoId} is still processing...`);
599
+ }
600
+ }
601
+
602
+ // Live video events
603
+ if (isLiveVideoEvent(change)) {
604
+ const context = extractLiveVideoContext(entry.id, entry.time, change);
605
+ if (context.isLive) {
606
+ console.log(`Live stream ${context.videoId} is now live!`);
607
+ } else if (context.isVODReady) {
608
+ console.log(`Live stream ${context.videoId} VOD is ready!`);
609
+ }
610
+ }
611
+ }
612
+ }
613
+
614
+ res.sendStatus(200);
615
+ });
616
+ ```
617
+
618
+ **Note**: Page webhooks use a different structure (`entry[].changes[]`) compared to Messenger webhooks (`entry[].messaging[]`). The SDK provides helpers for both.
619
+
620
+ ### Complete Controller Example (NestJS/Express)
621
+
622
+ Here's a complete TypeScript controller for handling webhooks with proper types:
623
+
624
+ ```typescript
625
+ import { Controller, Post, Body, Headers, Res, Get, Query } from '@nestjs/common';
626
+ import { Response } from 'express';
627
+ import {
628
+ GenericWebhookPayload,
629
+ PageWebhookPayload,
630
+ verifyWebhookSignature,
631
+ verifyWebhookSubscription,
632
+ processWebhookEvents,
633
+ isFeedEvent,
634
+ isVideoEvent,
635
+ isLiveVideoEvent,
636
+ } from '@warriorteam/messenger-sdk';
637
+
638
+ @Controller('webhook')
639
+ export class WebhookController {
640
+ // Subscription verification (GET)
641
+ @Get()
642
+ verifyWebhook(@Query() query: any, @Res() res: Response) {
643
+ const challenge = verifyWebhookSubscription(
644
+ query,
645
+ process.env.VERIFY_TOKEN!
646
+ );
647
+
648
+ if (challenge) {
649
+ return res.send(challenge);
650
+ }
651
+ return res.status(403).send('Forbidden');
652
+ }
653
+
654
+ // Messenger webhooks (POST)
655
+ @Post('messenger')
656
+ async handleMessenger(
657
+ @Body() payload: GenericWebhookPayload, // ← Correct type for Messenger
658
+ @Headers('x-hub-signature-256') signature: string,
659
+ @Res() res: Response
660
+ ) {
661
+ // Verify signature
662
+ const verification = await verifyWebhookSignature(
663
+ JSON.stringify(payload),
664
+ signature,
665
+ process.env.APP_SECRET!
666
+ );
667
+
668
+ if (!verification.isValid) {
669
+ return res.status(401).json({ error: 'Invalid signature' });
670
+ }
671
+
672
+ // Process events with type-safe handlers
673
+ await processWebhookEvents(payload, {
674
+ onMessage: async (event) => {
675
+ // event is MessageWebhookEvent - fully typed!
676
+ console.log(`From ${event.sender.id}: ${event.message.text}`);
677
+ },
678
+ onMessagingPostback: async (event) => {
679
+ // event is MessagingPostbackWebhookEvent
680
+ console.log(`Button clicked: ${event.postback.payload}`);
681
+ },
682
+ onMessageReaction: async (event) => {
683
+ // event is MessageReactionWebhookEvent
684
+ console.log(`Reaction: ${event.reaction.reaction}`);
685
+ },
686
+ });
687
+
688
+ return res.sendStatus(200);
689
+ }
690
+
691
+ // Page webhooks (POST)
692
+ @Post('page')
693
+ async handlePage(
694
+ @Body() payload: PageWebhookPayload, // ← Correct type for Page webhooks
695
+ @Headers('x-hub-signature-256') signature: string,
696
+ @Res() res: Response
697
+ ) {
698
+ // Verify signature
699
+ const verification = await verifyWebhookSignature(
700
+ JSON.stringify(payload),
701
+ signature,
702
+ process.env.APP_SECRET!
703
+ );
704
+
705
+ if (!verification.isValid) {
706
+ return res.status(401).json({ error: 'Invalid signature' });
707
+ }
708
+
709
+ // Process Page events
710
+ for (const entry of payload.entry) {
711
+ for (const change of entry.changes || []) {
712
+ if (isFeedEvent(change)) {
713
+ console.log(`Page feed: ${change.value.verb} ${change.value.item}`);
714
+ }
715
+
716
+ if (isVideoEvent(change)) {
717
+ console.log(`Video status: ${change.value.status.video_status}`);
718
+ }
719
+
720
+ if (isLiveVideoEvent(change)) {
721
+ console.log(`Live video status: ${change.value.status}`);
722
+ }
723
+ }
724
+ }
725
+
726
+ return res.sendStatus(200);
727
+ }
728
+ }
729
+ ```
730
+
731
+ **Key Types to Use:**
732
+ - `GenericWebhookPayload` - For Messenger Platform webhooks (`entry[].messaging[]`)
733
+ - `PageWebhookPayload` - For Page webhooks (`entry[].changes[]`)
734
+
420
735
  ## Error Handling
421
736
 
422
737
  The SDK provides specific error types for different scenarios:
@@ -454,6 +769,7 @@ Check the `examples/` directory for complete usage examples:
454
769
  - `send-template.ts` - Template messages
455
770
  - `user-profile.ts` - Profile API usage
456
771
  - `moderation.ts` - User moderation
772
+ - `conversations.ts` - Retrieve conversations and messages
457
773
  - `webhook-handler.ts` - Complete webhook setup with type safety
458
774
  - `multi-tenant.ts` - Token override for multi-tenant applications
459
775
  - `signature-verification.ts` - Webhook security implementation
@@ -477,6 +793,52 @@ npm run lint
477
793
  npm run format
478
794
  ```
479
795
 
796
+ ## Changelog
797
+
798
+ ### v1.5.1 (Latest)
799
+ - **Added**: Complete NestJS/Express webhook controller example in README
800
+ - **Updated**: WebhookEventType enum to include FEED, VIDEOS, LIVE_VIDEOS
801
+ - **Improved**: Documentation with clear type usage for webhook handlers
802
+
803
+ ### v1.5.0
804
+ - **Added**: Conversations API for retrieving conversation history and messages
805
+ - List conversations for Messenger and Instagram
806
+ - Get conversation details with participants and messages
807
+ - Retrieve individual message details with attachments, reactions, and replies
808
+ - Convenience method for getting recent messages with full details
809
+ - Find conversations by user ID
810
+ - Full pagination support
811
+ - Support for both Messenger and Instagram platforms
812
+ - Token override support for multi-tenant applications
813
+ - **Added**: Comprehensive TypeScript types for Conversations API
814
+ - `Conversation`, `ConversationDetail`, `Message` types
815
+ - Message attachments, reactions, shares, story replies
816
+ - Image/video data types for media attachments
817
+ - Request/response types for all operations
818
+
819
+ ### v1.4.2
820
+ - **Fixed**: Resolved export naming conflicts for `isProcessing` function between video and live video webhooks
821
+ - `isProcessing` from videos module now exported as `isVideoProcessing`
822
+ - `isProcessing` from live-videos module now exported as `isLiveVideoProcessing`
823
+ - Added explicit exports for all video and live video helper functions with unique names
824
+ - Similar to existing pattern used for `ReferralType` and `ReferralSource` conflicts
825
+ - **Improved**: Better TypeScript type safety with no export ambiguities
826
+
827
+ ### v1.4.x
828
+ - **Added**: Comprehensive Facebook Page webhook types
829
+ - Feed webhook events (posts, photos, videos, status updates)
830
+ - Video encoding webhook events (processing, ready, error states)
831
+ - Live video webhook events (live, stopped, scheduled, VOD ready)
832
+ - **Added**: Type guards and helper functions for all Page webhook events
833
+ - **Added**: Context extraction utilities for video events
834
+
835
+ ### v1.3.x
836
+ - **Added**: Token override support for multi-tenant applications
837
+ - **Improved**: All API methods now accept optional `RequestOptions` parameter
838
+
839
+ ### v1.1.0
840
+ - **Added**: User Profile API support
841
+
480
842
  ## License
481
843
 
482
844
  MIT
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var q="v23.0",X="https://graph.facebook.com";var g={MESSAGES:"/me/messages",MESSAGE_ATTACHMENTS:"/me/message_attachments",MODERATE_CONVERSATIONS:"/me/moderate_conversations"},_={TEXT_MESSAGE_MAX_CHARS:2e3},ce={IMAGE_MAX_SIZE:8*1024*1024,OTHER_MAX_SIZE:25*1024*1024,VIDEO_TIMEOUT:75,OTHER_TIMEOUT:10},i={GENERIC_ELEMENTS_MAX:10,GENERIC_TITLE_MAX_CHARS:80,GENERIC_SUBTITLE_MAX_CHARS:80,BUTTON_TEXT_MAX_CHARS:640,BUTTONS_MAX_COUNT:3,BUTTON_TITLE_MAX_CHARS:20,POSTBACK_PAYLOAD_MAX_CHARS:1e3,MEDIA_ELEMENTS_COUNT:1,MEDIA_BUTTONS_MAX_COUNT:3};var l=class extends Error{code;type;subcode;fbtrace_id;statusCode;response;constructor(e,s,o){super(e.message),this.name="MessengerAPIError",this.code=e.code,this.type=e.type,this.subcode=e.error_subcode,this.fbtrace_id=e.fbtrace_id,this.statusCode=s,this.response=o;}},b=class extends Error{cause;constructor(e,s){super(e),this.name="MessengerNetworkError",this.cause=s;}},h=class extends Error{timeout;constructor(e){super(`Request timed out after ${e}ms`),this.name="MessengerTimeoutError",this.timeout=e;}},m=class extends Error{constructor(e){super(e),this.name="MessengerConfigError";}};var P=class{config;constructor(e){this.config={accessToken:e.accessToken,version:e.version,baseUrl:e.baseUrl||X,timeout:e.timeout||3e4,maxRetries:e.maxRetries||3};}async request(e){let s=this.buildUrl(e.path,e.query,e.accessToken),o;for(let a=0;a<=this.config.maxRetries;a++)try{let n=await this.makeRequest(s,e);return await this.handleResponse(n)}catch(n){if(o=n,n instanceof l&&n.statusCode>=400&&n.statusCode<500||a===this.config.maxRetries)throw n;await this.delay(1e3*(a+1));}throw o||new Error("Unknown error occurred")}buildUrl(e,s,o){let a=new URL(`${this.config.baseUrl}/${this.config.version}${e}`),n=o||this.config.accessToken;if(!n)throw new Error("Access token is required. Provide it in constructor or method options.");return a.searchParams.append("access_token",n),s&&Object.entries(s).forEach(([c,p])=>{a.searchParams.append(c,String(p));}),a.toString()}async makeRequest(e,s){let o=new AbortController,a=setTimeout(()=>o.abort(),this.config.timeout);try{let n={method:s.method,headers:{"Content-Type":"application/json"},signal:o.signal};return s.body&&(n.body=JSON.stringify(s.body)),await fetch(e,n)}catch(n){throw n instanceof Error?n.name==="AbortError"?new h(this.config.timeout):new b(`Network request failed: ${n.message}`,n):n}finally{clearTimeout(a);}}async handleResponse(e){let o=e.headers.get("content-type")?.includes("application/json");if(!e.ok)if(o){let a=await e.json();throw new l(a.error,e.status,a)}else {let a=await e.text();throw new l({message:a||`HTTP ${e.status} ${e.statusText}`,type:"http_error",code:e.status,fbtrace_id:""},e.status,a)}return o?await e.json():await e.text()}delay(e){return new Promise(s=>setTimeout(s,e))}};var u=class extends Error{constructor(e){super(e),this.name="MessageValidationError";}};function j(t){if(!t||t.trim()==="")throw new u("Text message cannot be empty");if(t.length>_.TEXT_MESSAGE_MAX_CHARS)throw new u(`Text message cannot exceed ${_.TEXT_MESSAGE_MAX_CHARS} characters`)}var f=class{constructor(e){this.httpClient=e;}async message(e,s){return e.message?.text&&j(e.message.text),this.httpClient.request({method:"POST",path:g.MESSAGES,body:e,accessToken:s?.accessToken})}async action(e,s,o){return this.httpClient.request({method:"POST",path:g.MESSAGES,body:{recipient:{id:e},messaging_type:"RESPONSE",sender_action:s},accessToken:o?.accessToken})}async typingOn(e,s){return this.action(e,"typing_on",s)}async typingOff(e,s){return this.action(e,"typing_off",s)}async markSeen(e,s){return this.action(e,"mark_seen",s)}async attachment(e,s){return this.message({recipient:e.recipient,messaging_type:e.messaging_type??"RESPONSE",message:{attachment:{type:e.type,payload:{attachment_id:e.attachment_id}}}},s)}async attachmentFromUrl(e,s){return this.message({recipient:e.recipient,messaging_type:e.messaging_type??"RESPONSE",message:{attachment:{type:e.type,payload:{url:e.url}}}},s)}};var y=class{constructor(e){this.httpClient=e;}async upload(e,s){let o={message:{attachment:{type:e.type,payload:{url:e.url,is_reusable:e.is_reusable??true}}}};return this.httpClient.request({method:"POST",path:g.MESSAGE_ATTACHMENTS,body:o,accessToken:s?.accessToken})}};var T=class{constructor(e){this.httpClient=e;}async moderate(e,s){return this.httpClient.request({method:"POST",path:g.MODERATE_CONVERSATIONS,body:e,accessToken:s?.accessToken})}async blockUser(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["block_user"]},s)}async unblockUser(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["unblock_user"]},s)}async banUser(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["ban_user"]},s)}async unbanUser(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["unban_user"]},s)}async moveToSpam(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["move_to_spam"]},s)}async blockAndSpam(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["block_user","move_to_spam"]},s)}};var r=class extends Error{constructor(e){super(e),this.name="TemplateValidationError";}};function V(t){if(t.length===0)throw new r("Generic template must have at least 1 element");if(t.length>i.GENERIC_ELEMENTS_MAX)throw new r(`Generic template cannot have more than ${i.GENERIC_ELEMENTS_MAX} elements`);t.forEach((e,s)=>{me(e,s);});}function me(t,e){if(!t.title||t.title.trim()==="")throw new r(`Element ${e}: title is required`);if(t.title.length>i.GENERIC_TITLE_MAX_CHARS)throw new r(`Element ${e}: title cannot exceed ${i.GENERIC_TITLE_MAX_CHARS} characters`);if(t.subtitle&&t.subtitle.length>i.GENERIC_SUBTITLE_MAX_CHARS)throw new r(`Element ${e}: subtitle cannot exceed ${i.GENERIC_SUBTITLE_MAX_CHARS} characters`);if(t.image_url&&!M(t.image_url))throw new r(`Element ${e}: image_url must be HTTPS`);if(t.buttons&&v(t.buttons,`Element ${e}`),!!!(t.subtitle||t.image_url||t.default_action||t.buttons&&t.buttons.length>0))throw new r(`Element ${e}: must have at least one additional property beyond title`)}function $(t,e){if(!t||t.trim()==="")throw new r("Button template text is required");if(t.length>i.BUTTON_TEXT_MAX_CHARS)throw new r(`Button template text cannot exceed ${i.BUTTON_TEXT_MAX_CHARS} characters`);if(e.length===0)throw new r("Button template must have at least 1 button");v(e,"Button template");}function K(t){if(!t.media_type)throw new r("Media template element must have media_type");if(!t.url&&!t.attachment_id)throw new r("Media template element must have either url or attachment_id");if(t.url&&t.attachment_id)throw new r("Media template element cannot have both url and attachment_id");if(t.url&&!M(t.url))throw new r("Media template url must be HTTPS");if(t.buttons){if(t.buttons.length>i.MEDIA_BUTTONS_MAX_COUNT)throw new r(`Media template cannot have more than ${i.MEDIA_BUTTONS_MAX_COUNT} buttons`);v(t.buttons,"Media template");}}function v(t,e){if(t.length>i.BUTTONS_MAX_COUNT)throw new r(`${e} cannot have more than ${i.BUTTONS_MAX_COUNT} buttons`);t.forEach((s,o)=>{le(s,`${e} button ${o}`);});}function le(t,e){if(!t.type)throw new r(`${e}: type is required`);if(t.type!=="account_unlink"&&(!t.title||t.title.trim()===""))throw new r(`${e}: title is required for ${t.type} buttons`);if(t.title&&t.title.length>i.BUTTON_TITLE_MAX_CHARS)throw new r(`${e}: title cannot exceed ${i.BUTTON_TITLE_MAX_CHARS} characters`);switch(t.type){case "web_url":if(!t.url)throw new r(`${e}: url is required for web_url buttons`);if(!M(t.url))throw new r(`${e}: url must be HTTPS for web_url buttons`);break;case "postback":if(!t.payload)throw new r(`${e}: payload is required for postback buttons`);if(t.payload.length>i.POSTBACK_PAYLOAD_MAX_CHARS)throw new r(`${e}: payload cannot exceed ${i.POSTBACK_PAYLOAD_MAX_CHARS} characters`);break;case "phone_number":if(!t.payload)throw new r(`${e}: payload is required for phone_number buttons`);if(!t.payload.startsWith("+"))throw new r(`${e}: phone_number payload must start with + (e.g., +1234567890)`);break;case "game_play":break;case "account_link":if(!t.url)throw new r(`${e}: url is required for account_link buttons`);if(!M(t.url))throw new r(`${e}: url must be HTTPS for account_link buttons`);break;}if(t.type==="web_url"&&t.messenger_extensions&&t.fallback_url&&!M(t.fallback_url))throw new r(`${e}: fallback_url must be HTTPS`)}function M(t){try{return new URL(t).protocol==="https:"}catch{return false}}var k=class{constructor(e){this.httpClient=e;}async generic(e,s){V(e.elements);let o={template_type:"generic",elements:e.elements,image_aspect_ratio:e.image_aspect_ratio},a={recipient:e.recipient,messaging_type:e.messaging_type||"UPDATE",message:{attachment:{type:"template",payload:o}},notification_type:e.notification_type,tag:e.tag};return this.httpClient.request({method:"POST",path:g.MESSAGES,body:a,accessToken:s?.accessToken})}async button(e,s){$(e.text,e.buttons);let o={template_type:"button",text:e.text,buttons:e.buttons},a={recipient:e.recipient,messaging_type:e.messaging_type||"UPDATE",message:{attachment:{type:"template",payload:o}},notification_type:e.notification_type,tag:e.tag};return this.httpClient.request({method:"POST",path:g.MESSAGES,body:a,accessToken:s?.accessToken})}async media(e,s){K(e.element);let o={template_type:"media",elements:[e.element]},a={recipient:e.recipient,messaging_type:e.messaging_type||"UPDATE",message:{attachment:{type:"template",payload:o}},notification_type:e.notification_type,tag:e.tag};return this.httpClient.request({method:"POST",path:g.MESSAGES,body:a,accessToken:s?.accessToken})}async product(e,s){let o={template_type:"product",elements:e.elements},a={recipient:e.recipient,messaging_type:e.messaging_type||"UPDATE",message:{attachment:{type:"template",payload:o}},notification_type:e.notification_type,tag:e.tag};return this.httpClient.request({method:"POST",path:g.MESSAGES,body:a,accessToken:s?.accessToken})}};var S=class{constructor(e){this.httpClient=e;}async get(e,s){let{psid:o,fields:a=["first_name","last_name"]}=e,n=new URLSearchParams({fields:a.join(",")});return this.httpClient.request({method:"GET",path:`/${o}?${n.toString()}`,body:void 0,accessToken:s?.accessToken})}async getBasic(e,s){return this.get({psid:e,fields:["first_name","last_name","profile_pic"]},s)}async getFull(e,s){return this.get({psid:e,fields:["id","name","first_name","last_name","profile_pic","locale","timezone","gender"]},s)}async getName(e,s){return this.get({psid:e,fields:["first_name","last_name"]},s)}async getProfilePicture(e,s){return this.get({psid:e,fields:["profile_pic"]},s)}};var W=class{send;attachments;moderation;templates;profile;httpClient;constructor(e={}){this.validateConfig(e);let s={accessToken:e.accessToken,version:e.version||q,baseUrl:e.baseUrl,timeout:e.timeout,maxRetries:e.maxRetries};this.httpClient=new P(s),this.send=new f(this.httpClient),this.attachments=new y(this.httpClient),this.moderation=new T(this.httpClient),this.templates=new k(this.httpClient),this.profile=new S(this.httpClient);}validateConfig(e){if(e.accessToken!==void 0&&(typeof e.accessToken!="string"||e.accessToken.trim()===""))throw new m("Access token must be a non-empty string");if(e.version&&typeof e.version!="string")throw new m("API version must be a string");if(e.timeout&&(typeof e.timeout!="number"||e.timeout<=0))throw new m("Timeout must be a positive number");if(e.maxRetries&&(typeof e.maxRetries!="number"||e.maxRetries<0))throw new m("Max retries must be a non-negative number")}};var A=(c=>(c.MESSAGE="message",c.MESSAGE_EDIT="message_edit",c.MESSAGE_REACTION="reaction",c.MESSAGE_READ="read",c.MESSAGING_FEEDBACK="messaging_feedback",c.MESSAGING_POSTBACK="postback",c))(A||{});function Ee(t){return typeof t.id=="string"&&t.id.length>0}function Y(t){let e=[];if(t.object==="page"&&Array.isArray(t.entry))for(let s of t.entry)Array.isArray(s.messaging)&&e.push(...s.messaging);return e}function R(t){let e=Ee(t.sender);return {senderId:t.sender.id,userRef:t.sender.user_ref,recipientId:t.recipient.id,timestamp:t.timestamp,isIdentifiedUser:e,eventDate:new Date(t.timestamp)}}function be(t){return t&&typeof t=="object"&&"message_edit"in t}function he(t){return {...R(t),messageId:t.message_edit.mid,updatedText:t.message_edit.text,editCount:t.message_edit.num_edit}}var ue={MAX_EDITS:5,EVENT_TYPE:"message_edit"};var I=(d=>(d.LIKE="like",d.DISLIKE="dislike",d.LOVE="love",d.SAD="sad",d.ANGRY="angry",d.WOW="wow",d.SMILE="smile",d.OTHER="other",d))(I||{}),O=(s=>(s.REACT="react",s.UNREACT="unreact",s))(O||{});function fe(t){return t&&typeof t=="object"&&"read"in t}function ye(t){return {senderId:t.sender.id,recipientId:t.recipient.id,watermarkTimestamp:t.read.watermark,readTimestamp:t.timestamp,watermarkDate:new Date(t.read.watermark),readDate:new Date(t.timestamp)}}function Q(t,e){return t<=e}function z(t,e){return t.filter(s=>Q(s.timestamp,e))}function Te(t,e){return z(t,e).length}var Me={EVENT_TYPE:"message_reads",READ_PROPERTY:"read"};function ke(t){return t&&typeof t=="object"&&"postback"in t}function Z(t){return t.postback&&"referral"in t.postback&&t.postback.referral!=null}function J(t){return t&&typeof t.id=="string"&&t.id.length>0}function Se(t){let e=Z(t),s=J(t.sender);return {payload:t.postback.payload,senderId:t.sender.id,userRef:t.sender.user_ref,recipientId:t.recipient.id,buttonTitle:t.postback.title,messageId:t.postback.mid,timestamp:t.timestamp,referralContext:e?{ref:t.postback.referral.ref,source:t.postback.referral.source,type:t.postback.referral.type}:void 0,isReferred:e,isIdentifiedUser:s}}var Ae={GET_STARTED:"GET_STARTED",MAIN_MENU:"MAIN_MENU",HELP:"HELP",SUPPORT:"SUPPORT",CONTACT:"CONTACT",CONTACT_SALES:"CONTACT_SALES",CONTACT_SUPPORT:"CONTACT_SUPPORT",BACK:"BACK",NEXT:"NEXT",CANCEL:"CANCEL",SETTINGS:"SETTINGS",PREFERENCES:"PREFERENCES"},_e={MAX_PAYLOAD_LENGTH:1e3,EVENT_TYPE:"postback",REFERRAL_SOURCES:{SHORTLINK:"SHORTLINK",ADS:"ADS",MESSENGER_CODE:"MESSENGER_CODE"},REFERRAL_TYPES:{OPEN_THREAD:"OPEN_THREAD"}};var N=(o=>(o.CSAT="csat",o.NPS="nps",o.CES="ces",o))(N||{}),w=(o=>(o.ONE_TO_FIVE="one_to_five",o.FIVE_STARS="five_stars",o.FIVE_EMOJIS="five_emojis",o))(w||{}),G=(e=>(e.ZERO_TO_TEN="zero_to_ten",e))(G||{}),D=(e=>(e.ONE_TO_SEVEN="one_to_seven",e))(D||{}),U=(e=>(e.FREE_FORM="free_form",e))(U||{});function Pe(t){return t&&typeof t=="object"&&"messaging_feedback"in t}function Re(t){let e=[];return t.messaging_feedback.feedback_screens.forEach(s=>{Object.entries(s.questions).forEach(([o,a])=>{e.push({questionId:o,feedbackType:a.type,score:parseInt(a.payload,10),textFeedback:a.follow_up?.payload,screenId:s.screen_id});});}),{senderId:t.sender.id,recipientId:t.recipient.id,submissionTimestamp:t.timestamp,screenCount:t.messaging_feedback.feedback_screens.length,allResponses:e}}function xe(t){let e=new Map;return t.messaging_feedback.feedback_screens.forEach(s=>{Object.values(s.questions).forEach(o=>{let a=parseInt(o.payload,10),n=e.get(o.type)||[];e.set(o.type,[...n,a]);});}),e}function Ce(t){let e=[];return t.messaging_feedback.feedback_screens.forEach(s=>{Object.values(s.questions).forEach(o=>{o.follow_up?.payload&&e.push(o.follow_up.payload);});}),e}var E={MAX_TEXT_FEEDBACK_LENGTH:400,SCORE_RANGES:{csat:{min:1,max:5},nps:{min:0,max:10},ces:{min:1,max:7}},TEMPLATE_EXPIRY:{MIN_DAYS:1,MAX_DAYS:7,DEFAULT_DAYS:1},QUESTION_ID:{MAX_LENGTH:80,VALID_PATTERN:/^[a-zA-Z0-9_]+$/},TEMPLATE_LIMITS:{MAX_TITLES:1,MAX_SCORING_COMPONENTS:1},EVENT_TYPE:"messaging_feedback"};function ve(t,e){let s=E.SCORE_RANGES[t];return Number.isInteger(e)&&e>=s.min&&e<=s.max}function We(t){return t.length<=E.QUESTION_ID.MAX_LENGTH&&E.QUESTION_ID.VALID_PATTERN.test(t)}function Ie(t){return t.length<=E.MAX_TEXT_FEEDBACK_LENGTH}var F=(p=>(p.AUDIO="audio",p.FILE="file",p.IMAGE="image",p.VIDEO="video",p.FALLBACK="fallback",p.REEL="reel",p.IG_REEL="ig_reel",p))(F||{}),B=(o=>(o.OPEN_THREAD="OPEN_THREAD",o.PRODUCT="product",o.ADS="ads",o))(B||{}),L=(n=>(n.MESSENGER_CODE="MESSENGER_CODE",n.DISCOVER_TAB="DISCOVER_TAB",n.ADS="ADS",n.SHORTLINK="SHORTLINK",n.CUSTOMER_CHAT_PLUGIN="CUSTOMER_CHAT_PLUGIN",n))(L||{});function Oe(t){return t&&typeof t=="object"&&"message"in t}function Ne(t){return typeof t.text=="string"&&t.text.length>0}function x(t){return Array.isArray(t.attachments)&&t.attachments.length>0}function ee(t){return t.quick_reply!==void 0}function te(t){return t.reply_to!==void 0}function se(t){return t.referral!==void 0}function oe(t,e){return t.type===e}function we(t){let{message:e}=t;return {...R(t),messageId:e.mid,text:e.text,hasAttachments:x(e),isQuickReply:ee(e),isReply:te(e),hasReferral:se(e),quickReplyPayload:e.quick_reply?.payload,repliedToMessageId:e.reply_to?.mid}}function Ge(t,e){return x(t)?t.attachments.filter(s=>oe(s,e)):[]}function De(t){return x(t)?t.attachments.map(e=>e.payload.url):[]}var Ue={MAX_TEXT_LENGTH:2e3,MAX_QUICK_REPLY_PAYLOAD_LENGTH:1e3,MAX_REFERRAL_REF_LENGTH:250,EVENT_TYPE:"message"},Fe={image:["image/jpeg","image/png","image/gif","image/webp"],video:["video/mp4","video/avi","video/quicktime","video/webm"],audio:["audio/mpeg","audio/mp4","audio/wav","audio/ogg"],file:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain"]};function C(t){return !t||typeof t!="object"?null:"type"in t&&Object.values(A).includes(t.type)?t.type:"message"in t?"message":"message_edit"in t?"message_edit":"reaction"in t?"reaction":"read"in t?"read":"messaging_feedback"in t?"messaging_feedback":"postback"in t?"postback":null}function ae(t){let e=new Set;if(t.object==="page"&&Array.isArray(t.entry)){for(let s of t.entry)if(Array.isArray(s.messaging))for(let o of s.messaging){let a=C(o);a&&e.add(a);}}return Array.from(e)}function H(t){return Y(t)}function Be(t){let e=C(t);return e?"type"in t?t:{...t,type:e}:null}async function ne(t,e){let s=H(t);for(let o of s){let a=Be(o);if(!a){e.onUnknown&&await e.onUnknown(o);continue}switch(a.type){case "message":e.onMessage&&await e.onMessage(a);break;case "message_edit":e.onMessageEdit&&await e.onMessageEdit(a);break;case "reaction":e.onMessageReaction&&await e.onMessageReaction(a);break;case "read":e.onMessageRead&&await e.onMessageRead(a);break;case "messaging_feedback":e.onMessagingFeedback&&await e.onMessagingFeedback(a);break;case "postback":e.onMessagingPostback&&await e.onMessagingPostback(a);break;default:let n=a;e.onUnknown&&await e.onUnknown(n);break}}}function re(t,e){return t["hub.mode"]==="subscribe"&&t["hub.verify_token"]===e?t["hub.challenge"]:null}async function ie(t,e,s){if(!e)return {isValid:false,error:"Missing X-Hub-Signature-256 header"};if(!e.startsWith("sha256="))return {isValid:false,error:"Invalid signature format. Expected sha256= prefix"};if(!s)return {isValid:false,error:"App secret is required for signature verification"};try{if(typeof Buffer>"u")return {isValid:!1,error:"Signature verification is only supported in Node.js environments"};let o=await import('crypto'),a=e.substring(7),n=o.createHmac("sha256",s).update(t).digest("hex"),c=Buffer.from(a,"hex"),p=Buffer.from(n,"hex");if(c.length!==p.length)return {isValid:!1,error:"Signature length mismatch"};let d=o.timingSafeEqual(c,p);return {isValid:d,error:d?void 0:"Signature verification failed"}}catch(o){return {isValid:false,error:`Signature verification error: ${o instanceof Error?o.message:"Unknown error"}`}}}
2
- exports.ATTACHMENT_LIMITS=ce;exports.ATTACHMENT_MIME_TYPES=Fe;exports.AttachmentsAPI=y;exports.CESDisplayOption=D;exports.COMMON_POSTBACK_PAYLOADS=Ae;exports.CSATDisplayOption=w;exports.FeedbackType=N;exports.FollowUpType=U;exports.MESSAGE_CONSTANTS=Ue;exports.MESSAGE_EDIT_CONSTANTS=ue;exports.MESSAGE_LIMITS=_;exports.MESSAGE_READS_CONSTANTS=Me;exports.MESSAGING_FEEDBACK_CONSTANTS=E;exports.MessageReactionAction=O;exports.MessageReactionType=I;exports.MessageReferralSource=L;exports.MessageReferralType=B;exports.MessageValidationError=u;exports.Messenger=W;exports.MessengerAPIError=l;exports.MessengerConfigError=m;exports.MessengerNetworkError=b;exports.MessengerTimeoutError=h;exports.ModerationAPI=T;exports.NPSDisplayOption=G;exports.POSTBACK_CONSTANTS=_e;exports.ProfileAPI=S;exports.SendAPI=f;exports.TEMPLATE_LIMITS=i;exports.TemplateValidationError=r;exports.TemplatesAPI=k;exports.WebhookAttachmentType=F;exports.WebhookEventType=A;exports.extractMessageContext=we;exports.extractMessageEditContext=he;exports.extractMessageReadsContext=ye;exports.extractMessagingFeedbackContext=Re;exports.extractPostbackContext=Se;exports.extractTextFeedback=Ce;exports.extractWebhookEvents=H;exports.getAttachmentUrls=De;exports.getAttachmentsByType=Ge;exports.getFeedbackScoresByType=xe;exports.getReadMessageCount=Te;exports.getReadMessages=z;exports.getWebhookEventType=C;exports.getWebhookPayloadEventTypes=ae;exports.hasAttachments=x;exports.hasQuickReply=ee;exports.hasReferral=se;exports.hasReferralData=Z;exports.isAttachmentType=oe;exports.isIdentifiedSender=J;exports.isMessageEditEvent=be;exports.isMessageEvent=Oe;exports.isMessageRead=Q;exports.isMessageReadsEvent=fe;exports.isMessagingFeedbackEvent=Pe;exports.isMessagingPostbackEvent=ke;exports.isReplyMessage=te;exports.isTextMessage=Ne;exports.isValidFeedbackScore=ve;exports.isValidQuestionId=We;exports.isValidTextFeedback=Ie;exports.processWebhookEvents=ne;exports.verifyWebhookSignature=ie;exports.verifyWebhookSubscription=re;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var ne="v23.0",re="https://graph.facebook.com";var m={MESSAGES:"/me/messages",MESSAGE_ATTACHMENTS:"/me/message_attachments",MODERATE_CONVERSATIONS:"/me/moderate_conversations"},v={TEXT_MESSAGE_MAX_CHARS:2e3},Fe={IMAGE_MAX_SIZE:8*1024*1024,OTHER_MAX_SIZE:25*1024*1024,VIDEO_TIMEOUT:75,OTHER_TIMEOUT:10},d={GENERIC_ELEMENTS_MAX:10,GENERIC_TITLE_MAX_CHARS:80,GENERIC_SUBTITLE_MAX_CHARS:80,BUTTON_TEXT_MAX_CHARS:640,BUTTONS_MAX_COUNT:3,BUTTON_TITLE_MAX_CHARS:20,POSTBACK_PAYLOAD_MAX_CHARS:1e3,MEDIA_ELEMENTS_COUNT:1,MEDIA_BUTTONS_MAX_COUNT:3};var u=class extends Error{code;type;subcode;fbtrace_id;statusCode;response;constructor(e,s,o){super(e.message),this.name="MessengerAPIError",this.code=e.code,this.type=e.type,this.subcode=e.error_subcode,this.fbtrace_id=e.fbtrace_id,this.statusCode=s,this.response=o;}},b=class extends Error{cause;constructor(e,s){super(e),this.name="MessengerNetworkError",this.cause=s;}},y=class extends Error{timeout;constructor(e){super(`Request timed out after ${e}ms`),this.name="MessengerTimeoutError",this.timeout=e;}},p=class extends Error{constructor(e){super(e),this.name="MessengerConfigError";}};var C=class{config;constructor(e){this.config={accessToken:e.accessToken,version:e.version,baseUrl:e.baseUrl||re,timeout:e.timeout||3e4,maxRetries:e.maxRetries||3};}async request(e){let s=this.buildUrl(e.path,e.query,e.accessToken),o;for(let a=0;a<=this.config.maxRetries;a++)try{let n=await this.makeRequest(s,e);return await this.handleResponse(n)}catch(n){if(o=n,n instanceof u&&n.statusCode>=400&&n.statusCode<500||a===this.config.maxRetries)throw n;await this.delay(1e3*(a+1));}throw o||new Error("Unknown error occurred")}buildUrl(e,s,o){let a=new URL(`${this.config.baseUrl}/${this.config.version}${e}`),n=o||this.config.accessToken;if(!n)throw new Error("Access token is required. Provide it in constructor or method options.");return a.searchParams.append("access_token",n),s&&Object.entries(s).forEach(([h,g])=>{a.searchParams.append(h,String(g));}),a.toString()}async makeRequest(e,s){let o=new AbortController,a=setTimeout(()=>o.abort(),this.config.timeout);try{let n={method:s.method,headers:{"Content-Type":"application/json"},signal:o.signal};return s.body&&(n.body=JSON.stringify(s.body)),await fetch(e,n)}catch(n){throw n instanceof Error?n.name==="AbortError"?new y(this.config.timeout):new b(`Network request failed: ${n.message}`,n):n}finally{clearTimeout(a);}}async handleResponse(e){let o=e.headers.get("content-type")?.includes("application/json");if(!e.ok)if(o){let a=await e.json();throw new u(a.error,e.status,a)}else {let a=await e.text();throw new u({message:a||`HTTP ${e.status} ${e.statusText}`,type:"http_error",code:e.status,fbtrace_id:""},e.status,a)}return o?await e.json():await e.text()}delay(e){return new Promise(s=>setTimeout(s,e))}};var T=class extends Error{constructor(e){super(e),this.name="MessageValidationError";}};function ie(t){if(!t||t.trim()==="")throw new T("Text message cannot be empty");if(t.length>v.TEXT_MESSAGE_MAX_CHARS)throw new T(`Text message cannot exceed ${v.TEXT_MESSAGE_MAX_CHARS} characters`)}var M=class{constructor(e){this.httpClient=e;}async message(e,s){return e.message?.text&&ie(e.message.text),this.httpClient.request({method:"POST",path:m.MESSAGES,body:e,accessToken:s?.accessToken})}async action(e,s,o){return this.httpClient.request({method:"POST",path:m.MESSAGES,body:{recipient:{id:e},messaging_type:"RESPONSE",sender_action:s},accessToken:o?.accessToken})}async typingOn(e,s){return this.action(e,"typing_on",s)}async typingOff(e,s){return this.action(e,"typing_off",s)}async markSeen(e,s){return this.action(e,"mark_seen",s)}async attachment(e,s){return this.message({recipient:e.recipient,messaging_type:e.messaging_type??"RESPONSE",message:{attachment:{type:e.type,payload:{attachment_id:e.attachment_id}}}},s)}async attachmentFromUrl(e,s){return this.message({recipient:e.recipient,messaging_type:e.messaging_type??"RESPONSE",message:{attachment:{type:e.type,payload:{url:e.url}}}},s)}};var P=class{constructor(e){this.httpClient=e;}async upload(e,s){let o={message:{attachment:{type:e.type,payload:{url:e.url,is_reusable:e.is_reusable??true}}}};return this.httpClient.request({method:"POST",path:m.MESSAGE_ATTACHMENTS,body:o,accessToken:s?.accessToken})}};var k=class{constructor(e){this.httpClient=e;}async moderate(e,s){return this.httpClient.request({method:"POST",path:m.MODERATE_CONVERSATIONS,body:e,accessToken:s?.accessToken})}async blockUser(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["block_user"]},s)}async unblockUser(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["unblock_user"]},s)}async banUser(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["ban_user"]},s)}async unbanUser(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["unban_user"]},s)}async moveToSpam(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["move_to_spam"]},s)}async blockAndSpam(e,s){let o=Array.isArray(e)?e.map(a=>({id:a})):[{id:e}];return this.moderate({user_ids:o,actions:["block_user","move_to_spam"]},s)}};var i=class extends Error{constructor(e){super(e),this.name="TemplateValidationError";}};function ce(t){if(t.length===0)throw new i("Generic template must have at least 1 element");if(t.length>d.GENERIC_ELEMENTS_MAX)throw new i(`Generic template cannot have more than ${d.GENERIC_ELEMENTS_MAX} elements`);t.forEach((e,s)=>{Xe(e,s);});}function Xe(t,e){if(!t.title||t.title.trim()==="")throw new i(`Element ${e}: title is required`);if(t.title.length>d.GENERIC_TITLE_MAX_CHARS)throw new i(`Element ${e}: title cannot exceed ${d.GENERIC_TITLE_MAX_CHARS} characters`);if(t.subtitle&&t.subtitle.length>d.GENERIC_SUBTITLE_MAX_CHARS)throw new i(`Element ${e}: subtitle cannot exceed ${d.GENERIC_SUBTITLE_MAX_CHARS} characters`);if(t.image_url&&!S(t.image_url))throw new i(`Element ${e}: image_url must be HTTPS`);if(t.buttons&&L(t.buttons,`Element ${e}`),!!!(t.subtitle||t.image_url||t.default_action||t.buttons&&t.buttons.length>0))throw new i(`Element ${e}: must have at least one additional property beyond title`)}function de(t,e){if(!t||t.trim()==="")throw new i("Button template text is required");if(t.length>d.BUTTON_TEXT_MAX_CHARS)throw new i(`Button template text cannot exceed ${d.BUTTON_TEXT_MAX_CHARS} characters`);if(e.length===0)throw new i("Button template must have at least 1 button");L(e,"Button template");}function pe(t){if(!t.media_type)throw new i("Media template element must have media_type");if(!t.url&&!t.attachment_id)throw new i("Media template element must have either url or attachment_id");if(t.url&&t.attachment_id)throw new i("Media template element cannot have both url and attachment_id");if(t.url&&!S(t.url))throw new i("Media template url must be HTTPS");if(t.buttons){if(t.buttons.length>d.MEDIA_BUTTONS_MAX_COUNT)throw new i(`Media template cannot have more than ${d.MEDIA_BUTTONS_MAX_COUNT} buttons`);L(t.buttons,"Media template");}}function L(t,e){if(t.length>d.BUTTONS_MAX_COUNT)throw new i(`${e} cannot have more than ${d.BUTTONS_MAX_COUNT} buttons`);t.forEach((s,o)=>{je(s,`${e} button ${o}`);});}function je(t,e){if(!t.type)throw new i(`${e}: type is required`);if(t.type!=="account_unlink"&&(!t.title||t.title.trim()===""))throw new i(`${e}: title is required for ${t.type} buttons`);if(t.title&&t.title.length>d.BUTTON_TITLE_MAX_CHARS)throw new i(`${e}: title cannot exceed ${d.BUTTON_TITLE_MAX_CHARS} characters`);switch(t.type){case "web_url":if(!t.url)throw new i(`${e}: url is required for web_url buttons`);if(!S(t.url))throw new i(`${e}: url must be HTTPS for web_url buttons`);break;case "postback":if(!t.payload)throw new i(`${e}: payload is required for postback buttons`);if(t.payload.length>d.POSTBACK_PAYLOAD_MAX_CHARS)throw new i(`${e}: payload cannot exceed ${d.POSTBACK_PAYLOAD_MAX_CHARS} characters`);break;case "phone_number":if(!t.payload)throw new i(`${e}: payload is required for phone_number buttons`);if(!t.payload.startsWith("+"))throw new i(`${e}: phone_number payload must start with + (e.g., +1234567890)`);break;case "game_play":break;case "account_link":if(!t.url)throw new i(`${e}: url is required for account_link buttons`);if(!S(t.url))throw new i(`${e}: url must be HTTPS for account_link buttons`);break;}if(t.type==="web_url"&&t.messenger_extensions&&t.fallback_url&&!S(t.fallback_url))throw new i(`${e}: fallback_url must be HTTPS`)}function S(t){try{return new URL(t).protocol==="https:"}catch{return false}}var _=class{constructor(e){this.httpClient=e;}async generic(e,s){ce(e.elements);let o={template_type:"generic",elements:e.elements,image_aspect_ratio:e.image_aspect_ratio},a={recipient:e.recipient,messaging_type:e.messaging_type||"UPDATE",message:{attachment:{type:"template",payload:o}},notification_type:e.notification_type,tag:e.tag};return this.httpClient.request({method:"POST",path:m.MESSAGES,body:a,accessToken:s?.accessToken})}async button(e,s){de(e.text,e.buttons);let o={template_type:"button",text:e.text,buttons:e.buttons},a={recipient:e.recipient,messaging_type:e.messaging_type||"UPDATE",message:{attachment:{type:"template",payload:o}},notification_type:e.notification_type,tag:e.tag};return this.httpClient.request({method:"POST",path:m.MESSAGES,body:a,accessToken:s?.accessToken})}async media(e,s){pe(e.element);let o={template_type:"media",elements:[e.element]},a={recipient:e.recipient,messaging_type:e.messaging_type||"UPDATE",message:{attachment:{type:"template",payload:o}},notification_type:e.notification_type,tag:e.tag};return this.httpClient.request({method:"POST",path:m.MESSAGES,body:a,accessToken:s?.accessToken})}async product(e,s){let o={template_type:"product",elements:e.elements},a={recipient:e.recipient,messaging_type:e.messaging_type||"UPDATE",message:{attachment:{type:"template",payload:o}},notification_type:e.notification_type,tag:e.tag};return this.httpClient.request({method:"POST",path:m.MESSAGES,body:a,accessToken:s?.accessToken})}};var A=class{constructor(e){this.httpClient=e;}async get(e,s){let{psid:o,fields:a=["first_name","last_name"]}=e,n=new URLSearchParams({fields:a.join(",")});return this.httpClient.request({method:"GET",path:`/${o}?${n.toString()}`,body:void 0,accessToken:s?.accessToken})}async getBasic(e,s){return this.get({psid:e,fields:["first_name","last_name","profile_pic"]},s)}async getFull(e,s){return this.get({psid:e,fields:["id","name","first_name","last_name","profile_pic","locale","timezone","gender"]},s)}async getName(e,s){return this.get({psid:e,fields:["first_name","last_name"]},s)}async getProfilePicture(e,s){return this.get({psid:e,fields:["profile_pic"]},s)}};var R=class{constructor(e){this.httpClient=e;}async list(e,s,o){if(!e)throw new p("Page ID is required");let a={};return s?.platform&&(a.platform=s.platform),s?.user_id&&(a.user_id=s.user_id),s?.folder&&(a.folder=s.folder),s?.limit&&(a.limit=s.limit.toString()),s?.after&&(a.after=s.after),s?.before&&(a.before=s.before),this.httpClient.request({method:"GET",path:`/${e}/conversations`,query:a,accessToken:o?.accessToken})}async get(e,s,o){if(!e)throw new p("Conversation ID is required");let a={};return s?.fields&&s.fields.length>0&&(a.fields=s.fields.join(",")),s?.limit&&(a.limit=s.limit.toString()),s?.after&&(a.after=s.after),s?.before&&(a.before=s.before),this.httpClient.request({method:"GET",path:`/${e}`,query:a,accessToken:o?.accessToken})}async getMessages(e,s,o){if(!e)throw new p("Conversation ID is required");let a={fields:"messages"};s?.limit&&(a.limit=s.limit.toString()),s?.after&&(a.after=s.after),s?.before&&(a.before=s.before);let n=await this.httpClient.request({method:"GET",path:`/${e}`,query:a,accessToken:o?.accessToken});return {data:n.messages?.data||[],paging:n.messages?.paging}}async getMessage(e,s,o){if(!e)throw new p("Message ID is required");let a={};return s?.fields&&s.fields.length>0?a.fields=s.fields.join(","):a.fields="id,created_time,from,to,message,attachments,reactions,reply_to",this.httpClient.request({method:"GET",path:`/${e}`,query:a,accessToken:o?.accessToken})}async getRecentMessages(e,s){let a=(await this.getMessages(e,{limit:20},s)).data.map(n=>this.getMessage(n.id,void 0,s));return Promise.all(a)}async findByUser(e,s,o,a){let n=await this.list(e,{platform:o,user_id:s},a);return n.data&&n.data.length>0&&n.data[0]?n.data[0].id:null}};var V=class{send;attachments;moderation;templates;profile;conversations;httpClient;constructor(e={}){this.validateConfig(e);let s={accessToken:e.accessToken,version:e.version||ne,baseUrl:e.baseUrl,timeout:e.timeout,maxRetries:e.maxRetries};this.httpClient=new C(s),this.send=new M(this.httpClient),this.attachments=new P(this.httpClient),this.moderation=new k(this.httpClient),this.templates=new _(this.httpClient),this.profile=new A(this.httpClient),this.conversations=new R(this.httpClient);}validateConfig(e){if(e.accessToken!==void 0&&(typeof e.accessToken!="string"||e.accessToken.trim()===""))throw new p("Access token must be a non-empty string");if(e.version&&typeof e.version!="string")throw new p("API version must be a string");if(e.timeout&&(typeof e.timeout!="number"||e.timeout<=0))throw new p("Timeout must be a positive number");if(e.maxRetries&&(typeof e.maxRetries!="number"||e.maxRetries<0))throw new p("Max retries must be a non-negative number")}};var x=(c=>(c.MESSAGE="message",c.MESSAGE_EDIT="message_edit",c.MESSAGE_REACTION="reaction",c.MESSAGE_READ="read",c.MESSAGING_FEEDBACK="messaging_feedback",c.MESSAGING_POSTBACK="postback",c.FEED="feed",c.VIDEOS="videos",c.LIVE_VIDEOS="live_videos",c))(x||{});function $e(t){return typeof t.id=="string"&&t.id.length>0}function ge(t){let e=[];if(t.object==="page"&&Array.isArray(t.entry))for(let s of t.entry)Array.isArray(s.messaging)&&e.push(...s.messaging);return e}function Ee(t){let e=[];if(t.object==="page"&&Array.isArray(t.entry))for(let s of t.entry)Array.isArray(s.changes)&&e.push(...s.changes);return e}function O(t){let e=$e(t.sender);return {senderId:t.sender.id,userRef:t.sender.user_ref,recipientId:t.recipient.id,timestamp:t.timestamp,isIdentifiedUser:e,eventDate:new Date(t.timestamp)}}function Ke(t){return t&&typeof t=="object"&&"message_edit"in t}function Ye(t){return {...O(t),messageId:t.message_edit.mid,updatedText:t.message_edit.text,editCount:t.message_edit.num_edit}}var Qe={MAX_EDITS:5,EVENT_TYPE:"message_edit"};var w=(l=>(l.LIKE="like",l.DISLIKE="dislike",l.LOVE="love",l.SAD="sad",l.ANGRY="angry",l.WOW="wow",l.SMILE="smile",l.OTHER="other",l))(w||{}),U=(s=>(s.REACT="react",s.UNREACT="unreact",s))(U||{});function ze(t){return t&&typeof t=="object"&&"read"in t}function Ze(t){return {senderId:t.sender.id,recipientId:t.recipient.id,watermarkTimestamp:t.read.watermark,readTimestamp:t.timestamp,watermarkDate:new Date(t.read.watermark),readDate:new Date(t.timestamp)}}function me(t,e){return t<=e}function le(t,e){return t.filter(s=>me(s.timestamp,e))}function Je(t,e){return le(t,e).length}var et={EVENT_TYPE:"message_reads",READ_PROPERTY:"read"};function tt(t){return t&&typeof t=="object"&&"postback"in t}function ue(t){return t.postback&&"referral"in t.postback&&t.postback.referral!=null}function fe(t){return t&&typeof t.id=="string"&&t.id.length>0}function st(t){let e=ue(t),s=fe(t.sender);return {payload:t.postback.payload,senderId:t.sender.id,userRef:t.sender.user_ref,recipientId:t.recipient.id,buttonTitle:t.postback.title,messageId:t.postback.mid,timestamp:t.timestamp,referralContext:e?{ref:t.postback.referral.ref,source:t.postback.referral.source,type:t.postback.referral.type}:void 0,isReferred:e,isIdentifiedUser:s}}var ot={GET_STARTED:"GET_STARTED",MAIN_MENU:"MAIN_MENU",HELP:"HELP",SUPPORT:"SUPPORT",CONTACT:"CONTACT",CONTACT_SALES:"CONTACT_SALES",CONTACT_SUPPORT:"CONTACT_SUPPORT",BACK:"BACK",NEXT:"NEXT",CANCEL:"CANCEL",SETTINGS:"SETTINGS",PREFERENCES:"PREFERENCES"},at={MAX_PAYLOAD_LENGTH:1e3,EVENT_TYPE:"postback",REFERRAL_SOURCES:{SHORTLINK:"SHORTLINK",ADS:"ADS",MESSENGER_CODE:"MESSENGER_CODE"},REFERRAL_TYPES:{OPEN_THREAD:"OPEN_THREAD"}};var G=(o=>(o.CSAT="csat",o.NPS="nps",o.CES="ces",o))(G||{}),F=(o=>(o.ONE_TO_FIVE="one_to_five",o.FIVE_STARS="five_stars",o.FIVE_EMOJIS="five_emojis",o))(F||{}),B=(e=>(e.ZERO_TO_TEN="zero_to_ten",e))(B||{}),H=(e=>(e.ONE_TO_SEVEN="one_to_seven",e))(H||{}),q=(e=>(e.FREE_FORM="free_form",e))(q||{});function nt(t){return t&&typeof t=="object"&&"messaging_feedback"in t}function rt(t){let e=[];return t.messaging_feedback.feedback_screens.forEach(s=>{Object.entries(s.questions).forEach(([o,a])=>{e.push({questionId:o,feedbackType:a.type,score:parseInt(a.payload,10),textFeedback:a.follow_up?.payload,screenId:s.screen_id});});}),{senderId:t.sender.id,recipientId:t.recipient.id,submissionTimestamp:t.timestamp,screenCount:t.messaging_feedback.feedback_screens.length,allResponses:e}}function it(t){let e=new Map;return t.messaging_feedback.feedback_screens.forEach(s=>{Object.values(s.questions).forEach(o=>{let a=parseInt(o.payload,10),n=e.get(o.type)||[];e.set(o.type,[...n,a]);});}),e}function ct(t){let e=[];return t.messaging_feedback.feedback_screens.forEach(s=>{Object.values(s.questions).forEach(o=>{o.follow_up?.payload&&e.push(o.follow_up.payload);});}),e}var f={MAX_TEXT_FEEDBACK_LENGTH:400,SCORE_RANGES:{csat:{min:1,max:5},nps:{min:0,max:10},ces:{min:1,max:7}},TEMPLATE_EXPIRY:{MIN_DAYS:1,MAX_DAYS:7,DEFAULT_DAYS:1},QUESTION_ID:{MAX_LENGTH:80,VALID_PATTERN:/^[a-zA-Z0-9_]+$/},TEMPLATE_LIMITS:{MAX_TITLES:1,MAX_SCORING_COMPONENTS:1},EVENT_TYPE:"messaging_feedback"};function dt(t,e){let s=f.SCORE_RANGES[t];return Number.isInteger(e)&&e>=s.min&&e<=s.max}function pt(t){return t.length<=f.QUESTION_ID.MAX_LENGTH&&f.QUESTION_ID.VALID_PATTERN.test(t)}function gt(t){return t.length<=f.MAX_TEXT_FEEDBACK_LENGTH}var X=(r=>(r.ALBUM="album",r.ADDRESS="address",r.COMMENT="comment",r.CONNECTION="connection",r.COUPON="coupon",r.EVENT="event",r.EXPERIENCE="experience",r.GROUP="group",r.GROUP_MESSAGE="group_message",r.INTEREST="interest",r.LINK="link",r.MENTION="mention",r.MILESTONE="milestone",r.NOTE="note",r.PAGE="page",r.PICTURE="picture",r.PLATFORM_STORY="platform-story",r.PHOTO="photo",r.PHOTO_ALBUM="photo-album",r.POST="post",r.PROFILE="profile",r.QUESTION="question",r.RATING="rating",r.REACTION="reaction",r.RELATIONSHIP_STATUS="relationship-status",r.SHARE="share",r.STATUS="status",r.STORY="story",r.TIMELINE_COVER="timeline cover",r.TAG="tag",r.VIDEO="video",r))(X||{}),j=(E=>(E.ADD="add",E.BLOCK="block",E.EDIT="edit",E.EDITED="edited",E.DELETE="delete",E.FOLLOW="follow",E.HIDE="hide",E.MUTE="mute",E.REMOVE="remove",E.UNBLOCK="unblock",E.UNHIDE="unhide",E.UPDATE="update",E))(j||{});function Et(t){return t&&typeof t=="object"&&t.field==="feed"}function he(t){return t.verb==="add"&&t.item==="post"}function be(t){return t.item==="comment"}function ye(t){return t.item==="photo"||t.item==="photo-album"}function Te(t){return t.item==="video"}function Me(t){return t.item==="reaction"}function mt(t){return typeof t.message=="string"&&t.message.length>0}function lt(t,e,s){let{value:o}=s;return {pageId:t,timestamp:e,eventDate:new Date(e),sender:o.from,postId:o.post_id,commentId:o.comment_id,verb:o.verb,item:o.item,message:o.message,isPostCreated:he(o),isComment:be(o),isPhoto:ye(o),isVideo:Te(o),isReaction:Me(o)}}function ut(t){let e=[];return t.photo&&e.push({url:t.photo,id:t.photo_id}),t.photos&&Array.isArray(t.photos)&&e.push(...t.photos.map((s,o)=>({url:s,id:t.photo_ids?.[o]}))),e}var Pe={FIELD_NAME:"feed",MAX_PAGE_LIKES_FOR_NOTIFICATIONS:1e4};var W=(o=>(o.PROCESSING="processing",o.READY="ready",o.ERROR="error",o))(W||{});function ke(t){return t&&typeof t=="object"&&t.field==="videos"}function $(t){return t.status.video_status==="processing"}function K(t){return t.status.video_status==="ready"}function Y(t){return t.status.video_status==="error"}function Se(t,e,s){let{value:o}=s;return {pageId:t,timestamp:e,eventDate:new Date(e),videoId:o.id,status:o.status.video_status,isProcessing:$(o),isReady:K(o),hasError:Y(o)}}function _e(t,e){return t==="processing"&&e==="ready"}function Ae(t,e){return t==="processing"&&e==="error"}var Re={FIELD_NAME:"videos",STATUSES:Object.values(W)};var I=(c=>(c.LIVE="LIVE",c.LIVE_STOPPED="LIVE_STOPPED",c.PROCESSING="PROCESSING",c.SCHEDULED_CANCELED="SCHEDULED_CANCELED",c.SCHEDULED_EXPIRED="SCHEDULED_EXPIRED",c.SCHEDULED_LIVE="SCHEDULED_LIVE",c.SCHEDULED_UNPUBLISHED="SCHEDULED_UNPUBLISHED",c.UNPUBLISHED="UNPUBLISHED",c.VOD="VOD",c))(I||{});function xe(t){return t&&typeof t=="object"&&t.field==="live_videos"}function Q(t){return t.status==="LIVE"}function z(t){return t.status==="SCHEDULED_UNPUBLISHED"||t.status==="SCHEDULED_LIVE"}function Z(t){return t.status==="PROCESSING"}function J(t){return t.status==="LIVE_STOPPED"||t.status==="SCHEDULED_CANCELED"||t.status==="SCHEDULED_EXPIRED"}function ee(t){return t.status==="VOD"}function ve(t,e,s){let{value:o}=s;return {pageId:t,timestamp:e,eventDate:new Date(e),videoId:o.id,status:o.status,isLive:Q(o),isScheduled:z(o),isProcessing:Z(o),hasEnded:J(o),isVODReady:ee(o)}}function Ce(t,e){return t!=="LIVE"&&e==="LIVE"}function Oe(t,e){return t==="LIVE"&&(e==="LIVE_STOPPED"||e==="SCHEDULED_CANCELED"||e==="SCHEDULED_EXPIRED")}var We={FIELD_NAME:"live_videos",STATUSES:Object.values(I)};var te=(g=>(g.AUDIO="audio",g.FILE="file",g.IMAGE="image",g.VIDEO="video",g.FALLBACK="fallback",g.REEL="reel",g.IG_REEL="ig_reel",g))(te||{}),se=(o=>(o.OPEN_THREAD="OPEN_THREAD",o.PRODUCT="product",o.ADS="ads",o))(se||{}),oe=(n=>(n.MESSENGER_CODE="MESSENGER_CODE",n.DISCOVER_TAB="DISCOVER_TAB",n.ADS="ADS",n.SHORTLINK="SHORTLINK",n.CUSTOMER_CHAT_PLUGIN="CUSTOMER_CHAT_PLUGIN",n))(oe||{});function ft(t){return t&&typeof t=="object"&&"message"in t}function ht(t){return typeof t.text=="string"&&t.text.length>0}function D(t){return Array.isArray(t.attachments)&&t.attachments.length>0}function Ie(t){return t.quick_reply!==void 0}function De(t){return t.reply_to!==void 0}function Ne(t){return t.referral!==void 0}function Le(t,e){return t.type===e}function bt(t){let{message:e}=t;return {...O(t),messageId:e.mid,text:e.text,hasAttachments:D(e),isQuickReply:Ie(e),isReply:De(e),hasReferral:Ne(e),quickReplyPayload:e.quick_reply?.payload,repliedToMessageId:e.reply_to?.mid}}function yt(t,e){return D(t)?t.attachments.filter(s=>Le(s,e)):[]}function Tt(t){return D(t)?t.attachments.map(e=>e.payload.url):[]}var Mt={MAX_TEXT_LENGTH:2e3,MAX_QUICK_REPLY_PAYLOAD_LENGTH:1e3,MAX_REFERRAL_REF_LENGTH:250,EVENT_TYPE:"message"},Pt={image:["image/jpeg","image/png","image/gif","image/webp"],video:["video/mp4","video/avi","video/quicktime","video/webm"],audio:["audio/mpeg","audio/mp4","audio/wav","audio/ogg"],file:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain"]};function N(t){return !t||typeof t!="object"?null:"type"in t&&Object.values(x).includes(t.type)?t.type:"message"in t?"message":"message_edit"in t?"message_edit":"reaction"in t?"reaction":"read"in t?"read":"messaging_feedback"in t?"messaging_feedback":"postback"in t?"postback":null}function Ve(t){let e=new Set;if(t.object==="page"&&Array.isArray(t.entry)){for(let s of t.entry)if(Array.isArray(s.messaging))for(let o of s.messaging){let a=N(o);a&&e.add(a);}}return Array.from(e)}function ae(t){return ge(t)}function kt(t){let e=N(t);return e?"type"in t?t:{...t,type:e}:null}async function we(t,e){let s=ae(t);for(let o of s){let a=kt(o);if(!a){e.onUnknown&&await e.onUnknown(o);continue}switch(a.type){case "message":e.onMessage&&await e.onMessage(a);break;case "message_edit":e.onMessageEdit&&await e.onMessageEdit(a);break;case "reaction":e.onMessageReaction&&await e.onMessageReaction(a);break;case "read":e.onMessageRead&&await e.onMessageRead(a);break;case "messaging_feedback":e.onMessagingFeedback&&await e.onMessagingFeedback(a);break;case "postback":e.onMessagingPostback&&await e.onMessagingPostback(a);break;default:let n=a;e.onUnknown&&await e.onUnknown(n);break}}}function Ue(t,e){return t["hub.mode"]==="subscribe"&&t["hub.verify_token"]===e?t["hub.challenge"]:null}async function Ge(t,e,s){if(!e)return {isValid:false,error:"Missing X-Hub-Signature-256 header"};if(!e.startsWith("sha256="))return {isValid:false,error:"Invalid signature format. Expected sha256= prefix"};if(!s)return {isValid:false,error:"App secret is required for signature verification"};try{if(typeof Buffer>"u")return {isValid:!1,error:"Signature verification is only supported in Node.js environments"};let o=await import('crypto'),a=e.substring(7),n=o.createHmac("sha256",s).update(t).digest("hex"),h=Buffer.from(a,"hex"),g=Buffer.from(n,"hex");if(h.length!==g.length)return {isValid:!1,error:"Signature length mismatch"};let l=o.timingSafeEqual(h,g);return {isValid:l,error:l?void 0:"Signature verification failed"}}catch(o){return {isValid:false,error:`Signature verification error: ${o instanceof Error?o.message:"Unknown error"}`}}}
2
+ exports.ATTACHMENT_LIMITS=Fe;exports.ATTACHMENT_MIME_TYPES=Pt;exports.AttachmentsAPI=P;exports.CESDisplayOption=H;exports.COMMON_POSTBACK_PAYLOADS=ot;exports.CSATDisplayOption=F;exports.ConversationsAPI=R;exports.FEED_CONSTANTS=Pe;exports.FeedActionVerb=j;exports.FeedItemType=X;exports.FeedbackType=G;exports.FollowUpType=q;exports.LIVE_VIDEO_CONSTANTS=We;exports.LiveVideoStatus=I;exports.MESSAGE_CONSTANTS=Mt;exports.MESSAGE_EDIT_CONSTANTS=Qe;exports.MESSAGE_LIMITS=v;exports.MESSAGE_READS_CONSTANTS=et;exports.MESSAGING_FEEDBACK_CONSTANTS=f;exports.MessageReactionAction=U;exports.MessageReactionType=w;exports.MessageReferralSource=oe;exports.MessageReferralType=se;exports.MessageValidationError=T;exports.Messenger=V;exports.MessengerAPIError=u;exports.MessengerConfigError=p;exports.MessengerNetworkError=b;exports.MessengerTimeoutError=y;exports.ModerationAPI=k;exports.NPSDisplayOption=B;exports.POSTBACK_CONSTANTS=at;exports.ProfileAPI=A;exports.SendAPI=M;exports.TEMPLATE_LIMITS=d;exports.TemplateValidationError=i;exports.TemplatesAPI=_;exports.VIDEO_CONSTANTS=Re;exports.VideoStatus=W;exports.WebhookAttachmentType=te;exports.WebhookEventType=x;exports.extractFeedContext=lt;exports.extractLiveVideoContext=ve;exports.extractMessageContext=bt;exports.extractMessageEditContext=Ye;exports.extractMessageReadsContext=Ze;exports.extractMessagingFeedbackContext=rt;exports.extractPageEvents=Ee;exports.extractPhotos=ut;exports.extractPostbackContext=st;exports.extractTextFeedback=ct;exports.extractVideoContext=Se;exports.extractWebhookEvents=ae;exports.getAttachmentUrls=Tt;exports.getAttachmentsByType=yt;exports.getFeedbackScoresByType=it;exports.getReadMessageCount=Je;exports.getReadMessages=le;exports.getWebhookEventType=N;exports.getWebhookPayloadEventTypes=Ve;exports.hasAttachments=D;exports.hasEnded=J;exports.hasMessage=mt;exports.hasQuickReply=Ie;exports.hasReferral=Ne;exports.hasReferralData=ue;exports.isAttachmentType=Le;exports.isComment=be;exports.isCompletingEncoding=_e;exports.isEncodingFailed=Ae;exports.isEndingLive=Oe;exports.isFeedEvent=Et;exports.isFeedVideo=Te;exports.isGoingLive=Ce;exports.isIdentifiedSender=fe;exports.isLive=Q;exports.isLiveVideoEvent=xe;exports.isLiveVideoProcessing=Z;exports.isMessageEditEvent=Ke;exports.isMessageEvent=ft;exports.isMessageRead=me;exports.isMessageReadsEvent=ze;exports.isMessagingFeedbackEvent=nt;exports.isMessagingPostbackEvent=tt;exports.isPhoto=ye;exports.isPostCreated=he;exports.isReaction=Me;exports.isReplyMessage=De;exports.isScheduled=z;exports.isTextMessage=ht;exports.isVODReady=ee;exports.isValidFeedbackScore=dt;exports.isValidQuestionId=pt;exports.isValidTextFeedback=gt;exports.isVideoEvent=ke;exports.isVideoProcessing=$;exports.isVideoReady=K;exports.processWebhookEvents=we;exports.verifyWebhookSignature=Ge;exports.verifyWebhookSubscription=Ue;exports.videoHasError=Y;//# sourceMappingURL=index.cjs.map
3
3
  //# sourceMappingURL=index.cjs.map