myiam_supabase_flutter_sdk 0.1.0
myiam_supabase_flutter_sdk: ^0.1.0 copied to clipboard
MyIAM + Supabase 연동 SDK for Flutter. MyIAM 인증과 Supabase 서비스를 브릿지합니다.
myiam_supabase_flutter_sdk #
A Flutter SDK that bridges MyIAM authentication with Supabase, enabling seamless use of Supabase services with MyIAM-managed identities.
Features #
- Automatic Supabase session creation on MyIAM login
- Unified auth state via Riverpod (
supabaseAuthProvider) - Token refresh with Supabase reconnection
- Unified logout (MyIAM + Supabase)
Install #
flutter pub add myiam_supabase_flutter_sdk
Prerequisites #
- myiam_flutter_sdk configured with your MyIAM credentials
- Supabase project with a
mint-supabase-tokenEdge Function deployed
Quick Start #
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:myiam_flutter_sdk/myiam_flutter_sdk.dart';
import 'package:myiam_supabase_flutter_sdk/myiam_supabase_flutter_sdk.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// 1. Initialize Supabase
await Supabase.initialize(
url: 'YOUR_SUPABASE_URL',
anonKey: 'YOUR_SUPABASE_ANON_KEY',
);
// 2. Run app with MyIAM config
runApp(
ProviderScope(
overrides: [
authConfigProvider.overrideWithValue(
const MyiamConfig(
serviceUid: 'YOUR_SERVICE_UID',
oauth2ClientId: 'YOUR_CLIENT_ID',
apiKey: 'YOUR_API_KEY',
redirectScheme: 'YOUR_APP_SCHEME',
redirectHost: 'YOUR_REDIRECT_HOST',
),
),
],
child: const MyApp(),
),
);
}
// 3. Watch auth state
final authState = ref.watch(supabaseAuthProvider);
switch (authState) {
case SupabaseAuthAuthenticated(:final supabaseConnected):
if (supabaseConnected) {
// Both MyIAM and Supabase are ready
final supabase = ref.read(supabaseClientProvider);
// Use supabase client...
}
case SupabaseAuthUnauthenticated():
// Show login screen
case SupabaseAuthLoading():
// Show loading
case SupabaseAuthError(:final message):
// Handle error
}
// 4. Logout (both MyIAM + Supabase)
await ref.read(supabaseAuthProvider.notifier).logout();
Custom Edge Function Name #
ProviderScope(
overrides: [
supabaseAuthBridgeProvider.overrideWithValue(
SupabaseAuthBridge(functionName: 'my-custom-function'),
),
],
child: const MyApp(),
)
License #
MIT