@wazo/sdk 0.39.15 → 0.40.0

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.
Files changed (283) hide show
  1. package/README.md +2 -2
  2. package/dist/wazo-sdk.js +12 -12
  3. package/esm/__tests__/api-client.test.js +0 -10
  4. package/esm/__tests__/web-rtc-client.test.js +2 -15
  5. package/esm/api/chatd.js +0 -1
  6. package/esm/api/dird.js +7 -10
  7. package/esm/checker/checks/ice-ipv4.js +2 -3
  8. package/esm/checker/checks/symmetric-nat.js +7 -4
  9. package/esm/domain/AdHocAPIConference.js +1 -1
  10. package/esm/domain/CallLog.js +1 -1
  11. package/esm/domain/Contact.js +2 -1
  12. package/esm/domain/MeetingAuthorization.js +6 -0
  13. package/esm/domain/Phone/CTIPhone.js +2 -0
  14. package/esm/domain/Phone/WebRTCPhone.js +16 -18
  15. package/esm/domain/Session.js +2 -2
  16. package/esm/domain/__tests__/Agent.test.js +0 -2
  17. package/esm/domain/__tests__/Call.test.js +0 -1
  18. package/esm/domain/__tests__/CallLog.test.js +0 -1
  19. package/esm/domain/__tests__/CallSession.test.js +1 -2
  20. package/esm/domain/__tests__/Contact.test.js +2 -4
  21. package/esm/domain/__tests__/IndirectTransfer.test.js +0 -1
  22. package/esm/domain/__tests__/Profile.test.js +0 -1
  23. package/esm/domain/__tests__/Room.test.js +1 -25
  24. package/esm/domain/__tests__/Session.test.js +13 -14
  25. package/esm/domain/__tests__/SipLine.test.js +2 -3
  26. package/esm/index.js +42 -88
  27. package/esm/lib/WazoSessionDescriptionHandler.js +9 -15
  28. package/esm/service/IssueReporter.js +1 -3
  29. package/esm/service/__tests__/IssueReporter.test.js +0 -1
  30. package/esm/simple/Phone.js +1 -1
  31. package/esm/simple/Websocket.js +2 -2
  32. package/esm/simple/index.js +5 -4
  33. package/esm/simple/room/Room.js +15 -15
  34. package/esm/simple/room/SipRoom.js +1 -1
  35. package/esm/simple/room/Stream.js +1 -2
  36. package/esm/simple/room/__tests__/Participant.test.js +0 -2
  37. package/esm/simple/room/__tests__/RemoteParticipant.test.js +1 -2
  38. package/esm/types/api/auth.d.ts +2 -2
  39. package/esm/types/api/auth.d.ts.map +1 -1
  40. package/esm/types/api/call-logd.d.ts +3 -3
  41. package/esm/types/api/call-logd.d.ts.map +1 -1
  42. package/esm/types/api/chatd.d.ts +9 -22
  43. package/esm/types/api/chatd.d.ts.map +1 -1
  44. package/esm/types/api/dird.d.ts +21 -14
  45. package/esm/types/api/dird.d.ts.map +1 -1
  46. package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -1
  47. package/esm/types/checker/checks/index.d.ts +1 -1
  48. package/esm/types/checker/checks/symmetric-nat.d.ts.map +1 -1
  49. package/esm/types/checker/checks/webrtc-transport.d.ts +2 -2
  50. package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -1
  51. package/esm/types/domain/Agent.d.ts +1 -1
  52. package/esm/types/domain/Agent.d.ts.map +1 -1
  53. package/esm/types/domain/CallLog.d.ts +14 -26
  54. package/esm/types/domain/CallLog.d.ts.map +1 -1
  55. package/esm/types/domain/CallSession.d.ts +3 -4
  56. package/esm/types/domain/CallSession.d.ts.map +1 -1
  57. package/esm/types/domain/Contact.d.ts +8 -0
  58. package/esm/types/domain/Contact.d.ts.map +1 -1
  59. package/esm/types/domain/MeetingAuthorization.d.ts +6 -0
  60. package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -1
  61. package/esm/types/domain/Phone/CTIPhone.d.ts +2 -0
  62. package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
  63. package/esm/types/domain/Phone/Phone.d.ts +12 -2
  64. package/esm/types/domain/Phone/Phone.d.ts.map +1 -1
  65. package/esm/types/domain/Phone/WebRTCPhone.d.ts +24 -20
  66. package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
  67. package/esm/types/domain/Room.d.ts +10 -12
  68. package/esm/types/domain/Room.d.ts.map +1 -1
  69. package/esm/types/domain/Session.d.ts +1 -1
  70. package/esm/types/domain/Session.d.ts.map +1 -1
  71. package/esm/types/domain/SipLine.d.ts +3 -3
  72. package/esm/types/domain/SipLine.d.ts.map +1 -1
  73. package/esm/types/domain/types.d.ts +64 -10
  74. package/esm/types/domain/types.d.ts.map +1 -1
  75. package/esm/types/index.d.ts +51 -314
  76. package/esm/types/index.d.ts.map +1 -1
  77. package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +5 -4
  78. package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
  79. package/esm/types/service/CallApi.d.ts +3 -3
  80. package/esm/types/service/CallApi.d.ts.map +1 -1
  81. package/esm/types/service/IssueReporter.d.ts.map +1 -1
  82. package/esm/types/simple/Auth.d.ts +0 -40
  83. package/esm/types/simple/Auth.d.ts.map +1 -1
  84. package/esm/types/simple/Phone.d.ts +0 -113
  85. package/esm/types/simple/Phone.d.ts.map +1 -1
  86. package/esm/types/simple/Websocket.d.ts +0 -16
  87. package/esm/types/simple/Websocket.d.ts.map +1 -1
  88. package/esm/types/simple/index.d.ts +8 -8
  89. package/esm/types/simple/index.d.ts.map +1 -1
  90. package/esm/types/simple/room/Participant.d.ts +4 -3
  91. package/esm/types/simple/room/Participant.d.ts.map +1 -1
  92. package/esm/types/simple/room/Room.d.ts +29 -18
  93. package/esm/types/simple/room/Room.d.ts.map +1 -1
  94. package/esm/types/simple/room/SipRoom.d.ts +1 -1
  95. package/esm/types/simple/room/SipRoom.d.ts.map +1 -1
  96. package/esm/types/simple/room/Stream.d.ts +1 -1
  97. package/esm/types/simple/room/Stream.d.ts.map +1 -1
  98. package/esm/types/utils/PhoneNumberUtil.d.ts +1 -1
  99. package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -1
  100. package/esm/types/utils/api-requester.d.ts +1 -1
  101. package/esm/types/utils/api-requester.d.ts.map +1 -1
  102. package/esm/types/utils/sdp.d.ts +20 -5
  103. package/esm/types/utils/sdp.d.ts.map +1 -1
  104. package/esm/types/web-rtc-client.d.ts +51 -49
  105. package/esm/types/web-rtc-client.d.ts.map +1 -1
  106. package/esm/types/websocket-client.d.ts.map +1 -1
  107. package/esm/utils/__tests__/PhoneNumberUtil.test.js +0 -6
  108. package/esm/utils/__tests__/api-requester.test.js +0 -2
  109. package/esm/utils/__tests__/sdp.test.js +4 -18
  110. package/esm/utils/api-requester.js +1 -2
  111. package/esm/utils/sdp.js +8 -3
  112. package/esm/web-rtc-client.js +99 -136
  113. package/esm/websocket-client.js +1 -2
  114. package/index.js +1 -0
  115. package/lib/__tests__/api-client.test.js +0 -10
  116. package/lib/__tests__/web-rtc-client.test.js +2 -15
  117. package/lib/api/chatd.js +0 -1
  118. package/lib/api/dird.js +19 -22
  119. package/lib/checker/checks/ice-ipv4.js +2 -3
  120. package/lib/checker/checks/symmetric-nat.js +7 -4
  121. package/lib/domain/AdHocAPIConference.js +1 -1
  122. package/lib/domain/CallLog.js +1 -1
  123. package/lib/domain/Contact.js +2 -1
  124. package/lib/domain/MeetingAuthorization.js +6 -0
  125. package/lib/domain/Phone/CTIPhone.js +2 -0
  126. package/lib/domain/Phone/WebRTCPhone.js +16 -18
  127. package/lib/domain/Session.js +2 -2
  128. package/lib/domain/__tests__/Agent.test.js +0 -2
  129. package/lib/domain/__tests__/Call.test.js +0 -1
  130. package/lib/domain/__tests__/CallLog.test.js +0 -1
  131. package/lib/domain/__tests__/CallSession.test.js +1 -2
  132. package/lib/domain/__tests__/Contact.test.js +2 -4
  133. package/lib/domain/__tests__/IndirectTransfer.test.js +0 -1
  134. package/lib/domain/__tests__/Profile.test.js +0 -1
  135. package/lib/domain/__tests__/Room.test.js +1 -25
  136. package/lib/domain/__tests__/Session.test.js +13 -14
  137. package/lib/domain/__tests__/SipLine.test.js +2 -3
  138. package/lib/index.js +93 -99
  139. package/lib/lib/WazoSessionDescriptionHandler.js +9 -15
  140. package/lib/service/IssueReporter.js +1 -3
  141. package/lib/service/__tests__/IssueReporter.test.js +0 -1
  142. package/lib/simple/Phone.js +1 -1
  143. package/lib/simple/Websocket.js +2 -2
  144. package/lib/simple/index.js +2 -1
  145. package/lib/simple/room/Room.js +17 -15
  146. package/lib/simple/room/SipRoom.js +1 -1
  147. package/lib/simple/room/Stream.js +1 -2
  148. package/lib/simple/room/__tests__/Participant.test.js +0 -2
  149. package/lib/simple/room/__tests__/RemoteParticipant.test.js +1 -2
  150. package/lib/types/api/auth.d.ts +2 -2
  151. package/lib/types/api/auth.d.ts.map +1 -1
  152. package/lib/types/api/call-logd.d.ts +3 -3
  153. package/lib/types/api/call-logd.d.ts.map +1 -1
  154. package/lib/types/api/chatd.d.ts +9 -22
  155. package/lib/types/api/chatd.d.ts.map +1 -1
  156. package/lib/types/api/dird.d.ts +21 -14
  157. package/lib/types/api/dird.d.ts.map +1 -1
  158. package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -1
  159. package/lib/types/checker/checks/index.d.ts +1 -1
  160. package/lib/types/checker/checks/symmetric-nat.d.ts.map +1 -1
  161. package/lib/types/checker/checks/webrtc-transport.d.ts +2 -2
  162. package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -1
  163. package/lib/types/domain/Agent.d.ts +1 -1
  164. package/lib/types/domain/Agent.d.ts.map +1 -1
  165. package/lib/types/domain/CallLog.d.ts +14 -26
  166. package/lib/types/domain/CallLog.d.ts.map +1 -1
  167. package/lib/types/domain/CallSession.d.ts +3 -4
  168. package/lib/types/domain/CallSession.d.ts.map +1 -1
  169. package/lib/types/domain/Contact.d.ts +8 -0
  170. package/lib/types/domain/Contact.d.ts.map +1 -1
  171. package/lib/types/domain/MeetingAuthorization.d.ts +6 -0
  172. package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -1
  173. package/lib/types/domain/Phone/CTIPhone.d.ts +2 -0
  174. package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
  175. package/lib/types/domain/Phone/Phone.d.ts +12 -2
  176. package/lib/types/domain/Phone/Phone.d.ts.map +1 -1
  177. package/lib/types/domain/Phone/WebRTCPhone.d.ts +24 -20
  178. package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
  179. package/lib/types/domain/Room.d.ts +10 -12
  180. package/lib/types/domain/Room.d.ts.map +1 -1
  181. package/lib/types/domain/Session.d.ts +1 -1
  182. package/lib/types/domain/Session.d.ts.map +1 -1
  183. package/lib/types/domain/SipLine.d.ts +3 -3
  184. package/lib/types/domain/SipLine.d.ts.map +1 -1
  185. package/lib/types/domain/types.d.ts +64 -10
  186. package/lib/types/domain/types.d.ts.map +1 -1
  187. package/lib/types/index.d.ts +51 -314
  188. package/lib/types/index.d.ts.map +1 -1
  189. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +5 -4
  190. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
  191. package/lib/types/service/CallApi.d.ts +3 -3
  192. package/lib/types/service/CallApi.d.ts.map +1 -1
  193. package/lib/types/service/IssueReporter.d.ts.map +1 -1
  194. package/lib/types/simple/Auth.d.ts +0 -40
  195. package/lib/types/simple/Auth.d.ts.map +1 -1
  196. package/lib/types/simple/Phone.d.ts +0 -113
  197. package/lib/types/simple/Phone.d.ts.map +1 -1
  198. package/lib/types/simple/Websocket.d.ts +0 -16
  199. package/lib/types/simple/Websocket.d.ts.map +1 -1
  200. package/lib/types/simple/index.d.ts +8 -8
  201. package/lib/types/simple/index.d.ts.map +1 -1
  202. package/lib/types/simple/room/Participant.d.ts +4 -3
  203. package/lib/types/simple/room/Participant.d.ts.map +1 -1
  204. package/lib/types/simple/room/Room.d.ts +29 -18
  205. package/lib/types/simple/room/Room.d.ts.map +1 -1
  206. package/lib/types/simple/room/SipRoom.d.ts +1 -1
  207. package/lib/types/simple/room/SipRoom.d.ts.map +1 -1
  208. package/lib/types/simple/room/Stream.d.ts +1 -1
  209. package/lib/types/simple/room/Stream.d.ts.map +1 -1
  210. package/lib/types/utils/PhoneNumberUtil.d.ts +1 -1
  211. package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -1
  212. package/lib/types/utils/api-requester.d.ts +1 -1
  213. package/lib/types/utils/api-requester.d.ts.map +1 -1
  214. package/lib/types/utils/sdp.d.ts +20 -5
  215. package/lib/types/utils/sdp.d.ts.map +1 -1
  216. package/lib/types/web-rtc-client.d.ts +51 -49
  217. package/lib/types/web-rtc-client.d.ts.map +1 -1
  218. package/lib/types/websocket-client.d.ts.map +1 -1
  219. package/lib/utils/__tests__/PhoneNumberUtil.test.js +0 -6
  220. package/lib/utils/__tests__/api-requester.test.js +0 -2
  221. package/lib/utils/__tests__/sdp.test.js +6 -18
  222. package/lib/utils/api-requester.js +2 -3
  223. package/lib/utils/sdp.js +9 -3
  224. package/lib/web-rtc-client.js +105 -140
  225. package/lib/websocket-client.js +1 -2
  226. package/package.json +5 -18
  227. package/src/__tests__/api-client.test.ts +10 -19
  228. package/src/__tests__/web-rtc-client.test.ts +13 -25
  229. package/src/api/auth.ts +2 -5
  230. package/src/api/call-logd.ts +3 -3
  231. package/src/api/chatd.ts +10 -24
  232. package/src/api/dird.ts +33 -39
  233. package/src/checker/checks/ice-ipv4.ts +4 -5
  234. package/src/checker/checks/symmetric-nat.ts +11 -7
  235. package/src/checker/checks/webrtc-transport.ts +2 -2
  236. package/src/domain/AdHocAPIConference.ts +1 -1
  237. package/src/domain/Agent.ts +1 -1
  238. package/src/domain/CallLog.ts +19 -27
  239. package/src/domain/CallSession.ts +3 -4
  240. package/src/domain/Contact.ts +3 -1
  241. package/src/domain/MeetingAuthorization.ts +13 -0
  242. package/src/domain/Phone/CTIPhone.ts +4 -0
  243. package/src/domain/Phone/Phone.ts +11 -2
  244. package/src/domain/Phone/WebRTCPhone.ts +51 -52
  245. package/src/domain/Room.ts +12 -14
  246. package/src/domain/Session.ts +3 -3
  247. package/src/domain/SipLine.ts +3 -3
  248. package/src/domain/__tests__/Agent.test.ts +3 -5
  249. package/src/domain/__tests__/Call.test.ts +4 -5
  250. package/src/domain/__tests__/CallLog.test.ts +1 -3
  251. package/src/domain/__tests__/CallSession.test.ts +10 -11
  252. package/src/domain/__tests__/Contact.test.ts +2 -4
  253. package/src/domain/__tests__/IndirectTransfer.test.ts +6 -7
  254. package/src/domain/__tests__/Profile.test.ts +3 -4
  255. package/src/domain/__tests__/Room.test.ts +27 -51
  256. package/src/domain/__tests__/Session.test.ts +27 -28
  257. package/src/domain/__tests__/SipLine.test.ts +4 -5
  258. package/src/domain/types.ts +64 -11
  259. package/src/index.ts +51 -111
  260. package/src/lib/WazoSessionDescriptionHandler.ts +24 -30
  261. package/src/service/CallApi.ts +3 -3
  262. package/src/service/IssueReporter.ts +3 -5
  263. package/src/service/__tests__/IssueReporter.test.ts +1 -2
  264. package/src/simple/Auth.ts +1 -41
  265. package/src/simple/Phone.ts +9 -116
  266. package/src/simple/Websocket.ts +4 -20
  267. package/src/simple/index.ts +8 -7
  268. package/src/simple/room/Participant.ts +4 -3
  269. package/src/simple/room/Room.ts +44 -36
  270. package/src/simple/room/SipRoom.ts +4 -4
  271. package/src/simple/room/Stream.ts +2 -3
  272. package/src/simple/room/__tests__/Participant.test.ts +2 -4
  273. package/src/simple/room/__tests__/RemoteParticipant.test.ts +4 -3
  274. package/src/types/wazo.d.ts +1 -0
  275. package/src/utils/PhoneNumberUtil.ts +1 -1
  276. package/src/utils/__tests__/PhoneNumberUtil.test.ts +0 -6
  277. package/src/utils/__tests__/api-requester.test.ts +3 -4
  278. package/src/utils/__tests__/sdp.test.ts +16 -30
  279. package/src/utils/api-requester.ts +1 -4
  280. package/src/utils/sdp.ts +38 -17
  281. package/src/web-rtc-client.ts +196 -234
  282. package/src/websocket-client.ts +2 -3
  283. package/lib/.DS_Store +0 -0
