@maverickcer/env-cap 0.2.0 → 0.3.0
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/build.cjs +1 -1
- package/dist/build.js +1 -1
- package/dist/cli/index.js +1 -1
- package/package.json +4 -4
- package/dist/.dts/build/manifest-snapshot.d.ts +0 -229
- package/dist/.dts/build/manifest-snapshot.d.ts.map +0 -1
- package/dist/.dts/build/resolve-import.d.ts +0 -50
- package/dist/.dts/build/resolve-import.d.ts.map +0 -1
- package/dist/.dts/build/resolve-package-schema.d.ts +0 -99
- package/dist/.dts/build/resolve-package-schema.d.ts.map +0 -1
- package/dist/.dts/build/resolve-tsconfig-paths.d.ts +0 -100
- package/dist/.dts/build/resolve-tsconfig-paths.d.ts.map +0 -1
- package/dist/.dts/build/resolve-within-root.d.ts +0 -35
- package/dist/.dts/build/resolve-within-root.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-import.d.ts","sourceRoot":"","sources":["../../../src/build/resolve-import.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,MAAM,6BAA6B,CAAA;AAEpC;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,qBAAqB,CACzC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAe7B;AAWD,8GAA8G;AAC9G,MAAM,WAAW,uBAAuB;IACtC,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,6HAA6H;IAC7H,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,8HAA8H;IAC9H,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAA;IACnE,0IAA0I;IAC1I,QAAQ,CAAC,aAAa,EAAE,uBAAuB,GAAG,SAAS,CAAA;IAC3D,iMAAiM;IACjM,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAA;CAC1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAe7B"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { ParseWarning } from "./parse.js";
|
|
2
|
-
/**
|
|
3
|
-
* Cross-package schema discovery (ADR 0014, Experimental -- see VERSIONING.md).
|
|
4
|
-
*
|
|
5
|
-
* Resolves an explicitly allow-listed installed package name to the one
|
|
6
|
-
* schema file it declares via its own `"envCap": { "schema": "<path>" }`
|
|
7
|
-
* package.json field. Every step here is `createRequire(...).resolve(...)`,
|
|
8
|
-
* `fs.stat`/`fs.realpath`/`fs.readFile` on a path already fully known --
|
|
9
|
-
* never a `readdir` walk of any directory, named package or not. This is a
|
|
10
|
-
* completely separate code path from `discover.ts`'s `discoverSchemaFiles()`,
|
|
11
|
-
* which continues to unconditionally prune `node_modules` during its own
|
|
12
|
-
* walk exactly as before; the two never overlap.
|
|
13
|
-
*
|
|
14
|
-
* This module only ever locates a file. It never imports, requires, or
|
|
15
|
-
* executes it -- a package-resolved file is fed into the exact same
|
|
16
|
-
* `parseSchemaFile()`/AST-only pipeline as a locally-discovered file,
|
|
17
|
-
* indistinguishable from it after resolution. See ADR 0002 and ADR 0014.
|
|
18
|
-
*/
|
|
19
|
-
export declare const SCHEMA_FILE_EXTENSIONS: readonly [".ts", ".tsx"];
|
|
20
|
-
/** 1 MiB. New hardening specific to this trust tier -- a package crosses a
|
|
21
|
-
* real versioning/trust boundary that locally-discovered source doesn't,
|
|
22
|
-
* so this caps the cost of parsing an oversized or adversarial file before
|
|
23
|
-
* any of its content is even read into memory. See ADR 0014. */
|
|
24
|
-
export declare const MAX_PACKAGE_SCHEMA_FILE_BYTES = 1048576;
|
|
25
|
-
export type PackageResolutionFailureCode = "PACKAGE_NOT_FOUND" | "MALFORMED_PACKAGE_JSON" | "FIELD_MISSING" | "INVALID_EXTENSION" | "OUTSIDE_PACKAGE" | "FILE_TOO_LARGE";
|
|
26
|
-
/** Both the authored and resolved forms are kept -- diagnostics benefit from
|
|
27
|
-
* showing exactly what a package author wrote versus what it resolved to. */
|
|
28
|
-
export interface PackageOrigin {
|
|
29
|
-
/** The allow-listed package name that declared this schema. */
|
|
30
|
-
readonly packageName: string;
|
|
31
|
-
/** The `"envCap.schema"` value exactly as the package author wrote it. */
|
|
32
|
-
readonly declaredField: string;
|
|
33
|
-
/** Absolute, realpath-canonicalized path to the resolved schema file. */
|
|
34
|
-
readonly resolvedFile: string;
|
|
35
|
-
/** Absolute, realpath-canonicalized path to the package's own directory. */
|
|
36
|
-
readonly packageDir: string;
|
|
37
|
-
}
|
|
38
|
-
export type PackageSchemaResolutionResult = {
|
|
39
|
-
readonly ok: true;
|
|
40
|
-
readonly origin: PackageOrigin;
|
|
41
|
-
} | {
|
|
42
|
-
readonly ok: false;
|
|
43
|
-
readonly code: PackageResolutionFailureCode;
|
|
44
|
-
readonly reason: string;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Resolves one allow-listed package name. Memoized in a caller-owned
|
|
48
|
-
* `cache` (one per `generate*()` invocation, shared with linking/dependency-
|
|
49
|
-
* graph resolution) so a name referenced from multiple places -- multiple
|
|
50
|
-
* scanned files bare-importing the same package, or a duplicate entry in
|
|
51
|
-
* `packages` -- is only ever resolved once. The cache is populated with the
|
|
52
|
-
* in-flight promise before it settles, so concurrent callers await the same
|
|
53
|
-
* resolution rather than racing duplicate work.
|
|
54
|
-
*/
|
|
55
|
-
export declare function resolvePackageSchemaFile(packageName: string, root: string, cache: Map<string, Promise<PackageSchemaResolutionResult>>): Promise<PackageSchemaResolutionResult>;
|
|
56
|
-
export interface ResolvedPackageFile {
|
|
57
|
-
readonly packageName: string;
|
|
58
|
-
readonly file: string;
|
|
59
|
-
}
|
|
60
|
-
export interface ResolvePackagesResult {
|
|
61
|
-
readonly files: readonly ResolvedPackageFile[];
|
|
62
|
-
/** Keyed by resolved file path, for `DiscoveredContract.packageOrigin` lookups downstream. */
|
|
63
|
-
readonly origins: ReadonlyMap<string, PackageOrigin>;
|
|
64
|
-
readonly warnings: readonly ParseWarning[];
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Resolves every allow-listed package name. Input is deduplicated first, so
|
|
68
|
-
* a duplicate entry in `packages` (accidental or defensive) produces exactly
|
|
69
|
-
* one resolution attempt and, on failure, exactly one warning -- never two.
|
|
70
|
-
* Never throws: every failure becomes one `ParseWarning`, consistent with
|
|
71
|
-
* every other static-analysis boundary in this codebase.
|
|
72
|
-
*/
|
|
73
|
-
export declare function resolveAllowlistedPackages(packages: readonly string[], root: string, cache: Map<string, Promise<PackageSchemaResolutionResult>>): Promise<ResolvePackagesResult>;
|
|
74
|
-
/**
|
|
75
|
-
* Combines local schema-discovery hits with package-resolved files into one
|
|
76
|
-
* deduplicated list, keyed by realpath rather than lexical absolute path --
|
|
77
|
-
* package-resolved files are already realpath-canonicalized (see
|
|
78
|
-
* `resolveUncached` above), but local `discoverSchemaFiles()` hits are plain
|
|
79
|
-
* `readdir`-derived absolute paths that may themselves traverse a symlink (a
|
|
80
|
-
* symlinked `root`, or an included path reached through one). Deduplicating
|
|
81
|
-
* on the lexical path alone would miss the case where the same physical file
|
|
82
|
-
* is reached twice through two different symlinked routes -- one via local
|
|
83
|
-
* glob discovery, one via package resolution -- and silently double-count it
|
|
84
|
-
* into two identical contracts, including the more mundane case of a package
|
|
85
|
-
* that's both locally glob-reachable (e.g. during a monorepo migration) and
|
|
86
|
-
* explicitly allow-listed. On a collision, the local path string identity
|
|
87
|
-
* wins (the package-resolved duplicate is dropped).
|
|
88
|
-
*/
|
|
89
|
-
export declare function mergeLocalAndPackageFiles(localFiles: readonly string[], packageFiles: readonly string[]): Promise<string[]>;
|
|
90
|
-
/**
|
|
91
|
-
* Bare-specifier-to-allowlist matching, used by `resolve-import.ts`'s
|
|
92
|
-
* `resolveImportSpecifier()` as its package-resolution fallback. Only ever
|
|
93
|
-
* attempts resolution for a specifier that is (or is a subpath of) an
|
|
94
|
-
* allow-listed package name -- any other bare specifier is not this
|
|
95
|
-
* mechanism's concern and returns `undefined` immediately, identical to
|
|
96
|
-
* `resolveRelativeImport()`'s existing bare-specifier no-op.
|
|
97
|
-
*/
|
|
98
|
-
export declare function resolvePackageImport(specifier: string, allowedPackages: readonly string[], root: string, cache: Map<string, Promise<PackageSchemaResolutionResult>>): Promise<string | undefined>;
|
|
99
|
-
//# sourceMappingURL=resolve-package-schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-package-schema.d.ts","sourceRoot":"","sources":["../../../src/build/resolve-package-schema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAG9C;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,sBAAsB,0BAA2B,CAAA;AAE9D;;;iEAGiE;AACjE,eAAO,MAAM,6BAA6B,UAAY,CAAA;AAItD,MAAM,MAAM,4BAA4B,GACpC,mBAAmB,GACnB,wBAAwB,GACxB,eAAe,GACf,mBAAmB,GACnB,iBAAiB,GACjB,gBAAgB,CAAA;AAEpB;8EAC8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,MAAM,6BAA6B,GACrC;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,4BAA4B,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AA0LhG;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC,GACzD,OAAO,CAAC,6BAA6B,CAAC,CAOxC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,CAAA;IAC9C,8FAA8F;IAC9F,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpD,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAA;CAC3C;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC,GACzD,OAAO,CAAC,qBAAqB,CAAC,CAuBhC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,YAAY,EAAE,SAAS,MAAM,EAAE,GAC9B,OAAO,CAAC,MAAM,EAAE,CAAC,CAuBnB;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,SAAS,MAAM,EAAE,EAClC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC,GACzD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAO7B"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import type { ParseWarning } from "./parse.js";
|
|
3
|
-
/**
|
|
4
|
-
* TypeScript path-alias resolution (ADR 0023, Experimental -- see VERSIONING.md).
|
|
5
|
-
*
|
|
6
|
-
* Resolves a bare import specifier (`"@/lib/env.schema.js"`) against a project's own
|
|
7
|
-
* `tsconfig.json` `compilerOptions.paths`/`baseUrl`, so a schema or consumer reached only
|
|
8
|
-
* through an alias isn't misreported by `link.ts`/`dependency-graph.ts` as unresolved or
|
|
9
|
-
* abandoned. Unlike `resolve-package-schema.ts` (ADR 0014), this never crosses a
|
|
10
|
-
* trust/versioning boundary -- every resolved file is already local, already-trusted
|
|
11
|
-
* project source -- so it is on by default (auto-detecting `root/tsconfig.json`) rather
|
|
12
|
-
* than requiring an explicit allowlist.
|
|
13
|
-
*
|
|
14
|
-
* The actual `paths`/`baseUrl` matching algorithm (longest-prefix matching, `*` wildcard
|
|
15
|
-
* substitution, multiple fallback targets, `extends`-chain merging, JSONC parsing) is
|
|
16
|
-
* delegated entirely to the TypeScript compiler via `ts.resolveModuleName()` and
|
|
17
|
-
* `ts.parseJsonConfigFileContent()` -- the same functions `tsc`/`tsserver` themselves use --
|
|
18
|
-
* rather than reimplemented here. This module's own logic is limited to loading the config,
|
|
19
|
-
* caching resolutions, and enforcing the `node_modules` safety boundary below.
|
|
20
|
-
*/
|
|
21
|
-
/** Parsed `tsconfig.json` `paths`/`baseUrl` configuration, immutable for the life of one generate*() run. See {@link loadTsconfigPaths}. */
|
|
22
|
-
export interface TsconfigPathsResolution {
|
|
23
|
-
/** The subset of `compilerOptions` `ts.resolveModuleName()` needs -- at minimum `paths` and/or `baseUrl`. */
|
|
24
|
-
readonly compilerOptions: ts.CompilerOptions;
|
|
25
|
-
/** Absolute path of the tsconfig.json this was loaded from, for diagnostics. */
|
|
26
|
-
readonly configFile: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Opaque memoization for {@link resolveAliasImport}, created once per generate*() run via
|
|
30
|
-
* {@link createAliasResolutionCache} and threaded through `ImportResolutionContext`. Kept
|
|
31
|
-
* distinct from `TsconfigPathsResolution` (immutable config) so the cache's internal
|
|
32
|
-
* representation stays free to change without touching that type's shape.
|
|
33
|
-
*/
|
|
34
|
-
export interface AliasResolutionCache {
|
|
35
|
-
/**
|
|
36
|
-
* Keyed by `` `${importingFile}\0${specifier}` ``, not by `specifier` alone. With one
|
|
37
|
-
* fixed `compilerOptions` object and no project-reference support, `paths`-pattern
|
|
38
|
-
* substitution itself doesn't depend on the importing file -- but `ts.resolveModuleName()`'s
|
|
39
|
-
* fallback behavior when `paths` doesn't match a real file (classic-mode ancestor search,
|
|
40
|
-
* extension-preference edge cases) legitimately can. A `Map`, not a network call, so
|
|
41
|
-
* keying defensively by both costs nothing.
|
|
42
|
-
*/
|
|
43
|
-
readonly resolutions: Map<string, string | undefined>;
|
|
44
|
-
}
|
|
45
|
-
/** Creates a fresh, empty {@link AliasResolutionCache} for one generate*()/computeArtifacts() run. */
|
|
46
|
-
export declare function createAliasResolutionCache(): AliasResolutionCache;
|
|
47
|
-
export interface LoadTsconfigPathsResult {
|
|
48
|
-
readonly resolution: TsconfigPathsResolution | undefined;
|
|
49
|
-
readonly warning: ParseWarning | undefined;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Loads and parses a `tsconfig.json` for alias resolution. Called exactly once per
|
|
53
|
-
* `generate*()`/`computeArtifacts()` invocation, at the same point
|
|
54
|
-
* `resolveAllowlistedPackages()` is already called once -- so at most one tsconfig-related
|
|
55
|
-
* warning is ever produced per run, never once per file scanned.
|
|
56
|
-
*
|
|
57
|
-
* @remarks
|
|
58
|
-
* `tsconfigOption === false` disables alias resolution entirely.
|
|
59
|
-
* `tsconfigOption === undefined` (the default) looks for `root/tsconfig.json` exactly --
|
|
60
|
-
* deliberately not `ts.findConfigFile()`'s upward directory walk, since every other
|
|
61
|
-
* root-relative mechanism in this codebase (schema discovery, `packages` resolution)
|
|
62
|
-
* treats `root` as a hard boundary. A missing default tsconfig is silent (most projects
|
|
63
|
-
* don't use aliases); a missing *explicit* `tsconfigOption` is a real misconfiguration and
|
|
64
|
-
* warns. `jsconfig.json` is intentionally not auto-detected -- pass `tsconfig:
|
|
65
|
-
* "jsconfig.json"` explicitly if needed; this loader only cares about the file's JSON
|
|
66
|
-
* shape, not its name.
|
|
67
|
-
*
|
|
68
|
-
* The gate for building a resolution is "`paths` non-empty OR `baseUrl` set", not `paths`
|
|
69
|
-
* alone -- a `baseUrl`-only tsconfig (no `paths` at all) still makes TypeScript resolve
|
|
70
|
-
* bare specifiers relative to `baseUrl`, and `ts.resolveModuleName()` already handles that
|
|
71
|
-
* once `compilerOptions.baseUrl` is passed through.
|
|
72
|
-
*/
|
|
73
|
-
export declare function loadTsconfigPaths(root: string, tsconfigOption: string | false | undefined): Promise<LoadTsconfigPathsResult>;
|
|
74
|
-
/**
|
|
75
|
-
* Resolves one bare import specifier against a project's `tsconfig.json` `paths`/`baseUrl`,
|
|
76
|
-
* or returns `undefined` if it doesn't resolve through this mechanism.
|
|
77
|
-
*
|
|
78
|
-
* @remarks
|
|
79
|
-
* Necessarily synchronous -- `ts.resolveModuleName()` has no async form, matching how
|
|
80
|
-
* `tsc`/`tsserver` themselves always call it. `ts.sys` is used directly as the resolution
|
|
81
|
-
* host (an existing Node-backed singleton the `typescript` package exports; nothing to
|
|
82
|
-
* construct).
|
|
83
|
-
*
|
|
84
|
-
* Two safety/scope filters apply to any candidate `ts.resolveModuleName()` returns,
|
|
85
|
-
* independent of its own internal fallback behavior:
|
|
86
|
-
* - **Never resolves into `node_modules`.** `ts.resolveModuleName()` can, in principle,
|
|
87
|
-
* fall through to classic Node resolution and land inside `node_modules`; any resolved
|
|
88
|
-
* path containing a `node_modules` path segment (checked after `path.normalize()`, so
|
|
89
|
-
* mixed separators can't slip past it on Windows) is discarded here. Bare package
|
|
90
|
-
* specifiers continue to be handled exclusively by `resolvePackageImport()`
|
|
91
|
-
* (ADR 0014) -- this mechanism never overlaps with that trust boundary.
|
|
92
|
-
* - **`.ts`/`.tsx` only.** Matches `resolveRelativeImport()`'s own existing candidate set
|
|
93
|
-
* and `resolve-package-schema.ts`'s `SCHEMA_FILE_EXTENSIONS` -- this codebase's static-
|
|
94
|
-
* analysis pipeline is `.ts`/`.tsx` only today. A resolved non-`.ts`/`.tsx` file is a
|
|
95
|
-
* real risk, not just a gap: feeding it straight into `ts.createSourceFile()` wouldn't
|
|
96
|
-
* error, it would silently parse garbage -- exactly the "guess" this codebase's
|
|
97
|
-
* warn-don't-guess philosophy exists to avoid.
|
|
98
|
-
*/
|
|
99
|
-
export declare function resolveAliasImport(specifier: string, importingFile: string, resolution: TsconfigPathsResolution, cache: AliasResolutionCache): string | undefined;
|
|
100
|
-
//# sourceMappingURL=resolve-tsconfig-paths.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-tsconfig-paths.d.ts","sourceRoot":"","sources":["../../../src/build/resolve-tsconfig-paths.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C;;;;;;;;;;;;;;;;;GAiBG;AAEH,4IAA4I;AAC5I,MAAM,WAAW,uBAAuB;IACtC,6GAA6G;IAC7G,QAAQ,CAAC,eAAe,EAAE,EAAE,CAAC,eAAe,CAAA;IAC5C,gFAAgF;IAChF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CACtD;AAED,sGAAsG;AACtG,wBAAgB,0BAA0B,IAAI,oBAAoB,CAEjE;AAWD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,UAAU,EAAE,uBAAuB,GAAG,SAAS,CAAA;IACxD,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,CAAA;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,GACzC,OAAO,CAAC,uBAAuB,CAAC,CAqClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,uBAAuB,EACnC,KAAK,EAAE,oBAAoB,GAC1B,MAAM,GAAG,SAAS,CAiBpB"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { CompatibilityIssue } from "./compatibility.js";
|
|
2
|
-
export type ResolveWithinRootResult = {
|
|
3
|
-
readonly ok: true;
|
|
4
|
-
readonly resolved: string;
|
|
5
|
-
} | {
|
|
6
|
-
readonly ok: false;
|
|
7
|
-
readonly issue: CompatibilityIssue;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Plain lexical bounds-check: is `targetPath` inside `baseDir`? Shared by
|
|
11
|
-
* `resolveWithinRoot()` below (output paths, checked lexically since they
|
|
12
|
-
* usually don't exist on disk yet) and `resolve-package-schema.ts` (which
|
|
13
|
-
* additionally re-checks this against `fs.realpath`-resolved paths, since a
|
|
14
|
-
* package-declared schema path both exists on disk and crosses a real trust
|
|
15
|
-
* boundary -- see ADR 0014). Boundary-agnostic on purpose: neither caller's
|
|
16
|
-
* notion of "root" is baked in here.
|
|
17
|
-
*/
|
|
18
|
-
export declare function isWithinDirectory(baseDir: string, targetPath: string): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Resolves `location` against `root` and checks the result doesn't escape it
|
|
21
|
-
* (e.g. `location: "../../malicious.ts"`, or an absolute path on another
|
|
22
|
-
* branch of the filesystem entirely). Discovery (`include`/`exclude`) is
|
|
23
|
-
* already safe by construction -- it only ever walks *down* from `root` via
|
|
24
|
-
* `readdir`, so a pattern can't make it read outside `root`. Output
|
|
25
|
-
* locations have no such structural guarantee, since `path.resolve` happily
|
|
26
|
-
* walks back out via `..` segments, so this is a plain lexical bounds-check
|
|
27
|
-
* (not a symlink-aware `realpath` check -- these are *output* paths that
|
|
28
|
-
* usually don't exist yet).
|
|
29
|
-
*
|
|
30
|
-
* Never throws itself -- returns a `CompatibilityIssue`-shaped finding on
|
|
31
|
-
* escape so each generator function (`generateEnvManifest`, `generateDocumentation`,
|
|
32
|
-
* `generateUsageReport`, `generateEnvArtifacts`) can wrap it in its own error type.
|
|
33
|
-
*/
|
|
34
|
-
export declare function resolveWithinRoot(root: string, location: string, optionName: string, functionName: string): ResolveWithinRootResult;
|
|
35
|
-
//# sourceMappingURL=resolve-within-root.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-within-root.d.ts","sourceRoot":"","sources":["../../../src/build/resolve-within-root.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAE5D,MAAM,MAAM,uBAAuB,GAC/B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAA;AAE9D;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAG9E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,uBAAuB,CAgBzB"}
|