概览
revolution/laravel-nostr 是一个让你能在 Laravel 中使用 Nostr 协议的包。它提供密钥生成与转换、事件获取与发布、pool(多 relay)支持、NIP-05 profile、NIP-17 Private Direct Messages,以及与 Laravel Notifications 的集成。由于 Nostr 规范仍在演进中,该包也在持续开发。通知功能已经可以实际投入使用。
驱动
该包提供两个驱动。native 驱动不支持 NIP-04。配置默认驱动
在config/nostr.php 或 .env 中配置。
安装
1
安装包
2
发布配置文件
密钥管理
生成密钥
转换密钥
从 nsec 转换。获取事件
获取多个事件
获取单个事件
发布事件
发布到单个 relay
发布到多个 relay(pool)
Relay 服务器配置
使用的 relay 服务器
当仅使用Nostr::event() 时,会使用 config/nostr.php 中的第一个 relay。当使用 Nostr::pool() 时,配置中的所有 relay 都会作为目标。
在运行时更换 relay
NIP-05 profile
NIP-17 Private Direct Messages
NIP-17 仅在
native 驱动中受支持。发送私信
解密私信
Laravel Notifications
使用NostrChannel,你可以从 Laravel Notifications 向 Nostr 发送消息。
Notification 类
按需通知
与 User 模型集成
通知中使用的 relay 服务器
默认情况下会使用config/nostr.php 中配置的所有 relay。也可以通过 NostrRoute 在运行时指定 relay。
更多最新信息请参见 GitHub 仓库。