@@ -199,10 +199,9 @@ class WebSocketClient extends Emitter_1.default {
199
199
  default:
200
200
  }
201
201
  };
202
- this.socket.onerror = event => {
202
+ this.socket.onerror = (event) => {
203
203
  logger.info('Wazo WS error', {
204
204
  message: event.message,
205
- // @ts-ignore
206
205
  code: event.code,
207
206
  readyState: event.target.readyState,
208
207
  });
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.39.15",
3
+ "version": "0.40.0",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
- "main": "dist/wazo-sdk.js",
5
+ "main": "index.js",
6
+ "types": "lib/types/index.d.ts",
6
7
  "author": "Wazo (http://wazo.io)",
7
8
  "maintainers": [
8
9
  "Wazo Team <dev@wazo.io> (https://github.com/wazo-platform)"
@@ -13,6 +14,7 @@
13
14
  "license": "MIT",
14
15
  "homepage": "https://github.com/wazo-platform/wazo-js-sdk",
15
16
  "files": [
17
+ "index.js",
16
18
  "dist/*.js",
17
19
  "src/**/*",
18
20
  "esm/**/*",
@@ -39,21 +41,6 @@
39
41
  "typecheck": "./node_modules/.bin/tsc --noEmit",
40
42
  "prepublishOnly": "yarn build"
41
43
  },
42
- "exports": {
43
- ".": {
44
- "import": {
45
- "types": "./esm/types/index.d.ts",
46
- "default": "./esm/index.mjs"
47
- },
48
- "require": {
49
- "types": "./lib/types/index.d.ts",
50
- "default": "./lib/index.js"
51
- }
52
- },
53
- "./lib/": "./lib/",
54
- "./lib/simple": "./lib/simple/index.js",
55
- "./dist/wazo-sdk": "./dist/wazo-sdk.js"
56
- },
57
44
  "dependencies": {
58
45
  "events": "^3.3.0",
59
46
  "fstream": "^1.0.12",
@@ -84,7 +71,7 @@
84
71
  "@types/jest": "^29.5.2",
85
72
  "@types/jsrsasign": "^10.5.8",
86
73
  "@types/node": "^20.4.0",
87
- "@types/sdp-transform": "^2.4.6",
74
+ "@types/sdp-transform": "^2.4.9",
88
75
  "@typescript-eslint/eslint-plugin": "^5.61.0",
89
76
  "@typescript-eslint/parser": "^5.61.0",
90
77
  "babel-core": "^7.0.0-bridge.0",
@@ -88,8 +88,7 @@ client.setToken(token);
88
88
  describe('With correct API results', () => {
89
89
  beforeEach(() => {
90
90
  jest.resetModules();
91
- // @ts-expect-error
92
- global.fetch = jest.fn(() => Promise.resolve(mockedJson));
91
+ global.fetch = jest.fn(() => Promise.resolve(mockedJson)) as any;
93
92
  });
94
93
 
95
94
  describe('logIn test', () => {
@@ -102,13 +101,12 @@ describe('With correct API results', () => {
102
101
  Authorization: `Basic ${Base64.encode(`${username}:${password}`)}`,
103
102
  'Content-Type': 'application/json',
104
103
  };
105
- // @ts-expect-error
104
+
106
105
  const result = await client.auth.logIn({
107
106
  username,
108
107
  password,
109
- });
108
+ } as any) as any;
110
109
  expect(result).toBeInstanceOf(Session);
111
- // @ts-expect-error
112
110
  expect(result.token).toBe(1);
113
111
  expect(global.fetch).toBeCalledWith(`https://${server}/api/auth/${authVersion}/token`, {
114
112
  method: 'post',
@@ -123,8 +121,7 @@ describe('With correct API results', () => {
123
121
  describe('logOut test', () => {
124
122
  it('should delete the specified token', async () => {
125
123
  const oldToken = 123;
126
- // @ts-expect-error
127
- await client.auth.logOut(oldToken);
124
+ await client.auth.logOut(oldToken as any);
128
125
  expect(global.fetch).toBeCalledWith(`https://${server}/api/auth/${authVersion}/token/${oldToken}`, {
129
126
  method: 'delete',
130
127
  body: null,
@@ -139,8 +136,7 @@ describe('With correct API results', () => {
139
136
  describe('With unAuthorized API results', () => {
140
137
  beforeEach(() => {
141
138
  jest.resetModules();
142
- // @ts-expect-error
143
- global.fetch = jest.fn(() => Promise.resolve(mockedUnAuthorized));
139
+ global.fetch = jest.fn(() => Promise.resolve(mockedUnAuthorized)) as any;
144
140
  });
145
141
 
146
142
  describe('checkLogin test', () => {
@@ -162,8 +158,7 @@ describe('With unAuthorized API results', () => {
162
158
  describe('With not found API results', () => {
163
159
  beforeEach(() => {
164
160
  jest.resetModules();
165
- // @ts-expect-error
166
- global.fetch = jest.fn(() => Promise.resolve(mockedNotFound));
161
+ global.fetch = jest.fn(() => Promise.resolve(mockedNotFound)) as any;
167
162
  });
168
163
 
169
164
  describe('fetchVoicemail test', () => {
@@ -198,19 +193,17 @@ describe('With not found API results', () => {
198
193
  describe('With erroneous text API results', () => {
199
194
  beforeEach(() => {
200
195
  jest.resetModules();
201
- // @ts-expect-error
202
- global.fetch = jest.fn(() => Promise.resolve(mockedTextError));
196
+ global.fetch = jest.fn(() => Promise.resolve(mockedTextError)) as any;
203
197
  });
204
198
 
205
199
  it('throw an exception when the response is >= 500', async () => {
206
200
  let error = null;
207
201
 
208
202
  try {
209
- // @ts-expect-error
210
203
  await client.auth.logIn({
211
204
  username,
212
205
  password,
213
- });
206
+ } as any);
214
207
  } catch (e: any) {
215
208
  error = e;
216
209
  }
@@ -225,19 +218,17 @@ describe('With erroneous text API results', () => {
225
218
  describe('With erroneous json API results', () => {
226
219
  beforeEach(() => {
227
220
  jest.resetModules();
228
- // @ts-expect-error
229
- global.fetch = jest.fn(() => Promise.resolve(mockedJsonError));
221
+ global.fetch = jest.fn(() => Promise.resolve(mockedJsonError)) as any;
230
222
  });
231
223
 
232
224
  it('throw an exception when the response is >= 500', async () => {
233
225
  let error = null;
234
226
 
235
227
  try {
236
- // @ts-expect-error
237
228
  await client.auth.logIn({
238
229
  username,
239
230
  password,
240
- });
231
+ } as any);
241
232
  } catch (e: any) {
242
233
  error = e;
243
234
  }
@@ -4,18 +4,15 @@ jest.mock('sip.js/lib/platform/web/transport');
4
4
  jest.mock('sip.js/lib/api/user-agent', () => ({
5
5
  start: () => {},
6
6
  UserAgent: class UserAgent {
7
- // @ts-ignore
8
- static makeURI = () => {};
7
+ static makeURI: () => null = () => null;
9
8
 
10
- // @ts-ignore
11
9
  start = () => {};
12
10
 
13
11
  transport = {};
14
12
  },
15
13
  }));
16
14
 
17
- // @ts-expect-error
18
- const client = new WebRTCClient({});
15
+ const client = new WebRTCClient({} as any, null, undefined);
19
16
 
20
17
  describe('WebRTC client', () => {
21
18
  it('should compute muted/unmuted state', async () => {
@@ -65,14 +62,11 @@ describe('WebRTC client', () => {
65
62
  },
66
63
  },
67
64
  };
68
- // @ts-expect-error
69
- expect(client.isAudioMuted(mutedSession)).toBeTruthy();
70
- // @ts-expect-error
71
- expect(client.isAudioMuted(oldKindMuted)).toBeTruthy();
72
- // @ts-expect-error
73
- expect(client.isAudioMuted(unMutedSession)).toBeFalsy();
74
- // @ts-expect-error
75
- expect(client.isAudioMuted(oldKindUnmuted)).toBeFalsy();
65
+
66
+ expect(client.isAudioMuted(mutedSession as any)).toBeTruthy();
67
+ expect(client.isAudioMuted(oldKindMuted as any)).toBeTruthy();
68
+ expect(client.isAudioMuted(unMutedSession as any)).toBeFalsy();
69
+ expect(client.isAudioMuted(oldKindUnmuted as any)).toBeFalsy();
76
70
  });
77
71
  });
78
72
  describe('changeAudioInputDevice', () => {
@@ -131,27 +125,21 @@ describe('changeAudioInputDevice', () => {
131
125
  },
132
126
  });
133
127
  it('should change the audio input track if the provided id is different', async () => {
134
- // @ts-expect-error
135
- client.setMediaConstraints(constraints);
128
+ client.setMediaConstraints(constraints as any);
136
129
  expect(client.getAudioDeviceId()).toBe(defaultId);
137
- // @ts-expect-error
138
- const result = await client.changeAudioInputDevice(deviceId, session);
130
+ const result = await client.changeAudioInputDevice(deviceId, session as any);
139
131
  expect(result).toBeTruthy();
140
132
  });
141
133
  it('should NOT change the audio input track if the provided id is the same', async () => {
142
- // @ts-expect-error
143
- client.setMediaConstraints(constraints);
134
+ client.setMediaConstraints(constraints as any);
144
135
  expect(client.getAudioDeviceId()).toBe(defaultId);
145
- // @ts-expect-error
146
- const result = await client.changeAudioInputDevice(defaultId, session);
136
+ const result = await client.changeAudioInputDevice(defaultId, session as any);
147
137
  expect(result).toBeFalsy();
148
138
  });
149
139
  it('should change the audio input track if the provided id is the same and force param is TRUE', async () => {
150
- // @ts-expect-error
151
- client.setMediaConstraints(constraints);
140
+ client.setMediaConstraints(constraints as any);
152
141
  expect(client.getAudioDeviceId()).toBe(defaultId);
153
- // @ts-expect-error
154
- const result = await client.changeAudioInputDevice(defaultId, session, true);
142
+ const result = await client.changeAudioInputDevice(defaultId, session as any, true);
155
143
  expect(result).toBeTruthy();
156
144
  });
157
145
  describe('setVideoInputDevice', () => {
package/src/api/auth.ts CHANGED
@@ -17,8 +17,8 @@ type LoginParams = {
17
17
  };
18
18
 
19
19
  type SendResetPasswordArgs = {
20
- username: string,
21
- email: string,
20
+ username?: string,
21
+ email?: string,
22
22
  };
23
23
 
24
24
  export interface AuthD {
@@ -166,9 +166,6 @@ export default ((client: ApiRequester, baseUrl: string): AuthD => ({
166
166
  sendResetPasswordEmail: ({
167
167
  username,
168
168
  email,
169
- }: {
170
- username: string | null | undefined;
171
- email: string | null | undefined;
172
169
  }) => {
173
170
  const body: any = {};
174
171
 
@@ -2,10 +2,10 @@ import ApiRequester from '../utils/api-requester';
2
2
  import CallLog from '../domain/CallLog';
3
3
 
4
4
  export interface CallLogD {
5
- search: (search: string, limit: number) => Promise<Array<CallLog>>;
6
- searchBy: (field: string, value: string, limit: number) => Promise<Array<CallLog>>;
5
+ search: (search: string, limit?: number) => Promise<Array<CallLog>>;
6
+ searchBy: (field: string, value: string, limit?: number) => Promise<Array<CallLog>>;
7
7
  listCallLogs: (offset?: number, limit?: number) => Promise<Array<CallLog>>;
8
- listDistinctCallLogs: (offset: number, limit: number, distinct?: string) => Promise<Array<CallLog>>;
8
+ listDistinctCallLogs: (offset: number, limit?: number, distinct?: string) => Promise<Array<CallLog>>;
9
9
  listCallLogsFromDate: (from: Date, number: string) => Promise<Array<CallLog>>;
10
10
  }
11
11
 
package/src/api/chatd.ts CHANGED
@@ -1,35 +1,22 @@
1
1
  import ApiRequester from '../utils/api-requester';
2
- import type { UUID } from '../domain/types';
2
+ import type { PresenceResponse, UUID } from '../domain/types';
3
3
  import Profile from '../domain/Profile';
4
4
  import ChatRoom from '../domain/ChatRoom';
5
5
  import type { ChatUser, ChatMessageListResponse } from '../domain/ChatMessage';
6
6
  import ChatMessage from '../domain/ChatMessage';
7
7
 
8
- export type PresenceResponse = {
9
- lines: Array<{
10
- id: number;
11
- state: string;
12
- }>;
13
- sessions: Array<{
14
- mobile: boolean;
15
- uuid: string;
16
- }>;
17
- state: string;
18
- status: string;
19
- user_uuid: string;
20
- };
21
8
  type PresenceListResponse = {
22
9
  filtered: number;
23
10
  total: number;
24
11
  items: Array<PresenceResponse>;
25
12
  };
26
13
  type GetMessagesOptions = {
27
- direction: string | null | undefined;
28
- limit: number | null | undefined;
29
- order: string | null | undefined;
30
- offset: string | null | undefined;
31
- search: string | null | undefined;
32
- distinct: string | null | undefined;
14
+ direction?: string;
15
+ limit?: number;
16
+ order?: string;
17
+ offset?: string;
18
+ search?: string;
19
+ distinct?: string;
33
20
  };
34
21
 
35
22
  export interface ChatD {
@@ -43,7 +30,7 @@ export interface ChatD {
43
30
  createRoom: (name: string, users: Array<ChatUser>) => Promise<ChatRoom>;
44
31
  getRoomMessages: (roomUuid: string, params?: GetMessagesOptions) => Promise<Array<ChatMessage>>;
45
32
  sendRoomMessage: (roomUuid: string, message: ChatMessage) => Promise<ChatMessage>;
46
- getMessages: (options: GetMessagesOptions) => Promise<ChatMessage>;
33
+ getMessages: (options: GetMessagesOptions) => Promise<ChatMessageListResponse>;
47
34
  }
48
35
 
49
36
  // split contact status retrieval to avoid `414 Request-URI Too Large`.
@@ -68,9 +55,8 @@ export default ((client: ApiRequester, baseUrl: string): ChatD => ({
68
55
  const uuids: Array<UUID> = contactUuids || [];
69
56
 
70
57
  if (uuids.length > MAX_PRESENCE_FETCHED) {
71
- const requests = uuids.reduce((acc, _, i) => {
58
+ const requests = uuids.reduce((acc: Promise<PresenceResponse[]>[], _, i) => {
72
59
  if (i % MAX_PRESENCE_FETCHED === 0) {
73
- // @ts-ignore
74
60
  acc.push(this.getMultipleLineState(uuids.slice(i, i + MAX_PRESENCE_FETCHED)));
75
61
  }
76
62
  return acc;
@@ -97,5 +83,5 @@ export default ((client: ApiRequester, baseUrl: string): ChatD => ({
97
83
  return client.get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`).then((response: ChatMessageListResponse) => ChatMessage.parseMany(response));
98
84
  },
99
85
  sendRoomMessage: async (roomUuid: string, message: ChatMessage): Promise<ChatMessage> => client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
100
- getMessages: async (options: GetMessagesOptions): Promise<ChatMessage> => client.get(`${baseUrl}/users/me/rooms/messages`, options),
86
+ getMessages: async (options: GetMessagesOptions): Promise<ChatMessageListResponse> => client.get(`${baseUrl}/users/me/rooms/messages`, options),
101
87
  }));
package/src/api/dird.ts CHANGED
@@ -1,27 +1,21 @@
1
1
  import { jsonToGraphQLQuery } from 'json-to-graphql-query/lib/jsonToGraphQLQuery';
2
2
  import ApiRequester from '../utils/api-requester';
3
- import type { UUID } from '../domain/types';
4
- import Contact from '../domain/Contact';
5
- import type { NewContact } from '../domain/Contact';
6
- import type { DirectorySource, DirectorySources } from '../domain/DirectorySource';
7
- import type { Sources } from '../index';
8
- import { ContactsResponse } from '../index';
3
+ import type { PhonebookResponseItem, UUID } from '../domain/types';
4
+ import { Contact, ContactsResponse } from '../index';
5
+ import type { NewContact, DirectorySource, DirectorySources } from '../index';
9
6
 
10
7
  type PhoneBookSearchQueryParams = {
11
- order: string | null;
12
- direction: 'asc' | 'desc' | null;
13
- limit: number | null;
14
- offset: number | null;
8
+ order?: string;
9
+ direction?: 'asc' | 'desc';
10
+ limit?: number;
11
+ offset?: number;
15
12
  };
16
13
 
17
14
  const getContactPayload = (contact: NewContact | Contact) => ({
18
15
  email: contact.email,
19
- // @ts-ignore
20
- firstname: contact.firstName ? contact.firstName : '',
21
- // @ts-ignore
22
- lastname: contact.lastName ? contact.lastName : '',
23
- // @ts-ignore
24
- number: contact.phoneNumber ? contact.phoneNumber : '',
16
+ firstname: (contact as any).firstName ? (contact as any).firstName : '',
17
+ lastname: (contact as any).lastName ? (contact as any).lastName : '',
18
+ number: (contact as any).phoneNumber ? (contact as any).phoneNumber : '',
25
19
  entreprise: contact.entreprise ? contact.entreprise : '',
26
20
  birthday: contact.birthday ? contact.birthday : '',
27
21
  address: contact.address ? contact.address : '',
@@ -40,15 +34,15 @@ export interface DirD {
40
34
  markAsFavorite: (source: string, sourceId: string) => Promise<boolean>;
41
35
  removeFavorite: (source: string, sourceId: string) => Promise<void>;
42
36
  fetchOffice365Source: (context: string) => Promise<DirectorySources>;
43
- fetchOffice365Contacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]> | null | undefined;
44
- fetchWazoSource: (context: string) => Promise<Sources>;
45
- fetchSourcesFor: (context: string, backend: string) => Promise<Sources[]>;
46
- fetchWazoContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]> | null | undefined;
47
- fetchGoogleSource: (context: string) => Promise<Sources>;
48
- fetchGoogleContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]> | null | undefined;
49
- fetchConferenceSource: (context: string) => Promise<Sources>;
50
- fetchConferenceContacts: (source: DirectorySource) => Promise<Contact[]> | null | undefined;
51
- fetchPhonebookContacts: (source: DirectorySource) => Promise<object[]> | null | undefined;
37
+ fetchOffice365Contacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]> ;
38
+ fetchWazoSource: (context: string) => Promise<DirectorySources>;
39
+ fetchSourcesFor: (context: string, backend: string) => Promise<DirectorySources>;
40
+ fetchWazoContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]>;
41
+ fetchGoogleSource: (context: string) => Promise<DirectorySources>;
42
+ fetchGoogleContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams) => Promise<Contact[]>;
43
+ fetchConferenceSource: (context: string) => Promise<DirectorySources>;
44
+ fetchConferenceContacts: (source: DirectorySource) => Promise<Contact[]>;
45
+ fetchPhonebookContacts: (source: DirectorySource, params?: PhoneBookSearchQueryParams) => Promise<{ items: PhonebookResponseItem[], total: number }>;
52
46
  findMultipleContactsByNumber: (numbers: string[], fields?: Record<string, any>) => Promise<Contact[]>;
53
47
  }
54
48
 
@@ -85,48 +79,48 @@ export default ((client: ApiRequester, baseUrl: string): DirD => ({
85
79
  fetchOffice365Source: (context: string): Promise<DirectorySources> => client.get(`${baseUrl}/directories/${context}/sources`, {
86
80
  backend: 'office365',
87
81
  }),
88
- fetchOffice365Contacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]> | null | undefined => {
82
+ fetchOffice365Contacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]> => {
89
83
  if (!source) {
90
- return null;
84
+ return Promise.resolve([]);
91
85
  }
92
86
 
93
87
  return client.get(`${baseUrl}/backends/office365/sources/${source.uuid}/contacts`, queryParams).then((response: any) => Contact.parseManyOffice365(response.items, source));
94
88
  },
95
- fetchWazoSource: (context: string): Promise<Sources> => client.get(`${baseUrl}/directories/${context}/sources`, {
89
+ fetchWazoSource: (context: string): Promise<DirectorySources> => client.get(`${baseUrl}/directories/${context}/sources`, {
96
90
  backend: 'wazo',
97
91
  }),
98
92
  // Can be used with `queryParams = { uuid: uuid1, uuid2 }` to fetch multiple contacts
99
- fetchWazoContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]> | null | undefined => {
93
+ fetchWazoContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]> => {
100
94
  if (!source) {
101
- return null;
95
+ return Promise.resolve([]);
102
96
  }
103
97
 
104
98
  return client.get(`${baseUrl}/backends/wazo/sources/${source.uuid}/contacts`, queryParams).then((response: any) => Contact.parseManyWazo(response.items, source));
105
99
  },
106
- fetchGoogleSource: (context: string): Promise<Sources> => client.get(`${baseUrl}/directories/${context}/sources`, {
100
+ fetchGoogleSource: (context: string): Promise<DirectorySources> => client.get(`${baseUrl}/directories/${context}/sources`, {
107
101
  backend: 'google',
108
102
  }),
109
- fetchGoogleContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]> | null | undefined => {
103
+ fetchGoogleContacts: (source: DirectorySource, queryParams: ContactSearchQueryParams = null): Promise<Contact[]> => {
110
104
  if (!source) {
111
- return null;
105
+ return Promise.resolve([]);
112
106
  }
113
107
 
114
108
  return client.get(`${baseUrl}/backends/google/sources/${source.uuid}/contacts`, queryParams).then((response: any) => Contact.parseManyGoogle(response.items, source));
115
109
  },
116
- fetchConferenceSource: (context: string): Promise<Sources> => client.get(`${baseUrl}/directories/${context}/sources`, {
110
+ fetchConferenceSource: (context: string): Promise<DirectorySources> => client.get(`${baseUrl}/directories/${context}/sources`, {
117
111
  backend: 'conference',
118
112
  }),
119
- fetchSourcesFor: (context: string, backend: string): Promise<Sources[]> => client.get(`${baseUrl}/directories/${context}/sources`, { backend }),
120
- fetchPhonebookContacts: (source: DirectorySource, params: PhoneBookSearchQueryParams | null = null): Promise<object[]> | null | undefined => {
113
+ fetchSourcesFor: (context: string, backend: string): Promise<DirectorySources> => client.get(`${baseUrl}/directories/${context}/sources`, { backend }),
114
+ fetchPhonebookContacts: (source: DirectorySource, params?: PhoneBookSearchQueryParams): Promise<{ items: PhonebookResponseItem[], total: number }> => {
121
115
  if (!source) {
122
- return null;
116
+ return Promise.resolve({ items: [], total: 0 });
123
117
  }
124
118
 
125
119
  return client.get(`${baseUrl}/backends/phonebook/sources/${source.uuid}/contacts`, params);
126
120
  },
127
- fetchConferenceContacts: (source: DirectorySource): Promise<Contact[]> | null | undefined => {
121
+ fetchConferenceContacts: (source: DirectorySource): Promise<Contact[]> => {
128
122
  if (!source) {
129
- return null;
123
+ return Promise.resolve([]);
130
124
  }
131
125
 
132
126
  return client.get(`${baseUrl}/backends/conference/sources/${source.uuid}/contacts`).then((response: any) => Contact.parseManyConference(response.items, source));
@@ -21,11 +21,11 @@ export default {
21
21
  }
22
22
 
23
23
  const mobile = isMobile();
24
- const offerOptions: any = {
24
+ const offerOptions = {
25
25
  offerToReceiveAudio: 1,
26
26
  };
27
27
  const ips: string[] = [];
28
- const config: any = {
28
+ const config: RTCConfiguration = {
29
29
  iceServers: [{
30
30
  urls: 'stun:stun1.l.google.com:19302',
31
31
  }, {
@@ -43,7 +43,7 @@ export default {
43
43
  }
44
44
 
45
45
  if (externalAppConfig && externalAppConfig.turn_servers) {
46
- config.iceServers = [...JSON.parse(externalAppConfig.turn_servers), ...config.iceServers];
46
+ config.iceServers = [...JSON.parse(externalAppConfig.turn_servers), ...(config.iceServers || [])];
47
47
  // Force to use TURN when defined in config
48
48
  config.iceTransportPolicy = 'relay';
49
49
  }
@@ -66,8 +66,7 @@ export default {
66
66
  }
67
67
 
68
68
  if (ips.every(checkIsIPV4)) {
69
- // @ts-ignore
70
- resolve();
69
+ resolve(null);
71
70
  } else {
72
71
  const nonIPV4 = ips.find(ip => !checkIsIPV4(ip));
73
72
  reject(new Error(`Non IPv4 ice candidate found : ${nonIPV4}.`));
@@ -10,8 +10,8 @@ export default {
10
10
  return resolve('Skipped on node');
11
11
  }
12
12
 
13
- const candidates: any = {};
14
- const rawCandidates: any = [];
13
+ const candidates: Record<string, any> = {};
14
+ const rawCandidates: any[] = [];
15
15
  let nbCandidates = 0;
16
16
  const pc = new RTCPeerConnection({
17
17
  iceServers: [{
@@ -22,7 +22,7 @@ export default {
22
22
  urls: 'stun:stun2.l.google.com:19302',
23
23
  }],
24
24
  });
25
- let timeout: any;
25
+ let timeout: string | number | NodeJS.Timeout | undefined;
26
26
 
27
27
  const onEnded = () => {
28
28
  clearTimeout(timeout);
@@ -44,7 +44,7 @@ export default {
44
44
  timeout = setTimeout(onEnded, timeoutDuration);
45
45
  pc.createDataChannel('wazo-check-nat');
46
46
 
47
- pc.onicecandidate = e => {
47
+ pc.onicecandidate = (e: RTCPeerConnectionIceEvent) => {
48
48
  nbCandidates++;
49
49
 
50
50
  if (e.candidate) {
@@ -52,9 +52,13 @@ export default {
52
52
  }
53
53
 
54
54
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
55
- const cand: any = parseCandidate(e.candidate.candidate);
56
- if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
57
- candidates[cand.relatedPort].push(cand.port);
55
+ const cand = parseCandidate(e.candidate.candidate);
56
+ if (cand.relatedPort) {
57
+ if (!candidates[cand.relatedPort]) {
58
+ candidates[cand.relatedPort] = [];
59
+ }
60
+ candidates[cand.relatedPort].push(cand.port);
61
+ }
58
62
  } else if (!e.candidate) {
59
63
  onEnded();
60
64
  }
@@ -1,9 +1,9 @@
1
- import { Invitation, Inviter } from 'sip.js';
2
1
  import WebRTCClient from '../../web-rtc-client';
2
+ import { WazoSession } from '../../domain/types';
3
3
 
4
4
  export default {
5
5
  name: 'WebRTC Transport (WS) ~30s',
6
- check: (server: string, session: Inviter | Invitation): Promise<void> => new Promise((resolve, reject) => {
6
+ check: (server: string, session: WazoSession): Promise<void> => new Promise((resolve, reject) => {
7
7
  const [host, port = 443] = server.split(':');
8
8
 
9
9
  const client = new WebRTCClient({
@@ -76,7 +76,7 @@ export default class AdHocAPIConference {
76
76
 
77
77
  async start() {
78
78
  this.started = true;
79
- // @ts-ignore
79
+ // @ts-ignore: date / number
80
80
  this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
81
81
  const participantIds = Object.keys(this.participants);
82
82
  const conference = await getApiClient().calld.createAdHocConference(this.host.callId, participantIds);
@@ -8,7 +8,7 @@ export type AgentResponse = {
8
8
  paused_reason: string;
9
9
  };
10
10
 
11
- type AgentArguments = {
11
+ export type AgentArguments = {
12
12
  context: string;
13
13
  extension: string;
14
14
  id: number;