@super-repo/envx 0.4.0 → 0.4.1-b.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.
Files changed (106) hide show
  1. package/README.md +2 -2
  2. package/dist/auto.js +1 -1
  3. package/dist/chunks/auto-preload-CrSuZDg1.js +75 -0
  4. package/dist/chunks/auto-preload-CrSuZDg1.js.map +1 -0
  5. package/dist/chunks/aws-DgcXfw-Y.js +54 -0
  6. package/dist/chunks/aws-DgcXfw-Y.js.map +1 -0
  7. package/dist/chunks/azure-Cmh5-dPn.js +62 -0
  8. package/dist/chunks/azure-Cmh5-dPn.js.map +1 -0
  9. package/dist/chunks/{commands-KUyDszno.js → commands-Br0Z7uUF.js} +2 -2
  10. package/dist/chunks/commands-Br0Z7uUF.js.map +1 -0
  11. package/dist/chunks/doppler-BkQsajIp.js +50 -0
  12. package/dist/chunks/doppler-BkQsajIp.js.map +1 -0
  13. package/dist/chunks/gcp-Dq7QncPS.js +53 -0
  14. package/dist/chunks/gcp-Dq7QncPS.js.map +1 -0
  15. package/dist/chunks/infisical-CO073rdx.js +57 -0
  16. package/dist/chunks/infisical-CO073rdx.js.map +1 -0
  17. package/dist/chunks/{src-Ln2uXfYC.js → libs-CqVa6LY9.js} +0 -0
  18. package/dist/chunks/libs-CqVa6LY9.js.map +1 -0
  19. package/dist/chunks/op-CG9UWJIj.js +76 -0
  20. package/dist/chunks/op-CG9UWJIj.js.map +1 -0
  21. package/dist/chunks/runtime-BIEf_Dgo.js +102 -0
  22. package/dist/chunks/runtime-BIEf_Dgo.js.map +1 -0
  23. package/dist/chunks/{src-BM4EdT3z.js → src-ke3h417V.js} +2 -2
  24. package/dist/chunks/src-ke3h417V.js.map +1 -0
  25. package/dist/chunks/types-COrFYR0z.js +62 -0
  26. package/dist/chunks/types-COrFYR0z.js.map +1 -0
  27. package/dist/chunks/vault-BWdO9DFO.js +54 -0
  28. package/dist/chunks/vault-BWdO9DFO.js.map +1 -0
  29. package/dist/cli.js +1 -1
  30. package/dist/commands/index.js +1 -1
  31. package/dist/index.d.ts +3 -3
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +2 -2
  34. package/dist/libs/audit.d.ts +62 -0
  35. package/dist/libs/audit.d.ts.map +1 -0
  36. package/dist/libs/config.d.ts +185 -0
  37. package/dist/libs/config.d.ts.map +1 -0
  38. package/dist/libs/crypto.d.ts +34 -0
  39. package/dist/libs/crypto.d.ts.map +1 -0
  40. package/dist/libs/decrypt.d.ts +10 -0
  41. package/dist/libs/decrypt.d.ts.map +1 -0
  42. package/dist/libs/encrypt.d.ts +21 -0
  43. package/dist/libs/encrypt.d.ts.map +1 -0
  44. package/dist/libs/env.d.ts +178 -0
  45. package/dist/libs/env.d.ts.map +1 -0
  46. package/dist/libs/expand.d.ts +51 -0
  47. package/dist/libs/expand.d.ts.map +1 -0
  48. package/dist/libs/index.d.ts +22 -0
  49. package/dist/libs/index.d.ts.map +1 -0
  50. package/dist/libs/index.js +2 -0
  51. package/dist/libs/keys.d.ts +92 -0
  52. package/dist/libs/keys.d.ts.map +1 -0
  53. package/dist/libs/match.d.ts +7 -0
  54. package/dist/libs/match.d.ts.map +1 -0
  55. package/dist/libs/parser.d.ts +33 -0
  56. package/dist/libs/parser.d.ts.map +1 -0
  57. package/dist/libs/rotate.d.ts +24 -0
  58. package/dist/libs/rotate.d.ts.map +1 -0
  59. package/dist/libs/types.d.ts +42 -0
  60. package/dist/libs/types.d.ts.map +1 -0
  61. package/dist/plugins/auto-preload.d.ts +50 -0
  62. package/dist/plugins/auto-preload.d.ts.map +1 -0
  63. package/dist/plugins/auto-preload.js +2 -0
  64. package/dist/plugins/aws.d.ts +52 -0
  65. package/dist/plugins/aws.d.ts.map +1 -0
  66. package/dist/plugins/aws.js +2 -0
  67. package/dist/plugins/azure.d.ts +46 -0
  68. package/dist/plugins/azure.d.ts.map +1 -0
  69. package/dist/plugins/azure.js +2 -0
  70. package/dist/plugins/doppler.d.ts +36 -0
  71. package/dist/plugins/doppler.d.ts.map +1 -0
  72. package/dist/plugins/doppler.js +2 -0
  73. package/dist/plugins/gcp.d.ts +48 -0
  74. package/dist/plugins/gcp.d.ts.map +1 -0
  75. package/dist/plugins/gcp.js +2 -0
  76. package/dist/plugins/index.d.ts +11 -0
  77. package/dist/plugins/index.d.ts.map +1 -0
  78. package/dist/plugins/index.js +11 -0
  79. package/dist/plugins/infisical.d.ts +51 -0
  80. package/dist/plugins/infisical.d.ts.map +1 -0
  81. package/dist/plugins/infisical.js +2 -0
  82. package/dist/plugins/op.d.ts +52 -0
  83. package/dist/plugins/op.d.ts.map +1 -0
  84. package/dist/plugins/op.js +2 -0
  85. package/dist/plugins/runtime.d.ts +95 -0
  86. package/dist/plugins/runtime.d.ts.map +1 -0
  87. package/dist/plugins/runtime.js +2 -0
  88. package/dist/plugins/types.d.ts +54 -0
  89. package/dist/plugins/types.d.ts.map +1 -0
  90. package/dist/plugins/vault.d.ts +47 -0
  91. package/dist/plugins/vault.d.ts.map +1 -0
  92. package/dist/plugins/vault.js +2 -0
  93. package/docs/plugins/custom-providers.md +26 -0
  94. package/docs/plugins/library-api.md +52 -0
  95. package/docs/plugins/overview.md +96 -0
  96. package/docs/plugins/providers.md +149 -0
  97. package/docs/plugins/recipes.md +77 -0
  98. package/docs/plugins/runtime.md +88 -0
  99. package/docs/security-models.md +3 -3
  100. package/package.json +51 -11
  101. package/dist/bin/dotenvx.d.ts +0 -1
  102. package/dist/bin/dotenvx.d.ts.map +0 -1
  103. package/dist/bin/dotenvx.js +0 -2
  104. package/dist/chunks/commands-KUyDszno.js.map +0 -1
  105. package/dist/chunks/src-BM4EdT3z.js.map +0 -1
  106. package/dist/chunks/src-Ln2uXfYC.js.map +0 -1
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Built-in `NODE_ENV → suffix` mapping. Users can extend or override
3
+ * via `nodeEnvMap` in `envx.config.{ts,js,json}`. Anything NOT in the
4
+ * resolved map passes through as the lowercased `NODE_ENV` value —
5
+ * so `NODE_ENV=staging` becomes the `staging` suffix → `.env.staging`.
6
+ */
7
+ export declare const DEFAULT_NODE_ENV_MAP: Readonly<Record<string, string>>;
8
+ export interface DetectEnvironmentOptions {
9
+ /** Override the NODE_ENV → suffix mapping. Merged on top of the defaults. */
10
+ readonly nodeEnvMap?: Readonly<Record<string, string>>;
11
+ }
12
+ /**
13
+ * Detect the deployment environment from well-known platform variables.
14
+ * Order of precedence: Vercel → Netlify → `NODE_ENV` → 'root'.
15
+ *
16
+ * `NODE_ENV` resolution:
17
+ * 1. If the lowercased value is in `opts.nodeEnvMap` (or the built-in
18
+ * `DEFAULT_NODE_ENV_MAP`), use the mapped suffix. Empty string
19
+ * means "no suffix" (just `.env`).
20
+ * 2. Otherwise, use the lowercased value directly so unmapped values
21
+ * like `staging`, `qa`, `preview` resolve to `.env.<value>`
22
+ * automatically.
23
+ */
24
+ export declare function detectEnvironment(opts?: DetectEnvironmentOptions): string;
25
+ /**
26
+ * Parse a `KEY=value` string from `-v KEY=value` into a `[key, value]` tuple.
27
+ * Calls `process.exit(1)` on malformed input.
28
+ */
29
+ export declare function validateCmdVariable(param: string): [string, string];
30
+ /**
31
+ * Walk up from `startDir` looking for a `package.json` that declares
32
+ * `workspaces` (npm/yarn) or `pnpm.workspaces`. Falls back to other
33
+ * monorepo indicators (pnpm-workspace.yaml, nx.json, …). Returns
34
+ * `startDir` if nothing is found.
35
+ */
36
+ export declare function findWorkspaceRoot(startDir?: string): string;
37
+ /**
38
+ * Resolve a relative path against `cwd` first; if nothing exists at the
39
+ * cwd-rooted location, walk up to the workspace root and try there. If
40
+ * neither exists, return the cwd-rooted path so callers downstream (who
41
+ * may want to *create* the file/dir, e.g. `envx encrypt` writing a fresh
42
+ * `.env.keys`) get the user's expected location.
43
+ *
44
+ * Absolute paths are returned verbatim.
45
+ *
46
+ * resolveCwdOrWorkspace(".env.keys", "/repo/packages/web")
47
+ * → "/repo/packages/web/.env.keys" // exists in cwd
48
+ * → "/repo/.env.keys" // exists at workspace root
49
+ * → "/repo/packages/web/.env.keys" // neither — caller decides
50
+ */
51
+ export declare function resolveCwdOrWorkspace(relPath: string, cwd?: string): string;
52
+ /**
53
+ * List every `.env*` file in `dir`, sorted by name. Skips dotfile
54
+ * subdirectories. Returns the basenames (not absolute paths) so callers
55
+ * can hand them straight to `loadEnv` / `encryptFiles` / `decryptFiles`.
56
+ *
57
+ * Used by the CLI when `envPath`/`--vault` is set and `--env` is
58
+ * omitted: the user's intent is "all of the vault", not just `.env`.
59
+ */
60
+ export declare function listEnvFiles(dir: string): string[];
61
+ /**
62
+ * Expand env file paths according to the cascade strategy. For each
63
+ * base path `p` and a `cascadeName` like `"prod"`, produces:
64
+ *
65
+ * [`${p}.prod.local`, `${p}.local`, `${p}.prod`, p]
66
+ *
67
+ * Order is most-specific-first so callers (which load them in order
68
+ * with later entries overriding earlier ones) end up with the most
69
+ * specific values winning at the lowest index.
70
+ */
71
+ export declare function expandCascadePaths(paths: string[], cascadeName: string): string[];
72
+ export interface ResolveEnvOptions {
73
+ readonly envFiles?: string[] | string;
74
+ /**
75
+ * - `string` (e.g. `"prod"`) — cascade with this explicit name.
76
+ * - `true` — cascade with the auto-detected environment name (if
77
+ * detection produces `"root"`, no cascade is applied since there's
78
+ * nothing to layer).
79
+ * - `false` / undefined — no cascade.
80
+ */
81
+ readonly cascade?: string | boolean;
82
+ /** Default `true`. Set to `false` to disable platform auto-detection. */
83
+ readonly autoDetect?: boolean;
84
+ /** Override the built-in `NODE_ENV → suffix` mapping. */
85
+ readonly nodeEnvMap?: Readonly<Record<string, string>>;
86
+ }
87
+ /**
88
+ * Resolve which `.env*` paths to load given the user's options. Handles
89
+ * the auto-detect default (when only `.env` was passed), prefixing
90
+ * bare names with `.env.`, and cascade expansion.
91
+ */
92
+ export declare function resolveEnvPaths(opts: ResolveEnvOptions): string[];
93
+ export interface LoadEnvOptions {
94
+ readonly envFiles?: string[] | string;
95
+ readonly variables?: string[] | string;
96
+ /**
97
+ * - `string` — cascade with this explicit name.
98
+ * - `true` — cascade with the auto-detected env name.
99
+ * - `false` / undefined — no cascade.
100
+ */
101
+ readonly cascade?: string | boolean;
102
+ /**
103
+ * `true` is shorthand for `envPath: "vault"`. A string sets the
104
+ * subdirectory explicitly. Either way, relative env files resolve to
105
+ * `<workspaceRoot>/<envPath>/<file>`.
106
+ */
107
+ readonly vault?: boolean;
108
+ /** Subdirectory of the workspace root where env files live. */
109
+ readonly envPath?: string;
110
+ /**
111
+ * Explicit path to the `.env.keys` file. When unset, envx falls back
112
+ * to the cwd-first / workspace-root walk-up via `defaultKeysPath()`
113
+ * (see keys.ts). Forwarded to dotenvx for every env file load —
114
+ * required when `envFiles` are absolute paths whose directory isn't
115
+ * the same one holding `.env.keys` (e.g. `vault/.env.prod` while the
116
+ * keys file lives at the workspace root).
117
+ */
118
+ readonly envKeysFile?: string;
119
+ readonly override?: boolean;
120
+ readonly quiet?: boolean;
121
+ /** Default `true`. Set to `false` to disable platform auto-detection. */
122
+ readonly autoDetect?: boolean;
123
+ /** Override the built-in `NODE_ENV → suffix` mapping. */
124
+ readonly nodeEnvMap?: Readonly<Record<string, string>>;
125
+ /**
126
+ * Keys that MUST be set in `process.env` after loading completes.
127
+ * Any missing values cause envx to log + `process.exit(1)`.
128
+ */
129
+ readonly required?: readonly string[];
130
+ /**
131
+ * Auto-resolve `${VAR}` / `$VAR` / `${VAR:-default}` / `${VAR:?msg}`
132
+ * references in the loaded values after files load.
133
+ */
134
+ readonly expand?: boolean;
135
+ /**
136
+ * Fallback values for keys that are still unset after files +
137
+ * `variables`. Different from `variables`, which always overrides.
138
+ */
139
+ readonly defaults?: Readonly<Record<string, string>>;
140
+ /**
141
+ * Explicit workspace root. If unset, envx walks up from cwd via
142
+ * `findWorkspaceRoot()`.
143
+ */
144
+ readonly workspaceRoot?: string;
145
+ /**
146
+ * Optional schema validator with a `safeParse(input) → { success,
147
+ * error? }` method (e.g. a Zod schema). Run after files + variables
148
+ * + defaults + expand and before `required`. Failures cause
149
+ * `process.exit(1)` with a per-issue diagnostic.
150
+ */
151
+ readonly schema?: unknown;
152
+ /**
153
+ * Map of provider key → resolver. Values like `${provider:id}` in env
154
+ * files are passed to the matching resolver and replaced with its
155
+ * return. Misses are left as the literal `${provider:id}` so they
156
+ * surface clearly rather than silently emptying.
157
+ */
158
+ readonly resolvers?: Readonly<Record<string, (id: string) => string | undefined>>;
159
+ /**
160
+ * Framework prefixes to mirror "public" vars under. See
161
+ * `DotenvxConfig.publicPrefixes` for the full description. Mirrors
162
+ * are written to `process.env` AFTER expansion and BEFORE schema
163
+ * validation, so `VITE_API_URL` can be required by a Zod schema
164
+ * even though the source line was `PUBLIC_API_URL=…`.
165
+ */
166
+ readonly publicPrefixes?: readonly string[];
167
+ /** Source prefix marking public variables. Default `"PUBLIC_"`. */
168
+ readonly publicSource?: string;
169
+ }
170
+ /**
171
+ * Load env files (resolving relative paths against both the workspace
172
+ * root and CWD) and apply `KEY=value` overrides from `--variables`.
173
+ * Mutates `process.env`.
174
+ */
175
+ export declare function loadEnv(opts: LoadEnvOptions): {
176
+ paths: string[];
177
+ };
178
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/libs/env.ts"],"names":[],"mappings":"AAyHA;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIjE,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACxD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,wBAA6B,GAAG,MAAM,CA8B7E;AAMD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAA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R:?error}` references
3
+ * in env-file values. Iterative + cycle-safe: builds a dependency graph,
4
+ * topologically substitutes, and bails with a clear error on cycles.
5
+ *
6
+ * More robust than the bash version in `.github/actions/decrypt-vault`:
7
+ * - Handles `$VAR` (bare) and `${VAR}` syntactically.
8
+ * - Supports `${VAR:-default}` (use default if VAR is unset/empty)
9
+ * and `${VAR:?msg}` (error if unset/empty).
10
+ * - Supports `\${VAR}` and `\$VAR` escapes for literal `${VAR}` / `$VAR`.
11
+ * - Detects cycles instead of silently truncating after N passes.
12
+ * - Reports each unresolved variable, doesn't silently leave them.
13
+ */
14
+ export interface ExpandOptions {
15
+ /**
16
+ * Variables to layer in beneath the file's own values. The file's
17
+ * values take precedence; this is the fallback (typically process.env).
18
+ */
19
+ readonly fallback?: Readonly<Record<string, string | undefined>>;
20
+ /**
21
+ * What to do when a `${UNSET_VAR}` reference can't be resolved.
22
+ * - "leave" (default): keep the literal `${UNSET_VAR}` in place,
23
+ * and add a warning to the result.
24
+ * - "empty": substitute an empty string, add a warning.
25
+ * - "throw": throw an Error listing all unresolved refs.
26
+ */
27
+ readonly onMissing?: "leave" | "empty" | "throw";
28
+ }
29
+ export interface ExpandResult {
30
+ /** Expanded key→value map (file-only — fallback is not included). */
31
+ readonly values: Record<string, string>;
32
+ /** Re-serialized env-file content with all values expanded. */
33
+ readonly envSrc: string;
34
+ /** Variables that were referenced but couldn't be resolved. */
35
+ readonly unresolved: string[];
36
+ /** Variables that participated in an unresolvable cycle. */
37
+ readonly cycles: string[][];
38
+ }
39
+ /** Expand a key→value record. Returns the expanded record + diagnostics. */
40
+ export declare function expandRecord(values: Readonly<Record<string, string>>, opts?: ExpandOptions): {
41
+ values: Record<string, string>;
42
+ unresolved: string[];
43
+ cycles: string[][];
44
+ };
45
+ /**
46
+ * Expand variables in a parsed env file (string in, string out). The
47
+ * file's own values take precedence; `opts.fallback` (default:
48
+ * `process.env`) fills in the rest.
49
+ */
50
+ export declare function expandEnvSrc(envSrc: string, opts?: ExpandOptions): ExpandResult;
51
+ //# sourceMappingURL=expand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../src/libs/expand.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACjE;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;CAClD;AAED,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAC9B,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CAC7B;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAC1B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACxC,IAAI,GAAE,aAAkB,GACvB;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CAiG9E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,aAAkB,GAAG,YAAY,CAiBnF"}
@@ -0,0 +1,22 @@
1
+ import { ProcessedEnv } from './types.js';
2
+ export type { ProcessedEnv, ProcessingError, ErrorCode, RunOptions, RunResult, } from './types.js';
3
+ export { ENCRYPTED_PREFIX, encryptValueAsymmetric, decryptValueAsymmetric, generateKeyPair, isEncrypted, } from './crypto.js';
4
+ export { parseEnv, serializeEnv, toRecord, type EnvLine, type KvLine, type RawLine, } from './parser.js';
5
+ export { ENVX_PRIVATE_KEY_PREFIX, ENVX_PUBLIC_KEY_PREFIX, KEYS_FILE_BANNER, LEGACY_PRIVATE_KEY_PREFIX, LEGACY_PUBLIC_KEY_PREFIX, PUBLIC_KEY_BANNER, defaultKeysPath, defaultKeysPathFor, privateKeyCandidateNamesFor, privateKeyNameFor, publicKeyCandidateNamesFor, publicKeyNameFor, readKeysFile, writeKeysFile, } from './keys.js';
6
+ export { isSelected, matchesAny } from './match.js';
7
+ export { encryptFiles } from './encrypt.js';
8
+ export { decryptFiles } from './decrypt.js';
9
+ export { rotateFiles } from './rotate.js';
10
+ export { expandRecord, expandEnvSrc, type ExpandOptions, type ExpandResult, } from './expand.js';
11
+ export { auditFiles, BUILT_IN_PATTERNS, type AuditFinding, type AuditOptions, type SecretPattern, } from './audit.js';
12
+ export { defineConfig, loadDotenvxConfig, type DotenvxConfig, type LoadConfigOptions, type LoadedConfig, } from './config.js';
13
+ export { DEFAULT_NODE_ENV_MAP, detectEnvironment, validateCmdVariable, findWorkspaceRoot, resolveCwdOrWorkspace, expandCascadePaths, listEnvFiles, resolveEnvPaths, loadEnv, type DetectEnvironmentOptions, type ResolveEnvOptions, type LoadEnvOptions, } from './env.js';
14
+ /**
15
+ * Persist any changed processedEnvs to disk. Returns the absolute paths
16
+ * that were actually written. Skips entries with errors and entries
17
+ * marked unchanged.
18
+ */
19
+ export declare function writeProcessed(processed: readonly ProcessedEnv[]): {
20
+ written: string[];
21
+ };
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/libs/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,YAAY,EACZ,eAAe,EACf,SAAS,EACT,UAAU,EACV,SAAS,GAC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C;AAQlB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,SAAS,YAAY,EAAE,GACjC;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAQvB"}
@@ -0,0 +1,2 @@
1
+ import { A as loadEnv, B as ENCRYPTED_PREFIX, C as readKeysFile, D as expandCascadePaths, E as detectEnvironment, F as expandRecord, H as encryptValueAsymmetric, L as parseEnv, M as resolveEnvPaths, N as validateCmdVariable, O as findWorkspaceRoot, P as expandEnvSrc, R as serializeEnv, S as publicKeyNameFor, T as DEFAULT_NODE_ENV_MAP, U as generateKeyPair, V as decryptValueAsymmetric, W as isEncrypted, _ as defaultKeysPath, a as auditFiles, b as privateKeyNameFor, c as encryptFiles, d as ENVX_PRIVATE_KEY_PREFIX, f as ENVX_PUBLIC_KEY_PREFIX, g as PUBLIC_KEY_BANNER, h as LEGACY_PUBLIC_KEY_PREFIX, i as BUILT_IN_PATTERNS, j as resolveCwdOrWorkspace, k as listEnvFiles, l as isSelected, m as LEGACY_PRIVATE_KEY_PREFIX, n as defineConfig, o as rotateFiles, p as KEYS_FILE_BANNER, r as loadDotenvxConfig, s as decryptFiles, t as writeProcessed, u as matchesAny, v as defaultKeysPathFor, w as writeKeysFile, x as publicKeyCandidateNamesFor, y as privateKeyCandidateNamesFor, z as toRecord } from "../chunks/libs-CqVa6LY9.js";
2
+ export { BUILT_IN_PATTERNS, DEFAULT_NODE_ENV_MAP, ENCRYPTED_PREFIX, ENVX_PRIVATE_KEY_PREFIX, ENVX_PUBLIC_KEY_PREFIX, KEYS_FILE_BANNER, LEGACY_PRIVATE_KEY_PREFIX, LEGACY_PUBLIC_KEY_PREFIX, PUBLIC_KEY_BANNER, auditFiles, decryptFiles, decryptValueAsymmetric, defaultKeysPath, defaultKeysPathFor, defineConfig, detectEnvironment, encryptFiles, encryptValueAsymmetric, expandCascadePaths, expandEnvSrc, expandRecord, findWorkspaceRoot, generateKeyPair, isEncrypted, isSelected, listEnvFiles, loadDotenvxConfig, loadEnv, matchesAny, parseEnv, privateKeyCandidateNamesFor, privateKeyNameFor, publicKeyCandidateNamesFor, publicKeyNameFor, readKeysFile, resolveCwdOrWorkspace, resolveEnvPaths, rotateFiles, serializeEnv, toRecord, validateCmdVariable, writeKeysFile, writeProcessed };
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Canonical (default) prefix for envx private-key variables. Used when
3
+ * encrypt writes a fresh entry to `.env.keys`.
4
+ */
5
+ export declare const ENVX_PRIVATE_KEY_PREFIX = "ENVX_PRIVATE_KEY";
6
+ /**
7
+ * Canonical prefix for envx public-key variables. Stored in plaintext at
8
+ * the top of the encrypted `.env*` file so anyone with read access can
9
+ * encrypt new values; only the holder of the matching private key (in
10
+ * `.env.keys`) can decrypt.
11
+ */
12
+ export declare const ENVX_PUBLIC_KEY_PREFIX = "ENVX_PUBLIC_KEY";
13
+ /**
14
+ * Legacy prefix kept for backwards compatibility with the upstream
15
+ * `dotenvx` convention. envx will read keys stored under this prefix
16
+ * but never *writes* new ones with it.
17
+ */
18
+ export declare const LEGACY_PRIVATE_KEY_PREFIX = "DOTENV_PRIVATE_KEY";
19
+ /** Legacy public-key prefix (upstream dotenvx). Read-only fallback. */
20
+ export declare const LEGACY_PUBLIC_KEY_PREFIX = "DOTENV_PUBLIC_KEY";
21
+ /**
22
+ * Canonical private-key variable name for an env file:
23
+ * `ENVX_PRIVATE_KEY` for `.env`, `ENVX_PRIVATE_KEY_PROD` for `.env.prod`,
24
+ * etc. This is the name encrypt writes to `.env.keys`.
25
+ *
26
+ * Decrypt accepts both this and the legacy `DOTENV_PRIVATE_KEY*` form
27
+ * — see {@link privateKeyCandidateNamesFor}.
28
+ */
29
+ export declare function privateKeyNameFor(envFilePath: string): string;
30
+ /**
31
+ * Both names a `.env.keys` file may use for the given env file's private
32
+ * key, in resolution order:
33
+ *
34
+ * 1. `ENVX_PRIVATE_KEY*` (canonical — written by current envx)
35
+ * 2. `DOTENV_PRIVATE_KEY*` (legacy — written by upstream dotenvx
36
+ * and earlier envx versions)
37
+ *
38
+ * Callers should check each name against the keys map and use the first
39
+ * match. New keys are always written under the canonical name.
40
+ */
41
+ export declare function privateKeyCandidateNamesFor(envFilePath: string): readonly string[];
42
+ /** Canonical `ENVX_PUBLIC_KEY*` variable name for an env file. */
43
+ export declare function publicKeyNameFor(envFilePath: string): string;
44
+ /**
45
+ * Public-key candidate names, canonical first then legacy
46
+ * `DOTENV_PUBLIC_KEY*`. Decrypt callers don't need the public key
47
+ * (decryption uses the private key), but encrypt may read an existing
48
+ * public-key header from a `.env*` file to skip re-generating one.
49
+ */
50
+ export declare function publicKeyCandidateNamesFor(envFilePath: string): readonly string[];
51
+ /** Read a .env.keys file as a key→value map. Returns an empty map when the file doesn't exist. */
52
+ export declare function readKeysFile(keysPath: string): Map<string, string>;
53
+ /**
54
+ * Banner for `.env.keys` files. Mirrors the upstream `dotenvx`
55
+ * formatting so the file is self-describing and visually distinct.
56
+ */
57
+ export declare const KEYS_FILE_BANNER: string;
58
+ /**
59
+ * Banner placed above an `ENVX_PUBLIC_KEY*` entry inside a `.env*` file.
60
+ * Public keys are safe to commit — anyone with them can encrypt; only
61
+ * the private-key holder can decrypt.
62
+ */
63
+ export declare const PUBLIC_KEY_BANNER: string;
64
+ /**
65
+ * Persist a key→value map to `.env.keys`. Overwrites the file. Preserves
66
+ * order from the input map (so consumers get stable diffs) and emits the
67
+ * private-keys banner when writing a non-empty map.
68
+ *
69
+ * `sectionFor` (optional): a function that, given a key name, returns a
70
+ * section header to write above it (e.g. `# .env.dev`). Used by encrypt
71
+ * to group keys by their associated env file.
72
+ */
73
+ export declare function writeKeysFile(keysPath: string, keys: Map<string, string>, opts?: {
74
+ readonly sectionFor?: (keyName: string) => string | undefined;
75
+ }): void;
76
+ /**
77
+ * Default location for `.env.keys`: cwd first, with a walk-up to the
78
+ * workspace root if no `.env.keys` exists at cwd. This lets users run
79
+ * envx from a subpackage and still find the workspace-level keys file
80
+ * without passing `-fk`.
81
+ *
82
+ * If neither location has a file, falls back to `<cwd>/.env.keys` so a
83
+ * fresh `envx encrypt` creates the file where the user expects it.
84
+ */
85
+ export declare function defaultKeysPath(): string;
86
+ /**
87
+ * @deprecated Use `defaultKeysPath()` instead. Kept as a thin re-export so
88
+ * external callers don't break — the `envFilepath` argument is now ignored
89
+ * and the returned path is always `<cwd>/.env.keys`.
90
+ */
91
+ export declare function defaultKeysPathFor(_envFilepath: string): string;
92
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/libs/keys.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,oBAAoB,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D,uEAAuE;AACvE,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,MAAM,GAClB,SAAS,MAAM,EAAE,CAKnB;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,GAClB,SAAS,MAAM,EAAE,CAKnB;AAoBD,kGAAkG;AAClG,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAIlE;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAIsC,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAIqC,CAAC;AAEpE;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACzB,IAAI,GAAE;IACJ,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAC1D,GACL,IAAI,CA+BN;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE/D"}
@@ -0,0 +1,7 @@
1
+ export declare function matchesAny(key: string, patterns: readonly string[]): boolean;
2
+ /**
3
+ * Decide whether to operate on a key given include + exclude filters.
4
+ * Empty includes means "all keys". Excludes always win.
5
+ */
6
+ export declare function isSelected(key: string, includes: readonly string[], excludes: readonly string[]): boolean;
7
+ //# sourceMappingURL=match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../src/libs/match.ts"],"names":[],"mappings":"AAcA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAK5E;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,OAAO,CAIT"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Line-preserving env-file parser. We parse to a typed line array
3
+ * rather than a flat key→value map so that round-tripping (encrypt
4
+ * one value, write file back) preserves comments, blank lines, and
5
+ * declaration order — the signal-to-noise ratio of an env file's diff
6
+ * is critical when these files live in version control.
7
+ */
8
+ export interface KvLine {
9
+ readonly type: "kv";
10
+ readonly key: string;
11
+ /** Raw value as it appeared in the file (still quoted if it was). */
12
+ readonly raw: string;
13
+ /** Logical value — quotes stripped, escape sequences resolved. */
14
+ value: string;
15
+ /** Quote style for serialization. Mutable so transforms (e.g. encrypt)
16
+ * can drop quotes when the new value is self-quote-safe (URL-safe base64). */
17
+ quote: '"' | "'" | "";
18
+ /** Trailing comment, including the leading '#' and whitespace. */
19
+ readonly trailing: string;
20
+ }
21
+ export interface RawLine {
22
+ readonly type: "raw";
23
+ /** Comment lines, blank lines, malformed lines — preserved verbatim. */
24
+ readonly raw: string;
25
+ }
26
+ export type EnvLine = KvLine | RawLine;
27
+ /** Parse a raw env-file string into a line array. */
28
+ export declare function parseEnv(content: string): EnvLine[];
29
+ /** Re-serialize a parsed line array. Round-trip safe for unmodified inputs. */
30
+ export declare function serializeEnv(lines: readonly EnvLine[]): string;
31
+ /** Build a flat key→value map from a parsed line array. Last write wins. */
32
+ export declare function toRecord(lines: readonly EnvLine[]): Record<string, string>;
33
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/libs/parser.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd;mFAC+E;IAC/E,KAAK,EAAE,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,wEAAwE;IACxE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAIvC,qDAAqD;AACrD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAwBnD;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAQ9D;AAsFD,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM1E"}
@@ -0,0 +1,24 @@
1
+ import { RunOptions, RunResult } from './types.js';
2
+ /**
3
+ * Rotate the keypair on one or more `.env*` files. For each file:
4
+ *
5
+ * 1. Locate the existing public-key header (`ENVX_PUBLIC_KEY*` —
6
+ * or `DOTENV_PUBLIC_KEY*` for dotenvx-compat reads). Files without
7
+ * a header surface an `INVALID_CIPHERTEXT` error: rotation needs
8
+ * the existing keypair to round-trip the values.
9
+ * 2. Look up the matching private key in `.env.keys` (canonical
10
+ * `ENVX_PRIVATE_KEY*` first, then `DOTENV_PRIVATE_KEY*`).
11
+ * 3. Generate a fresh secp256k1 keypair.
12
+ * 4. Decrypt every encrypted value with the *old* private key,
13
+ * re-encrypt with the *new* public key.
14
+ * 5. Replace the public-key header line in the env file with the
15
+ * new public key, and write the new private key under the
16
+ * canonical name in `.env.keys`. The keys file is written eagerly
17
+ * so the returned envSrc is decryptable on disk if persisted.
18
+ *
19
+ * Pure (per the encrypt/decrypt convention): returns new file contents
20
+ * but does not write the env files themselves to disk. Use
21
+ * {@link writeProcessed} on the returned `processedEnvs` to persist.
22
+ */
23
+ export declare function rotateFiles(opts: RunOptions): RunResult;
24
+ //# sourceMappingURL=rotate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rotate.d.ts","sourceRoot":"","sources":["../../src/libs/rotate.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAiC,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CA2LvD"}
@@ -0,0 +1,42 @@
1
+ /** Per-file processing result. Mirrors the shape of upstream dotenvx
2
+ * for familiarity, but is fully owned by this package. */
3
+ export interface ProcessedEnv {
4
+ /** Path the caller supplied (may be relative). */
5
+ readonly envFilepath: string;
6
+ /** Absolute resolved path on disk. */
7
+ readonly filepath: string;
8
+ /** New file contents after the operation. */
9
+ readonly envSrc: string;
10
+ /** True when envSrc differs from the on-disk file. */
11
+ readonly changed: boolean;
12
+ /** All keys observed in the file. */
13
+ readonly keys: string[];
14
+ /** Set when a private key was newly generated and stored in .env.keys. */
15
+ readonly privateKeyAdded?: boolean;
16
+ readonly privateKeyName?: string;
17
+ readonly privateKey?: string;
18
+ /** Set when the file failed to process. */
19
+ readonly error?: ProcessingError;
20
+ }
21
+ export interface ProcessingError {
22
+ readonly code: ErrorCode;
23
+ readonly message: string;
24
+ readonly help?: string;
25
+ }
26
+ export type ErrorCode = "MISSING_ENV_FILE" | "MISSING_PRIVATE_KEY" | "DECRYPTION_FAILED" | "INVALID_CIPHERTEXT";
27
+ export interface RunOptions {
28
+ /** Env file paths to operate on. */
29
+ readonly envFiles: readonly string[];
30
+ /** Specific keys (or globs) to include. Default: all keys. */
31
+ readonly keys?: readonly string[];
32
+ /** Keys (or globs) to skip. */
33
+ readonly excludeKeys?: readonly string[];
34
+ /** Path to the .env.keys file (default: alongside the env file). */
35
+ readonly envKeysFile?: string;
36
+ }
37
+ export interface RunResult {
38
+ readonly processedEnvs: ProcessedEnv[];
39
+ readonly changedFilepaths: string[];
40
+ readonly unchangedFilepaths: string[];
41
+ }
42
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/libs/types.ts"],"names":[],"mappings":"AAEA;0DAC0D;AAC1D,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,QAAQ,CA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EAAE,MAAM,EAAE,CAAC;CACvC"}
@@ -0,0 +1,50 @@
1
+ import { SecretProvider } from './types.js';
2
+ export interface AutoPreloadOptions {
3
+ /**
4
+ * Env files to scan for `${provider:id}` references. Paths are
5
+ * resolved against `cwd` (which defaults to `process.cwd()`).
6
+ * Missing files are silently skipped — the helper assumes you
7
+ * already know which files will load and just need the references
8
+ * pre-resolved.
9
+ */
10
+ readonly envFiles: readonly string[];
11
+ /** Defaults to `process.cwd()`. */
12
+ readonly cwd?: string;
13
+ }
14
+ /**
15
+ * Scan a set of env files for `${provider:id}` references and call
16
+ * `preload()` on every plugin whose `name` matches a found provider.
17
+ * Plugins whose names don't appear in any reference are skipped (no
18
+ * round-trip, no SDK warm-up, no surprise charges).
19
+ *
20
+ * Composes with the rest of envx like this:
21
+ *
22
+ * ```ts
23
+ * import envx from "@super-repo/envx";
24
+ * import { awsSecrets } from "@super-repo/envx/plugins/aws";
25
+ * import { gcpSecrets } from "@super-repo/envx/plugins/gcp";
26
+ * import { autoPreload } from "@super-repo/envx/plugins";
27
+ *
28
+ * const aws = awsSecrets({ region: "us-east-1" });
29
+ * const gcp = gcpSecrets({ projectId: "acme-prod" });
30
+ *
31
+ * await autoPreload([aws, gcp], { envFiles: [".env", "vault/.env.prod"] });
32
+ *
33
+ * envx({
34
+ * resolvers: {
35
+ * [aws.name]: aws.resolve,
36
+ * [gcp.name]: gcp.resolve,
37
+ * },
38
+ * });
39
+ * ```
40
+ */
41
+ export declare function autoPreload(providers: readonly SecretProvider[], opts: AutoPreloadOptions): Promise<{
42
+ readonly preloaded: Record<string, string[]>;
43
+ }>;
44
+ /**
45
+ * Build a `resolvers:` map from a list of providers — the shape envx's
46
+ * `resolvers` config expects. Saves you from repeating
47
+ * `{ [p.name]: p.resolve }` for every provider.
48
+ */
49
+ export declare function asResolvers(providers: readonly SecretProvider[]): Record<string, (id: string) => string | undefined>;
50
+ //# sourceMappingURL=auto-preload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-preload.d.ts","sourceRoot":"","sources":["../../src/plugins/auto-preload.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAOjD,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,mCAAmC;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,SAAS,cAAc,EAAE,EACpC,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC,CAiC3D;AAMD;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,SAAS,cAAc,EAAE,GACnC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,CAIpD"}
@@ -0,0 +1,2 @@
1
+ import { n as autoPreload, t as asResolvers } from "../chunks/auto-preload-CrSuZDg1.js";
2
+ export { asResolvers, autoPreload };
@@ -0,0 +1,52 @@
1
+ import { SecretProvider } from './types.js';
2
+ export interface AwsSecretsOptions {
3
+ /** AWS region the secrets live in (e.g. "us-east-1"). */
4
+ readonly region: string;
5
+ /**
6
+ * Override the default SDK client. Useful for tests, for sharing a
7
+ * client across plugins, or when your environment needs a custom
8
+ * credential provider chain. The object only needs a `send(command)`
9
+ * method that returns a `{ SecretString?: string; SecretBinary?: Uint8Array }`.
10
+ */
11
+ readonly client?: {
12
+ send: (cmd: unknown) => Promise<{
13
+ SecretString?: string;
14
+ SecretBinary?: Uint8Array;
15
+ }>;
16
+ };
17
+ /**
18
+ * Custom name for this provider instance. Defaults to `"aws-secrets"`,
19
+ * matching the conventional `${aws-secrets:my-id}` reference shape. If
20
+ * you want multiple AWS regions to coexist, give each a distinct name
21
+ * (`"aws-us"`, `"aws-eu"`) and reference accordingly.
22
+ */
23
+ readonly name?: string;
24
+ }
25
+ /**
26
+ * AWS Secrets Manager provider.
27
+ *
28
+ * ```ts
29
+ * import { awsSecrets } from "@super-repo/envx/plugins/aws";
30
+ *
31
+ * const aws = awsSecrets({ region: "us-east-1" });
32
+ * await aws.preload(["prod/db", "prod/api-key"]);
33
+ *
34
+ * envx({
35
+ * resolvers: { [aws.name]: aws.resolve },
36
+ * });
37
+ * ```
38
+ *
39
+ * Reference shape in `.env*`:
40
+ *
41
+ * ```
42
+ * DATABASE_URL=${aws-secrets:prod/db}
43
+ * API_KEY=${aws-secrets:prod/api-key}
44
+ * ```
45
+ *
46
+ * The plugin uses `@aws-sdk/client-secrets-manager` (lazy-loaded —
47
+ * only required when `preload()` runs). Install it in your app:
48
+ *
49
+ * pnpm add @aws-sdk/client-secrets-manager
50
+ */
51
+ export declare function awsSecrets(opts: AwsSecretsOptions): SecretProvider;
52
+ //# sourceMappingURL=aws.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../../src/plugins/aws.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjF,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,IAAI,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;YAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;YACtB,YAAY,CAAC,EAAE,UAAU,CAAC;SAC3B,CAAC,CAAC;KACJ,CAAC;IACF;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,CAkDlE"}
@@ -0,0 +1,2 @@
1
+ import { t as awsSecrets } from "../chunks/aws-DgcXfw-Y.js";
2
+ export { awsSecrets };