stytch_dart_auth_sdk
Dart SDK for Stytch B2B auth workflows.
This package provides typed service clients and models for user, session, organization, and invitation operations over the Stytch B2B API.
Package Status
Implemented and exported from lib/stytch_dart_auth_sdk.dart:
StytchAuthmain entrypoint.- Service clients:
AuthService,UserService,OrganizationService,InvitationService. - Typed request/response models under
lib/src/models/. - Error model and exception mapping (
StytchException,StytchAuthException, etc). - Firebase-style compatibility helpers under
lib/src/auth/(primarily for the Flutter example app).
Important: parts of the Firebase compatibility API are currently placeholders/mocks. Use the Stytch service clients for production flows.
Docs Index
Installation
dependencies:
stytch_dart_auth_sdk: ^0.0.2
Then run:
dart pub get
Initialization
Direct configuration
import 'package:stytch_dart_auth_sdk/stytch_dart_auth_sdk.dart';
final stytch = StytchAuth(
apiKey: 'YOUR_STYTCH_API_KEY',
projectId: 'YOUR_STYTCH_PROJECT_ID',
environment: 'sandbox', // sandbox | development | production
);
Environment variables
Supported environment variables:
STYTCH_API_KEY(required)STYTCH_PROJECT_ID(required)STYTCH_ENVIRONMENT(optional)STYTCH_BASE_URL(optional)STYTCH_TIMEOUTin seconds (optional)
final stytch = StytchAuth.fromEnvironmentVariables();
Basic Usage
import 'package:stytch_dart_auth_sdk/stytch_dart_auth_sdk.dart';
Future<void> main() async {
final stytch = StytchAuth(
apiKey: 'YOUR_STYTCH_API_KEY',
projectId: 'YOUR_STYTCH_PROJECT_ID',
environment: 'sandbox',
);
final created = await stytch.user.createUser(
const CreateUserRequest(
email: 'alice@example.com',
name: 'Alice',
password: 'strong-password',
),
);
final login = await stytch.auth.loginWithEmailPassword(
const EmailPasswordLoginRequest(
email: 'alice@example.com',
password: 'strong-password',
),
);
final validation = await stytch.auth.validateSession(
ValidateSessionRequest(sessionToken: login.sessionToken),
);
print('User ID: ${created.userId}');
print('Session valid: ${validation.valid}');
}
API Surface Overview
AuthService
loginWithEmailPasswordloginWithSsostartMfacompleteMfacreateSessionvalidateSessionrevokeSessionrevokeAllUserSessionsexchangeSession
UserService
createUsergetUsergetCurrentUserupdateUserdeleteUserlistUserssearchUserssetMfaEnabledgetUserOrganizationsremoveFromOrganizationdeleteAuthenticationFactor
OrganizationService
createOrganizationgetOrganizationgetOrganizationBySlugupdateOrganizationdeleteOrganizationlistOrganizationssearchOrganizationsgetOrganizationMembersaddUserToOrganizationremoveUserFromOrganizationupdateOrganizationMember
InvitationService
sendInvitationgetInvitationlistInvitationscancelInvitationacceptInvitationsendBulkInvitationsgetPendingInvitationsForEmailresendInvitation
Example App
Flutter sample app location:
example/stytch-dart-auth-sdk-flutter-mobile-app/
Run it with:
cd example/stytch-dart-auth-sdk-flutter-mobile-app
flutter pub get
flutter run
Development
From this package directory:
dart pub get
dart analyze
dart test
Testing
Run all tests:
dart test
Run only unit tests:
dart test test/unit/
Run integration tests:
dart test test/integration/
Run a single test file:
dart test test/unit/stytch_working_test.dart
Current note: many compatibility and integration tests are still placeholders, so a green test run is currently a smoke/structure signal more than full behavioral coverage.
CI Status
- The top-level pipeline currently runs validation, Flutter example analysis, and release orchestration.
- The unit-test stage in
.gitlab-ci.ymlis currently commented out. tools/pipelines/backend/child-ci-unit-tests-pre-dev.ymlexists but is not wired in and still has stale paths.
License
BSD 3-Clause. See LICENSE.
Libraries
- stytch_dart_auth_sdk
- Main export file for stytch_dart_auth_sdk