@wazo/sdk 0.43.6 → 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +3 -3
- package/esm/__tests__/__voice__/call.test.js +72 -0
- package/esm/__tests__/__voice__/softphone.test.js +66 -0
- package/esm/__tests__/api-client.test.js +1 -20
- package/esm/api/auth.js +2 -13
- package/esm/checker/checks/webrtc.js +2 -1
- package/esm/domain/InvalidState.js +8 -0
- package/esm/domain/InvalidStateTransition.js +10 -0
- package/esm/domain/Phone/WebRTCPhone.js +33 -35
- package/esm/simple/Auth.js +12 -6
- package/esm/simple/Phone.js +2 -1
- package/esm/simple/__tests__/Auth.test.js +64 -8
- package/esm/simple/index.js +8 -2
- package/esm/simple/room/Room.js +2 -1
- package/esm/simple/room/SipRoom.js +2 -1
- package/esm/state-machine/call-state-machine.js +114 -0
- package/esm/state-machine/softphone-state-machine.js +39 -0
- package/esm/state-machine/utils.js +40 -0
- package/esm/types/__tests__/__voice__/call.test.d.ts +2 -0
- package/esm/types/__tests__/__voice__/call.test.d.ts.map +1 -0
- package/esm/types/__tests__/__voice__/softphone.test.d.ts +2 -0
- package/esm/types/__tests__/__voice__/softphone.test.d.ts.map +1 -0
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/checker/checks/webrtc.d.ts.map +1 -1
- package/esm/types/domain/InvalidState.d.ts +6 -0
- package/esm/types/domain/InvalidState.d.ts.map +1 -0
- package/esm/types/domain/InvalidStateTransition.d.ts +7 -0
- package/esm/types/domain/InvalidStateTransition.d.ts.map +1 -0
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +0 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/domain/types.d.ts +4 -0
- package/esm/types/domain/types.d.ts.map +1 -1
- package/esm/types/simple/Auth.d.ts.map +1 -1
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/esm/types/simple/index.d.ts +7 -2
- package/esm/types/simple/index.d.ts.map +1 -1
- package/esm/types/simple/room/Room.d.ts.map +1 -1
- package/esm/types/simple/room/SipRoom.d.ts +1 -1
- package/esm/types/simple/room/SipRoom.d.ts.map +1 -1
- package/esm/types/state-machine/call-state-machine.d.ts +43 -0
- package/esm/types/state-machine/call-state-machine.d.ts.map +1 -0
- package/esm/types/state-machine/softphone-state-machine.d.ts +19 -0
- package/esm/types/state-machine/softphone-state-machine.d.ts.map +1 -0
- package/esm/types/state-machine/utils.d.ts +9 -0
- package/esm/types/state-machine/utils.d.ts.map +1 -0
- package/esm/types/utils/api-requester.d.ts.map +1 -1
- package/esm/types/utils/sdp.d.ts +6 -0
- package/esm/types/utils/sdp.d.ts.map +1 -1
- package/esm/types/utils/sip-logger.d.ts +4 -0
- package/esm/types/utils/sip-logger.d.ts.map +1 -0
- package/esm/types/utils/webrtc.d.ts +40 -0
- package/esm/types/utils/webrtc.d.ts.map +1 -1
- package/esm/types/voice/call.d.ts +110 -0
- package/esm/types/voice/call.d.ts.map +1 -0
- package/esm/types/voice/softphone.d.ts +77 -0
- package/esm/types/voice/softphone.d.ts.map +1 -0
- package/esm/types/web-rtc-client.d.ts +1 -36
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/utils/__tests__/api-requester.test.js +0 -17
- package/esm/utils/api-requester.js +1 -9
- package/esm/utils/sdp.js +26 -0
- package/esm/utils/sip-logger.js +32 -0
- package/esm/utils/webrtc.js +465 -0
- package/esm/voice/call.js +527 -0
- package/esm/voice/softphone.js +347 -0
- package/esm/web-rtc-client.js +86 -584
- package/lib/__tests__/__voice__/call.test.js +86 -0
- package/lib/__tests__/__voice__/softphone.test.js +80 -0
- package/lib/__tests__/api-client.test.js +1 -20
- package/lib/api/auth.js +2 -13
- package/lib/checker/checks/webrtc.js +2 -1
- package/lib/domain/InvalidState.js +9 -0
- package/lib/domain/InvalidStateTransition.js +10 -0
- package/lib/domain/Phone/WebRTCPhone.js +33 -35
- package/lib/simple/Auth.js +12 -6
- package/lib/simple/Phone.js +2 -1
- package/lib/simple/__tests__/Auth.test.js +64 -11
- package/lib/simple/index.js +6 -0
- package/lib/simple/room/Room.js +4 -3
- package/lib/simple/room/SipRoom.js +2 -1
- package/lib/state-machine/call-state-machine.js +120 -0
- package/lib/state-machine/softphone-state-machine.js +42 -0
- package/lib/state-machine/utils.js +52 -0
- package/lib/types/__tests__/__voice__/call.test.d.ts +2 -0
- package/lib/types/__tests__/__voice__/call.test.d.ts.map +1 -0
- package/lib/types/__tests__/__voice__/softphone.test.d.ts +2 -0
- package/lib/types/__tests__/__voice__/softphone.test.d.ts.map +1 -0
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/checker/checks/webrtc.d.ts.map +1 -1
- package/lib/types/domain/InvalidState.d.ts +6 -0
- package/lib/types/domain/InvalidState.d.ts.map +1 -0
- package/lib/types/domain/InvalidStateTransition.d.ts +7 -0
- package/lib/types/domain/InvalidStateTransition.d.ts.map +1 -0
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +0 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/domain/types.d.ts +4 -0
- package/lib/types/domain/types.d.ts.map +1 -1
- package/lib/types/simple/Auth.d.ts.map +1 -1
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/lib/types/simple/index.d.ts +7 -2
- package/lib/types/simple/index.d.ts.map +1 -1
- package/lib/types/simple/room/Room.d.ts.map +1 -1
- package/lib/types/simple/room/SipRoom.d.ts +1 -1
- package/lib/types/simple/room/SipRoom.d.ts.map +1 -1
- package/lib/types/state-machine/call-state-machine.d.ts +43 -0
- package/lib/types/state-machine/call-state-machine.d.ts.map +1 -0
- package/lib/types/state-machine/softphone-state-machine.d.ts +19 -0
- package/lib/types/state-machine/softphone-state-machine.d.ts.map +1 -0
- package/lib/types/state-machine/utils.d.ts +9 -0
- package/lib/types/state-machine/utils.d.ts.map +1 -0
- package/lib/types/utils/api-requester.d.ts.map +1 -1
- package/lib/types/utils/sdp.d.ts +6 -0
- package/lib/types/utils/sdp.d.ts.map +1 -1
- package/lib/types/utils/sip-logger.d.ts +4 -0
- package/lib/types/utils/sip-logger.d.ts.map +1 -0
- package/lib/types/utils/webrtc.d.ts +40 -0
- package/lib/types/utils/webrtc.d.ts.map +1 -1
- package/lib/types/voice/call.d.ts +110 -0
- package/lib/types/voice/call.d.ts.map +1 -0
- package/lib/types/voice/softphone.d.ts +77 -0
- package/lib/types/voice/softphone.d.ts.map +1 -0
- package/lib/types/web-rtc-client.d.ts +1 -36
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/utils/__tests__/api-requester.test.js +0 -17
- package/lib/utils/api-requester.js +1 -9
- package/lib/utils/sdp.js +27 -1
- package/lib/utils/sip-logger.js +37 -0
- package/lib/utils/webrtc.js +521 -1
- package/lib/voice/call.js +577 -0
- package/lib/voice/softphone.js +375 -0
- package/lib/web-rtc-client.js +89 -601
- package/package.json +3 -2
- package/src/__tests__/__voice__/call.test.ts +90 -0
- package/src/__tests__/__voice__/softphone.test.ts +82 -0
- package/src/__tests__/api-client.test.ts +1 -22
- package/src/api/auth.ts +3 -25
- package/src/checker/checks/webrtc.ts +2 -1
- package/src/domain/InvalidState.ts +13 -0
- package/src/domain/InvalidStateTransition.ts +17 -0
- package/src/domain/Phone/WebRTCPhone.ts +34 -36
- package/src/domain/types.ts +6 -1
- package/src/simple/Auth.ts +13 -6
- package/src/simple/Phone.ts +2 -1
- package/src/simple/__tests__/Auth.test.ts +87 -9
- package/src/simple/index.ts +9 -2
- package/src/simple/room/Room.ts +2 -1
- package/src/simple/room/SipRoom.ts +2 -1
- package/src/state-machine/call-state-machine.ts +131 -0
- package/src/state-machine/softphone-state-machine.ts +49 -0
- package/src/state-machine/utils.ts +53 -0
- package/src/utils/__tests__/api-requester.test.ts +0 -20
- package/src/utils/api-requester.ts +1 -9
- package/src/utils/sdp.ts +36 -0
- package/src/utils/sip-logger.ts +40 -0
- package/src/utils/webrtc.ts +571 -0
- package/src/voice/call.ts +713 -0
- package/src/voice/softphone.ts +485 -0
- package/src/web-rtc-client.ts +90 -690
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
/* eslint-disable no-underscore-dangle */
|
|
16
|
+
const sip_js_1 = require("sip.js");
|
|
17
|
+
const softphone_1 = __importDefault(require("../../voice/softphone"));
|
|
18
|
+
const call_1 = __importDefault(require("../../voice/call"));
|
|
19
|
+
const call_state_machine_1 = require("../../state-machine/call-state-machine");
|
|
20
|
+
const softphone_state_machine_1 = require("../../state-machine/softphone-state-machine");
|
|
21
|
+
const InvalidStateTransition_1 = __importDefault(require("../../domain/InvalidStateTransition"));
|
|
22
|
+
const uaOptions = {
|
|
23
|
+
logBuiltinEnabled: false,
|
|
24
|
+
transportOptions: {
|
|
25
|
+
traceSip: false,
|
|
26
|
+
wsServers: 'ws://localhost',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
jest.mock('../..', () => ({
|
|
30
|
+
__esModule: true,
|
|
31
|
+
default: {
|
|
32
|
+
Auth: {
|
|
33
|
+
getHost: jest.fn(() => 'my-stack.io'),
|
|
34
|
+
getSession: jest.fn(() => ({
|
|
35
|
+
displayName: () => 'John Doe',
|
|
36
|
+
primaryWebRtcLine: () => ({}),
|
|
37
|
+
})),
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}));
|
|
41
|
+
jest.mock('../../web-rtc-client', () => jest.fn().mockImplementation(() => ({
|
|
42
|
+
answer: jest.fn(() => Promise.resolve()),
|
|
43
|
+
hangup: jest.fn(() => Promise.resolve()),
|
|
44
|
+
register: jest.fn(() => Promise.resolve()),
|
|
45
|
+
setOnHeartbeatTimeout: jest.fn(() => Promise.resolve()),
|
|
46
|
+
setOnHeartbeatCallback: jest.fn(() => Promise.resolve()),
|
|
47
|
+
on: jest.fn(),
|
|
48
|
+
})));
|
|
49
|
+
const ua = new sip_js_1.UserAgent(uaOptions);
|
|
50
|
+
const sipCall = new sip_js_1.Inviter(ua, sip_js_1.UserAgent.makeURI('sip:1234@my.stack.io'));
|
|
51
|
+
softphone_1.default.connect();
|
|
52
|
+
softphone_1.default._sendAction(softphone_state_machine_1.Actions.REGISTER_DONE);
|
|
53
|
+
const invalidStateTransition = (state, action) => new InvalidStateTransition_1.default(`Invalid state transition from ${state} with action ${action}`, state, action);
|
|
54
|
+
describe('Call', () => {
|
|
55
|
+
describe('accept', () => {
|
|
56
|
+
it('Should throw an error when accepting a not ringing call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
const call = new call_1.default(sipCall, softphone_1.default);
|
|
58
|
+
yield expect(call.accept()).rejects.toThrowError(invalidStateTransition(call_state_machine_1.States.IDLE, call_state_machine_1.Actions.ACCEPT));
|
|
59
|
+
}));
|
|
60
|
+
it.only('Should throw an error when the softphone is not registered', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
const call = new call_1.default(sipCall, softphone_1.default);
|
|
62
|
+
call._sendAction(call_state_machine_1.Actions.INCOMING_CALL);
|
|
63
|
+
softphone_1.default._sendAction(softphone_state_machine_1.Actions.TRANSPORT_CLOSED);
|
|
64
|
+
yield expect(call.accept()).rejects.toThrowError(invalidStateTransition(call_state_machine_1.States.RINGING, call_state_machine_1.Actions.ACCEPT));
|
|
65
|
+
}));
|
|
66
|
+
it('Should not throw an error when accepting a not ringing call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
const call = new call_1.default(sipCall, softphone_1.default);
|
|
68
|
+
call._sendAction(call_state_machine_1.Actions.INCOMING_CALL);
|
|
69
|
+
yield call.accept();
|
|
70
|
+
expect(softphone_1.default.client.answer).toHaveBeenCalled();
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
describe('hangup', () => {
|
|
74
|
+
it('Should throw an error when terminating a non established call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
const call = new call_1.default(sipCall, softphone_1.default);
|
|
76
|
+
yield expect(call.hangup()).rejects.toThrowError(invalidStateTransition(call_state_machine_1.States.IDLE, call_state_machine_1.Actions.HANGUP));
|
|
77
|
+
}));
|
|
78
|
+
it('Should not throw an error when terminating an established call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
const call = new call_1.default(sipCall, softphone_1.default);
|
|
80
|
+
call._sendAction(call_state_machine_1.Actions.MAKE_CALL);
|
|
81
|
+
call._sendAction(call_state_machine_1.Actions.REMOTLY_ACCEPTED);
|
|
82
|
+
yield call.hangup();
|
|
83
|
+
expect(softphone_1.default.client.hangup).toHaveBeenCalled();
|
|
84
|
+
}));
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const softphone_1 = require("../../voice/softphone");
|
|
16
|
+
const softphone_state_machine_1 = require("../../state-machine/softphone-state-machine");
|
|
17
|
+
const __1 = __importDefault(require("../.."));
|
|
18
|
+
const InvalidStateTransition_1 = __importDefault(require("../../domain/InvalidStateTransition"));
|
|
19
|
+
const server = 'my.stack.io';
|
|
20
|
+
const displayName = 'John Doe';
|
|
21
|
+
const webRtcLine = {};
|
|
22
|
+
const session = {
|
|
23
|
+
uuid: '1234',
|
|
24
|
+
displayName: jest.fn(() => displayName),
|
|
25
|
+
primaryWebRtcLine: jest.fn(() => webRtcLine),
|
|
26
|
+
};
|
|
27
|
+
jest.mock('../..', () => ({
|
|
28
|
+
__esModule: true,
|
|
29
|
+
default: {
|
|
30
|
+
Auth: {
|
|
31
|
+
getHost: jest.fn(() => server),
|
|
32
|
+
getSession: jest.fn(() => session),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
jest.mock('../../web-rtc-client', () => jest.fn().mockImplementation(() => ({
|
|
37
|
+
register: jest.fn(() => Promise.resolve()),
|
|
38
|
+
unregister: jest.fn(() => Promise.resolve()),
|
|
39
|
+
setOnHeartbeatTimeout: jest.fn(() => Promise.resolve()),
|
|
40
|
+
setOnHeartbeatCallback: jest.fn(() => Promise.resolve()),
|
|
41
|
+
on: jest.fn(),
|
|
42
|
+
INVITE: 'invite',
|
|
43
|
+
})));
|
|
44
|
+
const invalidStateTransition = (state, action) => new InvalidStateTransition_1.default(`Invalid state transition from ${state} with action ${action}`, state, action);
|
|
45
|
+
describe('Softphone', () => {
|
|
46
|
+
describe('connect', () => {
|
|
47
|
+
it('Should retrieve information from Wazo.Auth', () => {
|
|
48
|
+
const instance = new softphone_1.Softphone();
|
|
49
|
+
jest.spyOn(instance, 'connectWithCredentials');
|
|
50
|
+
instance.connect({});
|
|
51
|
+
expect(__1.default.Auth.getHost).toHaveBeenCalled();
|
|
52
|
+
expect(__1.default.Auth.getSession).toHaveBeenCalled();
|
|
53
|
+
expect(instance.connectWithCredentials).toHaveBeenCalledWith(server, webRtcLine, displayName, { userUuid: session.uuid });
|
|
54
|
+
expect(instance.client.on).toHaveBeenCalledWith('invite', expect.anything());
|
|
55
|
+
});
|
|
56
|
+
it('Should throw an error when already connected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
const instance = new softphone_1.Softphone();
|
|
58
|
+
instance.softphoneActor.send({ type: softphone_state_machine_1.Actions.REGISTER });
|
|
59
|
+
yield expect(instance.connect({})).rejects.toThrowError(invalidStateTransition(softphone_state_machine_1.States.REGISTERING, softphone_state_machine_1.Actions.REGISTER));
|
|
60
|
+
}));
|
|
61
|
+
it('Should not allow to register twice', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
const instance = new softphone_1.Softphone();
|
|
63
|
+
instance.connect({});
|
|
64
|
+
yield expect(instance.connect({})).rejects.toThrowError(invalidStateTransition(softphone_state_machine_1.States.REGISTERING, softphone_state_machine_1.Actions.REGISTER));
|
|
65
|
+
}));
|
|
66
|
+
});
|
|
67
|
+
describe('disconnect', () => {
|
|
68
|
+
it('Should throw an error when not connected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
const instance = new softphone_1.Softphone();
|
|
70
|
+
yield expect(instance.disconnect()).rejects.toThrowError(invalidStateTransition(softphone_state_machine_1.States.UNREGISTERED, softphone_state_machine_1.Actions.UNREGISTER));
|
|
71
|
+
}));
|
|
72
|
+
it('Should unregister the client', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
const instance = new softphone_1.Softphone();
|
|
74
|
+
instance.connect({});
|
|
75
|
+
instance.softphoneActor.send({ type: softphone_state_machine_1.Actions.REGISTER_DONE });
|
|
76
|
+
yield instance.disconnect();
|
|
77
|
+
expect(instance.client.unregister).toHaveBeenCalled();
|
|
78
|
+
}));
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -127,6 +127,7 @@ describe('With correct API results', () => {
|
|
|
127
127
|
body: JSON.stringify({ saml_session_id: samlSessionId }),
|
|
128
128
|
signal: expect.any(Object),
|
|
129
129
|
headers: {
|
|
130
|
+
'X-Auth-Token': token,
|
|
130
131
|
'Content-Type': 'application/json',
|
|
131
132
|
Accept: 'application/json',
|
|
132
133
|
},
|
|
@@ -134,26 +135,6 @@ describe('With correct API results', () => {
|
|
|
134
135
|
});
|
|
135
136
|
}));
|
|
136
137
|
});
|
|
137
|
-
describe('samlLogIn mobile test', () => {
|
|
138
|
-
it('should retrieve user token', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
-
Wazo.Auth.mobile = true;
|
|
140
|
-
const samlSessionId = 'a1b2C3d4';
|
|
141
|
-
const result = yield client.auth.samlLogIn(samlSessionId);
|
|
142
|
-
expect(result).toBeInstanceOf(Session_1.default);
|
|
143
|
-
expect(result === null || result === void 0 ? void 0 : result.token).toBe(1);
|
|
144
|
-
expect(global.fetch).toBeCalledWith(`https://${server}/api/auth/${authVersion}/token`, {
|
|
145
|
-
method: 'post',
|
|
146
|
-
body: JSON.stringify({ saml_session_id: samlSessionId }),
|
|
147
|
-
signal: expect.any(Object),
|
|
148
|
-
headers: {
|
|
149
|
-
'Content-Type': 'application/json',
|
|
150
|
-
'Wazo-Session-Type': 'mobile',
|
|
151
|
-
Accept: 'application/json',
|
|
152
|
-
},
|
|
153
|
-
agent: null,
|
|
154
|
-
});
|
|
155
|
-
}));
|
|
156
|
-
});
|
|
157
138
|
describe('logOut test', () => {
|
|
158
139
|
it('should delete the specified token', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
159
140
|
const oldToken = 123;
|
package/lib/api/auth.js
CHANGED
|
@@ -48,21 +48,10 @@ exports.default = ((client, baseUrl) => ({
|
|
|
48
48
|
},
|
|
49
49
|
logOut: (token) => client.delete(`${baseUrl}/token/${token}`, null, {}, api_requester_1.default.successResponseParser),
|
|
50
50
|
samlLogIn: (samlSessionId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
-
const headers = {
|
|
52
|
-
Accept: 'application/json',
|
|
53
|
-
'Content-Type': 'application/json',
|
|
54
|
-
};
|
|
55
51
|
const body = {
|
|
56
52
|
saml_session_id: samlSessionId,
|
|
57
53
|
};
|
|
58
|
-
|
|
59
|
-
body.access_type = 'offline';
|
|
60
|
-
body.client_id = client.clientId;
|
|
61
|
-
}
|
|
62
|
-
if (Wazo.Auth.mobile) {
|
|
63
|
-
headers['Wazo-Session-Type'] = 'mobile';
|
|
64
|
-
}
|
|
65
|
-
return client.post(`${baseUrl}/token`, body, headers).then(Session_1.default.parse);
|
|
54
|
+
return client.post(`${baseUrl}/token`, body).then(Session_1.default.parse);
|
|
66
55
|
}),
|
|
67
56
|
initiateIdpAuthentication: (domain, redirectUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
57
|
const body = {
|
|
@@ -73,7 +62,7 @@ exports.default = ((client, baseUrl) => ({
|
|
|
73
62
|
Accept: 'application/json',
|
|
74
63
|
'Content-Type': 'application/json',
|
|
75
64
|
};
|
|
76
|
-
return client.post(`${baseUrl}/saml/sso`, body, headers);
|
|
65
|
+
return client.post(`${baseUrl}/saml/sso`, body, headers, (response) => response);
|
|
77
66
|
}),
|
|
78
67
|
refreshToken: (refreshToken, backend, expiration, isMobile, tenantId, domainName) => {
|
|
79
68
|
const body = {
|
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
/* global MediaStream */
|
|
16
|
+
const sdp_1 = require("../../utils/sdp");
|
|
16
17
|
const web_rtc_client_1 = __importDefault(require("../../web-rtc-client"));
|
|
17
18
|
exports.default = {
|
|
18
19
|
name: 'WebRTC',
|
|
@@ -42,7 +43,7 @@ exports.default = {
|
|
|
42
43
|
});
|
|
43
44
|
client.on(client.REGISTERED, () => {
|
|
44
45
|
const sipSession = client.call('*10');
|
|
45
|
-
if (!sipSession || !
|
|
46
|
+
if (!sipSession || !(0, sdp_1.getSipSessionId)(sipSession)) {
|
|
46
47
|
return handleError('Unable to make call through WebRTC');
|
|
47
48
|
}
|
|
48
49
|
setTimeout(() => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class InvalidStateTransition extends Error {
|
|
4
|
+
constructor(message, action, state) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.action = action;
|
|
7
|
+
this.state = state;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = InvalidStateTransition;
|
|
@@ -18,6 +18,8 @@ const api_1 = require("sip.js/lib/api");
|
|
|
18
18
|
const CallSession_1 = __importDefault(require("../CallSession"));
|
|
19
19
|
const Emitter_1 = __importDefault(require("../../utils/Emitter"));
|
|
20
20
|
const IssueReporter_1 = __importDefault(require("../../service/IssueReporter"));
|
|
21
|
+
const sdp_1 = require("../../utils/sdp");
|
|
22
|
+
const webrtc_1 = require("../../utils/webrtc");
|
|
21
23
|
exports.ON_USER_AGENT = 'onUserAgent';
|
|
22
24
|
exports.ON_REGISTERED = 'onRegistered';
|
|
23
25
|
exports.ON_UNREGISTERED = 'onUnRegistered';
|
|
@@ -220,7 +222,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
220
222
|
id: callSession ? callSession.getId() : null,
|
|
221
223
|
withMessage,
|
|
222
224
|
});
|
|
223
|
-
|
|
225
|
+
(0, webrtc_1.downgradeToAudio)(sipSession);
|
|
224
226
|
if (callSession) {
|
|
225
227
|
callSession.cameraEnabled = false;
|
|
226
228
|
this._updateCallSession(callSession);
|
|
@@ -246,7 +248,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
246
248
|
const desktop = constraints && constraints.desktop;
|
|
247
249
|
const options = sipSession.sessionDescriptionHandlerOptionsReInvite;
|
|
248
250
|
const wasAudioOnly = options === null || options === void 0 ? void 0 : options.audioOnly;
|
|
249
|
-
const newStream = yield
|
|
251
|
+
const newStream = yield (0, webrtc_1.upgradeToVideo)(sipSession, constraints, isConference);
|
|
250
252
|
if (callSession) {
|
|
251
253
|
callSession.cameraEnabled = true;
|
|
252
254
|
this._updateCallSession(callSession);
|
|
@@ -280,16 +282,15 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
280
282
|
content: {
|
|
281
283
|
type: exports.ON_MESSAGE_TRACK_UPDATED,
|
|
282
284
|
update: isUpgrade ? 'upgrade' : 'downgrade',
|
|
283
|
-
sipCallId: sipSession &&
|
|
285
|
+
sipCallId: sipSession && (0, sdp_1.getSipSessionId)(sipSession),
|
|
284
286
|
callId: callSession ? callSession.callId : null,
|
|
285
287
|
number: callSession ? callSession.number : null,
|
|
286
|
-
callerNumber: callSession ? callSession.callerNumber : null,
|
|
287
288
|
},
|
|
288
289
|
}));
|
|
289
290
|
}, 2500);
|
|
290
291
|
}
|
|
291
292
|
_bindEvents(sipSession) {
|
|
292
|
-
const sipSessionId =
|
|
293
|
+
const sipSessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
293
294
|
if (sipSession instanceof api_1.Invitation) {
|
|
294
295
|
// Monkey patch to know when canceled with the CANCEL message
|
|
295
296
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
@@ -343,7 +344,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
343
344
|
const [stream] = event.streams;
|
|
344
345
|
const kind = event && event.track && event.track.kind;
|
|
345
346
|
logger.info('on track stream called on the peer connection', {
|
|
346
|
-
callId:
|
|
347
|
+
callId: (0, sdp_1.getSipSessionId)(sipSession),
|
|
347
348
|
streamId: stream ? stream.id : null,
|
|
348
349
|
tracks: stream ? stream.getTracks() : null,
|
|
349
350
|
kind,
|
|
@@ -367,15 +368,15 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
367
368
|
constraints,
|
|
368
369
|
id: callSession ? callSession.getId() : null,
|
|
369
370
|
});
|
|
370
|
-
const screenShareStream = yield
|
|
371
|
+
const screenShareStream = yield (0, webrtc_1.getStreamFromConstraints)(constraints);
|
|
371
372
|
if (!screenShareStream) {
|
|
372
373
|
throw new Error(`Can't create media stream for screensharing with: ${JSON.stringify(constraints)}`);
|
|
373
374
|
}
|
|
374
375
|
const screenTrack = screenShareStream.getVideoTracks()[0];
|
|
375
376
|
const sipSession = this.currentSipSession;
|
|
376
|
-
const pc = sipSession && this.client.getPeerConnection(
|
|
377
|
+
const pc = sipSession && this.client.getPeerConnection((0, sdp_1.getSipSessionId)(sipSession));
|
|
377
378
|
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
378
|
-
const localStream = sipSession && this.client.getLocalStream(
|
|
379
|
+
const localStream = sipSession && this.client.getLocalStream((0, sdp_1.getSipSessionId)(sipSession));
|
|
379
380
|
const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
|
|
380
381
|
const hadVideo = !!videoTrack;
|
|
381
382
|
// Stop local video tracks
|
|
@@ -440,19 +441,19 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
440
441
|
}
|
|
441
442
|
_onScreenSharing(screenStream, sipSession, callSession, hadVideo, desktop) {
|
|
442
443
|
const screenTrack = screenStream.getVideoTracks()[0];
|
|
443
|
-
const sipSessionId =
|
|
444
|
+
const sipSessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
444
445
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
445
446
|
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
446
447
|
logger.info('WebRTC phone - on screensharing', {
|
|
447
448
|
hadVideo,
|
|
448
|
-
id:
|
|
449
|
+
id: (0, sdp_1.getSipSessionId)(sipSession),
|
|
449
450
|
screenTrack,
|
|
450
451
|
});
|
|
451
452
|
if (screenTrack) {
|
|
452
453
|
screenTrack.onended = () => {
|
|
453
454
|
logger.info('WebRTC phone - on screenshare ended', {
|
|
454
455
|
hadVideo,
|
|
455
|
-
id:
|
|
456
|
+
id: (0, sdp_1.getSipSessionId)(sipSession),
|
|
456
457
|
screenTrack,
|
|
457
458
|
});
|
|
458
459
|
this.eventEmitter.emit(exports.ON_SHARE_SCREEN_ENDING, this._createCallSession(sipSession, callSession));
|
|
@@ -465,7 +466,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
465
466
|
sipSessionId,
|
|
466
467
|
desktop,
|
|
467
468
|
};
|
|
468
|
-
|
|
469
|
+
(0, webrtc_1.setLocalMediaStream)(sipSession, screenStream);
|
|
469
470
|
this.eventEmitter.emit(exports.ON_SHARE_SCREEN_STARTED, this._createCallSession(sipSession, callSession, {
|
|
470
471
|
screensharing: true,
|
|
471
472
|
}), screenStream);
|
|
@@ -486,7 +487,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
486
487
|
this.currentSipSession = sipSession;
|
|
487
488
|
this.currentCallSession = callSession;
|
|
488
489
|
this.eventEmitter.emit(exports.ON_TERMINATE_SOUND, callSession, 'call accepted');
|
|
489
|
-
const sipSessionId =
|
|
490
|
+
const sipSessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
490
491
|
if (sipSessionId) {
|
|
491
492
|
this.removeIncomingSessions(sipSessionId);
|
|
492
493
|
}
|
|
@@ -549,7 +550,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
549
550
|
return this.currentSipSession && this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
550
551
|
}
|
|
551
552
|
_onCallTerminated(sipSession) {
|
|
552
|
-
const sipSessionId =
|
|
553
|
+
const sipSessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
553
554
|
logger.info('WebRTC phone - on call terminated', {
|
|
554
555
|
sipId: sipSession.id,
|
|
555
556
|
sipSessionId,
|
|
@@ -641,7 +642,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
641
642
|
if (!this.currentSipSession) {
|
|
642
643
|
return false;
|
|
643
644
|
}
|
|
644
|
-
return this.currentSipSession &&
|
|
645
|
+
return this.currentSipSession && (0, sdp_1.getSipSessionId)(this.currentSipSession) === callSession.getId();
|
|
645
646
|
}
|
|
646
647
|
hasVideo(callSession) {
|
|
647
648
|
return this.client.hasVideo(callSession.getId());
|
|
@@ -799,7 +800,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
799
800
|
if (!sipSession) {
|
|
800
801
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
801
802
|
}
|
|
802
|
-
const sessionId =
|
|
803
|
+
const sessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
803
804
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
804
805
|
logger.info('WebRTC hold sip session', {
|
|
805
806
|
sipId: sipSession.id,
|
|
@@ -812,7 +813,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
812
813
|
}
|
|
813
814
|
// Downgrade to audio if needed
|
|
814
815
|
if (hasVideo) {
|
|
815
|
-
yield
|
|
816
|
+
yield (0, webrtc_1.downgradeToAudio)(sipSession);
|
|
816
817
|
}
|
|
817
818
|
const isConference = !!callSession && callSession.isConference();
|
|
818
819
|
const promise = this.client.hold(sipSession, isConference, hasVideo);
|
|
@@ -828,7 +829,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
828
829
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
829
830
|
}
|
|
830
831
|
const isConference = !!callSession && callSession.isConference();
|
|
831
|
-
const sessionId =
|
|
832
|
+
const sessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
832
833
|
logger.info('WebRTC unhold sip session', {
|
|
833
834
|
sessionId,
|
|
834
835
|
isConference,
|
|
@@ -844,7 +845,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
844
845
|
screen: wasScreensharing,
|
|
845
846
|
desktop: wasDesktop,
|
|
846
847
|
};
|
|
847
|
-
yield
|
|
848
|
+
yield (0, webrtc_1.upgradeToVideo)(sipSession, constraints, isConference);
|
|
848
849
|
}
|
|
849
850
|
const onScreenSharing = (stream) => {
|
|
850
851
|
const hadVideo = this.lastScreenShare && this.lastScreenShare.hadVideo;
|
|
@@ -1057,7 +1058,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1057
1058
|
console.error('Call is unknown to the WebRTC phone', callSession ? callSession.sipCallId : null, callSession ? callSession.callId : null);
|
|
1058
1059
|
return false;
|
|
1059
1060
|
}
|
|
1060
|
-
const sipSessionId =
|
|
1061
|
+
const sipSessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
1061
1062
|
logger.info('WebRTC hangup', {
|
|
1062
1063
|
sipId: sipSession.id,
|
|
1063
1064
|
sipSessionId,
|
|
@@ -1077,7 +1078,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1077
1078
|
getStats(callSession) {
|
|
1078
1079
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1079
1080
|
const sipSession = this.findSipSession(callSession);
|
|
1080
|
-
return sipSession ?
|
|
1081
|
+
return sipSession ? (0, webrtc_1.getWebRtcStats)(sipSession) : null;
|
|
1081
1082
|
});
|
|
1082
1083
|
}
|
|
1083
1084
|
startNetworkMonitoring(callSession, interval = 1000) {
|
|
@@ -1249,12 +1250,12 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1249
1250
|
// if `_createCallSession` is called too soon `hasVideo` will return false because the stream doesn't exists yet
|
|
1250
1251
|
setTimeout(() => {
|
|
1251
1252
|
// Update callSession
|
|
1252
|
-
this._createCallSession(sipSession, this.callSessions[
|
|
1253
|
+
this._createCallSession(sipSession, this.callSessions[(0, sdp_1.getSipSessionId)(sipSession)]);
|
|
1253
1254
|
this.eventEmitter.emit.apply(this.eventEmitter, [this.client.ON_REINVITE, ...args]);
|
|
1254
1255
|
}, 2000);
|
|
1255
1256
|
});
|
|
1256
1257
|
this.client.on(this.client.ACCEPTED, (sipSession) => __awaiter(this, void 0, void 0, function* () {
|
|
1257
|
-
const sessionId =
|
|
1258
|
+
const sessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
1258
1259
|
const hasSession = (sessionId in this.callSessions);
|
|
1259
1260
|
logger.info('WebRTC call accepted', {
|
|
1260
1261
|
sipId: sessionId,
|
|
@@ -1281,7 +1282,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1281
1282
|
const callSession = this._createCallSession(session);
|
|
1282
1283
|
// `_createCallSession` add the CallSession in `this.callSessions`.
|
|
1283
1284
|
// so we have to remove it or `callCount` will always return 1 even if the call was rejected
|
|
1284
|
-
delete this.callSessions[
|
|
1285
|
+
delete this.callSessions[(0, sdp_1.getSipSessionId)(session)];
|
|
1285
1286
|
callSession.endTime = new Date();
|
|
1286
1287
|
this.eventEmitter.emit(exports.ON_CALL_REJECTED, callSession);
|
|
1287
1288
|
});
|
|
@@ -1298,7 +1299,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1298
1299
|
const callSession = this._createCallSession(session, null, {
|
|
1299
1300
|
incoming: false,
|
|
1300
1301
|
ringing: true,
|
|
1301
|
-
callId:
|
|
1302
|
+
callId: (0, sdp_1.getSipSessionId)(session),
|
|
1302
1303
|
});
|
|
1303
1304
|
this.eventEmitter.emit(exports.ON_PROGRESS, callSession, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
1304
1305
|
});
|
|
@@ -1307,7 +1308,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1307
1308
|
const callSession = this._createCallSession(session, null, {
|
|
1308
1309
|
incoming: false,
|
|
1309
1310
|
ringing: true,
|
|
1310
|
-
callId:
|
|
1311
|
+
callId: (0, sdp_1.getSipSessionId)(session),
|
|
1311
1312
|
});
|
|
1312
1313
|
this.eventEmitter.emit(exports.ON_EARLY_MEDIA, callSession, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
1313
1314
|
});
|
|
@@ -1364,12 +1365,12 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1364
1365
|
this.eventEmitter.emit(exports.ON_MESSAGE, message);
|
|
1365
1366
|
});
|
|
1366
1367
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
1367
|
-
const callSession = this.getCallSession(
|
|
1368
|
+
const callSession = this.getCallSession((0, sdp_1.getSipSessionId)(session));
|
|
1368
1369
|
this.eventEmitter.emit(exports.ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
1369
1370
|
});
|
|
1370
1371
|
// Used when upgrading directly in screenshare mode
|
|
1371
1372
|
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession, response, desktop) => {
|
|
1372
|
-
const sipSessionId =
|
|
1373
|
+
const sipSessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
1373
1374
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
1374
1375
|
const callSession = this.callSessions[sipSessionId];
|
|
1375
1376
|
logger.info('Updrading directly in screensharing mode', {
|
|
@@ -1384,7 +1385,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1384
1385
|
const keys = this.client.getSipSessionIds();
|
|
1385
1386
|
const keyIndex = keys.findIndex(sessionId => callSession && callSession.isId(sessionId));
|
|
1386
1387
|
if (keyIndex === -1) {
|
|
1387
|
-
const currentSipSessionId = this.currentSipSession ?
|
|
1388
|
+
const currentSipSessionId = this.currentSipSession ? (0, sdp_1.getSipSessionId)(this.currentSipSession) : this.client.getSipSessionIds()[0];
|
|
1388
1389
|
return currentSipSessionId ? this.client.getSipSession(currentSipSessionId) : null;
|
|
1389
1390
|
}
|
|
1390
1391
|
return this.client.getSipSession(keys[keyIndex]);
|
|
@@ -1392,12 +1393,9 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1392
1393
|
getCallSession(sipSessionId) {
|
|
1393
1394
|
return this.callSessions[sipSessionId];
|
|
1394
1395
|
}
|
|
1395
|
-
getSipSessionId(sipSession) {
|
|
1396
|
-
return this.client.getSipSessionId(sipSession);
|
|
1397
|
-
}
|
|
1398
1396
|
getSipSessionIdFromCallSession(callSession) {
|
|
1399
1397
|
const sipSession = this.findSipSession(callSession);
|
|
1400
|
-
return sipSession ?
|
|
1398
|
+
return sipSession ? (0, sdp_1.getSipSessionId)(sipSession) : null;
|
|
1401
1399
|
}
|
|
1402
1400
|
_updateCallSession(callSession) {
|
|
1403
1401
|
const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
|
|
@@ -1475,7 +1473,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1475
1473
|
// @ts-ignore: private
|
|
1476
1474
|
const number = identity ? identity.uri._normal.user : null;
|
|
1477
1475
|
const { state, } = sipSession || {};
|
|
1478
|
-
const sessionId =
|
|
1476
|
+
const sessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
1479
1477
|
fromSession = fromSession || this.callSessions[sessionId];
|
|
1480
1478
|
const callSession = new CallSession_1.default(Object.assign({ callId: fromSession && fromSession.callId, sipCallId: sessionId, sipStatus: state, displayName: identity ? identity.displayName || number : number,
|
|
1481
1479
|
// @ts-ignore: date / number
|
package/lib/simple/Auth.js
CHANGED
|
@@ -156,19 +156,25 @@ class Auth {
|
|
|
156
156
|
}
|
|
157
157
|
initiateIdpAuthentication(domain, redirectUrl) {
|
|
158
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
let response;
|
|
159
160
|
try {
|
|
160
|
-
|
|
161
|
+
response = yield (0, getApiClient_1.default)().auth.initiateIdpAuthentication(domain, redirectUrl);
|
|
161
162
|
}
|
|
162
163
|
catch (e) {
|
|
163
|
-
logger.error('Error during IdP authentication
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
logger.error('Error during IdP authentication initiation:', e.message);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (!response.ok) {
|
|
168
|
+
if (response.status === 404) {
|
|
169
|
+
throw new NoSamlRouteError('No route found for saml sso');
|
|
166
170
|
}
|
|
167
|
-
if (
|
|
171
|
+
if (response.status === 500) {
|
|
168
172
|
throw new SamlConfigError('SAML/server configuration error');
|
|
169
173
|
}
|
|
170
|
-
|
|
174
|
+
const error = yield response.json();
|
|
175
|
+
throw new Error(error.message || error.reason);
|
|
171
176
|
}
|
|
177
|
+
return response.json();
|
|
172
178
|
});
|
|
173
179
|
}
|
|
174
180
|
logInViaRefreshToken(refreshToken) {
|
package/lib/simple/Phone.js
CHANGED
|
@@ -45,6 +45,7 @@ const IssueReporter_1 = __importDefault(require("../service/IssueReporter"));
|
|
|
45
45
|
const Emitter_1 = __importDefault(require("../utils/Emitter"));
|
|
46
46
|
const index_1 = __importDefault(require("./index"));
|
|
47
47
|
const SFUNotAvailableError_1 = __importDefault(require("../domain/SFUNotAvailableError"));
|
|
48
|
+
const sdp_1 = require("../utils/sdp");
|
|
48
49
|
const logger = IssueReporter_1.default.loggerFor('simple-phone');
|
|
49
50
|
const sipLogger = IssueReporter_1.default.loggerFor('sip.js');
|
|
50
51
|
const protocolLogger = IssueReporter_1.default.loggerFor('sip');
|
|
@@ -239,7 +240,7 @@ class Phone extends Emitter_1.default {
|
|
|
239
240
|
if (!sipSession || !this.phone) {
|
|
240
241
|
return null;
|
|
241
242
|
}
|
|
242
|
-
return
|
|
243
|
+
return (0, sdp_1.getSipSessionId)(sipSession);
|
|
243
244
|
}
|
|
244
245
|
sendMessage(body, sipSession, contentType = 'text/plain') {
|
|
245
246
|
const toSipSession = sipSession || this.getCurrentSipSession();
|