Search by

shortdramadb / nativephp-secure-storage

Matse2005

NativePHP Mobile plugin: secure storage in the iOS Keychain and Android Keystore, behind NativePHP's SecureStorage facade

Package info

github.com/Matse2005/nativephp-secure-storage

Language:Kotlin

Type:nativephp-plugin

pkg:composer/shortdramadb/nativephp-secure-storage

Statistics

Installs: 16

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-21 14:26 UTC

This package is auto-updated.

Last update: 2026-11-21 15:09:07 UTC


README

The native side of NativePHP's own SecureStorage facade. NativePHP Mobile v4 ships the facade (Native\Mobile\Facades\SecureStorage) but not the native code behind it. This plugin supplies the three bridge functions the facade calls, so apps use the facade unchanged:

Bridge function Facade call
SecureStorage.Set SecureStorage::set($key, $value, $accessibility); a null value deletes the key
SecureStorage.Get SecureStorage::get($key) and SecureStorage::read($key)
SecureStorage.Delete SecureStorage::delete($key)

Storage

  • iOS: generic password items in the Keychain, one service per app (<bundle id>.secure-storage). Items use the ThisDeviceOnly accessibility classes, so they never sync to iCloud or restore onto another device. SecureStorageAccessibility::WhenUnlocked (default), AfterFirstUnlock and WhenPasscodeSet map to the matching classes. A read on a locked device answers unavailable, not not_found.
  • Android: AES-256-GCM with a key kept in the Android Keystore (hardware-backed where the device supports it). Only the ciphertext goes into a private SharedPreferences file. A value restored from a backup onto another device cannot be decrypted there; it reads as not_found and is dropped. Platform APIs only, no androidx.security.

Install

composer require shortdramadb/nativephp-secure-storage
php artisan native:plugin:register shortdramadb/nativephp-secure-storage
php artisan native:plugin:list

The native code is compiled into your own builds (native:run, native:package). The Jump preview app does not contain it, so under Jump the facade reports a failure: keep a fallback for development.

Testing

Under a test runner the plugin adds macros to NativePHP's fake bridge:

Native::fakeBridge()->withSecureStorage(['api_token' => 'abc']);   // in-memory keychain

Native::fakeBridge()->assertStored('api_token');
Native::fakeBridge()->assertDeleted('api_token');
Native::fakeBridge()->assertNothingStored();