Skip to content

Commit

Permalink
Remove appview proxy runtime flags (#1590)
Browse files Browse the repository at this point in the history
* remove appview proxy runtime flags

* clean up proxy tests
  • Loading branch information
dholms authored Sep 14, 2023
1 parent 1c42157 commit 36ba295
Show file tree
Hide file tree
Showing 34 changed files with 57 additions and 180 deletions.
37 changes: 0 additions & 37 deletions packages/dev-env/src/bin-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const run = async () => {
},
plc: { port: 2582 },
})
await enableProxy(network)
await generateMockSetup(network)

console.log(
Expand All @@ -40,39 +39,3 @@ const run = async () => {
}

run()

// @TODO remove once we remove proxy runtime flags
const enableProxy = async (network: TestNetwork) => {
const flags = [
'appview-proxy:app.bsky.feed.getAuthorFeed',
'appview-proxy:app.bsky.graph.getFollowers',
'appview-proxy:app.bsky.feed.getPosts',
'appview-proxy:app.bsky.graph.getFollows',
'appview-proxy:app.bsky.feed.getLikes',
'appview-proxy:app.bsky.feed.getRepostedBy',
'appview-proxy:app.bsky.feed.getPostThread',
'appview-proxy:app.bsky.actor.getProfile',
'appview-proxy:app.bsky.actor.getProfiles',
'appview-proxy:app.bsky.feed.getTimeline',
'appview-proxy:app.bsky.feed.getSuggestions',
'appview-proxy:app.bsky.feed.getFeed',
'appview-proxy:app.bsky.feed.getActorFeeds',
'appview-proxy:app.bsky.feed.getActorLikes',
'appview-proxy:app.bsky.feed.getFeedGenerator',
'appview-proxy:app.bsky.feed.getFeedGenerators',
'appview-proxy:app.bsky.feed.getBlocks',
'appview-proxy:app.bsky.feed.getList',
'appview-proxy:app.bsky.notification.listNotifications',
'appview-proxy:app.bsky.feed.getLists',
'appview-proxy:app.bsky.feed.getListMutes',
'appview-proxy:com.atproto.repo.getRecord',
'appview-proxy:com.atproto.identity.resolveHandle',
'appview-proxy:app.bsky.notification.getUnreadCount',
'appview-proxy:app.bsky.actor.searchActorsTypeahead',
'appview-proxy:app.bsky.actor.searchActors',
]
await network.pds.ctx.db.db
.insertInto('runtime_flag')
.values(flags.map((name) => ({ name, value: '10' })))
.execute()
}
5 changes: 2 additions & 3 deletions packages/pds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
"@atproto/api": "workspace:^",
"@atproto/common": "workspace:^",
"@atproto/crypto": "workspace:^",
"@atproto/syntax": "workspace:^",
"@atproto/identity": "workspace:^",
"@atproto/lexicon": "workspace:^",
"@atproto/repo": "workspace:^",
"@atproto/syntax": "workspace:^",
"@atproto/xrpc": "workspace:^",
"@atproto/xrpc-server": "workspace:^",
"@did-plc/lib": "^0.0.1",
Expand All @@ -53,7 +53,6 @@
"iso-datestring-validator": "^2.2.2",
"jsonwebtoken": "^8.5.1",
"kysely": "^0.22.0",
"lru-cache": "^10.0.1",
"multiformats": "^9.9.0",
"nodemailer": "^6.8.0",
"nodemailer-html-to-text": "^3.2.0",
Expand All @@ -67,9 +66,9 @@
"zod": "^3.21.4"
},
"devDependencies": {
"@atproto/api": "workspace:^",
"@atproto/bsky": "workspace:^",
"@atproto/dev-env": "workspace:^",
"@atproto/api": "workspace:^",
"@atproto/lex-cli": "workspace:^",
"@did-plc/server": "^0.0.1",
"@types/cors": "^2.8.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/api/com/atproto/identity/resolveHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Server } from '../../../../lexicon'
import AppContext from '../../../../context'

export default function (server: Server, ctx: AppContext) {
server.com.atproto.identity.resolveHandle(async ({ params, req }) => {
server.com.atproto.identity.resolveHandle(async ({ params }) => {
let handle: string
try {
handle = ident.normalizeAndEnsureValidHandle(params.handle)
Expand Down Expand Up @@ -34,7 +34,7 @@ export default function (server: Server, ctx: AppContext) {

// this is not someone on our server, but we help with resolving anyway

if (!did && (await ctx.canProxyRead(req))) {
if (!did && ctx.canProxyRead()) {
did = await tryResolveFromAppview(ctx.appviewAgent, handle)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/api/com/atproto/repo/getRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Server } from '../../../../lexicon'
import AppContext from '../../../../context'

export default function (server: Server, ctx: AppContext) {
server.com.atproto.repo.getRecord(async ({ req, params }) => {
server.com.atproto.repo.getRecord(async ({ params }) => {
const { repo, collection, rkey, cid } = params
const did = await ctx.services.account(ctx.db).getDidForActor(repo)

Expand All @@ -26,7 +26,7 @@ export default function (server: Server, ctx: AppContext) {
}
}

if (await ctx.canProxyRead(req)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.com.atproto.repo.getRecord(params)
return {
encoding: 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/src/app-view/api/app/bsky/actor/getProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function (server: Server, ctx: AppContext) {
handler: async ({ req, auth, params }) => {
const requester =
auth.credentials.type === 'access' ? auth.credentials.did : null
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.actor.getProfile(
params,
requester
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/actor/getProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { handleReadAfterWrite } from '../util/read-after-write'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.actor.getProfiles({
auth: ctx.accessVerifier,
handler: async ({ req, auth, params }) => {
handler: async ({ auth, params }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.actor.getProfiles(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Server } from '../../../../../lexicon'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.actor.getSuggestions({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.actor.getSuggestions(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/actor/searchActors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
export default function (server: Server, ctx: AppContext) {
server.app.bsky.actor.searchActors({
auth: ctx.accessVerifier,
handler: async ({ req, auth, params }) => {
handler: async ({ auth, params }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.actor.searchActors(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { DidHandle } from '../../../../../db/tables/did-handle'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.actor.searchActorsTypeahead({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res =
await ctx.appviewAgent.api.app.bsky.actor.searchActorsTypeahead(
params,
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/feed/getActorFeeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { InvalidRequestError } from '@atproto/xrpc-server'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getActorFeeds({
auth: ctx.accessVerifier,
handler: async ({ req, auth, params }) => {
handler: async ({ auth, params }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.feed.getActorFeeds(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function (server: Server, ctx: AppContext) {
const requester =
auth.credentials.type === 'access' ? auth.credentials.did : null

if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.feed.getActorLikes(
params,
requester
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function (server: Server, ctx: AppContext) {
handler: async ({ req, params, auth }) => {
const requester =
auth.credentials.type === 'access' ? auth.credentials.did : null
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.feed.getAuthorFeed(
params,
requester
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/feed/getFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export default function (server: Server, ctx: AppContext) {

server.app.bsky.feed.getFeed({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did

if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const { data: feed } =
await ctx.appviewAgent.api.app.bsky.feed.getFeedGenerator(
{ feed: params.feed },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import AppContext from '../../../../../context'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getFeedGenerator({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.feed.getFeedGenerator(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import AppContext from '../../../../../context'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getFeedGenerators({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.feed.getFeedGenerators(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/feed/getLikes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { notSoftDeletedClause } from '../../../../../db/util'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getLikes({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.feed.getLikes(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/feed/getPostThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export type PostThread = {
export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getPostThread({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
try {
const res = await ctx.appviewAgent.api.app.bsky.feed.getPostThread(
params,
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/feed/getPosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { PostView } from '../../../../../lexicon/types/app/bsky/feed/defs'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getPosts({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.feed.getPosts(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/feed/getRepostedBy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { notSoftDeletedClause } from '../../../../../db/util'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getRepostedBy({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.feed.getRepostedBy(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/feed/getTimeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import { LocalRecords } from '../../../../../services/local'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getTimeline({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
const { algorithm, limit, cursor } = params
if (algorithm && algorithm !== FeedAlgorithm.ReverseChronological) {
throw new InvalidRequestError(`Unsupported algorithm: ${algorithm}`)
}

if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.feed.getTimeline(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/graph/getBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { notSoftDeletedClause } from '../../../../../db/util'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.graph.getBlocks({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.graph.getBlocks(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function (server: Server, ctx: AppContext) {
handler: async ({ req, params, auth }) => {
const requester =
auth.credentials.type === 'access' ? auth.credentials.did : null
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.graph.getFollowers(
params,
requester
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/src/app-view/api/app/bsky/graph/getFollows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function (server: Server, ctx: AppContext) {
handler: async ({ req, params, auth }) => {
const requester =
auth.credentials.type === 'access' ? auth.credentials.did : null
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.graph.getFollows(
params,
requester
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/graph/getList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import AppContext from '../../../../../context'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.graph.getList({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.graph.getList(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/graph/getListMutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import AppContext from '../../../../../context'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.graph.getListMutes({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.graph.getListMutes(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/graph/getLists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import AppContext from '../../../../../context'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.graph.getLists({
auth: ctx.accessVerifier,
handler: async ({ req, params, auth }) => {
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.graph.getLists(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
4 changes: 2 additions & 2 deletions packages/pds/src/app-view/api/app/bsky/graph/getMutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { notSoftDeletedClause } from '../../../../../db/util'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.graph.getMutes({
auth: ctx.accessVerifier,
handler: async ({ req, auth, params }) => {
handler: async ({ auth, params }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res = await ctx.appviewAgent.api.app.bsky.graph.getMutes(
params,
await ctx.serviceAuthHeaders(requester),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import AppContext from '../../../../../context'
export default function (server: Server, ctx: AppContext) {
server.app.bsky.notification.getUnreadCount({
auth: ctx.accessVerifier,
handler: async ({ req, auth, params }) => {
handler: async ({ auth, params }) => {
const requester = auth.credentials.did
if (await ctx.canProxyRead(req, requester)) {
if (ctx.canProxyRead()) {
const res =
await ctx.appviewAgent.api.app.bsky.notification.getUnreadCount(
params,
Expand Down
Loading

0 comments on commit 36ba295

Please sign in to comment.