kernl API
    Preparing search index...

    Function createPrivateMessagesBackend

    • A MessagingBackend for private messages (NIP-17) over the active account's signer.

      Sending builds a kind 14 rumour, seals it once per recipient and once for the user in a kind 13 event signed by signer() and encrypted with its nip44, and wraps each seal in a kind 1059 event signed by an ephemeral key that lives only inside an applesauce PrivateKeySigner for that one wrap. Each wrap goes to its recipient's kind 10050 inbox relays, or to the outbox and super tiers when they publish none. Receiving subscribes to kind 1059 events tagged with the user on the user's own inbox relays and opens them with applesauce's gift-wrap helpers and the same signer; a wrap that does not open, or holds anything but a kind 14 rumour, is ignored.

      Conversation ids are the sorted participant set, the user included, so both sides of a conversation use the same id. Message ids are the rumour id, so the copy addressed to the user is not filed twice.

      Parameters

      Returns MessagingBackend

      A backend for the private provider; available while the signer has nip44.

      const backend = createPrivateMessagesBackend({
      store: kernl.eventStore,
      pool: kernl.pool,
      tiers: kernl.relays,
      signer: () => kernl.accounts.active,
      selfPubkey: () => kernl.accounts.active?.pubkey,
      });
      await backend.send({ recipients: [alice], content: 'hello' });