@d11/dream-auth-login-provider
v0.2.4
Published
Provides authentication utilities for integrating user login through the Dream11 SDK.
Readme
DreamAuth Login Provider
A React Native library that provides seamless authentication login functionality for Dream11 applications. This library handles OAuth flows, session management, and deep linking for secure user authentication.
Features
- OAuth Authentication Flow - Complete OAuth 2.0 implementation for Dream11 authentication
- WebView Integration - Secure web-based login flow with custom WebView implementation
- Deep Link Handling - Automatic deep link processing for authentication callbacks
- Cross-Platform - Full support for both iOS and Android platforms
- Session Management - Robust session handling with refresh token support
- Security - Secure token storage and transmission
- Turbo Module - Built with React Native's new architecture for optimal performance
Installation
npm install @d11/dream-auth-login-provider
yarn add @d11/dream-auth-login-provideriOS Setup
- Install pods:
cd ios && pod install- Add URL scheme to your
Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.dream11.app</string>
<key>CFBundleURLSchemes</key>
<array>
<string>dream11</string>
</array>
</dict>
</array>- Handle deep links in your
AppDelegate.swift:
import DreamAuthLoginProvider
func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
if url.scheme == "dream11" {
DreamAuthLoginProviderInitializer.handleRedirect(
uri: url.absoluteString, refreshToken: nil,
baseUrl: "https://auth.dream11.com", providerApp: "dream11")
return true
}
return RCTLinkingManager.application(application, open: url, options: [:])
}Android Setup
- Add deep link handling to your
AndroidManifest.xml:
<activity>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="dream11" />
</intent-filter>
</activity>- Handle deep links in your
MainActivity.kt:
import com.dreamauthloginprovider.DreamAuthLoginProviderInitializer
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
intent?.data?.let { uri ->
if (uri.scheme == "dream11") {
DreamAuthLoginProviderInitializer.handleRedirect(
context = this,
uri = uri.toString(),
refreshToken = "",
baseUrl = ""
)
}
}
}Authentication Flow Overview
- Deep Link Reception: The library intercepts deep links with the
dream11scheme - Session Initialization: Parses authentication parameters and initializes session
- WebView Launch: Opens a secure WebView for user authentication
- Session Verification: Verifies the authentication session with the server
- Consent Handling: Manages user consent for data sharing
- Redirect Completion: Redirects back to the host application with authentication results
Authentication States
The library handles various authentication states:
LOGGED_IN- User successfully authenticatedCONSENT_NOT_PROVIDED- User denied consentLOGIN_DISMISSED- User cancelled the login flowSOMETHING_WENT_WRONG- An error occurred during authentication
Architecture
The library is built with a modular architecture supports both React Native architecture:
Core Components
- Configuration: Session management and initialization
- WebView Flow: Secure web-based authentication
- Deep Link Handling: URL scheme processing and routing
- Verification Flow: Session verification and consent handling
- HTTP Client: Network communication with authentication servers
- Client Details: Client application configuration management
Platform-Specific Implementation
- iOS: Swift-based implementation with UIKit integration
- Android: Kotlin-based implementation with Android Activities
- React Native: TypeScript bridge for cross-platform functionality
Development
Setup
- Clone the repository:
git clone https://github.com/dream11/dream-auth-login-provider.git
cd dream-auth-login-provider- Install dependencies:
yarn- Run the example app:
# Start Metro bundler
yarn example start
# Run on iOS
yarn example ios
# Run on Android
yarn example androidAvailable Scripts
yarn typecheck- TypeScript type checkingyarn lint- ESLint lintingyarn test- Run unit testsyarn clean- Clean build artifactsyarn prepare- Build the libraryyarn release- Release new version
Security
- All network communications use HTTPS
- Tokens are securely stored and transmitted
- WebView implementation prevents unauthorized access
- Session validation ensures authentication integrity
Contributing
We welcome contributions! Please see our Contributing Guide for details on:
- Development workflow
- Code style and linting
- Testing requirements
- Pull request process
- Commit message conventions
License
MIT License - see LICENSE file for details.
Support
For support and questions:
- Create an issue on GitHub
- Contact the development team
- Check the example app for usage patterns
Made with ❤️ by the Dream11 team
