applesauce-common 6.2.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/README.md +1 -0
  2. package/dist/casts/_circular-import.d.ts +3 -0
  3. package/dist/casts/_circular-import.js +3 -0
  4. package/dist/casts/app-handler.d.ts +56 -0
  5. package/dist/casts/app-handler.js +105 -0
  6. package/dist/casts/app-recommendation.d.ts +26 -0
  7. package/dist/casts/app-recommendation.js +41 -0
  8. package/dist/casts/external-identities.d.ts +9 -0
  9. package/dist/casts/external-identities.js +14 -0
  10. package/dist/casts/forum-thread.d.ts +17 -0
  11. package/dist/casts/forum-thread.js +31 -0
  12. package/dist/casts/git-issue.d.ts +18 -0
  13. package/dist/casts/git-issue.js +26 -0
  14. package/dist/casts/git-patch.d.ts +49 -0
  15. package/dist/casts/git-patch.js +88 -0
  16. package/dist/casts/git-pull-request.d.ts +67 -0
  17. package/dist/casts/git-pull-request.js +122 -0
  18. package/dist/casts/git-repository.d.ts +9 -0
  19. package/dist/casts/git-repository.js +16 -0
  20. package/dist/casts/git-thread.d.ts +33 -0
  21. package/dist/casts/git-thread.js +65 -0
  22. package/dist/casts/index.d.ts +12 -0
  23. package/dist/casts/index.js +12 -0
  24. package/dist/casts/napplet-handlers.d.ts +39 -0
  25. package/dist/casts/napplet-handlers.js +91 -0
  26. package/dist/casts/napplet.d.ts +98 -0
  27. package/dist/casts/napplet.js +196 -0
  28. package/dist/casts/note.d.ts +8 -0
  29. package/dist/casts/note.js +21 -1
  30. package/dist/casts/nsite.d.ts +134 -0
  31. package/dist/casts/nsite.js +249 -0
  32. package/dist/casts/profile.d.ts +20 -0
  33. package/dist/casts/profile.js +30 -0
  34. package/dist/casts/reaction.d.ts +1 -1
  35. package/dist/casts/relay-discovery.d.ts +4 -0
  36. package/dist/casts/relay-discovery.js +9 -1
  37. package/dist/casts/report.d.ts +28 -15
  38. package/dist/casts/report.js +42 -19
  39. package/dist/casts/share.d.ts +1 -1
  40. package/dist/casts/torrent.d.ts +5 -0
  41. package/dist/casts/torrent.js +8 -1
  42. package/dist/casts/trusted-assertions.d.ts +2 -0
  43. package/dist/casts/trusted-assertions.js +19 -18
  44. package/dist/casts/user-status.d.ts +33 -0
  45. package/dist/casts/user-status.js +69 -0
  46. package/dist/casts/user.d.ts +7 -0
  47. package/dist/casts/user.js +20 -1
  48. package/dist/factories/app-handler.d.ts +31 -0
  49. package/dist/factories/app-handler.js +50 -0
  50. package/dist/factories/app-recommendation.d.ts +21 -0
  51. package/dist/factories/app-recommendation.js +28 -0
  52. package/dist/factories/chat-message.d.ts +37 -0
  53. package/dist/factories/chat-message.js +56 -0
  54. package/dist/factories/comment.d.ts +8 -7
  55. package/dist/factories/comment.js +2 -2
  56. package/dist/factories/external-identities.d.ts +17 -0
  57. package/dist/factories/external-identities.js +28 -0
  58. package/dist/factories/file-message.d.ts +24 -0
  59. package/dist/factories/file-message.js +37 -0
  60. package/dist/factories/forum-thread.d.ts +34 -0
  61. package/dist/factories/forum-thread.js +50 -0
  62. package/dist/factories/git-applied-status.d.ts +39 -0
  63. package/dist/factories/git-applied-status.js +53 -0
  64. package/dist/factories/git-closed-status.d.ts +18 -0
  65. package/dist/factories/git-closed-status.js +24 -0
  66. package/dist/factories/git-draft-status.d.ts +18 -0
  67. package/dist/factories/git-draft-status.js +24 -0
  68. package/dist/factories/git-issue.d.ts +19 -0
  69. package/dist/factories/git-issue.js +25 -0
  70. package/dist/factories/git-open-status.d.ts +18 -0
  71. package/dist/factories/git-open-status.js +22 -0
  72. package/dist/factories/git-patch.d.ts +59 -0
  73. package/dist/factories/git-patch.js +102 -0
  74. package/dist/factories/git-pull-request-update.d.ts +23 -0
  75. package/dist/factories/git-pull-request-update.js +33 -0
  76. package/dist/factories/git-pull-request.d.ts +39 -0
  77. package/dist/factories/git-pull-request.js +64 -0
  78. package/dist/factories/index.d.ts +24 -0
  79. package/dist/factories/index.js +24 -0
  80. package/dist/factories/internal/git-pull-request.d.ts +19 -0
  81. package/dist/factories/internal/git-pull-request.js +26 -0
  82. package/dist/factories/internal/git-status.d.ts +11 -0
  83. package/dist/factories/internal/git-status.js +12 -0
  84. package/dist/factories/internal/git-thread.d.ts +19 -0
  85. package/dist/factories/internal/git-thread.js +29 -0
  86. package/dist/factories/internal/napplet-manifest.d.ts +52 -0
  87. package/dist/factories/internal/napplet-manifest.js +85 -0
  88. package/dist/factories/internal/nsite-manifest.d.ts +45 -0
  89. package/dist/factories/internal/nsite-manifest.js +68 -0
  90. package/dist/factories/legacy-message.d.ts +2 -0
  91. package/dist/factories/legacy-message.js +9 -2
  92. package/dist/factories/named-napplet.d.ts +20 -0
  93. package/dist/factories/named-napplet.js +30 -0
  94. package/dist/factories/named-nsite.d.ts +28 -0
  95. package/dist/factories/named-nsite.js +53 -0
  96. package/dist/factories/napplet-handlers.d.ts +34 -0
  97. package/dist/factories/napplet-handlers.js +77 -0
  98. package/dist/factories/napplet-snapshot.d.ts +18 -0
  99. package/dist/factories/napplet-snapshot.js +38 -0
  100. package/dist/factories/nsite-snapshot.d.ts +18 -0
  101. package/dist/factories/nsite-snapshot.js +29 -0
  102. package/dist/factories/reaction.d.ts +3 -2
  103. package/dist/factories/report.d.ts +48 -0
  104. package/dist/factories/report.js +66 -0
  105. package/dist/factories/root-napplet.d.ts +18 -0
  106. package/dist/factories/root-napplet.js +24 -0
  107. package/dist/factories/root-nsite.d.ts +23 -0
  108. package/dist/factories/root-nsite.js +44 -0
  109. package/dist/factories/torrent.d.ts +24 -10
  110. package/dist/factories/torrent.js +48 -44
  111. package/dist/factories/trusted-provider-list.d.ts +23 -0
  112. package/dist/factories/trusted-provider-list.js +39 -0
  113. package/dist/factories/user-status.d.ts +26 -0
  114. package/dist/factories/user-status.js +52 -0
  115. package/dist/factories/wrapped-message.js +10 -4
  116. package/dist/helpers/app-data.js +15 -7
  117. package/dist/helpers/app-handler.d.ts +43 -6
  118. package/dist/helpers/app-handler.js +53 -3
  119. package/dist/helpers/app-recommendation.d.ts +24 -0
  120. package/dist/helpers/app-recommendation.js +30 -0
  121. package/dist/helpers/bookmark.js +5 -2
  122. package/dist/helpers/comment.d.ts +11 -5
  123. package/dist/helpers/comment.js +7 -1
  124. package/dist/helpers/content.d.ts +3 -1
  125. package/dist/helpers/emoji-pack.js +11 -6
  126. package/dist/helpers/emoji.d.ts +2 -2
  127. package/dist/helpers/encrypted-content-cache.d.ts +2 -11
  128. package/dist/helpers/encrypted-content-cache.js +6 -14
  129. package/dist/helpers/encrypted-file.d.ts +41 -0
  130. package/dist/helpers/encrypted-file.js +64 -0
  131. package/dist/helpers/external-id.js +13 -19
  132. package/dist/helpers/external-identities.d.ts +29 -0
  133. package/dist/helpers/external-identities.js +52 -0
  134. package/dist/helpers/file-message.d.ts +18 -0
  135. package/dist/helpers/file-message.js +44 -0
  136. package/dist/helpers/file-metadata.d.ts +9 -4
  137. package/dist/helpers/file-metadata.js +21 -6
  138. package/dist/helpers/forum-thread.d.ts +10 -0
  139. package/dist/helpers/forum-thread.js +10 -0
  140. package/dist/helpers/gift-wrap.d.ts +40 -15
  141. package/dist/helpers/gift-wrap.js +110 -33
  142. package/dist/helpers/git-issue.d.ts +13 -0
  143. package/dist/helpers/git-issue.js +19 -0
  144. package/dist/helpers/git-patch.d.ts +41 -0
  145. package/dist/helpers/git-patch.js +73 -0
  146. package/dist/helpers/git-pull-request.d.ts +57 -0
  147. package/dist/helpers/git-pull-request.js +111 -0
  148. package/dist/helpers/git-repository.d.ts +4 -0
  149. package/dist/helpers/git-repository.js +16 -0
  150. package/dist/helpers/git-status.d.ts +44 -0
  151. package/dist/helpers/git-status.js +93 -0
  152. package/dist/helpers/git.d.ts +2 -0
  153. package/dist/helpers/git.js +4 -0
  154. package/dist/helpers/groups.d.ts +5 -2
  155. package/dist/helpers/groups.js +40 -18
  156. package/dist/helpers/hashtag.d.ts +4 -2
  157. package/dist/helpers/index.d.ts +13 -0
  158. package/dist/helpers/index.js +13 -0
  159. package/dist/helpers/lists.js +14 -2
  160. package/dist/helpers/lnurl.js +1 -1
  161. package/dist/helpers/messages.js +3 -2
  162. package/dist/helpers/mute.js +20 -9
  163. package/dist/helpers/napplet-handlers.d.ts +79 -0
  164. package/dist/helpers/napplet-handlers.js +187 -0
  165. package/dist/helpers/napplet.d.ts +107 -0
  166. package/dist/helpers/napplet.js +177 -0
  167. package/dist/helpers/nsite.d.ts +90 -0
  168. package/dist/helpers/nsite.js +217 -0
  169. package/dist/helpers/relay-discovery.d.ts +4 -0
  170. package/dist/helpers/relay-discovery.js +8 -0
  171. package/dist/helpers/reports.d.ts +35 -0
  172. package/dist/helpers/reports.js +36 -5
  173. package/dist/helpers/threading.d.ts +4 -2
  174. package/dist/helpers/torrent.d.ts +9 -6
  175. package/dist/helpers/torrent.js +23 -15
  176. package/dist/helpers/trusted-assertions.d.ts +7 -0
  177. package/dist/helpers/trusted-assertions.js +41 -2
  178. package/dist/helpers/user-status.d.ts +13 -1
  179. package/dist/helpers/user-status.js +15 -0
  180. package/dist/helpers/wrapped-messages.d.ts +2 -0
  181. package/dist/helpers/wrapped-messages.js +6 -1
  182. package/dist/models/app-handler.d.ts +21 -0
  183. package/dist/models/app-handler.js +47 -0
  184. package/dist/models/git.d.ts +34 -0
  185. package/dist/models/git.js +144 -0
  186. package/dist/models/index.d.ts +4 -0
  187. package/dist/models/index.js +4 -0
  188. package/dist/models/legacy-messages.js +6 -1
  189. package/dist/models/napplet-handlers.d.ts +16 -0
  190. package/dist/models/napplet-handlers.js +45 -0
  191. package/dist/models/nsite.d.ts +22 -0
  192. package/dist/models/nsite.js +67 -0
  193. package/dist/models/thread.d.ts +4 -1
  194. package/dist/models/thread.js +34 -5
  195. package/dist/models/user-status.d.ts +8 -4
  196. package/dist/models/user-status.js +16 -22
  197. package/dist/models/wrapped-messages.js +9 -7
  198. package/dist/observable/filter-timeline-by-mutes.d.ts +1 -1
  199. package/dist/observable/filter-timeline-by-mutes.js +6 -2
  200. package/dist/operations/app-handler.d.ts +24 -0
  201. package/dist/operations/app-handler.js +58 -0
  202. package/dist/operations/app-recommendation.d.ts +13 -0
  203. package/dist/operations/app-recommendation.js +40 -0
  204. package/dist/operations/calendar-event.js +3 -2
  205. package/dist/operations/chat-message.d.ts +9 -0
  206. package/dist/operations/chat-message.js +12 -0
  207. package/dist/operations/client.d.ts +1 -4
  208. package/dist/operations/client.js +1 -23
  209. package/dist/operations/comment.d.ts +9 -3
  210. package/dist/operations/comment.js +12 -9
  211. package/dist/operations/external-identities.d.ts +8 -0
  212. package/dist/operations/external-identities.js +23 -0
  213. package/dist/operations/file-message.d.ts +7 -0
  214. package/dist/operations/file-message.js +34 -0
  215. package/dist/operations/forum-thread.d.ts +3 -0
  216. package/dist/operations/forum-thread.js +6 -0
  217. package/dist/operations/gift-wrap.js +38 -14
  218. package/dist/operations/git-issue.d.ts +18 -0
  219. package/dist/operations/git-issue.js +31 -0
  220. package/dist/operations/git-patch.d.ts +30 -0
  221. package/dist/operations/git-patch.js +75 -0
  222. package/dist/operations/git-pull-request.d.ts +29 -0
  223. package/dist/operations/git-pull-request.js +74 -0
  224. package/dist/operations/git-repository.js +4 -4
  225. package/dist/operations/git-status.d.ts +28 -0
  226. package/dist/operations/git-status.js +116 -0
  227. package/dist/operations/git-thread.d.ts +13 -0
  228. package/dist/operations/git-thread.js +39 -0
  229. package/dist/operations/index.d.ts +17 -0
  230. package/dist/operations/index.js +17 -0
  231. package/dist/operations/internal/git-commits.d.ts +2 -0
  232. package/dist/operations/internal/git-commits.js +16 -0
  233. package/dist/operations/napplet-handlers.d.ts +47 -0
  234. package/dist/operations/napplet-handlers.js +161 -0
  235. package/dist/operations/napplet.d.ts +51 -0
  236. package/dist/operations/napplet.js +121 -0
  237. package/dist/operations/nsite.d.ts +51 -0
  238. package/dist/operations/nsite.js +112 -0
  239. package/dist/operations/reaction.d.ts +12 -2
  240. package/dist/operations/reaction.js +1 -1
  241. package/dist/operations/report.d.ts +33 -0
  242. package/dist/operations/report.js +60 -0
  243. package/dist/operations/stream.js +5 -4
  244. package/dist/operations/torrent.d.ts +1 -4
  245. package/dist/operations/torrent.js +24 -11
  246. package/dist/operations/trusted-providers.d.ts +14 -0
  247. package/dist/operations/trusted-providers.js +33 -0
  248. package/dist/operations/user-status.d.ts +11 -0
  249. package/dist/operations/user-status.js +29 -0
  250. package/dist/operations/wrapped-message.js +2 -2
  251. package/package.json +13 -17
