@appium/base-driver 10.2.1 → 10.3.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/build/lib/basedriver/commands/execute.js +2 -1
- package/build/lib/basedriver/commands/execute.js.map +1 -1
- package/build/lib/jsonwp-proxy/protocol-converter.d.ts +42 -78
- package/build/lib/jsonwp-proxy/protocol-converter.d.ts.map +1 -1
- package/build/lib/jsonwp-proxy/protocol-converter.js +87 -139
- package/build/lib/jsonwp-proxy/protocol-converter.js.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.d.ts +52 -97
- package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.js +98 -141
- package/build/lib/jsonwp-proxy/proxy.js.map +1 -1
- package/lib/basedriver/commands/execute.ts +2 -1
- package/lib/jsonwp-proxy/protocol-converter.ts +284 -0
- package/lib/jsonwp-proxy/proxy.ts +506 -0
- package/package.json +9 -9
- package/lib/jsonwp-proxy/protocol-converter.js +0 -317
- package/lib/jsonwp-proxy/proxy.js +0 -493
|
@@ -1,128 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
port: number;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/** @type {string} */
|
|
15
|
-
reqBasePath: string;
|
|
16
|
-
/** @type {string?} */
|
|
1
|
+
import type { AppiumLogger, HTTPBody, HTTPHeaders, HTTPMethod, ProxyOptions, ProxyResponse } from '@appium/types';
|
|
2
|
+
import { PROTOCOLS } from '../constants';
|
|
3
|
+
import { ProtocolConverter } from './protocol-converter';
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
import https from 'node:https';
|
|
6
|
+
import type { Request, Response } from 'express';
|
|
7
|
+
type Protocol = (typeof PROTOCOLS)[keyof typeof PROTOCOLS];
|
|
8
|
+
export declare class JWProxy {
|
|
9
|
+
readonly scheme: string;
|
|
10
|
+
readonly server: string;
|
|
11
|
+
readonly port: number;
|
|
12
|
+
readonly base: string;
|
|
13
|
+
readonly reqBasePath: string;
|
|
17
14
|
sessionId: string | null;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
_downstreamProtocol
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
protocolConverter: ProtocolConverter;
|
|
29
|
-
_log: import("@appium/types").AppiumLogger | undefined;
|
|
30
|
-
get log(): import("@appium/types").AppiumLogger;
|
|
15
|
+
readonly timeout: number;
|
|
16
|
+
readonly headers: HTTPHeaders | undefined;
|
|
17
|
+
readonly httpAgent: http.Agent;
|
|
18
|
+
readonly httpsAgent: https.Agent;
|
|
19
|
+
readonly protocolConverter: ProtocolConverter;
|
|
20
|
+
private _downstreamProtocol;
|
|
21
|
+
private _activeRequests;
|
|
22
|
+
private readonly _log;
|
|
23
|
+
constructor(opts?: ProxyOptions);
|
|
24
|
+
get log(): AppiumLogger;
|
|
31
25
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @private - Do not call this method directly,
|
|
35
|
-
* it uses client-specific arguments and responses!
|
|
36
|
-
*
|
|
37
|
-
* @param {import('axios').RawAxiosRequestConfig} requestConfig
|
|
38
|
-
* @returns {Promise<import('axios').AxiosResponse>}
|
|
26
|
+
* Returns the number of active downstream HTTP requests.
|
|
39
27
|
*/
|
|
40
|
-
|
|
28
|
+
getActiveRequestsCount(): number;
|
|
41
29
|
/**
|
|
42
|
-
*
|
|
30
|
+
* Cancels all currently active downstream HTTP requests.
|
|
43
31
|
*/
|
|
44
|
-
getActiveRequestsCount(): number;
|
|
45
32
|
cancelActiveRequests(): void;
|
|
46
33
|
/**
|
|
47
|
-
*
|
|
34
|
+
* Sets the protocol used by the downstream server (W3C or MJSONWP).
|
|
48
35
|
*/
|
|
49
36
|
set downstreamProtocol(value: Protocol | null | undefined);
|
|
50
|
-
get downstreamProtocol(): Protocol | null | undefined;
|
|
51
37
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param {string} url
|
|
54
|
-
* @param {string} [method]
|
|
55
|
-
* @returns {string}
|
|
38
|
+
* Gets the protocol used by the downstream server (W3C or MJSONWP).
|
|
56
39
|
*/
|
|
57
|
-
|
|
40
|
+
get downstreamProtocol(): Protocol | null | undefined;
|
|
58
41
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @param {string} url
|
|
61
|
-
* @param {string} method
|
|
62
|
-
* @param {import('@appium/types').HTTPBody} [body=null]
|
|
63
|
-
* @returns {Promise<[import('@appium/types').ProxyResponse, import('@appium/types').HTTPBody]>}
|
|
42
|
+
* Builds a full downstream URL (including base path and session) for a given upstream URL.
|
|
64
43
|
*/
|
|
65
|
-
|
|
44
|
+
getUrlForProxy(url: string, method?: HTTPMethod): string;
|
|
66
45
|
/**
|
|
67
|
-
*
|
|
68
|
-
* @param {Record<string, any>} resObj
|
|
69
|
-
* @returns {Protocol | undefined}
|
|
46
|
+
* Proxies a raw WebDriver command to the downstream server.
|
|
70
47
|
*/
|
|
71
|
-
|
|
48
|
+
proxy(url: string, method: string, body?: HTTPBody): Promise<[ProxyResponse, HTTPBody]>;
|
|
72
49
|
/**
|
|
73
|
-
*
|
|
74
|
-
* @param {string} url
|
|
75
|
-
* @param {import('@appium/types').HTTPMethod} method
|
|
76
|
-
* @param {import('@appium/types').HTTPBody} [body=null]
|
|
77
|
-
* @returns {Promise<[import('@appium/types').ProxyResponse, import('@appium/types').HTTPBody]>}
|
|
50
|
+
* Detects the downstream protocol from a response body.
|
|
78
51
|
*/
|
|
79
|
-
|
|
52
|
+
getProtocolFromResBody(resObj: Record<string, unknown>): Protocol | undefined;
|
|
80
53
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @param {string} url
|
|
83
|
-
* @param {import('@appium/types').HTTPMethod} method
|
|
84
|
-
* @param {import('@appium/types').HTTPBody} [body=null]
|
|
85
|
-
* @returns {Promise<import('@appium/types').HTTPBody>}
|
|
54
|
+
* Proxies a command identified by its HTTP method and URL to the downstream server.
|
|
86
55
|
*/
|
|
87
|
-
|
|
56
|
+
proxyCommand(url: string, method: HTTPMethod, body?: HTTPBody): Promise<[ProxyResponse, HTTPBody]>;
|
|
88
57
|
/**
|
|
89
|
-
*
|
|
90
|
-
* @param {string} url
|
|
91
|
-
* @returns {string | null}
|
|
58
|
+
* Executes a WebDriver command and returns the unwrapped `value` field (or throws).
|
|
92
59
|
*/
|
|
93
|
-
|
|
60
|
+
command(url: string, method: HTTPMethod, body?: HTTPBody): Promise<HTTPBody>;
|
|
94
61
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @param {import('express').Request} req
|
|
97
|
-
* @param {import('express').Response} res
|
|
62
|
+
* Extracts a session id from a WebDriver-style URL.
|
|
98
63
|
*/
|
|
99
|
-
|
|
64
|
+
getSessionIdFromUrl(url: string): string | null;
|
|
100
65
|
/**
|
|
66
|
+
* Proxies an Express `Request`/`Response` pair to the downstream server,
|
|
67
|
+
* converting any downstream errors into a proper W3C HTTP response.
|
|
101
68
|
*
|
|
102
|
-
*
|
|
103
|
-
* @returns {ParsedUrl}
|
|
69
|
+
* This method must not throw; it always writes a response.
|
|
104
70
|
*/
|
|
105
|
-
|
|
71
|
+
proxyReqRes(req: Request, res: Response): Promise<void>;
|
|
106
72
|
/**
|
|
73
|
+
* Performs requests to the downstream server
|
|
107
74
|
*
|
|
108
|
-
* @
|
|
109
|
-
*
|
|
75
|
+
* @private - Do not call this method directly,
|
|
76
|
+
* it uses client-specific arguments and responses!
|
|
110
77
|
*/
|
|
111
|
-
|
|
78
|
+
private request;
|
|
79
|
+
private _parseUrl;
|
|
80
|
+
private _toNormalizedPathname;
|
|
112
81
|
}
|
|
113
|
-
export
|
|
114
|
-
export type ProxyError = Error & {
|
|
115
|
-
response: {
|
|
116
|
-
data: import("type-fest").JsonObject;
|
|
117
|
-
status: import("http-status-codes").StatusCodes;
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
export type ParsedUrl = nodeUrl.UrlWithStringQuery;
|
|
121
|
-
export type Protocol = (typeof PROTOCOLS)[keyof typeof PROTOCOLS];
|
|
122
|
-
import { ProxyRequest } from './proxy-request';
|
|
123
|
-
import http from 'node:http';
|
|
124
|
-
import https from 'node:https';
|
|
125
|
-
import ProtocolConverter from './protocol-converter';
|
|
126
|
-
import nodeUrl from 'node:url';
|
|
127
|
-
import { PROTOCOLS } from '../constants';
|
|
82
|
+
export {};
|
|
128
83
|
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../lib/jsonwp-proxy/proxy.
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../lib/jsonwp-proxy/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACd,MAAM,eAAe,CAAC;AAYvB,OAAO,EAAyC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAI/B,OAAO,KAAK,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAW/C,KAAK,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAe3D,qBAAa,OAAO;IAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC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