clone

nostr relays on demand at <name>.bind.ws: claim one with your key, pay in zaps past the free allowance

kinds: every special event kind in one module, by NIP; 30078 had three names in three files, and the NIP-46 and report kinds lived in relay.ts

Dami committed ef4749a
commit
ef4749ac9086a9b338aa3aecc53cafb427c5764a
parent
c7a481ac13ea6e29be8e85ec5f9467774e4ec324
author
Dami <dami.etoile@gmail.com>
11 files changed, +69 -52
Msrc/blossom.ts3+-
Msrc/card.ts3+-
Msrc/event.ts4--
Msrc/groups.ts16+--------
Msrc/identity.ts15+--------
Asrc/kinds.ts55++++++++++++++++++++++++++++++
Msrc/nip66.ts2-
Msrc/notify.ts3+-
Msrc/relay.ts12++----
Msrc/views.ts5+--
Mtest/object/views.test.ts3+-
M src/blossom.ts +2 -1
M src/card.ts +1 -2
M src/event.ts +0 -4
M src/groups.ts +2 -14
M src/identity.ts +1 -14
A src/kinds.ts +55 -0
@@ -0,0 +1,55 @@
1+// Every event kind the relay treats specially, in one place, by the NIP2+// that defines it. A module that needs one imports it from here.3+4+// NIP-01, 09, 62, 425+export const KIND_PROFILE = 0;6+export const KIND_DELETION = 5;7+export const KIND_VANISH = 62;8+export const KIND_AUTH = 22242;9+10+// NIP-17 and NIP-59: the rumour and the gift wrap the relay writes its owner (notify.ts)11+export const KIND_DM = 14;12+export const KIND_WRAP = 1059;13+14+// NIP-56 reports, through the socket and the /report door15+export const KIND_REPORT = 1984;16+17+// NIP-46 remote signing traffic: ephemeral, encrypted end to end, never stored.18+export const KIND_NOSTR_CONNECT = 24133;19+20+// NIP-78 application data: the views the relay signs (views.ts) and the21+// card's record (card.ts). Presence is ephemeral: 20000 plus the view22+// kind's 78, so a client that knows one can guess the other.23+export const KIND_APP_DATA = 30078;24+export const KIND_VIEW = KIND_APP_DATA;25+export const KIND_PRESENCE = 20078;26+27+// NIP-43 relay membership: the roster, the role definition, and the deltas28+export const KIND_MEMBER_ADDED = 8000;29+export const KIND_MEMBER_REMOVED = 8001;30+export const KIND_ROSTER = 13534;31+export const KIND_ROLE_DEF = 33534;32+// NIP-43's own join and leave requests: ephemeral, no h tag, a claim tag33+// carries the invite code.34+export const KIND_NIP43_JOIN = 28934;35+export const KIND_NIP43_LEAVE = 28936;36+37+// NIP-29 groups: moderation events clients send, and the state the relay signs38+export const KIND_PUT_USER = 9000;39+export const KIND_REMOVE_USER = 9001;40+export const KIND_EDIT_METADATA = 9002;41+export const KIND_DELETE_EVENT = 9005;42+export const KIND_CREATE_GROUP = 9007;43+export const KIND_DELETE_GROUP = 9008;44+export const KIND_CREATE_INVITE = 9009;45+export const KIND_PINS = 9010;46+export const KIND_JOIN = 9021;47+export const KIND_LEAVE = 9022;48+export const KIND_GROUP_METADATA = 39000;49+export const KIND_GROUP_ADMINS = 39001;50+export const KIND_GROUP_MEMBERS = 39002;51+export const KIND_GROUP_ROLES = 39003;52+export const KIND_GROUP_PINS = 39005;53+54+// NIP-66: the discovery record the relay signs about itself55+export const KIND_RELAY_DISCOVERY = 30166;
M src/nip66.ts +0 -2
M src/notify.ts +1 -2
M src/relay.ts +4 -8
@@ -3,11 +3,11 @@
33 // relay.go; policy is per relay and owner-managed (see manage.ts).44 import { DurableObject } from "cloudflare:workers";55 import { sha256 } from "@noble/hashes/sha2.js";6-import { KIND_AUTH, KIND_VANISH, difficulty, expiration, hasTag, isPrivate, now, tagValues, validate, canonical, type Event } from "./event.ts";6+import { difficulty, expiration, hasTag, isPrivate, now, tagValues, validate, canonical, type Event } from "./event.ts";77 import { match, parseFilter, type Filter } from "./filter.ts";88 import { hllOffset } from "./hll.ts";99 import { Negentropy, bytesToHex, hexToBytes } from "./negentropy.ts";10-import { KIND_RELAY_DISCOVERY, discovery } from "./nip66.ts";10+import { discovery } from "./nip66.ts";1111 import { Audit } from "./audit.ts";1212 import { ERR_DUPLICATE, ERR_TOO_BIG, Store, type Access } from "./store.ts";1313 import { Settings, isReplaceable, isProtected, SUCCESSION_WARN_DAYS } from "./settings.ts";
@@ -21,7 +21,6 @@ import { blossom, blobBytes, isBlobPath } from "./blossom.ts";
2121 import { nip96 } from "./nip96.ts";2222 import { dumpBytes, dumpDue, dumpDownload, writeDump } from "./dumps.ts";2323 import { importBytes, importUpload } from "./imports.ts";24-import { KIND_GROUP_PINS } from "./identity.ts";2524 import { DIGEST_DAYS, digestText } from "./notify.ts";2625 import { claimFromProfile, nip05Document } from "./nip05.ts";2726 import { checkInvite, claimInvite, inviteCreator, invitePage, termsPage } from "./invites.ts";
@@ -32,13 +31,13 @@ import { leaseDays, leaseNames, validName } from "./names.ts";
3231 import { MAX_JOBS, MAX_STANDING, checkJob, finishRun, newJobID, pruneFinished, pullView, runRound, startRun, type Job, type JobSpec } from "./jobs.ts";3332 import { Hostnames, forgetDomains } from "./domains.ts";3433 import { groupFacts, handleGroupEvent, isGroupManagement, isGroupState, isNIP43Request } from "./groups.ts";35-import { KIND_GROUP_MEMBERS } from "./identity.ts";3634 import { SIGNER_JS } from "./gen/signer.ts";3735 import { isPagePath, pages } from "./pages.ts";3836 import { notify, fuelLow, fuelText } from "./notify.ts";3937 import { card } from "./card.ts";40-import { KIND_PRESENCE, PRESENCE_THROTTLE_S, VIEWS, latestStored, nip11Views, presenceTags, serveView, viewByName, viewD, viewEvent, viewOn, viewStored, type ViewRun } from "./views.ts";38+import { PRESENCE_THROTTLE_S, VIEWS, latestStored, nip11Views, presenceTags, serveView, viewByName, viewD, viewEvent, viewOn, viewStored, type ViewRun } from "./views.ts";4139 import type { Blob } from "./blossom.ts";40+import { KIND_VANISH, KIND_AUTH, KIND_REPORT, KIND_NOSTR_CONNECT, KIND_PRESENCE, KIND_GROUP_MEMBERS, KIND_GROUP_PINS, KIND_RELAY_DISCOVERY } from "./kinds.ts";4241 4342 export interface Env {4443 RELAY: DurableObjectNamespace<Relay>;
@@ -81,9 +80,6 @@ export interface Env {
8180 // gate(); 66 is the discovery record the relay signs about itself8281 // (publishDiscovery); 77 is negentropy sync (handleSync).8382 export const SUPPORTED_NIPS = [1, 5, 9, 11, 13, 17, 29, 40, 42, 45, 46, 50, 56, 59, 62, 66, 67, 70, 77, 86, 98];84-export const KIND_REPORT = 1984;85-// NIP-46 remote signing traffic: ephemeral, encrypted end to end, never stored.86-export const KIND_NOSTR_CONNECT = 24133;8783 export const SOFTWARE = "https://bind.ws";8884 export const VERSION = "0.1.0";8985 export const MAX_MESSAGE = 1024 * 1024;
M src/views.ts +1 -4
M test/object/views.test.ts +2 -1