dephy_proto

Crates.iodephy_proto
lib.rsdephy_proto
version0.1.3
sourcesrc
created_at2023-11-07 16:29:02.405318
updated_at2023-11-17 21:13:38.922279
descriptionProtobuf definitions for DePHY messages.
homepagehttps://dephy.io/
repositoryhttps://github.com/dephy-io/dephy-message-proto
max_upload_size
id1028217
size5,256
Krhougs (krhougs)

documentation

README

Messaging in DePHY

The dephy-proto Package

There are packages for developpers to build applications with protobuf definitions in this repository.

cargo add dephy_proto # for Rust
npm install dephy-proto # for Node.js

The Rust crate is built with prost and published on crates.io.

The JavaScript/TypeScript package for Node.js and Deno is built with pbkit and published on NPM.

Direct Message

A Direct Message in DePHY is a message for DePHY devices and Edge Brokers to communicate directly in Protocol Buffer encoding.

It should be transferred in binary when interacting between the device and Edge Brokers’ service endpoints(MQTT or HTTP).

Usually, a DePHY device send Direct Messages to:

  • mqtt://path.to.dephy.edge:1883
    • topic: /dephy/signed_message
    • the message binary should be the payload
  • http://path.to.dephy.edge:3883/dephy/signed_message
    • method: POST
    • content-type: application/x-dephy
    • the message binary should be the HTTP body

Routed Message

A Routed Message in DePHY is a NoStr event wrapping a Direct Message which will be redistributed by Edge Brokers in a NoStr decentralized network:

  • The kind of the event should be 1111.
  • The content should be a Direct Message encoded in Base58 (a.k.a base58(bytes(SignedMessage))).
  • It should contain these tags:
    • c is the marker of a Routed Message and should be always dephy
    • dephy_from is the DID string of the message sender
    • dephy_to is the DID string of the message recipent
    • dephy_edge is the DID string of the message forwarder

And it looks like this:

{
  "id": "...",
  "pubkey": "...",
  "created_at": 0,
  "kind": 1111, // Magic!
  "content": "...", // base58(bytes(SignedMessage))
  "tags": [
    ["c", "dephy"],
    ["dephy_to", "did:dephy:0x..."], // did(direct_message.payload.to)
    ["dephy_from", "did:dephy:0x..."], // did(direct_message.payload.from)
    ["dephy_edge", "did:dephy:0x..."], // did(origin_edge)
  ],
  "sig": "..."
}

You don’t need to care about Routed Messages if you just build applications interacting with only devices and Edge Brokers.

Commit count: 8

cargo fmt