@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 CHANGED
@@ -1,10 +1,10 @@
1
- import { type GitSshCredentialMaterial, type LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
2
- export declare const manifest: {
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
- export { parseProfiles };
9
- export default extension;
10
- //# sourceMappingURL=index.d.ts.map
9
+
10
+ export { extension as default, manifest, parseProfiles };
package/dist/index.js CHANGED
@@ -1,47 +1,49 @@
1
- import { coreHostCapabilities, } from "@leitwerk-dev/process-sdk";
2
- export const manifest = { id: "git-ssh", version: "0.1.0" };
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
- 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;
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
- 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
- },
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,"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,GAA+B,CAAC,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,WAAW,GAChB,IAAI,CAAC,WAAW,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ;QACvD,CAAC,CAAE,IAAI,CAAC,WAAuC;QAC/C,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoC,CAAC;IAC7D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC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AI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;QAClD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;YACnF,MAAM,IAAI,KAAK,CACd,+BAA+B,GAAG,4CAA4C,CAC9E,CAAC;QACH,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,MAAM,SAAS,GAA4B;IAC1C,QAAQ;IACR,WAAW,CAAC,GAAG,EAAE,MAAM;QACtB,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,OAAO;QACzC,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC;YACnC,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI;SAC3C,CAAC,CAAC;IACJ,CAAC;CACD,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,eAAe,SAAS,CAAC"}
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.repositoryC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AC,SAAS,KAAK,MAAM,KAAK,EAAE,SAAS,CAAC;AAClF,YAAM,IAAI;AAAA,QACT,+BAA+B,GAAG;AAAA,MACnC;AACD,aAAS,IAAI,KAAK,EAAE,YAAY,WAAW,CAAC;AAAA,EAC7C;AACA,SAAO;AACR;AAEA,IAAM,YAAqC;AAAA,EAC1C;AAAA,EACA,YAAY,KAAK,QAAQ;AACxB,UAAM,OAAO,IAAI,IAAI,qBAAqB,WAAW;AACrD,QAAI,CAAC,QAAQ,MAAM,QAAQ,IAAI,EAAG;AAClC,UAAM,WAAW,cAAc,MAAM;AACrC,SAAK,sBAAsB,SAAS;AAAA,MACnC,MAAM;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.0",
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.0"
28
+ "@leitwerk-dev/process-sdk": "0.1.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "tsup": "^8.5.1"
@@ -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"}