@atproto/dev-env 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,420 @@
1
+ import { TestPds } from './pds'
2
+ import { AtpAgent } from '@atproto/api'
3
+ import { Secp256k1Keypair } from '@atproto/crypto'
4
+
5
+ export class OzoneServiceProfile {
6
+ did?: string
7
+ key?: Secp256k1Keypair
8
+ thirdPartyPdsClient: AtpAgent
9
+
10
+ modUserDetails = {
11
+ email: 'mod-authority@test.com',
12
+ handle: 'mod-authority.test',
13
+ password: 'hunter2',
14
+ }
15
+
16
+ public constructor(public thirdPartyPds: TestPds) {
17
+ this.thirdPartyPdsClient = this.thirdPartyPds.getClient()
18
+ }
19
+
20
+ async createDidAndKey() {
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
+ })
29
+
30
+ this.did = modUser.data.did
31
+ this.key = await Secp256k1Keypair.create({ exportable: true })
32
+ return { did: this.did, key: this.key }
33
+ }
34
+
35
+ async createServiceDetails(
36
+ pds: TestPds,
37
+ ozoneUrl: string,
38
+ userDetails: { inviteCode?: string } = {},
39
+ ) {
40
+ if (!this.did || !this.key) {
41
+ throw new Error('No DID/key found!')
42
+ }
43
+ const pdsClient = pds.getClient()
44
+ const describeRes = await pdsClient.api.com.atproto.server.describeServer()
45
+ const newServerDid = describeRes.data.did
46
+
47
+ const serviceJwtRes =
48
+ await this.thirdPartyPdsClient.com.atproto.server.getServiceAuth({
49
+ aud: newServerDid,
50
+ })
51
+ const serviceJwt = serviceJwtRes.data.token
52
+
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
+ )
65
+
66
+ pdsClient.api.setHeader(
67
+ 'Authorization',
68
+ `Bearer ${accountResponse.data.accessJwt}`,
69
+ )
70
+
71
+ const getDidCredentials =
72
+ await pdsClient.com.atproto.identity.getRecommendedDidCredentials()
73
+
74
+ await this.thirdPartyPdsClient.com.atproto.identity.requestPlcOperationSignature()
75
+
76
+ const tokenRes = await this.thirdPartyPds.ctx.accountManager.db.db
77
+ .selectFrom('email_token')
78
+ .selectAll()
79
+ .where('did', '=', this.did)
80
+ .where('purpose', '=', 'plc_operation')
81
+ .executeTakeFirst()
82
+ const token = tokenRes?.token
83
+ const plcOperationData = {
84
+ token,
85
+ ...getDidCredentials.data,
86
+ }
87
+
88
+ if (!plcOperationData.services) plcOperationData.services = {}
89
+ plcOperationData.services['atproto_labeler'] = {
90
+ type: 'AtprotoLabeler',
91
+ endpoint: ozoneUrl,
92
+ }
93
+ if (!plcOperationData.verificationMethods)
94
+ plcOperationData.verificationMethods = {}
95
+ plcOperationData.verificationMethods['atproto_label'] = this.key.did()
96
+
97
+ const plcOp =
98
+ await this.thirdPartyPdsClient.com.atproto.identity.signPlcOperation(
99
+ plcOperationData,
100
+ )
101
+
102
+ await pdsClient.com.atproto.identity.submitPlcOperation({
103
+ operation: plcOp.data.operation,
104
+ })
105
+
106
+ await pdsClient.api.com.atproto.server.activateAccount()
107
+
108
+ await pdsClient.api.app.bsky.actor.profile.create(
109
+ { repo: this.did },
110
+ {
111
+ displayName: 'Dev-env Moderation',
112
+ description: `The pretend version of mod.bsky.app`,
113
+ },
114
+ )
115
+
116
+ await pdsClient.api.app.bsky.labeler.service.create(
117
+ { repo: this.did, rkey: 'self' },
118
+ {
119
+ policies: {
120
+ labelValues: [
121
+ '!hide',
122
+ '!warn',
123
+ 'porn',
124
+ 'sexual',
125
+ 'nudity',
126
+ 'sexual-figurative',
127
+ 'graphic-media',
128
+ 'self-harm',
129
+ 'sensitive',
130
+ 'extremist',
131
+ 'intolerant',
132
+ 'threat',
133
+ 'rude',
134
+ 'illicit',
135
+ 'security',
136
+ 'unsafe-link',
137
+ 'impersonation',
138
+ 'misinformation',
139
+ 'scam',
140
+ 'engagement-farming',
141
+ 'spam',
142
+ 'rumor',
143
+ 'misleading',
144
+ 'inauthentic',
145
+ ],
146
+ labelValueDefinitions: [
147
+ {
148
+ identifier: 'spam',
149
+ blurs: 'content',
150
+ severity: 'inform',
151
+ defaultSetting: 'hide',
152
+ adultOnly: false,
153
+ locales: [
154
+ {
155
+ lang: 'en',
156
+ name: 'Spam',
157
+ description:
158
+ 'Unwanted, repeated, or unrelated actions that bother users.',
159
+ },
160
+ ],
161
+ },
162
+ {
163
+ identifier: 'impersonation',
164
+ blurs: 'none',
165
+ severity: 'inform',
166
+ defaultSetting: 'hide',
167
+ adultOnly: false,
168
+ locales: [
169
+ {
170
+ lang: 'en',
171
+ name: 'Impersonation',
172
+ description:
173
+ 'Pretending to be someone else without permission.',
174
+ },
175
+ ],
176
+ },
177
+ {
178
+ identifier: 'scam',
179
+ blurs: 'content',
180
+ severity: 'alert',
181
+ defaultSetting: 'hide',
182
+ adultOnly: false,
183
+ locales: [
184
+ {
185
+ lang: 'en',
186
+ name: 'Scam',
187
+ description: 'Scams, phishing & fraud.',
188
+ },
189
+ ],
190
+ },
191
+ {
192
+ identifier: 'intolerant',
193
+ blurs: 'content',
194
+ severity: 'alert',
195
+ defaultSetting: 'warn',
196
+ adultOnly: false,
197
+ locales: [
198
+ {
199
+ lang: 'en',
200
+ name: 'Intolerance',
201
+ description: 'Discrimination against protected groups.',
202
+ },
203
+ ],
204
+ },
205
+ {
206
+ identifier: 'self-harm',
207
+ blurs: 'content',
208
+ severity: 'alert',
209
+ defaultSetting: 'warn',
210
+ adultOnly: false,
211
+ locales: [
212
+ {
213
+ lang: 'en',
214
+ name: 'Self-Harm',
215
+ description:
216
+ 'Promotes self-harm, including graphic images, glorifying discussions, or triggering stories.',
217
+ },
218
+ ],
219
+ },
220
+ {
221
+ identifier: 'security',
222
+ blurs: 'content',
223
+ severity: 'alert',
224
+ defaultSetting: 'hide',
225
+ adultOnly: false,
226
+ locales: [
227
+ {
228
+ lang: 'en',
229
+ name: 'Security Concerns',
230
+ description:
231
+ 'May be unsafe and could harm your device, steal your info, or get your account hacked.',
232
+ },
233
+ ],
234
+ },
235
+ {
236
+ identifier: 'misleading',
237
+ blurs: 'content',
238
+ severity: 'alert',
239
+ defaultSetting: 'warn',
240
+ adultOnly: false,
241
+ locales: [
242
+ {
243
+ lang: 'en',
244
+ name: 'Misleading',
245
+ description:
246
+ 'Altered images/videos, deceptive links, or false statements.',
247
+ },
248
+ ],
249
+ },
250
+ {
251
+ identifier: 'threat',
252
+ blurs: 'content',
253
+ severity: 'inform',
254
+ defaultSetting: 'hide',
255
+ adultOnly: false,
256
+ locales: [
257
+ {
258
+ lang: 'en',
259
+ name: 'Threats',
260
+ description:
261
+ 'Promotes violence or harm towards others, including threats, incitement, or advocacy of harm.',
262
+ },
263
+ ],
264
+ },
265
+ {
266
+ identifier: 'unsafe-link',
267
+ blurs: 'content',
268
+ severity: 'alert',
269
+ defaultSetting: 'hide',
270
+ adultOnly: false,
271
+ locales: [
272
+ {
273
+ lang: 'en',
274
+ name: 'Unsafe link',
275
+ description:
276
+ 'Links to harmful sites with malware, phishing, or violating content that risk security and privacy.',
277
+ },
278
+ ],
279
+ },
280
+ {
281
+ identifier: 'illicit',
282
+ blurs: 'content',
283
+ severity: 'alert',
284
+ defaultSetting: 'hide',
285
+ adultOnly: false,
286
+ locales: [
287
+ {
288
+ lang: 'en',
289
+ name: 'Illicit',
290
+ description:
291
+ 'Promoting or selling potentially illicit goods, services, or activities.',
292
+ },
293
+ ],
294
+ },
295
+ {
296
+ identifier: 'misinformation',
297
+ blurs: 'content',
298
+ severity: 'inform',
299
+ defaultSetting: 'warn',
300
+ adultOnly: false,
301
+ locales: [
302
+ {
303
+ lang: 'en',
304
+ name: 'Misinformation',
305
+ description:
306
+ 'Spreading false or misleading info, including unverified claims and harmful conspiracy theories.',
307
+ },
308
+ ],
309
+ },
310
+ {
311
+ identifier: 'rumor',
312
+ blurs: 'content',
313
+ severity: 'inform',
314
+ defaultSetting: 'warn',
315
+ adultOnly: false,
316
+ locales: [
317
+ {
318
+ lang: 'en',
319
+ name: 'Rumor',
320
+ description:
321
+ 'Approach with caution, as these claims lack evidence from credible sources.',
322
+ },
323
+ ],
324
+ },
325
+ {
326
+ identifier: 'rude',
327
+ blurs: 'content',
328
+ severity: 'inform',
329
+ defaultSetting: 'hide',
330
+ adultOnly: false,
331
+ locales: [
332
+ {
333
+ lang: 'en',
334
+ name: 'Rude',
335
+ description:
336
+ 'Rude or impolite, including crude language and disrespectful comments, without constructive purpose.',
337
+ },
338
+ ],
339
+ },
340
+ {
341
+ identifier: 'extremist',
342
+ blurs: 'content',
343
+ severity: 'alert',
344
+ defaultSetting: 'hide',
345
+ adultOnly: false,
346
+ locales: [
347
+ {
348
+ lang: 'en',
349
+ name: 'Extremist',
350
+ description:
351
+ 'Radical views advocating violence, hate, or discrimination against individuals or groups.',
352
+ },
353
+ ],
354
+ },
355
+ {
356
+ identifier: 'sensitive',
357
+ blurs: 'content',
358
+ severity: 'alert',
359
+ defaultSetting: 'warn',
360
+ adultOnly: false,
361
+ locales: [
362
+ {
363
+ lang: 'en',
364
+ name: 'Sensitive',
365
+ description:
366
+ 'May be upsetting, covering topics like substance abuse or mental health issues, cautioning sensitive viewers.',
367
+ },
368
+ ],
369
+ },
370
+ {
371
+ identifier: 'engagement-farming',
372
+ blurs: 'content',
373
+ severity: 'alert',
374
+ defaultSetting: 'hide',
375
+ adultOnly: false,
376
+ locales: [
377
+ {
378
+ lang: 'en',
379
+ name: 'Engagement Farming',
380
+ description:
381
+ 'Insincere content or bulk actions aimed at gaining followers, including frequent follows, posts, and likes.',
382
+ },
383
+ ],
384
+ },
385
+ {
386
+ identifier: 'inauthentic',
387
+ blurs: 'content',
388
+ severity: 'alert',
389
+ defaultSetting: 'hide',
390
+ adultOnly: false,
391
+ locales: [
392
+ {
393
+ lang: 'en',
394
+ name: 'Inauthentic Account',
395
+ description: 'Bot or a person pretending to be someone else.',
396
+ },
397
+ ],
398
+ },
399
+ {
400
+ identifier: 'sexual-figurative',
401
+ blurs: 'media',
402
+ severity: 'none',
403
+ defaultSetting: 'show',
404
+ adultOnly: true,
405
+ locales: [
406
+ {
407
+ lang: 'en',
408
+ name: 'Sexually Suggestive (Cartoon)',
409
+ description:
410
+ 'Art with explicit or suggestive sexual themes, including provocative imagery or partial nudity.',
411
+ },
412
+ ],
413
+ },
414
+ ],
415
+ },
416
+ createdAt: new Date().toISOString(),
417
+ },
418
+ )
419
+ }
420
+ }
package/src/ozone.ts CHANGED
@@ -56,7 +56,7 @@ export class TestOzone {
56
56
  version: '0.0.0',
57
57
  port,
58
58
  didPlcUrl: config.plcUrl,
59
- publicUrl: 'https://ozone.public.url',
59
+ publicUrl: url,
60
60
  serverDid,
61
61
  signingKeyHex,
62
62
  ...config,