@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.
- package/CHANGELOG.md +50 -0
- package/dist/api/age-assurance/const.js +19 -19
- package/dist/api/age-assurance/const.js.map +1 -1
- package/dist/kws.d.ts +8 -0
- package/dist/kws.d.ts.map +1 -1
- package/dist/kws.js +53 -4
- package/dist/kws.js.map +1 -1
- package/dist/lexicons/app/bsky/actor/defs.defs.d.ts +6 -0
- package/dist/lexicons/app/bsky/actor/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/actor/defs.defs.js +1 -0
- package/dist/lexicons/app/bsky/actor/defs.defs.js.map +1 -1
- package/package.json +28 -23
- package/bin/migration-create.ts +0 -46
- package/buf.gen.yaml +0 -12
- package/proto/bsky.proto +0 -1907
- package/proto/courier.proto +0 -84
- package/proto/rolodex.proto +0 -116
- package/src/api/age-assurance/const.ts +0 -203
- package/src/api/age-assurance/index.ts +0 -34
- package/src/api/age-assurance/kws/age-verified.test.ts +0 -98
- package/src/api/age-assurance/kws/age-verified.ts +0 -81
- package/src/api/age-assurance/kws/const.ts +0 -33
- package/src/api/age-assurance/kws/external-payload.test.ts +0 -72
- package/src/api/age-assurance/kws/external-payload.ts +0 -149
- package/src/api/age-assurance/redirects/kws-age-verified.ts +0 -107
- package/src/api/age-assurance/stash.ts +0 -23
- package/src/api/age-assurance/types.ts +0 -10
- package/src/api/age-assurance/util.ts +0 -68
- package/src/api/age-assurance/webhooks/kws-age-verified.ts +0 -75
- package/src/api/app/bsky/actor/getProfile.ts +0 -106
- package/src/api/app/bsky/actor/getProfiles.ts +0 -99
- package/src/api/app/bsky/actor/getSuggestions.ts +0 -163
- package/src/api/app/bsky/actor/searchActors.ts +0 -171
- package/src/api/app/bsky/actor/searchActorsTypeahead.ts +0 -164
- package/src/api/app/bsky/ageassurance/begin.ts +0 -175
- package/src/api/app/bsky/ageassurance/getConfig.ts +0 -16
- package/src/api/app/bsky/ageassurance/getState.ts +0 -58
- package/src/api/app/bsky/bookmark/createBookmark.ts +0 -39
- package/src/api/app/bsky/bookmark/deleteBookmark.ts +0 -32
- package/src/api/app/bsky/bookmark/getBookmarks.ts +0 -97
- package/src/api/app/bsky/bookmark/util.ts +0 -13
- package/src/api/app/bsky/contact/dismissMatch.ts +0 -26
- package/src/api/app/bsky/contact/getMatches.ts +0 -111
- package/src/api/app/bsky/contact/getSyncStatus.ts +0 -38
- package/src/api/app/bsky/contact/importContacts.ts +0 -119
- package/src/api/app/bsky/contact/removeData.ts +0 -25
- package/src/api/app/bsky/contact/sendNotification.ts +0 -33
- package/src/api/app/bsky/contact/startPhoneVerification.ts +0 -26
- package/src/api/app/bsky/contact/util.ts +0 -92
- package/src/api/app/bsky/contact/verifyPhone.ts +0 -29
- package/src/api/app/bsky/draft/createDraft.ts +0 -45
- package/src/api/app/bsky/draft/deleteDraft.ts +0 -20
- package/src/api/app/bsky/draft/getDrafts.ts +0 -44
- package/src/api/app/bsky/draft/updateDraft.ts +0 -26
- package/src/api/app/bsky/embed/getEmbedExternalView.ts +0 -154
- package/src/api/app/bsky/feed/getActorFeeds.ts +0 -101
- package/src/api/app/bsky/feed/getActorLikes.ts +0 -128
- package/src/api/app/bsky/feed/getAuthorFeed.ts +0 -279
- package/src/api/app/bsky/feed/getFeed.ts +0 -282
- package/src/api/app/bsky/feed/getFeedGenerator.ts +0 -68
- package/src/api/app/bsky/feed/getFeedGenerators.ts +0 -86
- package/src/api/app/bsky/feed/getLikes.ts +0 -151
- package/src/api/app/bsky/feed/getListFeed.ts +0 -147
- package/src/api/app/bsky/feed/getPostThread.ts +0 -156
- package/src/api/app/bsky/feed/getPosts.ts +0 -100
- package/src/api/app/bsky/feed/getQuotes.ts +0 -122
- package/src/api/app/bsky/feed/getRepostedBy.ts +0 -121
- package/src/api/app/bsky/feed/getSuggestedFeeds.ts +0 -39
- package/src/api/app/bsky/feed/getTimeline.ts +0 -127
- package/src/api/app/bsky/feed/searchPosts.ts +0 -274
- package/src/api/app/bsky/feed/searchPostsV2.ts +0 -243
- package/src/api/app/bsky/graph/getActorStarterPacks.ts +0 -103
- package/src/api/app/bsky/graph/getBlocks.ts +0 -94
- package/src/api/app/bsky/graph/getFollowers.ts +0 -153
- package/src/api/app/bsky/graph/getFollows.ts +0 -151
- package/src/api/app/bsky/graph/getKnownFollowers.ts +0 -123
- package/src/api/app/bsky/graph/getList.ts +0 -152
- package/src/api/app/bsky/graph/getListBlocks.ts +0 -87
- package/src/api/app/bsky/graph/getListMutes.ts +0 -87
- package/src/api/app/bsky/graph/getLists.ts +0 -125
- package/src/api/app/bsky/graph/getListsWithMembership.ts +0 -146
- package/src/api/app/bsky/graph/getMutes.ts +0 -87
- package/src/api/app/bsky/graph/getRelationships.ts +0 -58
- package/src/api/app/bsky/graph/getStarterPack.ts +0 -82
- package/src/api/app/bsky/graph/getStarterPacks.ts +0 -86
- package/src/api/app/bsky/graph/getStarterPacksWithMembership.ts +0 -136
- package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +0 -171
- package/src/api/app/bsky/graph/muteActor.ts +0 -24
- package/src/api/app/bsky/graph/muteActorList.ts +0 -19
- package/src/api/app/bsky/graph/muteThread.ts +0 -19
- package/src/api/app/bsky/graph/searchStarterPacks.ts +0 -169
- package/src/api/app/bsky/graph/unmuteActor.ts +0 -21
- package/src/api/app/bsky/graph/unmuteActorList.ts +0 -19
- package/src/api/app/bsky/graph/unmuteThread.ts +0 -19
- package/src/api/app/bsky/labeler/getServices.ts +0 -41
- package/src/api/app/bsky/notification/getPreferences.ts +0 -49
- package/src/api/app/bsky/notification/getUnreadCount.ts +0 -83
- package/src/api/app/bsky/notification/listActivitySubscriptions.ts +0 -116
- package/src/api/app/bsky/notification/listNotifications.ts +0 -272
- package/src/api/app/bsky/notification/putActivitySubscription.ts +0 -69
- package/src/api/app/bsky/notification/putPreferences.ts +0 -17
- package/src/api/app/bsky/notification/putPreferencesV2.ts +0 -64
- package/src/api/app/bsky/notification/registerPush.ts +0 -40
- package/src/api/app/bsky/notification/unregisterPush.ts +0 -39
- package/src/api/app/bsky/notification/updateSeen.ts +0 -52
- package/src/api/app/bsky/notification/util.ts +0 -134
- package/src/api/app/bsky/unspecced/getAgeAssuranceState.ts +0 -48
- package/src/api/app/bsky/unspecced/getConfig.ts +0 -20
- package/src/api/app/bsky/unspecced/getOnboardingSuggestedStarterPacks.ts +0 -162
- package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +0 -91
- package/src/api/app/bsky/unspecced/getPostThreadOtherV2.ts +0 -126
- package/src/api/app/bsky/unspecced/getPostThreadV2.ts +0 -148
- package/src/api/app/bsky/unspecced/getSuggestedFeeds.ts +0 -100
- package/src/api/app/bsky/unspecced/getSuggestedOnboardingUsers.ts +0 -143
- package/src/api/app/bsky/unspecced/getSuggestedStarterPacks.ts +0 -165
- package/src/api/app/bsky/unspecced/getSuggestedUsers.ts +0 -183
- package/src/api/app/bsky/unspecced/getSuggestedUsersForDiscover.ts +0 -175
- package/src/api/app/bsky/unspecced/getSuggestedUsersForExplore.ts +0 -178
- package/src/api/app/bsky/unspecced/getSuggestedUsersForSeeMore.ts +0 -178
- package/src/api/app/bsky/unspecced/getTaggedSuggestions.ts +0 -27
- package/src/api/app/bsky/unspecced/getTrendingTopics.ts +0 -96
- package/src/api/app/bsky/unspecced/getTrends.ts +0 -162
- package/src/api/app/bsky/unspecced/initAgeAssurance.ts +0 -150
- package/src/api/blob-dispatcher.ts +0 -41
- package/src/api/blob-resolver.ts +0 -401
- package/src/api/com/atproto/admin/getAccountInfos.ts +0 -49
- package/src/api/com/atproto/admin/getSubjectStatus.ts +0 -79
- package/src/api/com/atproto/admin/updateSubjectStatus.ts +0 -80
- package/src/api/com/atproto/identity/resolveHandle.ts +0 -19
- package/src/api/com/atproto/label/queryLabels.ts +0 -42
- package/src/api/com/atproto/repo/getRecord.ts +0 -44
- package/src/api/com/atproto/temp/fetchLabels.ts +0 -9
- package/src/api/external.ts +0 -15
- package/src/api/health.ts +0 -47
- package/src/api/index.ts +0 -216
- package/src/api/internal/bsky/actor/getProfiles.ts +0 -87
- package/src/api/kws/api.ts +0 -113
- package/src/api/kws/index.ts +0 -29
- package/src/api/kws/types.ts +0 -78
- package/src/api/kws/util.test.ts +0 -50
- package/src/api/kws/util.ts +0 -109
- package/src/api/kws/webhook.ts +0 -134
- package/src/api/sitemap.ts +0 -76
- package/src/api/util.ts +0 -45
- package/src/api/well-known.ts +0 -44
- package/src/auth-verifier.ts +0 -522
- package/src/bsync.ts +0 -41
- package/src/cache/read-through.ts +0 -157
- package/src/config.ts +0 -719
- package/src/context.ts +0 -143
- package/src/courier.ts +0 -41
- package/src/data-plane/client/hosts.ts +0 -103
- package/src/data-plane/client/index.ts +0 -125
- package/src/data-plane/client/util.test.ts +0 -29
- package/src/data-plane/client/util.ts +0 -74
- package/src/data-plane/index.ts +0 -2
- package/src/data-plane/server/background.ts +0 -66
- package/src/data-plane/server/bsync-subscription.ts +0 -590
- package/src/data-plane/server/db/database-schema.ts +0 -90
- package/src/data-plane/server/db/db.ts +0 -204
- package/src/data-plane/server/db/index.ts +0 -2
- package/src/data-plane/server/db/migrations/20230309T045948368Z-init.ts +0 -305
- package/src/data-plane/server/db/migrations/20230408T152211201Z-notification-init.ts +0 -25
- package/src/data-plane/server/db/migrations/20230417T210628672Z-moderation-init.ts +0 -127
- package/src/data-plane/server/db/migrations/20230420T211446071Z-did-cache.ts +0 -14
- package/src/data-plane/server/db/migrations/20230427T194702079Z-notif-record-index.ts +0 -14
- package/src/data-plane/server/db/migrations/20230605T144730094Z-post-profile-aggs.ts +0 -23
- package/src/data-plane/server/db/migrations/20230607T211442112Z-feed-generator-init.ts +0 -34
- package/src/data-plane/server/db/migrations/20230608T155101190Z-algo-whats-hot-view.ts +0 -85
- package/src/data-plane/server/db/migrations/20230608T201813132Z-mute-lists.ts +0 -78
- package/src/data-plane/server/db/migrations/20230608T205147239Z-mutes.ts +0 -15
- package/src/data-plane/server/db/migrations/20230609T153623961Z-blocks.ts +0 -33
- package/src/data-plane/server/db/migrations/20230609T232122649Z-actor-deletion-indexes.ts +0 -27
- package/src/data-plane/server/db/migrations/20230610T203555962Z-suggested-follows.ts +0 -13
- package/src/data-plane/server/db/migrations/20230611T215300060Z-actor-state.ts +0 -13
- package/src/data-plane/server/db/migrations/20230620T161134972Z-post-langs.ts +0 -9
- package/src/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.ts +0 -15
- package/src/data-plane/server/db/migrations/20230629T220835893Z-remove-post-hierarchy.ts +0 -32
- package/src/data-plane/server/db/migrations/20230703T045536691Z-feed-and-label-indices.ts +0 -31
- package/src/data-plane/server/db/migrations/20230720T164800037Z-posts-cursor-idx.ts +0 -19
- package/src/data-plane/server/db/migrations/20230807T035309811Z-feed-item-delete-invite-for-user-idx.ts +0 -14
- package/src/data-plane/server/db/migrations/20230808T172902639Z-repo-rev.ts +0 -12
- package/src/data-plane/server/db/migrations/20230810T203349843Z-action-duration.ts +0 -23
- package/src/data-plane/server/db/migrations/20230817T195936007Z-native-notifications.ts +0 -16
- package/src/data-plane/server/db/migrations/20230830T205507322Z-suggested-feeds.ts +0 -13
- package/src/data-plane/server/db/migrations/20230904T211011773Z-block-lists.ts +0 -24
- package/src/data-plane/server/db/migrations/20230906T222220386Z-thread-gating.ts +0 -27
- package/src/data-plane/server/db/migrations/20230920T213858047Z-add-tags-to-post.ts +0 -9
- package/src/data-plane/server/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +0 -40
- package/src/data-plane/server/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +0 -123
- package/src/data-plane/server/db/migrations/20231220T225126090Z-blob-takedowns.ts +0 -66
- package/src/data-plane/server/db/migrations/20240124T023719200Z-tagged-suggestions.ts +0 -15
- package/src/data-plane/server/db/migrations/20240226T225725627Z-labelers.ts +0 -27
- package/src/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.ts +0 -12
- package/src/data-plane/server/db/migrations/20240606T171229898Z-thread-mutes.ts +0 -15
- package/src/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.ts +0 -45
- package/src/data-plane/server/db/migrations/20240719T203853939Z-priority-notifs.ts +0 -25
- package/src/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.ts +0 -12
- package/src/data-plane/server/db/migrations/20240723T220703655Z-quotes.ts +0 -28
- package/src/data-plane/server/db/migrations/20240801T193939827Z-post-gate.ts +0 -17
- package/src/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.ts +0 -25
- package/src/data-plane/server/db/migrations/20240829T211238293Z-simplify-actor-sync.ts +0 -23
- package/src/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.ts +0 -17
- package/src/data-plane/server/db/migrations/20241114T153108102Z-add-starter-packs-name.ts +0 -19
- package/src/data-plane/server/db/migrations/20250116T222618297Z-post-embed-video.ts +0 -17
- package/src/data-plane/server/db/migrations/20250207T174822012Z-add-label-exp.ts +0 -9
- package/src/data-plane/server/db/migrations/20250404T163421487Z-verifications.ts +0 -39
- package/src/data-plane/server/db/migrations/20250526T023712742Z-like-repost-via.ts +0 -17
- package/src/data-plane/server/db/migrations/20250528T221913281Z-add-record-tags.ts +0 -9
- package/src/data-plane/server/db/migrations/20250602T190357447Z-add-private-data.ts +0 -22
- package/src/data-plane/server/db/migrations/20250611T140649895Z-add-activity-subscription.ts +0 -22
- package/src/data-plane/server/db/migrations/20250627T025331240Z-add-actor-age-assurance-columns.ts +0 -22
- package/src/data-plane/server/db/migrations/20250812T183735692Z-add-bookmarks.ts +0 -23
- package/src/data-plane/server/db/migrations/20250813T174955711Z-add-post-agg-bookmarks.ts +0 -12
- package/src/data-plane/server/db/migrations/20251120T004738098Z-update-actor-age-assurance-v2.ts +0 -28
- package/src/data-plane/server/db/migrations/20260112T133951271Z-add-drafts.ts +0 -24
- package/src/data-plane/server/db/migrations/20260604T224952774Z-post-embed-gallery-image.ts +0 -19
- package/src/data-plane/server/db/migrations/index.ts +0 -60
- package/src/data-plane/server/db/migrations/provider.ts +0 -26
- package/src/data-plane/server/db/pagination.ts +0 -341
- package/src/data-plane/server/db/tables/activity-subscription.ts +0 -12
- package/src/data-plane/server/db/tables/actor-block.ts +0 -14
- package/src/data-plane/server/db/tables/actor-state.ts +0 -10
- package/src/data-plane/server/db/tables/actor-sync.ts +0 -9
- package/src/data-plane/server/db/tables/actor.ts +0 -19
- package/src/data-plane/server/db/tables/algo.ts +0 -11
- package/src/data-plane/server/db/tables/blob-takedown.ts +0 -9
- package/src/data-plane/server/db/tables/bookmark.ts +0 -11
- package/src/data-plane/server/db/tables/did-cache.ts +0 -13
- package/src/data-plane/server/db/tables/draft.ts +0 -11
- package/src/data-plane/server/db/tables/duplicate-record.ts +0 -12
- package/src/data-plane/server/db/tables/feed-generator.ts +0 -21
- package/src/data-plane/server/db/tables/feed-item.ts +0 -12
- package/src/data-plane/server/db/tables/follow.ts +0 -15
- package/src/data-plane/server/db/tables/label.ts +0 -13
- package/src/data-plane/server/db/tables/labeler.ts +0 -16
- package/src/data-plane/server/db/tables/like.ts +0 -18
- package/src/data-plane/server/db/tables/list-block.ts +0 -15
- package/src/data-plane/server/db/tables/list-item.ts +0 -16
- package/src/data-plane/server/db/tables/list-mute.ts +0 -9
- package/src/data-plane/server/db/tables/list.ts +0 -19
- package/src/data-plane/server/db/tables/mute.ts +0 -9
- package/src/data-plane/server/db/tables/notification-push-token.ts +0 -10
- package/src/data-plane/server/db/tables/notification.ts +0 -16
- package/src/data-plane/server/db/tables/post-agg.ts +0 -16
- package/src/data-plane/server/db/tables/post-embed.ts +0 -47
- package/src/data-plane/server/db/tables/post-gate.ts +0 -12
- package/src/data-plane/server/db/tables/post.ts +0 -28
- package/src/data-plane/server/db/tables/private-data.ts +0 -13
- package/src/data-plane/server/db/tables/profile-agg.ts +0 -14
- package/src/data-plane/server/db/tables/profile.ts +0 -17
- package/src/data-plane/server/db/tables/quote.ts +0 -15
- package/src/data-plane/server/db/tables/record.ts +0 -15
- package/src/data-plane/server/db/tables/repost.ts +0 -18
- package/src/data-plane/server/db/tables/starter-pack.ts +0 -17
- package/src/data-plane/server/db/tables/subscription.ts +0 -9
- package/src/data-plane/server/db/tables/suggested-feed.ts +0 -10
- package/src/data-plane/server/db/tables/suggested-follow.ts +0 -10
- package/src/data-plane/server/db/tables/tagged-suggestion.ts +0 -11
- package/src/data-plane/server/db/tables/thread-gate.ts +0 -12
- package/src/data-plane/server/db/tables/thread-mute.ts +0 -9
- package/src/data-plane/server/db/tables/verification.ts +0 -20
- package/src/data-plane/server/db/tables/view-param.ts +0 -12
- package/src/data-plane/server/db/types.ts +0 -12
- package/src/data-plane/server/db/util.ts +0 -67
- package/src/data-plane/server/index.ts +0 -44
- package/src/data-plane/server/indexing/index.ts +0 -458
- package/src/data-plane/server/indexing/plugins/block.ts +0 -84
- package/src/data-plane/server/indexing/plugins/chat-declaration.ts +0 -60
- package/src/data-plane/server/indexing/plugins/feed-generator.ts +0 -80
- package/src/data-plane/server/indexing/plugins/follow.ts +0 -132
- package/src/data-plane/server/indexing/plugins/germ-declaration.ts +0 -57
- package/src/data-plane/server/indexing/plugins/labeler.ts +0 -74
- package/src/data-plane/server/indexing/plugins/like.ts +0 -151
- package/src/data-plane/server/indexing/plugins/list-block.ts +0 -84
- package/src/data-plane/server/indexing/plugins/list-item.ts +0 -92
- package/src/data-plane/server/indexing/plugins/list.ts +0 -80
- package/src/data-plane/server/indexing/plugins/notif-declaration.ts +0 -57
- package/src/data-plane/server/indexing/plugins/post-gate.ts +0 -101
- package/src/data-plane/server/indexing/plugins/post.ts +0 -675
- package/src/data-plane/server/indexing/plugins/profile.ts +0 -90
- package/src/data-plane/server/indexing/plugins/repost.ts +0 -176
- package/src/data-plane/server/indexing/plugins/starter-pack.ts +0 -74
- package/src/data-plane/server/indexing/plugins/status.ts +0 -57
- package/src/data-plane/server/indexing/plugins/thread-gate.ts +0 -101
- package/src/data-plane/server/indexing/plugins/verification.ts +0 -113
- package/src/data-plane/server/indexing/processor.ts +0 -292
- package/src/data-plane/server/routes/activity-subscription.ts +0 -84
- package/src/data-plane/server/routes/blocks.ts +0 -127
- package/src/data-plane/server/routes/bookmarks.ts +0 -83
- package/src/data-plane/server/routes/drafts.ts +0 -37
- package/src/data-plane/server/routes/feed-gens.ts +0 -89
- package/src/data-plane/server/routes/feeds.ts +0 -176
- package/src/data-plane/server/routes/follows.ts +0 -141
- package/src/data-plane/server/routes/identity.ts +0 -59
- package/src/data-plane/server/routes/index.ts +0 -67
- package/src/data-plane/server/routes/interactions.ts +0 -120
- package/src/data-plane/server/routes/labels.ts +0 -55
- package/src/data-plane/server/routes/likes.ts +0 -92
- package/src/data-plane/server/routes/lists.ts +0 -88
- package/src/data-plane/server/routes/moderation.ts +0 -102
- package/src/data-plane/server/routes/mutes.ts +0 -195
- package/src/data-plane/server/routes/notifs.ts +0 -239
- package/src/data-plane/server/routes/profile.ts +0 -220
- package/src/data-plane/server/routes/quotes.ts +0 -32
- package/src/data-plane/server/routes/records.ts +0 -119
- package/src/data-plane/server/routes/relationships.ts +0 -174
- package/src/data-plane/server/routes/reposts.ts +0 -76
- package/src/data-plane/server/routes/search.ts +0 -181
- package/src/data-plane/server/routes/site-standard.ts +0 -12
- package/src/data-plane/server/routes/sitemap.ts +0 -43
- package/src/data-plane/server/routes/starter-packs.ts +0 -32
- package/src/data-plane/server/routes/suggestions.ts +0 -175
- package/src/data-plane/server/routes/sync.ts +0 -16
- package/src/data-plane/server/routes/threads.ts +0 -33
- package/src/data-plane/server/subscription.ts +0 -152
- package/src/data-plane/server/util.ts +0 -202
- package/src/error.ts +0 -12
- package/src/etcd.ts +0 -90
- package/src/feature-gates/README.md +0 -83
- package/src/feature-gates/gates.ts +0 -25
- package/src/feature-gates/index.ts +0 -235
- package/src/feature-gates/metrics.test.ts +0 -196
- package/src/feature-gates/metrics.ts +0 -107
- package/src/feature-gates/types.ts +0 -62
- package/src/feature-gates/utils.test.ts +0 -66
- package/src/feature-gates/utils.ts +0 -135
- package/src/hydration/actor.ts +0 -578
- package/src/hydration/external.test.ts +0 -281
- package/src/hydration/external.ts +0 -268
- package/src/hydration/feed.ts +0 -455
- package/src/hydration/graph.ts +0 -354
- package/src/hydration/hydrator.ts +0 -1835
- package/src/hydration/label.ts +0 -207
- package/src/hydration/util.ts +0 -199
- package/src/image/index.ts +0 -2
- package/src/image/invalidator.ts +0 -33
- package/src/image/logger.ts +0 -6
- package/src/image/server.ts +0 -228
- package/src/image/sharp.ts +0 -89
- package/src/image/uri.ts +0 -114
- package/src/image/util.ts +0 -41
- package/src/index.ts +0 -312
- package/src/kws.ts +0 -197
- package/src/logger.ts +0 -40
- package/src/pipeline.ts +0 -60
- package/src/redis.ts +0 -205
- package/src/rolodex.ts +0 -42
- package/src/stash.ts +0 -76
- package/src/util/debug.ts +0 -10
- package/src/util/http.ts +0 -42
- package/src/util/retry.ts +0 -10
- package/src/util/standard-site.test.ts +0 -423
- package/src/util/standard-site.ts +0 -196
- package/src/util/uris.ts +0 -38
- package/src/util.ts +0 -48
- package/src/views/index.ts +0 -2783
- package/src/views/threads-v2.ts +0 -510
- package/src/views/types.ts +0 -193
- package/src/views/util.ts +0 -114
- package/test.env +0 -2
- package/tests/__snapshots__/feed-generation.test.ts.snap +0 -2510
- package/tests/_util.ts +0 -292
- package/tests/admin/admin-auth.test.ts +0 -190
- package/tests/admin/moderation.test.ts +0 -222
- package/tests/auth.test.ts +0 -90
- package/tests/blob-resolver.test.ts +0 -125
- package/tests/data-plane/__snapshots__/indexing.test.ts.snap +0 -887
- package/tests/data-plane/db.test.ts +0 -189
- package/tests/data-plane/duplicate-records.test.ts +0 -156
- package/tests/data-plane/handle-invalidation.test.ts +0 -153
- package/tests/data-plane/indexing.test.ts +0 -827
- package/tests/data-plane/subscription.test.ts +0 -128
- package/tests/data-plane/thread-mutes.test.ts +0 -175
- package/tests/entryway-auth.test.ts +0 -177
- package/tests/etcd.test.ts +0 -302
- package/tests/feed-generation.test.ts +0 -965
- package/tests/hydration/util.test.ts +0 -119
- package/tests/image/server.test.ts +0 -97
- package/tests/image/sharp.test.ts +0 -199
- package/tests/image/uri.test.ts +0 -106
- package/tests/label-hydration.test.ts +0 -245
- package/tests/postgates.test.ts +0 -182
- package/tests/query-labels.test.ts +0 -85
- package/tests/redis-cache.test.ts +0 -230
- package/tests/seed/feed-hidden-replies.ts +0 -63
- package/tests/seed/get-suggested-starter-packs.ts +0 -64
- package/tests/seed/get-trends.ts +0 -71
- package/tests/seed/known-followers.ts +0 -111
- package/tests/seed/postgates.ts +0 -57
- package/tests/server.test.ts +0 -115
- package/tests/sitemap.test.ts +0 -75
- package/tests/stash.test.ts +0 -180
- package/tests/utils.test.ts +0 -36
- package/tests/views/__snapshots__/actor-search.test.ts.snap +0 -155
- package/tests/views/__snapshots__/author-feed.test.ts.snap +0 -6301
- package/tests/views/__snapshots__/block-lists.test.ts.snap +0 -690
- package/tests/views/__snapshots__/blocks.test.ts.snap +0 -462
- package/tests/views/__snapshots__/bookmarks.test.ts.snap +0 -379
- package/tests/views/__snapshots__/follows.test.ts.snap +0 -798
- package/tests/views/__snapshots__/labeler-service.test.ts.snap +0 -233
- package/tests/views/__snapshots__/likes.test.ts.snap +0 -124
- package/tests/views/__snapshots__/list-feed.test.ts.snap +0 -883
- package/tests/views/__snapshots__/lists.test.ts.snap +0 -650
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +0 -705
- package/tests/views/__snapshots__/mutes.test.ts.snap +0 -353
- package/tests/views/__snapshots__/notifications.test.ts.snap +0 -3074
- package/tests/views/__snapshots__/posts.test.ts.snap +0 -1019
- package/tests/views/__snapshots__/profile.test.ts.snap +0 -811
- package/tests/views/__snapshots__/quotes.test.ts.snap +0 -445
- package/tests/views/__snapshots__/reposts.test.ts.snap +0 -112
- package/tests/views/__snapshots__/starter-packs.test.ts.snap +0 -836
- package/tests/views/__snapshots__/thread-v2.test.ts.snap +0 -1298
- package/tests/views/__snapshots__/thread.test.ts.snap +0 -2051
- package/tests/views/__snapshots__/threadgating.test.ts.snap +0 -189
- package/tests/views/__snapshots__/timeline.test.ts.snap +0 -7252
- package/tests/views/account-deactivation.test.ts +0 -81
- package/tests/views/actor-likes.test.ts +0 -138
- package/tests/views/actor-search.test.ts +0 -261
- package/tests/views/age-assurance-v2.test.ts +0 -823
- package/tests/views/age-assurance.test.ts +0 -479
- package/tests/views/author-feed.test.ts +0 -694
- package/tests/views/block-lists.test.ts +0 -661
- package/tests/views/blocks.test.ts +0 -889
- package/tests/views/bookmarks.test.ts +0 -345
- package/tests/views/drafts.test.ts +0 -430
- package/tests/views/feed-hidden-replies.test.ts +0 -243
- package/tests/views/feed-view-post.test.ts +0 -501
- package/tests/views/follows.test.ts +0 -372
- package/tests/views/get-config.test.ts +0 -64
- package/tests/views/get-suggested-onboarding-users.test.ts +0 -193
- package/tests/views/get-suggested-starter-packs.test.ts +0 -137
- package/tests/views/get-trends.test.ts +0 -141
- package/tests/views/internal-actor.test.ts +0 -127
- package/tests/views/known-followers.test.ts +0 -193
- package/tests/views/labeler-service.test.ts +0 -242
- package/tests/views/labels-needs-review.test.ts +0 -316
- package/tests/views/labels-takedown.test.ts +0 -247
- package/tests/views/likes.test.ts +0 -192
- package/tests/views/list-feed.test.ts +0 -195
- package/tests/views/lists.test.ts +0 -412
- package/tests/views/mute-lists.test.ts +0 -509
- package/tests/views/mutes.test.ts +0 -308
- package/tests/views/notifications.test.ts +0 -1581
- package/tests/views/post-search.test.ts +0 -281
- package/tests/views/posts-debug.test.ts +0 -79
- package/tests/views/posts.test.ts +0 -427
- package/tests/views/profile-debug.test.ts +0 -75
- package/tests/views/profile.test.ts +0 -795
- package/tests/views/quotes.test.ts +0 -133
- package/tests/views/reposts.test.ts +0 -112
- package/tests/views/starter-packs.test.ts +0 -395
- package/tests/views/suggestions.test.ts +0 -145
- package/tests/views/thread-v2.test.ts +0 -2005
- package/tests/views/thread.test.ts +0 -637
- package/tests/views/threadgating.test.ts +0 -843
- package/tests/views/timeline.test.ts +0 -328
- package/tests/views/verification.test.ts +0 -296
- package/tsconfig.build.json +0 -10
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.json +0 -7
- package/tsconfig.tests.json +0 -8
- package/vitest.config.ts +0 -10
package/src/kws.ts
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
import { KwsExternalPayload } from './api/kws/types.js'
|
|
3
|
-
import { serializeExternalPayload } from './api/kws/util.js'
|
|
4
|
-
import { buildBasicAuth } from './auth-verifier.js'
|
|
5
|
-
import { KwsConfig } from './config.js'
|
|
6
|
-
import { httpLogger as log } from './logger.js'
|
|
7
|
-
|
|
8
|
-
export const createKwsClient = (cfg: KwsConfig): KwsClient => {
|
|
9
|
-
return new KwsClient(cfg)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Not `.strict()` to avoid breaking if KWS adds fields.
|
|
13
|
-
const authResponseSchema = z.object({
|
|
14
|
-
access_token: z.string(),
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
const EXTERNAL_PAYLOAD_CHAR_LIMIT = 200
|
|
18
|
-
/**
|
|
19
|
-
* Thrown when the provided external payload exceeds KWS's character limit.
|
|
20
|
-
* This is most commonly caused by DIDs that are too long, such as for
|
|
21
|
-
* `did:web` DIDs. But it's very rare, and the client has special handling for
|
|
22
|
-
* this case.
|
|
23
|
-
*/
|
|
24
|
-
export class KwsExternalPayloadError extends Error {}
|
|
25
|
-
|
|
26
|
-
export type KWSSendEmailRequestCommon = {
|
|
27
|
-
email: string
|
|
28
|
-
location: string
|
|
29
|
-
language: string
|
|
30
|
-
externalPayload: string
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type KWSSendEmailRequest =
|
|
34
|
-
| (KWSSendEmailRequestCommon & {
|
|
35
|
-
userContext: 'adult'
|
|
36
|
-
})
|
|
37
|
-
| (KWSSendEmailRequestCommon & {
|
|
38
|
-
userContext: 'age'
|
|
39
|
-
minimumAge: number
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
export class KwsClient {
|
|
43
|
-
constructor(public cfg: KwsConfig) {}
|
|
44
|
-
|
|
45
|
-
private async auth() {
|
|
46
|
-
try {
|
|
47
|
-
const res = await fetch(
|
|
48
|
-
`${this.cfg.authOrigin}/auth/realms/kws/protocol/openid-connect/token`,
|
|
49
|
-
{
|
|
50
|
-
method: 'POST',
|
|
51
|
-
headers: {
|
|
52
|
-
Accept: 'application/json',
|
|
53
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
54
|
-
Authorization: buildBasicAuth(this.cfg.clientId, this.cfg.apiKey),
|
|
55
|
-
},
|
|
56
|
-
body: new URLSearchParams({
|
|
57
|
-
grant_type: 'client_credentials',
|
|
58
|
-
scope: 'verification',
|
|
59
|
-
}),
|
|
60
|
-
},
|
|
61
|
-
)
|
|
62
|
-
if (!res.ok) {
|
|
63
|
-
const errorText = await res.text()
|
|
64
|
-
throw new Error(
|
|
65
|
-
`Failed to fetch age assurance access token: status: ${res.status}, statusText: ${res.statusText}, errorText: ${errorText}`,
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const auth = await res.json()
|
|
70
|
-
const authResponse = authResponseSchema.parse(auth)
|
|
71
|
-
return authResponse.access_token
|
|
72
|
-
} catch (err) {
|
|
73
|
-
log.error({ err }, 'Failed to authenticate with KWS')
|
|
74
|
-
throw err
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private async fetchWithAuth(
|
|
79
|
-
url: string,
|
|
80
|
-
init: RequestInit,
|
|
81
|
-
): Promise<Response> {
|
|
82
|
-
const accessToken = await this.auth()
|
|
83
|
-
|
|
84
|
-
return fetch(url, {
|
|
85
|
-
...init,
|
|
86
|
-
headers: {
|
|
87
|
-
...(init.headers ?? {}),
|
|
88
|
-
Authorization: `Bearer ${accessToken}`,
|
|
89
|
-
},
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @deprecated Use `sendAdultVerifiedFlowEmail` or `sendAgeVerifiedFlowEmail` instead.
|
|
95
|
-
*/
|
|
96
|
-
async sendEmail({
|
|
97
|
-
countryCode,
|
|
98
|
-
email,
|
|
99
|
-
externalPayload,
|
|
100
|
-
language,
|
|
101
|
-
}: {
|
|
102
|
-
countryCode: string
|
|
103
|
-
email: string
|
|
104
|
-
externalPayload: KwsExternalPayload
|
|
105
|
-
language: string
|
|
106
|
-
}) {
|
|
107
|
-
const serializedExternalPayload = serializeExternalPayload(externalPayload)
|
|
108
|
-
if (serializedExternalPayload.length > EXTERNAL_PAYLOAD_CHAR_LIMIT) {
|
|
109
|
-
throw new KwsExternalPayloadError()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const res = await this.fetchWithAuth(
|
|
113
|
-
`${this.cfg.apiOrigin}/v1/verifications/send-email`,
|
|
114
|
-
{
|
|
115
|
-
method: 'POST',
|
|
116
|
-
headers: {
|
|
117
|
-
'Content-Type': 'application/json',
|
|
118
|
-
'User-Agent': this.cfg.userAgent,
|
|
119
|
-
},
|
|
120
|
-
body: JSON.stringify({
|
|
121
|
-
email,
|
|
122
|
-
externalPayload: serializedExternalPayload,
|
|
123
|
-
language,
|
|
124
|
-
location: countryCode,
|
|
125
|
-
userContext: 'adult',
|
|
126
|
-
}),
|
|
127
|
-
},
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
if (!res.ok) {
|
|
131
|
-
const errorText = await res.text()
|
|
132
|
-
log.error(
|
|
133
|
-
{ status: res.status, statusText: res.statusText, errorText },
|
|
134
|
-
'Failed to send age assurance email',
|
|
135
|
-
)
|
|
136
|
-
throw new Error('Failed to send age assurance email')
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return res.json()
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Sends a KWS verification email with the given properties.
|
|
144
|
-
*/
|
|
145
|
-
async email(props: KWSSendEmailRequest) {
|
|
146
|
-
const res = await this.fetchWithAuth(
|
|
147
|
-
`${this.cfg.apiOrigin}/v1/verifications/send-email`,
|
|
148
|
-
{
|
|
149
|
-
method: 'POST',
|
|
150
|
-
headers: {
|
|
151
|
-
'Content-Type': 'application/json',
|
|
152
|
-
'User-Agent': this.cfg.userAgent,
|
|
153
|
-
},
|
|
154
|
-
body: JSON.stringify(props),
|
|
155
|
-
},
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
if (!res.ok) {
|
|
159
|
-
const errorText = await res.text()
|
|
160
|
-
log.error(
|
|
161
|
-
{
|
|
162
|
-
status: res.status,
|
|
163
|
-
statusText: res.statusText,
|
|
164
|
-
errorText,
|
|
165
|
-
flow: props.userContext,
|
|
166
|
-
},
|
|
167
|
-
'Failed to send KWS email',
|
|
168
|
-
)
|
|
169
|
-
throw new Error('Failed to send KWS email')
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return res.json()
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Sends an email to the user initiating an `adult` verification flow, which
|
|
177
|
-
* results in `adult-verified` events/webhooks.
|
|
178
|
-
*/
|
|
179
|
-
async sendAdultVerifiedFlowEmail(props: KWSSendEmailRequestCommon) {
|
|
180
|
-
return this.email({
|
|
181
|
-
...props,
|
|
182
|
-
userContext: 'adult',
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Sends an email to the user initiating an `age` verification flow, which
|
|
188
|
-
* results in `age-verified` events/webhooks.
|
|
189
|
-
*/
|
|
190
|
-
async sendAgeVerifiedFlowEmail(props: KWSSendEmailRequestCommon) {
|
|
191
|
-
return this.email({
|
|
192
|
-
...props,
|
|
193
|
-
userContext: 'age',
|
|
194
|
-
minimumAge: 16, // KWS required value
|
|
195
|
-
})
|
|
196
|
-
}
|
|
197
|
-
}
|
package/src/logger.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage } from 'node:http'
|
|
2
|
-
import { stdSerializers } from 'pino'
|
|
3
|
-
import { pinoHttp } from 'pino-http'
|
|
4
|
-
import { obfuscateHeaders, subsystemLogger } from '@atproto/common'
|
|
5
|
-
|
|
6
|
-
export const dbLogger: ReturnType<typeof subsystemLogger> =
|
|
7
|
-
subsystemLogger('bsky:db')
|
|
8
|
-
export const cacheLogger: ReturnType<typeof subsystemLogger> =
|
|
9
|
-
subsystemLogger('bsky:cache')
|
|
10
|
-
export const subLogger: ReturnType<typeof subsystemLogger> =
|
|
11
|
-
subsystemLogger('bsky:sub')
|
|
12
|
-
export const labelerLogger: ReturnType<typeof subsystemLogger> =
|
|
13
|
-
subsystemLogger('bsky:labeler')
|
|
14
|
-
export const hydrationLogger: ReturnType<typeof subsystemLogger> =
|
|
15
|
-
subsystemLogger('bsky:hydration')
|
|
16
|
-
export const featureGatesLogger: ReturnType<typeof subsystemLogger> =
|
|
17
|
-
subsystemLogger('bsky:featuregates')
|
|
18
|
-
export const dataplaneLogger: ReturnType<typeof subsystemLogger> =
|
|
19
|
-
subsystemLogger('bsky:dp')
|
|
20
|
-
export const ageAssuranceLogger: ReturnType<typeof subsystemLogger> =
|
|
21
|
-
subsystemLogger('bsky:aa')
|
|
22
|
-
export const viewsLogger: ReturnType<typeof subsystemLogger> =
|
|
23
|
-
subsystemLogger('bsky:views')
|
|
24
|
-
export const httpLogger: ReturnType<typeof subsystemLogger> =
|
|
25
|
-
subsystemLogger('bsky')
|
|
26
|
-
|
|
27
|
-
export const loggerMiddleware = pinoHttp({
|
|
28
|
-
logger: httpLogger,
|
|
29
|
-
serializers: {
|
|
30
|
-
err: (err: unknown) => ({
|
|
31
|
-
code: err?.['code'],
|
|
32
|
-
message: err?.['message'],
|
|
33
|
-
}),
|
|
34
|
-
req: (req: IncomingMessage) => {
|
|
35
|
-
const serialized = stdSerializers.req(req)
|
|
36
|
-
const headers = obfuscateHeaders(serialized.headers)
|
|
37
|
-
return { ...serialized, headers }
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
})
|
package/src/pipeline.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { HydrationState } from './hydration/hydrator.js'
|
|
2
|
-
|
|
3
|
-
export function createPipeline<Params, Skeleton, View, Context>(
|
|
4
|
-
skeletonFn: SkeletonFn<Context, Params, Skeleton>,
|
|
5
|
-
hydrationFn: HydrationFn<Context, Params, Skeleton>,
|
|
6
|
-
rulesFn: RulesFn<Context, Params, Skeleton>,
|
|
7
|
-
presentationFn: PresentationFn<Context, Params, Skeleton, View>,
|
|
8
|
-
) {
|
|
9
|
-
return async (params: Params, ctx: Context) => {
|
|
10
|
-
const skeleton = await skeletonFn({ ctx, params })
|
|
11
|
-
const hydration = await hydrationFn({ ctx, params, skeleton })
|
|
12
|
-
const appliedRules = rulesFn({ ctx, params, skeleton, hydration })
|
|
13
|
-
return presentationFn({ ctx, params, skeleton: appliedRules, hydration })
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type SkeletonFn<Context, Params, Skeleton> = (
|
|
18
|
-
input: SkeletonFnInput<Context, Params>,
|
|
19
|
-
) => Promise<Skeleton>
|
|
20
|
-
|
|
21
|
-
export type SkeletonFnInput<Context, Params> = {
|
|
22
|
-
ctx: Context
|
|
23
|
-
params: Params
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type HydrationFn<Context, Params, Skeleton> = (
|
|
27
|
-
input: HydrationFnInput<Context, Params, Skeleton>,
|
|
28
|
-
) => Promise<HydrationState>
|
|
29
|
-
|
|
30
|
-
export type HydrationFnInput<Context, Params, Skeleton> = {
|
|
31
|
-
ctx: Context
|
|
32
|
-
params: Params
|
|
33
|
-
skeleton: Skeleton
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type RulesFn<Context, Params, Skeleton> = (
|
|
37
|
-
input: RulesFnInput<Context, Params, Skeleton>,
|
|
38
|
-
) => Skeleton
|
|
39
|
-
|
|
40
|
-
export type RulesFnInput<Context, Params, Skeleton> = {
|
|
41
|
-
ctx: Context
|
|
42
|
-
params: Params
|
|
43
|
-
skeleton: Skeleton
|
|
44
|
-
hydration: HydrationState
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export type PresentationFn<Context, Params, Skeleton, View> = (
|
|
48
|
-
input: PresentationFnInput<Context, Params, Skeleton>,
|
|
49
|
-
) => View
|
|
50
|
-
|
|
51
|
-
export type PresentationFnInput<Context, Params, Skeleton> = {
|
|
52
|
-
ctx: Context
|
|
53
|
-
params: Params
|
|
54
|
-
skeleton: Skeleton
|
|
55
|
-
hydration: HydrationState
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function noRules<S>(input: { skeleton: S }) {
|
|
59
|
-
return input.skeleton
|
|
60
|
-
}
|
package/src/redis.ts
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert'
|
|
2
|
-
import { Redis as RedisDriver } from 'ioredis'
|
|
3
|
-
|
|
4
|
-
export class Redis {
|
|
5
|
-
driver: RedisDriver
|
|
6
|
-
namespace?: string
|
|
7
|
-
constructor(opts: RedisOptions) {
|
|
8
|
-
if ('sentinel' in opts) {
|
|
9
|
-
assert(opts.sentinel && Array.isArray(opts.hosts) && opts.hosts.length)
|
|
10
|
-
this.driver = new RedisDriver({
|
|
11
|
-
name: opts.sentinel,
|
|
12
|
-
sentinels: opts.hosts.map((h) => addressParts(h, 26379)),
|
|
13
|
-
password: opts.password,
|
|
14
|
-
db: opts.db,
|
|
15
|
-
commandTimeout: opts.commandTimeout,
|
|
16
|
-
})
|
|
17
|
-
} else if ('host' in opts) {
|
|
18
|
-
assert(opts.host)
|
|
19
|
-
this.driver = new RedisDriver({
|
|
20
|
-
...addressParts(opts.host),
|
|
21
|
-
password: opts.password,
|
|
22
|
-
db: opts.db,
|
|
23
|
-
commandTimeout: opts.commandTimeout,
|
|
24
|
-
})
|
|
25
|
-
} else {
|
|
26
|
-
assert(opts.driver)
|
|
27
|
-
this.driver = opts.driver
|
|
28
|
-
}
|
|
29
|
-
this.namespace = opts.namespace
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
withNamespace(namespace: string): Redis {
|
|
33
|
-
return new Redis({ driver: this.driver, namespace })
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async readStreams(
|
|
37
|
-
streams: StreamRef[],
|
|
38
|
-
opts: { count: number; blockMs?: number },
|
|
39
|
-
) {
|
|
40
|
-
const allRead = await this.driver.xreadBuffer(
|
|
41
|
-
'COUNT',
|
|
42
|
-
opts.count, // events per stream
|
|
43
|
-
'BLOCK',
|
|
44
|
-
opts.blockMs ?? 1000, // millis
|
|
45
|
-
'STREAMS',
|
|
46
|
-
...streams.map((s) => this.ns(s.key)),
|
|
47
|
-
...streams.map((s) => s.cursor),
|
|
48
|
-
)
|
|
49
|
-
const results: StreamOutput[] = []
|
|
50
|
-
for (const [key, messages] of allRead ?? []) {
|
|
51
|
-
const result: StreamOutput = {
|
|
52
|
-
key: this.rmns(key.toString()),
|
|
53
|
-
messages: [],
|
|
54
|
-
}
|
|
55
|
-
results.push(result)
|
|
56
|
-
for (const [seqBuf, values] of messages) {
|
|
57
|
-
const message = { cursor: seqBuf.toString(), contents: {} }
|
|
58
|
-
result.messages.push(message)
|
|
59
|
-
for (let i = 0; i < values.length; ++i) {
|
|
60
|
-
if (i % 2 === 0) continue
|
|
61
|
-
const field = values[i - 1].toString()
|
|
62
|
-
message.contents[field] = values[i]
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return results
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async addToStream(
|
|
70
|
-
key: string,
|
|
71
|
-
id: number | string,
|
|
72
|
-
fields: [key: string, value: string | Buffer][],
|
|
73
|
-
) {
|
|
74
|
-
await this.driver.xadd(this.ns(key), id, ...fields.flat())
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async addMultiToStream(
|
|
78
|
-
evts: {
|
|
79
|
-
key: string
|
|
80
|
-
id: number | string
|
|
81
|
-
fields: [key: string, value: string | Buffer][]
|
|
82
|
-
}[],
|
|
83
|
-
) {
|
|
84
|
-
const pipeline = this.driver.pipeline()
|
|
85
|
-
for (const { key, id, fields } of evts) {
|
|
86
|
-
pipeline.xadd(this.ns(key), id, ...fields.flat())
|
|
87
|
-
}
|
|
88
|
-
return (await pipeline.exec()) ?? []
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async trimStream(key: string, cursor: number | string) {
|
|
92
|
-
await this.driver.xtrim(this.ns(key), 'MINID', cursor)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async streamLengths(keys: string[]) {
|
|
96
|
-
const pipeline = this.driver.pipeline()
|
|
97
|
-
for (const key of keys) {
|
|
98
|
-
pipeline.xlen(this.ns(key))
|
|
99
|
-
}
|
|
100
|
-
const results = await pipeline.exec()
|
|
101
|
-
return (results ?? []).map(([, len = 0]) => Number(len))
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async get(key: string) {
|
|
105
|
-
return await this.driver.get(this.ns(key))
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async set(key: string, val: string | number, ttlMs?: number) {
|
|
109
|
-
if (ttlMs !== undefined) {
|
|
110
|
-
await this.driver.set(this.ns(key), val, 'PX', ttlMs)
|
|
111
|
-
} else {
|
|
112
|
-
await this.driver.set(this.ns(key), val)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async getMulti(keys: string[]) {
|
|
117
|
-
const namespaced = keys.map((k) => this.ns(k))
|
|
118
|
-
const got = await this.driver.mget(...namespaced)
|
|
119
|
-
const results = {}
|
|
120
|
-
for (let i = 0; i < keys.length; i++) {
|
|
121
|
-
const key = keys[i]
|
|
122
|
-
results[key] = got[i]
|
|
123
|
-
}
|
|
124
|
-
return results
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async setMulti(vals: Record<string, string | number>, ttlMs?: number) {
|
|
128
|
-
if (Object.keys(vals).length === 0) {
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
let builder = this.driver.multi({ pipeline: true })
|
|
132
|
-
for (const key of Object.keys(vals)) {
|
|
133
|
-
if (ttlMs !== undefined) {
|
|
134
|
-
builder = builder.set(this.ns(key), vals[key], 'PX', ttlMs)
|
|
135
|
-
} else {
|
|
136
|
-
builder = builder.set(this.ns(key), vals[key])
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
await builder.exec()
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async del(key: string) {
|
|
143
|
-
return await this.driver.del(this.ns(key))
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async expire(key: string, seconds: number) {
|
|
147
|
-
return await this.driver.expire(this.ns(key), seconds)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async zremrangebyscore(key: string, min: number, max: number) {
|
|
151
|
-
return await this.driver.zremrangebyscore(this.ns(key), min, max)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async zcount(key: string, min: number, max: number) {
|
|
155
|
-
return await this.driver.zcount(this.ns(key), min, max)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async zadd(key: string, score: number, member: number | string) {
|
|
159
|
-
return await this.driver.zadd(this.ns(key), score, member)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async destroy() {
|
|
163
|
-
await this.driver.quit()
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// namespace redis keys
|
|
167
|
-
ns(key: string) {
|
|
168
|
-
return this.namespace ? `${this.namespace}:${key}` : key
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// remove namespace from redis key
|
|
172
|
-
rmns(key: string) {
|
|
173
|
-
return this.namespace && key.startsWith(`${this.namespace}:`)
|
|
174
|
-
? key.replace(`${this.namespace}:`, '')
|
|
175
|
-
: key
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
type StreamRef = { key: string; cursor: string | number }
|
|
180
|
-
|
|
181
|
-
type StreamOutput = {
|
|
182
|
-
key: string
|
|
183
|
-
messages: { cursor: string; contents: Record<string, Buffer | undefined> }[]
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export type RedisOptions = (
|
|
187
|
-
| { driver: RedisDriver }
|
|
188
|
-
| { host: string }
|
|
189
|
-
| { sentinel: string; hosts: string[] }
|
|
190
|
-
) & {
|
|
191
|
-
password?: string
|
|
192
|
-
namespace?: string
|
|
193
|
-
db?: number
|
|
194
|
-
commandTimeout?: number
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function addressParts(
|
|
198
|
-
addr: string,
|
|
199
|
-
defaultPort = 6379,
|
|
200
|
-
): { host: string; port: number } {
|
|
201
|
-
const [host, portStr, ...others] = addr.split(':')
|
|
202
|
-
const port = portStr ? parseInt(portStr, 10) : defaultPort
|
|
203
|
-
assert(host && !isNaN(port) && !others.length, `invalid address: ${addr}`)
|
|
204
|
-
return { host, port }
|
|
205
|
-
}
|
package/src/rolodex.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Code,
|
|
3
|
-
ConnectError,
|
|
4
|
-
Interceptor,
|
|
5
|
-
PromiseClient,
|
|
6
|
-
createPromiseClient,
|
|
7
|
-
} from '@connectrpc/connect'
|
|
8
|
-
import {
|
|
9
|
-
ConnectTransportOptions,
|
|
10
|
-
createConnectTransport,
|
|
11
|
-
} from '@connectrpc/connect-node'
|
|
12
|
-
import { RolodexService } from './proto/rolodex_connect.js'
|
|
13
|
-
|
|
14
|
-
// Rolodex is the service that does contact imports following https://docs.bsky.app/blog/contact-import-rfc.
|
|
15
|
-
export type RolodexClient = PromiseClient<typeof RolodexService>
|
|
16
|
-
|
|
17
|
-
export const createRolodexClient = (
|
|
18
|
-
opts: ConnectTransportOptions,
|
|
19
|
-
): RolodexClient => {
|
|
20
|
-
const transport = createConnectTransport(opts)
|
|
21
|
-
return createPromiseClient(RolodexService, transport)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { Code }
|
|
25
|
-
|
|
26
|
-
export const isRolodexError = (
|
|
27
|
-
err: unknown,
|
|
28
|
-
code?: Code,
|
|
29
|
-
): err is ConnectError => {
|
|
30
|
-
if (err instanceof ConnectError) {
|
|
31
|
-
return !code || err.code === code
|
|
32
|
-
}
|
|
33
|
-
return false
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const authWithApiKey =
|
|
37
|
-
(apiKey: string): Interceptor =>
|
|
38
|
-
(next) =>
|
|
39
|
-
(req) => {
|
|
40
|
-
req.header.set('authorization', `Bearer ${apiKey}`)
|
|
41
|
-
return next(req)
|
|
42
|
-
}
|
package/src/stash.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { LexMap, TypedObjectSchema, lexStringify } from '@atproto/lex'
|
|
2
|
-
import { BsyncClient } from './bsync.js'
|
|
3
|
-
import { app } from './lexicons/index.js'
|
|
4
|
-
import { Method } from './proto/bsync_pb.js'
|
|
5
|
-
|
|
6
|
-
export const Namespaces = {
|
|
7
|
-
AppBskyAgeassuranceDefsEvent: app.bsky.ageassurance.defs.event,
|
|
8
|
-
AppBskyBookmarkDefsBookmark: app.bsky.bookmark.defs.bookmark,
|
|
9
|
-
AppBskyContactDefsNotification: app.bsky.contact.defs.notification,
|
|
10
|
-
AppBskyDraftDefsDraftWithId: app.bsky.draft.defs.draftWithId,
|
|
11
|
-
AppBskyNotificationDefsPreferences: app.bsky.notification.defs.preferences,
|
|
12
|
-
AppBskyNotificationDefsSubjectActivitySubscription:
|
|
13
|
-
app.bsky.notification.defs.subjectActivitySubscription,
|
|
14
|
-
AppBskyUnspeccedDefsAgeAssuranceEvent:
|
|
15
|
-
app.bsky.unspecced.defs.ageAssuranceEvent,
|
|
16
|
-
} as const satisfies Record<string, TypedObjectSchema>
|
|
17
|
-
|
|
18
|
-
export const createStashClient = (bsyncClient: BsyncClient): StashClient => {
|
|
19
|
-
return new StashClient(bsyncClient)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// An abstraction over the BsyncClient, that uses the bsync `PutOperation` RPC
|
|
23
|
-
// to store private data, which can be indexed by the dataplane and queried by the appview.
|
|
24
|
-
export class StashClient {
|
|
25
|
-
constructor(private readonly bsyncClient: BsyncClient) {}
|
|
26
|
-
|
|
27
|
-
create(input: CreateInput) {
|
|
28
|
-
input.namespace.assert(input.payload)
|
|
29
|
-
return this.putOperation(Method.CREATE, input)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
update(input: UpdateInput) {
|
|
33
|
-
input.namespace.assert(input.payload)
|
|
34
|
-
return this.putOperation(Method.UPDATE, input)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
delete(input: DeleteInput) {
|
|
38
|
-
return this.putOperation(Method.DELETE, { ...input, payload: undefined })
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private async putOperation(
|
|
42
|
-
method: Method,
|
|
43
|
-
input: {
|
|
44
|
-
actorDid: string
|
|
45
|
-
namespace: TypedObjectSchema
|
|
46
|
-
key: string
|
|
47
|
-
payload: LexMap | undefined
|
|
48
|
-
},
|
|
49
|
-
) {
|
|
50
|
-
const { actorDid, namespace, key, payload } = input
|
|
51
|
-
await this.bsyncClient.putOperation({
|
|
52
|
-
actorDid,
|
|
53
|
-
namespace: namespace.$type,
|
|
54
|
-
key,
|
|
55
|
-
method,
|
|
56
|
-
payload: payload
|
|
57
|
-
? Buffer.from(lexStringify({ ...payload, $type: namespace.$type }))
|
|
58
|
-
: undefined,
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
type CreateInput = {
|
|
64
|
-
actorDid: string
|
|
65
|
-
namespace: TypedObjectSchema
|
|
66
|
-
key: string
|
|
67
|
-
payload: LexMap
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
type UpdateInput = CreateInput
|
|
71
|
-
|
|
72
|
-
type DeleteInput = {
|
|
73
|
-
actorDid: string
|
|
74
|
-
namespace: TypedObjectSchema
|
|
75
|
-
key: string
|
|
76
|
-
}
|
package/src/util/debug.ts
DELETED
package/src/util/http.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse } from 'node:http'
|
|
2
|
-
import createHttpError from 'http-errors'
|
|
3
|
-
|
|
4
|
-
type IncomingHttpHeaders = Record<string, string | string[] | undefined>
|
|
5
|
-
|
|
6
|
-
type NextFunction = (err?: unknown) => void
|
|
7
|
-
|
|
8
|
-
export type Middleware = (
|
|
9
|
-
req: IncomingMessage,
|
|
10
|
-
res: ServerResponse,
|
|
11
|
-
next: NextFunction,
|
|
12
|
-
) => void
|
|
13
|
-
|
|
14
|
-
export type ResponseData = { statusCode: number; headers: IncomingHttpHeaders }
|
|
15
|
-
|
|
16
|
-
const RESPONSE_HEADERS_TO_PROXY = new Set([
|
|
17
|
-
'content-type',
|
|
18
|
-
'content-length',
|
|
19
|
-
'content-encoding',
|
|
20
|
-
'content-language',
|
|
21
|
-
'cache-control',
|
|
22
|
-
'last-modified',
|
|
23
|
-
'etag',
|
|
24
|
-
'expires',
|
|
25
|
-
'retry-after',
|
|
26
|
-
'vary', // Might vary based on "accept" headers
|
|
27
|
-
] as const satisfies (keyof IncomingHttpHeaders)[])
|
|
28
|
-
|
|
29
|
-
export function proxyResponseHeaders(data: ResponseData, res: ServerResponse) {
|
|
30
|
-
res.statusCode = data.statusCode >= 500 ? 502 : data.statusCode
|
|
31
|
-
for (const name of RESPONSE_HEADERS_TO_PROXY) {
|
|
32
|
-
const val = data.headers[name]
|
|
33
|
-
if (val) res.setHeader(name, val)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function responseSignal(res: ServerResponse): AbortSignal {
|
|
38
|
-
if (res.destroyed) throw createHttpError(499, 'Client Disconnected')
|
|
39
|
-
const controller = new AbortController()
|
|
40
|
-
res.once('close', () => controller.abort())
|
|
41
|
-
return controller.signal
|
|
42
|
-
}
|
package/src/util/retry.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createRetryable } from '@atproto/common'
|
|
2
|
-
import { XrpcError } from '@atproto/lex'
|
|
3
|
-
|
|
4
|
-
export const RETRYABLE_HTTP_STATUS_CODES = new Set([
|
|
5
|
-
408, 425, 429, 500, 502, 503, 504, 522, 524,
|
|
6
|
-
])
|
|
7
|
-
|
|
8
|
-
export const retryXrpc = createRetryable((err) => {
|
|
9
|
-
return err instanceof XrpcError && err.shouldRetry()
|
|
10
|
-
})
|