New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rn-keychain-store

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rn-keychain-store

Keychain and Keystore simple API Implementation

latest
Source
npmnpm
Version
0.3.6
Version published
Weekly downloads
1
-90%
Maintainers
1
Weekly downloads
 
Created
Source

rn-keychain-store

A secure, simple, and efficient React Native module for storing sensitive data using iOS Keychain and Android Keystore. This module provides a unified API for securely storing and retrieving sensitive information across both platforms.

Features

  • 🔒 Secure storage using iOS Keychain and Android Keystore
  • 🔄 Unified API for both platforms
  • ⚡️ Built with React Native Turbo Modules for better performance
  • 🛡️ Data encryption on Android using AES/GCM
  • 🔑 Simple and intuitive API
  • 📦 Zero dependencies
  • 🧪 Fully tested
  • 📱 Supports both iOS and Android

Installation

# Using npm
npm install rn-keychain-store

# Using yarn
yarn add rn-keychain-store

# Using pnpm
pnpm add rn-keychain-store

iOS

  • Install pods:
cd ios && pod install && cd ..

No additional steps required. The module will be automatically linked.

Android

No additional steps required. The module will be automatically linked.

Usage

import KeychainStore, { setItem, getItem, removeItem, clear } from 'rn-keychain-store';

// Store sensitive data
const storeToken = () => {
  try {
    const success = setItem('auth_token', 'your-secure-token');
    if (success) {
      console.log('Token stored successfully');
    }
  } catch (error) {
    console.error('Failed to store token:', error);
  }
};

// Retrieve stored data
const getToken = () => {
  try {
    const token = getItem('auth_token');
    if (token) {
      console.log('Retrieved token:', token);
    }
  } catch (error) {
    console.error('Failed to retrieve token:', error);
  }
};

// Remove specific item
const removeToken = () => {
  try {
    const success = removeItem('auth_token');
    if (success) {
      console.log('Token removed successfully');
    }
  } catch (error) {
    console.error('Failed to remove token:', error);
  }
};

// Clear all stored data
const clearAll = () => {
  try {
    clear();
    console.log('All data cleared successfully');
  } catch (error) {
    console.error('Failed to clear data:', error);
  }
};

API Reference

setItem(key: string, value: string): boolean

Stores a value securely in the keychain/keystore.

  • key: The key to store the value under
  • value: The value to store
  • Returns: boolean - true if successful, false otherwise

getItem(key: string): string | null

Retrieves a value from the keychain/keystore.

  • key: The key to retrieve
  • Returns: string | null - The stored value or null if not found

removeItem(key: string): boolean

Removes a value from the keychain/keystore.

  • key: The key to remove
  • Returns: boolean - true if successful, false otherwise

clear(): void

Removes all values from the keychain/keystore.

Security Considerations

  • On iOS, data is stored in the Keychain and persists across app uninstalls
  • On Android, data is encrypted using AES/GCM and stored in the Keystore
  • All operations are performed on a background thread to prevent UI blocking
  • Keys are hashed before storage on Android for additional security

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Made with create-react-native-library

Keywords

react-native

FAQs

Package last updated on 15 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts