meta-cloud-api 0.2.23 → 0.2.25
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/dist/{chunk-EYGUX4EA.js → chunk-2NCV35XS.js} +2 -2
- package/dist/{chunk-EYGUX4EA.js.map → chunk-2NCV35XS.js.map} +1 -1
- package/dist/chunk-M2GC5VFJ.js +2 -0
- package/dist/{chunk-4C666HHU.js.map → chunk-M2GC5VFJ.js.map} +1 -1
- package/dist/{chunk-BSNA6RYF.js → chunk-XQDM2WBV.js} +3 -3
- package/dist/{chunk-BSNA6RYF.js.map → chunk-XQDM2WBV.js.map} +1 -1
- package/dist/chunk-ZJV5NIQ7.js +3 -0
- package/dist/chunk-ZJV5NIQ7.js.map +1 -0
- package/dist/core/webhook/index.d.ts +328 -74
- package/dist/core/webhook/index.js +1 -1
- package/dist/core/whatsapp/index.js +1 -1
- package/dist/features/encryption/index.js +1 -1
- package/dist/features/flow/index.js +1 -1
- package/dist/features/media/index.js +1 -1
- package/dist/features/messages/index.js +1 -1
- package/dist/features/phone/index.js +1 -1
- package/dist/features/profile/index.js +1 -1
- package/dist/features/qrCode/index.js +1 -1
- package/dist/features/registration/index.js +1 -1
- package/dist/features/template/index.js +1 -1
- package/dist/features/twoStepVerification/index.js +1 -1
- package/dist/features/waba/index.js +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/shared/types/enums.js +1 -1
- package/dist/shared/utils/isMetaError.js +1 -1
- package/package.json +43 -1
- package/dist/chunk-4C666HHU.js +0 -2
- package/dist/chunk-ADHNXDTF.js +0 -3
- package/dist/chunk-ADHNXDTF.js.map +0 -1
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { M as MessageTypesEnum } from '../../enums-CI7vzKhn.js';
|
|
2
|
-
import { WhatsAppConfig } from '../../shared/types/config.js';
|
|
3
|
-
import { IncomingMessage } from 'http';
|
|
4
2
|
import { c as FlowEndpointRequest, m as FlowTypeEnum } from '../../FlowApi-BhpWbli2.js';
|
|
3
|
+
import { WabaConfigType, WhatsAppConfig } from '../../shared/types/config.js';
|
|
5
4
|
import { WhatsApp } from '../whatsapp/index.js';
|
|
5
|
+
import { Request as Request$1, Response as Response$1 } from 'express';
|
|
6
|
+
import { FastifyRequest, FastifyReply } from 'fastify';
|
|
7
|
+
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
8
|
+
import { Observable } from 'rxjs';
|
|
9
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
10
|
+
import { NextRequest } from 'next/server';
|
|
6
11
|
import '../../base--LmzWHx3.js';
|
|
7
12
|
import '../../MessageApi-Cr3Q6qg4.js';
|
|
8
13
|
import '../../MediaApi-DM3WohTN.js';
|
|
@@ -476,6 +481,125 @@ interface WebhookMessage {
|
|
|
476
481
|
*/
|
|
477
482
|
originalData: any;
|
|
478
483
|
}
|
|
484
|
+
/**
|
|
485
|
+
* Represents a message status update received through the webhook
|
|
486
|
+
* Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#statuses-object
|
|
487
|
+
*/
|
|
488
|
+
interface WebhookMessageStatus {
|
|
489
|
+
/**
|
|
490
|
+
* The phone number ID that received the status update
|
|
491
|
+
*/
|
|
492
|
+
phoneNumberId: string;
|
|
493
|
+
/**
|
|
494
|
+
* The display phone number that received the status update
|
|
495
|
+
*/
|
|
496
|
+
displayPhoneNumber: string;
|
|
497
|
+
/**
|
|
498
|
+
* Arbitrary string included in sent message
|
|
499
|
+
*/
|
|
500
|
+
biz_opaque_callback_data?: string;
|
|
501
|
+
/**
|
|
502
|
+
* Information about the conversation
|
|
503
|
+
*/
|
|
504
|
+
conversation?: {
|
|
505
|
+
/**
|
|
506
|
+
* Represents the ID of the conversation the given status notification belongs to
|
|
507
|
+
*/
|
|
508
|
+
id: string;
|
|
509
|
+
/**
|
|
510
|
+
* Describes conversation category
|
|
511
|
+
*/
|
|
512
|
+
origin: {
|
|
513
|
+
/**
|
|
514
|
+
* Indicates conversation category. This can also be referred to as a conversation entry point
|
|
515
|
+
* - authentication: Conversation opened by business sending template categorized as AUTHENTICATION
|
|
516
|
+
* - marketing: Conversation opened by business sending template categorized as MARKETING
|
|
517
|
+
* - utility: Conversation opened by business sending template categorized as UTILITY
|
|
518
|
+
* - service: Conversation opened by business replying to customer within service window
|
|
519
|
+
* - referral_conversion: Free entry point conversation
|
|
520
|
+
*/
|
|
521
|
+
type: 'authentication' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
|
|
522
|
+
};
|
|
523
|
+
/**
|
|
524
|
+
* Date when the conversation expires. Only present for messages with status 'sent'
|
|
525
|
+
*/
|
|
526
|
+
expiration_timestamp?: string;
|
|
527
|
+
};
|
|
528
|
+
/**
|
|
529
|
+
* Array of error objects describing the error
|
|
530
|
+
*/
|
|
531
|
+
errors?: Array<{
|
|
532
|
+
/**
|
|
533
|
+
* Error code
|
|
534
|
+
*/
|
|
535
|
+
code: number;
|
|
536
|
+
/**
|
|
537
|
+
* Error code title
|
|
538
|
+
*/
|
|
539
|
+
title: string;
|
|
540
|
+
/**
|
|
541
|
+
* Error code message
|
|
542
|
+
*/
|
|
543
|
+
message: string;
|
|
544
|
+
/**
|
|
545
|
+
* Error details object
|
|
546
|
+
*/
|
|
547
|
+
error_data?: {
|
|
548
|
+
/**
|
|
549
|
+
* Describes the error details
|
|
550
|
+
*/
|
|
551
|
+
details: string;
|
|
552
|
+
};
|
|
553
|
+
}>;
|
|
554
|
+
/**
|
|
555
|
+
* The ID for the message that the business sent to a customer
|
|
556
|
+
*/
|
|
557
|
+
id: string;
|
|
558
|
+
/**
|
|
559
|
+
* Pricing information for the message/conversation
|
|
560
|
+
*/
|
|
561
|
+
pricing?: {
|
|
562
|
+
/**
|
|
563
|
+
* Indicates if the given message or conversation is billable
|
|
564
|
+
* @deprecated This field is deprecated. Visit the WhatsApp Changelog for more information.
|
|
565
|
+
*/
|
|
566
|
+
billable?: boolean;
|
|
567
|
+
/**
|
|
568
|
+
* Indicates the conversation category:
|
|
569
|
+
* - authentication: Authentication conversation
|
|
570
|
+
* - authentication_international: Authentication-international conversation
|
|
571
|
+
* - marketing: Marketing conversation
|
|
572
|
+
* - utility: Utility conversation
|
|
573
|
+
* - service: Service conversation
|
|
574
|
+
* - referral_conversion: Free entry point conversation
|
|
575
|
+
*/
|
|
576
|
+
category: 'authentication' | 'authentication_international' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
|
|
577
|
+
/**
|
|
578
|
+
* Type of pricing model used by the business. Current supported value is CBP
|
|
579
|
+
*/
|
|
580
|
+
pricing_model: 'CBP';
|
|
581
|
+
};
|
|
582
|
+
/**
|
|
583
|
+
* The customer's WhatsApp ID. Business can respond to customer using this ID.
|
|
584
|
+
* This ID may not match the customer's phone number.
|
|
585
|
+
*/
|
|
586
|
+
recipient_id: string;
|
|
587
|
+
/**
|
|
588
|
+
* Status of the message:
|
|
589
|
+
* - delivered: Message has been delivered
|
|
590
|
+
* - read: Message has been read by the customer
|
|
591
|
+
* - sent: Message has been sent to the customer
|
|
592
|
+
*/
|
|
593
|
+
status: 'delivered' | 'read' | 'sent';
|
|
594
|
+
/**
|
|
595
|
+
* Unix timestamp for the status message
|
|
596
|
+
*/
|
|
597
|
+
timestamp: string;
|
|
598
|
+
/**
|
|
599
|
+
* The original status data as received from the webhook
|
|
600
|
+
*/
|
|
601
|
+
originalData: any;
|
|
602
|
+
}
|
|
479
603
|
/**
|
|
480
604
|
* Webhook event received from WhatsApp
|
|
481
605
|
*/
|
|
@@ -493,14 +617,6 @@ interface WebhookEvent {
|
|
|
493
617
|
*/
|
|
494
618
|
timestamp: number;
|
|
495
619
|
}
|
|
496
|
-
/**
|
|
497
|
-
* Message handler function type
|
|
498
|
-
*/
|
|
499
|
-
type MessageHandler = (message: WebhookMessage) => void | Promise<void>;
|
|
500
|
-
/**
|
|
501
|
-
* Event handler function type
|
|
502
|
-
*/
|
|
503
|
-
type EventHandler = (event: WebhookEvent) => void | Promise<void>;
|
|
504
620
|
/**
|
|
505
621
|
* Message status enum
|
|
506
622
|
*/
|
|
@@ -521,110 +637,248 @@ declare enum EventField {
|
|
|
521
637
|
UNKNOWN = "unknown"
|
|
522
638
|
}
|
|
523
639
|
|
|
524
|
-
interface
|
|
525
|
-
|
|
640
|
+
interface WebhookRequest {
|
|
641
|
+
method: string;
|
|
526
642
|
query: Record<string, any>;
|
|
527
|
-
|
|
643
|
+
body: any;
|
|
644
|
+
headers: Record<string, string | string[] | undefined>;
|
|
645
|
+
rawBody?: string;
|
|
528
646
|
}
|
|
529
|
-
interface
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
end: () => void;
|
|
647
|
+
interface WebhookResponse {
|
|
648
|
+
statusCode: number;
|
|
649
|
+
body?: any;
|
|
650
|
+
headers?: Record<string, string>;
|
|
534
651
|
}
|
|
652
|
+
type MessageHandler = (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>;
|
|
653
|
+
type EventHandler = (event: WebhookEvent) => void | Promise<void>;
|
|
654
|
+
type StatusHandler = (whatsapp: WhatsApp, statuses: WebhookMessageStatus) => void | Promise<void>;
|
|
655
|
+
type FlowHandler = (whatsapp: WhatsApp, request: FlowEndpointRequest) => any | Promise<any>;
|
|
656
|
+
/**
|
|
657
|
+
* Pure function to handle webhook verification
|
|
658
|
+
*/
|
|
659
|
+
declare function verifyWebhook(request: WebhookRequest, verificationToken: string): WebhookResponse;
|
|
660
|
+
/**
|
|
661
|
+
* Pure function to process webhook messages
|
|
662
|
+
*/
|
|
663
|
+
declare function processWebhookMessages(request: WebhookRequest, whatsapp: WhatsApp, handlers: {
|
|
664
|
+
messageHandlers: Map<MessageTypesEnum, MessageHandler>;
|
|
665
|
+
eventHandlers: Map<string, EventHandler>;
|
|
666
|
+
statusHandlers?: Map<MessageStatus, StatusHandler>;
|
|
667
|
+
preProcessHandler?: MessageHandler;
|
|
668
|
+
postProcessHandler?: MessageHandler;
|
|
669
|
+
}): Promise<WebhookResponse>;
|
|
535
670
|
/**
|
|
536
|
-
*
|
|
671
|
+
* Pure function to handle flow requests
|
|
672
|
+
*/
|
|
673
|
+
declare function processFlowRequest(request: WebhookRequest, config: WabaConfigType, whatsapp: WhatsApp, flowHandlers: Map<FlowTypeEnum, FlowHandler>): Promise<WebhookResponse>;
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Framework-agnostic WebhookHandler using pure functions
|
|
537
677
|
*/
|
|
538
678
|
declare class WebhookHandler {
|
|
539
679
|
private config;
|
|
540
680
|
private client;
|
|
541
681
|
private messageHandlers;
|
|
682
|
+
private statusHandlers;
|
|
542
683
|
private eventHandlers;
|
|
543
684
|
private preProcessHandler;
|
|
544
685
|
private postProcessHandler;
|
|
545
686
|
private flowHandlers;
|
|
546
|
-
/**
|
|
547
|
-
* Create a new WebhookHandler
|
|
548
|
-
* @param config The WhatsApp configuration
|
|
549
|
-
*/
|
|
550
687
|
constructor(config: WhatsAppConfig);
|
|
551
688
|
/**
|
|
552
|
-
* Handle
|
|
689
|
+
* Handle webhook verification (framework-agnostic)
|
|
553
690
|
*/
|
|
554
|
-
|
|
555
|
-
handleVerificationRequest<Req extends IRequest>(req: Req): string;
|
|
691
|
+
handleVerification: (request: WebhookRequest) => WebhookResponse;
|
|
556
692
|
/**
|
|
557
|
-
* Handle
|
|
693
|
+
* Handle webhook messages (framework-agnostic)
|
|
558
694
|
*/
|
|
559
|
-
|
|
560
|
-
handleWebhookRequest<Req extends IRequest>(req: Req): Promise<{
|
|
561
|
-
success: boolean;
|
|
562
|
-
errors?: string[];
|
|
563
|
-
}>;
|
|
564
|
-
/**
|
|
565
|
-
* Handle webhook requests (both verification and events)
|
|
566
|
-
*/
|
|
567
|
-
handleRequest<Req extends IRequest, Res extends IResponse>(req: Req, res: Res): void | Promise<void>;
|
|
568
|
-
handleRequest<Req extends IRequest>(req: Req): string | Promise<{
|
|
569
|
-
success: boolean;
|
|
570
|
-
errors?: string[];
|
|
571
|
-
}>;
|
|
695
|
+
handleWebhook: (request: WebhookRequest) => Promise<WebhookResponse>;
|
|
572
696
|
/**
|
|
573
|
-
*
|
|
697
|
+
* Handle flow requests (framework-agnostic)
|
|
574
698
|
*/
|
|
575
|
-
|
|
699
|
+
handleFlow: (request: WebhookRequest) => Promise<WebhookResponse>;
|
|
576
700
|
/**
|
|
577
|
-
*
|
|
701
|
+
* Register a message handler for a specific message type
|
|
578
702
|
*/
|
|
579
|
-
|
|
703
|
+
onMessage(type: MessageTypesEnum, handler: MessageHandler): void;
|
|
580
704
|
/**
|
|
581
|
-
* Register a
|
|
705
|
+
* Register a status handler for a specific status type
|
|
582
706
|
*/
|
|
583
|
-
|
|
707
|
+
onStatus(type: MessageStatus, handler: StatusHandler): void;
|
|
584
708
|
/**
|
|
585
709
|
* Register an event handler for a specific field
|
|
586
710
|
*/
|
|
587
|
-
onEvent(field: string, handler:
|
|
711
|
+
onEvent(field: string, handler: EventHandler): void;
|
|
588
712
|
/**
|
|
589
713
|
* Register a pre-process handler that runs before all message handlers
|
|
590
714
|
*/
|
|
591
|
-
onMessagePreProcess(handler:
|
|
715
|
+
onMessagePreProcess(handler: MessageHandler): void;
|
|
592
716
|
/**
|
|
593
717
|
* Register a post-process handler that runs after all message handlers
|
|
594
718
|
*/
|
|
595
|
-
onMessagePostProcess(handler:
|
|
596
|
-
handleFlowRequest<Req extends IRequest & {
|
|
597
|
-
rawBody: string;
|
|
598
|
-
}, Res extends IResponse>(req: Req, res: Res): Promise<void>;
|
|
599
|
-
handleFlowRequest<Req extends IRequest & {
|
|
600
|
-
rawBody: string;
|
|
601
|
-
}>(req: Req): Promise<{
|
|
602
|
-
statusCode: number;
|
|
603
|
-
body: any;
|
|
604
|
-
headers?: Record<string, string>;
|
|
605
|
-
}>;
|
|
719
|
+
onMessagePostProcess(handler: MessageHandler): void;
|
|
606
720
|
/**
|
|
607
|
-
*
|
|
721
|
+
* Register a flow handler for a specific flow type
|
|
608
722
|
*/
|
|
609
|
-
|
|
610
|
-
rawBody: string;
|
|
611
|
-
}): boolean;
|
|
723
|
+
onFlow(type: FlowTypeEnum, handler: FlowHandler): void;
|
|
612
724
|
/**
|
|
613
|
-
*
|
|
725
|
+
* Get the WhatsApp client instance
|
|
614
726
|
*/
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
727
|
+
getClient(): WhatsApp;
|
|
728
|
+
/**
|
|
729
|
+
* Get the configuration
|
|
730
|
+
*/
|
|
731
|
+
getConfig(): WabaConfigType;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
declare const generateXHub256Sig: (body: string, appSecret: string) => string;
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Create Express.js adapter for webhook handlers
|
|
738
|
+
*/
|
|
739
|
+
declare function createExpressAdapter(): {
|
|
620
740
|
/**
|
|
621
|
-
*
|
|
741
|
+
* Handle webhook verification requests
|
|
622
742
|
*/
|
|
623
|
-
|
|
743
|
+
handleVerification: (handler: (request: WebhookRequest) => WebhookResponse) => (req: Request$1, res: Response$1) => void;
|
|
624
744
|
/**
|
|
625
|
-
*
|
|
745
|
+
* Handle webhook POST requests
|
|
746
|
+
*/
|
|
747
|
+
handleWebhook: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (req: Request$1, res: Response$1) => Promise<void>;
|
|
748
|
+
/**
|
|
749
|
+
* Handle flow requests
|
|
750
|
+
*/
|
|
751
|
+
handleFlow: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (req: Request$1, res: Response$1) => Promise<void>;
|
|
752
|
+
/**
|
|
753
|
+
* Universal handler that routes based on method
|
|
754
|
+
*/
|
|
755
|
+
handleRequest: (handlers: {
|
|
756
|
+
verification: (request: WebhookRequest) => WebhookResponse;
|
|
757
|
+
webhook: (request: WebhookRequest) => Promise<WebhookResponse>;
|
|
758
|
+
}) => (req: Request$1, res: Response$1) => Promise<void>;
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Create Fastify adapter for webhook handlers
|
|
763
|
+
*/
|
|
764
|
+
declare function createFastifyAdapter(): {
|
|
765
|
+
/**
|
|
766
|
+
* Handle webhook verification requests
|
|
767
|
+
*/
|
|
768
|
+
handleVerification: (handler: (request: WebhookRequest) => WebhookResponse) => (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
769
|
+
/**
|
|
770
|
+
* Handle webhook POST requests
|
|
771
|
+
*/
|
|
772
|
+
handleWebhook: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
773
|
+
/**
|
|
774
|
+
* Handle flow requests
|
|
775
|
+
*/
|
|
776
|
+
handleFlow: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
777
|
+
/**
|
|
778
|
+
* Universal handler that routes based on method
|
|
626
779
|
*/
|
|
627
|
-
|
|
780
|
+
handleRequest: (handlers: {
|
|
781
|
+
verification: (request: WebhookRequest) => WebhookResponse;
|
|
782
|
+
webhook: (request: WebhookRequest) => Promise<WebhookResponse>;
|
|
783
|
+
}) => (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Custom parameter decorator to inject WebhookRequest
|
|
788
|
+
*/
|
|
789
|
+
declare const WebhookReq: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
790
|
+
/**
|
|
791
|
+
* Interceptor to handle WebhookResponse conversion
|
|
792
|
+
*/
|
|
793
|
+
declare class WebhookResponseInterceptor implements NestInterceptor<WebhookResponse, void> {
|
|
794
|
+
intercept(context: ExecutionContext, next: CallHandler<WebhookResponse>): Observable<void>;
|
|
628
795
|
}
|
|
796
|
+
/**
|
|
797
|
+
* Create NestJS adapter for webhook handlers
|
|
798
|
+
*/
|
|
799
|
+
declare function createNestJSAdapter(): {
|
|
800
|
+
/**
|
|
801
|
+
* Handle webhook verification requests
|
|
802
|
+
*/
|
|
803
|
+
handleVerification: (handler: (request: WebhookRequest) => WebhookResponse) => (req: Request$1, res: Response$1) => void;
|
|
804
|
+
/**
|
|
805
|
+
* Handle webhook POST requests
|
|
806
|
+
*/
|
|
807
|
+
handleWebhook: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (req: Request$1, res: Response$1) => Promise<void>;
|
|
808
|
+
/**
|
|
809
|
+
* Handle flow requests
|
|
810
|
+
*/
|
|
811
|
+
handleFlow: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (req: Request$1, res: Response$1) => Promise<void>;
|
|
812
|
+
/**
|
|
813
|
+
* Universal handler that routes based on method
|
|
814
|
+
*/
|
|
815
|
+
handleRequest: (handlers: {
|
|
816
|
+
verification: (request: WebhookRequest) => WebhookResponse;
|
|
817
|
+
webhook: (request: WebhookRequest) => Promise<WebhookResponse>;
|
|
818
|
+
}) => (req: Request$1, res: Response$1) => Promise<void>;
|
|
819
|
+
/**
|
|
820
|
+
* Create controller method decorator for webhook verification
|
|
821
|
+
*/
|
|
822
|
+
createVerificationHandler: (handler: (request: WebhookRequest) => WebhookResponse) => (target: any, propertyName: string, descriptor: PropertyDescriptor) => void;
|
|
823
|
+
/**
|
|
824
|
+
* Create controller method decorator for webhook POST handling
|
|
825
|
+
*/
|
|
826
|
+
createWebhookHandler: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (target: any, propertyName: string, descriptor: PropertyDescriptor) => void;
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Create Next.js Pages Router adapter for webhook handlers
|
|
831
|
+
* For App Router, use createNextJSRouteHandlerAdapter instead
|
|
832
|
+
*/
|
|
833
|
+
declare function createNextJSAdapter(): {
|
|
834
|
+
/**
|
|
835
|
+
* Handle webhook verification requests
|
|
836
|
+
*/
|
|
837
|
+
handleVerification: (handler: (request: WebhookRequest) => WebhookResponse) => (req: NextApiRequest, res: NextApiResponse) => void;
|
|
838
|
+
/**
|
|
839
|
+
* Handle webhook POST requests
|
|
840
|
+
*/
|
|
841
|
+
handleWebhook: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
842
|
+
/**
|
|
843
|
+
* Handle flow requests
|
|
844
|
+
*/
|
|
845
|
+
handleFlow: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
846
|
+
/**
|
|
847
|
+
* Universal handler that routes based on method
|
|
848
|
+
*/
|
|
849
|
+
handleRequest: (handlers: {
|
|
850
|
+
verification: (request: WebhookRequest) => WebhookResponse;
|
|
851
|
+
webhook: (request: WebhookRequest) => Promise<WebhookResponse>;
|
|
852
|
+
}) => (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Create Next.js Route Handler adapter for webhook handlers
|
|
857
|
+
*/
|
|
858
|
+
declare function createNextJSRouteHandlerAdapter(): {
|
|
859
|
+
/**
|
|
860
|
+
* Handle webhook verification requests (GET)
|
|
861
|
+
*/
|
|
862
|
+
handleVerification: (handler: (request: WebhookRequest) => WebhookResponse) => (req: NextRequest) => Response;
|
|
863
|
+
/**
|
|
864
|
+
* Handle webhook POST requests
|
|
865
|
+
*/
|
|
866
|
+
handleWebhook: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (req: Request) => Promise<Response>;
|
|
867
|
+
/**
|
|
868
|
+
* Handle flow requests
|
|
869
|
+
*/
|
|
870
|
+
handleFlow: (handler: (request: WebhookRequest) => Promise<WebhookResponse>) => (req: Request) => Promise<Response>;
|
|
871
|
+
/**
|
|
872
|
+
* Universal handler that creates separate GET and POST handlers
|
|
873
|
+
* Usage: export const { GET, POST } = adapter.createHandlers({ verification, webhook })
|
|
874
|
+
*/
|
|
875
|
+
createHandlers: (handlers: {
|
|
876
|
+
verification: (request: WebhookRequest) => WebhookResponse;
|
|
877
|
+
webhook: (request: WebhookRequest) => Promise<WebhookResponse>;
|
|
878
|
+
}) => {
|
|
879
|
+
GET: (req: NextRequest) => Response;
|
|
880
|
+
POST: (req: Request) => Promise<Response>;
|
|
881
|
+
};
|
|
882
|
+
};
|
|
629
883
|
|
|
630
|
-
export { EventField, type EventHandler, type
|
|
884
|
+
export { EventField, type EventHandler, type FlowHandler, type MessageHandler, MessageStatus, type StatusHandler, type WebhookContact, type WebhookEvent, WebhookHandler, type WebhookMessage, type WebhookMessageStatus, WebhookReq, type WebhookRequest, type WebhookResponse, WebhookResponseInterceptor, createExpressAdapter, createFastifyAdapter, createNestJSAdapter, createNextJSAdapter, createNextJSRouteHandlerAdapter, generateXHub256Sig, processFlowRequest, processWebhookMessages, verifyWebhook };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{b as EventField,a as MessageStatus,c as
|
|
1
|
+
export{b as EventField,a as MessageStatus,f as WebhookHandler,j as WebhookReq,k as WebhookResponseInterceptor,h as createExpressAdapter,i as createFastifyAdapter,l as createNestJSAdapter,m as createNextJSAdapter,n as createNextJSRouteHandlerAdapter,g as generateXHub256Sig,e as processFlowRequest,d as processWebhookMessages,c as verifyWebhook}from'../../chunk-ZJV5NIQ7.js';import'../../chunk-XQDM2WBV.js';import'../../chunk-3MO3BTBC.js';import'../../chunk-R36L2XYO.js';import'../../chunk-GT3XQN7Y.js';import'../../chunk-O2OTHNWM.js';import'../../chunk-7NQLQPLH.js';import'../../chunk-UQPD6GIF.js';import'../../chunk-5JGM556C.js';import'../../chunk-2NJVBJUN.js';import'../../chunk-XPPDOFBN.js';import'../../chunk-KFPOVYEJ.js';import'../../chunk-7GL74SXM.js';import'../../chunk-A264MT4Q.js';import'../../chunk-GIQLIMOD.js';import'../../chunk-BZ5QDXNR.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{b as WhatsApp}from'../../chunk-
|
|
1
|
+
export{b as WhatsApp}from'../../chunk-XQDM2WBV.js';import'../../chunk-3MO3BTBC.js';import'../../chunk-R36L2XYO.js';import'../../chunk-GT3XQN7Y.js';import'../../chunk-O2OTHNWM.js';import'../../chunk-7NQLQPLH.js';import'../../chunk-UQPD6GIF.js';import'../../chunk-5JGM556C.js';import'../../chunk-2NJVBJUN.js';import'../../chunk-XPPDOFBN.js';import'../../chunk-KFPOVYEJ.js';import'../../chunk-7GL74SXM.js';import'../../chunk-A264MT4Q.js';import'../../chunk-GIQLIMOD.js';import'../../chunk-BZ5QDXNR.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as EncryptionApi,b as default}from'../../chunk-7NQLQPLH.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as EncryptionApi,b as default}from'../../chunk-7NQLQPLH.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as FlowApi,b as default}from'../../chunk-A264MT4Q.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as FlowApi,b as default}from'../../chunk-A264MT4Q.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as MediaApi,b as default}from'../../chunk-XPPDOFBN.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as MediaApi,b as default}from'../../chunk-XPPDOFBN.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as MessageApi,b as default}from'../../chunk-2NJVBJUN.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as MessageApi,b as default}from'../../chunk-2NJVBJUN.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as PhoneNumberApi,b as default}from'../../chunk-GIQLIMOD.js';import'../../chunk-BZ5QDXNR.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as PhoneNumberApi,b as default}from'../../chunk-GIQLIMOD.js';import'../../chunk-BZ5QDXNR.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as BusinessProfileApi,b as default}from'../../chunk-KFPOVYEJ.js';import'../../chunk-7GL74SXM.js';import'../../chunk-BZ5QDXNR.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as BusinessProfileApi,b as default}from'../../chunk-KFPOVYEJ.js';import'../../chunk-7GL74SXM.js';import'../../chunk-BZ5QDXNR.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as default}from'../../chunk-I222VSWK.js';export{a as QrCodeApi}from'../../chunk-GT3XQN7Y.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as default}from'../../chunk-I222VSWK.js';export{a as QrCodeApi}from'../../chunk-GT3XQN7Y.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as RegistrationApi,b as default}from'../../chunk-O2OTHNWM.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as RegistrationApi,b as default}from'../../chunk-O2OTHNWM.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as default}from'../../chunk-H55VIWDI.js';export{a as TemplateApi}from'../../chunk-R36L2XYO.js';import'../../chunk-BZ5QDXNR.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as default}from'../../chunk-H55VIWDI.js';export{a as TemplateApi}from'../../chunk-R36L2XYO.js';import'../../chunk-BZ5QDXNR.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as TwoStepVerificationApi,b as default}from'../../chunk-UQPD6GIF.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as TwoStepVerificationApi,b as default}from'../../chunk-UQPD6GIF.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as WabaApi,b as default}from'../../chunk-5JGM556C.js';import'../../chunk-7GL74SXM.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-
|
|
1
|
+
export{a as WabaApi,b as default}from'../../chunk-5JGM556C.js';import'../../chunk-7GL74SXM.js';import'../../chunk-VW3LGHTJ.js';import'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { EventField, EventHandler, MessageHandler, MessageStatus, WebhookContact, WebhookEvent, WebhookHandler, WebhookMessage } from './core/webhook/index.js';
|
|
1
|
+
export { EventField, EventHandler, FlowHandler, MessageHandler, MessageStatus, StatusHandler, WebhookContact, WebhookEvent, WebhookHandler, WebhookMessage, WebhookMessageStatus, WebhookReq, WebhookRequest, WebhookResponse, WebhookResponseInterceptor, createExpressAdapter, createFastifyAdapter, createNestJSAdapter, createNextJSAdapter, createNextJSRouteHandlerAdapter, generateXHub256Sig, processFlowRequest, processWebhookMessages, verifyWebhook } from './core/webhook/index.js';
|
|
2
2
|
export { A as AudioMediaObject, C as ContactObject, D as DocumentMediaObject, I as ImageMediaObject, a as InteractiveObject, L as LocationObject, b as MessageRequestParams, d as MessageTemplateObject, M as MessagesApi, c as MessagesResponse, R as ReactionParams, S as StatusParams, e as StickerMediaObject, T as TextMessageParams, f as TextObject, V as VideoMediaObject } from './MessageApi-Cr3Q6qg4.js';
|
|
3
3
|
export { WabaConfigType, WhatsAppConfig } from './shared/types/config.js';
|
|
4
4
|
export { A as AudioMediaTypesEnum, k as BusinessVerticalEnum, a as ButtonPositionEnum, B as ButtonTypesEnum, C as CategoryEnum, b as ComponentTypesEnum, c as ConversationTypesEnum, i as CurrencyCodesEnum, j as DataLocalizationRegionEnum, D as DocumentMediaTypesEnum, H as HttpMethodsEnum, e as ImageMediaTypesEnum, I as InteractiveTypesEnum, L as LanguagesEnum, M as MessageTypesEnum, P as ParametersTypesEnum, R as ReferralSourceTypesEnum, h as RequestCodeMethodsEnum, S as StatusEnum, d as StickerMediaTypesEnum, g as SystemChangeTypesEnum, T as TemplateStatusEnum, V as VideoMediaTypesEnum, W as WabaConfigEnum, f as WebhookTypesEnum } from './enums-CI7vzKhn.js';
|
|
@@ -13,7 +13,12 @@ export { Q as QrCodeApi, a as QrCodeClass, b as QrCodeResponse } from './QrCodeA
|
|
|
13
13
|
export { T as TwoStepVerificationApi } from './TwoStepVerificationApi-nJ12648J.js';
|
|
14
14
|
export { b as WABAClass, a as WabaAccount, W as WabaApi } from './WabaApi-BIP6G4pB.js';
|
|
15
15
|
import { WhatsApp } from './core/whatsapp/index.js';
|
|
16
|
-
import '
|
|
16
|
+
import 'express';
|
|
17
|
+
import 'fastify';
|
|
18
|
+
import '@nestjs/common';
|
|
19
|
+
import 'rxjs';
|
|
20
|
+
import 'next';
|
|
21
|
+
import 'next/server';
|
|
17
22
|
import './base--LmzWHx3.js';
|
|
18
23
|
import 'https';
|
|
19
24
|
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as TemplateApi}from'./chunk-H55VIWDI.js';export{a as QrCodeApi}from'./chunk-I222VSWK.js';import'./chunk-W2U7MN7M.js';export{c as
|
|
1
|
+
export{a as TemplateApi}from'./chunk-H55VIWDI.js';export{a as QrCodeApi}from'./chunk-I222VSWK.js';import'./chunk-W2U7MN7M.js';export{b as EventField,a as MessageStatus,f as WebhookHandler,j as WebhookReq,k as WebhookResponseInterceptor,h as createExpressAdapter,i as createFastifyAdapter,l as createNestJSAdapter,m as createNextJSAdapter,n as createNextJSRouteHandlerAdapter,g as generateXHub256Sig,e as processFlowRequest,d as processWebhookMessages,c as verifyWebhook}from'./chunk-ZJV5NIQ7.js';import {b}from'./chunk-XQDM2WBV.js';import'./chunk-3MO3BTBC.js';import'./chunk-R36L2XYO.js';import'./chunk-GT3XQN7Y.js';export{b as RegistrationApi}from'./chunk-O2OTHNWM.js';export{b as EncryptionApi}from'./chunk-7NQLQPLH.js';export{b as TwoStepVerificationApi}from'./chunk-UQPD6GIF.js';export{b as WabaApi}from'./chunk-5JGM556C.js';export{b as MessagesApi}from'./chunk-2NJVBJUN.js';import'./chunk-XPPDOFBN.js';export{b as BusinessProfileApi}from'./chunk-KFPOVYEJ.js';import'./chunk-7GL74SXM.js';export{b as FlowApi}from'./chunk-A264MT4Q.js';export{b as PhoneNumberApi}from'./chunk-GIQLIMOD.js';import'./chunk-BZ5QDXNR.js';import'./chunk-VW3LGHTJ.js';export{q as AudioMediaTypesEnum,y as BusinessVerticalEnum,h as ButtonPositionEnum,g as ButtonTypesEnum,a as CategoryEnum,i as ComponentTypesEnum,k as ConversationTypesEnum,w as CurrencyCodesEnum,x as DataLocalizationRegionEnum,p as DocumentMediaTypesEnum,c as HttpMethodsEnum,o as ImageMediaTypesEnum,f as InteractiveTypesEnum,v as LanguagesEnum,d as MessageTypesEnum,e as ParametersTypesEnum,t as ReferralSourceTypesEnum,u as RequestCodeMethodsEnum,l as StatusEnum,n as StickerMediaTypesEnum,s as SystemChangeTypesEnum,b as TemplateStatusEnum,m as VideoMediaTypesEnum,j as WabaConfigEnum,r as WebhookTypesEnum}from'./chunk-2NCV35XS.js';import'./chunk-M2GC5VFJ.js';var le=b;export{le as default};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["src_default","WhatsApp"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["src_default","WhatsApp"],"mappings":"oxDAGA,IAAOA,EAAQC,CAAAA","file":"index.js","sourcesContent":["import { WebhookHandler } from './core/webhook';\nimport { WhatsApp } from './core/whatsapp';\n\nexport default WhatsApp;\n\nexport * from './core/webhook';\n\nexport { WebhookHandler };\n\nexport {\n BusinessProfileApi,\n EncryptionApi,\n FlowApi,\n MessagesApi,\n PhoneNumberApi,\n QrCodeApi,\n RegistrationApi,\n TemplateApi,\n TwoStepVerificationApi,\n WabaApi,\n} from './features';\n\nexport type {\n AudioMediaObject,\n BusinessProfileClass,\n BusinessProfileResponse,\n ContactObject,\n DocumentMediaObject,\n Flow,\n FlowClass,\n FlowEndpointRequest,\n FlowEndpointResponse,\n ImageMediaObject,\n InteractiveObject,\n LocationObject,\n MediaClass,\n MediaResponse,\n MediasResponse,\n MessageRequestParams,\n MessagesResponse,\n MessageTemplateObject,\n PhoneNumberClass,\n PhoneNumberResponse,\n QrCodeClass,\n QrCodeResponse,\n ReactionParams,\n RegistrationClass,\n StatusParams,\n StickerMediaObject,\n TemplateClass,\n TemplateResponse,\n TextMessageParams,\n TextObject,\n UploadMediaResponse,\n VideoMediaObject,\n WabaAccount,\n WABAClass,\n} from './features';\n\nexport * from './shared/types/config';\nexport * from './shared/types/enums';\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{q as AudioMediaTypesEnum,y as BusinessVerticalEnum,h as ButtonPositionEnum,g as ButtonTypesEnum,a as CategoryEnum,i as ComponentTypesEnum,k as ConversationTypesEnum,w as CurrencyCodesEnum,x as DataLocalizationRegionEnum,p as DocumentMediaTypesEnum,c as HttpMethodsEnum,o as ImageMediaTypesEnum,f as InteractiveTypesEnum,v as LanguagesEnum,d as MessageTypesEnum,e as ParametersTypesEnum,t as ReferralSourceTypesEnum,u as RequestCodeMethodsEnum,l as StatusEnum,n as StickerMediaTypesEnum,s as SystemChangeTypesEnum,b as TemplateStatusEnum,m as VideoMediaTypesEnum,j as WabaConfigEnum,r as WebhookTypesEnum}from'../../chunk-
|
|
1
|
+
export{q as AudioMediaTypesEnum,y as BusinessVerticalEnum,h as ButtonPositionEnum,g as ButtonTypesEnum,a as CategoryEnum,i as ComponentTypesEnum,k as ConversationTypesEnum,w as CurrencyCodesEnum,x as DataLocalizationRegionEnum,p as DocumentMediaTypesEnum,c as HttpMethodsEnum,o as ImageMediaTypesEnum,f as InteractiveTypesEnum,v as LanguagesEnum,d as MessageTypesEnum,e as ParametersTypesEnum,t as ReferralSourceTypesEnum,u as RequestCodeMethodsEnum,l as StatusEnum,n as StickerMediaTypesEnum,s as SystemChangeTypesEnum,b as TemplateStatusEnum,m as VideoMediaTypesEnum,j as WabaConfigEnum,r as WebhookTypesEnum}from'../../chunk-2NCV35XS.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=enums.js.map
|
|
2
2
|
//# sourceMappingURL=enums.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as isMetaError}from'../../chunk-3MO3BTBC.js';import'../../chunk-
|
|
1
|
+
export{a as isMetaError}from'../../chunk-3MO3BTBC.js';import'../../chunk-M2GC5VFJ.js';//# sourceMappingURL=isMetaError.js.map
|
|
2
2
|
//# sourceMappingURL=isMetaError.js.map
|