@leitwerk-dev/git-ssh 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/README.md +3 -0
- package/dist/LICENSE +13 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
- package/src/index.ts +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# Git SSH
|
|
2
|
+
|
|
3
|
+
Provides pinned, non-interactive Git-over-SSH credential profiles to repository processes. Configure profiles under `extensions.git-ssh.credentials`. Private keys and `known_hosts` are delivered only in authenticated `worker.start` IPC; ambient SSH configuration and agents are not used.
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2026 Leitwerk contributors.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type GitSshCredentialMaterial, type LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
export declare const manifest: {
|
|
3
|
+
readonly id: "git-ssh";
|
|
4
|
+
readonly version: "0.1.0";
|
|
5
|
+
};
|
|
6
|
+
declare function parseProfiles(raw: unknown): Map<string, GitSshCredentialMaterial>;
|
|
7
|
+
declare const extension: LeitwerkExtensionModule;
|
|
8
|
+
export { parseProfiles };
|
|
9
|
+
export default extension;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,QAAQ;;;CAA+C,CAAC;AAErE,iBAAS,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAiC1E;AAED,QAAA,MAAM,SAAS,EAAE,uBAWhB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,eAAe,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { coreHostCapabilities, } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
export const manifest = { id: "git-ssh", version: "0.1.0" };
|
|
3
|
+
function parseProfiles(raw) {
|
|
4
|
+
const root = raw && typeof raw === "object" ? raw : {};
|
|
5
|
+
const credentials = root.credentials && typeof root.credentials === "object"
|
|
6
|
+
? root.credentials
|
|
7
|
+
: {};
|
|
8
|
+
const profiles = new Map();
|
|
9
|
+
for (const [ref, value] of Object.entries(credentials)) {
|
|
10
|
+
const profile = value && typeof value === "object" ? value : {};
|
|
11
|
+
const privateKey = typeof profile.private_key === "string" ? profile.private_key.trim() : "";
|
|
12
|
+
const knownHosts = typeof profile.known_hosts === "string" ? profile.known_hosts.trim() : "";
|
|
13
|
+
if (!privateKey.includes("BEGIN OPENSSH PRIVATE KEY"))
|
|
14
|
+
throw new Error(`Invalid git_ssh credential '${ref}': an OpenSSH private key is required`);
|
|
15
|
+
const encodedBody = privateKey
|
|
16
|
+
.split(/\r?\n/)
|
|
17
|
+
.filter((line) => !line.startsWith("-----"))
|
|
18
|
+
.join("");
|
|
19
|
+
const decodedHeader = Buffer.from(encodedBody, "base64").subarray(0, 96).toString("latin1");
|
|
20
|
+
if (/ENCRYPTED/.test(privateKey) || decodedHeader.includes("bcrypt"))
|
|
21
|
+
throw new Error(`Invalid git_ssh credential '${ref}': encrypted keys requiring a passphrase are unsupported`);
|
|
22
|
+
const hostLines = knownHosts
|
|
23
|
+
.split(/\r?\n/)
|
|
24
|
+
.map((line) => line.trim())
|
|
25
|
+
.filter((line) => line && !line.startsWith("#"));
|
|
26
|
+
if (hostLines.length === 0 || hostLines.some((line) => line.split(/\s+/).length < 3))
|
|
27
|
+
throw new Error(`Invalid git_ssh credential '${ref}': pinned known_hosts entries are required`);
|
|
28
|
+
profiles.set(ref, { privateKey, knownHosts });
|
|
29
|
+
}
|
|
30
|
+
return profiles;
|
|
31
|
+
}
|
|
32
|
+
const extension = {
|
|
33
|
+
manifest,
|
|
34
|
+
setupServer(api, config) {
|
|
35
|
+
const deps = api.get(coreHostCapabilities.serverSetup);
|
|
36
|
+
if (!deps || Array.isArray(deps))
|
|
37
|
+
return;
|
|
38
|
+
const profiles = parseProfiles(config);
|
|
39
|
+
deps.repositoryCredentials.register({
|
|
40
|
+
kind: "git_ssh",
|
|
41
|
+
resolve: (ref) => profiles.get(ref) ?? null,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export { parseProfiles };
|
|
46
|
+
export default extension;
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,GAGpB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAW,CAAC;AAErE,SAAS,aAAa,CAAC,GAAY;IAClC,MAAM,IAAI,GAAG,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAE,G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,CAAC,CAAC;IACJ,CAAC;CACD,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,eAAe,SAAS,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@leitwerk-dev/git-ssh",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/leitwerk-dev/leitwerk.git",
|
|
7
|
+
"directory": "extensions/git-ssh"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"leitwerk": {
|
|
11
|
+
"extension": {
|
|
12
|
+
"source": "./src/index.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"discover": false
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"source": "./src/index.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup --silent"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@leitwerk-dev/process-sdk": "0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"tsup": "^8.5.1"
|
|
32
|
+
},
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=22"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist/**",
|
|
42
|
+
"src/**",
|
|
43
|
+
"!dist/**/*.test.*",
|
|
44
|
+
"!src/**/*.test.ts"
|
|
45
|
+
]
|
|
46
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
coreHostCapabilities,
|
|
3
|
+
type GitSshCredentialMaterial,
|
|
4
|
+
type LeitwerkExtensionModule,
|
|
5
|
+
} from "@leitwerk-dev/process-sdk";
|
|
6
|
+
|
|
7
|
+
export const manifest = { id: "git-ssh", version: "0.1.0" } as const;
|
|
8
|
+
|
|
9
|
+
function parseProfiles(raw: unknown): Map<string, GitSshCredentialMaterial> {
|
|
10
|
+
const root = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
|
|
11
|
+
const credentials =
|
|
12
|
+
root.credentials && typeof root.credentials === "object"
|
|
13
|
+
? (root.credentials as Record<string, unknown>)
|
|
14
|
+
: {};
|
|
15
|
+
const profiles = new Map<string, GitSshCredentialMaterial>();
|
|
16
|
+
for (const [ref, value] of Object.entries(credentials)) {
|
|
17
|
+
const profile = value && typeof value === "object" ? (value as Record<string, unknown>) : {};
|
|
18
|
+
const privateKey = typeof profile.private_key === "string" ? profile.private_key.trim() : "";
|
|
19
|
+
const knownHosts = typeof profile.known_hosts === "string" ? profile.known_hosts.trim() : "";
|
|
20
|
+
if (!privateKey.includes("BEGIN OPENSSH PRIVATE KEY"))
|
|
21
|
+
throw new Error(`Invalid git_ssh credential '${ref}': an OpenSSH private key is required`);
|
|
22
|
+
const encodedBody = privateKey
|
|
23
|
+
.split(/\r?\n/)
|
|
24
|
+
.filter((line) => !line.startsWith("-----"))
|
|
25
|
+
.join("");
|
|
26
|
+
const decodedHeader = Buffer.from(encodedBody, "base64").subarray(0, 96).toString("latin1");
|
|
27
|
+
if (/ENCRYPTED/.test(privateKey) || decodedHeader.includes("bcrypt"))
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Invalid git_ssh credential '${ref}': encrypted keys requiring a passphrase are unsupported`,
|
|
30
|
+
);
|
|
31
|
+
const hostLines = knownHosts
|
|
32
|
+
.split(/\r?\n/)
|
|
33
|
+
.map((line) => line.trim())
|
|
34
|
+
.filter((line) => line && !line.startsWith("#"));
|
|
35
|
+
if (hostLines.length === 0 || hostLines.some((line) => line.split(/\s+/).length < 3))
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Invalid git_ssh credential '${ref}': pinned known_hosts entries are required`,
|
|
38
|
+
);
|
|
39
|
+
profiles.set(ref, { privateKey, knownHosts });
|
|
40
|
+
}
|
|
41
|
+
return profiles;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const extension: LeitwerkExtensionModule = {
|
|
45
|
+
manifest,
|
|
46
|
+
setupServer(api, config) {
|
|
47
|
+
const deps = api.get(coreHostCapabilities.serverSetup);
|
|
48
|
+
if (!deps || Array.isArray(deps)) return;
|
|
49
|
+
const profiles = parseProfiles(config);
|
|
50
|
+
deps.repositoryCredentials.register({
|
|
51
|
+
kind: "git_ssh",
|
|
52
|
+
resolve: (ref) => profiles.get(ref) ?? null,
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { parseProfiles };
|
|
58
|
+
export default extension;
|