@ref0/git 0.0.0 → 0.2.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 +51 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +160 -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 +150 -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 +10 -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 +63 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +401 -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 +126 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +245 -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 +174 -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/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +468 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +290 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +204 -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 +46 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1069 -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 +24 -0
- package/dist/core/seam.mjs +41 -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 +3 -0
- package/dist/extend.mjs +1 -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 +1036 -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 +17 -0
- package/dist/rest/handler.mjs +106 -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 +14 -0
- package/dist/server/extension.mjs +85 -0
- package/dist/server/routes.d.mts +25 -0
- package/dist/server/routes.mjs +67 -0
- package/dist/server/server.d.mts +2 -0
- package/dist/server/server.mjs +439 -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/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 +13 -0
- package/dist/storage/fetch.mjs +792 -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 +1433 -0
- package/dist/storage/index-fetch.d.mts +9 -0
- package/dist/storage/index-fetch.mjs +756 -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 +120 -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 +779 -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 +990 -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 +600 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +151 -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 +3 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/shallow.d.mts +5 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +236 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +7 -0
- package/dist/storage/walk.mjs +170 -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/crossing.mjs +66 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +85 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +129 -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 +295 -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 +29 -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 +80 -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 +554 -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 +126 -0
- package/package.json +86 -5
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { joinedBytes } from "../protocol/bytes/joined.mjs";
|
|
2
|
+
import { pushUploadAbove } from "../protocol/wire/push-uploads.mjs";
|
|
3
|
+
import { gitHttp } from "./git-http.mjs";
|
|
4
|
+
import { helperNode, written } from "./helper-node.mjs";
|
|
5
|
+
import { packInMemory } from "./push-upload.mjs";
|
|
6
|
+
import { helperAdvertisement, readHelperStart, relayPush } from "./remote-helper.mjs";
|
|
7
|
+
import { secretScrubber } from "./scrub.mjs";
|
|
8
|
+
import { gitError } from "../store/errors.mjs";
|
|
9
|
+
import { runIn, uncounted } from "../store/crossing.mjs";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Result from "effect/Result";
|
|
12
|
+
import * as Base64 from "effect/encoding/Base64";
|
|
13
|
+
import * as Redacted from "effect/Redacted";
|
|
14
|
+
// src/client/run-remote-helper.ts
|
|
15
|
+
/** Each signal the helper catches, with the status a shell gives a process it ends. */
|
|
16
|
+
const signals = [
|
|
17
|
+
["SIGHUP", 129],
|
|
18
|
+
["SIGINT", 130],
|
|
19
|
+
["SIGTERM", 143]
|
|
20
|
+
];
|
|
21
|
+
/** `credential` as a request sends it, its secret unwrapped. */
|
|
22
|
+
const sent = (credential) => ({
|
|
23
|
+
username: credential.username,
|
|
24
|
+
password: Redacted.value(credential.password)
|
|
25
|
+
});
|
|
26
|
+
/** `credential` as `approve` and `reject` take it back, its secret unwrapped. */
|
|
27
|
+
const given = (credential) => ({
|
|
28
|
+
...sent(credential),
|
|
29
|
+
expiresAt: credential.expiresAt
|
|
30
|
+
});
|
|
31
|
+
/** The folder a large pack is spooled in, while there is one. */
|
|
32
|
+
let spoolDir;
|
|
33
|
+
const removeSpool = () => {
|
|
34
|
+
if (spoolDir !== void 0) helperNode().fs.rmSync(spoolDir, {
|
|
35
|
+
recursive: true,
|
|
36
|
+
force: true
|
|
37
|
+
});
|
|
38
|
+
spoolDir = void 0;
|
|
39
|
+
};
|
|
40
|
+
/** Thrown to stop with `error` printed, scrubbed of any secret. */
|
|
41
|
+
var Stopped = class extends Error {
|
|
42
|
+
error;
|
|
43
|
+
constructor(error) {
|
|
44
|
+
super(error.message);
|
|
45
|
+
this.error = error;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/** A client calls a remote over HTTP, never a store's or a bucket's door. */
|
|
49
|
+
const aClient = uncounted("a client: it calls a remote");
|
|
50
|
+
const run = async (effect) => {
|
|
51
|
+
const result = await runIn(Effect.result(effect), aClient);
|
|
52
|
+
if (Result.isFailure(result)) throw new Stopped(result.failure);
|
|
53
|
+
return result.success;
|
|
54
|
+
};
|
|
55
|
+
/** Another chunk of input added to what's held: false at its end. */
|
|
56
|
+
const more = async (input) => {
|
|
57
|
+
const next = await input.chunks.next();
|
|
58
|
+
if (next.done === true) return false;
|
|
59
|
+
input.held = joinedBytes([input.held, next.value]);
|
|
60
|
+
return true;
|
|
61
|
+
};
|
|
62
|
+
/** Git's next command line, or `undefined` at the end of input. */
|
|
63
|
+
const commandLine = async (input) => {
|
|
64
|
+
for (;;) {
|
|
65
|
+
const at = input.held.indexOf(10);
|
|
66
|
+
if (at !== -1) {
|
|
67
|
+
const line = new TextDecoder().decode(input.held.subarray(0, at));
|
|
68
|
+
input.held = input.held.subarray(at + 1);
|
|
69
|
+
return line;
|
|
70
|
+
}
|
|
71
|
+
if (!await more(input)) return void 0;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/** A new file to write and read, in a fresh private folder, made only if no file is there. */
|
|
75
|
+
const spoolFile = async () => {
|
|
76
|
+
const node = helperNode();
|
|
77
|
+
spoolDir = node.fs.mkdtempSync(`${node.tmpdir()}/ref0-push-`);
|
|
78
|
+
return node.open(`${spoolDir}/pack`, "wx+", 384);
|
|
79
|
+
};
|
|
80
|
+
const writeAll = async (file, chunk) => {
|
|
81
|
+
for (let at = 0; at < chunk.length;) at += (await file.write(chunk.subarray(at))).bytesWritten;
|
|
82
|
+
};
|
|
83
|
+
const unreadSpool = gitError("INTERNAL", "The push's spool file couldn't be read");
|
|
84
|
+
const spooled = (file, bytes) => ({
|
|
85
|
+
bytes,
|
|
86
|
+
read: (offset, length) => Effect.tryPromise({
|
|
87
|
+
try: async () => {
|
|
88
|
+
const buffer = new Uint8Array(length);
|
|
89
|
+
for (let at = 0; at < length;) {
|
|
90
|
+
const { bytesRead } = await file.read(buffer, at, length - at, offset + at);
|
|
91
|
+
if (bytesRead === 0) throw new RangeError("The spool file ended early");
|
|
92
|
+
at += bytesRead;
|
|
93
|
+
}
|
|
94
|
+
return buffer;
|
|
95
|
+
},
|
|
96
|
+
catch: () => unreadSpool
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
/** The pack, the input's rest: in memory, or spooled once it's past `spillAbove`. */
|
|
100
|
+
const packOf = async (input, spillAbove) => {
|
|
101
|
+
const chunks = [];
|
|
102
|
+
let bytes = 0;
|
|
103
|
+
let file;
|
|
104
|
+
const add = async (chunk) => {
|
|
105
|
+
bytes += chunk.length;
|
|
106
|
+
if (file === void 0 && spillAbove !== void 0 && bytes > spillAbove) {
|
|
107
|
+
file = await spoolFile();
|
|
108
|
+
for (const held of chunks.splice(0)) await writeAll(file, held);
|
|
109
|
+
}
|
|
110
|
+
if (file === void 0) chunks.push(chunk);
|
|
111
|
+
else await writeAll(file, chunk);
|
|
112
|
+
};
|
|
113
|
+
await add(input.held);
|
|
114
|
+
for (let next = await input.chunks.next(); next.done !== true; next = await input.chunks.next()) await add(next.value);
|
|
115
|
+
return file === void 0 ? packInMemory(joinedBytes(chunks)) : spooled(file, bytes);
|
|
116
|
+
};
|
|
117
|
+
/** The remote's URL from Git's: `ref0::https://…` reaches the helper as `https://…`. */
|
|
118
|
+
const remoteUrl = (given) => {
|
|
119
|
+
const url = URL.parse(given?.replace(/^ref0:\/\//, "https://") ?? "");
|
|
120
|
+
if (url === null || url.protocol !== "https:" && url.protocol !== "http:") throw new Stopped(gitError("INVALID_ARGUMENT", "git-remote-ref0 takes an https:// URL", { hint: "Name the remote as ref0::https://host/owner/repo.git" }));
|
|
121
|
+
if (url.password !== "") throw new Stopped(gitError("INVALID_ARGUMENT", "The remote's URL holds a password", { hint: "Keep it in a credential helper instead" }));
|
|
122
|
+
return url;
|
|
123
|
+
};
|
|
124
|
+
/** The credential `fill` gives for `url`, its secret redacted as it's received. */
|
|
125
|
+
const filled = async (calls, url) => {
|
|
126
|
+
const credential = await calls.fill(url).then((answer) => answer === void 0 ? void 0 : {
|
|
127
|
+
...answer,
|
|
128
|
+
password: Redacted.make(answer.password)
|
|
129
|
+
});
|
|
130
|
+
if (credential === void 0) throw new Stopped(gitError("UNAUTHENTICATED", "No credential for the remote"));
|
|
131
|
+
return credential;
|
|
132
|
+
};
|
|
133
|
+
/** What the helper must never print: its credential, raw and as Basic sends it, once it has one. */
|
|
134
|
+
const { hide, scrub: scrubbed } = secretScrubber();
|
|
135
|
+
/**
|
|
136
|
+
* Where the repo at `url` is, once an `info/refs` redirect moved it, as Git takes a renamed repo's:
|
|
137
|
+
* on `url`'s own origin only, so the credential goes nowhere else.
|
|
138
|
+
*/
|
|
139
|
+
const movedTo = (moved, url) => {
|
|
140
|
+
const to = URL.parse(moved ?? "");
|
|
141
|
+
if (to === null || to.origin !== url.origin || !to.pathname.endsWith("/info/refs")) return url;
|
|
142
|
+
const at = new URL(url);
|
|
143
|
+
at.pathname = to.pathname.slice(0, -10);
|
|
144
|
+
return at;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Git's push through `connect git-receive-pack`, relayed to the remote at `url`. As Git's own HTTPS
|
|
148
|
+
* does, it asks first with no credential, and fills one only after a 401: a remote that knows its
|
|
149
|
+
* caller some other way needs none. Once a redirect moves the repo, it fills, approves and rejects
|
|
150
|
+
* the credential for where it moved, as Git 2.53's http.c does.
|
|
151
|
+
*/
|
|
152
|
+
const push = async (calls, input, url) => {
|
|
153
|
+
const { process } = helperNode();
|
|
154
|
+
let at = url;
|
|
155
|
+
let credential;
|
|
156
|
+
let challenged = false;
|
|
157
|
+
let refused = false;
|
|
158
|
+
let moved;
|
|
159
|
+
const transport = async (request) => {
|
|
160
|
+
const response = await fetch(request);
|
|
161
|
+
if (response.redirected && new URL(request.url).pathname.endsWith("/info/refs")) moved = response.url;
|
|
162
|
+
if (response.status === 401) {
|
|
163
|
+
challenged = true;
|
|
164
|
+
refused ||= request.headers.has("authorization");
|
|
165
|
+
}
|
|
166
|
+
return response;
|
|
167
|
+
};
|
|
168
|
+
const httpAt = () => {
|
|
169
|
+
const base = `${at.origin}${at.pathname}`;
|
|
170
|
+
return credential === void 0 ? gitHttp({
|
|
171
|
+
url: base,
|
|
172
|
+
transport,
|
|
173
|
+
retry: 3
|
|
174
|
+
}) : gitHttp({
|
|
175
|
+
url: base,
|
|
176
|
+
credentials: sent(credential),
|
|
177
|
+
transport,
|
|
178
|
+
retry: 3
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
try {
|
|
182
|
+
const anonymous = await runIn(Effect.result(helperAdvertisement(httpAt())), aClient);
|
|
183
|
+
if (Result.isFailure(anonymous) && !challenged) throw new Stopped(anonymous.failure);
|
|
184
|
+
at = movedTo(moved, url);
|
|
185
|
+
if (Result.isFailure(anonymous)) {
|
|
186
|
+
credential = await filled(calls, at);
|
|
187
|
+
const { username, password } = sent(credential);
|
|
188
|
+
hide(password, Base64.encode(`${username}:${password}`));
|
|
189
|
+
}
|
|
190
|
+
const advertised = Result.isSuccess(anonymous) ? anonymous.success : await run(helperAdvertisement(httpAt()));
|
|
191
|
+
at = movedTo(moved, url);
|
|
192
|
+
const http = httpAt();
|
|
193
|
+
await written(process.stdout, joinedBytes([new Uint8Array([10]), advertised.relayed]));
|
|
194
|
+
let read = await run(readHelperStart(input.held));
|
|
195
|
+
while (read.kind === "incomplete") {
|
|
196
|
+
if (!await more(input)) return;
|
|
197
|
+
read = await run(readHelperStart(input.held));
|
|
198
|
+
}
|
|
199
|
+
if (read.kind === "nothing") return;
|
|
200
|
+
const { start, packFollows } = read;
|
|
201
|
+
const startBytes = input.held.subarray(0, start.packOffset);
|
|
202
|
+
input.held = input.held.subarray(start.packOffset);
|
|
203
|
+
const spillAbove = pushUploadAbove(advertised.capabilities);
|
|
204
|
+
const pack = packFollows ? await packOf(input, spillAbove) : packInMemory(/* @__PURE__ */ new Uint8Array());
|
|
205
|
+
const answered = await run(relayPush(http, advertised.capabilities, start, startBytes, pack));
|
|
206
|
+
await written(process.stdout, answered.report);
|
|
207
|
+
if (answered.unpacked && credential !== void 0) await calls.approve(at, given(credential));
|
|
208
|
+
} catch (error) {
|
|
209
|
+
if (refused && credential !== void 0) await calls.reject(at, given(credential));
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
/** The helper's commands, as Git sends them: `capabilities`, then `connect` to a service. */
|
|
214
|
+
const main = async (calls) => {
|
|
215
|
+
const { process } = helperNode();
|
|
216
|
+
const url = remoteUrl(process.argv[3] ?? process.argv[2]);
|
|
217
|
+
const input = {
|
|
218
|
+
held: /* @__PURE__ */ new Uint8Array(),
|
|
219
|
+
chunks: process.stdin[Symbol.asyncIterator]()
|
|
220
|
+
};
|
|
221
|
+
for (let line = await commandLine(input); line !== void 0 && line !== ""; line = await commandLine(input)) {
|
|
222
|
+
if (line === "capabilities") {
|
|
223
|
+
await written(process.stdout, "connect\n\n");
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (line === "connect git-receive-pack") return push(calls, input, url);
|
|
227
|
+
throw new Stopped(gitError("FAILED_PRECONDITION", "git-remote-ref0 takes pushes only", { hint: "Fetch from the https:// URL, or set the remote's pushurl alone to ref0::" }));
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
/** What stopped the helper, or `undefined` when it finished. */
|
|
231
|
+
const stopped = async (calls) => {
|
|
232
|
+
try {
|
|
233
|
+
await main(calls);
|
|
234
|
+
return;
|
|
235
|
+
} catch (thrown) {
|
|
236
|
+
return thrown instanceof Stopped ? thrown.error : gitError("INTERNAL", "git-remote-ref0 failed");
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Runs `git-remote-ref0` in this Node process, as Git starts it, and ends the process with its
|
|
241
|
+
* status: 0 once Git's commands end, or 128 after printing what stopped it on stderr, scrubbed of
|
|
242
|
+
* the credential `fill` gave. It reads its URL from argv, Git's commands from stdin, and writes
|
|
243
|
+
* Git's answers on stdout. It fills, approves and rejects its credential only through `calls`.
|
|
244
|
+
*/
|
|
245
|
+
const runRemoteHelper = async (calls) => {
|
|
246
|
+
const { process } = helperNode();
|
|
247
|
+
process.on("exit", removeSpool);
|
|
248
|
+
for (const [signal, status] of signals) process.on(signal, () => {
|
|
249
|
+
removeSpool();
|
|
250
|
+
process.exit(status);
|
|
251
|
+
});
|
|
252
|
+
const error = await stopped(calls);
|
|
253
|
+
if (error !== void 0) {
|
|
254
|
+
const hint = error.hint === void 0 ? "" : `hint: ${scrubbed(error.hint)}\n`;
|
|
255
|
+
await written(process.stderr, `error: ${scrubbed(error.message)}\n${hint}`).catch(() => void 0);
|
|
256
|
+
}
|
|
257
|
+
return process.exit(error === void 0 ? 0 : 128);
|
|
258
|
+
};
|
|
259
|
+
export { runRemoteHelper };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scrubber `git-remote-ref0` and `ref0-git` print through, so no secret either was given
|
|
3
|
+
* reaches its output.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* What a bin must never print, and `scrub`, which takes them out of a text: a hostile remote's
|
|
7
|
+
* refusal could echo the credential it was sent, or a link it signed. `hide` takes each secret as
|
|
8
|
+
* it would be printed, so a caller hides a credential raw and as Basic's Base64 sends it. `scrub`
|
|
9
|
+
* replaces each with `<credential>`, and its start too when a cut at the text's end leaves 4 or more
|
|
10
|
+
* of its characters, then each `https://` or `http://` link with `<link>`, unless `links: false`.
|
|
11
|
+
* It's pure: it reads and writes nothing but the secrets it's given.
|
|
12
|
+
*/
|
|
13
|
+
export declare const secretScrubber: (options?: {
|
|
14
|
+
readonly links?: boolean;
|
|
15
|
+
}) => {
|
|
16
|
+
hide: (...more: readonly string[]) => void;
|
|
17
|
+
scrub: (text: string) => string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/client/scrub.ts
|
|
2
|
+
/**
|
|
3
|
+
* The scrubber `git-remote-ref0` and `ref0-git` print through, so no secret either was given
|
|
4
|
+
* reaches its output.
|
|
5
|
+
*/
|
|
6
|
+
/** The shortest start of a secret a cut at a text's end may leave that's taken out too. */
|
|
7
|
+
const cutSecretLeast = 4;
|
|
8
|
+
/**
|
|
9
|
+
* `text` with `secret` taken out, and its start too when that ends the text: a client keeps a
|
|
10
|
+
* refusal's first 1,024 characters, so a remote can pad its echo to leave all of the secret but
|
|
11
|
+
* its last character.
|
|
12
|
+
*/
|
|
13
|
+
const withoutSecret = (text, secret) => {
|
|
14
|
+
const whole = text.replaceAll(secret, "<credential>");
|
|
15
|
+
for (let kept = secret.length - 1; kept >= cutSecretLeast; kept -= 1) if (whole.endsWith(secret.slice(0, kept))) return `${whole.slice(0, -kept)}<credential>`;
|
|
16
|
+
return whole;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* What a bin must never print, and `scrub`, which takes them out of a text: a hostile remote's
|
|
20
|
+
* refusal could echo the credential it was sent, or a link it signed. `hide` takes each secret as
|
|
21
|
+
* it would be printed, so a caller hides a credential raw and as Basic's Base64 sends it. `scrub`
|
|
22
|
+
* replaces each with `<credential>`, and its start too when a cut at the text's end leaves 4 or more
|
|
23
|
+
* of its characters, then each `https://` or `http://` link with `<link>`, unless `links: false`.
|
|
24
|
+
* It's pure: it reads and writes nothing but the secrets it's given.
|
|
25
|
+
*/
|
|
26
|
+
const secretScrubber = (options = {}) => {
|
|
27
|
+
const secrets = [];
|
|
28
|
+
return {
|
|
29
|
+
hide: (...more) => {
|
|
30
|
+
secrets.push(...more.filter((secret) => secret.length > 0));
|
|
31
|
+
},
|
|
32
|
+
scrub: (text) => {
|
|
33
|
+
const scrubbed = secrets.reduce(withoutSecret, text);
|
|
34
|
+
return options.links === false ? scrubbed : scrubbed.replace(/https?:\/\/\S+/g, "<link>");
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export { secretScrubber };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { joinedBytes } from "../protocol/bytes/joined.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Predicate from "effect/Predicate";
|
|
4
|
+
import * as Base64 from "effect/encoding/Base64";
|
|
5
|
+
// src/client/transport.ts
|
|
6
|
+
/**
|
|
7
|
+
* One remote's requests as the Web sends them: each with the credential, again as `retry` says,
|
|
8
|
+
* and once more with a fresh credential after a 401. Web `Request` and `Response` all through, so
|
|
9
|
+
* the Git client carries no HTTP client of its own.
|
|
10
|
+
*/
|
|
11
|
+
/** What a retry count sends again: no answer, a rate limit, or a gateway that couldn't reach it. */
|
|
12
|
+
const retriedStatuses = /* @__PURE__ */ new Set([
|
|
13
|
+
429,
|
|
14
|
+
502,
|
|
15
|
+
503,
|
|
16
|
+
504
|
|
17
|
+
]);
|
|
18
|
+
/** No answer at all, as `retry` sees it: status 0. */
|
|
19
|
+
const unanswered = {
|
|
20
|
+
status: 0,
|
|
21
|
+
error: {
|
|
22
|
+
code: "UNAVAILABLE",
|
|
23
|
+
message: "The remote didn't answer"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** 250 ms before the first retry, doubling to 4 s. */
|
|
27
|
+
const pauseOf = (attempt) => Math.min(250 * 2 ** (attempt - 1), 4e3);
|
|
28
|
+
/** What no header carries: CR, LF, NUL, or a character past one byte. */
|
|
29
|
+
const unsendable = /[\0\n\r]|[^\0-\u00ff]/u;
|
|
30
|
+
/**
|
|
31
|
+
* A credential no header carries, refused before it's sent. The header's own `TypeError` would
|
|
32
|
+
* name the value, so neither is a cause. It's written whole, in the shape `gitError` gives, so the
|
|
33
|
+
* REST client this module is part of carries no store code.
|
|
34
|
+
*/
|
|
35
|
+
const credentialRefused = {
|
|
36
|
+
code: "INVALID_ARGUMENT",
|
|
37
|
+
message: "The credential holds a character no HTTP header carries, such as a newline",
|
|
38
|
+
hint: "Check the token or password for a stray newline"
|
|
39
|
+
};
|
|
40
|
+
const authorization = (credential) => "token" in credential ? `Bearer ${credential.token}` : `Basic ${Base64.encode(`${credential.username}:${credential.password}`)}`;
|
|
41
|
+
const credentialOf = (credentials) => Predicate.isFunction(credentials) ? Effect.promise(async (signal) => credentials({ signal })) : Effect.succeed(credentials);
|
|
42
|
+
/**
|
|
43
|
+
* A copy of `request` to send, with the credential's header value, aborted with `signal` or with
|
|
44
|
+
* `request`'s own: the caller's, which still holds while the answer's body is read.
|
|
45
|
+
*/
|
|
46
|
+
const signed = (request, credential, signal) => {
|
|
47
|
+
const headers = new Headers(request.headers);
|
|
48
|
+
if (credential !== void 0) headers.set("authorization", credential);
|
|
49
|
+
return new Request(request.clone(), {
|
|
50
|
+
headers,
|
|
51
|
+
signal: AbortSignal.any([request.signal, signal])
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const shouldRetry = (retry, attempt, failure) => {
|
|
55
|
+
if (retry === void 0 || failure.status === 401) return false;
|
|
56
|
+
if (Predicate.isFunction(retry)) return retry({
|
|
57
|
+
attempt,
|
|
58
|
+
failure
|
|
59
|
+
});
|
|
60
|
+
return attempt <= retry && (failure.status === 0 || retriedStatuses.has(failure.status));
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Drops an answer's body unread. A clone's body is a branch of its answer's, and the remote's
|
|
64
|
+
* stream is cancelled only once both branches are.
|
|
65
|
+
*/
|
|
66
|
+
const dropped = (response) => Effect.sync(() => void response.body?.cancel().catch(() => void 0));
|
|
67
|
+
/**
|
|
68
|
+
* `response` as `fetch` answers one: when `signal` aborts before its body ends, the body is
|
|
69
|
+
* cancelled and its read errors with the signal's reason. So an answer an interrupted call drops,
|
|
70
|
+
* whoever holds it, is let go and the remote's stream ends. The listener goes once the body is
|
|
71
|
+
* read out, errs or is cancelled, a read waiting or not, and an abort after changes nothing.
|
|
72
|
+
*/
|
|
73
|
+
const abortable = (response, signal) => {
|
|
74
|
+
const body = response.body;
|
|
75
|
+
if (body === null) return response;
|
|
76
|
+
if (signal.aborted) {
|
|
77
|
+
body.cancel(signal.reason).catch(() => void 0);
|
|
78
|
+
return response;
|
|
79
|
+
}
|
|
80
|
+
const reader = body.getReader();
|
|
81
|
+
let held;
|
|
82
|
+
const ended = () => signal.removeEventListener("abort", aborted);
|
|
83
|
+
const aborted = () => {
|
|
84
|
+
held?.error(signal.reason);
|
|
85
|
+
reader.cancel(signal.reason).catch(() => void 0);
|
|
86
|
+
};
|
|
87
|
+
signal.addEventListener("abort", aborted, { once: true });
|
|
88
|
+
reader.closed.catch((cause) => {
|
|
89
|
+
ended();
|
|
90
|
+
held?.error(cause);
|
|
91
|
+
});
|
|
92
|
+
const stream = new ReadableStream({
|
|
93
|
+
start: (controller) => {
|
|
94
|
+
held = controller;
|
|
95
|
+
},
|
|
96
|
+
pull: async (controller) => {
|
|
97
|
+
const next = await reader.read();
|
|
98
|
+
if (signal.aborted) return;
|
|
99
|
+
if (next.done) {
|
|
100
|
+
ended();
|
|
101
|
+
return controller.close();
|
|
102
|
+
}
|
|
103
|
+
controller.enqueue(next.value);
|
|
104
|
+
},
|
|
105
|
+
cancel: async (reason) => {
|
|
106
|
+
ended();
|
|
107
|
+
await reader.cancel(reason);
|
|
108
|
+
}
|
|
109
|
+
}, { highWaterMark: 0 });
|
|
110
|
+
const { status, statusText, headers, redirected, url } = response;
|
|
111
|
+
const answered = new Response(stream, {
|
|
112
|
+
status,
|
|
113
|
+
statusText,
|
|
114
|
+
headers
|
|
115
|
+
});
|
|
116
|
+
return redirected ? Object.defineProperties(answered, {
|
|
117
|
+
redirected: { value: true },
|
|
118
|
+
url: { value: url }
|
|
119
|
+
}) : answered;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* The start of `response`'s body, at most `most` bytes in at most `most` reads, its rest
|
|
123
|
+
* cancelled, and whether it was `cut`: whether more came after those bytes, before its end. An
|
|
124
|
+
* interrupted read cancels it too.
|
|
125
|
+
*
|
|
126
|
+
* With `end`, for a caller that tells a cut body from a whole one, it reads once more at the
|
|
127
|
+
* bound: a body of exactly `most` bytes then its end isn't cut (#811). Anything else that read
|
|
128
|
+
* gives, an empty chunk or a failure, is cut, the bytes before it kept. Without `end`, a body that
|
|
129
|
+
* reaches the bound is cut, unread past it, so a caller that only wants its start never waits on
|
|
130
|
+
* a read more.
|
|
131
|
+
*/
|
|
132
|
+
const bodyStart = (response, most, end = false) => Effect.tryPromise(async (signal) => {
|
|
133
|
+
if (response.body === null) return {
|
|
134
|
+
bytes: /* @__PURE__ */ new Uint8Array(),
|
|
135
|
+
cut: false
|
|
136
|
+
};
|
|
137
|
+
const reader = response.body.getReader();
|
|
138
|
+
const cancel = () => void reader.cancel().catch(() => void 0);
|
|
139
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
140
|
+
try {
|
|
141
|
+
const chunks = [];
|
|
142
|
+
let size = 0;
|
|
143
|
+
let cut = false;
|
|
144
|
+
for (let read = await reader.read(); !read.done; read = await reader.read()) {
|
|
145
|
+
const allowed = read.value.subarray(0, most - size);
|
|
146
|
+
if (allowed.length > 0) chunks.push(allowed);
|
|
147
|
+
if (allowed.length < read.value.length) {
|
|
148
|
+
cut = true;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
size += Math.max(allowed.length, 1);
|
|
152
|
+
if (size >= most) {
|
|
153
|
+
cut = !end || !await reader.read().then((read) => read.done, () => false);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
cancel();
|
|
158
|
+
return {
|
|
159
|
+
bytes: joinedBytes(chunks),
|
|
160
|
+
cut
|
|
161
|
+
};
|
|
162
|
+
} finally {
|
|
163
|
+
signal.removeEventListener("abort", cancel);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
/** The start of `response`'s body as text, as `bodyStart` reads it. */
|
|
167
|
+
const bodyText = (response, most) => Effect.map(bodyStart(response, most), ({ bytes }) => new TextDecoder().decode(bytes));
|
|
168
|
+
/**
|
|
169
|
+
* What a refused answer said, read from a clone: the clone dropped once read, and the answer too
|
|
170
|
+
* when the read is interrupted, so the remote's stream ends either way.
|
|
171
|
+
*/
|
|
172
|
+
const refusalOf = (response, failureOf) => {
|
|
173
|
+
const copy = response.clone();
|
|
174
|
+
return failureOf(copy).pipe(Effect.ensuring(dropped(copy)), Effect.onInterrupt(() => dropped(response)));
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* The remote at `options`: each request sent through `options.transport`, or `fetch`, with the
|
|
178
|
+
* credential, again as `retry` says, and once more with a fresh credential after a 401 when
|
|
179
|
+
* `credentials` is a function. `failureOf` reads what a refused answer said: REST's JSON, or
|
|
180
|
+
* Git's line of text. Each send is a clone, so `request` itself is never read.
|
|
181
|
+
*/
|
|
182
|
+
const remoteFetch = (options, failureOf) => {
|
|
183
|
+
const send = options.transport ?? (async (request) => fetch(request));
|
|
184
|
+
const tries = (request, credential, attempt) => {
|
|
185
|
+
/** The next try when `retry` takes `failure`, after `drop` and a pause; else `answer`. */
|
|
186
|
+
const again = (failure, answer, drop = Effect.void) => shouldRetry(options.retry, attempt, failure) ? drop.pipe(Effect.andThen(Effect.sleep(pauseOf(attempt))), Effect.andThen(tries(request, credential, attempt + 1))) : answer;
|
|
187
|
+
return Effect.tryPromise({
|
|
188
|
+
try: async (signal) => {
|
|
189
|
+
const sent = signed(request, credential, signal);
|
|
190
|
+
return abortable(await send(sent), sent.signal);
|
|
191
|
+
},
|
|
192
|
+
catch: (cause) => ({
|
|
193
|
+
kind: "unanswered",
|
|
194
|
+
cause
|
|
195
|
+
})
|
|
196
|
+
}).pipe(Effect.matchEffect({
|
|
197
|
+
onFailure: (failed) => again(unanswered, Effect.fail(failed)),
|
|
198
|
+
onSuccess: (response) => response.status < 400 ? Effect.succeed(response) : Effect.flatMap(refusalOf(response, failureOf), (failure) => again(failure, Effect.succeed(response), dropped(response)))
|
|
199
|
+
}));
|
|
200
|
+
};
|
|
201
|
+
const signedTries = (request) => Effect.flatMap(credentialOf(options.credentials), (credential) => {
|
|
202
|
+
const value = credential === void 0 ? void 0 : authorization(credential);
|
|
203
|
+
if (value !== void 0 && unsendable.test(value)) return Effect.fail({
|
|
204
|
+
kind: "refused",
|
|
205
|
+
error: credentialRefused
|
|
206
|
+
});
|
|
207
|
+
return tries(request, value, 1);
|
|
208
|
+
});
|
|
209
|
+
return (request) => Effect.flatMap(signedTries(request), (response) => response.status === 401 && Predicate.isFunction(options.credentials) ? Effect.andThen(dropped(response), signedTries(request)) : Effect.succeed(response));
|
|
210
|
+
};
|
|
211
|
+
export { abortable, bodyStart, bodyText, credentialRefused, dropped, remoteFetch };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { RefName } from "./ids.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* What `authorize` accepts a `refs.private` operation with: the patterns, of those it was asked
|
|
4
|
+
* about, whose refs the caller sees, and those whose commits the caller may publish. A list left
|
|
5
|
+
* out is empty.
|
|
6
|
+
*/
|
|
7
|
+
export interface RefAudience {
|
|
8
|
+
readonly read?: readonly RefName[];
|
|
9
|
+
readonly publish?: readonly RefName[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Ref names from `from`, and before `to`, in the stores' id order: with no `to`, to the end of the
|
|
13
|
+
* names under the listing's prefix. A `to` ending in U+0000, which no ref name holds, ends just
|
|
14
|
+
* after the name before it, so a span can end at one name.
|
|
15
|
+
*/
|
|
16
|
+
export interface HiddenSpan {
|
|
17
|
+
readonly from: string;
|
|
18
|
+
readonly to?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Which refs one caller sees, from its `refs.private` answer. A ref it doesn't see answers as a
|
|
22
|
+
* missing one on every surface. `whole` is true when it reads every pattern: then it sees every
|
|
23
|
+
* ref, and nothing is filtered. A caller who isn't whole sees none of Git's own refs, a merge
|
|
24
|
+
* queue's candidates under `refs/queue/` and an import's staging under `refs/import/`, since they
|
|
25
|
+
* hold whatever their entries hold, private commits too.
|
|
26
|
+
*/
|
|
27
|
+
export interface RefSight {
|
|
28
|
+
readonly whole: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the caller sees `ref`: a public ref, or one whose pattern the caller reads; one of
|
|
31
|
+
* Git's own only when `whole`.
|
|
32
|
+
*/
|
|
33
|
+
readonly sees: (ref: RefName) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether a write may create `ref`: not when the caller doesn't see it, nor when a folder above
|
|
36
|
+
* it is a name the caller doesn't see, nor when it's a folder whose refs a pattern the caller
|
|
37
|
+
* doesn't read could match. Each is answered whatever refs the repo holds, so a refused create
|
|
38
|
+
* tells the caller nothing of the refs it can't see. A write that moves or deletes a ref the
|
|
39
|
+
* caller sees needs only `sees`: a held ref has no refs above or under it.
|
|
40
|
+
*/
|
|
41
|
+
readonly creates: (ref: RefName) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The names under `prefix` the caller doesn't see, all of them, as spans in id order, apart and
|
|
44
|
+
* sorted, by `byBytes`. A listing reads only the gaps between them, so what it reads follows the
|
|
45
|
+
* refs the caller sees, never how many it can't. A span from `prefix` with no `to` hides every
|
|
46
|
+
* ref under it, and the listing answers empty with no read.
|
|
47
|
+
* - Every name in a span is hidden: a pattern the caller reads, listed before the one that
|
|
48
|
+
* hides it, ends the span, since a ref is private by the first pattern that matches it.
|
|
49
|
+
* Git's own prefixes are spans too, for a caller who isn't whole.
|
|
50
|
+
* - Every hidden name is in a span: `refs.count` counts the prefix less the spans, with no row
|
|
51
|
+
* read out. A sight that leaves a hidden name out of them, an empty list with `sees` left to
|
|
52
|
+
* filter included, counts that ref where no listing shows it, so a caller learns how many refs
|
|
53
|
+
* under a prefix it can't see: the count less the listing's length. `whole` answers none.
|
|
54
|
+
* - Answered from the patterns alone, never the repo's refs, so a span tells nothing.
|
|
55
|
+
*/
|
|
56
|
+
readonly hiddenSpans: (prefix: string) => readonly HiddenSpan[];
|
|
57
|
+
/** Whether the caller reads `pattern`, one of `AccessOption.patterns`: every one when `whole`. */
|
|
58
|
+
readonly reads: (pattern: RefName) => boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the caller may publish `pattern`'s commits: make them reachable from a ref outside
|
|
61
|
+
* it, which more people see. A push that would publish one of a pattern it may not is refused,
|
|
62
|
+
* whether it reads that pattern or not. `whole` says nothing of it.
|
|
63
|
+
* - It's the `publish` half of the one answer `authorize` gives for `refs.private`, never a
|
|
64
|
+
* second decision: a host's own sight derives it and `reads` from that same answer.
|
|
65
|
+
* - Publishing needs reading too: the push's check takes a pattern as publishable only when
|
|
66
|
+
* `reads` and `publishes` both say so.
|
|
67
|
+
*/
|
|
68
|
+
readonly publishes: (pattern: RefName) => boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Private branches, as `privateRefs` from `@ref0/git/access` makes them, for `createGitServer`'s
|
|
72
|
+
* `access`. Without it, everyone who may read a repo sees all of it, and none of this runs.
|
|
73
|
+
*/
|
|
74
|
+
export interface AccessOption {
|
|
75
|
+
/** The patterns `privateRefs` was given, as written, in order. */
|
|
76
|
+
readonly patterns: readonly RefName[];
|
|
77
|
+
/**
|
|
78
|
+
* The pattern `ref` is private by: the first of `patterns`, as written, that matches its full
|
|
79
|
+
* name, where a bare pattern names a branch and `*` matches any run of characters, `/`
|
|
80
|
+
* included, as `refs.protect`'s do. `undefined` for a public ref, one no pattern matches, which
|
|
81
|
+
* everyone who may read the repo sees. A ref is seen by a caller who reads that one pattern,
|
|
82
|
+
* so list a narrower pattern before a wider one that also matches its refs.
|
|
83
|
+
*/
|
|
84
|
+
readonly patternOf: (ref: RefName) => RefName | undefined;
|
|
85
|
+
/** The refs a caller sees, given `authorize`'s answer, already checked against `patterns`. */
|
|
86
|
+
readonly sightOf: (audience: RefAudience) => RefSight;
|
|
87
|
+
}
|