@@ -0,0 +1,161 @@
1
+ import { isEvent } from "applesauce-core/helpers/event";
2
+ import { decodeAddressPointer, decodeEventPointer, getReplaceableAddressFromPointer, isAddressPointer, parseReplaceableAddress, } from "applesauce-core/helpers/pointers";
3
+ import { isSafeRelayURL } from "applesauce-core/helpers/relays";
4
+ import { isHexKey } from "applesauce-core/helpers/string";
5
+ import { normalizeURL } from "applesauce-core/helpers/url";
6
+ import { isNappletHandlerAddress } from "../helpers/napplet-handlers.js";
7
+ import { NAPPLET_KIND, NAPPLET_ROOT_KIND, NAPPLET_SNAPSHOT_KIND, parseNappletConvention } from "../helpers/napplet.js";
8
+ /** Returns the first safe relay hint, normalized */
9
+ function getRelayHint(relays) {
10
+ const hint = relays?.find((url) => isSafeRelayURL(url));
11
+ return hint ? normalizeURL(hint) : undefined;
12
+ }
13
+ /** Creates an `a` tag for a root or named napplet address */
14
+ function createAddressTag(pointer) {
15
+ if (!isNappletHandlerAddress(pointer))
16
+ throw new Error("Expected a root or named napplet address");
17
+ const coordinate = getReplaceableAddressFromPointer(pointer);
18
+ const relay = getRelayHint(pointer.relays);
19
+ return relay ? ["a", coordinate, relay] : ["a", coordinate];
20
+ }
21
+ /** Creates an `e` tag for a pinned snapshot */
22
+ function createSnapshotTag(pointer) {
23
+ // Replaceable manifest ids become unresolvable once the napplet updates, so only snapshots can be pinned
24
+ if (pointer.kind !== undefined && pointer.kind !== NAPPLET_SNAPSHOT_KIND) {
25
+ throw new Error("Napplet pins must reference a kind 5129 snapshot");
26
+ }
27
+ if (!isHexKey(pointer.id))
28
+ throw new Error("Invalid napplet snapshot id");
29
+ const id = pointer.id.toLowerCase();
30
+ const relay = getRelayHint(pointer.relays);
31
+ // The relay hint is positional, so keep an empty slot when only the author is known
32
+ if (pointer.author)
33
+ return ["e", id, relay ?? "", pointer.author];
34
+ return relay ? ["e", id, relay] : ["e", id];
35
+ }
36
+ /**
37
+ * Creates the archetype-wide `a` or `e` tag for a napplet
38
+ * @throws if the input is not a root or named napplet, or a kind 5129 snapshot
39
+ */
40
+ export function createNappletHandlerTag(input) {
41
+ if (typeof input === "string") {
42
+ if (isHexKey(input))
43
+ return createSnapshotTag({ id: input });
44
+ const pointer = input.startsWith("naddr1") ? decodeAddressPointer(input) : parseReplaceableAddress(input);
45
+ if (pointer)
46
+ return createAddressTag(pointer);
47
+ const snapshot = decodeEventPointer(input);
48
+ if (snapshot)
49
+ return createSnapshotTag(snapshot);
50
+ throw new Error(`Invalid napplet reference: ${input}`);
51
+ }
52
+ if (isEvent(input)) {
53
+ if (input.kind === NAPPLET_SNAPSHOT_KIND) {
54
+ return createSnapshotTag({ id: input.id, kind: input.kind, author: input.pubkey });
55
+ }
56
+ if (input.kind !== NAPPLET_KIND && input.kind !== NAPPLET_ROOT_KIND) {
57
+ throw new Error("Expected a napplet manifest event");
58
+ }
59
+ const identifier = input.tags.find((t) => t[0] === "d")?.[1] ?? "";
60
+ return createAddressTag({ kind: input.kind, pubkey: input.pubkey, identifier });
61
+ }
62
+ if (isAddressPointer(input))
63
+ return createAddressTag(input);
64
+ return createSnapshotTag(input);
65
+ }
66
+ /**
67
+ * Returns the coordinate or snapshot id used as an `i` tag reference
68
+ * @throws if the input is not a root or named napplet, or a kind 5129 snapshot
69
+ */
70
+ export function getNappletHandlerReference(input) {
71
+ return createNappletHandlerTag(input)[1];
72
+ }
73
+ /** Checks if a tag is an archetype-wide handler entry for a reference */
74
+ function isHandlerTag(tag, reference) {
75
+ return (tag[0] === "a" || tag[0] === "e") && tag[1] === reference;
76
+ }
77
+ /** Checks if a tag is an intent-specific handler entry, optionally for a single reference */
78
+ function isIntentTag(tag, identity, reference) {
79
+ return tag[0] === "i" && tag[1] === identity && (reference === undefined || tag[2] === reference);
80
+ }
81
+ /** Inserts a tag before the first matching tag, or appends it when none match */
82
+ function insertBefore(tags, tag, matches) {
83
+ const index = tags.findIndex(matches);
84
+ if (index === -1)
85
+ return [...tags, tag];
86
+ return [...tags.slice(0, index), tag, ...tags.slice(index)];
87
+ }
88
+ /** Throws if a convention identity is malformed or has a query or fragment */
89
+ function assertConvention(identity) {
90
+ if (!parseNappletConvention(identity))
91
+ throw new Error(`Invalid napplet convention identity: ${identity}`);
92
+ }
93
+ /**
94
+ * Adds an archetype-wide handler as the last fallback, or updates its relay hint in place
95
+ * @throws if the input is not a root or named napplet, or a kind 5129 snapshot
96
+ */
97
+ export function addNappletHandlerTag(input) {
98
+ const tag = createNappletHandlerTag(input);
99
+ return (tags) => {
100
+ const index = tags.findIndex((t) => isHandlerTag(t, tag[1]));
101
+ if (index === -1)
102
+ return [...tags, tag];
103
+ return tags.map((t, i) => (i === index ? tag : t));
104
+ };
105
+ }
106
+ /**
107
+ * Moves or inserts an archetype-wide handler to the front so it becomes preferred
108
+ * @throws if the input is not a root or named napplet, or a kind 5129 snapshot
109
+ */
110
+ export function preferNappletHandlerTag(input) {
111
+ const tag = createNappletHandlerTag(input);
112
+ return (tags) => {
113
+ const remaining = tags.filter((t) => !isHandlerTag(t, tag[1]));
114
+ return insertBefore(remaining, tag, (t) => t[0] === "a" || t[0] === "e");
115
+ };
116
+ }
117
+ /**
118
+ * Removes an archetype-wide handler
119
+ * @throws if the input is not a root or named napplet, or a kind 5129 snapshot
120
+ */
121
+ export function removeNappletHandlerTag(input) {
122
+ const reference = getNappletHandlerReference(input);
123
+ return (tags) => tags.filter((t) => !isHandlerTag(t, reference));
124
+ }
125
+ /**
126
+ * Adds an intent-specific handler as the last fallback for a convention identity
127
+ * @throws if the identity is invalid, or the input is not a napplet or kind 5129 snapshot
128
+ */
129
+ export function addNappletIntentHandlerTag(identity, input) {
130
+ assertConvention(identity);
131
+ const reference = getNappletHandlerReference(input);
132
+ return (tags) => {
133
+ if (tags.some((t) => isIntentTag(t, identity, reference)))
134
+ return tags;
135
+ return [...tags, ["i", identity, reference]];
136
+ };
137
+ }
138
+ /**
139
+ * Moves or inserts an intent-specific handler to the front so it becomes preferred for a convention identity
140
+ * @throws if the identity is invalid, or the input is not a napplet or kind 5129 snapshot
141
+ */
142
+ export function preferNappletIntentHandlerTag(identity, input) {
143
+ assertConvention(identity);
144
+ const reference = getNappletHandlerReference(input);
145
+ return (tags) => {
146
+ const remaining = tags.filter((t) => !isIntentTag(t, identity, reference));
147
+ return insertBefore(remaining, ["i", identity, reference], (t) => isIntentTag(t, identity));
148
+ };
149
+ }
150
+ /**
151
+ * Removes one intent-specific handler, or every handler for the convention identity when no input is given
152
+ * @throws if the input is not a napplet or kind 5129 snapshot
153
+ */
154
+ export function removeNappletIntentHandlerTag(identity, input) {
155
+ const reference = input === undefined ? undefined : getNappletHandlerReference(input);
156
+ return (tags) => tags.filter((t) => !isIntentTag(t, identity, reference));
157
+ }
158
+ /** Removes every `a`, `e`, and `i` handler entry while keeping the `d` tag and unknown tags */
159
+ export function clearNappletHandlerTags() {
160
+ return (tags) => tags.filter((t) => t[0] !== "a" && t[0] !== "e" && t[0] !== "i");
161
+ }
@@ -0,0 +1,51 @@
1
+ import { EventOperation } from "applesauce-core/factories";
2
+ import { AddressPointer } from "applesauce-core/helpers/pointers";
3
+ import { NappletIconType } from "../helpers/napplet.js";
4
+ /** Sets the `d` tag identifier of a named napplet */
5
+ export declare function setNappletIdentifier(identifier: string): EventOperation;
6
+ /**
7
+ * Sets the sha256 of the napplet `index.html` artifact (`x` tag)
8
+ * @throws if the hash is not a 64 character lowercase hex string
9
+ */
10
+ export declare function setNappletArtifactHash(sha256: string): EventOperation;
11
+ /** Sets the plain-text description of the napplet */
12
+ export declare function setNappletDescription(description: string): EventOperation;
13
+ /** Sets or removes the short display label (`title` tag) */
14
+ export declare function setNappletTitle(title: string | null): EventOperation;
15
+ /** Sets or removes the source URL (`source` tag) */
16
+ export declare function setNappletSource(url: string | null): EventOperation;
17
+ /** Adds an archetype (`z` tag) */
18
+ export declare function addNappletArchetype(archetype: string): EventOperation;
19
+ /** Removes an archetype (`z` tag) */
20
+ export declare function removeNappletArchetype(archetype: string): EventOperation;
21
+ /** Adds or replaces an accepted intent and its parameter names (`i` tag) */
22
+ export declare function addNappletIntent(intent: string, params?: string[]): EventOperation;
23
+ /** Removes an accepted intent (`i` tag) */
24
+ export declare function removeNappletIntent(intent: string): EventOperation;
25
+ /** Adds a NAP domain required for full functionality (`R` tag) */
26
+ export declare function addNappletRequiredDomain(domain: string): EventOperation;
27
+ /** Removes a required NAP domain (`R` tag) */
28
+ export declare function removeNappletRequiredDomain(domain: string): EventOperation;
29
+ /** Adds an optional NAP domain (`O` tag) */
30
+ export declare function addNappletOptionalDomain(domain: string): EventOperation;
31
+ /** Removes an optional NAP domain (`O` tag) */
32
+ export declare function removeNappletOptionalDomain(domain: string): EventOperation;
33
+ /** Adds a Blossom server hint (`server` tag) */
34
+ export declare function addNappletServer(url: string): EventOperation;
35
+ /** Removes a Blossom server hint (`server` tag) */
36
+ export declare function removeNappletServer(url: string): EventOperation;
37
+ /**
38
+ * Sets or removes the content-addressed icon (`icon` tag)
39
+ * @throws if the hash is not a lowercase hex sha256 or the MIME type is not png, jpeg or webp
40
+ */
41
+ export declare function setNappletIcon(sha256: string | null, type?: NappletIconType): EventOperation;
42
+ /**
43
+ * Sets or removes the address of the napplet a snapshot derives from (`a` tag)
44
+ * @throws if the address cannot be parsed
45
+ */
46
+ export declare function setNappletParent(parent: AddressPointer | string | null): EventOperation;
47
+ /**
48
+ * Sets or removes the address of the root napplet a snapshot's lineage originates from (`A` tag)
49
+ * @throws if the address cannot be parsed
50
+ */
51
+ export declare function setNappletRoot(root: AddressPointer | string | null): EventOperation;
@@ -0,0 +1,121 @@
1
+ import { getReplaceableAddressFromPointer, parseReplaceableAddress, } from "applesauce-core/helpers/pointers";
2
+ import { isSafeRelayURL } from "applesauce-core/helpers/relays";
3
+ import { normalizeURL } from "applesauce-core/helpers/url";
4
+ import { setContent } from "applesauce-core/operations/content";
5
+ import { addNameValueTag, removeNameValueTag, removeSingletonTag, setSingletonTag, } from "applesauce-core/operations/tag/common";
6
+ import { includeSingletonTag, modifyPublicTags } from "applesauce-core/operations/tags";
7
+ import { isSha256 } from "../helpers/blossom.js";
8
+ import { isNappletIconType } from "../helpers/napplet.js";
9
+ /** Builds a lineage tag (`a` or `A`) for a napplet address */
10
+ function createLineageTag(name, input) {
11
+ const pointer = typeof input === "string" ? parseReplaceableAddress(input) : input;
12
+ if (!pointer)
13
+ throw new Error(`Invalid napplet address: ${input}`);
14
+ const hint = pointer.relays?.find((url) => isSafeRelayURL(url));
15
+ const address = getReplaceableAddressFromPointer(pointer);
16
+ return hint ? [name, address, normalizeURL(hint)] : [name, address];
17
+ }
18
+ /** Removes all but the first tag with a name */
19
+ function keepFirstTag(name) {
20
+ return (tags) => {
21
+ const first = tags.findIndex((t) => t[0] === name);
22
+ return tags.filter((t, i) => t[0] !== name || i === first);
23
+ };
24
+ }
25
+ /** Sets the `d` tag identifier of a named napplet */
26
+ export function setNappletIdentifier(identifier) {
27
+ return includeSingletonTag(["d", identifier], true);
28
+ }
29
+ /**
30
+ * Sets the sha256 of the napplet `index.html` artifact (`x` tag)
31
+ * @throws if the hash is not a 64 character lowercase hex string
32
+ */
33
+ export function setNappletArtifactHash(sha256) {
34
+ if (!isSha256(sha256))
35
+ throw new Error("Napplet artifact hash must be a lowercase hex sha256");
36
+ // Drop duplicate "x" tags since a manifest must carry exactly one
37
+ return modifyPublicTags(keepFirstTag("x"), setSingletonTag(["x", sha256], true));
38
+ }
39
+ /** Sets the plain-text description of the napplet */
40
+ export function setNappletDescription(description) {
41
+ return setContent(description);
42
+ }
43
+ /** Sets or removes the short display label (`title` tag) */
44
+ export function setNappletTitle(title) {
45
+ return modifyPublicTags(title === null ? removeSingletonTag("title") : setSingletonTag(["title", title], true));
46
+ }
47
+ /** Sets or removes the source URL (`source` tag) */
48
+ export function setNappletSource(url) {
49
+ return modifyPublicTags(url === null ? removeSingletonTag("source") : setSingletonTag(["source", url], true));
50
+ }
51
+ /** Adds an archetype (`z` tag) */
52
+ export function addNappletArchetype(archetype) {
53
+ return modifyPublicTags(addNameValueTag(["z", archetype]));
54
+ }
55
+ /** Removes an archetype (`z` tag) */
56
+ export function removeNappletArchetype(archetype) {
57
+ return modifyPublicTags(removeNameValueTag(["z", archetype]));
58
+ }
59
+ /** Adds or replaces an accepted intent and its parameter names (`i` tag) */
60
+ export function addNappletIntent(intent, params = []) {
61
+ return modifyPublicTags(addNameValueTag(["i", intent, ...params]));
62
+ }
63
+ /** Removes an accepted intent (`i` tag) */
64
+ export function removeNappletIntent(intent) {
65
+ return modifyPublicTags(removeNameValueTag(["i", intent]));
66
+ }
67
+ /** Adds a NAP domain required for full functionality (`R` tag) */
68
+ export function addNappletRequiredDomain(domain) {
69
+ return modifyPublicTags(addNameValueTag(["R", domain]));
70
+ }
71
+ /** Removes a required NAP domain (`R` tag) */
72
+ export function removeNappletRequiredDomain(domain) {
73
+ return modifyPublicTags(removeNameValueTag(["R", domain]));
74
+ }
75
+ /** Adds an optional NAP domain (`O` tag) */
76
+ export function addNappletOptionalDomain(domain) {
77
+ return modifyPublicTags(addNameValueTag(["O", domain]));
78
+ }
79
+ /** Removes an optional NAP domain (`O` tag) */
80
+ export function removeNappletOptionalDomain(domain) {
81
+ return modifyPublicTags(removeNameValueTag(["O", domain]));
82
+ }
83
+ /** Adds a Blossom server hint (`server` tag) */
84
+ export function addNappletServer(url) {
85
+ return modifyPublicTags(addNameValueTag(["server", url]));
86
+ }
87
+ /** Removes a Blossom server hint (`server` tag) */
88
+ export function removeNappletServer(url) {
89
+ return modifyPublicTags(removeNameValueTag(["server", url]));
90
+ }
91
+ /**
92
+ * Sets or removes the content-addressed icon (`icon` tag)
93
+ * @throws if the hash is not a lowercase hex sha256 or the MIME type is not png, jpeg or webp
94
+ */
95
+ export function setNappletIcon(sha256, type) {
96
+ if (sha256 === null)
97
+ return modifyPublicTags(removeSingletonTag("icon"));
98
+ if (!isSha256(sha256))
99
+ throw new Error("Napplet icon hash must be a lowercase hex sha256");
100
+ if (!type || !isNappletIconType(type))
101
+ throw new Error(`Unsupported napplet icon type: ${type}`);
102
+ return modifyPublicTags(setSingletonTag(["icon", sha256, type], true));
103
+ }
104
+ /**
105
+ * Sets or removes the address of the napplet a snapshot derives from (`a` tag)
106
+ * @throws if the address cannot be parsed
107
+ */
108
+ export function setNappletParent(parent) {
109
+ if (parent === null)
110
+ return modifyPublicTags(removeSingletonTag("a"));
111
+ return modifyPublicTags(setSingletonTag(createLineageTag("a", parent), true));
112
+ }
113
+ /**
114
+ * Sets or removes the address of the root napplet a snapshot's lineage originates from (`A` tag)
115
+ * @throws if the address cannot be parsed
116
+ */
117
+ export function setNappletRoot(root) {
118
+ if (root === null)
119
+ return modifyPublicTags(removeSingletonTag("A"));
120
+ return modifyPublicTags(setSingletonTag(createLineageTag("A", root), true));
121
+ }
@@ -0,0 +1,51 @@
1
+ import { EventOperation } from "applesauce-core/factories";
2
+ import { AddressPointer } from "applesauce-core/helpers/pointers";
3
+ /**
4
+ * Sets the identifier of a named site
5
+ * @throws if the identifier is invalid or the draft is not a named site
6
+ */
7
+ export declare function setNsiteIdentifier(identifier: string): EventOperation;
8
+ /** Sets or removes the site's title */
9
+ export declare function setNsiteTitle(title: string | null): EventOperation;
10
+ /** Sets or removes the site's description tag */
11
+ export declare function setNsiteDescription(description: string | null): EventOperation;
12
+ /** Sets or removes the site's source repository or archive URL */
13
+ export declare function setNsiteSource(source: string | null): EventOperation;
14
+ /** Adds a Blossom server hint */
15
+ export declare function addNsiteServer(server: string): EventOperation;
16
+ /** Removes a Blossom server hint */
17
+ export declare function removeNsiteServer(server: string): EventOperation;
18
+ /**
19
+ * Adds or replaces an upstream app descriptor reference
20
+ * @throws if the address is not addressable
21
+ */
22
+ export declare function addNsiteApp(app: AddressPointer | string): EventOperation;
23
+ /**
24
+ * Removes an upstream app descriptor reference
25
+ * @throws if the address is not addressable
26
+ */
27
+ export declare function removeNsiteApp(app: AddressPointer | string): EventOperation;
28
+ /**
29
+ * Sets or removes the immediate parent site address
30
+ * @throws if the address does not reference a root or named site
31
+ */
32
+ export declare function setNsiteParent(parent: AddressPointer | string | null): EventOperation;
33
+ /**
34
+ * Sets or removes the origin site address of the copy lineage
35
+ * @throws if the address does not reference a root or named site
36
+ */
37
+ export declare function setNsiteRoot(root: AddressPointer | string | null): EventOperation;
38
+ /**
39
+ * Sets or removes the advertised aggregate hash
40
+ * @throws if the hash is not lowercase hexadecimal SHA-256
41
+ */
42
+ export declare function setNsiteAggregateHash(hash: string | null): EventOperation;
43
+ /** Updates the aggregate hash from all current path tags */
44
+ export declare function updateNsiteAggregateHash(): EventOperation;
45
+ /**
46
+ * Adds or replaces a file mapping and updates the aggregate hash
47
+ * @throws if the path or hash is invalid
48
+ */
49
+ export declare function setNsiteFile(path: string, hash: string): EventOperation;
50
+ /** Removes a file mapping and updates the aggregate hash */
51
+ export declare function removeNsiteFile(path: string): EventOperation;
@@ -0,0 +1,112 @@
1
+ import { getReplaceableAddressFromPointer, parseReplaceableAddress, } from "applesauce-core/helpers/pointers";
2
+ import { isSafeRelayURL } from "applesauce-core/helpers/relays";
3
+ import { normalizeURL } from "applesauce-core/helpers/url";
4
+ import { addNameValueTag, removeNameValueTag } from "applesauce-core/operations/tag/common";
5
+ import { modifyPublicTags } from "applesauce-core/operations/tags";
6
+ import { isSha256 } from "../helpers/blossom.js";
7
+ import { computeNsiteAggregateHash, isNsiteAddressPointer, isValidNsiteIdentifier, isValidNsitePath, NSITE_KIND, } from "../helpers/nsite.js";
8
+ function singleton(name, value) {
9
+ return modifyPublicTags((tags) => [...tags.filter((t) => t[0] !== name), ...(value ? [[name, ...value]] : [])]);
10
+ }
11
+ function pointerTag(name, input) {
12
+ const pointer = typeof input === "string" ? parseReplaceableAddress(input) : input;
13
+ if (!pointer ||
14
+ !isSha256(pointer.pubkey) ||
15
+ (name === "app" ? pointer.kind < 30000 || pointer.kind >= 40000 : !isNsiteAddressPointer(pointer)))
16
+ throw new Error(`Invalid ${name === "app" ? "app descriptor" : "nsite"} address`);
17
+ const relay = pointer.relays?.find(isSafeRelayURL);
18
+ return [name, getReplaceableAddressFromPointer(pointer), ...(relay ? [normalizeURL(relay)] : [])];
19
+ }
20
+ /**
21
+ * Sets the identifier of a named site
22
+ * @throws if the identifier is invalid or the draft is not a named site
23
+ */
24
+ export function setNsiteIdentifier(identifier) {
25
+ if (!isValidNsiteIdentifier(identifier))
26
+ throw new Error("Invalid nsite identifier");
27
+ return (draft) => {
28
+ if (draft.kind !== NSITE_KIND)
29
+ throw new Error("Only named nsites have identifiers");
30
+ return singleton("d", [identifier])(draft);
31
+ };
32
+ }
33
+ /** Sets or removes the site's title */
34
+ export function setNsiteTitle(title) {
35
+ return singleton("title", title === null ? null : [title]);
36
+ }
37
+ /** Sets or removes the site's description tag */
38
+ export function setNsiteDescription(description) {
39
+ return singleton("description", description === null ? null : [description]);
40
+ }
41
+ /** Sets or removes the site's source repository or archive URL */
42
+ export function setNsiteSource(source) {
43
+ return singleton("source", source === null ? null : [source]);
44
+ }
45
+ /** Adds a Blossom server hint */
46
+ export function addNsiteServer(server) {
47
+ return modifyPublicTags(addNameValueTag(["server", server]));
48
+ }
49
+ /** Removes a Blossom server hint */
50
+ export function removeNsiteServer(server) {
51
+ return modifyPublicTags(removeNameValueTag(["server", server]));
52
+ }
53
+ /**
54
+ * Adds or replaces an upstream app descriptor reference
55
+ * @throws if the address is not addressable
56
+ */
57
+ export function addNsiteApp(app) {
58
+ return modifyPublicTags(addNameValueTag(pointerTag("app", app)));
59
+ }
60
+ /**
61
+ * Removes an upstream app descriptor reference
62
+ * @throws if the address is not addressable
63
+ */
64
+ export function removeNsiteApp(app) {
65
+ return modifyPublicTags(removeNameValueTag(pointerTag("app", app).slice(0, 2)));
66
+ }
67
+ /**
68
+ * Sets or removes the immediate parent site address
69
+ * @throws if the address does not reference a root or named site
70
+ */
71
+ export function setNsiteParent(parent) {
72
+ return singleton("a", parent === null ? null : pointerTag("a", parent).slice(1));
73
+ }
74
+ /**
75
+ * Sets or removes the origin site address of the copy lineage
76
+ * @throws if the address does not reference a root or named site
77
+ */
78
+ export function setNsiteRoot(root) {
79
+ return singleton("A", root === null ? null : pointerTag("A", root).slice(1));
80
+ }
81
+ /**
82
+ * Sets or removes the advertised aggregate hash
83
+ * @throws if the hash is not lowercase hexadecimal SHA-256
84
+ */
85
+ export function setNsiteAggregateHash(hash) {
86
+ if (hash !== null && !isSha256(hash))
87
+ throw new Error("Invalid nsite aggregate hash");
88
+ return singleton("x", hash === null ? null : [hash, "aggregate"]);
89
+ }
90
+ /** Updates the aggregate hash from all current path tags */
91
+ export function updateNsiteAggregateHash() {
92
+ return (draft) => setNsiteAggregateHash(computeNsiteAggregateHash(draft))(draft);
93
+ }
94
+ /**
95
+ * Adds or replaces a file mapping and updates the aggregate hash
96
+ * @throws if the path or hash is invalid
97
+ */
98
+ export function setNsiteFile(path, hash) {
99
+ if (!isValidNsitePath(path) || !isSha256(hash))
100
+ throw new Error("Invalid nsite file path or hash");
101
+ return modifyPublicTags((tags) => {
102
+ const next = [...tags.filter((t) => !(t[0] === "path" && t[1] === path) && t[0] !== "x"), ["path", path, hash]];
103
+ return [...next, ["x", computeNsiteAggregateHash({ tags: next }), "aggregate"]];
104
+ });
105
+ }
106
+ /** Removes a file mapping and updates the aggregate hash */
107
+ export function removeNsiteFile(path) {
108
+ return modifyPublicTags((tags) => {
109
+ const next = tags.filter((t) => !(t[0] === "path" && t[1] === path) && t[0] !== "x");
110
+ return [...next, ["x", computeNsiteAggregateHash({ tags: next }), "aggregate"]];
111
+ });
112
+ }
@@ -1,12 +1,22 @@
1
1
  import { EventOperation } from "applesauce-core/factories";
