@atproto/api 0.5.4 → 0.5.5
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/README.md +11 -3
- package/dist/agent.d.ts +44 -25
- package/dist/bsky-agent.d.ts +62 -43
- package/dist/client/lexicons.d.ts +48 -0
- package/dist/client/types/app/bsky/actor/defs.d.ts +74 -65
- package/dist/client/types/app/bsky/actor/profile.d.ts +5 -0
- package/dist/client/types/app/bsky/embed/external.d.ts +23 -23
- package/dist/client/types/app/bsky/embed/images.d.ts +20 -20
- package/dist/client/types/app/bsky/embed/record.d.ts +53 -41
- package/dist/client/types/app/bsky/embed/recordWithMedia.d.ts +26 -20
- package/dist/client/types/app/bsky/feed/defs.d.ts +141 -107
- package/dist/client/types/app/bsky/feed/generator.d.ts +5 -0
- package/dist/client/types/app/bsky/feed/getAuthorFeed.d.ts +1 -0
- package/dist/client/types/app/bsky/feed/like.d.ts +7 -7
- package/dist/client/types/app/bsky/feed/post.d.ts +5 -0
- package/dist/client/types/app/bsky/feed/repost.d.ts +7 -7
- package/dist/client/types/app/bsky/graph/block.d.ts +6 -6
- package/dist/client/types/app/bsky/graph/defs.d.ts +36 -36
- package/dist/client/types/app/bsky/graph/follow.d.ts +6 -6
- package/dist/client/types/app/bsky/graph/list.d.ts +5 -0
- package/dist/client/types/app/bsky/graph/listitem.d.ts +7 -7
- package/dist/client/types/app/bsky/richtext/facet.d.ts +26 -22
- package/dist/client/types/com/atproto/label/defs.d.ts +12 -0
- package/dist/client/types/com/atproto/label/subscribeLabels.d.ts +12 -12
- package/dist/client/types/com/atproto/moderation/defs.d.ts +16 -7
- package/dist/client/types/com/atproto/repo/strongRef.d.ts +6 -6
- package/dist/client/types/com/atproto/server/defs.d.ts +16 -16
- package/dist/client/types/com/atproto/sync/subscribeRepos.d.ts +46 -46
- package/dist/client/util.d.ts +5 -2
- package/dist/index.js +76 -8
- package/dist/index.js.map +2 -2
- package/dist/moderation/types.d.ts +7 -3
- package/dist/rich-text/detection.d.ts +4 -4
- package/dist/rich-text/rich-text.d.ts +31 -31
- package/dist/rich-text/sanitization.d.ts +7 -4
- package/dist/rich-text/unicode.d.ts +9 -9
- package/dist/types.d.ts +34 -22
- package/docs/moderation.md +14 -5
- package/package.json +1 -1
- package/src/client/lexicons.ts +55 -0
- package/src/client/types/app/bsky/actor/profile.ts +4 -0
- package/src/client/types/app/bsky/feed/generator.ts +4 -0
- package/src/client/types/app/bsky/feed/getAuthorFeed.ts +5 -0
- package/src/client/types/app/bsky/feed/post.ts +4 -0
- package/src/client/types/app/bsky/graph/list.ts +4 -0
- package/src/client/types/com/atproto/label/defs.ts +37 -0
- package/src/moderation/accumulator.ts +17 -12
- package/src/moderation/types.ts +5 -3
- package/tests/moderation.test.ts +334 -0
- package/tests/util/moderation-behavior.ts +3 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/client/types/app/bsky/actor/createScene.d.ts +0 -32
- package/dist/client/types/app/bsky/actor/ref.d.ts +0 -28
- package/dist/client/types/app/bsky/actor/search.d.ts +0 -22
- package/dist/client/types/app/bsky/actor/searchTypeahead.d.ts +0 -20
- package/dist/client/types/app/bsky/actor/updateProfile.d.ts +0 -40
- package/dist/client/types/app/bsky/feed/feedViewPost.d.ts +0 -28
- package/dist/client/types/app/bsky/feed/getSavedFeeds.d.ts +0 -21
- package/dist/client/types/app/bsky/feed/getVotes.d.ts +0 -36
- package/dist/client/types/app/bsky/feed/saveFeed.d.ts +0 -17
- package/dist/client/types/app/bsky/feed/setVote.d.ts +0 -25
- package/dist/client/types/app/bsky/feed/trend.d.ts +0 -9
- package/dist/client/types/app/bsky/feed/unsaveFeed.d.ts +0 -17
- package/dist/client/types/app/bsky/feed/vote.d.ts +0 -10
- package/dist/client/types/app/bsky/graph/assertCreator.d.ts +0 -1
- package/dist/client/types/app/bsky/graph/assertMember.d.ts +0 -1
- package/dist/client/types/app/bsky/graph/assertion.d.ts +0 -10
- package/dist/client/types/app/bsky/graph/confirmation.d.ts +0 -11
- package/dist/client/types/app/bsky/graph/getAssertions.d.ts +0 -48
- package/dist/client/types/app/bsky/graph/getListBlocks.d.ts +0 -21
- package/dist/client/types/app/bsky/graph/getMembers.d.ts +0 -36
- package/dist/client/types/app/bsky/graph/getMemberships.d.ts +0 -36
- package/dist/client/types/app/bsky/graph/listblock.d.ts +0 -8
- package/dist/client/types/app/bsky/graph/mute.d.ts +0 -17
- package/dist/client/types/app/bsky/graph/subscribeMuteList.d.ts +0 -17
- package/dist/client/types/app/bsky/graph/unmute.d.ts +0 -17
- package/dist/client/types/app/bsky/graph/unsubscribeMuteList.d.ts +0 -17
- package/dist/client/types/app/bsky/notification/getCount.d.ts +0 -17
- package/dist/client/types/app/bsky/notification/list.d.ts +0 -35
- package/dist/client/types/app/bsky/system/actorScene.d.ts +0 -1
- package/dist/client/types/app/bsky/system/actorUser.d.ts +0 -1
- package/dist/client/types/app/bsky/system/declRef.d.ts +0 -8
- package/dist/client/types/app/bsky/system/declaration.d.ts +0 -7
- package/dist/client/types/com/atproto/account/create.d.ts +0 -41
- package/dist/client/types/com/atproto/account/createInviteCode.d.ts +0 -22
- package/dist/client/types/com/atproto/account/delete.d.ts +0 -25
- package/dist/client/types/com/atproto/account/get.d.ts +0 -12
- package/dist/client/types/com/atproto/account/requestDelete.d.ts +0 -13
- package/dist/client/types/com/atproto/account/requestPasswordReset.d.ts +0 -17
- package/dist/client/types/com/atproto/account/resetPassword.d.ts +0 -24
- package/dist/client/types/com/atproto/admin/blob.d.ts +0 -37
- package/dist/client/types/com/atproto/admin/moderationAction.d.ts +0 -60
- package/dist/client/types/com/atproto/admin/moderationReport.d.ts +0 -37
- package/dist/client/types/com/atproto/admin/record.d.ts +0 -43
- package/dist/client/types/com/atproto/admin/repo.d.ts +0 -45
- package/dist/client/types/com/atproto/blob/upload.d.ts +0 -19
- package/dist/client/types/com/atproto/handle/resolve.d.ts +0 -18
- package/dist/client/types/com/atproto/handle/update.d.ts +0 -17
- package/dist/client/types/com/atproto/repo/batchWrite.d.ts +0 -46
- package/dist/client/types/com/atproto/repo/describe.d.ts +0 -22
- package/dist/client/types/com/atproto/repo/recordRef.d.ts +0 -8
- package/dist/client/types/com/atproto/repo/repoRef.d.ts +0 -7
- package/dist/client/types/com/atproto/report/create.d.ts +0 -39
- package/dist/client/types/com/atproto/report/reasonType.d.ts +0 -3
- package/dist/client/types/com/atproto/report/subject.d.ts +0 -23
- package/dist/client/types/com/atproto/server/getAccountsConfig.d.ts +0 -27
- package/dist/client/types/com/atproto/session/create.d.ts +0 -29
- package/dist/client/types/com/atproto/session/delete.d.ts +0 -13
- package/dist/client/types/com/atproto/session/get.d.ts +0 -18
- package/dist/client/types/com/atproto/session/refresh.d.ts +0 -24
- package/dist/client/types/com/atproto/sync/getRoot.d.ts +0 -18
- package/dist/client/types/com/atproto/sync/subscribeAllRepos.d.ts +0 -9
- package/dist/client/types/com/atproto/sync/updateRepo.d.ts +0 -15
- package/dist/helpers/bsky.d.ts +0 -20
- package/dist/mixins/bsky.d.ts +0 -23
- package/dist/rich-text/sanitize.d.ts +0 -4
- package/dist/session.d.ts +0 -42
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { moderateProfile, moderatePost } from '../src'
|
|
2
|
+
import { mock } from './util'
|
|
3
|
+
import './util/moderation-behavior'
|
|
4
|
+
|
|
5
|
+
describe('Moderation', () => {
|
|
6
|
+
it('Applies self-labels on profiles according to the global preferences', () => {
|
|
7
|
+
// porn (hide)
|
|
8
|
+
const res1 = moderateProfile(
|
|
9
|
+
mock.profileViewBasic({
|
|
10
|
+
handle: 'bob.test',
|
|
11
|
+
displayName: 'Bob',
|
|
12
|
+
labels: [
|
|
13
|
+
{
|
|
14
|
+
src: 'did:web:bob.test',
|
|
15
|
+
uri: 'at://did:web:bob.test/app.bsky.actor.profile/self',
|
|
16
|
+
val: 'porn',
|
|
17
|
+
cts: new Date().toISOString(),
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
}),
|
|
21
|
+
{
|
|
22
|
+
userDid: 'did:web:alice.test',
|
|
23
|
+
adultContentEnabled: true,
|
|
24
|
+
labels: {
|
|
25
|
+
porn: 'hide',
|
|
26
|
+
},
|
|
27
|
+
labelers: [],
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
expect(res1.account).toBeModerationResult(
|
|
31
|
+
{},
|
|
32
|
+
'post content',
|
|
33
|
+
JSON.stringify(res1, null, 2),
|
|
34
|
+
)
|
|
35
|
+
expect(res1.profile).toBeModerationResult(
|
|
36
|
+
{},
|
|
37
|
+
'post content',
|
|
38
|
+
JSON.stringify(res1, null, 2),
|
|
39
|
+
)
|
|
40
|
+
expect(res1.avatar).toBeModerationResult(
|
|
41
|
+
{ blur: true },
|
|
42
|
+
'post avatar',
|
|
43
|
+
JSON.stringify(res1, null, 2),
|
|
44
|
+
true,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
// porn (ignore)
|
|
48
|
+
const res2 = moderateProfile(
|
|
49
|
+
mock.profileViewBasic({
|
|
50
|
+
handle: 'bob.test',
|
|
51
|
+
displayName: 'Bob',
|
|
52
|
+
labels: [
|
|
53
|
+
{
|
|
54
|
+
src: 'did:web:bob.test',
|
|
55
|
+
uri: 'at://did:web:bob.test/app.bsky.actor.profile/self',
|
|
56
|
+
val: 'porn',
|
|
57
|
+
cts: new Date().toISOString(),
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
}),
|
|
61
|
+
{
|
|
62
|
+
userDid: 'did:web:alice.test',
|
|
63
|
+
adultContentEnabled: true,
|
|
64
|
+
labels: {
|
|
65
|
+
porn: 'ignore',
|
|
66
|
+
},
|
|
67
|
+
labelers: [],
|
|
68
|
+
},
|
|
69
|
+
)
|
|
70
|
+
expect(res2.account).toBeModerationResult(
|
|
71
|
+
{},
|
|
72
|
+
'post content',
|
|
73
|
+
JSON.stringify(res2, null, 2),
|
|
74
|
+
)
|
|
75
|
+
expect(res2.profile).toBeModerationResult(
|
|
76
|
+
{},
|
|
77
|
+
'post content',
|
|
78
|
+
JSON.stringify(res2, null, 2),
|
|
79
|
+
)
|
|
80
|
+
expect(res2.avatar).toBeModerationResult(
|
|
81
|
+
{},
|
|
82
|
+
'post avatar',
|
|
83
|
+
JSON.stringify(res2, null, 2),
|
|
84
|
+
true,
|
|
85
|
+
)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('Applies self-labels on posts according to the global preferences', () => {
|
|
89
|
+
// porn (hide)
|
|
90
|
+
const res1 = moderatePost(
|
|
91
|
+
mock.postView({
|
|
92
|
+
record: {
|
|
93
|
+
text: 'Hello',
|
|
94
|
+
createdAt: new Date().toISOString(),
|
|
95
|
+
},
|
|
96
|
+
author: mock.profileViewBasic({
|
|
97
|
+
handle: 'bob.test',
|
|
98
|
+
displayName: 'Bob',
|
|
99
|
+
}),
|
|
100
|
+
labels: [
|
|
101
|
+
{
|
|
102
|
+
src: 'did:web:bob.test',
|
|
103
|
+
uri: 'at://did:web:bob.test/app.bsky.actor.profile/self',
|
|
104
|
+
val: 'porn',
|
|
105
|
+
cts: new Date().toISOString(),
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
}),
|
|
109
|
+
{
|
|
110
|
+
userDid: 'did:web:alice.test',
|
|
111
|
+
adultContentEnabled: true,
|
|
112
|
+
labels: {
|
|
113
|
+
porn: 'hide',
|
|
114
|
+
},
|
|
115
|
+
labelers: [],
|
|
116
|
+
},
|
|
117
|
+
)
|
|
118
|
+
expect(res1.content).toBeModerationResult(
|
|
119
|
+
{ cause: 'label:porn', filter: true },
|
|
120
|
+
'post content',
|
|
121
|
+
JSON.stringify(res1, null, 2),
|
|
122
|
+
)
|
|
123
|
+
expect(res1.embed).toBeModerationResult(
|
|
124
|
+
{ cause: 'label:porn', blur: true },
|
|
125
|
+
'post content',
|
|
126
|
+
JSON.stringify(res1, null, 2),
|
|
127
|
+
)
|
|
128
|
+
expect(res1.avatar).toBeModerationResult(
|
|
129
|
+
{},
|
|
130
|
+
'post avatar',
|
|
131
|
+
JSON.stringify(res1, null, 2),
|
|
132
|
+
true,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
// porn (ignore)
|
|
136
|
+
const res2 = moderatePost(
|
|
137
|
+
mock.postView({
|
|
138
|
+
record: {
|
|
139
|
+
text: 'Hello',
|
|
140
|
+
createdAt: new Date().toISOString(),
|
|
141
|
+
},
|
|
142
|
+
author: mock.profileViewBasic({
|
|
143
|
+
handle: 'bob.test',
|
|
144
|
+
displayName: 'Bob',
|
|
145
|
+
}),
|
|
146
|
+
labels: [
|
|
147
|
+
{
|
|
148
|
+
src: 'did:web:bob.test',
|
|
149
|
+
uri: 'at://did:web:bob.test/app.bsky.actor.profile/self',
|
|
150
|
+
val: 'porn',
|
|
151
|
+
cts: new Date().toISOString(),
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
}),
|
|
155
|
+
{
|
|
156
|
+
userDid: 'did:web:alice.test',
|
|
157
|
+
adultContentEnabled: true,
|
|
158
|
+
labels: {
|
|
159
|
+
porn: 'ignore',
|
|
160
|
+
},
|
|
161
|
+
labelers: [],
|
|
162
|
+
},
|
|
163
|
+
)
|
|
164
|
+
expect(res2.content).toBeModerationResult(
|
|
165
|
+
{},
|
|
166
|
+
'post content',
|
|
167
|
+
JSON.stringify(res2, null, 2),
|
|
168
|
+
)
|
|
169
|
+
expect(res2.embed).toBeModerationResult(
|
|
170
|
+
{},
|
|
171
|
+
'post content',
|
|
172
|
+
JSON.stringify(res2, null, 2),
|
|
173
|
+
)
|
|
174
|
+
expect(res2.avatar).toBeModerationResult(
|
|
175
|
+
{},
|
|
176
|
+
'post avatar',
|
|
177
|
+
JSON.stringify(res2, null, 2),
|
|
178
|
+
true,
|
|
179
|
+
)
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('Applies labeler labels according to the per-labeler then global preferences', () => {
|
|
183
|
+
// porn (ignore for labeler, hide for global)
|
|
184
|
+
const res1 = moderateProfile(
|
|
185
|
+
mock.profileViewBasic({
|
|
186
|
+
handle: 'bob.test',
|
|
187
|
+
displayName: 'Bob',
|
|
188
|
+
labels: [
|
|
189
|
+
{
|
|
190
|
+
src: 'did:web:labeler.test',
|
|
191
|
+
uri: 'at://did:web:bob.test/app.bsky.actor.profile/self',
|
|
192
|
+
val: 'porn',
|
|
193
|
+
cts: new Date().toISOString(),
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
}),
|
|
197
|
+
{
|
|
198
|
+
userDid: 'did:web:alice.test',
|
|
199
|
+
adultContentEnabled: true,
|
|
200
|
+
labels: {
|
|
201
|
+
porn: 'hide',
|
|
202
|
+
},
|
|
203
|
+
labelers: [
|
|
204
|
+
{
|
|
205
|
+
labeler: {
|
|
206
|
+
did: 'did:web:labeler.test',
|
|
207
|
+
displayName: 'Labeler',
|
|
208
|
+
},
|
|
209
|
+
labels: {
|
|
210
|
+
porn: 'ignore',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
)
|
|
216
|
+
expect(res1.avatar).toBeModerationResult(
|
|
217
|
+
{},
|
|
218
|
+
'post avatar',
|
|
219
|
+
JSON.stringify(res1, null, 2),
|
|
220
|
+
true,
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
// porn (hide for labeler, ignore for global)
|
|
224
|
+
const res2 = moderateProfile(
|
|
225
|
+
mock.profileViewBasic({
|
|
226
|
+
handle: 'bob.test',
|
|
227
|
+
displayName: 'Bob',
|
|
228
|
+
labels: [
|
|
229
|
+
{
|
|
230
|
+
src: 'did:web:labeler.test',
|
|
231
|
+
uri: 'at://did:web:bob.test/app.bsky.actor.profile/self',
|
|
232
|
+
val: 'porn',
|
|
233
|
+
cts: new Date().toISOString(),
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
}),
|
|
237
|
+
{
|
|
238
|
+
userDid: 'did:web:alice.test',
|
|
239
|
+
adultContentEnabled: true,
|
|
240
|
+
labels: {
|
|
241
|
+
porn: 'ignore',
|
|
242
|
+
},
|
|
243
|
+
labelers: [
|
|
244
|
+
{
|
|
245
|
+
labeler: {
|
|
246
|
+
did: 'did:web:labeler.test',
|
|
247
|
+
displayName: 'Labeler',
|
|
248
|
+
},
|
|
249
|
+
labels: {
|
|
250
|
+
porn: 'hide',
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
)
|
|
256
|
+
expect(res2.avatar).toBeModerationResult(
|
|
257
|
+
{ blur: true },
|
|
258
|
+
'post avatar',
|
|
259
|
+
JSON.stringify(res2, null, 2),
|
|
260
|
+
true,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
// porn (unspecified for labeler, hide for global)
|
|
264
|
+
const res3 = moderateProfile(
|
|
265
|
+
mock.profileViewBasic({
|
|
266
|
+
handle: 'bob.test',
|
|
267
|
+
displayName: 'Bob',
|
|
268
|
+
labels: [
|
|
269
|
+
{
|
|
270
|
+
src: 'did:web:labeler.test',
|
|
271
|
+
uri: 'at://did:web:bob.test/app.bsky.actor.profile/self',
|
|
272
|
+
val: 'porn',
|
|
273
|
+
cts: new Date().toISOString(),
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
}),
|
|
277
|
+
{
|
|
278
|
+
userDid: 'did:web:alice.test',
|
|
279
|
+
adultContentEnabled: true,
|
|
280
|
+
labels: {
|
|
281
|
+
porn: 'hide',
|
|
282
|
+
},
|
|
283
|
+
labelers: [
|
|
284
|
+
{
|
|
285
|
+
labeler: {
|
|
286
|
+
did: 'did:web:labeler.test',
|
|
287
|
+
displayName: 'Labeler',
|
|
288
|
+
},
|
|
289
|
+
labels: {},
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
)
|
|
294
|
+
expect(res3.avatar).toBeModerationResult(
|
|
295
|
+
{ blur: true },
|
|
296
|
+
'post avatar',
|
|
297
|
+
JSON.stringify(res3, null, 2),
|
|
298
|
+
true,
|
|
299
|
+
)
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
/*
|
|
303
|
+
TODO enable when 3P labeler support is addded
|
|
304
|
+
it('Ignores labels from unknown labelers', () => {
|
|
305
|
+
const res1 = moderateProfile(
|
|
306
|
+
mock.profileViewBasic({
|
|
307
|
+
handle: 'bob.test',
|
|
308
|
+
displayName: 'Bob',
|
|
309
|
+
labels: [
|
|
310
|
+
{
|
|
311
|
+
src: 'did:web:rando.test',
|
|
312
|
+
uri: 'at://did:web:bob.test/app.bsky.actor.profile/self',
|
|
313
|
+
val: 'porn',
|
|
314
|
+
cts: new Date().toISOString(),
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
}),
|
|
318
|
+
{
|
|
319
|
+
userDid: 'did:web:alice.test',
|
|
320
|
+
adultContentEnabled: true,
|
|
321
|
+
labels: {
|
|
322
|
+
porn: 'hide',
|
|
323
|
+
},
|
|
324
|
+
labelers: [],
|
|
325
|
+
},
|
|
326
|
+
)
|
|
327
|
+
expect(res1.avatar).toBeModerationResult(
|
|
328
|
+
{},
|
|
329
|
+
'post avatar',
|
|
330
|
+
JSON.stringify(res1, null, 2),
|
|
331
|
+
true,
|
|
332
|
+
)
|
|
333
|
+
})*/
|
|
334
|
+
})
|
|
@@ -166,13 +166,14 @@ export class ModerationBehaviorSuiteRunner {
|
|
|
166
166
|
adultContentEnabled: Boolean(
|
|
167
167
|
this.suite.configurations[scenario.cfg].adultContentEnabled,
|
|
168
168
|
),
|
|
169
|
-
|
|
169
|
+
labels: this.suite.configurations[scenario.cfg].settings,
|
|
170
|
+
labelers: [
|
|
170
171
|
{
|
|
171
172
|
labeler: {
|
|
172
173
|
did: 'did:plc:fake-labeler',
|
|
173
174
|
displayName: 'Fake Labeler',
|
|
174
175
|
},
|
|
175
|
-
|
|
176
|
+
labels: this.suite.configurations[scenario.cfg].settings,
|
|
176
177
|
},
|
|
177
178
|
],
|
|
178
179
|
}
|