diff options
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/db/models.py')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/db/models.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/db/models.py b/packages/meshbay-hub/src/meshbay_hub/db/models.py index 2aeae41..c0b0491 100644 --- a/packages/meshbay-hub/src/meshbay_hub/db/models.py +++ b/packages/meshbay-hub/src/meshbay_hub/db/models.py @@ -42,6 +42,7 @@ class User(Base): email: Mapped[str] = mapped_column(String(256), nullable=False) # kept for recovery pw_hash: Mapped[bytes] = mapped_column(nullable=False) pw_salt: Mapped[bytes] = mapped_column(nullable=False) + pw_version: Mapped[int] = mapped_column(Integer, default=1) pk_ed25519: Mapped[str] = mapped_column(String(64), nullable=False) # base64 raw 32B pk_x25519: Mapped[str] = mapped_column(String(64), nullable=False) # base64 raw 32B hub_id: Mapped[str] = mapped_column(String(128), nullable=False) @@ -132,17 +133,31 @@ class RefreshToken(Base): id: Mapped[str] = mapped_column(String(36), primary_key=True, default=_uuid) user_id: Mapped[str] = mapped_column(ForeignKey("users.id"), nullable=False) token_hash: Mapped[str] = mapped_column(String(64), unique=True, nullable=False) # blake3 hex + family_id: Mapped[str] = mapped_column(String(36), nullable=False, default=_uuid) expires_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False) created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=_now) revoked: Mapped[bool] = mapped_column(Boolean, default=False) user: Mapped["User"] = relationship(back_populates="refresh_tokens") - __table_args__ = (Index("ix_refresh_tokens_hash", "token_hash"),) + __table_args__ = ( + Index("ix_refresh_tokens_hash", "token_hash"), + Index("ix_refresh_tokens_family", "family_id"), + ) # ── IP logs (legal compliance) ──────────────────────────────────────────────── +class HubPeer(Base): + """Trusted peer hub for MHP federation.""" + __tablename__ = "hub_peers" + + hub_id: Mapped[str] = mapped_column(String(128), primary_key=True) + hub_url: Mapped[str] = mapped_column(String(256), nullable=False) + pk_hub_pem: Mapped[str] = mapped_column(Text, nullable=False) + trusted_since: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=_now) + + class FederatedGroup(Base): """ Groups received from peer hubs via MHP federation. |