@atproto/bsky 0.0.250 → 0.0.253
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/dist/api/age-assurance/const.js +19 -19
- package/dist/api/age-assurance/const.js.map +1 -1
- package/dist/api/app/bsky/feed/getFeed.d.ts.map +1 -1
- package/dist/api/app/bsky/feed/getFeed.js +4 -0
- package/dist/api/app/bsky/feed/getFeed.js.map +1 -1
- package/dist/api/app/bsky/feed/searchPosts.js +5 -0
- package/dist/api/app/bsky/feed/searchPosts.js.map +1 -1
- package/dist/api/app/bsky/feed/searchPostsV2.js +5 -0
- package/dist/api/app/bsky/feed/searchPostsV2.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -1
- package/dist/hydration/feed.d.ts +1 -2
- package/dist/hydration/feed.d.ts.map +1 -1
- package/dist/hydration/feed.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/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 -277
- 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 -267
- package/src/api/app/bsky/feed/searchPostsV2.ts +0 -236
- 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 -710
- 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 -456
- 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 -2463
- 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 -919
- 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 -200
- 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
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import {
|
|
3
|
-
KWSExternalPayloadVersion,
|
|
4
|
-
parseKWSExternalPayloadV1WithV2Compat,
|
|
5
|
-
parseKWSExternalPayloadV2,
|
|
6
|
-
parseKWSExternalPayloadVersion,
|
|
7
|
-
serializeKWSExternalPayloadV1,
|
|
8
|
-
serializeKWSExternalPayloadV2,
|
|
9
|
-
} from './external-payload.js'
|
|
10
|
-
|
|
11
|
-
describe('parseKWSExternalPayloadVersion', () => {
|
|
12
|
-
it('should return V2 for "2"', () => {
|
|
13
|
-
const result = parseKWSExternalPayloadVersion('2')
|
|
14
|
-
expect(result).toBe('2')
|
|
15
|
-
})
|
|
16
|
-
it('should return V1 for unknown versions', () => {
|
|
17
|
-
const result = parseKWSExternalPayloadVersion('unknown')
|
|
18
|
-
expect(result).toBe('1')
|
|
19
|
-
})
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
describe('parseKWSExternalPayloadV1WithV2Compat', () => {
|
|
23
|
-
it('should parse V1 payload correctly', () => {
|
|
24
|
-
const payload = {
|
|
25
|
-
attemptId: '123',
|
|
26
|
-
actorDid: 'did:plc:123',
|
|
27
|
-
}
|
|
28
|
-
const serialized = serializeKWSExternalPayloadV1(payload)
|
|
29
|
-
const result = parseKWSExternalPayloadV1WithV2Compat(serialized)
|
|
30
|
-
expect(result).toEqual({
|
|
31
|
-
version: KWSExternalPayloadVersion.V1,
|
|
32
|
-
...payload,
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
it('should parse V2 payload correctly', () => {
|
|
36
|
-
const payload = {
|
|
37
|
-
version: KWSExternalPayloadVersion.V2 as const,
|
|
38
|
-
attemptId: '123',
|
|
39
|
-
actorDid: 'did:plc:123',
|
|
40
|
-
countryCode: 'US',
|
|
41
|
-
}
|
|
42
|
-
const serialized = serializeKWSExternalPayloadV2(payload)
|
|
43
|
-
const result = parseKWSExternalPayloadV1WithV2Compat(serialized)
|
|
44
|
-
expect(result).toEqual(payload)
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
describe('serializeKWSExternalPayloadV2 & parseKWSExternalPayloadV2', () => {
|
|
49
|
-
const payload = {
|
|
50
|
-
version: KWSExternalPayloadVersion.V2 as const,
|
|
51
|
-
attemptId: '123',
|
|
52
|
-
actorDid: 'did:plc:123',
|
|
53
|
-
countryCode: 'US',
|
|
54
|
-
regionCode: 'CA',
|
|
55
|
-
}
|
|
56
|
-
it('compresses when serializing', () => {
|
|
57
|
-
const serialized = serializeKWSExternalPayloadV2(payload)
|
|
58
|
-
const comparison = JSON.stringify({
|
|
59
|
-
v: KWSExternalPayloadVersion.V2,
|
|
60
|
-
id: payload.attemptId,
|
|
61
|
-
did: payload.actorDid,
|
|
62
|
-
gc: payload.countryCode,
|
|
63
|
-
gr: payload.regionCode,
|
|
64
|
-
})
|
|
65
|
-
expect(serialized).toEqual(comparison)
|
|
66
|
-
})
|
|
67
|
-
it('decompresses when parsing', () => {
|
|
68
|
-
const serialized = serializeKWSExternalPayloadV2(payload)
|
|
69
|
-
const deserialized = parseKWSExternalPayloadV2(serialized)
|
|
70
|
-
expect(deserialized).toEqual(payload)
|
|
71
|
-
})
|
|
72
|
-
})
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
|
|
3
|
-
export const KWS_EXTERNAL_PAYLOAD_CHAR_LIMIT = 250
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Thrown when the provided external payload exceeds KWS's character limit.
|
|
7
|
-
*
|
|
8
|
-
* This is most commonly caused by DIDs that are too long, such as for
|
|
9
|
-
* `did:web` DIDs. But it's very rare, and the client has special handling for
|
|
10
|
-
* this case.
|
|
11
|
-
*/
|
|
12
|
-
export class KWSExternalPayloadTooLargeError extends Error {}
|
|
13
|
-
|
|
14
|
-
export enum KWSExternalPayloadVersion {
|
|
15
|
-
V1 = '1',
|
|
16
|
-
V2 = '2',
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function parseKWSExternalPayloadVersion(raw: string) {
|
|
20
|
-
switch (raw) {
|
|
21
|
-
case KWSExternalPayloadVersion.V2:
|
|
22
|
-
return KWSExternalPayloadVersion.V2
|
|
23
|
-
default:
|
|
24
|
-
return KWSExternalPayloadVersion.V1
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type KWSExternalPayloadV1 = {
|
|
29
|
-
actorDid: string
|
|
30
|
-
attemptId: string
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const KWSExternalPayloadV1Schema = z.object({
|
|
34
|
-
actorDid: z.string(),
|
|
35
|
-
attemptId: z.string(),
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
export function parseKWSExternalPayloadV1(raw: string): KWSExternalPayloadV1 {
|
|
39
|
-
try {
|
|
40
|
-
const value: unknown = JSON.parse(raw)
|
|
41
|
-
return KWSExternalPayloadV1Schema.parse(value)
|
|
42
|
-
} catch (err) {
|
|
43
|
-
throw new Error(`Failed to parse KWSExternalPayloadV1`, {
|
|
44
|
-
cause: err,
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function serializeKWSExternalPayloadV1(
|
|
50
|
-
payload: KWSExternalPayloadV1,
|
|
51
|
-
): string {
|
|
52
|
-
try {
|
|
53
|
-
return JSON.stringify(KWSExternalPayloadV1Schema.parse(payload))
|
|
54
|
-
} catch (err) {
|
|
55
|
-
throw new Error('Failed to serialize KWSExternalPayloadV1', { cause: err })
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* During our migration from v1 to v2 of the KWS external payload, we'll be
|
|
61
|
-
* sending v2 payloads on the v1 flow (the `adult-verified` email flow). We use
|
|
62
|
-
* this utility to parse either v1 or v2 payloads in that flow.
|
|
63
|
-
*
|
|
64
|
-
* Check for the `version` field on the output of this method to discriminate
|
|
65
|
-
* between the two types and handle them differently.
|
|
66
|
-
*/
|
|
67
|
-
export function parseKWSExternalPayloadV1WithV2Compat(
|
|
68
|
-
raw: string,
|
|
69
|
-
):
|
|
70
|
-
| (KWSExternalPayloadV1 & { version: KWSExternalPayloadVersion.V1 })
|
|
71
|
-
| KWSExternalPayloadV2 {
|
|
72
|
-
const deserialized = JSON.parse(raw)
|
|
73
|
-
const v2 = deserialized.v === KWSExternalPayloadVersion.V2
|
|
74
|
-
|
|
75
|
-
if (v2) {
|
|
76
|
-
return parseKWSExternalPayloadV2(raw)
|
|
77
|
-
} else {
|
|
78
|
-
return {
|
|
79
|
-
...parseKWSExternalPayloadV1(raw),
|
|
80
|
-
version: KWSExternalPayloadVersion.V1,
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/***************************
|
|
86
|
-
* KWS External Payload V2 *
|
|
87
|
-
***************************/
|
|
88
|
-
|
|
89
|
-
export type KWSExternalPayloadV2 = {
|
|
90
|
-
version: KWSExternalPayloadVersion.V2
|
|
91
|
-
attemptId: string
|
|
92
|
-
actorDid: string
|
|
93
|
-
countryCode: string
|
|
94
|
-
regionCode?: string
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export const KWSExternalPayloadV2Schema = z.object({
|
|
98
|
-
v: z.string(),
|
|
99
|
-
id: z.string(),
|
|
100
|
-
did: z.string(),
|
|
101
|
-
gc: z.string().length(2),
|
|
102
|
-
gr: z.string().optional(),
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
export function serializeKWSExternalPayloadV2(
|
|
106
|
-
payload: KWSExternalPayloadV2,
|
|
107
|
-
): string {
|
|
108
|
-
let compressed: z.infer<typeof KWSExternalPayloadV2Schema>
|
|
109
|
-
try {
|
|
110
|
-
compressed = KWSExternalPayloadV2Schema.parse({
|
|
111
|
-
v: KWSExternalPayloadVersion.V2, // version
|
|
112
|
-
id: payload.attemptId,
|
|
113
|
-
did: payload.actorDid,
|
|
114
|
-
gc: payload.countryCode, // geolocation country
|
|
115
|
-
gr: payload.regionCode, // geolocation region
|
|
116
|
-
})
|
|
117
|
-
} catch (err) {
|
|
118
|
-
throw new Error('Failed to serialize KWSExternalPayloadV2', { cause: err })
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const serialized = JSON.stringify(compressed)
|
|
122
|
-
|
|
123
|
-
if (serialized.length > KWS_EXTERNAL_PAYLOAD_CHAR_LIMIT) {
|
|
124
|
-
throw new KWSExternalPayloadTooLargeError(
|
|
125
|
-
`Serialized external payload size ${serialized.length} exceeds limit of ${KWS_EXTERNAL_PAYLOAD_CHAR_LIMIT}`,
|
|
126
|
-
)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return serialized
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function parseKWSExternalPayloadV2(raw: string): KWSExternalPayloadV2 {
|
|
133
|
-
try {
|
|
134
|
-
const deserialized = JSON.parse(raw)
|
|
135
|
-
const parsed = KWSExternalPayloadV2Schema.parse(deserialized)
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
version: KWSExternalPayloadVersion.V2,
|
|
139
|
-
attemptId: parsed.id,
|
|
140
|
-
actorDid: parsed.did,
|
|
141
|
-
countryCode: parsed.gc,
|
|
142
|
-
regionCode: parsed.gr,
|
|
143
|
-
}
|
|
144
|
-
} catch (err) {
|
|
145
|
-
throw new Error(`Failed to parse KWSExternalPayloadV2`, {
|
|
146
|
-
cause: err,
|
|
147
|
-
})
|
|
148
|
-
}
|
|
149
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import express, { RequestHandler } from 'express'
|
|
2
|
-
import { ageAssuranceLogger as logger } from '../../../logger.js'
|
|
3
|
-
import { getClientUa, validateSignature } from '../../kws/util.js'
|
|
4
|
-
import { AGE_ASSURANCE_CONFIG } from '../const.js'
|
|
5
|
-
import { parseKWSAgeVerifiedStatus } from '../kws/age-verified.js'
|
|
6
|
-
import {
|
|
7
|
-
type KWSExternalPayloadV2,
|
|
8
|
-
parseKWSExternalPayloadV2,
|
|
9
|
-
} from '../kws/external-payload.js'
|
|
10
|
-
import { createEvent } from '../stash.js'
|
|
11
|
-
import { AppContextWithAA } from '../types.js'
|
|
12
|
-
import { computeAgeAssuranceAccessOrThrow } from '../util.js'
|
|
13
|
-
|
|
14
|
-
function parseQueryParams(
|
|
15
|
-
ctx: AppContextWithAA,
|
|
16
|
-
req: express.Request,
|
|
17
|
-
): {
|
|
18
|
-
status: string
|
|
19
|
-
externalPayload: string
|
|
20
|
-
} {
|
|
21
|
-
try {
|
|
22
|
-
const status = String(req.query.status)
|
|
23
|
-
const externalPayload = String(req.query.externalPayload)
|
|
24
|
-
const signature = String(req.query.signature)
|
|
25
|
-
|
|
26
|
-
validateSignature(
|
|
27
|
-
ctx.cfg.kws.ageVerifiedRedirectSecret,
|
|
28
|
-
`${status}:${externalPayload}`,
|
|
29
|
-
signature,
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
status,
|
|
34
|
-
externalPayload,
|
|
35
|
-
}
|
|
36
|
-
} catch (err) {
|
|
37
|
-
throw new Error('Invalid KWS API request', { cause: err })
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const handler =
|
|
42
|
-
(ctx: AppContextWithAA): RequestHandler =>
|
|
43
|
-
async (req: express.Request, res: express.Response) => {
|
|
44
|
-
let externalPayload: KWSExternalPayloadV2 | undefined
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
const query = parseQueryParams(ctx, req)
|
|
48
|
-
const { verified, verifiedMinimumAge } = parseKWSAgeVerifiedStatus(
|
|
49
|
-
query.status,
|
|
50
|
-
)
|
|
51
|
-
externalPayload = parseKWSExternalPayloadV2(query.externalPayload)
|
|
52
|
-
const { actorDid, attemptId, countryCode, regionCode } = externalPayload
|
|
53
|
-
|
|
54
|
-
/*
|
|
55
|
-
* KWS does not send unverified webhooks for age verification, so we
|
|
56
|
-
* expect all webhooks to be verified. This is just a sanity check.
|
|
57
|
-
*/
|
|
58
|
-
if (!verified) {
|
|
59
|
-
const message =
|
|
60
|
-
'Expected KWS verification redirect to have verified status'
|
|
61
|
-
logger.error({}, message)
|
|
62
|
-
throw new Error(message)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const { access } = computeAgeAssuranceAccessOrThrow(
|
|
66
|
-
AGE_ASSURANCE_CONFIG,
|
|
67
|
-
{
|
|
68
|
-
countryCode,
|
|
69
|
-
regionCode,
|
|
70
|
-
verifiedMinimumAge,
|
|
71
|
-
},
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
await createEvent(ctx, actorDid, {
|
|
75
|
-
attemptId,
|
|
76
|
-
// Assumes `app.set('trust proxy', ...)` configured with `true` or specific values.
|
|
77
|
-
completeIp: req.ip,
|
|
78
|
-
completeUa: getClientUa(req),
|
|
79
|
-
countryCode,
|
|
80
|
-
regionCode,
|
|
81
|
-
status: 'assured',
|
|
82
|
-
access,
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
const q = new URLSearchParams({ actorDid, result: 'success' })
|
|
86
|
-
|
|
87
|
-
return res
|
|
88
|
-
.status(302)
|
|
89
|
-
.setHeader('Location', `${ctx.cfg.kws.redirectUrl}?${q}`)
|
|
90
|
-
.end()
|
|
91
|
-
} catch (err) {
|
|
92
|
-
logger.error(
|
|
93
|
-
{ err, ...externalPayload },
|
|
94
|
-
'Failed to handle KWS verification redirect',
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
const q = new URLSearchParams({
|
|
98
|
-
...(externalPayload ? { actorDid: externalPayload.actorDid } : {}),
|
|
99
|
-
result: 'unknown',
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
return res
|
|
103
|
-
.status(302)
|
|
104
|
-
.setHeader('Location', `${ctx.cfg.kws.redirectUrl}?${q}`)
|
|
105
|
-
.end()
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { TID } from '@atproto/common'
|
|
2
|
-
import { DatetimeString } from '@atproto/syntax'
|
|
3
|
-
import { AppContext } from '../../context.js'
|
|
4
|
-
import { app } from '../../lexicons/index.js'
|
|
5
|
-
import { Namespaces } from '../../stash.js'
|
|
6
|
-
|
|
7
|
-
export async function createEvent(
|
|
8
|
-
ctx: AppContext,
|
|
9
|
-
actorDid: string,
|
|
10
|
-
event: Omit<app.bsky.ageassurance.defs.Event, 'createdAt'>,
|
|
11
|
-
) {
|
|
12
|
-
const payload: app.bsky.ageassurance.defs.Event = {
|
|
13
|
-
createdAt: new Date().toISOString() as DatetimeString,
|
|
14
|
-
...event,
|
|
15
|
-
}
|
|
16
|
-
await ctx.stashClient.create({
|
|
17
|
-
actorDid: actorDid,
|
|
18
|
-
namespace: Namespaces.AppBskyAgeassuranceDefsEvent,
|
|
19
|
-
key: TID.nextStr(),
|
|
20
|
-
payload,
|
|
21
|
-
})
|
|
22
|
-
return payload
|
|
23
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { KwsConfig, ServerConfig } from '../../config.js'
|
|
2
|
-
import { AppContext } from '../../context.js'
|
|
3
|
-
import { KwsClient } from '../../kws.js'
|
|
4
|
-
|
|
5
|
-
export type AppContextWithAA = AppContext & {
|
|
6
|
-
kwsClient: KwsClient
|
|
7
|
-
cfg: ServerConfig & {
|
|
8
|
-
kws: KwsConfig
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AgeAssuranceRuleID,
|
|
3
|
-
AppBskyAgeassuranceDefs,
|
|
4
|
-
computeAgeAssuranceRegionAccess,
|
|
5
|
-
getAgeAssuranceRegionConfig,
|
|
6
|
-
} from '@atproto/api'
|
|
7
|
-
import { app } from '../../lexicons/index.js'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Compute age assurance access based on verified minimum age. Thrown errors
|
|
11
|
-
* are internal errors, so handle them accordingly.
|
|
12
|
-
*/
|
|
13
|
-
export function computeAgeAssuranceAccessOrThrow(
|
|
14
|
-
config: app.bsky.ageassurance.defs.Config,
|
|
15
|
-
{
|
|
16
|
-
countryCode,
|
|
17
|
-
regionCode,
|
|
18
|
-
verifiedMinimumAge,
|
|
19
|
-
}: {
|
|
20
|
-
countryCode: string
|
|
21
|
-
regionCode?: string
|
|
22
|
-
verifiedMinimumAge: number
|
|
23
|
-
},
|
|
24
|
-
): { access: AppBskyAgeassuranceDefs.Access; reason: AgeAssuranceRuleID } {
|
|
25
|
-
const region = getAgeAssuranceRegionConfig(config, {
|
|
26
|
-
countryCode,
|
|
27
|
-
regionCode,
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
if (region) {
|
|
31
|
-
const result = computeAgeAssuranceRegionAccess(region, {
|
|
32
|
-
assuredAge: verifiedMinimumAge,
|
|
33
|
-
/*
|
|
34
|
-
* We don't care about this here, this is a client-only rule. If we have
|
|
35
|
-
* verified data, we can use that, and the account creation date is
|
|
36
|
-
* irrelevant.
|
|
37
|
-
*/
|
|
38
|
-
accountCreatedAt: undefined,
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
if (result) {
|
|
42
|
-
return result
|
|
43
|
-
} else {
|
|
44
|
-
/*
|
|
45
|
-
* If we don't get a result, it's because none of the rules matched,
|
|
46
|
-
* which is a configuration error: there should always be a default
|
|
47
|
-
* rule.
|
|
48
|
-
*/
|
|
49
|
-
throw new Error('Cound not compute age assurance region access')
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
/**
|
|
53
|
-
* If we had geolocation data, but we don't have a region config for this
|
|
54
|
-
* geolocation, then it means a user outside of our configured regions
|
|
55
|
-
* has completed age verification. In this case, we can't determine their
|
|
56
|
-
* access level, so we throw an error.
|
|
57
|
-
*
|
|
58
|
-
* This case is also guarded in `app.bsky.ageassurance.begin`.
|
|
59
|
-
*/
|
|
60
|
-
throw new Error('Could not get config for region')
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function createLocationString(countryCode: string, regionCode?: string) {
|
|
65
|
-
return regionCode
|
|
66
|
-
? `${countryCode.toUpperCase()}-${regionCode.toUpperCase()}`
|
|
67
|
-
: countryCode.toUpperCase()
|
|
68
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import express, { RequestHandler } from 'express'
|
|
2
|
-
import { ageAssuranceLogger as logger } from '../../../logger.js'
|
|
3
|
-
import { AGE_ASSURANCE_CONFIG } from '../const.js'
|
|
4
|
-
import {
|
|
5
|
-
type KWSWebhookAgeVerified,
|
|
6
|
-
parseKWSAgeVerifiedWebhook,
|
|
7
|
-
} from '../kws/age-verified.js'
|
|
8
|
-
import { parseKWSExternalPayloadV2 } from '../kws/external-payload.js'
|
|
9
|
-
import { createEvent } from '../stash.js'
|
|
10
|
-
import { type AppContextWithAA } from '../types.js'
|
|
11
|
-
import { computeAgeAssuranceAccessOrThrow } from '../util.js'
|
|
12
|
-
|
|
13
|
-
export const handler =
|
|
14
|
-
(ctx: AppContextWithAA): RequestHandler =>
|
|
15
|
-
async (req: express.Request, res: express.Response) => {
|
|
16
|
-
let body: KWSWebhookAgeVerified
|
|
17
|
-
try {
|
|
18
|
-
body = parseKWSAgeVerifiedWebhook(req.body)
|
|
19
|
-
} catch (err) {
|
|
20
|
-
const message = 'Failed to parse KWS webhook body'
|
|
21
|
-
logger.error({ err }, message)
|
|
22
|
-
return res.status(400).json({ error: message })
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const { status, externalPayload } = body.payload
|
|
26
|
-
const { verified, verifiedMinimumAge } = status
|
|
27
|
-
const { actorDid, countryCode, regionCode, attemptId } =
|
|
28
|
-
parseKWSExternalPayloadV2(externalPayload)
|
|
29
|
-
|
|
30
|
-
/*
|
|
31
|
-
* KWS does not send unverified webhooks for age verification, so we
|
|
32
|
-
* expect all webhooks to be verified. This is just a sanity check.
|
|
33
|
-
*/
|
|
34
|
-
if (!verified) {
|
|
35
|
-
const message = 'Expected KWS webhook to have verified status'
|
|
36
|
-
logger.error({}, message)
|
|
37
|
-
return res.status(400).json({ error: message })
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let result: ReturnType<typeof computeAgeAssuranceAccessOrThrow> | undefined
|
|
41
|
-
try {
|
|
42
|
-
result = computeAgeAssuranceAccessOrThrow(AGE_ASSURANCE_CONFIG, {
|
|
43
|
-
countryCode,
|
|
44
|
-
regionCode,
|
|
45
|
-
verifiedMinimumAge,
|
|
46
|
-
})
|
|
47
|
-
} catch (err) {
|
|
48
|
-
// internal errors
|
|
49
|
-
logger.error(
|
|
50
|
-
{ err, attemptId, actorDid, countryCode, regionCode },
|
|
51
|
-
'Failed to compute age assurance access',
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
if (result) {
|
|
57
|
-
await createEvent(ctx, actorDid, {
|
|
58
|
-
attemptId,
|
|
59
|
-
countryCode,
|
|
60
|
-
regionCode,
|
|
61
|
-
status: 'assured',
|
|
62
|
-
access: result.access,
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return res.status(200).end()
|
|
67
|
-
} catch (err) {
|
|
68
|
-
const message = 'Failed to handle KWS webhook'
|
|
69
|
-
logger.error(
|
|
70
|
-
{ err, attemptId, actorDid, countryCode, regionCode },
|
|
71
|
-
message,
|
|
72
|
-
)
|
|
73
|
-
return res.status(500).json({ error: message })
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { DidString } from '@atproto/syntax'
|
|
2
|
-
import { InvalidRequestError, Server } from '@atproto/xrpc-server'
|
|
3
|
-
import { AppContext } from '../../../../context.js'
|
|
4
|
-
import {
|
|
5
|
-
HydrateCtx,
|
|
6
|
-
HydrationState,
|
|
7
|
-
Hydrator,
|
|
8
|
-
} from '../../../../hydration/hydrator.js'
|
|
9
|
-
import { app } from '../../../../lexicons/index.js'
|
|
10
|
-
import { createPipeline, noRules } from '../../../../pipeline.js'
|
|
11
|
-
import { Views } from '../../../../views/index.js'
|
|
12
|
-
import { resHeaders } from '../../../util.js'
|
|
13
|
-
|
|
14
|
-
export default function (server: Server, ctx: AppContext) {
|
|
15
|
-
const getProfile = createPipeline(skeleton, hydration, noRules, presentation)
|
|
16
|
-
server.add(app.bsky.actor.getProfile, {
|
|
17
|
-
auth: ctx.authVerifier.optionalStandardOrRole,
|
|
18
|
-
handler: async ({ auth, params, req }) => {
|
|
19
|
-
const { viewer, includeTakedowns, skipViewerBlocks } =
|
|
20
|
-
ctx.authVerifier.parseCreds(auth)
|
|
21
|
-
const labelers = ctx.reqLabelers(req)
|
|
22
|
-
const hydrateCtx = await ctx.hydrator.createContext({
|
|
23
|
-
labelers,
|
|
24
|
-
viewer,
|
|
25
|
-
includeTakedowns,
|
|
26
|
-
skipViewerBlocks,
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
const result = await getProfile({ ...params, hydrateCtx }, ctx)
|
|
30
|
-
|
|
31
|
-
const repoRev = await ctx.hydrator.actor.getRepoRevSafe(viewer)
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
encoding: 'application/json',
|
|
35
|
-
body: result,
|
|
36
|
-
headers: resHeaders({
|
|
37
|
-
repoRev,
|
|
38
|
-
labelers: hydrateCtx.labelers,
|
|
39
|
-
}),
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const skeleton = async (input: {
|
|
46
|
-
ctx: Context
|
|
47
|
-
params: Params
|
|
48
|
-
}): Promise<SkeletonState> => {
|
|
49
|
-
const { ctx, params } = input
|
|
50
|
-
const [did] = await ctx.hydrator.actor.getDids([params.actor])
|
|
51
|
-
if (!did) {
|
|
52
|
-
throw new InvalidRequestError('Profile not found')
|
|
53
|
-
}
|
|
54
|
-
return { did }
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const hydration = async (input: {
|
|
58
|
-
ctx: Context
|
|
59
|
-
params: Params
|
|
60
|
-
skeleton: SkeletonState
|
|
61
|
-
}) => {
|
|
62
|
-
const { ctx, params, skeleton } = input
|
|
63
|
-
return ctx.hydrator.hydrateProfilesDetailed(
|
|
64
|
-
[skeleton.did],
|
|
65
|
-
params.hydrateCtx.copy({
|
|
66
|
-
overrideIncludeTakedownsForActor: true,
|
|
67
|
-
}),
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const presentation = (input: {
|
|
72
|
-
ctx: Context
|
|
73
|
-
params: Params
|
|
74
|
-
skeleton: SkeletonState
|
|
75
|
-
hydration: HydrationState
|
|
76
|
-
}) => {
|
|
77
|
-
const { ctx, params, skeleton, hydration } = input
|
|
78
|
-
const profile = ctx.views.profileDetailed(skeleton.did, hydration)
|
|
79
|
-
if (!profile) {
|
|
80
|
-
throw new InvalidRequestError('Profile not found')
|
|
81
|
-
} else if (!params.hydrateCtx.includeTakedowns) {
|
|
82
|
-
if (ctx.views.actorIsTakendown(skeleton.did, hydration)) {
|
|
83
|
-
throw new InvalidRequestError(
|
|
84
|
-
'Account has been suspended',
|
|
85
|
-
'AccountTakedown',
|
|
86
|
-
)
|
|
87
|
-
} else if (ctx.views.actorIsDeactivated(skeleton.did, hydration)) {
|
|
88
|
-
throw new InvalidRequestError(
|
|
89
|
-
'Account is deactivated',
|
|
90
|
-
'AccountDeactivated',
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return profile
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
type Context = {
|
|
98
|
-
hydrator: Hydrator
|
|
99
|
-
views: Views
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
type Params = app.bsky.actor.getProfile.$Params & {
|
|
103
|
-
hydrateCtx: HydrateCtx
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
type SkeletonState = { did: DidString }
|