@wazo/sdk 0.40.4 → 0.40.5

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 (47) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/api/calld.js +1 -1
  3. package/esm/domain/Phone/CTIPhone.js +1 -1
  4. package/esm/domain/Phone/WebRTCPhone.js +1 -1
  5. package/esm/domain/Session.js +2 -1
  6. package/esm/simple/Auth.js +1 -0
  7. package/esm/types/api/calld.d.ts +2 -2
  8. package/esm/types/api/calld.d.ts.map +1 -1
  9. package/esm/types/domain/Phone/CTIPhone.d.ts +2 -1
  10. package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
  11. package/esm/types/domain/Phone/Phone.d.ts +2 -1
  12. package/esm/types/domain/Phone/Phone.d.ts.map +1 -1
  13. package/esm/types/domain/Phone/WebRTCPhone.d.ts +1 -1
  14. package/esm/types/domain/Session.d.ts.map +1 -1
  15. package/esm/types/simple/Auth.d.ts.map +1 -1
  16. package/esm/types/web-rtc-client.d.ts.map +1 -1
  17. package/esm/types/websocket-client.d.ts.map +1 -1
  18. package/esm/web-rtc-client.js +3 -1
  19. package/esm/websocket-client.js +4 -0
  20. package/lib/api/calld.js +1 -1
  21. package/lib/domain/Phone/CTIPhone.js +1 -1
  22. package/lib/domain/Phone/WebRTCPhone.js +1 -1
  23. package/lib/domain/Session.js +2 -1
  24. package/lib/simple/Auth.js +1 -0
  25. package/lib/types/api/calld.d.ts +2 -2
  26. package/lib/types/api/calld.d.ts.map +1 -1
  27. package/lib/types/domain/Phone/CTIPhone.d.ts +2 -1
  28. package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
  29. package/lib/types/domain/Phone/Phone.d.ts +2 -1
  30. package/lib/types/domain/Phone/Phone.d.ts.map +1 -1
  31. package/lib/types/domain/Phone/WebRTCPhone.d.ts +1 -1
  32. package/lib/types/domain/Session.d.ts.map +1 -1
  33. package/lib/types/simple/Auth.d.ts.map +1 -1
  34. package/lib/types/web-rtc-client.d.ts.map +1 -1
  35. package/lib/types/websocket-client.d.ts.map +1 -1
  36. package/lib/web-rtc-client.js +3 -1
  37. package/lib/websocket-client.js +4 -0
  38. package/package.json +7 -3
  39. package/src/api/calld.ts +4 -4
  40. package/src/domain/Phone/CTIPhone.ts +3 -2
  41. package/src/domain/Phone/Phone.ts +2 -1
  42. package/src/domain/Phone/WebRTCPhone.ts +1 -1
  43. package/src/domain/Session.ts +2 -1
  44. package/src/simple/Auth.ts +2 -0
  45. package/src/web-rtc-client.ts +3 -1
  46. package/src/websocket-client.ts +5 -0
  47. package/lib/.DS_Store +0 -0
@@ -216,6 +216,10 @@ class WebSocketClient extends Emitter_1.default {
216
216
  if (!this.socket) {
217
217
  return;
218
218
  }
219
+ if (this.socket.readyState === 3) {
220
+ logger.warn('Trying to close an already closed websocket, bailing.', { url: this._getUrl() });
221
+ return;
222
+ }
219
223
  this.socket.close();
220
224
  this.initialized = false;
221
225
  if (force) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.40.4",
3
+ "version": "0.40.5",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -20,6 +20,11 @@
20
20
  "esm/**/*",
21
21
  "lib/**/*"
22
22
  ],
23
+ "exports": {
24
+ "import": "./esm/index.js",
25
+ "node": "./dist/wazo-sdk.js",
26
+ "require": "./lib/index.js"
27
+ },
23
28
  "repository": {
24
29
  "type": "git",
25
30
  "url": "https://github.com/wazo-platform/wazo-js-sdk"
@@ -48,14 +53,13 @@
48
53
  "google-libphonenumber": "^3.2.32",
49
54
  "js-base64": "^3.7.5",
50
55
  "json-to-graphql-query": "^2.2.5",
51
- "jsrsasign": "^10.8.6",
56
+ "jsrsasign": "^11.0.0",
52
57
  "moment": "^2.29.1",
53
58
  "node-abort-controller": "^3.1.1",
54
59
  "node-fetch": "^3.3.1",
55
60
  "reconnecting-websocket": "^4.4.0",
56
61
  "sdp-transform": "^2.14.1",
57
62
  "sip.js": "^0.21.2",
58
- "user": "^0.0.0",
59
63
  "webrtc-adapter": "^8.2.3"
60
64
  },
