@16x/webphone-sdk 3.1.10 → 4.0.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 +0 -46
- package/README.md +0 -43
- package/dist/CCBarClient-BFq7695C.cjs +1 -0
- package/dist/{CCBarClient-Sr_zlDBu.js → CCBarClient-CAGBUxil.js} +123 -194
- package/dist/{Diagnostics-WkQagE6_.js → Diagnostics-Cs02iAlB.js} +1 -1
- package/dist/Diagnostics-DwF6aDHZ.cjs +1 -0
- package/dist/api/contracts.d.ts +0 -11
- package/dist/core/CCBarClient.d.ts +4 -8
- package/dist/diagnostics/index.cjs +1 -1
- package/dist/diagnostics/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/index.umd.js +17 -17
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.d.ts +0 -2
- package/dist/legacy/index.js +10 -276
- package/dist/types.d.ts +1 -5
- package/dist/version.d.ts +1 -1
- package/package.json +109 -109
- package/dist/CCBarClient-z-TFUjTB.cjs +0 -1
- package/dist/Diagnostics-x4G0ho6W.cjs +0 -1
- package/dist/legacy/legacyAes.d.ts +0 -7
- package/dist/legacy/legacySessionProvider.d.ts +0 -79
package/dist/legacy/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../SharedWorkerProtocol-39dch6xL.cjs"),t=require("../CCBarClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../SharedWorkerProtocol-39dch6xL.cjs"),t=require("../CCBarClient-BFq7695C.cjs");require("../createJsSipFactory-Dr8HbLl-.cjs");var n=class extends Error{code=`LEGACY_METHOD_DEPRECATED`;constructor(e,t){super(`${e} 已废弃:${t}`),this.name=`DeprecatedError`}},r=class{client;warnedMethods=new Set;unsubscribeIncoming;currentCall;constructor(e){this.client=new t.t(e),this.unsubscribeIncoming=this.client.on(`call.incoming`,({callId:e})=>{this.currentCall=this.client.getCalls().find(t=>t.id===e)})}getToken(...e){return this.warn(`getToken`,`请改用 client.connect()`),this.client.connect()}getAccount(...e){return this.warn(`getAccount`,`请改用 client.connect()`),this.client.connect()}login(...e){return this.warn(`login`,`请改用 client.connect()`),this.client.connect()}async call(e,...t){this.warn(`call`,`请改用 client.dial({ destination })`);let n=await this.client.dial({destination:String(e)});return this.currentCall=n,n}async insideCall(e,...t){this.warn(`insideCall`,`请改用 client.dial({ destination, type: 'extension' })`);let n=await this.client.dial({destination:String(e),type:`extension`});return this.currentCall=n,n}answer(...e){this.warn(`answer`,`请改用 call.answer()`);let t=this.requireCurrentCall();return this.client.answer(t.id)}async hangup(...e){this.warn(`hangup`,`请改用 call.hangup()`);let t=this.requireCurrentCall();try{await t.hangup()}finally{this.currentCall===t&&(this.currentCall=void 0)}}holdCall(...e){return this.warn(`holdCall`,`请改用 call.hold()`),this.requireCurrentCall().hold()}unholdCall(...e){return this.warn(`unholdCall`,`请改用 call.resume()`),this.requireCurrentCall().resume()}transSo(e,...t){return this.warn(`transSo`,`请改用 call.transfer({ target, type: 'blind' })`),this.requireCurrentCall().transfer({target:String(e),type:`blind`})}async signOut(...e){this.warn(`signOut`,`请改用 client.disconnect() 和 client.dispose()`);let t;try{await this.client.disconnect()}catch(e){t=e}try{await this.client.dispose()}catch(e){t??=e}if(this.unsubscribeIncoming(),this.currentCall=void 0,t!==void 0)throw t}setId(...e){return this.warn(`setId`,`请改用 client.setAgentStatus('available')`),this.client.setAgentStatus(`available`)}setBu(...e){throw this.warn(`setBu`,`busy由通话状态或服务端状态策略控制,浏览器不得伪造`),new n(`setBu()`,`busy由通话状态或服务端状态策略控制,浏览器不得伪造`)}setRe(...e){return this.warn(`setRe`,`请改用 client.setAgentStatus('break')`),this.client.setAgentStatus(`break`)}requireCurrentCall(){let t=this.client.getActiveCall();if(t!==void 0&&(this.currentCall=t),this.currentCall===void 0)throw new e.i(`CALL_NOT_CONNECTED`,`call`,!1);return this.currentCall}warn(e,t){i()&&!this.warnedMethods.has(e)&&(this.warnedMethods.add(e),console.warn(`[CCBarSDK] ${e}() 已废弃。${t}`))}};function i(){return!1}var a=`0.1.0`;typeof window<`u`&&(window.CCBarSDK=r),exports.CCBarSDK=r,exports.DeprecatedError=n,exports.legacyVersion=a;
|
package/dist/legacy/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { CCBarSDK } from './CCBarSDK.js';
|
|
2
2
|
export { CCBarSDK, DeprecatedError } from './CCBarSDK.js';
|
|
3
|
-
export { decryptSipPassword, type DecryptSipPasswordOptions } from './legacyAes.js';
|
|
4
|
-
export { createLegacySessionProvider, type LegacyPlatformSessionProviderOptions, type LegacySeatAccount, type LegacyTokenResult, } from './legacySessionProvider.js';
|
|
5
3
|
export declare const legacyVersion = "0.1.0";
|
|
6
4
|
declare global {
|
|
7
5
|
interface Window {
|
package/dist/legacy/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { i as e } from "../SharedWorkerProtocol-DKVQ5-po.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t } from "../CCBarClient-CAGBUxil.js";
|
|
3
3
|
//#region src/legacy/CCBarSDK.ts
|
|
4
|
-
var
|
|
4
|
+
var n = class extends Error {
|
|
5
5
|
code = "LEGACY_METHOD_DEPRECATED";
|
|
6
6
|
constructor(e, t) {
|
|
7
7
|
super(`${e} 已废弃:${t}`), this.name = "DeprecatedError";
|
|
8
8
|
}
|
|
9
|
-
},
|
|
9
|
+
}, r = class {
|
|
10
10
|
client;
|
|
11
11
|
warnedMethods = /* @__PURE__ */ new Set();
|
|
12
12
|
unsubscribeIncoming;
|
|
13
13
|
currentCall;
|
|
14
14
|
constructor(e) {
|
|
15
|
-
this.client = new
|
|
15
|
+
this.client = new t(e), this.unsubscribeIncoming = this.client.on("call.incoming", ({ callId: e }) => {
|
|
16
16
|
this.currentCall = this.client.getCalls().find((t) => t.id === e);
|
|
17
17
|
});
|
|
18
18
|
}
|
|
@@ -83,7 +83,7 @@ var r = class extends Error {
|
|
|
83
83
|
return this.warn("setId", "请改用 client.setAgentStatus('available')"), this.client.setAgentStatus("available");
|
|
84
84
|
}
|
|
85
85
|
setBu(...e) {
|
|
86
|
-
throw this.warn("setBu", "busy由通话状态或服务端状态策略控制,浏览器不得伪造"), new
|
|
86
|
+
throw this.warn("setBu", "busy由通话状态或服务端状态策略控制,浏览器不得伪造"), new n("setBu()", "busy由通话状态或服务端状态策略控制,浏览器不得伪造");
|
|
87
87
|
}
|
|
88
88
|
setRe(...e) {
|
|
89
89
|
return this.warn("setRe", "请改用 client.setAgentStatus('break')"), this.client.setAgentStatus("break");
|
|
@@ -94,281 +94,15 @@ var r = class extends Error {
|
|
|
94
94
|
return this.currentCall;
|
|
95
95
|
}
|
|
96
96
|
warn(e, t) {
|
|
97
|
-
|
|
97
|
+
i() && !this.warnedMethods.has(e) && (this.warnedMethods.add(e), console.warn(`[CCBarSDK] ${e}() 已废弃。${t}`));
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
-
function
|
|
100
|
+
function i() {
|
|
101
101
|
return !1;
|
|
102
102
|
}
|
|
103
103
|
//#endregion
|
|
104
|
-
//#region src/legacy/legacySessionProvider.ts
|
|
105
|
-
var o = "/openapi/token/v1", s = "/seat/account/get", c = "/seats/set-status", l = "/api/fs/sip-ws", u = 7443, d = 3478, f = 600, p = 600, m = 180, h = 60, g = 5e3, _ = 2e4, v = [
|
|
106
|
-
"outbound",
|
|
107
|
-
"inbound",
|
|
108
|
-
"mute",
|
|
109
|
-
"dtmf",
|
|
110
|
-
"hold",
|
|
111
|
-
"blind_transfer"
|
|
112
|
-
], y = {
|
|
113
|
-
available: {
|
|
114
|
-
status: "Available",
|
|
115
|
-
reason: "空闲"
|
|
116
|
-
},
|
|
117
|
-
break: {
|
|
118
|
-
status: "On Break",
|
|
119
|
-
reason: "休息"
|
|
120
|
-
},
|
|
121
|
-
offline: {
|
|
122
|
-
status: "Logged Out",
|
|
123
|
-
reason: ""
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
function b(n) {
|
|
127
|
-
let r = x(n.host), i = S(n.pathPrefix ?? o), a = `${r}${i}${C(n.accountPath ?? s)}`, _ = `${r}${i}${C(n.statusPath ?? c)}`, b = C(n.sipWsPath ?? l), O = {
|
|
128
|
-
...n.aesKey ? { key: n.aesKey } : {},
|
|
129
|
-
...n.aesIv ? { iv: n.aesIv } : {}
|
|
130
|
-
}, k = Math.max(0, n.refreshBufferSeconds ?? m), A = n.fetchImpl ?? globalThis.fetch, j, M, N = "";
|
|
131
|
-
async function P() {
|
|
132
|
-
if (n.getToken !== void 0) return n.getToken();
|
|
133
|
-
if (n.tokenUrl !== void 0) {
|
|
134
|
-
let t = n.tokenMethod ?? "POST", r = {
|
|
135
|
-
method: t,
|
|
136
|
-
headers: {
|
|
137
|
-
Accept: "application/json",
|
|
138
|
-
...n.tokenHeaders ?? {}
|
|
139
|
-
},
|
|
140
|
-
credentials: "include"
|
|
141
|
-
};
|
|
142
|
-
t === "POST" && (r.headers = {
|
|
143
|
-
"Content-Type": "application/json",
|
|
144
|
-
...r.headers
|
|
145
|
-
}, r.body = JSON.stringify(n.tokenBody ?? {}));
|
|
146
|
-
let i = await D(A, n.tokenUrl, r, "取 token"), a = await i.text();
|
|
147
|
-
try {
|
|
148
|
-
return JSON.parse(a);
|
|
149
|
-
} catch {
|
|
150
|
-
throw new e("AUTH_TOKEN_UNAVAILABLE", "auth", !0, {
|
|
151
|
-
status: i.status,
|
|
152
|
-
cause: `取 token 的接口返回了非 JSON 响应(HTTP ${i.status}):${a.trim().slice(0, 120)}`
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
throw new e("CONFIG_INVALID", "configuration", !1, { cause: "createLegacySessionProvider 需要 getToken 或 tokenUrl;坐席状态也可以直接用会话软电话地址里的 token(setAgentStatus 的 context.wssUrl),但这次调用没有会话可用" });
|
|
157
|
-
}
|
|
158
|
-
async function F() {
|
|
159
|
-
if (j && j.expiresAtMs - Date.now() > g) return j.token;
|
|
160
|
-
let t;
|
|
161
|
-
try {
|
|
162
|
-
t = await P();
|
|
163
|
-
} catch (t) {
|
|
164
|
-
throw t instanceof e ? t : new e("AUTH_TOKEN_UNAVAILABLE", "auth", !0, { cause: t });
|
|
165
|
-
}
|
|
166
|
-
let n = E(t);
|
|
167
|
-
if (!n.token) throw new e("AUTH_TOKEN_UNAVAILABLE", "auth", !0, { cause: "取 token 的返回里没有 token(支持 {token}、{accessToken}、{data:{token}} 或裸字符串)" });
|
|
168
|
-
let r = T(n.expires, 3600);
|
|
169
|
-
return j = {
|
|
170
|
-
token: n.token,
|
|
171
|
-
expiresAtMs: Date.now() + r * 1e3
|
|
172
|
-
}, j.token;
|
|
173
|
-
}
|
|
174
|
-
function I(e) {
|
|
175
|
-
if (!e) return "";
|
|
176
|
-
try {
|
|
177
|
-
return String(new URL(e).searchParams.get("token") ?? "").trim();
|
|
178
|
-
} catch {
|
|
179
|
-
return "";
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
async function L(e) {
|
|
183
|
-
let t = I(e?.wssUrl);
|
|
184
|
-
return t ? (N = t, t) : N || F();
|
|
185
|
-
}
|
|
186
|
-
async function R(t) {
|
|
187
|
-
let n = t || await F(), r = await D(A, a, {
|
|
188
|
-
method: "POST",
|
|
189
|
-
headers: {
|
|
190
|
-
Authorization: n,
|
|
191
|
-
"Content-Type": "application/json",
|
|
192
|
-
Accept: "application/json"
|
|
193
|
-
},
|
|
194
|
-
body: "{}"
|
|
195
|
-
}, "取坐席账号"), i = await r.text(), o;
|
|
196
|
-
try {
|
|
197
|
-
o = JSON.parse(i);
|
|
198
|
-
} catch {
|
|
199
|
-
throw new e("LEGACY_PLATFORM_UNREACHABLE", "network", !0, {
|
|
200
|
-
status: r.status,
|
|
201
|
-
cause: `${a} 返回了非 JSON 响应(HTTP ${r.status});请确认 host 填的是接口网关(不是文档站)`
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
let s = Number(o.code ?? NaN);
|
|
205
|
-
if (!r.ok || s !== 0) throw new e("LEGACY_PLATFORM_REJECTED", "auth", s === 50, {
|
|
206
|
-
status: r.status,
|
|
207
|
-
serverCode: Number.isFinite(s) ? String(s) : void 0,
|
|
208
|
-
cause: o.message || `取坐席账号失败(HTTP ${r.status})`
|
|
209
|
-
});
|
|
210
|
-
if (!o.data) throw new e("LEGACY_PLATFORM_REJECTED", "auth", !1, { cause: "坐席账号接口没有返回 data" });
|
|
211
|
-
return M = o.data, M;
|
|
212
|
-
}
|
|
213
|
-
let z = (e) => t(e, O);
|
|
214
|
-
function B(t, i) {
|
|
215
|
-
let a = Number(t.wssPort) || u, o = String(t.domain ?? "").trim(), s = String(n.sipWsUrl ?? "").trim(), c;
|
|
216
|
-
if (s) c = new URL(s, r), c.protocol === "http:" && (c.protocol = "ws:"), c.protocol === "https:" && (c.protocol = "wss:");
|
|
217
|
-
else {
|
|
218
|
-
if (!o) throw new e("LEGACY_PLATFORM_REJECTED", "auth", !1, { cause: "坐席账号里没有 domain,无法拼软电话地址;可用 sipWsUrl 显式指定" });
|
|
219
|
-
let t = a === 443 ? "" : `:${a}`;
|
|
220
|
-
c = new URL(`wss://${o}${t}${b}`);
|
|
221
|
-
}
|
|
222
|
-
return (n.attachTokenToWss ?? !0) && i && c.searchParams.set("token", i), c.toString();
|
|
223
|
-
}
|
|
224
|
-
function V(e) {
|
|
225
|
-
let t = (Array.isArray(e.iceServers) ? e.iceServers : []).map((e) => {
|
|
226
|
-
let t = (Array.isArray(e?.urls) ? e.urls : typeof e?.urls == "string" ? [e.urls] : []).map((e) => String(e ?? "").trim()).filter(Boolean);
|
|
227
|
-
if (t.length !== 0) return {
|
|
228
|
-
urls: t,
|
|
229
|
-
...e?.username ? { username: String(e.username) } : {},
|
|
230
|
-
...e?.credential ? { credential: String(e.credential) } : {}
|
|
231
|
-
};
|
|
232
|
-
}).filter((e) => e !== void 0);
|
|
233
|
-
if (t.length > 0) return t;
|
|
234
|
-
let n = String(e.turnIp ?? "").trim();
|
|
235
|
-
return n ? [{ urls: [`stun:${n}:${Number(e.turnPort) || d}`] }] : [];
|
|
236
|
-
}
|
|
237
|
-
async function H() {
|
|
238
|
-
let t = await F(), i = await R(), a = String(i.username ?? i.account ?? "").trim();
|
|
239
|
-
if (!a) throw new e("LEGACY_PLATFORM_REJECTED", "auth", !1, { cause: "坐席账号里没有 username" });
|
|
240
|
-
let o = String(i.registerPassword ?? i.password ?? ""), s = o ? await z(o) : "";
|
|
241
|
-
if (!s) throw new e("LEGACY_PLATFORM_REJECTED", "auth", !1, { cause: "坐席账号里没有 password/registerPassword,或解密后为空" });
|
|
242
|
-
let c = T(i.expiresIn ?? i.expires_in, p), l = Math.max(0, Math.round((j.expiresAtMs - Date.now()) / 1e3)), u = Math.max(h, Math.min(l || c, c) - k), d = String(i.domain ?? "").trim() || w(r), m = B(i, t);
|
|
243
|
-
return t && (N = t), {
|
|
244
|
-
sessionId: `legacy-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`,
|
|
245
|
-
expiresAt: Math.floor(Date.now() / 1e3) + u,
|
|
246
|
-
agent: {
|
|
247
|
-
id: a,
|
|
248
|
-
externalUserId: a,
|
|
249
|
-
displayName: a,
|
|
250
|
-
extension: a,
|
|
251
|
-
status: "Available"
|
|
252
|
-
},
|
|
253
|
-
sip: {
|
|
254
|
-
uri: `sip:${a}@${d}`,
|
|
255
|
-
registrar: d,
|
|
256
|
-
registerTicket: s,
|
|
257
|
-
registerExpires: Number(n.registerExpires) > 0 ? Number(n.registerExpires) : f,
|
|
258
|
-
ticketExpiresIn: u
|
|
259
|
-
},
|
|
260
|
-
transport: {
|
|
261
|
-
wssUrl: m,
|
|
262
|
-
ticket: "",
|
|
263
|
-
ticketExpiresIn: u
|
|
264
|
-
},
|
|
265
|
-
iceServers: V(i),
|
|
266
|
-
policy: {
|
|
267
|
-
maxConcurrentCalls: Number(n.maxConcurrentCalls) > 0 ? Number(n.maxConcurrentCalls) : 2,
|
|
268
|
-
incomingEnabled: n.incomingEnabled ?? !0,
|
|
269
|
-
mobileIncomingEnabled: n.mobileIncomingEnabled ?? !0,
|
|
270
|
-
backgroundCallingSupported: !1
|
|
271
|
-
},
|
|
272
|
-
capabilities: [...n.capabilities ?? v]
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
return {
|
|
276
|
-
createSession: H,
|
|
277
|
-
refreshSession: H,
|
|
278
|
-
setAgentStatus: async ({ status: t, reason: n }, r) => {
|
|
279
|
-
let i = await L(r), a = M ?? await R(i), o = String(a.username ?? a.account ?? "").trim();
|
|
280
|
-
if (!o) throw new e("LEGACY_PLATFORM_REJECTED", "auth", !1, { cause: "坐席账号里没有 username" });
|
|
281
|
-
let s = y[t], c = await D(A, _, {
|
|
282
|
-
method: "POST",
|
|
283
|
-
headers: {
|
|
284
|
-
Authorization: i,
|
|
285
|
-
"Content-Type": "application/json",
|
|
286
|
-
Accept: "application/json"
|
|
287
|
-
},
|
|
288
|
-
body: JSON.stringify({
|
|
289
|
-
extension: o,
|
|
290
|
-
status: s.status,
|
|
291
|
-
reason: n || s.reason
|
|
292
|
-
})
|
|
293
|
-
}, "设置坐席状态"), l = await c.text(), u;
|
|
294
|
-
try {
|
|
295
|
-
u = JSON.parse(l);
|
|
296
|
-
} catch {
|
|
297
|
-
throw new e("LEGACY_PLATFORM_UNREACHABLE", "network", !0, {
|
|
298
|
-
status: c.status,
|
|
299
|
-
cause: `${_} 返回了非 JSON 响应(HTTP ${c.status})`
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
let d = Number(u.code ?? NaN);
|
|
303
|
-
if (!c.ok || d !== 0) throw new e("LEGACY_PLATFORM_REJECTED", "auth", d === 50, {
|
|
304
|
-
status: c.status,
|
|
305
|
-
serverCode: Number.isFinite(d) ? String(d) : void 0,
|
|
306
|
-
cause: u.message || `设置坐席状态失败(HTTP ${c.status})`
|
|
307
|
-
});
|
|
308
|
-
},
|
|
309
|
-
invalidateToken: () => {
|
|
310
|
-
j = void 0, N = "";
|
|
311
|
-
},
|
|
312
|
-
getSeatAccount: async () => M ?? R()
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
function x(t) {
|
|
316
|
-
let n = String(t ?? "").trim().replace(/\/+$/, "");
|
|
317
|
-
if (!n) throw new e("CONFIG_INVALID", "configuration", !1, { cause: "createLegacySessionProvider 需要 host" });
|
|
318
|
-
return /^https?:\/\//i.test(n) ? n : `https://${n}`;
|
|
319
|
-
}
|
|
320
|
-
function S(e) {
|
|
321
|
-
let t = String(e ?? "").trim();
|
|
322
|
-
return !t || t === "/" ? "" : `/${t.replace(/^\/+|\/+$/g, "")}`;
|
|
323
|
-
}
|
|
324
|
-
function C(e) {
|
|
325
|
-
let t = String(e ?? "").trim();
|
|
326
|
-
return t.startsWith("/") ? t : `/${t}`;
|
|
327
|
-
}
|
|
328
|
-
function w(e) {
|
|
329
|
-
try {
|
|
330
|
-
return new URL(e).hostname;
|
|
331
|
-
} catch {
|
|
332
|
-
return "";
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
function T(e, t) {
|
|
336
|
-
let n = Number(e);
|
|
337
|
-
return !Number.isFinite(n) || n <= 0 ? t : (n > 86400 && (n /= 1e3), Math.min(Math.max(Math.floor(n), h), 86400));
|
|
338
|
-
}
|
|
339
|
-
function E(e) {
|
|
340
|
-
if (typeof e == "string") return { token: e.trim() };
|
|
341
|
-
let t = e ?? {}, n = typeof t.data == "object" && t.data !== null ? t.data : void 0;
|
|
342
|
-
for (let e of [t, n]) {
|
|
343
|
-
if (e === void 0) continue;
|
|
344
|
-
let t = e.token ?? e.accessToken;
|
|
345
|
-
if (typeof t == "string" && t.trim()) {
|
|
346
|
-
let n = Number(e.expires ?? e.expiresIn ?? e.expires_at);
|
|
347
|
-
return {
|
|
348
|
-
token: t.trim(),
|
|
349
|
-
...Number.isFinite(n) && n > 0 ? { expires: n } : {}
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
return { token: "" };
|
|
354
|
-
}
|
|
355
|
-
async function D(t, n, r, i) {
|
|
356
|
-
let a = new AbortController(), o = setTimeout(() => a.abort(), _);
|
|
357
|
-
try {
|
|
358
|
-
return await t(n, {
|
|
359
|
-
...r,
|
|
360
|
-
signal: a.signal
|
|
361
|
-
});
|
|
362
|
-
} catch (t) {
|
|
363
|
-
let r = a.signal.aborted;
|
|
364
|
-
throw new e(r ? "NETWORK_TIMEOUT" : "LEGACY_PLATFORM_UNREACHABLE", "network", !0, { cause: r ? `${i}超时(${_ / 1e3} 秒):POST ${n}` : `${i}失败:无法请求 ${n}(${t instanceof Error ? t.message : String(t)})` });
|
|
365
|
-
} finally {
|
|
366
|
-
clearTimeout(o);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
//#endregion
|
|
370
104
|
//#region src/legacy/index.ts
|
|
371
|
-
var
|
|
372
|
-
typeof window < "u" && (window.CCBarSDK =
|
|
105
|
+
var a = "0.1.0";
|
|
106
|
+
typeof window < "u" && (window.CCBarSDK = r);
|
|
373
107
|
//#endregion
|
|
374
|
-
export {
|
|
108
|
+
export { r as CCBarSDK, n as DeprecatedError, a as legacyVersion };
|
package/dist/types.d.ts
CHANGED
|
@@ -58,11 +58,7 @@ export interface MediaManager {
|
|
|
58
58
|
releaseAll(): Promise<void>;
|
|
59
59
|
}
|
|
60
60
|
export type CCBarErrorCategory = 'auth' | 'configuration' | 'network' | 'registration' | 'media' | 'call' | 'capability' | 'internal';
|
|
61
|
-
export type CCBarErrorCode = 'AUTH_TOKEN_UNAVAILABLE' | 'AUTH_TOKEN_EXPIRED' | 'AUTH_PERMISSION_DENIED' | 'CONFIG_INVALID' | 'CONFIG_ORIGIN_NOT_ALLOWED' | 'NETWORK_OFFLINE' | 'NETWORK_TIMEOUT' | 'SIP_WS_UNAVAILABLE' | 'REGISTRATION_FAILED' | 'REGISTRATION_REJECTED' | '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' | 'CALL_OPERATION_NOT_ALLOWED' | 'CAPABILITY_NOT_SUPPORTED' | 'H5_BACKGROUND_NOT_SUPPORTED' | 'SDK_ALREADY_DISPOSED' | 'SDK_INTERNAL_ERROR'
|
|
62
|
-
/** 老平台接口(seat/account/get、seats/set-status)不可达:网络失败、超时或返回非 JSON */
|
|
63
|
-
| 'LEGACY_PLATFORM_UNREACHABLE'
|
|
64
|
-
/** 老平台接口返回了业务错误(code != 0)或缺少必需字段;平台的 code 在 error.serverCode 上 */
|
|
65
|
-
| 'LEGACY_PLATFORM_REJECTED';
|
|
61
|
+
export type CCBarErrorCode = 'AUTH_TOKEN_UNAVAILABLE' | 'AUTH_TOKEN_EXPIRED' | 'AUTH_PERMISSION_DENIED' | 'CONFIG_INVALID' | 'CONFIG_ORIGIN_NOT_ALLOWED' | 'NETWORK_OFFLINE' | 'NETWORK_TIMEOUT' | 'SIP_WS_UNAVAILABLE' | 'REGISTRATION_FAILED' | 'REGISTRATION_REJECTED' | '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' | 'CALL_OPERATION_NOT_ALLOWED' | 'CAPABILITY_NOT_SUPPORTED' | 'H5_BACKGROUND_NOT_SUPPORTED' | 'SDK_ALREADY_DISPOSED' | 'SDK_INTERNAL_ERROR';
|
|
66
62
|
export interface ConnectionStateEvent {
|
|
67
63
|
state: 'offline' | 'connecting' | 'connected' | 'reconnecting' | 'failed';
|
|
68
64
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "4.0.0";
|
package/package.json
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@16x/webphone-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"homepage": "https://www.npmjs.com/package/@16x/webphone-sdk",
|
|
5
|
-
"private": false,
|
|
6
|
-
"license": "UNLICENSED",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public",
|
|
9
|
-
"registry": "https://registry.npmjs.org"
|
|
10
|
-
},
|
|
11
|
-
"type": "module",
|
|
12
|
-
"sideEffects": [
|
|
13
|
-
"./dist/styles.css"
|
|
14
|
-
],
|
|
15
|
-
"files": [
|
|
16
|
-
"dist/index.js",
|
|
17
|
-
"dist/index.cjs",
|
|
18
|
-
"dist/index.umd.js",
|
|
19
|
-
"dist/*.js",
|
|
20
|
-
"dist/*.cjs",
|
|
21
|
-
"dist/index.d.ts",
|
|
22
|
-
"dist/types.d.ts",
|
|
23
|
-
"dist/version.d.ts",
|
|
24
|
-
"dist/errors",
|
|
25
|
-
"dist/events",
|
|
26
|
-
"dist/state",
|
|
27
|
-
"dist/api",
|
|
28
|
-
"dist/core",
|
|
29
|
-
"dist/shared",
|
|
30
|
-
"dist/ui",
|
|
31
|
-
"dist/legacy",
|
|
32
|
-
"dist/diagnostics",
|
|
33
|
-
"dist/shared-worker.js",
|
|
34
|
-
"dist/shared-worker.d.ts",
|
|
35
|
-
"dist/styles.css",
|
|
36
|
-
"README.md",
|
|
37
|
-
"LICENSE",
|
|
38
|
-
"CHANGELOG.md"
|
|
39
|
-
],
|
|
40
|
-
"exports": {
|
|
41
|
-
".": {
|
|
42
|
-
"types": "./dist/index.d.ts",
|
|
43
|
-
"import": "./dist/index.js",
|
|
44
|
-
"require": "./dist/index.cjs"
|
|
45
|
-
},
|
|
46
|
-
"./ui": {
|
|
47
|
-
"types": "./dist/ui/index.d.ts",
|
|
48
|
-
"import": "./dist/ui/index.js",
|
|
49
|
-
"require": "./dist/ui/index.cjs"
|
|
50
|
-
},
|
|
51
|
-
"./legacy": {
|
|
52
|
-
"types": "./dist/legacy/index.d.ts",
|
|
53
|
-
"import": "./dist/legacy/index.js",
|
|
54
|
-
"require": "./dist/legacy/index.cjs"
|
|
55
|
-
},
|
|
56
|
-
"./diagnostics": {
|
|
57
|
-
"types": "./dist/diagnostics/index.d.ts",
|
|
58
|
-
"import": "./dist/diagnostics/index.js",
|
|
59
|
-
"require": "./dist/diagnostics/index.cjs"
|
|
60
|
-
},
|
|
61
|
-
"./shared-worker": {
|
|
62
|
-
"types": "./dist/shared-worker.d.ts",
|
|
63
|
-
"import": "./dist/shared-worker.js"
|
|
64
|
-
},
|
|
65
|
-
"./styles.css": "./dist/styles.css"
|
|
66
|
-
},
|
|
67
|
-
"scripts": {
|
|
68
|
-
"build": "vite build && vite build -c vite.umd.config.ts",
|
|
69
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
70
|
-
"test": "npm run build && npm run docs:build && vitest run",
|
|
71
|
-
"lint": "eslint .",
|
|
72
|
-
"pack:check": "node scripts/check-package.mjs",
|
|
73
|
-
"sbom": "node scripts/generate-sbom.mjs",
|
|
74
|
-
"release:artifacts": "node scripts/generate-release-artifacts.mjs",
|
|
75
|
-
"check:node-next": "npm run build && node scripts/check-node-next-consumer.mjs",
|
|
76
|
-
"verify:bundle": "node scripts/check-bundle-size.mjs",
|
|
77
|
-
"verify:memory": "node scripts/run-memory-soak.mjs",
|
|
78
|
-
"verify:call-soak": "node scripts/run-call-soak.mjs",
|
|
79
|
-
"verify:hour-soak": "node scripts/run-browser-call-soak.mjs",
|
|
80
|
-
"verify:staged": "npm run verify:memory && npm run verify:call-soak",
|
|
81
|
-
"docs:build": "node scripts/build-docs-site.mjs",
|
|
82
|
-
"docs:check": "node scripts/check-docs-site.mjs",
|
|
83
|
-
"docs:test": "npm run docs:build && npx vitest run tests/docs-site/static-site.test.ts tests/docs-site/navigation.test.ts tests/docs-site/check-docs-site.test.ts",
|
|
84
|
-
"docs:release": "npm run customer:packages && npm run docs:build && node scripts/create-integration-package.mjs && npm run docs:build && npm run docs:check",
|
|
85
|
-
"customer:packages": "node scripts/create-customer-packages.mjs",
|
|
86
|
-
"publish:npm": "bash scripts/publish-npm.sh",
|
|
87
|
-
"verify:release": "npm run lint && npm run typecheck && npm test && npm run build && npm run verify:bundle && npm run pack:check && npm run sbom"
|
|
88
|
-
},
|
|
89
|
-
"dependencies": {
|
|
90
|
-
"jssip": "3.10.1"
|
|
91
|
-
},
|
|
92
|
-
"devDependencies": {
|
|
93
|
-
"@eslint/js": "^10.0.1",
|
|
94
|
-
"@types/react": "^19.3.0",
|
|
95
|
-
"@types/react-dom": "^19.3.0",
|
|
96
|
-
"@vitejs/plugin-react": "^6.1.1",
|
|
97
|
-
"@vitejs/plugin-vue": "^6.0.9",
|
|
98
|
-
"eslint": "^10.10.0",
|
|
99
|
-
"happy-dom": "^20.14.5",
|
|
100
|
-
"react": "^19.3.0",
|
|
101
|
-
"react-dom": "^19.3.0",
|
|
102
|
-
"typescript": "^6.0.3",
|
|
103
|
-
"typescript-eslint": "^8.70.0",
|
|
104
|
-
"vite": "^8.3.0",
|
|
105
|
-
"vite-plugin-dts": "^5.1.0",
|
|
106
|
-
"vitest": "^5.0.1",
|
|
107
|
-
"vue": "^3.5.43"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@16x/webphone-sdk",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"homepage": "https://www.npmjs.com/package/@16x/webphone-sdk",
|
|
5
|
+
"private": false,
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./dist/styles.css"
|
|
14
|
+
],
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/index.js",
|
|
17
|
+
"dist/index.cjs",
|
|
18
|
+
"dist/index.umd.js",
|
|
19
|
+
"dist/*.js",
|
|
20
|
+
"dist/*.cjs",
|
|
21
|
+
"dist/index.d.ts",
|
|
22
|
+
"dist/types.d.ts",
|
|
23
|
+
"dist/version.d.ts",
|
|
24
|
+
"dist/errors",
|
|
25
|
+
"dist/events",
|
|
26
|
+
"dist/state",
|
|
27
|
+
"dist/api",
|
|
28
|
+
"dist/core",
|
|
29
|
+
"dist/shared",
|
|
30
|
+
"dist/ui",
|
|
31
|
+
"dist/legacy",
|
|
32
|
+
"dist/diagnostics",
|
|
33
|
+
"dist/shared-worker.js",
|
|
34
|
+
"dist/shared-worker.d.ts",
|
|
35
|
+
"dist/styles.css",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE",
|
|
38
|
+
"CHANGELOG.md"
|
|
39
|
+
],
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"import": "./dist/index.js",
|
|
44
|
+
"require": "./dist/index.cjs"
|
|
45
|
+
},
|
|
46
|
+
"./ui": {
|
|
47
|
+
"types": "./dist/ui/index.d.ts",
|
|
48
|
+
"import": "./dist/ui/index.js",
|
|
49
|
+
"require": "./dist/ui/index.cjs"
|
|
50
|
+
},
|
|
51
|
+
"./legacy": {
|
|
52
|
+
"types": "./dist/legacy/index.d.ts",
|
|
53
|
+
"import": "./dist/legacy/index.js",
|
|
54
|
+
"require": "./dist/legacy/index.cjs"
|
|
55
|
+
},
|
|
56
|
+
"./diagnostics": {
|
|
57
|
+
"types": "./dist/diagnostics/index.d.ts",
|
|
58
|
+
"import": "./dist/diagnostics/index.js",
|
|
59
|
+
"require": "./dist/diagnostics/index.cjs"
|
|
60
|
+
},
|
|
61
|
+
"./shared-worker": {
|
|
62
|
+
"types": "./dist/shared-worker.d.ts",
|
|
63
|
+
"import": "./dist/shared-worker.js"
|
|
64
|
+
},
|
|
65
|
+
"./styles.css": "./dist/styles.css"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"build": "vite build && vite build -c vite.umd.config.ts",
|
|
69
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
70
|
+
"test": "npm run build && npm run docs:build && vitest run",
|
|
71
|
+
"lint": "eslint .",
|
|
72
|
+
"pack:check": "node scripts/check-package.mjs",
|
|
73
|
+
"sbom": "node scripts/generate-sbom.mjs",
|
|
74
|
+
"release:artifacts": "node scripts/generate-release-artifacts.mjs",
|
|
75
|
+
"check:node-next": "npm run build && node scripts/check-node-next-consumer.mjs",
|
|
76
|
+
"verify:bundle": "node scripts/check-bundle-size.mjs",
|
|
77
|
+
"verify:memory": "node scripts/run-memory-soak.mjs",
|
|
78
|
+
"verify:call-soak": "node scripts/run-call-soak.mjs",
|
|
79
|
+
"verify:hour-soak": "node scripts/run-browser-call-soak.mjs",
|
|
80
|
+
"verify:staged": "npm run verify:memory && npm run verify:call-soak",
|
|
81
|
+
"docs:build": "node scripts/build-docs-site.mjs",
|
|
82
|
+
"docs:check": "node scripts/check-docs-site.mjs",
|
|
83
|
+
"docs:test": "npm run docs:build && npx vitest run tests/docs-site/static-site.test.ts tests/docs-site/navigation.test.ts tests/docs-site/check-docs-site.test.ts",
|
|
84
|
+
"docs:release": "npm run customer:packages && npm run docs:build && node scripts/create-integration-package.mjs && npm run docs:build && npm run docs:check",
|
|
85
|
+
"customer:packages": "node scripts/create-customer-packages.mjs",
|
|
86
|
+
"publish:npm": "bash scripts/publish-npm.sh",
|
|
87
|
+
"verify:release": "npm run lint && npm run typecheck && npm test && npm run build && npm run verify:bundle && npm run pack:check && npm run sbom"
|
|
88
|
+
},
|
|
89
|
+
"dependencies": {
|
|
90
|
+
"jssip": "3.10.1"
|
|
91
|
+
},
|
|
92
|
+
"devDependencies": {
|
|
93
|
+
"@eslint/js": "^10.0.1",
|
|
94
|
+
"@types/react": "^19.3.0",
|
|
95
|
+
"@types/react-dom": "^19.3.0",
|
|
96
|
+
"@vitejs/plugin-react": "^6.1.1",
|
|
97
|
+
"@vitejs/plugin-vue": "^6.0.9",
|
|
98
|
+
"eslint": "^10.10.0",
|
|
99
|
+
"happy-dom": "^20.14.5",
|
|
100
|
+
"react": "^19.3.0",
|
|
101
|
+
"react-dom": "^19.3.0",
|
|
102
|
+
"typescript": "^6.0.3",
|
|
103
|
+
"typescript-eslint": "^8.70.0",
|
|
104
|
+
"vite": "^8.3.0",
|
|
105
|
+
"vite-plugin-dts": "^5.1.0",
|
|
106
|
+
"vitest": "^5.0.1",
|
|
107
|
+
"vue": "^3.5.43"
|
|
108
|
+
}
|
|
109
|
+
}
|