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-coreUsage
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, timestampProcessResult- Result with action ('accept' | 'reject') and optional message
License
MIT