25ed765a03
6 Wochen uncommittete Arbeit (Voice-Channels, LiveKit-Manager, Settings-Modal u.v.m.) als ein WIP-Commit gesichert, damit nichts verloren geht und der Pi den aktuellen Stand klonen kann. Thematische Aufarbeitung: siehe ROADMAP M0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CPrAGBxBT6GfPXzeWQ4AXb
38 lines
919 B
Dart
38 lines
919 B
Dart
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
|
|
|
class LiveKitTokenGenerator {
|
|
// Your LiveKit Credentials
|
|
static const String apiKey = 'LKMatrixPi';
|
|
static const String apiSecret = 'rYUT2PRaKLedp5VLQCQE83eZG7fjuBWtFPXGiveBmIE';
|
|
|
|
static String generate({
|
|
required String roomName,
|
|
required String identity,
|
|
String? displayName,
|
|
int ttlSeconds = 3600, // Valid for 1 hour by default
|
|
}) {
|
|
final jwt = JWT(
|
|
{
|
|
'video': {
|
|
'roomJoin': true,
|
|
'room': roomName,
|
|
'canPublish': true,
|
|
'canSubscribe': true,
|
|
'canPublishData': true,
|
|
},
|
|
'metadata': displayName ?? identity,
|
|
},
|
|
issuer: apiKey,
|
|
subject: identity,
|
|
);
|
|
|
|
// Sign the token with your secret
|
|
final token = jwt.sign(
|
|
SecretKey(apiSecret),
|
|
expiresIn: Duration(seconds: ttlSeconds),
|
|
);
|
|
|
|
return token;
|
|
}
|
|
}
|