@atproto/api 0.3.2 → 0.3.4

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 (309) hide show
  1. package/bench/agent.bench.ts +9 -0
  2. package/dist/client/index.d.ts +6 -0
  3. package/dist/client/lexicons.d.ts +116 -0
  4. package/dist/client/types/app/bsky/actor/defs.d.ts +17 -0
  5. package/dist/client/types/app/bsky/actor/{searchActorTypeahead.d.ts → getPreferences.d.ts} +1 -3
  6. package/dist/client/types/app/bsky/{feed/unbookmarkFeed.d.ts → actor/putPreferences.d.ts} +2 -1
  7. package/dist/client/types/com/atproto/admin/defs.d.ts +14 -2
  8. package/dist/client/types/com/atproto/admin/getModerationReports.d.ts +1 -0
  9. package/dist/client/types/com/atproto/admin/getRecord.d.ts +4 -1
  10. package/dist/client/types/com/atproto/admin/getRepo.d.ts +4 -1
  11. package/dist/client/types/com/atproto/server/createAccount.d.ts +7 -0
  12. package/dist/index.js +9113 -83
  13. package/dist/index.js.map +4 -4
  14. package/docs/rn-fetch-handler.ts +1 -1
  15. package/jest.bench.config.js +8 -0
  16. package/package.json +4 -2
  17. package/src/client/index.ts +26 -0
  18. package/src/client/lexicons.ts +138 -0
  19. package/src/client/types/app/bsky/actor/defs.ts +41 -0
  20. package/src/client/types/app/bsky/actor/getPreferences.ts +34 -0
  21. package/src/client/types/app/bsky/actor/putPreferences.ts +33 -0
  22. package/src/client/types/com/atproto/admin/defs.ts +46 -2
  23. package/src/client/types/com/atproto/admin/getModerationReports.ts +6 -0
  24. package/src/client/types/com/atproto/admin/getRecord.ts +7 -0
  25. package/src/client/types/com/atproto/admin/getRepo.ts +7 -0
  26. package/src/client/types/com/atproto/server/createAccount.ts +15 -0
  27. package/tests/agent.test.ts +63 -0
  28. package/tests/bsky-agent.test.ts +63 -0
  29. package/tsconfig.build.tsbuildinfo +1 -1
  30. package/dist/client/types/app/bsky/actor/createScene.d.ts +0 -32
  31. package/dist/client/types/app/bsky/actor/ref.d.ts +0 -28
  32. package/dist/client/types/app/bsky/actor/search.d.ts +0 -22
  33. package/dist/client/types/app/bsky/actor/searchActor.d.ts +0 -22
  34. package/dist/client/types/app/bsky/actor/searchTypeahead.d.ts +0 -20
  35. package/dist/client/types/app/bsky/actor/updateProfile.d.ts +0 -47
  36. package/dist/client/types/app/bsky/feed/bookmarkFeed.d.ts +0 -17
  37. package/dist/client/types/app/bsky/feed/feedViewPost.d.ts +0 -28
  38. package/dist/client/types/app/bsky/feed/generator.d.ts +0 -13
  39. package/dist/client/types/app/bsky/feed/getActorFeeds.d.ts +0 -22
  40. package/dist/client/types/app/bsky/feed/getBookmarkedFeeds.d.ts +0 -21
  41. package/dist/client/types/app/bsky/feed/getFeed.d.ts +0 -22
  42. package/dist/client/types/app/bsky/feed/getFeedSkeleton.d.ts +0 -22
  43. package/dist/client/types/app/bsky/feed/getVotes.d.ts +0 -36
  44. package/dist/client/types/app/bsky/feed/setVote.d.ts +0 -25
  45. package/dist/client/types/app/bsky/feed/trend.d.ts +0 -9
  46. package/dist/client/types/app/bsky/feed/vote.d.ts +0 -10
  47. package/dist/client/types/app/bsky/graph/assertCreator.d.ts +0 -1
  48. package/dist/client/types/app/bsky/graph/assertMember.d.ts +0 -1
  49. package/dist/client/types/app/bsky/graph/assertion.d.ts +0 -10
  50. package/dist/client/types/app/bsky/graph/confirmation.d.ts +0 -11
  51. package/dist/client/types/app/bsky/graph/getAssertions.d.ts +0 -48
  52. package/dist/client/types/app/bsky/graph/getMembers.d.ts +0 -36
  53. package/dist/client/types/app/bsky/graph/getMemberships.d.ts +0 -36
  54. package/dist/client/types/app/bsky/graph/mute.d.ts +0 -17
  55. package/dist/client/types/app/bsky/graph/unmute.d.ts +0 -17
  56. package/dist/client/types/app/bsky/notification/getCount.d.ts +0 -17
  57. package/dist/client/types/app/bsky/notification/list.d.ts +0 -35
  58. package/dist/client/types/app/bsky/system/actorScene.d.ts +0 -1
  59. package/dist/client/types/app/bsky/system/actorUser.d.ts +0 -1
  60. package/dist/client/types/app/bsky/system/declRef.d.ts +0 -8
  61. package/dist/client/types/app/bsky/system/declaration.d.ts +0 -7
  62. package/dist/client/types/com/atproto/account/create.d.ts +0 -41
  63. package/dist/client/types/com/atproto/account/createInviteCode.d.ts +0 -22
  64. package/dist/client/types/com/atproto/account/delete.d.ts +0 -25
  65. package/dist/client/types/com/atproto/account/get.d.ts +0 -12
  66. package/dist/client/types/com/atproto/account/requestDelete.d.ts +0 -13
  67. package/dist/client/types/com/atproto/account/requestPasswordReset.d.ts +0 -17
  68. package/dist/client/types/com/atproto/account/resetPassword.d.ts +0 -24
  69. package/dist/client/types/com/atproto/admin/blob.d.ts +0 -37
  70. package/dist/client/types/com/atproto/admin/getInviteCodeUsage.d.ts +0 -29
  71. package/dist/client/types/com/atproto/admin/moderationAction.d.ts +0 -60
  72. package/dist/client/types/com/atproto/admin/moderationReport.d.ts +0 -37
  73. package/dist/client/types/com/atproto/admin/record.d.ts +0 -43
  74. package/dist/client/types/com/atproto/admin/repo.d.ts +0 -45
  75. package/dist/client/types/com/atproto/blob/upload.d.ts +0 -19
  76. package/dist/client/types/com/atproto/handle/resolve.d.ts +0 -18
  77. package/dist/client/types/com/atproto/handle/update.d.ts +0 -17
  78. package/dist/client/types/com/atproto/repo/batchWrite.d.ts +0 -46
  79. package/dist/client/types/com/atproto/repo/describe.d.ts +0 -22
  80. package/dist/client/types/com/atproto/repo/importRepo.d.ts +0 -19
  81. package/dist/client/types/com/atproto/repo/recordRef.d.ts +0 -8
  82. package/dist/client/types/com/atproto/repo/repoRef.d.ts +0 -7
  83. package/dist/client/types/com/atproto/repo/uploadRepo.d.ts +0 -19
  84. package/dist/client/types/com/atproto/report/create.d.ts +0 -39
  85. package/dist/client/types/com/atproto/report/reasonType.d.ts +0 -3
  86. package/dist/client/types/com/atproto/report/subject.d.ts +0 -23
  87. package/dist/client/types/com/atproto/server/getAccountsConfig.d.ts +0 -27
  88. package/dist/client/types/com/atproto/server/getUserInviteCodes.d.ts +0 -31
  89. package/dist/client/types/com/atproto/session/create.d.ts +0 -29
  90. package/dist/client/types/com/atproto/session/delete.d.ts +0 -13
  91. package/dist/client/types/com/atproto/session/get.d.ts +0 -18
  92. package/dist/client/types/com/atproto/session/refresh.d.ts +0 -24
  93. package/dist/client/types/com/atproto/sync/getRoot.d.ts +0 -18
  94. package/dist/client/types/com/atproto/sync/subscribeAllRepos.d.ts +0 -9
  95. package/dist/client/types/com/atproto/sync/updateRepo.d.ts +0 -15
  96. package/dist/session.d.ts +0 -42
  97. package/dist/src/client/index.d.ts +0 -462
  98. package/dist/src/client/lexicons.d.ts +0 -2910
  99. package/dist/src/client/schemas.d.ts +0 -17
  100. package/dist/src/client/types/app/bsky/actor/createScene.d.ts +0 -32
  101. package/dist/src/client/types/app/bsky/actor/getProfile.d.ts +0 -36
  102. package/dist/src/client/types/app/bsky/actor/getSuggestions.d.ts +0 -36
  103. package/dist/src/client/types/app/bsky/actor/profile.d.ts +0 -15
  104. package/dist/src/client/types/app/bsky/actor/ref.d.ts +0 -14
  105. package/dist/src/client/types/app/bsky/actor/search.d.ts +0 -32
  106. package/dist/src/client/types/app/bsky/actor/searchTypeahead.d.ts +0 -28
  107. package/dist/src/client/types/app/bsky/actor/updateProfile.d.ts +0 -48
  108. package/dist/src/client/types/app/bsky/badge.d.ts +0 -22
  109. package/dist/src/client/types/app/bsky/badgeAccept.d.ts +0 -11
  110. package/dist/src/client/types/app/bsky/badgeOffer.d.ts +0 -11
  111. package/dist/src/client/types/app/bsky/declaration.d.ts +0 -6
  112. package/dist/src/client/types/app/bsky/embed/external.d.ts +0 -26
  113. package/dist/src/client/types/app/bsky/embed/images.d.ts +0 -23
  114. package/dist/src/client/types/app/bsky/feed/embed.d.ts +0 -36
  115. package/dist/src/client/types/app/bsky/feed/feedViewPost.d.ts +0 -26
  116. package/dist/src/client/types/app/bsky/feed/getAuthorFeed.d.ts +0 -22
  117. package/dist/src/client/types/app/bsky/feed/getPostThread.d.ts +0 -43
  118. package/dist/src/client/types/app/bsky/feed/getRepostedBy.d.ts +0 -35
  119. package/dist/src/client/types/app/bsky/feed/getTimeline.d.ts +0 -22
  120. package/dist/src/client/types/app/bsky/feed/getVotes.d.ts +0 -33
  121. package/dist/src/client/types/app/bsky/feed/mediaEmbed.d.ts +0 -18
  122. package/dist/src/client/types/app/bsky/feed/post.d.ts +0 -54
  123. package/dist/src/client/types/app/bsky/feed/repost.d.ts +0 -6
  124. package/dist/src/client/types/app/bsky/feed/setVote.d.ts +0 -25
  125. package/dist/src/client/types/app/bsky/feed/trend.d.ts +0 -6
  126. package/dist/src/client/types/app/bsky/feed/vote.d.ts +0 -7
  127. package/dist/src/client/types/app/bsky/follow.d.ts +0 -9
  128. package/dist/src/client/types/app/bsky/getAuthorFeed.d.ts +0 -56
  129. package/dist/src/client/types/app/bsky/getBadgeMembers.d.ts +0 -29
  130. package/dist/src/client/types/app/bsky/getHomeFeed.d.ts +0 -56
  131. package/dist/src/client/types/app/bsky/getLikedBy.d.ts +0 -29
  132. package/dist/src/client/types/app/bsky/getNotificationCount.d.ts +0 -16
  133. package/dist/src/client/types/app/bsky/getNotifications.d.ts +0 -33
  134. package/dist/src/client/types/app/bsky/getPostThread.d.ts +0 -55
  135. package/dist/src/client/types/app/bsky/getProfile.d.ts +0 -26
  136. package/dist/src/client/types/app/bsky/getRepostedBy.d.ts +0 -29
  137. package/dist/src/client/types/app/bsky/getTimeline.d.ts +0 -56
  138. package/dist/src/client/types/app/bsky/getUserFollowers.d.ts +0 -31
  139. package/dist/src/client/types/app/bsky/getUserFollows.d.ts +0 -31
  140. package/dist/src/client/types/app/bsky/getUsersSearch.d.ts +0 -26
  141. package/dist/src/client/types/app/bsky/getUsersTypeahead.d.ts +0 -22
  142. package/dist/src/client/types/app/bsky/graph/assertCreator.d.ts +0 -1
  143. package/dist/src/client/types/app/bsky/graph/assertMember.d.ts +0 -1
  144. package/dist/src/client/types/app/bsky/graph/assertion.d.ts +0 -7
  145. package/dist/src/client/types/app/bsky/graph/confirmation.d.ts +0 -8
  146. package/dist/src/client/types/app/bsky/graph/follow.d.ts +0 -6
  147. package/dist/src/client/types/app/bsky/graph/getAssertions.d.ts +0 -43
  148. package/dist/src/client/types/app/bsky/graph/getFollowers.d.ts +0 -34
  149. package/dist/src/client/types/app/bsky/graph/getFollows.d.ts +0 -33
  150. package/dist/src/client/types/app/bsky/graph/getMembers.d.ts +0 -33
  151. package/dist/src/client/types/app/bsky/graph/getMemberships.d.ts +0 -33
  152. package/dist/src/client/types/app/bsky/invite.d.ts +0 -10
  153. package/dist/src/client/types/app/bsky/inviteAccept.d.ts +0 -14
  154. package/dist/src/client/types/app/bsky/like.d.ts +0 -10
  155. package/dist/src/client/types/app/bsky/mediaEmbed.d.ts +0 -15
  156. package/dist/src/client/types/app/bsky/notification/getCount.d.ts +0 -17
  157. package/dist/src/client/types/app/bsky/notification/list.d.ts +0 -32
  158. package/dist/src/client/types/app/bsky/notification/updateSeen.d.ts +0 -17
  159. package/dist/src/client/types/app/bsky/post.d.ts +0 -23
  160. package/dist/src/client/types/app/bsky/postNotificationsSeen.d.ts +0 -20
  161. package/dist/src/client/types/app/bsky/profile.d.ts +0 -5
  162. package/dist/src/client/types/app/bsky/repost.d.ts +0 -10
  163. package/dist/src/client/types/app/bsky/system/actorScene.d.ts +0 -1
  164. package/dist/src/client/types/app/bsky/system/actorUser.d.ts +0 -1
  165. package/dist/src/client/types/app/bsky/system/declRef.d.ts +0 -5
  166. package/dist/src/client/types/app/bsky/system/declaration.d.ts +0 -4
  167. package/dist/src/client/types/app/bsky/updateProfile.d.ts +0 -23
  168. package/dist/src/client/types/com/atproto/account/create.d.ts +0 -41
  169. package/dist/src/client/types/com/atproto/account/createInviteCode.d.ts +0 -22
  170. package/dist/src/client/types/com/atproto/account/delete.d.ts +0 -13
  171. package/dist/src/client/types/com/atproto/account/get.d.ts +0 -12
  172. package/dist/src/client/types/com/atproto/account/requestPasswordReset.d.ts +0 -17
  173. package/dist/src/client/types/com/atproto/account/resetPassword.d.ts +0 -24
  174. package/dist/src/client/types/com/atproto/blob/upload.d.ts +0 -19
  175. package/dist/src/client/types/com/atproto/createAccount.d.ts +0 -40
  176. package/dist/src/client/types/com/atproto/createInviteCode.d.ts +0 -20
  177. package/dist/src/client/types/com/atproto/createSession.d.ts +0 -24
  178. package/dist/src/client/types/com/atproto/data/uploadFile.d.ts +0 -19
  179. package/dist/src/client/types/com/atproto/deleteAccount.d.ts +0 -20
  180. package/dist/src/client/types/com/atproto/deleteSession.d.ts +0 -17
  181. package/dist/src/client/types/com/atproto/getAccount.d.ts +0 -16
  182. package/dist/src/client/types/com/atproto/getAccountsConfig.d.ts +0 -17
  183. package/dist/src/client/types/com/atproto/getSession.d.ts +0 -17
  184. package/dist/src/client/types/com/atproto/handle/resolve.d.ts +0 -18
  185. package/dist/src/client/types/com/atproto/refreshSession.d.ts +0 -20
  186. package/dist/src/client/types/com/atproto/repo/batchWrite.d.ts +0 -39
  187. package/dist/src/client/types/com/atproto/repo/createRecord.d.ts +0 -26
  188. package/dist/src/client/types/com/atproto/repo/deleteRecord.d.ts +0 -19
  189. package/dist/src/client/types/com/atproto/repo/describe.d.ts +0 -22
  190. package/dist/src/client/types/com/atproto/repo/getRecord.d.ts +0 -23
  191. package/dist/src/client/types/com/atproto/repo/listRecords.d.ts +0 -30
  192. package/dist/src/client/types/com/atproto/repo/putRecord.d.ts +0 -27
  193. package/dist/src/client/types/com/atproto/repo/strongRef.d.ts +0 -5
  194. package/dist/src/client/types/com/atproto/repoBatchWrite.d.ts +0 -36
  195. package/dist/src/client/types/com/atproto/repoCreateRecord.d.ts +0 -24
  196. package/dist/src/client/types/com/atproto/repoDeleteRecord.d.ts +0 -18
  197. package/dist/src/client/types/com/atproto/repoDescribe.d.ts +0 -21
  198. package/dist/src/client/types/com/atproto/repoGetRecord.d.ts +0 -22
  199. package/dist/src/client/types/com/atproto/repoListRecords.d.ts +0 -27
  200. package/dist/src/client/types/com/atproto/repoPutRecord.d.ts +0 -25
  201. package/dist/src/client/types/com/atproto/requestAccountPasswordReset.d.ts +0 -19
  202. package/dist/src/client/types/com/atproto/resetAccountPassword.d.ts +0 -26
  203. package/dist/src/client/types/com/atproto/resolveHandle.d.ts +0 -17
  204. package/dist/src/client/types/com/atproto/resolveName.d.ts +0 -17
  205. package/dist/src/client/types/com/atproto/server/getAccountsConfig.d.ts +0 -24
  206. package/dist/src/client/types/com/atproto/session/create.d.ts +0 -26
  207. package/dist/src/client/types/com/atproto/session/delete.d.ts +0 -13
  208. package/dist/src/client/types/com/atproto/session/get.d.ts +0 -18
  209. package/dist/src/client/types/com/atproto/session/refresh.d.ts +0 -21
  210. package/dist/src/client/types/com/atproto/sync/getRepo.d.ts +0 -15
  211. package/dist/src/client/types/com/atproto/sync/getRoot.d.ts +0 -18
  212. package/dist/src/client/types/com/atproto/sync/updateRepo.d.ts +0 -15
  213. package/dist/src/client/types/com/atproto/syncGetRepo.d.ts +0 -15
  214. package/dist/src/client/types/com/atproto/syncGetRoot.d.ts +0 -17
  215. package/dist/src/client/types/com/atproto/syncUpdateRepo.d.ts +0 -15
  216. package/dist/src/index.d.ts +0 -4
  217. package/dist/src/schemas.d.ts +0 -19
  218. package/dist/src/session.d.ts +0 -42
  219. package/dist/src/types/app/bsky/acceptedBadge.d.ts +0 -10
  220. package/dist/src/types/app/bsky/badge.d.ts +0 -22
  221. package/dist/src/types/app/bsky/badgeAccept.d.ts +0 -11
  222. package/dist/src/types/app/bsky/badgeOffer.d.ts +0 -11
  223. package/dist/src/types/app/bsky/declaration.d.ts +0 -6
  224. package/dist/src/types/app/bsky/follow.d.ts +0 -9
  225. package/dist/src/types/app/bsky/getAuthorFeed.d.ts +0 -56
  226. package/dist/src/types/app/bsky/getBadgeMembers.d.ts +0 -29
  227. package/dist/src/types/app/bsky/getHomeFeed.d.ts +0 -56
  228. package/dist/src/types/app/bsky/getLikedBy.d.ts +0 -29
  229. package/dist/src/types/app/bsky/getNotificationCount.d.ts +0 -16
  230. package/dist/src/types/app/bsky/getNotifications.d.ts +0 -33
  231. package/dist/src/types/app/bsky/getPostThread.d.ts +0 -55
  232. package/dist/src/types/app/bsky/getProfile.d.ts +0 -42
  233. package/dist/src/types/app/bsky/getRepostedBy.d.ts +0 -29
  234. package/dist/src/types/app/bsky/getUserFollowers.d.ts +0 -31
  235. package/dist/src/types/app/bsky/getUserFollows.d.ts +0 -31
  236. package/dist/src/types/app/bsky/getUsersSearch.d.ts +0 -26
  237. package/dist/src/types/app/bsky/getUsersTypeahead.d.ts +0 -22
  238. package/dist/src/types/app/bsky/invite.d.ts +0 -10
  239. package/dist/src/types/app/bsky/inviteAccept.d.ts +0 -14
  240. package/dist/src/types/app/bsky/like.d.ts +0 -10
  241. package/dist/src/types/app/bsky/mediaEmbed.d.ts +0 -15
  242. package/dist/src/types/app/bsky/post.d.ts +0 -23
  243. package/dist/src/types/app/bsky/postNotificationsSeen.d.ts +0 -19
  244. package/dist/src/types/app/bsky/profile.d.ts +0 -11
  245. package/dist/src/types/app/bsky/repost.d.ts +0 -10
  246. package/dist/src/types/app/bsky/updateProfile.d.ts +0 -27
  247. package/dist/src/types/com/atproto/createAccount.d.ts +0 -39
  248. package/dist/src/types/com/atproto/createInviteCode.d.ts +0 -19
  249. package/dist/src/types/com/atproto/createSession.d.ts +0 -23
  250. package/dist/src/types/com/atproto/deleteAccount.d.ts +0 -19
  251. package/dist/src/types/com/atproto/deleteSession.d.ts +0 -16
  252. package/dist/src/types/com/atproto/getAccount.d.ts +0 -19
  253. package/dist/src/types/com/atproto/getAccountsConfig.d.ts +0 -17
  254. package/dist/src/types/com/atproto/getSession.d.ts +0 -17
  255. package/dist/src/types/com/atproto/refreshSession.d.ts +0 -19
  256. package/dist/src/types/com/atproto/repoBatchWrite.d.ts +0 -35
  257. package/dist/src/types/com/atproto/repoCreateRecord.d.ts +0 -23
  258. package/dist/src/types/com/atproto/repoDeleteRecord.d.ts +0 -15
  259. package/dist/src/types/com/atproto/repoDescribe.d.ts +0 -21
  260. package/dist/src/types/com/atproto/repoGetRecord.d.ts +0 -22
  261. package/dist/src/types/com/atproto/repoListRecords.d.ts +0 -27
  262. package/dist/src/types/com/atproto/repoPutRecord.d.ts +0 -24
  263. package/dist/src/types/com/atproto/requestAccountPasswordReset.d.ts +0 -18
  264. package/dist/src/types/com/atproto/resetAccountPassword.d.ts +0 -25
  265. package/dist/src/types/com/atproto/resolveName.d.ts +0 -17
  266. package/dist/src/types/com/atproto/syncGetRepo.d.ts +0 -15
  267. package/dist/src/types/com/atproto/syncGetRoot.d.ts +0 -17
  268. package/dist/src/types/com/atproto/syncUpdateRepo.d.ts +0 -14
  269. package/dist/src/types/todo/adx/createAccount.d.ts +0 -36
  270. package/dist/src/types/todo/adx/createInviteCode.d.ts +0 -19
  271. package/dist/src/types/todo/adx/createSession.d.ts +0 -22
  272. package/dist/src/types/todo/adx/deleteAccount.d.ts +0 -19
  273. package/dist/src/types/todo/adx/deleteSession.d.ts +0 -19
  274. package/dist/src/types/todo/adx/getAccount.d.ts +0 -19
  275. package/dist/src/types/todo/adx/getAccountsConfig.d.ts +0 -17
  276. package/dist/src/types/todo/adx/getSession.d.ts +0 -17
  277. package/dist/src/types/todo/adx/repoBatchWrite.d.ts +0 -34
  278. package/dist/src/types/todo/adx/repoCreateRecord.d.ts +0 -22
  279. package/dist/src/types/todo/adx/repoDeleteRecord.d.ts +0 -15
  280. package/dist/src/types/todo/adx/repoDescribe.d.ts +0 -21
  281. package/dist/src/types/todo/adx/repoGetRecord.d.ts +0 -20
  282. package/dist/src/types/todo/adx/repoListRecords.d.ts +0 -25
  283. package/dist/src/types/todo/adx/repoPutRecord.d.ts +0 -23
  284. package/dist/src/types/todo/adx/requestAccountPasswordReset.d.ts +0 -18
  285. package/dist/src/types/todo/adx/resetAccountPassword.d.ts +0 -25
  286. package/dist/src/types/todo/adx/resolveName.d.ts +0 -17
  287. package/dist/src/types/todo/adx/syncGetRepo.d.ts +0 -15
  288. package/dist/src/types/todo/adx/syncGetRoot.d.ts +0 -17
  289. package/dist/src/types/todo/adx/syncUpdateRepo.d.ts +0 -14
  290. package/dist/src/types/todo/social/badge.d.ts +0 -23
  291. package/dist/src/types/todo/social/follow.d.ts +0 -5
  292. package/dist/src/types/todo/social/getAuthorFeed.d.ts +0 -55
  293. package/dist/src/types/todo/social/getFeed.d.ts +0 -55
  294. package/dist/src/types/todo/social/getHomeFeed.d.ts +0 -55
  295. package/dist/src/types/todo/social/getLikedBy.d.ts +0 -26
  296. package/dist/src/types/todo/social/getNotificationCount.d.ts +0 -16
  297. package/dist/src/types/todo/social/getNotifications.d.ts +0 -31
  298. package/dist/src/types/todo/social/getPostThread.d.ts +0 -54
  299. package/dist/src/types/todo/social/getProfile.d.ts +0 -40
  300. package/dist/src/types/todo/social/getRepostedBy.d.ts +0 -26
  301. package/dist/src/types/todo/social/getUserFollowers.d.ts +0 -30
  302. package/dist/src/types/todo/social/getUserFollows.d.ts +0 -30
  303. package/dist/src/types/todo/social/like.d.ts +0 -5
  304. package/dist/src/types/todo/social/mediaEmbed.d.ts +0 -15
  305. package/dist/src/types/todo/social/post.d.ts +0 -18
  306. package/dist/src/types/todo/social/postNotificationsSeen.d.ts +0 -19
  307. package/dist/src/types/todo/social/profile.d.ts +0 -10
  308. package/dist/src/types/todo/social/repost.d.ts +0 -5
  309. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -74,7 +74,7 @@ async function fetchHandler(
74
74
  } else if (resMimeType.startsWith('text/')) {
75
75
  resBody = await res.text()
76
76
  } else {
77
- throw new Error('TODO: non-textual response body')
77
+ resBody = await res.blob()
78
78
  }
