@atproto/bsky 0.0.251 → 0.0.254

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 (463) hide show
  1. package/CHANGELOG.md +50 -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/kws.d.ts +8 -0
  5. package/dist/kws.d.ts.map +1 -1
  6. package/dist/kws.js +53 -4
  7. package/dist/kws.js.map +1 -1
  8. package/dist/lexicons/app/bsky/actor/defs.defs.d.ts +6 -0
  9. package/dist/lexicons/app/bsky/actor/defs.defs.d.ts.map +1 -1
  10. package/dist/lexicons/app/bsky/actor/defs.defs.js +1 -0
  11. package/dist/lexicons/app/bsky/actor/defs.defs.js.map +1 -1
  12. package/package.json +28 -23
  13. package/bin/migration-create.ts +0 -46
  14. package/buf.gen.yaml +0 -12
  15. package/proto/bsky.proto +0 -1907
  16. package/proto/courier.proto +0 -84
  17. package/proto/rolodex.proto +0 -116
  18. package/src/api/age-assurance/const.ts +0 -203
  19. package/src/api/age-assurance/index.ts +0 -34
  20. package/src/api/age-assurance/kws/age-verified.test.ts +0 -98
  21. package/src/api/age-assurance/kws/age-verified.ts +0 -81
  22. package/src/api/age-assurance/kws/const.ts +0 -33
  23. package/src/api/age-assurance/kws/external-payload.test.ts +0 -72
  24. package/src/api/age-assurance/kws/external-payload.ts +0 -149
  25. package/src/api/age-assurance/redirects/kws-age-verified.ts +0 -107
  26. package/src/api/age-assurance/stash.ts +0 -23
  27. package/src/api/age-assurance/types.ts +0 -10
  28. package/src/api/age-assurance/util.ts +0 -68
  29. package/src/api/age-assurance/webhooks/kws-age-verified.ts +0 -75
  30. package/src/api/app/bsky/actor/getProfile.ts +0 -106
  31. package/src/api/app/bsky/actor/getProfiles.ts +0 -99
  32. package/src/api/app/bsky/actor/getSuggestions.ts +0 -163
  33. package/src/api/app/bsky/actor/searchActors.ts +0 -171
  34. package/src/api/app/bsky/actor/searchActorsTypeahead.ts +0 -164
  35. package/src/api/app/bsky/ageassurance/begin.ts +0 -175
  36. package/src/api/app/bsky/ageassurance/getConfig.ts +0 -16
  37. package/src/api/app/bsky/ageassurance/getState.ts +0 -58
  38. package/src/api/app/bsky/bookmark/createBookmark.ts +0 -39
  39. package/src/api/app/bsky/bookmark/deleteBookmark.ts +0 -32
  40. package/src/api/app/bsky/bookmark/getBookmarks.ts +0 -97
  41. package/src/api/app/bsky/bookmark/util.ts +0 -13
  42. package/src/api/app/bsky/contact/dismissMatch.ts +0 -26
  43. package/src/api/app/bsky/contact/getMatches.ts +0 -111
  44. package/src/api/app/bsky/contact/getSyncStatus.ts +0 -38
  45. package/src/api/app/bsky/contact/importContacts.ts +0 -119
  46. package/src/api/app/bsky/contact/removeData.ts +0 -25
  47. package/src/api/app/bsky/contact/sendNotification.ts +0 -33
  48. package/src/api/app/bsky/contact/startPhoneVerification.ts +0 -26
  49. package/src/api/app/bsky/contact/util.ts +0 -92
  50. package/src/api/app/bsky/contact/verifyPhone.ts +0 -29
  51. package/src/api/app/bsky/draft/createDraft.ts +0 -45
  52. package/src/api/app/bsky/draft/deleteDraft.ts +0 -20
  53. package/src/api/app/bsky/draft/getDrafts.ts +0 -44
  54. package/src/api/app/bsky/draft/updateDraft.ts +0 -26
  55. package/src/api/app/bsky/embed/getEmbedExternalView.ts +0 -154
  56. package/src/api/app/bsky/feed/getActorFeeds.ts +0 -101
  57. package/src/api/app/bsky/feed/getActorLikes.ts +0 -128
  58. package/src/api/app/bsky/feed/getAuthorFeed.ts +0 -279
  59. package/src/api/app/bsky/feed/getFeed.ts +0 -282
  60. package/src/api/app/bsky/feed/getFeedGenerator.ts +0 -68
  61. package/src/api/app/bsky/feed/getFeedGenerators.ts +0 -86
  62. package/src/api/app/bsky/feed/getLikes.ts +0 -151
  63. package/src/api/app/bsky/feed/getListFeed.ts +0 -147
  64. package/src/api/app/bsky/feed/getPostThread.ts +0 -156
  65. package/src/api/app/bsky/feed/getPosts.ts +0 -100
  66. package/src/api/app/bsky/feed/getQuotes.ts +0 -122
  67. package/src/api/app/bsky/feed/getRepostedBy.ts +0 -121
  68. package/src/api/app/bsky/feed/getSuggestedFeeds.ts +0 -39
  69. package/src/api/app/bsky/feed/getTimeline.ts +0 -127
  70. package/src/api/app/bsky/feed/searchPosts.ts +0 -274
  71. package/src/api/app/bsky/feed/searchPostsV2.ts +0 -243
  72. package/src/api/app/bsky/graph/getActorStarterPacks.ts +0 -103
  73. package/src/api/app/bsky/graph/getBlocks.ts +0 -94
  74. package/src/api/app/bsky/graph/getFollowers.ts +0 -153
  75. package/src/api/app/bsky/graph/getFollows.ts +0 -151
  76. package/src/api/app/bsky/graph/getKnownFollowers.ts +0 -123
  77. package/src/api/app/bsky/graph/getList.ts +0 -152
  78. package/src/api/app/bsky/graph/getListBlocks.ts +0 -87
  79. package/src/api/app/bsky/graph/getListMutes.ts +0 -87
  80. package/src/api/app/bsky/graph/getLists.ts +0 -125
  81. package/src/api/app/bsky/graph/getListsWithMembership.ts +0 -146
  82. package/src/api/app/bsky/graph/getMutes.ts +0 -87
  83. package/src/api/app/bsky/graph/getRelationships.ts +0 -58
  84. package/src/api/app/bsky/graph/getStarterPack.ts +0 -82
  85. package/src/api/app/bsky/graph/getStarterPacks.ts +0 -86
  86. package/src/api/app/bsky/graph/getStarterPacksWithMembership.ts +0 -136
  87. package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +0 -171
  88. package/src/api/app/bsky/graph/muteActor.ts +0 -24
  89. package/src/api/app/bsky/graph/muteActorList.ts +0 -19
  90. package/src/api/app/bsky/graph/muteThread.ts +0 -19
  91. package/src/api/app/bsky/graph/searchStarterPacks.ts +0 -169
  92. package/src/api/app/bsky/graph/unmuteActor.ts +0 -21
  93. package/src/api/app/bsky/graph/unmuteActorList.ts +0 -19
  94. package/src/api/app/bsky/graph/unmuteThread.ts +0 -19
  95. package/src/api/app/bsky/labeler/getServices.ts +0 -41
  96. package/src/api/app/bsky/notification/getPreferences.ts +0 -49
  97. package/src/api/app/bsky/notification/getUnreadCount.ts +0 -83
  98. package/src/api/app/bsky/notification/listActivitySubscriptions.ts +0 -116
  99. package/src/api/app/bsky/notification/listNotifications.ts +0 -272
  100. package/src/api/app/bsky/notification/putActivitySubscription.ts +0 -69
  101. package/src/api/app/bsky/notification/putPreferences.ts +0 -17
  102. package/src/api/app/bsky/notification/putPreferencesV2.ts +0 -64
  103. package/src/api/app/bsky/notification/registerPush.ts +0 -40
  104. package/src/api/app/bsky/notification/unregisterPush.ts +0 -39
  105. package/src/api/app/bsky/notification/updateSeen.ts +0 -52
  106. package/src/api/app/bsky/notification/util.ts +0 -134
  107. package/src/api/app/bsky/unspecced/getAgeAssuranceState.ts +0 -48
  108. package/src/api/app/bsky/unspecced/getConfig.ts +0 -20
  109. package/src/api/app/bsky/unspecced/getOnboardingSuggestedStarterPacks.ts +0 -162
  110. package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +0 -91
  111. package/src/api/app/bsky/unspecced/getPostThreadOtherV2.ts +0 -126
  112. package/src/api/app/bsky/unspecced/getPostThreadV2.ts +0 -148
  113. package/src/api/app/bsky/unspecced/getSuggestedFeeds.ts +0 -100
  114. package/src/api/app/bsky/unspecced/getSuggestedOnboardingUsers.ts +0 -143
  115. package/src/api/app/bsky/unspecced/getSuggestedStarterPacks.ts +0 -165
  116. package/src/api/app/bsky/unspecced/getSuggestedUsers.ts +0 -183
  117. package/src/api/app/bsky/unspecced/getSuggestedUsersForDiscover.ts +0 -175
  118. package/src/api/app/bsky/unspecced/getSuggestedUsersForExplore.ts +0 -178
  119. package/src/api/app/bsky/unspecced/getSuggestedUsersForSeeMore.ts +0 -178
  120. package/src/api/app/bsky/unspecced/getTaggedSuggestions.ts +0 -27
  121. package/src/api/app/bsky/unspecced/getTrendingTopics.ts +0 -96
  122. package/src/api/app/bsky/unspecced/getTrends.ts +0 -162
  123. package/src/api/app/bsky/unspecced/initAgeAssurance.ts +0 -150
  124. package/src/api/blob-dispatcher.ts +0 -41
  125. package/src/api/blob-resolver.ts +0 -401
  126. package/src/api/com/atproto/admin/getAccountInfos.ts +0 -49
  127. package/src/api/com/atproto/admin/getSubjectStatus.ts +0 -79
  128. package/src/api/com/atproto/admin/updateSubjectStatus.ts +0 -80
  129. package/src/api/com/atproto/identity/resolveHandle.ts +0 -19
  130. package/src/api/com/atproto/label/queryLabels.ts +0 -42
  131. package/src/api/com/atproto/repo/getRecord.ts +0 -44
  132. package/src/api/com/atproto/temp/fetchLabels.ts +0 -9
  133. package/src/api/external.ts +0 -15
  134. package/src/api/health.ts +0 -47
  135. package/src/api/index.ts +0 -216
  136. package/src/api/internal/bsky/actor/getProfiles.ts +0 -87
  137. package/src/api/kws/api.ts +0 -113
  138. package/src/api/kws/index.ts +0 -29
  139. package/src/api/kws/types.ts +0 -78
  140. package/src/api/kws/util.test.ts +0 -50
  141. package/src/api/kws/util.ts +0 -109
  142. package/src/api/kws/webhook.ts +0 -134
  143. package/src/api/sitemap.ts +0 -76
  144. package/src/api/util.ts +0 -45
  145. package/src/api/well-known.ts +0 -44
  146. package/src/auth-verifier.ts +0 -522
  147. package/src/bsync.ts +0 -41
  148. package/src/cache/read-through.ts +0 -157
  149. package/src/config.ts +0 -719
  150. package/src/context.ts +0 -143
  151. package/src/courier.ts +0 -41
  152. package/src/data-plane/client/hosts.ts +0 -103
  153. package/src/data-plane/client/index.ts +0 -125
  154. package/src/data-plane/client/util.test.ts +0 -29
  155. package/src/data-plane/client/util.ts +0 -74
  156. package/src/data-plane/index.ts +0 -2
  157. package/src/data-plane/server/background.ts +0 -66
  158. package/src/data-plane/server/bsync-subscription.ts +0 -590
  159. package/src/data-plane/server/db/database-schema.ts +0 -90
  160. package/src/data-plane/server/db/db.ts +0 -204
  161. package/src/data-plane/server/db/index.ts +0 -2
  162. package/src/data-plane/server/db/migrations/20230309T045948368Z-init.ts +0 -305
  163. package/src/data-plane/server/db/migrations/20230408T152211201Z-notification-init.ts +0 -25
  164. package/src/data-plane/server/db/migrations/20230417T210628672Z-moderation-init.ts +0 -127
  165. package/src/data-plane/server/db/migrations/20230420T211446071Z-did-cache.ts +0 -14
  166. package/src/data-plane/server/db/migrations/20230427T194702079Z-notif-record-index.ts +0 -14
  167. package/src/data-plane/server/db/migrations/20230605T144730094Z-post-profile-aggs.ts +0 -23
  168. package/src/data-plane/server/db/migrations/20230607T211442112Z-feed-generator-init.ts +0 -34
  169. package/src/data-plane/server/db/migrations/20230608T155101190Z-algo-whats-hot-view.ts +0 -85
  170. package/src/data-plane/server/db/migrations/20230608T201813132Z-mute-lists.ts +0 -78
  171. package/src/data-plane/server/db/migrations/20230608T205147239Z-mutes.ts +0 -15
  172. package/src/data-plane/server/db/migrations/20230609T153623961Z-blocks.ts +0 -33
  173. package/src/data-plane/server/db/migrations/20230609T232122649Z-actor-deletion-indexes.ts +0 -27
  174. package/src/data-plane/server/db/migrations/20230610T203555962Z-suggested-follows.ts +0 -13
  175. package/src/data-plane/server/db/migrations/20230611T215300060Z-actor-state.ts +0 -13
  176. package/src/data-plane/server/db/migrations/20230620T161134972Z-post-langs.ts +0 -9
  177. package/src/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.ts +0 -15
  178. package/src/data-plane/server/db/migrations/20230629T220835893Z-remove-post-hierarchy.ts +0 -32
  179. package/src/data-plane/server/db/migrations/20230703T045536691Z-feed-and-label-indices.ts +0 -31
  180. package/src/data-plane/server/db/migrations/20230720T164800037Z-posts-cursor-idx.ts +0 -19
  181. package/src/data-plane/server/db/migrations/20230807T035309811Z-feed-item-delete-invite-for-user-idx.ts +0 -14
  182. package/src/data-plane/server/db/migrations/20230808T172902639Z-repo-rev.ts +0 -12
  183. package/src/data-plane/server/db/migrations/20230810T203349843Z-action-duration.ts +0 -23
  184. package/src/data-plane/server/db/migrations/20230817T195936007Z-native-notifications.ts +0 -16
  185. package/src/data-plane/server/db/migrations/20230830T205507322Z-suggested-feeds.ts +0 -13
  186. package/src/data-plane/server/db/migrations/20230904T211011773Z-block-lists.ts +0 -24
  187. package/src/data-plane/server/db/migrations/20230906T222220386Z-thread-gating.ts +0 -27
  188. package/src/data-plane/server/db/migrations/20230920T213858047Z-add-tags-to-post.ts +0 -9
  189. package/src/data-plane/server/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +0 -40
  190. package/src/data-plane/server/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +0 -123
  191. package/src/data-plane/server/db/migrations/20231220T225126090Z-blob-takedowns.ts +0 -66
  192. package/src/data-plane/server/db/migrations/20240124T023719200Z-tagged-suggestions.ts +0 -15
  193. package/src/data-plane/server/db/migrations/20240226T225725627Z-labelers.ts +0 -27
  194. package/src/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.ts +0 -12
  195. package/src/data-plane/server/db/migrations/20240606T171229898Z-thread-mutes.ts +0 -15
  196. package/src/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.ts +0 -45
  197. package/src/data-plane/server/db/migrations/20240719T203853939Z-priority-notifs.ts +0 -25
  198. package/src/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.ts +0 -12
  199. package/src/data-plane/server/db/migrations/20240723T220703655Z-quotes.ts +0 -28
  200. package/src/data-plane/server/db/migrations/20240801T193939827Z-post-gate.ts +0 -17
  201. package/src/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.ts +0 -25
  202. package/src/data-plane/server/db/migrations/20240829T211238293Z-simplify-actor-sync.ts +0 -23
  203. package/src/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.ts +0 -17
  204. package/src/data-plane/server/db/migrations/20241114T153108102Z-add-starter-packs-name.ts +0 -19
  205. package/src/data-plane/server/db/migrations/20250116T222618297Z-post-embed-video.ts +0 -17
  206. package/src/data-plane/server/db/migrations/20250207T174822012Z-add-label-exp.ts +0 -9
  207. package/src/data-plane/server/db/migrations/20250404T163421487Z-verifications.ts +0 -39
  208. package/src/data-plane/server/db/migrations/20250526T023712742Z-like-repost-via.ts +0 -17
  209. package/src/data-plane/server/db/migrations/20250528T221913281Z-add-record-tags.ts +0 -9
  210. package/src/data-plane/server/db/migrations/20250602T190357447Z-add-private-data.ts +0 -22
  211. package/src/data-plane/server/db/migrations/20250611T140649895Z-add-activity-subscription.ts +0 -22
  212. package/src/data-plane/server/db/migrations/20250627T025331240Z-add-actor-age-assurance-columns.ts +0 -22
  213. package/src/data-plane/server/db/migrations/20250812T183735692Z-add-bookmarks.ts +0 -23
  214. package/src/data-plane/server/db/migrations/20250813T174955711Z-add-post-agg-bookmarks.ts +0 -12
  215. package/src/data-plane/server/db/migrations/20251120T004738098Z-update-actor-age-assurance-v2.ts +0 -28
  216. package/src/data-plane/server/db/migrations/20260112T133951271Z-add-drafts.ts +0 -24
  217. package/src/data-plane/server/db/migrations/20260604T224952774Z-post-embed-gallery-image.ts +0 -19
  218. package/src/data-plane/server/db/migrations/index.ts +0 -60
  219. package/src/data-plane/server/db/migrations/provider.ts +0 -26
  220. package/src/data-plane/server/db/pagination.ts +0 -341
  221. package/src/data-plane/server/db/tables/activity-subscription.ts +0 -12
  222. package/src/data-plane/server/db/tables/actor-block.ts +0 -14
  223. package/src/data-plane/server/db/tables/actor-state.ts +0 -10
  224. package/src/data-plane/server/db/tables/actor-sync.ts +0 -9
  225. package/src/data-plane/server/db/tables/actor.ts +0 -19
  226. package/src/data-plane/server/db/tables/algo.ts +0 -11
  227. package/src/data-plane/server/db/tables/blob-takedown.ts +0 -9
  228. package/src/data-plane/server/db/tables/bookmark.ts +0 -11
  229. package/src/data-plane/server/db/tables/did-cache.ts +0 -13
  230. package/src/data-plane/server/db/tables/draft.ts +0 -11
  231. package/src/data-plane/server/db/tables/duplicate-record.ts +0 -12
  232. package/src/data-plane/server/db/tables/feed-generator.ts +0 -21
  233. package/src/data-plane/server/db/tables/feed-item.ts +0 -12
  234. package/src/data-plane/server/db/tables/follow.ts +0 -15
  235. package/src/data-plane/server/db/tables/label.ts +0 -13
  236. package/src/data-plane/server/db/tables/labeler.ts +0 -16
  237. package/src/data-plane/server/db/tables/like.ts +0 -18
  238. package/src/data-plane/server/db/tables/list-block.ts +0 -15
  239. package/src/data-plane/server/db/tables/list-item.ts +0 -16
  240. package/src/data-plane/server/db/tables/list-mute.ts +0 -9
  241. package/src/data-plane/server/db/tables/list.ts +0 -19
  242. package/src/data-plane/server/db/tables/mute.ts +0 -9
  243. package/src/data-plane/server/db/tables/notification-push-token.ts +0 -10
  244. package/src/data-plane/server/db/tables/notification.ts +0 -16
  245. package/src/data-plane/server/db/tables/post-agg.ts +0 -16
  246. package/src/data-plane/server/db/tables/post-embed.ts +0 -47
  247. package/src/data-plane/server/db/tables/post-gate.ts +0 -12
  248. package/src/data-plane/server/db/tables/post.ts +0 -28
  249. package/src/data-plane/server/db/tables/private-data.ts +0 -13
  250. package/src/data-plane/server/db/tables/profile-agg.ts +0 -14
  251. package/src/data-plane/server/db/tables/profile.ts +0 -17
  252. package/src/data-plane/server/db/tables/quote.ts +0 -15
  253. package/src/data-plane/server/db/tables/record.ts +0 -15
  254. package/src/data-plane/server/db/tables/repost.ts +0 -18
  255. package/src/data-plane/server/db/tables/starter-pack.ts +0 -17
  256. package/src/data-plane/server/db/tables/subscription.ts +0 -9
  257. package/src/data-plane/server/db/tables/suggested-feed.ts +0 -10
  258. package/src/data-plane/server/db/tables/suggested-follow.ts +0 -10
  259. package/src/data-plane/server/db/tables/tagged-suggestion.ts +0 -11
  260. package/src/data-plane/server/db/tables/thread-gate.ts +0 -12
  261. package/src/data-plane/server/db/tables/thread-mute.ts +0 -9
  262. package/src/data-plane/server/db/tables/verification.ts +0 -20
  263. package/src/data-plane/server/db/tables/view-param.ts +0 -12
  264. package/src/data-plane/server/db/types.ts +0 -12
  265. package/src/data-plane/server/db/util.ts +0 -67
  266. package/src/data-plane/server/index.ts +0 -44
  267. package/src/data-plane/server/indexing/index.ts +0 -458
  268. package/src/data-plane/server/indexing/plugins/block.ts +0 -84
  269. package/src/data-plane/server/indexing/plugins/chat-declaration.ts +0 -60
  270. package/src/data-plane/server/indexing/plugins/feed-generator.ts +0 -80
  271. package/src/data-plane/server/indexing/plugins/follow.ts +0 -132
  272. package/src/data-plane/server/indexing/plugins/germ-declaration.ts +0 -57
  273. package/src/data-plane/server/indexing/plugins/labeler.ts +0 -74
  274. package/src/data-plane/server/indexing/plugins/like.ts +0 -151
  275. package/src/data-plane/server/indexing/plugins/list-block.ts +0 -84
  276. package/src/data-plane/server/indexing/plugins/list-item.ts +0 -92
  277. package/src/data-plane/server/indexing/plugins/list.ts +0 -80
  278. package/src/data-plane/server/indexing/plugins/notif-declaration.ts +0 -57
  279. package/src/data-plane/server/indexing/plugins/post-gate.ts +0 -101
  280. package/src/data-plane/server/indexing/plugins/post.ts +0 -675
  281. package/src/data-plane/server/indexing/plugins/profile.ts +0 -90
  282. package/src/data-plane/server/indexing/plugins/repost.ts +0 -176
  283. package/src/data-plane/server/indexing/plugins/starter-pack.ts +0 -74
  284. package/src/data-plane/server/indexing/plugins/status.ts +0 -57
  285. package/src/data-plane/server/indexing/plugins/thread-gate.ts +0 -101
  286. package/src/data-plane/server/indexing/plugins/verification.ts +0 -113
  287. package/src/data-plane/server/indexing/processor.ts +0 -292
  288. package/src/data-plane/server/routes/activity-subscription.ts +0 -84
  289. package/src/data-plane/server/routes/blocks.ts +0 -127
  290. package/src/data-plane/server/routes/bookmarks.ts +0 -83
  291. package/src/data-plane/server/routes/drafts.ts +0 -37
  292. package/src/data-plane/server/routes/feed-gens.ts +0 -89
  293. package/src/data-plane/server/routes/feeds.ts +0 -176
  294. package/src/data-plane/server/routes/follows.ts +0 -141
  295. package/src/data-plane/server/routes/identity.ts +0 -59
  296. package/src/data-plane/server/routes/index.ts +0 -67
  297. package/src/data-plane/server/routes/interactions.ts +0 -120
  298. package/src/data-plane/server/routes/labels.ts +0 -55
  299. package/src/data-plane/server/routes/likes.ts +0 -92
  300. package/src/data-plane/server/routes/lists.ts +0 -88
  301. package/src/data-plane/server/routes/moderation.ts +0 -102
  302. package/src/data-plane/server/routes/mutes.ts +0 -195
  303. package/src/data-plane/server/routes/notifs.ts +0 -239
  304. package/src/data-plane/server/routes/profile.ts +0 -220
  305. package/src/data-plane/server/routes/quotes.ts +0 -32
  306. package/src/data-plane/server/routes/records.ts +0 -119
  307. package/src/data-plane/server/routes/relationships.ts +0 -174
  308. package/src/data-plane/server/routes/reposts.ts +0 -76
  309. package/src/data-plane/server/routes/search.ts +0 -181
  310. package/src/data-plane/server/routes/site-standard.ts +0 -12
  311. package/src/data-plane/server/routes/sitemap.ts +0 -43
  312. package/src/data-plane/server/routes/starter-packs.ts +0 -32
  313. package/src/data-plane/server/routes/suggestions.ts +0 -175
  314. package/src/data-plane/server/routes/sync.ts +0 -16
  315. package/src/data-plane/server/routes/threads.ts +0 -33
  316. package/src/data-plane/server/subscription.ts +0 -152
  317. package/src/data-plane/server/util.ts +0 -202
  318. package/src/error.ts +0 -12
  319. package/src/etcd.ts +0 -90
  320. package/src/feature-gates/README.md +0 -83
  321. package/src/feature-gates/gates.ts +0 -25
  322. package/src/feature-gates/index.ts +0 -235
  323. package/src/feature-gates/metrics.test.ts +0 -196
  324. package/src/feature-gates/metrics.ts +0 -107
  325. package/src/feature-gates/types.ts +0 -62
  326. package/src/feature-gates/utils.test.ts +0 -66
  327. package/src/feature-gates/utils.ts +0 -135
  328. package/src/hydration/actor.ts +0 -578
  329. package/src/hydration/external.test.ts +0 -281
  330. package/src/hydration/external.ts +0 -268
  331. package/src/hydration/feed.ts +0 -455
  332. package/src/hydration/graph.ts +0 -354
  333. package/src/hydration/hydrator.ts +0 -1835
  334. package/src/hydration/label.ts +0 -207
  335. package/src/hydration/util.ts +0 -199
  336. package/src/image/index.ts +0 -2
  337. package/src/image/invalidator.ts +0 -33
  338. package/src/image/logger.ts +0 -6
  339. package/src/image/server.ts +0 -228
  340. package/src/image/sharp.ts +0 -89
  341. package/src/image/uri.ts +0 -114
  342. package/src/image/util.ts +0 -41
  343. package/src/index.ts +0 -312
  344. package/src/kws.ts +0 -197
  345. package/src/logger.ts +0 -40
  346. package/src/pipeline.ts +0 -60
  347. package/src/redis.ts +0 -205
  348. package/src/rolodex.ts +0 -42
  349. package/src/stash.ts +0 -76
  350. package/src/util/debug.ts +0 -10
  351. package/src/util/http.ts +0 -42
  352. package/src/util/retry.ts +0 -10
  353. package/src/util/standard-site.test.ts +0 -423
  354. package/src/util/standard-site.ts +0 -196
  355. package/src/util/uris.ts +0 -38
  356. package/src/util.ts +0 -48
  357. package/src/views/index.ts +0 -2783
  358. package/src/views/threads-v2.ts +0 -510
  359. package/src/views/types.ts +0 -193
  360. package/src/views/util.ts +0 -114
  361. package/test.env +0 -2
  362. package/tests/__snapshots__/feed-generation.test.ts.snap +0 -2510
  363. package/tests/_util.ts +0 -292
  364. package/tests/admin/admin-auth.test.ts +0 -190
  365. package/tests/admin/moderation.test.ts +0 -222
  366. package/tests/auth.test.ts +0 -90
  367. package/tests/blob-resolver.test.ts +0 -125
  368. package/tests/data-plane/__snapshots__/indexing.test.ts.snap +0 -887
  369. package/tests/data-plane/db.test.ts +0 -189
  370. package/tests/data-plane/duplicate-records.test.ts +0 -156
  371. package/tests/data-plane/handle-invalidation.test.ts +0 -153
  372. package/tests/data-plane/indexing.test.ts +0 -827
  373. package/tests/data-plane/subscription.test.ts +0 -128
  374. package/tests/data-plane/thread-mutes.test.ts +0 -175
  375. package/tests/entryway-auth.test.ts +0 -177
  376. package/tests/etcd.test.ts +0 -302
  377. package/tests/feed-generation.test.ts +0 -965
  378. package/tests/hydration/util.test.ts +0 -119
  379. package/tests/image/server.test.ts +0 -97
  380. package/tests/image/sharp.test.ts +0 -199
  381. package/tests/image/uri.test.ts +0 -106
  382. package/tests/label-hydration.test.ts +0 -245
  383. package/tests/postgates.test.ts +0 -182
  384. package/tests/query-labels.test.ts +0 -85
  385. package/tests/redis-cache.test.ts +0 -230
  386. package/tests/seed/feed-hidden-replies.ts +0 -63
  387. package/tests/seed/get-suggested-starter-packs.ts +0 -64
  388. package/tests/seed/get-trends.ts +0 -71
  389. package/tests/seed/known-followers.ts +0 -111
  390. package/tests/seed/postgates.ts +0 -57
  391. package/tests/server.test.ts +0 -115
  392. package/tests/sitemap.test.ts +0 -75
  393. package/tests/stash.test.ts +0 -180
  394. package/tests/utils.test.ts +0 -36
  395. package/tests/views/__snapshots__/actor-search.test.ts.snap +0 -155
  396. package/tests/views/__snapshots__/author-feed.test.ts.snap +0 -6301
  397. package/tests/views/__snapshots__/block-lists.test.ts.snap +0 -690
  398. package/tests/views/__snapshots__/blocks.test.ts.snap +0 -462
  399. package/tests/views/__snapshots__/bookmarks.test.ts.snap +0 -379
  400. package/tests/views/__snapshots__/follows.test.ts.snap +0 -798
  401. package/tests/views/__snapshots__/labeler-service.test.ts.snap +0 -233
  402. package/tests/views/__snapshots__/likes.test.ts.snap +0 -124
  403. package/tests/views/__snapshots__/list-feed.test.ts.snap +0 -883
  404. package/tests/views/__snapshots__/lists.test.ts.snap +0 -650
  405. package/tests/views/__snapshots__/mute-lists.test.ts.snap +0 -705
  406. package/tests/views/__snapshots__/mutes.test.ts.snap +0 -353
  407. package/tests/views/__snapshots__/notifications.test.ts.snap +0 -3074
  408. package/tests/views/__snapshots__/posts.test.ts.snap +0 -1019
  409. package/tests/views/__snapshots__/profile.test.ts.snap +0 -811
  410. package/tests/views/__snapshots__/quotes.test.ts.snap +0 -445
  411. package/tests/views/__snapshots__/reposts.test.ts.snap +0 -112
  412. package/tests/views/__snapshots__/starter-packs.test.ts.snap +0 -836
  413. package/tests/views/__snapshots__/thread-v2.test.ts.snap +0 -1298
  414. package/tests/views/__snapshots__/thread.test.ts.snap +0 -2051
  415. package/tests/views/__snapshots__/threadgating.test.ts.snap +0 -189
  416. package/tests/views/__snapshots__/timeline.test.ts.snap +0 -7252
  417. package/tests/views/account-deactivation.test.ts +0 -81
  418. package/tests/views/actor-likes.test.ts +0 -138
  419. package/tests/views/actor-search.test.ts +0 -261
  420. package/tests/views/age-assurance-v2.test.ts +0 -823
  421. package/tests/views/age-assurance.test.ts +0 -479
  422. package/tests/views/author-feed.test.ts +0 -694
  423. package/tests/views/block-lists.test.ts +0 -661
  424. package/tests/views/blocks.test.ts +0 -889
  425. package/tests/views/bookmarks.test.ts +0 -345
  426. package/tests/views/drafts.test.ts +0 -430
  427. package/tests/views/feed-hidden-replies.test.ts +0 -243
  428. package/tests/views/feed-view-post.test.ts +0 -501
  429. package/tests/views/follows.test.ts +0 -372
  430. package/tests/views/get-config.test.ts +0 -64
  431. package/tests/views/get-suggested-onboarding-users.test.ts +0 -193
  432. package/tests/views/get-suggested-starter-packs.test.ts +0 -137
  433. package/tests/views/get-trends.test.ts +0 -141
  434. package/tests/views/internal-actor.test.ts +0 -127
  435. package/tests/views/known-followers.test.ts +0 -193
  436. package/tests/views/labeler-service.test.ts +0 -242
  437. package/tests/views/labels-needs-review.test.ts +0 -316
  438. package/tests/views/labels-takedown.test.ts +0 -247
  439. package/tests/views/likes.test.ts +0 -192
  440. package/tests/views/list-feed.test.ts +0 -195
  441. package/tests/views/lists.test.ts +0 -412
  442. package/tests/views/mute-lists.test.ts +0 -509
  443. package/tests/views/mutes.test.ts +0 -308
  444. package/tests/views/notifications.test.ts +0 -1581
  445. package/tests/views/post-search.test.ts +0 -281
  446. package/tests/views/posts-debug.test.ts +0 -79
  447. package/tests/views/posts.test.ts +0 -427
  448. package/tests/views/profile-debug.test.ts +0 -75
  449. package/tests/views/profile.test.ts +0 -795
  450. package/tests/views/quotes.test.ts +0 -133
  451. package/tests/views/reposts.test.ts +0 -112
  452. package/tests/views/starter-packs.test.ts +0 -395
  453. package/tests/views/suggestions.test.ts +0 -145
  454. package/tests/views/thread-v2.test.ts +0 -2005
  455. package/tests/views/thread.test.ts +0 -637
  456. package/tests/views/threadgating.test.ts +0 -843
  457. package/tests/views/timeline.test.ts +0 -328
  458. package/tests/views/verification.test.ts +0 -296
  459. package/tsconfig.build.json +0 -10
  460. package/tsconfig.build.tsbuildinfo +0 -1
  461. package/tsconfig.json +0 -7
  462. package/tsconfig.tests.json +0 -8
  463. package/vitest.config.ts +0 -10
