How pradeep1991singh/react-native-secure-key-store works
Main Components
• React Native JS Interface: This is the JavaScript API (as seen from index.js and index.d.ts) that exposes methods such as set, get, and remove to application developers.
• Android Native Module: Located in the “android” directory (with files under com/reactlibrary/securekeystore), this module implements the native functionality for secure key storage using Android’s KeyStore.
• iOS Native Module: Found in the “ios” folder (with files like RNSecureKeyStore.h, RNSecureKeyStore.m, and the podspec), this module wraps around iOS Keychain APIs.
• Example Application: The “example” directory provides a demonstration app that integrates the library. This component helps illustrate how the React Native application interacts with the secure key store module.
• Testing & Mocks: The project includes a mocked implementation (under __tests__ directories and RNSecureKeyStoreMock) to facilitate unit testing of the JS layer without needing the actual native modules.
Relationships and Interactions
• The React Native application (or any RN-based project) calls the library’s JS interface. This interface then bridges to the native code.
• On Android, the JS calls go to the RNSecureKeyStoreModule (and Package) which interacts directly with Android’s KeyStore APIs.
• On iOS, the JS calls reach the corresponding native module that utilizes the Keychain for secure storage.
• The Example Application essentially demonstrates the integration path from the JS layer into the respective native implementations.
• Testing mocks ensure that unit tests can simulate the behavior of native storage without actually invoking device-specific APIs.
Architectural Patterns & Design Principles
• Bridging Pattern: The core idea is that the React Native library acts as a bridge between JavaScript and platform-specific implementations (Android and iOS).
• Modular Structure: The separation into “android”, “ios”, and “example” directories signifies clear modularity, allowing developers to maintain platform-specific code easily.
• Abstraction: The JS interface abstracts the underlying platform differences, allowing a consistent API for both mobile operating systems.
• Testability: By including mocks and tests, the design emphasizes maintainable and testable code.
Relevant Technologies & Frameworks
• For Android: Java (or Kotlin if evolving), Gradle as build system.
• For iOS: Objective-C and Xcode project files (with podspec for CocoaPods integration).
• React Native API: The JavaScript layer that leverages the native bridges.
• Additional configuration and build tools (e.g., Gradle for Android, Xcode for iOS, and Metro bundler for the JS code).