@atproto/api 0.6.24-next.1 → 0.7.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 +17 -0
- package/LICENSE.txt +7 -0
- package/definitions/labels.json +6 -0
- package/definitions/locale/en/labels.json +14 -0
- package/definitions/moderation-behaviors.d.ts +1 -0
- package/definitions/post-moderation-behaviors.json +118 -0
- package/definitions/profile-moderation-behaviors.json +48 -0
- package/dist/client/index.d.ts +12 -0
- package/dist/client/lexicons.d.ts +147 -12
- package/dist/client/types/app/bsky/feed/defs.d.ts +1 -7
- package/dist/client/types/app/bsky/graph/defs.d.ts +1 -0
- package/dist/client/types/com/atproto/admin/defs.d.ts +2 -0
- package/dist/client/types/com/atproto/admin/deleteAccount.d.ts +17 -0
- package/dist/client/types/com/atproto/temp/importRepo.d.ts +16 -0
- package/dist/client/types/com/atproto/temp/pushBlob.d.ts +15 -0
- package/dist/client/types/com/atproto/temp/transferAccount.d.ts +48 -0
- package/dist/index.js +656 -353
- package/dist/index.js.map +3 -3
- package/dist/moderation/types.d.ts +1 -1
- package/docs/labels.md +16 -0
- package/docs/moderation-behaviors/posts.md +159 -92
- package/docs/moderation-behaviors/profiles.md +68 -0
- package/package.json +17 -20
- package/scripts/docs/labels.mjs +27 -27
- package/scripts/docs/post-moderation-behaviors.mjs +43 -48
- package/src/client/index.ts +52 -0
- package/src/client/lexicons.ts +170 -13
- package/src/client/types/app/bsky/feed/defs.ts +1 -18
- package/src/client/types/app/bsky/graph/defs.ts +1 -0
- package/src/client/types/com/atproto/admin/defs.ts +2 -0
- package/src/client/types/com/atproto/admin/deleteAccount.ts +32 -0
- package/src/client/types/com/atproto/temp/importRepo.ts +33 -0
- package/src/client/types/com/atproto/temp/pushBlob.ts +32 -0
- package/src/client/types/com/atproto/temp/transferAccount.ts +92 -0
- package/src/moderation/accumulator.ts +5 -0
- package/src/moderation/const/label-groups.ts +6 -1
- package/src/moderation/const/labels.ts +31 -0
- package/src/moderation/types.ts +1 -1
- package/tests/util/moderation-behavior.ts +4 -1
|
@@ -48,6 +48,7 @@ export function validatePostView(v: unknown): ValidationResult {
|
|
|
48
48
|
export interface ViewerState {
|
|
49
49
|
repost?: string
|
|
50
50
|
like?: string
|
|
51
|
+
replyDisabled?: boolean
|
|
51
52
|
[k: string]: unknown
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -137,7 +138,6 @@ export interface ThreadViewPost {
|
|
|
137
138
|
| BlockedPost
|
|
138
139
|
| { $type: string; [k: string]: unknown }
|
|
139
140
|
)[]
|
|
140
|
-
viewer?: ViewerThreadState
|
|
141
141
|
[k: string]: unknown
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -208,23 +208,6 @@ export function validateBlockedAuthor(v: unknown): ValidationResult {
|
|
|
208
208
|
return lexicons.validate('app.bsky.feed.defs#blockedAuthor', v)
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
export interface ViewerThreadState {
|
|
212
|
-
canReply?: boolean
|
|
213
|
-
[k: string]: unknown
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function isViewerThreadState(v: unknown): v is ViewerThreadState {
|
|
217
|
-
return (
|
|
218
|
-
isObj(v) &&
|
|
219
|
-
hasProp(v, '$type') &&
|
|
220
|
-
v.$type === 'app.bsky.feed.defs#viewerThreadState'
|
|
221
|
-
)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export function validateViewerThreadState(v: unknown): ValidationResult {
|
|
225
|
-
return lexicons.validate('app.bsky.feed.defs#viewerThreadState', v)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
211
|
export interface GeneratorView {
|
|
229
212
|
uri: string
|
|
230
213
|
cid: string
|
|
@@ -499,6 +499,7 @@ export const REVIEWCLOSED = 'com.atproto.admin.defs#reviewClosed'
|
|
|
499
499
|
|
|
500
500
|
/** Take down a subject permanently or temporarily */
|
|
501
501
|
export interface ModEventTakedown {
|
|
502
|
+
comment?: string
|
|
502
503
|
/** Indicates how long the takedown should be in effect before automatically expiring. */
|
|
503
504
|
durationInHours?: number
|
|
504
505
|
[k: string]: unknown
|
|
@@ -578,6 +579,7 @@ export function validateModEventReport(v: unknown): ValidationResult {
|
|
|
578
579
|
|
|
579
580
|
/** Apply/Negate labels on a subject */
|
|
580
581
|
export interface ModEventLabel {
|
|
582
|
+
comment?: string
|
|
581
583
|
createLabelVals: string[]
|
|
582
584
|
negateLabelVals: string[]
|
|
583
585
|
[k: string]: unknown
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Headers, XRPCError } from '@atproto/xrpc'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { isObj, hasProp } from '../../../../util'
|
|
7
|
+
import { lexicons } from '../../../../lexicons'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
|
|
10
|
+
export interface QueryParams {}
|
|
11
|
+
|
|
12
|
+
export interface InputSchema {
|
|
13
|
+
did: string
|
|
14
|
+
[k: string]: unknown
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface CallOptions {
|
|
18
|
+
headers?: Headers
|
|
19
|
+
qp?: QueryParams
|
|
20
|
+
encoding: 'application/json'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Response {
|
|
24
|
+
success: boolean
|
|
25
|
+
headers: Headers
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function toKnownErr(e: any) {
|
|
29
|
+
if (e instanceof XRPCError) {
|
|
30
|
+
}
|
|
31
|
+
return e
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Headers, XRPCError } from '@atproto/xrpc'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { isObj, hasProp } from '../../../../util'
|
|
7
|
+
import { lexicons } from '../../../../lexicons'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
|
|
10
|
+
export interface QueryParams {
|
|
11
|
+
/** The DID of the repo. */
|
|
12
|
+
did: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type InputSchema = string | Uint8Array
|
|
16
|
+
|
|
17
|
+
export interface CallOptions {
|
|
18
|
+
headers?: Headers
|
|
19
|
+
qp?: QueryParams
|
|
20
|
+
encoding: 'application/vnd.ipld.car'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Response {
|
|
24
|
+
success: boolean
|
|
25
|
+
headers: Headers
|
|
26
|
+
data: Uint8Array
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function toKnownErr(e: any) {
|
|
30
|
+
if (e instanceof XRPCError) {
|
|
31
|
+
}
|
|
32
|
+
return e
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Headers, XRPCError } from '@atproto/xrpc'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { isObj, hasProp } from '../../../../util'
|
|
7
|
+
import { lexicons } from '../../../../lexicons'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
|
|
10
|
+
export interface QueryParams {
|
|
11
|
+
/** The DID of the repo. */
|
|
12
|
+
did: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type InputSchema = string | Uint8Array
|
|
16
|
+
|
|
17
|
+
export interface CallOptions {
|
|
18
|
+
headers?: Headers
|
|
19
|
+
qp?: QueryParams
|
|
20
|
+
encoding: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Response {
|
|
24
|
+
success: boolean
|
|
25
|
+
headers: Headers
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function toKnownErr(e: any) {
|
|
29
|
+
if (e instanceof XRPCError) {
|
|
30
|
+
}
|
|
31
|
+
return e
|
|
32
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Headers, XRPCError } from '@atproto/xrpc'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { isObj, hasProp } from '../../../../util'
|
|
7
|
+
import { lexicons } from '../../../../lexicons'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
|
|
10
|
+
export interface QueryParams {}
|
|
11
|
+
|
|
12
|
+
export interface InputSchema {
|
|
13
|
+
handle: string
|
|
14
|
+
did: string
|
|
15
|
+
plcOp: {}
|
|
16
|
+
[k: string]: unknown
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface OutputSchema {
|
|
20
|
+
accessJwt: string
|
|
21
|
+
refreshJwt: string
|
|
22
|
+
handle: string
|
|
23
|
+
did: string
|
|
24
|
+
[k: string]: unknown
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface CallOptions {
|
|
28
|
+
headers?: Headers
|
|
29
|
+
qp?: QueryParams
|
|
30
|
+
encoding: 'application/json'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Response {
|
|
34
|
+
success: boolean
|
|
35
|
+
headers: Headers
|
|
36
|
+
data: OutputSchema
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class InvalidHandleError extends XRPCError {
|
|
40
|
+
constructor(src: XRPCError) {
|
|
41
|
+
super(src.status, src.error, src.message, src.headers)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class InvalidPasswordError extends XRPCError {
|
|
46
|
+
constructor(src: XRPCError) {
|
|
47
|
+
super(src.status, src.error, src.message, src.headers)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class InvalidInviteCodeError extends XRPCError {
|
|
52
|
+
constructor(src: XRPCError) {
|
|
53
|
+
super(src.status, src.error, src.message, src.headers)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export class HandleNotAvailableError extends XRPCError {
|
|
58
|
+
constructor(src: XRPCError) {
|
|
59
|
+
super(src.status, src.error, src.message, src.headers)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class UnsupportedDomainError extends XRPCError {
|
|
64
|
+
constructor(src: XRPCError) {
|
|
65
|
+
super(src.status, src.error, src.message, src.headers)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class UnresolvableDidError extends XRPCError {
|
|
70
|
+
constructor(src: XRPCError) {
|
|
71
|
+
super(src.status, src.error, src.message, src.headers)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export class IncompatibleDidDocError extends XRPCError {
|
|
76
|
+
constructor(src: XRPCError) {
|
|
77
|
+
super(src.status, src.error, src.message, src.headers)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function toKnownErr(e: any) {
|
|
82
|
+
if (e instanceof XRPCError) {
|
|
83
|
+
if (e.error === 'InvalidHandle') return new InvalidHandleError(e)
|
|
84
|
+
if (e.error === 'InvalidPassword') return new InvalidPasswordError(e)
|
|
85
|
+
if (e.error === 'InvalidInviteCode') return new InvalidInviteCodeError(e)
|
|
86
|
+
if (e.error === 'HandleNotAvailable') return new HandleNotAvailableError(e)
|
|
87
|
+
if (e.error === 'UnsupportedDomain') return new UnsupportedDomainError(e)
|
|
88
|
+
if (e.error === 'UnresolvableDid') return new UnresolvableDidError(e)
|
|
89
|
+
if (e.error === 'IncompatibleDidDoc') return new IncompatibleDidDocError(e)
|
|
90
|
+
}
|
|
91
|
+
return e
|
|
92
|
+
}
|
|
@@ -96,6 +96,11 @@ export class ModerationCauseAccumulator {
|
|
|
96
96
|
return
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
// ignore 'unauthed' labels when the user is authed
|
|
100
|
+
if (labelDef.flags.includes('unauthed') && !!opts.userDid) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
99
104
|
// establish the priority of the label
|
|
100
105
|
let priority: 1 | 2 | 5 | 7 | 8
|
|
101
106
|
if (labelDef.flags.includes('no-override')) {
|
|
@@ -6,7 +6,12 @@ export const LABEL_GROUPS: LabelGroupDefinitionMap = {
|
|
|
6
6
|
system: {
|
|
7
7
|
id: 'system',
|
|
8
8
|
configurable: false,
|
|
9
|
-
labels: [
|
|
9
|
+
labels: [
|
|
10
|
+
LABELS['!hide'],
|
|
11
|
+
LABELS['!no-promote'],
|
|
12
|
+
LABELS['!warn'],
|
|
13
|
+
LABELS['!no-unauthenticated'],
|
|
14
|
+
],
|
|
10
15
|
strings: {
|
|
11
16
|
settings: {
|
|
12
17
|
en: {
|
|
@@ -89,6 +89,37 @@ export const LABELS: LabelDefinitionMap = {
|
|
|
89
89
|
},
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
|
+
'!no-unauthenticated': {
|
|
93
|
+
id: '!no-unauthenticated',
|
|
94
|
+
preferences: ['hide'],
|
|
95
|
+
flags: ['no-override', 'unauthed'],
|
|
96
|
+
onwarn: 'blur',
|
|
97
|
+
groupId: 'system',
|
|
98
|
+
configurable: false,
|
|
99
|
+
strings: {
|
|
100
|
+
settings: {
|
|
101
|
+
en: {
|
|
102
|
+
name: 'Requested Hidden to Logged-out Users',
|
|
103
|
+
description:
|
|
104
|
+
'This user has requested that their content only be shown to logged-in accounts.',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
account: {
|
|
108
|
+
en: {
|
|
109
|
+
name: 'Sign-in Required',
|
|
110
|
+
description:
|
|
111
|
+
'This user has requested that their content only be shown to logged-in accounts.',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
content: {
|
|
115
|
+
en: {
|
|
116
|
+
name: 'Sign-in Required',
|
|
117
|
+
description:
|
|
118
|
+
'This user has requested that their content only be shown to logged-in accounts.',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
92
123
|
'dmca-violation': {
|
|
93
124
|
id: 'dmca-violation',
|
|
94
125
|
preferences: ['hide'],
|
package/src/moderation/types.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
export type Label = ComAtprotoLabelDefs.Label
|
|
12
12
|
|
|
13
13
|
export type LabelPreference = 'ignore' | 'warn' | 'hide'
|
|
14
|
-
export type LabelDefinitionFlag = 'no-override' | 'adult'
|
|
14
|
+
export type LabelDefinitionFlag = 'no-override' | 'adult' | 'unauthed'
|
|
15
15
|
export type LabelDefinitionOnWarnBehavior =
|
|
16
16
|
| 'blur'
|
|
17
17
|
| 'blur-media'
|
|
@@ -170,7 +170,10 @@ export class ModerationBehaviorSuiteRunner {
|
|
|
170
170
|
|
|
171
171
|
moderationOpts(scenario: ModerationBehaviorScenario): ModerationOpts {
|
|
172
172
|
return {
|
|
173
|
-
userDid:
|
|
173
|
+
userDid:
|
|
174
|
+
this.suite.configurations[scenario.cfg].authed === false
|
|
175
|
+
? ''
|
|
176
|
+
: 'did:web:self.test',
|
|
174
177
|
adultContentEnabled: Boolean(
|
|
175
178
|
this.suite.configurations[scenario.cfg].adultContentEnabled,
|
|
176
179
|
),
|