opensips-js 0.1.47 → 0.1.48

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,72 @@ 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 SYNC: "m.sync";
608
+ readonly UPLOAD_REQUEST: "m.upload.request";
609
+ readonly UPLOAD_RESPONSE: "m.upload.response";
610
+ readonly FILE_ACCESS_REQUEST: "m.file.access.request";
611
+ readonly FILE_ACCESS_RESPONSE: "m.file.access.response";
612
+ readonly REACTION: "m.reaction";
613
+ readonly TYPING: "m.typing";
614
+ readonly SENT: "m.sent";
615
+ readonly DELIVERED: "m.delivered";
616
+ readonly READ: "m.read";
617
+ readonly FAILED: "m.failed";
618
+ readonly SENDING: "m.sending";
619
+ };
620
+
592
621
  declare type msrpConversationCreatedListener = (payload: {
593
622
  conversationKey: string
594
- conversation: MSRPConversationState
623
+ conversation: MSRPConversationState_2
595
624
  }) => void
596
625
 
597
626
  declare type msrpConversationRemovedListener = (payload: { conversationKey: string }) => void
598
627
 
599
- /**
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.
609
- */
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;
628
+ export declare interface MSRPConversationState {
629
+ conversationKey: string
630
+ creator: string | null
631
+ members: Set<string>
632
+ memberRoles: Map<string, MSRPMemberRole>
633
+ currentUserRole: MSRPMemberRole
634
+ currentUserStatus: MSRPMembership | null
635
+ state_events: { [key: string]: { [stateKey: string]: any } }
636
+ created_at: number
637
+ updated_at: number
638
+ status?: string
639
+ }
640
+
641
+ declare interface MSRPConversationState_2 {
642
+ conversationKey: string
643
+ creator: string | null
644
+ members: Set<string>
645
+ memberRoles: Map<string, MSRPMemberRole_2>
646
+ currentUserRole: MSRPMemberRole_2
647
+ currentUserStatus: MSRPMembership_2 | null
648
+ state_events: { [key: string]: { [stateKey: string]: any } }
649
+ created_at: number
650
+ updated_at: number
651
+ status?: string
625
652
  }
626
653
 
627
654
  declare type msrpConversationUpdatedListener = (payload: {
628
655
  conversationKey: string
629
- patch: Partial<MSRPConversationState>
656
+ patch: Partial<MSRPConversationState_2>
630
657
  }) => void
631
658
 
632
659
  declare type MSRPInitializingListener = (sessionId: string | undefined) => void
633
660
 
634
- declare type MSRPMemberRole = 'in_charge' | 'manager' | 'assigned';
661
+ export declare type MSRPMemberRole = 'in_charge' | 'manager' | 'assigned'
635
662
 
636
- declare type MSRPMembership = 'join' | 'leave' | 'invite' | 'ban';
663
+ declare type MSRPMemberRole_2 = 'in_charge' | 'manager' | 'assigned'
664
+
665
+ export declare type MSRPMembership = 'join' | 'leave' | 'invite' | 'ban'
666
+
667
+ declare type MSRPMembership_2 = 'join' | 'leave' | 'invite' | 'ban'
637
668
 
