@atproto/bsky 0.0.10 → 0.0.12
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 +26 -0
- package/dist/api/com/atproto/admin/util.d.ts +5 -0
- package/dist/config.d.ts +2 -0
- package/dist/context.d.ts +8 -0
- package/dist/db/index.js +51 -2
- package/dist/db/index.js.map +3 -3
- package/dist/db/migrations/20230929T192920807Z-record-cursor-indexes.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/did-cache.d.ts +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1818 -580
- package/dist/index.js.map +3 -3
- package/dist/lexicon/index.d.ts +16 -0
- package/dist/lexicon/lexicons.d.ts +330 -3
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +28 -0
- package/dist/lexicon/types/com/atproto/admin/getAccountInfo.d.ts +29 -0
- package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts +39 -0
- package/dist/lexicon/types/com/atproto/admin/searchRepos.d.ts +0 -1
- package/dist/lexicon/types/com/atproto/admin/updateSubjectStatus.d.ts +46 -0
- package/dist/lexicon/types/com/atproto/server/confirmEmail.d.ts +27 -0
- package/dist/lexicon/types/com/atproto/server/createAccount.d.ts +2 -0
- package/dist/lexicon/types/com/atproto/server/createSession.d.ts +2 -0
- package/dist/lexicon/types/com/atproto/server/getSession.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/server/requestEmailConfirmation.d.ts +19 -0
- package/dist/lexicon/types/com/atproto/server/requestEmailUpdate.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/server/reserveSigningKey.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/server/updateEmail.d.ts +27 -0
- package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +1 -0
- package/dist/services/actor/index.d.ts +2 -2
- package/dist/services/actor/types.d.ts +1 -0
- package/dist/services/graph/index.d.ts +2 -0
- package/dist/services/moderation/index.d.ts +13 -3
- package/dist/services/util/search.d.ts +3 -3
- package/package.json +13 -14
- package/src/api/app/bsky/actor/searchActors.ts +36 -22
- package/src/api/app/bsky/actor/searchActorsTypeahead.ts +24 -17
- package/src/api/app/bsky/feed/getAuthorFeed.ts +2 -2
- package/src/api/app/bsky/feed/getPostThread.ts +2 -2
- package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +1 -0
- package/src/api/app/bsky/notification/listNotifications.ts +33 -22
- package/src/api/com/atproto/admin/getModerationAction.ts +28 -2
- package/src/api/com/atproto/admin/getModerationReport.ts +27 -2
- package/src/api/com/atproto/admin/getRecord.ts +14 -2
- package/src/api/com/atproto/admin/getRepo.ts +13 -2
- package/src/api/com/atproto/admin/reverseModerationAction.ts +31 -5
- package/src/api/com/atproto/admin/searchRepos.ts +6 -12
- package/src/api/com/atproto/admin/takeModerationAction.ts +41 -7
- package/src/api/com/atproto/admin/util.ts +50 -0
- package/src/api/well-known.ts +8 -0
- package/src/auth.ts +12 -5
- package/src/auto-moderator/index.ts +1 -0
- package/src/config.ts +7 -0
- package/src/context.ts +30 -0
- package/src/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +40 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/did-cache.ts +29 -14
- package/src/feed-gen/with-friends.ts +2 -2
- package/src/index.ts +9 -1
- package/src/indexer/subscription.ts +1 -21
- package/src/lexicon/index.ts +96 -0
- package/src/lexicon/lexicons.ts +368 -4
- package/src/lexicon/types/app/bsky/actor/defs.ts +1 -0
- package/src/lexicon/types/com/atproto/admin/defs.ts +61 -0
- package/src/lexicon/types/com/atproto/admin/getAccountInfo.ts +41 -0
- package/src/lexicon/types/com/atproto/admin/getSubjectStatus.ts +54 -0
- package/src/lexicon/types/com/atproto/admin/searchRepos.ts +0 -1
- package/src/lexicon/types/com/atproto/admin/updateSubjectStatus.ts +61 -0
- package/src/lexicon/types/com/atproto/server/confirmEmail.ts +40 -0
- package/src/lexicon/types/com/atproto/server/createAccount.ts +2 -0
- package/src/lexicon/types/com/atproto/server/createSession.ts +2 -0
- package/src/lexicon/types/com/atproto/server/getSession.ts +1 -0
- package/src/lexicon/types/com/atproto/server/refreshSession.ts +1 -0
- package/src/lexicon/types/com/atproto/server/requestEmailConfirmation.ts +31 -0
- package/src/lexicon/types/com/atproto/server/requestEmailUpdate.ts +43 -0
- package/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +44 -0
- package/src/lexicon/types/com/atproto/server/updateEmail.ts +41 -0
- package/src/lexicon/types/com/atproto/sync/listRepos.ts +1 -0
- package/src/logger.ts +8 -0
- package/src/services/actor/index.ts +16 -10
- package/src/services/actor/types.ts +1 -0
- package/src/services/actor/views.ts +26 -8
- package/src/services/graph/index.ts +26 -7
- package/src/services/indexing/index.ts +15 -17
- package/src/services/moderation/index.ts +94 -14
- package/src/services/moderation/views.ts +1 -0
- package/src/services/util/search.ts +24 -23
- package/tests/__snapshots__/feed-generation.test.ts.snap +12 -12
- package/tests/__snapshots__/indexing.test.ts.snap +4 -4
- package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +172 -0
- package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +178 -0
- package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +177 -0
- package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +307 -0
- package/tests/admin/__snapshots__/get-record.test.ts.snap +275 -0
- package/tests/admin/__snapshots__/get-repo.test.ts.snap +103 -0
- package/tests/admin/get-moderation-action.test.ts +100 -0
- package/tests/admin/get-moderation-actions.test.ts +164 -0
- package/tests/admin/get-moderation-report.test.ts +100 -0
- package/tests/admin/get-moderation-reports.test.ts +332 -0
- package/tests/admin/get-record.test.ts +115 -0
- package/tests/admin/get-repo.test.ts +101 -0
- package/tests/{moderation.test.ts → admin/moderation.test.ts} +107 -9
- package/tests/admin/repo-search.test.ts +124 -0
- package/tests/algos/hot-classic.test.ts +3 -5
- package/tests/algos/whats-hot.test.ts +3 -5
- package/tests/algos/with-friends.test.ts +2 -4
- package/tests/auth.test.ts +64 -0
- package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -3
- package/tests/auto-moderator/labeler.test.ts +5 -7
- package/tests/auto-moderator/takedowns.test.ts +11 -12
- package/tests/blob-resolver.test.ts +1 -3
- package/tests/did-cache.test.ts +2 -5
- package/tests/feed-generation.test.ts +8 -6
- package/tests/handle-invalidation.test.ts +2 -3
- package/tests/image/server.test.ts +1 -4
- package/tests/image/sharp.test.ts +1 -1
- package/tests/indexing.test.ts +4 -4
- package/tests/notification-server.test.ts +2 -3
- package/tests/pipeline/backpressure.test.ts +2 -3
- package/tests/pipeline/reingest.test.ts +7 -4
- package/tests/pipeline/repartition.test.ts +2 -3
- package/tests/reprocessing.test.ts +2 -6
- package/tests/seeds/basic.ts +4 -4
- package/tests/seeds/follows.ts +1 -1
- package/tests/seeds/likes.ts +1 -1
- package/tests/seeds/reposts.ts +1 -1
- package/tests/seeds/users-bulk.ts +1 -1
- package/tests/seeds/users.ts +1 -1
- package/tests/server.test.ts +1 -3
- package/tests/subscription/repo.test.ts +2 -4
- package/tests/views/__snapshots__/author-feed.test.ts.snap +24 -24
- package/tests/views/__snapshots__/block-lists.test.ts.snap +42 -7
- package/tests/views/__snapshots__/blocks.test.ts.snap +2 -2
- package/tests/views/__snapshots__/list-feed.test.ts.snap +6 -6
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +15 -4
- package/tests/views/__snapshots__/mutes.test.ts.snap +2 -2
- package/tests/views/__snapshots__/notifications.test.ts.snap +2 -2
- package/tests/views/__snapshots__/posts.test.ts.snap +8 -8
- package/tests/views/__snapshots__/thread.test.ts.snap +10 -10
- package/tests/views/__snapshots__/timeline.test.ts.snap +58 -58
- package/tests/views/actor-likes.test.ts +2 -3
- package/tests/views/actor-search.test.ts +5 -5
- package/tests/views/admin/repo-search.test.ts +2 -4
- package/tests/views/author-feed.test.ts +2 -4
- package/tests/views/block-lists.test.ts +34 -7
- package/tests/views/blocks.test.ts +6 -3
- package/tests/views/follows.test.ts +2 -4
- package/tests/views/likes.test.ts +2 -5
- package/tests/views/list-feed.test.ts +2 -4
- package/tests/views/mute-lists.test.ts +23 -5
- package/tests/views/mutes.test.ts +2 -5
- package/tests/views/notifications.test.ts +2 -4
- package/tests/views/posts.test.ts +2 -5
- package/tests/views/profile.test.ts +4 -5
- package/tests/views/reposts.test.ts +2 -4
- package/tests/views/suggested-follows.test.ts +2 -3
- package/tests/views/suggestions.test.ts +2 -4
- package/tests/views/thread.test.ts +2 -4
- package/tests/views/threadgating.test.ts +2 -3
- package/tests/views/timeline.test.ts +2 -4
- package/dist/env.d.ts +0 -1
- package/example.dev.env +0 -5
- package/src/env.ts +0 -9
- package/tests/seeds/client.ts +0 -466
- /package/tests/{__snapshots__ → admin/__snapshots__}/moderation.test.ts.snap +0 -0
- /package/tests/{image/fixtures → sample-img}/at.png +0 -0
- /package/tests/{image/fixtures → sample-img}/hd-key.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-alt.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-landscape-large.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-landscape-small.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-portrait-large.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-portrait-small.jpg +0 -0
package/src/context.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as plc from '@did-plc/lib'
|
|
2
2
|
import { IdResolver } from '@atproto/identity'
|
|
3
|
+
import { AtpAgent } from '@atproto/api'
|
|
4
|
+
import { Keypair } from '@atproto/crypto'
|
|
5
|
+
import { createServiceJwt } from '@atproto/xrpc-server'
|
|
3
6
|
import { DatabaseCoordinator } from './db'
|
|
4
7
|
import { ServerConfig } from './config'
|
|
5
8
|
import { ImageUriBuilder } from './image/uri'
|
|
@@ -18,10 +21,12 @@ export class AppContext {
|
|
|
18
21
|
imgUriBuilder: ImageUriBuilder
|
|
19
22
|
cfg: ServerConfig
|
|
20
23
|
services: Services
|
|
24
|
+
signingKey: Keypair
|
|
21
25
|
idResolver: IdResolver
|
|
22
26
|
didCache: DidSqlCache
|
|
23
27
|
labelCache: LabelCache
|
|
24
28
|
backgroundQueue: BackgroundQueue
|
|
29
|
+
searchAgent?: AtpAgent
|
|
25
30
|
algos: MountedAlgos
|
|
26
31
|
notifServer: NotificationServer
|
|
27
32
|
},
|
|
@@ -43,6 +48,10 @@ export class AppContext {
|
|
|
43
48
|
return this.opts.services
|
|
44
49
|
}
|
|
45
50
|
|
|
51
|
+
get signingKey(): Keypair {
|
|
52
|
+
return this.opts.signingKey
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
get plcClient(): plc.Client {
|
|
47
56
|
return new plc.Client(this.cfg.didPlcUrl)
|
|
48
57
|
}
|
|
@@ -63,6 +72,10 @@ export class AppContext {
|
|
|
63
72
|
return this.opts.notifServer
|
|
64
73
|
}
|
|
65
74
|
|
|
75
|
+
get searchAgent(): AtpAgent | undefined {
|
|
76
|
+
return this.opts.searchAgent
|
|
77
|
+
}
|
|
78
|
+
|
|
66
79
|
get authVerifier() {
|
|
67
80
|
return auth.authVerifier(this.idResolver, { aud: this.cfg.serverDid })
|
|
68
81
|
}
|
|
@@ -85,6 +98,23 @@ export class AppContext {
|
|
|
85
98
|
return auth.roleVerifier(this.cfg)
|
|
86
99
|
}
|
|
87
100
|
|
|
101
|
+
async serviceAuthJwt(aud: string) {
|
|
102
|
+
const iss = this.cfg.serverDid
|
|
103
|
+
return createServiceJwt({
|
|
104
|
+
iss,
|
|
105
|
+
aud,
|
|
106
|
+
keypair: this.signingKey,
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async pdsAdminAgent(did: string): Promise<AtpAgent> {
|
|
111
|
+
const data = await this.idResolver.did.resolveAtprotoData(did)
|
|
112
|
+
const agent = new AtpAgent({ service: data.pds })
|
|
113
|
+
const jwt = await this.serviceAuthJwt(did)
|
|
114
|
+
agent.api.setHeader('authorization', `Bearer ${jwt}`)
|
|
115
|
+
return agent
|
|
116
|
+
}
|
|
117
|
+
|
|
88
118
|
get backgroundQueue(): BackgroundQueue {
|
|
89
119
|
return this.opts.backgroundQueue
|
|
90
120
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Kysely } from 'kysely'
|
|
2
|
+
|
|
3
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
4
|
+
await db.schema
|
|
5
|
+
.createIndex('like_creator_cursor_idx')
|
|
6
|
+
.on('like')
|
|
7
|
+
.columns(['creator', 'sortAt', 'cid'])
|
|
8
|
+
.execute()
|
|
9
|
+
await db.schema
|
|
10
|
+
.createIndex('follow_creator_cursor_idx')
|
|
11
|
+
.on('follow')
|
|
12
|
+
.columns(['creator', 'sortAt', 'cid'])
|
|
13
|
+
.execute()
|
|
14
|
+
await db.schema
|
|
15
|
+
.createIndex('follow_subject_cursor_idx')
|
|
16
|
+
.on('follow')
|
|
17
|
+
.columns(['subjectDid', 'sortAt', 'cid'])
|
|
18
|
+
.execute()
|
|
19
|
+
|
|
20
|
+
// drop old indices that are superceded by these
|
|
21
|
+
await db.schema.dropIndex('like_creator_idx').execute()
|
|
22
|
+
await db.schema.dropIndex('follow_subjectdid_idx').execute()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
26
|
+
await db.schema
|
|
27
|
+
.createIndex('like_creator_idx')
|
|
28
|
+
.on('like')
|
|
29
|
+
.column('creator')
|
|
30
|
+
.execute()
|
|
31
|
+
await db.schema
|
|
32
|
+
.createIndex('follow_subjectdid_idx')
|
|
33
|
+
.on('follow')
|
|
34
|
+
.column('subjectDid')
|
|
35
|
+
.execute()
|
|
36
|
+
|
|
37
|
+
await db.schema.dropIndex('like_creator_cursor_idx').execute()
|
|
38
|
+
await db.schema.dropIndex('follow_creator_cursor_idx').execute()
|
|
39
|
+
await db.schema.dropIndex('follow_subject_cursor_idx').execute()
|
|
40
|
+
}
|
|
@@ -29,3 +29,4 @@ export * as _20230830T205507322Z from './20230830T205507322Z-suggested-feeds'
|
|
|
29
29
|
export * as _20230904T211011773Z from './20230904T211011773Z-block-lists'
|
|
30
30
|
export * as _20230906T222220386Z from './20230906T222220386Z-thread-gating'
|
|
31
31
|
export * as _20230920T213858047Z from './20230920T213858047Z-add-tags-to-post'
|
|
32
|
+
export * as _20230929T192920807Z from './20230929T192920807Z-record-cursor-indexes'
|
package/src/did-cache.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PQueue from 'p-queue'
|
|
2
2
|
import { CacheResult, DidCache, DidDocument } from '@atproto/identity'
|
|
3
3
|
import { PrimaryDatabase } from './db'
|
|
4
|
+
import { excluded } from './db/util'
|
|
4
5
|
import { dbLogger } from './logger'
|
|
5
6
|
|
|
6
7
|
export class DidSqlCache implements DidCache {
|
|
@@ -16,25 +17,42 @@ export class DidSqlCache implements DidCache {
|
|
|
16
17
|
this.pQueue = new PQueue()
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
async cacheDid(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
async cacheDid(
|
|
21
|
+
did: string,
|
|
22
|
+
doc: DidDocument,
|
|
23
|
+
prevResult?: CacheResult,
|
|
24
|
+
): Promise<void> {
|
|
25
|
+
if (prevResult) {
|
|
26
|
+
await this.db.db
|
|
27
|
+
.updateTable('did_cache')
|
|
28
|
+
.set({ doc, updatedAt: Date.now() })
|
|
29
|
+
.where('did', '=', did)
|
|
30
|
+
.where('updatedAt', '=', prevResult.updatedAt)
|
|
31
|
+
.execute()
|
|
32
|
+
} else {
|
|
33
|
+
await this.db.db
|
|
34
|
+
.insertInto('did_cache')
|
|
35
|
+
.values({ did, doc, updatedAt: Date.now() })
|
|
36
|
+
.onConflict((oc) =>
|
|
37
|
+
oc.column('did').doUpdateSet({
|
|
38
|
+
doc: excluded(this.db.db, 'doc'),
|
|
39
|
+
updatedAt: excluded(this.db.db, 'updatedAt'),
|
|
40
|
+
}),
|
|
41
|
+
)
|
|
42
|
+
.executeTakeFirst()
|
|
43
|
+
}
|
|
27
44
|
}
|
|
28
45
|
|
|
29
46
|
async refreshCache(
|
|
30
47
|
did: string,
|
|
31
48
|
getDoc: () => Promise<DidDocument | null>,
|
|
49
|
+
prevResult?: CacheResult,
|
|
32
50
|
): Promise<void> {
|
|
33
51
|
this.pQueue?.add(async () => {
|
|
34
52
|
try {
|
|
35
53
|
const doc = await getDoc()
|
|
36
54
|
if (doc) {
|
|
37
|
-
await this.cacheDid(did, doc)
|
|
55
|
+
await this.cacheDid(did, doc, prevResult)
|
|
38
56
|
} else {
|
|
39
57
|
await this.clearEntry(did)
|
|
40
58
|
}
|
|
@@ -51,20 +69,17 @@ export class DidSqlCache implements DidCache {
|
|
|
51
69
|
.selectAll()
|
|
52
70
|
.executeTakeFirst()
|
|
53
71
|
if (!res) return null
|
|
72
|
+
|
|
54
73
|
const now = Date.now()
|
|
55
74
|
const updatedAt = new Date(res.updatedAt).getTime()
|
|
56
|
-
|
|
57
75
|
const expired = now > updatedAt + this.maxTTL
|
|
58
|
-
if (expired) {
|
|
59
|
-
return null
|
|
60
|
-
}
|
|
61
|
-
|
|
62
76
|
const stale = now > updatedAt + this.staleTTL
|
|
63
77
|
return {
|
|
64
78
|
doc: res.doc,
|
|
65
79
|
updatedAt,
|
|
66
80
|
did,
|
|
67
81
|
stale,
|
|
82
|
+
expired,
|
|
68
83
|
}
|
|
69
84
|
}
|
|
70
85
|
|
|
@@ -15,7 +15,7 @@ const handler: AlgoHandler = async (
|
|
|
15
15
|
|
|
16
16
|
const { ref } = db.db.dynamic
|
|
17
17
|
|
|
18
|
-
const keyset = new FeedKeyset(ref('post.
|
|
18
|
+
const keyset = new FeedKeyset(ref('post.sortAt'), ref('post.cid'))
|
|
19
19
|
const sortFrom = keyset.unpack(cursor)?.primary
|
|
20
20
|
|
|
21
21
|
let postsQb = feedService
|
|
@@ -24,7 +24,7 @@ const handler: AlgoHandler = async (
|
|
|
24
24
|
.innerJoin('post_agg', 'post_agg.uri', 'post.uri')
|
|
25
25
|
.where('post_agg.likeCount', '>=', 5)
|
|
26
26
|
.where('follow.creator', '=', requester)
|
|
27
|
-
.where('post.
|
|
27
|
+
.where('post.sortAt', '>', getFeedDateThreshold(sortFrom))
|
|
28
28
|
|
|
29
29
|
postsQb = paginate(postsQb, { limit, cursor, keyset, tryIndex: true })
|
|
30
30
|
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,8 @@ import { BackgroundQueue } from './background'
|
|
|
25
25
|
import { MountedAlgos } from './feed-gen/types'
|
|
26
26
|
import { LabelCache } from './label-cache'
|
|
27
27
|
import { NotificationServer } from './notifications'
|
|
28
|
+
import { AtpAgent } from '@atproto/api'
|
|
29
|
+
import { Keypair } from '@atproto/crypto'
|
|
28
30
|
|
|
29
31
|
export type { ServerConfigValues } from './config'
|
|
30
32
|
export type { MountedAlgos } from './feed-gen/types'
|
|
@@ -53,10 +55,11 @@ export class BskyAppView {
|
|
|
53
55
|
static create(opts: {
|
|
54
56
|
db: DatabaseCoordinator
|
|
55
57
|
config: ServerConfig
|
|
58
|
+
signingKey: Keypair
|
|
56
59
|
imgInvalidator?: ImageInvalidator
|
|
57
60
|
algos?: MountedAlgos
|
|
58
61
|
}): BskyAppView {
|
|
59
|
-
const { db, config, algos = {} } = opts
|
|
62
|
+
const { db, config, signingKey, algos = {} } = opts
|
|
60
63
|
let maybeImgInvalidator = opts.imgInvalidator
|
|
61
64
|
const app = express()
|
|
62
65
|
app.use(cors())
|
|
@@ -100,6 +103,9 @@ export class BskyAppView {
|
|
|
100
103
|
const backgroundQueue = new BackgroundQueue(db.getPrimary())
|
|
101
104
|
const labelCache = new LabelCache(db.getPrimary())
|
|
102
105
|
const notifServer = new NotificationServer(db.getPrimary())
|
|
106
|
+
const searchAgent = config.searchEndpoint
|
|
107
|
+
? new AtpAgent({ service: config.searchEndpoint })
|
|
108
|
+
: undefined
|
|
103
109
|
|
|
104
110
|
const services = createServices({
|
|
105
111
|
imgUriBuilder,
|
|
@@ -112,10 +118,12 @@ export class BskyAppView {
|
|
|
112
118
|
cfg: config,
|
|
113
119
|
services,
|
|
114
120
|
imgUriBuilder,
|
|
121
|
+
signingKey,
|
|
115
122
|
idResolver,
|
|
116
123
|
didCache,
|
|
117
124
|
labelCache,
|
|
118
125
|
backgroundQueue,
|
|
126
|
+
searchAgent,
|
|
119
127
|
algos,
|
|
120
128
|
notifServer,
|
|
121
129
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'node:assert'
|
|
2
2
|
import { CID } from 'multiformats/cid'
|
|
3
3
|
import { AtUri } from '@atproto/syntax'
|
|
4
|
-
import { cborDecode, wait } from '@atproto/common'
|
|
4
|
+
import { cborDecode, wait, handleAllSettledErrors } from '@atproto/common'
|
|
5
5
|
import { DisconnectError } from '@atproto/xrpc-server'
|
|
6
6
|
import {
|
|
7
7
|
WriteOpAction,
|
|
@@ -343,23 +343,3 @@ type PreparedDelete = {
|
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
type PreparedWrite = PreparedCreate | PreparedUpdate | PreparedDelete
|
|
346
|
-
|
|
347
|
-
function handleAllSettledErrors(results: PromiseSettledResult<unknown>[]) {
|
|
348
|
-
const errors = results.filter(isRejected).map((res) => res.reason)
|
|
349
|
-
if (errors.length === 0) {
|
|
350
|
-
return
|
|
351
|
-
}
|
|
352
|
-
if (errors.length === 1) {
|
|
353
|
-
throw errors[0]
|
|
354
|
-
}
|
|
355
|
-
throw new AggregateError(
|
|
356
|
-
errors,
|
|
357
|
-
'Multiple errors: ' + errors.map((err) => err?.message).join('\n'),
|
|
358
|
-
)
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function isRejected(
|
|
362
|
-
result: PromiseSettledResult<unknown>,
|
|
363
|
-
): result is PromiseRejectedResult {
|
|
364
|
-
return result.status === 'rejected'
|
|
365
|
-
}
|
package/src/lexicon/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { schemas } from './lexicons'
|
|
|
12
12
|
import * as ComAtprotoAdminDisableAccountInvites from './types/com/atproto/admin/disableAccountInvites'
|
|
13
13
|
import * as ComAtprotoAdminDisableInviteCodes from './types/com/atproto/admin/disableInviteCodes'
|
|
14
14
|
import * as ComAtprotoAdminEnableAccountInvites from './types/com/atproto/admin/enableAccountInvites'
|
|
15
|
+
import * as ComAtprotoAdminGetAccountInfo from './types/com/atproto/admin/getAccountInfo'
|
|
15
16
|
import * as ComAtprotoAdminGetInviteCodes from './types/com/atproto/admin/getInviteCodes'
|
|
16
17
|
import * as ComAtprotoAdminGetModerationAction from './types/com/atproto/admin/getModerationAction'
|
|
17
18
|
import * as ComAtprotoAdminGetModerationActions from './types/com/atproto/admin/getModerationActions'
|
|
@@ -19,6 +20,7 @@ import * as ComAtprotoAdminGetModerationReport from './types/com/atproto/admin/g
|
|
|
19
20
|
import * as ComAtprotoAdminGetModerationReports from './types/com/atproto/admin/getModerationReports'
|
|
20
21
|
import * as ComAtprotoAdminGetRecord from './types/com/atproto/admin/getRecord'
|
|
21
22
|
import * as ComAtprotoAdminGetRepo from './types/com/atproto/admin/getRepo'
|
|
23
|
+
import * as ComAtprotoAdminGetSubjectStatus from './types/com/atproto/admin/getSubjectStatus'
|
|
22
24
|
import * as ComAtprotoAdminResolveModerationReports from './types/com/atproto/admin/resolveModerationReports'
|
|
23
25
|
import * as ComAtprotoAdminReverseModerationAction from './types/com/atproto/admin/reverseModerationAction'
|
|
24
26
|
import * as ComAtprotoAdminSearchRepos from './types/com/atproto/admin/searchRepos'
|
|
@@ -26,6 +28,7 @@ import * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail'
|
|
|
26
28
|
import * as ComAtprotoAdminTakeModerationAction from './types/com/atproto/admin/takeModerationAction'
|
|
27
29
|
import * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail'
|
|
28
30
|
import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle'
|
|
31
|
+
import * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus'
|
|
29
32
|
import * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle'
|
|
30
33
|
import * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle'
|
|
31
34
|
import * as ComAtprotoLabelQueryLabels from './types/com/atproto/label/queryLabels'
|
|
@@ -39,6 +42,7 @@ import * as ComAtprotoRepoGetRecord from './types/com/atproto/repo/getRecord'
|
|
|
39
42
|
import * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords'
|
|
40
43
|
import * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord'
|
|
41
44
|
import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
|
|
45
|
+
import * as ComAtprotoServerConfirmEmail from './types/com/atproto/server/confirmEmail'
|
|
42
46
|
import * as ComAtprotoServerCreateAccount from './types/com/atproto/server/createAccount'
|
|
43
47
|
import * as ComAtprotoServerCreateAppPassword from './types/com/atproto/server/createAppPassword'
|
|
44
48
|
import * as ComAtprotoServerCreateInviteCode from './types/com/atproto/server/createInviteCode'
|
|
@@ -52,9 +56,13 @@ import * as ComAtprotoServerGetSession from './types/com/atproto/server/getSessi
|
|
|
52
56
|
import * as ComAtprotoServerListAppPasswords from './types/com/atproto/server/listAppPasswords'
|
|
53
57
|
import * as ComAtprotoServerRefreshSession from './types/com/atproto/server/refreshSession'
|
|
54
58
|
import * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/server/requestAccountDelete'
|
|
59
|
+
import * as ComAtprotoServerRequestEmailConfirmation from './types/com/atproto/server/requestEmailConfirmation'
|
|
60
|
+
import * as ComAtprotoServerRequestEmailUpdate from './types/com/atproto/server/requestEmailUpdate'
|
|
55
61
|
import * as ComAtprotoServerRequestPasswordReset from './types/com/atproto/server/requestPasswordReset'
|
|
62
|
+
import * as ComAtprotoServerReserveSigningKey from './types/com/atproto/server/reserveSigningKey'
|
|
56
63
|
import * as ComAtprotoServerResetPassword from './types/com/atproto/server/resetPassword'
|
|
57
64
|
import * as ComAtprotoServerRevokeAppPassword from './types/com/atproto/server/revokeAppPassword'
|
|
65
|
+
import * as ComAtprotoServerUpdateEmail from './types/com/atproto/server/updateEmail'
|
|
58
66
|
import * as ComAtprotoSyncGetBlob from './types/com/atproto/sync/getBlob'
|
|
59
67
|
import * as ComAtprotoSyncGetBlocks from './types/com/atproto/sync/getBlocks'
|
|
60
68
|
import * as ComAtprotoSyncGetCheckout from './types/com/atproto/sync/getCheckout'
|
|
@@ -220,6 +228,17 @@ export class AdminNS {
|
|
|
220
228
|
return this._server.xrpc.method(nsid, cfg)
|
|
221
229
|
}
|
|
222
230
|
|
|
231
|
+
getAccountInfo<AV extends AuthVerifier>(
|
|
232
|
+
cfg: ConfigOf<
|
|
233
|
+
AV,
|
|
234
|
+
ComAtprotoAdminGetAccountInfo.Handler<ExtractAuth<AV>>,
|
|
235
|
+
ComAtprotoAdminGetAccountInfo.HandlerReqCtx<ExtractAuth<AV>>
|
|
236
|
+
>,
|
|
237
|
+
) {
|
|
238
|
+
const nsid = 'com.atproto.admin.getAccountInfo' // @ts-ignore
|
|
239
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
240
|
+
}
|
|
241
|
+
|
|
223
242
|
getInviteCodes<AV extends AuthVerifier>(
|
|
224
243
|
cfg: ConfigOf<
|
|
225
244
|
AV,
|
|
@@ -297,6 +316,17 @@ export class AdminNS {
|
|
|
297
316
|
return this._server.xrpc.method(nsid, cfg)
|
|
298
317
|
}
|
|
299
318
|
|
|
319
|
+
getSubjectStatus<AV extends AuthVerifier>(
|
|
320
|
+
cfg: ConfigOf<
|
|
321
|
+
AV,
|
|
322
|
+
ComAtprotoAdminGetSubjectStatus.Handler<ExtractAuth<AV>>,
|
|
323
|
+
ComAtprotoAdminGetSubjectStatus.HandlerReqCtx<ExtractAuth<AV>>
|
|
324
|
+
>,
|
|
325
|
+
) {
|
|
326
|
+
const nsid = 'com.atproto.admin.getSubjectStatus' // @ts-ignore
|
|
327
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
328
|
+
}
|
|
329
|
+
|
|
300
330
|
resolveModerationReports<AV extends AuthVerifier>(
|
|
301
331
|
cfg: ConfigOf<
|
|
302
332
|
AV,
|
|
@@ -373,6 +403,17 @@ export class AdminNS {
|
|
|
373
403
|
const nsid = 'com.atproto.admin.updateAccountHandle' // @ts-ignore
|
|
374
404
|
return this._server.xrpc.method(nsid, cfg)
|
|
375
405
|
}
|
|
406
|
+
|
|
407
|
+
updateSubjectStatus<AV extends AuthVerifier>(
|
|
408
|
+
cfg: ConfigOf<
|
|
409
|
+
AV,
|
|
410
|
+
ComAtprotoAdminUpdateSubjectStatus.Handler<ExtractAuth<AV>>,
|
|
411
|
+
ComAtprotoAdminUpdateSubjectStatus.HandlerReqCtx<ExtractAuth<AV>>
|
|
412
|
+
>,
|
|
413
|
+
) {
|
|
414
|
+
const nsid = 'com.atproto.admin.updateSubjectStatus' // @ts-ignore
|
|
415
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
416
|
+
}
|
|
376
417
|
}
|
|
377
418
|
|
|
378
419
|
export class IdentityNS {
|
|
@@ -557,6 +598,17 @@ export class ServerNS {
|
|
|
557
598
|
this._server = server
|
|
558
599
|
}
|
|
559
600
|
|
|
601
|
+
confirmEmail<AV extends AuthVerifier>(
|
|
602
|
+
cfg: ConfigOf<
|
|
603
|
+
AV,
|
|
604
|
+
ComAtprotoServerConfirmEmail.Handler<ExtractAuth<AV>>,
|
|
605
|
+
ComAtprotoServerConfirmEmail.HandlerReqCtx<ExtractAuth<AV>>
|
|
606
|
+
>,
|
|
607
|
+
) {
|
|
608
|
+
const nsid = 'com.atproto.server.confirmEmail' // @ts-ignore
|
|
609
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
610
|
+
}
|
|
611
|
+
|
|
560
612
|
createAccount<AV extends AuthVerifier>(
|
|
561
613
|
cfg: ConfigOf<
|
|
562
614
|
AV,
|
|
@@ -700,6 +752,28 @@ export class ServerNS {
|
|
|
700
752
|
return this._server.xrpc.method(nsid, cfg)
|
|
701
753
|
}
|
|
702
754
|
|
|
755
|
+
requestEmailConfirmation<AV extends AuthVerifier>(
|
|
756
|
+
cfg: ConfigOf<
|
|
757
|
+
AV,
|
|
758
|
+
ComAtprotoServerRequestEmailConfirmation.Handler<ExtractAuth<AV>>,
|
|
759
|
+
ComAtprotoServerRequestEmailConfirmation.HandlerReqCtx<ExtractAuth<AV>>
|
|
760
|
+
>,
|
|
761
|
+
) {
|
|
762
|
+
const nsid = 'com.atproto.server.requestEmailConfirmation' // @ts-ignore
|
|
763
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
requestEmailUpdate<AV extends AuthVerifier>(
|
|
767
|
+
cfg: ConfigOf<
|
|
768
|
+
AV,
|
|
769
|
+
ComAtprotoServerRequestEmailUpdate.Handler<ExtractAuth<AV>>,
|
|
770
|
+
ComAtprotoServerRequestEmailUpdate.HandlerReqCtx<ExtractAuth<AV>>
|
|
771
|
+
>,
|
|
772
|
+
) {
|
|
773
|
+
const nsid = 'com.atproto.server.requestEmailUpdate' // @ts-ignore
|
|
774
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
775
|
+
}
|
|
776
|
+
|
|
703
777
|
requestPasswordReset<AV extends AuthVerifier>(
|
|
704
778
|
cfg: ConfigOf<
|
|
705
779
|
AV,
|
|
@@ -711,6 +785,17 @@ export class ServerNS {
|
|
|
711
785
|
return this._server.xrpc.method(nsid, cfg)
|
|
712
786
|
}
|
|
713
787
|
|
|
788
|
+
reserveSigningKey<AV extends AuthVerifier>(
|
|
789
|
+
cfg: ConfigOf<
|
|
790
|
+
AV,
|
|
791
|
+
ComAtprotoServerReserveSigningKey.Handler<ExtractAuth<AV>>,
|
|
792
|
+
ComAtprotoServerReserveSigningKey.HandlerReqCtx<ExtractAuth<AV>>
|
|
793
|
+
>,
|
|
794
|
+
) {
|
|
795
|
+
const nsid = 'com.atproto.server.reserveSigningKey' // @ts-ignore
|
|
796
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
797
|
+
}
|
|
798
|
+
|
|
714
799
|
resetPassword<AV extends AuthVerifier>(
|
|
715
800
|
cfg: ConfigOf<
|
|
716
801
|
AV,
|
|
@@ -732,6 +817,17 @@ export class ServerNS {
|
|
|
732
817
|
const nsid = 'com.atproto.server.revokeAppPassword' // @ts-ignore
|
|
733
818
|
return this._server.xrpc.method(nsid, cfg)
|
|
734
819
|
}
|
|
820
|
+
|
|
821
|
+
updateEmail<AV extends AuthVerifier>(
|
|
822
|
+
cfg: ConfigOf<
|
|
823
|
+
AV,
|
|
824
|
+
ComAtprotoServerUpdateEmail.Handler<ExtractAuth<AV>>,
|
|
825
|
+
ComAtprotoServerUpdateEmail.HandlerReqCtx<ExtractAuth<AV>>
|
|
826
|
+
>,
|
|
827
|
+
) {
|
|
828
|
+
const nsid = 'com.atproto.server.updateEmail' // @ts-ignore
|
|
829
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
830
|
+
}
|
|
735
831
|
}
|
|
736
832
|
|
|
737
833
|
export class SyncNS {
|