JSPM

applesauce-signers

4.1.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 529
    • Score
      100M100P100Q100055F
    • License MIT

    Signer classes for applesauce

    Package Exports

    • applesauce-signers
    • applesauce-signers/helpers
    • applesauce-signers/helpers/encryption
    • applesauce-signers/helpers/index
    • applesauce-signers/helpers/nostr-connect
    • applesauce-signers/signers
    • applesauce-signers/signers/amber-clipboard-signer
    • applesauce-signers/signers/extension-signer
    • applesauce-signers/signers/index
    • applesauce-signers/signers/nostr-connect-provider
    • applesauce-signers/signers/nostr-connect-signer
    • applesauce-signers/signers/password-signer
    • applesauce-signers/signers/private-key-signer
    • applesauce-signers/signers/readonly-signer
    • applesauce-signers/signers/serial-port-signer
    • applesauce-signers/signers/simple-signer

    Readme

    applesauce-signer

    A collection of signer classes for applesauce that are compatible with the NIP-07 API.

    Documentation

    For detailed documentation and API reference, see:

    Available Signers

    Password Signer (NIP-49)

    A secure signer that encrypts private keys using NIP-49.

    // Create a new password signer
    const signer = new PasswordSigner();
    
    // Set up with a new key and password
    const randomBytes = new Uint8Array(64);
    window.crypto.getRandomValues(randomBytes);
    
    signer.key = randomBytes;
    signer.setPassword("your-password");
    
    // Unlock the signer when needed
    await signer.unlock("your-password");

    Simple Signer

    A basic signer that holds the secret key in memory with NIP-04 and NIP-44 encryption support.

    // Create new signer with random key
    const signer = new PrivateKeySigner();
    
    // Or import existing key
    const key = new Uint8Array(32);
    window.crypto.getRandomValues(key);
    const signer = new PrivateKeySigner(key);

    Nostr Connect Signer (NIP-46)

    A client-side implementation for remote signing using NIP-46.

    // First, set up the required relay communication methods
    import { Observable } from "rxjs";
    
    // Define subscription method for receiving events
    const subscriptionMethod = (filters, relays) => {
      return new Observable((observer) => {
        // Create subscription to relays
        const cleanup = subscribeToRelays(relays, filters, (event) => {
          observer.next(event);
        });
        return () => cleanup();
      });
    };
    
    // Define publish method for sending events
    const publishMethod = async (event, relays) => {
      for (const relay of relays) await publishToRelay(relay, event);
    };
    
    // You can set these methods globally at app initialization
    NostrConnectSigner.subscriptionMethod = subscriptionMethod;
    NostrConnectSigner.publishMethod = publishMethod;
    
    // Now create and use the signer
    const signer = new NostrConnectSigner({
      remote: "<remote signer pubkey>",
      relays: ["wss://relay.example.com"],
      // Or pass methods directly to the constructor
      subscriptionMethod,
      publishMethod,
    });
    
    // Create a connection URI for your app
    const uri = signer.getNostrConnectURI({
      name: "My App",
      url: "https://example.com",
      permissions: NostrConnectSigner.buildSigningPermissions([0, 1, 3]),
    });
    
    // Connect using bunker URI
    const bunkerSigner = await NostrConnectSigner.fromBunkerURI("bunker://...your-uri-here...", {
      permissions: NostrConnectSigner.buildSigningPermissions([0, 1, 3]),
    });

    Other Signers

    • Serial Port Signer: For hardware signing devices (Chrome browsers only)
    • Amber Clipboard Signer: Integration with Amber wallet's web API