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