node-env-resolver 6.5.2 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder.cjs +1 -1
- package/dist/builder.js +1 -1
- package/dist/cli/bin.cjs +0 -0
- package/dist/provider-kit.cjs +2 -0
- package/dist/provider-kit.d.cts +50 -0
- package/dist/provider-kit.d.ts +50 -0
- package/dist/provider-kit.js +2 -0
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.js +1 -1
- package/dist/web.cjs +1 -1
- package/dist/web.js +1 -1
- package/dist/zod.cjs +1 -1
- package/dist/zod.js +1 -1
- package/package.json +25 -18
package/dist/builder.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkWVMDTD6J_cjs=require('./chunk-WVMDTD6J.cjs');require('./chunk-CDXO2XX3.cjs'),require('./chunk-O7NR4K6A.cjs');var chunkDIJNUFGZ_cjs=require('./chunk-DIJNUFGZ.cjs'),chunk4QOKRJ3F_cjs=require('./chunk-4QOKRJ3F.cjs');require('./chunk-D6WM53FN.cjs');var i=class{constructor(e,s={}){this.localSchema=e;this.options=s;}layers=[];from(e,s){return this.layers.push({resolver:e,schema:s}),this}resolve(){let e=chunkWVMDTD6J_cjs.f(this.localSchema);for(let l of this.layers){let m=chunkWVMDTD6J_cjs.f(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 chunkWVMDTD6J_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(chunkDIJNUFGZ_cjs.a({expand:true})),s.push(chunk4QOKRJ3F_cjs.a()),s}},n=class{constructor(e,s={}){this.localSchema=e;this.options=s;}layers=[];from(e,s){return this.layers.push({resolver:e,schema:s}),this}resolveSync(){let e=chunkWVMDTD6J_cjs.f(this.localSchema);for(let l of this.layers){let m=chunkWVMDTD6J_cjs.f(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 chunkWVMDTD6J_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(chunkDIJNUFGZ_cjs.a({expand:true})),s.push(chunk4QOKRJ3F_cjs.a()),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.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {f,h}from'./chunk-K4NIC5T3.js';import'./chunk-CTJYBBOB.js';import'./chunk-6EWR3WHU.js';import {a}from'./chunk-ZSM2NDX5.js';import {a as a$1}from'./chunk-WKIPEKF6.js';import'./chunk-I7AUKTXE.js';var i=class{constructor(e,s={}){this.localSchema=e;this.options=s;}layers=[];from(e,s){return this.layers.push({resolver:e,schema:s}),this}resolve(){let e=f(this.localSchema);for(let l of this.layers){let m=f(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 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(a({expand:true})),s.push(a$1()),s}},n=class{constructor(e,s={}){this.localSchema=e;this.options=s;}layers=[];from(e,s){return this.layers.push({resolver:e,schema:s}),this}resolveSync(){let e=f(this.localSchema);for(let l of this.layers){let m=f(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 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(a({expand:true})),s.push(a$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};
|
package/dist/cli/bin.cjs
CHANGED
|
File without changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';require('./chunk-D6WM53FN.cjs');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
|
+
exports.assertSecureUrl=l;exports.fetchWithTimeout=f;exports.requireCredential=u;exports.resolveCredential=a;exports.resolveOptionalCredential=c;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolkit for building remote-secret resolvers (Bitwarden, Infisical, Doppler,
|
|
3
|
+
* 1Password, and any third-party vault).
|
|
4
|
+
*
|
|
5
|
+
* It centralises the cross-cutting concerns every vault provider shares so each
|
|
6
|
+
* one is written — and audited — exactly once:
|
|
7
|
+
*
|
|
8
|
+
* - **Bootstrap-credential resolution** that accepts a lazy provider instead of
|
|
9
|
+
* forcing a plaintext environment string. The function form keeps the secret
|
|
10
|
+
* out of `process.env`/dotfiles (read it from the OS keychain, an STS/OIDC
|
|
11
|
+
* exchange, `op read`, …) so an environment harvest finds nothing.
|
|
12
|
+
* - **HTTPS transport enforcement** so a bootstrap credential is never sent in
|
|
13
|
+
* cleartext to an overridable (self-hosted) endpoint.
|
|
14
|
+
* - **A fetch wrapper** with an abort-based timeout.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* A bootstrap credential — a vault access token, client secret, service token, …
|
|
18
|
+
*
|
|
19
|
+
* Either a literal string, or a function that produces one on demand. Prefer the
|
|
20
|
+
* function form in hardened setups: it lets the credential come from the OS
|
|
21
|
+
* keychain, a short-lived token exchange, or workload identity rather than living
|
|
22
|
+
* in an environment variable a supply-chain harvester can read.
|
|
23
|
+
*/
|
|
24
|
+
type CredentialInput = string | (() => string | Promise<string>);
|
|
25
|
+
/**
|
|
26
|
+
* Validate a *required* credential at construction time.
|
|
27
|
+
*
|
|
28
|
+
* A literal string is checked eagerly so the familiar synchronous
|
|
29
|
+
* `"<label> is required"` error still fires the moment the resolver is built. A
|
|
30
|
+
* function provider is accepted as-is and validated when it is later resolved
|
|
31
|
+
* (its value isn't available yet).
|
|
32
|
+
*/
|
|
33
|
+
declare function requireCredential(input: CredentialInput | undefined, label: string): CredentialInput;
|
|
34
|
+
/** Resolve a credential to its string value at use time, asserting it is non-empty. */
|
|
35
|
+
declare function resolveCredential(input: CredentialInput, label: string): Promise<string>;
|
|
36
|
+
/** Resolve an *optional* credential: `undefined` passes through, anything else is validated. */
|
|
37
|
+
declare function resolveOptionalCredential(input: CredentialInput | undefined, label: string): Promise<string | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* Reject a non-`https:` endpoint so a bootstrap credential is never transmitted
|
|
40
|
+
* in cleartext.
|
|
41
|
+
*
|
|
42
|
+
* Loopback hosts (`localhost`, `127.0.0.1`, `::1`) are always allowed — they are
|
|
43
|
+
* not exposed to network interception. Any other `http://` URL requires an
|
|
44
|
+
* explicit `allowInsecureHttp` opt-in.
|
|
45
|
+
*/
|
|
46
|
+
declare function assertSecureUrl(rawUrl: string, label: string, allowInsecureHttp?: boolean): void;
|
|
47
|
+
/** `fetch()` with an abort-based timeout (default 30s), surfacing a clear timeout error. */
|
|
48
|
+
declare function fetchWithTimeout(url: string, init: RequestInit, service: string, timeoutMs?: number): Promise<Response>;
|
|
49
|
+
|
|
50
|
+
export { type CredentialInput, assertSecureUrl, fetchWithTimeout, requireCredential, resolveCredential, resolveOptionalCredential };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolkit for building remote-secret resolvers (Bitwarden, Infisical, Doppler,
|
|
3
|
+
* 1Password, and any third-party vault).
|
|
4
|
+
*
|
|
5
|
+
* It centralises the cross-cutting concerns every vault provider shares so each
|
|
6
|
+
* one is written — and audited — exactly once:
|
|
7
|
+
*
|
|
8
|
+
* - **Bootstrap-credential resolution** that accepts a lazy provider instead of
|
|
9
|
+
* forcing a plaintext environment string. The function form keeps the secret
|
|
10
|
+
* out of `process.env`/dotfiles (read it from the OS keychain, an STS/OIDC
|
|
11
|
+
* exchange, `op read`, …) so an environment harvest finds nothing.
|
|
12
|
+
* - **HTTPS transport enforcement** so a bootstrap credential is never sent in
|
|
13
|
+
* cleartext to an overridable (self-hosted) endpoint.
|
|
14
|
+
* - **A fetch wrapper** with an abort-based timeout.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* A bootstrap credential — a vault access token, client secret, service token, …
|
|
18
|
+
*
|
|
19
|
+
* Either a literal string, or a function that produces one on demand. Prefer the
|
|
20
|
+
* function form in hardened setups: it lets the credential come from the OS
|
|
21
|
+
* keychain, a short-lived token exchange, or workload identity rather than living
|
|
22
|
+
* in an environment variable a supply-chain harvester can read.
|
|
23
|
+
*/
|
|
24
|
+
type CredentialInput = string | (() => string | Promise<string>);
|
|
25
|
+
/**
|
|
26
|
+
* Validate a *required* credential at construction time.
|
|
27
|
+
*
|
|
28
|
+
* A literal string is checked eagerly so the familiar synchronous
|
|
29
|
+
* `"<label> is required"` error still fires the moment the resolver is built. A
|
|
30
|
+
* function provider is accepted as-is and validated when it is later resolved
|
|
31
|
+
* (its value isn't available yet).
|
|
32
|
+
*/
|
|
33
|
+
declare function requireCredential(input: CredentialInput | undefined, label: string): CredentialInput;
|
|
34
|
+
/** Resolve a credential to its string value at use time, asserting it is non-empty. */
|
|
35
|
+
declare function resolveCredential(input: CredentialInput, label: string): Promise<string>;
|
|
36
|
+
/** Resolve an *optional* credential: `undefined` passes through, anything else is validated. */
|
|
37
|
+
declare function resolveOptionalCredential(input: CredentialInput | undefined, label: string): Promise<string | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* Reject a non-`https:` endpoint so a bootstrap credential is never transmitted
|
|
40
|
+
* in cleartext.
|
|
41
|
+
*
|
|
42
|
+
* Loopback hosts (`localhost`, `127.0.0.1`, `::1`) are always allowed — they are
|
|
43
|
+
* not exposed to network interception. Any other `http://` URL requires an
|
|
44
|
+
* explicit `allowInsecureHttp` opt-in.
|
|
45
|
+
*/
|
|
46
|
+
declare function assertSecureUrl(rawUrl: string, label: string, allowInsecureHttp?: boolean): void;
|
|
47
|
+
/** `fetch()` with an abort-based timeout (default 30s), surfacing a clear timeout error. */
|
|
48
|
+
declare function fetchWithTimeout(url: string, init: RequestInit, service: string, timeoutMs?: number): Promise<Response>;
|
|
49
|
+
|
|
50
|
+
export { type CredentialInput, assertSecureUrl, fetchWithTimeout, requireCredential, resolveCredential, resolveOptionalCredential };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'./chunk-I7AUKTXE.js';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
|
+
export{l as assertSecureUrl,f as fetchWithTimeout,u as requireCredential,a as resolveCredential,c as resolveOptionalCredential};
|
package/dist/valibot.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';require('./chunk-
|
|
1
|
+
'use strict';var chunkCDXO2XX3_cjs=require('./chunk-CDXO2XX3.cjs');require('./chunk-DIJNUFGZ.cjs');var chunk4QOKRJ3F_cjs=require('./chunk-4QOKRJ3F.cjs');require('./chunk-D6WM53FN.cjs');async function v(o,t,e,c){let r={},a={};for(let n of o)try{let s=n.load?await n.load():{};r={...r,...s};for(let[i,u]of Object.entries(s))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(s){if(e)throw new Error(`Resolver ${n.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(t)for(let[n,s]of Object.entries(r))r[n]=s.replace(/\$\{([^}]+)\}/g,(i,u)=>r[u]||"");return await chunkCDXO2XX3_cjs.c(r,a,c),{env:r,provenance:a}}function d(o,t,e,c){let r={},a={};for(let n of o)try{if(!n.loadSync){if(e)throw new Error(`Resolver ${n.name} does not support sync loading`);continue}let s=n.loadSync();r={...r,...s};for(let[i,u]of Object.entries(s))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(s){if(e)throw new Error(`Resolver ${n.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(t)for(let[n,s]of Object.entries(r))r[n]=s.replace(/\$\{([^}]+)\}/g,(i,u)=>r[u]||"");return chunkCDXO2XX3_cjs.b(r,a,c),{env:r,provenance:a}}function y(o){return !o||!Array.isArray(o)?[{path:[],message:"Validation failed",code:"unknown_error"}]:o.map(t=>{if(!t||typeof t!="object")return {path:[],message:"Validation failed",code:"unknown_error"};let e=t;return {path:e.path?.map(c=>c.key)||[],message:e.message||"Validation failed",code:e.type}})}async function b(o,t={}){let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=false,strict:r=true,references:a}=t,{env:n}=await v(e,c,r,a);return o.parseAsync(n)}async function w(o,t={}){try{let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=!1,strict:r=!0,references:a}=t,{env:n}=await v(e,c,r,a),s=await o.safeParseAsync(n);if(s.success)return {success:!0,data:s.output};let i=y(s.issues);return {success:!1,error:i.map(f=>f.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}function h(o,t={}){let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=false,strict:r=true,references:a}=t,{env:n}=d(e,c,r,a);return o.parse(n)}function S(o,t={}){try{let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=!1,strict:r=!0,references:a}=t,{env:n}=d(e,c,r,a),s=o.safeParse(n);if(s.success)return {success:!0,data:s.output};let i=y(s.issues);return {success:!1,error:i.map(f=>f.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}exports.resolveSyncValibot=h;exports.resolveValibot=b;exports.safeResolveSyncValibot=S;exports.safeResolveValibot=w;
|
package/dist/valibot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {c,b as b$1}from'./chunk-CTJYBBOB.js';import'./chunk-ZSM2NDX5.js';import {a}from'./chunk-WKIPEKF6.js';import'./chunk-I7AUKTXE.js';async function v(o,t,e,c$1){let r={},a={};for(let n of o)try{let s=n.load?await n.load():{};r={...r,...s};for(let[i,u]of Object.entries(s))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(s){if(e)throw new Error(`Resolver ${n.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(t)for(let[n,s]of Object.entries(r))r[n]=s.replace(/\$\{([^}]+)\}/g,(i,u)=>r[u]||"");return await c(r,a,c$1),{env:r,provenance:a}}function d(o,t,e,c){let r={},a={};for(let n of o)try{if(!n.loadSync){if(e)throw new Error(`Resolver ${n.name} does not support sync loading`);continue}let s=n.loadSync();r={...r,...s};for(let[i,u]of Object.entries(s))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(s){if(e)throw new Error(`Resolver ${n.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(t)for(let[n,s]of Object.entries(r))r[n]=s.replace(/\$\{([^}]+)\}/g,(i,u)=>r[u]||"");return b$1(r,a,c),{env:r,provenance:a}}function y(o){return !o||!Array.isArray(o)?[{path:[],message:"Validation failed",code:"unknown_error"}]:o.map(t=>{if(!t||typeof t!="object")return {path:[],message:"Validation failed",code:"unknown_error"};let e=t;return {path:e.path?.map(c=>c.key)||[],message:e.message||"Validation failed",code:e.type}})}async function b(o,t={}){let{resolvers:e=[a()],interpolate:c=false,strict:r=true,references:a$1}=t,{env:n}=await v(e,c,r,a$1);return o.parseAsync(n)}async function w(o,t={}){try{let{resolvers:e=[a()],interpolate:c=!1,strict:r=!0,references:a$1}=t,{env:n}=await v(e,c,r,a$1),s=await o.safeParseAsync(n);if(s.success)return {success:!0,data:s.output};let i=y(s.issues);return {success:!1,error:i.map(f=>f.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}function h(o,t={}){let{resolvers:e=[a()],interpolate:c=false,strict:r=true,references:a$1}=t,{env:n}=d(e,c,r,a$1);return o.parse(n)}function S(o,t={}){try{let{resolvers:e=[a()],interpolate:c=!1,strict:r=!0,references:a$1}=t,{env:n}=d(e,c,r,a$1),s=o.safeParse(n);if(s.success)return {success:!0,data:s.output};let i=y(s.issues);return {success:!1,error:i.map(f=>f.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}export{h as resolveSyncValibot,b as resolveValibot,S as safeResolveSyncValibot,w as safeResolveValibot};
|
package/dist/web.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkDYFRO3NM_cjs=require('./chunk-DYFRO3NM.cjs');require('./chunk-WVMDTD6J.cjs'),require('./chunk-CDXO2XX3.cjs'),require('./chunk-O7NR4K6A.cjs');var chunkDIJNUFGZ_cjs=require('./chunk-DIJNUFGZ.cjs'),chunk4QOKRJ3F_cjs=require('./chunk-4QOKRJ3F.cjs');require('./chunk-BFLXBLZ3.cjs'),require('./chunk-D6WM53FN.cjs');var x=()=>typeof globalThis.window<"u";async function E(r,v={}){let{resolvers:l=[chunk4QOKRJ3F_cjs.a()],clientPrefix:e="PUBLIC_",strict:p=true,references:m}=v,i=Object.keys(r).filter(n=>!n.startsWith(e));if(x()&&i.length>0){let n=new Error(`\u274C Server-only environment variables accessed in browser context: ${i.join(", ")}
|
|
2
2
|
\u{1F4A1} Only variables prefixed with '${e}' are allowed in client bundles.`);if(process.env.NODE_ENV==="development")throw n;return console.error(n.message),{}}let s={};for(let[n,c]of Object.entries(r))n.startsWith(e)&&(s[n]=c);let S=l.map(n=>[n,s]);return await chunkDYFRO3NM_cjs.d({resolvers:S,references:m,options:{strict:p}})}async function P(r,v={}){let{resolvers:l=[chunkDIJNUFGZ_cjs.a({expand:true}),chunk4QOKRJ3F_cjs.a()],clientPrefix:e="PUBLIC_",policies:p,interpolate:m,strict:i,references:s}=v,o=Object.keys(r.client).filter(t=>!t.startsWith(e));if(o.length>0)throw new Error(`\u274C Client environment variables must be prefixed with '${e}': ${o.join(", ")}
|
|
3
3
|
\u{1F4A1} Rename these variables to start with '${e}' (e.g., ${o[0]} \u2192 ${e}${o[0]})`);let c=Object.keys(r.server).filter(t=>t.startsWith(e));if(c.length>0)throw new Error(`\u274C Server environment variables should not be prefixed with '${e}': ${c.join(", ")}
|
|
4
4
|
\u{1F4A1} These variables will be exposed to the client. Move to client schema or remove prefix.`);let T=l.map(t=>[t,r.server]),d=await chunkDYFRO3NM_cjs.d({resolvers:T,references:s,options:{policies:p,interpolate:m,strict:i}}),y=l.map(t=>[t,r.client]),b=await chunkDYFRO3NM_cjs.d({resolvers:y,references:s,options:{strict:i}});return {server:d,client:b}}x()&&process.env.NODE_ENV==="development"&&console.warn(`\u{1F310} node-env-resolver/web: Running in browser context
|
package/dist/web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {d}from'./chunk-3EWCMDFP.js';import'./chunk-K4NIC5T3.js';import'./chunk-CTJYBBOB.js';import'./chunk-6EWR3WHU.js';import {a as a$1}from'./chunk-ZSM2NDX5.js';import {a}from'./chunk-WKIPEKF6.js';import'./chunk-ZMRT37K3.js';import'./chunk-I7AUKTXE.js';var x=()=>typeof globalThis.window<"u";async function E(r,v={}){let{resolvers:l=[a()],clientPrefix:e="PUBLIC_",strict:p=true,references:m}=v,i=Object.keys(r).filter(n=>!n.startsWith(e));if(x()&&i.length>0){let n=new Error(`\u274C Server-only environment variables accessed in browser context: ${i.join(", ")}
|
|
2
2
|
\u{1F4A1} Only variables prefixed with '${e}' are allowed in client bundles.`);if(process.env.NODE_ENV==="development")throw n;return console.error(n.message),{}}let s={};for(let[n,c]of Object.entries(r))n.startsWith(e)&&(s[n]=c);let S=l.map(n=>[n,s]);return await d({resolvers:S,references:m,options:{strict:p}})}async function P(r,v={}){let{resolvers:l=[a$1({expand:true}),a()],clientPrefix:e="PUBLIC_",policies:p,interpolate:m,strict:i,references:s}=v,o=Object.keys(r.client).filter(t=>!t.startsWith(e));if(o.length>0)throw new Error(`\u274C Client environment variables must be prefixed with '${e}': ${o.join(", ")}
|
|
3
3
|
\u{1F4A1} Rename these variables to start with '${e}' (e.g., ${o[0]} \u2192 ${e}${o[0]})`);let c=Object.keys(r.server).filter(t=>t.startsWith(e));if(c.length>0)throw new Error(`\u274C Server environment variables should not be prefixed with '${e}': ${c.join(", ")}
|
|
4
4
|
\u{1F4A1} These variables will be exposed to the client. Move to client schema or remove prefix.`);let T=l.map(t=>[t,r.server]),d$1=await d({resolvers:T,references:s,options:{policies:p,interpolate:m,strict:i}}),y=l.map(t=>[t,r.client]),b=await d({resolvers:y,references:s,options:{strict:i}});return {server:d$1,client:b}}x()&&process.env.NODE_ENV==="development"&&console.warn(`\u{1F310} node-env-resolver/web: Running in browser context
|
package/dist/zod.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';require('./chunk-
|
|
1
|
+
'use strict';var chunkCDXO2XX3_cjs=require('./chunk-CDXO2XX3.cjs');require('./chunk-DIJNUFGZ.cjs');var chunk4QOKRJ3F_cjs=require('./chunk-4QOKRJ3F.cjs');require('./chunk-D6WM53FN.cjs');async function m(o,t,e,c){let s={},a={};for(let n of o)try{let r=n.load?await n.load():{};s={...s,...r};for(let[i,u]of Object.entries(r))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(r){if(e)throw new Error(`Resolver ${n.name} failed: ${r instanceof Error?r.message:r}`,{cause:r})}if(t)for(let[n,r]of Object.entries(s))s[n]=r.replace(/\$\{([^}]+)\}/g,(i,u)=>s[u]||"");return await chunkCDXO2XX3_cjs.c(s,a,c),{env:s,provenance:a}}function v(o){if(!o||typeof o!="object")return [{path:[],message:"Validation failed",code:"unknown_error"}];let t=o;return !t.issues||!Array.isArray(t.issues)?[{path:[],message:"Validation failed",code:"unknown_error"}]:t.issues.map(e=>({path:e.path||[],message:e.message,code:e.code}))}async function h(o,t={}){let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=false,strict:s=true,references:a}=t,{env:n}=await m(e,c,s,a);return o.parse(n)}async function S(o,t={}){try{let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=!1,strict:s=!0,references:a}=t,{env:n}=await m(e,c,s,a),r=o.safeParse(n);if(r.success)return {success:!0,data:r.data};let i=v(r.error);return {success:!1,error:i.map(l=>l.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}function g(o,t,e,c){let s={},a={};for(let n of o)try{if(!n.loadSync){if(e)throw new Error(`Resolver ${n.name} does not support sync loading`);continue}let r=n.loadSync();s={...s,...r};for(let[i,u]of Object.entries(r))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(r){if(e)throw new Error(`Resolver ${n.name} failed: ${r instanceof Error?r.message:r}`,{cause:r})}if(t)for(let[n,r]of Object.entries(s))s[n]=r.replace(/\$\{([^}]+)\}/g,(i,u)=>s[u]||"");return chunkCDXO2XX3_cjs.b(s,a,c),{env:s,provenance:a}}function w(o,t={}){let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=false,strict:s=true,references:a}=t,{env:n}=g(e,c,s,a);return o.parse(n)}function O(o,t={}){try{let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:c=!1,strict:s=!0,references:a}=t,{env:n}=g(e,c,s,a),r=o.safeParse(n);if(r.success)return {success:!0,data:r.data};let i=v(r.error);return {success:!1,error:i.map(l=>l.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}exports.resolveSyncZod=w;exports.resolveZod=h;exports.safeResolveSyncZod=O;exports.safeResolveZod=S;
|
package/dist/zod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-
|
|
1
|
+
import {c,b}from'./chunk-CTJYBBOB.js';import'./chunk-ZSM2NDX5.js';import {a}from'./chunk-WKIPEKF6.js';import'./chunk-I7AUKTXE.js';async function m(o,t,e,c$1){let s={},a={};for(let n of o)try{let r=n.load?await n.load():{};s={...s,...r};for(let[i,u]of Object.entries(r))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(r){if(e)throw new Error(`Resolver ${n.name} failed: ${r instanceof Error?r.message:r}`,{cause:r})}if(t)for(let[n,r]of Object.entries(s))s[n]=r.replace(/\$\{([^}]+)\}/g,(i,u)=>s[u]||"");return await c(s,a,c$1),{env:s,provenance:a}}function v(o){if(!o||typeof o!="object")return [{path:[],message:"Validation failed",code:"unknown_error"}];let t=o;return !t.issues||!Array.isArray(t.issues)?[{path:[],message:"Validation failed",code:"unknown_error"}]:t.issues.map(e=>({path:e.path||[],message:e.message,code:e.code}))}async function h(o,t={}){let{resolvers:e=[a()],interpolate:c=false,strict:s=true,references:a$1}=t,{env:n}=await m(e,c,s,a$1);return o.parse(n)}async function S(o,t={}){try{let{resolvers:e=[a()],interpolate:c=!1,strict:s=!0,references:a$1}=t,{env:n}=await m(e,c,s,a$1),r=o.safeParse(n);if(r.success)return {success:!0,data:r.data};let i=v(r.error);return {success:!1,error:i.map(l=>l.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}function g(o,t,e,c){let s={},a={};for(let n of o)try{if(!n.loadSync){if(e)throw new Error(`Resolver ${n.name} does not support sync loading`);continue}let r=n.loadSync();s={...s,...r};for(let[i,u]of Object.entries(r))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(r){if(e)throw new Error(`Resolver ${n.name} failed: ${r instanceof Error?r.message:r}`,{cause:r})}if(t)for(let[n,r]of Object.entries(s))s[n]=r.replace(/\$\{([^}]+)\}/g,(i,u)=>s[u]||"");return b(s,a,c),{env:s,provenance:a}}function w(o,t={}){let{resolvers:e=[a()],interpolate:c=false,strict:s=true,references:a$1}=t,{env:n}=g(e,c,s,a$1);return o.parse(n)}function O(o,t={}){try{let{resolvers:e=[a()],interpolate:c=!1,strict:s=!0,references:a$1}=t,{env:n}=g(e,c,s,a$1),r=o.safeParse(n);if(r.success)return {success:!0,data:r.data};let i=v(r.error);return {success:!1,error:i.map(l=>l.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}export{w as resolveSyncZod,h as resolveZod,O as safeResolveSyncZod,S as safeResolveZod};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-env-resolver",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "Type-safe environment variable resolver with async resolvers - lightweight, tree-shakeable, no dependencies",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,6 +46,12 @@
|
|
|
46
46
|
"require": "./dist/resolvers.cjs",
|
|
47
47
|
"default": "./dist/resolvers.js"
|
|
48
48
|
},
|
|
49
|
+
"./provider-kit": {
|
|
50
|
+
"types": "./dist/provider-kit.d.ts",
|
|
51
|
+
"import": "./dist/provider-kit.js",
|
|
52
|
+
"require": "./dist/provider-kit.cjs",
|
|
53
|
+
"default": "./dist/provider-kit.js"
|
|
54
|
+
},
|
|
49
55
|
"./validators": {
|
|
50
56
|
"types": "./dist/validators.d.ts",
|
|
51
57
|
"import": "./dist/validators.js",
|
|
@@ -133,6 +139,16 @@
|
|
|
133
139
|
"dist",
|
|
134
140
|
"README.md"
|
|
135
141
|
],
|
|
142
|
+
"scripts": {
|
|
143
|
+
"build": "NODE_ENV=production tsup",
|
|
144
|
+
"build:dev": "tsup",
|
|
145
|
+
"build:dts": "tsc --emitDeclarationOnly",
|
|
146
|
+
"type-check": "tsc -p tsconfig.json --noEmit",
|
|
147
|
+
"lint": "eslint src/",
|
|
148
|
+
"test": "vitest run",
|
|
149
|
+
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
|
|
150
|
+
"prepublishOnly": "pnpm build && pnpm type-check"
|
|
151
|
+
},
|
|
136
152
|
"keywords": [
|
|
137
153
|
"environment",
|
|
138
154
|
"env",
|
|
@@ -167,24 +183,15 @@
|
|
|
167
183
|
},
|
|
168
184
|
"devDependencies": {
|
|
169
185
|
"@eslint/js": "^10.0.1",
|
|
170
|
-
"@types/node": "^25.
|
|
171
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
172
|
-
"@typescript-eslint/parser": "^8.
|
|
173
|
-
"eslint": "^10.
|
|
186
|
+
"@types/node": "^25.9.2",
|
|
187
|
+
"@typescript-eslint/eslint-plugin": "^8.60.1",
|
|
188
|
+
"@typescript-eslint/parser": "^8.60.1",
|
|
189
|
+
"eslint": "^10.4.1",
|
|
174
190
|
"eslint-config-prettier": "^10.1.8",
|
|
175
191
|
"eslint-plugin-import-zod": "^1.2.1",
|
|
176
|
-
"prettier": "^3.8.
|
|
192
|
+
"prettier": "^3.8.3",
|
|
177
193
|
"tsup": "^8.5.1",
|
|
178
|
-
"typescript": "^6.0.
|
|
179
|
-
"vitest": "^4.1.
|
|
180
|
-
},
|
|
181
|
-
"scripts": {
|
|
182
|
-
"build": "NODE_ENV=production tsup",
|
|
183
|
-
"build:dev": "tsup",
|
|
184
|
-
"build:dts": "tsc --emitDeclarationOnly",
|
|
185
|
-
"type-check": "tsc -p tsconfig.json --noEmit",
|
|
186
|
-
"lint": "eslint src/",
|
|
187
|
-
"test": "vitest run",
|
|
188
|
-
"format": "prettier --write \"**/*.{ts,tsx,md}\""
|
|
194
|
+
"typescript": "^6.0.3",
|
|
195
|
+
"vitest": "^4.1.8"
|
|
189
196
|
}
|
|
190
|
-
}
|
|
197
|
+
}
|