applesauce-common 5.2.0 → 6.0.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 (263) hide show
  1. package/dist/casts/_circular-import.d.ts +7 -0
  2. package/dist/casts/_circular-import.js +9 -0
  3. package/dist/casts/article.d.ts +1 -1
  4. package/dist/casts/badge-award.d.ts +24 -0
  5. package/dist/casts/badge-award.js +39 -0
  6. package/dist/casts/badge.d.ts +19 -0
  7. package/dist/casts/badge.js +48 -0
  8. package/dist/casts/bookmarks.d.ts +5 -5
  9. package/dist/casts/cast.d.ts +1 -30
  10. package/dist/casts/cast.js +2 -67
  11. package/dist/casts/comment.d.ts +5 -5
  12. package/dist/casts/emoji-pack.d.ts +11 -0
  13. package/dist/casts/emoji-pack.js +25 -0
  14. package/dist/casts/favorite-emojis.d.ts +25 -0
  15. package/dist/casts/favorite-emojis.js +62 -0
  16. package/dist/casts/file-metadata.d.ts +22 -0
  17. package/dist/casts/file-metadata.js +55 -0
  18. package/dist/casts/groups.d.ts +1 -1
  19. package/dist/casts/index.d.ts +7 -0
  20. package/dist/casts/index.js +7 -0
  21. package/dist/casts/mutes.d.ts +1 -1
  22. package/dist/casts/note.d.ts +7 -7
  23. package/dist/casts/profile-badges.d.ts +28 -0
  24. package/dist/casts/profile-badges.js +59 -0
  25. package/dist/casts/reaction.d.ts +1 -1
  26. package/dist/casts/relay-lists.d.ts +1 -1
  27. package/dist/casts/relay-monitor.d.ts +1 -1
  28. package/dist/casts/report.d.ts +2 -2
  29. package/dist/casts/share.d.ts +2 -2
  30. package/dist/casts/stream.d.ts +9 -9
  31. package/dist/casts/torrent.d.ts +3 -3
  32. package/dist/casts/trusted-assertions.d.ts +144 -0
  33. package/dist/casts/trusted-assertions.js +281 -0
  34. package/dist/casts/user.d.ts +22 -40
  35. package/dist/casts/user.js +105 -161
  36. package/dist/casts/zap-goal.d.ts +2 -2
  37. package/dist/casts/zap.d.ts +4 -4
  38. package/dist/factories/app-data.d.ts +13 -0
  39. package/dist/factories/app-data.js +20 -0
  40. package/dist/factories/badge-award.d.ts +25 -0
  41. package/dist/factories/badge-award.js +41 -0
  42. package/dist/factories/badge.d.ts +32 -0
  43. package/dist/factories/badge.js +50 -0
  44. package/dist/factories/blocked-relays.d.ts +10 -0
  45. package/dist/factories/blocked-relays.js +16 -0
  46. package/dist/factories/blossom-server-list.d.ts +19 -0
  47. package/dist/factories/blossom-server-list.js +36 -0
  48. package/dist/factories/bookmark-list.d.ts +23 -0
  49. package/dist/factories/bookmark-list.js +45 -0
  50. package/dist/factories/bookmark-set.d.ts +25 -0
  51. package/dist/factories/bookmark-set.js +51 -0
  52. package/dist/factories/calendar-event.d.ts +88 -0
  53. package/dist/factories/calendar-event.js +175 -0
  54. package/dist/factories/calendar-rsvp.d.ts +22 -0
  55. package/dist/factories/calendar-rsvp.js +35 -0
  56. package/dist/factories/calendar.d.ts +20 -0
  57. package/dist/factories/calendar.js +36 -0
  58. package/dist/factories/code-snippet.d.ts +65 -0
  59. package/dist/factories/code-snippet.js +100 -0
  60. package/dist/factories/comment.d.ts +26 -0
  61. package/dist/factories/comment.js +49 -0
  62. package/dist/factories/contacts.d.ts +19 -0
  63. package/dist/factories/contacts.js +36 -0
  64. package/dist/factories/dm-relays.d.ts +10 -0
  65. package/dist/factories/dm-relays.js +16 -0
  66. package/dist/factories/favorite-relays.d.ts +16 -0
  67. package/dist/factories/favorite-relays.js +31 -0
  68. package/dist/factories/file-metadata.d.ts +54 -0
  69. package/dist/factories/file-metadata.js +92 -0
  70. package/dist/factories/follow-set.d.ts +12 -0
  71. package/dist/factories/follow-set.js +22 -0
  72. package/dist/factories/gift-wrap.d.ts +17 -0
  73. package/dist/factories/gift-wrap.js +21 -0
  74. package/dist/factories/group-management.d.ts +63 -0
  75. package/dist/factories/group-management.js +147 -0
  76. package/dist/factories/group.d.ts +35 -0
  77. package/dist/factories/group.js +69 -0
  78. package/dist/factories/highlight.d.ts +33 -0
  79. package/dist/factories/highlight.js +49 -0
  80. package/dist/factories/index.d.ts +41 -0
  81. package/dist/factories/index.js +41 -0
  82. package/dist/factories/legacy-message.d.ts +10 -0
  83. package/dist/factories/legacy-message.js +19 -0
  84. package/dist/factories/list.d.ts +56 -0
  85. package/dist/factories/list.js +120 -0
  86. package/dist/factories/live-stream.d.ts +48 -0
  87. package/dist/factories/live-stream.js +90 -0
  88. package/dist/factories/mute-list.d.ts +27 -0
  89. package/dist/factories/mute-list.js +57 -0
  90. package/dist/factories/note.d.ts +38 -0
  91. package/dist/factories/note.js +66 -0
  92. package/dist/factories/picture-post.d.ts +28 -0
  93. package/dist/factories/picture-post.js +46 -0
  94. package/dist/factories/pin-list.d.ts +14 -0
  95. package/dist/factories/pin-list.js +24 -0
  96. package/dist/factories/poll-response.d.ts +36 -0
  97. package/dist/factories/poll-response.js +46 -0
  98. package/dist/factories/poll.d.ts +35 -0
  99. package/dist/factories/poll.js +48 -0
  100. package/dist/factories/profile-badges.d.ts +31 -0
  101. package/dist/factories/profile-badges.js +52 -0
  102. package/dist/factories/reaction.d.ts +22 -0
  103. package/dist/factories/reaction.js +37 -0
  104. package/dist/factories/relay-set.d.ts +12 -0
  105. package/dist/factories/relay-set.js +22 -0
  106. package/dist/factories/search-relays.d.ts +10 -0
  107. package/dist/factories/search-relays.js +16 -0
  108. package/dist/factories/share.d.ts +26 -0
  109. package/dist/factories/share.js +44 -0
  110. package/dist/factories/stream-chat-message.d.ts +22 -0
  111. package/dist/factories/stream-chat-message.js +31 -0
  112. package/dist/factories/torrent.d.ts +57 -0
  113. package/dist/factories/torrent.js +93 -0
  114. package/dist/factories/wrapped-message.d.ts +22 -0
  115. package/dist/factories/wrapped-message.js +39 -0
  116. package/dist/factories/zap-goal.d.ts +35 -0
  117. package/dist/factories/zap-goal.js +49 -0
  118. package/dist/factories/zap-request.d.ts +28 -0
  119. package/dist/factories/zap-request.js +55 -0
  120. package/dist/factories/zap.d.ts +13 -0
  121. package/dist/factories/zap.js +21 -0
  122. package/dist/helpers/badge-award.d.ts +15 -0
  123. package/dist/helpers/badge-award.js +32 -0
  124. package/dist/helpers/badge.d.ts +27 -0
  125. package/dist/helpers/badge.js +59 -0
  126. package/dist/helpers/blossom.d.ts +29 -1
  127. package/dist/helpers/blossom.js +64 -7
  128. package/dist/helpers/emoji-pack.d.ts +43 -0
  129. package/dist/helpers/emoji-pack.js +108 -0
  130. package/dist/helpers/emoji.d.ts +0 -4
  131. package/dist/helpers/emoji.js +0 -16
  132. package/dist/helpers/file-metadata.d.ts +18 -13
  133. package/dist/helpers/file-metadata.js +10 -4
  134. package/dist/helpers/groups.d.ts +1 -0
  135. package/dist/helpers/groups.js +3 -2
  136. package/dist/helpers/hashtag.d.ts +1 -0
  137. package/dist/helpers/hashtag.js +3 -3
  138. package/dist/helpers/index.d.ts +7 -2
  139. package/dist/helpers/index.js +7 -2
  140. package/dist/helpers/lists.d.ts +8 -0
  141. package/dist/helpers/lists.js +27 -5
  142. package/dist/helpers/picture-post.d.ts +2 -2
  143. package/dist/helpers/profile-badges.d.ts +23 -0
  144. package/dist/helpers/profile-badges.js +51 -0
  145. package/dist/helpers/trusted-assertions.d.ts +81 -0
  146. package/dist/helpers/trusted-assertions.js +161 -0
  147. package/dist/helpers/zap.d.ts +8 -2
  148. package/dist/helpers/zap.js +31 -26
  149. package/dist/index.d.ts +2 -2
  150. package/dist/index.js +3 -3
  151. package/dist/models/index.d.ts +1 -1
  152. package/dist/models/index.js +1 -1
  153. package/dist/observable/chainable.d.ts +1 -36
  154. package/dist/observable/chainable.js +2 -72
  155. package/dist/operations/app-data.d.ts +8 -3
  156. package/dist/operations/app-data.js +9 -4
  157. package/dist/operations/badge-award.d.ts +17 -0
  158. package/dist/operations/badge-award.js +30 -0
  159. package/dist/operations/badge.d.ts +22 -0
  160. package/dist/operations/badge.js +54 -0
  161. package/dist/operations/blossom.d.ts +1 -1
  162. package/dist/operations/calendar-event.d.ts +1 -1
  163. package/dist/operations/calendar-rsvp.d.ts +1 -1
  164. package/dist/operations/calendar.d.ts +1 -1
  165. package/dist/operations/channel.d.ts +1 -1
  166. package/dist/operations/client.d.ts +1 -1
  167. package/dist/operations/client.js +2 -2
  168. package/dist/operations/code-snippet.d.ts +27 -0
  169. package/dist/operations/code-snippet.js +63 -0
  170. package/dist/operations/comment.d.ts +7 -3
  171. package/dist/operations/comment.js +8 -4
  172. package/dist/operations/file-metadata.d.ts +38 -4
  173. package/dist/operations/file-metadata.js +105 -19
  174. package/dist/operations/geohash.d.ts +1 -1
  175. package/dist/operations/gift-wrap.d.ts +19 -7
  176. package/dist/operations/gift-wrap.js +36 -26
  177. package/dist/operations/group.d.ts +1 -1
  178. package/dist/operations/hashtags.d.ts +1 -1
  179. package/dist/operations/highlight.d.ts +1 -1
  180. package/dist/operations/highlight.js +5 -5
  181. package/dist/operations/index.d.ts +7 -1
  182. package/dist/operations/index.js +7 -1
  183. package/dist/operations/legacy-message.d.ts +1 -1
  184. package/dist/operations/list.d.ts +1 -1
  185. package/dist/operations/live-stream.d.ts +7 -3
  186. package/dist/operations/live-stream.js +9 -5
  187. package/dist/operations/media-attachment.d.ts +3 -3
  188. package/dist/operations/note.d.ts +10 -4
  189. package/dist/operations/note.js +14 -8
  190. package/dist/operations/picture-post.d.ts +1 -1
  191. package/dist/operations/poll-response.d.ts +1 -1
  192. package/dist/operations/poll-response.js +1 -1
  193. package/dist/operations/poll.d.ts +1 -1
  194. package/dist/operations/profile-badges.d.ts +26 -0
  195. package/dist/operations/profile-badges.js +150 -0
  196. package/dist/operations/reaction.d.ts +8 -3
  197. package/dist/operations/reaction.js +10 -5
  198. package/dist/operations/share.d.ts +8 -3
  199. package/dist/operations/share.js +10 -5
  200. package/dist/operations/stream.d.ts +1 -1
  201. package/dist/operations/tag/bookmarks.d.ts +1 -1
  202. package/dist/operations/torrent.d.ts +1 -1
  203. package/dist/operations/wrapped-message.d.ts +1 -1
  204. package/dist/operations/zap-goal.d.ts +1 -1
  205. package/dist/operations/zap-request.d.ts +22 -0
  206. package/dist/operations/zap-request.js +40 -0
  207. package/dist/operations/zap-split.d.ts +8 -4
  208. package/dist/operations/zap-split.js +10 -6
  209. package/dist/operations/zap.d.ts +12 -0
  210. package/dist/operations/zap.js +34 -0
  211. package/package.json +12 -11
  212. package/dist/blueprints/__register__.d.ts +0 -7
  213. package/dist/blueprints/__register__.js +0 -8
  214. package/dist/blueprints/app-data.d.ts +0 -5
  215. package/dist/blueprints/app-data.js +0 -10
  216. package/dist/blueprints/calendar.d.ts +0 -5
  217. package/dist/blueprints/calendar.js +0 -7
  218. package/dist/blueprints/channels.d.ts +0 -6
  219. package/dist/blueprints/channels.js +0 -13
  220. package/dist/blueprints/comment.d.ts +0 -13
  221. package/dist/blueprints/comment.js +0 -15
  222. package/dist/blueprints/delete.d.ts +0 -9
  223. package/dist/blueprints/delete.js +0 -14
  224. package/dist/blueprints/file-metadata.d.ts +0 -8
  225. package/dist/blueprints/file-metadata.js +0 -11
  226. package/dist/blueprints/follow-set.d.ts +0 -11
  227. package/dist/blueprints/follow-set.js +0 -21
  228. package/dist/blueprints/gift-wrap.d.ts +0 -5
  229. package/dist/blueprints/gift-wrap.js +0 -6
  230. package/dist/blueprints/group-mangement.d.ts +0 -25
  231. package/dist/blueprints/group-mangement.js +0 -40
  232. package/dist/blueprints/group.d.ts +0 -9
  233. package/dist/blueprints/group.js +0 -17
  234. package/dist/blueprints/highlight.d.ts +0 -20
  235. package/dist/blueprints/highlight.js +0 -12
  236. package/dist/blueprints/index.d.ts +0 -25
  237. package/dist/blueprints/index.js +0 -26
  238. package/dist/blueprints/legacy-message.d.ts +0 -7
  239. package/dist/blueprints/legacy-message.js +0 -29
  240. package/dist/blueprints/live-stream.d.ts +0 -6
  241. package/dist/blueprints/live-stream.js +0 -9
  242. package/dist/blueprints/note.d.ts +0 -16
  243. package/dist/blueprints/note.js +0 -30
  244. package/dist/blueprints/picture-post.d.ts +0 -12
  245. package/dist/blueprints/picture-post.js +0 -17
  246. package/dist/blueprints/poll.d.ts +0 -41
  247. package/dist/blueprints/poll.js +0 -33
  248. package/dist/blueprints/profile.d.ts +0 -3
  249. package/dist/blueprints/profile.js +0 -7
  250. package/dist/blueprints/reaction.d.ts +0 -10
  251. package/dist/blueprints/reaction.js +0 -14
  252. package/dist/blueprints/share.d.ts +0 -12
  253. package/dist/blueprints/share.js +0 -25
  254. package/dist/blueprints/stream.d.ts +0 -6
  255. package/dist/blueprints/stream.js +0 -7
  256. package/dist/blueprints/torrent.d.ts +0 -30
  257. package/dist/blueprints/torrent.js +0 -29
  258. package/dist/blueprints/wrapped-message.d.ts +0 -20
  259. package/dist/blueprints/wrapped-message.js +0 -64
  260. package/dist/blueprints/zap-goal.d.ts +0 -16
  261. package/dist/blueprints/zap-goal.js +0 -12
  262. package/dist/register.d.ts +0 -2
  263. package/dist/register.js +0 -4
