@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,84 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package courier;
4
- option go_package = "./;courier";
5
-
6
- import "google/protobuf/struct.proto";
7
- import "google/protobuf/timestamp.proto";
8
-
9
- //
10
- // Messages
11
- //
12
-
13
- // Ping
14
- message PingRequest {}
15
- message PingResponse {}
16
-
17
- // Notifications
18
-
19
- enum AppPlatform {
20
- APP_PLATFORM_UNSPECIFIED = 0;
21
- APP_PLATFORM_IOS = 1;
22
- APP_PLATFORM_ANDROID = 2;
23
- APP_PLATFORM_WEB = 3;
24
- }
25
-
26
- message Notification {
27
- string id = 1;
28
- string recipient_did = 2;
29
- string title = 3;
30
- string message = 4;
31
- string collapse_key = 5;
32
- bool always_deliver = 6;
33
- google.protobuf.Timestamp timestamp = 7;
34
- google.protobuf.Struct additional = 8;
35
- bool client_controlled = 9;
36
- // Maps to iOS's `thread-id`: https://developer.apple.com/documentation/usernotifications/generating-a-remote-notification.
37
- string thread_id = 10;
38
- }
39
-
40
- message PushNotificationsRequest {
41
- repeated Notification notifications = 1;
42
- }
43
-
44
- message PushNotificationsResponse {}
45
-
46
- message RegisterDeviceTokenRequest {
47
- string did = 1;
48
- string token = 2;
49
- string app_id = 3;
50
- AppPlatform platform = 4;
51
- bool age_restricted = 5;
52
- }
53
-
54
- message RegisterDeviceTokenResponse {}
55
-
56
- message UnregisterDeviceTokenRequest {
57
- string did = 1;
58
- string token = 2;
59
- string app_id = 3;
60
- AppPlatform platform = 4;
61
- }
62
-
63
- message UnregisterDeviceTokenResponse {}
64
-
65
- message SetAgeRestrictedRequest {
66
- string did = 1;
67
- bool age_restricted = 2;
68
- }
69
-
70
- message SetAgeRestrictedResponse {}
71
-
72
- service Service {
73
- rpc Ping(PingRequest) returns (PingResponse);
74
-
75
- // Push notifications.
76
-
77
- rpc PushNotifications(PushNotificationsRequest) returns (PushNotificationsResponse);
78
-
79
- // Device token management.
80
-
81
- rpc RegisterDeviceToken(RegisterDeviceTokenRequest) returns (RegisterDeviceTokenResponse);
82
- rpc UnregisterDeviceToken(UnregisterDeviceTokenRequest) returns (UnregisterDeviceTokenResponse);
83
- rpc SetAgeRestricted(SetAgeRestrictedRequest) returns (SetAgeRestrictedResponse);
84
- }
@@ -1,116 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package rolodex;
4
- option go_package = "./;rolodex";
5
-
6
- import "google/protobuf/timestamp.proto";
7
-
8
- //
9
- // Messages
10
- //
11
-
12
- // Ping
13
- message PingRequest {}
14
-
15
- message PingResponse {}
16
-
17
- // GetSyncStatus
18
- message GetSyncStatusRequest {
19
- string actor = 1;
20
- }
21
-
22
- message SyncStatus {
23
- google.protobuf.Timestamp synced_at = 1;
24
- int32 matches_count = 2;
25
- }
26
-
27
- message GetSyncStatusResponse {
28
- SyncStatus status = 1;
29
- }
30
-
31
- // StartPhoneVerification
32
- message StartPhoneVerificationRequest {
33
- string actor = 1;
34
- string phone = 2;
35
- }
36
-
37
- message StartPhoneVerificationResponse {}
38
-
39
- // VerifyPhone
40
- message VerifyPhoneRequest {
41
- string actor = 1;
42
- string phone = 2;
43
- string verification_code = 3;
44
- }
45
-
46
- message VerifyPhoneResponse {
47
- string token = 1;
48
- }
49
-
50
- // ImportContacts
51
- message ImportContactsRequest {
52
- string actor = 1;
53
- string token = 2;
54
- repeated string contacts = 3;
55
- }
56
-
57
- message ImportContactsMatch {
58
- // To which index of the input contacts this contact corresponds.
59
- int32 input_index = 1;
60
- string subject = 2;
61
- }
62
-
63
- message ImportContactsResponse {
64
- repeated ImportContactsMatch matches = 1;
65
- }
66
-
67
- // GetMatches
68
- message GetMatchesRequest {
69
- string actor = 1;
70
- int32 limit = 2;
71
- string cursor = 3;
72
- }
73
-
74
- message GetMatchesResponse {
75
- repeated string subjects = 1;
76
- string cursor = 2;
77
- }
78
-
79
- // DismissMatch
80
- message DismissMatchRequest {
81
- string actor = 1;
82
- string subject = 2;
83
- }
84
-
85
- message DismissMatchResponse {
86
- int32 matches_count = 1;
87
- }
88
-
89
- // RemoveData
90
- message RemoveDataRequest {
91
- string actor = 1;
92
- }
93
-
94
- message RemoveDataResponse {
95
- int32 contacts_count = 1;
96
- int32 matches_count = 2;
97
- }
98
-
99
- //
100
- // Service
101
- //
102
-
103
- service RolodexService {
104
- rpc Ping(PingRequest) returns (PingResponse);
105
-
106
- rpc GetSyncStatus(GetSyncStatusRequest) returns (GetSyncStatusResponse);
107
-
108
- rpc StartPhoneVerification(StartPhoneVerificationRequest) returns (StartPhoneVerificationResponse);
109
- rpc VerifyPhone(VerifyPhoneRequest) returns (VerifyPhoneResponse);
110
- rpc ImportContacts(ImportContactsRequest) returns (ImportContactsResponse);
111
-
112
- rpc GetMatches(GetMatchesRequest) returns (GetMatchesResponse);
113
- rpc DismissMatch(DismissMatchRequest) returns (DismissMatchResponse);
114
-
115
- rpc RemoveData(RemoveDataRequest) returns (RemoveDataResponse);
116
- }
@@ -1,203 +0,0 @@
1
- import { app } from '../../lexicons/index.js'
2
-
3
- /**
4
- * Age assurance configuration defining rules for various regions.
5
- *
6
- * NOTE: These rules are matched in order, and the first matching rule
7
- * determines the access level granted.
8
- *
9
- * NOTE: all regions MUST have a default rule as the last rule.
10
- */
11
- export const AGE_ASSURANCE_CONFIG = app.bsky.ageassurance.defs.config.$build({
12
- regions: [
13
- {
14
- countryCode: 'GB',
15
- regionCode: undefined,
16
- minAccessAge: 13,
17
- rules: [
18
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
19
- age: 18,
20
- access: 'full',
21
- }),
22
- app.bsky.ageassurance.defs.configRegionRuleIfDeclaredOverAge.$build({
23
- age: 13,
24
- access: 'safe',
25
- }),
26
- app.bsky.ageassurance.defs.configRegionRuleDefault.$build({
27
- access: 'none',
28
- }),
29
- ],
30
- },
31
- {
32
- countryCode: 'AU',
33
- regionCode: undefined,
34
- minAccessAge: 16,
35
- rules: [
36
- app.bsky.ageassurance.defs.configRegionRuleIfAccountNewerThan.$build({
37
- date: '2025-12-10T00:00:00Z',
38
- access: 'none',
39
- }),
40
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
41
- age: 18,
42
- access: 'full',
43
- }),
44
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
45
- age: 16,
46
- access: 'safe',
47
- }),
48
- app.bsky.ageassurance.defs.configRegionRuleIfDeclaredOverAge.$build({
49
- age: 16,
50
- access: 'safe',
51
- }),
52
- app.bsky.ageassurance.defs.configRegionRuleDefault.$build({
53
- access: 'none',
54
- }),
55
- ],
56
- },
57
- {
58
- countryCode: 'US',
59
- regionCode: 'SD',
60
- minAccessAge: 13,
61
- rules: [
62
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
63
- age: 18,
64
- access: 'full',
65
- }),
66
- app.bsky.ageassurance.defs.configRegionRuleIfDeclaredOverAge.$build({
67
- age: 13,
68
- access: 'safe',
69
- }),
70
- app.bsky.ageassurance.defs.configRegionRuleDefault.$build({
71
- access: 'none',
72
- }),
73
- ],
74
- },
75
- {
76
- countryCode: 'US',
77
- regionCode: 'WY',
78
- minAccessAge: 13,
79
- rules: [
80
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
81
- age: 18,
82
- access: 'full',
83
- }),
84
- app.bsky.ageassurance.defs.configRegionRuleIfDeclaredOverAge.$build({
85
- age: 13,
86
- access: 'safe',
87
- }),
88
- app.bsky.ageassurance.defs.configRegionRuleDefault.$build({
89
- access: 'none',
90
- }),
91
- ],
92
- },
93
- {
94
- countryCode: 'US',
95
- regionCode: 'OH',
96
- minAccessAge: 13,
97
- rules: [
98
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
99
- age: 18,
100
- access: 'full',
101
- }),
102
- app.bsky.ageassurance.defs.configRegionRuleIfDeclaredOverAge.$build({
103
- age: 13,
104
- access: 'safe',
105
- }),
106
- app.bsky.ageassurance.defs.configRegionRuleDefault.$build({
107
- access: 'none',
108
- }),
109
- ],
110
- },
111
- {
112
- countryCode: 'US',
113
- regionCode: 'MS',
114
- minAccessAge: 18,
115
- rules: [
116
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
117
- age: 18,
118
- access: 'full',
119
- }),
120
- app.bsky.ageassurance.defs.configRegionRuleDefault.$build({
121
- access: 'none',
122
- }),
123
- ],
124
- },
125
- {
126
- countryCode: 'US',
127
- regionCode: 'VA',
128
- minAccessAge: 16,
129
- rules: [
130
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
131
- age: 16,
132
- access: 'full',
133
- }),
134
- app.bsky.ageassurance.defs.configRegionRuleIfDeclaredOverAge.$build({
135
- age: 16,
136
- access: 'full',
137
- }),
138
- app.bsky.ageassurance.defs.configRegionRuleDefault.$build({
139
- access: 'none',
140
- }),
141
- ],
142
- },
143
- {
144
- countryCode: 'US',
145
- regionCode: 'TN',
146
- minAccessAge: 18,
147
- rules: [
148
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
149
- age: 18,
150
- access: 'full',
151
- }),
152
- app.bsky.ageassurance.defs.configRegionRuleIfDeclaredOverAge.$build({
153
- age: 18,
154
- access: 'full',
155
- }),
156
- app.bsky.ageassurance.defs.configRegionRuleDefault.$build({
157
- access: 'none',
158
- }),
159
- ],
160
- },
161
- {
162
- countryCode: 'US',
163
- regionCode: 'TX',
164
- minAccessAge: 18,
165
- // On-device age verification is permitted here in addition to the
166
- // third-party (KWS) flow, which is always supported and remains as a
167
- // fallback for platforms without the native age API (e.g. web) or
168
- // insufficient device results.
169
- additionalVerificationMethods: ['device'],
170
- rules: [
171
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
172
- age: 18,
173
- access: 'full',
174
- }),
175
- app.bsky.ageassurance.defs.configRegionRuleDefault.$build({
176
- access: 'none',
177
- }),
178
- ],
179
- },
180
- {
181
- countryCode: 'BR',
182
- regionCode: undefined,
183
- minAccessAge: 13,
184
- rules: [
185
- app.bsky.ageassurance.defs.configRegionRuleIfAssuredOverAge.$build({
186
- age: 18,
187
- access: 'full',
188
- }),
189
- app.bsky.ageassurance.defs.configRegionRuleIfDeclaredOverAge.$build({
190
- age: 18,
191
- access: 'full',
192
- }),
193
- app.bsky.ageassurance.defs.configRegionRuleIfDeclaredOverAge.$build({
194
- age: 13,
195
- access: 'safe',
196
- }),
197
- app.bsky.ageassurance.defs.configRegionRuleDefault.$build({
198
- access: 'none',
199
- }),
200
- ],
201
- },
202
- ],
203
- })
@@ -1,34 +0,0 @@
1
- import { Router, raw } from 'express'
2
- import { AppContext } from '../../context.js'
3
- import { webhookAuth } from '../kws/webhook.js'
4
- import { handler as ageVerifiedRedirect } from './redirects/kws-age-verified.js'
5
- import { AppContextWithAA } from './types.js'
6
- import { handler as ageVerifiedWebhook } from './webhooks/kws-age-verified.js'
7
-
8
- export const createRouter = (ctx: AppContext): Router => {
9
- assertAppContextWithAgeAssuranceClient(ctx)
10
-
11
- const router = Router()
12
- router.use(raw({ type: 'application/json' }))
13
- router.post(
14
- '/age-assurance/webhooks/kws-age-verified',
15
- webhookAuth({
16
- secret: ctx.cfg.kws.ageVerifiedWebhookSecret,
17
- }),
18
- ageVerifiedWebhook(ctx),
19
- )
20
- router.get(
21
- '/age-assurance/redirects/kws-age-verified',
22
- ageVerifiedRedirect(ctx),
23
- )
24
-
25
- return router
26
- }
27
-
28
- const assertAppContextWithAgeAssuranceClient: (
29
- ctx: AppContext,
30
- ) => asserts ctx is AppContextWithAA = (ctx: AppContext) => {
31
- if (!ctx.kwsClient) {
32
- throw new Error('Tried to set up KWS router without kwsClient configured.')
33
- }
34
- }
@@ -1,98 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
- import {
3
- parseKWSAgeVerifiedStatus,
4
- serializeKWSAgeVerifiedStatus,
5
- } from './age-verified.js'
6
-
7
- describe('parseKWSAgeVerifiedStatus', () => {
8
- it('parses a minimal status object', () => {
9
- const raw = JSON.stringify({ verified: true, verifiedMinimumAge: 18 })
10
- expect(parseKWSAgeVerifiedStatus(raw)).toEqual({
11
- verified: true,
12
- verifiedMinimumAge: 18,
13
- })
14
- })
15
-
16
- it('parses the optional transactionId and timestamp fields', () => {
17
- const raw = JSON.stringify({
18
- verified: true,
19
- verifiedMinimumAge: 18,
20
- transactionId: 'txn-123',
21
- timestamp: 1750680000,
22
- })
23
- expect(parseKWSAgeVerifiedStatus(raw)).toEqual({
24
- verified: true,
25
- verifiedMinimumAge: 18,
26
- transactionId: 'txn-123',
27
- timestamp: 1750680000,
28
- })
29
- })
30
-
31
- it('tolerates the new timestamp field without transactionId', () => {
32
- const raw = JSON.stringify({
33
- verified: true,
34
- verifiedMinimumAge: 18,
35
- timestamp: 1750680000,
36
- })
37
- expect(parseKWSAgeVerifiedStatus(raw)).toEqual({
38
- verified: true,
39
- verifiedMinimumAge: 18,
40
- timestamp: 1750680000,
41
- })
42
- })
43
-
44
- it('silently strips unknown fields KWS may add', () => {
45
- const raw = JSON.stringify({
46
- verified: true,
47
- verifiedMinimumAge: 18,
48
- timestamp: 1750680000,
49
- errorCode: null,
50
- somethingNew: 'ignored',
51
- })
52
- expect(parseKWSAgeVerifiedStatus(raw)).toEqual({
53
- verified: true,
54
- verifiedMinimumAge: 18,
55
- timestamp: 1750680000,
56
- errorCode: null,
57
- })
58
- })
59
-
60
- it('strips a truly unknown field', () => {
61
- const raw = JSON.stringify({
62
- verified: true,
63
- verifiedMinimumAge: 18,
64
- somethingNew: 'ignored',
65
- })
66
- expect(parseKWSAgeVerifiedStatus(raw)).toEqual({
67
- verified: true,
68
- verifiedMinimumAge: 18,
69
- })
70
- })
71
-
72
- it('throws on malformed JSON', () => {
73
- expect(() => parseKWSAgeVerifiedStatus('not json')).toThrow(
74
- /Invalid KWS age-verified status/,
75
- )
76
- })
77
-
78
- it('throws when a required field is missing', () => {
79
- const raw = JSON.stringify({ verified: true })
80
- expect(() => parseKWSAgeVerifiedStatus(raw)).toThrow(
81
- /Invalid KWS age-verified status/,
82
- )
83
- })
84
- })
85
-
86
- describe('serializeKWSAgeVerifiedStatus', () => {
87
- it('round-trips a status object including timestamp', () => {
88
- const status = {
89
- verified: true,
90
- verifiedMinimumAge: 18,
91
- transactionId: 'txn-123',
92
- timestamp: 1750680000,
93
- }
94
- expect(
95
- parseKWSAgeVerifiedStatus(serializeKWSAgeVerifiedStatus(status)),
96
- ).toEqual(status)
97
- })
98
- })
@@ -1,81 +0,0 @@
1
- import { z } from 'zod'
2
-
3
- /**
4
- * Schema for KWS the `status` object on `age-verified` payloads.
5
- */
6
- export const KWSAgeVerifiedStatusSchema = z.object({
7
- verified: z.boolean(),
8
- verifiedMinimumAge: z.number(),
9
- transactionId: z.string().optional(),
10
- // A code indicating the reason for failure, or null when verification
11
- // succeeded.
12
- errorCode: z.string().nullable().optional(),
13
- // Epoch seconds indicating when KWS generated the payload. Optional so we
14
- // remain compatible with payloads sent before this field was introduced.
15
- timestamp: z.number().optional(),
16
- })
17
-
18
- /**
19
- * The KWS `status` object on `age-verified` payloads.
20
- */
21
- export type KWSAgeVerifiedStatus = z.infer<typeof KWSAgeVerifiedStatusSchema>
22
-
23
- export function serializeKWSAgeVerifiedStatus(
24
- status: KWSAgeVerifiedStatus,
25
- ): string {
26
- return JSON.stringify(KWSAgeVerifiedStatusSchema.parse(status))
27
- }
28
-
29
- /**
30
- * Parse KWS `age-verified` status object.
31
- */
32
- export const parseKWSAgeVerifiedStatus = (
33
- raw: string,
34
- ): KWSAgeVerifiedStatus => {
35
- try {
36
- const value = JSON.parse(raw)
37
- return KWSAgeVerifiedStatusSchema.parse(value)
38
- } catch (err) {
39
- throw new Error(`Invalid KWS age-verified status: ${raw}`, {
40
- cause: err,
41
- })
42
- }
43
- }
44
-
45
- /**
46
- * Schema for KWS `age-verified` webhooks.
47
- *
48
- * Note: we don't use `.strict()` here so that we avoid breaking if KWS adds
49
- * fields, and some fields below are not strictly typed since we're not using
50
- * them.
51
- */
52
- export const KWSAgeVerifiedWebhookSchema = z.object({
53
- name: z.string(),
54
- time: z.string(), // ISO8601 timestamp, but don't validate here
55
- orgId: z.string().uuid().optional(),
56
- productId: z.string().uuid().optional(),
57
- payload: z.object({
58
- email: z.string(), // no need to validate here
59
- externalPayload: z.string(),
60
- status: KWSAgeVerifiedStatusSchema,
61
- }),
62
- })
63
-
64
- /**
65
- * The raw KWS `age-verified` webhook body
66
- */
67
- export type KWSWebhookAgeVerified = z.infer<typeof KWSAgeVerifiedWebhookSchema>
68
-
69
- /**
70
- * Parse KWS `age-verified` webhook body and its external payload.
71
- */
72
- export const parseKWSAgeVerifiedWebhook = (
73
- raw: string,
74
- ): KWSWebhookAgeVerified => {
75
- try {
76
- const value: unknown = JSON.parse(raw)
77
- return KWSAgeVerifiedWebhookSchema.parse(value)
78
- } catch (err) {
79
- throw new Error(`Invalid webhook body: ${raw}`, { cause: err })
80
- }
81
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * Supported languages for KWS Adult Verification. This list comes from KWS's
3
- * Age Verification Developer Guide PDF doc.
4
- */
5
- export const KWS_SUPPORTED_LANGUAGES = new Set([
6
- 'en',
7
- 'ar',
8
- 'zh-Hans',
9
- 'nl',
10
- 'tl',
11
- 'fr',
12
- 'de',
13
- 'id',
14
- 'it',
15
- 'ja',
16
- 'ko',
17
- 'pl',
18
- 'pt-BR',
19
- 'pt',
20
- 'ru',
21
- 'es',
22
- 'th',
23
- 'tr',
24
- 'vi',
25
- ])
26
-
27
- /**
28
- * Regions where our "version 2" using the `age-verified` KWS flow is
29
- * available. In these regions, we'll use a different KWS flow from the
30
- * existing `adult-verified` flow, pass along a different external payload, and
31
- * handle webhooks/redirects differently in the appview.
32
- */
33
- export const KWS_V2_COUNTRIES = new Set(['AU'])