···
-
import 'package:atproto_oauth_flutter/atproto_oauth_flutter.dart';
-
import 'environment_config.dart';
-
/// OAuth Configuration for atProto
-
/// This configuration provides ClientMetadata for the new
-
/// atproto_oauth_flutter package. The new package handles proper
-
/// decentralized OAuth discovery (works with ANY PDS).
-
// OAuth Server Configuration
-
// Cloudflare Worker that hosts client-metadata.json and handles OAuth
-
static const String oauthServerUrl =
-
'https://lingering-darkness-50a6.brettmay0212.workers.dev';
// Custom URL scheme for deep linking
-
// Must match AndroidManifest.xml intent filters
-
// Using the same format as working Expo implementation
-
static const String customScheme =
-
'dev.workers.brettmay0212.lingering-darkness-50a6';
-
// Environment-aware API URL
-
static String get apiUrl => EnvironmentConfig.current.apiUrl;
-
static const String clientId = '$oauthServerUrl/client-metadata.json';
-
// IMPORTANT: Private-use URI schemes (RFC 8252) require SINGLE slash,
-
// Correct: dev.workers.example:/oauth/callback
-
// Incorrect: dev.workers.example://oauth/callback
-
static const String customSchemeCallback = '$customScheme:/oauth/callback';
-
// HTTPS callback (fallback for PDS that don't support custom
-
static const String httpsCallback = '$oauthServerUrl/oauth/callback';
// OAuth Scopes - recommended scope for atProto
static const String scope = 'atproto transition:generic';
// Client name for display during authorization
static const String clientName = 'Coves';
-
/// Create ClientMetadata for the FlutterOAuthClient
-
/// This configures the OAuth client with:
-
/// - Discoverable client ID (HTTPS URL to metadata JSON)
-
/// - HTTPS callback (primary - works with all PDS servers)
-
/// - Custom URL scheme (fallback - requires PDS support)
-
/// - DPoP enabled for token security
-
/// - Proper scopes for atProto access
-
static ClientMetadata createClientMetadata() {
-
return const ClientMetadata(
-
// Use HTTPS as PRIMARY - prevents browser re-navigation that
-
// invalidates auth codes. Custom scheme as fallback (Worker page
-
// redirects to custom scheme anyway)
-
redirectUris: [httpsCallback, customSchemeCallback],
-
clientName: clientName,
-
dpopBoundAccessTokens: true, // Enable DPoP for security
-
applicationType: 'native',
-
grantTypes: ['authorization_code', 'refresh_token'],
-
tokenEndpointAuthMethod: 'none', // Public client (mobile apps)