@exotel-npm-dev/webrtc-client-sdk 1.0.2 → 1.0.4

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.
@@ -0,0 +1 @@
1
+ export default __webpack_public_path__ + "9b002be293af5cfbf781cfd215e3ea86.wav";
@@ -0,0 +1 @@
1
+ export default __webpack_public_path__ + "c79bd9a78f9efa815c0f1b4a5db3a98b.wav";
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@exotel-npm-dev/webrtc-client-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "client sdk for webrtc based on webrtc core sdk",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "webpack --config webpack.config.js"
8
9
  },
9
10
  "repository": {
10
11
  "type": "git",
@@ -21,5 +22,13 @@
21
22
  "homepage": "https://bitbucket.org/Exotel/webrtc#readme",
22
23
  "dependencies": {
23
24
  "@exotel-npm-dev/webrtc-core-sdk": "^1.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "babel-loader": "^8.2.5",
28
+ "circular-dependency-plugin": "^5.2.2",
29
+ "file-loader": "^6.2.0",
30
+ "uuid": "^9.0.0",
31
+ "webpack": "^5.74.0",
32
+ "webpack-cli": "^4.10.0"
24
33
  }
25
34
  }
@@ -87,7 +87,7 @@ export function ExDelegationHandler(exClient_) {
87
87
  if (sipMethod == "CONNECTION") {
88
88
  exClient.registerEventCallback(eventType, exClient.userName)
89
89
  } else if (sipMethod == "CALL") {
90
- exClient.callEventCallback(eventType, exClient.userName,exClient.call)
90
+ exClient.callEventCallback(eventType, exClient.callFromNumber,exClient.call)
91
91
  }
92
92
  }
93
93
 
@@ -155,8 +155,9 @@ export function ExDelegationHandler(exClient_) {
155
155
  logger.log("delegationHandler: stopCallStat\n");
156
156
  }
157
157
 
