appsocom library
Server SDK for sfukit: join tokens, room admin, moderation, metadata and webhook verification. For servers (Dart Frog, Shelf, Serverpod...) only: it needs the deployment's admin key, which must never ship in a Flutter app.
final kit = SfuKit(url: 'https://video.client.com', adminKey: env['SFUKIT_ADMIN_API_KEY']!);
final token = await kit.createToken('class-1', 'u_7', name: 'Ada', role: 'student');
Classes
- SfuKit
- Admin client for one sfukit deployment.
- SfuKitToken
- A join token and its expiry (unix seconds).
Constants
- signatureHeader → const String
-
Header carrying
t=<unix>,v1=<hex HMAC-SHA256 of "t.body">.
Functions
-
signToken(
String jwtSecret, String roomId, String userId, {String? name, String? role, Map< String, bool> ? permissions, bool? canPublish, Map<String, dynamic> ? metadata, int? maxParticipants, int? ttlSeconds, String? dataSaver}) → SfuKitToken - Sign a join token with the deployment's JWT_SECRET, without calling the kit. Produces exactly what POST /tokens would (HS256, audience "sfukit").
-
signWebhook(
String secret, String rawBody, [int? t]) → String - Build a signature header (for tests of your webhook endpoint).
-
verifyWebhook(
String secret, String rawBody, String? signature, {Duration tolerance = const Duration(minutes: 5)}) → Map< String, dynamic> ? -
Check a webhook delivery. Pass the RAW body (not re-serialized JSON) and
the X-SfuKit-Signature header.
secretis WEBHOOK_SECRET (or ADMIN_API_KEY if none was set). Returns the event, or null if the signature is wrong or older thantolerance.
Exceptions / Errors
- SfuKitError
- A non-2xx answer from the kit (or a bad argument caught before calling it, status 400).