- commit
- 5cf7ea42aea03a06ab5fcc82e416fe52892f07cd
- parent
- b27adb87dccb9e8c33159a179984dc52f63a13e1
- author
- Dami <dami.etoile@gmail.com>
| M | docs/ | 2 | +- |
| M | docs/ | 2 | +- |
| M | src/ | 6 | ++++-- |
| M | test/ | 4 | ++++ |
@@ -17,7 +17,7 @@ Pages and the feed exist only while **Rules > Reads** is *anyone*. On a members-
1717 1818 ## The card and the group address1919 20-Every relay has a card. `/card.svg` is a picture with the name, who may read and write, the fuel state and a QR code of the group address. `/card.json` has the same facts as data, and `/card.nostr` is the same facts signed by the relay's own key. A relay nobody has claimed, or a temporary one, gets a card that says so.20+Every relay has a card. `/card.svg` is a picture with the name, who may read and write, the fuel state and a QR code of the group address. `/card.json` has the same facts as data, plus the owner's profile address with this relay as the hint, and `/card.nostr` is the same facts signed by the relay's own key. A relay nobody has claimed, or a temporary one, gets a card that says so.2121 2222 On the Identity tab, **Share** shows the card, the group address with **Copy naddr**, its QR code and **Copy embed** for a snippet to put on a profile or a page. Group-aware clients open that address as your relay's community. Cards refresh every five minutes.2323 @@ -79,7 +79,7 @@ Only while reads are open. Otherwise every path here answers 404, and an unclaim
7979 8080 | Path | Method | Answers | Status |8181 |---|---|---|---|82-| `/card.json` | GET | `name`, `state`, `url`, `console`; on a claimed relay also `description`, `icon`, `owner`, `self`, `members` when the directory is public, `reads`, `writes`, `fuel`, `naddr`, `signed_url`, `image`; a lease adds `expires_at` | 200 |82+| `/card.json` | GET | `name`, `state`, `url`, `console`; on a claimed relay also `description`, `icon`, `owner`, `self`, `members` when the directory is public, `reads`, `writes`, `fuel`, `naddr`, `nprofile` (the owner with this relay as the hint), `signed_url`, `image`; a lease adds `expires_at` | 200 |8383 | `/card.nostr` | GET | the same facts as a kind 30078 signed by the relay's key | 200; 404 no owner |8484 | `/card.svg` | GET | a 600 by 315 picture with the naddr as a QR | 200 |8585 | `/qr.svg?text=` | GET | any text up to 512 bytes as a QR | 200; 400 empty; 413 too long |@@ -1,13 +1,13 @@
11 // The relay card: something a name can be linked to from a profile.22 //3-// GET /card.json the facts: name, owner, members, rules, fuel, naddr3+// GET /card.json the facts: name, owner, members, rules, fuel, naddr, nprofile44 // GET /card.nostr the same facts as a kind 30078 signed by the relay key55 // GET /card.svg an open graph sized picture with a QR of the naddr66 // GET /qr.svg any short text as a QR, for the console77 //88 // Cards are public and cached for five minutes. Unclaimed and leased relays99 // get a smaller card that says so.10-import { naddrEncode } from "nostr-tools/nip19";10+import { naddrEncode, nprofileEncode } from "nostr-tools/nip19";1111 import { svg as qrSVG, encode as qrEncode } from "./qr.ts";1212 import { KIND_GROUP_METADATA } from "./identity.ts";1313 import { escapeHTML } from "./ui.ts";@@ -35,6 +35,7 @@ export interface Card {
3535 writes?: "open" | "allowlist" | "wot" | "owner";3636 fuel?: "allowance" | "burning" | "out";3737 naddr?: string;38+ nprofile?: string; // the owner, with this relay as the hint: "find me here" for feed clients3839 signed_url?: string;3940 image?: string;4041 }@@ -63,6 +64,7 @@ export function cardData(relay: Relay, host: string, caller: string[] = []): Car
6364 image: web + "/card.svg",6465 };6566 if (p.icon) card.icon = p.icon;67+ card.nprofile = nprofileEncode({ pubkey: p.owner, relays: [url] });6668 if (self) {6769 card.self = self;6870 card.naddr = naddrEncode({ kind: KIND_GROUP_METADATA, pubkey: self, identifier: relay.slug, relays: [url] });@@ -122,6 +122,10 @@ describe("relay card", () => {
122122 expect(c.fuel).toBe("allowance");123123 expect(c.self).toMatch(/^[0-9a-f]{64}$/);124124 expect(c.signed_url).toBe("https://cardy.bind.ws/card.nostr");125+ const prof = decode(c.nprofile);126+ expect(prof.type).toBe("nprofile");127+ expect((prof.data as any).pubkey).toBe(c.owner);128+ expect((prof.data as any).relays).toEqual(["wss://cardy.bind.ws"]);125129 const addr = decode(c.naddr);126130 expect(addr.type).toBe("naddr");127131 expect((addr.data as any).kind).toBe(39000);