From 9e6d6f1c3972b49174a37530d940f3a81b6e0eba Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Wed, 8 Jul 2026 12:11:18 +0700 Subject: [PATCH] fix: switch to Coracle's nostr-signer-capacitor-plugin fork + correct API The chebizarro npm version has a different API to the Coracle fork that Welshman/Coracle actually use in production. Now using: github:coracle-social/nostr-signer-capacitor-plugin#main Correct API (from Welshman nip55.js source): NostrSignerPlugin.setPackageName(packageName: string) // string not object NostrSignerPlugin.getPublicKey(packageName?: string) // packageName as arg NostrSignerPlugin.isExternalSignerInstalled(packageName?) Co-authored-by: shakespeare.diy --- package.json | 4 ++-- release-notes.txt | 9 ++++---- src/components/auth/LoginDialog.tsx | 34 +++++++++++++++++------------ 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 1667cb3..5b31af7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "skate-spots", "private": true, - "version": "1.0.32", + "version": "1.0.33", "type": "module", "homepage": "https://skate-spots.com", "scripts": { @@ -83,7 +83,7 @@ "leaflet.markercluster": "^1.5.3", "lucide-react": "^0.462.0", "ngeohash": "^0.6.3", - "nostr-signer-capacitor-plugin": "^0.0.5", + "nostr-signer-capacitor-plugin": "github:coracle-social/nostr-signer-capacitor-plugin#main", "nostr-tools": "^2.13.0", "npubcash-sdk": "^0.2.0", "qrcode": "^1.5.4", diff --git a/release-notes.txt b/release-notes.txt index 7afb4f4..b520d5a 100644 --- a/release-notes.txt +++ b/release-notes.txt @@ -1,6 +1,5 @@ -v1.0.32 — Amber login via native Capacitor plugin +v1.0.33 — Amber login via Coracle's Capacitor plugin (correct fork + correct API) -- Replaced all URL-scheme hacks with nostr-signer-capacitor-plugin -- Plugin uses native Android intents directly — no nostrsigner: URL, no intent: URL, no encoding issues -- This is how Coracle and other proper Capacitor apps do it -- Requires: npm run android:build && cap sync android (plugin needs native sync) +- Switched to coracle-social/nostr-signer-capacitor-plugin (same fork Coracle uses in production) +- Fixed API calls to match Coracle fork: setPackageName(string) and getPublicKey(packageName) +- Requires: npm install && npx cap sync android after git pull diff --git a/src/components/auth/LoginDialog.tsx b/src/components/auth/LoginDialog.tsx index 4f43434..dee5cfd 100644 --- a/src/components/auth/LoginDialog.tsx +++ b/src/components/auth/LoginDialog.tsx @@ -35,28 +35,34 @@ export const LoginDialog: React.FC = ({ isOpen, onClose, onLog const isAndroid = /Android/i.test(navigator.userAgent); + const AMBER_PACKAGE = 'com.greenart7c3.nostrsigner'; + const handleAmberLogin = async () => { setAmberStep('loading'); setAmberError(''); try { - // Use the Capacitor plugin for native intent-based NIP-55 communication. - // This is the correct approach for Capacitor APKs — it uses Android intents - // directly, not URL schemes from JavaScript (which don't work reliably). - const { default: NostrSignerPlugin } = await import('nostr-signer-capacitor-plugin'); - - // Set Amber's package name - await NostrSignerPlugin.setPackageName({ packageName: 'com.greenart7c3.nostrsigner' }); - + // Use the Capacitor plugin for native Android intent-based NIP-55. + // We use Coracle's fork API (github:coracle-social/nostr-signer-capacitor-plugin) + // which is the battle-tested version used in production by Coracle. + // + // API (Coracle fork — different from chebizarro's npm version): + // setPackageName(packageName: string): Promise + // getPublicKey(packageName?: string): Promise<{ npub: string; package: string }> + const { NostrSignerPlugin } = await import('nostr-signer-capacitor-plugin'); + + // Set package name first (Coracle fork takes string, not object) + await NostrSignerPlugin.setPackageName(AMBER_PACKAGE); + // Check Amber is installed - const { installed } = await NostrSignerPlugin.isExternalSignerInstalled(); + const { installed } = await NostrSignerPlugin.isExternalSignerInstalled(AMBER_PACKAGE); if (!installed) { - throw new Error('Amber is not installed. Install it from Zapstore or F-Droid.'); + throw new Error('Amber is not installed. Get it from Zapstore or F-Droid.'); } - // Request pubkey — opens Amber, user approves, returns npub - const { npub } = await NostrSignerPlugin.getPublicKey(); - - // Convert npub to hex pubkey + // Request pubkey — opens Amber natively, user approves, promise resolves + const { npub } = await NostrSignerPlugin.getPublicKey(AMBER_PACKAGE); + + // Convert npub → hex pubkey const { nip19 } = await import('nostr-tools'); const decoded = nip19.decode(npub); if (decoded.type !== 'npub') throw new Error('Invalid pubkey from Amber');