@atproto/bsky 0.0.250 → 0.0.253

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 (473) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/api/age-assurance/const.js +19 -19
  3. package/dist/api/age-assurance/const.js.map +1 -1
  4. package/dist/api/app/bsky/feed/getFeed.d.ts.map +1 -1
  5. package/dist/api/app/bsky/feed/getFeed.js +4 -0
  6. package/dist/api/app/bsky/feed/getFeed.js.map +1 -1
  7. package/dist/api/app/bsky/feed/searchPosts.js +5 -0
  8. package/dist/api/app/bsky/feed/searchPosts.js.map +1 -1
  9. package/dist/api/app/bsky/feed/searchPostsV2.js +5 -0
  10. package/dist/api/app/bsky/feed/searchPostsV2.js.map +1 -1
  11. package/dist/config.d.ts +2 -0
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js +5 -0
  14. package/dist/config.js.map +1 -1
  15. package/dist/hydration/feed.d.ts +1 -2
  16. package/dist/hydration/feed.d.ts.map +1 -1
  17. package/dist/hydration/feed.js.map +1 -1
  18. package/dist/kws.d.ts +8 -0
  19. package/dist/kws.d.ts.map +1 -1
  20. package/dist/kws.js +53 -4
  21. package/dist/kws.js.map +1 -1
  22. package/package.json +28 -23
  23. package/bin/migration-create.ts +0 -46
  24. package/buf.gen.yaml +0 -12
  25. package/proto/bsky.proto +0 -1907
  26. package/proto/courier.proto +0 -84
  27. package/proto/rolodex.proto +0 -116
  28. package/src/api/age-assurance/const.ts +0 -203
  29. package/src/api/age-assurance/index.ts +0 -34
  30. package/src/api/age-assurance/kws/age-verified.test.ts +0 -98
  31. package/src/api/age-assurance/kws/age-verified.ts +0 -81
  32. package/src/api/age-assurance/kws/const.ts +0 -33
  33. package/src/api/age-assurance/kws/external-payload.test.ts +0 -72
  34. package/src/api/age-assurance/kws/external-payload.ts +0 -149
  35. package/src/api/age-assurance/redirects/kws-age-verified.ts +0 -107
  36. package/src/api/age-assurance/stash.ts +0 -23
  37. package/src/api/age-assurance/types.ts +0 -10
  38. package/src/api/age-assurance/util.ts +0 -68
  39. package/src/api/age-assurance/webhooks/kws-age-verified.ts +0 -75
  40. package/src/api/app/bsky/actor/getProfile.ts +0 -106
  41. package/src/api/app/bsky/actor/getProfiles.ts +0 -99
  42. package/src/api/app/bsky/actor/getSuggestions.ts +0 -163
  43. package/src/api/app/bsky/actor/searchActors.ts +0 -171
  44. package/src/api/app/bsky/actor/searchActorsTypeahead.ts +0 -164
  45. package/src/api/app/bsky/ageassurance/begin.ts +0 -175
  46. package/src/api/app/bsky/ageassurance/getConfig.ts +0 -16
  47. package/src/api/app/bsky/ageassurance/getState.ts +0 -58
  48. package/src/api/app/bsky/bookmark/createBookmark.ts +0 -39
  49. package/src/api/app/bsky/bookmark/deleteBookmark.ts +0 -32
  50. package/src/api/app/bsky/bookmark/getBookmarks.ts +0 -97
  51. package/src/api/app/bsky/bookmark/util.ts +0 -13
  52. package/src/api/app/bsky/contact/dismissMatch.ts +0 -26
  53. package/src/api/app/bsky/contact/getMatches.ts +0 -111
  54. package/src/api/app/bsky/contact/getSyncStatus.ts +0 -38
  55. package/src/api/app/bsky/contact/importContacts.ts +0 -119
  56. package/src/api/app/bsky/contact/removeData.ts +0 -25
  57. package/src/api/app/bsky/contact/sendNotification.ts +0 -33
  58. package/src/api/app/bsky/contact/startPhoneVerification.ts +0 -26
  59. package/src/api/app/bsky/contact/util.ts +0 -92
  60. package/src/api/app/bsky/contact/verifyPhone.ts +0 -29
  61. package/src/api/app/bsky/draft/createDraft.ts +0 -45
  62. package/src/api/app/bsky/draft/deleteDraft.ts +0 -20
  63. package/src/api/app/bsky/draft/getDrafts.ts +0 -44
  64. package/src/api/app/bsky/draft/updateDraft.ts +0 -26
  65. package/src/api/app/bsky/embed/getEmbedExternalView.ts +0 -154
  66. package/src/api/app/bsky/feed/getActorFeeds.ts +0 -101
  67. package/src/api/app/bsky/feed/getActorLikes.ts +0 -128
  68. package/src/api/app/bsky/feed/getAuthorFeed.ts +0 -279
  69. package/src/api/app/bsky/feed/getFeed.ts +0 -277
  70. package/src/api/app/bsky/feed/getFeedGenerator.ts +0 -68
  71. package/src/api/app/bsky/feed/getFeedGenerators.ts +0 -86
  72. package/src/api/app/bsky/feed/getLikes.ts +0 -151
  73. package/src/api/app/bsky/feed/getListFeed.ts +0 -147
  74. package/src/api/app/bsky/feed/getPostThread.ts +0 -156
  75. package/src/api/app/bsky/feed/getPosts.ts +0 -100
  76. package/src/api/app/bsky/feed/getQuotes.ts +0 -122
  77. package/src/api/app/bsky/feed/getRepostedBy.ts +0 -121
  78. package/src/api/app/bsky/feed/getSuggestedFeeds.ts +0 -39
  79. package/src/api/app/bsky/feed/getTimeline.ts +0 -127
  80. package/src/api/app/bsky/feed/searchPosts.ts +0 -267
  81. package/src/api/app/bsky/feed/searchPostsV2.ts +0 -236
  82. package/src/api/app/bsky/graph/getActorStarterPacks.ts +0 -103
  83. package/src/api/app/bsky/graph/getBlocks.ts +0 -94
  84. package/src/api/app/bsky/graph/getFollowers.ts +0 -153
  85. package/src/api/app/bsky/graph/getFollows.ts +0 -151
  86. package/src/api/app/bsky/graph/getKnownFollowers.ts +0 -123
  87. package/src/api/app/bsky/graph/getList.ts +0 -152
  88. package/src/api/app/bsky/graph/getListBlocks.ts +0 -87
  89. package/src/api/app/bsky/graph/getListMutes.ts +0 -87
  90. package/src/api/app/bsky/graph/getLists.ts +0 -125
  91. package/src/api/app/bsky/graph/getListsWithMembership.ts +0 -146
  92. package/src/api/app/bsky/graph/getMutes.ts +0 -87
  93. package/src/api/app/bsky/graph/getRelationships.ts +0 -58
  94. package/src/api/app/bsky/graph/getStarterPack.ts +0 -82
  95. package/src/api/app/bsky/graph/getStarterPacks.ts +0 -86
  96. package/src/api/app/bsky/graph/getStarterPacksWithMembership.ts +0 -136
  97. package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +0 -171
  98. package/src/api/app/bsky/graph/muteActor.ts +0 -24
  99. package/src/api/app/bsky/graph/muteActorList.ts +0 -19
  100. package/src/api/app/bsky/graph/muteThread.ts +0 -19
  101. package/src/api/app/bsky/graph/searchStarterPacks.ts +0 -169
  102. package/src/api/app/bsky/graph/unmuteActor.ts +0 -21
  103. package/src/api/app/bsky/graph/unmuteActorList.ts +0 -19
  104. package/src/api/app/bsky/graph/unmuteThread.ts +0 -19
  105. package/src/api/app/bsky/labeler/getServices.ts +0 -41
  106. package/src/api/app/bsky/notification/getPreferences.ts +0 -49
  107. package/src/api/app/bsky/notification/getUnreadCount.ts +0 -83
  108. package/src/api/app/bsky/notification/listActivitySubscriptions.ts +0 -116
  109. package/src/api/app/bsky/notification/listNotifications.ts +0 -272
  110. package/src/api/app/bsky/notification/putActivitySubscription.ts +0 -69
  111. package/src/api/app/bsky/notification/putPreferences.ts +0 -17
  112. package/src/api/app/bsky/notification/putPreferencesV2.ts +0 -64
  113. package/src/api/app/bsky/notification/registerPush.ts +0 -40
  114. package/src/api/app/bsky/notification/unregisterPush.ts +0 -39
  115. package/src/api/app/bsky/notification/updateSeen.ts +0 -52
  116. package/src/api/app/bsky/notification/util.ts +0 -134
  117. package/src/api/app/bsky/unspecced/getAgeAssuranceState.ts +0 -48
  118. package/src/api/app/bsky/unspecced/getConfig.ts +0 -20
  119. package/src/api/app/bsky/unspecced/getOnboardingSuggestedStarterPacks.ts +0 -162
  120. package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +0 -91
  121. package/src/api/app/bsky/unspecced/getPostThreadOtherV2.ts +0 -126
  122. package/src/api/app/bsky/unspecced/getPostThreadV2.ts +0 -148
  123. package/src/api/app/bsky/unspecced/getSuggestedFeeds.ts +0 -100
  124. package/src/api/app/bsky/unspecced/getSuggestedOnboardingUsers.ts +0 -143
  125. package/src/api/app/bsky/unspecced/getSuggestedStarterPacks.ts +0 -165
  126. package/src/api/app/bsky/unspecced/getSuggestedUsers.ts +0 -183
  127. package/src/api/app/bsky/unspecced/getSuggestedUsersForDiscover.ts +0 -175
  128. package/src/api/app/bsky/unspecced/getSuggestedUsersForExplore.ts +0 -178
  129. package/src/api/app/bsky/unspecced/getSuggestedUsersForSeeMore.ts +0 -178
  130. package/src/api/app/bsky/unspecced/getTaggedSuggestions.ts +0 -27
  131. package/src/api/app/bsky/unspecced/getTrendingTopics.ts +0 -96
  132. package/src/api/app/bsky/unspecced/getTrends.ts +0 -162
  133. package/src/api/app/bsky/unspecced/initAgeAssurance.ts +0 -150
  134. package/src/api/blob-dispatcher.ts +0 -41
  135. package/src/api/blob-resolver.ts +0 -401
  136. package/src/api/com/atproto/admin/getAccountInfos.ts +0 -49
  137. package/src/api/com/atproto/admin/getSubjectStatus.ts +0 -79
  138. package/src/api/com/atproto/admin/updateSubjectStatus.ts +0 -80
  139. package/src/api/com/atproto/identity/resolveHandle.ts +0 -19
  140. package/src/api/com/atproto/label/queryLabels.ts +0 -42
  141. package/src/api/com/atproto/repo/getRecord.ts +0 -44
  142. package/src/api/com/atproto/temp/fetchLabels.ts +0 -9
  143. package/src/api/external.ts +0 -15
  144. package/src/api/health.ts +0 -47
  145. package/src/api/index.ts +0 -216
  146. package/src/api/internal/bsky/actor/getProfiles.ts +0 -87
  147. package/src/api/kws/api.ts +0 -113
  148. package/src/api/kws/index.ts +0 -29
  149. package/src/api/kws/types.ts +0 -78
  150. package/src/api/kws/util.test.ts +0 -50
  151. package/src/api/kws/util.ts +0 -109
  152. package/src/api/kws/webhook.ts +0 -134
  153. package/src/api/sitemap.ts +0 -76
  154. package/src/api/util.ts +0 -45
  155. package/src/api/well-known.ts +0 -44
  156. package/src/auth-verifier.ts +0 -522
  157. package/src/bsync.ts +0 -41
  158. package/src/cache/read-through.ts +0 -157
  159. package/src/config.ts +0 -710
  160. package/src/context.ts +0 -143
  161. package/src/courier.ts +0 -41
  162. package/src/data-plane/client/hosts.ts +0 -103
  163. package/src/data-plane/client/index.ts +0 -125
  164. package/src/data-plane/client/util.test.ts +0 -29
  165. package/src/data-plane/client/util.ts +0 -74
  166. package/src/data-plane/index.ts +0 -2
  167. package/src/data-plane/server/background.ts +0 -66
  168. package/src/data-plane/server/bsync-subscription.ts +0 -590
  169. package/src/data-plane/server/db/database-schema.ts +0 -90
  170. package/src/data-plane/server/db/db.ts +0 -204
  171. package/src/data-plane/server/db/index.ts +0 -2
  172. package/src/data-plane/server/db/migrations/20230309T045948368Z-init.ts +0 -305
  173. package/src/data-plane/server/db/migrations/20230408T152211201Z-notification-init.ts +0 -25
  174. package/src/data-plane/server/db/migrations/20230417T210628672Z-moderation-init.ts +0 -127
  175. package/src/data-plane/server/db/migrations/20230420T211446071Z-did-cache.ts +0 -14
  176. package/src/data-plane/server/db/migrations/20230427T194702079Z-notif-record-index.ts +0 -14
  177. package/src/data-plane/server/db/migrations/20230605T144730094Z-post-profile-aggs.ts +0 -23
  178. package/src/data-plane/server/db/migrations/20230607T211442112Z-feed-generator-init.ts +0 -34
  179. package/src/data-plane/server/db/migrations/20230608T155101190Z-algo-whats-hot-view.ts +0 -85
  180. package/src/data-plane/server/db/migrations/20230608T201813132Z-mute-lists.ts +0 -78
  181. package/src/data-plane/server/db/migrations/20230608T205147239Z-mutes.ts +0 -15
  182. package/src/data-plane/server/db/migrations/20230609T153623961Z-blocks.ts +0 -33
  183. package/src/data-plane/server/db/migrations/20230609T232122649Z-actor-deletion-indexes.ts +0 -27
  184. package/src/data-plane/server/db/migrations/20230610T203555962Z-suggested-follows.ts +0 -13
  185. package/src/data-plane/server/db/migrations/20230611T215300060Z-actor-state.ts +0 -13
  186. package/src/data-plane/server/db/migrations/20230620T161134972Z-post-langs.ts +0 -9
  187. package/src/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.ts +0 -15
  188. package/src/data-plane/server/db/migrations/20230629T220835893Z-remove-post-hierarchy.ts +0 -32
  189. package/src/data-plane/server/db/migrations/20230703T045536691Z-feed-and-label-indices.ts +0 -31
  190. package/src/data-plane/server/db/migrations/20230720T164800037Z-posts-cursor-idx.ts +0 -19
  191. package/src/data-plane/server/db/migrations/20230807T035309811Z-feed-item-delete-invite-for-user-idx.ts +0 -14
  192. package/src/data-plane/server/db/migrations/20230808T172902639Z-repo-rev.ts +0 -12
  193. package/src/data-plane/server/db/migrations/20230810T203349843Z-action-duration.ts +0 -23
  194. package/src/data-plane/server/db/migrations/20230817T195936007Z-native-notifications.ts +0 -16
  195. package/src/data-plane/server/db/migrations/20230830T205507322Z-suggested-feeds.ts +0 -13
  196. package/src/data-plane/server/db/migrations/20230904T211011773Z-block-lists.ts +0 -24
  197. package/src/data-plane/server/db/migrations/20230906T222220386Z-thread-gating.ts +0 -27
  198. package/src/data-plane/server/db/migrations/20230920T213858047Z-add-tags-to-post.ts +0 -9
  199. package/src/data-plane/server/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +0 -40
  200. package/src/data-plane/server/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +0 -123
  201. package/src/data-plane/server/db/migrations/20231220T225126090Z-blob-takedowns.ts +0 -66
  202. package/src/data-plane/server/db/migrations/20240124T023719200Z-tagged-suggestions.ts +0 -15
  203. package/src/data-plane/server/db/migrations/20240226T225725627Z-labelers.ts +0 -27
  204. package/src/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.ts +0 -12
  205. package/src/data-plane/server/db/migrations/20240606T171229898Z-thread-mutes.ts +0 -15
  206. package/src/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.ts +0 -45
  207. package/src/data-plane/server/db/migrations/20240719T203853939Z-priority-notifs.ts +0 -25
  208. package/src/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.ts +0 -12
  209. package/src/data-plane/server/db/migrations/20240723T220703655Z-quotes.ts +0 -28
  210. package/src/data-plane/server/db/migrations/20240801T193939827Z-post-gate.ts +0 -17
  211. package/src/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.ts +0 -25
  212. package/src/data-plane/server/db/migrations/20240829T211238293Z-simplify-actor-sync.ts +0 -23
  213. package/src/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.ts +0 -17
  214. package/src/data-plane/server/db/migrations/20241114T153108102Z-add-starter-packs-name.ts +0 -19
  215. package/src/data-plane/server/db/migrations/20250116T222618297Z-post-embed-video.ts +0 -17
  216. package/src/data-plane/server/db/migrations/20250207T174822012Z-add-label-exp.ts +0 -9
  217. package/src/data-plane/server/db/migrations/20250404T163421487Z-verifications.ts +0 -39
  218. package/src/data-plane/server/db/migrations/20250526T023712742Z-like-repost-via.ts +0 -17
  219. package/src/data-plane/server/db/migrations/20250528T221913281Z-add-record-tags.ts +0 -9
  220. package/src/data-plane/server/db/migrations/20250602T190357447Z-add-private-data.ts +0 -22
  221. package/src/data-plane/server/db/migrations/20250611T140649895Z-add-activity-subscription.ts +0 -22
  222. package/src/data-plane/server/db/migrations/20250627T025331240Z-add-actor-age-assurance-columns.ts +0 -22
  223. package/src/data-plane/server/db/migrations/20250812T183735692Z-add-bookmarks.ts +0 -23
  224. package/src/data-plane/server/db/migrations/20250813T174955711Z-add-post-agg-bookmarks.ts +0 -12
  225. package/src/data-plane/server/db/migrations/20251120T004738098Z-update-actor-age-assurance-v2.ts +0 -28
  226. package/src/data-plane/server/db/migrations/20260112T133951271Z-add-drafts.ts +0 -24
  227. package/src/data-plane/server/db/migrations/20260604T224952774Z-post-embed-gallery-image.ts +0 -19
  228. package/src/data-plane/server/db/migrations/index.ts +0 -60
  229. package/src/data-plane/server/db/migrations/provider.ts +0 -26
  230. package/src/data-plane/server/db/pagination.ts +0 -341
  231. package/src/data-plane/server/db/tables/activity-subscription.ts +0 -12
  232. package/src/data-plane/server/db/tables/actor-block.ts +0 -14
  233. package/src/data-plane/server/db/tables/actor-state.ts +0 -10
  234. package/src/data-plane/server/db/tables/actor-sync.ts +0 -9
  235. package/src/data-plane/server/db/tables/actor.ts +0 -19
  236. package/src/data-plane/server/db/tables/algo.ts +0 -11
  237. package/src/data-plane/server/db/tables/blob-takedown.ts +0 -9
  238. package/src/data-plane/server/db/tables/bookmark.ts +0 -11
  239. package/src/data-plane/server/db/tables/did-cache.ts +0 -13
  240. package/src/data-plane/server/db/tables/draft.ts +0 -11
  241. package/src/data-plane/server/db/tables/duplicate-record.ts +0 -12
  242. package/src/data-plane/server/db/tables/feed-generator.ts +0 -21
  243. package/src/data-plane/server/db/tables/feed-item.ts +0 -12
  244. package/src/data-plane/server/db/tables/follow.ts +0 -15
  245. package/src/data-plane/server/db/tables/label.ts +0 -13
  246. package/src/data-plane/server/db/tables/labeler.ts +0 -16
  247. package/src/data-plane/server/db/tables/like.ts +0 -18
  248. package/src/data-plane/server/db/tables/list-block.ts +0 -15
  249. package/src/data-plane/server/db/tables/list-item.ts +0 -16
  250. package/src/data-plane/server/db/tables/list-mute.ts +0 -9
  251. package/src/data-plane/server/db/tables/list.ts +0 -19
  252. package/src/data-plane/server/db/tables/mute.ts +0 -9
  253. package/src/data-plane/server/db/tables/notification-push-token.ts +0 -10
  254. package/src/data-plane/server/db/tables/notification.ts +0 -16
  255. package/src/data-plane/server/db/tables/post-agg.ts +0 -16
  256. package/src/data-plane/server/db/tables/post-embed.ts +0 -47
  257. package/src/data-plane/server/db/tables/post-gate.ts +0 -12
  258. package/src/data-plane/server/db/tables/post.ts +0 -28
  259. package/src/data-plane/server/db/tables/private-data.ts +0 -13
  260. package/src/data-plane/server/db/tables/profile-agg.ts +0 -14
  261. package/src/data-plane/server/db/tables/profile.ts +0 -17
  262. package/src/data-plane/server/db/tables/quote.ts +0 -15
  263. package/src/data-plane/server/db/tables/record.ts +0 -15
  264. package/src/data-plane/server/db/tables/repost.ts +0 -18
  265. package/src/data-plane/server/db/tables/starter-pack.ts +0 -17
  266. package/src/data-plane/server/db/tables/subscription.ts +0 -9
  267. package/src/data-plane/server/db/tables/suggested-feed.ts +0 -10
  268. package/src/data-plane/server/db/tables/suggested-follow.ts +0 -10
  269. package/src/data-plane/server/db/tables/tagged-suggestion.ts +0 -11
  270. package/src/data-plane/server/db/tables/thread-gate.ts +0 -12
  271. package/src/data-plane/server/db/tables/thread-mute.ts +0 -9
  272. package/src/data-plane/server/db/tables/verification.ts +0 -20
  273. package/src/data-plane/server/db/tables/view-param.ts +0 -12
  274. package/src/data-plane/server/db/types.ts +0 -12
  275. package/src/data-plane/server/db/util.ts +0 -67
  276. package/src/data-plane/server/index.ts +0 -44
  277. package/src/data-plane/server/indexing/index.ts +0 -458
  278. package/src/data-plane/server/indexing/plugins/block.ts +0 -84
  279. package/src/data-plane/server/indexing/plugins/chat-declaration.ts +0 -60
  280. package/src/data-plane/server/indexing/plugins/feed-generator.ts +0 -80
  281. package/src/data-plane/server/indexing/plugins/follow.ts +0 -132
  282. package/src/data-plane/server/indexing/plugins/germ-declaration.ts +0 -57
  283. package/src/data-plane/server/indexing/plugins/labeler.ts +0 -74
  284. package/src/data-plane/server/indexing/plugins/like.ts +0 -151
  285. package/src/data-plane/server/indexing/plugins/list-block.ts +0 -84
  286. package/src/data-plane/server/indexing/plugins/list-item.ts +0 -92
  287. package/src/data-plane/server/indexing/plugins/list.ts +0 -80
  288. package/src/data-plane/server/indexing/plugins/notif-declaration.ts +0 -57
  289. package/src/data-plane/server/indexing/plugins/post-gate.ts +0 -101
  290. package/src/data-plane/server/indexing/plugins/post.ts +0 -675
  291. package/src/data-plane/server/indexing/plugins/profile.ts +0 -90
  292. package/src/data-plane/server/indexing/plugins/repost.ts +0 -176
  293. package/src/data-plane/server/indexing/plugins/starter-pack.ts +0 -74
  294. package/src/data-plane/server/indexing/plugins/status.ts +0 -57
  295. package/src/data-plane/server/indexing/plugins/thread-gate.ts +0 -101
  296. package/src/data-plane/server/indexing/plugins/verification.ts +0 -113
  297. package/src/data-plane/server/indexing/processor.ts +0 -292
  298. package/src/data-plane/server/routes/activity-subscription.ts +0 -84
  299. package/src/data-plane/server/routes/blocks.ts +0 -127
  300. package/src/data-plane/server/routes/bookmarks.ts +0 -83
  301. package/src/data-plane/server/routes/drafts.ts +0 -37
  302. package/src/data-plane/server/routes/feed-gens.ts +0 -89
  303. package/src/data-plane/server/routes/feeds.ts +0 -176
  304. package/src/data-plane/server/routes/follows.ts +0 -141
  305. package/src/data-plane/server/routes/identity.ts +0 -59
  306. package/src/data-plane/server/routes/index.ts +0 -67
  307. package/src/data-plane/server/routes/interactions.ts +0 -120
  308. package/src/data-plane/server/routes/labels.ts +0 -55
  309. package/src/data-plane/server/routes/likes.ts +0 -92
  310. package/src/data-plane/server/routes/lists.ts +0 -88
  311. package/src/data-plane/server/routes/moderation.ts +0 -102
  312. package/src/data-plane/server/routes/mutes.ts +0 -195
  313. package/src/data-plane/server/routes/notifs.ts +0 -239
  314. package/src/data-plane/server/routes/profile.ts +0 -220
  315. package/src/data-plane/server/routes/quotes.ts +0 -32
  316. package/src/data-plane/server/routes/records.ts +0 -119
  317. package/src/data-plane/server/routes/relationships.ts +0 -174
  318. package/src/data-plane/server/routes/reposts.ts +0 -76
  319. package/src/data-plane/server/routes/search.ts +0 -181
  320. package/src/data-plane/server/routes/site-standard.ts +0 -12
  321. package/src/data-plane/server/routes/sitemap.ts +0 -43
  322. package/src/data-plane/server/routes/starter-packs.ts +0 -32
  323. package/src/data-plane/server/routes/suggestions.ts +0 -175
  324. package/src/data-plane/server/routes/sync.ts +0 -16
  325. package/src/data-plane/server/routes/threads.ts +0 -33
  326. package/src/data-plane/server/subscription.ts +0 -152
  327. package/src/data-plane/server/util.ts +0 -202
  328. package/src/error.ts +0 -12
  329. package/src/etcd.ts +0 -90
  330. package/src/feature-gates/README.md +0 -83
  331. package/src/feature-gates/gates.ts +0 -25
  332. package/src/feature-gates/index.ts +0 -235
  333. package/src/feature-gates/metrics.test.ts +0 -196
  334. package/src/feature-gates/metrics.ts +0 -107
  335. package/src/feature-gates/types.ts +0 -62
  336. package/src/feature-gates/utils.test.ts +0 -66
  337. package/src/feature-gates/utils.ts +0 -135
  338. package/src/hydration/actor.ts +0 -578
  339. package/src/hydration/external.test.ts +0 -281
  340. package/src/hydration/external.ts +0 -268
  341. package/src/hydration/feed.ts +0 -456
  342. package/src/hydration/graph.ts +0 -354
  343. package/src/hydration/hydrator.ts +0 -1835
  344. package/src/hydration/label.ts +0 -207
  345. package/src/hydration/util.ts +0 -199
  346. package/src/image/index.ts +0 -2
  347. package/src/image/invalidator.ts +0 -33
  348. package/src/image/logger.ts +0 -6
  349. package/src/image/server.ts +0 -228
  350. package/src/image/sharp.ts +0 -89
  351. package/src/image/uri.ts +0 -114
  352. package/src/image/util.ts +0 -41
  353. package/src/index.ts +0 -312
  354. package/src/kws.ts +0 -197
  355. package/src/logger.ts +0 -40
  356. package/src/pipeline.ts +0 -60
  357. package/src/redis.ts +0 -205
  358. package/src/rolodex.ts +0 -42
  359. package/src/stash.ts +0 -76
  360. package/src/util/debug.ts +0 -10
  361. package/src/util/http.ts +0 -42
  362. package/src/util/retry.ts +0 -10
  363. package/src/util/standard-site.test.ts +0 -423
  364. package/src/util/standard-site.ts +0 -196
  365. package/src/util/uris.ts +0 -38
  366. package/src/util.ts +0 -48
  367. package/src/views/index.ts +0 -2783
  368. package/src/views/threads-v2.ts +0 -510
  369. package/src/views/types.ts +0 -193
  370. package/src/views/util.ts +0 -114
  371. package/test.env +0 -2
  372. package/tests/__snapshots__/feed-generation.test.ts.snap +0 -2463
  373. package/tests/_util.ts +0 -292
  374. package/tests/admin/admin-auth.test.ts +0 -190
  375. package/tests/admin/moderation.test.ts +0 -222
  376. package/tests/auth.test.ts +0 -90
  377. package/tests/blob-resolver.test.ts +0 -125
  378. package/tests/data-plane/__snapshots__/indexing.test.ts.snap +0 -887
  379. package/tests/data-plane/db.test.ts +0 -189
  380. package/tests/data-plane/duplicate-records.test.ts +0 -156
  381. package/tests/data-plane/handle-invalidation.test.ts +0 -153
  382. package/tests/data-plane/indexing.test.ts +0 -827
  383. package/tests/data-plane/subscription.test.ts +0 -128
  384. package/tests/data-plane/thread-mutes.test.ts +0 -175
  385. package/tests/entryway-auth.test.ts +0 -177
  386. package/tests/etcd.test.ts +0 -302
  387. package/tests/feed-generation.test.ts +0 -919
  388. package/tests/hydration/util.test.ts +0 -119
  389. package/tests/image/server.test.ts +0 -97
  390. package/tests/image/sharp.test.ts +0 -199
  391. package/tests/image/uri.test.ts +0 -106
  392. package/tests/label-hydration.test.ts +0 -245
  393. package/tests/postgates.test.ts +0 -182
  394. package/tests/query-labels.test.ts +0 -85
  395. package/tests/redis-cache.test.ts +0 -230
  396. package/tests/seed/feed-hidden-replies.ts +0 -63
  397. package/tests/seed/get-suggested-starter-packs.ts +0 -64
  398. package/tests/seed/get-trends.ts +0 -71
  399. package/tests/seed/known-followers.ts +0 -111
  400. package/tests/seed/postgates.ts +0 -57
  401. package/tests/server.test.ts +0 -115
  402. package/tests/sitemap.test.ts +0 -75
  403. package/tests/stash.test.ts +0 -180
  404. package/tests/utils.test.ts +0 -36
  405. package/tests/views/__snapshots__/actor-search.test.ts.snap +0 -155
  406. package/tests/views/__snapshots__/author-feed.test.ts.snap +0 -6301
  407. package/tests/views/__snapshots__/block-lists.test.ts.snap +0 -690
  408. package/tests/views/__snapshots__/blocks.test.ts.snap +0 -462
  409. package/tests/views/__snapshots__/bookmarks.test.ts.snap +0 -379
  410. package/tests/views/__snapshots__/follows.test.ts.snap +0 -798
  411. package/tests/views/__snapshots__/labeler-service.test.ts.snap +0 -233
  412. package/tests/views/__snapshots__/likes.test.ts.snap +0 -124
  413. package/tests/views/__snapshots__/list-feed.test.ts.snap +0 -883
  414. package/tests/views/__snapshots__/lists.test.ts.snap +0 -650
  415. package/tests/views/__snapshots__/mute-lists.test.ts.snap +0 -705
  416. package/tests/views/__snapshots__/mutes.test.ts.snap +0 -353
  417. package/tests/views/__snapshots__/notifications.test.ts.snap +0 -3074
  418. package/tests/views/__snapshots__/posts.test.ts.snap +0 -1019
  419. package/tests/views/__snapshots__/profile.test.ts.snap +0 -811
  420. package/tests/views/__snapshots__/quotes.test.ts.snap +0 -445
  421. package/tests/views/__snapshots__/reposts.test.ts.snap +0 -112
  422. package/tests/views/__snapshots__/starter-packs.test.ts.snap +0 -836
  423. package/tests/views/__snapshots__/thread-v2.test.ts.snap +0 -1298
  424. package/tests/views/__snapshots__/thread.test.ts.snap +0 -2051
  425. package/tests/views/__snapshots__/threadgating.test.ts.snap +0 -189
  426. package/tests/views/__snapshots__/timeline.test.ts.snap +0 -7252
  427. package/tests/views/account-deactivation.test.ts +0 -81
  428. package/tests/views/actor-likes.test.ts +0 -138
  429. package/tests/views/actor-search.test.ts +0 -261
  430. package/tests/views/age-assurance-v2.test.ts +0 -823
  431. package/tests/views/age-assurance.test.ts +0 -479
  432. package/tests/views/author-feed.test.ts +0 -694
  433. package/tests/views/block-lists.test.ts +0 -661
  434. package/tests/views/blocks.test.ts +0 -889
  435. package/tests/views/bookmarks.test.ts +0 -345
  436. package/tests/views/drafts.test.ts +0 -430
  437. package/tests/views/feed-hidden-replies.test.ts +0 -243
  438. package/tests/views/feed-view-post.test.ts +0 -501
  439. package/tests/views/follows.test.ts +0 -372
  440. package/tests/views/get-config.test.ts +0 -64
  441. package/tests/views/get-suggested-onboarding-users.test.ts +0 -193
  442. package/tests/views/get-suggested-starter-packs.test.ts +0 -137
  443. package/tests/views/get-trends.test.ts +0 -141
  444. package/tests/views/internal-actor.test.ts +0 -127
  445. package/tests/views/known-followers.test.ts +0 -193
  446. package/tests/views/labeler-service.test.ts +0 -242
  447. package/tests/views/labels-needs-review.test.ts +0 -316
  448. package/tests/views/labels-takedown.test.ts +0 -247
  449. package/tests/views/likes.test.ts +0 -192
  450. package/tests/views/list-feed.test.ts +0 -195
  451. package/tests/views/lists.test.ts +0 -412
  452. package/tests/views/mute-lists.test.ts +0 -509
  453. package/tests/views/mutes.test.ts +0 -308
  454. package/tests/views/notifications.test.ts +0 -1581
  455. package/tests/views/post-search.test.ts +0 -200
  456. package/tests/views/posts-debug.test.ts +0 -79
  457. package/tests/views/posts.test.ts +0 -427
  458. package/tests/views/profile-debug.test.ts +0 -75
  459. package/tests/views/profile.test.ts +0 -795
  460. package/tests/views/quotes.test.ts +0 -133
  461. package/tests/views/reposts.test.ts +0 -112
  462. package/tests/views/starter-packs.test.ts +0 -395
  463. package/tests/views/suggestions.test.ts +0 -145
  464. package/tests/views/thread-v2.test.ts +0 -2005
  465. package/tests/views/thread.test.ts +0 -637
  466. package/tests/views/threadgating.test.ts +0 -843
  467. package/tests/views/timeline.test.ts +0 -328
  468. package/tests/views/verification.test.ts +0 -296
  469. package/tsconfig.build.json +0 -10
  470. package/tsconfig.build.tsbuildinfo +0 -1
  471. package/tsconfig.json +0 -7
  472. package/tsconfig.tests.json +0 -8
  473. package/vitest.config.ts +0 -10
