@wazo/sdk 0.38.21 → 0.39.0-beta.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/README.md +0 -293
- package/dist/wazo-sdk.js +9 -25
- package/esm/__tests__/api-client.test.js +183 -5059
- package/esm/__tests__/web-rtc-client.test.js +177 -7932
- package/esm/api/agentd.js +23 -832
- package/esm/api/amid.js +9 -411
- package/esm/api/application.js +60 -829
- package/esm/api/auth.js +164 -1213
- package/esm/api/call-logd.js +24 -733
- package/esm/api/calld.js +114 -1469
- package/esm/api/chatd.js +35 -1312
- package/esm/api/confd.js +67 -1580
- package/esm/api/ctid-ng.js +92 -1343
- package/esm/api/dird.js +100 -1590
- package/esm/api/webhookd.js +7 -513
- package/esm/api-client.js +143 -4881
- package/esm/checker/Checker.js +45 -8729
- package/esm/checker/checks/aor.js +24 -4924
- package/esm/checker/checks/api.js +70 -4968
- package/esm/checker/checks/ice-ipv4.js +63 -117
- package/esm/checker/checks/index.js +8 -8679
- package/esm/checker/checks/symmetric-nat.js +54 -102
- package/esm/checker/checks/wazo-websocket.js +34 -999
- package/esm/checker/checks/webrtc-transport.js +28 -7847
- package/esm/checker/checks/webrtc.js +31 -7854
- package/esm/domain/AdHocAPIConference.js +86 -5115
- package/esm/domain/Agent.js +27 -61
- package/esm/domain/BadResponse.js +20 -43
- package/esm/domain/Call.js +120 -210
- package/esm/domain/CallLog.js +123 -305
- package/esm/domain/CallSession.js +251 -423
- package/esm/domain/ChatMessage.js +52 -105
- package/esm/domain/ChatRoom.js +28 -60
- package/esm/domain/Contact.js +430 -741
- package/esm/domain/Country.js +17 -19
- package/esm/domain/Device/DebugDevice.js +31 -47
- package/esm/domain/Device/Device.js +1 -1
- package/esm/domain/DirectorySource.js +1 -1
- package/esm/domain/ExternalApp.js +23 -56
- package/esm/domain/Features.js +57 -5009
- package/esm/domain/ForwardOption.js +35 -70
- package/esm/domain/IndirectTransfer.js +38 -97
- package/esm/domain/Line.js +37 -88
- package/esm/domain/Meeting.js +58 -113
- package/esm/domain/MeetingAuthorization.js +38 -68
- package/esm/domain/MeetingStatus.js +13 -28
- package/esm/domain/NotificationOptions.js +43 -77
- package/esm/domain/Phone/CTIPhone.js +245 -5743
- package/esm/domain/Phone/Phone.js +1 -2
- package/esm/domain/Phone/WebRTCPhone.js +1446 -2670
- package/esm/domain/Profile.js +120 -405
- package/esm/domain/Recording.js +27 -51
- package/esm/domain/Relocation.js +16 -40
- package/esm/domain/Room.js +90 -133
- package/esm/domain/SFUNotAvailableError.js +5 -8
- package/esm/domain/ServerError.js +8 -61
- package/esm/domain/Session.js +125 -251
- package/esm/domain/SipLine.js +78 -155
- package/esm/domain/Subscription.js +39 -83
- package/esm/domain/SwitchboardCall.js +51 -143
- package/esm/domain/Voicemail.js +57 -122
- package/esm/domain/__tests__/Agent.test.js +31 -101
- package/esm/domain/__tests__/Call.test.js +24 -232
- package/esm/domain/__tests__/CallLog.test.js +60 -386
- package/esm/domain/__tests__/CallSession.test.js +74 -502
- package/esm/domain/__tests__/Contact.test.js +220 -902
- package/esm/domain/__tests__/IndirectTransfer.test.js +63 -546
- package/esm/domain/__tests__/Line.test.js +48 -156
- package/esm/domain/__tests__/Meeting.test.js +73 -226
- package/esm/domain/__tests__/MeetingAuthorization.test.js +45 -105
- package/esm/domain/__tests__/Profile.test.js +135 -496
- package/esm/domain/__tests__/Room.test.js +227 -719
- package/esm/domain/__tests__/Session.test.js +357 -1025
- package/esm/domain/__tests__/SipLine.test.js +24 -179
- package/esm/domain/__tests__/Voicemail.test.js +82 -200
- package/esm/domain/types.js +1 -1
- package/esm/index.js +63 -14987
- package/esm/lib/WazoSessionDescriptionHandler.js +406 -890
- package/esm/pubkey.js +10 -0
- package/esm/service/CallApi.js +42 -5014
- package/esm/service/IssueReporter.js +278 -360
- package/esm/service/__tests__/IssueReporter.test.js +92 -494
- package/esm/service/getApiClient.js +53 -4972
- package/esm/simple/Auth.js +211 -14749
- package/esm/simple/Configuration.js +8 -14798
- package/esm/simple/Directory.js +6 -4964
- package/esm/simple/Phone.js +309 -14729
- package/esm/simple/Websocket.js +68 -1112
- package/esm/simple/index.js +125 -14794
- package/esm/simple/room/LocalParticipant.js +1 -14799
- package/esm/simple/room/Participant.js +274 -14762
- package/esm/simple/room/RemoteParticipant.js +6 -14798
- package/esm/simple/room/Room.js +648 -14738
- package/esm/simple/room/SipRoom.js +111 -14792
- package/esm/simple/room/Stream.js +40 -14794
- package/esm/simple/room/__tests__/Participant.test.js +68 -14874
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +10 -14807
- package/esm/simple/utils.js +9 -14801
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/types/__tests__/api-client.test.d.ts +2 -0
- package/esm/types/__tests__/api-client.test.d.ts.map +1 -0
- package/esm/types/__tests__/web-rtc-client.test.d.ts +2 -0
- package/esm/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
- package/esm/types/api/agentd.d.ts +17 -0
- package/esm/types/api/agentd.d.ts.map +1 -0
- package/esm/types/api/amid.d.ts +8 -0
- package/esm/types/api/amid.d.ts.map +1 -0
- package/esm/types/api/application.d.ts +34 -0
- package/esm/types/api/application.d.ts.map +1 -0
- package/esm/types/api/auth.d.ts +64 -0
- package/esm/types/api/auth.d.ts.map +1 -0
- package/esm/types/api/call-logd.d.ts +12 -0
- package/esm/types/api/call-logd.d.ts.map +1 -0
- package/esm/types/api/calld.d.ts +51 -0
- package/esm/types/api/calld.d.ts.map +1 -0
- package/esm/types/api/chatd.d.ts +42 -0
- package/esm/types/api/chatd.d.ts.map +1 -0
- package/esm/types/api/confd.d.ts +39 -0
- package/esm/types/api/confd.d.ts.map +1 -0
- package/esm/types/api/ctid-ng.d.ts +36 -0
- package/esm/types/api/ctid-ng.d.ts.map +1 -0
- package/esm/types/api/dird.d.ts +38 -0
- package/esm/types/api/dird.d.ts.map +1 -0
- package/esm/types/api/webhookd.d.ts +24 -0
- package/esm/types/api/webhookd.d.ts.map +1 -0
- package/esm/types/api-client.d.ts +63 -0
- package/esm/types/api-client.d.ts.map +1 -0
- package/esm/types/checker/Checker.d.ts +13 -0
- package/esm/types/checker/Checker.d.ts.map +1 -0
- package/esm/types/checker/checks/aor.d.ts +6 -0
- package/esm/types/checker/checks/aor.d.ts.map +1 -0
- package/esm/types/checker/checks/api.d.ts +6 -0
- package/esm/types/checker/checks/api.d.ts.map +1 -0
- package/esm/types/checker/checks/ice-ipv4.d.ts +6 -0
- package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -0
- package/esm/types/checker/checks/index.d.ts +9 -0
- package/esm/types/checker/checks/index.d.ts.map +1 -0
- package/esm/types/checker/checks/symmetric-nat.d.ts +6 -0
- package/esm/types/checker/checks/symmetric-nat.d.ts.map +1 -0
- package/esm/types/checker/checks/wazo-websocket.d.ts +6 -0
- package/esm/types/checker/checks/wazo-websocket.d.ts.map +1 -0
- package/esm/types/checker/checks/webrtc-transport.d.ts +7 -0
- package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -0
- package/esm/types/checker/checks/webrtc.d.ts +6 -0
- package/esm/types/checker/checks/webrtc.d.ts.map +1 -0
- package/esm/types/domain/AdHocAPIConference.d.ts +54 -0
- package/esm/types/domain/AdHocAPIConference.d.ts.map +1 -0
- package/esm/types/domain/Agent.d.ts +31 -0
- package/esm/types/domain/Agent.d.ts.map +1 -0
- package/esm/types/domain/BadResponse.d.ts +11 -0
- package/esm/types/domain/BadResponse.d.ts.map +1 -0
- package/esm/types/domain/Call.d.ts +79 -0
- package/esm/types/domain/Call.d.ts.map +1 -0
- package/esm/types/domain/CallLog.d.ts +91 -0
- package/esm/types/domain/CallLog.d.ts.map +1 -0
- package/esm/types/domain/CallSession.d.ts +120 -0
- package/esm/types/domain/CallSession.d.ts.map +1 -0
- package/esm/types/domain/ChatMessage.d.ts +41 -0
- package/esm/types/domain/ChatMessage.d.ts.map +1 -0
- package/esm/types/domain/ChatRoom.d.ts +22 -0
- package/esm/types/domain/ChatRoom.d.ts.map +1 -0
- package/esm/types/domain/Contact.d.ts +316 -0
- package/esm/types/domain/Contact.d.ts.map +1 -0
- package/esm/types/domain/Country.d.ts +20 -0
- package/esm/types/domain/Country.d.ts.map +1 -0
- package/esm/types/domain/Device/DebugDevice.d.ts +14 -0
- package/esm/types/domain/Device/DebugDevice.d.ts.map +1 -0
- package/esm/types/domain/Device/Device.d.ts +13 -0
- package/esm/types/domain/Device/Device.d.ts.map +1 -0
- package/esm/types/domain/DirectorySource.d.ts +13 -0
- package/esm/types/domain/DirectorySource.d.ts.map +1 -0
- package/esm/types/domain/ExternalApp.d.ts +22 -0
- package/esm/types/domain/ExternalApp.d.ts.map +1 -0
- package/esm/types/domain/Features.d.ts +24 -0
- package/esm/types/domain/Features.d.ts.map +1 -0
- package/esm/types/domain/ForwardOption.d.ts +27 -0
- package/esm/types/domain/ForwardOption.d.ts.map +1 -0
- package/esm/types/domain/IndirectTransfer.d.ts +31 -0
- package/esm/types/domain/IndirectTransfer.d.ts.map +1 -0
- package/esm/types/domain/Line.d.ts +46 -0
- package/esm/types/domain/Line.d.ts.map +1 -0
- package/esm/types/domain/Meeting.d.ts +45 -0
- package/esm/types/domain/Meeting.d.ts.map +1 -0
- package/esm/types/domain/MeetingAuthorization.d.ts +26 -0
- package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -0
- package/esm/types/domain/MeetingStatus.d.ts +10 -0
- package/esm/types/domain/MeetingStatus.d.ts.map +1 -0
- package/esm/types/domain/NotificationOptions.d.ts +22 -0
- package/esm/types/domain/NotificationOptions.d.ts.map +1 -0
- package/esm/types/domain/Phone/CTIPhone.d.ts +76 -0
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -0
- package/esm/types/domain/Phone/Phone.d.ts +71 -0
- package/esm/types/domain/Phone/Phone.d.ts.map +1 -0
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +179 -0
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
- package/esm/types/domain/Profile.d.ts +151 -0
- package/esm/types/domain/Profile.d.ts.map +1 -0
- package/esm/types/domain/Recording.d.ts +26 -0
- package/esm/types/domain/Recording.d.ts.map +1 -0
- package/esm/types/domain/Relocation.d.ts +23 -0
- package/esm/types/domain/Relocation.d.ts.map +1 -0
- package/esm/types/domain/Room.d.ts +35 -0
- package/esm/types/domain/Room.d.ts.map +1 -0
- package/esm/types/domain/SFUNotAvailableError.d.ts +4 -0
- package/esm/types/domain/SFUNotAvailableError.d.ts.map +1 -0
- package/esm/types/domain/ServerError.d.ts +6 -0
- package/esm/types/domain/ServerError.d.ts.map +1 -0
- package/esm/types/domain/Session.d.ts +90 -0
- package/esm/types/domain/Session.d.ts.map +1 -0
- package/esm/types/domain/SipLine.d.ts +54 -0
- package/esm/types/domain/SipLine.d.ts.map +1 -0
- package/esm/types/domain/Subscription.d.ts +43 -0
- package/esm/types/domain/Subscription.d.ts.map +1 -0
- package/esm/types/domain/SwitchboardCall.d.ts +62 -0
- package/esm/types/domain/SwitchboardCall.d.ts.map +1 -0
- package/esm/types/domain/Voicemail.d.ts +50 -0
- package/esm/types/domain/Voicemail.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Agent.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Agent.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Call.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Call.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/CallLog.test.d.ts +2 -0
- package/esm/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/CallSession.test.d.ts +2 -0
- package/esm/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Contact.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Contact.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
- package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Line.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Line.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Meeting.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
- package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Profile.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Profile.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Room.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Room.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Session.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Session.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/SipLine.test.d.ts +2 -0
- package/esm/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Voicemail.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
- package/esm/types/domain/types.d.ts +217 -0
- package/esm/types/domain/types.d.ts.map +1 -0
- package/esm/types/index.d.ts +304 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
- package/esm/types/pubkey.d.ts +3 -0
- package/esm/types/pubkey.d.ts.map +1 -0
- package/esm/types/service/CallApi.d.ts +28 -0
- package/esm/types/service/CallApi.d.ts.map +1 -0
- package/esm/types/service/IssueReporter.d.ts +40 -0
- package/esm/types/service/IssueReporter.d.ts.map +1 -0
- package/esm/types/service/__tests__/IssueReporter.test.d.ts +2 -0
- package/esm/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
- package/esm/types/service/getApiClient.d.ts +16 -0
- package/esm/types/service/getApiClient.d.ts.map +1 -0
- package/esm/types/simple/Auth.d.ts +51 -0
- package/esm/types/simple/Auth.d.ts.map +1 -0
- package/esm/types/simple/Configuration.d.ts +3 -0
- package/esm/types/simple/Configuration.d.ts.map +1 -0
- package/esm/types/simple/Directory.d.ts +3 -0
- package/esm/types/simple/Directory.d.ts.map +1 -0
- package/esm/types/simple/Phone.d.ts +115 -0
- package/esm/types/simple/Phone.d.ts.map +1 -0
- package/esm/types/simple/Websocket.d.ts +19 -0
- package/esm/types/simple/Websocket.d.ts.map +1 -0
- package/esm/types/simple/index.d.ts +147 -0
- package/esm/types/simple/index.d.ts.map +1 -0
- package/esm/types/simple/room/LocalParticipant.d.ts +5 -0
- package/esm/types/simple/room/LocalParticipant.d.ts.map +1 -0
- package/esm/types/simple/room/Participant.d.ts +76 -0
- package/esm/types/simple/room/Participant.d.ts.map +1 -0
- package/esm/types/simple/room/RemoteParticipant.d.ts +7 -0
- package/esm/types/simple/room/RemoteParticipant.d.ts.map +1 -0
- package/esm/types/simple/room/Room.d.ts +116 -0
- package/esm/types/simple/room/Room.d.ts.map +1 -0
- package/esm/types/simple/room/SipRoom.d.ts +14 -0
- package/esm/types/simple/room/SipRoom.d.ts.map +1 -0
- package/esm/types/simple/room/Stream.d.ts +13 -0
- package/esm/types/simple/room/Stream.d.ts.map +1 -0
- package/esm/types/simple/room/__tests__/Participant.test.d.ts +2 -0
- package/esm/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
- package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
- package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
- package/esm/types/simple/utils.d.ts +3 -0
- package/esm/types/simple/utils.d.ts.map +1 -0
- package/esm/types/types/WebSocketMessage.d.ts +285 -0
- package/esm/types/types/WebSocketMessage.d.ts.map +1 -0
- package/esm/types/utils/Emitter.d.ts +18 -0
- package/esm/types/utils/Emitter.d.ts.map +1 -0
- package/esm/types/utils/Heartbeat.d.ts +21 -0
- package/esm/types/utils/Heartbeat.d.ts.map +1 -0
- package/esm/types/utils/PhoneNumberUtil.d.ts +8 -0
- package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -0
- package/esm/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
- package/esm/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
- package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/api-requester.test.d.ts +2 -0
- package/esm/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/array.test.d.ts +2 -0
- package/esm/types/utils/__tests__/array.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/compare-version.test.d.ts +2 -0
- package/esm/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/object.test.d.ts +2 -0
- package/esm/types/utils/__tests__/object.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/sdp.test.d.ts +2 -0
- package/esm/types/utils/__tests__/sdp.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/string.test.d.ts +2 -0
- package/esm/types/utils/__tests__/string.test.d.ts.map +1 -0
- package/esm/types/utils/api-requester.d.ts +45 -0
- package/esm/types/utils/api-requester.d.ts.map +1 -0
- package/esm/types/utils/array.d.ts +2 -0
- package/esm/types/utils/array.d.ts.map +1 -0
- package/esm/types/utils/compare-version.d.ts +3 -0
- package/esm/types/utils/compare-version.d.ts.map +1 -0
- package/esm/types/utils/isMobile.d.ts +3 -0
- package/esm/types/utils/isMobile.d.ts.map +1 -0
- package/esm/types/utils/new-from.d.ts +3 -0
- package/esm/types/utils/new-from.d.ts.map +1 -0
- package/esm/types/utils/object.d.ts +2 -0
- package/esm/types/utils/object.d.ts.map +1 -0
- package/esm/types/utils/once.d.ts +2 -0
- package/esm/types/utils/once.d.ts.map +1 -0
- package/esm/types/utils/sdp.d.ts +13 -0
- package/esm/types/utils/sdp.d.ts.map +1 -0
- package/esm/types/utils/string.d.ts +2 -0
- package/esm/types/utils/string.d.ts.map +1 -0
- package/esm/types/utils/update-from.d.ts +3 -0
- package/esm/types/utils/update-from.d.ts.map +1 -0
- package/esm/types/utils/webrtc.d.ts +15 -0
- package/esm/types/utils/webrtc.d.ts.map +1 -0
- package/esm/types/web-rtc-client.d.ts +211 -0
- package/esm/types/web-rtc-client.d.ts.map +1 -0
- package/esm/types/websocket-client.d.ts +134 -0
- package/esm/types/websocket-client.d.ts.map +1 -0
- package/esm/utils/Emitter.js +17 -27
- package/esm/utils/Heartbeat.js +60 -83
- package/esm/utils/PhoneNumberUtil.js +48 -63
- package/esm/utils/__tests__/Heartbeat.test.js +59 -168
- package/esm/utils/__tests__/PhoneNumberUtil.test.js +55 -125
- package/esm/utils/__tests__/api-requester.test.js +127 -780
- package/esm/utils/__tests__/array.test.js +16 -19
- package/esm/utils/__tests__/compare-version.test.js +8 -26
- package/esm/utils/__tests__/object.test.js +73 -54
- package/esm/utils/__tests__/sdp.test.js +87 -216
- package/esm/utils/__tests__/string.test.js +21 -27
- package/esm/utils/api-requester.js +197 -675
- package/esm/utils/array.js +7 -11
- package/esm/utils/compare-version.js +12 -15
- package/esm/utils/isMobile.js +0 -2
- package/esm/utils/new-from.js +7 -12
- package/esm/utils/object.js +9 -23
- package/esm/utils/once.js +12 -13
- package/esm/utils/sdp.js +87 -131
- package/esm/utils/string.js +5 -9
- package/esm/utils/update-from.js +9 -16
- package/esm/utils/webrtc.js +35 -36
- package/esm/web-rtc-client.js +1973 -7678
- package/esm/websocket-client.js +352 -944
- package/lib/__tests__/api-client.test.js +199 -5067
- package/lib/__tests__/web-rtc-client.test.js +191 -7943
- package/lib/api/agentd.js +27 -837
- package/lib/api/amid.js +18 -415
- package/lib/api/application.js +64 -834
- package/lib/api/auth.js +166 -1222
- package/lib/api/call-logd.js +28 -738
- package/lib/api/calld.js +126 -1473
- package/lib/api/chatd.js +49 -1316
- package/lib/api/confd.js +79 -1584
- package/lib/api/ctid-ng.js +96 -1348
- package/lib/api/dird.js +105 -1596
- package/lib/api/webhookd.js +11 -518
- package/lib/api-client.js +138 -4884
- package/lib/checker/Checker.js +61 -8741
- package/lib/checker/checks/aor.js +37 -4929
- package/lib/checker/checks/api.js +81 -4971
- package/lib/checker/checks/ice-ipv4.js +66 -118
- package/lib/checker/checks/index.js +13 -8689
- package/lib/checker/checks/symmetric-nat.js +56 -104
- package/lib/checker/checks/wazo-websocket.js +58 -1006
- package/lib/checker/checks/webrtc-transport.js +41 -7855
- package/lib/checker/checks/webrtc.js +42 -7860
- package/lib/domain/AdHocAPIConference.js +80 -5116
- package/lib/domain/Agent.js +23 -64
- package/lib/domain/BadResponse.js +17 -44
- package/lib/domain/Call.js +108 -215
- package/lib/domain/CallLog.js +117 -311
- package/lib/domain/CallSession.js +221 -424
- package/lib/domain/ChatMessage.js +49 -110
- package/lib/domain/ChatRoom.js +28 -60
- package/lib/domain/Contact.js +404 -742
- package/lib/domain/Country.js +19 -21
- package/lib/domain/Device/DebugDevice.js +34 -49
- package/lib/domain/Device/Device.js +2 -2
- package/lib/domain/DirectorySource.js +2 -2
- package/lib/domain/ExternalApp.js +24 -56
- package/lib/domain/Features.js +68 -5018
- package/lib/domain/ForwardOption.js +36 -71
- package/lib/domain/IndirectTransfer.js +39 -98
- package/lib/domain/Line.js +35 -88
- package/lib/domain/Meeting.js +51 -118
- package/lib/domain/MeetingAuthorization.js +35 -75
- package/lib/domain/MeetingStatus.js +13 -29
- package/lib/domain/NotificationOptions.js +45 -77
- package/lib/domain/Phone/CTIPhone.js +283 -5755
- package/lib/domain/Phone/Phone.js +2 -5
- package/lib/domain/Phone/WebRTCPhone.js +1446 -2715
- package/lib/domain/Profile.js +127 -406
- package/lib/domain/Recording.js +28 -57
- package/lib/domain/Relocation.js +15 -43
- package/lib/domain/Room.js +73 -134
- package/lib/domain/SFUNotAvailableError.js +7 -9
- package/lib/domain/ServerError.js +14 -63
- package/lib/domain/Session.js +118 -251
- package/lib/domain/SipLine.js +70 -155
- package/lib/domain/Subscription.js +32 -86
- package/lib/domain/SwitchboardCall.js +45 -145
- package/lib/domain/Voicemail.js +56 -127
- package/lib/domain/__tests__/Agent.test.js +36 -103
- package/lib/domain/__tests__/Call.test.js +28 -237
- package/lib/domain/__tests__/CallLog.test.js +65 -392
- package/lib/domain/__tests__/CallSession.test.js +78 -503
- package/lib/domain/__tests__/Contact.test.js +224 -903
- package/lib/domain/__tests__/IndirectTransfer.test.js +75 -546
- package/lib/domain/__tests__/Line.test.js +52 -157
- package/lib/domain/__tests__/Meeting.test.js +78 -232
- package/lib/domain/__tests__/MeetingAuthorization.test.js +50 -107
- package/lib/domain/__tests__/Profile.test.js +161 -496
- package/lib/domain/__tests__/Room.test.js +239 -719
- package/lib/domain/__tests__/Session.test.js +350 -1024
- package/lib/domain/__tests__/SipLine.test.js +28 -180
- package/lib/domain/__tests__/Voicemail.test.js +86 -205
- package/lib/domain/types.js +2 -2
- package/lib/index.js +105 -15012
- package/lib/lib/WazoSessionDescriptionHandler.js +409 -898
- package/lib/pubkey.js +12 -0
- package/lib/service/CallApi.js +88 -5015
- package/lib/service/IssueReporter.js +264 -366
- package/lib/service/__tests__/IssueReporter.test.js +97 -500
- package/lib/service/getApiClient.js +70 -4990
- package/lib/simple/Auth.js +271 -14779
- package/lib/simple/Configuration.js +23 -14807
- package/lib/simple/Directory.js +18 -4966
- package/lib/simple/Phone.js +345 -14748
- package/lib/simple/Websocket.js +98 -1117
- package/lib/simple/index.js +151 -14802
- package/lib/simple/room/LocalParticipant.js +7 -14810
- package/lib/simple/room/Participant.js +269 -14780
- package/lib/simple/room/RemoteParticipant.js +11 -14808
- package/lib/simple/room/Room.js +655 -14763
- package/lib/simple/room/SipRoom.js +136 -14807
- package/lib/simple/room/Stream.js +43 -14804
- package/lib/simple/room/__tests__/Participant.test.js +79 -14881
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +14 -14816
- package/lib/simple/utils.js +22 -14810
- package/lib/types/WebSocketMessage.js +2 -4
- package/lib/types/__tests__/api-client.test.d.ts +2 -0
- package/lib/types/__tests__/api-client.test.d.ts.map +1 -0
- package/lib/types/__tests__/web-rtc-client.test.d.ts +2 -0
- package/lib/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
- package/lib/types/api/agentd.d.ts +17 -0
- package/lib/types/api/agentd.d.ts.map +1 -0
- package/lib/types/api/amid.d.ts +8 -0
- package/lib/types/api/amid.d.ts.map +1 -0
- package/lib/types/api/application.d.ts +34 -0
- package/lib/types/api/application.d.ts.map +1 -0
- package/lib/types/api/auth.d.ts +64 -0
- package/lib/types/api/auth.d.ts.map +1 -0
- package/lib/types/api/call-logd.d.ts +12 -0
- package/lib/types/api/call-logd.d.ts.map +1 -0
- package/lib/types/api/calld.d.ts +51 -0
- package/lib/types/api/calld.d.ts.map +1 -0
- package/lib/types/api/chatd.d.ts +42 -0
- package/lib/types/api/chatd.d.ts.map +1 -0
- package/lib/types/api/confd.d.ts +39 -0
- package/lib/types/api/confd.d.ts.map +1 -0
- package/lib/types/api/ctid-ng.d.ts +36 -0
- package/lib/types/api/ctid-ng.d.ts.map +1 -0
- package/lib/types/api/dird.d.ts +38 -0
- package/lib/types/api/dird.d.ts.map +1 -0
- package/lib/types/api/webhookd.d.ts +24 -0
- package/lib/types/api/webhookd.d.ts.map +1 -0
- package/lib/types/api-client.d.ts +63 -0
- package/lib/types/api-client.d.ts.map +1 -0
- package/lib/types/checker/Checker.d.ts +13 -0
- package/lib/types/checker/Checker.d.ts.map +1 -0
- package/lib/types/checker/checks/aor.d.ts +6 -0
- package/lib/types/checker/checks/aor.d.ts.map +1 -0
- package/lib/types/checker/checks/api.d.ts +6 -0
- package/lib/types/checker/checks/api.d.ts.map +1 -0
- package/lib/types/checker/checks/ice-ipv4.d.ts +6 -0
- package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -0
- package/lib/types/checker/checks/index.d.ts +9 -0
- package/lib/types/checker/checks/index.d.ts.map +1 -0
- package/lib/types/checker/checks/symmetric-nat.d.ts +6 -0
- package/lib/types/checker/checks/symmetric-nat.d.ts.map +1 -0
- package/lib/types/checker/checks/wazo-websocket.d.ts +6 -0
- package/lib/types/checker/checks/wazo-websocket.d.ts.map +1 -0
- package/lib/types/checker/checks/webrtc-transport.d.ts +7 -0
- package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -0
- package/lib/types/checker/checks/webrtc.d.ts +6 -0
- package/lib/types/checker/checks/webrtc.d.ts.map +1 -0
- package/lib/types/domain/AdHocAPIConference.d.ts +54 -0
- package/lib/types/domain/AdHocAPIConference.d.ts.map +1 -0
- package/lib/types/domain/Agent.d.ts +31 -0
- package/lib/types/domain/Agent.d.ts.map +1 -0
- package/lib/types/domain/BadResponse.d.ts +11 -0
- package/lib/types/domain/BadResponse.d.ts.map +1 -0
- package/lib/types/domain/Call.d.ts +79 -0
- package/lib/types/domain/Call.d.ts.map +1 -0
- package/lib/types/domain/CallLog.d.ts +91 -0
- package/lib/types/domain/CallLog.d.ts.map +1 -0
- package/lib/types/domain/CallSession.d.ts +120 -0
- package/lib/types/domain/CallSession.d.ts.map +1 -0
- package/lib/types/domain/ChatMessage.d.ts +41 -0
- package/lib/types/domain/ChatMessage.d.ts.map +1 -0
- package/lib/types/domain/ChatRoom.d.ts +22 -0
- package/lib/types/domain/ChatRoom.d.ts.map +1 -0
- package/lib/types/domain/Contact.d.ts +316 -0
- package/lib/types/domain/Contact.d.ts.map +1 -0
- package/lib/types/domain/Country.d.ts +20 -0
- package/lib/types/domain/Country.d.ts.map +1 -0
- package/lib/types/domain/Device/DebugDevice.d.ts +14 -0
- package/lib/types/domain/Device/DebugDevice.d.ts.map +1 -0
- package/lib/types/domain/Device/Device.d.ts +13 -0
- package/lib/types/domain/Device/Device.d.ts.map +1 -0
- package/lib/types/domain/DirectorySource.d.ts +13 -0
- package/lib/types/domain/DirectorySource.d.ts.map +1 -0
- package/lib/types/domain/ExternalApp.d.ts +22 -0
- package/lib/types/domain/ExternalApp.d.ts.map +1 -0
- package/lib/types/domain/Features.d.ts +24 -0
- package/lib/types/domain/Features.d.ts.map +1 -0
- package/lib/types/domain/ForwardOption.d.ts +27 -0
- package/lib/types/domain/ForwardOption.d.ts.map +1 -0
- package/lib/types/domain/IndirectTransfer.d.ts +31 -0
- package/lib/types/domain/IndirectTransfer.d.ts.map +1 -0
- package/lib/types/domain/Line.d.ts +46 -0
- package/lib/types/domain/Line.d.ts.map +1 -0
- package/lib/types/domain/Meeting.d.ts +45 -0
- package/lib/types/domain/Meeting.d.ts.map +1 -0
- package/lib/types/domain/MeetingAuthorization.d.ts +26 -0
- package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -0
- package/lib/types/domain/MeetingStatus.d.ts +10 -0
- package/lib/types/domain/MeetingStatus.d.ts.map +1 -0
- package/lib/types/domain/NotificationOptions.d.ts +22 -0
- package/lib/types/domain/NotificationOptions.d.ts.map +1 -0
- package/lib/types/domain/Phone/CTIPhone.d.ts +76 -0
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -0
- package/lib/types/domain/Phone/Phone.d.ts +71 -0
- package/lib/types/domain/Phone/Phone.d.ts.map +1 -0
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +179 -0
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
- package/lib/types/domain/Profile.d.ts +151 -0
- package/lib/types/domain/Profile.d.ts.map +1 -0
- package/lib/types/domain/Recording.d.ts +26 -0
- package/lib/types/domain/Recording.d.ts.map +1 -0
- package/lib/types/domain/Relocation.d.ts +23 -0
- package/lib/types/domain/Relocation.d.ts.map +1 -0
- package/lib/types/domain/Room.d.ts +35 -0
- package/lib/types/domain/Room.d.ts.map +1 -0
- package/lib/types/domain/SFUNotAvailableError.d.ts +4 -0
- package/lib/types/domain/SFUNotAvailableError.d.ts.map +1 -0
- package/lib/types/domain/ServerError.d.ts +6 -0
- package/lib/types/domain/ServerError.d.ts.map +1 -0
- package/lib/types/domain/Session.d.ts +90 -0
- package/lib/types/domain/Session.d.ts.map +1 -0
- package/lib/types/domain/SipLine.d.ts +54 -0
- package/lib/types/domain/SipLine.d.ts.map +1 -0
- package/lib/types/domain/Subscription.d.ts +43 -0
- package/lib/types/domain/Subscription.d.ts.map +1 -0
- package/lib/types/domain/SwitchboardCall.d.ts +62 -0
- package/lib/types/domain/SwitchboardCall.d.ts.map +1 -0
- package/lib/types/domain/Voicemail.d.ts +50 -0
- package/lib/types/domain/Voicemail.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Agent.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Agent.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Call.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Call.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/CallLog.test.d.ts +2 -0
- package/lib/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/CallSession.test.d.ts +2 -0
- package/lib/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Contact.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Contact.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
- package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Line.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Line.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Meeting.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
- package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Profile.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Profile.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Room.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Room.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Session.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Session.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/SipLine.test.d.ts +2 -0
- package/lib/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Voicemail.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
- package/lib/types/domain/types.d.ts +217 -0
- package/lib/types/domain/types.d.ts.map +1 -0
- package/lib/types/index.d.ts +304 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
- package/lib/types/pubkey.d.ts +3 -0
- package/lib/types/pubkey.d.ts.map +1 -0
- package/lib/types/service/CallApi.d.ts +28 -0
- package/lib/types/service/CallApi.d.ts.map +1 -0
- package/lib/types/service/IssueReporter.d.ts +40 -0
- package/lib/types/service/IssueReporter.d.ts.map +1 -0
- package/lib/types/service/__tests__/IssueReporter.test.d.ts +2 -0
- package/lib/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
- package/lib/types/service/getApiClient.d.ts +16 -0
- package/lib/types/service/getApiClient.d.ts.map +1 -0
- package/lib/types/simple/Auth.d.ts +51 -0
- package/lib/types/simple/Auth.d.ts.map +1 -0
- package/lib/types/simple/Configuration.d.ts +3 -0
- package/lib/types/simple/Configuration.d.ts.map +1 -0
- package/lib/types/simple/Directory.d.ts +3 -0
- package/lib/types/simple/Directory.d.ts.map +1 -0
- package/lib/types/simple/Phone.d.ts +115 -0
- package/lib/types/simple/Phone.d.ts.map +1 -0
- package/lib/types/simple/Websocket.d.ts +19 -0
- package/lib/types/simple/Websocket.d.ts.map +1 -0
- package/lib/types/simple/index.d.ts +147 -0
- package/lib/types/simple/index.d.ts.map +1 -0
- package/lib/types/simple/room/LocalParticipant.d.ts +5 -0
- package/lib/types/simple/room/LocalParticipant.d.ts.map +1 -0
- package/lib/types/simple/room/Participant.d.ts +76 -0
- package/lib/types/simple/room/Participant.d.ts.map +1 -0
- package/lib/types/simple/room/RemoteParticipant.d.ts +7 -0
- package/lib/types/simple/room/RemoteParticipant.d.ts.map +1 -0
- package/lib/types/simple/room/Room.d.ts +116 -0
- package/lib/types/simple/room/Room.d.ts.map +1 -0
- package/lib/types/simple/room/SipRoom.d.ts +14 -0
- package/lib/types/simple/room/SipRoom.d.ts.map +1 -0
- package/lib/types/simple/room/Stream.d.ts +13 -0
- package/lib/types/simple/room/Stream.d.ts.map +1 -0
- package/lib/types/simple/room/__tests__/Participant.test.d.ts +2 -0
- package/lib/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
- package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
- package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
- package/lib/types/simple/utils.d.ts +3 -0
- package/lib/types/simple/utils.d.ts.map +1 -0
- package/lib/types/types/WebSocketMessage.d.ts +285 -0
- package/lib/types/types/WebSocketMessage.d.ts.map +1 -0
- package/lib/types/utils/Emitter.d.ts +18 -0
- package/lib/types/utils/Emitter.d.ts.map +1 -0
- package/lib/types/utils/Heartbeat.d.ts +21 -0
- package/lib/types/utils/Heartbeat.d.ts.map +1 -0
- package/lib/types/utils/PhoneNumberUtil.d.ts +8 -0
- package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -0
- package/lib/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
- package/lib/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
- package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/api-requester.test.d.ts +2 -0
- package/lib/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/array.test.d.ts +2 -0
- package/lib/types/utils/__tests__/array.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/compare-version.test.d.ts +2 -0
- package/lib/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/object.test.d.ts +2 -0
- package/lib/types/utils/__tests__/object.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/sdp.test.d.ts +2 -0
- package/lib/types/utils/__tests__/sdp.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/string.test.d.ts +2 -0
- package/lib/types/utils/__tests__/string.test.d.ts.map +1 -0
- package/lib/types/utils/api-requester.d.ts +45 -0
- package/lib/types/utils/api-requester.d.ts.map +1 -0
- package/lib/types/utils/array.d.ts +2 -0
- package/lib/types/utils/array.d.ts.map +1 -0
- package/lib/types/utils/compare-version.d.ts +3 -0
- package/lib/types/utils/compare-version.d.ts.map +1 -0
- package/lib/types/utils/isMobile.d.ts +3 -0
- package/lib/types/utils/isMobile.d.ts.map +1 -0
- package/lib/types/utils/new-from.d.ts +3 -0
- package/lib/types/utils/new-from.d.ts.map +1 -0
- package/lib/types/utils/object.d.ts +2 -0
- package/lib/types/utils/object.d.ts.map +1 -0
- package/lib/types/utils/once.d.ts +2 -0
- package/lib/types/utils/once.d.ts.map +1 -0
- package/lib/types/utils/sdp.d.ts +13 -0
- package/lib/types/utils/sdp.d.ts.map +1 -0
- package/lib/types/utils/string.d.ts +2 -0
- package/lib/types/utils/string.d.ts.map +1 -0
- package/lib/types/utils/update-from.d.ts +3 -0
- package/lib/types/utils/update-from.d.ts.map +1 -0
- package/lib/types/utils/webrtc.d.ts +15 -0
- package/lib/types/utils/webrtc.d.ts.map +1 -0
- package/lib/types/web-rtc-client.d.ts +211 -0
- package/lib/types/web-rtc-client.d.ts.map +1 -0
- package/lib/types/websocket-client.d.ts +134 -0
- package/lib/types/websocket-client.d.ts.map +1 -0
- package/lib/utils/Emitter.js +22 -33
- package/lib/utils/Heartbeat.js +54 -86
- package/lib/utils/PhoneNumberUtil.js +60 -77
- package/lib/utils/__tests__/Heartbeat.test.js +73 -170
- package/lib/utils/__tests__/PhoneNumberUtil.test.js +57 -131
- package/lib/utils/__tests__/api-requester.test.js +139 -784
- package/lib/utils/__tests__/array.test.js +18 -21
- package/lib/utils/__tests__/compare-version.test.js +12 -27
- package/lib/utils/__tests__/object.test.js +75 -56
- package/lib/utils/__tests__/sdp.test.js +99 -220
- package/lib/utils/__tests__/string.test.js +23 -29
- package/lib/utils/api-requester.js +191 -685
- package/lib/utils/array.js +10 -14
- package/lib/utils/compare-version.js +15 -18
- package/lib/utils/isMobile.js +3 -5
- package/lib/utils/new-from.js +9 -14
- package/lib/utils/object.js +12 -26
- package/lib/utils/once.js +15 -15
- package/lib/utils/sdp.js +97 -150
- package/lib/utils/string.js +8 -12
- package/lib/utils/update-from.js +11 -18
- package/lib/utils/webrtc.js +38 -39
- package/lib/web-rtc-client.js +1999 -7698
- package/lib/websocket-client.js +357 -1021
- package/package.json +40 -34
- package/src/__tests__/{api-client.test.js → api-client.test.ts} +71 -29
- package/src/__tests__/{web-rtc-client.test.js → web-rtc-client.test.ts} +95 -35
- package/src/api/agentd.ts +37 -0
- package/src/api/amid.ts +16 -0
- package/src/api/application.ts +96 -0
- package/src/api/auth.ts +259 -0
- package/src/api/call-logd.ts +38 -0
- package/src/api/calld.ts +183 -0
- package/src/api/chatd.ts +83 -0
- package/src/api/confd.ts +110 -0
- package/src/api/ctid-ng.ts +152 -0
- package/src/api/dird.ts +146 -0
- package/src/api/webhookd.ts +30 -0
- package/src/{api-client.js → api-client.ts} +99 -65
- package/src/checker/{Checker.js → Checker.ts} +27 -20
- package/src/checker/checks/{aor.js → aor.ts} +10 -6
- package/src/checker/checks/{api.js → api.ts} +18 -17
- package/src/checker/checks/{ice-ipv4.js → ice-ipv4.ts} +23 -26
- package/src/checker/checks/{index.js → index.ts} +1 -9
- package/src/checker/checks/{symmetric-nat.js → symmetric-nat.ts} +14 -15
- package/src/checker/checks/{wazo-websocket.js → wazo-websocket.ts} +7 -5
- package/src/checker/checks/{webrtc-transport.js → webrtc-transport.ts} +3 -2
- package/src/checker/checks/{webrtc.js → webrtc.ts} +3 -4
- package/src/domain/{AdHocAPIConference.js → AdHocAPIConference.ts} +38 -54
- package/src/domain/{Agent.js → Agent.ts} +11 -7
- package/src/domain/BadResponse.ts +29 -0
- package/src/domain/{Call.js → Call.ts} +62 -46
- package/src/domain/{CallLog.js → CallLog.ts} +61 -63
- package/src/domain/{CallSession.js → CallSession.ts} +55 -52
- package/src/domain/{ChatMessage.js → ChatMessage.ts} +32 -21
- package/src/domain/{ChatRoom.js → ChatRoom.ts} +15 -11
- package/src/domain/{Contact.js → Contact.ts} +373 -261
- package/src/domain/{Country.js → Country.ts} +0 -0
- package/src/domain/Device/{DebugDevice.js → DebugDevice.ts} +3 -5
- package/src/domain/Device/{Device.js → Device.ts} +0 -11
- package/src/domain/DirectorySource.ts +13 -0
- package/src/domain/{ExternalApp.js → ExternalApp.ts} +14 -13
- package/src/domain/{Features.js → Features.ts} +43 -17
- package/src/domain/{ForwardOption.js → ForwardOption.ts} +16 -16
- package/src/domain/{IndirectTransfer.js → IndirectTransfer.ts} +21 -19
- package/src/domain/{Line.js → Line.ts} +39 -26
- package/src/domain/{Meeting.js → Meeting.ts} +36 -29
- package/src/domain/{MeetingAuthorization.js → MeetingAuthorization.ts} +13 -12
- package/src/domain/{MeetingStatus.js → MeetingStatus.ts} +2 -6
- package/src/domain/{NotificationOptions.js → NotificationOptions.ts} +14 -13
- package/src/domain/Phone/{CTIPhone.js → CTIPhone.ts} +90 -60
- package/src/domain/Phone/{Phone.js → Phone.ts} +27 -72
- package/src/domain/Phone/{WebRTCPhone.js → WebRTCPhone.ts} +434 -413
- package/src/domain/{Profile.js → Profile.ts} +117 -100
- package/src/domain/{Recording.js → Recording.ts} +25 -16
- package/src/domain/{Relocation.js → Relocation.ts} +15 -14
- package/src/domain/{Room.js → Room.ts} +58 -27
- package/src/domain/{SFUNotAvailableError.js → SFUNotAvailableError.ts} +2 -2
- package/src/domain/ServerError.ts +12 -0
- package/src/domain/{Session.js → Session.ts} +89 -67
- package/src/domain/{SipLine.js → SipLine.ts} +52 -45
- package/src/domain/{Subscription.js → Subscription.ts} +22 -13
- package/src/domain/{SwitchboardCall.js → SwitchboardCall.ts} +48 -43
- package/src/domain/{Voicemail.js → Voicemail.ts} +38 -34
- package/src/domain/__tests__/{Agent.test.js → Agent.test.ts} +11 -19
- package/src/domain/__tests__/{Call.test.js → Call.test.ts} +12 -9
- package/src/domain/__tests__/CallLog.test.ts +65 -0
- package/src/domain/__tests__/{CallSession.test.js → CallSession.test.ts} +15 -19
- package/src/domain/__tests__/Contact.test.ts +238 -0
- package/src/domain/__tests__/{IndirectTransfer.test.js → IndirectTransfer.test.ts} +38 -31
- package/src/domain/__tests__/Line.test.ts +53 -0
- package/src/domain/__tests__/{Meeting.test.js → Meeting.test.ts} +12 -38
- package/src/domain/__tests__/{MeetingAuthorization.test.js → MeetingAuthorization.test.ts} +13 -21
- package/src/domain/__tests__/Profile.test.ts +139 -0
- package/src/domain/__tests__/{Room.test.js → Room.test.ts} +114 -76
- package/src/domain/__tests__/{Session.test.js → Session.test.ts} +137 -162
- package/src/domain/__tests__/{SipLine.test.js → SipLine.test.ts} +7 -3
- package/src/domain/__tests__/{Voicemail.test.js → Voicemail.test.ts} +26 -20
- package/src/domain/types.ts +227 -0
- package/src/global.d.ts +5 -0
- package/src/{index.js → index.ts} +4 -28
- package/src/lib/WazoSessionDescriptionHandler.ts +534 -0
- package/{config.js → src/pubkey.ts} +3 -3
- package/src/service/{CallApi.js → CallApi.ts} +14 -18
- package/src/service/{IssueReporter.js → IssueReporter.ts} +105 -56
- package/src/service/__tests__/{IssueReporter.test.js → IssueReporter.test.ts} +27 -23
- package/src/service/getApiClient.ts +94 -0
- package/src/simple/{Auth.js → Auth.ts} +127 -100
- package/src/simple/{Configuration.js → Configuration.ts} +2 -3
- package/src/simple/{Directory.js → Directory.ts} +2 -3
- package/src/simple/Phone.ts +623 -0
- package/src/simple/Websocket.ts +119 -0
- package/src/simple/{index.js → index.ts} +51 -21
- package/src/simple/room/{LocalParticipant.js → LocalParticipant.ts} +1 -3
- package/src/simple/room/{Participant.js → Participant.ts} +108 -46
- package/src/simple/room/{RemoteParticipant.js → RemoteParticipant.ts} +5 -4
- package/src/simple/room/{Room.js → Room.ts} +266 -183
- package/src/simple/room/{SipRoom.js → SipRoom.ts} +46 -29
- package/src/simple/room/{Stream.js → Stream.ts} +8 -6
- package/src/simple/room/__tests__/{Participant.test.js → Participant.test.ts} +9 -15
- package/src/simple/room/__tests__/{RemoteParticipant.test.js → RemoteParticipant.test.ts} +5 -1
- package/src/simple/utils.ts +12 -0
- package/src/types/WebSocketMessage.ts +335 -0
- package/src/types/global.d.ts +26 -0
- package/src/utils/Emitter.ts +34 -0
- package/src/utils/{Heartbeat.js → Heartbeat.ts} +17 -11
- package/src/utils/{PhoneNumberUtil.js → PhoneNumberUtil.ts} +12 -18
- package/src/utils/__tests__/{Heartbeat.test.js → Heartbeat.test.ts} +0 -15
- package/src/utils/__tests__/{PhoneNumberUtil.test.js → PhoneNumberUtil.test.ts} +6 -4
- package/src/utils/__tests__/{api-requester.test.js → api-requester.test.ts} +75 -24
- package/src/utils/__tests__/{array.test.js → array.test.ts} +10 -2
- package/src/utils/__tests__/{compare-version.test.js → compare-version.test.ts} +0 -0
- package/src/utils/__tests__/object.test.ts +77 -0
- package/src/utils/__tests__/{sdp.test.js → sdp.test.ts} +15 -37
- package/src/utils/__tests__/{string.test.js → string.test.ts} +4 -2
- package/src/utils/{api-requester.js → api-requester.ts} +104 -83
- package/src/utils/{array.js → array.ts} +2 -2
- package/src/utils/{compare-version.js → compare-version.ts} +3 -2
- package/src/utils/{isMobile.js → isMobile.ts} +1 -1
- package/src/utils/{new-from.js → new-from.ts} +3 -6
- package/src/utils/{object.js → object.ts} +3 -6
- package/src/utils/{once.js → once.ts} +5 -5
- package/src/utils/sdp.ts +119 -0
- package/src/utils/{string.js → string.ts} +2 -3
- package/src/utils/update-from.ts +11 -0
- package/src/utils/{webrtc.js → webrtc.ts} +21 -3
- package/src/{web-rtc-client.js → web-rtc-client.ts} +786 -459
- package/src/{websocket-client.js → websocket-client.ts} +146 -144
- package/esm/simple/Softphone.js +0 -394
- package/lib/simple/Softphone.js +0 -396
- package/src/api/agentd.js +0 -74
- package/src/api/amid.js +0 -13
- package/src/api/application.js +0 -137
- package/src/api/auth.js +0 -279
- package/src/api/call-logd.js +0 -20
- package/src/api/calld.js +0 -214
- package/src/api/chatd.js +0 -80
- package/src/api/confd.js +0 -127
- package/src/api/ctid-ng.js +0 -153
- package/src/api/dird.js +0 -159
- package/src/api/webhookd.js +0 -31
- package/src/domain/BadResponse.js +0 -42
- package/src/domain/DirectorySource.js +0 -16
- package/src/domain/ServerError.js +0 -18
- package/src/domain/__tests__/CallLog.test.js +0 -75
- package/src/domain/__tests__/Contact.test.js +0 -170
- package/src/domain/__tests__/Line.test.js +0 -73
- package/src/domain/__tests__/Profile.test.js +0 -104
- package/src/domain/types.js +0 -248
- package/src/lib/WazoSessionDescriptionHandler.js +0 -467
- package/src/service/getApiClient.js +0 -122
- package/src/simple/Phone.js +0 -425
- package/src/simple/Softphone.js +0 -392
- package/src/simple/Websocket.js +0 -86
- package/src/simple/utils.js +0 -17
- package/src/types/WebSocketMessage.js +0 -232
- package/src/utils/Emitter.js +0 -26
- package/src/utils/__tests__/object.test.js +0 -35
- package/src/utils/sdp.js +0 -140
- package/src/utils/update-from.js +0 -15
|
@@ -1,1047 +1,379 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
|
|
6
|
-
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
|
|
7
|
-
djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
|
|
8
|
-
ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
|
|
9
|
-
pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
|
|
10
|
-
NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
|
|
11
|
-
nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
|
|
12
|
-
BwIDAQAB
|
|
13
|
-
-----END PUBLIC KEY-----`;
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
var newFrom = (instance , ToClass ) => {
|
|
18
|
-
const args = {};
|
|
19
|
-
Object.getOwnPropertyNames(instance).forEach(prop => {
|
|
20
|
-
args[prop] = instance[prop];
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
return new ToClass(args);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
class Line {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
static parse(plain ) {
|
|
67
|
-
return new Line({
|
|
68
|
-
id: plain.id,
|
|
69
|
-
extensions: plain.extensions,
|
|
70
|
-
endpointCustom: plain.endpoint_custom || null,
|
|
71
|
-
endpointSccp: plain.endpoint_sccp || null,
|
|
72
|
-
endpointSip: plain.endpoint_sip || null,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static newFrom(profile ) {
|
|
77
|
-
return newFrom(profile, Line);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
is(line ) {
|
|
81
|
-
return line ? this.id === line.id : false;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
hasExtension(extension ) {
|
|
85
|
-
if (!this.extensions) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return this.extensions.some(ext => ext.exten === extension);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
constructor({ id, extensions, endpointCustom, endpointSccp, endpointSip } = {}) {
|
|
93
|
-
this.id = id;
|
|
94
|
-
this.extensions = extensions;
|
|
95
|
-
this.endpointCustom = endpointCustom || null;
|
|
96
|
-
this.endpointSccp = endpointSccp || null;
|
|
97
|
-
this.endpointSip = endpointSip || null;
|
|
98
|
-
|
|
99
|
-
// Useful to compare instead of instanceof with minified code
|
|
100
|
-
this.type = 'Line';
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const FORWARD_KEYS = {
|
|
112
|
-
BUSY: 'busy',
|
|
113
|
-
NO_ANSWER: 'noanswer',
|
|
114
|
-
UNCONDITIONAL: 'unconditional',
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
class ForwardOption {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
static parse(plain , key ) {
|
|
129
|
-
return new ForwardOption({
|
|
130
|
-
destination: plain.destination || '',
|
|
131
|
-
enabled: plain.enabled,
|
|
132
|
-
key,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
static newFrom(profile ) {
|
|
137
|
-
return newFrom(profile, ForwardOption);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
constructor({ destination, enabled, key } = {}) {
|
|
141
|
-
this.destination = destination;
|
|
142
|
-
this.enabled = enabled;
|
|
143
|
-
this.key = key;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
setDestination(number ) {
|
|
147
|
-
this.destination = number;
|
|
148
|
-
|
|
149
|
-
return this;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
setEnabled(enabled ) {
|
|
153
|
-
this.enabled = enabled;
|
|
154
|
-
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
is(other ) {
|
|
159
|
-
return this.key === other.key;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
const LINE_STATE = {
|
|
166
|
-
AVAILABLE: 'available',
|
|
167
|
-
HOLDING: 'holding',
|
|
168
|
-
RINGING: 'ringing',
|
|
169
|
-
TALKING: 'talking',
|
|
170
|
-
UNAVAILABLE: 'unavailable',
|
|
171
|
-
PROGRESSING: 'progressing',
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
class Profile {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
static parse(plain ) {
|
|
286
|
-
return new Profile({
|
|
287
|
-
id: plain.uuid,
|
|
288
|
-
firstName: plain.firstName || plain.firstname || '',
|
|
289
|
-
lastName: plain.lastName || plain.lastname || '',
|
|
290
|
-
email: plain.email,
|
|
291
|
-
lines: plain.lines.map(line => Line.parse(line)),
|
|
292
|
-
username: plain.username,
|
|
293
|
-
mobileNumber: plain.mobile_phone_number || '',
|
|
294
|
-
ringSeconds: plain.ring_seconds,
|
|
295
|
-
forwards: [
|
|
296
|
-
ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
|
|
297
|
-
ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
|
|
298
|
-
ForwardOption.parse(plain.forwards.busy, FORWARD_KEYS.BUSY),
|
|
299
|
-
],
|
|
300
|
-
doNotDisturb: plain.services.dnd.enabled,
|
|
301
|
-
subscriptionType: plain.subscription_type,
|
|
302
|
-
voicemail: plain.voicemail,
|
|
303
|
-
switchboards: plain.switchboards || [],
|
|
304
|
-
agent: plain.agent,
|
|
305
|
-
status: '',
|
|
306
|
-
callPickupTargetUsers: plain.call_pickup_target_users || [],
|
|
307
|
-
onlineCallRecordEnabled: plain.online_call_record_enabled,
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
static newFrom(profile ) {
|
|
312
|
-
return newFrom(profile, Profile);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
constructor({
|
|
316
|
-
id,
|
|
317
|
-
firstName,
|
|
318
|
-
lastName,
|
|
319
|
-
email,
|
|
320
|
-
lines,
|
|
321
|
-
username,
|
|
322
|
-
mobileNumber,
|
|
323
|
-
forwards,
|
|
324
|
-
doNotDisturb,
|
|
325
|
-
state,
|
|
326
|
-
subscriptionType,
|
|
327
|
-
voicemail,
|
|
328
|
-
switchboards,
|
|
329
|
-
agent,
|
|
330
|
-
status,
|
|
331
|
-
ringSeconds,
|
|
332
|
-
sipLines,
|
|
333
|
-
callPickupTargetUsers,
|
|
334
|
-
onlineCallRecordEnabled,
|
|
335
|
-
} = {}) {
|
|
336
|
-
this.id = id;
|
|
337
|
-
this.firstName = firstName;
|
|
338
|
-
this.lastName = lastName;
|
|
339
|
-
this.email = email;
|
|
340
|
-
this.lines = lines;
|
|
341
|
-
this.username = username;
|
|
342
|
-
this.mobileNumber = mobileNumber;
|
|
343
|
-
this.forwards = forwards;
|
|
344
|
-
this.doNotDisturb = doNotDisturb;
|
|
345
|
-
this.state = state;
|
|
346
|
-
this.voicemail = voicemail;
|
|
347
|
-
this.subscriptionType = subscriptionType;
|
|
348
|
-
this.switchboards = switchboards;
|
|
349
|
-
this.agent = agent;
|
|
350
|
-
this.status = status;
|
|
351
|
-
this.callPickupTargetUsers = callPickupTargetUsers;
|
|
352
|
-
this.onlineCallRecordEnabled = onlineCallRecordEnabled;
|
|
353
|
-
this.ringSeconds = ringSeconds;
|
|
354
|
-
|
|
355
|
-
this.sipLines = sipLines || [];
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
static getLinesState(lines ) {
|
|
359
|
-
let result = LINE_STATE.UNAVAILABLE;
|
|
360
|
-
|
|
361
|
-
// eslint-disable-next-line
|
|
362
|
-
for (const line of lines) {
|
|
363
|
-
if (line.state === LINE_STATE.RINGING) {
|
|
364
|
-
result = LINE_STATE.RINGING;
|
|
365
|
-
break;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if (line.state === LINE_STATE.TALKING) {
|
|
369
|
-
result = LINE_STATE.TALKING;
|
|
370
|
-
break;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
if (line.state === LINE_STATE.AVAILABLE) {
|
|
374
|
-
result = LINE_STATE.AVAILABLE;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
return result;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
hasId(id ) {
|
|
382
|
-
return id === this.id;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
setMobileNumber(number ) {
|
|
386
|
-
this.mobileNumber = number;
|
|
387
|
-
|
|
388
|
-
return this;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
setForwardOption(forwardOption ) {
|
|
392
|
-
const updatedForwardOptions = this.forwards.slice();
|
|
393
|
-
const index = updatedForwardOptions.findIndex(forward => forward.is(forwardOption));
|
|
394
|
-
updatedForwardOptions.splice(index, 1, forwardOption);
|
|
395
|
-
|
|
396
|
-
this.forwards = updatedForwardOptions;
|
|
397
|
-
|
|
398
|
-
return this;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
setDoNotDisturb(enabled ) {
|
|
402
|
-
this.doNotDisturb = enabled;
|
|
403
|
-
|
|
404
|
-
return this;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
setState(state ) {
|
|
408
|
-
this.state = state;
|
|
409
|
-
|
|
410
|
-
return this;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// Can't use `semver` package as Wazo version aren't in semver format
|
|
415
|
-
|
|
416
|
-
const compareVersions = (a, b) => {
|
|
417
|
-
let i;
|
|
418
|
-
let diff;
|
|
419
|
-
const regExStrip0 = /(\.0+)+$/;
|
|
420
|
-
const segmentsA = a.replace(regExStrip0, '').split('.');
|
|
421
|
-
const segmentsB = b.replace(regExStrip0, '').split('.');
|
|
422
|
-
const l = Math.min(segmentsA.length, segmentsB.length);
|
|
423
|
-
|
|
424
|
-
for (i = 0; i < l; i++) {
|
|
425
|
-
diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);
|
|
426
|
-
if (diff) {
|
|
427
|
-
return diff;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
return segmentsA.length - segmentsB.length;
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
//
|
|
434
|
-
|
|
435
|
-
const swarmKey = KEYUTIL.getKey(swarmPublicKey);
|
|
436
|
-
const MINIMUM_WAZO_ENGINE_VERSION_FOR_DEFAULT_CONTEXT = '19.08';
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
class Session {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
static parse(plain ) {
|
|
500
|
-
const token = plain.data.metadata ? plain.data.metadata.jwt : null;
|
|
501
|
-
let authorizations = [];
|
|
502
|
-
|
|
503
|
-
// Add authorizations from JWT
|
|
504
|
-
if (token) {
|
|
505
|
-
const isValid = jws.JWS.verifyJWT(token, swarmKey, { alg: ['RS256'], verifyAt: new Date() });
|
|
506
|
-
if (isValid) {
|
|
507
|
-
const decodedToken = jws.JWS.readSafeJSONString(b64utoutf8(token.split('.')[1]));
|
|
508
|
-
authorizations = decodedToken ? decodedToken.authorizations : [];
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
return new Session({
|
|
513
|
-
token: plain.data.token,
|
|
514
|
-
refreshToken: plain.data.refresh_token || null,
|
|
515
|
-
uuid: plain.data.metadata ? plain.data.metadata.uuid : null,
|
|
516
|
-
sessionUuid: plain.data.session_uuid,
|
|
517
|
-
authorizations,
|
|
518
|
-
acl: plain.data.acls ? plain.data.acls : plain.data.acl ? plain.data.acl : [],
|
|
519
|
-
tenantUuid: plain.data.metadata ? plain.data.metadata.tenant_uuid : undefined,
|
|
520
|
-
expiresAt: new Date(`${plain.data.utc_expires_at}z`),
|
|
521
|
-
engineUuid: plain.data.xivo_uuid,
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
static newFrom(profile ) {
|
|
526
|
-
return newFrom(profile, Session);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
constructor({
|
|
530
|
-
token,
|
|
531
|
-
uuid,
|
|
532
|
-
tenantUuid,
|
|
533
|
-
profile,
|
|
534
|
-
expiresAt,
|
|
535
|
-
authorizations,
|
|
536
|
-
acl,
|
|
537
|
-
engineVersion,
|
|
538
|
-
refreshToken,
|
|
539
|
-
sessionUuid,
|
|
540
|
-
engineUuid,
|
|
541
|
-
} = {}) {
|
|
542
|
-
this.token = token;
|
|
543
|
-
this.uuid = uuid;
|
|
544
|
-
this.tenantUuid = tenantUuid || null;
|
|
545
|
-
this.profile = profile;
|
|
546
|
-
this.expiresAt = expiresAt;
|
|
547
|
-
this.authorizations = authorizations || [];
|
|
548
|
-
this.acl = acl || [];
|
|
549
|
-
this.engineVersion = engineVersion;
|
|
550
|
-
this.refreshToken = refreshToken;
|
|
551
|
-
this.sessionUuid = sessionUuid;
|
|
552
|
-
this.engineUuid = engineUuid;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
hasExpired(date = new Date()) {
|
|
556
|
-
return date >= this.expiresAt;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
is(contact ) {
|
|
560
|
-
return Boolean(contact) && this.uuid === contact.uuid;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
using(profile ) {
|
|
564
|
-
this.profile = profile;
|
|
565
|
-
|
|
566
|
-
return this;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
hasAuthorizations() {
|
|
570
|
-
return this.authorizations && !!this.authorizations.length;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
displayName() {
|
|
574
|
-
return this.profile ? `${this.profile.firstName} ${this.profile.lastName}` : '';
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
hasAccessToVoicemail() {
|
|
578
|
-
if (!this.profile) {
|
|
579
|
-
return false;
|
|
580
|
-
}
|
|
581
|
-
return !!this.profile.voicemail;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
primaryLine() {
|
|
585
|
-
return this.profile && this.profile.lines.length > 0 ? this.profile.lines[0] : null;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
primarySipLine() {
|
|
589
|
-
return this.profile && this.profile.sipLines.length > 0 ? this.profile.sipLines[0] : null;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
primaryWebRtcLine() {
|
|
593
|
-
return this.profile && (this.profile.sipLines || []).find(sipLine => sipLine && sipLine.isWebRtc());
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
primaryCtiLine() {
|
|
597
|
-
return this.profile && (this.profile.sipLines || []).find(sipLine => sipLine && !sipLine.isWebRtc());
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
primaryContext() {
|
|
601
|
-
if (this.engineVersion) {
|
|
602
|
-
if (this.hasEngineVersionGte(MINIMUM_WAZO_ENGINE_VERSION_FOR_DEFAULT_CONTEXT)) {
|
|
603
|
-
return 'default';
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
const line = this.primaryLine();
|
|
608
|
-
|
|
609
|
-
return line && line.extensions.length > 0 ? line.extensions[0].context : 'default';
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
hasEngineVersionGte(version ) {
|
|
613
|
-
return this.engineVersion && compareVersions(String(this.engineVersion), String(version)) >= 0;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
primaryNumber() {
|
|
617
|
-
const line = this.primaryLine();
|
|
618
|
-
|
|
619
|
-
return line && line.extensions.length ? line.extensions[0].exten : null;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
allLines() {
|
|
623
|
-
return this.profile ? this.profile.lines || [] : [];
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
allNumbers() {
|
|
627
|
-
const extensions = this.allLines().map(line => line.extensions.map(extension => extension.exten));
|
|
628
|
-
if (!extensions.length) {
|
|
629
|
-
return [];
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
return extensions.reduce((a, b) => a.concat(b));
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
hasExtension(extension ) {
|
|
636
|
-
return this.allNumbers().some(number => number === extension);
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
get acls() {
|
|
640
|
-
console.warn('`acls` property of Session has been removed in Wazo\'s SDK, please use `acl` instead.');
|
|
641
|
-
return this.acl;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
//
|
|
646
|
-
|
|
1
|
+
import Session from '../Session';
|
|
2
|
+
import Profile from '../Profile';
|
|
3
|
+
import Line from '../Line';
|
|
647
4
|
describe('Session domain', () => {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
'events.config.users.me.#',
|
|
677
|
-
'events.statuses.*',
|
|
678
|
-
'events.switchboards.#',
|
|
679
|
-
'events.transfers.me',
|
|
680
|
-
'events.users.me.#',
|
|
681
|
-
'events.directory.me.#',
|
|
682
|
-
'websocketd',
|
|
683
|
-
'call-logd.users.me.cdr.read',
|
|
684
|
-
],
|
|
685
|
-
utc_expires_at: '2017-07-19T21:27:53.086990',
|
|
686
|
-
session_uuid: 'f14dd6d6-547c-434d-bd5c-e882b5b83b32',
|
|
687
|
-
xivo_uuid: '6cd695d2-cdb9-4444-8b2d-27425ab85fa8',
|
|
688
|
-
issued_at: '2017-07-19T16:27:53.086990',
|
|
689
|
-
utc_issued_at: '2017-07-19T20:27:53.086990',
|
|
690
|
-
auth_id: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
|
|
691
|
-
metadata: {
|
|
692
|
-
uuid: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
|
|
693
|
-
},
|
|
694
|
-
expires_at: '2017-07-19T17:27:53.086990',
|
|
695
|
-
xivo_user_uuid: null,
|
|
696
|
-
},
|
|
697
|
-
};
|
|
698
|
-
|
|
699
|
-
const session = Session.parse(plain);
|
|
700
|
-
|
|
701
|
-
expect(session).toEqual(
|
|
702
|
-
new Session({
|
|
703
|
-
token: 'b93ae6bd-08d7-4001-9e61-057e72bbc4b3',
|
|
704
|
-
refreshToken: null,
|
|
705
|
-
acl: [
|
|
706
|
-
'calld.lines.*.presences.read',
|
|
707
|
-
'calld.switchboards.#',
|
|
708
|
-
'calld.transfers.*.complete.update',
|
|
709
|
-
'calld.transfers.*.delete',
|
|
710
|
-
'calld.transfers.*.read',
|
|
711
|
-
'calld.users.*.presences.read',
|
|
712
|
-
'calld.users.me.#',
|
|
713
|
-
'confd.infos.read',
|
|
714
|
-
'confd.users.me.#.read',
|
|
715
|
-
'confd.users.me.forwards.*.*',
|
|
716
|
-
'confd.users.me.funckeys.*',
|
|
717
|
-
'confd.users.me.funckeys.*.*',
|
|
718
|
-
'confd.users.me.read',
|
|
719
|
-
'confd.users.me.services.*.*',
|
|
720
|
-
'confd.users.me.update',
|
|
721
|
-
'dird.#.me.read',
|
|
722
|
-
'dird.directories.favorites.#',
|
|
723
|
-
'dird.directories.lookup.*.headers.read',
|
|
724
|
-
'dird.directories.lookup.*.read',
|
|
725
|
-
'dird.directories.personal.*.read',
|
|
726
|
-
'dird.personal.#',
|
|
727
|
-
'events.calls.me',
|
|
728
|
-
'events.chat.message.*.me',
|
|
729
|
-
'events.config.users.me.#',
|
|
730
|
-
'events.statuses.*',
|
|
731
|
-
'events.switchboards.#',
|
|
732
|
-
'events.transfers.me',
|
|
733
|
-
'events.users.me.#',
|
|
734
|
-
'events.directory.me.#',
|
|
735
|
-
'websocketd',
|
|
736
|
-
'call-logd.users.me.cdr.read',
|
|
737
|
-
],
|
|
738
|
-
uuid: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
|
|
739
|
-
expiresAt: new Date('2017-07-19T21:27:53.086990z'),
|
|
740
|
-
sessionUuid: 'f14dd6d6-547c-434d-bd5c-e882b5b83b32',
|
|
741
|
-
engineUuid: '6cd695d2-cdb9-4444-8b2d-27425ab85fa8',
|
|
742
|
-
}),
|
|
743
|
-
);
|
|
744
|
-
});
|
|
745
|
-
|
|
746
|
-
describe('about voicemails', () => {
|
|
747
|
-
const A_DATE = new Date(2999, 5, 6, 14, 30, 1);
|
|
748
|
-
it('has access to voicemail given there is a voicemail configured', () => {
|
|
749
|
-
const session = new Session({
|
|
750
|
-
token: 'ref-12345',
|
|
751
|
-
uuid: '1234',
|
|
752
|
-
profile: new Profile({
|
|
753
|
-
voicemail: {
|
|
754
|
-
id: 1234,
|
|
755
|
-
name: 'inbox',
|
|
756
|
-
},
|
|
757
|
-
}),
|
|
758
|
-
expiresAt: A_DATE,
|
|
759
|
-
});
|
|
760
|
-
|
|
761
|
-
expect(session.hasAccessToVoicemail()).toBeTruthy();
|
|
5
|
+
it('can parse a plain session to domain', () => {
|
|
6
|
+
const plain = {
|
|
7
|
+
data: {
|
|
8
|
+
token: 'b93ae6bd-08d7-4001-9e61-057e72bbc4b3',
|
|
9
|
+
acl: ['calld.lines.*.presences.read', 'calld.switchboards.#', 'calld.transfers.*.complete.update', 'calld.transfers.*.delete', 'calld.transfers.*.read', 'calld.users.*.presences.read', 'calld.users.me.#', 'confd.infos.read', 'confd.users.me.#.read', 'confd.users.me.forwards.*.*', 'confd.users.me.funckeys.*', 'confd.users.me.funckeys.*.*', 'confd.users.me.read', 'confd.users.me.services.*.*', 'confd.users.me.update', 'dird.#.me.read', 'dird.directories.favorites.#', 'dird.directories.lookup.*.headers.read', 'dird.directories.lookup.*.read', 'dird.directories.personal.*.read', 'dird.personal.#', 'events.calls.me', 'events.chat.message.*.me', 'events.config.users.me.#', 'events.statuses.*', 'events.switchboards.#', 'events.transfers.me', 'events.users.me.#', 'events.directory.me.#', 'websocketd', 'call-logd.users.me.cdr.read'],
|
|
10
|
+
utc_expires_at: '2017-07-19T21:27:53.086990',
|
|
11
|
+
session_uuid: 'f14dd6d6-547c-434d-bd5c-e882b5b83b32',
|
|
12
|
+
xivo_uuid: '6cd695d2-cdb9-4444-8b2d-27425ab85fa8',
|
|
13
|
+
issued_at: '2017-07-19T16:27:53.086990',
|
|
14
|
+
utc_issued_at: '2017-07-19T20:27:53.086990',
|
|
15
|
+
auth_id: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
|
|
16
|
+
metadata: {
|
|
17
|
+
uuid: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
|
|
18
|
+
},
|
|
19
|
+
expires_at: '2017-07-19T17:27:53.086990',
|
|
20
|
+
xivo_user_uuid: null,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const session = Session.parse(plain);
|
|
24
|
+
expect(session).toEqual(new Session({
|
|
25
|
+
token: 'b93ae6bd-08d7-4001-9e61-057e72bbc4b3',
|
|
26
|
+
refreshToken: null,
|
|
27
|
+
acl: ['calld.lines.*.presences.read', 'calld.switchboards.#', 'calld.transfers.*.complete.update', 'calld.transfers.*.delete', 'calld.transfers.*.read', 'calld.users.*.presences.read', 'calld.users.me.#', 'confd.infos.read', 'confd.users.me.#.read', 'confd.users.me.forwards.*.*', 'confd.users.me.funckeys.*', 'confd.users.me.funckeys.*.*', 'confd.users.me.read', 'confd.users.me.services.*.*', 'confd.users.me.update', 'dird.#.me.read', 'dird.directories.favorites.#', 'dird.directories.lookup.*.headers.read', 'dird.directories.lookup.*.read', 'dird.directories.personal.*.read', 'dird.personal.#', 'events.calls.me', 'events.chat.message.*.me', 'events.config.users.me.#', 'events.statuses.*', 'events.switchboards.#', 'events.transfers.me', 'events.users.me.#', 'events.directory.me.#', 'websocketd', 'call-logd.users.me.cdr.read'],
|
|
28
|
+
uuid: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
|
|
29
|
+
expiresAt: new Date('2017-07-19T21:27:53.086990z'),
|
|
30
|
+
sessionUuid: 'f14dd6d6-547c-434d-bd5c-e882b5b83b32',
|
|
31
|
+
engineUuid: '6cd695d2-cdb9-4444-8b2d-27425ab85fa8',
|
|
32
|
+
}));
|
|
762
33
|
});
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
expect(session.allNumbers().length).toBeGreaterThan(1);
|
|
780
|
-
});
|
|
781
|
-
});
|
|
782
|
-
describe('and the user has one line', () => {
|
|
783
|
-
it('should return only one extension', () => {
|
|
784
|
-
const session = new Session({
|
|
785
|
-
token: 'ref-12345',
|
|
786
|
-
uuid: '1234',
|
|
787
|
-
profile: new Profile({
|
|
788
|
-
lines: [new Line({ id: 9012, extensions: [{ id: 1, exten: '8000', context: 'default' }] })],
|
|
789
|
-
}),
|
|
790
|
-
expiresAt: A_DATE,
|
|
791
|
-
});
|
|
792
|
-
|
|
793
|
-
expect(session.allNumbers().length).toEqual(1);
|
|
34
|
+
describe('about voicemails', () => {
|
|
35
|
+
const A_DATE = new Date(2999, 5, 6, 14, 30, 1);
|
|
36
|
+
it('has access to voicemail given there is a voicemail configured', () => {
|
|
37
|
+
const session = new Session({
|
|
38
|
+
token: 'ref-12345',
|
|
39
|
+
uuid: '1234',
|
|
40
|
+
// @ts-expect-error
|
|
41
|
+
profile: new Profile({
|
|
42
|
+
voicemail: {
|
|
43
|
+
id: 1234,
|
|
44
|
+
name: 'inbox',
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
expiresAt: A_DATE,
|
|
48
|
+
});
|
|
49
|
+
expect(session.hasAccessToVoicemail()).toBeTruthy();
|
|
794
50
|
});
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
});
|
|
846
|
-
|
|
847
|
-
it('session should not be expired given date is before expiration', () => {
|
|
848
|
-
const session = new Session({
|
|
849
|
-
token: 'ref-12345',
|
|
850
|
-
uuid: '1234',
|
|
851
|
-
expiresAt: EXPIRATION_DATE,
|
|
852
|
-
});
|
|
853
|
-
const currentDate = new Date(2006, 5, 6, 14, 29, 0);
|
|
854
|
-
|
|
855
|
-
expect(session.hasExpired(currentDate)).toBeFalsy();
|
|
856
|
-
});
|
|
857
|
-
});
|
|
858
|
-
|
|
859
|
-
describe('when checking if session has a specific extension', () => {
|
|
860
|
-
const session = new Session({
|
|
861
|
-
token: 'ref-12345',
|
|
862
|
-
uuid: '1234',
|
|
863
|
-
profile: new Profile({
|
|
864
|
-
lines: [
|
|
865
|
-
new Line({ id: 9012, extensions: [{ id: 1, exten: '8000', context: 'default' }] }),
|
|
866
|
-
new Line({ id: 3421, extensions: [{ id: 2, exten: '9980', context: 'internal' }] }),
|
|
867
|
-
],
|
|
868
|
-
}),
|
|
869
|
-
expiresAt: new Date(9999, 0, 1),
|
|
870
|
-
});
|
|
871
|
-
|
|
872
|
-
it('should return true given it owns the extension', () => {
|
|
873
|
-
expect(session.hasExtension('8000')).toBeTruthy();
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
it("should return true given it owns the extension even if it's not the default one", () => {
|
|
877
|
-
expect(session.hasExtension('9980')).toBeTruthy();
|
|
878
|
-
});
|
|
879
|
-
|
|
880
|
-
it("should return false given it does't own the extension", () => {
|
|
881
|
-
expect(session.hasExtension('12')).toBeFalsy();
|
|
882
|
-
});
|
|
883
|
-
});
|
|
884
|
-
|
|
885
|
-
describe('when getting the primary context', () => {
|
|
886
|
-
const DEFAULT_CONTEXT = 'default';
|
|
887
|
-
const SOME_CONTEXT = 'some-context';
|
|
888
|
-
|
|
889
|
-
let A_SESSION;
|
|
890
|
-
|
|
891
|
-
beforeEach(() => {
|
|
892
|
-
A_SESSION = new Session({
|
|
893
|
-
token: 'ref-12345',
|
|
894
|
-
uuid: '1234',
|
|
895
|
-
expiresAt: new Date(9999, 0, 1),
|
|
896
|
-
engineVersion: null,
|
|
897
|
-
});
|
|
898
|
-
});
|
|
899
|
-
|
|
900
|
-
describe('given NO engine version', () => {
|
|
901
|
-
beforeEach(() => {
|
|
902
|
-
A_SESSION = new Session({ ...A_SESSION, engineVersion: null });
|
|
903
|
-
});
|
|
904
|
-
|
|
905
|
-
describe('and NO profile', () => {
|
|
906
|
-
beforeEach(() => {
|
|
907
|
-
A_SESSION = new Session({ ...A_SESSION, profile: null });
|
|
51
|
+
describe('When getting all numbers', () => {
|
|
52
|
+
describe('and the user has multiple lines', () => {
|
|
53
|
+
it('should return multiple extensions', () => {
|
|
54
|
+
const session = new Session({
|
|
55
|
+
token: 'ref-12345',
|
|
56
|
+
uuid: '1234',
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
profile: new Profile({
|
|
59
|
+
lines: [new Line({
|
|
60
|
+
id: 9012,
|
|
61
|
+
extensions: [{
|
|
62
|
+
id: 1,
|
|
63
|
+
exten: '8000',
|
|
64
|
+
context: 'default',
|
|
65
|
+
}],
|
|
66
|
+
}), new Line({
|
|
67
|
+
id: 3421,
|
|
68
|
+
extensions: [{
|
|
69
|
+
id: 2,
|
|
70
|
+
exten: '9980',
|
|
71
|
+
context: 'internal',
|
|
72
|
+
}],
|
|
73
|
+
})],
|
|
74
|
+
}),
|
|
75
|
+
expiresAt: A_DATE,
|
|
76
|
+
});
|
|
77
|
+
expect(session.allNumbers().length).toBeGreaterThan(1);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('and the user has one line', () => {
|
|
81
|
+
it('should return only one extension', () => {
|
|
82
|
+
const session = new Session({
|
|
83
|
+
token: 'ref-12345',
|
|
84
|
+
uuid: '1234',
|
|
85
|
+
// @ts-expect-error
|
|
86
|
+
profile: new Profile({
|
|
87
|
+
lines: [new Line({
|
|
88
|
+
id: 9012,
|
|
89
|
+
extensions: [{
|
|
90
|
+
id: 1,
|
|
91
|
+
exten: '8000',
|
|
92
|
+
context: 'default',
|
|
93
|
+
}],
|
|
94
|
+
})],
|
|
95
|
+
}),
|
|
96
|
+
expiresAt: A_DATE,
|
|
97
|
+
});
|
|
98
|
+
expect(session.allNumbers().length).toEqual(1);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
908
101
|
});
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
102
|
+
it('does not have access to voicemail given there is no voicemail configured', () => {
|
|
103
|
+
const session = new Session({
|
|
104
|
+
token: 'ref-12345',
|
|
105
|
+
uuid: '1234',
|
|
106
|
+
// @ts-expect-error
|
|
107
|
+
profile: new Profile({
|
|
108
|
+
voicemail: undefined,
|
|
109
|
+
}),
|
|
110
|
+
expiresAt: A_DATE,
|
|
111
|
+
});
|
|
112
|
+
expect(session.hasAccessToVoicemail()).toBeFalsy();
|
|
914
113
|
});
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
114
|
+
it('does not have access to voicemail given there is no profile', () => {
|
|
115
|
+
const session = new Session({
|
|
116
|
+
token: 'ref-12345',
|
|
117
|
+
uuid: '1234',
|
|
118
|
+
expiresAt: A_DATE,
|
|
119
|
+
});
|
|
120
|
+
expect(session.hasAccessToVoicemail()).toBeFalsy();
|
|
920
121
|
});
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
122
|
+
});
|
|
123
|
+
describe('Session expiration', () => {
|
|
124
|
+
const EXPIRATION_DATE = new Date(2006, 5, 6, 14, 30, 1);
|
|
125
|
+
it('session should be expired given date is equal to expiration date', () => {
|
|
126
|
+
const session = new Session({
|
|
127
|
+
token: 'ref-12345',
|
|
128
|
+
uuid: '1234',
|
|
129
|
+
expiresAt: EXPIRATION_DATE,
|
|
130
|
+
});
|
|
131
|
+
const currentDate = new Date(2006, 5, 6, 14, 30, 1);
|
|
132
|
+
expect(session.hasExpired(currentDate)).toBeTruthy();
|
|
926
133
|
});
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
134
|
+
it('session should be expired given date is after expiration', () => {
|
|
135
|
+
const session = new Session({
|
|
136
|
+
token: 'ref-12345',
|
|
137
|
+
uuid: '1234',
|
|
138
|
+
expiresAt: EXPIRATION_DATE,
|
|
139
|
+
});
|
|
140
|
+
const currentDate = new Date(2006, 5, 6, 14, 32, 0);
|
|
141
|
+
expect(session.hasExpired(currentDate)).toBeTruthy();
|
|
934
142
|
});
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
143
|
+
it('session should not be expired given date is before expiration', () => {
|
|
144
|
+
const session = new Session({
|
|
145
|
+
token: 'ref-12345',
|
|
146
|
+
uuid: '1234',
|
|
147
|
+
expiresAt: EXPIRATION_DATE,
|
|
148
|
+
});
|
|
149
|
+
const currentDate = new Date(2006, 5, 6, 14, 29, 0);
|
|
150
|
+
expect(session.hasExpired(currentDate)).toBeFalsy();
|
|
940
151
|
});
|
|
941
|
-
});
|
|
942
152
|
});
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
153
|
+
describe('when checking if session has a specific extension', () => {
|
|
154
|
+
const session = new Session({
|
|
155
|
+
token: 'ref-12345',
|
|
156
|
+
uuid: '1234',
|
|
157
|
+
// @ts-expect-error
|
|
158
|
+
profile: new Profile({
|
|
159
|
+
lines: [new Line({
|
|
160
|
+
id: 9012,
|
|
161
|
+
extensions: [{
|
|
162
|
+
id: 1,
|
|
163
|
+
exten: '8000',
|
|
164
|
+
context: 'default',
|
|
165
|
+
}],
|
|
166
|
+
}), new Line({
|
|
167
|
+
id: 3421,
|
|
168
|
+
extensions: [{
|
|
169
|
+
id: 2,
|
|
170
|
+
exten: '9980',
|
|
171
|
+
context: 'internal',
|
|
172
|
+
}],
|
|
173
|
+
})],
|
|
174
|
+
}),
|
|
175
|
+
expiresAt: new Date(9999, 0, 1),
|
|
948
176
|
});
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
beforeEach(() => {
|
|
952
|
-
const profile = new Profile({ lines: [] });
|
|
953
|
-
A_SESSION = new Session({ ...A_SESSION, profile });
|
|
954
|
-
});
|
|
955
|
-
|
|
956
|
-
it('should return default context', async () => {
|
|
957
|
-
const context = A_SESSION.primaryContext();
|
|
958
|
-
|
|
959
|
-
expect(context).toEqual(DEFAULT_CONTEXT);
|
|
960
|
-
});
|
|
177
|
+
it('should return true given it owns the extension', () => {
|
|
178
|
+
expect(session.hasExtension('8000')).toBeTruthy();
|
|
961
179
|
});
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
beforeEach(() => {
|
|
965
|
-
const line = new Line({ extensions: [{ context: SOME_CONTEXT, id: 1, exten: '1' }], id: 1, exten: 1 });
|
|
966
|
-
const profile = new Profile({ lines: [line] });
|
|
967
|
-
A_SESSION = new Session({ ...A_SESSION, profile, engineVersion: '18.08' });
|
|
968
|
-
});
|
|
969
|
-
|
|
970
|
-
it('should return line context', async () => {
|
|
971
|
-
const context = A_SESSION.primaryContext();
|
|
972
|
-
|
|
973
|
-
expect(context).toEqual(SOME_CONTEXT);
|
|
974
|
-
});
|
|
180
|
+
it("should return true given it owns the extension even if it's not the default one", () => {
|
|
181
|
+
expect(session.hasExtension('9980')).toBeTruthy();
|
|
975
182
|
});
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
183
|
+
it("should return false given it does't own the extension", () => {
|
|
184
|
+
expect(session.hasExtension('12')).toBeFalsy();
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
describe('when getting the primary context', () => {
|
|
188
|
+
const DEFAULT_CONTEXT = 'default';
|
|
189
|
+
const SOME_CONTEXT = 'some-context';
|
|
190
|
+
let A_SESSION;
|
|
191
|
+
beforeEach(() => {
|
|
192
|
+
A_SESSION = new Session({
|
|
193
|
+
token: 'ref-12345',
|
|
194
|
+
uuid: '1234',
|
|
195
|
+
expiresAt: new Date(9999, 0, 1),
|
|
196
|
+
engineVersion: null,
|
|
985
197
|
});
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
describe('and some lines', () => {
|
|
198
|
+
});
|
|
199
|
+
describe('given NO engine version', () => {
|
|
989
200
|
beforeEach(() => {
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
201
|
+
A_SESSION = new Session({ ...A_SESSION,
|
|
202
|
+
engineVersion: null,
|
|
203
|
+
});
|
|
993
204
|
});
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
205
|
+
describe('and NO profile', () => {
|
|
206
|
+
beforeEach(() => {
|
|
207
|
+
A_SESSION = new Session({ ...A_SESSION,
|
|
208
|
+
profile: null,
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
it('should return default context', async () => {
|
|
212
|
+
const context = A_SESSION.primaryContext();
|
|
213
|
+
expect(context).toEqual(DEFAULT_CONTEXT);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
describe('and NO lines', () => {
|
|
217
|
+
beforeEach(() => {
|
|
218
|
+
A_SESSION = new Session({ ...A_SESSION,
|
|
219
|
+
// @ts-expect-error
|
|
220
|
+
profile: new Profile({
|
|
221
|
+
lines: [],
|
|
222
|
+
}),
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
it('should return default context', async () => {
|
|
226
|
+
const context = A_SESSION.primaryContext();
|
|
227
|
+
expect(context).toEqual(DEFAULT_CONTEXT);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
describe('and some lines', () => {
|
|
231
|
+
beforeEach(() => {
|
|
232
|
+
const line = new Line({
|
|
233
|
+
extensions: [{
|
|
234
|
+
context: SOME_CONTEXT,
|
|
235
|
+
id: 1,
|
|
236
|
+
exten: '1',
|
|
237
|
+
}],
|
|
238
|
+
id: 1,
|
|
239
|
+
// @ts-expect-error
|
|
240
|
+
exten: 1,
|
|
241
|
+
});
|
|
242
|
+
// @ts-expect-error
|
|
243
|
+
const profile = new Profile({
|
|
244
|
+
lines: [line],
|
|
245
|
+
});
|
|
246
|
+
A_SESSION = new Session({ ...A_SESSION,
|
|
247
|
+
profile,
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
it('should return line context', async () => {
|
|
251
|
+
const context = A_SESSION.primaryContext();
|
|
252
|
+
expect(context).toEqual(SOME_CONTEXT);
|
|
253
|
+
});
|
|
999
254
|
});
|
|
1000
|
-
});
|
|
1001
|
-
});
|
|
1002
|
-
|
|
1003
|
-
describe('and equal to 19.08', () => {
|
|
1004
|
-
it('should return default context', async () => {
|
|
1005
|
-
const context = A_SESSION.primaryContext();
|
|
1006
|
-
|
|
1007
|
-
expect(context).toEqual(DEFAULT_CONTEXT);
|
|
1008
|
-
});
|
|
1009
255
|
});
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
256
|
+
describe('given an engine version', () => {
|
|
257
|
+
describe('that is invalid', () => {
|
|
258
|
+
beforeEach(() => {
|
|
259
|
+
A_SESSION = new Session({ ...A_SESSION,
|
|
260
|
+
engineVersion: '19.09',
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
describe('and NO lines', () => {
|
|
264
|
+
beforeEach(() => {
|
|
265
|
+
// @ts-expect-error
|
|
266
|
+
const profile = new Profile({
|
|
267
|
+
lines: [],
|
|
268
|
+
});
|
|
269
|
+
A_SESSION = new Session({ ...A_SESSION,
|
|
270
|
+
profile,
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
it('should return default context', async () => {
|
|
274
|
+
const context = A_SESSION.primaryContext();
|
|
275
|
+
expect(context).toEqual(DEFAULT_CONTEXT);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
describe('and some lines', () => {
|
|
279
|
+
beforeEach(() => {
|
|
280
|
+
const line = new Line({
|
|
281
|
+
extensions: [{
|
|
282
|
+
context: SOME_CONTEXT,
|
|
283
|
+
id: 1,
|
|
284
|
+
exten: '1',
|
|
285
|
+
}],
|
|
286
|
+
id: 1,
|
|
287
|
+
// @ts-expect-error
|
|
288
|
+
exten: 1,
|
|
289
|
+
});
|
|
290
|
+
// @ts-expect-error
|
|
291
|
+
const profile = new Profile({
|
|
292
|
+
lines: [line],
|
|
293
|
+
});
|
|
294
|
+
A_SESSION = new Session({ ...A_SESSION,
|
|
295
|
+
profile,
|
|
296
|
+
engineVersion: '18.08',
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
it('should return line context', async () => {
|
|
300
|
+
const context = A_SESSION.primaryContext();
|
|
301
|
+
expect(context).toEqual(SOME_CONTEXT);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
describe('that is valid', () => {
|
|
306
|
+
describe('and under 19.08', () => {
|
|
307
|
+
describe('and NO lines', () => {
|
|
308
|
+
it('should return default context', async () => {
|
|
309
|
+
const context = A_SESSION.primaryContext();
|
|
310
|
+
expect(context).toEqual(DEFAULT_CONTEXT);
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
describe('and some lines', () => {
|
|
314
|
+
beforeEach(() => {
|
|
315
|
+
const line = new Line({
|
|
316
|
+
extensions: [{
|
|
317
|
+
context: SOME_CONTEXT,
|
|
318
|
+
id: 1,
|
|
319
|
+
exten: '1',
|
|
320
|
+
}],
|
|
321
|
+
id: 1,
|
|
322
|
+
// @ts-expect-error
|
|
323
|
+
exten: 1,
|
|
324
|
+
});
|
|
325
|
+
// @ts-expect-error
|
|
326
|
+
const profile = new Profile({
|
|
327
|
+
lines: [line],
|
|
328
|
+
});
|
|
329
|
+
A_SESSION = new Session({ ...A_SESSION,
|
|
330
|
+
profile,
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
it('should return line context', async () => {
|
|
334
|
+
const context = A_SESSION.primaryContext();
|
|
335
|
+
expect(context).toEqual(SOME_CONTEXT);
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
describe('and equal to 19.08', () => {
|
|
340
|
+
it('should return default context', async () => {
|
|
341
|
+
const context = A_SESSION.primaryContext();
|
|
342
|
+
expect(context).toEqual(DEFAULT_CONTEXT);
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
describe('and higher then 19.08', () => {
|
|
346
|
+
it('should return default context', async () => {
|
|
347
|
+
const context = A_SESSION.primaryContext();
|
|
348
|
+
expect(context).toEqual(DEFAULT_CONTEXT);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
describe('when version is 19.10', () => {
|
|
353
|
+
it('should not consider that version is 19.1', () => {
|
|
354
|
+
A_SESSION = new Session({ ...A_SESSION,
|
|
355
|
+
engineVersion: '19.10',
|
|
356
|
+
});
|
|
357
|
+
expect(A_SESSION.hasEngineVersionGte('19.10')).toBeTruthy();
|
|
358
|
+
expect(A_SESSION.hasEngineVersionGte('19.11')).toBeFalsy();
|
|
359
|
+
expect(A_SESSION.hasEngineVersionGte('19.09')).toBeTruthy();
|
|
360
|
+
expect(A_SESSION.hasEngineVersionGte('19.1')).toBeTruthy();
|
|
361
|
+
expect(A_SESSION.hasEngineVersionGte('19.2')).toBeTruthy();
|
|
362
|
+
});
|
|
363
|
+
});
|
|
1017
364
|
});
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
expect(A_SESSION.hasEngineVersionGte('19.09')).toBeTruthy();
|
|
1026
|
-
expect(A_SESSION.hasEngineVersionGte('19.1')).toBeTruthy();
|
|
1027
|
-
expect(A_SESSION.hasEngineVersionGte('19.2')).toBeTruthy();
|
|
365
|
+
});
|
|
366
|
+
it('Should return `acl` when accessing `acls` property since it\'s deprecated', () => {
|
|
367
|
+
const acl = ['calld.lines.*.presences.read'];
|
|
368
|
+
const session = new Session({
|
|
369
|
+
acl,
|
|
370
|
+
expiresAt: new Date(),
|
|
371
|
+
token: 'abc',
|
|
1028
372
|
});
|
|
1029
|
-
|
|
373
|
+
const oldWarn = console.warn;
|
|
374
|
+
console.warn = () => { };
|
|
375
|
+
expect(session.acls).toEqual(acl);
|
|
376
|
+
expect(session.acl).toEqual(acl);
|
|
377
|
+
console.warn = oldWarn;
|
|
1030
378
|
});
|
|
1031
|
-
});
|
|
1032
|
-
|
|
1033
|
-
it('Should return `acl` when accessing `acls` property since it\'s deprecated', () => {
|
|
1034
|
-
const acl = ['calld.lines.*.presences.read'];
|
|
1035
|
-
const session = new Session({ acl, expiresAt: new Date(), token: 'abc' });
|
|
1036
|
-
|
|
1037
|
-
const oldWarn = console.warn;
|
|
1038
|
-
// $FlowFixMe
|
|
1039
|
-
console.warn = () => {};
|
|
1040
|
-
|
|
1041
|
-
expect(session.acls).toEqual(acl);
|
|
1042
|
-
expect(session.acl).toEqual(acl);
|
|
1043
|
-
|
|
1044
|
-
// $FlowFixMe
|
|
1045
|
-
console.warn = oldWarn;
|
|
1046
|
-
});
|
|
1047
379
|
});
|