@wazo/sdk 0.43.7 → 0.43.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -7
- package/dist/wazo-sdk.js +6 -6
- package/esm/domain/CallLog.js +2 -3
- package/esm/domain/Phone/WebRTCPhone.js +32 -27
- package/esm/simple/Phone.js +2 -2
- package/esm/types/domain/CallLog.d.ts.map +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +4 -4
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/simple/Phone.d.ts +2 -2
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/web-rtc-client.js +28 -28
- package/lib/domain/CallLog.js +2 -3
- package/lib/domain/Phone/WebRTCPhone.js +32 -27
- package/lib/types/domain/CallLog.d.ts.map +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +4 -4
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/simple/Phone.d.ts +2 -2
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/web-rtc-client.js +28 -28
- package/package.json +1 -1
- package/src/domain/CallLog.ts +2 -3
- package/src/domain/Phone/WebRTCPhone.ts +37 -32
- package/src/simple/Phone.ts +3 -3
- package/src/web-rtc-client.ts +29 -29
package/src/web-rtc-client.ts
CHANGED
|
@@ -42,7 +42,6 @@ export const replaceLocalIpModifier = (description: Record<string, any>) => Prom
|
|
|
42
42
|
...JSON.parse(JSON.stringify(description)),
|
|
43
43
|
sdp: description.sdp.replace('c=IN IP4 0.0.0.0', 'c=IN IP4 127.0.0.1'),
|
|
44
44
|
});
|
|
45
|
-
const SIP_ID_LENGTH = 36;
|
|
46
45
|
const DEFAULT_ICE_TIMEOUT = 3000;
|
|
47
46
|
const SEND_STATS_DELAY = 5000;
|
|
48
47
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
@@ -268,7 +267,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
268
267
|
logger.info('sdk webrtc on invite', {
|
|
269
268
|
method: 'delegate.onInvite',
|
|
270
269
|
clientId: this.clientId,
|
|
271
|
-
id: invitation
|
|
270
|
+
id: this.getSipSessionId(invitation),
|
|
272
271
|
remoteURI: (invitation as any).remoteURI,
|
|
273
272
|
});
|
|
274
273
|
|
|
@@ -604,7 +603,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
604
603
|
},
|
|
605
604
|
onReject: (response: IncomingResponse) => {
|
|
606
605
|
logger.info('on call rejected', {
|
|
607
|
-
id: session
|
|
606
|
+
id: this.getSipSessionId(session),
|
|
608
607
|
// @ts-ignore: fromTag does not exist
|
|
609
608
|
fromTag: session?.fromTag,
|
|
610
609
|
});
|
|
@@ -641,7 +640,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
641
640
|
answer(session: Invitation, enableVideo?: boolean): Promise<void> {
|
|
642
641
|
logger.info('sdk webrtc answer call', {
|
|
643
642
|
clientId: this.clientId,
|
|
644
|
-
id: session
|
|
643
|
+
id: this.getSipSessionId(session),
|
|
645
644
|
enableVideo,
|
|
646
645
|
});
|
|
647
646
|
|
|
@@ -659,7 +658,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
659
658
|
if (session.isCanceled) {
|
|
660
659
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
661
660
|
logger.error(message, {
|
|
662
|
-
id: session
|
|
661
|
+
id: this.getSipSessionId(session),
|
|
663
662
|
});
|
|
664
663
|
this.onCallEnded(session);
|
|
665
664
|
throw new CanceledCallError(message);
|
|
@@ -669,7 +668,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
669
668
|
|
|
670
669
|
this._onAccepted(session);
|
|
671
670
|
}).catch(e => {
|
|
672
|
-
logger.error(`answer call error for ${session
|
|
671
|
+
logger.error(`answer call error for ${this.getSipSessionId(session)}`, e);
|
|
673
672
|
throw e;
|
|
674
673
|
});
|
|
675
674
|
}
|
|
@@ -747,7 +746,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
747
746
|
async reject(session: WazoSession): Promise<void> {
|
|
748
747
|
logger.info('sdk webrtc reject call', {
|
|
749
748
|
clientId: this.clientId,
|
|
750
|
-
id: session
|
|
749
|
+
id: this.getSipSessionId(session),
|
|
751
750
|
});
|
|
752
751
|
|
|
753
752
|
try {
|
|
@@ -819,7 +818,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
819
818
|
|
|
820
819
|
mute(session: WazoSession): void {
|
|
821
820
|
logger.info('sdk webrtc mute', {
|
|
822
|
-
id: session
|
|
821
|
+
id: this.getSipSessionId(session),
|
|
823
822
|
});
|
|
824
823
|
|
|
825
824
|
this._toggleAudio(session, true);
|
|
@@ -827,7 +826,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
827
826
|
|
|
828
827
|
unmute(session: WazoSession): void {
|
|
829
828
|
logger.info('sdk webrtc unmute', {
|
|
830
|
-
id: session
|
|
829
|
+
id: this.getSipSessionId(session),
|
|
831
830
|
});
|
|
832
831
|
|
|
833
832
|
this._toggleAudio(session, false);
|
|
@@ -872,7 +871,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
872
871
|
|
|
873
872
|
toggleCameraOn(session: WazoSession): void {
|
|
874
873
|
logger.info('sdk webrtc toggle camera on', {
|
|
875
|
-
id: session
|
|
874
|
+
id: this.getSipSessionId(session),
|
|
876
875
|
});
|
|
877
876
|
|
|
878
877
|
this._toggleVideo(session, false);
|
|
@@ -880,7 +879,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
880
879
|
|
|
881
880
|
toggleCameraOff(session: WazoSession): void {
|
|
882
881
|
logger.info('sdk webrtc toggle camera off', {
|
|
883
|
-
id: session
|
|
882
|
+
id: this.getSipSessionId(session),
|
|
884
883
|
});
|
|
885
884
|
|
|
886
885
|
this._toggleVideo(session, true);
|
|
@@ -1178,7 +1177,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1178
1177
|
}
|
|
1179
1178
|
|
|
1180
1179
|
logger.info('send WebRTC message', {
|
|
1181
|
-
sipId: sipSession
|
|
1180
|
+
sipId: this.getSipSessionId(sipSession),
|
|
1182
1181
|
contentType,
|
|
1183
1182
|
});
|
|
1184
1183
|
|
|
@@ -1611,20 +1610,21 @@ export default class WebRTCClient extends Emitter {
|
|
|
1611
1610
|
return '';
|
|
1612
1611
|
}
|
|
1613
1612
|
|
|
1614
|
-
const message = sipSession.message as Partial<{ callId?: string }>;
|
|
1615
|
-
if (message?.callId) {
|
|
1616
|
-
return message.callId.substring(0, SIP_ID_LENGTH);
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
1613
|
// For Inviter
|
|
1620
1614
|
// @ts-ignore: private
|
|
1621
1615
|
if (sipSession instanceof Inviter && sipSession.outgoingRequestMessage) {
|
|
1622
1616
|
// @ts-ignore: private
|
|
1623
|
-
return sipSession.outgoingRequestMessage.callId
|
|
1617
|
+
return sipSession.outgoingRequestMessage.callId;
|
|
1624
1618
|
}
|
|
1625
1619
|
|
|
1626
1620
|
// For Invitation
|
|
1627
|
-
|
|
1621
|
+
// @ts-ignore: private
|
|
1622
|
+
if (sipSession instanceof Invitation && sipSession.incomingInviteRequest.message) {
|
|
1623
|
+
// @ts-ignore: private
|
|
1624
|
+
return sipSession.incomingInviteRequest.message.callId;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
return '';
|
|
1628
1628
|
}
|
|
1629
1629
|
|
|
1630
1630
|
async waitForRegister(): Promise<void> {
|
|
@@ -1704,7 +1704,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1704
1704
|
}
|
|
1705
1705
|
|
|
1706
1706
|
getSipSession(id: string): WazoSession | null | undefined {
|
|
1707
|
-
return id in this.sipSessions ? this.sipSessions[id
|
|
1707
|
+
return id in this.sipSessions ? this.sipSessions[id] : null;
|
|
1708
1708
|
}
|
|
1709
1709
|
|
|
1710
1710
|
getSipSessionIds(): string[] {
|
|
@@ -2168,7 +2168,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2168
2168
|
async _onProgress(session: WazoSession, early = false): Promise<void> {
|
|
2169
2169
|
await this._setupMedias(session);
|
|
2170
2170
|
|
|
2171
|
-
const sessionId = this.getSipSessionId(session)
|
|
2171
|
+
const sessionId = this.getSipSessionId(session);
|
|
2172
2172
|
this.updateRemoteStream(sessionId);
|
|
2173
2173
|
logger.info('progress received', {
|
|
2174
2174
|
sessionId,
|
|
@@ -2179,7 +2179,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2179
2179
|
|
|
2180
2180
|
async _onAccepted(session: WazoSession, sessionDialog?: SessionDialog, withEvent = true, initAllTracks = true): Promise<void> {
|
|
2181
2181
|
logger.info('on call accepted', {
|
|
2182
|
-
id: session
|
|
2182
|
+
id: this.getSipSessionId(session),
|
|
2183
2183
|
clientId: this.clientId,
|
|
2184
2184
|
remoteTag: session.remoteTag,
|
|
2185
2185
|
});
|
|
@@ -2610,20 +2610,20 @@ export default class WebRTCClient extends Emitter {
|
|
|
2610
2610
|
async _accept(session: Invitation, options: InvitationAcceptOptions = {}) {
|
|
2611
2611
|
if (session.state === SessionState.Terminated || session.state === SessionState.Terminating) {
|
|
2612
2612
|
const error = 'Trying to accept a terminated sipSession.';
|
|
2613
|
-
logger.warn(error, { state: session.state, sessionId: session
|
|
2613
|
+
logger.warn(error, { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2614
2614
|
throw new Error(error);
|
|
2615
2615
|
}
|
|
2616
2616
|
|
|
2617
2617
|
if (session.state !== SessionState.Initial) {
|
|
2618
2618
|
const error = 'Trying to accept a non Initial sipSession.';
|
|
2619
|
-
logger.warn(error, { state: session.state, sessionId: session
|
|
2619
|
+
logger.warn(error, { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2620
2620
|
throw new Error(error);
|
|
2621
2621
|
}
|
|
2622
2622
|
|
|
2623
2623
|
// @ts-ignore: private
|
|
2624
2624
|
if (!session.incomingInviteRequest.acceptable) {
|
|
2625
2625
|
const error = 'Trying to reject a non `acceptable` session';
|
|
2626
|
-
logger.warn(error, { state: session.state, sessionId: session
|
|
2626
|
+
logger.warn(error, { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2627
2627
|
throw new Error(error);
|
|
2628
2628
|
}
|
|
2629
2629
|
|
|
@@ -2636,13 +2636,13 @@ export default class WebRTCClient extends Emitter {
|
|
|
2636
2636
|
|
|
2637
2637
|
async _reject(session: Invitation, options: InvitationRejectOptions = {}) {
|
|
2638
2638
|
if (session.state !== SessionState.Initial && session.state !== SessionState.Establishing) {
|
|
2639
|
-
logger.warn('Trying to reject a session in a wrong state', { state: session.state, sessionId: session
|
|
2639
|
+
logger.warn('Trying to reject a session in a wrong state', { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2640
2640
|
return;
|
|
2641
2641
|
}
|
|
2642
2642
|
|
|
2643
2643
|
// @ts-ignore: private
|
|
2644
2644
|
if (!session.incomingInviteRequest.rejectable) {
|
|
2645
|
-
logger.warn('Trying to reject a non `rejectable` session', { state: session.state, sessionId: session
|
|
2645
|
+
logger.warn('Trying to reject a non `rejectable` session', { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2646
2646
|
return;
|
|
2647
2647
|
}
|
|
2648
2648
|
|
|
@@ -2655,7 +2655,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2655
2655
|
|
|
2656
2656
|
async _cancel(session: Inviter, options: InviterCancelOptions = {}) {
|
|
2657
2657
|
if (session.state !== SessionState.Initial && session.state !== SessionState.Establishing) {
|
|
2658
|
-
logger.warn('Trying to cancel a session in a wrong state', { state: session.state, sessionId: session
|
|
2658
|
+
logger.warn('Trying to cancel a session in a wrong state', { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2659
2659
|
return;
|
|
2660
2660
|
}
|
|
2661
2661
|
|
|
@@ -2668,7 +2668,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2668
2668
|
|
|
2669
2669
|
async _bye(session: WazoSession, options: SessionByeOptions = {}) {
|
|
2670
2670
|
if (session.state !== SessionState.Established) {
|
|
2671
|
-
logger.warn('Trying to end a session in a wrong state', { state: session.state, sessionId: session
|
|
2671
|
+
logger.warn('Trying to end a session in a wrong state', { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2672
2672
|
return null;
|
|
2673
2673
|
}
|
|
2674
2674
|
|