feat: initial commit

This commit is contained in:
Carlos
2024-08-12 22:57:35 -04:00
commit 6f68ae8259
13140 changed files with 1104801 additions and 0 deletions

21
node_modules/dotenv-webpack/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 Matt Steele
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

142
node_modules/dotenv-webpack/README.md generated vendored Normal file
View File

@ -0,0 +1,142 @@
<h1>
<img width="30" height="30" src="https://raw.githubusercontent.com/motdotla/dotenv/master/dotenv.png" alt="dotenv" />
<img width="30" height="30" src="https://webpack.js.org/assets/icon-square-big.svg" alt="webpack">
dotenv-webpack
</h1>
A secure webpack plugin that supports dotenv and other environment variables and **only exposes what you choose and use**.
<div align="center">
<a href="https://www.npmjs.com/package/dotenv-webpack" target="_blank">
<img alt="npm" src="https://img.shields.io/npm/v/dotenv-webpack.svg?maxAge=0&style=flat" />
</a>
<a href="https://codecov.io/gh/mrsteele/dotenv-webpack" target="_blank">
<img alt="codecov" src="https://codecov.io/gh/mrsteele/dotenv-webpack/branch/master/graph/badge.svg" />
</a>
<a href="https://github.com/mrsteele/dotenv-webpack/actions/workflows/main.yml" target="_blank">
<img alt="Main" src="https://github.com/mrsteele/dotenv-webpack/actions/workflows/main.yml/badge.svg" />
</a>
<object id="badge" data="https://snyk-widget.herokuapp.com/badge/npm/dotenv-webpack/badge.svg" type="image/svg+xml"></object>
<a href="https://www.dotenv.org/get-started?r=3" target="_blank">
<img alt="dotenv-vault" src="https://badge.dotenv.org/works-with.svg?r=3" />
</a>
</div>
## Installation
Include the package locally in your repository.
`npm install dotenv-webpack --save-dev`
## Description
`dotenv-webpack` wraps `dotenv` and `Webpack.DefinePlugin`. As such, it does a text replace in the resulting bundle for any instances of `process.env`.
Your `.env` files can include sensitive information. Because of this,`dotenv-webpack` will only expose environment variables that are **explicitly referenced in your code** to your final bundle.
Interested in taking your environments to the next level? Check out the [Dotenv Organization](https://www.dotenv.org/get-started?r=3).
## Usage
The plugin can be installed with little-to-no configuration needed. Once installed, you can access the variables within your code using `process.env` as you would with `dotenv`.
The example bellow shows a standard use-case.
### Create a .env file
```dosini
// .env
DB_HOST=127.0.0.1
DB_PASS=foobar
S3_API=mysecretkey
```
### Add it to your Webpack config file
```javascript
// webpack.config.js
const Dotenv = require('dotenv-webpack');
module.exports = {
...
plugins: [
new Dotenv()
]
...
};
```
### Use in your code
```javascript
// file1.js
console.log(process.env.DB_HOST);
// '127.0.0.1'
```
### Resulting bundle
```javascript
// bundle.js
console.log('127.0.0.1');
```
Note: the `.env` values for `DB_PASS` and `S3_API` are **NOT** present in our bundle, as they were never referenced (as `process.env.[VAR_NAME]`) in the code.
## How Secure?
By allowing you to define exactly where you are loading environment variables from and bundling only variables in your project that are explicitly referenced in your code, you can be sure that only what you need is included and you do not accidentally leak anything sensitive.
### Recommended
Add `.env` to your `.gitignore` file
## Limitations
Due to the fact that we use `webpack.DefinePlugin` under the hood, we cannot support destructing as that breaks how this plugin is meant to be used. Because of this, please reference your variables without destructing. For more information about this, please review the issue [here](https://github.com/mrsteele/dotenv-webpack/issues/70).
## `process.env` stubbing / replacing
`process.env` is not polyfilled in Webpack 5+, leading to errors in environments where `process` is `null` (browsers).
We automatically replace any remaining `process.env`s in these environments with `"MISSING_ENV_VAR"` to avoid these errors.
When the `prefix` option is set, `process.env`s will not be stubbed.
If you are running into issues where you or another package you use interfaces with `process.env`, it might be best to set `ignoreStub: true` and make sure you always reference variables that exist within your code (See [this issue](https://github.com/mrsteele/dotenv-webpack/issues/271) for more information).
## Properties
Use the following properties to configure your instance.
* **path** (`'./.env'`) - The path to your environment variables.
* **safe** (`false`) - If true, load '.env.example' to verify the '.env' variables are all set. Can also be a string to a different file.
* **allowEmptyValues** (`false`) - Whether to allow empty strings in safe mode. If false, will throw an error if any env variables are empty (but only if safe mode is enabled).
* **systemvars** (`false`) - Set to true if you would rather load all system variables as well (useful for CI purposes).
* **silent** (`false`) - If true, all warnings will be suppressed.
* **expand** (`false`) - Allows your variables to be "expanded" for reusability within your `.env` file.
* **defaults** (`false`) - Adds support for `dotenv-defaults`. If set to `true`, uses `./.env.defaults`. If a string, uses that location for a defaults file. Read more at [npm](https://www.npmjs.com/package/dotenv-defaults).
* **ignoreStub** (`false`) - Override the automatic check whether to stub `process.env`. [Read more here](#user-content-processenv-stubbing--replacing).
* **prefix** (`'process.env.'`) - The prefix to use before the name of your env variables.
The following example shows how to set any/all arguments.
```javascript
module.exports = {
...
plugins: [
new Dotenv({
path: './some.other.env', // load this now instead of the ones in '.env'
safe: true, // load '.env.example' to verify the '.env' variables are all set. Can also be a string to a different file.
allowEmptyValues: true, // allow empty variables (e.g. `FOO=`) (treat it as empty string, rather than missing)
systemvars: true, // load all the predefined 'process.env' variables which will trump anything local per dotenv specs.
silent: true, // hide any errors
defaults: false, // load '.env.defaults' as the default values if empty.
prefix: 'import.meta.env.' // reference your env variables as 'import.meta.env.ENV_VAR'.
})
]
...
};
```
## LICENSE
MIT

3
node_modules/dotenv-webpack/browser.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
const plugin = require('./dist').default
module.exports = plugin

266
node_modules/dotenv-webpack/dist/index.js generated vendored Normal file
View File

@ -0,0 +1,266 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _dotenvDefaults = _interopRequireDefault(require("dotenv-defaults"));
var _fs = _interopRequireDefault(require("fs"));
var _webpack = require("webpack");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
// Mostly taken from here: https://github.com/motdotla/dotenv-expand/blob/master/lib/main.js#L4
var interpolate = function interpolate(env, vars) {
var matches = env.match(/\$([a-zA-Z0-9_]+)|\${([a-zA-Z0-9_]+)}/g) || [];
matches.forEach(function (match) {
var key = match.replace(/\$|{|}/g, '');
var variable = vars[key] || '';
variable = interpolate(variable, vars);
env = env.replace(match, variable);
});
return env;
};
var isMainThreadElectron = function isMainThreadElectron(target) {
return target.startsWith('electron') && target.endsWith('main');
};
var Dotenv = /*#__PURE__*/function () {
/**
* The dotenv-webpack plugin.
* @param {Object} options - The parameters.
* @param {String} [options.path=./.env] - The location of the environment variable.
* @param {Boolean|String} [options.safe=false] - If false ignore safe-mode, if true load `'./.env.example'`, if a string load that file as the sample.
* @param {Boolean} [options.systemvars=false] - If true, load system environment variables.
* @param {Boolean} [options.silent=false] - If true, suppress warnings, if false, display warnings.
* @param {String} [options.prefix=process.env.] - The prefix, used to denote environment variables.
* @returns {webpack.DefinePlugin}
*/
function Dotenv() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, Dotenv);
this.config = Object.assign({}, {
path: './.env',
prefix: 'process.env.'
}, config);
}
_createClass(Dotenv, [{
key: "apply",
value: function apply(compiler) {
var _compiler$options$tar;
var variables = this.gatherVariables();
var target = (_compiler$options$tar = compiler.options.target) !== null && _compiler$options$tar !== void 0 ? _compiler$options$tar : 'web';
var version = compiler.webpack && compiler.webpack.version || '4';
var data = this.formatData({
variables: variables,
target: target,
version: version
});
new _webpack.DefinePlugin(data).apply(compiler);
}
}, {
key: "gatherVariables",
value: function gatherVariables() {
var _this$config = this.config,
safe = _this$config.safe,
allowEmptyValues = _this$config.allowEmptyValues;
var vars = this.initializeVars();
var _this$getEnvs = this.getEnvs(),
env = _this$getEnvs.env,
blueprint = _this$getEnvs.blueprint;
Object.keys(blueprint).forEach(function (key) {
var value = Object.prototype.hasOwnProperty.call(vars, key) ? vars[key] : env[key];
var isMissing = typeof value === 'undefined' || value === null || !allowEmptyValues && value === '';
if (safe && isMissing) {
throw new Error("Missing environment variable: ".concat(key));
} else {
vars[key] = value;
}
}); // add the leftovers
if (safe) {
Object.keys(env).forEach(function (key) {
if (!Object.prototype.hasOwnProperty.call(vars, key)) {
vars[key] = env[key];
}
});
}
return vars;
}
}, {
key: "initializeVars",
value: function initializeVars() {
return this.config.systemvars ? Object.assign({}, process.env) : {};
}
}, {
key: "getEnvs",
value: function getEnvs() {
var _this$config2 = this.config,
path = _this$config2.path,
silent = _this$config2.silent,
safe = _this$config2.safe;
var env = _dotenvDefaults["default"].parse(this.loadFile({
file: path,
silent: silent
}), this.getDefaults());
var blueprint = env;
if (safe) {
var file = './.env.example';
if (safe !== true) {
file = safe;
}
blueprint = _dotenvDefaults["default"].parse(this.loadFile({
file: file,
silent: silent
}));
}
return {
env: env,
blueprint: blueprint
};
}
}, {
key: "getDefaults",
value: function getDefaults() {
var _this$config3 = this.config,
silent = _this$config3.silent,
defaults = _this$config3.defaults;
if (defaults) {
return this.loadFile({
file: defaults === true ? './.env.defaults' : defaults,
silent: silent
});
}
return '';
}
}, {
key: "formatData",
value: function formatData(_ref) {
var _ref$variables = _ref.variables,
variables = _ref$variables === void 0 ? {} : _ref$variables,
target = _ref.target,
version = _ref.version;
var _this$config4 = this.config,
expand = _this$config4.expand,
prefix = _this$config4.prefix;
var formatted = Object.keys(variables).reduce(function (obj, key) {
var v = variables[key];
var vKey = "".concat(prefix).concat(key);
var vValue;
if (expand) {
if (v.substring(0, 2) === '\\$') {
vValue = v.substring(1);
} else if (v.indexOf('\\$') > 0) {
vValue = v.replace(/\\\$/g, '$');
} else {
vValue = interpolate(v, variables);
}
} else {
vValue = v;
}
obj[vKey] = JSON.stringify(vValue);
return obj;
}, {}); // We have to stub any remaining `process.env`s due to Webpack 5 not polyfilling it anymore
// https://github.com/mrsteele/dotenv-webpack/issues/240#issuecomment-710231534
// However, if someone targets Node or Electron `process.env` still exists, and should therefore be kept
// https://webpack.js.org/configuration/target
if (this.shouldStub({
target: target,
version: version
})) {
// Results in `"MISSING_ENV_VAR".NAME` which is valid JS
formatted['process.env'] = '"MISSING_ENV_VAR"';
}
return formatted;
}
}, {
key: "shouldStub",
value: function shouldStub(_ref2) {
var _this = this;
var targetInput = _ref2.target,
version = _ref2.version;
if (!version.startsWith('5')) {
return false;
}
var targets = Array.isArray(targetInput) ? targetInput : [targetInput];
return targets.every(function (target) {
return (// If configured prefix is 'process.env'
_this.config.prefix === 'process.env.' && // If we're not configured to never stub
_this.config.ignoreStub !== true && ( // And
// We are configured to always stub
_this.config.ignoreStub === false || // Or if we should according to the target
!target.includes('node') && !isMainThreadElectron(target))
);
});
}
/**
* Load a file.
* @param {String} config.file - The file to load.
* @param {Boolean} config.silent - If true, suppress warnings, if false, display warnings.
* @returns {Object}
*/
}, {
key: "loadFile",
value: function loadFile(_ref3) {
var file = _ref3.file,
silent = _ref3.silent;
try {
return _fs["default"].readFileSync(file, 'utf8');
} catch (err) {
this.warn("Failed to load ".concat(file, "."), silent);
return {};
}
}
/**
* Displays a console message if 'silent' is falsey
* @param {String} msg - The message.
* @param {Boolean} silent - If true, display the message, if false, suppress the message.
*/
}, {
key: "warn",
value: function warn(msg, silent) {
!silent && console.warn(msg);
}
}]);
return Dotenv;
}();
var _default = Dotenv;
exports["default"] = _default;

16
node_modules/dotenv-webpack/index.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
'use strict'
let plugin
try {
plugin = require('./dist').default
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
require('babel-register')
plugin = require('./src').default
} else {
console.log(err)
process.exit(1)
}
}
module.exports = plugin

78
node_modules/dotenv-webpack/package.json generated vendored Normal file
View File

@ -0,0 +1,78 @@
{
"name": "dotenv-webpack",
"description": "A simple webpack plugin to support dotenv.",
"version": "7.1.1",
"main": "index.js",
"scripts": {
"precommit": "npm run lint",
"prepush": "npm t",
"lint": "standard",
"predoc": "rimraf docs",
"doc": "jsdoc src/index.js -d docs",
"pretest": "npm run build",
"test": "jest",
"prebuild": "rimraf dist",
"build": "babel --copy-files --out-dir dist src",
"travis": "npm run lint && npm t"
},
"repository": {
"type": "git",
"url": "https://github.com/mrsteele/dotenv-webpack.git"
},
"jest": {
"coverageDirectory": "./coverage/",
"collectCoverage": true,
"watchPathIgnorePatterns": [
"output/.*?"
]
},
"keywords": [
"dotenv",
"env",
"safe",
"environment",
"dotenv-safe",
"variables",
"process",
"process.env",
"webpack",
"plugin"
],
"author": "Matt Steele <matt@omnionline.us> (http://omnionline.us/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/mrsteele/dotenv-webpack/issues"
},
"homepage": "https://github.com/mrsteele/dotenv-webpack#readme",
"engines": {
"node": ">=10"
},
"peerDependencies": {
"webpack": "^4 || ^5"
},
"dependencies": {
"dotenv-defaults": "^2.0.2"
},
"devDependencies": {
"@babel/cli": "^7.13.0",
"@babel/core": "^7.13.8",
"@babel/preset-env": "^7.13.9",
"@babel/register": "^7.13.8",
"husky": "^7.0.1",
"jest": "^27.0.4",
"jsdoc": "^3.6.10",
"rimraf": "^3.0.0",
"sinon": "^11.1.1",
"standard": "^16.0.3",
"webpack": "^5.24.3"
},
"files": [
"dist"
],
"browser": "browser.js",
"babel": {
"presets": [
"@babel/preset-env"
]
}
}