@16x/webphone-sdk 3.0.1 → 3.1.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/CHANGELOG.md +39 -22
- package/LICENSE +1 -2
- package/README.md +113 -113
- package/dist/{CCBarClient-BdbynNBi.js → CCBarClient-CcPfEToZ.js} +431 -179
- package/dist/CCBarClient-DCQ8XjcL.cjs +1 -0
- package/dist/{Diagnostics-BYVvmxil.cjs → Diagnostics-D38Hm3NT.cjs} +1 -1
- package/dist/{Diagnostics-Cw2HVrCD.js → Diagnostics-Di049OpT.js} +9 -9
- package/dist/JsSipAdapter-BBRrDaM4.cjs +1 -0
- package/dist/{JsSipAdapter-GHzVSCDh.js → JsSipAdapter-Bke1Qjfe.js} +37 -25
- package/dist/SharedWorkerProtocol-39dch6xL.cjs +1 -0
- package/dist/{SharedWorkerProtocol-BqUafs8d.js → SharedWorkerProtocol-DKVQ5-po.js} +31 -17
- package/dist/core/CCBarClient.d.ts +36 -4
- package/dist/core/CallManager.d.ts +2 -0
- package/dist/{createJsSipFactory-yttVU3d6.js → createJsSipFactory-9CPsweDR.js} +4 -1
- package/dist/{createJsSipFactory-2X4FBIU2.cjs → createJsSipFactory-Dr8HbLl-.cjs} +1 -1
- package/dist/diagnostics/Diagnostics.d.ts +1 -0
- package/dist/diagnostics/index.cjs +1 -1
- package/dist/diagnostics/index.d.ts +1 -1
- package/dist/diagnostics/index.js +3 -6
- package/dist/errors/CCBarError.d.ts +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +9 -139
- package/dist/index.umd.js +17 -17
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +2 -2
- package/dist/shared/SharedWorkerProtocol.d.ts +2 -0
- package/dist/shared-worker.cjs +1 -1
- package/dist/shared-worker.js +13 -6
- package/dist/styles.css +7 -7
- package/dist/types.d.ts +5 -0
- package/dist/ui/XCallCCBarElement.d.ts +2 -0
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.js +138 -130
- package/dist/version.d.ts +1 -0
- package/package.json +111 -107
- package/dist/CCBarClient-DKWdvgf5.cjs +0 -1
- package/dist/CCBarError-CIqJE8zK.cjs +0 -1
- package/dist/CCBarError-DSbPw2dA.js +0 -14
- package/dist/JsSipAdapter-jtGdoXrm.cjs +0 -1
- package/dist/SharedWorkerProtocol-CYN0AprP.cjs +0 -1
|
@@ -72,4 +72,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
72
72
|
`,i+=`CSeq: ${p.cseq} ${p.method}\r
|
|
73
73
|
`,i+=`\r
|
|
74
74
|
`,h.send(i)}})),ge=s((e=>{function t(e,t){var r;if(typeof Symbol>`u`||e[Symbol.iterator]==null){if(Array.isArray(e)||(r=n(e))||t&&e&&typeof e.length==`number`){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
75
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,c=e},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(s)throw c}}}}function n(e,t){if(e){if(typeof e==`string`)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}}function r(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var i=P(),a=k(),o=M(),s=N(),c=fe(),l=A();e.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:a.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:a.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:a.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${i.createRandomToken(12)}.invalid`};var u={mandatory:{sockets:function(e){var n=[];if(c.isSocket(e))n.push({socket:e});else if(Array.isArray(e)&&e.length){var r=t(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;Object.prototype.hasOwnProperty.call(a,`socket`)&&c.isSocket(a.socket)?n.push(a):c.isSocket(a)&&n.push({socket:a})}}catch(e){r.e(e)}finally{r.f()}}else return;return n},uri:function(e){/^sip:/i.test(e)||(e=`${a.SIP}:${e}`);var t=s.parse(e);if(t&&t.user)return t}},optional:{authorization_user:function(e){if(o.parse(`"${e}"`,`quoted_string`)!==-1)return e},authorization_jwt:function(e){if(typeof e==`string`)return e},user_agent:function(e){if(typeof e==`string`)return e},connection_recovery_max_interval:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},connection_recovery_min_interval:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if(typeof e==`string`){var t=o.parse(e,`SIP_URI`);if(t!==-1)return t}},display_name:function(e){return e},instance_id:function(e){if(/^uuid:/i.test(e)&&(e=e.substr(5)),o.parse(e,`uuid`)!==-1)return e},no_answer_timeout:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},session_timers:function(e){if(typeof e==`boolean`)return e},session_timers_refresh_method:function(e){if(typeof e==`string`&&(e=e.toUpperCase(),e===a.INVITE||e===a.UPDATE))return e},session_timers_force_refresher:function(e){if(typeof e==`boolean`)return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if(typeof e==`boolean`)return e},register_expires:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e=`${a.SIP}:${e}`);var t=s.parse(e);if(t&&!t.user)return t},use_preloaded_route:function(e){if(typeof e==`boolean`)return e},extra_headers:function(e){var n=[];if(Array.isArray(e)&&e.length){var r=t(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;typeof a==`string`&&n.push(a)}}catch(e){r.e(e)}finally{r.f()}}else return;return n}}};e.load=function(e,t){for(var n in u.mandatory)if(t.hasOwnProperty(n)){var r=t[n],a=u.mandatory[n](r);if(a!==void 0)e[n]=a;else throw new l.ConfigurationError(n,r)}else throw new l.ConfigurationError(n);for(var o in u.optional)if(t.hasOwnProperty(o)){var s=t[o];if(i.isEmpty(s))continue;var c=u.optional[o](s);if(c!==void 0)e[o]=c;else throw new l.ConfigurationError(o,s)}}})),_e=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){var t=d();return function(){var n=f(e),r;if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function l(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:u(e)}function u(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function d(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}var p=F().EventEmitter,m=z(),h=k(),g=ie(),_=le(),v=ue(),y=de(),b=U(),x=pe(),S=P(),C=A(),w=N(),T=me(),E=V(),D=he(),O=ge(),j=new m(`UA`),M={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};t.exports=function(e){o(n,e);var t=c(n);a(n,null,[{key:`C`,get:function(){return M}}]);function n(e){var i;if(r(this,n),j.debug(`new() [configuration:%o]`,e),i=t.call(this),i._cache={credentials:{}},i._configuration=Object.assign({},O.settings),i._dynConfiguration={},i._dialogs={},i._applicants={},i._sessions={},i._transport=null,i._contact=null,i._status=M.STATUS_INIT,i._error=null,i._transactions={nist:{},nict:{},ist:{},ict:{}},i._data={},i._closeTimer=null,e===void 0)throw TypeError(`Not enough arguments`);try{i._loadConfig(e)}catch(e){throw i._status=M.STATUS_NOT_READY,i._error=M.CONFIGURATION_ERROR,e}return i._registrator=new g(u(i)),i}return a(n,[{key:`start`,value:function(){j.debug(`start()`),this._status===M.STATUS_INIT?this._transport.connect():this._status===M.STATUS_USER_CLOSED?(j.debug(`restarting UA`),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=M.STATUS_INIT,this._transport.connect()):this._status===M.STATUS_READY?j.debug(`UA is in READY status, not restarted`):j.debug(`ERROR: connection is down, Auto-Recovery system is trying to reconnect`),this._dynConfiguration.register=this._configuration.register}},{key:`register`,value:function(){j.debug(`register()`),this._dynConfiguration.register=!0,this._registrator.register()}},{key:`unregister`,value:function(e){j.debug(`unregister()`),this._dynConfiguration.register=!1,this._registrator.unregister(e)}},{key:`registrator`,value:function(){return this._registrator}},{key:`isRegistered`,value:function(){return this._registrator.registered}},{key:`isConnected`,value:function(){return this._transport.isConnected()}},{key:`call`,value:function(e,t){j.debug(`call()`);var n=new _(this);return n.connect(e,t),n}},{key:`sendMessage`,value:function(e,t,n){j.debug(`sendMessage()`);var r=new v(this);return r.send(e,t,n),r}},{key:`sendOptions`,value:function(e,t,n){j.debug(`sendOptions()`);var r=new y(this);return r.send(e,t,n),r}},{key:`terminateSessions`,value:function(e){for(var t in j.debug(`terminateSessions()`),this._sessions)this._sessions[t].isEnded()||this._sessions[t].terminate(e)}},{key:`stop`,value:function(){var e=this;if(j.debug(`stop()`),this._dynConfiguration={},this._status===M.STATUS_USER_CLOSED){j.debug(`UA already closed`);return}this._registrator.close();var t=Object.keys(this._sessions).length;for(var n in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,n)){j.debug(`closing session ${n}`);try{this._sessions[n].terminate()}catch{}}for(var r in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,r))try{this._applicants[r].close()}catch{}this._status=M.STATUS_USER_CLOSED,Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length===0&&t===0?this._transport.disconnect():this._closeTimer=setTimeout(function(){e._closeTimer=null,e._transport.disconnect()},2e3)}},{key:`normalizeTarget`,value:function(e){return S.normalizeTarget(e,this._configuration.hostport_params)}},{key:`get`,value:function(e){switch(e){case`authorization_user`:return this._configuration.authorization_user;case`realm`:return this._configuration.realm;case`ha1`:return this._configuration.ha1;case`authorization_jwt`:return this._configuration.authorization_jwt;default:j.warn(`get() | cannot get "%s" parameter in runtime`,e);return}}},{key:`set`,value:function(e,t){switch(e){case`authorization_user`:this._configuration.authorization_user=String(t);break;case`password`:this._configuration.password=String(t);break;case`realm`:this._configuration.realm=String(t);break;case`ha1`:this._configuration.ha1=String(t),this._configuration.password=null;break;case`authorization_jwt`:this._configuration.authorization_jwt=String(t);break;case`display_name`:this._configuration.display_name=t;break;case`extra_headers`:this._configuration.extra_headers=t;break;default:return j.warn(`set() | cannot set "%s" parameter in runtime`,e),!1}return!0}},{key:`newTransaction`,value:function(e){this._transactions[e.type][e.id]=e,this.emit(`newTransaction`,{transaction:e})}},{key:`destroyTransaction`,value:function(e){delete this._transactions[e.type][e.id],this.emit(`transactionDestroyed`,{transaction:e})}},{key:`newDialog`,value:function(e){this._dialogs[e.id]=e}},{key:`destroyDialog`,value:function(e){delete this._dialogs[e.id]}},{key:`newMessage`,value:function(e,t){this._applicants[e]=e,this.emit(`newMessage`,t)}},{key:`newOptions`,value:function(e,t){this._applicants[e]=e,this.emit(`newOptions`,t)}},{key:`destroyMessage`,value:function(e){delete this._applicants[e]}},{key:`newRTCSession`,value:function(e,t){this._sessions[e.id]=e,this.emit(`newRTCSession`,t)}},{key:`destroyRTCSession`,value:function(e){delete this._sessions[e.id]}},{key:`registered`,value:function(e){this.emit(`registered`,e)}},{key:`unregistered`,value:function(e){this.emit(`unregistered`,e)}},{key:`registrationFailed`,value:function(e){this.emit(`registrationFailed`,e)}},{key:`receiveRequest`,value:function(e){var t=e.method;if(e.ruri.user!==this._configuration.uri.user&&e.ruri.user!==this._contact.uri.user){j.debug(`Request-URI does not point to us`),e.method!==h.ACK&&e.reply_sl(404);return}if(e.ruri.scheme===h.SIPS){e.reply_sl(416);return}if(!b.checkTransaction(this,e)){if(t===h.INVITE?new b.InviteServerTransaction(this,this._transport,e):t!==h.ACK&&t!==h.CANCEL&&new b.NonInviteServerTransaction(this,this._transport,e),t===h.OPTIONS){if(this.listeners(`newOptions`).length===0){e.reply(200);return}new y(this).init_incoming(e)}else if(t===h.MESSAGE){if(this.listeners(`newMessage`).length===0){e.reply(405);return}new v(this).init_incoming(e)}else if(t===h.INVITE&&!e.to_tag&&this.listeners(`newRTCSession`).length===0){e.reply(405);return}var n,r;if(e.to_tag)n=this._findDialog(e.call_id,e.from_tag,e.to_tag),n?n.receiveRequest(e):t===h.NOTIFY?(r=this._findSession(e),r?r.receiveRequest(e):(j.debug(`received NOTIFY request for a non existent subscription`),e.reply(481,`Subscription does not exist`))):t!==h.ACK&&e.reply(481);else switch(t){case h.INVITE:if(window.RTCPeerConnection){if(e.hasHeader(`replaces`)){var i=e.replaces;n=this._findDialog(i.call_id,i.from_tag,i.to_tag),n?(r=n.owner,r.isEnded()?e.reply(603):r.receiveRequest(e)):e.reply(481)}else r=new _(this),r.init_incoming(e)}else j.warn(`INVITE received but WebRTC is not supported`),e.reply(488);break;case h.BYE:e.reply(481);break;case h.CANCEL:r=this._findSession(e),r?r.receiveRequest(e):j.debug(`received CANCEL request for a non existent session`);break;case h.ACK:break;case h.NOTIFY:this.emit(`sipEvent`,{event:e.event,request:e}),e.reply(200);break;default:e.reply(405)}}}},{key:`_findSession`,value:function(e){var t=e.call_id,n=e.from_tag,r=e.to_tag,i=t+n,a=this._sessions[i],o=t+r,s=this._sessions[o];return a||s||null}},{key:`_findDialog`,value:function(e,t,n){var r=e+t+n,i=this._dialogs[r];return i||(r=e+n+t,i=this._dialogs[r],i||null)}},{key:`_loadConfig`,value:function(e){try{O.load(this._configuration,e)}catch(e){throw e}this._configuration.display_name===0&&(this._configuration.display_name=`0`),this._configuration.instance_id||(this._configuration.instance_id=S.newUUID()),this._configuration.jssip_id=S.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,``);try{this._transport=new x(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=I.bind(this),this._transport.onconnect=L.bind(this),this._transport.ondisconnect=R.bind(this),this._transport.ondata=B.bind(this)}catch(e){throw j.warn(e),new C.ConfigurationError(`sockets`,this._configuration.sockets)}if(delete this._configuration.sockets,this._configuration.authorization_user||(this._configuration.authorization_user=this._configuration.uri.user),!this._configuration.registrar_server){var n=this._configuration.uri.clone();n.user=null,n.clearParams(),n.clearHeaders(),this._configuration.registrar_server=n}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new w(`sip`,S.createRandomToken(8),this._configuration.via_host,null,{transport:`ws`}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.anonymous||null,n=e.outbound||null,r=`<`;return r+=t?this.temp_gruu||`sip:anonymous@anonymous.invalid;transport=ws`:this.pub_gruu||this.uri.toString(),n&&(t?!this.temp_gruu:!this.pub_gruu)&&(r+=`;ob`),r+=`>`,r}};var r=[`authorization_user`,`password`,`realm`,`ha1`,`authorization_jwt`,`display_name`,`register`,`extra_headers`];for(var i in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,i)&&(r.indexOf(i)===-1?Object.defineProperty(this._configuration,i,{writable:!1,configurable:!1}):Object.defineProperty(this._configuration,i,{writable:!0,configurable:!1}));for(var a in j.debug(`configuration parameters after validation:`),this._configuration)if(Object.prototype.hasOwnProperty.call(O.settings,a))switch(a){case`uri`:case`registrar_server`:j.debug(`- ${a}: ${this._configuration[a]}`);break;case`password`:case`ha1`:case`authorization_jwt`:j.debug(`- ${a}: NOT SHOWN`);break;default:j.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}},{key:`C`,get:function(){return M}},{key:`status`,get:function(){return this._status}},{key:`contact`,get:function(){return this._contact}},{key:`configuration`,get:function(){return this._configuration}},{key:`transport`,get:function(){return this._transport}}]),n}(p);function I(e){this.emit(`connecting`,e)}function L(e){this._status!==M.STATUS_USER_CLOSED&&(this._status=M.STATUS_READY,this._error=null,this.emit(`connected`,e),this._dynConfiguration.register&&this._registrator.register())}function R(e){for(var t=[`nict`,`ict`,`nist`,`ist`],n=0,r=t;n<r.length;n++){var i=r[n];for(var a in this._transactions[i])Object.prototype.hasOwnProperty.call(this._transactions[i],a)&&this._transactions[i][a].onTransportError()}this.emit(`disconnected`,e),this._registrator.onTransportClosed(),this._status!==M.STATUS_USER_CLOSED&&(this._status=M.STATUS_NOT_READY,this._error=M.NETWORK_ERROR)}function B(e){var t=e.transport,n=e.message;if(n=T.parseMessage(n,this),n&&!(this._status===M.STATUS_USER_CLOSED&&n instanceof E.IncomingRequest)&&D(n,this,t)){if(n instanceof E.IncomingRequest)n.transport=t,this.receiveRequest(n);else if(n instanceof E.IncomingResponse){var r;switch(n.method){case h.INVITE:r=this._transactions.ict[n.via_branch],r&&r.receiveResponse(n);break;case h.ACK:break;default:r=this._transactions.nict[n.via_branch],r&&r.receiveResponse(n)}}}}})),ve=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=z(),o=M(),s=new a(`WebSocketInterface`);t.exports=function(){function e(t){n(this,e),s.debug(`new() [url:"%s"]`,t),this._url=t,this._sip_uri=null,this._via_transport=null,this._ws=null;var r=o.parse(t,`absoluteURI`);if(r===-1)throw s.warn(`invalid WebSocket URI: ${t}`),TypeError(`Invalid argument: ${t}`);if(r.scheme!==`wss`&&r.scheme!==`ws`)throw s.warn(`invalid WebSocket URI scheme: ${r.scheme}`),TypeError(`Invalid argument: ${t}`);this._sip_uri=`sip:${r.host}${r.port?`:${r.port}`:``};transport=ws`,this._via_transport=r.scheme.toUpperCase()}return i(e,[{key:`connect`,value:function(){if(s.debug(`connect()`),this.isConnected()){s.debug(`WebSocket ${this._url} is already connected`);return}if(this.isConnecting()){s.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),s.debug(`connecting to WebSocket ${this._url}`);try{this._ws=new WebSocket(this._url,`sip`),this._ws.binaryType=`arraybuffer`,this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(e){this._onError(e)}}},{key:`disconnect`,value:function(){s.debug(`disconnect()`),this._ws&&=(this._ws.onopen=function(){},this._ws.onclose=function(){},this._ws.onmessage=function(){},this._ws.onerror=function(){},this._ws.close(),null)}},{key:`send`,value:function(e){return s.debug(`send()`),this.isConnected()?(this._ws.send(e),!0):(s.warn(`unable to send message, WebSocket is not open`),!1)}},{key:`isConnected`,value:function(){return this._ws&&this._ws.readyState===this._ws.OPEN}},{key:`isConnecting`,value:function(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}},{key:`_onOpen`,value:function(){s.debug(`WebSocket ${this._url} connected`),this.onconnect()}},{key:`_onClose`,value:function(e){var t=e.wasClean,n=e.code,r=e.reason;s.debug(`WebSocket ${this._url} closed`),t===!1&&s.debug(`WebSocket abrupt disconnection`),this.ondisconnect(!t,n,r)}},{key:`_onMessage`,value:function(e){var t=e.data;s.debug(`received WebSocket message`),this.ondata(t)}},{key:`_onError`,value:function(e){s.warn(`WebSocket ${this._url} error: `,e)}},{key:`via_transport`,get:function(){return this._via_transport},set:function(e){this._via_transport=e.toUpperCase()}},{key:`sip_uri`,get:function(){return this._sip_uri}},{key:`url`,get:function(){return this._url}}]),e}()})),ye=u(s(((e,t)=>{var n=(O(),d(f).default),r=k(),i=A(),a=P(),o=_e(),s=N(),c=j(),l=M(),u=ve();R()(`JsSIP`)(`version %s`,n.version),t.exports={C:r,Exceptions:i,Utils:a,UA:o,URI:s,NameAddrHeader:c,WebSocketInterface:u,Grammar:l,debug:R(),get name(){return n.title},get version(){return n.version}}}))(),1);function be(){return{createSocket:(e,t)=>new xe(e,t),createUa:e=>new ye.UA(e)}}var xe=class extends ye.WebSocketInterface{ticket;constructor(e,t){super(e),this.ticket=t}connect(){if(this.isConnected()||this.isConnecting())return;let e=this;e._ws&&this.disconnect();try{e._ws=new WebSocket(this.url,[`xcall-ticket.${this.ticket}`,`sip`]),e._ws.binaryType=`arraybuffer`,e._ws.onopen=e._onOpen.bind(this),e._ws.onclose=e._onClose.bind(this),e._ws.onmessage=e._onMessage.bind(this),e._ws.onerror=e._onError.bind(this)}catch(t){e._onError.call(this,t)}}};exports.createJsSipFactory=be,exports.t=d;
|
|
75
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,c=e},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(s)throw c}}}}function n(e,t){if(e){if(typeof e==`string`)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}}function r(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var i=P(),a=k(),o=M(),s=N(),c=fe(),l=A();e.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:a.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:a.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:a.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${i.createRandomToken(12)}.invalid`};var u={mandatory:{sockets:function(e){var n=[];if(c.isSocket(e))n.push({socket:e});else if(Array.isArray(e)&&e.length){var r=t(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;Object.prototype.hasOwnProperty.call(a,`socket`)&&c.isSocket(a.socket)?n.push(a):c.isSocket(a)&&n.push({socket:a})}}catch(e){r.e(e)}finally{r.f()}}else return;return n},uri:function(e){/^sip:/i.test(e)||(e=`${a.SIP}:${e}`);var t=s.parse(e);if(t&&t.user)return t}},optional:{authorization_user:function(e){if(o.parse(`"${e}"`,`quoted_string`)!==-1)return e},authorization_jwt:function(e){if(typeof e==`string`)return e},user_agent:function(e){if(typeof e==`string`)return e},connection_recovery_max_interval:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},connection_recovery_min_interval:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if(typeof e==`string`){var t=o.parse(e,`SIP_URI`);if(t!==-1)return t}},display_name:function(e){return e},instance_id:function(e){if(/^uuid:/i.test(e)&&(e=e.substr(5)),o.parse(e,`uuid`)!==-1)return e},no_answer_timeout:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},session_timers:function(e){if(typeof e==`boolean`)return e},session_timers_refresh_method:function(e){if(typeof e==`string`&&(e=e.toUpperCase(),e===a.INVITE||e===a.UPDATE))return e},session_timers_force_refresher:function(e){if(typeof e==`boolean`)return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if(typeof e==`boolean`)return e},register_expires:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e=`${a.SIP}:${e}`);var t=s.parse(e);if(t&&!t.user)return t},use_preloaded_route:function(e){if(typeof e==`boolean`)return e},extra_headers:function(e){var n=[];if(Array.isArray(e)&&e.length){var r=t(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;typeof a==`string`&&n.push(a)}}catch(e){r.e(e)}finally{r.f()}}else return;return n}}};e.load=function(e,t){for(var n in u.mandatory)if(t.hasOwnProperty(n)){var r=t[n],a=u.mandatory[n](r);if(a!==void 0)e[n]=a;else throw new l.ConfigurationError(n,r)}else throw new l.ConfigurationError(n);for(var o in u.optional)if(t.hasOwnProperty(o)){var s=t[o];if(i.isEmpty(s))continue;var c=u.optional[o](s);if(c!==void 0)e[o]=c;else throw new l.ConfigurationError(o,s)}}})),_e=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){var t=d();return function(){var n=f(e),r;if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function l(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:u(e)}function u(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function d(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}var p=F().EventEmitter,m=z(),h=k(),g=ie(),_=le(),v=ue(),y=de(),b=U(),x=pe(),S=P(),C=A(),w=N(),T=me(),E=V(),D=he(),O=ge(),j=new m(`UA`),M={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};t.exports=function(e){o(n,e);var t=c(n);a(n,null,[{key:`C`,get:function(){return M}}]);function n(e){var i;if(r(this,n),j.debug(`new() [configuration:%o]`,e),i=t.call(this),i._cache={credentials:{}},i._configuration=Object.assign({},O.settings),i._dynConfiguration={},i._dialogs={},i._applicants={},i._sessions={},i._transport=null,i._contact=null,i._status=M.STATUS_INIT,i._error=null,i._transactions={nist:{},nict:{},ist:{},ict:{}},i._data={},i._closeTimer=null,e===void 0)throw TypeError(`Not enough arguments`);try{i._loadConfig(e)}catch(e){throw i._status=M.STATUS_NOT_READY,i._error=M.CONFIGURATION_ERROR,e}return i._registrator=new g(u(i)),i}return a(n,[{key:`start`,value:function(){j.debug(`start()`),this._status===M.STATUS_INIT?this._transport.connect():this._status===M.STATUS_USER_CLOSED?(j.debug(`restarting UA`),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=M.STATUS_INIT,this._transport.connect()):this._status===M.STATUS_READY?j.debug(`UA is in READY status, not restarted`):j.debug(`ERROR: connection is down, Auto-Recovery system is trying to reconnect`),this._dynConfiguration.register=this._configuration.register}},{key:`register`,value:function(){j.debug(`register()`),this._dynConfiguration.register=!0,this._registrator.register()}},{key:`unregister`,value:function(e){j.debug(`unregister()`),this._dynConfiguration.register=!1,this._registrator.unregister(e)}},{key:`registrator`,value:function(){return this._registrator}},{key:`isRegistered`,value:function(){return this._registrator.registered}},{key:`isConnected`,value:function(){return this._transport.isConnected()}},{key:`call`,value:function(e,t){j.debug(`call()`);var n=new _(this);return n.connect(e,t),n}},{key:`sendMessage`,value:function(e,t,n){j.debug(`sendMessage()`);var r=new v(this);return r.send(e,t,n),r}},{key:`sendOptions`,value:function(e,t,n){j.debug(`sendOptions()`);var r=new y(this);return r.send(e,t,n),r}},{key:`terminateSessions`,value:function(e){for(var t in j.debug(`terminateSessions()`),this._sessions)this._sessions[t].isEnded()||this._sessions[t].terminate(e)}},{key:`stop`,value:function(){var e=this;if(j.debug(`stop()`),this._dynConfiguration={},this._status===M.STATUS_USER_CLOSED){j.debug(`UA already closed`);return}this._registrator.close();var t=Object.keys(this._sessions).length;for(var n in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,n)){j.debug(`closing session ${n}`);try{this._sessions[n].terminate()}catch{}}for(var r in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,r))try{this._applicants[r].close()}catch{}this._status=M.STATUS_USER_CLOSED,Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length===0&&t===0?this._transport.disconnect():this._closeTimer=setTimeout(function(){e._closeTimer=null,e._transport.disconnect()},2e3)}},{key:`normalizeTarget`,value:function(e){return S.normalizeTarget(e,this._configuration.hostport_params)}},{key:`get`,value:function(e){switch(e){case`authorization_user`:return this._configuration.authorization_user;case`realm`:return this._configuration.realm;case`ha1`:return this._configuration.ha1;case`authorization_jwt`:return this._configuration.authorization_jwt;default:j.warn(`get() | cannot get "%s" parameter in runtime`,e);return}}},{key:`set`,value:function(e,t){switch(e){case`authorization_user`:this._configuration.authorization_user=String(t);break;case`password`:this._configuration.password=String(t);break;case`realm`:this._configuration.realm=String(t);break;case`ha1`:this._configuration.ha1=String(t),this._configuration.password=null;break;case`authorization_jwt`:this._configuration.authorization_jwt=String(t);break;case`display_name`:this._configuration.display_name=t;break;case`extra_headers`:this._configuration.extra_headers=t;break;default:return j.warn(`set() | cannot set "%s" parameter in runtime`,e),!1}return!0}},{key:`newTransaction`,value:function(e){this._transactions[e.type][e.id]=e,this.emit(`newTransaction`,{transaction:e})}},{key:`destroyTransaction`,value:function(e){delete this._transactions[e.type][e.id],this.emit(`transactionDestroyed`,{transaction:e})}},{key:`newDialog`,value:function(e){this._dialogs[e.id]=e}},{key:`destroyDialog`,value:function(e){delete this._dialogs[e.id]}},{key:`newMessage`,value:function(e,t){this._applicants[e]=e,this.emit(`newMessage`,t)}},{key:`newOptions`,value:function(e,t){this._applicants[e]=e,this.emit(`newOptions`,t)}},{key:`destroyMessage`,value:function(e){delete this._applicants[e]}},{key:`newRTCSession`,value:function(e,t){this._sessions[e.id]=e,this.emit(`newRTCSession`,t)}},{key:`destroyRTCSession`,value:function(e){delete this._sessions[e.id]}},{key:`registered`,value:function(e){this.emit(`registered`,e)}},{key:`unregistered`,value:function(e){this.emit(`unregistered`,e)}},{key:`registrationFailed`,value:function(e){this.emit(`registrationFailed`,e)}},{key:`receiveRequest`,value:function(e){var t=e.method;if(e.ruri.user!==this._configuration.uri.user&&e.ruri.user!==this._contact.uri.user){j.debug(`Request-URI does not point to us`),e.method!==h.ACK&&e.reply_sl(404);return}if(e.ruri.scheme===h.SIPS){e.reply_sl(416);return}if(!b.checkTransaction(this,e)){if(t===h.INVITE?new b.InviteServerTransaction(this,this._transport,e):t!==h.ACK&&t!==h.CANCEL&&new b.NonInviteServerTransaction(this,this._transport,e),t===h.OPTIONS){if(this.listeners(`newOptions`).length===0){e.reply(200);return}new y(this).init_incoming(e)}else if(t===h.MESSAGE){if(this.listeners(`newMessage`).length===0){e.reply(405);return}new v(this).init_incoming(e)}else if(t===h.INVITE&&!e.to_tag&&this.listeners(`newRTCSession`).length===0){e.reply(405);return}var n,r;if(e.to_tag)n=this._findDialog(e.call_id,e.from_tag,e.to_tag),n?n.receiveRequest(e):t===h.NOTIFY?(r=this._findSession(e),r?r.receiveRequest(e):(j.debug(`received NOTIFY request for a non existent subscription`),e.reply(481,`Subscription does not exist`))):t!==h.ACK&&e.reply(481);else switch(t){case h.INVITE:if(window.RTCPeerConnection){if(e.hasHeader(`replaces`)){var i=e.replaces;n=this._findDialog(i.call_id,i.from_tag,i.to_tag),n?(r=n.owner,r.isEnded()?e.reply(603):r.receiveRequest(e)):e.reply(481)}else r=new _(this),r.init_incoming(e)}else j.warn(`INVITE received but WebRTC is not supported`),e.reply(488);break;case h.BYE:e.reply(481);break;case h.CANCEL:r=this._findSession(e),r?r.receiveRequest(e):j.debug(`received CANCEL request for a non existent session`);break;case h.ACK:break;case h.NOTIFY:this.emit(`sipEvent`,{event:e.event,request:e}),e.reply(200);break;default:e.reply(405)}}}},{key:`_findSession`,value:function(e){var t=e.call_id,n=e.from_tag,r=e.to_tag,i=t+n,a=this._sessions[i],o=t+r,s=this._sessions[o];return a||s||null}},{key:`_findDialog`,value:function(e,t,n){var r=e+t+n,i=this._dialogs[r];return i||(r=e+n+t,i=this._dialogs[r],i||null)}},{key:`_loadConfig`,value:function(e){try{O.load(this._configuration,e)}catch(e){throw e}this._configuration.display_name===0&&(this._configuration.display_name=`0`),this._configuration.instance_id||(this._configuration.instance_id=S.newUUID()),this._configuration.jssip_id=S.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,``);try{this._transport=new x(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=I.bind(this),this._transport.onconnect=L.bind(this),this._transport.ondisconnect=R.bind(this),this._transport.ondata=B.bind(this)}catch(e){throw j.warn(e),new C.ConfigurationError(`sockets`,this._configuration.sockets)}if(delete this._configuration.sockets,this._configuration.authorization_user||(this._configuration.authorization_user=this._configuration.uri.user),!this._configuration.registrar_server){var n=this._configuration.uri.clone();n.user=null,n.clearParams(),n.clearHeaders(),this._configuration.registrar_server=n}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new w(`sip`,S.createRandomToken(8),this._configuration.via_host,null,{transport:`ws`}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.anonymous||null,n=e.outbound||null,r=`<`;return r+=t?this.temp_gruu||`sip:anonymous@anonymous.invalid;transport=ws`:this.pub_gruu||this.uri.toString(),n&&(t?!this.temp_gruu:!this.pub_gruu)&&(r+=`;ob`),r+=`>`,r}};var r=[`authorization_user`,`password`,`realm`,`ha1`,`authorization_jwt`,`display_name`,`register`,`extra_headers`];for(var i in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,i)&&(r.indexOf(i)===-1?Object.defineProperty(this._configuration,i,{writable:!1,configurable:!1}):Object.defineProperty(this._configuration,i,{writable:!0,configurable:!1}));for(var a in j.debug(`configuration parameters after validation:`),this._configuration)if(Object.prototype.hasOwnProperty.call(O.settings,a))switch(a){case`uri`:case`registrar_server`:j.debug(`- ${a}: ${this._configuration[a]}`);break;case`password`:case`ha1`:case`authorization_jwt`:j.debug(`- ${a}: NOT SHOWN`);break;default:j.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}},{key:`C`,get:function(){return M}},{key:`status`,get:function(){return this._status}},{key:`contact`,get:function(){return this._contact}},{key:`configuration`,get:function(){return this._configuration}},{key:`transport`,get:function(){return this._transport}}]),n}(p);function I(e){this.emit(`connecting`,e)}function L(e){this._status!==M.STATUS_USER_CLOSED&&(this._status=M.STATUS_READY,this._error=null,this.emit(`connected`,e),this._dynConfiguration.register&&this._registrator.register())}function R(e){for(var t=[`nict`,`ict`,`nist`,`ist`],n=0,r=t;n<r.length;n++){var i=r[n];for(var a in this._transactions[i])Object.prototype.hasOwnProperty.call(this._transactions[i],a)&&this._transactions[i][a].onTransportError()}this.emit(`disconnected`,e),this._registrator.onTransportClosed(),this._status!==M.STATUS_USER_CLOSED&&(this._status=M.STATUS_NOT_READY,this._error=M.NETWORK_ERROR)}function B(e){var t=e.transport,n=e.message;if(n=T.parseMessage(n,this),n&&!(this._status===M.STATUS_USER_CLOSED&&n instanceof E.IncomingRequest)&&D(n,this,t)){if(n instanceof E.IncomingRequest)n.transport=t,this.receiveRequest(n);else if(n instanceof E.IncomingResponse){var r;switch(n.method){case h.INVITE:r=this._transactions.ict[n.via_branch],r&&r.receiveResponse(n);break;case h.ACK:break;default:r=this._transactions.nict[n.via_branch],r&&r.receiveResponse(n)}}}}})),ve=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=z(),o=M(),s=new a(`WebSocketInterface`);t.exports=function(){function e(t){n(this,e),s.debug(`new() [url:"%s"]`,t),this._url=t,this._sip_uri=null,this._via_transport=null,this._ws=null;var r=o.parse(t,`absoluteURI`);if(r===-1)throw s.warn(`invalid WebSocket URI: ${t}`),TypeError(`Invalid argument: ${t}`);if(r.scheme!==`wss`&&r.scheme!==`ws`)throw s.warn(`invalid WebSocket URI scheme: ${r.scheme}`),TypeError(`Invalid argument: ${t}`);this._sip_uri=`sip:${r.host}${r.port?`:${r.port}`:``};transport=ws`,this._via_transport=r.scheme.toUpperCase()}return i(e,[{key:`connect`,value:function(){if(s.debug(`connect()`),this.isConnected()){s.debug(`WebSocket ${this._url} is already connected`);return}if(this.isConnecting()){s.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),s.debug(`connecting to WebSocket ${this._url}`);try{this._ws=new WebSocket(this._url,`sip`),this._ws.binaryType=`arraybuffer`,this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(e){this._onError(e)}}},{key:`disconnect`,value:function(){s.debug(`disconnect()`),this._ws&&=(this._ws.onopen=function(){},this._ws.onclose=function(){},this._ws.onmessage=function(){},this._ws.onerror=function(){},this._ws.close(),null)}},{key:`send`,value:function(e){return s.debug(`send()`),this.isConnected()?(this._ws.send(e),!0):(s.warn(`unable to send message, WebSocket is not open`),!1)}},{key:`isConnected`,value:function(){return this._ws&&this._ws.readyState===this._ws.OPEN}},{key:`isConnecting`,value:function(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}},{key:`_onOpen`,value:function(){s.debug(`WebSocket ${this._url} connected`),this.onconnect()}},{key:`_onClose`,value:function(e){var t=e.wasClean,n=e.code,r=e.reason;s.debug(`WebSocket ${this._url} closed`),t===!1&&s.debug(`WebSocket abrupt disconnection`),this.ondisconnect(!t,n,r)}},{key:`_onMessage`,value:function(e){var t=e.data;s.debug(`received WebSocket message`),this.ondata(t)}},{key:`_onError`,value:function(e){s.warn(`WebSocket ${this._url} error: `,e)}},{key:`via_transport`,get:function(){return this._via_transport},set:function(e){this._via_transport=e.toUpperCase()}},{key:`sip_uri`,get:function(){return this._sip_uri}},{key:`url`,get:function(){return this._url}}]),e}()})),ye=u(s(((e,t)=>{var n=(O(),d(f).default),r=k(),i=A(),a=P(),o=_e(),s=N(),c=j(),l=M(),u=ve();R()(`JsSIP`)(`version %s`,n.version),t.exports={C:r,Exceptions:i,Utils:a,UA:o,URI:s,NameAddrHeader:c,WebSocketInterface:u,Grammar:l,debug:R(),get name(){return n.title},get version(){return n.version}}}))(),1);function be(){return{createSocket:(e,t)=>new xe(e,t),createUa:e=>new ye.UA(e)}}var xe=class extends ye.WebSocketInterface{ticket;constructor(e,t){super(e),this.ticket=t}protocols(){return this.ticket===``?[`sip`]:[`xcall-ticket.${this.ticket}`,`sip`]}connect(){if(this.isConnected()||this.isConnecting())return;let e=this;e._ws&&this.disconnect();try{e._ws=new WebSocket(this.url,this.protocols()),e._ws.binaryType=`arraybuffer`,e._ws.onopen=e._onOpen.bind(this),e._ws.onclose=e._onClose.bind(this),e._ws.onmessage=e._onMessage.bind(this),e._ws.onerror=e._onError.bind(this)}catch(t){e._onError.call(this,t)}}};exports.createJsSipFactory=be,exports.t=d;
|
|
@@ -14,6 +14,7 @@ export interface DiagnosticsResourceCounts {
|
|
|
14
14
|
readonly peerConnections: number;
|
|
15
15
|
readonly audioElements: number;
|
|
16
16
|
readonly webSockets: number;
|
|
17
|
+
readonly deletedSessions: number;
|
|
17
18
|
}
|
|
18
19
|
export interface DiagnosticCallSnapshot {
|
|
19
20
|
readonly callId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Diagnostics-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Diagnostics-D38Hm3NT.cjs"),t=require("../redact-Bq26pObO.cjs");require("../createJsSipFactory-Dr8HbLl-.cjs"),exports.Diagnostics=e.t,exports.RingBuffer=e.n,exports.diagnosticsVersion=e.r,exports.redactText=t.t,exports.redactValue=t.n;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { n as e, t } from "../Diagnostics-
|
|
2
|
-
import { n, t as
|
|
3
|
-
|
|
4
|
-
var i = "0.1.0";
|
|
5
|
-
//#endregion
|
|
6
|
-
export { t as Diagnostics, e as RingBuffer, i as diagnosticsVersion, r as redactText, n as redactValue };
|
|
1
|
+
import { n as e, r as t, t as n } from "../Diagnostics-Di049OpT.js";
|
|
2
|
+
import { n as r, t as i } from "../redact-DB3CMbsK.js";
|
|
3
|
+
export { n as Diagnostics, e as RingBuffer, t as diagnosticsVersion, i as redactText, r as redactValue };
|
|
@@ -3,6 +3,10 @@ export interface CCBarErrorOptions {
|
|
|
3
3
|
requestId?: string;
|
|
4
4
|
callId?: string;
|
|
5
5
|
cause?: unknown;
|
|
6
|
+
/** Stable server protocol code, retained for lifecycle recovery decisions. */
|
|
7
|
+
serverCode?: string;
|
|
8
|
+
/** HTTP status returned by the WebPhone API, when available. */
|
|
9
|
+
status?: number;
|
|
6
10
|
}
|
|
7
11
|
export declare class CCBarError extends Error {
|
|
8
12
|
readonly code: CCBarErrorCode;
|
|
@@ -11,5 +15,7 @@ export declare class CCBarError extends Error {
|
|
|
11
15
|
readonly requestId?: string;
|
|
12
16
|
readonly callId?: string;
|
|
13
17
|
readonly cause?: unknown;
|
|
18
|
+
readonly serverCode?: string;
|
|
19
|
+
readonly status?: number;
|
|
14
20
|
constructor(code: CCBarErrorCode, category: CCBarErrorCategory, retryable: boolean, options?: CCBarErrorOptions);
|
|
15
21
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./SharedWorkerProtocol-39dch6xL.cjs"),t=require("./CCBarClient-DCQ8XjcL.cjs"),n=require("./Diagnostics-D38Hm3NT.cjs"),r=require("./redact-Bq26pObO.cjs");require("./diagnostics/index.cjs"),require("./createJsSipFactory-Dr8HbLl-.cjs");function i(e){if(e.code!==`OK`)throw TypeError(`Unexpected session response code: ${e.code}`);if(e.data===void 0||e.data===null)throw TypeError(`Unexpected session response: missing data`);return e.data}function a(e={}){return{version:`0.1.0`,options:e}}var o=`0.1.0`;exports.CCBarCall=t.a,exports.CCBarClient=t.t,exports.CCBarError=e.i,exports.CallManager=t.i,exports.CallStateError=t.c,exports.Diagnostics=n.t,exports.RingBuffer=n.n,exports.TokenManager=t.s,exports.TypedEventBus=t.p,exports.WebPhoneApi=t.o,exports.assertCallTransition=t.l,exports.canTransition=t.u,exports.createSdk=a,exports.createSharedWorkerSelection=t.n,exports.diagnosticsVersion=n.r,exports.parseSessionResponse=i,exports.redactText=r.t,exports.redactValue=r.n,exports.resolveWorkerUrl=t.r,exports.transition=t.d,exports.transitions=t.f,exports.version=o;
|
package/dist/index.js
CHANGED
|
@@ -1,152 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as t, c as n, d as r, i,
|
|
3
|
-
import { n as
|
|
4
|
-
import { n as
|
|
5
|
-
import
|
|
6
|
-
import { t as _ } from "./SharedWorkerProtocol-BqUafs8d.js";
|
|
1
|
+
import { i as e } from "./SharedWorkerProtocol-DKVQ5-po.js";
|
|
2
|
+
import { a as t, c as n, d as r, f as i, i as a, l as o, n as s, o as c, p as l, r as u, s as d, t as f, u as p } from "./CCBarClient-CcPfEToZ.js";
|
|
3
|
+
import { n as m, r as h, t as g } from "./Diagnostics-Di049OpT.js";
|
|
4
|
+
import { n as _, t as v } from "./redact-DB3CMbsK.js";
|
|
5
|
+
import "./diagnostics/index.js";
|
|
7
6
|
//#region src/api/contracts.ts
|
|
8
|
-
function
|
|
7
|
+
function y(e) {
|
|
9
8
|
if (e.code !== "OK") throw TypeError(`Unexpected session response code: ${e.code}`);
|
|
10
9
|
if (e.data === void 0 || e.data === null) throw TypeError("Unexpected session response: missing data");
|
|
11
10
|
return e.data;
|
|
12
11
|
}
|
|
13
12
|
//#endregion
|
|
14
|
-
//#region src/shared/SharedWorkerClient.ts
|
|
15
|
-
var y = class {
|
|
16
|
-
port;
|
|
17
|
-
timeoutMs;
|
|
18
|
-
pending = /* @__PURE__ */ new Map();
|
|
19
|
-
eventHandlers = /* @__PURE__ */ new Set();
|
|
20
|
-
closed = !1;
|
|
21
|
-
lifecycleState = "connected";
|
|
22
|
-
constructor(e, t = {}) {
|
|
23
|
-
this.port = e, this.timeoutMs = t.timeoutMs ?? 15e3, this.port.onmessage = (e) => this.handleMessage(e.data), this.port.start();
|
|
24
|
-
}
|
|
25
|
-
request(t) {
|
|
26
|
-
return this.closed ? Promise.reject(new e("SDK_ALREADY_DISPOSED", "internal", !1)) : this.pending.has(t.requestId) ? Promise.reject(new e("SDK_INTERNAL_ERROR", "internal", !1, { requestId: t.requestId })) : this.lifecycleState === "reconnecting" && t.type === "command" && (t.command === "dial" || t.command === "answer") ? Promise.reject(new e("CALL_OPERATION_NOT_ALLOWED", "call", !0, { callId: t.payload?.callId })) : new Promise((n, r) => {
|
|
27
|
-
let i = setTimeout(() => {
|
|
28
|
-
this.pending.delete(t.requestId), r(new e("NETWORK_TIMEOUT", "network", !0, { requestId: t.requestId }));
|
|
29
|
-
}, this.timeoutMs);
|
|
30
|
-
this.pending.set(t.requestId, {
|
|
31
|
-
resolve: (e) => n(e),
|
|
32
|
-
reject: r,
|
|
33
|
-
timer: i
|
|
34
|
-
}), this.port.postMessage(t);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
onEvent(e) {
|
|
38
|
-
return this.closed ? () => void 0 : (this.eventHandlers.add(e), () => this.eventHandlers.delete(e));
|
|
39
|
-
}
|
|
40
|
-
getLifecycleState() {
|
|
41
|
-
return this.lifecycleState;
|
|
42
|
-
}
|
|
43
|
-
close() {
|
|
44
|
-
this.closed || (this.closed = !0, this.pending.forEach((t) => {
|
|
45
|
-
clearTimeout(t.timer), t.reject(new e("SDK_ALREADY_DISPOSED", "internal", !1));
|
|
46
|
-
}), this.pending.clear(), this.eventHandlers.clear(), this.port.close());
|
|
47
|
-
}
|
|
48
|
-
handleMessage(e) {
|
|
49
|
-
try {
|
|
50
|
-
let t = _(e);
|
|
51
|
-
if (t.type === "event") {
|
|
52
|
-
t.event === "connection.stateChanged" && b(t.payload) && (this.lifecycleState = t.payload.state), this.eventHandlers.forEach((e) => e(t));
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (t.type !== "response") return;
|
|
56
|
-
let n = this.pending.get(t.requestId);
|
|
57
|
-
if (n === void 0) return;
|
|
58
|
-
this.pending.delete(t.requestId), clearTimeout(n.timer), t.ok ? n.resolve(t.result) : n.reject(x(t));
|
|
59
|
-
} catch (e) {
|
|
60
|
-
this.pending.forEach((t) => t.reject(e)), this.pending.clear();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
function b(e) {
|
|
65
|
-
return typeof e == "object" && !!e && "state" in e && (e.state === "connected" || e.state === "reconnecting");
|
|
66
|
-
}
|
|
67
|
-
function x(t) {
|
|
68
|
-
let n = t.error;
|
|
69
|
-
return new e(n?.code ?? "SDK_INTERNAL_ERROR", n?.category ?? "internal", n?.retryable ?? !1, {
|
|
70
|
-
requestId: t.requestId,
|
|
71
|
-
...n?.message === void 0 ? {} : { cause: n.message }
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/shared/SharedWorkerFactory.ts
|
|
76
|
-
function S(t = {}) {
|
|
77
|
-
if ((t.enabled ?? "auto") === !1) return {
|
|
78
|
-
mode: "single-tab",
|
|
79
|
-
reason: "disabled"
|
|
80
|
-
};
|
|
81
|
-
let n = t.locationHref ?? w(), r = C(t.url, n), i = (n) => {
|
|
82
|
-
if (t.fallback === "error") throw new e("CONFIG_INVALID", "configuration", !1, { cause: n });
|
|
83
|
-
return {
|
|
84
|
-
mode: "single-tab",
|
|
85
|
-
reason: n
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
if (r === void 0) return i("SharedWorker URL is unavailable");
|
|
89
|
-
if (!E(r, n)) return i("SharedWorker URL must be same-origin");
|
|
90
|
-
let a = t.workerCtor ?? T();
|
|
91
|
-
if (a === void 0) return i("SharedWorker is not supported");
|
|
92
|
-
let o;
|
|
93
|
-
try {
|
|
94
|
-
o = new a(r, t.name === void 0 ? void 0 : { name: t.name });
|
|
95
|
-
} catch (e) {
|
|
96
|
-
return i(`SharedWorker construction failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
97
|
-
}
|
|
98
|
-
let s = t.tabId ?? D(), c = new y(o.port), l = {
|
|
99
|
-
version: 1,
|
|
100
|
-
type: "attach",
|
|
101
|
-
requestId: O(),
|
|
102
|
-
tabId: s
|
|
103
|
-
}, u = c.request(l).then(() => void 0).catch((e) => {
|
|
104
|
-
throw c.close(), e;
|
|
105
|
-
});
|
|
106
|
-
return {
|
|
107
|
-
mode: "shared",
|
|
108
|
-
worker: o,
|
|
109
|
-
client: c,
|
|
110
|
-
tabId: s,
|
|
111
|
-
workerUrl: r,
|
|
112
|
-
ready: u
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function C(e, t = w()) {
|
|
116
|
-
try {
|
|
117
|
-
return t === void 0 ? void 0 : new URL(e ?? "./shared-worker.js", t).toString();
|
|
118
|
-
} catch {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function w() {
|
|
123
|
-
return typeof location > "u" ? void 0 : location.href;
|
|
124
|
-
}
|
|
125
|
-
function T() {
|
|
126
|
-
if (typeof SharedWorker == "function") return SharedWorker;
|
|
127
|
-
}
|
|
128
|
-
function E(e, t) {
|
|
129
|
-
if (t === void 0) return !0;
|
|
130
|
-
try {
|
|
131
|
-
return new URL(e, t).origin === new URL(t).origin;
|
|
132
|
-
} catch {
|
|
133
|
-
return !1;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
function D() {
|
|
137
|
-
return `tab-${typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).slice(2)}`;
|
|
138
|
-
}
|
|
139
|
-
function O() {
|
|
140
|
-
return `attach-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
141
|
-
}
|
|
142
|
-
//#endregion
|
|
143
13
|
//#region src/index.ts
|
|
144
|
-
function
|
|
14
|
+
function b(e = {}) {
|
|
145
15
|
return {
|
|
146
16
|
version: "0.1.0",
|
|
147
17
|
options: e
|
|
148
18
|
};
|
|
149
19
|
}
|
|
150
|
-
var
|
|
20
|
+
var x = "0.1.0";
|
|
151
21
|
//#endregion
|
|
152
|
-
export {
|
|
22
|
+
export { t as CCBarCall, f as CCBarClient, e as CCBarError, a as CallManager, n as CallStateError, g as Diagnostics, m as RingBuffer, d as TokenManager, l as TypedEventBus, c as WebPhoneApi, o as assertCallTransition, p as canTransition, b as createSdk, s as createSharedWorkerSelection, h as diagnosticsVersion, y as parseSessionResponse, v as redactText, _ as redactValue, u as resolveWorkerUrl, r as transition, i as transitions, x as version };
|