Commit graph

51 commits

Author SHA1 Message Date
25023df8bd Add keypair rotation detection and migration feature
When a user rotates their Nostr keypair in account settings, the
merchant still holds the old key. This adds:

- key_mismatch flag on MerchantConfig (runtime, not persisted) -
  detected on each GET /api/v1/merchant by comparing account vs
  merchant pubkey
- POST /api/v1/merchant/{id}/migrate-keys endpoint that updates
  the merchant keys, republishes all stalls/products under the new
  identity, and resubscribes
- Warning banner in the UI with a "Migrate Keys" button and
  confirmation dialog
- update_merchant_keys() crud function

Orders and DM history are preserved since they reference customer
pubkeys. Old stall/product events on relays become orphaned.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-03 16:59:03 +02:00
725944ae9c Replace NIP-04 messaging with NIP-17 (NIP-44 + NIP-59 gift wrapping)
Modernize the entire customer-merchant communication layer from deprecated
NIP-04 (kind 4, AES-256-CBC) to NIP-17 private direct messages using
NIP-44 v2 encryption (ChaCha20 + HMAC-SHA256) and NIP-59 gift wrapping
(rumor/seal/gift-wrap protocol). No backwards compatibility retained.

New modules:
- nostr/nip44.py: NIP-44 v2 encryption verified against official spec vectors
- nostr/nip59.py: NIP-59 gift wrap with wrap/unwrap convenience functions
- tests/: 44 unit tests for NIP-44 and NIP-59

Key changes:
- Subscription filters: kind 4 → kind 1059 gift wraps
- Message handler: _handle_nip04_message → _handle_gift_wrap (unwrap + route)
- send_dm/reply_to_structured_dm: NIP-59 gift wrap to recipient + self-archive
- Merchant model: removed NIP-04 crypto methods (decrypt/encrypt/build_dm_event)
- helpers.py: removed NIP-04 functions, kept Schnorr signing + key normalization
- views_api.py: consolidated DM sending through send_dm() service function

Reliability improvements:
- Event deduplication via bounded LRU set in NostrClient
- Subscription health monitor (resubscribes after 120s of silence)
- Preserved 5-minute lenient time window from prior work

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-03 16:59:03 +02:00
319d5eeb04 Refactors type hints for clarity
Some checks failed
CI / lint (push) Has been cancelled
Updates type hints in `crud.py`, `helpers.py`, and `models.py` for improved readability and maintainability.

Replaces `Merchant | None` with `Optional[Merchant]` and `list[X]` with `List[X]` for consistency with standard Python typing practices.
2026-04-24 01:59:27 -04:00
c7f6b209dd TEMP: set merchant active to True by default 2026-04-24 01:59:27 -04:00
a8eeace36d Improve merchant creation with automatic keypair generation
Enhance the merchant creation process by automatically generating Nostr keypairs
for users who don't have them, and streamline the API interface.

Changes:
- Add CreateMerchantRequest model to simplify merchant creation API
- Auto-generate Nostr keypairs for users without existing keys
- Update merchant creation endpoint to use user account keypairs
- Improve error handling and validation in merchant creation flow
- Clean up frontend JavaScript for merchant creation

This ensures all merchants have proper Nostr keypairs for marketplace
functionality without requiring manual key management from users.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-24 01:59:27 -04:00
Ben Weeks
a21b5289c1 feat: add merchant profile edit, keys dialog, and publish to Nostr
- Add PATCH endpoint for updating merchant profile config
- Add website field to MerchantProfile model
- Fix to_nostr_event to include all profile fields (display_name, banner, website, nip05, lud16)
- Always publish merchant profile (kind 0) when publishing to Nostr
- Extract edit-profile-dialog and nostr-keys-dialog into separate components
- Fix profile avatar alignment to match original design
- Simplify keys dialog to show only npub QR code (no nsec QR)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 12:42:03 +00:00
Ben Weeks
c3dea9f01d feat: add merchant profile panel to Merchant tab
Display merchant profile information with:
- Banner image or grey placeholder
- Profile avatar with shadow
- Display name (or name fallback)
- About description
- NIP-05 verified identity indicator
- Lightning address (LUD16)

