@ibearua/bitmask-core-dev 1.0.0-beta.16 → 1.0.0-beta.17

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.
Files changed (2) hide show
  1. package/constants.js +23 -14
  2. package/package.json +1 -1
package/constants.js CHANGED
@@ -37,6 +37,15 @@ var _a;
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.init = exports.BITMASK = exports.CARBONADO = exports.LNDHUBX = exports.DISABLE_LN = exports.Network = exports.setEnv = exports.getEnv = exports.switchNetwork = exports.getNetwork = void 0;
39
39
  const bitmask_core_1 = __importStar(require("./bitmask_core")), BMC = bitmask_core_1;
40
+
41
+ // Browser-compatible environment variable helper
42
+ const getEnvVar = (key) => {
43
+ try {
44
+ return typeof process !== 'undefined' && process.env ? process.env[key] : undefined;
45
+ } catch {
46
+ return undefined;
47
+ }
48
+ };
40
49
  const getNetwork = () => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.get_network()); });
41
50
  exports.getNetwork = getNetwork;
42
51
  const switchNetwork = (network) => __awaiter(void 0, void 0, void 0, function* () { return BMC.switch_network(network.toString()); });
@@ -52,7 +61,7 @@ var Network;
52
61
  Network["signet"] = "signet";
53
62
  Network["regtest"] = "regtest";
54
63
  })(Network || (exports.Network = Network = {}));
55
- exports.DISABLE_LN = ((_a = process.env) === null || _a === void 0 ? void 0 : _a.DISABLE_LN) === "true" ? true : false || "";
64
+ exports.DISABLE_LN = getEnvVar('DISABLE_LN') === "true" ? true : false || "";
56
65
  exports.LNDHUBX = false;
57
66
  exports.CARBONADO = false;
58
67
  exports.BITMASK = false;
@@ -63,23 +72,23 @@ const init = (networkOverride) => __awaiter(void 0, void 0, void 0, function* ()
63
72
  }
64
73
  yield (0, bitmask_core_1.default)();
65
74
  const network = yield (0, exports.getNetwork)();
66
- if (network === "bitcoin" && process.env.PROD_LNDHUB_ENDPOINT) {
67
- yield (0, exports.setEnv)("LNDHUB_ENDPOINT", process.env.PROD_LNDHUB_ENDPOINT);
75
+ if (network === "bitcoin" && getEnvVar('PROD_LNDHUB_ENDPOINT')) {
76
+ yield (0, exports.setEnv)("LNDHUB_ENDPOINT", getEnvVar('PROD_LNDHUB_ENDPOINT'));
68
77
  }
69
- else if (process.env.TEST_LNDHUB_ENDPOINT) {
70
- yield (0, exports.setEnv)("LNDHUB_ENDPOINT", process.env.TEST_LNDHUB_ENDPOINT);
78
+ else if (getEnvVar('TEST_LNDHUB_ENDPOINT')) {
79
+ yield (0, exports.setEnv)("LNDHUB_ENDPOINT", getEnvVar('TEST_LNDHUB_ENDPOINT'));
71
80
  }
72
- if (process.env.CARBONADO_ENDPOINT) {
73
- yield (0, exports.setEnv)("CARBONADO_ENDPOINT", process.env.CARBONADO_ENDPOINT);
81
+ if (getEnvVar('CARBONADO_ENDPOINT')) {
82
+ yield (0, exports.setEnv)("CARBONADO_ENDPOINT", getEnvVar('CARBONADO_ENDPOINT'));
74
83
  }
75
- if (process.env.BITMASK_ENDPOINT) {
76
- yield (0, exports.setEnv)("BITMASK_ENDPOINT", process.env.BITMASK_ENDPOINT);
84
+ if (getEnvVar('BITMASK_ENDPOINT')) {
85
+ yield (0, exports.setEnv)("BITMASK_ENDPOINT", getEnvVar('BITMASK_ENDPOINT'));
77
86
  }
78
- if (process.env.BITCOIN_EXPLORER_API_MAINNET) {
79
- yield (0, exports.setEnv)("BITCOIN_EXPLORER_API_MAINNET", process.env.BITCOIN_EXPLORER_API_MAINNET);
87
+ if (getEnvVar('BITCOIN_EXPLORER_API_MAINNET')) {
88
+ yield (0, exports.setEnv)("BITCOIN_EXPLORER_API_MAINNET", getEnvVar('BITCOIN_EXPLORER_API_MAINNET'));
80
89
  }
81
- if (process.env.BITCOIN_EXPLORER_API_TESTNET) {
82
- yield (0, exports.setEnv)("BITCOIN_EXPLORER_API_TESTNET", process.env.BITCOIN_EXPLORER_API_TESTNET);
90
+ if (getEnvVar('BITCOIN_EXPLORER_API_TESTNET')) {
91
+ yield (0, exports.setEnv)("BITCOIN_EXPLORER_API_TESTNET", getEnvVar('BITCOIN_EXPLORER_API_TESTNET'));
83
92
  }
84
93
  }
85
94
  catch (err) {
@@ -123,7 +132,7 @@ const init = (networkOverride) => __awaiter(void 0, void 0, void 0, function* ()
123
132
  console.debug("Using bitmaskd endpoint:", bitmask);
124
133
  });
125
134
  exports.init = init;
126
- const networkOverride = process.env.NETWORK_OVERRIDE;
135
+ const networkOverride = getEnvVar('NETWORK_OVERRIDE');
127
136
  if (networkOverride) {
128
137
  const network = Network[networkOverride.toLowerCase()];
129
138
  (0, exports.init)(network);
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "Stanley Arua <stanarua@aol.com>"
11
11
  ],
12
12
  "description": "Core functionality for the BitMask wallet",
13
- "version": "1.0.0-beta.16",
13
+ "version": "1.0.0-beta.17",
14
14
  "license": "MIT/Apache-2.0",
15
15
  "repository": {
16
16
  "type": "git",