-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathITransport.ts
61 lines (57 loc) · 2.26 KB
/
ITransport.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import EResult from '../enums-steam/EResult';
/**
* @hidden
*/
export interface ApiRequest {
apiInterface: string;
apiMethod: string;
apiVersion: number;
accessToken?: string;
requestData?: any;
headers?: any;
}
/**
* @hidden
*/
export interface ApiResponse {
result?: EResult;
errorMessage?: string;
responseData?: any;
}
/**
* ```js
* import type {ITransport, ApiRequest, ApiResponse} from 'steam-session';
* ```
*
* It's possible to define a custom transport to be used when interacting with the Steam login server. The default
* transport used to interact with the Steam login server is chosen depending on your provided
* {@link steam-session.EAuthTokenPlatformType}.
*
* For the {@link steam-session.EAuthTokenPlatformType.SteamClient} platform type, a
* [WebSocketCMTransport](https://github.com/DoctorMcKay/node-steam-session/blob/master/src/transports/WebSocketCMTransport.ts)
* will be used to communicate with a CM server using a WebSocket. For other platform types, a
* [WebApiTransport](https://github.com/DoctorMcKay/node-steam-session/blob/master/src/transports/WebApiTransport.ts)
* will be used to interact with the Steam login server using api.steampowered.com.
*
* **You almost definitely don't need to do this.** This is used by steam-user to communicate with the auth server over
* the same channel as the rest of its network communication. Unless this matches your use-case, I cannot think of any
* reason why you'd need to implement your own custom transport unless you for some reason need to tunnel requests over
* an entirely different network protocol. If you simply need to proxy requests, you should instead use
* {@link method-params.ConstructorOptions.httpProxy}, {@link method-params.ConstructorOptions.socksProxy}, or
* {@link method-params.ConstructorOptions.agent}.
*
* @see [ITransport.ts](https://github.com/DoctorMcKay/node-steam-session/blob/master/src/transports/ITransport.ts)
*/
export default interface ITransport {
/**
* Sends a request to Steam.
*
* @param {ApiRequest} request
* @return {Promise<ApiResponse>}
*/
sendRequest(request: ApiRequest): Promise<ApiResponse>;
/**
* Cleans up any resources allocated by the transport.
*/
close(): void;
}