scrapfly-sdk 0.10.6 → 0.11.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/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 +104 -3
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +332 -14
- 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 +104 -3
- package/script/client.d.ts.map +1 -1
- package/script/client.js +332 -14
- 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 +402 -15
- 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/script/client.js
CHANGED
|
@@ -902,17 +902,53 @@ class ScrapflyClient {
|
|
|
902
902
|
try {
|
|
903
903
|
const url = new URL(this.HOST + '/crawl');
|
|
904
904
|
url.search = new URLSearchParams({ key: this.key }).toString();
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
905
|
+
// POST /crawl accepts two body formats:
|
|
906
|
+
// - application/json: the entire crawler configuration as JSON.
|
|
907
|
+
// Used for seed-URL crawls and remote_url_list crawls.
|
|
908
|
+
// - multipart/form-data: a 'config' JSON part and a 'urls' text
|
|
909
|
+
// part (one URL per line). Used only when the caller provides
|
|
910
|
+
// an in-memory url_list, so the URLs can be uploaded as a
|
|
911
|
+
// streamed file payload instead of inlined into the JSON body.
|
|
912
|
+
const params = config.toApiParams();
|
|
913
|
+
const urlList = Array.isArray(params.url_list) && params.url_list.length > 0
|
|
914
|
+
? params.url_list
|
|
915
|
+
: undefined;
|
|
916
|
+
if (urlList !== undefined) {
|
|
917
|
+
// Strip url_list from the JSON config — the URLs go through the
|
|
918
|
+
// 'urls' multipart part instead, which the API gateway streams
|
|
919
|
+
// straight through to the scrape engine.
|
|
920
|
+
delete params.url_list;
|
|
921
|
+
const form = new FormData();
|
|
922
|
+
const configBlob = new Blob([JSON.stringify(params)], { type: 'application/json' });
|
|
923
|
+
form.append('config', configBlob, 'config.json');
|
|
924
|
+
const urlsBlob = new Blob([urlList.join('\n')], { type: 'text/plain' });
|
|
925
|
+
form.append('urls', urlsBlob, 'urls.txt');
|
|
926
|
+
response = await this.fetch({
|
|
927
|
+
url: url.toString(),
|
|
928
|
+
method: 'POST',
|
|
929
|
+
headers: {
|
|
930
|
+
'user-agent': this.ua,
|
|
931
|
+
// Intentionally omit content-type — fetch fills in the
|
|
932
|
+
// multipart boundary itself when given a FormData body.
|
|
933
|
+
'accept-encoding': 'gzip, deflate, br',
|
|
934
|
+
accept: 'application/json',
|
|
935
|
+
},
|
|
936
|
+
body: form,
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
response = await this.fetch({
|
|
941
|
+
url: url.toString(),
|
|
942
|
+
method: 'POST',
|
|
943
|
+
headers: {
|
|
944
|
+
'user-agent': this.ua,
|
|
945
|
+
'content-type': 'application/json',
|
|
946
|
+
'accept-encoding': 'gzip, deflate, br',
|
|
947
|
+
accept: 'application/json',
|
|
948
|
+
},
|
|
949
|
+
body: JSON.stringify(params),
|
|
950
|
+
});
|
|
951
|
+
}
|
|
916
952
|
}
|
|
917
953
|
catch (e) {
|
|
918
954
|
logger_js_1.log.error('error', e);
|
|
@@ -1250,11 +1286,23 @@ class ScrapflyClient {
|
|
|
1250
1286
|
// --- Cloud Browser ---
|
|
1251
1287
|
/**
|
|
1252
1288
|
* Get the WebSocket URL for a Cloud Browser session.
|
|
1289
|
+
*
|
|
1290
|
+
* On rejection the server sends a JSON error frame then a close frame
|
|
1291
|
+
* with code 1008/1011/1013 and a "ERR::BROWSER::CODE: reason" string.
|
|
1292
|
+
* See https://scrapfly.io/docs/cloud-browser-api/errors#websocket-close-frame
|
|
1253
1293
|
*/
|
|
1254
1294
|
cloudBrowser(config) {
|
|
1255
1295
|
const browserConfig = config || new browserconfig_js_1.BrowserConfig();
|
|
1256
1296
|
return browserConfig.websocketUrl(this.key, this.cloudBrowserHost);
|
|
1257
1297
|
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Return the deterministic project salt for this client's api_key. Matches
|
|
1300
|
+
* the `X-Browser-Project-Salt` response header returned on a successful
|
|
1301
|
+
* Cloud Browser WebSocket upgrade.
|
|
1302
|
+
*/
|
|
1303
|
+
async cloudBrowserProjectSalt() {
|
|
1304
|
+
return browserconfig_js_1.BrowserConfig.projectSalt(this.key);
|
|
1305
|
+
}
|
|
1258
1306
|
/**
|
|
1259
1307
|
* Call the Cloud Browser Unblock API.
|
|
1260
1308
|
*/
|
|
@@ -1270,6 +1318,8 @@ class ScrapflyClient {
|
|
|
1270
1318
|
jsonBody.country = options.country;
|
|
1271
1319
|
if (options.os)
|
|
1272
1320
|
jsonBody.os = options.os;
|
|
1321
|
+
if (options.browser_brand)
|
|
1322
|
+
jsonBody.browser_brand = options.browser_brand;
|
|
1273
1323
|
if (options.timeout)
|
|
1274
1324
|
jsonBody.timeout = options.timeout;
|
|
1275
1325
|
if (options.browser_timeout)
|
|
@@ -1282,8 +1332,8 @@ class ScrapflyClient {
|
|
|
1282
1332
|
jsonBody.method = options.method;
|
|
1283
1333
|
if (options.enable_mcp !== undefined)
|
|
1284
1334
|
jsonBody.enable_mcp = options.enable_mcp;
|
|
1285
|
-
if (options.
|
|
1286
|
-
jsonBody.
|
|
1335
|
+
if (options.debug !== undefined)
|
|
1336
|
+
jsonBody.debug = options.debug;
|
|
1287
1337
|
const url = new URL(this.cloudBrowserApiHost + '/unblock');
|
|
1288
1338
|
url.searchParams.set('key', this.key);
|
|
1289
1339
|
const response = await this.fetch({
|
|
@@ -1415,6 +1465,251 @@ class ScrapflyClient {
|
|
|
1415
1465
|
}
|
|
1416
1466
|
return await response.json();
|
|
1417
1467
|
}
|
|
1468
|
+
// ----- Cloud Browser Credential Vault -------------------------------------
|
|
1469
|
+
// Server contract documented at apps/scrapfly/api/scrapfly-api/pkg/vault/.
|
|
1470
|
+
//
|
|
1471
|
+
// SECURITY: the vault key is the customer-held secret that decrypts every
|
|
1472
|
+
// item in the vault. The server emits it ONCE on POST /vault and POST
|
|
1473
|
+
// /vault/{id}/rotate; never log it, never include it in error messages,
|
|
1474
|
+
// never put it in a breadcrumb. See agent_secret_tokenization_boundary.md.
|
|
1475
|
+
/**
|
|
1476
|
+
* Create a new Cloud Browser Credential Vault. The response contains a
|
|
1477
|
+
* one-time `key` that the caller MUST save locally — the server cannot
|
|
1478
|
+
* recover it. Pair the key with the returned vault id when opening
|
|
1479
|
+
* sessions or creating items.
|
|
1480
|
+
*/
|
|
1481
|
+
async cloudBrowserVaultCreate(opts) {
|
|
1482
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault');
|
|
1483
|
+
url.searchParams.set('key', this.key);
|
|
1484
|
+
const body = { name: opts.name };
|
|
1485
|
+
if (opts.description !== undefined)
|
|
1486
|
+
body.description = opts.description;
|
|
1487
|
+
const response = await this.fetch({
|
|
1488
|
+
url: url.toString(),
|
|
1489
|
+
method: 'POST',
|
|
1490
|
+
headers: {
|
|
1491
|
+
'content-type': 'application/json',
|
|
1492
|
+
'user-agent': this.ua,
|
|
1493
|
+
},
|
|
1494
|
+
body: JSON.stringify(body),
|
|
1495
|
+
});
|
|
1496
|
+
if (!response.ok) {
|
|
1497
|
+
throw new Error(`Vault create failed: ${response.status} ${await response.text()}`);
|
|
1498
|
+
}
|
|
1499
|
+
return await response.json();
|
|
1500
|
+
}
|
|
1501
|
+
/** List every vault on the account. */
|
|
1502
|
+
async cloudBrowserVaultList() {
|
|
1503
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault');
|
|
1504
|
+
url.searchParams.set('key', this.key);
|
|
1505
|
+
const response = await this.fetch({
|
|
1506
|
+
url: url.toString(),
|
|
1507
|
+
method: 'GET',
|
|
1508
|
+
headers: { 'user-agent': this.ua },
|
|
1509
|
+
});
|
|
1510
|
+
if (!response.ok) {
|
|
1511
|
+
throw new Error(`Vault list failed: ${response.status} ${await response.text()}`);
|
|
1512
|
+
}
|
|
1513
|
+
const json = await response.json();
|
|
1514
|
+
return { vaults: json.vaults ?? [] };
|
|
1515
|
+
}
|
|
1516
|
+
/** Get a single vault by id. Does not return any secret material. */
|
|
1517
|
+
async cloudBrowserVaultGet(vaultId) {
|
|
1518
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId));
|
|
1519
|
+
url.searchParams.set('key', this.key);
|
|
1520
|
+
const response = await this.fetch({
|
|
1521
|
+
url: url.toString(),
|
|
1522
|
+
method: 'GET',
|
|
1523
|
+
headers: { 'user-agent': this.ua },
|
|
1524
|
+
});
|
|
1525
|
+
if (!response.ok) {
|
|
1526
|
+
throw new Error(`Vault get failed: ${response.status} ${await response.text()}`);
|
|
1527
|
+
}
|
|
1528
|
+
return await response.json();
|
|
1529
|
+
}
|
|
1530
|
+
/** Update vault metadata (name / description). Does not require the vault key. */
|
|
1531
|
+
async cloudBrowserVaultUpdate(vaultId, opts) {
|
|
1532
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId));
|
|
1533
|
+
url.searchParams.set('key', this.key);
|
|
1534
|
+
const body = {};
|
|
1535
|
+
if (opts.name !== undefined)
|
|
1536
|
+
body.name = opts.name;
|
|
1537
|
+
if (opts.description !== undefined)
|
|
1538
|
+
body.description = opts.description;
|
|
1539
|
+
const response = await this.fetch({
|
|
1540
|
+
url: url.toString(),
|
|
1541
|
+
method: 'PATCH',
|
|
1542
|
+
headers: {
|
|
1543
|
+
'content-type': 'application/json',
|
|
1544
|
+
'user-agent': this.ua,
|
|
1545
|
+
},
|
|
1546
|
+
body: JSON.stringify(body),
|
|
1547
|
+
});
|
|
1548
|
+
if (!response.ok) {
|
|
1549
|
+
throw new Error(`Vault update failed: ${response.status} ${await response.text()}`);
|
|
1550
|
+
}
|
|
1551
|
+
return await response.json();
|
|
1552
|
+
}
|
|
1553
|
+
/** Delete a vault and every item in it. Does not require the vault key. */
|
|
1554
|
+
async cloudBrowserVaultDelete(vaultId) {
|
|
1555
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId));
|
|
1556
|
+
url.searchParams.set('key', this.key);
|
|
1557
|
+
const response = await this.fetch({
|
|
1558
|
+
url: url.toString(),
|
|
1559
|
+
method: 'DELETE',
|
|
1560
|
+
headers: { 'user-agent': this.ua },
|
|
1561
|
+
});
|
|
1562
|
+
if (!response.ok) {
|
|
1563
|
+
throw new Error(`Vault delete failed: ${response.status} ${await response.text()}`);
|
|
1564
|
+
}
|
|
1565
|
+
const body = await response.json();
|
|
1566
|
+
return {
|
|
1567
|
+
success: body.success !== undefined ? Boolean(body.success) : true,
|
|
1568
|
+
message: typeof body.message === 'string' ? body.message : '',
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
/**
|
|
1572
|
+
* Rotate the vault key. The caller MUST pass the CURRENT key in
|
|
1573
|
+
* `currentVaultKey`; the server returns a fresh `key` exactly once. After
|
|
1574
|
+
* this call the old key cannot decrypt any row in the vault.
|
|
1575
|
+
*/
|
|
1576
|
+
async cloudBrowserVaultRotate(vaultId, currentVaultKey) {
|
|
1577
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId) + '/rotate');
|
|
1578
|
+
url.searchParams.set('key', this.key);
|
|
1579
|
+
const response = await this.fetch({
|
|
1580
|
+
url: url.toString(),
|
|
1581
|
+
method: 'POST',
|
|
1582
|
+
headers: {
|
|
1583
|
+
'user-agent': this.ua,
|
|
1584
|
+
'X-Vault-Key': currentVaultKey,
|
|
1585
|
+
},
|
|
1586
|
+
});
|
|
1587
|
+
if (!response.ok) {
|
|
1588
|
+
// Body may include the X-Vault-Key error message — safe to surface
|
|
1589
|
+
// because the server message names the header but not its value.
|
|
1590
|
+
throw new Error(`Vault rotate failed: ${response.status} ${await response.text()}`);
|
|
1591
|
+
}
|
|
1592
|
+
return await response.json();
|
|
1593
|
+
}
|
|
1594
|
+
/** List items in a vault. Items carry only opaque ciphertext, no plaintext. */
|
|
1595
|
+
async cloudBrowserVaultItemList(vaultId) {
|
|
1596
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId) + '/item');
|
|
1597
|
+
url.searchParams.set('key', this.key);
|
|
1598
|
+
const response = await this.fetch({
|
|
1599
|
+
url: url.toString(),
|
|
1600
|
+
method: 'GET',
|
|
1601
|
+
headers: { 'user-agent': this.ua },
|
|
1602
|
+
});
|
|
1603
|
+
if (!response.ok) {
|
|
1604
|
+
throw new Error(`Vault item list failed: ${response.status} ${await response.text()}`);
|
|
1605
|
+
}
|
|
1606
|
+
const json = await response.json();
|
|
1607
|
+
return { items: json.items ?? [] };
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Add a credential to a vault. Requires the vault key in the X-Vault-Key
|
|
1611
|
+
* header so the server can encrypt the secret payload at rest.
|
|
1612
|
+
*/
|
|
1613
|
+
async cloudBrowserVaultItemCreate(vaultId, vaultKey, item) {
|
|
1614
|
+
const url = new URL(this.cloudBrowserApiHost + '/vault/' + encodeURIComponent(vaultId) + '/item');
|
|
1615
|
+
url.searchParams.set('key', this.key);
|
|
1616
|
+
const body = {
|
|
1617
|
+
type: item.type,
|
|
1618
|
+
label: item.label,
|
|
1619
|
+
origin: item.origin,
|
|
1620
|
+
secret: item.secret,
|
|
1621
|
+
};
|
|
1622
|
+
if (item.username !== undefined)
|
|
1623
|
+
body.username = item.username;
|
|
1624
|
+
if (item.metadata !== undefined)
|
|
1625
|
+
body.metadata = item.metadata;
|
|
1626
|
+
const response = await this.fetch({
|
|
1627
|
+
url: url.toString(),
|
|
1628
|
+
method: 'POST',
|
|
1629
|
+
headers: {
|
|
1630
|
+
'content-type': 'application/json',
|
|
1631
|
+
'user-agent': this.ua,
|
|
1632
|
+
'X-Vault-Key': vaultKey,
|
|
1633
|
+
},
|
|
1634
|
+
body: JSON.stringify(body),
|
|
1635
|
+
});
|
|
1636
|
+
if (!response.ok) {
|
|
1637
|
+
throw new Error(`Vault item create failed: ${response.status} ${await response.text()}`);
|
|
1638
|
+
}
|
|
1639
|
+
return await response.json();
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Patch an item's metadata or rotate its secret. The server only requires
|
|
1643
|
+
* X-Vault-Key when `secret` is supplied (ciphertext rotation). Passing
|
|
1644
|
+
* `vaultKey` without `secret` is a no-op on the server side and is allowed
|
|
1645
|
+
* for caller convenience.
|
|
1646
|
+
*/
|
|
1647
|
+
async cloudBrowserVaultItemUpdate(vaultId, itemId, opts) {
|
|
1648
|
+
if (opts.secret !== undefined && (opts.vaultKey === undefined || opts.vaultKey === '')) {
|
|
1649
|
+
throw new Error('cloudBrowserVaultItemUpdate: vaultKey is required when rotating the item secret');
|
|
1650
|
+
}
|
|
1651
|
+
if (opts.secret !== undefined && opts.type === undefined) {
|
|
1652
|
+
throw new Error('cloudBrowserVaultItemUpdate: type is required when rotating the item secret');
|
|
1653
|
+
}
|
|
1654
|
+
const url = new URL(this.cloudBrowserApiHost +
|
|
1655
|
+
'/vault/' +
|
|
1656
|
+
encodeURIComponent(vaultId) +
|
|
1657
|
+
'/item/' +
|
|
1658
|
+
encodeURIComponent(itemId));
|
|
1659
|
+
url.searchParams.set('key', this.key);
|
|
1660
|
+
const body = {};
|
|
1661
|
+
if (opts.type !== undefined)
|
|
1662
|
+
body.type = opts.type;
|
|
1663
|
+
if (opts.label !== undefined)
|
|
1664
|
+
body.label = opts.label;
|
|
1665
|
+
if (opts.origin !== undefined)
|
|
1666
|
+
body.origin = opts.origin;
|
|
1667
|
+
if (opts.username !== undefined)
|
|
1668
|
+
body.username = opts.username;
|
|
1669
|
+
if (opts.metadata !== undefined)
|
|
1670
|
+
body.metadata = opts.metadata;
|
|
1671
|
+
if (opts.secret !== undefined)
|
|
1672
|
+
body.secret = opts.secret;
|
|
1673
|
+
const headers = {
|
|
1674
|
+
'content-type': 'application/json',
|
|
1675
|
+
'user-agent': this.ua,
|
|
1676
|
+
};
|
|
1677
|
+
if (opts.vaultKey !== undefined && opts.vaultKey !== '') {
|
|
1678
|
+
headers['X-Vault-Key'] = opts.vaultKey;
|
|
1679
|
+
}
|
|
1680
|
+
const response = await this.fetch({
|
|
1681
|
+
url: url.toString(),
|
|
1682
|
+
method: 'PATCH',
|
|
1683
|
+
headers,
|
|
1684
|
+
body: JSON.stringify(body),
|
|
1685
|
+
});
|
|
1686
|
+
if (!response.ok) {
|
|
1687
|
+
throw new Error(`Vault item update failed: ${response.status} ${await response.text()}`);
|
|
1688
|
+
}
|
|
1689
|
+
return await response.json();
|
|
1690
|
+
}
|
|
1691
|
+
/** Delete a single vault item. Does not require the vault key. */
|
|
1692
|
+
async cloudBrowserVaultItemDelete(vaultId, itemId) {
|
|
1693
|
+
const url = new URL(this.cloudBrowserApiHost +
|
|
1694
|
+
'/vault/' +
|
|
1695
|
+
encodeURIComponent(vaultId) +
|
|
1696
|
+
'/item/' +
|
|
1697
|
+
encodeURIComponent(itemId));
|
|
1698
|
+
url.searchParams.set('key', this.key);
|
|
1699
|
+
const response = await this.fetch({
|
|
1700
|
+
url: url.toString(),
|
|
1701
|
+
method: 'DELETE',
|
|
1702
|
+
headers: { 'user-agent': this.ua },
|
|
1703
|
+
});
|
|
1704
|
+
if (!response.ok) {
|
|
1705
|
+
throw new Error(`Vault item delete failed: ${response.status} ${await response.text()}`);
|
|
1706
|
+
}
|
|
1707
|
+
const body = await response.json();
|
|
1708
|
+
return {
|
|
1709
|
+
success: body.success !== undefined ? Boolean(body.success) : true,
|
|
1710
|
+
message: typeof body.message === 'string' ? body.message : '',
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1418
1713
|
/**
|
|
1419
1714
|
* Download a debug session recording video.
|
|
1420
1715
|
* Returns the video as an ArrayBuffer (stream from server).
|
|
@@ -1434,7 +1729,9 @@ class ScrapflyClient {
|
|
|
1434
1729
|
return { data: await response.arrayBuffer(), filename };
|
|
1435
1730
|
}
|
|
1436
1731
|
/**
|
|
1437
|
-
* Get playback info for a debug session recording.
|
|
1732
|
+
* Get playback info for a debug session recording. The returned object
|
|
1733
|
+
* carries `available`, `status` ('ready' | 'uploading' | 'unavailable' |
|
|
1734
|
+
* 'disabled'), `metadata`, `video_url`, and `retry_after_ms`.
|
|
1438
1735
|
*/
|
|
1439
1736
|
async cloudBrowserPlayback(runId) {
|
|
1440
1737
|
const url = new URL(this.cloudBrowserApiHost + '/run/' + runId + '/playback');
|
|
@@ -1449,6 +1746,27 @@ class ScrapflyClient {
|
|
|
1449
1746
|
}
|
|
1450
1747
|
return await response.json();
|
|
1451
1748
|
}
|
|
1749
|
+
/**
|
|
1750
|
+
* Poll the playback endpoint until the recording resolves to a terminal
|
|
1751
|
+
* state ('ready' or 'unavailable') or the timeout elapses. Honours the
|
|
1752
|
+
* server-side retry_after_ms hint when present.
|
|
1753
|
+
*/
|
|
1754
|
+
async cloudBrowserWaitForPlayback(runId, opts = {}) {
|
|
1755
|
+
const timeoutMs = opts.timeoutMs ?? 180_000;
|
|
1756
|
+
const fallbackMs = opts.pollIntervalFallbackMs ?? 3_000;
|
|
1757
|
+
const deadline = Date.now() + timeoutMs;
|
|
1758
|
+
while (true) {
|
|
1759
|
+
const playback = await this.cloudBrowserPlayback(runId);
|
|
1760
|
+
if (playback.status !== 'uploading')
|
|
1761
|
+
return playback;
|
|
1762
|
+
const remaining = deadline - Date.now();
|
|
1763
|
+
if (remaining <= 0)
|
|
1764
|
+
return playback;
|
|
1765
|
+
const retryAfter = Number(playback.retry_after_ms) || fallbackMs;
|
|
1766
|
+
const sleepFor = Math.min(retryAfter, remaining);
|
|
1767
|
+
await new Promise((resolve) => setTimeout(resolve, sleepFor));
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1452
1770
|
/**
|
|
1453
1771
|
* List all running Cloud Browser sessions.
|
|
1454
1772
|
*/
|
|
@@ -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;
|
|
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;IAIjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;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AAuB,EAAE,CAAC;gBAE/B,OAAO,EAAE,oBAAoB;IA2GzC,OAAO,CAAC,eAAe;IA0CvB;;;;;;;;;OASG;IACH,WAAW,IAAI,GAAG,CAAC,GAAG,CAAC;CA4CxB"}
|
package/script/crawlerconfig.js
CHANGED
|
@@ -44,6 +44,18 @@ class CrawlerConfig {
|
|
|
44
44
|
writable: true,
|
|
45
45
|
value: void 0
|
|
46
46
|
});
|
|
47
|
+
Object.defineProperty(this, "url_list", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: void 0
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(this, "remote_url_list", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: void 0
|
|
58
|
+
});
|
|
47
59
|
Object.defineProperty(this, "page_limit", {
|
|
48
60
|
enumerable: true,
|
|
49
61
|
configurable: true,
|
|
@@ -219,10 +231,22 @@ class CrawlerConfig {
|
|
|
219
231
|
value: void 0
|
|
220
232
|
});
|
|
221
233
|
this.validateOptions(options);
|
|
222
|
-
|
|
223
|
-
|
|
234
|
+
const hasSeed = typeof options.url === 'string' && options.url.trim() !== '';
|
|
235
|
+
const hasList = Array.isArray(options.url_list) && options.url_list.length > 0;
|
|
236
|
+
const hasRemote = typeof options.remote_url_list === 'string' && options.remote_url_list.trim() !== '';
|
|
237
|
+
const sourceCount = (hasSeed ? 1 : 0) + (hasList ? 1 : 0) + (hasRemote ? 1 : 0);
|
|
238
|
+
if (sourceCount === 0) {
|
|
239
|
+
throw new errors_js_1.CrawlerConfigError('Provide one of: url, url_list, remote_url_list');
|
|
240
|
+
}
|
|
241
|
+
if (sourceCount > 1) {
|
|
242
|
+
throw new errors_js_1.CrawlerConfigError('Only one of url, url_list, remote_url_list can be set');
|
|
224
243
|
}
|
|
225
|
-
|
|
244
|
+
if (hasSeed)
|
|
245
|
+
this.url = options.url;
|
|
246
|
+
if (hasList)
|
|
247
|
+
this.url_list = options.url_list;
|
|
248
|
+
if (hasRemote)
|
|
249
|
+
this.remote_url_list = options.remote_url_list;
|
|
226
250
|
// Mutually exclusive path filters
|
|
227
251
|
if (options.exclude_paths && options.include_only_paths) {
|
|
228
252
|
throw new errors_js_1.CrawlerConfigError('exclude_paths and include_only_paths are mutually exclusive');
|
|
@@ -311,6 +335,8 @@ class CrawlerConfig {
|
|
|
311
335
|
validateOptions(options) {
|
|
312
336
|
const validKeys = new Set([
|
|
313
337
|
'url',
|
|
338
|
+
'url_list',
|
|
339
|
+
'remote_url_list',
|
|
314
340
|
'page_limit',
|
|
315
341
|
'max_depth',
|
|
316
342
|
'max_duration',
|
|
@@ -358,8 +384,11 @@ class CrawlerConfig {
|
|
|
358
384
|
* defaults (e.g. `respect_robots_txt=true`).
|
|
359
385
|
*/
|
|
360
386
|
toApiParams() {
|
|
361
|
-
const params = {
|
|
387
|
+
const params = {};
|
|
362
388
|
const fields = [
|
|
389
|
+
'url',
|
|
390
|
+
'url_list',
|
|
391
|
+
'remote_url_list',
|
|
363
392
|
'page_limit',
|
|
364
393
|
'max_depth',
|
|
365
394
|
'max_duration',
|
|
@@ -209,7 +209,7 @@ class ExtractionConfig {
|
|
|
209
209
|
throw new errors_js_1.ExtractionConfigError('You cannot pass both parameters extraction_template and extraction_ephemeral_template. You must choose');
|
|
210
210
|
}
|
|
211
211
|
if (this.extraction_template) {
|
|
212
|
-
params.extraction_template = this.extraction_template;
|
|
212
|
+
params.extraction_template = 'persistent:' + this.extraction_template;
|
|
213
213
|
}
|
|
214
214
|
if (this.extraction_ephemeral_template) {
|
|
215
215
|
params.extraction_template = 'ephemeral:' + (0, utils_js_1.urlsafe_b64encode)(JSON.stringify(this.extraction_ephemeral_template));
|
package/script/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/script/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,IAAI,gBAAgB,EAC1B,OAAO,IAAI,iBAAiB,EAC5B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/E,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,mFAAmF;AACnF,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGzI,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACn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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/script/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;IACvC,IAAI,SAAS;IACb,sCAAsC;IACtC,QAAQ,aAAa;IACrB,gCAAgC;IAChC,UAAU,eAAe;IACzB,0CAA0C;IAC1C,GAAG,QAAQ;CACZ;AAED,+DAA+D;AAC/D,oBAAY,YAAY;IACtB,wCAAwC;IACxC,QAAQ,aAAa;IACrB,oCAAoC;IACpC,SAAS,cAAc;IACvB,4EAA4E;IAC5E,YAAY,iBAAiB;CAC9B;AAED,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EA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AAa,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/script/scrapeconfig.js
CHANGED
|
@@ -236,7 +236,7 @@ class ScrapeConfig {
|
|
|
236
236
|
enumerable: true,
|
|
237
237
|
configurable: true,
|
|
238
238
|
writable: true,
|
|
239
|
-
value:
|
|
239
|
+
value: true
|
|
240
240
|
});
|
|
241
241
|
Object.defineProperty(this, "screenshots", {
|
|
242
242
|
enumerable: true,
|
|
@@ -547,7 +547,7 @@ class ScrapeConfig {
|
|
|
547
547
|
throw new errors_js_1.ScrapeConfigError('You cannot pass both parameters extraction_template and extraction_ephemeral_template. You must choose');
|
|
548
548
|
}
|
|
549
549
|
if (this.extraction_template) {
|
|
550
|
-
params.extraction_template = this.extraction_template;
|
|
550
|
+
params.extraction_template = 'persistent:' + this.extraction_template;
|
|
551
551
|
}
|
|
552
552
|
if (this.extraction_ephemeral_template) {
|
|
553
553
|
params.extraction_template = 'ephemeral:' + (0, utils_js_1.urlsafe_b64encode)(JSON.stringify(this.extraction_ephemeral_template));
|
|
@@ -563,9 +563,7 @@ class ScrapeConfig {
|
|
|
563
563
|
}
|
|
564
564
|
if (this.session) {
|
|
565
565
|
params.session = this.session;
|
|
566
|
-
|
|
567
|
-
params.session_sticky_proxy = true;
|
|
568
|
-
}
|
|
566
|
+
params.session_sticky_proxy = this.session_sticky_proxy;
|
|
569
567
|
}
|
|
570
568
|
else {
|
|
571
569
|
if (this.session_sticky_proxy) {
|
|
@@ -603,3 +601,9 @@ Object.defineProperty(ScrapeConfig, "PUBLIC_RESIDENTIAL_POOL", {
|
|
|
603
601
|
writable: true,
|
|
604
602
|
value: 'public_residential_pool'
|
|
605
603
|
});
|
|
604
|
+
Object.defineProperty(ScrapeConfig, "PUBLIC_TOR_POOL", {
|
|
605
|
+
enumerable: true,
|
|
606
|
+
configurable: true,
|
|
607
|
+
writable: true,
|
|
608
|
+
value: 'public_tor_pool'
|
|
609
|
+
});
|