affyid_sdk 1.0.0 copy "affyid_sdk: ^1.0.0" to clipboard
affyid_sdk: ^1.0.0 copied to clipboard

Dart/Flutter SDK for AffyID authentication service. Supports OAuth 2.0, OIDC, passkeys, and two-factor authentication.

affyid_sdk #

Dart/Flutter SDK for AffyID authentication service.

Installation #

Add to your pubspec.yaml:

dependencies:
  affyid_sdk: ^1.0.0

Then run:

dart pub get
# or for Flutter
flutter pub get

Quick Start #

import 'package:affyid_sdk/api.dart';

void main() async {
  // Configure the API client
  final client = ApiClient(basePath: 'https://auth.yourdomain.com');
  final authApi = AuthenticationApi(client);
  final usersApi = UsersApi(client);

  // Register a new user
  final tokens = await authApi.registerUser(RegisterRequest(
    email: 'user@example.com',
    password: 'SecurePass123!',
    firstName: 'John',
    lastName: 'Doe',
  ));

  // Set token for authenticated requests
  client.addDefaultHeader('Authorization', 'Bearer ${tokens!.accessToken}');

  // Get user profile
  final user = await usersApi.getCurrentUser();
  print(user);
}

Authentication #

Login #

final authApi = AuthenticationApi(client);

final tokens = await authApi.loginUser(LoginRequest(
  email: 'user@example.com',
  password: 'SecurePass123!',
));

client.addDefaultHeader('Authorization', 'Bearer ${tokens!.accessToken}');

Token Refresh #

final newTokens = await authApi.refreshToken(RefreshRequest(
  refreshToken: tokens.refreshToken!,
));

client.addDefaultHeader('Authorization', 'Bearer ${newTokens!.accessToken}');

Logout #

await authApi.logoutUser(LogoutRequest(
  refreshToken: tokens.refreshToken!,
));

Two-Factor Authentication #

Setup TOTP #

// Get setup info (QR code, secret)
final setup = await authApi.setup2FA();
print(setup!.qrCodeUrl); // otpauth:// URL for QR code generation
print(setup.secret);  // Manual entry secret

// Confirm with code from authenticator app
await authApi.confirm2FA(TwoFactorConfirmRequest(code: '123456'));

Login with 2FA #

// Initial login may require 2FA
final loginResult = await authApi.loginUser(LoginRequest(
  email: 'user@example.com',
  password: 'SecurePass123!',
));

if (loginResult!.requires2fa == true) {
  // Complete with 2FA code
  final tokens = await authApi.login2FA(TwoFactorLoginRequest(
    tempToken: loginResult.tempToken!,
    code: '123456',
  ));
  client.addDefaultHeader('Authorization', 'Bearer ${tokens!.accessToken}');
}

API Reference #

Available APIs #

  • AuthenticationApi - Login, register, 2FA, passkeys
  • UsersApi - User profile and passkey management
  • OAuth20Api - OAuth 2.0 endpoints
  • OidcApi - OpenID Connect endpoints
  • HealthApi - Health check endpoints

Configuration #

final client = ApiClient(basePath: 'https://auth.yourdomain.com');

// Add default headers
client.addDefaultHeader('X-Custom-Header', 'value');

// Set bearer token
client.addDefaultHeader('Authorization', 'Bearer $token');

License #

MIT

0
likes
130
points
91
downloads

Publisher

verified publisheraffylabs.com

Weekly Downloads

Dart/Flutter SDK for AffyID authentication service. Supports OAuth 2.0, OIDC, passkeys, and two-factor authentication.

Repository (GitHub)

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

collection, http, intl, meta

More

Packages that depend on affyid_sdk