latinfo 0.5.7 → 0.5.8

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/README.md CHANGED
@@ -1,6 +1,10 @@
1
- # latinfo
1
+ <p align="center">
2
+ <img src="https://latinfo.dev/logo.svg" alt="latinfo" width="120">
3
+ </p>
2
4
 
3
- Tax registry API for Latin America. Query RUC, DNI, and company data from Peru's SUNAT. 18M+ records, updated daily, sub-100ms from anywhere.
5
+ <h1 align="center">latinfo</h1>
6
+
7
+ <p align="center">Tax registry API for Latin America. Query RUC, DNI, and company data from Peru's SUNAT. 18M+ records, updated daily, sub-100ms from anywhere.</p>
4
8
 
5
9
  ## Install
6
10
 
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.7';
13
+ const VERSION = '0.5.8';
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');
@@ -18,7 +18,9 @@ const CONFIG_FILE = path_1.default.join(CONFIG_DIR, 'config.json');
18
18
  // --- JSON mode ---
19
19
  const jsonFlag = process.argv.includes('--json');
20
20
  const liveFlag = process.argv.includes('--live');
21
- const rawArgs = process.argv.slice(2).filter(a => a !== '--json' && a !== '--live');
21
+ const tokenIdx = process.argv.indexOf('--token');
22
+ const tokenFlag = tokenIdx !== -1 ? process.argv[tokenIdx + 1] : undefined;
23
+ const rawArgs = process.argv.slice(2).filter(a => a !== '--json' && a !== '--live' && a !== '--token' && a !== tokenFlag);
22
24
  function jsonError(error, message) {
23
25
  process.stderr.write(JSON.stringify({ error, message }) + '\n');
24
26
  process.exit(1);
@@ -101,7 +103,27 @@ async function apiRequest(config, path) {
101
103
  return res;
102
104
  }
103
105
  // --- Commands ---
104
- async function login() {
106
+ async function login(token) {
107
+ // PAT login: no browser needed
108
+ if (token) {
109
+ const authRes = await fetch(`${API_URL}/auth/github`, {
110
+ method: 'POST',
111
+ headers: { 'Content-Type': 'application/json' },
112
+ body: JSON.stringify({ access_token: token }),
113
+ });
114
+ if (!authRes.ok) {
115
+ const text = await authRes.text();
116
+ if (jsonFlag)
117
+ jsonError('auth_failed', text);
118
+ console.error('Error getting API key:', text);
119
+ process.exit(1);
120
+ }
121
+ const authData = await authRes.json();
122
+ saveConfig({ api_key: authData.api_key, github_username: authData.github_username });
123
+ console.log(`Logged in as ${authData.github_username}`);
124
+ return;
125
+ }
126
+ // OAuth login: opens browser
105
127
  const port = 8400;
106
128
  const redirectUri = `http://localhost:${port}/callback`;
107
129
  const scope = 'read:user,user:email';
@@ -361,8 +383,11 @@ QUICK START
361
383
 
362
384
  COMMANDS
363
385
  login
364
- GitHub OAuth. Opens browser, waits for callback on localhost:8400,
365
- stores API key in ~/.latinfo/config.json.
386
+ GitHub OAuth. Opens browser, stores API key in ~/.latinfo/config.json.
387
+
388
+ login --token <github_pat>
389
+ Login with a GitHub Personal Access Token. No browser needed.
390
+ Create a PAT at github.com/settings/tokens (scope: read:user).
366
391
 
367
392
  logout
368
393
  Remove stored credentials.
@@ -435,7 +460,7 @@ if (rawArgs.includes('--version') || rawArgs.includes('-v')) {
435
460
  else {
436
461
  switch (command) {
437
462
  case 'login':
438
- login().catch(e => { console.error(e); process.exit(1); });
463
+ login(tokenFlag).catch(e => { console.error(e); process.exit(1); });
439
464
  break;
440
465
  case 'logout':
441
466
  logout();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latinfo",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
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": {