@leitwerk-dev/git-ssh 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -5
- package/dist/index.js +45 -43
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/index.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { LeitwerkExtensionModule, GitSshCredentialMaterial } from '@leitwerk-dev/process-sdk';
|
|
2
|
+
|
|
3
|
+
declare const manifest: {
|
|
3
4
|
readonly id: "git-ssh";
|
|
4
5
|
readonly version: "0.1.0";
|
|
5
6
|
};
|
|
6
7
|
declare function parseProfiles(raw: unknown): Map<string, GitSshCredentialMaterial>;
|
|
7
8
|
declare const extension: LeitwerkExtensionModule;
|
|
8
|
-
|
|
9
|
-
export default
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
9
|
+
|
|
10
|
+
export { extension as default, manifest, parseProfiles };
|
package/dist/index.js
CHANGED
|
@@ -1,47 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
coreHostCapabilities
|
|
4
|
+
} from "@leitwerk-dev/process-sdk";
|
|
5
|
+
var manifest = { id: "git-ssh", version: "0.1.0" };
|
|
3
6
|
function parseProfiles(raw) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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;
|
|
7
|
+
const root = raw && typeof raw === "object" ? raw : {};
|
|
8
|
+
const credentials = root.credentials && typeof root.credentials === "object" ? root.credentials : {};
|
|
9
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
10
|
+
for (const [ref, value] of Object.entries(credentials)) {
|
|
11
|
+
const profile = value && typeof value === "object" ? value : {};
|
|
12
|
+
const privateKey = typeof profile.private_key === "string" ? profile.private_key.trim() : "";
|
|
13
|
+
const knownHosts = typeof profile.known_hosts === "string" ? profile.known_hosts.trim() : "";
|
|
14
|
+
if (!privateKey.includes("BEGIN OPENSSH PRIVATE KEY"))
|
|
15
|
+
throw new Error(`Invalid git_ssh credential '${ref}': an OpenSSH private key is required`);
|
|
16
|
+
const encodedBody = privateKey.split(/\r?\n/).filter((line) => !line.startsWith("-----")).join("");
|
|
17
|
+
const decodedHeader = Buffer.from(encodedBody, "base64").subarray(0, 96).toString("latin1");
|
|
18
|
+
if (/ENCRYPTED/.test(privateKey) || decodedHeader.includes("bcrypt"))
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Invalid git_ssh credential '${ref}': encrypted keys requiring a passphrase are unsupported`
|
|
21
|
+
);
|
|
22
|
+
const hostLines = knownHosts.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
23
|
+
if (hostLines.length === 0 || hostLines.some((line) => line.split(/\s+/).length < 3))
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Invalid git_ssh credential '${ref}': pinned known_hosts entries are required`
|
|
26
|
+
);
|
|
27
|
+
profiles.set(ref, { privateKey, knownHosts });
|
|
28
|
+
}
|
|
29
|
+
return profiles;
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
var extension = {
|
|
32
|
+
manifest,
|
|
33
|
+
setupServer(api, config) {
|
|
34
|
+
const deps = api.get(coreHostCapabilities.serverSetup);
|
|
35
|
+
if (!deps || Array.isArray(deps)) return;
|
|
36
|
+
const profiles = parseProfiles(config);
|
|
37
|
+
deps.repositoryCredentials.register({
|
|
38
|
+
kind: "git_ssh",
|
|
39
|
+
resolve: (ref) => profiles.get(ref) ?? null
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var index_default = extension;
|
|
44
|
+
export {
|
|
45
|
+
index_default as default,
|
|
46
|
+
manifest,
|
|
47
|
+
parseProfiles
|
|
44
48
|
};
|
|
45
|
-
export { parseProfiles };
|
|
46
|
-
export default extension;
|
|
47
49
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n\tcoreHostCapabilities,\n\ttype GitSshCredentialMaterial,\n\ttype LeitwerkExtensionModule,\n} from \"@leitwerk-dev/process-sdk\";\n\nexport const manifest = { id: \"git-ssh\", version: \"0.1.0\" } as const;\n\nfunction parseProfiles(raw: unknown): Map<string, GitSshCredentialMaterial> {\n\tconst root = raw && typeof raw === \"object\" ? (raw as Record<string, unknown>) : {};\n\tconst credentials =\n\t\troot.credentials && typeof root.credentials === \"object\"\n\t\t\t? (root.credentials as Record<string, unknown>)\n\t\t\t: {};\n\tconst profiles = new Map<string, GitSshCredentialMaterial>();\n\tfor (const [ref, value] of Object.entries(credentials)) {\n\t\tconst profile = value && typeof value === \"object\" ? (value as Record<string, unknown>) : {};\n\t\tconst privateKey = typeof profile.private_key === \"string\" ? profile.private_key.trim() : \"\";\n\t\tconst knownHosts = typeof profile.known_hosts === \"string\" ? profile.known_hosts.trim() : \"\";\n\t\tif (!privateKey.includes(\"BEGIN OPENSSH PRIVATE KEY\"))\n\t\t\tthrow new Error(`Invalid git_ssh credential '${ref}': an OpenSSH private key is required`);\n\t\tconst encodedBody = privateKey\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.filter((line) => !line.startsWith(\"-----\"))\n\t\t\t.join(\"\");\n\t\tconst decodedHeader = Buffer.from(encodedBody, \"base64\").subarray(0, 96).toString(\"latin1\");\n\t\tif (/ENCRYPTED/.test(privateKey) || decodedHeader.includes(\"bcrypt\"))\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid git_ssh credential '${ref}': encrypted keys requiring a passphrase are unsupported`,\n\t\t\t);\n\t\tconst hostLines = knownHosts\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((line) => line.trim())\n\t\t\t.filter((line) => line && !line.startsWith(\"#\"));\n\t\tif (hostLines.length === 0 || hostLines.some((line) => line.split(/\\s+/).length < 3))\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid git_ssh credential '${ref}': pinned known_hosts entries are required`,\n\t\t\t);\n\t\tprofiles.set(ref, { privateKey, knownHosts });\n\t}\n\treturn profiles;\n}\n\nconst extension: LeitwerkExtensionModule = {\n\tmanifest,\n\tsetupServer(api, config) {\n\t\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\t\tif (!deps || Array.isArray(deps)) return;\n\t\tconst profiles = parseProfiles(config);\n\t\tdeps.repositoryCredentials.register({\n\t\t\tkind: \"git_ssh\",\n\t\t\tresolve: (ref) => profiles.get(ref) ?? null,\n\t\t});\n\t},\n};\n\nexport { parseProfiles };\nexport default extension;\n"],"mappings":";AAAA;AAAA,EACC;AAAA,OAGM;AAEA,IAAM,WAAW,EAAE,IAAI,WAAW,SAAS,QAAQ;AAE1D,SAAS,cAAc,KAAqD;AAC3E,QAAM,OAAO,OAAO,OAAO,QAAQ,WAAY,MAAkC,CAAC;AAClF,QAAM,cACL,KAAK,eAAe,OAAO,KAAK,gBAAgB,WAC5C,KAAK,cACN,CAAC;AACL,QAAM,WAAW,oBAAI,IAAsC;AAC3D,aAAW,C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M;AAAA,MACN,SAAS,CAAC,QAAQ,SAAS,IAAI,GAAG,KAAK;AAAA,IACxC,CAAC;AAAA,EACF;AACD;AAGA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leitwerk-dev/git-ssh",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/leitwerk-dev/leitwerk.git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "tsup --silent"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@leitwerk-dev/process-sdk": "0.1.
|
|
28
|
+
"@leitwerk-dev/process-sdk": "0.1.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"tsup": "^8.5.1"
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|