@atproto/api 0.0.8 → 0.1.1

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 (38) hide show
  1. package/README.md +44 -6
  2. package/dist/agent.d.ts +22 -0
  3. package/dist/client/index.d.ts +63 -61
  4. package/dist/client/lexicons.d.ts +237 -23
  5. package/dist/client/types/app/bsky/actor/getProfiles.d.ts +19 -0
  6. package/dist/client/types/app/bsky/actor/getSuggestions.d.ts +0 -7
  7. package/dist/client/types/app/bsky/actor/profile.d.ts +25 -0
  8. package/dist/client/types/com/atproto/admin/blob.d.ts +37 -0
  9. package/dist/client/types/com/atproto/admin/moderationAction.d.ts +13 -2
  10. package/dist/client/types/com/atproto/admin/record.d.ts +5 -2
  11. package/dist/client/types/com/atproto/admin/repo.d.ts +2 -2
  12. package/dist/client/types/com/atproto/admin/takeModerationAction.d.ts +5 -1
  13. package/dist/client/types/com/atproto/sync/getRepo.d.ts +2 -1
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +623 -253
  16. package/dist/index.js.map +4 -4
  17. package/dist/types.d.ts +33 -0
  18. package/package.json +1 -1
  19. package/src/agent.ts +305 -0
  20. package/src/client/index.ts +75 -63
  21. package/src/client/lexicons.ts +281 -38
  22. package/src/client/types/app/bsky/actor/getProfiles.ts +35 -0
  23. package/src/client/types/app/bsky/actor/getSuggestions.ts +0 -18
  24. package/src/client/types/app/bsky/actor/profile.ts +45 -0
  25. package/src/client/types/com/atproto/admin/blob.ts +84 -0
  26. package/src/client/types/com/atproto/admin/moderationAction.ts +29 -10
  27. package/src/client/types/com/atproto/admin/record.ts +5 -2
  28. package/src/client/types/com/atproto/admin/repo.ts +2 -2
  29. package/src/client/types/com/atproto/admin/takeModerationAction.ts +8 -0
  30. package/src/client/types/com/atproto/sync/getRepo.ts +4 -2
  31. package/src/index.ts +3 -3
  32. package/src/types.ts +71 -0
  33. package/tests/_util.ts +26 -0
  34. package/tests/agent.test.ts +391 -0
  35. package/tests/errors.test.ts +4 -8
  36. package/tsconfig.build.tsbuildinfo +1 -1
  37. package/src/session.ts +0 -194
  38. package/tests/session.test.ts +0 -239
