@atproto/ozone 0.0.2
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 +8 -0
- package/LICENSE.txt +7 -0
- package/README.md +15 -0
- package/babel.config.js +3 -0
- package/bin/migration-create.ts +38 -0
- package/build.js +18 -0
- package/dist/api/admin/emitModerationEvent.d.ts +3 -0
- package/dist/api/admin/getModerationEvent.d.ts +3 -0
- package/dist/api/admin/getRecord.d.ts +3 -0
- package/dist/api/admin/getRepo.d.ts +3 -0
- package/dist/api/admin/queryModerationEvents.d.ts +3 -0
- package/dist/api/admin/queryModerationStatuses.d.ts +3 -0
- package/dist/api/admin/searchRepos.d.ts +3 -0
- package/dist/api/admin/util.d.ts +5 -0
- package/dist/api/com/atproto/admin/emitModerationEvent.d.ts +3 -0
- package/dist/api/com/atproto/admin/getModerationEvent.d.ts +3 -0
- package/dist/api/com/atproto/admin/getRecord.d.ts +3 -0
- package/dist/api/com/atproto/admin/getRepo.d.ts +3 -0
- package/dist/api/com/atproto/admin/queryModerationEvents.d.ts +3 -0
- package/dist/api/com/atproto/admin/queryModerationStatuses.d.ts +3 -0
- package/dist/api/com/atproto/admin/searchRepos.d.ts +3 -0
- package/dist/api/com/atproto/admin/util.d.ts +5 -0
- package/dist/api/com/atproto/moderation/createReport.d.ts +3 -0
- package/dist/api/com/atproto/moderation/util.d.ts +4 -0
- package/dist/api/com/atproto/temp/fetchLabels.d.ts +3 -0
- package/dist/api/health.d.ts +3 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/label/queryLabels.d.ts +3 -0
- package/dist/api/label/subscribeLabels.d.ts +3 -0
- package/dist/api/moderation/createReport.d.ts +3 -0
- package/dist/api/moderation/util.d.ts +4 -0
- package/dist/api/temp/fetchLabels.d.ts +3 -0
- package/dist/api/util.d.ts +2 -0
- package/dist/api/well-known.d.ts +3 -0
- package/dist/auth-verifier.d.ts +47 -0
- package/dist/auth.d.ts +81 -0
- package/dist/background.d.ts +13 -0
- package/dist/config/config.d.ts +30 -0
- package/dist/config/env.d.ts +19 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/secrets.d.ts +8 -0
- package/dist/config.d.ts +42 -0
- package/dist/context.d.ts +140 -0
- package/dist/daemon/config.d.ts +23 -0
- package/dist/daemon/context.d.ts +25 -0
- package/dist/daemon/event-pusher.d.ts +48 -0
- package/dist/daemon/event-reverser.d.ts +16 -0
- package/dist/daemon/index.d.ts +13 -0
- package/dist/db/index.d.ts +32 -0
- package/dist/db/index.js +33707 -0
- package/dist/db/index.js.map +7 -0
- package/dist/db/migrations/20231219T205730722Z-init.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/db/migrations/provider.d.ts +11 -0
- package/dist/db/pagination.d.ts +66 -0
- package/dist/db/schema/blob_push_event.d.ts +17 -0
- package/dist/db/schema/index.d.ts +10 -0
- package/dist/db/schema/label.d.ts +12 -0
- package/dist/db/schema/moderation_event.d.ts +22 -0
- package/dist/db/schema/moderation_subject_status.d.ts +25 -0
- package/dist/db/schema/record_push_event.d.ts +17 -0
- package/dist/db/schema/repo_push_event.d.ts +15 -0
- package/dist/db/types.d.ts +12 -0
- package/dist/error.d.ts +2 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +131818 -0
- package/dist/index.js.map +7 -0
- package/dist/lexicon/index.d.ts +372 -0
- package/dist/lexicon/lexicons.d.ts +7553 -0
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +104 -0
- package/dist/lexicon/types/app/bsky/actor/getPreferences.d.ts +31 -0
- package/dist/lexicon/types/app/bsky/actor/getProfile.d.ts +29 -0
- package/dist/lexicon/types/app/bsky/actor/getProfiles.d.ts +32 -0
- package/dist/lexicon/types/app/bsky/actor/getSuggestions.d.ts +34 -0
- package/dist/lexicon/types/app/bsky/actor/profile.d.ts +15 -0
- package/dist/lexicon/types/app/bsky/actor/putPreferences.d.ts +26 -0
- package/dist/lexicon/types/app/bsky/actor/searchActors.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/actor/searchActorsTypeahead.d.ts +34 -0
- package/dist/lexicon/types/app/bsky/embed/external.d.ts +31 -0
- package/dist/lexicon/types/app/bsky/embed/images.d.ts +37 -0
- package/dist/lexicon/types/app/bsky/embed/record.d.ts +54 -0
- package/dist/lexicon/types/app/bsky/embed/recordWithMedia.d.ts +24 -0
- package/dist/lexicon/types/app/bsky/feed/defs.d.ts +151 -0
- package/dist/lexicon/types/app/bsky/feed/describeFeedGenerator.d.ts +46 -0
- package/dist/lexicon/types/app/bsky/feed/generator.d.ts +18 -0
- package/dist/lexicon/types/app/bsky/feed/getActorFeeds.d.ts +35 -0
- package/dist/lexicon/types/app/bsky/feed/getActorLikes.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/feed/getAuthorFeed.d.ts +37 -0
- package/dist/lexicon/types/app/bsky/feed/getFeed.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/feed/getFeedGenerator.d.ts +34 -0
- package/dist/lexicon/types/app/bsky/feed/getFeedGenerators.d.ts +32 -0
- package/dist/lexicon/types/app/bsky/feed/getFeedSkeleton.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/feed/getLikes.d.ts +47 -0
- package/dist/lexicon/types/app/bsky/feed/getListFeed.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/feed/getPostThread.d.ts +38 -0
- package/dist/lexicon/types/app/bsky/feed/getPosts.d.ts +32 -0
- package/dist/lexicon/types/app/bsky/feed/getRepostedBy.d.ts +38 -0
- package/dist/lexicon/types/app/bsky/feed/getSuggestedFeeds.d.ts +34 -0
- package/dist/lexicon/types/app/bsky/feed/getTimeline.d.ts +35 -0
- package/dist/lexicon/types/app/bsky/feed/like.d.ts +9 -0
- package/dist/lexicon/types/app/bsky/feed/post.d.ts +50 -0
- package/dist/lexicon/types/app/bsky/feed/repost.d.ts +9 -0
- package/dist/lexicon/types/app/bsky/feed/searchPosts.d.ts +37 -0
- package/dist/lexicon/types/app/bsky/feed/threadgate.d.ts +28 -0
- package/dist/lexicon/types/app/bsky/graph/block.d.ts +8 -0
- package/dist/lexicon/types/app/bsky/graph/defs.d.ts +47 -0
- package/dist/lexicon/types/app/bsky/graph/follow.d.ts +8 -0
- package/dist/lexicon/types/app/bsky/graph/getBlocks.d.ts +34 -0
- package/dist/lexicon/types/app/bsky/graph/getFollowers.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/graph/getFollows.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/graph/getList.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/graph/getListBlocks.d.ts +34 -0
- package/dist/lexicon/types/app/bsky/graph/getListMutes.d.ts +34 -0
- package/dist/lexicon/types/app/bsky/graph/getLists.d.ts +35 -0
- package/dist/lexicon/types/app/bsky/graph/getMutes.d.ts +34 -0
- package/dist/lexicon/types/app/bsky/graph/getSuggestedFollowsByActor.d.ts +32 -0
- package/dist/lexicon/types/app/bsky/graph/list.d.ts +19 -0
- package/dist/lexicon/types/app/bsky/graph/listblock.d.ts +8 -0
- package/dist/lexicon/types/app/bsky/graph/listitem.d.ts +9 -0
- package/dist/lexicon/types/app/bsky/graph/muteActor.d.ts +25 -0
- package/dist/lexicon/types/app/bsky/graph/muteActorList.d.ts +25 -0
- package/dist/lexicon/types/app/bsky/graph/unmuteActor.d.ts +25 -0
- package/dist/lexicon/types/app/bsky/graph/unmuteActorList.d.ts +25 -0
- package/dist/lexicon/types/app/bsky/moderation/defs.d.ts +49 -0
- package/dist/lexicon/types/app/bsky/moderation/getService.d.ts +29 -0
- package/dist/lexicon/types/app/bsky/moderation/getServices.d.ts +32 -0
- package/dist/lexicon/types/app/bsky/moderation/service.d.ts +17 -0
- package/dist/lexicon/types/app/bsky/notification/getUnreadCount.d.ts +31 -0
- package/dist/lexicon/types/app/bsky/notification/listNotifications.d.ts +52 -0
- package/dist/lexicon/types/app/bsky/notification/registerPush.d.ts +28 -0
- package/dist/lexicon/types/app/bsky/notification/updateSeen.d.ts +25 -0
- package/dist/lexicon/types/app/bsky/richtext/facet.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/unspecced/defs.d.ts +13 -0
- package/dist/lexicon/types/app/bsky/unspecced/getPopular.d.ts +35 -0
- package/dist/lexicon/types/app/bsky/unspecced/getPopularFeedGenerators.d.ts +35 -0
- package/dist/lexicon/types/app/bsky/unspecced/getTimelineSkeleton.d.ts +35 -0
- package/dist/lexicon/types/app/bsky/unspecced/searchActorsSkeleton.d.ts +38 -0
- package/dist/lexicon/types/app/bsky/unspecced/searchPostsSkeleton.d.ts +37 -0
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +319 -0
- package/dist/lexicon/types/com/atproto/admin/deleteAccount.d.ts +25 -0
- package/dist/lexicon/types/com/atproto/admin/disableAccountInvites.d.ts +26 -0
- package/dist/lexicon/types/com/atproto/admin/disableInviteCodes.d.ts +26 -0
- package/dist/lexicon/types/com/atproto/admin/emitModerationEvent.d.ts +45 -0
- package/dist/lexicon/types/com/atproto/admin/enableAccountInvites.d.ts +26 -0
- package/dist/lexicon/types/com/atproto/admin/getAccountInfo.d.ts +29 -0
- package/dist/lexicon/types/com/atproto/admin/getAccountInfos.d.ts +32 -0
- package/dist/lexicon/types/com/atproto/admin/getInviteCodes.d.ts +35 -0
- package/dist/lexicon/types/com/atproto/admin/getModerationEvent.d.ts +29 -0
- package/dist/lexicon/types/com/atproto/admin/getRecord.d.ts +31 -0
- package/dist/lexicon/types/com/atproto/admin/getRepo.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts +39 -0
- package/dist/lexicon/types/com/atproto/admin/queryModerationEvents.d.ts +39 -0
- package/dist/lexicon/types/com/atproto/admin/queryModerationStatuses.d.ts +48 -0
- package/dist/lexicon/types/com/atproto/admin/searchRepos.d.ts +36 -0
- package/dist/lexicon/types/com/atproto/admin/sendEmail.d.ts +40 -0
- package/dist/lexicon/types/com/atproto/admin/updateAccountEmail.d.ts +26 -0
- package/dist/lexicon/types/com/atproto/admin/updateAccountHandle.d.ts +26 -0
- package/dist/lexicon/types/com/atproto/admin/updateSubjectStatus.d.ts +46 -0
- package/dist/lexicon/types/com/atproto/identity/resolveHandle.d.ts +31 -0
- package/dist/lexicon/types/com/atproto/identity/updateHandle.d.ts +25 -0
- package/dist/lexicon/types/com/atproto/label/defs.d.ts +24 -0
- package/dist/lexicon/types/com/atproto/label/queryLabels.d.ts +36 -0
- package/dist/lexicon/types/com/atproto/label/subscribeLabels.d.ts +36 -0
- package/dist/lexicon/types/com/atproto/moderation/createReport.d.ts +52 -0
- package/dist/lexicon/types/com/atproto/moderation/defs.d.ts +8 -0
- package/dist/lexicon/types/com/atproto/repo/applyWrites.d.ts +53 -0
- package/dist/lexicon/types/com/atproto/repo/createRecord.d.ts +43 -0
- package/dist/lexicon/types/com/atproto/repo/deleteRecord.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/repo/describeRepo.d.ts +35 -0
- package/dist/lexicon/types/com/atproto/repo/getRecord.d.ts +36 -0
- package/dist/lexicon/types/com/atproto/repo/listRecords.d.ts +47 -0
- package/dist/lexicon/types/com/atproto/repo/putRecord.d.ts +44 -0
- package/dist/lexicon/types/com/atproto/repo/strongRef.d.ts +8 -0
- package/dist/lexicon/types/com/atproto/repo/uploadBlob.d.ts +36 -0
- package/dist/lexicon/types/com/atproto/server/confirmEmail.d.ts +27 -0
- package/dist/lexicon/types/com/atproto/server/createAccount.d.ts +49 -0
- package/dist/lexicon/types/com/atproto/server/createAppPassword.d.ts +43 -0
- package/dist/lexicon/types/com/atproto/server/createInviteCode.d.ts +37 -0
- package/dist/lexicon/types/com/atproto/server/createInviteCodes.d.ts +46 -0
- package/dist/lexicon/types/com/atproto/server/createSession.d.ts +44 -0
- package/dist/lexicon/types/com/atproto/server/defs.d.ts +20 -0
- package/dist/lexicon/types/com/atproto/server/deleteAccount.d.ts +28 -0
- package/dist/lexicon/types/com/atproto/server/deleteSession.d.ts +19 -0
- package/dist/lexicon/types/com/atproto/server/describeServer.d.ts +41 -0
- package/dist/lexicon/types/com/atproto/server/getAccountInviteCodes.d.ts +34 -0
- package/dist/lexicon/types/com/atproto/server/getSession.d.ts +34 -0
- package/dist/lexicon/types/com/atproto/server/listAppPasswords.d.ts +39 -0
- package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +35 -0
- package/dist/lexicon/types/com/atproto/server/requestAccountDelete.d.ts +19 -0
- package/dist/lexicon/types/com/atproto/server/requestEmailConfirmation.d.ts +19 -0
- package/dist/lexicon/types/com/atproto/server/requestEmailUpdate.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/server/requestPasswordReset.d.ts +25 -0
- package/dist/lexicon/types/com/atproto/server/reserveSigningKey.d.ts +36 -0
- package/dist/lexicon/types/com/atproto/server/resetPassword.d.ts +27 -0
- package/dist/lexicon/types/com/atproto/server/revokeAppPassword.d.ts +25 -0
- package/dist/lexicon/types/com/atproto/server/updateEmail.d.ts +27 -0
- package/dist/lexicon/types/com/atproto/sync/getBlob.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/sync/getBlocks.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/sync/getCheckout.d.ts +29 -0
- package/dist/lexicon/types/com/atproto/sync/getHead.d.ts +32 -0
- package/dist/lexicon/types/com/atproto/sync/getLatestCommit.d.ts +33 -0
- package/dist/lexicon/types/com/atproto/sync/getRecord.d.ts +32 -0
- package/dist/lexicon/types/com/atproto/sync/getRepo.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/sync/listBlobs.d.ts +35 -0
- package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +42 -0
- package/dist/lexicon/types/com/atproto/sync/notifyOfUpdate.d.ts +25 -0
- package/dist/lexicon/types/com/atproto/sync/requestCrawl.d.ts +25 -0
- package/dist/lexicon/types/com/atproto/sync/subscribeRepos.d.ts +80 -0
- package/dist/lexicon/types/com/atproto/temp/fetchLabels.d.ts +33 -0
- package/dist/lexicon/types/com/atproto/temp/importRepo.d.ts +32 -0
- package/dist/lexicon/types/com/atproto/temp/pushBlob.d.ts +25 -0
- package/dist/lexicon/types/com/atproto/temp/requestPhoneVerification.d.ts +25 -0
- package/dist/lexicon/types/com/atproto/temp/transferAccount.d.ts +42 -0
- package/dist/lexicon/util.d.ts +2 -0
- package/dist/logger.d.ts +4 -0
- package/dist/mod-service/index.d.ts +155 -0
- package/dist/mod-service/status.d.ts +12 -0
- package/dist/mod-service/subject.d.ts +59 -0
- package/dist/mod-service/types.d.ts +19 -0
- package/dist/mod-service/views.d.ts +49 -0
- package/dist/sequencer/index.d.ts +2 -0
- package/dist/sequencer/outbox.d.ts +16 -0
- package/dist/sequencer/sequencer.d.ts +35 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/moderation/index.d.ts +144 -0
- package/dist/services/moderation/status.d.ts +12 -0
- package/dist/services/moderation/subject.d.ts +60 -0
- package/dist/services/moderation/types.d.ts +19 -0
- package/dist/services/moderation/views.d.ts +42 -0
- package/dist/services/types.d.ts +2 -0
- package/dist/util/date.d.ts +1 -0
- package/dist/util/debug.d.ts +1 -0
- package/dist/util/retry.d.ts +3 -0
- package/dist/util.d.ts +3 -0
- package/jest.config.js +6 -0
- package/package.json +67 -0
- package/src/api/admin/emitModerationEvent.ts +130 -0
- package/src/api/admin/getModerationEvent.ts +19 -0
- package/src/api/admin/getRecord.ts +34 -0
- package/src/api/admin/getRepo.ts +31 -0
- package/src/api/admin/queryModerationEvents.ts +40 -0
- package/src/api/admin/queryModerationStatuses.ts +57 -0
- package/src/api/admin/searchRepos.ts +42 -0
- package/src/api/admin/util.ts +54 -0
- package/src/api/health.ts +20 -0
- package/src/api/index.ts +28 -0
- package/src/api/moderation/createReport.ts +41 -0
- package/src/api/moderation/util.ts +65 -0
- package/src/api/temp/fetchLabels.ts +29 -0
- package/src/api/well-known.ts +35 -0
- package/src/auth.ts +147 -0
- package/src/background.ts +35 -0
- package/src/config/config.ts +84 -0
- package/src/config/env.ts +41 -0
- package/src/config/index.ts +3 -0
- package/src/config/secrets.ts +23 -0
- package/src/context.ts +180 -0
- package/src/daemon/context.ts +90 -0
- package/src/daemon/event-pusher.ts +296 -0
- package/src/daemon/event-reverser.ts +74 -0
- package/src/daemon/index.ts +33 -0
- package/src/db/index.ts +197 -0
- package/src/db/migrations/20231219T205730722Z-init.ts +164 -0
- package/src/db/migrations/index.ts +5 -0
- package/src/db/migrations/provider.ts +25 -0
- package/src/db/pagination.ts +216 -0
- package/src/db/schema/blob_push_event.ts +21 -0
- package/src/db/schema/index.ts +18 -0
- package/src/db/schema/label.ts +12 -0
- package/src/db/schema/moderation_event.ts +35 -0
- package/src/db/schema/moderation_subject_status.ts +32 -0
- package/src/db/schema/record_push_event.ts +21 -0
- package/src/db/schema/repo_push_event.ts +19 -0
- package/src/db/types.ts +15 -0
- package/src/error.ts +12 -0
- package/src/index.ts +102 -0
- package/src/lexicon/index.ts +1626 -0
- package/src/lexicon/lexicons.ts +8050 -0
- package/src/lexicon/types/app/bsky/actor/defs.ts +235 -0
- package/src/lexicon/types/app/bsky/actor/getPreferences.ts +44 -0
- package/src/lexicon/types/app/bsky/actor/getProfile.ts +41 -0
- package/src/lexicon/types/app/bsky/actor/getProfiles.ts +46 -0
- package/src/lexicon/types/app/bsky/actor/getSuggestions.ts +48 -0
- package/src/lexicon/types/app/bsky/actor/profile.ts +32 -0
- package/src/lexicon/types/app/bsky/actor/putPreferences.ts +39 -0
- package/src/lexicon/types/app/bsky/actor/searchActors.ts +52 -0
- package/src/lexicon/types/app/bsky/actor/searchActorsTypeahead.ts +50 -0
- package/src/lexicon/types/app/bsky/embed/external.ts +82 -0
- package/src/lexicon/types/app/bsky/embed/images.ts +96 -0
- package/src/lexicon/types/app/bsky/embed/record.ts +120 -0
- package/src/lexicon/types/app/bsky/embed/recordWithMedia.ts +53 -0
- package/src/lexicon/types/app/bsky/feed/defs.ts +308 -0
- package/src/lexicon/types/app/bsky/feed/describeFeedGenerator.ts +80 -0
- package/src/lexicon/types/app/bsky/feed/generator.ts +35 -0
- package/src/lexicon/types/app/bsky/feed/getActorFeeds.ts +49 -0
- package/src/lexicon/types/app/bsky/feed/getActorLikes.ts +50 -0
- package/src/lexicon/types/app/bsky/feed/getAuthorFeed.ts +56 -0
- package/src/lexicon/types/app/bsky/feed/getFeed.ts +50 -0
- package/src/lexicon/types/app/bsky/feed/getFeedGenerator.ts +48 -0
- package/src/lexicon/types/app/bsky/feed/getFeedGenerators.ts +46 -0
- package/src/lexicon/types/app/bsky/feed/getFeedSkeleton.ts +50 -0
- package/src/lexicon/types/app/bsky/feed/getLikes.ts +69 -0
- package/src/lexicon/types/app/bsky/feed/getListFeed.ts +50 -0
- package/src/lexicon/types/app/bsky/feed/getPostThread.ts +53 -0
- package/src/lexicon/types/app/bsky/feed/getPosts.ts +46 -0
- package/src/lexicon/types/app/bsky/feed/getRepostedBy.ts +52 -0
- package/src/lexicon/types/app/bsky/feed/getSuggestedFeeds.ts +48 -0
- package/src/lexicon/types/app/bsky/feed/getTimeline.ts +49 -0
- package/src/lexicon/types/app/bsky/feed/like.ts +26 -0
- package/src/lexicon/types/app/bsky/feed/post.ts +102 -0
- package/src/lexicon/types/app/bsky/feed/repost.ts +27 -0
- package/src/lexicon/types/app/bsky/feed/searchPosts.ts +54 -0
- package/src/lexicon/types/app/bsky/feed/threadgate.ts +84 -0
- package/src/lexicon/types/app/bsky/graph/block.ts +26 -0
- package/src/lexicon/types/app/bsky/graph/defs.ts +104 -0
- package/src/lexicon/types/app/bsky/graph/follow.ts +26 -0
- package/src/lexicon/types/app/bsky/graph/getBlocks.ts +48 -0
- package/src/lexicon/types/app/bsky/graph/getFollowers.ts +50 -0
- package/src/lexicon/types/app/bsky/graph/getFollows.ts +50 -0
- package/src/lexicon/types/app/bsky/graph/getList.ts +50 -0
- package/src/lexicon/types/app/bsky/graph/getListBlocks.ts +48 -0
- package/src/lexicon/types/app/bsky/graph/getListMutes.ts +48 -0
- package/src/lexicon/types/app/bsky/graph/getLists.ts +49 -0
- package/src/lexicon/types/app/bsky/graph/getMutes.ts +48 -0
- package/src/lexicon/types/app/bsky/graph/getSuggestedFollowsByActor.ts +46 -0
- package/src/lexicon/types/app/bsky/graph/list.ts +36 -0
- package/src/lexicon/types/app/bsky/graph/listblock.ts +26 -0
- package/src/lexicon/types/app/bsky/graph/listitem.ts +27 -0
- package/src/lexicon/types/app/bsky/graph/muteActor.ts +38 -0
- package/src/lexicon/types/app/bsky/graph/muteActorList.ts +38 -0
- package/src/lexicon/types/app/bsky/graph/unmuteActor.ts +38 -0
- package/src/lexicon/types/app/bsky/graph/unmuteActorList.ts +38 -0
- package/src/lexicon/types/app/bsky/notification/getUnreadCount.ts +45 -0
- package/src/lexicon/types/app/bsky/notification/listNotifications.ts +87 -0
- package/src/lexicon/types/app/bsky/notification/registerPush.ts +41 -0
- package/src/lexicon/types/app/bsky/notification/updateSeen.ts +38 -0
- package/src/lexicon/types/app/bsky/richtext/facet.ts +97 -0
- package/src/lexicon/types/app/bsky/unspecced/defs.ts +41 -0
- package/src/lexicon/types/app/bsky/unspecced/getPopularFeedGenerators.ts +49 -0
- package/src/lexicon/types/app/bsky/unspecced/getTimelineSkeleton.ts +49 -0
- package/src/lexicon/types/app/bsky/unspecced/searchActorsSkeleton.ts +56 -0
- package/src/lexicon/types/app/bsky/unspecced/searchPostsSkeleton.ts +54 -0
- package/src/lexicon/types/com/atproto/admin/defs.ts +719 -0
- package/src/lexicon/types/com/atproto/admin/deleteAccount.ts +38 -0
- package/src/lexicon/types/com/atproto/admin/disableAccountInvites.ts +40 -0
- package/src/lexicon/types/com/atproto/admin/disableInviteCodes.ts +39 -0
- package/src/lexicon/types/com/atproto/admin/emitModerationEvent.ts +66 -0
- package/src/lexicon/types/com/atproto/admin/enableAccountInvites.ts +40 -0
- package/src/lexicon/types/com/atproto/admin/getAccountInfo.ts +41 -0
- package/src/lexicon/types/com/atproto/admin/getAccountInfos.ts +46 -0
- package/src/lexicon/types/com/atproto/admin/getInviteCodes.ts +49 -0
- package/src/lexicon/types/com/atproto/admin/getModerationEvent.ts +41 -0
- package/src/lexicon/types/com/atproto/admin/getRecord.ts +43 -0
- package/src/lexicon/types/com/atproto/admin/getRepo.ts +42 -0
- package/src/lexicon/types/com/atproto/admin/getSubjectStatus.ts +54 -0
- package/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts +56 -0
- package/src/lexicon/types/com/atproto/admin/queryModerationStatuses.ts +72 -0
- package/src/lexicon/types/com/atproto/admin/searchRepos.ts +51 -0
- package/src/lexicon/types/com/atproto/admin/sendEmail.ts +54 -0
- package/src/lexicon/types/com/atproto/admin/updateAccountEmail.ts +40 -0
- package/src/lexicon/types/com/atproto/admin/updateAccountHandle.ts +39 -0
- package/src/lexicon/types/com/atproto/admin/updateSubjectStatus.ts +61 -0
- package/src/lexicon/types/com/atproto/identity/resolveHandle.ts +46 -0
- package/src/lexicon/types/com/atproto/identity/updateHandle.ts +38 -0
- package/src/lexicon/types/com/atproto/label/defs.ts +73 -0
- package/src/lexicon/types/com/atproto/label/queryLabels.ts +52 -0
- package/src/lexicon/types/com/atproto/label/subscribeLabels.ts +67 -0
- package/src/lexicon/types/com/atproto/moderation/createReport.ts +65 -0
- package/src/lexicon/types/com/atproto/moderation/defs.ts +32 -0
- package/src/lexicon/types/com/atproto/repo/applyWrites.ts +103 -0
- package/src/lexicon/types/com/atproto/repo/createRecord.ts +62 -0
- package/src/lexicon/types/com/atproto/repo/deleteRecord.ts +48 -0
- package/src/lexicon/types/com/atproto/repo/describeRepo.ts +50 -0
- package/src/lexicon/types/com/atproto/repo/getRecord.ts +54 -0
- package/src/lexicon/types/com/atproto/repo/listRecords.ts +77 -0
- package/src/lexicon/types/com/atproto/repo/putRecord.ts +64 -0
- package/src/lexicon/types/com/atproto/repo/strongRef.ts +26 -0
- package/src/lexicon/types/com/atproto/repo/uploadBlob.ts +47 -0
- package/src/lexicon/types/com/atproto/server/confirmEmail.ts +40 -0
- package/src/lexicon/types/com/atproto/server/createAccount.ts +69 -0
- package/src/lexicon/types/com/atproto/server/createAppPassword.ts +69 -0
- package/src/lexicon/types/com/atproto/server/createInviteCode.ts +50 -0
- package/src/lexicon/types/com/atproto/server/createInviteCodes.ts +72 -0
- package/src/lexicon/types/com/atproto/server/createSession.ts +58 -0
- package/src/lexicon/types/com/atproto/server/defs.ts +48 -0
- package/src/lexicon/types/com/atproto/server/deleteAccount.ts +41 -0
- package/src/lexicon/types/com/atproto/server/deleteSession.ts +31 -0
- package/src/lexicon/types/com/atproto/server/describeServer.ts +64 -0
- package/src/lexicon/types/com/atproto/server/getAccountInviteCodes.ts +48 -0
- package/src/lexicon/types/com/atproto/server/getSession.ts +47 -0
- package/src/lexicon/types/com/atproto/server/listAppPasswords.ts +62 -0
- package/src/lexicon/types/com/atproto/server/refreshSession.ts +48 -0
- package/src/lexicon/types/com/atproto/server/requestAccountDelete.ts +31 -0
- package/src/lexicon/types/com/atproto/server/requestEmailConfirmation.ts +31 -0
- package/src/lexicon/types/com/atproto/server/requestEmailUpdate.ts +43 -0
- package/src/lexicon/types/com/atproto/server/requestPasswordReset.ts +38 -0
- package/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +51 -0
- package/src/lexicon/types/com/atproto/server/resetPassword.ts +40 -0
- package/src/lexicon/types/com/atproto/server/revokeAppPassword.ts +38 -0
- package/src/lexicon/types/com/atproto/server/updateEmail.ts +41 -0
- package/src/lexicon/types/com/atproto/sync/getBlob.ts +43 -0
- package/src/lexicon/types/com/atproto/sync/getBlocks.ts +42 -0
- package/src/lexicon/types/com/atproto/sync/getCheckout.ts +41 -0
- package/src/lexicon/types/com/atproto/sync/getHead.ts +47 -0
- package/src/lexicon/types/com/atproto/sync/getLatestCommit.ts +48 -0
- package/src/lexicon/types/com/atproto/sync/getRecord.ts +45 -0
- package/src/lexicon/types/com/atproto/sync/getRepo.ts +43 -0
- package/src/lexicon/types/com/atproto/sync/listBlobs.ts +51 -0
- package/src/lexicon/types/com/atproto/sync/listRepos.ts +66 -0
- package/src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts +39 -0
- package/src/lexicon/types/com/atproto/sync/requestCrawl.ts +39 -0
- package/src/lexicon/types/com/atproto/sync/subscribeRepos.ts +161 -0
- package/src/lexicon/types/com/atproto/temp/fetchLabels.ts +47 -0
- package/src/lexicon/types/com/atproto/temp/importRepo.ts +45 -0
- package/src/lexicon/types/com/atproto/temp/pushBlob.ts +39 -0
- package/src/lexicon/types/com/atproto/temp/requestPhoneVerification.ts +38 -0
- package/src/lexicon/types/com/atproto/temp/transferAccount.ts +62 -0
- package/src/lexicon/util.ts +13 -0
- package/src/logger.ts +19 -0
- package/src/mod-service/index.ts +758 -0
- package/src/mod-service/status.ts +264 -0
- package/src/mod-service/subject.ts +136 -0
- package/src/mod-service/types.ts +32 -0
- package/src/mod-service/views.ts +531 -0
- package/src/util.ts +26 -0
- package/test.env +2 -0
- package/test.log +0 -0
- package/tests/__snapshots__/get-record.test.ts.snap +173 -0
- package/tests/__snapshots__/get-repo.test.ts.snap +57 -0
- package/tests/__snapshots__/moderation-events.test.ts.snap +168 -0
- package/tests/__snapshots__/moderation-statuses.test.ts.snap +64 -0
- package/tests/__snapshots__/moderation.test.ts.snap +55 -0
- package/tests/_util.ts +192 -0
- package/tests/db.test.ts +184 -0
- package/tests/get-record.test.ts +110 -0
- package/tests/get-repo.test.ts +131 -0
- package/tests/moderation-appeals.test.ts +269 -0
- package/tests/moderation-events.test.ts +220 -0
- package/tests/moderation-statuses.test.ts +144 -0
- package/tests/moderation.test.ts +961 -0
- package/tests/repo-search.test.ts +123 -0
- package/tests/server.test.ts +76 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { CID } from 'multiformats/cid';
|
|
2
|
+
import { AtUri } from '@atproto/syntax';
|
|
3
|
+
import { Database } from '../../db';
|
|
4
|
+
import { ModerationViews } from './views';
|
|
5
|
+
import { Main as StrongRef } from '../../lexicon/types/com/atproto/repo/strongRef';
|
|
6
|
+
import { RepoRef, RepoBlobRef } from '../../lexicon/types/com/atproto/admin/defs';
|
|
7
|
+
import { ModEventType, ModerationEventRow, ModerationSubjectStatusRow, ReversibleModerationEvent } from './types';
|
|
8
|
+
import { ModerationEvent } from '../../db/schema/moderation_event';
|
|
9
|
+
import AtpAgent from '@atproto/api';
|
|
10
|
+
import { Label } from '../../lexicon/types/com/atproto/label/defs';
|
|
11
|
+
import { ModSubject, RecordSubject, RepoSubject } from './subject';
|
|
12
|
+
export declare class ModerationService {
|
|
13
|
+
db: Database;
|
|
14
|
+
appviewAgent: AtpAgent;
|
|
15
|
+
constructor(db: Database, appviewAgent: AtpAgent);
|
|
16
|
+
static creator(appviewAgent: AtpAgent): (db: Database) => ModerationService;
|
|
17
|
+
views: ModerationViews;
|
|
18
|
+
getEvent(id: number): Promise<ModerationEventRow | undefined>;
|
|
19
|
+
getEventOrThrow(id: number): Promise<ModerationEventRow>;
|
|
20
|
+
getEvents(opts: {
|
|
21
|
+
subject?: string;
|
|
22
|
+
createdBy?: string;
|
|
23
|
+
limit: number;
|
|
24
|
+
cursor?: string;
|
|
25
|
+
includeAllUserRecords: boolean;
|
|
26
|
+
types: ModerationEvent['action'][];
|
|
27
|
+
sortDirection?: 'asc' | 'desc';
|
|
28
|
+
}): Promise<{
|
|
29
|
+
cursor?: string;
|
|
30
|
+
events: ModerationEventRow[];
|
|
31
|
+
}>;
|
|
32
|
+
getReport(id: number): Promise<ModerationEventRow | undefined>;
|
|
33
|
+
getCurrentStatus(subject: {
|
|
34
|
+
did: string;
|
|
35
|
+
} | {
|
|
36
|
+
uri: AtUri;
|
|
37
|
+
} | {
|
|
38
|
+
cids: CID[];
|
|
39
|
+
}): Promise<{
|
|
40
|
+
did: string;
|
|
41
|
+
id: number;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
reviewState: "com.atproto.admin.defs#reviewOpen" | "com.atproto.admin.defs#reviewEscalated" | "com.atproto.admin.defs#reviewClosed";
|
|
45
|
+
blobCids: string[] | null;
|
|
46
|
+
comment: string | null;
|
|
47
|
+
lastReportedAt: string | null;
|
|
48
|
+
lastReviewedAt: string | null;
|
|
49
|
+
muteUntil: string | null;
|
|
50
|
+
lastReviewedBy: string | null;
|
|
51
|
+
takendown: boolean;
|
|
52
|
+
suspendUntil: string | null;
|
|
53
|
+
recordPath: string;
|
|
54
|
+
recordCid: string | null;
|
|
55
|
+
}[]>;
|
|
56
|
+
logEvent(info: {
|
|
57
|
+
event: ModEventType;
|
|
58
|
+
subject: ModSubject;
|
|
59
|
+
createdBy: string;
|
|
60
|
+
createdAt?: Date;
|
|
61
|
+
}): Promise<ModerationEventRow>;
|
|
62
|
+
getLastReversibleEventForSubject(subject: ReversalSubject): Promise<{
|
|
63
|
+
id: number;
|
|
64
|
+
createdBy: string;
|
|
65
|
+
createdAt: string;
|
|
66
|
+
comment: string | null;
|
|
67
|
+
createLabelVals: string | null;
|
|
68
|
+
negateLabelVals: string | null;
|
|
69
|
+
durationInHours: number | null;
|
|
70
|
+
action: "com.atproto.admin.defs#modEventTakedown" | "com.atproto.admin.defs#modEventAcknowledge" | "com.atproto.admin.defs#modEventEscalate" | "com.atproto.admin.defs#modEventComment" | "com.atproto.admin.defs#modEventLabel" | "com.atproto.admin.defs#modEventReport" | "com.atproto.admin.defs#modEventMute" | "com.atproto.admin.defs#modEventReverseTakedown" | "com.atproto.admin.defs#modEventEmail";
|
|
71
|
+
subjectType: "com.atproto.admin.defs#repoRef" | "com.atproto.repo.strongRef";
|
|
72
|
+
subjectDid: string;
|
|
73
|
+
subjectUri: string | null;
|
|
74
|
+
subjectCid: string | null;
|
|
75
|
+
meta: Record<string, string | boolean> | null;
|
|
76
|
+
expiresAt: string | null;
|
|
77
|
+
legacyRefId: number | null;
|
|
78
|
+
} | null | undefined>;
|
|
79
|
+
getSubjectsDueForReversal(): Promise<ReversalSubject[]>;
|
|
80
|
+
isSubjectSuspended(did: string): Promise<boolean>;
|
|
81
|
+
revertState({ createdBy, createdAt, comment, action, subject, }: ReversibleModerationEvent): Promise<ModerationEventRow>;
|
|
82
|
+
takedownRepo(subject: RepoSubject, takedownId: number): Promise<void>;
|
|
83
|
+
reverseTakedownRepo(subject: RepoSubject): Promise<void>;
|
|
84
|
+
takedownRecord(subject: RecordSubject, takedownId: number): Promise<void>;
|
|
85
|
+
reverseTakedownRecord(subject: RecordSubject): Promise<void>;
|
|
86
|
+
report(info: {
|
|
87
|
+
reasonType: NonNullable<ModerationEventRow['meta']>['reportType'];
|
|
88
|
+
reason?: string;
|
|
89
|
+
subject: ModSubject;
|
|
90
|
+
reportedBy: string;
|
|
91
|
+
createdAt?: Date;
|
|
92
|
+
}): Promise<ModerationEventRow>;
|
|
93
|
+
getSubjectStatuses({ cursor, limit, takendown, reviewState, reviewedAfter, reviewedBefore, reportedAfter, reportedBefore, includeMuted, ignoreSubjects, sortDirection, lastReviewedBy, sortField, subject, }: {
|
|
94
|
+
cursor?: string;
|
|
95
|
+
limit?: number;
|
|
96
|
+
takendown?: boolean;
|
|
97
|
+
reviewedBefore?: string;
|
|
98
|
+
reviewState?: ModerationSubjectStatusRow['reviewState'];
|
|
99
|
+
reviewedAfter?: string;
|
|
100
|
+
reportedAfter?: string;
|
|
101
|
+
reportedBefore?: string;
|
|
102
|
+
includeMuted?: boolean;
|
|
103
|
+
subject?: string;
|
|
104
|
+
ignoreSubjects?: string[];
|
|
105
|
+
sortDirection: 'asc' | 'desc';
|
|
106
|
+
lastReviewedBy?: string;
|
|
107
|
+
sortField: 'lastReviewedAt' | 'lastReportedAt';
|
|
108
|
+
}): Promise<{
|
|
109
|
+
statuses: {
|
|
110
|
+
handle: string;
|
|
111
|
+
did: string;
|
|
112
|
+
id: number;
|
|
113
|
+
createdAt: string;
|
|
114
|
+
updatedAt: string;
|
|
115
|
+
reviewState: "com.atproto.admin.defs#reviewOpen" | "com.atproto.admin.defs#reviewEscalated" | "com.atproto.admin.defs#reviewClosed";
|
|
116
|
+
blobCids: string[] | null;
|
|
117
|
+
comment: string | null;
|
|
118
|
+
lastReportedAt: string | null;
|
|
119
|
+
lastReviewedAt: string | null;
|
|
120
|
+
muteUntil: string | null;
|
|
121
|
+
lastReviewedBy: string | null;
|
|
122
|
+
takendown: boolean;
|
|
123
|
+
suspendUntil: string | null;
|
|
124
|
+
recordPath: string;
|
|
125
|
+
recordCid: string | null;
|
|
126
|
+
}[];
|
|
127
|
+
cursor: string | undefined;
|
|
128
|
+
}>;
|
|
129
|
+
isSubjectTakendown(subject: ModSubject): Promise<boolean>;
|
|
130
|
+
formatAndCreateLabels(src: string, uri: string, cid: string | null, labels: {
|
|
131
|
+
create?: string[];
|
|
132
|
+
negate?: string[];
|
|
133
|
+
}): Promise<Label[]>;
|
|
134
|
+
createLabels(labels: Label[]): Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
export declare type TakedownSubjects = {
|
|
137
|
+
did: string;
|
|
138
|
+
subjects: (RepoRef | RepoBlobRef | StrongRef)[];
|
|
139
|
+
};
|
|
140
|
+
export declare type ReversalSubject = {
|
|
141
|
+
subject: ModSubject;
|
|
142
|
+
reverseSuspend: boolean;
|
|
143
|
+
reverseMute: boolean;
|
|
144
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AtUri } from '@atproto/syntax';
|
|
2
|
+
import { Database } from '../../db';
|
|
3
|
+
import { ModerationSubjectStatus } from '../../db/schema/moderation_subject_status';
|
|
4
|
+
import { ModerationEventRow } from './types';
|
|
5
|
+
export declare const adjustModerationSubjectStatus: (db: Database, moderationEvent: ModerationEventRow, blobCids?: string[]) => Promise<import("kysely").InsertResult | null>;
|
|
6
|
+
declare type ModerationSubjectStatusFilter = Pick<ModerationSubjectStatus, 'did'> | Pick<ModerationSubjectStatus, 'did' | 'recordPath'> | Pick<ModerationSubjectStatus, 'did' | 'recordPath' | 'recordCid'>;
|
|
7
|
+
export declare const getModerationSubjectStatus: (db: Database, filters: ModerationSubjectStatusFilter) => Promise<{} | undefined>;
|
|
8
|
+
export declare const getStatusIdentifierFromSubject: (subject: string | AtUri) => {
|
|
9
|
+
did: string;
|
|
10
|
+
recordPath: string;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AtUri } from '@atproto/syntax';
|
|
2
|
+
import { InputSchema as ReportInput } from '../../lexicon/types/com/atproto/moderation/createReport';
|
|
3
|
+
import { InputSchema as ActionInput } from '../../lexicon/types/com/atproto/admin/emitModerationEvent';
|
|
4
|
+
import { ModerationEventRow, ModerationSubjectStatusRow } from './types';
|
|
5
|
+
import { RepoRef } from '../../lexicon/types/com/atproto/admin/defs';
|
|
6
|
+
import { Main as StrongRef } from '../../lexicon/types/com/atproto/repo/strongRef';
|
|
7
|
+
declare type SubjectInput = ReportInput['subject'] | ActionInput['subject'];
|
|
8
|
+
export declare const subjectFromInput: (subject: SubjectInput, blobs?: string[]) => ModSubject;
|
|
9
|
+
export declare const subjectFromEventRow: (row: ModerationEventRow) => ModSubject;
|
|
10
|
+
export declare const subjectFromStatusRow: (row: ModerationSubjectStatusRow) => ModSubject;
|
|
11
|
+
declare type SubjectInfo = {
|
|
12
|
+
subjectType: 'com.atproto.admin.defs#repoRef' | 'com.atproto.repo.strongRef';
|
|
13
|
+
subjectDid: string;
|
|
14
|
+
subjectUri: string | null;
|
|
15
|
+
subjectCid: string | null;
|
|
16
|
+
};
|
|
17
|
+
export interface ModSubject {
|
|
18
|
+
did: string;
|
|
19
|
+
recordPath: string | undefined;
|
|
20
|
+
blobCids?: string[];
|
|
21
|
+
isRepo(): this is RepoSubject;
|
|
22
|
+
isRecord(): this is RecordSubject;
|
|
23
|
+
info(): SubjectInfo;
|
|
24
|
+
lex(): RepoRef | StrongRef;
|
|
25
|
+
}
|
|
26
|
+
export declare class RepoSubject implements ModSubject {
|
|
27
|
+
did: string;
|
|
28
|
+
blobCids: undefined;
|
|
29
|
+
recordPath: undefined;
|
|
30
|
+
constructor(did: string);
|
|
31
|
+
isRepo(): boolean;
|
|
32
|
+
isRecord(): boolean;
|
|
33
|
+
isWeakRecord(): boolean;
|
|
34
|
+
info(): {
|
|
35
|
+
subjectType: "com.atproto.admin.defs#repoRef";
|
|
36
|
+
subjectDid: string;
|
|
37
|
+
subjectUri: null;
|
|
38
|
+
subjectCid: null;
|
|
39
|
+
};
|
|
40
|
+
lex(): RepoRef;
|
|
41
|
+
}
|
|
42
|
+
export declare class RecordSubject implements ModSubject {
|
|
43
|
+
uri: string;
|
|
44
|
+
cid: string;
|
|
45
|
+
blobCids?: string[] | undefined;
|
|
46
|
+
parsedUri: AtUri;
|
|
47
|
+
did: string;
|
|
48
|
+
recordPath: string;
|
|
49
|
+
constructor(uri: string, cid: string, blobCids?: string[] | undefined);
|
|
50
|
+
isRepo(): boolean;
|
|
51
|
+
isRecord(): boolean;
|
|
52
|
+
info(): {
|
|
53
|
+
subjectType: "com.atproto.repo.strongRef";
|
|
54
|
+
subjectDid: string;
|
|
55
|
+
subjectUri: string;
|
|
56
|
+
subjectCid: string;
|
|
57
|
+
};
|
|
58
|
+
lex(): StrongRef;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Selectable } from 'kysely';
|
|
2
|
+
import { ModerationEvent } from '../../db/schema/moderation_event';
|
|
3
|
+
import { ModerationSubjectStatus } from '../../db/schema/moderation_subject_status';
|
|
4
|
+
import { ComAtprotoAdminDefs } from '@atproto/api';
|
|
5
|
+
import { ModSubject } from './subject';
|
|
6
|
+
export declare type ModerationEventRow = Selectable<ModerationEvent>;
|
|
7
|
+
export declare type ReversibleModerationEvent = Pick<ModerationEventRow, 'createdBy' | 'comment' | 'action'> & {
|
|
8
|
+
createdAt?: Date;
|
|
9
|
+
subject: ModSubject;
|
|
10
|
+
};
|
|
11
|
+
export declare type ModerationEventRowWithHandle = ModerationEventRow & {
|
|
12
|
+
subjectHandle?: string | null;
|
|
13
|
+
creatorHandle?: string | null;
|
|
14
|
+
};
|
|
15
|
+
export declare type ModerationSubjectStatusRow = Selectable<ModerationSubjectStatus>;
|
|
16
|
+
export declare type ModerationSubjectStatusRowWithHandle = ModerationSubjectStatusRow & {
|
|
17
|
+
handle: string | null;
|
|
18
|
+
};
|
|
19
|
+
export declare type ModEventType = ComAtprotoAdminDefs.ModEventTakedown | ComAtprotoAdminDefs.ModEventAcknowledge | ComAtprotoAdminDefs.ModEventEscalate | ComAtprotoAdminDefs.ModEventComment | ComAtprotoAdminDefs.ModEventLabel | ComAtprotoAdminDefs.ModEventReport | ComAtprotoAdminDefs.ModEventMute | ComAtprotoAdminDefs.ModEventReverseTakedown;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import AtpAgent from '@atproto/api';
|
|
2
|
+
import { BlobRef } from '@atproto/lexicon';
|
|
3
|
+
import { Database } from '../../db';
|
|
4
|
+
import { ModEventView, RepoView, RepoViewDetail, RecordView, RecordViewDetail, ReportViewDetail, BlobView, SubjectStatusView, ModEventViewDetail, AccountView } from '../../lexicon/types/com/atproto/admin/defs';
|
|
5
|
+
import { OutputSchema as ReportOutput } from '../../lexicon/types/com/atproto/moderation/createReport';
|
|
6
|
+
import { Label } from '../../lexicon/types/com/atproto/label/defs';
|
|
7
|
+
import { ModerationEventRowWithHandle, ModerationSubjectStatusRowWithHandle } from './types';
|
|
8
|
+
export declare class ModerationViews {
|
|
9
|
+
private db;
|
|
10
|
+
private appviewAgent;
|
|
11
|
+
constructor(db: Database, appviewAgent: AtpAgent);
|
|
12
|
+
getAccoutInfosByDid(dids: string[]): Promise<Map<string, AccountView>>;
|
|
13
|
+
repos(dids: string[]): Promise<Map<string, RepoView>>;
|
|
14
|
+
formatEvent(event: ModerationEventRowWithHandle): ModEventView;
|
|
15
|
+
eventDetail(result: ModerationEventRowWithHandle): Promise<ModEventViewDetail>;
|
|
16
|
+
repoDetail(did: string): Promise<RepoViewDetail | undefined>;
|
|
17
|
+
fetchRecords(subjects: RecordSubject[]): Promise<Map<string, {
|
|
18
|
+
uri: string;
|
|
19
|
+
cid: string;
|
|
20
|
+
value: Record<string, unknown>;
|
|
21
|
+
indexedAt: string;
|
|
22
|
+
}>>;
|
|
23
|
+
records(subjects: RecordSubject[]): Promise<Map<string, RecordView>>;
|
|
24
|
+
recordDetail(subject: RecordSubject): Promise<RecordViewDetail | undefined>;
|
|
25
|
+
formatReport(report: ModerationEventRowWithHandle): ReportOutput;
|
|
26
|
+
subject(subject: string): Promise<SubjectView>;
|
|
27
|
+
blob(blobs: BlobRef[]): Promise<BlobView[]>;
|
|
28
|
+
labels(subject: string, includeNeg?: boolean): Promise<Label[]>;
|
|
29
|
+
getSubjectStatus(subjects: string[]): Promise<Map<string, ModerationSubjectStatusRowWithHandle>>;
|
|
30
|
+
formatSubjectStatus(status: ModerationSubjectStatusRowWithHandle): SubjectStatusView;
|
|
31
|
+
}
|
|
32
|
+
declare type RecordSubject = {
|
|
33
|
+
uri: string;
|
|
34
|
+
cid?: string;
|
|
35
|
+
};
|
|
36
|
+
declare type SubjectView = ModEventViewDetail['subject'] & ReportViewDetail['subject'];
|
|
37
|
+
export declare function getSelfLabels(details: {
|
|
38
|
+
uri: string | null;
|
|
39
|
+
cid: string | null;
|
|
40
|
+
record: Record<string, unknown> | null;
|
|
41
|
+
}): Label[];
|
|
42
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function addHoursToDate(hours: number, startingDate?: Date): Date;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const debugCatch: <Func extends (...args: any[]) => any>(fn: Func) => (...args: Parameters<Func>) => Promise<ReturnType<Func>>;
|
package/dist/util.d.ts
ADDED
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atproto/ozone",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Backend service for moderating the Bluesky network.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"atproto",
|
|
8
|
+
"bluesky"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://atproto.com",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/bluesky-social/atproto",
|
|
14
|
+
"directory": "packages/ozone"
|
|
15
|
+
},
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"bin": "dist/bin.js",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@did-plc/lib": "^0.0.1",
|
|
20
|
+
"compression": "^1.7.4",
|
|
21
|
+
"cors": "^2.8.5",
|
|
22
|
+
"express": "^4.17.2",
|
|
23
|
+
"express-async-errors": "^3.1.1",
|
|
24
|
+
"http-terminator": "^3.2.0",
|
|
25
|
+
"kysely": "^0.22.0",
|
|
26
|
+
"multiformats": "^9.9.0",
|
|
27
|
+
"p-queue": "^6.6.2",
|
|
28
|
+
"pg": "^8.10.0",
|
|
29
|
+
"pino": "^8.15.0",
|
|
30
|
+
"pino-http": "^8.2.1",
|
|
31
|
+
"typed-emitter": "^2.1.0",
|
|
32
|
+
"uint8arrays": "3.0.0",
|
|
33
|
+
"@atproto/common": "^0.3.3",
|
|
34
|
+
"@atproto/syntax": "^0.1.5",
|
|
35
|
+
"@atproto/identity": "^0.3.2",
|
|
36
|
+
"@atproto/lexicon": "^0.3.1",
|
|
37
|
+
"@atproto/xrpc-server": "^0.4.2",
|
|
38
|
+
"@atproto/crypto": "^0.3.0",
|
|
39
|
+
"@atproto/api": "^0.9.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@did-plc/server": "^0.0.1",
|
|
43
|
+
"@types/cors": "^2.8.12",
|
|
44
|
+
"@types/express": "^4.17.13",
|
|
45
|
+
"@types/express-serve-static-core": "^4.17.36",
|
|
46
|
+
"@types/pg": "^8.6.6",
|
|
47
|
+
"@types/qs": "^6.9.7",
|
|
48
|
+
"axios": "^0.27.2",
|
|
49
|
+
"@atproto/lex-cli": "^0.3.0",
|
|
50
|
+
"@atproto/api": "^0.9.0",
|
|
51
|
+
"@atproto/xrpc": "^0.4.1",
|
|
52
|
+
"@atproto/dev-env": "^0.2.23",
|
|
53
|
+
"@atproto/pds": "^0.3.11"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"codegen": "lex gen-server ./src/lexicon ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
|
|
57
|
+
"build": "node ./build.js",
|
|
58
|
+
"postbuild": "tsc --build tsconfig.build.json",
|
|
59
|
+
"update-main-to-dist": "node ../../update-main-to-dist.js packages/ozone",
|
|
60
|
+
"start": "node --enable-source-maps dist/bin.js",
|
|
61
|
+
"test": "../dev-infra/with-test-redis-and-db.sh jest",
|
|
62
|
+
"test:log": "tail -50 test.log | pino-pretty",
|
|
63
|
+
"test:updateSnapshot": "jest --updateSnapshot",
|
|
64
|
+
"migration:create": "ts-node ./bin/migration-create.ts"
|
|
65
|
+
},
|
|
66
|
+
"types": "dist/index.d.ts"
|
|
67
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
|
+
import { Server } from '../../lexicon'
|
|
3
|
+
import AppContext from '../../context'
|
|
4
|
+
import {
|
|
5
|
+
isModEventLabel,
|
|
6
|
+
isModEventReverseTakedown,
|
|
7
|
+
isModEventTakedown,
|
|
8
|
+
} from '../../lexicon/types/com/atproto/admin/defs'
|
|
9
|
+
import { subjectFromInput } from '../../mod-service/subject'
|
|
10
|
+
|
|
11
|
+
export default function (server: Server, ctx: AppContext) {
|
|
12
|
+
server.com.atproto.admin.emitModerationEvent({
|
|
13
|
+
auth: ctx.roleVerifier,
|
|
14
|
+
handler: async ({ input, auth }) => {
|
|
15
|
+
const access = auth.credentials
|
|
16
|
+
const db = ctx.db
|
|
17
|
+
const moderationService = ctx.modService(db)
|
|
18
|
+
const { createdBy, event } = input.body
|
|
19
|
+
const isTakedownEvent = isModEventTakedown(event)
|
|
20
|
+
const isReverseTakedownEvent = isModEventReverseTakedown(event)
|
|
21
|
+
const isLabelEvent = isModEventLabel(event)
|
|
22
|
+
const subject = subjectFromInput(
|
|
23
|
+
input.body.subject,
|
|
24
|
+
input.body.subjectBlobCids,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
// apply access rules
|
|
28
|
+
|
|
29
|
+
// if less than moderator access then can not takedown an account
|
|
30
|
+
if (!access.moderator && isTakedownEvent && subject.isRepo()) {
|
|
31
|
+
throw new AuthRequiredError(
|
|
32
|
+
'Must be a full moderator to perform an account takedown',
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
// if less than moderator access then can only take ack and escalation actions
|
|
36
|
+
if (!access.moderator && (isTakedownEvent || isReverseTakedownEvent)) {
|
|
37
|
+
throw new AuthRequiredError(
|
|
38
|
+
'Must be a full moderator to take this type of action',
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
// if less than moderator access then can not apply labels
|
|
42
|
+
if (!access.moderator && isLabelEvent) {
|
|
43
|
+
throw new AuthRequiredError('Must be a full moderator to label content')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (isLabelEvent) {
|
|
47
|
+
validateLabels([
|
|
48
|
+
...(event.createLabelVals ?? []),
|
|
49
|
+
...(event.negateLabelVals ?? []),
|
|
50
|
+
])
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (isTakedownEvent || isReverseTakedownEvent) {
|
|
54
|
+
const isSubjectTakendown = await moderationService.isSubjectTakendown(
|
|
55
|
+
subject,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if (isSubjectTakendown && isTakedownEvent) {
|
|
59
|
+
throw new InvalidRequestError(`Subject is already taken down`)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!isSubjectTakendown && isReverseTakedownEvent) {
|
|
63
|
+
throw new InvalidRequestError(`Subject is not taken down`)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const moderationEvent = await db.transaction(async (dbTxn) => {
|
|
68
|
+
const moderationTxn = ctx.modService(dbTxn)
|
|
69
|
+
|
|
70
|
+
const result = await moderationTxn.logEvent({
|
|
71
|
+
event,
|
|
72
|
+
subject,
|
|
73
|
+
createdBy,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
if (subject.isRepo()) {
|
|
77
|
+
if (isTakedownEvent) {
|
|
78
|
+
const isSuspend = !!result.durationInHours
|
|
79
|
+
await moderationTxn.takedownRepo(subject, result.id, isSuspend)
|
|
80
|
+
} else if (isReverseTakedownEvent) {
|
|
81
|
+
await moderationTxn.reverseTakedownRepo(subject)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (subject.isRecord()) {
|
|
86
|
+
if (isTakedownEvent) {
|
|
87
|
+
await moderationTxn.takedownRecord(subject, result.id)
|
|
88
|
+
} else if (isReverseTakedownEvent) {
|
|
89
|
+
await moderationTxn.reverseTakedownRecord(subject)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (isLabelEvent) {
|
|
94
|
+
await moderationTxn.formatAndCreateLabels(
|
|
95
|
+
ctx.cfg.service.did,
|
|
96
|
+
result.subjectUri ?? result.subjectDid,
|
|
97
|
+
result.subjectCid,
|
|
98
|
+
{
|
|
99
|
+
create: result.createLabelVals?.length
|
|
100
|
+
? result.createLabelVals.split(' ')
|
|
101
|
+
: undefined,
|
|
102
|
+
negate: result.negateLabelVals?.length
|
|
103
|
+
? result.negateLabelVals.split(' ')
|
|
104
|
+
: undefined,
|
|
105
|
+
},
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return result
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
encoding: 'application/json',
|
|
114
|
+
body: moderationService.views.formatEvent(moderationEvent),
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const validateLabels = (labels: string[]) => {
|
|
121
|
+
for (const label of labels) {
|
|
122
|
+
for (const char of badChars) {
|
|
123
|
+
if (label.includes(char)) {
|
|
124
|
+
throw new InvalidRequestError(`Invalid label: ${label}`)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const badChars = [' ', ',', ';', `'`, `"`]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Server } from '../../lexicon'
|
|
2
|
+
import AppContext from '../../context'
|
|
3
|
+
|
|
4
|
+
export default function (server: Server, ctx: AppContext) {
|
|
5
|
+
server.com.atproto.admin.getModerationEvent({
|
|
6
|
+
auth: ctx.roleVerifier,
|
|
7
|
+
handler: async ({ params }) => {
|
|
8
|
+
const { id } = params
|
|
9
|
+
const db = ctx.db
|
|
10
|
+
const modService = ctx.modService(db)
|
|
11
|
+
const event = await modService.getEventOrThrow(id)
|
|
12
|
+
const eventDetail = await modService.views.eventDetail(event)
|
|
13
|
+
return {
|
|
14
|
+
encoding: 'application/json',
|
|
15
|
+
body: eventDetail,
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
|
+
import { Server } from '../../lexicon'
|
|
3
|
+
import AppContext from '../../context'
|
|
4
|
+
import { addAccountInfoToRepoView, getPdsAccountInfo } from './util'
|
|
5
|
+
import { AtUri } from '@atproto/syntax'
|
|
6
|
+
|
|
7
|
+
export default function (server: Server, ctx: AppContext) {
|
|
8
|
+
server.com.atproto.admin.getRecord({
|
|
9
|
+
auth: ctx.roleVerifier,
|
|
10
|
+
handler: async ({ params, auth }) => {
|
|
11
|
+
const db = ctx.db
|
|
12
|
+
|
|
13
|
+
const [record, accountInfo] = await Promise.all([
|
|
14
|
+
ctx.modService(db).views.recordDetail(params),
|
|
15
|
+
getPdsAccountInfo(ctx, new AtUri(params.uri).hostname),
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
if (!record) {
|
|
19
|
+
throw new InvalidRequestError('Record not found', 'RecordNotFound')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
record.repo = addAccountInfoToRepoView(
|
|
23
|
+
record.repo,
|
|
24
|
+
accountInfo,
|
|
25
|
+
auth.credentials.moderator,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
encoding: 'application/json',
|
|
30
|
+
body: record,
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
|
+
import { Server } from '../../lexicon'
|
|
3
|
+
import AppContext from '../../context'
|
|
4
|
+
import { addAccountInfoToRepoViewDetail, getPdsAccountInfo } from './util'
|
|
5
|
+
|
|
6
|
+
export default function (server: Server, ctx: AppContext) {
|
|
7
|
+
server.com.atproto.admin.getRepo({
|
|
8
|
+
auth: ctx.roleVerifier,
|
|
9
|
+
handler: async ({ params, auth }) => {
|
|
10
|
+
const { did } = params
|
|
11
|
+
const db = ctx.db
|
|
12
|
+
const [partialRepo, accountInfo] = await Promise.all([
|
|
13
|
+
ctx.modService(db).views.repoDetail(did),
|
|
14
|
+
getPdsAccountInfo(ctx, did),
|
|
15
|
+
])
|
|
16
|
+
if (!partialRepo) {
|
|
17
|
+
throw new InvalidRequestError('Repo not found', 'RepoNotFound')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const repo = addAccountInfoToRepoViewDetail(
|
|
21
|
+
partialRepo,
|
|
22
|
+
accountInfo,
|
|
23
|
+
auth.credentials.moderator,
|
|
24
|
+
)
|
|
25
|
+
return {
|
|
26
|
+
encoding: 'application/json',
|
|
27
|
+
body: repo,
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Server } from '../../lexicon'
|
|
2
|
+
import AppContext from '../../context'
|
|
3
|
+
import { getEventType } from '../moderation/util'
|
|
4
|
+
|
|
5
|
+
export default function (server: Server, ctx: AppContext) {
|
|
6
|
+
server.com.atproto.admin.queryModerationEvents({
|
|
7
|
+
auth: ctx.roleVerifier,
|
|
8
|
+
handler: async ({ params }) => {
|
|
9
|
+
const {
|
|
10
|
+
subject,
|
|
11
|
+
limit = 50,
|
|
12
|
+
cursor,
|
|
13
|
+
sortDirection = 'desc',
|
|
14
|
+
types,
|
|
15
|
+
includeAllUserRecords = false,
|
|
16
|
+
createdBy,
|
|
17
|
+
} = params
|
|
18
|
+
const db = ctx.db
|
|
19
|
+
const modService = ctx.modService(db)
|
|
20
|
+
const results = await modService.getEvents({
|
|
21
|
+
types: types?.length ? types.map(getEventType) : [],
|
|
22
|
+
subject,
|
|
23
|
+
createdBy,
|
|
24
|
+
limit,
|
|
25
|
+
cursor,
|
|
26
|
+
sortDirection,
|
|
27
|
+
includeAllUserRecords,
|
|
28
|
+
})
|
|
29
|
+
return {
|
|
30
|
+
encoding: 'application/json',
|
|
31
|
+
body: {
|
|
32
|
+
cursor: results.cursor,
|
|
33
|
+
events: results.events.map((evt) =>
|
|
34
|
+
modService.views.formatEvent(evt),
|
|
35
|
+
),
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
}
|