myiam_supabase_flutter_sdk 0.3.2 copy "myiam_supabase_flutter_sdk: ^0.3.2" to clipboard
myiam_supabase_flutter_sdk: ^0.3.2 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)
  • Manual deregister flow: Edge Function bridge that completes MyIAM deregister + purges Supabase data + deletes auth.users atomically
  • Auto-reconnect on Supabase session expiry: attempts MyIAM token refresh → Supabase session reissue before falling back to logout
  • Drift-resistant auth state: Supabase signOut triggers reconnect attempt first, then chains to MyIAM logout if token is invalid

Install #

flutter pub add myiam_supabase_flutter_sdk

Prerequisites #

  • myiam_flutter_sdk configured with your MyIAM credentials
  • Supabase project with a mint-supabase-token Edge Function deployed
  • (Optional, for manual deregister) deregister-callback Edge Function deployed — see docs/edge-function-deregister.md

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();

Manual Deregister #

For services with asynchronous deregister (admin approval, email verification, etc.), the SDK provides a one-call orchestrator that uses a server-side Edge Function to atomically complete MyIAM deregister, purge your Supabase data, and delete auth.users:

// After receiving the deregister callback (e.g. via AppLinks)
final result = await ref
    .read(supabaseAuthProvider.notifier)
    .deregister(deregisterToken);
// MyIAM + Supabase logout is already done. Clear any local caches.
// result.redirectUrl — MyIAM logout URL (optionally open in browser)
// result.serviceUserUid — the deregistered MyIAM UID

Deploy the deregister-callback Edge Function template from docs/edge-function-deregister.md — customize purgeUserData for your schema.

Custom Edge Function Name #

ProviderScope(
  overrides: [
    supabaseAuthBridgeProvider.overrideWithValue(
      SupabaseAuthBridge(
        functionName: 'my-mint-function',
        deregisterFunctionName: 'my-deregister-function',
      ),
    ),
  ],
  child: const MyApp(),
)

License #

MIT

0
likes
0
points
23
downloads

Publisher

verified publishermyiam.io

Weekly Downloads

MyIAM + Supabase 연동 SDK for Flutter. MyIAM 인증과 Supabase 서비스를 브릿지합니다.

Homepage

License

unknown (license)

Dependencies

flutter, flutter_riverpod, myiam_flutter_sdk, supabase_flutter

More

Packages that depend on myiam_supabase_flutter_sdk