Skip to main content

dostr_nip46 0.1.0 copy "dostr_nip46: ^0.1.0" to clipboard
dostr_nip46: ^0.1.0 copied to clipboard

NIP-46 remote signing for Nostr, to connect to a bunker with a bunker:// or nostrconnect:// URL and sign and encrypt through it.

example/dostr_nip46_example.dart

import 'package:dostr_bip340/dostr_bip340.dart';
import 'package:dostr_core/dostr_core.dart';
import 'package:dostr_nip46/dostr_nip46.dart';

/// `dart run example/dostr_nip46_example.dart 'bunker://<pubkey>?relay=wss://...&secret=...'`
Future<void> main(List<String> args) async {
  final relayManager = RelayManager(
    nostrTransportFactory: webSocketTransportFactory(),
  );
  final bunkers = Bunkers(
    relayReqs: RelayReqs(
      relayManager: relayManager,
      eventVerifier: Bip340EventVerifier(),
    ),
    relayPublishes: RelayPublishes(relayManager: relayManager),
    signerFactory: const Bip340SignerFactory(),
  );

  final connection = await bunkers.connectWithBunkerUrl(
    args.first,
    clientMetadata: const Nip46ClientMetadata(name: 'dostr_nip46 example'),
    authCallback: (url) => print('approve the connection at $url'),
  );
  final signer = await bunkers.createSigner(connection);
  final note = await signer.sign(
    Nip01Event(pubkey: signer.publicKey, kind: 1, tags: [], content: 'hello'),
  );
  print(note.toJsonString());
  await signer.dispose();

  await relayManager.dispose();
}
0
likes
160
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

NIP-46 remote signing for Nostr, to connect to a bunker with a bunker:// or nostrconnect:// URL and sign and encrypt through it.

Repository (GitHub)
View/report issues

Topics

#nostr #dostr #nip46 #signer

License

MIT (license)

Dependencies

dostr_core, rxdart

More

Packages that depend on dostr_nip46