@wazo/sdk 0.46.0-rc.0 → 0.46.0-rc.1
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.js +127 -23
- package/dist/index.mjs +127 -23
- package/dist/types/api/auth.d.ts +2 -1
- package/dist/types/api/auth.d.ts.map +1 -1
- package/dist/types/domain/Phone/WebRTCPhone.d.ts +3 -1
- package/dist/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/dist/types/domain/types.d.ts +8 -0
- package/dist/types/domain/types.d.ts.map +1 -1
- package/dist/types/service/IssueReporter.d.ts +18 -1
- package/dist/types/service/IssueReporter.d.ts.map +1 -1
- package/dist/types/simple/Phone.d.ts +3 -1
- package/dist/types/simple/Phone.d.ts.map +1 -1
- package/dist/types/simple/index.d.ts +47 -2
- package/dist/types/simple/index.d.ts.map +1 -1
- package/dist/types/web-rtc-client.d.ts +10 -1
- package/dist/types/web-rtc-client.d.ts.map +1 -1
- package/dist/wazo-sdk.js +127 -23
- package/package.json +1 -1
package/dist/wazo-sdk.js
CHANGED
|
@@ -33285,8 +33285,10 @@
|
|
|
33285
33285
|
ON_CAMERA_DISABLED: ()=>ON_CAMERA_DISABLED,
|
|
33286
33286
|
ON_CAMERA_RESUMED: ()=>ON_CAMERA_RESUMED,
|
|
33287
33287
|
ON_CHAT: ()=>ON_CHAT,
|
|
33288
|
-
ON_DISCONNECTED: ()=>ON_DISCONNECTED,
|
|
33289
33288
|
ON_EARLY_MEDIA: ()=>ON_EARLY_MEDIA,
|
|
33289
|
+
ON_ICE_DISCONNECTED: ()=>ON_ICE_DISCONNECTED,
|
|
33290
|
+
ON_ICE_RECONNECTED: ()=>ON_ICE_RECONNECTED,
|
|
33291
|
+
ON_ICE_RECONNECTING: ()=>ON_ICE_RECONNECTING,
|
|
33290
33292
|
ON_MESSAGE: ()=>ON_MESSAGE,
|
|
33291
33293
|
ON_MESSAGE_TRACK_UPDATED: ()=>ON_MESSAGE_TRACK_UPDATED,
|
|
33292
33294
|
ON_NETWORK_STATS: ()=>ON_NETWORK_STATS,
|
|
@@ -33649,7 +33651,7 @@
|
|
|
33649
33651
|
];
|
|
33650
33652
|
const CATEGORY_PREFIX = 'logger-category=';
|
|
33651
33653
|
const MAX_REMOTE_RETRY = 10;
|
|
33652
|
-
|
|
33654
|
+
function addLevelsTo(instance, withMethods = false) {
|
|
33653
33655
|
instance.TRACE = TRACE;
|
|
33654
33656
|
instance.DEBUG = DEBUG;
|
|
33655
33657
|
instance.INFO = INFO;
|
|
@@ -33683,7 +33685,7 @@
|
|
|
33683
33685
|
]);
|
|
33684
33686
|
}
|
|
33685
33687
|
return instance;
|
|
33686
|
-
}
|
|
33688
|
+
}
|
|
33687
33689
|
const safeStringify = (object)=>{
|
|
33688
33690
|
const result = '{"message": "Not parsable JSON"}';
|
|
33689
33691
|
try {
|
|
@@ -35096,6 +35098,7 @@ BwIDAQAB
|
|
|
35096
35098
|
};
|
|
35097
35099
|
return client.put(`${baseUrl}/users/${userUuid}/password`, body, null, ApiRequester.successResponseParser);
|
|
35098
35100
|
},
|
|
35101
|
+
getDeviceToken: (userUuid)=>client.get(`${baseUrl}/users/${userUuid}/external/mobile`),
|
|
35099
35102
|
sendDeviceToken: (userUuid, deviceToken, apnsVoipToken, apnsNotificationToken)=>{
|
|
35100
35103
|
const body = {
|
|
35101
35104
|
token: deviceToken
|
|
@@ -41649,7 +41652,9 @@ BwIDAQAB
|
|
|
41649
41652
|
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
41650
41653
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
41651
41654
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
41652
|
-
const
|
|
41655
|
+
const ON_ICE_DISCONNECTED = 'onIceDisconnected';
|
|
41656
|
+
const ON_ICE_RECONNECTING = 'onIceReconnecting';
|
|
41657
|
+
const ON_ICE_RECONNECTED = 'onIceReconnected';
|
|
41653
41658
|
const ON_EARLY_MEDIA = 'onEarlyMedia';
|
|
41654
41659
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
41655
41660
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
@@ -41689,7 +41694,7 @@ BwIDAQAB
|
|
|
41689
41694
|
ON_CHAT,
|
|
41690
41695
|
ON_SIGNAL,
|
|
41691
41696
|
ON_NETWORK_STATS,
|
|
41692
|
-
|
|
41697
|
+
ON_ICE_DISCONNECTED,
|
|
41693
41698
|
ON_EARLY_MEDIA
|
|
41694
41699
|
];
|
|
41695
41700
|
const WebRTCPhone_logger = IssueReporter.loggerFor('webrtc-phone');
|
|
@@ -42709,9 +42714,17 @@ BwIDAQAB
|
|
|
42709
42714
|
WebRTCPhone_logger.info('WebRTC unregistered');
|
|
42710
42715
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
42711
42716
|
});
|
|
42712
|
-
this.client.on(this.client.
|
|
42713
|
-
WebRTCPhone_logger.info('
|
|
42714
|
-
this.eventEmitter.emit(
|
|
42717
|
+
this.client.on(this.client.ON_ICE_DISCONNECTED, ()=>{
|
|
42718
|
+
WebRTCPhone_logger.info('ICE connection disconnected');
|
|
42719
|
+
this.eventEmitter.emit(ON_ICE_DISCONNECTED);
|
|
42720
|
+
});
|
|
42721
|
+
this.client.on(this.client.ON_ICE_RECONNECTING, ()=>{
|
|
42722
|
+
WebRTCPhone_logger.info('ICE connection reconnecting');
|
|
42723
|
+
this.eventEmitter.emit(ON_ICE_RECONNECTING);
|
|
42724
|
+
});
|
|
42725
|
+
this.client.on(this.client.ON_ICE_RECONNECTED, ()=>{
|
|
42726
|
+
WebRTCPhone_logger.info('ICE connection reconnected');
|
|
42727
|
+
this.eventEmitter.emit(ON_ICE_RECONNECTED);
|
|
42715
42728
|
});
|
|
42716
42729
|
this.client.on(this.client.ON_PROGRESS, (session)=>{
|
|
42717
42730
|
WebRTCPhone_logger.info('WebRTC progress (180)');
|
|
@@ -50754,7 +50767,8 @@ BwIDAQAB
|
|
|
50754
50767
|
});
|
|
50755
50768
|
const DEFAULT_ICE_TIMEOUT = 3000;
|
|
50756
50769
|
const SEND_STATS_DELAY = 5000;
|
|
50757
|
-
const MAX_ICE_RECONNECT_ATTEMPTS =
|
|
50770
|
+
const MAX_ICE_RECONNECT_ATTEMPTS = 5;
|
|
50771
|
+
const DEFAULT_ICE_RECONNECT_DELAY = 500;
|
|
50758
50772
|
const states = [
|
|
50759
50773
|
'STATUS_NULL',
|
|
50760
50774
|
'STATUS_NEW',
|
|
@@ -50781,7 +50795,9 @@ BwIDAQAB
|
|
|
50781
50795
|
const ON_ERROR = 'onError';
|
|
50782
50796
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
50783
50797
|
const web_rtc_client_ON_NETWORK_STATS = 'onNetworkStats';
|
|
50784
|
-
const
|
|
50798
|
+
const web_rtc_client_ON_ICE_DISCONNECTED = 'onIceDisconnected';
|
|
50799
|
+
const web_rtc_client_ON_ICE_RECONNECTING = 'onIceReconnecting';
|
|
50800
|
+
const web_rtc_client_ON_ICE_RECONNECTED = 'onIceReconnected';
|
|
50785
50801
|
const web_rtc_client_events = [
|
|
50786
50802
|
REGISTERED,
|
|
50787
50803
|
UNREGISTERED,
|
|
@@ -50825,6 +50841,7 @@ BwIDAQAB
|
|
|
50825
50841
|
sessionNetworkStats;
|
|
50826
50842
|
forceClosed;
|
|
50827
50843
|
iceReconnectAttempts;
|
|
50844
|
+
iceReconnectDelay;
|
|
50828
50845
|
ON_USER_AGENT;
|
|
50829
50846
|
REGISTERED;
|
|
50830
50847
|
UNREGISTERED;
|
|
@@ -50843,7 +50860,9 @@ BwIDAQAB
|
|
|
50843
50860
|
ON_NETWORK_STATS;
|
|
50844
50861
|
ON_EARLY_MEDIA;
|
|
50845
50862
|
ON_PROGRESS;
|
|
50846
|
-
|
|
50863
|
+
ON_ICE_DISCONNECTED;
|
|
50864
|
+
ON_ICE_RECONNECTING;
|
|
50865
|
+
ON_ICE_RECONNECTED;
|
|
50847
50866
|
static isAPrivateIp(ip) {
|
|
50848
50867
|
const regex = /^(?:10|127|172\.(?:1[6-9]|2[0-9]|3[01])|192\.168)\..*/;
|
|
50849
50868
|
return null == regex.exec(ip);
|
|
@@ -50890,6 +50909,7 @@ BwIDAQAB
|
|
|
50890
50909
|
this.sessionNetworkStats = {};
|
|
50891
50910
|
this.forceClosed = false;
|
|
50892
50911
|
this.iceReconnectAttempts = {};
|
|
50912
|
+
this.iceReconnectDelay = config.iceReconnectDelay || DEFAULT_ICE_RECONNECT_DELAY;
|
|
50893
50913
|
this._boundOnHeartbeat = this._onHeartbeat.bind(this);
|
|
50894
50914
|
this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
|
|
50895
50915
|
this.heartbeat.setSendHeartbeat(this.pingServer.bind(this));
|
|
@@ -50909,9 +50929,11 @@ BwIDAQAB
|
|
|
50909
50929
|
this.ON_ERROR = ON_ERROR;
|
|
50910
50930
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
50911
50931
|
this.ON_NETWORK_STATS = web_rtc_client_ON_NETWORK_STATS;
|
|
50912
|
-
this.
|
|
50932
|
+
this.ON_ICE_DISCONNECTED = web_rtc_client_ON_ICE_DISCONNECTED;
|
|
50913
50933
|
this.ON_EARLY_MEDIA = web_rtc_client_ON_EARLY_MEDIA;
|
|
50914
50934
|
this.ON_PROGRESS = web_rtc_client_ON_PROGRESS;
|
|
50935
|
+
this.ON_ICE_RECONNECTING = web_rtc_client_ON_ICE_RECONNECTING;
|
|
50936
|
+
this.ON_ICE_RECONNECTED = web_rtc_client_ON_ICE_RECONNECTED;
|
|
50915
50937
|
}
|
|
50916
50938
|
configureMedia(media) {
|
|
50917
50939
|
this.hasAudio = !!media.audio;
|
|
@@ -51065,8 +51087,15 @@ BwIDAQAB
|
|
|
51065
51087
|
newState,
|
|
51066
51088
|
clientId: this.clientId
|
|
51067
51089
|
});
|
|
51068
|
-
if (newState === registerer_state_RegistererState.Registered && this.registerer
|
|
51069
|
-
|
|
51090
|
+
if (newState === registerer_state_RegistererState.Registered && this.registerer?.state === registerer_state_RegistererState.Registered) {
|
|
51091
|
+
this.warmupIceConnectivity().catch((error)=>{
|
|
51092
|
+
web_rtc_client_logger.warn('ICE warmup after registration failed', {
|
|
51093
|
+
error: error.message,
|
|
51094
|
+
clientId: this.clientId
|
|
51095
|
+
});
|
|
51096
|
+
});
|
|
51097
|
+
this.eventEmitter.emit(REGISTERED);
|
|
51098
|
+
} else if (newState === registerer_state_RegistererState.Unregistered) this.eventEmitter.emit(UNREGISTERED);
|
|
51070
51099
|
});
|
|
51071
51100
|
const options = {
|
|
51072
51101
|
requestDelegate: {
|
|
@@ -51912,6 +51941,75 @@ BwIDAQAB
|
|
|
51912
51941
|
this._stopSendingStats(session);
|
|
51913
51942
|
this.stopNetworkMonitoring(session);
|
|
51914
51943
|
}
|
|
51944
|
+
async warmupIceConnectivity() {
|
|
51945
|
+
if (!this.config.iceWarmup) {
|
|
51946
|
+
web_rtc_client_logger.info('ICE warmup disabled in configuration', {
|
|
51947
|
+
clientId: this.clientId
|
|
51948
|
+
});
|
|
51949
|
+
return;
|
|
51950
|
+
}
|
|
51951
|
+
const config = {
|
|
51952
|
+
iceServers: this.uaConfigOverrides?.peerConnectionOptions?.iceServers || WebRTCClient.getIceServers(this.config.host)
|
|
51953
|
+
};
|
|
51954
|
+
web_rtc_client_logger.info('Starting ICE connectivity warmup', {
|
|
51955
|
+
clientId: this.clientId,
|
|
51956
|
+
config
|
|
51957
|
+
});
|
|
51958
|
+
try {
|
|
51959
|
+
const pc = new RTCPeerConnection(config);
|
|
51960
|
+
pc.createDataChannel('warmup');
|
|
51961
|
+
const candidates = [];
|
|
51962
|
+
pc.onicecandidate = (event)=>{
|
|
51963
|
+
if (event.candidate) {
|
|
51964
|
+
candidates.push(event.candidate);
|
|
51965
|
+
web_rtc_client_logger.debug('ICE warmup candidate gathered', {
|
|
51966
|
+
candidate: event.candidate.candidate,
|
|
51967
|
+
type: event.candidate.type
|
|
51968
|
+
});
|
|
51969
|
+
} else web_rtc_client_logger.info('ICE warmup completed', {
|
|
51970
|
+
totalCandidates: candidates.length,
|
|
51971
|
+
clientId: this.clientId
|
|
51972
|
+
});
|
|
51973
|
+
};
|
|
51974
|
+
const offer = await pc.createOffer();
|
|
51975
|
+
await pc.setLocalDescription(offer);
|
|
51976
|
+
await new Promise((resolve, reject)=>{
|
|
51977
|
+
const timeout = setTimeout(()=>{
|
|
51978
|
+
web_rtc_client_logger.warn('ICE warmup timed out', {
|
|
51979
|
+
clientId: this.clientId
|
|
51980
|
+
});
|
|
51981
|
+
resolve();
|
|
51982
|
+
}, 10000);
|
|
51983
|
+
pc.onicegatheringstatechange = ()=>{
|
|
51984
|
+
if ('complete' === pc.iceGatheringState) {
|
|
51985
|
+
clearTimeout(timeout);
|
|
51986
|
+
web_rtc_client_logger.info('ICE warmup gathering completed', {
|
|
51987
|
+
candidates: candidates.length,
|
|
51988
|
+
clientId: this.clientId
|
|
51989
|
+
});
|
|
51990
|
+
resolve();
|
|
51991
|
+
}
|
|
51992
|
+
};
|
|
51993
|
+
if (candidates.length > 0) setTimeout(()=>{
|
|
51994
|
+
clearTimeout(timeout);
|
|
51995
|
+
web_rtc_client_logger.info('ICE warmup resolved with candidates', {
|
|
51996
|
+
candidates: candidates.length,
|
|
51997
|
+
clientId: this.clientId
|
|
51998
|
+
});
|
|
51999
|
+
resolve();
|
|
52000
|
+
}, 5000);
|
|
52001
|
+
});
|
|
52002
|
+
pc.close();
|
|
52003
|
+
web_rtc_client_logger.info('ICE warmup completed successfully', {
|
|
52004
|
+
clientId: this.clientId
|
|
52005
|
+
});
|
|
52006
|
+
} catch (error) {
|
|
52007
|
+
web_rtc_client_logger.warn('ICE warmup failed', {
|
|
52008
|
+
error: error.message,
|
|
52009
|
+
clientId: this.clientId
|
|
52010
|
+
});
|
|
52011
|
+
}
|
|
52012
|
+
}
|
|
51915
52013
|
attemptReconnection() {
|
|
51916
52014
|
web_rtc_client_logger.info('attempt reconnection', {
|
|
51917
52015
|
clientId: this.clientId,
|
|
@@ -52297,24 +52395,29 @@ BwIDAQAB
|
|
|
52297
52395
|
if ('disconnected' === pc.iceConnectionState) {
|
|
52298
52396
|
const attempts = this.iceReconnectAttempts[currentSessionId] || 0;
|
|
52299
52397
|
if (attempts < MAX_ICE_RECONNECT_ATTEMPTS) {
|
|
52398
|
+
this.eventEmitter.emit(web_rtc_client_ON_ICE_RECONNECTING, session);
|
|
52300
52399
|
this.iceReconnectAttempts[currentSessionId] = attempts + 1;
|
|
52301
52400
|
web_rtc_client_logger.info('ICE connection disconnected, attempting to reconnect...', {
|
|
52302
52401
|
sessionId: currentSessionId,
|
|
52303
52402
|
attempt: attempts + 1
|
|
52304
52403
|
});
|
|
52305
52404
|
const isConference = this.isConference(currentSessionId);
|
|
52306
|
-
|
|
52405
|
+
setTimeout(()=>{
|
|
52406
|
+
this.reinvite(session, null, isConference, false, true);
|
|
52407
|
+
}, this.iceReconnectDelay);
|
|
52307
52408
|
} else {
|
|
52308
52409
|
web_rtc_client_logger.warn('ICE reconnection failed after max attempts', {
|
|
52309
52410
|
sessionId: currentSessionId
|
|
52310
52411
|
});
|
|
52311
|
-
this.eventEmitter.emit(
|
|
52412
|
+
this.eventEmitter.emit(web_rtc_client_ON_ICE_DISCONNECTED, session);
|
|
52312
52413
|
}
|
|
52313
52414
|
} else if ('connected' === pc.iceConnectionState || 'completed' === pc.iceConnectionState) {
|
|
52314
|
-
if (this.iceReconnectAttempts[currentSessionId] > 0)
|
|
52315
|
-
|
|
52316
|
-
|
|
52317
|
-
|
|
52415
|
+
if (this.iceReconnectAttempts[currentSessionId] > 0) {
|
|
52416
|
+
this.eventEmitter.emit(web_rtc_client_ON_ICE_RECONNECTED, session);
|
|
52417
|
+
web_rtc_client_logger.info('ICE reconnected successfully', {
|
|
52418
|
+
sessionId: currentSessionId
|
|
52419
|
+
});
|
|
52420
|
+
}
|
|
52318
52421
|
}
|
|
52319
52422
|
};
|
|
52320
52423
|
}
|
|
@@ -52347,7 +52450,6 @@ BwIDAQAB
|
|
|
52347
52450
|
sessionId,
|
|
52348
52451
|
error
|
|
52349
52452
|
});
|
|
52350
|
-
return;
|
|
52351
52453
|
}
|
|
52352
52454
|
const audioElement = this.audioElements[sessionId];
|
|
52353
52455
|
if (!audioElement) {
|
|
@@ -52387,7 +52489,7 @@ BwIDAQAB
|
|
|
52387
52489
|
audioElement.srcObject = stream;
|
|
52388
52490
|
audioElement.volume = this.audioOutputVolume;
|
|
52389
52491
|
try {
|
|
52390
|
-
|
|
52492
|
+
audioElement.play();
|
|
52391
52493
|
web_rtc_client_logger.info('Audio element play() successful', {
|
|
52392
52494
|
sessionId
|
|
52393
52495
|
});
|
|
@@ -52776,7 +52878,9 @@ BwIDAQAB
|
|
|
52776
52878
|
ON_NETWORK_STATS;
|
|
52777
52879
|
ON_CHAT;
|
|
52778
52880
|
ON_SIGNAL;
|
|
52779
|
-
|
|
52881
|
+
ON_ICE_DISCONNECTED;
|
|
52882
|
+
ON_ICE_RECONNECTING;
|
|
52883
|
+
ON_ICE_RECONNECTED;
|
|
52780
52884
|
ON_EARLY_MEDIA;
|
|
52781
52885
|
MESSAGE_TYPE_CHAT;
|
|
52782
52886
|
MESSAGE_TYPE_SIGNAL;
|