@wazo/sdk 0.43.6 → 0.43.8
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 +1 -1
- package/esm/api/auth.js +3 -0
- package/esm/domain/CallLog.js +2 -3
- package/esm/simple/Auth.js +13 -3
- package/esm/simple/Phone.js +2 -2
- package/esm/types/api/auth.d.ts +3 -0
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/domain/CallLog.d.ts.map +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +3 -3
- package/esm/types/domain/Phone/WebRTCPhone.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 +2 -2
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/lib/api/auth.js +3 -0
- package/lib/domain/CallLog.js +2 -3
- package/lib/simple/Auth.js +15 -3
- package/lib/types/api/auth.d.ts +3 -0
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/domain/CallLog.d.ts.map +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +3 -3
- package/lib/types/domain/Phone/WebRTCPhone.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 +2 -2
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api/auth.ts +5 -0
- package/src/domain/CallLog.ts +2 -3
- package/src/domain/Phone/WebRTCPhone.ts +3 -3
- package/src/simple/Auth.ts +15 -3
- package/src/simple/Phone.ts +3 -3
package/src/api/auth.ts
CHANGED
|
@@ -33,6 +33,7 @@ export interface AuthD {
|
|
|
33
33
|
logIn(params: LoginParams): Promise<Session | null | undefined> ;
|
|
34
34
|
logOut: (token: Token) => Promise<LogoutResponse>;
|
|
35
35
|
samlLogIn: (samlSessionId: string) => Promise<Session | null | undefined>;
|
|
36
|
+
samlLogOut: () => Promise<void | { location:string }>;
|
|
36
37
|
initiateIdpAuthentication(domain: string, redirectUrl: string): Promise<any>;
|
|
37
38
|
refreshToken: (refreshToken: string, backend: string, expiration: number, isMobile?: boolean, tenantId?: string, domainName?: string) => Promise<Session | null | undefined>;
|
|
38
39
|
deleteRefreshToken: (clientId: string) => Promise<boolean>;
|
|
@@ -139,6 +140,10 @@ export default ((client: ApiRequester, baseUrl: string): AuthD => ({
|
|
|
139
140
|
return client.post(`${baseUrl}/token`, body, headers).then(Session.parse);
|
|
140
141
|
},
|
|
141
142
|
|
|
143
|
+
samlLogOut() {
|
|
144
|
+
return client.get(`${baseUrl}/saml/logout`, null, null);
|
|
145
|
+
},
|
|
146
|
+
|
|
142
147
|
initiateIdpAuthentication: async (domain: string, redirectUrl: string) => {
|
|
143
148
|
const body = {
|
|
144
149
|
domain,
|
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
|
`);
|
|
@@ -8,7 +8,7 @@ import { Inviter, Invitation, Session, SessionDescriptionHandlerOptions } from '
|
|
|
8
8
|
import { SessionDescriptionHandler } from 'sip.js/lib/platform/web';
|
|
9
9
|
import CallSession from '../CallSession';
|
|
10
10
|
import type { Phone, AvailablePhoneOptions } from './Phone';
|
|
11
|
-
import
|
|
11
|
+
import WebRTCClient from '../../web-rtc-client';
|
|
12
12
|
import Emitter from '../../utils/Emitter';
|
|
13
13
|
import IssueReporter from '../../service/IssueReporter';
|
|
14
14
|
import { PeerConnection, WazoSession } from '../types';
|
|
@@ -60,7 +60,7 @@ export const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
|
60
60
|
export const events = [ON_USER_AGENT, ON_REGISTERED, ON_UNREGISTERED, ON_PROGRESS, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_INCOMING, ON_CALL_OUTGOING, ON_CALL_MUTED, ON_CALL_UNMUTED, ON_CALL_RESUMED, ON_CALL_HELD, ON_CALL_UNHELD, ON_CAMERA_DISABLED, ON_CALL_FAILED, ON_CALL_ENDED, ON_CALL_REJECTED, ON_MESSAGE, ON_REINVITE, ON_TRACK, ON_AUDIO_STREAM, ON_VIDEO_STREAM, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_TERMINATE_SOUND, ON_PLAY_RING_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_HANGUP_SOUND, ON_PLAY_PROGRESS_SOUND, ON_VIDEO_INPUT_CHANGE, ON_SHARE_SCREEN_STARTED, ON_CALL_ERROR, ON_CHAT, ON_SIGNAL, ON_NETWORK_STATS, ON_DISCONNECTED, ON_EARLY_MEDIA];
|
|
61
61
|
const logger = IssueReporter.loggerFor('webrtc-phone');
|
|
62
62
|
export default class WebRTCPhone extends Emitter implements Phone {
|
|
63
|
-
client:
|
|
63
|
+
client: WebRTCClient;
|
|
64
64
|
|
|
65
65
|
allowVideo: boolean;
|
|
66
66
|
|
|
@@ -94,7 +94,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
94
94
|
|
|
95
95
|
shouldSendReinvite: boolean;
|
|
96
96
|
|
|
97
|
-
constructor(client:
|
|
97
|
+
constructor(client: WebRTCClient, audioOutputDeviceId: string | undefined, allowVideo = false, audioRingDeviceId?: string) {
|
|
98
98
|
super();
|
|
99
99
|
this.client = client;
|
|
100
100
|
this.allowVideo = allowVideo;
|
package/src/simple/Auth.ts
CHANGED
|
@@ -167,6 +167,10 @@ export class Auth {
|
|
|
167
167
|
return this._onAuthenticated(rawSession as Session);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
async samlLogOut(): Promise<void | { location: string }> {
|
|
171
|
+
return await this.logout(false, true);
|
|
172
|
+
}
|
|
173
|
+
|
|
170
174
|
async initiateIdpAuthentication(domain: string, redirectUrl: string): Promise<{ location: string, saml_session_id: string } | undefined> {
|
|
171
175
|
try {
|
|
172
176
|
return await getApiClient().auth.initiateIdpAuthentication(domain, redirectUrl);
|
|
@@ -218,20 +222,26 @@ export class Auth {
|
|
|
218
222
|
return getApiClient().auth.refreshToken(refreshToken, '', this.expiration);
|
|
219
223
|
}
|
|
220
224
|
|
|
221
|
-
async logout(deleteRefreshToken = true): Promise<void> {
|
|
225
|
+
async logout(deleteRefreshToken = true, saml = false): Promise<void | { location: string }> {
|
|
222
226
|
try {
|
|
223
227
|
Wazo.Websocket.close(true);
|
|
224
228
|
|
|
225
|
-
if (this.clientId && deleteRefreshToken) {
|
|
229
|
+
if (!saml && this.clientId && deleteRefreshToken) {
|
|
226
230
|
await getApiClient().auth.deleteRefreshToken(this.clientId);
|
|
227
231
|
}
|
|
228
232
|
} catch (e: any) {
|
|
229
233
|
// Nothing to
|
|
230
234
|
}
|
|
231
235
|
|
|
236
|
+
let response;
|
|
237
|
+
|
|
232
238
|
try {
|
|
233
239
|
if (this.session?.token) {
|
|
234
|
-
|
|
240
|
+
if (saml) {
|
|
241
|
+
response = await getApiClient().auth.samlLogOut();
|
|
242
|
+
} else {
|
|
243
|
+
await getApiClient().auth.logOut(this.session.token);
|
|
244
|
+
}
|
|
235
245
|
}
|
|
236
246
|
} catch (e: any) {
|
|
237
247
|
// Nothing to
|
|
@@ -243,6 +253,8 @@ export class Auth {
|
|
|
243
253
|
this.authenticated = false;
|
|
244
254
|
this.usingEdgeServer = undefined;
|
|
245
255
|
setFetchOptions({});
|
|
256
|
+
|
|
257
|
+
return response;
|
|
246
258
|
}
|
|
247
259
|
|
|
248
260
|
setOnHostFromHeaders(callback: (hostFromHeaders: string) => void) {
|
package/src/simple/Phone.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type CallSession from '../domain/CallSession';
|
|
|
6
6
|
import AdHocAPIConference from '../domain/AdHocAPIConference';
|
|
7
7
|
import WebRTCPhone, * as PHONE_EVENTS from '../domain/Phone/WebRTCPhone';
|
|
8
8
|
import { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL } from '../domain/Phone/WebRTCPhone';
|
|
9
|
-
import
|
|
9
|
+
import WebRTCClient, { events as clientEvents, transportEvents } from '../web-rtc-client';
|
|
10
10
|
import IssueReporter from '../service/IssueReporter';
|
|
11
11
|
import Emitter from '../utils/Emitter';
|
|
12
12
|
import Wazo from './index';
|
|
@@ -19,7 +19,7 @@ const protocolLogger = IssueReporter.loggerFor('sip');
|
|
|
19
19
|
const protocolDebugMessages = ['Received WebSocket text message:', 'Sending WebSocket message:'];
|
|
20
20
|
|
|
21
21
|
export class Phone extends Emitter {
|
|
22
|
-
client:
|
|
22
|
+
client: WebRTCClient;
|
|
23
23
|
|
|
24
24
|
phone: WebRTCPhone | null | undefined;
|
|
25
25
|
|
|
@@ -186,7 +186,7 @@ export class Phone extends Emitter {
|
|
|
186
186
|
options.log.connector = this._logConnector;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
this.client = new
|
|
189
|
+
this.client = new WebRTCClient({
|
|
190
190
|
host,
|
|
191
191
|
port: typeof port === 'string' ? parseInt(port, 10) : port,
|
|
192
192
|
displayName,
|