Skip to content

Refactor/app example#494

Merged
mCodex merged 4 commits intomasterfrom
refactor/appExample
Nov 3, 2025
Merged

Refactor/app example#494
mCodex merged 4 commits intomasterfrom
refactor/appExample

Conversation

@mCodex
Copy link
Owner

@mCodex mCodex commented Nov 3, 2025

This pull request introduces several documentation updates, dependency upgrades, and a significant improvement to error handling for biometric authentication. The most notable change is the introduction of a standardized error for user-canceled authentication prompts, which now surfaces as a friendly message in both Android and iOS implementations. The documentation has also been enhanced with a new security policy and expanded guidance on error handling. Additionally, dependencies have been updated for better stability and compatibility.

Error Handling Improvements

  • Standardized the handling of user-canceled biometric and device credential authentication prompts by introducing a new error type (SensitiveInfoException.AuthenticationCanceled on Android and a corresponding error on iOS). This ensures cancellations are surfaced as [E_AUTH_CANCELED] Authentication prompt canceled by the user. and do not poison hook state. [1] [2] [3] [4]

Documentation Updates

  • Added a comprehensive error handling section to the README.md, explaining how hook errors are structured and how to handle authentication cancellations gracefully.
  • Updated the table of contents in the README.md to include error handling.
  • Improved version selection guidance in the README.md to clarify the difference between 5.6.x and 6.x releases.
  • Added a new SECURITY.md file detailing supported versions, vulnerability reporting, and hardening recommendations.
  • Added a CODE_OF_CONDUCT.md file to establish community standards and enforcement policies.

Dependency Upgrades

  • Updated various dependencies in package.json and example/package.json, including react-native-nitro-modules, nitrogen, eslint, and related plugins for improved stability and compatibility. [1] [2] [3] [4]

License and Metadata

  • Corrected the copyright range in the LICENSE file to cover 2016–2025.
  • Enhanced the package description in package.json for clarity and marketing.

Code Quality

  • Applied consistent semicolon usage and formatting improvements in eslint.config.mts. [1] [2]

Replace the legacy sample with a simplified "Sensitive Info Playground"
example that leverages useSecureStorage and useSecurityAvailability.
Clean up imports, reduce access-control options to 'open' and 'biometric',
wire up save/reveal/delete/clear/refresh handlers, update ActionButton
behaviour, and refresh styles/layout to match the streamlined UI.
- Update dev deps: @eslint/compat -> 1.4.1, @eslint/js -> 9.39.0, eslint -> 9.39.0, globals -> 16.5.0, nitrogen -> 0.31.4
- Update runtime/example deps: react-native-nitro-modules -> 0.31.4, react-native-safe-area-context -> ^5.6.2
- Update yarn.lock to match dependency bumps
- Docs: change README references from "5.6.0" to "5.6.x" for consistent versioning
…p native cancel codes

- Add CODE_OF_CONDUCT
- Bump LICENSE copyright range to 2016-2025
- Android:
  - Introduce SensitiveInfoException.AuthenticationCanceled and throw/resume with it when user cancels biometric/device-credential prompts
  - Simplify device credential flow to always return cipher after prompt
- iOS:
  - Map relevant OSStatus values to an E_AUTH_CANCELED runtime error for friendly messaging
- Internal errors:
  - Add AUTH_CANCELED marker and helper hasErrorMarker/isAuthenticationCanceledError
  - Centralize detection of auth-cancelled errors
- Hooks & utilities:
  - Export and use isAuthenticationCanceledError in error-utils
  - Create user-friendly hook error message for canceled auths and export detector
  - Update hooks (useSecretItem, useHasSecret, useSecureOperation, useSecureStorage, useSecurityAvailability) to treat auth cancellations as non-fatal: preserve/clear state appropriately and avoid surfacing HookError when user dismisses prompts
  - Add applyError helper in useSecureStorage to centralize error handling
  - Update hook types and exports
- Nitro/native layers & types:
  - Type and formatting fixes across sensitive-info.nitro.ts, internal/native, options, core/storage and index exports
