@atproto/api 0.20.22 → 0.20.25

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 (64) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/client/lexicons.d.ts +28 -12
  3. package/dist/client/lexicons.d.ts.map +1 -1
  4. package/dist/client/lexicons.js +14 -6
  5. package/dist/client/lexicons.js.map +1 -1
  6. package/dist/client/types/app/bsky/ageassurance/defs.d.ts +2 -0
  7. package/dist/client/types/app/bsky/ageassurance/defs.d.ts.map +1 -1
  8. package/dist/client/types/app/bsky/ageassurance/defs.js.map +1 -1
  9. package/package.json +22 -16
  10. package/definitions/labels.json +0 -170
  11. package/docs/moderation.md +0 -260
  12. package/jest.config.cjs +0 -23
  13. package/jest.d.ts +0 -20
  14. package/jest.setup.ts +0 -97
  15. package/scripts/code/labels.mjs +0 -77
  16. package/scripts/generate-code.mjs +0 -4
  17. package/src/age-assurance.test.ts +0 -218
  18. package/src/age-assurance.ts +0 -137
  19. package/src/agent.ts +0 -1645
  20. package/src/atp-agent.ts +0 -570
  21. package/src/bsky-agent.ts +0 -14
  22. package/src/const.ts +0 -1
  23. package/src/index.ts +0 -44
  24. package/src/mocker.ts +0 -220
  25. package/src/moderation/decision.ts +0 -389
  26. package/src/moderation/index.ts +0 -69
  27. package/src/moderation/mutewords.ts +0 -170
  28. package/src/moderation/subjects/account.ts +0 -44
  29. package/src/moderation/subjects/feed-generator.ts +0 -24
  30. package/src/moderation/subjects/notification.ts +0 -25
  31. package/src/moderation/subjects/post.ts +0 -433
  32. package/src/moderation/subjects/profile.ts +0 -26
  33. package/src/moderation/subjects/status.ts +0 -27
  34. package/src/moderation/subjects/user-list.ts +0 -48
  35. package/src/moderation/types.ts +0 -191
  36. package/src/moderation/ui.ts +0 -21
  37. package/src/moderation/util.ts +0 -111
  38. package/src/predicate.ts +0 -52
  39. package/src/rich-text/detection.ts +0 -146
  40. package/src/rich-text/rich-text.ts +0 -418
  41. package/src/rich-text/sanitization.ts +0 -42
  42. package/src/rich-text/unicode.ts +0 -47
  43. package/src/rich-text/util.ts +0 -15
  44. package/src/session-manager.ts +0 -5
  45. package/src/types.ts +0 -165
  46. package/src/util.ts +0 -96
  47. package/tests/atp-agent.test.ts +0 -3863
  48. package/tests/dispatcher.test.ts +0 -527
  49. package/tests/errors.test.ts +0 -29
  50. package/tests/moderation-behaviors.test.ts +0 -951
  51. package/tests/moderation-custom-labels.test.ts +0 -334
  52. package/tests/moderation-mutewords.test.ts +0 -1299
  53. package/tests/moderation-prefs.test.ts +0 -402
  54. package/tests/moderation-quoteposts.test.ts +0 -277
  55. package/tests/moderation.test.ts +0 -739
  56. package/tests/rich-text-detection.test.ts +0 -456
  57. package/tests/rich-text-sanitization.test.ts +0 -216
  58. package/tests/rich-text.test.ts +0 -705
  59. package/tests/util/echo-server.ts +0 -37
  60. package/tests/util/moderation-behavior.ts +0 -268
  61. package/tsconfig.build.json +0 -9
  62. package/tsconfig.build.tsbuildinfo +0 -1
  63. package/tsconfig.json +0 -7
  64. package/tsconfig.tests.json +0 -10
