dostr_nip55 0.1.0
dostr_nip55: ^0.1.0 copied to clipboard
NIP-55 Android signer for Nostr, to log in, sign and encrypt with a signer app from a Flutter app, without depending on dostr_flutter.
0.1.0 #
- Initial release, moved out of the
ndk_flutterpackage. It does not depend ondostr_flutter. The native side is now its own Android plugin,Nip55Plugin, on thedostr_nip55method channel. Nip55EventSigneris nowNip55Signer, after theNostrSignerit implements. TheNip55Signerthat talks to the signer app is nowNip55SignerApp, andNip55Signertakes it assignerAppinstead ofnip55Signer.encryptNip44anddecryptNip44takerecipientPubkeyandsenderPubkey, as inNostrSigner, instead ofrecipientPubKeyandsenderPubKey. Thenip04Encrypt,nip04Decrypt,nip44Encryptandnip44Decryptmethods ofNip55SignerApptakepubkeyinstead ofpubKey.- As in
NostrSigner,encryptanddecryptare nowencryptNip04anddecryptNip04, with named parameters, the four encryption methods return aFuture<String>instead of aFuture<String?>,canSignis a getter,getPublicKey()is thepublicKeygetter, andrequiresInteractiveSigning,requiresSignerNetworkandsignerTransportRelayUrlsare gone. - Given an npub,
Nip55Signerkeeps its pubkey in hex, sopublicKeyis the hex pubkey that it sends ascurrent_user. signthrows anArgumentErrorfor an event of another pubkey, and aSignerRequestFailedExceptionwhen the signer app returns an invalid event or one signed by another account. It used to return that event, and to reject an invalid one with aSignerRequestRejectedException.- A queued request that
disposedrops fails with aSignerRequestFailedExceptioninstead of aSignerRequestRejectedException.disposealso fails the requests the signer app has not answered yet, and stops the plugin from waiting for them. The pending requests are thePendingSignRequest,PendingEncryptRequestandPendingDecryptRequestofdostr_signer. - Only a refusal of the user, which NIP-55 marks with
rejected, throws aSignerRequestRejectedException. A request with no usable answer throws aSignerRequestFailedExceptioninstead: no activity to open the signer app from, a signer app that cannot be opened, a result code other thanRESULT_OK, or an answer with no result. - When the user told the signer app to always reject a request, the Content Resolver answer rejects it, instead of opening the signer app to ask again, as NIP-55 requires.
- The Content Resolver is queried on a background thread instead of the main thread, which froze the UI while the signer app answered.
- Off Android,
Nip55Signer.canSignis false and every request throws anUnsupportedError, asNostrSignerrequires, instead of aSignerRequestRejectedException.isAppInstalledis false there, andNip55SignerApp.isSupportedtells whether the platform has NIP-55 signer apps.canSignfollowsNip55SignerApp.isAvailable, which a fake signer app can override to run off Android. isAppInstalledchecks the signer app ofpackagewhen it is set.Nip55Signertakes an optionalverifier, which checks the signature of every event the signer app signs.getPublicKeyandgetPublicKeyHexare gone:loginreturns the pubkey and the signer app package. Instead of returningnull,loginthrows aSignerRequestRejectedExceptionwhen the user refuses, and aSignerRequestFailedExceptionwhen no key comes back, such as when the signer app cannot be opened.cancelRequestalso stops the plugin from waiting for the answer of the signer app, throughNip55SignerApp.cancelRequest, which frees the slot of the request. A request cancelled while the plugin queries the Content Resolver no longer opens the signer app.- Two
Nip55Signernever use the same request id, so the answers and cancellations of two accounts no longer get mixed up. - When the signer app answers a request through the Intent of another request, that other request fails instead of waiting forever. It no longer takes the answer when the request it names is not waiting anymore, such as after
cancelRequest.