opensips-js 0.1.47 → 0.1.49

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/index.d.ts CHANGED
@@ -370,7 +370,7 @@ declare type changeActiveCallsListener = (event: { [key: string]: ICall }) => vo
370
370
 
371
371
  declare type changeActiveInputMediaDeviceListener = (event: string) => void
372
372
 
373
- declare type changeActiveMessagesListener = (event: { [key: string]: IMessage }) => void
373
+ declare type changeActiveMessagesListener = (event: { [key: string]: IMessage_2 }) => void
374
374
 
375
375
  declare type changeActiveOutputMediaDeviceListener = (event: string) => void
376
376
 
@@ -394,7 +394,7 @@ declare type changeIsDNDListener = (value: boolean) => void
394
394
 
395
395
  declare type changeIsMutedListener = (value: boolean) => void
396
396
 
397
- declare type changeMsrpSessionListener = (session: IMessage | null) => void
397
+ declare type changeMsrpSessionListener = (session: IMessage_2 | null) => void
398
398
 
399
399
  declare type changeMuteWhenJoinListener = (value: boolean) => void
400
400
 
@@ -402,7 +402,7 @@ declare type changeNoiseReductionStateListener = (event: boolean) => void
402
402
 
403
403
  declare type changeVideoStateListener = (state: boolean) => void
404
404
 
