@aigne/afs-did-space 1.12.0-beta.5

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 (510) hide show
  1. package/LICENSE.md +26 -0
  2. package/README.md +129 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs +11 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs +10 -0
  5. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  6. package/dist/afs-metadata-context.cjs +20 -0
  7. package/dist/afs-metadata-context.d.cts +21 -0
  8. package/dist/afs-metadata-context.d.cts.map +1 -0
  9. package/dist/afs-metadata-context.d.mts +21 -0
  10. package/dist/afs-metadata-context.d.mts.map +1 -0
  11. package/dist/afs-metadata-context.mjs +18 -0
  12. package/dist/afs-metadata-context.mjs.map +1 -0
  13. package/dist/blocklet-hook.cjs +180 -0
  14. package/dist/blocklet-hook.d.cts +29 -0
  15. package/dist/blocklet-hook.d.cts.map +1 -0
  16. package/dist/blocklet-hook.d.mts +29 -0
  17. package/dist/blocklet-hook.d.mts.map +1 -0
  18. package/dist/blocklet-hook.mjs +178 -0
  19. package/dist/blocklet-hook.mjs.map +1 -0
  20. package/dist/changelog-schema.cjs +603 -0
  21. package/dist/changelog-schema.d.cts +395 -0
  22. package/dist/changelog-schema.d.cts.map +1 -0
  23. package/dist/changelog-schema.d.mts +395 -0
  24. package/dist/changelog-schema.d.mts.map +1 -0
  25. package/dist/changelog-schema.mjs +570 -0
  26. package/dist/changelog-schema.mjs.map +1 -0
  27. package/dist/changelog-write.cjs +80 -0
  28. package/dist/changelog-write.d.cts +70 -0
  29. package/dist/changelog-write.d.cts.map +1 -0
  30. package/dist/changelog-write.d.mts +70 -0
  31. package/dist/changelog-write.d.mts.map +1 -0
  32. package/dist/changelog-write.mjs +77 -0
  33. package/dist/changelog-write.mjs.map +1 -0
  34. package/dist/cid-byte-cache.cjs +126 -0
  35. package/dist/cid-byte-cache.d.cts +46 -0
  36. package/dist/cid-byte-cache.d.cts.map +1 -0
  37. package/dist/cid-byte-cache.d.mts +47 -0
  38. package/dist/cid-byte-cache.d.mts.map +1 -0
  39. package/dist/cid-byte-cache.mjs +125 -0
  40. package/dist/cid-byte-cache.mjs.map +1 -0
  41. package/dist/cid.cjs +68 -0
  42. package/dist/cid.d.cts +22 -0
  43. package/dist/cid.d.cts.map +1 -0
  44. package/dist/cid.d.mts +22 -0
  45. package/dist/cid.d.mts.map +1 -0
  46. package/dist/cid.mjs +65 -0
  47. package/dist/cid.mjs.map +1 -0
  48. package/dist/client.cjs +221 -0
  49. package/dist/client.d.cts +72 -0
  50. package/dist/client.d.cts.map +1 -0
  51. package/dist/client.d.mts +72 -0
  52. package/dist/client.d.mts.map +1 -0
  53. package/dist/client.mjs +220 -0
  54. package/dist/client.mjs.map +1 -0
  55. package/dist/cloudflare.cjs +510 -0
  56. package/dist/cloudflare.d.cts +307 -0
  57. package/dist/cloudflare.d.cts.map +1 -0
  58. package/dist/cloudflare.d.mts +308 -0
  59. package/dist/cloudflare.d.mts.map +1 -0
  60. package/dist/cloudflare.mjs +507 -0
  61. package/dist/cloudflare.mjs.map +1 -0
  62. package/dist/ctime-backfill.cjs +272 -0
  63. package/dist/ctime-backfill.d.cts +169 -0
  64. package/dist/ctime-backfill.d.cts.map +1 -0
  65. package/dist/ctime-backfill.d.mts +169 -0
  66. package/dist/ctime-backfill.d.mts.map +1 -0
  67. package/dist/ctime-backfill.mjs +267 -0
  68. package/dist/ctime-backfill.mjs.map +1 -0
  69. package/dist/d1-gc-queue.cjs +80 -0
  70. package/dist/d1-gc-queue.d.cts +59 -0
  71. package/dist/d1-gc-queue.d.cts.map +1 -0
  72. package/dist/d1-gc-queue.d.mts +59 -0
  73. package/dist/d1-gc-queue.d.mts.map +1 -0
  74. package/dist/d1-gc-queue.mjs +81 -0
  75. package/dist/d1-gc-queue.mjs.map +1 -0
  76. package/dist/d1-resolve-store.cjs +189 -0
  77. package/dist/d1-resolve-store.d.cts +93 -0
  78. package/dist/d1-resolve-store.d.cts.map +1 -0
  79. package/dist/d1-resolve-store.d.mts +93 -0
  80. package/dist/d1-resolve-store.d.mts.map +1 -0
  81. package/dist/d1-resolve-store.mjs +190 -0
  82. package/dist/d1-resolve-store.mjs.map +1 -0
  83. package/dist/d1-schema.cjs +361 -0
  84. package/dist/d1-schema.d.cts +237 -0
  85. package/dist/d1-schema.d.cts.map +1 -0
  86. package/dist/d1-schema.d.mts +237 -0
  87. package/dist/d1-schema.d.mts.map +1 -0
  88. package/dist/d1-schema.mjs +341 -0
  89. package/dist/d1-schema.mjs.map +1 -0
  90. package/dist/d1-share-store.cjs +0 -0
  91. package/dist/d1-share-store.d.cts +53 -0
  92. package/dist/d1-share-store.d.cts.map +1 -0
  93. package/dist/d1-share-store.d.mts +53 -0
  94. package/dist/d1-share-store.d.mts.map +1 -0
  95. package/dist/d1-share-store.mjs +0 -0
  96. package/dist/d1-share-store.mjs.map +1 -0
  97. package/dist/d1-tree-index.cjs +1098 -0
  98. package/dist/d1-tree-index.d.cts +203 -0
  99. package/dist/d1-tree-index.d.cts.map +1 -0
  100. package/dist/d1-tree-index.d.mts +203 -0
  101. package/dist/d1-tree-index.d.mts.map +1 -0
  102. package/dist/d1-tree-index.mjs +1094 -0
  103. package/dist/d1-tree-index.mjs.map +1 -0
  104. package/dist/data-backend.cjs +147 -0
  105. package/dist/data-backend.d.cts +30 -0
  106. package/dist/data-backend.d.cts.map +1 -0
  107. package/dist/data-backend.d.mts +30 -0
  108. package/dist/data-backend.d.mts.map +1 -0
  109. package/dist/data-backend.mjs +148 -0
  110. package/dist/data-backend.mjs.map +1 -0
  111. package/dist/dedup-backfill.cjs +278 -0
  112. package/dist/dedup-backfill.d.cts +165 -0
  113. package/dist/dedup-backfill.d.cts.map +1 -0
  114. package/dist/dedup-backfill.d.mts +165 -0
  115. package/dist/dedup-backfill.d.mts.map +1 -0
  116. package/dist/dedup-backfill.mjs +273 -0
  117. package/dist/dedup-backfill.mjs.map +1 -0
  118. package/dist/did-space-like.d.cts +2 -0
  119. package/dist/did-space-like.d.mts +2 -0
  120. package/dist/did-utils.cjs +44 -0
  121. package/dist/did-utils.d.cts +25 -0
  122. package/dist/did-utils.d.cts.map +1 -0
  123. package/dist/did-utils.d.mts +25 -0
  124. package/dist/did-utils.d.mts.map +1 -0
  125. package/dist/did-utils.mjs +43 -0
  126. package/dist/did-utils.mjs.map +1 -0
  127. package/dist/dirty-path-queue.cjs +31 -0
  128. package/dist/dirty-path-queue.d.cts +104 -0
  129. package/dist/dirty-path-queue.d.cts.map +1 -0
  130. package/dist/dirty-path-queue.d.mts +104 -0
  131. package/dist/dirty-path-queue.d.mts.map +1 -0
  132. package/dist/dirty-path-queue.mjs +31 -0
  133. package/dist/dirty-path-queue.mjs.map +1 -0
  134. package/dist/dirty-path-schema.cjs +142 -0
  135. package/dist/dirty-path-schema.d.cts +90 -0
  136. package/dist/dirty-path-schema.d.cts.map +1 -0
  137. package/dist/dirty-path-schema.d.mts +90 -0
  138. package/dist/dirty-path-schema.d.mts.map +1 -0
  139. package/dist/dirty-path-schema.mjs +136 -0
  140. package/dist/dirty-path-schema.mjs.map +1 -0
  141. package/dist/download-actions.cjs +43 -0
  142. package/dist/download-actions.mjs +40 -0
  143. package/dist/download-actions.mjs.map +1 -0
  144. package/dist/fs-object-store.cjs +153 -0
  145. package/dist/fs-object-store.d.cts +21 -0
  146. package/dist/fs-object-store.d.cts.map +1 -0
  147. package/dist/fs-object-store.d.mts +22 -0
  148. package/dist/fs-object-store.d.mts.map +1 -0
  149. package/dist/fs-object-store.mjs +153 -0
  150. package/dist/fs-object-store.mjs.map +1 -0
  151. package/dist/gc-queue.d.cts +43 -0
  152. package/dist/gc-queue.d.cts.map +1 -0
  153. package/dist/gc-queue.d.mts +43 -0
  154. package/dist/gc-queue.d.mts.map +1 -0
  155. package/dist/index.cjs +2712 -0
  156. package/dist/index.d.cts +504 -0
  157. package/dist/index.d.cts.map +1 -0
  158. package/dist/index.d.mts +505 -0
  159. package/dist/index.d.mts.map +1 -0
  160. package/dist/index.mjs +2537 -0
  161. package/dist/index.mjs.map +1 -0
  162. package/dist/inline-content-migration.cjs +212 -0
  163. package/dist/inline-content-migration.d.cts +110 -0
  164. package/dist/inline-content-migration.d.cts.map +1 -0
  165. package/dist/inline-content-migration.d.mts +111 -0
  166. package/dist/inline-content-migration.d.mts.map +1 -0
  167. package/dist/inline-content-migration.mjs +207 -0
  168. package/dist/inline-content-migration.mjs.map +1 -0
  169. package/dist/inline-content.cjs +145 -0
  170. package/dist/inline-content.d.cts +98 -0
  171. package/dist/inline-content.d.cts.map +1 -0
  172. package/dist/inline-content.d.mts +98 -0
  173. package/dist/inline-content.d.mts.map +1 -0
  174. package/dist/inline-content.mjs +137 -0
  175. package/dist/inline-content.mjs.map +1 -0
  176. package/dist/local-changelog.cjs +241 -0
  177. package/dist/local-changelog.d.cts +119 -0
  178. package/dist/local-changelog.d.cts.map +1 -0
  179. package/dist/local-changelog.d.mts +119 -0
  180. package/dist/local-changelog.d.mts.map +1 -0
  181. package/dist/local-changelog.mjs +240 -0
  182. package/dist/local-changelog.mjs.map +1 -0
  183. package/dist/local.cjs +435 -0
  184. package/dist/local.d.cts +254 -0
  185. package/dist/local.d.cts.map +1 -0
  186. package/dist/local.d.mts +254 -0
  187. package/dist/local.d.mts.map +1 -0
  188. package/dist/local.mjs +427 -0
  189. package/dist/local.mjs.map +1 -0
  190. package/dist/memory-gc-queue.cjs +36 -0
  191. package/dist/memory-gc-queue.d.cts +22 -0
  192. package/dist/memory-gc-queue.d.cts.map +1 -0
  193. package/dist/memory-gc-queue.d.mts +22 -0
  194. package/dist/memory-gc-queue.d.mts.map +1 -0
  195. package/dist/memory-gc-queue.mjs +36 -0
  196. package/dist/memory-gc-queue.mjs.map +1 -0
  197. package/dist/memory-tree-index.cjs +734 -0
  198. package/dist/memory-tree-index.d.cts +159 -0
  199. package/dist/memory-tree-index.d.cts.map +1 -0
  200. package/dist/memory-tree-index.d.mts +159 -0
  201. package/dist/memory-tree-index.d.mts.map +1 -0
  202. package/dist/memory-tree-index.mjs +735 -0
  203. package/dist/memory-tree-index.mjs.map +1 -0
  204. package/dist/metadata-db.cjs +562 -0
  205. package/dist/metadata-db.d.cts +102 -0
  206. package/dist/metadata-db.d.cts.map +1 -0
  207. package/dist/metadata-db.d.mts +102 -0
  208. package/dist/metadata-db.d.mts.map +1 -0
  209. package/dist/metadata-db.mjs +562 -0
  210. package/dist/metadata-db.mjs.map +1 -0
  211. package/dist/mime-utils.cjs +2 -0
  212. package/dist/mime-utils.d.cts +2 -0
  213. package/dist/mime-utils.d.mts +2 -0
  214. package/dist/mime-utils.mjs +3 -0
  215. package/dist/object-key.cjs +41 -0
  216. package/dist/object-key.d.cts +25 -0
  217. package/dist/object-key.d.cts.map +1 -0
  218. package/dist/object-key.d.mts +25 -0
  219. package/dist/object-key.d.mts.map +1 -0
  220. package/dist/object-key.mjs +40 -0
  221. package/dist/object-key.mjs.map +1 -0
  222. package/dist/packages/session/dist/index.cjs +788 -0
  223. package/dist/packages/session/dist/index.mjs +782 -0
  224. package/dist/packages/session/dist/index.mjs.map +1 -0
  225. package/dist/platform/r2/dist/types.d.cts +49 -0
  226. package/dist/platform/r2/dist/types.d.cts.map +1 -0
  227. package/dist/prefix-range.cjs +33 -0
  228. package/dist/prefix-range.d.cts +29 -0
  229. package/dist/prefix-range.d.cts.map +1 -0
  230. package/dist/prefix-range.d.mts +29 -0
  231. package/dist/prefix-range.d.mts.map +1 -0
  232. package/dist/prefix-range.mjs +33 -0
  233. package/dist/prefix-range.mjs.map +1 -0
  234. package/dist/prefixed-tree-index.cjs +238 -0
  235. package/dist/prefixed-tree-index.d.cts +85 -0
  236. package/dist/prefixed-tree-index.d.cts.map +1 -0
  237. package/dist/prefixed-tree-index.d.mts +85 -0
  238. package/dist/prefixed-tree-index.d.mts.map +1 -0
  239. package/dist/prefixed-tree-index.mjs +239 -0
  240. package/dist/prefixed-tree-index.mjs.map +1 -0
  241. package/dist/presign-signer.cjs +7 -0
  242. package/dist/presign-signer.d.cts +99 -0
  243. package/dist/presign-signer.d.cts.map +1 -0
  244. package/dist/presign-signer.d.mts +99 -0
  245. package/dist/presign-signer.d.mts.map +1 -0
  246. package/dist/presign-signer.mjs +7 -0
  247. package/dist/presign-signer.mjs.map +1 -0
  248. package/dist/providers/platform/r2/dist/index.d.mts +3 -0
  249. package/dist/providers/platform/r2/dist/types.d.mts +49 -0
  250. package/dist/providers/platform/r2/dist/types.d.mts.map +1 -0
  251. package/dist/reconcile.cjs +184 -0
  252. package/dist/reconcile.d.cts +26 -0
  253. package/dist/reconcile.d.cts.map +1 -0
  254. package/dist/reconcile.d.mts +26 -0
  255. package/dist/reconcile.d.mts.map +1 -0
  256. package/dist/reconcile.mjs +184 -0
  257. package/dist/reconcile.mjs.map +1 -0
  258. package/dist/reference-check.cjs +49 -0
  259. package/dist/reference-check.d.cts +10 -0
  260. package/dist/reference-check.d.cts.map +1 -0
  261. package/dist/reference-check.d.mts +10 -0
  262. package/dist/reference-check.d.mts.map +1 -0
  263. package/dist/reference-check.mjs +48 -0
  264. package/dist/reference-check.mjs.map +1 -0
  265. package/dist/remote-afs.cjs +681 -0
  266. package/dist/remote-afs.d.cts +236 -0
  267. package/dist/remote-afs.d.cts.map +1 -0
  268. package/dist/remote-afs.d.mts +236 -0
  269. package/dist/remote-afs.d.mts.map +1 -0
  270. package/dist/remote-afs.mjs +676 -0
  271. package/dist/remote-afs.mjs.map +1 -0
  272. package/dist/rename-guard.cjs +18 -0
  273. package/dist/rename-guard.mjs +18 -0
  274. package/dist/rename-guard.mjs.map +1 -0
  275. package/dist/resolve.cjs +260 -0
  276. package/dist/resolve.d.cts +113 -0
  277. package/dist/resolve.d.cts.map +1 -0
  278. package/dist/resolve.d.mts +113 -0
  279. package/dist/resolve.d.mts.map +1 -0
  280. package/dist/resolve.mjs +260 -0
  281. package/dist/resolve.mjs.map +1 -0
  282. package/dist/rsync-content.cjs +33 -0
  283. package/dist/rsync-content.mjs +33 -0
  284. package/dist/rsync-content.mjs.map +1 -0
  285. package/dist/rsync.cjs +400 -0
  286. package/dist/rsync.d.cts +157 -0
  287. package/dist/rsync.d.cts.map +1 -0
  288. package/dist/rsync.d.mts +157 -0
  289. package/dist/rsync.d.mts.map +1 -0
  290. package/dist/rsync.mjs +397 -0
  291. package/dist/rsync.mjs.map +1 -0
  292. package/dist/run-gc.cjs +57 -0
  293. package/dist/run-gc.d.cts +40 -0
  294. package/dist/run-gc.d.cts.map +1 -0
  295. package/dist/run-gc.d.mts +41 -0
  296. package/dist/run-gc.d.mts.map +1 -0
  297. package/dist/run-gc.mjs +57 -0
  298. package/dist/run-gc.mjs.map +1 -0
  299. package/dist/scope-id.cjs +70 -0
  300. package/dist/scope-id.d.cts +35 -0
  301. package/dist/scope-id.d.cts.map +1 -0
  302. package/dist/scope-id.d.mts +35 -0
  303. package/dist/scope-id.d.mts.map +1 -0
  304. package/dist/scope-id.mjs +68 -0
  305. package/dist/scope-id.mjs.map +1 -0
  306. package/dist/scope-migration-node.cjs +172 -0
  307. package/dist/scope-migration-node.d.cts +44 -0
  308. package/dist/scope-migration-node.d.cts.map +1 -0
  309. package/dist/scope-migration-node.d.mts +44 -0
  310. package/dist/scope-migration-node.d.mts.map +1 -0
  311. package/dist/scope-migration-node.mjs +171 -0
  312. package/dist/scope-migration-node.mjs.map +1 -0
  313. package/dist/scope-migration.cjs +155 -0
  314. package/dist/scope-migration.d.cts +65 -0
  315. package/dist/scope-migration.d.cts.map +1 -0
  316. package/dist/scope-migration.d.mts +65 -0
  317. package/dist/scope-migration.d.mts.map +1 -0
  318. package/dist/scope-migration.mjs +154 -0
  319. package/dist/scope-migration.mjs.map +1 -0
  320. package/dist/share-declaration.cjs +225 -0
  321. package/dist/share-declaration.d.cts +30 -0
  322. package/dist/share-declaration.d.cts.map +1 -0
  323. package/dist/share-declaration.d.mts +32 -0
  324. package/dist/share-declaration.d.mts.map +1 -0
  325. package/dist/share-declaration.mjs +221 -0
  326. package/dist/share-declaration.mjs.map +1 -0
  327. package/dist/share-hook.cjs +63 -0
  328. package/dist/share-hook.mjs +62 -0
  329. package/dist/share-hook.mjs.map +1 -0
  330. package/dist/share-resolve.cjs +176 -0
  331. package/dist/share-resolve.d.cts +36 -0
  332. package/dist/share-resolve.d.cts.map +1 -0
  333. package/dist/share-resolve.d.mts +36 -0
  334. package/dist/share-resolve.d.mts.map +1 -0
  335. package/dist/share-resolve.mjs +177 -0
  336. package/dist/share-resolve.mjs.map +1 -0
  337. package/dist/share-serve.cjs +145 -0
  338. package/dist/share-serve.d.cts +30 -0
  339. package/dist/share-serve.d.cts.map +1 -0
  340. package/dist/share-serve.d.mts +30 -0
  341. package/dist/share-serve.d.mts.map +1 -0
  342. package/dist/share-serve.mjs +144 -0
  343. package/dist/share-serve.mjs.map +1 -0
  344. package/dist/share-store.cjs +25 -0
  345. package/dist/share-store.d.cts +65 -0
  346. package/dist/share-store.d.cts.map +1 -0
  347. package/dist/share-store.d.mts +65 -0
  348. package/dist/share-store.d.mts.map +1 -0
  349. package/dist/share-store.mjs +25 -0
  350. package/dist/share-store.mjs.map +1 -0
  351. package/dist/share-virtual-path.cjs +102 -0
  352. package/dist/share-virtual-path.mjs +101 -0
  353. package/dist/share-virtual-path.mjs.map +1 -0
  354. package/dist/space-resolver.cjs +54 -0
  355. package/dist/space-resolver.d.cts +34 -0
  356. package/dist/space-resolver.d.cts.map +1 -0
  357. package/dist/space-resolver.d.mts +34 -0
  358. package/dist/space-resolver.d.mts.map +1 -0
  359. package/dist/space-resolver.mjs +55 -0
  360. package/dist/space-resolver.mjs.map +1 -0
  361. package/dist/sqlite-gc-queue.cjs +51 -0
  362. package/dist/sqlite-gc-queue.d.cts +22 -0
  363. package/dist/sqlite-gc-queue.d.cts.map +1 -0
  364. package/dist/sqlite-gc-queue.d.mts +22 -0
  365. package/dist/sqlite-gc-queue.d.mts.map +1 -0
  366. package/dist/sqlite-gc-queue.mjs +52 -0
  367. package/dist/sqlite-gc-queue.mjs.map +1 -0
  368. package/dist/sqlite-resolve-store.cjs +163 -0
  369. package/dist/sqlite-resolve-store.d.cts +50 -0
  370. package/dist/sqlite-resolve-store.d.cts.map +1 -0
  371. package/dist/sqlite-resolve-store.d.mts +50 -0
  372. package/dist/sqlite-resolve-store.d.mts.map +1 -0
  373. package/dist/sqlite-resolve-store.mjs +164 -0
  374. package/dist/sqlite-resolve-store.mjs.map +1 -0
  375. package/dist/sqlite-share-store.cjs +157 -0
  376. package/dist/sqlite-share-store.d.cts +31 -0
  377. package/dist/sqlite-share-store.d.cts.map +1 -0
  378. package/dist/sqlite-share-store.d.mts +31 -0
  379. package/dist/sqlite-share-store.d.mts.map +1 -0
  380. package/dist/sqlite-share-store.mjs +157 -0
  381. package/dist/sqlite-share-store.mjs.map +1 -0
  382. package/dist/sqlite-tree-index.cjs +901 -0
  383. package/dist/sqlite-tree-index.d.cts +107 -0
  384. package/dist/sqlite-tree-index.d.cts.map +1 -0
  385. package/dist/sqlite-tree-index.d.mts +107 -0
  386. package/dist/sqlite-tree-index.d.mts.map +1 -0
  387. package/dist/sqlite-tree-index.mjs +902 -0
  388. package/dist/sqlite-tree-index.mjs.map +1 -0
  389. package/dist/sync-engine.cjs +1324 -0
  390. package/dist/sync-engine.d.cts +473 -0
  391. package/dist/sync-engine.d.cts.map +1 -0
  392. package/dist/sync-engine.d.mts +473 -0
  393. package/dist/sync-engine.d.mts.map +1 -0
  394. package/dist/sync-engine.mjs +1315 -0
  395. package/dist/sync-engine.mjs.map +1 -0
  396. package/dist/sync-state.cjs +303 -0
  397. package/dist/sync-state.d.cts +224 -0
  398. package/dist/sync-state.d.cts.map +1 -0
  399. package/dist/sync-state.d.mts +224 -0
  400. package/dist/sync-state.d.mts.map +1 -0
  401. package/dist/sync-state.mjs +297 -0
  402. package/dist/sync-state.mjs.map +1 -0
  403. package/dist/timestamp.cjs +92 -0
  404. package/dist/timestamp.mjs +91 -0
  405. package/dist/timestamp.mjs.map +1 -0
  406. package/dist/transports/http.cjs +54 -0
  407. package/dist/transports/http.d.cts +26 -0
  408. package/dist/transports/http.d.cts.map +1 -0
  409. package/dist/transports/http.d.mts +26 -0
  410. package/dist/transports/http.d.mts.map +1 -0
  411. package/dist/transports/http.mjs +54 -0
  412. package/dist/transports/http.mjs.map +1 -0
  413. package/dist/transports/static.cjs +55 -0
  414. package/dist/transports/static.d.cts +28 -0
  415. package/dist/transports/static.d.cts.map +1 -0
  416. package/dist/transports/static.d.mts +28 -0
  417. package/dist/transports/static.d.mts.map +1 -0
  418. package/dist/transports/static.mjs +55 -0
  419. package/dist/transports/static.mjs.map +1 -0
  420. package/dist/transports/types.cjs +13 -0
  421. package/dist/transports/types.d.cts +72 -0
  422. package/dist/transports/types.d.cts.map +1 -0
  423. package/dist/transports/types.d.mts +72 -0
  424. package/dist/transports/types.d.mts.map +1 -0
  425. package/dist/transports/types.mjs +13 -0
  426. package/dist/transports/types.mjs.map +1 -0
  427. package/dist/transports/ws.cjs +207 -0
  428. package/dist/transports/ws.d.cts +47 -0
  429. package/dist/transports/ws.d.cts.map +1 -0
  430. package/dist/transports/ws.d.mts +47 -0
  431. package/dist/transports/ws.d.mts.map +1 -0
  432. package/dist/transports/ws.mjs +206 -0
  433. package/dist/transports/ws.mjs.map +1 -0
  434. package/dist/tree-index.cjs +333 -0
  435. package/dist/tree-index.d.cts +524 -0
  436. package/dist/tree-index.d.cts.map +1 -0
  437. package/dist/tree-index.d.mts +524 -0
  438. package/dist/tree-index.d.mts.map +1 -0
  439. package/dist/tree-index.mjs +322 -0
  440. package/dist/tree-index.mjs.map +1 -0
  441. package/dist/tree-query.cjs +655 -0
  442. package/dist/tree-query.d.cts +70 -0
  443. package/dist/tree-query.d.cts.map +1 -0
  444. package/dist/tree-query.d.mts +70 -0
  445. package/dist/tree-query.d.mts.map +1 -0
  446. package/dist/tree-query.mjs +648 -0
  447. package/dist/tree-query.mjs.map +1 -0
  448. package/dist/upload-actions.cjs +97 -0
  449. package/dist/upload-actions.d.cts +19 -0
  450. package/dist/upload-actions.d.cts.map +1 -0
  451. package/dist/upload-actions.d.mts +21 -0
  452. package/dist/upload-actions.d.mts.map +1 -0
  453. package/dist/upload-actions.mjs +90 -0
  454. package/dist/upload-actions.mjs.map +1 -0
  455. package/dist/upload-session-store.cjs +185 -0
  456. package/dist/upload-session-store.d.cts +99 -0
  457. package/dist/upload-session-store.d.cts.map +1 -0
  458. package/dist/upload-session-store.d.mts +99 -0
  459. package/dist/upload-session-store.d.mts.map +1 -0
  460. package/dist/upload-session-store.mjs +184 -0
  461. package/dist/upload-session-store.mjs.map +1 -0
  462. package/dist/url-normalize.cjs +61 -0
  463. package/dist/url-normalize.d.cts +33 -0
  464. package/dist/url-normalize.d.cts.map +1 -0
  465. package/dist/url-normalize.d.mts +33 -0
  466. package/dist/url-normalize.d.mts.map +1 -0
  467. package/dist/url-normalize.mjs +61 -0
  468. package/dist/url-normalize.mjs.map +1 -0
  469. package/dist/versioned-content-backends.cjs +155 -0
  470. package/dist/versioned-content-backends.d.cts +49 -0
  471. package/dist/versioned-content-backends.d.cts.map +1 -0
  472. package/dist/versioned-content-backends.d.mts +49 -0
  473. package/dist/versioned-content-backends.d.mts.map +1 -0
  474. package/dist/versioned-content-backends.mjs +154 -0
  475. package/dist/versioned-content-backends.mjs.map +1 -0
  476. package/dist/versioned-content-index.cjs +102 -0
  477. package/dist/versioned-content-index.d.cts +46 -0
  478. package/dist/versioned-content-index.d.cts.map +1 -0
  479. package/dist/versioned-content-index.d.mts +46 -0
  480. package/dist/versioned-content-index.d.mts.map +1 -0
  481. package/dist/versioned-content-index.mjs +103 -0
  482. package/dist/versioned-content-index.mjs.map +1 -0
  483. package/dist/versioned-content-store.cjs +121 -0
  484. package/dist/versioned-content-store.d.cts +90 -0
  485. package/dist/versioned-content-store.d.cts.map +1 -0
  486. package/dist/versioned-content-store.d.mts +90 -0
  487. package/dist/versioned-content-store.d.mts.map +1 -0
  488. package/dist/versioned-content-store.mjs +122 -0
  489. package/dist/versioned-content-store.mjs.map +1 -0
  490. package/dist/versioned-scope.cjs +39 -0
  491. package/dist/versioned-scope.d.cts +57 -0
  492. package/dist/versioned-scope.d.cts.map +1 -0
  493. package/dist/versioned-scope.d.mts +57 -0
  494. package/dist/versioned-scope.d.mts.map +1 -0
  495. package/dist/versioned-scope.mjs +37 -0
  496. package/dist/versioned-scope.mjs.map +1 -0
  497. package/migrations/0001_tree_entries.sql +17 -0
  498. package/migrations/0002_resolve_entries.sql +7 -0
  499. package/migrations/0003_entries_v2.sql +38 -0
  500. package/migrations/0004_gc_queue.sql +5 -0
  501. package/migrations/0006_resolve_enhance.sql +14 -0
  502. package/migrations/0007_resolve_created_at.sql +10 -0
  503. package/migrations/0008_changelog.sql +34 -0
  504. package/migrations/0009_device_sync_state.sql +29 -0
  505. package/migrations/0010_scope_meta.sql +33 -0
  506. package/migrations/0011_shares.sql +25 -0
  507. package/migrations/0012_scope_meta_file_count.sql +41 -0
  508. package/migrations/0013_scope_meta_total_bytes.sql +47 -0
  509. package/migrations/0014_rename_tables.sql +62 -0
  510. package/package.json +102 -0
