@kubb/core 5.12.2 → 5.12.4

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.
@@ -19,7 +19,7 @@ var __name = (target, value) => __defProp(target, "name", {
19
19
  });
20
20
  //#endregion
21
21
  //#region package.json
22
- var version = "5.12.2";
22
+ var version = "5.12.4";
23
23
  //#endregion
24
24
  //#region ../../internals/utils/src/casing.ts
25
25
  /**
@@ -1359,15 +1359,34 @@ async function resolvePublicFetchConfig(repo, signal) {
1359
1359
  });
1360
1360
  }
1361
1361
  /**
1362
+ * The `GIT_CONFIG_*` pair that sends an `Authorization` header to `repo`'s origin, numbered after
1363
+ * the pairs already in `env`, so the token stays out of the process arguments. Throws
1364
+ * `KUBB_GIT_INPUT_FAILED` for a value with a line break, which would add another header.
1365
+ */
1366
+ function gitAuthEnv(env, { repo, authorization }) {
1367
+ if (/[\r\n]/.test(authorization) || !URL.canParse(repo)) throw gitError("The authorization for a git `input` must be one line, for an https repository.");
1368
+ const index = Math.max(0, Number.parseInt(env.GIT_CONFIG_COUNT ?? "", 10) || 0);
1369
+ return {
1370
+ GIT_CONFIG_COUNT: String(index + 1),
1371
+ [`GIT_CONFIG_KEY_${index}`]: `http.${new URL(repo).origin}/.extraheader`,
1372
+ [`GIT_CONFIG_VALUE_${index}`]: `Authorization: ${authorization}`
1373
+ };
1374
+ }
1375
+ /**
1362
1376
  * Fetches one commit of a git repository into a temporary directory with a shallow `git fetch`,
1363
1377
  * so any host and the user's own git credentials work, and relative `$ref` files resolve.
1364
1378
  * Resolves to the spec path on disk and a `dispose` that deletes the checkout.
1365
1379
  *
1366
1380
  * With `publicOnly`, the repository must be an https URL on public addresses, the fetch connects to
1367
- * the addresses checked, and it does not follow a redirect.
1381
+ * the addresses checked, and it does not follow a redirect. `authorization` adds that header to this
1382
+ * fetch only, through {@link gitAuthEnv}.
1368
1383
  */
1369
- async function checkoutGitInput(input, signal, { publicOnly = false } = {}) {
1384
+ async function checkoutGitInput(input, signal, { publicOnly = false, authorization } = {}) {
1370
1385
  const { repo, ref, path } = parseGitInput(input);
1386
+ const authEnv = authorization ? gitAuthEnv(process$1.env, {
1387
+ repo,
1388
+ authorization
1389
+ }) : {};
1371
1390
  const fetchConfig = publicOnly ? await resolvePublicFetchConfig(repo, signal) : [];
1372
1391
  const dir = await mkdtemp(join(tmpdir(), "kubb-git-"));
1373
1392
  const dispose = () => rm(dir, {
@@ -1383,6 +1402,7 @@ async function checkoutGitInput(input, signal, { publicOnly = false } = {}) {
1383
1402
  const label = `${redact(repo)}${ref ? ` at ${ref}` : ""}`;
1384
1403
  const env = {
1385
1404
  ...process$1.env,
1405
+ ...authEnv,
1386
1406
  GIT_TERMINAL_PROMPT: "0"
1387
1407
  };
1388
1408
  const steps = [
@@ -3068,4 +3088,4 @@ var Hookable = class {
3068
3088
  //#endregion
3069
3089
  export { formatMs as A, toError as B, useConfig as C, defineExtension as D, checkCompatibility as E, listFiles as F, __name as H, read as I, rm$1 as L, inParallel as M, existsSync$1 as N, resolveMeta as O, isPathInside as P, write as R, tryUseKubb as S, useOptions as T, camelCase as V, kubbContext as _, FileManager as a, setOptions as b, Resolver as c, isPublicAddress as d, assertPluginOption as f, injectFile as g, addMacro as h, createNodeCache as i, getElapsedMs as j, Diagnostics as k, getInputKind as l, addGenerator as m, KubbDriver as n, _usingCtx as o, definePlugin as p, pluginNotFoundError as r, createResolver as s, Hookable as t, checkoutGitInput as u, requirePlugin as v, useKubb as w, setResolver as x, setMacros as y, writeRaw as z };
3070
3090
 
3071
- //# sourceMappingURL=Hookable-DuUzYJNA.js.map
3091
+ //# sourceMappingURL=Hookable-CIEVq8yT.js.map