405
- declare type ChangeVolumeEventType = {
405
+ export declare type ChangeVolumeEventType = {
406
406
  callId: string
407
407
  volume: number
408
408
  }
@@ -417,7 +417,7 @@ declare type connectionListener = (value: boolean) => void
417
417
 
418
418
  declare type connectionStateChangeListener = (event: ConnectionStateChangeType) => void
419
419
 
420
- declare type ConnectionStateChangeType = {
420
+ export declare type ConnectionStateChangeType = {
421
421
  session: RTCSessionExtended,
422
422
  connectionState: string
423
423
  }
@@ -430,7 +430,7 @@ declare interface ConnectOptions {
430
430
  pcConfig?: object;
431
431
  }
432
432
 
433
- declare interface CustomLoggerType {
433
+ export declare interface CustomLoggerType {
434
434
  log: CommonLogMethodType
435
435
  warn: CommonLogMethodType
436
436
  error: CommonLogMethodType
@@ -451,7 +451,7 @@ declare type ExactConstraints_2 = {
451
451
  video?: boolean;
452
452
  }
453
453
 
454
- declare interface ICall extends RTCSessionExtended {
454
+ export declare interface ICall extends RTCSessionExtended {
455
455
  roomId?: number
456
456
  localMuted?: boolean
457
457
  localHold?: boolean
@@ -460,14 +460,14 @@ declare interface ICall extends RTCSessionExtended {
460
460
  putOnHoldTimestamp?: number
461
461
  }
462
462
 
463
- declare interface ICallStatus {
463
+ export declare interface ICallStatus {
464
464
  isMoving: boolean
465
465
  isTransferring: boolean
466
466
  isMerging: boolean
467
467
  isTransferred: boolean
468
468
  }
469
469
 
470
- declare interface IMessage extends MSRPSessionExtended {
470
+ export declare interface IMessage extends MSRPSessionExtended {
471
471
  roomId?: number
472
472
  localMuted?: boolean
473
473
  localHold?: boolean
@@ -475,6 +475,14 @@ declare interface IMessage extends MSRPSessionExtended {
475
475
  terminate(): void
476
476
  }
477
477
 
478
+ declare interface IMessage_2 extends MSRPSessionExtended_2 {
479
+ roomId?: number
480
+ localMuted?: boolean
481
+ localHold?: boolean
482
+ audioTag?: StreamMediaType_2
483
+ terminate(): void
484
+ }
485
+
478
486
  declare interface IncomingMSRPSessionEvent {
479
487
  originator: Originator.REMOTE;
480
488
  session: MSRPSession;
@@ -483,9 +491,9 @@ declare interface IncomingMSRPSessionEvent {
483
491
 
484
492
  declare type IncomingMSRPSessionListener = (event: IncomingMSRPSessionEvent) => void;
485
493
 
486
- declare type IOpenSIPSConfiguration = Omit<UAConfigurationExtended, 'sockets'>
494
+ export declare type IOpenSIPSConfiguration = Omit<UAConfigurationExtended, 'sockets'>
487
495
 
488
- declare interface IOpenSIPSJSOptions {
496
+ export declare interface IOpenSIPSJSOptions {
489
497
  configuration: IOpenSIPSConfiguration
490
498
  socketInterfaces: [ string ]
491
499
  sipDomain: string
@@ -500,7 +508,7 @@ declare interface IOpenSIPSJSOptions {
500
508
  msrpWs?: boolean
501
509
  }
502
510
 
503
- declare interface IRoom {
511
+ export declare interface IRoom {
504
512
  started: Date
505
513
  incomingInProgress: boolean
506
514
  roomId: number
@@ -510,7 +518,7 @@ declare type IRoomUpdate = Omit<IRoom, 'started'> & {
510
518
  started?: Date
511
519
  }
512
520
 
513
- declare interface ITimeData {
521
+ export declare interface ITimeData {
514
522
  callId: string
515
523
  hours: number
516
524
  minutes: number
@@ -562,9 +570,11 @@ declare type Listener_2 = (event: unknown) => void
562
570
 
563
571
  declare type Listener_3 = (event: unknown) => void
564
572
 
565
- declare type ListenerCallbackFnType<T extends ListenersKeyType> = OpenSIPSEventMap[T]
573
+ export declare type ListenerCallbackFnType<T extends ListenersKeyType> = OpenSIPSEventMap[T]
574
+
575
+ export declare type ListenerEventType = EndEvent | IncomingEvent | OutgoingEvent | IncomingAckEvent | OutgoingAckEvent
566
576
 
567
- declare type ListenerEventType = EndEvent | IncomingEvent | OutgoingEvent | IncomingAckEvent | OutgoingAckEvent
577
+ declare type ListenerEventType_2 = EndEvent | IncomingEvent | OutgoingEvent | IncomingAckEvent | OutgoingAckEvent
568
578
 
569
579
  declare type ListenersKeyType = keyof OpenSIPSEventMap
570
580
 
@@ -589,51 +599,107 @@ declare const MODULES: {
589
599
 
590
600
  declare type Modules = AudioModuleName | VideoModuleName | MSRPModuleName
591
601
 
602
+ export declare const MSRP_EVT: {
603
+ readonly CREATE: "m.conversation.create";
604
+ readonly MESSAGE: "m.conversation.message";
605
+ readonly MEMBER: "m.conversation.member";
606
+ readonly CLOSED: "m.conversation.closed";
607
+ readonly REOPEN: "m.conversation.reopen";
608
+ readonly DELETE: "m.conversation.delete";
609
+ readonly SYNC: "m.sync";
610
+ readonly UPLOAD_REQUEST: "m.upload.request";
611
+ readonly UPLOAD_RESPONSE: "m.upload.response";
612
+ readonly FILE_ACCESS_REQUEST: "m.file.access.request";
613
+ readonly FILE_ACCESS_RESPONSE: "m.file.access.response";
614
+ readonly REACTION: "m.reaction";
615
+ readonly TYPING: "m.typing";
616
+ readonly PRESENCE: "m.presence";
617
+ readonly SENT: "m.sent";
618
+ readonly DELIVERED: "m.delivered";
619
+ readonly READ: "m.read";
620
+ readonly UNREAD: "m.unread";
621
+ readonly FAILED: "m.failed";
622
+ readonly SENDING: "m.sending";
623
+ };
624
+
592
625
  declare type msrpConversationCreatedListener = (payload: {
593
- conversationKey: string
594
- conversation: MSRPConversationState
626
+ conversation: MSRPConversationState_2
595
627
  }) => void
596
628
 
597
- declare type msrpConversationRemovedListener = (payload: { conversationKey: string }) => void
598
-
599
629
  /**
600
- * Protocol-level conversation state owned by MSRPModule.
601
- *
602
- * Intentionally does NOT carry a `messages` array - the module is a pure
603
- * pipe for chat history. Live messages are emitted via `msrpMessageAdded`
604
- * and historical messages from `m.sync` come through the
605
- * `messagesByConversation` field of the `msrpSyncCompleted` payload.
606
- * The consumer (e.g. a Vue composable) is responsible for collecting them
607
- * into whatever data structure it needs and for downstream concerns like
608
- * deduplication, reaction aggregation and receipt application.
630
+ * A conversation is addressed exclusively by its public numeric
631
+ * `conversation_id`. A stringified id is also accepted for convenience.
609
632
  */
610
- declare interface MSRPConversationState {
611
- conversationKey: string;
612
- creator: string | null;
613
- members: Set<string>;
614
- memberRoles: Map<string, MSRPMemberRole>;
615
- currentUserRole: MSRPMemberRole;
616
- currentUserStatus: MSRPMembership | null;
617
- state_events: {
618
- [key: string]: {
619
- [stateKey: string]: any;
620
- };
621
- };
622
- created_at: number;
623
- updated_at: number;
624
- status?: string;
633
+ declare type MSRPConversationRef = number | string;
634
+
635
+ declare type msrpConversationRemovedListener = (payload: {
636
+ conversation_id?: number
637
+ }) => void
638
+
639
+ export declare interface MSRPConversationState {
640
+ /**
641
+ * Public, stable numeric conversation identifier assigned by the backend.
642
+ * This is the only identifier exposed to application code — conversations
643
+ * are addressed exclusively by `conversation_id`.
644
+ */
645
+ conversation_id?: number
646
+ creator: string | null
647
+ members: Set<string>
648
+ memberRoles: Map<string, MSRPMemberRole>
649
+ currentUserRole: MSRPMemberRole
650
+ currentUserStatus: MSRPMembership | null
651
+ /**
652
+ * Per-user read pointer (backend `last_read_message_id` in the current
653
+ * user's member state). `null` means the whole conversation is unread;
654
+ * an event_id means everything after that event is unread. Consumers
655
+ * derive the unread count from this pointer + the local timeline.
656
+ */
657
+ currentUserLastReadMessageId?: string | null
658
+ state_events: { [key: string]: { [stateKey: string]: any } }
659
+ created_at: number
660
+ updated_at: number
661
+ status?: string
662
+ }
663
+
664
+ declare interface MSRPConversationState_2 {
665
+ /**
666
+ * Public, stable numeric conversation identifier assigned by the backend.
667
+ * This is the only identifier exposed to application code — conversations
668
+ * are addressed exclusively by `conversation_id`.
669
+ */
670
+ conversation_id?: number
671
+ creator: string | null
672
+ members: Set<string>
673
+ memberRoles: Map<string, MSRPMemberRole_2>
674
+ currentUserRole: MSRPMemberRole_2
675
+ currentUserStatus: MSRPMembership_2 | null
676
+ /**
677
+ * Per-user read pointer (backend `last_read_message_id` in the current
678
+ * user's member state). `null` means the whole conversation is unread;
679
+ * an event_id means everything after that event is unread. Consumers
680
+ * derive the unread count from this pointer + the local timeline.
681
+ */
682
+ currentUserLastReadMessageId?: string | null
683
+ state_events: { [key: string]: { [stateKey: string]: any } }
684
+ created_at: number
685
+ updated_at: number
686
+ status?: string
625
687
  }
626
688
 
627
689
  declare type msrpConversationUpdatedListener = (payload: {
628
- conversationKey: string
629
- patch: Partial<MSRPConversationState>
690
+ conversation_id?: number
691
+ patch: Partial<MSRPConversationState_2>
630
692
  }) => void
631
693
 
632
- declare type MSRPInitializingListener = (sessionId: string | undefined) => void
694
+ declare type MSRPInitializingListener = (value: boolean) => void
695
+
696
+ export declare type MSRPMemberRole = 'in_charge' | 'manager' | 'assigned'
633
697
 
634
- declare type MSRPMemberRole = 'in_charge' | 'manager' | 'assigned';
698
+ declare type MSRPMemberRole_2 = 'in_charge' | 'manager' | 'assigned'
635
699
 
636
- declare type MSRPMembership = 'join' | 'leave' | 'invite' | 'ban';
700
+ export declare type MSRPMembership = 'join' | 'leave' | 'invite' | 'ban'
701
+
702
+ declare type MSRPMembership_2 = 'join' | 'leave' | 'invite' | 'ban'
637
703
 
638
704
  declare class MSRPMessage {
639
705
  protocol: string
@@ -651,18 +717,35 @@ declare class MSRPMessage {
651
717
  }
652
718
 
653
719
  declare type msrpMessageAddedListener = (payload: {
654
- conversationKey: string
720
+ conversation_id?: number
655
721
  message: any
656
722
  }) => void
657
723
 
658
- declare type MSRPMessageEventType = {
724
+ declare type msrpMessageDeletedListener = (payload: {
725
+ conversation_id?: number
726
+ eventId: string
727
+ deletedBy: string
728
+ updatedAt: number
729
+ }) => void
730
+
731
+ declare type msrpMessageEditedListener = (payload: {
732
+ conversation_id?: number
733
+ eventId: string
734
+ newContent: any
735
+ editEvent: any
736
+ updatedAt: number
737
+ }) => void
738
+
739
+ export declare type MSRPMessageEventType = {
659
740
  message: MSRPMessage,
660
- session: MSRPSessionExtended
741
+ session: MSRPSessionExtended_2
661
742
  }
662
743
 
663
744
  declare type MSRPMessageListener = (event: MSRPMessageEventType) => void;
664
745
 
665
- declare type MSRPMessageStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'failed';
746
+ export declare type MSRPMessageStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'failed'
747
+
748
+ declare type MSRPMessageStatus_2 = 'pending' | 'sent' | 'delivered' | 'read' | 'failed'
666
749
 
667
750
  declare class MSRPModule {
668
751
  private context;
@@ -675,7 +758,7 @@ declare class MSRPModule {
675
758
  private uploadRequestTimeoutMs;
676
759
  private fileAccessTimeoutMs;
677
760
  private typingKeepAliveInterval;
678
- private typingKeepAliveConversationKey;
761
+ private typingKeepAliveConversationId;
679
762
  private typingKeepAliveIntervalMs;
680
763
  constructor(context: any);
681
764
  get isMSRPInitializing(): boolean;
@@ -695,107 +778,112 @@ declare class MSRPModule {
695
778
  private newMSRPSessionCallback;
696
779
  private setIsMSRPInitializing;
697
780
  private getUserUri;
698
- /**
699
- * Open an MSRP session for the currently logged-in user. The SIP
700
- * identity is resolved automatically from the OpenSIPSJS
701
- * configuration, so the caller never has to pass it. Use this when
702
- * the session is intended to act as a long-lived transport pipe and
703
- * the first payload will be sent later through one of the higher-level
704
- * actions (e.g. `sendCreateConversationMessage`).
705
- */
706
781
  initMSRP(options?: any): void;
707
- /**
708
- * Open an MSRP session and push `body` as the first MSRP frame the
709
- * moment the session goes active. Use this for the legacy
710
- * "compose-and-send" flow where the first message is known at the
711
- * time the session is opened.
712
- */
713
782
  initMSRPAndSendMessage(target: string, body: string, options?: any): void;
714
- /**
715
- * Public raw send - kept for backward-compat with the old multi-session API.
716
- * Ignores the passed callId/sessionId because we only ever hold one session.
717
- */
718
783
  sendMSRP(_msrpSessionId: string, body: string): void;
719
784
  /**
720
785
  * Safe wrapper around session.sendMSRP. Returns true when the message was
721
786
  * handed off to the session; false when there is no active session or the
722
- * underlying send threw. On failure the stored session is cleared so the
723
- * next send attempt does not silently drop traffic on a half-dead session.
787
+ * underlying send threw.
724
788
  */
725
789
  safeSendMSRP(body: string): boolean;
726
790
  private buildCreateConversationEvent;
727
791
  private buildTextMessageEvent;
792
+ private buildEditMessageEvent;
793
+ private buildDeleteMessageEvent;
728
794
  private buildMediaMessageEvent;
729
795
  private buildMemberEvent;
730
796
  private buildCloseConversationEvent;
731
797
  private buildReactionEvent;
732
798
  private buildTypingEvent;
733
799
  private buildReadReceiptEvent;
800
+ private buildUnreadEvent;
801
+ sendCreateConversationMessage(targetSip: string | string[]): boolean;
802
+ sendTextMessage(conversationRef: MSRPConversationRef, text: string, options?: MSRPSendMessageOptions): boolean;
734
803
  /**
735
- * Create a new conversation by inviting one or more SIP URIs.
736
- * Accepts plain numbers/usernames and rewrites them into full SIP URIs
737
- * against the domain OpenSIPSJS was initialized with.
804
+ * Send an internal note — a message only visible to operators. The backend
805
+ * fan-out layer skips WhatsApp/SMS members when
806
+ * `content.message_type === 'internal_note'`, so it is never delivered to
807
+ * the customer channel.
738
808
  */
739
- sendCreateConversationMessage(targetSip: string | string[]): boolean;
740
- sendTextMessage(conversationKey: string, text: string): boolean;
741
- sendMediaMessage(conversationKey: string, uploadResult: MSRPUploadResult, caption?: string): boolean;
742
- sendReaction(conversationKey: string, targetEventId: string, emoji: string): boolean;
743
- sendTypingIndicator(conversationKey: string, isTyping: boolean): boolean;
809
+ sendInternalNote(conversationRef: MSRPConversationRef, text: string, options?: Omit<MSRPSendMessageOptions, 'messageType'>): boolean;
744
810
  /**
745
- * Start an automatic typing keep-alive loop for `conversationKey`. While
746
- * active, a typing=true event is re-sent every `typingKeepAliveIntervalMs`
747
- * so the remote side does not time out the indicator. Calling this with a
748
- * different conversationKey or calling `stopTypingKeepAlive()` cancels
749
- * any in-flight loop.
811
+ * Edit a previously sent message. Only the original author may edit, and
812
+ * only within the per-channel edit window enforced by the backend.
750
813
  */
751
- startTypingKeepAlive(conversationKey: string): void;
752
- stopTypingKeepAlive(sendStop?: boolean): void;
814
+ editMessage(conversationRef: MSRPConversationRef, targetEventId: string, newText: string): boolean;
753
815
  /**
754
- * Send a read receipt for `lastEventId` in `conversationKey`. The
755
- * caller is responsible for resolving which event_id represents the
756
- * "last seen" message because the module no longer stores chat history.
816
+ * Soft-delete a message ("delete for everyone"). Only the original author
817
+ * may delete; the backend marks it `is_deleted` and fans out the deletion.
757
818
  */
758
- sendReadReceipt(conversationKey: string, lastEventId: string): boolean;
819
+ deleteMessage(conversationRef: MSRPConversationRef, targetEventId: string): boolean;
820
+ /**
821
+ * Forward the text of an existing message into another conversation.
822
+ * The caller owns `forwardedFromLabel`; when omitted the raw sender URI
823
+ * of the source message is used. The SDK never invents a display name.
824
+ */
825
+ forwardMessage(sourceMessage: any, targetConversationRef: MSRPConversationRef, forwardedFromLabel?: string): boolean;
826
+ sendMediaMessage(conversationRef: MSRPConversationRef, uploadResult: MSRPUploadResult, caption?: string): boolean;
827
+ sendReaction(conversationRef: MSRPConversationRef, targetEventId: string, emoji: string, action?: MSRPReactionAction): boolean;
828
+ /** Convenience wrapper to remove a previously added reaction. */
829
+ removeReaction(conversationRef: MSRPConversationRef, targetEventId: string, emoji: string): boolean;
830
+ /**
831
+ * Emit a single `m.typing` heartbeat. Prefer {@link startTypingKeepAlive}
832
+ * — the heartbeat protocol requires a stream of `true` events.
833
+ */
834
+ sendTypingIndicator(conversationRef: MSRPConversationRef): boolean;
835
+ startTypingKeepAlive(conversationRef: MSRPConversationRef): void;
836
+ /**
837
+ * Stop our own heartbeat stream. Does NOT send a `typing=false` event —
838
+ * peers clear our indicator via their own silence-timeout, which also
839
+ * covers crash / network-drop / session-end cases.
840
+ */
841
+ stopTypingKeepAlive(): void;
842
+ sendReadReceipt(conversationRef: MSRPConversationRef, lastEventId: string): boolean;
843
+ /**
844
+ * Set the caller's per-user read pointer.
845
+ * - `lastReadEventId` = the last event to remain read (everything after
846
+ * becomes unread).
847
+ * - `null` (or omitted) = mark the whole conversation as unread.
848
+ */
849
+ markAsUnread(conversationRef: MSRPConversationRef, lastReadEventId?: string | null): boolean;
759
850
  /**
760
851
  * Close a conversation. Only callers with role 'in_charge' or 'manager'
761
852
  * are allowed by the backend.
762
853
  */
763
- closeConversation(conversationKey: string, reason?: string, cause?: string): boolean;
854
+ closeConversation(conversationRef: MSRPConversationRef, reason?: string, cause?: string): boolean;
764
855
  /**
765
- * Change another member's role inside a conversation. The current user
766
- * must be 'in_charge' or 'manager'.
856
+ * Change another member's role. Only callers with role 'in_charge' or
857
+ * 'manager' are allowed by the backend.
767
858
  */
768
- changeMemberRole(conversationKey: string, targetUri: string, newRole: MSRPMemberRole): boolean;
769
- acceptInvite(conversationKey: string): boolean;
770
- rejectInvite(conversationKey: string): boolean;
771
- leaveConversation(conversationKey: string): boolean;
859
+ changeMemberRole(conversationRef: MSRPConversationRef, targetUri: string, newRole: MSRPMemberRole): boolean;
860
+ acceptInvite(conversationRef: MSRPConversationRef): boolean;
861
+ rejectInvite(conversationRef: MSRPConversationRef): boolean;
862
+ leaveConversation(conversationRef: MSRPConversationRef): boolean;
772
863
  /**
773
- * Ask the server for a presigned upload URL via MSRP. Resolves with the
774
- * upload metadata once the matching `m.upload.response` arrives, or
775
- * rejects after `uploadRequestTimeoutMs` if no response is received.
864
+ * Ask the server for a presigned upload URL. Resolves with the upload
865
+ * metadata once the matching `m.upload.response` arrives, or rejects
866
+ * after `uploadRequestTimeoutMs`.
776
867
  */
777
- requestUploadUrl(conversationKey: string, filename: string, mimeType: string, fileSize: number): Promise<MSRPUploadResult>;
868
+ requestUploadUrl(conversationRef: MSRPConversationRef, filename: string, mimeType: string, fileSize: number): Promise<MSRPUploadResult>;
778
869
  /**
779
- * Ask the server for a one-shot download URL for a previously-uploaded
780
- * file. Resolves with the download URL, rejects on timeout or explicit
781
- * server error.
870
+ * Ask the server for a one-shot download URL. Resolves with the URL,
871
+ * rejects on timeout or explicit server error.
782
872
  */
783
- requestFileAccess(conversationKey: string, eventId: string): Promise<string>;
873
+ requestFileAccess(conversationRef: MSRPConversationRef, eventId: string): Promise<string>;
784
874
  /**
785
875
  * High-level helper: request a presigned URL, POST the file to it, then
786
876
  * send the resulting media message into the conversation in one go.
787
877
  */
788
- uploadFile(conversationKey: string, file: File, caption?: string): Promise<MSRPUploadResult>;
789
- /**
790
- * Parse a raw MSRP `newMessage` payload and dispatch it to the right
791
- * conversation-state mutator. Outgoing messages and non-JSON payloads
792
- * are ignored so the rest of the pipeline stays pure.
793
- */
878
+ uploadFile(conversationRef: MSRPConversationRef, file: File, caption?: string): Promise<MSRPUploadResult>;
794
879
  private processIncomingMSRPMessage;
795
880
  private handleIncomingEvent;
796
881
  private handleIncomingSync;
797
882
  private handleIncomingConversationCreate;
798
883
  private handleIncomingConversationMessage;
884
+ private handleIncomingMessageDelete;
885
+ private handleIncomingConversationReopen;
886
+ private handleIncomingPresence;
799
887
  private handleIncomingConversationClosed;
800
888
  private handleIncomingReceipt;
801
889
  private handleIncomingTyping;
@@ -804,34 +892,14 @@ declare class MSRPModule {
804
892
  private handleIncomingUploadResponse;
805
893
  private handleIncomingFileAccessResponse;
806
894
  private upsertConversationState;
807
- /**
808
- * Make a shallow snapshot of a conversation that is safe to hand off
809
- * to an external consumer (e.g. a Vue composable).
810
- *
811
- * The mutable top-level collections (members, memberRoles,
812
- * state_events) are cloned so subsequent internal mutations by the
813
- * module cannot leak into the consumer's state. There is no
814
- * `messages` field - chat history is owned by the consumer.
815
- */
895
+ private toConversationId;
896
+ private sendEvent;
816
897
  private snapshotConversation;
817
- /**
818
- * Snapshot the whole conversations map - used only for the bulk
819
- * `msrpSyncCompleted` emit.
820
- */
821
898
  private snapshotConversationsMap;
822
899
  isConversationClosed(conversation: MSRPConversationState | undefined | null): boolean;
823
- /**
824
- * Extract the conversationKey from either a string or an event/conversation object.
825
- */
826
- private conversationKeyOf;
827
- /**
828
- * Extract the user-part of a SIP URI, e.g. sip:103@example.com -> 103.
829
- */
900
+ private conversationIdOf;
830
901
  extractSipUser(sipUri: string | null | undefined): string | null;
831
- /**
832
- * Best-effort human-readable name for any URI we may encounter
833
- * (SIP / WhatsApp / SMS / GreenAPI).
834
- */
902
+ private readLastReadEventIdFromMemberContent;
835
903
  extractDisplayName(uri: string | null | undefined): string;
836
904
  }
837
905
 
@@ -851,8 +919,18 @@ declare interface MSRPOptions_2 extends AnswerOptions {
851
919
  fromDisplayName?: string;
852
920
  }
853
921
 
922
+ declare type msrpPresenceListener = (payload: {
923
+ conversation_id?: number
924
+ sender: string
925
+ presence: string | null
926
+ lastActiveAt: number | null
927
+ updatedAt: number
928
+ }) => void
929
+
930
+ declare type MSRPReactionAction = 'add' | 'remove';
931
+
854
932
  declare type msrpReactionChangedListener = (payload: {
855
- conversationKey: string
933
+ conversation_id?: number
856
934
  eventId: string
857
935
  emoji: string
858
936
  action: 'add' | 'remove'
@@ -861,12 +939,22 @@ declare type msrpReactionChangedListener = (payload: {
861
939
  }) => void
862
940
 
863
941
  declare type msrpReceiptChangedListener = (payload: {
864
- conversationKey: string
942
+ conversation_id?: number
865
943
  eventId: string
866
- status: MSRPMessageStatus
944
+ status: MSRPMessageStatus_2
867
945
  updatedAt: number
868
946
  }) => void
869
947
 
948
+ /** Optional modifiers for an outgoing text/note message. */
949
+ declare interface MSRPSendMessageOptions {
950
+ /** event_id of the message being replied to — becomes `content.in_reply_to`. */
951
+ replyToEventId?: string;
952
+ /** Overrides `content.message_type` (defaults to 'text'). */
953
+ messageType?: string;
954
+ /** Attribution label for a forwarded message — becomes `content.forwarded_from`. */
955
+ forwardedFrom?: string;
956
+ }
957
+
870
958
  declare class MSRPSession extends EventEmitter {
871
959
  _ua: UAExtendedInterface
872
960
  id: any
@@ -1011,7 +1099,30 @@ declare interface MSRPSessionEventMap_2 {
1011
1099
  'peerconnection:setremotedescriptionfailed': Listener_3;
1012
1100
  }
1013
1101
 
1014
- declare interface MSRPSessionExtended extends MSRPSession_2 {
1102
+ export declare interface MSRPSessionExtended extends MSRPSession_2 {
1103
+ id: string
1104
+ status: string
1105
+ start_time: Date
1106
+ direction: SessionDirection
1107
+ _id: string
1108
+ _cancel_reason: string
1109
+ _contact: string
1110
+ _end_time: Date
1111
+ _eventsCount: number
1112
+ _from_tag: string
1113
+ _is_canceled: boolean
1114
+ _is_confirmed: boolean
1115
+ _late_sdp: string
1116
+ _status: number
1117
+ _remote_identity: string
1118
+ target_addr: Array<string>
1119
+ answer(options?: any): void
1120
+ _init_incomeing(): void
1121
+ sendMSRP(body: string): void
1122
+ on<T extends keyof MSRPSessionEventMap_2>(type: T, listener: MSRPSessionEventMap_2[T]): this;
1123
+ }
1124
+
1125
+ declare interface MSRPSessionExtended_2 extends MSRPSession_2 {
1015
1126
  id: string
1016
1127
  status: string
1017
1128
  start_time: Date
@@ -1037,31 +1148,31 @@ declare interface MSRPSessionExtended extends MSRPSession_2 {
1037
1148
  declare type MSRPSessionListener = IncomingMSRPSessionListener | OutgoingMSRPSessionListener;
1038
1149
 
1039
1150
  declare type msrpSyncCompletedListener = (payload: {
1040
- conversations: { [key: string]: MSRPConversationState }
1151
+ conversations: { [key: string]: MSRPConversationState_2 }
1041
1152
  messagesByConversation: { [key: string]: any[] }
1042
1153
  }) => void
1043
1154
 
1044
1155
  declare type msrpTypingListener = (payload: {
1045
- conversationKey: string
1156
+ conversation_id?: number
1046
1157
  sender: string
1047
1158
  isTyping: boolean
1048
1159
  }) => void
1049
1160
 
1050
- declare interface MSRPUploadResult {
1051
- upload_url: string;
1052
- expires_in?: number;
1053
- mime_type: string;
1054
- request_id: string;
1055
- filename?: string;
1056
- preview_url?: string;
1057
- icon_url?: string;
1058
- transcription?: string;
1059
- media_type?: string;
1161
+ export declare interface MSRPUploadResult {
1162
+ upload_url: string
1163
+ expires_in?: number
1164
+ mime_type: string
1165
+ request_id: string
1166
+ filename?: string
1167
+ preview_url?: string
1168
+ icon_url?: string
1169
+ transcription?: string
1170
+ media_type?: string
1060
1171
  }
1061
1172
 
1062
- declare type NoiseReductionMode = 'disabled' | 'enabled' | 'dynamic'
1173
+ export declare type NoiseReductionMode = 'disabled' | 'enabled' | 'dynamic'
1063
1174
 
1064
- declare interface NoiseReductionOptions {
1175
+ export declare interface NoiseReductionOptions {
1065
1176
  mode: NoiseReductionMode,
1066
1177
  vadModule?: VADModule
1067
1178
  vadConfig?: Partial<VADOptions>
@@ -1082,11 +1193,11 @@ declare interface NoiseReductionOptions {
1082
1193
  onnxWASMBasePath?: string
1083
1194
  }
1084
1195
 
1085
- declare type NoiseReductionOptionsWithoutVadModule = Omit<NoiseReductionOptions, 'vadModule'>
1196
+ export declare type NoiseReductionOptionsWithoutVadModule = Omit<NoiseReductionOptions, 'vadModule'>
1086
1197
 
1087
1198
  declare type OnTransportCallback = (parsed: object, message: string) => void
1088
1199
 
1089
- declare interface OpenSIPSEventMap extends UAEventMap {
1200
+ export declare interface OpenSIPSEventMap extends UAEventMap {
1090
1201
  ready: readyListener
1091
1202
  connection: connectionListener
1092
1203
  reconnecting: reconnectionListener
@@ -1118,7 +1229,7 @@ declare interface OpenSIPSEventMap extends UAEventMap {
1118
1229
  connectionStateChange: connectionStateChangeListener
1119
1230
  newMSRPMessage: MSRPMessageListener
1120
1231
  newMSRPSession: MSRPSessionListener
1121
- // MSRP - granular conversation events
1232
+ // MSRP events listeners
1122
1233
  changeMsrpSession: changeMsrpSessionListener
1123
1234
  msrpSyncCompleted: msrpSyncCompletedListener
1124
1235
  msrpConversationCreated: msrpConversationCreatedListener
@@ -1128,6 +1239,9 @@ declare interface OpenSIPSEventMap extends UAEventMap {
1128
1239
  msrpReceiptChanged: msrpReceiptChangedListener
1129
1240
  msrpReactionChanged: msrpReactionChangedListener
1130
1241
  msrpTyping: msrpTypingListener
1242
+ msrpMessageEdited: msrpMessageEditedListener
1243
+ msrpMessageDeleted: msrpMessageDeletedListener
1244
+ msrpPresence: msrpPresenceListener
1131
1245
  // JANUS
1132
1246
  conferenceStart: conferenceStartListener
1133
1247
  conferenceEnd: conferenceEndListener
@@ -1273,11 +1387,22 @@ declare interface StreamMediaType extends HTMLAudioElement {
1273
1387
  setSinkId (id: string): Promise<void>
1274
1388
  }
1275
1389
 
1390
+ declare interface StreamMediaType_2 extends HTMLAudioElement {
1391
+ className: string
1392
+ setSinkId (id: string): Promise<void>
1393
+ }
1394
+
1276
1395
  declare type TestEventListener = (event: { test: string }) => void
1277
1396
 
1278
1397
  declare interface TriggerListenerOptions {
1279
1398
  listenerType: string
1280
1399
  session: RTCSessionExtended
1400
+ event?: ListenerEventType_2
1401
+ }
1402
+
1403
+ export declare interface TriggerMSRPListenerOptions {
1404
+ listenerType: string
1405
+ session: MSRPSessionExtended
1281
1406
  event?: ListenerEventType
1282
1407
  }
1283
1408
 
@@ -1411,7 +1536,7 @@ declare class VideoModule {
1411
1536
 
1412
1537
  declare type VideoModuleName = typeof MODULES.VIDEO
1413
1538
 
1414
- declare interface WebrtcMetricsConfigType {
1539
+ export declare interface WebrtcMetricsConfigType {
1415
1540
  refreshEvery?: number
1416
1541
  startAfter?: number
1417
1542
  stopAfter?: number