New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

envsafe

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envsafe - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

6

dist/envsafe.cjs.development.js

@@ -314,7 +314,5 @@ 'use strict';

try {
if (input instanceof URL) {
return input;
}
new URL(input); // validate url
return new URL(input);
return input;
} catch (_) {

@@ -321,0 +319,0 @@ throw new EnvError("Invalid url: \"" + input + "\"");

@@ -1,2 +0,2 @@

"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function i(t,e,r){return(i=o()?Reflect.construct:function(t,e,r){var o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(t,o));return r&&n(i,r.prototype),i}).apply(null,arguments)}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,o)}function o(){return i(t,arguments,r(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),n(o,t)})(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}Object.defineProperty(exports,"__esModule",{value:!0});var s=function(t){function r(e){var n;return n=t.call(this,e)||this,Object.setPrototypeOf(c(n),r.prototype),n}return e(r,t),r}(u(TypeError)),a=function(t){function r(e){var n;return n=t.call(this,e)||this,Object.setPrototypeOf(c(n),r.prototype),n}return e(r,t),r}(u(ReferenceError));function f(t){for(var e=t.errors,r=[],n=[],o=0,i=Object.keys(e);o<i.length;o++){var u=i[o],c=e[u];c instanceof a?n.push(" "+u+": "+(c.message||"required")):r.push(" "+u+": "+(c.message||"required"))}return r.length&&r.unshift("❌ Invalid environment variables:"),n.length&&n.unshift("💨 Missing environment variables:"),["================================"].concat(r,n,["================================"]).join("\n")}function p(t){var e=f(t);throw console.error(e),"undefined"!=typeof process&&process.exit(1),new Error("Invalid/missing environment variables: "+Object.keys(t.errors).join(", "))}function l(t){var e=t.env,r=t.validator,n=t.key,o=e[n];if(void 0===o&&"production"!==e.NODE_ENV&&void 0!==r.devDefault&&(o=r.devDefault),void 0===o&&void 0!==r.default&&(o=r.default),void 0===o)throw new a("Missing value for "+n);var i=r._parse(o);if(r.choices&&!r.choices.includes(i))throw new s('Value "'+i+'" not in choices ['+r.choices+"]");return i}var v=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function d(e){return function(r){return void 0===r&&(r={}),t({},r,{_parse:e})}}var h=d((function(t){switch(t){case!0:case"true":case"t":case"1":return!0;case!1:case"false":case"f":case"0":return!1;default:throw new s('Invalid boolean input: "'+t+'"')}})),y=d((function(t){if("string"!=typeof t)throw new s('Invalid string input: "'+t+'"');return t})),b=d((function(t){if(!v.test(t))throw new s('Invalid email address: "'+t+'"');return t})),w=d((function(t){var e=+t;if(Number.isNaN(e))throw new s('Invalid number input: "'+t+'"');return e})),O=d((function(t){var e=+t;if(Number.isNaN(e)||""+e!=""+t||e%1!=0||e<1||e>65535)throw new s('Invalid port input: "'+t+'"');return e})),g=d((function(t){try{return t instanceof URL?t:new URL(t)}catch(e){throw new s('Invalid url: "'+t+'"')}})),j=d((function(t){try{return"string"!=typeof t?t:JSON.parse(t)}catch(e){throw new s('Invalid json: "'+t+'"')}}));exports.EnvError=s,exports.EnvMissingError=a,exports.bool=h,exports.cleanEnv=function(t,e,r){var n=(void 0===r?{}:r).reporter,o=void 0===n?p:n,i={},u={};for(var c in e){var s=e[c];try{var a=l({env:t,validator:s,key:c});u[c]=a}catch(t){i[c]=t}}return Object.keys(i).length&&o({errors:i,output:u,env:t}),Object.freeze?Object.freeze(u):u},exports.defaultReporter=p,exports.defaultReporterText=f,exports.email=b,exports.json=j,exports.makeValidator=d,exports.num=w,exports.port=O,exports.str=y,exports.url=g;
"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function i(t,e,r){return(i=o()?Reflect.construct:function(t,e,r){var o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(t,o));return r&&n(i,r.prototype),i}).apply(null,arguments)}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,o)}function o(){return i(t,arguments,r(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),n(o,t)})(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}Object.defineProperty(exports,"__esModule",{value:!0});var s=function(t){function r(e){var n;return n=t.call(this,e)||this,Object.setPrototypeOf(c(n),r.prototype),n}return e(r,t),r}(u(TypeError)),a=function(t){function r(e){var n;return n=t.call(this,e)||this,Object.setPrototypeOf(c(n),r.prototype),n}return e(r,t),r}(u(ReferenceError));function f(t){for(var e=t.errors,r=[],n=[],o=0,i=Object.keys(e);o<i.length;o++){var u=i[o],c=e[u];c instanceof a?n.push(" "+u+": "+(c.message||"required")):r.push(" "+u+": "+(c.message||"required"))}return r.length&&r.unshift("❌ Invalid environment variables:"),n.length&&n.unshift("💨 Missing environment variables:"),["================================"].concat(r,n,["================================"]).join("\n")}function p(t){var e=f(t);throw console.error(e),"undefined"!=typeof process&&process.exit(1),new Error("Invalid/missing environment variables: "+Object.keys(t.errors).join(", "))}function l(t){var e=t.env,r=t.validator,n=t.key,o=e[n];if(void 0===o&&"production"!==e.NODE_ENV&&void 0!==r.devDefault&&(o=r.devDefault),void 0===o&&void 0!==r.default&&(o=r.default),void 0===o)throw new a("Missing value for "+n);var i=r._parse(o);if(r.choices&&!r.choices.includes(i))throw new s('Value "'+i+'" not in choices ['+r.choices+"]");return i}var v=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function d(e){return function(r){return void 0===r&&(r={}),t({},r,{_parse:e})}}var h=d((function(t){switch(t){case!0:case"true":case"t":case"1":return!0;case!1:case"false":case"f":case"0":return!1;default:throw new s('Invalid boolean input: "'+t+'"')}})),y=d((function(t){if("string"!=typeof t)throw new s('Invalid string input: "'+t+'"');return t})),b=d((function(t){if(!v.test(t))throw new s('Invalid email address: "'+t+'"');return t})),w=d((function(t){var e=+t;if(Number.isNaN(e))throw new s('Invalid number input: "'+t+'"');return e})),O=d((function(t){var e=+t;if(Number.isNaN(e)||""+e!=""+t||e%1!=0||e<1||e>65535)throw new s('Invalid port input: "'+t+'"');return e})),g=d((function(t){try{return new URL(t),t}catch(e){throw new s('Invalid url: "'+t+'"')}})),j=d((function(t){try{return"string"!=typeof t?t:JSON.parse(t)}catch(e){throw new s('Invalid json: "'+t+'"')}}));exports.EnvError=s,exports.EnvMissingError=a,exports.bool=h,exports.cleanEnv=function(t,e,r){var n=(void 0===r?{}:r).reporter,o=void 0===n?p:n,i={},u={};for(var c in e){var s=e[c];try{var a=l({env:t,validator:s,key:c});u[c]=a}catch(t){i[c]=t}}return Object.keys(i).length&&o({errors:i,output:u,env:t}),Object.freeze?Object.freeze(u):u},exports.defaultReporter=p,exports.defaultReporterText=f,exports.email=b,exports.json=j,exports.makeValidator=d,exports.num=w,exports.port=O,exports.str=y,exports.url=g;
//# sourceMappingURL=envsafe.cjs.production.min.js.map

