@kubb/core 5.12.1 → 5.12.3

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.1";
22
+ var version = "5.12.3";
23
23
  //#endregion
24
24
  //#region ../../internals/utils/src/casing.ts
25
25
  /**
@@ -1358,16 +1358,31 @@ async function resolvePublicFetchConfig(repo, signal) {
1358
1358
  addresses
1359
1359
  });
1360
1360
  }
1361
+ /** Adds an `Authorization` header for `repo`'s origin as the `GIT_CONFIG_*` pair after those in `env`, keeping the token out of the arguments; throws on a line break. */
1362
+ function gitAuthEnv(env, { repo, authorization }) {
1363
+ if (/[\r\n]/.test(authorization) || !URL.canParse(repo)) throw gitError("The authorization for a git `input` must be one line, for an https repository.");
1364
+ const index = Math.max(0, Number.parseInt(env.GIT_CONFIG_COUNT ?? "", 10) || 0);
1365
+ return {
1366
+ GIT_CONFIG_COUNT: String(index + 1),
1367
+ [`GIT_CONFIG_KEY_${index}`]: `http.${new URL(repo).origin}/.extraheader`,
1368
+ [`GIT_CONFIG_VALUE_${index}`]: `Authorization: ${authorization}`
1369
+ };
1370
+ }
1361
1371
  /**
1362
1372
  * Fetches one commit of a git repository into a temporary directory with a shallow `git fetch`,
1363
1373
  * so any host and the user's own git credentials work, and relative `$ref` files resolve.
1364
1374
  * Resolves to the spec path on disk and a `dispose` that deletes the checkout.
1365
1375
  *
1366
1376
  * 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.
1377
+ * the addresses checked, and it does not follow a redirect. `authorization` adds that header to this
1378
+ * fetch only, through {@link gitAuthEnv}.
1368
1379
  */
1369
- async function checkoutGitInput(input, signal, { publicOnly = false } = {}) {
1380
+ async function checkoutGitInput(input, signal, { publicOnly = false, authorization } = {}) {
1370
1381
  const { repo, ref, path } = parseGitInput(input);
1382
+ const authEnv = authorization ? gitAuthEnv(process$1.env, {
1383
+ repo,
1384
+ authorization
1385
+ }) : {};
1371
1386
  const fetchConfig = publicOnly ? await resolvePublicFetchConfig(repo, signal) : [];
1372
1387
  const dir = await mkdtemp(join(tmpdir(), "kubb-git-"));
1373
1388
  const dispose = () => rm(dir, {
@@ -1383,6 +1398,7 @@ async function checkoutGitInput(input, signal, { publicOnly = false } = {}) {
1383
1398
  const label = `${redact(repo)}${ref ? ` at ${ref}` : ""}`;
1384
1399
  const env = {
1385
1400
  ...process$1.env,
1401
+ ...authEnv,
1386
1402
  GIT_TERMINAL_PROMPT: "0"
1387
1403
  };
1388
1404
  const steps = [
@@ -3068,4 +3084,4 @@ var Hookable = class {
3068
3084
  //#endregion
3069
3085
  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
3086
 
3071
- //# sourceMappingURL=Hookable-D3jKB944.js.map
3087
+ //# sourceMappingURL=Hookable-DPTq2eNO.js.map