@aws-sdk/middleware-websocket 3.515.0 → 3.521.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/dist-cjs/index.js
CHANGED
|
@@ -241,11 +241,26 @@ var _WebSocketFetchHandler = class _WebSocketFetchHandler {
|
|
|
241
241
|
this.sockets = {};
|
|
242
242
|
this.httpHandler = httpHandler;
|
|
243
243
|
if (typeof options === "function") {
|
|
244
|
-
this.
|
|
244
|
+
this.config = {};
|
|
245
|
+
this.configPromise = options().then((opts) => this.config = opts ?? {});
|
|
245
246
|
} else {
|
|
246
|
-
this.
|
|
247
|
+
this.config = options ?? {};
|
|
248
|
+
this.configPromise = Promise.resolve(this.config);
|
|
247
249
|
}
|
|
248
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* @returns the input if it is an HttpHandler of any class,
|
|
253
|
+
* or instantiates a new instance of this handler.
|
|
254
|
+
*/
|
|
255
|
+
static create(instanceOrOptions, httpHandler = new import_fetch_http_handler.FetchHttpHandler()) {
|
|
256
|
+
if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
|
|
257
|
+
return instanceOrOptions;
|
|
258
|
+
}
|
|
259
|
+
return new _WebSocketFetchHandler(
|
|
260
|
+
instanceOrOptions,
|
|
261
|
+
httpHandler
|
|
262
|
+
);
|
|
263
|
+
}
|
|
249
264
|
/**
|
|
250
265
|
* Destroys the WebSocketHandler.
|
|
251
266
|
* Closes all sockets from the socket pool.
|
|
@@ -269,7 +284,8 @@ var _WebSocketFetchHandler = class _WebSocketFetchHandler {
|
|
|
269
284
|
}
|
|
270
285
|
this.sockets[url].push(socket);
|
|
271
286
|
socket.binaryType = "arraybuffer";
|
|
272
|
-
|
|
287
|
+
this.config = await this.configPromise;
|
|
288
|
+
const { connectionTimeout = DEFAULT_WS_CONNECTION_TIMEOUT_MS } = this.config;
|
|
273
289
|
await this.waitForReady(socket, connectionTimeout);
|
|
274
290
|
const { body } = request;
|
|
275
291
|
const bodyStream = getIterator(body);
|
|
@@ -283,6 +299,15 @@ var _WebSocketFetchHandler = class _WebSocketFetchHandler {
|
|
|
283
299
|
})
|
|
284
300
|
};
|
|
285
301
|
}
|
|
302
|
+
updateHttpClientConfig(key, value) {
|
|
303
|
+
this.configPromise = this.configPromise.then((config) => {
|
|
304
|
+
config[key] = value;
|
|
305
|
+
return config;
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
httpHandlerConfigs() {
|
|
309
|
+
return this.config ?? {};
|
|
310
|
+
}
|
|
286
311
|
/**
|
|
287
312
|
* Removes all closing/closed sockets from the socket pool for URL.
|
|
288
313
|
*/
|
|
@@ -5,6 +5,12 @@ import { HttpResponse } from "@smithy/protocol-http";
|
|
|
5
5
|
import { isWebSocketRequest } from "./utils";
|
|
6
6
|
const DEFAULT_WS_CONNECTION_TIMEOUT_MS = 2000;
|
|
7
7
|
export class WebSocketFetchHandler {
|
|
8
|
+
static create(instanceOrOptions, httpHandler = new FetchHttpHandler()) {
|
|
9
|
+
if (typeof instanceOrOptions?.handle === "function") {
|
|
10
|
+
return instanceOrOptions;
|
|
11
|
+
}
|
|
12
|
+
return new WebSocketFetchHandler(instanceOrOptions, httpHandler);
|
|
13
|
+
}
|
|
8
14
|
constructor(options, httpHandler = new FetchHttpHandler()) {
|
|
9
15
|
this.metadata = {
|
|
10
16
|
handlerProtocol: "websocket/h1.1",
|
|
@@ -12,10 +18,12 @@ export class WebSocketFetchHandler {
|
|
|
12
18
|
this.sockets = {};
|
|
13
19
|
this.httpHandler = httpHandler;
|
|
14
20
|
if (typeof options === "function") {
|
|
15
|
-
this.
|
|
21
|
+
this.config = {};
|
|
22
|
+
this.configPromise = options().then((opts) => (this.config = opts ?? {}));
|
|
16
23
|
}
|
|
17
24
|
else {
|
|
18
|
-
this.
|
|
25
|
+
this.config = options ?? {};
|
|
26
|
+
this.configPromise = Promise.resolve(this.config);
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
destroy() {
|
|
@@ -37,7 +45,8 @@ export class WebSocketFetchHandler {
|
|
|
37
45
|
}
|
|
38
46
|
this.sockets[url].push(socket);
|
|
39
47
|
socket.binaryType = "arraybuffer";
|
|
40
|
-
|
|
48
|
+
this.config = await this.configPromise;
|
|
49
|
+
const { connectionTimeout = DEFAULT_WS_CONNECTION_TIMEOUT_MS } = this.config;
|
|
41
50
|
await this.waitForReady(socket, connectionTimeout);
|
|
42
51
|
const { body } = request;
|
|
43
52
|
const bodyStream = getIterator(body);
|
|
@@ -50,6 +59,15 @@ export class WebSocketFetchHandler {
|
|
|
50
59
|
}),
|
|
51
60
|
};
|
|
52
61
|
}
|
|
62
|
+
updateHttpClientConfig(key, value) {
|
|
63
|
+
this.configPromise = this.configPromise.then((config) => {
|
|
64
|
+
config[key] = value;
|
|
65
|
+
return config;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
httpHandlerConfigs() {
|
|
69
|
+
return this.config ?? {};
|
|
70
|
+
}
|
|
53
71
|
removeNotUsableSockets(url) {
|
|
54
72
|
this.sockets[url] = (this.sockets[url] ?? []).filter((socket) => ![WebSocket.CLOSING, WebSocket.CLOSED].includes(socket.readyState));
|
|
55
73
|
}
|
|
@@ -9,9 +9,17 @@ export interface WebSocketFetchHandlerOptions {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class WebSocketFetchHandler {
|
|
11
11
|
readonly metadata: RequestHandlerMetadata;
|
|
12
|
-
private
|
|
12
|
+
private config;
|
|
13
|
+
private configPromise;
|
|
13
14
|
private readonly httpHandler;
|
|
14
15
|
private readonly sockets;
|
|
16
|
+
static create(
|
|
17
|
+
instanceOrOptions?:
|
|
18
|
+
| WebSocketFetchHandler
|
|
19
|
+
| WebSocketFetchHandlerOptions
|
|
20
|
+
| Provider<WebSocketFetchHandlerOptions | void>,
|
|
21
|
+
httpHandler?: RequestHandler<any, any>
|
|
22
|
+
): WebSocketFetchHandler;
|
|
15
23
|
constructor(
|
|
16
24
|
options?:
|
|
17
25
|
| WebSocketFetchHandlerOptions
|
|
@@ -22,6 +30,11 @@ export declare class WebSocketFetchHandler {
|
|
|
22
30
|
handle(request: HttpRequest): Promise<{
|
|
23
31
|
response: HttpResponse;
|
|
24
32
|
}>;
|
|
33
|
+
updateHttpClientConfig(
|
|
34
|
+
key: keyof WebSocketFetchHandlerOptions,
|
|
35
|
+
value: WebSocketFetchHandlerOptions[typeof key]
|
|
36
|
+
): void;
|
|
37
|
+
httpHandlerConfigs(): WebSocketFetchHandlerOptions;
|
|
25
38
|
private removeNotUsableSockets;
|
|
26
39
|
private waitForReady;
|
|
27
40
|
private connect;
|
|
@@ -15,9 +15,15 @@ export interface WebSocketFetchHandlerOptions {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare class WebSocketFetchHandler {
|
|
17
17
|
readonly metadata: RequestHandlerMetadata;
|
|
18
|
-
private
|
|
18
|
+
private config;
|
|
19
|
+
private configPromise;
|
|
19
20
|
private readonly httpHandler;
|
|
20
21
|
private readonly sockets;
|
|
22
|
+
/**
|
|
23
|
+
* @returns the input if it is an HttpHandler of any class,
|
|
24
|
+
* or instantiates a new instance of this handler.
|
|
25
|
+
*/
|
|
26
|
+
static create(instanceOrOptions?: WebSocketFetchHandler | WebSocketFetchHandlerOptions | Provider<WebSocketFetchHandlerOptions | void>, httpHandler?: RequestHandler<any, any>): WebSocketFetchHandler;
|
|
21
27
|
constructor(options?: WebSocketFetchHandlerOptions | Provider<WebSocketFetchHandlerOptions>, httpHandler?: RequestHandler<any, any>);
|
|
22
28
|
/**
|
|
23
29
|
* Destroys the WebSocketHandler.
|
|
@@ -27,6 +33,8 @@ export declare class WebSocketFetchHandler {
|
|
|
27
33
|
handle(request: HttpRequest): Promise<{
|
|
28
34
|
response: HttpResponse;
|
|
29
35
|
}>;
|
|
36
|
+
updateHttpClientConfig(key: keyof WebSocketFetchHandlerOptions, value: WebSocketFetchHandlerOptions[typeof key]): void;
|
|
37
|
+
httpHandlerConfigs(): WebSocketFetchHandlerOptions;
|
|
30
38
|
/**
|
|
31
39
|
* Removes all closing/closed sockets from the socket pool for URL.
|
|
32
40
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-websocket",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.521.0",
|
|
4
4
|
"main": "./dist-cjs/index.js",
|
|
5
5
|
"module": "./dist-es/index.js",
|
|
6
6
|
"types": "./dist-types/index.d.ts",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@aws-sdk/middleware-signing": "3.
|
|
25
|
-
"@aws-sdk/types": "3.
|
|
26
|
-
"@aws-sdk/util-format-url": "3.
|
|
24
|
+
"@aws-sdk/middleware-signing": "3.521.0",
|
|
25
|
+
"@aws-sdk/types": "3.521.0",
|
|
26
|
+
"@aws-sdk/util-format-url": "3.521.0",
|
|
27
27
|
"@smithy/eventstream-codec": "^2.1.1",
|
|
28
|
-
"@smithy/eventstream-serde-browser": "^2.1.
|
|
29
|
-
"@smithy/fetch-http-handler": "^2.4.
|
|
30
|
-
"@smithy/protocol-http": "^3.
|
|
28
|
+
"@smithy/eventstream-serde-browser": "^2.1.2",
|
|
29
|
+
"@smithy/fetch-http-handler": "^2.4.2",
|
|
30
|
+
"@smithy/protocol-http": "^3.2.0",
|
|
31
31
|
"@smithy/signature-v4": "^2.1.1",
|
|
32
|
-
"@smithy/types": "^2.
|
|
32
|
+
"@smithy/types": "^2.10.0",
|
|
33
33
|
"@smithy/util-hex-encoding": "^2.1.1",
|
|
34
34
|
"tslib": "^2.5.0"
|
|
35
35
|
},
|