Skip to content

Run without secure storage plugin - #1

Merged
simonhamp merged 6 commits into
NativePHP:mainfrom
kadirtikil:run-without-secure-storage-plugin
Oct 16, 2026
Merged

simonhamp merged 6 commits into
NativePHP:mainfrom
kadirtikil:run-without-secure-storage-plugin

Conversation

@kadirtikil

Copy link
Copy Markdown
Contributor

nativephp/mobile-secure-storage is a paid plugin, so composer install fails for anyone without a plugins.nativephp.com licence, and they can't run the app or its tests. This adds a way to run it without the plugin. Nothing changes for anyone who has it, including CI and release builds.

What changes

  • composer setup:free installs from a generated copy of composer.json and composer.lock (composer.free.*, git-ignored) with the plugin and its repository removed. Every other package keeps its locked version. Scripts aren't part of the lock hash, so composer.lock is untouched.
  • DeviceKey reads and writes through a KeyStore. KeyStores\Keychain calls SecureStorage exactly as before. KeyStores\EncryptedFile keeps the seed in storage/app/private/keys, encrypted with APP_KEY.
  • The store is chosen automatically: the Keychain when the plugin is installed, the file when it isn't. DEVNULL_KEY_STORE=keychain|file overrides it.
  • README: a "Without a plugin licence" section, including building with COMPOSER=composer.free.json php artisan native:run ios.

Why this works

The SecureStorage facade ships in nativephp/mobile. The plugin only adds the native side that answers its bridge calls. Without it, the PHP side runs fine. Only the device can't answer, and onboarding stopped at "could not read the device key". The file store fills that gap.

Safety

  • APP_KEY ships in the app, so the file store only keeps the seed out of plain text. It's for simulators, not releases, and release builds always have the plugin.
  • A file the app can't decrypt is reported as a failure, never replaced with a new key, which would orphan the key already on the user's GitHub.
  • Tests pin DEVNULL_KEY_STORE=keychain, so the existing Keychain tests run the same with or without the plugin.

Testing

  • Ran composer setup:free from an empty vendor/ with no plugin credentials. It installed everything else at the locked versions.
  • 249 tests pass without the plugin. New tests in tests/Feature/Devnull/EncryptedFileKeyStoreTest.php cover the file store and the store choice.
  • Built and ran on the iOS Simulator with COMPOSER=composer.free.json php artisan native:run ios.

kadirtikil and others added 6 commits October 16, 2026 09:25
composer setup:free copies composer.json and composer.lock to
composer.free.*, drops plugins.nativephp.com and removes
nativephp/mobile-secure-storage from the copy, then installs from it. Every
other package keeps its locked version. The copies are generated, so they
can't drift, and git ignores them.

The SecureStorage facade is part of nativephp/mobile. The plugin only adds
the native side that answers its bridge calls, and the tests fake those, so
the whole suite runs without it.
DeviceKey called the SecureStorage facade itself. It now takes a KeyStore,
and the only one is the Keychain, which calls the same facade. Nothing
changes yet. The next commit adds a second store for builds without the
Secure Storage plugin.
Without the plugin, nothing answers SecureStorage.Get on a device, so
onboarding stopped at "could not read the device key". DEVNULL_KEY_STORE
picks the store. It defaults to the Keychain when the plugin is installed
and to a file in storage encrypted with APP_KEY when it isn't. APP_KEY ships
in the app, so the file is only for running it without a plugin licence,
never for release builds.

Tests always use the Keychain, so they fake the same bridge calls with or
without the plugin.
The README covers composer setup:free, the encrypted-file key store and
DEVNULL_KEY_STORE. native:run copies the app and runs composer install on
the copy, and that install inherits COMPOSER, so building takes the same
COMPOSER=composer.free.json prefix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonhamp
simonhamp merged commit 7383eb1 into NativePHP:main Oct 16, 2026
1 check passed
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.

2 participants