@atproto/api 0.9.7 → 0.10.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 (51) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/bsky-agent.d.ts +6 -1
  3. package/dist/client/index.d.ts +30 -9
  4. package/dist/client/lexicons.d.ts +449 -110
  5. package/dist/client/types/app/bsky/actor/defs.d.ts +20 -0
  6. package/dist/client/types/com/atproto/admin/defs.d.ts +9 -0
  7. package/dist/client/types/com/atproto/admin/emitModerationEvent.d.ts +1 -1
  8. package/dist/client/types/com/atproto/admin/queryModerationEvents.d.ts +2 -0
  9. package/dist/client/types/com/atproto/admin/queryModerationStatuses.d.ts +2 -0
  10. package/dist/client/types/com/atproto/identity/getRecommendedDidCredentials.d.ts +20 -0
  11. package/dist/client/types/com/atproto/{temp/pushBlob.d.ts → identity/requestPlcOperationSignature.d.ts} +1 -3
  12. package/dist/client/types/com/atproto/identity/signPlcOperation.d.ts +26 -0
  13. package/dist/client/types/com/atproto/identity/submitPlcOperation.d.ts +17 -0
  14. package/dist/client/types/com/atproto/{temp → repo}/importRepo.d.ts +0 -2
  15. package/dist/client/types/com/atproto/repo/listMissingBlobs.d.ts +28 -0
  16. package/dist/client/types/com/atproto/server/activateAccount.d.ts +13 -0
  17. package/dist/client/types/com/atproto/server/checkAccountStatus.d.ts +25 -0
  18. package/dist/client/types/com/atproto/server/deactivateAccount.d.ts +17 -0
  19. package/dist/client/types/com/atproto/server/describeServer.d.ts +1 -0
  20. package/dist/client/types/com/atproto/server/getServiceAuth.d.ts +18 -0
  21. package/dist/client/types/com/atproto/sync/subscribeRepos.d.ts +8 -0
  22. package/dist/index.js +1068 -549
  23. package/dist/index.js.map +3 -3
  24. package/dist/types.d.ts +3 -0
  25. package/package.json +2 -2
  26. package/src/bsky-agent.ts +136 -0
  27. package/src/client/index.ts +140 -39
  28. package/src/client/lexicons.ts +491 -138
  29. package/src/client/types/app/bsky/actor/defs.ts +59 -0
  30. package/src/client/types/app/bsky/feed/post.ts +1 -1
  31. package/src/client/types/com/atproto/admin/defs.ts +24 -0
  32. package/src/client/types/com/atproto/admin/emitModerationEvent.ts +1 -0
  33. package/src/client/types/com/atproto/admin/queryModerationEvents.ts +4 -0
  34. package/src/client/types/com/atproto/admin/queryModerationStatuses.ts +2 -0
  35. package/src/client/types/com/atproto/identity/getRecommendedDidCredentials.ts +37 -0
  36. package/src/client/types/com/atproto/identity/requestPlcOperationSignature.ts +28 -0
  37. package/src/client/types/com/atproto/identity/signPlcOperation.ts +44 -0
  38. package/src/client/types/com/atproto/{temp/pushBlob.ts → identity/submitPlcOperation.ts} +6 -6
  39. package/src/client/types/com/atproto/{temp → repo}/importRepo.ts +1 -5
  40. package/src/client/types/com/atproto/repo/listMissingBlobs.ts +55 -0
  41. package/src/client/types/com/atproto/server/activateAccount.ts +28 -0
  42. package/src/client/types/com/atproto/server/checkAccountStatus.ts +41 -0
  43. package/src/client/types/com/atproto/server/deactivateAccount.ts +33 -0
  44. package/src/client/types/com/atproto/server/describeServer.ts +1 -0
  45. package/src/client/types/com/atproto/server/getServiceAuth.ts +36 -0
  46. package/src/client/types/com/atproto/sync/subscribeRepos.ts +23 -3
  47. package/src/types.ts +3 -0
  48. package/tests/agent.test.ts +1 -0
  49. package/tests/bsky-agent.test.ts +183 -0
  50. package/dist/client/types/com/atproto/temp/transferAccount.d.ts +0 -48
  51. package/src/client/types/com/atproto/temp/transferAccount.ts +0 -92
