Skip to main content

dartstream_client 0.3.3 copy "dartstream_client: ^0.3.3" to clipboard
dartstream_client: ^0.3.3 copied to clipboard

Public Dart client for wiring Flutter, Flame, and server apps to DartStream SaaS.

dartstream_client #

Public Dart client for wiring Flutter, Flame, Unity companion services, and server-side Dart code to DartStream SaaS.

This package is the customer-facing SDK surface. It does not include private provider adapters, service-account credentials, Secret Manager access, or DartStream SaaS control-plane internals. Customer apps bring their own provider accounts where needed; DartStream SaaS handles the wiring, tenant context, auth headers, and hosted service calls.

Quick Start #

The full customer path is still under beta validation. The current experience adapters use in-memory saves and sample inventory/profile/session data; do not use them for durable player progress. Browser/mobile helpers use Firebase user sessions. Machine credentials are server-only: client secrets must never be embedded in browser or mobile apps.

reactive.publishToChannel in version 0.3.2 targets /api/v1/reactive/streaming/channels/{channelId}/publish.

final client = DartStreamClient(
  config: DartStreamConfig.dev(firebaseApiKey: publicFirebaseApiKey),
);

final firebase = await client.auth.createEmailPasswordSession(
  email: email,
  password: password,
);
final session = await client.auth.onboardFirebaseSession(firebase);
const scope = DartStreamScope(projectId: 'flame-game');

await client.experience.saveCloudSave(
  session,
  scope: scope,
  slotKey: 'main',
  payload: {'level': 3, 'coins': 42},
);

For the one-call flow, use DartStreamClient.signIn or DartStreamClient.signUp. Both return a DartStreamConnection with the resolved session and a session-bound client.

For hosted Flutter web samples, load the public Firebase config from /__/firebase/init.json on the Firebase Hosting origin instead of committing API keys.

Service Clients #

DartStreamClient exposes named workflow clients:

  • client.auth for Firebase session onboarding, provider sign-in handoff, /me, /user-status, logout, enabled provider discovery, user profile updates, avatar bytes/upload/delete, and session revocation.
  • client.platform for projects, environments, tenant profile settings, and key-addressed feature flags.
  • client.experience for game/app experience helpers such as profiles, inventory, active sessions, cloud save snapshots, and connectors.
  • client.reactive for event tracking, runtime channel discovery, channel management, channel publishing, and generic list/create/delete operations under /api/v1/reactive.
  • client.persistence for provider catalog, provider configuration test flows, and generic list/create/delete operations under /api/v1/persistence.
  • client.billing for checkout, portal, subscription, and feature entitlement checks.

The root client still includes the original convenience helpers so existing sample apps can migrate incrementally.

Generic Authenticated Calls #

When a SaaS route exists before this SDK has a typed helper, use the generic JSON methods. They keep bearer auth, tenant headers, query parameters, and JSON encoding consistent.

final result = await client.postJson(
  DartStreamService.reactive,
  '/api/v1/reactive/custom-route',
  session: session,
  query: {'mode': 'qa'},
  body: {'enabled': true},
);

Prefer adding typed helpers in this package once a route becomes part of a stable customer workflow.

Environments #

Use DartStreamConfig.dev() for development SaaS, DartStreamConfig.prod() for production SaaS, and DartStreamConfig.local() for local open-source or developer-hosted backends. Every URL can be overridden when a sample app needs custom ports or preview hosts.

Server-side machine credentials (0.3.3 candidate) #

The beta credential model uses your trusted application server. Browser and mobile games authenticate to that server; it validates player identity and calls DartStream. Keep the client secret in server environment/secret storage. A direct public-client token flow is post-beta and is not implemented by this SDK.

import 'package:dartstream_client/dartstream_server.dart';

Future<void> main() async {
  final machine = DartStreamMachineClient.fromEnvironment();
  try {
    final flags = await machine.listFeatureFlags();
    // Return only the application data your authenticated player may read.
    print('Read ${flags.length} project flags.');
  } finally {
    machine.close();
  }
}

Set DARTSTREAM_CLIENT_ID, DARTSTREAM_CLIENT_SECRET, DARTSTREAM_TENANT_ID and DARTSTREAM_PROJECT_ID on that server. For a development server pass config: DartStreamConfig.dev(). Tokens last 300 seconds; session() and run((client, session) => ...) renew before expiry and share concurrent exchanges. Use run for each service operation. Failed mutations are never automatically replayed. listFeatureFlags always sends the configured project identifier. Server ownership checks in DartStream #146 remain a release acceptance gate; client-side checks do not establish server authorization.

The tenant is derived from the exchanged token. DARTSTREAM_TENANT_ID is optional; when supplied it must match. DARTSTREAM_PROJECT_ID remains required. For publish calls, use the UUID id from streamingChannels(), never channel_name.

0
likes
150
points
116
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Public Dart client for wiring Flutter, Flame, and server apps to DartStream SaaS.

Homepage

License

MIT (license)

Dependencies

http

More

Packages that depend on dartstream_client