79
79
  }
80
80
 
@@ -0,0 +1,8 @@
1
+ const base = require('./jest.config')
2
+
3
+ module.exports = {
4
+ ...base,
5
+ roots: ['<rootDir>/bench'],
6
+ testRegex: '(.*.bench.ts)',
7
+ testTimeout: 3000000,
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/api",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "codegen": "lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
@@ -10,7 +10,9 @@
10
10
  "update-main-to-src": "node ./update-pkg.js --update-main-to-src",
11
11
  "prepublish": "npm run update-main-to-dist",
12
12
  "postpublish": "npm run update-main-to-src",
13
- "test": "jest"
13
+ "test": "jest",
14
+ "bench": "jest --config jest.bench.config.js",
15
+ "bench:profile": "node --inspect-brk ../../node_modules/.bin/jest --config jest.bench.config.js"
14
16
  },
15
17
  "license": "MIT",
16
18
  "repository": {
@@ -71,10 +71,12 @@ import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOf
71
71
  import * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl'
72
72
  import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos'
73
73
  import * as AppBskyActorDefs from './types/app/bsky/actor/defs'
74
+ import * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
74
75
  import * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
75
76
  import * as AppBskyActorGetProfiles from './types/app/bsky/actor/getProfiles'
76
77
  import * as AppBskyActorGetSuggestions from './types/app/bsky/actor/getSuggestions'
77
78
  import * as AppBskyActorProfile from './types/app/bsky/actor/profile'
79
+ import * as AppBskyActorPutPreferences from './types/app/bsky/actor/putPreferences'
78
80
  import * as AppBskyActorSearchActors from './types/app/bsky/actor/searchActors'
79
81
  import * as AppBskyActorSearchActorsTypeahead from './types/app/bsky/actor/searchActorsTypeahead'
80
82
  import * as AppBskyEmbedExternal from './types/app/bsky/embed/external'
@@ -177,10 +179,12 @@ export * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOf
177
179
  export * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl'
178
180
  export * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos'
179
181
  export * as AppBskyActorDefs from './types/app/bsky/actor/defs'
182
+ export * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
180
183
  export * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
181
184
  export * as AppBskyActorGetProfiles from './types/app/bsky/actor/getProfiles'
182
185
  export * as AppBskyActorGetSuggestions from './types/app/bsky/actor/getSuggestions'
183
186
  export * as AppBskyActorProfile from './types/app/bsky/actor/profile'
187
+ export * as AppBskyActorPutPreferences from './types/app/bsky/actor/putPreferences'
184
188
  export * as AppBskyActorSearchActors from './types/app/bsky/actor/searchActors'
185
189
  export * as AppBskyActorSearchActorsTypeahead from './types/app/bsky/actor/searchActorsTypeahead'
186
190
  export * as AppBskyEmbedExternal from './types/app/bsky/embed/external'
@@ -1012,6 +1016,17 @@ export class ActorNS {
1012
1016
  this.profile = new ProfileRecord(service)
1013
1017
  }
1014
1018
 
1019
+ getPreferences(
1020
+ params?: AppBskyActorGetPreferences.QueryParams,
1021
+ opts?: AppBskyActorGetPreferences.CallOptions,
1022
+ ): Promise<AppBskyActorGetPreferences.Response> {
1023
+ return this._service.xrpc
1024
+ .call('app.bsky.actor.getPreferences', params, undefined, opts)
1025
+ .catch((e) => {
1026
+ throw AppBskyActorGetPreferences.toKnownErr(e)
1027
+ })
1028
+ }
1029
+
1015
1030
  getProfile(
1016
1031
  params?: AppBskyActorGetProfile.QueryParams,
1017
1032
  opts?: AppBskyActorGetProfile.CallOptions,
@@ -1045,6 +1060,17 @@ export class ActorNS {
1045
1060
  })
1046
1061
  }
