@atproto/pds 0.5.5 → 0.5.7
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 +31 -0
- package/dist/account-manager/account-manager.d.ts +51 -13
- package/dist/account-manager/account-manager.d.ts.map +1 -1
- package/dist/account-manager/account-manager.js +86 -26
- package/dist/account-manager/account-manager.js.map +1 -1
- package/dist/account-manager/db/migrations/005-oauth-account-management.d.ts.map +1 -1
- package/dist/account-manager/db/migrations/005-oauth-account-management.js +3 -4
- package/dist/account-manager/db/migrations/005-oauth-account-management.js.map +1 -1
- package/dist/account-manager/db/schema/authorization-request.d.ts +2 -2
- package/dist/account-manager/db/schema/authorization-request.d.ts.map +1 -1
- package/dist/account-manager/db/schema/authorization-request.js.map +1 -1
- package/dist/account-manager/db/schema/authorized-client.d.ts +2 -2
- package/dist/account-manager/db/schema/authorized-client.d.ts.map +1 -1
- package/dist/account-manager/db/schema/authorized-client.js.map +1 -1
- package/dist/account-manager/db/schema/token.d.ts +2 -2
- package/dist/account-manager/db/schema/token.d.ts.map +1 -1
- package/dist/account-manager/db/schema/token.js.map +1 -1
- package/dist/account-manager/helpers/account-device.d.ts +23 -196
- package/dist/account-manager/helpers/account-device.d.ts.map +1 -1
- package/dist/account-manager/helpers/account-device.js +3 -3
- package/dist/account-manager/helpers/account-device.js.map +1 -1
- package/dist/account-manager/helpers/account.d.ts +14 -4
- package/dist/account-manager/helpers/account.d.ts.map +1 -1
- package/dist/account-manager/helpers/account.js +17 -11
- package/dist/account-manager/helpers/account.js.map +1 -1
- package/dist/account-manager/helpers/auth.js +1 -1
- package/dist/account-manager/helpers/auth.js.map +1 -1
- package/dist/account-manager/helpers/authorization-request.d.ts +83 -5
- package/dist/account-manager/helpers/authorization-request.d.ts.map +1 -1
- package/dist/account-manager/helpers/authorization-request.js +8 -8
- package/dist/account-manager/helpers/authorization-request.js.map +1 -1
- package/dist/account-manager/helpers/authorized-client.d.ts +5 -4
- package/dist/account-manager/helpers/authorized-client.d.ts.map +1 -1
- package/dist/account-manager/helpers/authorized-client.js +3 -0
- package/dist/account-manager/helpers/authorized-client.js.map +1 -1
- package/dist/account-manager/helpers/device.d.ts +9 -3
- package/dist/account-manager/helpers/device.d.ts.map +1 -1
- package/dist/account-manager/helpers/device.js +4 -4
- package/dist/account-manager/helpers/device.js.map +1 -1
- package/dist/account-manager/helpers/invite.d.ts +35 -2
- package/dist/account-manager/helpers/invite.d.ts.map +1 -1
- package/dist/account-manager/helpers/lexicon.d.ts.map +1 -1
- package/dist/account-manager/helpers/lexicon.js +6 -0
- package/dist/account-manager/helpers/lexicon.js.map +1 -1
- package/dist/account-manager/helpers/password.d.ts +1 -0
- package/dist/account-manager/helpers/password.d.ts.map +1 -1
- package/dist/account-manager/helpers/password.js +3 -0
- package/dist/account-manager/helpers/password.js.map +1 -1
- package/dist/account-manager/helpers/token.d.ts +72 -1031
- package/dist/account-manager/helpers/token.d.ts.map +1 -1
- package/dist/account-manager/helpers/token.js +13 -10
- package/dist/account-manager/helpers/token.js.map +1 -1
- package/dist/account-manager/helpers/used-refresh-token.d.ts +6 -2
- package/dist/account-manager/helpers/used-refresh-token.d.ts.map +1 -1
- package/dist/account-manager/oauth-store.d.ts +17 -13
- package/dist/account-manager/oauth-store.d.ts.map +1 -1
- package/dist/account-manager/oauth-store.js +89 -39
- package/dist/account-manager/oauth-store.js.map +1 -1
- package/dist/actor-store/blob/reader.d.ts.map +1 -1
- package/dist/actor-store/blob/reader.js +2 -3
- package/dist/actor-store/blob/reader.js.map +1 -1
- package/dist/actor-store/record/reader.js +3 -3
- package/dist/actor-store/record/reader.js.map +1 -1
- package/dist/actor-store/repo/sql-repo-reader.d.ts +5 -1
- package/dist/actor-store/repo/sql-repo-reader.d.ts.map +1 -1
- package/dist/actor-store/repo/sql-repo-reader.js.map +1 -1
- package/dist/api/com/atproto/admin/updateSubjectStatus.d.ts.map +1 -1
- package/dist/api/com/atproto/admin/updateSubjectStatus.js +12 -4
- package/dist/api/com/atproto/admin/updateSubjectStatus.js.map +1 -1
- package/dist/api/com/atproto/server/activateAccount.d.ts.map +1 -1
- package/dist/api/com/atproto/server/activateAccount.js +25 -31
- package/dist/api/com/atproto/server/activateAccount.js.map +1 -1
- package/dist/api/com/atproto/server/deactivateAccount.d.ts.map +1 -1
- package/dist/api/com/atproto/server/deactivateAccount.js +3 -4
- package/dist/api/com/atproto/server/deactivateAccount.js.map +1 -1
- package/dist/api/com/atproto/server/deleteAccount.d.ts.map +1 -1
- package/dist/api/com/atproto/server/deleteAccount.js +51 -37
- package/dist/api/com/atproto/server/deleteAccount.js.map +1 -1
- package/dist/api/com/atproto/server/util.d.ts +25 -6
- package/dist/api/com/atproto/server/util.d.ts.map +1 -1
- package/dist/api/com/atproto/server/util.js.map +1 -1
- 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/config/config.d.ts +2 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +4 -1
- package/dist/config/config.js.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +5 -32
- package/dist/context.js.map +1 -1
- package/dist/db/migrator.d.ts +4 -3
- package/dist/db/migrator.d.ts.map +1 -1
- package/dist/db/migrator.js +1 -1
- package/dist/db/migrator.js.map +1 -1
- package/dist/db/pagination.d.ts +2 -1
- package/dist/db/pagination.d.ts.map +1 -1
- package/dist/db/pagination.js +2 -2
- package/dist/db/pagination.js.map +1 -1
- package/dist/db/util.d.ts +3 -3
- package/dist/db/util.d.ts.map +1 -1
- package/dist/db/util.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/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/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/mailer/index.d.ts +2 -0
- package/dist/mailer/index.d.ts.map +1 -1
- package/dist/mailer/index.js +2 -0
- package/dist/mailer/index.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/dist/scripts/sequencer-recovery/recovery-db.js.map +1 -1
- package/dist/sequencer/events.d.ts.map +1 -1
- package/dist/sequencer/events.js +6 -13
- package/dist/sequencer/events.js.map +1 -1
- package/dist/sequencer/sequencer.d.ts +1 -1
- package/dist/sequencer/sequencer.d.ts.map +1 -1
- package/dist/sequencer/sequencer.js.map +1 -1
- package/package.json +14 -14
- package/src/account-manager/account-manager.ts +135 -36
- package/src/account-manager/db/migrations/005-oauth-account-management.ts +6 -5
- package/src/account-manager/db/schema/authorization-request.ts +2 -1
- package/src/account-manager/db/schema/authorized-client.ts +6 -2
- package/src/account-manager/db/schema/token.ts +2 -2
- package/src/account-manager/helpers/account-device.ts +5 -11
- package/src/account-manager/helpers/account.ts +39 -16
- package/src/account-manager/helpers/auth.ts +2 -2
- package/src/account-manager/helpers/authorization-request.ts +12 -8
- package/src/account-manager/helpers/authorized-client.ts +12 -6
- package/src/account-manager/helpers/device.ts +4 -4
- package/src/account-manager/helpers/lexicon.ts +8 -3
- package/src/account-manager/helpers/password.ts +6 -0
- package/src/account-manager/helpers/token.ts +17 -11
- package/src/account-manager/oauth-store.ts +129 -61
- package/src/actor-store/blob/reader.ts +8 -5
- package/src/actor-store/record/reader.ts +3 -3
- package/src/actor-store/repo/sql-repo-reader.ts +1 -1
- package/src/api/com/atproto/admin/updateSubjectStatus.ts +16 -4
- package/src/api/com/atproto/server/activateAccount.ts +27 -49
- package/src/api/com/atproto/server/deactivateAccount.ts +3 -7
- package/src/api/com/atproto/server/deleteAccount.ts +60 -43
- package/src/api/com/atproto/server/util.ts +24 -7
- package/src/background.ts +49 -18
- package/src/config/config.ts +7 -2
- package/src/context.ts +6 -40
- package/src/db/migrator.ts +2 -1
- package/src/db/pagination.ts +7 -7
- package/src/db/util.ts +5 -2
- package/src/index.ts +31 -13
- package/src/mailer/index.ts +4 -2
- package/src/pipethrough.ts +38 -1
- package/src/scripts/sequencer-recovery/recovery-db.ts +1 -1
- package/src/sequencer/events.ts +8 -13
- package/src/sequencer/sequencer.ts +1 -3
- package/tests/_util.ts +8 -25
- package/tests/account-deactivation.test.ts +1 -1
- package/tests/account-deletion.test.ts +1 -1
- package/tests/account-manager.test.ts +79 -0
- package/tests/account-migration.test.ts +2 -2
- package/tests/account-status.test.ts +206 -0
- 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 +1 -1
- package/tests/create-post.test.ts +1 -1
- package/tests/crud.test.ts +1 -1
- package/tests/db.test.ts +4 -4
- 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 +1 -1
- package/tests/moderation.test.ts +1 -1
- package/tests/moderator-auth.test.ts +1 -1
- package/tests/oauth.test.ts +91 -0
- package/tests/plc-operations.test.ts +1 -1
- package/tests/preferences.test.ts +1 -1
- package/tests/proxied/admin.test.ts +1 -1
- package/tests/proxied/feedgen.test.ts +1 -1
- package/tests/proxied/notif.test.ts +6 -13
- package/tests/proxied/procedures.test.ts +1 -1
- package/tests/proxied/proxy-catchall.test.ts +9 -8
- package/tests/proxied/proxy-header.test.ts +12 -8
- package/tests/proxied/proxy-oauth-aud.test.ts +17 -10
- package/tests/proxied/read-after-write.test.ts +4 -5
- package/tests/proxied/views.test.ts +1 -1
- 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/users.ts +4 -1
- package/tests/sequencer.test.ts +1 -1
- package/tests/server.test.ts +9 -12
- package/tests/sync/invertible-ops.test.ts +1 -1
- package/tests/sync/list.test.ts +1 -1
- package/tests/sync/subscribe-repos.test.ts +1 -1
- package/tests/sync/sync.test.ts +1 -1
- package/tests/takedown-appeal.test.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -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
|
}
|
|
@@ -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,6 +4,8 @@ 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'
|
|
9
11
|
import { verifyJwt } from '@atproto/xrpc-server'
|
|
@@ -35,8 +37,8 @@ describe('proxy header', () => {
|
|
|
35
37
|
}, 20_000) // @NOTE seeding can take a while
|
|
36
38
|
|
|
37
39
|
afterAll(async () => {
|
|
38
|
-
await proxyServer
|
|
39
|
-
await network
|
|
40
|
+
await proxyServer?.close()
|
|
41
|
+
await network?.close()
|
|
40
42
|
})
|
|
41
43
|
|
|
42
44
|
it('parses proxy header', async () => {
|
|
@@ -171,12 +173,16 @@ type ProxyReq = {
|
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
class ProxyServer {
|
|
176
|
+
private terminator: httpTerminator.HttpTerminator
|
|
177
|
+
|
|
174
178
|
constructor(
|
|
175
|
-
|
|
179
|
+
server: http.Server,
|
|
176
180
|
public url: string,
|
|
177
181
|
public did: string,
|
|
178
182
|
public requests: ProxyReq[],
|
|
179
|
-
) {
|
|
183
|
+
) {
|
|
184
|
+
this.terminator = httpTerminator.createHttpTerminator({ server })
|
|
185
|
+
}
|
|
180
186
|
|
|
181
187
|
static async create(
|
|
182
188
|
plcClient: plc.Client,
|
|
@@ -226,9 +232,7 @@ class ProxyServer {
|
|
|
226
232
|
return new ProxyServer(server, url, did, requests)
|
|
227
233
|
}
|
|
228
234
|
|
|
229
|
-
close(): Promise<void> {
|
|
230
|
-
|
|
231
|
-
this.server.close(() => resolve())
|
|
232
|
-
})
|
|
235
|
+
async close(): Promise<void> {
|
|
236
|
+
await this.terminator.terminate()
|
|
233
237
|
}
|
|
234
238
|
}
|
|
@@ -3,6 +3,8 @@ import http from 'node:http'
|
|
|
3
3
|
import { AddressInfo } from 'node:net'
|
|
4
4
|
import * as plc from '@did-plc/lib'
|
|
5
5
|
import express from 'express'
|
|
6
|
+
// eslint-disable-next-line import/default
|
|
7
|
+
import httpTerminator from 'http-terminator'
|
|
6
8
|
import { Keypair } from '@atproto/crypto'
|
|
7
9
|
import { SeedClient, TestNetworkNoAppView, usersSeed } from '@atproto/dev-env'
|
|
8
10
|
import { ScopePermissions } from '@atproto/oauth-scopes'
|
|
@@ -30,7 +32,7 @@ describe('proxy oauth audience', () => {
|
|
|
30
32
|
let sc: SeedClient
|
|
31
33
|
let alice: string
|
|
32
34
|
let upstream: ProxyServer
|
|
33
|
-
let
|
|
35
|
+
let terminator: httpTerminator.HttpTerminator
|
|
34
36
|
let serverUrl: string
|
|
35
37
|
|
|
36
38
|
beforeAll(async () => {
|
|
@@ -88,15 +90,18 @@ describe('proxy oauth audience', () => {
|
|
|
88
90
|
res.status(err.status ?? err.statusCode ?? 500).end()
|
|
89
91
|
},
|
|
90
92
|
)
|
|
91
|
-
server = app.listen(0)
|
|
93
|
+
const server = app.listen(0)
|
|
92
94
|
await once(server, 'listening')
|
|
95
|
+
terminator = httpTerminator.createHttpTerminator({ server })
|
|
93
96
|
serverUrl = `http://localhost:${(server.address() as AddressInfo).port}`
|
|
94
97
|
})
|
|
95
98
|
|
|
96
99
|
afterAll(async () => {
|
|
97
|
-
await
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
await Promise.all([
|
|
101
|
+
terminator?.terminate(),
|
|
102
|
+
upstream?.close(),
|
|
103
|
+
network?.close(),
|
|
104
|
+
])
|
|
100
105
|
})
|
|
101
106
|
|
|
102
107
|
it('matches an OAuth rpc scope granted with combined did#serviceId aud', async () => {
|
|
@@ -127,11 +132,15 @@ describe('proxy oauth audience', () => {
|
|
|
127
132
|
})
|
|
128
133
|
|
|
129
134
|
class ProxyServer {
|
|
135
|
+
private terminator: httpTerminator.HttpTerminator
|
|
136
|
+
|
|
130
137
|
constructor(
|
|
131
|
-
|
|
138
|
+
server: http.Server,
|
|
132
139
|
public url: string,
|
|
133
140
|
public did: string,
|
|
134
|
-
) {
|
|
141
|
+
) {
|
|
142
|
+
this.terminator = httpTerminator.createHttpTerminator({ server })
|
|
143
|
+
}
|
|
135
144
|
|
|
136
145
|
static async create(
|
|
137
146
|
plcClient: plc.Client,
|
|
@@ -168,8 +177,6 @@ class ProxyServer {
|
|
|
168
177
|
}
|
|
169
178
|
|
|
170
179
|
close(): Promise<void> {
|
|
171
|
-
return
|
|
172
|
-
this.server.close(() => resolve())
|
|
173
|
-
})
|
|
180
|
+
return this.terminator.terminate()
|
|
174
181
|
}
|
|
175
182
|
}
|
|
@@ -27,15 +27,14 @@ describe('proxy read after write', () => {
|
|
|
27
27
|
agent = network.pds.getAgent()
|
|
28
28
|
sc = network.getSeedClient()
|
|
29
29
|
await basicSeed(sc, { addModLabels: network.bsky })
|
|
30
|
-
await network.processAll()
|
|
31
30
|
alice = sc.dids.alice
|
|
32
31
|
carol = sc.dids.carol
|
|
33
|
-
await network.
|
|
32
|
+
await network.processAll()
|
|
33
|
+
await network.bsky.sub.stop()
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
36
|
+
beforeEach(async () => network.processAll())
|
|
37
|
+
afterAll(async () => network?.close())
|
|
39
38
|
|
|
40
39
|
it('handles read after write on profiles', async () => {
|
|
41
40
|
await sc.updateProfile(alice, { displayName: 'blah' })
|
package/tests/races.test.ts
CHANGED
package/tests/recovery.test.ts
CHANGED
package/tests/seeds/basic.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { EXAMPLE_LABELER, SeedClient, TestBsky } from '@atproto/dev-env'
|
|
|
2
2
|
import { app, com } from '../../src/lexicons/index.js'
|
|
3
3
|
import usersSeed from './users.js'
|
|
4
4
|
|
|
5
|
-
export default async (
|
|
5
|
+
export default async function basicSeed(
|
|
6
6
|
sc: SeedClient,
|
|
7
7
|
opts?: { inviteCode?: string; addModLabels?: TestBsky },
|
|
8
|
-
)
|
|
8
|
+
) {
|
|
9
9
|
await usersSeed(sc, opts)
|
|
10
10
|
|
|
11
11
|
const alice = sc.dids.alice
|
package/tests/seeds/users.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { SeedClient } from '@atproto/dev-env'
|
|
2
2
|
|
|
3
|
-
export default async (
|
|
3
|
+
export default async function usersSeed(
|
|
4
|
+
sc: SeedClient,
|
|
5
|
+
opts?: { inviteCode?: string },
|
|
6
|
+
) {
|
|
4
7
|
await sc.createAccount('alice', {
|
|
5
8
|
...users.alice,
|
|
6
9
|
inviteCode: opts?.inviteCode,
|
package/tests/sequencer.test.ts
CHANGED
package/tests/server.test.ts
CHANGED
|
@@ -28,7 +28,7 @@ describe('server', () => {
|
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
afterAll(async () => {
|
|
31
|
-
await network
|
|
31
|
+
await network?.close()
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
it('preserves 404s.', async () => {
|
|
@@ -43,17 +43,14 @@ describe('server', () => {
|
|
|
43
43
|
})
|
|
44
44
|
.use(errorHandler)
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} finally {
|
|
55
|
-
await stop()
|
|
56
|
-
}
|
|
46
|
+
await using server = await startServer(app)
|
|
47
|
+
|
|
48
|
+
const res = await fetch(`http://localhost:${server.port}/oops`)
|
|
49
|
+
expect(res.status).toEqual(500)
|
|
50
|
+
await expect(res.json()).resolves.toEqual({
|
|
51
|
+
error: 'InternalServerError',
|
|
52
|
+
message: 'Internal Server Error',
|
|
53
|
+
})
|
|
57
54
|
})
|
|
58
55
|
|
|
59
56
|
it('limits size of json input.', async () => {
|
package/tests/sync/list.test.ts
CHANGED
package/tests/sync/sync.test.ts
CHANGED