@atproto/api 0.6.24 → 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.
Files changed (32) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/definitions/labels.json +6 -0
  3. package/definitions/locale/en/labels.json +14 -0
  4. package/definitions/moderation-behaviors.d.ts +1 -0
  5. package/definitions/post-moderation-behaviors.json +118 -0
  6. package/definitions/profile-moderation-behaviors.json +48 -0
  7. package/dist/client/index.d.ts +12 -0
  8. package/dist/client/lexicons.d.ts +134 -0
  9. package/dist/client/types/com/atproto/admin/deleteAccount.d.ts +17 -0
  10. package/dist/client/types/com/atproto/temp/importRepo.d.ts +16 -0
  11. package/dist/client/types/com/atproto/temp/pushBlob.d.ts +15 -0
  12. package/dist/client/types/com/atproto/temp/transferAccount.d.ts +48 -0
  13. package/dist/index.js +635 -325
  14. package/dist/index.js.map +3 -3
  15. package/dist/moderation/types.d.ts +1 -1
  16. package/docs/labels.md +16 -0
  17. package/docs/moderation-behaviors/posts.md +159 -92
  18. package/docs/moderation-behaviors/profiles.md +68 -0
  19. package/package.json +2 -2
  20. package/scripts/docs/labels.mjs +27 -27
  21. package/scripts/docs/post-moderation-behaviors.mjs +43 -48
  22. package/src/client/index.ts +52 -0
  23. package/src/client/lexicons.ts +156 -0
  24. package/src/client/types/com/atproto/admin/deleteAccount.ts +32 -0
  25. package/src/client/types/com/atproto/temp/importRepo.ts +33 -0
  26. package/src/client/types/com/atproto/temp/pushBlob.ts +32 -0
  27. package/src/client/types/com/atproto/temp/transferAccount.ts +92 -0
  28. package/src/moderation/accumulator.ts +5 -0
  29. package/src/moderation/const/label-groups.ts +6 -1
  30. package/src/moderation/const/labels.ts +31 -0
  31. package/src/moderation/types.ts +1 -1
  32. package/tests/util/moderation-behavior.ts +4 -1
@@ -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: [LABELS['!hide'], LABELS['!no-promote'], LABELS['!warn']],
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'],
@@ -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: 'did:web:self.test',
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
  ),