@builtwith/sdk 1.3.0 → 1.4.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.
- package/package.json +1 -1
- package/src/index.js +35 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -393,6 +393,41 @@ class BuiltWithClient {
|
|
|
393
393
|
_validate_domain(domain);
|
|
394
394
|
return { mcp_prompt: 'check-domain-trust', arguments: { domain } };
|
|
395
395
|
}
|
|
396
|
+
|
|
397
|
+
// ── Agent Device-Code Authorization (no API key required) ─────────────────
|
|
398
|
+
|
|
399
|
+
static async agent_auth_start() {
|
|
400
|
+
try {
|
|
401
|
+
const res = await _http_post('https://api.builtwith.com/agent-auth/start', {}, {}, 30000);
|
|
402
|
+
if (res.status < 200 || res.status >= 300) {
|
|
403
|
+
return _err(new BuiltWithError('HTTP_ERROR', `HTTP ${res.status}: ${res.body.substring(0, 200)}`, res.status), 'agent-auth-start');
|
|
404
|
+
}
|
|
405
|
+
let data;
|
|
406
|
+
try { data = JSON.parse(res.body); } catch (_) {
|
|
407
|
+
return _err(new BuiltWithError('PARSE_ERROR', 'Failed to parse agent-auth-start response.', res.status), 'agent-auth-start');
|
|
408
|
+
}
|
|
409
|
+
return _ok(data, data, 'agent-auth-start');
|
|
410
|
+
} catch (err) {
|
|
411
|
+
return _err(new BuiltWithError('NETWORK_ERROR', err.message, 0, null, 'Check network connectivity.'), 'agent-auth-start');
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
static async agent_auth_token(device_code) {
|
|
416
|
+
_validate_string('device_code', device_code);
|
|
417
|
+
try {
|
|
418
|
+
const res = await _http_post('https://api.builtwith.com/agent-auth/token', { device_code }, {}, 30000);
|
|
419
|
+
if (res.status < 200 || res.status >= 300) {
|
|
420
|
+
return _err(new BuiltWithError('HTTP_ERROR', `HTTP ${res.status}: ${res.body.substring(0, 200)}`, res.status), 'agent-auth-token');
|
|
421
|
+
}
|
|
422
|
+
let data;
|
|
423
|
+
try { data = JSON.parse(res.body); } catch (_) {
|
|
424
|
+
return _err(new BuiltWithError('PARSE_ERROR', 'Failed to parse agent-auth-token response.', res.status), 'agent-auth-token');
|
|
425
|
+
}
|
|
426
|
+
return _ok(data, data, 'agent-auth-token');
|
|
427
|
+
} catch (err) {
|
|
428
|
+
return _err(new BuiltWithError('NETWORK_ERROR', err.message, 0, null, 'Check network connectivity.'), 'agent-auth-token');
|
|
429
|
+
}
|
|
430
|
+
}
|
|
396
431
|
}
|
|
397
432
|
|
|
398
433
|
module.exports = { BuiltWithClient, BuiltWithError };
|