Home

Awesome

nodestr

A nip07 provider and polyfill for node js.

Depends on the @nostr-tools package.

Installation

npm i nodestr

Implementation Roadmap

Usage

const { Nip07Provider } = require("nodestr");

// Instantiate the NIP07Provider with a ConfigObject and register its methods on the global object.
new Nip07Provider({
    secretKeyMethod: "file",
    keyFilePath: "/your/path/to/keyfile",
}).register();

// Once the provider is registered it will polyfill the global window object with nip07 methods:
window.nostr
    .signEvent({
        kind: 1,
        content: "This is a test",
        tags: [],
        created_at: Math.floor(Date.now() / 1000),
    })
    .then((event) => {
        console.log(event);
    });

window.nostr.getPublicKey().then((pubkey) => {
    console.log(pubkey);
});

Config Object

type ProviderConfig = {
    secretKeyMethod: "throwaway" | "file" | "nip46";
    keyFilePath?: string;
};