diff --git a/package.json b/package.json index 4906b1827f5..9a3f4b42993 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "eslint": "^8.24.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.2.1", - "get-port": "^6.1.2", "jest": "^28.1.2", "node-gyp": "^9.3.1", "pino-pretty": "^9.1.0", diff --git a/packages/pds/src/api/app/bsky/preferences/getPreferences.ts b/packages/pds/src/api/app/bsky/preferences/getPreferences.ts deleted file mode 100644 index 1bca50f0bd1..00000000000 --- a/packages/pds/src/api/app/bsky/preferences/getPreferences.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Server } from '../../../../lexicon' -import AppContext from '../../../../context' -import { AuthScope } from '../../../../auth' - -export default function (server: Server, ctx: AppContext) { - server.app.bsky.actor.getPreferences({ - auth: ctx.accessVerifier, - handler: async ({ auth }) => { - const requester = auth.credentials.did - const { services, db } = ctx - let preferences = await services - .account(db) - .getPreferences(requester, 'app.bsky') - if (auth.credentials.scope !== AuthScope.Access) { - // filter out personal details for app passwords - preferences = preferences.filter( - (pref) => pref.$type !== 'app.bsky.actor.defs#personalDetailsPref', - ) - } - return { - encoding: 'application/json', - body: { preferences }, - } - }, - }) -} diff --git a/packages/pds/src/api/app/bsky/preferences/getProfile.ts b/packages/pds/src/api/app/bsky/preferences/getProfile.ts deleted file mode 100644 index c200e1dd75f..00000000000 --- a/packages/pds/src/api/app/bsky/preferences/getProfile.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Server } from '../../../../lexicon' -import AppContext from '../../../../context' -import { authPassthru } from '../../../../api/com/atproto/admin/util' -import { OutputSchema } from '../../../../lexicon/types/app/bsky/actor/getProfile' -import { handleReadAfterWrite } from '../util/read-after-write' -import { LocalRecords } from '../../../../services/local' - -export default function (server: Server, ctx: AppContext) { - server.app.bsky.actor.getProfile({ - auth: ctx.accessOrRoleVerifier, - handler: async ({ req, auth, params }) => { - const requester = - auth.credentials.type === 'access' ? auth.credentials.did : null - const res = await ctx.appViewAgent.api.app.bsky.actor.getProfile( - params, - requester ? await ctx.serviceAuthHeaders(requester) : authPassthru(req), - ) - if (res.data.did === requester) { - return await handleReadAfterWrite(ctx, requester, res, getProfileMunge) - } - return { - encoding: 'application/json', - body: res.data, - } - }, - }) -} - -const getProfileMunge = async ( - ctx: AppContext, - original: OutputSchema, - local: LocalRecords, -): Promise => { - if (!local.profile) return original - return ctx.services - .local(ctx.db) - .updateProfileDetailed(original, local.profile.record) -} diff --git a/packages/pds/src/api/app/bsky/preferences/getProfiles.ts b/packages/pds/src/api/app/bsky/preferences/getProfiles.ts deleted file mode 100644 index ebec9e36938..00000000000 --- a/packages/pds/src/api/app/bsky/preferences/getProfiles.ts +++ /dev/null @@ -1,46 +0,0 @@ -import AppContext from '../../../../context' -import { Server } from '../../../../lexicon' -import { OutputSchema } from '../../../../lexicon/types/app/bsky/actor/getProfiles' -import { LocalRecords } from '../../../../services/local' -import { handleReadAfterWrite } from '../util/read-after-write' - -export default function (server: Server, ctx: AppContext) { - server.app.bsky.actor.getProfiles({ - auth: ctx.accessVerifier, - handler: async ({ auth, params }) => { - const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.actor.getProfiles( - params, - await ctx.serviceAuthHeaders(requester), - ) - const hasSelf = res.data.profiles.some((prof) => prof.did === requester) - if (hasSelf) { - return await handleReadAfterWrite(ctx, requester, res, getProfilesMunge) - } - return { - encoding: 'application/json', - body: res.data, - } - }, - }) -} - -const getProfilesMunge = async ( - ctx: AppContext, - original: OutputSchema, - local: LocalRecords, - requester: string, -): Promise => { - const localProf = local.profile - if (!localProf) return original - const profiles = original.profiles.map((prof) => { - if (prof.did !== requester) return prof - return ctx.services - .local(ctx.db) - .updateProfileDetailed(prof, localProf.record) - }) - return { - ...original, - profiles, - } -} diff --git a/packages/pds/src/api/app/bsky/preferences/getSuggestions.ts b/packages/pds/src/api/app/bsky/preferences/getSuggestions.ts deleted file mode 100644 index 03c6fa6e609..00000000000 --- a/packages/pds/src/api/app/bsky/preferences/getSuggestions.ts +++ /dev/null @@ -1,19 +0,0 @@ -import AppContext from '../../../../context' -import { Server } from '../../../../lexicon' - -export default function (server: Server, ctx: AppContext) { - server.app.bsky.actor.getSuggestions({ - auth: ctx.accessVerifier, - handler: async ({ params, auth }) => { - const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.actor.getSuggestions( - params, - await ctx.serviceAuthHeaders(requester), - ) - return { - encoding: 'application/json', - body: res.data, - } - }, - }) -} diff --git a/packages/pds/src/api/app/bsky/preferences/index.ts b/packages/pds/src/api/app/bsky/preferences/index.ts deleted file mode 100644 index db69616f7e8..00000000000 --- a/packages/pds/src/api/app/bsky/preferences/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Server } from '../../../../lexicon' -import AppContext from '../../../../context' -import getPreferences from './getPreferences' -import getProfile from './getProfile' -import getProfiles from './getProfiles' -import getSuggestions from './getSuggestions' -import putPreferences from './putPreferences' -import searchActors from './searchActors' -import searchActorsTypeahead from './searchActorsTypeahead' - -export default function (server: Server, ctx: AppContext) { - getPreferences(server, ctx) - getProfile(server, ctx) - getProfiles(server, ctx) - getSuggestions(server, ctx) - putPreferences(server, ctx) - searchActors(server, ctx) - searchActorsTypeahead(server, ctx) -} diff --git a/packages/pds/src/api/app/bsky/preferences/putPreferences.ts b/packages/pds/src/api/app/bsky/preferences/putPreferences.ts deleted file mode 100644 index 27528595116..00000000000 --- a/packages/pds/src/api/app/bsky/preferences/putPreferences.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Server } from '../../../../lexicon' -import AppContext from '../../../../context' -import { UserPreference } from '../../../../services/account' -import { InvalidRequestError } from '@atproto/xrpc-server' - -export default function (server: Server, ctx: AppContext) { - server.app.bsky.actor.putPreferences({ - auth: ctx.accessVerifierCheckTakedown, - handler: async ({ auth, input }) => { - const { preferences } = input.body - const requester = auth.credentials.did - const { services, db } = ctx - const checkedPreferences: UserPreference[] = [] - for (const pref of preferences) { - if (typeof pref.$type === 'string') { - checkedPreferences.push(pref as UserPreference) - } else { - throw new InvalidRequestError('Preference is missing a $type') - } - } - await db.transaction(async (tx) => { - await services - .account(tx) - .putPreferences(requester, checkedPreferences, 'app.bsky') - }) - }, - }) -} diff --git a/packages/pds/src/api/app/bsky/preferences/searchActors.ts b/packages/pds/src/api/app/bsky/preferences/searchActors.ts deleted file mode 100644 index 0ae4d9b211c..00000000000 --- a/packages/pds/src/api/app/bsky/preferences/searchActors.ts +++ /dev/null @@ -1,19 +0,0 @@ -import AppContext from '../../../../context' -import { Server } from '../../../../lexicon' - -export default function (server: Server, ctx: AppContext) { - server.app.bsky.actor.searchActors({ - auth: ctx.accessVerifier, - handler: async ({ auth, params }) => { - const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.actor.searchActors( - params, - await ctx.serviceAuthHeaders(requester), - ) - return { - encoding: 'application/json', - body: res.data, - } - }, - }) -} diff --git a/packages/pds/src/api/app/bsky/preferences/searchActorsTypeahead.ts b/packages/pds/src/api/app/bsky/preferences/searchActorsTypeahead.ts deleted file mode 100644 index 3ece0083ec2..00000000000 --- a/packages/pds/src/api/app/bsky/preferences/searchActorsTypeahead.ts +++ /dev/null @@ -1,20 +0,0 @@ -import AppContext from '../../../../context' -import { Server } from '../../../../lexicon' - -export default function (server: Server, ctx: AppContext) { - server.app.bsky.actor.searchActorsTypeahead({ - auth: ctx.accessVerifier, - handler: async ({ params, auth }) => { - const requester = auth.credentials.did - const res = - await ctx.appViewAgent.api.app.bsky.actor.searchActorsTypeahead( - params, - await ctx.serviceAuthHeaders(requester), - ) - return { - encoding: 'application/json', - body: res.data, - } - }, - }) -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 698a8bc86b5..32dca6c6b0f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -65,9 +65,6 @@ importers: eslint-plugin-prettier: specifier: ^4.2.1 version: 4.2.1(eslint-config-prettier@8.5.0)(eslint@8.24.0)(prettier@2.7.1) - get-port: - specifier: ^6.1.2 - version: 6.1.2 jest: specifier: ^28.1.2 version: 28.1.2(@types/node@18.0.0)(ts-node@10.8.2)