stytch_dart_auth_sdk 0.0.1 copy "stytch_dart_auth_sdk: ^0.0.1" to clipboard
stytch_dart_auth_sdk: ^0.0.1 copied to clipboard

A Dart SDK for Stytch Authentication, enabling secure server-side authentication and user management for Dart-based backend applications.

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:

  • StytchAuth main 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 #

  • CHANGELOG
  • Contributing Guide
  • Local Dev Tools
  • Repository README

Installation #

dependencies:
  stytch_dart_auth_sdk: ^0.0.1

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_TIMEOUT in 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 #

  • loginWithEmailPassword
  • loginWithSso
  • startMfa
  • completeMfa
  • createSession
  • validateSession
  • revokeSession
  • revokeAllUserSessions
  • exchangeSession

UserService #

  • createUser
  • getUser
  • getCurrentUser
  • updateUser
  • deleteUser
  • listUsers
  • searchUsers
  • setMfaEnabled
  • getUserOrganizations
  • removeFromOrganization
  • deleteAuthenticationFactor

OrganizationService #

  • createOrganization
  • getOrganization
  • getOrganizationBySlug
  • updateOrganization
  • deleteOrganization
  • listOrganizations
  • searchOrganizations
  • getOrganizationMembers
  • addUserToOrganization
  • removeUserFromOrganization
  • updateOrganizationMember

InvitationService #

  • sendInvitation
  • getInvitation
  • listInvitations
  • cancelInvitation
  • acceptInvitation
  • sendBulkInvitations
  • getPendingInvitationsForEmail
  • resendInvitation

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.yml is currently commented out.
  • tools/pipelines/backend/child-ci-unit-tests-pre-dev.yml exists but is not wired in and still has stale paths.

License #

BSD 3-Clause. See LICENSE.

0
likes
150
points
98
downloads

Documentation

API reference

Publisher

verified publisheraortem.io

Weekly Downloads

A Dart SDK for Stytch Authentication, enabling secure server-side authentication and user management for Dart-based backend applications.

Repository (GitHub)

License

BSD-3-Clause (license)

Dependencies

build_web_compilers, ds_standard_features, jwt_generator

More

Packages that depend on stytch_dart_auth_sdk