@leed-ai/git-gateway-worker 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.
Files changed (269) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +49 -2
  3. package/dist/audit/audit-recorder.d.ts +2 -0
  4. package/dist/audit/audit-recorder.js +53 -0
  5. package/dist/audit/audit-recorder.js.map +1 -0
  6. package/dist/audit/push-report.d.ts +13 -0
  7. package/dist/audit/push-report.js +66 -0
  8. package/dist/audit/push-report.js.map +1 -0
  9. package/dist/audit-recorder-K1Ns3tfC.d.ts +31 -0
  10. package/dist/auth/authenticate.d.ts +14 -0
  11. package/dist/auth/authenticate.js +59 -0
  12. package/dist/auth/authenticate.js.map +1 -0
  13. package/dist/auth/authorize.d.ts +12 -0
  14. package/dist/auth/authorize.js +57 -0
  15. package/dist/auth/authorize.js.map +1 -0
  16. package/dist/auth/read-token-auth.d.ts +60 -0
  17. package/dist/auth/read-token-auth.js +83 -0
  18. package/dist/auth/read-token-auth.js.map +1 -0
  19. package/dist/cache/decision-cache.d.ts +2 -0
  20. package/dist/cache/decision-cache.js +45 -0
  21. package/dist/cache/decision-cache.js.map +1 -0
  22. package/dist/commit-workflow-schemas-BWlg7bZR.d.ts +95 -0
  23. package/dist/decision-cache-87U32iSj.d.ts +24 -0
  24. package/dist/gateway-app.d.ts +69 -0
  25. package/dist/gateway-app.js +80 -0
  26. package/dist/gateway-app.js.map +1 -0
  27. package/dist/gateway-context-Boh9I0mk.d.ts +54 -0
  28. package/dist/gateway-env-DnsBU4Pq.d.ts +40 -0
  29. package/dist/gateway-worker.d.ts +13 -0
  30. package/dist/gateway-worker.js +22 -0
  31. package/dist/gateway-worker.js.map +1 -0
  32. package/dist/git-route-Spxi09Rm.d.ts +22 -0
  33. package/dist/health.d.ts +6 -0
  34. package/dist/health.js +16 -0
  35. package/dist/health.js.map +1 -0
  36. package/dist/logger-BZ1zyKLb.d.ts +27 -0
  37. package/dist/logging/logger.d.ts +2 -0
  38. package/dist/logging/logger.js +15 -0
  39. package/dist/logging/logger.js.map +1 -0
  40. package/dist/on-push-DTREOB__.d.ts +62 -0
  41. package/dist/policy/branch-policy.d.ts +24 -0
  42. package/dist/policy/branch-policy.js +125 -0
  43. package/dist/policy/branch-policy.js.map +1 -0
  44. package/dist/policy/enforce-branch-policy.d.ts +30 -0
  45. package/dist/policy/enforce-branch-policy.js +214 -0
  46. package/dist/policy/enforce-branch-policy.js.map +1 -0
  47. package/dist/policy/fast-forward.d.ts +32 -0
  48. package/dist/policy/fast-forward.js +95 -0
  49. package/dist/policy/fast-forward.js.map +1 -0
  50. package/dist/policy/ref-pattern.d.ts +7 -0
  51. package/dist/policy/ref-pattern.js +25 -0
  52. package/dist/policy/ref-pattern.js.map +1 -0
  53. package/dist/policy/rule-branch-policy.d.ts +17 -0
  54. package/dist/policy/rule-branch-policy.js +69 -0
  55. package/dist/policy/rule-branch-policy.js.map +1 -0
  56. package/dist/proxy/defer.d.ts +8 -0
  57. package/dist/proxy/defer.js +15 -0
  58. package/dist/proxy/defer.js.map +1 -0
  59. package/dist/proxy/forward-read.d.ts +11 -0
  60. package/dist/proxy/forward-read.js +53 -0
  61. package/dist/proxy/forward-read.js.map +1 -0
  62. package/dist/proxy/gateway-deps.d.ts +39 -0
  63. package/dist/proxy/gateway-deps.js +0 -0
  64. package/dist/proxy/gateway-env.d.ts +2 -0
  65. package/dist/proxy/gateway-env.js +0 -0
  66. package/dist/proxy/git-responses.d.ts +25 -0
  67. package/dist/proxy/git-responses.js +83 -0
  68. package/dist/proxy/git-responses.js.map +1 -0
  69. package/dist/proxy/git-route.d.ts +2 -0
  70. package/dist/proxy/git-route.js +34 -0
  71. package/dist/proxy/git-route.js.map +1 -0
  72. package/dist/proxy/push-events.d.ts +28 -0
  73. package/dist/proxy/push-events.js +65 -0
  74. package/dist/proxy/push-events.js.map +1 -0
  75. package/dist/proxy/push-guard.d.ts +43 -0
  76. package/dist/proxy/push-guard.js +81 -0
  77. package/dist/proxy/push-guard.js.map +1 -0
  78. package/dist/proxy/push-options.d.ts +16 -0
  79. package/dist/proxy/push-options.js +33 -0
  80. package/dist/proxy/push-options.js.map +1 -0
  81. package/dist/proxy/receive-pack.d.ts +17 -0
  82. package/dist/proxy/receive-pack.js +244 -0
  83. package/dist/proxy/receive-pack.js.map +1 -0
  84. package/dist/proxy/request-log.d.ts +13 -0
  85. package/dist/proxy/request-log.js +41 -0
  86. package/dist/proxy/request-log.js.map +1 -0
  87. package/dist/proxy/resolve-route.d.ts +9 -0
  88. package/dist/proxy/resolve-route.js +22 -0
  89. package/dist/proxy/resolve-route.js.map +1 -0
  90. package/dist/proxy/upstream-call.d.ts +23 -0
  91. package/dist/proxy/upstream-call.js +63 -0
  92. package/dist/proxy/upstream-call.js.map +1 -0
  93. package/dist/proxy/upstream.d.ts +2 -0
  94. package/dist/proxy/upstream.js +68 -0
  95. package/dist/proxy/upstream.js.map +1 -0
  96. package/dist/push-event-f-5TsFUY.d.ts +15 -0
  97. package/dist/push-policy/changed-paths.d.ts +26 -0
  98. package/dist/push-policy/changed-paths.js +117 -0
  99. package/dist/push-policy/changed-paths.js.map +1 -0
  100. package/dist/push-policy/pushed-objects.d.ts +30 -0
  101. package/dist/push-policy/pushed-objects.js +76 -0
  102. package/dist/push-policy/pushed-objects.js.map +1 -0
  103. package/dist/push-policy/run-push-policy.d.ts +35 -0
  104. package/dist/push-policy/run-push-policy.js +77 -0
  105. package/dist/push-policy/run-push-policy.js.map +1 -0
  106. package/dist/push-policy/tree-diff.d.ts +21 -0
  107. package/dist/push-policy/tree-diff.js +78 -0
  108. package/dist/push-policy/tree-diff.js.map +1 -0
  109. package/dist/push-policy/uncheckable.d.ts +14 -0
  110. package/dist/push-policy/uncheckable.js +25 -0
  111. package/dist/push-policy/uncheckable.js.map +1 -0
  112. package/dist/rpc/branch-methods.d.ts +16 -0
  113. package/dist/rpc/branch-methods.js +43 -0
  114. package/dist/rpc/branch-methods.js.map +1 -0
  115. package/dist/rpc/commit-attempt.d.ts +27 -0
  116. package/dist/rpc/commit-attempt.js +85 -0
  117. package/dist/rpc/commit-attempt.js.map +1 -0
  118. package/dist/rpc/commit-graph.d.ts +20 -0
  119. package/dist/rpc/commit-graph.js +38 -0
  120. package/dist/rpc/commit-graph.js.map +1 -0
  121. package/dist/rpc/commit-method.d.ts +13 -0
  122. package/dist/rpc/commit-method.js +30 -0
  123. package/dist/rpc/commit-method.js.map +1 -0
  124. package/dist/rpc/commit-source.d.ts +12 -0
  125. package/dist/rpc/commit-source.js +9 -0
  126. package/dist/rpc/commit-source.js.map +1 -0
  127. package/dist/rpc/gateway-context.d.ts +2 -0
  128. package/dist/rpc/gateway-context.js +30 -0
  129. package/dist/rpc/gateway-context.js.map +1 -0
  130. package/dist/rpc/gateway-rpc.d.ts +10 -0
  131. package/dist/rpc/gateway-rpc.js +48 -0
  132. package/dist/rpc/gateway-rpc.js.map +1 -0
  133. package/dist/rpc/gateway-service.d.ts +24 -0
  134. package/dist/rpc/gateway-service.js +63 -0
  135. package/dist/rpc/gateway-service.js.map +1 -0
  136. package/dist/rpc/history-page.d.ts +35 -0
  137. package/dist/rpc/history-page.js +122 -0
  138. package/dist/rpc/history-page.js.map +1 -0
  139. package/dist/rpc/lifecycle-methods.d.ts +12 -0
  140. package/dist/rpc/lifecycle-methods.js +39 -0
  141. package/dist/rpc/lifecycle-methods.js.map +1 -0
  142. package/dist/rpc/paint-down.d.ts +17 -0
  143. package/dist/rpc/paint-down.js +96 -0
  144. package/dist/rpc/paint-down.js.map +1 -0
  145. package/dist/rpc/promote-attempt.d.ts +21 -0
  146. package/dist/rpc/promote-attempt.js +55 -0
  147. package/dist/rpc/promote-attempt.js.map +1 -0
  148. package/dist/rpc/push-ref.d.ts +21 -0
  149. package/dist/rpc/push-ref.js +47 -0
  150. package/dist/rpc/push-ref.js.map +1 -0
  151. package/dist/rpc/read-methods.d.ts +17 -0
  152. package/dist/rpc/read-methods.js +94 -0
  153. package/dist/rpc/read-methods.js.map +1 -0
  154. package/dist/rpc/read-token.d.ts +39 -0
  155. package/dist/rpc/read-token.js +107 -0
  156. package/dist/rpc/read-token.js.map +1 -0
  157. package/dist/rpc/repo-access.d.ts +36 -0
  158. package/dist/rpc/repo-access.js +75 -0
  159. package/dist/rpc/repo-access.js.map +1 -0
  160. package/dist/rpc/sync-attempt.d.ts +23 -0
  161. package/dist/rpc/sync-attempt.js +105 -0
  162. package/dist/rpc/sync-attempt.js.map +1 -0
  163. package/dist/sync-workflow-schemas-DCNmNE5-.d.ts +57 -0
  164. package/dist/upstream-DvqMCj5N.d.ts +15 -0
  165. package/dist/workflow-starter-BqhwX6oA.d.ts +45 -0
  166. package/dist/workflows/commit-workflow-schemas.d.ts +2 -0
  167. package/dist/workflows/commit-workflow-schemas.js +84 -0
  168. package/dist/workflows/commit-workflow-schemas.js.map +1 -0
  169. package/dist/workflows/commit-workflow.d.ts +16 -0
  170. package/dist/workflows/commit-workflow.js +22 -0
  171. package/dist/workflows/commit-workflow.js.map +1 -0
  172. package/dist/workflows/on-push.d.ts +2 -0
  173. package/dist/workflows/on-push.js +90 -0
  174. package/dist/workflows/on-push.js.map +1 -0
  175. package/dist/workflows/push-event.d.ts +2 -0
  176. package/dist/workflows/push-event.js +28 -0
  177. package/dist/workflows/push-event.js.map +1 -0
  178. package/dist/workflows/run-commit-workflow.d.ts +15 -0
  179. package/dist/workflows/run-commit-workflow.js +49 -0
  180. package/dist/workflows/run-commit-workflow.js.map +1 -0
  181. package/dist/workflows/run-sync-workflow.d.ts +14 -0
  182. package/dist/workflows/run-sync-workflow.js +67 -0
  183. package/dist/workflows/run-sync-workflow.js.map +1 -0
  184. package/dist/workflows/step-errors.d.ts +15 -0
  185. package/dist/workflows/step-errors.js +24 -0
  186. package/dist/workflows/step-errors.js.map +1 -0
  187. package/dist/workflows/step-runner.d.ts +31 -0
  188. package/dist/workflows/step-runner.js +6 -0
  189. package/dist/workflows/step-runner.js.map +1 -0
  190. package/dist/workflows/sync-branch-workflow.d.ts +15 -0
  191. package/dist/workflows/sync-branch-workflow.js +21 -0
  192. package/dist/workflows/sync-branch-workflow.js.map +1 -0
  193. package/dist/workflows/sync-workflow-schemas.d.ts +2 -0
  194. package/dist/workflows/sync-workflow-schemas.js +104 -0
  195. package/dist/workflows/sync-workflow-schemas.js.map +1 -0
  196. package/dist/workflows/workflow-instance-id.d.ts +12 -0
  197. package/dist/workflows/workflow-instance-id.js +33 -0
  198. package/dist/workflows/workflow-instance-id.js.map +1 -0
  199. package/dist/workflows/workflow-runtime.d.ts +7 -0
  200. package/dist/workflows/workflow-runtime.js +11 -0
  201. package/dist/workflows/workflow-runtime.js.map +1 -0
  202. package/dist/workflows/workflow-starter.d.ts +2 -0
  203. package/dist/workflows/workflow-starter.js +40 -0
  204. package/dist/workflows/workflow-starter.js.map +1 -0
  205. package/package.json +381 -4
  206. package/src/audit/audit-recorder.ts +74 -0
  207. package/src/audit/push-report.ts +60 -0
  208. package/src/auth/authenticate.ts +68 -0
  209. package/src/auth/authorize.ts +57 -0
  210. package/src/auth/read-token-auth.ts +119 -0
  211. package/src/cache/decision-cache.ts +57 -0
  212. package/src/gateway-app.ts +147 -0
  213. package/src/gateway-worker.ts +32 -0
  214. package/src/health.ts +12 -0
  215. package/src/logging/logger.ts +40 -0
  216. package/src/policy/branch-policy.ts +119 -0
  217. package/src/policy/enforce-branch-policy.ts +213 -0
  218. package/src/policy/fast-forward.ts +136 -0
  219. package/src/policy/ref-pattern.ts +24 -0
  220. package/src/policy/rule-branch-policy.ts +76 -0
  221. package/src/proxy/defer.ts +18 -0
  222. package/src/proxy/forward-read.ts +52 -0
  223. package/src/proxy/gateway-deps.ts +43 -0
  224. package/src/proxy/gateway-env.ts +43 -0
  225. package/src/proxy/git-responses.ts +89 -0
  226. package/src/proxy/git-route.ts +49 -0
  227. package/src/proxy/push-events.ts +91 -0
  228. package/src/proxy/push-guard.ts +109 -0
  229. package/src/proxy/push-options.ts +38 -0
  230. package/src/proxy/receive-pack.ts +257 -0
  231. package/src/proxy/request-log.ts +44 -0
  232. package/src/proxy/resolve-route.ts +24 -0
  233. package/src/proxy/upstream-call.ts +71 -0
  234. package/src/proxy/upstream.ts +76 -0
  235. package/src/push-policy/changed-paths.ts +143 -0
  236. package/src/push-policy/pushed-objects.ts +88 -0
  237. package/src/push-policy/run-push-policy.ts +99 -0
  238. package/src/push-policy/tree-diff.ts +107 -0
  239. package/src/push-policy/uncheckable.ts +27 -0
  240. package/src/rpc/branch-methods.ts +57 -0
  241. package/src/rpc/commit-attempt.ts +87 -0
  242. package/src/rpc/commit-graph.ts +44 -0
  243. package/src/rpc/commit-method.ts +36 -0
  244. package/src/rpc/commit-source.ts +15 -0
  245. package/src/rpc/gateway-context.ts +77 -0
  246. package/src/rpc/gateway-rpc.ts +65 -0
  247. package/src/rpc/gateway-service.ts +85 -0
  248. package/src/rpc/history-page.ts +163 -0
  249. package/src/rpc/lifecycle-methods.ts +50 -0
  250. package/src/rpc/paint-down.ts +120 -0
  251. package/src/rpc/promote-attempt.ts +52 -0
  252. package/src/rpc/push-ref.ts +54 -0
  253. package/src/rpc/read-methods.ts +111 -0
  254. package/src/rpc/read-token.ts +135 -0
  255. package/src/rpc/repo-access.ts +112 -0
  256. package/src/rpc/sync-attempt.ts +84 -0
  257. package/src/workflows/commit-workflow-schemas.ts +95 -0
  258. package/src/workflows/commit-workflow.ts +39 -0
  259. package/src/workflows/on-push.ts +128 -0
  260. package/src/workflows/push-event.ts +41 -0
  261. package/src/workflows/run-commit-workflow.ts +45 -0
  262. package/src/workflows/run-sync-workflow.ts +52 -0
  263. package/src/workflows/step-errors.ts +26 -0
  264. package/src/workflows/step-runner.ts +36 -0
  265. package/src/workflows/sync-branch-workflow.ts +40 -0
  266. package/src/workflows/sync-workflow-schemas.ts +122 -0
  267. package/src/workflows/workflow-instance-id.ts +26 -0
  268. package/src/workflows/workflow-runtime.ts +13 -0
  269. package/src/workflows/workflow-starter.ts +69 -0
