@atproto/api 0.0.8 → 0.1.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/README.md +44 -6
- package/dist/agent.d.ts +22 -0
- package/dist/client/index.d.ts +60 -61
- package/dist/client/lexicons.d.ts +136 -22
- package/dist/client/types/app/bsky/actor/getSuggestions.d.ts +0 -7
- package/dist/client/types/com/atproto/admin/blob.d.ts +37 -0
- package/dist/client/types/com/atproto/admin/moderationAction.d.ts +13 -2
- package/dist/client/types/com/atproto/admin/record.d.ts +5 -2
- package/dist/client/types/com/atproto/admin/repo.d.ts +2 -2
- package/dist/client/types/com/atproto/admin/takeModerationAction.d.ts +5 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +425 -196
- package/dist/index.js.map +4 -4
- package/dist/types.d.ts +33 -0
- package/package.json +1 -1
- package/src/agent.ts +305 -0
- package/src/client/index.ts +62 -63
- package/src/client/lexicons.ts +169 -36
- package/src/client/types/app/bsky/actor/getSuggestions.ts +0 -18
- package/src/client/types/com/atproto/admin/blob.ts +84 -0
- package/src/client/types/com/atproto/admin/moderationAction.ts +29 -10
- package/src/client/types/com/atproto/admin/record.ts +5 -2
- package/src/client/types/com/atproto/admin/repo.ts +2 -2
- package/src/client/types/com/atproto/admin/takeModerationAction.ts +8 -0
- package/src/index.ts +3 -3
- package/src/types.ts +71 -0
- package/tests/_util.ts +26 -0
- package/tests/agent.test.ts +391 -0
- package/tests/errors.test.ts +4 -8
- package/tsconfig.build.tsbuildinfo +1 -1
- package/src/session.ts +0 -194
- package/tests/session.test.ts +0 -239
package/dist/index.js
CHANGED
|
@@ -120,12 +120,14 @@ __export(src_exports, {
|
|
|
120
120
|
AppBskySystemDeclaration: () => declaration_exports,
|
|
121
121
|
AppNS: () => AppNS,
|
|
122
122
|
AssertionRecord: () => AssertionRecord,
|
|
123
|
+
AtpAgent: () => AtpAgent,
|
|
124
|
+
AtpBaseClient: () => AtpBaseClient,
|
|
125
|
+
AtpServiceClient: () => AtpServiceClient,
|
|
123
126
|
AtprotoNS: () => AtprotoNS,
|
|
124
127
|
BlobNS: () => BlobNS,
|
|
125
128
|
BskyNS: () => BskyNS,
|
|
126
129
|
COM_ATPROTO_ADMIN: () => COM_ATPROTO_ADMIN,
|
|
127
130
|
COM_ATPROTO_REPORT: () => COM_ATPROTO_REPORT,
|
|
128
|
-
Client: () => Client2,
|
|
129
131
|
ComAtprotoAccountCreate: () => create_exports,
|
|
130
132
|
ComAtprotoAccountCreateInviteCode: () => createInviteCode_exports,
|
|
131
133
|
ComAtprotoAccountDelete: () => delete_exports,
|
|
@@ -133,6 +135,7 @@ __export(src_exports, {
|
|
|
133
135
|
ComAtprotoAccountRequestDelete: () => requestDelete_exports,
|
|
134
136
|
ComAtprotoAccountRequestPasswordReset: () => requestPasswordReset_exports,
|
|
135
137
|
ComAtprotoAccountResetPassword: () => resetPassword_exports,
|
|
138
|
+
ComAtprotoAdminBlob: () => blob_exports2,
|
|
136
139
|
ComAtprotoAdminGetModerationAction: () => getModerationAction_exports,
|
|
137
140
|
ComAtprotoAdminGetModerationActions: () => getModerationActions_exports,
|
|
138
141
|
ComAtprotoAdminGetModerationReport: () => getModerationReport_exports,
|
|
@@ -187,17 +190,11 @@ __export(src_exports, {
|
|
|
187
190
|
ReportNS: () => ReportNS,
|
|
188
191
|
RepostRecord: () => RepostRecord,
|
|
189
192
|
ServerNS: () => ServerNS,
|
|
190
|
-
ServiceClient: () => ServiceClient2,
|
|
191
|
-
SessionClient: () => SessionClient,
|
|
192
|
-
SessionManager: () => SessionManager,
|
|
193
193
|
SessionNS: () => SessionNS,
|
|
194
|
-
SessionServiceClient: () => SessionServiceClient,
|
|
195
|
-
SessionXrpcServiceClient: () => SessionXrpcServiceClient,
|
|
196
194
|
SyncNS: () => SyncNS,
|
|
197
195
|
SystemNS: () => SystemNS,
|
|
198
196
|
VoteRecord: () => VoteRecord,
|
|
199
|
-
default: () =>
|
|
200
|
-
sessionClient: () => session_default
|
|
197
|
+
default: () => AtpAgent
|
|
201
198
|
});
|
|
202
199
|
module.exports = __toCommonJS(src_exports);
|
|
203
200
|
|
|
@@ -4536,6 +4533,78 @@ var schemaDict = {
|
|
|
4536
4533
|
}
|
|
4537
4534
|
}
|
|
4538
4535
|
},
|
|
4536
|
+
ComAtprotoAdminBlob: {
|
|
4537
|
+
lexicon: 1,
|
|
4538
|
+
id: "com.atproto.admin.blob",
|
|
4539
|
+
defs: {
|
|
4540
|
+
view: {
|
|
4541
|
+
type: "object",
|
|
4542
|
+
required: ["cid", "mimeType", "size", "createdAt"],
|
|
4543
|
+
properties: {
|
|
4544
|
+
cid: {
|
|
4545
|
+
type: "string"
|
|
4546
|
+
},
|
|
4547
|
+
mimeType: {
|
|
4548
|
+
type: "string"
|
|
4549
|
+
},
|
|
4550
|
+
size: {
|
|
4551
|
+
type: "integer"
|
|
4552
|
+
},
|
|
4553
|
+
createdAt: {
|
|
4554
|
+
type: "datetime"
|
|
4555
|
+
},
|
|
4556
|
+
details: {
|
|
4557
|
+
type: "union",
|
|
4558
|
+
refs: [
|
|
4559
|
+
"lex:com.atproto.admin.blob#imageDetails",
|
|
4560
|
+
"lex:com.atproto.admin.blob#videoDetails"
|
|
4561
|
+
]
|
|
4562
|
+
},
|
|
4563
|
+
moderation: {
|
|
4564
|
+
type: "ref",
|
|
4565
|
+
ref: "lex:com.atproto.admin.blob#moderation"
|
|
4566
|
+
}
|
|
4567
|
+
}
|
|
4568
|
+
},
|
|
4569
|
+
imageDetails: {
|
|
4570
|
+
type: "object",
|
|
4571
|
+
required: ["width", "height"],
|
|
4572
|
+
properties: {
|
|
4573
|
+
width: {
|
|
4574
|
+
type: "integer"
|
|
4575
|
+
},
|
|
4576
|
+
height: {
|
|
4577
|
+
type: "integer"
|
|
4578
|
+
}
|
|
4579
|
+
}
|
|
4580
|
+
},
|
|
4581
|
+
videoDetails: {
|
|
4582
|
+
type: "object",
|
|
4583
|
+
required: ["width", "height", "length"],
|
|
4584
|
+
properties: {
|
|
4585
|
+
width: {
|
|
4586
|
+
type: "integer"
|
|
4587
|
+
},
|
|
4588
|
+
height: {
|
|
4589
|
+
type: "integer"
|
|
4590
|
+
},
|
|
4591
|
+
length: {
|
|
4592
|
+
type: "integer"
|
|
4593
|
+
}
|
|
4594
|
+
}
|
|
4595
|
+
},
|
|
4596
|
+
moderation: {
|
|
4597
|
+
type: "object",
|
|
4598
|
+
required: [],
|
|
4599
|
+
properties: {
|
|
4600
|
+
currentAction: {
|
|
4601
|
+
type: "ref",
|
|
4602
|
+
ref: "lex:com.atproto.admin.moderationAction#viewCurrent"
|
|
4603
|
+
}
|
|
4604
|
+
}
|
|
4605
|
+
}
|
|
4606
|
+
}
|
|
4607
|
+
},
|
|
4539
4608
|
ComAtprotoAdminGetModerationAction: {
|
|
4540
4609
|
lexicon: 1,
|
|
4541
4610
|
id: "com.atproto.admin.getModerationAction",
|
|
@@ -4748,6 +4817,7 @@ var schemaDict = {
|
|
|
4748
4817
|
"id",
|
|
4749
4818
|
"action",
|
|
4750
4819
|
"subject",
|
|
4820
|
+
"subjectBlobCids",
|
|
4751
4821
|
"reason",
|
|
4752
4822
|
"createdBy",
|
|
4753
4823
|
"createdAt",
|
|
@@ -4758,12 +4828,8 @@ var schemaDict = {
|
|
|
4758
4828
|
type: "integer"
|
|
4759
4829
|
},
|
|
4760
4830
|
action: {
|
|
4761
|
-
type: "
|
|
4762
|
-
|
|
4763
|
-
"com.atproto.admin.moderationAction#takedown",
|
|
4764
|
-
"com.atproto.admin.moderationAction#flag",
|
|
4765
|
-
"com.atproto.admin.moderationAction#acknowledge"
|
|
4766
|
-
]
|
|
4831
|
+
type: "ref",
|
|
4832
|
+
ref: "lex:com.atproto.admin.moderationAction#actionType"
|
|
4767
4833
|
},
|
|
4768
4834
|
subject: {
|
|
4769
4835
|
type: "union",
|
|
@@ -4772,6 +4838,12 @@ var schemaDict = {
|
|
|
4772
4838
|
"lex:com.atproto.repo.strongRef"
|
|
4773
4839
|
]
|
|
4774
4840
|
},
|
|
4841
|
+
subjectBlobCids: {
|
|
4842
|
+
type: "array",
|
|
4843
|
+
items: {
|
|
4844
|
+
type: "string"
|
|
4845
|
+
}
|
|
4846
|
+
},
|
|
4775
4847
|
reason: {
|
|
4776
4848
|
type: "string"
|
|
4777
4849
|
},
|
|
@@ -4799,6 +4871,7 @@ var schemaDict = {
|
|
|
4799
4871
|
"id",
|
|
4800
4872
|
"action",
|
|
4801
4873
|
"subject",
|
|
4874
|
+
"subjectBlobs",
|
|
4802
4875
|
"reason",
|
|
4803
4876
|
"createdBy",
|
|
4804
4877
|
"createdAt",
|
|
@@ -4809,12 +4882,8 @@ var schemaDict = {
|
|
|
4809
4882
|
type: "integer"
|
|
4810
4883
|
},
|
|
4811
4884
|
action: {
|
|
4812
|
-
type: "
|
|
4813
|
-
|
|
4814
|
-
"com.atproto.admin.moderationAction#takedown",
|
|
4815
|
-
"com.atproto.admin.moderationAction#flag",
|
|
4816
|
-
"com.atproto.admin.moderationAction#acknowledge"
|
|
4817
|
-
]
|
|
4885
|
+
type: "ref",
|
|
4886
|
+
ref: "lex:com.atproto.admin.moderationAction#actionType"
|
|
4818
4887
|
},
|
|
4819
4888
|
subject: {
|
|
4820
4889
|
type: "union",
|
|
@@ -4823,6 +4892,13 @@ var schemaDict = {
|
|
|
4823
4892
|
"lex:com.atproto.admin.record#view"
|
|
4824
4893
|
]
|
|
4825
4894
|
},
|
|
4895
|
+
subjectBlobs: {
|
|
4896
|
+
type: "array",
|
|
4897
|
+
items: {
|
|
4898
|
+
type: "ref",
|
|
4899
|
+
ref: "lex:com.atproto.admin.blob#view"
|
|
4900
|
+
}
|
|
4901
|
+
},
|
|
4826
4902
|
reason: {
|
|
4827
4903
|
type: "string"
|
|
4828
4904
|
},
|
|
@@ -4845,6 +4921,19 @@ var schemaDict = {
|
|
|
4845
4921
|
}
|
|
4846
4922
|
}
|
|
4847
4923
|
},
|
|
4924
|
+
viewCurrent: {
|
|
4925
|
+
type: "object",
|
|
4926
|
+
required: ["id", "action"],
|
|
4927
|
+
properties: {
|
|
4928
|
+
id: {
|
|
4929
|
+
type: "integer"
|
|
4930
|
+
},
|
|
4931
|
+
action: {
|
|
4932
|
+
type: "ref",
|
|
4933
|
+
ref: "lex:com.atproto.admin.moderationAction#actionType"
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
},
|
|
4848
4937
|
reversal: {
|
|
4849
4938
|
type: "object",
|
|
4850
4939
|
required: ["reason", "createdBy", "createdAt"],
|
|
@@ -4860,6 +4949,14 @@ var schemaDict = {
|
|
|
4860
4949
|
}
|
|
4861
4950
|
}
|
|
4862
4951
|
},
|
|
4952
|
+
actionType: {
|
|
4953
|
+
type: "string",
|
|
4954
|
+
knownValues: [
|
|
4955
|
+
"com.atproto.admin.moderationAction#takedown",
|
|
4956
|
+
"com.atproto.admin.moderationAction#flag",
|
|
4957
|
+
"com.atproto.admin.moderationAction#acknowledge"
|
|
4958
|
+
]
|
|
4959
|
+
},
|
|
4863
4960
|
takedown: {
|
|
4864
4961
|
type: "token",
|
|
4865
4962
|
description: "Moderation action type: Takedown. Indicates that content should not be served by the PDS."
|
|
@@ -4971,7 +5068,15 @@ var schemaDict = {
|
|
|
4971
5068
|
defs: {
|
|
4972
5069
|
view: {
|
|
4973
5070
|
type: "object",
|
|
4974
|
-
required: [
|
|
5071
|
+
required: [
|
|
5072
|
+
"uri",
|
|
5073
|
+
"cid",
|
|
5074
|
+
"value",
|
|
5075
|
+
"blobCids",
|
|
5076
|
+
"indexedAt",
|
|
5077
|
+
"moderation",
|
|
5078
|
+
"repo"
|
|
5079
|
+
],
|
|
4975
5080
|
properties: {
|
|
4976
5081
|
uri: {
|
|
4977
5082
|
type: "string"
|
|
@@ -4982,6 +5087,12 @@ var schemaDict = {
|
|
|
4982
5087
|
value: {
|
|
4983
5088
|
type: "unknown"
|
|
4984
5089
|
},
|
|
5090
|
+
blobCids: {
|
|
5091
|
+
type: "array",
|
|
5092
|
+
items: {
|
|
5093
|
+
type: "string"
|
|
5094
|
+
}
|
|
5095
|
+
},
|
|
4985
5096
|
indexedAt: {
|
|
4986
5097
|
type: "string"
|
|
4987
5098
|
},
|
|
@@ -4997,7 +5108,15 @@ var schemaDict = {
|
|
|
4997
5108
|
},
|
|
4998
5109
|
viewDetail: {
|
|
4999
5110
|
type: "object",
|
|
5000
|
-
required: [
|
|
5111
|
+
required: [
|
|
5112
|
+
"uri",
|
|
5113
|
+
"cid",
|
|
5114
|
+
"value",
|
|
5115
|
+
"blobs",
|
|
5116
|
+
"indexedAt",
|
|
5117
|
+
"moderation",
|
|
5118
|
+
"repo"
|
|
5119
|
+
],
|
|
5001
5120
|
properties: {
|
|
5002
5121
|
uri: {
|
|
5003
5122
|
type: "string"
|
|
@@ -5008,6 +5127,13 @@ var schemaDict = {
|
|
|
5008
5127
|
value: {
|
|
5009
5128
|
type: "unknown"
|
|
5010
5129
|
},
|
|
5130
|
+
blobs: {
|
|
5131
|
+
type: "array",
|
|
5132
|
+
items: {
|
|
5133
|
+
type: "ref",
|
|
5134
|
+
ref: "lex:com.atproto.admin.blob#view"
|
|
5135
|
+
}
|
|
5136
|
+
},
|
|
5011
5137
|
indexedAt: {
|
|
5012
5138
|
type: "string"
|
|
5013
5139
|
},
|
|
@@ -5025,8 +5151,9 @@ var schemaDict = {
|
|
|
5025
5151
|
type: "object",
|
|
5026
5152
|
required: [],
|
|
5027
5153
|
properties: {
|
|
5028
|
-
|
|
5029
|
-
type: "
|
|
5154
|
+
currentAction: {
|
|
5155
|
+
type: "ref",
|
|
5156
|
+
ref: "lex:com.atproto.admin.moderationAction#viewCurrent"
|
|
5030
5157
|
}
|
|
5031
5158
|
}
|
|
5032
5159
|
},
|
|
@@ -5034,6 +5161,10 @@ var schemaDict = {
|
|
|
5034
5161
|
type: "object",
|
|
5035
5162
|
required: ["actions", "reports"],
|
|
5036
5163
|
properties: {
|
|
5164
|
+
currentAction: {
|
|
5165
|
+
type: "ref",
|
|
5166
|
+
ref: "lex:com.atproto.admin.moderationAction#viewCurrent"
|
|
5167
|
+
},
|
|
5037
5168
|
actions: {
|
|
5038
5169
|
type: "array",
|
|
5039
5170
|
items: {
|
|
@@ -5047,9 +5178,6 @@ var schemaDict = {
|
|
|
5047
5178
|
type: "ref",
|
|
5048
5179
|
ref: "lex:com.atproto.admin.moderationReport#view"
|
|
5049
5180
|
}
|
|
5050
|
-
},
|
|
5051
|
-
takedownId: {
|
|
5052
|
-
type: "integer"
|
|
5053
5181
|
}
|
|
5054
5182
|
}
|
|
5055
5183
|
}
|
|
@@ -5142,8 +5270,9 @@ var schemaDict = {
|
|
|
5142
5270
|
type: "object",
|
|
5143
5271
|
required: [],
|
|
5144
5272
|
properties: {
|
|
5145
|
-
|
|
5146
|
-
type: "
|
|
5273
|
+
currentAction: {
|
|
5274
|
+
type: "ref",
|
|
5275
|
+
ref: "lex:com.atproto.admin.moderationAction#viewCurrent"
|
|
5147
5276
|
}
|
|
5148
5277
|
}
|
|
5149
5278
|
},
|
|
@@ -5151,6 +5280,10 @@ var schemaDict = {
|
|
|
5151
5280
|
type: "object",
|
|
5152
5281
|
required: ["actions", "reports"],
|
|
5153
5282
|
properties: {
|
|
5283
|
+
currentAction: {
|
|
5284
|
+
type: "ref",
|
|
5285
|
+
ref: "lex:com.atproto.admin.moderationAction#viewCurrent"
|
|
5286
|
+
},
|
|
5154
5287
|
actions: {
|
|
5155
5288
|
type: "array",
|
|
5156
5289
|
items: {
|
|
@@ -5164,9 +5297,6 @@ var schemaDict = {
|
|
|
5164
5297
|
type: "ref",
|
|
5165
5298
|
ref: "lex:com.atproto.admin.moderationReport#view"
|
|
5166
5299
|
}
|
|
5167
|
-
},
|
|
5168
|
-
takedownId: {
|
|
5169
|
-
type: "integer"
|
|
5170
5300
|
}
|
|
5171
5301
|
}
|
|
5172
5302
|
}
|
|
@@ -5319,6 +5449,12 @@ var schemaDict = {
|
|
|
5319
5449
|
"lex:com.atproto.repo.recordRef"
|
|
5320
5450
|
]
|
|
5321
5451
|
},
|
|
5452
|
+
subjectBlobCids: {
|
|
5453
|
+
type: "array",
|
|
5454
|
+
items: {
|
|
5455
|
+
type: "string"
|
|
5456
|
+
}
|
|
5457
|
+
},
|
|
5322
5458
|
reason: {
|
|
5323
5459
|
type: "string"
|
|
5324
5460
|
},
|
|
@@ -5334,7 +5470,12 @@ var schemaDict = {
|
|
|
5334
5470
|
type: "ref",
|
|
5335
5471
|
ref: "lex:com.atproto.admin.moderationAction#view"
|
|
5336
5472
|
}
|
|
5337
|
-
}
|
|
5473
|
+
},
|
|
5474
|
+
errors: [
|
|
5475
|
+
{
|
|
5476
|
+
name: "SubjectHasAction"
|
|
5477
|
+
}
|
|
5478
|
+
]
|
|
5338
5479
|
}
|
|
5339
5480
|
}
|
|
5340
5481
|
},
|
|
@@ -6482,18 +6623,6 @@ var schemaDict = {
|
|
|
6482
6623
|
},
|
|
6483
6624
|
indexedAt: {
|
|
6484
6625
|
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
6626
|
}
|
|
6498
6627
|
}
|
|
6499
6628
|
}
|
|
@@ -8369,10 +8498,18 @@ function toKnownErr16(e) {
|
|
|
8369
8498
|
// src/client/types/com/atproto/admin/takeModerationAction.ts
|
|
8370
8499
|
var takeModerationAction_exports = {};
|
|
8371
8500
|
__export(takeModerationAction_exports, {
|
|
8501
|
+
SubjectHasActionError: () => SubjectHasActionError,
|
|
8372
8502
|
toKnownErr: () => toKnownErr17
|
|
8373
8503
|
});
|
|
8504
|
+
var SubjectHasActionError = class extends XRPCError {
|
|
8505
|
+
constructor(src) {
|
|
8506
|
+
super(src.status, src.error, src.message);
|
|
8507
|
+
}
|
|
8508
|
+
};
|
|
8374
8509
|
function toKnownErr17(e) {
|
|
8375
8510
|
if (e instanceof XRPCError) {
|
|
8511
|
+
if (e.error === "SubjectHasAction")
|
|
8512
|
+
return new SubjectHasActionError(e);
|
|
8376
8513
|
}
|
|
8377
8514
|
return e;
|
|
8378
8515
|
}
|
|
@@ -8686,10 +8823,8 @@ function validateMyState(v) {
|
|
|
8686
8823
|
var getSuggestions_exports = {};
|
|
8687
8824
|
__export(getSuggestions_exports, {
|
|
8688
8825
|
isActor: () => isActor,
|
|
8689
|
-
isMyState: () => isMyState2,
|
|
8690
8826
|
toKnownErr: () => toKnownErr39,
|
|
8691
|
-
validateActor: () => validateActor
|
|
8692
|
-
validateMyState: () => validateMyState2
|
|
8827
|
+
validateActor: () => validateActor
|
|
8693
8828
|
});
|
|
8694
8829
|
function toKnownErr39(e) {
|
|
8695
8830
|
if (e instanceof XRPCError) {
|
|
@@ -8702,12 +8837,6 @@ function isActor(v) {
|
|
|
8702
8837
|
function validateActor(v) {
|
|
8703
8838
|
return lexicons.validate("app.bsky.actor.getSuggestions#actor", v);
|
|
8704
8839
|
}
|
|
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
8840
|
|
|
8712
8841
|
// src/client/types/app/bsky/actor/search.ts
|
|
8713
8842
|
var search_exports = {};
|
|
@@ -9016,6 +9145,43 @@ function toKnownErr56(e) {
|
|
|
9016
9145
|
return e;
|
|
9017
9146
|
}
|
|
9018
9147
|
|
|
9148
|
+
// src/client/types/com/atproto/admin/blob.ts
|
|
9149
|
+
var blob_exports2 = {};
|
|
9150
|
+
__export(blob_exports2, {
|
|
9151
|
+
isImageDetails: () => isImageDetails,
|
|
9152
|
+
isModeration: () => isModeration,
|
|
9153
|
+
isVideoDetails: () => isVideoDetails,
|
|
9154
|
+
isView: () => isView,
|
|
9155
|
+
validateImageDetails: () => validateImageDetails,
|
|
9156
|
+
validateModeration: () => validateModeration,
|
|
9157
|
+
validateVideoDetails: () => validateVideoDetails,
|
|
9158
|
+
validateView: () => validateView
|
|
9159
|
+
});
|
|
9160
|
+
function isView(v) {
|
|
9161
|
+
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.blob#view";
|
|
9162
|
+
}
|
|
9163
|
+
function validateView(v) {
|
|
9164
|
+
return lexicons.validate("com.atproto.admin.blob#view", v);
|
|
9165
|
+
}
|
|
9166
|
+
function isImageDetails(v) {
|
|
9167
|
+
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.blob#imageDetails";
|
|
9168
|
+
}
|
|
9169
|
+
function validateImageDetails(v) {
|
|
9170
|
+
return lexicons.validate("com.atproto.admin.blob#imageDetails", v);
|
|
9171
|
+
}
|
|
9172
|
+
function isVideoDetails(v) {
|
|
9173
|
+
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.blob#videoDetails";
|
|
9174
|
+
}
|
|
9175
|
+
function validateVideoDetails(v) {
|
|
9176
|
+
return lexicons.validate("com.atproto.admin.blob#videoDetails", v);
|
|
9177
|
+
}
|
|
9178
|
+
function isModeration(v) {
|
|
9179
|
+
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.blob#moderation";
|
|
9180
|
+
}
|
|
9181
|
+
function validateModeration(v) {
|
|
9182
|
+
return lexicons.validate("com.atproto.admin.blob#moderation", v);
|
|
9183
|
+
}
|
|
9184
|
+
|
|
9019
9185
|
// src/client/types/com/atproto/admin/moderationAction.ts
|
|
9020
9186
|
var moderationAction_exports = {};
|
|
9021
9187
|
__export(moderationAction_exports, {
|
|
@@ -9023,16 +9189,18 @@ __export(moderationAction_exports, {
|
|
|
9023
9189
|
FLAG: () => FLAG,
|
|
9024
9190
|
TAKEDOWN: () => TAKEDOWN,
|
|
9025
9191
|
isReversal: () => isReversal,
|
|
9026
|
-
isView: () =>
|
|
9192
|
+
isView: () => isView2,
|
|
9193
|
+
isViewCurrent: () => isViewCurrent,
|
|
9027
9194
|
isViewDetail: () => isViewDetail,
|
|
9028
9195
|
validateReversal: () => validateReversal,
|
|
9029
|
-
validateView: () =>
|
|
9196
|
+
validateView: () => validateView2,
|
|
9197
|
+
validateViewCurrent: () => validateViewCurrent,
|
|
9030
9198
|
validateViewDetail: () => validateViewDetail
|
|
9031
9199
|
});
|
|
9032
|
-
function
|
|
9200
|
+
function isView2(v) {
|
|
9033
9201
|
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.moderationAction#view";
|
|
9034
9202
|
}
|
|
9035
|
-
function
|
|
9203
|
+
function validateView2(v) {
|
|
9036
9204
|
return lexicons.validate("com.atproto.admin.moderationAction#view", v);
|
|
9037
9205
|
}
|
|
9038
9206
|
function isViewDetail(v) {
|
|
@@ -9041,6 +9209,12 @@ function isViewDetail(v) {
|
|
|
9041
9209
|
function validateViewDetail(v) {
|
|
9042
9210
|
return lexicons.validate("com.atproto.admin.moderationAction#viewDetail", v);
|
|
9043
9211
|
}
|
|
9212
|
+
function isViewCurrent(v) {
|
|
9213
|
+
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.moderationAction#viewCurrent";
|
|
9214
|
+
}
|
|
9215
|
+
function validateViewCurrent(v) {
|
|
9216
|
+
return lexicons.validate("com.atproto.admin.moderationAction#viewCurrent", v);
|
|
9217
|
+
}
|
|
9044
9218
|
function isReversal(v) {
|
|
9045
9219
|
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.moderationAction#reversal";
|
|
9046
9220
|
}
|
|
@@ -9054,15 +9228,15 @@ var ACKNOWLEDGE = "com.atproto.admin.moderationAction#acknowledge";
|
|
|
9054
9228
|
// src/client/types/com/atproto/admin/moderationReport.ts
|
|
9055
9229
|
var moderationReport_exports = {};
|
|
9056
9230
|
__export(moderationReport_exports, {
|
|
9057
|
-
isView: () =>
|
|
9231
|
+
isView: () => isView3,
|
|
9058
9232
|
isViewDetail: () => isViewDetail2,
|
|
9059
|
-
validateView: () =>
|
|
9233
|
+
validateView: () => validateView3,
|
|
9060
9234
|
validateViewDetail: () => validateViewDetail2
|
|
9061
9235
|
});
|
|
9062
|
-
function
|
|
9236
|
+
function isView3(v) {
|
|
9063
9237
|
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.moderationReport#view";
|
|
9064
9238
|
}
|
|
9065
|
-
function
|
|
9239
|
+
function validateView3(v) {
|
|
9066
9240
|
return lexicons.validate("com.atproto.admin.moderationReport#view", v);
|
|
9067
9241
|
}
|
|
9068
9242
|
function isViewDetail2(v) {
|
|
@@ -9075,19 +9249,19 @@ function validateViewDetail2(v) {
|
|
|
9075
9249
|
// src/client/types/com/atproto/admin/record.ts
|
|
9076
9250
|
var record_exports = {};
|
|
9077
9251
|
__export(record_exports, {
|
|
9078
|
-
isModeration: () =>
|
|
9252
|
+
isModeration: () => isModeration2,
|
|
9079
9253
|
isModerationDetail: () => isModerationDetail,
|
|
9080
|
-
isView: () =>
|
|
9254
|
+
isView: () => isView4,
|
|
9081
9255
|
isViewDetail: () => isViewDetail3,
|
|
9082
|
-
validateModeration: () =>
|
|
9256
|
+
validateModeration: () => validateModeration2,
|
|
9083
9257
|
validateModerationDetail: () => validateModerationDetail,
|
|
9084
|
-
validateView: () =>
|
|
9258
|
+
validateView: () => validateView4,
|
|
9085
9259
|
validateViewDetail: () => validateViewDetail3
|
|
9086
9260
|
});
|
|
9087
|
-
function
|
|
9261
|
+
function isView4(v) {
|
|
9088
9262
|
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.record#view";
|
|
9089
9263
|
}
|
|
9090
|
-
function
|
|
9264
|
+
function validateView4(v) {
|
|
9091
9265
|
return lexicons.validate("com.atproto.admin.record#view", v);
|
|
9092
9266
|
}
|
|
9093
9267
|
function isViewDetail3(v) {
|
|
@@ -9096,10 +9270,10 @@ function isViewDetail3(v) {
|
|
|
9096
9270
|
function validateViewDetail3(v) {
|
|
9097
9271
|
return lexicons.validate("com.atproto.admin.record#viewDetail", v);
|
|
9098
9272
|
}
|
|
9099
|
-
function
|
|
9273
|
+
function isModeration2(v) {
|
|
9100
9274
|
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.record#moderation";
|
|
9101
9275
|
}
|
|
9102
|
-
function
|
|
9276
|
+
function validateModeration2(v) {
|
|
9103
9277
|
return lexicons.validate("com.atproto.admin.record#moderation", v);
|
|
9104
9278
|
}
|
|
9105
9279
|
function isModerationDetail(v) {
|
|
@@ -9113,20 +9287,20 @@ function validateModerationDetail(v) {
|
|
|
9113
9287
|
var repo_exports = {};
|
|
9114
9288
|
__export(repo_exports, {
|
|
9115
9289
|
isAccount: () => isAccount,
|
|
9116
|
-
isModeration: () =>
|
|
9290
|
+
isModeration: () => isModeration3,
|
|
9117
9291
|
isModerationDetail: () => isModerationDetail2,
|
|
9118
|
-
isView: () =>
|
|
9292
|
+
isView: () => isView5,
|
|
9119
9293
|
isViewDetail: () => isViewDetail4,
|
|
9120
9294
|
validateAccount: () => validateAccount,
|
|
9121
|
-
validateModeration: () =>
|
|
9295
|
+
validateModeration: () => validateModeration3,
|
|
9122
9296
|
validateModerationDetail: () => validateModerationDetail2,
|
|
9123
|
-
validateView: () =>
|
|
9297
|
+
validateView: () => validateView5,
|
|
9124
9298
|
validateViewDetail: () => validateViewDetail4
|
|
9125
9299
|
});
|
|
9126
|
-
function
|
|
9300
|
+
function isView5(v) {
|
|
9127
9301
|
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.repo#view";
|
|
9128
9302
|
}
|
|
9129
|
-
function
|
|
9303
|
+
function validateView5(v) {
|
|
9130
9304
|
return lexicons.validate("com.atproto.admin.repo#view", v);
|
|
9131
9305
|
}
|
|
9132
9306
|
function isViewDetail4(v) {
|
|
@@ -9141,10 +9315,10 @@ function isAccount(v) {
|
|
|
9141
9315
|
function validateAccount(v) {
|
|
9142
9316
|
return lexicons.validate("com.atproto.admin.repo#account", v);
|
|
9143
9317
|
}
|
|
9144
|
-
function
|
|
9318
|
+
function isModeration3(v) {
|
|
9145
9319
|
return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.admin.repo#moderation";
|
|
9146
9320
|
}
|
|
9147
|
-
function
|
|
9321
|
+
function validateModeration3(v) {
|
|
9148
9322
|
return lexicons.validate("com.atproto.admin.repo#moderation", v);
|
|
9149
9323
|
}
|
|
9150
9324
|
function isModerationDetail2(v) {
|
|
@@ -9383,13 +9557,13 @@ __export(post_exports, {
|
|
|
9383
9557
|
isRecord: () => isRecord4,
|
|
9384
9558
|
isReplyRef: () => isReplyRef2,
|
|
9385
9559
|
isTextSlice: () => isTextSlice,
|
|
9386
|
-
isView: () =>
|
|
9560
|
+
isView: () => isView6,
|
|
9387
9561
|
isViewerState: () => isViewerState2,
|
|
9388
9562
|
validateEntity: () => validateEntity,
|
|
9389
9563
|
validateRecord: () => validateRecord4,
|
|
9390
9564
|
validateReplyRef: () => validateReplyRef2,
|
|
9391
9565
|
validateTextSlice: () => validateTextSlice,
|
|
9392
|
-
validateView: () =>
|
|
9566
|
+
validateView: () => validateView6,
|
|
9393
9567
|
validateViewerState: () => validateViewerState2
|
|
9394
9568
|
});
|
|
9395
9569
|
function isRecord4(v) {
|
|
@@ -9416,10 +9590,10 @@ function isTextSlice(v) {
|
|
|
9416
9590
|
function validateTextSlice(v) {
|
|
9417
9591
|
return lexicons.validate("app.bsky.feed.post#textSlice", v);
|
|
9418
9592
|
}
|
|
9419
|
-
function
|
|
9593
|
+
function isView6(v) {
|
|
9420
9594
|
return isObj2(v) && hasProp2(v, "$type") && v.$type === "app.bsky.feed.post#view";
|
|
9421
9595
|
}
|
|
9422
|
-
function
|
|
9596
|
+
function validateView6(v) {
|
|
9423
9597
|
return lexicons.validate("app.bsky.feed.post#view", v);
|
|
9424
9598
|
}
|
|
9425
9599
|
function isViewerState2(v) {
|
|
@@ -9558,18 +9732,16 @@ var APP_BSKY_GRAPH = {
|
|
|
9558
9732
|
var APP_BSKY_SYSTEM = {
|
|
9559
9733
|
ActorUser: "app.bsky.system.actorUser"
|
|
9560
9734
|
};
|
|
9561
|
-
var
|
|
9735
|
+
var AtpBaseClient = class {
|
|
9562
9736
|
constructor() {
|
|
9563
9737
|
this.xrpc = new Client();
|
|
9564
9738
|
this.xrpc.addLexicons(schemas);
|
|
9565
9739
|
}
|
|
9566
9740
|
service(serviceUri) {
|
|
9567
|
-
return new
|
|
9741
|
+
return new AtpServiceClient(this, this.xrpc.service(serviceUri));
|
|
9568
9742
|
}
|
|
9569
9743
|
};
|
|
9570
|
-
var
|
|
9571
|
-
var client_default = defaultInst2;
|
|
9572
|
-
var ServiceClient2 = class {
|
|
9744
|
+
var AtpServiceClient = class {
|
|
9573
9745
|
constructor(baseClient, xrpcService) {
|
|
9574
9746
|
this._baseClient = baseClient;
|
|
9575
9747
|
this.xrpc = xrpcService;
|
|
@@ -10277,129 +10449,189 @@ var DeclarationRecord = class {
|
|
|
10277
10449
|
}
|
|
10278
10450
|
};
|
|
10279
10451
|
|
|
10280
|
-
// src/
|
|
10281
|
-
var import_events = __toESM(require("events"));
|
|
10282
|
-
var CREATE_SESSION = "com.atproto.session.create";
|
|
10452
|
+
// src/agent.ts
|
|
10283
10453
|
var REFRESH_SESSION = "com.atproto.session.refresh";
|
|
10284
|
-
var
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10454
|
+
var _AtpAgent = class {
|
|
10455
|
+
static configure(opts) {
|
|
10456
|
+
_AtpAgent.fetch = opts.fetch;
|
|
10457
|
+
}
|
|
10458
|
+
constructor(opts) {
|
|
10459
|
+
this.service = opts.service instanceof URL ? opts.service : new URL(opts.service);
|
|
10460
|
+
this._persistSession = opts.persistSession;
|
|
10461
|
+
this._baseClient = new AtpBaseClient();
|
|
10462
|
+
this._baseClient.xrpc.fetch = this._fetch.bind(this);
|
|
10463
|
+
this.api = this._baseClient.service(opts.service);
|
|
10464
|
+
}
|
|
10465
|
+
get hasSession() {
|
|
10466
|
+
return !!this.session;
|
|
10290
10467
|
}
|
|
10291
|
-
|
|
10292
|
-
|
|
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;
|
|
10468
|
+
setPersistSessionHandler(handler) {
|
|
10469
|
+
this._persistSession = handler;
|
|
10298
10470
|
}
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10471
|
+
async createAccount(opts) {
|
|
10472
|
+
try {
|
|
10473
|
+
const res = await this.api.com.atproto.account.create({
|
|
10474
|
+
handle: opts.handle,
|
|
10475
|
+
password: opts.password,
|
|
10476
|
+
email: opts.email,
|
|
10477
|
+
inviteCode: opts.inviteCode
|
|
10478
|
+
});
|
|
10479
|
+
this.session = {
|
|
10480
|
+
accessJwt: res.data.accessJwt,
|
|
10481
|
+
refreshJwt: res.data.refreshJwt,
|
|
10482
|
+
handle: res.data.handle,
|
|
10483
|
+
did: res.data.did
|
|
10484
|
+
};
|
|
10485
|
+
return res;
|
|
10486
|
+
} catch (e) {
|
|
10487
|
+
this.session = void 0;
|
|
10488
|
+
throw e;
|
|
10489
|
+
} finally {
|
|
10490
|
+
if (this.session) {
|
|
10491
|
+
this._persistSession?.("create", this.session);
|
|
10308
10492
|
} else {
|
|
10309
|
-
this.
|
|
10493
|
+
this._persistSession?.("create-failed", void 0);
|
|
10310
10494
|
}
|
|
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
10495
|
}
|
|
10496
|
+
}
|
|
10497
|
+
async login(opts) {
|
|
10339
10498
|
try {
|
|
10340
|
-
|
|
10341
|
-
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10499
|
+
const res = await this.api.com.atproto.session.create({
|
|
10500
|
+
identifier: opts.identifier,
|
|
10501
|
+
password: opts.password
|
|
10502
|
+
});
|
|
10503
|
+
this.session = {
|
|
10504
|
+
accessJwt: res.data.accessJwt,
|
|
10505
|
+
refreshJwt: res.data.refreshJwt,
|
|
10506
|
+
handle: res.data.handle,
|
|
10507
|
+
did: res.data.did
|
|
10508
|
+
};
|
|
10509
|
+
return res;
|
|
10510
|
+
} catch (e) {
|
|
10511
|
+
this.session = void 0;
|
|
10512
|
+
throw e;
|
|
10513
|
+
} finally {
|
|
10514
|
+
if (this.session) {
|
|
10515
|
+
this._persistSession?.("create", this.session);
|
|
10516
|
+
} else {
|
|
10517
|
+
this._persistSession?.("create-failed", void 0);
|
|
10345
10518
|
}
|
|
10346
|
-
throw err;
|
|
10347
10519
|
}
|
|
10348
10520
|
}
|
|
10349
|
-
async
|
|
10350
|
-
this.refreshing ?? (this.refreshing = this._refresh(opts));
|
|
10521
|
+
async resumeSession(session) {
|
|
10351
10522
|
try {
|
|
10352
|
-
|
|
10523
|
+
this.session = session;
|
|
10524
|
+
const res = await this.api.com.atproto.session.get();
|
|
10525
|
+
if (!res.success || res.data.did !== this.session.did) {
|
|
10526
|
+
throw new Error("Invalid session");
|
|
10527
|
+
}
|
|
10528
|
+
return res;
|
|
10529
|
+
} catch (e) {
|
|
10530
|
+
this.session = void 0;
|
|
10531
|
+
throw e;
|
|
10353
10532
|
} finally {
|
|
10354
|
-
this.
|
|
10533
|
+
if (this.session) {
|
|
10534
|
+
this._persistSession?.("create", this.session);
|
|
10535
|
+
} else {
|
|
10536
|
+
this._persistSession?.("create-failed", void 0);
|
|
10537
|
+
}
|
|
10355
10538
|
}
|
|
10356
10539
|
}
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
...
|
|
10361
|
-
|
|
10362
|
-
|
|
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;
|
|
10540
|
+
_addAuthHeader(reqHeaders) {
|
|
10541
|
+
if (!reqHeaders.authorization && this.session?.accessJwt) {
|
|
10542
|
+
return {
|
|
10543
|
+
...reqHeaders,
|
|
10544
|
+
authorization: `Bearer ${this.session.accessJwt}`
|
|
10545
|
+
};
|
|
10374
10546
|
}
|
|
10547
|
+
return reqHeaders;
|
|
10375
10548
|
}
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10549
|
+
async _fetch(reqUri, reqMethod, reqHeaders, reqBody) {
|
|
10550
|
+
if (!_AtpAgent.fetch) {
|
|
10551
|
+
throw new Error("AtpAgent fetch() method not configured");
|
|
10552
|
+
}
|
|
10553
|
+
await this._refreshSessionPromise;
|
|
10554
|
+
let res = await _AtpAgent.fetch(
|
|
10555
|
+
reqUri,
|
|
10556
|
+
reqMethod,
|
|
10557
|
+
this._addAuthHeader(reqHeaders),
|
|
10558
|
+
reqBody
|
|
10559
|
+
);
|
|
10560
|
+
if (isErrorResponse(res, ["ExpiredToken"]) && this.session?.refreshJwt) {
|
|
10561
|
+
await this._refreshSession();
|
|
10562
|
+
res = await _AtpAgent.fetch(
|
|
10563
|
+
reqUri,
|
|
10564
|
+
reqMethod,
|
|
10565
|
+
this._addAuthHeader(reqHeaders),
|
|
10566
|
+
reqBody
|
|
10567
|
+
);
|
|
10568
|
+
}
|
|
10569
|
+
return res;
|
|
10380
10570
|
}
|
|
10381
|
-
|
|
10382
|
-
this.
|
|
10383
|
-
|
|
10571
|
+
async _refreshSession() {
|
|
10572
|
+
if (this._refreshSessionPromise) {
|
|
10573
|
+
return this._refreshSessionPromise;
|
|
10574
|
+
}
|
|
10575
|
+
this._refreshSessionPromise = this._refreshSessionInner();
|
|
10576
|
+
try {
|
|
10577
|
+
await this._refreshSessionPromise;
|
|
10578
|
+
} finally {
|
|
10579
|
+
this._refreshSessionPromise = void 0;
|
|
10580
|
+
}
|
|
10384
10581
|
}
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10582
|
+
async _refreshSessionInner() {
|
|
10583
|
+
if (!_AtpAgent.fetch) {
|
|
10584
|
+
throw new Error("AtpAgent fetch() method not configured");
|
|
10585
|
+
}
|
|
10586
|
+
if (!this.session?.refreshJwt) {
|
|
10587
|
+
return;
|
|
10588
|
+
}
|
|
10589
|
+
const url = new URL(this.service.origin);
|
|
10590
|
+
url.pathname = `/xrpc/${REFRESH_SESSION}`;
|
|
10591
|
+
const res = await _AtpAgent.fetch(
|
|
10592
|
+
url.toString(),
|
|
10593
|
+
"POST",
|
|
10594
|
+
{
|
|
10595
|
+
authorization: `Bearer ${this.session.refreshJwt}`
|
|
10596
|
+
},
|
|
10597
|
+
void 0
|
|
10598
|
+
);
|
|
10599
|
+
if (isErrorResponse(res, ["ExpiredToken", "InvalidToken"])) {
|
|
10600
|
+
this.session = void 0;
|
|
10601
|
+
this._persistSession?.("expired", void 0);
|
|
10602
|
+
} else if (isNewSessionObject(this._baseClient, res.body)) {
|
|
10603
|
+
this.session = {
|
|
10604
|
+
accessJwt: res.body.accessJwt,
|
|
10605
|
+
refreshJwt: res.body.refreshJwt,
|
|
10606
|
+
handle: res.body.handle,
|
|
10607
|
+
did: res.body.did
|
|
10608
|
+
};
|
|
10609
|
+
this._persistSession?.("update", this.session);
|
|
10610
|
+
}
|
|
10388
10611
|
}
|
|
10389
|
-
|
|
10390
|
-
|
|
10612
|
+
};
|
|
10613
|
+
var AtpAgent = _AtpAgent;
|
|
10614
|
+
AtpAgent.fetch = defaultFetchHandler;
|
|
10615
|
+
function isErrorObject(v) {
|
|
10616
|
+
return errorResponseBody.safeParse(v).success;
|
|
10617
|
+
}
|
|
10618
|
+
function isErrorResponse(res, errorNames) {
|
|
10619
|
+
if (res.status !== 400) {
|
|
10620
|
+
return false;
|
|
10391
10621
|
}
|
|
10392
|
-
|
|
10393
|
-
return
|
|
10394
|
-
authorization: `Bearer ${this.session.accessJwt}`
|
|
10395
|
-
};
|
|
10622
|
+
if (!isErrorObject(res.body)) {
|
|
10623
|
+
return false;
|
|
10396
10624
|
}
|
|
10397
|
-
|
|
10398
|
-
|
|
10399
|
-
|
|
10400
|
-
|
|
10625
|
+
return typeof res.body.error === "string" && errorNames.includes(res.body.error);
|
|
10626
|
+
}
|
|
10627
|
+
function isNewSessionObject(client, v) {
|
|
10628
|
+
try {
|
|
10629
|
+
client.xrpc.lex.assertValidXrpcOutput("com.atproto.session.refresh", v);
|
|
10630
|
+
return true;
|
|
10631
|
+
} catch {
|
|
10632
|
+
return false;
|
|
10401
10633
|
}
|
|
10402
|
-
}
|
|
10634
|
+
}
|
|
10403
10635
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10404
10636
|
0 && (module.exports = {
|
|
10405
10637
|
APP_BSKY_GRAPH,
|
|
@@ -10444,12 +10676,14 @@ var SessionManager = class extends import_events.default {
|
|
|
10444
10676
|
AppBskySystemDeclaration,
|
|
10445
10677
|
AppNS,
|
|
10446
10678
|
AssertionRecord,
|
|
10679
|
+
AtpAgent,
|
|
10680
|
+
AtpBaseClient,
|
|
10681
|
+
AtpServiceClient,
|
|
10447
10682
|
AtprotoNS,
|
|
10448
10683
|
BlobNS,
|
|
10449
10684
|
BskyNS,
|
|
10450
10685
|
COM_ATPROTO_ADMIN,
|
|
10451
10686
|
COM_ATPROTO_REPORT,
|
|
10452
|
-
Client,
|
|
10453
10687
|
ComAtprotoAccountCreate,
|
|
10454
10688
|
ComAtprotoAccountCreateInviteCode,
|
|
10455
10689
|
ComAtprotoAccountDelete,
|
|
@@ -10457,6 +10691,7 @@ var SessionManager = class extends import_events.default {
|
|
|
10457
10691
|
ComAtprotoAccountRequestDelete,
|
|
10458
10692
|
ComAtprotoAccountRequestPasswordReset,
|
|
10459
10693
|
ComAtprotoAccountResetPassword,
|
|
10694
|
+
ComAtprotoAdminBlob,
|
|
10460
10695
|
ComAtprotoAdminGetModerationAction,
|
|
10461
10696
|
ComAtprotoAdminGetModerationActions,
|
|
10462
10697
|
ComAtprotoAdminGetModerationReport,
|
|
@@ -10511,15 +10746,9 @@ var SessionManager = class extends import_events.default {
|
|
|
10511
10746
|
ReportNS,
|
|
10512
10747
|
RepostRecord,
|
|
10513
10748
|
ServerNS,
|
|
10514
|
-
ServiceClient,
|
|
10515
|
-
SessionClient,
|
|
10516
|
-
SessionManager,
|
|
10517
10749
|
SessionNS,
|
|
10518
|
-
SessionServiceClient,
|
|
10519
|
-
SessionXrpcServiceClient,
|
|
10520
10750
|
SyncNS,
|
|
10521
10751
|
SystemNS,
|
|
10522
|
-
VoteRecord
|
|
10523
|
-
sessionClient
|
|
10752
|
+
VoteRecord
|
|
10524
10753
|
});
|
|
10525
10754
|
//# sourceMappingURL=index.js.map
|