@atproto/pds 0.5.1 → 0.5.3
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 +22 -0
- package/dist/account-manager/account-manager.d.ts +35 -4
- package/dist/account-manager/account-manager.d.ts.map +1 -1
- package/dist/account-manager/account-manager.js +67 -6
- package/dist/account-manager/account-manager.js.map +1 -1
- package/dist/account-manager/helpers/account.d.ts +1 -1
- package/dist/account-manager/helpers/account.d.ts.map +1 -1
- package/dist/account-manager/helpers/account.js +10 -4
- package/dist/account-manager/helpers/account.js.map +1 -1
- package/dist/account-manager/oauth-store.d.ts +2 -1
- package/dist/account-manager/oauth-store.d.ts.map +1 -1
- package/dist/account-manager/oauth-store.js +61 -12
- package/dist/account-manager/oauth-store.js.map +1 -1
- package/dist/actor-store/record/reader.d.ts +1 -1
- package/dist/actor-store/record/reader.d.ts.map +1 -1
- package/dist/actor-store/record/reader.js.map +1 -1
- package/dist/api/com/atproto/admin/updateAccountHandle.d.ts.map +1 -1
- package/dist/api/com/atproto/admin/updateAccountHandle.js +33 -43
- package/dist/api/com/atproto/admin/updateAccountHandle.js.map +1 -1
- package/dist/api/com/atproto/identity/updateHandle.d.ts.map +1 -1
- package/dist/api/com/atproto/identity/updateHandle.js +39 -61
- package/dist/api/com/atproto/identity/updateHandle.js.map +1 -1
- package/dist/api/com/atproto/repo/getRecord.js +3 -3
- package/dist/api/com/atproto/repo/getRecord.js.map +1 -1
- package/dist/api/com/atproto/repo/putRecord.js +2 -2
- package/dist/api/com/atproto/repo/putRecord.js.map +1 -1
- package/dist/api/com/atproto/sync/getRepo.d.ts.map +1 -1
- package/dist/api/com/atproto/sync/getRepo.js +17 -9
- package/dist/api/com/atproto/sync/getRepo.js.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +2 -2
- package/dist/context.js.map +1 -1
- package/dist/lexicons/app/bsky/actor/defs.defs.d.ts +8 -0
- package/dist/lexicons/app/bsky/actor/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/actor/defs.defs.js +3 -0
- package/dist/lexicons/app/bsky/actor/defs.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/actor/profile.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/actor/status.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/draft/defs.defs.d.ts +22 -0
- package/dist/lexicons/app/bsky/draft/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/draft/defs.defs.js +11 -0
- package/dist/lexicons/app/bsky/draft/defs.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/embed/gallery.d.ts +3 -0
- package/dist/lexicons/app/bsky/embed/gallery.d.ts.map +1 -0
- package/dist/lexicons/app/bsky/embed/gallery.defs.d.ts +130 -0
- package/dist/lexicons/app/bsky/embed/gallery.defs.d.ts.map +1 -0
- package/dist/lexicons/app/bsky/embed/gallery.defs.js +47 -0
- package/dist/lexicons/app/bsky/embed/gallery.defs.js.map +1 -0
- package/dist/lexicons/app/bsky/embed/gallery.js +6 -0
- package/dist/lexicons/app/bsky/embed/gallery.js.map +1 -0
- package/dist/lexicons/app/bsky/embed/record.defs.d.ts +2 -1
- package/dist/lexicons/app/bsky/embed/record.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/embed/record.defs.js +2 -0
- package/dist/lexicons/app/bsky/embed/record.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/embed/recordWithMedia.defs.d.ts +13 -12
- package/dist/lexicons/app/bsky/embed/recordWithMedia.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/embed/recordWithMedia.defs.js +3 -0
- package/dist/lexicons/app/bsky/embed/recordWithMedia.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/embed.d.ts +1 -0
- package/dist/lexicons/app/bsky/embed.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/embed.js +1 -0
- package/dist/lexicons/app/bsky/embed.js.map +1 -1
- package/dist/lexicons/app/bsky/feed/defs.defs.d.ts +2 -1
- package/dist/lexicons/app/bsky/feed/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/defs.defs.js +2 -0
- package/dist/lexicons/app/bsky/feed/defs.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/feed/generator.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/like.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/post.defs.d.ts +12 -11
- package/dist/lexicons/app/bsky/feed/post.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/post.defs.js +2 -0
- package/dist/lexicons/app/bsky/feed/post.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/feed/postgate.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/repost.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/threadgate.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/graph/block.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/graph/follow.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/graph/list.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/graph/listblock.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/graph/listitem.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/graph/starterpack.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/graph/verification.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/labeler/service.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/notification/declaration.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/actor/declaration.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/authFullChatClient.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/authFullChatClient.defs.js +1 -0
- package/dist/lexicons/chat/bsky/authFullChatClient.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/convo/defs.defs.d.ts +57 -14
- package/dist/lexicons/chat/bsky/convo/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/convo/defs.defs.js +34 -5
- package/dist/lexicons/chat/bsky/convo/defs.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/convo/getConvoForMembers.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/convo/getConvoForMembers.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/convo/getConvoForMembers.defs.js +1 -0
- package/dist/lexicons/chat/bsky/convo/getConvoForMembers.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/convo/getLog.defs.d.ts +2 -2
- package/dist/lexicons/chat/bsky/convo/getLog.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/convo/getLog.defs.js +3 -0
- package/dist/lexicons/chat/bsky/convo/getLog.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.d.ts +3 -0
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.d.ts +23 -0
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.js +19 -0
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.js +6 -0
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.js.map +1 -0
- package/dist/lexicons/chat/bsky/convo/unlockConvo.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/convo/unlockConvo.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/convo/unlockConvo.defs.js +1 -0
- package/dist/lexicons/chat/bsky/convo/unlockConvo.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/convo.d.ts +1 -0
- package/dist/lexicons/chat/bsky/convo.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/convo.js +1 -0
- package/dist/lexicons/chat/bsky/convo.js.map +1 -1
- package/dist/lexicons/chat/bsky/embed/joinLink.d.ts +3 -0
- package/dist/lexicons/chat/bsky/embed/joinLink.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/embed/joinLink.defs.d.ts +99 -0
- package/dist/lexicons/chat/bsky/embed/joinLink.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/embed/joinLink.defs.js +32 -0
- package/dist/lexicons/chat/bsky/embed/joinLink.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/embed/joinLink.js +6 -0
- package/dist/lexicons/chat/bsky/embed/joinLink.js.map +1 -0
- package/dist/lexicons/chat/bsky/embed.d.ts +2 -0
- package/dist/lexicons/chat/bsky/embed.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/embed.js +5 -0
- package/dist/lexicons/chat/bsky/embed.js.map +1 -0
- package/dist/lexicons/chat/bsky/group/addMembers.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/addMembers.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/addMembers.defs.js +1 -0
- package/dist/lexicons/chat/bsky/group/addMembers.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/createGroup.defs.d.ts +6 -6
- package/dist/lexicons/chat/bsky/group/createGroup.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/createGroup.defs.js +4 -3
- package/dist/lexicons/chat/bsky/group/createGroup.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/defs.defs.d.ts +26 -2
- package/dist/lexicons/chat/bsky/group/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/defs.defs.js +15 -2
- package/dist/lexicons/chat/bsky/group/defs.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.d.ts +3 -3
- package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.js +6 -2
- package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.d.ts +3 -0
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.d.ts +20 -0
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.js +19 -0
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.js +6 -0
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.js.map +1 -0
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.d.ts +3 -0
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.d.ts +20 -0
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.js +18 -0
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.js +6 -0
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.js.map +1 -0
- package/dist/lexicons/chat/bsky/group.d.ts +2 -0
- package/dist/lexicons/chat/bsky/group.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group.js +2 -0
- package/dist/lexicons/chat/bsky/group.js.map +1 -1
- package/dist/lexicons/chat/bsky/moderation/defs.d.ts +2 -0
- package/dist/lexicons/chat/bsky/moderation/defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/defs.defs.d.ts +58 -0
- package/dist/lexicons/chat/bsky/moderation/defs.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/defs.defs.js +38 -0
- package/dist/lexicons/chat/bsky/moderation/defs.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/defs.js +5 -0
- package/dist/lexicons/chat/bsky/moderation/defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvo.d.ts +3 -0
- package/dist/lexicons/chat/bsky/moderation/getConvo.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvo.defs.d.ts +22 -0
- package/dist/lexicons/chat/bsky/moderation/getConvo.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvo.defs.js +18 -0
- package/dist/lexicons/chat/bsky/moderation/getConvo.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvo.js +6 -0
- package/dist/lexicons/chat/bsky/moderation/getConvo.js.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.d.ts +3 -0
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.d.ts +28 -0
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.js +24 -0
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.js +6 -0
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.js.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvos.d.ts +3 -0
- package/dist/lexicons/chat/bsky/moderation/getConvos.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvos.defs.d.ts +22 -0
- package/dist/lexicons/chat/bsky/moderation/getConvos.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvos.defs.js +22 -0
- package/dist/lexicons/chat/bsky/moderation/getConvos.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/getConvos.js +6 -0
- package/dist/lexicons/chat/bsky/moderation/getConvos.js.map +1 -0
- package/dist/lexicons/chat/bsky/moderation/subscribeModEvents.defs.d.ts +21 -3
- package/dist/lexicons/chat/bsky/moderation/subscribeModEvents.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/moderation/subscribeModEvents.defs.js +11 -0
- package/dist/lexicons/chat/bsky/moderation/subscribeModEvents.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/moderation.d.ts +4 -0
- package/dist/lexicons/chat/bsky/moderation.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/moderation.js +4 -0
- package/dist/lexicons/chat/bsky/moderation.js.map +1 -1
- package/dist/lexicons/chat/bsky.d.ts +1 -0
- package/dist/lexicons/chat/bsky.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky.js +1 -0
- package/dist/lexicons/chat/bsky.js.map +1 -1
- package/dist/lexicons/com/atproto/lexicon/schema.defs.d.ts.map +1 -1
- package/dist/lexicons/com/germnetwork/declaration.defs.d.ts.map +1 -1
- package/dist/lexicons/index.d.ts +1 -0
- package/dist/lexicons/index.d.ts.map +1 -1
- package/dist/lexicons/index.js +1 -0
- package/dist/lexicons/index.js.map +1 -1
- package/dist/lexicons/internal/bsky/actor/getProfiles.d.ts +3 -0
- package/dist/lexicons/internal/bsky/actor/getProfiles.d.ts.map +1 -0
- package/dist/lexicons/internal/bsky/actor/getProfiles.defs.d.ts +38 -0
- package/dist/lexicons/internal/bsky/actor/getProfiles.defs.d.ts.map +1 -0
- package/dist/lexicons/internal/bsky/actor/getProfiles.defs.js +26 -0
- package/dist/lexicons/internal/bsky/actor/getProfiles.defs.js.map +1 -0
- package/dist/lexicons/internal/bsky/actor/getProfiles.js +6 -0
- package/dist/lexicons/internal/bsky/actor/getProfiles.js.map +1 -0
- package/dist/lexicons/internal/bsky/actor.d.ts +2 -0
- package/dist/lexicons/internal/bsky/actor.d.ts.map +1 -0
- package/dist/lexicons/internal/bsky/actor.js +5 -0
- package/dist/lexicons/internal/bsky/actor.js.map +1 -0
- package/dist/lexicons/internal/bsky.d.ts +2 -0
- package/dist/lexicons/internal/bsky.d.ts.map +1 -0
- package/dist/lexicons/internal/bsky.js +5 -0
- package/dist/lexicons/internal/bsky.js.map +1 -0
- package/dist/lexicons/internal.d.ts +2 -0
- package/dist/lexicons/internal.d.ts.map +1 -0
- package/dist/lexicons/internal.js +5 -0
- package/dist/lexicons/internal.js.map +1 -0
- package/dist/lexicons/site/standard/document.defs.d.ts.map +1 -1
- package/dist/lexicons/site/standard/graph/recommend.defs.d.ts.map +1 -1
- package/dist/lexicons/site/standard/graph/subscription.defs.d.ts.map +1 -1
- package/dist/lexicons/site/standard/publication.defs.d.ts.map +1 -1
- package/dist/lexicons/site/standard/theme/basic.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/moderation/defs.defs.d.ts +11 -3
- package/dist/lexicons/tools/ozone/moderation/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/moderation/defs.defs.js +9 -0
- package/dist/lexicons/tools/ozone/moderation/defs.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/moderation/queryEvents.defs.d.ts +2 -2
- package/dist/lexicons/tools/ozone/moderation/queryEvents.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/moderation/queryEvents.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/moderation/queryStatuses.defs.d.ts +2 -2
- package/dist/lexicons/tools/ozone/moderation/queryStatuses.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/moderation/queryStatuses.defs.js.map +1 -1
- package/dist/read-after-write/viewer.d.ts +2 -2
- package/package.json +12 -12
- package/src/account-manager/account-manager.ts +105 -7
- package/src/account-manager/helpers/account.ts +15 -7
- package/src/account-manager/oauth-store.ts +76 -18
- package/src/actor-store/record/reader.ts +1 -1
- package/src/api/com/atproto/admin/updateAccountHandle.ts +37 -46
- package/src/api/com/atproto/identity/updateHandle.ts +45 -76
- package/src/api/com/atproto/repo/getRecord.ts +3 -3
- package/src/api/com/atproto/repo/putRecord.ts +2 -2
- package/src/api/com/atproto/sync/getRepo.ts +18 -9
- package/src/context.ts +12 -9
- package/tests/_puppeteer.ts +8 -2
- package/tests/account-manager.test.ts +200 -49
- package/tests/oauth.test.ts +5 -5
- package/tsconfig.build.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +2 -2
- package/tsconfig.tests.json +2 -2
|
@@ -1,75 +1,53 @@
|
|
|
1
1
|
import { DAY, MINUTE } from '@atproto/common';
|
|
2
|
-
import { InvalidRequestError } from '@atproto/xrpc-server';
|
|
3
2
|
import { com } from '../../../../lexicons/index.js';
|
|
4
|
-
import { httpLogger } from '../../../../logger.js';
|
|
5
3
|
export default function (server, ctx) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
4
|
+
const { entrywayClient } = ctx;
|
|
5
|
+
const auth = ctx.authVerifier.authorization({
|
|
6
|
+
checkTakedown: true,
|
|
7
|
+
authorize: (permissions) => {
|
|
8
|
+
permissions.assertIdentity({ attr: 'handle' });
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
const rateLimit = [
|
|
12
|
+
{
|
|
13
|
+
durationMs: 5 * MINUTE,
|
|
14
|
+
points: 10,
|
|
15
|
+
calcKey: ({ auth }) => auth.credentials.did,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
durationMs: DAY,
|
|
19
|
+
points: 50,
|
|
20
|
+
calcKey: ({ auth }) => auth.credentials.did,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
if (entrywayClient) {
|
|
24
|
+
server.add(com.atproto.identity.updateHandle, {
|
|
25
|
+
auth,
|
|
26
|
+
rateLimit,
|
|
27
|
+
handler: async ({ auth, input, req }) => {
|
|
28
28
|
const { headers } = await ctx.entrywayAuthHeaders(req, auth.credentials.did, com.atproto.identity.updateHandle.$lxm);
|
|
29
|
-
//
|
|
29
|
+
// The full flow is:
|
|
30
30
|
// -> entryway(identity.updateHandle) [update handle, submit plc op]
|
|
31
31
|
// -> pds(admin.updateAccountHandle) [track handle, sequence handle update]
|
|
32
|
-
await
|
|
32
|
+
await entrywayClient.xrpc(com.atproto.identity.updateHandle, {
|
|
33
33
|
headers,
|
|
34
34
|
body: {
|
|
35
35
|
handle: input.body.handle,
|
|
36
36
|
// @ts-expect-error "did" is not in the schema
|
|
37
|
-
did:
|
|
37
|
+
did: auth.credentials.did,
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const resolved = await ctx.idResolver.did.resolveAtprotoData(requester, true);
|
|
53
|
-
if (resolved.handle !== handle) {
|
|
54
|
-
throw new InvalidRequestError('DID is not properly configured for handle');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
await ctx.accountManager.updateHandle(requester, handle);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// if we found an account with matching handle, check if it is the same as requester
|
|
61
|
-
// if so emit an identity event, otherwise error.
|
|
62
|
-
if (account.did !== requester) {
|
|
63
|
-
throw new InvalidRequestError(`Handle already taken: ${handle}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
try {
|
|
67
|
-
await ctx.sequencer.sequenceIdentityEvt(requester, handle);
|
|
68
|
-
}
|
|
69
|
-
catch (err) {
|
|
70
|
-
httpLogger.error({ err, did: requester, handle }, 'failed to sequence handle update');
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
});
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
server.add(com.atproto.identity.updateHandle, {
|
|
45
|
+
auth,
|
|
46
|
+
rateLimit,
|
|
47
|
+
handler: async ({ auth, input }) => {
|
|
48
|
+
await ctx.accountManager.updateHandle(auth.credentials.did, input.body.handle);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
74
52
|
}
|
|
75
53
|
//# sourceMappingURL=updateHandle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateHandle.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/identity/updateHandle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"updateHandle.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/identity/updateHandle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAI7C,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAEnD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;IAE9B,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC;QAC1C,aAAa,EAAE,IAAI;QACnB,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE;YACzB,WAAW,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;QAChD,CAAC;KACF,CAAC,CAAA;IAEF,MAAM,SAAS,GAAgD;QAC7D;YACE,UAAU,EAAE,CAAC,GAAG,MAAM;YACtB,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG;SAC5C;QACD;YACE,UAAU,EAAE,GAAG;YACf,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,CAAC,EA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\nimport { MethodRateLimit, Server } from '@atproto/xrpc-server'\nimport { AccessOutput, OAuthOutput } from '../../../../auth-output.js'\nimport { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { entrywayClient } = ctx\n\n const auth = ctx.authVerifier.authorization({\n checkTakedown: true,\n authorize: (permissions) => {\n permissions.assertIdentity({ attr: 'handle' })\n },\n })\n\n const rateLimit: MethodRateLimit<AccessOutput | OAuthOutput> = [\n {\n durationMs: 5 * MINUTE,\n points: 10,\n calcKey: ({ auth }) => auth.credentials.did,\n },\n {\n durationMs: DAY,\n points: 50,\n calcKey: ({ auth }) => auth.credentials.did,\n },\n ]\n\n if (entrywayClient) {\n server.add(com.atproto.identity.updateHandle, {\n auth,\n rateLimit,\n handler: async ({ auth, input, req }) => {\n const { headers } = await ctx.entrywayAuthHeaders(\n req,\n auth.credentials.did,\n com.atproto.identity.updateHandle.$lxm,\n )\n\n // The full flow is:\n // -> entryway(identity.updateHandle) [update handle, submit plc op]\n // -> pds(admin.updateAccountHandle) [track handle, sequence handle update]\n await entrywayClient.xrpc(com.atproto.identity.updateHandle, {\n headers,\n body: {\n handle: input.body.handle,\n // @ts-expect-error \"did\" is not in the schema\n did: auth.credentials.did,\n },\n })\n },\n })\n } else {\n server.add(com.atproto.identity.updateHandle, {\n auth,\n rateLimit,\n handler: async ({ auth, input }) => {\n await ctx.accountManager.updateHandle(\n auth.credentials.did,\n input.body.handle,\n )\n },\n })\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { atUri } from '@atproto/lex';
|
|
2
2
|
import { InvalidRequestError } from '@atproto/xrpc-server';
|
|
3
3
|
import { com } from '../../../../lexicons/index.js';
|
|
4
4
|
import { pipethrough } from '../../../../pipethrough.js';
|
|
@@ -8,7 +8,7 @@ export default function (server, ctx) {
|
|
|
8
8
|
const did = await ctx.accountManager.getDidForActor(repo);
|
|
9
9
|
// fetch from pds if available, if not then fetch from appview
|
|
10
10
|
if (did) {
|
|
11
|
-
const uri =
|
|
11
|
+
const uri = atUri(did, collection, rkey);
|
|
12
12
|
const record = await ctx.actorStore.read(did, (store) => store.record.getRecord(uri, cid ?? null));
|
|
13
13
|
if (!record || record.takedownRef !== null) {
|
|
14
14
|
throw new InvalidRequestError(`Could not locate record: ${uri}`, 'RecordNotFound');
|
|
@@ -16,7 +16,7 @@ export default function (server, ctx) {
|
|
|
16
16
|
return {
|
|
17
17
|
encoding: 'application/json',
|
|
18
18
|
body: {
|
|
19
|
-
uri
|
|
19
|
+
uri,
|
|
20
20
|
cid: record.cid,
|
|
21
21
|
value: record.value,
|
|
22
22
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRecord.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/repo/getRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getRecord.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/repo/getRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,mBAAmB,EAAU,MAAM,sBAAsB,CAAA;AAElE,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE;QAC/D,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAA;QAC9C,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;QAEzD,8DAA8D;QAC9D,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;YACxC,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CACtD,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,CACzC,CAAA;YACD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;gBAC3C,MAAM,IAAI,mBAAmB,CAC3B,4BAA4B,GAAG,EAAE,EACjC,gBAAgB,CACjB,CAAA;YACH,CAAC;YACD,OAAO;gBACL,QAAQ,EAAE,kBAA2B;gBACrC,IAAI,EAAE;oBACJ,GAAG;oBACH,GAAG,EAAE,MAAM,CAAC,GAAG;oBACf,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB;aACF,CAAA;QACH,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;YACzB,MAAM,IAAI,mBAAmB,CAAC,yBAAyB,CAAC,CAAA;QAC1D,CAAC;QAED,OAAO,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { atUri } from '@atproto/lex'\nimport { InvalidRequestError, Server } from '@atproto/xrpc-server'\nimport { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { pipethrough } from '../../../../pipethrough.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.repo.getRecord, async ({ req, params }) => {\n const { repo, collection, rkey, cid } = params\n const did = await ctx.accountManager.getDidForActor(repo)\n\n // fetch from pds if available, if not then fetch from appview\n if (did) {\n const uri = atUri(did, collection, rkey)\n const record = await ctx.actorStore.read(did, (store) =>\n store.record.getRecord(uri, cid ?? null),\n )\n if (!record || record.takedownRef !== null) {\n throw new InvalidRequestError(\n `Could not locate record: ${uri}`,\n 'RecordNotFound',\n )\n }\n return {\n encoding: 'application/json' as const,\n body: {\n uri,\n cid: record.cid,\n value: record.value,\n },\n }\n }\n\n if (!ctx.cfg.bskyAppView) {\n throw new InvalidRequestError(`Could not locate record`)\n }\n\n return pipethrough(ctx, req)\n })\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { atUri } from '@atproto/lex';
|
|
1
2
|
import { isLegacyBlobRef, parseCid, } from '@atproto/lex-data';
|
|
2
|
-
import { AtUri } from '@atproto/syntax';
|
|
3
3
|
import { AuthRequiredError, InvalidRequestError, } from '@atproto/xrpc-server';
|
|
4
4
|
import { app, com } from '../../../../lexicons/index.js';
|
|
5
5
|
import { dbLogger } from '../../../../logger.js';
|
|
@@ -56,7 +56,7 @@ export default function (server, ctx) {
|
|
|
56
56
|
collection,
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
const uri =
|
|
59
|
+
const uri = atUri(did, collection, rkey);
|
|
60
60
|
const swapCommitCid = swapCommit ? parseCid(swapCommit) : undefined;
|
|
61
61
|
const swapRecordCid = typeof swapRecord === 'string' ? parseCid(swapRecord) : swapRecord;
|
|
62
62
|
const { commit, write } = await ctx.actorStore.transact(did, async (actorTxn) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"putRecord.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/repo/putRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,eAAe,EACf,QAAQ,GACT,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAE,QAAQ,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CAAC,MAAM,GAAG,MAAM,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACpE,CAAC;AACH,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC9B,UAAgC,EAChC,UAAyB;IAEzB,MAAM,GAAG,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACpC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;IAC5D,OAAO;QACL,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,GAAG;QACH,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAA;AACH,CAAC","sourcesContent":["import {\n LegacyBlobRef,\n LexMap,\n TypedBlobRef,\n isLegacyBlobRef,\n parseCid,\n} from '@atproto/lex-data'\nimport { AtUri } from '@atproto/syntax'\nimport {\n AuthRequiredError,\n InvalidRequestError,\n Server,\n} from '@atproto/xrpc-server'\nimport { ActorStoreTransactor } from '../../../../actor-store/actor-store-transactor.js'\nimport { AppContext } from '../../../../context.js'\nimport { app, com } from '../../../../lexicons/index.js'\nimport { dbLogger } from '../../../../logger.js'\nimport {\n BadCommitSwapError,\n BadRecordSwapError,\n InvalidRecordError,\n PreparedCreate,\n PreparedUpdate,\n prepareCreate,\n prepareUpdate,\n} from '../../../../repo/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.repo.putRecord, {\n auth: ctx.authVerifier.authorization({\n // @NOTE the \"checkTakedown\" and \"checkDeactivated\" checks are typically\n // performed during auth. However, since this method's \"repo\" parameter\n // can be a handle, we will need to fetch the account again to ensure that\n // the handle matches the DID from the request's credentials. In order to\n // avoid fetching the account twice (during auth, and then again in the\n // controller), the checks are disabled here:\n\n // checkTakedown: true,\n // checkDeactivated: true,\n authorize: () => {\n // Performed in the handler as it requires the request body\n },\n }),\n rateLimit: [\n {\n name: 'repo-write-hour',\n calcKey: ({ auth }) => auth.credentials.did,\n calcPoints: () => 2,\n },\n {\n name: 'repo-write-day',\n calcKey: ({ auth }) => auth.credentials.did,\n calcPoints: () => 2,\n },\n ],\n opts: {\n jsonLimit: 1_000_000,\n },\n handler: async ({ auth, input }) => {\n const {\n repo,\n collection,\n rkey,\n record,\n validate,\n swapCommit,\n swapRecord,\n } = input.body\n\n const account = await ctx.authVerifier.findAccount(repo, {\n checkDeactivated: true,\n checkTakedown: true,\n })\n\n const did = account.did\n if (did !== auth.credentials.did) {\n throw new AuthRequiredError()\n }\n\n // We can't compute permissions based on the request payload (\"input\") in\n // the 'auth' phase, so we do it here.\n if (auth.credentials.type === 'oauth') {\n auth.credentials.permissions.assertRepo({\n action: 'create',\n collection,\n })\n auth.credentials.permissions.assertRepo({\n action: 'update',\n collection,\n })\n }\n\n const uri = AtUri.make(did, collection, rkey)\n const swapCommitCid = swapCommit ? parseCid(swapCommit) : undefined\n const swapRecordCid =\n typeof swapRecord === 'string' ? parseCid(swapRecord) : swapRecord\n\n const { commit, write } = await ctx.actorStore.transact(\n did,\n async (actorTxn) => {\n const current = await actorTxn.record.getRecord(uri, null, true)\n const isUpdate = current !== null\n\n // @TODO temporaray hack for legacy blob refs in profiles - remove after migrating legacy blobs\n if (isUpdate && collection === app.bsky.actor.profile.$type) {\n await updateProfileLegacyBlobRef(actorTxn, record)\n }\n\n const writeInfo = {\n did,\n collection,\n rkey,\n record,\n swapCid: swapRecordCid,\n validate,\n }\n\n let write: PreparedCreate | PreparedUpdate\n try {\n write = isUpdate\n ? await prepareUpdate(writeInfo)\n : await prepareCreate(writeInfo)\n } catch (err) {\n if (err instanceof InvalidRecordError) {\n throw new InvalidRequestError(err.message)\n }\n throw err\n }\n\n // no-op\n if (current && current.cid === write.cid.toString()) {\n return {\n commit: null,\n write,\n }\n }\n\n const commit = await actorTxn.repo\n .processWrites([write], swapCommitCid)\n .catch((err) => {\n if (\n err instanceof BadCommitSwapError ||\n err instanceof BadRecordSwapError\n ) {\n throw new InvalidRequestError(err.message, 'InvalidSwap')\n } else {\n throw err\n }\n })\n\n await ctx.sequencer.sequenceCommit(did, commit)\n\n return { commit, write }\n },\n )\n\n if (commit !== null) {\n await ctx.accountManager\n .updateRepoRoot(did, commit.cid, commit.rev)\n .catch((err) => {\n dbLogger.error(\n { err, did, cid: commit.cid, rev: commit.rev },\n 'failed to update account root',\n )\n })\n }\n\n return {\n encoding: 'application/json',\n body: {\n uri: write.uri.toString(),\n cid: write.cid.toString(),\n commit: commit\n ? {\n cid: commit.cid.toString(),\n rev: commit.rev,\n }\n : undefined,\n validationStatus: write.validationStatus,\n },\n }\n },\n })\n}\n\n// WARNING: mutates object\nasync function updateProfileLegacyBlobRef(\n actorStore: ActorStoreTransactor,\n record: LexMap,\n): Promise<void> {\n if (isLegacyBlobRef(record.avatar)) {\n record.avatar = await upgradeLegacyBlob(actorStore, record.avatar)\n }\n if (isLegacyBlobRef(record.banner)) {\n record.banner = await upgradeLegacyBlob(actorStore, record.banner)\n }\n}\n\nasync function upgradeLegacyBlob(\n actorStore: ActorStoreTransactor,\n legacyBlob: LegacyBlobRef,\n): Promise<TypedBlobRef> {\n const ref = parseCid(legacyBlob.cid)\n const blob = await actorStore.repo.blob.getBlobMetadata(ref)\n return {\n $type: 'blob',\n mimeType: legacyBlob.mimeType,\n ref,\n size: blob.size,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"putRecord.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/repo/putRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAIL,eAAe,EACf,QAAQ,GACT,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAA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B,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACpE,CAAC;AACH,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC9B,UAAgC,EAChC,UAAyB;IAEzB,MAAM,GAAG,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACpC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;IAC5D,OAAO;QACL,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,GAAG;QACH,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAA;AACH,CAAC","sourcesContent":["import { atUri } from '@atproto/lex'\nimport {\n LegacyBlobRef,\n LexMap,\n TypedBlobRef,\n isLegacyBlobRef,\n parseCid,\n} from '@atproto/lex-data'\nimport {\n AuthRequiredError,\n InvalidRequestError,\n Server,\n} from '@atproto/xrpc-server'\nimport { ActorStoreTransactor } from '../../../../actor-store/actor-store-transactor.js'\nimport { AppContext } from '../../../../context.js'\nimport { app, com } from '../../../../lexicons/index.js'\nimport { dbLogger } from '../../../../logger.js'\nimport {\n BadCommitSwapError,\n BadRecordSwapError,\n InvalidRecordError,\n PreparedCreate,\n PreparedUpdate,\n prepareCreate,\n prepareUpdate,\n} from '../../../../repo/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.repo.putRecord, {\n auth: ctx.authVerifier.authorization({\n // @NOTE the \"checkTakedown\" and \"checkDeactivated\" checks are typically\n // performed during auth. However, since this method's \"repo\" parameter\n // can be a handle, we will need to fetch the account again to ensure that\n // the handle matches the DID from the request's credentials. In order to\n // avoid fetching the account twice (during auth, and then again in the\n // controller), the checks are disabled here:\n\n // checkTakedown: true,\n // checkDeactivated: true,\n authorize: () => {\n // Performed in the handler as it requires the request body\n },\n }),\n rateLimit: [\n {\n name: 'repo-write-hour',\n calcKey: ({ auth }) => auth.credentials.did,\n calcPoints: () => 2,\n },\n {\n name: 'repo-write-day',\n calcKey: ({ auth }) => auth.credentials.did,\n calcPoints: () => 2,\n },\n ],\n opts: {\n jsonLimit: 1_000_000,\n },\n handler: async ({ auth, input }) => {\n const {\n repo,\n collection,\n rkey,\n record,\n validate,\n swapCommit,\n swapRecord,\n } = input.body\n\n const account = await ctx.authVerifier.findAccount(repo, {\n checkDeactivated: true,\n checkTakedown: true,\n })\n\n const did = account.did\n if (did !== auth.credentials.did) {\n throw new AuthRequiredError()\n }\n\n // We can't compute permissions based on the request payload (\"input\") in\n // the 'auth' phase, so we do it here.\n if (auth.credentials.type === 'oauth') {\n auth.credentials.permissions.assertRepo({\n action: 'create',\n collection,\n })\n auth.credentials.permissions.assertRepo({\n action: 'update',\n collection,\n })\n }\n\n const uri = atUri(did, collection, rkey)\n const swapCommitCid = swapCommit ? parseCid(swapCommit) : undefined\n const swapRecordCid =\n typeof swapRecord === 'string' ? parseCid(swapRecord) : swapRecord\n\n const { commit, write } = await ctx.actorStore.transact(\n did,\n async (actorTxn) => {\n const current = await actorTxn.record.getRecord(uri, null, true)\n const isUpdate = current !== null\n\n // @TODO temporaray hack for legacy blob refs in profiles - remove after migrating legacy blobs\n if (isUpdate && collection === app.bsky.actor.profile.$type) {\n await updateProfileLegacyBlobRef(actorTxn, record)\n }\n\n const writeInfo = {\n did,\n collection,\n rkey,\n record,\n swapCid: swapRecordCid,\n validate,\n }\n\n let write: PreparedCreate | PreparedUpdate\n try {\n write = isUpdate\n ? await prepareUpdate(writeInfo)\n : await prepareCreate(writeInfo)\n } catch (err) {\n if (err instanceof InvalidRecordError) {\n throw new InvalidRequestError(err.message)\n }\n throw err\n }\n\n // no-op\n if (current && current.cid === write.cid.toString()) {\n return {\n commit: null,\n write,\n }\n }\n\n const commit = await actorTxn.repo\n .processWrites([write], swapCommitCid)\n .catch((err) => {\n if (\n err instanceof BadCommitSwapError ||\n err instanceof BadRecordSwapError\n ) {\n throw new InvalidRequestError(err.message, 'InvalidSwap')\n } else {\n throw err\n }\n })\n\n await ctx.sequencer.sequenceCommit(did, commit)\n\n return { commit, write }\n },\n )\n\n if (commit !== null) {\n await ctx.accountManager\n .updateRepoRoot(did, commit.cid, commit.rev)\n .catch((err) => {\n dbLogger.error(\n { err, did, cid: commit.cid, rev: commit.rev },\n 'failed to update account root',\n )\n })\n }\n\n return {\n encoding: 'application/json',\n body: {\n uri: write.uri.toString(),\n cid: write.cid.toString(),\n commit: commit\n ? {\n cid: commit.cid.toString(),\n rev: commit.rev,\n }\n : undefined,\n validationStatus: write.validationStatus,\n },\n }\n },\n })\n}\n\n// WARNING: mutates object\nasync function updateProfileLegacyBlobRef(\n actorStore: ActorStoreTransactor,\n record: LexMap,\n): Promise<void> {\n if (isLegacyBlobRef(record.avatar)) {\n record.avatar = await upgradeLegacyBlob(actorStore, record.avatar)\n }\n if (isLegacyBlobRef(record.banner)) {\n record.banner = await upgradeLegacyBlob(actorStore, record.banner)\n }\n}\n\nasync function upgradeLegacyBlob(\n actorStore: ActorStoreTransactor,\n legacyBlob: LegacyBlobRef,\n): Promise<TypedBlobRef> {\n const ref = parseCid(legacyBlob.cid)\n const blob = await actorStore.repo.blob.getBlobMetadata(ref)\n return {\n $type: 'blob',\n mimeType: legacyBlob.mimeType,\n ref,\n size: blob.size,\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRepo.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/sync/getRepo.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAuB,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAOlE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"getRepo.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/sync/getRepo.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAuB,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAOlE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAMnD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QA4BvD;AAED,eAAO,MAAM,YAAY,GACvB,KAAK,UAAU,EACf,KAAK,MAAM,EACX,QAAQ,MAAM,KACb,OAAO,CAAC,MAAM,CAAC,QAAQ,CAiBzB,CAAA"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { byteIterableToStream } from '@atproto/common';
|
|
1
|
+
import { byteIterableToStream, coalesceByteStream } from '@atproto/common';
|
|
2
2
|
import { InvalidRequestError } from '@atproto/xrpc-server';
|
|
3
3
|
import { RepoRootNotFoundError, SqlRepoReader, } from '../../../../actor-store/repo/sql-repo-reader.js';
|
|
4
4
|
import { AuthScope } from '../../../../auth-scope.js';
|
|
5
5
|
import { isUserOrAdmin } from '../../../../auth-verifier.js';
|
|
6
6
|
import { com } from '../../../../lexicons/index.js';
|
|
7
7
|
import { assertRepoAvailability } from './util.js';
|
|
8
|
+
const CAR_STREAM_CHUNK_SIZE = 64 * 1024;
|
|
8
9
|
export default function (server, ctx) {
|
|
9
10
|
server.add(com.atproto.sync.getRepo, {
|
|
10
11
|
auth: ctx.authVerifier.authorizationOrAdminTokenOptional({
|
|
@@ -13,24 +14,35 @@ export default function (server, ctx) {
|
|
|
13
14
|
// always allow
|
|
14
15
|
},
|
|
15
16
|
}),
|
|
16
|
-
handler: async ({ params, auth }) => {
|
|
17
|
+
handler: async ({ req, params, auth }) => {
|
|
17
18
|
const { did, since } = params;
|
|
18
19
|
await assertRepoAvailability(ctx, did, isUserOrAdmin(auth, did));
|
|
19
20
|
const carStream = await getCarStream(ctx, did, since);
|
|
20
21
|
return {
|
|
21
22
|
encoding: 'application/vnd.ipld.car',
|
|
22
|
-
|
|
23
|
+
// @NOTE If the client asked for compression (via "accept-encoding"), we
|
|
24
|
+
// coalesce the CAR stream into larger chunks to improve compression
|
|
25
|
+
// efficiency. See https://github.com/bluesky-social/atproto/pull/5078
|
|
26
|
+
//
|
|
27
|
+
// @TODO This would be better handled by xrpc-server and/or the
|
|
28
|
+
// compression middleware instead of manually coalescing the stream.
|
|
29
|
+
body: req.headers['accept-encoding']
|
|
30
|
+
? coalesceByteStream(carStream, CAR_STREAM_CHUNK_SIZE)
|
|
31
|
+
: carStream,
|
|
23
32
|
};
|
|
24
33
|
},
|
|
25
34
|
});
|
|
26
35
|
}
|
|
27
36
|
export const getCarStream = async (ctx, did, since) => {
|
|
28
37
|
const actorDb = await ctx.actorStore.openDb(did);
|
|
29
|
-
let carStream;
|
|
30
38
|
try {
|
|
31
39
|
const storage = new SqlRepoReader(actorDb);
|
|
32
40
|
const carIter = await storage.getCarStream(since);
|
|
33
|
-
carStream = byteIterableToStream(carIter);
|
|
41
|
+
const carStream = byteIterableToStream(carIter);
|
|
42
|
+
const closeDb = () => actorDb.close();
|
|
43
|
+
carStream.on('error', closeDb);
|
|
44
|
+
carStream.on('close', closeDb);
|
|
45
|
+
return carStream;
|
|
34
46
|
}
|
|
35
47
|
catch (err) {
|
|
36
48
|
await actorDb.close();
|
|
@@ -39,9 +51,5 @@ export const getCarStream = async (ctx, did, since) => {
|
|
|
39
51
|
}
|
|
40
52
|
throw err;
|
|
41
53
|
}
|
|
42
|
-
const closeDb = () => actorDb.close();
|
|
43
|
-
carStream.on('error', closeDb);
|
|
44
|
-
carStream.on('close', closeDb);
|
|
45
|
-
return carStream;
|
|
46
54
|
};
|
|
47
55
|
//# sourceMappingURL=getRepo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRepo.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/sync/getRepo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"getRepo.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/sync/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EAAE,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC;oBAClC,CAAC,CAAC,kBAAkB,CAAC,SAAS,EAAE,qBAAqB,CAAC;oBACtD,CAAC,CAAC,SAAS;aACd,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,GAAe,EACf,GAAW,EACX,KAAc,EACY,EAAE;IAC5B,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAChD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;QAC1C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QACjD,MAAM,SAAS,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAA;QAC/C,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QACrC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC9B,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC9B,OAAO,SAAS,CAAA;IAClB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;QACrB,IAAI,GAAG,YAAY,qBAAqB,EAAE,CAAC;YACzC,MAAM,IAAI,mBAAmB,CAAC,gCAAgC,GAAG,EAAE,CAAC,CAAA;QACtE,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC,CAAA","sourcesContent":["import stream from 'node:stream'\nimport { byteIterableToStream, coalesceByteStream } from '@atproto/common'\nimport { InvalidRequestError, Server } from '@atproto/xrpc-server'\nimport {\n RepoRootNotFoundError,\n SqlRepoReader,\n} from '../../../../actor-store/repo/sql-repo-reader.js'\nimport { AuthScope } from '../../../../auth-scope.js'\nimport { isUserOrAdmin } from '../../../../auth-verifier.js'\nimport { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { assertRepoAvailability } from './util.js'\n\nconst CAR_STREAM_CHUNK_SIZE = 64 * 1024\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.sync.getRepo, {\n auth: ctx.authVerifier.authorizationOrAdminTokenOptional({\n additional: [AuthScope.Takendown],\n authorize: () => {\n // always allow\n },\n }),\n handler: async ({ req, params, auth }) => {\n const { did, since } = params\n await assertRepoAvailability(ctx, did, isUserOrAdmin(auth, did))\n\n const carStream = await getCarStream(ctx, did, since)\n\n return {\n encoding: 'application/vnd.ipld.car' as const,\n // @NOTE If the client asked for compression (via \"accept-encoding\"), we\n // coalesce the CAR stream into larger chunks to improve compression\n // efficiency. See https://github.com/bluesky-social/atproto/pull/5078\n //\n // @TODO This would be better handled by xrpc-server and/or the\n // compression middleware instead of manually coalescing the stream.\n body: req.headers['accept-encoding']\n ? coalesceByteStream(carStream, CAR_STREAM_CHUNK_SIZE)\n : carStream,\n }\n },\n })\n}\n\nexport const getCarStream = async (\n ctx: AppContext,\n did: string,\n since?: string,\n): Promise<stream.Readable> => {\n const actorDb = await ctx.actorStore.openDb(did)\n try {\n const storage = new SqlRepoReader(actorDb)\n const carIter = await storage.getCarStream(since)\n const carStream = byteIterableToStream(carIter)\n const closeDb = () => actorDb.close()\n carStream.on('error', closeDb)\n carStream.on('close', closeDb)\n return carStream\n } catch (err) {\n await actorDb.close()\n if (err instanceof RepoRootNotFoundError) {\n throw new InvalidRequestError(`Could not find repo for DID: ${did}`)\n }\n throw err\n }\n}\n"]}
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,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AE,MAAM;;;;;IAK3C,mBAAmB,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;;;IAUxE,uBAAuB,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO;;;IAItC,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;;;;;IAUxD,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAS3D;AAUD,eAAe,UAAU,CAAA"}
|
package/dist/context.js
CHANGED
|
@@ -135,13 +135,13 @@ export class AppContext {
|
|
|
135
135
|
blobstore,
|
|
136
136
|
backgroundQueue,
|
|
137
137
|
});
|
|
138
|
-
const accountManager = new AccountManager(idResolver, jwtSecretKey, mailer, cfg.service.did, cfg.identity.serviceHandleDomains, cfg.db);
|
|
139
|
-
await accountManager.migrateOrThrow();
|
|
140
138
|
const plcRotationKey = secrets.plcRotationKey.provider === 'kms'
|
|
141
139
|
? await KmsKeypair.load({
|
|
142
140
|
keyId: secrets.plcRotationKey.keyId,
|
|
143
141
|
})
|
|
144
142
|
: await crypto.Secp256k1Keypair.import(secrets.plcRotationKey.privateKeyHex);
|
|
143
|
+
const accountManager = new AccountManager(idResolver, jwtSecretKey, mailer, sequencer, plcClient, plcRotationKey, cfg.service.did, cfg.identity.serviceHandleDomains, cfg.db);
|
|
144
|
+
await accountManager.migrateOrThrow();
|
|
145
145
|
const localViewer = LocalViewer.creator(accountManager, imageUrlBuilder, bskyAppView);
|
|
146
146
|
// An agent for performing HTTP requests based on user provided URLs.
|
|
147
147
|
const proxyAgentBase = new undici.Agent({
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,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,GAAW,EAAE,GAAW;QACxD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAClD,OAAO,gBAAgB,CAAC;YACtB,GAAG,EAAE,GAAG;YACR,GAAG;YACH,GAAG;YACH,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AAED,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,QAAgB,EAAE,EAAE;IAC7D,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAC1B,GAAG,CAAC,UAAU,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,EAAE,MAAM,CAAC,EACjD,WAAW,CACZ,CAAA;IACD,OAAO,SAAS,OAAO,EAAE,CAAA;AAC3B,CAAC,CAAA;AAED,eAAe,UAAU,CAAA","sourcesContent":["import assert from 'node:assert'\nimport * as plc from '@did-plc/lib'\nimport express from 'express'\nimport { Redis } from 'ioredis'\nimport * as nodemailer from 'nodemailer'\nimport * as ui8 from 'uint8arrays'\nimport * as undici from 'undici'\nimport { KmsKeypair, S3BlobStore } from '@atproto/aws'\nimport * as crypto from '@atproto/crypto'\nimport { IdResolver } from '@atproto/identity'\nimport { Client } from '@atproto/lex'\nimport {\n AccessTokenMode,\n JoseKey,\n LexResolver,\n OAuthProvider,\n OAuthVerifier,\n} from '@atproto/oauth-provider'\nimport { BlobStore } from '@atproto/repo'\nimport {\n createServiceAuthHeaders,\n createServiceJwt,\n} from '@atproto/xrpc-server'\nimport {\n Fetch,\n isUnicastIp,\n safeFetchWrap,\n unicastLookup,\n} from '@atproto-labs/fetch-node'\nimport { AccountManager } from './account-manager/account-manager.js'\nimport { OAuthStore } from './account-manager/oauth-store.js'\nimport { ScopeReferenceGetter } from './account-manager/scope-reference-getter.js'\nimport { ActorStore } from './actor-store/actor-store.js'\nimport { authPassthru, forwardedFor } from './api/proxy.js'\nimport {\n AuthVerifier,\n createPublicKeyObject,\n createSecretKeyObject,\n} from './auth-verifier.js'\nimport { BackgroundQueue } from './background.js'\nimport { BskyAppView } from './bsky-app-view.js'\nimport { ServerConfig, ServerSecrets } from './config/index.js'\nimport { Crawlers } from './crawlers.js'\nimport { DidSqliteCache } from './did-cache/index.js'\nimport { DiskBlobStore } from './disk-blobstore.js'\nimport { ImageUrlBuilder } from './image/image-url-builder.js'\nimport { fetchLogger, lexiconResolverLogger, oauthLogger } from './logger.js'\nimport { ServerMailer } from './mailer/index.js'\nimport { ModerationMailer } from './mailer/moderation.js'\nimport { LocalViewer, LocalViewerCreator } from './read-after-write/viewer.js'\nimport { getRedisClient } from './redis.js'\nimport { Sequencer } from './sequencer/index.js'\n\nexport type AppContextOptions = {\n actorStore: ActorStore\n blobstore: (did: string) => BlobStore\n localViewer: LocalViewerCreator\n mailer: ServerMailer\n moderationMailer: ModerationMailer\n didCache: DidSqliteCache\n idResolver: IdResolver\n plcClient: plc.Client\n accountManager: AccountManager\n sequencer: Sequencer\n backgroundQueue: BackgroundQueue\n redisScratch?: Redis\n crawlers: Crawlers\n bskyAppView?: BskyAppView\n moderationClient?: Client\n reportingClient?: Client\n entrywayClient?: Client\n entrywayAdminClient?: Client\n proxyAgent: undici.Dispatcher\n safeFetch: Fetch\n oauthProvider?: OAuthProvider\n authVerifier: AuthVerifier\n plcRotationKey: crypto.Keypair\n cfg: ServerConfig\n}\n\nexport class AppContext {\n public actorStore: ActorStore\n public blobstore: (did: string) => BlobStore\n public localViewer: LocalViewerCreator\n public mailer: ServerMailer\n public moderationMailer: ModerationMailer\n public didCache: DidSqliteCache\n public idResolver: IdResolver\n public plcClient: plc.Client\n public accountManager: AccountManager\n public sequencer: Sequencer\n public backgroundQueue: BackgroundQueue\n public redisScratch?: Redis\n public crawlers: Crawlers\n public bskyAppView?: BskyAppView\n public moderationClient: Client | undefined\n public reportingClient: Client | undefined\n public entrywayClient: Client | undefined\n public entrywayAdminClient: Client | undefined\n public proxyAgent: undici.Dispatcher\n public safeFetch: Fetch\n public authVerifier: AuthVerifier\n public oauthProvider?: OAuthProvider\n public plcRotationKey: crypto.Keypair\n public cfg: ServerConfig\n\n constructor(opts: AppContextOptions) {\n this.actorStore = opts.actorStore\n this.blobstore = opts.blobstore\n this.localViewer = opts.localViewer\n this.mailer = opts.mailer\n this.moderationMailer = opts.moderationMailer\n this.didCache = opts.didCache\n this.idResolver = opts.idResolver\n this.plcClient = opts.plcClient\n this.accountManager = opts.accountManager\n this.sequencer = opts.sequencer\n this.backgroundQueue = opts.backgroundQueue\n this.redisScratch = opts.redisScratch\n this.crawlers = opts.crawlers\n this.bskyAppView = opts.bskyAppView\n this.moderationClient = opts.moderationClient\n this.reportingClient = opts.reportingClient\n this.entrywayClient = opts.entrywayClient\n this.entrywayAdminClient = opts.entrywayAdminClient\n this.proxyAgent = opts.proxyAgent\n this.safeFetch = opts.safeFetch\n this.authVerifier = opts.authVerifier\n this.oauthProvider = opts.oauthProvider\n this.plcRotationKey = opts.plcRotationKey\n this.cfg = opts.cfg\n }\n\n static async fromConfig(\n cfg: ServerConfig,\n secrets: ServerSecrets,\n overrides?: Partial<AppContextOptions>,\n ): Promise<AppContext> {\n const blobstore =\n cfg.blobstore.provider === 's3'\n ? S3BlobStore.creator({\n bucket: cfg.blobstore.bucket,\n region: cfg.blobstore.region,\n endpoint: cfg.blobstore.endpoint,\n forcePathStyle: cfg.blobstore.forcePathStyle,\n credentials: cfg.blobstore.credentials,\n uploadTimeoutMs: cfg.blobstore.uploadTimeoutMs,\n })\n : DiskBlobStore.creator(\n cfg.blobstore.location,\n cfg.blobstore.tempLocation,\n )\n\n const mailTransport =\n cfg.email !== null\n ? nodemailer.createTransport(cfg.email.smtpUrl)\n : nodemailer.createTransport({ jsonTransport: true })\n\n const mailer = new ServerMailer(mailTransport, cfg.email, cfg.branding)\n\n const modMailTransport =\n cfg.moderationEmail !== null\n ? nodemailer.createTransport(cfg.moderationEmail.smtpUrl)\n : nodemailer.createTransport({ jsonTransport: true })\n\n const moderationMailer = new ModerationMailer(modMailTransport, cfg)\n\n const didCache = new DidSqliteCache(\n cfg.db.didCacheDbLoc,\n cfg.identity.cacheStaleTTL,\n cfg.identity.cacheMaxTTL,\n cfg.db.disableWalAutoCheckpoint,\n )\n await didCache.migrateOrThrow()\n\n const idResolver = new IdResolver({\n plcUrl: cfg.identity.plcUrl,\n didCache,\n timeout: cfg.identity.resolverTimeout,\n backupNameservers: cfg.identity.handleBackupNameservers,\n })\n const plcClient = new plc.Client(cfg.identity.plcUrl)\n\n const backgroundQueue = new BackgroundQueue()\n const crawlers = new Crawlers(\n backgroundQueue,\n cfg.service.hostname,\n cfg.crawlers,\n )\n const sequencer = new Sequencer(\n cfg.db.sequencerDbLoc,\n crawlers,\n undefined,\n cfg.db.disableWalAutoCheckpoint,\n )\n const redisScratch = cfg.redis\n ? getRedisClient(cfg.redis.address, cfg.redis.password)\n : undefined\n\n const bskyAppView = cfg.bskyAppView\n ? new BskyAppView({\n ...cfg.bskyAppView,\n validateResponse: cfg.service.devMode,\n })\n : undefined\n\n const moderationClient = cfg.modService\n ? new Client(\n { service: cfg.modService.url },\n {\n // Trust internal services to send us well-formed responses\n strictResponseProcessing: false,\n validateResponse: cfg.service.devMode,\n },\n )\n : undefined\n const reportingClient = cfg.reportService\n ? new Client(\n { service: cfg.reportService.url },\n {\n // Trust internal services to send us well-formed responses\n strictResponseProcessing: false,\n validateResponse: cfg.service.devMode,\n },\n )\n : undefined\n const entrywayClient = cfg.entryway\n ? new Client(\n { service: cfg.entryway.url },\n {\n // Trust internal services to send us well-formed responses\n strictResponseProcessing: false,\n validateResponse: cfg.service.devMode,\n },\n )\n : undefined\n const entrywayAdminClient =\n cfg.entryway && secrets.entrywayAdminToken\n ? new Client(\n { service: cfg.entryway.url },\n {\n headers: {\n authorization: basicAuthHeader(\n 'admin',\n secrets.entrywayAdminToken,\n ),\n },\n // Trust internal services to send us well-formed responses\n strictResponseProcessing: false,\n validateResponse: cfg.service.devMode,\n },\n )\n : undefined\n\n const jwtSecretKey = createSecretKeyObject(secrets.jwtSecret)\n const jwtPublicKey = cfg.entryway\n ? createPublicKeyObject(cfg.entryway.jwtPublicKeyHex)\n : null\n\n const imageUrlBuilder = new ImageUrlBuilder(\n cfg.service.hostname,\n bskyAppView,\n )\n\n const actorStore = new ActorStore(cfg.actorStore, {\n blobstore,\n backgroundQueue,\n })\n\n const accountManager = new AccountManager(\n idResolver,\n jwtSecretKey,\n mailer,\n cfg.service.did,\n cfg.identity.serviceHandleDomains,\n cfg.db,\n )\n await accountManager.migrateOrThrow()\n\n const plcRotationKey =\n secrets.plcRotationKey.provider === 'kms'\n ? await KmsKeypair.load({\n keyId: secrets.plcRotationKey.keyId,\n })\n : await crypto.Secp256k1Keypair.import(\n secrets.plcRotationKey.privateKeyHex,\n )\n\n const localViewer = LocalViewer.creator(\n accountManager,\n imageUrlBuilder,\n bskyAppView,\n )\n\n // An agent for performing HTTP requests based on user provided URLs.\n const proxyAgentBase = new undici.Agent({\n allowH2: cfg.proxy.allowHTTP2, // This is experimental\n headersTimeout: cfg.proxy.headersTimeout,\n maxResponseSize: cfg.proxy.maxResponseSize,\n bodyTimeout: cfg.proxy.bodyTimeout,\n factory: cfg.proxy.disableSsrfProtection\n ? undefined\n : (origin, opts) => {\n const { protocol, hostname } =\n origin instanceof URL ? origin : new URL(origin)\n if (protocol !== 'https:') {\n throw new Error(`Forbidden protocol \"${protocol}\"`)\n }\n if (isUnicastIp(hostname) === false) {\n throw new Error('Hostname resolved to non-unicast address')\n }\n return new undici.Pool(origin, opts)\n },\n connect: {\n lookup: cfg.proxy.disableSsrfProtection ? undefined : unicastLookup,\n },\n })\n const proxyAgent =\n cfg.proxy.maxRetries > 0\n ? new undici.RetryAgent(proxyAgentBase, {\n statusCodes: [], // Only retry on socket errors\n methods: ['GET', 'HEAD'],\n maxRetries: cfg.proxy.maxRetries,\n })\n : proxyAgentBase\n\n /**\n * A fetch() function that protects against SSRF attacks, large responses &\n * known bad domains. This function can safely be used to fetch user\n * provided URLs (unless \"disableSsrfProtection\" is true, of course).\n *\n * @note **DO NOT** wrap `safeFetch` with any logging or other transforms as\n * this might prevent the use of explicit `redirect: \"follow\"` init from\n * working. See {@link safeFetchWrap}.\n */\n const safeFetch = safeFetchWrap({\n allowIpHost: false,\n allowImplicitRedirect: false,\n responseMaxSize: cfg.fetch.maxResponseSize,\n ssrfProtection: !cfg.fetch.disableSsrfProtection,\n\n fetch: function (input, init) {\n const method =\n init?.method ?? (input instanceof Request ? input.method : 'GET')\n const uri = input instanceof Request ? input.url : String(input)\n\n fetchLogger.info({ method, uri }, 'fetch')\n\n return globalThis.fetch.call(this, input, init)\n },\n })\n\n const oauthProvider = cfg.oauth.provider\n ? new OAuthProvider({\n issuer: cfg.oauth.issuer,\n keyset: [await JoseKey.fromKeyLike(jwtSecretKey, undefined, 'HS256')],\n store: new OAuthStore(\n accountManager,\n actorStore,\n imageUrlBuilder,\n backgroundQueue,\n mailer,\n sequencer,\n plcClient,\n plcRotationKey,\n cfg.service.publicUrl,\n cfg.identity.recoveryDidKey,\n ),\n redis: redisScratch,\n dpopSecret: secrets.dpopSecret,\n inviteCodeRequired: cfg.invites.required,\n availableUserDomains: cfg.identity.serviceHandleDomains,\n hcaptcha: cfg.oauth.provider.hcaptcha,\n branding: cfg.oauth.provider.branding,\n safeFetch,\n lexResolver: new LexResolver({\n fetch: safeFetch,\n plcDirectoryUrl: cfg.identity.plcUrl,\n hooks: {\n onResolveAuthority: ({ nsid }) => {\n lexiconResolverLogger.debug(\n { nsid: nsid.toString() },\n 'Resolving lexicon DID authority',\n )\n // Override the lexicon did resolution to point to a custom PDS\n return cfg.lexicon.didAuthority\n },\n onResolveAuthorityResult({ nsid, did }) {\n lexiconResolverLogger.info(\n { nsid: nsid.toString(), did },\n 'Resolved lexicon DID',\n )\n },\n onResolveAuthorityError({ nsid, err }) {\n lexiconResolverLogger.error(\n { nsid: nsid.toString(), err },\n 'Lexicon DID resolution error',\n )\n },\n onFetchResult({ uri, cid }) {\n lexiconResolverLogger.info(\n { uri: uri.toString(), cid: cid.toString() },\n 'Fetched lexicon',\n )\n },\n onFetchError({ err, uri }) {\n lexiconResolverLogger.error(\n { uri: uri.toString(), err },\n 'Lexicon fetch error',\n )\n },\n },\n }),\n metadata: {\n protected_resources: [new URL(cfg.oauth.issuer).origin],\n },\n // If the PDS is both an authorization server & resource server (no\n // entryway), we can afford to check the token validity on every\n // request. This allows revoked tokens to be rejected immediately.\n // This also allows JWT to be shorter since some claims (notably the\n // \"scope\" claim) do not need to be included in the token.\n accessTokenMode: AccessTokenMode.stateful,\n\n getClientInfo(clientId) {\n return {\n isTrusted: cfg.oauth.provider?.trustedClients?.includes(clientId),\n }\n },\n })\n : undefined\n\n const scopeRefGetter = entrywayClient\n ? new ScopeReferenceGetter(entrywayClient, redisScratch)\n : undefined\n\n const oauthVerifier: OAuthVerifier =\n oauthProvider ?? // OAuthProvider extends OAuthVerifier\n new OAuthVerifier({\n issuer: cfg.oauth.issuer,\n keyset: [await JoseKey.fromKeyLike(jwtPublicKey!, undefined, 'ES256K')],\n dpopSecret: secrets.dpopSecret,\n redis: redisScratch,\n onDecodeToken: async ({ payload, dpopProof }) => {\n // @TODO drop this once oauth provider no longer accepts DPoP proof with\n // query or fragment in \"htu\" claim.\n if (dpopProof?.htu.match(/[?#]/)) {\n oauthLogger.info(\n { htu: dpopProof.htu, client_id: payload.client_id },\n 'DPoP proof \"htu\" contains query or fragment',\n )\n }\n\n if (scopeRefGetter) {\n payload.scope = await scopeRefGetter.dereference(payload.scope)\n }\n\n return payload\n },\n })\n\n const authVerifier = new AuthVerifier(\n accountManager,\n idResolver,\n oauthVerifier,\n {\n publicUrl: cfg.service.publicUrl,\n jwtKey: jwtPublicKey ?? jwtSecretKey,\n adminPass: secrets.adminPassword,\n dids: {\n pds: cfg.service.did,\n entryway: cfg.entryway?.did,\n modService: cfg.modService?.did,\n },\n },\n )\n\n return new AppContext({\n actorStore,\n blobstore,\n localViewer,\n mailer,\n moderationMailer,\n didCache,\n idResolver,\n plcClient,\n accountManager,\n sequencer,\n backgroundQueue,\n redisScratch,\n crawlers,\n bskyAppView,\n moderationClient,\n reportingClient,\n entrywayClient,\n entrywayAdminClient,\n proxyAgent,\n safeFetch,\n authVerifier,\n oauthProvider,\n plcRotationKey,\n cfg,\n ...(overrides ?? {}),\n })\n }\n\n async appviewAuthHeaders(did: string, lxm: string) {\n assert(this.bskyAppView)\n return this.serviceAuthHeaders(did, this.bskyAppView.did, lxm)\n }\n\n async entrywayAuthHeaders(req: express.Request, did: string, lxm: string) {\n assert(this.cfg.entryway)\n const headers = await this.serviceAuthHeaders(\n did,\n this.cfg.entryway.did,\n lxm,\n )\n return forwardedFor(req, headers)\n }\n\n entrywayPassthruHeaders(req: express.Request) {\n return forwardedFor(req, authPassthru(req))\n }\n\n async serviceAuthHeaders(did: string, aud: string, lxm: string) {\n const keypair = await this.actorStore.keypair(did)\n return createServiceAuthHeaders({\n iss: did,\n aud,\n lxm,\n keypair,\n })\n }\n\n async serviceAuthJwt(did: string, aud: string, lxm: string) {\n const keypair = await this.actorStore.keypair(did)\n return createServiceJwt({\n iss: did,\n aud,\n lxm,\n keypair,\n })\n }\n}\n\nconst basicAuthHeader = (username: string, password: string) => {\n const encoded = ui8.toString(\n ui8.fromString(`${username}:${password}`, 'utf8'),\n 'base64pad',\n )\n return `Basic ${encoded}`\n}\n\nexport default AppContext\n"]}
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAGnC,OAAO,KAAK,UAAU,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,E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AAC,QAAgB,EAAE,QAAgB,EAAE,EAAE;IAC7D,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAC1B,GAAG,CAAC,UAAU,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,EAAE,MAAM,CAAC,EACjD,WAAW,CACZ,CAAA;IACD,OAAO,SAAS,OAAO,EAAE,CAAA;AAC3B,CAAC,CAAA;AAED,eAAe,UAAU,CAAA","sourcesContent":["import assert from 'node:assert'\nimport * as plc from '@did-plc/lib'\nimport express from 'express'\nimport { Redis } from 'ioredis'\nimport * as nodemailer from 'nodemailer'\nimport * as ui8 from 'uint8arrays'\nimport * as undici from 'undici'\nimport { KmsKeypair, S3BlobStore } from '@atproto/aws'\nimport * as crypto from '@atproto/crypto'\nimport { IdResolver } from '@atproto/identity'\nimport { Client } from '@atproto/lex'\nimport {\n AccessTokenMode,\n JoseKey,\n LexResolver,\n OAuthProvider,\n OAuthVerifier,\n} from '@atproto/oauth-provider'\nimport { BlobStore } from '@atproto/repo'\nimport {\n createServiceAuthHeaders,\n createServiceJwt,\n} from '@atproto/xrpc-server'\nimport {\n Fetch,\n isUnicastIp,\n safeFetchWrap,\n unicastLookup,\n} from '@atproto-labs/fetch-node'\nimport { AccountManager } from './account-manager/account-manager.js'\nimport { OAuthStore } from './account-manager/oauth-store.js'\nimport { ScopeReferenceGetter } from './account-manager/scope-reference-getter.js'\nimport { ActorStore } from './actor-store/actor-store.js'\nimport { authPassthru, forwardedFor } from './api/proxy.js'\nimport {\n AuthVerifier,\n createPublicKeyObject,\n createSecretKeyObject,\n} from './auth-verifier.js'\nimport { BackgroundQueue } from './background.js'\nimport { BskyAppView } from './bsky-app-view.js'\nimport { ServerConfig, ServerSecrets } from './config/index.js'\nimport { Crawlers } from './crawlers.js'\nimport { DidSqliteCache } from './did-cache/index.js'\nimport { DiskBlobStore } from './disk-blobstore.js'\nimport { ImageUrlBuilder } from './image/image-url-builder.js'\nimport { fetchLogger, lexiconResolverLogger, oauthLogger } from './logger.js'\nimport { ServerMailer } from './mailer/index.js'\nimport { ModerationMailer } from './mailer/moderation.js'\nimport { LocalViewer, LocalViewerCreator } from './read-after-write/viewer.js'\nimport { getRedisClient } from './redis.js'\nimport { Sequencer } from './sequencer/index.js'\n\nexport type AppContextOptions = {\n actorStore: ActorStore\n blobstore: (did: string) => BlobStore\n localViewer: LocalViewerCreator\n mailer: ServerMailer\n moderationMailer: ModerationMailer\n didCache: DidSqliteCache\n idResolver: IdResolver\n plcClient: plc.Client\n accountManager: AccountManager\n sequencer: Sequencer\n backgroundQueue: BackgroundQueue\n redisScratch?: Redis\n crawlers: Crawlers\n bskyAppView?: BskyAppView\n moderationClient?: Client\n reportingClient?: Client\n entrywayClient?: Client\n entrywayAdminClient?: Client\n proxyAgent: undici.Dispatcher\n safeFetch: Fetch\n oauthProvider?: OAuthProvider\n authVerifier: AuthVerifier\n plcRotationKey: crypto.Keypair\n cfg: ServerConfig\n}\n\nexport class AppContext {\n public actorStore: ActorStore\n public blobstore: (did: string) => BlobStore\n public localViewer: LocalViewerCreator\n public mailer: ServerMailer\n public moderationMailer: ModerationMailer\n public didCache: DidSqliteCache\n public idResolver: IdResolver\n public plcClient: plc.Client\n public accountManager: AccountManager\n public sequencer: Sequencer\n public backgroundQueue: BackgroundQueue\n public redisScratch?: Redis\n public crawlers: Crawlers\n public bskyAppView?: BskyAppView\n public moderationClient: Client | undefined\n public reportingClient: Client | undefined\n public entrywayClient: Client | undefined\n public entrywayAdminClient: Client | undefined\n public proxyAgent: undici.Dispatcher\n public safeFetch: Fetch\n public authVerifier: AuthVerifier\n public oauthProvider?: OAuthProvider\n public plcRotationKey: crypto.Keypair\n public cfg: ServerConfig\n\n constructor(opts: AppContextOptions) {\n this.actorStore = opts.actorStore\n this.blobstore = opts.blobstore\n this.localViewer = opts.localViewer\n this.mailer = opts.mailer\n this.moderationMailer = opts.moderationMailer\n this.didCache = opts.didCache\n this.idResolver = opts.idResolver\n this.plcClient = opts.plcClient\n this.accountManager = opts.accountManager\n this.sequencer = opts.sequencer\n this.backgroundQueue = opts.backgroundQueue\n this.redisScratch = opts.redisScratch\n this.crawlers = opts.crawlers\n this.bskyAppView = opts.bskyAppView\n this.moderationClient = opts.moderationClient\n this.reportingClient = opts.reportingClient\n this.entrywayClient = opts.entrywayClient\n this.entrywayAdminClient = opts.entrywayAdminClient\n this.proxyAgent = opts.proxyAgent\n this.safeFetch = opts.safeFetch\n this.authVerifier = opts.authVerifier\n this.oauthProvider = opts.oauthProvider\n this.plcRotationKey = opts.plcRotationKey\n this.cfg = opts.cfg\n }\n\n static async fromConfig(\n cfg: ServerConfig,\n secrets: ServerSecrets,\n overrides?: Partial<AppContextOptions>,\n ): Promise<AppContext> {\n const blobstore =\n cfg.blobstore.provider === 's3'\n ? S3BlobStore.creator({\n bucket: cfg.blobstore.bucket,\n region: cfg.blobstore.region,\n endpoint: cfg.blobstore.endpoint,\n forcePathStyle: cfg.blobstore.forcePathStyle,\n credentials: cfg.blobstore.credentials,\n uploadTimeoutMs: cfg.blobstore.uploadTimeoutMs,\n })\n : DiskBlobStore.creator(\n cfg.blobstore.location,\n cfg.blobstore.tempLocation,\n )\n\n const mailTransport =\n cfg.email !== null\n ? nodemailer.createTransport(cfg.email.smtpUrl)\n : nodemailer.createTransport({ jsonTransport: true })\n\n const mailer = new ServerMailer(mailTransport, cfg.email, cfg.branding)\n\n const modMailTransport =\n cfg.moderationEmail !== null\n ? nodemailer.createTransport(cfg.moderationEmail.smtpUrl)\n : nodemailer.createTransport({ jsonTransport: true })\n\n const moderationMailer = new ModerationMailer(modMailTransport, cfg)\n\n const didCache = new DidSqliteCache(\n cfg.db.didCacheDbLoc,\n cfg.identity.cacheStaleTTL,\n cfg.identity.cacheMaxTTL,\n cfg.db.disableWalAutoCheckpoint,\n )\n await didCache.migrateOrThrow()\n\n const idResolver = new IdResolver({\n plcUrl: cfg.identity.plcUrl,\n didCache,\n timeout: cfg.identity.resolverTimeout,\n backupNameservers: cfg.identity.handleBackupNameservers,\n })\n const plcClient = new plc.Client(cfg.identity.plcUrl)\n\n const backgroundQueue = new BackgroundQueue()\n const crawlers = new Crawlers(\n backgroundQueue,\n cfg.service.hostname,\n cfg.crawlers,\n )\n const sequencer = new Sequencer(\n cfg.db.sequencerDbLoc,\n crawlers,\n undefined,\n cfg.db.disableWalAutoCheckpoint,\n )\n const redisScratch = cfg.redis\n ? getRedisClient(cfg.redis.address, cfg.redis.password)\n : undefined\n\n const bskyAppView = cfg.bskyAppView\n ? new BskyAppView({\n ...cfg.bskyAppView,\n validateResponse: cfg.service.devMode,\n })\n : undefined\n\n const moderationClient = cfg.modService\n ? new Client(\n { service: cfg.modService.url },\n {\n // Trust internal services to send us well-formed responses\n strictResponseProcessing: false,\n validateResponse: cfg.service.devMode,\n },\n )\n : undefined\n const reportingClient = cfg.reportService\n ? new Client(\n { service: cfg.reportService.url },\n {\n // Trust internal services to send us well-formed responses\n strictResponseProcessing: false,\n validateResponse: cfg.service.devMode,\n },\n )\n : undefined\n const entrywayClient = cfg.entryway\n ? new Client(\n { service: cfg.entryway.url },\n {\n // Trust internal services to send us well-formed responses\n strictResponseProcessing: false,\n validateResponse: cfg.service.devMode,\n },\n )\n : undefined\n const entrywayAdminClient =\n cfg.entryway && secrets.entrywayAdminToken\n ? new Client(\n { service: cfg.entryway.url },\n {\n headers: {\n authorization: basicAuthHeader(\n 'admin',\n secrets.entrywayAdminToken,\n ),\n },\n // Trust internal services to send us well-formed responses\n strictResponseProcessing: false,\n validateResponse: cfg.service.devMode,\n },\n )\n : undefined\n\n const jwtSecretKey = createSecretKeyObject(secrets.jwtSecret)\n const jwtPublicKey = cfg.entryway\n ? createPublicKeyObject(cfg.entryway.jwtPublicKeyHex)\n : null\n\n const imageUrlBuilder = new ImageUrlBuilder(\n cfg.service.hostname,\n bskyAppView,\n )\n\n const actorStore = new ActorStore(cfg.actorStore, {\n blobstore,\n backgroundQueue,\n })\n\n const plcRotationKey =\n secrets.plcRotationKey.provider === 'kms'\n ? await KmsKeypair.load({\n keyId: secrets.plcRotationKey.keyId,\n })\n : await crypto.Secp256k1Keypair.import(\n secrets.plcRotationKey.privateKeyHex,\n )\n\n const accountManager = new AccountManager(\n idResolver,\n jwtSecretKey,\n mailer,\n sequencer,\n plcClient,\n plcRotationKey,\n cfg.service.did,\n cfg.identity.serviceHandleDomains,\n cfg.db,\n )\n await accountManager.migrateOrThrow()\n\n const localViewer = LocalViewer.creator(\n accountManager,\n imageUrlBuilder,\n bskyAppView,\n )\n\n // An agent for performing HTTP requests based on user provided URLs.\n const proxyAgentBase = new undici.Agent({\n allowH2: cfg.proxy.allowHTTP2, // This is experimental\n headersTimeout: cfg.proxy.headersTimeout,\n maxResponseSize: cfg.proxy.maxResponseSize,\n bodyTimeout: cfg.proxy.bodyTimeout,\n factory: cfg.proxy.disableSsrfProtection\n ? undefined\n : (origin, opts) => {\n const { protocol, hostname } =\n origin instanceof URL ? origin : new URL(origin)\n if (protocol !== 'https:') {\n throw new Error(`Forbidden protocol \"${protocol}\"`)\n }\n if (isUnicastIp(hostname) === false) {\n throw new Error('Hostname resolved to non-unicast address')\n }\n return new undici.Pool(origin, opts)\n },\n connect: {\n lookup: cfg.proxy.disableSsrfProtection ? undefined : unicastLookup,\n },\n })\n const proxyAgent =\n cfg.proxy.maxRetries > 0\n ? new undici.RetryAgent(proxyAgentBase, {\n statusCodes: [], // Only retry on socket errors\n methods: ['GET', 'HEAD'],\n maxRetries: cfg.proxy.maxRetries,\n })\n : proxyAgentBase\n\n /**\n * A fetch() function that protects against SSRF attacks, large responses &\n * known bad domains. This function can safely be used to fetch user\n * provided URLs (unless \"disableSsrfProtection\" is true, of course).\n *\n * @note **DO NOT** wrap `safeFetch` with any logging or other transforms as\n * this might prevent the use of explicit `redirect: \"follow\"` init from\n * working. See {@link safeFetchWrap}.\n */\n const safeFetch = safeFetchWrap({\n allowIpHost: false,\n allowImplicitRedirect: false,\n responseMaxSize: cfg.fetch.maxResponseSize,\n ssrfProtection: !cfg.fetch.disableSsrfProtection,\n\n fetch: function (input, init) {\n const method =\n init?.method ?? (input instanceof Request ? input.method : 'GET')\n const uri = input instanceof Request ? input.url : String(input)\n\n fetchLogger.info({ method, uri }, 'fetch')\n\n return globalThis.fetch.call(this, input, init)\n },\n })\n\n const oauthProvider = cfg.oauth.provider\n ? new OAuthProvider({\n issuer: cfg.oauth.issuer,\n keyset: [await JoseKey.fromKeyLike(jwtSecretKey, undefined, 'HS256')],\n store: new OAuthStore(\n accountManager,\n actorStore,\n imageUrlBuilder,\n backgroundQueue,\n mailer,\n sequencer,\n plcClient,\n plcRotationKey,\n cfg.service.publicUrl,\n cfg.identity.recoveryDidKey,\n ),\n redis: redisScratch,\n dpopSecret: secrets.dpopSecret,\n inviteCodeRequired: cfg.invites.required,\n availableUserDomains: cfg.identity.serviceHandleDomains,\n hcaptcha: cfg.oauth.provider.hcaptcha,\n branding: cfg.oauth.provider.branding,\n safeFetch,\n lexResolver: new LexResolver({\n fetch: safeFetch,\n plcDirectoryUrl: cfg.identity.plcUrl,\n hooks: {\n onResolveAuthority: ({ nsid }) => {\n lexiconResolverLogger.debug(\n { nsid: nsid.toString() },\n 'Resolving lexicon DID authority',\n )\n // Override the lexicon did resolution to point to a custom PDS\n return cfg.lexicon.didAuthority\n },\n onResolveAuthorityResult({ nsid, did }) {\n lexiconResolverLogger.info(\n { nsid: nsid.toString(), did },\n 'Resolved lexicon DID',\n )\n },\n onResolveAuthorityError({ nsid, err }) {\n lexiconResolverLogger.error(\n { nsid: nsid.toString(), err },\n 'Lexicon DID resolution error',\n )\n },\n onFetchResult({ uri, cid }) {\n lexiconResolverLogger.info(\n { uri: uri.toString(), cid: cid.toString() },\n 'Fetched lexicon',\n )\n },\n onFetchError({ err, uri }) {\n lexiconResolverLogger.error(\n { uri: uri.toString(), err },\n 'Lexicon fetch error',\n )\n },\n },\n }),\n metadata: {\n protected_resources: [new URL(cfg.oauth.issuer).origin],\n },\n // If the PDS is both an authorization server & resource server (no\n // entryway), we can afford to check the token validity on every\n // request. This allows revoked tokens to be rejected immediately.\n // This also allows JWT to be shorter since some claims (notably the\n // \"scope\" claim) do not need to be included in the token.\n accessTokenMode: AccessTokenMode.stateful,\n\n getClientInfo(clientId) {\n return {\n isTrusted: cfg.oauth.provider?.trustedClients?.includes(clientId),\n }\n },\n })\n : undefined\n\n const scopeRefGetter = entrywayClient\n ? new ScopeReferenceGetter(entrywayClient, redisScratch)\n : undefined\n\n const oauthVerifier: OAuthVerifier =\n oauthProvider ?? // OAuthProvider extends OAuthVerifier\n new OAuthVerifier({\n issuer: cfg.oauth.issuer,\n keyset: [await JoseKey.fromKeyLike(jwtPublicKey!, undefined, 'ES256K')],\n dpopSecret: secrets.dpopSecret,\n redis: redisScratch,\n onDecodeToken: async ({ payload, dpopProof }) => {\n // @TODO drop this once oauth provider no longer accepts DPoP proof with\n // query or fragment in \"htu\" claim.\n if (dpopProof?.htu.match(/[?#]/)) {\n oauthLogger.info(\n { htu: dpopProof.htu, client_id: payload.client_id },\n 'DPoP proof \"htu\" contains query or fragment',\n )\n }\n\n if (scopeRefGetter) {\n payload.scope = await scopeRefGetter.dereference(payload.scope)\n }\n\n return payload\n },\n })\n\n const authVerifier = new AuthVerifier(\n accountManager,\n idResolver,\n oauthVerifier,\n {\n publicUrl: cfg.service.publicUrl,\n jwtKey: jwtPublicKey ?? jwtSecretKey,\n adminPass: secrets.adminPassword,\n dids: {\n pds: cfg.service.did,\n entryway: cfg.entryway?.did,\n modService: cfg.modService?.did,\n },\n },\n )\n\n return new AppContext({\n actorStore,\n blobstore,\n localViewer,\n mailer,\n moderationMailer,\n didCache,\n idResolver,\n plcClient,\n accountManager,\n sequencer,\n backgroundQueue,\n redisScratch,\n crawlers,\n bskyAppView,\n moderationClient,\n reportingClient,\n entrywayClient,\n entrywayAdminClient,\n proxyAgent,\n safeFetch,\n authVerifier,\n oauthProvider,\n plcRotationKey,\n cfg,\n ...(overrides ?? {}),\n })\n }\n\n async appviewAuthHeaders(did: string, lxm: string) {\n assert(this.bskyAppView)\n return this.serviceAuthHeaders(did, this.bskyAppView.did, lxm)\n }\n\n async entrywayAuthHeaders(req: express.Request, did: string, lxm: string) {\n assert(this.cfg.entryway)\n const headers = await this.serviceAuthHeaders(\n did,\n this.cfg.entryway.did,\n lxm,\n )\n return forwardedFor(req, headers)\n }\n\n entrywayPassthruHeaders(req: express.Request) {\n return forwardedFor(req, authPassthru(req))\n }\n\n async serviceAuthHeaders(did: string, aud: string, lxm: string) {\n const keypair = await this.actorStore.keypair(did)\n return createServiceAuthHeaders({\n iss: did,\n aud,\n lxm,\n keypair,\n })\n }\n\n async serviceAuthJwt(did: string, aud: string, lxm: string) {\n const keypair = await this.actorStore.keypair(did)\n return createServiceJwt({\n iss: did,\n aud,\n lxm,\n keypair,\n })\n }\n}\n\nconst basicAuthHeader = (username: string, password: string) => {\n const encoded = ui8.toString(\n ui8.fromString(`${username}:${password}`, 'utf8'),\n 'base64pad',\n )\n return `Basic ${encoded}`\n}\n\nexport default AppContext\n"]}
|
|
@@ -178,6 +178,14 @@ type VerificationView = {
|
|
|
178
178
|
* The user who issued this verification.
|
|
179
179
|
*/
|
|
180
180
|
issuer: l.DidString;
|
|
181
|
+
/**
|
|
182
|
+
* The display name of the issuer.
|
|
183
|
+
*/
|
|
184
|
+
issuerDisplayName?: string;
|
|
185
|
+
/**
|
|
186
|
+
* The handle of the issuer.
|
|
187
|
+
*/
|
|
188
|
+
issuerHandle?: l.HandleString;
|
|
181
189
|
/**
|
|
182
190
|
* The AT-URI of the verification record.
|
|
183
191
|
*/
|