@@ -1,10 +1,11 @@
1
1
  import { getOrComputeCachedValue, notifyEventUpdate } from "applesauce-core/helpers";
2
- import { getReplaceableIdentifier, getTagValue } from "applesauce-core/helpers/event";
2
+ import { getReplaceableIdentifier, getTagValue, kinds } from "applesauce-core/helpers/event";
3
3
  import { getHiddenTags, isHiddenTagsUnlocked, unlockHiddenTags } from "applesauce-core/helpers/hidden-tags";
4
4
  import { processTags } from "applesauce-core/helpers/tags";
5
5
  import { normalizeURL } from "applesauce-core/helpers/url";
6
6
  export const GROUPS_LIST_KIND = 10009;
7
- export const GROUP_MESSAGE_KIND = 9;
7
+ export const GROUP_MESSAGE_KIND = kinds.ChatMessage;
8
+ export const GROUP_THREAD_KIND = kinds.ForumThread;
8
9
  // NIP-29 Group event kinds
9
10
  export const GROUP_METADATA_KIND = 39000;
10
11
  export const GROUP_ADMINS_KIND = 39001;
@@ -1,2 +1,3 @@
1
1
  import { EventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
+ /** Returns a matching ["t", string] tag for a hashtag in an event */
2
3
  export declare function getHashtagTag(event: NostrEvent | EventTemplate, hashtag: string): ["t", string];
@@ -1,7 +1,7 @@
1
+ import { isTTag } from "applesauce-core/helpers";
1
2
  import { stripInvisibleChar } from "applesauce-core/helpers/string";
3
+ /** Returns a matching ["t", string] tag for a hashtag in an event */
2
4
  export function getHashtagTag(event, hashtag) {
3
5
  hashtag = stripInvisibleChar(hashtag.replace(/^#/, "").toLocaleLowerCase());
4
- return event.tags
5
- .filter((t) => t[0] === "t" && t[1])
6
- .find((t) => stripInvisibleChar(t[1].toLowerCase()) === hashtag);
6
+ return event.tags.filter(isTTag).find((t) => stripInvisibleChar(t[1].toLowerCase()) === hashtag);
7
7
  }
@@ -1,5 +1,7 @@
1
1
  export * from "./app-handler.js";
2
2
  export * from "./article.js";
3
+ export * from "./badge-award.js";
4
+ export * from "./badge.js";
3
5
  export * from "./blossom.js";
4
6
  export * from "./bolt11.js";
5
7
  export * from "./bookmark.js";
@@ -10,6 +12,7 @@ export * from "./channels.js";
10
12
  export * from "./comment.js";
11
13
  export * from "./content.js";
12
14
  export * from "./emoji.js";
15
+ export * from "./emoji-pack.js";
13
16
  export * from "./encrypted-content-cache.js";
14
17
  export * from "./file-metadata.js";
15
18
  export * from "./gift-wrap.js";
@@ -23,16 +26,18 @@ export * from "./messages.js";
23
26
  export * from "./mute.js";
24
27
  export * from "./picture-post.js";
25
28
  export * from "./poll.js";
29
+ export * from "./profile-badges.js";
26
30
  export * from "./reaction.js";
27
31
  export * from "./relay-discovery.js";
32
+ export * from "./relay-list.js";
28
33
  export * from "./reports.js";
29
34
  export * from "./share.js";
30
35
  export * from "./stream-chat.js";
31
36
  export * from "./stream.js";
32
37
  export * from "./threading.js";
33
38
  export * from "./torrent.js";
39
+ export * from "./trusted-assertions.js";
34
40
  export * from "./user-status.js";
35
41
  export * from "./wrapped-messages.js";
36
- export * from "./zap.js";
37
42
  export * from "./zap-goal.js";
38
- export * from "./relay-list.js";
43
+ export * from "./zap.js";
@@ -1,5 +1,7 @@
1
1
  export * from "./app-handler.js";
2
2
  export * from "./article.js";
3
+ export * from "./badge-award.js";
4
+ export * from "./badge.js";
3
5
  export * from "./blossom.js";
4
6
  export * from "./bolt11.js";
5
7
  export * from "./bookmark.js";
@@ -10,6 +12,7 @@ export * from "./channels.js";
10
12
  export * from "./comment.js";
11
13
  export * from "./content.js";
12
14
  export * from "./emoji.js";
15
+ export * from "./emoji-pack.js";
13
16
  export * from "./encrypted-content-cache.js";
14
17
  export * from "./file-metadata.js";
15
18
  export * from "./gift-wrap.js";
@@ -23,16 +26,18 @@ export * from "./messages.js";
23
26
  export * from "./mute.js";
24
27
  export * from "./picture-post.js";
25
28
  export * from "./poll.js";
29
+ export * from "./profile-badges.js";
26
30
  export * from "./reaction.js";
27
31
  export * from "./relay-discovery.js";
32
+ export * from "./relay-list.js";
28
33
  export * from "./reports.js";
29
34
  export * from "./share.js";
30
35
  export * from "./stream-chat.js";
31
36
  export * from "./stream.js";
32
37
  export * from "./threading.js";
33
38
  export * from "./torrent.js";
39
+ export * from "./trusted-assertions.js";
34
40
  export * from "./user-status.js";
35
41
  export * from "./wrapped-messages.js";
36
- export * from "./zap.js";
37
42
  export * from "./zap-goal.js";
38
- export * from "./relay-list.js";
43
+ export * from "./zap.js";
@@ -1,6 +1,14 @@
1
1
  import { NostrEvent } from "applesauce-core/helpers/event";
2
2
  import { AddressPointer, EventPointer, ProfilePointer } from "applesauce-core/helpers/pointers";
3
3
  export type ReadListTags = "public" | "hidden" | "all";
4
+ /** A symbol used to cache profile pointers from a list event */
5
+ export declare const ListProfilePointersSymbol: unique symbol;
6
+ /** A symbol used to cache event pointers from a list event */
7
+ export declare const ListEventPointersSymbol: unique symbol;
8
+ /** A symbol used to cache address pointers from a list event */
9
+ export declare const ListAddressPointersSymbol: unique symbol;
10
+ /** A symbol used to cache relay pointers from a list event */
11
+ export declare const ListRelaysSymbol: unique symbol;
4
12
  /** Returns all the tags of a list or set */
5
13
  export declare function getListTags(list: NostrEvent, type?: ReadListTags): string[][];
6
14
  /**
@@ -1,8 +1,30 @@
1
1
  import { getReplaceableIdentifier, isAddressableKind, isReplaceable, isReplaceableKind, } from "applesauce-core/helpers/event";
2
- import { getHiddenTags } from "applesauce-core/helpers/hidden-tags";
2
+ import { getHiddenTags, isHiddenTagsUnlocked } from "applesauce-core/helpers/hidden-tags";
3
3
  import { getAddressPointerForEvent, getAddressPointerFromATag, getEventPointerFromETag, getProfilePointerFromPTag, getReplaceableAddressFromPointer, } from "applesauce-core/helpers/pointers";
4
4
  import { relaySet } from "applesauce-core/helpers/relays";
5
5
  import { isATag, isETag, isPTag, processTags } from "applesauce-core/helpers/tags";
6
+ /** A symbol used to cache profile pointers from a list event */
7
+ export const ListProfilePointersSymbol = Symbol.for("list-profile-pointers");
8
+ /** A symbol used to cache event pointers from a list event */
9
+ export const ListEventPointersSymbol = Symbol.for("list-event-pointers");
10
+ /** A symbol used to cache address pointers from a list event */
11
+ export const ListAddressPointersSymbol = Symbol.for("list-address-pointers");
12
+ /** A symbol used to cache relay pointers from a list event */
13
+ export const ListRelaysSymbol = Symbol.for("list-relays");
14
+ function getOrComputeListCache(list, symbol, type, compute) {
15
+ const cacheType = type ?? "public";
16
+ // Hidden/all results depend on unlocked hidden tags, so avoid caching until available
17
+ if ((cacheType === "hidden" || cacheType === "all") && !isHiddenTagsUnlocked(list))
18
+ return compute();
19
+ const cache = Reflect.get(list, symbol) ?? {};
20
+ Reflect.set(list, symbol, cache);
21
+ const cached = cache[cacheType];
22
+ if (cached !== undefined)
23
+ return cached;
24
+ const value = compute();
25
+ cache[cacheType] = value;
26
+ return value;
27
+ }
6
28
  /** Returns all the tags of a list or set */
7
29
  export function getListTags(list, type) {
8
30
  switch (type) {
@@ -66,7 +88,7 @@ export function isEventInList(list, event) {
66
88
  * @param type - Which types of tags to read
67
89
  */
68
90
  export function getEventPointersFromList(list, type) {
69
- return processTags(getListTags(list, type), (tag) => (isETag(tag) ? tag : undefined), (t) => getEventPointerFromETag(t) ?? undefined);
91
+ return getOrComputeListCache(list, ListEventPointersSymbol, type, () => processTags(getListTags(list, type), (tag) => (isETag(tag) ? tag : undefined), (t) => getEventPointerFromETag(t) ?? undefined));
70
92
  }
71
93
  /**
72
94
  * Returns all the AddressPointer in a list or set
@@ -74,7 +96,7 @@ export function getEventPointersFromList(list, type) {
74
96
  * @param type - Which types of tags to read
75
97
  */
76
98
  export function getAddressPointersFromList(list, type) {
77
- return processTags(getListTags(list, type), (t) => (isATag(t) ? t : undefined), (t) => getAddressPointerFromATag(t) ?? undefined);
99
+ return getOrComputeListCache(list, ListAddressPointersSymbol, type, () => processTags(getListTags(list, type), (t) => (isATag(t) ? t : undefined), (t) => getAddressPointerFromATag(t) ?? undefined));
78
100
  }
79
101
  /**
80
102
  * Returns all the ProfilePointer in a list or set
@@ -82,7 +104,7 @@ export function getAddressPointersFromList(list, type) {
82
104
  * @param type - Which types of tags to read
83
105
  */
84
106
  export function getProfilePointersFromList(list, type) {
85
- return processTags(getListTags(list, type), (t) => (isPTag(t) ? t : undefined), (t) => getProfilePointerFromPTag(t) ?? undefined);
107
+ return getOrComputeListCache(list, ListProfilePointersSymbol, type, () => processTags(getListTags(list, type), (t) => (isPTag(t) ? t : undefined), (t) => getProfilePointerFromPTag(t) ?? undefined));
86
108
  }
87
109
  /**
88
110
  * Returns a deduplicated array of all 'relay' tags in a list or set
@@ -90,7 +112,7 @@ export function getProfilePointersFromList(list, type) {
90
112
  * @param type - Which types of tags to read
91
113
  */
92
114
  export function getRelaysFromList(list, type) {
93
- return relaySet(processTags(getListTags(list, type), (t) => (t[0] === "relay" ? t[1] : undefined)));
115
+ return getOrComputeListCache(list, ListRelaysSymbol, type, () => relaySet(processTags(getListTags(list, type), (t) => (t[0] === "relay" ? t[1] : undefined))));
94
116
  }
95
117
  /** Returns if an event is a valid list or set */
96
118
  export function isValidList(event) {
@@ -1,5 +1,5 @@
1
1
  import { NostrEvent } from "applesauce-core/helpers/event";
2
- import { FileMetadata } from "./file-metadata.js";
2
+ import { FileMetadataFields } from "./file-metadata.js";
3
3
  export declare const PICTURE_POST_KIND = 20;
4
4
  /** Return the media attachments from a kind 20 media post */
5
- export declare function getPicturePostAttachments(post: NostrEvent): FileMetadata[];
5
+ export declare function getPicturePostAttachments(post: NostrEvent): FileMetadataFields[];
@@ -0,0 +1,23 @@
1
+ import { KnownEvent, NostrEvent } from "applesauce-core/helpers/event";
2
+ import { AddressPointer, EventPointer } from "applesauce-core/helpers/pointers";
3
+ export declare const PROFILE_BADGES_KIND = 10008;
4
+ export declare const LEGACY_PROFILE_BADGES_KIND = 30008;
5
+ export declare const LEGACY_PROFILE_BADGES_IDENTIFIER = "profile_badges";
6
+ /** Ordered pair connecting a badge definition to an accepted award */
7
+ export type ProfileBadgeSlot = {
8
+ badge: AddressPointer;
9
+ award: EventPointer;
10
+ };
11
+ /** Kind 10008 profile badges event */
12
+ export type ProfileBadgesEvent = KnownEvent<typeof PROFILE_BADGES_KIND>;
13
+ /** Legacy kind 30008 profile badges event (NIP-58 original spec) */
14
+ export type LegacyProfileBadgesEvent = KnownEvent<typeof LEGACY_PROFILE_BADGES_KIND>;
15
+ /** Returns true if the event is a profile badges list (kind 10008 or legacy 30008 `profile_badges`). */
16
+ export declare function isValidProfileBadges(event?: NostrEvent): event is ProfileBadgesEvent | LegacyProfileBadgesEvent;
17
+ /**
18
+ * Extracts ordered profile badge slots from a badges event.
19
+ * Each slot pairs an `a` tag (definition pointer) with the next `e` tag (award receipt).
20
+ */
21
+ export declare function getProfileBadgeSlots(event?: NostrEvent): ProfileBadgeSlot[];
22
+ /** Chooses the most recent profile badge event between modern + legacy formats. */
23
+ export declare function compareProfileBadgeEvents(a?: NostrEvent, b?: NostrEvent): NostrEvent | undefined;
@@ -0,0 +1,51 @@
1
+ import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
2
+ import { getReplaceableIdentifier } from "applesauce-core/helpers/event";
3
+ import { getAddressPointerFromATag, getEventPointerFromETag, } from "applesauce-core/helpers/pointers";
4
+ import { isATag, isETag } from "applesauce-core/helpers/tags";
5
+ export const PROFILE_BADGES_KIND = 10008;
6
+ export const LEGACY_PROFILE_BADGES_KIND = 30008;
7
+ export const LEGACY_PROFILE_BADGES_IDENTIFIER = "profile_badges";
8
+ const ProfileBadgeSlotsSymbol = Symbol.for("profile-badge-slots");
9
+ /** Returns true if the event is a profile badges list (kind 10008 or legacy 30008 `profile_badges`). */
10
+ export function isValidProfileBadges(event) {
11
+ if (!event)
12
+ return false;
13
+ if (event.kind === PROFILE_BADGES_KIND)
14
+ return true;
15
+ if (event.kind === LEGACY_PROFILE_BADGES_KIND) {
16
+ return getReplaceableIdentifier(event) === LEGACY_PROFILE_BADGES_IDENTIFIER;
17
+ }
18
+ return false;
19
+ }
20
+ /**
21
+ * Extracts ordered profile badge slots from a badges event.
22
+ * Each slot pairs an `a` tag (definition pointer) with the next `e` tag (award receipt).
23
+ */
24
+ export function getProfileBadgeSlots(event) {
25
+ if (!isValidProfileBadges(event))
26
+ return [];
27
+ return getOrComputeCachedValue(event, ProfileBadgeSlotsSymbol, () => {
28
+ const slots = [];
29
+ for (let i = 0; i < event.tags.length - 1; i++) {
30
+ const aTag = event.tags[i];
31
+ const eTag = event.tags[i + 1];
32
+ if (!isATag(aTag) || !isETag(eTag))
33
+ continue;
34
+ const definition = getAddressPointerFromATag(aTag);
35
+ const award = getEventPointerFromETag(eTag);
36
+ if (definition && award) {
37
+ slots.push({ badge: definition, award });
38
+ i += 1; // Skip the E tag we just consumed
39
+ }
40
+ }
41
+ return slots;
42
+ });
43
+ }
44
+ /** Chooses the most recent profile badge event between modern + legacy formats. */
45
+ export function compareProfileBadgeEvents(a, b) {
46
+ if (!a)
47
+ return b;
48
+ if (!b)
49
+ return a;
50
+ return a.created_at >= b.created_at ? a : b;
51
+ }
@@ -0,0 +1,81 @@
1
+ import { KnownEvent, NostrEvent } from "applesauce-core/helpers/event";
2
+ import { HiddenContentSigner } from "applesauce-core/helpers/hidden-content";
3
+ export declare const TRUSTED_PROVIDER_LIST_KIND = 10040;
4
+ export declare const USER_ASSERTION_KIND = 30382;
5
+ export type TrustedProviderListEvent = KnownEvent<typeof TRUSTED_PROVIDER_LIST_KIND>;
6
+ export type UserAssertionEvent = KnownEvent<typeof USER_ASSERTION_KIND>;
7
+ /** A parsed trusted provider declaration from a kind 10040 event */
8
+ export type TrustedProvider = {
9
+ /** The assertion kind (e.g. 30382) */
10
+ kind: number;
11
+ /** The assertion tag name (e.g. "rank") */
12
+ tag: string;
13
+ /** The service provider's pubkey */
14
+ servicePubkey: string;
15
+ /** Optional relay hint where the provider publishes assertion events */
16
+ relay?: string;
17
+ };
18
+ /** Unlocked trusted provider list type */
19
+ export type UnlockedTrustedProviderList = {
20
+ [TrustedProvidersHiddenSymbol]: TrustedProvider[];
21
+ };
22
+ export declare const TrustedProvidersPublicSymbol: unique symbol;
23
+ export declare const TrustedProvidersHiddenSymbol: unique symbol;
24
+ /** Validates that an event is a valid trusted provider list (kind 10040) */
25
+ export declare function isValidTrustedProviderList(event: NostrEvent): event is TrustedProviderListEvent;
26
+ /**
27
+ * Parses a single provider tag into a {@link TrustedProvider}
28
+ * Tag format: ["<kind>:<tag>", "<servicePubkey>", "<relayHint?>"]
29
+ */
30
+ export declare function parseProviderTag(tag: string[]): TrustedProvider | undefined;
31
+ /** Returns all public trusted providers from a kind 10040 event */
32
+ export declare function getPublicProviders(event: NostrEvent): TrustedProvider[];
33
+ /** Returns hidden trusted providers if the event is unlocked */
34
+ export declare function getHiddenProviders<T extends NostrEvent & UnlockedTrustedProviderList>(event: T): TrustedProvider[];
35
+ export declare function getHiddenProviders<T extends NostrEvent>(event: T): TrustedProvider[] | undefined;
36
+ /** Checks if the hidden providers are unlocked */
37
+ export declare function isHiddenProvidersUnlocked<T extends NostrEvent>(event: T): event is T & UnlockedTrustedProviderList;
38
+ /** Unlocks the hidden providers in a trusted provider list event */
39
+ export declare function unlockHiddenProviders(event: NostrEvent, signer: HiddenContentSigner): Promise<TrustedProvider[]>;
40
+ /** Returns all providers (public + hidden if unlocked) for a given kind and tag */
41
+ export declare function getAllProviders(event: NostrEvent): TrustedProvider[];
42
+ /** Returns all providers for a specific assertion kind and tag */
43
+ export declare function getProvidersForAssertion(event: NostrEvent, kind: number, tag: string): TrustedProvider[];
44
+ /** Validates that an event is a valid user assertion (kind 30382) */
45
+ export declare function isValidUserAssertion(event: NostrEvent): event is UserAssertionEvent;
46
+ /** Returns the subject pubkey from a user assertion event (from the `d` tag) */
47
+ export declare function getAssertionSubject(event: NostrEvent): string | undefined;
48
+ /** Returns the user rank (0–100) */
49
+ export declare function getAssertionRank(event: NostrEvent): number | undefined;
50
+ /** Returns the follower count */
51
+ export declare function getAssertionFollowerCount(event: NostrEvent): number | undefined;
52
+ /** Returns the unix timestamp of the user's first post */
53
+ export declare function getAssertionFirstCreatedAt(event: NostrEvent): number | undefined;
54
+ /** Returns the total post count */
55
+ export declare function getAssertionPostCount(event: NostrEvent): number | undefined;
56
+ /** Returns the total reply count */
57
+ export declare function getAssertionReplyCount(event: NostrEvent): number | undefined;
58
+ /** Returns the total reactions count */
59
+ export declare function getAssertionReactionsCount(event: NostrEvent): number | undefined;
60
+ /** Returns the total zap amount received (in sats) */
61
+ export declare function getAssertionZapAmountReceived(event: NostrEvent): number | undefined;
62
+ /** Returns the total zap amount sent (in sats) */
63
+ export declare function getAssertionZapAmountSent(event: NostrEvent): number | undefined;
64
+ /** Returns the total number of zaps received */
65
+ export declare function getAssertionZapCountReceived(event: NostrEvent): number | undefined;
66
+ /** Returns the total number of zaps sent */
67
+ export declare function getAssertionZapCountSent(event: NostrEvent): number | undefined;
68
+ /** Returns the average zap amount received per day (in sats) */
69
+ export declare function getAssertionZapAvgAmountDayReceived(event: NostrEvent): number | undefined;
70
+ /** Returns the average zap amount sent per day (in sats) */
71
+ export declare function getAssertionZapAvgAmountDaySent(event: NostrEvent): number | undefined;
72
+ /** Returns the number of reports received */
73
+ export declare function getAssertionReportsReceived(event: NostrEvent): number | undefined;
74
+ /** Returns the number of reports sent */
75
+ export declare function getAssertionReportsSent(event: NostrEvent): number | undefined;
76
+ /** Returns the user's common topics (from `t` tags) */
77
+ export declare function getAssertionTopics(event: NostrEvent): string[];
78
+ /** Returns the hour (UTC, 0–24) at which the user generally becomes active */
79
+ export declare function getAssertionActivityHoursStart(event: NostrEvent): number | undefined;
80
+ /** Returns the hour (UTC, 0–24) at which the user generally becomes inactive */
81
+ export declare function getAssertionActivityHoursEnd(event: NostrEvent): number | undefined;
@@ -0,0 +1,161 @@
1
+ import { getOrComputeCachedValue, notifyEventUpdate } from "applesauce-core/helpers";
2
+ import { getTagValue } from "applesauce-core/helpers/event";
3
+ import { getHiddenTags, isHiddenTagsUnlocked, setHiddenTagsEncryptionMethod, unlockHiddenTags, } from "applesauce-core/helpers/hidden-tags";
4
+ // NIP-85 Trusted Assertions Kinds
5
+ export const TRUSTED_PROVIDER_LIST_KIND = 10040;
6
+ export const USER_ASSERTION_KIND = 30382;
7
+ // Register NIP-85 kind 10040 as using NIP-44 hidden tags
8
+ setHiddenTagsEncryptionMethod(TRUSTED_PROVIDER_LIST_KIND, "nip44");
9
+ // Caching symbols
10
+ export const TrustedProvidersPublicSymbol = Symbol.for("trusted-providers-public");
11
+ export const TrustedProvidersHiddenSymbol = Symbol.for("trusted-providers-hidden");
12
+ // ─── Kind 10040 Helpers ──────────────────────────────────────────────────────
13
+ /** Validates that an event is a valid trusted provider list (kind 10040) */
14
+ export function isValidTrustedProviderList(event) {
15
+ return event.kind === TRUSTED_PROVIDER_LIST_KIND;
16
+ }
17
+ /**
18
+ * Parses a single provider tag into a {@link TrustedProvider}
19
+ * Tag format: ["<kind>:<tag>", "<servicePubkey>", "<relayHint?>"]
20
+ */
21
+ export function parseProviderTag(tag) {
22
+ if (tag.length < 2)
23
+ return undefined;
24
+ const [kindTag, servicePubkey, relay] = tag;
25
+ if (!kindTag || !servicePubkey)
26
+ return undefined;
27
+ const colonIndex = kindTag.indexOf(":");
28
+ if (colonIndex === -1)
29
+ return undefined;
30
+ const kind = parseInt(kindTag.slice(0, colonIndex), 10);
31
+ const assertionTag = kindTag.slice(colonIndex + 1);
32
+ if (isNaN(kind) || !assertionTag)
33
+ return undefined;
34
+ return { kind, tag: assertionTag, servicePubkey, relay: relay || undefined };
35
+ }
36
+ /** Returns all public trusted providers from a kind 10040 event */
37
+ export function getPublicProviders(event) {
38
+ return getOrComputeCachedValue(event, TrustedProvidersPublicSymbol, () => event.tags.map(parseProviderTag).filter((p) => p !== undefined));
39
+ }
40
+ export function getHiddenProviders(event) {
41
+ if (TrustedProvidersHiddenSymbol in event)
42
+ return event[TrustedProvidersHiddenSymbol];
43
+ const tags = getHiddenTags(event);
44
+ if (!tags)
45
+ return undefined;
46
+ const providers = tags.map(parseProviderTag).filter((p) => p !== undefined);
47
+ Reflect.set(event, TrustedProvidersHiddenSymbol, providers);
48
+ return providers;
49
+ }
50
+ /** Checks if the hidden providers are unlocked */
51
+ export function isHiddenProvidersUnlocked(event) {
52
+ return TrustedProvidersHiddenSymbol in event || isHiddenTagsUnlocked(event);
53
+ }
54
+ /** Unlocks the hidden providers in a trusted provider list event */
55
+ export async function unlockHiddenProviders(event, signer) {
56
+ if (TrustedProvidersHiddenSymbol in event)
57
+ return event[TrustedProvidersHiddenSymbol];
58
+ await unlockHiddenTags(event, signer);
59
+ const providers = getHiddenProviders(event);
60
+ if (!providers)
61
+ throw new Error("Failed to unlock hidden providers");
62
+ notifyEventUpdate(event);
63
+ return providers;
64
+ }
65
+ /** Returns all providers (public + hidden if unlocked) for a given kind and tag */
66
+ export function getAllProviders(event) {
67
+ const pub = getPublicProviders(event);
68
+ const hidden = getHiddenProviders(event);
69
+ return hidden ? [...pub, ...hidden] : pub;
70
+ }
71
+ /** Returns all providers for a specific assertion kind and tag */
72
+ export function getProvidersForAssertion(event, kind, tag) {
73
+ return getAllProviders(event).filter((p) => p.kind === kind && p.tag === tag);
74
+ }
75
+ // ─── Kind 30382 User Assertion Helpers ──────────────────────────────────────
76
+ /** Validates that an event is a valid user assertion (kind 30382) */
77
+ export function isValidUserAssertion(event) {
78
+ if (event.kind !== USER_ASSERTION_KIND)
79
+ return false;
80
+ return !!getTagValue(event, "d");
81
+ }
82
+ /** Returns the subject pubkey from a user assertion event (from the `d` tag) */
83
+ export function getAssertionSubject(event) {
84
+ return getTagValue(event, "d");
85
+ }
86
+ /** Parses an integer tag value, returns undefined if absent or not a number */
87
+ function getIntTag(event, name) {
88
+ const value = getTagValue(event, name);
89
+ if (value === undefined)
90
+ return undefined;
91
+ const n = parseInt(value, 10);
92
+ return isNaN(n) ? undefined : n;
93
+ }
94
+ /** Returns the user rank (0–100) */
95
+ export function getAssertionRank(event) {
96
+ return getIntTag(event, "rank");
97
+ }
98
+ /** Returns the follower count */
99
+ export function getAssertionFollowerCount(event) {
100
+ return getIntTag(event, "followers");
101
+ }
102
+ /** Returns the unix timestamp of the user's first post */
103
+ export function getAssertionFirstCreatedAt(event) {
104
+ return getIntTag(event, "first_created_at");
105
+ }
106
+ /** Returns the total post count */
107
+ export function getAssertionPostCount(event) {
108
+ return getIntTag(event, "post_cnt");
109
+ }
110
+ /** Returns the total reply count */
111
+ export function getAssertionReplyCount(event) {
112
+ return getIntTag(event, "reply_cnt");
113
+ }
114
+ /** Returns the total reactions count */
115
+ export function getAssertionReactionsCount(event) {
116
+ return getIntTag(event, "reactions_cnt");
117
+ }
118
+ /** Returns the total zap amount received (in sats) */
119
+ export function getAssertionZapAmountReceived(event) {
120
+ return getIntTag(event, "zap_amt_recd");
121
+ }
122
+ /** Returns the total zap amount sent (in sats) */
123
+ export function getAssertionZapAmountSent(event) {
124
+ return getIntTag(event, "zap_amt_sent");
125
+ }
126
+ /** Returns the total number of zaps received */
127
+ export function getAssertionZapCountReceived(event) {
128
+ return getIntTag(event, "zap_cnt_recd");
129
+ }
130
+ /** Returns the total number of zaps sent */
131
+ export function getAssertionZapCountSent(event) {
132
+ return getIntTag(event, "zap_cnt_sent");
133
+ }
134
+ /** Returns the average zap amount received per day (in sats) */
135
+ export function getAssertionZapAvgAmountDayReceived(event) {
136
+ return getIntTag(event, "zap_avg_amt_day_recd");
137
+ }
138
+ /** Returns the average zap amount sent per day (in sats) */
139
+ export function getAssertionZapAvgAmountDaySent(event) {
140
+ return getIntTag(event, "zap_avg_amt_day_sent");
141
+ }
142
+ /** Returns the number of reports received */
143
+ export function getAssertionReportsReceived(event) {
144
+ return getIntTag(event, "reports_cnt_recd");
145
+ }
146
+ /** Returns the number of reports sent */
147
+ export function getAssertionReportsSent(event) {
148
+ return getIntTag(event, "reports_cnt_sent");
149
+ }
150
+ /** Returns the user's common topics (from `t` tags) */
151
+ export function getAssertionTopics(event) {
152
+ return event.tags.filter((t) => t[0] === "t" && t[1]).map((t) => t[1]);
153
+ }
154
+ /** Returns the hour (UTC, 0–24) at which the user generally becomes active */
155
+ export function getAssertionActivityHoursStart(event) {
156
+ return getIntTag(event, "active_hours_start");
157
+ }
158
+ /** Returns the hour (UTC, 0–24) at which the user generally becomes inactive */
159
+ export function getAssertionActivityHoursEnd(event) {
160
+ return getIntTag(event, "active_hours_end");
161
+ }
@@ -4,6 +4,7 @@ import { AddressPointer, EventPointer } from "applesauce-core/helpers/pointers";
4
4
  import { ParsedInvoice } from "./bolt11.js";
5
5
  /** Type for validated zap event */
6
6
  export type ZapEvent = KnownEvent<kinds.Zap>;
7
+ export type ZapRequestEvent = KnownEvent<kinds.ZapRequest>;
7
8
  export declare const ZapRequestSymbol: unique symbol;
8
9
  export declare const ZapSenderSymbol: unique symbol;
9
10
  export declare const ZapReceiverSymbol: unique symbol;
@@ -29,8 +30,13 @@ export declare function getZapEventPointer(zap: NostrEvent): EventPointer | null
29
30
  /** Gets the preimage for the bolt11 invoice */
30
31
  export declare function getZapPreimage(zap: NostrEvent): string | undefined;
31
32
  /** Returns the zap request event inside the zap receipt */
32
- export declare function getZapRequest(zap: ZapEvent): NostrEvent;
33
- export declare function getZapRequest(zap: NostrEvent): NostrEvent | undefined;
33
+ export declare function getZapRequest(zap: ZapEvent): ZapRequestEvent;
34
+ export declare function getZapRequest(zap: NostrEvent): ZapRequestEvent | undefined;
35
+ /**
36
+ * Checks if a zap request event is valid
37
+ * Validates kind, signature, required p tag (valid hex), optional e tag (valid hex), and relays tag
38
+ */
39
+ export declare function isValidZapRequest(event?: NostrEvent): event is ZapRequestEvent;
34
40
  /**
35
41
  * Checks if a zap event is valid (not missing fields)
36
42
  * DOES NOT validate LNURL address
@@ -59,38 +59,43 @@ export function getZapRequest(zap) {
59
59
  const description = getTagValue(zap, "description");
60
60
  if (!description)
61
61
  return;
62
- // Attempt to parse the zap request
63
62
  try {
64
- // Copied from nostr-tools/nip57 and modified to use the internal verifyZap method and return the zap request event
65
- let zapRequest;
66
- try {
67
- zapRequest = JSON.parse(description);
68
- }
69
- catch (err) {
70
- throw new Error("Invalid zap request JSON.");
71
- }
72
- if (!isEvent(zapRequest))
73
- throw new Error("Zap request is not a valid Nostr event.");
74
- if (!verifyWrappedEvent(zapRequest))
75
- throw new Error("Invalid signature on zap request.");
76
- let p = zapRequest.tags.find(([t, v]) => t === "p" && v);
77
- if (!p)
78
- throw new Error("Zap request doesn't have a 'p' tag.");
79
- if (!p[1].match(/^[a-f0-9]{64}$/))
80
- throw new Error("Zap request 'p' tag is not valid hex.");
81
- let e = zapRequest.tags.find(([t, v]) => t === "e" && v);
82
- if (e && !e[1].match(/^[a-f0-9]{64}$/))
83
- throw new Error("Zap request 'e' tag is not valid hex.");
84
- let relays = zapRequest.tags.find(([t, v]) => t === "relays" && v);
85
- if (!relays)
86
- throw new Error("Zap request doesn't have a 'relays' tag.");
87
- return zapRequest;
63
+ const zapRequest = JSON.parse(description);
64
+ if (isValidZapRequest(zapRequest))
65
+ return zapRequest;
66
+ return undefined;
88
67
  }
89
- catch (error) {
68
+ catch {
90
69
  return undefined;
91
70
  }
92
71
  });
93
72
  }
73
+ /**
74
+ * Checks if a zap request event is valid
75
+ * Validates kind, signature, required p tag (valid hex), optional e tag (valid hex), and relays tag
76
+ */
77
+ export function isValidZapRequest(event) {
78
+ if (!event)
79
+ return false;
80
+ if (event.kind !== kinds.ZapRequest)
81
+ return false;
82
+ if (!isEvent(event))
83
+ return false;
84
+ if (!verifyWrappedEvent(event))
85
+ return false;
86
+ const p = event.tags.find(([t, v]) => t === "p" && v);
87
+ if (!p)
88
+ return false;
89
+ if (!p[1].match(/^[a-f0-9]{64}$/))
90
+ return false;
91
+ const e = event.tags.find(([t, v]) => t === "e" && v);
92
+ if (e && !e[1].match(/^[a-f0-9]{64}$/))
93
+ return false;
94
+ const relays = event.tags.find(([t, v]) => t === "relays" && v);
95
+ if (!relays)
96
+ return false;
97
+ return true;
98
+ }
94
99
  /**
95
100
  * Checks if a zap event is valid (not missing fields)
96
101
  * DOES NOT validate LNURL address
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * as Helpers from "./helpers/index.js";
2
2
  export * as Models from "./models/index.js";
3
3
  export * as Operations from "./operations/index.js";
4
- export * as Blueprints from "./blueprints/index.js";
4
+ export * as Factories from "./factories/index.js";
5
5
  export * as Observable from "./observable/index.js";
6
6
  export * as Casts from "./casts/index.js";
7
- import "./register.js";
7
+ import "./models/__register__.js";
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export * as Helpers from "./helpers/index.js";
2
2
  export * as Models from "./models/index.js";
3
3
  export * as Operations from "./operations/index.js";
4
- export * as Blueprints from "./blueprints/index.js";
4
+ export * as Factories from "./factories/index.js";
5
5
  export * as Observable from "./observable/index.js";
6
6
  export * as Casts from "./casts/index.js";
7
- // Register the common models and blueprints with the event store and event factory
8
- import "./register.js";
7
+ // Register the common models with the event store
8
+ import "./models/__register__.js";
@@ -17,4 +17,4 @@ export * from "./stream.js";
17
17
  export * from "./shares.js";
18
18
  export * from "./zap-goals.js";
19
19
  export * from "applesauce-core/models";
20
- import "../register.js";
20
+ import "./__register__.js";
@@ -19,4 +19,4 @@ export * from "./zap-goals.js";
19
19
  // Export all models from core
20
20
  export * from "applesauce-core/models";
21
21
  // Register the common models with the event store
22
- import "../register.js";
22
+ import "./__register__.js";