package/dist/index.js CHANGED
@@ -84,6 +84,7 @@ __export(src_exports, {
84
84
  ActorNS: () => ActorNS,
85
85
  AdminNS: () => AdminNS,
86
86
  AppBskyActorGetProfile: () => getProfile_exports,
87
+ AppBskyActorGetProfiles: () => getProfiles_exports,
87
88
  AppBskyActorGetSuggestions: () => getSuggestions_exports,
88
89
  AppBskyActorProfile: () => profile_exports,
89
90
  AppBskyActorRef: () => ref_exports,
@@ -120,12 +121,14 @@ __export(src_exports, {
120
121
  AppBskySystemDeclaration: () => declaration_exports,
121
122
  AppNS: () => AppNS,
122
123
  AssertionRecord: () => AssertionRecord,
124
+ AtpAgent: () => AtpAgent,
125
+ AtpBaseClient: () => AtpBaseClient,
126
+ AtpServiceClient: () => AtpServiceClient,
123
127
  AtprotoNS: () => AtprotoNS,
124
128
  BlobNS: () => BlobNS,
125
129
  BskyNS: () => BskyNS,
126
130
  COM_ATPROTO_ADMIN: () => COM_ATPROTO_ADMIN,
127
131
  COM_ATPROTO_REPORT: () => COM_ATPROTO_REPORT,
128
- Client: () => Client2,
129
132
  ComAtprotoAccountCreate: () => create_exports,
130
133
  ComAtprotoAccountCreateInviteCode: () => createInviteCode_exports,
131
134
  ComAtprotoAccountDelete: () => delete_exports,
@@ -133,6 +136,7 @@ __export(src_exports, {
133
136
  ComAtprotoAccountRequestDelete: () => requestDelete_exports,
134
137
  ComAtprotoAccountRequestPasswordReset: () => requestPasswordReset_exports,
135
138
  ComAtprotoAccountResetPassword: () => resetPassword_exports,
139
+ ComAtprotoAdminBlob: () => blob_exports2,
136
140
  ComAtprotoAdminGetModerationAction: () => getModerationAction_exports,
137
141
  ComAtprotoAdminGetModerationActions: () => getModerationActions_exports,
138
142
  ComAtprotoAdminGetModerationReport: () => getModerationReport_exports,
@@ -187,17 +191,11 @@ __export(src_exports, {
187
191
  ReportNS: () => ReportNS,
188
192
  RepostRecord: () => RepostRecord,
189
193
  ServerNS: () => ServerNS,
190
- ServiceClient: () => ServiceClient2,
191
- SessionClient: () => SessionClient,
192
- SessionManager: () => SessionManager,
193
194
  SessionNS: () => SessionNS,
194
- SessionServiceClient: () => SessionServiceClient,
195
- SessionXrpcServiceClient: () => SessionXrpcServiceClient,
196
195
  SyncNS: () => SyncNS,
197
196
  SystemNS: () => SystemNS,
198
197
  VoteRecord: () => VoteRecord,
199
- default: () => client_default,
200
- sessionClient: () => session_default
198
+ default: () => AtpAgent
201
199
  });
202
200
  module.exports = __toCommonJS(src_exports);
203
201
 
@@ -4536,6 +4534,78 @@ var schemaDict = {
4536
4534
  }
4537
4535
  }
4538
4536
  },
4537
+ ComAtprotoAdminBlob: {
4538
+ lexicon: 1,
4539
+ id: "com.atproto.admin.blob",
4540
+ defs: {
4541
+ view: {
4542
+ type: "object",
4543
+ required: ["cid", "mimeType", "size", "createdAt"],
4544
+ properties: {
4545
+ cid: {
4546
+ type: "string"
4547
+ },
4548
+ mimeType: {
4549
+ type: "string"
4550
+ },
4551
+ size: {
4552
+ type: "integer"
4553
+ },
4554
+ createdAt: {
4555
+ type: "datetime"
4556
+ },
4557
+ details: {
4558
+ type: "union",
4559
+ refs: [
4560
+ "lex:com.atproto.admin.blob#imageDetails",
4561
+ "lex:com.atproto.admin.blob#videoDetails"
4562
+ ]
4563
+ },
4564
+ moderation: {
4565
+ type: "ref",
4566
+ ref: "lex:com.atproto.admin.blob#moderation"
4567
+ }
4568
+ }
4569
+ },
4570
+ imageDetails: {
4571
+ type: "object",
4572
+ required: ["width", "height"],
4573
+ properties: {
4574
+ width: {
4575
+ type: "integer"
4576
+ },
4577
+ height: {
4578
+ type: "integer"
4579
+ }
4580
+ }
4581
+ },
4582
+ videoDetails: {
4583
+ type: "object",
4584
+ required: ["width", "height", "length"],
4585
+ properties: {
4586
+ width: {
4587
+ type: "integer"
4588
+ },
4589
+ height: {
4590
+ type: "integer"
4591
+ },
4592
+ length: {
4593
+ type: "integer"
4594
+ }
4595
+ }
4596
+ },
4597
+ moderation: {
4598
+ type: "object",
4599
+ required: [],
4600
+ properties: {
4601
+ currentAction: {
4602
+ type: "ref",
4603
+ ref: "lex:com.atproto.admin.moderationAction#viewCurrent"
4604
+ }
4605
+ }
4606
+ }
4607
+ }
4608
+ },
4539
4609
  ComAtprotoAdminGetModerationAction: {
4540
4610
  lexicon: 1,
4541
4611
  id: "com.atproto.admin.getModerationAction",
@@ -4748,6 +4818,7 @@ var schemaDict = {
4748
4818
  "id",
4749
4819
  "action",
4750
4820
  "subject",
4821
+ "subjectBlobCids",
4751
4822
  "reason",
4752
4823
  "createdBy",
4753
4824
  "createdAt",
@@ -4758,12 +4829,8 @@ var schemaDict = {
4758
4829
  type: "integer"
4759
4830
  },
4760
4831
  action: {
4761
- type: "string",
4762
- knownValues: [
4763
- "com.atproto.admin.moderationAction#takedown",
4764
- "com.atproto.admin.moderationAction#flag",
4765
- "com.atproto.admin.moderationAction#acknowledge"
4766
- ]
4832
+ type: "ref",
4833
+ ref: "lex:com.atproto.admin.moderationAction#actionType"
4767
4834
  },
4768
4835
  subject: {
4769
4836
  type: "union",
@@ -4772,6 +4839,12 @@ var schemaDict = {
4772
4839
  "lex:com.atproto.repo.strongRef"
4773
4840
  ]
4774
4841
  },
4842
+ subjectBlobCids: {
4843
+ type: "array",
4844
+ items: {
4845
+ type: "string"
4846
+ }
4847
+ },
4775
4848
  reason: {
4776
4849
  type: "string"
4777
4850
  },
@@ -4799,6 +4872,7 @@ var schemaDict = {
4799
4872
  "id",
4800
4873
  "action",
4801
4874
  "subject",
4875
+ "subjectBlobs",
4802
4876
  "reason",
4803
4877
  "createdBy",
4804
4878
  "createdAt",
@@ -4809,12 +4883,8 @@ var schemaDict = {
4809
4883
  type: "integer"
4810
4884
  },
4811
4885
  action: {
4812
- type: "string",
4813
- knownValues: [
4814
- "com.atproto.admin.moderationAction#takedown",
4815
- "com.atproto.admin.moderationAction#flag",
4816
- "com.atproto.admin.moderationAction#acknowledge"
4817
- ]
4886
+ type: "ref",
4887
+ ref: "lex:com.atproto.admin.moderationAction#actionType"
4818
4888
  },
4819
4889
  subject: {
4820
4890
  type: "union",
@@ -4823,6 +4893,13 @@ var schemaDict = {
4823
4893
  "lex:com.atproto.admin.record#view"
4824
4894
  ]
4825
4895
  },
4896
+ subjectBlobs: {
4897
+ type: "array",
4898
+ items: {
4899
+ type: "ref",
4900
+ ref: "lex:com.atproto.admin.blob#view"
4901
+ }
4902
+ },
4826
4903
  reason: {
4827
4904
  type: "string"
4828
4905
  },
@@ -4845,6 +4922,19 @@ var schemaDict = {
4845
4922
  }
4846
4923
  }
4847
4924
  },
4925
+ viewCurrent: {
4926
+ type: "object",
4927
+ required: ["id", "action"],
4928
+ properties: {
4929
+ id: {
4930
+ type: "integer"
4931
+ },
4932
+ action: {
4933
+ type: "ref",
4934
+ ref: "lex:com.atproto.admin.moderationAction#actionType"
4935
+ }
4936
+ }
4937
+ },
4848
4938
  reversal: {
4849
4939
  type: "object",
4850
4940
  required: ["reason", "createdBy", "createdAt"],
@@ -4860,6 +4950,14 @@ var schemaDict = {
4860
4950
  }
4861
4951
  }
4862
4952
  },
4953
+ actionType: {
4954
+ type: "string",
4955
+ knownValues: [
4956
+ "com.atproto.admin.moderationAction#takedown",
4957
+ "com.atproto.admin.moderationAction#flag",
4958
+ "com.atproto.admin.moderationAction#acknowledge"
4959
+ ]
4960
+ },
4863
4961
  takedown: {
4864
4962
  type: "token",
4865
4963
  description: "Moderation action type: Takedown. Indicates that content should not be served by the PDS."
@@ -4971,7 +5069,15 @@ var schemaDict = {
4971
5069
  defs: {
4972
5070
  view: {
4973
5071
  type: "object",
4974
- required: ["uri", "cid", "value", "indexedAt", "moderation", "repo"],
5072
+ required: [
5073
+ "uri",
5074
+ "cid",
5075
+ "value",
5076
+ "blobCids",
5077
+ "indexedAt",
5078
+ "moderation",
5079
+ "repo"
5080
+ ],
4975
5081
  properties: {
4976
5082
  uri: {
4977
5083
  type: "string"
@@ -4982,6 +5088,12 @@ var schemaDict = {
4982
5088
  value: {
4983
5089
  type: "unknown"
4984
5090
  },
5091
+ blobCids: {
5092
+ type: "array",
5093
+ items: {
5094
+ type: "string"
5095
+ }
5096
+ },
4985
5097
  indexedAt: {
4986
5098
  type: "string"
4987
5099
  },
@@ -4997,7 +5109,15 @@ var schemaDict = {
4997
5109
  },
4998
5110
  viewDetail: {
4999
5111
  type: "object",
5000
- required: ["uri", "cid", "value", "indexedAt", "moderation", "repo"],
5112
+ required: [
5113
+ "uri",
5114
+ "cid",
5115
+ "value",
5116
+ "blobs",
5117
+ "indexedAt",
5118
+ "moderation",
5119
+ "repo"
5120
+ ],
5001
5121
  properties: {
5002
5122
  uri: {
5003
5123
  type: "string"
@@ -5008,6 +5128,13 @@ var schemaDict = {
5008
5128
  value: {
5009
5129
  type: "unknown"
5010
5130
  },
5131
+ blobs: {
5132
+ type: "array",
5133
+ items: {
5134
+ type: "ref",
5135
+ ref: "lex:com.atproto.admin.blob#view"
5136
+ }
5137
+ },
5011
5138
  indexedAt: {
5012
5139
  type: "string"
5013
5140
  },
@@ -5025,8 +5152,9 @@ var schemaDict = {
5025
5152
  type: "object",
5026
5153
  required: [],
5027
5154
  properties: {
5028
- takedownId: {
5029
- type: "integer"
5155
+ currentAction: {
5156
+ type: "ref",
5157
+ ref: "lex:com.atproto.admin.moderationAction#viewCurrent"
5030
5158
  }
5031
5159
  }
5032
5160
  },
@@ -5034,6 +5162,10 @@ var schemaDict = {
5034
5162
  type: "object",
5035
5163
  required: ["actions", "reports"],
5036
5164
  properties: {
5165
+ currentAction: {
5166
+ type: "ref",
5167
+ ref: "lex:com.atproto.admin.moderationAction#viewCurrent"
5168
+ },
5037
5169
  actions: {
5038
5170
  type: "array",
5039
5171
  items: {
@@ -5047,9 +5179,6 @@ var schemaDict = {
5047
5179
  type: "ref",
5048
5180
  ref: "lex:com.atproto.admin.moderationReport#view"
5049
5181
  }
5050
- },
5051
- takedownId: {
5052
- type: "integer"
5053
5182
  }
5054
5183
  }
5055
5184
  }
@@ -5142,8 +5271,9 @@ var schemaDict = {
5142
5271
  type: "object",
5143
5272
  required: [],
5144
5273
  properties: {
5145
- takedownId: {
5146
- type: "integer"
5274
+ currentAction: {
5275
+ type: "ref",
5276
+ ref: "lex:com.atproto.admin.moderationAction#viewCurrent"
5147
5277
  }
5148
5278
  }
5149
5279
  },
@@ -5151,6 +5281,10 @@ var schemaDict = {
5151
5281
  type: "object",
5152
5282
  required: ["actions", "reports"],
5153
5283
  properties: {
5284
+ currentAction: {
5285
+ type: "ref",
5286
+ ref: "lex:com.atproto.admin.moderationAction#viewCurrent"
5287
+ },
5154
5288
  actions: {
5155
5289
  type: "array",
5156
5290
  items: {
@@ -5164,9 +5298,6 @@ var schemaDict = {
5164
5298
  type: "ref",
5165
5299
  ref: "lex:com.atproto.admin.moderationReport#view"
5166
5300
  }
5167
- },
5168
- takedownId: {
5169
- type: "integer"
5170
5301
  }
5171
5302
  }
5172
5303
  }
@@ -5319,6 +5450,12 @@ var schemaDict = {
5319
5450
  "lex:com.atproto.repo.recordRef"
5320
5451
  ]
5321
5452
  },
5453
+ subjectBlobCids: {
5454
+ type: "array",
5455
+ items: {
5456
+ type: "string"
5457
+ }
5458
+ },
5322
5459
  reason: {
5323
5460
  type: "string"
5324
5461
  },
@@ -5334,7 +5471,12 @@ var schemaDict = {
5334
5471
  type: "ref",
5335
5472
  ref: "lex:com.atproto.admin.moderationAction#view"
5336
5473
  }
5337
- }
5474
+ },
5475
+ errors: [
5476
+ {
5477
+ name: "SubjectHasAction"
5478
+ }
5479
+ ]
5338
5480
  }
5339
5481
  }
5340
5482
  },
@@ -6317,9 +6459,13 @@ var schemaDict = {
6317
6459
  type: "string",
6318
6460
  description: "The DID of the repo."
6319
6461
  },
6320
- from: {
6462
+ earliest: {
6321
6463
  type: "string",
6322
- description: "A past commit CID."
6464
+ description: "The earliest commit in the commit range (not inclusive)"
6465
+ },
6466
+ latest: {
6467
+ type: "string",
6468
+ description: "The latest commit you in the commit range (inclusive"
6323
6469
  }
6324
6470
  }
6325
6471
  },
@@ -6415,6 +6561,44 @@ var schemaDict = {
6415
6561
  }
6416
6562
  }
6417
6563
  },
6564
+ AppBskyActorGetProfiles: {
6565
+ lexicon: 1,
6566
+ id: "app.bsky.actor.getProfiles",
6567
+ defs: {
6568
+ main: {
6569
+ type: "query",
6570
+ parameters: {
6571
+ type: "params",
6572
+ required: ["actors"],
6573
+ properties: {
6574
+ actors: {
6575
+ type: "array",
6576
+ items: {
6577
+ type: "string"
6578
+ },
6579
+ maxLength: 25
6580
+ }
6581
+ }
6582
+ },
6583
+ output: {
6584
+ encoding: "application/json",
6585
+ schema: {
6586
+ type: "object",
6587
+ required: ["profiles"],
6588
+ properties: {
6589
+ profiles: {
6590
+ type: "array",
6591
+ items: {
6592
+ type: "ref",
6593
+ ref: "lex:app.bsky.actor.profile#view"
6594
+ }
6595
+ }
6596
+ }
6597
+ }
6598
+ }
6599
+ }
6600
+ }
6601
+ },
6418
6602
  AppBskyActorGetSuggestions: {
6419
6603
  lexicon: 1,
6420
6604
  id: "app.bsky.actor.getSuggestions",
@@ -6482,18 +6666,6 @@ var schemaDict = {
6482
6666
  },
6483
6667
  indexedAt: {
6484
6668
  type: "datetime"
6485
- },
6486
- myState: {
6487
- type: "ref",
6488
- ref: "lex:app.bsky.actor.getSuggestions#myState"
6489
- }
6490
- }
6491
- },
6492
- myState: {
6493
- type: "object",
6494
- properties: {
6495
- follow: {
6496
- type: "string"
6497
6669
  }
6498
6670
  }
6499
6671
  }
@@ -6534,6 +6706,71 @@ var schemaDict = {
6534
6706
  }
6535
6707
  }
6536
6708
  }
6709
+ },
6710
+ view: {
6711
+ type: "object",
6712
+ required: [
6713
+ "did",
6714
+ "declaration",
6715
+ "handle",
6716
+ "creator",
6717
+ "followersCount",
6718
+ "followsCount",
6719
+ "postsCount"
6720
+ ],
6721
+ properties: {
6722
+ did: {
6723
+ type: "string"
6724
+ },
6725
+ declaration: {
6726
+ type: "ref",
6727
+ ref: "lex:app.bsky.system.declRef"
6728
+ },
6729
+ handle: {
6730
+ type: "string"
6731
+ },
6732
+ creator: {
6733
+ type: "string"
6734
+ },
6735
+ displayName: {
6736
+ type: "string",
6737
+ maxLength: 64
6738
+ },
6739
+ description: {
6740
+ type: "string",
6741
+ maxLength: 256
6742
+ },
6743
+ avatar: {
6744
+ type: "string"
6745
+ },
6746
+ banner: {
6747
+ type: "string"
6748
+ },
6749
+ followersCount: {
6750
+ type: "integer"
6751
+ },
6752
+ followsCount: {
6753
+ type: "integer"
6754
+ },
6755
+ postsCount: {
6756
+ type: "integer"
6757
+ },
6758
+ myState: {
6759
+ type: "ref",
6760
+ ref: "lex:app.bsky.actor.profile#myState"
6761
+ }
6762
+ }
6763
+ },
6764
+ myState: {
6765
+ type: "object",
6766
+ properties: {
6767
+ follow: {
6768
+ type: "string"
6769
+ },
6770
+ muted: {
6771
+ type: "boolean"
6772
+ }
6773
+ }
6537
6774
  }
6538
6775
  }
6539
6776
  },
@@ -8369,10 +8606,18 @@ function toKnownErr16(e) {
8369
8606
  // src/client/types/com/atproto/admin/takeModerationAction.ts
8370
8607
  var takeModerationAction_exports = {};
8371
8608
  __export(takeModerationAction_exports, {
8609
+ SubjectHasActionError: () => SubjectHasActionError,
8372
8610
  toKnownErr: () => toKnownErr17
8373
8611
  });
8612
+ var SubjectHasActionError = class extends XRPCError {
8613
+ constructor(src) {
8614
+ super(src.status, src.error, src.message);
8615
+ }
8616
+ };
8374
8617
  function toKnownErr17(e) {
8375
8618
  if (e instanceof XRPCError) {
8619
+ if (e.error === "SubjectHasAction")
8620
+ return new SubjectHasActionError(e);
8376
8621
  }
8377
8622
  return e;
8378
8623
  }
@@ -8682,16 +8927,25 @@ function validateMyState(v) {
8682
8927
  return lexicons.validate("app.bsky.actor.getProfile#myState", v);
8683
8928
  }
8684
8929
 
8930
+ // src/client/types/app/bsky/actor/getProfiles.ts
8931
+ var getProfiles_exports = {};
8932
+ __export(getProfiles_exports, {
8933
+ toKnownErr: () => toKnownErr39
8934
+ });
8935
+ function toKnownErr39(e) {
8936
+ if (e instanceof XRPCError) {
8937
+ }
8938
+ return e;
8939
+ }
8940
+
8685
8941
  // src/client/types/app/bsky/actor/getSuggestions.ts
8686
8942
  var getSuggestions_exports = {};
8687
8943
  __export(getSuggestions_exports, {
8688
8944
  isActor: () => isActor,
8689
- isMyState: () => isMyState2,
8690
- toKnownErr: () => toKnownErr39,
8691
- validateActor: () => validateActor,
8692
- validateMyState: () => validateMyState2
8945
+ toKnownErr: () => toKnownErr40,
8946
+ validateActor: () => validateActor
8693
8947
  });
8694
- function toKnownErr39(e) {
8948
+ function toKnownErr40(e) {
8695
8949
  if (e instanceof XRPCError) {
8696
8950
  }
8697
8951
  return e;
@@ -8702,21 +8956,15 @@ function isActor(v) {
8702
8956
  function validateActor(v) {
8703
8957
  return lexicons.validate("app.bsky.actor.getSuggestions#actor", v);
8704
8958
  }
8705
- function isMyState2(v) {
8706
- return isObj2(v) && hasProp2(v, "$type") && v.$type === "app.bsky.actor.getSuggestions#myState";
8707
- }
8708
- function validateMyState2(v) {
8709
- return lexicons.validate("app.bsky.actor.getSuggestions#myState", v);
8710
- }
8711
8959
 
8712
8960
  // src/client/types/app/bsky/actor/search.ts
8713
8961
  var search_exports = {};
8714
8962
  __export(search_exports, {
8715
8963
  isUser: () => isUser,
8716
- toKnownErr: () => toKnownErr40,
8964
+ toKnownErr: () => toKnownErr41,
8717
8965
  validateUser: () => validateUser
8718
8966
  });
8719
- function toKnownErr40(e) {
8967
+ function toKnownErr41(e) {
8720
8968
  if (e instanceof XRPCError) {
8721
8969
  }
8722
8970
  return e;
@@ -8732,10 +8980,10 @@ function validateUser(v) {
8732
8980
  var searchTypeahead_exports = {};
8733
8981
  __export(searchTypeahead_exports, {
8734
8982
  isUser: () => isUser2,
8735
- toKnownErr: () => toKnownErr41,
8983
+ toKnownErr: () => toKnownErr42,
8736
8984
  validateUser: () => validateUser2
8737
8985
  });
8738
- function toKnownErr41(e) {
8986
+ function toKnownErr42(e) {
8739
8987
  if (e instanceof XRPCError) {
8740
8988
  }
8741
8989
  return e;
@@ -8754,7 +9002,7 @@ __export(updateProfile_exports, {
8754
9002
  InvalidBlobError: () => InvalidBlobError,
8755
9003
  InvalidImageDimensionsError: () => InvalidImageDimensionsError,
8756
9004
  InvalidMimeTypeError: () => InvalidMimeTypeError,
8757
- toKnownErr: () => toKnownErr42
9005
+ toKnownErr: () => toKnownErr43
8758
9006
  });
8759
9007
  var InvalidBlobError = class extends XRPCError {
8760
9008
  constructor(src) {
@@ -8776,7 +9024,7 @@ var InvalidImageDimensionsError = class extends XRPCError {
8776
9024
  super(src.status, src.error, src.message);
8777
9025
  }
8778
9026
  };
8779
- function toKnownErr42(e) {
9027
+ function toKnownErr43(e) {
8780
9028
  if (e instanceof XRPCError) {
8781
9029
  if (e.error === "InvalidBlob")
8782
9030
  return new InvalidBlobError(e);
@@ -8793,9 +9041,9 @@ function toKnownErr42(e) {
8793
9041
  // src/client/types/app/bsky/feed/getAuthorFeed.ts
8794
9042
  var getAuthorFeed_exports = {};
8795
9043
  __export(getAuthorFeed_exports, {
8796
- toKnownErr: () => toKnownErr43
9044
+ toKnownErr: () => toKnownErr44
8797
9045
  });
8798
- function toKnownErr43(e) {
9046
+ function toKnownErr44(e) {
8799
9047
  if (e instanceof XRPCError) {
8800
9048
  }
8801
9049
  return e;
@@ -8807,7 +9055,7 @@ __export(getPostThread_exports, {
8807
9055
  NotFoundError: () => NotFoundError,
8808
9056
  isNotFoundPost: () => isNotFoundPost,
8809
9057
  isThreadViewPost: () => isThreadViewPost,
8810
- toKnownErr: () => toKnownErr44,
9058
+ toKnownErr: () => toKnownErr45,
8811
9059
  validateNotFoundPost: () => validateNotFoundPost,
8812
9060
  validateThreadViewPost: () => validateThreadViewPost
8813
9061
  });
@@ -8816,7 +9064,7 @@ var NotFoundError = class extends XRPCError {
8816
9064
  super(src.status, src.error, src.message);
8817
9065
  }
8818
9066
  };
8819
- function toKnownErr44(e) {
9067
+ function toKnownErr45(e) {
8820
9068
  if (e instanceof XRPCError) {
8821
9069
  if (e.error === "NotFound")
8822
9070
  return new NotFoundError(e);
@@ -8840,10 +9088,10 @@ function validateNotFoundPost(v) {
8840
9088
  var getRepostedBy_exports = {};
8841
9089
  __export(getRepostedBy_exports, {
8842
9090
  isRepostedBy: () => isRepostedBy,
8843
- toKnownErr: () => toKnownErr45,
9091
+ toKnownErr: () => toKnownErr46,
8844
9092
  validateRepostedBy: () => validateRepostedBy
8845
9093
  });
8846
- function toKnownErr45(e) {
9094
+ function toKnownErr46(e) {
8847
9095
  if (e instanceof XRPCError) {
8848
9096
  }
8849
9097
  return e;
@@ -8858,9 +9106,9 @@ function validateRepostedBy(v) {
8858
9106
  // src/client/types/app/bsky/feed/getTimeline.ts
8859
9107
  var getTimeline_exports = {};
8860
9108
  __export(getTimeline_exports, {
8861
- toKnownErr: () => toKnownErr46
9109
+ toKnownErr: () => toKnownErr47
8862
9110
  });
8863
- function toKnownErr46(e) {
9111
+ function toKnownErr47(e) {
8864
9112
  if (e instanceof XRPCError) {
8865
9113
  }
8866
9114
  return e;
@@ -8870,10 +9118,10 @@ function toKnownErr46(e) {
8870
9118
  var getVotes_exports = {};
8871
9119
  __export(getVotes_exports, {
8872
9120
  isVote: () => isVote,
8873
- toKnownErr: () => toKnownErr47,
9121
+ toKnownErr: () => toKnownErr48,
8874
9122
  validateVote: () => validateVote
8875
9123
  });
8876
- function toKnownErr47(e) {
9124
+ function toKnownErr48(e) {
8877
9125
  if (e instanceof XRPCError) {
8878
9126
  }
8879
9127
  return e;
@@ -8888,9 +9136,9 @@ function validateVote(v) {
8888
9136
  // src/client/types/app/bsky/feed/setVote.ts
8889
9137
  var setVote_exports = {};
8890
9138
  __export(setVote_exports, {
8891
- toKnownErr: () => toKnownErr48
9139
+ toKnownErr: () => toKnownErr49
8892
9140
  });
8893
- function toKnownErr48(e) {
9141
+ function toKnownErr49(e) {
8894
9142
  if (e instanceof XRPCError) {
8895
9143
  }
8896
9144
  return e;
@@ -8900,10 +9148,10 @@ function toKnownErr48(e) {
8900
9148
  var getFollowers_exports = {};
8901
9149
  __export(getFollowers_exports, {
8902
9150
  isFollower: () => isFollower,
8903
- toKnownErr: () => toKnownErr49,
9151
+ toKnownErr: () => toKnownErr50,
8904
9152
  validateFollower: () => validateFollower
8905
9153
  });
8906
- function toKnownErr49(e) {
9154
+ function toKnownErr50(e) {
8907
9155
  if (e instanceof XRPCError) {
8908
9156
  }
8909
9157
  return e;
@@ -8919,10 +9167,10 @@ function validateFollower(v) {
8919
9167
  var getFollows_exports = {};
8920
9168
  __export(getFollows_exports, {
8921
9169
  isFollow: () => isFollow,
8922
- toKnownErr: () => toKnownErr50,
9170
+ toKnownErr: () => toKnownErr51,
8923
9171
  validateFollow: () => validateFollow
8924
9172
  });
8925
- function toKnownErr50(e) {
9173
+ function toKnownErr51(e) {
8926
9174
  if (e instanceof XRPCError) {
8927
9175
  }
8928
9176
  return e;
@@ -8938,10 +9186,10 @@ function validateFollow(v) {
8938
9186
  var getMutes_exports = {};
8939
9187
  __export(getMutes_exports, {
8940
9188
  isMute: () => isMute,
8941
- toKnownErr: () => toKnownErr51,
9189
+ toKnownErr: () => toKnownErr52,
8942
9190
  validateMute: () => validateMute
8943
9191
  });
8944
- function toKnownErr51(e) {
9192
+ function toKnownErr52(e) {
8945
9193
  if (e instanceof XRPCError) {
8946
9194
  }
8947
9195
  return e;
@@ -8956,9 +9204,9 @@ function validateMute(v) {
8956
9204
  // src/client/types/app/bsky/graph/mute.ts
8957
9205
  var mute_exports = {};
8958
9206
  __export(mute_exports, {
8959
- toKnownErr: () => toKnownErr52
9207
+ toKnownErr: () => toKnownErr53
8960
9208
  });
8961
- function toKnownErr52(e) {
9209
+ function toKnownErr53(e) {
8962
9210
  if (e instanceof XRPCError) {
8963
9211
  }
8964
9212
  return e;
@@ -8967,9 +9215,9 @@ function toKnownErr52(e) {
8967
9215
  // src/client/types/app/bsky/graph/unmute.ts
8968
9216
  var unmute_exports = {};
8969
9217
  __export(unmute_exports, {
8970
- toKnownErr: () => toKnownErr53
9218
+ toKnownErr: () => toKnownErr54
8971
9219
  });
8972
- function toKnownErr53(e) {
9220
+ function toKnownErr54(e) {
8973
9221
  if (e instanceof XRPCError) {
8974
9222
  }
8975
9223
  return e;
@@ -8978,9 +9226,9 @@ function toKnownErr53(e) {
8978
9226
  // src/client/types/app/bsky/notification/getCount.ts
8979
9227
  var getCount_exports = {};
8980
9228
  __export(getCount_exports, {
8981
- toKnownErr: () => toKnownErr54
9229
+ toKnownErr: () => toKnownErr55
8982
9230
  });
8983
- function toKnownErr54(e) {
9231
+ function toKnownErr55(e) {
8984
9232
  if (e instanceof XRPCError) {
8985
9233
  }
8986
9234
  return e;
@@ -8990,10 +9238,10 @@ function toKnownErr54(e) {
8990
9238
  var list_exports = {};
8991
9239
  __export(list_exports, {
8992
9240
  isNotification: () => isNotification,
8993
- toKnownErr: () => toKnownErr55,
9241
+ toKnownErr: () => toKnownErr56,
8994
9242
  validateNotification: () => validateNotification
8995
9243
  });
8996
- function toKnownErr55(e) {
9244
+ function toKnownErr56(e) {
8997
9245
  if (e instanceof XRPCError) {
8998
9246
  }
8999
9247
  return e;
@@ -9008,14 +9256,51 @@ function validateNotification(v) {
9008
9256
  // src/client/types/app/bsky/notification/updateSeen.ts
9009
9257
  var updateSeen_exports = {};
9010
9258
  __export(updateSeen_exports, {
9011
- toKnownErr: () => toKnownErr56
9259
+ toKnownErr: () => toKnownErr57
9012
9260
  });
9013
- function toKnownErr56(e) {
9261
+ function toKnownErr57(e) {
9014
9262
  if (e instanceof XRPCError) {
9015
9263
  }
9016
9264
  return e;
9017
9265
  }
9018
9266
 
9267
+ // src/client/types/com/atproto/admin/blob.ts
9268
+ var blob_exports2 = {};
9269
+ __export(blob_exports2, {
9270
+ isImageDetails: () => isImageDetails,
9271
+ isModeration: () => isModeration,
9272
+ isVideoDetails: () => isVideoDetails,
9273
+ isView: () => isView,
9274
+ validateImageDetails: () => validateImageDetails,
9275
+ validateModeration: () => validateModeration,
9276
+ validateVideoDetails: () => validateVideoDetails,
9277
+ validateView: () => validateView
9278
+ });
9279
+ function isView(v) {
9280
+ return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.blob#view";
9281
+ }
9282
+ function validateView(v) {
9283
+ return lexicons.validate("com.atproto.admin.blob#view", v);
9284
+ }
9285
+ function isImageDetails(v) {
9286
+ return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.blob#imageDetails";
9287
+ }
9288
+ function validateImageDetails(v) {
9289
+ return lexicons.validate("com.atproto.admin.blob#imageDetails", v);
9290
+ }
9291
+ function isVideoDetails(v) {
9292
+ return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.blob#videoDetails";
9293
+ }
9294
+ function validateVideoDetails(v) {
9295
+ return lexicons.validate("com.atproto.admin.blob#videoDetails", v);
9296
+ }
9297
+ function isModeration(v) {
9298
+ return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.blob#moderation";
9299
+ }
9300
+ function validateModeration(v) {
9301
+ return lexicons.validate("com.atproto.admin.blob#moderation", v);
9302
+ }
9303
+
9019
9304
  // src/client/types/com/atproto/admin/moderationAction.ts
9020
9305
  var moderationAction_exports = {};
9021
9306
  __export(moderationAction_exports, {
@@ -9023,16 +9308,18 @@ __export(moderationAction_exports, {
9023
9308
  FLAG: () => FLAG,
9024
9309
  TAKEDOWN: () => TAKEDOWN,
9025
9310
  isReversal: () => isReversal,
9026
- isView: () => isView,
9311
+ isView: () => isView2,
9312
+ isViewCurrent: () => isViewCurrent,
9027
9313
  isViewDetail: () => isViewDetail,
9028
9314
  validateReversal: () => validateReversal,
9029
- validateView: () => validateView,
9315
+ validateView: () => validateView2,
9316
+ validateViewCurrent: () => validateViewCurrent,
9030
9317
  validateViewDetail: () => validateViewDetail
9031
9318
  });
9032
- function isView(v) {
9319
+ function isView2(v) {
9033
9320
  return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.moderationAction#view";
9034
9321
  }
9035
- function validateView(v) {
9322
+ function validateView2(v) {
9036
9323
  return lexicons.validate("com.atproto.admin.moderationAction#view", v);
9037
9324
  }
9038
9325
  function isViewDetail(v) {
@@ -9041,6 +9328,12 @@ function isViewDetail(v) {
9041
9328
  function validateViewDetail(v) {
9042
9329
  return lexicons.validate("com.atproto.admin.moderationAction#viewDetail", v);
9043
9330
  }
9331
+ function isViewCurrent(v) {
9332
+ return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.moderationAction#viewCurrent";
9333
+ }
9334
+ function validateViewCurrent(v) {
9335
+ return lexicons.validate("com.atproto.admin.moderationAction#viewCurrent", v);
9336
+ }
9044
9337
  function isReversal(v) {
9045
9338
  return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.moderationAction#reversal";
9046
9339
  }
@@ -9054,15 +9347,15 @@ var ACKNOWLEDGE = "com.atproto.admin.moderationAction#acknowledge";
9054
9347
  // src/client/types/com/atproto/admin/moderationReport.ts
9055
9348
  var moderationReport_exports = {};
9056
9349
  __export(moderationReport_exports, {
9057
- isView: () => isView2,
9350
+ isView: () => isView3,
9058
9351
  isViewDetail: () => isViewDetail2,
9059
- validateView: () => validateView2,
9352
+ validateView: () => validateView3,
9060
9353
  validateViewDetail: () => validateViewDetail2
9061
9354
  });
9062
- function isView2(v) {
9355
+ function isView3(v) {
9063
9356
  return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.moderationReport#view";
9064
9357
  }
9065
- function validateView2(v) {
9358
+ function validateView3(v) {
9066
9359
  return lexicons.validate("com.atproto.admin.moderationReport#view", v);
9067
9360
  }
9068
9361
  function isViewDetail2(v) {
@@ -9075,19 +9368,19 @@ function validateViewDetail2(v) {
9075
9368
  // src/client/types/com/atproto/admin/record.ts
9076
9369
  var record_exports = {};
9077
9370
  __export(record_exports, {
9078
- isModeration: () => isModeration,
9371
+ isModeration: () => isModeration2,
9079
9372
  isModerationDetail: () => isModerationDetail,
9080
- isView: () => isView3,
9373
+ isView: () => isView4,
9081
9374
  isViewDetail: () => isViewDetail3,
9082
- validateModeration: () => validateModeration,
9375
+ validateModeration: () => validateModeration2,
9083
9376
  validateModerationDetail: () => validateModerationDetail,
9084
- validateView: () => validateView3,
9377
+ validateView: () => validateView4,
9085
9378
  validateViewDetail: () => validateViewDetail3
9086
9379
  });
9087
- function isView3(v) {
9380
+ function isView4(v) {
9088
9381
  return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.record#view";
9089
9382
  }
9090
- function validateView3(v) {
9383
+ function validateView4(v) {
9091
9384
  return lexicons.validate("com.atproto.admin.record#view", v);
9092
9385
  }
9093
9386
  function isViewDetail3(v) {
@@ -9096,10 +9389,10 @@ function isViewDetail3(v) {
9096
9389
  function validateViewDetail3(v) {
9097
9390
  return lexicons.validate("com.atproto.admin.record#viewDetail", v);
9098
9391
  }
9099
- function isModeration(v) {
9392
+ function isModeration2(v) {
9100
9393
  return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.record#moderation";
9101
9394
  }
9102
- function validateModeration(v) {
9395
+ function validateModeration2(v) {
9103
9396
  return lexicons.validate("com.atproto.admin.record#moderation", v);
9104
9397
  }
9105
9398
  function isModerationDetail(v) {
@@ -9113,20 +9406,20 @@ function validateModerationDetail(v) {
9113
9406
  var repo_exports = {};
9114
9407
  __export(repo_exports, {
9115
9408
  isAccount: () => isAccount,
9116
- isModeration: () => isModeration2,
9409
+ isModeration: () => isModeration3,
9117
9410
  isModerationDetail: () => isModerationDetail2,
9118
- isView: () => isView4,
9411
+ isView: () => isView5,
9119
9412
  isViewDetail: () => isViewDetail4,
9120
9413
  validateAccount: () => validateAccount,
9121
- validateModeration: () => validateModeration2,
9414
+ validateModeration: () => validateModeration3,
9122
9415
  validateModerationDetail: () => validateModerationDetail2,
9123
- validateView: () => validateView4,
9416
+ validateView: () => validateView5,
9124
9417
  validateViewDetail: () => validateViewDetail4
9125
9418
  });
9126
- function isView4(v) {
9419
+ function isView5(v) {
9127
9420
  return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.repo#view";
9128
9421
  }
9129
- function validateView4(v) {
9422
+ function validateView5(v) {
9130
9423
  return lexicons.validate("com.atproto.admin.repo#view", v);
9131
9424
  }
9132
9425
  function isViewDetail4(v) {
@@ -9141,10 +9434,10 @@ function isAccount(v) {
9141
9434
  function validateAccount(v) {
9142
9435
  return lexicons.validate("com.atproto.admin.repo#account", v);
9143
9436
  }
9144
- function isModeration2(v) {
9437
+ function isModeration3(v) {
9145
9438
  return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.repo#moderation";
9146
9439
  }
9147
- function validateModeration2(v) {
9440
+ function validateModeration3(v) {
9148
9441
  return lexicons.validate("com.atproto.admin.repo#moderation", v);
9149
9442
  }
9150
9443
  function isModerationDetail2(v) {
@@ -9234,8 +9527,12 @@ function validateRecordRef(v) {
9234
9527
  // src/client/types/app/bsky/actor/profile.ts
9235
9528
  var profile_exports = {};
9236
9529
  __export(profile_exports, {
9530
+ isMyState: () => isMyState2,
9237
9531
  isRecord: () => isRecord3,
9238
- validateRecord: () => validateRecord3
9532
+ isView: () => isView6,
9533
+ validateMyState: () => validateMyState2,
9534
+ validateRecord: () => validateRecord3,
9535
+ validateView: () => validateView6
9239
9536
  });
9240
9537
  function isRecord3(v) {
9241
9538
  return isObj2(v) && hasProp2(v, "$type") && (v.$type === "app.bsky.actor.profile#main" || v.$type === "app.bsky.actor.profile");
@@ -9243,6 +9540,18 @@ function isRecord3(v) {
9243
9540
  function validateRecord3(v) {
9244
9541
  return lexicons.validate("app.bsky.actor.profile#main", v);
9245
9542
  }
9543
+ function isView6(v) {
9544
+ return isObj2(v) && hasProp2(v, "$type") && v.$type === "app.bsky.actor.profile#view";
9545
+ }
9546
+ function validateView6(v) {
9547
+ return lexicons.validate("app.bsky.actor.profile#view", v);
9548
+ }
9549
+ function isMyState2(v) {
9550
+ return isObj2(v) && hasProp2(v, "$type") && v.$type === "app.bsky.actor.profile#myState";
9551
+ }
9552
+ function validateMyState2(v) {
9553
+ return lexicons.validate("app.bsky.actor.profile#myState", v);
9554
+ }
9246
9555
 
9247
9556
  // src/client/types/app/bsky/actor/ref.ts
9248
9557
  var ref_exports = {};
@@ -9383,13 +9692,13 @@ __export(post_exports, {
9383
9692
  isRecord: () => isRecord4,
9384
9693
  isReplyRef: () => isReplyRef2,
9385
9694
  isTextSlice: () => isTextSlice,
9386
- isView: () => isView5,
9695
+ isView: () => isView7,
9387
9696
  isViewerState: () => isViewerState2,
9388
9697
  validateEntity: () => validateEntity,
9389
9698
  validateRecord: () => validateRecord4,
9390
9699
  validateReplyRef: () => validateReplyRef2,
9391
9700
  validateTextSlice: () => validateTextSlice,
9392
- validateView: () => validateView5,
9701
+ validateView: () => validateView7,
9393
9702
  validateViewerState: () => validateViewerState2
9394
9703
  });
9395
9704
  function isRecord4(v) {
@@ -9416,10 +9725,10 @@ function isTextSlice(v) {
9416
9725
  function validateTextSlice(v) {
9417
9726
  return lexicons.validate("app.bsky.feed.post#textSlice", v);
9418
9727
  }
9419
- function isView5(v) {
9728
+ function isView7(v) {
9420
9729
  return isObj2(v) && hasProp2(v, "$type") && v.$type === "app.bsky.feed.post#view";
9421
9730
  }
9422
- function validateView5(v) {
9731
+ function validateView7(v) {
9423
9732
  return lexicons.validate("app.bsky.feed.post#view", v);
9424
9733
  }
9425
9734
  function isViewerState2(v) {
@@ -9558,18 +9867,16 @@ var APP_BSKY_GRAPH = {
9558
9867
  var APP_BSKY_SYSTEM = {
9559
9868
  ActorUser: "app.bsky.system.actorUser"
9560
9869
  };
9561
- var Client2 = class {
9870
+ var AtpBaseClient = class {
9562
9871
  constructor() {
9563
9872
  this.xrpc = new Client();
9564
9873
  this.xrpc.addLexicons(schemas);
9565
9874
  }
9566
9875
  service(serviceUri) {
9567
- return new ServiceClient2(this, this.xrpc.service(serviceUri));
9876
+ return new AtpServiceClient(this, this.xrpc.service(serviceUri));
9568
9877
  }
9569
9878
  };
9570
- var defaultInst2 = new Client2();
9571
- var client_default = defaultInst2;
9572
- var ServiceClient2 = class {
9879
+ var AtpServiceClient = class {
9573
9880
  constructor(baseClient, xrpcService) {
9574
9881
  this._baseClient = baseClient;
9575
9882
  this.xrpc = xrpcService;
@@ -9857,24 +10164,29 @@ var ActorNS = class {
9857
10164
  throw toKnownErr38(e);
9858
10165
  });
9859
10166
  }
10167
+ getProfiles(params2, opts) {
10168
+ return this._service.xrpc.call("app.bsky.actor.getProfiles", params2, void 0, opts).catch((e) => {
10169
+ throw toKnownErr39(e);
10170
+ });
10171
+ }
9860
10172
  getSuggestions(params2, opts) {
9861
10173
  return this._service.xrpc.call("app.bsky.actor.getSuggestions", params2, void 0, opts).catch((e) => {
9862
- throw toKnownErr39(e);
10174
+ throw toKnownErr40(e);
9863
10175
  });
9864
10176
  }
9865
10177
  search(params2, opts) {
9866
10178
  return this._service.xrpc.call("app.bsky.actor.search", params2, void 0, opts).catch((e) => {
9867
- throw toKnownErr40(e);
10179
+ throw toKnownErr41(e);
9868
10180
  });
9869
10181
  }
9870
10182
  searchTypeahead(params2, opts) {
9871
10183
  return this._service.xrpc.call("app.bsky.actor.searchTypeahead", params2, void 0, opts).catch((e) => {
9872
- throw toKnownErr41(e);
10184
+ throw toKnownErr42(e);
9873
10185
  });
9874
10186
  }
9875
10187
  updateProfile(data, opts) {
9876
10188
  return this._service.xrpc.call("app.bsky.actor.updateProfile", opts?.qp, data, opts).catch((e) => {
9877
- throw toKnownErr42(e);
10189
+ throw toKnownErr43(e);
9878
10190
  });
9879
10191
  }
9880
10192
  };
@@ -9929,32 +10241,32 @@ var FeedNS = class {
9929
10241
  }
9930
10242
  getAuthorFeed(params2, opts) {
9931
10243
  return this._service.xrpc.call("app.bsky.feed.getAuthorFeed", params2, void 0, opts).catch((e) => {
9932
- throw toKnownErr43(e);
10244
+ throw toKnownErr44(e);
9933
10245
  });
9934
10246
  }
9935
10247
  getPostThread(params2, opts) {
9936
10248
  return this._service.xrpc.call("app.bsky.feed.getPostThread", params2, void 0, opts).catch((e) => {
9937
- throw toKnownErr44(e);
10249
+ throw toKnownErr45(e);
9938
10250
  });
9939
10251
  }
9940
10252
  getRepostedBy(params2, opts) {
9941
10253
  return this._service.xrpc.call("app.bsky.feed.getRepostedBy", params2, void 0, opts).catch((e) => {
9942
- throw toKnownErr45(e);
10254
+ throw toKnownErr46(e);
9943
10255
  });
9944
10256
  }
9945
10257
  getTimeline(params2, opts) {
9946
10258
  return this._service.xrpc.call("app.bsky.feed.getTimeline", params2, void 0, opts).catch((e) => {
9947
- throw toKnownErr46(e);
10259
+ throw toKnownErr47(e);
9948
10260
  });
9949
10261
  }
9950
10262
  getVotes(params2, opts) {
9951
10263
  return this._service.xrpc.call("app.bsky.feed.getVotes", params2, void 0, opts).catch((e) => {
9952
- throw toKnownErr47(e);
10264
+ throw toKnownErr48(e);
9953
10265
  });
9954
10266
  }
9955
10267
  setVote(data, opts) {
9956
10268
  return this._service.xrpc.call("app.bsky.feed.setVote", opts?.qp, data, opts).catch((e) => {
9957
- throw toKnownErr48(e);
10269
+ throw toKnownErr49(e);
9958
10270
  });
9959
10271
  }
9960
10272
  };
@@ -10078,27 +10390,27 @@ var GraphNS = class {
10078
10390
  }
10079
10391
  getFollowers(params2, opts) {
10080
10392
  return this._service.xrpc.call("app.bsky.graph.getFollowers", params2, void 0, opts).catch((e) => {
10081
- throw toKnownErr49(e);
10393
+ throw toKnownErr50(e);
10082
10394
  });
10083
10395
  }
10084
10396
  getFollows(params2, opts) {
10085
10397
  return this._service.xrpc.call("app.bsky.graph.getFollows", params2, void 0, opts).catch((e) => {
10086
- throw toKnownErr50(e);
10398
+ throw toKnownErr51(e);
10087
10399
  });
10088
10400
  }
10089
10401
  getMutes(params2, opts) {
10090
10402
  return this._service.xrpc.call("app.bsky.graph.getMutes", params2, void 0, opts).catch((e) => {
10091
- throw toKnownErr51(e);
10403
+ throw toKnownErr52(e);
10092
10404
  });
10093
10405
  }
10094
10406
  mute(data, opts) {
10095
10407
  return this._service.xrpc.call("app.bsky.graph.mute", opts?.qp, data, opts).catch((e) => {
10096
- throw toKnownErr52(e);
10408
+ throw toKnownErr53(e);
10097
10409
  });
10098
10410
  }
10099
10411
  unmute(data, opts) {
10100
10412
  return this._service.xrpc.call("app.bsky.graph.unmute", opts?.qp, data, opts).catch((e) => {
10101
- throw toKnownErr53(e);
10413
+ throw toKnownErr54(e);
10102
10414
  });
10103
10415
  }
10104
10416
  };
@@ -10219,17 +10531,17 @@ var NotificationNS = class {
10219
10531
  }
10220
10532
  getCount(params2, opts) {
10221
10533
  return this._service.xrpc.call("app.bsky.notification.getCount", params2, void 0, opts).catch((e) => {
10222
- throw toKnownErr54(e);
10534
+ throw toKnownErr55(e);
10223
10535
  });
10224
10536
  }
10225
10537
  list(params2, opts) {
10226
10538
  return this._service.xrpc.call("app.bsky.notification.list", params2, void 0, opts).catch((e) => {
10227
- throw toKnownErr55(e);
10539
+ throw toKnownErr56(e);
10228
10540
  });
10229
10541
  }
10230
10542
  updateSeen(data, opts) {
10231
10543
  return this._service.xrpc.call("app.bsky.notification.updateSeen", opts?.qp, data, opts).catch((e) => {
10232
- throw toKnownErr56(e);
10544
+ throw toKnownErr57(e);
10233
10545
  });
10234
10546
  }
10235
10547
  };
@@ -10277,129 +10589,189 @@ var DeclarationRecord = class {
10277
10589
  }
10278
10590
  };
10279
10591
 
10280
- // src/session.ts
10281
- var import_events = __toESM(require("events"));
10282
- var CREATE_SESSION = "com.atproto.session.create";
10592
+ // src/agent.ts
10283
10593
  var REFRESH_SESSION = "com.atproto.session.refresh";
10284
- var DELETE_SESSION = "com.atproto.session.delete";
10285
- var CREATE_ACCOUNT = "com.atproto.account.create";
10286
- var SessionClient = class extends Client2 {
10287
- service(serviceUri) {
10288
- const xrpcService = new SessionXrpcServiceClient(this.xrpc, serviceUri);
10289
- return new SessionServiceClient(this, xrpcService);
10594
+ var _AtpAgent = class {
10595
+ static configure(opts) {
10596
+ _AtpAgent.fetch = opts.fetch;
10597
+ }
10598
+ constructor(opts) {
10599
+ this.service = opts.service instanceof URL ? opts.service : new URL(opts.service);
10600
+ this._persistSession = opts.persistSession;
10601
+ this._baseClient = new AtpBaseClient();
10602
+ this._baseClient.xrpc.fetch = this._fetch.bind(this);
10603
+ this.api = this._baseClient.service(opts.service);
10604
+ }
10605
+ get hasSession() {
10606
+ return !!this.session;
10290
10607
  }
10291
- };
10292
- var defaultInst3 = new SessionClient();
10293
- var session_default = defaultInst3;
10294
- var SessionServiceClient = class extends ServiceClient2 {
10295
- constructor(baseClient, xrpcService) {
10296
- super(baseClient, xrpcService);
10297
- this.sessionManager = this.xrpc.sessionManager;
10608
+ setPersistSessionHandler(handler) {
10609
+ this._persistSession = handler;
10298
10610
  }
10299
- };
10300
- var SessionXrpcServiceClient = class extends ServiceClient {
10301
- constructor(baseClient, serviceUri) {
10302
- super(baseClient, serviceUri);
10303
- this.sessionManager = new SessionManager();
10304
- this.sessionManager.on("session", () => {
10305
- const accessHeaders = this.sessionManager.accessHeaders();
10306
- if (accessHeaders) {
10307
- this.setHeader("authorization", accessHeaders.authorization);
10611
+ async createAccount(opts) {
10612
+ try {
10613
+ const res = await this.api.com.atproto.account.create({
10614
+ handle: opts.handle,
10615
+ password: opts.password,
10616
+ email: opts.email,
10617
+ inviteCode: opts.inviteCode
10618
+ });
10619
+ this.session = {
10620
+ accessJwt: res.data.accessJwt,
10621
+ refreshJwt: res.data.refreshJwt,
10622
+ handle: res.data.handle,
10623
+ did: res.data.did
10624
+ };
10625
+ return res;
10626
+ } catch (e) {
10627
+ this.session = void 0;
10628
+ throw e;
10629
+ } finally {
10630
+ if (this.session) {
10631
+ this._persistSession?.("create", this.session);
10308
10632
  } else {
10309
- this.unsetHeader("authorization");
10633
+ this._persistSession?.("create-failed", void 0);
10310
10634
  }
10311
- });
10312
- }
10313
- async call(methodNsid, params2, data, opts) {
10314
- const original = (overrideOpts) => super.call(methodNsid, params2, data, overrideOpts ?? opts);
10315
- if (opts?.headers?.authorization) {
10316
- return await original();
10317
- }
10318
- if (methodNsid === REFRESH_SESSION) {
10319
- return await this.refresh(opts);
10320
- }
10321
- await this.refreshing;
10322
- if (methodNsid === CREATE_SESSION || methodNsid === CREATE_ACCOUNT) {
10323
- const result = await original();
10324
- const { accessJwt, refreshJwt } = result.data;
10325
- this.sessionManager.set({ accessJwt, refreshJwt });
10326
- return result;
10327
- }
10328
- if (methodNsid === DELETE_SESSION) {
10329
- const result = await original({
10330
- ...opts,
10331
- headers: {
10332
- ...opts?.headers,
10333
- ...this.sessionManager.refreshHeaders()
10334
- }
10335
- });
10336
- this.sessionManager.unset();
10337
- return result;
10338
10635
  }
10636
+ }
10637
+ async login(opts) {
10339
10638
  try {
10340
- return await original();
10341
- } catch (err) {
10342
- if (err instanceof XRPCError && err.status === 400 /* InvalidRequest */ && err.error === "ExpiredToken" && this.sessionManager.active()) {
10343
- await this.refresh(opts);
10344
- return await original();
10639
+ const res = await this.api.com.atproto.session.create({
10640
+ identifier: opts.identifier,
10641
+ password: opts.password
10642
+ });
10643
+ this.session = {
10644
+ accessJwt: res.data.accessJwt,
10645
+ refreshJwt: res.data.refreshJwt,
10646
+ handle: res.data.handle,
10647
+ did: res.data.did
10648
+ };
10649
+ return res;
10650
+ } catch (e) {
10651
+ this.session = void 0;
10652
+ throw e;
10653
+ } finally {
10654
+ if (this.session) {
10655
+ this._persistSession?.("create", this.session);
10656
+ } else {
10657
+ this._persistSession?.("create-failed", void 0);
10345
10658
  }
10346
- throw err;
10347
10659
  }
10348
10660
  }
10349
- async refresh(opts) {
10350
- this.refreshing ?? (this.refreshing = this._refresh(opts));
10661
+ async resumeSession(session) {
10351
10662
  try {
10352
- return await this.refreshing;
10663
+ this.session = session;
10664
+ const res = await this.api.com.atproto.session.get();
10665
+ if (!res.success || res.data.did !== this.session.did) {
10666
+ throw new Error("Invalid session");
10667
+ }
10668
+ return res;
10669
+ } catch (e) {
10670
+ this.session = void 0;
10671
+ throw e;
10353
10672
  } finally {
10354
- this.refreshing = void 0;
10673
+ if (this.session) {
10674
+ this._persistSession?.("create", this.session);
10675
+ } else {
10676
+ this._persistSession?.("create-failed", void 0);
10677
+ }
10355
10678
  }
10356
10679
  }
10357
- async _refresh(opts) {
10358
- try {
10359
- const result = await super.call(REFRESH_SESSION, void 0, void 0, {
10360
- ...opts,
10361
- headers: {
10362
- ...opts?.headers,
10363
- ...this.sessionManager.refreshHeaders()
10364
- }
10365
- });
10366
- const { accessJwt, refreshJwt } = result.data;
10367
- this.sessionManager.set({ accessJwt, refreshJwt });
10368
- return result;
10369
- } catch (err) {
10370
- if (err instanceof XRPCError && err.status === 400 /* InvalidRequest */ && (err.error === "ExpiredToken" || err.error === "InvalidToken")) {
10371
- this.sessionManager.unset();
10372
- }
10373
- throw err;
10680
+ _addAuthHeader(reqHeaders) {
10681
+ if (!reqHeaders.authorization && this.session?.accessJwt) {
10682
+ return {
10683
+ ...reqHeaders,
10684
+ authorization: `Bearer ${this.session.accessJwt}`
10685
+ };
10374
10686
  }
10687
+ return reqHeaders;
10375
10688
  }
10376
- };
10377
- var SessionManager = class extends import_events.default {
10378
- get() {
10379
- return this.session;
10689
+ async _fetch(reqUri, reqMethod, reqHeaders, reqBody) {
10690
+ if (!_AtpAgent.fetch) {
10691
+ throw new Error("AtpAgent fetch() method not configured");
10692
+ }
10693
+ await this._refreshSessionPromise;
10694
+ let res = await _AtpAgent.fetch(
10695
+ reqUri,
10696
+ reqMethod,
10697
+ this._addAuthHeader(reqHeaders),
10698
+ reqBody
10699
+ );
10700
+ if (isErrorResponse(res, ["ExpiredToken"]) && this.session?.refreshJwt) {
10701
+ await this._refreshSession();
10702
+ res = await _AtpAgent.fetch(
10703
+ reqUri,
10704
+ reqMethod,
10705
+ this._addAuthHeader(reqHeaders),
10706
+ reqBody
10707
+ );
10708
+ }
10709
+ return res;
10380
10710
  }
10381
- set(session) {
10382
- this.session = session;
10383
- this.emit("session", session);
10711
+ async _refreshSession() {
10712
+ if (this._refreshSessionPromise) {
10713
+ return this._refreshSessionPromise;
10714
+ }
10715
+ this._refreshSessionPromise = this._refreshSessionInner();
10716
+ try {
10717
+ await this._refreshSessionPromise;
10718
+ } finally {
10719
+ this._refreshSessionPromise = void 0;
10720
+ }
10384
10721
  }
10385
- unset() {
10386
- this.session = void 0;
10387
- this.emit("session", void 0);
10722
+ async _refreshSessionInner() {
10723
+ if (!_AtpAgent.fetch) {
10724
+ throw new Error("AtpAgent fetch() method not configured");
10725
+ }
10726
+ if (!this.session?.refreshJwt) {
10727
+ return;
10728
+ }
10729
+ const url = new URL(this.service.origin);
10730
+ url.pathname = `/xrpc/${REFRESH_SESSION}`;
10731
+ const res = await _AtpAgent.fetch(
10732
+ url.toString(),
10733
+ "POST",
10734
+ {
10735
+ authorization: `Bearer ${this.session.refreshJwt}`
10736
+ },
10737
+ void 0
10738
+ );
10739
+ if (isErrorResponse(res, ["ExpiredToken", "InvalidToken"])) {
10740
+ this.session = void 0;
10741
+ this._persistSession?.("expired", void 0);
10742
+ } else if (isNewSessionObject(this._baseClient, res.body)) {
10743
+ this.session = {
10744
+ accessJwt: res.body.accessJwt,
10745
+ refreshJwt: res.body.refreshJwt,
10746
+ handle: res.body.handle,
10747
+ did: res.body.did
10748
+ };
10749
+ this._persistSession?.("update", this.session);
10750
+ }
10388
10751
  }
10389
- active() {
10390
- return !!this.session;
10752
+ };
10753
+ var AtpAgent = _AtpAgent;
10754
+ AtpAgent.fetch = defaultFetchHandler;
10755
+ function isErrorObject(v) {
10756
+ return errorResponseBody.safeParse(v).success;
10757
+ }
10758
+ function isErrorResponse(res, errorNames) {
10759
+ if (res.status !== 400) {
10760
+ return false;
10391
10761
  }
10392
- accessHeaders() {
10393
- return this.session && {
10394
- authorization: `Bearer ${this.session.accessJwt}`
10395
- };
10762
+ if (!isErrorObject(res.body)) {
10763
+ return false;
10396
10764
  }
10397
- refreshHeaders() {
10398
- return this.session && {
10399
- authorization: `Bearer ${this.session.refreshJwt}`
10400
- };
10765
+ return typeof res.body.error === "string" && errorNames.includes(res.body.error);
10766
+ }
10767
+ function isNewSessionObject(client, v) {
10768
+ try {
10769
+ client.xrpc.lex.assertValidXrpcOutput("com.atproto.session.refresh", v);
10770
+ return true;
10771
+ } catch {
10772
+ return false;
10401
10773
  }
10402
- };
10774
+ }
10403
10775
  // Annotate the CommonJS export names for ESM import in node:
10404
10776
  0 && (module.exports = {
10405
10777
  APP_BSKY_GRAPH,
@@ -10408,6 +10780,7 @@ var SessionManager = class extends import_events.default {
10408
10780
  ActorNS,
10409
10781
  AdminNS,
10410
10782
  AppBskyActorGetProfile,
10783
+ AppBskyActorGetProfiles,
10411
10784
  AppBskyActorGetSuggestions,
10412
10785
  AppBskyActorProfile,
10413
10786
  AppBskyActorRef,
@@ -10444,12 +10817,14 @@ var SessionManager = class extends import_events.default {
10444
10817
  AppBskySystemDeclaration,
10445
10818
  AppNS,
10446
10819
  AssertionRecord,
10820
+ AtpAgent,
10821
+ AtpBaseClient,
10822
+ AtpServiceClient,
10447
10823
  AtprotoNS,
10448
10824
  BlobNS,
10449
10825
  BskyNS,
10450
10826
  COM_ATPROTO_ADMIN,
10451
10827
  COM_ATPROTO_REPORT,
10452
- Client,
10453
10828
  ComAtprotoAccountCreate,
10454
10829
  ComAtprotoAccountCreateInviteCode,
10455
10830
  ComAtprotoAccountDelete,
@@ -10457,6 +10832,7 @@ var SessionManager = class extends import_events.default {
10457
10832
  ComAtprotoAccountRequestDelete,
10458
10833
  ComAtprotoAccountRequestPasswordReset,
10459
10834
  ComAtprotoAccountResetPassword,
10835
+ ComAtprotoAdminBlob,
10460
10836
  ComAtprotoAdminGetModerationAction,
10461
10837
  ComAtprotoAdminGetModerationActions,
10462
10838
  ComAtprotoAdminGetModerationReport,
@@ -10511,15 +10887,9 @@ var SessionManager = class extends import_events.default {
10511
10887
  ReportNS,
10512
10888
  RepostRecord,
10513
10889
  ServerNS,
10514
- ServiceClient,
10515
- SessionClient,
10516
- SessionManager,
10517
10890
  SessionNS,
10518
- SessionServiceClient,
10519
- SessionXrpcServiceClient,
10520
10891
  SyncNS,
10521
10892
  SystemNS,
10522
- VoteRecord,
10523
- sessionClient
10893
+ VoteRecord
10524
10894
  });
10525
10895
  //# sourceMappingURL=index.js.map