@wazo/sdk 0.41.1 → 0.41.2
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/wazo-sdk.js +42 -41913
- package/esm/__tests__/api-client.test.js +15 -5
- package/esm/service/__tests__/IssueReporter.test.js +5 -1
- package/esm/types/service/getApiClient.d.ts.map +1 -1
- package/esm/types/utils/array.d.ts.map +1 -1
- package/esm/utils/__tests__/api-requester.test.js +19 -15
- package/esm/web-rtc-client.js +1 -1
- package/esm/websocket-client.js +1 -1
- package/lib/__tests__/api-client.test.js +15 -5
- package/lib/checker/Checker.js +2 -2
- package/lib/domain/Phone/WebRTCPhone.js +12 -12
- package/lib/service/CallApi.js +4 -4
- package/lib/service/__tests__/IssueReporter.test.js +5 -1
- package/lib/simple/Auth.js +5 -5
- package/lib/simple/Phone.js +9 -9
- package/lib/simple/room/Participant.js +2 -2
- package/lib/simple/room/Room.js +8 -8
- package/lib/simple/room/SipRoom.js +2 -2
- package/lib/simple/utils.js +1 -1
- package/lib/types/service/getApiClient.d.ts.map +1 -1
- package/lib/types/utils/array.d.ts.map +1 -1
- package/lib/utils/__tests__/api-requester.test.js +19 -15
- package/lib/utils/api-requester.js +2 -2
- package/lib/web-rtc-client.js +23 -27
- package/lib/websocket-client.js +1 -1
- package/package.json +23 -20
- package/src/__tests__/api-client.test.ts +15 -5
- package/src/service/__tests__/IssueReporter.test.ts +5 -1
- package/src/utils/__tests__/api-requester.test.ts +20 -16
- package/src/web-rtc-client.ts +1 -1
- package/src/websocket-client.ts +1 -1
package/lib/web-rtc-client.js
CHANGED
|
@@ -249,8 +249,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
249
249
|
return this.register();
|
|
250
250
|
}
|
|
251
251
|
onDisconnect(error) {
|
|
252
|
-
var _a;
|
|
253
252
|
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
var _a;
|
|
254
254
|
logger.info('sdk webrtc disconnected', { method: 'delegate.onConnect', clientId: this.clientId, error });
|
|
255
255
|
this.connectionPromise = null;
|
|
256
256
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
@@ -266,9 +266,9 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
266
266
|
}
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
|
-
register(
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
register() {
|
|
270
|
+
return __awaiter(this, arguments, void 0, function* (tries = 0) {
|
|
271
|
+
var _a;
|
|
272
272
|
const logInfo = {
|
|
273
273
|
clientId: this.clientId,
|
|
274
274
|
userAgent: !!this.userAgent,
|
|
@@ -449,14 +449,10 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
449
449
|
conference,
|
|
450
450
|
options,
|
|
451
451
|
});
|
|
452
|
-
const inviterOptions = {
|
|
453
|
-
sessionDescriptionHandlerOptionsReInvite: {
|
|
452
|
+
const inviterOptions = Object.assign({ sessionDescriptionHandlerOptionsReInvite: {
|
|
454
453
|
conference,
|
|
455
454
|
audioOnly,
|
|
456
|
-
},
|
|
457
|
-
earlyMedia: true,
|
|
458
|
-
options,
|
|
459
|
-
};
|
|
455
|
+
}, earlyMedia: true }, options);
|
|
460
456
|
if (audioOnly) {
|
|
461
457
|
inviterOptions.sessionDescriptionHandlerModifiersReInvite = [modifiers_1.stripVideo];
|
|
462
458
|
}
|
|
@@ -576,8 +572,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
576
572
|
});
|
|
577
573
|
}
|
|
578
574
|
getStats(session) {
|
|
579
|
-
var _a;
|
|
580
575
|
return __awaiter(this, void 0, void 0, function* () {
|
|
576
|
+
var _a;
|
|
581
577
|
const pc = (_a = session.sessionDescriptionHandler) === null || _a === void 0 ? void 0 : _a.peerConnection;
|
|
582
578
|
if (!pc) {
|
|
583
579
|
return null;
|
|
@@ -628,8 +624,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
628
624
|
}
|
|
629
625
|
});
|
|
630
626
|
}
|
|
631
|
-
close(
|
|
632
|
-
return __awaiter(this,
|
|
627
|
+
close() {
|
|
628
|
+
return __awaiter(this, arguments, void 0, function* (force = false) {
|
|
633
629
|
logger.info('sdk webrtc closing client', {
|
|
634
630
|
clientId: this.clientId,
|
|
635
631
|
userAgent: !!this.userAgent,
|
|
@@ -817,8 +813,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
817
813
|
}
|
|
818
814
|
// Returns true if a re-INVITE is required
|
|
819
815
|
upgradeToVideo(session, constraints, isConference) {
|
|
820
|
-
var _a, _b;
|
|
821
816
|
return __awaiter(this, void 0, void 0, function* () {
|
|
817
|
+
var _a, _b;
|
|
822
818
|
const pc = (_a = session.sessionDescriptionHandler) === null || _a === void 0 ? void 0 : _a.peerConnection;
|
|
823
819
|
// Check if a video sender already exists
|
|
824
820
|
let videoSender;
|
|
@@ -875,8 +871,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
875
871
|
localStream.removeTrack(videoTrack);
|
|
876
872
|
});
|
|
877
873
|
}
|
|
878
|
-
getStreamFromConstraints(
|
|
879
|
-
return __awaiter(this,
|
|
874
|
+
getStreamFromConstraints(constraints_1) {
|
|
875
|
+
return __awaiter(this, arguments, void 0, function* (constraints, conference = false) {
|
|
880
876
|
const video = constraints && constraints.video;
|
|
881
877
|
const { constraints: newConstraints, } = this.getMediaConfiguration(video, conference, constraints);
|
|
882
878
|
let newStream = null;
|
|
@@ -2032,9 +2028,9 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
2032
2028
|
_makeURI(target) {
|
|
2033
2029
|
return user_agent_1.UserAgent.makeURI(`sip:${target}@${this.config.host}`);
|
|
2034
2030
|
}
|
|
2035
|
-
_disconnectTransport(
|
|
2036
|
-
|
|
2037
|
-
|
|
2031
|
+
_disconnectTransport() {
|
|
2032
|
+
return __awaiter(this, arguments, void 0, function* (force = false) {
|
|
2033
|
+
var _a;
|
|
2038
2034
|
const transport = (_a = this.userAgent) === null || _a === void 0 ? void 0 : _a.transport;
|
|
2039
2035
|
if (force && transport) {
|
|
2040
2036
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
@@ -2155,8 +2151,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
2155
2151
|
}
|
|
2156
2152
|
});
|
|
2157
2153
|
}
|
|
2158
|
-
_accept(
|
|
2159
|
-
return __awaiter(this,
|
|
2154
|
+
_accept(session_1) {
|
|
2155
|
+
return __awaiter(this, arguments, void 0, function* (session, options = {}) {
|
|
2160
2156
|
if (session.state === session_state_1.SessionState.Terminated || session.state === session_state_1.SessionState.Terminating) {
|
|
2161
2157
|
const error = 'Trying to accept a terminated sipSession.';
|
|
2162
2158
|
logger.warn(error, { state: session.state, sessionId: session.id });
|
|
@@ -2181,8 +2177,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
2181
2177
|
}
|
|
2182
2178
|
});
|
|
2183
2179
|
}
|
|
2184
|
-
_reject(
|
|
2185
|
-
return __awaiter(this,
|
|
2180
|
+
_reject(session_1) {
|
|
2181
|
+
return __awaiter(this, arguments, void 0, function* (session, options = {}) {
|
|
2186
2182
|
if (session.state !== session_state_1.SessionState.Initial && session.state !== session_state_1.SessionState.Establishing) {
|
|
2187
2183
|
logger.warn('Trying to reject a session in a wrong state', { state: session.state, sessionId: session.id });
|
|
2188
2184
|
return;
|
|
@@ -2200,8 +2196,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
2200
2196
|
}
|
|
2201
2197
|
});
|
|
2202
2198
|
}
|
|
2203
|
-
_cancel(
|
|
2204
|
-
return __awaiter(this,
|
|
2199
|
+
_cancel(session_1) {
|
|
2200
|
+
return __awaiter(this, arguments, void 0, function* (session, options = {}) {
|
|
2205
2201
|
if (session.state !== session_state_1.SessionState.Initial && session.state !== session_state_1.SessionState.Establishing) {
|
|
2206
2202
|
logger.warn('Trying to cancel a session in a wrong state', { state: session.state, sessionId: session.id });
|
|
2207
2203
|
return;
|
|
@@ -2214,8 +2210,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
2214
2210
|
}
|
|
2215
2211
|
});
|
|
2216
2212
|
}
|
|
2217
|
-
_bye(
|
|
2218
|
-
return __awaiter(this,
|
|
2213
|
+
_bye(session_1) {
|
|
2214
|
+
return __awaiter(this, arguments, void 0, function* (session, options = {}) {
|
|
2219
2215
|
if (session.state !== session_state_1.SessionState.Established) {
|
|
2220
2216
|
logger.warn('Trying to end a session in a wrong state', { state: session.state, sessionId: session.id });
|
|
2221
2217
|
return null;
|
package/lib/websocket-client.js
CHANGED
|
@@ -220,7 +220,7 @@ class WebSocketClient extends Emitter_1.default {
|
|
|
220
220
|
logger.warn('Trying to close an already closed websocket, bailing.', { url: this._getUrl() });
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
|
-
this.socket.close();
|
|
223
|
+
this.socket.close(1000);
|
|
224
224
|
this.initialized = false;
|
|
225
225
|
if (force) {
|
|
226
226
|
this.host = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wazo/sdk",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.2",
|
|
4
4
|
"description": "Wazo's JavaScript Software Development Kit.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -51,26 +51,26 @@
|
|
|
51
51
|
"fstream": "^1.0.12",
|
|
52
52
|
"getstats": "wazo-platform/getStats#fix_stats_mobile",
|
|
53
53
|
"google-libphonenumber": "^3.2.32",
|
|
54
|
-
"js-base64": "^3.7.
|
|
54
|
+
"js-base64": "^3.7.7",
|
|
55
55
|
"json-to-graphql-query": "^2.2.5",
|
|
56
|
-
"jsrsasign": "^11.
|
|
57
|
-
"moment": "^2.
|
|
56
|
+
"jsrsasign": "^11.1.0",
|
|
57
|
+
"moment": "^2.30.1",
|
|
58
58
|
"reconnecting-websocket": "^4.4.0",
|
|
59
|
-
"sdp-transform": "^2.14.
|
|
59
|
+
"sdp-transform": "^2.14.2",
|
|
60
60
|
"sip.js": "^0.21.2",
|
|
61
61
|
"webrtc-adapter": "^8.2.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@babel/core": "^7.
|
|
65
|
-
"@babel/preset-env": "^7.
|
|
66
|
-
"@babel/preset-typescript": "^7.
|
|
67
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
68
|
-
"@rollup/plugin-json": "^6.
|
|
69
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
70
|
-
"@rollup/plugin-terser": "^0.4.
|
|
71
|
-
"@rollup/plugin-typescript": "^11.1.
|
|
72
|
-
"@types/events": "^3.0.
|
|
73
|
-
"@types/google-libphonenumber": "^7.4.
|
|
64
|
+
"@babel/core": "^7.24.4",
|
|
65
|
+
"@babel/preset-env": "^7.24.4",
|
|
66
|
+
"@babel/preset-typescript": "^7.24.1",
|
|
67
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
68
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
69
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
70
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
71
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
72
|
+
"@types/events": "^3.0.3",
|
|
73
|
+
"@types/google-libphonenumber": "^7.4.30",
|
|
74
74
|
"@types/jest": "^29.5.2",
|
|
75
75
|
"@types/jsrsasign": "^10.5.8",
|
|
76
76
|
"@types/node": "^20.4.0",
|
|
@@ -79,20 +79,23 @@
|
|
|
79
79
|
"@typescript-eslint/parser": "^5.61.0",
|
|
80
80
|
"babel-core": "^7.0.0-bridge.0",
|
|
81
81
|
"babel-eslint": "10.1.0",
|
|
82
|
-
"babel-loader": "^9.1.
|
|
82
|
+
"babel-loader": "^9.1.3",
|
|
83
83
|
"eslint": "^8.44.0",
|
|
84
84
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
85
85
|
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
86
86
|
"eslint-config-prettier": "^8.8.0",
|
|
87
|
-
"eslint-plugin-import": "^2.
|
|
87
|
+
"eslint-plugin-import": "^2.29.1",
|
|
88
88
|
"eslint-plugin-prettier": "^4.2.1",
|
|
89
89
|
"jest": "^29.6.1",
|
|
90
90
|
"jsonlint": "^1.6.3",
|
|
91
91
|
"prettier-eslint-cli": "^7.1.0",
|
|
92
|
-
"rimraf": "^5.0.
|
|
92
|
+
"rimraf": "^5.0.5",
|
|
93
93
|
"rollup": "^3.26.2",
|
|
94
|
-
"ts-jest": "^29.1.
|
|
95
|
-
"typescript": "^5.
|
|
94
|
+
"ts-jest": "^29.1.2",
|
|
95
|
+
"typescript": "^5.4.5"
|
|
96
|
+
},
|
|
97
|
+
"resolutions": {
|
|
98
|
+
"underscore": "1.12.1"
|
|
96
99
|
},
|
|
97
100
|
"engines": {
|
|
98
101
|
"node": ">=18.0.0"
|
|
@@ -87,7 +87,9 @@ client.setToken(token);
|
|
|
87
87
|
describe('With correct API results', () => {
|
|
88
88
|
beforeEach(() => {
|
|
89
89
|
jest.resetModules();
|
|
90
|
-
|
|
90
|
+
Object.defineProperty(global, 'fetch', {
|
|
91
|
+
value: jest.fn(() => Promise.resolve(mockedJson) as any),
|
|
92
|
+
});
|
|
91
93
|
});
|
|
92
94
|
|
|
93
95
|
describe('logIn test', () => {
|
|
@@ -135,7 +137,9 @@ describe('With correct API results', () => {
|
|
|
135
137
|
describe('With unAuthorized API results', () => {
|
|
136
138
|
beforeEach(() => {
|
|
137
139
|
jest.resetModules();
|
|
138
|
-
|
|
140
|
+
Object.defineProperty(global, 'fetch', {
|
|
141
|
+
value: jest.fn(() => Promise.resolve(mockedUnAuthorized) as any),
|
|
142
|
+
});
|
|
139
143
|
});
|
|
140
144
|
|
|
141
145
|
describe('checkLogin test', () => {
|
|
@@ -157,7 +161,9 @@ describe('With unAuthorized API results', () => {
|
|
|
157
161
|
describe('With not found API results', () => {
|
|
158
162
|
beforeEach(() => {
|
|
159
163
|
jest.resetModules();
|
|
160
|
-
|
|
164
|
+
Object.defineProperty(global, 'fetch', {
|
|
165
|
+
value: jest.fn(() => Promise.resolve(mockedNotFound) as any),
|
|
166
|
+
});
|
|
161
167
|
});
|
|
162
168
|
|
|
163
169
|
describe('fetchVoicemail test', () => {
|
|
@@ -192,7 +198,9 @@ describe('With not found API results', () => {
|
|
|
192
198
|
describe('With erroneous text API results', () => {
|
|
193
199
|
beforeEach(() => {
|
|
194
200
|
jest.resetModules();
|
|
195
|
-
|
|
201
|
+
Object.defineProperty(global, 'fetch', {
|
|
202
|
+
value: jest.fn(() => Promise.resolve(mockedTextError) as any),
|
|
203
|
+
});
|
|
196
204
|
});
|
|
197
205
|
|
|
198
206
|
it('throw an exception when the response is >= 500', async () => {
|
|
@@ -217,7 +225,9 @@ describe('With erroneous text API results', () => {
|
|
|
217
225
|
describe('With erroneous json API results', () => {
|
|
218
226
|
beforeEach(() => {
|
|
219
227
|
jest.resetModules();
|
|
220
|
-
|
|
228
|
+
Object.defineProperty(global, 'fetch', {
|
|
229
|
+
value: jest.fn(() => Promise.resolve(mockedJsonError) as any),
|
|
230
|
+
});
|
|
221
231
|
});
|
|
222
232
|
|
|
223
233
|
it('throw an exception when the response is >= 500', async () => {
|
|
@@ -24,7 +24,11 @@ describe('IssueReporter', () => {
|
|
|
24
24
|
});
|
|
25
25
|
beforeEach(() => {
|
|
26
26
|
jest.resetAllMocks();
|
|
27
|
-
|
|
27
|
+
Object.defineProperty(global, 'fetch', {
|
|
28
|
+
value: jest.fn(() => ({
|
|
29
|
+
catch: () => {},
|
|
30
|
+
})),
|
|
31
|
+
});
|
|
28
32
|
});
|
|
29
33
|
afterAll(() => {
|
|
30
34
|
console.log = oldLog;
|
|
@@ -79,12 +79,14 @@ describe('Retrieving headers', () => {
|
|
|
79
79
|
});
|
|
80
80
|
describe('Calling fetch', () => {
|
|
81
81
|
it('should call fetch without body but query string in get method', async () => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
Object.defineProperty(global, 'fetch', {
|
|
83
|
+
value: jest.fn(() => Promise.resolve({
|
|
84
|
+
json: () => Promise.resolve({}),
|
|
85
|
+
headers: {
|
|
86
|
+
get: () => '',
|
|
87
|
+
},
|
|
88
|
+
}) as any),
|
|
89
|
+
});
|
|
88
90
|
|
|
89
91
|
await new ApiRequester({
|
|
90
92
|
server,
|
|
@@ -107,17 +109,19 @@ describe('Calling fetch', () => {
|
|
|
107
109
|
describe('With a refresh token', () => {
|
|
108
110
|
it('should retry the call with a new token', async () => {
|
|
109
111
|
let calls = 0;
|
|
112
|
+
Object.defineProperty(global, 'fetch', {
|
|
113
|
+
value: jest.fn(() => {
|
|
114
|
+
calls++;
|
|
115
|
+
return Promise.resolve({
|
|
116
|
+
headers: {
|
|
117
|
+
get: () => 'application/json',
|
|
118
|
+
},
|
|
119
|
+
status: calls === 1 ? 401 : 200,
|
|
120
|
+
json: () => Promise.resolve({}),
|
|
121
|
+
} as any);
|
|
122
|
+
}),
|
|
123
|
+
});
|
|
110
124
|
|
|
111
|
-
global.fetch = jest.fn(() => {
|
|
112
|
-
calls++;
|
|
113
|
-
return Promise.resolve({
|
|
114
|
-
headers: {
|
|
115
|
-
get: () => 'application/json',
|
|
116
|
-
},
|
|
117
|
-
status: calls === 1 ? 401 : 200,
|
|
118
|
-
json: () => Promise.resolve({}),
|
|
119
|
-
});
|
|
120
|
-
}) as any;
|
|
121
125
|
const requester = new ApiRequester({
|
|
122
126
|
server,
|
|
123
127
|
agent: null,
|
package/src/web-rtc-client.ts
CHANGED