@@ -254,3 +254,62 @@ export function isInterestsPref(v: unknown): v is InterestsPref {
254
254
  export function validateInterestsPref(v: unknown): ValidationResult {
255
255
  return lexicons.validate('app.bsky.actor.defs#interestsPref', v)
256
256
  }
257
+
258
+ export type MutedWordTarget = 'content' | 'tag' | (string & {})
259
+
260
+ /** A word that the account owner has muted. */
261
+ export interface MutedWord {
262
+ /** The muted word itself. */
263
+ value: string
264
+ /** The intended targets of the muted word. */
265
+ targets: MutedWordTarget[]
266
+ [k: string]: unknown
267
+ }
268
+
269
+ export function isMutedWord(v: unknown): v is MutedWord {
270
+ return (
271
+ isObj(v) &&
272
+ hasProp(v, '$type') &&
273
+ v.$type === 'app.bsky.actor.defs#mutedWord'
274
+ )
275
+ }
276
+
277
+ export function validateMutedWord(v: unknown): ValidationResult {
278
+ return lexicons.validate('app.bsky.actor.defs#mutedWord', v)
279
+ }
280
+
281
+ export interface MutedWordsPref {
282
+ /** A list of words the account owner has muted. */
283
+ items: MutedWord[]
284
+ [k: string]: unknown
285
+ }
286
+
287
+ export function isMutedWordsPref(v: unknown): v is MutedWordsPref {
288
+ return (
289
+ isObj(v) &&
290
+ hasProp(v, '$type') &&
291
+ v.$type === 'app.bsky.actor.defs#mutedWordsPref'
292
+ )
293
+ }
294
+
295
+ export function validateMutedWordsPref(v: unknown): ValidationResult {
296
+ return lexicons.validate('app.bsky.actor.defs#mutedWordsPref', v)
297
+ }
298
+
299
+ export interface HiddenPostsPref {
300
+ /** A list of URIs of posts the account owner has hidden. */
301
+ items: string[]
302
+ [k: string]: unknown
303
+ }
304
+
305
+ export function isHiddenPostsPref(v: unknown): v is HiddenPostsPref {
306
+ return (
307
+ isObj(v) &&
308
+ hasProp(v, '$type') &&
309
+ v.$type === 'app.bsky.actor.defs#hiddenPostsPref'
310
+ )
311
+ }
312
+
313
+ export function validateHiddenPostsPref(v: unknown): ValidationResult {
314
+ return lexicons.validate('app.bsky.actor.defs#hiddenPostsPref', v)
315
+ }
@@ -32,7 +32,7 @@ export interface Record {
32
32
  labels?:
33
33
  | ComAtprotoLabelDefs.SelfLabels
34
34
  | { $type: string; [k: string]: unknown }
35
- /** Additional non-inline tags describing this post. */
35
+ /** Additional hashtags, in addition to any included in post text and facets. */
36
36
  tags?: string[]
37
37
  /** Client-declared timestamp when this post was originally created. */
38
38
  createdAt: string
@@ -156,6 +156,7 @@ export interface SubjectStatusView {
156
156
  /** True indicates that the a previously taken moderator action was appealed against, by the author of the content. False indicates last appeal was resolved by moderators. */
157
157
  appealed?: boolean
158
158
  suspendUntil?: string
159
+ tags?: string[]
159
160
  [k: string]: unknown
160
161
  }
161
162
 
@@ -720,6 +721,29 @@ export function validateModEventEmail(v: unknown): ValidationResult {
720
721
  return lexicons.validate('com.atproto.admin.defs#modEventEmail', v)
721
722
  }
722
723
 
724
+ /** Add/Remove a tag on a subject */
725
+ export interface ModEventTag {
726
+ /** Tags to be added to the subject. If already exists, won't be duplicated. */
727
+ add: string[]
728
+ /** Tags to be removed to the subject. Ignores a tag If it doesn't exist, won't be duplicated. */
729
+ remove: string[]
730
+ /** Additional comment about added/removed tags. */
731
+ comment?: string
732
+ [k: string]: unknown
733
+ }
734
+
735
+ export function isModEventTag(v: unknown): v is ModEventTag {
736
+ return (
737
+ isObj(v) &&
738
+ hasProp(v, '$type') &&
739
+ v.$type === 'com.atproto.admin.defs#modEventTag'
740
+ )
741
+ }
742
+
743
+ export function validateModEventTag(v: unknown): ValidationResult {
744
+ return lexicons.validate('com.atproto.admin.defs#modEventTag', v)
745
+ }
746
+
723
747
  export interface CommunicationTemplateView {
724
748
  id: string
725
749
  /** Name of the template. */
@@ -23,6 +23,7 @@ export interface InputSchema {
23
23
  | ComAtprotoAdminDefs.ModEventReverseTakedown
24
24
  | ComAtprotoAdminDefs.ModEventUnmute
25
25
  | ComAtprotoAdminDefs.ModEventEmail
26
+ | ComAtprotoAdminDefs.ModEventTag
26
27
  | { $type: string; [k: string]: unknown }
27
28
  subject:
28
29
  | ComAtprotoAdminDefs.RepoRef
@@ -30,6 +30,10 @@ export interface QueryParams {
30
30
  addedLabels?: string[]
31
31
  /** If specified, only events where all of these labels were removed are returned */
32
32
  removedLabels?: string[]
33
+ /** If specified, only events where all of these tags were added are returned */
34
+ addedTags?: string[]
35
+ /** If specified, only events where all of these tags were removed are returned */
36
+ removedTags?: string[]
33
37
  reportTypes?: string[]
34
38
  cursor?: string
35
39
  }
@@ -34,6 +34,8 @@ export interface QueryParams {
34
34
  /** Get subjects in unresolved appealed status */
35
35
  appealed?: boolean
36
36
  limit?: number
37
+ tags?: string[]
38
+ excludeTags?: string[]
37
39
  cursor?: string
38
40
  }
39
41
 
@@ -0,0 +1,37 @@
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 type InputSchema = undefined
13
+
14
+ export interface OutputSchema {
15
+ /** Recommended rotation keys for PLC dids. Should be undefined (or ignored) for did:webs. */
16
+ rotationKeys?: string[]
17
+ alsoKnownAs?: string[]
18
+ verificationMethods?: {}
19
+ services?: {}
20
+ [k: string]: unknown
21
+ }
22
+
23
+ export interface CallOptions {
24
+ headers?: Headers
25
+ }
26
+
27
+ export interface Response {
28
+ success: boolean
29
+ headers: Headers
30
+ data: OutputSchema
31
+ }
32
+
33
+ export function toKnownErr(e: any) {
34
+ if (e instanceof XRPCError) {
35
+ }
36
+ return e
37
+ }
@@ -0,0 +1,28 @@
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 type InputSchema = undefined
13
+
14
+ export interface CallOptions {
15
+ headers?: Headers
16
+ qp?: QueryParams
17
+ }
18
+
19
+ export interface Response {
20
+ success: boolean
21
+ headers: Headers
22
+ }
23
+
24
+ export function toKnownErr(e: any) {
25
+ if (e instanceof XRPCError) {
26
+ }
27
+ return e
28
+ }
@@ -0,0 +1,44 @@
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
+ /** A token received through com.atproto.identity.requestPlcOperationSignature */
14
+ token?: string
15
+ rotationKeys?: string[]
16
+ alsoKnownAs?: string[]
17
+ verificationMethods?: {}
18
+ services?: {}
19
+ [k: string]: unknown
20
+ }
21
+
22
+ export interface OutputSchema {
23
+ /** A signed DID PLC operation. */
24
+ operation: {}
25
+ [k: string]: unknown
26
+ }
27
+
28
+ export interface CallOptions {
29
+ headers?: Headers
30
+ qp?: QueryParams
31
+ encoding: 'application/json'
32
+ }
33
+
34
+ export interface Response {
35
+ success: boolean
36
+ headers: Headers
37
+ data: OutputSchema
38
+ }
39
+
40
+ export function toKnownErr(e: any) {
41
+ if (e instanceof XRPCError) {
42
+ }
43
+ return e
44
+ }
@@ -7,17 +7,17 @@ import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
8
  import { CID } from 'multiformats/cid'
9
9
 
10
- export interface QueryParams {
11
- /** The DID of the repo. */
12
- did: string
13
- }
10
+ export interface QueryParams {}
14
11
 
15
- export type InputSchema = string | Uint8Array
12
+ export interface InputSchema {
13
+ operation: {}
14
+ [k: string]: unknown
15
+ }
16
16
 
17
17
  export interface CallOptions {
18
18
  headers?: Headers
19
19
  qp?: QueryParams
20
- encoding: string
20
+ encoding: 'application/json'
21
21
  }
22
22
 
23
23
  export interface Response {
@@ -7,10 +7,7 @@ import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
8
  import { CID } from 'multiformats/cid'
9
9
 
10
- export interface QueryParams {
11
- /** The DID of the repo. */
12
- did: string
13
- }
10
+ export interface QueryParams {}
14
11
 
15
12
  export type InputSchema = string | Uint8Array
16
13
 
@@ -23,7 +20,6 @@ export interface CallOptions {
23
20
  export interface Response {
24
21
  success: boolean
25
22
  headers: Headers
26
- data: Uint8Array
27
23
  }
28
24
 
29
25
  export function toKnownErr(e: any) {
@@ -0,0 +1,55 @@
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
+ limit?: number
12
+ cursor?: string
13
+ }
14
+
15
+ export type InputSchema = undefined
16
+
17
+ export interface OutputSchema {
18
+ cursor?: string
19
+ blobs: RecordBlob[]
20
+ [k: string]: unknown
21
+ }
22
+
23
+ export interface CallOptions {
24
+ headers?: Headers
25
+ }
26
+
27
+ export interface Response {
28
+ success: boolean
29
+ headers: Headers
30
+ data: OutputSchema
31
+ }
32
+
33
+ export function toKnownErr(e: any) {
34
+ if (e instanceof XRPCError) {
35
+ }
36
+ return e
37
+ }
38
+
39
+ export interface RecordBlob {
40
+ cid: string
41
+ recordUri: string
42
+ [k: string]: unknown
43
+ }
44
+
45
+ export function isRecordBlob(v: unknown): v is RecordBlob {
46
+ return (
47
+ isObj(v) &&
48
+ hasProp(v, '$type') &&
49
+ v.$type === 'com.atproto.repo.listMissingBlobs#recordBlob'
50
+ )
51
+ }
52
+
53
+ export function validateRecordBlob(v: unknown): ValidationResult {
54
+ return lexicons.validate('com.atproto.repo.listMissingBlobs#recordBlob', v)
55
+ }
@@ -0,0 +1,28 @@
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 type InputSchema = undefined
13
+
14
+ export interface CallOptions {
15
+ headers?: Headers
16
+ qp?: QueryParams
17
+ }
18
+
19
+ export interface Response {
20
+ success: boolean
21
+ headers: Headers
22
+ }
23
+
24
+ export function toKnownErr(e: any) {
25
+ if (e instanceof XRPCError) {
26
+ }
27
+ return e
28
+ }
@@ -0,0 +1,41 @@
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 type InputSchema = undefined
13
+
14
+ export interface OutputSchema {
15
+ activated: boolean
16
+ validDid: boolean
17
+ repoCommit: string
18
+ repoRev: string
19
+ repoBlocks: number
20
+ indexedRecords: number
21
+ privateStateValues: number
22
+ expectedBlobs: number
23
+ importedBlobs: number
24
+ [k: string]: unknown
25
+ }
26
+
27
+ export interface CallOptions {
28
+ headers?: Headers
29
+ }
30
+
31
+ export interface Response {
32
+ success: boolean
33
+ headers: Headers
34
+ data: OutputSchema
35
+ }
36
+
37
+ export function toKnownErr(e: any) {
38
+ if (e instanceof XRPCError) {
39
+ }
40
+ return e
41
+ }
@@ -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
+
12
+ export interface InputSchema {
13
+ /** A recommendation to server as to how long they should hold onto the deactivated account before deleting. */
14
+ deleteAfter?: string
15
+ [k: string]: unknown
16
+ }
17
+
18
+ export interface CallOptions {
19
+ headers?: Headers
20
+ qp?: QueryParams
21
+ encoding: 'application/json'
22
+ }
23
+
24
+ export interface Response {
25
+ success: boolean
26
+ headers: Headers
27
+ }
28
+
29
+ export function toKnownErr(e: any) {
30
+ if (e instanceof XRPCError) {
31
+ }
32
+ return e
33
+ }
@@ -19,6 +19,7 @@ export interface OutputSchema {
19
19
  /** List of domain suffixes that can be used in account handles. */
20
20
  availableUserDomains: string[]
21
21
  links?: Links
22
+ did: string
22
23
  [k: string]: unknown
23
24
  }
24
25
 
@@ -0,0 +1,36 @@
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 service that the token will be used to authenticate with */
12
+ aud: string
13
+ }
14
+
15
+ export type InputSchema = undefined
16
+
17
+ export interface OutputSchema {
18
+ token: string
19
+ [k: string]: unknown
20
+ }
21
+
22
+ export interface CallOptions {
23
+ headers?: Headers
24
+ }
25
+
26
+ export interface Response {
27
+ success: boolean
28
+ headers: Headers
29
+ data: OutputSchema
30
+ }
31
+
32
+ export function toKnownErr(e: any) {
33
+ if (e instanceof XRPCError) {
34
+ }
35
+ return e
36
+ }
@@ -46,7 +46,27 @@ export function validateCommit(v: unknown): ValidationResult {
46
46
  return lexicons.validate('com.atproto.sync.subscribeRepos#commit', v)
47
47
  }
48
48
 
49
- /** Represents an update of the account's handle, or transition to/from invalid state. */
49
+ /** Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache. */
50
+ export interface Identity {
51
+ seq: number
52
+ did: string
53
+ time: string
54
+ [k: string]: unknown
55
+ }
56
+
57
+ export function isIdentity(v: unknown): v is Identity {
58
+ return (
59
+ isObj(v) &&
60
+ hasProp(v, '$type') &&
61
+ v.$type === 'com.atproto.sync.subscribeRepos#identity'
62
+ )
63
+ }
64
+
65
+ export function validateIdentity(v: unknown): ValidationResult {
66
+ return lexicons.validate('com.atproto.sync.subscribeRepos#identity', v)
67
+ }
68
+
69
+ /** Represents an update of the account's handle, or transition to/from invalid state. NOTE: Will be deprecated in favor of #identity. */
50
70
  export interface Handle {
51
71
  seq: number
52
72
  did: string
@@ -67,7 +87,7 @@ export function validateHandle(v: unknown): ValidationResult {
67
87
  return lexicons.validate('com.atproto.sync.subscribeRepos#handle', v)
68
88
  }
69
89
 
70
- /** Represents an account moving from one PDS instance to another. NOTE: not implemented; full account migration may introduce a new message instead. */
90
+ /** Represents an account moving from one PDS instance to another. NOTE: not implemented; account migration uses #identity instead */
71
91
  export interface Migrate {
72
92
  seq: number
73
93
  did: string
@@ -88,7 +108,7 @@ export function validateMigrate(v: unknown): ValidationResult {
88
108
  return lexicons.validate('com.atproto.sync.subscribeRepos#migrate', v)
89
109
  }
90
110
 
91
- /** Indicates that an account has been deleted. */
111
+ /** Indicates that an account has been deleted. NOTE: may be deprecated in favor of #identity or a future #account event */
92
112
  export interface Tombstone {
93
113
  seq: number
94
114
  did: string
package/src/types.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { AppBskyActorNS, AppBskyActorDefs } from './client'
1
2
  import { LabelPreference } from './moderation/types'
2
3
 
3
4
  /**
@@ -119,4 +120,6 @@ export interface BskyPreferences {
119
120
  contentLabels: Record<string, BskyLabelPreference>
120
121
  birthDate: Date | undefined
121
122
  interests: BskyInterestsPreference
123
+ mutedWords: AppBskyActorDefs.MutedWord[]
124
+ hiddenPosts: string[]
122
125
  }
@@ -439,6 +439,7 @@ describe('agent', () => {
439
439
  expect(originalHandlerCallCount).toEqual(1)
440
440
 
441
441
  agent.setPersistSessionHandler(newPersistSession)
442
+ agent.session = undefined
442
443
 
443
444
  await agent.createAccount({
444
445
  handle: 'user8.test',