@trebired/git-host 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 (212) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/LICENSE +21 -0
  3. package/README.md +451 -0
  4. package/dist/api/handler/action.d.ts +5 -0
  5. package/dist/api/handler/action.d.ts.map +1 -0
  6. package/dist/api/handler/action.js +47 -0
  7. package/dist/api/handler/action.js.map +1 -0
  8. package/dist/api/handler/response.d.ts +34 -0
  9. package/dist/api/handler/response.d.ts.map +1 -0
  10. package/dist/api/handler/response.js +87 -0
  11. package/dist/api/handler/response.js.map +1 -0
  12. package/dist/api/handler/route.d.ts +15 -0
  13. package/dist/api/handler/route.d.ts.map +1 -0
  14. package/dist/api/handler/route.js +51 -0
  15. package/dist/api/handler/route.js.map +1 -0
  16. package/dist/api/handler.d.ts +6 -0
  17. package/dist/api/handler.d.ts.map +1 -0
  18. package/dist/api/handler.js +117 -0
  19. package/dist/api/handler.js.map +1 -0
  20. package/dist/constants.d.ts +8 -0
  21. package/dist/constants.d.ts.map +1 -0
  22. package/dist/constants.js +16 -0
  23. package/dist/constants.js.map +1 -0
  24. package/dist/core/create_git_host/branch_methods.d.ts +5 -0
  25. package/dist/core/create_git_host/branch_methods.d.ts.map +1 -0
  26. package/dist/core/create_git_host/branch_methods.js +137 -0
  27. package/dist/core/create_git_host/branch_methods.js.map +1 -0
  28. package/dist/core/create_git_host/content_methods.d.ts +5 -0
  29. package/dist/core/create_git_host/content_methods.d.ts.map +1 -0
  30. package/dist/core/create_git_host/content_methods.js +24 -0
  31. package/dist/core/create_git_host/content_methods.js.map +1 -0
  32. package/dist/core/create_git_host/remote_methods.d.ts +5 -0
  33. package/dist/core/create_git_host/remote_methods.d.ts.map +1 -0
  34. package/dist/core/create_git_host/remote_methods.js +48 -0
  35. package/dist/core/create_git_host/remote_methods.js.map +1 -0
  36. package/dist/core/create_git_host/shared.d.ts +21 -0
  37. package/dist/core/create_git_host/shared.d.ts.map +1 -0
  38. package/dist/core/create_git_host/shared.js +17 -0
  39. package/dist/core/create_git_host/shared.js.map +1 -0
  40. package/dist/core/create_git_host/working_tree_methods.d.ts +5 -0
  41. package/dist/core/create_git_host/working_tree_methods.d.ts.map +1 -0
  42. package/dist/core/create_git_host/working_tree_methods.js +63 -0
  43. package/dist/core/create_git_host/working_tree_methods.js.map +1 -0
  44. package/dist/core/create_git_host.d.ts +4 -0
  45. package/dist/core/create_git_host.d.ts.map +1 -0
  46. package/dist/core/create_git_host.js +167 -0
  47. package/dist/core/create_git_host.js.map +1 -0
  48. package/dist/core/inspect/helpers.d.ts +27 -0
  49. package/dist/core/inspect/helpers.d.ts.map +1 -0
  50. package/dist/core/inspect/helpers.js +86 -0
  51. package/dist/core/inspect/helpers.js.map +1 -0
  52. package/dist/core/inspect.d.ts +17 -0
  53. package/dist/core/inspect.d.ts.map +1 -0
  54. package/dist/core/inspect.js +174 -0
  55. package/dist/core/inspect.js.map +1 -0
  56. package/dist/core/locks.d.ts +5 -0
  57. package/dist/core/locks.d.ts.map +1 -0
  58. package/dist/core/locks.js +27 -0
  59. package/dist/core/locks.js.map +1 -0
  60. package/dist/core/operation_state.d.ts +4 -0
  61. package/dist/core/operation_state.d.ts.map +1 -0
  62. package/dist/core/operation_state.js +51 -0
  63. package/dist/core/operation_state.js.map +1 -0
  64. package/dist/core/remote.d.ts +13 -0
  65. package/dist/core/remote.d.ts.map +1 -0
  66. package/dist/core/remote.js +187 -0
  67. package/dist/core/remote.js.map +1 -0
  68. package/dist/core/repository/parsers.d.ts +12 -0
  69. package/dist/core/repository/parsers.d.ts.map +1 -0
  70. package/dist/core/repository/parsers.js +181 -0
  71. package/dist/core/repository/parsers.js.map +1 -0
  72. package/dist/core/repository.d.ts +11 -0
  73. package/dist/core/repository.d.ts.map +1 -0
  74. package/dist/core/repository.js +81 -0
  75. package/dist/core/repository.js.map +1 -0
  76. package/dist/core/run_git/env.d.ts +7 -0
  77. package/dist/core/run_git/env.d.ts.map +1 -0
  78. package/dist/core/run_git/env.js +18 -0
  79. package/dist/core/run_git/env.js.map +1 -0
  80. package/dist/core/run_git/process.d.ts +13 -0
  81. package/dist/core/run_git/process.d.ts.map +1 -0
  82. package/dist/core/run_git/process.js +96 -0
  83. package/dist/core/run_git/process.js.map +1 -0
  84. package/dist/core/run_git/repository_setup.d.ts +20 -0
  85. package/dist/core/run_git/repository_setup.d.ts.map +1 -0
  86. package/dist/core/run_git/repository_setup.js +116 -0
  87. package/dist/core/run_git/repository_setup.js.map +1 -0
  88. package/dist/core/run_git.d.ts +6 -0
  89. package/dist/core/run_git.d.ts.map +1 -0
  90. package/dist/core/run_git.js +6 -0
  91. package/dist/core/run_git.js.map +1 -0
  92. package/dist/core/working_tree/mutate.d.ts +9 -0
  93. package/dist/core/working_tree/mutate.d.ts.map +1 -0
  94. package/dist/core/working_tree/mutate.js +159 -0
  95. package/dist/core/working_tree/mutate.js.map +1 -0
  96. package/dist/core/working_tree/read.d.ts +6 -0
  97. package/dist/core/working_tree/read.d.ts.map +1 -0
  98. package/dist/core/working_tree/read.js +108 -0
  99. package/dist/core/working_tree/read.js.map +1 -0
  100. package/dist/core/working_tree/shared.d.ts +20 -0
  101. package/dist/core/working_tree/shared.d.ts.map +1 -0
  102. package/dist/core/working_tree/shared.js +87 -0
  103. package/dist/core/working_tree/shared.js.map +1 -0
  104. package/dist/core/working_tree.d.ts +3 -0
  105. package/dist/core/working_tree.d.ts.map +1 -0
  106. package/dist/core/working_tree.js +3 -0
  107. package/dist/core/working_tree.js.map +1 -0
  108. package/dist/errors.d.ts +10 -0
  109. package/dist/errors.d.ts.map +1 -0
  110. package/dist/errors.js +13 -0
  111. package/dist/errors.js.map +1 -0
  112. package/dist/http/handler/helpers.d.ts +35 -0
  113. package/dist/http/handler/helpers.d.ts.map +1 -0
  114. package/dist/http/handler/helpers.js +146 -0
  115. package/dist/http/handler/helpers.js.map +1 -0
  116. package/dist/http/handler.d.ts +6 -0
  117. package/dist/http/handler.d.ts.map +1 -0
  118. package/dist/http/handler.js +208 -0
  119. package/dist/http/handler.js.map +1 -0
  120. package/dist/index.d.ts +18 -0
  121. package/dist/index.d.ts.map +1 -0
  122. package/dist/index.js +15 -0
  123. package/dist/index.js.map +1 -0
  124. package/dist/logging.d.ts +4 -0
  125. package/dist/logging.d.ts.map +1 -0
  126. package/dist/logging.js +134 -0
  127. package/dist/logging.js.map +1 -0
  128. package/dist/react/client/error.d.ts +14 -0
  129. package/dist/react/client/error.d.ts.map +1 -0
  130. package/dist/react/client/error.js +32 -0
  131. package/dist/react/client/error.js.map +1 -0
  132. package/dist/react/client/helpers.d.ts +12 -0
  133. package/dist/react/client/helpers.d.ts.map +1 -0
  134. package/dist/react/client/helpers.js +45 -0
  135. package/dist/react/client/helpers.js.map +1 -0
  136. package/dist/react/client/types.d.ts +61 -0
  137. package/dist/react/client/types.d.ts.map +1 -0
  138. package/dist/react/client/types.js +2 -0
  139. package/dist/react/client/types.js.map +1 -0
  140. package/dist/react/client.d.ts +6 -0
  141. package/dist/react/client.d.ts.map +1 -0
  142. package/dist/react/client.js +115 -0
  143. package/dist/react/client.js.map +1 -0
  144. package/dist/react/hooks/query.d.ts +10 -0
  145. package/dist/react/hooks/query.d.ts.map +1 -0
  146. package/dist/react/hooks/query.js +74 -0
  147. package/dist/react/hooks/query.js.map +1 -0
  148. package/dist/react/hooks/resources.d.ts +11 -0
  149. package/dist/react/hooks/resources.d.ts.map +1 -0
  150. package/dist/react/hooks/resources.js +113 -0
  151. package/dist/react/hooks/resources.js.map +1 -0
  152. package/dist/react/hooks/types.d.ts +40 -0
  153. package/dist/react/hooks/types.d.ts.map +1 -0
  154. package/dist/react/hooks/types.js +2 -0
  155. package/dist/react/hooks/types.js.map +1 -0
  156. package/dist/react/hooks.d.ts +4 -0
  157. package/dist/react/hooks.d.ts.map +1 -0
  158. package/dist/react/hooks.js +3 -0
  159. package/dist/react/hooks.js.map +1 -0
  160. package/dist/react/index.d.ts +5 -0
  161. package/dist/react/index.d.ts.map +1 -0
  162. package/dist/react/index.js +3 -0
  163. package/dist/react/index.js.map +1 -0
  164. package/dist/ssh/keys.d.ts +18 -0
  165. package/dist/ssh/keys.d.ts.map +1 -0
  166. package/dist/ssh/keys.js +41 -0
  167. package/dist/ssh/keys.js.map +1 -0
  168. package/dist/ssh/server/audit.d.ts +5 -0
  169. package/dist/ssh/server/audit.d.ts.map +1 -0
  170. package/dist/ssh/server/audit.js +21 -0
  171. package/dist/ssh/server/audit.js.map +1 -0
  172. package/dist/ssh/server/shared.d.ts +30 -0
  173. package/dist/ssh/server/shared.d.ts.map +1 -0
  174. package/dist/ssh/server/shared.js +93 -0
  175. package/dist/ssh/server/shared.js.map +1 -0
  176. package/dist/ssh/server.d.ts +5 -0
  177. package/dist/ssh/server.d.ts.map +1 -0
  178. package/dist/ssh/server.js +265 -0
  179. package/dist/ssh/server.js.map +1 -0
  180. package/dist/types/common.d.ts +32 -0
  181. package/dist/types/common.d.ts.map +1 -0
  182. package/dist/types/common.js +2 -0
  183. package/dist/types/common.js.map +1 -0
  184. package/dist/types/host.d.ts +142 -0
  185. package/dist/types/host.d.ts.map +1 -0
  186. package/dist/types/host.js +2 -0
  187. package/dist/types/host.js.map +1 -0
  188. package/dist/types/index.d.ts +5 -0
  189. package/dist/types/index.d.ts.map +1 -0
  190. package/dist/types/index.js +2 -0
  191. package/dist/types/index.js.map +1 -0
  192. package/dist/types/repository.d.ts +163 -0
  193. package/dist/types/repository.d.ts.map +1 -0
  194. package/dist/types/repository.js +2 -0
  195. package/dist/types/repository.js.map +1 -0
  196. package/dist/types/transports.d.ts +156 -0
  197. package/dist/types/transports.d.ts.map +1 -0
  198. package/dist/types/transports.js +2 -0
  199. package/dist/types/transports.js.map +1 -0
  200. package/dist/types.d.ts +2 -0
  201. package/dist/types.d.ts.map +1 -0
  202. package/dist/types.js +2 -0
  203. package/dist/types.js.map +1 -0
  204. package/dist/utils/paths.d.ts +10 -0
  205. package/dist/utils/paths.d.ts.map +1 -0
  206. package/dist/utils/paths.js +51 -0
  207. package/dist/utils/paths.js.map +1 -0
  208. package/dist/utils/text.d.ts +4 -0
  209. package/dist/utils/text.d.ts.map +1 -0
  210. package/dist/utils/text.js +10 -0
  211. package/dist/utils/text.js.map +1 -0
  212. package/package.json +81 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/working_tree/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,QAAQ,EACR,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,KAAK,UAAU,yBAAyB,CAAC,UAA+B;IACtE,MAAM,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAExC,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACvG,oBAAoB,CAAC,UAAU,CAAC,IAAI,CAAC;QACrC,MAAM,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;QACrF,MAAM,CAAC,CAAC,MAAM,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;QACzE,MAAM,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,gBAAgB,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,IAAI,EAAE,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AI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC3B,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;QACvC,MAAM,EAAE,QAAQ;QAChB,GAAG,iBAAiB,CAAC,UAAU,CAAC,MAAM,CAAC;KACxC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,0BAA0B,CACvC,UAA+B,EAC/B,OAAmC;IAEnC,MAAM,qBAAqB,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,yBAAyB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAEhE,OAAO;QACL,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO,CAAC,UAAU;QACxB,MAAM,EAAE,UAAU;QAClB,GAAG,iBAAiB,CAAC,OAAO,CAAC;KAC9B,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { GitFileContent, GitRepositoryHandle, GitWorkingTree, GitWorkingTreeEntry, ReadWorkingTreeFileOptions } from "../../types.js";