@@ -1,423 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
- import { validateStandardSiteForUrl } from './standard-site.js'
3
-
4
- const docDid = 'did:plc:doc'
5
- const pubDid = 'did:plc:pub'
6
- const docUri = `at://${docDid}/site.standard.document/abc`
7
- const pubUri = `at://${pubDid}/site.standard.publication/self`
8
-
9
- const makeDoc = (record: { site: string; path?: string }) => ({
10
- ref: { uri: docUri },
11
- info: { record },
12
- })
13
-
14
- const makePub = (record: { url: string }) => ({
15
- ref: { uri: pubUri },
16
- info: { record },
17
- })
18
-
19
- describe(validateStandardSiteForUrl, () => {
20
- describe('document + publication', () => {
21
- it('accepts when site resolves to publication and url+path matches', () => {
22
- const doc = makeDoc({ site: pubUri, path: '/posts/hello' })
23
- const pub = makePub({ url: 'https://example.com' })
24
- expect(
25
- validateStandardSiteForUrl(doc, pub, 'https://example.com/posts/hello'),
26
- ).toBe(true)
27
- })
28
-
29
- it('rejects when joined url+path does not match assumedUrl', () => {
30
- const doc = makeDoc({ site: pubUri, path: '/posts/hello' })
31
- const pub = makePub({ url: 'https://example.com' })
32
- expect(
33
- validateStandardSiteForUrl(
34
- doc,
35
- pub,
36
- 'https://example.com/posts/different',
37
- ),
38
- ).toBe(false)
39
- })
40
-
41
- it('accepts when document has no path and assumedUrl is the bare publication url', () => {
42
- const doc = makeDoc({ site: pubUri })
43
- const pub = makePub({ url: 'https://example.com' })
44
- expect(validateStandardSiteForUrl(doc, pub, 'https://example.com')).toBe(
45
- true,
46
- )
47
- })
48
- })
49
-
50
- describe('document only (loose doc)', () => {
51
- it('accepts when site is HTTP and matches assumedUrl', () => {
52
- const doc = makeDoc({ site: 'https://example.com', path: '/posts/hi' })
53
- expect(
54
- validateStandardSiteForUrl(
55
- doc,
56
- undefined,
57
- 'https://example.com/posts/hi',
58
- ),
59
- ).toBe(true)
60
- })
61
-
62
- // The lookups reject this pairing upstream, but validate as a fallback:
63
- // an at-uri base canonicalizes to null and fails the URL match.
64
- it('rejects when site is an at-uri (non-HTTP base canonicalizes to null)', () => {
65
- const doc = makeDoc({ site: pubUri, path: '/posts/hi' })
66
- expect(
67
- validateStandardSiteForUrl(
68
- doc,
69
- undefined,
70
- 'https://example.com/posts/hi',
71
- ),
72
- ).toBe(false)
73
- })
74
-
75
- it('rejects when assumedUrl is on a different host', () => {
76
- const doc = makeDoc({ site: 'https://example.com', path: '/posts/hi' })
77
- expect(
78
- validateStandardSiteForUrl(doc, undefined, 'https://evil.com/posts/hi'),
79
- ).toBe(false)
80
- })
81
-
82
- it('accepts when site has no path field and assumedUrl is the bare site', () => {
83
- const doc = makeDoc({ site: 'https://example.com' })
84
- expect(
85
- validateStandardSiteForUrl(doc, undefined, 'https://example.com'),
86
- ).toBe(true)
87
- })
88
- })
89
-
90
- describe('publication only', () => {
91
- it('accepts when publication.url matches assumedUrl', () => {
92
- const pub = makePub({ url: 'https://example.com' })
93
- expect(
94
- validateStandardSiteForUrl(undefined, pub, 'https://example.com'),
95
- ).toBe(true)
96
- })
97
-
98
- it('rejects when publication.url and assumedUrl differ', () => {
99
- const pub = makePub({ url: 'https://example.com' })
100
- expect(
101
- validateStandardSiteForUrl(undefined, pub, 'https://other.com'),
102
- ).toBe(false)
103
- })
104
-
105
- it('accepts when assumedUrl has a trailing slash and publication.url does not', () => {
106
- const pub = makePub({ url: 'https://atproto.com/blog' })
107
- expect(
108
- validateStandardSiteForUrl(undefined, pub, 'https://atproto.com/blog/'),
109
- ).toBe(true)
110
- })
111
- })
112
-
113
- describe('neither', () => {
114
- it('returns true (caller handles the no-records short-circuit)', () => {
115
- expect(
116
- validateStandardSiteForUrl(undefined, undefined, 'https://example.com'),
117
- ).toBe(true)
118
- })
119
- })
120
-
121
- describe('assumedUrl variants', () => {
122
- const doc = makeDoc({ site: pubUri, path: '/posts/hello' })
123
- const pub = makePub({ url: 'https://example.com' })
124
-
125
- for (const { note, assumedUrl, expected } of [
126
- {
127
- note: 'trailing slash on assumed URL',
128
- assumedUrl: 'https://example.com/posts/hello/',
129
- expected: true,
130
- },
131
- {
132
- note: 'query string ignored',
133
- assumedUrl: 'https://example.com/posts/hello?utm_source=twitter',
134
- expected: true,
135
- },
136
- {
137
- note: 'fragment ignored',
138
- assumedUrl: 'https://example.com/posts/hello#section',
139
- expected: true,
140
- },
141
- {
142
- note: 'mixed-case host',
143
- assumedUrl: 'https://Example.COM/posts/hello',
144
- expected: true,
145
- },
146
- {
147
- note: 'http vs https mismatch is rejected',
148
- assumedUrl: 'http://example.com/posts/hello',
149
- expected: false,
150
- },
151
- {
152
- note: 'unparseable assumed URL is rejected',
153
- assumedUrl: 'not a url',
154
- expected: false,
155
- },
156
- {
157
- note: 'non-http scheme is rejected',
158
- assumedUrl: 'ftp://example.com/posts/hello',
159
- expected: false,
160
- },
161
- ]) {
162
- it(note, () => {
163
- expect(validateStandardSiteForUrl(doc, pub, assumedUrl)).toBe(expected)
164
- })
165
- }
166
- })
167
-
168
- describe('path joining (root domain × subpath × slash placement)', () => {
169
- // Real-world example that originally broke:
170
- // pub.url: 'https://atproto.com/blog'
171
- // doc.path: '/indexing-standard-site'
172
- // expected: 'https://atproto.com/blog/indexing-standard-site'
173
- // `new URL('/indexing-standard-site', 'https://atproto.com/blog')` would
174
- // resolve to 'https://atproto.com/indexing-standard-site' (the leading
175
- // slash on path swallows the base's pathname under WHATWG semantics) —
176
- // we want path-append, not relative resolution.
177
- for (const { note, baseUrl, path, assumedUrl, expected } of [
178
- // Root-domain base, all four slash combinations.
179
- {
180
- note: 'root base, base/, path/',
181
- baseUrl: 'https://example.com/',
182
- path: '/posts/hello',
183
- assumedUrl: 'https://example.com/posts/hello',
184
- expected: true,
185
- },
186
- {
187
- note: 'root base, base/, path-no-slash',
188
- baseUrl: 'https://example.com/',
189
- path: 'posts/hello',
190
- assumedUrl: 'https://example.com/posts/hello',
191
- expected: true,
192
- },
193
- {
194
- note: 'root base, base-no-slash, path/',
195
- baseUrl: 'https://example.com',
196
- path: '/posts/hello',
197
- assumedUrl: 'https://example.com/posts/hello',
198
- expected: true,
199
- },
200
- {
201
- note: 'root base, base-no-slash, path-no-slash',
202
- baseUrl: 'https://example.com',
203
- path: 'posts/hello',
204
- assumedUrl: 'https://example.com/posts/hello',
205
- expected: true,
206
- },
207
- // Subpath base, all four slash combinations (the regression case).
208
- {
209
- note: 'subpath base, base/, path/',
210
- baseUrl: 'https://atproto.com/blog/',
211
- path: '/indexing-standard-site',
212
- assumedUrl: 'https://atproto.com/blog/indexing-standard-site',
213
- expected: true,
214
- },
215
- {
216
- note: 'subpath base, base/, path-no-slash',
217
- baseUrl: 'https://atproto.com/blog/',
218
- path: 'indexing-standard-site',
219
- assumedUrl: 'https://atproto.com/blog/indexing-standard-site',
220
- expected: true,
221
- },
222
- {
223
- note: 'subpath base, base-no-slash, path/ (regression)',
224
- baseUrl: 'https://atproto.com/blog',
225
- path: '/indexing-standard-site',
226
- assumedUrl: 'https://atproto.com/blog/indexing-standard-site',
227
- expected: true,
228
- },
229
- {
230
- note: 'subpath base, base-no-slash, path-no-slash',
231
- baseUrl: 'https://atproto.com/blog',
232
- path: 'indexing-standard-site',
233
- assumedUrl: 'https://atproto.com/blog/indexing-standard-site',
234
- expected: true,
235
- },
236
- // Empty path: assumedUrl should equal the base.
237
- {
238
- note: 'empty path, root base, no trailing slash',
239
- baseUrl: 'https://example.com',
240
- path: undefined,
241
- assumedUrl: 'https://example.com',
242
- expected: true,
243
- },
244
- {
245
- note: 'empty path, subpath base, with trailing slash',
246
- baseUrl: 'https://atproto.com/blog/',
247
- path: undefined,
248
- assumedUrl: 'https://atproto.com/blog',
249
- expected: true,
250
- },
251
- // Negative: subpath base with assumedUrl that lost the subpath
252
- // (what `new URL`'s relative resolution would have produced).
253
- {
254
- note: 'rejects when assumed URL drops the subpath',
255
- baseUrl: 'https://atproto.com/blog',
256
- path: '/indexing-standard-site',
257
- assumedUrl: 'https://atproto.com/indexing-standard-site',
258
- expected: false,
259
- },
260
- ]) {
261
- it(`doc + pub: ${note}`, () => {
262
- const doc = makeDoc(
263
- path === undefined ? { site: pubUri } : { site: pubUri, path },
264
- )
265
- const pub = makePub({ url: baseUrl })
266
- expect(validateStandardSiteForUrl(doc, pub, assumedUrl)).toBe(expected)
267
- })
268
- it(`loose doc: ${note}`, () => {
269
- const doc = makeDoc(
270
- path === undefined ? { site: baseUrl } : { site: baseUrl, path },
271
- )
272
- expect(validateStandardSiteForUrl(doc, undefined, assumedUrl)).toBe(
273
- expected,
274
- )
275
- })
276
- }
277
- })
278
-
279
- describe('subpath-friendly hosts', () => {
280
- // Allowlist of hosts where each record's author owns the full subpath
281
- // space under their canonical record URL. These platforms typically
282
- // serve dynamic per-record subpaths (page numbers, revision ids,
283
- // comment threads, etc.) under the same slug, so an `assumedUrl` with
284
- // extra path segments past the record URL is still authentic content.
285
- for (const { note, baseUrl, path, assumedUrl, expected } of [
286
- // Allowlisted apex domain (subdomain) — extra path segments accepted.
287
- {
288
- note: 'pckt.blog subdomain accepts extra path segments past the record URL',
289
- baseUrl: 'https://waow-tech.pckt.blog',
290
- path: '/typeahead-more-like-typebehind-amirite-tzgmqge',
291
- assumedUrl:
292
- 'https://waow-tech.pckt.blog/typeahead-more-like-typebehind-amirite-tzgmqge/589/621',
293
- expected: true,
294
- },
295
- {
296
- note: 'leaflet.pub subdomain with one extra segment',
297
- baseUrl: 'https://author.leaflet.pub',
298
- path: '/post-slug',
299
- assumedUrl: 'https://author.leaflet.pub/post-slug/v2',
300
- expected: true,
301
- },
302
- {
303
- note: 'offprint.app at apex with multi-segment extension',
304
- baseUrl: 'https://offprint.app',
305
- path: '/story/abc',
306
- assumedUrl: 'https://offprint.app/story/abc/chapter/3',
307
- expected: true,
308
- },
309
- // Allowlisted host but the assumed URL diverges from the path —
310
- // still rejected; subpath is "extends with extra segments after a
311
- // path-segment boundary," not "any URL on the same host."
312
- {
313
- note: 'pckt.blog rejects assumed URLs that diverge before the boundary',
314
- baseUrl: 'https://blog.pckt.blog',
315
- path: '/post-slug',
316
- assumedUrl: 'https://blog.pckt.blog/different-post',
317
- expected: false,
318
- },
319
- {
320
- note: 'pckt.blog rejects partial-segment matches (no slash boundary)',
321
- baseUrl: 'https://blog.pckt.blog',
322
- path: '/foo',
323
- assumedUrl: 'https://blog.pckt.blog/foobar',
324
- expected: false,
325
- },
326
- // Non-allowlisted hosts — exact match still required.
327
- {
328
- note: 'arbitrary host rejects extra path segments',
329
- baseUrl: 'https://example.com',
330
- path: '/article',
331
- assumedUrl: 'https://example.com/article/extra',
332
- expected: false,
333
- },
334
- {
335
- note: 'lookalike host (pckt.blog.evil.com) is NOT allowlisted',
336
- baseUrl: 'https://pckt.blog.evil.com',
337
- path: '/post',
338
- assumedUrl: 'https://pckt.blog.evil.com/post/extra',
339
- expected: false,
340
- },
341
- {
342
- note: 'evilpckt.blog is NOT allowlisted (no subdomain dot before pckt.blog)',
343
- baseUrl: 'https://evilpckt.blog',
344
- path: '/post',
345
- assumedUrl: 'https://evilpckt.blog/post/extra',
346
- expected: false,
347
- },
348
- // Allowlist host with exact match still works (no regression).
349
- {
350
- note: 'pckt.blog still accepts exact match without subpath',
351
- baseUrl: 'https://author.pckt.blog',
352
- path: '/post-slug',
353
- assumedUrl: 'https://author.pckt.blog/post-slug',
354
- expected: true,
355
- },
356
- // Allowlist host with cross-host mismatch — still rejected.
357
- {
358
- note: 'allowlisted record host vs different host on assumed URL is rejected',
359
- baseUrl: 'https://author.pckt.blog',
360
- path: '/post',
361
- assumedUrl: 'https://example.com/author.pckt.blog/post/extra',
362
- expected: false,
363
- },
364
- ]) {
365
- it(`doc + pub: ${note}`, () => {
366
- const doc = makeDoc(
367
- path === undefined ? { site: pubUri } : { site: pubUri, path },
368
- )
369
- const pub = makePub({ url: baseUrl })
370
- expect(validateStandardSiteForUrl(doc, pub, assumedUrl)).toBe(expected)
371
- })
372
- it(`loose doc: ${note}`, () => {
373
- const doc = makeDoc(
374
- path === undefined ? { site: baseUrl } : { site: baseUrl, path },
375
- )
376
- expect(validateStandardSiteForUrl(doc, undefined, assumedUrl)).toBe(
377
- expected,
378
- )
379
- })
380
- }
381
-
382
- // Publication-only validation never accepts subpaths — `assumedUrl`
383
- // for a publication is the home-page URL, not an article underneath
384
- // it. Subpath relaxation belongs to documents.
385
- it('publication-only: allowlisted host still requires exact match', () => {
386
- const pub = makePub({ url: 'https://author.pckt.blog' })
387
- expect(
388
- validateStandardSiteForUrl(
389
- undefined,
390
- pub,
391
- 'https://author.pckt.blog/some/sub/path',
392
- ),
393
- ).toBe(false)
394
- })
395
-
396
- it('publication-only: non-allowlisted host rejects subpath', () => {
397
- const pub = makePub({ url: 'https://example.com' })
398
- expect(
399
- validateStandardSiteForUrl(
400
- undefined,
401
- pub,
402
- 'https://example.com/some/sub/path',
403
- ),
404
- ).toBe(false)
405
- })
406
-
407
- // Case-insensitivity on the host.
408
- it('host comparison is case-insensitive', () => {
409
- const doc = makeDoc({
410
- site: pubUri,
411
- path: '/post',
412
- })
413
- const pub = makePub({ url: 'https://Author.PCKT.blog' })
414
- expect(
415
- validateStandardSiteForUrl(
416
- doc,
417
- pub,
418
- 'https://author.pckt.BLOG/post/extra',
419
- ),
420
- ).toBe(true)
421
- })
422
- })
423
- })
@@ -1,196 +0,0 @@
1
- import { AtUriString } from '@atproto/syntax'
2
-
3
- export const SITE_STANDARD_NSID_PREFIX = 'site.standard.'
4
-
5
- /**
6
- * Composes a stable map key from an `(uri, cid)` pair. A single hydration
7
- * batch can pull more than one version of the same SS record URI (different
8
- * posts pinning different cids), so the composite is needed for O(1)
9
- * version-exact lookups.
10
- */
11
- export const siteStandardRecordKey = (uri: string, cid: string) =>
12
- `${uri}@${cid}`
13
-
14
- export const parseSiteStandardRecordKey = (
15
- key: string,
16
- ): { uri: AtUriString; cid: string } => {
17
- const at = key.lastIndexOf('@')
18
- return {
19
- uri: key.slice(0, at) as AtUriString,
20
- cid: key.slice(at + 1),
21
- }
22
- }
23
-
24
- /**
25
- * Parse `url` as HTTP(S) and reduce it to a canonical
26
- * `protocol://host/path` string for equality comparison: lowercases host,
27
- * strips a trailing slash from the path, and drops query/fragment. Returns
28
- * `null` when the input isn't a valid HTTP(S) URL.
29
- */
30
- const canonicalizeHttpUrl = (url: string): string | null => {
31
- let parsed: URL
32
- try {
33
- parsed = new URL(url)
34
- } catch {
35
- return null
36
- }
37
- if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null
38
- const path = parsed.pathname === '/' ? '' : parsed.pathname.replace(/\/$/, '')
39
- return `${parsed.protocol}//${parsed.host}${path}`
40
- }
41
-
42
- /**
43
- * Append `path` to `base` with exactly one slash between, or return `base`
44
- * unchanged when `path` is empty. Unlike `new URL(path, base)`, a leading
45
- * slash on `path` does NOT swallow `base`'s pathname — so
46
- * `joinPath('https://x.com/blog', '/foo')` is `https://x.com/blog/foo`,
47
- * not `https://x.com/foo`.
48
- */
49
- const joinPath = (base: string, path: string): string => {
50
- if (!path) return base
51
- const baseTrimmed = base.endsWith('/') ? base.slice(0, -1) : base
52
- const pathTrimmed = path.startsWith('/') ? path.slice(1) : path
53
- return `${baseTrimmed}/${pathTrimmed}`
54
- }
55
-
56
- /**
57
- * Apex domains whose authors own the full subpath space under their
58
- * record-claimed URL. Each entry matches itself and any subdomain; e.g.
59
- * `pckt.blog` matches `pckt.blog` and `waow-tech.pckt.blog`.
60
- *
61
- * On these domains, an `assumedUrl` whose pathname extends the canonical
62
- * record URL with extra segments is treated as valid. Adding to this list
63
- * is a trust call — only platforms where each record's URL space is
64
- * authoritatively owned by its author belong here.
65
- */
66
- const SUBPATH_FRIENDLY_DOMAINS = ['pckt.blog', 'leaflet.pub', 'offprint.app']
67
-
68
- const isSubpathFriendlyHost = (host: string): boolean => {
69
- const lower = host.toLowerCase()
70
- return SUBPATH_FRIENDLY_DOMAINS.some(
71
- (domain) => lower === domain || lower.endsWith(`.${domain}`),
72
- )
73
- }
74
-
75
- /**
76
- * Return whether `recordUrl` and `assumedUrl` should validate as the same
77
- * canonical content. Strictly equal canonical forms always match. On
78
- * subpath-friendly hosts (see `SUBPATH_FRIENDLY_DOMAINS`), an `assumedUrl`
79
- * whose path extends `recordUrl`'s with extra segments is also accepted.
80
- *
81
- * Both inputs are pre-canonicalized strings (`canonicalizeHttpUrl` output)
82
- * with no trailing slash and no query/fragment.
83
- */
84
- const canonicalUrlMatchesAssumed = (
85
- canonicalRecordUrl: string,
86
- canonicalAssumedUrl: string,
87
- ): boolean => {
88
- if (canonicalRecordUrl === canonicalAssumedUrl) return true
89
- // Subpath fallback. Both strings are canonicalized, so a real
90
- // path-segment boundary at `recordUrl + '/'` (e.g. `/foo` vs `/foo-bar`
91
- // never matches; `/foo` vs `/foo/bar` does).
92
- if (!canonicalAssumedUrl.startsWith(`${canonicalRecordUrl}/`)) return false
93
- let host: string
94
- try {
95
- host = new URL(canonicalAssumedUrl).host
96
- } catch {
97
- return false
98
- }
99
- return isSubpathFriendlyHost(host)
100
- }
101
-
102
- /**
103
- * Confirm that the supplied SS records actually back `assumedUrl`. The
104
- * record-side URL is built by concatenating the publication URL (or the
105
- * loose-doc site) with the document's `path` field, then both sides are
106
- * canonicalized for equality: lowercase host, query/fragment dropped,
107
- * trailing slash stripped.
108
- *
109
- * Path concatenation is `base + '/' + path` semantics — a leading `/` on
110
- * `path` does NOT swallow the base's pathname (the way
111
- * `new URL(path, base)` would). So
112
- * `'https://atproto.com/blog' + '/indexing-standard-site'` resolves to
113
- * `https://atproto.com/blog/indexing-standard-site` regardless of which
114
- * side carries the slash.
115
- *
116
- * Structural validation of the doc/pub pair (matching `site` ↔ pub URI,
117
- * no orphan docs that claim a missing publication) happens upstream in
118
- * `getSiteStandardRecordsFromHydrationMapsByRefs` /
119
- * `…ByDocumentUri` (see `hydration/external.ts`); by the time this
120
- * function runs the pair is already known to be structurally consistent,
121
- * so we only check whether the records back the URL.
122
- *
123
- * For document validation, `SUBPATH_FRIENDLY_DOMAINS` (and their
124
- * subdomains) accept an assumed URL whose path extends the canonical
125
- * record URL with additional segments — these are platforms where each
126
- * record's author owns the full subpath space under their claimed URL.
127
- * Publication-only validation always requires exact match: there's no
128
- * coherent "subpath" of a publication's home page.
129
- *
130
- * Cases:
131
- * - Document + publication: `publication.url + document.path` must
132
- * canonicalize to `assumedUrl` (or be a subpath-friendly prefix of it).
133
- * - Loose document (web-URL `site`): `document.site + document.path`
134
- * must canonicalize to `assumedUrl` (or be a subpath-friendly prefix).
135
- * (Doc with at-uri `site` but no publication can't reach this function
136
- * — the lookups reject it.)
137
- * - Publication only: `publication.url` must canonicalize exactly to
138
- * `assumedUrl`.
139
- * - Neither: vacuously valid; the caller short-circuits before we get
140
- * here.
141
- */
142
- export const validateStandardSiteForUrl = (
143
- document:
144
- | {
145
- ref: { uri: string }
146
- info: { record: { site: string; path?: string } }
147
- }
148
- | undefined,
149
- publication:
150
- | { ref: { uri: string }; info: { record: { url: string } } }
151
- | undefined,
152
- assumedUrl: string,
153
- ): boolean => {
154
- const canonicalAssumed = canonicalizeHttpUrl(assumedUrl)
155
- if (canonicalAssumed === null) return false
156
-
157
- if (document && publication) {
158
- const joined = canonicalizeHttpUrl(
159
- joinPath(publication.info.record.url, document.info.record.path ?? ''),
160
- )
161
- return (
162
- joined !== null && canonicalUrlMatchesAssumed(joined, canonicalAssumed)
163
- )
164
- }
165
- if (document) {
166
- const joined = canonicalizeHttpUrl(
167
- joinPath(document.info.record.site, document.info.record.path ?? ''),
168
- )
169
- return (
170
- joined !== null && canonicalUrlMatchesAssumed(joined, canonicalAssumed)
171
- )
172
- }
173
- if (publication) {
174
- // Publication-only matches are exact: `assumedUrl` represents the
175
- // publication's home page, not an article underneath it. Subpath
176
- // extensions belong to document validation.
177
- return canonicalizeHttpUrl(publication.info.record.url) === canonicalAssumed
178
- }
179
- return true
180
- }
181
-
182
- const WORDS_PER_MINUTE = 200
183
-
184
- /**
185
- * Estimate reading time in minutes from a plaintext document body. Returns
186
- * `undefined` when the input has no countable words. Uses a coarse
187
- * `WORDS_PER_MINUTE` heuristic; swap in a more accurate library here if
188
- * needed (e.g. `reading-time`).
189
- */
190
- export const estimateReadingTimeMinutes = (
191
- text: string,
192
- ): number | undefined => {
193
- const words = text.trim().split(/\s+/).filter(Boolean).length
194
- if (!words) return undefined
195
- return Math.max(1, Math.ceil(words / WORDS_PER_MINUTE))
196
- }
package/src/util/uris.ts DELETED
@@ -1,38 +0,0 @@
1
- import { AtUri, DidString } from '@atproto/syntax'
2
- import { app } from '../lexicons/index.js'
3
- import { StrongRef, validateStrongRef } from '../views/types.js'
4
-
5
- /**
6
- * Convert a post URI to a threadgate URI. If the URI is not a valid
7
- * post URI, return URI unchanged. Threadgate lookups will then fail.
8
- */
9
- export function postUriToThreadgateUri(postUri: string) {
10
- const urip = new AtUri(postUri)
11
- if (urip.collection === app.bsky.feed.post.$type) {
12
- urip.collection = app.bsky.feed.threadgate.$type
13
- }
14
- return urip.toString()
15
- }
16
-
17
- /**
18
- * Convert a post URI to a postgate URI. If the URI is not a valid
19
- * post URI, return URI unchanged. Postgate lookups will then fail.
20
- */
21
- export function postUriToPostgateUri(postUri: string) {
22
- const urip = new AtUri(postUri)
23
- if (urip.collection === app.bsky.feed.post.$type) {
24
- urip.collection = app.bsky.feed.postgate.$type
25
- }
26
- return urip.toString()
27
- }
28
-
29
- export function uriToDid(uri: string): DidString {
30
- // @NOTE URIs returned from the dataplane are always in DID form.
31
- return new AtUri(uri).hostname as DidString
32
- }
33
-
34
- // @TODO temp fix for proliferation of invalid pinned post values
35
- export function safePinnedPost(value: unknown): StrongRef | undefined {
36
- const validated = validateStrongRef(value)
37
- return validated.success ? validated.value : undefined
38
- }