Extends MerchantProfile model with new fields:
display_name, banner, nip05, lud16

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 11:10:39 +00:00
dni ⚡
3a8c16d155
chore: add uv, add ci, fix some issues (#113)
in preparation of removing secp
2025-10-30 10:11:18 +01:00
Vlad Stan
de7fe059b8
V1 (#106)
Some checks failed
/ release (push) Has been cancelled
/ pullrequest (push) Has been cancelled
2024-11-06 11:50:21 +02:00
rleed
2020bd9838
Changes to deactivate/reactivate products (#89) 2024-11-04 10:59:04 +02:00
Vlad Stan
f29e77db7e
Custom shipping cost (#86)
* feat: simple UI for shipping zone per product

* feat: add empty cost

* fix: backwards compatible zones

* feat: finish UI for product shipping cost

* fix: some ui issues

* feat: add per product shipping cost

* feat: show receipt for product

* fix: publish per product shipping cost
2023-09-21 17:29:13 +03:00
Vlad Stan
2891474312
feat: add auto-reply on payment (#82) 2023-09-15 10:21:03 +03:00
Vlad Stan
f8fd28a5f2 fix: do not add a default for merchant time column 2023-07-11 08:56:37 +02:00
Vlad Stan
df5e894b8c feat: update shipping zone when re-issuing invoice 2023-07-04 17:15:20 +02:00
Vlad Stan
0a0e11e286 feat: show failed order error message 2023-07-04 16:20:08 +02:00
Vlad Stan
da284ba768 feat: prepare for merchant active/restoring state 2023-07-04 08:40:49 +02:00
Vlad Stan
33adae672d
Product delete (#64)
* feat: restore stalls from `nostr` as pending

* feat: stall and prod last update time

* feat: restore products and stalls as `pending`

* feat: show pending stalls

* feat: restore stall

* feat: restore a stall from nostr

* feat: add  blank `Restore Product` button

* fix: handle no talls to restore case

* feat: show restore dialog

* feat: allow query for pending products

* feat: restore products

* chore: code clean-up

* fix: last dm and last order query

* chore: code clean-up

* fix: subscribe for stalls and products on merchant create/restore

* feat: add message type to orders

* feat: simplify messages; code format

* feat: add type to DMs; restore DMs from nostr

* fix: parsing ints

* fix: hide copy button if invoice not present

* fix: do not generate invoice if product not found

* feat: order restore: first version

* refactor: move some logic into `services`

* feat: improve restore UX

* fix: too many calls to customer DMs

* fix: allow `All` customers filter

* fix: ws reconnect on server restart

* fix: query for customer profiles only one

* fix: unread messages per customer per merchant

* fix: disable `user-profile-events`

* fix: customer profile is optional

* fix: get customers after new message debounced

* chore: code clean-up

* feat: auto-create zone

* feat: fixed ID for default zone

* feat: notify order paid
2023-06-30 13:12:56 +03:00
Vlad Stan
6ec8d648ff fix: do not erase merchant profile 2023-04-19 10:27:47 +03:00
Vlad Stan
6e4247964b fix: missing image_urls 2023-04-06 11:57:50 +03:00
Vlad Stan
4996a6b7fd feat: add more images for product 2023-04-03 18:36:14 +03:00
Vlad Stan
a65017d04e fix: shipping cost; update UI on new order 2023-04-03 11:57:55 +03:00
Vlad Stan
87c0477b33 feat: keep track of new messages 2023-03-30 13:58:14 +03:00
Vlad Stan
9dac1d25b2 feat: keep customer profiles up to date 2023-03-30 13:58:14 +03:00
Vlad Stan
32695bf698 feat: stubs for sync from nostr 2023-03-24 15:10:30 +02:00
Vlad Stan
319d1a12d1 feat: send id in event content 2023-03-23 15:41:43 +02:00
Vlad Stan
dd4d677ce1 feat: allow delete merchant from nostr 2023-03-23 11:14:34 +02:00
Vlad Stan
fa6b07ff37 feat: optimize filtering for DMs 2023-03-14 14:31:30 +02:00
Vlad Stan
70effcc515 feat: store event_created_at for some events 2023-03-14 14:31:30 +02:00
Vlad Stan
c355e3111c feat: basic chat 2023-03-14 14:31:30 +02:00
Vlad Stan
5e6e9b8d26 feat: save incoming DMs 2023-03-14 14:31:30 +02:00
Vlad Stan
aa0d662a4f feat: handle order paid 2023-03-07 13:10:01 +02:00
Vlad Stan
f98e66038d feat: show more details about the order 2023-03-07 12:00:43 +02:00
Vlad Stan
fc02609d47 feat: show orders per stall 2023-03-07 10:31:25 +02:00
Vlad Stan
b7071d6796 feat: add address for order 2023-03-06 18:07:52 +02:00
Vlad Stan
dd47c6c64b refactor: extract simpler methods 2023-03-06 18:01:05 +02:00
Vlad Stan
8cdcb144b9 feat: send invoice back for order 2023-03-06 17:33:55 +02:00
Vlad Stan
12c32b019f feat: return payment-request for order 2023-03-06 16:31:34 +02:00
Vlad Stan
2912589b70 feat: create order on DM 2023-03-06 15:03:02 +02:00
Vlad Stan
3988933e40 feat: listen for direct messages 2023-03-03 18:24:53 +02:00
Vlad Stan
b9cf037565 feat: add currency to product 2023-03-03 11:30:48 +02:00
Vlad Stan
2ac7a9f63b feat: show stall ID 2023-03-03 11:23:09 +02:00
Vlad Stan
b6ae448bea feat: publish events for products 2023-03-03 11:08:55 +02:00
Vlad Stan
d261b0c7f3 feat: add to_nostr_event for product 2023-03-02 18:45:27 +02:00
Vlad Stan
dbf0cee6cb fat: add create product logic 2023-03-02 17:42:28 +02:00
Vlad Stan
8fbe3d33c3 chore: label updates 2023-03-02 14:25:23 +02:00
Vlad Stan
5ea6fec967 fix: store id for shipping zone 2023-03-02 13:41:10 +02:00
Vlad Stan
484cfaa14f feat: validate currency for stall shipping zones 2023-03-02 10:36:39 +02:00
Vlad Stan
639b4cb880 feat: publish event on C_UD for stalls 2023-03-02 10:14:11 +02:00
Vlad Stan
8ea5fbc113 feat: basic stall flow 2023-03-01 11:35:04 +02:00
Vlad Stan
fef4f349f2 feat: manage shipping zones 2023-02-28 16:30:09 +02:00