Embed @napi-rs/keyring native bindings for all CLI release targets#1611
Merged
ChiragAgg5k merged 2 commits intoJun 24, 2026
Conversation
The CLI publish workflow cross-compiles all six bun targets on one Linux host after a single `bun install`. @napi-rs/keyring ships its native binding as os/cpu-gated platform packages, so that install only fetches the host's (@napi-rs/keyring-linux-x64-gnu). bun --compile embeds a binding only when its platform package is present on disk, so every non-linux-x64 binary shipped with no binding and silently fell back to plaintext credential storage at runtime (the keyring code itself landed earlier; this is the missing build half). Fetch each target's platform package (direct npm tarball, which bypasses the os/cpu install skip) before cross-compiling so every released binary embeds its native keyring binding.
Contributor
Greptile SummaryThis PR updates the CLI publish workflow to include keyring native bindings in release binaries. The main changes are:
Confidence Score: 5/5The workflow-only change is merge-safe and directly addresses the missing native package inputs for cross-compiled CLI release targets. The update is narrowly scoped to the publish workflow, fetches the expected platform packages before compilation, and has no accepted code issues.
What T-Rex did
Reviews (2): Last reviewed commit: "Split keyring binding fetch into its own..." | Re-trigger Greptile |
Self-documenting step names (Install / Fetch keyring native bindings / Build) replace the comment; read the version with bun instead of sed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The compiled CLI binaries ship without the
@napi-rs/keyringnative binding for every target exceptlinux-x64, so on macOS/Windows/linux-arm64 the CLI silently stores OAuth refresh tokens in plaintext (~/.appwrite/prefs.json) instead of the OS keychain. No crash — silent downgrade.Reproduced on a released
22.2.1Homebrew binary (darwin-arm64): the native keyring symbols are absent, andappwrite loginwrites the refresh token in plaintext.Root cause
The keyring loader code (literal per-platform
require) shipped already. The missing half is the build:templates/cli/.github/workflows/publish.ymlcross-compiles all sixbun --compiletargets on a singleubuntu-latesthost after onebun install --frozen-lockfile.@napi-rs/keyring's native binding is delivered asos/cpu-gated platform packages, so that install only fetches the host's —@napi-rs/keyring-linux-x64-gnu.bun --compileembeds a.nodeonly when its platform package is present on disk, so every other target (darwin-arm64,darwin-x64,linux-arm64,win32-*) is compiled with no binding to embed and falls back to plaintext at runtime. bun does not error on the missing cross-target package — it silently omits it, which is why the broken build shipped green.Fix
Before cross-compiling, fetch each target's platform package directly from the npm registry (a plain tarball extract, which bypasses the
os/cpuinstall skip) intonode_modules, sobun --compilecan embed the matching.nodefor every target.Verified locally
linux-x64on macOS with its platform package missing → builds fine, 0 embedded bindings (reproduces the shipped bug).Scope
publish.ymliscopyscope; only the template is committed (generatedexamples/cliis gitignored).sdk-for-cliand cut a22.2.2so released binaries actually use the keychain. The access token stays inprefs.jsonby design (short-lived); only the long-lived refresh token moves to the keychain.