@atproto/dev-env 0.3.34-rc.0 → 0.3.35
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 +13 -29
- package/dist/bsky.d.ts.map +1 -1
- package/dist/bsky.js +1 -1
- package/dist/bsky.js.map +1 -1
- package/dist/mock/index.d.ts.map +1 -1
- package/dist/mock/index.js +72 -54
- package/dist/mock/index.js.map +1 -1
- package/dist/moderator-client.d.ts +1 -1
- package/dist/moderator-client.d.ts.map +1 -1
- package/dist/moderator-client.js +5 -5
- package/dist/moderator-client.js.map +1 -1
- package/dist/ozone-service-profile.d.ts.map +1 -1
- package/dist/ozone-service-profile.js +12 -11
- package/dist/ozone-service-profile.js.map +1 -1
- package/dist/ozone.d.ts.map +1 -1
- package/dist/ozone.js +1 -3
- package/dist/ozone.js.map +1 -1
- package/dist/pds.js +1 -1
- package/dist/pds.js.map +1 -1
- package/dist/seed/client.d.ts +2 -2
- package/dist/seed/client.d.ts.map +1 -1
- package/dist/seed/client.js +21 -21
- package/dist/seed/client.js.map +1 -1
- package/package.json +8 -8
- package/src/bsky.ts +2 -2
- package/src/mock/index.ts +114 -95
- package/src/moderator-client.ts +11 -9
- package/src/ozone-service-profile.ts +29 -21
- package/src/ozone.ts +3 -5
- package/src/pds.ts +1 -1
- package/src/seed/client.ts +23 -30
package/src/mock/index.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { AtUri } from '@atproto/syntax'
|
2
|
-
import { COM_ATPROTO_MODERATION
|
2
|
+
import AtpAgent, { COM_ATPROTO_MODERATION } from '@atproto/api'
|
3
3
|
import { Database } from '@atproto/bsky'
|
4
4
|
import { EXAMPLE_LABELER, RecordRef, TestNetwork } from '../index'
|
5
5
|
import { postTexts, replyTexts } from './data'
|
@@ -30,67 +30,90 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
30
30
|
throw new Error('Not found')
|
31
31
|
}
|
32
32
|
|
33
|
-
const
|
34
|
-
|
35
|
-
|
33
|
+
const clients = {
|
34
|
+
loggedout: env.pds.getClient(),
|
35
|
+
alice: env.pds.getClient(),
|
36
|
+
bob: env.pds.getClient(),
|
37
|
+
carla: env.pds.getClient(),
|
38
|
+
}
|
39
|
+
interface User {
|
40
|
+
email: string
|
41
|
+
did: string
|
42
|
+
handle: string
|
43
|
+
password: string
|
44
|
+
agent: AtpAgent
|
45
|
+
}
|
46
|
+
const users: User[] = [
|
36
47
|
{
|
37
48
|
email: 'alice@test.com',
|
49
|
+
did: '',
|
38
50
|
handle: `alice.test`,
|
39
51
|
password: 'hunter2',
|
52
|
+
agent: clients.alice,
|
40
53
|
},
|
41
54
|
{
|
42
55
|
email: 'bob@test.com',
|
56
|
+
did: '',
|
43
57
|
handle: `bob.test`,
|
44
58
|
password: 'hunter2',
|
59
|
+
agent: clients.bob,
|
45
60
|
},
|
46
61
|
{
|
47
62
|
email: 'carla@test.com',
|
63
|
+
did: '',
|
48
64
|
handle: `carla.test`,
|
49
65
|
password: 'hunter2',
|
66
|
+
agent: clients.carla,
|
50
67
|
},
|
51
68
|
]
|
69
|
+
const alice = users[0]
|
70
|
+
const bob = users[1]
|
71
|
+
const carla = users[2]
|
52
72
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
73
|
+
let _i = 1
|
74
|
+
for (const user of users) {
|
75
|
+
const res = await clients.loggedout.api.com.atproto.server.createAccount({
|
76
|
+
email: user.email,
|
77
|
+
handle: user.handle,
|
78
|
+
password: user.password,
|
79
|
+
})
|
80
|
+
user.agent.api.setHeader('Authorization', `Bearer ${res.data.accessJwt}`)
|
81
|
+
user.did = res.data.did
|
82
|
+
await user.agent.api.app.bsky.actor.profile.create(
|
83
|
+
{ repo: user.did },
|
84
|
+
{
|
85
|
+
displayName: ucfirst(user.handle).slice(0, -5),
|
86
|
+
description: `Test user ${_i++}`,
|
87
|
+
},
|
88
|
+
)
|
89
|
+
}
|
70
90
|
|
71
91
|
// Create moderator accounts
|
72
|
-
const triageRes =
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
92
|
+
const triageRes =
|
93
|
+
await clients.loggedout.api.com.atproto.server.createAccount({
|
94
|
+
email: 'triage@test.com',
|
95
|
+
handle: 'triage.test',
|
96
|
+
password: 'triage-pass',
|
97
|
+
})
|
77
98
|
await env.ozone.addTriageDid(triageRes.data.did)
|
78
|
-
const modRes = await
|
99
|
+
const modRes = await clients.loggedout.api.com.atproto.server.createAccount({
|
79
100
|
email: 'mod@test.com',
|
80
101
|
handle: 'mod.test',
|
81
102
|
password: 'mod-pass',
|
82
103
|
})
|
83
104
|
await env.ozone.addModeratorDid(modRes.data.did)
|
84
|
-
const adminRes = await
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
105
|
+
const adminRes = await clients.loggedout.api.com.atproto.server.createAccount(
|
106
|
+
{
|
107
|
+
email: 'admin-mod@test.com',
|
108
|
+
handle: 'admin-mod.test',
|
109
|
+
password: 'admin-mod-pass',
|
110
|
+
},
|
111
|
+
)
|
89
112
|
await env.ozone.addAdminDid(adminRes.data.did)
|
90
113
|
|
91
114
|
// Report one user
|
92
|
-
const reporter = picka(
|
93
|
-
await reporter.com.atproto.moderation.createReport({
|
115
|
+
const reporter = picka(users)
|
116
|
+
await reporter.agent.api.com.atproto.moderation.createReport({
|
94
117
|
reasonType: picka([
|
95
118
|
COM_ATPROTO_MODERATION.DefsReasonSpam,
|
96
119
|
COM_ATPROTO_MODERATION.DefsReasonOther,
|
@@ -98,16 +121,16 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
98
121
|
reason: picka(["Didn't look right to me", undefined, undefined]),
|
99
122
|
subject: {
|
100
123
|
$type: 'com.atproto.admin.defs#repoRef',
|
101
|
-
did: picka(
|
124
|
+
did: picka(users).did,
|
102
125
|
},
|
103
126
|
})
|
104
127
|
|
105
128
|
// everybody follows everybody
|
106
|
-
const follow = async (author:
|
107
|
-
await author.app.bsky.graph.follow.create(
|
108
|
-
{ repo: author.
|
129
|
+
const follow = async (author: User, subject: User) => {
|
130
|
+
await author.agent.api.app.bsky.graph.follow.create(
|
131
|
+
{ repo: author.did },
|
109
132
|
{
|
110
|
-
subject: subject.
|
133
|
+
subject: subject.did,
|
111
134
|
createdAt: date.next().value,
|
112
135
|
},
|
113
136
|
)
|
@@ -122,8 +145,8 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
122
145
|
// a set of posts and reposts
|
123
146
|
const posts: { uri: string; cid: string }[] = []
|
124
147
|
for (let i = 0; i < postTexts.length; i++) {
|
125
|
-
const author = picka(
|
126
|
-
const post = await author.app.bsky.feed.post.create(
|
148
|
+
const author = picka(users)
|
149
|
+
const post = await author.agent.api.app.bsky.feed.post.create(
|
127
150
|
{ repo: author.did },
|
128
151
|
{
|
129
152
|
text: postTexts[i],
|
@@ -132,8 +155,8 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
132
155
|
)
|
133
156
|
posts.push(post)
|
134
157
|
if (rand(10) === 0) {
|
135
|
-
const reposter = picka(
|
136
|
-
await reposter.app.bsky.feed.repost.create(
|
158
|
+
const reposter = picka(users)
|
159
|
+
await reposter.agent.api.app.bsky.feed.repost.create(
|
137
160
|
{ repo: reposter.did },
|
138
161
|
{
|
139
162
|
subject: picka(posts),
|
@@ -142,8 +165,8 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
142
165
|
)
|
143
166
|
}
|
144
167
|
if (rand(6) === 0) {
|
145
|
-
const reporter = picka(
|
146
|
-
await reporter.com.atproto.moderation.createReport({
|
168
|
+
const reporter = picka(users)
|
169
|
+
await reporter.agent.api.com.atproto.moderation.createReport({
|
147
170
|
reasonType: picka([
|
148
171
|
COM_ATPROTO_MODERATION.DefsReasonSpam,
|
149
172
|
COM_ATPROTO_MODERATION.DefsReasonOther,
|
@@ -160,11 +183,11 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
160
183
|
|
161
184
|
// make some naughty posts & label them
|
162
185
|
const file = Buffer.from(labeledImgB64, 'base64')
|
163
|
-
const uploadedImg = await bob.com.atproto.repo.uploadBlob(file, {
|
186
|
+
const uploadedImg = await bob.agent.api.com.atproto.repo.uploadBlob(file, {
|
164
187
|
encoding: 'image/png',
|
165
188
|
})
|
166
|
-
const labeledPost = await bob.app.bsky.feed.post.create(
|
167
|
-
{ repo: bob.
|
189
|
+
const labeledPost = await bob.agent.api.app.bsky.feed.post.create(
|
190
|
+
{ repo: bob.did },
|
168
191
|
{
|
169
192
|
text: 'naughty post',
|
170
193
|
embed: {
|
@@ -180,8 +203,8 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
180
203
|
},
|
181
204
|
)
|
182
205
|
|
183
|
-
const filteredPost = await bob.app.bsky.feed.post.create(
|
184
|
-
{ repo: bob.
|
206
|
+
const filteredPost = await bob.agent.api.app.bsky.feed.post.create(
|
207
|
+
{ repo: bob.did },
|
185
208
|
{
|
186
209
|
text: 'reallly bad post should be deleted',
|
187
210
|
createdAt: date.next().value,
|
@@ -203,13 +226,13 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
203
226
|
for (let i = 0; i < 100; i++) {
|
204
227
|
const targetUri = picka(posts).uri
|
205
228
|
const urip = new AtUri(targetUri)
|
206
|
-
const target = await alice.app.bsky.feed.post.get({
|
229
|
+
const target = await alice.agent.api.app.bsky.feed.post.get({
|
207
230
|
repo: urip.host,
|
208
231
|
rkey: urip.rkey,
|
209
232
|
})
|
210
|
-
const author = picka(
|
233
|
+
const author = picka(users)
|
211
234
|
posts.push(
|
212
|
-
await author.app.bsky.feed.post.create(
|
235
|
+
await author.agent.api.app.bsky.feed.post.create(
|
213
236
|
{ repo: author.did },
|
214
237
|
{
|
215
238
|
text: picka(replyTexts),
|
@@ -225,9 +248,9 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
225
248
|
|
226
249
|
// a set of likes
|
227
250
|
for (const post of posts) {
|
228
|
-
for (const user of
|
251
|
+
for (const user of users) {
|
229
252
|
if (rand(3) === 0) {
|
230
|
-
await user.app.bsky.feed.like.create(
|
253
|
+
await user.agent.api.app.bsky.feed.like.create(
|
231
254
|
{ repo: user.did },
|
232
255
|
{
|
233
256
|
subject: post,
|
@@ -239,11 +262,7 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
239
262
|
}
|
240
263
|
|
241
264
|
// a couple feed generators that returns some posts
|
242
|
-
const fg1Uri = AtUri.make(
|
243
|
-
alice.accountDid,
|
244
|
-
'app.bsky.feed.generator',
|
245
|
-
'alice-favs',
|
246
|
-
)
|
265
|
+
const fg1Uri = AtUri.make(alice.did, 'app.bsky.feed.generator', 'alice-favs')
|
247
266
|
const fg1 = await env.createFeedGen({
|
248
267
|
[fg1Uri.toString()]: async () => {
|
249
268
|
const feed = posts
|
@@ -258,11 +277,14 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
258
277
|
},
|
259
278
|
})
|
260
279
|
const avatarImg = Buffer.from(blurHashB64, 'base64')
|
261
|
-
const avatarRes = await alice.com.atproto.repo.uploadBlob(
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
280
|
+
const avatarRes = await alice.agent.api.com.atproto.repo.uploadBlob(
|
281
|
+
avatarImg,
|
282
|
+
{
|
283
|
+
encoding: 'image/png',
|
284
|
+
},
|
285
|
+
)
|
286
|
+
const fgAliceRes = await alice.agent.api.app.bsky.feed.generator.create(
|
287
|
+
{ repo: alice.did, rkey: fg1Uri.rkey },
|
266
288
|
{
|
267
289
|
did: fg1.did,
|
268
290
|
displayName: 'alices feed',
|
@@ -272,8 +294,8 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
272
294
|
},
|
273
295
|
)
|
274
296
|
|
275
|
-
await alice.app.bsky.feed.post.create(
|
276
|
-
{ repo: alice.
|
297
|
+
await alice.agent.api.app.bsky.feed.post.create(
|
298
|
+
{ repo: alice.did },
|
277
299
|
{
|
278
300
|
text: 'check out my algorithm!',
|
279
301
|
embed: {
|
@@ -284,7 +306,7 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
284
306
|
},
|
285
307
|
)
|
286
308
|
for (const user of [alice, bob, carla]) {
|
287
|
-
await user.app.bsky.feed.like.create(
|
309
|
+
await user.agent.api.app.bsky.feed.like.create(
|
288
310
|
{ repo: user.did },
|
289
311
|
{
|
290
312
|
subject: fgAliceRes,
|
@@ -293,11 +315,7 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
293
315
|
)
|
294
316
|
}
|
295
317
|
|
296
|
-
const fg2Uri = AtUri.make(
|
297
|
-
bob.accountDid,
|
298
|
-
'app.bsky.feed.generator',
|
299
|
-
'bob-redux',
|
300
|
-
)
|
318
|
+
const fg2Uri = AtUri.make(bob.did, 'app.bsky.feed.generator', 'bob-redux')
|
301
319
|
const fg2 = await env.createFeedGen({
|
302
320
|
[fg2Uri.toString()]: async () => {
|
303
321
|
const feed = posts
|
@@ -311,8 +329,8 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
311
329
|
}
|
312
330
|
},
|
313
331
|
})
|
314
|
-
const fgBobRes = await bob.app.bsky.feed.generator.create(
|
315
|
-
{ repo: bob.
|
332
|
+
const fgBobRes = await bob.agent.api.app.bsky.feed.generator.create(
|
333
|
+
{ repo: bob.did, rkey: fg2Uri.rkey },
|
316
334
|
{
|
317
335
|
did: fg2.did,
|
318
336
|
displayName: 'Bobby boy hot new algo',
|
@@ -320,8 +338,8 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
320
338
|
},
|
321
339
|
)
|
322
340
|
|
323
|
-
await alice.app.bsky.feed.post.create(
|
324
|
-
{ repo: alice.
|
341
|
+
await alice.agent.api.app.bsky.feed.post.create(
|
342
|
+
{ repo: alice.did },
|
325
343
|
{
|
326
344
|
text: `bobs feed is neat too`,
|
327
345
|
embed: {
|
@@ -334,13 +352,14 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
334
352
|
|
335
353
|
// create a labeler account
|
336
354
|
{
|
337
|
-
const
|
338
|
-
const res = await labeler.createAccount({
|
355
|
+
const res = await clients.loggedout.api.com.atproto.server.createAccount({
|
339
356
|
email: 'labeler@test.com',
|
340
357
|
handle: 'labeler.test',
|
341
358
|
password: 'hunter2',
|
342
359
|
})
|
343
|
-
|
360
|
+
const agent = env.pds.getClient()
|
361
|
+
agent.api.setHeader('Authorization', `Bearer ${res.data.accessJwt}`)
|
362
|
+
await agent.api.app.bsky.actor.profile.create(
|
344
363
|
{ repo: res.data.did },
|
345
364
|
{
|
346
365
|
displayName: 'Test Labeler',
|
@@ -348,7 +367,7 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
348
367
|
},
|
349
368
|
)
|
350
369
|
|
351
|
-
await
|
370
|
+
await agent.api.app.bsky.labeler.service.create(
|
352
371
|
{ repo: res.data.did, rkey: 'self' },
|
353
372
|
{
|
354
373
|
policies: {
|
@@ -436,25 +455,25 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
436
455
|
},
|
437
456
|
)
|
438
457
|
await createLabel(env.bsky.db, {
|
439
|
-
uri: alice.
|
458
|
+
uri: alice.did,
|
440
459
|
cid: '',
|
441
460
|
val: 'rude',
|
442
461
|
src: res.data.did,
|
443
462
|
})
|
444
463
|
await createLabel(env.bsky.db, {
|
445
|
-
uri: `at://${alice.
|
464
|
+
uri: `at://${alice.did}/app.bsky.feed.generator/alice-favs`,
|
446
465
|
cid: '',
|
447
466
|
val: 'cool',
|
448
467
|
src: res.data.did,
|
449
468
|
})
|
450
469
|
await createLabel(env.bsky.db, {
|
451
|
-
uri: bob.
|
470
|
+
uri: bob.did,
|
452
471
|
cid: '',
|
453
472
|
val: 'cool',
|
454
473
|
src: res.data.did,
|
455
474
|
})
|
456
475
|
await createLabel(env.bsky.db, {
|
457
|
-
uri: carla.
|
476
|
+
uri: carla.did,
|
458
477
|
cid: '',
|
459
478
|
val: 'spam',
|
460
479
|
src: res.data.did,
|
@@ -463,8 +482,8 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
463
482
|
|
464
483
|
// Create lists and add people to the lists
|
465
484
|
{
|
466
|
-
const flowerLovers = await alice.app.bsky.graph.list.create(
|
467
|
-
{ repo: alice.
|
485
|
+
const flowerLovers = await alice.agent.api.app.bsky.graph.list.create(
|
486
|
+
{ repo: alice.did },
|
468
487
|
{
|
469
488
|
name: 'Flower Lovers',
|
470
489
|
purpose: 'app.bsky.graph.defs#curatelist',
|
@@ -472,8 +491,8 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
472
491
|
description: 'A list of posts about flowers',
|
473
492
|
},
|
474
493
|
)
|
475
|
-
const labelHaters = await bob.app.bsky.graph.list.create(
|
476
|
-
{ repo: bob.
|
494
|
+
const labelHaters = await bob.agent.api.app.bsky.graph.list.create(
|
495
|
+
{ repo: bob.did },
|
477
496
|
{
|
478
497
|
name: 'Label Haters',
|
479
498
|
purpose: 'app.bsky.graph.defs#modlist',
|
@@ -481,18 +500,18 @@ export async function generateMockSetup(env: TestNetwork) {
|
|
481
500
|
description: 'A list of people who hate labels',
|
482
501
|
},
|
483
502
|
)
|
484
|
-
await alice.app.bsky.graph.listitem.create(
|
485
|
-
{ repo: alice.
|
503
|
+
await alice.agent.api.app.bsky.graph.listitem.create(
|
504
|
+
{ repo: alice.did },
|
486
505
|
{
|
487
|
-
subject: bob.
|
506
|
+
subject: bob.did,
|
488
507
|
createdAt: new Date().toISOString(),
|
489
508
|
list: new RecordRef(flowerLovers.uri, flowerLovers.cid).uriStr,
|
490
509
|
},
|
491
510
|
)
|
492
|
-
await bob.app.bsky.graph.listitem.create(
|
493
|
-
{ repo: bob.
|
511
|
+
await bob.agent.api.app.bsky.graph.listitem.create(
|
512
|
+
{ repo: bob.did },
|
494
513
|
{
|
495
|
-
subject: alice.
|
514
|
+
subject: alice.did,
|
496
515
|
createdAt: new Date().toISOString(),
|
497
516
|
list: new RecordRef(labelHaters.uri, labelHaters.cid).uriStr,
|
498
517
|
},
|
package/src/moderator-client.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
AtpAgent,
|
1
|
+
import AtpAgent, {
|
3
2
|
ToolsOzoneModerationEmitEvent as EmitModerationEvent,
|
4
3
|
ToolsOzoneModerationQueryStatuses as QueryModerationStatuses,
|
5
4
|
ToolsOzoneModerationQueryEvents as QueryModerationEvents,
|
@@ -18,7 +17,7 @@ export class ModeratorClient {
|
|
18
17
|
}
|
19
18
|
|
20
19
|
async getEvent(id: number, role?: ModLevel) {
|
21
|
-
const result = await this.agent.tools.ozone.moderation.getEvent(
|
20
|
+
const result = await this.agent.api.tools.ozone.moderation.getEvent(
|
22
21
|
{ id },
|
23
22
|
{
|
24
23
|
headers: await this.ozone.modHeaders(role),
|
@@ -28,7 +27,7 @@ export class ModeratorClient {
|
|
28
27
|
}
|
29
28
|
|
30
29
|
async queryStatuses(input: QueryStatusesParams, role?: ModLevel) {
|
31
|
-
const result = await this.agent.tools.ozone.moderation.queryStatuses(
|
30
|
+
const result = await this.agent.api.tools.ozone.moderation.queryStatuses(
|
32
31
|
input,
|
33
32
|
{
|
34
33
|
headers: await this.ozone.modHeaders(role),
|
@@ -38,9 +37,12 @@ export class ModeratorClient {
|
|
38
37
|
}
|
39
38
|
|
40
39
|
async queryEvents(input: QueryEventsParams, role?: ModLevel) {
|
41
|
-
const result = await this.agent.tools.ozone.moderation.queryEvents(
|
42
|
-
|
43
|
-
|
40
|
+
const result = await this.agent.api.tools.ozone.moderation.queryEvents(
|
41
|
+
input,
|
42
|
+
{
|
43
|
+
headers: await this.ozone.modHeaders(role),
|
44
|
+
},
|
45
|
+
)
|
44
46
|
return result.data
|
45
47
|
}
|
46
48
|
|
@@ -62,7 +64,7 @@ export class ModeratorClient {
|
|
62
64
|
reason = 'X',
|
63
65
|
createdBy = 'did:example:admin',
|
64
66
|
} = opts
|
65
|
-
const result = await this.agent.tools.ozone.moderation.emitEvent(
|
67
|
+
const result = await this.agent.api.tools.ozone.moderation.emitEvent(
|
66
68
|
{ event, subject, subjectBlobCids, createdBy, reason },
|
67
69
|
{
|
68
70
|
encoding: 'application/json',
|
@@ -82,7 +84,7 @@ export class ModeratorClient {
|
|
82
84
|
role?: ModLevel,
|
83
85
|
) {
|
84
86
|
const { subject, reason = 'X', createdBy = 'did:example:admin' } = opts
|
85
|
-
const result = await this.agent.tools.ozone.moderation.emitEvent(
|
87
|
+
const result = await this.agent.api.tools.ozone.moderation.emitEvent(
|
86
88
|
{
|
87
89
|
subject,
|
88
90
|
event: {
|
@@ -18,9 +18,16 @@ export class OzoneServiceProfile {
|
|
18
18
|
}
|
19
19
|
|
20
20
|
async createDidAndKey() {
|
21
|
-
|
21
|
+
const modUser =
|
22
|
+
await this.thirdPartyPdsClient.api.com.atproto.server.createAccount(
|
23
|
+
this.modUserDetails,
|
24
|
+
)
|
25
|
+
await this.thirdPartyPdsClient.login({
|
26
|
+
identifier: this.modUserDetails.handle,
|
27
|
+
password: this.modUserDetails.password,
|
28
|
+
})
|
22
29
|
|
23
|
-
this.did =
|
30
|
+
this.did = modUser.data.did
|
24
31
|
this.key = await Secp256k1Keypair.create({ exportable: true })
|
25
32
|
return { did: this.did, key: this.key }
|
26
33
|
}
|
@@ -34,7 +41,7 @@ export class OzoneServiceProfile {
|
|
34
41
|
throw new Error('No DID/key found!')
|
35
42
|
}
|
36
43
|
const pdsClient = pds.getClient()
|
37
|
-
const describeRes = await pdsClient.com.atproto.server.describeServer()
|
44
|
+
const describeRes = await pdsClient.api.com.atproto.server.describeServer()
|
38
45
|
const newServerDid = describeRes.data.did
|
39
46
|
|
40
47
|
const serviceJwtRes =
|
@@ -43,22 +50,23 @@ export class OzoneServiceProfile {
|
|
43
50
|
})
|
44
51
|
const serviceJwt = serviceJwtRes.data.token
|
45
52
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
const accountResponse =
|
54
|
+
await pdsClient.api.com.atproto.server.createAccount(
|
55
|
+
{
|
56
|
+
...this.modUserDetails,
|
57
|
+
...userDetails,
|
58
|
+
did: this.did,
|
59
|
+
},
|
60
|
+
{
|
61
|
+
headers: { authorization: `Bearer ${serviceJwt}` },
|
62
|
+
encoding: 'application/json',
|
63
|
+
},
|
64
|
+
)
|
57
65
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
66
|
+
pdsClient.api.setHeader(
|
67
|
+
'Authorization',
|
68
|
+
`Bearer ${accountResponse.data.accessJwt}`,
|
69
|
+
)
|
62
70
|
|
63
71
|
const getDidCredentials =
|
64
72
|
await pdsClient.com.atproto.identity.getRecommendedDidCredentials()
|
@@ -95,9 +103,9 @@ export class OzoneServiceProfile {
|
|
95
103
|
operation: plcOp.data.operation,
|
96
104
|
})
|
97
105
|
|
98
|
-
await pdsClient.com.atproto.server.activateAccount()
|
106
|
+
await pdsClient.api.com.atproto.server.activateAccount()
|
99
107
|
|
100
|
-
await pdsClient.app.bsky.actor.profile.create(
|
108
|
+
await pdsClient.api.app.bsky.actor.profile.create(
|
101
109
|
{ repo: this.did },
|
102
110
|
{
|
103
111
|
displayName: 'Dev-env Moderation',
|
@@ -105,7 +113,7 @@ export class OzoneServiceProfile {
|
|
105
113
|
},
|
106
114
|
)
|
107
115
|
|
108
|
-
await pdsClient.app.bsky.labeler.service.create(
|
116
|
+
await pdsClient.api.app.bsky.labeler.service.create(
|
109
117
|
{ repo: this.did, rkey: 'self' },
|
110
118
|
{
|
111
119
|
policies: {
|
package/src/ozone.ts
CHANGED
@@ -6,7 +6,7 @@ import { AtpAgent } from '@atproto/api'
|
|
6
6
|
import { createServiceJwt } from '@atproto/xrpc-server'
|
7
7
|
import { Keypair, Secp256k1Keypair } from '@atproto/crypto'
|
8
8
|
import { DidAndKey, OzoneConfig } from './types'
|
9
|
-
import { ADMIN_PASSWORD
|
9
|
+
import { ADMIN_PASSWORD } from './const'
|
10
10
|
import { createDidAndKey } from './util'
|
11
11
|
import { ModeratorClient } from './moderator-client'
|
12
12
|
|
@@ -103,10 +103,8 @@ export class TestOzone {
|
|
103
103
|
return this.server.ctx
|
104
104
|
}
|
105
105
|
|
106
|
-
getClient()
|
107
|
-
|
108
|
-
agent.configureLabelers([EXAMPLE_LABELER])
|
109
|
-
return agent
|
106
|
+
getClient() {
|
107
|
+
return new AtpAgent({ service: this.url })
|
110
108
|
}
|
111
109
|
|
112
110
|
getModClient() {
|