@@ -1,334 +0,0 @@
1
- import {
2
- InterpretedLabelValueDefinition,
3
- ModerationOpts,
4
- interpretLabelValueDefinition,
5
- mock,
6
- moderatePost,
7
- moderateProfile,
8
- } from '../src/index.js'
9
- import './util/moderation-behavior.js'
10
-
11
- interface ScenarioResult {
12
- profileList?: string[]
13
- profileView?: string[]
14
- avatar?: string[]
15
- banner?: string[]
16
- displayName?: string[]
17
- contentList?: string[]
18
- contentView?: string[]
19
- contentMedia?: string[]
20
- }
21
-
22
- interface Scenario {
23
- blurs: 'content' | 'media' | 'none'
24
- severity: 'alert' | 'inform' | 'none'
25
- account: ScenarioResult
26
- profile: ScenarioResult
27
- post: ScenarioResult
28
- }
29
-
30
- const TESTS: Scenario[] = [
31
- {
32
- blurs: 'content',
33
- severity: 'alert',
34
- account: {
35
- profileList: ['filter', 'alert'],
36
- profileView: ['alert'],
37
- contentList: ['filter', 'blur'],
38
- contentView: ['alert'],
39
- },
40
- profile: {
41
- profileList: ['alert'],
42
- profileView: ['alert'],
43
- },
44
- post: {
45
- contentList: ['filter', 'blur'],
46
- contentView: ['alert'],
47
- },
48
- },
49
- {
50
- blurs: 'content',
51
- severity: 'inform',
52
- account: {
53
- profileList: ['filter', 'inform'],
54
- profileView: ['inform'],
55
- contentList: ['filter', 'blur'],
56
- contentView: ['inform'],
57
- },
58
- profile: {
59
- profileList: ['inform'],
60
- profileView: ['inform'],
61
- },
62
- post: {
63
- contentList: ['filter', 'blur'],
64
- contentView: ['inform'],
65
- },
66
- },
67
- {
68
- blurs: 'content',
69
- severity: 'none',
70
- account: {
71
- profileList: ['filter'],
72
- profileView: [],
73
- contentList: ['filter', 'blur'],
74
- contentView: [],
75
- },
76
- profile: {
77
- profileList: [],
78
- profileView: [],
79
- },
80
- post: {
81
- contentList: ['filter', 'blur'],
82
- contentView: [],
83
- },
84
- },
85
-
86
- {
87
- blurs: 'media',
88
- severity: 'alert',
89
- account: {
90
- profileList: ['filter', 'alert'],
91
- profileView: ['alert'],
92
- avatar: ['blur'],
93
- banner: ['blur'],
94
- contentList: ['filter'],
95
- },
96
- profile: {
97
- profileList: ['alert'],
98
- profileView: ['alert'],
99
- avatar: ['blur'],
100
- banner: ['blur'],
101
- },
102
- post: {
103
- contentList: ['filter'],
104
- contentMedia: ['blur'],
105
- },
106
- },
107
- {
108
- blurs: 'media',
109
- severity: 'inform',
110
- account: {
111
- profileList: ['filter', 'inform'],
112
- profileView: ['inform'],
113
- avatar: ['blur'],
114
- banner: ['blur'],
115
- contentList: ['filter'],
116
- },
117
- profile: {
118
- profileList: ['inform'],
119
- profileView: ['inform'],
120
- avatar: ['blur'],
121
- banner: ['blur'],
122
- },
123
- post: {
124
- contentList: ['filter'],
125
- contentMedia: ['blur'],
126
- },
127
- },
128
- {
129
- blurs: 'media',
130
- severity: 'none',
131
- account: {
132
- profileList: ['filter'],
133
- avatar: ['blur'],
134
- banner: ['blur'],
135
- contentList: ['filter'],
136
- },
137
- profile: {
138
- avatar: ['blur'],
139
- banner: ['blur'],
140
- },
141
- post: {
142
- contentList: ['filter'],
143
- contentMedia: ['blur'],
144
- },
145
- },
146
-
147
- {
148
- blurs: 'none',
149
- severity: 'alert',
150
- account: {
151
- profileList: ['filter', 'alert'],
152
- profileView: ['alert'],
153
- contentList: ['filter', 'alert'],
154
- contentView: ['alert'],
155
- },
156
- profile: {
157
- profileList: ['alert'],
158
- profileView: ['alert'],
159
- },
160
- post: {
161
- contentList: ['filter', 'alert'],
162
- contentView: ['alert'],
163
- },
164
- },
165
- {
166
- blurs: 'none',
167
- severity: 'inform',
168
- account: {
169
- profileList: ['filter', 'inform'],
170
- profileView: ['inform'],
171
- contentList: ['filter', 'inform'],
172
- contentView: ['inform'],
173
- },
174
- profile: {
175
- profileList: ['inform'],
176
- profileView: ['inform'],
177
- },
178
- post: {
179
- contentList: ['filter', 'inform'],
180
- contentView: ['inform'],
181
- },
182
- },
183
- {
184
- blurs: 'none',
185
- severity: 'none',
186
- account: {
187
- profileList: ['filter'],
188
- contentList: ['filter'],
189
- },
190
- profile: {},
191
- post: {
192
- contentList: ['filter'],
193
- },
194
- },
195
- ]
196
-
197
- describe('Moderation: custom labels', () => {
198
- const scenarios = TESTS.flatMap((test) => [
199
- {
200
- blurs: test.blurs,
201
- severity: test.severity,
202
- target: 'post',
203
- expected: test.post,
204
- },
205
- {
206
- blurs: test.blurs,
207
- severity: test.severity,
208
- target: 'profile',
209
- expected: test.profile,
210
- },
211
- {
212
- blurs: test.blurs,
213
- severity: test.severity,
214
- target: 'account',
215
- expected: test.account,
216
- },
217
- ])
218
- it.each(scenarios)(
219
- 'blurs=$blurs, severity=$severity, target=$target',
220
- ({ blurs, severity, target, expected }) => {
221
- let res
222
- if (target === 'post') {
223
- res = moderatePost(
224
- mock.postView({
225
- record: {
226
- $type: 'app.bsky.feed.post',
227
- text: 'Hello',
228
- createdAt: new Date().toISOString(),
229
- },
230
- author: mock.profileViewBasic({
231
- handle: 'bob.test',
232
- displayName: 'Bob',
233
- }),
234
- labels: [
235
- mock.label({
236
- val: 'custom',
237
- uri: 'at://did:web:bob.test/app.bsky.feed.post/fake',
238
- src: 'did:web:labeler.test',
239
- }),
240
- ],
241
- }),
242
- modOpts(blurs, severity),
243
- )
244
- } else if (target === 'profile') {
245
- res = moderateProfile(
246
- mock.profileViewBasic({
247
- handle: 'bob.test',
248
- displayName: 'Bob',
249
- labels: [
250
- mock.label({
251
- val: 'custom',
252
- uri: 'at://did:web:bob.test/app.bsky.actor.profile/self',
253
- src: 'did:web:labeler.test',
254
- }),
255
- ],
256
- }),
257
- modOpts(blurs, severity),
258
- )
259
- } else {
260
- res = moderateProfile(
261
- mock.profileViewBasic({
262
- handle: 'bob.test',
263
- displayName: 'Bob',
264
- labels: [
265
- mock.label({
266
- val: 'custom',
267
- uri: 'did:web:bob.test',
268
- src: 'did:web:labeler.test',
269
- }),
270
- ],
271
- }),
272
- modOpts(blurs, severity),
273
- )
274
- }
275
- expect(res.ui('profileList')).toBeModerationResult(
276
- expected.profileList || [],
277
- )
278
- expect(res.ui('profileView')).toBeModerationResult(
279
- expected.profileView || [],
280
- )
281
- expect(res.ui('avatar')).toBeModerationResult(expected.avatar || [])
282
- expect(res.ui('banner')).toBeModerationResult(expected.banner || [])
283
- expect(res.ui('displayName')).toBeModerationResult(
284
- expected.displayName || [],
285
- )
286
- expect(res.ui('contentList')).toBeModerationResult(
287
- expected.contentList || [],
288
- )
289
- expect(res.ui('contentView')).toBeModerationResult(
290
- expected.contentView || [],
291
- )
292
- expect(res.ui('contentMedia')).toBeModerationResult(
293
- expected.contentMedia || [],
294
- )
295
- },
296
- )
297
- })
298
-
299
- function modOpts(blurs: string, severity: string): ModerationOpts {
300
- return {
301
- userDid: 'did:web:alice.test',
302
- prefs: {
303
- adultContentEnabled: true,
304
- labels: {},
305
- labelers: [
306
- {
307
- did: 'did:web:labeler.test',
308
- labels: { custom: 'hide' },
309
- },
310
- ],
311
- mutedWords: [],
312
- hiddenPosts: [],
313
- },
314
- labelDefs: {
315
- 'did:web:labeler.test': [makeCustomLabel(blurs, severity)],
316
- },
317
- }
318
- }
319
-
320
- function makeCustomLabel(
321
- blurs: string,
322
- severity: string,
323
- ): InterpretedLabelValueDefinition {
324
- return interpretLabelValueDefinition(
325
- {
326
- identifier: 'custom',
327
- blurs,
328
- severity,
329
- defaultSetting: 'warn',
330
- locales: [],
331
- },
332
- 'did:web:labeler.test',
333
- )
334
- }