该提交新增了完整的 Nostr 去中心化社交网络适配器实现,包含以下核心功能: 1. 基础加密与密钥处理:支持 nsec/npub/hex 格式密钥转换,实现 NIP-04/NIP-17 加解密 2. Relay 管理与健康监控:支持多 Relay 连接、自动重连、健康评分与自动选优 3. 事件与消息处理:实现事件校验、去重、速率限制、消息缓存与状态持久化 4. 个人资料管理:支持发布/导入/合并 Nostr Kind 0 元数据事件 5. 配对机制:实现安全的双向配对通信流程 6. Zap 功能:支持 NIP-57 打赏请求与收据解析 7. NIP-05 验证:实现域名身份验证 8. 配置系统:完整的配置校验与多账户支持 9. 监控与指标:提供连接监控、事件统计与健康快照 10. HTTP API:提供个人资料管理的 RESTful 接口 11. 安装向导:命令行配置向导与初始化流程 所有模块均遵循 Nostr 协议规范,支持多账户、多 Relay 部署,内置安全防护与流量控制机制。
25 lines
444 B
Python
25 lines
444 B
Python
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class NostrEvent(BaseModel):
|
|
id: str
|
|
pubkey: str
|
|
created_at: int
|
|
kind: int
|
|
tags: list[list[str]] = []
|
|
content: str = ""
|
|
sig: str | None = None
|
|
|
|
|
|
class NostrProfile(BaseModel):
|
|
name: str = ""
|
|
display_name: str = ""
|
|
about: str = ""
|
|
picture: str = ""
|
|
banner: str = ""
|
|
website: str = ""
|
|
nip05: str = ""
|
|
lud16: str = ""
|