remit2any_auth 0.0.5
remit2any_auth: ^0.0.5 copied to clipboard
A Flutter package for Remit2Any authentication.
Remit2Any Auth Flutter SDK #
A Flutter package for seamless AWS Cognito authentication via WebView for Remit2Any.
Features #
- WebView-based sign-in with Remit2Any
- Secure token storage using flutter_secure_storage
- Fetch user profile from Cognito
- Background token refresh
Installation #
Add to your pubspec.yaml:
dependencies:
remit2any_auth:
path: ../remit2any_auth # or use your published version
Configuration #
Set your Cognito client IDs in config/environment_config.dart:
- Replace
your_dev_cognito_client_idwith your development Cognito client ID - Replace
your_prod_cognito_client_idwith your production Cognito client ID
Usage #
Basic Setup #
import 'package:remit2any_auth/remit2any_auth.dart';
// Set environment (optional, defaults to dev)
Remit2AnyEnvironmentConfig.setEnvironment(Environment.prod); // or Environment.dev
// Create auth instance
final auth = Remit2AnyAuth();
Authentication #
// Sign in with WebView (returns tokens map)
final tokens = await auth.signIn(context, email: 'user@example.com'); // email is optional
if (tokens != null) {
// Tokens contain: accessToken, refreshToken, idToken, email, userId
print('Access Token: ${tokens['accessToken']}');
print('User Email: ${tokens['email']}');
}
// Get current user information
final UserInfo? user = await auth.getUser();
if (user != null) {
print('Username: ${user.username}');
print('Email: ${user.email}');
print('User ID: ${user.sub}');
print('Picture: ${user.picture}');
}
// Get stored user data
final String? email = await auth.getStoredEmail();
final String? userId = await auth.getStoredUserId();
// Sign out (clears local tokens and Cognito session)
await auth.signOut(context);
Token Management #
// Manual token refresh
await auth.refreshTokens();
// Start automatic token refresh (refreshes every 30 minutes)
auth.startTokenRefreshLoop();
WebView Pages #
// Open US KYC documents page
await auth.openUsKyc(context);
// Open transfer page with optional USD amount
await auth.openTransfer(context, usdAmount: 250.0); // defaults to 100.0
// Open transactions page
await auth.openTransactions(context);
// Check if US KYC is completed
final bool isKycCompleted = await auth.isUsKycCompleted();
Environment Configuration #
// Set development environment
Remit2AnyEnvironmentConfig.setEnvironment(Environment.dev);
// Set production environment
Remit2AnyEnvironmentConfig.setEnvironment(Environment.prod);
// Check current environment
if (Remit2AnyEnvironmentConfig.isDev) {
print('Running in development mode');
}
// Get current URLs
print('Auth URL: ${Remit2AnyEnvironmentConfig.authUrl}');
print('Base URL: ${Remit2AnyEnvironmentConfig.baseUrl}');
Example #
See the example/ app for a working demo.
Security #
- Tokens are stored securely using flutter_secure_storage.
- Only trusted domains are used for WebView.
Flutter Package Publishing #
Prerequisites #
- Dart/Flutter SDK: Ensure you have the latest stable version installed
- pub.dev Account: Create an account at pub.dev
- Google Account: Link your Google account to pub.dev
- Package Name: Ensure your package name is unique on pub.dev
Version Management #
Semantic Versioning
Follow semantic versioning (MAJOR.MINOR.PATCH):
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
Update Version in pubspec.yaml
name: remit2any_auth
description: A Flutter package for Remit2Any authentication
version: 1.0.0 # Update this before publishing
Pre-Publishing Checklist #
-
Update Documentation
- Ensure README.md is complete and accurate
- Update CHANGELOG.md with new changes
- Verify all code examples work
-
Code Quality
# Run static analysis dart analyze # Run tests flutter test # Check for issues flutter doctor -
Package Validation
# Validate package structure dart pub publish --dry-run -
Test the Package
# Test in a local project cd example flutter pub get flutter run
Publishing Steps #
1. Prepare for Publishing
# Navigate to package directory
cd remit2any_auth
# Update version in pubspec.yaml
# Edit pubspec.yaml and increment version number
# Update CHANGELOG.md
# Add entry for new version
2. Validate Package
# Run dry-run to check for issues
dart pub publish --dry-run
# Fix any issues reported
3. Publish to pub.dev
# Publish the package
dart pub publish
# Follow the prompts to authenticate
4. Verify Publication
- Check pub.dev for your package
- Verify all files are uploaded correctly
- Test installation in a new project
Post-Publishing #
1. Update Dependencies
After publishing, update the example app to use the published version:
# In example/pubspec.yaml
dependencies:
remit2any_auth: ^1.0.0 # Use published version
2. Tag Release
# Create git tag
git tag v1.0.0
git push origin v1.0.0
3. Update Documentation
- Update any references to use the published version
- Update installation instructions in README
Publishing Checklist #
- ❌ Update version in
pubspec.yaml - ❌ Update
CHANGELOG.md - ❌ Run
dart analyze(no issues) - ❌ Run
flutter test(all tests pass) - ❌ Run
dart pub publish --dry-run(no issues) - ❌ Test package in example app
- ❌ Publish with
dart pub publish - ❌ Verify package on pub.dev
- ❌ Create git tag
- ❌ Update documentation
Troubleshooting #
Common Issues
-
Package Name Already Taken
- Choose a unique package name
- Check availability on pub.dev
-
Authentication Issues
- Ensure you're logged into pub.dev
- Verify Google account is linked
-
Validation Errors
- Fix all
dart analyzeissues - Ensure all dependencies are compatible
- Fix all
-
Version Conflicts
- Check for version conflicts in dependencies
- Update dependencies if needed
Rollback Procedure
If you need to rollback a published version:
- Publish a new version with fixes
- Update documentation to reflect changes
- Communicate changes to users
Continuous Integration #
Consider setting up CI/CD for automated publishing:
# .github/workflows/publish.yml
name: Publish Package
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- run: dart analyze
- run: flutter test
- run: dart pub publish --force
License #
MIT