scrapfly-sdk 0.10.6 → 0.11.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/esm/browserconfig.d.ts +54 -0
- package/esm/browserconfig.d.ts.map +1 -1
- package/esm/browserconfig.js +106 -0
- package/esm/client.d.ts +110 -7
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +339 -26
- package/esm/crawlerconfig.d.ts +6 -2
- package/esm/crawlerconfig.d.ts.map +1 -1
- package/esm/crawlerconfig.js +33 -4
- package/esm/extractionconfig.js +1 -1
- package/esm/main.d.ts +1 -0
- package/esm/main.d.ts.map +1 -1
- package/esm/scrapeconfig.d.ts +1 -0
- package/esm/scrapeconfig.d.ts.map +1 -1
- package/esm/scrapeconfig.js +9 -5
- package/esm/types.d.ts +94 -0
- package/esm/types.d.ts.map +1 -1
- package/esm/utils.d.ts +1 -1
- package/esm/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/browserconfig.d.ts +54 -0
- package/script/browserconfig.d.ts.map +1 -1
- package/script/browserconfig.js +106 -0
- package/script/client.d.ts +110 -7
- package/script/client.d.ts.map +1 -1
- package/script/client.js +339 -26
- package/script/crawlerconfig.d.ts +6 -2
- package/script/crawlerconfig.d.ts.map +1 -1
- package/script/crawlerconfig.js +33 -4
- package/script/extractionconfig.js +1 -1
- package/script/main.d.ts +1 -0
- package/script/main.d.ts.map +1 -1
- package/script/scrapeconfig.d.ts +1 -0
- package/script/scrapeconfig.d.ts.map +1 -1
- package/script/scrapeconfig.js +9 -5
- package/script/types.d.ts +94 -0
- package/script/types.d.ts.map +1 -1
- package/script/utils.d.ts +1 -1
- package/script/utils.d.ts.map +1 -1
- package/src/browserconfig.ts +87 -0
- package/src/client.ts +409 -28
- package/src/crawlerconfig.ts +27 -6
- package/src/extractionconfig.ts +1 -1
- package/src/main.ts +1 -0
- package/src/scrapeconfig.ts +4 -5
- package/src/types.ts +115 -0
- package/src/utils.ts +6 -1
package/esm/client.js
CHANGED
|
@@ -876,17 +876,53 @@ export class ScrapflyClient {
|
|
|
876
876
|
try {
|
|
877
877
|
const url = new URL(this.HOST + '/crawl');
|
|
878
878
|
url.search = new URLSearchParams({ key: this.key }).toString();
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
879
|
+
// POST /crawl accepts two body formats:
|
|
880
|
+
// - application/json: the entire crawler configuration as JSON.
|
|
881
|
+
// Used for seed-URL crawls and remote_url_list crawls.
|
|
882
|
+
// - multipart/form-data: a 'config' JSON part and a 'urls' text
|
|
883
|
+
// part (one URL per line). Used only when the caller provides
|
|
884
|
+
// an in-memory url_list, so the URLs can be uploaded as a
|
|
885
|
+
// streamed file payload instead of inlined into the JSON body.
|
|
886
|
+
const params = config.toApiParams();
|
|
887
|
+
const urlList = Array.isArray(params.url_list) && params.url_list.length > 0
|
|
888
|
+
? params.url_list
|
|
889
|
+
: undefined;
|
|
890
|
+
if (urlList !== undefined) {
|
|
891
|
+
// Strip url_list from the JSON config — the URLs go through the
|
|
892
|
+
// 'urls' multipart part instead, which the API gateway streams
|
|
893
|
+
// straight through to the scrape engine.
|
|
894
|
+
delete params.url_list;
|
|
895
|
+
const form = new FormData();
|
|
896
|
+
const configBlob = new Blob([JSON.stringify(params)], { type: 'application/json' });
|
|
897
|
+
form.append('config', configBlob, 'config.json');
|
|
898
|
+
const urlsBlob = new Blob([urlList.join('\n')], { type: 'text/plain' });
|
|
899
|
+
form.append('urls', urlsBlob, 'urls.txt');
|
|
900
|
+
response = await this.fetch({
|
|
901
|
+
url: url.toString(),
|
|
902
|
+
method: 'POST',
|
|
903
|
+
headers: {
|
|
904
|
+
'user-agent': this.ua,
|
|
905
|
+
// Intentionally omit content-type — fetch fills in the
|
|
906
|
+
// multipart boundary itself when given a FormData body.
|
|
907
|
+
'accept-encoding': 'gzip, deflate, br',
|
|
908
|
+
accept: 'application/json',
|
|
909
|
+
},
|
|
910
|
+
body: form,
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
else {
|
|
914
|
+
response = await this.fetch({
|
|
915
|
+
url: url.toString(),
|
|
916
|
+
method: 'POST',
|
|
917
|
+
headers: {
|
|
918
|
+
'user-agent': this.ua,
|
|
919
|
+
'content-type': 'application/json',
|
|
920
|
+
'accept-encoding': 'gzip, deflate, br',
|
|
921
|
+
accept: 'application/json',
|
|
922
|
+
},
|
|
923
|
+
body: JSON.stringify(params),
|
|
924
|
+
});
|
|
925
|
+
}
|
|
890
926
|
}
|
|
891
927
|
catch (e) {
|
|
892
928
|
log.error('error', e);
|
|
@@ -1224,40 +1260,49 @@ export class ScrapflyClient {
|
|
|
1224
1260
|
// --- Cloud Browser ---
|
|
1225
1261
|
/**
|
|
1226
1262
|
* Get the WebSocket URL for a Cloud Browser session.
|
|
1263
|
+
*
|
|
1264
|
+
* On rejection the server sends a JSON error frame then a close frame
|
|
1265
|
+
* with code 1008/1011/1013 and a "ERR::BROWSER::CODE: reason" string.
|
|
1266
|
+
* See https://scrapfly.io/docs/cloud-browser-api/errors#websocket-close-frame
|
|
1227
1267
|
*/
|
|
1228
1268
|
cloudBrowser(config) {
|
|
1229
1269
|
const browserConfig = config || new BrowserConfig();
|
|
1230
1270
|
return browserConfig.websocketUrl(this.key, this.cloudBrowserHost);
|
|
1231
1271
|
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Return the deterministic project salt for this client's api_key. Matches
|
|
1274
|
+
* the `X-Browser-Project-Salt` response header returned on a successful
|
|
1275
|
+
* Cloud Browser WebSocket upgrade.
|
|
1276
|
+
*/
|
|
1277
|
+
async cloudBrowserProjectSalt() {
|
|
1278
|
+
return BrowserConfig.projectSalt(this.key);
|
|
1279
|
+
}
|
|
1232
1280
|
/**
|
|
1233
1281
|
* Call the Cloud Browser Unblock API.
|
|
1282
|
+
*
|
|
1283
|
+
* Unblock always uses a residential proxy (no proxy pool selection) and
|
|
1284
|
+
* always performs a GET — the endpoint's purpose is to harvest cookies /
|
|
1285
|
+
* clearance tokens via an ASP-bypass navigation, not to proxy arbitrary
|
|
1286
|
+
* HTTP requests.
|
|
1234
1287
|
*/
|
|
1235
1288
|
async cloudBrowserUnblock(options) {
|
|
1236
|
-
const proxyPoolMap = {
|
|
1237
|
-
datacenter: 'public_datacenter_pool',
|
|
1238
|
-
residential: 'public_residential_pool',
|
|
1239
|
-
};
|
|
1240
1289
|
const jsonBody = { url: options.url };
|
|
1241
|
-
if (options.proxy_pool)
|
|
1242
|
-
jsonBody.proxy_pool = proxyPoolMap[options.proxy_pool] || options.proxy_pool;
|
|
1243
1290
|
if (options.country)
|
|
1244
1291
|
jsonBody.country = options.country;
|
|
1245
1292
|
if (options.os)
|
|
1246
1293
|
jsonBody.os = options.os;
|
|
1294
|
+
if (options.browser_brand)
|
|
1295
|
+
jsonBody.browser_brand = options.browser_brand;
|
|
1296
|
+
if (options.session)
|
|
1297
|
+
jsonBody.session = options.session;
|
|
1247
1298
|
if (options.timeout)
|
|
1248
1299
|
jsonBody.timeout = options.timeout;
|
|
1249
1300
|
if (options.browser_timeout)
|
|
1250
1301
|
jsonBody.browser_timeout = options.browser_timeout;
|
|
1251
|
-
if (options.headers)
|
|
1252
|
-
jsonBody.headers = options.headers;
|
|
1253
|
-
if (options.body)
|
|
1254
|
-
jsonBody.body = options.body;
|
|
1255
|
-
if (options.method)
|
|
1256
|
-
jsonBody.method = options.method;
|
|
1257
1302
|
if (options.enable_mcp !== undefined)
|
|
1258
1303
|
jsonBody.enable_mcp = options.enable_mcp;
|
|
1259
|
-
if (options.
|
|
1260
|
-
jsonBody.
|
|
1304
|
+
if (options.debug !== undefined)
|
|
1305
|
+
jsonBody.debug = options.debug;
|
|
1261
1306
|
const url = new URL(this.cloudBrowserApiHost + '/unblock');
|
|
1262
1307
|
url.searchParams.set('key', this.key);
|
|
1263
1308
|
const response = await this.fetch({
|
|
@@ -1389,6 +1434,251 @@ export class ScrapflyClient {
|
|
|
1389
1434
|
}
|
|
1390
1435
|
return await response.json();
|
|
1391
1436
|
}
|
|
1437
|
+
// ----- Cloud Browser Credential Vault -------------------------------------
|
|
1438
|
+
// Server contract documented at apps/scrapfly/api/scrapfly-api/pkg/vault/.
|
|
1439
|
+
//
|
|
1440
|
+
// SECURITY: the vault key is the customer-held secret that decrypts every
|
|
1441
|
+
// item in the vault. The server emits it ONCE on POST /vault and POST
|
|
1442
|
+
// /vault/{id}/rotate; never log it, never include it in error messages,
|
|
1443
|
+
// never put it in a breadcrumb. See agent_secret_tokenization_boundary.md.
|
|
1444
|
+
/**
|
|
1445
|
+
* Create a new Cloud Browser Credential Vault. The response contains a
|
|
1446
|
+
* one-time `key` that the caller MUST save locally — the server cannot
|
|
1447
|
+
* recover it. Pair the key with the returned vault id when opening
|
|
1448
|
+
* sessions or creating items.
|
|
1449
|
+
*/
|
|
1450
|
+
async cloudBrowserVaultCreate(opts) {
|
|
1451
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault');
|
|
1452
|
+
url.searchParams.set('key', this.key);
|
|
1453
|
+
const body = { name: opts.name };
|
|
1454
|
+
if (opts.description !== undefined)
|
|
1455
|
+
body.description = opts.description;
|
|
1456
|
+
const response = await this.fetch({
|
|
1457
|
+
url: url.toString(),
|
|
1458
|
+
method: 'POST',
|
|
1459
|
+
headers: {
|
|
1460
|
+
'content-type': 'application/json',
|
|
1461
|
+
'user-agent': this.ua,
|
|
1462
|
+
},
|
|
1463
|
+
body: JSON.stringify(body),
|
|
1464
|
+
});
|
|
1465
|
+
if (!response.ok) {
|
|
1466
|
+
throw new Error(`Vault create failed: ${response.status} ${await response.text()}`);
|
|
1467
|
+
}
|
|
1468
|
+
return await response.json();
|
|
1469
|
+
}
|
|
1470
|
+
/** List every vault on the account. */
|
|
1471
|
+
async cloudBrowserVaultList() {
|
|
1472
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault');
|
|
1473
|
+
url.searchParams.set('key', this.key);
|
|
1474
|
+
const response = await this.fetch({
|
|
1475
|
+
url: url.toString(),
|
|
1476
|
+
method: 'GET',
|
|
1477
|
+
headers: { 'user-agent': this.ua },
|
|
1478
|
+
});
|
|
1479
|
+
if (!response.ok) {
|
|
1480
|
+
throw new Error(`Vault list failed: ${response.status} ${await response.text()}`);
|
|
1481
|
+
}
|
|
1482
|
+
const json = await response.json();
|
|
1483
|
+
return { vaults: json.vaults ?? [] };
|
|
1484
|
+
}
|
|
1485
|
+
/** Get a single vault by id. Does not return any secret material. */
|
|
1486
|
+
async cloudBrowserVaultGet(vaultId) {
|
|
1487
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId));
|
|
1488
|
+
url.searchParams.set('key', this.key);
|
|
1489
|
+
const response = await this.fetch({
|
|
1490
|
+
url: url.toString(),
|
|
1491
|
+
method: 'GET',
|
|
1492
|
+
headers: { 'user-agent': this.ua },
|
|
1493
|
+
});
|
|
1494
|
+
if (!response.ok) {
|
|
1495
|
+
throw new Error(`Vault get failed: ${response.status} ${await response.text()}`);
|
|
1496
|
+
}
|
|
1497
|
+
return await response.json();
|
|
1498
|
+
}
|
|
1499
|
+
/** Update vault metadata (name / description). Does not require the vault key. */
|
|
1500
|
+
async cloudBrowserVaultUpdate(vaultId, opts) {
|
|
1501
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId));
|
|
1502
|
+
url.searchParams.set('key', this.key);
|
|
1503
|
+
const body = {};
|
|
1504
|
+
if (opts.name !== undefined)
|
|
1505
|
+
body.name = opts.name;
|
|
1506
|
+
if (opts.description !== undefined)
|
|
1507
|
+
body.description = opts.description;
|
|
1508
|
+
const response = await this.fetch({
|
|
1509
|
+
url: url.toString(),
|
|
1510
|
+
method: 'PATCH',
|
|
1511
|
+
headers: {
|
|
1512
|
+
'content-type': 'application/json',
|
|
1513
|
+
'user-agent': this.ua,
|
|
1514
|
+
},
|
|
1515
|
+
body: JSON.stringify(body),
|
|
1516
|
+
});
|
|
1517
|
+
if (!response.ok) {
|
|
1518
|
+
throw new Error(`Vault update failed: ${response.status} ${await response.text()}`);
|
|
1519
|
+
}
|
|
1520
|
+
return await response.json();
|
|
1521
|
+
}
|
|
1522
|
+
/** Delete a vault and every item in it. Does not require the vault key. */
|
|
1523
|
+
async cloudBrowserVaultDelete(vaultId) {
|
|
1524
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId));
|
|
1525
|
+
url.searchParams.set('key', this.key);
|
|
1526
|
+
const response = await this.fetch({
|
|
1527
|
+
url: url.toString(),
|
|
1528
|
+
method: 'DELETE',
|
|
1529
|
+
headers: { 'user-agent': this.ua },
|
|
1530
|
+
});
|
|
1531
|
+
if (!response.ok) {
|
|
1532
|
+
throw new Error(`Vault delete failed: ${response.status} ${await response.text()}`);
|
|
1533
|
+
}
|
|
1534
|
+
const body = await response.json();
|
|
1535
|
+
return {
|
|
1536
|
+
success: body.success !== undefined ? Boolean(body.success) : true,
|
|
1537
|
+
message: typeof body.message === 'string' ? body.message : '',
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Rotate the vault key. The caller MUST pass the CURRENT key in
|
|
1542
|
+
* `currentVaultKey`; the server returns a fresh `key` exactly once. After
|
|
1543
|
+
* this call the old key cannot decrypt any row in the vault.
|
|
1544
|
+
*/
|
|
1545
|
+
async cloudBrowserVaultRotate(vaultId, currentVaultKey) {
|
|
1546
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId) + '/rotate');
|
|
1547
|
+
url.searchParams.set('key', this.key);
|
|
1548
|
+
const response = await this.fetch({
|
|
1549
|
+
url: url.toString(),
|
|
1550
|
+
method: 'POST',
|
|
1551
|
+
headers: {
|
|
1552
|
+
'user-agent': this.ua,
|
|
1553
|
+
'X-Vault-Key': currentVaultKey,
|
|
1554
|
+
},
|
|
1555
|
+
});
|
|
1556
|
+
if (!response.ok) {
|
|
1557
|
+
// Body may include the X-Vault-Key error message — safe to surface
|
|
1558
|
+
// because the server message names the header but not its value.
|
|
1559
|
+
throw new Error(`Vault rotate failed: ${response.status} ${await response.text()}`);
|
|
1560
|
+
}
|
|
1561
|
+
return await response.json();
|
|
1562
|
+
}
|
|
1563
|
+
/** List items in a vault. Items carry only opaque ciphertext, no plaintext. */
|
|
1564
|
+
async cloudBrowserVaultItemList(vaultId) {
|
|
1565
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId) + '/item');
|
|
1566
|
+
url.searchParams.set('key', this.key);
|
|
1567
|
+
const response = await this.fetch({
|
|
1568
|
+
url: url.toString(),
|
|
1569
|
+
method: 'GET',
|
|
1570
|
+
headers: { 'user-agent': this.ua },
|
|
1571
|
+
});
|
|
1572
|
+
if (!response.ok) {
|
|
1573
|
+
throw new Error(`Vault item list failed: ${response.status} ${await response.text()}`);
|
|
1574
|
+
}
|
|
1575
|
+
const json = await response.json();
|
|
1576
|
+
return { items: json.items ?? [] };
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* Add a credential to a vault. Requires the vault key in the X-Vault-Key
|
|
1580
|
+
* header so the server can encrypt the secret payload at rest.
|
|
1581
|
+
*/
|
|
1582
|
+
async cloudBrowserVaultItemCreate(vaultId, vaultKey, item) {
|
|
1583
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId) + '/item');
|
|
1584
|
+
url.searchParams.set('key', this.key);
|
|
1585
|
+
const body = {
|
|
1586
|
+
type: item.type,
|
|
1587
|
+
label: item.label,
|
|
1588
|
+
origin: item.origin,
|
|
1589
|
+
secret: item.secret,
|
|
1590
|
+
};
|
|
1591
|
+
if (item.username !== undefined)
|
|
1592
|
+
body.username = item.username;
|
|
1593
|
+
if (item.metadata !== undefined)
|
|
1594
|
+
body.metadata = item.metadata;
|
|
1595
|
+
const response = await this.fetch({
|
|
1596
|
+
url: url.toString(),
|
|
1597
|
+
method: 'POST',
|
|
1598
|
+
headers: {
|
|
1599
|
+
'content-type': 'application/json',
|
|
1600
|
+
'user-agent': this.ua,
|
|
1601
|
+
'X-Vault-Key': vaultKey,
|
|
1602
|
+
},
|
|
1603
|
+
body: JSON.stringify(body),
|
|
1604
|
+
});
|
|
1605
|
+
if (!response.ok) {
|
|
1606
|
+
throw new Error(`Vault item create failed: ${response.status} ${await response.text()}`);
|
|
1607
|
+
}
|
|
1608
|
+
return await response.json();
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* Patch an item's metadata or rotate its secret. The server only requires
|
|
1612
|
+
* X-Vault-Key when `secret` is supplied (ciphertext rotation). Passing
|
|
1613
|
+
* `vaultKey` without `secret` is a no-op on the server side and is allowed
|
|
1614
|
+
* for caller convenience.
|
|
1615
|
+
*/
|
|
1616
|
+
async cloudBrowserVaultItemUpdate(vaultId, itemId, opts) {
|
|
1617
|
+
if (opts.secret !== undefined && (opts.vaultKey === undefined || opts.vaultKey === '')) {
|
|
1618
|
+
throw new Error('cloudBrowserVaultItemUpdate: vaultKey is required when rotating the item secret');
|
|
1619
|
+
}
|
|
1620
|
+
if (opts.secret !== undefined && opts.type === undefined) {
|
|
1621
|
+
throw new Error('cloudBrowserVaultItemUpdate: type is required when rotating the item secret');
|
|
1622
|
+
}
|
|
1623
|
+
const url = new URL(this.cloudBrowserApiHost +
|
|
1624
|
+
'/vault/' +
|
|
1625
|
+
encodeURIComponent(vaultId) +
|
|
1626
|
+
'/item/' +
|
|
1627
|
+
encodeURIComponent(itemId));
|
|
1628
|
+
url.searchParams.set('key', this.key);
|
|
1629
|
+
const body = {};
|
|
1630
|
+
if (opts.type !== undefined)
|
|
1631
|
+
body.type = opts.type;
|
|
1632
|
+
if (opts.label !== undefined)
|
|
1633
|
+
body.label = opts.label;
|
|
1634
|
+
if (opts.origin !== undefined)
|
|
1635
|
+
body.origin = opts.origin;
|
|
1636
|
+
if (opts.username !== undefined)
|
|
1637
|
+
body.username = opts.username;
|
|
1638
|
+
if (opts.metadata !== undefined)
|
|
1639
|
+
body.metadata = opts.metadata;
|
|
1640
|
+
if (opts.secret !== undefined)
|
|
1641
|
+
body.secret = opts.secret;
|
|
1642
|
+
const headers = {
|
|
1643
|
+
'content-type': 'application/json',
|
|
1644
|
+
'user-agent': this.ua,
|
|
1645
|
+
};
|
|
1646
|
+
if (opts.vaultKey !== undefined && opts.vaultKey !== '') {
|
|
1647
|
+
headers['X-Vault-Key'] = opts.vaultKey;
|
|
1648
|
+
}
|
|
1649
|
+
const response = await this.fetch({
|
|
1650
|
+
url: url.toString(),
|
|
1651
|
+
method: 'PATCH',
|
|
1652
|
+
headers,
|
|
1653
|
+
body: JSON.stringify(body),
|
|
1654
|
+
});
|
|
1655
|
+
if (!response.ok) {
|
|
1656
|
+
throw new Error(`Vault item update failed: ${response.status} ${await response.text()}`);
|
|
1657
|
+
}
|
|
1658
|
+
return await response.json();
|
|
1659
|
+
}
|
|
1660
|
+
/** Delete a single vault item. Does not require the vault key. */
|
|
1661
|
+
async cloudBrowserVaultItemDelete(vaultId, itemId) {
|
|
1662
|
+
const url = new URL(this.cloudBrowserApiHost +
|
|
1663
|
+
'/vault/' +
|
|
1664
|
+
encodeURIComponent(vaultId) +
|
|
1665
|
+
'/item/' +
|
|
1666
|
+
encodeURIComponent(itemId));
|
|
1667
|
+
url.searchParams.set('key', this.key);
|
|
1668
|
+
const response = await this.fetch({
|
|
1669
|
+
url: url.toString(),
|
|
1670
|
+
method: 'DELETE',
|
|
1671
|
+
headers: { 'user-agent': this.ua },
|
|
1672
|
+
});
|
|
1673
|
+
if (!response.ok) {
|
|
1674
|
+
throw new Error(`Vault item delete failed: ${response.status} ${await response.text()}`);
|
|
1675
|
+
}
|
|
1676
|
+
const body = await response.json();
|
|
1677
|
+
return {
|
|
1678
|
+
success: body.success !== undefined ? Boolean(body.success) : true,
|
|
1679
|
+
message: typeof body.message === 'string' ? body.message : '',
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1392
1682
|
/**
|
|
1393
1683
|
* Download a debug session recording video.
|
|
1394
1684
|
* Returns the video as an ArrayBuffer (stream from server).
|
|
@@ -1408,7 +1698,9 @@ export class ScrapflyClient {
|
|
|
1408
1698
|
return { data: await response.arrayBuffer(), filename };
|
|
1409
1699
|
}
|
|
1410
1700
|
/**
|
|
1411
|
-
* Get playback info for a debug session recording.
|
|
1701
|
+
* Get playback info for a debug session recording. The returned object
|
|
1702
|
+
* carries `available`, `status` ('ready' | 'uploading' | 'unavailable' |
|
|
1703
|
+
* 'disabled'), `metadata`, `video_url`, and `retry_after_ms`.
|
|
1412
1704
|
*/
|
|
1413
1705
|
async cloudBrowserPlayback(runId) {
|
|
1414
1706
|
const url = new URL(this.cloudBrowserApiHost + '/run/' + runId + '/playback');
|
|
@@ -1423,6 +1715,27 @@ export class ScrapflyClient {
|
|
|
1423
1715
|
}
|
|
1424
1716
|
return await response.json();
|
|
1425
1717
|
}
|
|
1718
|
+
/**
|
|
1719
|
+
* Poll the playback endpoint until the recording resolves to a terminal
|
|
1720
|
+
* state ('ready' or 'unavailable') or the timeout elapses. Honours the
|
|
1721
|
+
* server-side retry_after_ms hint when present.
|
|
1722
|
+
*/
|
|
1723
|
+
async cloudBrowserWaitForPlayback(runId, opts = {}) {
|
|
1724
|
+
const timeoutMs = opts.timeoutMs ?? 180_000;
|
|
1725
|
+
const fallbackMs = opts.pollIntervalFallbackMs ?? 3_000;
|
|
1726
|
+
const deadline = Date.now() + timeoutMs;
|
|
1727
|
+
while (true) {
|
|
1728
|
+
const playback = await this.cloudBrowserPlayback(runId);
|
|
1729
|
+
if (playback.status !== 'uploading')
|
|
1730
|
+
return playback;
|
|
1731
|
+
const remaining = deadline - Date.now();
|
|
1732
|
+
if (remaining <= 0)
|
|
1733
|
+
return playback;
|
|
1734
|
+
const retryAfter = Number(playback.retry_after_ms) || fallbackMs;
|
|
1735
|
+
const sleepFor = Math.min(retryAfter, remaining);
|
|
1736
|
+
await new Promise((resolve) => setTimeout(resolve, sleepFor));
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1426
1739
|
/**
|
|
1427
1740
|
* List all running Cloud Browser sessions.
|
|
1428
1741
|
*/
|
package/esm/crawlerconfig.d.ts
CHANGED
|
@@ -25,7 +25,9 @@ export type CrawlerWebhookEventName = 'crawler_started' | 'crawler_url_visited'
|
|
|
25
25
|
* which lets the server apply its documented defaults (e.g. `respect_robots_txt=true`).
|
|
26
26
|
*/
|
|
27
27
|
export type CrawlerConfigOptions = {
|
|
28
|
-
url
|
|
28
|
+
url?: string;
|
|
29
|
+
url_list?: string[];
|
|
30
|
+
remote_url_list?: string;
|
|
29
31
|
page_limit?: number;
|
|
30
32
|
max_depth?: number;
|
|
31
33
|
max_duration?: number;
|
|
@@ -72,7 +74,9 @@ export type CrawlerConfigOptions = {
|
|
|
72
74
|
* ```
|
|
73
75
|
*/
|
|
74
76
|
export declare class CrawlerConfig {
|
|
75
|
-
url
|
|
77
|
+
url?: string;
|
|
78
|
+
url_list?: string[];
|
|
79
|
+
remote_url_list?: string;
|
|
76
80
|
page_limit?: number;
|
|
77
81
|
max_depth?: number;
|
|
78
82
|
max_duration?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crawlerconfig.d.ts","sourceRoot":"","sources":["../src/crawlerconfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,YAAY,GACZ,UAAU,GACV,MAAM,GACN,MAAM,GACN,gBAAgB,GAChB,eAAe,CAAC;AAYpB;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAC/B,iBAAiB,GACjB,qBAAqB,GACrB,qBAAqB,GACrB,wBAAwB,GACxB,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,GACnB,kBAAkB,CAAC;AAavB;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG;
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;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,eAAe,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACzC,gBAAgB,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAE5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,uBAAuB,EAAE,CAAC;gBAE/B,OAAO,EAAE,oBAAoB;IA2GzC,OAAO,CAAC,eAAe;IA0CvB;;;;;;;;;OASG;IACH,WAAW,IAAI,GAAG,CAAC,GAAG,CAAC;CA4CxB"}
|
package/esm/crawlerconfig.js
CHANGED
|
@@ -41,6 +41,18 @@ export class CrawlerConfig {
|
|
|
41
41
|
writable: true,
|
|
42
42
|
value: void 0
|
|
43
43
|
});
|
|
44
|
+
Object.defineProperty(this, "url_list", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: void 0
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(this, "remote_url_list", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: void 0
|
|
55
|
+
});
|
|
44
56
|
Object.defineProperty(this, "page_limit", {
|
|
45
57
|
enumerable: true,
|
|
46
58
|
configurable: true,
|
|
@@ -216,10 +228,22 @@ export class CrawlerConfig {
|
|
|
216
228
|
value: void 0
|
|
217
229
|
});
|
|
218
230
|
this.validateOptions(options);
|
|
219
|
-
|
|
220
|
-
|
|
231
|
+
const hasSeed = typeof options.url === 'string' && options.url.trim() !== '';
|
|
232
|
+
const hasList = Array.isArray(options.url_list) && options.url_list.length > 0;
|
|
233
|
+
const hasRemote = typeof options.remote_url_list === 'string' && options.remote_url_list.trim() !== '';
|
|
234
|
+
const sourceCount = (hasSeed ? 1 : 0) + (hasList ? 1 : 0) + (hasRemote ? 1 : 0);
|
|
235
|
+
if (sourceCount === 0) {
|
|
236
|
+
throw new CrawlerConfigError('Provide one of: url, url_list, remote_url_list');
|
|
237
|
+
}
|
|
238
|
+
if (sourceCount > 1) {
|
|
239
|
+
throw new CrawlerConfigError('Only one of url, url_list, remote_url_list can be set');
|
|
221
240
|
}
|
|
222
|
-
|
|
241
|
+
if (hasSeed)
|
|
242
|
+
this.url = options.url;
|
|
243
|
+
if (hasList)
|
|
244
|
+
this.url_list = options.url_list;
|
|
245
|
+
if (hasRemote)
|
|
246
|
+
this.remote_url_list = options.remote_url_list;
|
|
223
247
|
// Mutually exclusive path filters
|
|
224
248
|
if (options.exclude_paths && options.include_only_paths) {
|
|
225
249
|
throw new CrawlerConfigError('exclude_paths and include_only_paths are mutually exclusive');
|
|
@@ -308,6 +332,8 @@ export class CrawlerConfig {
|
|
|
308
332
|
validateOptions(options) {
|
|
309
333
|
const validKeys = new Set([
|
|
310
334
|
'url',
|
|
335
|
+
'url_list',
|
|
336
|
+
'remote_url_list',
|
|
311
337
|
'page_limit',
|
|
312
338
|
'max_depth',
|
|
313
339
|
'max_duration',
|
|
@@ -355,8 +381,11 @@ export class CrawlerConfig {
|
|
|
355
381
|
* defaults (e.g. `respect_robots_txt=true`).
|
|
356
382
|
*/
|
|
357
383
|
toApiParams() {
|
|
358
|
-
const params = {
|
|
384
|
+
const params = {};
|
|
359
385
|
const fields = [
|
|
386
|
+
'url',
|
|
387
|
+
'url_list',
|
|
388
|
+
'remote_url_list',
|
|
360
389
|
'page_limit',
|
|
361
390
|
'max_depth',
|
|
362
391
|
'max_duration',
|
package/esm/extractionconfig.js
CHANGED
|
@@ -183,7 +183,7 @@ export class ExtractionConfig {
|
|
|
183
183
|
throw new ExtractionConfigError('You cannot pass both parameters extraction_template and extraction_ephemeral_template. You must choose');
|
|
184
184
|
}
|
|
185
185
|
if (this.extraction_template) {
|
|
186
|
-
params.extraction_template = this.extraction_template;
|
|
186
|
+
params.extraction_template = 'persistent:' + this.extraction_template;
|
|
187
187
|
}
|
|
188
188
|
if (this.extraction_ephemeral_template) {
|
|
189
189
|
params.extraction_template = 'ephemeral:' + urlsafe_b64encode(JSON.stringify(this.extraction_ephemeral_template));
|
package/esm/main.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export { Format as ScreenshotFormat, Options as ScreenshotOptions, ScreenshotCon
|
|
|
30
30
|
export { ExtractionConfig } from './extractionconfig.js';
|
|
31
31
|
export { BrowserConfig, ProxyPool, OperatingSystem } from './browserconfig.js';
|
|
32
32
|
export type { BrowserConfigOptions } from './browserconfig.js';
|
|
33
|
+
export type { Vault, VaultItem, VaultItemCreate, VaultItemType, VaultSecret } from './types.js';
|
|
33
34
|
/** Namespace of every error class the SDK can throw. See {@link ScrapflyError}. */
|
|
34
35
|
export * as errors from './errors.js';
|
|
35
36
|
export { ExtractionResult, ScrapeResult, ScreenshotResult } from './result.js';
|
package/esm/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,YAAY,IAAI,mBAAmB,EACnC,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,MAAM,IA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AE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,EACX,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,6BAA6B,EAC7B,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
package/esm/scrapeconfig.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrapeconfig.d.ts","sourceRoot":"","sources":["../src/scrapeconfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGlD,oBAAY,eAAe;IACzB;;;;;;;QAOI;IACJ,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;IACzC,YAAY,iBAAiB;CAC9B;AAED,uDAAuD;AACvD,oBAAY,MAAM;IAChB,uBAAuB;IACvB,IAAI,SAAS;IACb,uCAAuC;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AC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,UAAQ;IAC5B,WAAW,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,gBAAgB,CAAC,EACf,CAAC,aAAa,GAAG,WAAW,GAAG,eAAe,GAAG,oBAAoB,GAAG,cAAc,GAAG,eAAe,CAAC,EAAE,CAAC;IAC9G,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,UAAU,GAAG,kBAAkB,CAAC;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,OAAO,EAAE,mBAAmB;IA+FxC,OAAO,CAAC,eAAe;IASvB,WAAW,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAqL3D"}
|
package/esm/scrapeconfig.js
CHANGED
|
@@ -233,7 +233,7 @@ export class ScrapeConfig {
|
|
|
233
233
|
enumerable: true,
|
|
234
234
|
configurable: true,
|
|
235
235
|
writable: true,
|
|
236
|
-
value:
|
|
236
|
+
value: true
|
|
237
237
|
});
|
|
238
238
|
Object.defineProperty(this, "screenshots", {
|
|
239
239
|
enumerable: true,
|
|
@@ -544,7 +544,7 @@ export class ScrapeConfig {
|
|
|
544
544
|
throw new ScrapeConfigError('You cannot pass both parameters extraction_template and extraction_ephemeral_template. You must choose');
|
|
545
545
|
}
|
|
546
546
|
if (this.extraction_template) {
|
|
547
|
-
params.extraction_template = this.extraction_template;
|
|
547
|
+
params.extraction_template = 'persistent:' + this.extraction_template;
|
|
548
548
|
}
|
|
549
549
|
if (this.extraction_ephemeral_template) {
|
|
550
550
|
params.extraction_template = 'ephemeral:' + urlsafe_b64encode(JSON.stringify(this.extraction_ephemeral_template));
|
|
@@ -560,9 +560,7 @@ export class ScrapeConfig {
|
|
|
560
560
|
}
|
|
561
561
|
if (this.session) {
|
|
562
562
|
params.session = this.session;
|
|
563
|
-
|
|
564
|
-
params.session_sticky_proxy = true;
|
|
565
|
-
}
|
|
563
|
+
params.session_sticky_proxy = this.session_sticky_proxy;
|
|
566
564
|
}
|
|
567
565
|
else {
|
|
568
566
|
if (this.session_sticky_proxy) {
|
|
@@ -599,3 +597,9 @@ Object.defineProperty(ScrapeConfig, "PUBLIC_RESIDENTIAL_POOL", {
|
|
|
599
597
|
writable: true,
|
|
600
598
|
value: 'public_residential_pool'
|
|
601
599
|
});
|
|
600
|
+
Object.defineProperty(ScrapeConfig, "PUBLIC_TOR_POOL", {
|
|
601
|
+
enumerable: true,
|
|
602
|
+
configurable: true,
|
|
603
|
+
writable: true,
|
|
604
|
+
value: 'public_tor_pool'
|
|
605
|
+
});
|