feat(controlled): 实现设备激活与安全认证流程

- 添加API客户端、加密存储和provision/token激活逻辑
- WebSocket改用Bearer令牌认证,移除REGISTER请求
- 设备ID改为服务端下发,支持令牌刷新和强制下线处理
- 新增deviceSecret加密存储和accessToken自动刷新
- 更新设备ID获取方式为出厂SN,添加安全存储依赖
This commit is contained in:
2026-08-01 15:13:12 +08:00
parent 376a2c1217
commit 6eb2c7321a
124 changed files with 10535 additions and 862 deletions

View File

@@ -10,8 +10,8 @@ import 'package:path_provider/path_provider.dart';
/// 无需自行触碰原生 VideoSink。
///
/// 录制文件保存位置:
/// - Android/Android/data/<包名>/files/WebRTCRecordings/app 专属外部存储,无需存储权限)
/// - iOS<App>/Documents/WebRTCRecordings/
/// - Android/Android/data/&lt;包名&gt;/files/WebRTCRecordings/app 专属外部存储,无需存储权限)
/// - iOS&lt;App&gt;/Documents/WebRTCRecordings/
class VideoRecorder {
MediaRecorder? _recorder;
bool _recording = false;

View File

@@ -88,6 +88,9 @@ class WebRtcController {
static const int streamModeWebRtc = 0;
static const int streamModeSelfCodec = 1;
/// 由服务端下发的 TURN 短期凭证覆盖默认 ICE 配置(为空则用 kIceServers
static List<Map<String, dynamic>>? iceServersOverride;
WebRtcController({
required this.signaling,
required this.deviceId,
@@ -100,8 +103,9 @@ class WebRtcController {
Future<void> initialize() async {
await renderer.initialize();
final iceServers = iceServersOverride ?? kIceServers;
final configuration = {
'iceServers': kIceServers,
'iceServers': iceServers,
'sdpSemantics': 'unified-plan',
'iceCandidatePoolSize': 10,
// 增强复杂网络下的稳定性,参考 Android 端配置。
@@ -110,7 +114,7 @@ class WebRtcController {
'tcpCandidatePolicy': 'enabled',
};
final iceUrls = (kIceServers)
final iceUrls = iceServers
.map((e) => '${e['username'] != null ? '(${e['username']})' : ''}${e['urls']}')
.join(', ');
debugPrint('[WebRtcController] signaling server: ${signaling.serverUrl} | '