@ref0/git 0.0.0 → 0.3.0
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/dist/LICENSE +202 -0
- package/dist/access/private-refs.d.mts +27 -0
- package/dist/access/private-refs.mjs +173 -0
- package/dist/access.d.mts +2 -0
- package/dist/access.mjs +1 -0
- package/dist/auth/access-jwt.d.mts +21 -0
- package/dist/auth/access-jwt.mjs +102 -0
- package/dist/auth/acting.mjs +15 -0
- package/dist/auth/authorize.d.mts +5 -0
- package/dist/auth/authorize.mjs +292 -0
- package/dist/auth/credentials.mjs +57 -0
- package/dist/auth/fences.d.mts +5 -0
- package/dist/auth/fences.mjs +65 -0
- package/dist/auth/grants.mjs +61 -0
- package/dist/auth/helpers.d.mts +17 -0
- package/dist/auth/helpers.mjs +25 -0
- package/dist/auth/host-function.d.mts +4 -0
- package/dist/auth/host-function.mjs +69 -0
- package/dist/auth/identify.d.mts +6 -0
- package/dist/auth/identify.mjs +97 -0
- package/dist/auth/token-rows.mjs +100 -0
- package/dist/auth/token-text.mjs +66 -0
- package/dist/auth/tokens.d.mts +10 -0
- package/dist/auth/tokens.mjs +347 -0
- package/dist/auth.d.mts +7 -0
- package/dist/auth.mjs +6 -0
- package/dist/client/answer.mjs +141 -0
- package/dist/client/client.d.mts +23 -0
- package/dist/client/client.mjs +50 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +170 -0
- package/dist/client/negotiate.mjs +170 -0
- package/dist/client/push-upload.mjs +53 -0
- package/dist/client/remote-helper.mjs +129 -0
- package/dist/client/remote.mjs +398 -0
- package/dist/client/run-remote-helper.d.mts +35 -0
- package/dist/client/run-remote-helper.mjs +259 -0
- package/dist/client/scrub.d.mts +18 -0
- package/dist/client/scrub.mjs +38 -0
- package/dist/client/transport.d.mts +2 -0
- package/dist/client/transport.mjs +211 -0
- package/dist/contracts/access.d.mts +87 -0
- package/dist/contracts/actors.d.mts +144 -0
- package/dist/contracts/blobs.d.mts +38 -0
- package/dist/contracts/calls-spent.d.mts +11 -0
- package/dist/contracts/calls-spent.mjs +151 -0
- package/dist/contracts/client.d.mts +90 -0
- package/dist/contracts/commits.d.mts +126 -0
- package/dist/contracts/engine.d.mts +134 -0
- package/dist/contracts/events.d.mts +276 -0
- package/dist/contracts/files.d.mts +75 -0
- package/dist/contracts/forks.d.mts +78 -0
- package/dist/contracts/grants.d.mts +60 -0
- package/dist/contracts/handlers.d.mts +11 -0
- package/dist/contracts/ids.d.mts +15 -0
- package/dist/contracts/ids.mjs +15 -0
- package/dist/contracts/lfs.d.mts +27 -0
- package/dist/contracts/merges.d.mts +33 -0
- package/dist/contracts/objects.d.mts +645 -0
- package/dist/contracts/objects.mjs +54 -0
- package/dist/contracts/operations.d.mts +133 -0
- package/dist/contracts/promises.d.mts +38 -0
- package/dist/contracts/promises.mjs +13 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +402 -0
- package/dist/contracts/refs.d.mts +95 -0
- package/dist/contracts/remote.d.mts +50 -0
- package/dist/contracts/repos.d.mts +153 -0
- package/dist/contracts/result.d.mts +133 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +272 -0
- package/dist/contracts/services.d.mts +36 -0
- package/dist/contracts/services.mjs +13 -0
- package/dist/contracts/signin.d.mts +126 -0
- package/dist/contracts/store.d.mts +41 -0
- package/dist/contracts/sync.d.mts +210 -0
- package/dist/contracts/sync.mjs +8 -0
- package/dist/contracts/tags.d.mts +50 -0
- package/dist/contracts/tags.mjs +6 -0
- package/dist/contracts/tokens.d.mts +87 -0
- package/dist/contracts/tokens.mjs +15 -0
- package/dist/contracts/topics.d.mts +180 -0
- package/dist/contracts/trees.d.mts +84 -0
- package/dist/contracts/work.d.mts +31 -0
- package/dist/core/access.d.mts +22 -0
- package/dist/core/access.mjs +262 -0
- package/dist/core/ancestry.mjs +235 -0
- package/dist/core/call-names.d.mts +1 -0
- package/dist/core/call-names.mjs +93 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +475 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +297 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +212 -0
- package/dist/core/hooks/pre-receive.d.mts +5 -0
- package/dist/core/hooks/pre-receive.mjs +34 -0
- package/dist/core/index-job.mjs +198 -0
- package/dist/core/names.mjs +30 -0
- package/dist/core/objects/blobs.mjs +60 -0
- package/dist/core/objects/commit-writes.mjs +185 -0
- package/dist/core/objects/commits.mjs +172 -0
- package/dist/core/objects/files.mjs +211 -0
- package/dist/core/objects/lines.mjs +42 -0
- package/dist/core/objects/merges.mjs +83 -0
- package/dist/core/objects/peel.mjs +166 -0
- package/dist/core/objects/reading.mjs +284 -0
- package/dist/core/objects/tags.mjs +96 -0
- package/dist/core/objects/tree-edits.mjs +266 -0
- package/dist/core/objects/trees.mjs +229 -0
- package/dist/core/objects/writing.mjs +266 -0
- package/dist/core/own-writes.mjs +94 -0
- package/dist/core/promise.mjs +64 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1070 -0
- package/dist/core/receipts.d.mts +7 -0
- package/dist/core/receipts.mjs +234 -0
- package/dist/core/ref-conflicts.mjs +27 -0
- package/dist/core/refs.mjs +359 -0
- package/dist/core/repack.mjs +521 -0
- package/dist/core/repos.mjs +752 -0
- package/dist/core/rules/changes.mjs +57 -0
- package/dist/core/rules/check.mjs +101 -0
- package/dist/core/rules/commit-changes.mjs +216 -0
- package/dist/core/rules/context.d.mts +9 -0
- package/dist/core/rules/context.mjs +120 -0
- package/dist/core/rules/define.d.mts +5 -0
- package/dist/core/rules/define.mjs +13 -0
- package/dist/core/rules/facts.mjs +13 -0
- package/dist/core/rules/fetch.d.mts +5 -0
- package/dist/core/rules/fetch.mjs +59 -0
- package/dist/core/rules/file-globs.mjs +55 -0
- package/dist/core/rules/files.mjs +142 -0
- package/dist/core/rules/patterns.mjs +23 -0
- package/dist/core/rules/protect.d.mts +9 -0
- package/dist/core/rules/protect.mjs +116 -0
- package/dist/core/seam.d.mts +26 -0
- package/dist/core/seam.mjs +54 -0
- package/dist/core/sight.mjs +99 -0
- package/dist/core/tokens.mjs +95 -0
- package/dist/core/view.d.mts +9 -0
- package/dist/core/view.mjs +221 -0
- package/dist/core/work.mjs +92 -0
- package/dist/effect.d.mts +20 -0
- package/dist/effect.mjs +18 -0
- package/dist/engine/allotted-xdiff.d.mts +4 -0
- package/dist/engine/allotted-xdiff.mjs +80 -0
- package/dist/engine/attribute-patterns.mjs +163 -0
- package/dist/engine/attributes.mjs +226 -0
- package/dist/engine/combined.mjs +653 -0
- package/dist/engine/commits.mjs +90 -0
- package/dist/engine/content.d.mts +4 -0
- package/dist/engine/content.mjs +221 -0
- package/dist/engine/diff.mjs +49 -0
- package/dist/engine/engine.d.mts +25 -0
- package/dist/engine/engine.mjs +49 -0
- package/dist/engine/failures.d.mts +4 -0
- package/dist/engine/failures.mjs +23 -0
- package/dist/engine/line-count.mjs +23 -0
- package/dist/engine/merge-base-walk.d.mts +2 -0
- package/dist/engine/merge-base-walk.mjs +265 -0
- package/dist/engine/merge-bases.mjs +27 -0
- package/dist/engine/merge-renames.mjs +165 -0
- package/dist/engine/merge.mjs +1125 -0
- package/dist/engine/parts.d.mts +8 -0
- package/dist/engine/parts.mjs +9 -0
- package/dist/engine/reads.d.mts +5 -0
- package/dist/engine/reads.mjs +105 -0
- package/dist/engine/walk.mjs +328 -0
- package/dist/engine/xdiff/NOTICE.md +63 -0
- package/dist/engine/xdiff/compiled.d.mts +7 -0
- package/dist/engine/xdiff/compiled.mjs +9 -0
- package/dist/engine/xdiff/embedded.mjs +4 -0
- package/dist/engine/xdiff/node.d.mts +7 -0
- package/dist/engine/xdiff/node.mjs +10 -0
- package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine/xdiff.d.mts +34 -0
- package/dist/engine/xdiff.mjs +380 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/extend.d.mts +4 -0
- package/dist/extend.mjs +3 -0
- package/dist/http/answers.mjs +74 -0
- package/dist/http/bodies.mjs +143 -0
- package/dist/http/core-parts.mjs +252 -0
- package/dist/http/fetch-depth.mjs +26 -0
- package/dist/http/handler.mjs +94 -0
- package/dist/http/node.d.mts +70 -0
- package/dist/http/node.mjs +178 -0
- package/dist/http/paths.d.mts +9 -0
- package/dist/http/paths.mjs +118 -0
- package/dist/http/push-uploads.mjs +286 -0
- package/dist/http/receive-pack.mjs +235 -0
- package/dist/http/upload-pack.mjs +229 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +16 -0
- package/dist/lfs/calls.mjs +16 -0
- package/dist/lfs/locks.mjs +161 -0
- package/dist/lfs/objects.mjs +370 -0
- package/dist/lfs/pointers.mjs +141 -0
- package/dist/lfs/repo.mjs +42 -0
- package/dist/lfs/rows.mjs +108 -0
- package/dist/lfs/service.mjs +34 -0
- package/dist/lfs/upkeep.mjs +162 -0
- package/dist/lfs/wire.mjs +102 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.mjs +3 -0
- package/dist/protocol/bytes/buffers.d.mts +38 -0
- package/dist/protocol/bytes/buffers.mjs +62 -0
- package/dist/protocol/bytes/crc32.d.mts +4 -0
- package/dist/protocol/bytes/crc32.mjs +14 -0
- package/dist/protocol/bytes/deflate.d.mts +78 -0
- package/dist/protocol/bytes/deflate.mjs +175 -0
- package/dist/protocol/bytes/errors.d.mts +20 -0
- package/dist/protocol/bytes/errors.mjs +19 -0
- package/dist/protocol/bytes/hex.mjs +16 -0
- package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
- package/dist/protocol/bytes/inflate.d.mts +40 -0
- package/dist/protocol/bytes/inflate.mjs +109 -0
- package/dist/protocol/bytes/joined.d.mts +2 -0
- package/dist/protocol/bytes/joined.mjs +25 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
- package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
- package/dist/protocol/bytes/sha1.d.mts +35 -0
- package/dist/protocol/bytes/sha1.mjs +409 -0
- package/dist/protocol/bytes/sha256.mjs +156 -0
- package/dist/protocol/bytes/streams.mjs +11 -0
- package/dist/protocol/bytes/text.mjs +19 -0
- package/dist/protocol/diff/diff-raw.d.mts +29 -0
- package/dist/protocol/diff/diff-raw.mjs +73 -0
- package/dist/protocol/diff/patch.mjs +92 -0
- package/dist/protocol/diff/paths.mjs +67 -0
- package/dist/protocol/diff/read.d.mts +62 -0
- package/dist/protocol/diff/read.mjs +342 -0
- package/dist/protocol/diff/rename-similarity.mjs +428 -0
- package/dist/protocol/diff/text.mjs +12 -0
- package/dist/protocol/diff/tree-diff.d.mts +41 -0
- package/dist/protocol/diff/tree-diff.mjs +607 -0
- package/dist/protocol/framing/band.d.mts +10 -0
- package/dist/protocol/framing/band.mjs +16 -0
- package/dist/protocol/framing/pkt-line.d.mts +48 -0
- package/dist/protocol/framing/pkt-line.mjs +92 -0
- package/dist/protocol/objects/checked-blobs.mjs +127 -0
- package/dist/protocol/objects/commit.d.mts +25 -0
- package/dist/protocol/objects/commit.mjs +138 -0
- package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
- package/dist/protocol/objects/fsck-names.mjs +189 -0
- package/dist/protocol/objects/fsck.mjs +297 -0
- package/dist/protocol/objects/headers.mjs +109 -0
- package/dist/protocol/objects/held.mjs +56 -0
- package/dist/protocol/objects/iconv.mjs +145 -0
- package/dist/protocol/objects/ident.mjs +111 -0
- package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
- package/dist/protocol/objects/lfs-pointer.mjs +63 -0
- package/dist/protocol/objects/links-raw.mjs +89 -0
- package/dist/protocol/objects/object-rules.mjs +75 -0
- package/dist/protocol/objects/object.d.mts +16 -0
- package/dist/protocol/objects/object.mjs +29 -0
- package/dist/protocol/objects/tag.d.mts +21 -0
- package/dist/protocol/objects/tag.mjs +96 -0
- package/dist/protocol/objects/tree.d.mts +43 -0
- package/dist/protocol/objects/tree.mjs +162 -0
- package/dist/protocol/objects/utf8-verify.mjs +71 -0
- package/dist/protocol/packs/delta.d.mts +57 -0
- package/dist/protocol/packs/delta.mjs +229 -0
- package/dist/protocol/packs/graph.mjs +78 -0
- package/dist/protocol/packs/idx.d.mts +54 -0
- package/dist/protocol/packs/idx.mjs +274 -0
- package/dist/protocol/packs/indexer.d.mts +167 -0
- package/dist/protocol/packs/indexer.mjs +507 -0
- package/dist/protocol/packs/parts.d.mts +40 -0
- package/dist/protocol/packs/parts.mjs +89 -0
- package/dist/protocol/packs/pos.mjs +51 -0
- package/dist/protocol/packs/reader.d.mts +180 -0
- package/dist/protocol/packs/reader.mjs +414 -0
- package/dist/protocol/packs/rev.d.mts +32 -0
- package/dist/protocol/packs/rev.mjs +99 -0
- package/dist/protocol/packs/step.d.mts +10 -0
- package/dist/protocol/packs/step.mjs +12 -0
- package/dist/protocol/packs/write-error.d.mts +12 -0
- package/dist/protocol/packs/write-error.mjs +27 -0
- package/dist/protocol/packs/writer.d.mts +157 -0
- package/dist/protocol/packs/writer.mjs +353 -0
- package/dist/protocol/wire/advertisement.d.mts +72 -0
- package/dist/protocol/wire/advertisement.mjs +161 -0
- package/dist/protocol/wire/fetch.d.mts +155 -0
- package/dist/protocol/wire/fetch.mjs +458 -0
- package/dist/protocol/wire/lines.mjs +107 -0
- package/dist/protocol/wire/push-uploads.mjs +43 -0
- package/dist/protocol/wire/receive-pack.d.mts +71 -0
- package/dist/protocol/wire/receive-pack.mjs +157 -0
- package/dist/protocol/wire/report-status.d.mts +47 -0
- package/dist/protocol/wire/report-status.mjs +119 -0
- package/dist/protocol/wire/v2.d.mts +90 -0
- package/dist/protocol/wire/v2.mjs +185 -0
- package/dist/protocol.d.mts +31 -0
- package/dist/protocol.mjs +31 -0
- package/dist/queue/advance.mjs +1037 -0
- package/dist/queue/callers.mjs +134 -0
- package/dist/queue/calls.mjs +1154 -0
- package/dist/queue/commit.mjs +85 -0
- package/dist/queue/host.d.mts +15 -0
- package/dist/queue/host.mjs +88 -0
- package/dist/queue/ids.d.mts +5 -0
- package/dist/queue/ids.mjs +21 -0
- package/dist/queue/lanes.mjs +86 -0
- package/dist/queue/limits.mjs +99 -0
- package/dist/queue/pages.mjs +76 -0
- package/dist/queue/push-option.mjs +62 -0
- package/dist/queue/rows.mjs +206 -0
- package/dist/queue/schedule.mjs +132 -0
- package/dist/queue/search.mjs +315 -0
- package/dist/queue/state.mjs +325 -0
- package/dist/queue/steps.mjs +317 -0
- package/dist/remote-helper.d.mts +3 -0
- package/dist/remote-helper.mjs +3 -0
- package/dist/rest/api.d.mts +23 -0
- package/dist/rest/api.mjs +27 -0
- package/dist/rest/blobs.d.mts +58 -0
- package/dist/rest/blobs.mjs +41 -0
- package/dist/rest/caller.d.mts +102 -0
- package/dist/rest/caller.mjs +18 -0
- package/dist/rest/client.d.mts +18 -0
- package/dist/rest/client.mjs +587 -0
- package/dist/rest/commits.d.mts +435 -0
- package/dist/rest/commits.mjs +140 -0
- package/dist/rest/errors.d.mts +44 -0
- package/dist/rest/errors.mjs +186 -0
- package/dist/rest/events.d.mts +38 -0
- package/dist/rest/events.mjs +74 -0
- package/dist/rest/files.d.mts +179 -0
- package/dist/rest/files.mjs +92 -0
- package/dist/rest/forks.d.mts +205 -0
- package/dist/rest/forks.mjs +51 -0
- package/dist/rest/handler.d.mts +18 -0
- package/dist/rest/handler.mjs +129 -0
- package/dist/rest/handlers.d.mts +8 -0
- package/dist/rest/handlers.mjs +592 -0
- package/dist/rest/listen.d.mts +24 -0
- package/dist/rest/listen.mjs +142 -0
- package/dist/rest/me.d.mts +55 -0
- package/dist/rest/me.mjs +21 -0
- package/dist/rest/merges.d.mts +90 -0
- package/dist/rest/merges.mjs +39 -0
- package/dist/rest/paths.mjs +86 -0
- package/dist/rest/queue.d.mts +486 -0
- package/dist/rest/queue.mjs +228 -0
- package/dist/rest/refs.d.mts +232 -0
- package/dist/rest/refs.mjs +86 -0
- package/dist/rest/repos.d.mts +223 -0
- package/dist/rest/repos.mjs +93 -0
- package/dist/rest/tags.d.mts +153 -0
- package/dist/rest/tags.mjs +72 -0
- package/dist/rest/tokens.d.mts +297 -0
- package/dist/rest/tokens.mjs +88 -0
- package/dist/rest/topics.d.mts +257 -0
- package/dist/rest/topics.mjs +116 -0
- package/dist/rest/trees.d.mts +158 -0
- package/dist/rest/trees.mjs +118 -0
- package/dist/rest/wire.mjs +57 -0
- package/dist/rest/work.d.mts +107 -0
- package/dist/rest/work.mjs +77 -0
- package/dist/rest.d.mts +8 -0
- package/dist/rest.mjs +5 -0
- package/dist/server/extension.d.mts +17 -0
- package/dist/server/extension.mjs +93 -0
- package/dist/server/lifecycle.d.mts +3 -0
- package/dist/server/lifecycle.mjs +89 -0
- package/dist/server/routes.d.mts +28 -0
- package/dist/server/routes.mjs +60 -0
- package/dist/server/server.d.mts +8 -0
- package/dist/server/server.mjs +615 -0
- package/dist/signin/codes.mjs +47 -0
- package/dist/signin/context.d.mts +9 -0
- package/dist/signin/context.mjs +121 -0
- package/dist/signin/device.mjs +122 -0
- package/dist/signin/forms.mjs +157 -0
- package/dist/signin/grants.d.mts +5 -0
- package/dist/signin/grants.mjs +257 -0
- package/dist/signin/route.mjs +68 -0
- package/dist/signin/web.mjs +125 -0
- package/dist/signin/wire.d.mts +42 -0
- package/dist/signin/wire.mjs +43 -0
- package/dist/storage/allotted.mjs +102 -0
- package/dist/storage/bits.mjs +41 -0
- package/dist/storage/budget.mjs +96 -0
- package/dist/storage/calls.d.mts +18 -0
- package/dist/storage/calls.mjs +273 -0
- package/dist/storage/clean-up.mjs +124 -0
- package/dist/storage/distinct-ids.mjs +39 -0
- package/dist/storage/ewah.mjs +97 -0
- package/dist/storage/fetch.d.mts +15 -0
- package/dist/storage/fetch.mjs +998 -0
- package/dist/storage/fsck.mjs +77 -0
- package/dist/storage/held-memo.mjs +188 -0
- package/dist/storage/index-bitmaps.d.mts +4 -0
- package/dist/storage/index-bitmaps.mjs +654 -0
- package/dist/storage/index-build.d.mts +15 -0
- package/dist/storage/index-build.mjs +1447 -0
- package/dist/storage/index-fetch.d.mts +10 -0
- package/dist/storage/index-fetch.mjs +677 -0
- package/dist/storage/index-files.mjs +232 -0
- package/dist/storage/index-graph.d.mts +3 -0
- package/dist/storage/index-graph.mjs +1049 -0
- package/dist/storage/index-layers.mjs +317 -0
- package/dist/storage/index-reach.mjs +216 -0
- package/dist/storage/index-remap.d.mts +8 -0
- package/dist/storage/index-remap.mjs +592 -0
- package/dist/storage/layout.mjs +69 -0
- package/dist/storage/lfs-pointers.d.mts +21 -0
- package/dist/storage/lfs-pointers.mjs +175 -0
- package/dist/storage/link-join.mjs +106 -0
- package/dist/storage/links.mjs +105 -0
- package/dist/storage/loose.d.mts +15 -0
- package/dist/storage/loose.mjs +121 -0
- package/dist/storage/memory-budget.d.mts +8 -0
- package/dist/storage/memory-budget.mjs +546 -0
- package/dist/storage/merge.mjs +416 -0
- package/dist/storage/object-rows.d.mts +6 -0
- package/dist/storage/object-rows.mjs +211 -0
- package/dist/storage/pack-order.d.mts +8 -0
- package/dist/storage/pack-order.mjs +781 -0
- package/dist/storage/pack-ranges.d.mts +5 -0
- package/dist/storage/pack-ranges.mjs +284 -0
- package/dist/storage/pack-reads.d.mts +11 -0
- package/dist/storage/pack-reads.mjs +1007 -0
- package/dist/storage/pack-receive.d.mts +11 -0
- package/dist/storage/pack-receive.mjs +449 -0
- package/dist/storage/packs.d.mts +56 -0
- package/dist/storage/packs.mjs +603 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +152 -0
- package/dist/storage/pushed-commits.mjs +136 -0
- package/dist/storage/quarantine.mjs +98 -0
- package/dist/storage/raw-ids.mjs +44 -0
- package/dist/storage/ready.d.mts +19 -0
- package/dist/storage/ready.mjs +328 -0
- package/dist/storage/receive-links.mjs +297 -0
- package/dist/storage/repack-job.mjs +48 -0
- package/dist/storage/repack.d.mts +31 -0
- package/dist/storage/repack.mjs +182 -0
- package/dist/storage/roots.mjs +42 -0
- package/dist/storage/rows.d.mts +4 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/send-list.d.mts +8 -0
- package/dist/storage/send-list.mjs +319 -0
- package/dist/storage/shallow.d.mts +4 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +238 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +8 -0
- package/dist/storage/walk.mjs +176 -0
- package/dist/storage/wants.mjs +362 -0
- package/dist/store/call-count.d.mts +47 -0
- package/dist/store/call-count.mjs +207 -0
- package/dist/store/catalogue.d.mts +7 -0
- package/dist/store/catalogue.mjs +643 -0
- package/dist/store/closed.d.mts +21 -0
- package/dist/store/closed.mjs +34 -0
- package/dist/store/crossing.mjs +69 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +88 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +135 -0
- package/dist/store/git-store.mjs +75 -0
- package/dist/store/list-job.mjs +35 -0
- package/dist/store/outbox.d.mts +7 -0
- package/dist/store/outbox.mjs +297 -0
- package/dist/store/promises.d.mts +5 -0
- package/dist/store/promises.mjs +258 -0
- package/dist/store/queue-jobs.mjs +43 -0
- package/dist/store/random.mjs +28 -0
- package/dist/store/records.d.mts +4 -0
- package/dist/store/records.mjs +192 -0
- package/dist/store/ref-rows.d.mts +4 -0
- package/dist/store/ref-rows.mjs +30 -0
- package/dist/store/repo-record.mjs +100 -0
- package/dist/store/reservations.mjs +82 -0
- package/dist/store/scopes.mjs +170 -0
- package/dist/store/settle.mjs +63 -0
- package/dist/store/topic-jobs.mjs +62 -0
- package/dist/sync/bound.d.mts +7 -0
- package/dist/sync/bound.mjs +34 -0
- package/dist/sync/github.d.mts +12 -0
- package/dist/sync/github.mjs +297 -0
- package/dist/sync/import.d.mts +8 -0
- package/dist/sync/import.mjs +154 -0
- package/dist/sync/jobs.d.mts +9 -0
- package/dist/sync/jobs.mjs +83 -0
- package/dist/sync/mirror.d.mts +9 -0
- package/dist/sync/mirror.mjs +227 -0
- package/dist/sync/publish.d.mts +5 -0
- package/dist/sync/publish.mjs +117 -0
- package/dist/sync/records.mjs +73 -0
- package/dist/sync/smart-http.d.mts +8 -0
- package/dist/sync/smart-http.mjs +23 -0
- package/dist/sync/step.mjs +334 -0
- package/dist/sync/tries.mjs +126 -0
- package/dist/sync.d.mts +8 -0
- package/dist/sync.mjs +8 -0
- package/dist/topics/advance.mjs +555 -0
- package/dist/topics/calls.mjs +346 -0
- package/dist/topics/directory.mjs +107 -0
- package/dist/topics/host.d.mts +11 -0
- package/dist/topics/host.mjs +71 -0
- package/dist/topics/members.mjs +177 -0
- package/dist/topics/rows.mjs +99 -0
- package/dist/topics/topic.mjs +141 -0
- package/package.json +86 -5
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { openRepo } from "../core/access.mjs";
|
|
2
|
+
import { gitPush } from "../core/push.mjs";
|
|
3
|
+
import { runFetchRules } from "../core/rules/fetch.mjs";
|
|
4
|
+
import { SealedObjects, viewOf } from "../core/view.mjs";
|
|
5
|
+
import { notReachable } from "../storage/visible.mjs";
|
|
6
|
+
import { heldOf, peeledOf, unreachableWant } from "../storage/wants.mjs";
|
|
7
|
+
import { effectObjects, walkObjects } from "../storage/calls.mjs";
|
|
8
|
+
import { indexRowKey } from "../storage/layout.mjs";
|
|
9
|
+
import { spentIn } from "../contracts/calls-spent.mjs";
|
|
10
|
+
import { answerSpent, fail } from "../store/errors.mjs";
|
|
11
|
+
import { decodePacks } from "../store/git-store.mjs";
|
|
12
|
+
import { readRecord } from "../store/repo-record.mjs";
|
|
13
|
+
import { collections, reachedKey } from "../store/scopes.mjs";
|
|
14
|
+
import { fetchReaches } from "../protocol/wire/lines.mjs";
|
|
15
|
+
import * as Effect from "effect/Effect";
|
|
16
|
+
// src/http/core-parts.ts
|
|
17
|
+
/**
|
|
18
|
+
* Git's HTTP over a server's core: who a request is and where a renamed repo went, from the
|
|
19
|
+
* seam; each repo opened as the core opens it for `authorize`; a fetch's pack from the server's
|
|
20
|
+
* objects once each want is found under a readable ref; and a push into the core's own push.
|
|
21
|
+
*/
|
|
22
|
+
/** Sent as `agent=`. */
|
|
23
|
+
const serverAgent = "git/ref0";
|
|
24
|
+
/** How many tags' peels are read at once. */
|
|
25
|
+
const readsAtOnce = 16;
|
|
26
|
+
const refsRead = { collection: collections.refs };
|
|
27
|
+
const packsRead = { collection: collections.packs };
|
|
28
|
+
const headOf = (branch) => branch.startsWith("refs/") ? branch : `refs/heads/${branch}`;
|
|
29
|
+
/**
|
|
30
|
+
* Whether `request` is a full clone of `refs`: no haves, shallow commits, depth or filter, and a
|
|
31
|
+
* want of every ref Git advertises. Anything less builds, so a `--single-branch` clone isn't sent
|
|
32
|
+
* the other branches' objects.
|
|
33
|
+
*/
|
|
34
|
+
const fullClone = (request, refs) => {
|
|
35
|
+
const wants = new Set(request.wants);
|
|
36
|
+
return request.haves.length === 0 && request.shallows.length === 0 && request.depth === void 0 && request.deepenRelative !== true && request.filter === void 0 && refs.every((ref) => !fetchReaches(ref.name) || wants.has(ref.oid));
|
|
37
|
+
};
|
|
38
|
+
const coreHttpParts = (parts, options = {}) => {
|
|
39
|
+
const { core } = parts;
|
|
40
|
+
/** A ref, with what it peels to when it's an annotated tag. Only tags are read for it. */
|
|
41
|
+
const advertised = (read, listed, name, oid) => {
|
|
42
|
+
if (!name.startsWith("refs/tags/")) return Effect.succeed({
|
|
43
|
+
name,
|
|
44
|
+
oid
|
|
45
|
+
});
|
|
46
|
+
return Effect.map(peeledOf(read, listed, oid), (peeled) => peeled === void 0 ? {
|
|
47
|
+
name,
|
|
48
|
+
oid
|
|
49
|
+
} : {
|
|
50
|
+
name,
|
|
51
|
+
oid,
|
|
52
|
+
peeled
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The repo `operation` names, once `authorize` lets `caller` do it, with its refs and list. They
|
|
57
|
+
* are read only after, so a refused caller costs no more than a repo that isn't there, and with
|
|
58
|
+
* the record again, so `HEAD` names the default branch of the same version as the refs.
|
|
59
|
+
*/
|
|
60
|
+
const opened = Effect.fnUntraced(function* (caller, operation) {
|
|
61
|
+
const resolved = yield* openRepo(core, caller, operation);
|
|
62
|
+
const { record, snapshot } = yield* readRecord(core.store, resolved.internalId, [
|
|
63
|
+
refsRead,
|
|
64
|
+
packsRead,
|
|
65
|
+
indexRowKey,
|
|
66
|
+
reachedKey
|
|
67
|
+
]);
|
|
68
|
+
if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${operation.repo}'`);
|
|
69
|
+
const [, refRows = [], packRows = [], indexRows = [], markRows = []] = snapshot.results;
|
|
70
|
+
const packs = yield* decodePacks(packRows);
|
|
71
|
+
const listed = {
|
|
72
|
+
repo: resolved.internalId,
|
|
73
|
+
version: snapshot.version,
|
|
74
|
+
packs
|
|
75
|
+
};
|
|
76
|
+
const view = viewOf(core, caller, resolved, void 0, { ownWrites: false });
|
|
77
|
+
const seen = yield* view.refs(refRows);
|
|
78
|
+
const row = indexRows[0]?.value;
|
|
79
|
+
const sighted = yield* view.objectsAt({
|
|
80
|
+
listed,
|
|
81
|
+
refs: seen,
|
|
82
|
+
index: row
|
|
83
|
+
});
|
|
84
|
+
const objects = effectObjects(sighted);
|
|
85
|
+
const index = sighted.index === void 0 ? void 0 : {
|
|
86
|
+
calls: sighted.index,
|
|
87
|
+
row
|
|
88
|
+
};
|
|
89
|
+
const refs = yield* Effect.scoped(Effect.flatMap(walkObjects(objects), (read) => Effect.forEach([...seen], ([name, oid]) => advertised(read, listed, name, oid), { concurrency: readsAtOnce })));
|
|
90
|
+
const head = headOf(record.defaultBranch);
|
|
91
|
+
const sight = yield* view.sight;
|
|
92
|
+
const served = sight.sees(head) ? {
|
|
93
|
+
head,
|
|
94
|
+
refs
|
|
95
|
+
} : { refs };
|
|
96
|
+
const shown = refs.filter((ref) => fetchReaches(ref.name)).length;
|
|
97
|
+
const whole = markRows.length > 0 && sight.whole && shown === refRows.length;
|
|
98
|
+
return index === void 0 ? {
|
|
99
|
+
listed,
|
|
100
|
+
refs: served,
|
|
101
|
+
objects,
|
|
102
|
+
whole
|
|
103
|
+
} : {
|
|
104
|
+
listed,
|
|
105
|
+
refs: served,
|
|
106
|
+
objects,
|
|
107
|
+
whole,
|
|
108
|
+
index
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
/**
|
|
112
|
+
* A refused push, told as `refused` only to a caller that may read the repo: anyone else gets
|
|
113
|
+
* the read's own refusal, as a fetch or a REST read would. By default that's the `NOT_FOUND` a
|
|
114
|
+
* repo that isn't there gets, so a push can't tell a stranger a private repo exists; a host's
|
|
115
|
+
* `authorize` that refuses the read with a code of its own is answered with it, as everywhere. A
|
|
116
|
+
* push past a call bound never reaches it: the bound stops the request whole.
|
|
117
|
+
*/
|
|
118
|
+
const readersOnly = (caller, repo, refused) => Effect.andThen(openRepo(core, caller, {
|
|
119
|
+
kind: "read",
|
|
120
|
+
repo
|
|
121
|
+
}), Effect.fail(refused));
|
|
122
|
+
const served = (caller, repo, at) => {
|
|
123
|
+
const tips = new Set(at.refs.refs.flatMap((ref) => {
|
|
124
|
+
if (!fetchReaches(ref.name)) return [];
|
|
125
|
+
return ref.peeled === void 0 ? [ref.oid] : [ref.oid, ref.peeled];
|
|
126
|
+
}));
|
|
127
|
+
const tags = at.refs.refs.flatMap((ref) => ref.name.startsWith("refs/tags/") ? [ref.oid] : []);
|
|
128
|
+
return {
|
|
129
|
+
refs: at.refs,
|
|
130
|
+
held: (oids) => heldOf(at.objects, at.listed, oids),
|
|
131
|
+
ruledDepth: (fetch, request) => runFetchRules(core.fetchRules, {
|
|
132
|
+
caller,
|
|
133
|
+
repo,
|
|
134
|
+
fetch,
|
|
135
|
+
request
|
|
136
|
+
}),
|
|
137
|
+
fetch: (request, signal) => Effect.gen(function* () {
|
|
138
|
+
const input = {
|
|
139
|
+
objects: at.objects,
|
|
140
|
+
listed: at.listed,
|
|
141
|
+
tips,
|
|
142
|
+
wants: request.wants,
|
|
143
|
+
signal
|
|
144
|
+
};
|
|
145
|
+
if (at.index !== void 0) input.index = at.index;
|
|
146
|
+
const missing = yield* unreachableWant(input);
|
|
147
|
+
if (missing !== void 0) return yield* Effect.fail(notReachable(missing));
|
|
148
|
+
const fetching = {
|
|
149
|
+
request,
|
|
150
|
+
limits: core.fetchLimits,
|
|
151
|
+
tags,
|
|
152
|
+
signal
|
|
153
|
+
};
|
|
154
|
+
const unruled = core.fetchRules.rules.length === 0;
|
|
155
|
+
if (at.whole && unruled && fullClone(request, at.refs.refs)) fetching.whole = true;
|
|
156
|
+
return yield* at.objects.fetch(at.listed, fetching);
|
|
157
|
+
})
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
const receiving = (caller, repo, at) => ({
|
|
161
|
+
refs: at.refs,
|
|
162
|
+
push: (input) => pushed(core, caller, repo, input, options.queue)
|
|
163
|
+
});
|
|
164
|
+
const http = {
|
|
165
|
+
basePath: parts.basePath,
|
|
166
|
+
agent: serverAgent,
|
|
167
|
+
identify: parts.identify,
|
|
168
|
+
renamedTo: parts.renamedTo,
|
|
169
|
+
serve: (caller, repo) => Effect.map(opened(caller, {
|
|
170
|
+
kind: "fetch",
|
|
171
|
+
repo
|
|
172
|
+
}), (at) => served(caller, repo, at)),
|
|
173
|
+
receive: (caller, repo) => opened(caller, {
|
|
174
|
+
kind: "push",
|
|
175
|
+
repo,
|
|
176
|
+
updates: []
|
|
177
|
+
}).pipe(Effect.map((at) => receiving(caller, repo, at)), Effect.catch((error) => readersOnly(caller, repo, error)))
|
|
178
|
+
};
|
|
179
|
+
if (options.resolve !== void 0) http.resolve = options.resolve;
|
|
180
|
+
if (options.lfs !== void 0) http.lfs = options.lfs;
|
|
181
|
+
if (options.uploads !== void 0) http.uploads = options.uploads;
|
|
182
|
+
if (options.maxDuration !== void 0) http.maxDuration = options.maxDuration;
|
|
183
|
+
if (options.calls !== void 0) http.fetchCalls = options.calls;
|
|
184
|
+
if (options.pushCalls !== void 0) http.pushCalls = options.pushCalls;
|
|
185
|
+
return http;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* A Git push's refusal past its request's count or the platform's cap, with what it's told to try
|
|
189
|
+
* in place of the store's hint: every `git push` comes through `pushed`, and no other write is told
|
|
190
|
+
* of commits. Its cause is `error`, which keeps the bound.
|
|
191
|
+
*/
|
|
192
|
+
const pushLess = (error) => spentIn(error)?.of === "budget" || spentIn(error) === void 0 ? error : {
|
|
193
|
+
...error,
|
|
194
|
+
hint: "Push fewer commits at a time",
|
|
195
|
+
cause: error
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* A push, with `git push -o queue`'s admission before it lands and its note after, whole inside
|
|
199
|
+
* the edge its spent call bounds are answered at, `pushLess`'s: a bound spent in the admission is
|
|
200
|
+
* refused as the push's, so the route still drains its pack and reports each ref. A failure of the
|
|
201
|
+
* pack's own receive is Git's `unpack` failing, so no ref moved; the objects are watched to tell
|
|
202
|
+
* it from any other refusal of the whole push, as it is, as the cause of `pushLess`'s hint, or as
|
|
203
|
+
* the same spent bound.
|
|
204
|
+
*/
|
|
205
|
+
const pushed = (core, caller, repo, input, queue) => {
|
|
206
|
+
let unpack;
|
|
207
|
+
const watched = SealedObjects.onReceive(core.objects, (result) => {
|
|
208
|
+
if (result.kind === "error") unpack = result.error;
|
|
209
|
+
});
|
|
210
|
+
const whole = Effect.gen(function* () {
|
|
211
|
+
const queueing = queue === void 0 ? void 0 : yield* queue(caller, repo, input.edits, input.pushOptions);
|
|
212
|
+
const { updated, notes } = yield* landed(core, watched, caller, repo, input, queueing?.internalId);
|
|
213
|
+
const queued = queueing === void 0 ? [] : yield* queueing.queued(updated);
|
|
214
|
+
const all = [...notes, ...queued];
|
|
215
|
+
return all.length === 0 ? {
|
|
216
|
+
kind: "updated",
|
|
217
|
+
updated
|
|
218
|
+
} : {
|
|
219
|
+
kind: "updated",
|
|
220
|
+
updated,
|
|
221
|
+
notes: all
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
return answerSpent(whole).pipe(Effect.mapError(pushLess), Effect.catch((error) => unpack !== void 0 && (error === unpack || error.cause === unpack || spentIn(unpack) !== void 0 && spentIn(unpack) === spentIn(error)) ? Effect.succeed({
|
|
225
|
+
kind: "unpack-failed",
|
|
226
|
+
error
|
|
227
|
+
}) : Effect.fail(error)));
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* The core's push of `input` over `objects`, into `internalId` when the queue admitted the push's
|
|
231
|
+
* branches.
|
|
232
|
+
*/
|
|
233
|
+
const landed = (core, objects, caller, repo, input, internalId) => {
|
|
234
|
+
const request = {
|
|
235
|
+
caller,
|
|
236
|
+
repo,
|
|
237
|
+
source: "git",
|
|
238
|
+
edits: input.edits,
|
|
239
|
+
atomic: input.atomic,
|
|
240
|
+
pushOptions: input.pushOptions,
|
|
241
|
+
request: input.request,
|
|
242
|
+
signal: input.signal
|
|
243
|
+
};
|
|
244
|
+
if (input.pack !== void 0) request.pack = input.pack;
|
|
245
|
+
if (internalId !== void 0) request.internalId = internalId;
|
|
246
|
+
if (input.shallow !== void 0) request.shallow = input.shallow;
|
|
247
|
+
return gitPush({
|
|
248
|
+
...core,
|
|
249
|
+
objects
|
|
250
|
+
}, request);
|
|
251
|
+
};
|
|
252
|
+
export { coreHttpParts, serverAgent };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as Result from "effect/Result";
|
|
2
|
+
// src/http/fetch-depth.ts
|
|
3
|
+
/**
|
|
4
|
+
* `request` with the depth a repo's fetch rules give it, `ruled`, as Git's client can take it,
|
|
5
|
+
* or the `ERR` message that refuses it:
|
|
6
|
+
* - a fetch that asked for a depth gets the lesser of the two, in v0 and v2;
|
|
7
|
+
* - in v2, a clone, which sends no haves and no shallow lines, gets `ruled`, since v2's client
|
|
8
|
+
* reads a `shallow-info` section it didn't ask for, and any other fetch is left whole, so a
|
|
9
|
+
* rule never cuts a clone's history once it's been fetched;
|
|
10
|
+
* - in v0, a fetch that asked for none is refused: its client reads no shallow lines, so it
|
|
11
|
+
* could only be sent more than the rule allows.
|
|
12
|
+
*/
|
|
13
|
+
const withRuledDepth = (request, ruled, version) => {
|
|
14
|
+
if (ruled === void 0) return Result.succeed(request);
|
|
15
|
+
if (request.depth !== void 0) return Result.succeed({
|
|
16
|
+
...request,
|
|
17
|
+
depth: Math.min(request.depth, ruled)
|
|
18
|
+
});
|
|
19
|
+
if (version === "v0") return Result.fail(`a fetch rule limits this fetch to a depth of ${ruled}, which protocol v0 serves only to a fetch that asks for one: fetch with --depth, or use protocol v2`);
|
|
20
|
+
const clone = request.haves.length === 0 && request.shallows.length === 0;
|
|
21
|
+
return Result.succeed(clone ? {
|
|
22
|
+
...request,
|
|
23
|
+
depth: ruled
|
|
24
|
+
} : request);
|
|
25
|
+
};
|
|
26
|
+
export { withRuledDepth };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
|
|
2
|
+
import { gitError, routeEdge } from "../store/errors.mjs";
|
|
3
|
+
import { moved, notFound, refusal, requestType, told } from "./answers.mjs";
|
|
4
|
+
import { lfsAnswer, lfsRefusal } from "../lfs/wire.mjs";
|
|
5
|
+
import { gitUrlOf, infoRefsPath, isGitService, normalBase } from "./paths.mjs";
|
|
6
|
+
import { receivePack, receivePackRefs, routeCounted } from "./receive-pack.mjs";
|
|
7
|
+
import { uploadPack, uploadPackRefs } from "./upload-pack.mjs";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Clock from "effect/Clock";
|
|
10
|
+
// src/http/handler.ts
|
|
11
|
+
const gitHttp = (parts) => {
|
|
12
|
+
const base = normalBase(parts.basePath);
|
|
13
|
+
return { route: (request) => {
|
|
14
|
+
const url = new URL(request.url);
|
|
15
|
+
const git = gitUrlOf(url, base);
|
|
16
|
+
if (git === void 0) return Effect.succeed(void 0);
|
|
17
|
+
if (git.kind === "lfs") return lfsRoute(parts, git, url, request);
|
|
18
|
+
if (git.kind === "push-upload") return uploadRoute(parts, git, url, request);
|
|
19
|
+
const malformed = malformedRequest(git, request);
|
|
20
|
+
if (malformed !== void 0) return Effect.succeed(malformed);
|
|
21
|
+
return answer(parts, base, git, url, request);
|
|
22
|
+
} };
|
|
23
|
+
};
|
|
24
|
+
/** A request to Git LFS's API: its refusals are LFS's JSON, as git-lfs reads them. */
|
|
25
|
+
const lfsRoute = (parts, git, url, request) => Effect.gen(function* () {
|
|
26
|
+
const { lfs } = parts;
|
|
27
|
+
if (lfs === void 0) return lfsAnswer(404, { message: "This server has no Git LFS" });
|
|
28
|
+
const caller = yield* parts.identify(request);
|
|
29
|
+
const repo = yield* repoOf(parts, git, url, caller);
|
|
30
|
+
if (repo === void 0) return lfsAnswer(404, { message: "Repository not found" });
|
|
31
|
+
return yield* routeCounted(parts, lfs({
|
|
32
|
+
caller,
|
|
33
|
+
repo,
|
|
34
|
+
request,
|
|
35
|
+
route: git.route,
|
|
36
|
+
repoUrl: git.repoUrl
|
|
37
|
+
}));
|
|
38
|
+
}).pipe((route) => routeEdge(route, lfsRefusal));
|
|
39
|
+
/** A large push's upload: its refusals are a push's, as `git-remote-ref0` reads them. */
|
|
40
|
+
const uploadRoute = (parts, git, url, request) => Effect.gen(function* () {
|
|
41
|
+
const { uploads } = parts;
|
|
42
|
+
if (uploads === void 0) return told(404, "This server takes no push uploads");
|
|
43
|
+
if (request.method !== "POST") return told(405, "Method not allowed", { allow: "POST" });
|
|
44
|
+
const caller = yield* parts.identify(request);
|
|
45
|
+
const repo = yield* repoOf(parts, git, url, caller);
|
|
46
|
+
if (repo === void 0) return notFound();
|
|
47
|
+
return yield* uploads.serve(parts, {
|
|
48
|
+
caller,
|
|
49
|
+
repo,
|
|
50
|
+
request,
|
|
51
|
+
route: git.route
|
|
52
|
+
});
|
|
53
|
+
}).pipe((route) => routeEdge(route, (error) => refusal(error, true)));
|
|
54
|
+
/** Why `request` isn't one Git sends, as an answer, or `undefined`. */
|
|
55
|
+
const malformedRequest = (git, request) => {
|
|
56
|
+
if (git.kind === "info-refs") {
|
|
57
|
+
if (request.method !== "GET" && request.method !== "HEAD") return told(405, "Method not allowed", { allow: "GET, HEAD" });
|
|
58
|
+
return isGitService(git.service) ? void 0 : told(403, "Only smart HTTP is served");
|
|
59
|
+
}
|
|
60
|
+
if (request.method !== "POST") return told(405, "Method not allowed", { allow: "POST" });
|
|
61
|
+
return (request.headers.get("content-type") ?? "").split(";")[0]?.trim().toLowerCase() === requestType(git.service) ? void 0 : told(415, "Unsupported media type");
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The repo `git` names for `caller`: the host's `resolve`, or the path itself. Its signal aborts
|
|
65
|
+
* when the request does or the server closes.
|
|
66
|
+
*/
|
|
67
|
+
const repoOf = (parts, git, url, caller) => {
|
|
68
|
+
const { resolve } = parts;
|
|
69
|
+
if (resolve === void 0) return Effect.succeed(git.path);
|
|
70
|
+
return tryUnlessSpent(async (signal) => resolve({
|
|
71
|
+
actor: caller.actor,
|
|
72
|
+
url,
|
|
73
|
+
path: git.path,
|
|
74
|
+
signal
|
|
75
|
+
}), (cause) => gitError("INTERNAL", "The host's resolve failed", { cause }));
|
|
76
|
+
};
|
|
77
|
+
const answer = (parts, base, git, url, request) => Effect.gen(function* () {
|
|
78
|
+
const started = yield* Clock.currentTimeMillis;
|
|
79
|
+
const caller = yield* parts.identify(request);
|
|
80
|
+
const repo = yield* repoOf(parts, git, url, caller);
|
|
81
|
+
if (repo === void 0) return notFound();
|
|
82
|
+
return yield* serve(parts, base, git, caller, repo, request, started);
|
|
83
|
+
}).pipe((route) => routeEdge(route, (error) => refusal(error, git.service === "git-receive-pack")));
|
|
84
|
+
/** A refusal a repo that isn't there gets, which a renamed repo's old name may answer instead. */
|
|
85
|
+
const isMissing = (error) => error.code === "NOT_FOUND" || error.code === "UNAUTHENTICATED" || error.code === "NOT_ALLOWED";
|
|
86
|
+
const serve = (parts, base, git, caller, repo, request, started) => {
|
|
87
|
+
if (git.kind === "info-refs") {
|
|
88
|
+
const { service, dotGit } = git;
|
|
89
|
+
const missing = (error) => parts.resolve !== void 0 || !isMissing(error) || !isGitService(service) ? Effect.fail(error) : Effect.flatMap(parts.renamedTo(caller, repo), (renamed) => renamed === void 0 ? Effect.fail(error) : Effect.succeed(moved(infoRefsPath(base, renamed, dotGit, service))));
|
|
90
|
+
return git.service === "git-receive-pack" ? receivePackRefs(parts, caller, repo, missing) : uploadPackRefs(parts, caller, repo, request, missing);
|
|
91
|
+
}
|
|
92
|
+
return git.service === "git-receive-pack" ? receivePack(parts, caller, repo, request) : uploadPack(parts, caller, repo, request, started);
|
|
93
|
+
};
|
|
94
|
+
export { gitHttp };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { GitServer } from "../contracts/server.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* What `toNodeHandler` reads of `node:http`'s request, which Express's extends: this package has
|
|
4
|
+
* no Node types, so the few members used are typed here.
|
|
5
|
+
*/
|
|
6
|
+
export interface NodeRequest extends AsyncIterable<Uint8Array> {
|
|
7
|
+
readonly method?: string | undefined;
|
|
8
|
+
readonly url?: string | undefined;
|
|
9
|
+
/** Express's: the path before a router took its mount off `url`. */
|
|
10
|
+
readonly originalUrl?: string | undefined;
|
|
11
|
+
readonly rawHeaders: ReadonlyArray<string>;
|
|
12
|
+
/** `host`, or over HTTP/2, `node:http2`'s `:authority`, which stands in for it. */
|
|
13
|
+
readonly headers: {
|
|
14
|
+
readonly host?: string | undefined;
|
|
15
|
+
readonly ':authority'?: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
/** A `Socket`, whose `remoteAddress` every one has; a TLS one's `encrypted` is `true`. */
|
|
18
|
+
readonly socket: {
|
|
19
|
+
readonly remoteAddress?: string | undefined;
|
|
20
|
+
readonly encrypted?: boolean | undefined;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* What `toNodeHandler` calls of `node:http`'s response, or `node:http2`'s compatibility one. Both
|
|
25
|
+
* set `writableEnded` once `end` is called, and not for a client that left first; `node:http2`'s
|
|
26
|
+
* has no `destroyed` of its own, and its stream's says whether it's gone, and its `close` that
|
|
27
|
+
* the client left.
|
|
28
|
+
*/
|
|
29
|
+
export interface NodeResponse {
|
|
30
|
+
readonly headersSent: boolean;
|
|
31
|
+
readonly writableEnded: boolean;
|
|
32
|
+
readonly destroyed?: boolean | undefined;
|
|
33
|
+
readonly stream?: {
|
|
34
|
+
readonly destroyed: boolean;
|
|
35
|
+
once(event: 'close', listener: () => void): void;
|
|
36
|
+
} | undefined;
|
|
37
|
+
writeHead(status: number, headers: string[]): void;
|
|
38
|
+
write(chunk: Uint8Array): boolean;
|
|
39
|
+
end(): void;
|
|
40
|
+
once(event: 'drain' | 'close', listener: () => void): void;
|
|
41
|
+
removeListener(event: 'drain' | 'close', listener: () => void): void;
|
|
42
|
+
destroy(): void;
|
|
43
|
+
}
|
|
44
|
+
/** A listener for `node:http`'s `createServer`, or an Express route. */
|
|
45
|
+
export type NodeHandler = (request: NodeRequest, response: NodeResponse) => void;
|
|
46
|
+
/**
|
|
47
|
+
* A Git server, or any `fetch`, as a `node:http` or `node:http2` listener or an Express route:
|
|
48
|
+
* `createServer(toNodeHandler(git))`; beside an app's own routes, `toNodeMiddleware`. The body
|
|
49
|
+
* streams to Git unread. The response streams back as Node can take it, and a client that
|
|
50
|
+
* disconnects or resets its stream before the response ends, which a `close` of the HTTP/2
|
|
51
|
+
* stream, or the HTTP/1 response, before `writableEnded` says, aborts the request's `signal`, which ends Git's reads and leaves it
|
|
52
|
+
* unanswered. A request whose URL can't be read, such as one with a malformed `Host`, is answered
|
|
53
|
+
* 400. Over HTTP/2, `node:http2` keeps a stream open while its client's end is, as for a `HEAD`
|
|
54
|
+
* whose client never ends it: that holds only the client's own stream.
|
|
55
|
+
*/
|
|
56
|
+
export declare const toNodeHandler: (handler: Pick<GitServer, 'fetch'>) => NodeHandler;
|
|
57
|
+
/** Express's `next`: the request goes on to the app's own middleware and routes. */
|
|
58
|
+
export type NodeNext = () => void;
|
|
59
|
+
/** An Express middleware, or `next` for a request it doesn't answer. */
|
|
60
|
+
export type NodeMiddleware = (request: NodeRequest, response: NodeResponse, next: NodeNext) => void;
|
|
61
|
+
/**
|
|
62
|
+
* A Git server, or any `fetch`, beside an app's own routes, as an Express middleware:
|
|
63
|
+
* `app.use(toNodeMiddleware(git, (url) => gitPathOf(url, '/git')))`, before any body parser. A
|
|
64
|
+
* request `pathOf` names is answered at the path it gives, as `toNodeHandler` answers it, the
|
|
65
|
+
* query kept; every other goes on to `next`, its body unread. `pathOf` is handed the URL `fetch`
|
|
66
|
+
* gets, with its dot segments resolved, so the path Express routed by never decides. A URL that
|
|
67
|
+
* can't be read goes on to `next` too. It calls `next` synchronously, before it returns, or not
|
|
68
|
+
* at all, so a framework's hook, as Fastify's `onRequest` is, can tell by then whether it answers.
|
|
69
|
+
*/
|
|
70
|
+
export declare const toNodeMiddleware: (handler: Pick<GitServer, 'fetch'>, pathOf: (url: URL) => string | undefined) => NodeMiddleware;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// src/http/node.ts
|
|
2
|
+
/**
|
|
3
|
+
* A request's body as a stream, read from Node only as the handler pulls it, with nothing read
|
|
4
|
+
* ahead: over HTTP/2, `node:http2` closes a stream whose upload no one reads once its answer has
|
|
5
|
+
* ended, so an upload Git refused unread doesn't hold the stream open till the client ends it.
|
|
6
|
+
*/
|
|
7
|
+
const streamOf = (incoming) => {
|
|
8
|
+
const chunks = incoming[Symbol.asyncIterator]();
|
|
9
|
+
return new ReadableStream({
|
|
10
|
+
pull: async (controller) => {
|
|
11
|
+
const next = await chunks.next();
|
|
12
|
+
if (next.done === true) return controller.close();
|
|
13
|
+
controller.enqueue(next.value);
|
|
14
|
+
},
|
|
15
|
+
cancel: async () => {
|
|
16
|
+
await chunks.return?.();
|
|
17
|
+
}
|
|
18
|
+
}, { highWaterMark: 0 });
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The URL Node received, as `Request` reads it: dot segments, `%2e%2e` and `\` resolved. A path
|
|
22
|
+
* is read after the connection's origin, so one that starts `//`, as `//evil.example/git/…` does,
|
|
23
|
+
* stays a path, and an absolute target keeps only its path and query: neither names the origin
|
|
24
|
+
* Git builds its links from. It throws for one that can't be read, such as one whose `Host` is
|
|
25
|
+
* empty or holds more than a host and port, as `mo.dev#`, `mo.dev/git` or `@evil.example` do,
|
|
26
|
+
* since the target would be read as part of the origin. Over HTTP/2, `:authority` is the `Host`,
|
|
27
|
+
* and a request whose `host` names another, which RFC 9113 calls malformed, has none.
|
|
28
|
+
*/
|
|
29
|
+
const urlOf = (incoming) => {
|
|
30
|
+
const authority = incoming.headers[":authority"];
|
|
31
|
+
const given = incoming.headers.host;
|
|
32
|
+
if (authority !== void 0 && given !== void 0 && given.toLowerCase() !== authority.toLowerCase()) throw new TypeError(`A Host, ${given}, that isn't the :authority, ${authority}`);
|
|
33
|
+
const host = authority ?? given ?? "localhost";
|
|
34
|
+
if (host === "" || /[/\\?#@]/.test(host)) throw new TypeError(`No origin in the Host ${host}`);
|
|
35
|
+
const origin = `${incoming.socket.encrypted === true ? "https" : "http"}://${host}`;
|
|
36
|
+
const target = incoming.originalUrl ?? incoming.url ?? "/";
|
|
37
|
+
if (target.startsWith("/")) return new URL(`${origin}${target}`);
|
|
38
|
+
const named = new URL(target);
|
|
39
|
+
return new URL(`${origin}${named.pathname}${named.search}`);
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The request Node received, at `url`, as a `Request` on `signal`, its body streamed. HTTP/2's
|
|
43
|
+
* pseudo-headers, such as `:method` and `:authority`, are left out: `Headers` refuses their names.
|
|
44
|
+
*/
|
|
45
|
+
const requestOf = (incoming, signal, url = urlOf(incoming)) => {
|
|
46
|
+
const headers = new Headers();
|
|
47
|
+
for (let at = 0; at + 1 < incoming.rawHeaders.length; at += 2) {
|
|
48
|
+
const name = incoming.rawHeaders[at] ?? "";
|
|
49
|
+
if (!name.startsWith(":")) headers.append(name, incoming.rawHeaders[at + 1] ?? "");
|
|
50
|
+
}
|
|
51
|
+
const method = incoming.method ?? "GET";
|
|
52
|
+
const init = {
|
|
53
|
+
method,
|
|
54
|
+
headers
|
|
55
|
+
};
|
|
56
|
+
if (signal !== void 0) init.signal = signal;
|
|
57
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
58
|
+
init.body = streamOf(incoming);
|
|
59
|
+
init.duplex = "half";
|
|
60
|
+
}
|
|
61
|
+
return new Request(url, init);
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* What emits `close` when the client leaves: over HTTP/2, the response's stream, since `node:http2`'s
|
|
65
|
+
* compatibility response emits none for a HEAD whose stream closes before `end`; else the response.
|
|
66
|
+
*/
|
|
67
|
+
const closer = (response) => response.stream ?? response;
|
|
68
|
+
/**
|
|
69
|
+
* Whether Node's response is gone, its connection closed or reset: `node:http`'s says so itself,
|
|
70
|
+
* and `node:http2`'s compatibility response only through its stream.
|
|
71
|
+
*/
|
|
72
|
+
const gone = (response) => response.destroyed === true || response.stream?.destroyed === true;
|
|
73
|
+
/**
|
|
74
|
+
* Resolves once Node can take more of the response, or once its connection has closed, and takes
|
|
75
|
+
* its other listener off: a long answer waits for `drain` many times, and each wait would leave a
|
|
76
|
+
* `close` listener on the response till it closed.
|
|
77
|
+
*/
|
|
78
|
+
const writable = (response) => new Promise((ready) => {
|
|
79
|
+
const settle = () => {
|
|
80
|
+
response.removeListener("drain", settle);
|
|
81
|
+
response.removeListener("close", settle);
|
|
82
|
+
ready();
|
|
83
|
+
};
|
|
84
|
+
response.once("drain", settle);
|
|
85
|
+
response.once("close", settle);
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Writes `answer` to Node's response, each header as it is, its body as it streams: a write Node
|
|
89
|
+
* can't take yet waits for `drain`, so a slow client holds the stream back, not memory. A
|
|
90
|
+
* connection that closes first cancels the body, a read it waits on included. The answer to a
|
|
91
|
+
* `HEAD` goes without its body, which is cancelled, as RFC 9110 says: `node:http2` ends a HEAD's
|
|
92
|
+
* stream with its head, and would take no write after it.
|
|
93
|
+
*/
|
|
94
|
+
const respond = async (answer, response, head = false) => {
|
|
95
|
+
const headers = [...answer.headers].flatMap(([name, value]) => [name, value]);
|
|
96
|
+
response.writeHead(answer.status, headers);
|
|
97
|
+
if (head) answer.body?.cancel().catch(() => {});
|
|
98
|
+
else if (answer.body !== null) {
|
|
99
|
+
const reader = answer.body.getReader();
|
|
100
|
+
const cancel = () => void reader.cancel().catch(() => {});
|
|
101
|
+
if (gone(response)) return cancel();
|
|
102
|
+
closer(response).once("close", () => {
|
|
103
|
+
if (!response.writableEnded) cancel();
|
|
104
|
+
});
|
|
105
|
+
for (;;) {
|
|
106
|
+
const next = await reader.read();
|
|
107
|
+
if (next.done || gone(response)) break;
|
|
108
|
+
if (!response.write(next.value)) await writable(response);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (!gone(response)) response.end();
|
|
112
|
+
};
|
|
113
|
+
/** No answer to a client that went away: `answer`'s body is cancelled and the response destroyed. */
|
|
114
|
+
const leave = (answer, response) => {
|
|
115
|
+
answer.body?.cancel().catch(() => {});
|
|
116
|
+
response.destroy();
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* `handler`'s answer to `incoming`, at `url` or the URL Node received, written to `response`. A
|
|
120
|
+
* response already gone, as when the client left while the app's earlier middleware ran, gets no
|
|
121
|
+
* call to `handler`: its `close` came before this could hear it.
|
|
122
|
+
*/
|
|
123
|
+
const answerAt = (handler, incoming, response, url) => {
|
|
124
|
+
if (gone(response)) return;
|
|
125
|
+
const ended = new AbortController();
|
|
126
|
+
closer(response).once("close", () => {
|
|
127
|
+
if (!response.writableEnded) ended.abort();
|
|
128
|
+
});
|
|
129
|
+
let request;
|
|
130
|
+
try {
|
|
131
|
+
request = requestOf(incoming, ended.signal, url ?? urlOf(incoming));
|
|
132
|
+
} catch {
|
|
133
|
+
response.writeHead(400, ["content-type", "text/plain"]);
|
|
134
|
+
response.end();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
Promise.resolve().then(() => handler.fetch(request)).then((answer) => ended.signal.aborted ? leave(answer, response) : respond(answer, response, request.method === "HEAD")).catch(() => {
|
|
138
|
+
if (ended.signal.aborted || response.headersSent || gone(response)) {
|
|
139
|
+
response.destroy();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
response.writeHead(500, ["content-type", "text/plain"]);
|
|
143
|
+
response.end();
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* A Git server, or any `fetch`, as a `node:http` or `node:http2` listener or an Express route:
|
|
148
|
+
* `createServer(toNodeHandler(git))`; beside an app's own routes, `toNodeMiddleware`. The body
|
|
149
|
+
* streams to Git unread. The response streams back as Node can take it, and a client that
|
|
150
|
+
* disconnects or resets its stream before the response ends, which a `close` of the HTTP/2
|
|
151
|
+
* stream, or the HTTP/1 response, before `writableEnded` says, aborts the request's `signal`, which ends Git's reads and leaves it
|
|
152
|
+
* unanswered. A request whose URL can't be read, such as one with a malformed `Host`, is answered
|
|
153
|
+
* 400. Over HTTP/2, `node:http2` keeps a stream open while its client's end is, as for a `HEAD`
|
|
154
|
+
* whose client never ends it: that holds only the client's own stream.
|
|
155
|
+
*/
|
|
156
|
+
const toNodeHandler = (handler) => (incoming, response) => answerAt(handler, incoming, response, void 0);
|
|
157
|
+
/**
|
|
158
|
+
* A Git server, or any `fetch`, beside an app's own routes, as an Express middleware:
|
|
159
|
+
* `app.use(toNodeMiddleware(git, (url) => gitPathOf(url, '/git')))`, before any body parser. A
|
|
160
|
+
* request `pathOf` names is answered at the path it gives, as `toNodeHandler` answers it, the
|
|
161
|
+
* query kept; every other goes on to `next`, its body unread. `pathOf` is handed the URL `fetch`
|
|
162
|
+
* gets, with its dot segments resolved, so the path Express routed by never decides. A URL that
|
|
163
|
+
* can't be read goes on to `next` too. It calls `next` synchronously, before it returns, or not
|
|
164
|
+
* at all, so a framework's hook, as Fastify's `onRequest` is, can tell by then whether it answers.
|
|
165
|
+
*/
|
|
166
|
+
const toNodeMiddleware = (handler, pathOf) => (incoming, response, next) => {
|
|
167
|
+
let url;
|
|
168
|
+
try {
|
|
169
|
+
url = urlOf(incoming);
|
|
170
|
+
} catch {
|
|
171
|
+
return next();
|
|
172
|
+
}
|
|
173
|
+
const path = pathOf(url);
|
|
174
|
+
if (path === void 0) return next();
|
|
175
|
+
url.pathname = path;
|
|
176
|
+
answerAt(handler, incoming, response, url);
|
|
177
|
+
};
|
|
178
|
+
export { requestOf, respond, toNodeHandler, toNodeMiddleware };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../protocol/wire/advertisement.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* The path Git answers `url` at under `basePath`, or `undefined` for a URL that isn't Git's: its
|
|
4
|
+
* own path, under the base path, as the URL parser left it, with dot segments, `%2e%2e` and `\`
|
|
5
|
+
* resolved. A mount beside an app calls it with the URL Git is handed, so it never decides on a
|
|
6
|
+
* raw path that Git reads as another: a path it doesn't name falls through to the app. A path
|
|
7
|
+
* that starts `//` is none of Git's, since a parser that reads it as a host would name another.
|
|
8
|
+
*/
|
|
9
|
+
export declare const gitPathOf: (url: URL, basePath: string) => string | undefined;
|