@signalwire/js 1.2.5-beta.1 → 1.2.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.
Files changed (38) hide show
  1. package/README.md +4 -2
  2. package/dist/esm/common/src/BaseSession.d.ts +2 -1
  3. package/dist/esm/common/src/BaseSession.js +15 -6
  4. package/dist/esm/common/src/BrowserSession.d.ts +4 -3
  5. package/dist/esm/common/src/BrowserSession.js +9 -4
  6. package/dist/esm/common/src/messages/Verto.d.ts +1 -1
  7. package/dist/esm/common/src/messages/Verto.js +1 -1
  8. package/dist/esm/common/src/services/Connection.js +3 -3
  9. package/dist/esm/common/src/util/constants/index.d.ts +0 -44
  10. package/dist/esm/common/src/util/constants/index.js +0 -49
  11. package/dist/esm/common/src/util/helpers.d.ts +1 -0
  12. package/dist/esm/common/src/util/helpers.js +3 -0
  13. package/dist/esm/common/src/util/interfaces.d.ts +47 -38
  14. package/dist/esm/common/src/webrtc/BaseCall.d.ts +3 -4
  15. package/dist/esm/common/src/webrtc/BaseCall.js +2 -2
  16. package/dist/esm/common/src/webrtc/Call.d.ts +1 -1
  17. package/dist/esm/common/src/webrtc/CantinaAuth.d.ts +22 -0
  18. package/dist/esm/common/src/webrtc/CantinaAuth.js +68 -0
  19. package/dist/esm/common/src/webrtc/LayoutHandler.js +2 -2
  20. package/dist/esm/common/src/webrtc/Peer.d.ts +2 -2
  21. package/dist/esm/common/src/webrtc/Peer.js +3 -2
  22. package/dist/esm/common/src/webrtc/VertoHandler.js +3 -2
  23. package/dist/esm/common/src/webrtc/constants.d.ts +74 -0
  24. package/dist/esm/common/src/{util/constants/call.js → webrtc/constants.js} +43 -3
  25. package/dist/esm/common/src/webrtc/helpers.d.ts +2 -2
  26. package/dist/esm/common/src/webrtc/helpers.js +9 -15
  27. package/dist/esm/common/src/webrtc/interfaces.d.ts +87 -0
  28. package/dist/esm/common/src/webrtc/interfaces.js +0 -0
  29. package/dist/esm/js/index.d.ts +4 -2
  30. package/dist/esm/js/index.js +3 -2
  31. package/dist/esm/js/src/SignalWire.d.ts +1 -1
  32. package/dist/esm/js/src/Verto.d.ts +3 -1
  33. package/dist/esm/js/src/Verto.js +5 -0
  34. package/dist/index.min.js +2 -2
  35. package/package.json +15 -15
  36. package/CHANGELOG.md +0 -101
  37. package/dist/.DS_Store +0 -0
  38. package/dist/esm/common/src/util/constants/call.d.ts +0 -35
@@ -11,9 +11,10 @@ import logger from '../util/logger';
11
11
  import Call from './Call';
12
12
  import { checkSubscribeResponse } from './helpers';
13
13
  import { Result } from '../messages/Verto';
14
- import { SwEvent, VertoMethod, NOTIFICATION_TYPE } from '../util/constants';
14
+ import { SwEvent } from '../util/constants';
15
+ import { VertoMethod, NOTIFICATION_TYPE } from './constants';
15
16
  import { trigger, deRegister } from '../services/Handler';
16
- import { State, ConferenceAction } from '../util/constants/call';
17
+ import { State, ConferenceAction } from './constants';
17
18
  import { MCULayoutEventHandler } from './LayoutHandler';