2
- import { NostrEvent } from "applesauce-core/helpers/event";
2
+ import { NostrEvent, Rumor } from "applesauce-core/helpers/event";
3
3
  import { Emoji } from "../helpers/emoji.js";
4
4
  /** Sets the content for a reaction event */
5
5
  export declare function setReaction(emoji?: string | Emoji): EventOperation;
6
+ /**
7
+ * The event a reaction points to. A full event/rumor carries its tags (so an
8
+ * addressable target can be resolved to an "a" tag), or a lightweight
9
+ * `{ id, pubkey, kind }` pointer for cases where only the identity is known.
10
+ */
11
+ export type ReactionParent = NostrEvent | Rumor | {
12
+ id: string;
13
+ pubkey: string;
14
+ kind: number;
15
+ };
6
16
  /**
7
17
  * Includes NIP-25 "e", "p", "k", and "a" tags for a reaction event to point to a parent event
8
18
  * @param event - Event being reacted to
9
19
  * @param getEventRelayHint - Optional function to get relay hint for event ID
10
20
  * @param getPubkeyRelayHint - Optional function to get relay hint for pubkey
11
21
  */
12
- export declare function setReactionParent(event: NostrEvent, getEventRelayHint?: (eventId: string) => Promise<string | undefined>, getPubkeyRelayHint?: (pubkey: string) => Promise<string | undefined>): EventOperation;
22
+ export declare function setReactionParent(event: ReactionParent, getEventRelayHint?: (eventId: string) => Promise<string | undefined>, getPubkeyRelayHint?: (pubkey: string) => Promise<string | undefined>): EventOperation;
@@ -26,7 +26,7 @@ export function setReactionParent(event, getEventRelayHint, getPubkeyRelayHint)
26
26
  pubkey: event.pubkey,
