@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,11 @@
1
+ import type { Main, Restricted } from '@atproto/lex-client';
2
+ import type { RecordSchema, Space } from '@atproto/lex-schema';
3
+ /** The collections declared by a space type. */
4
+ export type SpaceCollection<S extends Space> = S['collections'][number];
5
+ /**
6
+ * A record schema, restricted to the collections declared by `S`. The
7
+ * `SpaceReader` and `SpaceClient` methods taking one accept any record schema
8
+ * with `validateRequest: false`.
9
+ */
10
+ export type SpaceCollectionSchema<S extends Space, T extends RecordSchema> = T['$type'] extends SpaceCollection<S> ? Main<T> : Restricted<'This record type is not a collection of the space type'>;
11
+ //# sourceMappingURL=space-collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-collection.d.ts","sourceRoot":"","sources":["../src/space-collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE9D,gDAAgD;AAChD,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvE;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS,YAAY,IACvE,CAAC,CAAC,OAAO,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,GACjC,IAAI,CAAC,CAAC,CAAC,GACP,UAAU,CAAC,wDAAwD,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=space-collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-collection.js","sourceRoot":"","sources":["../src/space-collection.ts"],"names":[],"mappings":"","sourcesContent":["import type { Main, Restricted } from '@atproto/lex-client'\nimport type { RecordSchema, Space } from '@atproto/lex-schema'\n\n/** The collections declared by a space type. */\nexport type SpaceCollection<S extends Space> = S['collections'][number]\n\n/**\n * A record schema, restricted to the collections declared by `S`. The\n * `SpaceReader` and `SpaceClient` methods taking one accept any record schema\n * with `validateRequest: false`.\n */\nexport type SpaceCollectionSchema<S extends Space, T extends RecordSchema> =\n T['$type'] extends SpaceCollection<S>\n ? Main<T>\n : Restricted<'This record type is not a collection of the space type'>\n"]}
@@ -0,0 +1,68 @@
1
+ import { SpaceRef, type SpaceRefString } from '@atproto/syntax';
2
+ import { CachedGetter, type Getter } from '@atproto-labs/simple-store';
3
+ import type { AtprotoDidResolver } from './atproto-did-resolver.js';
4
+ import type { ClientAttestationProvider } from './client-attestation-provider.js';
5
+ import type { DelegationTokenProvider } from './delegation-token-provider.js';
6
+ import { type Notify } from './lexicons/com/atproto/space/authorizeSpaceSync.js';
7
+ import { SpaceCredential } from './space-credential.js';
8
+ /**
9
+ * Where, and with what token, the space host notifies a syncer of updates to a
10
+ * space (with `com.atproto.space.notifySpaceUpdate`).
11
+ */
12
+ export type NotifyRegistration = Omit<Notify, '$type'>;
13
+ /**
14
+ * Provides the registration for notifications of updates to a space, renewed
15
+ * with every credential obtained. The `endpoint` must implement
16
+ * `com.atproto.space.confirmRegistration`, which the space host calls before
17
+ * registering it, and `com.atproto.space.notifySpaceUpdate`. The `token`
18
+ * should be unique to the space, and stay the same across credentials.
19
+ * Resolves `undefined` not to register.
20
+ */
21
+ export type NotifyRegistrationProvider = (space: SpaceRef, options: {
22
+ signal?: AbortSignal;
23
+ }) => Promise<NotifyRegistration | undefined>;
24
+ export type SpaceCredentialProviderOptions = {
25
+ signal?: AbortSignal;
26
+ renew?: boolean;
27
+ };
28
+ /**
29
+ * Obtains the space credentials of a {@link SpaceReader}, e.g. to share them
30
+ * between readers of a space.
31
+ */
32
+ export type SpaceCredentialProvider = (space: SpaceRef, options?: SpaceCredentialProviderOptions) => Promise<SpaceCredential>;
33
+ export type BuildSpaceCredentialProviderOptions = {
34
+ /**
35
+ * Provides the delegation tokens exchanged for space credentials. Only
36
+ * spaces with public read access can be read without.
37
+ *
38
+ * @default noDelegationToken
39
+ */
40
+ delegationTokenProvider?: DelegationTokenProvider;
41
+ /** For spaces that only grant access to specific apps. */
42
+ clientAttestationProvider?: ClientAttestationProvider;
43
+ /**
44
+ * Registers for notifications of updates to the space, with each credential
45
+ * obtained. The registration stays active while the latest credential is
46
+ * valid. Obtaining a credential fails with `RegistrationNotConfirmed` if the
47
+ * endpoint does not confirm the registration.
48
+ */
49
+ notifyRegistrationProvider?: NotifyRegistrationProvider;
50
+ /**
51
+ * Resolves the space authority and the space's members to their PDS and
52
+ * `#atproto_kem` key.
53
+ */
54
+ didResolver?: AtprotoDidResolver;
55
+ /** Used for all requests. */
56
+ fetch?: typeof globalThis.fetch;
57
+ };
58
+ export declare function buildSpaceCredentialProvider({ fetch, didResolver, clientAttestationProvider, delegationTokenProvider, notifyRegistrationProvider, }: BuildSpaceCredentialProviderOptions): SpaceCredentialProvider;
59
+ /**
60
+ * Caches the space credentials obtained by `mint` until they need renewal.
61
+ * Concurrent requests for a space share a single mint.
62
+ */
63
+ export declare class SpaceCredentialProviderCache extends CachedGetter<SpaceRefString, SpaceCredential> {
64
+ static for(provider: SpaceCredentialProvider): SpaceCredentialProviderCache;
65
+ protected constructor(getter: Getter<SpaceRefString, SpaceCredential>);
66
+ getCredential: SpaceCredentialProvider;
67
+ }
68
+ //# sourceMappingURL=space-credential-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-credential-provider.d.ts","sourceRoot":"","sources":["../src/space-credential-provider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAE/D,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AACjF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,EACL,KAAK,MAAM,EAEZ,MAAM,oDAAoD,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEtD;;;;;;;GAOG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACvC,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,KAC9B,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAA;AAE5C,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,CACpC,KAAK,EAAE,QAAQ,EACf,OAAO,CAAC,EAAE,8BAA8B,KACrC,OAAO,CAAC,eAAe,CAAC,CAAA;AAE7B,MAAM,MAAM,mCAAmC,GAAG;IAChD;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAA;IAEjD,0DAA0D;IAC1D,yBAAyB,CAAC,EAAE,yBAAyB,CAAA;IAErD;;;;;OAKG;IACH,0BAA0B,CAAC,EAAE,0BAA0B,CAAA;IAEvD;;;OAGG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAEhC,6BAA6B;IAC7B,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAChC,CAAA;AAED,wBAAgB,4BAA4B,CAAC,EAC3C,KAAwB,EACxB,WAA0C,EAC1C,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,GAC3B,EAAE,mCAAmC,GAAG,uBAAuB,CAkC/D;AAED;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,YAAY,CAE5D,cAAc,EACd,eAAe,CAChB;IACC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,uBAAuB,GAAG,4BAA4B,CAO1E;IAED,SAAS,aAAa,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,eAAe,CAAC,EAgBpE;IAED,aAAa,EAAE,uBAAuB,CAKrC;CACF"}
@@ -0,0 +1,68 @@
1
+ import { P256Keypair } from '@atproto/crypto';
2
+ import { extractPdsUrl } from '@atproto/did';
3
+ import { XrpcResponseError, buildAgent, xrpc } from '@atproto/lex-client';
4
+ import { SPACE_CREDENTIAL_MAX_AGE_SEC, spaceHostAud } from '@atproto/space';
5
+ import { SpaceRef } from '@atproto/syntax';
6
+ import { createDidResolver } from '@atproto-labs/did-resolver';
7
+ import { CachedGetter } from '@atproto-labs/simple-store';
8
+ import { SimpleStoreMemory } from '@atproto-labs/simple-store-memory';
9
+ import { main as authorizeSpaceSync, } from './lexicons/com/atproto/space/authorizeSpaceSync.js';
10
+ import { SpaceCredential } from './space-credential.js';
11
+ export function buildSpaceCredentialProvider({ fetch = globalThis.fetch, didResolver = createDidResolver({ fetch }), clientAttestationProvider, delegationTokenProvider, notifyRegistrationProvider, }) {
12
+ return async (space, { signal, renew } = {}) => {
13
+ const [service, delegationToken, clientAttestation, notify] = await Promise.all([
14
+ didResolver
15
+ .resolve(space.spaceDid, { signal, noCache: renew })
16
+ .then(extractPdsUrl),
17
+ delegationTokenProvider?.(space, { signal }),
18
+ clientAttestationProvider?.(spaceHostAud(space.spaceDid)),
19
+ notifyRegistrationProvider?.(space, { signal }),
20
+ ]);
21
+ signal?.throwIfAborted?.();
22
+ const key = await P256Keypair.create();
23
+ signal?.throwIfAborted?.();
24
+ const agent = buildAgent({ fetch, service });
25
+ const res = await xrpc(agent, authorizeSpaceSync, {
26
+ signal,
27
+ body: {
28
+ space: space.toString(),
29
+ credentialKey: key.did(),
30
+ delegationToken,
31
+ clientAttestation,
32
+ notify,
33
+ },
34
+ });
35
+ return SpaceCredential.parse(res.body.credential, key, {
36
+ spaceRev: res.body.spaceRev,
37
+ });
38
+ };
39
+ }
40
+ /**
41
+ * Caches the space credentials obtained by `mint` until they need renewal.
42
+ * Concurrent requests for a space share a single mint.
43
+ */
44
+ export class SpaceCredentialProviderCache extends CachedGetter {
45
+ static for(provider) {
46
+ return new SpaceCredentialProviderCache(async (space, { signal, noCache }) => {
47
+ // A renewal re-resolves the authority, e.g. in case it moved to another PDS.
48
+ return provider(SpaceRef.parse(space), { signal, renew: noCache });
49
+ });
50
+ }
51
+ constructor(getter) {
52
+ super(getter,
53
+ // @NOTE Credentials are only kept in memory: they hold a non-exportable
54
+ // private key, and persisting them would expose read access to the space.
55
+ new SimpleStoreMemory({
56
+ ttl: SPACE_CREDENTIAL_MAX_AGE_SEC * 1e3,
57
+ ttlAutopurge: true,
58
+ }), {
59
+ isStale: (_space, credential) => credential.needsRenewal,
60
+ // Syncers are expected to drop a deleted space, credential included.
61
+ deleteOnError: (err) => err instanceof XrpcResponseError && err.error === 'SpaceDeleted',
62
+ });
63
+ this.getCredential = async (space, { signal, renew } = {}) => {
64
+ return this.get(space.toString(), { signal, noCache: renew });
65
+ };
66
+ }
67
+ }
68
+ //# sourceMappingURL=space-credential-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-credential-provider.js","sourceRoot":"","sources":["../src/space-credential-provider.ts"],"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G;YACvC,YAAY,EAAE,IAAI;SACnB,CAAC,EACF;YACE,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY;YACxD,qEAAqE;YACrE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CACrB,GAAG,YAAY,iBAAiB,IAAI,GAAG,CAAC,KAAK,KAAK,cAAc;SACnE,CACF,CAAA;QAGH,kBAAa,GAA4B,KAAK,EAC5C,KAAK,EACL,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EACtB,EAAE;YACF,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;QAC/D,CAAC,CAAA;IAPD,CAAC;CAQF","sourcesContent":["import { P256Keypair } from '@atproto/crypto'\nimport { extractPdsUrl } from '@atproto/did'\nimport { XrpcResponseError, buildAgent, xrpc } from '@atproto/lex-client'\nimport { SPACE_CREDENTIAL_MAX_AGE_SEC, spaceHostAud } from '@atproto/space'\nimport { SpaceRef, type SpaceRefString } from '@atproto/syntax'\nimport { createDidResolver } from '@atproto-labs/did-resolver'\nimport { CachedGetter, type Getter } from '@atproto-labs/simple-store'\nimport { SimpleStoreMemory } from '@atproto-labs/simple-store-memory'\nimport type { AtprotoDidResolver } from './atproto-did-resolver.js'\nimport type { ClientAttestationProvider } from './client-attestation-provider.js'\nimport type { DelegationTokenProvider } from './delegation-token-provider.js'\nimport {\n type Notify,\n main as authorizeSpaceSync,\n} from './lexicons/com/atproto/space/authorizeSpaceSync.js'\nimport { SpaceCredential } from './space-credential.js'\n\n/**\n * Where, and with what token, the space host notifies a syncer of updates to a\n * space (with `com.atproto.space.notifySpaceUpdate`).\n */\nexport type NotifyRegistration = Omit<Notify, '$type'>\n\n/**\n * Provides the registration for notifications of updates to a space, renewed\n * with every credential obtained. The `endpoint` must implement\n * `com.atproto.space.confirmRegistration`, which the space host calls before\n * registering it, and `com.atproto.space.notifySpaceUpdate`. The `token`\n * should be unique to the space, and stay the same across credentials.\n * Resolves `undefined` not to register.\n */\nexport type NotifyRegistrationProvider = (\n space: SpaceRef,\n options: { signal?: AbortSignal },\n) => Promise<NotifyRegistration | undefined>\n\nexport type SpaceCredentialProviderOptions = {\n signal?: AbortSignal\n renew?: boolean\n}\n\n/**\n * Obtains the space credentials of a {@link SpaceReader}, e.g. to share them\n * between readers of a space.\n */\nexport type SpaceCredentialProvider = (\n space: SpaceRef,\n options?: SpaceCredentialProviderOptions,\n) => Promise<SpaceCredential>\n\nexport type BuildSpaceCredentialProviderOptions = {\n /**\n * Provides the delegation tokens exchanged for space credentials. Only\n * spaces with public read access can be read without.\n *\n * @default noDelegationToken\n */\n delegationTokenProvider?: DelegationTokenProvider\n\n /** For spaces that only grant access to specific apps. */\n clientAttestationProvider?: ClientAttestationProvider\n\n /**\n * Registers for notifications of updates to the space, with each credential\n * obtained. The registration stays active while the latest credential is\n * valid. Obtaining a credential fails with `RegistrationNotConfirmed` if the\n * endpoint does not confirm the registration.\n */\n notifyRegistrationProvider?: NotifyRegistrationProvider\n\n /**\n * Resolves the space authority and the space's members to their PDS and\n * `#atproto_kem` key.\n */\n didResolver?: AtprotoDidResolver\n\n /** Used for all requests. */\n fetch?: typeof globalThis.fetch\n}\n\nexport function buildSpaceCredentialProvider({\n fetch = globalThis.fetch,\n didResolver = createDidResolver({ fetch }),\n clientAttestationProvider,\n delegationTokenProvider,\n notifyRegistrationProvider,\n}: BuildSpaceCredentialProviderOptions): SpaceCredentialProvider {\n return async (space, { signal, renew } = {}) => {\n const [service, delegationToken, clientAttestation, notify] =\n await Promise.all([\n didResolver\n .resolve(space.spaceDid, { signal, noCache: renew })\n .then(extractPdsUrl),\n delegationTokenProvider?.(space, { signal }),\n clientAttestationProvider?.(spaceHostAud(space.spaceDid)),\n notifyRegistrationProvider?.(space, { signal }),\n ])\n\n signal?.throwIfAborted?.()\n\n const key = await P256Keypair.create()\n\n signal?.throwIfAborted?.()\n\n const agent = buildAgent({ fetch, service })\n const res = await xrpc(agent, authorizeSpaceSync, {\n signal,\n body: {\n space: space.toString(),\n credentialKey: key.did(),\n delegationToken,\n clientAttestation,\n notify,\n },\n })\n\n return SpaceCredential.parse(res.body.credential, key, {\n spaceRev: res.body.spaceRev,\n })\n }\n}\n\n/**\n * Caches the space credentials obtained by `mint` until they need renewal.\n * Concurrent requests for a space share a single mint.\n */\nexport class SpaceCredentialProviderCache extends CachedGetter<\n // @NOTE We need to use string keys\n SpaceRefString,\n SpaceCredential\n> {\n static for(provider: SpaceCredentialProvider): SpaceCredentialProviderCache {\n return new SpaceCredentialProviderCache(\n async (space, { signal, noCache }) => {\n // A renewal re-resolves the authority, e.g. in case it moved to another PDS.\n return provider(SpaceRef.parse(space), { signal, renew: noCache })\n },\n )\n }\n\n protected constructor(getter: Getter<SpaceRefString, SpaceCredential>) {\n super(\n getter,\n // @NOTE Credentials are only kept in memory: they hold a non-exportable\n // private key, and persisting them would expose read access to the space.\n new SimpleStoreMemory({\n ttl: SPACE_CREDENTIAL_MAX_AGE_SEC * 1e3,\n ttlAutopurge: true,\n }),\n {\n isStale: (_space, credential) => credential.needsRenewal,\n // Syncers are expected to drop a deleted space, credential included.\n deleteOnError: (err) =>\n err instanceof XrpcResponseError && err.error === 'SpaceDeleted',\n },\n )\n }\n\n getCredential: SpaceCredentialProvider = async (\n space,\n { signal, renew } = {},\n ) => {\n return this.get(space.toString(), { signal, noCache: renew })\n }\n}\n"]}
@@ -0,0 +1,35 @@
1
+ import type { P256Keypair } from '@atproto/crypto';
2
+ import type { DidString } from '@atproto/syntax';
3
+ /**
4
+ * A space credential, together with the key it is bound to (its `cnf.kid`).
5
+ */
6
+ export declare class SpaceCredential {
7
+ #private;
8
+ readonly token: string;
9
+ readonly key: P256Keypair;
10
+ /** Unix time (seconds) after which the credential should be renewed. */
11
+ readonly renewAt: number;
12
+ /**
13
+ * The space's revision when the credential was issued, or `undefined` if
14
+ * the space had no update yet. A syncer that last saw an earlier revision
15
+ * has missed updates, and can catch up with `listWriters`.
16
+ */
17
+ readonly spaceRev?: string | undefined;
18
+ private constructor();
19
+ /**
20
+ * @throws {SpaceTokenError} if `token` is not a space credential bound to `key`
21
+ */
22
+ static parse(token: string, key: P256Keypair, { spaceRev }?: {
23
+ spaceRev?: string;
24
+ }): SpaceCredential;
25
+ get needsRenewal(): boolean;
26
+ /**
27
+ * The headers presenting this credential to `audience`: the repo owner's DID
28
+ * for repo methods, the space authority's DID for space host methods.
29
+ *
30
+ * @note The signature covers only the credential and the audience, so the
31
+ * headers are computed once per audience and reused.
32
+ */
33
+ headers(audience: DidString): Promise<Record<string, string>>;
34
+ }
35
+ //# sourceMappingURL=space-credential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-credential.d.ts","sourceRoot":"","sources":["../src/space-credential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAKhD;;GAEG;AACH,qBAAa,eAAe;;IAIxB,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,GAAG,EAAE,WAAW;IACzB,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM;IAV5B,OAAO,eAWH;IAEJ;;OAEG;IACH,MAAM,CAAC,KAAK,CACV,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,WAAW,EAChB,EAAE,QAAQ,EAAE,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GACvC,eAAe,CAUjB;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED;;;;;;OAMG;IACG,OAAO,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkBlE;CACF"}
@@ -0,0 +1,64 @@
1
+ import { SpaceTokenError, createSpaceSigHeaders, parseSpaceToken, } from '@atproto/space';
2
+ // Renew this long before expiry, capped at half the credential's lifetime.
3
+ const RENEWAL_MARGIN_SEC = 60;
4
+ /**
5
+ * A space credential, together with the key it is bound to (its `cnf.kid`).
6
+ */
7
+ export class SpaceCredential {
8
+ #headers = new Map();
9
+ constructor(token, key,
10
+ /** Unix time (seconds) after which the credential should be renewed. */
11
+ renewAt,
12
+ /**
13
+ * The space's revision when the credential was issued, or `undefined` if
14
+ * the space had no update yet. A syncer that last saw an earlier revision
15
+ * has missed updates, and can catch up with `listWriters`.
16
+ */
17
+ spaceRev) {
18
+ this.token = token;
19
+ this.key = key;
20
+ this.renewAt = renewAt;
21
+ this.spaceRev = spaceRev;
22
+ }
23
+ /**
24
+ * @throws {SpaceTokenError} if `token` is not a space credential bound to `key`
25
+ */
26
+ static parse(token, key, { spaceRev } = {}) {
27
+ const { payload } = parseSpaceToken('credential', token);
28
+ if (payload.cnf?.kid !== key.did()) {
29
+ throw new SpaceTokenError('space credential is not bound to the requested key', 'BadJwtCnf');
30
+ }
31
+ const margin = Math.min(RENEWAL_MARGIN_SEC, (payload.exp - payload.iat) / 2);
32
+ return new SpaceCredential(token, key, payload.exp - margin, spaceRev);
33
+ }
34
+ get needsRenewal() {
35
+ return Date.now() / 1e3 >= this.renewAt;
36
+ }
37
+ /**
38
+ * The headers presenting this credential to `audience`: the repo owner's DID
39
+ * for repo methods, the space authority's DID for space host methods.
40
+ *
41
+ * @note The signature covers only the credential and the audience, so the
42
+ * headers are computed once per audience and reused.
43
+ */
44
+ async headers(audience) {
45
+ let headersPromise = this.#headers.get(audience);
46
+ if (!headersPromise) {
47
+ const promise = createSpaceSigHeaders({
48
+ authorization: `Atproto-Space-Credential ${this.token}`,
49
+ audience,
50
+ keypair: this.key,
51
+ }).then(({ headers }) => headers);
52
+ this.#headers.set(audience, promise);
53
+ // Don't keep a failure, so that the next request tries again.
54
+ promise.catch(() => {
55
+ if (this.#headers.get(audience) === promise) {
56
+ this.#headers.delete(audience);
57
+ }
58
+ });
59
+ headersPromise = promise;
60
+ }
61
+ return headersPromise;
62
+ }
63
+ }
64
+ //# sourceMappingURL=space-credential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-credential.js","sourceRoot":"","sources":["../src/space-credential.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,eAAe,GAChB,MAAM,gBAAgB,CAAA;AAGvB,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAE7B;;GAEG;AACH,MAAM,OAAO,eAAe;IACjB,QAAQ,GAAG,IAAI,GAAG,EAA8C,CAAA;IAEzE,YACW,KAAa,EACb,GAAgB;IACzB,wEAAwE;IAC/D,OAAe;IACxB;;;;OAIG;IACM,QAAiB;qBATjB,KAAK;mBACL,GAAG;uBAEH,OAAO;wBAMP,QAAQ;IAChB,CAAC;IAEJ;;OAEG;IACH,MAAM,CAAC,KAAK,CACV,KAAa,EACb,GAAgB,EAChB,EAAE,QAAQ,EAAE,GAA0B,EAAE;QAExC,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;QACxD,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC;YACnC,MAAM,IAAI,eAAe,CACvB,oDAAoD,EACpD,WAAW,CACZ,CAAA;QACH,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QAC5E,OAAO,IAAI,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAA;IACxE,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,IAAI,CAAC,OAAO,CAAA;IACzC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,QAAmB;QAC/B,IAAI,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAChD,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,OAAO,GAAG,qBAAqB,CAAC;gBACpC,aAAa,EAAE,4BAA4B,IAAI,CAAC,KAAK,EAAE;gBACvD,QAAQ;gBACR,OAAO,EAAE,IAAI,CAAC,GAAG;aAClB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,CAAA;YACjC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;YACpC,8DAA8D;YAC9D,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE;gBACjB,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,OAAO,EAAE,CAAC;oBAC5C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;gBAChC,CAAC;YACH,CAAC,CAAC,CAAA;YACF,cAAc,GAAG,OAAO,CAAA;QAC1B,CAAC;QACD,OAAO,cAAc,CAAA;IACvB,CAAC;CACF","sourcesContent":["import type { P256Keypair } from '@atproto/crypto'\nimport {\n SpaceTokenError,\n createSpaceSigHeaders,\n parseSpaceToken,\n} from '@atproto/space'\nimport type { DidString } from '@atproto/syntax'\n\n// Renew this long before expiry, capped at half the credential's lifetime.\nconst RENEWAL_MARGIN_SEC = 60\n\n/**\n * A space credential, together with the key it is bound to (its `cnf.kid`).\n */\nexport class SpaceCredential {\n readonly #headers = new Map<DidString, Promise<Record<string, string>>>()\n\n private constructor(\n readonly token: string,\n readonly key: P256Keypair,\n /** Unix time (seconds) after which the credential should be renewed. */\n readonly renewAt: number,\n /**\n * The space's revision when the credential was issued, or `undefined` if\n * the space had no update yet. A syncer that last saw an earlier revision\n * has missed updates, and can catch up with `listWriters`.\n */\n readonly spaceRev?: string,\n ) {}\n\n /**\n * @throws {SpaceTokenError} if `token` is not a space credential bound to `key`\n */\n static parse(\n token: string,\n key: P256Keypair,\n { spaceRev }: { spaceRev?: string } = {},\n ): SpaceCredential {\n const { payload } = parseSpaceToken('credential', token)\n if (payload.cnf?.kid !== key.did()) {\n throw new SpaceTokenError(\n 'space credential is not bound to the requested key',\n 'BadJwtCnf',\n )\n }\n const margin = Math.min(RENEWAL_MARGIN_SEC, (payload.exp - payload.iat) / 2)\n return new SpaceCredential(token, key, payload.exp - margin, spaceRev)\n }\n\n get needsRenewal(): boolean {\n return Date.now() / 1e3 >= this.renewAt\n }\n\n /**\n * The headers presenting this credential to `audience`: the repo owner's DID\n * for repo methods, the space authority's DID for space host methods.\n *\n * @note The signature covers only the credential and the audience, so the\n * headers are computed once per audience and reused.\n */\n async headers(audience: DidString): Promise<Record<string, string>> {\n let headersPromise = this.#headers.get(audience)\n if (!headersPromise) {\n const promise = createSpaceSigHeaders({\n authorization: `Atproto-Space-Credential ${this.token}`,\n audience,\n keypair: this.key,\n }).then(({ headers }) => headers)\n this.#headers.set(audience, promise)\n // Don't keep a failure, so that the next request tries again.\n promise.catch(() => {\n if (this.#headers.get(audience) === promise) {\n this.#headers.delete(audience)\n }\n })\n headersPromise = promise\n }\n return headersPromise\n }\n}\n"]}
@@ -0,0 +1,102 @@
1
+ import { type AccountAgent, type Agent, type DidString, type XrpcOptions, type XrpcResponseBody } from '@atproto/lex-client';
2
+ import { SpaceRef, type SpaceRefString } from '@atproto/syntax';
3
+ import getSpace from './lexicons/com/atproto/space/getSpace.js';
4
+ import { type BaselineSpacePolicyManager } from './policies/baseline.js';
5
+ import type { SpacePolicy, SpacePolicyManager } from './policies/space-policy-manager.js';
6
+ export type { BaselineSpacePolicyManager, SpacePolicy };
7
+ export declare namespace SpaceManager {
8
+ type PolicyManagerClass<TInstance = unknown> = SpacePolicyManager.Class<TInstance>;
9
+ type CallOptions = Omit<XrpcOptions, 'params' | 'body' | 'encoding' | 'service' | 'labelers'>;
10
+ type ManagePolicyOptions<P extends readonly PolicyManagerClass[] | undefined> = {
11
+ /**
12
+ * The managers of the policies to accept, in place of the baseline ones: e.g.
13
+ * to only accept a memberspace, or to support another policy.
14
+ *
15
+ * @default baselineSpacePolicies
16
+ */
17
+ policies?: P;
18
+ signal?: AbortSignal;
19
+ };
20
+ /**
21
+ * The manager of a space governed by one of the policies in `P`, or by any
22
+ * baseline policy when `P` is `undefined`.
23
+ */
24
+ type PolicyManagerOf<P extends readonly PolicyManagerClass[] | undefined> = undefined extends P ? BaselineSpacePolicyManager : InstanceType<NonNullable<P>[number]>;
25
+ }
26
+ /**
27
+ * Manages a space as its authority, whatever its policy: its lifecycle, and
28
+ * the API of its policy (see {@link managePolicy}).
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const manager = await SpaceManager.open(client.agent, spaceUri)
33
+ * if (manager instanceof MemberspacePolicyManager) {
34
+ * await manager.putMembers([{ did, read: true, write: true }])
35
+ * }
36
+ *
37
+ * const space = new SpaceManager(client.agent, spaceUri)
38
+ * await space.updateSpace(managedspace.policy.$build({ managingApp }))
39
+ * await space.deleteSpace()
40
+ * ```
41
+ */
42
+ export declare class SpaceManager {
43
+ /** The agent of the space authority. */
44
+ readonly agent: AccountAgent;
45
+ readonly ref: SpaceRef;
46
+ readonly uri: SpaceRefString;
47
+ /**
48
+ * Gets the manager of the policy governing a space of the user of `agent`
49
+ * (see {@link managePolicy}).
50
+ *
51
+ * @throws {TypeError} if `agent` does not act for the space authority
52
+ * @throws {UnsupportedSpacePolicyError} if the space is not governed by one
53
+ * of `policies`
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const members = await SpaceManager.open(client.agent, spaceUri, {
58
+ * policies: [MemberspacePolicyManager],
59
+ * })
60
+ * await members.putMembers([{ did, read: true, write: true }])
61
+ * ```
62
+ */
63
+ static open<const P extends readonly SpaceManager.PolicyManagerClass[] | undefined = undefined>(agent: Agent, space: SpaceRefString | SpaceRef, options?: SpaceManager.ManagePolicyOptions<P>): Promise<SpaceManager.PolicyManagerOf<P>>;
64
+ /**
65
+ * @throws {TypeError} if `agent` does not act for the space authority
66
+ */
67
+ constructor(
68
+ /** The agent of the space authority. */
69
+ agent: AccountAgent, ref: SpaceRefString | SpaceRef);
70
+ /** Gets the space, including the policy governing it. */
71
+ getSpace(options?: SpaceManager.CallOptions): Promise<XrpcResponseBody<typeof getSpace>>;
72
+ /**
73
+ * Replaces the policy of the space wholesale. A policy of another `$type`
74
+ * migrates the space, discarding the state of the previous policy (e.g. a
75
+ * member list).
76
+ */
77
+ updateSpace(policy: SpacePolicy, options?: SpaceManager.CallOptions): Promise<void>;
78
+ /**
79
+ * Deletes the space, and the authority's repo in it. Other members' repos
80
+ * are left in place.
81
+ */
82
+ deleteSpace(options?: SpaceManager.CallOptions): Promise<void>;
83
+ /** Removes an account's repo from the writer set of the space. */
84
+ removeWriter(repo: DidString, options?: SpaceManager.CallOptions): Promise<void>;
85
+ /**
86
+ * Gets the manager of the policy governing the space, from the first of
87
+ * `policies` whose schema matches it.
88
+ *
89
+ * @throws {UnsupportedSpacePolicyError} if the space is not governed by one
90
+ * of `policies`
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const manager = await space.managePolicy({
95
+ * policies: [MemberspacePolicyManager],
96
+ * })
97
+ * await manager.putMembers([{ did, read: true, write: true }])
98
+ * ```
99
+ */
100
+ managePolicy<const P extends readonly SpaceManager.PolicyManagerClass[] | undefined = undefined>({ policies, signal, }?: SpaceManager.ManagePolicyOptions<P>): Promise<SpaceManager.PolicyManagerOf<P>>;
101
+ }
102
+ //# sourceMappingURL=space-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-manager.d.ts","sourceRoot":"","sources":["../src/space-manager.ts"],"names":[],"mapp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@atproto/lex-client';
2
+ import { SpaceRef } from '@atproto/syntax';
3
+ import { UnsupportedSpacePolicyError } from './errors.js';
4
+ import deleteSpace from './lexicons/com/atproto/space/deleteSpace.js';
5
+ import getSpace from './lexicons/com/atproto/space/getSpace.js';
6
+ import removeWriter from './lexicons/com/atproto/space/removeWriter.js';
7
+ import updateSpace from './lexicons/com/atproto/space/updateSpace.js';
8
+ import { baselineSpacePolicies, } from './policies/baseline.js';
9
+ /**
10
+ * Manages a space as its authority, whatever its policy: its lifecycle, and
11
+ * the API of its policy (see {@link managePolicy}).
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const manager = await SpaceManager.open(client.agent, spaceUri)
16
+ * if (manager instanceof MemberspacePolicyManager) {
17
+ * await manager.putMembers([{ did, read: true, write: true }])
18
+ * }
19
+ *
20
+ * const space = new SpaceManager(client.agent, spaceUri)
21
+ * await space.updateSpace(managedspace.policy.$build({ managingApp }))
22
+ * await space.deleteSpace()
23
+ * ```
24
+ */
25
+ export class SpaceManager {
26
+ /**
27
+ * Gets the manager of the policy governing a space of the user of `agent`
28
+ * (see {@link managePolicy}).
29
+ *
30
+ * @throws {TypeError} if `agent` does not act for the space authority
31
+ * @throws {UnsupportedSpacePolicyError} if the space is not governed by one
32
+ * of `policies`
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const members = await SpaceManager.open(client.agent, spaceUri, {
37
+ * policies: [MemberspacePolicyManager],
38
+ * })
39
+ * await members.putMembers([{ did, read: true, write: true }])
40
+ * ```
41
+ */
42
+ static async open(agent, space, options) {
43
+ if (!isAccountAgent(agent)) {
44
+ throw new TypeError('Agent must be authenticated');
45
+ }
46
+ return new SpaceManager(agent, space).managePolicy(options);
47
+ }
48
+ /**
49
+ * @throws {TypeError} if `agent` does not act for the space authority
50
+ */
51
+ constructor(
52
+ /** The agent of the space authority. */
53
+ agent, ref) {
54
+ this.agent = agent;
55
+ this.ref = typeof ref === 'string' ? SpaceRef.parse(ref) : ref;
56
+ this.uri = this.ref.toString();
57
+ if (agent.did !== this.ref.spaceDid) {
58
+ throw new TypeError(`Only the space authority (${this.ref.spaceDid}) can manage ${this.uri}`);
59
+ }
60
+ }
61
+ /** Gets the space, including the policy governing it. */
62
+ async getSpace(options = {}) {
63
+ const { body } = await xrpc(this.agent, getSpace, {
64
+ ...options,
65
+ params: { space: this.uri },
66
+ });
67
+ return body;
68
+ }
69
+ /**
70
+ * Replaces the policy of the space wholesale. A policy of another `$type`
71
+ * migrates the space, discarding the state of the previous policy (e.g. a
72
+ * member list).
73
+ */
74
+ async updateSpace(policy, options = {}) {
75
+ await xrpc(this.agent, updateSpace, {
76
+ ...options,
77
+ body: { space: this.uri, policy },
78
+ });
79
+ }
80
+ /**
81
+ * Deletes the space, and the authority's repo in it. Other members' repos
82
+ * are left in place.
83
+ */
84
+ async deleteSpace(options = {}) {
85
+ await xrpc(this.agent, deleteSpace, {
86
+ ...options,
87
+ body: { space: this.uri },
88
+ });
89
+ }
90
+ /** Removes an account's repo from the writer set of the space. */
91
+ async removeWriter(repo, options = {}) {
92
+ await xrpc(this.agent, removeWriter, {
93
+ ...options,
94
+ body: { space: this.uri, repo },
95
+ });
96
+ }
97
+ /**
98
+ * Gets the manager of the policy governing the space, from the first of
99
+ * `policies` whose schema matches it.
100
+ *
101
+ * @throws {UnsupportedSpacePolicyError} if the space is not governed by one
102
+ * of `policies`
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const manager = await space.managePolicy({
107
+ * policies: [MemberspacePolicyManager],
108
+ * })
109
+ * await manager.putMembers([{ did, read: true, write: true }])
110
+ * ```
111
+ */
112
+ async managePolicy({ policies = baselineSpacePolicies, signal, } = {}) {
113
+ const { policy } = await this.getSpace({ signal });
114
+ const Manager = policies.find(({ schema }) => schema.matches(policy));
115
+ if (!Manager)
116
+ throw new UnsupportedSpacePolicyError(policy);
117
+ const manager = new Manager(this.agent, this.ref, policy);
118
+ return manager;
119
+ }
120
+ }
121
+ //# sourceMappingURL=space-manager.js.map
@@ -0,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wC,EAAE;QAGzC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QACrE,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,2BAA2B,CAAC,MAAM,CAAC,CAAA;QAC3D,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACzD,OAAO,OAA0C,CAAA;IACnD,CAAC;CACF","sourcesContent":["import {\n type AccountAgent,\n type Agent,\n type DidString,\n type XrpcOptions,\n type XrpcResponseBody,\n isAccountAgent,\n xrpc,\n} from '@atproto/lex-client'\nimport { SpaceRef, type SpaceRefString } from '@atproto/syntax'\nimport { UnsupportedSpacePolicyError } from './errors.js'\nimport deleteSpace from './lexicons/com/atproto/space/deleteSpace.js'\nimport getSpace from './lexicons/com/atproto/space/getSpace.js'\nimport removeWriter from './lexicons/com/atproto/space/removeWriter.js'\nimport updateSpace from './lexicons/com/atproto/space/updateSpace.js'\nimport {\n type BaselineSpacePolicyManager,\n baselineSpacePolicies,\n} from './policies/baseline.js'\nimport type {\n SpacePolicy,\n SpacePolicyManager,\n} from './policies/space-policy-manager.js'\n\nexport type { BaselineSpacePolicyManager, SpacePolicy }\n\nexport declare namespace SpaceManager {\n export type PolicyManagerClass<TInstance = unknown> =\n SpacePolicyManager.Class<TInstance>\n\n export type CallOptions = Omit<\n XrpcOptions,\n 'params' | 'body' | 'encoding' | 'service' | 'labelers'\n >\n\n export type ManagePolicyOptions<\n P extends readonly PolicyManagerClass[] | undefined,\n > = {\n /**\n * The managers of the policies to accept, in place of the baseline ones: e.g.\n * to only accept a memberspace, or to support another policy.\n *\n * @default baselineSpacePolicies\n */\n policies?: P\n signal?: AbortSignal\n }\n\n /**\n * The manager of a space governed by one of the policies in `P`, or by any\n * baseline policy when `P` is `undefined`.\n */\n export type PolicyManagerOf<\n P extends readonly PolicyManagerClass[] | undefined,\n > = undefined extends P\n ? BaselineSpacePolicyManager\n : InstanceType<NonNullable<P>[number]>\n}\n\n/**\n * Manages a space as its authority, whatever its policy: its lifecycle, and\n * the API of its policy (see {@link managePolicy}).\n *\n * @example\n * ```typescript\n * const manager = await SpaceManager.open(client.agent, spaceUri)\n * if (manager instanceof MemberspacePolicyManager) {\n * await manager.putMembers([{ did, read: true, write: true }])\n * }\n *\n * const space = new SpaceManager(client.agent, spaceUri)\n * await space.updateSpace(managedspace.policy.$build({ managingApp }))\n * await space.deleteSpace()\n * ```\n */\nexport class SpaceManager {\n readonly ref: SpaceRef\n readonly uri: SpaceRefString\n\n /**\n * Gets the manager of the policy governing a space of the user of `agent`\n * (see {@link managePolicy}).\n *\n * @throws {TypeError} if `agent` does not act for the space authority\n * @throws {UnsupportedSpacePolicyError} if the space is not governed by one\n * of `policies`\n *\n * @example\n * ```typescript\n * const members = await SpaceManager.open(client.agent, spaceUri, {\n * policies: [MemberspacePolicyManager],\n * })\n * await members.putMembers([{ did, read: true, write: true }])\n * ```\n */\n static async open<\n const P extends readonly SpaceManager.PolicyManagerClass[] | undefined =\n undefined,\n >(\n agent: Agent,\n space: SpaceRefString | SpaceRef,\n options?: SpaceManager.ManagePolicyOptions<P>,\n ): Promise<SpaceManager.PolicyManagerOf<P>> {\n if (!isAccountAgent(agent)) {\n throw new TypeError('Agent must be authenticated')\n }\n return new SpaceManager(agent, space).managePolicy(options)\n }\n\n /**\n * @throws {TypeError} if `agent` does not act for the space authority\n */\n constructor(\n /** The agent of the space authority. */\n readonly agent: AccountAgent,\n ref: SpaceRefString | SpaceRef,\n ) {\n this.ref = typeof ref === 'string' ? SpaceRef.parse(ref) : ref\n this.uri = this.ref.toString()\n if (agent.did !== this.ref.spaceDid) {\n throw new TypeError(\n `Only the space authority (${this.ref.spaceDid}) can manage ${this.uri}`,\n )\n }\n }\n\n /** Gets the space, including the policy governing it. */\n async getSpace(\n options: SpaceManager.CallOptions = {},\n ): Promise<XrpcResponseBody<typeof getSpace>> {\n const { body } = await xrpc(this.agent, getSpace, {\n ...options,\n params: { space: this.uri },\n })\n return body\n }\n\n /**\n * Replaces the policy of the space wholesale. A policy of another `$type`\n * migrates the space, discarding the state of the previous policy (e.g. a\n * member list).\n */\n async updateSpace(\n policy: SpacePolicy,\n options: SpaceManager.CallOptions = {},\n ): Promise<void> {\n await xrpc(this.agent, updateSpace, {\n ...options,\n body: { space: this.uri, policy },\n })\n }\n\n /**\n * Deletes the space, and the authority's repo in it. Other members' repos\n * are left in place.\n */\n async deleteSpace(options: SpaceManager.CallOptions = {}): Promise<void> {\n await xrpc(this.agent, deleteSpace, {\n ...options,\n body: { space: this.uri },\n })\n }\n\n /** Removes an account's repo from the writer set of the space. */\n async removeWriter(\n repo: DidString,\n options: SpaceManager.CallOptions = {},\n ): Promise<void> {\n await xrpc(this.agent, removeWriter, {\n ...options,\n body: { space: this.uri, repo },\n })\n }\n\n /**\n * Gets the manager of the policy governing the space, from the first of\n * `policies` whose schema matches it.\n *\n * @throws {UnsupportedSpacePolicyError} if the space is not governed by one\n * of `policies`\n *\n * @example\n * ```typescript\n * const manager = await space.managePolicy({\n * policies: [MemberspacePolicyManager],\n * })\n * await manager.putMembers([{ did, read: true, write: true }])\n * ```\n */\n async managePolicy<\n const P extends readonly SpaceManager.PolicyManagerClass[] | undefined =\n undefined,\n >({\n policies = baselineSpacePolicies,\n signal,\n }: SpaceManager.ManagePolicyOptions<P> = {}): Promise<\n SpaceManager.PolicyManagerOf<P>\n > {\n const { policy } = await this.getSpace({ signal })\n const Manager = policies.find(({ schema }) => schema.matches(policy))\n if (!Manager) throw new UnsupportedSpacePolicyError(policy)\n const manager = new Manager(this.agent, this.ref, policy)\n return manager as SpaceManager.PolicyManagerOf<P>\n }\n}\n"]}