@atproto/pds 0.4.164 → 0.4.166

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 (296) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/account-manager/account-manager.js +2 -2
  3. package/dist/account-manager/account-manager.js.map +1 -1
  4. package/dist/account-manager/helpers/account-device.d.ts +4 -4
  5. package/dist/account-manager/helpers/account.d.ts +1 -1
  6. package/dist/account-manager/helpers/auth.d.ts +1 -1
  7. package/dist/account-manager/helpers/auth.d.ts.map +1 -1
  8. package/dist/account-manager/helpers/auth.js +8 -8
  9. package/dist/account-manager/helpers/auth.js.map +1 -1
  10. package/dist/account-manager/helpers/authorization-request.d.ts +1 -1
  11. package/dist/account-manager/helpers/authorization-request.d.ts.map +1 -1
  12. package/dist/account-manager/helpers/authorization-request.js +16 -8
  13. package/dist/account-manager/helpers/authorization-request.js.map +1 -1
  14. package/dist/account-manager/helpers/token.d.ts +65 -65
  15. package/dist/actor-store/preference/reader.d.ts +2 -2
  16. package/dist/actor-store/preference/reader.d.ts.map +1 -1
  17. package/dist/actor-store/preference/reader.js +2 -2
  18. package/dist/actor-store/preference/reader.js.map +1 -1
  19. package/dist/actor-store/preference/transactor.d.ts +2 -2
  20. package/dist/actor-store/preference/transactor.d.ts.map +1 -1
  21. package/dist/actor-store/preference/transactor.js +5 -5
  22. package/dist/actor-store/preference/transactor.js.map +1 -1
  23. package/dist/actor-store/preference/util.d.ts +4 -2
  24. package/dist/actor-store/preference/util.d.ts.map +1 -1
  25. package/dist/actor-store/preference/util.js +9 -8
  26. package/dist/actor-store/preference/util.js.map +1 -1
  27. package/dist/actor-store/record/reader.d.ts +2 -2
  28. package/dist/api/app/bsky/actor/getPreferences.d.ts.map +1 -1
  29. package/dist/api/app/bsky/actor/getPreferences.js +29 -7
  30. package/dist/api/app/bsky/actor/getPreferences.js.map +1 -1
  31. package/dist/api/app/bsky/actor/getProfile.d.ts.map +1 -1
  32. package/dist/api/app/bsky/actor/getProfile.js +9 -1
  33. package/dist/api/app/bsky/actor/getProfile.js.map +1 -1
  34. package/dist/api/app/bsky/actor/getProfiles.d.ts.map +1 -1
  35. package/dist/api/app/bsky/actor/getProfiles.js +9 -1
  36. package/dist/api/app/bsky/actor/getProfiles.js.map +1 -1
  37. package/dist/api/app/bsky/actor/putPreferences.d.ts.map +1 -1
  38. package/dist/api/app/bsky/actor/putPreferences.js +30 -8
  39. package/dist/api/app/bsky/actor/putPreferences.js.map +1 -1
  40. package/dist/api/app/bsky/feed/getActorLikes.d.ts.map +1 -1
  41. package/dist/api/app/bsky/feed/getActorLikes.js +9 -1
  42. package/dist/api/app/bsky/feed/getActorLikes.js.map +1 -1
  43. package/dist/api/app/bsky/feed/getAuthorFeed.d.ts.map +1 -1
  44. package/dist/api/app/bsky/feed/getAuthorFeed.js +9 -1
  45. package/dist/api/app/bsky/feed/getAuthorFeed.js.map +1 -1
  46. package/dist/api/app/bsky/feed/getFeed.d.ts.map +1 -1
  47. package/dist/api/app/bsky/feed/getFeed.js +8 -1
  48. package/dist/api/app/bsky/feed/getFeed.js.map +1 -1
  49. package/dist/api/app/bsky/feed/getPostThread.d.ts.map +1 -1
  50. package/dist/api/app/bsky/feed/getPostThread.js +8 -1
  51. package/dist/api/app/bsky/feed/getPostThread.js.map +1 -1
  52. package/dist/api/app/bsky/feed/getTimeline.d.ts.map +1 -1
  53. package/dist/api/app/bsky/feed/getTimeline.js +9 -1
  54. package/dist/api/app/bsky/feed/getTimeline.js.map +1 -1
  55. package/dist/api/app/bsky/notification/registerPush.d.ts.map +1 -1
  56. package/dist/api/app/bsky/notification/registerPush.js +16 -4
  57. package/dist/api/app/bsky/notification/registerPush.js.map +1 -1
  58. package/dist/api/com/atproto/identity/getRecommendedDidCredentials.d.ts.map +1 -1
  59. package/dist/api/com/atproto/identity/getRecommendedDidCredentials.js +5 -1
  60. package/dist/api/com/atproto/identity/getRecommendedDidCredentials.js.map +1 -1
  61. package/dist/api/com/atproto/identity/requestPlcOperationSignature.d.ts.map +1 -1
  62. package/dist/api/com/atproto/identity/requestPlcOperationSignature.js +9 -2
  63. package/dist/api/com/atproto/identity/requestPlcOperationSignature.js.map +1 -1
  64. package/dist/api/com/atproto/identity/signPlcOperation.d.ts.map +1 -1
  65. package/dist/api/com/atproto/identity/signPlcOperation.js +9 -1
  66. package/dist/api/com/atproto/identity/signPlcOperation.js.map +1 -1
  67. package/dist/api/com/atproto/identity/submitPlcOperation.d.ts.map +1 -1
  68. package/dist/api/com/atproto/identity/submitPlcOperation.js +5 -1
  69. package/dist/api/com/atproto/identity/submitPlcOperation.js.map +1 -1
  70. package/dist/api/com/atproto/identity/updateHandle.d.ts.map +1 -1
  71. package/dist/api/com/atproto/identity/updateHandle.js +6 -1
  72. package/dist/api/com/atproto/identity/updateHandle.js.map +1 -1
  73. package/dist/api/com/atproto/moderation/createReport.d.ts.map +1 -1
  74. package/dist/api/com/atproto/moderation/createReport.js +8 -3
  75. package/dist/api/com/atproto/moderation/createReport.js.map +1 -1
  76. package/dist/api/com/atproto/repo/applyWrites.d.ts.map +1 -1
  77. package/dist/api/com/atproto/repo/applyWrites.js +25 -19
  78. package/dist/api/com/atproto/repo/applyWrites.js.map +1 -1
  79. package/dist/api/com/atproto/repo/createRecord.d.ts.map +1 -1
  80. package/dist/api/com/atproto/repo/createRecord.js +10 -1
  81. package/dist/api/com/atproto/repo/createRecord.js.map +1 -1
  82. package/dist/api/com/atproto/repo/deleteRecord.d.ts.map +1 -1
  83. package/dist/api/com/atproto/repo/deleteRecord.js +12 -1
  84. package/dist/api/com/atproto/repo/deleteRecord.js.map +1 -1
  85. package/dist/api/com/atproto/repo/importRepo.d.ts.map +1 -1
  86. package/dist/api/com/atproto/repo/importRepo.js +7 -2
  87. package/dist/api/com/atproto/repo/importRepo.js.map +1 -1
  88. package/dist/api/com/atproto/repo/listMissingBlobs.d.ts.map +1 -1
  89. package/dist/api/com/atproto/repo/listMissingBlobs.js +6 -2
  90. package/dist/api/com/atproto/repo/listMissingBlobs.js.map +1 -1
  91. package/dist/api/com/atproto/repo/putRecord.d.ts.map +1 -1
  92. package/dist/api/com/atproto/repo/putRecord.js +17 -11
  93. package/dist/api/com/atproto/repo/putRecord.js.map +1 -1
  94. package/dist/api/com/atproto/repo/uploadBlob.d.ts.map +1 -1
  95. package/dist/api/com/atproto/repo/uploadBlob.js +5 -1
  96. package/dist/api/com/atproto/repo/uploadBlob.js.map +1 -1
  97. package/dist/api/com/atproto/server/activateAccount.d.ts.map +1 -1
  98. package/dist/api/com/atproto/server/activateAccount.js +7 -1
  99. package/dist/api/com/atproto/server/activateAccount.js.map +1 -1
  100. package/dist/api/com/atproto/server/checkAccountStatus.d.ts.map +1 -1
  101. package/dist/api/com/atproto/server/checkAccountStatus.js +5 -1
  102. package/dist/api/com/atproto/server/checkAccountStatus.js.map +1 -1
  103. package/dist/api/com/atproto/server/confirmEmail.d.ts.map +1 -1
  104. package/dist/api/com/atproto/server/confirmEmail.js +6 -1
  105. package/dist/api/com/atproto/server/confirmEmail.js.map +1 -1
  106. package/dist/api/com/atproto/server/createAppPassword.d.ts.map +1 -1
  107. package/dist/api/com/atproto/server/createAppPassword.js +7 -1
  108. package/dist/api/com/atproto/server/createAppPassword.js.map +1 -1
  109. package/dist/api/com/atproto/server/deactivateAccount.d.ts.map +1 -1
  110. package/dist/api/com/atproto/server/deactivateAccount.js +9 -2
  111. package/dist/api/com/atproto/server/deactivateAccount.js.map +1 -1
  112. package/dist/api/com/atproto/server/deleteSession.d.ts.map +1 -1
  113. package/dist/api/com/atproto/server/deleteSession.js +3 -1
  114. package/dist/api/com/atproto/server/deleteSession.js.map +1 -1
  115. package/dist/api/com/atproto/server/getAccountInviteCodes.d.ts.map +1 -1
  116. package/dist/api/com/atproto/server/getAccountInviteCodes.js +8 -1
  117. package/dist/api/com/atproto/server/getAccountInviteCodes.js.map +1 -1
  118. package/dist/api/com/atproto/server/getServiceAuth.d.ts.map +1 -1
  119. package/dist/api/com/atproto/server/getServiceAuth.js +24 -13
  120. package/dist/api/com/atproto/server/getServiceAuth.js.map +1 -1
  121. package/dist/api/com/atproto/server/getSession.d.ts.map +1 -1
  122. package/dist/api/com/atproto/server/getSession.js +12 -19
  123. package/dist/api/com/atproto/server/getSession.js.map +1 -1
  124. package/dist/api/com/atproto/server/listAppPasswords.d.ts.map +1 -1
  125. package/dist/api/com/atproto/server/listAppPasswords.js +6 -1
  126. package/dist/api/com/atproto/server/listAppPasswords.js.map +1 -1
  127. package/dist/api/com/atproto/server/refreshSession.js +1 -1
  128. package/dist/api/com/atproto/server/refreshSession.js.map +1 -1
  129. package/dist/api/com/atproto/server/requestAccountDelete.d.ts.map +1 -1
  130. package/dist/api/com/atproto/server/requestAccountDelete.js +8 -1
  131. package/dist/api/com/atproto/server/requestAccountDelete.js.map +1 -1
  132. package/dist/api/com/atproto/server/requestEmailConfirmation.d.ts.map +1 -1
  133. package/dist/api/com/atproto/server/requestEmailConfirmation.js +6 -1
  134. package/dist/api/com/atproto/server/requestEmailConfirmation.js.map +1 -1
  135. package/dist/api/com/atproto/server/requestEmailUpdate.d.ts.map +1 -1
  136. package/dist/api/com/atproto/server/requestEmailUpdate.js +6 -1
  137. package/dist/api/com/atproto/server/requestEmailUpdate.js.map +1 -1
  138. package/dist/api/com/atproto/server/revokeAppPassword.d.ts.map +1 -1
  139. package/dist/api/com/atproto/server/revokeAppPassword.js +6 -1
  140. package/dist/api/com/atproto/server/revokeAppPassword.js.map +1 -1
  141. package/dist/api/com/atproto/server/updateEmail.d.ts.map +1 -1
  142. package/dist/api/com/atproto/server/updateEmail.js +8 -1
  143. package/dist/api/com/atproto/server/updateEmail.js.map +1 -1
  144. package/dist/api/com/atproto/sync/deprecated/getCheckout.d.ts.map +1 -1
  145. package/dist/api/com/atproto/sync/deprecated/getCheckout.js +7 -2
  146. package/dist/api/com/atproto/sync/deprecated/getCheckout.js.map +1 -1
  147. package/dist/api/com/atproto/sync/deprecated/getHead.d.ts.map +1 -1
  148. package/dist/api/com/atproto/sync/deprecated/getHead.js +7 -2
  149. package/dist/api/com/atproto/sync/deprecated/getHead.js.map +1 -1
  150. package/dist/api/com/atproto/sync/getBlob.d.ts.map +1 -1
  151. package/dist/api/com/atproto/sync/getBlob.js +7 -3
  152. package/dist/api/com/atproto/sync/getBlob.js.map +1 -1
  153. package/dist/api/com/atproto/sync/getBlocks.d.ts.map +1 -1
  154. package/dist/api/com/atproto/sync/getBlocks.js +7 -2
  155. package/dist/api/com/atproto/sync/getBlocks.js.map +1 -1
  156. package/dist/api/com/atproto/sync/getLatestCommit.d.ts.map +1 -1
  157. package/dist/api/com/atproto/sync/getLatestCommit.js +7 -2
  158. package/dist/api/com/atproto/sync/getLatestCommit.js.map +1 -1
  159. package/dist/api/com/atproto/sync/getRecord.d.ts.map +1 -1
  160. package/dist/api/com/atproto/sync/getRecord.js +7 -2
  161. package/dist/api/com/atproto/sync/getRecord.js.map +1 -1
  162. package/dist/api/com/atproto/sync/getRepo.d.ts.map +1 -1
  163. package/dist/api/com/atproto/sync/getRepo.js +7 -3
  164. package/dist/api/com/atproto/sync/getRepo.js.map +1 -1
  165. package/dist/api/com/atproto/sync/listBlobs.d.ts.map +1 -1
  166. package/dist/api/com/atproto/sync/listBlobs.js +7 -3
  167. package/dist/api/com/atproto/sync/listBlobs.js.map +1 -1
  168. package/dist/api/com/atproto/temp/checkSignupQueue.d.ts.map +1 -1
  169. package/dist/api/com/atproto/temp/checkSignupQueue.js +7 -3
  170. package/dist/api/com/atproto/temp/checkSignupQueue.js.map +1 -1
  171. package/dist/auth-output.d.ts +45 -0
  172. package/dist/auth-output.d.ts.map +1 -0
  173. package/dist/auth-output.js +3 -0
  174. package/dist/auth-output.js.map +1 -0
  175. package/dist/auth-scope.d.ts +16 -0
  176. package/dist/auth-scope.d.ts.map +1 -0
  177. package/dist/auth-scope.js +40 -0
  178. package/dist/auth-scope.js.map +1 -0
  179. package/dist/auth-verifier.d.ts +50 -115
  180. package/dist/auth-verifier.d.ts.map +1 -1
  181. package/dist/auth-verifier.js +275 -366
  182. package/dist/auth-verifier.js.map +1 -1
  183. package/dist/config/config.d.ts +2 -1
  184. package/dist/config/config.d.ts.map +1 -1
  185. package/dist/config/config.js +2 -1
  186. package/dist/config/config.js.map +1 -1
  187. package/dist/config/env.d.ts +1 -0
  188. package/dist/config/env.d.ts.map +1 -1
  189. package/dist/config/env.js +3 -1
  190. package/dist/config/env.js.map +1 -1
  191. package/dist/context.d.ts.map +1 -1
  192. package/dist/context.js +5 -5
  193. package/dist/context.js.map +1 -1
  194. package/dist/lexicon/index.d.ts +234 -230
  195. package/dist/lexicon/index.d.ts.map +1 -1
  196. package/dist/lexicon/index.js +682 -674
  197. package/dist/lexicon/index.js.map +1 -1
  198. package/dist/lexicon/lexicons.d.ts +17994 -17706
  199. package/dist/lexicon/lexicons.d.ts.map +1 -1
  200. package/dist/lexicon/lexicons.js +9126 -8980
  201. package/dist/lexicon/lexicons.js.map +1 -1
  202. package/dist/lexicon/types/app/bsky/graph/getLists.d.ts +2 -0
  203. package/dist/lexicon/types/app/bsky/graph/getLists.d.ts.map +1 -1
  204. package/dist/lexicon/types/app/bsky/graph/getListsWithMembership.d.ts +40 -0
  205. package/dist/lexicon/types/app/bsky/graph/getListsWithMembership.d.ts.map +1 -0
  206. package/dist/lexicon/types/app/bsky/graph/getListsWithMembership.js +16 -0
  207. package/dist/lexicon/types/app/bsky/graph/getListsWithMembership.js.map +1 -0
  208. package/dist/lexicon/types/app/bsky/graph/getStarterPacksWithMembership.d.ts +38 -0
  209. package/dist/lexicon/types/app/bsky/graph/getStarterPacksWithMembership.d.ts.map +1 -0
  210. package/dist/lexicon/types/app/bsky/graph/getStarterPacksWithMembership.js +16 -0
  211. package/dist/lexicon/types/app/bsky/graph/getStarterPacksWithMembership.js.map +1 -0
  212. package/dist/pipethrough.d.ts +5 -3
  213. package/dist/pipethrough.d.ts.map +1 -1
  214. package/dist/pipethrough.js +42 -15
  215. package/dist/pipethrough.js.map +1 -1
  216. package/dist/sequencer/events.d.ts +13 -13
  217. package/dist/util/http.d.ts +7 -0
  218. package/dist/util/http.d.ts.map +1 -0
  219. package/dist/util/http.js +31 -0
  220. package/dist/util/http.js.map +1 -0
  221. package/dist/util/types.d.ts +5 -0
  222. package/dist/util/types.d.ts.map +1 -0
  223. package/dist/util/types.js +3 -0
  224. package/dist/util/types.js.map +1 -0
  225. package/package.json +7 -6
  226. package/src/account-manager/account-manager.ts +1 -1
  227. package/src/account-manager/helpers/auth.ts +1 -1
  228. package/src/account-manager/helpers/authorization-request.ts +8 -4
  229. package/src/actor-store/preference/reader.ts +3 -4
  230. package/src/actor-store/preference/transactor.ts +6 -7
  231. package/src/actor-store/preference/util.ts +15 -5
  232. package/src/api/app/bsky/actor/getPreferences.ts +33 -8
  233. package/src/api/app/bsky/actor/getProfile.ts +9 -1
  234. package/src/api/app/bsky/actor/getProfiles.ts +9 -1
  235. package/src/api/app/bsky/actor/putPreferences.ts +35 -12
  236. package/src/api/app/bsky/feed/getActorLikes.ts +9 -1
  237. package/src/api/app/bsky/feed/getAuthorFeed.ts +9 -1
  238. package/src/api/app/bsky/feed/getFeed.ts +9 -2
  239. package/src/api/app/bsky/feed/getPostThread.ts +8 -1
  240. package/src/api/app/bsky/feed/getTimeline.ts +9 -1
  241. package/src/api/app/bsky/notification/registerPush.ts +16 -5
  242. package/src/api/com/atproto/identity/getRecommendedDidCredentials.ts +5 -1
  243. package/src/api/com/atproto/identity/requestPlcOperationSignature.ts +9 -2
  244. package/src/api/com/atproto/identity/signPlcOperation.ts +9 -1
  245. package/src/api/com/atproto/identity/submitPlcOperation.ts +5 -1
  246. package/src/api/com/atproto/identity/updateHandle.ts +6 -1
  247. package/src/api/com/atproto/moderation/createReport.ts +8 -3
  248. package/src/api/com/atproto/repo/applyWrites.ts +28 -20
  249. package/src/api/com/atproto/repo/createRecord.ts +12 -1
  250. package/src/api/com/atproto/repo/deleteRecord.ts +14 -1
  251. package/src/api/com/atproto/repo/importRepo.ts +9 -2
  252. package/src/api/com/atproto/repo/listMissingBlobs.ts +7 -2
  253. package/src/api/com/atproto/repo/putRecord.ts +18 -10
  254. package/src/api/com/atproto/repo/uploadBlob.ts +6 -2
  255. package/src/api/com/atproto/server/activateAccount.ts +10 -2
  256. package/src/api/com/atproto/server/checkAccountStatus.ts +5 -1
  257. package/src/api/com/atproto/server/confirmEmail.ts +6 -1
  258. package/src/api/com/atproto/server/createAppPassword.ts +9 -1
  259. package/src/api/com/atproto/server/deactivateAccount.ts +11 -2
  260. package/src/api/com/atproto/server/deleteSession.ts +3 -1
  261. package/src/api/com/atproto/server/getAccountInviteCodes.ts +11 -2
  262. package/src/api/com/atproto/server/getServiceAuth.ts +37 -18
  263. package/src/api/com/atproto/server/getSession.ts +20 -27
  264. package/src/api/com/atproto/server/listAppPasswords.ts +8 -1
  265. package/src/api/com/atproto/server/refreshSession.ts +1 -1
  266. package/src/api/com/atproto/server/requestAccountDelete.ts +11 -2
  267. package/src/api/com/atproto/server/requestEmailConfirmation.ts +6 -1
  268. package/src/api/com/atproto/server/requestEmailUpdate.ts +6 -1
  269. package/src/api/com/atproto/server/revokeAppPassword.ts +8 -1
  270. package/src/api/com/atproto/server/updateEmail.ts +11 -2
  271. package/src/api/com/atproto/sync/deprecated/getCheckout.ts +7 -6
  272. package/src/api/com/atproto/sync/deprecated/getHead.ts +7 -6
  273. package/src/api/com/atproto/sync/getBlob.ts +7 -7
  274. package/src/api/com/atproto/sync/getBlocks.ts +7 -6
  275. package/src/api/com/atproto/sync/getLatestCommit.ts +7 -6
  276. package/src/api/com/atproto/sync/getRecord.ts +7 -6
  277. package/src/api/com/atproto/sync/getRepo.ts +7 -7
  278. package/src/api/com/atproto/sync/listBlobs.ts +7 -7
  279. package/src/api/com/atproto/temp/checkSignupQueue.ts +8 -2
  280. package/src/auth-output.ts +51 -0
  281. package/src/auth-scope.ts +40 -0
  282. package/src/auth-verifier.ts +404 -520
  283. package/src/config/config.ts +7 -7
  284. package/src/config/env.ts +5 -1
  285. package/src/context.ts +6 -5
  286. package/src/lexicon/index.ts +1247 -1221
  287. package/src/lexicon/lexicons.ts +9494 -9341
  288. package/src/lexicon/types/app/bsky/graph/getLists.ts +2 -0
  289. package/src/lexicon/types/app/bsky/graph/getListsWithMembership.ts +63 -0
  290. package/src/lexicon/types/app/bsky/graph/getStarterPacksWithMembership.ts +65 -0
  291. package/src/pipethrough.ts +61 -18
  292. package/src/util/http.ts +31 -0
  293. package/src/util/types.ts +7 -0
  294. package/tests/oauth.test.ts +11 -37
  295. package/tests/preferences.test.ts +7 -3
  296. package/tsconfig.build.tsbuildinfo +1 -1