27
27
  relays: pubkeyHint ? [pubkeyHint] : undefined,
28
28
  });
29
- if (isAddressableKind(event.kind)) {
29
+ if (isAddressableKind(event.kind) && "tags" in event) {
30
30
  // include "a" tag
31
31
  const identifier = getTagValue(event, "d");
32
32
  if (identifier)
@@ -0,0 +1,33 @@
1
+ import { EventOperation } from "applesauce-core/factories";
2
+ import { ReportReason, ReportTarget } from "../helpers/reports.js";
3
+ /** An event identity required when reporting an event or its media */
4
+ export type ReportEventTarget = {
5
+ /** The event ID */
6
+ id: string;
7
+ /** The event author's public key */
8
+ pubkey: string;
9
+ };
10
+ /**
11
+ * Adds or updates a reported user
12
+ * @throws if the public key or reason is invalid
13
+ */
14
+ export declare function addReportUser(pubkey: string, reason: ReportReason): EventOperation;
15
+ /**
16
+ * Adds or updates a reported event and includes its author
17
+ * @throws if the event identity or reason is invalid
18
+ */
19
+ export declare function addReportEvent(event: ReportEventTarget, reason: ReportReason): EventOperation;
20
+ /**
21
+ * Adds or updates a reported blob and includes its containing event and author
22
+ * @throws if the hash, event identity, or reason is invalid
23
+ */
24
+ export declare function addReportBlob(hash: string, event: ReportEventTarget, reason: ReportReason): EventOperation;
25
+ /** Removes matching target tags and preserves all other tags */
26
+ export declare function removeReportTarget(type: ReportTarget["type"], value: string): EventOperation;
27
+ /**
28
+ * Adds a media server or direct media URL without rewriting its path
29
+ * @throws if the URL is invalid or does not use HTTP or HTTPS
30
+ */
31
+ export declare function addReportServer(server: string): EventOperation;
32
+ /** Removes a media server or direct media URL */
33
+ export declare function removeReportServer(server: string): EventOperation;
@@ -0,0 +1,60 @@
1
+ import { modifyPublicTags } from "applesauce-core/operations/tags";
2
+ import { isReportIdentifier, ReportReason } from "../helpers/reports.js";
3
+ function check(value, reason) {
4
+ if (!isReportIdentifier(value))
5
+ throw new Error("Expected a 32-byte lowercase hex report target");
6
+ if (reason !== undefined && !Object.values(ReportReason).includes(reason))
7
+ throw new Error("Invalid report reason");
8
+ }
9
+ function put(tags, name, value, reason) {
10
+ const existing = tags.find((t) => t[0] === name && t[1] === value);
11
+ if (existing && reason === undefined)
12
+ return tags;
13
+ return [...tags.filter((t) => t[0] !== name || t[1] !== value), reason ? [name, value, reason] : [name, value]];
14
+ }
15
+ /**
16
+ * Adds or updates a reported user
17
+ * @throws if the public key or reason is invalid
18
+ */
19
+ export function addReportUser(pubkey, reason) {
20
+ check(pubkey, reason);
21
+ return modifyPublicTags((tags) => put(tags, "p", pubkey, reason));
22
+ }
23
+ /**
24
+ * Adds or updates a reported event and includes its author
25
+ * @throws if the event identity or reason is invalid
26
+ */
27
+ export function addReportEvent(event, reason) {
28
+ check(event.id, reason);
29
+ check(event.pubkey);
30
+ return modifyPublicTags((tags) => put(put(tags, "p", event.pubkey), "e", event.id, reason));
31
+ }
32
+ /**
33
+ * Adds or updates a reported blob and includes its containing event and author
34
+ * @throws if the hash, event identity, or reason is invalid
35
+ */
36
+ export function addReportBlob(hash, event, reason) {
37
+ check(hash, reason);
38
+ check(event.id);
39
+ check(event.pubkey);
40
+ return modifyPublicTags((tags) => put(put(put(tags, "p", event.pubkey), "e", event.id), "x", hash, reason));
41
+ }
42
+ /** Removes matching target tags and preserves all other tags */
43
+ export function removeReportTarget(type, value) {
44
+ const name = { user: "p", event: "e", blob: "x" }[type];
45
+ return modifyPublicTags((tags) => tags.filter((t) => t[0] !== name || t[1] !== value));
46
+ }
47
+ /**
48
+ * Adds a media server or direct media URL without rewriting its path
49
+ * @throws if the URL is invalid or does not use HTTP or HTTPS
50
+ */
51
+ export function addReportServer(server) {
52
+ const url = new URL(server);
53
+ if (url.protocol !== "http:" && url.protocol !== "https:")
54
+ throw new Error("Expected an HTTP media URL");
55
+ return modifyPublicTags((tags) => tags.some((t) => t[0] === "server" && t[1] === server) ? tags : [...tags, ["server", server]]);
56
+ }
57
+ /** Removes a media server or direct media URL */
58
+ export function removeReportServer(server) {
59
+ return modifyPublicTags((tags) => tags.filter((t) => t[0] !== "server" || t[1] !== server));
60
+ }
@@ -1,3 +1,4 @@
1
+ import { serializeURL } from "applesauce-core/helpers/url";
1
2
  import { ensureMarkedProfilePointerTag } from "applesauce-core/helpers/factory";
2
3
  import { addNameValueTag, removeNameValueTag } from "applesauce-core/operations/tag/common";
3
4
  import { includeSingletonTag, modifyPublicTags } from "applesauce-core/operations/tags";
@@ -17,11 +18,11 @@ export function setImage(image) {
17
18
  }
18
19
  /** Sets the streaming URL for a live event */
19
20
  export function setStreamingUrl(url) {
20
- return includeSingletonTag(["streaming", new URL(url).toString()], true);
21
+ return includeSingletonTag(["streaming", serializeURL(url)], true);
21
22
  }
22
23
  /** Sets the recording URL for a live event (typically after the event ends) */
23
24
  export function setRecordingUrl(url) {
24
- return includeSingletonTag(["recording", new URL(url).toString()], true);
25
+ return includeSingletonTag(["recording", serializeURL(url)], true);
25
26
  }
26
27
  /** Sets the start timestamp for a live event */
27
28
  export function setStartTime(start) {
@@ -59,11 +60,11 @@ export function removeParticipant(pubkey) {
59
60
  }
60
61
  /** Adds a relay to the live event's relay list */
61
62
  export function addRelay(relay) {
62
- return modifyPublicTags(addNameValueTag(["relays", new URL(relay).toString()], true));
63
+ return modifyPublicTags(addNameValueTag(["relays", serializeURL(relay)], true));
63
64
  }
64
65
  /** Removes a relay from the live event's relay list */
65
66
  export function removeRelay(relay) {
66
- return modifyPublicTags(removeNameValueTag(["relays", new URL(relay).toString()]));
67
+ return modifyPublicTags(removeNameValueTag(["relays", serializeURL(relay)]));
67
68
  }
68
69
  /** Sets a pinned live chat message */
69
70
  export function setPinnedMessage(eventId) {