1047
1062
 
1063
+ putPreferences(
1064
+ data?: AppBskyActorPutPreferences.InputSchema,
1065
+ opts?: AppBskyActorPutPreferences.CallOptions,
1066
+ ): Promise<AppBskyActorPutPreferences.Response> {
1067
+ return this._service.xrpc
1068
+ .call('app.bsky.actor.putPreferences', opts?.qp, data, opts)
1069
+ .catch((e) => {
1070
+ throw AppBskyActorPutPreferences.toKnownErr(e)
1071
+ })
1072
+ }
1073
+
1048
1074
  searchActors(
1049
1075
  params?: AppBskyActorSearchActors.QueryParams,
1050
1076
  opts?: AppBskyActorSearchActors.CallOptions,
@@ -100,7 +100,9 @@ export const schemaDict = {
100
100
  type: 'union',
101
101
  refs: [
102
102
  'lex:com.atproto.admin.defs#repoView',
103
+ 'lex:com.atproto.admin.defs#repoViewNotFound',
103
104
  'lex:com.atproto.admin.defs#recordView',
105
+ 'lex:com.atproto.admin.defs#recordViewNotFound',
104
106
  ],
105
107
  },
106
108
  subjectBlobs: {
@@ -274,7 +276,9 @@ export const schemaDict = {
274
276
  type: 'union',
275
277
  refs: [
276
278
  'lex:com.atproto.admin.defs#repoView',
279
+ 'lex:com.atproto.admin.defs#repoViewNotFound',
277
280
  'lex:com.atproto.admin.defs#recordView',
281
+ 'lex:com.atproto.admin.defs#recordViewNotFound',
278
282
  ],
279
283
  },
280
284
  reportedBy: {
@@ -396,6 +400,16 @@ export const schemaDict = {
396
400
  },
397
401
  },
398
402
  },
403
+ repoViewNotFound: {
404
+ type: 'object',
405
+ required: ['did'],
406
+ properties: {
407
+ did: {
408
+ type: 'string',
409
+ format: 'did',
410
+ },
411
+ },
412
+ },
399
413
  repoRef: {
400
414
  type: 'object',
401
415
  required: ['did'],
@@ -501,6 +515,16 @@ export const schemaDict = {
501
515
  },
502
516
  },
503
517
  },
