Skip to content

Conversation

@mCodex
Copy link
Owner

@mCodex mCodex commented Oct 29, 2025

This pull request refactors the secure storage API implementation to improve maintainability and reliability. The main changes include introducing a unified native invocation utility, extracting fallback logic for non-native environments, and updating all storage-related methods to use these new patterns. Additionally, the entry point has been updated for consistency, and the exports in package.json have been corrected.

Core API refactor and fallback logic improvements:

  • Introduced a generic invokeNative function and related types to standardize calling native methods, and extracted fallback logic for all storage operations (set, get, has, delete, list, clear) into dedicated helper functions in src/index.ts.
  • Updated all core API methods (setItem, getItem, hasItem, deleteItem, getAllItems, clearService, getSupportedSecurityLevels) to use the new invokeNative function and fallback helpers, improving error handling and code clarity in src/index.ts.

Entry point and exports updates:

  • Changed the main source entry in package.json from index.tsx to index.ts to match the refactored codebase.
  • Removed the legacy export file src/index.tsx and consolidated all exports in src/index.ts.

Code organization and consistency:

  • Added utility types and helper functions (e.g., resolveService, NativeSensitiveInfoModule, KeychainScopedOptions) to improve code structure and type safety in src/index.ts.
  • Updated comments and docstrings for clarity and accuracy in src/index.ts.

These changes make the secure storage API more robust and easier to maintain, especially in environments where native modules may not be available.

Changed package.json to use src/index.ts as the source entry, removed src/index.tsx, and refactored src/index.ts to add robust fallback logic for native module methods. This improves reliability when native modules are unavailable and centralizes fallback implementations for storage operations.
Copilot AI review requested due to automatic review settings October 29, 2025 23:35
@mCodex mCodex added bug javascript Pull requests that update javascript code labels Oct 29, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the codebase to eliminate a circular import issue and improve code organization by:

  • Removing the problematic src/index.tsx file that had circular exports pointing to itself
  • Updating the package.json to correctly point to src/index.ts as the source entry point
  • Refactoring the native module invocation logic to use a unified invokeNative helper function
  • Extracting fallback storage implementations into separate, reusable functions
  • Adding proper TypeScript typing for the native module interface

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/index.tsx Removed file containing circular self-imports
src/index.ts Refactored to add type-safe native module interface, unified invocation helper, and extracted fallback functions for improved maintainability
package.json Updated source entry point from index.tsx to index.ts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mCodex and others added 2 commits October 29, 2025 20:37
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mCodex mCodex merged commit 0dc1598 into v5.x Oct 30, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Index.js file broken and getSupportedSecurityLevels returning hardcoded values (version 5.6.1)

2 participants