@ref0/git 0.12.0 → 0.20.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/access/private-refs.mjs +3 -3
- package/dist/auth/access-jwt.mjs +2 -2
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +4 -20
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -28
- package/dist/auth/tokens-layer.mjs +6 -12
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -17
- package/dist/auth/tokens.mjs +9 -87
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +35 -11
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +39 -12
- package/dist/client/remote.mjs +95 -31
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +57 -10
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +23 -19
- package/dist/contracts/commits.d.mts +34 -26
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +12 -12
- package/dist/contracts/forks.d.mts +27 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +39 -7
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -9
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +103 -35
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +50 -25
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +5 -4
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +106 -127
- package/dist/contracts/repos.mjs +33 -4
- package/dist/contracts/result.d.mts +49 -25
- package/dist/contracts/result.mjs +52 -11
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +37 -111
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +90 -26
- package/dist/contracts/sync.mjs +45 -11
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -22
- package/dist/contracts/tokens.mjs +3 -3
- package/dist/contracts/topics.d.mts +1 -6
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +87 -12
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +46 -13
- package/dist/core/ancestry.d.mts +10 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +43 -5
- package/dist/core/call-names.mjs +7 -1
- package/dist/core/call-services.mjs +13 -4
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +48 -33
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +931 -435
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +159 -15
- package/dist/core/index-job.mjs +128 -37
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +10 -6
- package/dist/core/parts.mjs +3 -11
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +316 -42
- package/dist/core/push-decide.mjs +3 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +153 -70
- package/dist/core/receipts.mjs +34 -13
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +61 -7
- package/dist/core/refs.mjs +18 -13
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +46 -28
- package/dist/core/repo-info.mjs +19 -12
- package/dist/core/repos.mjs +50 -22
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +51 -26
- package/dist/core/work.mjs +105 -35
- package/dist/effect.d.mts +5 -12
- package/dist/effect.mjs +3 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +17 -10
- package/dist/engine/walk.mjs +4 -4
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +3 -3
- package/dist/event-streams/stream.mjs +38 -15
- package/dist/extend.d.mts +4 -5
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +12 -7
- package/dist/http/core-parts.mjs +129 -64
- package/dist/http/handler.mjs +36 -9
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +61 -31
- package/dist/http/parts.d.mts +2 -0
- package/dist/http/push-upload-job.mjs +507 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +142 -69
- package/dist/http/upload-pack.mjs +10 -9
- package/dist/index.d.mts +27 -28
- package/dist/index.mjs +5 -8
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +9 -3
- package/dist/lfs/base.mjs +27 -2
- package/dist/lfs/copy.d.mts +60 -0
- package/dist/lfs/copy.mjs +109 -0
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +28 -13
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +7 -0
- package/dist/lfs/objects.mjs +152 -55
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +3 -3
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +22 -25
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +2 -22
- package/dist/queue/host.mjs +2 -13
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +11 -4
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +6 -4
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4231
- package/dist/rest/caller.mjs +5 -1
- package/dist/rest/client.d.mts +15 -5
- package/dist/rest/client.mjs +23 -2
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.mjs +68 -9
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +7 -13
- package/dist/rest/me.d.mts +3 -428
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/work.mjs +8 -0
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +14 -15
- package/dist/server/edge-node.mjs +12 -12
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +6 -11
- package/dist/server/git-layer.mjs +29 -23
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +21 -40
- package/dist/server/joined.mjs +11 -62
- package/dist/server/lifecycle.mjs +65 -69
- package/dist/server/registry.mjs +28 -3
- package/dist/server/server.mjs +245 -465
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/{core/purge.d.mts → storage/batches.d.mts} +4 -4
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +85 -19
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +298 -216
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +1 -1
- package/dist/storage/index-build.mjs +185 -84
- package/dist/storage/index-fetch.mjs +128 -74
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +208 -65
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +214 -67
- package/dist/storage/memory-budget.mjs +44 -8
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +165 -49
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +85 -27
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +172 -86
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +299 -37
- package/dist/storage/prune-walk.mjs +240 -62
- package/dist/storage/prune.mjs +749 -213
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +40 -16
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/quarantine.mjs +9 -9
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +55 -25
- package/dist/storage/receive-bounds.mjs +51 -15
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +2 -2
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +13 -2
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +132 -28
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +31 -3
- package/dist/storage/walk.mjs +194 -39
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +146 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -3
- package/dist/store/cursor-seal.mjs +40 -18
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +24 -34
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +5 -0
- package/dist/store/records.mjs +12 -6
- package/dist/store/repo-record.d.mts +10 -9
- package/dist/store/repo-record.mjs +123 -28
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +21 -2
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +56 -44
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +32 -18
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +118 -0
- package/dist/sync/lfs-copy.mjs +262 -0
- package/dist/sync/mirror.mjs +227 -151
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +58 -30
- package/dist/sync/tries.mjs +52 -21
- package/dist/sync.d.mts +2 -2
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +2 -20
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +3 -4
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -9
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/core/registered-rows.d.mts +0 -5
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -825
- package/dist/rest/commits.d.mts +0 -3510
- package/dist/rest/errors.d.mts +0 -2104
- package/dist/rest/events.d.mts +0 -423
- package/dist/rest/files.d.mts +0 -1330
- package/dist/rest/forks.d.mts +0 -2136
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -473
- package/dist/rest/queue.d.mts +0 -5861
- package/dist/rest/refs.d.mts +0 -2959
- package/dist/rest/repos.d.mts +0 -2539
- package/dist/rest/tags.d.mts +0 -1304
- package/dist/rest/tokens.d.mts +0 -2590
- package/dist/rest/topics.d.mts +0 -2204
- package/dist/rest/trees.d.mts +0 -1693
- package/dist/rest/work.d.mts +0 -1248
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
- package/dist/topics/host.d.mts +0 -7
package/dist/lfs/wire.mjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { fail
|
|
1
|
+
import { fail } from "../contracts/result.mjs";
|
|
2
2
|
import { decodeJson } from "../protocol/wire/json.mjs";
|
|
3
3
|
import { boundedBytes } from "../protocol/bytes/reader.mjs";
|
|
4
4
|
import { brokenRead, endedEarly, readBody } from "../store/errors.mjs";
|
|
5
|
+
import { lfsResponse } from "./answer.mjs";
|
|
5
6
|
import * as Effect from "effect/Effect";
|
|
6
7
|
import * as Schema from "effect/Schema";
|
|
7
8
|
import * as Result from "effect/Result";
|
|
8
9
|
// src/lfs/wire.ts
|
|
9
10
|
/**
|
|
10
|
-
* Git LFS's wire: its JSON bodies, as the batch and locking APIs name them, and its answers
|
|
11
|
-
*
|
|
12
|
-
* the client asks Git's credential helper for the same ones a push sends.
|
|
11
|
+
* Git LFS's wire: its JSON bodies, as the batch and locking APIs name them, and its answers with
|
|
12
|
+
* them. A refusal's is `answer.ts`'s.
|
|
13
13
|
*/
|
|
14
|
-
const lfsType = "application/vnd.git-lfs+json";
|
|
15
14
|
/** The most a JSON body may hold: a batch of 1,000 objects is about 100 KiB. */
|
|
16
15
|
const bodyMost = 1048576;
|
|
17
16
|
/** The most objects one batch names: git-lfs sends 100 at a time. */
|
|
@@ -73,7 +72,6 @@ const LfsLock = /* @__PURE__ */ Schema.Struct({
|
|
|
73
72
|
locked_at: Schema.String,
|
|
74
73
|
owner: Schema.Struct({ name: Schema.String })
|
|
75
74
|
});
|
|
76
|
-
const noStore = { "cache-control": "no-store" };
|
|
77
75
|
/**
|
|
78
76
|
* The bodies LFS's JSON answers carry: a batch's, a lock's, a page of locks, a verify's page split
|
|
79
77
|
* into the caller's and others', or a refusal's `{ message }`. A union encodes as its first member
|
|
@@ -103,30 +101,7 @@ const LfsBody = /* @__PURE__ */ Schema.Union([
|
|
|
103
101
|
]);
|
|
104
102
|
const lfsJson = /* @__PURE__ */ Schema.encodeSync(Schema.fromJsonString(LfsBody));
|
|
105
103
|
/** A JSON answer of LFS's. */
|
|
106
|
-
const lfsAnswer = (status, body, headers) =>
|
|
107
|
-
const answer = new Headers(headers);
|
|
108
|
-
answer.set("content-type", lfsType);
|
|
109
|
-
answer.set("cache-control", noStore["cache-control"]);
|
|
110
|
-
return new Response(lfsJson(body), {
|
|
111
|
-
status,
|
|
112
|
-
headers: answer
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* A refusal as LFS answers one. An anonymous caller is asked for Basic credentials; a repo a
|
|
117
|
-
* caller can't read is a 404, as a missing one is, and so is a write's refusal for a caller
|
|
118
|
-
* that can't read the repo, which the caller of `lfsRefusal` arranges. A body LFS can't take is
|
|
119
|
-
* its validation error, 422, but one that ended early is a 400, as Git's is.
|
|
120
|
-
*/
|
|
121
|
-
const lfsRefusal = (error) => {
|
|
122
|
-
if (error.code === "UNAUTHENTICATED") return lfsAnswer(401, { message: error.message }, { "lfs-authenticate": "Basic realm=\"Git LFS\"" });
|
|
123
|
-
if (error.code === "NOT_FOUND") return lfsAnswer(404, { message: error.message });
|
|
124
|
-
const status = error.code === "INVALID_ARGUMENT" && error.context?.reason === "body-ended" ? httpStatus[error.code] : lfsStatus[error.code] ?? httpStatus[error.code];
|
|
125
|
-
const retry = error.code === "UNAVAILABLE" ? { "retry-after": "1" } : void 0;
|
|
126
|
-
return lfsAnswer(status, { message: error.message }, retry);
|
|
127
|
-
};
|
|
128
|
-
/** Where LFS's status differs from Git's: a body it can't take is its validation error. */
|
|
129
|
-
const lfsStatus = { INVALID_ARGUMENT: 422 };
|
|
104
|
+
const lfsAnswer = (status, body, headers) => lfsResponse(status, lfsJson(body), headers);
|
|
130
105
|
const unreadable = (why) => fail("INVALID_ARGUMENT", `The body is unreadable: ${why}`);
|
|
131
106
|
/**
|
|
132
107
|
* `request`'s body, read whole up to 1 MiB, then decoded as `schema`'s JSON. A read that breaks
|
|
@@ -141,4 +116,4 @@ const bodyOf = /* @__PURE__ */ Effect.fnUntraced(function* (request, schema) {
|
|
|
141
116
|
onSuccess: (value) => Effect.succeed(value)
|
|
142
117
|
});
|
|
143
118
|
});
|
|
144
|
-
export { BatchRequest, LfsAction, LfsBody, LfsLock, LfsObjectAnswer, LockCreate, LockQuery, LockVerify, Unlock, VerifyRequest, batchMost, bodyOf, lfsAnswer
|
|
119
|
+
export { BatchRequest, LfsAction, LfsBody, LfsLock, LfsObjectAnswer, LockCreate, LockQuery, LockVerify, Unlock, VerifyRequest, batchMost, bodyOf, lfsAnswer };
|
package/dist/merges/merges.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { MergeParts, Merges } from "../core/merge-parts.mjs";
|
|
|
2
2
|
import { Objects } from "../core/objects/objects.mjs";
|
|
3
3
|
import { loadedXdiff, mergeParts } from "../engine/parts.mjs";
|
|
4
4
|
import { defaultXdiffBudget } from "../engine/xdiff.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { scopedReader } from "../storage/calls.mjs";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Context from "effect/Context";
|
|
8
8
|
import * as Layer from "effect/Layer";
|
|
@@ -19,7 +19,7 @@ const mergesContext = /* @__PURE__ */ Effect.fnUntraced(function* (options, obje
|
|
|
19
19
|
view,
|
|
20
20
|
at
|
|
21
21
|
});
|
|
22
|
-
const reader = yield* scopedReader(
|
|
22
|
+
const reader = yield* scopedReader(read, at.listed);
|
|
23
23
|
const allot = Effect.succeed((most, refusal) => reader.allotment(most, refusal));
|
|
24
24
|
return yield* parts.mergeTrees((object) => reader.read(object), input, allot);
|
|
25
25
|
}));
|
package/dist/node.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NodeHandler, NodeMiddleware, NodeNext, NodeRequest, NodeResponse } from "./http/node.mjs";
|
|
3
|
-
export { type
|
|
1
|
+
import { toNodeHandler, toNodeMiddleware } from "./server/edge-node.mjs";
|
|
2
|
+
import { NodeHandler, NodeMiddleware, NodeNext, NodeRequest, NodeResponse, NodeServeOptions } from "./http/node.mjs";
|
|
3
|
+
export { type NodeHandler, type NodeMiddleware, type NodeNext, type NodeRequest, type NodeResponse, type NodeServeOptions, toNodeHandler, toNodeMiddleware };
|
|
@@ -49,15 +49,23 @@ var BufferError = class extends Schema.TaggedError()("BufferError", {
|
|
|
49
49
|
message: Schema.String
|
|
50
50
|
}) {};
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
52
|
+
* `bytes` allotted to `part` at once: nothing when they fit, or the error naming the ceiling they'd
|
|
53
|
+
* pass, with nothing allotted.
|
|
54
54
|
*/
|
|
55
|
-
const
|
|
55
|
+
const allotNow = (meter, part, bytes) => meter.allot(part, bytes) ? void 0 : new BufferError({
|
|
56
56
|
part,
|
|
57
57
|
bytes,
|
|
58
58
|
ceiling: meter.ceiling,
|
|
59
59
|
message: `${part} would retain ${bytes} bytes past ${meter.ceiling}`
|
|
60
|
-
})
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* An allotment that fails by name past the meter's ceiling, made each time it runs: one built and
|
|
63
|
+
* never run allots nothing, and one run twice allots twice.
|
|
64
|
+
*/
|
|
65
|
+
const allotOrFail = (meter, part, bytes) => Effect.suspend(() => {
|
|
66
|
+
const refused = allotNow(meter, part, bytes);
|
|
67
|
+
return refused === void 0 ? Effect.void : Effect.fail(refused);
|
|
68
|
+
});
|
|
61
69
|
/**
|
|
62
70
|
* `bytes` allotted to `part` until the scope closes, failing by name past the meter's ceiling: each
|
|
63
71
|
* run allots when it runs and lets go when its own scope closes.
|
|
@@ -65,4 +73,4 @@ const allotOrFail = (meter, part, bytes) => Effect.suspend(() => meter.allot(par
|
|
|
65
73
|
const allotScoped = (meter, part, bytes) => Effect.acquireRelease(allotOrFail(meter, part, bytes), () => Effect.sync(() => meter.free(part)));
|
|
66
74
|
/** The capacity a view keeps alive: its whole buffer's. */
|
|
67
75
|
const capacityOf = (bytes) => bytes.buffer.byteLength;
|
|
68
|
-
export { BufferError, BufferMeter, allotOrFail, allotScoped, capacityOf };
|
|
76
|
+
export { BufferError, BufferMeter, allotNow, allotOrFail, allotScoped, capacityOf };
|
|
@@ -12,6 +12,11 @@ const scopedReader = (body) => Effect.acquireRelease(Effect.sync(() => body.getR
|
|
|
12
12
|
reader.releaseLock();
|
|
13
13
|
}));
|
|
14
14
|
/**
|
|
15
|
+
* `body` cancelled, unread, its cancel's own failure dropped: a body no one will read, let go so
|
|
16
|
+
* its sender stops. A `null` or `undefined` body has nothing to let go.
|
|
17
|
+
*/
|
|
18
|
+
const dropBody = (body) => body === null || body === void 0 ? Effect.void : Effect.promise(() => body.cancel().catch(() => void 0));
|
|
19
|
+
/**
|
|
15
20
|
* A whole body within `most` bytes, or undefined past it. Chunks are checked before they are
|
|
16
21
|
* retained. The caller owns the byte bound and the errors; this scope owns the reader on every
|
|
17
22
|
* exit, including a failure between reads. Without an explicit empty-chunk policy, a run of
|
|
@@ -58,4 +63,4 @@ const ownedReader = (body) => {
|
|
|
58
63
|
}
|
|
59
64
|
};
|
|
60
65
|
};
|
|
61
|
-
export { boundedBytes, ownedReader, scopedReader };
|
|
66
|
+
export { boundedBytes, dropBody, ownedReader, scopedReader };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./sha1-hasher.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
/**
|
|
4
|
+
* A SHA-256 written a piece at a time as an upload's body streams through, as `@ref0/github`'s
|
|
5
|
+
* release asset in one request is (#2452), through the runtime's own hash: workerd's
|
|
6
|
+
* `crypto.DigestStream`, or Node's `createHash`, and `Sha256` where a runtime has neither.
|
|
7
|
+
* `sha1-hasher.ts` does the same for a pack's SHA-1.
|
|
8
|
+
*/
|
|
9
|
+
/** A SHA-256 written a piece at a time, then its sum as 64 lowercase hex digits. */
|
|
10
|
+
export interface Sha256Hasher {
|
|
11
|
+
readonly write: (bytes: Uint8Array) => Effect.Effect<void>;
|
|
12
|
+
readonly hex: Effect.Effect<string>;
|
|
13
|
+
}
|
|
14
|
+
/** A `Sha256Hasher` through this runtime's own hash, or `Sha256` where it has none. */
|
|
15
|
+
export declare const nativeSha256Hasher: () => Sha256Hasher;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
/**
|
|
3
|
+
* A SHA-256's state between writes: its eight words, the bytes it took, and the bytes past its last
|
|
4
|
+
* whole 64-byte block, as lowercase hex, as many as `length` leaves past a block. Decode stored
|
|
5
|
+
* state through it, so a damaged one fails by name before a `Sha256` goes on from it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Sha256State: Schema.Struct<{
|
|
8
|
+
readonly words: Schema.Tuple<readonly [Schema.Number, Schema.Number, Schema.Number, Schema.Number, Schema.Number, Schema.Number, Schema.Number, Schema.Number]>;
|
|
9
|
+
readonly length: Schema.Int;
|
|
10
|
+
readonly pending: Schema.String;
|
|
11
|
+
}>;
|
|
12
|
+
export type Sha256State = typeof Sha256State.Type;
|
|
13
|
+
/** A stored state, checked: a typed failure for one no `Sha256` could have written. */
|
|
14
|
+
export declare const decodeSha256State: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
15
|
+
readonly words: readonly [number, number, number, number, number, number, number, number];
|
|
16
|
+
readonly length: number;
|
|
17
|
+
readonly pending: string;
|
|
18
|
+
}, Schema.SchemaError, never>;
|
|
19
|
+
export declare class Sha256 {
|
|
20
|
+
#private;
|
|
21
|
+
/**
|
|
22
|
+
* A hash from the start, or going on from `state`, which it trusts: one `decodeSha256State`
|
|
23
|
+
* hasn't checked and that holds a block or more of pending bytes throws a `RangeError`.
|
|
24
|
+
*/
|
|
25
|
+
constructor(state?: Sha256State);
|
|
26
|
+
/** Takes `bytes`, after every byte before them. */
|
|
27
|
+
update(bytes: Uint8Array): void;
|
|
28
|
+
/** The state to go on from, as plain data. */
|
|
29
|
+
state(): Sha256State;
|
|
30
|
+
/** The digest of every byte taken, as 64 lowercase hex digits; the hash takes no more after it. */
|
|
31
|
+
hex(): string;
|
|
32
|
+
}
|
|
@@ -1,9 +1,40 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import * as Result from "effect/Result";
|
|
3
|
+
import * as Hex from "effect/encoding/Hex";
|
|
1
4
|
// src/protocol/bytes/sha256.ts
|
|
2
5
|
/**
|
|
3
|
-
* SHA-256, as FIPS 180-4 defines it, written a piece at a time
|
|
4
|
-
* they stream past, and
|
|
6
|
+
* SHA-256, as FIPS 180-4 defines it, written a piece at a time, whose state is plain data: LFS
|
|
7
|
+
* checks an upload's bytes as they stream past, and a release asset's parts, each put in a request
|
|
8
|
+
* of its own, hash on from the state the part before left. The runtime's `crypto.subtle` takes only
|
|
9
|
+
* bytes held whole, and its `DigestStream` keeps its state where nothing can save it.
|
|
5
10
|
*/
|
|
6
|
-
const
|
|
11
|
+
const Word = /* @__PURE__ */ Schema.Number.check(Schema.isUint32());
|
|
12
|
+
/**
|
|
13
|
+
* A SHA-256's state between writes: its eight words, the bytes it took, and the bytes past its last
|
|
14
|
+
* whole 64-byte block, as lowercase hex, as many as `length` leaves past a block. Decode stored
|
|
15
|
+
* state through it, so a damaged one fails by name before a `Sha256` goes on from it.
|
|
16
|
+
*/
|
|
17
|
+
const Sha256State = /* @__PURE__ */ Schema.Struct({
|
|
18
|
+
words: Schema.Tuple([
|
|
19
|
+
Word,
|
|
20
|
+
Word,
|
|
21
|
+
Word,
|
|
22
|
+
Word,
|
|
23
|
+
Word,
|
|
24
|
+
Word,
|
|
25
|
+
Word,
|
|
26
|
+
Word
|
|
27
|
+
]),
|
|
28
|
+
length: Schema.Int.check(Schema.isBetween({
|
|
29
|
+
minimum: 0,
|
|
30
|
+
maximum: Number.MAX_SAFE_INTEGER / 8
|
|
31
|
+
})),
|
|
32
|
+
pending: Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{2}){0,63}$/))
|
|
33
|
+
}).check(Schema.makeFilter((state) => state.pending.length / 2 === state.length % 64 || "its pending bytes are not the bytes past its last whole block"));
|
|
34
|
+
/** A stored state, checked: a typed failure for one no `Sha256` could have written. */
|
|
35
|
+
const decodeSha256State = /* @__PURE__ */ Schema.decodeUnknownEffect(Sha256State);
|
|
36
|
+
/** The 64 round constants, signed 32-bit, as the rounds add them. */
|
|
37
|
+
const rounds = Int32Array.from([
|
|
7
38
|
1116352408,
|
|
8
39
|
1899447441,
|
|
9
40
|
3049323471,
|
|
@@ -79,26 +110,51 @@ const initial = [
|
|
|
79
110
|
528734635,
|
|
80
111
|
1541459225
|
|
81
112
|
];
|
|
82
|
-
const rotate = (word, by) => word >>> by | word << 32 - by;
|
|
83
113
|
var Sha256 = class {
|
|
84
|
-
#words
|
|
114
|
+
#words;
|
|
85
115
|
#block = /* @__PURE__ */ new Uint8Array(64);
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
116
|
+
#blockView = new DataView(this.#block.buffer);
|
|
117
|
+
#schedule = /* @__PURE__ */ new Int32Array(64);
|
|
118
|
+
#filled;
|
|
119
|
+
#length;
|
|
120
|
+
/**
|
|
121
|
+
* A hash from the start, or going on from `state`, which it trusts: one `decodeSha256State`
|
|
122
|
+
* hasn't checked and that holds a block or more of pending bytes throws a `RangeError`.
|
|
123
|
+
*/
|
|
124
|
+
constructor(state) {
|
|
125
|
+
const pending = state === void 0 ? /* @__PURE__ */ new Uint8Array(0) : Result.getOrThrow(Hex.decode(state.pending));
|
|
126
|
+
if (pending.length >= 64) throw new RangeError("a SHA-256's pending bytes fill a block");
|
|
127
|
+
this.#words = [...state?.words ?? initial];
|
|
128
|
+
this.#block.set(pending);
|
|
129
|
+
this.#filled = pending.length;
|
|
130
|
+
this.#length = state?.length ?? 0;
|
|
131
|
+
}
|
|
89
132
|
/** Takes `bytes`, after every byte before them. */
|
|
90
133
|
update(bytes) {
|
|
134
|
+
let at = 0;
|
|
91
135
|
this.#length += bytes.length;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.#block.set(bytes.subarray(
|
|
95
|
-
this.#filled +=
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
this.#filled = 0;
|
|
100
|
-
}
|
|
136
|
+
if (this.#filled > 0) {
|
|
137
|
+
at = Math.min(64 - this.#filled, bytes.length);
|
|
138
|
+
this.#block.set(bytes.subarray(0, at), this.#filled);
|
|
139
|
+
this.#filled += at;
|
|
140
|
+
if (this.#filled < 64) return;
|
|
141
|
+
this.#compress(this.#blockView, 0);
|
|
142
|
+
this.#filled = 0;
|
|
101
143
|
}
|
|
144
|
+
if (at + 64 <= bytes.length) {
|
|
145
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
146
|
+
for (; at + 64 <= bytes.length; at += 64) this.#compress(view, at);
|
|
147
|
+
}
|
|
148
|
+
this.#block.set(bytes.subarray(at));
|
|
149
|
+
this.#filled = bytes.length - at;
|
|
150
|
+
}
|
|
151
|
+
/** The state to go on from, as plain data. */
|
|
152
|
+
state() {
|
|
153
|
+
return {
|
|
154
|
+
words: [...this.#words],
|
|
155
|
+
length: this.#length,
|
|
156
|
+
pending: Hex.encode(this.#block.subarray(0, this.#filled))
|
|
157
|
+
};
|
|
102
158
|
}
|
|
103
159
|
/** The digest of every byte taken, as 64 lowercase hex digits; the hash takes no more after it. */
|
|
104
160
|
hex() {
|
|
@@ -106,51 +162,51 @@ var Sha256 = class {
|
|
|
106
162
|
this.#block[this.#filled] = 128;
|
|
107
163
|
this.#block.fill(0, this.#filled + 1);
|
|
108
164
|
if (this.#filled >= 56) {
|
|
109
|
-
this.#compress();
|
|
165
|
+
this.#compress(this.#blockView, 0);
|
|
110
166
|
this.#block.fill(0);
|
|
111
167
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.#
|
|
116
|
-
return Array.from(this.#words, (word) => word.toString(16).padStart(8, "0")).join("");
|
|
168
|
+
this.#blockView.setUint32(56, Math.floor(bits / 2 ** 32));
|
|
169
|
+
this.#blockView.setUint32(60, bits >>> 0);
|
|
170
|
+
this.#compress(this.#blockView, 0);
|
|
171
|
+
return this.#words.map((word) => word.toString(16).padStart(8, "0")).join("");
|
|
117
172
|
}
|
|
118
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Hashes the 64 bytes of `view` from `from` into the words, its working words in locals and its
|
|
175
|
+
* schedule in one reused array, each signed 32-bit until it's stored: an array of words read
|
|
176
|
+
* back through `?? 0` held it to about 55 MiB/s in Node.
|
|
177
|
+
*/
|
|
178
|
+
#compress(view, from) {
|
|
119
179
|
const w = this.#schedule;
|
|
120
|
-
|
|
121
|
-
for (let t = 0; t < 16; t += 1) w[t] = view.getUint32(t * 4);
|
|
180
|
+
for (let t = 0; t < 16; t += 1) w[t] = view.getInt32(from + t * 4);
|
|
122
181
|
for (let t = 16; t < 64; t += 1) {
|
|
123
|
-
const back2 = w[t - 2]
|
|
124
|
-
const back15 = w[t - 15]
|
|
125
|
-
const s0 =
|
|
126
|
-
const s1 =
|
|
127
|
-
w[t] =
|
|
182
|
+
const back2 = w[t - 2];
|
|
183
|
+
const back15 = w[t - 15];
|
|
184
|
+
const s0 = (back15 >>> 7 | back15 << 25) ^ (back15 >>> 18 | back15 << 14) ^ back15 >>> 3;
|
|
185
|
+
const s1 = (back2 >>> 17 | back2 << 15) ^ (back2 >>> 19 | back2 << 13) ^ back2 >>> 10;
|
|
186
|
+
w[t] = w[t - 16] + s0 + w[t - 7] + s1 | 0;
|
|
128
187
|
}
|
|
129
|
-
let [a
|
|
188
|
+
let [a, b, c, d, e, f, g, h] = this.#words;
|
|
130
189
|
for (let t = 0; t < 64; t += 1) {
|
|
131
|
-
const s1 =
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
const second = (rotate(a, 2) ^ rotate(a, 13) ^ rotate(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
|
|
190
|
+
const s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
|
|
191
|
+
const first = h + s1 + (e & f ^ ~e & g) + rounds[t] + w[t] | 0;
|
|
192
|
+
const second = ((a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10)) + (a & b ^ a & c ^ b & c) | 0;
|
|
135
193
|
h = g;
|
|
136
194
|
g = f;
|
|
137
195
|
f = e;
|
|
138
|
-
e = d + first
|
|
196
|
+
e = d + first | 0;
|
|
139
197
|
d = c;
|
|
140
198
|
c = b;
|
|
141
199
|
b = a;
|
|
142
|
-
a = first + second
|
|
200
|
+
a = first + second | 0;
|
|
143
201
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
h
|
|
153
|
-
].entries()) this.#words[at] = (this.#words[at] ?? 0) + word;
|
|
202
|
+
this.#words[0] = this.#words[0] + a >>> 0;
|
|
203
|
+
this.#words[1] = this.#words[1] + b >>> 0;
|
|
204
|
+
this.#words[2] = this.#words[2] + c >>> 0;
|
|
205
|
+
this.#words[3] = this.#words[3] + d >>> 0;
|
|
206
|
+
this.#words[4] = this.#words[4] + e >>> 0;
|
|
207
|
+
this.#words[5] = this.#words[5] + f >>> 0;
|
|
208
|
+
this.#words[6] = this.#words[6] + g >>> 0;
|
|
209
|
+
this.#words[7] = this.#words[7] + h >>> 0;
|
|
154
210
|
}
|
|
155
211
|
};
|
|
156
|
-
export { Sha256 };
|
|
212
|
+
export { Sha256, Sha256State, decodeSha256State };
|
|
@@ -23,6 +23,32 @@ const streamOf = (bytes, piece = Math.max(1, bytes.length)) => {
|
|
|
23
23
|
} });
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
+
* `bytes` as a body read once, in one piece, `done` run once it's read to its end, cancelled, or
|
|
27
|
+
* ended unread by `expired`, which fails it with the signal's reason: what holds the bytes, such as
|
|
28
|
+
* a charge to a budget, is let go only then. No piece is pulled before a reader asks, since a pull
|
|
29
|
+
* on its own would end it unread.
|
|
30
|
+
*/
|
|
31
|
+
const streamThen = (bytes, done, expired) => {
|
|
32
|
+
let ended = false;
|
|
33
|
+
const end = () => {
|
|
34
|
+
if (ended) return false;
|
|
35
|
+
ended = true;
|
|
36
|
+
done();
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
return new ReadableStream({
|
|
40
|
+
start: (controller) => {
|
|
41
|
+
expired?.addEventListener("abort", () => end() && controller.error(expired.reason), { once: true });
|
|
42
|
+
},
|
|
43
|
+
pull: (controller) => {
|
|
44
|
+
controller.enqueue(bytes);
|
|
45
|
+
controller.close();
|
|
46
|
+
end();
|
|
47
|
+
},
|
|
48
|
+
cancel: () => void end()
|
|
49
|
+
}, { highWaterMark: 0 });
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
26
52
|
* `body` gathered into pieces, each `pieceAt(given)` bytes, `given` the bytes it has handed on,
|
|
27
53
|
* its last smaller, each copied from its chunks as they come, so code that pays for each chunk pays
|
|
28
54
|
* once a piece: a client's body reaches a deployed Worker in chunks of at most 4,096 B (run
|
|
@@ -100,4 +126,4 @@ const gathered = (body, pieceAt) => {
|
|
|
100
126
|
}
|
|
101
127
|
}, { highWaterMark: 0 });
|
|
102
128
|
};
|
|
103
|
-
export { gathered, streamOf };
|
|
129
|
+
export { gathered, streamOf, streamThen };
|
|
@@ -33,13 +33,14 @@ export interface DiffLimits {
|
|
|
33
33
|
*/
|
|
34
34
|
export declare const defaultDiffLimits: DiffLimits;
|
|
35
35
|
declare const DiffError_base: Schema.Class<DiffError, Schema.TaggedStruct<"DiffError", {
|
|
36
|
-
readonly reason: Schema.Literals<readonly ["missing", "malformed", "unreadable", "diff-limit", "object-too-large"]>;
|
|
36
|
+
readonly reason: Schema.Literals<readonly ["missing", "past-roots", "malformed", "unreadable", "diff-limit", "object-too-large"]>;
|
|
37
37
|
readonly oid: Schema.optionalKey<Schema.String>;
|
|
38
38
|
readonly message: Schema.String;
|
|
39
39
|
}>, import("effect/Cause").YieldableError>;
|
|
40
40
|
/**
|
|
41
|
-
* Why a diff stopped: an object `missing`,
|
|
42
|
-
*
|
|
41
|
+
* Why a diff stopped: an object `missing`, or `past-roots`, missing from a repo that holds roots,
|
|
42
|
+
* so it may be history past them; `malformed` or `unreadable`; a read or a charge past the diff's
|
|
43
|
+
* limits, `diff-limit`; or one object past its own, `object-too-large`.
|
|
43
44
|
*/
|
|
44
45
|
export declare class DiffError extends DiffError_base {}
|
|
45
46
|
/**
|
|
@@ -22,12 +22,14 @@ const defaultDiffLimits = {
|
|
|
22
22
|
fileBytes: 16 * mebibyte
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
* Why a diff stopped: an object `missing`,
|
|
26
|
-
*
|
|
25
|
+
* Why a diff stopped: an object `missing`, or `past-roots`, missing from a repo that holds roots,
|
|
26
|
+
* so it may be history past them; `malformed` or `unreadable`; a read or a charge past the diff's
|
|
27
|
+
* limits, `diff-limit`; or one object past its own, `object-too-large`.
|
|
27
28
|
*/
|
|
28
29
|
var DiffError = class extends Schema.TaggedError()("DiffError", {
|
|
29
30
|
reason: Schema.Literals([
|
|
30
31
|
"missing",
|
|
32
|
+
"past-roots",
|
|
31
33
|
"malformed",
|
|
32
34
|
"unreadable",
|
|
33
35
|
"diff-limit",
|
|
@@ -177,7 +179,10 @@ var DiffReader = class {
|
|
|
177
179
|
if (this.#objects > this.limits.objects) return yield* failed("diff-limit", `the diff reads past ${this.limits.objects} objects`);
|
|
178
180
|
if (this.tally?.object() === false) return yield* failed("diff-limit", `the call reads past ${this.tally.limits.objects} objects`);
|
|
179
181
|
const object = yield* this.read(oid);
|
|
180
|
-
if (object === void 0)
|
|
182
|
+
if (object === void 0) {
|
|
183
|
+
const reason = this.roots.size === 0 ? "missing" : "past-roots";
|
|
184
|
+
return yield* failed(reason, `object ${oid} is missing`, oid);
|
|
185
|
+
}
|
|
181
186
|
this.#sizes.set(oid, object.size);
|
|
182
187
|
if (type !== void 0 && object.type !== type) {
|
|
183
188
|
object.bytes.cancel().catch(() => void 0);
|
|
@@ -4,5 +4,17 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/** The most bytes a pointer file holds, as Git LFS's spec says. */
|
|
6
6
|
export declare const maxLfsPointerBytes = 1024;
|
|
7
|
-
/**
|
|
8
|
-
export
|
|
7
|
+
/** What a pointer names: its object's oid and size. */
|
|
8
|
+
export interface LfsPointerTarget {
|
|
9
|
+
readonly oid: string;
|
|
10
|
+
/** As written, read as a number: past 2⁵³ it's the nearest one. */
|
|
11
|
+
readonly size: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* What a Git LFS pointer names, or `undefined` for text that isn't one: its version line, its
|
|
15
|
+
* extensions in rising order, `oid sha256:<hex>`, `size <n>` within a signed 64-bit integer, each
|
|
16
|
+
* ending in a newline, and nothing else but blank lines, which git-lfs skips. Text that git-lfs
|
|
17
|
+
* reads as a pointer may still be refused here, as one with CRLFs, but never text that git-lfs
|
|
18
|
+
* refuses, so a plain file is never taken for a pointer.
|
|
19
|
+
*/
|
|
20
|
+
export declare const lfsPointerOf: (text: string) => LfsPointerTarget | undefined;
|
|
@@ -40,8 +40,6 @@ const lfsPointerOf = (text) => {
|
|
|
40
40
|
* Other texts may point at the same object, but this is the one `git lfs track` commits.
|
|
41
41
|
*/
|
|
42
42
|
const lfsPointerText = (target) => `${pointerVersion}\noid sha256:${target.oid}\nsize ${target.size}\n`;
|
|
43
|
-
/** The oid a Git LFS pointer names, as `lfsPointerOf` reads it. */
|
|
44
|
-
const lfsPointerOid = (text) => lfsPointerOf(text)?.oid;
|
|
45
43
|
const versionBytes = new TextEncoder().encode(pointerVersion);
|
|
46
44
|
/**
|
|
47
45
|
* Whether `bytes` may be a pointer: what `TextDecoder` reads them as, past its byte order mark and
|
|
@@ -65,4 +63,4 @@ const lfsPointerOfBlob = (bytes) => {
|
|
|
65
63
|
size: pointer.size
|
|
66
64
|
};
|
|
67
65
|
};
|
|
68
|
-
export { isLfsOid, lfsPointerOf, lfsPointerOfBlob,
|
|
66
|
+
export { isLfsOid, lfsPointerOf, lfsPointerOfBlob, lfsPointerText, maxLfsPointerBytes };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hexValue, modeKind
|
|
1
|
+
import { hexValue, modeKind } from "./object-rules.mjs";
|
|
2
2
|
// src/protocol/objects/links-raw.ts
|
|
3
3
|
/**
|
|
4
4
|
* The IDs an object names, as 20 raw bytes each, with no string made: a tree's entries but its
|
|
@@ -15,17 +15,31 @@ const rawLinks = (kind, bytes, visit) => {
|
|
|
15
15
|
const space = 32;
|
|
16
16
|
const nul = 0;
|
|
17
17
|
const newline = 10;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* A tree's entries: its mode's digits, a space, its name, a NUL, then its ID's 20 bytes. Each
|
|
20
|
+
* entry is read in one pass, its mode's value made as its digits go by, `octalMode`'s rule and
|
|
21
|
+
* order, with no `indexOf` call for its space or its NUL: a call each was most of a read step's
|
|
22
|
+
* tree CPU (#664). `links-raw.fuzz.test.ts` holds it to `octalMode` and `modeKind`.
|
|
23
|
+
*/
|
|
19
24
|
const treeLinks = (bytes, visit) => {
|
|
25
|
+
const length = bytes.byteLength;
|
|
20
26
|
let at = 0;
|
|
21
|
-
while (at <
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
while (at < length) {
|
|
28
|
+
let modeEnd = at;
|
|
29
|
+
let mode = 0;
|
|
30
|
+
let octal = true;
|
|
31
|
+
for (; modeEnd < length; modeEnd += 1) {
|
|
32
|
+
const byte = bytes[modeEnd] ?? 0;
|
|
33
|
+
if (byte === space) break;
|
|
34
|
+
if (byte < 48 || byte > 55) octal = false;
|
|
35
|
+
mode = (mode << 3) + (byte - 48) >>> 0;
|
|
36
|
+
}
|
|
37
|
+
if (modeEnd === length || modeEnd === at) return `an entry at ${at} has no mode`;
|
|
38
|
+
let nameEnd = modeEnd + 1;
|
|
39
|
+
while (nameEnd < length && bytes[nameEnd] !== nul) nameEnd += 1;
|
|
40
|
+
if (nameEnd === length || nameEnd === modeEnd + 1) return `an entry at ${at} has no name`;
|
|
41
|
+
if (nameEnd + 21 > length) return `an entry at ${at} ends inside its ID`;
|
|
42
|
+
if (!octal) return `an entry at ${at} has a mode that isn't octal`;
|
|
29
43
|
if (modeKind(mode) !== "gitlink") visit(bytes, nameEnd + 1);
|
|
30
44
|
at = nameEnd + 21;
|
|
31
45
|
}
|
|
@@ -18,6 +18,6 @@ export declare const decodeTag: (bytes: Uint8Array) => Effect.Effect<Omit<Tag, '
|
|
|
18
18
|
* wouldn't write fails before any byte: an ID that isn't 40 lowercase hex, a type that isn't an
|
|
19
19
|
* object's, a name Git can't put under `refs/tags/`, a tagger Git refuses, or a NUL in its message.
|
|
20
20
|
*/
|
|
21
|
-
export declare const encodeTag: (tag: TagFields & {
|
|
21
|
+
export declare const encodeTag: (tag: Omit<TagFields, 'type'> & {
|
|
22
22
|
readonly type: ObjectType;
|
|
23
23
|
}) => Effect.Effect<Uint8Array<ArrayBuffer>, WireEncodeError>;
|
|
@@ -64,11 +64,12 @@ const parseTreeBytes = (bytes) => Effect.suspend(() => {
|
|
|
64
64
|
});
|
|
65
65
|
/**
|
|
66
66
|
* A tree's entries one at a time, in order, as `parseTreeBytes` reads them, `undefined` past the
|
|
67
|
-
* last
|
|
68
|
-
*
|
|
69
|
-
*
|
|
67
|
+
* last, each ID left where the tree holds it, so a caller that asks or copies IDs as bytes makes
|
|
68
|
+
* no text of them. It holds none, so a tree as wide as a push may carry is read without an array
|
|
69
|
+
* of them. A name is a view of `bytes`, so one kept is copied first. Fails as `parseTreeBytes`
|
|
70
|
+
* does, at the entry at fault.
|
|
70
71
|
*/
|
|
71
|
-
const
|
|
72
|
+
const treeIdReader = (bytes) => {
|
|
72
73
|
let previous;
|
|
73
74
|
let at = 0;
|
|
74
75
|
return () => {
|
|
@@ -83,7 +84,7 @@ const treeReader = (bytes) => {
|
|
|
83
84
|
const entry = {
|
|
84
85
|
mode: canonicalMode(mode),
|
|
85
86
|
name,
|
|
86
|
-
|
|
87
|
+
idAt: nul + 1
|
|
87
88
|
};
|
|
88
89
|
if (previous !== void 0 && compareEntries(previous, entry) >= 0) return notATree(`the entry at byte ${at} is out of Git's order or named twice`);
|
|
89
90
|
previous = entry;
|
|
@@ -91,6 +92,22 @@ const treeReader = (bytes) => {
|
|
|
91
92
|
return Result.succeed(entry);
|
|
92
93
|
};
|
|
93
94
|
};
|
|
95
|
+
/** `treeIdReader`'s entries, each with its ID as text. */
|
|
96
|
+
const treeReader = (bytes) => {
|
|
97
|
+
const next = treeIdReader(bytes);
|
|
98
|
+
return () => {
|
|
99
|
+
const read = next();
|
|
100
|
+
if (Result.isFailure(read)) return Result.fail(read.failure);
|
|
101
|
+
const entry = read.success;
|
|
102
|
+
if (entry === void 0) return Result.succeed(void 0);
|
|
103
|
+
const { mode, name, idAt } = entry;
|
|
104
|
+
return Result.succeed({
|
|
105
|
+
mode,
|
|
106
|
+
name,
|
|
107
|
+
oid: hexOf(bytes.subarray(idAt, idAt + 20))
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
};
|
|
94
111
|
const encoder = new TextEncoder();
|
|
95
112
|
/** The modes a tree's entry can be written with: a file, an executable, a symlink, a gitlink. */
|
|
96
113
|
const writableModes = /* @__PURE__ */ new Set([
|
|
@@ -159,4 +176,4 @@ const treeMatches = (oid, entries) => encodeTree(entries).pipe(Effect.flatMap((b
|
|
|
159
176
|
type: "tree",
|
|
160
177
|
bytes
|
|
161
178
|
})), Effect.map((id) => id === oid));
|
|
162
|
-
export { compareEntries, compareNames, encodeTree, parseTreeBytes, treeBytes, treeEntriesIn, treeMatches, treeReader };
|
|
179
|
+
export { compareEntries, compareNames, encodeTree, parseTreeBytes, treeBytes, treeEntriesIn, treeIdReader, treeMatches, treeReader };
|