@atproto/pds 0.4.103 → 0.4.105

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 (328) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/account-manager/{index.d.ts → account-manager.d.ts} +26 -35
  3. package/dist/account-manager/account-manager.d.ts.map +1 -0
  4. package/dist/account-manager/{index.js → account-manager.js} +52 -207
  5. package/dist/account-manager/account-manager.js.map +1 -0
  6. package/dist/account-manager/helpers/account.d.ts +3 -3
  7. package/dist/account-manager/helpers/device-account.d.ts +15 -15
  8. package/dist/account-manager/helpers/device-account.d.ts.map +1 -1
  9. package/dist/account-manager/helpers/device-account.js +2 -1
  10. package/dist/account-manager/helpers/device-account.js.map +1 -1
  11. package/dist/account-manager/helpers/token.d.ts +98 -98
  12. package/dist/account-manager/oauth-store.d.ts +58 -0
  13. package/dist/account-manager/oauth-store.d.ts.map +1 -0
  14. package/dist/account-manager/oauth-store.js +417 -0
  15. package/dist/account-manager/oauth-store.js.map +1 -0
  16. package/dist/actor-store/record/reader.d.ts +3 -3
  17. package/dist/actor-store/repo/reader.d.ts +2 -0
  18. package/dist/actor-store/repo/reader.d.ts.map +1 -1
  19. package/dist/actor-store/repo/reader.js +9 -0
  20. package/dist/actor-store/repo/reader.js.map +1 -1
  21. package/dist/actor-store/repo/sql-repo-reader.d.ts +1 -1
  22. package/dist/actor-store/repo/transactor.d.ts.map +1 -1
  23. package/dist/actor-store/repo/transactor.js +13 -4
  24. package/dist/actor-store/repo/transactor.js.map +1 -1
  25. package/dist/api/com/atproto/admin/deleteAccount.d.ts.map +1 -1
  26. package/dist/api/com/atproto/admin/deleteAccount.js +2 -3
  27. package/dist/api/com/atproto/admin/deleteAccount.js.map +1 -1
  28. package/dist/api/com/atproto/admin/sendEmail.d.ts.map +1 -1
  29. package/dist/api/com/atproto/admin/sendEmail.js +2 -7
  30. package/dist/api/com/atproto/admin/sendEmail.js.map +1 -1
  31. package/dist/api/com/atproto/admin/updateAccountEmail.d.ts.map +1 -1
  32. package/dist/api/com/atproto/admin/updateAccountEmail.js +1 -2
  33. package/dist/api/com/atproto/admin/updateAccountEmail.js.map +1 -1
  34. package/dist/api/com/atproto/admin/updateAccountHandle.d.ts.map +1 -1
  35. package/dist/api/com/atproto/admin/updateAccountHandle.js +2 -6
  36. package/dist/api/com/atproto/admin/updateAccountHandle.js.map +1 -1
  37. package/dist/api/com/atproto/admin/updateAccountPassword.d.ts.map +1 -1
  38. package/dist/api/com/atproto/admin/updateAccountPassword.js +1 -2
  39. package/dist/api/com/atproto/admin/updateAccountPassword.js.map +1 -1
  40. package/dist/api/com/atproto/identity/requestPlcOperationSignature.d.ts.map +1 -1
  41. package/dist/api/com/atproto/identity/requestPlcOperationSignature.js +2 -7
  42. package/dist/api/com/atproto/identity/requestPlcOperationSignature.js.map +1 -1
  43. package/dist/api/com/atproto/identity/resolveHandle.d.ts.map +1 -1
  44. package/dist/api/com/atproto/identity/resolveHandle.js +2 -36
  45. package/dist/api/com/atproto/identity/resolveHandle.js.map +1 -1
  46. package/dist/api/com/atproto/identity/signPlcOperation.d.ts.map +1 -1
  47. package/dist/api/com/atproto/identity/signPlcOperation.js +2 -7
  48. package/dist/api/com/atproto/identity/signPlcOperation.js.map +1 -1
  49. package/dist/api/com/atproto/identity/updateHandle.d.ts.map +1 -1
  50. package/dist/api/com/atproto/identity/updateHandle.js +3 -14
  51. package/dist/api/com/atproto/identity/updateHandle.js.map +1 -1
  52. package/dist/api/com/atproto/repo/applyWrites.d.ts.map +1 -1
  53. package/dist/api/com/atproto/repo/applyWrites.js +12 -7
  54. package/dist/api/com/atproto/repo/applyWrites.js.map +1 -1
  55. package/dist/api/com/atproto/repo/createRecord.d.ts.map +1 -1
  56. package/dist/api/com/atproto/repo/createRecord.js +12 -8
  57. package/dist/api/com/atproto/repo/createRecord.js.map +1 -1
  58. package/dist/api/com/atproto/repo/deleteRecord.d.ts.map +1 -1
  59. package/dist/api/com/atproto/repo/deleteRecord.js +12 -7
  60. package/dist/api/com/atproto/repo/deleteRecord.js.map +1 -1
  61. package/dist/api/com/atproto/repo/listRecords.d.ts.map +1 -1
  62. package/dist/api/com/atproto/repo/listRecords.js +1 -3
  63. package/dist/api/com/atproto/repo/listRecords.js.map +1 -1
  64. package/dist/api/com/atproto/repo/putRecord.d.ts.map +1 -1
  65. package/dist/api/com/atproto/repo/putRecord.js +11 -8
  66. package/dist/api/com/atproto/repo/putRecord.js.map +1 -1
  67. package/dist/api/com/atproto/server/activateAccount.d.ts.map +1 -1
  68. package/dist/api/com/atproto/server/activateAccount.js +3 -20
  69. package/dist/api/com/atproto/server/activateAccount.js.map +1 -1
  70. package/dist/api/com/atproto/server/confirmEmail.d.ts.map +1 -1
  71. package/dist/api/com/atproto/server/confirmEmail.js +2 -7
  72. package/dist/api/com/atproto/server/confirmEmail.js.map +1 -1
  73. package/dist/api/com/atproto/server/createAccount.d.ts.map +1 -1
  74. package/dist/api/com/atproto/server/createAccount.js +5 -7
  75. package/dist/api/com/atproto/server/createAccount.js.map +1 -1
  76. package/dist/api/com/atproto/server/createAppPassword.d.ts.map +1 -1
  77. package/dist/api/com/atproto/server/createAppPassword.js +2 -7
  78. package/dist/api/com/atproto/server/createAppPassword.js.map +1 -1
  79. package/dist/api/com/atproto/server/createSession.js +2 -2
  80. package/dist/api/com/atproto/server/createSession.js.map +1 -1
  81. package/dist/api/com/atproto/server/deactivateAccount.d.ts.map +1 -1
  82. package/dist/api/com/atproto/server/deactivateAccount.js +1 -2
  83. package/dist/api/com/atproto/server/deactivateAccount.js.map +1 -1
  84. package/dist/api/com/atproto/server/deleteAccount.d.ts.map +1 -1
  85. package/dist/api/com/atproto/server/deleteAccount.js +3 -5
  86. package/dist/api/com/atproto/server/deleteAccount.js.map +1 -1
  87. package/dist/api/com/atproto/server/deleteSession.d.ts.map +1 -1
  88. package/dist/api/com/atproto/server/deleteSession.js +2 -3
  89. package/dist/api/com/atproto/server/deleteSession.js.map +1 -1
  90. package/dist/api/com/atproto/server/getAccountInviteCodes.d.ts.map +1 -1
  91. package/dist/api/com/atproto/server/getAccountInviteCodes.js +2 -7
  92. package/dist/api/com/atproto/server/getAccountInviteCodes.js.map +1 -1
  93. package/dist/api/com/atproto/server/getSession.js +2 -2
  94. package/dist/api/com/atproto/server/getSession.js.map +1 -1
  95. package/dist/api/com/atproto/server/listAppPasswords.d.ts.map +1 -1
  96. package/dist/api/com/atproto/server/listAppPasswords.js +2 -7
  97. package/dist/api/com/atproto/server/listAppPasswords.js.map +1 -1
  98. package/dist/api/com/atproto/server/refreshSession.js +2 -2
  99. package/dist/api/com/atproto/server/refreshSession.js.map +1 -1
  100. package/dist/api/com/atproto/server/requestAccountDelete.d.ts.map +1 -1
  101. package/dist/api/com/atproto/server/requestAccountDelete.js +2 -7
  102. package/dist/api/com/atproto/server/requestAccountDelete.js.map +1 -1
  103. package/dist/api/com/atproto/server/requestEmailConfirmation.d.ts.map +1 -1
  104. package/dist/api/com/atproto/server/requestEmailConfirmation.js +2 -7
  105. package/dist/api/com/atproto/server/requestEmailConfirmation.js.map +1 -1
  106. package/dist/api/com/atproto/server/requestEmailUpdate.d.ts.map +1 -1
  107. package/dist/api/com/atproto/server/requestEmailUpdate.js +2 -7
  108. package/dist/api/com/atproto/server/requestEmailUpdate.js.map +1 -1
  109. package/dist/api/com/atproto/server/requestPasswordReset.d.ts.map +1 -1
  110. package/dist/api/com/atproto/server/requestPasswordReset.js +1 -2
  111. package/dist/api/com/atproto/server/requestPasswordReset.js.map +1 -1
  112. package/dist/api/com/atproto/server/resetPassword.d.ts.map +1 -1
  113. package/dist/api/com/atproto/server/resetPassword.js +1 -2
  114. package/dist/api/com/atproto/server/resetPassword.js.map +1 -1
  115. package/dist/api/com/atproto/server/revokeAppPassword.d.ts.map +1 -1
  116. package/dist/api/com/atproto/server/revokeAppPassword.js +2 -7
  117. package/dist/api/com/atproto/server/revokeAppPassword.js.map +1 -1
  118. package/dist/api/com/atproto/server/updateEmail.d.ts.map +1 -1
  119. package/dist/api/com/atproto/server/updateEmail.js +2 -7
  120. package/dist/api/com/atproto/server/updateEmail.js.map +1 -1
  121. package/dist/api/com/atproto/sync/getRecord.d.ts.map +1 -1
  122. package/dist/api/com/atproto/sync/getRecord.js +1 -4
  123. package/dist/api/com/atproto/sync/getRecord.js.map +1 -1
  124. package/dist/api/com/atproto/sync/getRepoStatus.js +1 -1
  125. package/dist/api/com/atproto/sync/getRepoStatus.js.map +1 -1
  126. package/dist/api/com/atproto/sync/listRepos.js +1 -1
  127. package/dist/api/com/atproto/sync/listRepos.js.map +1 -1
  128. package/dist/api/com/atproto/sync/subscribeRepos.d.ts.map +1 -1
  129. package/dist/api/com/atproto/sync/subscribeRepos.js +2 -10
  130. package/dist/api/com/atproto/sync/subscribeRepos.js.map +1 -1
  131. package/dist/api/com/atproto/temp/checkSignupQueue.js +1 -1
  132. package/dist/api/com/atproto/temp/checkSignupQueue.js.map +1 -1
  133. package/dist/api/proxy.d.ts +7 -8
  134. package/dist/api/proxy.d.ts.map +1 -1
  135. package/dist/api/proxy.js +14 -6
  136. package/dist/api/proxy.js.map +1 -1
  137. package/dist/app-view.d.ts +14 -0
  138. package/dist/app-view.d.ts.map +1 -0
  139. package/dist/app-view.js +36 -0
  140. package/dist/app-view.js.map +1 -0
  141. package/dist/auth-routes.d.ts +1 -1
  142. package/dist/auth-routes.d.ts.map +1 -1
  143. package/dist/auth-routes.js +9 -3
  144. package/dist/auth-routes.js.map +1 -1
  145. package/dist/auth-verifier.d.ts +1 -1
  146. package/dist/auth-verifier.d.ts.map +1 -1
  147. package/dist/config/config.d.ts +3 -2
  148. package/dist/config/config.d.ts.map +1 -1
  149. package/dist/config/config.js +17 -7
  150. package/dist/config/config.js.map +1 -1
  151. package/dist/config/env.d.ts +4 -0
  152. package/dist/config/env.d.ts.map +1 -1
  153. package/dist/config/env.js +5 -0
  154. package/dist/config/env.js.map +1 -1
  155. package/dist/context.d.ts +11 -4
  156. package/dist/context.d.ts.map +1 -1
  157. package/dist/context.js +33 -18
  158. package/dist/context.js.map +1 -1
  159. package/dist/handle/index.d.ts +0 -7
  160. package/dist/handle/index.d.ts.map +1 -1
  161. package/dist/handle/index.js +4 -58
  162. package/dist/handle/index.js.map +1 -1
  163. package/dist/image/image-url.d.ts +8 -0
  164. package/dist/image/image-url.d.ts.map +1 -0
  165. package/dist/image/image-url.js +26 -0
  166. package/dist/image/image-url.js.map +1 -0
  167. package/dist/index.js +1 -1
  168. package/dist/index.js.map +1 -1
  169. package/dist/lexicon/index.d.ts +6 -0
  170. package/dist/lexicon/index.d.ts.map +1 -1
  171. package/dist/lexicon/index.js +12 -0
  172. package/dist/lexicon/index.js.map +1 -1
  173. package/dist/lexicon/lexicons.d.ts +412 -158
  174. package/dist/lexicon/lexicons.d.ts.map +1 -1
  175. package/dist/lexicon/lexicons.js +222 -81
  176. package/dist/lexicon/lexicons.js.map +1 -1
  177. package/dist/lexicon/types/app/bsky/embed/video.d.ts +1 -0
  178. package/dist/lexicon/types/app/bsky/embed/video.d.ts.map +1 -1
  179. package/dist/lexicon/types/app/bsky/embed/video.js.map +1 -1
  180. package/dist/lexicon/types/app/bsky/labeler/defs.d.ts +7 -0
  181. package/dist/lexicon/types/app/bsky/labeler/defs.d.ts.map +1 -1
  182. package/dist/lexicon/types/app/bsky/labeler/defs.js.map +1 -1
  183. package/dist/lexicon/types/app/bsky/labeler/service.d.ts +7 -0
  184. package/dist/lexicon/types/app/bsky/labeler/service.d.ts.map +1 -1
  185. package/dist/lexicon/types/app/bsky/labeler/service.js.map +1 -1
  186. package/dist/lexicon/types/com/atproto/identity/defs.d.ts +17 -0
  187. package/dist/lexicon/types/com/atproto/identity/defs.d.ts.map +1 -0
  188. package/dist/lexicon/types/com/atproto/identity/defs.js +16 -0
  189. package/dist/lexicon/types/com/atproto/identity/defs.js.map +1 -0
  190. package/dist/lexicon/types/com/atproto/identity/refreshIdentity.d.ts +39 -0
  191. package/dist/lexicon/types/com/atproto/identity/refreshIdentity.d.ts.map +1 -0
  192. package/dist/lexicon/types/com/atproto/identity/refreshIdentity.js +7 -0
  193. package/dist/lexicon/types/com/atproto/identity/refreshIdentity.js.map +1 -0
  194. package/dist/lexicon/types/com/atproto/identity/resolveDid.d.ts +40 -0
  195. package/dist/lexicon/types/com/atproto/identity/resolveDid.d.ts.map +1 -0
  196. package/dist/lexicon/types/com/atproto/identity/resolveDid.js +7 -0
  197. package/dist/lexicon/types/com/atproto/identity/resolveDid.js.map +1 -0
  198. package/dist/lexicon/types/com/atproto/identity/resolveHandle.d.ts +1 -0
  199. package/dist/lexicon/types/com/atproto/identity/resolveHandle.d.ts.map +1 -1
  200. package/dist/lexicon/types/com/atproto/identity/resolveIdentity.d.ts +36 -0
  201. package/dist/lexicon/types/com/atproto/identity/resolveIdentity.d.ts.map +1 -0
  202. package/dist/lexicon/types/com/atproto/identity/resolveIdentity.js +7 -0
  203. package/dist/lexicon/types/com/atproto/identity/resolveIdentity.js.map +1 -0
  204. package/dist/lexicon/types/com/atproto/moderation/defs.d.ts +2 -0
  205. package/dist/lexicon/types/com/atproto/moderation/defs.d.ts.map +1 -1
  206. package/dist/lexicon/types/com/atproto/repo/listRecords.d.ts +0 -4
  207. package/dist/lexicon/types/com/atproto/repo/listRecords.d.ts.map +1 -1
  208. package/dist/lexicon/types/com/atproto/repo/listRecords.js.map +1 -1
  209. package/dist/lexicon/types/com/atproto/sync/getRecord.d.ts +0 -2
  210. package/dist/lexicon/types/com/atproto/sync/getRecord.d.ts.map +1 -1
  211. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.d.ts +1 -30
  212. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.d.ts.map +1 -1
  213. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.js +0 -27
  214. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.js.map +1 -1
  215. package/dist/mailer/index.d.ts +5 -5
  216. package/dist/mailer/index.d.ts.map +1 -1
  217. package/dist/mailer/index.js +6 -5
  218. package/dist/mailer/index.js.map +1 -1
  219. package/dist/read-after-write/viewer.d.ts +1 -1
  220. package/dist/read-after-write/viewer.d.ts.map +1 -1
  221. package/dist/repo/types.d.ts +6 -2
  222. package/dist/repo/types.d.ts.map +1 -1
  223. package/dist/repo/types.js.map +1 -1
  224. package/dist/scripts/rebuild-repo.d.ts.map +1 -1
  225. package/dist/scripts/rebuild-repo.js +2 -1
  226. package/dist/scripts/rebuild-repo.js.map +1 -1
  227. package/dist/sequencer/db/schema.d.ts +1 -1
  228. package/dist/sequencer/db/schema.d.ts.map +1 -1
  229. package/dist/sequencer/events.d.ts +29 -41
  230. package/dist/sequencer/events.d.ts.map +1 -1
  231. package/dist/sequencer/events.js +24 -58
  232. package/dist/sequencer/events.js.map +1 -1
  233. package/dist/sequencer/sequencer.d.ts +2 -3
  234. package/dist/sequencer/sequencer.d.ts.map +1 -1
  235. package/dist/sequencer/sequencer.js +5 -17
  236. package/dist/sequencer/sequencer.js.map +1 -1
  237. package/package.json +15 -15
  238. package/src/account-manager/{index.ts → account-manager.ts} +107 -307
  239. package/src/account-manager/helpers/device-account.ts +1 -0
  240. package/src/account-manager/oauth-store.ts +494 -0
  241. package/src/actor-store/repo/reader.ts +11 -0
  242. package/src/actor-store/repo/transactor.ts +15 -4
  243. package/src/api/com/atproto/admin/deleteAccount.ts +2 -3
  244. package/src/api/com/atproto/admin/sendEmail.ts +3 -5
  245. package/src/api/com/atproto/admin/updateAccountEmail.ts +1 -2
  246. package/src/api/com/atproto/admin/updateAccountHandle.ts +7 -8
  247. package/src/api/com/atproto/admin/updateAccountPassword.ts +1 -2
  248. package/src/api/com/atproto/identity/requestPlcOperationSignature.ts +3 -5
  249. package/src/api/com/atproto/identity/resolveHandle.ts +2 -11
  250. package/src/api/com/atproto/identity/signPlcOperation.ts +3 -5
  251. package/src/api/com/atproto/identity/updateHandle.ts +7 -13
  252. package/src/api/com/atproto/repo/applyWrites.ts +21 -11
  253. package/src/api/com/atproto/repo/createRecord.ts +19 -14
  254. package/src/api/com/atproto/repo/deleteRecord.ts +26 -14
  255. package/src/api/com/atproto/repo/listRecords.ts +1 -11
  256. package/src/api/com/atproto/repo/putRecord.ts +24 -16
  257. package/src/api/com/atproto/server/activateAccount.ts +5 -20
  258. package/src/api/com/atproto/server/confirmEmail.ts +3 -5
  259. package/src/api/com/atproto/server/createAccount.ts +10 -11
  260. package/src/api/com/atproto/server/createAppPassword.ts +3 -6
  261. package/src/api/com/atproto/server/createSession.ts +3 -3
  262. package/src/api/com/atproto/server/deactivateAccount.ts +1 -2
  263. package/src/api/com/atproto/server/deleteAccount.ts +3 -5
  264. package/src/api/com/atproto/server/deleteSession.ts +2 -3
  265. package/src/api/com/atproto/server/getAccountInviteCodes.ts +3 -5
  266. package/src/api/com/atproto/server/getSession.ts +3 -3
  267. package/src/api/com/atproto/server/listAppPasswords.ts +3 -5
  268. package/src/api/com/atproto/server/refreshSession.ts +3 -3
  269. package/src/api/com/atproto/server/requestAccountDelete.ts +3 -5
  270. package/src/api/com/atproto/server/requestEmailConfirmation.ts +3 -5
  271. package/src/api/com/atproto/server/requestEmailUpdate.ts +3 -5
  272. package/src/api/com/atproto/server/requestPasswordReset.ts +1 -2
  273. package/src/api/com/atproto/server/resetPassword.ts +1 -2
  274. package/src/api/com/atproto/server/revokeAppPassword.ts +3 -5
  275. package/src/api/com/atproto/server/updateEmail.ts +3 -5
  276. package/src/api/com/atproto/sync/getRecord.ts +1 -4
  277. package/src/api/com/atproto/sync/getRepoStatus.ts +1 -1
  278. package/src/api/com/atproto/sync/listRepos.ts +1 -1
  279. package/src/api/com/atproto/sync/subscribeRepos.ts +2 -9
  280. package/src/api/com/atproto/temp/checkSignupQueue.ts +2 -2
  281. package/src/api/proxy.ts +19 -19
  282. package/src/app-view.ts +24 -0
  283. package/src/auth-routes.ts +9 -3
  284. package/src/auth-verifier.ts +1 -1
  285. package/src/config/config.ts +25 -13
  286. package/src/config/env.ts +12 -0
  287. package/src/context.ts +60 -24
  288. package/src/handle/index.ts +6 -52
  289. package/src/image/image-url.ts +16 -0
  290. package/src/index.ts +1 -1
  291. package/src/lexicon/index.ts +36 -0
  292. package/src/lexicon/lexicons.ts +243 -84
  293. package/src/lexicon/types/app/bsky/embed/video.ts +1 -0
  294. package/src/lexicon/types/app/bsky/labeler/defs.ts +7 -0
  295. package/src/lexicon/types/app/bsky/labeler/service.ts +7 -0
  296. package/src/lexicon/types/com/atproto/identity/defs.ts +30 -0
  297. package/src/lexicon/types/com/atproto/identity/refreshIdentity.ts +52 -0
  298. package/src/lexicon/types/com/atproto/identity/resolveDid.ts +52 -0
  299. package/src/lexicon/types/com/atproto/identity/resolveHandle.ts +1 -0
  300. package/src/lexicon/types/com/atproto/identity/resolveIdentity.ts +48 -0
  301. package/src/lexicon/types/com/atproto/moderation/defs.ts +3 -0
  302. package/src/lexicon/types/com/atproto/repo/listRecords.ts +0 -4
  303. package/src/lexicon/types/com/atproto/sync/getRecord.ts +0 -2
  304. package/src/lexicon/types/com/atproto/sync/subscribeRepos.ts +0 -59
  305. package/src/mailer/index.ts +7 -5
  306. package/src/read-after-write/viewer.ts +1 -1
  307. package/src/repo/types.ts +7 -2
  308. package/src/scripts/rebuild-repo.ts +4 -1
  309. package/src/sequencer/db/schema.ts +1 -8
  310. package/src/sequencer/events.ts +29 -75
  311. package/src/sequencer/sequencer.ts +9 -23
  312. package/tests/account-deletion.test.ts +3 -5
  313. package/tests/oauth.test.ts +286 -71
  314. package/tests/sequencer.test.ts +18 -27
  315. package/tests/sync/subscribe-repos.test.ts +67 -45
  316. package/tsconfig.build.tsbuildinfo +1 -1
  317. package/dist/account-manager/index.d.ts.map +0 -1
  318. package/dist/account-manager/index.js.map +0 -1
  319. package/dist/actor-store/repo/util.d.ts +0 -5
  320. package/dist/actor-store/repo/util.d.ts.map +0 -1
  321. package/dist/actor-store/repo/util.js +0 -25
  322. package/dist/actor-store/repo/util.js.map +0 -1
  323. package/dist/oauth/provider.d.ts +0 -10
  324. package/dist/oauth/provider.d.ts.map +0 -1
  325. package/dist/oauth/provider.js +0 -38
  326. package/dist/oauth/provider.js.map +0 -1
  327. package/src/actor-store/repo/util.ts +0 -22
  328. package/src/oauth/provider.ts +0 -59
