Implement Nostr WebSocket relay publishing #129

Open
opened 2026-06-21 15:49:16 +00:00 by jmiller · 0 comments
Owner

Summary

The Nostr service plugin (plg_mokosuitecross_nostr) is an explicit stub. The publish() method returns a failure with "Nostr WebSocket relay publishing is not yet implemented."

File: source/packages/plg_mokosuitecross_nostr/src/Extension/NostrService.php

What's needed

Nostr uses the NIP-01 protocol which requires:

  1. Event creation — Build a kind-1 (text note) event JSON with content, pubkey, created_at, tags
  2. Event signing — Sign the event with the user's private key (secp256k1 Schnorr signature)
  3. Relay publishing — Open a WebSocket connection to configured relay(s) and send ["EVENT", event]
  4. Response handling — Wait for ["OK", event_id, true/false, message] from the relay

Challenges

  • PHP has no built-in WebSocket client — need a library like textalk/websocket or implement raw socket
  • secp256k1 Schnorr signatures require ext-secp256k1 or a pure-PHP implementation
  • Multiple relays may need to be supported (comma-separated relay URLs)

Current credential fields

Check the service form XML for which credential fields are defined (likely private_key and relay_urls).

Acceptance Criteria

  • publish() creates a valid NIP-01 kind-1 event
  • Event is properly signed with the configured private key
  • Event is published to at least one configured relay via WebSocket
  • validateCredentials() verifies the private key format and relay connectivity
  • Success response includes the event ID as platform_post_id
## Summary The Nostr service plugin (`plg_mokosuitecross_nostr`) is an explicit stub. The `publish()` method returns a failure with "Nostr WebSocket relay publishing is not yet implemented." **File**: `source/packages/plg_mokosuitecross_nostr/src/Extension/NostrService.php` ## What's needed Nostr uses the [NIP-01 protocol](https://github.com/nostr-protocol/nips/blob/master/01.md) which requires: 1. **Event creation** — Build a kind-1 (text note) event JSON with content, pubkey, created_at, tags 2. **Event signing** — Sign the event with the user's private key (secp256k1 Schnorr signature) 3. **Relay publishing** — Open a WebSocket connection to configured relay(s) and send `["EVENT", event]` 4. **Response handling** — Wait for `["OK", event_id, true/false, message]` from the relay ### Challenges - PHP has no built-in WebSocket client — need a library like `textalk/websocket` or implement raw socket - secp256k1 Schnorr signatures require `ext-secp256k1` or a pure-PHP implementation - Multiple relays may need to be supported (comma-separated relay URLs) ### Current credential fields Check the service form XML for which credential fields are defined (likely `private_key` and `relay_urls`). ## Acceptance Criteria - [ ] `publish()` creates a valid NIP-01 kind-1 event - [ ] Event is properly signed with the configured private key - [ ] Event is published to at least one configured relay via WebSocket - [ ] `validateCredentials()` verifies the private key format and relay connectivity - [ ] Success response includes the event ID as `platform_post_id`
Sign in to join this conversation.
No labels
Priority Medium
Type Feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoSuiteCross#129