518
+ recordViewNotFound: {
519
+ type: 'object',
520
+ required: ['uri'],
521
+ properties: {
522
+ uri: {
523
+ type: 'string',
524
+ format: 'at-uri',
525
+ },
526
+ },
527
+ },
504
528
  moderation: {
505
529
  type: 'object',
506
530
  required: [],
@@ -835,6 +859,15 @@ export const schemaDict = {
835
859
  resolved: {
836
860
  type: 'boolean',
837
861
  },
862
+ actionType: {
863
+ type: 'string',
864
+ knownValues: [
865
+ 'com.atproto.admin.defs#takedown',
866
+ 'com.atproto.admin.defs#flag',
867
+ 'com.atproto.admin.defs#acknowledge',
868
+ 'com.atproto.admin.defs#escalate',
869
+ ],
870
+ },
838
871
  limit: {
839
872
  type: 'integer',
840
873
  minimum: 1,
@@ -896,6 +929,11 @@ export const schemaDict = {
896
929
  ref: 'lex:com.atproto.admin.defs#recordViewDetail',
897
930
  },
898
931
  },
932
+ errors: [
933
+ {
934
+ name: 'RecordNotFound',
935
+ },
936
+ ],
899
937
  },
900
938
  },
901
939
  },
@@ -923,6 +961,11 @@ export const schemaDict = {
923
961
  ref: 'lex:com.atproto.admin.defs#repoViewDetail',
924
962
  },
