dm3-org / dm3

The dm3 protocol | New standard of web3 messaging | Decentralized ENS-based registry | Secure end-to-end encryption | Easy dApp integration
https://dm3.network
BSD 2-Clause "Simplified" License
72 stars 14 forks source link

Profile, accounts, sessions #907

Open malteish opened 2 months ago

malteish commented 2 months ago

Background

Currently, both backend and delivery service store the user's "profile" in their database. Since the profile should ideally be managed on-chain, only one source of truth should ever exist. There are several options:

  1. Backend hosts profile: A user should be able to use many delivery services, but will most likely opt for only one backend - with this assumption, the backend should be the service responsible for publishing and providing the profile. The backend would then be used as a data source by the offchain resolver.
  2. Delivery service hosts profile: not feasible for the main profile, but a delivery service still keeps a profile for a user that contains things like max message size and ttl.
  3. Profile published on-chain: best option, but not our default approach.

Option 1 is the way to go.

Discussion and results

See notes.

Which data must be handled?

Who handles what?

Sessions

The services store information about the user in "sessions", which is a very unfortunate term to use in this context.

Estimate: 3 days

AlexNi245 commented 2 months ago

Reasons why we need to store the profile in the first place

malteish commented 2 months ago

Reasons why we need to store the profile in the first place

  • During the challenge response flow, the Backend checks if the challenge was signed by the users signing key
  • When receiving a message the Postmark is signed by the receiver's encryption key DS
  1. I propose issuing challenges as short-lived jwt, in an effort to make session management stateless
  2. You are right. Even though it seems inefficient, I will start by querying the key from the ENS profile whenever it is needed. We should introduce caching later.
malteish commented 2 months ago

Account management in delivery service

creating accounts

Prerequisites: A user can have multiple ens names, e.g. alice.eth and 0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5.addr.dm3.network. They must publish a dm3 profile for every ens name they want to use with dm3 (this is a one-time setup and is NOT done by the delivery service).

Once a profile is published, the user can create an account for that profile with a delivery service through the account endpoint, which expects an account creation message that is signed with the profile's signature key.

deleting accounts

An account can be deleted by the account owner through the account endpoint. The account deletion message must be signed with the profile's signature key and contain the ens name, the delivery service URL, the topic deleteAccount and a timestamp to prevent replay attacks.

Session management

malteish commented 2 days ago

Plan:

Notes

Account

Names

Should an account be identifyable by it's unique ens name? That might be a good idea.