feat(controlled): 实现设备激活与安全认证流程
- 添加API客户端、加密存储和provision/token激活逻辑 - WebSocket改用Bearer令牌认证,移除REGISTER请求 - 设备ID改为服务端下发,支持令牌刷新和强制下线处理 - 新增deviceSecret加密存储和accessToken自动刷新 - 更新设备ID获取方式为出厂SN,添加安全存储依赖
This commit is contained in:
@@ -56,6 +56,9 @@ final class WebRTCClient: NSObject {
|
||||
super.init()
|
||||
}
|
||||
|
||||
/// 由服务端下发的 TURN 短期凭证覆盖默认 ICE 配置(为空时用内置 STUN/TURN)。
|
||||
static var iceServersOverride: [[String: Any]]?
|
||||
|
||||
var isDataChannelOpen: Bool {
|
||||
controlChannel?.readyState == .open
|
||||
}
|
||||
@@ -71,13 +74,23 @@ final class WebRTCClient: NSObject {
|
||||
self.remoteRenderer = renderer
|
||||
|
||||
let config = RTCConfiguration()
|
||||
config.iceServers = [
|
||||
RTCIceServer(urlStrings: ["stun:stun.l.google.com:19302"]),
|
||||
RTCIceServer(urlStrings: ["stun:www.ttstd.com:3478"]),
|
||||
RTCIceServer(urlStrings: ["turn:www.ttstd.com:3478"],
|
||||
username: "ttstd",
|
||||
credential: "ttstd123")
|
||||
]
|
||||
if let override = WebRTCClient.iceServersOverride {
|
||||
// 服务端下发的 TURN 短期凭证(RFC 7635)。
|
||||
config.iceServers = override.compactMap { entry in
|
||||
guard let urls = entry["urls"] as? String else { return nil }
|
||||
return RTCIceServer(urlStrings: [urls],
|
||||
username: entry["username"] as? String,
|
||||
credential: entry["credential"] as? String)
|
||||
}
|
||||
} else {
|
||||
config.iceServers = [
|
||||
RTCIceServer(urlStrings: ["stun:stun.l.google.com:19302"]),
|
||||
RTCIceServer(urlStrings: ["stun:www.ttstd.com:3478"]),
|
||||
RTCIceServer(urlStrings: ["turn:www.ttstd.com:3478"],
|
||||
username: "ttstd",
|
||||
credential: "ttstd123")
|
||||
]
|
||||
}
|
||||
config.sdpSemantics = .unifiedPlan
|
||||
config.continualGatheringPolicy = .gatherContinually
|
||||
config.iceCandidatePoolSize = 10
|
||||
|
||||
Reference in New Issue
Block a user