925
963
  },
964
+ errors: [
965
+ {
966
+ name: 'RepoNotFound',
967
+ },
968
+ ],
926
969
  },
927
970
  },
928
971
  },
@@ -2114,6 +2157,10 @@ export const schemaDict = {
2114
2157
  type: 'string',
2115
2158
  format: 'handle',
2116
2159
  },
2160
+ did: {
2161
+ type: 'string',
2162
+ format: 'did',
2163
+ },
2117
2164
  inviteCode: {
2118
2165
  type: 'string',
2119
2166
  },
@@ -2165,6 +2212,12 @@ export const schemaDict = {
2165
2212
  {
2166
2213
  name: 'UnsupportedDomain',
2167
2214
  },
2215
+ {
2216
+ name: 'UnresolvableDid',
2217
+ },
2218
+ {
2219
+ name: 'IncompatibleDidDoc',
2220
+ },
2168
2221
  ],
2169
2222
  },
2170
2223
  },
@@ -3509,6 +3562,66 @@ export const schemaDict = {
3509
3562
  },
3510
3563
  },
3511
3564
  },
3565
+ preferences: {
3566
+ type: 'array',
3567
+ items: {
3568
+ type: 'union',
3569
+ refs: [
3570
+ 'lex:app.bsky.actor.defs#adultContentPref',
3571
+ 'lex:app.bsky.actor.defs#contentLabelPref',
3572
+ ],
3573
+ },
3574
+ },
3575
+ adultContentPref: {
3576
+ type: 'object',
3577
+ required: ['enabled'],
3578
+ properties: {
3579
+ enabled: {
3580
+ type: 'boolean',
3581
+ default: false,
3582
+ },
3583
+ },
3584
+ },
3585
+ contentLabelPref: {
3586
+ type: 'object',
3587
+ required: ['label', 'visibility'],
3588
+ properties: {
3589
+ label: {
3590
+ type: 'string',
3591
+ },
3592
+ visibility: {
3593
+ type: 'string',
3594
+ knownValues: ['show', 'warn', 'hide'],
3595
+ },
3596
+ },
3597
+ },
3598
+ },
3599
+ },
3600
+ AppBskyActorGetPreferences: {
3601
+ lexicon: 1,
3602
+ id: 'app.bsky.actor.getPreferences',
3603
+ defs: {
3604
+ main: {
3605
+ type: 'query',
3606
+ description: 'Get private preferences attached to the account.',
3607
+ parameters: {
3608
+ type: 'params',
3609
+ properties: {},
3610
+ },
3611
+ output: {
3612
+ encoding: 'application/json',
3613
+ schema: {
3614
+ type: 'object',
3615
+ required: ['preferences'],
3616
+ properties: {
3617
+ preferences: {
3618
+ type: 'ref',
3619
+ ref: 'lex:app.bsky.actor.defs#preferences',
3620
+ },
3621
+ },
3622
+ },
3623
+ },
3624
+ },
3512
3625
  },
3513
3626
  },
