@atproto/lex-space 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/LICENSE.txt +7 -0
  2. package/README.md +463 -2
  3. package/dist/actions.d.ts +17 -0
  4. package/dist/actions.d.ts.map +1 -0
  5. package/dist/actions.js +20 -0
  6. package/dist/actions.js.map +1 -0
  7. package/dist/atproto-did-resolver.d.ts +3 -0
  8. package/dist/atproto-did-resolver.d.ts.map +1 -0
  9. package/dist/atproto-did-resolver.js +2 -0
  10. package/dist/atproto-did-resolver.js.map +1 -0
  11. package/dist/client-attestation-provider.d.ts +57 -0
  12. package/dist/client-attestation-provider.d.ts.map +1 -0
  13. package/dist/client-attestation-provider.js +51 -0
  14. package/dist/client-attestation-provider.js.map +1 -0
  15. package/dist/delegation-token-provider.d.ts +25 -0
  16. package/dist/delegation-token-provider.d.ts.map +1 -0
  17. package/dist/delegation-token-provider.js +28 -0
  18. package/dist/delegation-token-provider.js.map +1 -0
  19. package/dist/errors.d.ts +27 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +27 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/index.d.ts +15 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +15 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/lexicons/com/atproto/managedspace/policy.d.ts +3 -0
  28. package/dist/lexicons/com/atproto/managedspace/policy.d.ts.map +1 -0
  29. package/dist/lexicons/com/atproto/managedspace/policy.defs.d.ts +78 -0
  30. package/dist/lexicons/com/atproto/managedspace/policy.defs.d.ts.map +1 -0
  31. package/dist/lexicons/com/atproto/managedspace/policy.defs.js +23 -0
  32. package/dist/lexicons/com/atproto/managedspace/policy.defs.js.map +1 -0
  33. package/dist/lexicons/com/atproto/managedspace/policy.js +6 -0
  34. package/dist/lexicons/com/atproto/managedspace/policy.js.map +1 -0
  35. package/dist/lexicons/com/atproto/managedspace.d.ts +2 -0
  36. package/dist/lexicons/com/atproto/managedspace.d.ts.map +1 -0
  37. package/dist/lexicons/com/atproto/managedspace.js +5 -0
  38. package/dist/lexicons/com/atproto/managedspace.js.map +1 -0
  39. package/dist/lexicons/com/atproto/memberspace/defs.d.ts +2 -0
  40. package/dist/lexicons/com/atproto/memberspace/defs.d.ts.map +1 -0
  41. package/dist/lexicons/com/atproto/memberspace/defs.defs.d.ts +14 -0
  42. package/dist/lexicons/com/atproto/memberspace/defs.defs.d.ts.map +1 -0
  43. package/dist/lexicons/com/atproto/memberspace/defs.defs.js +9 -0
  44. package/dist/lexicons/com/atproto/memberspace/defs.defs.js.map +1 -0
  45. package/dist/lexicons/com/atproto/memberspace/defs.js +5 -0
  46. package/dist/lexicons/com/atproto/memberspace/defs.js.map +1 -0
  47. package/dist/lexicons/com/atproto/memberspace/listMembers.d.ts +3 -0
  48. package/dist/lexicons/com/atproto/memberspace/listMembers.d.ts.map +1 -0
  49. package/dist/lexicons/com/atproto/memberspace/listMembers.defs.d.ts +35 -0
  50. package/dist/lexicons/com/atproto/memberspace/listMembers.defs.d.ts.map +1 -0
  51. package/dist/lexicons/com/atproto/memberspace/listMembers.defs.js +15 -0
  52. package/dist/lexicons/com/atproto/memberspace/listMembers.defs.js.map +1 -0
  53. package/dist/lexicons/com/atproto/memberspace/listMembers.js +6 -0
  54. package/dist/lexicons/com/atproto/memberspace/listMembers.js.map +1 -0
  55. package/dist/lexicons/com/atproto/memberspace/policy.d.ts +3 -0
  56. package/dist/lexicons/com/atproto/memberspace/policy.d.ts.map +1 -0
  57. package/dist/lexicons/com/atproto/memberspace/policy.defs.d.ts +120 -0
  58. package/dist/lexicons/com/atproto/memberspace/policy.defs.d.ts.map +1 -0
  59. package/dist/lexicons/com/atproto/memberspace/policy.defs.js +23 -0
  60. package/dist/lexicons/com/atproto/memberspace/policy.defs.js.map +1 -0
  61. package/dist/lexicons/com/atproto/memberspace/policy.js +6 -0
  62. package/dist/lexicons/com/atproto/memberspace/policy.js.map +1 -0
  63. package/dist/lexicons/com/atproto/memberspace/putMembers.d.ts +3 -0
  64. package/dist/lexicons/com/atproto/memberspace/putMembers.d.ts.map +1 -0
  65. package/dist/lexicons/com/atproto/memberspace/putMembers.defs.d.ts +30 -0
  66. package/dist/lexicons/com/atproto/memberspace/putMembers.defs.d.ts.map +1 -0
  67. package/dist/lexicons/com/atproto/memberspace/putMembers.defs.js +16 -0
  68. package/dist/lexicons/com/atproto/memberspace/putMembers.defs.js.map +1 -0
  69. package/dist/lexicons/com/atproto/memberspace/putMembers.js +6 -0
  70. package/dist/lexicons/com/atproto/memberspace/putMembers.js.map +1 -0
  71. package/dist/lexicons/com/atproto/memberspace/removeMembers.d.ts +3 -0
  72. package/dist/lexicons/com/atproto/memberspace/removeMembers.d.ts.map +1 -0
  73. package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.d.ts +33 -0
  74. package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.d.ts.map +1 -0
  75. package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.js +15 -0
  76. package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.js.map +1 -0
  77. package/dist/lexicons/com/atproto/memberspace/removeMembers.js +6 -0
  78. package/dist/lexicons/com/atproto/memberspace/removeMembers.js.map +1 -0
  79. package/dist/lexicons/com/atproto/memberspace.d.ts +6 -0
  80. package/dist/lexicons/com/atproto/memberspace.d.ts.map +1 -0
  81. package/dist/lexicons/com/atproto/memberspace.js +9 -0
  82. package/dist/lexicons/com/atproto/memberspace.js.map +1 -0
  83. package/dist/lexicons/com/atproto/personalspace/policy.d.ts +3 -0
  84. package/dist/lexicons/com/atproto/personalspace/policy.d.ts.map +1 -0
  85. package/dist/lexicons/com/atproto/personalspace/policy.defs.d.ts +50 -0
  86. package/dist/lexicons/com/atproto/personalspace/policy.defs.d.ts.map +1 -0
  87. package/dist/lexicons/com/atproto/personalspace/policy.defs.js +23 -0
  88. package/dist/lexicons/com/atproto/personalspace/policy.defs.js.map +1 -0
  89. package/dist/lexicons/com/atproto/personalspace/policy.js +6 -0
  90. package/dist/lexicons/com/atproto/personalspace/policy.js.map +1 -0
  91. package/dist/lexicons/com/atproto/personalspace.d.ts +2 -0
  92. package/dist/lexicons/com/atproto/personalspace.d.ts.map +1 -0
  93. package/dist/lexicons/com/atproto/personalspace.js +5 -0
  94. package/dist/lexicons/com/atproto/personalspace.js.map +1 -0
  95. package/dist/lexicons/com/atproto/space/applyWrites.d.ts +3 -0
  96. package/dist/lexicons/com/atproto/space/applyWrites.d.ts.map +1 -0
  97. package/dist/lexicons/com/atproto/space/applyWrites.defs.d.ts +97 -0
  98. package/dist/lexicons/com/atproto/space/applyWrites.defs.d.ts.map +1 -0
  99. package/dist/lexicons/com/atproto/space/applyWrites.defs.js +30 -0
  100. package/dist/lexicons/com/atproto/space/applyWrites.defs.js.map +1 -0
  101. package/dist/lexicons/com/atproto/space/applyWrites.js +6 -0
  102. package/dist/lexicons/com/atproto/space/applyWrites.js.map +1 -0
  103. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.d.ts +3 -0
  104. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.d.ts.map +1 -0
  105. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.d.ts +59 -0
  106. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.d.ts.map +1 -0
  107. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.js +17 -0
  108. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.js.map +1 -0
  109. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.js +6 -0
  110. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.js.map +1 -0
  111. package/dist/lexicons/com/atproto/space/clearRecords.d.ts +3 -0
  112. package/dist/lexicons/com/atproto/space/clearRecords.d.ts.map +1 -0
  113. package/dist/lexicons/com/atproto/space/clearRecords.defs.d.ts +33 -0
  114. package/dist/lexicons/com/atproto/space/clearRecords.defs.d.ts.map +1 -0
  115. package/dist/lexicons/com/atproto/space/clearRecords.defs.js +15 -0
  116. package/dist/lexicons/com/atproto/space/clearRecords.defs.js.map +1 -0
  117. package/dist/lexicons/com/atproto/space/clearRecords.js +6 -0
  118. package/dist/lexicons/com/atproto/space/clearRecords.js.map +1 -0
  119. package/dist/lexicons/com/atproto/space/createRecord.d.ts +3 -0
  120. package/dist/lexicons/com/atproto/space/createRecord.d.ts.map +1 -0
  121. package/dist/lexicons/com/atproto/space/createRecord.defs.d.ts +69 -0
  122. package/dist/lexicons/com/atproto/space/createRecord.defs.d.ts.map +1 -0
  123. package/dist/lexicons/com/atproto/space/createRecord.defs.js +15 -0
  124. package/dist/lexicons/com/atproto/space/createRecord.defs.js.map +1 -0
  125. package/dist/lexicons/com/atproto/space/createRecord.js +6 -0
  126. package/dist/lexicons/com/atproto/space/createRecord.js.map +1 -0
  127. package/dist/lexicons/com/atproto/space/createSpace.d.ts +3 -0
  128. package/dist/lexicons/com/atproto/space/createSpace.d.ts.map +1 -0
  129. package/dist/lexicons/com/atproto/space/createSpace.defs.d.ts +46 -0
  130. package/dist/lexicons/com/atproto/space/createSpace.defs.d.ts.map +1 -0
  131. package/dist/lexicons/com/atproto/space/createSpace.defs.js +18 -0
  132. package/dist/lexicons/com/atproto/space/createSpace.defs.js.map +1 -0
  133. package/dist/lexicons/com/atproto/space/createSpace.js +6 -0
  134. package/dist/lexicons/com/atproto/space/createSpace.js.map +1 -0
  135. package/dist/lexicons/com/atproto/space/defs.d.ts +2 -0
  136. package/dist/lexicons/com/atproto/space/defs.d.ts.map +1 -0
  137. package/dist/lexicons/com/atproto/space/defs.defs.d.ts +60 -0
  138. package/dist/lexicons/com/atproto/space/defs.defs.d.ts.map +1 -0
  139. package/dist/lexicons/com/atproto/space/defs.defs.js +16 -0
  140. package/dist/lexicons/com/atproto/space/defs.defs.js.map +1 -0
  141. package/dist/lexicons/com/atproto/space/defs.js +5 -0
  142. package/dist/lexicons/com/atproto/space/defs.js.map +1 -0
  143. package/dist/lexicons/com/atproto/space/deleteRecord.d.ts +3 -0
  144. package/dist/lexicons/com/atproto/space/deleteRecord.d.ts.map +1 -0
  145. package/dist/lexicons/com/atproto/space/deleteRecord.defs.d.ts +45 -0
  146. package/dist/lexicons/com/atproto/space/deleteRecord.defs.d.ts.map +1 -0
  147. package/dist/lexicons/com/atproto/space/deleteRecord.defs.js +15 -0
  148. package/dist/lexicons/com/atproto/space/deleteRecord.defs.js.map +1 -0
  149. package/dist/lexicons/com/atproto/space/deleteRecord.js +6 -0
  150. package/dist/lexicons/com/atproto/space/deleteRecord.js.map +1 -0
  151. package/dist/lexicons/com/atproto/space/deleteSpace.d.ts +3 -0
  152. package/dist/lexicons/com/atproto/space/deleteSpace.d.ts.map +1 -0
  153. package/dist/lexicons/com/atproto/space/deleteSpace.defs.d.ts +27 -0
  154. package/dist/lexicons/com/atproto/space/deleteSpace.defs.d.ts.map +1 -0
  155. package/dist/lexicons/com/atproto/space/deleteSpace.defs.js +15 -0
  156. package/dist/lexicons/com/atproto/space/deleteSpace.defs.js.map +1 -0
  157. package/dist/lexicons/com/atproto/space/deleteSpace.js +6 -0
  158. package/dist/lexicons/com/atproto/space/deleteSpace.js.map +1 -0
  159. package/dist/lexicons/com/atproto/space/getBlob.d.ts +3 -0
  160. package/dist/lexicons/com/atproto/space/getBlob.d.ts.map +1 -0
  161. package/dist/lexicons/com/atproto/space/getBlob.defs.d.ts +36 -0
  162. package/dist/lexicons/com/atproto/space/getBlob.defs.d.ts.map +1 -0
  163. package/dist/lexicons/com/atproto/space/getBlob.defs.js +14 -0
  164. package/dist/lexicons/com/atproto/space/getBlob.defs.js.map +1 -0
  165. package/dist/lexicons/com/atproto/space/getBlob.js +6 -0
  166. package/dist/lexicons/com/atproto/space/getBlob.js.map +1 -0
  167. package/dist/lexicons/com/atproto/space/getDelegationToken.d.ts +3 -0
  168. package/dist/lexicons/com/atproto/space/getDelegationToken.d.ts.map +1 -0
  169. package/dist/lexicons/com/atproto/space/getDelegationToken.defs.d.ts +28 -0
  170. package/dist/lexicons/com/atproto/space/getDelegationToken.defs.d.ts.map +1 -0
  171. package/dist/lexicons/com/atproto/space/getDelegationToken.defs.js +14 -0
  172. package/dist/lexicons/com/atproto/space/getDelegationToken.defs.js.map +1 -0
  173. package/dist/lexicons/com/atproto/space/getDelegationToken.js +6 -0
  174. package/dist/lexicons/com/atproto/space/getDelegationToken.js.map +1 -0
  175. package/dist/lexicons/com/atproto/space/getLatestCommit.d.ts +3 -0
  176. package/dist/lexicons/com/atproto/space/getLatestCommit.d.ts.map +1 -0
  177. package/dist/lexicons/com/atproto/space/getLatestCommit.defs.d.ts +35 -0
  178. package/dist/lexicons/com/atproto/space/getLatestCommit.defs.d.ts.map +1 -0
  179. package/dist/lexicons/com/atproto/space/getLatestCommit.defs.js +15 -0
  180. package/dist/lexicons/com/atproto/space/getLatestCommit.defs.js.map +1 -0
  181. package/dist/lexicons/com/atproto/space/getLatestCommit.js +6 -0
  182. package/dist/lexicons/com/atproto/space/getLatestCommit.js.map +1 -0
  183. package/dist/lexicons/com/atproto/space/getRecord.d.ts +3 -0
  184. package/dist/lexicons/com/atproto/space/getRecord.d.ts.map +1 -0
  185. package/dist/lexicons/com/atproto/space/getRecord.defs.d.ts +58 -0
  186. package/dist/lexicons/com/atproto/space/getRecord.defs.d.ts.map +1 -0
  187. package/dist/lexicons/com/atproto/space/getRecord.defs.js +14 -0
  188. package/dist/lexicons/com/atproto/space/getRecord.defs.js.map +1 -0
  189. package/dist/lexicons/com/atproto/space/getRecord.js +6 -0
  190. package/dist/lexicons/com/atproto/space/getRecord.js.map +1 -0
  191. package/dist/lexicons/com/atproto/space/getRepo.d.ts +3 -0
  192. package/dist/lexicons/com/atproto/space/getRepo.d.ts.map +1 -0
  193. package/dist/lexicons/com/atproto/space/getRepo.defs.d.ts +30 -0
  194. package/dist/lexicons/com/atproto/space/getRepo.defs.d.ts.map +1 -0
  195. package/dist/lexicons/com/atproto/space/getRepo.defs.js +14 -0
  196. package/dist/lexicons/com/atproto/space/getRepo.defs.js.map +1 -0
  197. package/dist/lexicons/com/atproto/space/getRepo.js +6 -0
  198. package/dist/lexicons/com/atproto/space/getRepo.js.map +1 -0
  199. package/dist/lexicons/com/atproto/space/getSpace.d.ts +3 -0
  200. package/dist/lexicons/com/atproto/space/getSpace.d.ts.map +1 -0
  201. package/dist/lexicons/com/atproto/space/getSpace.defs.d.ts +37 -0
  202. package/dist/lexicons/com/atproto/space/getSpace.defs.d.ts.map +1 -0
  203. package/dist/lexicons/com/atproto/space/getSpace.defs.js +17 -0
  204. package/dist/lexicons/com/atproto/space/getSpace.defs.js.map +1 -0
  205. package/dist/lexicons/com/atproto/space/getSpace.js +6 -0
  206. package/dist/lexicons/com/atproto/space/getSpace.js.map +1 -0
  207. package/dist/lexicons/com/atproto/space/getSpaceCredential.d.ts +3 -0
  208. package/dist/lexicons/com/atproto/space/getSpaceCredential.d.ts.map +1 -0
  209. package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.d.ts +53 -0
  210. package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.d.ts.map +1 -0
  211. package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.js +17 -0
  212. package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.js.map +1 -0
  213. package/dist/lexicons/com/atproto/space/getSpaceCredential.js +6 -0
  214. package/dist/lexicons/com/atproto/space/getSpaceCredential.js.map +1 -0
  215. package/dist/lexicons/com/atproto/space/listBlobs.d.ts +3 -0
  216. package/dist/lexicons/com/atproto/space/listBlobs.d.ts.map +1 -0
  217. package/dist/lexicons/com/atproto/space/listBlobs.defs.d.ts +44 -0
  218. package/dist/lexicons/com/atproto/space/listBlobs.defs.d.ts.map +1 -0
  219. package/dist/lexicons/com/atproto/space/listBlobs.defs.js +14 -0
  220. package/dist/lexicons/com/atproto/space/listBlobs.defs.js.map +1 -0
  221. package/dist/lexicons/com/atproto/space/listBlobs.js +6 -0
  222. package/dist/lexicons/com/atproto/space/listBlobs.js.map +1 -0
  223. package/dist/lexicons/com/atproto/space/listRecords.d.ts +3 -0
  224. package/dist/lexicons/com/atproto/space/listRecords.d.ts.map +1 -0
  225. package/dist/lexicons/com/atproto/space/listRecords.defs.d.ts +58 -0
  226. package/dist/lexicons/com/atproto/space/listRecords.defs.d.ts.map +1 -0
  227. package/dist/lexicons/com/atproto/space/listRecords.defs.js +16 -0
  228. package/dist/lexicons/com/atproto/space/listRecords.defs.js.map +1 -0
  229. package/dist/lexicons/com/atproto/space/listRecords.js +6 -0
  230. package/dist/lexicons/com/atproto/space/listRecords.js.map +1 -0
  231. package/dist/lexicons/com/atproto/space/listRepoOps.d.ts +3 -0
  232. package/dist/lexicons/com/atproto/space/listRepoOps.d.ts.map +1 -0
  233. package/dist/lexicons/com/atproto/space/listRepoOps.defs.d.ts +74 -0
  234. package/dist/lexicons/com/atproto/space/listRepoOps.defs.d.ts.map +1 -0
  235. package/dist/lexicons/com/atproto/space/listRepoOps.defs.js +18 -0
  236. package/dist/lexicons/com/atproto/space/listRepoOps.defs.js.map +1 -0
  237. package/dist/lexicons/com/atproto/space/listRepoOps.js +6 -0
  238. package/dist/lexicons/com/atproto/space/listRepoOps.js.map +1 -0
  239. package/dist/lexicons/com/atproto/space/listSpaces.d.ts +3 -0
  240. package/dist/lexicons/com/atproto/space/listSpaces.d.ts.map +1 -0
  241. package/dist/lexicons/com/atproto/space/listSpaces.defs.d.ts +59 -0
  242. package/dist/lexicons/com/atproto/space/listSpaces.defs.d.ts.map +1 -0
  243. package/dist/lexicons/com/atproto/space/listSpaces.defs.js +16 -0
  244. package/dist/lexicons/com/atproto/space/listSpaces.defs.js.map +1 -0
  245. package/dist/lexicons/com/atproto/space/listSpaces.js +6 -0
  246. package/dist/lexicons/com/atproto/space/listSpaces.js.map +1 -0
  247. package/dist/lexicons/com/atproto/space/listWriters.d.ts +3 -0
  248. package/dist/lexicons/com/atproto/space/listWriters.d.ts.map +1 -0
  249. package/dist/lexicons/com/atproto/space/listWriters.defs.d.ts +35 -0
  250. package/dist/lexicons/com/atproto/space/listWriters.defs.d.ts.map +1 -0
  251. package/dist/lexicons/com/atproto/space/listWriters.defs.js +15 -0
  252. package/dist/lexicons/com/atproto/space/listWriters.defs.js.map +1 -0
  253. package/dist/lexicons/com/atproto/space/listWriters.js +6 -0
  254. package/dist/lexicons/com/atproto/space/listWriters.js.map +1 -0
  255. package/dist/lexicons/com/atproto/space/putRecord.d.ts +3 -0
  256. package/dist/lexicons/com/atproto/space/putRecord.d.ts.map +1 -0
  257. package/dist/lexicons/com/atproto/space/putRecord.defs.d.ts +69 -0
  258. package/dist/lexicons/com/atproto/space/putRecord.defs.d.ts.map +1 -0
  259. package/dist/lexicons/com/atproto/space/putRecord.defs.js +15 -0
  260. package/dist/lexicons/com/atproto/space/putRecord.defs.js.map +1 -0
  261. package/dist/lexicons/com/atproto/space/putRecord.js +6 -0
  262. package/dist/lexicons/com/atproto/space/putRecord.js.map +1 -0
  263. package/dist/lexicons/com/atproto/space/registerNotify.d.ts +3 -0
  264. package/dist/lexicons/com/atproto/space/registerNotify.d.ts.map +1 -0
  265. package/dist/lexicons/com/atproto/space/registerNotify.defs.d.ts +37 -0
  266. package/dist/lexicons/com/atproto/space/registerNotify.defs.d.ts.map +1 -0
  267. package/dist/lexicons/com/atproto/space/registerNotify.defs.js +23 -0
  268. package/dist/lexicons/com/atproto/space/registerNotify.defs.js.map +1 -0
  269. package/dist/lexicons/com/atproto/space/registerNotify.js +6 -0
  270. package/dist/lexicons/com/atproto/space/registerNotify.js.map +1 -0
  271. package/dist/lexicons/com/atproto/space/removeWriter.d.ts +3 -0
  272. package/dist/lexicons/com/atproto/space/removeWriter.d.ts.map +1 -0
  273. package/dist/lexicons/com/atproto/space/removeWriter.defs.d.ts +33 -0
  274. package/dist/lexicons/com/atproto/space/removeWriter.defs.d.ts.map +1 -0
  275. package/dist/lexicons/com/atproto/space/removeWriter.defs.js +15 -0
  276. package/dist/lexicons/com/atproto/space/removeWriter.defs.js.map +1 -0
  277. package/dist/lexicons/com/atproto/space/removeWriter.js +6 -0
  278. package/dist/lexicons/com/atproto/space/removeWriter.js.map +1 -0
  279. package/dist/lexicons/com/atproto/space/unregisterNotify.d.ts +3 -0
  280. package/dist/lexicons/com/atproto/space/unregisterNotify.d.ts.map +1 -0
  281. package/dist/lexicons/com/atproto/space/unregisterNotify.defs.d.ts +29 -0
  282. package/dist/lexicons/com/atproto/space/unregisterNotify.defs.d.ts.map +1 -0
  283. package/dist/lexicons/com/atproto/space/unregisterNotify.defs.js +20 -0
  284. package/dist/lexicons/com/atproto/space/unregisterNotify.defs.js.map +1 -0
  285. package/dist/lexicons/com/atproto/space/unregisterNotify.js +6 -0
  286. package/dist/lexicons/com/atproto/space/unregisterNotify.js.map +1 -0
  287. package/dist/lexicons/com/atproto/space/updateSpace.d.ts +3 -0
  288. package/dist/lexicons/com/atproto/space/updateSpace.d.ts.map +1 -0
  289. package/dist/lexicons/com/atproto/space/updateSpace.defs.d.ts +32 -0
  290. package/dist/lexicons/com/atproto/space/updateSpace.defs.d.ts.map +1 -0
  291. package/dist/lexicons/com/atproto/space/updateSpace.defs.js +18 -0
  292. package/dist/lexicons/com/atproto/space/updateSpace.defs.js.map +1 -0
  293. package/dist/lexicons/com/atproto/space/updateSpace.js +6 -0
  294. package/dist/lexicons/com/atproto/space/updateSpace.js.map +1 -0
  295. package/dist/lexicons/com/atproto/space.d.ts +23 -0
  296. package/dist/lexicons/com/atproto/space.d.ts.map +1 -0
  297. package/dist/lexicons/com/atproto/space.js +26 -0
  298. package/dist/lexicons/com/atproto/space.js.map +1 -0
  299. package/dist/lexicons/com/atproto.d.ts +5 -0
  300. package/dist/lexicons/com/atproto.d.ts.map +1 -0
  301. package/dist/lexicons/com/atproto.js +8 -0
  302. package/dist/lexicons/com/atproto.js.map +1 -0
  303. package/dist/lexicons/com.d.ts +2 -0
  304. package/dist/lexicons/com.d.ts.map +1 -0
  305. package/dist/lexicons/com.js +5 -0
  306. package/dist/lexicons/com.js.map +1 -0
  307. package/dist/lexicons/index.d.ts +2 -0
  308. package/dist/lexicons/index.d.ts.map +1 -0
  309. package/dist/lexicons/index.js +5 -0
  310. package/dist/lexicons/index.js.map +1 -0
  311. package/dist/policies/baseline.d.ts +7 -0
  312. package/dist/policies/baseline.d.ts.map +1 -0
  313. package/dist/policies/baseline.js +10 -0
  314. package/dist/policies/baseline.js.map +1 -0
  315. package/dist/policies/index.d.ts +6 -0
  316. package/dist/policies/index.d.ts.map +1 -0
  317. package/dist/policies/index.js +6 -0
  318. package/dist/policies/index.js.map +1 -0
  319. package/dist/policies/managedspace.d.ts +12 -0
  320. package/dist/policies/managedspace.d.ts.map +1 -0
  321. package/dist/policies/managedspace.js +12 -0
  322. package/dist/policies/managedspace.js.map +1 -0
  323. package/dist/policies/memberspace.d.ts +31 -0
  324. package/dist/policies/memberspace.d.ts.map +1 -0
  325. package/dist/policies/memberspace.js +48 -0
  326. package/dist/policies/memberspace.js.map +1 -0
  327. package/dist/policies/personalspace.d.ts +11 -0
  328. package/dist/policies/personalspace.d.ts.map +1 -0
  329. package/dist/policies/personalspace.js +11 -0
  330. package/dist/policies/personalspace.js.map +1 -0
  331. package/dist/policies/space-policy-manager.d.ts +73 -0
  332. package/dist/policies/space-policy-manager.d.ts.map +1 -0
  333. package/dist/policies/space-policy-manager.js +81 -0
  334. package/dist/policies/space-policy-manager.js.map +1 -0
  335. package/dist/space-client.d.ts +254 -0
  336. package/dist/space-client.d.ts.map +1 -0
  337. package/dist/space-client.js +301 -0
  338. package/dist/space-client.js.map +1 -0
  339. package/dist/space-collection.d.ts +11 -0
  340. package/dist/space-collection.d.ts.map +1 -0
  341. package/dist/space-collection.js +2 -0
  342. package/dist/space-collection.js.map +1 -0
  343. package/dist/space-credential-provider.d.ts +68 -0
  344. package/dist/space-credential-provider.d.ts.map +1 -0
  345. package/dist/space-credential-provider.js +68 -0
  346. package/dist/space-credential-provider.js.map +1 -0
  347. package/dist/space-credential.d.ts +35 -0
  348. package/dist/space-credential.d.ts.map +1 -0
  349. package/dist/space-credential.js +64 -0
  350. package/dist/space-credential.js.map +1 -0
  351. package/dist/space-manager.d.ts +102 -0
  352. package/dist/space-manager.d.ts.map +1 -0
  353. package/dist/space-manager.js +121 -0
  354. package/dist/space-manager.js.map +1 -0
  355. package/dist/space-reader.d.ts +400 -0
  356. package/dist/space-reader.d.ts.map +1 -0
  357. package/dist/space-reader.js +573 -0
  358. package/dist/space-reader.js.map +1 -0
  359. package/dist/write-operation-builder.d.ts +22 -0
  360. package/dist/write-operation-builder.d.ts.map +1 -0
  361. package/dist/write-operation-builder.js +37 -0
  362. package/dist/write-operation-builder.js.map +1 -0
  363. package/package.json +64 -3
