module-develop-kit 0.5.10 → 0.5.12

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.
Files changed (165) hide show
  1. package/dist/commonjs-virtual-dir/Config.js +4 -0
  2. package/dist/commonjs-virtual-dir/Constants.js +5 -0
  3. package/dist/commonjs-virtual-dir/DTMF.js +4 -0
  4. package/dist/commonjs-virtual-dir/JsSIP.js +5 -0
  5. package/dist/commonjs-virtual-dir/Parser2.js +4 -0
  6. package/dist/commonjs-virtual-dir/Socket.js +4 -0
  7. package/dist/commonjs-virtual-dir/Utils.js +4 -0
  8. package/dist/commonjs-virtual-dir/___vite-browser-external.js +6 -0
  9. package/dist/commonjs-virtual-dir/__vite-browser-external.js +4 -0
  10. package/dist/commonjs-virtual-dir/_commonjs-dynamic-modules.js +6 -0
  11. package/dist/commonjs-virtual-dir/_commonjsHelpers.js +33 -0
  12. package/dist/commonjs-virtual-dir/_virtual_mobile-compatibility-detection.js +4 -0
  13. package/dist/commonjs-virtual-dir/_virtual_pc-compatibility-detection.js +4 -0
  14. package/dist/commonjs-virtual-dir/aes.js +4 -0
  15. package/dist/commonjs-virtual-dir/blowfish.js +4 -0
  16. package/dist/commonjs-virtual-dir/browser.js +4 -0
  17. package/dist/commonjs-virtual-dir/cipher-core.js +4 -0
  18. package/dist/commonjs-virtual-dir/core.js +4 -0
  19. package/dist/commonjs-virtual-dir/enc-base64.js +4 -0
  20. package/dist/commonjs-virtual-dir/enc-base64url.js +4 -0
  21. package/dist/commonjs-virtual-dir/enc-utf16.js +4 -0
  22. package/dist/commonjs-virtual-dir/events.js +4 -0
  23. package/dist/commonjs-virtual-dir/evpkdf.js +4 -0
  24. package/dist/commonjs-virtual-dir/format-hex.js +4 -0
  25. package/dist/commonjs-virtual-dir/grammar.js +4 -0
  26. package/dist/commonjs-virtual-dir/hmac.js +4 -0
  27. package/dist/commonjs-virtual-dir/index.js +5 -0
  28. package/dist/commonjs-virtual-dir/index2.js +5 -0
  29. package/dist/commonjs-virtual-dir/index3.js +7 -0
  30. package/dist/commonjs-virtual-dir/index4.js +7 -0
  31. package/dist/commonjs-virtual-dir/index5.js +4 -0
  32. package/dist/commonjs-virtual-dir/index6.js +4 -0
  33. package/dist/commonjs-virtual-dir/index7.js +4 -0
  34. package/dist/commonjs-virtual-dir/index8.js +4 -0
  35. package/dist/commonjs-virtual-dir/lib-typedarrays.js +4 -0
  36. package/dist/commonjs-virtual-dir/md5.js +4 -0
  37. package/dist/commonjs-virtual-dir/mode-cfb.js +4 -0
  38. package/dist/commonjs-virtual-dir/mode-ctr-gladman.js +4 -0
  39. package/dist/commonjs-virtual-dir/mode-ctr.js +4 -0
  40. package/dist/commonjs-virtual-dir/mode-ecb.js +4 -0
  41. package/dist/commonjs-virtual-dir/mode-ofb.js +4 -0
  42. package/dist/commonjs-virtual-dir/pad-ansix923.js +4 -0
  43. package/dist/commonjs-virtual-dir/pad-iso10126.js +4 -0
  44. package/dist/commonjs-virtual-dir/pad-iso97971.js +4 -0
  45. package/dist/commonjs-virtual-dir/pad-nopadding.js +4 -0
  46. package/dist/commonjs-virtual-dir/pad-zeropadding.js +4 -0
  47. package/dist/commonjs-virtual-dir/parser.js +4 -0
  48. package/dist/commonjs-virtual-dir/pbkdf2.js +4 -0
  49. package/dist/commonjs-virtual-dir/rabbit-legacy.js +4 -0
  50. package/dist/commonjs-virtual-dir/rabbit.js +4 -0
  51. package/dist/commonjs-virtual-dir/rc4.js +4 -0
  52. package/dist/commonjs-virtual-dir/ripemd160.js +4 -0
  53. package/dist/commonjs-virtual-dir/sha1.js +4 -0
  54. package/dist/commonjs-virtual-dir/sha224.js +4 -0
  55. package/dist/commonjs-virtual-dir/sha256.js +4 -0
  56. package/dist/commonjs-virtual-dir/sha3.js +4 -0
  57. package/dist/commonjs-virtual-dir/sha384.js +4 -0
  58. package/dist/commonjs-virtual-dir/sha512.js +4 -0
  59. package/dist/commonjs-virtual-dir/tripledes.js +4 -0
  60. package/dist/commonjs-virtual-dir/x64-core.js +4 -0
  61. package/dist/main.js +25 -0
  62. package/dist/src/outside-call/CallManagement.js +249 -0
  63. package/dist/src/outside-call/constants.js +42 -0
  64. package/dist/src/outside-call/index.js +74 -0
  65. package/dist/src/outside-call/utils.js +50 -0
  66. package/dist/src/shield/crypto.js +28 -0
  67. package/dist/src/shield/index.js +59 -0
  68. package/dist/src/shield/no-debugger.js +26 -0
  69. package/dist/src/utils/eventBus.js +59 -0
  70. package/dist/src/vite-plugins/getCompatibilityPlugins.js +13 -0
  71. package/dist/src/vite-plugins/vitePluginCompatibilityDetection.js +28 -0
  72. package/dist/vendor/base64-js/index.js +52 -0
  73. package/dist/vendor/crypto-js/aes.js +69 -0
  74. package/dist/vendor/crypto-js/blowfish.js +1131 -0
  75. package/dist/vendor/crypto-js/cipher-core.js +544 -0
  76. package/dist/vendor/crypto-js/core.js +508 -0
  77. package/dist/vendor/crypto-js/enc-base64.js +80 -0
  78. package/dist/vendor/crypto-js/enc-base64url.js +87 -0
  79. package/dist/vendor/crypto-js/enc-utf16.js +99 -0
  80. package/dist/vendor/crypto-js/evpkdf.js +70 -0
  81. package/dist/vendor/crypto-js/format-hex.js +53 -0
  82. package/dist/vendor/crypto-js/hmac.js +83 -0
  83. package/dist/vendor/crypto-js/index.js +49 -0
  84. package/dist/vendor/crypto-js/lib-typedarrays.js +27 -0
  85. package/dist/vendor/crypto-js/md5.js +71 -0
  86. package/dist/vendor/crypto-js/mode-cfb.js +36 -0
  87. package/dist/vendor/crypto-js/mode-ctr-gladman.js +45 -0
  88. package/dist/vendor/crypto-js/mode-ctr.js +28 -0
  89. package/dist/vendor/crypto-js/mode-ecb.js +27 -0
  90. package/dist/vendor/crypto-js/mode-ofb.js +26 -0
  91. package/dist/vendor/crypto-js/pad-ansix923.js +25 -0
  92. package/dist/vendor/crypto-js/pad-iso10126.js +25 -0
  93. package/dist/vendor/crypto-js/pad-iso97971.js +23 -0
  94. package/dist/vendor/crypto-js/pad-nopadding.js +21 -0
  95. package/dist/vendor/crypto-js/pad-zeropadding.js +28 -0
  96. package/dist/vendor/crypto-js/pbkdf2.js +74 -0
  97. package/dist/vendor/crypto-js/rabbit-legacy.js +73 -0
  98. package/dist/vendor/crypto-js/rabbit.js +75 -0
  99. package/dist/vendor/crypto-js/rc4.js +63 -0
  100. package/dist/vendor/crypto-js/ripemd160.js +398 -0
  101. package/dist/vendor/crypto-js/sha1.js +49 -0
  102. package/dist/vendor/crypto-js/sha224.js +36 -0
  103. package/dist/vendor/crypto-js/sha256.js +57 -0
  104. package/dist/vendor/crypto-js/sha3.js +116 -0
  105. package/dist/vendor/crypto-js/sha384.js +37 -0
  106. package/dist/vendor/crypto-js/sha512.js +147 -0
  107. package/dist/vendor/crypto-js/tripledes.js +729 -0
  108. package/dist/vendor/crypto-js/x64-core.js +235 -0
  109. package/dist/vendor/debug/src/browser.js +146 -0
  110. package/dist/vendor/debug/src/common.js +97 -0
  111. package/dist/vendor/events/events.js +216 -0
  112. package/dist/vendor/gm-crypt/index.js +10 -0
  113. package/dist/vendor/gm-crypt/src/crypt.js +60 -0
  114. package/dist/vendor/gm-crypt/src/sm4.js +513 -0
  115. package/dist/vendor/jsbn/index.js +714 -0
  116. package/dist/vendor/jssip/lib/Constants.js +180 -0
  117. package/dist/vendor/jssip/lib-es5/Config.js +263 -0
  118. package/dist/vendor/jssip/lib-es5/Constants.js +180 -0
  119. package/dist/vendor/jssip/lib-es5/Dialog/RequestSender.js +84 -0
  120. package/dist/vendor/jssip/lib-es5/Dialog.js +179 -0
  121. package/dist/vendor/jssip/lib-es5/DigestAuthentication.js +93 -0
  122. package/dist/vendor/jssip/lib-es5/Exceptions.js +131 -0
  123. package/dist/vendor/jssip/lib-es5/Grammar.js +1937 -0
  124. package/dist/vendor/jssip/lib-es5/JsSIP.js +37 -0
  125. package/dist/vendor/jssip/lib-es5/Logger.js +44 -0
  126. package/dist/vendor/jssip/lib-es5/Message.js +229 -0
  127. package/dist/vendor/jssip/lib-es5/NameAddrHeader.js +107 -0
  128. package/dist/vendor/jssip/lib-es5/Options.js +227 -0
  129. package/dist/vendor/jssip/lib-es5/Parser.js +202 -0
  130. package/dist/vendor/jssip/lib-es5/RTCSession/DTMF.js +175 -0
  131. package/dist/vendor/jssip/lib-es5/RTCSession/Info.js +149 -0
  132. package/dist/vendor/jssip/lib-es5/RTCSession/ReferNotifier.js +52 -0
  133. package/dist/vendor/jssip/lib-es5/RTCSession/ReferSubscriber.js +187 -0
  134. package/dist/vendor/jssip/lib-es5/RTCSession.js +1799 -0
  135. package/dist/vendor/jssip/lib-es5/Registrator.js +194 -0
  136. package/dist/vendor/jssip/lib-es5/RequestSender.js +99 -0
  137. package/dist/vendor/jssip/lib-es5/SIPMessage.js +623 -0
  138. package/dist/vendor/jssip/lib-es5/Socket.js +38 -0
  139. package/dist/vendor/jssip/lib-es5/Timers.js +25 -0
  140. package/dist/vendor/jssip/lib-es5/Transactions.js +481 -0
  141. package/dist/vendor/jssip/lib-es5/Transport.js +220 -0
  142. package/dist/vendor/jssip/lib-es5/UA.js +663 -0
  143. package/dist/vendor/jssip/lib-es5/URI.js +221 -0
  144. package/dist/vendor/jssip/lib-es5/Utils.js +263 -0
  145. package/dist/vendor/jssip/lib-es5/WebSocketInterface.js +120 -0
  146. package/dist/vendor/jssip/lib-es5/sanityCheck.js +170 -0
  147. package/dist/vendor/jssip/package.json.js +9 -0
  148. package/dist/vendor/ms/index.js +85 -0
  149. package/dist/vendor/sdp-transform/lib/grammar.js +449 -0
  150. package/dist/vendor/sdp-transform/lib/index.js +14 -0
  151. package/dist/vendor/sdp-transform/lib/parser.js +70 -0
  152. package/dist/vendor/sdp-transform/lib/writer.js +74 -0
  153. package/dist/vendor/sm-crypto/src/index.js +14 -0
  154. package/dist/vendor/sm-crypto/src/sm2/asn1.js +86 -0
  155. package/dist/vendor/sm-crypto/src/sm2/ec.js +205 -0
  156. package/dist/vendor/sm-crypto/src/sm2/index.js +114 -0
  157. package/dist/vendor/sm-crypto/src/sm2/sm3.js +71 -0
  158. package/dist/vendor/sm-crypto/src/sm2/utils.js +95 -0
  159. package/dist/vendor/sm-crypto/src/sm3/index.js +50 -0
  160. package/dist/vendor/sm-crypto/src/sm4/index.js +408 -0
  161. package/dist/vite-plugins/index.d.ts +1 -1
  162. package/dist/vite-plugins/index.js +6 -0
  163. package/package.json +6 -5
  164. package/dist/index.es.js +0 -18159
  165. package/dist/vite-plugins/index.es.js +0 -33
