@16x/webphone-sdk 3.1.1 → 3.1.3
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 +17 -0
- package/README.md +60 -6
- package/dist/{CCBarClient-BaO_GM1u.cjs → CCBarClient-DUMELx2A.cjs} +1 -1
- package/dist/{CCBarClient-BCWPbFNX.js → CCBarClient-Dj6Rv2b5.js} +3 -3
- package/dist/{Diagnostics-Hb2Y9WsN.js → Diagnostics-BRfc_7re.js} +1 -1
- package/dist/{Diagnostics-BXKjfW9h.cjs → Diagnostics-bSnxTr6Y.cjs} +1 -1
- package/dist/JsSipAdapter-BHNVNkCS.cjs +1 -0
- package/dist/{JsSipAdapter-BoxqJZsR.js → JsSipAdapter-oIJe-1OX.js} +63 -29
- package/dist/core/CCBarClient.d.ts +10 -0
- package/dist/diagnostics/index.cjs +1 -1
- package/dist/diagnostics/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/JsSipAdapter-915kI1VH.cjs +0 -1
|
@@ -42,32 +42,54 @@ function t(e) {
|
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/sip/JsSipAdapter.ts
|
|
45
|
-
var n = 300, r = 25;
|
|
46
|
-
function
|
|
45
|
+
var n = 300, r = 25, i = 2, a = "", o = 120;
|
|
46
|
+
function s(e) {
|
|
47
47
|
let t = Math.floor(Number(e.sip.registerExpires));
|
|
48
48
|
return Number.isFinite(t) && t > 0 ? t : n;
|
|
49
49
|
}
|
|
50
|
-
var
|
|
50
|
+
var c = class {
|
|
51
51
|
factory;
|
|
52
52
|
transportBaseUrl;
|
|
53
53
|
keepaliveSeconds;
|
|
54
|
+
agentTerminal;
|
|
55
|
+
sessionTimers;
|
|
54
56
|
ua;
|
|
55
57
|
uaListeners;
|
|
56
58
|
incomingHandlers;
|
|
57
59
|
iceServers;
|
|
58
60
|
pendingConnection;
|
|
59
61
|
disposed = !1;
|
|
62
|
+
warmPc;
|
|
60
63
|
keepaliveTimer;
|
|
61
64
|
keepaliveBusy = !1;
|
|
62
65
|
registerExpiresSeconds = 0;
|
|
63
66
|
connectionHandlers = /* @__PURE__ */ new Set();
|
|
64
|
-
constructor(e, t, n = r) {
|
|
65
|
-
this.factory = e, this.transportBaseUrl = t, this.keepaliveSeconds = n;
|
|
67
|
+
constructor(e, t, n = r, i = a, o = !1) {
|
|
68
|
+
this.factory = e, this.transportBaseUrl = t, this.keepaliveSeconds = n, this.agentTerminal = i, this.sessionTimers = o;
|
|
69
|
+
}
|
|
70
|
+
terminalHeaders() {
|
|
71
|
+
return this.agentTerminal === "" ? [] : [`X-Agent-Terminal: ${this.agentTerminal}`];
|
|
72
|
+
}
|
|
73
|
+
warmIceCandidatePool() {
|
|
74
|
+
if (this.closeWarmPc(), typeof RTCPeerConnection < "u" && this.iceServers !== void 0) try {
|
|
75
|
+
this.warmPc = new RTCPeerConnection({
|
|
76
|
+
iceServers: [...this.iceServers],
|
|
77
|
+
iceCandidatePoolSize: i
|
|
78
|
+
});
|
|
79
|
+
} catch {
|
|
80
|
+
this.warmPc = void 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
closeWarmPc() {
|
|
84
|
+
try {
|
|
85
|
+
this.warmPc?.close();
|
|
86
|
+
} catch {}
|
|
87
|
+
this.warmPc = void 0;
|
|
66
88
|
}
|
|
67
89
|
keepaliveTick(e) {
|
|
68
90
|
if (this.isCurrentUa(e) && !this.keepaliveBusy) try {
|
|
69
91
|
if (typeof e.isConnected == "function" && e.isConnected() === !1 || typeof e.register != "function") return;
|
|
70
|
-
this.keepaliveBusy = !0, e.register();
|
|
92
|
+
this.keepaliveBusy = !0, e.register({ extraHeaders: this.terminalHeaders() });
|
|
71
93
|
} catch {} finally {
|
|
72
94
|
this.keepaliveBusy = !1;
|
|
73
95
|
}
|
|
@@ -84,21 +106,23 @@ var a = class {
|
|
|
84
106
|
this.assertNotDisposed(), this.disconnect(this.registrationError("SIP connection replaced"));
|
|
85
107
|
try {
|
|
86
108
|
let e = this.factory.createUa({
|
|
87
|
-
sockets:
|
|
109
|
+
sockets: f(this.factory.createSocket(this.withoutTicket(this.resolveWssUrl(t.transport.wssUrl)), t.transport.ticket)),
|
|
88
110
|
uri: t.sip.uri,
|
|
89
111
|
password: t.sip.registerTicket,
|
|
90
112
|
registrar_server: t.sip.registrar,
|
|
91
113
|
register: !0,
|
|
92
|
-
register_expires:
|
|
114
|
+
register_expires: s(t),
|
|
115
|
+
session_timers: this.sessionTimers,
|
|
116
|
+
...this.agentTerminal === "" ? {} : { user_agent: this.agentTerminal }
|
|
93
117
|
});
|
|
94
|
-
return this.ua = e, this.registerExpiresSeconds =
|
|
118
|
+
return this.ua = e, this.registerExpiresSeconds = s(t), this.iceServers = t.iceServers, this.uaListeners = [], this.startRegistration(e);
|
|
95
119
|
} catch (t) {
|
|
96
120
|
let n = t instanceof e && t.code === "CONFIG_INVALID" ? t : this.transportError(t);
|
|
97
121
|
return this.disconnect(n), Promise.reject(n);
|
|
98
122
|
}
|
|
99
123
|
}
|
|
100
124
|
disconnect(e = this.registrationError("SIP connection disconnected")) {
|
|
101
|
-
this.stopKeepalive();
|
|
125
|
+
this.stopKeepalive(), this.closeWarmPc();
|
|
102
126
|
let t = this.pendingConnection;
|
|
103
127
|
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);
|
|
104
128
|
}
|
|
@@ -111,18 +135,28 @@ var a = class {
|
|
|
111
135
|
audio: !0,
|
|
112
136
|
video: !1
|
|
113
137
|
},
|
|
114
|
-
sessionTimersExpires:
|
|
115
|
-
pcConfig: {
|
|
138
|
+
sessionTimersExpires: o,
|
|
139
|
+
pcConfig: {
|
|
140
|
+
iceServers: this.iceServers,
|
|
141
|
+
iceCandidatePoolSize: i
|
|
142
|
+
}
|
|
116
143
|
} : {
|
|
117
144
|
mediaConstraints: {
|
|
118
145
|
audio: !0,
|
|
119
146
|
video: !1
|
|
120
147
|
},
|
|
121
|
-
sessionTimersExpires:
|
|
122
|
-
pcConfig: {
|
|
123
|
-
|
|
148
|
+
sessionTimersExpires: o,
|
|
149
|
+
pcConfig: {
|
|
150
|
+
iceServers: [...n.iceServers],
|
|
151
|
+
iceCandidatePoolSize: i
|
|
152
|
+
},
|
|
153
|
+
extraHeaders: [
|
|
154
|
+
...this.terminalHeaders(),
|
|
155
|
+
...n.extraHeaders,
|
|
156
|
+
...n.type === "extension" ? ["X-XCall-Destination-Type: extension"] : []
|
|
157
|
+
]
|
|
124
158
|
};
|
|
125
|
-
return new
|
|
159
|
+
return new l(r.call(t, e));
|
|
126
160
|
} catch (t) {
|
|
127
161
|
throw new e("CALL_OPERATION_NOT_ALLOWED", "call", !1, { cause: t });
|
|
128
162
|
}
|
|
@@ -145,10 +179,10 @@ var a = class {
|
|
|
145
179
|
};
|
|
146
180
|
}
|
|
147
181
|
handleIncoming(e) {
|
|
148
|
-
if (!
|
|
182
|
+
if (!u(e)) return;
|
|
149
183
|
let t = e.session;
|
|
150
184
|
if (t === void 0) return;
|
|
151
|
-
let n = new
|
|
185
|
+
let n = new l(t);
|
|
152
186
|
this.incomingHandlers?.forEach((e) => e(n));
|
|
153
187
|
}
|
|
154
188
|
startRegistration(e) {
|
|
@@ -202,14 +236,14 @@ var a = class {
|
|
|
202
236
|
}
|
|
203
237
|
resolveConnection(e) {
|
|
204
238
|
let t = this.pendingConnection;
|
|
205
|
-
t?.ua === e && (this.pendingConnection = void 0, t.resolve(), this.startKeepalive(e, this.registerExpiresSeconds), this.connectionHandlers.forEach((e) => e("registered")));
|
|
239
|
+
t?.ua === e && (this.pendingConnection = void 0, t.resolve(), this.warmIceCandidatePool(), this.startKeepalive(e, this.registerExpiresSeconds), this.connectionHandlers.forEach((e) => e("registered")));
|
|
206
240
|
}
|
|
207
241
|
resolveWssUrl(e) {
|
|
208
242
|
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);
|
|
209
243
|
return n.protocol === "http:" && (n.protocol = "ws:"), n.protocol === "https:" && (n.protocol = "wss:"), this.assertAllowedWssUrl(n), n.toString();
|
|
210
244
|
}
|
|
211
245
|
assertAllowedWssUrl(t) {
|
|
212
|
-
if (t.protocol !== "wss:" && !(t.protocol === "ws:" &&
|
|
246
|
+
if (t.protocol !== "wss:" && !(t.protocol === "ws:" && p(t.hostname))) throw new e("CONFIG_INVALID", "configuration", !1, { cause: t.origin });
|
|
213
247
|
}
|
|
214
248
|
withoutTicket(e) {
|
|
215
249
|
let t = new URL(e);
|
|
@@ -231,7 +265,7 @@ var a = class {
|
|
|
231
265
|
registrationFailureCause(e) {
|
|
232
266
|
return typeof e == "object" && e && "cause" in e ? e.cause : e;
|
|
233
267
|
}
|
|
234
|
-
},
|
|
268
|
+
}, l = class {
|
|
235
269
|
session;
|
|
236
270
|
pendingHoldReject;
|
|
237
271
|
mediaRegistration;
|
|
@@ -243,7 +277,7 @@ var a = class {
|
|
|
243
277
|
return this.session.id;
|
|
244
278
|
}
|
|
245
279
|
get from() {
|
|
246
|
-
return this.session.from ??
|
|
280
|
+
return this.session.from ?? m(this.session.remote_identity);
|
|
247
281
|
}
|
|
248
282
|
getMediaRegistration() {
|
|
249
283
|
let e = this.session.connection;
|
|
@@ -311,22 +345,22 @@ var a = class {
|
|
|
311
345
|
});
|
|
312
346
|
}
|
|
313
347
|
};
|
|
314
|
-
function
|
|
348
|
+
function u(e) {
|
|
315
349
|
if (typeof e != "object" || !e) return !1;
|
|
316
350
|
let t = e;
|
|
317
|
-
return t.originator === "remote" &&
|
|
351
|
+
return t.originator === "remote" && d(t.session);
|
|
318
352
|
}
|
|
319
|
-
function
|
|
353
|
+
function d(e) {
|
|
320
354
|
return typeof e == "object" && !!e && "id" in e;
|
|
321
355
|
}
|
|
322
|
-
function
|
|
356
|
+
function f(e) {
|
|
323
357
|
return typeof e == "object" && e && (e.via_transport = "WSS"), e;
|
|
324
358
|
}
|
|
325
|
-
function
|
|
359
|
+
function p(e) {
|
|
326
360
|
let t = e.replace(/^\[|\]$/g, "").toLowerCase();
|
|
327
361
|
return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "0:0:0:0:0:0:0:1";
|
|
328
362
|
}
|
|
329
|
-
function
|
|
363
|
+
function m(e) {
|
|
330
364
|
let t = e?.uri;
|
|
331
365
|
if (t == null) return;
|
|
332
366
|
if (typeof t.user == "string" && t.user !== "") return t.user;
|
|
@@ -334,4 +368,4 @@ function d(e) {
|
|
|
334
368
|
return n.match(/^sips?:([^@;>]+)/i)?.[1] ?? (n === "" ? void 0 : n);
|
|
335
369
|
}
|
|
336
370
|
//#endregion
|
|
337
|
-
export {
|
|
371
|
+
export { c as JsSipAdapter };
|
|
@@ -37,6 +37,16 @@ export interface CCBarClientOptions {
|
|
|
37
37
|
* 页面还显示已注册,下一次 INVITE 却直接失败。
|
|
38
38
|
*/
|
|
39
39
|
readonly sipKeepaliveSeconds?: number;
|
|
40
|
+
/**
|
|
41
|
+
* 终端标识:设了就在 INVITE / REGISTER 上带 `X-Agent-Terminal`,并作为 UA 的 User-Agent。
|
|
42
|
+
* 默认**不发**(旧版脚本 SDK 的两种做法都能外呼:一种带 'ccbar坐席',一种完全不带)。
|
|
43
|
+
*/
|
|
44
|
+
readonly agentTerminal?: string;
|
|
45
|
+
/**
|
|
46
|
+
* SIP 会话定时器(Session-Expires)。默认 **false**,与旧版脚本 SDK 一致:
|
|
47
|
+
* 打开时 INVITE 会带 `Session-Expires` / `Supported: timer`,个别平台对此敏感。
|
|
48
|
+
*/
|
|
49
|
+
readonly sipSessionTimers?: boolean;
|
|
40
50
|
/** SharedWorker attach/close is attempted when this option is provided. SIP remains tab-local until the next-minor adapter. */
|
|
41
51
|
readonly sharedWorker?: SharedWorkerOptions;
|
|
42
52
|
/** @internal Test/integration dependency injection; not required by consumers. */
|
|
@@ -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-bSnxTr6Y.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,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-BRfc_7re.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 };
|
package/dist/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-DUMELx2A.cjs"),n=require("./Diagnostics-bSnxTr6Y.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,6 +1,6 @@
|
|
|
1
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-
|
|
3
|
-
import { n as m, r as h, t as g } from "./Diagnostics-
|
|
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-Dj6Rv2b5.js";
|
|
3
|
+
import { n as m, r as h, t as g } from "./Diagnostics-BRfc_7re.js";
|
|
4
4
|
import { n as _, t as v } from "./redact-DB3CMbsK.js";
|
|
5
5
|
import "./diagnostics/index.js";
|
|
6
6
|
//#region src/api/contracts.ts
|