@h3ravel/core 0.1.0 → 0.2.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/index.cjs CHANGED
@@ -9,9 +9,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
9
9
  var __esm = (fn, res) => function __init() {
10
10
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
11
  };
12
- var __commonJS = (cb, mod) => function __require() {
13
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
- };
15
12
  var __export = (target, all) => {
16
13
  for (var name in all)
17
14
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -716,441 +713,6 @@ var init_Helpers = __esm({
716
713
  }
717
714
  });
718
715
 
719
- // ../../node_modules/.pnpm/dotenv@17.2.1/node_modules/dotenv/package.json
720
- var require_package = __commonJS({
721
- "../../node_modules/.pnpm/dotenv@17.2.1/node_modules/dotenv/package.json"(exports2, module2) {
722
- module2.exports = {
723
- name: "dotenv",
724
- version: "17.2.1",
725
- description: "Loads environment variables from .env file",
726
- main: "lib/main.js",
727
- types: "lib/main.d.ts",
728
- exports: {
729
- ".": {
730
- types: "./lib/main.d.ts",
731
- require: "./lib/main.js",
732
- default: "./lib/main.js"
733
- },
734
- "./config": "./config.js",
735
- "./config.js": "./config.js",
736
- "./lib/env-options": "./lib/env-options.js",
737
- "./lib/env-options.js": "./lib/env-options.js",
738
- "./lib/cli-options": "./lib/cli-options.js",
739
- "./lib/cli-options.js": "./lib/cli-options.js",
740
- "./package.json": "./package.json"
741
- },
742
- scripts: {
743
- "dts-check": "tsc --project tests/types/tsconfig.json",
744
- lint: "standard",
745
- pretest: "npm run lint && npm run dts-check",
746
- test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
747
- "test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
748
- prerelease: "npm test",
749
- release: "standard-version"
750
- },
751
- repository: {
752
- type: "git",
753
- url: "git://github.com/motdotla/dotenv.git"
754
- },
755
- homepage: "https://github.com/motdotla/dotenv#readme",
756
- funding: "https://dotenvx.com",
757
- keywords: [
758
- "dotenv",
759
- "env",
760
- ".env",
761
- "environment",
762
- "variables",
763
- "config",
764
- "settings"
765
- ],
766
- readmeFilename: "README.md",
767
- license: "BSD-2-Clause",
768
- devDependencies: {
769
- "@types/node": "^18.11.3",
770
- decache: "^4.6.2",
771
- sinon: "^14.0.1",
772
- standard: "^17.0.0",
773
- "standard-version": "^9.5.0",
774
- tap: "^19.2.0",
775
- typescript: "^4.8.4"
776
- },
777
- engines: {
778
- node: ">=12"
779
- },
780
- browser: {
781
- fs: false
782
- }
783
- };
784
- }
785
- });
786
-
787
- // ../../node_modules/.pnpm/dotenv@17.2.1/node_modules/dotenv/lib/main.js
788
- var require_main = __commonJS({
789
- "../../node_modules/.pnpm/dotenv@17.2.1/node_modules/dotenv/lib/main.js"(exports2, module2) {
790
- "use strict";
791
- var fs = require("fs");
792
- var path4 = require("path");
793
- var os = require("os");
794
- var crypto = require("crypto");
795
- var packageJson = require_package();
796
- var version = packageJson.version;
797
- var TIPS = [
798
- "\u{1F510} encrypt with Dotenvx: https://dotenvx.com",
799
- "\u{1F510} prevent committing .env to code: https://dotenvx.com/precommit",
800
- "\u{1F510} prevent building .env in docker: https://dotenvx.com/prebuild",
801
- "\u{1F4E1} observe env with Radar: https://dotenvx.com/radar",
802
- "\u{1F4E1} auto-backup env with Radar: https://dotenvx.com/radar",
803
- "\u{1F4E1} version env with Radar: https://dotenvx.com/radar",
804
- "\u{1F6E0}\uFE0F run anywhere with `dotenvx run -- yourcommand`",
805
- "\u2699\uFE0F specify custom .env file path with { path: '/custom/path/.env' }",
806
- "\u2699\uFE0F enable debug logging with { debug: true }",
807
- "\u2699\uFE0F override existing env vars with { override: true }",
808
- "\u2699\uFE0F suppress all logs with { quiet: true }",
809
- "\u2699\uFE0F write to custom object with { processEnv: myObject }",
810
- "\u2699\uFE0F load multiple .env files with { path: ['.env.local', '.env'] }"
811
- ];
812
- function _getRandomTip() {
813
- return TIPS[Math.floor(Math.random() * TIPS.length)];
814
- }
815
- __name(_getRandomTip, "_getRandomTip");
816
- function parseBoolean(value) {
817
- if (typeof value === "string") {
818
- return ![
819
- "false",
820
- "0",
821
- "no",
822
- "off",
823
- ""
824
- ].includes(value.toLowerCase());
825
- }
826
- return Boolean(value);
827
- }
828
- __name(parseBoolean, "parseBoolean");
829
- function supportsAnsi() {
830
- return process.stdout.isTTY;
831
- }
832
- __name(supportsAnsi, "supportsAnsi");
833
- function dim(text) {
834
- return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
835
- }
836
- __name(dim, "dim");
837
- var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
838
- function parse(src) {
839
- const obj = {};
840
- let lines = src.toString();
841
- lines = lines.replace(/\r\n?/mg, "\n");
842
- let match;
843
- while ((match = LINE.exec(lines)) != null) {
844
- const key = match[1];
845
- let value = match[2] || "";
846
- value = value.trim();
847
- const maybeQuote = value[0];
848
- value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
849
- if (maybeQuote === '"') {
850
- value = value.replace(/\\n/g, "\n");
851
- value = value.replace(/\\r/g, "\r");
852
- }
853
- obj[key] = value;
854
- }
855
- return obj;
856
- }
857
- __name(parse, "parse");
858
- function _parseVault(options) {
859
- options = options || {};
860
- const vaultPath = _vaultPath(options);
861
- options.path = vaultPath;
862
- const result = DotenvModule.configDotenv(options);
863
- if (!result.parsed) {
864
- const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
865
- err.code = "MISSING_DATA";
866
- throw err;
867
- }
868
- const keys = _dotenvKey(options).split(",");
869
- const length = keys.length;
870
- let decrypted;
871
- for (let i = 0; i < length; i++) {
872
- try {
873
- const key = keys[i].trim();
874
- const attrs = _instructions(result, key);
875
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
876
- break;
877
- } catch (error) {
878
- if (i + 1 >= length) {
879
- throw error;
880
- }
881
- }
882
- }
883
- return DotenvModule.parse(decrypted);
884
- }
885
- __name(_parseVault, "_parseVault");
886
- function _warn(message) {
887
- console.error(`[dotenv@${version}][WARN] ${message}`);
888
- }
889
- __name(_warn, "_warn");
890
- function _debug(message) {
891
- console.log(`[dotenv@${version}][DEBUG] ${message}`);
892
- }
893
- __name(_debug, "_debug");
894
- function _log(message) {
895
- console.log(`[dotenv@${version}] ${message}`);
896
- }
897
- __name(_log, "_log");
898
- function _dotenvKey(options) {
899
- if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
900
- return options.DOTENV_KEY;
901
- }
902
- if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
903
- return process.env.DOTENV_KEY;
904
- }
905
- return "";
906
- }
907
- __name(_dotenvKey, "_dotenvKey");
908
- function _instructions(result, dotenvKey) {
909
- let uri;
910
- try {
911
- uri = new URL(dotenvKey);
912
- } catch (error) {
913
- if (error.code === "ERR_INVALID_URL") {
914
- const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
915
- err.code = "INVALID_DOTENV_KEY";
916
- throw err;
917
- }
918
- throw error;
919
- }
920
- const key = uri.password;
921
- if (!key) {
922
- const err = new Error("INVALID_DOTENV_KEY: Missing key part");
923
- err.code = "INVALID_DOTENV_KEY";
924
- throw err;
925
- }
926
- const environment = uri.searchParams.get("environment");
927
- if (!environment) {
928
- const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
929
- err.code = "INVALID_DOTENV_KEY";
930
- throw err;
931
- }
932
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
933
- const ciphertext = result.parsed[environmentKey];
934
- if (!ciphertext) {
935
- const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
936
- err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
937
- throw err;
938
- }
939
- return {
940
- ciphertext,
941
- key
942
- };
943
- }
944
- __name(_instructions, "_instructions");
945
- function _vaultPath(options) {
946
- let possibleVaultPath = null;
947
- if (options && options.path && options.path.length > 0) {
948
- if (Array.isArray(options.path)) {
949
- for (const filepath of options.path) {
950
- if (fs.existsSync(filepath)) {
951
- possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
952
- }
953
- }
954
- } else {
955
- possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
956
- }
957
- } else {
958
- possibleVaultPath = path4.resolve(process.cwd(), ".env.vault");
959
- }
960
- if (fs.existsSync(possibleVaultPath)) {
961
- return possibleVaultPath;
962
- }
963
- return null;
964
- }
965
- __name(_vaultPath, "_vaultPath");
966
- function _resolveHome(envPath) {
967
- return envPath[0] === "~" ? path4.join(os.homedir(), envPath.slice(1)) : envPath;
968
- }
969
- __name(_resolveHome, "_resolveHome");
970
- function _configVault(options) {
971
- const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
972
- const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
973
- if (debug || !quiet) {
974
- _log("Loading env from encrypted .env.vault");
975
- }
976
- const parsed = DotenvModule._parseVault(options);
977
- let processEnv = process.env;
978
- if (options && options.processEnv != null) {
979
- processEnv = options.processEnv;
980
- }
981
- DotenvModule.populate(processEnv, parsed, options);
982
- return {
983
- parsed
984
- };
985
- }
986
- __name(_configVault, "_configVault");
987
- function configDotenv(options) {
988
- const dotenvPath = path4.resolve(process.cwd(), ".env");
989
- let encoding = "utf8";
990
- let processEnv = process.env;
991
- if (options && options.processEnv != null) {
992
- processEnv = options.processEnv;
993
- }
994
- let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
995
- let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
996
- if (options && options.encoding) {
997
- encoding = options.encoding;
998
- } else {
999
- if (debug) {
1000
- _debug("No encoding is specified. UTF-8 is used by default");
1001
- }
1002
- }
1003
- let optionPaths = [
1004
- dotenvPath
1005
- ];
1006
- if (options && options.path) {
1007
- if (!Array.isArray(options.path)) {
1008
- optionPaths = [
1009
- _resolveHome(options.path)
1010
- ];
1011
- } else {
1012
- optionPaths = [];
1013
- for (const filepath of options.path) {
1014
- optionPaths.push(_resolveHome(filepath));
1015
- }
1016
- }
1017
- }
1018
- let lastError;
1019
- const parsedAll = {};
1020
- for (const path5 of optionPaths) {
1021
- try {
1022
- const parsed = DotenvModule.parse(fs.readFileSync(path5, {
1023
- encoding
1024
- }));
1025
- DotenvModule.populate(parsedAll, parsed, options);
1026
- } catch (e) {
1027
- if (debug) {
1028
- _debug(`Failed to load ${path5} ${e.message}`);
1029
- }
1030
- lastError = e;
1031
- }
1032
- }
1033
- const populated = DotenvModule.populate(processEnv, parsedAll, options);
1034
- debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
1035
- quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
1036
- if (debug || !quiet) {
1037
- const keysCount = Object.keys(populated).length;
1038
- const shortPaths = [];
1039
- for (const filePath of optionPaths) {
1040
- try {
1041
- const relative = path4.relative(process.cwd(), filePath);
1042
- shortPaths.push(relative);
1043
- } catch (e) {
1044
- if (debug) {
1045
- _debug(`Failed to load ${filePath} ${e.message}`);
1046
- }
1047
- lastError = e;
1048
- }
1049
- }
1050
- _log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
1051
- }
1052
- if (lastError) {
1053
- return {
1054
- parsed: parsedAll,
1055
- error: lastError
1056
- };
1057
- } else {
1058
- return {
1059
- parsed: parsedAll
1060
- };
1061
- }
1062
- }
1063
- __name(configDotenv, "configDotenv");
1064
- function config(options) {
1065
- if (_dotenvKey(options).length === 0) {
1066
- return DotenvModule.configDotenv(options);
1067
- }
1068
- const vaultPath = _vaultPath(options);
1069
- if (!vaultPath) {
1070
- _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
1071
- return DotenvModule.configDotenv(options);
1072
- }
1073
- return DotenvModule._configVault(options);
1074
- }
1075
- __name(config, "config");
1076
- function decrypt(encrypted, keyStr) {
1077
- const key = Buffer.from(keyStr.slice(-64), "hex");
1078
- let ciphertext = Buffer.from(encrypted, "base64");
1079
- const nonce = ciphertext.subarray(0, 12);
1080
- const authTag = ciphertext.subarray(-16);
1081
- ciphertext = ciphertext.subarray(12, -16);
1082
- try {
1083
- const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
1084
- aesgcm.setAuthTag(authTag);
1085
- return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
1086
- } catch (error) {
1087
- const isRange = error instanceof RangeError;
1088
- const invalidKeyLength = error.message === "Invalid key length";
1089
- const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
1090
- if (isRange || invalidKeyLength) {
1091
- const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
1092
- err.code = "INVALID_DOTENV_KEY";
1093
- throw err;
1094
- } else if (decryptionFailed) {
1095
- const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
1096
- err.code = "DECRYPTION_FAILED";
1097
- throw err;
1098
- } else {
1099
- throw error;
1100
- }
1101
- }
1102
- }
1103
- __name(decrypt, "decrypt");
1104
- function populate(processEnv, parsed, options = {}) {
1105
- const debug = Boolean(options && options.debug);
1106
- const override = Boolean(options && options.override);
1107
- const populated = {};
1108
- if (typeof parsed !== "object") {
1109
- const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
1110
- err.code = "OBJECT_REQUIRED";
1111
- throw err;
1112
- }
1113
- for (const key of Object.keys(parsed)) {
1114
- if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
1115
- if (override === true) {
1116
- processEnv[key] = parsed[key];
1117
- populated[key] = parsed[key];
1118
- }
1119
- if (debug) {
1120
- if (override === true) {
1121
- _debug(`"${key}" is already defined and WAS overwritten`);
1122
- } else {
1123
- _debug(`"${key}" is already defined and was NOT overwritten`);
1124
- }
1125
- }
1126
- } else {
1127
- processEnv[key] = parsed[key];
1128
- populated[key] = parsed[key];
1129
- }
1130
- }
1131
- return populated;
1132
- }
1133
- __name(populate, "populate");
1134
- var DotenvModule = {
1135
- configDotenv,
1136
- _configVault,
1137
- _parseVault,
1138
- config,
1139
- decrypt,
1140
- parse,
1141
- populate
1142
- };
1143
- module2.exports.configDotenv = DotenvModule.configDotenv;
1144
- module2.exports._configVault = DotenvModule._configVault;
1145
- module2.exports._parseVault = DotenvModule._parseVault;
1146
- module2.exports.config = DotenvModule.config;
1147
- module2.exports.decrypt = DotenvModule.decrypt;
1148
- module2.exports.parse = DotenvModule.parse;
1149
- module2.exports.populate = DotenvModule.populate;
1150
- module2.exports = DotenvModule;
1151
- }
1152
- });
1153
-
1154
716
  // ../config/src/Providers/ConfigServiceProvider.ts
1155
717
  var import_dotenv, ConfigServiceProvider;
1156
718
  var init_ConfigServiceProvider = __esm({
@@ -1158,7 +720,7 @@ var init_ConfigServiceProvider = __esm({
1158
720
  "use strict";
1159
721
  init_index();
1160
722
  init_src3();
1161
- import_dotenv = __toESM(require_main(), 1);
723
+ import_dotenv = require("dotenv");
1162
724
  ConfigServiceProvider = class extends ServiceProvider {
1163
725
  static {
1164
726
  __name(this, "ConfigServiceProvider");