3514
3627
  AppBskyActorGetProfile: {
@@ -3655,6 +3768,29 @@ export const schemaDict = {
3655
3768
  },
3656
3769
  },
3657
3770
  },
3771
+ AppBskyActorPutPreferences: {
3772
+ lexicon: 1,
3773
+ id: 'app.bsky.actor.putPreferences',
3774
+ defs: {
3775
+ main: {
3776
+ type: 'procedure',
3777
+ description: 'Sets the private preferences attached to the account.',
3778
+ input: {
3779
+ encoding: 'application/json',
3780
+ schema: {
3781
+ type: 'object',
3782
+ required: ['preferences'],
3783
+ properties: {
3784
+ preferences: {
3785
+ type: 'ref',
3786
+ ref: 'lex:app.bsky.actor.defs#preferences',
3787
+ },
3788
+ },
3789
+ },
3790
+ },
3791
+ },
3792
+ },
3793
+ },
3658
3794
  AppBskyActorSearchActors: {
3659
3795
  lexicon: 1,
3660
3796
  id: 'app.bsky.actor.searchActors',
@@ -5659,10 +5795,12 @@ export const ids = {
5659
5795
  ComAtprotoSyncRequestCrawl: 'com.atproto.sync.requestCrawl',
5660
5796
  ComAtprotoSyncSubscribeRepos: 'com.atproto.sync.subscribeRepos',
5661
5797
  AppBskyActorDefs: 'app.bsky.actor.defs',
5798
+ AppBskyActorGetPreferences: 'app.bsky.actor.getPreferences',
5662
5799
  AppBskyActorGetProfile: 'app.bsky.actor.getProfile',
5663
5800
  AppBskyActorGetProfiles: 'app.bsky.actor.getProfiles',
5664
5801
  AppBskyActorGetSuggestions: 'app.bsky.actor.getSuggestions',
5665
5802
  AppBskyActorProfile: 'app.bsky.actor.profile',
5803
+ AppBskyActorPutPreferences: 'app.bsky.actor.putPreferences',
5666
5804
  AppBskyActorSearchActors: 'app.bsky.actor.searchActors',
5667
5805
  AppBskyActorSearchActorsTypeahead: 'app.bsky.actor.searchActorsTypeahead',
5668
5806
  AppBskyEmbedExternal: 'app.bsky.embed.external',
@@ -103,3 +103,44 @@ export function isViewerState(v: unknown): v is ViewerState {
103
103
  export function validateViewerState(v: unknown): ValidationResult {
104
104
  return lexicons.validate('app.bsky.actor.defs#viewerState', v)
105
105
  }
106
+
107
+ export type Preferences = (
108
+ | AdultContentPref
109
+ | ContentLabelPref
110
+ | { $type: string; [k: string]: unknown }
111
+ )[]
112
+
113
+ export interface AdultContentPref {
114
+ enabled: boolean
115
+ [k: string]: unknown
116
+ }
117
+
118
+ export function isAdultContentPref(v: unknown): v is AdultContentPref {
119
+ return (
120
+ isObj(v) &&
121
+ hasProp(v, '$type') &&
122
+ v.$type === 'app.bsky.actor.defs#adultContentPref'
123
+ )
124
+ }
125
+
126
+ export function validateAdultContentPref(v: unknown): ValidationResult {
127
+ return lexicons.validate('app.bsky.actor.defs#adultContentPref', v)
128
+ }
129
+
130
+ export interface ContentLabelPref {
131
+ label: string
132
+ visibility: 'show' | 'warn' | 'hide' | (string & {})
133
+ [k: string]: unknown
134
+ }
135
+
136
+ export function isContentLabelPref(v: unknown): v is ContentLabelPref {
137
+ return (
138
+ isObj(v) &&
139
+ hasProp(v, '$type') &&
140
+ v.$type === 'app.bsky.actor.defs#contentLabelPref'
141
+ )
142
+ }
143
+
144
+ export function validateContentLabelPref(v: unknown): ValidationResult {
145
+ return lexicons.validate('app.bsky.actor.defs#contentLabelPref', v)
146
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { Headers, XRPCError } from '@atproto/xrpc'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
9
+ import * as AppBskyActorDefs from './defs'
10
+
11
+ export interface QueryParams {}
12
+
13
+ export type InputSchema = undefined
14
+
15
+ export interface OutputSchema {
16
+ preferences: AppBskyActorDefs.Preferences
17
+ [k: string]: unknown
18
+ }
19
+
20
+ export interface CallOptions {
21
+ headers?: Headers
22
+ }
23
+
24
+ export interface Response {
25
+ success: boolean
26
+ headers: Headers
27
+ data: OutputSchema
28
+ }
29
+
30
+ export function toKnownErr(e: any) {
31
+ if (e instanceof XRPCError) {
32
+ }
33
+ return e
34
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { Headers, XRPCError } from '@atproto/xrpc'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
9
+ import * as AppBskyActorDefs from './defs'
10
+
11
+ export interface QueryParams {}
12
+
13
+ export interface InputSchema {
14
+ preferences: AppBskyActorDefs.Preferences
15
+ [k: string]: unknown
16
+ }
17
+
18
+ export interface CallOptions {
19
+ headers?: Headers
20
+ qp?: QueryParams
21
+ encoding: 'application/json'
22
+ }
23
+
24
+ export interface Response {
25
+ success: boolean
26
+ headers: Headers
27
+ }
28
+
29
+ export function toKnownErr(e: any) {
30
+ if (e instanceof XRPCError) {
31
+ }
32
+ return e
33
+ }
@@ -43,7 +43,12 @@ export function validateActionView(v: unknown): ValidationResult {
43
43
  export interface ActionViewDetail {
44
44
  id: number
45
45
  action: ActionType
46
- subject: RepoView | RecordView | { $type: string; [k: string]: unknown }
46
+ subject:
47
+ | RepoView
48
+ | RepoViewNotFound
49
+ | RecordView
50
+ | RecordViewNotFound
51
+ | { $type: string; [k: string]: unknown }
47
52
  subjectBlobs: BlobView[]
48
53
  createLabelVals?: string[]
49
54
  negateLabelVals?: string[]
@@ -150,7 +155,12 @@ export interface ReportViewDetail {
150
155
  id: number
151
156
  reasonType: ComAtprotoModerationDefs.ReasonType
152
157
  reason?: string
153
- subject: RepoView | RecordView | { $type: string; [k: string]: unknown }
158
+ subject:
159
+ | RepoView
160
+ | RepoViewNotFound
161
+ | RecordView
162
+ | RecordViewNotFound
163
+ | { $type: string; [k: string]: unknown }
154
164
  reportedBy: string
155
165
  createdAt: string
156
166
  resolvedByActions: ActionView[]
@@ -219,6 +229,23 @@ export function validateRepoViewDetail(v: unknown): ValidationResult {
219
229
  return lexicons.validate('com.atproto.admin.defs#repoViewDetail', v)
220
230
  }
221
231
 
232
+ export interface RepoViewNotFound {
233
+ did: string
234
+ [k: string]: unknown
235
+ }
236
+
237
+ export function isRepoViewNotFound(v: unknown): v is RepoViewNotFound {
238
+ return (
239
+ isObj(v) &&
240
+ hasProp(v, '$type') &&
241
+ v.$type === 'com.atproto.admin.defs#repoViewNotFound'
242
+ )
243
+ }
244
+
245
+ export function validateRepoViewNotFound(v: unknown): ValidationResult {
246
+ return lexicons.validate('com.atproto.admin.defs#repoViewNotFound', v)
247
+ }
248
+
222
249
  export interface RepoRef {
223
250
  did: string
224
251
  [k: string]: unknown
@@ -283,6 +310,23 @@ export function validateRecordViewDetail(v: unknown): ValidationResult {
283
310
  return lexicons.validate('com.atproto.admin.defs#recordViewDetail', v)
284
311
  }
285
312
 
313
+ export interface RecordViewNotFound {
314
+ uri: string
315
+ [k: string]: unknown
316
+ }
317
+
318
+ export function isRecordViewNotFound(v: unknown): v is RecordViewNotFound {
319
+ return (
320
+ isObj(v) &&
321
+ hasProp(v, '$type') &&
322
+ v.$type === 'com.atproto.admin.defs#recordViewNotFound'
323
+ )
324
+ }
325
+
326
+ export function validateRecordViewNotFound(v: unknown): ValidationResult {
327
+ return lexicons.validate('com.atproto.admin.defs#recordViewNotFound', v)
328
+ }
329
+
286
330
  export interface Moderation {
287
331
  currentAction?: ActionViewCurrent
288
332
  [k: string]: unknown
@@ -11,6 +11,12 @@ import * as ComAtprotoAdminDefs from './defs'
11
11
  export interface QueryParams {
12
12
  subject?: string
13
13
  resolved?: boolean
14
+ actionType?:
15
+ | 'com.atproto.admin.defs#takedown'
16
+ | 'com.atproto.admin.defs#flag'
17
+ | 'com.atproto.admin.defs#acknowledge'
18
+ | 'com.atproto.admin.defs#escalate'
19
+ | (string & {})
14
20
  limit?: number
15
21
  cursor?: string
16
22
  }
@@ -26,8 +26,15 @@ export interface Response {
26
26
  data: OutputSchema
27
27
  }
28
28
 
29
+ export class RecordNotFoundError extends XRPCError {
30
+ constructor(src: XRPCError) {
31
+ super(src.status, src.error, src.message)
32
+ }
33
+ }
34
+
29
35
  export function toKnownErr(e: any) {
30
36
  if (e instanceof XRPCError) {
37
+ if (e.error === 'RecordNotFound') return new RecordNotFoundError(e)
31
38
  }
32
39
  return e
33
40
  }
@@ -25,8 +25,15 @@ export interface Response {
25
25
  data: OutputSchema
26
26
  }
27
27
 
28
+ export class RepoNotFoundError extends XRPCError {
29
+ constructor(src: XRPCError) {
30
+ super(src.status, src.error, src.message)
31
+ }
32
+ }
33
+
28
34
  export function toKnownErr(e: any) {
29
35
  if (e instanceof XRPCError) {
36
+ if (e.error === 'RepoNotFound') return new RepoNotFoundError(e)
30
37
  }
31
38
  return e
32
39
  }
@@ -12,6 +12,7 @@ export interface QueryParams {}
12
12
  export interface InputSchema {
13
13
  email: string
14
14
  handle: string
15
+ did?: string
15
16
  inviteCode?: string
16
17
  password: string
17
18
  recoveryKey?: string
@@ -68,6 +69,18 @@ export class UnsupportedDomainError extends XRPCError {
68
69
  }
69
70
  }
70
71
 
72
+ export class UnresolvableDidError extends XRPCError {
73
+ constructor(src: XRPCError) {
74
+ super(src.status, src.error, src.message)
75
+ }
76
+ }
77
+
78
+ export class IncompatibleDidDocError extends XRPCError {
79
+ constructor(src: XRPCError) {
80
+ super(src.status, src.error, src.message)
81
+ }
82
+ }
83
+
71
84
  export function toKnownErr(e: any) {
72
85
  if (e instanceof XRPCError) {
73
86
  if (e.error === 'InvalidHandle') return new InvalidHandleError(e)
@@ -75,6 +88,8 @@ export function toKnownErr(e: any) {
75
88
  if (e.error === 'InvalidInviteCode') return new InvalidInviteCodeError(e)
76
89
  if (e.error === 'HandleNotAvailable') return new HandleNotAvailableError(e)
77
90
  if (e.error === 'UnsupportedDomain') return new UnsupportedDomainError(e)
91
+ if (e.error === 'UnresolvableDid') return new UnresolvableDidError(e)
92
+ if (e.error === 'IncompatibleDidDoc') return new IncompatibleDidDocError(e)
78
93
  }
79
94
  return e
80
95
  }
@@ -398,4 +398,67 @@ describe('agent', () => {
398
398
  expect(sessions.length).toEqual(1)
399
399
  expect(sessions[0]?.accessJwt).toEqual(origAccessJwt)
400
400
  })
401
+
402
+ describe('setPersistSessionHandler', () => {
403
+ it('sets persist session handler', async () => {
404
+ let originalHandlerCallCount = 0
405
+ let newHandlerCallCount = 0
406
+
407
+ const persistSession = () => {
408
+ originalHandlerCallCount++
409
+ }
410
+ const newPersistSession = () => {
411
+ newHandlerCallCount++
412
+ }
413
+
414
+ const agent = new AtpAgent({ service: server.url, persistSession })
415
+
416
+ await agent.createAccount({
417
+ handle: 'user7.test',
418
+ email: 'user7@test.com',
419
+ password: 'password',
420
+ })
421
+
422
+ expect(originalHandlerCallCount).toEqual(1)
423
+
424
+ agent.setPersistSessionHandler(newPersistSession)
425
+
426
+ await agent.createAccount({
427
+ handle: 'user8.test',
428
+ email: 'user8@test.com',
429
+ password: 'password',
430
+ })
431
+
432
+ expect(originalHandlerCallCount).toEqual(1)
433
+ expect(newHandlerCallCount).toEqual(1)
434
+ })
435
+ })
436
+
437
+ describe('createAccount', () => {
438
+ it('persists an empty session on failure', async () => {
439
+ const events: string[] = []
440
+ const sessions: (AtpSessionData | undefined)[] = []
441
+ const persistSession = (evt: AtpSessionEvent, sess?: AtpSessionData) => {
442
+ events.push(evt)
443
+ sessions.push(sess)
444
+ }
445
+
446
+ const agent = new AtpAgent({ service: server.url, persistSession })
447
+
448
+ await expect(
449
+ agent.createAccount({
450
+ handle: '',
451
+ email: '',
452
+ password: 'password',
453
+ }),
454
+ ).rejects.toThrow()
455
+
456
+ expect(agent.hasSession).toEqual(false)
457
+ expect(agent.session).toEqual(undefined)
458
+ expect(events.length).toEqual(1)
459
+ expect(events[0]).toEqual('create-failed')
460
+ expect(sessions.length).toEqual(1)
461
+ expect(sessions[0]).toEqual(undefined)
462
+ })
463
+ })
401
464
  })