@@ -1,795 +0,0 @@
1
- import assert from 'node:assert'
2
- import fs from 'node:fs/promises'
3
- import { Timestamp } from '@bufbuild/protobuf'
4
- import {
5
- afterAll,
6
- beforeAll,
7
- beforeEach,
8
- describe,
9
- expect,
10
- it,
11
- vi,
12
- } from 'vitest'
13
- import {
14
- AppBskyEmbedExternal,
15
- AtpAgent,
16
- ComGermnetworkDeclaration,
17
- ids,
18
- } from '@atproto/api'
19
- import { HOUR, MINUTE } from '@atproto/common'
20
- import { SeedClient, TestNetwork, basicSeed } from '@atproto/dev-env'
21
- import type { DidString } from '@atproto/syntax'
22
- import { forSnapshot, stripViewer } from '../_util.js'
23
-
24
- describe('pds profile views', () => {
25
- let network: TestNetwork
26
- let agent: AtpAgent
27
- let pdsAgent: AtpAgent
28
- let sc: SeedClient
29
- let labelerDid: DidString
30
-
31
- // account dids, for convenience
32
- let alice: DidString
33
- let bob: DidString
34
- let dan: DidString
35
- let eve: DidString
36
- let frank: DidString
37
- let noprofile: DidString
38
-
39
- beforeAll(async () => {
40
- network = await TestNetwork.create({
41
- dbPostgresSchema: 'bsky_views_profile',
42
- })
43
- agent = network.bsky.getAgent()
44
- pdsAgent = network.pds.getAgent()
45
- sc = network.getSeedClient()
46
- labelerDid = network.bsky.ctx.cfg.labelsFromIssuerDids[0]
47
- await basicSeed(sc)
48
-
49
- await sc.createAccount('eve', {
50
- handle: 'eve.test',
51
- email: 'eve@test.com',
52
- password: 'eve-pass',
53
- })
54
- await sc.createProfile(
55
- sc.dids.eve,
56
- 'eve',
57
- `It's me, eve`,
58
- undefined,
59
- undefined,
60
- {
61
- pronouns: 'They/them',
62
- // Not allowing that to go through, even though is a valid URL.
63
- website: 'wss://jetstream1.us-east.bsky.network',
64
- },
65
- )
66
-
67
- await sc.createAccount('frank', {
68
- handle: 'frank.test',
69
- email: 'frank@test.com',
70
- password: 'frank-pass',
71
- })
72
- await sc.createProfile(
73
- sc.dids.frank,
74
- 'frank',
75
- `It's me, frank`,
76
- undefined,
77
- undefined,
78
- {
79
- website: 'https://frank.example.com',
80
- },
81
- )
82
-
83
- await sc.createAccount('noprofile', {
84
- handle: 'noprofile.test',
85
- email: 'noprofile@test.com',
86
- password: 'noprofile-pass',
87
- })
88
-
89
- alice = sc.dids.alice
90
- bob = sc.dids.bob
91
- dan = sc.dids.dan
92
- eve = sc.dids.eve
93
- frank = sc.dids.frank
94
- noprofile = sc.dids.noprofile
95
- })
96
-
97
- beforeEach(async () => network.processAll())
98
- afterAll(async () => network?.close())
99
-
100
- // @TODO(bsky) blocked by actor takedown via labels.
101
-
102
- it('fetches own profile', async () => {
103
- const aliceForAlice = await agent.api.app.bsky.actor.getProfile(
104
- { actor: alice },
105
- {
106
- headers: await network.serviceHeaders(
107
- alice,
108
- ids.AppBskyActorGetProfile,
109
- ),
110
- },
111
- )
112
-
113
- expect(forSnapshot(aliceForAlice.data)).toMatchSnapshot()
114
- })
115
-
116
- it('returns empty profile if actor exists but has no profile', async () => {
117
- const res = await agent.app.bsky.actor.getProfile(
118
- { actor: noprofile },
119
- {
120
- headers: await network.serviceHeaders(
121
- alice,
122
- ids.AppBskyActorGetProfile,
123
- ),
124
- },
125
- )
126
-
127
- expect(forSnapshot(res.data)).toMatchSnapshot()
128
- })
129
-
130
- it('returns empty profile for actor that exists but has no profile', async () => {
131
- const res = await agent.app.bsky.actor.getProfiles(
132
- { actors: [bob, noprofile] },
133
- {
134
- headers: await network.serviceHeaders(
135
- alice,
136
- ids.AppBskyActorGetProfiles,
137
- ),
138
- },
139
- )
140
-
141
- expect(res.data.profiles).toHaveLength(2)
142
- expect(res.data.profiles[0].did).toBe(bob)
143
- expect(res.data.profiles[1].did).toBe(noprofile)
144
- expect(forSnapshot(res.data)).toMatchSnapshot()
145
- })
146
-
147
- it('reflects self-labels', async () => {
148
- const aliceForBob = await agent.api.app.bsky.actor.getProfile(
149
- { actor: alice },
150
- {
151
- headers: await network.serviceHeaders(bob, ids.AppBskyActorGetProfile),
152
- },
153
- )
154
-
155
- const labels = aliceForBob.data.labels
156
- ?.filter((label) => label.src === alice)
157
- .map((label) => label.val)
158
- .sort()
159
-
160
- expect(labels).toEqual(['self-label-a', 'self-label-b'])
161
- })
162
-
163
- it("fetches other's profile, with a follow", async () => {
164
- const aliceForBob = await agent.api.app.bsky.actor.getProfile(
165
- { actor: alice },
166
- {
167
- headers: await network.serviceHeaders(bob, ids.AppBskyActorGetProfile),
168
- },
169
- )
170
-
171
- expect(forSnapshot(aliceForBob.data)).toMatchSnapshot()
172
- })
173
-
174
- it("fetches other's profile, without a follow", async () => {
175
- const danForBob = await agent.api.app.bsky.actor.getProfile(
176
- { actor: dan },
177
- {
178
- headers: await network.serviceHeaders(bob, ids.AppBskyActorGetProfile),
179
- },
180
- )
181
-
182
- expect(forSnapshot(danForBob.data)).toMatchSnapshot()
183
- })
184
-
185
- it('fetches multiple profiles', async () => {
186
- const {
187
- data: { profiles },
188
- } = await agent.api.app.bsky.actor.getProfiles(
189
- {
190
- actors: [
191
- alice,
192
- 'bob.test',
193
- 'did:example:missing',
194
- 'carol.test',
195
- dan,
196
- eve,
197
- frank,
198
- 'missing.test',
199
- ],
200
- },
201
- {
202
- headers: await network.serviceHeaders(bob, ids.AppBskyActorGetProfiles),
203
- },
204
- )
205
-
206
- expect(profiles.map((p) => p.handle)).toEqual([
207
- 'alice.test',
208
- 'bob.test',
209
- 'carol.test',
210
- 'dan.test',
211
- 'eve.test',
212
- 'frank.test',
213
- ])
214
-
215
- expect(forSnapshot(profiles)).toMatchSnapshot()
216
- })
217
-
218
- it('presents avatars & banners', async () => {
219
- const avatarImg = await fs.readFile(
220
- '../dev-env/assets/key-portrait-small.jpg',
221
- )
222
- const bannerImg = await fs.readFile(
223
- '../dev-env/assets/key-landscape-small.jpg',
224
- )
225
- const avatarRes = await pdsAgent.api.com.atproto.repo.uploadBlob(
226
- avatarImg,
227
- {
228
- headers: sc.getHeaders(alice),
229
- encoding: 'image/jpeg',
230
- },
231
- )
232
- const bannerRes = await pdsAgent.api.com.atproto.repo.uploadBlob(
233
- bannerImg,
234
- {
235
- headers: sc.getHeaders(alice),
236
- encoding: 'image/jpeg',
237
- },
238
- )
239
-
240
- await updateProfile(alice, {
241
- displayName: 'ali',
242
- description: 'new descript',
243
- avatar: avatarRes.data.blob,
244
- banner: bannerRes.data.blob,
245
- })
246
- await network.processAll()
247
-
248
- const aliceForAlice = await agent.api.app.bsky.actor.getProfile(
249
- { actor: alice },
250
- {
251
- headers: await network.serviceHeaders(
252
- alice,
253
- ids.AppBskyActorGetProfile,
254
- ),
255
- },
256
- )
257
-
258
- expect(forSnapshot(aliceForAlice.data)).toMatchSnapshot()
259
- })
260
-
261
- it('fetches profile by handle', async () => {
262
- const byDid = await agent.api.app.bsky.actor.getProfile(
263
- { actor: alice },
264
- {
265
- headers: await network.serviceHeaders(bob, ids.AppBskyActorGetProfile),
266
- },
267
- )
268
-
269
- const byHandle = await agent.api.app.bsky.actor.getProfile(
270
- { actor: sc.accounts[alice].handle },
271
- {
272
- headers: await network.serviceHeaders(bob, ids.AppBskyActorGetProfile),
273
- },
274
- )
275
-
276
- expect(byHandle.data).toEqual(byDid.data)
277
- })
278
-
279
- it('fetches profile unauthed', async () => {
280
- const { data: authed } = await agent.api.app.bsky.actor.getProfile(
281
- { actor: alice },
282
- {
283
- headers: await network.serviceHeaders(bob, ids.AppBskyActorGetProfile),
284
- },
285
- )
286
- const { data: unauthed } = await agent.api.app.bsky.actor.getProfile({
287
- actor: alice,
288
- })
289
- expect(unauthed).toEqual(stripViewer(authed))
290
- })
291
-
292
- it('fetches multiple profiles unauthed', async () => {
293
- const { data: authed } = await agent.api.app.bsky.actor.getProfiles(
294
- {
295
- actors: [alice, 'bob.test', 'missing.test'],
296
- },
297
- {
298
- headers: await network.serviceHeaders(bob, ids.AppBskyActorGetProfiles),
299
- },
300
- )
301
- const { data: unauthed } = await agent.api.app.bsky.actor.getProfiles({
302
- actors: [alice, 'bob.test', 'missing.test'],
303
- })
304
- expect(unauthed.profiles.length).toBeGreaterThan(0)
305
- expect(unauthed.profiles).toEqual(authed.profiles.map(stripViewer))
306
- })
307
-
308
- it('blocked by actor takedown', async () => {
309
- await network.bsky.ctx.dataplane.takedownActor({
310
- did: alice,
311
- })
312
- const promise = agent.api.app.bsky.actor.getProfile(
313
- { actor: alice },
314
- {
315
- headers: await network.serviceHeaders(bob, ids.AppBskyActorGetProfile),
316
- },
317
- )
318
-
319
- await expect(promise).rejects.toThrow('Account has been suspended')
320
-
321
- // Cleanup
322
- await network.bsky.ctx.dataplane.untakedownActor({
323
- did: alice,
324
- })
325
- })
326
-
327
- describe('status', () => {
328
- const embed: AppBskyEmbedExternal.Main = {
329
- $type: 'app.bsky.embed.external',
330
- external: {
331
- uri: 'https://example.com',
332
- title: 'TestImage',
333
- description: 'testLink',
334
- },
335
- }
336
-
337
- it(`omits status if doesn't exist`, async () => {
338
- const { data } = await agent.api.app.bsky.actor.getProfile(
339
- { actor: alice },
340
- {
341
- headers: await network.serviceHeaders(
342
- alice,
343
- ids.AppBskyActorGetProfile,
344
- ),
345
- },
346
- )
347
- expect(data.status).toBeUndefined()
348
- })
349
-
350
- it('returns active status when within the duration', async () => {
351
- await sc.agent.com.atproto.repo.createRecord(
352
- {
353
- repo: alice,
354
- collection: ids.AppBskyActorStatus,
355
- rkey: 'self',
356
- record: {
357
- status: 'app.bsky.actor.status#live',
358
- embed,
359
- durationMinutes: 10,
360
- createdAt: new Date().toISOString(),
361
- },
362
- },
363
- {
364
- headers: sc.getHeaders(alice),
365
- encoding: 'application/json',
366
- },
367
- )
368
- await network.processAll()
369
-
370
- const { data } = await agent.api.app.bsky.actor.getProfile(
371
- { actor: alice },
372
- {
373
- headers: await network.serviceHeaders(
374
- alice,
375
- ids.AppBskyActorGetProfile,
376
- ),
377
- },
378
- )
379
- expect(forSnapshot(data.status)).toMatchSnapshot()
380
- })
381
-
382
- it('limits the minimum duration', async () => {
383
- await sc.agent.com.atproto.repo.putRecord(
384
- {
385
- repo: alice,
386
- collection: ids.AppBskyActorStatus,
387
- rkey: 'self',
388
- record: {
389
- status: 'app.bsky.actor.status#live',
390
- embed,
391
- durationMinutes: 1,
392
- createdAt: new Date().toISOString(),
393
- },
394
- },
395
- {
396
- headers: sc.getHeaders(alice),
397
- encoding: 'application/json',
398
- },
399
- )
400
- await network.processAll()
401
-
402
- const { data } = await agent.api.app.bsky.actor.getProfile(
403
- { actor: alice },
404
- {
405
- headers: await network.serviceHeaders(
406
- alice,
407
- ids.AppBskyActorGetProfile,
408
- ),
409
- },
410
- )
411
-
412
- assert(data.status)
413
- const createdAt = new Date(data.status.record.createdAt as string)
414
- const expiresAt = new Date(data.status.expiresAt as string)
415
- expect(expiresAt.getTime() - createdAt.getTime()).toBe(5 * MINUTE)
416
- })
417
-
418
- it('limits the maximum duration', async () => {
419
- await sc.agent.com.atproto.repo.putRecord(
420
- {
421
- repo: alice,
422
- collection: ids.AppBskyActorStatus,
423
- rkey: 'self',
424
- record: {
425
- status: 'app.bsky.actor.status#live',
426
- embed,
427
- durationMinutes: 1_440, // 1 day in minutes
428
- createdAt: new Date().toISOString(),
429
- },
430
- },
431
- {
432
- headers: sc.getHeaders(alice),
433
- encoding: 'application/json',
434
- },
435
- )
436
- await network.processAll()
437
-
438
- const { data } = await agent.api.app.bsky.actor.getProfile(
439
- { actor: alice },
440
- {
441
- headers: await network.serviceHeaders(
442
- alice,
443
- ids.AppBskyActorGetProfile,
444
- ),
445
- },
446
- )
447
-
448
- assert(data.status)
449
- const createdAt = new Date(data.status.record.createdAt as string)
450
- const expiresAt = new Date(data.status.expiresAt as string)
451
- expect(expiresAt.getTime() - createdAt.getTime()).toBe(4 * HOUR)
452
- })
453
-
454
- describe('when outside the duration', () => {
455
- const now = '2021-01-01T01:00:00.000Z'
456
- const nowPlus15M = '2021-01-01T01:15:00.000Z'
457
-
458
- beforeAll(() => {
459
- vi.useFakeTimers({ toFake: ['Date'] })
460
- vi.setSystemTime(new Date(now))
461
- })
462
-
463
- afterAll(async () => {
464
- vi.useRealTimers()
465
- })
466
-
467
- it('returns inactive status', async () => {
468
- await sc.agent.com.atproto.repo.putRecord(
469
- {
470
- repo: alice,
471
- collection: ids.AppBskyActorStatus,
472
- rkey: 'self',
473
- record: {
474
- status: 'app.bsky.actor.status#live',
475
- embed,
476
- durationMinutes: 10,
477
- createdAt: new Date().toISOString(),
478
- },
479
- },
480
- {
481
- headers: sc.getHeaders(alice),
482
- encoding: 'application/json',
483
- },
484
- )
485
- await network.processAll()
486
-
487
- vi.setSystemTime(new Date(nowPlus15M))
488
-
489
- const { data } = await agent.api.app.bsky.actor.getProfile(
490
- { actor: alice },
491
- {
492
- headers: await network.serviceHeaders(
493
- alice,
494
- ids.AppBskyActorGetProfile,
495
- ),
496
- },
497
- )
498
-
499
- // Doesn't need `forSnapshot` because the dates are already mocked.
500
- expect(forSnapshot(data.status)).toMatchSnapshot()
501
- })
502
- })
503
-
504
- describe('labeled', () => {
505
- beforeAll(async () => {
506
- const res = await sc.agent.com.atproto.repo.putRecord(
507
- {
508
- repo: alice,
509
- collection: ids.AppBskyActorStatus,
510
- rkey: 'self',
511
- record: {
512
- status: 'app.bsky.actor.status#live',
513
- embed,
514
- durationMinutes: 10,
515
- createdAt: new Date().toISOString(),
516
- },
517
- },
518
- {
519
- headers: sc.getHeaders(alice),
520
- encoding: 'application/json',
521
- },
522
- )
523
- await network.processAll()
524
-
525
- await createLabel({
526
- src: labelerDid,
527
- uri: res.data.uri,
528
- cid: res.data.cid,
529
- val: 'spam',
530
- })
531
- await network.processAll()
532
- })
533
-
534
- it('returns labels on statusView', async () => {
535
- const { data } = await agent.api.app.bsky.actor.getProfile(
536
- { actor: alice },
537
- {
538
- headers: {
539
- 'atproto-accept-labelers': labelerDid,
540
- ...(await network.serviceHeaders(
541
- bob,
542
- ids.AppBskyActorGetProfile,
543
- )),
544
- },
545
- },
546
- )
547
-
548
- expect(data.status?.labels).toBeDefined()
549
- expect(data.status?.labels?.length).toBe(1)
550
- expect(data.status?.labels?.at(0)?.val).toBe('spam')
551
- })
552
- })
553
-
554
- /*
555
- * THIS ONE MUST BE LAST, since a takedown of a `self` rkey record prevents
556
- * subsequent hydrations of that record.
557
- */
558
- describe('when taken down', () => {
559
- beforeAll(async () => {
560
- const res = await sc.agent.com.atproto.repo.putRecord(
561
- {
562
- repo: alice,
563
- collection: ids.AppBskyActorStatus,
564
- rkey: 'self',
565
- record: {
566
- status: 'app.bsky.actor.status#live',
567
- embed,
568
- durationMinutes: 10,
569
- createdAt: new Date().toISOString(),
570
- },
571
- },
572
- {
573
- headers: sc.getHeaders(alice),
574
- encoding: 'application/json',
575
- },
576
- )
577
- await network.processAll()
578
-
579
- await network.bsky.ctx.dataplane.takedownRecord({
580
- recordUri: res.data.uri,
581
- })
582
- await network.processAll()
583
- })
584
-
585
- it('it returns the live status with isDisabled=true for status owner', async () => {
586
- const { data } = await agent.api.app.bsky.actor.getProfile(
587
- { actor: alice },
588
- {
589
- headers: await network.serviceHeaders(
590
- alice,
591
- ids.AppBskyActorGetProfile,
592
- ),
593
- },
594
- )
595
-
596
- expect(data.status?.isDisabled).toBe(true)
597
- expect(forSnapshot(data.status)).toMatchSnapshot()
598
- })
599
-
600
- it('it does not return the live status for non-owner', async () => {
601
- const { data } = await agent.api.app.bsky.actor.getProfile(
602
- { actor: alice },
603
- {
604
- headers: await network.serviceHeaders(
605
- bob,
606
- ids.AppBskyActorGetProfile,
607
- ),
608
- },
609
- )
610
-
611
- expect(forSnapshot(data.status)).toBeUndefined()
612
- })
613
- })
614
- })
615
-
616
- describe('chat', () => {
617
- it('omits chat if no declaration exists', async () => {
618
- const { data } = await agent.api.app.bsky.actor.getProfile(
619
- { actor: alice },
620
- {
621
- headers: await network.serviceHeaders(
622
- alice,
623
- ids.AppBskyActorGetProfile,
624
- ),
625
- },
626
- )
627
- expect(data.associated?.chat).toBeUndefined()
628
- })
629
-
630
- it('returns allowIncoming when only that field is set', async () => {
631
- const { data } = await agent.api.app.bsky.actor.getProfile(
632
- { actor: dan },
633
- {
634
- headers: await network.serviceHeaders(
635
- alice,
636
- ids.AppBskyActorGetProfile,
637
- ),
638
- },
639
- )
640
- expect(data.associated?.chat).toEqual({
641
- allowIncoming: 'none',
642
- })
643
- })
644
-
645
- it('returns both allowIncoming and allowGroupInvites when both are set', async () => {
646
- await sc.agent.com.atproto.repo.putRecord(
647
- {
648
- repo: eve,
649
- collection: ids.ChatBskyActorDeclaration,
650
- rkey: 'self',
651
- record: {
652
- $type: ids.ChatBskyActorDeclaration,
653
- allowIncoming: 'following',
654
- allowGroupInvites: 'all',
655
- },
656
- },
657
- {
658
- headers: sc.getHeaders(eve),
659
- encoding: 'application/json',
660
- },
661
- )
662
- await network.processAll()
663
-
664
- const { data } = await agent.api.app.bsky.actor.getProfile(
665
- { actor: eve },
666
- {
667
- headers: await network.serviceHeaders(
668
- alice,
669
- ids.AppBskyActorGetProfile,
670
- ),
671
- },
672
- )
673
- expect(data.associated?.chat).toEqual({
674
- allowIncoming: 'following',
675
- allowGroupInvites: 'all',
676
- })
677
- })
678
- })
679
-
680
- describe('germ', () => {
681
- const germDeclaration: ComGermnetworkDeclaration.Main = {
682
- $type: ids.ComGermnetworkDeclaration,
683
- version: '0.1.0',
684
- currentKey: new Uint8Array([0o01, 0o02, 0o03]),
685
- messageMe: {
686
- messageMeUrl: 'https://chat.example.com/start-conversation',
687
- showButtonTo: 'everyone',
688
- },
689
- }
690
-
691
- it(`omits germ record if doesn't exist`, async () => {
692
- const { data } = await agent.api.app.bsky.actor.getProfile(
693
- { actor: alice },
694
- {
695
- headers: await network.serviceHeaders(
696
- alice,
697
- ids.AppBskyActorGetProfile,
698
- ),
699
- },
700
- )
701
- expect(data.associated?.germ).toBeUndefined()
702
- })
703
-
704
- it('returns germ record if it does exist', async () => {
705
- await sc.agent.com.atproto.repo.createRecord(
706
- {
707
- repo: bob,
708
- collection: ids.ComGermnetworkDeclaration,
709
- rkey: 'self',
710
- record: germDeclaration,
711
- },
712
- {
713
- headers: sc.getHeaders(bob),
714
- encoding: 'application/json',
715
- },
716
- )
717
- await network.processAll()
718
-
719
- const { data } = await agent.api.app.bsky.actor.getProfile(
720
- { actor: bob },
721
- {
722
- headers: await network.serviceHeaders(
723
- alice,
724
- ids.AppBskyActorGetProfile,
725
- ),
726
- },
727
- )
728
- expect(data.associated?.germ?.showButtonTo).toEqual('everyone')
729
- expect(forSnapshot(data.associated?.germ)).toMatchSnapshot()
730
- })
731
- })
732
-
733
- it('filters out Go zero-value dates from dataplane', async () => {
734
- using getActorsSpy = vi.spyOn(network.bsky.ctx.dataplane, 'getActors')
735
-
736
- getActorsSpy.mockImplementationOnce(async (req) => {
737
- const result = await network.bsky.ctx.dataplane.getActors(req)
738
-
739
- // Inject a Go zero-value date (0001-01-01 00:00:00 UTC)
740
- if (result.actors.length > 0 && result.actors[0]) {
741
- const actor = result.actors[0]
742
- const goZeroDate = new Date(-62135596800000)
743
- actor.createdAt = Timestamp.fromDate(goZeroDate)
744
- }
745
-
746
- return result
747
- })
748
-
749
- const { data } = await agent.app.bsky.actor.getProfile(
750
- { actor: alice },
751
- {
752
- headers: await network.serviceHeaders(bob, ids.AppBskyActorGetProfile),
753
- },
754
- )
755
-
756
- // The hydration layer filters Go zero-values out
757
- expect(data.createdAt).toBeUndefined()
758
- })
759
-
760
- async function updateProfile(
761
- did: DidString,
762
- record: Record<string, unknown>,
763
- ) {
764
- return await pdsAgent.api.com.atproto.repo.putRecord(
765
- {
766
- repo: did,
767
- collection: ids.AppBskyActorProfile,
768
- rkey: 'self',
769
- record,
770
- },
771
- { headers: sc.getHeaders(did), encoding: 'application/json' },
772
- )
773
- }
774
-
775
- const createLabel = async (opts: {
776
- src?: string
777
- uri: string
778
- cid: string
779
- val: string
780
- exp?: string
781
- }) => {
782
- await network.bsky.db.db
783
- .insertInto('label')
784
- .values({
785
- uri: opts.uri,
786
- cid: opts.cid,
787
- val: opts.val,
788
- cts: new Date().toISOString(),
789
- exp: opts.exp ?? null,
790
- neg: false,
791
- src: opts.src ?? labelerDid,
792
- })
793
- .execute()
794
- }
795
- })