package/src/context.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import assert from 'node:assert'
2
2
  import * as plc from '@did-plc/lib'
3
+ import express from 'express'
3
4
  import { Redis } from 'ioredis'
4
5
  import * as nodemailer from 'nodemailer'
5
6
  import * as undici from 'undici'
@@ -7,7 +8,12 @@ import { AtpAgent } from '@atproto/api'
7
8
  import { KmsKeypair, S3BlobStore } from '@atproto/aws'
8
9
  import * as crypto from '@atproto/crypto'
9
10
  import { IdResolver } from '@atproto/identity'
10
- import { JoseKey, OAuthVerifier } from '@atproto/oauth-provider'
11
+ import {
12
+ AccessTokenType,
13
+ JoseKey,
14
+ OAuthProvider,
15
+ OAuthVerifier,
16
+ } from '@atproto/oauth-provider'
11
17
  import { BlobStore } from '@atproto/repo'
12
18
  import {
13
19
  RateLimiter,
@@ -23,8 +29,10 @@ import {
23
29
  safeFetchWrap,
24
30
  unicastLookup,
25
31
  } from '@atproto-labs/fetch-node'
26
- import { AccountManager } from './account-manager'
32
+ import { AccountManager } from './account-manager/account-manager'
33
+ import { OAuthStore } from './account-manager/oauth-store'
27
34
  import { ActorStore } from './actor-store/actor-store'
35
+ import { authPassthru, forwardedFor } from './api/proxy'
28
36
  import {
29
37
  AuthVerifier,
30
38
  createPublicKeyObject,
@@ -40,7 +48,6 @@ import { ImageUrlBuilder } from './image/image-url-builder'
40
48
  import { fetchLogger } from './logger'
41
49
  import { ServerMailer } from './mailer'
42
50
  import { ModerationMailer } from './mailer/moderation'
43
- import { PdsOAuthProvider } from './oauth/provider'
44
51
  import { LocalViewer, LocalViewerCreator } from './read-after-write/viewer'
45
52
  import { getRedisClient } from './redis'
46
53
  import { Sequencer } from './sequencer'
@@ -66,7 +73,7 @@ export type AppContextOptions = {
66
73
  entrywayAgent?: AtpAgent
67
74
  proxyAgent: undici.Dispatcher
68
75
  safeFetch: Fetch
69
- authProvider?: PdsOAuthProvider
76
+ oauthProvider?: OAuthProvider
70
77
  authVerifier: AuthVerifier
71
78
  plcRotationKey: crypto.Keypair
72
79
  cfg: ServerConfig
@@ -94,7 +101,7 @@ export class AppContext {
94
101
  public proxyAgent: undici.Dispatcher
95
102
  public safeFetch: Fetch
96
103
  public authVerifier: AuthVerifier
97
- public authProvider?: PdsOAuthProvider
104
+ public oauthProvider?: OAuthProvider
98
105
  public plcRotationKey: crypto.Keypair
99
106
  public cfg: ServerConfig
100
107
 
@@ -120,7 +127,7 @@ export class AppContext {
120
127
  this.proxyAgent = opts.proxyAgent
121
128
  this.safeFetch = opts.safeFetch
122
129
  this.authVerifier = opts.authVerifier
123
- this.authProvider = opts.authProvider
130
+ this.oauthProvider = opts.oauthProvider
124
131
  this.plcRotationKey = opts.plcRotationKey
125
132
  this.cfg = opts.cfg
126
133
  }
@@ -245,13 +252,11 @@ export class AppContext {
245
252
  })
246
253
 
247
254
  const accountManager = new AccountManager(
248
- actorStore,
249
- imageUrlBuilder,
250
- backgroundQueue,
251
- cfg.db.accountDbLoc,
255
+ idResolver,
252
256
  jwtSecretKey,
253
257
  cfg.service.did,
254
- cfg.db.disableWalAutoCheckpoint,
258
+ cfg.identity.serviceHandleDomains,
259
+ cfg.db,
255
260
  )
256
261
  await accountManager.migrateOrThrow()
257
262
 
@@ -321,26 +326,43 @@ export class AppContext {
321
326
  logError: false,
322
327
  })
323
328
 
324
- const authProvider = cfg.oauth.provider
325
- ? new PdsOAuthProvider({
329
+ const oauthProvider = cfg.oauth.provider
330
+ ? new OAuthProvider({
326
331
  issuer: cfg.oauth.issuer,
327
- keyset: [
328
- // Note: OpenID compatibility would require an RS256 private key in this list
329
- await JoseKey.fromKeyLike(jwtSecretKey, undefined, 'HS256'),
330
- ],
331
- accountManager,
332
+ keyset: [await JoseKey.fromKeyLike(jwtSecretKey, undefined, 'HS256')],
333
+ store: new OAuthStore(
334
+ accountManager,
335
+ actorStore,
336
+ imageUrlBuilder,
337
+ backgroundQueue,
338
+ mailer,
339
+ sequencer,
340
+ plcClient,
341
+ plcRotationKey,
342
+ cfg.service.publicUrl,
343
+ cfg.identity.recoveryDidKey,
344
+ ),
332
345
  redis: redisScratch,
333
346
  dpopSecret: secrets.dpopSecret,
334
- customization: cfg.oauth.provider.customization,
347
+ inviteCodeRequired: cfg.invites.required,
348
+ availableUserDomains: cfg.identity.serviceHandleDomains,
349
+ hcaptcha: cfg.oauth.provider.hcaptcha,
350
+ branding: cfg.oauth.provider.branding,
335
351
  safeFetch,
336
- // @TODO: Make this configurable. The legacy implementation used to
337
- // blindly trust the X-Forwarded-For header.
338
- trustProxy: (_addr: string, _i: number) => true,
352
+ metadata: {
353
+ protected_resources: [new URL(cfg.oauth.issuer).origin],
354
+ scopes_supported: ['transition:generic', 'transition:chat.bsky'],
355
+ },
356
+ // If the PDS is both an authorization server & resource server (no
357
+ // entryway), there is no need to use JWTs as access tokens. Instead,
358
+ // the PDS can use tokenId as access tokens. This allows the PDS to
359
+ // always use up-to-date token data from the token store.
360
+ accessTokenType: AccessTokenType.id,
339
361
  })
340
362
  : undefined
341
363
 
342
364
  const oauthVerifier: OAuthVerifier =
343
- authProvider ?? // OAuthProvider extends OAuthVerifier
365
+ oauthProvider ?? // OAuthProvider extends OAuthVerifier
344
366
  new OAuthVerifier({
345
367
  issuer: cfg.oauth.issuer,
346
368
  keyset: [await JoseKey.fromKeyLike(jwtPublicKey!, undefined, 'ES256K')],
@@ -386,7 +408,7 @@ export class AppContext {
386
408
  proxyAgent,
387
409
  safeFetch,
388
410
  authVerifier,
389
- authProvider,
411
+ oauthProvider,
390
412
  plcRotationKey,
391
413
  cfg,
392
414
  ...(overrides ?? {}),
@@ -398,6 +420,20 @@ export class AppContext {
398
420
  return this.serviceAuthHeaders(did, this.bskyAppView.did, lxm)
399
421
  }
400
422
 
423
+ async entrywayAuthHeaders(req: express.Request, did: string, lxm: string) {
424
+ assert(this.cfg.entryway)
425
+ const headers = await this.serviceAuthHeaders(
426
+ did,
427
+ this.cfg.entryway.did,
428
+ lxm,
429
+ )
430
+ return forwardedFor(req, headers)
431
+ }
432
+
433
+ entrywayPassthruHeaders(req: express.Request) {
434
+ return forwardedFor(req, authPassthru(req))
435
+ }
436
+
401
437
  async serviceAuthHeaders(did: string, aud: string, lxm: string) {
402
438
  const keypair = await this.actorStore.keypair(did)
403
439
  return createServiceAuthHeaders({
@@ -1,61 +1,15 @@
1
- import * as ident from '@atproto/syntax'
1
+ import {
2
+ InvalidHandleError,
3
+ normalizeAndEnsureValidHandle,
4
+ } from '@atproto/syntax'
2
5
  import { InvalidRequestError } from '@atproto/xrpc-server'
3
- import { AppContext } from '../context'
4
- import { hasExplicitSlur } from './explicit-slurs'
5
6
  import { reservedSubdomains } from './reserved'
6
7
 
7
- export const normalizeAndValidateHandle = async (opts: {
8
- ctx: AppContext
9
- handle: string
10
- did?: string
11
- allowReserved?: boolean
12
- }): Promise<string> => {
13
- const { ctx, did, allowReserved } = opts
14
- // base formatting validation
15
- const handle = baseNormalizeAndValidate(opts.handle)
16
- // tld validation
17
- if (!ident.isValidTld(handle)) {
18
- throw new InvalidRequestError(
19
- 'Handle TLD is invalid or disallowed',
20
- 'InvalidHandle',
21
- )
22
- }
23
- // slur check
24
- if (hasExplicitSlur(handle)) {
25
- throw new InvalidRequestError(
26
- 'Inappropriate language in handle',
27
- 'InvalidHandle',
28
- )
29
- }
30
- if (isServiceDomain(handle, ctx.cfg.identity.serviceHandleDomains)) {
31
- // verify constraints on a service domain
32
- ensureHandleServiceConstraints(
33
- handle,
34
- ctx.cfg.identity.serviceHandleDomains,
35
- allowReserved,
36
- )
37
- } else {
38
- if (opts.did === undefined) {
39
- throw new InvalidRequestError(
40
- 'Not a supported handle domain',
41
- 'UnsupportedDomain',
42
- )
43
- }
44
- // verify resolution of a non-service domain
45
- const resolvedDid = await ctx.idResolver.handle.resolve(handle)
46
- if (resolvedDid !== did) {
47
- throw new InvalidRequestError('External handle did not resolve to DID')
48
- }
49
- }
50
- return handle
51
- }
52
-
53
8
  export const baseNormalizeAndValidate = (handle: string) => {
54
9
  try {
55
- const normalized = ident.normalizeAndEnsureValidHandle(handle)
56
- return normalized
10
+ return normalizeAndEnsureValidHandle(handle)
57
11
  } catch (err) {
58
- if (err instanceof ident.InvalidHandleError) {
12
+ if (err instanceof InvalidHandleError) {
59
13
  throw new InvalidRequestError(err.message, 'InvalidHandle')
60
14
  }
61
15
  throw err
@@ -0,0 +1,16 @@
1
+ import { AppView } from '../app-view'
2
+ import { ids } from '../lexicon/lexicons'
3
+
4
+ export class ImageUrlBuilder {
5
+ constructor(
6
+ readonly pdsHostname: string,
7
+ readonly appview?: AppView,
8
+ ) {}
9
+
10
+ build(pattern: string, did: string, cid: string): string {
11
+ return (
12
+ this.appview?.getImageUrl(pattern, did, cid) ??
13
+ `https://${this.pdsHostname}/xrpc/${ids.ComAtprotoSyncGetBlob}?did=${did}&cid=${cid}`
14
+ )
15
+ }
16
+ }
package/src/index.ts CHANGED
@@ -122,7 +122,7 @@ export class PDS {
122
122
  server = API(server, ctx)
123
123
 
124
124
  const app = express()
125
- app.set('trust proxy', true)
125
+ app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal'])
126
126
  app.use(loggerMiddleware)
127
127
  app.use(compression())
128
128
  app.use(authRoutes.createRouter(ctx)) // Before CORS
@@ -24,8 +24,11 @@ import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/u
24
24
  import * as ComAtprotoAdminUpdateAccountPassword from './types/com/atproto/admin/updateAccountPassword.js'
25
25
  import * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus.js'
26
26
  import * as ComAtprotoIdentityGetRecommendedDidCredentials from './types/com/atproto/identity/getRecommendedDidCredentials.js'
27
+ import * as ComAtprotoIdentityRefreshIdentity from './types/com/atproto/identity/refreshIdentity.js'
27
28
  import * as ComAtprotoIdentityRequestPlcOperationSignature from './types/com/atproto/identity/requestPlcOperationSignature.js'
29
+ import * as ComAtprotoIdentityResolveDid from './types/com/atproto/identity/resolveDid.js'
28
30
  import * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle.js'
31
+ import * as ComAtprotoIdentityResolveIdentity from './types/com/atproto/identity/resolveIdentity.js'
29
32
  import * as ComAtprotoIdentitySignPlcOperation from './types/com/atproto/identity/signPlcOperation.js'
30
33
  import * as ComAtprotoIdentitySubmitPlcOperation from './types/com/atproto/identity/submitPlcOperation.js'
31
34
  import * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle.js'
@@ -480,6 +483,17 @@ export class ComAtprotoIdentityNS {
480
483
  return this._server.xrpc.method(nsid, cfg)
481
484
  }
482
485
 
486
+ refreshIdentity<AV extends AuthVerifier>(
487
+ cfg: ConfigOf<
488
+ AV,
489
+ ComAtprotoIdentityRefreshIdentity.Handler<ExtractAuth<AV>>,
490
+ ComAtprotoIdentityRefreshIdentity.HandlerReqCtx<ExtractAuth<AV>>
491
+ >,
492
+ ) {
493
+ const nsid = 'com.atproto.identity.refreshIdentity' // @ts-ignore
494
+ return this._server.xrpc.method(nsid, cfg)
495
+ }
496
+
483
497
  requestPlcOperationSignature<AV extends AuthVerifier>(
484
498
  cfg: ConfigOf<
485
499
  AV,
@@ -493,6 +507,17 @@ export class ComAtprotoIdentityNS {
493
507
  return this._server.xrpc.method(nsid, cfg)
494
508
  }
495
509
 
510
+ resolveDid<AV extends AuthVerifier>(
511
+ cfg: ConfigOf<
512
+ AV,
513
+ ComAtprotoIdentityResolveDid.Handler<ExtractAuth<AV>>,
514
+ ComAtprotoIdentityResolveDid.HandlerReqCtx<ExtractAuth<AV>>
515
+ >,
516
+ ) {
517
+ const nsid = 'com.atproto.identity.resolveDid' // @ts-ignore
518
+ return this._server.xrpc.method(nsid, cfg)
519
+ }
520
+
496
521
  resolveHandle<AV extends AuthVerifier>(
497
522
  cfg: ConfigOf<
498
523
  AV,
@@ -504,6 +529,17 @@ export class ComAtprotoIdentityNS {
504
529
  return this._server.xrpc.method(nsid, cfg)
505
530
  }
506
531
 
532
+ resolveIdentity<AV extends AuthVerifier>(
533
+ cfg: ConfigOf<
534
+ AV,
535
+ ComAtprotoIdentityResolveIdentity.Handler<ExtractAuth<AV>>,
536
+ ComAtprotoIdentityResolveIdentity.HandlerReqCtx<ExtractAuth<AV>>
537
+ >,
538
+ ) {
539
+ const nsid = 'com.atproto.identity.resolveIdentity' // @ts-ignore
540
+ return this._server.xrpc.method(nsid, cfg)
541
+ }
542
+
507
543
  signPlcOperation<AV extends AuthVerifier>(
508
544
  cfg: ConfigOf<
509
545
  AV,