feat: scaffold Antonym fashion store
Anonymous Bitcoin-only fashion e-commerce with: - Vue 3 + Tailwind 4 frontend with glassmorphism dark/light design system - Express 5 + SQLite backend with BTCPay Server integration - Nostr identity (NIP-07/keypair) for anonymous purchase tracking - ChaCha20-Poly1305 encrypted shipping addresses - Admin panel with order/product/stock management - SVG logo splash animation with clip-path reveal - 5 seeded products across 4 categories Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
28
server/lib/nostr.ts
Normal file
28
server/lib/nostr.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
export async function sendDm(recipientPubkey: string, message: string): Promise<void> {
|
||||
const privkeyHex = process.env.NOSTR_PRIVATE_KEY
|
||||
if (!privkeyHex || !recipientPubkey) return
|
||||
|
||||
try {
|
||||
const { finalizeEvent } = await import('nostr-tools/pure')
|
||||
const { encrypt } = await import('nostr-tools/nip04')
|
||||
const privkey = Uint8Array.from(Buffer.from(privkeyHex, 'hex'))
|
||||
const ciphertext = await encrypt(privkey, recipientPubkey, message)
|
||||
const event = finalizeEvent({ kind: 4, created_at: Math.floor(Date.now() / 1000), tags: [['p', recipientPubkey]], content: ciphertext }, privkey)
|
||||
privkey.fill(0)
|
||||
|
||||
const { Relay } = await import('nostr-tools/relay')
|
||||
const relays = ['wss://relay.damus.io', 'wss://nos.lol', 'wss://relay.nostr.band']
|
||||
for (const url of relays) {
|
||||
try { const relay = await Relay.connect(url); await relay.publish(event); relay.close() } catch {}
|
||||
}
|
||||
} catch { console.error('Failed to send Nostr DM') }
|
||||
}
|
||||
|
||||
export async function notifyOrderConfirmed(pubkey: string, orderId: string, totalSats: number): Promise<void> {
|
||||
await sendDm(pubkey, `Your Antonym order ${orderId} for ${totalSats.toLocaleString()} sats has been confirmed. Track it at: ${process.env.SITE_URL || 'http://localhost:3333'}/order/${orderId}`)
|
||||
}
|
||||
|
||||
export async function notifyStatusUpdate(pubkey: string, orderId: string, status: string, note?: string): Promise<void> {
|
||||
const noteText = note ? ` — ${note}` : ''
|
||||
await sendDm(pubkey, `Your Antonym order ${orderId} has been updated to: ${status}${noteText}`)
|
||||
}
|
||||
Reference in New Issue
Block a user