@@ -0,0 +1,65 @@
1
+ import { ShareDeclaration } from "./share-declaration.cjs";
2
+
3
+ //#region src/share-store.d.ts
4
+ interface ShareEntry {
5
+ id: string;
6
+ ownerDid: string;
7
+ sourcePath: string;
8
+ declPath: string;
9
+ slug: string;
10
+ kind: "raw" | "web";
11
+ status: "active" | "revoked";
12
+ declCid?: string;
13
+ config: ShareDeclaration;
14
+ createdAt: number;
15
+ updatedAt: number;
16
+ }
17
+ interface ShareRow {
18
+ id: string;
19
+ owner_did: string;
20
+ source_path: string;
21
+ decl_path: string;
22
+ slug: string;
23
+ kind: "raw" | "web";
24
+ status: "active" | "revoked";
25
+ decl_cid: string | null;
26
+ config_json: string;
27
+ created_at: number;
28
+ updated_at: number;
29
+ }
30
+ /** Map a raw storage row to a public ShareEntry (malformed config_json → {}). */
31
+ declare function rowToEntry(row: ShareRow): ShareEntry;
32
+ interface ShareStore {
33
+ /** Create the `shares` table + indices if missing (idempotent). */
34
+ ensureTable(): Promise<void>;
35
+ /** Public serving hot path — slug is global, no owner scope. */
36
+ resolveBySlug(slug: string): Promise<ShareEntry | null>;
37
+ /** `.shares/` listing — active, non-unlisted, newest first. */
38
+ listByOwner(ownerDid: string): Promise<ShareEntry[]>;
39
+ /** `instances/{iid}/.shares` listing — active, non-unlisted, newest first. */
40
+ listByInstance(ownerDid: string, instanceDid: string): Promise<ShareEntry[]>;
41
+ /** `.shares/{slug}` read — owner-scoped (cross-owner read returns null). */
42
+ readByOwnerAndSlug(ownerDid: string, slug: string): Promise<ShareEntry | null>;
43
+ /** Reconcile: look up the existing row for this owner's decl path. */
44
+ findByOwnerAndDeclPath(ownerDid: string, declPath: string): Promise<ShareEntry | null>;
45
+ /**
46
+ * Nested-share detection — return the conflicting decl_path (a parent or
47
+ * child share owned by the SAME owner whose sourcePath overlaps), or null.
48
+ */
49
+ findNestedConflict(ownerDid: string, declPath: string, sourcePath: string): Promise<string | null>;
50
+ /**
51
+ * Slug uniqueness check (slug is global). Return the conflicting decl_path,
52
+ * or null. The row identified by `(ownerDid, declPath)` is excluded BY
53
+ * IDENTITY — never by decl_path alone, else a sibling owner's same-decl_path
54
+ * row would be wrongly excluded and let the slug collision slip past the
55
+ * pre-io dry-run into a post-io global-UNIQUE failure.
56
+ */
57
+ findSlugConflict(slug: string, ownerDid: string, declPath: string): Promise<string | null>;
58
+ /** Reconcile write — INSERT … ON CONFLICT(owner_did, decl_path) DO UPDATE. */
59
+ upsert(row: ShareRow): Promise<void>;
60
+ /** Reconcile delete — owner-scoped (never touches a sibling owner's row). */
61
+ deleteByOwnerAndDeclPath(ownerDid: string, declPath: string): Promise<void>;
62
+ }
63
+ //#endregion
64
+ export { ShareEntry, ShareRow, ShareStore, rowToEntry };
65
+ //# sourceMappingURL=share-store.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-store.d.cts","names":[],"sources":["../src/share-store.ts"],"mappings":";;;UAyBiB,UAAA;EACf,EAAA;EACA,QAAA;EACA,UAAA;EACA,QAAA;EACA,IAAA;EACA,IAAA;EACA,MAAA;EACA,OAAA;EACA,MAAA,EAAQ,gBAAA;EACR,SAAA;EACA,SAAA;AAAA;AAAA,UAKe,QAAA;EACf,EAAA;EACA,SAAA;EACA,WAAA;EACA,SAAA;EACA,IAAA;EACA,IAAA;EACA,MAAA;EACA,QAAA;EACA,WAAA;EACA,UAAA;EACA,UAAA;AAAA;AA4BF;AAAA,iBAxBgB,UAAA,CAAW,GAAA,EAAK,QAAA,GAAW,UAAA;AAAA,UAwB1B,UAAA;EAEA;EAAf,WAAA,IAAe,OAAA;EAGc;EAA7B,aAAA,CAAc,IAAA,WAAe,OAAA,CAAQ,UAAA;EAGN;EAA/B,WAAA,CAAY,QAAA,WAAmB,OAAA,CAAQ,UAAA;EAGgB;EAAvD,cAAA,CAAe,QAAA,UAAkB,WAAA,WAAsB,OAAA,CAAQ,UAAA;EAGX;EAApD,kBAAA,CAAmB,QAAA,UAAkB,IAAA,WAAe,OAAA,CAAQ,UAAA;EAGA;EAA5D,sBAAA,CAAuB,QAAA,UAAkB,QAAA,WAAmB,OAAA,CAAQ,UAAA;EAmBA;;;;EAbpE,kBAAA,CACE,QAAA,UACA,QAAA,UACA,UAAA,WACC,OAAA;EAekE;;;;;;;EANrE,gBAAA,CAAiB,IAAA,UAAc,QAAA,UAAkB,QAAA,WAAmB,OAAA;EA5BxD;EA+BZ,MAAA,CAAO,GAAA,EAAK,QAAA,GAAW,OAAA;EA/BgB;EAkCvC,wBAAA,CAAyB,QAAA,UAAkB,QAAA,WAAmB,OAAA;AAAA"}
@@ -0,0 +1,65 @@
1
+ import { ShareDeclaration } from "./share-declaration.mjs";
2
+
3
+ //#region src/share-store.d.ts
4
+ interface ShareEntry {
5
+ id: string;
6
+ ownerDid: string;
7
+ sourcePath: string;
8
+ declPath: string;
9
+ slug: string;
10
+ kind: "raw" | "web";
11
+ status: "active" | "revoked";
12
+ declCid?: string;
13
+ config: ShareDeclaration;
14
+ createdAt: number;
15
+ updatedAt: number;
16
+ }
17
+ interface ShareRow {
18
+ id: string;
19
+ owner_did: string;
20
+ source_path: string;
21
+ decl_path: string;
22
+ slug: string;
23
+ kind: "raw" | "web";
24
+ status: "active" | "revoked";
25
+ decl_cid: string | null;
26
+ config_json: string;
27
+ created_at: number;
28
+ updated_at: number;
29
+ }
30
+ /** Map a raw storage row to a public ShareEntry (malformed config_json → {}). */
31
+ declare function rowToEntry(row: ShareRow): ShareEntry;
32
+ interface ShareStore {
33
+ /** Create the `shares` table + indices if missing (idempotent). */
34
+ ensureTable(): Promise<void>;
35
+ /** Public serving hot path — slug is global, no owner scope. */
36
+ resolveBySlug(slug: string): Promise<ShareEntry | null>;
37
+ /** `.shares/` listing — active, non-unlisted, newest first. */
38
+ listByOwner(ownerDid: string): Promise<ShareEntry[]>;
39
+ /** `instances/{iid}/.shares` listing — active, non-unlisted, newest first. */
40
+ listByInstance(ownerDid: string, instanceDid: string): Promise<ShareEntry[]>;
41
+ /** `.shares/{slug}` read — owner-scoped (cross-owner read returns null). */
42
+ readByOwnerAndSlug(ownerDid: string, slug: string): Promise<ShareEntry | null>;
43
+ /** Reconcile: look up the existing row for this owner's decl path. */
44
+ findByOwnerAndDeclPath(ownerDid: string, declPath: string): Promise<ShareEntry | null>;
45
+ /**
46
+ * Nested-share detection — return the conflicting decl_path (a parent or
47
+ * child share owned by the SAME owner whose sourcePath overlaps), or null.
48
+ */
49
+ findNestedConflict(ownerDid: string, declPath: string, sourcePath: string): Promise<string | null>;
50
+ /**
51
+ * Slug uniqueness check (slug is global). Return the conflicting decl_path,
52
+ * or null. The row identified by `(ownerDid, declPath)` is excluded BY
53
+ * IDENTITY — never by decl_path alone, else a sibling owner's same-decl_path
54
+ * row would be wrongly excluded and let the slug collision slip past the
55
+ * pre-io dry-run into a post-io global-UNIQUE failure.
56
+ */
57
+ findSlugConflict(slug: string, ownerDid: string, declPath: string): Promise<string | null>;
58
+ /** Reconcile write — INSERT … ON CONFLICT(owner_did, decl_path) DO UPDATE. */
59
+ upsert(row: ShareRow): Promise<void>;
60
+ /** Reconcile delete — owner-scoped (never touches a sibling owner's row). */
61
+ deleteByOwnerAndDeclPath(ownerDid: string, declPath: string): Promise<void>;
62
+ }
63
+ //#endregion
64
+ export { ShareEntry, ShareRow, ShareStore, rowToEntry };
65
+ //# sourceMappingURL=share-store.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-store.d.mts","names":[],"sources":["../src/share-store.ts"],"mappings":";;;UAyBiB,UAAA;EACf,EAAA;EACA,QAAA;EACA,UAAA;EACA,QAAA;EACA,IAAA;EACA,IAAA;EACA,MAAA;EACA,OAAA;EACA,MAAA,EAAQ,gBAAA;EACR,SAAA;EACA,SAAA;AAAA;AAAA,UAKe,QAAA;EACf,EAAA;EACA,SAAA;EACA,WAAA;EACA,SAAA;EACA,IAAA;EACA,IAAA;EACA,MAAA;EACA,QAAA;EACA,WAAA;EACA,UAAA;EACA,UAAA;AAAA;AA4BF;AAAA,iBAxBgB,UAAA,CAAW,GAAA,EAAK,QAAA,GAAW,UAAA;AAAA,UAwB1B,UAAA;EAEA;EAAf,WAAA,IAAe,OAAA;EAGc;EAA7B,aAAA,CAAc,IAAA,WAAe,OAAA,CAAQ,UAAA;EAGN;EAA/B,WAAA,CAAY,QAAA,WAAmB,OAAA,CAAQ,UAAA;EAGgB;EAAvD,cAAA,CAAe,QAAA,UAAkB,WAAA,WAAsB,OAAA,CAAQ,UAAA;EAGX;EAApD,kBAAA,CAAmB,QAAA,UAAkB,IAAA,WAAe,OAAA,CAAQ,UAAA;EAGA;EAA5D,sBAAA,CAAuB,QAAA,UAAkB,QAAA,WAAmB,OAAA,CAAQ,UAAA;EAmBA;;;;EAbpE,kBAAA,CACE,QAAA,UACA,QAAA,UACA,UAAA,WACC,OAAA;EAekE;;;;;;;EANrE,gBAAA,CAAiB,IAAA,UAAc,QAAA,UAAkB,QAAA,WAAmB,OAAA;EA5BxD;EA+BZ,MAAA,CAAO,GAAA,EAAK,QAAA,GAAW,OAAA;EA/BgB;EAkCvC,wBAAA,CAAyB,QAAA,UAAkB,QAAA,WAAmB,OAAA;AAAA"}
@@ -0,0 +1,25 @@
1
+ //#region src/share-store.ts
2
+ /** Map a raw storage row to a public ShareEntry (malformed config_json → {}). */
3
+ function rowToEntry(row) {
4
+ let config = {};
5
+ try {
6
+ config = JSON.parse(row.config_json);
7
+ } catch {}
8
+ return {
9
+ id: row.id,
10
+ ownerDid: row.owner_did,
11
+ sourcePath: row.source_path,
12
+ declPath: row.decl_path,
13
+ slug: row.slug,
14
+ kind: row.kind,
15
+ status: row.status,
16
+ declCid: row.decl_cid ?? void 0,
17
+ config,
18
+ createdAt: row.created_at,
19
+ updatedAt: row.updated_at
20
+ };
21
+ }
22
+
23
+ //#endregion
24
+ export { rowToEntry };
25
+ //# sourceMappingURL=share-store.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-store.mjs","names":[],"sources":["../src/share-store.ts"],"sourcesContent":["/**\n * Phase 0.2 — ShareStore: storage-agnostic contract for the `shares` table.\n *\n * The `ShareResolver` (share-resolve.ts) is a storage-agnostic orchestrator\n * that holds the reconcile business logic (parse / derive / slug + nesting\n * conflict detection / kind auto-detect) and delegates ALL table access to a\n * `ShareStore`. This mirrors the repo's existing `DIDSpaceResolver +\n * KeyValueStore` precedent: one interface, hand-written siblings per backend\n * (`D1ShareStore` for Cloudflare D1, `SqliteShareStore` for the Node daemon),\n * no adapter shim.\n *\n * Owner-scoped identity: every mutating / point-lookup method takes `ownerDid`\n * because the identity key is the composite `(owner_did, decl_path)` — two\n * owners legitimately share the same relative `decl_path`. `slug` is global, so\n * `resolveBySlug` (public serving hot path) is the only caller-less method.\n *\n * `reconcileAll` (offline full rebuild) is intentionally NOT here — it scans the\n * `entries` table (TreeIndex domain) and needs an ObjectStore, so it stays a\n * D1-only concern in `D1ShareReconciler`.\n */\n\nimport type { ShareDeclaration } from \"./share-declaration.js\";\n\n// ─── Public entry (camelCase, what callers consume) ─────────────────────────────\n\nexport interface ShareEntry {\n id: string;\n ownerDid: string;\n sourcePath: string;\n declPath: string;\n slug: string;\n kind: \"raw\" | \"web\";\n status: \"active\" | \"revoked\";\n declCid?: string;\n config: ShareDeclaration;\n createdAt: number;\n updatedAt: number;\n}\n\n// ─── Storage row (snake_case D1/sqlite column names) ────────────────────────────\n\nexport interface ShareRow {\n id: string;\n owner_did: string;\n source_path: string;\n decl_path: string;\n slug: string;\n kind: \"raw\" | \"web\";\n status: \"active\" | \"revoked\";\n decl_cid: string | null;\n config_json: string;\n created_at: number;\n updated_at: number;\n}\n\n/** Map a raw storage row to a public ShareEntry (malformed config_json → {}). */\nexport function rowToEntry(row: ShareRow): ShareEntry {\n let config: ShareDeclaration = {};\n try {\n config = JSON.parse(row.config_json) as ShareDeclaration;\n } catch {\n // malformed config_json — treat as empty declaration\n }\n return {\n id: row.id,\n ownerDid: row.owner_did,\n sourcePath: row.source_path,\n declPath: row.decl_path,\n slug: row.slug,\n kind: row.kind,\n status: row.status,\n declCid: row.decl_cid ?? undefined,\n config,\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n}\n\n// ─── ShareStore contract ────────────────────────────────────────────────────────\n\nexport interface ShareStore {\n /** Create the `shares` table + indices if missing (idempotent). */\n ensureTable(): Promise<void>;\n\n /** Public serving hot path — slug is global, no owner scope. */\n resolveBySlug(slug: string): Promise<ShareEntry | null>;\n\n /** `.shares/` listing — active, non-unlisted, newest first. */\n listByOwner(ownerDid: string): Promise<ShareEntry[]>;\n\n /** `instances/{iid}/.shares` listing — active, non-unlisted, newest first. */\n listByInstance(ownerDid: string, instanceDid: string): Promise<ShareEntry[]>;\n\n /** `.shares/{slug}` read — owner-scoped (cross-owner read returns null). */\n readByOwnerAndSlug(ownerDid: string, slug: string): Promise<ShareEntry | null>;\n\n /** Reconcile: look up the existing row for this owner's decl path. */\n findByOwnerAndDeclPath(ownerDid: string, declPath: string): Promise<ShareEntry | null>;\n\n /**\n * Nested-share detection — return the conflicting decl_path (a parent or\n * child share owned by the SAME owner whose sourcePath overlaps), or null.\n */\n findNestedConflict(\n ownerDid: string,\n declPath: string,\n sourcePath: string,\n ): Promise<string | null>;\n\n /**\n * Slug uniqueness check (slug is global). Return the conflicting decl_path,\n * or null. The row identified by `(ownerDid, declPath)` is excluded BY\n * IDENTITY — never by decl_path alone, else a sibling owner's same-decl_path\n * row would be wrongly excluded and let the slug collision slip past the\n * pre-io dry-run into a post-io global-UNIQUE failure.\n */\n findSlugConflict(slug: string, ownerDid: string, declPath: string): Promise<string | null>;\n\n /** Reconcile write — INSERT … ON CONFLICT(owner_did, decl_path) DO UPDATE. */\n upsert(row: ShareRow): Promise<void>;\n\n /** Reconcile delete — owner-scoped (never touches a sibling owner's row). */\n deleteByOwnerAndDeclPath(ownerDid: string, declPath: string): Promise<void>;\n}\n"],"mappings":";;AAwDA,SAAgB,WAAW,KAA2B;CACpD,IAAI,SAA2B,EAAE;AACjC,KAAI;AACF,WAAS,KAAK,MAAM,IAAI,YAAY;SAC9B;AAGR,QAAO;EACL,IAAI,IAAI;EACR,UAAU,IAAI;EACd,YAAY,IAAI;EAChB,UAAU,IAAI;EACd,MAAM,IAAI;EACV,MAAM,IAAI;EACV,QAAQ,IAAI;EACZ,SAAS,IAAI,YAAY;EACzB;EACA,WAAW,IAAI;EACf,WAAW,IAAI;EAChB"}
@@ -0,0 +1,102 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let ufo = require("ufo");
3
+
4
+ //#region src/share-virtual-path.ts
5
+ /** Strip leading and trailing slashes — returns bare path (e.g. "instances/z1abc/.shares"). */
6
+ function normalisePath(path) {
7
+ return (0, ufo.withoutLeadingSlash)((0, ufo.withoutTrailingSlash)(path));
8
+ }
9
+ /**
10
+ * Match an AFS path to a SharesVirtualMatch variant.
11
+ *
12
+ * Matching rules (after leading/trailing slash stripping):
13
+ * ".shares" → { kind: "owner-list" }
14
+ * ".shares/{slug}" → { kind: "owner-read", slug }
15
+ * "instances/{iid}/.shares" → { kind: "instance-list", instanceDid: iid }
16
+ * "instances/{iid}/.shares/{s}" → { kind: "instance-read", instanceDid: iid, slug: s }
17
+ * anything else → null
18
+ */
19
+ function matchSharesVirtualPath(path) {
20
+ const norm = normalisePath(path);
21
+ if (norm === ".shares") return { kind: "owner-list" };
22
+ if (norm.startsWith(".shares/")) {
23
+ const slug = norm.slice(8);
24
+ if (slug && !slug.includes("/")) return {
25
+ kind: "owner-read",
26
+ slug
27
+ };
28
+ return null;
29
+ }
30
+ const instanceMatch = /^instances\/([^/]+)\/.shares(\/(.*))?$/.exec(norm);
31
+ if (instanceMatch) {
32
+ const instanceDid = instanceMatch[1];
33
+ const afterShares = instanceMatch[3] ?? "";
34
+ if (!afterShares) return {
35
+ kind: "instance-list",
36
+ instanceDid
37
+ };
38
+ if (!afterShares.includes("/")) return {
39
+ kind: "instance-read",
40
+ instanceDid,
41
+ slug: afterShares
42
+ };
43
+ return null;
44
+ }
45
+ return null;
46
+ }
47
+ var ShareVirtualHandler = class {
48
+ constructor(resolver, ownerDid) {
49
+ this.resolver = resolver;
50
+ this.ownerDid = ownerDid;
51
+ }
52
+ /**
53
+ * Serve a list request for a matched virtual path.
54
+ * Returns an empty list for null matches.
55
+ *
56
+ * Filter rules:
57
+ * - visibility: "unlisted" → excluded from list (but accessible via read)
58
+ * - status: "revoked" → excluded from list
59
+ */
60
+ async list(match) {
61
+ if (!match) return { list: [] };
62
+ if (match.kind === "owner-list") return { list: (await this.resolver.listByOwner(this.ownerDid)).map((e) => buildShareEntry(`/.shares/${e.slug}`, e)) };
63
+ if (match.kind === "instance-list") return { list: (await this.resolver.listByInstance(this.ownerDid, match.instanceDid)).map((e) => buildShareEntry(`/instances/${match.instanceDid}/.shares/${e.slug}`, e)) };
64
+ return { list: [] };
65
+ }
66
+ /**
67
+ * Serve a read request for a matched virtual path.
68
+ * Returns null when the match is null or the slug is not found.
69
+ * Note: read does NOT filter by visibility — unlisted shares are accessible by slug.
70
+ */
71
+ async read(match) {
72
+ if (!match) return null;
73
+ if (match.kind === "owner-read") {
74
+ const entry = await this.resolver.readShare(this.ownerDid, match.slug);
75
+ if (!entry) return null;
76
+ return { data: buildShareEntry(`/.shares/${entry.slug}`, entry) };
77
+ }
78
+ if (match.kind === "instance-read") {
79
+ const entry = await this.resolver.readShare(this.ownerDid, match.slug);
80
+ if (!entry) return null;
81
+ const expectedPrefix = `instances/${match.instanceDid}/`;
82
+ if (!entry.sourcePath.startsWith(expectedPrefix)) return null;
83
+ return { data: buildShareEntry(`/instances/${match.instanceDid}/.shares/${entry.slug}`, entry) };
84
+ }
85
+ return null;
86
+ }
87
+ };
88
+ /** Serialize a ShareEntry to an AFSEntry with JSON content and kind "did-space:share". */
89
+ function buildShareEntry(path, shareEntry) {
90
+ return {
91
+ id: path,
92
+ path,
93
+ content: JSON.stringify(shareEntry),
94
+ meta: { kind: "did-space:share" },
95
+ createdAt: new Date(shareEntry.createdAt),
96
+ updatedAt: new Date(shareEntry.updatedAt)
97
+ };
98
+ }
99
+
100
+ //#endregion
101
+ exports.ShareVirtualHandler = ShareVirtualHandler;
102
+ exports.matchSharesVirtualPath = matchSharesVirtualPath;
@@ -0,0 +1,101 @@
1
+ import { withoutLeadingSlash, withoutTrailingSlash } from "ufo";
2
+
3
+ //#region src/share-virtual-path.ts
4
+ /** Strip leading and trailing slashes — returns bare path (e.g. "instances/z1abc/.shares"). */
5
+ function normalisePath(path) {
6
+ return withoutLeadingSlash(withoutTrailingSlash(path));
7
+ }
8
+ /**
9
+ * Match an AFS path to a SharesVirtualMatch variant.
10
+ *
11
+ * Matching rules (after leading/trailing slash stripping):
12
+ * ".shares" → { kind: "owner-list" }
13
+ * ".shares/{slug}" → { kind: "owner-read", slug }
14
+ * "instances/{iid}/.shares" → { kind: "instance-list", instanceDid: iid }
15
+ * "instances/{iid}/.shares/{s}" → { kind: "instance-read", instanceDid: iid, slug: s }
16
+ * anything else → null
17
+ */
18
+ function matchSharesVirtualPath(path) {
19
+ const norm = normalisePath(path);
20
+ if (norm === ".shares") return { kind: "owner-list" };
21
+ if (norm.startsWith(".shares/")) {
22
+ const slug = norm.slice(8);
23
+ if (slug && !slug.includes("/")) return {
24
+ kind: "owner-read",
25
+ slug
26
+ };
27
+ return null;
28
+ }
29
+ const instanceMatch = /^instances\/([^/]+)\/.shares(\/(.*))?$/.exec(norm);
30
+ if (instanceMatch) {
31
+ const instanceDid = instanceMatch[1];
32
+ const afterShares = instanceMatch[3] ?? "";
33
+ if (!afterShares) return {
34
+ kind: "instance-list",
35
+ instanceDid
36
+ };
37
+ if (!afterShares.includes("/")) return {
38
+ kind: "instance-read",
39
+ instanceDid,
40
+ slug: afterShares
41
+ };
42
+ return null;
43
+ }
44
+ return null;
45
+ }
46
+ var ShareVirtualHandler = class {
47
+ constructor(resolver, ownerDid) {
48
+ this.resolver = resolver;
49
+ this.ownerDid = ownerDid;
50
+ }
51
+ /**
52
+ * Serve a list request for a matched virtual path.
53
+ * Returns an empty list for null matches.
54
+ *
55
+ * Filter rules:
56
+ * - visibility: "unlisted" → excluded from list (but accessible via read)
57
+ * - status: "revoked" → excluded from list
58
+ */
59
+ async list(match) {
60
+ if (!match) return { list: [] };
61
+ if (match.kind === "owner-list") return { list: (await this.resolver.listByOwner(this.ownerDid)).map((e) => buildShareEntry(`/.shares/${e.slug}`, e)) };
62
+ if (match.kind === "instance-list") return { list: (await this.resolver.listByInstance(this.ownerDid, match.instanceDid)).map((e) => buildShareEntry(`/instances/${match.instanceDid}/.shares/${e.slug}`, e)) };
63
+ return { list: [] };
64
+ }
65
+ /**
66
+ * Serve a read request for a matched virtual path.
67
+ * Returns null when the match is null or the slug is not found.
68
+ * Note: read does NOT filter by visibility — unlisted shares are accessible by slug.
69
+ */
70
+ async read(match) {
71
+ if (!match) return null;
72
+ if (match.kind === "owner-read") {
73
+ const entry = await this.resolver.readShare(this.ownerDid, match.slug);
74
+ if (!entry) return null;
75
+ return { data: buildShareEntry(`/.shares/${entry.slug}`, entry) };
76
+ }
77
+ if (match.kind === "instance-read") {
78
+ const entry = await this.resolver.readShare(this.ownerDid, match.slug);
79
+ if (!entry) return null;
80
+ const expectedPrefix = `instances/${match.instanceDid}/`;
81
+ if (!entry.sourcePath.startsWith(expectedPrefix)) return null;
82
+ return { data: buildShareEntry(`/instances/${match.instanceDid}/.shares/${entry.slug}`, entry) };
83
+ }
84
+ return null;
85
+ }
86
+ };
87
+ /** Serialize a ShareEntry to an AFSEntry with JSON content and kind "did-space:share". */
88
+ function buildShareEntry(path, shareEntry) {
89
+ return {
90
+ id: path,
91
+ path,
92
+ content: JSON.stringify(shareEntry),
93
+ meta: { kind: "did-space:share" },
94
+ createdAt: new Date(shareEntry.createdAt),
95
+ updatedAt: new Date(shareEntry.updatedAt)
96
+ };
97
+ }
98
+
99
+ //#endregion
100
+ export { ShareVirtualHandler, matchSharesVirtualPath };
101
+ //# sourceMappingURL=share-virtual-path.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-virtual-path.mjs","names":[],"sources":["../src/share-virtual-path.ts"],"sourcesContent":["/**\n * Phase 0.5 — ShareVirtualHandler + `.shares/` virtual path routing.\n *\n * matchSharesVirtualPath: maps an AFS path to one of 4 match variants\n * (owner-list, owner-read, instance-list, instance-read) or null.\n *\n * ShareVirtualHandler: uses ShareResolver to serve list/read for virtual views.\n */\n\nimport type { AFSEntry, AFSEntryMetadata } from \"@aigne/afs\";\nimport { withoutLeadingSlash, withoutTrailingSlash } from \"ufo\";\nimport type { ShareEntry, ShareResolver } from \"./share-resolve.js\";\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\nexport type SharesVirtualMatch =\n | { kind: \"owner-list\" }\n | { kind: \"owner-read\"; slug: string }\n | { kind: \"instance-list\"; instanceDid: string }\n | { kind: \"instance-read\"; instanceDid: string; slug: string }\n | null;\n\n// ─── matchSharesVirtualPath ───────────────────────────────────────────────────\n\n/** Strip leading and trailing slashes — returns bare path (e.g. \"instances/z1abc/.shares\"). */\nfunction normalisePath(path: string): string {\n return withoutLeadingSlash(withoutTrailingSlash(path));\n}\n\n/**\n * Match an AFS path to a SharesVirtualMatch variant.\n *\n * Matching rules (after leading/trailing slash stripping):\n * \".shares\" → { kind: \"owner-list\" }\n * \".shares/{slug}\" → { kind: \"owner-read\", slug }\n * \"instances/{iid}/.shares\" → { kind: \"instance-list\", instanceDid: iid }\n * \"instances/{iid}/.shares/{s}\" → { kind: \"instance-read\", instanceDid: iid, slug: s }\n * anything else → null\n */\nexport function matchSharesVirtualPath(path: string): SharesVirtualMatch {\n const norm = normalisePath(path);\n\n // Owner-scope: \".shares\" or \".shares/{slug}\"\n if (norm === \".shares\") {\n return { kind: \"owner-list\" };\n }\n if (norm.startsWith(\".shares/\")) {\n const slug = norm.slice(\".shares/\".length);\n // slug must be non-empty and must not contain any \"/\" (no nested paths)\n if (slug && !slug.includes(\"/\")) {\n return { kind: \"owner-read\", slug };\n }\n return null;\n }\n\n // Instance-scope: \"instances/{iid}/.shares\" or \"instances/{iid}/.shares/{slug}\"\n const instanceMatch = /^instances\\/([^/]+)\\/.shares(\\/(.*))?$/.exec(norm);\n if (instanceMatch) {\n const instanceDid = instanceMatch[1]!;\n const afterShares = instanceMatch[3] ?? \"\";\n if (!afterShares) {\n return { kind: \"instance-list\", instanceDid };\n }\n // afterShares must not contain \"/\"\n if (!afterShares.includes(\"/\")) {\n return { kind: \"instance-read\", instanceDid, slug: afterShares };\n }\n return null;\n }\n\n return null;\n}\n\n// ─── ShareVirtualHandler ──────────────────────────────────────────────────────\n\nexport class ShareVirtualHandler {\n constructor(\n private readonly resolver: ShareResolver,\n private readonly ownerDid: string,\n ) {}\n\n /**\n * Serve a list request for a matched virtual path.\n * Returns an empty list for null matches.\n *\n * Filter rules:\n * - visibility: \"unlisted\" → excluded from list (but accessible via read)\n * - status: \"revoked\" → excluded from list\n */\n async list(match: SharesVirtualMatch): Promise<{ list: AFSEntry[] }> {\n if (!match) return { list: [] };\n\n if (match.kind === \"owner-list\") {\n const entries = await this.resolver.listByOwner(this.ownerDid);\n return {\n list: entries.map((e) => buildShareEntry(`/.shares/${e.slug}`, e)),\n };\n }\n\n if (match.kind === \"instance-list\") {\n const entries = await this.resolver.listByInstance(this.ownerDid, match.instanceDid);\n return {\n list: entries.map((e) =>\n buildShareEntry(`/instances/${match.instanceDid}/.shares/${e.slug}`, e),\n ),\n };\n }\n\n // owner-read and instance-read are not list operations\n return { list: [] };\n }\n\n /**\n * Serve a read request for a matched virtual path.\n * Returns null when the match is null or the slug is not found.\n * Note: read does NOT filter by visibility — unlisted shares are accessible by slug.\n */\n async read(match: SharesVirtualMatch): Promise<{ data: AFSEntry } | null> {\n if (!match) return null;\n\n if (match.kind === \"owner-read\") {\n const entry = await this.resolver.readShare(this.ownerDid, match.slug);\n if (!entry) return null;\n return { data: buildShareEntry(`/.shares/${entry.slug}`, entry) };\n }\n\n if (match.kind === \"instance-read\") {\n // Verify slug belongs to this instance: source_path must be under instances/{iid}/\n const entry = await this.resolver.readShare(this.ownerDid, match.slug);\n if (!entry) return null;\n const expectedPrefix = `instances/${match.instanceDid}/`;\n if (!entry.sourcePath.startsWith(expectedPrefix)) return null;\n return {\n data: buildShareEntry(`/instances/${match.instanceDid}/.shares/${entry.slug}`, entry),\n };\n }\n\n // owner-list and instance-list are not read operations\n return null;\n }\n}\n\n// ─── Helpers ──────────────────────────────────────────────────────────────────\n\n/** Serialize a ShareEntry to an AFSEntry with JSON content and kind \"did-space:share\". */\nfunction buildShareEntry(path: string, shareEntry: ShareEntry): AFSEntry {\n return {\n id: path,\n path,\n content: JSON.stringify(shareEntry),\n meta: { kind: \"did-space:share\" } as AFSEntryMetadata,\n createdAt: new Date(shareEntry.createdAt),\n updatedAt: new Date(shareEntry.updatedAt),\n };\n}\n"],"mappings":";;;;AAyBA,SAAS,cAAc,MAAsB;AAC3C,QAAO,oBAAoB,qBAAqB,KAAK,CAAC;;;;;;;;;;;;AAaxD,SAAgB,uBAAuB,MAAkC;CACvE,MAAM,OAAO,cAAc,KAAK;AAGhC,KAAI,SAAS,UACX,QAAO,EAAE,MAAM,cAAc;AAE/B,KAAI,KAAK,WAAW,WAAW,EAAE;EAC/B,MAAM,OAAO,KAAK,MAAM,EAAkB;AAE1C,MAAI,QAAQ,CAAC,KAAK,SAAS,IAAI,CAC7B,QAAO;GAAE,MAAM;GAAc;GAAM;AAErC,SAAO;;CAIT,MAAM,gBAAgB,yCAAyC,KAAK,KAAK;AACzE,KAAI,eAAe;EACjB,MAAM,cAAc,cAAc;EAClC,MAAM,cAAc,cAAc,MAAM;AACxC,MAAI,CAAC,YACH,QAAO;GAAE,MAAM;GAAiB;GAAa;AAG/C,MAAI,CAAC,YAAY,SAAS,IAAI,CAC5B,QAAO;GAAE,MAAM;GAAiB;GAAa,MAAM;GAAa;AAElE,SAAO;;AAGT,QAAO;;AAKT,IAAa,sBAAb,MAAiC;CAC/B,YACE,AAAiB,UACjB,AAAiB,UACjB;EAFiB;EACA;;;;;;;;;;CAWnB,MAAM,KAAK,OAA0D;AACnE,MAAI,CAAC,MAAO,QAAO,EAAE,MAAM,EAAE,EAAE;AAE/B,MAAI,MAAM,SAAS,aAEjB,QAAO,EACL,OAFc,MAAM,KAAK,SAAS,YAAY,KAAK,SAAS,EAE9C,KAAK,MAAM,gBAAgB,YAAY,EAAE,QAAQ,EAAE,CAAC,EACnE;AAGH,MAAI,MAAM,SAAS,gBAEjB,QAAO,EACL,OAFc,MAAM,KAAK,SAAS,eAAe,KAAK,UAAU,MAAM,YAAY,EAEpE,KAAK,MACjB,gBAAgB,cAAc,MAAM,YAAY,WAAW,EAAE,QAAQ,EAAE,CACxE,EACF;AAIH,SAAO,EAAE,MAAM,EAAE,EAAE;;;;;;;CAQrB,MAAM,KAAK,OAA+D;AACxE,MAAI,CAAC,MAAO,QAAO;AAEnB,MAAI,MAAM,SAAS,cAAc;GAC/B,MAAM,QAAQ,MAAM,KAAK,SAAS,UAAU,KAAK,UAAU,MAAM,KAAK;AACtE,OAAI,CAAC,MAAO,QAAO;AACnB,UAAO,EAAE,MAAM,gBAAgB,YAAY,MAAM,QAAQ,MAAM,EAAE;;AAGnE,MAAI,MAAM,SAAS,iBAAiB;GAElC,MAAM,QAAQ,MAAM,KAAK,SAAS,UAAU,KAAK,UAAU,MAAM,KAAK;AACtE,OAAI,CAAC,MAAO,QAAO;GACnB,MAAM,iBAAiB,aAAa,MAAM,YAAY;AACtD,OAAI,CAAC,MAAM,WAAW,WAAW,eAAe,CAAE,QAAO;AACzD,UAAO,EACL,MAAM,gBAAgB,cAAc,MAAM,YAAY,WAAW,MAAM,QAAQ,MAAM,EACtF;;AAIH,SAAO;;;;AAOX,SAAS,gBAAgB,MAAc,YAAkC;AACvE,QAAO;EACL,IAAI;EACJ;EACA,SAAS,KAAK,UAAU,WAAW;EACnC,MAAM,EAAE,MAAM,mBAAmB;EACjC,WAAW,IAAI,KAAK,WAAW,UAAU;EACzC,WAAW,IAAI,KAAK,WAAW,UAAU;EAC1C"}
@@ -0,0 +1,54 @@
1
+ const require_did_utils = require('./did-utils.cjs');
2
+ const require_local = require('./local.cjs');
3
+
4
+ //#region src/space-resolver.ts
5
+ var LocalSpaceResolver = class {
6
+ /**
7
+ * Per-user DID Spaces this resolver constructed, keyed by normalized userDid.
8
+ * The installer/owner space is intentionally NOT tracked here — its lifecycle
9
+ * belongs to whoever constructed and passed it in. Closed via `close()`.
10
+ */
11
+ ownedSpaces = /* @__PURE__ */ new Map();
12
+ /**
13
+ * @param installerSpace the installer/owner DIDSpace (its share-resolver
14
+ * factory is late-injected by the daemon via setShareResolverFactory).
15
+ * @param shareResolverFactory share-out Phase 3: threaded into every sibling
16
+ * `new DIDSpace(...)` so a caller space's `.share` writes reach the SAME
17
+ * daemon-global store (same factory closure) as the installer space.
18
+ * @param scopeHmacSecret scope de-id (README §5.3): threaded into every sibling
19
+ * `new DIDSpace(...)` so each caller space derives the same storage scope the
20
+ * installer space does. The installer space is constructed with the SAME
21
+ * secret by the daemon. Undefined → de-id off (plaintext dirs, back-compat).
22
+ */
23
+ constructor(installerSpace, shareResolverFactory, scopeHmacSecret) {
24
+ this.installerSpace = installerSpace;
25
+ this.shareResolverFactory = shareResolverFactory;
26
+ this.scopeHmacSecret = scopeHmacSecret;
27
+ }
28
+ async resolveInstallerSpace() {
29
+ return this.installerSpace;
30
+ }
31
+ async resolveUserSpace(userDid) {
32
+ require_did_utils.validateId(userDid);
33
+ const key = require_did_utils.normalizeId(userDid);
34
+ if (key === this.installerSpace.config.userDid) return this.installerSpace;
35
+ const cached = this.ownedSpaces.get(key);
36
+ if (cached) return cached;
37
+ const space = new require_local.DIDSpace({
38
+ rootPath: this.installerSpace.config.rootPath,
39
+ userDid,
40
+ shareResolverFactory: this.shareResolverFactory,
41
+ scopeHmacSecret: this.scopeHmacSecret
42
+ });
43
+ this.ownedSpaces.set(key, space);
44
+ return space;
45
+ }
46
+ /** Close every per-user space this resolver created (call on daemon shutdown). */
47
+ close() {
48
+ for (const space of this.ownedSpaces.values()) space.close();
49
+ this.ownedSpaces.clear();
50
+ }
51
+ };
52
+
53
+ //#endregion
54
+ exports.LocalSpaceResolver = LocalSpaceResolver;
@@ -0,0 +1,34 @@
1
+ import { DIDSpace, ShareResolverFactory } from "./local.cjs";
2
+ import { DIDSpaceLike, SpaceResolver } from "@aigne/afs";
3
+
4
+ //#region src/space-resolver.d.ts
5
+ declare class LocalSpaceResolver implements SpaceResolver {
6
+ private readonly installerSpace;
7
+ private readonly shareResolverFactory?;
8
+ private readonly scopeHmacSecret?;
9
+ /**
10
+ * Per-user DID Spaces this resolver constructed, keyed by normalized userDid.
11
+ * The installer/owner space is intentionally NOT tracked here — its lifecycle
12
+ * belongs to whoever constructed and passed it in. Closed via `close()`.
13
+ */
14
+ private readonly ownedSpaces;
15
+ /**
16
+ * @param installerSpace the installer/owner DIDSpace (its share-resolver
17
+ * factory is late-injected by the daemon via setShareResolverFactory).
18
+ * @param shareResolverFactory share-out Phase 3: threaded into every sibling
19
+ * `new DIDSpace(...)` so a caller space's `.share` writes reach the SAME
20
+ * daemon-global store (same factory closure) as the installer space.
21
+ * @param scopeHmacSecret scope de-id (README §5.3): threaded into every sibling
22
+ * `new DIDSpace(...)` so each caller space derives the same storage scope the
23
+ * installer space does. The installer space is constructed with the SAME
24
+ * secret by the daemon. Undefined → de-id off (plaintext dirs, back-compat).
25
+ */
26
+ constructor(installerSpace: DIDSpace, shareResolverFactory?: ShareResolverFactory | undefined, scopeHmacSecret?: Uint8Array | undefined);
27
+ resolveInstallerSpace(): Promise<DIDSpaceLike>;
28
+ resolveUserSpace(userDid: string): Promise<DIDSpaceLike>;
29
+ /** Close every per-user space this resolver created (call on daemon shutdown). */
30
+ close(): void;
31
+ }
32
+ //#endregion
33
+ export { LocalSpaceResolver };
34
+ //# sourceMappingURL=space-resolver.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-resolver.d.cts","names":[],"sources":["../src/space-resolver.ts"],"mappings":";;;;cAsBa,kBAAA,YAA8B,aAAA;EAAA,iBAoBtB,cAAA;EAAA,iBACA,oBAAA;EAAA,iBACA,eAAA;EAFgB;;;;;EAAA,iBAdlB,WAAA;EAmBX;;;;;;;;;;;cALa,cAAA,EAAgB,QAAA,EAChB,oBAAA,GAAuB,oBAAA,cACvB,eAAA,GAAkB,UAAA;EAG/B,qBAAA,CAAA,GAAyB,OAAA,CAAQ,YAAA;EAIjC,gBAAA,CAAiB,OAAA,WAAkB,OAAA,CAAQ,YAAA;;EA2BjD,KAAA,CAAA;AAAA"}
@@ -0,0 +1,34 @@
1
+ import { DIDSpace, ShareResolverFactory } from "./local.mjs";
2
+ import { DIDSpaceLike, SpaceResolver } from "@aigne/afs";
3
+
4
+ //#region src/space-resolver.d.ts
5
+ declare class LocalSpaceResolver implements SpaceResolver {
6
+ private readonly installerSpace;
7
+ private readonly shareResolverFactory?;
8
+ private readonly scopeHmacSecret?;
9
+ /**
10
+ * Per-user DID Spaces this resolver constructed, keyed by normalized userDid.
11
+ * The installer/owner space is intentionally NOT tracked here — its lifecycle
12
+ * belongs to whoever constructed and passed it in. Closed via `close()`.
13
+ */
14
+ private readonly ownedSpaces;
15
+ /**
16
+ * @param installerSpace the installer/owner DIDSpace (its share-resolver
17
+ * factory is late-injected by the daemon via setShareResolverFactory).
18
+ * @param shareResolverFactory share-out Phase 3: threaded into every sibling
19
+ * `new DIDSpace(...)` so a caller space's `.share` writes reach the SAME
20
+ * daemon-global store (same factory closure) as the installer space.
21
+ * @param scopeHmacSecret scope de-id (README §5.3): threaded into every sibling
22
+ * `new DIDSpace(...)` so each caller space derives the same storage scope the
23
+ * installer space does. The installer space is constructed with the SAME
24
+ * secret by the daemon. Undefined → de-id off (plaintext dirs, back-compat).
25
+ */
26
+ constructor(installerSpace: DIDSpace, shareResolverFactory?: ShareResolverFactory | undefined, scopeHmacSecret?: Uint8Array | undefined);
27
+ resolveInstallerSpace(): Promise<DIDSpaceLike>;
28
+ resolveUserSpace(userDid: string): Promise<DIDSpaceLike>;
29
+ /** Close every per-user space this resolver created (call on daemon shutdown). */
30
+ close(): void;
31
+ }
32
+ //#endregion
33
+ export { LocalSpaceResolver };
34
+ //# sourceMappingURL=space-resolver.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-resolver.d.mts","names":[],"sources":["../src/space-resolver.ts"],"mappings":";;;;cAsBa,kBAAA,YAA8B,aAAA;EAAA,iBAoBtB,cAAA;EAAA,iBACA,oBAAA;EAAA,iBACA,eAAA;EAFgB;;;;;EAAA,iBAdlB,WAAA;EAmBX;;;;;;;;;;;cALa,cAAA,EAAgB,QAAA,EAChB,oBAAA,GAAuB,oBAAA,cACvB,eAAA,GAAkB,UAAA;EAG/B,qBAAA,CAAA,GAAyB,OAAA,CAAQ,YAAA;EAIjC,gBAAA,CAAiB,OAAA,WAAkB,OAAA,CAAQ,YAAA;;EA2BjD,KAAA,CAAA;AAAA"}
@@ -0,0 +1,55 @@
1
+ import { normalizeId, validateId } from "./did-utils.mjs";
2
+ import { DIDSpace } from "./local.mjs";
3
+
4
+ //#region src/space-resolver.ts
5
+ var LocalSpaceResolver = class {
6
+ /**
7
+ * Per-user DID Spaces this resolver constructed, keyed by normalized userDid.
8
+ * The installer/owner space is intentionally NOT tracked here — its lifecycle
9
+ * belongs to whoever constructed and passed it in. Closed via `close()`.
10
+ */
11
+ ownedSpaces = /* @__PURE__ */ new Map();
12
+ /**
13
+ * @param installerSpace the installer/owner DIDSpace (its share-resolver
14
+ * factory is late-injected by the daemon via setShareResolverFactory).
15
+ * @param shareResolverFactory share-out Phase 3: threaded into every sibling
16
+ * `new DIDSpace(...)` so a caller space's `.share` writes reach the SAME
17
+ * daemon-global store (same factory closure) as the installer space.
18
+ * @param scopeHmacSecret scope de-id (README §5.3): threaded into every sibling
19
+ * `new DIDSpace(...)` so each caller space derives the same storage scope the
20
+ * installer space does. The installer space is constructed with the SAME
21
+ * secret by the daemon. Undefined → de-id off (plaintext dirs, back-compat).
22
+ */
23
+ constructor(installerSpace, shareResolverFactory, scopeHmacSecret) {
24
+ this.installerSpace = installerSpace;
25
+ this.shareResolverFactory = shareResolverFactory;
26
+ this.scopeHmacSecret = scopeHmacSecret;
27
+ }
28
+ async resolveInstallerSpace() {
29
+ return this.installerSpace;
30
+ }
31
+ async resolveUserSpace(userDid) {
32
+ validateId(userDid);
33
+ const key = normalizeId(userDid);
34
+ if (key === this.installerSpace.config.userDid) return this.installerSpace;
35
+ const cached = this.ownedSpaces.get(key);
36
+ if (cached) return cached;
37
+ const space = new DIDSpace({
38
+ rootPath: this.installerSpace.config.rootPath,
39
+ userDid,
40
+ shareResolverFactory: this.shareResolverFactory,
41
+ scopeHmacSecret: this.scopeHmacSecret
42
+ });
43
+ this.ownedSpaces.set(key, space);
44
+ return space;
45
+ }
46
+ /** Close every per-user space this resolver created (call on daemon shutdown). */
47
+ close() {
48
+ for (const space of this.ownedSpaces.values()) space.close();
49
+ this.ownedSpaces.clear();
50
+ }
51
+ };
52
+
53
+ //#endregion
54
+ export { LocalSpaceResolver };
55
+ //# sourceMappingURL=space-resolver.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-resolver.mjs","names":[],"sources":["../src/space-resolver.ts"],"sourcesContent":["/**\n * LocalSpaceResolver — the local (filesystem) implementation of the core\n * `SpaceResolver` contract (design.md §6.6/§6.7).\n *\n * Separates \"which space backs this identity\" from \"slice within a space\"\n * (`getInstanceSpace`). The local runtime can host many users' spaces as\n * SIBLING roots under one `rootPath` (`spaces/<did>`), so `resolveUserSpace`\n * selects the caller's own root rather than nesting their data under the\n * installer's.\n *\n * Phase 2 (current): `resolveUserSpace(u)` returns the caller's OWN space — a\n * sibling root `spaces/<u>` under the same `rootPath` — so each user's bytes\n * live in their own DID Space (design.md §六: 嵌套→并列). `resolveInstallerSpace`\n * stays the installer/owner space. This is the \"single space collapse\" fix.\n *\n * NB: unrelated to this package's `DIDSpaceResolver` (share / CID resolution).\n */\n\nimport type { DIDSpaceLike, SpaceResolver } from \"@aigne/afs\";\nimport { normalizeId, validateId } from \"./did-utils.js\";\nimport { DIDSpace, type ShareResolverFactory } from \"./local.js\";\n\nexport class LocalSpaceResolver implements SpaceResolver {\n /**\n * Per-user DID Spaces this resolver constructed, keyed by normalized userDid.\n * The installer/owner space is intentionally NOT tracked here — its lifecycle\n * belongs to whoever constructed and passed it in. Closed via `close()`.\n */\n private readonly ownedSpaces = new Map<string, DIDSpace>();\n\n /**\n * @param installerSpace the installer/owner DIDSpace (its share-resolver\n * factory is late-injected by the daemon via setShareResolverFactory).\n * @param shareResolverFactory share-out Phase 3: threaded into every sibling\n * `new DIDSpace(...)` so a caller space's `.share` writes reach the SAME\n * daemon-global store (same factory closure) as the installer space.\n * @param scopeHmacSecret scope de-id (README §5.3): threaded into every sibling\n * `new DIDSpace(...)` so each caller space derives the same storage scope the\n * installer space does. The installer space is constructed with the SAME\n * secret by the daemon. Undefined → de-id off (plaintext dirs, back-compat).\n */\n constructor(\n private readonly installerSpace: DIDSpace,\n private readonly shareResolverFactory?: ShareResolverFactory,\n private readonly scopeHmacSecret?: Uint8Array,\n ) {}\n\n async resolveInstallerSpace(): Promise<DIDSpaceLike> {\n return this.installerSpace;\n }\n\n async resolveUserSpace(userDid: string): Promise<DIDSpaceLike> {\n // Reject path-unsafe identities up front (DIDSpace's ctor also validates,\n // but failing here gives a clearer call site + avoids a half-built space).\n validateId(userDid);\n const key = normalizeId(userDid);\n\n // Degenerate special case: when the caller IS the installer/owner (local dev\n // with a single identity, design.md §五), reuse the installer space rather\n // than opening a SECOND DIDSpace over the same physical dir — two metadata\n // DBs on one directory would race. Their data already coincides by design.\n if (key === this.installerSpace.config.userDid) return this.installerSpace;\n\n const cached = this.ownedSpaces.get(key);\n if (cached) return cached;\n\n // The caller's own sibling root: same rootPath, userDir = rootPath/<u>.\n const space = new DIDSpace({\n rootPath: this.installerSpace.config.rootPath,\n userDid,\n shareResolverFactory: this.shareResolverFactory,\n scopeHmacSecret: this.scopeHmacSecret,\n });\n this.ownedSpaces.set(key, space);\n return space;\n }\n\n /** Close every per-user space this resolver created (call on daemon shutdown). */\n close(): void {\n for (const space of this.ownedSpaces.values()) space.close();\n this.ownedSpaces.clear();\n }\n}\n"],"mappings":";;;;AAsBA,IAAa,qBAAb,MAAyD;;;;;;CAMvD,AAAiB,8BAAc,IAAI,KAAuB;;;;;;;;;;;;CAa1D,YACE,AAAiB,gBACjB,AAAiB,sBACjB,AAAiB,iBACjB;EAHiB;EACA;EACA;;CAGnB,MAAM,wBAA+C;AACnD,SAAO,KAAK;;CAGd,MAAM,iBAAiB,SAAwC;AAG7D,aAAW,QAAQ;EACnB,MAAM,MAAM,YAAY,QAAQ;AAMhC,MAAI,QAAQ,KAAK,eAAe,OAAO,QAAS,QAAO,KAAK;EAE5D,MAAM,SAAS,KAAK,YAAY,IAAI,IAAI;AACxC,MAAI,OAAQ,QAAO;EAGnB,MAAM,QAAQ,IAAI,SAAS;GACzB,UAAU,KAAK,eAAe,OAAO;GACrC;GACA,sBAAsB,KAAK;GAC3B,iBAAiB,KAAK;GACvB,CAAC;AACF,OAAK,YAAY,IAAI,KAAK,MAAM;AAChC,SAAO;;;CAIT,QAAc;AACZ,OAAK,MAAM,SAAS,KAAK,YAAY,QAAQ,CAAE,OAAM,OAAO;AAC5D,OAAK,YAAY,OAAO"}
@@ -0,0 +1,51 @@
1
+ const require_d1_schema = require('./d1-schema.cjs');
2
+
3
+ //#region src/sqlite-gc-queue.ts
4
+ /** Default grace matches `D1GCQueue` (2h) for cross-impl parity. `runGc` always
5
+ * overrides with the canonical 7d, so this default is never relied upon. */
6
+ const DEFAULT_GRACE_MS = 7200 * 1e3;
7
+ var SqliteGcQueue = class {
8
+ constructor(client) {
9
+ this.client = client;
10
+ }
11
+ async ensureTable() {
12
+ await this.client.execute(`CREATE TABLE IF NOT EXISTS ds_gc_queue (
13
+ cid TEXT NOT NULL,
14
+ queued_at INTEGER NOT NULL,
15
+ PRIMARY KEY (cid)
16
+ )`);
17
+ for (const sql of require_d1_schema.GC_QUEUE_INDEX_SQL) await this.client.execute(sql);
18
+ }
19
+ async enqueue(cids) {
20
+ if (cids.length === 0) return;
21
+ await this.enqueueAt(cids, Date.now());
22
+ }
23
+ /**
24
+ * Enqueue with an explicit `queued_at` — used by the conformance suite to
25
+ * exercise the grace boundary deterministically. Not part of `GcQueue`.
26
+ */
27
+ async enqueueAt(cids, queuedAt) {
28
+ if (cids.length === 0) return;
29
+ const stmts = cids.map((cid) => ({
30
+ sql: "INSERT INTO ds_gc_queue (cid, queued_at) VALUES (?, ?) ON CONFLICT DO NOTHING",
31
+ args: [cid, queuedAt]
32
+ }));
33
+ await this.client.batch(stmts, "write");
34
+ }
35
+ async fetchCandidates(limit = 500, graceMs = DEFAULT_GRACE_MS) {
36
+ if (limit === 0) return [];
37
+ return (await this.client.execute({
38
+ sql: "SELECT cid FROM ds_gc_queue WHERE queued_at <= ? LIMIT ?",
39
+ args: [Date.now() - graceMs, limit]
40
+ })).rows.map((r) => ({ cid: r.cid }));
41
+ }
42
+ async remove(cid) {
43
+ await this.client.execute({
44
+ sql: "DELETE FROM ds_gc_queue WHERE cid = ?",
45
+ args: [cid]
46
+ });
47
+ }
48
+ };
49
+
50
+ //#endregion
51
+ exports.SqliteGcQueue = SqliteGcQueue;