package/package.json CHANGED
@@ -1,6 +1,383 @@
1
1
  {
2
2
  "name": "@leed-ai/git-gateway-worker",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "The git-gateway Cloudflare Worker: smart-HTTP proxy, auth and branch-policy pipeline, RPC entrypoint and Workflows.",
5
+ "keywords": [
6
+ "cloudflare-workers",
7
+ "git",
8
+ "git-gateway",
9
+ "hono",
10
+ "smart-http"
11
+ ],
12
+ "homepage": "https://github.com/leed-ai/git-gateway/tree/main/packages/worker#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/leed-ai/git-gateway/issues"
15
+ },
16
+ "license": "Apache-2.0",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/leed-ai/git-gateway.git",
20
+ "directory": "packages/worker"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "src"
25
+ ],
26
+ "type": "module",
27
+ "sideEffects": false,
28
+ "exports": {
29
+ "./audit/audit-recorder": {
30
+ "source": "./src/audit/audit-recorder.ts",
31
+ "types": "./dist/audit/audit-recorder.d.ts",
32
+ "default": "./dist/audit/audit-recorder.js"
33
+ },
34
+ "./audit/push-report": {
35
+ "source": "./src/audit/push-report.ts",
36
+ "types": "./dist/audit/push-report.d.ts",
37
+ "default": "./dist/audit/push-report.js"
38
+ },
39
+ "./auth/authenticate": {
40
+ "source": "./src/auth/authenticate.ts",
41
+ "types": "./dist/auth/authenticate.d.ts",
42
+ "default": "./dist/auth/authenticate.js"
43
+ },
44
+ "./auth/authorize": {
45
+ "source": "./src/auth/authorize.ts",
46
+ "types": "./dist/auth/authorize.d.ts",
47
+ "default": "./dist/auth/authorize.js"
48
+ },
49
+ "./auth/read-token-auth": {
50
+ "source": "./src/auth/read-token-auth.ts",
51
+ "types": "./dist/auth/read-token-auth.d.ts",
52
+ "default": "./dist/auth/read-token-auth.js"
53
+ },
54
+ "./cache/decision-cache": {
55
+ "source": "./src/cache/decision-cache.ts",
56
+ "types": "./dist/cache/decision-cache.d.ts",
57
+ "default": "./dist/cache/decision-cache.js"
58
+ },
59
+ "./gateway-app": {
60
+ "source": "./src/gateway-app.ts",
61
+ "types": "./dist/gateway-app.d.ts",
62
+ "default": "./dist/gateway-app.js"
63
+ },
64
+ "./gateway-worker": {
65
+ "source": "./src/gateway-worker.ts",
66
+ "types": "./dist/gateway-worker.d.ts",
67
+ "default": "./dist/gateway-worker.js"
68
+ },
69
+ "./health": {
70
+ "source": "./src/health.ts",
71
+ "types": "./dist/health.d.ts",
72
+ "default": "./dist/health.js"
73
+ },
74
+ "./logging/logger": {
75
+ "source": "./src/logging/logger.ts",
76
+ "types": "./dist/logging/logger.d.ts",
77
+ "default": "./dist/logging/logger.js"
78
+ },
79
+ "./policy/branch-policy": {
80
+ "source": "./src/policy/branch-policy.ts",
81
+ "types": "./dist/policy/branch-policy.d.ts",
82
+ "default": "./dist/policy/branch-policy.js"
83
+ },
84
+ "./policy/enforce-branch-policy": {
85
+ "source": "./src/policy/enforce-branch-policy.ts",
86
+ "types": "./dist/policy/enforce-branch-policy.d.ts",
87
+ "default": "./dist/policy/enforce-branch-policy.js"
88
+ },
89
+ "./policy/fast-forward": {
90
+ "source": "./src/policy/fast-forward.ts",
91
+ "types": "./dist/policy/fast-forward.d.ts",
92
+ "default": "./dist/policy/fast-forward.js"
93
+ },
94
+ "./policy/ref-pattern": {
95
+ "source": "./src/policy/ref-pattern.ts",
96
+ "types": "./dist/policy/ref-pattern.d.ts",
97
+ "default": "./dist/policy/ref-pattern.js"
98
+ },
99
+ "./policy/rule-branch-policy": {
100
+ "source": "./src/policy/rule-branch-policy.ts",
101
+ "types": "./dist/policy/rule-branch-policy.d.ts",
102
+ "default": "./dist/policy/rule-branch-policy.js"
103
+ },
104
+ "./proxy/defer": {
105
+ "source": "./src/proxy/defer.ts",
106
+ "types": "./dist/proxy/defer.d.ts",
107
+ "default": "./dist/proxy/defer.js"
108
+ },
109
+ "./proxy/forward-read": {
110
+ "source": "./src/proxy/forward-read.ts",
111
+ "types": "./dist/proxy/forward-read.d.ts",
112
+ "default": "./dist/proxy/forward-read.js"
113
+ },
114
+ "./proxy/gateway-deps": {
115
+ "source": "./src/proxy/gateway-deps.ts",
116
+ "types": "./dist/proxy/gateway-deps.d.ts",
117
+ "default": "./dist/proxy/gateway-deps.js"
118
+ },
119
+ "./proxy/gateway-env": {
120
+ "source": "./src/proxy/gateway-env.ts",
121
+ "types": "./dist/proxy/gateway-env.d.ts",
122
+ "default": "./dist/proxy/gateway-env.js"
123
+ },
124
+ "./proxy/git-responses": {
125
+ "source": "./src/proxy/git-responses.ts",
126
+ "types": "./dist/proxy/git-responses.d.ts",
127
+ "default": "./dist/proxy/git-responses.js"
128
+ },
129
+ "./proxy/git-route": {
130
+ "source": "./src/proxy/git-route.ts",
131
+ "types": "./dist/proxy/git-route.d.ts",
132
+ "default": "./dist/proxy/git-route.js"
133
+ },
134
+ "./proxy/push-events": {
135
+ "source": "./src/proxy/push-events.ts",
136
+ "types": "./dist/proxy/push-events.d.ts",
137
+ "default": "./dist/proxy/push-events.js"
138
+ },
139
+ "./proxy/push-guard": {
140
+ "source": "./src/proxy/push-guard.ts",
141
+ "types": "./dist/proxy/push-guard.d.ts",
142
+ "default": "./dist/proxy/push-guard.js"
143
+ },
144
+ "./proxy/push-options": {
145
+ "source": "./src/proxy/push-options.ts",
146
+ "types": "./dist/proxy/push-options.d.ts",
147
+ "default": "./dist/proxy/push-options.js"
148
+ },
149
+ "./proxy/receive-pack": {
150
+ "source": "./src/proxy/receive-pack.ts",
151
+ "types": "./dist/proxy/receive-pack.d.ts",
152
+ "default": "./dist/proxy/receive-pack.js"
153
+ },
154
+ "./proxy/request-log": {
155
+ "source": "./src/proxy/request-log.ts",
156
+ "types": "./dist/proxy/request-log.d.ts",
157
+ "default": "./dist/proxy/request-log.js"
158
+ },
159
+ "./proxy/resolve-route": {
160
+ "source": "./src/proxy/resolve-route.ts",
161
+ "types": "./dist/proxy/resolve-route.d.ts",
162
+ "default": "./dist/proxy/resolve-route.js"
163
+ },
164
+ "./proxy/upstream": {
165
+ "source": "./src/proxy/upstream.ts",
166
+ "types": "./dist/proxy/upstream.d.ts",
167
+ "default": "./dist/proxy/upstream.js"
168
+ },
169
+ "./proxy/upstream-call": {
170
+ "source": "./src/proxy/upstream-call.ts",
171
+ "types": "./dist/proxy/upstream-call.d.ts",
172
+ "default": "./dist/proxy/upstream-call.js"
173
+ },
174
+ "./push-policy/changed-paths": {
175
+ "source": "./src/push-policy/changed-paths.ts",
176
+ "types": "./dist/push-policy/changed-paths.d.ts",
177
+ "default": "./dist/push-policy/changed-paths.js"
178
+ },
179
+ "./push-policy/pushed-objects": {
180
+ "source": "./src/push-policy/pushed-objects.ts",
181
+ "types": "./dist/push-policy/pushed-objects.d.ts",
182
+ "default": "./dist/push-policy/pushed-objects.js"
183
+ },
184
+ "./push-policy/run-push-policy": {
185
+ "source": "./src/push-policy/run-push-policy.ts",
186
+ "types": "./dist/push-policy/run-push-policy.d.ts",
187
+ "default": "./dist/push-policy/run-push-policy.js"
188
+ },
189
+ "./push-policy/tree-diff": {
190
+ "source": "./src/push-policy/tree-diff.ts",
191
+ "types": "./dist/push-policy/tree-diff.d.ts",
192
+ "default": "./dist/push-policy/tree-diff.js"
193
+ },
194
+ "./push-policy/uncheckable": {
195
+ "source": "./src/push-policy/uncheckable.ts",
196
+ "types": "./dist/push-policy/uncheckable.d.ts",
197
+ "default": "./dist/push-policy/uncheckable.js"
198
+ },
199
+ "./rpc/branch-methods": {
200
+ "source": "./src/rpc/branch-methods.ts",
201
+ "types": "./dist/rpc/branch-methods.d.ts",
202
+ "default": "./dist/rpc/branch-methods.js"
203
+ },
204
+ "./rpc/commit-attempt": {
205
+ "source": "./src/rpc/commit-attempt.ts",
206
+ "types": "./dist/rpc/commit-attempt.d.ts",
207
+ "default": "./dist/rpc/commit-attempt.js"
208
+ },
209
+ "./rpc/commit-graph": {
210
+ "source": "./src/rpc/commit-graph.ts",
211
+ "types": "./dist/rpc/commit-graph.d.ts",
212
+ "default": "./dist/rpc/commit-graph.js"
213
+ },
214
+ "./rpc/commit-method": {
215
+ "source": "./src/rpc/commit-method.ts",
216
+ "types": "./dist/rpc/commit-method.d.ts",
217
+ "default": "./dist/rpc/commit-method.js"
218
+ },
219
+ "./rpc/commit-source": {
220
+ "source": "./src/rpc/commit-source.ts",
221
+ "types": "./dist/rpc/commit-source.d.ts",
222
+ "default": "./dist/rpc/commit-source.js"
223
+ },
224
+ "./rpc/gateway-context": {
225
+ "source": "./src/rpc/gateway-context.ts",
226
+ "types": "./dist/rpc/gateway-context.d.ts",
227
+ "default": "./dist/rpc/gateway-context.js"
228
+ },
229
+ "./rpc/gateway-rpc": {
230
+ "source": "./src/rpc/gateway-rpc.ts",
231
+ "types": "./dist/rpc/gateway-rpc.d.ts",
232
+ "default": "./dist/rpc/gateway-rpc.js"
233
+ },
234
+ "./rpc/gateway-service": {
235
+ "source": "./src/rpc/gateway-service.ts",
236
+ "types": "./dist/rpc/gateway-service.d.ts",
237
+ "default": "./dist/rpc/gateway-service.js"
238
+ },
239
+ "./rpc/history-page": {
240
+ "source": "./src/rpc/history-page.ts",
241
+ "types": "./dist/rpc/history-page.d.ts",
242
+ "default": "./dist/rpc/history-page.js"
243
+ },
244
+ "./rpc/lifecycle-methods": {
245
+ "source": "./src/rpc/lifecycle-methods.ts",
246
+ "types": "./dist/rpc/lifecycle-methods.d.ts",
247
+ "default": "./dist/rpc/lifecycle-methods.js"
248
+ },
249
+ "./rpc/paint-down": {
250
+ "source": "./src/rpc/paint-down.ts",
251
+ "types": "./dist/rpc/paint-down.d.ts",
252
+ "default": "./dist/rpc/paint-down.js"
253
+ },
254
+ "./rpc/promote-attempt": {
255
+ "source": "./src/rpc/promote-attempt.ts",
256
+ "types": "./dist/rpc/promote-attempt.d.ts",
257
+ "default": "./dist/rpc/promote-attempt.js"
258
+ },
259
+ "./rpc/push-ref": {
260
+ "source": "./src/rpc/push-ref.ts",
261
+ "types": "./dist/rpc/push-ref.d.ts",
262
+ "default": "./dist/rpc/push-ref.js"
263
+ },
264
+ "./rpc/read-methods": {
265
+ "source": "./src/rpc/read-methods.ts",
266
+ "types": "./dist/rpc/read-methods.d.ts",
267
+ "default": "./dist/rpc/read-methods.js"
268
+ },
269
+ "./rpc/read-token": {
270
+ "source": "./src/rpc/read-token.ts",
271
+ "types": "./dist/rpc/read-token.d.ts",
272
+ "default": "./dist/rpc/read-token.js"
273
+ },
274
+ "./rpc/repo-access": {
275
+ "source": "./src/rpc/repo-access.ts",
276
+ "types": "./dist/rpc/repo-access.d.ts",
277
+ "default": "./dist/rpc/repo-access.js"
278
+ },
279
+ "./rpc/sync-attempt": {
280
+ "source": "./src/rpc/sync-attempt.ts",
281
+ "types": "./dist/rpc/sync-attempt.d.ts",
282
+ "default": "./dist/rpc/sync-attempt.js"
283
+ },
284
+ "./workflows/commit-workflow": {
285
+ "source": "./src/workflows/commit-workflow.ts",
286
+ "types": "./dist/workflows/commit-workflow.d.ts",
287
+ "default": "./dist/workflows/commit-workflow.js"
288
+ },
289
+ "./workflows/commit-workflow-schemas": {
290
+ "source": "./src/workflows/commit-workflow-schemas.ts",
291
+ "types": "./dist/workflows/commit-workflow-schemas.d.ts",
292
+ "default": "./dist/workflows/commit-workflow-schemas.js"
293
+ },
294
+ "./workflows/on-push": {
295
+ "source": "./src/workflows/on-push.ts",
296
+ "types": "./dist/workflows/on-push.d.ts",
297
+ "default": "./dist/workflows/on-push.js"
298
+ },
299
+ "./workflows/push-event": {
300
+ "source": "./src/workflows/push-event.ts",
301
+ "types": "./dist/workflows/push-event.d.ts",
302
+ "default": "./dist/workflows/push-event.js"
303
+ },
304
+ "./workflows/run-commit-workflow": {
305
+ "source": "./src/workflows/run-commit-workflow.ts",
306
+ "types": "./dist/workflows/run-commit-workflow.d.ts",
307
+ "default": "./dist/workflows/run-commit-workflow.js"
308
+ },
309
+ "./workflows/run-sync-workflow": {
310
+ "source": "./src/workflows/run-sync-workflow.ts",
311
+ "types": "./dist/workflows/run-sync-workflow.d.ts",
312
+ "default": "./dist/workflows/run-sync-workflow.js"
313
+ },
314
+ "./workflows/step-errors": {
315
+ "source": "./src/workflows/step-errors.ts",
316
+ "types": "./dist/workflows/step-errors.d.ts",
317
+ "default": "./dist/workflows/step-errors.js"
318
+ },
319
+ "./workflows/step-runner": {
320
+ "source": "./src/workflows/step-runner.ts",
321
+ "types": "./dist/workflows/step-runner.d.ts",
322
+ "default": "./dist/workflows/step-runner.js"
323
+ },
324
+ "./workflows/sync-branch-workflow": {
325
+ "source": "./src/workflows/sync-branch-workflow.ts",
326
+ "types": "./dist/workflows/sync-branch-workflow.d.ts",
327
+ "default": "./dist/workflows/sync-branch-workflow.js"
328
+ },
329
+ "./workflows/sync-workflow-schemas": {
330
+ "source": "./src/workflows/sync-workflow-schemas.ts",
331
+ "types": "./dist/workflows/sync-workflow-schemas.d.ts",
332
+ "default": "./dist/workflows/sync-workflow-schemas.js"
333
+ },
334
+ "./workflows/workflow-instance-id": {
335
+ "source": "./src/workflows/workflow-instance-id.ts",
336
+ "types": "./dist/workflows/workflow-instance-id.d.ts",
337
+ "default": "./dist/workflows/workflow-instance-id.js"
338
+ },
339
+ "./workflows/workflow-runtime": {
340
+ "source": "./src/workflows/workflow-runtime.ts",
341
+ "types": "./dist/workflows/workflow-runtime.d.ts",
342
+ "default": "./dist/workflows/workflow-runtime.js"
343
+ },
344
+ "./workflows/workflow-starter": {
345
+ "source": "./src/workflows/workflow-starter.ts",
346
+ "types": "./dist/workflows/workflow-starter.d.ts",
347
+ "default": "./dist/workflows/workflow-starter.js"
348
+ },
349
+ "./package.json": "./package.json"
350
+ },
351
+ "publishConfig": {
352
+ "access": "public",
353
+ "provenance": true
354
+ },
355
+ "scripts": {
356
+ "build": "vp pack",
357
+ "check": "vp check",
358
+ "test": "vp test"
359
+ },
360
+ "dependencies": {
361
+ "@leed-ai/git-gateway-contract": "0.1.0",
362
+ "@leed-ai/git-gateway-core": "0.1.0"
363
+ },
364
+ "devDependencies": {
365
+ "@cloudflare/vitest-plugin": "^1.8.5",
366
+ "@cloudflare/workers-types": "^5.20261120.1",
367
+ "@leed-ai/git-gateway-repo-tools": "0.0.0",
368
+ "@leed-ai/git-gateway-schema-docs": "0.0.0",
369
+ "@leed-ai/git-gateway-testkit": "0.1.0",
370
+ "fast-check": "^4.10.3",
371
+ "hono": "^4.13.19",
372
+ "typescript": "^7.0.2",
373
+ "vite-plus": "^1.7.0",
374
+ "zod": "^4.6.7"
375
+ },
376
+ "peerDependencies": {
377
+ "hono": "^4",
378
+ "zod": "^4"
379
+ },
380
+ "engines": {
381
+ "node": ">=22.18.0"
382
+ }
383
+ }
@@ -0,0 +1,74 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { AuditEvent, type AuditRefOutcome } from '@leed-ai/git-gateway-contract/proxy/audit-event';
3
+ import type { AuditHook } from '@leed-ai/git-gateway-contract/proxy/gateway-hooks';
4
+ import type { Principal } from '@leed-ai/git-gateway-contract/proxy/principal';
5
+
6
+ import type { Logger } from '../logging/logger.ts';
7
+ import type { GitRequest } from '../proxy/git-route.ts';
8
+
9
+ /** What one request contributes to its audit event. */
10
+ export interface AuditFacts {
11
+ readonly requestId: string;
12
+ readonly principal: Principal;
13
+ readonly git: GitRequest;
14
+ readonly outcome: AuditEvent['outcome'];
15
+ readonly reason: string | null;
16
+ readonly refs: readonly AuditRefOutcome[];
17
+ }
18
+
19
+ /** Runs work after the response, through the runtime's `waitUntil` when there is one. */
20
+ export type Defer = (work: Promise<unknown>) => void;
21
+
22
+ /**
23
+ * Builds audit events and hands them to the deployment's hook without ever affecting the
24
+ * response: the hook runs deferred, and a hook that throws (or an event the schema rejects) is
25
+ * logged and dropped.
26
+ */
27
+ export class AuditRecorder {
28
+ readonly #hook: AuditHook | undefined;
29
+ readonly #logger: Logger;
30
+ readonly #now: () => Date;
31
+
32
+ constructor(hook: AuditHook | undefined, logger: Logger, now: () => Date) {
33
+ this.#hook = hook;
34
+ this.#logger = logger;
35
+ this.#now = now;
36
+ }
37
+
38
+ /** Whether a hook is configured (when not, callers can skip gathering facts). */
39
+ get enabled(): boolean {
40
+ return this.#hook !== undefined;
41
+ }
42
+
43
+ /** Records one event, deferred; `facts` may be a promise (for a push whose report is still streaming). */
44
+ record(facts: AuditFacts | Promise<AuditFacts>, defer: Defer, requestId: string): void {
45
+ const hook = this.#hook;
46
+ if (hook === undefined) return;
47
+ defer(
48
+ (async () => {
49
+ try {
50
+ const resolved = await facts;
51
+ const event = AuditEvent.parse({
52
+ requestId: resolved.requestId,
53
+ at: this.#now().toISOString(),
54
+ principal: resolved.principal,
55
+ repo: resolved.git.repo,
56
+ operation: resolved.git.operation,
57
+ endpoint: resolved.git.endpoint,
58
+ outcome: resolved.outcome,
59
+ reason: resolved.reason,
60
+ refs: resolved.refs,
61
+ });
62
+ await hook(event);
63
+ } catch (error) {
64
+ this.#logger.log({
65
+ level: 'error',
66
+ message: 'audit hook failed',
67
+ requestId,
68
+ error: error instanceof Error ? error.message : String(error),
69
+ });
70
+ }
71
+ })(),
72
+ );
73
+ }
74
+ }
@@ -0,0 +1,60 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import type { AuditRefOutcome } from '@leed-ai/git-gateway-contract/proxy/audit-event';
3
+ import { concatBytes } from '@leed-ai/git-gateway-core/bytes';
4
+ import { parseReportStatus, reportStatusFraming } from '@leed-ai/git-gateway-core/receive-pack/report-status';
5
+ import type { ReceivePackRequest } from '@leed-ai/git-gateway-core/schemas/receive-pack';
6
+
7
+ /** The ref outcomes of a push before the storage host has answered: every update "unknown". */
8
+ export function unknownOutcomes(request: ReceivePackRequest): AuditRefOutcome[] {
9
+ return request.commands.map((command) => ({ ...command, status: 'unknown', reason: null }));
10
+ }
11
+
12
+ /** Every update of a push refused with its reason. */
13
+ export function rejectedOutcomes(
14
+ request: ReceivePackRequest,
15
+ reasons: ReadonlyMap<string, string>,
16
+ fallback: string,
17
+ ): AuditRefOutcome[] {
18
+ return request.commands.map((command) => ({
19
+ ...command,
20
+ status: 'rejected',
21
+ reason: reasons.get(command.ref) ?? fallback,
22
+ }));
23
+ }
24
+
25
+ /**
26
+ * Reads up to `maxBytes` of a storage host's receive-pack response (one branch of a tee) and
27
+ * turns its report-status into per-ref outcomes. When the response is larger, unreadable or not a
28
+ * report, every ref is "unknown". Never throws.
29
+ */
30
+ export async function readPushOutcomes(
31
+ stream: ReadableStream<Uint8Array>,
32
+ request: ReceivePackRequest,
33
+ maxBytes: number,
34
+ ): Promise<AuditRefOutcome[]> {
35
+ const reader = stream.getReader();
36
+ const chunks: Uint8Array[] = [];
37
+ let total = 0;
38
+ try {
39
+ for (let next = await reader.read(); !next.done; next = await reader.read()) {
40
+ total += next.value.length;
41
+ if (total > maxBytes) {
42
+ await reader.cancel();
43
+ return unknownOutcomes(request);
44
+ }
45
+ chunks.push(next.value);
46
+ }
47
+ const report = parseReportStatus(concatBytes(chunks), reportStatusFraming(request.capabilities));
48
+ const byRef = new Map(report.refs.map((status) => [status.ref, status]));
49
+ return request.commands.map((command) => {
50
+ const status = byRef.get(command.ref);
51
+ if (status === undefined) return { ...command, status: 'unknown', reason: null };
52
+ if (status.status === 'ok' && report.unpack === 'ok') return { ...command, status: 'ok', reason: null };
53
+ const reason = status.status === 'ng' ? status.reason : `unpack failed: ${report.unpack}`;
54
+ return { ...command, status: 'rejected', reason: reason.slice(0, 1000) };
55
+ });
56
+ } catch {
57
+ await reader.cancel().catch(() => undefined);
58
+ return unknownOutcomes(request);
59
+ }
60
+ }
@@ -0,0 +1,68 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { Principal } from '@leed-ai/git-gateway-contract/proxy/principal';
3
+ import type { MiddlewareHandler } from 'hono';
4
+
5
+ import type { GatewayDeps } from '../proxy/gateway-deps.ts';
6
+ import type { GatewayEnv } from '../proxy/gateway-env.ts';
7
+ import { textResponse, unauthorized } from '../proxy/git-responses.ts';
8
+ import {
9
+ credentialFingerprint,
10
+ readCredential,
11
+ } from '@leed-ai/git-gateway-contract/proxy/request-credential';
12
+
13
+ /** Milliseconds a decision about `principal` may be cached: the configured TTL, never past its expiry. */
14
+ export function decisionTtl(deps: GatewayDeps, principal: Principal): number {
15
+ if (principal.expiresAt === null) return deps.cacheTtlMs;
16
+ return Math.min(deps.cacheTtlMs, Date.parse(principal.expiresAt) - deps.now().getTime());
17
+ }
18
+
19
+ const expired = (deps: GatewayDeps, principal: Principal): boolean =>
20
+ principal.expiresAt !== null && Date.parse(principal.expiresAt) <= deps.now().getTime();
21
+
22
+ /**
23
+ * Authentication middleware: establishes the request's principal with the deployment's
24
+ * Authenticator, through the decision cache (keyed by a SHA-256 fingerprint of the credential,
25
+ * never the credential). No principal — or one whose credential has expired — answers 401 with
26
+ * `WWW-Authenticate: Basic`, so git asks its credential helper and retries.
27
+ */
28
+ export function authenticate(deps: GatewayDeps): MiddlewareHandler<GatewayEnv> {
29
+ return async (context, next) => {
30
+ const requestId = context.get('requestId');
31
+ const credential = readCredential(context.req.raw);
32
+ const key = credential === null ? null : `authn:${await credentialFingerprint(credential)}`;
33
+ const cached = key === null ? undefined : deps.cache.get(key);
34
+ let principal = cached?.kind === 'principal' ? cached.principal : null;
35
+ if (principal === null) {
36
+ try {
37
+ const found = await deps.authenticator.authenticate(context.req.raw);
38
+ principal = found === null ? null : Principal.parse(found);
39
+ } catch (error) {
40
+ deps.logger.log({
41
+ level: 'error',
42
+ message: 'authenticator failed',
43
+ requestId,
44
+ error: error instanceof Error ? error.message : String(error),
45
+ });
46
+ return textResponse(503, 'Authentication is unavailable; try again later', {
47
+ 'X-Request-Id': requestId,
48
+ });
49
+ }
50
+ if (principal !== null && key !== null && !expired(deps, principal)) {
51
+ deps.cache.set(key, { kind: 'principal', principal }, decisionTtl(deps, principal));
52
+ }
53
+ }
54
+ if (principal === null || expired(deps, principal)) {
55
+ deps.logger.log({
56
+ level: 'info',
57
+ message: 'authentication required',
58
+ requestId,
59
+ credential: credential === null ? 'none' : principal === null ? 'rejected' : 'expired',
60
+ });
61
+ const response = unauthorized(deps.config.realm);
62
+ response.headers.set('X-Request-Id', requestId);
63
+ return response;
64
+ }
65
+ context.set('principal', principal);
66
+ return next();
67
+ };
68
+ }
@@ -0,0 +1,57 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import type { MiddlewareHandler } from 'hono';
3
+
4
+ import type { GatewayDeps } from '../proxy/gateway-deps.ts';
5
+ import type { GatewayEnv } from '../proxy/gateway-env.ts';
6
+ import { deferWith } from '../proxy/defer.ts';
7
+ import { errResponse, textResponse } from '../proxy/git-responses.ts';
8
+ import { decisionTtl } from './authenticate.ts';
9
+
10
+ /**
11
+ * Authorization middleware: asks the deployment's Authorizer whether the principal may read
12
+ * (fetch) or write (push) the repository, through the decision cache keyed by principal subject
13
+ * and roles, repository and operation. A refusal is audited and answered as `smartHttp.deniedStatus`
14
+ * says: in-protocol with an "ERR" packet (default), so git prints "remote error: …", or HTTP 403
15
+ * with the reason as the body.
16
+ */
17
+ export function authorize(deps: GatewayDeps): MiddlewareHandler<GatewayEnv> {
18
+ return async (context, next) => {
19
+ const requestId = context.get('requestId');
20
+ const principal = context.get('principal');
21
+ const git = context.get('git');
22
+ const key = `authz:${principal.subject}\u0000${principal.roles.join(' ')}\u0000${git.repo}\u0000${git.operation}`;
23
+ const cached = deps.cache.get(key);
24
+ let allowed = cached?.kind === 'allowed' ? cached.allowed : null;
25
+ if (allowed === null) {
26
+ try {
27
+ allowed = await deps.authorizer.authorize(principal, git.repo, git.operation);
28
+ } catch (error) {
29
+ deps.logger.log({
30
+ level: 'error',
31
+ message: 'authorizer failed',
32
+ requestId,
33
+ error: error instanceof Error ? error.message : String(error),
34
+ });
35
+ return textResponse(503, 'Authorization is unavailable; try again later', {
36
+ 'X-Request-Id': requestId,
37
+ });
38
+ }
39
+ deps.cache.set(key, { kind: 'allowed', allowed }, decisionTtl(deps, principal));
40
+ }
41
+ if (!allowed) {
42
+ const reason = `access denied: ${principal.subject} may not ${git.operation === 'read' ? 'read' : 'push to'} ${git.repo}`;
43
+ deps.audit.record(
44
+ { requestId, principal, git, outcome: 'denied', reason, refs: [] },
45
+ deferWith(context),
46
+ requestId,
47
+ );
48
+ if (deps.config.deniedStatus === 403) {
49
+ return textResponse(403, reason, { 'X-Request-Id': requestId });
50
+ }
51
+ const response = errResponse(git.service, git.endpoint === 'info-refs' ? 'info-refs' : 'rpc', reason);
52
+ response.headers.set('X-Request-Id', requestId);
53
+ return response;
54
+ }
55
+ return next();
56
+ };
57
+ }