18
19
  class VertoHandler {
19
20
  constructor(session) {
@@ -0,0 +1,74 @@
1
+ import { CallOptions } from './interfaces';
2
+ export declare enum PeerType {
3
+ Offer = "offer",
4
+ Answer = "answer"
5
+ }
6
+ export declare enum Direction {
7
+ Inbound = "inbound",
8
+ Outbound = "outbound"
9
+ }
10
+ export declare enum VertoMethod {
11
+ Invite = "verto.invite",
12
+ Attach = "verto.attach",
13
+ Answer = "verto.answer",
14
+ Info = "verto.info",
15
+ Display = "verto.display",
16
+ Media = "verto.media",
17
+ Event = "verto.event",
18
+ Bye = "verto.bye",
19
+ Punt = "verto.punt",
20
+ Broadcast = "verto.broadcast",
21
+ Subscribe = "verto.subscribe",
22
+ Unsubscribe = "verto.unsubscribe",
23
+ ClientReady = "verto.clientReady",
24
+ Modify = "verto.modify"
25
+ }
26
+ export declare const NOTIFICATION_TYPE: {
27
+ generic: string;
28
+ "verto.display": string;
29
+ "verto.attach": string;
30
+ conferenceUpdate: string;
31
+ callUpdate: string;
32
+ vertoClientReady: string;
33
+ userMediaError: string;
34
+ refreshToken: string;
35
+ };
36
+ export declare const DEFAULT_CALL_OPTIONS: CallOptions;
37
+ export declare enum State {
38
+ New = 0,
39
+ Requesting = 1,
40
+ Trying = 2,
41
+ Recovering = 3,
42
+ Ringing = 4,
43
+ Answering = 5,
44
+ Early = 6,
45
+ Active = 7,
46
+ Held = 8,
47
+ Hangup = 9,
48
+ Destroy = 10,
49
+ Purge = 11
50
+ }
51
+ export declare enum Role {
52
+ Participant = "participant",
53
+ Moderator = "moderator"
54
+ }
55
+ export declare enum ConferenceAction {
56
+ Join = "join",
57
+ Leave = "leave",
58
+ Bootstrap = "bootstrap",
59
+ Add = "add",
60
+ Modify = "modify",
61
+ Delete = "delete",
62
+ Clear = "clear",
63
+ ChatMessage = "chatMessage",
64
+ LayerInfo = "layerInfo",
65
+ LogoInfo = "logoInfo",
66
+ LayoutInfo = "layoutInfo",
67
+ LayoutList = "layoutList",
68
+ ModCmdResponse = "modCommandResponse"
69
+ }
70
+ export declare enum DeviceType {
71
+ Video = "videoinput",
72
+ AudioIn = "audioinput",
73
+ AudioOut = "audiooutput"
74
+ }
@@ -1,3 +1,40 @@
1
+ export var PeerType;
2
+ (function (PeerType) {
3
+ PeerType["Offer"] = "offer";
4
+ PeerType["Answer"] = "answer";
5
+ })(PeerType || (PeerType = {}));
6
+ export var Direction;
7
+ (function (Direction) {
8
+ Direction["Inbound"] = "inbound";
9
+ Direction["Outbound"] = "outbound";
10
+ })(Direction || (Direction = {}));
11
+ export var VertoMethod;
12
+ (function (VertoMethod) {
13
+ VertoMethod["Invite"] = "verto.invite";
14
+ VertoMethod["Attach"] = "verto.attach";
15
+ VertoMethod["Answer"] = "verto.answer";
16
+ VertoMethod["Info"] = "verto.info";
17
+ VertoMethod["Display"] = "verto.display";
18
+ VertoMethod["Media"] = "verto.media";
19
+ VertoMethod["Event"] = "verto.event";
20
+ VertoMethod["Bye"] = "verto.bye";
21
+ VertoMethod["Punt"] = "verto.punt";
22
+ VertoMethod["Broadcast"] = "verto.broadcast";
23
+ VertoMethod["Subscribe"] = "verto.subscribe";
24
+ VertoMethod["Unsubscribe"] = "verto.unsubscribe";
25
+ VertoMethod["ClientReady"] = "verto.clientReady";
26
+ VertoMethod["Modify"] = "verto.modify";
27
+ })(VertoMethod || (VertoMethod = {}));
28
+ export const NOTIFICATION_TYPE = {
29
+ generic: 'event',
30
+ [VertoMethod.Display]: 'participantData',
31
+ [VertoMethod.Attach]: 'participantData',
32
+ conferenceUpdate: 'conferenceUpdate',
33
+ callUpdate: 'callUpdate',
34
+ vertoClientReady: 'vertoClientReady',
35
+ userMediaError: 'userMediaError',
36
+ refreshToken: 'refreshToken',
37
+ };
1
38
  export const DEFAULT_CALL_OPTIONS = {
2
39
  destinationNumber: '',
3
40
  remoteCallerName: 'Outbound Call',
@@ -10,9 +47,6 @@ export const DEFAULT_CALL_OPTIONS = {
10
47
  attach: false,
11
48
  screenShare: false,
12
49
  userVariables: {},
13
- googleMaxBitrate: 2048,
14
- googleMinBitrate: 0,
15
- googleStartBitrate: 1024,
16
50
  };
17
51
  export var State;
18
52
  (function (State) {
@@ -50,3 +84,9 @@ export var ConferenceAction;
50
84
  ConferenceAction["LayoutList"] = "layoutList";
51
85
  ConferenceAction["ModCmdResponse"] = "modCommandResponse";
52
86
  })(ConferenceAction || (ConferenceAction = {}));
87
+ export var DeviceType;
88
+ (function (DeviceType) {
89
+ DeviceType["Video"] = "videoinput";
90
+ DeviceType["AudioIn"] = "audioinput";
91
+ DeviceType["AudioOut"] = "audiooutput";
92
+ })(DeviceType || (DeviceType = {}));
@@ -1,6 +1,6 @@
1
- import { CallOptions } from '../util/interfaces';
1
+ import { CallOptions } from './interfaces';
2
2
  declare const getUserMedia: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
3
- declare const getDevices: (kind?: string) => Promise<MediaDeviceInfo[]>;
3
+ declare const getDevices: (kind?: string, fullList?: boolean) => Promise<MediaDeviceInfo[]>;
4
4
  declare const scanResolutions: (deviceId: string) => Promise<any[]>;
5
5
  declare const getMediaConstraints: (options: CallOptions) => Promise<MediaStreamConstraints>;
6
6
  declare const assureDeviceId: (id: string, label: string, kind: MediaDeviceKind) => Promise<string>;
@@ -10,8 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import logger from '../util/logger';
11
11
  import * as WebRTC from '../util/webrtc';
12
12
  import { isDefined } from '../util/helpers';
13
- import { stopStream } from '../util/webrtc';
14
- import { DeviceType } from '../util/constants';
13
+ import { DeviceType } from './constants';
15
14
  const getUserMedia = (constraints) => __awaiter(void 0, void 0, void 0, function* () {
16
15
  logger.info('RTCService.getUserMedia', constraints);
17
16
  const { audio, video } = constraints;
@@ -32,17 +31,20 @@ const _constraintsByKind = (kind = null) => {
32
31
  video: !kind || kind === DeviceType.Video
33
32
  };
34
33
  };
35
- const getDevices = (kind = null) => __awaiter(void 0, void 0, void 0, function* () {
34
+ const getDevices = (kind = null, fullList = false) => __awaiter(void 0, void 0, void 0, function* () {
36
35
  let devices = yield WebRTC.enumerateDevices().catch(error => []);
37
36
  if (kind) {
38
37
  devices = devices.filter((d) => d.kind === kind);
39
38
  }
40
- const invalid = devices.length && devices.every((d) => (!d.deviceId || !d.label));
41
- if (invalid) {
39
+ const valid = devices.length && devices.every((d) => (d.deviceId && d.label));
40
+ if (!valid) {
42
41
  const stream = yield WebRTC.getUserMedia(_constraintsByKind(kind));
43
42
  WebRTC.stopStream(stream);
44
43
  return getDevices(kind);
45
44
  }
45
+ if (fullList === true) {
46
+ return devices;
47
+ }
46
48
  const found = [];
47
49
  devices = devices.filter(({ kind, groupId }) => {
48
50
  if (!groupId) {
@@ -71,7 +73,7 @@ const scanResolutions = (deviceId) => __awaiter(void 0, void 0, void 0, function
71
73
  supported.push({ resolution: `${width}x${height}`, width, height });
72
74
  }
73
75
  }
74
- stopStream(stream);
76
+ WebRTC.stopStream(stream);
75
77
  return supported;
76
78
  });
77
79
  const getMediaConstraints = (options) => __awaiter(void 0, void 0, void 0, function* () {
@@ -100,15 +102,7 @@ const getMediaConstraints = (options) => __awaiter(void 0, void 0, void 0, funct
100
102
  return { audio, video };
101
103
  });
102
104
  const assureDeviceId = (id, label, kind) => __awaiter(void 0, void 0, void 0, function* () {
103
- const devices = yield WebRTC.enumerateDevices()
104
- .catch(error => [])
105
- .then(all => all.filter((d) => d.kind === kind));
106
- const invalid = devices.length && devices.every((d) => (!d.deviceId || !d.label));
107
- if (invalid) {
108
- const stream = yield WebRTC.getUserMedia(_constraintsByKind(kind));
109
- WebRTC.stopStream(stream);
110
- return assureDeviceId(id, label, kind);
111
- }
105
+ const devices = yield getDevices(kind, true);
112
106
  for (let i = 0; i < devices.length; i++) {
113
107
  const { deviceId, label: deviceLabel } = devices[i];
114
108
  if (id === deviceId || label === deviceLabel) {
@@ -0,0 +1,87 @@
1
+ export interface CallOptions {
2
+ destinationNumber: string;
3
+ remoteCallerName: string;
4
+ remoteCallerNumber: string;
5
+ callerName: string;
6
+ callerNumber: string;
7
+ id?: string;
8
+ remoteSdp?: string;
9
+ localStream?: MediaStream;
10
+ remoteStream?: MediaStream;
11
+ localElement?: HTMLMediaElement | string | Function;
12
+ remoteElement?: HTMLMediaElement | string | Function;
13
+ iceServers?: RTCIceServer[];
14
+ audio?: boolean | MediaTrackConstraints;
15
+ video?: boolean | MediaTrackConstraints;
16
+ attach?: boolean;
17
+ useStereo?: boolean;
18
+ micId?: string;
19
+ micLabel?: string;
20
+ camId?: string;
21
+ camLabel?: string;
22
+ speakerId?: string;
23
+ userVariables?: Object;
24
+ screenShare?: boolean;
25
+ onNotification?: Function;
26
+ googleMaxBitrate?: number;
27
+ googleMinBitrate?: number;
28
+ googleStartBitrate?: number;
29
+ }
30
+ export interface IWebRTCCall {
31
+ id: string;
32
+ state: string;
33
+ prevState: string;
34
+ direction: string;
35
+ options: CallOptions;
36
+ cause: string;
37
+ causeCode: number;
38
+ channels: string[];
39
+ role: string;
40
+ extension: string;
41
+ localStream: MediaStream;
42
+ remoteStream: MediaStream;
43
+ invite: () => void;
44
+ answer: () => void;
45
+ hangup: (params: any, execute: boolean) => void;
46
+ transfer: (destination: string) => void;
47
+ replace: (replaceCallID: string) => void;
48
+ hold: () => void;
49
+ unhold: () => void;
50
+ toggleHold: () => void;
51
+ dtmf: (dtmf: string) => void;
52
+ message: (to: string, body: string) => void;
53
+ muteAudio: () => void;
54
+ unmuteAudio: () => void;
55
+ toggleAudioMute: () => void;
56
+ setAudioInDevice: (deviceId: string) => Promise<void>;
57
+ muteVideo: () => void;
58
+ unmuteVideo: () => void;
59
+ toggleVideoMute: () => void;
60
+ setVideoDevice: (deviceId: string) => Promise<void>;
61
+ deaf: () => void;
62
+ undeaf: () => void;
63
+ toggleDeaf: () => void;
64
+ setState: (state: any) => void;
65
+ handleMessage: (msg: any) => void;
66
+ _addChannel: (laChannel: any) => void;
67
+ handleConferenceUpdate: (packet: any, pvtData: any) => Promise<string>;
68
+ startScreenShare?: (opts?: object) => Promise<IWebRTCCall>;
69
+ stopScreenShare?: () => void;
70
+ setAudioOutDevice?: (deviceId: string) => Promise<boolean>;
71
+ switchCamera?: () => void;
72
+ setSpeakerPhone?: (flag: boolean) => void;
73
+ }
74
+ export interface ICantinaAuthParams {
75
+ hostname?: string;
76
+ }
77
+ export interface ICantinaUser {
78
+ first_name: string;
79
+ last_name: string;
80
+ email: string;
81
+ phone: string;
82
+ avatar: string;
83
+ project: string;
84
+ jwt_token: string;
85
+ scopes: string[];
86
+ config?: object;
87
+ }
File without changes
@@ -1,4 +1,6 @@
1
1
  import Relay from './src/SignalWire';
2
2
  import Verto from './src/Verto';
3
- export declare const VERSION = "1.2.5-beta.1";
4
- export { Relay, Verto };
3
+ import CantinaAuth from '../common/src/webrtc/CantinaAuth';
4
+ export declare const VERSION = "1.2.8";
5
+ export { Relay, Verto, CantinaAuth };
6
+ export * from '../common/src/util/interfaces';
@@ -1,6 +1,7 @@
1
1
  import Relay from './src/SignalWire';
2
2
  import Verto from './src/Verto';
3
3
  import { setAgentName } from '../common/src/messages/blade/Connect';
4
- export const VERSION = '1.2.5-beta.1';
4
+ import CantinaAuth from '../common/src/webrtc/CantinaAuth';
5
+ export const VERSION = '1.2.8';
5
6
  setAgentName(`JavaScript SDK/${VERSION}`);
6
- export { Relay, Verto };
7
+ export { Relay, Verto, CantinaAuth };
@@ -1,6 +1,6 @@
1
1
  import BrowserSession from '../../common/src/BrowserSession';
2
2
  import BaseMessage from '../../common/src/messages/BaseMessage';
3
- import { CallOptions } from '../../common/src/util/interfaces';
3
+ import { CallOptions } from '../../common/src/webrtc/interfaces';
4
4
  import Call from '../../common/src/webrtc/Call';
5
5
  export default class SignalWire extends BrowserSession {
6
6
  execute(message: BaseMessage): any;
@@ -1,9 +1,11 @@
1
1
  import BrowserSession from '../../common/src/BrowserSession';
2
- import { SubscribeParams, BroadcastParams, CallOptions } from '../../common/src/util/interfaces';
2
+ import { SubscribeParams, BroadcastParams } from '../../common/src/util/interfaces';
3
+ import { CallOptions } from '../../common/src/webrtc/interfaces';
3
4
  import Call from '../../common/src/webrtc/Call';
4
5
  export declare const VERTO_PROTOCOL = "verto-protocol";
5
6
  export default class Verto extends BrowserSession {
6
7
  relayProtocol: string;
8
+ timeoutErrorCode: number;
7
9
  validateOptions(): boolean;
8
10
  newCall(options: CallOptions): Call;
9
11
  broadcast(params: BroadcastParams): void;
@@ -19,6 +19,7 @@ export default class Verto extends BrowserSession {
19
19
  constructor() {
20
20
  super(...arguments);
21
21
  this.relayProtocol = VERTO_PROTOCOL;
22
+ this.timeoutErrorCode = -329990;
22
23
  }
23
24
  validateOptions() {
24
25
  const { host, login, passwd, password } = this.options;
@@ -46,6 +47,10 @@ export default class Verto extends BrowserSession {
46
47
  return __awaiter(this, void 0, void 0, function* () {
47
48
  this._idle = false;
48
49
  const { login, password, passwd, userVariables } = this.options;
50
+ if (this.sessionid) {
51
+ const sessidLogin = new Login(undefined, undefined, this.sessionid, undefined);
52
+ yield this.execute(sessidLogin).catch(console.error);
53
+ }
49
54
  const msg = new Login(login, (password || passwd), this.sessionid, userVariables);
50
55
  const response = yield this.execute(msg).catch(this._handleLoginError);
51
56
  if (response) {