@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,142 @@
|
|
|
1
|
+
import { accept, reject } from "../../contracts/result.mjs";
|
|
2
|
+
import { WalkRefused } from "../../engine/combined.mjs";
|
|
3
|
+
import { commitChangesCovered } from "./context.mjs";
|
|
4
|
+
import { fileGlobs, globsMatch, pathKey } from "./file-globs.mjs";
|
|
5
|
+
import { patternList, refMatcher, shortRef } from "./patterns.mjs";
|
|
6
|
+
// src/core/rules/files.ts
|
|
7
|
+
/** The push option that asks `authorize` to let refused files through. */
|
|
8
|
+
const allowFilesOption = "allow-files";
|
|
9
|
+
/** The most of `authorize`'s refusal a hint repeats: the host's text, in Git's output. */
|
|
10
|
+
const hostWordsMost = 200;
|
|
11
|
+
/**
|
|
12
|
+
* The files a push changes on its ref, as the rule reads them, one at a time: each commit the
|
|
13
|
+
* push brings, and the paths it changes against every parent, as `PushContext.commitChanges`
|
|
14
|
+
* lists them. Through the API, a merge commit's parent past the first counts only when it's the
|
|
15
|
+
* tip of a ref this rule covers, so the rule judged it when it got there (Q732). Each one's path
|
|
16
|
+
* alone is read, never its contents.
|
|
17
|
+
*/
|
|
18
|
+
const changedFiles = (input, by) => commitChangesCovered(input, by);
|
|
19
|
+
/** What the ref is called in a refusal: a branch by that word. */
|
|
20
|
+
const refWord = (ref) => ref.startsWith("refs/heads/") ? "this branch" : "this ref";
|
|
21
|
+
/** The first refused file, and how many more, as the refusal names them. */
|
|
22
|
+
const named = (first, total) => total === 1 ? first : `${first} and ${total - 1} more ${total === 2 ? "file" : "files"}`;
|
|
23
|
+
/** A commit as the refusal names it: 7 hex digits, as Git's default `core.abbrev`. */
|
|
24
|
+
const shortId = (oid) => oid.slice(0, 7);
|
|
25
|
+
/** How the person takes the file out: amend the commit, or rebase from before it. */
|
|
26
|
+
const removal = ({ first, several }) => {
|
|
27
|
+
if (!several) return "Remove it, amend the commit and push again";
|
|
28
|
+
const id = shortId(first.commit);
|
|
29
|
+
return `Remove it from ${id}, for example with git rebase -i ${first.root ? "--root" : `${id}~1`}, and push again`;
|
|
30
|
+
};
|
|
31
|
+
/** The lines a refusal's hint ends with: the listing of each commit, and a push of one ref. */
|
|
32
|
+
const after = (where) => {
|
|
33
|
+
const lines = [];
|
|
34
|
+
const path = where.first.change.path;
|
|
35
|
+
if (where.several) lines.push(`To list each commit that changes it: git log --oneline HEAD --branches --not --remotes -- ${path}`);
|
|
36
|
+
if (where.refs > 1) lines.push(`This push moves ${where.refs} refs. If only another ref's commits add it, push ${shortRef(where.ref)} on its own`);
|
|
37
|
+
return lines;
|
|
38
|
+
};
|
|
39
|
+
const hintOf = (first, where) => [first, ...after(where)].join("\n");
|
|
40
|
+
const refusalOf = (where, total, hint) => {
|
|
41
|
+
const first = where.first.change.path;
|
|
42
|
+
return {
|
|
43
|
+
message: `${`${named(first, total)} ${total === 1 ? "isn't" : "aren't"} allowed on ${refWord(where.ref)}`}${where.several ? `: ${shortId(where.first.commit)} adds ${total === 1 ? "it" : first}` : ""}`,
|
|
44
|
+
hint,
|
|
45
|
+
context: {
|
|
46
|
+
reason: "files-refused",
|
|
47
|
+
paths: [first],
|
|
48
|
+
total
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/** `authorize`'s refusal as a hint repeats it: its first line, cut to `hostWordsMost`. */
|
|
53
|
+
const hostWords = (message) => {
|
|
54
|
+
const line = (message.split(/\r?\n/, 1)[0] ?? "").trim();
|
|
55
|
+
return line.length <= hostWordsMost ? line : `${line.slice(0, 199)}…`;
|
|
56
|
+
};
|
|
57
|
+
/** An API move's fix: the merge commit that keeps an overridden file, or the file taken out. */
|
|
58
|
+
const mergeInstead = "If -o allow-files let it through on the branch you're merging, use a merge commit, not a squash or rebase. Otherwise, remove it and try again";
|
|
59
|
+
/**
|
|
60
|
+
* `refs.files`. On a ref `patterns` name, a push that adds or changes a file `refuse` matches, in
|
|
61
|
+
* any commit it brings, is refused, naming the first it finds; a deleted file isn't. With
|
|
62
|
+
* `-o allow-files`, it asks `authorize` for `files.allow` with each matched path, at most
|
|
63
|
+
* `allowedFilesMost`, instead.
|
|
64
|
+
*
|
|
65
|
+
* Its memory doesn't grow with the push: it keeps its read globs, one path at a time, a count, the
|
|
66
|
+
* first match, and the refused files, each once, at most one past `allowedFilesMost`. What it reads
|
|
67
|
+
* is `commitChanges`', one commit at a time.
|
|
68
|
+
*/
|
|
69
|
+
const fileRule = (patterns, options) => {
|
|
70
|
+
const matches = refMatcher(patterns);
|
|
71
|
+
const globs = fileGlobs(options.refuse);
|
|
72
|
+
const names = patternList(patterns).join(", ");
|
|
73
|
+
const judging = {
|
|
74
|
+
covers: matches,
|
|
75
|
+
refuses: (change) => change.status !== "D" && globsMatch(globs, pathKey(change.path, change.pathBytes))
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
name: `refs.files(${names})`,
|
|
79
|
+
check: async (input) => {
|
|
80
|
+
const { ref, to } = input.update;
|
|
81
|
+
if (to === null || !matches(ref)) return accept();
|
|
82
|
+
const allowing = input.pushOptions?.includes(allowFilesOption) === true;
|
|
83
|
+
const keys = [];
|
|
84
|
+
const paths = [];
|
|
85
|
+
let first;
|
|
86
|
+
let several = false;
|
|
87
|
+
let total = 0;
|
|
88
|
+
try {
|
|
89
|
+
for await (const found of changedFiles(input, judging)) {
|
|
90
|
+
const { change } = found;
|
|
91
|
+
const key = pathKey(change.path, change.pathBytes);
|
|
92
|
+
if (change.status === "D" || !globsMatch(globs, key)) continue;
|
|
93
|
+
first ??= found;
|
|
94
|
+
if (found.commit !== first.commit) several = true;
|
|
95
|
+
if (keys.includes(key)) continue;
|
|
96
|
+
total += 1;
|
|
97
|
+
if (keys.length <= 100) {
|
|
98
|
+
keys.push(key);
|
|
99
|
+
paths.push(change.path);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} catch (thrown) {
|
|
103
|
+
if (!(thrown instanceof WalkRefused)) throw thrown;
|
|
104
|
+
return thrown.rejected;
|
|
105
|
+
}
|
|
106
|
+
if (first === void 0) return accept();
|
|
107
|
+
if (first.commit !== to) several = true;
|
|
108
|
+
const moved = input.source === "api";
|
|
109
|
+
const where = {
|
|
110
|
+
ref,
|
|
111
|
+
first,
|
|
112
|
+
several,
|
|
113
|
+
refs: input.push.updates.length,
|
|
114
|
+
moved
|
|
115
|
+
};
|
|
116
|
+
if (moved) return reject(refusalOf(where, total, mergeInstead));
|
|
117
|
+
if (!allowing) {
|
|
118
|
+
const line = `${removal(where)}, or push with -o ${allowFilesOption} if it's meant to be there`;
|
|
119
|
+
return reject(refusalOf(where, total, hintOf(line, where)));
|
|
120
|
+
}
|
|
121
|
+
if (total > 100) return reject({
|
|
122
|
+
message: `${allowFilesOption} lets at most 100 files through a ref: ${total} match`,
|
|
123
|
+
hint: "Push fewer of them at a time, or edit the rule in policy.ts",
|
|
124
|
+
context: {
|
|
125
|
+
reason: "files-refused",
|
|
126
|
+
paths: [first.change.path],
|
|
127
|
+
total
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const answer = await input.authorize({
|
|
131
|
+
kind: "files.allow",
|
|
132
|
+
repo: input.repo,
|
|
133
|
+
ref,
|
|
134
|
+
paths
|
|
135
|
+
});
|
|
136
|
+
if (answer.kind === "accept") return accept();
|
|
137
|
+
const line = `-o ${allowFilesOption} was refused: ${hostWords(answer.message)}. ${removal(where)}`;
|
|
138
|
+
return reject(refusalOf(where, total, hintOf(line, where)));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
export { allowFilesOption, fileRule };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/core/rules/patterns.ts
|
|
2
|
+
/** A pattern's full ref: a bare name, such as `main`, means `refs/heads/main`. */
|
|
3
|
+
const fullPattern = (pattern) => pattern.startsWith("refs/") ? pattern : `refs/heads/${pattern}`;
|
|
4
|
+
/** A ref as a person reads it: a branch by its name, any other ref whole. */
|
|
5
|
+
const shortRef = (ref) => ref.startsWith("refs/heads/") ? ref.slice(11) : ref;
|
|
6
|
+
const escaped = (text) => text.replaceAll(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
7
|
+
/** `patterns` as a list. */
|
|
8
|
+
const patternList = (patterns) => {
|
|
9
|
+
return [].concat(patterns);
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Whether a ref is one `patterns` names. `*` matches any run of characters, `/` included, so
|
|
13
|
+
* `release/*` protects every ref under `refs/heads/release/`, however deep: a pattern that
|
|
14
|
+
* protected less than it reads would leave a ref open. An empty pattern is a `TypeError`.
|
|
15
|
+
*/
|
|
16
|
+
const refMatcher = (patterns) => {
|
|
17
|
+
const listed = patternList(patterns);
|
|
18
|
+
if (listed.length === 0 || listed.some((pattern) => pattern.length === 0)) throw new TypeError("A ref pattern names a ref: got none, or an empty one");
|
|
19
|
+
const sources = listed.map((pattern) => fullPattern(pattern).split("*").map(escaped).join(".*"));
|
|
20
|
+
const matcher = new RegExp(`^(?:${sources.join("|")})$`, "s");
|
|
21
|
+
return (ref) => matcher.test(ref);
|
|
22
|
+
};
|
|
23
|
+
export { fullPattern, patternList, refMatcher, shortRef };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../../contracts/refs.mjs";
|
|
2
|
+
import { RefRules } from "../../contracts/rules.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* `refs.protect`, `refs.lock` and `refs.files`, which `files.ts` holds. A protected ref may be
|
|
5
|
+
* created by any source, and never deleted or force-pushed; with `sources`, only those sources
|
|
6
|
+
* move it. A change the rule refuses asks `authorize` for `protect.bypass`, or `lock.bypass`, which
|
|
7
|
+
* lifts the rule for that change when accepted.
|
|
8
|
+
*/
|
|
9
|
+
export declare const refs: RefRules;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { accept, reject } from "../../contracts/result.mjs";
|
|
2
|
+
import { fileRule } from "./files.mjs";
|
|
3
|
+
import { patternList, refMatcher, shortRef } from "./patterns.mjs";
|
|
4
|
+
// src/core/rules/protect.ts
|
|
5
|
+
const refSources = [
|
|
6
|
+
"git",
|
|
7
|
+
"api",
|
|
8
|
+
"queue",
|
|
9
|
+
"import"
|
|
10
|
+
];
|
|
11
|
+
/** How each source reads in a refusal: the way a change came in. */
|
|
12
|
+
const sourceWords = {
|
|
13
|
+
git: "a push",
|
|
14
|
+
api: "the API",
|
|
15
|
+
queue: "the merge queue",
|
|
16
|
+
import: "an import"
|
|
17
|
+
};
|
|
18
|
+
/** Each `refs.protect` and `refs.lock` rule's protection, for the server's start and `refs.protection`. */
|
|
19
|
+
const protections = /* @__PURE__ */ new WeakMap();
|
|
20
|
+
/** The sources `rule` lets change its refs, when it's a `refs.protect` or `refs.lock` that names any. */
|
|
21
|
+
const protectedSources = (rule) => protections.get(rule)?.sources;
|
|
22
|
+
/**
|
|
23
|
+
* How `rules`' `refs.protect` and `refs.lock` guard `ref`, or `undefined` when none names it. A
|
|
24
|
+
* change passes every rule that matches, so the sources are those each one that names any lets in,
|
|
25
|
+
* in `refSources`' order. Custom rules aren't told.
|
|
26
|
+
*/
|
|
27
|
+
const refProtection = (rules, ref) => {
|
|
28
|
+
const matching = rules.flatMap((rule) => {
|
|
29
|
+
const protection = protections.get(rule);
|
|
30
|
+
return protection?.matches(ref) === true ? [protection] : [];
|
|
31
|
+
});
|
|
32
|
+
if (matching.length === 0) return void 0;
|
|
33
|
+
const named = matching.flatMap(({ sources }) => sources === void 0 ? [] : [sources]);
|
|
34
|
+
if (named.length === 0) return {};
|
|
35
|
+
return { sources: refSources.filter((source) => named.every((some) => some.includes(source))) };
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Throws a `TypeError` when one of `rules` is a `refs.protect` that lets the merge queue move its
|
|
39
|
+
* refs, on a server with no merge queue: nothing would ever move them, and the host meant
|
|
40
|
+
* something to.
|
|
41
|
+
*/
|
|
42
|
+
const servedSources = (rules) => {
|
|
43
|
+
for (const rule of rules) {
|
|
44
|
+
if (protectedSources(rule)?.includes("queue") !== true) continue;
|
|
45
|
+
throw new TypeError(`The push rule '${rule.name}' lets the merge queue move its refs, but this server has no merge queue`);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const listed = (words) => words.length <= 1 ? words.join("") : `${words.slice(0, -1).join(", ")} or ${words[words.length - 1]}`;
|
|
49
|
+
/**
|
|
50
|
+
* Why a protected ref can't take `input`'s change, never a create, which it always can, or
|
|
51
|
+
* `undefined` when it can: a delete and a force never can; a fast-forward only from a source
|
|
52
|
+
* `sources` names.
|
|
53
|
+
*/
|
|
54
|
+
const refusalOf = (input, sources) => {
|
|
55
|
+
const { update, source } = input;
|
|
56
|
+
const name = shortRef(update.ref);
|
|
57
|
+
if (sources?.length === 0) return { message: `${name} is locked: it never moves or goes away` };
|
|
58
|
+
if (update.kind === "delete") return { message: `${name} is protected: it can't be deleted` };
|
|
59
|
+
if (update.kind === "force") return {
|
|
60
|
+
message: `${name} is protected: it can't be force-pushed`,
|
|
61
|
+
hint: "Fetch and merge it, then push again"
|
|
62
|
+
};
|
|
63
|
+
if (sources === void 0 || sources.includes(source)) return void 0;
|
|
64
|
+
const through = listed(sources.map((named) => sourceWords[named]));
|
|
65
|
+
return sources.includes("queue") ? {
|
|
66
|
+
message: `${name} is protected: changes reach it only through ${through}`,
|
|
67
|
+
hint: "Push to another branch and queue it"
|
|
68
|
+
} : { message: `${name} is protected: changes reach it only through ${through}` };
|
|
69
|
+
};
|
|
70
|
+
const sourcesOf = (sources) => {
|
|
71
|
+
const unknown = sources?.find((source) => !refSources.includes(source));
|
|
72
|
+
if (unknown !== void 0) throw new TypeError(`A ref's sources are ${listed(refSources)}: got '${String(unknown)}'`);
|
|
73
|
+
return sources === void 0 ? void 0 : [...new Set(sources)];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* What a `kind` rule asks `authorize` to lift for `input`'s change, which it refuses: the one
|
|
77
|
+
* place either kind's operation is built, from the rule's input.
|
|
78
|
+
*/
|
|
79
|
+
const bypassOf = (kind, input, move) => ({
|
|
80
|
+
kind: `${kind}.bypass`,
|
|
81
|
+
repo: input.repo,
|
|
82
|
+
ref: input.update.ref,
|
|
83
|
+
move,
|
|
84
|
+
source: input.source
|
|
85
|
+
});
|
|
86
|
+
const protectRule = (kind, patterns, options) => {
|
|
87
|
+
const matches = refMatcher(patterns);
|
|
88
|
+
const sources = sourcesOf(options.sources);
|
|
89
|
+
const rule = {
|
|
90
|
+
name: `refs.${kind}(${patternList(patterns).join(", ")})`,
|
|
91
|
+
check: async (input) => {
|
|
92
|
+
const move = input.update.kind;
|
|
93
|
+
if (!matches(input.update.ref) || move === "create") return accept();
|
|
94
|
+
const refusal = refusalOf(input, sources);
|
|
95
|
+
if (refusal === void 0) return accept();
|
|
96
|
+
return (await input.authorize(bypassOf(kind, input, move))).kind === "accept" ? accept() : reject(refusal);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
protections.set(rule, {
|
|
100
|
+
matches,
|
|
101
|
+
sources
|
|
102
|
+
});
|
|
103
|
+
return rule;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* `refs.protect`, `refs.lock` and `refs.files`, which `files.ts` holds. A protected ref may be
|
|
107
|
+
* created by any source, and never deleted or force-pushed; with `sources`, only those sources
|
|
108
|
+
* move it. A change the rule refuses asks `authorize` for `protect.bypass`, or `lock.bypass`, which
|
|
109
|
+
* lifts the rule for that change when accepted.
|
|
110
|
+
*/
|
|
111
|
+
const refs = {
|
|
112
|
+
files: fileRule,
|
|
113
|
+
protect: (patterns, options = {}) => protectRule("protect", patterns, options),
|
|
114
|
+
lock: (patterns) => protectRule("lock", patterns, { sources: [] })
|
|
115
|
+
};
|
|
116
|
+
export { refProtection, refs, servedSources };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Caller } from "../contracts/actors.mjs";
|
|
2
|
+
import { RepoId } from "../contracts/ids.mjs";
|
|
3
|
+
import { Operation } from "../contracts/operations.mjs";
|
|
4
|
+
import { GitError } from "../contracts/result.mjs";
|
|
5
|
+
import "../contracts/server.mjs";
|
|
6
|
+
import "../contracts/services.mjs";
|
|
7
|
+
import { TokenId } from "../contracts/tokens.mjs";
|
|
8
|
+
import "../auth/identify.mjs";
|
|
9
|
+
import "../store/promises.mjs";
|
|
10
|
+
import "./access.mjs";
|
|
11
|
+
import "./call-names.mjs";
|
|
12
|
+
import { FeedItem } from "./events/stream.mjs";
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
/** A revoke over HTTP names only the token: `authorize` is asked about what the token covers. */
|
|
15
|
+
export interface TokenRevokeCheck {
|
|
16
|
+
readonly kind: 'token.revoke';
|
|
17
|
+
readonly token: TokenId;
|
|
18
|
+
}
|
|
19
|
+
/** One check a route asks before its call: `repo`, when the operation is on one. */
|
|
20
|
+
export interface SeamAuthorizeInput {
|
|
21
|
+
readonly caller: Caller;
|
|
22
|
+
readonly operation: Operation | TokenRevokeCheck;
|
|
23
|
+
readonly repo?: RepoId;
|
|
24
|
+
}
|
|
25
|
+
/** Opens a repo's event stream for `caller`: `openFeed` over the server's core and clock. */
|
|
26
|
+
export type Listen = (caller: Caller, repo: RepoId, after: number | undefined) => Effect.Effect<ReadableStream<FeedItem>, GitError>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { redirectOf, resolveRepo } from "../store/catalogue.mjs";
|
|
2
|
+
import { readableRedirect } from "./access.mjs";
|
|
3
|
+
import { callOf, lazyGroups } from "./promise.mjs";
|
|
4
|
+
import { revokeCheck } from "./tokens.mjs";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
// src/core/seam.ts
|
|
7
|
+
const seamByServer = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
/** Called once, by `createGitServer`, for the server it returns. */
|
|
9
|
+
const attachParts = (server, seam) => {
|
|
10
|
+
seamByServer.set(server, seam);
|
|
11
|
+
};
|
|
12
|
+
/** The seam of a server `createGitServer` made; `undefined` for any other. */
|
|
13
|
+
const seamOf = (server) => seamByServer.get(server);
|
|
14
|
+
/** `seam`'s parts but its core, each waiting for the build: a route's, made before it. */
|
|
15
|
+
const lazyParts = (seam) => {
|
|
16
|
+
const { parts } = seam;
|
|
17
|
+
return {
|
|
18
|
+
basePath: seam.basePath,
|
|
19
|
+
callsFor: (caller) => lazyGroups(seam.names, (group, name, args) => Effect.flatMap(parts, (built) => callOf(built.callsFor(caller), group, name)(...args))),
|
|
20
|
+
identify: (request) => Effect.flatMap(parts, (built) => built.identify(request)),
|
|
21
|
+
authorize: (input) => Effect.flatMap(parts, (built) => built.authorize(input)),
|
|
22
|
+
renamedTo: (caller, repo) => Effect.flatMap(parts, (built) => built.renamedTo(caller, repo)),
|
|
23
|
+
listen: (caller, repo, after) => Effect.flatMap(parts, (built) => built.listen(caller, repo, after))
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* `authorize` for a route: a repo's operation with the repo's access, or a revoke against the
|
|
28
|
+
* token's own coverage. A repo that isn't there is asked without access, and a caller it lets
|
|
29
|
+
* through meets the call's own `NOT_FOUND`.
|
|
30
|
+
*/
|
|
31
|
+
const seamAuthorizer = (core) => (input) => {
|
|
32
|
+
const { caller, operation } = input;
|
|
33
|
+
if ("token" in operation) return revokeCheck(core, caller, operation.token);
|
|
34
|
+
const checked = operation;
|
|
35
|
+
if (input.repo === void 0) return core.authorize({
|
|
36
|
+
caller,
|
|
37
|
+
operation: checked
|
|
38
|
+
});
|
|
39
|
+
return resolveRepo(core.store, input.repo).pipe(Effect.map(({ name, record, internalId }) => ({
|
|
40
|
+
id: name,
|
|
41
|
+
public: record.public,
|
|
42
|
+
internalId
|
|
43
|
+
})), Effect.catch((error) => error.code === "NOT_FOUND" ? Effect.succeed(void 0) : Effect.fail(error)), Effect.flatMap((repo) => repo === void 0 ? core.authorize({
|
|
44
|
+
caller,
|
|
45
|
+
operation: checked
|
|
46
|
+
}) : core.authorize({
|
|
47
|
+
caller,
|
|
48
|
+
operation: checked,
|
|
49
|
+
repo
|
|
50
|
+
})));
|
|
51
|
+
};
|
|
52
|
+
/** Where `repo` went, for a route's redirect: only to a caller that may read it there. */
|
|
53
|
+
const renamedTo = (core) => (caller, repo) => Effect.flatMap(redirectOf(core.store, repo), (to) => to === void 0 ? Effect.succeed(void 0) : readableRedirect(core, caller, to));
|
|
54
|
+
export { attachParts, lazyParts, renamedTo, seamAuthorizer, seamOf };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { grantNameOf } from "../auth/grants.mjs";
|
|
2
|
+
import { fail } from "../store/errors.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
// src/core/sight.ts
|
|
7
|
+
/** What a caller who reads every pattern, or any caller of a server with no `access`, sees. */
|
|
8
|
+
const wholeSight = {
|
|
9
|
+
whole: true,
|
|
10
|
+
sees: () => true,
|
|
11
|
+
creates: () => true,
|
|
12
|
+
hiddenSpans: () => [],
|
|
13
|
+
reads: () => true,
|
|
14
|
+
publishes: () => true
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A request's `refs.private` answers, by repo and caller, so a request asks once for each however
|
|
18
|
+
* many times it opens a repo: a write opens it twice, and 10,000 refs make one call.
|
|
19
|
+
* `withAudienceMemo` starts one for each call and each HTTP request.
|
|
20
|
+
*/
|
|
21
|
+
const AudienceMemo = Context.Service("@ref0/git/AudienceMemo");
|
|
22
|
+
/**
|
|
23
|
+
* A request's narrowed objects, by repo, caller and version, so the objects a caller's refs reach
|
|
24
|
+
* are read once a request: a write that opens a repo twice, or a fetch's want check and its plan,
|
|
25
|
+
* share one set. Like `AudienceMemo`, one serves one call or one request, never two callers.
|
|
26
|
+
* Under a key it holds one entry per distinct tip list the request asked by, each the set those
|
|
27
|
+
* tips reach.
|
|
28
|
+
*/
|
|
29
|
+
const SeenMemo = Context.Service("@ref0/git/SeenMemo");
|
|
30
|
+
/** `effect` with memos of its own for `refs.private`'s answers and the objects they narrow to. */
|
|
31
|
+
const withAudienceMemo = (effect) => Effect.suspend(() => effect.pipe(Effect.provideService(AudienceMemo, /* @__PURE__ */ new Map()), Effect.provideService(SeenMemo, /* @__PURE__ */ new Map())));
|
|
32
|
+
/**
|
|
33
|
+
* The objects `caller` reads of a repo at `version` from `tips`, `make`'s, kept for the request.
|
|
34
|
+
* A held set is answered only for the same tips, compared in full as sets, so a tip named twice
|
|
35
|
+
* counts once: the same version can be asked by other tips, as a push's own refs are. `make`
|
|
36
|
+
* answers `undefined` only for objects sealed with no index, which `createGitServer` never makes
|
|
37
|
+
* under `access`, so that fails closed.
|
|
38
|
+
*/
|
|
39
|
+
const seenIn = (caller, internalId, version, tips, make) => Effect.gen(function* () {
|
|
40
|
+
const memo = yield* Effect.serviceOption(SeenMemo);
|
|
41
|
+
const key = `${memoKey(internalId, caller)}@${version}`;
|
|
42
|
+
const asked = new Set(tips);
|
|
43
|
+
const entries = Option.isSome(memo) ? memo.value.get(key) : void 0;
|
|
44
|
+
const held = entries?.find((entry) => entry.tips.size === asked.size && tips.every((tip) => entry.tips.has(tip)));
|
|
45
|
+
if (held !== void 0) return held.objects;
|
|
46
|
+
const made = make();
|
|
47
|
+
if (made === void 0) return yield* fail("INTERNAL", "access hides objects, which needs objects that keep an index");
|
|
48
|
+
if (Option.isSome(memo)) {
|
|
49
|
+
const entry = {
|
|
50
|
+
tips: asked,
|
|
51
|
+
objects: made
|
|
52
|
+
};
|
|
53
|
+
if (entries === void 0) memo.value.set(key, [entry]);
|
|
54
|
+
else entries.push(entry);
|
|
55
|
+
}
|
|
56
|
+
return made;
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* The memo's key: the repo, and every part of the caller `authorize` may answer by but the
|
|
60
|
+
* actor's `meta`. One actor with two tokens, or a token and a grant, is two callers, each asked on
|
|
61
|
+
* its own. `meta` is left out because one memo serves one call or one request, which acts for one
|
|
62
|
+
* caller: two callers who differ only by `meta` must never share a memo, so a call that acts for
|
|
63
|
+
* more than one caller starts a memo for each, with `withAudienceMemo`.
|
|
64
|
+
*/
|
|
65
|
+
const memoKey = (internalId, caller) => JSON.stringify([
|
|
66
|
+
internalId,
|
|
67
|
+
caller.actor.anonymous === true ? null : caller.actor.id,
|
|
68
|
+
caller.subject?.id ?? null,
|
|
69
|
+
caller.token === void 0 ? null : [
|
|
70
|
+
caller.token.id,
|
|
71
|
+
caller.token.scope,
|
|
72
|
+
caller.token.repo ?? null,
|
|
73
|
+
caller.token.prefix ?? null
|
|
74
|
+
],
|
|
75
|
+
grantNameOf(caller) ?? null
|
|
76
|
+
]);
|
|
77
|
+
/** `caller`'s sight of `repo`'s refs, asked of `authorize` once per request at most. */
|
|
78
|
+
const sightIn = (core, caller, repo) => {
|
|
79
|
+
const { access } = core;
|
|
80
|
+
if (access === void 0) return Effect.succeed(wholeSight);
|
|
81
|
+
const ask = Effect.map(Effect.suspend(() => core.audience({
|
|
82
|
+
caller,
|
|
83
|
+
repo,
|
|
84
|
+
patterns: access.patterns
|
|
85
|
+
})), (audience) => access.sightOf(audience));
|
|
86
|
+
return Effect.gen(function* () {
|
|
87
|
+
const memo = yield* Effect.serviceOption(AudienceMemo);
|
|
88
|
+
if (Option.isNone(memo)) return yield* ask;
|
|
89
|
+
const key = memoKey(repo.internalId, caller);
|
|
90
|
+
const held = memo.value.get(key);
|
|
91
|
+
if (held !== void 0) return yield* held;
|
|
92
|
+
const once = yield* Effect.cached(ask);
|
|
93
|
+
const raced = memo.value.get(key);
|
|
94
|
+
if (raced !== void 0) return yield* raced;
|
|
95
|
+
memo.value.set(key, once);
|
|
96
|
+
return yield* once;
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
export { AudienceMemo, SeenMemo, seenIn, sightIn, wholeSight, withAudienceMemo };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { readToken } from "../auth/token-rows.mjs";
|
|
2
|
+
import { isPrefixTarget, tokenParties } from "../auth/tokens.mjs";
|
|
3
|
+
import { namedRecordOf } from "../store/catalogue.mjs";
|
|
4
|
+
import { fail, gitError } from "../store/errors.mjs";
|
|
5
|
+
import { openRepo } from "./access.mjs";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
// src/core/tokens.ts
|
|
8
|
+
const noToken = (id) => gitError("NOT_FOUND", `No token '${id}'`);
|
|
9
|
+
/**
|
|
10
|
+
* `authorize` on a create's or a list's target: a repo's with the repo's access, answering the repo
|
|
11
|
+
* it checked, which the call then holds to, or a prefix's.
|
|
12
|
+
*/
|
|
13
|
+
const targetCheck = (core, caller, ask, target) => isPrefixTarget(target) ? Effect.as(core.authorize({
|
|
14
|
+
caller,
|
|
15
|
+
operation: {
|
|
16
|
+
...ask,
|
|
17
|
+
prefix: target.prefix
|
|
18
|
+
}
|
|
19
|
+
}), void 0) : Effect.map(openRepo(core, caller, {
|
|
20
|
+
...ask,
|
|
21
|
+
repo: target
|
|
22
|
+
}), ({ internalId }) => internalId);
|
|
23
|
+
/**
|
|
24
|
+
* `authorize` asked `ask` of a repo token's own repo, found by its internal ID, never by name:
|
|
25
|
+
* under the name the catalogue gives it and with its own record, as a list of its tokens is asked,
|
|
26
|
+
* so a host that decides by visibility answers the two alike. A rename that lost its new name, or
|
|
27
|
+
* handed its old one on, never has another repo's record asked. A repo no name reaches is
|
|
28
|
+
* `NOT_FOUND` for a get and a revoke alike, since a name its record once held may be another
|
|
29
|
+
* repo's now: its token reaches nothing then, as a repo token's ceiling matches a repo by name and
|
|
30
|
+
* then by the repo the name holds, and once the repo is named again, it's asked of there. Answers
|
|
31
|
+
* the name it asked of.
|
|
32
|
+
*/
|
|
33
|
+
const ownRepoCheck = Effect.fnUntraced(function* (core, caller, ask, internalId) {
|
|
34
|
+
const named = yield* namedRecordOf(core.store, internalId);
|
|
35
|
+
if (named === void 0) return yield* fail("NOT_FOUND", "No repo");
|
|
36
|
+
const repo = {
|
|
37
|
+
id: named.name,
|
|
38
|
+
public: named.record.public,
|
|
39
|
+
internalId
|
|
40
|
+
};
|
|
41
|
+
yield* core.authorize({
|
|
42
|
+
caller,
|
|
43
|
+
operation: {
|
|
44
|
+
...ask,
|
|
45
|
+
repo: named.name
|
|
46
|
+
},
|
|
47
|
+
repo
|
|
48
|
+
});
|
|
49
|
+
return named.name;
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* A call on one token by ID, `kind` as `authorize` is asked it of the token's coverage, a revoke
|
|
53
|
+
* with the subject the stored record names: an anonymous caller is asked to sign in before
|
|
54
|
+
* anything is read, and for a signed-in one an unknown ID and a refused one are both `NOT_FOUND`,
|
|
55
|
+
* so IDs can't be probed, whoever's they are. Answers the token's record.
|
|
56
|
+
*/
|
|
57
|
+
const heldCheck = Effect.fnUntraced(function* (core, caller, id, kind) {
|
|
58
|
+
if (caller.actor.anonymous === true) return yield* fail("UNAUTHENTICATED", "Sign in first", { hint: "Send a token or credentials" });
|
|
59
|
+
const held = yield* readToken(core.store, id);
|
|
60
|
+
if (held === void 0) return yield* Effect.fail(noToken(id));
|
|
61
|
+
const { place, record } = held;
|
|
62
|
+
const ask = kind === "token.revoke" ? {
|
|
63
|
+
kind,
|
|
64
|
+
subject: { id: record.subject.id }
|
|
65
|
+
} : { kind };
|
|
66
|
+
const name = yield* (place.kind === "prefix" ? Effect.as(core.authorize({
|
|
67
|
+
caller,
|
|
68
|
+
operation: {
|
|
69
|
+
...ask,
|
|
70
|
+
prefix: place.prefix
|
|
71
|
+
}
|
|
72
|
+
}), void 0) : ownRepoCheck(core, caller, ask, place.internalId)).pipe(Effect.catch((error) => error.code === "UNAVAILABLE" ? Effect.fail(error) : Effect.fail(noToken(id))));
|
|
73
|
+
return record.repo === void 0 || name === void 0 ? record : {
|
|
74
|
+
...record,
|
|
75
|
+
repo: name
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
/** A revoke by ID, as `heldCheck` asks it: `token.revoke` of what the token covers. */
|
|
79
|
+
const revokeCheck = (core, caller, id) => Effect.asVoid(heldCheck(core, caller, id, "token.revoke"));
|
|
80
|
+
/**
|
|
81
|
+
* `tokens` for `caller`, the one `identify` answered: each call asks `authorize` about what it
|
|
82
|
+
* reaches before the trusted call runs, on the repo it checked, so a credential's ceiling holds here
|
|
83
|
+
* as on every other call. A host's direct calls, with no caller, are the trusted ones themselves.
|
|
84
|
+
*/
|
|
85
|
+
const callerTokenCalls = (core, tokens, caller) => ({
|
|
86
|
+
create: (target, input) => Effect.flatMap(targetCheck(core, caller, {
|
|
87
|
+
kind: "token.create",
|
|
88
|
+
...tokenParties(input)
|
|
89
|
+
}, target), (held) => tokens.create(target, input, held)),
|
|
90
|
+
list: (target, input) => Effect.flatMap(targetCheck(core, caller, { kind: "token.list" }, target), (held) => tokens.list(target, input, held)),
|
|
91
|
+
get: (id) => heldCheck(core, caller, id, "token.list"),
|
|
92
|
+
revoke: (id, input) => Effect.andThen(revokeCheck(core, caller, id), tokens.revoke(id, input, caller)),
|
|
93
|
+
revokeKey: () => fail("NOT_ALLOWED", "Revoking by key is a host's own call")
|
|
94
|
+
});
|
|
95
|
+
export { callerTokenCalls, revokeCheck };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../contracts/actors.mjs";
|
|
2
|
+
import "../contracts/refs.mjs";
|
|
3
|
+
import "../contracts/objects.mjs";
|
|
4
|
+
import "../contracts/store.mjs";
|
|
5
|
+
import "../store/catalogue.mjs";
|
|
6
|
+
import "../store/ref-rows.mjs";
|
|
7
|
+
import "./access.mjs";
|
|
8
|
+
import { Read, Row } from "@ref0/infra";
|
|
9
|
+
import "effect/Effect";
|