dostr_nip07 0.1.0
dostr_nip07: ^0.1.0 copied to clipboard
NIP-07 browser extension signer for Nostr, to sign and encrypt with the user's extension from any Dart web app, without Flutter.
0.1.0 #
- Initial release, moved out of the
ndk_flutterpackage. It does not depend on Flutter, so pure Dart web apps can use it. It replaces thenip07_event_signerpackage. Nip07EventSigneris nowNip07Signer, after theNostrSignerit implements.encryptNip44anddecryptNip44takerecipientPubkeyandsenderPubkey, as inNostrSigner, instead ofrecipientPubKeyandsenderPubKey.- 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. - BREAKING A
Nip07Signerknows the user's pubkey from the start, sopublicKeynever throws:Nip07Signer.connect()completes once the extension sent it, andNip07Signer(publicKey: ...)takes it, for an account restored from storage, instead ofcachedPublicKey.getPublicKeyAsyncis gone, andNip07Signer.isAvailabletells whether the browser has an extension, asNip07Signer().canSigndid. Nip07Signer(publicKey: ...)throws aFormatExceptionfor a pubkey that is not 64 lowercase hex characters, asconnectalready failed on one.connecttakes atimeout, 10 minutes by default, and throws aSignerRequestFailedExceptiononce it passes without a pubkey. It used to wait forever.Nip07Signer.waitForExtension()waits for an extension that addswindow.nostrafter the page loads.Nip07Signerandconnecttake an optionalverifier, which checks the signature of every event the extension signs.signthrows anArgumentErrorfor an event of another pubkey, and aSignerRequestFailedExceptionwhen the extension returns an invalid event or signs as another account, such as after the user switched accounts in it. It used to return that event.- Without an extension, every request throws a
StateErrorinstead of anException, and an extension without NIP-04 or NIP-44 fails the request with aSignerRequestFailedExceptioninstead of aSignerRequestRejectedException. - A request the extension rejects throws a
SignerRequestRejectedException, whether the user refused it or the extension failed, since NIP-07 does not tell the two apart. An answer the signer cannot use, such as a decrypted text that is not a string, throws aSignerRequestFailedException. disposefails the requests the extension has not answered yet with aSignerRequestFailedException, instead of leaving them waiting.- Request ids are unique across signers.
- The pending requests are the
PendingSignRequest,PendingEncryptRequestandPendingDecryptRequestofdostr_signer, so asking for the pubkey is no longer one.