@16x/webphone-sdk 3.1.2 → 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 +11 -0
- package/dist/{CCBarClient-CEybNVKb.cjs → CCBarClient-DUMELx2A.cjs} +1 -1
- package/dist/{CCBarClient-BsVx2U72.js → CCBarClient-Dj6Rv2b5.js} +3 -3
- package/dist/{Diagnostics-B0AJ4g-B.js → Diagnostics-BRfc_7re.js} +1 -1
- package/dist/{Diagnostics-BIK-fe3F.cjs → Diagnostics-bSnxTr6Y.cjs} +1 -1
- package/dist/JsSipAdapter-BHNVNkCS.cjs +1 -0
- package/dist/{JsSipAdapter-BPNEN6Qc.js → JsSipAdapter-oIJe-1OX.js} +55 -27
- 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-56sHLkSX.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, i = 2;
|
|
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 o = 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,7 +135,7 @@ var o = class {
|
|
|
111
135
|
audio: !0,
|
|
112
136
|
video: !1
|
|
113
137
|
},
|
|
114
|
-
sessionTimersExpires:
|
|
138
|
+
sessionTimersExpires: o,
|
|
115
139
|
pcConfig: {
|
|
116
140
|
iceServers: this.iceServers,
|
|
117
141
|
iceCandidatePoolSize: i
|
|
@@ -121,14 +145,18 @@ var o = class {
|
|
|
121
145
|
audio: !0,
|
|
122
146
|
video: !1
|
|
123
147
|
},
|
|
124
|
-
sessionTimersExpires:
|
|
148
|
+
sessionTimersExpires: o,
|
|
125
149
|
pcConfig: {
|
|
126
150
|
iceServers: [...n.iceServers],
|
|
127
151
|
iceCandidatePoolSize: i
|
|
128
152
|
},
|
|
129
|
-
extraHeaders: [
|
|
153
|
+
extraHeaders: [
|
|
154
|
+
...this.terminalHeaders(),
|
|
155
|
+
...n.extraHeaders,
|
|
156
|
+
...n.type === "extension" ? ["X-XCall-Destination-Type: extension"] : []
|
|
157
|
+
]
|
|
130
158
|
};
|
|
131
|
-
return new
|
|
159
|
+
return new l(r.call(t, e));
|
|
132
160
|
} catch (t) {
|
|
133
161
|
throw new e("CALL_OPERATION_NOT_ALLOWED", "call", !1, { cause: t });
|
|
134
162
|
}
|
|
@@ -151,10 +179,10 @@ var o = class {
|
|
|
151
179
|
};
|
|
152
180
|
}
|
|
153
181
|
handleIncoming(e) {
|
|
154
|
-
if (!
|
|
182
|
+
if (!u(e)) return;
|
|
155
183
|
let t = e.session;
|
|
156
184
|
if (t === void 0) return;
|
|
157
|
-
let n = new
|
|
185
|
+
let n = new l(t);
|
|
158
186
|
this.incomingHandlers?.forEach((e) => e(n));
|
|
159
187
|
}
|
|
160
188
|
startRegistration(e) {
|
|
@@ -208,14 +236,14 @@ var o = class {
|
|
|
208
236
|
}
|
|
209
237
|
resolveConnection(e) {
|
|
210
238
|
let t = this.pendingConnection;
|
|
211
|
-
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")));
|
|
212
240
|
}
|
|
213
241
|
resolveWssUrl(e) {
|
|
214
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);
|
|
215
243
|
return n.protocol === "http:" && (n.protocol = "ws:"), n.protocol === "https:" && (n.protocol = "wss:"), this.assertAllowedWssUrl(n), n.toString();
|
|
216
244
|
}
|
|
217
245
|
assertAllowedWssUrl(t) {
|
|
218
|
-
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 });
|
|
219
247
|
}
|
|
220
248
|
withoutTicket(e) {
|
|
221
249
|
let t = new URL(e);
|
|
@@ -237,7 +265,7 @@ var o = class {
|
|
|
237
265
|
registrationFailureCause(e) {
|
|
238
266
|
return typeof e == "object" && e && "cause" in e ? e.cause : e;
|
|
239
267
|
}
|
|
240
|
-
},
|
|
268
|
+
}, l = class {
|
|
241
269
|
session;
|
|
242
270
|
pendingHoldReject;
|
|
243
271
|
mediaRegistration;
|
|
@@ -249,7 +277,7 @@ var o = class {
|
|
|
249
277
|
return this.session.id;
|
|
250
278
|
}
|
|
251
279
|
get from() {
|
|
252
|
-
return this.session.from ??
|
|
280
|
+
return this.session.from ?? m(this.session.remote_identity);
|
|
253
281
|
}
|
|
254
282
|
getMediaRegistration() {
|
|
255
283
|
let e = this.session.connection;
|
|
@@ -317,22 +345,22 @@ var o = class {
|
|
|
317
345
|
});
|
|
318
346
|
}
|
|
319
347
|
};
|
|
320
|
-
function
|
|
348
|
+
function u(e) {
|
|
321
349
|
if (typeof e != "object" || !e) return !1;
|
|
322
350
|
let t = e;
|
|
323
|
-
return t.originator === "remote" &&
|
|
351
|
+
return t.originator === "remote" && d(t.session);
|
|
324
352
|
}
|
|
325
|
-
function
|
|
353
|
+
function d(e) {
|
|
326
354
|
return typeof e == "object" && !!e && "id" in e;
|
|
327
355
|
}
|
|
328
|
-
function
|
|
356
|
+
function f(e) {
|
|
329
357
|
return typeof e == "object" && e && (e.via_transport = "WSS"), e;
|
|
330
358
|
}
|
|
331
|
-
function
|
|
359
|
+
function p(e) {
|
|
332
360
|
let t = e.replace(/^\[|\]$/g, "").toLowerCase();
|
|
333
361
|
return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "0:0:0:0:0:0:0:1";
|
|
334
362
|
}
|
|
335
|
-
function
|
|
363
|
+
function m(e) {
|
|
336
364
|
let t = e?.uri;
|
|
337
365
|
if (t == null) return;
|
|
338
366
|
if (typeof t.user == "string" && t.user !== "") return t.user;
|
|
@@ -340,4 +368,4 @@ function f(e) {
|
|
|
340
368
|
return n.match(/^sips?:([^@;>]+)/i)?.[1] ?? (n === "" ? void 0 : n);
|
|
341
369
|
}
|
|
342
370
|
//#endregion
|
|
343
|
-
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
|