@@ -310,7 +310,5 @@ function _extends() {

try {
if (input instanceof URL) {
return input;
}
new URL(input); // validate url
return new URL(input);
return input;
} catch (_) {

@@ -317,0 +315,0 @@ throw new EnvError("Invalid url: \"" + input + "\"");

@@ -8,3 +8,3 @@ import { Spec, ValidatorSpec } from './types';

export declare const port: (spec?: Spec<number> | undefined) => ValidatorSpec<number>;
export declare const url: (spec?: Spec<URL> | undefined) => ValidatorSpec<URL>;
export declare const url: (spec?: Spec<string> | undefined) => ValidatorSpec<string>;
export declare const json: (spec?: Spec<unknown> | undefined) => ValidatorSpec<unknown>;
{
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -5,4 +5,13 @@ [![Maintainability](https://api.codeclimate.com/v1/badges/c17614f0d80b810e47a6/maintainability)](https://codeclimate.com/github/KATT/envsafe/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/c17614f0d80b810e47a6/test_coverage)](https://codeclimate.com/github/KATT/envsafe/test_coverage)

Mostly based on the great project [envalid](https://github.com/af/envalid).
Mostly based on the great project [envalid](https://github.com/af/envalid), but with some key differences
- Rewrite in 100% TypeScript
- Always strict - only get the props you have defined
- No dependencies - smaller bundle for browser/isomorphic
## API
```ts
```
## Commands

@@ -9,0 +18,0 @@

@@ -69,8 +69,6 @@ import { EnvError } from './errors';

export const url = makeValidator<URL>(input => {
export const url = makeValidator<string>(input => {
try {
if (input instanceof URL) {
return input;
}
return new URL(input);
new URL(input); // validate url
return input;
} catch (_) {

@@ -77,0 +75,0 @@ throw new EnvError(`Invalid url: "${input}"`);

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc