wrc-ts 0.1.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/LICENSE +21 -0
- package/README.md +123 -0
- package/dist/browser.d.ts +39 -0
- package/dist/browser.js +43 -0
- package/dist/client.d.ts +840 -0
- package/dist/client.js +1264 -0
- package/dist/config.d.ts +65 -0
- package/dist/config.js +78 -0
- package/dist/cookies.d.ts +21 -0
- package/dist/cookies.js +1 -0
- package/dist/defaults.d.ts +19 -0
- package/dist/defaults.js +22 -0
- package/dist/errors.d.ts +18 -0
- package/dist/errors.js +21 -0
- package/dist/gen/google/protobuf/empty_pb.d.ts +15 -0
- package/dist/gen/google/protobuf/empty_pb.js +13 -0
- package/dist/gen/wrc_pb.d.ts +2189 -0
- package/dist/gen/wrc_pb.js +328 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.js +134 -0
- package/dist/internal/convert.d.ts +44 -0
- package/dist/internal/convert.js +250 -0
- package/dist/locator.d.ts +191 -0
- package/dist/locator.js +255 -0
- package/dist/network.d.ts +37 -0
- package/dist/network.js +2 -0
- package/dist/options.d.ts +96 -0
- package/dist/options.js +7 -0
- package/dist/storage.d.ts +14 -0
- package/dist/storage.js +1 -0
- package/dist/types.d.ts +161 -0
- package/dist/types.js +3 -0
- package/dist/wrc.browser.js +5627 -0
- package/dist/ws-transport.d.ts +15 -0
- package/dist/ws-transport.js +99 -0
- package/package.json +80 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for renting a browser session.
|
|
3
|
+
* Create with the required parameters, then chain optional setters.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const config = new BrowserConfig("api-key", 300, "proxy.example.com", 8080, "user", "pass")
|
|
7
|
+
* .withCountryCode("DE")
|
|
8
|
+
* .withTimezone("Europe/Berlin");
|
|
9
|
+
*/
|
|
10
|
+
export declare class BrowserConfig {
|
|
11
|
+
readonly apiKey: string;
|
|
12
|
+
readonly rentDuration: number;
|
|
13
|
+
readonly proxyHost: string;
|
|
14
|
+
readonly proxyPort: number;
|
|
15
|
+
readonly proxyUsername: string;
|
|
16
|
+
readonly proxyPassword: string;
|
|
17
|
+
private _countryCode?;
|
|
18
|
+
private _timezone?;
|
|
19
|
+
private _fingerprint?;
|
|
20
|
+
constructor(apiKey: string, rentDuration: number, proxyHost: string, proxyPort: number, proxyUsername: string, proxyPassword: string);
|
|
21
|
+
/**
|
|
22
|
+
* Sets the geo-IP country code for the rented session.
|
|
23
|
+
*
|
|
24
|
+
* Drives both the assigned exit-IP region and the locale defaults
|
|
25
|
+
* (Accept-Language, timezone fallback) when those are not overridden
|
|
26
|
+
* separately.
|
|
27
|
+
*
|
|
28
|
+
* @param countryCode - ISO-3166 country code (e.g. "DE", "US")
|
|
29
|
+
*
|
|
30
|
+
* @returns this BrowserConfig for chaining
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* new BrowserConfig(apiKey, 600, "", 0, "", "").withCountryCode("DE");
|
|
34
|
+
*/
|
|
35
|
+
withCountryCode(countryCode: string): BrowserConfig;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the IANA timezone for the rented session.
|
|
38
|
+
*
|
|
39
|
+
* @param timezone - IANA timezone (e.g. "Europe/Berlin")
|
|
40
|
+
*
|
|
41
|
+
* @returns this BrowserConfig for chaining
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* new BrowserConfig(apiKey, 600, "", 0, "", "").withTimezone("Europe/Berlin");
|
|
45
|
+
*/
|
|
46
|
+
withTimezone(timezone: string): BrowserConfig;
|
|
47
|
+
/**
|
|
48
|
+
* Pins a specific browser fingerprint id for the session.
|
|
49
|
+
*
|
|
50
|
+
* When omitted the server picks a fingerprint based on the country
|
|
51
|
+
* code. Pass a known id (e.g. one returned by a previous rental) to
|
|
52
|
+
* keep fingerprints stable across sessions.
|
|
53
|
+
*
|
|
54
|
+
* @param fingerprint - server-side fingerprint id
|
|
55
|
+
*
|
|
56
|
+
* @returns this BrowserConfig for chaining
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* new BrowserConfig(apiKey, 600, "", 0, "", "").withFingerprint("fp_abc123");
|
|
60
|
+
*/
|
|
61
|
+
withFingerprint(fingerprint: string): BrowserConfig;
|
|
62
|
+
get countryCode(): string | undefined;
|
|
63
|
+
get timezone(): string | undefined;
|
|
64
|
+
get fingerprint(): string | undefined;
|
|
65
|
+
}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for renting a browser session.
|
|
3
|
+
* Create with the required parameters, then chain optional setters.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const config = new BrowserConfig("api-key", 300, "proxy.example.com", 8080, "user", "pass")
|
|
7
|
+
* .withCountryCode("DE")
|
|
8
|
+
* .withTimezone("Europe/Berlin");
|
|
9
|
+
*/
|
|
10
|
+
export class BrowserConfig {
|
|
11
|
+
constructor(apiKey, rentDuration, proxyHost, proxyPort, proxyUsername, proxyPassword) {
|
|
12
|
+
this.apiKey = apiKey;
|
|
13
|
+
this.rentDuration = rentDuration;
|
|
14
|
+
this.proxyHost = proxyHost;
|
|
15
|
+
this.proxyPort = proxyPort;
|
|
16
|
+
this.proxyUsername = proxyUsername;
|
|
17
|
+
this.proxyPassword = proxyPassword;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Sets the geo-IP country code for the rented session.
|
|
21
|
+
*
|
|
22
|
+
* Drives both the assigned exit-IP region and the locale defaults
|
|
23
|
+
* (Accept-Language, timezone fallback) when those are not overridden
|
|
24
|
+
* separately.
|
|
25
|
+
*
|
|
26
|
+
* @param countryCode - ISO-3166 country code (e.g. "DE", "US")
|
|
27
|
+
*
|
|
28
|
+
* @returns this BrowserConfig for chaining
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* new BrowserConfig(apiKey, 600, "", 0, "", "").withCountryCode("DE");
|
|
32
|
+
*/
|
|
33
|
+
withCountryCode(countryCode) {
|
|
34
|
+
this._countryCode = countryCode;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Sets the IANA timezone for the rented session.
|
|
39
|
+
*
|
|
40
|
+
* @param timezone - IANA timezone (e.g. "Europe/Berlin")
|
|
41
|
+
*
|
|
42
|
+
* @returns this BrowserConfig for chaining
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* new BrowserConfig(apiKey, 600, "", 0, "", "").withTimezone("Europe/Berlin");
|
|
46
|
+
*/
|
|
47
|
+
withTimezone(timezone) {
|
|
48
|
+
this._timezone = timezone;
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Pins a specific browser fingerprint id for the session.
|
|
53
|
+
*
|
|
54
|
+
* When omitted the server picks a fingerprint based on the country
|
|
55
|
+
* code. Pass a known id (e.g. one returned by a previous rental) to
|
|
56
|
+
* keep fingerprints stable across sessions.
|
|
57
|
+
*
|
|
58
|
+
* @param fingerprint - server-side fingerprint id
|
|
59
|
+
*
|
|
60
|
+
* @returns this BrowserConfig for chaining
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* new BrowserConfig(apiKey, 600, "", 0, "", "").withFingerprint("fp_abc123");
|
|
64
|
+
*/
|
|
65
|
+
withFingerprint(fingerprint) {
|
|
66
|
+
this._fingerprint = fingerprint;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
get countryCode() {
|
|
70
|
+
return this._countryCode;
|
|
71
|
+
}
|
|
72
|
+
get timezone() {
|
|
73
|
+
return this._timezone;
|
|
74
|
+
}
|
|
75
|
+
get fingerprint() {
|
|
76
|
+
return this._fingerprint;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Partition metadata for partitioned cookies (CHIPS). */
|
|
2
|
+
export interface CookiePartitionKey {
|
|
3
|
+
topLevelSite: string;
|
|
4
|
+
hasCrossSiteAncestor: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** CookieParam is one entry returned by getCookies() or passed to setCookies(). */
|
|
7
|
+
export interface CookieParam {
|
|
8
|
+
name: string;
|
|
9
|
+
value: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
domain: string;
|
|
12
|
+
path: string;
|
|
13
|
+
secure?: boolean;
|
|
14
|
+
httpOnly?: boolean;
|
|
15
|
+
sameSite?: string;
|
|
16
|
+
expires?: number;
|
|
17
|
+
priority?: string;
|
|
18
|
+
sourceScheme?: string;
|
|
19
|
+
sourcePort?: number;
|
|
20
|
+
partitionKey?: CookiePartitionKey;
|
|
21
|
+
}
|
package/dist/cookies.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default timeout (ms) used by wait() / waitAny() when no opts.timeoutMs
|
|
3
|
+
* is passed.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DefaultWaitTimeoutMs = 30000;
|
|
6
|
+
/**
|
|
7
|
+
* Default visibility flag baked into css(...) and js(...). For JS
|
|
8
|
+
* expressions returning a non-Element value (boolean, string, number,
|
|
9
|
+
* plain object) this flag is a no-op. Use .visible(false) on the returned
|
|
10
|
+
* Locator to opt out.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DefaultVisible = true;
|
|
13
|
+
/**
|
|
14
|
+
* Default steady-time (ms) baked into css(...) and js(...). For JS
|
|
15
|
+
* expressions returning a non-Element value this is a no-op. Use
|
|
16
|
+
* .steady(ms) (or .steady(0) to disable) on the returned Locator to
|
|
17
|
+
* override.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DefaultSteadyMs = 500;
|
package/dist/defaults.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Defaults the SDK applies automatically before sending a request. Any
|
|
2
|
+
// field not listed here is left unset on the wire and follows the WRC API's
|
|
3
|
+
// server-side default.
|
|
4
|
+
/**
|
|
5
|
+
* Default timeout (ms) used by wait() / waitAny() when no opts.timeoutMs
|
|
6
|
+
* is passed.
|
|
7
|
+
*/
|
|
8
|
+
export const DefaultWaitTimeoutMs = 30000;
|
|
9
|
+
/**
|
|
10
|
+
* Default visibility flag baked into css(...) and js(...). For JS
|
|
11
|
+
* expressions returning a non-Element value (boolean, string, number,
|
|
12
|
+
* plain object) this flag is a no-op. Use .visible(false) on the returned
|
|
13
|
+
* Locator to opt out.
|
|
14
|
+
*/
|
|
15
|
+
export const DefaultVisible = true;
|
|
16
|
+
/**
|
|
17
|
+
* Default steady-time (ms) baked into css(...) and js(...). For JS
|
|
18
|
+
* expressions returning a non-Element value this is a no-op. Use
|
|
19
|
+
* .steady(ms) (or .steady(0) to disable) on the returned Locator to
|
|
20
|
+
* override.
|
|
21
|
+
*/
|
|
22
|
+
export const DefaultSteadyMs = 500;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WRCError is the single error type thrown by all SDK methods. It wraps
|
|
3
|
+
* either:
|
|
4
|
+
* - a client-side validation failure (bad locator, missing patterns, …)
|
|
5
|
+
* - a server-side gRPC error (Connect's ConnectError, available as `cause`)
|
|
6
|
+
*
|
|
7
|
+
* Catch it with `instanceof WRCError`:
|
|
8
|
+
*
|
|
9
|
+
* try {
|
|
10
|
+
* await browser.click(css("#btn"));
|
|
11
|
+
* } catch (e) {
|
|
12
|
+
* if (e instanceof WRCError) { ... }
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export declare class WRCError extends Error {
|
|
16
|
+
readonly cause?: unknown | undefined;
|
|
17
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
18
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WRCError is the single error type thrown by all SDK methods. It wraps
|
|
3
|
+
* either:
|
|
4
|
+
* - a client-side validation failure (bad locator, missing patterns, …)
|
|
5
|
+
* - a server-side gRPC error (Connect's ConnectError, available as `cause`)
|
|
6
|
+
*
|
|
7
|
+
* Catch it with `instanceof WRCError`:
|
|
8
|
+
*
|
|
9
|
+
* try {
|
|
10
|
+
* await browser.click(css("#btn"));
|
|
11
|
+
* } catch (e) {
|
|
12
|
+
* if (e instanceof WRCError) { ... }
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export class WRCError extends Error {
|
|
16
|
+
constructor(message, cause) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.cause = cause;
|
|
19
|
+
this.name = "WRCError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
|
|
2
|
+
import type { Message } from "@bufbuild/protobuf";
|
|
3
|
+
/**
|
|
4
|
+
* Describes the file google/protobuf/empty.proto.
|
|
5
|
+
*/
|
|
6
|
+
export declare const file_google_protobuf_empty: GenFile;
|
|
7
|
+
/**
|
|
8
|
+
* @generated from message google.protobuf.Empty
|
|
9
|
+
*/
|
|
10
|
+
export type Empty = Message<"google.protobuf.Empty"> & {};
|
|
11
|
+
/**
|
|
12
|
+
* Describes the message google.protobuf.Empty.
|
|
13
|
+
* Use `create(EmptySchema)` to create a new message.
|
|
14
|
+
*/
|
|
15
|
+
export declare const EmptySchema: GenMessage<Empty>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts"
|
|
2
|
+
// @generated from file google/protobuf/empty.proto (package google.protobuf, syntax proto3)
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
import { fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
|
|
5
|
+
/**
|
|
6
|
+
* Describes the file google/protobuf/empty.proto.
|
|
7
|
+
*/
|
|
8
|
+
export const file_google_protobuf_empty = /*@__PURE__*/ fileDesc("Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1ZiIHCgVFbXB0eUIwWi5nb29nbGUuZ29sYW5nLm9yZy9wcm90b2J1Zi90eXBlcy9rbm93bi9lbXB0eXBiYgZwcm90bzM");
|
|
9
|
+
/**
|
|
10
|
+
* Describes the message google.protobuf.Empty.
|
|
11
|
+
* Use `create(EmptySchema)` to create a new message.
|
|
12
|
+
*/
|
|
13
|
+
export const EmptySchema = /*@__PURE__*/ messageDesc(file_google_protobuf_empty, 0);
|