@atproto/pds 0.5.6 → 0.5.8
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 +25 -0
- package/dist/background.d.ts +12 -6
- package/dist/background.d.ts.map +1 -1
- package/dist/background.js +32 -13
- package/dist/background.js.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +4 -31
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -11
- package/dist/index.js.map +1 -1
- package/dist/lexicons/app/bsky/authFullApp.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/authFullApp.defs.js +1 -0
- package/dist/lexicons/app/bsky/authFullApp.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/authViewAll.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/authViewAll.defs.js +1 -0
- package/dist/lexicons/app/bsky/authViewAll.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/feed/searchPostsV2.d.ts +3 -0
- package/dist/lexicons/app/bsky/feed/searchPostsV2.d.ts.map +1 -0
- package/dist/lexicons/app/bsky/feed/searchPostsV2.defs.d.ts +158 -0
- package/dist/lexicons/app/bsky/feed/searchPostsV2.defs.d.ts.map +1 -0
- package/dist/lexicons/app/bsky/feed/searchPostsV2.defs.js +74 -0
- package/dist/lexicons/app/bsky/feed/searchPostsV2.defs.js.map +1 -0
- package/dist/lexicons/app/bsky/feed/searchPostsV2.js +6 -0
- package/dist/lexicons/app/bsky/feed/searchPostsV2.js.map +1 -0
- package/dist/lexicons/app/bsky/feed.d.ts +1 -0
- package/dist/lexicons/app/bsky/feed.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed.js +1 -0
- package/dist/lexicons/app/bsky/feed.js.map +1 -1
- package/dist/lexicons/app/bsky/notification/defs.defs.d.ts +5 -0
- package/dist/lexicons/app/bsky/notification/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/notification/defs.defs.js +1 -0
- package/dist/lexicons/app/bsky/notification/defs.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/actor/declaration.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/actor/declaration.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/actor/defs.defs.d.ts +4 -6
- package/dist/lexicons/chat/bsky/actor/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/actor/defs.defs.js +2 -3
- package/dist/lexicons/chat/bsky/actor/defs.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/convo/defs.defs.d.ts +64 -70
- package/dist/lexicons/chat/bsky/convo/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/convo/defs.defs.js +32 -35
- package/dist/lexicons/chat/bsky/convo/defs.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.js +1 -1
- package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/convo/listConvoRequests.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/convo/listConvoRequests.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/convo/listConvoRequests.defs.js +1 -1
- package/dist/lexicons/chat/bsky/convo/listConvoRequests.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/convo/lockConvo.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/convo/lockConvo.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/convo/lockConvo.defs.js +1 -1
- package/dist/lexicons/chat/bsky/convo/lockConvo.defs.js.map +1 -1
- 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 -1
- package/dist/lexicons/chat/bsky/convo/unlockConvo.defs.js.map +1 -1
- 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 -1
- package/dist/lexicons/chat/bsky/group/addMembers.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/approveJoinRequest.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/approveJoinRequest.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/approveJoinRequest.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/approveJoinRequest.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/createGroup.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/createGroup.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/createGroup.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/createGroup.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/createJoinLink.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/createJoinLink.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/createJoinLink.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/createJoinLink.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/disableJoinLink.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/disableJoinLink.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/disableJoinLink.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/disableJoinLink.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/editGroup.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/editGroup.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/editGroup.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/editGroup.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/editJoinLink.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/editJoinLink.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/editJoinLink.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/editJoinLink.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/enableJoinLink.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/enableJoinLink.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/enableJoinLink.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/enableJoinLink.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/listJoinRequests.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/listJoinRequests.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/listJoinRequests.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/listJoinRequests.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/listMutualGroups.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/listMutualGroups.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/listMutualGroups.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/listMutualGroups.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/rejectJoinRequest.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/rejectJoinRequest.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/rejectJoinRequest.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/rejectJoinRequest.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/removeMembers.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/removeMembers.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/removeMembers.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/removeMembers.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/requestJoin.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/requestJoin.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/requestJoin.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/requestJoin.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.js +1 -1
- package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/moderation/defs.defs.d.ts +6 -6
- package/dist/lexicons/chat/bsky/moderation/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/moderation/defs.defs.js +3 -3
- package/dist/lexicons/chat/bsky/moderation/defs.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvo.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvo.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvo.defs.js +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvo.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.js +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvos.defs.d.ts +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvos.defs.d.ts.map +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvos.defs.js +1 -1
- package/dist/lexicons/chat/bsky/moderation/getConvos.defs.js.map +1 -1
- package/dist/lexicons/chat/bsky/notification/defs.d.ts +2 -0
- package/dist/lexicons/chat/bsky/notification/defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/notification/defs.defs.d.ts +20 -0
- package/dist/lexicons/chat/bsky/notification/defs.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/notification/defs.defs.js +19 -0
- package/dist/lexicons/chat/bsky/notification/defs.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/notification/defs.js +5 -0
- package/dist/lexicons/chat/bsky/notification/defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/notification/getPreferences.d.ts +3 -0
- package/dist/lexicons/chat/bsky/notification/getPreferences.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/notification/getPreferences.defs.d.ts +18 -0
- package/dist/lexicons/chat/bsky/notification/getPreferences.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/notification/getPreferences.defs.js +16 -0
- package/dist/lexicons/chat/bsky/notification/getPreferences.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/notification/getPreferences.js +6 -0
- package/dist/lexicons/chat/bsky/notification/getPreferences.js.map +1 -0
- package/dist/lexicons/chat/bsky/notification/putPreferences.d.ts +3 -0
- package/dist/lexicons/chat/bsky/notification/putPreferences.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/notification/putPreferences.defs.d.ts +27 -0
- package/dist/lexicons/chat/bsky/notification/putPreferences.defs.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/notification/putPreferences.defs.js +22 -0
- package/dist/lexicons/chat/bsky/notification/putPreferences.defs.js.map +1 -0
- package/dist/lexicons/chat/bsky/notification/putPreferences.js +6 -0
- package/dist/lexicons/chat/bsky/notification/putPreferences.js.map +1 -0
- package/dist/lexicons/chat/bsky/notification.d.ts +4 -0
- package/dist/lexicons/chat/bsky/notification.d.ts.map +1 -0
- package/dist/lexicons/chat/bsky/notification.js +7 -0
- package/dist/lexicons/chat/bsky/notification.js.map +1 -0
- 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/tools/ozone/report/defs.defs.d.ts +4 -0
- package/dist/lexicons/tools/ozone/report/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/report/defs.defs.js +2 -0
- package/dist/lexicons/tools/ozone/report/defs.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/report/queryActivities.d.ts +3 -0
- package/dist/lexicons/tools/ozone/report/queryActivities.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/report/queryActivities.defs.d.ts +42 -0
- package/dist/lexicons/tools/ozone/report/queryActivities.defs.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/report/queryActivities.defs.js +31 -0
- package/dist/lexicons/tools/ozone/report/queryActivities.defs.js.map +1 -0
- package/dist/lexicons/tools/ozone/report/queryActivities.js +6 -0
- package/dist/lexicons/tools/ozone/report/queryActivities.js.map +1 -0
- package/dist/lexicons/tools/ozone/report.d.ts +1 -0
- package/dist/lexicons/tools/ozone/report.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/report.js +1 -0
- package/dist/lexicons/tools/ozone/report.js.map +1 -1
- package/dist/pipethrough.d.ts +3 -0
- package/dist/pipethrough.d.ts.map +1 -1
- package/dist/pipethrough.js +32 -0
- package/dist/pipethrough.js.map +1 -1
- package/package.json +13 -13
- package/src/background.ts +49 -18
- package/src/context.ts +4 -37
- package/src/index.ts +31 -13
- package/src/pipethrough.ts +38 -1
- package/tests/_util.ts +8 -25
- package/tests/account-deactivation.test.ts +3 -2
- package/tests/account-deletion.test.ts +1 -1
- package/tests/account-migration.test.ts +2 -2
- package/tests/account-status.test.ts +1 -1
- package/tests/account.test.ts +1 -1
- package/tests/app-passwords.test.ts +1 -1
- package/tests/auth.test.ts +1 -1
- package/tests/blob-deletes.test.ts +5 -4
- package/tests/create-post.test.ts +1 -1
- package/tests/crud.test.ts +1 -1
- package/tests/db.test.ts +1 -1
- package/tests/email-confirmation.test.ts +1 -1
- package/tests/file-uploads.test.ts +2 -2
- package/tests/get-service-auth.test.ts +1 -1
- package/tests/handles.test.ts +1 -1
- package/tests/invite-codes.test.ts +1 -1
- package/tests/invites-admin.test.ts +5 -4
- package/tests/moderation.test.ts +1 -1
- package/tests/moderator-auth.test.ts +1 -1
- package/tests/plc-operations.test.ts +3 -2
- package/tests/preferences.test.ts +1 -1
- package/tests/proxied/admin.test.ts +3 -2
- package/tests/proxied/feedgen.test.ts +1 -1
- package/tests/proxied/notif.test.ts +6 -13
- package/tests/proxied/procedures.test.ts +5 -4
- package/tests/proxied/proxy-catchall.test.ts +9 -8
- package/tests/proxied/proxy-header.test.ts +14 -9
- package/tests/proxied/proxy-oauth-aud.test.ts +17 -10
- package/tests/proxied/read-after-write.test.ts +7 -7
- package/tests/proxied/views.test.ts +6 -5
- package/tests/races.test.ts +1 -1
- package/tests/rate-limits.test.ts +1 -1
- package/tests/recovery.test.ts +1 -1
- package/tests/seeds/basic.ts +2 -2
- package/tests/seeds/follows.ts +1 -1
- package/tests/seeds/users-bulk.ts +2 -1
- package/tests/seeds/users.ts +5 -2
- package/tests/sequencer.test.ts +6 -4
- package/tests/server.test.ts +11 -13
- package/tests/sync/invertible-ops.test.ts +4 -1
- package/tests/sync/list.test.ts +1 -1
- package/tests/sync/subscribe-repos.test.ts +7 -6
- package/tests/sync/sync.test.ts +2 -2
- package/tests/takedown-appeal.test.ts +3 -2
- package/tsconfig.build.tsbuildinfo +1 -1
package/src/pipethrough.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, ServerResponse } from 'node:http'
|
|
2
2
|
import { PassThrough, Readable, finished } from 'node:stream'
|
|
3
3
|
import { Request } from 'express'
|
|
4
|
-
import { Dispatcher } from 'undici'
|
|
4
|
+
import { Agent, Dispatcher, Pool, interceptors } from 'undici'
|
|
5
5
|
import {
|
|
6
6
|
decodeStream,
|
|
7
7
|
getServiceEndpoint,
|
|
@@ -20,12 +20,49 @@ import {
|
|
|
20
20
|
excludeErrorResult,
|
|
21
21
|
parseReqNsid,
|
|
22
22
|
} from '@atproto/xrpc-server'
|
|
23
|
+
import { isUnicastIp, unicastLookup } from '@atproto-labs/fetch-node'
|
|
23
24
|
import { buildProxiedContentEncoding } from '@atproto-labs/xrpc-utils'
|
|
24
25
|
import { isAccessPrivileged } from './auth-scope.js'
|
|
26
|
+
import { ProxyConfig } from './config/config.js'
|
|
25
27
|
import { AppContext } from './context.js'
|
|
26
28
|
import { chat, com, tools } from './lexicons/index.js'
|
|
27
29
|
import { httpLogger } from './logger.js'
|
|
28
30
|
|
|
31
|
+
export function buildProxyAgent(cfg: ProxyConfig): Dispatcher {
|
|
32
|
+
const agent = new Agent({
|
|
33
|
+
allowH2: cfg.allowHTTP2,
|
|
34
|
+
headersTimeout: cfg.headersTimeout,
|
|
35
|
+
maxResponseSize: cfg.maxResponseSize,
|
|
36
|
+
bodyTimeout: cfg.bodyTimeout,
|
|
37
|
+
factory: cfg.disableSsrfProtection
|
|
38
|
+
? undefined
|
|
39
|
+
: (origin, opts) => {
|
|
40
|
+
const { protocol, hostname } =
|
|
41
|
+
origin instanceof URL ? origin : new URL(origin)
|
|
42
|
+
if (protocol !== 'https:') {
|
|
43
|
+
throw new Error(`Forbidden protocol "${protocol}"`)
|
|
44
|
+
}
|
|
45
|
+
if (isUnicastIp(hostname) === false) {
|
|
46
|
+
throw new Error('Hostname resolved to non-unicast address')
|
|
47
|
+
}
|
|
48
|
+
return new Pool(origin, opts)
|
|
49
|
+
},
|
|
50
|
+
connect: {
|
|
51
|
+
lookup: cfg.disableSsrfProtection ? undefined : unicastLookup,
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
return agent.compose(
|
|
56
|
+
cfg.maxRetries > 0
|
|
57
|
+
? interceptors.retry({
|
|
58
|
+
statusCodes: [], // Only retry on socket errors
|
|
59
|
+
methods: ['GET', 'HEAD'],
|
|
60
|
+
maxRetries: cfg.maxRetries,
|
|
61
|
+
})
|
|
62
|
+
: (dispatch) => dispatch,
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
29
66
|
export const proxyHandler = (ctx: AppContext): CatchallHandler => {
|
|
30
67
|
const performAuth = ctx.authVerifier.authorization<RpcPermissionMatch>({
|
|
31
68
|
authorize: (permissions, { params }) => permissions.assertRpc(params),
|
package/tests/_util.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RequestListener, createServer } from 'node:http'
|
|
2
2
|
import { AddressInfo } from 'node:net'
|
|
3
|
-
|
|
3
|
+
// eslint-disable-next-line import/default
|
|
4
|
+
import httpTerminator from 'http-terminator'
|
|
4
5
|
import { ToolsOzoneModerationDefs, lexToJson } from '@atproto/api'
|
|
5
6
|
import { isCidString } from '@atproto/lex'
|
|
6
7
|
import { isCid, isPlainObject } from '@atproto/lex-data'
|
|
@@ -146,19 +147,11 @@ export const paginateAll = async <T extends { cursor?: string }>(
|
|
|
146
147
|
return results
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
export async function startServer(
|
|
150
|
-
return new Promise<{
|
|
151
|
-
origin: string
|
|
152
|
-
server: Server
|
|
153
|
-
stop: () => Promise<void>
|
|
154
|
-
}>((resolve, reject) => {
|
|
150
|
+
export async function startServer(listener: RequestListener) {
|
|
151
|
+
return new Promise<AsyncDisposable & { port: number }>((resolve, reject) => {
|
|
155
152
|
const onListen = () => {
|
|
156
153
|
const port = (server.address() as AddressInfo).port
|
|
157
|
-
resolve({
|
|
158
|
-
server,
|
|
159
|
-
origin: `http://localhost:${port}`,
|
|
160
|
-
stop: () => stopServer(server),
|
|
161
|
-
})
|
|
154
|
+
resolve({ port, [Symbol.asyncDispose]: () => terminator.terminate() })
|
|
162
155
|
cleanup()
|
|
163
156
|
}
|
|
164
157
|
const onError = (err: Error) => {
|
|
@@ -170,22 +163,12 @@ export async function startServer(app: Express) {
|
|
|
170
163
|
server.removeListener('error', onError)
|
|
171
164
|
}
|
|
172
165
|
|
|
173
|
-
const server =
|
|
166
|
+
const server = createServer(listener)
|
|
174
167
|
.listen(0)
|
|
175
168
|
.once('listening', onListen)
|
|
176
169
|
.once('error', onError)
|
|
177
|
-
})
|
|
178
|
-
}
|
|
179
170
|
|
|
180
|
-
|
|
181
|
-
return new Promise<void>((resolve, reject) => {
|
|
182
|
-
server.close((err) => {
|
|
183
|
-
if (err) {
|
|
184
|
-
reject(err)
|
|
185
|
-
} else {
|
|
186
|
-
resolve()
|
|
187
|
-
}
|
|
188
|
-
})
|
|
171
|
+
const terminator = httpTerminator.createHttpTerminator({ server })
|
|
189
172
|
})
|
|
190
173
|
}
|
|
191
174
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
TestNetworkNoAppView,
|
|
6
6
|
basicSeed,
|
|
7
7
|
} from '@atproto/dev-env'
|
|
8
|
+
import type { DidString } from '@atproto/syntax'
|
|
8
9
|
|
|
9
10
|
describe('account deactivation', () => {
|
|
10
11
|
let network: TestNetworkNoAppView
|
|
@@ -12,7 +13,7 @@ describe('account deactivation', () => {
|
|
|
12
13
|
let sc: SeedClient
|
|
13
14
|
let agent: AtpAgent
|
|
14
15
|
|
|
15
|
-
let alice:
|
|
16
|
+
let alice: DidString
|
|
16
17
|
let aliceAvatar: ImageRef
|
|
17
18
|
|
|
18
19
|
beforeAll(async () => {
|
|
@@ -39,7 +40,7 @@ describe('account deactivation', () => {
|
|
|
39
40
|
})
|
|
40
41
|
|
|
41
42
|
afterAll(async () => {
|
|
42
|
-
await network
|
|
43
|
+
await network?.close()
|
|
43
44
|
})
|
|
44
45
|
|
|
45
46
|
it('deactivates account', async () => {
|
package/tests/account.test.ts
CHANGED
package/tests/auth.test.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AtpAgent, BlobRef } from '@atproto/api'
|
|
2
2
|
import { SeedClient, TestNetworkNoAppView } from '@atproto/dev-env'
|
|
3
|
+
import type { DidString } from '@atproto/syntax'
|
|
3
4
|
import { AppContext } from '../src/index.js'
|
|
4
5
|
|
|
5
6
|
describe('blob deletes', () => {
|
|
@@ -9,8 +10,8 @@ describe('blob deletes', () => {
|
|
|
9
10
|
|
|
10
11
|
let ctx: AppContext
|
|
11
12
|
|
|
12
|
-
let alice:
|
|
13
|
-
let bob:
|
|
13
|
+
let alice: DidString
|
|
14
|
+
let bob: DidString
|
|
14
15
|
|
|
15
16
|
beforeAll(async () => {
|
|
16
17
|
network = await TestNetworkNoAppView.create({
|
|
@@ -35,7 +36,7 @@ describe('blob deletes', () => {
|
|
|
35
36
|
})
|
|
36
37
|
|
|
37
38
|
afterAll(async () => {
|
|
38
|
-
await network
|
|
39
|
+
await network?.close()
|
|
39
40
|
})
|
|
40
41
|
|
|
41
42
|
const getDbBlobsForDid = (did: string) => {
|
|
@@ -184,7 +185,7 @@ describe('blob deletes', () => {
|
|
|
184
185
|
|
|
185
186
|
async function updateProfile(
|
|
186
187
|
sc: SeedClient,
|
|
187
|
-
did:
|
|
188
|
+
did: DidString,
|
|
188
189
|
avatar?: BlobRef,
|
|
189
190
|
banner?: BlobRef,
|
|
190
191
|
) {
|
package/tests/crud.test.ts
CHANGED
package/tests/db.test.ts
CHANGED
package/tests/handles.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AtpAgent } from '@atproto/api'
|
|
2
2
|
import { randomStr } from '@atproto/crypto'
|
|
3
3
|
import { SeedClient, TestNetworkNoAppView } from '@atproto/dev-env'
|
|
4
|
+
import type { DidString } from '@atproto/syntax'
|
|
4
5
|
|
|
5
6
|
describe('pds admin invite views', () => {
|
|
6
7
|
let network: TestNetworkNoAppView
|
|
@@ -20,12 +21,12 @@ describe('pds admin invite views', () => {
|
|
|
20
21
|
})
|
|
21
22
|
|
|
22
23
|
afterAll(async () => {
|
|
23
|
-
await network
|
|
24
|
+
await network?.close()
|
|
24
25
|
})
|
|
25
26
|
|
|
26
|
-
let alice:
|
|
27
|
-
let bob:
|
|
28
|
-
let carol:
|
|
27
|
+
let alice: DidString
|
|
28
|
+
let bob: DidString
|
|
29
|
+
let carol: DidString
|
|
29
30
|
|
|
30
31
|
beforeAll(async () => {
|
|
31
32
|
const adminCode = await agent.api.com.atproto.server.createInviteCode(
|
package/tests/moderation.test.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { AtpAgent } from '@atproto/api'
|
|
|
6
6
|
import { check } from '@atproto/common'
|
|
7
7
|
import { Secp256k1Keypair } from '@atproto/crypto'
|
|
8
8
|
import { SeedClient, TestNetworkNoAppView, basicSeed } from '@atproto/dev-env'
|
|
9
|
+
import type { DidString } from '@atproto/syntax'
|
|
9
10
|
import { AppContext } from '../src/index.js'
|
|
10
11
|
|
|
11
12
|
describe('plc operations', () => {
|
|
@@ -17,7 +18,7 @@ describe('plc operations', () => {
|
|
|
17
18
|
const mailCatcher = new EventEmitter()
|
|
18
19
|
let _origSendMail
|
|
19
20
|
|
|
20
|
-
let alice:
|
|
21
|
+
let alice: DidString
|
|
21
22
|
|
|
22
23
|
let sampleKey: string
|
|
23
24
|
|
|
@@ -48,7 +49,7 @@ describe('plc operations', () => {
|
|
|
48
49
|
})
|
|
49
50
|
|
|
50
51
|
afterAll(async () => {
|
|
51
|
-
await network
|
|
52
|
+
await network?.close()
|
|
52
53
|
})
|
|
53
54
|
|
|
54
55
|
const getMailFrom = async (promise): Promise<SendMailOptions> => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AtpAgent } from '@atproto/api'
|
|
2
2
|
import { SeedClient, TestNetwork } from '@atproto/dev-env'
|
|
3
|
+
import type { DidString } from '@atproto/syntax'
|
|
3
4
|
import { forSnapshot } from '../_util.js'
|
|
4
5
|
import basicSeed from '../seeds/basic.js'
|
|
5
6
|
|
|
@@ -8,7 +9,7 @@ describe('proxies admin requests', () => {
|
|
|
8
9
|
let agent: AtpAgent
|
|
9
10
|
let sc: SeedClient
|
|
10
11
|
|
|
11
|
-
let moderator:
|
|
12
|
+
let moderator: DidString
|
|
12
13
|
|
|
13
14
|
beforeAll(async () => {
|
|
14
15
|
network = await TestNetwork.create({
|
|
@@ -69,7 +70,7 @@ describe('proxies admin requests', () => {
|
|
|
69
70
|
})
|
|
70
71
|
|
|
71
72
|
afterAll(async () => {
|
|
72
|
-
await network
|
|
73
|
+
await network?.close()
|
|
73
74
|
})
|
|
74
75
|
|
|
75
76
|
it('creates reports of a repo.', async () => {
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { once } from 'node:events'
|
|
2
|
-
import http from 'node:http'
|
|
3
|
-
import { AddressInfo } from 'node:net'
|
|
4
|
-
import express from 'express'
|
|
5
1
|
import { AtpAgent } from '@atproto/api'
|
|
6
2
|
import { SeedClient, TestNetworkNoAppView } from '@atproto/dev-env'
|
|
7
3
|
import { createServer, verifyJwt } from '@atproto/xrpc-server'
|
|
8
4
|
import { app } from '../../src/lexicons/index.js'
|
|
5
|
+
import { startServer } from '../_util.js'
|
|
9
6
|
import usersSeed from '../seeds/users.js'
|
|
10
7
|
|
|
11
8
|
describe('notif service proxy', () => {
|
|
12
9
|
let network: TestNetworkNoAppView
|
|
13
|
-
let notifServer:
|
|
10
|
+
let notifServer: AsyncDisposable & { port: number }
|
|
14
11
|
let notifDid: string
|
|
15
12
|
let agent: AtpAgent
|
|
16
13
|
let sc: SeedClient
|
|
@@ -29,10 +26,9 @@ describe('notif service proxy', () => {
|
|
|
29
26
|
notifServer = await createMockNotifService(spy)
|
|
30
27
|
notifDid = sc.dids.dan
|
|
31
28
|
await plc.updateData(notifDid, network.pds.ctx.plcRotationKey, (x) => {
|
|
32
|
-
const addr = notifServer.address() as AddressInfo
|
|
33
29
|
x.services['bsky_notif'] = {
|
|
34
30
|
type: 'BskyNotificationService',
|
|
35
|
-
endpoint: `http://localhost:${
|
|
31
|
+
endpoint: `http://localhost:${notifServer.port}`,
|
|
36
32
|
}
|
|
37
33
|
return x
|
|
38
34
|
})
|
|
@@ -40,9 +36,8 @@ describe('notif service proxy', () => {
|
|
|
40
36
|
}, 20_000) // @NOTE seeding can take a while
|
|
41
37
|
|
|
42
38
|
afterAll(async () => {
|
|
43
|
-
await
|
|
44
|
-
|
|
45
|
-
await once(notifServer, 'close')
|
|
39
|
+
await notifServer?.[Symbol.asyncDispose]()
|
|
40
|
+
await network?.close()
|
|
46
41
|
})
|
|
47
42
|
|
|
48
43
|
it('proxies to notif service.', async () => {
|
|
@@ -86,7 +81,5 @@ async function createMockNotifService(ref: { current: unknown }) {
|
|
|
86
81
|
jwt: req.headers.authorization?.replace('Bearer ', ''),
|
|
87
82
|
}
|
|
88
83
|
})
|
|
89
|
-
|
|
90
|
-
await once(server, 'listening')
|
|
91
|
-
return server
|
|
84
|
+
return startServer(svc.router)
|
|
92
85
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AtpAgent } from '@atproto/api'
|
|
2
2
|
import { SeedClient, TestNetwork } from '@atproto/dev-env'
|
|
3
|
+
import type { DidString } from '@atproto/syntax'
|
|
3
4
|
import basicSeed from '../seeds/basic.js'
|
|
4
5
|
|
|
5
6
|
describe('proxies appview procedures', () => {
|
|
@@ -7,9 +8,9 @@ describe('proxies appview procedures', () => {
|
|
|
7
8
|
let agent: AtpAgent
|
|
8
9
|
let sc: SeedClient
|
|
9
10
|
|
|
10
|
-
let alice:
|
|
11
|
-
let bob:
|
|
12
|
-
let carol:
|
|
11
|
+
let alice: DidString
|
|
12
|
+
let bob: DidString
|
|
13
|
+
let carol: DidString
|
|
13
14
|
|
|
14
15
|
beforeAll(async () => {
|
|
15
16
|
network = await TestNetwork.create({
|
|
@@ -25,7 +26,7 @@ describe('proxies appview procedures', () => {
|
|
|
25
26
|
})
|
|
26
27
|
|
|
27
28
|
afterAll(async () => {
|
|
28
|
-
await network
|
|
29
|
+
await network?.close()
|
|
29
30
|
})
|
|
30
31
|
|
|
31
32
|
it('maintains muted actors.', async () => {
|
|
@@ -4,6 +4,8 @@ import { AddressInfo } from 'node:net'
|
|
|
4
4
|
import { setTimeout as sleep } from 'node:timers/promises'
|
|
5
5
|
import * as plc from '@did-plc/lib'
|
|
6
6
|
import express from 'express'
|
|
7
|
+
// eslint-disable-next-line import/default
|
|
8
|
+
import httpTerminator from 'http-terminator'
|
|
7
9
|
import AtpAgent from '@atproto/api'
|
|
8
10
|
import { Keypair } from '@atproto/crypto'
|
|
9
11
|
import { TestNetworkNoAppView } from '@atproto/dev-env'
|
|
@@ -158,10 +160,14 @@ describe('proxy header', () => {
|
|
|
158
160
|
})
|
|
159
161
|
|
|
160
162
|
class ProxyServer {
|
|
163
|
+
private terminator: httpTerminator.HttpTerminator
|
|
164
|
+
|
|
161
165
|
constructor(
|
|
162
|
-
|
|
166
|
+
server: http.Server,
|
|
163
167
|
public did: string,
|
|
164
|
-
) {
|
|
168
|
+
) {
|
|
169
|
+
this.terminator = httpTerminator.createHttpTerminator({ server })
|
|
170
|
+
}
|
|
165
171
|
|
|
166
172
|
static async create(
|
|
167
173
|
plcClient: plc.Client,
|
|
@@ -245,11 +251,6 @@ class ProxyServer {
|
|
|
245
251
|
}
|
|
246
252
|
|
|
247
253
|
async close() {
|
|
248
|
-
await
|
|
249
|
-
this.server.close((err) => {
|
|
250
|
-
if (err) reject(err)
|
|
251
|
-
else resolve()
|
|
252
|
-
})
|
|
253
|
-
})
|
|
254
|
+
await this.terminator.terminate()
|
|
254
255
|
}
|
|
255
256
|
}
|
|
@@ -4,8 +4,11 @@ import http from 'node:http'
|
|
|
4
4
|
import { AddressInfo } from 'node:net'
|
|
5
5
|
import * as plc from '@did-plc/lib'
|
|
6
6
|
import express from 'express'
|
|
7
|
+
// eslint-disable-next-line import/default
|
|
8
|
+
import httpTerminator from 'http-terminator'
|
|
7
9
|
import { Keypair } from '@atproto/crypto'
|
|
8
10
|
import { SeedClient, TestNetworkNoAppView, usersSeed } from '@atproto/dev-env'
|
|
11
|
+
import type { DidString } from '@atproto/syntax'
|
|
9
12
|
import { verifyJwt } from '@atproto/xrpc-server'
|
|
10
13
|
import { parseProxyHeader } from '../../src/pipethrough.js'
|
|
11
14
|
|
|
@@ -13,7 +16,7 @@ describe('proxy header', () => {
|
|
|
13
16
|
let network: TestNetworkNoAppView
|
|
14
17
|
let sc: SeedClient
|
|
15
18
|
|
|
16
|
-
let alice:
|
|
19
|
+
let alice: DidString
|
|
17
20
|
|
|
18
21
|
let proxyServer: ProxyServer
|
|
19
22
|
|
|
@@ -35,8 +38,8 @@ describe('proxy header', () => {
|
|
|
35
38
|
}, 20_000) // @NOTE seeding can take a while
|
|
36
39
|
|
|
37
40
|
afterAll(async () => {
|
|
38
|
-
await proxyServer
|
|
39
|
-
await network
|
|
41
|
+
await proxyServer?.close()
|
|
42
|
+
await network?.close()
|
|
40
43
|
})
|
|
41
44
|
|
|
42
45
|
it('parses proxy header', async () => {
|
|
@@ -171,12 +174,16 @@ type ProxyReq = {
|
|
|
171
174
|
}
|
|
172
175
|
|
|
173
176
|
class ProxyServer {
|
|
177
|
+
private terminator: httpTerminator.HttpTerminator
|
|
178
|
+
|
|
174
179
|
constructor(
|
|
175
|
-
|
|
180
|
+
server: http.Server,
|
|
176
181
|
public url: string,
|
|
177
182
|
public did: string,
|
|
178
183
|
public requests: ProxyReq[],
|
|
179
|
-
) {
|
|
184
|
+
) {
|
|
185
|
+
this.terminator = httpTerminator.createHttpTerminator({ server })
|
|
186
|
+
}
|
|
180
187
|
|
|
181
188
|
static async create(
|
|
182
189
|
plcClient: plc.Client,
|
|
@@ -226,9 +233,7 @@ class ProxyServer {
|
|
|
226
233
|
return new ProxyServer(server, url, did, requests)
|
|
227
234
|
}
|
|
228
235
|
|
|
229
|
-
close(): Promise<void> {
|
|
230
|
-
|
|
231
|
-
this.server.close(() => resolve())
|
|
232
|
-
})
|
|
236
|
+
async close(): Promise<void> {
|
|
237
|
+
await this.terminator.terminate()
|
|
233
238
|
}
|
|
234
239
|
}
|