@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.
- package/LICENSE.md +26 -0
- package/README.md +129 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs +10 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/afs-metadata-context.cjs +20 -0
- package/dist/afs-metadata-context.d.cts +21 -0
- package/dist/afs-metadata-context.d.cts.map +1 -0
- package/dist/afs-metadata-context.d.mts +21 -0
- package/dist/afs-metadata-context.d.mts.map +1 -0
- package/dist/afs-metadata-context.mjs +18 -0
- package/dist/afs-metadata-context.mjs.map +1 -0
- package/dist/blocklet-hook.cjs +180 -0
- package/dist/blocklet-hook.d.cts +29 -0
- package/dist/blocklet-hook.d.cts.map +1 -0
- package/dist/blocklet-hook.d.mts +29 -0
- package/dist/blocklet-hook.d.mts.map +1 -0
- package/dist/blocklet-hook.mjs +178 -0
- package/dist/blocklet-hook.mjs.map +1 -0
- package/dist/changelog-schema.cjs +603 -0
- package/dist/changelog-schema.d.cts +395 -0
- package/dist/changelog-schema.d.cts.map +1 -0
- package/dist/changelog-schema.d.mts +395 -0
- package/dist/changelog-schema.d.mts.map +1 -0
- package/dist/changelog-schema.mjs +570 -0
- package/dist/changelog-schema.mjs.map +1 -0
- package/dist/changelog-write.cjs +80 -0
- package/dist/changelog-write.d.cts +70 -0
- package/dist/changelog-write.d.cts.map +1 -0
- package/dist/changelog-write.d.mts +70 -0
- package/dist/changelog-write.d.mts.map +1 -0
- package/dist/changelog-write.mjs +77 -0
- package/dist/changelog-write.mjs.map +1 -0
- package/dist/cid-byte-cache.cjs +126 -0
- package/dist/cid-byte-cache.d.cts +46 -0
- package/dist/cid-byte-cache.d.cts.map +1 -0
- package/dist/cid-byte-cache.d.mts +47 -0
- package/dist/cid-byte-cache.d.mts.map +1 -0
- package/dist/cid-byte-cache.mjs +125 -0
- package/dist/cid-byte-cache.mjs.map +1 -0
- package/dist/cid.cjs +68 -0
- package/dist/cid.d.cts +22 -0
- package/dist/cid.d.cts.map +1 -0
- package/dist/cid.d.mts +22 -0
- package/dist/cid.d.mts.map +1 -0
- package/dist/cid.mjs +65 -0
- package/dist/cid.mjs.map +1 -0
- package/dist/client.cjs +221 -0
- package/dist/client.d.cts +72 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.mts +72 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +220 -0
- package/dist/client.mjs.map +1 -0
- package/dist/cloudflare.cjs +510 -0
- package/dist/cloudflare.d.cts +307 -0
- package/dist/cloudflare.d.cts.map +1 -0
- package/dist/cloudflare.d.mts +308 -0
- package/dist/cloudflare.d.mts.map +1 -0
- package/dist/cloudflare.mjs +507 -0
- package/dist/cloudflare.mjs.map +1 -0
- package/dist/ctime-backfill.cjs +272 -0
- package/dist/ctime-backfill.d.cts +169 -0
- package/dist/ctime-backfill.d.cts.map +1 -0
- package/dist/ctime-backfill.d.mts +169 -0
- package/dist/ctime-backfill.d.mts.map +1 -0
- package/dist/ctime-backfill.mjs +267 -0
- package/dist/ctime-backfill.mjs.map +1 -0
- package/dist/d1-gc-queue.cjs +80 -0
- package/dist/d1-gc-queue.d.cts +59 -0
- package/dist/d1-gc-queue.d.cts.map +1 -0
- package/dist/d1-gc-queue.d.mts +59 -0
- package/dist/d1-gc-queue.d.mts.map +1 -0
- package/dist/d1-gc-queue.mjs +81 -0
- package/dist/d1-gc-queue.mjs.map +1 -0
- package/dist/d1-resolve-store.cjs +189 -0
- package/dist/d1-resolve-store.d.cts +93 -0
- package/dist/d1-resolve-store.d.cts.map +1 -0
- package/dist/d1-resolve-store.d.mts +93 -0
- package/dist/d1-resolve-store.d.mts.map +1 -0
- package/dist/d1-resolve-store.mjs +190 -0
- package/dist/d1-resolve-store.mjs.map +1 -0
- package/dist/d1-schema.cjs +361 -0
- package/dist/d1-schema.d.cts +237 -0
- package/dist/d1-schema.d.cts.map +1 -0
- package/dist/d1-schema.d.mts +237 -0
- package/dist/d1-schema.d.mts.map +1 -0
- package/dist/d1-schema.mjs +341 -0
- package/dist/d1-schema.mjs.map +1 -0
- package/dist/d1-share-store.cjs +0 -0
- package/dist/d1-share-store.d.cts +53 -0
- package/dist/d1-share-store.d.cts.map +1 -0
- package/dist/d1-share-store.d.mts +53 -0
- package/dist/d1-share-store.d.mts.map +1 -0
- package/dist/d1-share-store.mjs +0 -0
- package/dist/d1-share-store.mjs.map +1 -0
- package/dist/d1-tree-index.cjs +1098 -0
- package/dist/d1-tree-index.d.cts +203 -0
- package/dist/d1-tree-index.d.cts.map +1 -0
- package/dist/d1-tree-index.d.mts +203 -0
- package/dist/d1-tree-index.d.mts.map +1 -0
- package/dist/d1-tree-index.mjs +1094 -0
- package/dist/d1-tree-index.mjs.map +1 -0
- package/dist/data-backend.cjs +147 -0
- package/dist/data-backend.d.cts +30 -0
- package/dist/data-backend.d.cts.map +1 -0
- package/dist/data-backend.d.mts +30 -0
- package/dist/data-backend.d.mts.map +1 -0
- package/dist/data-backend.mjs +148 -0
- package/dist/data-backend.mjs.map +1 -0
- package/dist/dedup-backfill.cjs +278 -0
- package/dist/dedup-backfill.d.cts +165 -0
- package/dist/dedup-backfill.d.cts.map +1 -0
- package/dist/dedup-backfill.d.mts +165 -0
- package/dist/dedup-backfill.d.mts.map +1 -0
- package/dist/dedup-backfill.mjs +273 -0
- package/dist/dedup-backfill.mjs.map +1 -0
- package/dist/did-space-like.d.cts +2 -0
- package/dist/did-space-like.d.mts +2 -0
- package/dist/did-utils.cjs +44 -0
- package/dist/did-utils.d.cts +25 -0
- package/dist/did-utils.d.cts.map +1 -0
- package/dist/did-utils.d.mts +25 -0
- package/dist/did-utils.d.mts.map +1 -0
- package/dist/did-utils.mjs +43 -0
- package/dist/did-utils.mjs.map +1 -0
- package/dist/dirty-path-queue.cjs +31 -0
- package/dist/dirty-path-queue.d.cts +104 -0
- package/dist/dirty-path-queue.d.cts.map +1 -0
- package/dist/dirty-path-queue.d.mts +104 -0
- package/dist/dirty-path-queue.d.mts.map +1 -0
- package/dist/dirty-path-queue.mjs +31 -0
- package/dist/dirty-path-queue.mjs.map +1 -0
- package/dist/dirty-path-schema.cjs +142 -0
- package/dist/dirty-path-schema.d.cts +90 -0
- package/dist/dirty-path-schema.d.cts.map +1 -0
- package/dist/dirty-path-schema.d.mts +90 -0
- package/dist/dirty-path-schema.d.mts.map +1 -0
- package/dist/dirty-path-schema.mjs +136 -0
- package/dist/dirty-path-schema.mjs.map +1 -0
- package/dist/download-actions.cjs +43 -0
- package/dist/download-actions.mjs +40 -0
- package/dist/download-actions.mjs.map +1 -0
- package/dist/fs-object-store.cjs +153 -0
- package/dist/fs-object-store.d.cts +21 -0
- package/dist/fs-object-store.d.cts.map +1 -0
- package/dist/fs-object-store.d.mts +22 -0
- package/dist/fs-object-store.d.mts.map +1 -0
- package/dist/fs-object-store.mjs +153 -0
- package/dist/fs-object-store.mjs.map +1 -0
- package/dist/gc-queue.d.cts +43 -0
- package/dist/gc-queue.d.cts.map +1 -0
- package/dist/gc-queue.d.mts +43 -0
- package/dist/gc-queue.d.mts.map +1 -0
- package/dist/index.cjs +2712 -0
- package/dist/index.d.cts +504 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +505 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2537 -0
- package/dist/index.mjs.map +1 -0
- package/dist/inline-content-migration.cjs +212 -0
- package/dist/inline-content-migration.d.cts +110 -0
- package/dist/inline-content-migration.d.cts.map +1 -0
- package/dist/inline-content-migration.d.mts +111 -0
- package/dist/inline-content-migration.d.mts.map +1 -0
- package/dist/inline-content-migration.mjs +207 -0
- package/dist/inline-content-migration.mjs.map +1 -0
- package/dist/inline-content.cjs +145 -0
- package/dist/inline-content.d.cts +98 -0
- package/dist/inline-content.d.cts.map +1 -0
- package/dist/inline-content.d.mts +98 -0
- package/dist/inline-content.d.mts.map +1 -0
- package/dist/inline-content.mjs +137 -0
- package/dist/inline-content.mjs.map +1 -0
- package/dist/local-changelog.cjs +241 -0
- package/dist/local-changelog.d.cts +119 -0
- package/dist/local-changelog.d.cts.map +1 -0
- package/dist/local-changelog.d.mts +119 -0
- package/dist/local-changelog.d.mts.map +1 -0
- package/dist/local-changelog.mjs +240 -0
- package/dist/local-changelog.mjs.map +1 -0
- package/dist/local.cjs +435 -0
- package/dist/local.d.cts +254 -0
- package/dist/local.d.cts.map +1 -0
- package/dist/local.d.mts +254 -0
- package/dist/local.d.mts.map +1 -0
- package/dist/local.mjs +427 -0
- package/dist/local.mjs.map +1 -0
- package/dist/memory-gc-queue.cjs +36 -0
- package/dist/memory-gc-queue.d.cts +22 -0
- package/dist/memory-gc-queue.d.cts.map +1 -0
- package/dist/memory-gc-queue.d.mts +22 -0
- package/dist/memory-gc-queue.d.mts.map +1 -0
- package/dist/memory-gc-queue.mjs +36 -0
- package/dist/memory-gc-queue.mjs.map +1 -0
- package/dist/memory-tree-index.cjs +734 -0
- package/dist/memory-tree-index.d.cts +159 -0
- package/dist/memory-tree-index.d.cts.map +1 -0
- package/dist/memory-tree-index.d.mts +159 -0
- package/dist/memory-tree-index.d.mts.map +1 -0
- package/dist/memory-tree-index.mjs +735 -0
- package/dist/memory-tree-index.mjs.map +1 -0
- package/dist/metadata-db.cjs +562 -0
- package/dist/metadata-db.d.cts +102 -0
- package/dist/metadata-db.d.cts.map +1 -0
- package/dist/metadata-db.d.mts +102 -0
- package/dist/metadata-db.d.mts.map +1 -0
- package/dist/metadata-db.mjs +562 -0
- package/dist/metadata-db.mjs.map +1 -0
- package/dist/mime-utils.cjs +2 -0
- package/dist/mime-utils.d.cts +2 -0
- package/dist/mime-utils.d.mts +2 -0
- package/dist/mime-utils.mjs +3 -0
- package/dist/object-key.cjs +41 -0
- package/dist/object-key.d.cts +25 -0
- package/dist/object-key.d.cts.map +1 -0
- package/dist/object-key.d.mts +25 -0
- package/dist/object-key.d.mts.map +1 -0
- package/dist/object-key.mjs +40 -0
- package/dist/object-key.mjs.map +1 -0
- package/dist/packages/session/dist/index.cjs +788 -0
- package/dist/packages/session/dist/index.mjs +782 -0
- package/dist/packages/session/dist/index.mjs.map +1 -0
- package/dist/platform/r2/dist/types.d.cts +49 -0
- package/dist/platform/r2/dist/types.d.cts.map +1 -0
- package/dist/prefix-range.cjs +33 -0
- package/dist/prefix-range.d.cts +29 -0
- package/dist/prefix-range.d.cts.map +1 -0
- package/dist/prefix-range.d.mts +29 -0
- package/dist/prefix-range.d.mts.map +1 -0
- package/dist/prefix-range.mjs +33 -0
- package/dist/prefix-range.mjs.map +1 -0
- package/dist/prefixed-tree-index.cjs +238 -0
- package/dist/prefixed-tree-index.d.cts +85 -0
- package/dist/prefixed-tree-index.d.cts.map +1 -0
- package/dist/prefixed-tree-index.d.mts +85 -0
- package/dist/prefixed-tree-index.d.mts.map +1 -0
- package/dist/prefixed-tree-index.mjs +239 -0
- package/dist/prefixed-tree-index.mjs.map +1 -0
- package/dist/presign-signer.cjs +7 -0
- package/dist/presign-signer.d.cts +99 -0
- package/dist/presign-signer.d.cts.map +1 -0
- package/dist/presign-signer.d.mts +99 -0
- package/dist/presign-signer.d.mts.map +1 -0
- package/dist/presign-signer.mjs +7 -0
- package/dist/presign-signer.mjs.map +1 -0
- package/dist/providers/platform/r2/dist/index.d.mts +3 -0
- package/dist/providers/platform/r2/dist/types.d.mts +49 -0
- package/dist/providers/platform/r2/dist/types.d.mts.map +1 -0
- package/dist/reconcile.cjs +184 -0
- package/dist/reconcile.d.cts +26 -0
- package/dist/reconcile.d.cts.map +1 -0
- package/dist/reconcile.d.mts +26 -0
- package/dist/reconcile.d.mts.map +1 -0
- package/dist/reconcile.mjs +184 -0
- package/dist/reconcile.mjs.map +1 -0
- package/dist/reference-check.cjs +49 -0
- package/dist/reference-check.d.cts +10 -0
- package/dist/reference-check.d.cts.map +1 -0
- package/dist/reference-check.d.mts +10 -0
- package/dist/reference-check.d.mts.map +1 -0
- package/dist/reference-check.mjs +48 -0
- package/dist/reference-check.mjs.map +1 -0
- package/dist/remote-afs.cjs +681 -0
- package/dist/remote-afs.d.cts +236 -0
- package/dist/remote-afs.d.cts.map +1 -0
- package/dist/remote-afs.d.mts +236 -0
- package/dist/remote-afs.d.mts.map +1 -0
- package/dist/remote-afs.mjs +676 -0
- package/dist/remote-afs.mjs.map +1 -0
- package/dist/rename-guard.cjs +18 -0
- package/dist/rename-guard.mjs +18 -0
- package/dist/rename-guard.mjs.map +1 -0
- package/dist/resolve.cjs +260 -0
- package/dist/resolve.d.cts +113 -0
- package/dist/resolve.d.cts.map +1 -0
- package/dist/resolve.d.mts +113 -0
- package/dist/resolve.d.mts.map +1 -0
- package/dist/resolve.mjs +260 -0
- package/dist/resolve.mjs.map +1 -0
- package/dist/rsync-content.cjs +33 -0
- package/dist/rsync-content.mjs +33 -0
- package/dist/rsync-content.mjs.map +1 -0
- package/dist/rsync.cjs +400 -0
- package/dist/rsync.d.cts +157 -0
- package/dist/rsync.d.cts.map +1 -0
- package/dist/rsync.d.mts +157 -0
- package/dist/rsync.d.mts.map +1 -0
- package/dist/rsync.mjs +397 -0
- package/dist/rsync.mjs.map +1 -0
- package/dist/run-gc.cjs +57 -0
- package/dist/run-gc.d.cts +40 -0
- package/dist/run-gc.d.cts.map +1 -0
- package/dist/run-gc.d.mts +41 -0
- package/dist/run-gc.d.mts.map +1 -0
- package/dist/run-gc.mjs +57 -0
- package/dist/run-gc.mjs.map +1 -0
- package/dist/scope-id.cjs +70 -0
- package/dist/scope-id.d.cts +35 -0
- package/dist/scope-id.d.cts.map +1 -0
- package/dist/scope-id.d.mts +35 -0
- package/dist/scope-id.d.mts.map +1 -0
- package/dist/scope-id.mjs +68 -0
- package/dist/scope-id.mjs.map +1 -0
- package/dist/scope-migration-node.cjs +172 -0
- package/dist/scope-migration-node.d.cts +44 -0
- package/dist/scope-migration-node.d.cts.map +1 -0
- package/dist/scope-migration-node.d.mts +44 -0
- package/dist/scope-migration-node.d.mts.map +1 -0
- package/dist/scope-migration-node.mjs +171 -0
- package/dist/scope-migration-node.mjs.map +1 -0
- package/dist/scope-migration.cjs +155 -0
- package/dist/scope-migration.d.cts +65 -0
- package/dist/scope-migration.d.cts.map +1 -0
- package/dist/scope-migration.d.mts +65 -0
- package/dist/scope-migration.d.mts.map +1 -0
- package/dist/scope-migration.mjs +154 -0
- package/dist/scope-migration.mjs.map +1 -0
- package/dist/share-declaration.cjs +225 -0
- package/dist/share-declaration.d.cts +30 -0
- package/dist/share-declaration.d.cts.map +1 -0
- package/dist/share-declaration.d.mts +32 -0
- package/dist/share-declaration.d.mts.map +1 -0
- package/dist/share-declaration.mjs +221 -0
- package/dist/share-declaration.mjs.map +1 -0
- package/dist/share-hook.cjs +63 -0
- package/dist/share-hook.mjs +62 -0
- package/dist/share-hook.mjs.map +1 -0
- package/dist/share-resolve.cjs +176 -0
- package/dist/share-resolve.d.cts +36 -0
- package/dist/share-resolve.d.cts.map +1 -0
- package/dist/share-resolve.d.mts +36 -0
- package/dist/share-resolve.d.mts.map +1 -0
- package/dist/share-resolve.mjs +177 -0
- package/dist/share-resolve.mjs.map +1 -0
- package/dist/share-serve.cjs +145 -0
- package/dist/share-serve.d.cts +30 -0
- package/dist/share-serve.d.cts.map +1 -0
- package/dist/share-serve.d.mts +30 -0
- package/dist/share-serve.d.mts.map +1 -0
- package/dist/share-serve.mjs +144 -0
- package/dist/share-serve.mjs.map +1 -0
- package/dist/share-store.cjs +25 -0
- package/dist/share-store.d.cts +65 -0
- package/dist/share-store.d.cts.map +1 -0
- package/dist/share-store.d.mts +65 -0
- package/dist/share-store.d.mts.map +1 -0
- package/dist/share-store.mjs +25 -0
- package/dist/share-store.mjs.map +1 -0
- package/dist/share-virtual-path.cjs +102 -0
- package/dist/share-virtual-path.mjs +101 -0
- package/dist/share-virtual-path.mjs.map +1 -0
- package/dist/space-resolver.cjs +54 -0
- package/dist/space-resolver.d.cts +34 -0
- package/dist/space-resolver.d.cts.map +1 -0
- package/dist/space-resolver.d.mts +34 -0
- package/dist/space-resolver.d.mts.map +1 -0
- package/dist/space-resolver.mjs +55 -0
- package/dist/space-resolver.mjs.map +1 -0
- package/dist/sqlite-gc-queue.cjs +51 -0
- package/dist/sqlite-gc-queue.d.cts +22 -0
- package/dist/sqlite-gc-queue.d.cts.map +1 -0
- package/dist/sqlite-gc-queue.d.mts +22 -0
- package/dist/sqlite-gc-queue.d.mts.map +1 -0
- package/dist/sqlite-gc-queue.mjs +52 -0
- package/dist/sqlite-gc-queue.mjs.map +1 -0
- package/dist/sqlite-resolve-store.cjs +163 -0
- package/dist/sqlite-resolve-store.d.cts +50 -0
- package/dist/sqlite-resolve-store.d.cts.map +1 -0
- package/dist/sqlite-resolve-store.d.mts +50 -0
- package/dist/sqlite-resolve-store.d.mts.map +1 -0
- package/dist/sqlite-resolve-store.mjs +164 -0
- package/dist/sqlite-resolve-store.mjs.map +1 -0
- package/dist/sqlite-share-store.cjs +157 -0
- package/dist/sqlite-share-store.d.cts +31 -0
- package/dist/sqlite-share-store.d.cts.map +1 -0
- package/dist/sqlite-share-store.d.mts +31 -0
- package/dist/sqlite-share-store.d.mts.map +1 -0
- package/dist/sqlite-share-store.mjs +157 -0
- package/dist/sqlite-share-store.mjs.map +1 -0
- package/dist/sqlite-tree-index.cjs +901 -0
- package/dist/sqlite-tree-index.d.cts +107 -0
- package/dist/sqlite-tree-index.d.cts.map +1 -0
- package/dist/sqlite-tree-index.d.mts +107 -0
- package/dist/sqlite-tree-index.d.mts.map +1 -0
- package/dist/sqlite-tree-index.mjs +902 -0
- package/dist/sqlite-tree-index.mjs.map +1 -0
- package/dist/sync-engine.cjs +1324 -0
- package/dist/sync-engine.d.cts +473 -0
- package/dist/sync-engine.d.cts.map +1 -0
- package/dist/sync-engine.d.mts +473 -0
- package/dist/sync-engine.d.mts.map +1 -0
- package/dist/sync-engine.mjs +1315 -0
- package/dist/sync-engine.mjs.map +1 -0
- package/dist/sync-state.cjs +303 -0
- package/dist/sync-state.d.cts +224 -0
- package/dist/sync-state.d.cts.map +1 -0
- package/dist/sync-state.d.mts +224 -0
- package/dist/sync-state.d.mts.map +1 -0
- package/dist/sync-state.mjs +297 -0
- package/dist/sync-state.mjs.map +1 -0
- package/dist/timestamp.cjs +92 -0
- package/dist/timestamp.mjs +91 -0
- package/dist/timestamp.mjs.map +1 -0
- package/dist/transports/http.cjs +54 -0
- package/dist/transports/http.d.cts +26 -0
- package/dist/transports/http.d.cts.map +1 -0
- package/dist/transports/http.d.mts +26 -0
- package/dist/transports/http.d.mts.map +1 -0
- package/dist/transports/http.mjs +54 -0
- package/dist/transports/http.mjs.map +1 -0
- package/dist/transports/static.cjs +55 -0
- package/dist/transports/static.d.cts +28 -0
- package/dist/transports/static.d.cts.map +1 -0
- package/dist/transports/static.d.mts +28 -0
- package/dist/transports/static.d.mts.map +1 -0
- package/dist/transports/static.mjs +55 -0
- package/dist/transports/static.mjs.map +1 -0
- package/dist/transports/types.cjs +13 -0
- package/dist/transports/types.d.cts +72 -0
- package/dist/transports/types.d.cts.map +1 -0
- package/dist/transports/types.d.mts +72 -0
- package/dist/transports/types.d.mts.map +1 -0
- package/dist/transports/types.mjs +13 -0
- package/dist/transports/types.mjs.map +1 -0
- package/dist/transports/ws.cjs +207 -0
- package/dist/transports/ws.d.cts +47 -0
- package/dist/transports/ws.d.cts.map +1 -0
- package/dist/transports/ws.d.mts +47 -0
- package/dist/transports/ws.d.mts.map +1 -0
- package/dist/transports/ws.mjs +206 -0
- package/dist/transports/ws.mjs.map +1 -0
- package/dist/tree-index.cjs +333 -0
- package/dist/tree-index.d.cts +524 -0
- package/dist/tree-index.d.cts.map +1 -0
- package/dist/tree-index.d.mts +524 -0
- package/dist/tree-index.d.mts.map +1 -0
- package/dist/tree-index.mjs +322 -0
- package/dist/tree-index.mjs.map +1 -0
- package/dist/tree-query.cjs +655 -0
- package/dist/tree-query.d.cts +70 -0
- package/dist/tree-query.d.cts.map +1 -0
- package/dist/tree-query.d.mts +70 -0
- package/dist/tree-query.d.mts.map +1 -0
- package/dist/tree-query.mjs +648 -0
- package/dist/tree-query.mjs.map +1 -0
- package/dist/upload-actions.cjs +97 -0
- package/dist/upload-actions.d.cts +19 -0
- package/dist/upload-actions.d.cts.map +1 -0
- package/dist/upload-actions.d.mts +21 -0
- package/dist/upload-actions.d.mts.map +1 -0
- package/dist/upload-actions.mjs +90 -0
- package/dist/upload-actions.mjs.map +1 -0
- package/dist/upload-session-store.cjs +185 -0
- package/dist/upload-session-store.d.cts +99 -0
- package/dist/upload-session-store.d.cts.map +1 -0
- package/dist/upload-session-store.d.mts +99 -0
- package/dist/upload-session-store.d.mts.map +1 -0
- package/dist/upload-session-store.mjs +184 -0
- package/dist/upload-session-store.mjs.map +1 -0
- package/dist/url-normalize.cjs +61 -0
- package/dist/url-normalize.d.cts +33 -0
- package/dist/url-normalize.d.cts.map +1 -0
- package/dist/url-normalize.d.mts +33 -0
- package/dist/url-normalize.d.mts.map +1 -0
- package/dist/url-normalize.mjs +61 -0
- package/dist/url-normalize.mjs.map +1 -0
- package/dist/versioned-content-backends.cjs +155 -0
- package/dist/versioned-content-backends.d.cts +49 -0
- package/dist/versioned-content-backends.d.cts.map +1 -0
- package/dist/versioned-content-backends.d.mts +49 -0
- package/dist/versioned-content-backends.d.mts.map +1 -0
- package/dist/versioned-content-backends.mjs +154 -0
- package/dist/versioned-content-backends.mjs.map +1 -0
- package/dist/versioned-content-index.cjs +102 -0
- package/dist/versioned-content-index.d.cts +46 -0
- package/dist/versioned-content-index.d.cts.map +1 -0
- package/dist/versioned-content-index.d.mts +46 -0
- package/dist/versioned-content-index.d.mts.map +1 -0
- package/dist/versioned-content-index.mjs +103 -0
- package/dist/versioned-content-index.mjs.map +1 -0
- package/dist/versioned-content-store.cjs +121 -0
- package/dist/versioned-content-store.d.cts +90 -0
- package/dist/versioned-content-store.d.cts.map +1 -0
- package/dist/versioned-content-store.d.mts +90 -0
- package/dist/versioned-content-store.d.mts.map +1 -0
- package/dist/versioned-content-store.mjs +122 -0
- package/dist/versioned-content-store.mjs.map +1 -0
- package/dist/versioned-scope.cjs +39 -0
- package/dist/versioned-scope.d.cts +57 -0
- package/dist/versioned-scope.d.cts.map +1 -0
- package/dist/versioned-scope.d.mts +57 -0
- package/dist/versioned-scope.d.mts.map +1 -0
- package/dist/versioned-scope.mjs +37 -0
- package/dist/versioned-scope.mjs.map +1 -0
- package/migrations/0001_tree_entries.sql +17 -0
- package/migrations/0002_resolve_entries.sql +7 -0
- package/migrations/0003_entries_v2.sql +38 -0
- package/migrations/0004_gc_queue.sql +5 -0
- package/migrations/0006_resolve_enhance.sql +14 -0
- package/migrations/0007_resolve_created_at.sql +10 -0
- package/migrations/0008_changelog.sql +34 -0
- package/migrations/0009_device_sync_state.sql +29 -0
- package/migrations/0010_scope_meta.sql +33 -0
- package/migrations/0011_shares.sql +25 -0
- package/migrations/0012_scope_meta_file_count.sql +41 -0
- package/migrations/0013_scope_meta_total_bytes.sql +47 -0
- package/migrations/0014_rename_tables.sql +62 -0
- package/package.json +102 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cid-byte-cache.mjs","names":[],"sources":["../src/cid-byte-cache.ts"],"sourcesContent":["/**\n * Content-addressed byte cache for the DID-Space object store.\n *\n * DID Space stores every blob once at the canonical key `objects/{cid}`, where\n * `cid` is a pure SHA-256 content hash (see {@link computeCID}) — no scope, no\n * owner, no salt. That makes the mapping `cid → bytes` **immutable**: the bytes\n * behind a given cid can never change. So a cache keyed by cid is ALWAYS valid —\n * it needs no TTL and no invalidation. A re-publish writes new bytes under a NEW\n * cid; the path→cid lookup (a cheap indexed D1/SQLite query, done fresh on every\n * read) points at the new cid, which simply misses the cache and is fetched once.\n * This is why re-published content is visible immediately even with caching on.\n *\n * The cache is a bounded LRU (bytes-budgeted). It wraps the object store — the\n * provider read path is unchanged and hits the cache transparently. Because cids\n * are global (identical bytes → identical cid across all users), this also dedups\n * hot blobs across a space's readers, matching the \"global object pool\" storage\n * design (see cloudflare.ts constructor).\n *\n * This lives INSIDE the provider layer on purpose (AFS-Only I/O: caching is the\n * store's own concern, invisible above the AFS interface — not a hand-rolled\n * cache in application/serve code).\n */\n\nimport type {\n ObjectStore,\n ObjectStoreHeadResult,\n ObjectStoreListOptions,\n ObjectStoreListResult,\n ObjectStoreObject,\n} from \"@aigne/afs-r2\";\n\n/** Canonical prefix under which content-addressed blobs live: `objects/{cid}`. */\nconst OBJECT_KEY_PREFIX = \"objects/\";\n\n/** Total bytes the cache may hold before LRU eviction kicks in (per instance). */\nconst DEFAULT_MAX_TOTAL_BYTES = 64 * 1024 * 1024; // 64 MiB\n/**\n * Largest single object we cache. Bigger blobs (large media / bundles) are left\n * uncached: they'd evict many small hot files, and the ≳8 MiB range is\n * download-plane territory (served R2-direct, never read through the Worker).\n */\nconst DEFAULT_MAX_ENTRY_BYTES = 4 * 1024 * 1024; // 4 MiB\n\nconst UTF8_DECODER = new TextDecoder();\n/** Synthetic timestamp for cached objects — object-store metadata is never read\n * from `get()` (the provider takes size/mtime from the tree index), so a fixed\n * epoch is faithful and avoids a per-entry Date allocation. */\nconst SYNTHETIC_UPLOADED = new Date(0);\n\nexport interface CidByteCacheOptions {\n /** Total byte budget before LRU eviction. Default 64 MiB. */\n maxTotalBytes?: number;\n /** Per-object cap; larger objects are not cached. Default 4 MiB. */\n maxEntryBytes?: number;\n}\n\n/**\n * Bounded LRU cache of `cid → bytes`. Insertion order in the backing Map is the\n * LRU order; a `get` re-inserts (bumps to most-recently-used).\n */\nexport class CidByteCache {\n private readonly map = new Map<string, Uint8Array>();\n private readonly maxTotalBytes: number;\n private readonly maxEntryBytes: number;\n private totalBytes = 0;\n\n constructor(options?: CidByteCacheOptions) {\n this.maxTotalBytes = options?.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;\n this.maxEntryBytes = options?.maxEntryBytes ?? DEFAULT_MAX_ENTRY_BYTES;\n }\n\n get(cid: string): Uint8Array | undefined {\n const bytes = this.map.get(cid);\n if (bytes === undefined) return undefined;\n // LRU bump: delete + re-set moves the key to the end (most-recent).\n this.map.delete(cid);\n this.map.set(cid, bytes);\n return bytes;\n }\n\n set(cid: string, bytes: Uint8Array): void {\n if (bytes.byteLength > this.maxEntryBytes) return; // too big to cache\n const existing = this.map.get(cid);\n if (existing !== undefined) {\n this.totalBytes -= existing.byteLength;\n this.map.delete(cid);\n }\n this.map.set(cid, bytes);\n this.totalBytes += bytes.byteLength;\n this.evictToBudget();\n }\n\n delete(cid: string): void {\n const existing = this.map.get(cid);\n if (existing === undefined) return;\n this.totalBytes -= existing.byteLength;\n this.map.delete(cid);\n }\n\n /** Test/introspection helper. */\n get size(): number {\n return this.map.size;\n }\n\n private evictToBudget(): void {\n while (this.totalBytes > this.maxTotalBytes) {\n const oldest = this.map.keys().next().value as string | undefined;\n if (oldest === undefined) break;\n const evicted = this.map.get(oldest);\n if (evicted !== undefined) this.totalBytes -= evicted.byteLength;\n this.map.delete(oldest);\n }\n }\n}\n\n/** Build a minimal ObjectStoreObject that serves cached bytes. */\nfunction objectFromBytes(key: string, bytes: Uint8Array): ObjectStoreObject {\n return {\n key,\n size: bytes.byteLength,\n uploaded: SYNTHETIC_UPLOADED,\n async text() {\n return UTF8_DECODER.decode(bytes);\n },\n async arrayBuffer() {\n // Copy so a caller can't mutate the cached buffer.\n return bytes.slice().buffer;\n },\n };\n}\n\n/**\n * ObjectStore decorator that serves `objects/{cid}` reads from an in-memory\n * {@link CidByteCache}. Non-`objects/` keys and all writes/lists pass straight\n * through. `delete` drops the cid from the cache (belt-and-suspenders against GC\n * — a still-referenced object is never GC'd, so this rarely matters).\n */\nexport class CachingObjectStore implements ObjectStore {\n constructor(\n private readonly inner: ObjectStore,\n private readonly cache: CidByteCache,\n ) {}\n\n private cidOf(key: string): string | undefined {\n return key.startsWith(OBJECT_KEY_PREFIX) ? key.slice(OBJECT_KEY_PREFIX.length) : undefined;\n }\n\n async get(key: string): Promise<ObjectStoreObject | null> {\n const cid = this.cidOf(key);\n if (cid === undefined) return this.inner.get(key);\n\n const cached = this.cache.get(cid);\n if (cached !== undefined) return objectFromBytes(key, cached);\n\n const obj = await this.inner.get(key);\n if (!obj) return null;\n const bytes = new Uint8Array(await obj.arrayBuffer());\n this.cache.set(cid, bytes);\n return objectFromBytes(key, bytes);\n }\n\n put(key: string, value: string | ArrayBuffer | ReadableStream): Promise<void> {\n // Content-addressed: a re-put of the same cid is the same bytes, nothing to\n // invalidate. Just delegate (do NOT populate the cache from a ReadableStream).\n return this.inner.put(key, value);\n }\n\n async delete(key: string): Promise<void> {\n const cid = this.cidOf(key);\n if (cid !== undefined) this.cache.delete(cid);\n return this.inner.delete(key);\n }\n\n list(options?: ObjectStoreListOptions): Promise<ObjectStoreListResult> {\n return this.inner.list(options);\n }\n\n head(key: string): Promise<ObjectStoreHeadResult | null> {\n return this.inner.head(key);\n }\n}\n"],"mappings":";;AAgCA,MAAM,oBAAoB;;AAG1B,MAAM,0BAA0B,KAAK,OAAO;;;;;;AAM5C,MAAM,0BAA0B,IAAI,OAAO;AAE3C,MAAM,eAAe,IAAI,aAAa;;;;AAItC,MAAM,qCAAqB,IAAI,KAAK,EAAE;;;;;AAatC,IAAa,eAAb,MAA0B;CACxB,AAAiB,sBAAM,IAAI,KAAyB;CACpD,AAAiB;CACjB,AAAiB;CACjB,AAAQ,aAAa;CAErB,YAAY,SAA+B;AACzC,OAAK,gBAAgB,SAAS,iBAAiB;AAC/C,OAAK,gBAAgB,SAAS,iBAAiB;;CAGjD,IAAI,KAAqC;EACvC,MAAM,QAAQ,KAAK,IAAI,IAAI,IAAI;AAC/B,MAAI,UAAU,OAAW,QAAO;AAEhC,OAAK,IAAI,OAAO,IAAI;AACpB,OAAK,IAAI,IAAI,KAAK,MAAM;AACxB,SAAO;;CAGT,IAAI,KAAa,OAAyB;AACxC,MAAI,MAAM,aAAa,KAAK,cAAe;EAC3C,MAAM,WAAW,KAAK,IAAI,IAAI,IAAI;AAClC,MAAI,aAAa,QAAW;AAC1B,QAAK,cAAc,SAAS;AAC5B,QAAK,IAAI,OAAO,IAAI;;AAEtB,OAAK,IAAI,IAAI,KAAK,MAAM;AACxB,OAAK,cAAc,MAAM;AACzB,OAAK,eAAe;;CAGtB,OAAO,KAAmB;EACxB,MAAM,WAAW,KAAK,IAAI,IAAI,IAAI;AAClC,MAAI,aAAa,OAAW;AAC5B,OAAK,cAAc,SAAS;AAC5B,OAAK,IAAI,OAAO,IAAI;;;CAItB,IAAI,OAAe;AACjB,SAAO,KAAK,IAAI;;CAGlB,AAAQ,gBAAsB;AAC5B,SAAO,KAAK,aAAa,KAAK,eAAe;GAC3C,MAAM,SAAS,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC;AACtC,OAAI,WAAW,OAAW;GAC1B,MAAM,UAAU,KAAK,IAAI,IAAI,OAAO;AACpC,OAAI,YAAY,OAAW,MAAK,cAAc,QAAQ;AACtD,QAAK,IAAI,OAAO,OAAO;;;;;AAM7B,SAAS,gBAAgB,KAAa,OAAsC;AAC1E,QAAO;EACL;EACA,MAAM,MAAM;EACZ,UAAU;EACV,MAAM,OAAO;AACX,UAAO,aAAa,OAAO,MAAM;;EAEnC,MAAM,cAAc;AAElB,UAAO,MAAM,OAAO,CAAC;;EAExB;;;;;;;;AASH,IAAa,qBAAb,MAAuD;CACrD,YACE,AAAiB,OACjB,AAAiB,OACjB;EAFiB;EACA;;CAGnB,AAAQ,MAAM,KAAiC;AAC7C,SAAO,IAAI,WAAW,kBAAkB,GAAG,IAAI,MAAM,EAAyB,GAAG;;CAGnF,MAAM,IAAI,KAAgD;EACxD,MAAM,MAAM,KAAK,MAAM,IAAI;AAC3B,MAAI,QAAQ,OAAW,QAAO,KAAK,MAAM,IAAI,IAAI;EAEjD,MAAM,SAAS,KAAK,MAAM,IAAI,IAAI;AAClC,MAAI,WAAW,OAAW,QAAO,gBAAgB,KAAK,OAAO;EAE7D,MAAM,MAAM,MAAM,KAAK,MAAM,IAAI,IAAI;AACrC,MAAI,CAAC,IAAK,QAAO;EACjB,MAAM,QAAQ,IAAI,WAAW,MAAM,IAAI,aAAa,CAAC;AACrD,OAAK,MAAM,IAAI,KAAK,MAAM;AAC1B,SAAO,gBAAgB,KAAK,MAAM;;CAGpC,IAAI,KAAa,OAA6D;AAG5E,SAAO,KAAK,MAAM,IAAI,KAAK,MAAM;;CAGnC,MAAM,OAAO,KAA4B;EACvC,MAAM,MAAM,KAAK,MAAM,IAAI;AAC3B,MAAI,QAAQ,OAAW,MAAK,MAAM,OAAO,IAAI;AAC7C,SAAO,KAAK,MAAM,OAAO,IAAI;;CAG/B,KAAK,SAAkE;AACrE,SAAO,KAAK,MAAM,KAAK,QAAQ;;CAGjC,KAAK,KAAoD;AACvD,SAAO,KAAK,MAAM,KAAK,IAAI"}
|
package/dist/cid.cjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let multiformats_bases_base64 = require("multiformats/bases/base64");
|
|
3
|
+
let multiformats_cid = require("multiformats/cid");
|
|
4
|
+
let multiformats_codecs_raw = require("multiformats/codecs/raw");
|
|
5
|
+
multiformats_codecs_raw = require_rolldown_runtime.__toESM(multiformats_codecs_raw);
|
|
6
|
+
let multiformats_hashes_digest = require("multiformats/hashes/digest");
|
|
7
|
+
|
|
8
|
+
//#region src/cid.ts
|
|
9
|
+
const SHA256_CODE = 18;
|
|
10
|
+
/**
|
|
11
|
+
* Compute a CID v1 (raw codec + SHA-256) for the given content.
|
|
12
|
+
* Uses Web Crypto API (crypto.subtle) — works in Workers, browsers, and Node.js 15+.
|
|
13
|
+
*/
|
|
14
|
+
async function computeCID(content) {
|
|
15
|
+
const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
16
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", bytes);
|
|
17
|
+
const digest = (0, multiformats_hashes_digest.create)(SHA256_CODE, new Uint8Array(hashBuffer));
|
|
18
|
+
return multiformats_cid.CID.createV1(multiformats_codecs_raw.code, digest).toString();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Compute the canonical `x-amz-checksum-sha256` value (`base64pad` of the
|
|
22
|
+
* 32-byte SHA-256 digest) directly from content — the SAME encoding
|
|
23
|
+
* {@link cidToChecksumSha256} derives from a CID. This lets the commit path
|
|
24
|
+
* verify a client-supplied inline copy against the session's stored
|
|
25
|
+
* `checksum_sha256` with ONE native SHA-256 and a byte compare, WITHOUT
|
|
26
|
+
* rebuilding a CID string or `CID.parse` (the digest-pre verify,
|
|
27
|
+
* inline-content-commit §5.1).
|
|
28
|
+
*
|
|
29
|
+
* The encoding MUST be `base64pad` (RFC4648 WITH padding) to land on the same
|
|
30
|
+
* alphabet as `cidToChecksumSha256` / the prepared session value — a no-pad
|
|
31
|
+
* `base64`/`base64url` would drop the trailing `=` and never match (a silent
|
|
32
|
+
* fail-closed that would drop every inline copy).
|
|
33
|
+
*/
|
|
34
|
+
async function checksumSha256OfContent(content) {
|
|
35
|
+
const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
36
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", bytes);
|
|
37
|
+
return multiformats_bases_base64.base64pad.baseEncode(new Uint8Array(hashBuffer));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Derive the canonical `x-amz-checksum-sha256` value (base64 of the 32-byte
|
|
41
|
+
* SHA-256 digest) from a DID Space CID — the bridge between content addressing
|
|
42
|
+
* and S3/R2 checksum enforcement (design §8).
|
|
43
|
+
*
|
|
44
|
+
* Accepts ONLY CIDv1 with raw codec (0x55) + SHA-256 multihash (0x12) — the
|
|
45
|
+
* exact shape `computeCID` produces. Any other codec/hash, or a malformed CID,
|
|
46
|
+
* is bad input and throws (the prepare-upload handler maps this to a validation
|
|
47
|
+
* error). The output is byte-equivalent to
|
|
48
|
+
* `base64(crypto.subtle.digest("SHA-256", bytes))`, which is what R2 expects in
|
|
49
|
+
* the pinned checksum header (P0-verified, p0-measurements.md §5).
|
|
50
|
+
*/
|
|
51
|
+
function cidToChecksumSha256(cid) {
|
|
52
|
+
let parsed;
|
|
53
|
+
try {
|
|
54
|
+
parsed = multiformats_cid.CID.parse(cid);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
throw new Error(`invalid CID: ${err instanceof Error ? err.message : String(err)}`);
|
|
57
|
+
}
|
|
58
|
+
if (parsed.code !== multiformats_codecs_raw.code) throw new Error(`CID codec must be raw (0x${multiformats_codecs_raw.code.toString(16)}), got 0x${parsed.code.toString(16)}`);
|
|
59
|
+
if (parsed.multihash.code !== SHA256_CODE) throw new Error(`CID hash must be sha256 (0x${SHA256_CODE.toString(16)}), got 0x${parsed.multihash.code.toString(16)}`);
|
|
60
|
+
const digest = parsed.multihash.digest;
|
|
61
|
+
if (digest.length !== 32) throw new Error(`sha256 digest must be 32 bytes, got ${digest.length}`);
|
|
62
|
+
return multiformats_bases_base64.base64pad.baseEncode(digest);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
exports.checksumSha256OfContent = checksumSha256OfContent;
|
|
67
|
+
exports.cidToChecksumSha256 = cidToChecksumSha256;
|
|
68
|
+
exports.computeCID = computeCID;
|
package/dist/cid.d.cts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/cid.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Compute a CID v1 (raw codec + SHA-256) for the given content.
|
|
4
|
+
* Uses Web Crypto API (crypto.subtle) — works in Workers, browsers, and Node.js 15+.
|
|
5
|
+
*/
|
|
6
|
+
declare function computeCID(content: string | Uint8Array): Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Derive the canonical `x-amz-checksum-sha256` value (base64 of the 32-byte
|
|
9
|
+
* SHA-256 digest) from a DID Space CID — the bridge between content addressing
|
|
10
|
+
* and S3/R2 checksum enforcement (design §8).
|
|
11
|
+
*
|
|
12
|
+
* Accepts ONLY CIDv1 with raw codec (0x55) + SHA-256 multihash (0x12) — the
|
|
13
|
+
* exact shape `computeCID` produces. Any other codec/hash, or a malformed CID,
|
|
14
|
+
* is bad input and throws (the prepare-upload handler maps this to a validation
|
|
15
|
+
* error). The output is byte-equivalent to
|
|
16
|
+
* `base64(crypto.subtle.digest("SHA-256", bytes))`, which is what R2 expects in
|
|
17
|
+
* the pinned checksum header (P0-verified, p0-measurements.md §5).
|
|
18
|
+
*/
|
|
19
|
+
declare function cidToChecksumSha256(cid: string): string;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { cidToChecksumSha256, computeCID };
|
|
22
|
+
//# sourceMappingURL=cid.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cid.d.cts","names":[],"sources":["../src/cid.ts"],"mappings":";;AAWA;;;iBAAsB,UAAA,CAAW,OAAA,WAAkB,UAAA,GAAa,OAAA;;;;;;;;;;;;;iBA2ChD,mBAAA,CAAoB,GAAA"}
|
package/dist/cid.d.mts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/cid.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Compute a CID v1 (raw codec + SHA-256) for the given content.
|
|
4
|
+
* Uses Web Crypto API (crypto.subtle) — works in Workers, browsers, and Node.js 15+.
|
|
5
|
+
*/
|
|
6
|
+
declare function computeCID(content: string | Uint8Array): Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Derive the canonical `x-amz-checksum-sha256` value (base64 of the 32-byte
|
|
9
|
+
* SHA-256 digest) from a DID Space CID — the bridge between content addressing
|
|
10
|
+
* and S3/R2 checksum enforcement (design §8).
|
|
11
|
+
*
|
|
12
|
+
* Accepts ONLY CIDv1 with raw codec (0x55) + SHA-256 multihash (0x12) — the
|
|
13
|
+
* exact shape `computeCID` produces. Any other codec/hash, or a malformed CID,
|
|
14
|
+
* is bad input and throws (the prepare-upload handler maps this to a validation
|
|
15
|
+
* error). The output is byte-equivalent to
|
|
16
|
+
* `base64(crypto.subtle.digest("SHA-256", bytes))`, which is what R2 expects in
|
|
17
|
+
* the pinned checksum header (P0-verified, p0-measurements.md §5).
|
|
18
|
+
*/
|
|
19
|
+
declare function cidToChecksumSha256(cid: string): string;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { cidToChecksumSha256, computeCID };
|
|
22
|
+
//# sourceMappingURL=cid.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cid.d.mts","names":[],"sources":["../src/cid.ts"],"mappings":";;AAWA;;;iBAAsB,UAAA,CAAW,OAAA,WAAkB,UAAA,GAAa,OAAA;;;;;;;;;;;;;iBA2ChD,mBAAA,CAAoB,GAAA"}
|
package/dist/cid.mjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { base64pad } from "multiformats/bases/base64";
|
|
2
|
+
import { CID } from "multiformats/cid";
|
|
3
|
+
import * as raw from "multiformats/codecs/raw";
|
|
4
|
+
import { create } from "multiformats/hashes/digest";
|
|
5
|
+
|
|
6
|
+
//#region src/cid.ts
|
|
7
|
+
const SHA256_CODE = 18;
|
|
8
|
+
/**
|
|
9
|
+
* Compute a CID v1 (raw codec + SHA-256) for the given content.
|
|
10
|
+
* Uses Web Crypto API (crypto.subtle) — works in Workers, browsers, and Node.js 15+.
|
|
11
|
+
*/
|
|
12
|
+
async function computeCID(content) {
|
|
13
|
+
const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
14
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", bytes);
|
|
15
|
+
const digest = create(SHA256_CODE, new Uint8Array(hashBuffer));
|
|
16
|
+
return CID.createV1(raw.code, digest).toString();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Compute the canonical `x-amz-checksum-sha256` value (`base64pad` of the
|
|
20
|
+
* 32-byte SHA-256 digest) directly from content — the SAME encoding
|
|
21
|
+
* {@link cidToChecksumSha256} derives from a CID. This lets the commit path
|
|
22
|
+
* verify a client-supplied inline copy against the session's stored
|
|
23
|
+
* `checksum_sha256` with ONE native SHA-256 and a byte compare, WITHOUT
|
|
24
|
+
* rebuilding a CID string or `CID.parse` (the digest-pre verify,
|
|
25
|
+
* inline-content-commit §5.1).
|
|
26
|
+
*
|
|
27
|
+
* The encoding MUST be `base64pad` (RFC4648 WITH padding) to land on the same
|
|
28
|
+
* alphabet as `cidToChecksumSha256` / the prepared session value — a no-pad
|
|
29
|
+
* `base64`/`base64url` would drop the trailing `=` and never match (a silent
|
|
30
|
+
* fail-closed that would drop every inline copy).
|
|
31
|
+
*/
|
|
32
|
+
async function checksumSha256OfContent(content) {
|
|
33
|
+
const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
34
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", bytes);
|
|
35
|
+
return base64pad.baseEncode(new Uint8Array(hashBuffer));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Derive the canonical `x-amz-checksum-sha256` value (base64 of the 32-byte
|
|
39
|
+
* SHA-256 digest) from a DID Space CID — the bridge between content addressing
|
|
40
|
+
* and S3/R2 checksum enforcement (design §8).
|
|
41
|
+
*
|
|
42
|
+
* Accepts ONLY CIDv1 with raw codec (0x55) + SHA-256 multihash (0x12) — the
|
|
43
|
+
* exact shape `computeCID` produces. Any other codec/hash, or a malformed CID,
|
|
44
|
+
* is bad input and throws (the prepare-upload handler maps this to a validation
|
|
45
|
+
* error). The output is byte-equivalent to
|
|
46
|
+
* `base64(crypto.subtle.digest("SHA-256", bytes))`, which is what R2 expects in
|
|
47
|
+
* the pinned checksum header (P0-verified, p0-measurements.md §5).
|
|
48
|
+
*/
|
|
49
|
+
function cidToChecksumSha256(cid) {
|
|
50
|
+
let parsed;
|
|
51
|
+
try {
|
|
52
|
+
parsed = CID.parse(cid);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
throw new Error(`invalid CID: ${err instanceof Error ? err.message : String(err)}`);
|
|
55
|
+
}
|
|
56
|
+
if (parsed.code !== raw.code) throw new Error(`CID codec must be raw (0x${raw.code.toString(16)}), got 0x${parsed.code.toString(16)}`);
|
|
57
|
+
if (parsed.multihash.code !== SHA256_CODE) throw new Error(`CID hash must be sha256 (0x${SHA256_CODE.toString(16)}), got 0x${parsed.multihash.code.toString(16)}`);
|
|
58
|
+
const digest = parsed.multihash.digest;
|
|
59
|
+
if (digest.length !== 32) throw new Error(`sha256 digest must be 32 bytes, got ${digest.length}`);
|
|
60
|
+
return base64pad.baseEncode(digest);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { checksumSha256OfContent, cidToChecksumSha256, computeCID };
|
|
65
|
+
//# sourceMappingURL=cid.mjs.map
|
package/dist/cid.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cid.mjs","names":["createDigest"],"sources":["../src/cid.ts"],"sourcesContent":["import { base64pad } from \"multiformats/bases/base64\";\nimport { CID } from \"multiformats/cid\";\nimport * as raw from \"multiformats/codecs/raw\";\nimport { create as createDigest } from \"multiformats/hashes/digest\";\n\nconst SHA256_CODE = 0x12;\n\n/**\n * Compute a CID v1 (raw codec + SHA-256) for the given content.\n * Uses Web Crypto API (crypto.subtle) — works in Workers, browsers, and Node.js 15+.\n */\nexport async function computeCID(content: string | Uint8Array): Promise<string> {\n const bytes = typeof content === \"string\" ? new TextEncoder().encode(content) : content;\n // Pass Uint8Array directly — NOT bytes.buffer — to avoid hashing the entire\n // underlying ArrayBuffer when bytes is a view into a Node.js Buffer pool.\n const hashBuffer = await crypto.subtle.digest(\"SHA-256\", bytes as unknown as ArrayBuffer);\n const digest = createDigest(SHA256_CODE, new Uint8Array(hashBuffer));\n return CID.createV1(raw.code, digest).toString();\n}\n\n/**\n * Compute the canonical `x-amz-checksum-sha256` value (`base64pad` of the\n * 32-byte SHA-256 digest) directly from content — the SAME encoding\n * {@link cidToChecksumSha256} derives from a CID. This lets the commit path\n * verify a client-supplied inline copy against the session's stored\n * `checksum_sha256` with ONE native SHA-256 and a byte compare, WITHOUT\n * rebuilding a CID string or `CID.parse` (the digest-pre verify,\n * inline-content-commit §5.1).\n *\n * The encoding MUST be `base64pad` (RFC4648 WITH padding) to land on the same\n * alphabet as `cidToChecksumSha256` / the prepared session value — a no-pad\n * `base64`/`base64url` would drop the trailing `=` and never match (a silent\n * fail-closed that would drop every inline copy).\n */\nexport async function checksumSha256OfContent(content: string | Uint8Array): Promise<string> {\n const bytes = typeof content === \"string\" ? new TextEncoder().encode(content) : content;\n // Pass the Uint8Array view directly (NOT bytes.buffer) — same Buffer-pool\n // caveat as computeCID.\n const hashBuffer = await crypto.subtle.digest(\"SHA-256\", bytes as unknown as ArrayBuffer);\n return base64pad.baseEncode(new Uint8Array(hashBuffer));\n}\n\n/**\n * Derive the canonical `x-amz-checksum-sha256` value (base64 of the 32-byte\n * SHA-256 digest) from a DID Space CID — the bridge between content addressing\n * and S3/R2 checksum enforcement (design §8).\n *\n * Accepts ONLY CIDv1 with raw codec (0x55) + SHA-256 multihash (0x12) — the\n * exact shape `computeCID` produces. Any other codec/hash, or a malformed CID,\n * is bad input and throws (the prepare-upload handler maps this to a validation\n * error). The output is byte-equivalent to\n * `base64(crypto.subtle.digest(\"SHA-256\", bytes))`, which is what R2 expects in\n * the pinned checksum header (P0-verified, p0-measurements.md §5).\n */\nexport function cidToChecksumSha256(cid: string): string {\n let parsed: CID;\n try {\n parsed = CID.parse(cid);\n } catch (err) {\n throw new Error(`invalid CID: ${err instanceof Error ? err.message : String(err)}`);\n }\n if (parsed.code !== raw.code) {\n throw new Error(\n `CID codec must be raw (0x${raw.code.toString(16)}), got 0x${parsed.code.toString(16)}`,\n );\n }\n if (parsed.multihash.code !== SHA256_CODE) {\n throw new Error(\n `CID hash must be sha256 (0x${SHA256_CODE.toString(16)}), got 0x${parsed.multihash.code.toString(16)}`,\n );\n }\n const digest = parsed.multihash.digest;\n if (digest.length !== 32) {\n throw new Error(`sha256 digest must be 32 bytes, got ${digest.length}`);\n }\n // `base64pad` is RFC4648 base64 WITH padding; `baseEncode` yields the raw\n // alphabet with no multibase prefix — byte-equivalent to Node's\n // `Buffer.toString(\"base64\")` and to what R2 expects in x-amz-checksum-sha256\n // (the no-pad `base64` variant would drop the trailing \"=\" and fail).\n return base64pad.baseEncode(digest);\n}\n"],"mappings":";;;;;;AAKA,MAAM,cAAc;;;;;AAMpB,eAAsB,WAAW,SAA+C;CAC9E,MAAM,QAAQ,OAAO,YAAY,WAAW,IAAI,aAAa,CAAC,OAAO,QAAQ,GAAG;CAGhF,MAAM,aAAa,MAAM,OAAO,OAAO,OAAO,WAAW,MAAgC;CACzF,MAAM,SAASA,OAAa,aAAa,IAAI,WAAW,WAAW,CAAC;AACpE,QAAO,IAAI,SAAS,IAAI,MAAM,OAAO,CAAC,UAAU;;;;;;;;;;;;;;;;AAiBlD,eAAsB,wBAAwB,SAA+C;CAC3F,MAAM,QAAQ,OAAO,YAAY,WAAW,IAAI,aAAa,CAAC,OAAO,QAAQ,GAAG;CAGhF,MAAM,aAAa,MAAM,OAAO,OAAO,OAAO,WAAW,MAAgC;AACzF,QAAO,UAAU,WAAW,IAAI,WAAW,WAAW,CAAC;;;;;;;;;;;;;;AAezD,SAAgB,oBAAoB,KAAqB;CACvD,IAAI;AACJ,KAAI;AACF,WAAS,IAAI,MAAM,IAAI;UAChB,KAAK;AACZ,QAAM,IAAI,MAAM,gBAAgB,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAAG;;AAErF,KAAI,OAAO,SAAS,IAAI,KACtB,OAAM,IAAI,MACR,4BAA4B,IAAI,KAAK,SAAS,GAAG,CAAC,WAAW,OAAO,KAAK,SAAS,GAAG,GACtF;AAEH,KAAI,OAAO,UAAU,SAAS,YAC5B,OAAM,IAAI,MACR,8BAA8B,YAAY,SAAS,GAAG,CAAC,WAAW,OAAO,UAAU,KAAK,SAAS,GAAG,GACrG;CAEH,MAAM,SAAS,OAAO,UAAU;AAChC,KAAI,OAAO,WAAW,GACpB,OAAM,IAAI,MAAM,uCAAuC,OAAO,SAAS;AAMzE,QAAO,UAAU,WAAW,OAAO"}
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_http = require('./transports/http.cjs');
|
|
3
|
+
const require_static = require('./transports/static.cjs');
|
|
4
|
+
const require_types = require('./transports/types.cjs');
|
|
5
|
+
const require_ws = require('./transports/ws.cjs');
|
|
6
|
+
let _aigne_afs_provider = require("@aigne/afs/provider");
|
|
7
|
+
|
|
8
|
+
//#region src/client.ts
|
|
9
|
+
const FORWARDED_OPERATIONS = [
|
|
10
|
+
"list",
|
|
11
|
+
"read",
|
|
12
|
+
"write",
|
|
13
|
+
"delete",
|
|
14
|
+
"stat",
|
|
15
|
+
"search",
|
|
16
|
+
"exec",
|
|
17
|
+
"explain"
|
|
18
|
+
];
|
|
19
|
+
const REQUIRED_TRANSPORT_METHODS = [
|
|
20
|
+
"list",
|
|
21
|
+
"read",
|
|
22
|
+
"write",
|
|
23
|
+
"delete",
|
|
24
|
+
"stat",
|
|
25
|
+
"search",
|
|
26
|
+
"exec",
|
|
27
|
+
"explain"
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* Implement {@link AFSEventFilter}'s wildcard match for `type`. Mirrors the
|
|
31
|
+
* helper used by the core event router: `"test:*"` matches `"test:anything"`,
|
|
32
|
+
* everything else is an exact compare.
|
|
33
|
+
*/
|
|
34
|
+
function matchEventType(eventType, filterType) {
|
|
35
|
+
if (filterType.endsWith(":*")) return eventType.startsWith(filterType.slice(0, -1));
|
|
36
|
+
return eventType === filterType;
|
|
37
|
+
}
|
|
38
|
+
function assertTransportShape(transport) {
|
|
39
|
+
if (!transport || typeof transport !== "object") throw new Error("DIDSpaceClient: transport is required");
|
|
40
|
+
if (!require_types.isTransportKind(transport.kind)) throw new Error(`DIDSpaceClient: transport.kind must be 'http' | 'ws' | 'static-readonly' (got: ${String(transport.kind)})`);
|
|
41
|
+
for (const method of REQUIRED_TRANSPORT_METHODS) if (typeof transport[method] !== "function") throw new Error(`DIDSpaceClient: transport is missing required method: ${method}`);
|
|
42
|
+
}
|
|
43
|
+
var DIDSpaceClient = class extends _aigne_afs_provider.AFSBaseProvider {
|
|
44
|
+
name;
|
|
45
|
+
description;
|
|
46
|
+
accessMode;
|
|
47
|
+
transport;
|
|
48
|
+
constructor(options) {
|
|
49
|
+
super();
|
|
50
|
+
assertTransportShape(options.transport);
|
|
51
|
+
this.transport = options.transport;
|
|
52
|
+
this.name = options.name ?? "did-space-client";
|
|
53
|
+
this.description = options.description;
|
|
54
|
+
this.accessMode = options.accessMode ?? (this.transport.kind === "static-readonly" ? "readonly" : "readwrite");
|
|
55
|
+
const unsupported = this.unsupportedOps();
|
|
56
|
+
for (const op of FORWARDED_OPERATIONS) {
|
|
57
|
+
if (unsupported.has(op)) continue;
|
|
58
|
+
delete this[op];
|
|
59
|
+
}
|
|
60
|
+
if (this.accessMode === "readonly") {
|
|
61
|
+
this.write = void 0;
|
|
62
|
+
this.delete = void 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Operations the transport is known *not* to support (e.g. HTTP REST
|
|
67
|
+
* does not expose stat/search/exec/explain). Used at construction time
|
|
68
|
+
* to keep those methods `undefined` so AFS routing knows.
|
|
69
|
+
*/
|
|
70
|
+
unsupportedOps() {
|
|
71
|
+
const set = /* @__PURE__ */ new Set();
|
|
72
|
+
if (this.transport.kind === "http") {
|
|
73
|
+
set.add("stat");
|
|
74
|
+
set.add("search");
|
|
75
|
+
set.add("exec");
|
|
76
|
+
set.add("explain");
|
|
77
|
+
} else if (this.transport.kind === "static-readonly") {
|
|
78
|
+
set.add("search");
|
|
79
|
+
set.add("exec");
|
|
80
|
+
}
|
|
81
|
+
return set;
|
|
82
|
+
}
|
|
83
|
+
list(path, options) {
|
|
84
|
+
return this.transport.list(path, options);
|
|
85
|
+
}
|
|
86
|
+
read(path, options) {
|
|
87
|
+
return this.transport.read(path, options);
|
|
88
|
+
}
|
|
89
|
+
write(path, payload, options) {
|
|
90
|
+
return this.transport.write(path, payload, options);
|
|
91
|
+
}
|
|
92
|
+
delete(path, options) {
|
|
93
|
+
return this.transport.delete(path, options);
|
|
94
|
+
}
|
|
95
|
+
stat(path, options) {
|
|
96
|
+
return this.transport.stat(path, options);
|
|
97
|
+
}
|
|
98
|
+
search(path, query, options) {
|
|
99
|
+
return this.transport.search(path, query, options);
|
|
100
|
+
}
|
|
101
|
+
exec(path, args, options) {
|
|
102
|
+
return this.transport.exec(path, args, options);
|
|
103
|
+
}
|
|
104
|
+
explain(path, options) {
|
|
105
|
+
return this.transport.explain(path, options);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Subscribe to push events from the transport. Only WS supports this today.
|
|
109
|
+
*
|
|
110
|
+
* Conforms to `AFSRoot.subscribe(filter, callback)` so this provider can be
|
|
111
|
+
* mounted via `MaterializedMount` like any other. The underlying transport's
|
|
112
|
+
* subscribe is path-based and async, so:
|
|
113
|
+
* - `filter.path` is mapped to the transport's `path` argument (only the
|
|
114
|
+
* path dimension of {@link AFSEventFilter} is honored today; other
|
|
115
|
+
* filter dimensions are applied client-side in the wrapped callback)
|
|
116
|
+
* - the async `Promise<Unsubscribe>` returned by the transport is bridged
|
|
117
|
+
* to a sync {@link AFSUnsubscribe} that cancels whether or not the
|
|
118
|
+
* underlying subscribe has resolved yet
|
|
119
|
+
*/
|
|
120
|
+
subscribe(filter, callback) {
|
|
121
|
+
if (typeof this.transport.subscribe !== "function") throw new Error(`DIDSpaceClient: transport (${this.transport.kind}) does not support subscribe`);
|
|
122
|
+
const path = filter.path ?? "/";
|
|
123
|
+
const matches = (event) => {
|
|
124
|
+
if (filter.type !== void 0 && !matchEventType(event.type, filter.type)) return false;
|
|
125
|
+
if (filter.scope !== void 0 && event.scope !== filter.scope) return false;
|
|
126
|
+
if (filter.source !== void 0 && event.source !== filter.source) return false;
|
|
127
|
+
return true;
|
|
128
|
+
};
|
|
129
|
+
let cancelled = false;
|
|
130
|
+
let unsubscribe;
|
|
131
|
+
this.transport.subscribe(path, (event) => {
|
|
132
|
+
if (cancelled) return;
|
|
133
|
+
if (!matches(event)) return;
|
|
134
|
+
callback(event);
|
|
135
|
+
}).then((fn) => {
|
|
136
|
+
if (cancelled) {
|
|
137
|
+
fn();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
unsubscribe = fn;
|
|
141
|
+
}).catch(() => {});
|
|
142
|
+
return () => {
|
|
143
|
+
cancelled = true;
|
|
144
|
+
if (unsubscribe) unsubscribe();
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** Tear down the underlying transport (idempotent). */
|
|
148
|
+
async close() {
|
|
149
|
+
if (typeof this.transport.close === "function") await this.transport.close();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const UNSAFE_SCHEMES = new Set([
|
|
153
|
+
"file:",
|
|
154
|
+
"javascript:",
|
|
155
|
+
"data:",
|
|
156
|
+
"ftp:"
|
|
157
|
+
]);
|
|
158
|
+
function assertSafeUrl(rawUrl) {
|
|
159
|
+
let parsed;
|
|
160
|
+
try {
|
|
161
|
+
parsed = new URL(rawUrl);
|
|
162
|
+
} catch {
|
|
163
|
+
throw new Error(`connectDIDSpace: invalid URL: ${rawUrl}`);
|
|
164
|
+
}
|
|
165
|
+
if (UNSAFE_SCHEMES.has(parsed.protocol)) throw new Error(`connectDIDSpace: refusing unsafe URL scheme '${parsed.protocol}'`);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Construct a ready-to-mount {@link DIDSpaceClient} from a transport
|
|
169
|
+
* config. For long-lived transports (WS) the underlying connection is
|
|
170
|
+
* established before the client is returned.
|
|
171
|
+
*/
|
|
172
|
+
async function connectDIDSpace(options) {
|
|
173
|
+
const cfg = options.transport;
|
|
174
|
+
if (!cfg || typeof cfg !== "object") throw new Error("connectDIDSpace: options.transport is required");
|
|
175
|
+
if (!require_types.isTransportKind(cfg.kind)) throw new Error(`connectDIDSpace: unknown transport kind '${String(cfg.kind)}' (expected 'http' | 'ws' | 'static-readonly')`);
|
|
176
|
+
let transport;
|
|
177
|
+
switch (cfg.kind) {
|
|
178
|
+
case "http":
|
|
179
|
+
if (!cfg.url) throw new Error("connectDIDSpace: http transport requires url");
|
|
180
|
+
if (!cfg.token) throw new Error("connectDIDSpace: http transport requires token");
|
|
181
|
+
assertSafeUrl(cfg.url);
|
|
182
|
+
transport = new require_http.HttpTransport({
|
|
183
|
+
url: cfg.url,
|
|
184
|
+
token: cfg.token
|
|
185
|
+
});
|
|
186
|
+
break;
|
|
187
|
+
case "ws": {
|
|
188
|
+
if (!cfg.url) throw new Error("connectDIDSpace: ws transport requires url");
|
|
189
|
+
if (!cfg.token) throw new Error("connectDIDSpace: ws transport requires token");
|
|
190
|
+
assertSafeUrl(cfg.url);
|
|
191
|
+
const ws = new require_ws.WsTransport({
|
|
192
|
+
url: cfg.url,
|
|
193
|
+
token: cfg.token,
|
|
194
|
+
namespace: cfg.namespace,
|
|
195
|
+
requestTimeout: cfg.requestTimeout
|
|
196
|
+
});
|
|
197
|
+
await ws.connect();
|
|
198
|
+
transport = ws;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case "static-readonly":
|
|
202
|
+
if (!cfg.url) throw new Error("connectDIDSpace: static-readonly transport requires url");
|
|
203
|
+
assertSafeUrl(cfg.url);
|
|
204
|
+
transport = new require_static.StaticReadonlyTransport({
|
|
205
|
+
url: cfg.url,
|
|
206
|
+
token: cfg.token,
|
|
207
|
+
allowPrivateNetwork: cfg.allowPrivateNetwork
|
|
208
|
+
});
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
return new DIDSpaceClient({
|
|
212
|
+
transport,
|
|
213
|
+
name: options.name,
|
|
214
|
+
description: options.description,
|
|
215
|
+
accessMode: options.accessMode
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
exports.DIDSpaceClient = DIDSpaceClient;
|
|
221
|
+
exports.connectDIDSpace = connectDIDSpace;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Transport, TransportConfig } from "./transports/types.cjs";
|
|
2
|
+
import { AFSAccessMode, AFSDeleteOptions, AFSDeleteResult, AFSEventCallback, AFSEventFilter, AFSExecOptions, AFSExecResult, AFSExplainOptions, AFSExplainResult, AFSListOptions, AFSListResult, AFSReadOptions, AFSReadResult, AFSSearchOptions, AFSSearchResult, AFSStatOptions, AFSStatResult, AFSUnsubscribe, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult } from "@aigne/afs";
|
|
3
|
+
import { AFSBaseProvider } from "@aigne/afs/provider";
|
|
4
|
+
|
|
5
|
+
//#region src/client.d.ts
|
|
6
|
+
interface DIDSpaceClientOptions {
|
|
7
|
+
transport: Transport;
|
|
8
|
+
/** Optional name for the mount; default `did-space-client`. */
|
|
9
|
+
name?: string;
|
|
10
|
+
/** Optional description. */
|
|
11
|
+
description?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Override the access mode. Defaults to `readonly` for
|
|
14
|
+
* `static-readonly` transports, `readwrite` for the others.
|
|
15
|
+
*/
|
|
16
|
+
accessMode?: AFSAccessMode;
|
|
17
|
+
}
|
|
18
|
+
declare class DIDSpaceClient extends AFSBaseProvider {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly description?: string;
|
|
21
|
+
readonly accessMode: AFSAccessMode;
|
|
22
|
+
private readonly transport;
|
|
23
|
+
constructor(options: DIDSpaceClientOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Operations the transport is known *not* to support (e.g. HTTP REST
|
|
26
|
+
* does not expose stat/search/exec/explain). Used at construction time
|
|
27
|
+
* to keep those methods `undefined` so AFS routing knows.
|
|
28
|
+
*/
|
|
29
|
+
private unsupportedOps;
|
|
30
|
+
list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
|
|
31
|
+
read(path: string, options?: AFSReadOptions): Promise<AFSReadResult>;
|
|
32
|
+
write(path: string, payload: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
|
|
33
|
+
delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
|
|
34
|
+
stat(path: string, options?: AFSStatOptions): Promise<AFSStatResult>;
|
|
35
|
+
search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
|
|
36
|
+
exec(path: string, args: Record<string, unknown>, options: AFSExecOptions): Promise<AFSExecResult>;
|
|
37
|
+
explain(path: string, options?: AFSExplainOptions): Promise<AFSExplainResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Subscribe to push events from the transport. Only WS supports this today.
|
|
40
|
+
*
|
|
41
|
+
* Conforms to `AFSRoot.subscribe(filter, callback)` so this provider can be
|
|
42
|
+
* mounted via `MaterializedMount` like any other. The underlying transport's
|
|
43
|
+
* subscribe is path-based and async, so:
|
|
44
|
+
* - `filter.path` is mapped to the transport's `path` argument (only the
|
|
45
|
+
* path dimension of {@link AFSEventFilter} is honored today; other
|
|
46
|
+
* filter dimensions are applied client-side in the wrapped callback)
|
|
47
|
+
* - the async `Promise<Unsubscribe>` returned by the transport is bridged
|
|
48
|
+
* to a sync {@link AFSUnsubscribe} that cancels whether or not the
|
|
49
|
+
* underlying subscribe has resolved yet
|
|
50
|
+
*/
|
|
51
|
+
subscribe(filter: AFSEventFilter, callback: AFSEventCallback): AFSUnsubscribe;
|
|
52
|
+
/** Tear down the underlying transport (idempotent). */
|
|
53
|
+
close(): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
interface ConnectDIDSpaceOptions {
|
|
56
|
+
transport: TransportConfig;
|
|
57
|
+
/** See `DIDSpaceClientOptions.name`. */
|
|
58
|
+
name?: string;
|
|
59
|
+
/** See `DIDSpaceClientOptions.description`. */
|
|
60
|
+
description?: string;
|
|
61
|
+
/** See `DIDSpaceClientOptions.accessMode`. */
|
|
62
|
+
accessMode?: AFSAccessMode;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Construct a ready-to-mount {@link DIDSpaceClient} from a transport
|
|
66
|
+
* config. For long-lived transports (WS) the underlying connection is
|
|
67
|
+
* established before the client is returned.
|
|
68
|
+
*/
|
|
69
|
+
declare function connectDIDSpace(options: ConnectDIDSpaceOptions): Promise<DIDSpaceClient>;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { ConnectDIDSpaceOptions, DIDSpaceClient, DIDSpaceClientOptions, connectDIDSpace };
|
|
72
|
+
//# sourceMappingURL=client.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.cts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;UA0HiB,qBAAA;EACf,SAAA,EAAW,SAAA;EAwFgD;EAtF3D,IAAA;EA0F+D;EAxF/D,WAAA;EA+FY;;;;EA1FZ,UAAA,GAAa,aAAA;AAAA;AAAA,cAGF,cAAA,SAAuB,eAAA;EAAA,SAChB,IAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA,EAAY,aAAA;EAAA,iBACb,SAAA;cAEL,OAAA,EAAS,qBAAA;EA+G0C;;;;;EAAA,QA3EvD,cAAA;EAkBC,IAAA,CAAK,IAAA,UAAc,OAAA,GAAU,cAAA,GAAiB,OAAA,CAAQ,aAAA;EAItD,IAAA,CAAK,IAAA,UAAc,OAAA,GAAU,cAAA,GAAiB,OAAA,CAAQ,aAAA;EAItD,KAAA,CACP,IAAA,UACA,OAAA,EAAS,oBAAA,EACT,OAAA,GAAU,eAAA,GACT,OAAA,CAAQ,cAAA;EAIF,MAAA,CAAO,IAAA,UAAc,OAAA,GAAU,gBAAA,GAAmB,OAAA,CAAQ,eAAA;EAI1D,IAAA,CAAK,IAAA,UAAc,OAAA,GAAU,cAAA,GAAiB,OAAA,CAAQ,aAAA;EAItD,MAAA,CACP,IAAA,UACA,KAAA,UACA,OAAA,GAAU,gBAAA,GACT,OAAA,CAAQ,eAAA;EAIF,IAAA,CACP,IAAA,UACA,IAAA,EAAM,MAAA,mBACN,OAAA,EAAS,cAAA,GACR,OAAA,CAAQ,aAAA;EAIF,OAAA,CAAQ,IAAA,UAAc,OAAA,GAAU,iBAAA,GAAoB,OAAA,CAAQ,gBAAA;EA1D7D;;;;;;;;;;;;;EA2ER,SAAA,CAAU,MAAA,EAAQ,cAAA,EAAgB,QAAA,EAAU,gBAAA,GAAmB,cAAA;EAhD7D;EAyFI,KAAA,CAAA,GAAS,OAAA;AAAA;AAAA,UAWA,sBAAA;EACf,SAAA,EAAW,eAAA;EAlGR;EAoGH,IAAA;EAhGS;EAkGT,WAAA;EAlGwC;EAoGxC,UAAA,GAAa,aAAA;AAAA;;;;;;iBAsBO,eAAA,CAAgB,OAAA,EAAS,sBAAA,GAAyB,OAAA,CAAQ,cAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Transport, TransportConfig } from "./transports/types.mjs";
|
|
2
|
+
import { AFSAccessMode, AFSDeleteOptions, AFSDeleteResult, AFSEventCallback, AFSEventFilter, AFSExecOptions, AFSExecResult, AFSExplainOptions, AFSExplainResult, AFSListOptions, AFSListResult, AFSReadOptions, AFSReadResult, AFSSearchOptions, AFSSearchResult, AFSStatOptions, AFSStatResult, AFSUnsubscribe, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult } from "@aigne/afs";
|
|
3
|
+
import { AFSBaseProvider } from "@aigne/afs/provider";
|
|
4
|
+
|
|
5
|
+
//#region src/client.d.ts
|
|
6
|
+
interface DIDSpaceClientOptions {
|
|
7
|
+
transport: Transport;
|
|
8
|
+
/** Optional name for the mount; default `did-space-client`. */
|
|
9
|
+
name?: string;
|
|
10
|
+
/** Optional description. */
|
|
11
|
+
description?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Override the access mode. Defaults to `readonly` for
|
|
14
|
+
* `static-readonly` transports, `readwrite` for the others.
|
|
15
|
+
*/
|
|
16
|
+
accessMode?: AFSAccessMode;
|
|
17
|
+
}
|
|
18
|
+
declare class DIDSpaceClient extends AFSBaseProvider {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly description?: string;
|
|
21
|
+
readonly accessMode: AFSAccessMode;
|
|
22
|
+
private readonly transport;
|
|
23
|
+
constructor(options: DIDSpaceClientOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Operations the transport is known *not* to support (e.g. HTTP REST
|
|
26
|
+
* does not expose stat/search/exec/explain). Used at construction time
|
|
27
|
+
* to keep those methods `undefined` so AFS routing knows.
|
|
28
|
+
*/
|
|
29
|
+
private unsupportedOps;
|
|
30
|
+
list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
|
|
31
|
+
read(path: string, options?: AFSReadOptions): Promise<AFSReadResult>;
|
|
32
|
+
write(path: string, payload: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
|
|
33
|
+
delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
|
|
34
|
+
stat(path: string, options?: AFSStatOptions): Promise<AFSStatResult>;
|
|
35
|
+
search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
|
|
36
|
+
exec(path: string, args: Record<string, unknown>, options: AFSExecOptions): Promise<AFSExecResult>;
|
|
37
|
+
explain(path: string, options?: AFSExplainOptions): Promise<AFSExplainResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Subscribe to push events from the transport. Only WS supports this today.
|
|
40
|
+
*
|
|
41
|
+
* Conforms to `AFSRoot.subscribe(filter, callback)` so this provider can be
|
|
42
|
+
* mounted via `MaterializedMount` like any other. The underlying transport's
|
|
43
|
+
* subscribe is path-based and async, so:
|
|
44
|
+
* - `filter.path` is mapped to the transport's `path` argument (only the
|
|
45
|
+
* path dimension of {@link AFSEventFilter} is honored today; other
|
|
46
|
+
* filter dimensions are applied client-side in the wrapped callback)
|
|
47
|
+
* - the async `Promise<Unsubscribe>` returned by the transport is bridged
|
|
48
|
+
* to a sync {@link AFSUnsubscribe} that cancels whether or not the
|
|
49
|
+
* underlying subscribe has resolved yet
|
|
50
|
+
*/
|
|
51
|
+
subscribe(filter: AFSEventFilter, callback: AFSEventCallback): AFSUnsubscribe;
|
|
52
|
+
/** Tear down the underlying transport (idempotent). */
|
|
53
|
+
close(): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
interface ConnectDIDSpaceOptions {
|
|
56
|
+
transport: TransportConfig;
|
|
57
|
+
/** See `DIDSpaceClientOptions.name`. */
|
|
58
|
+
name?: string;
|
|
59
|
+
/** See `DIDSpaceClientOptions.description`. */
|
|
60
|
+
description?: string;
|
|
61
|
+
/** See `DIDSpaceClientOptions.accessMode`. */
|
|
62
|
+
accessMode?: AFSAccessMode;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Construct a ready-to-mount {@link DIDSpaceClient} from a transport
|
|
66
|
+
* config. For long-lived transports (WS) the underlying connection is
|
|
67
|
+
* established before the client is returned.
|
|
68
|
+
*/
|
|
69
|
+
declare function connectDIDSpace(options: ConnectDIDSpaceOptions): Promise<DIDSpaceClient>;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { ConnectDIDSpaceOptions, DIDSpaceClient, DIDSpaceClientOptions, connectDIDSpace };
|
|
72
|
+
//# sourceMappingURL=client.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;UA0HiB,qBAAA;EACf,SAAA,EAAW,SAAA;EAwFgD;EAtF3D,IAAA;EA0F+D;EAxF/D,WAAA;EA+FY;;;;EA1FZ,UAAA,GAAa,aAAA;AAAA;AAAA,cAGF,cAAA,SAAuB,eAAA;EAAA,SAChB,IAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA,EAAY,aAAA;EAAA,iBACb,SAAA;cAEL,OAAA,EAAS,qBAAA;EA+G0C;;;;;EAAA,QA3EvD,cAAA;EAkBC,IAAA,CAAK,IAAA,UAAc,OAAA,GAAU,cAAA,GAAiB,OAAA,CAAQ,aAAA;EAItD,IAAA,CAAK,IAAA,UAAc,OAAA,GAAU,cAAA,GAAiB,OAAA,CAAQ,aAAA;EAItD,KAAA,CACP,IAAA,UACA,OAAA,EAAS,oBAAA,EACT,OAAA,GAAU,eAAA,GACT,OAAA,CAAQ,cAAA;EAIF,MAAA,CAAO,IAAA,UAAc,OAAA,GAAU,gBAAA,GAAmB,OAAA,CAAQ,eAAA;EAI1D,IAAA,CAAK,IAAA,UAAc,OAAA,GAAU,cAAA,GAAiB,OAAA,CAAQ,aAAA;EAItD,MAAA,CACP,IAAA,UACA,KAAA,UACA,OAAA,GAAU,gBAAA,GACT,OAAA,CAAQ,eAAA;EAIF,IAAA,CACP,IAAA,UACA,IAAA,EAAM,MAAA,mBACN,OAAA,EAAS,cAAA,GACR,OAAA,CAAQ,aAAA;EAIF,OAAA,CAAQ,IAAA,UAAc,OAAA,GAAU,iBAAA,GAAoB,OAAA,CAAQ,gBAAA;EA1D7D;;;;;;;;;;;;;EA2ER,SAAA,CAAU,MAAA,EAAQ,cAAA,EAAgB,QAAA,EAAU,gBAAA,GAAmB,cAAA;EAhD7D;EAyFI,KAAA,CAAA,GAAS,OAAA;AAAA;AAAA,UAWA,sBAAA;EACf,SAAA,EAAW,eAAA;EAlGR;EAoGH,IAAA;EAhGS;EAkGT,WAAA;EAlGwC;EAoGxC,UAAA,GAAa,aAAA;AAAA;;;;;;iBAsBO,eAAA,CAAgB,OAAA,EAAS,sBAAA,GAAyB,OAAA,CAAQ,cAAA"}
|