JSPM

@nostr-mail/bridge-core

1.2.6
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 38
    • Score
      100M100P100Q72248F
    • License MIT

    Core library for email to Nostr bridge

    Package Exports

    • @nostr-mail/bridge-core
    • @nostr-mail/bridge-core/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@nostr-mail/bridge-core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    @nostr-mail/bridge-core

    Core library for the Nostr Mail Bridge inbound system. Handles email-to-Nostr message processing using NIP-59 gift wrap encryption.

    Installation

    npm i @nostr-mail/bridge-core

    Usage

    import { processIncomingEmail, initConfig, type IncomingEmail } from '@nostr-mail/bridge-core';
    
    // Initialize configuration
    initConfig({
      inboundPrivateKey: 'your-hex-private-key',
      relays: ['wss://relay.damus.io', 'wss://nos.lol'],
      pluginPath: './plugin.js', // optional
    });
    
    // Process an incoming email
    const email: IncomingEmail = {
      from: 'sender@example.com',
      to: 'npub1abc...@nostr-mail.example.com',
      subject: 'Hello',
      body: 'Message content',
      timestamp: Math.floor(Date.now() / 1000),
    };
    
    const result = await processIncomingEmail(email, 'smtp', '127.0.0.1');
    
    if (result.action === 'accept') {
      console.log('Email processed successfully');
    } else {
      console.log('Email rejected:', result.message);
    }

    API

    initConfig(config)

    Initialize the core configuration.

    processIncomingEmail(email, sourceType, sourceIP)

    Process an incoming email and publish it to Nostr relays as a NIP-59 gift wrap.

    Types

    • IncomingEmail - Email structure with from, to, subject, body, timestamp
    • ProcessResult - Result with action ('accept' | 'reject') and optional message

    License

    MIT