@coclaw/openclaw-coclaw 0.11.2 → 0.11.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/package.json +1 -1
- package/src/webrtc/ndc-preloader.js +28 -1
package/package.json
CHANGED
|
@@ -60,6 +60,33 @@ export function defaultResolvePaths(platformKey, pluginRoot) {
|
|
|
60
60
|
return { src, dest, destDir };
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* ndc polyfill 的 RTCPeerConnection 将 iceServers 的 username:credential 直接拼入 URL,
|
|
65
|
+
* 但 TURN REST API 的 username 格式为 `timestamp:identity`(含冒号),
|
|
66
|
+
* 导致 libdatachannel 的 URL parser 截断 username。
|
|
67
|
+
* 此 wrapper 在传入 polyfill 前对 username/credential 做 percent-encoding 规避该问题。
|
|
68
|
+
*/
|
|
69
|
+
function wrapNdcCredentials(NativeRTC) {
|
|
70
|
+
return class extends NativeRTC {
|
|
71
|
+
constructor(config = {}) {
|
|
72
|
+
if (config?.iceServers) {
|
|
73
|
+
config = {
|
|
74
|
+
...config,
|
|
75
|
+
iceServers: config.iceServers.map(s => {
|
|
76
|
+
if (!s.username && !s.credential) return s;
|
|
77
|
+
return {
|
|
78
|
+
...s,
|
|
79
|
+
username: s.username ? encodeURIComponent(s.username) : s.username,
|
|
80
|
+
credential: s.credential ? encodeURIComponent(s.credential) : s.credential,
|
|
81
|
+
};
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
super(config);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
63
90
|
/**
|
|
64
91
|
* 预加载 WebRTC 实现:优先 node-datachannel,失败回退 werift,全部失败返回 null。
|
|
65
92
|
*
|
|
@@ -160,7 +187,7 @@ export async function preloadNdc(deps = {}) {
|
|
|
160
187
|
// 当前由 RealtimeBridge.stop() 负责调用。若 gateway 被 SIGKILL 强杀则无法执行,
|
|
161
188
|
// 但 OS 会回收所有资源。若 OpenClaw 提供了优雅终止钩子,应在钩子中也调用 cleanup。
|
|
162
189
|
log(`ndc.loaded platform=${platformKey}`);
|
|
163
|
-
return { PeerConnection: RTCPeerConnection, cleanup, impl: 'ndc' };
|
|
190
|
+
return { PeerConnection: wrapNdcCredentials(RTCPeerConnection), cleanup, impl: 'ndc' };
|
|
164
191
|
} catch (err) {
|
|
165
192
|
// resolvePaths 或其他未预期异常的兜底
|
|
166
193
|
log(`ndc.fallback reason=unexpected error=${err.message}`);
|