feat(market): migrate order DMs to NIP-17 (NIP-44 + NIP-59) #39
No reviewers
Labels
No labels
app:activities
app:chat
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp!39
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/market-nip17-messaging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Migrate the customer-facing market module from deprecated NIP-04 (kind 4) to NIP-17 private direct messages (NIP-44 v2 encryption + NIP-59 gift wrap, kind 1059).
Why now: The companion change in the nostrmarket LNbits extension (aiolabs/nostrmarket#2) refactors the merchant backend to subscribe to kind 1059 gift wraps and ignore kind 4. Without this webapp change, customer orders can never reach merchants.
A test order on aio-demo confirmed the breakage: the customer published a kind 4 NIP-04 event, the merchant's refactored handler logged the event but never created an invoice (the dispatcher only routes kind 1059 now).
Changes
src/modules/market/services/nostrmarketService.tspublishOrder()now produces a NIP-59 gift-wrapped event:nip59.wrapEvent()from nostr-tools 2.10.4 builds the full three-layer envelope (unsigned kind 14 rumor, kind 13 seal signed by sender, kind 1059 gift wrap signed by ephemeral key with#precipient tag).src/modules/market/composables/useMarket.tsregisterMarketMessageHandler(): bypasseschatService.setMarketMessageHandler(chat is still on NIP-04) and subscribes the market directly to{kinds: [1059], '#p': [userPubkey]}viarelayHub.subscribe. Comment notes that when chat migrates to NIP-17, it can take over routing again viasetMarketMessageHandler.handleOrderDM(): replacesnip04.decrypt(userPrivkey, event.pubkey, event.content)withnip59.unwrapEvent(event, prvkeyBytes). The merchant's real pubkey is read fromrumor.pubkey(the gift wrap's pubkey is ephemeral). The JSONtypeswitch (1=payment_request, 2=status_update) is unchanged.Out of scope
src/modules/chat/services/chat-service.ts— handles general chat, still NIP-04. Migrate in a separate PR.Test plan
npm run build)🎁 Order gift-wrappedand a kind 1059 event is published_handle_gift_wrapruns and an invoice is generated (no more "Unhandled event kind: 4")Related
🤖 Generated with Claude Code
The dev SPA-fallback plugin used `!req.url.includes('.')` to skip asset requests, which also matched JWT-shaped `?token=hdr.body.sig` query strings — so `localhost:5185/?token=...` fell through to the hub `index.html` instead of `market.html`, breaking the hub→standalone auth-relay link. Strip the query before the extension check. Applied to all 7 standalone vite configs.