Zeba Academy Secure Auth

A Flutter package for secure offline authentication with PIN, Pattern, and Biometric login. Perfect for banking apps, enterprise apps, and any app that requires high security.


Features

  • šŸ”’ Local PIN/Pattern authentication
  • 🫱 Biometric login: fingerprint and Face ID
  • 🌐 Offline-first login flow
  • šŸ•’ Session management with configurable expiry
  • šŸ›” Root/jailbreak detection for device security

Installation

Add the dependency to your pubspec.yaml:

dependencies:
  zeba_academy_secure_auth:
    git:
      url: https://github.com/yourusername/zeba_academy_secure_auth.git

Then run:

flutter pub get

Usage

1. Import the package

import 'package:zeba_academy_secure_auth/zeba_academy_secure_auth.dart';

2. Initialize the service

final authService = SecureAuthService();

3. PIN Authentication

await authService.setPin('1234'); // Set a PIN
bool success = await authService.verifyPin('1234'); // Verify PIN

4. Pattern Authentication

await authService.setPattern('012345678'); // Set pattern
bool correct = await authService.verifyPattern('012345678'); // Verify pattern

5. Biometric Authentication

bool authenticated = await authService.authenticateBiometric();

6. Session Management

await authService.startSession();
bool active = await authService.isSessionActive();

7. Root / Jailbreak Detection

bool secure = await authService.isDeviceSecure();

Example

import 'package:flutter/material.dart';
import 'package:zeba_academy_secure_auth/zeba_academy_secure_auth.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: const LoginScreen());
  }
}

class LoginScreen extends StatefulWidget {
  const LoginScreen({super.key});

  @override
  State<LoginScreen> createState() => _LoginScreenState();
}

class _LoginScreenState extends State<LoginScreen> {
  final auth = SecureAuthService();
  final pinController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Secure Auth Demo')),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          children: [
            TextField(
              controller: pinController,
              keyboardType: TextInputType.number,
              decoration: const InputDecoration(labelText: 'Enter PIN'),
            ),
            ElevatedButton(
              onPressed: () async {
                final ok = await auth.verifyPin(pinController.text);
                ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(content: Text(ok ? 'PIN correct!' : 'Wrong PIN')),
                );
              },
              child: const Text('Login with PIN'),
            ),
            ElevatedButton(
              onPressed: () async {
                if (await auth.authenticateBiometric()) {
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(content: Text('Biometric Verified!')),
                  );
                }
              },
              child: const Text('Login with Biometrics'),
            ),
          ],
        ),
      ),
    );
  }
}

Contributing

Contributions are welcome!

  • Open an issue for bugs or feature requests
  • Submit pull requests with clean, tested code

License

MIT License – see LICENSE file.


About Me

✨ I’m Sufyan bin Uzayr, an open-source developer passionate about building and sharing meaningful projects. You can learn more about me and my work at sufyanism.com or connect with me on Linkedin


Your all-in-one no-bloat hub!

šŸš€ Explore cutting-edge resources in coding, tech, and development at zeba.academy and code.zeba.academy. Empower yourself with practical skills through curated directives, real-world projects, and hands-on experience. Level up your tech game today! šŸ’»āœØ

Zeba Academy is a learning platform dedicated to coding, technology, and development.

āž” Visit our main site: zeba.academy āž” Explore hands-on courses and resources at: code.zeba.academy āž” Check out our YouTube for more tutorials: zeba.academy āž” Follow us on Instagram: zeba.academy

Thank you for visiting!