@ref0/git 0.6.0 → 0.8.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/namespace.d.mts +2 -0
- package/dist/access/private-refs.d.mts +6 -29
- package/dist/access/private-refs.mjs +26 -13
- package/dist/access/public.d.mts +6 -0
- package/dist/access/public.mjs +9 -0
- package/dist/auth/access-jwt.d.mts +10 -6
- package/dist/auth/access-jwt.mjs +59 -40
- package/dist/auth/auth-namespace.d.mts +6 -0
- package/dist/auth/auth-namespace.mjs +12 -0
- package/dist/auth/auth.d.mts +3 -6
- package/dist/auth/auth.mjs +2 -9
- package/dist/auth/authorize.mjs +35 -29
- package/dist/auth/bridge.mjs +8 -8
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +1 -1
- package/dist/auth/grants.d.mts +0 -1
- package/dist/auth/grants.mjs +2 -2
- package/dist/auth/host-function.d.mts +1 -7
- package/dist/auth/host-function.mjs +51 -42
- package/dist/auth/identify.d.mts +0 -1
- package/dist/auth/identify.mjs +3 -2
- package/dist/auth/namespaces.d.mts +2 -2
- package/dist/auth/policy.d.mts +7 -4
- package/dist/auth/policy.mjs +13 -10
- package/dist/auth/token-rows.mjs +3 -6
- package/dist/auth/tokens-layer.d.mts +40 -0
- package/dist/auth/tokens-layer.mjs +29 -0
- package/dist/auth/tokens-namespace.d.mts +2 -0
- package/dist/auth/tokens-public.d.mts +6 -0
- package/dist/auth/tokens-public.mjs +31 -0
- package/dist/auth/tokens.d.mts +19 -7
- package/dist/auth/tokens.mjs +12 -6
- package/dist/auth.d.mts +2 -2
- package/dist/auth.mjs +2 -2
- package/dist/client/client.d.mts +22 -15
- package/dist/client/client.mjs +31 -27
- package/dist/client/git-http.mjs +23 -6
- package/dist/client/local.mjs +5 -4
- package/dist/client/namespace.d.mts +2 -0
- package/dist/client/push-upload.d.mts +1 -0
- package/dist/client/push-upload.mjs +169 -2
- package/dist/client/remote-helper.mjs +5 -12
- package/dist/client/remote.mjs +63 -22
- package/dist/client/run-remote-helper.d.mts +1 -1
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +26 -19
- package/dist/contracts/access.d.mts +18 -10
- package/dist/contracts/access.mjs +17 -0
- package/dist/contracts/actors.d.mts +73 -28
- package/dist/contracts/actors.mjs +45 -2
- package/dist/contracts/authorize.d.mts +26 -17
- package/dist/contracts/blobs.d.mts +1 -1
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/callers.mjs +40 -0
- package/dist/contracts/calls-spent.d.mts +6 -4
- package/dist/contracts/calls-spent.mjs +10 -8
- package/dist/contracts/client.d.mts +16 -9
- package/dist/contracts/commits.d.mts +2 -2
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +1 -1
- package/dist/contracts/events.d.mts +45 -32
- package/dist/contracts/events.mjs +21 -10
- package/dist/contracts/files.d.mts +44 -44
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +34 -58
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-events.d.mts +50 -0
- package/dist/contracts/git-events.mjs +23 -0
- package/dist/contracts/git-hooks.d.mts +254 -0
- package/dist/contracts/git-hooks.mjs +12 -0
- package/dist/contracts/git.d.mts +93 -42
- package/dist/contracts/git.mjs +6 -5
- package/dist/contracts/grants.d.mts +46 -27
- package/dist/contracts/ids.d.mts +16 -0
- package/dist/contracts/ids.mjs +19 -4
- package/dist/contracts/lfs.d.mts +19 -4
- package/dist/contracts/merges.d.mts +7 -7
- package/dist/contracts/namespaces.d.mts +2 -2
- package/dist/contracts/objects.d.mts +21 -5
- package/dist/contracts/opaque.mjs +27 -0
- package/dist/contracts/operations.d.mts +301 -101
- package/dist/contracts/operations.mjs +209 -0
- package/dist/contracts/promises.d.mts +2 -0
- package/dist/contracts/push-uploads.d.mts +4 -1
- package/dist/contracts/push-uploads.mjs +9 -4
- package/dist/contracts/queue.d.mts +220 -49
- package/dist/contracts/queue.mjs +68 -6
- package/dist/contracts/refs.d.mts +30 -8
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +53 -23
- package/dist/contracts/remote.mjs +22 -0
- package/dist/contracts/repo-records.d.mts +2 -2
- package/dist/contracts/repos.d.mts +100 -82
- package/dist/contracts/repos.mjs +47 -8
- package/dist/contracts/result.d.mts +73 -41
- package/dist/contracts/result.mjs +74 -17
- package/dist/contracts/rules.d.mts +734 -68
- package/dist/contracts/rules.mjs +84 -1
- package/dist/contracts/server.d.mts +20 -206
- package/dist/contracts/services.d.mts +1 -10
- package/dist/contracts/services.mjs +1 -5
- package/dist/contracts/signin.d.mts +140 -43
- package/dist/contracts/signin.mjs +36 -3
- package/dist/contracts/store.d.mts +1 -1
- package/dist/contracts/sync.d.mts +109 -90
- package/dist/contracts/sync.mjs +34 -7
- package/dist/contracts/tags.d.mts +1 -1
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +247 -60
- package/dist/contracts/tokens.mjs +93 -21
- package/dist/contracts/topics.d.mts +59 -20
- package/dist/contracts/topics.mjs +14 -5
- package/dist/contracts/trees.d.mts +2 -2
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +2 -2
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +10 -12
- package/dist/core/access.mjs +45 -11
- package/dist/core/clock.mjs +1 -1
- package/dist/core/events/deliver.d.mts +3 -2
- package/dist/core/events/deliver.mjs +188 -92
- package/dist/core/forks.mjs +78 -34
- package/dist/core/hooks/groups.d.mts +26 -0
- package/dist/core/hooks/groups.mjs +73 -0
- package/dist/core/hooks/namespace.d.mts +2 -0
- package/dist/core/hooks/order.d.mts +2 -2
- package/dist/core/hooks/order.mjs +6 -6
- package/dist/core/hooks/public.d.mts +7 -0
- package/dist/core/hooks/public.mjs +5 -0
- package/dist/core/imports.mjs +94 -10
- package/dist/core/index-job.mjs +11 -8
- package/dist/core/loose-tally.mjs +46 -0
- package/dist/core/merge-parts.d.mts +1 -1
- package/dist/core/merge-parts.mjs +1 -1
- package/dist/core/mirror-rows.mjs +18 -0
- package/dist/core/names.mjs +1 -1
- package/dist/core/namespaces.d.mts +2 -1
- package/dist/core/objects/commit-writes.mjs +5 -5
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/reading.mjs +52 -7
- package/dist/core/objects/tree-edits.mjs +13 -28
- package/dist/core/objects/trees.mjs +4 -4
- package/dist/core/objects/writing.mjs +4 -3
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +22 -3
- package/dist/core/parts.mjs +5 -3
- package/dist/core/promise.mjs +23 -17
- package/dist/core/purge.d.mts +2 -2
- package/dist/core/purge.mjs +89 -34
- package/dist/core/push.mjs +67 -79
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +28 -4
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +16 -8
- package/dist/core/refs.mjs +41 -10
- package/dist/core/registered-records.mjs +30 -0
- package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
- package/dist/core/repack.d.mts +2 -2
- package/dist/core/repack.mjs +30 -23
- package/dist/core/repo-info.mjs +62 -26
- package/dist/core/repos.mjs +18 -11
- package/dist/core/rules/changes.mjs +2 -2
- package/dist/core/rules/check.mjs +10 -10
- package/dist/core/rules/commit-changes.mjs +1 -1
- package/dist/core/rules/context.d.mts +7 -6
- package/dist/core/rules/context.mjs +18 -16
- package/dist/core/rules/fetch.mjs +78 -31
- package/dist/core/saved-caller-views.d.mts +72 -0
- package/dist/core/saved-caller-views.mjs +123 -0
- package/dist/core/saved-callers-public.d.mts +5 -0
- package/dist/core/saved-callers-public.mjs +10 -0
- package/dist/core/saved-callers.mjs +95 -0
- package/dist/core/seam.d.mts +12 -1
- package/dist/core/seam.mjs +4 -2
- package/dist/core/tokens.mjs +7 -2
- package/dist/core/view.d.mts +1 -1
- package/dist/core/view.mjs +1 -1
- package/dist/core/work.mjs +6 -5
- package/dist/effect.d.mts +2 -4
- package/dist/effect.mjs +2 -4
- package/dist/engine/commits.mjs +19 -47
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/diff.mjs +2 -2
- package/dist/engine/failures.d.mts +1 -2
- package/dist/engine/failures.mjs +1 -3
- package/dist/engine/merge-base-walk.mjs +57 -142
- package/dist/engine/merge-bases.mjs +5 -5
- package/dist/engine/merge-renames.mjs +1 -1
- package/dist/engine/merge.mjs +16 -14
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +1 -1
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +2 -2
- package/dist/event-streams/event-streams.d.mts +6 -2
- package/dist/event-streams/event-streams.mjs +6 -2
- package/dist/event-streams/stream.mjs +5 -2
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -2
- package/dist/http/answers.mjs +4 -3
- package/dist/http/core-parts.mjs +3 -4
- package/dist/http/handler.mjs +12 -32
- package/dist/http/parts.d.mts +1 -1
- package/dist/http/push-uploads.mjs +7 -5
- package/dist/http/receive-pack.mjs +3 -3
- package/dist/http/upload-pack.mjs +6 -5
- package/dist/index.d.mts +44 -24
- package/dist/index.mjs +17 -8
- package/dist/lfs/base.d.mts +8 -5
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/calls.mjs +3 -2
- package/dist/lfs/layer.d.mts +9 -7
- package/dist/lfs/layer.mjs +37 -22
- package/dist/lfs/locks.mjs +3 -3
- package/dist/lfs/objects.d.mts +3 -2
- package/dist/lfs/objects.mjs +235 -71
- package/dist/lfs/pointers.mjs +70 -19
- package/dist/lfs/purge.mjs +7 -3
- package/dist/lfs/rows.mjs +25 -8
- package/dist/lfs/service.d.mts +6 -3
- package/dist/lfs/service.mjs +8 -2
- package/dist/lfs/upkeep.mjs +53 -31
- package/dist/lfs/upload-most.mjs +41 -0
- package/dist/lfs/uploaded.mjs +59 -0
- package/dist/lfs/wire.mjs +1 -1
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +2 -2
- package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
- package/dist/protocol/bytes/text.mjs +6 -1
- package/dist/protocol/diff/read.d.mts +1 -1
- package/dist/protocol/diff/read.mjs +1 -1
- package/dist/protocol/diff/tree-diff.d.mts +1 -1
- package/dist/protocol/diff/tree-diff.mjs +11 -11
- package/dist/protocol/objects/fsck.mjs +6 -3
- package/dist/protocol/objects/lfs-pointer.mjs +6 -1
- package/dist/protocol/objects/tag.mjs +1 -1
- package/dist/protocol/objects/tree.mjs +1 -1
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +2 -2
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +4 -4
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +1 -1
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +1 -1
- package/dist/protocol/wire/lines.mjs +2 -2
- package/dist/protocol/wire/push-uploads.mjs +4 -2
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +2 -2
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/queue/advance.mjs +190 -68
- package/dist/queue/callers.mjs +56 -69
- package/dist/queue/calls.mjs +10 -11
- package/dist/queue/commit.mjs +28 -22
- package/dist/queue/host.d.mts +10 -11
- package/dist/queue/host.mjs +15 -7
- package/dist/queue/lanes.mjs +9 -18
- package/dist/queue/layer.d.mts +3 -3
- package/dist/queue/layer.mjs +11 -10
- package/dist/queue/limits.mjs +17 -5
- package/dist/queue/rows.mjs +13 -10
- package/dist/queue/schedule.mjs +7 -6
- package/dist/queue/search.mjs +11 -17
- package/dist/queue/state.mjs +7 -2
- package/dist/queue/trim.mjs +10 -5
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +20 -20
- package/dist/rest/caller.d.mts +22 -20
- package/dist/rest/client-namespace.d.mts +2 -0
- package/dist/rest/client.d.mts +32 -8
- package/dist/rest/client.mjs +314 -388
- package/dist/rest/commits.d.mts +284 -284
- package/dist/rest/errors.d.mts +10 -10
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/events.d.mts +13 -11
- package/dist/rest/events.mjs +3 -1
- package/dist/rest/files.d.mts +48 -48
- package/dist/rest/forks.d.mts +131 -143
- package/dist/rest/handler.mjs +4 -3
- package/dist/rest/handlers.mjs +15 -8
- package/dist/rest/layer.d.mts +3 -3
- package/dist/rest/layer.mjs +8 -7
- package/dist/rest/listen.d.mts +8 -6
- package/dist/rest/listen.mjs +33 -77
- package/dist/rest/me.d.mts +18 -20
- package/dist/rest/me.mjs +1 -1
- package/dist/rest/merges.d.mts +17 -17
- package/dist/rest/queue.d.mts +140 -140
- package/dist/rest/queue.mjs +1 -1
- package/dist/rest/refs.d.mts +214 -214
- package/dist/rest/refs.mjs +1 -1
- package/dist/rest/repos.d.mts +123 -135
- package/dist/rest/tags.d.mts +30 -30
- package/dist/rest/tokens.d.mts +250 -260
- package/dist/rest/tokens.mjs +10 -42
- package/dist/rest/topics.d.mts +162 -162
- package/dist/rest/topics.mjs +1 -1
- package/dist/rest/trees.d.mts +117 -117
- package/dist/rest/wire.d.mts +7 -5
- package/dist/rest/wire.mjs +4 -3
- package/dist/rest/work.d.mts +69 -69
- package/dist/rest/work.mjs +1 -1
- package/dist/rest.d.mts +1 -7
- package/dist/rest.mjs +1 -5
- package/dist/server/check-fetch.mjs +9 -0
- package/dist/server/extension.mjs +3 -115
- package/dist/server/git-layer.d.mts +30 -5
- package/dist/server/git-layer.mjs +59 -29
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/git-namespace.mjs +6 -4
- package/dist/server/joined.d.mts +83 -0
- package/dist/server/joined.mjs +91 -0
- package/dist/server/registry.d.mts +7 -3
- package/dist/server/registry.mjs +135 -31
- package/dist/server/server.d.mts +9 -3
- package/dist/server/server.mjs +277 -208
- package/dist/signin/context.d.mts +2 -2
- package/dist/signin/context.mjs +28 -37
- package/dist/signin/device.mjs +5 -5
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -3
- package/dist/signin/grants.mjs +5 -5
- package/dist/signin/layer.d.mts +9 -0
- package/dist/signin/layer.mjs +41 -0
- package/dist/signin/namespace.d.mts +2 -0
- package/dist/signin/public.d.mts +6 -0
- package/dist/signin/public.mjs +5 -0
- package/dist/signin/route.mjs +47 -21
- package/dist/signin/web.mjs +3 -3
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +4 -4
- package/dist/storage/clean-up.mjs +15 -6
- package/dist/storage/counted-bucket.mjs +34 -51
- package/dist/storage/fetch.mjs +1 -1
- package/dist/storage/fsck.mjs +12 -2
- package/dist/storage/graph-rebuild.mjs +262 -0
- package/dist/storage/host-bucket.mjs +1 -1
- package/dist/storage/index-build.d.mts +2 -2
- package/dist/storage/index-build.mjs +103 -15
- package/dist/storage/index-fetch.mjs +10 -6
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +1 -1
- package/dist/storage/index-visible.mjs +1 -1
- package/dist/storage/lfs-pointers.d.mts +5 -5
- package/dist/storage/lfs-pointers.mjs +37 -11
- package/dist/storage/loose.mjs +4 -1
- package/dist/storage/memory-budget.mjs +8 -2
- package/dist/storage/merge-cut.mjs +24 -1
- package/dist/storage/merge-fence.mjs +82 -20
- package/dist/storage/merge-most.mjs +1 -0
- package/dist/storage/merge-plan.mjs +5 -2
- package/dist/storage/merge-row.mjs +17 -5
- package/dist/storage/merge-stream.mjs +25 -13
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -2
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +2 -2
- package/dist/storage/object-rows.mjs +20 -4
- package/dist/storage/pack-ranges.d.mts +3 -1
- package/dist/storage/pack-ranges.mjs +168 -69
- package/dist/storage/pack-reads.mjs +4 -4
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +17 -15
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +103 -79
- package/dist/storage/placed-reads.mjs +81 -15
- package/dist/storage/prune-seen.mjs +126 -0
- package/dist/storage/prune-walk.mjs +87 -99
- package/dist/storage/prune.mjs +113 -50
- package/dist/storage/push-uploads.mjs +4 -2
- package/dist/storage/quarantine.d.mts +2 -2
- package/dist/storage/ready.d.mts +2 -2
- package/dist/storage/ready.mjs +15 -6
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +2 -2
- package/dist/storage/receive-steps.mjs +1 -1
- package/dist/storage/repack-contained.mjs +24 -16
- package/dist/storage/repack-job.d.mts +2 -2
- package/dist/storage/repack-job.mjs +5 -4
- package/dist/storage/repack.d.mts +2 -2
- package/dist/storage/repack.mjs +12 -5
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +15 -6
- package/dist/storage/send-list.mjs +6 -6
- package/dist/storage/single-flight.mjs +2 -2
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +8 -1
- package/dist/store/call-count.d.mts +24 -4
- package/dist/store/call-count.mjs +158 -44
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +2 -2
- package/dist/store/crossing.mjs +2 -6
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/errors.d.mts +7 -3
- package/dist/store/errors.mjs +41 -13
- package/dist/store/job-try.mjs +119 -15
- package/dist/store/list-job.mjs +5 -5
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +75 -16
- package/dist/store/promises.d.mts +2 -2
- package/dist/store/promises.mjs +31 -6
- package/dist/store/queue-jobs.mjs +1 -1
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +22 -24
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +6 -6
- package/dist/store/repo-record.mjs +29 -12
- package/dist/store/reservations.mjs +35 -8
- package/dist/store/scopes.mjs +12 -5
- package/dist/store/topic-jobs.mjs +8 -8
- package/dist/sync/bound.d.mts +1 -3
- package/dist/sync/bound.mjs +30 -42
- package/dist/sync/github.d.mts +5 -6
- package/dist/sync/github.mjs +37 -42
- package/dist/sync/http.mjs +15 -0
- package/dist/sync/import.mjs +30 -19
- package/dist/sync/layer.d.mts +13 -0
- package/dist/sync/layer.mjs +73 -0
- package/dist/sync/mirror.mjs +137 -58
- package/dist/sync/publish.mjs +3 -6
- package/dist/sync/step.mjs +223 -85
- package/dist/sync/tries.mjs +22 -15
- package/dist/sync.d.mts +3 -6
- package/dist/sync.mjs +3 -6
- package/dist/topics/advance.mjs +210 -94
- package/dist/topics/calls.mjs +8 -8
- package/dist/topics/directory.mjs +35 -12
- package/dist/topics/host.d.mts +5 -8
- package/dist/topics/host.mjs +42 -19
- package/dist/topics/layer.d.mts +381 -0
- package/dist/topics/layer.mjs +62 -0
- package/dist/topics/members.mjs +39 -10
- package/dist/topics/namespace.d.mts +2 -0
- package/dist/topics/public.d.mts +6 -0
- package/dist/topics/public.mjs +13 -0
- package/dist/topics/rows.mjs +12 -3
- package/dist/topics/topic.mjs +11 -10
- package/package.json +8 -13
- package/dist/access.d.mts +0 -2
- package/dist/access.mjs +0 -1
- package/dist/core/hooks/post-receive.mjs +0 -216
- package/dist/core/hooks/pre-receive.d.mts +0 -12
- package/dist/core/hooks/pre-receive.mjs +0 -36
- package/dist/engine/merge-base-walk.d.mts +0 -3
- package/dist/server/extension.d.mts +0 -21
- package/dist/server/routes.d.mts +0 -32
- package/dist/server/routes.mjs +0 -69
- package/dist/sync/import.d.mts +0 -10
- package/dist/sync/jobs.d.mts +0 -9
- package/dist/sync/jobs.mjs +0 -75
- package/dist/sync/mirror.d.mts +0 -13
- package/dist/sync/publish.d.mts +0 -6
- /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
|
@@ -2,78 +2,87 @@ import { GitErrorBody, gitError } from "../contracts/result.mjs";
|
|
|
2
2
|
import { spentAt } from "../contracts/calls-spent.mjs";
|
|
3
3
|
import { isServerClosed, tryClosing } from "../store/closed.mjs";
|
|
4
4
|
import { randomText } from "../store/random.mjs";
|
|
5
|
-
import * as Schema from "effect/Schema";
|
|
6
5
|
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
7
|
import * as Cause from "effect/Cause";
|
|
8
8
|
// src/auth/host-function.ts
|
|
9
|
-
/** A failure's ID, which the caller sees in the error's context and
|
|
9
|
+
/** A failure's ID, which the caller sees in the error's context and the host's log names. */
|
|
10
10
|
const failureId = () => `e_${randomText(8)}`;
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const annotationsOf = (name, about) => {
|
|
12
|
+
const annotations = { function: name };
|
|
13
|
+
if (about.repo !== void 0) annotations.repo = about.repo;
|
|
14
|
+
if (about.operation !== void 0) annotations.operation = about.operation.kind;
|
|
15
|
+
return annotations;
|
|
16
16
|
};
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Logs a host function's failure at `Error`, with its cause, annotated with the failure's ID the
|
|
19
|
+
* caller sees, and fails with the caller's error for it.
|
|
20
|
+
*/
|
|
21
|
+
const failed = (name, about, cause, timedOut) => Effect.suspend(() => {
|
|
19
22
|
const id = failureId();
|
|
20
|
-
const
|
|
21
|
-
id,
|
|
22
|
-
function: name,
|
|
23
|
-
timedOut
|
|
24
|
-
};
|
|
25
|
-
if (about.repo !== void 0) failure.repo = about.repo;
|
|
26
|
-
if (about.operation !== void 0) failure.operation = about.operation;
|
|
27
|
-
report(() => reports.onError?.(cause, failure));
|
|
28
|
-
return timedOut ? gitError("DEADLINE_EXCEEDED", "The server could not check this in time", {
|
|
23
|
+
const error = timedOut ? gitError("DEADLINE_EXCEEDED", "The server could not check this in time", {
|
|
29
24
|
hint: `Try again (${id})`,
|
|
30
25
|
context: { id }
|
|
31
26
|
}) : gitError("UNAVAILABLE", "The server could not check this", {
|
|
32
27
|
hint: `Try again (${id})`,
|
|
33
28
|
context: { id }
|
|
34
29
|
});
|
|
30
|
+
const message = timedOut ? `${name} ran out of time` : `${name} failed`;
|
|
31
|
+
return Effect.logError(message, Cause.die(cause)).pipe(Effect.annotateLogs({
|
|
32
|
+
...annotationsOf(name, about),
|
|
33
|
+
failure: id
|
|
34
|
+
}), Effect.andThen(Effect.fail(error)));
|
|
35
|
+
});
|
|
36
|
+
/** A host function's throw, carried out of `tryClosing` to be logged. */
|
|
37
|
+
var Threw = class {
|
|
38
|
+
cause;
|
|
39
|
+
constructor(cause) {
|
|
40
|
+
this.cause = cause;
|
|
41
|
+
}
|
|
35
42
|
};
|
|
36
43
|
/**
|
|
37
44
|
* Runs a host function: a throw is `UNAVAILABLE`, and a run past `timeout` `DEADLINE_EXCEEDED`,
|
|
38
|
-
* each with a fixed sentence and the failure's ID, which
|
|
45
|
+
* each with a fixed sentence and the failure's ID, which the host's log names beside the cause. A throw
|
|
39
46
|
* of a call bound Git or the store refused past, such as a hook's `changes` past its push's
|
|
40
47
|
* count, is no failure of the host's: it's the defect `CallsSpent` again, so the request stops
|
|
41
48
|
* whole, as it would have had Git made the call itself. Its `signal` aborts when the call
|
|
42
49
|
* is interrupted or runs out of time.
|
|
43
50
|
*/
|
|
44
|
-
const hostCall = (
|
|
45
|
-
const call = tryClosing(async (signal) => run(signal), (cause) =>
|
|
51
|
+
const hostCall = (name, about, run, options = {}) => {
|
|
52
|
+
const call = Effect.catch(tryClosing(async (signal) => run(signal), (cause) => new Threw(cause)), (threw) => failed(name, about, threw.cause, false));
|
|
46
53
|
const { timeout } = options;
|
|
47
54
|
if (timeout === void 0) return call;
|
|
48
55
|
return Effect.timeoutOrElse(call, {
|
|
49
56
|
duration: timeout,
|
|
50
|
-
orElse: () =>
|
|
57
|
+
orElse: () => failed(name, about, /* @__PURE__ */ new Error(`${name} ran past ${timeout} ms`), true)
|
|
51
58
|
});
|
|
52
59
|
};
|
|
53
60
|
/**
|
|
54
61
|
* Runs a host function that's an Effect, such as a rule's check, in the caller's fiber: its failure
|
|
55
|
-
* or its defect is `UNAVAILABLE`, as `hostCall` makes a throw, which
|
|
62
|
+
* or its defect is `UNAVAILABLE`, as `hostCall` makes a throw, which the host's log names with the
|
|
56
63
|
* cause. A call bound spent and a closed server stay the defects they are, so the request stops
|
|
57
|
-
* whole, and an interrupt stays one.
|
|
64
|
+
* whole, and an interrupt stays one. Past `timeout`, it interrupts the Effect and reports
|
|
65
|
+
* `timedOut: true` with `DEADLINE_EXCEEDED`.
|
|
58
66
|
*/
|
|
59
|
-
const hostEffect = (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
72
|
-
if (about.repo !== void 0) refusal.repo = about.repo;
|
|
73
|
-
if (about.operation !== void 0) refusal.operation = about.operation;
|
|
74
|
-
if (about.actor !== void 0) refusal.actor = about.actor;
|
|
75
|
-
report(() => reports.onRefused?.(refusal));
|
|
67
|
+
const hostEffect = (name, about, effect, options = {}) => {
|
|
68
|
+
const call = Effect.catchCause(effect, (cause) => {
|
|
69
|
+
if (Cause.hasInterruptsOnly(cause)) return Effect.interrupt;
|
|
70
|
+
const thrown = Cause.squash(cause);
|
|
71
|
+
if (spentAt(thrown) !== void 0 || isServerClosed(thrown)) return Effect.die(thrown);
|
|
72
|
+
return failed(name, about, thrown, false);
|
|
73
|
+
});
|
|
74
|
+
const { timeout, label = name } = options;
|
|
75
|
+
if (timeout === void 0) return call;
|
|
76
|
+
return Effect.timeoutOrElse(call, {
|
|
77
|
+
duration: timeout,
|
|
78
|
+
orElse: () => failed(name, about, /* @__PURE__ */ new Error(`${label} ran past ${timeout} ms`), true)
|
|
79
|
+
});
|
|
76
80
|
};
|
|
81
|
+
/** Logs a host function's refusal at `Debug`, as the caller is answered with it. */
|
|
82
|
+
const logRefusal = (name, about, error) => Effect.logDebug(`${name} refused: ${error.message}`).pipe(Effect.annotateLogs({
|
|
83
|
+
...annotationsOf(name, about),
|
|
84
|
+
code: error.code
|
|
85
|
+
}));
|
|
77
86
|
const isBody = /* @__PURE__ */ Schema.is(GitErrorBody);
|
|
78
87
|
/**
|
|
79
88
|
* A host function's refusal as it reads: `NOT_ALLOWED` when it names no code. Its context's
|
|
@@ -93,4 +102,4 @@ const rejectedError = (rejected) => {
|
|
|
93
102
|
})) input.context = context;
|
|
94
103
|
return gitError(code, message, input);
|
|
95
104
|
};
|
|
96
|
-
export { hostCall, hostEffect,
|
|
105
|
+
export { hostCall, hostEffect, logRefusal, rejectedError };
|
package/dist/auth/identify.d.mts
CHANGED
|
@@ -5,7 +5,6 @@ import { GitError } from "../contracts/result.mjs";
|
|
|
5
5
|
import "../contracts/tokens.mjs";
|
|
6
6
|
import "./auth.mjs";
|
|
7
7
|
import "./grants.mjs";
|
|
8
|
-
import "./host-function.mjs";
|
|
9
8
|
import * as Effect from "effect/Effect";
|
|
10
9
|
/** Who sent a request: its `Caller`, or `UNAUTHENTICATED` for a credential no one knows. */
|
|
11
10
|
export type Identify = (request: Request) => Effect.Effect<Caller, GitError>;
|
package/dist/auth/identify.mjs
CHANGED
|
@@ -48,7 +48,7 @@ const tokenCaller = ({ record }) => {
|
|
|
48
48
|
const identifier = (options) => {
|
|
49
49
|
const fromGrants = Effect.fnUntraced(function* (request, credentials) {
|
|
50
50
|
for (const resolver of options.grants()) {
|
|
51
|
-
const grant = yield* hostCall(
|
|
51
|
+
const grant = yield* hostCall("grants", {}, (signal) => resolver.resolve({
|
|
52
52
|
credentials,
|
|
53
53
|
request,
|
|
54
54
|
signal
|
|
@@ -80,7 +80,8 @@ const identifier = (options) => {
|
|
|
80
80
|
}
|
|
81
81
|
const { credentials } = read;
|
|
82
82
|
const secret = credentialSecret(credentials);
|
|
83
|
-
if (
|
|
83
|
+
if (secret.startsWith("gt_")) {
|
|
84
|
+
if (!options.tokens()) return yield* Effect.fail(unknownCredential());
|
|
84
85
|
const held = yield* verifyToken(options.store, secret, yield* options.now);
|
|
85
86
|
if (held === void 0) return yield* Effect.fail(unknownCredential());
|
|
86
87
|
return tokenCaller(held);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { auth_namespace_d_exports } from "./auth-namespace.mjs";
|
|
2
2
|
import { policy_d_exports } from "./policy.mjs";
|
|
3
|
-
export {
|
|
3
|
+
export { auth_namespace_d_exports as Auth, policy_d_exports as Policy };
|
package/dist/auth/policy.d.mts
CHANGED
|
@@ -18,9 +18,11 @@ export type Input = AuthorizeRequest;
|
|
|
18
18
|
export type Answer = DecisionAnswer | Accepted<RefAudience>;
|
|
19
19
|
export interface PolicyService {
|
|
20
20
|
/**
|
|
21
|
-
* Asked after core's own checks and a credential's ceiling: it narrows, and never opens.
|
|
22
|
-
* `
|
|
23
|
-
*
|
|
21
|
+
* Asked after core's own checks and a credential's ceiling: it narrows, and never opens. An
|
|
22
|
+
* `admin` token's ceiling is every kind, so the policy decides alone who may hold one, and a
|
|
23
|
+
* policy that doesn't accept it, as `signedIn` doesn't, refuses it. A `reject` is the caller's
|
|
24
|
+
* answer. A failure or a defect is `UNAVAILABLE`, logged at `Error` as `'authorize'`'s, so what
|
|
25
|
+
* the host's error says never reaches the caller. The default
|
|
24
26
|
* refusal, no code, `NOT_ALLOWED` or `NOT_FOUND`, answers a stranger as for a repo that isn't
|
|
25
27
|
* there, and a code of its own reaches only a caller who may read the repo.
|
|
26
28
|
*/
|
|
@@ -51,7 +53,8 @@ export declare const reject: (refusal: RejectInput) => Effect.Effect<Answer>;
|
|
|
51
53
|
* A `protect.bypass` or `lock.bypass` isn't, for anyone: a rule asks one on every change it
|
|
52
54
|
* refuses, so accepting it would lift every `Rules.protect` and `Rules.lock` for whoever may push.
|
|
53
55
|
* It allows every other operation kind, one Git adds later too, to any signed-in caller, so a host
|
|
54
|
-
* that wants a new kind closed until it decides writes its own policy.
|
|
56
|
+
* that wants a new kind closed until it decides writes its own policy. It names no one an admin:
|
|
57
|
+
* it refuses a caller on an `admin` token, and the minting of one.
|
|
55
58
|
*/
|
|
56
59
|
export declare const signedIn: PolicyService;
|
|
57
60
|
export { policy_d_exports };
|
package/dist/auth/policy.mjs
CHANGED
|
@@ -28,14 +28,11 @@ const accept = (value) => Effect.succeed(value === void 0 ? accept$1() : accept$
|
|
|
28
28
|
/** A refusal: `code` is `NOT_ALLOWED` when it's left out. Was `reject()`. */
|
|
29
29
|
const reject = (refusal) => Effect.succeed(reject$1(refusal));
|
|
30
30
|
/**
|
|
31
|
-
* Whether `
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* token or a grant, and no token scope or grant reaches any token operation, so only a host's own
|
|
35
|
-
* sign-in mints. If a token or a grant may ever mint, this must compare against
|
|
36
|
-
* `caller.subject ?? actor` instead.
|
|
31
|
+
* Whether `self`, the caller's `subject ?? actor`, mints `token` for themselves: they're its
|
|
32
|
+
* subject, with no one else acting. A caller on a token or a grant is its `subject`, and an
|
|
33
|
+
* `admin` token reaches token operations, so it's never the actor alone.
|
|
37
34
|
*/
|
|
38
|
-
const mintsForSelf = (
|
|
35
|
+
const mintsForSelf = (self, token) => token.subject.id === self.id && token.actor === void 0;
|
|
39
36
|
/**
|
|
40
37
|
* Git's own rules, which a host names when it has none of its own: a signed-in caller may do
|
|
41
38
|
* anything its credential's ceiling lets it but mint a token for anyone else, and an anonymous one
|
|
@@ -46,11 +43,17 @@ const mintsForSelf = (actor, token) => token.subject.id === actor.id && token.ac
|
|
|
46
43
|
* A `protect.bypass` or `lock.bypass` isn't, for anyone: a rule asks one on every change it
|
|
47
44
|
* refuses, so accepting it would lift every `Rules.protect` and `Rules.lock` for whoever may push.
|
|
48
45
|
* It allows every other operation kind, one Git adds later too, to any signed-in caller, so a host
|
|
49
|
-
* that wants a new kind closed until it decides writes its own policy.
|
|
46
|
+
* that wants a new kind closed until it decides writes its own policy. It names no one an admin:
|
|
47
|
+
* it refuses a caller on an `admin` token, and the minting of one.
|
|
50
48
|
*/
|
|
51
|
-
const signedIn = make(({ caller
|
|
49
|
+
const signedIn = make(({ caller, operation, repo }) => {
|
|
52
50
|
if (bypassKinds.has(operation.kind)) return reject({ message: "No rule is lifted for anyone" });
|
|
53
|
-
if (
|
|
51
|
+
if (caller.token?.scope === "admin" || operation.kind === "token.create" && operation.scope === "admin") return reject({ message: "No one holds an admin token here" });
|
|
52
|
+
const { actor } = caller;
|
|
53
|
+
if (actor.anonymous !== true) {
|
|
54
|
+
const self = caller.subject ?? actor;
|
|
55
|
+
return operation.kind === "token.create" && !mintsForSelf(self, operation) ? reject({ message: "Only tokens for yourself" }) : accept();
|
|
56
|
+
}
|
|
54
57
|
return operation.kind === "repo.list" || repo?.public === true && readKinds.has(operation.kind) ? accept() : reject({ message: "Sign in first" });
|
|
55
58
|
});
|
|
56
59
|
export { Policy, accept, layer, make, policy_exports, reject, signedIn };
|
package/dist/auth/token-rows.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { TokenScope } from "../contracts/tokens.mjs";
|
|
1
2
|
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
2
3
|
import { StoredRepo } from "../store/records.mjs";
|
|
3
4
|
import { collections, selfKey } from "../store/scopes.mjs";
|
|
4
5
|
import { hashSecret, placeScope, readTokenText, sameHash, tokenIdPlace } from "./token-text.mjs";
|
|
5
|
-
import * as Schema from "effect/Schema";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
7
8
|
// src/auth/token-rows.ts
|
|
8
9
|
const Party = /* @__PURE__ */ Schema.Struct({ id: Schema.String });
|
|
9
10
|
/**
|
|
@@ -12,11 +13,7 @@ const Party = /* @__PURE__ */ Schema.Struct({ id: Schema.String });
|
|
|
12
13
|
*/
|
|
13
14
|
const TokenRow = /* @__PURE__ */ Schema.Struct({
|
|
14
15
|
hash: Schema.String,
|
|
15
|
-
scope:
|
|
16
|
-
"read",
|
|
17
|
-
"report",
|
|
18
|
-
"write"
|
|
19
|
-
]),
|
|
16
|
+
scope: TokenScope,
|
|
20
17
|
expiresAt: Schema.Int,
|
|
21
18
|
subject: Party,
|
|
22
19
|
actor: Schema.optionalKey(Party),
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Git } from "../contracts/git.mjs";
|
|
2
|
+
import { Store } from "../contracts/promises.mjs";
|
|
3
|
+
import { GitError } from "../contracts/result.mjs";
|
|
4
|
+
import { Tokens } from "../contracts/tokens.mjs";
|
|
5
|
+
import { HeldTokenCalls } from "./tokens.mjs";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import { Moment } from "@ref0/infra";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
9
|
+
import * as Layer from "effect/Layer";
|
|
10
|
+
/** What Git's own tokens mint with once they're on, and what sign-in's routes answer through. */
|
|
11
|
+
export interface HeldTokens {
|
|
12
|
+
/** Git's trusted token calls: a mint names the repo its approval resolved, as `held`. */
|
|
13
|
+
readonly tokens: HeldTokenCalls;
|
|
14
|
+
readonly store: Store;
|
|
15
|
+
readonly now: Effect.Effect<Moment>;
|
|
16
|
+
readonly through: <A, E>(effect: Effect.Effect<A, E>) => Effect.Effect<A, E>;
|
|
17
|
+
readonly refuse: (error: GitError) => Response;
|
|
18
|
+
}
|
|
19
|
+
declare const TokensBase_base: Context.ServiceClass<TokensBase, "@ref0/git/auth/TokensBase", {
|
|
20
|
+
/** Turns Git's own tokens on, from the next request `identify` reads: a second is a defect. */
|
|
21
|
+
readonly attach: Effect.Effect<HeldTokenCalls>;
|
|
22
|
+
/** What sign-in mints through: `undefined` until the tokens are on. */
|
|
23
|
+
readonly held: Effect.Effect<HeldTokens | undefined>;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Core's tokens, which no host provides: `Tokens.layer()` turns them on once Git has opened, and the
|
|
27
|
+
* `tokens()` bridge as it opens. Until then `identify` sends a `gt_` credential on to the grants,
|
|
28
|
+
* and the server has no `tokens` group.
|
|
29
|
+
*/
|
|
30
|
+
export declare class TokensBase extends /* @__PURE__ */ TokensBase_base {}
|
|
31
|
+
/**
|
|
32
|
+
* Git's own tokens, as a feature of `Git.layer`: a row each in core's `git/tokens/`, swept by
|
|
33
|
+
* `git.tokens.cleanup`. `identify` checks a `gt_` credential before any grant or the host's `Auth`,
|
|
34
|
+
* and `SignIn.layer` mints through it. It registers the name `tokens`, so no other registration
|
|
35
|
+
* takes it, and adds no grant. It takes no options, as `Rest.layer()` takes none: nothing
|
|
36
|
+
* configures a token's rows or their sweep yet, and a parameter added later is a smaller break than
|
|
37
|
+
* an empty options bag kept.
|
|
38
|
+
*/
|
|
39
|
+
export declare const layer: () => Layer.Layer<Tokens, GitError, Git | TokensBase>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { register } from "../contracts/git.mjs";
|
|
2
|
+
import { gitError } from "../contracts/result.mjs";
|
|
3
|
+
import { Tokens } from "../contracts/tokens.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
7
|
+
// src/auth/tokens-layer.ts
|
|
8
|
+
/** A token call on a server with none of Git's own tokens on: REST's answer, and a joined face's. */
|
|
9
|
+
const noTokens = /* @__PURE__ */ gitError("NOT_FOUND", "This server doesn't have tokens turned on", { hostHint: "Provide Tokens.layer(), or pass tokens() to createGitServer" });
|
|
10
|
+
/**
|
|
11
|
+
* Core's tokens, which no host provides: `Tokens.layer()` turns them on once Git has opened, and the
|
|
12
|
+
* `tokens()` bridge as it opens. Until then `identify` sends a `gt_` credential on to the grants,
|
|
13
|
+
* and the server has no `tokens` group.
|
|
14
|
+
*/
|
|
15
|
+
var TokensBase = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/auth/TokensBase")) {};
|
|
16
|
+
/**
|
|
17
|
+
* Git's own tokens, as a feature of `Git.layer`: a row each in core's `git/tokens/`, swept by
|
|
18
|
+
* `git.tokens.cleanup`. `identify` checks a `gt_` credential before any grant or the host's `Auth`,
|
|
19
|
+
* and `SignIn.layer` mints through it. It registers the name `tokens`, so no other registration
|
|
20
|
+
* takes it, and adds no grant. It takes no options, as `Rest.layer()` takes none: nothing
|
|
21
|
+
* configures a token's rows or their sweep yet, and a parameter added later is a smaller break than
|
|
22
|
+
* an empty options bag kept.
|
|
23
|
+
*/
|
|
24
|
+
const layer = () => Layer.effect(Tokens, Effect.gen(function* () {
|
|
25
|
+
yield* register({ name: "tokens" });
|
|
26
|
+
const base = yield* TokensBase;
|
|
27
|
+
return Tokens.of(yield* base.attach);
|
|
28
|
+
}));
|
|
29
|
+
export { TokensBase, layer, noTokens };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CreatedToken, GrantScope, PrefixTarget, TokenCalls, TokenCoverage, TokenCreate, TokenCreateInput, TokenFields, TokenId, TokenInfo, TokenKey, TokenKeyInput, TokenList, TokenListInput, TokenRecord, TokenScope, TokenState, TokenTarget, Tokens, TokensFeature, TrustedWriteInput, VerifiedToken, create, get, grantScopes, list, revoke, revokeKey, tokenScopes, tokenStates } from "../contracts/tokens.mjs";
|
|
2
|
+
import { layer } from "./tokens-layer.mjs";
|
|
3
|
+
declare namespace tokens_public_d_exports {
|
|
4
|
+
export { CreatedToken, GrantScope, PrefixTarget, TokenCalls, TokenCoverage, TokenCreate, TokenCreateInput, TokenFields, TokenId, TokenInfo, TokenKey, TokenKeyInput, TokenList, TokenListInput, TokenRecord, TokenScope, TokenState, TokenTarget, Tokens, TokensFeature, TrustedWriteInput, VerifiedToken, create, get, grantScopes, layer, list, revoke, revokeKey, tokenScopes, tokenStates };
|
|
5
|
+
}
|
|
6
|
+
export { CreatedToken, GrantScope, PrefixTarget, TokenCalls, TokenCoverage, TokenCreate, TokenCreateInput, TokenFields, TokenId, TokenInfo, TokenKey, TokenKeyInput, TokenList, TokenListInput, TokenRecord, TokenScope, TokenState, TokenTarget, Tokens, TokensFeature, TrustedWriteInput, VerifiedToken, create, get, grantScopes, layer, list, revoke, revokeKey, tokenScopes, tokenStates, tokens_public_d_exports };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { CreatedToken, GrantScope, PrefixTarget, TokenCoverage, TokenCreate, TokenFields, TokenId, TokenInfo, TokenKey, TokenList, TokenRecord, TokenScope, TokenState, TokenTarget, Tokens, create, get, grantScopes, list, revoke, revokeKey, tokenScopes, tokenStates } from "../contracts/tokens.mjs";
|
|
3
|
+
import { layer } from "./tokens-layer.mjs";
|
|
4
|
+
// src/auth/tokens-public.ts
|
|
5
|
+
var tokens_public_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
CreatedToken: () => CreatedToken,
|
|
7
|
+
GrantScope: () => GrantScope,
|
|
8
|
+
PrefixTarget: () => PrefixTarget,
|
|
9
|
+
TokenCoverage: () => TokenCoverage,
|
|
10
|
+
TokenCreate: () => TokenCreate,
|
|
11
|
+
TokenFields: () => TokenFields,
|
|
12
|
+
TokenId: () => TokenId,
|
|
13
|
+
TokenInfo: () => TokenInfo,
|
|
14
|
+
TokenKey: () => TokenKey,
|
|
15
|
+
TokenList: () => TokenList,
|
|
16
|
+
TokenRecord: () => TokenRecord,
|
|
17
|
+
TokenScope: () => TokenScope,
|
|
18
|
+
TokenState: () => TokenState,
|
|
19
|
+
TokenTarget: () => TokenTarget,
|
|
20
|
+
Tokens: () => Tokens,
|
|
21
|
+
create: () => create,
|
|
22
|
+
get: () => get,
|
|
23
|
+
grantScopes: () => grantScopes,
|
|
24
|
+
layer: () => layer,
|
|
25
|
+
list: () => list,
|
|
26
|
+
revoke: () => revoke,
|
|
27
|
+
revokeKey: () => revokeKey,
|
|
28
|
+
tokenScopes: () => tokenScopes,
|
|
29
|
+
tokenStates: () => tokenStates
|
|
30
|
+
});
|
|
31
|
+
export { CreatedToken, GrantScope, PrefixTarget, TokenCoverage, TokenCreate, TokenFields, TokenId, TokenInfo, TokenKey, TokenList, TokenRecord, TokenScope, TokenState, TokenTarget, Tokens, create, get, grantScopes, layer, list, revoke, revokeKey, tokenScopes, tokenStates, tokens_public_exports };
|
package/dist/auth/tokens.d.mts
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import "../contracts/ids.mjs";
|
|
2
1
|
import "../contracts/events.mjs";
|
|
3
2
|
import "../contracts/promises.mjs";
|
|
4
|
-
import "../contracts/actors.mjs";
|
|
3
|
+
import { Caller } from "../contracts/actors.mjs";
|
|
4
|
+
import { InternalRepoId } from "../contracts/ids.mjs";
|
|
5
5
|
import "../contracts/operations.mjs";
|
|
6
6
|
import "../contracts/result.mjs";
|
|
7
|
-
import "../contracts/services.mjs";
|
|
8
|
-
import { TokensFeature } from "../contracts/tokens.mjs";
|
|
7
|
+
import { EffectCalls } from "../contracts/services.mjs";
|
|
8
|
+
import { TokenCalls, TokensFeature } from "../contracts/tokens.mjs";
|
|
9
9
|
import "../store/outbox.mjs";
|
|
10
|
-
import { JobDefinition, Moment, Read, Row } from "@ref0/infra";
|
|
11
10
|
import "effect/Effect";
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import { JobDefinition, Moment, Read, Row } from "@ref0/infra";
|
|
12
|
+
/**
|
|
13
|
+
* Turns on Git's own tokens. A token's scope is its ceiling, which the host's `Policy` narrows and
|
|
14
|
+
* never opens: an `admin` token, over the whole host alone, reaches every operation, but only as
|
|
15
|
+
* far as the policy accepts it. `Policy.signedIn` refuses it, so a host that mints one writes its
|
|
16
|
+
* own policy, naming who may hold it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const tokens: () => TokensFeature;
|
|
19
|
+
/** Git's token calls, where a create or a list may name the repo `authorize` checked, as `held`. */
|
|
20
|
+
export interface HeldTokenCalls extends EffectCalls<TokenCalls> {
|
|
21
|
+
readonly create: (...args: [...Parameters<EffectCalls<TokenCalls>['create']>, held?: InternalRepoId]) => ReturnType<EffectCalls<TokenCalls>['create']>;
|
|
22
|
+
readonly list: (...args: [...Parameters<EffectCalls<TokenCalls>['list']>, held?: InternalRepoId]) => ReturnType<EffectCalls<TokenCalls>['list']>;
|
|
23
|
+
/** `caller`: who revokes, for its event; a host's direct call names none. */
|
|
24
|
+
readonly revoke: (...args: [...Parameters<EffectCalls<TokenCalls>['revoke']>, caller?: Caller]) => ReturnType<EffectCalls<TokenCalls>['revoke']>;
|
|
25
|
+
}
|
package/dist/auth/tokens.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { gitJob } from "../store/job-try.mjs";
|
|
2
2
|
import { fail } from "../contracts/result.mjs";
|
|
3
3
|
import { resolveRepo } from "../store/catalogue.mjs";
|
|
4
4
|
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
@@ -9,12 +9,17 @@ import { settleName } from "../store/settle.mjs";
|
|
|
9
9
|
import { longActorId } from "./authorize.mjs";
|
|
10
10
|
import { TokenRow, readToken, tokenKey, tokenRecord, tokenState } from "./token-rows.mjs";
|
|
11
11
|
import { hashSecret, newSecret, newTokenId, placeScope, tokenText } from "./token-text.mjs";
|
|
12
|
-
import { CurrentJob, Job } from "@ref0/infra";
|
|
13
|
-
import * as Schema from "effect/Schema";
|
|
14
12
|
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Schema from "effect/Schema";
|
|
14
|
+
import { CurrentJob, Job } from "@ref0/infra";
|
|
15
15
|
import * as Random from "effect/Random";
|
|
16
16
|
// src/auth/tokens.ts
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Turns on Git's own tokens. A token's scope is its ceiling, which the host's `Policy` narrows and
|
|
19
|
+
* never opens: an `admin` token, over the whole host alone, reaches every operation, but only as
|
|
20
|
+
* far as the policy accepts it. `Policy.signedIn` refuses it, so a host that mints one writes its
|
|
21
|
+
* own policy, naming who may hold it.
|
|
22
|
+
*/
|
|
18
23
|
const tokens = () => ({ kind: "tokens" });
|
|
19
24
|
const day = 864e5;
|
|
20
25
|
/** The longest a token may live. */
|
|
@@ -145,6 +150,7 @@ const tokenCalls = (options) => {
|
|
|
145
150
|
const long = longActorId(input.subject, input.actor);
|
|
146
151
|
if (long !== void 0) return yield* Effect.fail(long);
|
|
147
152
|
yield* checkWriteKey(input.key);
|
|
153
|
+
if (input.scope === "admin" && !(isPrefixTarget(target) && target.prefix === "")) return yield* fail("INVALID_ARGUMENT", "An admin token covers the whole host: use prefix ''");
|
|
148
154
|
const now = yield* options.now;
|
|
149
155
|
const expiresAt = yield* tokenExpiry(now, input.expiresAt);
|
|
150
156
|
const pause = missedPauses();
|
|
@@ -378,9 +384,9 @@ const TokenCleanupJob = /* @__PURE__ */ Job.make(tokenCleanupName, {
|
|
|
378
384
|
}
|
|
379
385
|
});
|
|
380
386
|
/** `git.tokens.cleanup`, on the server's clock: each try one batch in its scope. */
|
|
381
|
-
const tokenCleanupJob = (now) =>
|
|
387
|
+
const tokenCleanupJob = (now) => gitJob(TokenCleanupJob, () => Effect.flatMap(Effect.all([
|
|
382
388
|
now,
|
|
383
389
|
CurrentJob.store,
|
|
384
390
|
CurrentJob.current
|
|
385
|
-
]), ([at, store, job]) => cleanupScope(store, job.scope, at)))
|
|
391
|
+
]), ([at, store, job]) => cleanupScope(store, job.scope, at)));
|
|
386
392
|
export { isPrefixTarget, keptAfterExpiry, maxTokenLife, readTarget, tokenCalls, tokenCleanupJob, tokenCleanupName, tokenExpiry, tokenParties, tokens };
|
package/dist/auth.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { accessHeader } from "./auth/access-jwt.mjs";
|
|
2
2
|
import { BasicOptions, BearerOptions, basic, bearer } from "./auth/helpers.mjs";
|
|
3
3
|
import { tokens } from "./auth/tokens.mjs";
|
|
4
4
|
import { ghClientId } from "./signin/context.mjs";
|
|
5
5
|
import { ghWriteScope } from "./contracts/signin.mjs";
|
|
6
6
|
import { AccessTokenAnswer, DeviceCodeAnswer, deviceGrant, readAccessTokenAnswer, readDeviceCodeAnswer, signInPaths } from "./signin/wire.mjs";
|
|
7
7
|
import { TokensFeature } from "./contracts/tokens.mjs";
|
|
8
|
-
export { type
|
|
8
|
+
export { type AccessTokenAnswer, type BasicOptions, type BearerOptions, type DeviceCodeAnswer, type TokensFeature, accessHeader, basic, bearer, deviceGrant, ghClientId, ghWriteScope, readAccessTokenAnswer, readDeviceCodeAnswer, signInPaths, tokens };
|
package/dist/auth.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { accessHeader
|
|
1
|
+
import { accessHeader } from "./auth/access-jwt.mjs";
|
|
2
2
|
import { basic, bearer } from "./auth/helpers.mjs";
|
|
3
3
|
import { tokens } from "./auth/tokens.mjs";
|
|
4
4
|
import { ghClientId } from "./signin/context.mjs";
|
|
5
5
|
import { ghWriteScope } from "./contracts/signin.mjs";
|
|
6
6
|
import { deviceGrant, readAccessTokenAnswer, readDeviceCodeAnswer, signInPaths } from "./signin/wire.mjs";
|
|
7
|
-
export { accessHeader,
|
|
7
|
+
export { accessHeader, basic, bearer, deviceGrant, ghClientId, ghWriteScope, readAccessTokenAnswer, readDeviceCodeAnswer, signInPaths, tokens };
|
package/dist/client/client.d.mts
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
import { GitClient, GitClientOptions, PagedInput } from "../contracts/client.mjs";
|
|
2
|
-
import { Result } from "../contracts/result.mjs";
|
|
3
1
|
import { EffectCalls } from "../contracts/services.mjs";
|
|
2
|
+
import "../effect.mjs";
|
|
3
|
+
import { GitClientCalls, GitClientOptions, GitClientPromises, PagedInput } from "../contracts/client.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
4
5
|
import { Listing } from "@ref0/infra";
|
|
6
|
+
import * as Context from "effect/Context";
|
|
7
|
+
import * as Stream from "effect/Stream";
|
|
8
|
+
declare namespace client_d_exports {
|
|
9
|
+
export { GitClient, GitClientCalls, make, paginate };
|
|
10
|
+
}
|
|
11
|
+
declare const GitClient_base: Context.ServiceClass<GitClient, "@ref0/git/GitClient", EffectCalls<GitClientPromises, never>>;
|
|
5
12
|
/**
|
|
6
|
-
* A client of one remote
|
|
7
|
-
*
|
|
8
|
-
* this, as a service. Each is an edge a host calls, as the server's Effect face is: a spent bound,
|
|
9
|
-
* a `CallBudget`'s or the platform's cap, is answered as its refusal, never a defect.
|
|
13
|
+
* A client of one remote as a service, for a program that's handed one: with `GitClient` from
|
|
14
|
+
* `@ref0/git`, `Layer.succeed(GitClient.GitClient, GitClient.make(options))` provides it.
|
|
10
15
|
*/
|
|
11
|
-
export declare
|
|
16
|
+
export declare class GitClient extends /* @__PURE__ */ GitClient_base {}
|
|
12
17
|
/**
|
|
13
|
-
* A client of `options.url
|
|
14
|
-
* calls on its own storage,
|
|
15
|
-
*
|
|
18
|
+
* A client of `options.url`, as Effects: `remoteRefs`, `fetch` and `push` on the remote over Git's
|
|
19
|
+
* smart HTTP, and the server's calls on its own storage, which a fetch fills and a push reads. Each
|
|
20
|
+
* is an edge a host calls, as the server's Effect face is: a spent bound, a `CallBudget`'s or the
|
|
21
|
+
* platform's cap, fails as its refusal, never a defect. Interrupting a call stops it.
|
|
16
22
|
*/
|
|
17
|
-
export declare const
|
|
23
|
+
export declare const make: (options: GitClientOptions) => GitClientCalls;
|
|
18
24
|
/**
|
|
19
|
-
* Each item `list` answers, a page at a time, from the input's `page` on: the next page asked
|
|
20
|
-
*
|
|
21
|
-
*
|
|
25
|
+
* Each item `list` answers, a page at a time, from the input's `page` on: the next page asked for
|
|
26
|
+
* only once the last one's items are taken. A refused page fails the stream with its own error,
|
|
27
|
+
* after the items of the pages before it.
|
|
22
28
|
*/
|
|
23
|
-
export declare
|
|
29
|
+
export declare const paginate: <Args extends unknown[], Input extends PagedInput, Item, E, R>(list: (...args: [...Args, Input]) => Effect.Effect<Listing<Item>, E, R>, ...args: [...Args, Input]) => Stream.Stream<Item, E, R>;
|
|
30
|
+
export { type GitClientCalls, client_d_exports };
|
package/dist/client/client.mjs
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { guardedCalls, noDoor } from "../core/promise.mjs";
|
|
3
3
|
import { gitHttp } from "./git-http.mjs";
|
|
4
4
|
import { localSide } from "./local.mjs";
|
|
5
5
|
import { fetchInto, pushFrom, remoteRefs } from "./remote.mjs";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Option from "effect/Option";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
9
|
+
import * as Stream from "effect/Stream";
|
|
6
10
|
// src/client/client.ts
|
|
11
|
+
var client_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
GitClient: () => GitClient,
|
|
13
|
+
make: () => make,
|
|
14
|
+
paginate: () => paginate
|
|
15
|
+
});
|
|
7
16
|
/**
|
|
8
|
-
* A client of one remote
|
|
9
|
-
*
|
|
10
|
-
* this, as a service. Each is an edge a host calls, as the server's Effect face is: a spent bound,
|
|
11
|
-
* a `CallBudget`'s or the platform's cap, is answered as its refusal, never a defect.
|
|
17
|
+
* A client of one remote as a service, for a program that's handed one: with `GitClient` from
|
|
18
|
+
* `@ref0/git`, `Layer.succeed(GitClient.GitClient, GitClient.make(options))` provides it.
|
|
12
19
|
*/
|
|
13
|
-
|
|
20
|
+
var GitClient = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/GitClient")) {};
|
|
21
|
+
/**
|
|
22
|
+
* A client of `options.url`, as Effects: `remoteRefs`, `fetch` and `push` on the remote over Git's
|
|
23
|
+
* smart HTTP, and the server's calls on its own storage, which a fetch fills and a push reads. Each
|
|
24
|
+
* is an edge a host calls, as the server's Effect face is: a spent bound, a `CallBudget`'s or the
|
|
25
|
+
* platform's cap, fails as its refusal, never a defect. Interrupting a call stops it.
|
|
26
|
+
*/
|
|
27
|
+
const make = (options) => {
|
|
14
28
|
const local = localSide(options);
|
|
15
29
|
const http = gitHttp(options);
|
|
16
30
|
return guardedCalls({
|
|
@@ -21,30 +35,20 @@ const effectGitClient = (options) => {
|
|
|
21
35
|
}, noDoor);
|
|
22
36
|
};
|
|
23
37
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
38
|
+
* Each item `list` answers, a page at a time, from the input's `page` on: the next page asked for
|
|
39
|
+
* only once the last one's items are taken. A refused page fails the stream with its own error,
|
|
40
|
+
* after the items of the pages before it.
|
|
27
41
|
*/
|
|
28
|
-
const
|
|
29
|
-
/**
|
|
30
|
-
* Each item `list` answers, a page at a time, from the input's `page` on: the next page asked
|
|
31
|
-
* for only once the last one's items are taken. A refused page throws its own `GitError`, so a
|
|
32
|
-
* loop over it stops there with the error's `code`.
|
|
33
|
-
*/
|
|
34
|
-
async function* paginate(list, ...args) {
|
|
42
|
+
const paginate = (list, ...args) => {
|
|
35
43
|
const head = args.slice(0, -1);
|
|
36
44
|
const input = args.at(-1);
|
|
37
|
-
|
|
45
|
+
return Stream.paginate(input.page?.after, (after) => {
|
|
38
46
|
const page = { ...input.page };
|
|
39
47
|
if (after !== void 0) page.after = after;
|
|
40
|
-
|
|
48
|
+
return Effect.map(list(...head, {
|
|
41
49
|
...input,
|
|
42
50
|
page
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
after = listed.value.next;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export { createGitClient, effectGitClient, paginate };
|
|
51
|
+
}), (listed) => [listed.items, Option.fromUndefinedOr(listed.next)]);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
export { GitClient, client_exports, make, paginate };
|