npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@welshman/signer

v0.0.17

Published

A nostr signer implemenation supporting several login methods.

Downloads

644

Readme

@welshman/signer version

Implementations of signer utilities and classes.

Nips supported

  • NIP 01 (private key login)
  • NIP 07
  • NIP 46
  • NIP 55
  • NIP 59 (gift wrapping, works with any signer that supports encryption)

Examples

NIP 01

import {makeSecret, Nip01Signer} from '@welshman/signer'

const signer = Nip01Signer.fromSecret(makeSecret())

NIP 07

import {getNip07, Nip07Signer} from '@welshman/signer'

if (getNip07()) {
  const signer = new Nip07Signer()
}

NIP 55

import {getNip07, Nip07Signer} from '@welshman/signer'

if (getNip07()) {
  const signer = new Nip07Signer()
}

NIP 46

import {createEvent, NOTE} from '@welshman/util'
import {makeSecret, Nip46Broker, Nip46Signer} from '@welshman/signer'

const clientSecret = makeSecret()
const relays = ['wss://relay.signer.example/']
const broker = Nip46Broker.get({relays, clientSecret})
const signer = new Nip46Signer(broker)
const ncUrl = broker.makeNostrconnectUrl({name: "My app"})
const abortController = new AbortController()

let response
try {
  response = await broker.waitForNostrconnect(url, abortController)
} catch (e: any) {
  if (e?.error) {
    showWarning(`Received error from signer: ${e.error}`)
  } else if (e) {
    console.error(e)
  }
}

if (response) {
  // Now we know the bunker's pubkey and can do stuff with the signer
  const signerPubkey = response.event.pubkey

  // Next time we want to use our signer, we can instantiate it like so:
  const newBroker = Nip46Broker.get({relays, clientSecret, signerPubkey})
  const newSigner = new Nip46Signer(newBroker)
}

Using signers

import {createEvent, NOTE, DIRECT_MESSAGE} from '@welshman/util'

const signer = // Create your signer...
const nip59 = Nip59.fromSigner(signer)

// Sign an event
const event = await signer.sign(createEvent(NOTE, {content: "hi"}))

// Wrap a NIP 17 DM
const rumor = await nip59.wrap(recipientPubkey, createEvent(DIRECT_MESSAGE, {content: "hi"}))

// Note that it returns a rumor; be sure to publish the `wrap`
const wrap = rumor.wrap