federated_auth_realm_sdk_dart 0.4.3
federated_auth_realm_sdk_dart: ^0.4.3 copied to clipboard
Dart SDK for interacting with the Savant Realms Federated Auth Realm API, providing auth helpers and SRWP discovery utilities.
Federated Auth Realm Dart SDK #
Official Dart SDK for interacting with the Savant Realms Federated Auth Realm API. It provides:
- A strongly typed
FederatedAuthClientwith helpers for registration, login, password flows, verification, and profile management - Token storage abstractions with an in-memory implementation that works for server-side code
- Automatic bearer injection + refresh token retry logic with a session-expired callback
- A lightweight SRWP (
Savant Realms Whispering Protocol) discovery client
Getting Started #
Add the dependency to your Dart or Flutter project:
dart pub add federated_auth_realm_sdk_dart
Initialize the client #
import 'package:federated_auth_realm_sdk_dart/federated_auth_realm_sdk_dart.dart';
final authClient = FederatedAuthClient(
baseUrl: 'https://api.federatedauthrealm.com/v1',
appKey: 'federated-auth-realm',
onSessionExpired: () {
// e.g. redirect user to login page
},
);
Register or Login #
final auth = await authClient.login(
LoginRequest(email: 'user@example.com', password: 'secret'),
);
print('access token: \\${auth.accessToken}');
final profile = await authClient.getProfile();
Token helpers #
final accessToken = await authClient.getAccessToken();
await authClient.setSessionTokens(
accessToken: 'existing-access',
refreshToken: 'existing-refresh',
);
SRWP discovery #
final srwp = SRWPDiscoveryClient('https://api.federatedauthrealm.com/v1');
final knownRealms = await srwp.getKnownRealms();
await srwp.bootstrap('https://another-realm.example.com');
The SRWP client automatically normalizes the provided base URL so that /srwp endpoints are targeted even if you pass the public /v1 API URL.
Development #
dart pub get
dart format .
dart test
Deployment & CI #
- Use
scripts/deploy.shto run formatting, static analysis, unit tests, anddart pub publish --dry-runbefore optionally publishing (configure credentials via.envor environment variables). - GitHub Actions (
.github/workflows/ci.yml) keeps formatting/analyze/test checks green on pushes and pull requests, with a manual workflow option for a dry-run deploy.