2
+ declare function normalizePathList(input: unknown): string[];
3
+ declare function withEntryStats(entries: GitWorkingTree["status"]["entries"], stagedStats: Map<string, {
4
+ lines_added: number;
5
+ lines_removed: number;
6
+ }>, unstagedStats: Map<string, {
7
+ lines_added: number;
8
+ lines_removed: number;
9
+ }>): GitWorkingTreeEntry[];
10
+ declare function sumLines(entries: GitWorkingTreeEntry[], addedKey: "staged_lines_added" | "unstaged_lines_added", removedKey: "staged_lines_removed" | "unstaged_lines_removed"): {
11
+ lines_added: number;
12
+ lines_removed: number;
13
+ };
14
+ declare function decodeFileContent(stdout: Buffer): Pick<GitFileContent, "content" | "encoding" | "is_binary">;
15
+ declare function assertRepositoryReady(repository: GitRepositoryHandle): Promise<void>;
16
+ declare function repositoryHasHead(workspaceRoot: string): Promise<boolean>;
17
+ declare function normalizeFilePath(options: ReadWorkingTreeFileOptions | undefined): string;
18
+ declare function readWorkingTreeFileBuffer(repository: GitRepositoryHandle, filePath: string): Buffer;
19
+ export { assertRepositoryReady, decodeFileContent, normalizeFilePath, normalizePathList, readWorkingTreeFileBuffer, repositoryHasHead, sumLines, withEntryStats, };
20
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/core/working_tree/shared.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAK3I,iBAAS,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAUnD;AAED,iBAAS,cAAc,CACrB,OAAO,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,EAC5C,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,EACxE,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,GACzE,mBAAmB,EAAE,CAYvB;AAED,iBAAS,QAAQ,CACf,OAAO,EAAE,mBAAmB,EAAE,EAC9B,QAAQ,EAAE,oBAAoB,GAAG,sBAAsB,EACvD,UAAU,EAAE,sBAAsB,GAAG,wBAAwB;;;EAM9D;AAED,iBAAS,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC,CAuBrG;AAED,iBAAe,qBAAqB,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQnF;AAED,iBAAe,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGxE;AAED,iBAAS,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,GAAG,SAAS,GAAG,MAAM,CAElF;AAED,iBAAS,yBAAyB,CAAC,UAAU,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAW5F;AAED,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB,EACjB,QAAQ,EACR,cAAc,GACf,CAAC"}
@@ -0,0 +1,87 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { GitHostError } from "../../errors.js";
4
+ import { normalizeRepositoryRelativePath } from "../../utils/paths.js";
5
+ import { text } from "../../utils/text.js";
6
+ import { repositoryExists, runGit } from "../run_git.js";
7
+ function normalizePathList(input) {
8
+ const values = Array.isArray(input) ? input : [input];
9
+ return Array.from(new Set(values
10
+ .map((value) => {
11
+ const raw = text(value);
12
+ return raw ? normalizeRepositoryRelativePath(raw) : "";
13
+ })
14
+ .filter(Boolean)));
15
+ }
16
+ function withEntryStats(entries, stagedStats, unstagedStats) {
17
+ return entries.map((entry) => {
18
+ const staged = stagedStats.get(entry.path) || { lines_added: 0, lines_removed: 0 };
19
+ const unstaged = unstagedStats.get(entry.path) || { lines_added: 0, lines_removed: 0 };
20
+ return {
21
+ ...entry,
22
+ staged_lines_added: Number(staged.lines_added) || 0,
23
+ staged_lines_removed: Number(staged.lines_removed) || 0,
24
+ unstaged_lines_added: Number(unstaged.lines_added) || 0,
25
+ unstaged_lines_removed: Number(unstaged.lines_removed) || 0,
26
+ };
27
+ });
28
+ }
29
+ function sumLines(entries, addedKey, removedKey) {
30
+ return entries.reduce((sum, entry) => ({
31
+ lines_added: sum.lines_added + (Number(entry[addedKey]) || 0),
32
+ lines_removed: sum.lines_removed + (Number(entry[removedKey]) || 0),
33
+ }), { lines_added: 0, lines_removed: 0 });
34
+ }
35
+ function decodeFileContent(stdout) {
36
+ if (stdout.includes(0)) {
37
+ return {
38
+ content: stdout.toString("base64"),
39
+ encoding: "base64",
40
+ is_binary: true,
41
+ };
42
+ }
43
+ const utf8 = stdout.toString("utf8");
44
+ if (Buffer.from(utf8, "utf8").equals(stdout)) {
45
+ return {
46
+ content: utf8,
47
+ encoding: "utf8",
48
+ is_binary: false,
49
+ };
50
+ }
51
+ return {
52
+ content: stdout.toString("base64"),
53
+ encoding: "base64",
54
+ is_binary: true,
55
+ };
56
+ }
57
+ async function assertRepositoryReady(repository) {
58
+ const hasRepo = await repositoryExists(repository.path);
59
+ if (!hasRepo) {
60
+ throw new GitHostError("repository_not_initialized", `Repository "${repository.id}" is not initialized.`, {
61
+ repositoryId: repository.id,
62
+ path: repository.path,
63
+ });
64
+ }
65
+ }
66
+ async function repositoryHasHead(workspaceRoot) {
67
+ const headRes = await runGit(["rev-parse", "--verify", "HEAD"], { cwd: workspaceRoot });
68
+ return headRes.ok === true;
69
+ }
70
+ function normalizeFilePath(options) {
71
+ return normalizeRepositoryRelativePath(options && options.path);
72
+ }
73
+ function readWorkingTreeFileBuffer(repository, filePath) {
74
+ const absolutePath = path.resolve(repository.path, ...filePath.split("/"));
75
+ try {
76
+ return fs.readFileSync(absolutePath);
77
+ }
78
+ catch (error) {
79
+ throw new GitHostError("git_command_failed", error instanceof Error ? error.message : "Failed to read working tree file.", {
80
+ path: filePath,
81
+ repositoryId: repository.id,
82
+ source: "unstaged",
83
+ });
84
+ }
85
+ }
86
+ export { assertRepositoryReady, decodeFileContent, normalizeFilePath, normalizePathList, readWorkingTreeFileBuffer, repositoryHasHead, sumLines, withEntryStats, };
87
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/core/working_tree/shared.ts"],"names":[],"mappings":"AA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,CAAC,OAAO,CAAC,CAAC,CAAC,mCAAmC,EAAE;YACzH,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,UAAU,CAAC,EAAE;YAC3B,MAAM,EAAE,UAAU;SACnB,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB,EACjB,QAAQ,EACR,cAAc,GACf,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { abortRepositoryOperation, commitRepository, continueRepositoryOperation, discardRepositoryPaths, stageRepositoryPaths, unstageRepositoryPaths, } from "./working_tree/mutate.js";
2
+ export { readRepositoryStagedFile, readRepositoryUnstagedFile, readRepositoryWorkingTree, } from "./working_tree/read.js";
3
+ //# sourceMappingURL=working_tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"working_tree.d.ts","sourceRoot":"","sources":["../../src/core/working_tree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,2BAA2B,EAC3B,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { abortRepositoryOperation, commitRepository, continueRepositoryOperation, discardRepositoryPaths, stageRepositoryPaths, unstageRepositoryPaths, } from "./working_tree/mutate.js";
2
+ export { readRepositoryStagedFile, readRepositoryUnstagedFile, readRepositoryWorkingTree, } from "./working_tree/read.js";
3
+ //# sourceMappingURL=working_tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"working_tree.js","sourceRoot":"","sources":["../../src/core/working_tree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,2BAA2B,EAC3B,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,10 @@
1
+ type GitHostErrorCode = "git_command_failed" | "invalid_branch_name" | "invalid_repository_path" | "repository_clone_target_not_empty" | "repository_not_found" | "repository_not_initialized";
2
+ declare class GitHostError extends Error {
3
+ code: GitHostErrorCode | string;
4
+ details: Record<string, unknown>;
5
+ constructor(code: GitHostErrorCode | string, message: string, details?: Record<string, unknown>);
6
+ }
7
+ declare function isGitHostError(value: unknown): value is GitHostError;
8
+ export { GitHostError, isGitHostError };
9
+ export type { GitHostErrorCode };
10
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GACjB,oBAAoB,GACpB,qBAAqB,GACrB,yBAAyB,GACzB,mCAAmC,GACnC,sBAAsB,GACtB,4BAA4B,CAAC;AAEjC,cAAM,YAAa,SAAQ,KAAK;IAC9B,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAErB,IAAI,EAAE,gBAAgB,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAMpG;AAED,iBAAS,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAE7D;AAED,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
package/dist/errors.js ADDED
@@ -0,0 +1,13 @@
1
+ class GitHostError extends Error {
2
+ constructor(code, message, details = {}) {
3
+ super(message);
4
+ this.name = "GitHostError";
5
+ this.code = code;
6
+ this.details = details;
7
+ }
8
+ }
9
+ function isGitHostError(value) {
10
+ return value instanceof GitHostError;
11
+ }
12
+ export { GitHostError, isGitHostError };
13
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAQA,MAAM,YAAa,SAAQ,KAAK;IAI9B,YAAY,IAA+B,EAAE,OAAe,EAAE,UAAmC,EAAE;QACjG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,KAAK,YAAY,YAAY,CAAC;AACvC,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import type { CreateGitHttpHandlerOptions, GitHttpAuthenticationResult, GitHttpAuditEvent, GitHttpAuthorizationResult, GitHttpResolvedRepository, GitHttpService, GitRepositoryHandle } from "../../types.js";
3
+ declare function parseGitHttpRoute(pathnameInput: unknown, basePathInput: unknown): {
4
+ repositoryKey: string;
5
+ repositoryPath: string;
6
+ suffix: string;
7
+ };
8
+ declare function requestedGitService(searchParams: URLSearchParams, suffixInput: unknown): GitHttpService;
9
+ declare function parseBackendHeaders(raw: string): {
10
+ headers: [string, string][];
11
+ statusCode: number;
12
+ };
13
+ declare function ensureHttpExportPath(repository: GitRepositoryHandle, exportNameInput: unknown): string;
14
+ declare function applyAuthorizationHeaders(res: ServerResponse, headers: Record<string, string> | undefined): void;
15
+ declare function normalizeAuthenticationResult(value: GitHttpAuthenticationResult | undefined): {
16
+ identity: unknown;
17
+ remoteUser: string;
18
+ };
19
+ declare function authorizationAllowed(value: GitHttpAuthorizationResult | undefined): {
20
+ allowed: boolean;
21
+ remoteUser: string;
22
+ status: number;
23
+ message: string;
24
+ headers?: undefined;
25
+ } | {
26
+ allowed: boolean;
27
+ headers: Record<string, string>;
28
+ message: string;
29
+ remoteUser: string;
30
+ status: number;
31
+ };
32
+ declare function emitHttpAuditEvent(onAuditEvent: ((event: GitHttpAuditEvent) => unknown) | undefined, event: GitHttpAuditEvent): void;
33
+ declare function resolveRepositoryResult(options: CreateGitHttpHandlerOptions, repositoryKey: string, request: IncomingMessage): Promise<GitHttpResolvedRepository | null>;
34
+ export { applyAuthorizationHeaders, authorizationAllowed, emitHttpAuditEvent, ensureHttpExportPath, normalizeAuthenticationResult, parseBackendHeaders, parseGitHttpRoute, requestedGitService, resolveRepositoryResult, };
35
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/http/handler/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAKjE,OAAO,KAAK,EACV,2BAA2B,EAC3B,2BAA2B,EAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,yBAAyB,EACzB,cAAc,EACd,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AASxB,iBAAS,iBAAiB,CAAC,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO;;;;EAsBxE;AAED,iBAAS,mBAAmB,CAAC,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,GAAG,cAAc,CAIhG;AAED,iBAAS,mBAAmB,CAAC,GAAG,EAAE,MAAM;;;EAmBvC;AAMD,iBAAS,oBAAoB,CAAC,UAAU,EAAE,mBAAmB,EAAE,eAAe,EAAE,OAAO,GAAG,MAAM,CAgC/F;AAED,iBAAS,yBAAyB,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,QAMlG;AAED,iBAAS,6BAA6B,CAAC,KAAK,EAAE,2BAA2B,GAAG,SAAS;;;EAGpF;AAED,iBAAS,oBAAoB,CAAC,KAAK,EAAE,0BAA0B,GAAG,SAAS;;;;;;;;;;;;EAW1E;AAED,iBAAS,kBAAkB,CAAC,YAAY,EAAE,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC,GAAG,SAAS,EAAE,KAAK,EAAE,iBAAiB,QAGtH;AAED,iBAAe,uBAAuB,CACpC,OAAO,EAAE,2BAA2B,EACpC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAgB3C;AAED,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,EAC7B,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,GACxB,CAAC"}
@@ -0,0 +1,146 @@
1
+ import { createHash } from "node:crypto";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { GitHostError } from "../../errors.js";
5
+ import { text } from "../../utils/text.js";
6
+ function normalizeBasePath(value) {
7
+ const next = text(value).replace(/\/+$/g, "");
8
+ if (!next || next === "/")
9
+ return "";
10
+ return next.startsWith("/") ? next : `/${next}`;
11
+ }
12
+ function parseGitHttpRoute(pathnameInput, basePathInput) {
13
+ const pathname = text(pathnameInput, "/");
14
+ const basePath = normalizeBasePath(basePathInput);
15
+ if (basePath && !pathname.startsWith(`${basePath}/`) && pathname !== basePath)
16
+ return null;
17
+ const remainder = basePath ? pathname.slice(basePath.length).replace(/^\/+/, "") : pathname.replace(/^\/+/, "");
18
+ if (!remainder)
19
+ return null;
20
+ const match = remainder.match(/^(.+\.git)(?:\/(.*))?$/);
21
+ if (!match)
22
+ return null;
23
+ const repositoryPath = String(match[1] || "");
24
+ const suffix = match[2] ? `/${match[2]}` : "";
25
+ let repositoryKey = "";
26
+ try {
27
+ repositoryKey = decodeURIComponent(repositoryPath.slice(0, -4));
28
+ }
29
+ catch {
30
+ return null;
31
+ }
32
+ return { repositoryKey, repositoryPath, suffix };
33
+ }
34
+ function requestedGitService(searchParams, suffixInput) {
35
+ const queryService = text(searchParams.get("service"));
36
+ if (queryService === "git-upload-pack" || queryService === "git-receive-pack")
37
+ return queryService;
38
+ return text(suffixInput).endsWith("/git-receive-pack") ? "git-receive-pack" : "git-upload-pack";
39
+ }
40
+ function parseBackendHeaders(raw) {
41
+ const lines = String(raw || "").split(/\r?\n/).filter(Boolean);
42
+ const headers = [];
43
+ let statusCode = 200;
44
+ for (const line of lines) {
45
+ const separator = line.indexOf(":");
46
+ if (separator <= 0)
47
+ continue;
48
+ const name = line.slice(0, separator).trim();
49
+ const value = line.slice(separator + 1).trim();
50
+ if (!name)
51
+ continue;
52
+ if (name.toLowerCase() === "status") {
53
+ statusCode = Number(value.split(/\s+/)[0]) || 200;
54
+ continue;
55
+ }
56
+ headers.push([name, value]);
57
+ }
58
+ return { headers, statusCode };
59
+ }
60
+ function sanitizeExportStem(value) {
61
+ return text(value).replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "repo";
62
+ }
63
+ function ensureHttpExportPath(repository, exportNameInput) {
64
+ const repositoryPath = path.resolve(repository.path);
65
+ if (repositoryPath.endsWith(".git"))
66
+ return repositoryPath;
67
+ const digest = createHash("sha1").update(repository.id).update("\0").update(repositoryPath).digest("hex").slice(0, 12);
68
+ const stem = sanitizeExportStem(exportNameInput || path.basename(repositoryPath));
69
+ const exportPath = path.join(path.dirname(repositoryPath), `.${stem}-git-host-${digest}.git`);
70
+ try {
71
+ if (fs.existsSync(exportPath)) {
72
+ const stat = fs.lstatSync(exportPath);
73
+ if (stat.isSymbolicLink()) {
74
+ const currentTarget = fs.readlinkSync(exportPath);
75
+ const resolvedTarget = path.resolve(path.dirname(exportPath), currentTarget);
76
+ if (resolvedTarget === repositoryPath)
77
+ return exportPath;
78
+ }
79
+ throw new GitHostError("invalid_repository_path", "Repository export path is occupied by a different filesystem entry.", {
80
+ exportPath,
81
+ repositoryId: repository.id,
82
+ });
83
+ }
84
+ fs.symlinkSync(repositoryPath, exportPath, "dir");
85
+ return exportPath;
86
+ }
87
+ catch (error) {
88
+ if (error instanceof GitHostError)
89
+ throw error;
90
+ throw new GitHostError("invalid_repository_path", "Failed to prepare the repository export path.", {
91
+ exportPath,
92
+ message: error instanceof Error ? error.message : String(error),
93
+ repositoryId: repository.id,
94
+ });
95
+ }
96
+ }
97
+ function applyAuthorizationHeaders(res, headers) {
98
+ const nextHeaders = headers && typeof headers === "object" ? headers : {};
99
+ for (const [name, value] of Object.entries(nextHeaders)) {
100
+ if (!name || typeof value !== "string")
101
+ continue;
102
+ res.setHeader(name, value);
103
+ }
104
+ }
105
+ function normalizeAuthenticationResult(value) {
106
+ if (value == null)
107
+ return { identity: undefined, remoteUser: "anonymous" };
108
+ return { identity: value.identity, remoteUser: text(value.remoteUser, "anonymous") };
109
+ }
110
+ function authorizationAllowed(value) {
111
+ if (value == null)
112
+ return { allowed: true, remoteUser: "", status: 200, message: "" };
113
+ if (typeof value === "boolean")
114
+ return { allowed: value, remoteUser: "", status: value ? 200 : 403, message: "" };
115
+ return {
116
+ allowed: value.allowed === true,
117
+ headers: value.headers,
118
+ message: text(value.message),
119
+ remoteUser: text(value.remoteUser, "anonymous"),
120
+ status: Number(value.status) || (value.allowed === true ? 200 : 403),
121
+ };
122
+ }
123
+ function emitHttpAuditEvent(onAuditEvent, event) {
124
+ if (typeof onAuditEvent !== "function")
125
+ return;
126
+ void Promise.resolve(onAuditEvent(event)).catch(() => { });
127
+ }
128
+ async function resolveRepositoryResult(options, repositoryKey, request) {
129
+ const resolved = await options.resolveRepository(repositoryKey, request);
130
+ if (!resolved)
131
+ return null;
132
+ if ("repository" in resolved) {
133
+ return {
134
+ exportName: resolved.exportName,
135
+ repository: resolved.repository,
136
+ repositoryKey: text(resolved.repositoryKey, repositoryKey),
137
+ };
138
+ }
139
+ return {
140
+ exportName: repositoryKey,
141
+ repository: resolved,
142
+ repositoryKey,
143
+ };
144
+ }
145
+ export { applyAuthorizationHeaders, authorizationAllowed, emitHttpAuditEvent, ensureHttpExportPath, normalizeAuthenticationResult, parseBackendHeaders, parseGitHttpRoute, requestedGitService, resolveRepositoryResult, };
146
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/http/handler/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAU/C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,SAAS,iBAAiB,CAAC,KAAc;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC9C,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;AAClD,CAAC;AAED,SAAS,iBAAiB,CAAC,aAAsB,EAAE,aAAsB;IACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAClD,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE3F,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,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AE,aAAa,CAAC;SAC3D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,QAAQ;QACpB,aAAa;KACd,CAAC;AACJ,CAAC;AAED,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,EAC7B,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,GACxB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import type { CreateGitHttpHandlerOptions } from "../types.js";
3
+ import { parseGitHttpRoute } from "./handler/helpers.js";
4
+ declare function createGitHttpHandler(options: CreateGitHttpHandlerOptions): (req: IncomingMessage, res: ServerResponse) => void;
5
+ export { createGitHttpHandler, parseGitHttpRoute };
6
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/http/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAKjE,OAAO,KAAK,EAAE,2BAA2B,EAAqB,MAAM,aAAa,CAAC;AAElF,OAAO,EAOL,iBAAiB,EAGlB,MAAM,sBAAsB,CAAC;AAyM9B,iBAAS,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,IAKjC,KAAK,eAAe,EAAE,KAAK,cAAc,UAMzE;AAED,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,208 @@
1
+ import { spawn } from "node:child_process";
2
+ import path from "node:path";
3
+ import { resolveLogger } from "../logging.js";
4
+ import { text } from "../utils/text.js";
5
+ import { applyAuthorizationHeaders, authorizationAllowed, emitHttpAuditEvent, ensureHttpExportPath, normalizeAuthenticationResult, parseBackendHeaders, parseGitHttpRoute, requestedGitService, resolveRepositoryResult, } from "./handler/helpers.js";
6
+ async function handleGitHttpRequest(req, res, options) {
7
+ const logger = resolveLogger(options.logger);
8
+ const verbose = options.verbose === true;
9
+ const logGroup = "git-host.http";
10
+ const url = new URL(String(req.url || "/"), "http://127.0.0.1");
11
+ const method = text(req.method).toUpperCase() || "GET";
12
+ const remoteAddress = text(req.socket && req.socket.remoteAddress);
13
+ const audit = {
14
+ method,
15
+ outcome: "failed",
16
+ pathname: url.pathname,
17
+ remoteAddress,
18
+ remoteUser: "anonymous",
19
+ status: 500,
20
+ wantsWrite: false,
21
+ };
22
+ let auditSent = false;
23
+ res.on("finish", () => {
24
+ if (auditSent)
25
+ return;
26
+ auditSent = true;
27
+ const status = Number(res.statusCode) || audit.status || 500;
28
+ let outcome = audit.outcome;
29
+ if (outcome === "failed" && status < 400)
30
+ outcome = "completed";
31
+ if (status === 404)
32
+ outcome = "not_found";
33
+ else if (status === 401 || status === 403)
34
+ outcome = "denied";
35
+ else if (status >= 400 && status < 500 && outcome === "failed")
36
+ outcome = "denied";
37
+ else if (status < 400)
38
+ outcome = "completed";
39
+ emitHttpAuditEvent(options.onAuditEvent, { ...audit, outcome, status });
40
+ const metadata = {
41
+ message: audit.message,
42
+ method,
43
+ outcome,
44
+ pathname: url.pathname,
45
+ remoteAddress,
46
+ remoteUser: audit.remoteUser,
47
+ repositoryKey: audit.repositoryKey,
48
+ service: audit.service,
49
+ status,
50
+ wantsWrite: audit.wantsWrite,
51
+ };
52
+ if (status >= 500)
53
+ logger.error(logGroup, "http git request failed", metadata);
54
+ else if (status >= 400)
55
+ logger.warn(logGroup, "http git request denied", metadata);
56
+ else if (verbose)
57
+ logger.info(logGroup, "http git request completed", metadata);
58
+ });
59
+ const route = parseGitHttpRoute(url.pathname, options.basePath);
60
+ if (!route) {
61
+ res.statusCode = 404;
62
+ audit.status = 404;
63
+ audit.message = "Not found.";
64
+ res.end("Not found.");
65
+ return;
66
+ }
67
+ audit.repositoryKey = route.repositoryKey;
68
+ const resolved = await resolveRepositoryResult(options, route.repositoryKey, req);
69
+ if (!resolved) {
70
+ res.statusCode = 404;
71
+ audit.status = 404;
72
+ audit.message = "Repository not found.";
73
+ res.end("Repository not found.");
74
+ return;
75
+ }
76
+ const repository = resolved.repository;
77
+ const exportPath = ensureHttpExportPath(repository, resolved.exportName || route.repositoryKey);
78
+ const service = requestedGitService(url.searchParams, route.suffix);
79
+ const wantsWrite = service === "git-receive-pack";
80
+ const repositoryKey = text(resolved.repositoryKey, route.repositoryKey);
81
+ audit.repository = repository;
82
+ audit.repositoryKey = repositoryKey;
83
+ audit.service = service;
84
+ audit.wantsWrite = wantsWrite;
85
+ const authn = normalizeAuthenticationResult(options.authenticate
86
+ ? await options.authenticate({
87
+ method,
88
+ pathname: url.pathname,
89
+ remoteAddress,
90
+ repository,
91
+ repositoryKey,
92
+ request: req,
93
+ searchParams: url.searchParams,
94
+ service,
95
+ wantsWrite,
96
+ })
97
+ : undefined);
98
+ audit.identity = authn.identity;
99
+ audit.remoteUser = authn.remoteUser;
100
+ const authResult = authorizationAllowed(options.authorize
101
+ ? await options.authorize({
102
+ identity: authn.identity,
103
+ method,
104
+ pathname: url.pathname,
105
+ remoteAddress,
106
+ remoteUser: authn.remoteUser,
107
+ repository,
108
+ repositoryKey,
109
+ request: req,
110
+ searchParams: url.searchParams,
111
+ service,
112
+ wantsWrite,
113
+ })
114
+ : undefined);
115
+ applyAuthorizationHeaders(res, authResult.headers);
116
+ if (!authResult.allowed) {
117
+ res.statusCode = authResult.status || 403;
118
+ audit.message = authResult.message || "Permission denied.";
119
+ audit.remoteUser = authResult.remoteUser || authn.remoteUser;
120
+ audit.status = res.statusCode;
121
+ res.end(authResult.message || "Permission denied.");
122
+ return;
123
+ }
124
+ audit.remoteUser = authResult.remoteUser || authn.remoteUser;
125
+ const child = spawn("git", ["http-backend"], {
126
+ env: {
127
+ ...process.env,
128
+ CONTENT_LENGTH: text(req.headers["content-length"]),
129
+ CONTENT_TYPE: text(req.headers["content-type"]),
130
+ GIT_HTTP_EXPORT_ALL: "1",
131
+ GIT_PROJECT_ROOT: path.dirname(exportPath),
132
+ PATH_INFO: `/${path.basename(exportPath)}${route.suffix}`,
133
+ QUERY_STRING: url.searchParams.toString(),
134
+ REMOTE_ADDR: remoteAddress,
135
+ REMOTE_USER: authResult.remoteUser || authn.remoteUser,
136
+ REQUEST_METHOD: method,
137
+ },
138
+ stdio: ["pipe", "pipe", "pipe"],
139
+ });
140
+ let stderr = "";
141
+ let headerBuffer = Buffer.alloc(0);
142
+ let headersSent = false;
143
+ child.stderr.on("data", (chunk) => {
144
+ stderr += String(chunk);
145
+ });
146
+ child.stdout.on("data", (chunk) => {
147
+ if (headersSent) {
148
+ res.write(chunk);
149
+ return;
150
+ }
151
+ headerBuffer = Buffer.concat([headerBuffer, chunk]);
152
+ let splitIndex = headerBuffer.indexOf(Buffer.from("\r\n\r\n"));
153
+ let splitSize = 4;
154
+ if (splitIndex < 0) {
155
+ splitIndex = headerBuffer.indexOf(Buffer.from("\n\n"));
156
+ splitSize = 2;
157
+ }
158
+ if (splitIndex < 0)
159
+ return;
160
+ const rawHeaders = headerBuffer.slice(0, splitIndex).toString("utf8");
161
+ const bodyChunk = headerBuffer.slice(splitIndex + splitSize);
162
+ const parsed = parseBackendHeaders(rawHeaders);
163
+ res.statusCode = parsed.statusCode;
164
+ for (const [name, value] of parsed.headers)
165
+ res.setHeader(name, value);
166
+ headersSent = true;
167
+ if (bodyChunk.length)
168
+ res.write(bodyChunk);
169
+ });
170
+ child.on("close", (code) => {
171
+ if (!headersSent) {
172
+ res.statusCode = 502;
173
+ audit.status = 502;
174
+ audit.message = text(stderr, `git-http-backend exited with code ${Number(code) || 0}`);
175
+ res.end(text(stderr, `git-http-backend exited with code ${Number(code) || 0}`));
176
+ return;
177
+ }
178
+ audit.status = res.statusCode || 200;
179
+ res.end();
180
+ });
181
+ child.on("error", (error) => {
182
+ const message = error && error.message ? String(error.message) : "Failed to start git-http-backend.";
183
+ if (!headersSent) {
184
+ res.statusCode = 502;
185
+ audit.status = 502;
186
+ audit.message = message;
187
+ res.end(message);
188
+ return;
189
+ }
190
+ audit.status = res.statusCode || 502;
191
+ audit.message = message;
192
+ res.end();
193
+ });
194
+ req.pipe(child.stdin);
195
+ }
196
+ function createGitHttpHandler(options) {
197
+ if (!options || typeof options.resolveRepository !== "function") {
198
+ throw new TypeError("createGitHttpHandler() requires a resolveRepository() function.");
199
+ }
200
+ return function gitHttpHandler(req, res) {
201
+ void handleGitHttpRequest(req, res, options).catch((error) => {
202
+ res.statusCode = 500;
203
+ res.end(error instanceof Error ? error.message : "Git HTTP handler failed.");
204
+ });
205
+ };
206
+ }
207
+ export { createGitHttpHandler, parseGitHttpRoute };
208
+ //# sourceMappingURL=handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/http/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,EAC7B,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAE9B,KAAK,UAAU,oBAAoB,CAAC,GAAoB,EAAE,GAAmB,EAAE,OAAoC;IACjH,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC;IACzC,MAAM,QAAQ,GAAG,eAAe,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,kBAAkB,CAAC,CAAC;IAChE,MAAM,M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