node-env-resolver 6.7.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -81
- package/dist/audit.js +1 -1
- package/dist/builder.d.ts +1 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +1 -1
- package/dist/chunk-DZBTXH7S.js +15 -0
- package/dist/{chunk-6NSX37SO.js → chunk-LUGOGCDY.js} +1 -1
- package/dist/cli/bin.js +20 -18
- package/dist/cli/scan.d.ts.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/inspect.d.ts +1 -1
- package/dist/inspect.d.ts.map +1 -1
- package/dist/process-env.d.ts +1 -1
- package/dist/process-env.d.ts.map +1 -1
- package/dist/provider-kit.js +1 -1
- package/dist/providers.d.ts +1 -1
- package/dist/providers.d.ts.map +1 -1
- package/dist/resolver.d.ts +1 -1
- package/dist/resolver.d.ts.map +1 -1
- package/dist/resolver.js +1 -1
- package/dist/resolvers.d.ts +2 -2
- package/dist/resolvers.d.ts.map +1 -1
- package/dist/resolvers.js +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/types.js +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/valibot.d.ts +2 -2
- package/dist/valibot.d.ts.map +1 -1
- package/dist/valibot.js +1 -1
- package/dist/validators.d.ts +1 -1
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +2 -2
- package/dist/web.d.ts +1 -1
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +1 -1
- package/dist/zod.d.ts +2 -2
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +1 -1
- package/package.json +2 -56
- package/dist/audit.cjs +0 -1
- package/dist/builder.cjs +0 -1
- package/dist/chunk-3TXO5AOZ.cjs +0 -3
- package/dist/chunk-4DUWYBNJ.cjs +0 -6
- package/dist/chunk-BFLXBLZ3.cjs +0 -1
- package/dist/chunk-CDXO2XX3.cjs +0 -2
- package/dist/chunk-D6WM53FN.cjs +0 -1
- package/dist/chunk-G5HNCCR6.cjs +0 -15
- package/dist/chunk-I7AUKTXE.js +0 -1
- package/dist/chunk-IP6POQCY.cjs +0 -1
- package/dist/chunk-JVRRDD3Y.js +0 -15
- package/dist/chunk-NHXSZY2U.cjs +0 -9
- package/dist/chunk-O7NR4K6A.cjs +0 -1
- package/dist/chunk-UZ7HKTYL.cjs +0 -1
- package/dist/cli/bin.cjs +0 -114
- package/dist/cli.cjs +0 -1
- package/dist/index.cjs +0 -1
- package/dist/provider-kit.cjs +0 -2
- package/dist/resolver.cjs +0 -1
- package/dist/resolvers.cjs +0 -1
- package/dist/runtime/index.cjs +0 -1
- package/dist/types.cjs +0 -1
- package/dist/utils.cjs +0 -1
- package/dist/valibot.cjs +0 -1
- package/dist/validation-types.cjs +0 -1
- package/dist/validators.cjs +0 -2
- package/dist/web.cjs +0 -6
- package/dist/zod.cjs +0 -1
package/README.md
CHANGED
|
@@ -14,39 +14,18 @@ npm install node-env-resolver
|
|
|
14
14
|
|
|
15
15
|
### TypeScript Configuration
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
**What to change:**
|
|
20
|
-
|
|
21
|
-
If your `tsconfig.json` has:
|
|
17
|
+
The package ships ES modules for Node.js 24 and later, with subpath `exports` such as `node-env-resolver/resolvers`. Set `moduleResolution` to `nodenext` or `bundler`:
|
|
22
18
|
|
|
23
19
|
```json
|
|
24
20
|
{
|
|
25
21
|
"compilerOptions": {
|
|
26
|
-
"module": "
|
|
27
|
-
"moduleResolution": "
|
|
22
|
+
"module": "nodenext",
|
|
23
|
+
"moduleResolution": "nodenext"
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
26
|
```
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```json
|
|
35
|
-
{
|
|
36
|
-
"compilerOptions": {
|
|
37
|
-
"module": "NodeNext", // Changed from "CommonJS"
|
|
38
|
-
"moduleResolution": "NodeNext" // Changed from "node"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
**Alternative options:**
|
|
44
|
-
|
|
45
|
-
- For bundler projects (Vite, Webpack, etc.): Use `"moduleResolution": "bundler"` (you can keep `"module": "CommonJS"` or use `"ESNext"`)
|
|
46
|
-
- For Node.js projects: Use `"moduleResolution": "node16"` with `"module": "node16"`
|
|
47
|
-
|
|
48
|
-
**Required values:** `"node16"`, `"nodenext"`, or `"bundler"`
|
|
49
|
-
**Not supported:** `"node"` (legacy resolution doesn't understand exports)
|
|
28
|
+
Bundled apps (Vite, Next.js, webpack) can use `"module": "esnext"` with `"moduleResolution": "bundler"`. CommonJS code on Node.js 24 can `require('node-env-resolver')` directly, and TypeScript accepts it under `"module": "nodenext"`.
|
|
50
29
|
|
|
51
30
|
If you see module resolution errors, see the [Troubleshooting](#troubleshooting) section below.
|
|
52
31
|
|
|
@@ -772,6 +751,8 @@ The `ner` CLI ships with the package. Install globally or run via `npx ner`.
|
|
|
772
751
|
|
|
773
752
|
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.
|
|
774
753
|
|
|
754
|
+
In JS and TS files, `ner scan` flags a `password`, `secret`, `token` or `apiKey` property when its value is a string literal. Values that are reference URIs such as `aws-sm://api/jwt-secret`, `op://vault/item/field` or `process-env://OTHER_KEY` pass, and so does the `.env.example` that `ner describe` writes. Known token formats are still checked inside `.env` comments. Add `// ner-scan-ignore` to a line to allow it.
|
|
755
|
+
|
|
775
756
|
```bash
|
|
776
757
|
# Scan a directory
|
|
777
758
|
ner scan src/
|
|
@@ -857,7 +838,7 @@ ner describe --format json > env.manifest.json
|
|
|
857
838
|
ner describe --format dotenv > .env.example
|
|
858
839
|
```
|
|
859
840
|
|
|
860
|
-
The CLI loads `env.schema.{ts,mts,js,mjs}` or `--schema <file>`, using the `schema` export or the default export.
|
|
841
|
+
The CLI loads `env.schema.{ts,mts,js,mjs}` or `--schema <file>`, using the `schema` export or the default export. Node.js 24 loads `.ts` schema files directly.
|
|
861
842
|
|
|
862
843
|
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
844
|
|
|
@@ -2233,61 +2214,7 @@ but this result could not be resolved under your current 'moduleResolution' sett
|
|
|
2233
2214
|
Consider updating to 'node16', 'nodenext', or 'bundler'.
|
|
2234
2215
|
```
|
|
2235
2216
|
|
|
2236
|
-
**Solution:**
|
|
2237
|
-
|
|
2238
|
-
**Example - if your config currently has:**
|
|
2239
|
-
|
|
2240
|
-
```json
|
|
2241
|
-
{
|
|
2242
|
-
"compilerOptions": {
|
|
2243
|
-
"module": "CommonJS",
|
|
2244
|
-
"moduleResolution": "node"
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
|
-
```
|
|
2248
|
-
|
|
2249
|
-
**Change to one of these options:**
|
|
2250
|
-
|
|
2251
|
-
1. **`moduleResolution: "NodeNext"`** (recommended for most Node.js projects):
|
|
2252
|
-
|
|
2253
|
-
```json
|
|
2254
|
-
{
|
|
2255
|
-
"compilerOptions": {
|
|
2256
|
-
"module": "NodeNext", // Changed from "CommonJS"
|
|
2257
|
-
"moduleResolution": "NodeNext" // Changed from "node"
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
```
|
|
2261
|
-
|
|
2262
|
-
2. **`moduleResolution: "bundler"`** (for bundler-based projects like Vite, Webpack, etc.):
|
|
2263
|
-
|
|
2264
|
-
```json
|
|
2265
|
-
{
|
|
2266
|
-
"compilerOptions": {
|
|
2267
|
-
"module": "CommonJS", // Can keep this or use "ESNext"
|
|
2268
|
-
"moduleResolution": "bundler" // Changed from "node"
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
```
|
|
2272
|
-
|
|
2273
|
-
3. **`moduleResolution: "node16"`** (alternative to NodeNext):
|
|
2274
|
-
|
|
2275
|
-
```json
|
|
2276
|
-
{
|
|
2277
|
-
"compilerOptions": {
|
|
2278
|
-
"module": "node16", // Changed from "CommonJS"
|
|
2279
|
-
"moduleResolution": "node16" // Changed from "node"
|
|
2280
|
-
}
|
|
2281
|
-
}
|
|
2282
|
-
```
|
|
2283
|
-
|
|
2284
|
-
**Why this is required:**
|
|
2285
|
-
|
|
2286
|
-
- The legacy `moduleResolution: "node"` strategy doesn't understand package.json `exports` field
|
|
2287
|
-
- Modern resolution strategies (`node16`, `nodenext`, `bundler`) properly support subpath exports
|
|
2288
|
-
- This is a TypeScript configuration requirement, not a runtime issue - your code will run correctly regardless
|
|
2289
|
-
|
|
2290
|
-
**Note:** The runtime will work correctly regardless of TypeScript's resolution mode. This is purely a TypeScript type-checking issue.
|
|
2217
|
+
**Solution:** set `moduleResolution` to `nodenext` or `bundler`, as shown in [TypeScript Configuration](#typescript-configuration). The legacy `node` setting ignores package.json `exports`.
|
|
2291
2218
|
|
|
2292
2219
|
## Testing
|
|
2293
2220
|
|
package/dist/audit.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as attachAuditSession,d as clearAuditLog,c as getAuditLog,b as logAuditEvent}from'./chunk-6EWR3WHU.js';
|
|
1
|
+
export{a as attachAuditSession,d as clearAuditLog,c as getAuditLog,b as logAuditEvent}from'./chunk-6EWR3WHU.js';
|
package/dist/builder.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* .resolve();
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
import type { Resolver, SimpleEnvSchema, InferSimpleSchema, ResolveOptions } from './types';
|
|
16
|
+
import type { Resolver, SimpleEnvSchema, InferSimpleSchema, ResolveOptions } from './types.js';
|
|
17
17
|
export type MergeSchemas<T, U> = Omit<T, keyof U> & U;
|
|
18
18
|
/**
|
|
19
19
|
* EnvBuilder class - accumulates resolvers and schemas, then resolves
|
package/dist/builder.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,IA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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 {e,h}from'./chunk-BITH5LSH.js';import'./chunk-CTJYBBOB.js';import'./chunk-NKISCWWB.js';import'./chunk-6EWR3WHU.js';import {a}from'./chunk-
|
|
1
|
+
import {e,h}from'./chunk-BITH5LSH.js';import'./chunk-CTJYBBOB.js';import'./chunk-NKISCWWB.js';import'./chunk-6EWR3WHU.js';import {a}from'./chunk-DZBTXH7S.js';import {b as b$1}from'./chunk-4CLWNKB5.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,15 @@
|
|
|
1
|
+
import {existsSync,readFileSync,readdirSync,statSync}from'fs';import {createRequire}from'module';import {resolve,join}from'path';var $=createRequire(import.meta.url),h=l=>{let o={},e=l.split(`
|
|
2
|
+
`);for(let t=0;t<e.length;t++){let s=e[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 r=s.slice(i+1).trim();if(r.length>=2){let n=r[0];(n==='"'||n==="'")&&r[r.length-1]===n&&(r=r.slice(1,-1),n==='"'&&(r=r.replace(/\\n/g,`
|
|
3
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\\\/g,"\\").replace(/\\"/g,'"').replace(/\\'/g,"'")));}else {let n=r.indexOf("#");n>=0&&(r=r.slice(0,n).trim());}o[a]=r;}return o};function U(l){let o=typeof l=="string"?{path:l,expand:false}:{path:l?.path??".env",expand:l?.expand??false},e=process.env.NODE_ENV||"development",t=o.expand?[`${o.path}.defaults`,o.path,`${o.path}.local`,`${o.path}.${e}`,`${o.path}.${e}.local`]:[o.path];return {name:o.expand?`dotenv-expand(${o.path})`:`dotenv(${o.path})`,metadata:{watchPaths:t},async load(){if(!o.expand){let r=resolve(process.cwd(),o.path);return existsSync(r)?h(readFileSync(r,"utf8")):{}}let s=o.path,i=[`${s}.defaults`,s,`${s}.local`,`${s}.${e}`,`${s}.${e}.local`],a={};for(let r of i){let n=resolve(process.cwd(),r);if(existsSync(n))try{a={...a,...h(readFileSync(n,"utf8"))};}catch{}}return a},loadSync(){if(!o.expand){let n=resolve(process.cwd(),o.path);return existsSync(n)?h(readFileSync(n,"utf8")):{}}let s=o.path,i=process.env.NODE_ENV||"development",a=[`${s}.defaults`,s,`${s}.local`,`${s}.${i}`,`${s}.${i}.local`],r={};for(let n of a){let c=resolve(process.cwd(),n);if(existsSync(c))try{r={...r,...h(readFileSync(c,"utf8"))};}catch{}}return r}}}function j(l){let o={path:l?.path??"package.json",fields:l?.fields??["version","name","config"]};return {name:"package.json",async load(){let e=resolve(process.cwd(),o.path);if(!existsSync(e))return {};try{let t=readFileSync(e,"utf8"),s=JSON.parse(t),i={};for(let a of o.fields){let r=s[a];if(r!==void 0)if(a==="config"&&typeof r=="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(r,"CONFIG");}else i[a.toUpperCase()]=String(r);}return i}catch(t){throw new Error(`Failed to read package.json: ${t instanceof Error?t.message:String(t)}`,{cause:t})}},loadSync(){let e=resolve(process.cwd(),o.path);if(!existsSync(e))return {};try{let t=readFileSync(e,"utf8"),s=JSON.parse(t),i={};for(let a of o.fields){let r=s[a];if(r!==void 0)if(a==="config"&&typeof r=="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(r,"CONFIG");}else i[a.toUpperCase()]=String(r);}return i}catch(t){throw new Error(`Failed to read package.json: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}}}function C(l,o){return {name:`http(${l})`,async load(){try{let e=new AbortController,t=o?.timeout??5e3,s=setTimeout(()=>e.abort(),t),i=await fetch(l,{...o,signal:e.signal});if(clearTimeout(s),!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);let a=await i.json(),r={},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):r[m.toUpperCase()]=String(p);}};return n(a),r}catch(e){throw e.name==="AbortError"?new Error(`HTTP request timeout after ${o?.timeout??5e3}ms`,{cause:e}):new Error(`Failed to fetch config from ${l}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}}}function F(l="config.json"){return {name:`json(${l})`,async load(){let o=resolve(process.cwd(),l);if(!existsSync(o))return {};try{let e=readFileSync(o,"utf8"),t=JSON.parse(e),s={},i=(a,r="")=>{if(a&&typeof a=="object"&&!Array.isArray(a))for(let[n,c]of Object.entries(a)){let d=r?`${r}_${n}`:n;c&&typeof c=="object"&&!Array.isArray(c)?i(c,d):s[d.toUpperCase()]=String(c);}};return i(t),s}catch(e){throw new Error(`Failed to parse JSON file ${l}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}},loadSync(){let o=resolve(process.cwd(),l);if(!existsSync(o))return {};try{let e=readFileSync(o,"utf8"),t=JSON.parse(e),s={},i=(a,r="")=>{if(a&&typeof a=="object"&&!Array.isArray(a))for(let[n,c]of Object.entries(a)){let d=r?`${r}_${n}`:n;c&&typeof c=="object"&&!Array.isArray(c)?i(c,d):s[d.toUpperCase()]=String(c);}};return i(t),s}catch(e){throw new Error(`Failed to parse JSON file ${l}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}}}function N(l="/run/secrets"){return {name:`secrets(${l})`,async load(){let{readdirSync:o,statSync:e}=await import('fs'),t=resolve(process.cwd(),l);if(!existsSync(t))return {};try{let s=o(t),i={};for(let a of s){let r=join(t,a);if(!e(r).isFile())continue;let c=a.toUpperCase().replace(/[.-]/g,"_"),d=readFileSync(r,"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 o=resolve(process.cwd(),l);if(!existsSync(o))return {};try{let e=readdirSync(o),t={};for(let s of e){let i=join(o,s);if(!statSync(i).isFile())continue;let r=s.toUpperCase().replace(/[.-]/g,"_"),n=readFileSync(i,"utf8").trim();t[r]=n;}return t}catch(e){throw new Error(`Failed to read secrets from ${l}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}}}function x(l){let o=typeof l=="string"?{path:l}:{path:l?.path??"config.yaml"};return {name:`yaml(${o.path})`,async load(){let e=join(process.cwd(),o.path);if(!existsSync(e))return {};try{let{load:t}=await import('js-yaml'),s=readFileSync(e,"utf8"),i=t(s),a={},r=(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)?r(f,p):a[p.toUpperCase()]=String(f);}};return r(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
|
+
npm install js-yaml
|
|
5
|
+
# or
|
|
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 e=join(process.cwd(),o.path);if(!existsSync(e))return {};try{let{load:t}=$("js-yaml"),s=readFileSync(e,"utf8"),i=t(s),a={},r=(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)?r(f,p):a[p.toUpperCase()]=String(f);}};return r(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
|
+
npm install js-yaml
|
|
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 T(l){let o=typeof l=="string"?{path:l}:{path:l?.path??"config.toml"};return {name:`toml(${o.path})`,async load(){let e=resolve(process.cwd(),o.path);if(!existsSync(e))return {};try{let{parse:t}=await import('smol-toml'),s=readFileSync(e,"utf8"),i=t(s),a={},r=(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)?r(f,p):a[p.toUpperCase()]=String(f);}};return r(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
|
+
npm install smol-toml
|
|
11
|
+
# or
|
|
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 e=resolve(process.cwd(),o.path);if(!existsSync(e))return {};try{let{parse:t}=$("smol-toml"),s=readFileSync(e,"utf8"),i=t(s),a={},r=(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)?r(f,p):a[p.toUpperCase()]=String(f);}};return r(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
|
+
npm install smol-toml
|
|
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})}}}}export{U as a,j as b,C as c,F as d,N as e,x as f,T as g};
|
|
@@ -3,4 +3,4 @@ import {e}from'./chunk-BITH5LSH.js';import {c,b as b$1}from'./chunk-NKISCWWB.js'
|
|
|
3
3
|
${e.key}=${e.example}`).join(`
|
|
4
4
|
|
|
5
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{
|
|
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{S as a,D as b,x as c,j as d,$ as e,q as f};
|
package/dist/cli/bin.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b,
|
|
3
|
-
`).forEach((
|
|
4
|
-
\x1B[90m${n.context}\x1B[0m`),s}function
|
|
5
|
-
`)){let o=t.trim();if(!o||o.startsWith("#"))continue;let r=o.indexOf("=");if(r===-1)continue;let
|
|
2
|
+
import {b,c,e,f,a}from'../chunk-LUGOGCDY.js';import'../chunk-BITH5LSH.js';import'../chunk-CTJYBBOB.js';import'../chunk-NKISCWWB.js';import'../chunk-6EWR3WHU.js';import {parseArgs}from'util';import {statSync,readFileSync,existsSync,readdirSync}from'fs';import {resolve,extname,join}from'path';import {pathToFileURL}from'url';import {spawn,execFileSync}from'child_process';var H=[{pattern:/sk_(live|test)_[a-zA-Z0-9]{24,}/g,type:"stripe-key"},{pattern:/pk_(live|test)_[a-zA-Z0-9]{24,}/g,type:"stripe-key"},{pattern:/xox[baprs]-[a-zA-Z0-9-]+/g,type:"slack-token"},{pattern:/gh[pousr]_[a-zA-Z0-9]{36}/g,type:"github-token"},{pattern:/eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/g,type:"jwt-token"},{pattern:/(postgres(ql)?|mysql|mongodb(\+srv)?|rediss?|amqps?):\/\/[^:\s/]+:[^@\s]+@/g,type:"connection-string"},{pattern:/AKIA[0-9A-Z]{16}/g,type:"aws-access-key"},{pattern:/aws_secret_access_key["']?\s*[:=]\s*["']?[A-Za-z0-9/+=]{40}/gi,type:"aws-secret-key"},{pattern:/-----BEGIN (RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----/g,type:"private-key"}],z=/(password|secret|token|api[_-]?key)["']?\s*[:=]\s*(["'`]?)([^"'`\s,}]{9,})/gi,W=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs"]),K="ner-scan-ignore",L=new Set([...b,"process-env","keychain"]),A=/\$\{|^fake-|:\/\/user:password@|AKIAIOSFODNN7EXAMPLE|wJalrXUtnFEMI\/K7MDENG\/bPxRfiCYEXAMPLEKEY/,Z=/^(undefined|[A-Za-z_$][\w$.]*\()/;function B(n){return A.test(n)||Z.test(n)||n.startsWith("process.env")||L.has(n.match(a)?.[1]??"")}var V=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".json",".yaml",".yml",".toml",".txt",".env",".md",".ini",".conf",".properties",".sh",".tf"]),q=new Set(["node_modules","dist","build",".git",".next",".turbo"]),J="[REDACTED]";function j(n,e,s){if(n.includes("\0"))return [];let t=[],o=W.has(extname(e)),r=/(^|[\\/])\.env/.test(e)||extname(e)===".env";return n.split(`
|
|
3
|
+
`).forEach((a,i)=>{if(a.includes(K))return;let c=[],f=[];for(let{pattern:m,type:p}of H)for(let l of a.matchAll(m))A.test(l[0])||(c.push([l.index,l.index+l[0].length]),f.push({column:l.index+1,type:p}));let I=r&&a.trimStart().startsWith("#")?[]:a.matchAll(z);for(let m of I){if(o&&!m[2])continue;let p=m[3];if(B(p))continue;let l=m.index+m[0].lastIndexOf(p);c.some(([v,P])=>l>=v&&l<P)||(c.push([l,l+p.length]),f.push({column:m.index+1,type:"potential-secret"}));}if(f.length===0)return;let d;if(s){d=a;for(let[m,p]of c.sort((l,v)=>v[0]-l[0]))d=d.slice(0,m)+J+d.slice(p);d=d.trim();}for(let m of f)t.push({file:e,line:i+1,...m,...d!==void 0&&{context:d}});}),t}function g(n,e){if(e.ignorePatterns.some(s=>s.test(n)))return [];try{return j(readFileSync(n,"utf-8"),n,e.showContext)}catch{return []}}function X(n){return n.startsWith(".")||V.has(extname(n))}function k(n,e){if(e.ignorePatterns.some(t=>t.test(n)))return [];let s;try{s=readdirSync(n);}catch{return []}return s.flatMap(t=>{let o=join(n,t);try{let r=statSync(o);if(r.isDirectory())return q.has(t)?[]:k(o,e);if(r.isFile()&&X(t))return g(o,e)}catch{}return []})}function $(n,e){return n.flatMap(s=>{try{return statSync(s).isDirectory()?k(s,e):g(s,e)}catch{return []}})}function _(n,e){return execFileSync("git",["diff","--cached","--name-only","--diff-filter=ACMR","-z"],{encoding:"utf-8",cwd:e}).split("\0").filter(Boolean).flatMap(t=>{if(n.ignorePatterns.some(r=>r.test(t)))return [];let o=execFileSync("git",["show",`:${t}`],{encoding:"utf-8",cwd:e,maxBuffer:64*1024*1024});return j(o,t,n.showContext)})}function N(n,e){let s=`\x1B[31m${n.file}:${n.line}:${n.column}\x1B[0m \x1B[33m[${n.type}]\x1B[0m`;return e&&n.context&&(s+=`
|
|
4
|
+
\x1B[90m${n.context}\x1B[0m`),s}function O(n=".env"){try{let e=readFileSync(n,"utf-8"),s={};for(let t of e.split(`
|
|
5
|
+
`)){let o=t.trim();if(!o||o.startsWith("#"))continue;let r=o.indexOf("=");if(r===-1)continue;let a=o.slice(0,r).trim(),i=o.slice(r+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),i=i.replace(/\$\{([^}]+)\}/g,(c,f)=>process.env[f]??s[f]??""),s[a]=i;}return s}catch{return {}}}var se=/^([a-z][a-z0-9-]+):\/\//;async function te(){let n=[];try{let s=await import('node-env-resolver-aws');s.awsSecretHandler&&n.push(s.awsSecretHandler),s.awsSsmHandler&&n.push(s.awsSsmHandler);}catch{}return n}async function F(n){let e=Object.entries(n).filter(([,r])=>b.includes(r.match(se)?.[1]??""));if(e.length===0)return n;let s=await te(),t=new Set;for(let[,r]of e){let a=r.match(/^([a-z][a-z0-9-]+):\/\//)?.[1];a&&!s.some(i=>i.name===a)&&t.add(a);}if(t.size>0){let r=[...t].join(", ");console.error(`\x1B[31mError:\x1B[0m No handler installed for scheme(s): ${r}://
|
|
6
6
|
For aws-sm:// and aws-ssm://, install: node-env-resolver-aws`),process.exit(1);}process.stderr.write(`Resolving ${e.length} reference(s)\u2026
|
|
7
|
-
`);let o={...n};for(let[r,
|
|
8
|
-
${
|
|
7
|
+
`);let o={...n};for(let[r,a]of e){let i=s.find(c=>a.startsWith(`${c.name}://`));if(i)try{let c=await i.resolve(a,{key:r,source:".env",reference:a});o[r]=c.value;}catch(c){let f=c instanceof Error?c.message:String(c);console.error(`\x1B[31mFailed to resolve ${r} (${a}):\x1B[0m
|
|
8
|
+
${f}`),process.exit(1);}}return o}async function oe(n){let{values:e,positionals:s}=parseArgs({args:n.slice(1),allowPositionals:true,options:{staged:{type:"boolean",default:false},ignore:{type:"string",multiple:true,default:["node_modules","\\.git(/|$)","dist","build","\\.map$"]},format:{type:"string",default:"text"},verbose:{type:"boolean",short:"v",default:false},context:{type:"boolean",short:"c",default:false},help:{type:"boolean",short:"h",default:false}}});e.help&&(console.log(`
|
|
9
9
|
\x1B[1mner scan\x1B[0m [options] [paths...]
|
|
10
10
|
|
|
11
11
|
Scan files (including dotfiles like .env.local) for hardcoded secrets.
|
|
@@ -26,17 +26,19 @@ Examples:
|
|
|
26
26
|
ner scan --staged
|
|
27
27
|
ner scan --format json .
|
|
28
28
|
|
|
29
|
+
Allow a line by adding the comment: // ner-scan-ignore
|
|
30
|
+
|
|
29
31
|
Pre-commit hook setup:
|
|
30
32
|
echo 'ner scan --staged' >> .git/hooks/pre-commit
|
|
31
33
|
chmod +x .git/hooks/pre-commit
|
|
32
|
-
`),process.exit(0));let t=e.format==="json",o={ignorePatterns:(e.ignore??[]).map(
|
|
34
|
+
`),process.exit(0));let t=e.format==="json",o={ignorePatterns:(e.ignore??[]).map(i=>new RegExp(i)),showContext:!!e.context},r;if(e.staged)try{r=_(o);}catch{console.error("\x1B[31mError:\x1B[0m could not read staged files. Is this a git repo?"),process.exit(2);}else s.length===0&&(console.error(`Provide at least one path to scan, or use --staged.
|
|
33
35
|
Run: ner scan --help`),process.exit(2)),t||console.log(`\x1B[1mScanning for secrets\u2026\x1B[0m
|
|
34
|
-
`),r
|
|
35
|
-
`);for(let
|
|
36
|
-
Summary:`);for(let[
|
|
36
|
+
`),r=$(s,o);t&&(console.log(JSON.stringify({count:r.length,findings:r},null,2)),process.exit(r.length===0?0:1)),r.length===0&&(console.log("\x1B[32m\u2713 No secrets found.\x1B[0m"),process.exit(0)),console.log(`\x1B[31m\u2717 Found ${r.length} potential secret(s):\x1B[0m
|
|
37
|
+
`);for(let i of r)console.log(N(i,o.showContext));let a={};for(let i of r)a[i.type]=(a[i.type]??0)+1;console.log(`
|
|
38
|
+
Summary:`);for(let[i,c]of Object.entries(a))console.log(` ${i}: ${c}`);console.log(`
|
|
37
39
|
Recommendations:`),console.log(" \u2022 Move secrets to environment variables or a secret manager"),console.log(" \u2022 Use reference handlers: DATABASE_URL=aws-sm://prod/db-url"),console.log(" \u2022 Add this check to CI: ner scan src/"),console.log(` \u2022 Pre-commit hook: echo "ner scan --staged" >> .git/hooks/pre-commit
|
|
38
|
-
`),process.exit(1);}var
|
|
39
|
-
The module must export \`schema\` (or a default export).`);let s=await import(pathToFileURL(resolve(e)).href),t=s.schema??s.default;if(!t||typeof t!="object")throw new Error(`${e} must export \`schema\` (or a default export)`);return t}async function
|
|
40
|
+
`),process.exit(1);}var C=["env.schema.ts","env.schema.mts","env.schema.js","env.schema.mjs"];async function D(n){let e=n??C.find(o=>existsSync(o));if(!e)throw new Error(`No schema file found. Pass --schema <file> or create one of: ${C.join(", ")}
|
|
41
|
+
The module must export \`schema\` (or a default export).`);let s=await import(pathToFileURL(resolve(e)).href),t=s.schema??s.default;if(!t||typeof t!="object")throw new Error(`${e} must export \`schema\` (or a default export)`);return t}async function re(n){let{values:e$1}=parseArgs({args:n.slice(1),options:{schema:{type:"string"},format:{type:"string",default:"text"},help:{type:"boolean",short:"h",default:false}}});e$1.help&&(console.log(`
|
|
40
42
|
\x1B[1mner describe\x1B[0m [options]
|
|
41
43
|
|
|
42
44
|
Describe the env schema: names, types, requirements, descriptions and safe
|
|
@@ -50,7 +52,7 @@ Options:
|
|
|
50
52
|
Examples:
|
|
51
53
|
ner describe --format json > env.manifest.json
|
|
52
54
|
ner describe --format dotenv > .env.example
|
|
53
|
-
`),process.exit(0));let s;try{s=await
|
|
55
|
+
`),process.exit(0));let s;try{s=await D(e$1.schema);}catch(t){console.error(t instanceof Error?t.message:String(t)),process.exit(2);}if(e$1.format==="json")console.log(JSON.stringify({version:1,variables:c(s)},null,2));else if(e$1.format==="dotenv")process.stdout.write(e(s));else for(let t of c(s)){let o=[t.type,t.required?"required":"optional",t.sensitive&&"sensitive"].filter(Boolean).join(", ");console.log(`${t.key} (${o})${t.description?` ${t.description}`:""}`);}process.exit(0);}async function ae(n){let{values:e}=parseArgs({args:n.slice(1),options:{schema:{type:"string"},env:{type:"string",default:".env"},resolve:{type:"boolean",default:false},agent:{type:"boolean",default:false},format:{type:"string",default:"text"},help:{type:"boolean",short:"h",default:false}}});e.help&&(console.log(`
|
|
54
56
|
\x1B[1mner check\x1B[0m [options]
|
|
55
57
|
|
|
56
58
|
Validate the environment (process env + .env file) against the schema.
|
|
@@ -68,7 +70,7 @@ Options:
|
|
|
68
70
|
--format <fmt> text (default) or json
|
|
69
71
|
|
|
70
72
|
Exit codes: 0 valid, 1 missing/invalid variables, 2 usage or schema error
|
|
71
|
-
`),process.exit(0));let s;try{s=await
|
|
73
|
+
`),process.exit(0));let s;try{s=await D(e.schema);}catch(a){console.error(a instanceof Error?a.message:String(a)),process.exit(2);}let t={...O(e.env),...process.env};if(e.resolve){let a=Object.fromEntries(Object.keys(s).flatMap(i=>t[i]===void 0?[]:[[i,t[i]]]));t={...t,...await F(a)};}let o=f(s,t);if(e.agent||e.format==="json")console.log(JSON.stringify({mode:e.resolve?"online":"offline",...o},null,2));else {for(let a of o.issues)console.log(`\x1B[31m\u2717\x1B[0m ${a.key}: ${a.message}`);for(let a of o.deferred)console.log(`\x1B[33m\u2026\x1B[0m ${a.key}: ${a.scheme}:// reference not resolved (run with --resolve where credentials are available)`);o.ok&&console.log(`\x1B[32m\u2713 ${o.checked} variable(s) valid\x1B[0m`);}process.exit(o.ok?0:1);}async function ie(n){let e=n.indexOf("--");(e===-1||e>=n.length-1)&&(console.error(`\x1B[31mError:\x1B[0m missing command after '--'
|
|
72
74
|
|
|
73
75
|
Usage: ner run [options] -- <command> [args...]
|
|
74
76
|
|
|
@@ -99,8 +101,8 @@ Examples:
|
|
|
99
101
|
Reference resolution (install node-env-resolver-aws for AWS support):
|
|
100
102
|
DATABASE_URL=aws-sm://prod/database resolved before process start
|
|
101
103
|
API_KEY=aws-ssm:///prod/api-key resolved before process start
|
|
102
|
-
`),process.exit(0));let t=s.env??".env",o=
|
|
103
|
-
`);}}s.resolve!==false&&(o=await
|
|
104
|
+
`),process.exit(0));let t=s.env??".env",o=O(t);if(s.scan){let c=g(t,{ignorePatterns:[],showContext:false});if(c.length>0){console.error(`\x1B[33m\u26A0 ${c.length} potential hardcoded secret(s) in ${t}:\x1B[0m`);for(let f of c)console.error(N(f,false));console.error(` Tip: use reference URIs instead \u2014 DATABASE_URL=aws-sm://prod/db
|
|
105
|
+
`);}}s.resolve!==false&&(o=await F(o));let[r,...a]=n.slice(e+1);r||(console.error("No command specified after --"),process.exit(1));let i=spawn(r,a,{stdio:"inherit",env:{...o,...process.env}});i.on("error",c=>{console.error(`\x1B[31mFailed to run "${r}":\x1B[0m ${c.message}`),process.exit(1);}),i.on("close",c=>{process.exit(c??0);});}async function ce(){let n=process.argv.slice(2),e=n[0];(!e||e==="--help"||e==="-h")&&(console.log(`
|
|
104
106
|
\x1B[1mner\x1B[0m \u2014 node-env-resolver CLI
|
|
105
107
|
|
|
106
108
|
Commands:
|
|
@@ -110,5 +112,5 @@ Commands:
|
|
|
110
112
|
check Validate env against the schema (no values in output)
|
|
111
113
|
|
|
112
114
|
Run \x1B[1mner <command> --help\x1B[0m for command-specific options.
|
|
113
|
-
`),process.exit(0)),e==="scan"?await
|
|
114
|
-
Run: ner --help`),process.exit(1));}
|
|
115
|
+
`),process.exit(0)),e==="scan"?await oe(n):e==="run"?await ie(n):e==="describe"?await re(n):e==="check"?await ae(n):(console.error(`\x1B[31mUnknown command:\x1B[0m ${e}
|
|
116
|
+
Run: ner --help`),process.exit(1));}ce().catch(n=>{console.error(n instanceof Error?n.message:n),process.exit(1);});
|
package/dist/cli/scan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/cli/scan.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/cli/scan.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6DH,eAAO,MAAM,QAAQ,eAAe,CAAC;AAErC,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,EAAE,CA6C1F;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,EAAE,CAO1E;AAOD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,EAAE,CAmB9E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,EAAE,CAQ1E;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CAkBxE"}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,QAAQ,CAqD9D"}
|
package/dist/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function f(g={}){let{argv:s=process.argv.slice(2),prefix:n="--",normalizeKeys:i=true}=g,l=()=>{let t={};for(let r=0;r<s.length;r++){let c=s[r];if(!c.startsWith(n))continue;let e=c.slice(n.length);if(e.includes("=")){let[p,u]=e.split("=",2);e=i?p.replace(/-/g,"_").toUpperCase():p,t[e]=u;continue}let a=i?e.replace(/-/g,"_").toUpperCase():e,o=s[r+1];!o||o.startsWith(n)?t[a]="true":(t[a]=o,r++);}return t};return {name:"cli-args",load(){return Promise.resolve(l())},loadSync(){return l()}}}export{f as cliArgs};
|
package/dist/index.d.ts
CHANGED
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
* });
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
import type { Resolver, SyncResolver, ResolveOptions, ResolveConfig, ResolveAsyncConfig, ResolveConfigWithSchema, ResolveAsyncConfigWithSchema, ReferenceOptions, SimpleEnvSchema, InferSimpleValue, InferMergedSchemaResult } from './types';
|
|
19
|
-
export type { EnvDefinition, EnvSchema, Resolver, SyncResolver, ResolveOptions, ResolveConfig, ResolveAsyncConfig, ReferenceOptions, ReferenceHandler, ReferenceContext, ReferenceResolution, Provenance, PolicyOptions, SimpleEnvValue, SimpleEnvSchema, InferType, InferSchema, InferSimpleSchema, InferResolveResult, Validator, } from './types';
|
|
20
|
-
export { processEnvReferenceHandler } from './references';
|
|
21
|
-
export { isSyncResolver, isAsyncOnlyResolver, AsyncResolver } from './types';
|
|
22
|
-
export type { ValidationIssue, SafeResolveResult as SafeResolveResultWithIssues, } from './validation-types';
|
|
23
|
-
export { getAuditLog, clearAuditLog, type AuditEvent, type AuditEventType, } from './audit';
|
|
24
|
-
export { type DebugValueMode, type DebugOptions, type DebugEntry, type VisibilityLevel, type SecuritySnapshotOptions, type SecuritySnapshotEntry, createDebugView, createSecuritySnapshot, createRedactedObject, DEFAULT_DEBUG_OPTIONS, DEFAULT_SENSITIVE_PATTERNS, } from './debug';
|
|
25
|
-
export { isSensitiveValidator, isSensitiveValue, isSensitiveKeyName, markSensitiveValue, findSensitiveKeys, } from './sensitivity';
|
|
26
|
-
import { type EnvIssue } from './resolver';
|
|
27
|
-
export { EnvValidationError, type EnvIssue } from './resolver';
|
|
28
|
-
export { strictReferencePolicies, strictReferenceResolveOptions, type StrictReferencePoliciesOptions, type StrictReferenceResolveOptions, } from './security';
|
|
18
|
+
import type { Resolver, SyncResolver, ResolveOptions, ResolveConfig, ResolveAsyncConfig, ResolveConfigWithSchema, ResolveAsyncConfigWithSchema, ReferenceOptions, SimpleEnvSchema, InferSimpleValue, InferMergedSchemaResult } from './types.js';
|
|
19
|
+
export type { EnvDefinition, EnvSchema, Resolver, SyncResolver, ResolveOptions, ResolveConfig, ResolveAsyncConfig, ReferenceOptions, ReferenceHandler, ReferenceContext, ReferenceResolution, Provenance, PolicyOptions, SimpleEnvValue, SimpleEnvSchema, InferType, InferSchema, InferSimpleSchema, InferResolveResult, Validator, } from './types.js';
|
|
20
|
+
export { processEnvReferenceHandler } from './references.js';
|
|
21
|
+
export { isSyncResolver, isAsyncOnlyResolver, AsyncResolver } from './types.js';
|
|
22
|
+
export type { ValidationIssue, SafeResolveResult as SafeResolveResultWithIssues, } from './validation-types.js';
|
|
23
|
+
export { getAuditLog, clearAuditLog, type AuditEvent, type AuditEventType, } from './audit.js';
|
|
24
|
+
export { type DebugValueMode, type DebugOptions, type DebugEntry, type VisibilityLevel, type SecuritySnapshotOptions, type SecuritySnapshotEntry, createDebugView, createSecuritySnapshot, createRedactedObject, DEFAULT_DEBUG_OPTIONS, DEFAULT_SENSITIVE_PATTERNS, } from './debug.js';
|
|
25
|
+
export { isSensitiveValidator, isSensitiveValue, isSensitiveKeyName, markSensitiveValue, findSensitiveKeys, } from './sensitivity.js';
|
|
26
|
+
import { type EnvIssue } from './resolver.js';
|
|
27
|
+
export { EnvValidationError, type EnvIssue } from './resolver.js';
|
|
28
|
+
export { strictReferencePolicies, strictReferenceResolveOptions, type StrictReferencePoliciesOptions, type StrictReferenceResolveOptions, } from './security.js';
|
|
29
29
|
export interface SafeResolveResult<T> {
|
|
30
30
|
success: true;
|
|
31
31
|
data: T;
|
|
@@ -174,5 +174,5 @@ declare function safeResolveAsync<T extends SimpleEnvSchema>(config: ResolveAsyn
|
|
|
174
174
|
[K in keyof T]: InferSimpleValue<T[K]>;
|
|
175
175
|
}>>;
|
|
176
176
|
export { safeResolveAsync, resolveAsync, resolve, safeResolve };
|
|
177
|
-
export { describeSchema, fakeEnv, toDotenvExample, checkEnv, KNOWN_REFERENCE_SCHEMES, type VarDescription, type CheckResult, type CheckIssue, type CheckDeferred, } from './inspect';
|
|
177
|
+
export { describeSchema, fakeEnv, toDotenvExample, checkEnv, KNOWN_REFERENCE_SCHEMES, type VarDescription, type CheckResult, type CheckIssue, type CheckDeferred, } from './inspect.js';
|
|
178
178
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,4BAA4B,EAC5B,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,4BAA4B,EAC5B,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,0BAA0B,EAAE,MAAM,iB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AE,gBAAgB,CAAC;CAC/B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;AAsDxC;;;;;;;GAOG;AACH,iBAAS,WAAW,CAAC,CAAC,SAAS,eAAe,EAC5C,IAAI,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,EAC1B,IAAI,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAC7B,qBAAqB,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,CAwGnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,iBAAe,gBAAgB,CAAC,CAAC,SAAS,eAAe,EACvD,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC5B,OAAO,CAAC,qBAAqB,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,CAAC,CAAC;AA4D9E,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAGhE,OAAO,EACL,cAAc,EACd,OAAO,EACP,eAAe,EACf,QAAQ,EACR,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c as resolve,d as resolveAsync,e as safeResolve,f as safeResolveAsync,a as strictReferencePolicies,b as strictReferenceResolveOptions}from'./chunk-KHEBSYFP.js';export{
|
|
1
|
+
export{c as resolve,d as resolveAsync,e as safeResolve,f as safeResolveAsync,a as strictReferencePolicies,b as strictReferenceResolveOptions}from'./chunk-KHEBSYFP.js';export{b as KNOWN_REFERENCE_SCHEMES,f as checkEnv,c as describeSchema,d as fakeEnv,e as toDotenvExample}from'./chunk-LUGOGCDY.js';export{b as DEFAULT_DEBUG_OPTIONS,f as EnvValidationError,a as createDebugView,d as createRedactedObject,c as createSecuritySnapshot}from'./chunk-BITH5LSH.js';export{a as processEnvReferenceHandler}from'./chunk-CTJYBBOB.js';export{a as DEFAULT_SENSITIVE_PATTERNS,g as findSensitiveKeys,b as isSensitiveKeyName,c as isSensitiveValidator,f as isSensitiveValue,e as markSensitiveValue}from'./chunk-NKISCWWB.js';export{d as clearAuditLog,c as getAuditLog}from'./chunk-6EWR3WHU.js';import'./chunk-4CLWNKB5.js';export{b as isAsyncOnlyResolver,a as isSyncResolver}from'./chunk-ZMRT37K3.js';
|
package/dist/inspect.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Nothing here calls providers or resolves reference URIs.
|
|
9
9
|
*/
|
|
10
|
-
import type { SimpleEnvSchema } from './types';
|
|
10
|
+
import type { SimpleEnvSchema } from './types.js';
|
|
11
11
|
export declare const REFERENCE_URI: RegExp;
|
|
12
12
|
/** Schemes handled by the official reference handler packages. */
|
|
13
13
|
export declare const KNOWN_REFERENCE_SCHEMES: readonly string[];
|
package/dist/inspect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAiB,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAiB,eAAe,EAAE,MAAM,YAAY,CAAC;AAEjE,eAAO,MAAM,aAAa,QAA4B,CAAC;AAEvD,kEAAkE;AAClE,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAQpD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CA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AU,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1E,WAAW,CAwCb"}
|
package/dist/process-env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-env.d.ts","sourceRoot":"","sources":["../src/process-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"process-env.d.ts","sourceRoot":"","sources":["../src/process-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,IAAI,SAAW,GACd,YAAY,CAWd;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,IAAI,YAAY,CAEzC"}
|
package/dist/provider-kit.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function u(t,r){if(typeof t=="function"||typeof t=="string"&&t.trim()!=="")return t;throw new Error(`${r} is required`)}async function a(t,r){let n=typeof t=="function"?await t():t;if(typeof n!="string"||n.trim()==="")throw new Error(`${r} is required`);return n}async function c(t,r){return t===void 0?void 0:a(t,r)}function l(t,r,n=false){let e;try{e=new URL(t);}catch{throw new Error(`${r} is not a valid URL: ${JSON.stringify(t)}`)}if(e.protocol==="https:")return;let o=e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]"||e.hostname==="::1";if(!(e.protocol==="http:"&&(n||o)))throw new Error(`${r} must use https:// \u2014 got "${e.protocol}//". Credentials sent over http can be intercepted on the network. Set allowInsecureHttp: true to override for a trusted endpoint.`)}async function f(t,r,n,e=3e4){let o=new AbortController,s=setTimeout(()=>o.abort(),e);try{return await fetch(t,{...r,signal:o.signal})}catch(i){throw i instanceof Error&&i.name==="AbortError"?new Error(`Request to ${n} timed out after ${e}ms`,{cause:i}):i}finally{clearTimeout(s);}}
|
|
2
2
|
export{l as assertSecureUrl,f as fetchWithTimeout,u as requireCredential,a as resolveCredential,c as resolveOptionalCredential};
|
package/dist/providers.d.ts
CHANGED
package/dist/providers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AA0DD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,QAAQ,CAqEjE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,IAAI,QAAQ,CAUrC"}
|
package/dist/resolver.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal resolver functions - extracted for use by both old and new APIs
|
|
3
3
|
*/
|
|
4
|
-
import type { Resolver, EnvSchema, SimpleEnvSchema, ResolveOptions } from './types';
|
|
4
|
+
import type { Resolver, EnvSchema, SimpleEnvSchema, ResolveOptions } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Convert simplified schema to standard EnvSchema
|
|
7
7
|
*/
|
package/dist/resolver.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EAET,eAAe,EACf,cAAc,EAGf,MAAM,
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EAET,eAAe,EACf,cAAc,EAGf,MAAM,YAAY,CAAC;AAuCpB;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CA2FlE;AAcD,mDAAmD;AACnD,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,yEAAyE;AACzE,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;IAE5B,YAAY,MAAM,EAAE,QAAQ,EAAE,EAM7B;CACF;AA0VD;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,SAAS,SAAS,EAC1D,MAAM,EAAE,CAAC,EACT,SAAS,EAAE,QAAQ,EAAE,EACrB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA+PlC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,SAAS,EACxD,MAAM,EAAE,CAAC,EACT,SAAS,EAAE,QAAQ,EAAE,EACrB,OAAO,EAAE,cAAc,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA8PzB"}
|
package/dist/resolver.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{f as EnvValidationError,e as normalizeSchema,g as resolveEnvInternal,h as resolveEnvInternalSync}from'./chunk-BITH5LSH.js';import'./chunk-CTJYBBOB.js';import'./chunk-NKISCWWB.js';import'./chunk-6EWR3WHU.js';
|
|
1
|
+
export{f as EnvValidationError,e as normalizeSchema,g as resolveEnvInternal,h as resolveEnvInternalSync}from'./chunk-BITH5LSH.js';import'./chunk-CTJYBBOB.js';import'./chunk-NKISCWWB.js';import'./chunk-6EWR3WHU.js';
|
package/dist/resolvers.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Built-in resolvers for environment variable resolution
|
|
3
3
|
*/
|
|
4
|
-
import type { Resolver, SyncResolver } from './types';
|
|
5
|
-
export { processEnv, fromObject } from './process-env';
|
|
4
|
+
import type { Resolver, SyncResolver } from './types.js';
|
|
5
|
+
export { processEnv, fromObject } from './process-env.js';
|
|
6
6
|
/**
|
|
7
7
|
* Options for the dotenv resolver
|
|
8
8
|
*/
|
package/dist/resolvers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../src/resolvers.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../src/resolvers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAKzD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AA0DD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,YAAY,CAiFrE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,GAAG,QAAQ,CA4FX;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAClB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,WAAW,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,QAAQ,CAqDV;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,MAAsB,GAAG,QAAQ,CAoE3D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,IAAI,GAAE,MAAuB,GAAG,QAAQ,CAmE/D;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAqG7D;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAqG7D"}
|
package/dist/resolvers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as dotenv,c as http,d as json,b as packageJson,e as secrets,g as toml,f as yaml}from'./chunk-
|
|
1
|
+
export{a as dotenv,c as http,d as json,b as packageJson,e as secrets,g as toml,f as yaml}from'./chunk-DZBTXH7S.js';export{a as fromObject,b as processEnv}from'./chunk-4CLWNKB5.js';
|
package/dist/runtime/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a,f,d}from'../chunk-NKISCWWB.js';
|
|
1
|
+
import {a,f,d}from'../chunk-NKISCWWB.js';var v=a,_=[/sk_live_[a-zA-Z0-9]{24,}/g,/sk_test_[a-zA-Z0-9]{24,}/g,/pk_live_[a-zA-Z0-9]{24,}/g,/pk_test_[a-zA-Z0-9]{24,}/g,/xox[baprs]-[a-zA-Z0-9-]+/g,/ghp_[a-zA-Z0-9]{36}/g,/gho_[a-zA-Z0-9]{36}/g,/ghu_[a-zA-Z0-9]{36}/g,/ghs_[a-zA-Z0-9]{36}/g,/ghr_[a-zA-Z0-9]{36}/g,/eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/g,/postgres:\/\/[^@]+:[^@]+@/g,/mysql:\/\/[^@]+:[^@]+@/g,/mongodb(\+srv)?:\/\/[^@]+:[^@]+@/g,/redis:\/\/[^:]+:[^@]+@/g,/rediss:\/\/[^:]+:[^@]+@/g];function A(t){let r=t.length;return r<=4?"****":r<=8?`${t[0]}****${t[r-1]}`:r<=16?`${t.slice(0,2)}****${t.slice(-2)}`:`${t.slice(0,4)}...${t.slice(-4)}`}function h(t,r={}){let{sensitivePatterns:a=v,customPatterns:u=[],fallbackValue:i="[REDACTED]"}=r,c=[..._,...u],l=new Set(t.values());function p(e){return a.some(n=>n.test(e))}function w(e){let n=e;for(let[,o]of t)if(typeof o=="string"&&o.length>0){let d=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=n.replace(new RegExp(d,"g"),i);}for(let o of c)n=n.replace(o,i);return n}function g(e,n=0,o=new WeakSet){if(n>10||e==null)return e;if(typeof e=="string")return w(e);if(typeof e=="number"||typeof e=="bigint")return l.has(String(e))?i:e;if(typeof e!="object")return e;if(o.has(e))return "[Circular]";if(o.add(e),Array.isArray(e))return e.map(s=>g(s,n+1,o));if(e instanceof Error){let s=new Error(w(e.message));return s.name=e.name,s.stack=e.stack?w(e.stack):void 0,s}if(e instanceof Date||e instanceof RegExp)return e;if(e instanceof Map)return new Map(Array.from(e.entries()).map(([s,f])=>[g(s,n+1,o),g(f,n+1,o)]));if(e instanceof Set)return new Set(Array.from(e.values()).map(s=>g(s,n+1,o)));let d={};for(let[s,f]of Object.entries(e))p(s)?d[s]=typeof f=="string"?i:"[REDACTED]":typeof f=="string"?d[s]=w(f):d[s]=g(f,n+1,o);return d}return {redactString:w,redactObject:g,maskValue:A,createFingerprint:e=>{let n=0;for(let o=0;o<e.length;o++){let d=e.charCodeAt(o);n=(n<<5)-n+d,n=n&n;}return `sha256:${Math.abs(n).toString(16).slice(0,8)}`},shouldRedactKey:p}}function y(t,r={}){let a=new Map,u=r.sensitiveKeys?.map(i=>new RegExp(i,"i"))??v;for(let[i,c]of Object.entries(t))f(c)?d(c).forEach((l,p)=>{a.set(p===0?i:`${i}#${p}`,l);}):typeof c=="string"&&u.some(l=>l.test(i))&&a.set(i,c);return a}var R="__nodeEnvResolverPatched";function S(t,r={}){let{enabled:a=true,methods:u=["log","debug","info","warn","error","trace"],redactStrings:i=true,redactObjects:c=true,...l}=r;if(!a)return ()=>{};let p=console;if(p[R])return ()=>{};let w=y(t),g=h(w,l),e={};for(let n of u)if(typeof console[n]=="function"){e[n]=console[n].bind(console);let o=e[n];console[n]=(...d)=>{let s=d.map(f=>typeof f=="string"&&i?g.redactString(f):(typeof f=="number"||typeof f=="bigint")&&i||typeof f=="object"&&c&&f!==null?g.redactObject(f):f);o(...s);};}return Object.defineProperty(p,R,{value:true,writable:true,enumerable:false,configurable:true}),()=>{for(let n of u)if(e[n]){let d=e[n].bind(console);console[n]=d;}try{delete p[R];}catch{}p[R]=false;}}function C(t,r={}){let a=y(t),u=h(a,r);return {redact:(...i)=>i.map(c=>typeof c=="string"?u.redactString(c):typeof c=="object"&&c!==null?u.redactObject(c):c),...u}}var x=["image/","video/","audio/","application/octet-stream","application/pdf"];function T(t,r){let a=t.toLowerCase();return !r.some(u=>a.includes(u.toLowerCase()))}function b(t,r,a){if(r===t)return t;if(a==="throw")throw new Error('Secret leak detected in HTTP response body. A sensitive value was found before it could be sent. Use mode: "redact" to automatically scrub, or mode: "warn" to log and continue.');return a==="warn"?(console.warn('[node-env-resolver] Potential secret leak detected in HTTP response. Set mode: "redact" to scrub automatically.'),t):r}function z(t,r={}){let{mode:a=process.env.NODE_ENV==="production"?"warn":"throw",ignoreContentTypes:u=x,maxBodySize:i=1024*1024,...c}=r,l=y(t),p=h(l,c);return function(g,e,n){let o=e.end.bind(e);e.end=function(...d){let s=d[0];if(s!=null&&(typeof s=="string"||Buffer.isBuffer(s))){let f=String(e.getHeader?.("content-type")??"");if(T(f,u)){let k=typeof s=="string"?s:s.toString("utf8");if(Buffer.byteLength(k)<=i)try{let m=p.redactString(k);d[0]=b(k,m,a);}catch(m){if(a==="throw")throw m;console.error("[node-env-resolver] Response scan error:",m);}}}return o(...d)},n();}}async function V(t,r,a={}){let{mode:u="warn",ignoreContentTypes:i=x,maxBodySize:c=1024*1024,...l}=a,p=t.headers.get("content-type")??"";if(!T(p,i))return t;let g=await t.clone().arrayBuffer();if(g.byteLength>c)return t;let e=new TextDecoder().decode(g),n=y(r),d=h(n,l).redactString(e);if(d===e)return t;if(u==="throw")throw new Error('Secret leak detected in HTTP response. Use mode: "redact" to scrub automatically.');return u==="warn"?(console.warn("[node-env-resolver] Potential secret leak detected in HTTP response."),t):new Response(d,{status:t.status,statusText:t.statusText,headers:t.headers})}function F(t,r,a={}){if(typeof t!="string"&&!Buffer.isBuffer(t))return {safe:true};let u=y(r),i=h(u,a),c=typeof t=="string"?t:t.toString("utf8"),l=i.redactString(c);return l!==c?{safe:false,redacted:l}:{safe:true}}function H(t,r={}){return r.console===false?()=>{}:S(t,r.console)}export{C as createConsoleRedactor,h as createRedactor,z as createResponseMiddleware,y as extractSensitiveValues,S as patchGlobalConsole,H as protect,F as scanBodyForSecrets,V as wrapFetchResponse};
|