638
669
  declare class MSRPMessage {
639
670
  protocol: string
@@ -655,14 +686,16 @@ declare type msrpMessageAddedListener = (payload: {
655
686
  message: any
656
687
  }) => void
657
688
 
658
- declare type MSRPMessageEventType = {
689
+ export declare type MSRPMessageEventType = {
659
690
  message: MSRPMessage,
660
- session: MSRPSessionExtended
691
+ session: MSRPSessionExtended_2
661
692
  }
662
693
 
663
694
  declare type MSRPMessageListener = (event: MSRPMessageEventType) => void;
664
695
 
665
- declare type MSRPMessageStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'failed';
696
+ export declare type MSRPMessageStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'failed'
697
+
698
+ declare type MSRPMessageStatus_2 = 'pending' | 'sent' | 'delivered' | 'read' | 'failed'
666
699
 
667
700
  declare class MSRPModule {
668
701
  private context;
@@ -695,32 +728,13 @@ declare class MSRPModule {
695
728
  private newMSRPSessionCallback;
696
729
  private setIsMSRPInitializing;
697
730
  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
731
  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
732
  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
733
  sendMSRP(_msrpSessionId: string, body: string): void;
719
734
  /**
720
735
  * Safe wrapper around session.sendMSRP. Returns true when the message was
721
736
  * 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.
737
+ * underlying send threw.
724
738
  */
725
739
  safeSendMSRP(body: string): boolean;
726
740
  private buildCreateConversationEvent;
@@ -731,30 +745,13 @@ declare class MSRPModule {
731
745
  private buildReactionEvent;
732
746
  private buildTypingEvent;
733
747
  private buildReadReceiptEvent;
734
- /**
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.
738
- */
739
748
  sendCreateConversationMessage(targetSip: string | string[]): boolean;
740
749
  sendTextMessage(conversationKey: string, text: string): boolean;
741
750
  sendMediaMessage(conversationKey: string, uploadResult: MSRPUploadResult, caption?: string): boolean;
742
751
  sendReaction(conversationKey: string, targetEventId: string, emoji: string): boolean;
743
752
  sendTypingIndicator(conversationKey: string, isTyping: boolean): boolean;
744
- /**
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.
750
- */
751
753
  startTypingKeepAlive(conversationKey: string): void;
752
754
  stopTypingKeepAlive(sendStop?: boolean): void;
753
- /**
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.
757
- */
758
755
  sendReadReceipt(conversationKey: string, lastEventId: string): boolean;
759
756
  /**
760
757
  * Close a conversation. Only callers with role 'in_charge' or 'manager'
@@ -786,11 +783,6 @@ declare class MSRPModule {
786
783
  * send the resulting media message into the conversation in one go.
787
784
  */
788
785
  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
- */
794
786
  private processIncomingMSRPMessage;
795
787
  private handleIncomingEvent;
796
788
  private handleIncomingSync;
@@ -804,34 +796,11 @@ declare class MSRPModule {
804
796
  private handleIncomingUploadResponse;
805
797
  private handleIncomingFileAccessResponse;
806
798
  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
- */
816
799
  private snapshotConversation;
817
- /**
818
- * Snapshot the whole conversations map - used only for the bulk
819
- * `msrpSyncCompleted` emit.
820
- */
821
800
  private snapshotConversationsMap;
822
801
  isConversationClosed(conversation: MSRPConversationState | undefined | null): boolean;
823
- /**
824
- * Extract the conversationKey from either a string or an event/conversation object.
825
- */
826
802
  private conversationKeyOf;
827
- /**
828
- * Extract the user-part of a SIP URI, e.g. sip:103@example.com -> 103.
829
- */
830
803
  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
- */
835
804
  extractDisplayName(uri: string | null | undefined): string;
836
805
  }
837
806
 
@@ -863,7 +832,7 @@ declare type msrpReactionChangedListener = (payload: {
863
832
  declare type msrpReceiptChangedListener = (payload: {
864
833
  conversationKey: string
865
834
  eventId: string
866
- status: MSRPMessageStatus
835
+ status: MSRPMessageStatus_2
867
836
  updatedAt: number
868
837
  }) => void
869
838
 
@@ -1011,7 +980,30 @@ declare interface MSRPSessionEventMap_2 {
1011
980
  'peerconnection:setremotedescriptionfailed': Listener_3;
1012
981
  }
1013
982
 
1014
- declare interface MSRPSessionExtended extends MSRPSession_2 {
983
+ export declare interface MSRPSessionExtended extends MSRPSession_2 {
984
+ id: string
985
+ status: string
986
+ start_time: Date
987
+ direction: SessionDirection
988
+ _id: string
989
+ _cancel_reason: string
990
+ _contact: string
991
+ _end_time: Date
992
+ _eventsCount: number
993
+ _from_tag: string
994
+ _is_canceled: boolean
995
+ _is_confirmed: boolean
996
+ _late_sdp: string
997
+ _status: number
998
+ _remote_identity: string
999
+ target_addr: Array<string>
1000
+ answer(options?: any): void
1001
+ _init_incomeing(): void
1002
+ sendMSRP(body: string): void
1003
+ on<T extends keyof MSRPSessionEventMap_2>(type: T, listener: MSRPSessionEventMap_2[T]): this;
1004
+ }
1005
+
1006
+ declare interface MSRPSessionExtended_2 extends MSRPSession_2 {
1015
1007
  id: string
1016
1008
  status: string
1017
1009
  start_time: Date
@@ -1037,7 +1029,7 @@ declare interface MSRPSessionExtended extends MSRPSession_2 {
1037
1029
  declare type MSRPSessionListener = IncomingMSRPSessionListener | OutgoingMSRPSessionListener;
1038
1030
 
1039
1031
  declare type msrpSyncCompletedListener = (payload: {
1040
- conversations: { [key: string]: MSRPConversationState }
1032
+ conversations: { [key: string]: MSRPConversationState_2 }
1041
1033
  messagesByConversation: { [key: string]: any[] }
1042
1034
  }) => void
1043
1035
 
@@ -1047,21 +1039,21 @@ declare type msrpTypingListener = (payload: {
1047
1039
  isTyping: boolean
1048
1040
  }) => void
1049
1041
 
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;
1042
+ export declare interface MSRPUploadResult {
1043
+ upload_url: string
1044
+ expires_in?: number
1045
+ mime_type: string
1046
+ request_id: string
1047
+ filename?: string
1048
+ preview_url?: string
1049
+ icon_url?: string
1050
+ transcription?: string
1051
+ media_type?: string
1060
1052
  }
1061
1053
 
1062
- declare type NoiseReductionMode = 'disabled' | 'enabled' | 'dynamic'
1054
+ export declare type NoiseReductionMode = 'disabled' | 'enabled' | 'dynamic'
1063
1055
 
1064
- declare interface NoiseReductionOptions {
1056
+ export declare interface NoiseReductionOptions {
1065
1057
  mode: NoiseReductionMode,
1066
1058
  vadModule?: VADModule
1067
1059
  vadConfig?: Partial<VADOptions>
@@ -1082,11 +1074,11 @@ declare interface NoiseReductionOptions {
1082
1074
  onnxWASMBasePath?: string
1083
1075
  }
1084
1076
 
1085
- declare type NoiseReductionOptionsWithoutVadModule = Omit<NoiseReductionOptions, 'vadModule'>
1077
+ export declare type NoiseReductionOptionsWithoutVadModule = Omit<NoiseReductionOptions, 'vadModule'>
1086
1078
 
1087
1079
  declare type OnTransportCallback = (parsed: object, message: string) => void
1088
1080
 
1089
- declare interface OpenSIPSEventMap extends UAEventMap {
1081
+ export declare interface OpenSIPSEventMap extends UAEventMap {
1090
1082
  ready: readyListener
1091
1083
  connection: connectionListener
1092
1084
  reconnecting: reconnectionListener
@@ -1118,7 +1110,7 @@ declare interface OpenSIPSEventMap extends UAEventMap {
1118
1110
  connectionStateChange: connectionStateChangeListener
1119
1111
  newMSRPMessage: MSRPMessageListener
1120
1112
  newMSRPSession: MSRPSessionListener
1121
- // MSRP - granular conversation events
1113
+ // MSRP events listeners
1122
1114
  changeMsrpSession: changeMsrpSessionListener
1123
1115
  msrpSyncCompleted: msrpSyncCompletedListener
1124
1116
  msrpConversationCreated: msrpConversationCreatedListener
@@ -1273,11 +1265,22 @@ declare interface StreamMediaType extends HTMLAudioElement {
1273
1265
  setSinkId (id: string): Promise<void>
1274
1266
  }
1275
1267
 
1268
+ declare interface StreamMediaType_2 extends HTMLAudioElement {
1269
+ className: string
1270
+ setSinkId (id: string): Promise<void>
1271
+ }
1272
+
1276
1273
  declare type TestEventListener = (event: { test: string }) => void
1277
1274
 
1278
1275
  declare interface TriggerListenerOptions {
1279
1276
  listenerType: string
1280
1277
  session: RTCSessionExtended
1278
+ event?: ListenerEventType_2
1279
+ }
1280
+
1281
+ export declare interface TriggerMSRPListenerOptions {
1282
+ listenerType: string
1283
+ session: MSRPSessionExtended
1281
1284
  event?: ListenerEventType
1282
1285
  }
1283
1286
 
@@ -1411,7 +1414,7 @@ declare class VideoModule {
1411
1414
 
1412
1415
  declare type VideoModuleName = typeof MODULES.VIDEO
1413
1416
 
1414
- declare interface WebrtcMetricsConfigType {
1417
+ export declare interface WebrtcMetricsConfigType {
1415
1418
  refreshEvery?: number
1416
1419
  startAfter?: number
1417
1420
  stopAfter?: number