node-env-resolver 6.6.0 → 6.7.1
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 +186 -11
- package/dist/audit.d.ts +7 -8
- package/dist/audit.d.ts.map +1 -0
- package/dist/builder.cjs +1 -1
- package/dist/builder.d.ts +9 -12
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +1 -1
- package/dist/chunk-3TXO5AOZ.cjs +3 -0
- package/dist/chunk-4CLWNKB5.js +1 -0
- package/dist/chunk-4DUWYBNJ.cjs +6 -0
- package/dist/chunk-6NSX37SO.js +6 -0
- package/dist/chunk-BITH5LSH.js +3 -0
- package/dist/{chunk-DIJNUFGZ.cjs → chunk-G5HNCCR6.cjs} +3 -3
- package/dist/chunk-IP6POQCY.cjs +1 -0
- package/dist/{chunk-ZSM2NDX5.js → chunk-JVRRDD3Y.js} +3 -3
- package/dist/chunk-KHEBSYFP.js +9 -0
- package/dist/chunk-NHXSZY2U.cjs +9 -0
- package/dist/chunk-NKISCWWB.js +1 -0
- package/dist/chunk-UZ7HKTYL.cjs +1 -0
- package/dist/cli/bin.cjs +67 -27
- package/dist/cli/bin.d.ts +11 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +67 -27
- package/dist/cli/scan.d.ts +24 -0
- package/dist/cli/scan.d.ts.map +1 -0
- package/dist/cli.d.ts +4 -7
- package/dist/cli.d.ts.map +1 -0
- package/dist/debug.d.ts +142 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +19 -61
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/inspect.d.ts +63 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/process-env.d.ts +32 -0
- package/dist/process-env.d.ts.map +1 -0
- package/dist/provider-kit.d.ts +7 -8
- package/dist/provider-kit.d.ts.map +1 -0
- package/dist/providers.d.ts +49 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/references.d.ts +5 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.d.ts +16 -8
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.ts +13 -31
- package/dist/resolvers.d.ts.map +1 -0
- package/dist/resolvers.js +1 -1
- package/dist/runtime/index.cjs +1 -1
- package/dist/runtime/index.d.ts +8 -108
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/patch-console.d.ts +23 -0
- package/dist/runtime/patch-console.d.ts.map +1 -0
- package/dist/runtime/redactor.d.ts +22 -0
- package/dist/runtime/redactor.d.ts.map +1 -0
- package/dist/runtime/response.d.ts +59 -0
- package/dist/runtime/response.d.ts.map +1 -0
- package/dist/security.d.ts +49 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/sensitivity.d.ts +34 -0
- package/dist/sensitivity.d.ts.map +1 -0
- package/dist/types.d.ts +150 -1
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +19 -21
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +1 -1
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.d.ts +9 -11
- package/dist/valibot.d.ts.map +1 -0
- package/dist/valibot.js +1 -1
- package/dist/validation-types.d.ts +3 -4
- package/dist/validation-types.d.ts.map +1 -0
- package/dist/validators.cjs +2 -2
- package/dist/validators.d.ts +59 -44
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +2 -2
- package/dist/web.cjs +3 -3
- package/dist/web.d.ts +8 -10
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js +3 -3
- package/dist/zod.cjs +1 -1
- package/dist/zod.d.ts +9 -11
- package/dist/zod.d.ts.map +1 -0
- package/dist/zod.js +1 -1
- package/package.json +15 -23
- package/dist/audit.d.cts +0 -52
- package/dist/builder.d.cts +0 -149
- package/dist/chunk-3EWCMDFP.js +0 -9
- package/dist/chunk-4QOKRJ3F.cjs +0 -1
- package/dist/chunk-DYFRO3NM.cjs +0 -9
- package/dist/chunk-K4NIC5T3.js +0 -9
- package/dist/chunk-WKIPEKF6.js +0 -1
- package/dist/chunk-WVMDTD6J.cjs +0 -9
- package/dist/cli/bin.d.cts +0 -1
- package/dist/cli.d.cts +0 -52
- package/dist/index.d.cts +0 -220
- package/dist/provider-kit.d.cts +0 -50
- package/dist/resolver.d.cts +0 -20
- package/dist/resolvers.d.cts +0 -190
- package/dist/runtime/index.d.cts +0 -161
- package/dist/types--RcOnfdl.d.cts +0 -284
- package/dist/types--RcOnfdl.d.ts +0 -284
- package/dist/types.d.cts +0 -1
- package/dist/utils.d.cts +0 -327
- package/dist/valibot.d.cts +0 -143
- package/dist/validation-types.d.cts +0 -29
- package/dist/validators.d.cts +0 -933
- package/dist/web.d.cts +0 -71
- package/dist/zod.d.cts +0 -122
package/README.md
CHANGED
|
@@ -154,6 +154,7 @@ const config = await resolveAsync({
|
|
|
154
154
|
- [Optional values](#optional-values)
|
|
155
155
|
- [Enums](#enums)
|
|
156
156
|
- [Optional Enums](#optional-enums)
|
|
157
|
+
- [Inferring the config type](#inferring-the-config-type)
|
|
157
158
|
- [Variable Naming Conventions](#variable-naming-conventions)
|
|
158
159
|
- [Performance & Bundle Size](#performance--bundle-size)
|
|
159
160
|
- [Custom validators](#custom-validators)
|
|
@@ -263,6 +264,26 @@ const config = resolve({
|
|
|
263
264
|
// config.COMPRESSION: 'gzip' | 'brotli' | 'none'
|
|
264
265
|
```
|
|
265
266
|
|
|
267
|
+
### Inferring the config type
|
|
268
|
+
|
|
269
|
+
Define the schema once and derive its type with `InferSimpleSchema`:
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
import { resolve, type InferSimpleSchema } from 'node-env-resolver';
|
|
273
|
+
import { port, string } from 'node-env-resolver/validators';
|
|
274
|
+
|
|
275
|
+
const schema = {
|
|
276
|
+
PORT: port({ default: 8400 }),
|
|
277
|
+
TOKEN: string(),
|
|
278
|
+
NODE_ENV: ['development', 'production'] as const,
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export type Env = InferSimpleSchema<typeof schema>;
|
|
282
|
+
// { PORT: number; TOKEN: string; NODE_ENV: 'development' | 'production' }
|
|
283
|
+
|
|
284
|
+
export const env: Env = resolve(schema);
|
|
285
|
+
```
|
|
286
|
+
|
|
266
287
|
## Variable Naming Conventions
|
|
267
288
|
|
|
268
289
|
The library validates environment variable names to prevent shell errors and ensure cross-platform compatibility.
|
|
@@ -677,6 +698,30 @@ if (result.success) {
|
|
|
677
698
|
}
|
|
678
699
|
```
|
|
679
700
|
|
|
701
|
+
When validation fails, `result.issues` lists each problem so you can map it to a field without parsing strings:
|
|
702
|
+
|
|
703
|
+
```ts
|
|
704
|
+
// result.issues: { key: string; reason: 'missing' | 'invalid' | 'policy'; message: string }[]
|
|
705
|
+
for (const issue of result.issues ?? []) {
|
|
706
|
+
console.error(`${issue.key} (${issue.reason}): ${issue.message}`);
|
|
707
|
+
}
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
`resolve()` and `resolveAsync()` throw an `EnvValidationError` carrying the same `issues`:
|
|
711
|
+
|
|
712
|
+
```ts
|
|
713
|
+
import { resolve, EnvValidationError } from 'node-env-resolver';
|
|
714
|
+
|
|
715
|
+
try {
|
|
716
|
+
resolve(schema);
|
|
717
|
+
} catch (error) {
|
|
718
|
+
if (error instanceof EnvValidationError) {
|
|
719
|
+
console.error(error.issues);
|
|
720
|
+
}
|
|
721
|
+
throw error;
|
|
722
|
+
}
|
|
723
|
+
```
|
|
724
|
+
|
|
680
725
|
All functions have safe variants:
|
|
681
726
|
|
|
682
727
|
- `resolve()` → `safeResolve()` (both synchronous)
|
|
@@ -725,18 +770,21 @@ The `ner` CLI ships with the package. Install globally or run via `npx ner`.
|
|
|
725
770
|
|
|
726
771
|
#### `ner scan` — secret scanner
|
|
727
772
|
|
|
728
|
-
Scans files for hardcoded secrets
|
|
773
|
+
Scans files for hardcoded secrets: Stripe keys, GitHub tokens, JWTs, DB connection strings, AWS keys, private keys and more. The scan includes dotfiles such as `.env.local` and `.npmrc`, because `.gitignore` does not stop an agent or a `git add -f` from reading them. Each finding reports file, line, column and type. Exit codes: `0` clean, `1` findings, `2` usage error.
|
|
729
774
|
|
|
730
775
|
```bash
|
|
731
776
|
# Scan a directory
|
|
732
777
|
ner scan src/
|
|
733
778
|
|
|
734
|
-
# Scan
|
|
779
|
+
# Scan the staged blobs that will be committed (pre-commit hooks)
|
|
735
780
|
ner scan --staged
|
|
736
781
|
|
|
737
|
-
# Show
|
|
782
|
+
# Show the matching line, with every secret replaced by [REDACTED]
|
|
738
783
|
ner scan --context src/
|
|
739
784
|
|
|
785
|
+
# Machine-readable output
|
|
786
|
+
ner scan --format json .
|
|
787
|
+
|
|
740
788
|
# Exclude patterns
|
|
741
789
|
ner scan --ignore "fixtures" --ignore "\.test\." src/
|
|
742
790
|
```
|
|
@@ -771,7 +819,7 @@ ner run --scan -- node server.js
|
|
|
771
819
|
```bash
|
|
772
820
|
# .env
|
|
773
821
|
DATABASE_URL=aws-sm://prod/database-credentials
|
|
774
|
-
API_KEY=aws-ssm
|
|
822
|
+
API_KEY=aws-ssm:///prod/payments/api-key
|
|
775
823
|
```
|
|
776
824
|
|
|
777
825
|
```bash
|
|
@@ -783,9 +831,95 @@ ner run -- node server.js
|
|
|
783
831
|
Requires `node-env-resolver-aws` for `aws-sm://` and `aws-ssm://` support:
|
|
784
832
|
|
|
785
833
|
```bash
|
|
786
|
-
npm install node-env-resolver-aws
|
|
834
|
+
npm install node-env-resolver-aws @aws-sdk/client-secrets-manager @aws-sdk/client-ssm
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
> `ner run` passes the resolved values and the parent environment to the child process. Launch your app with it, not a coding agent. See [Coding agents](#coding-agents).
|
|
838
|
+
|
|
839
|
+
#### `ner describe`: schema manifest
|
|
840
|
+
|
|
841
|
+
`ner describe` prints names, types, requirements, descriptions and fake examples from your schema. It reads no values and calls no providers, so you can commit the output and hand it to a coding agent.
|
|
842
|
+
|
|
843
|
+
```ts
|
|
844
|
+
// env.schema.ts: export the schema you pass to resolve()
|
|
845
|
+
import { secret, url, port, withMeta } from 'node-env-resolver/validators';
|
|
846
|
+
|
|
847
|
+
export const schema = {
|
|
848
|
+
STRIPE_KEY: withMeta(secret(), { description: 'Stripe API key' }),
|
|
849
|
+
API_URL: withMeta(url(), { description: 'Upstream API', example: 'https://api.example.com' }),
|
|
850
|
+
PORT: port({ default: 3000 }),
|
|
851
|
+
};
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
```bash
|
|
855
|
+
ner describe # table
|
|
856
|
+
ner describe --format json > env.manifest.json
|
|
857
|
+
ner describe --format dotenv > .env.example
|
|
858
|
+
```
|
|
859
|
+
|
|
860
|
+
The CLI loads `env.schema.{ts,mts,js,mjs}` or `--schema <file>`, using the `schema` export or the default export. `.ts` files need Node 22.18+ or a loader such as `tsx`.
|
|
861
|
+
|
|
862
|
+
In code, use `describeSchema(schema)`, `toDotenvExample(schema)` and `fakeEnv(schema)`. `fakeEnv` returns fake values for tests that run without cloud credentials. It validates each value and throws if a constraint such as `number({ min: 10 })` rejects the generated one. Supply your own with `withMeta(validator, { example })`.
|
|
863
|
+
|
|
864
|
+
```ts
|
|
865
|
+
import { resolve, fakeEnv } from 'node-env-resolver';
|
|
866
|
+
import { fromObject } from 'node-env-resolver/resolvers';
|
|
867
|
+
|
|
868
|
+
const config = resolve({ resolvers: [[fromObject(fakeEnv(schema)), schema]] });
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
#### `ner check`: validate without printing values
|
|
872
|
+
|
|
873
|
+
```bash
|
|
874
|
+
ner check # offline: reference URIs show up as "deferred"
|
|
875
|
+
ner check --agent # JSON: { ok, issues: [{ key, code, message, sensitive }], deferred }
|
|
876
|
+
ner check --resolve # online: resolve aws-sm:// and friends first (needs credentials)
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
Output contains key names, issue codes and the failed type check, plus allowed values for enums. It leaves out values, fragments, lengths, fingerprints and validator messages. `--resolve` resolves schema keys that use a known reference scheme (`aws-sm`, `aws-ssm`, `op`, `bws`, `doppler`, `infisical`, `vault`) and treats plain URLs as values. A `file()` variable with a `secretsDir` shows up as deferred. Exit codes: `0` valid, `1` missing or invalid variables, `2` usage or schema error.
|
|
880
|
+
|
|
881
|
+
### Sensitive values
|
|
882
|
+
|
|
883
|
+
The library masks sensitive values in debug views and redacts them in runtime console and HTTP protection, including numbers and `json()` fields. The Next.js and Vite adapters reject them from client config, by validator and by resolved value. A value counts as sensitive when:
|
|
884
|
+
|
|
885
|
+
1. **You mark it**: `secret()`, `file()`, `postgres()`, `mysql()`, `mongodb()`, `redis()`, or `withMeta(validator, { sensitive: true })`.
|
|
886
|
+
2. **It contains a marked value**: for example a URL built by interpolation or `withComputed()`. Encodings such as base64 fall outside this check.
|
|
887
|
+
3. **Its key name matches** `DEFAULT_SENSITIVE_PATTERNS` (`*KEY*`, `*TOKEN*`, `*SECRET*`, `*PASSWORD*` and others).
|
|
888
|
+
|
|
889
|
+
`withMeta(validator, { sensitive: false })` turns off the key-name match for `ner describe` and `ner check`. Debug views and runtime redaction keep it on.
|
|
890
|
+
|
|
891
|
+
### Coding agents
|
|
892
|
+
|
|
893
|
+
A coding agent reads whatever its process can reach: environment variables, repo files including git-ignored `.env` files, and command output. Give the agent the schema and the right to use credentials, and keep the credential values on the host.
|
|
894
|
+
|
|
895
|
+
- **Share context**: commit `ner describe --format json` output. Let agents run `ner check --agent` and tests against `fakeEnv(schema)`.
|
|
896
|
+
- **Keep plaintext out of the workspace**: put reference URIs (`aws-sm://...`) in `.env`. Docker documents that a sandboxed agent can read ignored and untracked files in the mounted repo.
|
|
897
|
+
- **Launch agents directly**: an agent started through `ner run` inherits every resolved secret.
|
|
898
|
+
|
|
899
|
+
#### Docker Sandboxes
|
|
900
|
+
|
|
901
|
+
[Docker Sandboxes](https://docs.docker.com/ai/sandboxes/security/credentials/) run agents in a microVM. A proxy on the host holds the real credential and the agent sees a placeholder. The proxy swaps in the real value on requests to hosts you allow. Point it at the secret your reference already names, and the value stays on the host:
|
|
902
|
+
|
|
903
|
+
```bash
|
|
904
|
+
# .env, shared with the sandbox: references only
|
|
905
|
+
STRIPE_KEY=aws-sm://prod/stripe-key
|
|
906
|
+
|
|
907
|
+
# On the host. The sandbox sees STRIPE_KEY=<placeholder>; the proxy injects
|
|
908
|
+
# the real value on requests to api.stripe.com.
|
|
909
|
+
sbx secret set-custom \
|
|
910
|
+
--host api.stripe.com \
|
|
911
|
+
--env STRIPE_KEY \
|
|
912
|
+
--command 'aws secretsmanager get-secret-value --secret-id prod/stripe-key --query SecretString --output text'
|
|
913
|
+
|
|
914
|
+
# 1Password references work for built-in services
|
|
915
|
+
sbx secret set anthropic --ref 'op://Work/Anthropic/credential'
|
|
787
916
|
```
|
|
788
917
|
|
|
918
|
+
Plan for two limits:
|
|
919
|
+
|
|
920
|
+
- The agent can make any request the credential allows to the allowed hosts. Scope credentials and host lists tightly.
|
|
921
|
+
- The proxy swaps placeholders in HTTP(S) traffic. Database drivers and SDKs that sign requests locally need the raw value, so run them against `fakeEnv(schema)` or local services and keep real integration tests outside the sandbox.
|
|
922
|
+
|
|
789
923
|
### Runtime Protection
|
|
790
924
|
|
|
791
925
|
Prevent accidental secret leaks in console output and HTTP responses.
|
|
@@ -1099,7 +1233,7 @@ This is useful when you want `OPENAI_API_KEY` to point at `API_KEY` without dupl
|
|
|
1099
1233
|
Install the AWS package:
|
|
1100
1234
|
|
|
1101
1235
|
```bash
|
|
1102
|
-
npm install node-env-resolver-aws
|
|
1236
|
+
npm install node-env-resolver-aws @aws-sdk/client-secrets-manager @aws-sdk/client-ssm
|
|
1103
1237
|
```
|
|
1104
1238
|
|
|
1105
1239
|
#### Reference URIs (recommended)
|
|
@@ -1110,7 +1244,7 @@ Store references in your `.env` and resolve at startup — no AWS SDK imports ne
|
|
|
1110
1244
|
# .env
|
|
1111
1245
|
DATABASE_URL=aws-sm://prod/database-credentials
|
|
1112
1246
|
DB_PASSWORD=aws-sm://prod/database#password # extract a JSON key
|
|
1113
|
-
API_KEY=aws-ssm
|
|
1247
|
+
API_KEY=aws-ssm:///prod/payments/api-key
|
|
1114
1248
|
```
|
|
1115
1249
|
|
|
1116
1250
|
```ts
|
|
@@ -1652,6 +1786,23 @@ export const handler = async (event) => {
|
|
|
1652
1786
|
};
|
|
1653
1787
|
```
|
|
1654
1788
|
|
|
1789
|
+
If the values arrive as an object (e.g. Cloudflare Workers `env`, or a Lambda event/context you've merged), resolve from it directly with `fromObject()`:
|
|
1790
|
+
|
|
1791
|
+
```ts
|
|
1792
|
+
import { resolve } from 'node-env-resolver';
|
|
1793
|
+
import { fromObject } from 'node-env-resolver/resolvers';
|
|
1794
|
+
import { string } from 'node-env-resolver/validators';
|
|
1795
|
+
|
|
1796
|
+
export default {
|
|
1797
|
+
async fetch(request: Request, env: Record<string, string | undefined>) {
|
|
1798
|
+
const config = resolve({
|
|
1799
|
+
resolvers: [[fromObject(env), { API_KEY: string() }]],
|
|
1800
|
+
});
|
|
1801
|
+
// ...
|
|
1802
|
+
},
|
|
1803
|
+
};
|
|
1804
|
+
```
|
|
1805
|
+
|
|
1655
1806
|
## Security Policies
|
|
1656
1807
|
|
|
1657
1808
|
Control where environment variables can be loaded from to enforce security requirements.
|
|
@@ -2205,6 +2356,28 @@ describe('getConfig', () => {
|
|
|
2205
2356
|
});
|
|
2206
2357
|
```
|
|
2207
2358
|
|
|
2359
|
+
### Resolving from a plain object
|
|
2360
|
+
|
|
2361
|
+
Use `fromObject()` when you already have an env object (tests, Lambda, Workers). `undefined` values are skipped, so `Record<string, string | undefined>` works as-is:
|
|
2362
|
+
|
|
2363
|
+
```typescript
|
|
2364
|
+
import { resolve } from 'node-env-resolver';
|
|
2365
|
+
import { fromObject } from 'node-env-resolver/resolvers';
|
|
2366
|
+
import { string, number } from 'node-env-resolver/validators';
|
|
2367
|
+
|
|
2368
|
+
const config = resolve({
|
|
2369
|
+
resolvers: [
|
|
2370
|
+
[fromObject({ DATABASE_URL: 'postgres://localhost/db', PORT: '8080' }), {
|
|
2371
|
+
DATABASE_URL: string(),
|
|
2372
|
+
PORT: number({ default: 3000 }),
|
|
2373
|
+
}],
|
|
2374
|
+
],
|
|
2375
|
+
});
|
|
2376
|
+
|
|
2377
|
+
// Or pass it to the DI-style getConfig() above
|
|
2378
|
+
const testConfig = await getConfig([fromObject({ DATABASE_URL: 'postgres://test/db' })]);
|
|
2379
|
+
```
|
|
2380
|
+
|
|
2208
2381
|
### Creating Mock Resolvers
|
|
2209
2382
|
|
|
2210
2383
|
A resolver is just an object with `name` and `load`/`loadSync` methods:
|
|
@@ -2259,15 +2432,17 @@ Benefits of dependency injection:
|
|
|
2259
2432
|
|
|
2260
2433
|
## Error messages
|
|
2261
2434
|
|
|
2262
|
-
|
|
2435
|
+
Every line names the variable it is about:
|
|
2263
2436
|
|
|
2264
2437
|
```text
|
|
2265
2438
|
Environment validation failed:
|
|
2266
|
-
-
|
|
2267
|
-
-
|
|
2268
|
-
-
|
|
2439
|
+
- PORT: Invalid port
|
|
2440
|
+
- NODE_ENV: Invalid value. Allowed values: development, production
|
|
2441
|
+
- DATABASE_URL: Missing required environment variable
|
|
2269
2442
|
```
|
|
2270
2443
|
|
|
2444
|
+
Messages leave out the rejected value, so a malformed `DATABASE_URL` or API key stays out of your startup logs. Read `error.issues` or `result.issues` for structured access (see [Safe error handling](#safe-error-handling)).
|
|
2445
|
+
|
|
2271
2446
|
## Licence
|
|
2272
2447
|
|
|
2273
2448
|
MIT
|
package/dist/audit.d.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Types of audit events that can be logged
|
|
6
6
|
*/
|
|
7
|
-
type AuditEventType = 'validation_success' | 'validation_failure' | 'policy_violation' | 'env_loaded' | 'provider_error' | 'resolver_error';
|
|
7
|
+
export type AuditEventType = 'validation_success' | 'validation_failure' | 'policy_violation' | 'env_loaded' | 'provider_error' | 'resolver_error';
|
|
8
8
|
/**
|
|
9
9
|
* Individual audit event record
|
|
10
10
|
*/
|
|
11
|
-
interface AuditEvent {
|
|
11
|
+
export interface AuditEvent {
|
|
12
12
|
/** Type of audit event */
|
|
13
13
|
type: AuditEventType;
|
|
14
14
|
/** Timestamp when the event occurred */
|
|
@@ -28,25 +28,24 @@ interface AuditEvent {
|
|
|
28
28
|
* Attach an audit session ID to a config object
|
|
29
29
|
* Returns the session ID for use in audit events
|
|
30
30
|
*/
|
|
31
|
-
declare function attachAuditSession(config: object): string;
|
|
31
|
+
export declare function attachAuditSession(config: object): string;
|
|
32
32
|
/**
|
|
33
33
|
* Log an audit event to the audit log
|
|
34
34
|
* Automatically manages log size to prevent memory leaks
|
|
35
35
|
*
|
|
36
36
|
* @param event - Audit event to log
|
|
37
37
|
*/
|
|
38
|
-
declare function logAuditEvent(event: AuditEvent): void;
|
|
38
|
+
export declare function logAuditEvent(event: AuditEvent): void;
|
|
39
39
|
/**
|
|
40
40
|
* Get audit log, optionally filtered by config object
|
|
41
41
|
*
|
|
42
42
|
* @param config - Optional config object to filter audit events for
|
|
43
43
|
* @returns Audit events (all events if no config provided, or filtered by config's session)
|
|
44
44
|
*/
|
|
45
|
-
declare function getAuditLog(config?: object): readonly AuditEvent[];
|
|
45
|
+
export declare function getAuditLog(config?: object): readonly AuditEvent[];
|
|
46
46
|
/**
|
|
47
47
|
* Clear all audit events from the audit log
|
|
48
48
|
* Useful for testing or memory management
|
|
49
49
|
*/
|
|
50
|
-
declare function clearAuditLog(): void;
|
|
51
|
-
|
|
52
|
-
export { type AuditEvent, type AuditEventType, attachAuditSession, clearAuditLog, getAuditLog, logAuditEvent };
|
|
50
|
+
export declare function clearAuditLog(): void;
|
|
51
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,oBAAoB,GACpB,oBAAoB,GACpB,kBAAkB,GAClB,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,0BAA0B;IAC1B,IAAI,EAAE,cAAc,CAAC;IACrB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMzD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAMrD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,UAAU,EAAE,CAelE;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
package/dist/builder.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk3TXO5AOZ_cjs=require('./chunk-3TXO5AOZ.cjs');require('./chunk-CDXO2XX3.cjs'),require('./chunk-UZ7HKTYL.cjs'),require('./chunk-O7NR4K6A.cjs');var chunkG5HNCCR6_cjs=require('./chunk-G5HNCCR6.cjs'),chunkIP6POQCY_cjs=require('./chunk-IP6POQCY.cjs');require('./chunk-D6WM53FN.cjs');var i=class{constructor(e,s={}){this.localSchema=e;this.options=s;}localSchema;options;layers=[];from(e,s){return this.layers.push({resolver:e,schema:s}),this}resolve(){let e=chunk3TXO5AOZ_cjs.e(this.localSchema);for(let l of this.layers){let m=chunk3TXO5AOZ_cjs.e(l.schema);Object.assign(e,m);}let s=this.buildDefaultResolvers(),r=this.layers.map(l=>l.resolver),a=this.options.extend||[],c=[...s,...r,...a],u=this.options.policies??{};return chunk3TXO5AOZ_cjs.h(e,c,{...this.options,policies:u,interpolate:this.options.interpolate??true,strict:this.options.strict??true})}buildDefaultResolvers(){let e=process.env.NODE_ENV==="production",s=[];return e||s.push(chunkG5HNCCR6_cjs.a({expand:true})),s.push(chunkIP6POQCY_cjs.b()),s}},n=class{constructor(e,s={}){this.localSchema=e;this.options=s;}localSchema;options;layers=[];from(e,s){return this.layers.push({resolver:e,schema:s}),this}resolveSync(){let e=chunk3TXO5AOZ_cjs.e(this.localSchema);for(let l of this.layers){let m=chunk3TXO5AOZ_cjs.e(l.schema);Object.assign(e,m);}let s=this.buildDefaultResolvers(),r=this.layers.map(l=>l.resolver),a=this.options.extend||[],c=[...s,...r,...a],u=this.options.policies??{};return chunk3TXO5AOZ_cjs.h(e,c,{...this.options,policies:u,interpolate:this.options.interpolate??true,strict:this.options.strict??true})}buildDefaultResolvers(){let e=process.env.NODE_ENV==="production",s=[];return e||s.push(chunkG5HNCCR6_cjs.a({expand:true})),s.push(chunkIP6POQCY_cjs.b()),s}};function y(t,e){return new i(t,e)}function b(t,e){return new n(t,e)}var d=class{builder;simpleResolve=null;constructor(e,s={}){this.builder=new i(e,s);}from(e,s){return this.builder.from(e,s),this}async compose(){return this.builder.resolve()}then(e,s){return this.simpleResolve||(this.simpleResolve=Promise.resolve(this.builder.resolve())),this.simpleResolve.then(e,s)}catch(e){return this.simpleResolve||(this.simpleResolve=Promise.resolve(this.builder.resolve())),this.simpleResolve.catch(e)}finally(e){return this.simpleResolve||(this.simpleResolve=Promise.resolve(this.builder.resolve())),this.simpleResolve.finally(e)}},S=class{builder;_resolved=null;_hasComposition=false;constructor(e,s={}){Object.defineProperty(this,"builder",{value:new n(e,s),enumerable:false,writable:true}),Object.defineProperty(this,"_hasComposition",{value:false,enumerable:false,writable:true});let r=this.builder.resolveSync();Object.defineProperty(this,"_resolved",{value:r,enumerable:false,writable:true}),Object.assign(this,r);}from(e,s){return Object.defineProperty(this,"_hasComposition",{value:true,enumerable:false,writable:true}),this.builder.from(e,s),this}compose(){return this._hasComposition&&(this._resolved=this.builder.resolveSync(),Object.assign(this,this._resolved)),this._resolved}valueOf(){return this._resolved}toJSON(){return this._resolved}};exports.EnvBuilder=i;exports.EnvBuilderSync=n;exports.ResolvableBuilder=d;exports.ResolvableBuilderSync=S;exports.env=y;exports.envSync=b;
|
package/dist/builder.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { S as SimpleEnvSchema, R as ResolveOptions, a as Resolver, I as InferSimpleSchema } from './types--RcOnfdl.js';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* EnvBuilder - Fluent API for composing environment variables from multiple resolvers
|
|
5
3
|
*
|
|
@@ -15,12 +13,12 @@ import { S as SimpleEnvSchema, R as ResolveOptions, a as Resolver, I as InferSim
|
|
|
15
13
|
* .resolve();
|
|
16
14
|
* ```
|
|
17
15
|
*/
|
|
18
|
-
|
|
19
|
-
type MergeSchemas<T, U> = Omit<T, keyof U> & U;
|
|
16
|
+
import type { Resolver, SimpleEnvSchema, InferSimpleSchema, ResolveOptions } from './types.js';
|
|
17
|
+
export type MergeSchemas<T, U> = Omit<T, keyof U> & U;
|
|
20
18
|
/**
|
|
21
19
|
* EnvBuilder class - accumulates resolvers and schemas, then resolves
|
|
22
20
|
*/
|
|
23
|
-
declare class EnvBuilder<TAccumulated extends Record<string, unknown>> {
|
|
21
|
+
export declare class EnvBuilder<TAccumulated extends Record<string, unknown>> {
|
|
24
22
|
private localSchema;
|
|
25
23
|
private options;
|
|
26
24
|
private layers;
|
|
@@ -42,7 +40,7 @@ declare class EnvBuilder<TAccumulated extends Record<string, unknown>> {
|
|
|
42
40
|
/**
|
|
43
41
|
* Synchronous EnvBuilder - only works with sync-capable resolvers
|
|
44
42
|
*/
|
|
45
|
-
declare class EnvBuilderSync<TAccumulated extends Record<string, unknown>> {
|
|
43
|
+
export declare class EnvBuilderSync<TAccumulated extends Record<string, unknown>> {
|
|
46
44
|
private localSchema;
|
|
47
45
|
private options;
|
|
48
46
|
private layers;
|
|
@@ -71,7 +69,7 @@ declare class EnvBuilderSync<TAccumulated extends Record<string, unknown>> {
|
|
|
71
69
|
* .resolve();
|
|
72
70
|
* ```
|
|
73
71
|
*/
|
|
74
|
-
declare function env<T extends SimpleEnvSchema>(localSchema: T, options?: Partial<ResolveOptions>): EnvBuilder<InferSimpleSchema<T>>;
|
|
72
|
+
export declare function env<T extends SimpleEnvSchema>(localSchema: T, options?: Partial<ResolveOptions>): EnvBuilder<InferSimpleSchema<T>>;
|
|
75
73
|
/**
|
|
76
74
|
* Synchronous version of env() - only works with sync-capable resolvers
|
|
77
75
|
*
|
|
@@ -83,13 +81,13 @@ declare function env<T extends SimpleEnvSchema>(localSchema: T, options?: Partia
|
|
|
83
81
|
* }).resolveSync();
|
|
84
82
|
* ```
|
|
85
83
|
*/
|
|
86
|
-
declare function envSync<T extends SimpleEnvSchema>(localSchema: T, options?: Partial<ResolveOptions>): EnvBuilderSync<InferSimpleSchema<T>>;
|
|
84
|
+
export declare function envSync<T extends SimpleEnvSchema>(localSchema: T, options?: Partial<ResolveOptions>): EnvBuilderSync<InferSimpleSchema<T>>;
|
|
87
85
|
/**
|
|
88
86
|
* ResolvableBuilder - A builder that is both awaitable AND chainable
|
|
89
87
|
* Simple usage: await resolve({...})
|
|
90
88
|
* Composition: await resolve({...}).from(...).compose()
|
|
91
89
|
*/
|
|
92
|
-
declare class ResolvableBuilder<TAccumulated extends Record<string, unknown>> implements PromiseLike<TAccumulated> {
|
|
90
|
+
export declare class ResolvableBuilder<TAccumulated extends Record<string, unknown>> implements PromiseLike<TAccumulated> {
|
|
93
91
|
private builder;
|
|
94
92
|
private simpleResolve;
|
|
95
93
|
constructor(localSchema: SimpleEnvSchema, options?: Partial<ResolveOptions>);
|
|
@@ -122,7 +120,7 @@ declare class ResolvableBuilder<TAccumulated extends Record<string, unknown>> im
|
|
|
122
120
|
*
|
|
123
121
|
* The returned object has all properties from TAccumulated plus builder methods
|
|
124
122
|
*/
|
|
125
|
-
declare class ResolvableBuilderSync<TAccumulated extends Record<string, unknown>> {
|
|
123
|
+
export declare class ResolvableBuilderSync<TAccumulated extends Record<string, unknown>> {
|
|
126
124
|
private builder;
|
|
127
125
|
private _resolved;
|
|
128
126
|
private _hasComposition;
|
|
@@ -145,5 +143,4 @@ declare class ResolvableBuilderSync<TAccumulated extends Record<string, unknown>
|
|
|
145
143
|
*/
|
|
146
144
|
toJSON(): TAccumulated;
|
|
147
145
|
}
|
|
148
|
-
|
|
149
|
-
export { EnvBuilder, EnvBuilderSync, type MergeSchemas, ResolvableBuilder, ResolvableBuilderSync, env, envSync };
|
|
146
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EAEf,iBAAiB,EACjB,cAAc,EACf,MAAM,YAAY,CAAC;AAIpB,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;AAUtD;;GAEG;AACH,qBAAa,UAAU,CAAC,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIhE,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,OAAO;IAJjB,OAAO,CAAC,MAAM,CAAwC;IAEtD,YACU,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE,OAAO,CAAC,cAAc,CAAM,EAC3C;IAEJ;;;OAGG;IACH,IAAI,CAAC,IAAI,SAAS,eAAe,EAC/B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,IAAI,GACX,UAAU,CAAC,YAAY,CAAC,YAAY,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAIjE;IAED;;OAEG;IACH,OAAO,IAAI,YAAY,CAqCtB;IAED;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAgB9B;AAED;;GAEG;AACH,qBAAa,cAAc,CAAC,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIpE,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,OAAO;IAJjB,OAAO,CAAC,MAAM,CAAwC;IAEtD,YACU,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE,OAAO,CAAC,cAAc,CAAM,EAC3C;IAEJ;;OAEG;IACH,IAAI,CAAC,IAAI,SAAS,eAAe,EAC/B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,IAAI,GACX,cAAc,CAAC,YAAY,CAAC,YAAY,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAIrE;IAED;;OAEG;IACH,WAAW,IAAI,YAAY,CAoC1B;IAED,OAAO,CAAC,qBAAqB;CAe9B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,eAAe,EAC3C,WAAW,EAAE,CAAC,EACd,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAChC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAElC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,eAAe,EAC/C,WAAW,EAAE,CAAC,EACd,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAChC,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAEtC;AAED;;;;GAIG;AACH,qBAAa,iBAAiB,CAC5B,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC5C,YAAW,WAAW,CAAC,YAAY,CAAC;IACpC,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,aAAa,CAAsC;IAE3D,YACE,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE,OAAO,CAAC,cAAc,CAAM,EAGtC;IAED;;OAEG;IACH,IAAI,CAAC,IAAI,SAAS,eAAe,EAC/B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,IAAI,GACX,iBAAiB,CAAC,YAAY,CAAC,YAAY,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAIxE;IAED;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,CAErC;IAED;;;OAGG;IACH,IAAI,CAAC,QAAQ,GAAG,YAAY,EAAE,QAAQ,GAAG,KAAK,EAC5C,WAAW,CAAC,EACR,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAC3D,IAAI,EACR,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,GAC1E,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAMlC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,GAAG,KAAK,EACnB,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,GACxE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,CAMjC;IAED;;OAEG;IACH,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAM9D;CACF;AAED;;;;;GAKG;AACH,qBAAa,qBAAqB,CAChC,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAE5C,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,SAAS,CAA6B;IAC9C,OAAO,CAAC,eAAe,CAAkB;IAEzC,YACE,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE,OAAO,CAAC,cAAc,CAAM,EA2BtC;IAED;;OAEG;IACH,IAAI,CAAC,IAAI,SAAS,eAAe,EAC/B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,IAAI,GACX,qBAAqB,CACtB,YAAY,CAAC,YAAY,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CACpD,CASA;IAED;;;OAGG;IACH,OAAO,IAAI,YAAY,CAOtB;IAED;;OAEG;IACH,OAAO,IAAI,YAAY,CAEtB;IAED;;OAEG;IACH,MAAM,IAAI,YAAY,CAErB;CACF"}
|
package/dist/builder.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {e,h}from'./chunk-BITH5LSH.js';import'./chunk-CTJYBBOB.js';import'./chunk-NKISCWWB.js';import'./chunk-6EWR3WHU.js';import {a}from'./chunk-JVRRDD3Y.js';import {b as b$1}from'./chunk-4CLWNKB5.js';import'./chunk-I7AUKTXE.js';var i=class{constructor(e,s={}){this.localSchema=e;this.options=s;}localSchema;options;layers=[];from(e,s){return this.layers.push({resolver:e,schema:s}),this}resolve(){let e$1=e(this.localSchema);for(let l of this.layers){let m=e(l.schema);Object.assign(e$1,m);}let s=this.buildDefaultResolvers(),r=this.layers.map(l=>l.resolver),a=this.options.extend||[],c=[...s,...r,...a],u=this.options.policies??{};return h(e$1,c,{...this.options,policies:u,interpolate:this.options.interpolate??true,strict:this.options.strict??true})}buildDefaultResolvers(){let e=process.env.NODE_ENV==="production",s=[];return e||s.push(a({expand:true})),s.push(b$1()),s}},n=class{constructor(e,s={}){this.localSchema=e;this.options=s;}localSchema;options;layers=[];from(e,s){return this.layers.push({resolver:e,schema:s}),this}resolveSync(){let e$1=e(this.localSchema);for(let l of this.layers){let m=e(l.schema);Object.assign(e$1,m);}let s=this.buildDefaultResolvers(),r=this.layers.map(l=>l.resolver),a=this.options.extend||[],c=[...s,...r,...a],u=this.options.policies??{};return h(e$1,c,{...this.options,policies:u,interpolate:this.options.interpolate??true,strict:this.options.strict??true})}buildDefaultResolvers(){let e=process.env.NODE_ENV==="production",s=[];return e||s.push(a({expand:true})),s.push(b$1()),s}};function y(t,e){return new i(t,e)}function b(t,e){return new n(t,e)}var d=class{builder;simpleResolve=null;constructor(e,s={}){this.builder=new i(e,s);}from(e,s){return this.builder.from(e,s),this}async compose(){return this.builder.resolve()}then(e,s){return this.simpleResolve||(this.simpleResolve=Promise.resolve(this.builder.resolve())),this.simpleResolve.then(e,s)}catch(e){return this.simpleResolve||(this.simpleResolve=Promise.resolve(this.builder.resolve())),this.simpleResolve.catch(e)}finally(e){return this.simpleResolve||(this.simpleResolve=Promise.resolve(this.builder.resolve())),this.simpleResolve.finally(e)}},S=class{builder;_resolved=null;_hasComposition=false;constructor(e,s={}){Object.defineProperty(this,"builder",{value:new n(e,s),enumerable:false,writable:true}),Object.defineProperty(this,"_hasComposition",{value:false,enumerable:false,writable:true});let r=this.builder.resolveSync();Object.defineProperty(this,"_resolved",{value:r,enumerable:false,writable:true}),Object.assign(this,r);}from(e,s){return Object.defineProperty(this,"_hasComposition",{value:true,enumerable:false,writable:true}),this.builder.from(e,s),this}compose(){return this._hasComposition&&(this._resolved=this.builder.resolveSync(),Object.assign(this,this._resolved)),this._resolved}valueOf(){return this._resolved}toJSON(){return this._resolved}};export{i as EnvBuilder,n as EnvBuilderSync,d as ResolvableBuilder,S as ResolvableBuilderSync,y as env,b as envSync};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunkCDXO2XX3_cjs=require('./chunk-CDXO2XX3.cjs'),chunkUZ7HKTYL_cjs=require('./chunk-UZ7HKTYL.cjs'),chunkO7NR4K6A_cjs=require('./chunk-O7NR4K6A.cjs'),crypto=require('crypto'),path=require('path'),fs=require('fs');function ee(r,a){let e=r.length;return e===0?"":e<=4?"****":e<=8?`${r[0]}****${r[e-1]}`:e<=16?`${r.slice(0,2)}****${r.slice(e-2)}`:`${r.slice(0,4)}\u2026${r.slice(e-4)}`}function ne(r){let a=crypto.createHash("sha256");return a.update(r),`sha256:${a.digest("hex").slice(0,8)}`}function te(r,a,e,l){if(chunkUZ7HKTYL_cjs.f(a))return true;if(e)return e(r,a);if(l){for(let s of l)if(new RegExp(s,"i").test(r))return true}return chunkUZ7HKTYL_cjs.b(r)}function P(r,a,e,l,s=false){let o=a!==void 0,c=a?.length??0,t=o&&(s||te(r,a,l.isSensitive,l.sensitiveKeys)),i=null,d=null;if(o&&a)switch(l.valueMode){case "fingerprint":d=ne(a);break;case "masked":t?i=ee(a):i=a;break;}return {key:r,resolved:o,source:l.includeSource!==false?e?.source??null:null,reference:e?.reference??null,resolvedVia:e?.resolvedVia??null,sensitive:t,length:c,fingerprint:d,preview:i}}function ue(r,a,e){let l=[];for(let s of Object.keys(r)){let o=r[s]!==void 0?String(r[s]):void 0,c=a[s];l.push(P(s,o,c,e));}return l}var de={enabled:false,valueMode:"none",includeSource:true,sensitiveKeys:[]};function fe(r,a,e,l){let s={visibility:"provenance",includeSource:true,includeConsumed:true,includeTimestamp:false,sensitiveKeys:[],...l},o={valueMode:s.visibility==="masked"?"masked":s.visibility==="fingerprint"?"fingerprint":"none",includeSource:s.includeSource,sensitiveKeys:s.sensitiveKeys,isSensitive:s.isSensitive},c=[];for(let t of Object.keys(r)){let i=r[t]!==void 0?String(r[t]):void 0,d=a[t],f=e[t]??false,v=P(t,i,d,o),w={key:v.key,resolved:v.resolved,consumed:s.includeConsumed?f:false,source:v.source,reference:v.reference,resolvedVia:v.resolvedVia,sensitive:v.sensitive,length:v.length,fingerprint:v.fingerprint,preview:v.preview};s.includeTimestamp&&d?.timestamp&&(w.timestamp=d.timestamp),c.push(w);}return c}function ve(r,a,e){let l={valueMode:"none",includeSource:true,sensitiveKeys:[],...e},s={};for(let o of Object.keys(r)){let c=r[o]!==void 0?String(r[o]):void 0,t=a[o],i=P(o,c,t,l);i.preview?s[o]=i.preview:i.fingerprint?s[o]=`[${i.fingerprint}]`:i.resolved?s[o]=i.sensitive?"[redacted]":c??"**undefined**":s[o]="**not resolved**";}return s}function Z(r,a){try{let e=path.resolve(process.cwd(),r);return {valid:!0,value:fs.readFileSync(e,"utf8").trim()}}catch(e){return {valid:false,error:`Failed to read file${""}: ${e instanceof Error?e.message:String(e)}`}}}var E=chunkO7NR4K6A_cjs.b,k=chunkO7NR4K6A_cjs.b,G=chunkO7NR4K6A_cjs.a;function Ee(r){let a={};for(let[e,l]of Object.entries(r))if(typeof l=="function"){let s=l,o=s.__isFileValidator===true;a[e]={type:o?"file":"custom",validator:l,...s.default!==void 0&&{default:s.default},...s.optional!==void 0&&{optional:s.optional},...s.secretsDir!==void 0&&{secretsDir:s.secretsDir},...chunkUZ7HKTYL_cjs.c(s)&&{sensitive:true}};}else if(typeof l=="string")a[e]={type:"string",default:l,validator:s=>{if(s===""&&!a[e].allowEmpty)throw new Error("String cannot be empty");return s}};else if(typeof l=="number")a[e]={type:"number",default:l,validator:s=>{let o=Number(s);if(isNaN(o))throw new Error("Invalid number");return o}};else if(typeof l=="boolean")a[e]={type:"boolean",default:l,validator:s=>{let o=s.toLowerCase();if(["true","1","yes","on"].includes(o))return true;if(["false","0","no","off",""].includes(o))return false;throw new Error("Invalid boolean")}};else if(Array.isArray(l)){let s=l.map(String),o=l.__optional===true;a[e]={type:"string",enum:s,optional:o,validator:(c,t)=>{if(!s.includes(c)){let i=t||e;throw new Error(`${i} must be one of: ${s.join(", ")}`)}return c}};}else a[e]=l;return a}function H(r,a){return r.replace(/\$\{([^}]+)\}/g,(e,l)=>a[l]||e)}var A=class extends Error{issues;constructor(a){super(`Environment validation failed:
|
|
2
|
+
${a.map(e=>` - ${e.key}: ${e.message}`).join(`
|
|
3
|
+
`)}`),this.name="EnvValidationError",this.issues=a;}};async function ie(r,a,e,l="last",s){let o={},c={};if(l==="last"){let t=await Promise.allSettled(r.map(async i=>({resolver:i,env:i.load?await i.load():{}})));for(let i of t){if(i.status==="rejected"){let v=i.reason;if(E({type:"resolver_error",timestamp:Date.now(),source:"unknown",error:v instanceof Error?v.message:String(v)}),e)throw new Error(`Resolver failed: ${v instanceof Error?v.message:v}`);continue}let{resolver:d,env:f}=i.value;for(let[v,w]of Object.entries(f))w!==void 0&&(o[v]=w,c[v]={source:d.name||"unknown",timestamp:Date.now(),...d.metadata?.cached!==void 0&&{cached:!!d.metadata.cached}});}}else for(let t of r)try{let i=t.load?await t.load():{};for(let[d,f]of Object.entries(i))if(f!==void 0){if(o[d]!==void 0)continue;o[d]=f,c[d]={source:t.name||"unknown",timestamp:Date.now(),...t.metadata?.cached!==void 0&&{cached:!!t.metadata.cached}};}if(s&&s.size>0&&Array.from(s).every(f=>o[f]!==void 0))break}catch(i){if(E({type:"resolver_error",timestamp:Date.now(),source:t.name,error:i instanceof Error?i.message:String(i)}),e)throw new Error(`Resolver ${t.name} failed: ${i instanceof Error?i.message:i}`,{cause:i})}if(a)for(let[t,i]of Object.entries(o))o[t]=H(i,o);return {mergedEnv:o,provenance:c}}function oe(r,a,e,l="last",s){let o={},c={};for(let t of r)try{if(!t.loadSync){if(e)throw new Error(`Resolver ${t.name} has no loadSync() method`);continue}let i=t.loadSync();for(let[d,f]of Object.entries(i))if(f!==void 0){if(l==="first"&&o[d]!==void 0)continue;o[d]=f,c[d]={source:t.name||"unknown",timestamp:Date.now(),...t.metadata?.cached!==void 0&&{cached:!!t.metadata.cached}};}if(l==="first"&&s&&s.size>0&&Array.from(s).every(f=>o[f]!==void 0))break}catch(i){if(k({type:"resolver_error",timestamp:Date.now(),source:t.name,error:i instanceof Error?i.message:String(i)}),e)throw new Error(`Resolver ${t.name} failed: ${i instanceof Error?i.message:i}`,{cause:i})}if(a)for(let[t,i]of Object.entries(o))o[t]=H(i,o);return {mergedEnv:o,provenance:c}}function J(r,a,e,l){if(!l)return null;if((process.env.NODE_ENV||"").toLowerCase()==="production"&&e&&e.source.startsWith("dotenv(")){let c=l.allowDotenvInProduction;return c===true?null:Array.isArray(c)?c.includes(r)?null:`cannot be sourced from .env files in production. Use process.env or cloud resolvers. To allow: policies.allowDotenvInProduction: ['${r}'] or set to true for all.`:"cannot be sourced from .env files in production (secure default). Production platforms (Vercel, AWS, etc.) use process.env. To allow .env in production: policies.allowDotenvInProduction: true"}let o=l.enforceAllowedSources;if(o&&o[r]&&e){let c=o[r],t=new Set,i=f=>{if(!f)return;t.add(f);let v=f.indexOf("(");v>0&&t.add(f.slice(0,v));};if(i(e.source),i(e.resolvedVia),!c.some(f=>t.has(f))){let f=e.resolvedVia?`${e.source} via ${e.resolvedVia}`:e.source;return `must be sourced from one of: ${c.join(", ")} (actual: ${f})`}}return null}function Q(r){let a=[],e=/^[A-Za-z_][A-Za-z0-9_]*$/;for(let l of Object.keys(r))e.test(l)||a.push({key:l,reason:"invalid",message:"Invalid environment variable name. Names must contain only letters, numbers, and underscores, and cannot start with a number."});return a}function X(r,a){let e={};for(let[l,s]of Object.entries(r)){if(!l.includes(a)){e[l]=s;continue}let o=l.split(a),c=e;for(let i=0;i<o.length-1;i++){let d=o[i].toLowerCase();d in c||(c[d]={}),c=c[d];}let t=o[o.length-1].toLowerCase();c[t]=s;}return e}async function De(r,a,e){let l=(process.env.NODE_ENV||"").toLowerCase()==="production",{interpolate:s=false,strict:o=true,policies:c,enableAudit:t=l,priority:i="last",secretsDir:d,debug:f,references:v}=e,w=f??{},j=w.enabled===true,R=w.onDebugEntry,D={},p;t&&(p=G(D));let V=Q(r);if(V.length>0)throw t&&E({type:"validation_failure",timestamp:Date.now(),error:`Invalid environment variable names: ${V.map(n=>n.key).join(", ")}`,sessionId:p}),new A(V);let N=new Set(Object.keys(r)),{mergedEnv:O,provenance:m}=await ie(a,s,o,i,N);try{await chunkCDXO2XX3_cjs.c(O,m,v);}catch(n){throw t&&E({type:"provider_error",timestamp:Date.now(),error:n instanceof Error?n.message:String(n),sessionId:p}),n}let y=[],I=[];for(let[n,C]of Object.entries(r)){let g=C,S=O[n];g.sensitive&&g.type!=="file"&&chunkUZ7HKTYL_cjs.e(S);let _=J(n,g,m[n],c);if(_){y.push({key:n,reason:"policy",message:_}),t&&E({type:"policy_violation",timestamp:Date.now(),key:n,source:m[n]?.source??"unknown",error:_,sessionId:p});continue}try{let u,h="invalid";if(S===void 0){let b=g.secretsDir??d;if(g.type==="file"&&b){let T=n.toLowerCase().replace(/_/g,"-"),L=path.join(b,T),$=Z(L);$.valid?(u={success:!0,value:$.value},m[n]={source:`secretsDir(${b})`,timestamp:Date.now()}):(h="missing",u={success:!1,error:$.error??"Failed to read secret"});}else g.default!==void 0?u={success:!0,value:g.default}:g.optional?u={success:!0,value:void 0}:(h="missing",u={success:!1,error:"Missing required environment variable"});}else if(g.validator)try{u={success:!0,value:g.validator(S,n)};}catch(b){u={success:!1,error:b instanceof Error?b.message:"Validation failed"};}else u={success:!0,value:S};u.success?(D[n]=u.value,g.sensitive&&chunkUZ7HKTYL_cjs.e(u.value),t&&E({type:"env_loaded",timestamp:Date.now(),key:n,source:m[n]?.source??"unknown",metadata:{cached:m[n]?.cached,reference:m[n]?.reference,resolvedVia:m[n]?.resolvedVia},sessionId:p}),j&&R&&I.push(n)):(y.push({key:n,reason:h,message:u.error}),t&&E({type:"validation_failure",timestamp:Date.now(),key:n,error:u.error,sessionId:p}));}catch(u){let h=u instanceof Error?u.message:String(u);y.push({key:n,reason:"invalid",message:h}),t&&E({type:"validation_failure",timestamp:Date.now(),key:n,error:h,sessionId:p});}}if(j&&R)for(let n of I)R(P(n,O[n],m[n],w,r[n].sensitive===true));if(y.length>0)throw t&&E({type:"validation_failure",timestamp:Date.now(),error:`${y.length} validation error(s)`,metadata:{errorCount:y.length},sessionId:p}),new A(y);return t&&E({type:"validation_success",timestamp:Date.now(),metadata:{variableCount:Object.keys(r).length},sessionId:p}),e.nestedDelimiter?X(D,e.nestedDelimiter):D}function Se(r,a,e){let l=(process.env.NODE_ENV||"").toLowerCase()==="production",{interpolate:s=false,strict:o=true,policies:c,enableAudit:t=l,priority:i="last",secretsDir:d,debug:f,references:v}=e,w=f??{},j=w.enabled===true,R=w.onDebugEntry,D={},p;t&&(p=G(D));let V=Q(r);if(V.length>0)throw t&&k({type:"validation_failure",timestamp:Date.now(),error:`Invalid environment variable names: ${V.map(n=>n.key).join(", ")}`,sessionId:p}),new A(V);let N=new Set(Object.keys(r)),{mergedEnv:O,provenance:m}=oe(a,s,o,i,N);try{chunkCDXO2XX3_cjs.b(O,m,v);}catch(n){throw t&&k({type:"provider_error",timestamp:Date.now(),error:n instanceof Error?n.message:String(n),sessionId:p}),n}let y=[],I=[];for(let[n,C]of Object.entries(r)){let g=C,S=O[n];g.sensitive&&g.type!=="file"&&chunkUZ7HKTYL_cjs.e(S);let _=J(n,g,m[n],c);if(_){y.push({key:n,reason:"policy",message:_}),t&&k({type:"policy_violation",timestamp:Date.now(),key:n,source:m[n]?.source??"unknown",error:_,sessionId:p});continue}try{let u,h="invalid";if(S===void 0){let b=g.secretsDir??d;if(g.type==="file"&&b){let T=n.toLowerCase().replace(/_/g,"-"),L=path.join(b,T),$=Z(L);$.valid?(u={success:!0,value:$.value},m[n]={source:`secretsDir(${b})`,timestamp:Date.now()}):(h="missing",u={success:!1,error:$.error??"Failed to read secret"});}else g.default!==void 0?u={success:!0,value:g.default}:g.optional?u={success:!0,value:void 0}:(h="missing",u={success:!1,error:"Missing required environment variable"});}else if(g.validator)try{u={success:!0,value:g.validator(S,n)};}catch(b){u={success:!1,error:b instanceof Error?b.message:"Validation failed"};}else u={success:!0,value:S};u.success?(D[n]=u.value,g.sensitive&&chunkUZ7HKTYL_cjs.e(u.value),t&&k({type:"env_loaded",timestamp:Date.now(),key:n,source:m[n]?.source??"unknown",metadata:{cached:m[n]?.cached,reference:m[n]?.reference,resolvedVia:m[n]?.resolvedVia},sessionId:p}),j&&R&&I.push(n)):(y.push({key:n,reason:h,message:u.error}),t&&k({type:"validation_failure",timestamp:Date.now(),key:n,error:u.error,sessionId:p}));}catch(u){let h=u instanceof Error?u.message:String(u);y.push({key:n,reason:"invalid",message:h}),t&&k({type:"validation_failure",timestamp:Date.now(),key:n,error:h,sessionId:p});}}if(j&&R)for(let n of I)R(P(n,O[n],m[n],w,r[n].sensitive===true));if(y.length>0)throw t&&k({type:"validation_failure",timestamp:Date.now(),error:`${y.length} validation error(s)`,metadata:{errorCount:y.length},sessionId:p}),new A(y);return t&&k({type:"validation_success",timestamp:Date.now(),metadata:{variableCount:Object.keys(r).length},sessionId:p}),e.nestedDelimiter?X(D,e.nestedDelimiter):D}exports.a=ue;exports.b=de;exports.c=fe;exports.d=ve;exports.e=Ee;exports.f=A;exports.g=De;exports.h=Se;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function s(o,t="object"){let e=()=>{let n={};for(let[c,r]of Object.entries(o))r!==void 0&&(n[c]=r);return n};return {name:t,load:async()=>e(),loadSync:e}}function i(){return s(process.env,"process.env")}export{s as a,i as b};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';var chunk3TXO5AOZ_cjs=require('./chunk-3TXO5AOZ.cjs'),chunkUZ7HKTYL_cjs=require('./chunk-UZ7HKTYL.cjs');var S=/^([a-z][a-z0-9-]+):\/\//,D=["aws-sm","aws-ssm","op","bws","doppler","infisical","vault"],_={string:"example",number:"1",boolean:"false",port:"3000",url:"https://example.com",http:"https://example.com",https:"https://example.com",email:"dev@example.com",json:"{}",postgres:"postgres://user:password@localhost:5432/app",mysql:"mysql://user:password@localhost:3306/app",mongodb:"mongodb://user:password@localhost:27017/app",redis:"redis://localhost:6379",stringArray:"a,b",numberArray:"1,2",urlArray:"https://example.com",duration:"30s",date:"2026-01-01",timestamp:"1700000000",file:"/run/secrets/example"};function g(n){return n.validator??{}}function b(n){if(n.type==="file")return "file";let e=g(n).__type;return typeof e=="string"?e:n.enum?"enum":n.type??"custom"}function w(n){let e=n.enum??g(n).__enum;return Array.isArray(e)?e.map(String):void 0}function y(n,e){let t=g(e),c=chunkUZ7HKTYL_cjs.c(e)||chunkUZ7HKTYL_cjs.c(t),r=t.__sensitive!==false&&chunkUZ7HKTYL_cjs.b(n),o=c?"explicit":r?"name":false,a=b(e),s=w(e),l=e.default!==void 0,i;return typeof t.__example=="string"?i=t.__example:s?.length?i=s[0]:l&&!o?i=String(e.default):o&&(a==="secret"||a==="string"||a==="custom")?i=`fake-${n.toLowerCase().replace(/_/g,"-")}`:i=_[a]??"example",{key:n,type:a,required:!e.optional&&!l,sensitive:o,...typeof t.__description=="string"&&{description:t.__description},...s&&{enum:s},...l&&!o&&{default:String(e.default)},example:i}}function x(n){let e=chunk3TXO5AOZ_cjs.e(n);return Object.entries(e).map(([t,c])=>y(t,c))}function j(n){let e=chunk3TXO5AOZ_cjs.e(n),t=[],c={};for(let r of x(n)){let o=e[r.key];try{o.validator?.(r.example,r.key),c[r.key]=r.example;}catch{t.push(r.key);}}if(t.length>0)throw new Error(`fakeEnv: no generated example passes validation for ${t.join(", ")}.
|
|
2
|
+
Provide a safe one: withMeta(validator, { example: '...' })`);return c}function $(n){return x(n).map(e=>`# ${[e.description,e.type,e.required?"required":"optional",e.sensitive&&"sensitive",e.enum&&`one of: ${e.enum.join(", ")}`].filter(Boolean).join(" | ")}
|
|
3
|
+
${e.key}=${e.example}`).join(`
|
|
4
|
+
|
|
5
|
+
`).concat(`
|
|
6
|
+
`)}function q(n,e,t={}){let c=t.referenceSchemes??D,r=chunk3TXO5AOZ_cjs.e(n),o=[],a=[];for(let[s,l]of Object.entries(r)){let i=l,p=y(s,i),h=p.sensitive!==false,u=e[s];if(u===void 0){i.type==="file"&&(i.secretsDir??t.secretsDir)?a.push({key:s,scheme:"secrets-dir"}):p.required&&o.push({key:s,code:"missing",message:"Missing required variable",sensitive:h});continue}let f=u.match(S)?.[1];if(f&&c.includes(f)){a.push({key:s,scheme:f});continue}if(i.validator)try{i.validator(u,s);}catch{let k=p.enum?`; expected one of: ${p.enum.join(", ")}`:"",E=`Value does not pass ${p.type} validation${k}`;o.push({key:s,code:"invalid",message:E,sensitive:h});}}return {ok:o.length===0,issues:o,deferred:a,checked:Object.keys(r).length}}exports.a=D;exports.b=x;exports.c=j;exports.d=$;exports.e=q;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {e}from'./chunk-BITH5LSH.js';import {c,b as b$1}from'./chunk-NKISCWWB.js';var S=/^([a-z][a-z0-9-]+):\/\//,D=["aws-sm","aws-ssm","op","bws","doppler","infisical","vault"],_={string:"example",number:"1",boolean:"false",port:"3000",url:"https://example.com",http:"https://example.com",https:"https://example.com",email:"dev@example.com",json:"{}",postgres:"postgres://user:password@localhost:5432/app",mysql:"mysql://user:password@localhost:3306/app",mongodb:"mongodb://user:password@localhost:27017/app",redis:"redis://localhost:6379",stringArray:"a,b",numberArray:"1,2",urlArray:"https://example.com",duration:"30s",date:"2026-01-01",timestamp:"1700000000",file:"/run/secrets/example"};function g(n){return n.validator??{}}function b(n){if(n.type==="file")return "file";let e=g(n).__type;return typeof e=="string"?e:n.enum?"enum":n.type??"custom"}function w(n){let e=n.enum??g(n).__enum;return Array.isArray(e)?e.map(String):void 0}function y(n,e){let t=g(e),c$1=c(e)||c(t),r=t.__sensitive!==false&&b$1(n),o=c$1?"explicit":r?"name":false,a=b(e),s=w(e),l=e.default!==void 0,i;return typeof t.__example=="string"?i=t.__example:s?.length?i=s[0]:l&&!o?i=String(e.default):o&&(a==="secret"||a==="string"||a==="custom")?i=`fake-${n.toLowerCase().replace(/_/g,"-")}`:i=_[a]??"example",{key:n,type:a,required:!e.optional&&!l,sensitive:o,...typeof t.__description=="string"&&{description:t.__description},...s&&{enum:s},...l&&!o&&{default:String(e.default)},example:i}}function x(n){let e$1=e(n);return Object.entries(e$1).map(([t,c])=>y(t,c))}function j(n){let e$1=e(n),t=[],c={};for(let r of x(n)){let o=e$1[r.key];try{o.validator?.(r.example,r.key),c[r.key]=r.example;}catch{t.push(r.key);}}if(t.length>0)throw new Error(`fakeEnv: no generated example passes validation for ${t.join(", ")}.
|
|
2
|
+
Provide a safe one: withMeta(validator, { example: '...' })`);return c}function $(n){return x(n).map(e=>`# ${[e.description,e.type,e.required?"required":"optional",e.sensitive&&"sensitive",e.enum&&`one of: ${e.enum.join(", ")}`].filter(Boolean).join(" | ")}
|
|
3
|
+
${e.key}=${e.example}`).join(`
|
|
4
|
+
|
|
5
|
+
`).concat(`
|
|
6
|
+
`)}function q(n,e$1,t={}){let c=t.referenceSchemes??D,r=e(n),o=[],a=[];for(let[s,l]of Object.entries(r)){let i=l,p=y(s,i),h=p.sensitive!==false,u=e$1[s];if(u===void 0){i.type==="file"&&(i.secretsDir??t.secretsDir)?a.push({key:s,scheme:"secrets-dir"}):p.required&&o.push({key:s,code:"missing",message:"Missing required variable",sensitive:h});continue}let f=u.match(S)?.[1];if(f&&c.includes(f)){a.push({key:s,scheme:f});continue}if(i.validator)try{i.validator(u,s);}catch{let k=p.enum?`; expected one of: ${p.enum.join(", ")}`:"",E=`Value does not pass ${p.type} validation${k}`;o.push({key:s,code:"invalid",message:E,sensitive:h});}}return {ok:o.length===0,issues:o,deferred:a,checked:Object.keys(r).length}}export{D as a,x as b,j as c,$ as d,q as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {c as c$1,b as b$1}from'./chunk-CTJYBBOB.js';import {c,e,f,b as b$2}from'./chunk-NKISCWWB.js';import {b,a}from'./chunk-6EWR3WHU.js';import {createHash}from'crypto';import {join,resolve}from'path';import {readFileSync}from'fs';function ee(r,a){let e=r.length;return e===0?"":e<=4?"****":e<=8?`${r[0]}****${r[e-1]}`:e<=16?`${r.slice(0,2)}****${r.slice(e-2)}`:`${r.slice(0,4)}\u2026${r.slice(e-4)}`}function ne(r){let a=createHash("sha256");return a.update(r),`sha256:${a.digest("hex").slice(0,8)}`}function te(r,a,e,l){if(f(a))return true;if(e)return e(r,a);if(l){for(let s of l)if(new RegExp(s,"i").test(r))return true}return b$2(r)}function P(r,a,e,l,s=false){let o=a!==void 0,c=a?.length??0,t=o&&(s||te(r,a,l.isSensitive,l.sensitiveKeys)),i=null,d=null;if(o&&a)switch(l.valueMode){case "fingerprint":d=ne(a);break;case "masked":t?i=ee(a):i=a;break;}return {key:r,resolved:o,source:l.includeSource!==false?e?.source??null:null,reference:e?.reference??null,resolvedVia:e?.resolvedVia??null,sensitive:t,length:c,fingerprint:d,preview:i}}function ue(r,a,e){let l=[];for(let s of Object.keys(r)){let o=r[s]!==void 0?String(r[s]):void 0,c=a[s];l.push(P(s,o,c,e));}return l}var de={enabled:false,valueMode:"none",includeSource:true,sensitiveKeys:[]};function fe(r,a,e,l){let s={visibility:"provenance",includeSource:true,includeConsumed:true,includeTimestamp:false,sensitiveKeys:[],...l},o={valueMode:s.visibility==="masked"?"masked":s.visibility==="fingerprint"?"fingerprint":"none",includeSource:s.includeSource,sensitiveKeys:s.sensitiveKeys,isSensitive:s.isSensitive},c=[];for(let t of Object.keys(r)){let i=r[t]!==void 0?String(r[t]):void 0,d=a[t],f=e[t]??false,v=P(t,i,d,o),w={key:v.key,resolved:v.resolved,consumed:s.includeConsumed?f:false,source:v.source,reference:v.reference,resolvedVia:v.resolvedVia,sensitive:v.sensitive,length:v.length,fingerprint:v.fingerprint,preview:v.preview};s.includeTimestamp&&d?.timestamp&&(w.timestamp=d.timestamp),c.push(w);}return c}function ve(r,a,e){let l={valueMode:"none",includeSource:true,sensitiveKeys:[],...e},s={};for(let o of Object.keys(r)){let c=r[o]!==void 0?String(r[o]):void 0,t=a[o],i=P(o,c,t,l);i.preview?s[o]=i.preview:i.fingerprint?s[o]=`[${i.fingerprint}]`:i.resolved?s[o]=i.sensitive?"[redacted]":c??"**undefined**":s[o]="**not resolved**";}return s}function Z(r,a){try{let e=resolve(process.cwd(),r);return {valid:!0,value:readFileSync(e,"utf8").trim()}}catch(e){return {valid:false,error:`Failed to read file${""}: ${e instanceof Error?e.message:String(e)}`}}}var E=b,k=b,G=a;function Ee(r){let a={};for(let[e,l]of Object.entries(r))if(typeof l=="function"){let s=l,o=s.__isFileValidator===true;a[e]={type:o?"file":"custom",validator:l,...s.default!==void 0&&{default:s.default},...s.optional!==void 0&&{optional:s.optional},...s.secretsDir!==void 0&&{secretsDir:s.secretsDir},...c(s)&&{sensitive:true}};}else if(typeof l=="string")a[e]={type:"string",default:l,validator:s=>{if(s===""&&!a[e].allowEmpty)throw new Error("String cannot be empty");return s}};else if(typeof l=="number")a[e]={type:"number",default:l,validator:s=>{let o=Number(s);if(isNaN(o))throw new Error("Invalid number");return o}};else if(typeof l=="boolean")a[e]={type:"boolean",default:l,validator:s=>{let o=s.toLowerCase();if(["true","1","yes","on"].includes(o))return true;if(["false","0","no","off",""].includes(o))return false;throw new Error("Invalid boolean")}};else if(Array.isArray(l)){let s=l.map(String),o=l.__optional===true;a[e]={type:"string",enum:s,optional:o,validator:(c,t)=>{if(!s.includes(c)){let i=t||e;throw new Error(`${i} must be one of: ${s.join(", ")}`)}return c}};}else a[e]=l;return a}function H(r,a){return r.replace(/\$\{([^}]+)\}/g,(e,l)=>a[l]||e)}var A=class extends Error{issues;constructor(a){super(`Environment validation failed:
|
|
2
|
+
${a.map(e=>` - ${e.key}: ${e.message}`).join(`
|
|
3
|
+
`)}`),this.name="EnvValidationError",this.issues=a;}};async function ie(r,a,e,l="last",s){let o={},c={};if(l==="last"){let t=await Promise.allSettled(r.map(async i=>({resolver:i,env:i.load?await i.load():{}})));for(let i of t){if(i.status==="rejected"){let v=i.reason;if(E({type:"resolver_error",timestamp:Date.now(),source:"unknown",error:v instanceof Error?v.message:String(v)}),e)throw new Error(`Resolver failed: ${v instanceof Error?v.message:v}`);continue}let{resolver:d,env:f}=i.value;for(let[v,w]of Object.entries(f))w!==void 0&&(o[v]=w,c[v]={source:d.name||"unknown",timestamp:Date.now(),...d.metadata?.cached!==void 0&&{cached:!!d.metadata.cached}});}}else for(let t of r)try{let i=t.load?await t.load():{};for(let[d,f]of Object.entries(i))if(f!==void 0){if(o[d]!==void 0)continue;o[d]=f,c[d]={source:t.name||"unknown",timestamp:Date.now(),...t.metadata?.cached!==void 0&&{cached:!!t.metadata.cached}};}if(s&&s.size>0&&Array.from(s).every(f=>o[f]!==void 0))break}catch(i){if(E({type:"resolver_error",timestamp:Date.now(),source:t.name,error:i instanceof Error?i.message:String(i)}),e)throw new Error(`Resolver ${t.name} failed: ${i instanceof Error?i.message:i}`,{cause:i})}if(a)for(let[t,i]of Object.entries(o))o[t]=H(i,o);return {mergedEnv:o,provenance:c}}function oe(r,a,e,l="last",s){let o={},c={};for(let t of r)try{if(!t.loadSync){if(e)throw new Error(`Resolver ${t.name} has no loadSync() method`);continue}let i=t.loadSync();for(let[d,f]of Object.entries(i))if(f!==void 0){if(l==="first"&&o[d]!==void 0)continue;o[d]=f,c[d]={source:t.name||"unknown",timestamp:Date.now(),...t.metadata?.cached!==void 0&&{cached:!!t.metadata.cached}};}if(l==="first"&&s&&s.size>0&&Array.from(s).every(f=>o[f]!==void 0))break}catch(i){if(k({type:"resolver_error",timestamp:Date.now(),source:t.name,error:i instanceof Error?i.message:String(i)}),e)throw new Error(`Resolver ${t.name} failed: ${i instanceof Error?i.message:i}`,{cause:i})}if(a)for(let[t,i]of Object.entries(o))o[t]=H(i,o);return {mergedEnv:o,provenance:c}}function J(r,a,e,l){if(!l)return null;if((process.env.NODE_ENV||"").toLowerCase()==="production"&&e&&e.source.startsWith("dotenv(")){let c=l.allowDotenvInProduction;return c===true?null:Array.isArray(c)?c.includes(r)?null:`cannot be sourced from .env files in production. Use process.env or cloud resolvers. To allow: policies.allowDotenvInProduction: ['${r}'] or set to true for all.`:"cannot be sourced from .env files in production (secure default). Production platforms (Vercel, AWS, etc.) use process.env. To allow .env in production: policies.allowDotenvInProduction: true"}let o=l.enforceAllowedSources;if(o&&o[r]&&e){let c=o[r],t=new Set,i=f=>{if(!f)return;t.add(f);let v=f.indexOf("(");v>0&&t.add(f.slice(0,v));};if(i(e.source),i(e.resolvedVia),!c.some(f=>t.has(f))){let f=e.resolvedVia?`${e.source} via ${e.resolvedVia}`:e.source;return `must be sourced from one of: ${c.join(", ")} (actual: ${f})`}}return null}function Q(r){let a=[],e=/^[A-Za-z_][A-Za-z0-9_]*$/;for(let l of Object.keys(r))e.test(l)||a.push({key:l,reason:"invalid",message:"Invalid environment variable name. Names must contain only letters, numbers, and underscores, and cannot start with a number."});return a}function X(r,a){let e={};for(let[l,s]of Object.entries(r)){if(!l.includes(a)){e[l]=s;continue}let o=l.split(a),c=e;for(let i=0;i<o.length-1;i++){let d=o[i].toLowerCase();d in c||(c[d]={}),c=c[d];}let t=o[o.length-1].toLowerCase();c[t]=s;}return e}async function De(r,a,e$1){let l=(process.env.NODE_ENV||"").toLowerCase()==="production",{interpolate:s=false,strict:o=true,policies:c,enableAudit:t=l,priority:i="last",secretsDir:d,debug:f,references:v}=e$1,w=f??{},j=w.enabled===true,R=w.onDebugEntry,D={},p;t&&(p=G(D));let V=Q(r);if(V.length>0)throw t&&E({type:"validation_failure",timestamp:Date.now(),error:`Invalid environment variable names: ${V.map(n=>n.key).join(", ")}`,sessionId:p}),new A(V);let N=new Set(Object.keys(r)),{mergedEnv:O,provenance:m}=await ie(a,s,o,i,N);try{await c$1(O,m,v);}catch(n){throw t&&E({type:"provider_error",timestamp:Date.now(),error:n instanceof Error?n.message:String(n),sessionId:p}),n}let y=[],I=[];for(let[n,C]of Object.entries(r)){let g=C,S=O[n];g.sensitive&&g.type!=="file"&&e(S);let _=J(n,g,m[n],c);if(_){y.push({key:n,reason:"policy",message:_}),t&&E({type:"policy_violation",timestamp:Date.now(),key:n,source:m[n]?.source??"unknown",error:_,sessionId:p});continue}try{let u,h="invalid";if(S===void 0){let b=g.secretsDir??d;if(g.type==="file"&&b){let T=n.toLowerCase().replace(/_/g,"-"),L=join(b,T),$=Z(L);$.valid?(u={success:!0,value:$.value},m[n]={source:`secretsDir(${b})`,timestamp:Date.now()}):(h="missing",u={success:!1,error:$.error??"Failed to read secret"});}else g.default!==void 0?u={success:!0,value:g.default}:g.optional?u={success:!0,value:void 0}:(h="missing",u={success:!1,error:"Missing required environment variable"});}else if(g.validator)try{u={success:!0,value:g.validator(S,n)};}catch(b){u={success:!1,error:b instanceof Error?b.message:"Validation failed"};}else u={success:!0,value:S};u.success?(D[n]=u.value,g.sensitive&&e(u.value),t&&E({type:"env_loaded",timestamp:Date.now(),key:n,source:m[n]?.source??"unknown",metadata:{cached:m[n]?.cached,reference:m[n]?.reference,resolvedVia:m[n]?.resolvedVia},sessionId:p}),j&&R&&I.push(n)):(y.push({key:n,reason:h,message:u.error}),t&&E({type:"validation_failure",timestamp:Date.now(),key:n,error:u.error,sessionId:p}));}catch(u){let h=u instanceof Error?u.message:String(u);y.push({key:n,reason:"invalid",message:h}),t&&E({type:"validation_failure",timestamp:Date.now(),key:n,error:h,sessionId:p});}}if(j&&R)for(let n of I)R(P(n,O[n],m[n],w,r[n].sensitive===true));if(y.length>0)throw t&&E({type:"validation_failure",timestamp:Date.now(),error:`${y.length} validation error(s)`,metadata:{errorCount:y.length},sessionId:p}),new A(y);return t&&E({type:"validation_success",timestamp:Date.now(),metadata:{variableCount:Object.keys(r).length},sessionId:p}),e$1.nestedDelimiter?X(D,e$1.nestedDelimiter):D}function Se(r,a,e$1){let l=(process.env.NODE_ENV||"").toLowerCase()==="production",{interpolate:s=false,strict:o=true,policies:c,enableAudit:t=l,priority:i="last",secretsDir:d,debug:f,references:v}=e$1,w=f??{},j=w.enabled===true,R=w.onDebugEntry,D={},p;t&&(p=G(D));let V=Q(r);if(V.length>0)throw t&&k({type:"validation_failure",timestamp:Date.now(),error:`Invalid environment variable names: ${V.map(n=>n.key).join(", ")}`,sessionId:p}),new A(V);let N=new Set(Object.keys(r)),{mergedEnv:O,provenance:m}=oe(a,s,o,i,N);try{b$1(O,m,v);}catch(n){throw t&&k({type:"provider_error",timestamp:Date.now(),error:n instanceof Error?n.message:String(n),sessionId:p}),n}let y=[],I=[];for(let[n,C]of Object.entries(r)){let g=C,S=O[n];g.sensitive&&g.type!=="file"&&e(S);let _=J(n,g,m[n],c);if(_){y.push({key:n,reason:"policy",message:_}),t&&k({type:"policy_violation",timestamp:Date.now(),key:n,source:m[n]?.source??"unknown",error:_,sessionId:p});continue}try{let u,h="invalid";if(S===void 0){let b=g.secretsDir??d;if(g.type==="file"&&b){let T=n.toLowerCase().replace(/_/g,"-"),L=join(b,T),$=Z(L);$.valid?(u={success:!0,value:$.value},m[n]={source:`secretsDir(${b})`,timestamp:Date.now()}):(h="missing",u={success:!1,error:$.error??"Failed to read secret"});}else g.default!==void 0?u={success:!0,value:g.default}:g.optional?u={success:!0,value:void 0}:(h="missing",u={success:!1,error:"Missing required environment variable"});}else if(g.validator)try{u={success:!0,value:g.validator(S,n)};}catch(b){u={success:!1,error:b instanceof Error?b.message:"Validation failed"};}else u={success:!0,value:S};u.success?(D[n]=u.value,g.sensitive&&e(u.value),t&&k({type:"env_loaded",timestamp:Date.now(),key:n,source:m[n]?.source??"unknown",metadata:{cached:m[n]?.cached,reference:m[n]?.reference,resolvedVia:m[n]?.resolvedVia},sessionId:p}),j&&R&&I.push(n)):(y.push({key:n,reason:h,message:u.error}),t&&k({type:"validation_failure",timestamp:Date.now(),key:n,error:u.error,sessionId:p}));}catch(u){let h=u instanceof Error?u.message:String(u);y.push({key:n,reason:"invalid",message:h}),t&&k({type:"validation_failure",timestamp:Date.now(),key:n,error:h,sessionId:p});}}if(j&&R)for(let n of I)R(P(n,O[n],m[n],w,r[n].sensitive===true));if(y.length>0)throw t&&k({type:"validation_failure",timestamp:Date.now(),error:`${y.length} validation error(s)`,metadata:{errorCount:y.length},sessionId:p}),new A(y);return t&&k({type:"validation_success",timestamp:Date.now(),metadata:{variableCount:Object.keys(r).length},sessionId:p}),e$1.nestedDelimiter?X(D,e$1.nestedDelimiter):D}export{ue as a,de as b,fe as c,ve as d,Ee as e,A as f,De as g,Se as h};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';var chunkD6WM53FN_cjs=require('./chunk-D6WM53FN.cjs'),fs=require('fs'),path=require('path');var h=l=>{let o={},r=l.split(`
|
|
2
2
|
`);for(let t=0;t<r.length;t++){let s=r[t]?.trim()??"";if(!s||s[0]==="#")continue;let i=s.indexOf("=");if(i<=0)continue;let a=s.slice(0,i).trim();if(!/^[A-Z_][A-Z0-9_]*$/i.test(a))continue;let e=s.slice(i+1).trim();if(e.length>=2){let n=e[0];(n==='"'||n==="'")&&e[e.length-1]===n&&(e=e.slice(1,-1),n==='"'&&(e=e.replace(/\\n/g,`
|
|
3
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\\\/g,"\\").replace(/\\"/g,'"').replace(/\\'/g,"'")));}else {let n=e.indexOf("#");n>=0&&(e=e.slice(0,n).trim());}o[a]=e;}return o};function
|
|
3
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\\\/g,"\\").replace(/\\"/g,'"').replace(/\\'/g,"'")));}else {let n=e.indexOf("#");n>=0&&(e=e.slice(0,n).trim());}o[a]=e;}return o};function S(l){let o=typeof l=="string"?{path:l,expand:false}:{path:l?.path??".env",expand:l?.expand??false},r=process.env.NODE_ENV||"development",t=o.expand?[`${o.path}.defaults`,o.path,`${o.path}.local`,`${o.path}.${r}`,`${o.path}.${r}.local`]:[o.path];return {name:o.expand?`dotenv-expand(${o.path})`:`dotenv(${o.path})`,metadata:{watchPaths:t},async load(){if(!o.expand){let e=path.resolve(process.cwd(),o.path);return fs.existsSync(e)?h(fs.readFileSync(e,"utf8")):{}}let s=o.path,i=[`${s}.defaults`,s,`${s}.local`,`${s}.${r}`,`${s}.${r}.local`],a={};for(let e of i){let n=path.resolve(process.cwd(),e);if(fs.existsSync(n))try{a={...a,...h(fs.readFileSync(n,"utf8"))};}catch{}}return a},loadSync(){if(!o.expand){let n=path.resolve(process.cwd(),o.path);return fs.existsSync(n)?h(fs.readFileSync(n,"utf8")):{}}let s=o.path,i=process.env.NODE_ENV||"development",a=[`${s}.defaults`,s,`${s}.local`,`${s}.${i}`,`${s}.${i}.local`],e={};for(let n of a){let c=path.resolve(process.cwd(),n);if(fs.existsSync(c))try{e={...e,...h(fs.readFileSync(c,"utf8"))};}catch{}}return e}}}function k(l){let o={path:l?.path??"package.json",fields:l?.fields??["version","name","config"]};return {name:"package.json",async load(){let r=path.resolve(process.cwd(),o.path);if(!fs.existsSync(r))return {};try{let t=fs.readFileSync(r,"utf8"),s=JSON.parse(t),i={};for(let a of o.fields){let e=s[a];if(e!==void 0)if(a==="config"&&typeof e=="object"){let n=(c,d)=>{if(c&&typeof c=="object"&&!Array.isArray(c))for(let[f,p]of Object.entries(c)){let m=`${d}_${f.toUpperCase()}`;p&&typeof p=="object"&&!Array.isArray(p)?n(p,m):i[m]=String(p);}};n(e,"CONFIG");}else i[a.toUpperCase()]=String(e);}return i}catch(t){throw new Error(`Failed to read package.json: ${t instanceof Error?t.message:String(t)}`,{cause:t})}},loadSync(){let r=path.resolve(process.cwd(),o.path);if(!fs.existsSync(r))return {};try{let t=fs.readFileSync(r,"utf8"),s=JSON.parse(t),i={};for(let a of o.fields){let e=s[a];if(e!==void 0)if(a==="config"&&typeof e=="object"){let n=(c,d)=>{if(c&&typeof c=="object"&&!Array.isArray(c))for(let[f,p]of Object.entries(c)){let m=`${d}_${f.toUpperCase()}`;p&&typeof p=="object"&&!Array.isArray(p)?n(p,m):i[m]=String(p);}};n(e,"CONFIG");}else i[a.toUpperCase()]=String(e);}return i}catch(t){throw new Error(`Failed to read package.json: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}}}function R(l,o){return {name:`http(${l})`,async load(){try{let r=new AbortController,t=o?.timeout??5e3,s=setTimeout(()=>r.abort(),t),i=await fetch(l,{...o,signal:r.signal});if(clearTimeout(s),!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);let a=await i.json(),e={},n=(c,d="")=>{if(c&&typeof c=="object"&&!Array.isArray(c))for(let[f,p]of Object.entries(c)){let m=d?`${d}_${f}`:f;p&&typeof p=="object"&&!Array.isArray(p)?n(p,m):e[m.toUpperCase()]=String(p);}};return n(a),e}catch(r){throw r.name==="AbortError"?new Error(`HTTP request timeout after ${o?.timeout??5e3}ms`,{cause:r}):new Error(`Failed to fetch config from ${l}: ${r instanceof Error?r.message:String(r)}`,{cause:r})}}}}function _(l="config.json"){return {name:`json(${l})`,async load(){let o=path.resolve(process.cwd(),l);if(!fs.existsSync(o))return {};try{let r=fs.readFileSync(o,"utf8"),t=JSON.parse(r),s={},i=(a,e="")=>{if(a&&typeof a=="object"&&!Array.isArray(a))for(let[n,c]of Object.entries(a)){let d=e?`${e}_${n}`:n;c&&typeof c=="object"&&!Array.isArray(c)?i(c,d):s[d.toUpperCase()]=String(c);}};return i(t),s}catch(r){throw new Error(`Failed to parse JSON file ${l}: ${r instanceof Error?r.message:String(r)}`,{cause:r})}},loadSync(){let o=path.resolve(process.cwd(),l);if(!fs.existsSync(o))return {};try{let r=fs.readFileSync(o,"utf8"),t=JSON.parse(r),s={},i=(a,e="")=>{if(a&&typeof a=="object"&&!Array.isArray(a))for(let[n,c]of Object.entries(a)){let d=e?`${e}_${n}`:n;c&&typeof c=="object"&&!Array.isArray(c)?i(c,d):s[d.toUpperCase()]=String(c);}};return i(t),s}catch(r){throw new Error(`Failed to parse JSON file ${l}: ${r instanceof Error?r.message:String(r)}`,{cause:r})}}}}function U(l="/run/secrets"){return {name:`secrets(${l})`,async load(){let{readdirSync:o,statSync:r}=await import('fs'),t=path.resolve(process.cwd(),l);if(!fs.existsSync(t))return {};try{let s=o(t),i={};for(let a of s){let e=path.join(t,a);if(!r(e).isFile())continue;let c=a.toUpperCase().replace(/[.-]/g,"_"),d=fs.readFileSync(e,"utf8").trim();i[c]=d;}return i}catch(s){throw new Error(`Failed to read secrets from ${l}: ${s instanceof Error?s.message:String(s)}`,{cause:s})}},loadSync(){let{readdirSync:o,statSync:r}=chunkD6WM53FN_cjs.a("fs"),t=path.resolve(process.cwd(),l);if(!fs.existsSync(t))return {};try{let s=o(t),i={};for(let a of s){let e=path.join(t,a);if(!r(e).isFile())continue;let c=a.toUpperCase().replace(/[.-]/g,"_"),d=fs.readFileSync(e,"utf8").trim();i[c]=d;}return i}catch(s){throw new Error(`Failed to read secrets from ${l}: ${s instanceof Error?s.message:String(s)}`,{cause:s})}}}}function C(l){let o=typeof l=="string"?{path:l}:{path:l?.path??"config.yaml"};return {name:`yaml(${o.path})`,async load(){let r=path.join(process.cwd(),o.path);if(!fs.existsSync(r))return {};try{let{load:t}=await import('js-yaml'),s=fs.readFileSync(r,"utf8"),i=t(s),a={},e=(n,c="")=>{if(n&&typeof n=="object"&&!Array.isArray(n))for(let[d,f]of Object.entries(n)){let p=c?`${c}_${d}`:d;f&&typeof f=="object"&&!Array.isArray(f)?e(f,p):a[p.toUpperCase()]=String(f);}};return e(i),a}catch(t){throw t.code==="MODULE_NOT_FOUND"||t.message?.includes("Cannot find package")?new Error(`YAML resolver requires 'js-yaml' package. Install it with:
|
|
4
4
|
npm install js-yaml
|
|
5
5
|
# or
|
|
6
6
|
pnpm add js-yaml`,{cause:t}):new Error(`Failed to parse YAML file ${o.path}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}},loadSync(){let r=path.join(process.cwd(),o.path);if(!fs.existsSync(r))return {};try{let{load:t}=chunkD6WM53FN_cjs.a("js-yaml"),s=fs.readFileSync(r,"utf8"),i=t(s),a={},e=(n,c="")=>{if(n&&typeof n=="object"&&!Array.isArray(n))for(let[d,f]of Object.entries(n)){let p=c?`${c}_${d}`:d;f&&typeof f=="object"&&!Array.isArray(f)?e(f,p):a[p.toUpperCase()]=String(f);}};return e(i),a}catch(t){throw t.code==="MODULE_NOT_FOUND"||t.message?.includes("Cannot find package")?new Error(`YAML resolver requires 'js-yaml' package. Install it with:
|
|
7
7
|
npm install js-yaml
|
|
8
8
|
# or
|
|
9
|
-
pnpm add js-yaml`,{cause:t}):new Error(`Failed to parse YAML file ${o.path}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}}}function
|
|
9
|
+
pnpm add js-yaml`,{cause:t}):new Error(`Failed to parse YAML file ${o.path}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}}}function F(l){let o=typeof l=="string"?{path:l}:{path:l?.path??"config.toml"};return {name:`toml(${o.path})`,async load(){let r=path.resolve(process.cwd(),o.path);if(!fs.existsSync(r))return {};try{let{parse:t}=await import('smol-toml'),s=fs.readFileSync(r,"utf8"),i=t(s),a={},e=(n,c="")=>{if(n&&typeof n=="object"&&!Array.isArray(n))for(let[d,f]of Object.entries(n)){let p=c?`${c}_${d}`:d;f&&typeof f=="object"&&!Array.isArray(f)?e(f,p):a[p.toUpperCase()]=String(f);}};return e(i),a}catch(t){throw t.code==="MODULE_NOT_FOUND"||t.message?.includes("Cannot find package")?new Error(`TOML resolver requires 'smol-toml' package. Install it with:
|
|
10
10
|
npm install smol-toml
|
|
11
11
|
# or
|
|
12
12
|
pnpm add smol-toml`,{cause:t}):new Error(`Failed to parse TOML file ${o.path}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}},loadSync(){let r=path.resolve(process.cwd(),o.path);if(!fs.existsSync(r))return {};try{let{parse:t}=chunkD6WM53FN_cjs.a("smol-toml"),s=fs.readFileSync(r,"utf8"),i=t(s),a={},e=(n,c="")=>{if(n&&typeof n=="object"&&!Array.isArray(n))for(let[d,f]of Object.entries(n)){let p=c?`${c}_${d}`:d;f&&typeof f=="object"&&!Array.isArray(f)?e(f,p):a[p.toUpperCase()]=String(f);}};return e(i),a}catch(t){throw t.code==="MODULE_NOT_FOUND"||t.message?.includes("Cannot find package")?new Error(`TOML resolver requires 'smol-toml' package. Install it with:
|
|
13
13
|
npm install smol-toml
|
|
14
14
|
# or
|
|
15
|
-
pnpm add smol-toml`,{cause:t}):new Error(`Failed to parse TOML file ${o.path}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}}}exports.a=
|
|
15
|
+
pnpm add smol-toml`,{cause:t}):new Error(`Failed to parse TOML file ${o.path}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}}}exports.a=S;exports.b=k;exports.c=R;exports.d=_;exports.e=U;exports.f=C;exports.g=F;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function s(o,t="object"){let e=()=>{let n={};for(let[c,r]of Object.entries(o))r!==void 0&&(n[c]=r);return n};return {name:t,load:async()=>e(),loadSync:e}}function i(){return s(process.env,"process.env")}exports.a=s;exports.b=i;
|