type-git 0.3.0-alpha.1 → 0.3.0-alpha.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.
- package/README.md +14 -0
- package/dist/adapters/bun/index.cjs +2 -2
- package/dist/adapters/bun/index.cjs.map +1 -1
- package/dist/adapters/bun/index.d.cts +1 -1
- package/dist/adapters/bun/index.d.ts +1 -1
- package/dist/adapters/bun/index.js +2 -2
- package/dist/adapters/bun/index.js.map +1 -1
- package/dist/adapters/deno/index.cjs +35 -2
- package/dist/adapters/deno/index.cjs.map +1 -1
- package/dist/adapters/deno/index.d.cts +1 -1
- package/dist/adapters/deno/index.d.ts +1 -1
- package/dist/adapters/deno/index.js +35 -2
- package/dist/adapters/deno/index.js.map +1 -1
- package/dist/adapters/node/index.cjs +230 -61
- package/dist/adapters/node/index.cjs.map +1 -1
- package/dist/adapters/node/index.d.cts +57 -6
- package/dist/adapters/node/index.d.ts +57 -6
- package/dist/adapters/node/index.js +230 -61
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/{adapters-Bpuvmw9y.d.cts → adapters-CZ8wj9Kr.d.cts} +60 -8
- package/dist/{adapters-Bpuvmw9y.d.ts → adapters-CZ8wj9Kr.d.ts} +60 -8
- package/dist/index.cjs +230 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +230 -61
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,31 @@
|
|
|
11
11
|
* Instead, only a curated allowlist of variables that Git genuinely needs to operate is
|
|
12
12
|
* inherited. Callers can widen or replace this behavior via the `inheritEnv` option.
|
|
13
13
|
*/
|
|
14
|
+
/**
|
|
15
|
+
* Fine-grained adjustment of the default allowlist.
|
|
16
|
+
*
|
|
17
|
+
* Starts from {@link DEFAULT_ENV_ALLOWLIST}, adds the names in `add`, then removes the
|
|
18
|
+
* names in `remove`. `remove` takes precedence, so `{ add: ['X'], remove: ['X'] }`
|
|
19
|
+
* excludes `X`. This is the way to drop a single default entry (for example
|
|
20
|
+
* `{ remove: ['SSH_AUTH_SOCK', 'SSH_AGENT_PID'] }` for an HTTPS-only application) while
|
|
21
|
+
* keeping the rest of the curated defaults.
|
|
22
|
+
*/
|
|
23
|
+
type EnvAllowlistAdjustment = {
|
|
24
|
+
/** Variable names to add to the default allowlist. */
|
|
25
|
+
add?: string[];
|
|
26
|
+
/** Variable names to remove from the (default + add) allowlist. */
|
|
27
|
+
remove?: string[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Predicate deciding, per variable, whether it is inherited from the parent environment.
|
|
31
|
+
* Receives each parent environment variable name and returns `true` to inherit it. This
|
|
32
|
+
* gives full control and bypasses the default allowlist entirely — reference
|
|
33
|
+
* {@link DEFAULT_ENV_ALLOWLIST} explicitly if you want to build on top of it.
|
|
34
|
+
*
|
|
35
|
+
* Note: on Windows the name is passed through as-is, so handle case-insensitivity yourself
|
|
36
|
+
* (e.g. compare against `name.toUpperCase()`).
|
|
37
|
+
*/
|
|
38
|
+
type EnvInheritancePredicate = (name: string) => boolean;
|
|
14
39
|
/**
|
|
15
40
|
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
16
41
|
*
|
|
@@ -22,8 +47,12 @@
|
|
|
22
47
|
* break Git if `PATH` is not otherwise supplied.
|
|
23
48
|
* - `string[]`: inherit {@link DEFAULT_ENV_ALLOWLIST} plus the named variables. Use this
|
|
24
49
|
* to explicitly opt specific variables (e.g. an SSH command or a token) back in.
|
|
50
|
+
* - `{ add?, remove? }`: inherit {@link DEFAULT_ENV_ALLOWLIST}, plus `add`, minus `remove`.
|
|
51
|
+
* Use this to drop a single default entry without rebuilding the whole allowlist.
|
|
52
|
+
* - `(name) => boolean`: a predicate that decides each variable individually, bypassing the
|
|
53
|
+
* default allowlist entirely.
|
|
25
54
|
*/
|
|
26
|
-
type EnvInheritance = boolean | string[];
|
|
55
|
+
type EnvInheritance = boolean | string[] | EnvAllowlistAdjustment | EnvInheritancePredicate;
|
|
27
56
|
/**
|
|
28
57
|
* Curated allowlist of environment variables inherited by default.
|
|
29
58
|
*
|
|
@@ -31,6 +60,16 @@ type EnvInheritance = boolean | string[];
|
|
|
31
60
|
* helpers) commonly needs to operate. The list intentionally excludes arbitrary
|
|
32
61
|
* application secrets so they are not silently forwarded to Git subprocesses.
|
|
33
62
|
*
|
|
63
|
+
* Security notes:
|
|
64
|
+
* - The SSH agent vars (`SSH_AUTH_SOCK`, `SSH_AGENT_PID`) and SSH/TLS transport config
|
|
65
|
+
* (`GIT_SSH_COMMAND`, `GIT_SSL_CAINFO`, …) are inherited by default so Git-over-SSH and
|
|
66
|
+
* fetch/push keep working out of the box. For an HTTPS-only application that does not
|
|
67
|
+
* want to expose the SSH agent, drop it with
|
|
68
|
+
* `inheritEnv: { remove: ['SSH_AUTH_SOCK', 'SSH_AGENT_PID'] }`.
|
|
69
|
+
* - The most credential-prone helpers (`GIT_ASKPASS`, `SSH_ASKPASS`, `GIT_PROXY_COMMAND`)
|
|
70
|
+
* are intentionally NOT in the default allowlist; opt them back in explicitly
|
|
71
|
+
* (`inheritEnv: ['GIT_ASKPASS']`) only when you trust the value.
|
|
72
|
+
*
|
|
34
73
|
* Variable names are matched case-insensitively on Windows.
|
|
35
74
|
*/
|
|
36
75
|
declare const DEFAULT_ENV_ALLOWLIST: readonly string[];
|
|
@@ -296,12 +335,20 @@ type Capabilities = {
|
|
|
296
335
|
lfsVersion?: string;
|
|
297
336
|
};
|
|
298
337
|
/**
|
|
299
|
-
* LFS mode configuration
|
|
338
|
+
* LFS mode configuration.
|
|
339
|
+
*
|
|
340
|
+
* - `'enabled'` (default): LFS behaves normally.
|
|
341
|
+
* - `'disabled'`: the `repo.lfs.*` / `repo.lfsExtra.*` helpers become no-ops.
|
|
342
|
+
* - object form: working-tree-populating operations (`checkout`, `switch`,
|
|
343
|
+
* `reset`, `merge`, `pull`, `rebase`, `restore`) run with
|
|
344
|
+
* `GIT_LFS_SKIP_SMUDGE=1` so Git leaves LFS pointer files in place instead of
|
|
345
|
+
* downloading their contents. The objects can be materialized later via the
|
|
346
|
+
* explicit `repo.lfs.pull()` / `repo.lfs.checkout()` helpers.
|
|
300
347
|
*/
|
|
301
348
|
type LfsMode = 'enabled' | 'disabled' | {
|
|
302
|
-
/** Skip smudge filter (don't download LFS files on checkout) */
|
|
349
|
+
/** Skip smudge filter (don't download LFS files on checkout). */
|
|
303
350
|
skipSmudge?: boolean;
|
|
304
|
-
/** Skip download
|
|
351
|
+
/** Skip download, keeping pointer files (also implies skip-smudge). */
|
|
305
352
|
skipDownload?: boolean;
|
|
306
353
|
};
|
|
307
354
|
/**
|
|
@@ -383,9 +430,12 @@ type GitOpenOptions = {
|
|
|
383
430
|
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
384
431
|
*
|
|
385
432
|
* By default, only a curated allowlist of variables that Git needs to operate is
|
|
386
|
-
* inherited (environment variable traversal prevention).
|
|
387
|
-
*
|
|
388
|
-
*
|
|
433
|
+
* inherited (environment variable traversal prevention). See {@link EnvInheritance} for
|
|
434
|
+
* all supported forms:
|
|
435
|
+
* - `true` — inherit the full parent environment.
|
|
436
|
+
* - `string[]` — inherit the default allowlist plus the named variables.
|
|
437
|
+
* - `{ add?, remove? }` — adjust the default allowlist (e.g. drop `SSH_AUTH_SOCK`).
|
|
438
|
+
* - `(name) => boolean` — decide each variable individually.
|
|
389
439
|
*/
|
|
390
440
|
inheritEnv?: EnvInheritance;
|
|
391
441
|
/** Directories to prepend to PATH */
|
|
@@ -573,6 +623,8 @@ type AuditConfig = {
|
|
|
573
623
|
type SpawnOptions = {
|
|
574
624
|
/** Command and arguments (first element is the command) */
|
|
575
625
|
argv: string[];
|
|
626
|
+
/** UTF-8 text to write to standard input, then close it. */
|
|
627
|
+
stdin?: string;
|
|
576
628
|
/** Additional environment variables */
|
|
577
629
|
env?: Record<string, string>;
|
|
578
630
|
/**
|
|
@@ -795,4 +847,4 @@ interface RuntimeAdapters {
|
|
|
795
847
|
*/
|
|
796
848
|
type AdapterFactory = () => RuntimeAdapters;
|
|
797
849
|
|
|
798
|
-
export { type AuditConfig as A, type
|
|
850
|
+
export { type AuditConfig as A, type AuditEventEnd as B, type Capabilities as C, DEFAULT_ENV_ALLOWLIST as D, type ExecAdapter as E, type FsAdapter as F, type GitErrorCategory as G, type AuditEvent as H, type TraceEvent as I, type LfsMode as L, type NonEmptyString as N, type OutputContract as O, type RuntimeAdapters as R, type SpawnOptions as S, type TailOptions as T, type StreamHandler as a, type SpawnResult as b, type SpawnHandle as c, type TailHandle as d, type ExecOpts as e, type RawResult as f, type GitProgress as g, type GitOpenOptions as h, type EnvInheritance as i, type ExecutionContext as j, GitError as k, type AdapterFactory as l, type EnvAllowlistAdjustment as m, type EnvInheritancePredicate as n, nonEmpty as o, isNonEmpty as p, type LfsProgress as q, resolveInheritedEnv as r, type GitErrorKind as s, GitArgumentError as t, type Runtime as u, type CommandSpec as v, type CredentialRequest as w, type Credential as x, type CredentialConfig as y, type AuditEventStart as z };
|
|
@@ -11,6 +11,31 @@
|
|
|
11
11
|
* Instead, only a curated allowlist of variables that Git genuinely needs to operate is
|
|
12
12
|
* inherited. Callers can widen or replace this behavior via the `inheritEnv` option.
|
|
13
13
|
*/
|
|
14
|
+
/**
|
|
15
|
+
* Fine-grained adjustment of the default allowlist.
|
|
16
|
+
*
|
|
17
|
+
* Starts from {@link DEFAULT_ENV_ALLOWLIST}, adds the names in `add`, then removes the
|
|
18
|
+
* names in `remove`. `remove` takes precedence, so `{ add: ['X'], remove: ['X'] }`
|
|
19
|
+
* excludes `X`. This is the way to drop a single default entry (for example
|
|
20
|
+
* `{ remove: ['SSH_AUTH_SOCK', 'SSH_AGENT_PID'] }` for an HTTPS-only application) while
|
|
21
|
+
* keeping the rest of the curated defaults.
|
|
22
|
+
*/
|
|
23
|
+
type EnvAllowlistAdjustment = {
|
|
24
|
+
/** Variable names to add to the default allowlist. */
|
|
25
|
+
add?: string[];
|
|
26
|
+
/** Variable names to remove from the (default + add) allowlist. */
|
|
27
|
+
remove?: string[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Predicate deciding, per variable, whether it is inherited from the parent environment.
|
|
31
|
+
* Receives each parent environment variable name and returns `true` to inherit it. This
|
|
32
|
+
* gives full control and bypasses the default allowlist entirely — reference
|
|
33
|
+
* {@link DEFAULT_ENV_ALLOWLIST} explicitly if you want to build on top of it.
|
|
34
|
+
*
|
|
35
|
+
* Note: on Windows the name is passed through as-is, so handle case-insensitivity yourself
|
|
36
|
+
* (e.g. compare against `name.toUpperCase()`).
|
|
37
|
+
*/
|
|
38
|
+
type EnvInheritancePredicate = (name: string) => boolean;
|
|
14
39
|
/**
|
|
15
40
|
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
16
41
|
*
|
|
@@ -22,8 +47,12 @@
|
|
|
22
47
|
* break Git if `PATH` is not otherwise supplied.
|
|
23
48
|
* - `string[]`: inherit {@link DEFAULT_ENV_ALLOWLIST} plus the named variables. Use this
|
|
24
49
|
* to explicitly opt specific variables (e.g. an SSH command or a token) back in.
|
|
50
|
+
* - `{ add?, remove? }`: inherit {@link DEFAULT_ENV_ALLOWLIST}, plus `add`, minus `remove`.
|
|
51
|
+
* Use this to drop a single default entry without rebuilding the whole allowlist.
|
|
52
|
+
* - `(name) => boolean`: a predicate that decides each variable individually, bypassing the
|
|
53
|
+
* default allowlist entirely.
|
|
25
54
|
*/
|
|
26
|
-
type EnvInheritance = boolean | string[];
|
|
55
|
+
type EnvInheritance = boolean | string[] | EnvAllowlistAdjustment | EnvInheritancePredicate;
|
|
27
56
|
/**
|
|
28
57
|
* Curated allowlist of environment variables inherited by default.
|
|
29
58
|
*
|
|
@@ -31,6 +60,16 @@ type EnvInheritance = boolean | string[];
|
|
|
31
60
|
* helpers) commonly needs to operate. The list intentionally excludes arbitrary
|
|
32
61
|
* application secrets so they are not silently forwarded to Git subprocesses.
|
|
33
62
|
*
|
|
63
|
+
* Security notes:
|
|
64
|
+
* - The SSH agent vars (`SSH_AUTH_SOCK`, `SSH_AGENT_PID`) and SSH/TLS transport config
|
|
65
|
+
* (`GIT_SSH_COMMAND`, `GIT_SSL_CAINFO`, …) are inherited by default so Git-over-SSH and
|
|
66
|
+
* fetch/push keep working out of the box. For an HTTPS-only application that does not
|
|
67
|
+
* want to expose the SSH agent, drop it with
|
|
68
|
+
* `inheritEnv: { remove: ['SSH_AUTH_SOCK', 'SSH_AGENT_PID'] }`.
|
|
69
|
+
* - The most credential-prone helpers (`GIT_ASKPASS`, `SSH_ASKPASS`, `GIT_PROXY_COMMAND`)
|
|
70
|
+
* are intentionally NOT in the default allowlist; opt them back in explicitly
|
|
71
|
+
* (`inheritEnv: ['GIT_ASKPASS']`) only when you trust the value.
|
|
72
|
+
*
|
|
34
73
|
* Variable names are matched case-insensitively on Windows.
|
|
35
74
|
*/
|
|
36
75
|
declare const DEFAULT_ENV_ALLOWLIST: readonly string[];
|
|
@@ -296,12 +335,20 @@ type Capabilities = {
|
|
|
296
335
|
lfsVersion?: string;
|
|
297
336
|
};
|
|
298
337
|
/**
|
|
299
|
-
* LFS mode configuration
|
|
338
|
+
* LFS mode configuration.
|
|
339
|
+
*
|
|
340
|
+
* - `'enabled'` (default): LFS behaves normally.
|
|
341
|
+
* - `'disabled'`: the `repo.lfs.*` / `repo.lfsExtra.*` helpers become no-ops.
|
|
342
|
+
* - object form: working-tree-populating operations (`checkout`, `switch`,
|
|
343
|
+
* `reset`, `merge`, `pull`, `rebase`, `restore`) run with
|
|
344
|
+
* `GIT_LFS_SKIP_SMUDGE=1` so Git leaves LFS pointer files in place instead of
|
|
345
|
+
* downloading their contents. The objects can be materialized later via the
|
|
346
|
+
* explicit `repo.lfs.pull()` / `repo.lfs.checkout()` helpers.
|
|
300
347
|
*/
|
|
301
348
|
type LfsMode = 'enabled' | 'disabled' | {
|
|
302
|
-
/** Skip smudge filter (don't download LFS files on checkout) */
|
|
349
|
+
/** Skip smudge filter (don't download LFS files on checkout). */
|
|
303
350
|
skipSmudge?: boolean;
|
|
304
|
-
/** Skip download
|
|
351
|
+
/** Skip download, keeping pointer files (also implies skip-smudge). */
|
|
305
352
|
skipDownload?: boolean;
|
|
306
353
|
};
|
|
307
354
|
/**
|
|
@@ -383,9 +430,12 @@ type GitOpenOptions = {
|
|
|
383
430
|
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
384
431
|
*
|
|
385
432
|
* By default, only a curated allowlist of variables that Git needs to operate is
|
|
386
|
-
* inherited (environment variable traversal prevention).
|
|
387
|
-
*
|
|
388
|
-
*
|
|
433
|
+
* inherited (environment variable traversal prevention). See {@link EnvInheritance} for
|
|
434
|
+
* all supported forms:
|
|
435
|
+
* - `true` — inherit the full parent environment.
|
|
436
|
+
* - `string[]` — inherit the default allowlist plus the named variables.
|
|
437
|
+
* - `{ add?, remove? }` — adjust the default allowlist (e.g. drop `SSH_AUTH_SOCK`).
|
|
438
|
+
* - `(name) => boolean` — decide each variable individually.
|
|
389
439
|
*/
|
|
390
440
|
inheritEnv?: EnvInheritance;
|
|
391
441
|
/** Directories to prepend to PATH */
|
|
@@ -573,6 +623,8 @@ type AuditConfig = {
|
|
|
573
623
|
type SpawnOptions = {
|
|
574
624
|
/** Command and arguments (first element is the command) */
|
|
575
625
|
argv: string[];
|
|
626
|
+
/** UTF-8 text to write to standard input, then close it. */
|
|
627
|
+
stdin?: string;
|
|
576
628
|
/** Additional environment variables */
|
|
577
629
|
env?: Record<string, string>;
|
|
578
630
|
/**
|
|
@@ -795,4 +847,4 @@ interface RuntimeAdapters {
|
|
|
795
847
|
*/
|
|
796
848
|
type AdapterFactory = () => RuntimeAdapters;
|
|
797
849
|
|
|
798
|
-
export { type AuditConfig as A, type
|
|
850
|
+
export { type AuditConfig as A, type AuditEventEnd as B, type Capabilities as C, DEFAULT_ENV_ALLOWLIST as D, type ExecAdapter as E, type FsAdapter as F, type GitErrorCategory as G, type AuditEvent as H, type TraceEvent as I, type LfsMode as L, type NonEmptyString as N, type OutputContract as O, type RuntimeAdapters as R, type SpawnOptions as S, type TailOptions as T, type StreamHandler as a, type SpawnResult as b, type SpawnHandle as c, type TailHandle as d, type ExecOpts as e, type RawResult as f, type GitProgress as g, type GitOpenOptions as h, type EnvInheritance as i, type ExecutionContext as j, GitError as k, type AdapterFactory as l, type EnvAllowlistAdjustment as m, type EnvInheritancePredicate as n, nonEmpty as o, isNonEmpty as p, type LfsProgress as q, resolveInheritedEnv as r, type GitErrorKind as s, GitArgumentError as t, type Runtime as u, type CommandSpec as v, type CredentialRequest as w, type Credential as x, type CredentialConfig as y, type AuditEventStart as z };
|