@@ -11,9 +11,12 @@ import {
11
11
 
12
12
  export default function (server: Server, ctx: AppContext) {
13
13
  server.com.atproto.repo.deleteRecord({
14
- auth: ctx.authVerifier.accessStandard({
14
+ auth: ctx.authVerifier.authorization({
15
15
  checkTakedown: true,
16
16
  checkDeactivated: true,
17
+ authorize: () => {
18
+ // Performed in the handler as it requires the request body
19
+ },
17
20
  }),
18
21
  rateLimit: [
19
22
  {
@@ -29,6 +32,16 @@ export default function (server: Server, ctx: AppContext) {
29
32
  ],
30
33
  handler: async ({ input, auth }) => {
31
34
  const { repo, collection, rkey, swapCommit, swapRecord } = input.body
35
+
36
+ // We can't compute permissions based on the request payload ("input") in
37
+ // the 'auth' phase, so we do it here.
38
+ if (auth.credentials.type === 'oauth') {
39
+ auth.credentials.permissions.assertRepo({
40
+ action: 'delete',
41
+ collection,
42
+ })
43
+ }
44
+
32
45
  const account = await ctx.accountManager.getAccount(repo, {
33
46
  includeDeactivated: true,
34
47
  })
@@ -12,19 +12,26 @@ import {
12
12
  import { AtUri } from '@atproto/syntax'
13
13
  import { InvalidRequestError } from '@atproto/xrpc-server'
14
14
  import { ActorStoreTransactor } from '../../../../actor-store/actor-store-transactor'
15
+ import { ACCESS_FULL } from '../../../../auth-scope'
15
16
  import { AppContext } from '../../../../context'
16
17
  import { Server } from '../../../../lexicon'
17
18
 
18
19
  export default function (server: Server, ctx: AppContext) {
19
20
  server.com.atproto.repo.importRepo({
20
- auth: ctx.authVerifier.accessFull({
21
+ auth: ctx.authVerifier.authorization({
21
22
  checkTakedown: true,
23
+ scopes: ACCESS_FULL,
24
+ authorize: (permissions) => {
25
+ permissions.assertAccount({ attr: 'repo', action: 'manage' })
26
+ },
22
27
  }),
23
28
  handler: async ({ input, auth }) => {
24
- const did = auth.credentials.did
25
29
  if (!ctx.cfg.service.acceptingImports) {
26
30
  throw new InvalidRequestError('Service is not accepting repo imports')
27
31
  }
32
+
33
+ const { did } = auth.credentials
34
+
28
35
  await ctx.actorStore.transact(did, (store) =>
29
36
  importRepo(store, input.body),
30
37
  )
@@ -3,10 +3,15 @@ import { Server } from '../../../../lexicon'
3
3
 
4
4
  export default function (server: Server, ctx: AppContext) {
5
5
  server.com.atproto.repo.listMissingBlobs({
6
- auth: ctx.authVerifier.accessStandard(),
6
+ auth: ctx.authVerifier.authorization({
7
+ authorize: () => {
8
+ // always allow
9
+ },
10
+ }),
7
11
  handler: async ({ auth, params }) => {
8
- const did = auth.credentials.did
12
+ const { did } = auth.credentials
9
13
  const { limit, cursor } = params
14
+
10
15
  const blobs = await ctx.actorStore.read(did, (store) =>
11
16
  store.repo.blob.listMissingBlobs({ limit, cursor }),
12
17
  )
@@ -20,9 +20,12 @@ import {
20
20
 
21
21
  export default function (server: Server, ctx: AppContext) {
22
22
  server.com.atproto.repo.putRecord({
23
- auth: ctx.authVerifier.accessStandard({
23
+ auth: ctx.authVerifier.authorization({
24
24
  checkTakedown: true,
25
25
  checkDeactivated: true,
26
+ authorize: () => {
27
+ // Performed in the handler as it requires the request body
28
+ },
26
29
  }),
27
30
  rateLimit: [
28
31
  {
@@ -46,17 +49,22 @@ export default function (server: Server, ctx: AppContext) {
46
49
  swapCommit,
47
50
  swapRecord,
48
51
  } = input.body
49
- const account = await ctx.accountManager.getAccount(repo, {
50
- includeDeactivated: true,
51
- })
52
52
 
53
- if (!account) {
54
- throw new InvalidRequestError(`Could not find repo: ${repo}`)
55
- } else if (account.deactivatedAt) {
56
- throw new InvalidRequestError('Account is deactivated')
53
+ // We can't compute permissions based on the request payload ("input") in
54
+ // the 'auth' phase, so we do it here.
55
+ if (auth.credentials.type === 'oauth') {
56
+ auth.credentials.permissions.assertRepo({
57
+ action: 'create',
58
+ collection,
59
+ })
60
+ auth.credentials.permissions.assertRepo({
61
+ action: 'update',
62
+ collection,
63
+ })
57
64
  }
58
- const did = account.did
59
- if (did !== auth.credentials.did) {
65
+
66
+ const { did } = auth.credentials
67
+ if (did !== repo) {
60
68
  throw new AuthRequiredError()
61
69
  }
62
70
 
@@ -1,13 +1,17 @@
1
1
  import { DAY } from '@atproto/common'
2
- import { UpstreamTimeoutError } from '@atproto/xrpc-server'
2
+ import { UpstreamTimeoutError, parseReqEncoding } from '@atproto/xrpc-server'
3
3
  import { BlobMetadata } from '../../../../actor-store/blob/transactor'
4
4
  import { AppContext } from '../../../../context'
5
5
  import { Server } from '../../../../lexicon'
6
6
 
7
7
  export default function (server: Server, ctx: AppContext) {
8
8
  server.com.atproto.repo.uploadBlob({
9
- auth: ctx.authVerifier.accessOrUserServiceAuth({
9
+ auth: ctx.authVerifier.authorizationOrUserServiceAuth({
10
10
  checkTakedown: true,
11
+ authorize: (permissions, { req }) => {
12
+ const encoding = parseReqEncoding(req)
13
+ permissions.assertBlob({ mime: encoding })
14
+ },
11
15
  }),
12
16
  rateLimit: {
13
17
  durationMs: DAY,
@@ -1,12 +1,20 @@
1
1
  import { INVALID_HANDLE } from '@atproto/syntax'
2
- import { InvalidRequestError } from '@atproto/xrpc-server'
2
+ import { ForbiddenError, InvalidRequestError } from '@atproto/xrpc-server'
3
+ import { ACCESS_FULL } from '../../../../auth-scope'
3
4
  import { AppContext } from '../../../../context'
4
5
  import { Server } from '../../../../lexicon'
5
6
  import { assertValidDidDocumentForService } from './util'
6
7
 
7
8
  export default function (server: Server, ctx: AppContext) {
8
9
  server.com.atproto.server.activateAccount({
9
- auth: ctx.authVerifier.accessFull(),
10
+ auth: ctx.authVerifier.authorization({
11
+ scopes: ACCESS_FULL,
12
+ authorize: () => {
13
+ throw new ForbiddenError(
14
+ 'OAuth credentials are not supported for this endpoint',
15
+ )
16
+ },
17
+ }),
10
18
  handler: async ({ req, auth }) => {
11
19
  // in the case of entryway, the full flow is activateAccount (PDS) -> activateAccount (Entryway) -> updateSubjectStatus(PDS)
12
20
  if (ctx.entrywayAgent) {
@@ -4,7 +4,11 @@ import { isValidDidDocForService } from './util'
4
4
 
5
5
  export default function (server: Server, ctx: AppContext) {
6
6
  server.com.atproto.server.checkAccountStatus({
7
- auth: ctx.authVerifier.accessStandard(),
7
+ auth: ctx.authVerifier.authorization({
8
+ authorize: () => {
9
+ // always allow
10
+ },
11
+ }),
8
12
  handler: async ({ auth }) => {
9
13
  const requester = auth.credentials.did
10
14
  const [
@@ -5,7 +5,12 @@ import { ids } from '../../../../lexicon/lexicons'
5
5
 
6
6
  export default function (server: Server, ctx: AppContext) {
7
7
  server.com.atproto.server.confirmEmail({
8
- auth: ctx.authVerifier.accessStandard({ checkTakedown: true }),
8
+ auth: ctx.authVerifier.authorization({
9
+ checkTakedown: true,
10
+ authorize: (permissions) => {
11
+ permissions.assertAccount({ attr: 'email', action: 'manage' })
12
+ },
13
+ }),
9
14
  handler: async ({ auth, input, req }) => {
10
15
  const did = auth.credentials.did
11
16
 
@@ -1,3 +1,5 @@
1
+ import { ForbiddenError } from '@atproto/xrpc-server'
2
+ import { ACCESS_FULL } from '../../../../auth-scope'
1
3
  import { AppContext } from '../../../../context'
2
4
  import { Server } from '../../../../lexicon'
3
5
  import { ids } from '../../../../lexicon/lexicons'
@@ -5,8 +7,14 @@ import { resultPassthru } from '../../../proxy'
5
7
 
6
8
  export default function (server: Server, ctx: AppContext) {
7
9
  server.com.atproto.server.createAppPassword({
8
- auth: ctx.authVerifier.accessFull({
10
+ auth: ctx.authVerifier.authorization({
9
11
  checkTakedown: true,
12
+ scopes: ACCESS_FULL,
13
+ authorize: () => {
14
+ throw new ForbiddenError(
15
+ 'OAuth credentials are not supported for this endpoint',
16
+ )
17
+ },
10
18
  }),
11
19
  handler: async ({ auth, input, req }) => {
12
20
  if (ctx.entrywayAgent) {
@@ -1,10 +1,19 @@
1
- import { AuthScope } from '../../../../auth-verifier'
1
+ import { ForbiddenError } from '@atproto/xrpc-server'
2
+ import { ACCESS_FULL, AuthScope } from '../../../../auth-scope'
2
3
  import { AppContext } from '../../../../context'
3
4
  import { Server } from '../../../../lexicon'
4
5
 
5
6
  export default function (server: Server, ctx: AppContext) {
6
7
  server.com.atproto.server.deactivateAccount({
7
- auth: ctx.authVerifier.accessFull({ additional: [AuthScope.Takendown] }),
8
+ auth: ctx.authVerifier.authorization({
9
+ additional: [AuthScope.Takendown],
10
+ scopes: ACCESS_FULL,
11
+ authorize: () => {
12
+ throw new ForbiddenError(
13
+ 'OAuth credentials are not supported for this endpoint',
14
+ )
15
+ },
16
+ }),
8
17
  handler: async ({ req, auth, input }) => {
9
18
  // in the case of entryway, the full flow is deactivateAccount (PDS) -> deactivateAccount (Entryway) -> updateSubjectStatus(PDS)
10
19
  if (ctx.entrywayAgent) {
@@ -12,7 +12,9 @@ export default function (server: Server, ctx: AppContext) {
12
12
  })
13
13
  } else {
14
14
  server.com.atproto.server.deleteSession({
15
- auth: ctx.authVerifier.refreshExpired,
15
+ auth: ctx.authVerifier.refresh({
16
+ allowExpired: true,
17
+ }),
16
18
  handler: async ({ auth }) => {
17
19
  await ctx.accountManager.revokeRefreshToken(auth.credentials.tokenId)
18
20
  },
@@ -1,5 +1,6 @@
1
- import { InvalidRequestError } from '@atproto/xrpc-server'
1
+ import { ForbiddenError, InvalidRequestError } from '@atproto/xrpc-server'
2
2
  import { CodeDetail } from '../../../../account-manager/helpers/invite'
3
+ import { ACCESS_FULL } from '../../../../auth-scope'
3
4
  import { AppContext } from '../../../../context'
4
5
  import { Server } from '../../../../lexicon'
5
6
  import { ids } from '../../../../lexicon/lexicons'
@@ -8,7 +9,15 @@ import { genInvCodes } from './util'
8
9
 
9
10
  export default function (server: Server, ctx: AppContext) {
10
11
  server.com.atproto.server.getAccountInviteCodes({
11
- auth: ctx.authVerifier.accessFull({ checkTakedown: true }),
12
+ auth: ctx.authVerifier.authorization({
13
+ checkTakedown: true,
14
+ scopes: ACCESS_FULL,
15
+ authorize: () => {
16
+ throw new ForbiddenError(
17
+ 'OAuth credentials are not supported for this endpoint',
18
+ )
19
+ },
20
+ }),
12
21
  handler: async ({ params, auth, req }) => {
13
22
  if (ctx.entrywayAgent) {
14
23
  return resultPassthru(
@@ -1,6 +1,10 @@
1
1
  import { HOUR, MINUTE } from '@atproto/common'
2
2
  import { InvalidRequestError, createServiceJwt } from '@atproto/xrpc-server'
3
- import { AuthScope } from '../../../../auth-verifier'
3
+ import {
4
+ AuthScope,
5
+ isAccessPrivileged,
6
+ isTakendown,
7
+ } from '../../../../auth-scope'
4
8
  import { AppContext } from '../../../../context'
5
9
  import { Server } from '../../../../lexicon'
6
10
  import { ids } from '../../../../lexicon/lexicons'
@@ -8,19 +12,41 @@ import { PRIVILEGED_METHODS, PROTECTED_METHODS } from '../../../../pipethrough'
8
12
 
9
13
  export default function (server: Server, ctx: AppContext) {
10
14
  server.com.atproto.server.getServiceAuth({
11
- auth: ctx.authVerifier.accessStandard({
15
+ auth: ctx.authVerifier.authorization({
12
16
  additional: [AuthScope.Takendown],
17
+ authorize: (permissions, ctx) => {
18
+ const { aud, lxm = '*' } = ctx.params
19
+ permissions.assertRpc({ aud, lxm })
20
+ },
13
21
  }),
14
22
  handler: async ({ params, auth }) => {
15
23
  const did = auth.credentials.did
24
+
25
+ // @NOTE "exp" is expressed in seconds since epoch, not milliseconds
16
26
  const { aud, exp, lxm = null } = params
17
27
 
18
28
  // Takendown accounts should not be able to generate service auth tokens except for methods necessary for account migration
19
- if (
20
- auth.credentials.scope === AuthScope.Takendown &&
21
- lxm !== ids.ComAtprotoServerCreateAccount
22
- ) {
23
- throw new InvalidRequestError('Bad token scope', 'InvalidToken')
29
+ if (auth.credentials.type === 'access') {
30
+ // @NOTE We should probably use "ForbiddenError" here. Using
31
+ // "InvalidRequestError" for legacy reasons.
32
+ if (
33
+ isTakendown(auth.credentials.scope) &&
34
+ lxm !== ids.ComAtprotoServerCreateAccount
35
+ ) {
36
+ throw new InvalidRequestError('Bad token scope', 'InvalidToken')
37
+ }
38
+
39
+ // @NOTE "oauth" based credentials already checked through permission
40
+ // set in "authorize" method above.
41
+ if (
42
+ lxm != null &&
43
+ PRIVILEGED_METHODS.has(lxm) &&
44
+ !isAccessPrivileged(auth.credentials.scope)
45
+ ) {
46
+ throw new InvalidRequestError(
47
+ `insufficient access to request a service auth token for the following method: ${lxm}`,
48
+ )
49
+ }
24
50
  }
25
51
 
26
52
  if (exp) {
@@ -43,17 +69,10 @@ export default function (server: Server, ctx: AppContext) {
43
69
  }
44
70
  }
45
71
 
46
- if (lxm) {
47
- if (PROTECTED_METHODS.has(lxm)) {
48
- throw new InvalidRequestError(
49
- `cannot request a service auth token for the following protected method: ${lxm}`,
50
- )
51
- }
52
- if (!auth.credentials.isPrivileged && PRIVILEGED_METHODS.has(lxm)) {
53
- throw new InvalidRequestError(
54
- `insufficient access to request a service auth token for the following method: ${lxm}`,
55
- )
56
- }
72
+ if (lxm && PROTECTED_METHODS.has(lxm)) {
73
+ throw new InvalidRequestError(
74
+ `cannot request a service auth token for the following protected method: ${lxm}`,
75
+ )
57
76
  }
58
77
 
59
78
  const keypair = await ctx.actorStore.keypair(did)
@@ -2,27 +2,27 @@ import { ComAtprotoServerGetSession } from '@atproto/api'
2
2
  import { INVALID_HANDLE } from '@atproto/syntax'
3
3
  import { InvalidRequestError } from '@atproto/xrpc-server'
4
4
  import { formatAccountStatus } from '../../../../account-manager/account-manager'
5
- import { AccessOutput, AuthScope, OAuthOutput } from '../../../../auth-verifier'
5
+ import { AccessOutput, OAuthOutput } from '../../../../auth-output'
6
+ import { AuthScope } from '../../../../auth-scope'
6
7
  import { AppContext } from '../../../../context'
7
8
  import { Server } from '../../../../lexicon'
8
9
  import { didDocForSession } from './util'
9
10
 
10
11
  export default function (server: Server, ctx: AppContext) {
11
12
  server.com.atproto.server.getSession({
12
- auth: ctx.authVerifier.accessStandard({
13
+ auth: ctx.authVerifier.authorization({
13
14
  additional: [AuthScope.SignupQueued],
15
+ authorize: () => {
16
+ // Always allowed. "email" access is checked in the handler.
17
+ },
14
18
  }),
15
19
  handler: async ({ auth, req }) => {
16
20
  if (ctx.entrywayAgent) {
17
- // Allow proxying of dpop bound requests by using service auth instead
18
- const headers =
19
- auth.credentials.type === 'oauth' // DPoP bound tokens cannot be proxied
20
- ? await ctx.entrywayAuthHeaders(
21
- req,
22
- auth.credentials.did,
23
- 'com.atproto.server.getSession',
24
- )
25
- : ctx.entrywayPassthruHeaders(req)
21
+ const headers = await ctx.entrywayAuthHeaders(
22
+ req,
23
+ auth.credentials.did,
24
+ 'com.atproto.server.getSession',
25
+ )
26
26
 
27
27
  const res = await ctx.entrywayAgent.com.atproto.server.getSession(
28
28
  undefined,
@@ -65,23 +65,16 @@ export default function (server: Server, ctx: AppContext) {
65
65
  }
66
66
 
67
67
  function output(
68
- { credentials }: AccessOutput | OAuthOutput,
68
+ { credentials }: OAuthOutput | AccessOutput,
69
69
  data: ComAtprotoServerGetSession.OutputSchema,
70
70
  ): ComAtprotoServerGetSession.OutputSchema {
71
- switch (credentials.type) {
72
- case 'access':
73
- return data
74
-
75
- case 'oauth':
76
- if (!credentials.oauthScopes.has('transition:email')) {
77
- const { email, emailAuthFactor, emailConfirmed, ...rest } = data
78
- return rest
79
- }
80
-
81
- return data
82
-
83
- default:
84
- // @ts-expect-error
85
- throw new Error(`Unknown credentials type: ${credentials.type}`)
71
+ if (
72
+ credentials.type === 'oauth' &&
73
+ !credentials.permissions.allowsAccount({ attr: 'email', action: 'read' })
74
+ ) {
75
+ const { email, emailAuthFactor, emailConfirmed, ...rest } = data
76
+ return rest
86
77
  }
78
+
79
+ return data
87
80
  }
@@ -1,3 +1,4 @@
1
+ import { ForbiddenError } from '@atproto/xrpc-server'
1
2
  import { AppContext } from '../../../../context'
2
3
  import { Server } from '../../../../lexicon'
3
4
  import { ids } from '../../../../lexicon/lexicons'
@@ -5,7 +6,13 @@ import { resultPassthru } from '../../../proxy'
5
6
 
6
7
  export default function (server: Server, ctx: AppContext) {
7
8
  server.com.atproto.server.listAppPasswords({
8
- auth: ctx.authVerifier.accessStandard(),
9
+ auth: ctx.authVerifier.authorization({
10
+ authorize: () => {
11
+ throw new ForbiddenError(
12
+ 'OAuth credentials are not supported for this endpoint',
13
+ )
14
+ },
15
+ }),
9
16
  handler: async ({ auth, req }) => {
10
17
  if (ctx.entrywayAgent) {
11
18
  return resultPassthru(
@@ -9,7 +9,7 @@ import { didDocForSession } from './util'
9
9
 
10
10
  export default function (server: Server, ctx: AppContext) {
11
11
  server.com.atproto.server.refreshSession({
12
- auth: ctx.authVerifier.refresh,
12
+ auth: ctx.authVerifier.refresh(),
13
13
  handler: async ({ auth, req }) => {
14
14
  const did = auth.credentials.did
15
15
  const user = await ctx.accountManager.getAccount(did, {
@@ -1,5 +1,6 @@
1
1
  import { DAY, HOUR } from '@atproto/common'
2
- import { InvalidRequestError } from '@atproto/xrpc-server'
2
+ import { ForbiddenError, InvalidRequestError } from '@atproto/xrpc-server'
3
+ import { ACCESS_FULL } from '../../../../auth-scope'
3
4
  import { AppContext } from '../../../../context'
4
5
  import { Server } from '../../../../lexicon'
5
6
  import { ids } from '../../../../lexicon/lexicons'
@@ -18,7 +19,15 @@ export default function (server: Server, ctx: AppContext) {
18
19
  calcKey: ({ auth }) => auth.credentials.did,
19
20
  },
20
21
  ],
21
- auth: ctx.authVerifier.accessFull({ checkTakedown: true }),
22
+ auth: ctx.authVerifier.authorization({
23
+ checkTakedown: true,
24
+ scopes: ACCESS_FULL,
25
+ authorize: () => {
26
+ throw new ForbiddenError(
27
+ 'OAuth credentials are not supported for this endpoint',
28
+ )
29
+ },
30
+ }),
22
31
  handler: async ({ auth, req }) => {
23
32
  const did = auth.credentials.did
24
33
  const account = await ctx.accountManager.getAccount(did, {
@@ -18,7 +18,12 @@ export default function (server: Server, ctx: AppContext) {
18
18
  calcKey: ({ auth }) => auth.credentials.did,
19
19
  },
20
20
  ],
21
- auth: ctx.authVerifier.accessStandard({ checkTakedown: true }),
21
+ auth: ctx.authVerifier.authorization({
22
+ checkTakedown: true,
23
+ authorize: (permissions) => {
24
+ permissions.assertAccount({ attr: 'email', action: 'manage' })
25
+ },
26
+ }),
22
27
  handler: async ({ auth, req }) => {
23
28
  const did = auth.credentials.did
24
29
  const account = await ctx.accountManager.getAccount(did, {
@@ -19,7 +19,12 @@ export default function (server: Server, ctx: AppContext) {
19
19
  calcKey: ({ auth }) => auth.credentials.did,
20
20
  },
21
21
  ],
22
- auth: ctx.authVerifier.accessStandard({ checkTakedown: true }),
22
+ auth: ctx.authVerifier.authorization({
23
+ checkTakedown: true,
24
+ authorize: (permissions) => {
25
+ permissions.assertAccount({ attr: 'email', action: 'manage' })
26
+ },
27
+ }),
23
28
  handler: async ({ auth, req }) => {
24
29
  const did = auth.credentials.did
25
30
  const account = await ctx.accountManager.getAccount(did, {
@@ -1,10 +1,17 @@
1
+ import { ForbiddenError } from '@atproto/xrpc-server'
1
2
  import { AppContext } from '../../../../context'
2
3
  import { Server } from '../../../../lexicon'
3
4
  import { ids } from '../../../../lexicon/lexicons'
4
5
 
5
6
  export default function (server: Server, ctx: AppContext) {
6
7
  server.com.atproto.server.revokeAppPassword({
7
- auth: ctx.authVerifier.accessStandard(),
8
+ auth: ctx.authVerifier.authorization({
9
+ authorize: () => {
10
+ throw new ForbiddenError(
11
+ 'OAuth credentials are not supported for this endpoint',
12
+ )
13
+ },
14
+ }),
8
15
  handler: async ({ auth, input, req }) => {
9
16
  if (ctx.entrywayAgent) {
10
17
  await ctx.entrywayAgent.com.atproto.server.revokeAppPassword(
@@ -1,14 +1,23 @@
1
1
  import { isEmailValid } from '@hapi/address'
2
2
  import { isDisposableEmail } from 'disposable-email-domains-js'
3
- import { InvalidRequestError } from '@atproto/xrpc-server'
3
+ import { ForbiddenError, InvalidRequestError } from '@atproto/xrpc-server'
4
4
  import { UserAlreadyExistsError } from '../../../../account-manager/helpers/account'
5
+ import { ACCESS_FULL } from '../../../../auth-scope'
5
6
  import { AppContext } from '../../../../context'
6
7
  import { Server } from '../../../../lexicon'
7
8
  import { ids } from '../../../../lexicon/lexicons'
8
9
 
9
10
  export default function (server: Server, ctx: AppContext) {
10
11
  server.com.atproto.server.updateEmail({
11
- auth: ctx.authVerifier.accessFull({ checkTakedown: true }),
12
+ auth: ctx.authVerifier.authorization({
13
+ checkTakedown: true,
14
+ scopes: ACCESS_FULL,
15
+ authorize: () => {
16
+ throw new ForbiddenError(
17
+ 'OAuth credentials are not supported for this endpoint',
18
+ )
19
+ },
20
+ }),
12
21
  handler: async ({ auth, input, req }) => {
13
22
  const did = auth.credentials.did
14
23
  const { token, email } = input.body
@@ -1,3 +1,4 @@
1
+ import { isUserOrAdmin } from '../../../../../auth-verifier'
1
2
  import { AppContext } from '../../../../../context'
2
3
  import { Server } from '../../../../../lexicon'
3
4
  import { getCarStream } from '../getRepo'
@@ -5,14 +6,14 @@ import { assertRepoAvailability } from '../util'
5
6
 
6
7
  export default function (server: Server, ctx: AppContext) {
7
8
  server.com.atproto.sync.getCheckout({
8
- auth: ctx.authVerifier.optionalAccessOrAdminToken(),
9
+ auth: ctx.authVerifier.authorizationOrAdminTokenOptional({
10
+ authorize: () => {
11
+ // always allow
12
+ },
13
+ }),
9
14
  handler: async ({ params, auth }) => {
10
15
  const { did } = params
11
- await assertRepoAvailability(
12
- ctx,
13
- did,
14
- ctx.authVerifier.isUserOrAdmin(auth, did),
15
- )
16
+ await assertRepoAvailability(ctx, did, isUserOrAdmin(auth, did))
16
17
 
17
18
  const carStream = await getCarStream(ctx, did)
18
19
 
@@ -1,18 +1,19 @@
1
1
  import { InvalidRequestError } from '@atproto/xrpc-server'
2
+ import { isUserOrAdmin } from '../../../../../auth-verifier'
2
3
  import { AppContext } from '../../../../../context'
3
4
  import { Server } from '../../../../../lexicon'
4
5
  import { assertRepoAvailability } from '../util'
5
6
 
6
7
  export default function (server: Server, ctx: AppContext) {
7
8
  server.com.atproto.sync.getHead({
8
- auth: ctx.authVerifier.optionalAccessOrAdminToken(),
9
+ auth: ctx.authVerifier.authorizationOrAdminTokenOptional({
10
+ authorize: () => {
11
+ // always allow
12
+ },
13
+ }),
9
14
  handler: async ({ params, auth }) => {
10
15
  const { did } = params
11
- await assertRepoAvailability(
12
- ctx,
13
- did,
14
- ctx.authVerifier.isUserOrAdmin(auth, did),
15
- )
16
+ await assertRepoAvailability(ctx, did, isUserOrAdmin(auth, did))
16
17
 
17
18
  const root = await ctx.actorStore.read(did, (store) =>
18
19
  store.repo.storage.getRoot(),
@@ -1,23 +1,23 @@
1
1
  import { CID } from 'multiformats/cid'
2
2
  import { BlobNotFoundError } from '@atproto/repo'
3
3
  import { InvalidRequestError } from '@atproto/xrpc-server'
4
- import { AuthScope } from '../../../../auth-verifier'
4
+ import { AuthScope } from '../../../../auth-scope'
5
+ import { isUserOrAdmin } from '../../../../auth-verifier'
5
6
  import { AppContext } from '../../../../context'
6
7
  import { Server } from '../../../../lexicon'
7
8
  import { assertRepoAvailability } from './util'
8
9
 
9
10
  export default function (server: Server, ctx: AppContext) {
10
11
  server.com.atproto.sync.getBlob({
11
- auth: ctx.authVerifier.optionalAccessOrAdminToken({
12
+ auth: ctx.authVerifier.authorizationOrAdminTokenOptional({
12
13
  additional: [AuthScope.Takendown],
14
+ authorize: () => {
15
+ // always allow
16
+ },
13
17
  }),
14
18
  handler: async ({ params, res, auth }) => {
15
19
  const { did } = params
16
- await assertRepoAvailability(
17
- ctx,
18
- did,
19
- ctx.authVerifier.isUserOrAdmin(auth, did),
20
- )
20
+ await assertRepoAvailability(ctx, did, isUserOrAdmin(auth, did))
21
21
 
22
22
  const cid = CID.parse(params.cid)
23
23
  const found = await ctx.actorStore.read(params.did, async (store) => {