latinfo 0.5.9 → 0.6.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.
Files changed (2) hide show
  1. package/dist/index.js +18 -3
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ const path_1 = __importDefault(require("path"));
10
10
  const os_1 = __importDefault(require("os"));
11
11
  const child_process_1 = require("child_process");
12
12
  const demo_data_1 = require("./demo-data");
13
- const VERSION = '0.5.8';
13
+ const VERSION = '0.6.0';
14
14
  const API_URL = process.env.LATINFO_API_URL || 'https://api.latinfo.dev';
15
15
  const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID || 'Ov23li5fcQaiCsVtaMKK';
16
16
  const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.latinfo');
@@ -45,8 +45,13 @@ function deleteConfig() {
45
45
  }
46
46
  // --- GitHub Authorization Code Flow ---
47
47
  function openBrowser(url) {
48
- const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
49
- (0, child_process_1.exec)(`${cmd} "${url}"`);
48
+ if (process.platform === 'win32') {
49
+ (0, child_process_1.exec)(`start "" "${url}"`);
50
+ }
51
+ else {
52
+ const cmd = process.platform === 'darwin' ? 'open' : 'xdg-open';
53
+ (0, child_process_1.exec)(`${cmd} "${url}"`);
54
+ }
50
55
  }
51
56
  async function waitForCallback(port, expectedState) {
52
57
  return new Promise((resolve, reject) => {
@@ -67,6 +72,14 @@ async function waitForCallback(port, expectedState) {
67
72
  reject(new Error('Invalid state or missing code'));
68
73
  }
69
74
  });
75
+ server.on('error', (err) => {
76
+ if (err.code === 'EADDRINUSE' || err.code === 'EACCES') {
77
+ reject(new Error(`Cannot listen on port ${port}. ${err.code === 'EADDRINUSE' ? 'Port already in use.' : 'Permission denied.'} Try: latinfo login --token <github_pat>`));
78
+ }
79
+ else {
80
+ reject(err);
81
+ }
82
+ });
70
83
  server.listen(port, () => { });
71
84
  setTimeout(() => { server.close(); reject(new Error('Timeout waiting for authorization')); }, 120_000);
72
85
  });
@@ -130,6 +143,8 @@ async function login(token) {
130
143
  const state = crypto.randomUUID();
131
144
  const authUrl = `https://github.com/login/oauth/authorize?client_id=${GITHUB_CLIENT_ID}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${scope}&state=${state}`;
132
145
  console.log('Opening GitHub...');
146
+ console.log('If your browser does not open, visit this URL:\n');
147
+ console.log(authUrl + '\n');
133
148
  openBrowser(authUrl);
134
149
  const code = await waitForCallback(port, state);
135
150
  const authRes = await fetch(`${API_URL}/auth/github`, {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "latinfo",
3
- "version": "0.5.9",
3
+ "version": "0.6.0",
4
4
  "description": "Tax registry API for Latin America. Query RUC, DNI, and company data from SUNAT Peru. 18M+ records, updated daily, sub-100ms from anywhere.",
5
5
  "homepage": "https://latinfo.dev",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/latinfo/latinfo"
8
+ "url": "git+https://github.com/latinfo/latinfo.git"
9
9
  },
10
10
  "keywords": [
11
11
  "sunat",