@wazo/sdk 1.0.0-alpha.0 → 1.0.0-alpha.10
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 +16 -7
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/__voice__/call.test.js +57 -2
- package/esm/__tests__/api-client.test.js +20 -1
- package/esm/api/auth.js +16 -2
- package/esm/checker/checks/webrtc.js +2 -2
- package/esm/domain/CallLog.js +2 -3
- package/esm/domain/Phone/CTIPhone.js +2 -2
- package/esm/domain/Phone/WebRTCPhone.js +64 -63
- package/esm/index.js +5 -1
- package/esm/service/CallApi.js +4 -4
- package/esm/simple/Auth.js +19 -15
- package/esm/simple/Phone.js +6 -5
- package/esm/simple/__tests__/Auth.test.js +8 -64
- package/esm/simple/index.js +2 -1
- package/esm/simple/room/Room.js +2 -2
- package/esm/simple/room/SipRoom.js +2 -2
- package/esm/state-machine/call-state-machine.js +2 -2
- package/esm/state-machine/softphone-state-machine.js +1 -2
- package/esm/state-machine/utils.js +8 -3
- package/esm/types/api/auth.d.ts +3 -0
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/checker/checks/index.d.ts +1 -1
- package/esm/types/checker/checks/webrtc-transport.d.ts +2 -2
- package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -1
- package/esm/types/domain/CallLog.d.ts.map +1 -1
- package/esm/types/domain/CallSession.d.ts +3 -3
- package/esm/types/domain/CallSession.d.ts.map +1 -1
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +22 -22
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/domain/types.d.ts +0 -4
- package/esm/types/domain/types.d.ts.map +1 -1
- package/esm/types/index.d.ts +5 -1
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +3 -3
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/esm/types/service/CallApi.d.ts +5 -5
- package/esm/types/service/CallApi.d.ts.map +1 -1
- package/esm/types/simple/Auth.d.ts +6 -1
- package/esm/types/simple/Auth.d.ts.map +1 -1
- package/esm/types/simple/Phone.d.ts +8 -8
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/esm/types/simple/index.d.ts +3 -1
- package/esm/types/simple/index.d.ts.map +1 -1
- package/esm/types/state-machine/softphone-state-machine.d.ts +1 -2
- package/esm/types/state-machine/softphone-state-machine.d.ts.map +1 -1
- package/esm/types/state-machine/utils.d.ts +2 -2
- package/esm/types/state-machine/utils.d.ts.map +1 -1
- package/esm/types/utils/api-requester.d.ts.map +1 -1
- package/esm/types/utils/sdp.d.ts +3 -2
- package/esm/types/utils/sdp.d.ts.map +1 -1
- package/esm/types/utils/webrtc.d.ts +1 -0
- package/esm/types/utils/webrtc.d.ts.map +1 -1
- package/esm/types/voice/call.d.ts +30 -12
- package/esm/types/voice/call.d.ts.map +1 -1
- package/esm/types/voice/softphone.d.ts +25 -13
- package/esm/types/voice/softphone.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts +39 -38
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/utils/__tests__/api-requester.test.js +17 -0
- package/esm/utils/api-requester.js +9 -1
- package/esm/utils/sdp.js +22 -9
- package/esm/utils/webrtc.js +24 -4
- package/esm/voice/call.js +130 -38
- package/esm/voice/softphone.js +145 -35
- package/esm/web-rtc-client.js +61 -58
- package/lib/__tests__/__voice__/call.test.js +56 -1
- package/lib/__tests__/api-client.test.js +20 -1
- package/lib/api/auth.js +16 -2
- package/lib/checker/checks/webrtc.js +1 -1
- package/lib/domain/CallLog.js +2 -3
- package/lib/domain/Phone/CTIPhone.js +2 -2
- package/lib/domain/Phone/WebRTCPhone.js +63 -62
- package/lib/index.js +11 -3
- package/lib/service/CallApi.js +2 -2
- package/lib/simple/Auth.js +21 -15
- package/lib/simple/Phone.js +3 -2
- package/lib/simple/__tests__/Auth.test.js +11 -64
- package/lib/simple/index.js +2 -1
- package/lib/simple/room/Room.js +1 -1
- package/lib/simple/room/SipRoom.js +1 -1
- package/lib/state-machine/call-state-machine.js +2 -2
- package/lib/state-machine/softphone-state-machine.js +1 -2
- package/lib/state-machine/utils.js +8 -3
- package/lib/types/api/auth.d.ts +3 -0
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/checker/checks/index.d.ts +1 -1
- package/lib/types/checker/checks/webrtc-transport.d.ts +2 -2
- package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -1
- package/lib/types/domain/CallLog.d.ts.map +1 -1
- package/lib/types/domain/CallSession.d.ts +3 -3
- package/lib/types/domain/CallSession.d.ts.map +1 -1
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +22 -22
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/domain/types.d.ts +0 -4
- package/lib/types/domain/types.d.ts.map +1 -1
- package/lib/types/index.d.ts +5 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +3 -3
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/lib/types/service/CallApi.d.ts +5 -5
- package/lib/types/service/CallApi.d.ts.map +1 -1
- package/lib/types/simple/Auth.d.ts +6 -1
- package/lib/types/simple/Auth.d.ts.map +1 -1
- package/lib/types/simple/Phone.d.ts +8 -8
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/lib/types/simple/index.d.ts +3 -1
- package/lib/types/simple/index.d.ts.map +1 -1
- package/lib/types/state-machine/softphone-state-machine.d.ts +1 -2
- package/lib/types/state-machine/softphone-state-machine.d.ts.map +1 -1
- package/lib/types/state-machine/utils.d.ts +2 -2
- package/lib/types/state-machine/utils.d.ts.map +1 -1
- package/lib/types/utils/api-requester.d.ts.map +1 -1
- package/lib/types/utils/sdp.d.ts +3 -2
- package/lib/types/utils/sdp.d.ts.map +1 -1
- package/lib/types/utils/webrtc.d.ts +1 -0
- package/lib/types/utils/webrtc.d.ts.map +1 -1
- package/lib/types/voice/call.d.ts +30 -12
- package/lib/types/voice/call.d.ts.map +1 -1
- package/lib/types/voice/softphone.d.ts +25 -13
- package/lib/types/voice/softphone.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts +39 -38
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/utils/__tests__/api-requester.test.js +17 -0
- package/lib/utils/api-requester.js +9 -1
- package/lib/utils/sdp.js +25 -10
- package/lib/utils/webrtc.js +25 -4
- package/lib/voice/call.js +131 -36
- package/lib/voice/softphone.js +150 -35
- package/lib/web-rtc-client.js +59 -57
- package/package.json +1 -1
- package/src/__tests__/__voice__/call.test.ts +63 -2
- package/src/__tests__/api-client.test.ts +22 -1
- package/src/api/auth.ts +30 -3
- package/src/checker/checks/webrtc-transport.ts +2 -2
- package/src/checker/checks/webrtc.ts +2 -2
- package/src/domain/CallLog.ts +2 -3
- package/src/domain/CallSession.ts +3 -3
- package/src/domain/Phone/CTIPhone.ts +3 -2
- package/src/domain/Phone/WebRTCPhone.ts +95 -93
- package/src/domain/types.ts +0 -5
- package/src/index.ts +6 -1
- package/src/lib/WazoSessionDescriptionHandler.ts +3 -3
- package/src/service/CallApi.ts +7 -7
- package/src/simple/Auth.ts +21 -16
- package/src/simple/Phone.ts +12 -11
- package/src/simple/__tests__/Auth.test.ts +9 -87
- package/src/simple/index.ts +2 -1
- package/src/simple/room/Room.ts +3 -3
- package/src/simple/room/SipRoom.ts +3 -3
- package/src/state-machine/call-state-machine.ts +2 -2
- package/src/state-machine/softphone-state-machine.ts +1 -2
- package/src/state-machine/utils.ts +12 -5
- package/src/utils/__tests__/api-requester.test.ts +20 -0
- package/src/utils/api-requester.ts +9 -1
- package/src/utils/sdp.ts +26 -11
- package/src/utils/webrtc.ts +27 -5
- package/src/voice/call.ts +169 -50
- package/src/voice/softphone.ts +180 -41
- package/src/web-rtc-client.ts +106 -99
package/src/api/auth.ts
CHANGED
|
@@ -16,6 +16,12 @@ type LoginParams = {
|
|
|
16
16
|
domainName?: string;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
type SamlLoginBody = {
|
|
20
|
+
saml_session_id: string,
|
|
21
|
+
access_type?: 'online' | 'offline';
|
|
22
|
+
client_id?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
19
25
|
type SendResetPasswordArgs = {
|
|
20
26
|
username?: string,
|
|
21
27
|
email?: string,
|
|
@@ -27,6 +33,7 @@ export interface AuthD {
|
|
|
27
33
|
logIn(params: LoginParams): Promise<Session | null | undefined> ;
|
|
28
34
|
logOut: (token: Token) => Promise<LogoutResponse>;
|
|
29
35
|
samlLogIn: (samlSessionId: string) => Promise<Session | null | undefined>;
|
|
36
|
+
samlLogOut: () => Promise<void | { location:string }>;
|
|
30
37
|
initiateIdpAuthentication(domain: string, redirectUrl: string): Promise<any>;
|
|
31
38
|
refreshToken: (refreshToken: string, backend: string, expiration: number, isMobile?: boolean, tenantId?: string, domainName?: string) => Promise<Session | null | undefined>;
|
|
32
39
|
deleteRefreshToken: (clientId: string) => Promise<boolean>;
|
|
@@ -110,13 +117,33 @@ export default ((client: ApiRequester, baseUrl: string): AuthD => ({
|
|
|
110
117
|
},
|
|
111
118
|
|
|
112
119
|
logOut: (token: Token): Promise<LogoutResponse> => client.delete(`${baseUrl}/token/${token}`, null, {}, ApiRequester.successResponseParser),
|
|
120
|
+
|
|
113
121
|
samlLogIn: async (samlSessionId: string): Promise<Session | null | undefined> => {
|
|
114
|
-
const
|
|
122
|
+
const headers: Record<string, any> = {
|
|
123
|
+
Accept: 'application/json',
|
|
124
|
+
'Content-Type': 'application/json',
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const body: SamlLoginBody = {
|
|
115
128
|
saml_session_id: samlSessionId,
|
|
116
129
|
};
|
|
117
130
|
|
|
118
|
-
|
|
131
|
+
if (client.clientId) {
|
|
132
|
+
body.access_type = 'offline';
|
|
133
|
+
body.client_id = client.clientId;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (Wazo.Auth.mobile) {
|
|
137
|
+
headers['Wazo-Session-Type'] = 'mobile';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return client.post(`${baseUrl}/token`, body, headers).then(Session.parse);
|
|
119
141
|
},
|
|
142
|
+
|
|
143
|
+
samlLogOut() {
|
|
144
|
+
return client.get(`${baseUrl}/saml/logout`, null, null);
|
|
145
|
+
},
|
|
146
|
+
|
|
120
147
|
initiateIdpAuthentication: async (domain: string, redirectUrl: string) => {
|
|
121
148
|
const body = {
|
|
122
149
|
domain,
|
|
@@ -128,7 +155,7 @@ export default ((client: ApiRequester, baseUrl: string): AuthD => ({
|
|
|
128
155
|
'Content-Type': 'application/json',
|
|
129
156
|
};
|
|
130
157
|
|
|
131
|
-
return client.post(`${baseUrl}/saml/sso`, body, headers
|
|
158
|
+
return client.post(`${baseUrl}/saml/sso`, body, headers);
|
|
132
159
|
},
|
|
133
160
|
refreshToken: (refreshToken: string, backend: string, expiration: number, isMobile?: boolean, tenantId?: string, domainName?: string): Promise<Session | null | undefined> => {
|
|
134
161
|
const body: Record<string, any> = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import WebRTCClient from '../../web-rtc-client';
|
|
2
|
-
import {
|
|
2
|
+
import { SipCall } from '../../domain/types';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
name: 'WebRTC Transport (WS) ~30s',
|
|
6
|
-
check: (server: string, session:
|
|
6
|
+
check: (server: string, session: SipCall): Promise<void> => new Promise((resolve, reject) => {
|
|
7
7
|
const [host, port = 443] = server.split(':');
|
|
8
8
|
|
|
9
9
|
const client = new WebRTCClient({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* global MediaStream */
|
|
2
|
-
import {
|
|
2
|
+
import { getSipCallId } from '../../utils/sdp';
|
|
3
3
|
import WebRTCClient from '../../web-rtc-client';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
@@ -36,7 +36,7 @@ export default {
|
|
|
36
36
|
client.on(client.REGISTERED, () => {
|
|
37
37
|
const sipSession = client.call('*10');
|
|
38
38
|
|
|
39
|
-
if (!sipSession || !
|
|
39
|
+
if (!sipSession || !getSipCallId(sipSession)) {
|
|
40
40
|
return handleError('Unable to make call through WebRTC');
|
|
41
41
|
}
|
|
42
42
|
|
package/src/domain/CallLog.ts
CHANGED
|
@@ -118,8 +118,7 @@ export default class CallLog {
|
|
|
118
118
|
|
|
119
119
|
static parseNew(plain: CallLogResponse, session: Session): CallLog {
|
|
120
120
|
const callLog: CallLog = CallLog.parse(plain);
|
|
121
|
-
|
|
122
|
-
callLog.newMissedCall = session && session.hasExtension((plain.requested_extension || plain.destination_extension) as string) && !plain.answered;
|
|
121
|
+
callLog.newMissedCall = session && plain.destination_user_uuid === session.uuid && !plain.answered;
|
|
123
122
|
return callLog;
|
|
124
123
|
}
|
|
125
124
|
|
|
@@ -203,7 +202,7 @@ export default class CallLog {
|
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
isAnOutgoingCall(session: Session): boolean {
|
|
206
|
-
console.warn(`@wazo/sdk
|
|
205
|
+
console.warn(`@wazo/sdk
|
|
207
206
|
CallLog.isAnOutgoingcall(session) method is obsolete.
|
|
208
207
|
Please use CallLog.isOutgoing(session).
|
|
209
208
|
`);
|
|
@@ -2,7 +2,7 @@ import { SessionState } from 'sip.js/lib/api/session-state';
|
|
|
2
2
|
import Call from './Call';
|
|
3
3
|
import newFrom from '../utils/new-from';
|
|
4
4
|
import updateFrom from '../utils/update-from';
|
|
5
|
-
import {
|
|
5
|
+
import { SipCall } from './types';
|
|
6
6
|
|
|
7
7
|
type CallSessionArguments = {
|
|
8
8
|
answered: boolean;
|
|
@@ -32,7 +32,7 @@ type CallSessionArguments = {
|
|
|
32
32
|
screensharing: boolean;
|
|
33
33
|
recording: boolean;
|
|
34
34
|
recordingPaused: boolean;
|
|
35
|
-
sipSession?:
|
|
35
|
+
sipSession?: SipCall;
|
|
36
36
|
conference: boolean;
|
|
37
37
|
};
|
|
38
38
|
export default class CallSession {
|
|
@@ -96,7 +96,7 @@ export default class CallSession {
|
|
|
96
96
|
|
|
97
97
|
recordingPaused: boolean;
|
|
98
98
|
|
|
99
|
-
sipSession:
|
|
99
|
+
sipSession: SipCall | undefined;
|
|
100
100
|
|
|
101
101
|
conference: boolean;
|
|
102
102
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Session from '../Session';
|
|
2
2
|
import Call from '../Call';
|
|
3
|
+
import SoftphoneCall from '../../voice/call';
|
|
3
4
|
import Line from '../Line';
|
|
4
5
|
import CallSession from '../CallSession';
|
|
5
6
|
import type { Phone, AvailablePhoneOptions } from './Phone';
|
|
@@ -141,7 +142,7 @@ export default class CTIPhone extends Emitter implements Phone {
|
|
|
141
142
|
});
|
|
142
143
|
|
|
143
144
|
try {
|
|
144
|
-
await CallApi.cancelCall(callSession);
|
|
145
|
+
await CallApi.cancelCall({ apiId: callSession.getId() } as SoftphoneCall);
|
|
145
146
|
|
|
146
147
|
if (this.currentCall && callSession.callId === this.currentCall.id) {
|
|
147
148
|
this.endCurrentCall(callSession);
|
|
@@ -167,7 +168,7 @@ export default class CTIPhone extends Emitter implements Phone {
|
|
|
167
168
|
callId: callSession.getId(),
|
|
168
169
|
number: callSession.number,
|
|
169
170
|
});
|
|
170
|
-
await CallApi.cancelCall(callSession);
|
|
171
|
+
await CallApi.cancelCall({ id: callSession.getId() } as SoftphoneCall);
|
|
171
172
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
172
173
|
}
|
|
173
174
|
|