61
65
  "devDependencies": {
package/src/api/calld.ts CHANGED
@@ -24,14 +24,14 @@ export interface CallD {
24
24
  listCalls: () => Promise<Array<Call>>;
25
25
  relocateCall: (callId: string, destination: string, lineId: number | null | undefined, contact?: string | null | undefined) => Promise<Relocation>;
26
26
  listVoicemails: () => Promise<Array<Voicemail>>;
27
- deleteVoicemail: (voicemailId: number) => Promise<boolean>;
27
+ deleteVoicemail: (voicemailId: string) => Promise<boolean>;
28
28
  getVoicemailUrl: (voicemail: Voicemail) => string;
29
29
  fetchSwitchboardHeldCalls: (switchboardUuid: UUID) => Promise<any>; // @TODO: replace `any`
30
30
  holdSwitchboardCall: (switchboardUuid: UUID, callId: string) => Promise<boolean>;
31
31
  answerSwitchboardHeldCall: (switchboardUuid: UUID, callId: string, lineId: string | null | undefined) => Promise<void>;
32
32
  fetchSwitchboardQueuedCalls: (switchboardUuid: UUID) => Promise<any>; // @TODO: replace `any`
33
33
  answerSwitchboardQueuedCall: (switchboardUuid: UUID, callId: string, lineId: string | null | undefined) => Promise<any>; // @TODO: replace `any`
34
- sendFax: (extension: string, fax: string, callerId: string | null | undefined) => Promise<void>;
34
+ sendFax: (extension: string, fax: string, callerId?: string) => Promise<void>;
35
35
  getConferenceParticipantsAsUser: (conferenceId: string) => Promise<Record<string, any>>; // @TODO: replace `any`
36
36
  getMeetingParticipantsAsUser: (meetingUuid: string) => Promise<Record<string, any>>; // @TODO: replace `any`
37
37
  banMeetingParticipant: (meetingUuid: string, participantUuid: string) => Promise<boolean>;
@@ -126,7 +126,7 @@ export default ((client: ApiRequester, baseUrl: string): CallD => ({
126
126
  },
127
127
 
128
128
  listVoicemails: (): Promise<Array<Voicemail>> => client.get(`${baseUrl}/users/me/voicemails`).then((response: any) => Voicemail.parseMany(response)),
129
- deleteVoicemail: (voicemailId: number): Promise<boolean> => client.delete(`${baseUrl}/users/me/voicemails/messages/${voicemailId}`),
129
+ deleteVoicemail: (voicemailId: string): Promise<boolean> => client.delete(`${baseUrl}/users/me/voicemails/messages/${voicemailId}`),
130
130
  getVoicemailUrl: (voicemail: Voicemail): string => {
131
131
  const body = {
132
132
  token: client.token,
@@ -138,7 +138,7 @@ export default ((client: ApiRequester, baseUrl: string): CallD => ({
138
138
  answerSwitchboardHeldCall: (switchboardUuid: UUID, callId: string, lineId: string | null | undefined = null) => client.put(`${baseUrl}/switchboards/${switchboardUuid}/calls/held/${callId}/answer${lineId ? `?line_id=${lineId}` : ''}`),
139
139
  fetchSwitchboardQueuedCalls: (switchboardUuid: UUID) => client.get(`${baseUrl}/switchboards/${switchboardUuid}/calls/queued`),
140
140
  answerSwitchboardQueuedCall: (switchboardUuid: UUID, callId: string, lineId: string | null | undefined = null) => client.put(`${baseUrl}/switchboards/${switchboardUuid}/calls/queued/${callId}/answer${lineId ? `?line_id=${lineId}` : ''}`),
141
- sendFax: (extension: string, fax: string, callerId: string | null | undefined = null) => {
141
+ sendFax: (extension: string, fax: string, callerId?: string) => {
142
142
  const headers = {
143
143
  'Content-type': 'application/pdf',
144
144
  'X-Auth-Token': client.token,
@@ -6,6 +6,7 @@ import type { Phone, AvailablePhoneOptions } from './Phone';
6
6
  import Emitter from '../../utils/Emitter';
7
7
  import CallApi from '../../service/CallApi';
8
8
  import IssueReporter from '../../service/IssueReporter';
9
+ import IndirectTransfer from '../IndirectTransfer';
9
10
 
10
11
  export const TRANSFER_FLOW_ATTENDED = 'attended';
11
12
  export const TRANSFER_FLOW_BLIND = 'blind';
@@ -187,9 +188,9 @@ export default class CTIPhone extends Emitter implements Phone {
187
188
  return Promise.resolve(false);
188
189
  }
189
190
 
190
- async initiateCTIIndirectTransfer(callSession: CallSession, number: string): Promise<any> {
191
+ async initiateCTIIndirectTransfer(callSession: CallSession, number: string): Promise<IndirectTransfer | null> {
191
192
  if (!callSession) {
192
- return;
193
+ return Promise.resolve(null);
193
194
  }
194
195
 
195
196
  logger.info('indirect CTI transfer', {
@@ -3,6 +3,7 @@ import Line from '../Line';
3
3
  import CallSession from '../CallSession';
4
4
  import type WebRTCClient from '../../web-rtc-client';
5
5
  import { IEmitter } from '../../utils/Emitter';
6
+ import IndirectTransfer from '../IndirectTransfer';
6
7
 
7
8
  export type PhoneEventCallbacks = {
8
9
  onCallIncoming?: (number: string) => void;
@@ -50,7 +51,7 @@ export interface Phone extends IEmitter {
50
51
  hasAnActiveCall(): boolean;
51
52
  hold(callSession: CallSession): Promise<any> | null | undefined;
52
53
  indirectTransfer(source: CallSession, destination: CallSession): Promise<boolean>;
53
- initiateCTIIndirectTransfer(callSession: CallSession, number: string): PhoneVoid;
54
+ initiateCTIIndirectTransfer(callSession: CallSession, number: string): Promise<IndirectTransfer | null>;
54
55
  cancelCTIIndirectTransfer(transferId: string): PhoneVoid;
55
56
  confirmCTIIndirectTransfer(transferId: string): PhoneVoid;
56
57
  hasVideo(callSession: CallSession): boolean;
@@ -1290,7 +1290,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
1290
1290
  });
1291
1291
  }
1292
1292
 
1293
- initiateCTIIndirectTransfer() {}
1293
+ initiateCTIIndirectTransfer() { return Promise.resolve(null); }
1294
1294
 
1295
1295
  cancelCTIIndirectTransfer() {}
1296
1296
 
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable no-nested-ternary */
2
2
  import { KEYUTIL, KJUR, b64utoutf8 } from 'jsrsasign';
3
+ import moment from 'moment';
3
4
  import swarmPublicKey from '../pubkey';
4
5
  import Profile from './Profile';
5
6
  import Contact from './Contact';
@@ -126,7 +127,7 @@ export default class Session {
126
127
  authorizations,
127
128
  acl: plain.data.acls ? plain.data.acls : plain.data.acl ? plain.data.acl : [],
128
129
  tenantUuid: plain.data.metadata ? plain.data.metadata.tenant_uuid : undefined,
129
- expiresAt: new Date(`${plain.data.utc_expires_at}z`),
130
+ expiresAt: moment.utc(plain.data.utc_expires_at).toDate(),
130
131
  stackUuid: plain.data.xivo_uuid,
131
132
  // eslint-disable-next-line
132
133
  stackHostFromHeader: plain._headers?.get?.('wazo-stack-host'),
@@ -372,6 +372,8 @@ class Auth {
372
372
  this.checkSubscription(session, +this.minSubscriptionType);
373
373
  }
374
374
  } catch (e: any) {
375
+ logger.error('on authenticated error', e);
376
+
375
377
  // Destroy tokens when validation fails
376
378
  if (this.clientId) {
377
379
  await getApiClient().auth.deleteRefreshToken(this.clientId);
@@ -2602,7 +2602,9 @@ export default class WebRTCClient extends Emitter {
2602
2602
 
2603
2603
  if (this.sessionNetworkStats[sessionId]) {
2604
2604
  this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
2605
- this.sessionNetworkStats[sessionId].push(networkStats);
2605
+ if (sessionId in this.sessionNetworkStats) {
2606
+ this.sessionNetworkStats[sessionId].push(networkStats);
2607
+ }
2606
2608
  }
2607
2609
  }
2608
2610
 
@@ -272,6 +272,11 @@ class WebSocketClient extends Emitter {
272
272
  return;
273
273
  }
274
274
 
275
+ if (this.socket.readyState === 3) {
276
+ logger.warn('Trying to close an already closed websocket, bailing.', { url: this._getUrl() });
277
+ return;
278
+ }
279
+
275
280
  this.socket.close();
276
281
  this.initialized = false;
277
282
 
package/lib/.DS_Store DELETED
Binary file