@16x/webphone-sdk 3.2.2 → 3.2.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.
- package/CHANGELOG.md +12 -0
- package/README.md +6 -3
- package/dist/{Diagnostics-KITeXgJy.cjs → Diagnostics-B1EdRU6l.cjs} +1 -1
- package/dist/{Diagnostics-DCXWv_mJ.js → Diagnostics-CwcR4kCt.js} +1 -1
- package/dist/{JsSipAdapter-CwDotPN2.js → JsSipAdapter-Cz6MwjPa.js} +5 -2
- package/dist/{JsSipAdapter-D_Ozsugr.cjs → JsSipAdapter-DZZ6vQSa.cjs} +1 -1
- package/dist/SharedWorkerProtocol-C-4KpECM.cjs +1 -0
- package/dist/SharedWorkerProtocol-CffZrUXg.js +119 -0
- package/dist/core/CCBarCall.d.ts +3 -0
- package/dist/diagnostics/index.cjs +1 -1
- package/dist/diagnostics/index.js +1 -1
- package/dist/errors/CCBarError.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/index.umd.js +10 -10
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +2 -2
- package/dist/legacySessionProvider-BK9-n2uj.cjs +1 -0
- package/dist/{legacySessionProvider-BuPxBMQY.js → legacySessionProvider-BdOk_ssd.js} +54 -31
- package/dist/shared/SharedWorkerProtocol.d.ts +1 -0
- package/dist/shared-worker.cjs +1 -1
- package/dist/shared-worker.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/SharedWorkerProtocol-39dch6xL.cjs +0 -1
- package/dist/SharedWorkerProtocol-DKVQ5-po.js +0 -87
- package/dist/legacySessionProvider-pPrvCuhz.cjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.2.4 - 2026-10-05
|
|
4
|
+
|
|
5
|
+
- Prevent overlapping hold/resume requests and include actionable `cause.reason` values when an operation is already pending or JsSIP rejects a hold change.
|
|
6
|
+
- Track local and remote hold origins separately; reject a local resume request while only the remote party has held the call.
|
|
7
|
+
- Document hold/resume completion and diagnostic causes.
|
|
8
|
+
|
|
9
|
+
## 3.2.3 - 2026-10-04
|
|
10
|
+
|
|
11
|
+
- Give `CCBarError.message` customer-readable Chinese text while keeping stable string `code` values for programmatic handling.
|
|
12
|
+
- Preserve numeric platform response codes as optional `platformCode`; normalize token rejection from the seat account API without mislabeling every 401 as an expired token.
|
|
13
|
+
- Carry `platformCode` and readable messages through SharedWorker serialization.
|
|
14
|
+
|
|
3
15
|
## 3.2.2 - 2026-10-04
|
|
4
16
|
|
|
5
17
|
- Reject malformed outbound destinations before creating a call or sending a SIP INVITE; preserve 3–20 digit phone numbers and SIP/SIPS URI destinations.
|
package/README.md
CHANGED
|
@@ -133,7 +133,7 @@ const offCallFailed = client.on('call.failed', ({ callId, error }) => {
|
|
|
133
133
|
});
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
拨号发起阶段的错误会让 `dial()` 拒绝;接通后的通话错误通过 `call.failed` 事件报告。SDK
|
|
136
|
+
拨号发起阶段的错误会让 `dial()` 拒绝;接通后的通话错误通过 `call.failed` 事件报告。npm SDK 与 CCBar Script 使用相同的字符串 `code` 和可读 `message`。若后端返回数字错误码,SDK 将其保留在可选的 `platformCode` 中:
|
|
137
137
|
|
|
138
138
|
```ts
|
|
139
139
|
import { CCBarError } from '@16x/webphone-sdk';
|
|
@@ -142,13 +142,16 @@ try {
|
|
|
142
142
|
await client.dial({ destination: '9196' });
|
|
143
143
|
} catch (error) {
|
|
144
144
|
if (error instanceof CCBarError) {
|
|
145
|
-
showCallError(error.
|
|
145
|
+
showCallError(error.message);
|
|
146
|
+
reportSafeError({ code: error.code, platformCode: error.platformCode });
|
|
146
147
|
} else {
|
|
147
|
-
showCallError('
|
|
148
|
+
showCallError('拨号失败,请稍后重试。');
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
```
|
|
151
152
|
|
|
153
|
+
客户代码应使用 `error.code` 做程序判断、将 `error.message` 显示给用户;`platformCode` 仅用于排查后端响应,不应作为 SDK 业务分支的依据。错误码清单和处理建议见 [错误码说明](./docs/customer/webphone/05-error-codes.md)。
|
|
154
|
+
|
|
152
155
|
通话状态含义如下。`ended` 和 `failed` 都是终态;一个 Call 到达终态后不会再恢复到其他状态。
|
|
153
156
|
|
|
154
157
|
| 状态 | 含义 |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./redact-Bq26pObO.cjs");var t=`3.2.
|
|
1
|
+
const e=require("./redact-Bq26pObO.cjs");var t=`3.2.4`,n=class{capacity;entries=[];constructor(e){if(this.capacity=e,!Number.isInteger(e)||e<=0)throw RangeError(`RingBuffer capacity must be a positive integer`)}push(e){this.entries.length===this.capacity&&this.entries.shift(),this.entries.push(e)}toArray(){return[...this.entries]}},r=`@16x/webphone-sdk`,i=200,a=class{dependencies;logs=new n(i);now;constructor(e){this.dependencies=e,this.now=e.now??(()=>new Date)}log(t,n,r){this.logs.push({timestamp:this.now().toISOString(),level:t,message:e.t(n),...r===void 0?{}:{context:e.n(r)}})}async getReport(n={}){let i=n.includeRecentLogs!==!1,a=n.includeDeviceNames===!0,u=n.maskPhoneNumbers!==!1,d=this.dependencies.getSnapshot(),f=this.dependencies.getPermission===void 0?d.permission:await o(this.dependencies.getPermission,d.permission),p=a?await s(this.dependencies.getDeviceNames):void 0,m=l(c(this.dependencies.getUserAgent)),h={generatedAt:this.now().toISOString(),sdk:{name:r,version:t},browser:m.browser,os:m.os,...d,permission:f,recentLogs:i?this.logs.toArray():[],...p===void 0?{}:{deviceNames:p}};return e.n(h,{maskPhoneNumbers:u})}};async function o(e,t){try{return await e()}catch{return t}}async function s(e){if(e===void 0)return[];try{return[...await e()]}catch{return[]}}function c(e){if(e!==void 0)try{return e()}catch{return``}return typeof navigator>`u`?``:navigator.userAgent}function l(e){return{browser:u(e),os:d(e)}}function u(e){for(let[t,n]of[[`Edge`,/Edg\/([\d.]+)/],[`Chrome`,/(?:Chrome|CriOS)\/([\d.]+)/],[`Firefox`,/(?:Firefox|FxiOS)\/([\d.]+)/],[`Safari`,/Version\/([\d.]+).*Safari/]]){let r=e.match(n);if(r?.[1]!==void 0)return{name:t,version:r[1]}}return{name:`unknown`,version:``}}function d(e){let t=e.match(/(?:iPhone|iPad).*OS ([\d_]+)/);if(t?.[1]!==void 0)return{name:`iOS`,version:t[1].replaceAll(`_`,`.`)};let n=e.match(/Android ([\d.]+)/);if(n?.[1]!==void 0)return{name:`Android`,version:n[1]};let r=e.match(/Windows NT ([\d.]+)/);if(r?.[1]!==void 0)return{name:`Windows`,version:r[1]};let i=e.match(/Mac OS X ([\d_]+)/);return i?.[1]===void 0?/Linux/.test(e)?{name:`Linux`,version:``}:{name:`unknown`,version:``}:{name:`macOS`,version:i[1].replaceAll(`_`,`.`)}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as e } from "./SharedWorkerProtocol-
|
|
1
|
+
import { i as e } from "./SharedWorkerProtocol-CffZrUXg.js";
|
|
2
2
|
//#region src/sip/nativeMediaAdapter.ts
|
|
3
3
|
function t(e) {
|
|
4
4
|
let t = /* @__PURE__ */ new Map();
|
|
@@ -369,7 +369,10 @@ var c = class {
|
|
|
369
369
|
}
|
|
370
370
|
this.pendingHoldReject = c;
|
|
371
371
|
try {
|
|
372
|
-
this.session[t](void 0, s) || c(
|
|
372
|
+
this.session[t](void 0, s) || c({
|
|
373
|
+
reason: "jssip_operation_rejected",
|
|
374
|
+
operation: t
|
|
375
|
+
});
|
|
373
376
|
} catch (e) {
|
|
374
377
|
c(e);
|
|
375
378
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./SharedWorkerProtocol-
|
|
1
|
+
const e=require("./SharedWorkerProtocol-C-4KpECM.cjs");require("./createJsSipFactory-B1ORbJiP.cjs");function t(e){let t=new Map;return{peerConnection:{getSenders:()=>e.getSenders().map(n=>{let r=t.get(n);if(r!==void 0)return r;let i={get track(){return n.track},get senderKind(){let t=n.track;if(t!==null)return t.kind===`audio`||t.kind===`video`?t.kind:void 0;let r=e.getTransceivers().find(e=>e.sender===n)?.receiver.track;if(r?.kind===`audio`||r?.kind===`video`)return r.kind;let i=n.getParameters().codecs?.find(e=>typeof e.mimeType==`string`);if(i?.mimeType?.toLowerCase().startsWith(`video/`))return`video`;if(i?.mimeType?.toLowerCase().startsWith(`audio/`))return`audio`},replaceTrack:e=>n.replaceTrack(e)};return t.set(n,i),i}),close:()=>{e.connectionState!==`closed`&&e.close()}},trackSource:{onTrack(t){let n=e=>{let n=e.track;t({streams:[...e.streams],track:n})};return e.addEventListener(`track`,n),()=>e.removeEventListener(`track`,n)}}}}var n=300,r=25,i=2,a=``,o=120;function s(e){let t=Math.floor(Number(e.sip.registerExpires));return Number.isFinite(t)&&t>0?t:n}var c=class{factory;transportBaseUrl;keepaliveSeconds;agentTerminal;sessionTimers;ua;uaListeners;incomingHandlers;iceServers;pendingConnection;disposed=!1;warmPc;keepaliveTimer;keepaliveBusy=!1;registerExpiresSeconds=0;connectionHandlers=new Set;constructor(e,t,n=r,i=a,o=!1){this.factory=e,this.transportBaseUrl=t,this.keepaliveSeconds=n,this.agentTerminal=i,this.sessionTimers=o}terminalHeaders(){return this.agentTerminal===``?[]:[`X-Agent-Terminal: ${this.agentTerminal}`]}warmIceCandidatePool(){if(this.closeWarmPc(),typeof RTCPeerConnection<`u`&&this.iceServers!==void 0)try{this.warmPc=new RTCPeerConnection({iceServers:[...this.iceServers],iceCandidatePoolSize:i})}catch{this.warmPc=void 0}}closeWarmPc(){try{this.warmPc?.close()}catch{}this.warmPc=void 0}keepaliveTick(e){if(this.isCurrentUa(e)&&!this.keepaliveBusy)try{if(typeof e.isConnected==`function`&&e.isConnected()===!1||typeof e.register!=`function`)return;this.keepaliveBusy=!0,e.register({extraHeaders:this.terminalHeaders()})}catch{}finally{this.keepaliveBusy=!1}}startKeepalive(e,t){if(this.stopKeepalive(),!Number.isFinite(this.keepaliveSeconds)||this.keepaliveSeconds<=0||t>0&&t<=this.keepaliveSeconds)return;let n=Math.max(10,Math.floor(this.keepaliveSeconds))*1e3;this.keepaliveTimer=setInterval(()=>this.keepaliveTick(e),n)}stopKeepalive(){this.keepaliveTimer!==void 0&&clearInterval(this.keepaliveTimer),this.keepaliveTimer=void 0}connect(t){this.assertNotDisposed(),this.disconnect(this.registrationError(`SIP connection replaced`));try{let e=this.factory.createUa({sockets:f(this.factory.createSocket(this.withoutTicket(this.resolveWssUrl(t.transport.wssUrl)),t.transport.ticket)),uri:t.sip.uri,password:t.sip.registerTicket,registrar_server:t.sip.registrar,register:!0,register_expires:s(t),session_timers:this.sessionTimers,...this.agentTerminal===``?{}:{user_agent:this.agentTerminal}});return this.ua=e,this.registerExpiresSeconds=s(t),this.iceServers=t.iceServers,this.uaListeners=[],this.startRegistration(e)}catch(t){let n=t instanceof e.i&&t.code===`CONFIG_INVALID`?t:this.transportError(t);return this.disconnect(n),Promise.reject(n)}}disconnect(e=this.registrationError(`SIP connection disconnected`)){this.stopKeepalive(),this.closeWarmPc();let t=this.pendingConnection;this.pendingConnection=void 0,this.ua!==void 0&&(this.removeUaListeners(this.ua),this.ua.stop()),this.ua=void 0,this.uaListeners=void 0,this.iceServers=void 0,t?.reject(e)}dial(t,n){let r=this.requireUa();if(t.trim()===``)throw new e.i(`CALL_INVALID_DESTINATION`,`call`,!1);try{let e=n===void 0?{mediaConstraints:{audio:!0,video:!1},sessionTimersExpires:o,pcConfig:{iceServers:this.iceServers,iceCandidatePoolSize:i}}:{mediaConstraints:{audio:!0,video:!1},sessionTimersExpires:o,pcConfig:{iceServers:[...n.iceServers],iceCandidatePoolSize:i},extraHeaders:[...this.terminalHeaders(),...n.extraHeaders,...n.type===`extension`?[`X-XCall-Destination-Type: extension`]:[]]};return new l(r.call(t,e))}catch(t){throw new e.i(`CALL_OPERATION_NOT_ALLOWED`,`call`,!1,{cause:t})}}onIncoming(e){this.assertNotDisposed();let t=this.incomingHandlers??new Set;return this.incomingHandlers=t,t.add(e),()=>t.delete(e)}onConnectionStateChanged(e){return this.disposed?()=>void 0:(this.connectionHandlers.add(e),()=>this.connectionHandlers.delete(e))}dispose(){this.disposed||(this.disposed=!0,this.disconnect(),this.incomingHandlers=void 0,this.connectionHandlers.clear())}getResourceCounts(){return{listeners:(this.uaListeners?.length??0)+(this.incomingHandlers?.size??0)+this.connectionHandlers.size,webSockets:this.ua===void 0?0:1}}handleIncoming(e){if(!u(e))return;let t=e.session;if(t===void 0)return;let n=new l(t);this.incomingHandlers?.forEach(e=>e(n))}startRegistration(e){let t=!0,n=!1,r=new Promise((t,n)=>{this.pendingConnection={ua:e,resolve:t,reject:n}});this.listen(e,`registered`,()=>{if(this.isCurrentUa(e)){if(t){n=!0;return}this.resolveConnection(e)}}),this.listen(e,`registrationFailed`,t=>{if(!this.isCurrentUa(e))return;let n=this.registrationError(this.registrationFailureCause(t));this.connectionHandlers.forEach(e=>e(`failed`,n)),this.disconnect(n)}),this.listen(e,`disconnected`,t=>{if(!this.isCurrentUa(e))return;let n=this.transportError(t);this.connectionHandlers.forEach(e=>e(`disconnected`,n)),this.disconnect(n)}),this.listen(e,`newRTCSession`,t=>{this.isCurrentUa(e)&&this.handleIncoming(t)});try{e.start()}catch(e){let t=this.transportError(e);this.connectionHandlers.forEach(e=>e(`failed`,t)),this.disconnect(t)}finally{t=!1}return n&&this.resolveConnection(e),r}listen(e,t,n){e.on(t,n),this.uaListeners?.push({event:t,handler:n})}removeUaListeners(e){this.uaListeners?.forEach(({event:t,handler:n})=>e.off(t,n))}isCurrentUa(e){return this.ua===e}resolveConnection(e){let t=this.pendingConnection;t?.ua===e&&(this.pendingConnection=void 0,t.resolve(),this.warmIceCandidatePool(),this.startKeepalive(e,this.registerExpiresSeconds),this.connectionHandlers.forEach(e=>e(`registered`)))}resolveWssUrl(e){let t=this.transportBaseUrl?.trim()===``||this.transportBaseUrl===void 0?typeof location>`u`?`http://localhost`:location.origin:this.transportBaseUrl,n=e.startsWith(`/`)?new URL(e,t):new URL(e);return n.protocol===`http:`&&(n.protocol=`ws:`),n.protocol===`https:`&&(n.protocol=`wss:`),this.assertAllowedWssUrl(n),n.toString()}assertAllowedWssUrl(t){if(t.protocol!==`wss:`&&!(t.protocol===`ws:`&&p(t.hostname)))throw new e.i(`CONFIG_INVALID`,`configuration`,!1,{cause:t.origin})}withoutTicket(e){let t=new URL(e);return t.searchParams.delete(`ticket`),t.toString()}requireUa(){if(this.assertNotDisposed(),this.ua===void 0)throw new e.i(`CALL_NOT_CONNECTED`,`call`,!1);return this.ua}assertNotDisposed(){if(this.disposed)throw new e.i(`SDK_ALREADY_DISPOSED`,`internal`,!1)}registrationError(t){return new e.i(`REGISTRATION_FAILED`,`registration`,!0,{cause:t})}transportError(t){return new e.i(`SIP_WS_UNAVAILABLE`,`registration`,!0,{cause:t})}registrationFailureCause(e){return typeof e==`object`&&e&&`cause`in e?e.cause:e}},l=class{session;pendingHoldReject;mediaRegistration;mediaConnection;mediaHandlers=new Set;mediaWatchStarted=!1;sessionUnsubscribeFromPeerConnection;constructor(e){this.session=e}get id(){return this.session.id}get from(){return this.session.from??m(this.session.remote_identity)}getMediaRegistration(){let e=this.session.connection;if(e!=null)return this.mediaRegistration!==void 0&&this.mediaConnection===e?this.mediaRegistration:(this.mediaConnection=e,this.mediaRegistration=t(e),this.mediaRegistration)}answer(e){this.session.answer({mediaConstraints:e.mediaConstraints,pcConfig:{iceServers:[...e.pcConfig.iceServers]}})}terminate(){this.pendingHoldReject?.(Error(`SIP session terminated`)),this.session.terminate()}hold(){return this.changeHoldState(`hold`)}unhold(){return this.changeHoldState(`unhold`)}mute(){this.session.mute()}unmute(){this.session.unmute()}sendDtmf(e){this.session.sendDTMF(e)}refer(e){this.session.refer(e)}on(e,t){return e===`mediaConnected`?(this.mediaHandlers.add(t),this.watchMediaConnection(),()=>{this.mediaHandlers.delete(t),this.mediaHandlers.size===0&&(this.sessionUnsubscribeFromPeerConnection?.(),this.sessionUnsubscribeFromPeerConnection=void 0)}):(this.session.on(e,t),()=>this.session.off(e,t))}watchMediaConnection(){if(this.mediaWatchStarted)return;this.mediaWatchStarted=!0;let e=!1,t=t=>{if(t==null)return;let n=()=>{if(e)return;let n=t.connectionState||t.iceConnectionState;if(n===`connected`){e=!0;for(let e of this.mediaHandlers)try{e({state:n})}catch{}}};t.addEventListener(`connectionstatechange`,n),n()},n=this.session.connection;if(n!=null){t(n);return}let r=e=>{t(e?.peerconnection??void 0)};this.session.on(`peerconnection`,r),this.sessionUnsubscribeFromPeerConnection=()=>this.session.off(`peerconnection`,r)}changeHoldState(t){return new Promise((n,r)=>{let i=!1,a=e=>{c(e)},o=()=>{try{this.session.off(`ended`,a)}catch{}try{this.session.off(`failed`,a)}catch{}this.pendingHoldReject===c&&(this.pendingHoldReject=void 0)},s=()=>{i||(i=!0,o(),n())},c=t=>{i||(i=!0,o(),r(new e.i(`CALL_OPERATION_NOT_ALLOWED`,`call`,!1,{cause:t})))};try{this.session.on(`ended`,a),this.session.on(`failed`,a)}catch(e){c(e);return}this.pendingHoldReject=c;try{this.session[t](void 0,s)||c({reason:`jssip_operation_rejected`,operation:t})}catch(e){c(e)}})}};function u(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.originator===`remote`&&d(t.session)}function d(e){return typeof e==`object`&&!!e&&`id`in e}function f(e){return typeof e==`object`&&e&&(e.via_transport=`WSS`),e}function p(e){let t=e.replace(/^\[|\]$/g,``).toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`0:0:0:0:0:0:0:1`}function m(e){let t=e?.uri;if(t==null)return;if(typeof t.user==`string`&&t.user!==``)return t.user;let n=t.toString();return n.match(/^sips?:([^@;>]+)/i)?.[1]??(n===``?void 0:n)}exports.JsSipAdapter=c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./redact-Bq26pObO.cjs");var t={AUTH_TOKEN_UNAVAILABLE:`获取登录凭证失败,请检查凭证获取服务后重试。`,AUTH_TOKEN_EXPIRED:`登录凭证已过期,请重新获取凭证后登录。`,AUTH_TOKEN_REJECTED:`服务端未接受当前登录凭证,请核实凭证类型和权限。`,AUTH_PERMISSION_DENIED:`当前账号没有执行此操作的权限,请联系管理员。`,CONFIG_INVALID:`配置不完整或格式不正确,请检查软电话配置。`,CONFIG_ORIGIN_NOT_ALLOWED:`当前页面域名未获授权,请联系管理员配置访问域名。`,NETWORK_OFFLINE:`网络连接已断开,请检查网络后重试。`,NETWORK_TIMEOUT:`请求超时,请检查网络后重试。`,SIP_WS_UNAVAILABLE:`无法连接 SIP 服务,请检查 SIP WSS 地址和网络。`,REGISTRATION_FAILED:`SIP 注册失败,请检查坐席配置后重试。`,REGISTRATION_REJECTED:`SIP 服务拒绝了当前账号,请核对分机和 SIP 凭证。`,MEDIA_PERMISSION_DENIED:`麦克风权限未开启,请在浏览器设置中允许使用麦克风。`,MEDIA_DEVICE_NOT_FOUND:`未找到可用的音频设备,请连接麦克风或耳机后重试。`,MEDIA_DEVICE_IN_USE:`音频设备正在被其他程序使用,请关闭占用设备的程序后重试。`,MEDIA_PLAYBACK_BLOCKED:`浏览器阻止了声音播放,请点击页面并检查浏览器音频设置。`,CALL_INVALID_DESTINATION:`被叫号码格式不正确,请检查后重试。`,CALL_INVALID_USERDATA:`通话附加数据格式不正确,请检查后重试。`,CALL_ALREADY_EXISTS:`当前已有进行中的通话,请先结束当前通话。`,CALL_REJECTED:`对方或呼叫平台拒绝了本次呼叫。`,CALL_BUSY:`对方正在通话中,请稍后重试。`,CALL_NOT_CONNECTED:`当前没有可操作的通话,请先拨打或接听电话。`,NOT_SIGNED_IN:`请先登录,并等待 SIP 注册成功后再操作。`,CALL_OPERATION_NOT_ALLOWED:`当前通话状态不支持此操作,请检查通话状态后重试。`,CAPABILITY_NOT_SUPPORTED:`当前浏览器或设备不支持此功能。`,H5_BACKGROUND_NOT_SUPPORTED:`页面在后台时无法执行此操作,请返回通话页面后重试。`,SDK_ALREADY_DISPOSED:`软电话实例已关闭,请重新创建实例后操作。`,SDK_INTERNAL_ERROR:`软电话发生异常,请稍后重试;如问题持续,请联系技术支持。`,LEGACY_PLATFORM_UNREACHABLE:`无法连接坐席服务,请检查 API host 和网络。`,LEGACY_PLATFORM_REJECTED:`坐席服务未能完成请求,请核对账号权限和接口配置。`},n=class extends Error{code;category;retryable;requestId;callId;cause;serverCode;platformCode;status;constructor(e,n,r,i={}){super(t[e]),this.name=`CCBarError`,this.code=e,this.category=n,this.retryable=r,this.requestId=i.requestId,this.callId=i.callId,this.cause=i.cause,this.serverCode=i.serverCode,this.platformCode=i.platformCode,this.status=i.status}},r=[`new`,`dialing`,`ringing`,`connecting`,`active`,`held`,`ended`,`failed`];function i(e){if(!l(e)||typeof e.id!=`string`||typeof e.destination!=`string`||typeof e.incoming!=`boolean`||!c(e.state))throw d(`Invalid call snapshot`);return{id:e.id,...typeof e.from==`string`?{from:e.from}:{},destination:e.destination,state:e.state,incoming:e.incoming,...typeof e.ownerTabId==`string`?{ownerTabId:e.ownerTabId}:{}}}function a(e){return e instanceof n?{code:e.code,category:e.category,retryable:e.retryable,...e.requestId===void 0?{}:{requestId:e.requestId},...e.callId===void 0?{}:{callId:e.callId},...e.serverCode===void 0?{}:{serverCode:e.serverCode},...e.platformCode===void 0?{}:{platformCode:e.platformCode},...e.status===void 0?{}:{status:e.status},message:u(e.message)}:{code:`SDK_INTERNAL_ERROR`,category:`internal`,retryable:!1,message:u(e instanceof Error?e.message:String(e))}}function o(e){if(!l(e))throw d(`Invalid worker message`);if(e.version!==1)throw d(`Unsupported worker protocol version`);if(e.type===`attach`||e.type===`detach`)return s(e),e;if(e.type===`command`){if(s(e),typeof e.command!=`string`||e.payload!==void 0&&!l(e.payload))throw d(`Invalid worker command`);return e}if(e.type===`response`){if(typeof e.requestId!=`string`||typeof e.ok!=`boolean`)throw d(`Invalid worker response`);return e}if(e.type===`event`){if(typeof e.event!=`string`||!(`payload`in e))throw d(`Invalid worker event`);return e}throw d(`Unknown worker message type`)}function s(e){if(typeof e.requestId!=`string`||typeof e.tabId!=`string`)throw d(`Worker request requires requestId and tabId`)}function c(e){return typeof e==`string`&&r.includes(e)}function l(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function u(t){return e.t(t).replace(/(?:authorization|token|ticket|credential|password|secret)/gi,`[REDACTED]`)}function d(e){return new n(`SDK_INTERNAL_ERROR`,`internal`,!1,{cause:e})}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { t as e } from "./redact-DB3CMbsK.js";
|
|
2
|
+
//#region src/errors/CCBarError.ts
|
|
3
|
+
var t = {
|
|
4
|
+
AUTH_TOKEN_UNAVAILABLE: "获取登录凭证失败,请检查凭证获取服务后重试。",
|
|
5
|
+
AUTH_TOKEN_EXPIRED: "登录凭证已过期,请重新获取凭证后登录。",
|
|
6
|
+
AUTH_TOKEN_REJECTED: "服务端未接受当前登录凭证,请核实凭证类型和权限。",
|
|
7
|
+
AUTH_PERMISSION_DENIED: "当前账号没有执行此操作的权限,请联系管理员。",
|
|
8
|
+
CONFIG_INVALID: "配置不完整或格式不正确,请检查软电话配置。",
|
|
9
|
+
CONFIG_ORIGIN_NOT_ALLOWED: "当前页面域名未获授权,请联系管理员配置访问域名。",
|
|
10
|
+
NETWORK_OFFLINE: "网络连接已断开,请检查网络后重试。",
|
|
11
|
+
NETWORK_TIMEOUT: "请求超时,请检查网络后重试。",
|
|
12
|
+
SIP_WS_UNAVAILABLE: "无法连接 SIP 服务,请检查 SIP WSS 地址和网络。",
|
|
13
|
+
REGISTRATION_FAILED: "SIP 注册失败,请检查坐席配置后重试。",
|
|
14
|
+
REGISTRATION_REJECTED: "SIP 服务拒绝了当前账号,请核对分机和 SIP 凭证。",
|
|
15
|
+
MEDIA_PERMISSION_DENIED: "麦克风权限未开启,请在浏览器设置中允许使用麦克风。",
|
|
16
|
+
MEDIA_DEVICE_NOT_FOUND: "未找到可用的音频设备,请连接麦克风或耳机后重试。",
|
|
17
|
+
MEDIA_DEVICE_IN_USE: "音频设备正在被其他程序使用,请关闭占用设备的程序后重试。",
|
|
18
|
+
MEDIA_PLAYBACK_BLOCKED: "浏览器阻止了声音播放,请点击页面并检查浏览器音频设置。",
|
|
19
|
+
CALL_INVALID_DESTINATION: "被叫号码格式不正确,请检查后重试。",
|
|
20
|
+
CALL_INVALID_USERDATA: "通话附加数据格式不正确,请检查后重试。",
|
|
21
|
+
CALL_ALREADY_EXISTS: "当前已有进行中的通话,请先结束当前通话。",
|
|
22
|
+
CALL_REJECTED: "对方或呼叫平台拒绝了本次呼叫。",
|
|
23
|
+
CALL_BUSY: "对方正在通话中,请稍后重试。",
|
|
24
|
+
CALL_NOT_CONNECTED: "当前没有可操作的通话,请先拨打或接听电话。",
|
|
25
|
+
NOT_SIGNED_IN: "请先登录,并等待 SIP 注册成功后再操作。",
|
|
26
|
+
CALL_OPERATION_NOT_ALLOWED: "当前通话状态不支持此操作,请检查通话状态后重试。",
|
|
27
|
+
CAPABILITY_NOT_SUPPORTED: "当前浏览器或设备不支持此功能。",
|
|
28
|
+
H5_BACKGROUND_NOT_SUPPORTED: "页面在后台时无法执行此操作,请返回通话页面后重试。",
|
|
29
|
+
SDK_ALREADY_DISPOSED: "软电话实例已关闭,请重新创建实例后操作。",
|
|
30
|
+
SDK_INTERNAL_ERROR: "软电话发生异常,请稍后重试;如问题持续,请联系技术支持。",
|
|
31
|
+
LEGACY_PLATFORM_UNREACHABLE: "无法连接坐席服务,请检查 API host 和网络。",
|
|
32
|
+
LEGACY_PLATFORM_REJECTED: "坐席服务未能完成请求,请核对账号权限和接口配置。"
|
|
33
|
+
}, n = class extends Error {
|
|
34
|
+
code;
|
|
35
|
+
category;
|
|
36
|
+
retryable;
|
|
37
|
+
requestId;
|
|
38
|
+
callId;
|
|
39
|
+
cause;
|
|
40
|
+
serverCode;
|
|
41
|
+
platformCode;
|
|
42
|
+
status;
|
|
43
|
+
constructor(e, n, r, i = {}) {
|
|
44
|
+
super(t[e]), this.name = "CCBarError", this.code = e, this.category = n, this.retryable = r, this.requestId = i.requestId, this.callId = i.callId, this.cause = i.cause, this.serverCode = i.serverCode, this.platformCode = i.platformCode, this.status = i.status;
|
|
45
|
+
}
|
|
46
|
+
}, r = [
|
|
47
|
+
"new",
|
|
48
|
+
"dialing",
|
|
49
|
+
"ringing",
|
|
50
|
+
"connecting",
|
|
51
|
+
"active",
|
|
52
|
+
"held",
|
|
53
|
+
"ended",
|
|
54
|
+
"failed"
|
|
55
|
+
];
|
|
56
|
+
function i(e) {
|
|
57
|
+
if (!l(e) || typeof e.id != "string" || typeof e.destination != "string" || typeof e.incoming != "boolean" || !c(e.state)) throw d("Invalid call snapshot");
|
|
58
|
+
return {
|
|
59
|
+
id: e.id,
|
|
60
|
+
...typeof e.from == "string" ? { from: e.from } : {},
|
|
61
|
+
destination: e.destination,
|
|
62
|
+
state: e.state,
|
|
63
|
+
incoming: e.incoming,
|
|
64
|
+
...typeof e.ownerTabId == "string" ? { ownerTabId: e.ownerTabId } : {}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function a(e) {
|
|
68
|
+
return e instanceof n ? {
|
|
69
|
+
code: e.code,
|
|
70
|
+
category: e.category,
|
|
71
|
+
retryable: e.retryable,
|
|
72
|
+
...e.requestId === void 0 ? {} : { requestId: e.requestId },
|
|
73
|
+
...e.callId === void 0 ? {} : { callId: e.callId },
|
|
74
|
+
...e.serverCode === void 0 ? {} : { serverCode: e.serverCode },
|
|
75
|
+
...e.platformCode === void 0 ? {} : { platformCode: e.platformCode },
|
|
76
|
+
...e.status === void 0 ? {} : { status: e.status },
|
|
77
|
+
message: u(e.message)
|
|
78
|
+
} : {
|
|
79
|
+
code: "SDK_INTERNAL_ERROR",
|
|
80
|
+
category: "internal",
|
|
81
|
+
retryable: !1,
|
|
82
|
+
message: u(e instanceof Error ? e.message : String(e))
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function o(e) {
|
|
86
|
+
if (!l(e)) throw d("Invalid worker message");
|
|
87
|
+
if (e.version !== 1) throw d("Unsupported worker protocol version");
|
|
88
|
+
if (e.type === "attach" || e.type === "detach") return s(e), e;
|
|
89
|
+
if (e.type === "command") {
|
|
90
|
+
if (s(e), typeof e.command != "string" || e.payload !== void 0 && !l(e.payload)) throw d("Invalid worker command");
|
|
91
|
+
return e;
|
|
92
|
+
}
|
|
93
|
+
if (e.type === "response") {
|
|
94
|
+
if (typeof e.requestId != "string" || typeof e.ok != "boolean") throw d("Invalid worker response");
|
|
95
|
+
return e;
|
|
96
|
+
}
|
|
97
|
+
if (e.type === "event") {
|
|
98
|
+
if (typeof e.event != "string" || !("payload" in e)) throw d("Invalid worker event");
|
|
99
|
+
return e;
|
|
100
|
+
}
|
|
101
|
+
throw d("Unknown worker message type");
|
|
102
|
+
}
|
|
103
|
+
function s(e) {
|
|
104
|
+
if (typeof e.requestId != "string" || typeof e.tabId != "string") throw d("Worker request requires requestId and tabId");
|
|
105
|
+
}
|
|
106
|
+
function c(e) {
|
|
107
|
+
return typeof e == "string" && r.includes(e);
|
|
108
|
+
}
|
|
109
|
+
function l(e) {
|
|
110
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
111
|
+
}
|
|
112
|
+
function u(t) {
|
|
113
|
+
return e(t).replace(/(?:authorization|token|ticket|credential|password|secret)/gi, "[REDACTED]");
|
|
114
|
+
}
|
|
115
|
+
function d(e) {
|
|
116
|
+
return new n("SDK_INTERNAL_ERROR", "internal", !1, { cause: e });
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { n as i, i as n, a as r, o as t };
|
package/dist/core/CCBarCall.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export declare class CCBarCall {
|
|
|
29
29
|
private readonly capabilities;
|
|
30
30
|
private disposed;
|
|
31
31
|
private pendingOperation?;
|
|
32
|
+
private localHeld;
|
|
33
|
+
private remoteHeld;
|
|
32
34
|
private incomingOperation?;
|
|
33
35
|
private ownerTabId?;
|
|
34
36
|
private ownerLost;
|
|
@@ -67,6 +69,7 @@ export declare class CCBarCall {
|
|
|
67
69
|
dispose(): void;
|
|
68
70
|
private handleSessionEvent;
|
|
69
71
|
private transitionToActive;
|
|
72
|
+
private updateHoldState;
|
|
70
73
|
private transitionIfAllowed;
|
|
71
74
|
private transitionIfStillRinging;
|
|
72
75
|
private transitionTo;
|
|
@@ -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-B1EdRU6l.cjs"),t=require("../redact-Bq26pObO.cjs");require("../createJsSipFactory-B1ORbJiP.cjs"),exports.Diagnostics=e.t,exports.RingBuffer=e.n,exports.diagnosticsVersion=e.r,exports.redactText=t.t,exports.redactValue=t.n;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "../Diagnostics-
|
|
1
|
+
import { n as e, r as t, t as n } from "../Diagnostics-CwcR4kCt.js";
|
|
2
2
|
import { n as r, t as i } from "../redact-DB3CMbsK.js";
|
|
3
3
|
export { n as Diagnostics, e as RingBuffer, t as diagnosticsVersion, i as redactText, r as redactValue };
|
|
@@ -5,6 +5,8 @@ export interface CCBarErrorOptions {
|
|
|
5
5
|
cause?: unknown;
|
|
6
6
|
/** Stable server protocol code, retained for lifecycle recovery decisions. */
|
|
7
7
|
serverCode?: string;
|
|
8
|
+
/** Numeric code returned by the platform; separate from the stable SDK code. */
|
|
9
|
+
platformCode?: number;
|
|
8
10
|
/** HTTP status returned by the WebPhone API, when available. */
|
|
9
11
|
status?: number;
|
|
10
12
|
}
|
|
@@ -16,6 +18,7 @@ export declare class CCBarError extends Error {
|
|
|
16
18
|
readonly callId?: string;
|
|
17
19
|
readonly cause?: unknown;
|
|
18
20
|
readonly serverCode?: string;
|
|
21
|
+
readonly platformCode?: number;
|
|
19
22
|
readonly status?: number;
|
|
20
23
|
constructor(code: CCBarErrorCode, category: CCBarErrorCategory, retryable: boolean, options?: CCBarErrorOptions);
|
|
21
24
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./SharedWorkerProtocol-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./SharedWorkerProtocol-C-4KpECM.cjs"),t=require("./legacySessionProvider-BK9-n2uj.cjs"),n=require("./Diagnostics-B1EdRU6l.cjs"),r=require("./redact-Bq26pObO.cjs");require("./diagnostics/index.cjs"),require("./createJsSipFactory-B1ORbJiP.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.c,exports.CCBarClient=t.r,exports.CCBarError=e.i,exports.CallManager=t.s,exports.CallStateError=t.l,exports.Diagnostics=n.t,exports.RingBuffer=n.n,exports.TypedEventBus=t.m,exports.assertCallTransition=t.u,exports.canTransition=t.d,exports.createSdk=a,exports.createSharedWorkerSelection=t.i,exports.createTokenSessionProvider=t.n,exports.diagnosticsVersion=n.r,exports.parseSessionResponse=i,exports.redactText=r.t,exports.redactValue=r.n,exports.resolveWorkerUrl=t.a,exports.transition=t.f,exports.transitions=t.p,exports.version=o;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as e } from "./SharedWorkerProtocol-
|
|
2
|
-
import { a as t, c as n, d as r, f as i, i as a, l as o, m as s, n as c, p as l, r as u, s as d, u as f } from "./legacySessionProvider-
|
|
3
|
-
import { n as p, r as m, t as h } from "./Diagnostics-
|
|
1
|
+
import { i as e } from "./SharedWorkerProtocol-CffZrUXg.js";
|
|
2
|
+
import { a as t, c as n, d as r, f as i, i as a, l as o, m as s, n as c, p as l, r as u, s as d, u as f } from "./legacySessionProvider-BdOk_ssd.js";
|
|
3
|
+
import { n as p, r as m, t as h } from "./Diagnostics-CwcR4kCt.js";
|
|
4
4
|
import { n as g, t as _ } from "./redact-DB3CMbsK.js";
|
|
5
5
|
import "./diagnostics/index.js";
|
|
6
6
|
//#region src/api/contracts.ts
|