@@ -0,0 +1,249 @@
1
+ import { J as h } from "../../commonjs-virtual-dir/JsSIP.js";
2
+ import { C as l } from "../../commonjs-virtual-dir/Constants.js";
3
+ import { ECallStatus as r, EMIT_EVENT_NAME as S } from "./constants.js";
4
+ import { CallLogger as s, getIceServersByCallConfig as p, formatSdp as f } from "./utils.js";
5
+ import { EventBus as m } from "../utils/eventBus.js";
6
+ class g {
7
+ ua = null;
8
+ session = null;
9
+ eventBus;
10
+ callStatus = r.INITIAL;
11
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
12
+ stopPlayTipAudio = () => {
13
+ };
14
+ // 有可能会出现 音频还未加载成功,但是会话已经结束的情况
15
+ isStop = !1;
16
+ constructor(o, t) {
17
+ this.eventBus = new m(), this.playTipAudio(t.tipAudioUrl), this.initUa(o, t);
18
+ }
19
+ /**
20
+ * 监听状态更新
21
+ * @param callback
22
+ */
23
+ onStatusUpdate(o) {
24
+ this.eventBus.$on(S.UPDATE_STATUS, o, !0);
25
+ }
26
+ /**
27
+ * 更新状态,触发状态更新
28
+ * @param status
29
+ * @param cause
30
+ * @param statusCode
31
+ */
32
+ updateStatus(o, t, e) {
33
+ this.callStatus = o, this.eventBus.$emit(S.UPDATE_STATUS, o, t, e);
34
+ }
35
+ /**
36
+ * 初始化sip和websocket的链接
37
+ * @param options
38
+ * @param config
39
+ * @private
40
+ */
41
+ initUa(o, t) {
42
+ try {
43
+ s.log("wssUrl", t.wssUrl), s.log("当前作席", t.extension);
44
+ const e = new h.WebSocketInterface(t.wssUrl);
45
+ this.ua = new h.UA({
46
+ sockets: [e],
47
+ uri: `sip:${t.extension}@${t.sipIp}`,
48
+ password: t.password,
49
+ realm: t.realm || t.sipIp,
50
+ register_expires: 300,
51
+ session_timers_expires: 120,
52
+ pcConfig: {
53
+ iceServers: p(t)
54
+ },
55
+ extra_headers: [`X-Call-ID: ${t.callId}`]
56
+ }), this.ua.on("registered", () => {
57
+ s.log("SIP 注册成功"), this.initSession(o, t);
58
+ }), this.ua.on("connected", () => {
59
+ s.log("WebSocket已连接");
60
+ }), this.ua.on("disconnected", () => {
61
+ s.warn("WebSocket已断开"), r.PENDING === this.callStatus && this.updateStatus(r.RECONNECT, l.causes.CONNECTION_ERROR);
62
+ }), this.ua.on("registrationFailed", (u) => {
63
+ this.updateStatus(r.FAILED, u.cause, u.response.status_code), s.error(`SIP 注册失败 cause: ${u?.cause} status_code: ${u?.response?.status_code}`), this.stop();
64
+ }), this.ua.start(), this.updateStatus(r.PENDING);
65
+ } catch (e) {
66
+ s.error("SIP 初始化失败", e?.message), this.stop(), this.updateStatus(r.FAILED, l.causes.SIP_FAILURE_CODE);
67
+ }
68
+ }
69
+ /**
70
+ * 用于优化通话,倒计时80s,如果超过80s还未接通,则挂断;并提示无法接听
71
+ */
72
+ optimizationCall() {
73
+ const o = Date.now();
74
+ s.log("开始接听倒计时:", o);
75
+ const t = 80 * 1e3 + o, e = () => {
76
+ requestAnimationFrame(() => {
77
+ r.PENDING === this.callStatus && (Date.now() > t ? (s.error("接听超时", Date.now()), this.updateStatus(r.FAILED, l.causes.NO_ANSWER), this.stop()) : e());
78
+ });
79
+ };
80
+ e();
81
+ }
82
+ /**
83
+ * 音频检测,存在有早期媒体但是并无声音的情况,所以增加音频分析检测;
84
+ */
85
+ audioCheck(o) {
86
+ try {
87
+ const t = new (Reflect.get(window, "AudioContext") || Reflect.get(window, "webkitAudioContext"))(), e = t.createAnalyser(), u = t.createMediaStreamSource(o.streams[0]);
88
+ u.connect(e), e.fftSize = 256;
89
+ const a = e.frequencyBinCount, i = new Uint8Array(a), n = () => {
90
+ e.getByteTimeDomainData(i), i.some((d) => Math.abs(d - 128) > 2) && (s.log("【音频分析】检测到有效声音"), u.disconnect(), this.stopPlayTipAudio()), requestAnimationFrame(n);
91
+ };
92
+ n();
93
+ } catch (t) {
94
+ s.error("音频分析模块初始化失败", t?.message);
95
+ }
96
+ }
97
+ /**
98
+ * 获取会话配置
99
+ * @param options
100
+ * @param config
101
+ * @private
102
+ */
103
+ getSessionEventHandlers(o, t) {
104
+ let e = !1;
105
+ const u = o.call.split("").slice(-4).join("");
106
+ return s.log("开始呼叫(尾号):", `sip:${u}@${t.sipIp}`), {
107
+ sdp: (a) => {
108
+ a.sdp = f(a.sdp);
109
+ },
110
+ connecting: () => {
111
+ r.PENDING !== this.callStatus && this.updateStatus(r.PENDING), s.log("正在连接...");
112
+ },
113
+ progress: (a) => {
114
+ if (s.log("呼叫进行中..."), this.optimizationCall(), a.response) {
115
+ const i = a.response.status_code, n = a.response.body;
116
+ i === 183 && n ? (s.log("收到 183 (带SDP),确认有早期媒体,停止本地提示音。"), this.stopPlayTipAudio()) : (i === 180 || i === 183 && !n) && s.log(`收到 ${i} (无SDP),继续播放本地提示音。`);
117
+ }
118
+ },
119
+ ended: (a) => {
120
+ if (r.FAILED !== this.callStatus) {
121
+ const i = e ? a?.cause : l.causes.REJECTED;
122
+ this.updateStatus(r.ENDED, i), s.log("通话已结束 cause: ", i);
123
+ }
124
+ this.stop();
125
+ },
126
+ failed: (a) => {
127
+ const { cause: i, message: n = {} } = a, c = i === "Canceled";
128
+ this.updateStatus(
129
+ c ? r.CANCELLED : r.FAILED,
130
+ i,
131
+ n?.status_code
132
+ ), c ? s.warn(
133
+ `通话已取消 cause: ${i} status_code: ${n?.status_code || ""}`
134
+ ) : s.error(
135
+ `通话失败 cause: ${i} status_code: ${n?.status_code || ""}`
136
+ ), this.stop();
137
+ },
138
+ accepted: () => {
139
+ this.stopPlayTipAudio(), s.log("通话已接听");
140
+ },
141
+ confirmed: () => {
142
+ this.updateStatus(r.ANSWERED), s.log("通话已确认");
143
+ const a = setTimeout(() => {
144
+ e = !0, clearTimeout(a);
145
+ }, 1500);
146
+ },
147
+ peerconnection: (a) => {
148
+ const i = a.peerconnection;
149
+ s.log("RTCPeerConnection 已创建或更新,正在设置 ontrack 监听器"), i.ontrack = (n) => {
150
+ if (n.track.kind === "audio" && n.streams[0]) {
151
+ s.log(n.track, "track"), s.log(`接收到远程媒体轨道 (track): ${n.track.kind}`);
152
+ const c = n.streams[0];
153
+ this.stopPlayTipAudio();
154
+ const d = document.getElementById(t.playAudioId);
155
+ d ? (d.srcObject = c, d.play().catch((E) => {
156
+ s.error("播放远程音频失败 (来自 ontrack)", E);
157
+ })) : s.error("无法播放远程音频,播放元素不存在", `${t.playAudioId}`), this.audioCheck(n);
158
+ }
159
+ }, i.addEventListener("iceconnectionstatechange", () => {
160
+ s.log(`ICE状态: ${i.iceConnectionState}`), i.iceConnectionState === "disconnected" && (s.error("ICE连接断开"), this.updateStatus(r.FAILED, l.causes.CONNECTION_ERROR), this.stop());
161
+ });
162
+ }
163
+ };
164
+ }
165
+ /**
166
+ * 初始化rtc会话
167
+ * @private
168
+ */
169
+ initSession(o, t) {
170
+ if (!this.ua) {
171
+ this.updateStatus(r.FAILED, l.causes.SIP_FAILURE_CODE), s.error("SIP 未初始化");
172
+ return;
173
+ }
174
+ try {
175
+ const u = {
176
+ eventHandlers: this.getSessionEventHandlers(o, t),
177
+ mediaConstraints: { audio: !0, video: !1 },
178
+ rtcOfferConstraints: {
179
+ offerToReceiveAudio: !0,
180
+ offerToReceiveVideo: !1
181
+ },
182
+ rtcConfiguration: {
183
+ iceServers: p(t)
184
+ },
185
+ sessionTimersExpires: 180
186
+ };
187
+ t.isDev || (u.pcConfig = {
188
+ iceServers: p(t)
189
+ }), this.session = this.ua.call(`sip:${o.call}@${t.sipIp}`, u);
190
+ } catch (e) {
191
+ s.error("SIP 会话创建失败", e?.message), this.stop();
192
+ }
193
+ }
194
+ /**
195
+ * 播放提示音
196
+ * @private
197
+ */
198
+ async playTipAudio(o) {
199
+ let t, e;
200
+ try {
201
+ s.log("开始播放提示音");
202
+ const i = await (await fetch(o || `https://store.zxfqf.com/file/uMgvB0wt9f.mp3?t=${Date.now()}`)).arrayBuffer();
203
+ t = new (window.AudioContext || Reflect.get(window, "webkitAudioContext"))(), await t.suspend();
204
+ const n = await t.decodeAudioData(i);
205
+ e = t.createBufferSource(), e.buffer = n, e.connect(t.destination), e.loop = !0, e.loopStart = 0, e.loopEnd = n.duration;
206
+ const c = t.currentTime;
207
+ s.log("音频播放开始时间:", c), await t.resume(), e.start(c);
208
+ } catch (a) {
209
+ s.error("播放音频失败", a?.message);
210
+ }
211
+ let u = !1;
212
+ this.stopPlayTipAudio = () => {
213
+ u || (s.log("停止播放提示音"), u = !0, e.stop(), e.disconnect(), t.close().finally(() => {
214
+ e = null, t = null, this.stopPlayTipAudio = () => {
215
+ };
216
+ }));
217
+ }, this.onStatusUpdate((a) => {
218
+ r.ANSWERED === a && this.stopPlayTipAudio();
219
+ }), this.isStop && this.stopPlayTipAudio();
220
+ }
221
+ /**
222
+ * 停止ws的连接,并且如果会话正在进行中,挂断电话。
223
+ * @private
224
+ */
225
+ stop() {
226
+ try {
227
+ this.ua?.stop?.(), !this.session?.isEnded?.() && this.session?.terminate();
228
+ } catch (o) {
229
+ s.error("挂断失败", o?.message);
230
+ } finally {
231
+ this.isStop = !0, this.stopPlayTipAudio();
232
+ }
233
+ }
234
+ /**
235
+ * 销毁对应的实例
236
+ */
237
+ destroy() {
238
+ this.ua = null, this.session = null, this.eventBus.$off(), this.stopPlayTipAudio();
239
+ }
240
+ /**
241
+ * 挂断电话
242
+ */
243
+ hangUp() {
244
+ r.ANSWERED === this.callStatus ? (this.updateStatus(r.ENDED), s.warn("客服正常挂断结束通话")) : (this.updateStatus(r.CANCELLED), s.warn("客服取消通话")), this.stop(), this.destroy();
245
+ }
246
+ }
247
+ export {
248
+ g as CallManagement
249
+ };
@@ -0,0 +1,42 @@
1
+ import { C as E } from "../../commonjs-virtual-dir/Constants.js";
2
+ var e = /* @__PURE__ */ ((s) => (s.PENDING = "pending", s.ANSWERED = "answered", s.FAILED = "failed", s.ENDED = "ended", s.INITIAL = "initial", s.CANCELLED = "cancelled", s.RECONNECT = "reconnect", s))(e || {});
3
+ const I = {
4
+ UPDATE_STATUS: "update:status"
5
+ }, N = {
6
+ [E.causes.AUTHENTICATION_ERROR]: "认证失败。",
7
+ [E.causes.CONNECTION_ERROR]: "网络连接异常,请检查网络或重试。",
8
+ [E.causes.REQUEST_TIMEOUT]: "请求超时,未收到服务器响应,请稍后重试。",
9
+ [E.causes.SIP_FAILURE_CODE]: "呼叫失败,请稍后重试。",
10
+ [E.causes.WEBRTC_ERROR]: "媒体系统错误,请检查麦克风权限或重试。",
11
+ [E.causes.BUSY]: "对方忙线,请稍后重拨。",
12
+ [E.causes.REJECTED]: "对方拒绝接听,请确认号码或稍后再试。",
13
+ [E.causes.REDIRECTED]: "线路已转接,请稍后重试或联系对方。",
14
+ [E.causes.UNAVAILABLE]: "对方暂时无法接听,请稍后再试。",
15
+ [E.causes.NOT_FOUND]: "号码不存在或无法呼达,请检查号码是否正确或稍后再试。",
16
+ [E.causes.INCOMPATIBLE_SDP]: "媒体协商失败,请检查网络或重拨。",
17
+ [E.causes.MISSING_SDP]: "未检测到媒体信息,无法建立呼叫。",
18
+ [E.causes.CANCELED]: "已取消呼叫。",
19
+ [E.causes.NO_ANSWER]: "用户暂未接听,请稍后重试",
20
+ [E.causes.EXPIRES]: "呼叫超时,请稍后重试。",
21
+ [E.causes.USER_DENIED_MEDIA_ACCESS]: "请允许访问麦克风以保证通话功能。",
22
+ [E.causes.RTP_TIMEOUT]: "网络不稳定,未检测到媒体流,请重试。"
23
+ }, R = {
24
+ /**
25
+ * 黑名单或者不存在
26
+ */
27
+ 404: "手机号状态异常,暂时无法呼叫",
28
+ /**
29
+ * 拒接
30
+ */
31
+ 500: "用户暂未接听,请稍后重试",
32
+ /**
33
+ * 拒接
34
+ */
35
+ 607: "用户暂未接听,请稍后重试"
36
+ };
37
+ export {
38
+ e as ECallStatus,
39
+ I as EMIT_EVENT_NAME,
40
+ R as SIP_CODE_MESSAGE,
41
+ N as SIP_ERROR_CAUSES
42
+ };
@@ -0,0 +1,74 @@
1
+ import { CallManagement as p } from "./CallManagement.js";
2
+ import { ECallStatus as t, SIP_CODE_MESSAGE as I, SIP_ERROR_CAUSES as R } from "./constants.js";
3
+ import { EMIT_EVENT_NAME as _ } from "./constants.js";
4
+ import { CallLogger as S, formatSeconds as T } from "./utils.js";
5
+ import { ref as u, watchEffect as w, watch as M } from "vue";
6
+ const y = (f) => {
7
+ const e = u(t.INITIAL), m = u(0), N = u(""), n = u(""), v = u("");
8
+ let a = null;
9
+ const g = (l, s) => {
10
+ try {
11
+ a?.destroy(), S.log("================================ 开始初始化 ====================================="), a = new p(l, s), N.value = s.extension, a.onStatusUpdate((r, E, c) => {
12
+ e.value = r, n.value = E || "", v.value = c ? String(c) : "", t.ANSWERED === r && (m.value = Date.now());
13
+ });
14
+ } catch (r) {
15
+ e.value = t.FAILED, S.error("callManagement 初始化失败:", r, l, s);
16
+ }
17
+ }, D = () => {
18
+ a && a.hangUp(), a = null;
19
+ }, A = () => {
20
+ a && a.destroy(), a = null;
21
+ }, o = u(""), C = (l, s, r = 1) => {
22
+ let E = null;
23
+ const c = (i) => {
24
+ if (s !== e.value || !a) {
25
+ E && clearTimeout(E);
26
+ return;
27
+ }
28
+ o.value = `${l}${".".repeat(i)}`, E = setTimeout(() => {
29
+ c(i < 3 ? i + 1 : 1);
30
+ }, 500);
31
+ };
32
+ c(r);
33
+ };
34
+ return w(() => {
35
+ if (t.PENDING === e.value)
36
+ C("呼叫中", t.PENDING);
37
+ else if (t.ANSWERED === e.value) {
38
+ const l = () => {
39
+ if (t.ANSWERED !== e.value || !a)
40
+ return;
41
+ const r = Date.now() - m.value || 0;
42
+ r > 0 ? o.value = T(r) : o.value = "00:00", requestAnimationFrame(l);
43
+ };
44
+ l();
45
+ } else t.CANCELLED === e.value ? o.value = "已取消" : t.FAILED === e.value ? o.value = "呼叫失败" : t.ENDED === e.value ? o.value = "通话结束" : t.RECONNECT === e.value ? C("重新连接中", t.RECONNECT) : o.value = "";
46
+ }), M(
47
+ () => [e.value, o.value],
48
+ ([l, s]) => {
49
+ f && f(l, s, n.value);
50
+ }
51
+ ), {
52
+ call: g,
53
+ hangUp: D,
54
+ callStatus: e,
55
+ callCauseCode: n,
56
+ statusCode: v,
57
+ callStatusText: o,
58
+ destroy: A,
59
+ extension: N,
60
+ getErrorMessage: () => {
61
+ console.log(v.value, n.value, "show error message");
62
+ const l = Reflect.get(I, v.value);
63
+ return l || Reflect.get(R, n.value);
64
+ }
65
+ };
66
+ };
67
+ export {
68
+ S as CallLogger,
69
+ t as ECallStatus,
70
+ _ as EMIT_EVENT_NAME,
71
+ I as SIP_CODE_MESSAGE,
72
+ R as SIP_ERROR_CAUSES,
73
+ y as useCall
74
+ };
@@ -0,0 +1,50 @@
1
+ import a from "../../commonjs-virtual-dir/index4.js";
2
+ const u = {
3
+ log(e, ...r) {
4
+ console.log(`%c【${(/* @__PURE__ */ new Date()).toLocaleString()}】`, "color: green; font-weight: bold;", e, ...r);
5
+ },
6
+ warn(e, ...r) {
7
+ console.log(`%c【${(/* @__PURE__ */ new Date()).toLocaleString()}】`, "color: orange; font-weight: bold;", e, ...r);
8
+ },
9
+ error(e, ...r) {
10
+ console.log(`%c【${(/* @__PURE__ */ new Date()).toLocaleString()}】`, "color: red; font-weight: bold;", e, ...r);
11
+ }
12
+ }, S = (e) => {
13
+ const r = a.parse(e);
14
+ return r.media = r.media.map((t) => {
15
+ if (t.type === "audio") {
16
+ const n = t.payloads;
17
+ if (n?.includes("8")) {
18
+ const o = n.split(" "), s = o.findIndex((c) => c === "8");
19
+ o.splice(s, 1), o.unshift("8"), t.payloads = o.join(" ");
20
+ const i = t.rtp, l = i.find((c) => c.codec === "PCMA"), d = i.findIndex((c) => c.codec === "PCMA");
21
+ i.splice(d, 1), l && i.unshift(l);
22
+ }
23
+ }
24
+ return t;
25
+ }), a.write(r);
26
+ }, f = (e) => {
27
+ if (typeof e != "number" || Number.isNaN(e))
28
+ throw new TypeError("输入必须是数字类型");
29
+ if (e < 0 || !Number.isInteger(e))
30
+ throw new RangeError("请输入非负整数");
31
+ const r = e / 1e3, t = Math.floor(r / 60), n = Math.floor(r % 60), o = String(t).padStart(2, "0"), s = String(n).padStart(2, "0");
32
+ return `${o}:${s}`;
33
+ }, g = (e) => {
34
+ const r = [
35
+ {
36
+ urls: [e.iceService.stunServerUrl]
37
+ }
38
+ ];
39
+ if (e.iceService.turnServer) {
40
+ const { urls: t, username: n, credential: o } = e.iceService.turnServer;
41
+ t && n && o && r.push(e.iceService.turnServer);
42
+ }
43
+ return r;
44
+ };
45
+ export {
46
+ u as CallLogger,
47
+ S as formatSdp,
48
+ f as formatSeconds,
49
+ g as getIceServersByCallConfig
50
+ };
@@ -0,0 +1,28 @@
1
+ import e from "../../commonjs-virtual-dir/index3.js";
2
+ import { g as o } from "../../commonjs-virtual-dir/index.js";
3
+ const s = (r, t, n) => e.AES.encrypt(t, e.enc.Utf8.parse(r), {
4
+ iv: e.enc.Utf8.parse(n),
5
+ mode: e.mode.CBC,
6
+ padding: e.pad.Pkcs7
7
+ }).toString(), i = (r, t, n) => e.AES.decrypt(t, e.enc.Utf8.parse(r), {
8
+ iv: e.enc.Utf8.parse(n),
9
+ mode: e.mode.CBC,
10
+ padding: e.pad.Pkcs7
11
+ }).toString(e.enc.Utf8), y = (r) => {
12
+ const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
13
+ let n = "";
14
+ for (let c = 0; c < r; c++)
15
+ n += t.charAt(Math.floor(Math.random() * t.length));
16
+ return n;
17
+ }, m = (r, t) => new o.sm4({
18
+ key: t.key,
19
+ iv: t.iv,
20
+ mode: t.mode || "cbc"
21
+ }).decrypt(r), a = (r, t) => new o.sm4({ key: t.key, iv: t.iv, mode: t.mode || "cbc" }).encrypt(r);
22
+ export {
23
+ i as aesDecryptString,
24
+ s as aesEncryptString,
25
+ y as generateRandomString,
26
+ m as sm4Decrypt,
27
+ a as sm4Encrypt
28
+ };
@@ -0,0 +1,59 @@
1
+ import { g as l } from "../../commonjs-virtual-dir/index.js";
2
+ import { s as S } from "../../commonjs-virtual-dir/index2.js";
3
+ import { aesEncryptString as b, generateRandomString as h } from "./crypto.js";
4
+ function g(t) {
5
+ return typeof t == "object" ? JSON.stringify(t ?? {}) : typeof t == "number" ? String(t) : t ?? "";
6
+ }
7
+ function T({ uid: t = "", salt: o = "", ts: r = 0, data: e = "", ...s }) {
8
+ const c = Date.now() + r, a = Math.random().toString(36).substring(2, 15), u = `${c}${t}${a}${g(e)}${o}`, n = S.sm3(u);
9
+ return {
10
+ ...s,
11
+ "X-Sign-Timestamp": String(c),
12
+ "X-Sign-Nonce": a,
13
+ "X-Sign-Client": n
14
+ };
15
+ }
16
+ function v(t, o, r) {
17
+ const e = h(16);
18
+ let s = {
19
+ body: ""
20
+ };
21
+ return r === "ase" && (s = {
22
+ body: b(t, g(o), e)
23
+ }), r === "sm4" && (s = {
24
+ body: new l.sm4({
25
+ key: t,
26
+ iv: e,
27
+ mode: "cbc"
28
+ }).encrypt(g(o))
29
+ }), {
30
+ headers: {
31
+ iv: e,
32
+ "Content-Type": "application/json"
33
+ },
34
+ data: s
35
+ };
36
+ }
37
+ function w(t) {
38
+ const o = ["script", "iframe", "object", "embed", "link", "meta", "style"], r = ["onerror", "onload", "onclick", "onmouseover", "onfocus", "onmouseenter", "onmouseleave"], e = (n) => /^javascript:/i.test(n) || /^data:text\/html/i.test(n), c = new DOMParser().parseFromString(`<div>${t}</div>`, "text/html"), a = c.body.firstChild;
39
+ function u(n) {
40
+ if (n.nodeType === Node.ELEMENT_NODE) {
41
+ const i = n, p = i.tagName.toLowerCase();
42
+ if (o.includes(p)) {
43
+ const m = i.outerHTML, d = c.createTextNode(m);
44
+ i.replaceWith(d);
45
+ return;
46
+ }
47
+ [...i.attributes].forEach((m) => {
48
+ const d = m.name.toLowerCase(), f = m.value;
49
+ (r.includes(d) || e(f)) && i.removeAttribute(m.name);
50
+ }), [...i.childNodes].forEach(u);
51
+ }
52
+ }
53
+ return [...a.childNodes].forEach(u), a.innerHTML;
54
+ }
55
+ export {
56
+ T as createHeaders,
57
+ w as htmlSanitize,
58
+ v as transmissionDataEncryption
59
+ };
@@ -0,0 +1,26 @@
1
+ const t = () => {
2
+ throw window.stop(), window.location.href = "about:blank", new Error("禁止debugger");
3
+ }, n = () => {
4
+ document.addEventListener(
5
+ "keydown",
6
+ (e) => {
7
+ if (e.key === "F12" || e.keyCode === 123) {
8
+ e.preventDefault();
9
+ return;
10
+ }
11
+ if (e.ctrlKey && e.shiftKey && /[ICJ]/i.test(e.key)) {
12
+ e.preventDefault();
13
+ return;
14
+ }
15
+ e.ctrlKey && e.key.toLowerCase() === "u" && e.preventDefault();
16
+ },
17
+ { passive: !1 }
18
+ ), setInterval(() => {
19
+ const e = performance.now();
20
+ (function() {
21
+ }).constructor("debugger")(), performance.now() - e > 200 && t();
22
+ }, 500);
23
+ };
24
+ export {
25
+ n as startNoDebugger
26
+ };
@@ -0,0 +1,59 @@
1
+ class o {
2
+ _eventList = [];
3
+ // 重写toString方法
4
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
5
+ _toString = (t) => Object.toString.call(t);
6
+ /**
7
+ * 监听
8
+ * @param {string} eventName 需要监听的名字
9
+ * @param {Function} callback 监听触发的回调
10
+ * @param immediate 是否立即执行
11
+ * */
12
+ $on(t, s, i = !1) {
13
+ const e = this._findEvent(t);
14
+ e ? e?.callbacks?.find(
15
+ (n) => this._toString(n) === this._toString(s)
16
+ ) || (e.callbacks.push(s), i && s(...e.params)) : this._addEvent(t, "", [s]);
17
+ }
18
+ /**
19
+ * 分发事件
20
+ * @param {string} eventName 需要分发的监听的名字
21
+ * @param { any } args 传递的参数
22
+ * */
23
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
24
+ $emit(t, ...s) {
25
+ const i = this._findEvent(t);
26
+ return i ? (i.params = s, Promise.all(i.callbacks?.map((e) => e(...i.params)))) : (this._addEvent(t, s), Promise.resolve());
27
+ }
28
+ /**
29
+ * 取消监听
30
+ * @param {string | Array<string>} eventName 需要取消的监听名称
31
+ * */
32
+ $off(t) {
33
+ if (typeof t == "string") {
34
+ const s = this._eventList.findIndex((i) => i.eventName === t);
35
+ s > -1 && this._eventList.splice(s, 1);
36
+ } else t instanceof Array ? t.map((s) => this.$off(s)) : this._eventList = [];
37
+ }
38
+ /**
39
+ * 执行一次的监听之后立即销毁
40
+ * @param {string} eventName 需要监听的名字
41
+ * @param {Function} callback 监听触发的回调
42
+ * */
43
+ $once(t, s) {
44
+ this.$emit(t, s, !0), this.$off(t);
45
+ }
46
+ _findEvent(t) {
47
+ return this._eventList.find((s) => s.eventName === t);
48
+ }
49
+ _addEvent(t, s, i) {
50
+ this._eventList.push({
51
+ eventName: t,
52
+ params: s ?? "",
53
+ callbacks: i ?? []
54
+ });
55
+ }
56
+ }
57
+ export {
58
+ o as EventBus
59
+ };
@@ -0,0 +1,13 @@
1
+ import p from "@vitejs/plugin-legacy";
2
+ import { vitePluginCompatibilityDetection as c } from "./vitePluginCompatibilityDetection.js";
3
+ const g = (i) => {
4
+ const e = {
5
+ start: !0,
6
+ startDetection: !0,
7
+ ...i || {}
8
+ }, t = [], { start: o, startDetection: n, detectionConfig: r, ...s } = e;
9
+ return o && (t.push(p(s)), n && t.push(c(r))), t;
10
+ };
11
+ export {
12
+ g as getCompatibilityPlugins
13
+ };
@@ -0,0 +1,28 @@
1
+ import p from "../../commonjs-virtual-dir/_virtual_mobile-compatibility-detection.js";
2
+ import n from "../../commonjs-virtual-dir/_virtual_pc-compatibility-detection.js";
3
+ const a = (e) => {
4
+ const t = e || { platform: "pc" };
5
+ t.platform === "mobile" && (t.attrs || (t.attrs = {}), t.attrs.type = "module");
6
+ const { platform: i, ...o } = t;
7
+ return {
8
+ name: "vite-plugin-compatibility-detection",
9
+ enforce: "post",
10
+ transformIndexHtml(r) {
11
+ return {
12
+ html: r,
13
+ tags: [
14
+ {
15
+ tag: "script",
16
+ children: i === "mobile" ? p : n,
17
+ // default head-prepend
18
+ injectTo: "head-prepend",
19
+ ...o || {}
20
+ }
21
+ ]
22
+ };
23
+ }
24
+ };
25
+ };
26
+ export {
27
+ a as vitePluginCompatibilityDetection
28
+ };
@@ -0,0 +1,52 @@
1
+ import { __exports as F } from "../../commonjs-virtual-dir/index8.js";
2
+ var A;
3
+ function _() {
4
+ if (A) return F;
5
+ A = 1, F.byteLength = y, F.toByteArray = C, F.fromByteArray = B;
6
+ for (var c = [], n = [], l = typeof Uint8Array < "u" ? Uint8Array : Array, d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", s = 0, p = d.length; s < p; ++s)
7
+ c[s] = d[s], n[d.charCodeAt(s)] = s;
8
+ n[45] = 62, n[95] = 63;
9
+ function x(r) {
10
+ var e = r.length;
11
+ if (e % 4 > 0)
12
+ throw new Error("Invalid string. Length must be a multiple of 4");
13
+ var a = r.indexOf("=");
14
+ a === -1 && (a = e);
15
+ var o = a === e ? 0 : 4 - a % 4;
16
+ return [a, o];
17
+ }
18
+ function y(r) {
19
+ var e = x(r), a = e[0], o = e[1];
20
+ return (a + o) * 3 / 4 - o;
21
+ }
22
+ function i(r, e, a) {
23
+ return (e + a) * 3 / 4 - a;
24
+ }
25
+ function C(r) {
26
+ var e, a = x(r), o = a[0], v = a[1], t = new l(i(r, o, v)), h = 0, u = v > 0 ? o - 4 : o, f;
27
+ for (f = 0; f < u; f += 4)
28
+ e = n[r.charCodeAt(f)] << 18 | n[r.charCodeAt(f + 1)] << 12 | n[r.charCodeAt(f + 2)] << 6 | n[r.charCodeAt(f + 3)], t[h++] = e >> 16 & 255, t[h++] = e >> 8 & 255, t[h++] = e & 255;
29
+ return v === 2 && (e = n[r.charCodeAt(f)] << 2 | n[r.charCodeAt(f + 1)] >> 4, t[h++] = e & 255), v === 1 && (e = n[r.charCodeAt(f)] << 10 | n[r.charCodeAt(f + 1)] << 4 | n[r.charCodeAt(f + 2)] >> 2, t[h++] = e >> 8 & 255, t[h++] = e & 255), t;
30
+ }
31
+ function L(r) {
32
+ return c[r >> 18 & 63] + c[r >> 12 & 63] + c[r >> 6 & 63] + c[r & 63];
33
+ }
34
+ function g(r, e, a) {
35
+ for (var o, v = [], t = e; t < a; t += 3)
36
+ o = (r[t] << 16 & 16711680) + (r[t + 1] << 8 & 65280) + (r[t + 2] & 255), v.push(L(o));
37
+ return v.join("");
38
+ }
39
+ function B(r) {
40
+ for (var e, a = r.length, o = a % 3, v = [], t = 16383, h = 0, u = a - o; h < u; h += t)
41
+ v.push(g(r, h, h + t > u ? u : h + t));
42
+ return o === 1 ? (e = r[a - 1], v.push(
43
+ c[e >> 2] + c[e << 4 & 63] + "=="
44
+ )) : o === 2 && (e = (r[a - 2] << 8) + r[a - 1], v.push(
45
+ c[e >> 10] + c[e >> 4 & 63] + c[e << 2 & 63] + "="
46
+ )), v.join("");
47
+ }
48
+ return F;
49
+ }
50
+ export {
51
+ _ as __require
52
+ };