surfsky 0.0.1 → 0.0.2
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 +13 -66
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,7 +47,9 @@ import { Surfsky } from "surfsky";
|
|
|
47
47
|
// or new Surfsky({ apiToken: "...", baseUrl: "..." }) instead of env vars
|
|
48
48
|
await using client = new Surfsky();
|
|
49
49
|
// starts a session, stops it when the block ends so it doesn't keep billing
|
|
50
|
-
await using browser = await client.browser({
|
|
50
|
+
await using browser = await client.browser({
|
|
51
|
+
proxy: { tier: "premium", country: "us" },
|
|
52
|
+
});
|
|
51
53
|
await browser.goto("https://duckduckgo.com", { waitUntil: "domcontentloaded" });
|
|
52
54
|
await browser.type('[name="q"]', "surfsky cloud browser");
|
|
53
55
|
await browser.click("#searchbox_homepage button[type=submit]");
|
|
@@ -125,7 +127,8 @@ If you need more control, write your own loop on top of the pool:
|
|
|
125
127
|
|
|
126
128
|
```ts
|
|
127
129
|
await using pool = await client.browsers();
|
|
128
|
-
await pool.lease(async (browser) => {
|
|
130
|
+
await pool.lease(async (browser) => {
|
|
131
|
+
// waits for a free browser
|
|
129
132
|
await browser.goto("https://example.com");
|
|
130
133
|
console.log(await browser.title());
|
|
131
134
|
});
|
|
@@ -179,12 +182,14 @@ built-in pools:
|
|
|
179
182
|
import { ProxyCycle, ProxyTemplate } from "surfsky";
|
|
180
183
|
|
|
181
184
|
proxy = { tier: "premium", country: "us", region: "ny", type: "mobile" }; // Surfsky premium
|
|
182
|
-
proxy = { tier: "shared", country: "us" };
|
|
183
|
-
proxy = { country: "de" };
|
|
184
|
-
proxy = "socks5://user:pass@host:1080";
|
|
185
|
-
proxy = new ProxyCycle(myProxies);
|
|
186
|
-
proxy = new ProxyTemplate(
|
|
187
|
-
|
|
185
|
+
proxy = { tier: "shared", country: "us" }; // Surfsky shared, for tests
|
|
186
|
+
proxy = { country: "de" }; // premium if set up, else shared
|
|
187
|
+
proxy = "socks5://user:pass@host:1080"; // your own
|
|
188
|
+
proxy = new ProxyCycle(myProxies); // round-robin over your own list
|
|
189
|
+
proxy = new ProxyTemplate(
|
|
190
|
+
"http://user-sessid-{session}:pw@gate.example.com:7000",
|
|
191
|
+
);
|
|
192
|
+
proxy = async () => pickOne(); // any function, sync or async
|
|
188
193
|
```
|
|
189
194
|
|
|
190
195
|
`client.proxies` lists available countries, regions and cities, plus your quota.
|
|
@@ -408,64 +413,6 @@ Live tests start real sessions and bill your account:
|
|
|
408
413
|
SURFSKY_LIVE_TESTS=1 SURFSKY_API_TOKEN=... SURFSKY_API_BASE_URL=... bun run test:live
|
|
409
414
|
```
|
|
410
415
|
|
|
411
|
-
## Releasing
|
|
412
|
-
|
|
413
|
-
One-time, GitHub:
|
|
414
|
-
|
|
415
|
-
```sh
|
|
416
|
-
gh repo create surfskyio/surfsky-js --public --source=. --remote=origin --push
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
CI (`.github/workflows/ci.yml`) then runs on every push and PR: lint, typecheck,
|
|
420
|
-
tests and a build on Node 22, 24 and 26, plus the same on Bun.
|
|
421
|
-
|
|
422
|
-
One-time, npm: publishing runs from `.github/workflows/release.yml` with no npm
|
|
423
|
-
token, so it needs [trusted
|
|
424
|
-
publishing](https://docs.npmjs.com/trusted-publishers) configured for the
|
|
425
|
-
package — provider GitHub Actions, repository `surfskyio/surfsky-js`, workflow
|
|
426
|
-
`release.yml`, environment `npm`, publish allowed. A trusted publisher is a
|
|
427
|
-
setting *on a package*, so the first version goes out by hand:
|
|
428
|
-
|
|
429
|
-
```sh
|
|
430
|
-
npm login
|
|
431
|
-
bun run check && bun run build
|
|
432
|
-
npm publish # no --provenance: that needs the OIDC token only CI has
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
Then attach the publisher, on npmjs.com under the package's settings or, with
|
|
436
|
-
npm new enough to have the command, from the shell:
|
|
437
|
-
|
|
438
|
-
```sh
|
|
439
|
-
npm trust github surfsky --repo surfskyio/surfsky-js --file release.yml \
|
|
440
|
-
--env npm --allow-publish
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
The alternative to all of it is a granular access token in the repo as
|
|
444
|
-
`NPM_TOKEN`, with `NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}` added to the
|
|
445
|
-
publish step.
|
|
446
|
-
|
|
447
|
-
Two things bite here: npm never validates a trusted-publisher config when you
|
|
448
|
-
save it, so a wrong workflow name surfaces only as a failed publish, and
|
|
449
|
-
`repository.url` in `package.json` has to match the GitHub repository exactly.
|
|
450
|
-
|
|
451
|
-
The `npm` environment is also where a required reviewer goes, if a release
|
|
452
|
-
should wait for an approval.
|
|
453
|
-
|
|
454
|
-
Every release after that is a tag:
|
|
455
|
-
|
|
456
|
-
```sh
|
|
457
|
-
# bump "version" in package.json first
|
|
458
|
-
bun run check && bun run build
|
|
459
|
-
git commit -am "release: v0.1.0"
|
|
460
|
-
git tag v0.1.0
|
|
461
|
-
git push origin main --tags
|
|
462
|
-
```
|
|
463
|
-
|
|
464
|
-
The workflow refuses to publish when the tag and `package.json` disagree, then
|
|
465
|
-
runs `bun run check`, builds, imports `dist/index.js` once to prove the bundle
|
|
466
|
-
loads, and publishes. `files` limits the tarball to `dist/`, `README.md`,
|
|
467
|
-
`LICENSE` and `package.json` - check it with `npm pack --dry-run`.
|
|
468
|
-
|
|
469
416
|
## License
|
|
470
417
|
|
|
471
418
|
MIT
|
package/dist/index.js
CHANGED