@t3-oss/env-core
Advanced tools
Comparing version 0.2.2 to 0.2.3-canary.d741dde
import z, { ZodType, ZodError, ZodObject } from 'zod'; | ||
type ErrorMessage<T extends string> = T; | ||
type Simplify<T> = { | ||
[TKey in keyof T]: T[TKey]; | ||
} & {}; | ||
interface BaseOptions<TPrefix extends string, TServer extends Record<string, ZodType>, TClient extends Record<string, ZodType>> { | ||
@@ -25,4 +28,4 @@ clientPrefix: TPrefix; | ||
} | ||
declare function createEnv<TPrefix extends string, TServer extends Record<string, ZodType> = NonNullable<unknown>, TClient extends Record<string, ZodType> = NonNullable<unknown>>(opts: LooseOptions<TPrefix, TServer, TClient> | StrictOptions<TPrefix, TServer, TClient>): z.infer<ZodObject<TServer>> & z.infer<ZodObject<TClient>>; | ||
declare function createEnv<TPrefix extends string, TServer extends Record<string, ZodType> = NonNullable<unknown>, TClient extends Record<string, ZodType> = NonNullable<unknown>>(opts: LooseOptions<TPrefix, TServer, TClient> | StrictOptions<TPrefix, TServer, TClient>): Simplify<z.infer<ZodObject<TServer>> & z.infer<ZodObject<TClient>>>; | ||
export { BaseOptions, ErrorMessage, LooseOptions, StrictOptions, createEnv }; | ||
export { BaseOptions, ErrorMessage, LooseOptions, Simplify, StrictOptions, createEnv }; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);function g(e){let t=_nullishCoalesce(_nullishCoalesce(e.runtimeEnvStrict, () => (e.runtimeEnv)), () => (process.env));if(_nullishCoalesce(e.skipValidation, () => ((!!process.env.SKIP_ENV_VALIDATION&&process.env.SKIP_ENV_VALIDATION!=="false"&&process.env.SKIP_ENV_VALIDATION!=="0"))))return t;let c=typeof e.client=="object"?e.client:{},s=_zod2.default.object(c),T=_zod2.default.object(e.server),o=_nullishCoalesce(e.isServer, () => (typeof window>"u")),a=T.merge(s),i=o?a.safeParse(t):s.safeParse(t),v=_nullishCoalesce(e.onValidationError, () => ((r=>{throw console.error("\u274C Invalid environment variables:",r.flatten().fieldErrors),new Error("Invalid environment variables")}))),l=_nullishCoalesce(e.onInvalidAccess, () => ((r=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")})));return i.success===!1?v(i.error):new Proxy(i.data,{get(r,n){if(typeof n=="string")return!o&&!n.startsWith(e.clientPrefix)?l(n):r[n]}})}exports.createEnv = g; | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);function g(e){let t=_nullishCoalesce(_nullishCoalesce(e.runtimeEnvStrict, () => (e.runtimeEnv)), () => (process.env));if(!!e.skipValidation)return t;let T=typeof e.client=="object"?e.client:{},o=_zod2.default.object(T),c=_zod2.default.object(e.server),s=_nullishCoalesce(e.isServer, () => (typeof window>"u")),a=c.merge(o),i=s?a.safeParse(t):o.safeParse(t),l=_nullishCoalesce(e.onValidationError, () => ((r=>{throw console.error("\u274C Invalid environment variables:",r.flatten().fieldErrors),new Error("Invalid environment variables")}))),v=_nullishCoalesce(e.onInvalidAccess, () => ((r=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")})));return i.success===!1?l(i.error):new Proxy(i.data,{get(r,n){if(typeof n=="string")return!s&&!n.startsWith(e.clientPrefix)?v(n):r[n]}})}exports.createEnv = g; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@t3-oss/env-core", | ||
"version": "0.2.2", | ||
"version": "0.2.3-canary.d741dde", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "create-t3-app", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
37
2
18384