diff --git a/src/lib/capacitorAmberSigner.ts b/src/lib/capacitorAmberSigner.ts index 22be76c..1f4e458 100644 --- a/src/lib/capacitorAmberSigner.ts +++ b/src/lib/capacitorAmberSigner.ts @@ -133,8 +133,23 @@ export async function getAmberPublicKeyViaPlugin(): Promise { throw new Error('Amber signing is only available in the SkateSpots Android app.'); } + // Request ALL permissions the app will need UP FRONT, so Amber pre-authorizes + // signing + encryption at login time. Without this, later signEvent/encrypt + // calls trigger a per-action permission check that, on GrapheneOS, routes + // through Amber's ContentProvider and stalls WITHOUT ever showing a prompt — + // the "Amber never pops up, delete hangs" bug. Pre-granting means signing + // afterwards is a fast background round-trip with no surprise stall. + const permissions = JSON.stringify([ + { type: 'get_public_key' }, + { type: 'sign_event' }, + { type: 'nip04_encrypt' }, + { type: 'nip04_decrypt' }, + { type: 'nip44_encrypt' }, + { type: 'nip44_decrypt' }, + ]); + const result = await withTimeout( - plugin.getPublicKey({ permissions: JSON.stringify([{ type: 'get_public_key' }]) }), + plugin.getPublicKey({ permissions }), 'login', );