opensips-js 0.1.46 → 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,13 +394,15 @@ declare type changeIsDNDListener = (value: boolean) => void
394
394
 
395
395
  declare type changeIsMutedListener = (value: boolean) => void
396
396
 
397
+ declare type changeMsrpSessionListener = (session: IMessage_2 | null) => void
398
+
397
399
  declare type changeMuteWhenJoinListener = (value: boolean) => void
398
400
 
399
401
  declare type changeNoiseReductionStateListener = (event: boolean) => void
400
402
 
401
403
  declare type changeVideoStateListener = (state: boolean) => void
402
404
 
403
- declare type ChangeVolumeEventType = {
405
+ export declare type ChangeVolumeEventType = {
404
406
  callId: string
405
407
  volume: number
406
408
  }
@@ -415,7 +417,7 @@ declare type connectionListener = (value: boolean) => void
415
417
 
416
418
  declare type connectionStateChangeListener = (event: ConnectionStateChangeType) => void
417
419
 
418
- declare type ConnectionStateChangeType = {
420
+ export declare type ConnectionStateChangeType = {
419
421
  session: RTCSessionExtended,
420
422
  connectionState: string
421
423
  }
@@ -428,7 +430,7 @@ declare interface ConnectOptions {
428
430
  pcConfig?: object;
429
431
  }
430
432
 
431
- declare interface CustomLoggerType {
433
+ export declare interface CustomLoggerType {
432
434
  log: CommonLogMethodType
433
435
  warn: CommonLogMethodType
434
436
  error: CommonLogMethodType
@@ -449,7 +451,7 @@ declare type ExactConstraints_2 = {
449
451
  video?: boolean;
450
452
  }
451
453
 
452
- declare interface ICall extends RTCSessionExtended {
454
+ export declare interface ICall extends RTCSessionExtended {
453
455
  roomId?: number
454
456
  localMuted?: boolean
455
457
  localHold?: boolean
@@ -458,14 +460,14 @@ declare interface ICall extends RTCSessionExtended {
458
460
  putOnHoldTimestamp?: number
459
461
  }
460
462
 
461
- declare interface ICallStatus {
463
+ export declare interface ICallStatus {
462
464
  isMoving: boolean
463
465
  isTransferring: boolean
464
466
  isMerging: boolean
465
467
  isTransferred: boolean
466
468
  }
467
469
 
468
- declare interface IMessage extends MSRPSessionExtended {
470
+ export declare interface IMessage extends MSRPSessionExtended {
469
471
  roomId?: number
470
472
  localMuted?: boolean
471
473
  localHold?: boolean
@@ -473,6 +475,14 @@ declare interface IMessage extends MSRPSessionExtended {
473
475
  terminate(): void
474
476
  }
475
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
+
476
486
  declare interface IncomingMSRPSessionEvent {
477
487
  originator: Originator.REMOTE;
478
488
  session: MSRPSession;
@@ -481,9 +491,9 @@ declare interface IncomingMSRPSessionEvent {
481
491
 
482
492
  declare type IncomingMSRPSessionListener = (event: IncomingMSRPSessionEvent) => void;
483
493
 
484
- declare type IOpenSIPSConfiguration = Omit<UAConfigurationExtended, 'sockets'>
494
+ export declare type IOpenSIPSConfiguration = Omit<UAConfigurationExtended, 'sockets'>
485
495
 
486
- declare interface IOpenSIPSJSOptions {
496
+ export declare interface IOpenSIPSJSOptions {
487
497
  configuration: IOpenSIPSConfiguration
488
498
  socketInterfaces: [ string ]
489
499
  sipDomain: string
@@ -498,7 +508,7 @@ declare interface IOpenSIPSJSOptions {
498
508
  msrpWs?: boolean
499
509
  }
500
510
 
501
- declare interface IRoom {
511
+ export declare interface IRoom {
502
512
  started: Date
503
513
  incomingInProgress: boolean
504
514
  roomId: number
@@ -508,7 +518,7 @@ declare type IRoomUpdate = Omit<IRoom, 'started'> & {
508
518
  started?: Date
509
519
  }
510
520
 
511
- declare interface ITimeData {
521
+ export declare interface ITimeData {
512
522
  callId: string
513
523
  hours: number
514
524
  minutes: number
@@ -560,9 +570,11 @@ declare type Listener_2 = (event: unknown) => void
560
570
 
561
571
  declare type Listener_3 = (event: unknown) => void
562
572
 
563
- declare type ListenerCallbackFnType<T extends ListenersKeyType> = OpenSIPSEventMap[T]
573
+ export declare type ListenerCallbackFnType<T extends ListenersKeyType> = OpenSIPSEventMap[T]
564
574
 
565
- declare type ListenerEventType = EndEvent | IncomingEvent | OutgoingEvent | IncomingAckEvent | OutgoingAckEvent
575
+ export declare type ListenerEventType = EndEvent | IncomingEvent | OutgoingEvent | IncomingAckEvent | OutgoingAckEvent
576
+
577
+ declare type ListenerEventType_2 = EndEvent | IncomingEvent | OutgoingEvent | IncomingAckEvent | OutgoingAckEvent
566
578
 
567
579
  declare type ListenersKeyType = keyof OpenSIPSEventMap
568
580
 
@@ -587,8 +599,73 @@ declare const MODULES: {
587
599
 
588
600
  declare type Modules = AudioModuleName | VideoModuleName | MSRPModuleName
589
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
+
621
+ declare type msrpConversationCreatedListener = (payload: {
622
+ conversationKey: string
623
+ conversation: MSRPConversationState_2
624
+ }) => void
625
+
626
+ declare type msrpConversationRemovedListener = (payload: { conversationKey: string }) => void
627
+
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
652
+ }
653
+
654
+ declare type msrpConversationUpdatedListener = (payload: {
655
+ conversationKey: string
656
+ patch: Partial<MSRPConversationState_2>
657
+ }) => void
658
+
590
659
  declare type MSRPInitializingListener = (sessionId: string | undefined) => void
591
660
 
661
+ export declare type MSRPMemberRole = 'in_charge' | 'manager' | 'assigned'
662
+
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'
668
+
592
669
  declare class MSRPMessage {
593
670
  protocol: string
594
671
  ident: string
@@ -604,37 +681,127 @@ declare class MSRPMessage {
604
681
  toString(): string
605
682
  }
606
683
 
607
- declare type MSRPMessageEventType = {
684
+ declare type msrpMessageAddedListener = (payload: {
685
+ conversationKey: string
686
+ message: any
687
+ }) => void
688
+
689
+ export declare type MSRPMessageEventType = {
608
690
  message: MSRPMessage,
609
- session: MSRPSessionExtended
691
+ session: MSRPSessionExtended_2
610
692
  }
611
693
 
612
694
  declare type MSRPMessageListener = (event: MSRPMessageEventType) => void;
613
695
 
696
+ export declare type MSRPMessageStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'failed'
697
+
698
+ declare type MSRPMessageStatus_2 = 'pending' | 'sent' | 'delivered' | 'read' | 'failed'
699
+
614
700
  declare class MSRPModule {
615
701
  private context;
616
- private activeMessages;
617
- private extendedMessages;
618
- private msrpHistory;
702
+ private msrpSession;
703
+ private extendedSession;
619
704
  private isMSRPInitializingValue;
705
+ private conversationsMap;
706
+ private pendingUploads;
707
+ private pendingFileAccessRequests;
708
+ private uploadRequestTimeoutMs;
709
+ private fileAccessTimeoutMs;
710
+ private typingKeepAliveInterval;
711
+ private typingKeepAliveConversationKey;
712
+ private typingKeepAliveIntervalMs;
620
713
  constructor(context: any);
621
714
  get isMSRPInitializing(): boolean;
622
- get getActiveMessages(): {
623
- [key: string]: IMessage;
715
+ get getMsrpSession(): IMessage;
716
+ get hasActiveSession(): boolean;
717
+ get conversations(): {
718
+ [key: string]: MSRPConversationState;
624
719
  };
625
- msrpAnswer(callId: string): void;
720
+ msrpAnswer(_callId: string): void;
626
721
  updateMSRPSession(value: IMessage): void;
627
- private addMMSRPSession;
722
+ private setMSRPSession;
628
723
  private addMSRPMessage;
629
- messageTerminate(callId: string): void;
724
+ messageTerminate(_callId: string): void;
630
725
  private addMessageSession;
631
726
  private triggerMSRPListener;
632
- private removeMMSRPSession;
633
- private activeMessageListRemove;
727
+ private clearMSRPSession;
634
728
  private newMSRPSessionCallback;
635
729
  private setIsMSRPInitializing;
636
- initMSRP(target: string, body: string, options: any): void;
637
- sendMSRP(msrpSessionId: string, body: string): void;
730
+ private getUserUri;
731
+ initMSRP(options?: any): void;
732
+ initMSRPAndSendMessage(target: string, body: string, options?: any): void;
733
+ sendMSRP(_msrpSessionId: string, body: string): void;
734
+ /**
735
+ * Safe wrapper around session.sendMSRP. Returns true when the message was
736
+ * handed off to the session; false when there is no active session or the
737
+ * underlying send threw.
738
+ */
739
+ safeSendMSRP(body: string): boolean;
740
+ private buildCreateConversationEvent;
741
+ private buildTextMessageEvent;
742
+ private buildMediaMessageEvent;
743
+ private buildMemberEvent;
744
+ private buildCloseConversationEvent;
745
+ private buildReactionEvent;
746
+ private buildTypingEvent;
747
+ private buildReadReceiptEvent;
748
+ sendCreateConversationMessage(targetSip: string | string[]): boolean;
749
+ sendTextMessage(conversationKey: string, text: string): boolean;
750
+ sendMediaMessage(conversationKey: string, uploadResult: MSRPUploadResult, caption?: string): boolean;
751
+ sendReaction(conversationKey: string, targetEventId: string, emoji: string): boolean;
752
+ sendTypingIndicator(conversationKey: string, isTyping: boolean): boolean;
753
+ startTypingKeepAlive(conversationKey: string): void;
754
+ stopTypingKeepAlive(sendStop?: boolean): void;
755
+ sendReadReceipt(conversationKey: string, lastEventId: string): boolean;
756
+ /**
757
+ * Close a conversation. Only callers with role 'in_charge' or 'manager'
758
+ * are allowed by the backend.
759
+ */
760
+ closeConversation(conversationKey: string, reason?: string, cause?: string): boolean;
761
+ /**
762
+ * Change another member's role inside a conversation. The current user
763
+ * must be 'in_charge' or 'manager'.
764
+ */
765
+ changeMemberRole(conversationKey: string, targetUri: string, newRole: MSRPMemberRole): boolean;
766
+ acceptInvite(conversationKey: string): boolean;
767
+ rejectInvite(conversationKey: string): boolean;
768
+ leaveConversation(conversationKey: string): boolean;
769
+ /**
770
+ * Ask the server for a presigned upload URL via MSRP. Resolves with the
771
+ * upload metadata once the matching `m.upload.response` arrives, or
772
+ * rejects after `uploadRequestTimeoutMs` if no response is received.
773
+ */
774
+ requestUploadUrl(conversationKey: string, filename: string, mimeType: string, fileSize: number): Promise<MSRPUploadResult>;
775
+ /**
776
+ * Ask the server for a one-shot download URL for a previously-uploaded
777
+ * file. Resolves with the download URL, rejects on timeout or explicit
778
+ * server error.
779
+ */
780
+ requestFileAccess(conversationKey: string, eventId: string): Promise<string>;
781
+ /**
782
+ * High-level helper: request a presigned URL, POST the file to it, then
783
+ * send the resulting media message into the conversation in one go.
784
+ */
785
+ uploadFile(conversationKey: string, file: File, caption?: string): Promise<MSRPUploadResult>;
786
+ private processIncomingMSRPMessage;
787
+ private handleIncomingEvent;
788
+ private handleIncomingSync;
789
+ private handleIncomingConversationCreate;
790
+ private handleIncomingConversationMessage;
791
+ private handleIncomingConversationClosed;
792
+ private handleIncomingReceipt;
793
+ private handleIncomingTyping;
794
+ private handleIncomingReaction;
795
+ private handleIncomingConversationMember;
796
+ private handleIncomingUploadResponse;
797
+ private handleIncomingFileAccessResponse;
798
+ private upsertConversationState;
799
+ private snapshotConversation;
800
+ private snapshotConversationsMap;
801
+ isConversationClosed(conversation: MSRPConversationState | undefined | null): boolean;
802
+ private conversationKeyOf;
803
+ extractSipUser(sipUri: string | null | undefined): string | null;
804
+ extractDisplayName(uri: string | null | undefined): string;
638
805
  }
639
806
 
640
807
  declare type MSRPModuleName = typeof MODULES.MSRP
@@ -653,6 +820,22 @@ declare interface MSRPOptions_2 extends AnswerOptions {
653
820
  fromDisplayName?: string;
654
821
  }
655
822
 
823
+ declare type msrpReactionChangedListener = (payload: {
824
+ conversationKey: string
825
+ eventId: string
826
+ emoji: string
827
+ action: 'add' | 'remove'
828
+ sender: string
829
+ updatedAt: number
830
+ }) => void
831
+
832
+ declare type msrpReceiptChangedListener = (payload: {
833
+ conversationKey: string
834
+ eventId: string
835
+ status: MSRPMessageStatus_2
836
+ updatedAt: number
837
+ }) => void
838
+
656
839
  declare class MSRPSession extends EventEmitter {
657
840
  _ua: UAExtendedInterface
658
841
  id: any
@@ -797,7 +980,30 @@ declare interface MSRPSessionEventMap_2 {
797
980
  'peerconnection:setremotedescriptionfailed': Listener_3;
798
981
  }
799
982
 
800
- 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 {
801
1007
  id: string
802
1008
  status: string
803
1009
  start_time: Date
@@ -822,9 +1028,32 @@ declare interface MSRPSessionExtended extends MSRPSession_2 {
822
1028
 
823
1029
  declare type MSRPSessionListener = IncomingMSRPSessionListener | OutgoingMSRPSessionListener;
824
1030
 
825
- declare type NoiseReductionMode = 'disabled' | 'enabled' | 'dynamic'
1031
+ declare type msrpSyncCompletedListener = (payload: {
1032
+ conversations: { [key: string]: MSRPConversationState_2 }
1033
+ messagesByConversation: { [key: string]: any[] }
1034
+ }) => void
1035
+
1036
+ declare type msrpTypingListener = (payload: {
1037
+ conversationKey: string
1038
+ sender: string
1039
+ isTyping: boolean
1040
+ }) => void
1041
+
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
1052
+ }
1053
+
1054
+ export declare type NoiseReductionMode = 'disabled' | 'enabled' | 'dynamic'
826
1055
 
827
- declare interface NoiseReductionOptions {
1056
+ export declare interface NoiseReductionOptions {
828
1057
  mode: NoiseReductionMode,
829
1058
  vadModule?: VADModule
830
1059
  vadConfig?: Partial<VADOptions>
@@ -845,11 +1074,11 @@ declare interface NoiseReductionOptions {
845
1074
  onnxWASMBasePath?: string
846
1075
  }
847
1076
 
848
- declare type NoiseReductionOptionsWithoutVadModule = Omit<NoiseReductionOptions, 'vadModule'>
1077
+ export declare type NoiseReductionOptionsWithoutVadModule = Omit<NoiseReductionOptions, 'vadModule'>
849
1078
 
850
1079
  declare type OnTransportCallback = (parsed: object, message: string) => void
851
1080
 
852
- declare interface OpenSIPSEventMap extends UAEventMap {
1081
+ export declare interface OpenSIPSEventMap extends UAEventMap {
853
1082
  ready: readyListener
854
1083
  connection: connectionListener
855
1084
  reconnecting: reconnectionListener
@@ -881,6 +1110,16 @@ declare interface OpenSIPSEventMap extends UAEventMap {
881
1110
  connectionStateChange: connectionStateChangeListener
882
1111
  newMSRPMessage: MSRPMessageListener
883
1112
  newMSRPSession: MSRPSessionListener
1113
+ // MSRP events listeners
1114
+ changeMsrpSession: changeMsrpSessionListener
1115
+ msrpSyncCompleted: msrpSyncCompletedListener
1116
+ msrpConversationCreated: msrpConversationCreatedListener
1117
+ msrpConversationRemoved: msrpConversationRemovedListener
1118
+ msrpConversationUpdated: msrpConversationUpdatedListener
1119
+ msrpMessageAdded: msrpMessageAddedListener
1120
+ msrpReceiptChanged: msrpReceiptChangedListener
1121
+ msrpReactionChanged: msrpReactionChangedListener
1122
+ msrpTyping: msrpTypingListener
884
1123
  // JANUS
885
1124
  conferenceStart: conferenceStartListener
886
1125
  conferenceEnd: conferenceEndListener
@@ -1026,11 +1265,22 @@ declare interface StreamMediaType extends HTMLAudioElement {
1026
1265
  setSinkId (id: string): Promise<void>
1027
1266
  }
1028
1267
 
1268
+ declare interface StreamMediaType_2 extends HTMLAudioElement {
1269
+ className: string
1270
+ setSinkId (id: string): Promise<void>
1271
+ }
1272
+
1029
1273
  declare type TestEventListener = (event: { test: string }) => void
1030
1274
 
1031
1275
  declare interface TriggerListenerOptions {
1032
1276
  listenerType: string
1033
1277
  session: RTCSessionExtended
1278
+ event?: ListenerEventType_2
1279
+ }
1280
+
1281
+ export declare interface TriggerMSRPListenerOptions {
1282
+ listenerType: string
1283
+ session: MSRPSessionExtended
1034
1284
  event?: ListenerEventType
1035
1285
  }
1036
1286
 
@@ -1164,7 +1414,7 @@ declare class VideoModule {
1164
1414
 
1165
1415
  declare type VideoModuleName = typeof MODULES.VIDEO
1166
1416
 
1167
- declare interface WebrtcMetricsConfigType {
1417
+ export declare interface WebrtcMetricsConfigType {
1168
1418
  refreshEvery?: number
1169
1419
  startAfter?: number
1170
1420
  stopAfter?: number