relaycorp / awala-endpoint-internet

Middleware for server-side apps to communicate over Awala without implementing any of the networking or cryptography from the protocol suite.
https://docs.relaycorp.tech/awala-endpoint-internet/
GNU Affero General Public License v3.0
0 stars 0 forks source link

Implement PoHTTP client to relay outgoing messages to gateways #12

Closed gnarea closed 1 year ago

gnarea commented 1 year ago

POST / in the PoHTTP client. We should use the binary mode of CloudEvents.

This basically processes outgoing-service-message events (refer to the README for the spec). For every event, it should do the following:

  1. Encrypt the service message (see example). If we don't have the recipient's public key (e.g., we haven't received a PDA from them), log a WARN message and return a 503 Service Unavailable.
  2. Create a parcel (see example). If we don't have a PDA (e.g., it expired, we never got it), log a WARN message and return a 503 Service Unavailable.
  3. Send the parcel to the gateway (see example).

Note on 5XX responses

They would cause a broker like Google PubSub to retry later.

gnarea commented 1 year ago

Route looks like this roughly:

const channel = await fastify.activeEndpoint.getChannel(event.subject);
const parcelSerialsied = await channel.makeMessage(
  new ServiceMessage(event.datacontenttype, event.data),
  Parcel,
  {
    creationDate: event.time,
    // ...
  },
)
await deliverParcel(channel.peer.internetAddress, parcelSerialsied, useTls);

Refer to https://github.com/relaycorp/awala-endpoint-internet#outgoing-service-message

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.4.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: