@leed-ai/git-gateway-contract 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +50 -2
- package/dist/behaviour/assertions.d.ts +23 -0
- package/dist/behaviour/assertions.js +56 -0
- package/dist/behaviour/assertions.js.map +1 -0
- package/dist/behaviour/behaviour-case.d.ts +19 -0
- package/dist/behaviour/behaviour-case.js +12 -0
- package/dist/behaviour/behaviour-case.js.map +1 -0
- package/dist/behaviour/behaviour-suite.d.ts +30 -0
- package/dist/behaviour/behaviour-suite.js +50 -0
- package/dist/behaviour/behaviour-suite.js.map +1 -0
- package/dist/behaviour/commit-action-cases.d.ts +4 -0
- package/dist/behaviour/commit-action-cases.js +342 -0
- package/dist/behaviour/commit-action-cases.js.map +1 -0
- package/dist/behaviour/commit-write-cases.d.ts +4 -0
- package/dist/behaviour/commit-write-cases.js +234 -0
- package/dist/behaviour/commit-write-cases.js.map +1 -0
- package/dist/behaviour/fixtures.d.ts +29 -0
- package/dist/behaviour/fixtures.js +83 -0
- package/dist/behaviour/fixtures.js.map +1 -0
- package/dist/behaviour/lifecycle-cases.d.ts +4 -0
- package/dist/behaviour/lifecycle-cases.js +158 -0
- package/dist/behaviour/lifecycle-cases.js.map +1 -0
- package/dist/behaviour/promote-cases.d.ts +4 -0
- package/dist/behaviour/promote-cases.js +122 -0
- package/dist/behaviour/promote-cases.js.map +1 -0
- package/dist/behaviour/read-cases.d.ts +4 -0
- package/dist/behaviour/read-cases.js +248 -0
- package/dist/behaviour/read-cases.js.map +1 -0
- package/dist/behaviour/sync-cases.d.ts +4 -0
- package/dist/behaviour/sync-cases.js +205 -0
- package/dist/behaviour/sync-cases.js.map +1 -0
- package/dist/clock-B3MlpmVY.d.ts +10 -0
- package/dist/commit-BEZmeAOl.d.ts +23 -0
- package/dist/file-map-CxUveLWz.d.ts +18 -0
- package/dist/gateway-config-oVsdTEeK.d.ts +39 -0
- package/dist/gateway-error-body-BWzZFAQI.d.ts +214 -0
- package/dist/gateway-error.d.ts +30 -0
- package/dist/gateway-error.js +63 -0
- package/dist/gateway-error.js.map +1 -0
- package/dist/git-gateway-VA9Tc5tn.d.ts +358 -0
- package/dist/git-gateway.d.ts +2 -0
- package/dist/git-gateway.js +65 -0
- package/dist/git-gateway.js.map +1 -0
- package/dist/health.d.ts +9 -0
- package/dist/health.js +18 -0
- package/dist/health.js.map +1 -0
- package/dist/history-CqvHaUE-.d.ts +20 -0
- package/dist/package-name.d.ts +3 -0
- package/dist/package-name.js +6 -0
- package/dist/package-name.js.map +1 -0
- package/dist/proxy/audit-event.d.ts +61 -0
- package/dist/proxy/audit-event.js +97 -0
- package/dist/proxy/audit-event.js.map +1 -0
- package/dist/proxy/branch-rule.d.ts +72 -0
- package/dist/proxy/branch-rule.js +106 -0
- package/dist/proxy/branch-rule.js.map +1 -0
- package/dist/proxy/gateway-hooks.d.ts +58 -0
- package/dist/proxy/gateway-hooks.js +0 -0
- package/dist/proxy/git-operation.d.ts +17 -0
- package/dist/proxy/git-operation.js +32 -0
- package/dist/proxy/git-operation.js.map +1 -0
- package/dist/proxy/policy-result.d.ts +51 -0
- package/dist/proxy/policy-result.js +90 -0
- package/dist/proxy/policy-result.js.map +1 -0
- package/dist/proxy/principal.d.ts +18 -0
- package/dist/proxy/principal.js +32 -0
- package/dist/proxy/principal.js.map +1 -0
- package/dist/proxy/push-policy-result.d.ts +34 -0
- package/dist/proxy/push-policy-result.js +48 -0
- package/dist/proxy/push-policy-result.js.map +1 -0
- package/dist/proxy/push-policy.d.ts +146 -0
- package/dist/proxy/push-policy.js +112 -0
- package/dist/proxy/push-policy.js.map +1 -0
- package/dist/proxy/request-credential.d.ts +22 -0
- package/dist/proxy/request-credential.js +46 -0
- package/dist/proxy/request-credential.js.map +1 -0
- package/dist/proxy/smart-http-config.d.ts +22 -0
- package/dist/proxy/smart-http-config.js +40 -0
- package/dist/proxy/smart-http-config.js.map +1 -0
- package/dist/reference/apply-actions.d.ts +9 -0
- package/dist/reference/apply-actions.js +84 -0
- package/dist/reference/apply-actions.js.map +1 -0
- package/dist/reference/branch-methods.d.ts +7 -0
- package/dist/reference/branch-methods.js +105 -0
- package/dist/reference/branch-methods.js.map +1 -0
- package/dist/reference/bytes.d.ts +22 -0
- package/dist/reference/bytes.js +62 -0
- package/dist/reference/bytes.js.map +1 -0
- package/dist/reference/clock.d.ts +2 -0
- package/dist/reference/clock.js +18 -0
- package/dist/reference/clock.js.map +1 -0
- package/dist/reference/commit-method.d.ts +5 -0
- package/dist/reference/commit-method.js +83 -0
- package/dist/reference/commit-method.js.map +1 -0
- package/dist/reference/file-map.d.ts +2 -0
- package/dist/reference/file-map.js +24 -0
- package/dist/reference/file-map.js.map +1 -0
- package/dist/reference/hash.d.ts +10 -0
- package/dist/reference/hash.js +25 -0
- package/dist/reference/hash.js.map +1 -0
- package/dist/reference/history.d.ts +2 -0
- package/dist/reference/history.js +65 -0
- package/dist/reference/history.js.map +1 -0
- package/dist/reference/lifecycle-methods.d.ts +9 -0
- package/dist/reference/lifecycle-methods.js +48 -0
- package/dist/reference/lifecycle-methods.js.map +1 -0
- package/dist/reference/read-methods.d.ts +13 -0
- package/dist/reference/read-methods.js +68 -0
- package/dist/reference/read-methods.js.map +1 -0
- package/dist/reference/reference-gateway.d.ts +18 -0
- package/dist/reference/reference-gateway.js +35 -0
- package/dist/reference/reference-gateway.js.map +1 -0
- package/dist/reference/repo-state.d.ts +43 -0
- package/dist/reference/repo-state.js +45 -0
- package/dist/reference/repo-state.js.map +1 -0
- package/dist/reference/run-method.d.ts +13 -0
- package/dist/reference/run-method.js +15 -0
- package/dist/reference/run-method.js.map +1 -0
- package/dist/reference/three-way-merge.d.ts +16 -0
- package/dist/reference/three-way-merge.js +45 -0
- package/dist/reference/three-way-merge.js.map +1 -0
- package/dist/reference/trailer.d.ts +7 -0
- package/dist/reference/trailer.js +16 -0
- package/dist/reference/trailer.js.map +1 -0
- package/dist/reference/tree-index.d.ts +2 -0
- package/dist/reference/tree-index.js +66 -0
- package/dist/reference/tree-index.js.map +1 -0
- package/dist/reference/write-commit.d.ts +15 -0
- package/dist/reference/write-commit.js +44 -0
- package/dist/reference/write-commit.js.map +1 -0
- package/dist/rpc/commit-exists.d.ts +16 -0
- package/dist/rpc/commit-exists.js +30 -0
- package/dist/rpc/commit-exists.js.map +1 -0
- package/dist/rpc/commit.d.ts +172 -0
- package/dist/rpc/commit.js +115 -0
- package/dist/rpc/commit.js.map +1 -0
- package/dist/rpc/list-tree.d.ts +59 -0
- package/dist/rpc/list-tree.js +54 -0
- package/dist/rpc/list-tree.js.map +1 -0
- package/dist/rpc/log.d.ts +35 -0
- package/dist/rpc/log.js +41 -0
- package/dist/rpc/log.js.map +1 -0
- package/dist/rpc/mint-read-token.d.ts +17 -0
- package/dist/rpc/mint-read-token.js +36 -0
- package/dist/rpc/mint-read-token.js.map +1 -0
- package/dist/rpc/promote.d.ts +39 -0
- package/dist/rpc/promote.js +69 -0
- package/dist/rpc/promote.js.map +1 -0
- package/dist/rpc/read-file.d.ts +44 -0
- package/dist/rpc/read-file.js +56 -0
- package/dist/rpc/read-file.js.map +1 -0
- package/dist/rpc/repo-lifecycle.d.ts +39 -0
- package/dist/rpc/repo-lifecycle.js +64 -0
- package/dist/rpc/repo-lifecycle.js.map +1 -0
- package/dist/rpc/resolve-ref.d.ts +15 -0
- package/dist/rpc/resolve-ref.js +28 -0
- package/dist/rpc/resolve-ref.js.map +1 -0
- package/dist/rpc/sync-branch.d.ts +107 -0
- package/dist/rpc/sync-branch.js +114 -0
- package/dist/rpc/sync-branch.js.map +1 -0
- package/dist/schemas/commit-action.d.ts +100 -0
- package/dist/schemas/commit-action.js +138 -0
- package/dist/schemas/commit-action.js.map +1 -0
- package/dist/schemas/commit.d.ts +2 -0
- package/dist/schemas/commit.js +24 -0
- package/dist/schemas/commit.js.map +1 -0
- package/dist/schemas/content-encoding.d.ts +24 -0
- package/dist/schemas/content-encoding.js +41 -0
- package/dist/schemas/content-encoding.js.map +1 -0
- package/dist/schemas/examples.d.ts +38 -0
- package/dist/schemas/examples.js +32 -0
- package/dist/schemas/examples.js.map +1 -0
- package/dist/schemas/gateway-config.d.ts +2 -0
- package/dist/schemas/gateway-config.js +72 -0
- package/dist/schemas/gateway-config.js.map +1 -0
- package/dist/schemas/gateway-error-body.d.ts +2 -0
- package/dist/schemas/gateway-error-body.js +188 -0
- package/dist/schemas/gateway-error-body.js.map +1 -0
- package/dist/schemas/identity.d.ts +21 -0
- package/dist/schemas/identity.js +40 -0
- package/dist/schemas/identity.js.map +1 -0
- package/dist/schemas/names.d.ts +26 -0
- package/dist/schemas/names.js +58 -0
- package/dist/schemas/names.js.map +1 -0
- package/dist/schemas/ref-update.d.ts +10 -0
- package/dist/schemas/ref-update.js +25 -0
- package/dist/schemas/ref-update.js.map +1 -0
- package/dist/schemas/sha.d.ts +8 -0
- package/dist/schemas/sha.js +14 -0
- package/dist/schemas/sha.js.map +1 -0
- package/dist/schemas/tree-entry.d.ts +2 -0
- package/dist/schemas/tree-entry.js +62 -0
- package/dist/schemas/tree-entry.js.map +1 -0
- package/dist/storage/git-remote.d.ts +17 -0
- package/dist/storage/git-remote.js +31 -0
- package/dist/storage/git-remote.js.map +1 -0
- package/dist/storage/storage-backend.d.ts +61 -0
- package/dist/storage/storage-backend.js +0 -0
- package/dist/storage/storage-errors.d.ts +12 -0
- package/dist/storage/storage-errors.js +22 -0
- package/dist/storage/storage-errors.js.map +1 -0
- package/dist/storage/storage-input.d.ts +7 -0
- package/dist/storage/storage-input.js +14 -0
- package/dist/storage/storage-input.js.map +1 -0
- package/dist/storage/storage-read.d.ts +13 -0
- package/dist/storage/storage-read.js +30 -0
- package/dist/storage/storage-read.js.map +1 -0
- package/dist/storage/storage-repo-info.d.ts +16 -0
- package/dist/storage/storage-repo-info.js +30 -0
- package/dist/storage/storage-repo-info.js.map +1 -0
- package/dist/storage/storage-tree-entry.d.ts +21 -0
- package/dist/storage/storage-tree-entry.js +17 -0
- package/dist/storage/storage-tree-entry.js.map +1 -0
- package/dist/tree-entry-BM_1gou1.d.ts +41 -0
- package/dist/tree-index-Bk721Phv.d.ts +14 -0
- package/package.json +401 -4
- package/src/behaviour/assertions.ts +75 -0
- package/src/behaviour/behaviour-case.ts +28 -0
- package/src/behaviour/behaviour-suite.ts +76 -0
- package/src/behaviour/commit-action-cases.ts +253 -0
- package/src/behaviour/commit-write-cases.ts +205 -0
- package/src/behaviour/fixtures.ts +103 -0
- package/src/behaviour/lifecycle-cases.ts +104 -0
- package/src/behaviour/promote-cases.ts +78 -0
- package/src/behaviour/read-cases.ts +176 -0
- package/src/behaviour/sync-cases.ts +156 -0
- package/src/gateway-error.ts +72 -0
- package/src/git-gateway.ts +76 -0
- package/src/health.ts +26 -0
- package/src/package-name.ts +4 -0
- package/src/proxy/audit-event.ts +135 -0
- package/src/proxy/branch-rule.ts +190 -0
- package/src/proxy/gateway-hooks.ts +67 -0
- package/src/proxy/git-operation.ts +36 -0
- package/src/proxy/policy-result.ts +127 -0
- package/src/proxy/principal.ts +81 -0
- package/src/proxy/push-policy-result.ts +86 -0
- package/src/proxy/push-policy.ts +158 -0
- package/src/proxy/request-credential.ts +47 -0
- package/src/proxy/smart-http-config.ts +158 -0
- package/src/reference/apply-actions.ts +96 -0
- package/src/reference/branch-methods.ts +105 -0
- package/src/reference/bytes.ts +66 -0
- package/src/reference/clock.ts +19 -0
- package/src/reference/commit-method.ts +97 -0
- package/src/reference/file-map.ts +35 -0
- package/src/reference/hash.ts +25 -0
- package/src/reference/history.ts +78 -0
- package/src/reference/lifecycle-methods.ts +52 -0
- package/src/reference/read-methods.ts +87 -0
- package/src/reference/reference-gateway.ts +50 -0
- package/src/reference/repo-state.ts +83 -0
- package/src/reference/run-method.ts +25 -0
- package/src/reference/three-way-merge.ts +42 -0
- package/src/reference/trailer.ts +18 -0
- package/src/reference/tree-index.ts +65 -0
- package/src/reference/write-commit.ts +44 -0
- package/src/rpc/commit-exists.ts +46 -0
- package/src/rpc/commit.ts +156 -0
- package/src/rpc/list-tree.ts +78 -0
- package/src/rpc/log.ts +51 -0
- package/src/rpc/mint-read-token.ts +59 -0
- package/src/rpc/promote.ts +72 -0
- package/src/rpc/read-file.ts +75 -0
- package/src/rpc/repo-lifecycle.ts +103 -0
- package/src/rpc/resolve-ref.ts +41 -0
- package/src/rpc/sync-branch.ts +149 -0
- package/src/schemas/commit-action.ts +157 -0
- package/src/schemas/commit.ts +43 -0
- package/src/schemas/content-encoding.ts +58 -0
- package/src/schemas/examples.ts +24 -0
- package/src/schemas/gateway-config.ts +116 -0
- package/src/schemas/gateway-error-body.ts +230 -0
- package/src/schemas/identity.ts +57 -0
- package/src/schemas/names.ts +126 -0
- package/src/schemas/ref-update.ts +38 -0
- package/src/schemas/sha.ts +20 -0
- package/src/schemas/tree-entry.ts +72 -0
- package/src/storage/git-remote.ts +58 -0
- package/src/storage/storage-backend.ts +65 -0
- package/src/storage/storage-errors.ts +24 -0
- package/src/storage/storage-input.ts +14 -0
- package/src/storage/storage-read.ts +45 -0
- package/src/storage/storage-repo-info.ts +46 -0
- package/src/storage/storage-tree-entry.ts +20 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CommitExistsInput, CommitExistsOutput } from "./rpc/commit-exists.js";
|
|
2
|
+
import { CommitInput, CommitOutput } from "./rpc/commit.js";
|
|
3
|
+
import { ListTreeInput, ListTreeOutput } from "./rpc/list-tree.js";
|
|
4
|
+
import { LogInput, LogOutput } from "./rpc/log.js";
|
|
5
|
+
import { MintReadTokenInput, MintReadTokenOutput } from "./rpc/mint-read-token.js";
|
|
6
|
+
import { PromoteInput, PromoteOutput } from "./rpc/promote.js";
|
|
7
|
+
import { ReadFileInput, ReadFileOutput } from "./rpc/read-file.js";
|
|
8
|
+
import { CreateRepoInput, CreateRepoOutput, DeleteRepoInput, DeleteRepoOutput } from "./rpc/repo-lifecycle.js";
|
|
9
|
+
import { ResolveRefInput, ResolveRefOutput } from "./rpc/resolve-ref.js";
|
|
10
|
+
import { SyncBranchInput, SyncBranchOutput } from "./rpc/sync-branch.js";
|
|
11
|
+
// src/git-gateway.ts
|
|
12
|
+
/**
|
|
13
|
+
* The input and output schema of every RPC method. An implementation parses each input with its
|
|
14
|
+
* schema before acting and returns a value its output schema accepts; failures are thrown as
|
|
15
|
+
* {@link GatewayError}s.
|
|
16
|
+
*/
|
|
17
|
+
const RPC_SCHEMAS = {
|
|
18
|
+
commit: {
|
|
19
|
+
input: CommitInput,
|
|
20
|
+
output: CommitOutput
|
|
21
|
+
},
|
|
22
|
+
readFile: {
|
|
23
|
+
input: ReadFileInput,
|
|
24
|
+
output: ReadFileOutput
|
|
25
|
+
},
|
|
26
|
+
listTree: {
|
|
27
|
+
input: ListTreeInput,
|
|
28
|
+
output: ListTreeOutput
|
|
29
|
+
},
|
|
30
|
+
resolveRef: {
|
|
31
|
+
input: ResolveRefInput,
|
|
32
|
+
output: ResolveRefOutput
|
|
33
|
+
},
|
|
34
|
+
log: {
|
|
35
|
+
input: LogInput,
|
|
36
|
+
output: LogOutput
|
|
37
|
+
},
|
|
38
|
+
commitExists: {
|
|
39
|
+
input: CommitExistsInput,
|
|
40
|
+
output: CommitExistsOutput
|
|
41
|
+
},
|
|
42
|
+
syncBranch: {
|
|
43
|
+
input: SyncBranchInput,
|
|
44
|
+
output: SyncBranchOutput
|
|
45
|
+
},
|
|
46
|
+
promote: {
|
|
47
|
+
input: PromoteInput,
|
|
48
|
+
output: PromoteOutput
|
|
49
|
+
},
|
|
50
|
+
createRepo: {
|
|
51
|
+
input: CreateRepoInput,
|
|
52
|
+
output: CreateRepoOutput
|
|
53
|
+
},
|
|
54
|
+
deleteRepo: {
|
|
55
|
+
input: DeleteRepoInput,
|
|
56
|
+
output: DeleteRepoOutput
|
|
57
|
+
},
|
|
58
|
+
mintReadToken: {
|
|
59
|
+
input: MintReadTokenInput,
|
|
60
|
+
output: MintReadTokenOutput
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
export { RPC_SCHEMAS };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=git-gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-gateway.js","names":[],"sources":["../src/git-gateway.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport type { z } from 'zod';\n\nimport { CommitExistsInput, CommitExistsOutput } from './rpc/commit-exists.ts';\nimport { CommitInput, CommitOutput } from './rpc/commit.ts';\nimport { ListTreeInput, ListTreeOutput } from './rpc/list-tree.ts';\nimport { LogInput, LogOutput } from './rpc/log.ts';\nimport { MintReadTokenInput, MintReadTokenOutput } from './rpc/mint-read-token.ts';\nimport { PromoteInput, PromoteOutput } from './rpc/promote.ts';\nimport { ReadFileInput, ReadFileOutput } from './rpc/read-file.ts';\nimport {\n CreateRepoInput,\n CreateRepoOutput,\n DeleteRepoInput,\n DeleteRepoOutput,\n} from './rpc/repo-lifecycle.ts';\nimport { ResolveRefInput, ResolveRefOutput } from './rpc/resolve-ref.ts';\nimport { SyncBranchInput, SyncBranchOutput } from './rpc/sync-branch.ts';\n\n/**\n * The input and output schema of every RPC method. An implementation parses each input with its\n * schema before acting and returns a value its output schema accepts; failures are thrown as\n * {@link GatewayError}s.\n */\nexport const RPC_SCHEMAS = {\n commit: { input: CommitInput, output: CommitOutput },\n readFile: { input: ReadFileInput, output: ReadFileOutput },\n listTree: { input: ListTreeInput, output: ListTreeOutput },\n resolveRef: { input: ResolveRefInput, output: ResolveRefOutput },\n log: { input: LogInput, output: LogOutput },\n commitExists: { input: CommitExistsInput, output: CommitExistsOutput },\n syncBranch: { input: SyncBranchInput, output: SyncBranchOutput },\n promote: { input: PromoteInput, output: PromoteOutput },\n createRepo: { input: CreateRepoInput, output: CreateRepoOutput },\n deleteRepo: { input: DeleteRepoInput, output: DeleteRepoOutput },\n mintReadToken: { input: MintReadTokenInput, output: MintReadTokenOutput },\n} as const;\n\n/** The name of an RPC method. */\nexport type RpcMethod = keyof typeof RPC_SCHEMAS;\n\n/** What a caller passes to an RPC method (defaults optional). */\nexport type RpcInput<M extends RpcMethod> = z.input<(typeof RPC_SCHEMAS)[M]['input']>;\n/** What an implementation works with after parsing the input (defaults applied). */\nexport type RpcParsedInput<M extends RpcMethod> = z.output<(typeof RPC_SCHEMAS)[M]['input']>;\n/** What an RPC method resolves to. */\nexport type RpcOutput<M extends RpcMethod> = z.output<(typeof RPC_SCHEMAS)[M]['output']>;\n\n/**\n * The git-gateway RPC API, reached over a Workers service binding. Every method's signature is\n * the inferred type of its schemas in {@link RPC_SCHEMAS}; errors are thrown as GatewayErrors.\n */\nexport interface GitGateway {\n /** A multi-file commit to one branch, built without a clone; idempotent by key. */\n commit(input: RpcInput<'commit'>): Promise<RpcOutput<'commit'>>;\n /** One file at a branch or commit, or null when no file is at the path. */\n readFile(input: RpcInput<'readFile'>): Promise<RpcOutput<'readFile'>>;\n /** A directory listing at a branch or commit, or null when the path is not a directory. */\n listTree(input: RpcInput<'listTree'>): Promise<RpcOutput<'listTree'>>;\n /** The commit a branch names, or null when it does not exist. */\n resolveRef(input: RpcInput<'resolveRef'>): Promise<RpcOutput<'resolveRef'>>;\n /** A page of history reachable from a branch or commit. */\n log(input: RpcInput<'log'>): Promise<RpcOutput<'log'>>;\n /** Whether a commit exists, optionally reachable from a branch. */\n commitExists(input: RpcInput<'commitExists'>): Promise<RpcOutput<'commitExists'>>;\n /** Bring one branch up to date with another without rewriting it. */\n syncBranch(input: RpcInput<'syncBranch'>): Promise<RpcOutput<'syncBranch'>>;\n /** Fast-forward one branch to the head of another, never merging or forcing. */\n promote(input: RpcInput<'promote'>): Promise<RpcOutput<'promote'>>;\n /** Create an empty repository. */\n createRepo(input: RpcInput<'createRepo'>): Promise<RpcOutput<'createRepo'>>;\n /** Permanently delete a repository. */\n deleteRepo(input: RpcInput<'deleteRepo'>): Promise<RpcOutput<'deleteRepo'>>;\n /** A short-lived credential that can read one repository through the gateway. */\n mintReadToken(input: RpcInput<'mintReadToken'>): Promise<RpcOutput<'mintReadToken'>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAa,cAAc;CACzB,QAAQ;EAAE,OAAO;EAAa,QAAQ;CAAa;CACnD,UAAU;EAAE,OAAO;EAAe,QAAQ;CAAe;CACzD,UAAU;EAAE,OAAO;EAAe,QAAQ;CAAe;CACzD,YAAY;EAAE,OAAO;EAAiB,QAAQ;CAAiB;CAC/D,KAAK;EAAE,OAAO;EAAU,QAAQ;CAAU;CAC1C,cAAc;EAAE,OAAO;EAAmB,QAAQ;CAAmB;CACrE,YAAY;EAAE,OAAO;EAAiB,QAAQ;CAAiB;CAC/D,SAAS;EAAE,OAAO;EAAc,QAAQ;CAAc;CACtD,YAAY;EAAE,OAAO;EAAiB,QAAQ;CAAiB;CAC/D,YAAY;EAAE,OAAO;EAAiB,QAAQ;CAAiB;CAC/D,eAAe;EAAE,OAAO;EAAoB,QAAQ;CAAoB;AAC1E"}
|
package/dist/health.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Body of `GET /health`. */
|
|
3
|
+
export declare const HealthResponse: z.ZodObject<{
|
|
4
|
+
status: z.ZodLiteral<"ok">;
|
|
5
|
+
service: z.ZodString;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
/** Body of `GET /health`, inferred from {@link HealthResponse}. */
|
|
8
|
+
export type HealthResponse = z.infer<typeof HealthResponse>;
|
|
9
|
+
//# sourceMappingURL=health.d.ts.map
|
package/dist/health.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// src/health.ts
|
|
3
|
+
/** Body of `GET /health`. */
|
|
4
|
+
const HealthResponse = z.object({
|
|
5
|
+
status: z.literal("ok").describe("Always \"ok\": the gateway Worker is up and routing requests."),
|
|
6
|
+
service: z.string().min(1).max(64).describe("Name of the deployment answering, 1–64 characters; \"git-gateway\" unless the deployment names itself.")
|
|
7
|
+
}).strict().meta({
|
|
8
|
+
id: "HealthResponse",
|
|
9
|
+
title: "Health response",
|
|
10
|
+
description: "Body of GET /health. Returned with status 200 whenever the Worker is serving; it does not probe storage backends.",
|
|
11
|
+
examples: [{
|
|
12
|
+
status: "ok",
|
|
13
|
+
service: "git-gateway"
|
|
14
|
+
}]
|
|
15
|
+
});
|
|
16
|
+
export { HealthResponse };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","names":[],"sources":["../src/health.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\n/** Body of `GET /health`. */\nexport const HealthResponse = z\n .object({\n status: z.literal('ok').describe('Always \"ok\": the gateway Worker is up and routing requests.'),\n service: z\n .string()\n .min(1)\n .max(64)\n .describe(\n 'Name of the deployment answering, 1–64 characters; \"git-gateway\" unless the deployment names itself.',\n ),\n })\n .strict()\n .meta({\n id: 'HealthResponse',\n title: 'Health response',\n description:\n 'Body of GET /health. Returned with status 200 whenever the Worker is serving; it does not probe storage backends.',\n examples: [{ status: 'ok', service: 'git-gateway' }],\n });\n\n/** Body of `GET /health`, inferred from {@link HealthResponse}. */\nexport type HealthResponse = z.infer<typeof HealthResponse>;\n"],"mappings":";;;AAIA,MAAa,iBAAiB,EAC3B,OAAO;CACN,QAAQ,EAAE,QAAQ,IAAI,CAAC,CAAC,SAAS,+DAA6D;CAC9F,SAAS,EACN,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,EAAE,CAAC,CACP,SACC,wGACF;AACJ,CAAC,CAAC,CACD,OAAO,CAAC,CACR,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CAAC;EAAE,QAAQ;EAAM,SAAS;CAAc,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as Commit } from "./commit-BEZmeAOl.js";
|
|
2
|
+
/** Looks up a stored commit by id. */
|
|
3
|
+
type CommitLookup = (sha: string) => Commit | undefined;
|
|
4
|
+
/** Every commit reachable from `start`, itself included. */
|
|
5
|
+
declare function ancestors(lookup: CommitLookup, start: string): Set<string>;
|
|
6
|
+
/** True when `ancestor` is reachable from `descendant` (a commit contains itself). */
|
|
7
|
+
declare function contains(lookup: CommitLookup, descendant: string, ancestor: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* History reachable from `start`, newest committer date first, never listing a commit before
|
|
10
|
+
* one of its children; ties go to the commit discovered last (as git log does).
|
|
11
|
+
*/
|
|
12
|
+
declare function walkHistory(lookup: CommitLookup, start: string): Commit[];
|
|
13
|
+
/**
|
|
14
|
+
* The best common ancestor of two commits: a common ancestor no other common ancestor descends
|
|
15
|
+
* from. When several qualify (criss-cross history) the newest by committer date wins, then the
|
|
16
|
+
* lowest id. Null when the histories are unrelated.
|
|
17
|
+
*/
|
|
18
|
+
declare function mergeBase(lookup: CommitLookup, a: string, b: string): string | null;
|
|
19
|
+
export { walkHistory as a, mergeBase as i, ancestors as n, contains as r, CommitLookup as t };
|
|
20
|
+
//# sourceMappingURL=history-CqvHaUE-.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-name.js","names":[],"sources":["../src/package-name.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/** The npm name this package is published under. */\nexport const packageName = '@leed-ai/git-gateway-contract' as const;\n"],"mappings":";;AAGA,MAAa,cAAc"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** A request id: opaque, safe to log. */
|
|
3
|
+
export declare const RequestId: z.ZodString;
|
|
4
|
+
/** A request id, inferred from {@link RequestId}. */
|
|
5
|
+
export type RequestId = z.infer<typeof RequestId>;
|
|
6
|
+
/** The outcome of one ref update of a push, as far as the gateway knows it. */
|
|
7
|
+
export declare const AuditRefOutcome: z.ZodObject<{
|
|
8
|
+
ref: z.ZodString;
|
|
9
|
+
oldSha: z.ZodString;
|
|
10
|
+
newSha: z.ZodString;
|
|
11
|
+
status: z.ZodEnum<{
|
|
12
|
+
ok: "ok";
|
|
13
|
+
rejected: "rejected";
|
|
14
|
+
unknown: "unknown";
|
|
15
|
+
}>;
|
|
16
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
/** An audited ref update, inferred from {@link AuditRefOutcome}. */
|
|
19
|
+
export type AuditRefOutcome = z.infer<typeof AuditRefOutcome>;
|
|
20
|
+
/** One authenticated smart-HTTP operation, as handed to the audit hook. */
|
|
21
|
+
export declare const AuditEvent: z.ZodObject<{
|
|
22
|
+
requestId: z.ZodString;
|
|
23
|
+
at: z.ZodISODateTime;
|
|
24
|
+
principal: z.ZodObject<{
|
|
25
|
+
subject: z.ZodString;
|
|
26
|
+
name: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
email: z.ZodDefault<z.ZodNullable<z.ZodEmail>>;
|
|
28
|
+
roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
29
|
+
expiresAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
repo: z.ZodString;
|
|
32
|
+
operation: z.ZodEnum<{
|
|
33
|
+
read: "read";
|
|
34
|
+
write: "write";
|
|
35
|
+
}>;
|
|
36
|
+
endpoint: z.ZodEnum<{
|
|
37
|
+
"info-refs": "info-refs";
|
|
38
|
+
"receive-pack": "receive-pack";
|
|
39
|
+
"upload-pack": "upload-pack";
|
|
40
|
+
}>;
|
|
41
|
+
outcome: z.ZodEnum<{
|
|
42
|
+
allowed: "allowed";
|
|
43
|
+
denied: "denied";
|
|
44
|
+
failed: "failed";
|
|
45
|
+
}>;
|
|
46
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
47
|
+
refs: z.ZodArray<z.ZodObject<{
|
|
48
|
+
ref: z.ZodString;
|
|
49
|
+
oldSha: z.ZodString;
|
|
50
|
+
newSha: z.ZodString;
|
|
51
|
+
status: z.ZodEnum<{
|
|
52
|
+
ok: "ok";
|
|
53
|
+
rejected: "rejected";
|
|
54
|
+
unknown: "unknown";
|
|
55
|
+
}>;
|
|
56
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
57
|
+
}, z.core.$strict>>;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
/** An audit event, inferred from {@link AuditEvent}. */
|
|
60
|
+
export type AuditEvent = z.infer<typeof AuditEvent>;
|
|
61
|
+
//# sourceMappingURL=audit-event.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Timestamp } from "../schemas/identity.js";
|
|
2
|
+
import { RepoName } from "../schemas/names.js";
|
|
3
|
+
import { Sha } from "../schemas/sha.js";
|
|
4
|
+
import { GitOperation, SmartHttpEndpoint } from "./git-operation.js";
|
|
5
|
+
import { Principal } from "./principal.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
// src/proxy/audit-event.ts
|
|
8
|
+
/** A request id: opaque, safe to log. */
|
|
9
|
+
const RequestId = z.string().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/).meta({
|
|
10
|
+
id: "RequestId",
|
|
11
|
+
title: "Request id",
|
|
12
|
+
description: "Identifies one request in logs, audit events and the X-Request-Id response header: 1–128 characters of letters, digits, \".\", \"_\", \":\" and \"-\". The Cloudflare Ray id when there is one, otherwise a random UUID.",
|
|
13
|
+
examples: ["8f1c2d3e4a5b6c7d-LHR", "6f1d2c3b-9a8e-4f7d-b6c5-a4e3d2c1b0a9"]
|
|
14
|
+
});
|
|
15
|
+
/** The outcome of one ref update of a push, as far as the gateway knows it. */
|
|
16
|
+
const AuditRefOutcome = z.object({
|
|
17
|
+
ref: z.string().min(6).max(4096).regex(/^refs\/[^\n\0]+$/).describe("The ref the update command named, fully qualified; any namespace, since refused ones are audited too."),
|
|
18
|
+
oldSha: Sha.describe("Id the client said the ref named; all zeros when it asked to create the ref."),
|
|
19
|
+
newSha: Sha.describe("Id the client asked the ref to name; all zeros when it asked to delete the ref."),
|
|
20
|
+
status: z.enum([
|
|
21
|
+
"ok",
|
|
22
|
+
"rejected",
|
|
23
|
+
"unknown"
|
|
24
|
+
]).meta({
|
|
25
|
+
description: "What happened to the ref.",
|
|
26
|
+
enumDescriptions: {
|
|
27
|
+
ok: "The storage host reported the ref updated.",
|
|
28
|
+
rejected: "The gateway or the storage host refused the update; `reason` says why.",
|
|
29
|
+
unknown: "The push was forwarded but the storage host report could not be read."
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
reason: z.string().min(1).max(1e3).nullable().describe("Why the update was refused, as git was told; null unless `status` is \"rejected\".")
|
|
33
|
+
}).strict().meta({
|
|
34
|
+
id: "AuditRefOutcome",
|
|
35
|
+
title: "Audited ref update",
|
|
36
|
+
description: "One update command of an audited push and what became of it.",
|
|
37
|
+
examples: [{
|
|
38
|
+
ref: "refs/heads/main",
|
|
39
|
+
oldSha: "1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d",
|
|
40
|
+
newSha: "8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a",
|
|
41
|
+
status: "rejected",
|
|
42
|
+
reason: "main is protected"
|
|
43
|
+
}]
|
|
44
|
+
});
|
|
45
|
+
/** One authenticated smart-HTTP operation, as handed to the audit hook. */
|
|
46
|
+
const AuditEvent = z.object({
|
|
47
|
+
requestId: RequestId.describe("The request this event records."),
|
|
48
|
+
at: Timestamp.describe("When the gateway finished deciding and forwarding the request."),
|
|
49
|
+
principal: Principal.describe("Who made the request (never the credential)."),
|
|
50
|
+
repo: RepoName.describe("The repository the request named."),
|
|
51
|
+
operation: GitOperation.describe("Whether the request reads or writes the repository."),
|
|
52
|
+
endpoint: SmartHttpEndpoint.describe("Which smart-HTTP endpoint the request reached."),
|
|
53
|
+
outcome: z.enum([
|
|
54
|
+
"allowed",
|
|
55
|
+
"denied",
|
|
56
|
+
"failed"
|
|
57
|
+
]).meta({
|
|
58
|
+
description: "What the gateway did with the request.",
|
|
59
|
+
enumDescriptions: {
|
|
60
|
+
allowed: "Authorized and forwarded to storage; for a push, `refs` says what storage did with each ref.",
|
|
61
|
+
denied: "Refused by the authorizer or the branch policy; nothing reached storage.",
|
|
62
|
+
failed: "Authorized, but the gateway or the storage host failed before an answer was complete."
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
reason: z.string().min(1).max(1e3).nullable().describe("Why the request was denied or failed, as the client was told; null when it was allowed."),
|
|
66
|
+
refs: z.array(AuditRefOutcome).max(1e4).describe("For a push (receive-pack), every update command and its outcome; empty for every other request.")
|
|
67
|
+
}).strict().meta({
|
|
68
|
+
id: "AuditEvent",
|
|
69
|
+
title: "Audit event",
|
|
70
|
+
description: "Handed to the audit hook for every authenticated smart-HTTP request once it is decided: principal, repository, operation, refs and outcome. Never contains a credential.",
|
|
71
|
+
examples: [{
|
|
72
|
+
requestId: "6f1d2c3b-9a8e-4f7d-b6c5-a4e3d2c1b0a9",
|
|
73
|
+
at: "2026-11-20T09:30:00.000Z",
|
|
74
|
+
principal: {
|
|
75
|
+
subject: "user:42",
|
|
76
|
+
name: null,
|
|
77
|
+
email: null,
|
|
78
|
+
roles: ["editor"],
|
|
79
|
+
expiresAt: null
|
|
80
|
+
},
|
|
81
|
+
repo: "acme-raw-content",
|
|
82
|
+
operation: "write",
|
|
83
|
+
endpoint: "receive-pack",
|
|
84
|
+
outcome: "denied",
|
|
85
|
+
reason: "main is protected",
|
|
86
|
+
refs: [{
|
|
87
|
+
ref: "refs/heads/main",
|
|
88
|
+
oldSha: "1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d",
|
|
89
|
+
newSha: "8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a",
|
|
90
|
+
status: "rejected",
|
|
91
|
+
reason: "main is protected"
|
|
92
|
+
}]
|
|
93
|
+
}]
|
|
94
|
+
});
|
|
95
|
+
export { AuditEvent, AuditRefOutcome, RequestId };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=audit-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-event.js","names":[],"sources":["../../src/proxy/audit-event.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\nimport { Timestamp } from '../schemas/identity.ts';\nimport { RepoName } from '../schemas/names.ts';\nimport { Sha } from '../schemas/sha.ts';\nimport { GitOperation, SmartHttpEndpoint } from './git-operation.ts';\nimport { Principal } from './principal.ts';\n\n/** A request id: opaque, safe to log. */\nexport const RequestId = z\n .string()\n .min(1)\n .max(128)\n .regex(/^[A-Za-z0-9._:-]+$/)\n .meta({\n id: 'RequestId',\n title: 'Request id',\n description:\n 'Identifies one request in logs, audit events and the X-Request-Id response header: 1–128 characters of letters, digits, \".\", \"_\", \":\" and \"-\". The Cloudflare Ray id when there is one, otherwise a random UUID.',\n examples: ['8f1c2d3e4a5b6c7d-LHR', '6f1d2c3b-9a8e-4f7d-b6c5-a4e3d2c1b0a9'],\n });\n\n/** A request id, inferred from {@link RequestId}. */\nexport type RequestId = z.infer<typeof RequestId>;\n\n/** The outcome of one ref update of a push, as far as the gateway knows it. */\nexport const AuditRefOutcome = z\n .object({\n ref: z\n .string()\n .min(6)\n .max(4096)\n .regex(/^refs\\/[^\\n\\0]+$/)\n .describe(\n 'The ref the update command named, fully qualified; any namespace, since refused ones are audited too.',\n ),\n oldSha: Sha.describe('Id the client said the ref named; all zeros when it asked to create the ref.'),\n newSha: Sha.describe('Id the client asked the ref to name; all zeros when it asked to delete the ref.'),\n status: z.enum(['ok', 'rejected', 'unknown']).meta({\n description: 'What happened to the ref.',\n enumDescriptions: {\n ok: 'The storage host reported the ref updated.',\n rejected: 'The gateway or the storage host refused the update; `reason` says why.',\n unknown: 'The push was forwarded but the storage host report could not be read.',\n },\n }),\n reason: z\n .string()\n .min(1)\n .max(1000)\n .nullable()\n .describe('Why the update was refused, as git was told; null unless `status` is \"rejected\".'),\n })\n .strict()\n .meta({\n id: 'AuditRefOutcome',\n title: 'Audited ref update',\n description: 'One update command of an audited push and what became of it.',\n examples: [\n {\n ref: 'refs/heads/main',\n oldSha: '1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d',\n newSha: '8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a',\n status: 'rejected',\n reason: 'main is protected',\n },\n ],\n });\n\n/** An audited ref update, inferred from {@link AuditRefOutcome}. */\nexport type AuditRefOutcome = z.infer<typeof AuditRefOutcome>;\n\n/** One authenticated smart-HTTP operation, as handed to the audit hook. */\nexport const AuditEvent = z\n .object({\n requestId: RequestId.describe('The request this event records.'),\n at: Timestamp.describe('When the gateway finished deciding and forwarding the request.'),\n principal: Principal.describe('Who made the request (never the credential).'),\n repo: RepoName.describe('The repository the request named.'),\n operation: GitOperation.describe('Whether the request reads or writes the repository.'),\n endpoint: SmartHttpEndpoint.describe('Which smart-HTTP endpoint the request reached.'),\n outcome: z.enum(['allowed', 'denied', 'failed']).meta({\n description: 'What the gateway did with the request.',\n enumDescriptions: {\n allowed:\n 'Authorized and forwarded to storage; for a push, `refs` says what storage did with each ref.',\n denied: 'Refused by the authorizer or the branch policy; nothing reached storage.',\n failed: 'Authorized, but the gateway or the storage host failed before an answer was complete.',\n },\n }),\n reason: z\n .string()\n .min(1)\n .max(1000)\n .nullable()\n .describe('Why the request was denied or failed, as the client was told; null when it was allowed.'),\n refs: z\n .array(AuditRefOutcome)\n .max(10_000)\n .describe(\n 'For a push (receive-pack), every update command and its outcome; empty for every other request.',\n ),\n })\n .strict()\n .meta({\n id: 'AuditEvent',\n title: 'Audit event',\n description:\n 'Handed to the audit hook for every authenticated smart-HTTP request once it is decided: principal, repository, operation, refs and outcome. Never contains a credential.',\n examples: [\n {\n requestId: '6f1d2c3b-9a8e-4f7d-b6c5-a4e3d2c1b0a9',\n at: '2026-11-20T09:30:00.000Z',\n principal: { subject: 'user:42', name: null, email: null, roles: ['editor'], expiresAt: null },\n repo: 'acme-raw-content',\n operation: 'write',\n endpoint: 'receive-pack',\n outcome: 'denied',\n reason: 'main is protected',\n refs: [\n {\n ref: 'refs/heads/main',\n oldSha: '1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d',\n newSha: '8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a',\n status: 'rejected',\n reason: 'main is protected',\n },\n ],\n },\n ],\n });\n\n/** An audit event, inferred from {@link AuditEvent}. */\nexport type AuditEvent = z.infer<typeof AuditEvent>;\n"],"mappings":";;;;;;;;AAUA,MAAa,YAAY,EACtB,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,MAAM,oBAAoB,CAAC,CAC3B,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CAAC,wBAAwB,sCAAsC;AAC3E,CAAC;;AAMH,MAAa,kBAAkB,EAC5B,OAAO;CACN,KAAK,EACF,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,IAAI,CAAC,CACT,MAAM,kBAAkB,CAAC,CACzB,SACC,uGACF;CACF,QAAQ,IAAI,SAAS,8EAA8E;CACnG,QAAQ,IAAI,SAAS,iFAAiF;CACtG,QAAQ,EAAE,KAAK;EAAC;EAAM;EAAY;CAAS,CAAC,CAAC,CAAC,KAAK;EACjD,aAAa;EACb,kBAAkB;GAChB,IAAI;GACJ,UAAU;GACV,SAAS;EACX;CACF,CAAC;CACD,QAAQ,EACL,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,GAAI,CAAC,CACT,SAAS,CAAC,CACV,SAAS,oFAAkF;AAChG,CAAC,CAAC,CACD,OAAO,CAAC,CACR,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aAAa;CACb,UAAU,CACR;EACE,KAAK;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;CACV,CACF;AACF,CAAC;;AAMH,MAAa,aAAa,EACvB,OAAO;CACN,WAAW,UAAU,SAAS,iCAAiC;CAC/D,IAAI,UAAU,SAAS,gEAAgE;CACvF,WAAW,UAAU,SAAS,8CAA8C;CAC5E,MAAM,SAAS,SAAS,mCAAmC;CAC3D,WAAW,aAAa,SAAS,qDAAqD;CACtF,UAAU,kBAAkB,SAAS,gDAAgD;CACrF,SAAS,EAAE,KAAK;EAAC;EAAW;EAAU;CAAQ,CAAC,CAAC,CAAC,KAAK;EACpD,aAAa;EACb,kBAAkB;GAChB,SACE;GACF,QAAQ;GACR,QAAQ;EACV;CACF,CAAC;CACD,QAAQ,EACL,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,GAAI,CAAC,CACT,SAAS,CAAC,CACV,SAAS,yFAAyF;CACrG,MAAM,EACH,MAAM,eAAe,CAAC,CACtB,IAAI,GAAM,CAAC,CACX,SACC,iGACF;AACJ,CAAC,CAAC,CACD,OAAO,CAAC,CACR,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CACR;EACE,WAAW;EACX,IAAI;EACJ,WAAW;GAAE,SAAS;GAAW,MAAM;GAAM,OAAO;GAAM,OAAO,CAAC,QAAQ;GAAG,WAAW;EAAK;EAC7F,MAAM;EACN,WAAW;EACX,UAAU;EACV,SAAS;EACT,QAAQ;EACR,MAAM,CACJ;GACE,KAAK;GACL,QAAQ;GACR,QAAQ;GACR,QAAQ;GACR,QAAQ;EACV,CACF;CACF,CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** A glob over fully qualified branch or tag refs. */
|
|
3
|
+
export declare const RefPattern: z.ZodString;
|
|
4
|
+
/** A ref glob, inferred from {@link RefPattern}. */
|
|
5
|
+
export type RefPattern = z.infer<typeof RefPattern>;
|
|
6
|
+
/** Which principals a rule lets push. */
|
|
7
|
+
export declare const PrincipalSelector: z.ZodObject<{
|
|
8
|
+
subjects: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
9
|
+
roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
/** A principal selector as written (defaults optional). */
|
|
12
|
+
export type PrincipalSelectorInput = z.input<typeof PrincipalSelector>;
|
|
13
|
+
/** A principal selector, inferred from {@link PrincipalSelector}. */
|
|
14
|
+
export type PrincipalSelector = z.output<typeof PrincipalSelector>;
|
|
15
|
+
/** What the rule-based branch policy allows on refs no rule matches. */
|
|
16
|
+
export declare const BranchPermissions: z.ZodObject<{
|
|
17
|
+
pushers: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
18
|
+
subjects: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
19
|
+
roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
20
|
+
}, z.core.$strict>>>;
|
|
21
|
+
create: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
+
delete: z.ZodDefault<z.ZodBoolean>;
|
|
23
|
+
forcePush: z.ZodDefault<z.ZodBoolean>;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
/** Branch permissions as written (defaults optional). */
|
|
26
|
+
export type BranchPermissionsInput = z.input<typeof BranchPermissions>;
|
|
27
|
+
/** Branch permissions, inferred from {@link BranchPermissions}. */
|
|
28
|
+
export type BranchPermissions = z.output<typeof BranchPermissions>;
|
|
29
|
+
/** One rule of the rule-based branch policy. */
|
|
30
|
+
export declare const BranchRule: z.ZodObject<{
|
|
31
|
+
pattern: z.ZodString;
|
|
32
|
+
pushers: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
33
|
+
subjects: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
34
|
+
roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
35
|
+
}, z.core.$strict>>>;
|
|
36
|
+
create: z.ZodDefault<z.ZodBoolean>;
|
|
37
|
+
delete: z.ZodDefault<z.ZodBoolean>;
|
|
38
|
+
forcePush: z.ZodDefault<z.ZodBoolean>;
|
|
39
|
+
message: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
/** A branch rule as written (defaults optional). */
|
|
42
|
+
export type BranchRuleInput = z.input<typeof BranchRule>;
|
|
43
|
+
/** A branch rule, inferred from {@link BranchRule}. */
|
|
44
|
+
export type BranchRule = z.output<typeof BranchRule>;
|
|
45
|
+
/** Configuration of the rule-based branch policy. */
|
|
46
|
+
export declare const BranchPolicyConfig: z.ZodObject<{
|
|
47
|
+
rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
48
|
+
pattern: z.ZodString;
|
|
49
|
+
pushers: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
50
|
+
subjects: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
51
|
+
roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
52
|
+
}, z.core.$strict>>>;
|
|
53
|
+
create: z.ZodDefault<z.ZodBoolean>;
|
|
54
|
+
delete: z.ZodDefault<z.ZodBoolean>;
|
|
55
|
+
forcePush: z.ZodDefault<z.ZodBoolean>;
|
|
56
|
+
message: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
57
|
+
}, z.core.$strict>>>;
|
|
58
|
+
fallback: z.ZodDefault<z.ZodObject<{
|
|
59
|
+
pushers: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
60
|
+
subjects: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
61
|
+
roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
62
|
+
}, z.core.$strict>>>;
|
|
63
|
+
create: z.ZodDefault<z.ZodBoolean>;
|
|
64
|
+
delete: z.ZodDefault<z.ZodBoolean>;
|
|
65
|
+
forcePush: z.ZodDefault<z.ZodBoolean>;
|
|
66
|
+
}, z.core.$strict>>;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
/** A branch policy configuration as written (defaults optional). */
|
|
69
|
+
export type BranchPolicyConfigInput = z.input<typeof BranchPolicyConfig>;
|
|
70
|
+
/** A branch policy configuration, inferred from {@link BranchPolicyConfig}. */
|
|
71
|
+
export type BranchPolicyConfig = z.output<typeof BranchPolicyConfig>;
|
|
72
|
+
//# sourceMappingURL=branch-rule.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Role } from "./principal.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/proxy/branch-rule.ts
|
|
4
|
+
/** A glob over fully qualified branch or tag refs. */
|
|
5
|
+
const RefPattern = z.string().min(12).max(266).regex(new RegExp(String.raw`^refs/(?:heads|tags)/(?!.*\.\.)(?!.*//)(?!.*/$)(?!.*\*{3})[^\x00-\x20\x7f~^:?[\\]+$`)).meta({
|
|
6
|
+
id: "RefPattern",
|
|
7
|
+
title: "Ref pattern",
|
|
8
|
+
description: "A glob matched against a whole fully qualified ref under refs/heads/ or refs/tags/: \"*\" matches any run of characters inside one path component (never \"/\"), \"**\" matches any run including \"/\", everything else matches itself. No \"..\", \"//\", trailing \"/\", whitespace, control characters, ~ ^ : ? [ or backslash; 12–266 characters.",
|
|
9
|
+
examples: [
|
|
10
|
+
"refs/heads/main",
|
|
11
|
+
"refs/heads/release/*",
|
|
12
|
+
"refs/tags/**"
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
const subjectName = z.string().min(1).max(255).regex(/^[^\n\0]+$/).describe("A principal subject, compared exactly with Principal.subject.");
|
|
16
|
+
/** Which principals a rule lets push. */
|
|
17
|
+
const PrincipalSelector = z.object({
|
|
18
|
+
subjects: z.array(subjectName).max(1e3).default([]).describe("Principals named by subject; at most 1000, default none."),
|
|
19
|
+
roles: z.array(Role).max(100).default([]).describe("Principals holding any of these roles; at most 100, default none.")
|
|
20
|
+
}).strict().meta({
|
|
21
|
+
id: "PrincipalSelector",
|
|
22
|
+
title: "Principal selector",
|
|
23
|
+
description: "Selects principals by subject or role: a principal matches when its subject is listed or it holds any listed role. With both lists empty it matches nobody.",
|
|
24
|
+
examples: [{
|
|
25
|
+
subjects: ["user:42"],
|
|
26
|
+
roles: ["maintainer"]
|
|
27
|
+
}]
|
|
28
|
+
});
|
|
29
|
+
const pushers = PrincipalSelector.nullable().default(null).describe("Who may update matching refs at all; null (the default) lets every principal the Authorizer allowed to write.");
|
|
30
|
+
/** What the rule-based branch policy allows on refs no rule matches. */
|
|
31
|
+
const BranchPermissions = z.object({
|
|
32
|
+
pushers,
|
|
33
|
+
create: z.boolean().default(true).describe("Whether a push may create a ref; default true."),
|
|
34
|
+
delete: z.boolean().default(true).describe("Whether a push may delete a ref; default true."),
|
|
35
|
+
forcePush: z.boolean().default(false).describe("Whether a push may move a branch to a commit that does not contain its current head (a non-fast-forward, \"git push --force\") or move an existing tag; default false.")
|
|
36
|
+
}).strict().meta({
|
|
37
|
+
id: "BranchPermissions",
|
|
38
|
+
title: "Branch permissions",
|
|
39
|
+
description: "What the rule-based branch policy allows on a ref no rule matches. Defaults: anyone with write access, create and delete allowed, force pushes refused.",
|
|
40
|
+
examples: [{
|
|
41
|
+
pushers: null,
|
|
42
|
+
create: true,
|
|
43
|
+
delete: true,
|
|
44
|
+
forcePush: false
|
|
45
|
+
}]
|
|
46
|
+
});
|
|
47
|
+
/** One rule of the rule-based branch policy. */
|
|
48
|
+
const BranchRule = z.object({
|
|
49
|
+
pattern: RefPattern.describe("The refs this rule governs."),
|
|
50
|
+
pushers,
|
|
51
|
+
create: z.boolean().default(true).describe("Whether a push may create a matching ref; default true."),
|
|
52
|
+
delete: z.boolean().default(false).describe("Whether a push may delete a matching ref; default false (rules usually protect)."),
|
|
53
|
+
forcePush: z.boolean().default(false).describe("Whether a push may move a matching branch to a commit that does not contain its current head, or move a matching tag; default false."),
|
|
54
|
+
message: z.string().min(1).max(200).regex(/^[^\n\0]+$/).nullable().default(null).describe("Text git shows the user when this rule refuses an update, e.g. \"main is protected\"; one line of 1–200 characters. Null (the default) uses a message naming the ref and what was refused.")
|
|
55
|
+
}).strict().meta({
|
|
56
|
+
id: "BranchRule",
|
|
57
|
+
title: "Branch rule",
|
|
58
|
+
description: "Governs the refs matching `pattern`: who may push them, whether they may be created or deleted, and whether force pushes are allowed. Rules are tried in order and the first match decides.",
|
|
59
|
+
examples: [{
|
|
60
|
+
pattern: "refs/heads/main",
|
|
61
|
+
pushers: {
|
|
62
|
+
subjects: [],
|
|
63
|
+
roles: ["maintainer"]
|
|
64
|
+
},
|
|
65
|
+
create: true,
|
|
66
|
+
delete: false,
|
|
67
|
+
forcePush: false,
|
|
68
|
+
message: "main is protected"
|
|
69
|
+
}]
|
|
70
|
+
});
|
|
71
|
+
/** Configuration of the rule-based branch policy. */
|
|
72
|
+
const BranchPolicyConfig = z.object({
|
|
73
|
+
rules: z.array(BranchRule).max(200).default([]).describe("Rules tried in order; the first whose pattern matches a ref decides it. At most 200, default none."),
|
|
74
|
+
fallback: BranchPermissions.default({
|
|
75
|
+
pushers: null,
|
|
76
|
+
create: true,
|
|
77
|
+
delete: true,
|
|
78
|
+
forcePush: false
|
|
79
|
+
}).describe("What applies to a branch or tag ref no rule matches; default anyone with write access, create and delete allowed, force refused.")
|
|
80
|
+
}).strict().meta({
|
|
81
|
+
id: "BranchPolicyConfig",
|
|
82
|
+
title: "Branch policy configuration",
|
|
83
|
+
description: "Configuration of the reference rule-based BranchPolicy. Refs outside refs/heads/ and refs/tags/ are always refused, whatever the rules say.",
|
|
84
|
+
examples: [{
|
|
85
|
+
rules: [{
|
|
86
|
+
pattern: "refs/heads/main",
|
|
87
|
+
pushers: {
|
|
88
|
+
subjects: [],
|
|
89
|
+
roles: ["maintainer"]
|
|
90
|
+
},
|
|
91
|
+
create: true,
|
|
92
|
+
delete: false,
|
|
93
|
+
forcePush: false,
|
|
94
|
+
message: "main is protected"
|
|
95
|
+
}],
|
|
96
|
+
fallback: {
|
|
97
|
+
pushers: null,
|
|
98
|
+
create: true,
|
|
99
|
+
delete: true,
|
|
100
|
+
forcePush: false
|
|
101
|
+
}
|
|
102
|
+
}]
|
|
103
|
+
});
|
|
104
|
+
export { BranchPermissions, BranchPolicyConfig, BranchRule, PrincipalSelector, RefPattern };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=branch-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-rule.js","names":[],"sources":["../../src/proxy/branch-rule.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\nimport { Role } from './principal.ts';\n\n/** A glob over fully qualified branch or tag refs. */\nexport const RefPattern = z\n .string()\n .min(12)\n .max(266)\n .regex(\n new RegExp(\n String.raw`^refs/(?:heads|tags)/(?!.*\\.\\.)(?!.*//)(?!.*/$)(?!.*\\*{3})[^\\x00-\\x20\\x7f~^:?[\\\\]+$`,\n ),\n )\n .meta({\n id: 'RefPattern',\n title: 'Ref pattern',\n description:\n 'A glob matched against a whole fully qualified ref under refs/heads/ or refs/tags/: \"*\" matches any run of characters inside one path component (never \"/\"), \"**\" matches any run including \"/\", everything else matches itself. No \"..\", \"//\", trailing \"/\", whitespace, control characters, ~ ^ : ? [ or backslash; 12–266 characters.',\n examples: ['refs/heads/main', 'refs/heads/release/*', 'refs/tags/**'],\n });\n\n/** A ref glob, inferred from {@link RefPattern}. */\nexport type RefPattern = z.infer<typeof RefPattern>;\n\nconst subjectName = z\n .string()\n .min(1)\n .max(255)\n .regex(/^[^\\n\\0]+$/)\n .describe('A principal subject, compared exactly with Principal.subject.');\n\n/** Which principals a rule lets push. */\nexport const PrincipalSelector = z\n .object({\n subjects: z\n .array(subjectName)\n .max(1000)\n .default([])\n .describe('Principals named by subject; at most 1000, default none.'),\n roles: z\n .array(Role)\n .max(100)\n .default([])\n .describe('Principals holding any of these roles; at most 100, default none.'),\n })\n .strict()\n .meta({\n id: 'PrincipalSelector',\n title: 'Principal selector',\n description:\n 'Selects principals by subject or role: a principal matches when its subject is listed or it holds any listed role. With both lists empty it matches nobody.',\n examples: [{ subjects: ['user:42'], roles: ['maintainer'] }],\n });\n\n/** A principal selector as written (defaults optional). */\nexport type PrincipalSelectorInput = z.input<typeof PrincipalSelector>;\n/** A principal selector, inferred from {@link PrincipalSelector}. */\nexport type PrincipalSelector = z.output<typeof PrincipalSelector>;\n\nconst pushers = PrincipalSelector.nullable()\n .default(null)\n .describe(\n 'Who may update matching refs at all; null (the default) lets every principal the Authorizer allowed to write.',\n );\n\n/** What the rule-based branch policy allows on refs no rule matches. */\nexport const BranchPermissions = z\n .object({\n pushers,\n create: z.boolean().default(true).describe('Whether a push may create a ref; default true.'),\n delete: z.boolean().default(true).describe('Whether a push may delete a ref; default true.'),\n forcePush: z\n .boolean()\n .default(false)\n .describe(\n 'Whether a push may move a branch to a commit that does not contain its current head (a non-fast-forward, \"git push --force\") or move an existing tag; default false.',\n ),\n })\n .strict()\n .meta({\n id: 'BranchPermissions',\n title: 'Branch permissions',\n description:\n 'What the rule-based branch policy allows on a ref no rule matches. Defaults: anyone with write access, create and delete allowed, force pushes refused.',\n examples: [{ pushers: null, create: true, delete: true, forcePush: false }],\n });\n\n/** Branch permissions as written (defaults optional). */\nexport type BranchPermissionsInput = z.input<typeof BranchPermissions>;\n/** Branch permissions, inferred from {@link BranchPermissions}. */\nexport type BranchPermissions = z.output<typeof BranchPermissions>;\n\n/** One rule of the rule-based branch policy. */\nexport const BranchRule = z\n .object({\n pattern: RefPattern.describe('The refs this rule governs.'),\n pushers,\n create: z.boolean().default(true).describe('Whether a push may create a matching ref; default true.'),\n delete: z\n .boolean()\n .default(false)\n .describe('Whether a push may delete a matching ref; default false (rules usually protect).'),\n forcePush: z\n .boolean()\n .default(false)\n .describe(\n 'Whether a push may move a matching branch to a commit that does not contain its current head, or move a matching tag; default false.',\n ),\n message: z\n .string()\n .min(1)\n .max(200)\n .regex(/^[^\\n\\0]+$/)\n .nullable()\n .default(null)\n .describe(\n 'Text git shows the user when this rule refuses an update, e.g. \"main is protected\"; one line of 1–200 characters. Null (the default) uses a message naming the ref and what was refused.',\n ),\n })\n .strict()\n .meta({\n id: 'BranchRule',\n title: 'Branch rule',\n description:\n 'Governs the refs matching `pattern`: who may push them, whether they may be created or deleted, and whether force pushes are allowed. Rules are tried in order and the first match decides.',\n examples: [\n {\n pattern: 'refs/heads/main',\n pushers: { subjects: [], roles: ['maintainer'] },\n create: true,\n delete: false,\n forcePush: false,\n message: 'main is protected',\n },\n ],\n });\n\n/** A branch rule as written (defaults optional). */\nexport type BranchRuleInput = z.input<typeof BranchRule>;\n/** A branch rule, inferred from {@link BranchRule}. */\nexport type BranchRule = z.output<typeof BranchRule>;\n\n/** Configuration of the rule-based branch policy. */\nexport const BranchPolicyConfig = z\n .object({\n rules: z\n .array(BranchRule)\n .max(200)\n .default([])\n .describe(\n 'Rules tried in order; the first whose pattern matches a ref decides it. At most 200, default none.',\n ),\n fallback: BranchPermissions.default({\n pushers: null,\n create: true,\n delete: true,\n forcePush: false,\n }).describe(\n 'What applies to a branch or tag ref no rule matches; default anyone with write access, create and delete allowed, force refused.',\n ),\n })\n .strict()\n .meta({\n id: 'BranchPolicyConfig',\n title: 'Branch policy configuration',\n description:\n 'Configuration of the reference rule-based BranchPolicy. Refs outside refs/heads/ and refs/tags/ are always refused, whatever the rules say.',\n examples: [\n {\n rules: [\n {\n pattern: 'refs/heads/main',\n pushers: { subjects: [], roles: ['maintainer'] },\n create: true,\n delete: false,\n forcePush: false,\n message: 'main is protected',\n },\n ],\n fallback: { pushers: null, create: true, delete: true, forcePush: false },\n },\n ],\n });\n\n/** A branch policy configuration as written (defaults optional). */\nexport type BranchPolicyConfigInput = z.input<typeof BranchPolicyConfig>;\n/** A branch policy configuration, inferred from {@link BranchPolicyConfig}. */\nexport type BranchPolicyConfig = z.output<typeof BranchPolicyConfig>;\n"],"mappings":";;;;AAMA,MAAa,aAAa,EACvB,OAAO,CAAC,CACR,IAAI,EAAE,CAAC,CACP,IAAI,GAAG,CAAC,CACR,MACC,IAAI,OACF,OAAO,GAAG,qFACZ,CACF,CAAC,CACA,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU;EAAC;EAAmB;EAAwB;CAAc;AACtE,CAAC;AAKH,MAAM,cAAc,EACjB,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,MAAM,YAAY,CAAC,CACnB,SAAS,+DAA+D;;AAG3E,MAAa,oBAAoB,EAC9B,OAAO;CACN,UAAU,EACP,MAAM,WAAW,CAAC,CAClB,IAAI,GAAI,CAAC,CACT,QAAQ,CAAC,CAAC,CAAC,CACX,SAAS,0DAA0D;CACtE,OAAO,EACJ,MAAM,IAAI,CAAC,CACX,IAAI,GAAG,CAAC,CACR,QAAQ,CAAC,CAAC,CAAC,CACX,SAAS,mEAAmE;AACjF,CAAC,CAAC,CACD,OAAO,CAAC,CACR,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CAAC;EAAE,UAAU,CAAC,SAAS;EAAG,OAAO,CAAC,YAAY;CAAE,CAAC;AAC7D,CAAC;AAOH,MAAM,UAAU,kBAAkB,SAAS,CAAC,CACzC,QAAQ,IAAI,CAAC,CACb,SACC,+GACF;;AAGF,MAAa,oBAAoB,EAC9B,OAAO;CACN;CACA,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,SAAS,gDAAgD;CAC3F,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,SAAS,gDAAgD;CAC3F,WAAW,EACR,QAAQ,CAAC,CACT,QAAQ,KAAK,CAAC,CACd,SACC,wKACF;AACJ,CAAC,CAAC,CACD,OAAO,CAAC,CACR,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CAAC;EAAE,SAAS;EAAM,QAAQ;EAAM,QAAQ;EAAM,WAAW;CAAM,CAAC;AAC5E,CAAC;;AAQH,MAAa,aAAa,EACvB,OAAO;CACN,SAAS,WAAW,SAAS,6BAA6B;CAC1D;CACA,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,SAAS,yDAAyD;CACpG,QAAQ,EACL,QAAQ,CAAC,CACT,QAAQ,KAAK,CAAC,CACd,SAAS,kFAAkF;CAC9F,WAAW,EACR,QAAQ,CAAC,CACT,QAAQ,KAAK,CAAC,CACd,SACC,sIACF;CACF,SAAS,EACN,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,MAAM,YAAY,CAAC,CACnB,SAAS,CAAC,CACV,QAAQ,IAAI,CAAC,CACb,SACC,4LACF;AACJ,CAAC,CAAC,CACD,OAAO,CAAC,CACR,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CACR;EACE,SAAS;EACT,SAAS;GAAE,UAAU,CAAC;GAAG,OAAO,CAAC,YAAY;EAAE;EAC/C,QAAQ;EACR,QAAQ;EACR,WAAW;EACX,SAAS;CACX,CACF;AACF,CAAC;;AAQH,MAAa,qBAAqB,EAC/B,OAAO;CACN,OAAO,EACJ,MAAM,UAAU,CAAC,CACjB,IAAI,GAAG,CAAC,CACR,QAAQ,CAAC,CAAC,CAAC,CACX,SACC,oGACF;CACF,UAAU,kBAAkB,QAAQ;EAClC,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,WAAW;CACb,CAAC,CAAC,CAAC,SACD,kIACF;AACF,CAAC,CAAC,CACD,OAAO,CAAC,CACR,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CACR;EACE,OAAO,CACL;GACE,SAAS;GACT,SAAS;IAAE,UAAU,CAAC;IAAG,OAAO,CAAC,YAAY;GAAE;GAC/C,QAAQ;GACR,QAAQ;GACR,WAAW;GACX,SAAS;EACX,CACF;EACA,UAAU;GAAE,SAAS;GAAM,QAAQ;GAAM,QAAQ;GAAM,WAAW;EAAM;CAC1E,CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { RefUpdate } from "../schemas/ref-update.js";
|
|
2
|
+
import { RepoName } from "../schemas/names.js";
|
|
3
|
+
import { AuditEvent } from "./audit-event.js";
|
|
4
|
+
import { GitOperation } from "./git-operation.js";
|
|
5
|
+
import { PolicyResult } from "./policy-result.js";
|
|
6
|
+
import { Principal, PrincipalInput } from "./principal.js";
|
|
7
|
+
import { PushPolicyNeeds, PushPolicyResultInput } from "./push-policy-result.js";
|
|
8
|
+
import { PushPolicyInput } from "./push-policy.js";
|
|
9
|
+
/**
|
|
10
|
+
* Establishes who a smart-HTTP request acts for. git sends credentials as HTTP Basic; the
|
|
11
|
+
* password is a bearer credential (an OAuth access token, a JWT, an API key), so a credential
|
|
12
|
+
* helper can supply one. Return null when the request carries no valid credential — the gateway
|
|
13
|
+
* then answers 401 with `WWW-Authenticate: Basic` so git asks its credential helper. The result
|
|
14
|
+
* is parsed with {@link Principal} before use.
|
|
15
|
+
*/
|
|
16
|
+
export interface Authenticator {
|
|
17
|
+
authenticate(request: Request): Promise<PrincipalInput | null>;
|
|
18
|
+
}
|
|
19
|
+
/** Decides whether a principal may read (clone, fetch) or write (push) a repository. */
|
|
20
|
+
export interface Authorizer {
|
|
21
|
+
authorize(principal: Principal, repo: RepoName, operation: GitOperation): Promise<boolean>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Decides, per ref, whether a push may update it. Called with every branch or tag update of a
|
|
25
|
+
* push (refs in other namespaces are refused before it is called). Synchronous: it decides from
|
|
26
|
+
* the principal and the update commands alone; the gateway proves fast-forwards itself when the
|
|
27
|
+
* result asks for "fast-forward-only". The result is parsed with {@link PolicyResult}.
|
|
28
|
+
*/
|
|
29
|
+
export interface BranchPolicy {
|
|
30
|
+
check(principal: Principal, repo: RepoName, updates: readonly RefUpdate[]): PolicyResult;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A deployment's own rules over what a push changes, run after the BranchPolicy on every push it
|
|
34
|
+
* allowed — e.g. which paths a principal may change, which file types or sizes are accepted.
|
|
35
|
+
* Pushes through the RPC API (`commit`, `syncBranch`, `promote`) are the calling service's and are
|
|
36
|
+
* not checked.
|
|
37
|
+
*
|
|
38
|
+
* `needs()` is called first, with the ref updates alone, and says whether `check()` needs changed
|
|
39
|
+
* paths (its result is parsed with {@link PushPolicyNeeds}). Without them, `check()` runs before
|
|
40
|
+
* the pack is read and a refusal sends nothing to storage. With them, the gateway reads the
|
|
41
|
+
* pushed pack as it streams to storage (holding back its checksum, as it does to prove
|
|
42
|
+
* fast-forwards), computes every new commit's changed paths from the pack and storage within the
|
|
43
|
+
* configured bounds, and calls `check()` before the push completes; a refusal cuts the pack short
|
|
44
|
+
* so storage writes nothing. A push that cannot be checked within the bounds is refused. Either
|
|
45
|
+
* way a refusal reaches git in-protocol ("! [remote rejected] <ref> (<reason>)"). The result is
|
|
46
|
+
* parsed with PushPolicyResult; a `check()` that throws refuses the push.
|
|
47
|
+
*/
|
|
48
|
+
export interface PushPolicy {
|
|
49
|
+
needs(principal: Principal, repo: RepoName, updates: readonly RefUpdate[]): PushPolicyNeeds | Promise<PushPolicyNeeds>;
|
|
50
|
+
check(input: PushPolicyInput): PushPolicyResultInput | Promise<PushPolicyResultInput>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Receives every authenticated smart-HTTP operation once it is decided. It runs after the
|
|
54
|
+
* response is under way (through `waitUntil` when the runtime has it); a failure is logged and
|
|
55
|
+
* never changes the response.
|
|
56
|
+
*/
|
|
57
|
+
export type AuditHook = (event: AuditEvent) => void | Promise<void>;
|
|
58
|
+
//# sourceMappingURL=gateway-hooks.d.ts.map
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** What a smart-HTTP request does to a repository. */
|
|
3
|
+
export declare const GitOperation: z.ZodEnum<{
|
|
4
|
+
read: "read";
|
|
5
|
+
write: "write";
|
|
6
|
+
}>;
|
|
7
|
+
/** A git operation, inferred from {@link GitOperation}. */
|
|
8
|
+
export type GitOperation = z.infer<typeof GitOperation>;
|
|
9
|
+
/** The smart-HTTP endpoint a request reached. */
|
|
10
|
+
export declare const SmartHttpEndpoint: z.ZodEnum<{
|
|
11
|
+
"info-refs": "info-refs";
|
|
12
|
+
"receive-pack": "receive-pack";
|
|
13
|
+
"upload-pack": "upload-pack";
|
|
14
|
+
}>;
|
|
15
|
+
/** A smart-HTTP endpoint, inferred from {@link SmartHttpEndpoint}. */
|
|
16
|
+
export type SmartHttpEndpoint = z.infer<typeof SmartHttpEndpoint>;
|
|
17
|
+
//# sourceMappingURL=git-operation.d.ts.map
|