- Tests & tooling:
  - Apply consistent code style (semicolons, trailing commas) across tests and configs
  - Update many test files to match changes and ensure behavior for canceled auth flows
- Misc:
  - Update package.json description
  - ESLint config formatting fixes

This change makes authentication prompt cancellations explicit (E_AUTH_CANCELED) and prevents noisy error states in hooks when users dismiss biometric / device credential prompts.
Copilot AI review requested due to automatic review settings November 3, 2025 15:03
@mCodex mCodex merged commit ed1b003 into master Nov 3, 2025
5 of 6 checks passed
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 pull request introduces authentication cancellation handling, code formatting improvements (semicolons), dependency updates, and documentation enhancements. The key changes include:

  • New authentication cancellation error handling with [E_AUTH_CANCELED] markers
  • Consistent semicolon formatting across TypeScript files
  • Updates to ESLint, Nitro modules, and other dependencies
  • Enhanced example app UI with simplified user flows
  • New documentation files (SECURITY.md, CODE_OF_CONDUCT.md)

Reviewed Changes

Copilot reviewed 47 out of 48 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/internal/errors.ts Adds isAuthenticationCanceledError helper function
src/hooks/error-utils.ts Creates friendly messages for canceled authentication
src/hooks/useSecureStorage.ts Implements authentication cancellation handling in hooks
ios/HybridSensitiveInfo.swift Adds iOS authentication cancellation detection
android/.../BiometricAuthenticator.kt Handles biometric cancellation on Android
example/App.tsx Complete UI redesign with simplified interface
package.json Dependency updates and improved package description
README.md Adds error handling section and updates version guidance

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

@@ -1,15 +1,15 @@
import { useCallback, useEffect, useRef } from 'react'
import type { MutableRefObject } from 'react'
import type { RefObject } from 'react'
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The import type change from MutableRefObject to RefObject is incorrect. RefObject is read-only and should not be used for refs that need to be mutated. The code at line 16 assigns to cachedInstance and line 28 assigns to mountedRef.current, which requires a mutable reference. This will cause TypeScript errors.

Copilot uses AI. Check for mistakes.
* Indicates whether the component that owns the hook is still mounted. Helpful when dispatching asynchronous state updates.
*/
readonly mountedRef: MutableRefObject<boolean>
readonly mountedRef: RefObject<boolean>
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Using RefObject for mountedRef is incorrect because the code mutates mountedRef.current in the cleanup effect. RefObject is read-only and should remain as MutableRefObject<boolean> to allow mutations.

Copilot uses AI. Check for mistakes.
* Stores the last {@link AbortController} created by {@link begin}. Exposed for advanced scenarios such as manual cancellation.
*/
readonly controllerRef: MutableRefObject<AbortController | null>
readonly controllerRef: RefObject<AbortController | null>
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Using RefObject for controllerRef is incorrect because the code mutates controllerRef.current when creating new AbortControllers. RefObject is read-only and should remain as MutableRefObject<AbortController | null> to allow mutations.

Copilot uses AI. Check for mistakes.
useState,
type ReactNode,
} from 'react';
import React, { useCallback, useMemo, useState } from 'react'
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The import statement is missing semicolons while the rest of the file uses semicolons consistently. This creates inconsistency within the same file.

Copilot uses AI. Check for mistakes.
Text,
TextInput,
View,
} from 'react-native'
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Missing semicolon at the end of the import statement, inconsistent with the rest of the file's formatting.

Suggested change
} from 'react-native'
} from 'react-native';

Copilot uses AI. Check for mistakes.
useSecureStorage,
useSecurityAvailability,
type AccessControl,
} from 'react-native-sensitive-info'
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Missing semicolon at the end of the import statement, inconsistent with the rest of the file's formatting.

Suggested change
} from 'react-native-sensitive-info'
} from 'react-native-sensitive-info';

Copilot uses AI. Check for mistakes.
@mCodex mCodex deleted the refactor/appExample branch December 15, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant