@atproto/bsky 0.0.11 → 0.0.13

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.
Files changed (158) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE.txt +7 -0
  3. package/README.md +6 -1
  4. package/dist/api/com/atproto/admin/util.d.ts +5 -0
  5. package/dist/context.d.ts +6 -1
  6. package/dist/db/index.js +51 -2
  7. package/dist/db/index.js.map +3 -3
  8. package/dist/db/migrations/20230929T192920807Z-record-cursor-indexes.d.ts +3 -0
  9. package/dist/db/migrations/index.d.ts +1 -0
  10. package/dist/did-cache.d.ts +2 -2
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.js +1630 -755
  13. package/dist/index.js.map +3 -3
  14. package/dist/lexicon/index.d.ts +8 -0
  15. package/dist/lexicon/lexicons.d.ts +243 -3
  16. package/dist/lexicon/types/app/bsky/actor/defs.d.ts +1 -0
  17. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +28 -0
  18. package/dist/lexicon/types/com/atproto/admin/getAccountInfo.d.ts +29 -0
  19. package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts +39 -0
  20. package/dist/lexicon/types/com/atproto/admin/searchRepos.d.ts +0 -1
  21. package/dist/lexicon/types/com/atproto/admin/updateSubjectStatus.d.ts +46 -0
  22. package/dist/lexicon/types/com/atproto/server/createAccount.d.ts +4 -2
  23. package/dist/lexicon/types/com/atproto/server/createSession.d.ts +1 -0
  24. package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +1 -0
  25. package/dist/lexicon/types/com/atproto/server/reserveSigningKey.d.ts +36 -0
  26. package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +1 -0
  27. package/dist/services/actor/types.d.ts +1 -0
  28. package/dist/services/graph/index.d.ts +2 -0
  29. package/dist/services/moderation/index.d.ts +13 -3
  30. package/package.json +14 -15
  31. package/src/api/app/bsky/feed/getAuthorFeed.ts +2 -2
  32. package/src/api/app/bsky/feed/getPostThread.ts +2 -2
  33. package/src/api/app/bsky/notification/listNotifications.ts +33 -22
  34. package/src/api/com/atproto/admin/getModerationAction.ts +28 -2
  35. package/src/api/com/atproto/admin/getModerationReport.ts +27 -2
  36. package/src/api/com/atproto/admin/getRecord.ts +14 -2
  37. package/src/api/com/atproto/admin/getRepo.ts +13 -2
  38. package/src/api/com/atproto/admin/reverseModerationAction.ts +31 -5
  39. package/src/api/com/atproto/admin/searchRepos.ts +2 -5
  40. package/src/api/com/atproto/admin/takeModerationAction.ts +41 -7
  41. package/src/api/com/atproto/admin/util.ts +50 -0
  42. package/src/api/well-known.ts +8 -0
  43. package/src/auth.ts +12 -5
  44. package/src/auto-moderator/index.ts +1 -0
  45. package/src/context.ts +25 -1
  46. package/src/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +40 -0
  47. package/src/db/migrations/index.ts +1 -0
  48. package/src/did-cache.ts +29 -14
  49. package/src/feed-gen/with-friends.ts +2 -2
  50. package/src/index.ts +4 -1
  51. package/src/indexer/subscription.ts +1 -21
  52. package/src/lexicon/index.ts +48 -0
  53. package/src/lexicon/lexicons.ts +259 -5
  54. package/src/lexicon/types/app/bsky/actor/defs.ts +1 -0
  55. package/src/lexicon/types/com/atproto/admin/defs.ts +61 -0
  56. package/src/lexicon/types/com/atproto/admin/getAccountInfo.ts +41 -0
  57. package/src/lexicon/types/com/atproto/admin/getSubjectStatus.ts +54 -0
  58. package/src/lexicon/types/com/atproto/admin/searchRepos.ts +0 -1
  59. package/src/lexicon/types/com/atproto/admin/updateSubjectStatus.ts +61 -0
  60. package/src/lexicon/types/com/atproto/server/createAccount.ts +4 -2
  61. package/src/lexicon/types/com/atproto/server/createSession.ts +1 -0
  62. package/src/lexicon/types/com/atproto/server/refreshSession.ts +1 -0
  63. package/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +51 -0
  64. package/src/lexicon/types/com/atproto/sync/listRepos.ts +1 -0
  65. package/src/logger.ts +8 -0
  66. package/src/services/actor/index.ts +7 -1
  67. package/src/services/actor/types.ts +1 -0
  68. package/src/services/actor/views.ts +26 -8
  69. package/src/services/graph/index.ts +26 -7
  70. package/src/services/indexing/index.ts +15 -17
  71. package/src/services/moderation/index.ts +94 -14
  72. package/src/services/moderation/views.ts +1 -0
  73. package/tests/__snapshots__/feed-generation.test.ts.snap +12 -12
  74. package/tests/__snapshots__/indexing.test.ts.snap +4 -4
  75. package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +172 -0
  76. package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +178 -0
  77. package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +177 -0
  78. package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +307 -0
  79. package/tests/admin/__snapshots__/get-record.test.ts.snap +275 -0
  80. package/tests/admin/__snapshots__/get-repo.test.ts.snap +103 -0
  81. package/tests/admin/get-moderation-action.test.ts +100 -0
  82. package/tests/admin/get-moderation-actions.test.ts +164 -0
  83. package/tests/admin/get-moderation-report.test.ts +100 -0
  84. package/tests/admin/get-moderation-reports.test.ts +332 -0
  85. package/tests/admin/get-record.test.ts +115 -0
  86. package/tests/admin/get-repo.test.ts +101 -0
  87. package/tests/{moderation.test.ts → admin/moderation.test.ts} +107 -9
  88. package/tests/admin/repo-search.test.ts +124 -0
  89. package/tests/algos/hot-classic.test.ts +3 -5
  90. package/tests/algos/whats-hot.test.ts +3 -5
  91. package/tests/algos/with-friends.test.ts +2 -4
  92. package/tests/auth.test.ts +64 -0
  93. package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -3
  94. package/tests/auto-moderator/labeler.test.ts +5 -7
  95. package/tests/auto-moderator/takedowns.test.ts +11 -12
  96. package/tests/blob-resolver.test.ts +1 -3
  97. package/tests/did-cache.test.ts +2 -5
  98. package/tests/feed-generation.test.ts +8 -6
  99. package/tests/handle-invalidation.test.ts +2 -3
  100. package/tests/image/server.test.ts +1 -4
  101. package/tests/image/sharp.test.ts +1 -1
  102. package/tests/indexing.test.ts +4 -4
  103. package/tests/notification-server.test.ts +2 -3
  104. package/tests/pipeline/backpressure.test.ts +2 -3
  105. package/tests/pipeline/reingest.test.ts +7 -4
  106. package/tests/pipeline/repartition.test.ts +2 -3
  107. package/tests/reprocessing.test.ts +2 -6
  108. package/tests/seeds/basic.ts +4 -4
  109. package/tests/seeds/follows.ts +1 -1
  110. package/tests/seeds/likes.ts +1 -1
  111. package/tests/seeds/reposts.ts +1 -1
  112. package/tests/seeds/users-bulk.ts +1 -1
  113. package/tests/seeds/users.ts +1 -1
  114. package/tests/server.test.ts +1 -3
  115. package/tests/subscription/repo.test.ts +2 -4
  116. package/tests/views/__snapshots__/author-feed.test.ts.snap +24 -24
  117. package/tests/views/__snapshots__/block-lists.test.ts.snap +42 -7
  118. package/tests/views/__snapshots__/blocks.test.ts.snap +2 -2
  119. package/tests/views/__snapshots__/list-feed.test.ts.snap +6 -6
  120. package/tests/views/__snapshots__/mute-lists.test.ts.snap +15 -4
  121. package/tests/views/__snapshots__/mutes.test.ts.snap +2 -2
  122. package/tests/views/__snapshots__/notifications.test.ts.snap +2 -2
  123. package/tests/views/__snapshots__/posts.test.ts.snap +8 -8
  124. package/tests/views/__snapshots__/thread.test.ts.snap +10 -10
  125. package/tests/views/__snapshots__/timeline.test.ts.snap +58 -58
  126. package/tests/views/actor-likes.test.ts +2 -3
  127. package/tests/views/actor-search.test.ts +5 -5
  128. package/tests/views/admin/repo-search.test.ts +2 -4
  129. package/tests/views/author-feed.test.ts +2 -4
  130. package/tests/views/block-lists.test.ts +34 -7
  131. package/tests/views/blocks.test.ts +6 -3
  132. package/tests/views/follows.test.ts +2 -4
  133. package/tests/views/likes.test.ts +2 -5
  134. package/tests/views/list-feed.test.ts +2 -4
  135. package/tests/views/mute-lists.test.ts +23 -5
  136. package/tests/views/mutes.test.ts +2 -5
  137. package/tests/views/notifications.test.ts +2 -4
  138. package/tests/views/posts.test.ts +2 -5
  139. package/tests/views/profile.test.ts +4 -5
  140. package/tests/views/reposts.test.ts +2 -4
  141. package/tests/views/suggested-follows.test.ts +2 -3
  142. package/tests/views/suggestions.test.ts +2 -4
  143. package/tests/views/thread.test.ts +2 -4
  144. package/tests/views/threadgating.test.ts +2 -3
  145. package/tests/views/timeline.test.ts +2 -4
  146. package/LICENSE +0 -21
  147. package/dist/env.d.ts +0 -1
  148. package/example.dev.env +0 -5
  149. package/src/env.ts +0 -9
  150. package/tests/seeds/client.ts +0 -466
  151. /package/tests/{__snapshots__ → admin/__snapshots__}/moderation.test.ts.snap +0 -0
  152. /package/tests/{image/fixtures → sample-img}/at.png +0 -0
  153. /package/tests/{image/fixtures → sample-img}/hd-key.jpg +0 -0
  154. /package/tests/{image/fixtures → sample-img}/key-alt.jpg +0 -0
  155. /package/tests/{image/fixtures → sample-img}/key-landscape-large.jpg +0 -0
  156. /package/tests/{image/fixtures → sample-img}/key-landscape-small.jpg +0 -0
  157. /package/tests/{image/fixtures → sample-img}/key-portrait-large.jpg +0 -0
  158. /package/tests/{image/fixtures → sample-img}/key-portrait-small.jpg +0 -0