@@ -0,0 +1,573 @@
1
+ import { formatDidVerificationMethod } from '@atproto/crypto';
2
+ import { extractKemKey, extractPdsUrl } from '@atproto/did';
3
+ import { cidForLex } from '@atproto/lex-cbor';
4
+ import { XrpcAuthenticationError, XrpcResponseError, buildAgent, xrpc, } from '@atproto/lex-client';
5
+ import { checkCid, isCidForBytes, parseCid, } from '@atproto/lex-data';
6
+ import { getMain, } from '@atproto/lex-schema';
7
+ import { COMMIT_MAC_PROFILE, RECORD_MAC_PROFILE, RepoCommit, SpaceMacError, SpaceRepoVerificationError, encapsulate, formatMacRequest, formatRecordPath, verifyCommit, verifyRecord, verifyRepoStar, } from '@atproto/space';
8
+ import { SpaceRef, } from '@atproto/syntax';
9
+ import { createDidResolver } from '@atproto-labs/did-resolver';
10
+ import { RepoGapError } from './errors.js';
11
+ import { repoRemoved, repoWrite, } from './lexicons/com/atproto/space/defs.js';
12
+ import getBlob from './lexicons/com/atproto/space/getBlob.js';
13
+ import getLatestCommit from './lexicons/com/atproto/space/getLatestCommit.js';
14
+ import getRecord from './lexicons/com/atproto/space/getRecord.js';
15
+ import getRepo from './lexicons/com/atproto/space/getRepo.js';
16
+ import listBlobs from './lexicons/com/atproto/space/listBlobs.js';
17
+ import listRecords, {} from './lexicons/com/atproto/space/listRecords.js';
18
+ import listRepoOps from './lexicons/com/atproto/space/listRepoOps.js';
19
+ import listWriters from './lexicons/com/atproto/space/listWriters.js';
20
+ import { SpaceCredentialProviderCache, buildSpaceCredentialProvider, } from './space-credential-provider.js';
21
+ export { SpaceRef };
22
+ /**
23
+ * Reads a space of the type described by `schema`, with a space credential
24
+ * obtained in exchange for delegation tokens (see
25
+ * {@link DelegationTokenProvider}). Use it to sync a space without acting for a
26
+ * specific user, e.g. in a sync service; see `SpaceClient` to act for a user.
27
+ *
28
+ * Requests are sent to the PDS of the account whose repo they target, or to
29
+ * the space host (the authority's PDS) when they target no repo. Records,
30
+ * commits, repos and blobs are verified against the MAC, or CID, their host
31
+ * provided.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const reader = SpaceReader.openSpace(com.example.forum, spaceUri, {
36
+ * delegationTokenProvider: async (space) => requestDelegationToken(space),
37
+ * })
38
+ *
39
+ * for await (const record of reader.allRecords()) {
40
+ * console.log(record.repo, record.collection, record.rkey, record.record)
41
+ * }
42
+ * ```
43
+ */
44
+ export class SpaceReader {
45
+ #resolver;
46
+ #fetch;
47
+ #credentialProvider;
48
+ /**
49
+ * Reads a space, identified by its URI or by its authority and key.
50
+ *
51
+ * @throws {TypeError} if the space is not of the type described by `schema`
52
+ */
53
+ static openSpace(schema, space, options) {
54
+ const ref = typeof space === 'string'
55
+ ? SpaceRef.parse(space)
56
+ : space instanceof SpaceRef
57
+ ? space
58
+ : schema.spaceRefFor(space.authority, space.skey);
59
+ return new SpaceReader(schema, ref, options);
60
+ }
61
+ /**
62
+ * @throws {TypeError} if the space is not of the type described by `schema`
63
+ */
64
+ constructor(
65
+ /** The space type, e.g. to restrict the collections read and written. */
66
+ schema, ref, { fetch = globalThis.fetch, didResolver = createDidResolver({ fetch }), clientAttestationProvider = undefined, delegationTokenProvider = undefined, notifyRegistrationProvider = undefined, credentialProvider = buildSpaceCredentialProvider({
67
+ didResolver,
68
+ fetch,
69
+ clientAttestationProvider,
70
+ delegationTokenProvider,
71
+ notifyRegistrationProvider,
72
+ }), } = {}) {
73
+ this.schema = schema;
74
+ this.ref = ref;
75
+ if (ref.spaceType !== schema.nsid) {
76
+ throw new TypeError(`${ref} is not a ${schema.nsid} space`);
77
+ }
78
+ this.uri = ref.toString();
79
+ this.#resolver = didResolver;
80
+ this.#fetch = fetch;
81
+ this.#credentialProvider =
82
+ SpaceCredentialProviderCache.for(credentialProvider);
83
+ }
84
+ /**
85
+ * Lists the accounts holding a repo in the space (its writer set), as known
86
+ * to the space host.
87
+ */
88
+ async listWriters({ limit, cursor, ...options } = {}) {
89
+ return this.authorityXrpc(listWriters, {
90
+ ...options,
91
+ params: { space: this.uri, limit, cursor },
92
+ });
93
+ }
94
+ /**
95
+ * Iterates over the writer set of the space, at the latest update to each
96
+ * repo, in ascending `spaceRev` order. A repo removed from the writer set is
97
+ * listed as `repoRemoved`, and is not part of the space. A repo updated while
98
+ * iterating may be yielded again, in which case its last entry is current.
99
+ *
100
+ * The highest `spaceRev` yielded can be used as `cursor` to only list the
101
+ * repos updated since. Removals may be forgotten by the space host after 72
102
+ * hours, so with an older cursor, list the whole writer set instead, and drop
103
+ * the repos missing from it.
104
+ */
105
+ async *writers(options = {}) {
106
+ let { cursor } = options;
107
+ do {
108
+ const { body } = await this.listWriters({ ...options, cursor });
109
+ for (const entry of body.repos) {
110
+ // Entries of a kind unknown to this version are skipped.
111
+ if (repoWrite.$isTypeOf(entry) || repoRemoved.$isTypeOf(entry)) {
112
+ yield entry;
113
+ }
114
+ }
115
+ // Guard against a server returning the same cursor
116
+ if (body.cursor === cursor)
117
+ return;
118
+ cursor = body.cursor;
119
+ } while (cursor);
120
+ }
121
+ async listRecords({ repo, collection, limit, cursor, excludeValues, ...options }) {
122
+ return this.repoXrpc(repo, listRecords, {
123
+ ...options,
124
+ params: {
125
+ space: this.uri,
126
+ repo,
127
+ collection,
128
+ limit,
129
+ cursor,
130
+ excludeValues,
131
+ },
132
+ });
133
+ }
134
+ /**
135
+ * Iterates over the records of a repo.
136
+ *
137
+ * @note Listed records are not covered by a MAC; see {@link getRepo} for a
138
+ * verified copy of a repo.
139
+ */
140
+ async *records(options) {
141
+ let { cursor } = options;
142
+ do {
143
+ const { body } = await this.listRecords({ ...options, cursor });
144
+ yield* body.records;
145
+ if (body.cursor === cursor)
146
+ return;
147
+ cursor = body.cursor;
148
+ } while (cursor);
149
+ }
150
+ /**
151
+ * Gets a record, verified against the MAC its host computed for the
152
+ * request.
153
+ *
154
+ * @throws {SpaceRepoVerificationError} if the record fails verification
155
+ */
156
+ async getRecord(collection, rkey, { repo, ...options }) {
157
+ const params = { space: this.uri, repo, collection, rkey };
158
+ const uri = `${this.uri}/${repo}/${collection}/${rkey}`;
159
+ return this.#verified(`Record ${uri} failed verification`, async (kem) => {
160
+ const { response, mac } = await this.#withMac(repo, getRecord, RECORD_MAC_PROFILE, { ...options, params }, kem);
161
+ await verifyRecord(response.body, { ...mac, uri });
162
+ return response;
163
+ });
164
+ }
165
+ /**
166
+ * Gets the current commit of a repo, verified against the MAC its host
167
+ * computed for the request.
168
+ *
169
+ * @throws {SpaceRepoVerificationError} if the commit fails verification
170
+ */
171
+ async getLatestCommit({ repo, ...options }) {
172
+ const params = { space: this.uri, repo };
173
+ return this.#verified(`Repo ${repo} commit failed verification`, async (kem) => {
174
+ const { response, mac } = await this.#withMac(repo, getLatestCommit, COMMIT_MAC_PROFILE, { ...options, params }, kem);
175
+ verifyCommit(response.body.commit, { ...params, ...mac });
176
+ return response;
177
+ });
178
+ }
179
+ /**
180
+ * Gets a repo in full. Its commit is verified against the MAC its host
181
+ * computed for the request, and its records against its commit as they are
182
+ * read: all of them must be read before trusting any.
183
+ *
184
+ * @note The returned repo must be disposed of, or its records read.
185
+ * @throws {SpaceRepoVerificationError} if the repo fails verification
186
+ */
187
+ async getRepo({ repo, ...options }) {
188
+ const params = { space: this.uri, repo };
189
+ return this.#verified(`Repo ${repo} failed verification`, async (kem) => {
190
+ const { response, mac } = await this.#withMac(repo, getRepo, COMMIT_MAC_PROFILE, { ...options, params }, kem);
191
+ // @TODO Stream the archive, once lex-client can stream response bodies
192
+ return verifyRepoStar([response.body], { ...params, ...mac });
193
+ });
194
+ }
195
+ /**
196
+ * Lists a page of a repo's operation log. The repo's current commit, included
197
+ * with every page, is verified against the MAC its host computed for the
198
+ * request.
199
+ *
200
+ * @see {@link syncRepo} to apply the operations to a known state.
201
+ * @throws {SpaceRepoVerificationError} if the commit fails verification
202
+ */
203
+ async listRepoOps({ repo, since, cursor, limit, excludeValues, ...options }) {
204
+ const params = {
205
+ space: this.uri,
206
+ repo,
207
+ since,
208
+ cursor,
209
+ limit,
210
+ excludeValues,
211
+ };
212
+ return this.#verified(`Repo ${repo} commit failed verification`, async (kem) => {
213
+ const { response, mac } = await this.#withMac(repo, listRepoOps, COMMIT_MAC_PROFILE, { ...options, params }, kem);
214
+ verifyCommit(response.body.commit, { space: this.uri, repo, ...mac });
215
+ return response;
216
+ });
217
+ }
218
+ /**
219
+ * Brings a known state of a repo up to date, from its operation log. Every
220
+ * operation is checked against the state (using `lookup` for the CIDs of the
221
+ * records it touches), and the resulting state against the repo's commit.
222
+ *
223
+ * @throws {RepoGapError} if the operation log cannot be applied to `head`
224
+ * @throws {SpaceRepoVerificationError} if the repo fails verification
225
+ */
226
+ async syncRepo({ repo, head, lookup, signal, }) {
227
+ const repoCommit = RepoCommit.fromState(head.state);
228
+ const changes = new Map();
229
+ let commit;
230
+ let cursor;
231
+ let rev = head.rev;
232
+ do {
233
+ const { body } = await this.listRepoOps({
234
+ repo,
235
+ since: head.rev,
236
+ cursor,
237
+ signal,
238
+ });
239
+ for (const op of body.ops) {
240
+ // Operations sharing a revision were applied atomically.
241
+ if (op.rev <= head.rev || op.rev < rev) {
242
+ throw new RepoGapError(`Repo ${repo} operations are out of order`);
243
+ }
244
+ rev = op.rev;
245
+ const path = formatRecordPath(op.collection, op.rkey);
246
+ const change = changes.get(path);
247
+ const current = change
248
+ ? change.cid
249
+ : ((await lookup(op.collection, op.rkey)) ?? null);
250
+ const prev = op.prev ? parseCid(op.prev) : null;
251
+ if (!cidEquals(prev, current)) {
252
+ throw new RepoGapError(`Repo ${repo} diverged at ${path}`);
253
+ }
254
+ const cid = op.cid ? parseCid(op.cid) : null;
255
+ if (op.value && !(cid && (await cidForLex(op.value)).equals(cid))) {
256
+ throw new SpaceRepoVerificationError(`Record ${path} failed verification`);
257
+ }
258
+ repoCommit.applyOp({
259
+ collection: op.collection,
260
+ rkey: op.rkey,
261
+ cid,
262
+ prev,
263
+ });
264
+ changes.set(path, {
265
+ collection: op.collection,
266
+ rkey: op.rkey,
267
+ cid,
268
+ prev: change ? change.prev : prev,
269
+ record: op.value,
270
+ });
271
+ }
272
+ // Every page carries the repo's current commit. The last page's is checked
273
+ // against the state once all the operations are applied.
274
+ commit = body.commit;
275
+ cursor = body.cursor;
276
+ } while (cursor);
277
+ if (!repoCommit.matches(commit)) {
278
+ throw new RepoGapError(`Repo ${repo} diverged from its commit`);
279
+ }
280
+ // A value is only listed with the last operation on its record.
281
+ for (const change of changes.values()) {
282
+ if (change.cid && !change.record) {
283
+ const { collection, rkey } = change;
284
+ const { body } = await this.getRecord(collection, rkey, {
285
+ repo,
286
+ signal,
287
+ });
288
+ if (!parseCid(body.cid).equals(change.cid)) {
289
+ throw new RepoGapError(`Repo ${repo} changed while syncing`);
290
+ }
291
+ change.record = body.value;
292
+ }
293
+ }
294
+ return {
295
+ commit,
296
+ head: { rev: commit.rev, state: repoCommit.setHash.state() },
297
+ // A record created then deleted since `head` did not change.
298
+ changes: [...changes.values()].filter((c) => c.cid || c.prev),
299
+ };
300
+ }
301
+ /**
302
+ * Gets a repo in full, and the state needed to {@link syncRepo} it later.
303
+ *
304
+ * @throws {SpaceRepoVerificationError} if the repo fails verification
305
+ */
306
+ async getRepoSnapshot({ repo, signal, }) {
307
+ const { commit, records } = await this.getRepo({ repo, signal });
308
+ const collected = [];
309
+ for await (const record of records)
310
+ collected.push(record);
311
+ const state = RepoCommit.fromRecords(collected).setHash.state();
312
+ return { commit, head: { rev: commit.rev, state }, records: collected };
313
+ }
314
+ /**
315
+ * Brings a repo up to date: incrementally from its known state (`head` and
316
+ * `lookup`), and in full when there is none (e.g. on the first pull), or
317
+ * when the incremental sync fails. A repo its host does not have is pulled
318
+ * as an empty repo.
319
+ */
320
+ async pullRepo({ repo, head, lookup, signal, }) {
321
+ if (head) {
322
+ try {
323
+ const changes = await this.syncRepo({ repo, head, lookup, signal });
324
+ return { type: 'changes', ...changes };
325
+ }
326
+ catch (err) {
327
+ if (isRepoNotFound(err))
328
+ return { type: 'empty' };
329
+ if (!(err instanceof RepoGapError) &&
330
+ !(err instanceof SpaceRepoVerificationError)) {
331
+ throw err;
332
+ }
333
+ }
334
+ }
335
+ let snapshot;
336
+ try {
337
+ snapshot = await this.getRepoSnapshot({ repo, signal });
338
+ }
339
+ catch (err) {
340
+ if (isRepoNotFound(err))
341
+ return { type: 'empty' };
342
+ throw err;
343
+ }
344
+ if (head && snapshot.commit.rev < head.rev) {
345
+ throw new RepoGapError(`Repo ${repo} is older than its known state`);
346
+ }
347
+ return { type: 'snapshot', ...snapshot };
348
+ }
349
+ async *allRecords({ collections, validateRequest, concurrency = 4, signal, } = {}) {
350
+ const schemas = collections?.map(getMain);
351
+ if (schemas && validateRequest !== false) {
352
+ for (const { $type } of schemas)
353
+ this.assertCollection($type);
354
+ }
355
+ // A repo listed again was updated while listing: its last entry is current.
356
+ const writers = new Map();
357
+ for await (const entry of this.writers({ signal })) {
358
+ writers.set(entry.repo, entry);
359
+ }
360
+ const queue = [...writers.values()]
361
+ .filter((entry) => repoWrite.$isTypeOf(entry))
362
+ .map((entry) => entry.repo);
363
+ while (queue.length) {
364
+ const batch = queue.splice(0, concurrency);
365
+ const snapshots = await Promise.all(batch.map((repo) => this.getRepoSnapshot({ repo, signal }).catch((err) => {
366
+ if (err instanceof XrpcResponseError) {
367
+ switch (err.error) {
368
+ // Errors meaning that a member's repo holds no readable data.
369
+ case 'RepoNotFound':
370
+ case 'RepoTakendown':
371
+ case 'RepoSuspended':
372
+ case 'RepoDeactivated':
373
+ return undefined;
374
+ }
375
+ }
376
+ throw err;
377
+ })));
378
+ for (const [i, snapshot] of snapshots.entries()) {
379
+ for (const record of snapshot?.records ?? []) {
380
+ const item = { ...record, repo: batch[i] };
381
+ if (!schemas) {
382
+ yield this.isCollection(record.collection)
383
+ ? { ...item, valid: true }
384
+ : { ...item, valid: false };
385
+ continue;
386
+ }
387
+ const schema = schemas.find((s) => s.$type === record.collection);
388
+ if (!schema)
389
+ continue;
390
+ const result = schema.safeValidate(record.record);
391
+ yield result.success
392
+ ? { ...item, valid: true, record: result.value }
393
+ : { ...item, valid: false };
394
+ }
395
+ }
396
+ }
397
+ }
398
+ /** Whether `collection` is one of the collections declared by the space type. */
399
+ isCollection(collection) {
400
+ return this.schema.collections.includes(collection);
401
+ }
402
+ /**
403
+ * @throws {TypeError} if `collection` is not one of the collections declared
404
+ * by the space type
405
+ */
406
+ assertCollection(collection) {
407
+ if (!this.isCollection(collection)) {
408
+ throw new TypeError(`${collection} is not a collection of ${this.schema.nsid} spaces`);
409
+ }
410
+ }
411
+ /**
412
+ * Gets a blob, verified against its CID.
413
+ *
414
+ * @throws {SpaceRepoVerificationError} if the blob fails verification
415
+ */
416
+ async getBlob({ repo, cid: cidInput, ...options }) {
417
+ const cid = typeof cidInput === 'string' ? parseCid(cidInput) : cidInput;
418
+ if (!checkCid(cid, { flavor: 'raw' })) {
419
+ throw new TypeError(`${cid} is not a raw CID`);
420
+ }
421
+ // @TODO Stream the blob, once lex-client can stream response bodies
422
+ const response = await this.repoXrpc(repo, getBlob, {
423
+ ...options,
424
+ params: { space: this.uri, repo, cid: cid.toString() },
425
+ });
426
+ if (!(await isCidForBytes(cid, response.body))) {
427
+ throw new SpaceRepoVerificationError(`Blob ${cid} failed verification`);
428
+ }
429
+ return response;
430
+ }
431
+ /** Lists the CIDs of the blobs referenced by a repo's records. */
432
+ async listBlobs({ repo, cursor, limit, ...options }) {
433
+ return this.repoXrpc(repo, listBlobs, {
434
+ ...options,
435
+ params: { space: this.uri, repo, cursor, limit },
436
+ });
437
+ }
438
+ /**
439
+ * Makes a request to the space host (the authority's PDS), with the space
440
+ * credential presented to the space authority.
441
+ */
442
+ async authorityXrpc(ns, options) {
443
+ return this.credentialXrpc(this.ref.spaceDid, ns, options);
444
+ }
445
+ /**
446
+ * Makes a request to the host (PDS) of a repo in the space, with the space
447
+ * credential presented to the repo's account.
448
+ */
449
+ async repoXrpc(repo, ns, options) {
450
+ return this.credentialXrpc(repo, ns, options);
451
+ }
452
+ /**
453
+ * Makes a request with the space credential, presented to `audience` (whose
454
+ * PDS receives the request).
455
+ */
456
+ async credentialXrpc(audience, ns, options) {
457
+ const agent = await this.buildCredentialXrpcAgent(audience, options);
458
+ try {
459
+ return await xrpc(agent, ns, options);
460
+ }
461
+ catch (err) {
462
+ if (!('renew' in options && options.renew) &&
463
+ !options.signal?.aborted &&
464
+ err instanceof XrpcAuthenticationError) {
465
+ // Retry with a new credential
466
+ const agent = await this.buildCredentialXrpcAgent(audience, {
467
+ signal: options.signal,
468
+ renew: true,
469
+ });
470
+ return xrpc(agent, ns, options);
471
+ }
472
+ throw err;
473
+ }
474
+ }
475
+ async buildCredentialXrpcAgent(audience, { signal, renew } = {}) {
476
+ // Did resolution first, to avoid unnecessary credential requests if the
477
+ // audience's PDS cannot be resolved.
478
+ const service = await this.#resolver
479
+ .resolve(audience, { signal, noCache: renew })
480
+ .then(extractPdsUrl);
481
+ signal?.throwIfAborted?.();
482
+ const credential = await this.authorize({ signal, renew });
483
+ signal?.throwIfAborted?.();
484
+ const headers = await credential.headers(audience);
485
+ return buildAgent({ service, headers, fetch: this.#fetch });
486
+ }
487
+ /**
488
+ * Obtains the space credential (or a new one, with `renew`). The credential
489
+ * is otherwise obtained on first use: call this to check, early, that the
490
+ * space grants access.
491
+ *
492
+ * @throws {XrpcResponseError} if the credential cannot be obtained, e.g.
493
+ * `SpaceNotFound` (not granted access), `AppNotAuthorized` or `SpaceDeleted`
494
+ */
495
+ async authorize(options) {
496
+ return this.#credentialProvider.getCredential(this.ref, options);
497
+ }
498
+ /**
499
+ * Makes a request to a member's PDS asking for a MAC (with `Accept-Signature`),
500
+ * using a new key share (derived from the member's `#atproto_kem` key) for
501
+ * every attempt, retries included. Returns what the response's MAC is
502
+ * verified with.
503
+ */
504
+ async #withMac(repo, ns, profile, options, refreshKemKey) {
505
+ const kemKey = await this.#resolveKemKey(repo, options.signal, refreshKemKey);
506
+ const { headers: headersInit } = options;
507
+ let encapsulation;
508
+ const response = await this.repoXrpc(repo, ns, {
509
+ ...options,
510
+ // The encapsulated key can only be used once, even on retries, so we
511
+ // generate a new one for each request.
512
+ headers: async () => {
513
+ options.signal?.throwIfAborted?.();
514
+ const headers = new Headers(typeof headersInit === 'function' ? await headersInit() : headersInit);
515
+ options.signal?.throwIfAborted?.();
516
+ encapsulation = await encapsulate(kemKey);
517
+ options.signal?.throwIfAborted?.();
518
+ headers.set('accept-signature', formatMacRequest(profile, encapsulation.keyShare));
519
+ return headers;
520
+ },
521
+ });
522
+ // A missing MAC fails verification, like an invalid one.
523
+ return { response, mac: { ...encapsulation, headers: response.headers } };
524
+ }
525
+ /**
526
+ * Resolves the `#atproto_kem` key of a repo's account. A DID document without
527
+ * one is resolved again, as the key may have been added since it was cached.
528
+ */
529
+ async #resolveKemKey(repo, signal, noCache) {
530
+ const didDocument = await this.#resolver.resolve(repo, { signal, noCache });
531
+ try {
532
+ return formatDidVerificationMethod(extractKemKey(didDocument));
533
+ }
534
+ catch (err) {
535
+ if (noCache)
536
+ throw err;
537
+ return this.#resolveKemKey(repo, signal, true);
538
+ }
539
+ }
540
+ /**
541
+ * Retries a verification once, with the author's KEM key re-resolved, as it
542
+ * may have been rotated since it was cached.
543
+ *
544
+ * @throws {SpaceRepoVerificationError} if both attempts fail verification
545
+ */
546
+ async #verified(message, attempt) {
547
+ try {
548
+ return await attempt(false);
549
+ }
550
+ catch (err) {
551
+ if (!isVerificationError(err))
552
+ throw err;
553
+ }
554
+ try {
555
+ return await attempt(true);
556
+ }
557
+ catch (err) {
558
+ if (!isVerificationError(err))
559
+ throw err;
560
+ throw new SpaceRepoVerificationError(message, { cause: err });
561
+ }
562
+ }
563
+ }
564
+ function isRepoNotFound(err) {
565
+ return err instanceof XrpcResponseError && err.error === 'RepoNotFound';
566
+ }
567
+ function isVerificationError(err) {
568
+ return (err instanceof SpaceMacError || err instanceof SpaceRepoVerificationError);
569
+ }
570
+ function cidEquals(a, b) {
571
+ return a === null || b === null ? a === b : a.equals(b);
572
+ }
573
+ //# sourceMappingURL=space-reader.js.map