How formidablelabs/react-native-app-auth works
Main Components to Highlight
• React Native JavaScript Layer: This is the public-facing API that developers use in their React Native apps.
• Bridge Module (React Native App Auth Package): Located under packages/react-native-app-auth, this component serves as the bridge between JavaScript and native code.
• Native Modules for iOS: The “ios” folder inside the packages/react-native-app-auth directory contains the native iOS implementation that wraps the AppAuth-iOS SDK.
• Native Modules for Android: Similarly, the “android” folder in the same package contains the native Android implementation that wraps the AppAuth-Android SDK.
• Demo/Example Apps: Found under examples/demo, these apps (with subdirectories for iOS and Android) demonstrate integration and provide a reference for usage.
• Documentation and Developer Guides: Under docs, this section provides comprehensive guides, configuration examples, and provider-specific documentation.
Relationships and Interactions
• From a usage perspective, the React Native application (consumer) calls the JavaScript API exposed by the bridge.
• The bridge delegates authentication requests from the JS layer to the native modules.
• The iOS and Android native modules then call into their respective AppAuth native SDKs to perform the OAuth2 / OpenID Connect flows.
• After successfully authenticating, the results (tokens, errors, etc.) propagate back through the native layer, into the bridge module, and then back to the JS layer.
• The examples and test code validate these data flows and interactions, ensuring that configurations (such as redirect URLs, PKCE handling, etc.) are correctly set up.
Architectural Patterns and Design Principles
• Separation of Concerns: The architecture cleanly separates Android and iOS logic from the shared JavaScript logic.
• Bridging Pattern: Implements a bridge that allows interoperability between React Native’s JS environment and native implementations.
• Modular Design: With a clear packages directory, the project is designed for easy extension/maintenance and is built with a plugin-like architecture for supporting multiple providers.
• Documentation Driven Development: The docs folder contains Docusaurus-based documentation, which is a key part of the project ecosystem.
Relevant Technologies and Frameworks
• React Native: The core platform.
• AppAuth-iOS and AppAuth-Android: The native authentication SDKs.
• OAuth 2.0 and OpenID Connect standards.
• Native build systems such as Xcode for iOS and Gradle for Android.
• The build and testing tools include ESLint, Prettier, Jest, and others which support code health and consistency.
Detail
• Major configuration and build tools briefly if space permits (for instance, mention that there are Gradle build scripts for Android and Pod configurations for iOS in the respective native modules).