@16x/webphone-sdk 3.1.11 → 3.1.13
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 +37 -215
- package/LICENSE +1 -1
- package/README.md +161 -219
- package/dist/{CCBarClient-Dmw3T0lF.js → CCBarClient-BJO4qjN2.js} +93 -64
- package/dist/CCBarClient-_sG61iiu.cjs +1 -0
- package/dist/{Diagnostics-Dmhx4niF.cjs → Diagnostics-B9EQ0Y8m.cjs} +1 -1
- package/dist/{Diagnostics-BLHANihC.js → Diagnostics-DdbpMSMr.js} +1 -1
- package/dist/JsSipAdapter-BB-SusrS.cjs +1 -0
- package/dist/{JsSipAdapter-CwDotPN2.js → JsSipAdapter-BHtCsy_S.js} +206 -35
- 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/createJsSipFactory-B1ORbJiP.cjs +22 -0
- package/dist/createJsSipFactory-CoWZN-BC.js +7410 -0
- package/dist/diagnostics/Diagnostics.d.ts +8 -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 +1 -75
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +67 -69
- package/dist/legacy/legacySessionProvider.d.ts +4 -8
- package/dist/shared/SharedWorkerProtocol.d.ts +1 -0
- package/dist/shared-worker.cjs +1 -1
- package/dist/shared-worker.js +1 -1
- package/dist/styles.css +7 -7
- package/dist/types.d.ts +1 -1
- package/dist/ui/i18n/types.d.ts +1 -0
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.js +16 -7
- package/dist/version.d.ts +1 -1
- package/package.json +4 -3
- package/dist/CCBarClient-B7SRICz8.cjs +0 -1
- package/dist/JsSipAdapter-BN9BAFHr.cjs +0 -1
- package/dist/SharedWorkerProtocol-39dch6xL.cjs +0 -1
- package/dist/SharedWorkerProtocol-DKVQ5-po.js +0 -87
- package/dist/createJsSipFactory-9CPsweDR.js +0 -9665
- package/dist/createJsSipFactory-Dr8HbLl-.cjs +0 -75
|
@@ -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();
|
|
@@ -41,13 +41,169 @@ function t(e) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
|
+
//#region src/sip/iceServerQuality.ts
|
|
45
|
+
var n = 2e3;
|
|
46
|
+
function r(e) {
|
|
47
|
+
if (!e) return "";
|
|
48
|
+
let t = String(e.type ?? "");
|
|
49
|
+
return t === "" ? / typ (\w+)/.exec(String(e.candidate ?? ""))?.[1] ?? "" : t;
|
|
50
|
+
}
|
|
51
|
+
function i(e, t = {}) {
|
|
52
|
+
let i = Number.isFinite(t.timeoutMs) && t.timeoutMs > 0 ? t.timeoutMs : n;
|
|
53
|
+
if (typeof RTCPeerConnection > "u" || !Array.isArray(e)) return Promise.resolve([]);
|
|
54
|
+
let a = [];
|
|
55
|
+
for (let t of e) {
|
|
56
|
+
if (!t) continue;
|
|
57
|
+
let e = Array.isArray(t.urls) ? t.urls : [t.urls];
|
|
58
|
+
for (let n of e) {
|
|
59
|
+
let e = String(n ?? "").trim();
|
|
60
|
+
/^(stun|turn|turns):/i.test(e) && a.push({
|
|
61
|
+
url: e,
|
|
62
|
+
entry: t
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return Promise.all(a.map((e) => new Promise((t) => {
|
|
67
|
+
let n = !1, a, o = (r) => {
|
|
68
|
+
if (!n) {
|
|
69
|
+
n = !0, clearTimeout(s);
|
|
70
|
+
try {
|
|
71
|
+
a?.close();
|
|
72
|
+
} catch {}
|
|
73
|
+
t({
|
|
74
|
+
url: e.url,
|
|
75
|
+
ok: r,
|
|
76
|
+
tcp: /transport=tcp/i.test(e.url) || /^turns:/i.test(e.url)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}, s = setTimeout(() => o(!1), i);
|
|
80
|
+
try {
|
|
81
|
+
let t = { urls: [e.url] };
|
|
82
|
+
e.entry.username && (t.username = e.entry.username), e.entry.credential && (t.credential = e.entry.credential), a = new RTCPeerConnection({ iceServers: [t] }), a.createDataChannel("webphone-ice-probe"), a.onicecandidate = (e) => {
|
|
83
|
+
if (!e || !e.candidate) return;
|
|
84
|
+
let t = r(e.candidate);
|
|
85
|
+
(t === "srflx" || t === "relay") && o(!0);
|
|
86
|
+
}, a.createOffer().then((e) => a?.setLocalDescription(e)).catch(() => o(!1));
|
|
87
|
+
} catch {
|
|
88
|
+
o(!1);
|
|
89
|
+
}
|
|
90
|
+
})));
|
|
91
|
+
}
|
|
92
|
+
function a(e, t) {
|
|
93
|
+
let n = /* @__PURE__ */ new Map();
|
|
94
|
+
for (let e of t) e && e.url && n.set(String(e.url), e.ok === !0);
|
|
95
|
+
let r = [];
|
|
96
|
+
for (let t of e ?? []) {
|
|
97
|
+
if (!t) continue;
|
|
98
|
+
let e = (Array.isArray(t.urls) ? t.urls : [t.urls]).filter(Boolean).filter((e) => n.get(String(e)) === !0);
|
|
99
|
+
if (e.length === 0) continue;
|
|
100
|
+
let i = {
|
|
101
|
+
...t,
|
|
102
|
+
urls: e
|
|
103
|
+
};
|
|
104
|
+
r.push(i);
|
|
105
|
+
}
|
|
106
|
+
return r;
|
|
107
|
+
}
|
|
108
|
+
var o = class {
|
|
109
|
+
convergedList;
|
|
110
|
+
lastResults = [];
|
|
111
|
+
snapshotState = {
|
|
112
|
+
runs: 0,
|
|
113
|
+
lastMs: null,
|
|
114
|
+
udpOk: !1,
|
|
115
|
+
tcpRelayOk: !1,
|
|
116
|
+
convergedServers: null,
|
|
117
|
+
unchanged: null
|
|
118
|
+
};
|
|
119
|
+
running = !1;
|
|
120
|
+
seq = 0;
|
|
121
|
+
converged(e) {
|
|
122
|
+
return this.convergedList ?? e;
|
|
123
|
+
}
|
|
124
|
+
snapshot() {
|
|
125
|
+
return this.snapshotState;
|
|
126
|
+
}
|
|
127
|
+
reset() {
|
|
128
|
+
this.seq++, this.running = !1, this.convergedList = void 0, this.lastResults = [], this.snapshotState = {
|
|
129
|
+
runs: 0,
|
|
130
|
+
lastMs: null,
|
|
131
|
+
udpOk: !1,
|
|
132
|
+
tcpRelayOk: !1,
|
|
133
|
+
convergedServers: null,
|
|
134
|
+
unchanged: null
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
assess(e, t = {}) {
|
|
138
|
+
if (e === void 0 || e.length === 0) return;
|
|
139
|
+
let n = e.map((e) => ({
|
|
140
|
+
...e,
|
|
141
|
+
urls: Array.isArray(e.urls) ? [...e.urls] : [e.urls]
|
|
142
|
+
}));
|
|
143
|
+
if (typeof RTCPeerConnection > "u" || !n.some((e) => (Array.isArray(e.urls) ? e.urls : [e.urls]).some((e) => /^(stun|turn|turns):/i.test(String(e ?? ""))))) return;
|
|
144
|
+
let r = ++this.seq;
|
|
145
|
+
this.running = !0;
|
|
146
|
+
let o = Date.now();
|
|
147
|
+
i(n, t).then((e) => {
|
|
148
|
+
if (r !== this.seq) return;
|
|
149
|
+
this.lastResults = e;
|
|
150
|
+
let t = n, i = a(t, e);
|
|
151
|
+
this.convergedList = i, this.snapshotState = {
|
|
152
|
+
runs: this.snapshotState.runs + 1,
|
|
153
|
+
lastMs: Date.now() - o,
|
|
154
|
+
udpOk: e.some((e) => e.ok && !e.tcp),
|
|
155
|
+
tcpRelayOk: e.some((e) => e.ok && e.tcp),
|
|
156
|
+
convergedServers: i.length,
|
|
157
|
+
unchanged: JSON.stringify(i) === JSON.stringify(t)
|
|
158
|
+
};
|
|
159
|
+
}).catch(() => {
|
|
160
|
+
this.seq;
|
|
161
|
+
}).finally(() => {
|
|
162
|
+
r === this.seq && (this.running = !1);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
isRunning() {
|
|
166
|
+
return this.running;
|
|
167
|
+
}
|
|
168
|
+
}, s = 3e3;
|
|
169
|
+
function c(e) {
|
|
170
|
+
if (!e) return "";
|
|
171
|
+
let t = String(e.type ?? "");
|
|
172
|
+
return t === "" ? / typ (\w+)/.exec(String(e.candidate ?? ""))?.[1] ?? "" : t;
|
|
173
|
+
}
|
|
174
|
+
function l(e, t = {}) {
|
|
175
|
+
if (typeof e.on != "function") return () => void 0;
|
|
176
|
+
let n = Number.isFinite(t.timeoutMs) && t.timeoutMs > 0 ? t.timeoutMs : s, r = !1, i, a = () => {
|
|
177
|
+
if (!r) {
|
|
178
|
+
r = !0, clearTimeout(l);
|
|
179
|
+
try {
|
|
180
|
+
i?.();
|
|
181
|
+
} catch {}
|
|
182
|
+
}
|
|
183
|
+
}, o = (e) => {
|
|
184
|
+
let t = e;
|
|
185
|
+
if (!t || typeof t.ready != "function") return;
|
|
186
|
+
i = t.ready;
|
|
187
|
+
let n = c(t.candidate);
|
|
188
|
+
(n === "srflx" || n === "relay") && a();
|
|
189
|
+
};
|
|
190
|
+
e.on("icecandidate", o);
|
|
191
|
+
let l = setTimeout(a, n);
|
|
192
|
+
return () => {
|
|
193
|
+
clearTimeout(l);
|
|
194
|
+
try {
|
|
195
|
+
e.off?.("icecandidate", o);
|
|
196
|
+
} catch {}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
44
200
|
//#region src/sip/JsSipAdapter.ts
|
|
45
|
-
var
|
|
46
|
-
function
|
|
201
|
+
var u = 300, d = 25, f = 2, p = "", m = 120;
|
|
202
|
+
function h(e) {
|
|
47
203
|
let t = Math.floor(Number(e.sip.registerExpires));
|
|
48
|
-
return Number.isFinite(t) && t > 0 ? t :
|
|
204
|
+
return Number.isFinite(t) && t > 0 ? t : u;
|
|
49
205
|
}
|
|
50
|
-
var
|
|
206
|
+
var g = class {
|
|
51
207
|
factory;
|
|
52
208
|
transportBaseUrl;
|
|
53
209
|
keepaliveSeconds;
|
|
@@ -64,8 +220,9 @@ var c = class {
|
|
|
64
220
|
keepaliveBusy = !1;
|
|
65
221
|
registerExpiresSeconds = 0;
|
|
66
222
|
connectionHandlers = /* @__PURE__ */ new Set();
|
|
67
|
-
|
|
68
|
-
|
|
223
|
+
iceQuality = new o();
|
|
224
|
+
constructor(e, t, n = d, r = p, i = !1) {
|
|
225
|
+
this.factory = e, this.transportBaseUrl = t, this.keepaliveSeconds = n, this.agentTerminal = r, this.sessionTimers = i;
|
|
69
226
|
}
|
|
70
227
|
terminalHeaders() {
|
|
71
228
|
return this.agentTerminal === "" ? [] : [`X-Agent-Terminal: ${this.agentTerminal}`];
|
|
@@ -74,7 +231,7 @@ var c = class {
|
|
|
74
231
|
if (this.closeWarmPc(), typeof RTCPeerConnection < "u" && this.iceServers !== void 0) try {
|
|
75
232
|
this.warmPc = new RTCPeerConnection({
|
|
76
233
|
iceServers: [...this.iceServers],
|
|
77
|
-
iceCandidatePoolSize:
|
|
234
|
+
iceCandidatePoolSize: f
|
|
78
235
|
});
|
|
79
236
|
} catch {
|
|
80
237
|
this.warmPc = void 0;
|
|
@@ -106,23 +263,23 @@ var c = class {
|
|
|
106
263
|
this.assertNotDisposed(), this.disconnect(this.registrationError("SIP connection replaced"));
|
|
107
264
|
try {
|
|
108
265
|
let e = this.factory.createUa({
|
|
109
|
-
sockets:
|
|
266
|
+
sockets: b(this.factory.createSocket(this.withoutTicket(this.resolveWssUrl(t.transport.wssUrl)), t.transport.ticket)),
|
|
110
267
|
uri: t.sip.uri,
|
|
111
268
|
password: t.sip.registerTicket,
|
|
112
269
|
registrar_server: t.sip.registrar,
|
|
113
270
|
register: !0,
|
|
114
|
-
register_expires:
|
|
271
|
+
register_expires: h(t),
|
|
115
272
|
session_timers: this.sessionTimers,
|
|
116
273
|
...this.agentTerminal === "" ? {} : { user_agent: this.agentTerminal }
|
|
117
274
|
});
|
|
118
|
-
return this.ua = e, this.registerExpiresSeconds =
|
|
275
|
+
return this.ua = e, this.registerExpiresSeconds = h(t), this.iceServers = t.iceServers, this.uaListeners = [], this.startRegistration(e);
|
|
119
276
|
} catch (t) {
|
|
120
277
|
let n = t instanceof e && t.code === "CONFIG_INVALID" ? t : this.transportError(t);
|
|
121
278
|
return this.disconnect(n), Promise.reject(n);
|
|
122
279
|
}
|
|
123
280
|
}
|
|
124
281
|
disconnect(e = this.registrationError("SIP connection disconnected")) {
|
|
125
|
-
this.stopKeepalive(), this.closeWarmPc();
|
|
282
|
+
this.stopKeepalive(), this.closeWarmPc(), this.iceQuality.reset();
|
|
126
283
|
let t = this.pendingConnection;
|
|
127
284
|
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);
|
|
128
285
|
}
|
|
@@ -135,20 +292,20 @@ var c = class {
|
|
|
135
292
|
audio: !0,
|
|
136
293
|
video: !1
|
|
137
294
|
},
|
|
138
|
-
sessionTimersExpires:
|
|
295
|
+
sessionTimersExpires: m,
|
|
139
296
|
pcConfig: {
|
|
140
|
-
iceServers: this.
|
|
141
|
-
iceCandidatePoolSize:
|
|
297
|
+
iceServers: this.dialIceServers(),
|
|
298
|
+
iceCandidatePoolSize: f
|
|
142
299
|
}
|
|
143
300
|
} : {
|
|
144
301
|
mediaConstraints: {
|
|
145
302
|
audio: !0,
|
|
146
303
|
video: !1
|
|
147
304
|
},
|
|
148
|
-
sessionTimersExpires:
|
|
305
|
+
sessionTimersExpires: m,
|
|
149
306
|
pcConfig: {
|
|
150
307
|
iceServers: [...n.iceServers],
|
|
151
|
-
iceCandidatePoolSize:
|
|
308
|
+
iceCandidatePoolSize: f
|
|
152
309
|
},
|
|
153
310
|
extraHeaders: [
|
|
154
311
|
...this.terminalHeaders(),
|
|
@@ -156,7 +313,7 @@ var c = class {
|
|
|
156
313
|
...n.type === "extension" ? ["X-XCall-Destination-Type: extension"] : []
|
|
157
314
|
]
|
|
158
315
|
};
|
|
159
|
-
return new
|
|
316
|
+
return new _(r.call(t, e));
|
|
160
317
|
} catch (t) {
|
|
161
318
|
throw new e("CALL_OPERATION_NOT_ALLOWED", "call", !1, { cause: t });
|
|
162
319
|
}
|
|
@@ -172,6 +329,13 @@ var c = class {
|
|
|
172
329
|
dispose() {
|
|
173
330
|
this.disposed || (this.disposed = !0, this.disconnect(), this.incomingHandlers = void 0, this.connectionHandlers.clear());
|
|
174
331
|
}
|
|
332
|
+
dialIceServers() {
|
|
333
|
+
let e = this.iceQuality.converged(this.iceServers);
|
|
334
|
+
return e === void 0 ? void 0 : [...e];
|
|
335
|
+
}
|
|
336
|
+
iceQualitySnapshot() {
|
|
337
|
+
return this.iceQuality.snapshot();
|
|
338
|
+
}
|
|
175
339
|
getResourceCounts() {
|
|
176
340
|
return {
|
|
177
341
|
listeners: (this.uaListeners?.length ?? 0) + (this.incomingHandlers?.size ?? 0) + this.connectionHandlers.size,
|
|
@@ -179,10 +343,10 @@ var c = class {
|
|
|
179
343
|
};
|
|
180
344
|
}
|
|
181
345
|
handleIncoming(e) {
|
|
182
|
-
if (!
|
|
346
|
+
if (!v(e)) return;
|
|
183
347
|
let t = e.session;
|
|
184
348
|
if (t === void 0) return;
|
|
185
|
-
let n = new
|
|
349
|
+
let n = new _(t);
|
|
186
350
|
this.incomingHandlers?.forEach((e) => e(n));
|
|
187
351
|
}
|
|
188
352
|
startRegistration(e) {
|
|
@@ -236,14 +400,14 @@ var c = class {
|
|
|
236
400
|
}
|
|
237
401
|
resolveConnection(e) {
|
|
238
402
|
let t = this.pendingConnection;
|
|
239
|
-
t?.ua === e && (this.pendingConnection = void 0, t.resolve(), this.warmIceCandidatePool(), this.startKeepalive(e, this.registerExpiresSeconds), this.connectionHandlers.forEach((e) => e("registered")));
|
|
403
|
+
t?.ua === e && (this.pendingConnection = void 0, t.resolve(), this.warmIceCandidatePool(), this.iceQuality.assess(this.iceServers), this.startKeepalive(e, this.registerExpiresSeconds), this.connectionHandlers.forEach((e) => e("registered")));
|
|
240
404
|
}
|
|
241
405
|
resolveWssUrl(e) {
|
|
242
406
|
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);
|
|
243
407
|
return n.protocol === "http:" && (n.protocol = "ws:"), n.protocol === "https:" && (n.protocol = "wss:"), this.assertAllowedWssUrl(n), n.toString();
|
|
244
408
|
}
|
|
245
409
|
assertAllowedWssUrl(t) {
|
|
246
|
-
if (t.protocol !== "wss:" && !(t.protocol === "ws:" &&
|
|
410
|
+
if (t.protocol !== "wss:" && !(t.protocol === "ws:" && x(t.hostname))) throw new e("CONFIG_INVALID", "configuration", !1, { cause: t.origin });
|
|
247
411
|
}
|
|
248
412
|
withoutTicket(e) {
|
|
249
413
|
let t = new URL(e);
|
|
@@ -265,7 +429,7 @@ var c = class {
|
|
|
265
429
|
registrationFailureCause(e) {
|
|
266
430
|
return typeof e == "object" && e && "cause" in e ? e.cause : e;
|
|
267
431
|
}
|
|
268
|
-
},
|
|
432
|
+
}, _ = class {
|
|
269
433
|
session;
|
|
270
434
|
pendingHoldReject;
|
|
271
435
|
mediaRegistration;
|
|
@@ -273,14 +437,15 @@ var c = class {
|
|
|
273
437
|
mediaHandlers = /* @__PURE__ */ new Set();
|
|
274
438
|
mediaWatchStarted = !1;
|
|
275
439
|
sessionUnsubscribeFromPeerConnection;
|
|
440
|
+
detachIceGatheringTimeout;
|
|
276
441
|
constructor(e) {
|
|
277
|
-
this.session = e;
|
|
442
|
+
this.session = e, this.detachIceGatheringTimeout = l(e);
|
|
278
443
|
}
|
|
279
444
|
get id() {
|
|
280
445
|
return this.session.id;
|
|
281
446
|
}
|
|
282
447
|
get from() {
|
|
283
|
-
return this.session.from ??
|
|
448
|
+
return this.session.from ?? S(this.session.remote_identity);
|
|
284
449
|
}
|
|
285
450
|
getMediaRegistration() {
|
|
286
451
|
let e = this.session.connection;
|
|
@@ -289,11 +454,14 @@ var c = class {
|
|
|
289
454
|
answer(e) {
|
|
290
455
|
this.session.answer({
|
|
291
456
|
mediaConstraints: e.mediaConstraints,
|
|
292
|
-
pcConfig: {
|
|
457
|
+
pcConfig: {
|
|
458
|
+
iceServers: [...e.pcConfig.iceServers],
|
|
459
|
+
iceCandidatePoolSize: f
|
|
460
|
+
}
|
|
293
461
|
});
|
|
294
462
|
}
|
|
295
463
|
terminate() {
|
|
296
|
-
this.pendingHoldReject?.(/* @__PURE__ */ Error("SIP session terminated")), this.session.terminate();
|
|
464
|
+
this.detachIceGatheringTimeout?.(), this.detachIceGatheringTimeout = void 0, this.pendingHoldReject?.(/* @__PURE__ */ Error("SIP session terminated")), this.session.terminate();
|
|
297
465
|
}
|
|
298
466
|
hold() {
|
|
299
467
|
return this.changeHoldState("hold");
|
|
@@ -369,29 +537,32 @@ var c = class {
|
|
|
369
537
|
}
|
|
370
538
|
this.pendingHoldReject = c;
|
|
371
539
|
try {
|
|
372
|
-
this.session[t](void 0, s) || c(
|
|
540
|
+
this.session[t](void 0, s) || c({
|
|
541
|
+
reason: "jssip_operation_rejected",
|
|
542
|
+
operation: t
|
|
543
|
+
});
|
|
373
544
|
} catch (e) {
|
|
374
545
|
c(e);
|
|
375
546
|
}
|
|
376
547
|
});
|
|
377
548
|
}
|
|
378
549
|
};
|
|
379
|
-
function
|
|
550
|
+
function v(e) {
|
|
380
551
|
if (typeof e != "object" || !e) return !1;
|
|
381
552
|
let t = e;
|
|
382
|
-
return t.originator === "remote" &&
|
|
553
|
+
return t.originator === "remote" && y(t.session);
|
|
383
554
|
}
|
|
384
|
-
function
|
|
555
|
+
function y(e) {
|
|
385
556
|
return typeof e == "object" && !!e && "id" in e;
|
|
386
557
|
}
|
|
387
|
-
function
|
|
558
|
+
function b(e) {
|
|
388
559
|
return typeof e == "object" && e && (e.via_transport = "WSS"), e;
|
|
389
560
|
}
|
|
390
|
-
function
|
|
561
|
+
function x(e) {
|
|
391
562
|
let t = e.replace(/^\[|\]$/g, "").toLowerCase();
|
|
392
563
|
return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "0:0:0:0:0:0:0:1";
|
|
393
564
|
}
|
|
394
|
-
function
|
|
565
|
+
function S(e) {
|
|
395
566
|
let t = e?.uri;
|
|
396
567
|
if (t == null) return;
|
|
397
568
|
if (typeof t.user == "string" && t.user !== "") return t.user;
|
|
@@ -399,4 +570,4 @@ function m(e) {
|
|
|
399
570
|
return n.match(/^sips?:([^@;>]+)/i)?.[1] ?? (n === "" ? void 0 : n);
|
|
400
571
|
}
|
|
401
572
|
//#endregion
|
|
402
|
-
export {
|
|
573
|
+
export { g as JsSipAdapter };
|
|
@@ -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;
|
|
@@ -68,6 +70,7 @@ export declare class CCBarCall {
|
|
|
68
70
|
private handleSessionEvent;
|
|
69
71
|
private transitionToActive;
|
|
70
72
|
private transitionIfAllowed;
|
|
73
|
+
private updateHoldState;
|
|
71
74
|
private transitionIfStillRinging;
|
|
72
75
|
private transitionTo;
|
|
73
76
|
private startPendingOperation;
|