@@ -1,466 +0,0 @@
1
- import fs from 'fs/promises'
2
- import { CID } from 'multiformats/cid'
3
- import AtpAgent from '@atproto/api'
4
- import { AtUri } from '@atproto/syntax'
5
- import { BlobRef } from '@atproto/lexicon'
6
- import { Main as Facet } from '@atproto/api/src/client/types/app/bsky/richtext/facet'
7
- import { InputSchema as TakeActionInput } from '@atproto/api/src/client/types/com/atproto/admin/takeModerationAction'
8
- import { InputSchema as CreateReportInput } from '@atproto/api/src/client/types/com/atproto/moderation/createReport'
9
- import { Record as PostRecord } from '@atproto/api/src/client/types/app/bsky/feed/post'
10
- import { Record as LikeRecord } from '@atproto/api/src/client/types/app/bsky/feed/like'
11
- import { Record as FollowRecord } from '@atproto/api/src/client/types/app/bsky/graph/follow'
12
-
13
- // Makes it simple to create data via the XRPC client,
14
- // and keeps track of all created data in memory for convenience.
15
-
16
- let AVATAR_IMG: Uint8Array | undefined
17
-
18
- export type ImageRef = {
19
- image: BlobRef
20
- alt: string
21
- }
22
-
23
- export class RecordRef {
24
- uri: AtUri
25
- cid: CID
26
-
27
- constructor(uri: AtUri | string, cid: CID | string) {
28
- this.uri = new AtUri(uri.toString())
29
- this.cid = CID.parse(cid.toString())
30
- }
31
-
32
- get raw(): { uri: string; cid: string } {
33
- return {
34
- uri: this.uri.toString(),
35
- cid: this.cid.toString(),
36
- }
37
- }
38
-
39
- get uriStr(): string {
40
- return this.uri.toString()
41
- }
42
-
43
- get cidStr(): string {
44
- return this.cid.toString()
45
- }
46
- }
47
-
48
- export class SeedClient {
49
- accounts: Record<
50
- string,
51
- {
52
- did: string
53
- accessJwt: string
54
- refreshJwt: string
55
- handle: string
56
- email: string
57
- password: string
58
- }
59
- >
60
- profiles: Record<
61
- string,
62
- {
63
- displayName: string
64
- description: string
65
- avatar: { cid: string; mimeType: string }
66
- ref: RecordRef
67
- }
68
- >
69
- follows: Record<string, Record<string, RecordRef>>
70
- posts: Record<
71
- string,
72
- { text: string; ref: RecordRef; images: ImageRef[]; quote?: RecordRef }[]
73
- >
74
- likes: Record<string, Record<string, AtUri>>
75
- replies: Record<string, { text: string; ref: RecordRef }[]>
76
- reposts: Record<string, RecordRef[]>
77
- lists: Record<
78
- string,
79
- Record<string, { ref: RecordRef; items: Record<string, RecordRef> }>
80
- >
81
- dids: Record<string, string>
82
-
83
- constructor(public agent: AtpAgent, public adminAuth?: string) {
84
- this.accounts = {}
85
- this.profiles = {}
86
- this.follows = {}
87
- this.posts = {}
88
- this.likes = {}
89
- this.replies = {}
90
- this.reposts = {}
91
- this.lists = {}
92
- this.dids = {}
93
- }
94
-
95
- async createAccount(
96
- shortName: string,
97
- params: {
98
- handle: string
99
- email: string
100
- password: string
101
- },
102
- ) {
103
- const { data: account } =
104
- await this.agent.api.com.atproto.server.createAccount(params)
105
- this.dids[shortName] = account.did
106
- this.accounts[account.did] = {
107
- ...account,
108
- email: params.email,
109
- password: params.password,
110
- }
111
- return this.accounts[account.did]
112
- }
113
-
114
- async updateHandle(by: string, handle: string) {
115
- await this.agent.api.com.atproto.identity.updateHandle(
116
- { handle },
117
- { encoding: 'application/json', headers: this.getHeaders(by) },
118
- )
119
- }
120
-
121
- async createProfile(
122
- by: string,
123
- displayName: string,
124
- description: string,
125
- selfLabels?: string[],
126
- ) {
127
- AVATAR_IMG ??= await fs.readFile(
128
- 'tests/image/fixtures/key-portrait-small.jpg',
129
- )
130
-
131
- let avatarBlob
132
- {
133
- const res = await this.agent.api.com.atproto.repo.uploadBlob(AVATAR_IMG, {
134
- encoding: 'image/jpeg',
135
- headers: this.getHeaders(by),
136
- } as any)
137
- avatarBlob = res.data.blob
138
- }
139
-
140
- {
141
- const res = await this.agent.api.app.bsky.actor.profile.create(
142
- { repo: by },
143
- {
144
- displayName,
145
- description,
146
- avatar: avatarBlob,
147
- labels: selfLabels
148
- ? {
149
- $type: 'com.atproto.label.defs#selfLabels',
150
- values: selfLabels.map((val) => ({ val })),
151
- }
152
- : undefined,
153
- },
154
- this.getHeaders(by),
155
- )
156
- this.profiles[by] = {
157
- displayName,
158
- description,
159
- avatar: avatarBlob,
160
- ref: new RecordRef(res.uri, res.cid),
161
- }
162
- }
163
- return this.profiles[by]
164
- }
165
-
166
- async follow(from: string, to: string, overrides?: Partial<FollowRecord>) {
167
- const res = await this.agent.api.app.bsky.graph.follow.create(
168
- { repo: from },
169
- {
170
- subject: to,
171
- createdAt: new Date().toISOString(),
172
- ...overrides,
173
- },
174
- this.getHeaders(from),
175
- )
176
- this.follows[from] ??= {}
177
- this.follows[from][to] = new RecordRef(res.uri, res.cid)
178
- return this.follows[from][to]
179
- }
180
-
181
- async unfollow(from: string, to: string) {
182
- const follow = this.follows[from][to]
183
- if (!follow) {
184
- throw new Error('follow does not exist')
185
- }
186
- await this.agent.api.app.bsky.graph.follow.delete(
187
- { repo: from, rkey: follow.uri.rkey },
188
- this.getHeaders(from),
189
- )
190
- delete this.follows[from][to]
191
- }
192
-
193
- async post(
194
- by: string,
195
- text: string,
196
- facets?: Facet[],
197
- images?: ImageRef[],
198
- quote?: RecordRef,
199
- overrides?: Partial<PostRecord>,
200
- ) {
201
- const imageEmbed = images && {
202
- $type: 'app.bsky.embed.images',
203
- images,
204
- }
205
- const recordEmbed = quote && {
206
- record: { uri: quote.uriStr, cid: quote.cidStr },
207
- }
208
- const embed =
209
- imageEmbed && recordEmbed
210
- ? {
211
- $type: 'app.bsky.embed.recordWithMedia',
212
- record: recordEmbed,
213
- media: imageEmbed,
214
- }
215
- : recordEmbed
216
- ? { $type: 'app.bsky.embed.record', ...recordEmbed }
217
- : imageEmbed
218
- const res = await this.agent.api.app.bsky.feed.post.create(
219
- { repo: by },
220
- {
221
- text: text,
222
- facets,
223
- embed,
224
- createdAt: new Date().toISOString(),
225
- ...overrides,
226
- },
227
- this.getHeaders(by),
228
- )
229
- this.posts[by] ??= []
230
- const post = {
231
- text,
232
- ref: new RecordRef(res.uri, res.cid),
233
- images: images ?? [],
234
- quote,
235
- }
236
- this.posts[by].push(post)
237
- return post
238
- }
239
-
240
- async deletePost(by: string, uri: AtUri) {
241
- await this.agent.api.app.bsky.feed.post.delete(
242
- {
243
- repo: by,
244
- rkey: uri.rkey,
245
- },
246
- this.getHeaders(by),
247
- )
248
- }
249
-
250
- async uploadFile(
251
- by: string,
252
- filePath: string,
253
- encoding: string,
254
- ): Promise<ImageRef> {
255
- const file = await fs.readFile(filePath)
256
- const res = await this.agent.api.com.atproto.repo.uploadBlob(file, {
257
- headers: this.getHeaders(by),
258
- encoding,
259
- } as any)
260
- return { image: res.data.blob, alt: filePath }
261
- }
262
-
263
- async like(by: string, subject: RecordRef, overrides?: Partial<LikeRecord>) {
264
- const res = await this.agent.api.app.bsky.feed.like.create(
265
- { repo: by },
266
- {
267
- subject: subject.raw,
268
- createdAt: new Date().toISOString(),
269
- ...overrides,
270
- },
271
- this.getHeaders(by),
272
- )
273
- this.likes[by] ??= {}
274
- this.likes[by][subject.uriStr] = new AtUri(res.uri)
275
- return this.likes[by][subject.uriStr]
276
- }
277
-
278
- async reply(
279
- by: string,
280
- root: RecordRef,
281
- parent: RecordRef,
282
- text: string,
283
- facets?: Facet[],
284
- images?: ImageRef[],
285
- ) {
286
- const embed = images
287
- ? {
288
- $type: 'app.bsky.embed.images',
289
- images,
290
- }
291
- : undefined
292
- const res = await this.agent.api.app.bsky.feed.post.create(
293
- { repo: by },
294
- {
295
- text: text,
296
- reply: {
297
- root: root.raw,
298
- parent: parent.raw,
299
- },
300
- facets,
301
- embed,
302
- createdAt: new Date().toISOString(),
303
- },
304
- this.getHeaders(by),
305
- )
306
- this.replies[by] ??= []
307
- const reply = {
308
- text,
309
- ref: new RecordRef(res.uri, res.cid),
310
- }
311
- this.replies[by].push(reply)
312
- return reply
313
- }
314
-
315
- async repost(by: string, subject: RecordRef) {
316
- const res = await this.agent.api.app.bsky.feed.repost.create(
317
- { repo: by },
318
- { subject: subject.raw, createdAt: new Date().toISOString() },
319
- this.getHeaders(by),
320
- )
321
- this.reposts[by] ??= []
322
- const repost = new RecordRef(res.uri, res.cid)
323
- this.reposts[by].push(repost)
324
- return repost
325
- }
326
-
327
- async createList(by: string, name: string, purpose: 'mod' | 'curate') {
328
- const res = await this.agent.api.app.bsky.graph.list.create(
329
- { repo: by },
330
- {
331
- name,
332
- purpose:
333
- purpose === 'mod'
334
- ? 'app.bsky.graph.defs#modlist'
335
- : 'app.bsky.graph.defs#curatelist',
336
- createdAt: new Date().toISOString(),
337
- },
338
- this.getHeaders(by),
339
- )
340
- this.lists[by] ??= {}
341
- const ref = new RecordRef(res.uri, res.cid)
342
- this.lists[by][ref.uriStr] = {
343
- ref: ref,
344
- items: {},
345
- }
346
- return ref
347
- }
348
-
349
- async addToList(by: string, subject: string, list: RecordRef) {
350
- const res = await this.agent.api.app.bsky.graph.listitem.create(
351
- { repo: by },
352
- { subject, list: list.uriStr, createdAt: new Date().toISOString() },
353
- this.getHeaders(by),
354
- )
355
- const ref = new RecordRef(res.uri, res.cid)
356
- const found = (this.lists[by] ?? {})[list.uriStr]
357
- if (found) {
358
- found.items[subject] = ref
359
- }
360
- return ref
361
- }
362
-
363
- async rmFromList(by: string, subject: string, list: RecordRef) {
364
- const foundList = (this.lists[by] ?? {})[list.uriStr] ?? {}
365
- if (!foundList) return
366
- const foundItem = foundList.items[subject]
367
- if (!foundItem) return
368
- await this.agent.api.app.bsky.graph.listitem.delete(
369
- { repo: by, rkey: foundItem.uri.rkey },
370
- this.getHeaders(by),
371
- )
372
- delete foundList.items[subject]
373
- }
374
-
375
- async takeModerationAction(opts: {
376
- action: TakeActionInput['action']
377
- subject: TakeActionInput['subject']
378
- reason?: string
379
- createdBy?: string
380
- }) {
381
- if (!this.adminAuth) {
382
- throw new Error('No admin auth provided to seed client')
383
- }
384
- const {
385
- action,
386
- subject,
387
- reason = 'X',
388
- createdBy = 'did:example:admin',
389
- } = opts
390
- const result = await this.agent.api.com.atproto.admin.takeModerationAction(
391
- { action, subject, createdBy, reason },
392
- {
393
- encoding: 'application/json',
394
- headers: { authorization: this.adminAuth },
395
- },
396
- )
397
- return result.data
398
- }
399
-
400
- async reverseModerationAction(opts: {
401
- id: number
402
- reason?: string
403
- createdBy?: string
404
- }) {
405
- if (!this.adminAuth) {
406
- throw new Error('No admin auth provided to seed client')
407
- }
408
-
409
- const { id, reason = 'X', createdBy = 'did:example:admin' } = opts
410
- const result =
411
- await this.agent.api.com.atproto.admin.reverseModerationAction(
412
- { id, reason, createdBy },
413
- {
414
- encoding: 'application/json',
415
- headers: { authorization: this.adminAuth },
416
- },
417
- )
418
- return result.data
419
- }
420
-
421
- async resolveReports(opts: {
422
- actionId: number
423
- reportIds: number[]
424
- createdBy?: string
425
- }) {
426
- if (!this.adminAuth) {
427
- throw new Error('No admin auth provided to seed client')
428
- }
429
-
430
- const { actionId, reportIds, createdBy = 'did:example:admin' } = opts
431
- const result =
432
- await this.agent.api.com.atproto.admin.resolveModerationReports(
433
- { actionId, createdBy, reportIds },
434
- {
435
- encoding: 'application/json',
436
- headers: { authorization: this.adminAuth },
437
- },
438
- )
439
- return result.data
440
- }
441
-
442
- async createReport(opts: {
443
- reasonType: CreateReportInput['reasonType']
444
- subject: CreateReportInput['subject']
445
- reason?: string
446
- reportedBy: string
447
- }) {
448
- const { reasonType, subject, reason, reportedBy } = opts
449
- const result = await this.agent.api.com.atproto.moderation.createReport(
450
- { reasonType, subject, reason },
451
- {
452
- encoding: 'application/json',
453
- headers: this.getHeaders(reportedBy),
454
- },
455
- )
456
- return result.data
457
- }
458
-
459
- getHeaders(did: string) {
460
- return SeedClient.getHeaders(this.accounts[did].accessJwt)
461
- }
462
-
463
- static getHeaders(jwt: string) {
464
- return { authorization: `Bearer ${jwt}` }
465
- }
466
- }
File without changes
File without changes