Skip to content

Instantly share code, notes, and snippets.

@SnowCait
Last active April 23, 2024 13:51
Show Gist options
  • Save SnowCait/33f59ef20bae0c075b7c9cf51766dca7 to your computer and use it in GitHub Desktop.
Save SnowCait/33f59ef20bae0c075b7c9cf51766dca7 to your computer and use it in GitHub Desktop.
Nostr テキストアップローダー

概要

画像アップローダーとほぼ同じ。

メリット

  • 削除可能
  • 編集履歴
  • NIP-98 認証 → フォローユーザーに限定することで鍵垢の実装が可能

Private account possibility

Publish

Alice publishes a private note to their permission list (kind 3 or 30000).

sequenceDiagram
  participant Client as Client (Alice)
  participant Relay
  participant Storage as File Storage Server (NIP-96)

  Client->>Relay: REQ<br>{ kinds: [ 3 ], authors: [ Alice ] }
  Relay-->>Client: EVENT<br>{ kind: 3, tags: [ [ "p", Bob ], ... ] }

  Client->>Storage: POST <api_url><br>Authorization: <NIP-98><br>{ file: <content>, permission: { pubkeys: [ Bob, ... ] } }
  Storage-->>Client: { nip94_event: { tags: [ "url", <url> ] } }

  Client->>Relay: EVENT<br> { kind: x, pubkey: Alice, tags: [ [ "file", <url> ], [ "p", Bob ], ... ] }
  Relay-->>Client: OK
Loading

Subscribe

Bob subscribes private notes.

sequenceDiagram
  participant Client as Client (Bob)
  participant Relay
  participant Storage as File Storage Server (NIP-96)

  Client->>Relay: REQ<br>{ kinds: [ x ], authors: [ Alice, ... ], p: [ Bob ] }
  Relay-->>Client: EVENT<br>{ kind: x, pubkey: Alice, tags: [ [ "file", <url> ] ] }

  Client->>Storage: GET <url><br>Authorization: <NIP-98>
  alt permitted
    Storage-->>Client: Content-Type: text/plain<br><content>
  else
    Storage-->>Client: 404
  end

  Client->>Client: Show <content>
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment