builtwith-official-cli 1.5.0 → 1.5.1
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 +15 -0
- package/lib/client.js +2 -2
- package/lib/commands/auth.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -181,6 +181,19 @@ bw vector search "react framework"
|
|
|
181
181
|
bw vector search "ecommerce platform" --limit 20
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
+
### 🔐 Auth
|
|
185
|
+
|
|
186
|
+
Obtain a temporary `bw-` prefixed API token via browser approval — no API key needed to run this command.
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
bw auth login
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Flow:
|
|
193
|
+
1. Prints a `builtwith.com` URL — open it in your browser and click **Approve**
|
|
194
|
+
2. Polls automatically every 5 seconds
|
|
195
|
+
3. Prints the `access_token` (`bw-...`) on approval — use it as `BW_API_KEY`
|
|
196
|
+
|
|
184
197
|
### 💳 Payment
|
|
185
198
|
|
|
186
199
|
Manage API credits autonomously.
|
|
@@ -391,6 +404,8 @@ If your API key isn't in an env var or `.builtwithrc`, pass it inline:
|
|
|
391
404
|
| `payment_purchase` | 🛒 Purchase API credits (minimum 2000) |
|
|
392
405
|
| `account_whoami` | 👤 Authenticated account identity |
|
|
393
406
|
| `account_usage` | 📊 API usage statistics |
|
|
407
|
+
| `agent-auth-start` | 🔐 Start Device-Code Authorization (no API key required) |
|
|
408
|
+
| `agent-auth-token` | 🔐 Poll for authorization result and access token (no API key required) |
|
|
394
409
|
|
|
395
410
|
### 🔬 Implementation note
|
|
396
411
|
|
package/lib/client.js
CHANGED
|
@@ -43,8 +43,8 @@ const BASE_URLS = {
|
|
|
43
43
|
'payment-balance': 'https://payments.builtwith.com/v1/billing/api-discovery',
|
|
44
44
|
'payment-config': 'https://payments.builtwith.com/v1/billing/api-configuration',
|
|
45
45
|
'payment-purchase': 'https://payments.builtwith.com/v1/billing/api-purchase',
|
|
46
|
-
'agent-auth-start': 'https://api.builtwith.com/agent-auth
|
|
47
|
-
'agent-auth-token': 'https://api.builtwith.com/agent-auth
|
|
46
|
+
'agent-auth-start': 'https://api.builtwith.com/agent-auth-start',
|
|
47
|
+
'agent-auth-token': 'https://api.builtwith.com/agent-auth-token',
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
/**
|
package/lib/commands/auth.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const fetch = require('node-fetch');
|
|
4
4
|
const output = require('../output');
|
|
5
5
|
|
|
6
|
-
const AUTH_START_URL = 'https://api.builtwith.com/agent-auth
|
|
7
|
-
const AUTH_TOKEN_URL = 'https://api.builtwith.com/agent-auth
|
|
6
|
+
const AUTH_START_URL = 'https://api.builtwith.com/agent-auth-start';
|
|
7
|
+
const AUTH_TOKEN_URL = 'https://api.builtwith.com/agent-auth-token';
|
|
8
8
|
const POLL_INTERVAL_MS = 5000;
|
|
9
9
|
const TIMEOUT_MS = 5 * 60 * 1000;
|
|
10
10
|
|
|
@@ -60,18 +60,18 @@ module.exports = function registerAuth(program) {
|
|
|
60
60
|
process.exit(1);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
if (tokenRes.
|
|
63
|
+
if (tokenRes.access_token) {
|
|
64
64
|
process.stderr.write('\n\n');
|
|
65
65
|
output.print({ access_token: tokenRes.access_token, message: 'Authorization approved. Use this token as your BW_API_KEY.' }, { format: opts.format });
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
if (tokenRes.
|
|
69
|
+
if (tokenRes.error === 'access_denied') {
|
|
70
70
|
process.stderr.write('\n');
|
|
71
71
|
output.error('Authorization was denied by the user.');
|
|
72
72
|
process.exit(1);
|
|
73
73
|
}
|
|
74
|
-
//
|
|
74
|
+
// error === 'authorization_pending' — keep polling
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
process.stderr.write('\n');
|