158
- this.onRecieveInvite = function() {
158
+ this.onRecieveInvite = function(incomingSession) {
159
159
  logger.log("delegationHandler: onRecieveInvite\n");
160
+ exClient.callFromNumber = incomingSession.incomingInviteRequest.message.from.displayName;
160
161
  }
161
162
 
162
163
  this.onPickCall = function() {
@@ -195,119 +196,120 @@ export function ExSynchronousHandler() {
195
196
  }
196
197
  }
197
198
 
198
- export const ExotelWebClient = {
199
+ export class ExotelWebClient {
199
200
 
200
201
 
201
202
 
202
- ctrlr : null,
203
- call : null,
204
- eventListener : null,
205
- callListener : null,
203
+ ctrlr = null;
204
+ call = null;
205
+ eventListener = null;
206
+ callListener = null;
207
+ callFromNumber = null;
206
208
  /* OLD-Way to be revisited for multile phone support */
207
209
  //this.webRTCPhones = {};
208
210
 
209
- sipAccountInfo : null,
211
+ sipAccountInfo = null;
210
212
 
211
- initWebrtc : (sipAccountInfo_,
213
+ initWebrtc = (sipAccountInfo_,
212
214
  RegisterEventCallBack, CallListenerCallback, SessionCallback) => {
213
215
 
214
- if (!ExotelWebClient.eventListener) {
215
- ExotelWebClient.eventListener = new ExotelVoiceClientListener();
216
+ if (!this.eventListener) {
217
+ this.eventListener = new ExotelVoiceClientListener();
216
218
  }
217
219
 
218
- if (!ExotelWebClient.callListener) {
219
- ExotelWebClient.callListener = new CallListener();
220
+ if (!this.callListener) {
221
+ this.callListener = new CallListener();
220
222
  }
221
223
 
222
- if (!ExotelWebClient.ctrlr) {
223
- ExotelWebClient.ctrlr = new CallController();
224
+ if (!this.ctrlr) {
225
+ this.ctrlr = new CallController();
224
226
  }
225
227
 
226
- if (!ExotelWebClient.call) {
227
- ExotelWebClient.call = new Call();
228
+ if (!this.call) {
229
+ this.call = new Call();
228
230
  }
229
231
 
230
232
  logger.log("Exotel Client Initialised with " + JSON.stringify(sipAccountInfo_))
231
- ExotelWebClient.sipAccountInfo = sipAccountInfo_;
232
- if ( !ExotelWebClient.sipAccountInfo["userName"] || !ExotelWebClient.sipAccountInfo["sipdomain"] || !ExotelWebClient.sipAccountInfo["port"]) {
233
+ this.sipAccountInfo = sipAccountInfo_;
234
+ if ( !this.sipAccountInfo["userName"] || !this.sipAccountInfo["sipdomain"] || !this.sipAccountInfo["port"]) {
233
235
  return false;
234
236
  }
235
- ExotelWebClient.sipAccountInfo["sipUri"] = "wss://" + ExotelWebClient.sipAccountInfo["userName"] + "@" + ExotelWebClient.sipAccountInfo["sipdomain"] + ":" + ExotelWebClient.sipAccountInfo["port"];
237
+ this.sipAccountInfo["sipUri"] = "wss://" + this.sipAccountInfo["userName"] + "@" + this.sipAccountInfo["sipdomain"] + ":" + this.sipAccountInfo["port"];
236
238
 
237
239
  callbacks.initializeCallback(CallListenerCallback);
238
240
  registerCallback.initializeRegisterCallback(RegisterEventCallBack);
239
241
  logger.log("Initializing session callback")
240
242
  sessionCallback.initializeSessionCallback(SessionCallback);
241
- ExotelWebClient.setEventListener(ExotelWebClient.eventListener);
243
+ this.setEventListener(this.eventListener);
242
244
  return true;
243
- },
245
+ };
244
246
 
245
- DoRegister : () => {
246
- DoRegisterRL(ExotelWebClient.sipAccountInfo, ExotelWebClient)
247
- },
247
+ DoRegister = () => {
248
+ DoRegisterRL(this.sipAccountInfo, this)
249
+ };
248
250
 
249
- UnRegister : () => {
250
- UnRegisterRL(ExotelWebClient.sipAccountInfo, ExotelWebClient)
251
- },
251
+ UnRegister = () => {
252
+ UnRegisterRL(this.sipAccountInfo, this)
253
+ };
252
254
 
253
- initDiagnostics : (saveDiagnosticsCallback, keyValueSetCallback) => {
255
+ initDiagnostics = (saveDiagnosticsCallback, keyValueSetCallback) => {
254
256
  initDiagnosticsDL(saveDiagnosticsCallback, keyValueSetCallback)
255
- },
257
+ };
256
258
 
257
- closeDiagnostics : () => {
259
+ closeDiagnostics = () => {
258
260
  closeDiagnosticsDL()
259
- },
261
+ };
260
262
 
261
- startSpeakerDiagnosticsTest : () => {
263
+ startSpeakerDiagnosticsTest = () => {
262
264
  startSpeakerDiagnosticsTestDL()
263
- },
265
+ };
264
266
 
265
- stopSpeakerDiagnosticsTest : (speakerTestResponse='none') => {
267
+ stopSpeakerDiagnosticsTest = (speakerTestResponse='none') => {
266
268
  stopSpeakerDiagnosticsTestDL(speakerTestResponse)
267
- },
269
+ };
268
270
 
269
- startMicDiagnosticsTest : () => {
271
+ startMicDiagnosticsTest = () => {
270
272
  startMicDiagnosticsTestDL()
271
- },
273
+ };
272
274
 
273
- stopMicDiagnosticsTest : (micTestResponse='none') => {
275
+ stopMicDiagnosticsTest = (micTestResponse='none') => {
274
276
  stopMicDiagnosticsTestDL(micTestResponse)
275
- },
277
+ };
276
278
 
277
- startNetworkDiagnostics : () => {
279
+ startNetworkDiagnostics = () => {
278
280
  startNetworkDiagnosticsDL()
279
- ExotelWebClient.DoRegister()
280
- },
281
+ this.DoRegister()
282
+ };
281
283
 
282
- stopNetworkDiagnostics : () => {
284
+ stopNetworkDiagnostics = () => {
283
285
  stopNetworkDiagnosticsDL()
284
- },
286
+ };
285
287
 
286
- SessionListener : () => {
288
+ SessionListener = () => {
287
289
  SessionListenerSL()
288
- },
290
+ };
289
291
 
290
292
  /**
291
293
  * function that returns the instance of the call controller object object
292
294
  */
293
295
 
294
- getCallController :() => {
295
- return ExotelWebClient.ctrlr;
296
- },
296
+ getCallController =() => {
297
+ return this.ctrlr;
298
+ };
297
299
 
298
- getCall :() => {
299
- if (!ExotelWebClient.call) {
300
- ExotelWebClient.call = call = new Call();
300
+ getCall =() => {
301
+ if (!this.call) {
302
+ this.call = call = new Call();
301
303
  }
302
- return ExotelWebClient.call;
303
- },
304
+ return this.call;
305
+ };
304
306
 
305
307
  /**
306
308
  * Dummy function to set the event listener object
307
309
  */
308
- setEventListener :(eventListener) => {
309
- ExotelWebClient.eventListener = eventListener;
310
- },
310
+ setEventListener =(eventListener) => {
311
+ this.eventListener = eventListener;
312
+ };
311
313
 
312
314
 
313
315
  /**
@@ -317,42 +319,42 @@ export const ExotelWebClient = {
317
319
  * @param {*} param
318
320
  */
319
321
 
320
- registerEventCallback :(event, phone, param) => {
322
+ registerEventCallback =(event, phone, param) => {
321
323
 
322
324
  logger.log("Dialer: registerEventCallback: Received ---> " + event + 'phone....', phone + 'param....', param)
323
325
  if (event === "connected") {
324
326
  /**
325
327
  * When registration is successful then send the phone number of the same to UI
326
328
  */
327
- ExotelWebClient.eventListener.onInitializationSuccess(phone);
329
+ this.eventListener.onInitializationSuccess(phone);
328
330
  } else if( event === "failed_to_start" || event === "transport_error"){
329
331
  /**
330
332
  * If registration fails
331
333
  */
332
- ExotelWebClient.eventListener.onInitializationFailure(phone);
334
+ this.eventListener.onInitializationFailure(phone);
333
335
  } else if( event === "sent_request"){
334
336
  /**
335
337
  * If registration request waiting...
336
338
  */
337
- ExotelWebClient.eventListener.onInitializationWaiting(phone);
339
+ this.eventListener.onInitializationWaiting(phone);
338
340
  }
339
- },
341
+ };
340
342
  /**
341
343
  * Event listener for calls, any change in sipjsphone will trigger the callback here
342
344
  * @param {*} event
343
345
  * @param {*} phone
344
346
  * @param {*} param
345
347
  */
346
- callEventCallback :(event, phone, param) => {
348
+ callEventCallback =(event, phone, param) => {
347
349
  logger.log("Dialer: callEventCallback: Received ---> " + event + 'param sent....' + param + 'for phone....' + phone)
348
350
  if (event === "i_new_call") {
349
- ExotelWebClient.callListener.onIncomingCall(param,phone)
351
+ this.callListener.onIncomingCall(param,phone)
350
352
  } else if (event === "connected") {
351
- ExotelWebClient.callListener.onCallEstablished(param,phone);
353
+ this.callListener.onCallEstablished(param,phone);
352
354
  } else if (event === "terminated") {
353
- ExotelWebClient.callListener.onCallEnded(param,phone);
355
+ this.callListener.onCallEnded(param,phone);
354
356
  }
355
- },
357
+ };
356
358
 
357
359
  /**
358
360
  * Event listener for diagnostic tests, any change in diagnostic tests will trigger this callback
@@ -360,34 +362,34 @@ export const ExotelWebClient = {
360
362
  * @param {*} phone
361
363
  * @param {*} param
362
364
  */
363
- diagnosticEventCallback :(event, phone, param) => {
365
+ diagnosticEventCallback =(event, phone, param) => {
364
366
  webrtcTroubleshooterEventBus.sendDiagnosticEvent(event, phone, param)
365
- },
367
+ };
366
368
 
367
369
  /**
368
370
  * Function to unregister a phone
369
371
  * @param {*} sipAccountInfo
370
372
  */
371
- unregister :(sipAccountInfo) => {
373
+ unregister =(sipAccountInfo) => {
372
374
  // webrtcSIPPhone.unregister(sipAccountInfo)
373
375
  webrtcSIPPhone.sipUnRegisterWebRTC();
374
- },
376
+ };
375
377
 
376
378
 
377
- webRTCStatusCallbackHandler :(msg1, arg1) => {
379
+ webRTCStatusCallbackHandler =(msg1, arg1) => {
378
380
  logger.log("webRTCStatusCallbackHandler: " + msg1 + " " + arg1)
379
- },
381
+ };
380
382
 
381
383
  /**
382
384
  * initialize function called when user wants to register client
383
385
  */
384
- initialize :(uiContext, hostName,subscriberName,
386
+ initialize =(uiContext, hostName,subscriberName,
385
387
  displayName,accountSid,subscriberToken,
386
388
  sipAccountInfo) => {
387
389
 
388
390
  let wssPort = sipAccountInfo.port;
389
- let wsPort = 8089;
390
- ExotelWebClient.sipAccntInfo = {
391
+ let wsPort = 4442;
392
+ this.sipAccntInfo = {
391
393
  'userName':'',
392
394
  'authUser':'',
393
395
  'domain':'',
@@ -407,65 +409,65 @@ export const ExotelWebClient = {
407
409
  fetchPublicIP(sipAccountInfo);
408
410
 
409
411
  /* Temporary till we figure out the arguments - Start */
410
- ExotelWebClient.domain = hostName = sipAccountInfo.domain;
411
- ExotelWebClient.sipdomain = sipAccountInfo.sipdomain;
412
- ExotelWebClient.accountName = ExotelWebClient.userName = sipAccountInfo.userName;
413
- ExotelWebClient.authUser = subscriberName = sipAccountInfo.authUser;
414
- ExotelWebClient.displayName = sipAccountInfo.displayName;
415
- ExotelWebClient.accountSid = 'exotelt1';
416
- ExotelWebClient.subscriberToken = sipAccountInfo.secret;
417
- ExotelWebClient.secret = ExotelWebClient.password = sipAccountInfo.secret;
418
- ExotelWebClient.endpoint = sipAccountInfo.endpoint;
419
- ExotelWebClient.port = sipAccountInfo.port;
420
- ExotelWebClient.contactHost = sipAccountInfo.contactHost;
421
- ExotelWebClient.sipWsPort = 5061;
422
- ExotelWebClient.sipPort = 5061;
423
- ExotelWebClient.sipSecurePort = 5062;
412
+ this.domain = hostName = sipAccountInfo.domain;
413
+ this.sipdomain = sipAccountInfo.sipdomain;
414
+ this.accountName = this.userName = sipAccountInfo.userName;
415
+ this.authUser = subscriberName = sipAccountInfo.authUser;
416
+ this.displayName = sipAccountInfo.displayName;
417
+ this.accountSid = 'exotelt1';
418
+ this.subscriberToken = sipAccountInfo.secret;
419
+ this.secret = this.password = sipAccountInfo.secret;
420
+ this.security = sipAccountInfo.security ? sipAccountInfo.security : "wss";
421
+ this.endpoint = sipAccountInfo.endpoint ? sipAccountInfo.endpoint : "wss";
422
+ this.port = sipAccountInfo.port;
423
+ this.contactHost = sipAccountInfo.contactHost;
424
+ this.sipWsPort = 5061;
425
+ this.sipPort = 5061;
426
+ this.sipSecurePort = 5062;
424
427
  /* Temporary till we figure out the arguments - End */
425
428
 
426
429
  /* This is permanent -Start */
427
- let webrtcPort = wsPort;
430
+ let webrtcPort = wssPort;
428
431
 
429
- if (ExotelWebClient.endpoint === 'wss') {
430
- ExotelWebClient.security = 'wss';
431
- webrtcPort = wssPort;
432
- }
432
+ if (this.security === 'ws') {
433
+ webrtcPort = wsPort;
434
+ }
433
435
 
434
436
 
435
437
 
436
- ExotelWebClient.sipAccntInfo['userName'] = ExotelWebClient.userName;
437
- ExotelWebClient.sipAccntInfo['authUser'] = subscriberName;
438
- ExotelWebClient.sipAccntInfo['domain'] = hostName;
439
- ExotelWebClient.sipAccntInfo['sipdomain'] = ExotelWebClient.sipdomain;
440
- ExotelWebClient.sipAccntInfo['accountName'] = ExotelWebClient.userName;
441
- ExotelWebClient.sipAccntInfo['secret'] = ExotelWebClient.password;
442
- ExotelWebClient.sipAccntInfo['sipuri'] = ExotelWebClient.sipuri;
443
- ExotelWebClient.sipAccntInfo['security'] = ExotelWebClient.security;
444
- ExotelWebClient.sipAccntInfo['endpoint'] = ExotelWebClient.endpoint;
445
- ExotelWebClient.sipAccntInfo['port'] = webrtcPort;
446
- ExotelWebClient.sipAccntInfo['contactHost'] = ExotelWebClient.contactHost;
447
- localStorage.setItem('contactHost', ExotelWebClient.contactHost);
438
+ this.sipAccntInfo['userName'] = this.userName;
439
+ this.sipAccntInfo['authUser'] = subscriberName;
440
+ this.sipAccntInfo['domain'] = hostName;
441
+ this.sipAccntInfo['sipdomain'] = this.sipdomain;
442
+ this.sipAccntInfo['accountName'] = this.userName;
443
+ this.sipAccntInfo['secret'] = this.password;
444
+ this.sipAccntInfo['sipuri'] = this.sipuri;
445
+ this.sipAccntInfo['security'] = this.security;
446
+ this.sipAccntInfo['endpoint'] = this.endpoint;
447
+ this.sipAccntInfo['port'] = webrtcPort;
448
+ this.sipAccntInfo['contactHost'] = this.contactHost;
449
+ localStorage.setItem('contactHost', this.contactHost);
448
450
  /* This is permanent -End */
449
451
 
450
452
  /**
451
453
  * Call the webclient function inside this and pass register and call callbacks as arg
452
454
  */
453
- var synchronousHandler = new ExSynchronousHandler(ExotelWebClient);
454
- var delegationHandler = new ExDelegationHandler(ExotelWebClient);
455
+ var synchronousHandler = new ExSynchronousHandler(this);
456
+ var delegationHandler = new ExDelegationHandler(this);
455
457
 
456
- var userName = ExotelWebClient.userName;
458
+ var userName = this.userName;
457
459
  /* OLD-Way to be revisited for multile phone support */
458
460
  //webRTCPhones[userName] = webRTC;
459
461
 
460
462
  /* New-Way */
461
463
  webrtcSIPPhone.registerPhone("sipjs",delegationHandler);
462
- webrtcSIPPhone.registerWebRTCClient(ExotelWebClient.sipAccntInfo, synchronousHandler);
464
+ webrtcSIPPhone.registerWebRTCClient(this.sipAccntInfo, synchronousHandler);
463
465
 
464
466
  /**
465
467
  * Store the intervalID against a map
466
468
  */
467
469
  intervalIDMap.set(userName, intervalId);
468
- }
470
+ };
469
471
  }
470
472
 
471
473
  export default ExotelWebClient;
@@ -0,0 +1,75 @@
1
+ const path = require('path');
2
+ var webpack = require('webpack');
3
+ var TerserPlugin = require('terser-webpack-plugin');
4
+ const CircularDependencyPlugin = require('circular-dependency-plugin')
5
+
6
+ var pkg = require('./package.json');
7
+ var banner = '\
8
+ \n\
9
+ WebRTC CLient SIP version ' + pkg.version + '\n\
10
+ ';
11
+
12
+ module.exports = {
13
+ entry: {
14
+ exotelsdk: './index.js'
15
+ },
16
+ devtool: 'source-map',
17
+ mode: 'development',
18
+ output: {
19
+ filename:'[name].js',
20
+ path: path.resolve(__dirname, 'dist'),
21
+ libraryTarget: 'umd',
22
+ library: 'exotelSDK',
23
+ globalObject: 'this',
24
+ assetModuleFilename: '[name][ext][query]'
25
+ },
26
+ module: {
27
+ rules: [
28
+ { test: /\.wav$/,exclude: /node_modules/, use: 'file-loader',type: 'asset/resource' },
29
+ {
30
+ test: /\.ts$/,
31
+ exclude: /node_modules/,
32
+ loader: "ts-loader",
33
+ options: {
34
+ compilerOptions: {
35
+ "declaration": false,
36
+ "declarationMap": false,
37
+ "outDir": path.resolve(__dirname, 'dist')
38
+ }
39
+ }
40
+ },
41
+ {
42
+ test: /\.(js)$/,
43
+ exclude: /node_modules/,
44
+ use: 'babel-loader',
45
+ }
46
+ ],
47
+ },
48
+ resolve: {
49
+ extensions: ['.ts', '.d.ts', '.js']
50
+ },
51
+ optimization: {
52
+ minimizer: [
53
+ new TerserPlugin({
54
+ terserOptions: {
55
+ output: {
56
+ ascii_only: true
57
+ }
58
+ }
59
+ })
60
+ ]
61
+ },
62
+ plugins: [
63
+ new CircularDependencyPlugin({
64
+ // exclude detection of files based on a RegExp
65
+ exclude: /a\.js|node_modules/,
66
+ // add errors to webpack instead of warnings
67
+ failOnError: true,
68
+ // set the current working directory for displaying module paths
69
+ cwd: process.cwd(),
70
+ }),
71
+ new webpack.BannerPlugin({
72
+ banner: banner
73
+ })
74
+ ]
75
+ };