@http-forge/core 0.6.42 → 0.7.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.
@@ -227,6 +227,8 @@ export interface SecretProviderEntry {
227
227
  provider: 'aws' | 'azure' | 'gcp' | 'vault' | '1password' | 'doppler' | 'custom';
228
228
  /** AWS region (aws only) */
229
229
  region?: string;
230
+ /** AWS shared-config profile (aws only; falls back to AWS_PROFILE) */
231
+ profile?: string;
230
232
  /** Azure Key Vault URL (azure only) */
231
233
  vaultUrl?: string;
232
234
  /** GCP project ID (gcp only) */
@@ -11,6 +11,7 @@
11
11
  * Platform-independent — no vscode dependency.
12
12
  */
13
13
  import { IEnvironmentConfigService } from '../../types/environment-config';
14
+ import { IWebSocketClient, ISocketIoClient } from '../../types/platform';
14
15
  import { ExecutionRequest, ExecutionResult, PreparedRequest, RequestAuth, RequestScripts } from '../../types/types';
15
16
  import { IHttpRequestService } from '../http/interfaces';
16
17
  import { ICookieJar, IScriptExecutor } from '../script/interfaces';
@@ -35,7 +36,9 @@ export declare class CollectionRequestExecutor implements ICollectionRequestExec
35
36
  private readonly collectionAuth?;
36
37
  private readonly iteration?;
37
38
  private readonly iterationCount?;
38
- constructor(httpService: IHttpRequestService, scriptExecutor: IScriptExecutor, envConfigService: IEnvironmentConfigService, requestPreparer: IRequestPreparer, environment: string, cookieJar?: ICookieJar | undefined, collectionScripts?: RequestScripts | undefined, folderScriptsChain?: (RequestScripts | RequestScripts[]) | undefined, onConsoleOutput?: ConsoleOutputCallback | undefined, collectionName?: string | undefined, collectionAuth?: RequestAuth | undefined, iteration?: number | undefined, iterationCount?: number | undefined);
39
+ private readonly webSocketClient?;
40
+ private readonly socketIoClient?;
41
+ constructor(httpService: IHttpRequestService, scriptExecutor: IScriptExecutor, envConfigService: IEnvironmentConfigService, requestPreparer: IRequestPreparer, environment: string, cookieJar?: ICookieJar | undefined, collectionScripts?: RequestScripts | undefined, folderScriptsChain?: (RequestScripts | RequestScripts[]) | undefined, onConsoleOutput?: ConsoleOutputCallback | undefined, collectionName?: string | undefined, collectionAuth?: RequestAuth | undefined, iteration?: number | undefined, iterationCount?: number | undefined, webSocketClient?: IWebSocketClient | undefined, socketIoClient?: ISocketIoClient | undefined);
39
42
  /**
40
43
  * Execute a request with full Postman parity.
41
44
  */
@@ -2,7 +2,9 @@
2
2
  * AWS Secrets Manager resolver
3
3
  *
4
4
  * Uses the AWS SDK v3 credential chain — no credentials are stored in HTTP Forge config.
5
- * Order: env vars → ~/.aws/credentials → IAM instance role → ECS task role
5
+ * A configured profile selects ~/.aws/credentials or ~/.aws/config (including SSO)
6
+ * without requiring AWS_PROFILE in the extension host environment.
7
+ * Order: configured profile → env vars → ~/.aws/credentials → IAM instance role → ECS task role
6
8
  *
7
9
  * Token syntax: {{secret:aws/<secretId>}}
8
10
  * e.g. {{secret:aws/myapp/prod/db-password}}
@@ -12,6 +14,7 @@ import type { AwsSecretsConfig, ISecretResolver } from '../../types/secret-resol
12
14
  export declare class AwsSecretResolver implements ISecretResolver {
13
15
  readonly providerName = "aws";
14
16
  private readonly region;
17
+ private readonly profile;
15
18
  private readonly moduleRequire;
16
19
  private sdk?;
17
20
  constructor(config: AwsSecretsConfig, moduleRequire?: (name: string) => any);
@@ -0,0 +1,18 @@
1
+ import type { IDisposable } from '../../types/platform';
2
+ import type { ISocketIoClient, ISocketIoConnection, SocketIoConnectOptions, SocketIoEvent } from '../../types/platform';
3
+ export type { IDisposable, ISocketIoClient, ISocketIoConnection, SocketIoConnectOptions, SocketIoEvent };
4
+ /**
5
+ * Node.js Socket.IO transport adapter.
6
+ *
7
+ * Wraps the lazily loaded `socket.io-client` so Socket.IO requests can run
8
+ * headlessly (collection runner / suite executor) and interactively (Request
9
+ * Tester). `socket.io-client` stays out of the eager bundle.
10
+ */
11
+ export declare class NodeSocketIoClient implements ISocketIoClient {
12
+ connect(options: SocketIoConnectOptions): Promise<ISocketIoConnection>;
13
+ }
14
+ /**
15
+ * Backwards-compatible alias for the extension's previous adapter name.
16
+ */
17
+ export declare class SocketIoClientAdapter extends NodeSocketIoClient {
18
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Node WebSocket client adapter.
3
+ *
4
+ * Uses `ws` lazily so HTTP-only consumers do not load it. The module is
5
+ * intentionally VS Code-free and exposes only the core WebSocket port.
6
+ */
7
+ import { IWebSocketClient, IWebSocketConnection, WebSocketConnectOptions } from '../../types/platform';
8
+ export interface NodeWebSocketClientOptions {
9
+ /** Base directory used to resolve relative TLS certificate paths. */
10
+ basePath?: string;
11
+ }
12
+ /**
13
+ * WebSocket client backed by the `ws` package.
14
+ */
15
+ export declare class NodeWebSocketClient implements IWebSocketClient {
16
+ private readonly options;
17
+ constructor(options?: NodeWebSocketClientOptions);
18
+ connect(options: WebSocketConnectOptions): Promise<IWebSocketConnection>;
19
+ private buildTransportOptions;
20
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Headless Socket.IO request runner.
3
+ *
4
+ * Mirrors `websocket-request-runner.ts` for the Socket.IO flavor: a Socket.IO
5
+ * request is executed as a bounded transcript (connect → emit saved messages
6
+ * → collect events for `websocket.settings.responseTimeout` → disconnect).
7
+ *
8
+ * Socket.IO is a higher-level protocol than raw WebSocket, so this runner
9
+ * talks to the injected `ISocketIoClient` (extension host / Node adapter) and
10
+ * records events + acknowledgements as transcript frames.
11
+ */
12
+ import type { ISocketIoClient } from '../../types/platform';
13
+ import { ExecutionRequest, HttpResponse, PreparedRequest } from '../../types/types';
14
+ export declare const DEFAULT_SOCKETIO_RESPONSE_TIMEOUT_MS = 1000;
15
+ export declare function runSocketIoRequest(client: ISocketIoClient, request: ExecutionRequest, prepared: PreparedRequest, signal?: AbortSignal): Promise<HttpResponse>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Headless WebSocket request runner.
3
+ *
4
+ * Collection/suite execution has no interactive frame stream, so a WebSocket
5
+ * request is executed as a bounded transcript:
6
+ * 1. connect (prepared URL, headers, subprotocols, TLS/timeout settings)
7
+ * 2. send the saved messages in order
8
+ * 3. collect inbound frames for `websocket.settings.responseTimeout`
9
+ * 4. close and return a synthetic `HttpResponse`
10
+ *
11
+ * The response body is a `WebSocketRunTranscript`, exposed to post-response
12
+ * scripts as `pm.response.json()`. The executor owns pre/post script
13
+ * orchestration; this module only owns the socket lifecycle.
14
+ */
15
+ import { IWebSocketClient } from '../../types/platform';
16
+ import { ExecutionRequest, HttpResponse, PreparedRequest } from '../../types/types';
17
+ /** Default time to collect inbound frames after the saved messages are sent. */
18
+ export declare const DEFAULT_WEBSOCKET_RESPONSE_TIMEOUT_MS = 1000;
19
+ /**
20
+ * Execute a WebSocket request headlessly and return its transcript response.
21
+ *
22
+ * Socket.IO requests are rejected for now: the client lives in the extension
23
+ * host so core stays free of `socket.io-client`. A core-side transport port is
24
+ * a separate design decision.
25
+ */
26
+ export declare function runWebSocketRequest(client: IWebSocketClient, request: ExecutionRequest, prepared: PreparedRequest, signal?: AbortSignal): Promise<HttpResponse>;
@@ -8,9 +8,17 @@
8
8
  */
9
9
  import type { ServiceContainer } from '../di/service-container';
10
10
  import type { CollectionRequest } from '../types/collection';
11
- import type { ExecutionRequest, RequestAuth } from '../types/types';
11
+ import type { ExecutionRequest, RequestAuth, RequestType } from '../types/types';
12
12
  export declare function disposeContainerResources(container: ServiceContainer): void;
13
13
  export declare function isEnabled(value: string | undefined): boolean;
14
+ /**
15
+ * Transport-aware success check for run summaries.
16
+ *
17
+ * A successful WebSocket handshake is HTTP 101 (Switching Protocols), which
18
+ * falls outside the 2xx range used for HTTP requests. Suite/direct reporting
19
+ * must not label a working WebSocket run as failed.
20
+ */
21
+ export declare function isSuccessfulExecutionStatus(status: number | undefined, requestType?: RequestType): boolean;
14
22
  export declare function shouldEnforceMaxRequests(): boolean;
15
23
  export declare function getDirectMaxRequestsLimit(): number;
16
24
  export declare function shouldGenerateReports(include: string[], reporters?: string[]): boolean;
@@ -188,13 +188,93 @@ export interface IFileSystem {
188
188
  readDir(dirPath: string): Promise<string[]>;
189
189
  isDirectory(filePath: string): Promise<boolean>;
190
190
  }
191
- import { HttpRequestOptions, HttpResponse } from './types';
191
+ import { HttpRequestOptions, HttpResponse, RequestSettings } from './types';
192
192
  /**
193
193
  * Interface for executing HTTP requests.
194
194
  */
195
195
  export interface IHttpClient {
196
196
  send(options: HttpRequestOptions): Promise<HttpResponse>;
197
197
  }
198
+ /**
199
+ * Options for opening a WebSocket connection.
200
+ */
201
+ export interface WebSocketConnectOptions {
202
+ url: string;
203
+ headers?: Record<string, string>;
204
+ protocols?: string[];
205
+ settings?: RequestSettings;
206
+ /** Maximum accepted message size in bytes. 0 or undefined means unlimited. */
207
+ maxPayloadBytes?: number;
208
+ signal?: AbortSignal;
209
+ }
210
+ /**
211
+ * A single WebSocket message frame.
212
+ *
213
+ * Binary data is exposed as a Uint8Array so the port stays platform-neutral.
214
+ */
215
+ export interface WebSocketFrame {
216
+ data: string | Uint8Array;
217
+ isBinary: boolean;
218
+ }
219
+ /**
220
+ * Close details for a WebSocket connection.
221
+ */
222
+ export interface WebSocketCloseInfo {
223
+ code: number;
224
+ reason: string;
225
+ wasClean: boolean;
226
+ }
227
+ export type WebSocketConnectionState = 'connecting' | 'open' | 'closing' | 'closed';
228
+ /**
229
+ * An open WebSocket connection.
230
+ */
231
+ export interface IWebSocketConnection extends IDisposable {
232
+ readonly state: WebSocketConnectionState;
233
+ readonly negotiatedProtocol: string;
234
+ readonly handshakeHeaders?: Record<string, string>;
235
+ send(data: string | Uint8Array): Promise<void>;
236
+ close(code?: number, reason?: string): Promise<void>;
237
+ onFrame(listener: (frame: WebSocketFrame) => void): IDisposable;
238
+ onClose(listener: (info: WebSocketCloseInfo) => void): IDisposable;
239
+ onError(listener: (error: Error) => void): IDisposable;
240
+ }
241
+ /**
242
+ * Platform abstraction for opening WebSocket connections.
243
+ */
244
+ export interface IWebSocketClient {
245
+ connect(options: WebSocketConnectOptions): Promise<IWebSocketConnection>;
246
+ }
247
+ export interface SocketIoConnectOptions {
248
+ url: string;
249
+ headers?: Record<string, string>;
250
+ path?: string;
251
+ clientVersion?: string;
252
+ namespace?: string;
253
+ auth?: unknown;
254
+ transports?: Array<'websocket' | 'polling'>;
255
+ timeout?: number;
256
+ reconnectionAttempts?: number;
257
+ reconnectionDelay?: number;
258
+ listeners?: string[];
259
+ }
260
+ export interface SocketIoEvent {
261
+ event: string;
262
+ args: unknown[];
263
+ }
264
+ export interface ISocketIoConnection extends IDisposable {
265
+ readonly connected: boolean;
266
+ readonly id?: string;
267
+ send(event: string, args: unknown[], expectAck?: boolean): Promise<unknown[] | undefined>;
268
+ close(): void;
269
+ onEvent(listener: (event: SocketIoEvent) => void): IDisposable;
270
+ onConnect(listener: () => void): IDisposable;
271
+ onDisconnect(listener: (reason: string) => void): IDisposable;
272
+ onReconnectFailed(listener: () => void): IDisposable;
273
+ onError(listener: (error: Error) => void): IDisposable;
274
+ }
275
+ export interface ISocketIoClient {
276
+ connect(options: SocketIoConnectOptions): Promise<ISocketIoConnection>;
277
+ }
198
278
  /**
199
279
  * Interface for logging.
200
280
  */
@@ -34,6 +34,8 @@ export interface AwsSecretsConfig {
34
34
  provider: 'aws';
35
35
  /** AWS region, e.g. "us-east-1". Falls back to AWS_DEFAULT_REGION env var. */
36
36
  region?: string;
37
+ /** AWS shared-config profile, e.g. "my-sso-profile". Falls back to AWS_PROFILE when omitted. */
38
+ profile?: string;
37
39
  }
38
40
  export interface AzureKeyVaultConfig {
39
41
  provider: 'azure';
@@ -57,6 +57,12 @@ export interface OperationResponse {
57
57
  examples?: Record<string, any>;
58
58
  headers?: Record<string, KeyValueEntry>;
59
59
  }
60
+ /**
61
+ * Request transport. HTTP requests use `method` as the HTTP verb; WebSocket
62
+ * requests use `method: 'GET'` for the handshake and keep their socket-specific
63
+ * configuration in `websocket`.
64
+ */
65
+ export type RequestType = 'http' | 'websocket';
60
66
  /**
61
67
  * Unified Request - normalized request format
62
68
  * Supports full feature set from CollectionRequest with metadata preservation
@@ -67,6 +73,7 @@ export interface UnifiedRequest {
67
73
  name: string;
68
74
  description?: string;
69
75
  doc?: string;
76
+ requestType?: RequestType;
70
77
  method: string;
71
78
  url: string;
72
79
  /** Headers with per-header enabled/disabled flag and OpenAPI metadata */
@@ -81,6 +88,8 @@ export interface UnifiedRequest {
81
88
  auth?: CollectionAuth;
82
89
  settings?: RequestSettings;
83
90
  scripts?: CollectionScripts;
91
+ /** WebSocket-specific configuration when requestType is 'websocket'. */
92
+ websocket?: WebSocketRequestConfig;
84
93
  /** Mark request as disabled (not editable via UI) */
85
94
  disabled?: boolean;
86
95
  /** Mark request as deprecated */
@@ -179,6 +188,141 @@ export interface GraphQLContent {
179
188
  variables?: Record<string, unknown>;
180
189
  operationName?: string;
181
190
  }
191
+ /**
192
+ * WebSocket request flavor. Raw WebSocket and Socket.IO share the WebSocket
193
+ * transport but expose different composer/listener UI.
194
+ */
195
+ export type WebSocketProtocol = 'websocket' | 'socketio';
196
+ /** Presentation/validation format for a WebSocket message. */
197
+ export type WebSocketMessageFormat = 'text' | 'json' | 'xml' | 'html' | 'binary';
198
+ /** Encoding used when a WebSocket message is binary. */
199
+ export type WebSocketBinaryEncoding = 'base64' | 'hex';
200
+ /**
201
+ * Saved WebSocket composer message.
202
+ *
203
+ * Text frames store their payload directly. Binary frames store the encoded
204
+ * bytes so the request can round-trip through JSON without losing data.
205
+ */
206
+ export interface WebSocketMessageDraft {
207
+ id: string;
208
+ name?: string;
209
+ type: 'text' | 'binary';
210
+ format?: WebSocketMessageFormat;
211
+ /** Binary encoding used by `data`; ignored for text messages. */
212
+ encoding?: WebSocketBinaryEncoding;
213
+ data: string;
214
+ enabled?: boolean;
215
+ /** Socket.IO event name. Defaults to `message`. */
216
+ event?: string;
217
+ /** Additional Socket.IO arguments, stored as text. */
218
+ args?: string[];
219
+ /** Request an acknowledgement from the Socket.IO server. */
220
+ ack?: boolean;
221
+ }
222
+ /**
223
+ * A frame captured while a WebSocket request runs headlessly (collection
224
+ * runner / suite executor). Binary payloads are encoded so the transcript can
225
+ * round-trip through JSON and be asserted on from scripts.
226
+ */
227
+ export interface WebSocketRunFrame {
228
+ direction: 'in' | 'out' | 'system';
229
+ type: 'text' | 'binary';
230
+ /** Text payload, or the encoded binary payload. */
231
+ data: string;
232
+ /** Encoding used by `data` for binary frames. */
233
+ encoding?: WebSocketBinaryEncoding;
234
+ /** Socket.IO event name, when applicable. */
235
+ event?: string;
236
+ /** Socket.IO arguments, when applicable. */
237
+ args?: string[];
238
+ /** Whether this frame is an acknowledgement. */
239
+ ack?: boolean;
240
+ /** Frame size in bytes. */
241
+ size: number;
242
+ time: number;
243
+ }
244
+ /**
245
+ * Response body exposed to post-response scripts for headless WebSocket runs.
246
+ *
247
+ * Scripts can assert on the frames, for example:
248
+ * `pm.test('greeting', () => pm.expect(pm.response.json().frames.some(f => f.direction === 'in')).to.be.true)`
249
+ */
250
+ export interface WebSocketRunTranscript {
251
+ protocol: WebSocketProtocol;
252
+ frames: WebSocketRunFrame[];
253
+ close?: {
254
+ code: number;
255
+ reason: string;
256
+ wasClean: boolean;
257
+ };
258
+ }
259
+ /**
260
+ * Socket.IO event listener saved with a request.
261
+ */
262
+ export interface SocketIoEventListener {
263
+ id: string;
264
+ name: string;
265
+ description?: string;
266
+ enabled?: boolean;
267
+ }
268
+ /**
269
+ * Socket.IO-specific request configuration.
270
+ */
271
+ export interface SocketIoConfig {
272
+ /** Socket.IO client version selected in the UI. */
273
+ clientVersion?: string;
274
+ /** Handshake path (defaults to `/socket.io`). */
275
+ handshakePath?: string;
276
+ /** Socket.IO namespace (defaults to `/`). */
277
+ namespace?: string;
278
+ /** Auth payload sent during the Socket.IO handshake (stored as JSON text). */
279
+ auth?: string;
280
+ /** Transports to use (defaults to `websocket`). */
281
+ transports?: Array<'websocket' | 'polling'>;
282
+ /** Events the response pane should listen to. */
283
+ listeners?: SocketIoEventListener[];
284
+ }
285
+ /**
286
+ * WebSocket-specific connection settings. TLS verification and HTTP timeout
287
+ * stay in the shared `RequestSettings` bag; these settings only apply to the
288
+ * socket connection/reconnect loop.
289
+ */
290
+ export interface WebSocketConnectionSettings {
291
+ /** Handshake timeout in milliseconds. Overrides `RequestSettings.timeout`. */
292
+ handshakeTimeout?: number;
293
+ /** Maximum automatic reconnect attempts after an unexpected close. */
294
+ reconnectionAttempts?: number;
295
+ /** Delay between reconnect attempts in milliseconds. */
296
+ reconnectionInterval?: number;
297
+ /** Maximum accepted message size in megabytes. 0 means unlimited. */
298
+ maxMessageSizeMb?: number;
299
+ /**
300
+ * Time in milliseconds to collect inbound frames after sending saved
301
+ * messages during a headless run. Defaults to 1000; 0 closes immediately.
302
+ */
303
+ responseTimeout?: number;
304
+ }
305
+ /**
306
+ * WebSocket-specific request configuration.
307
+ *
308
+ * WebSocket requests set `requestType: 'websocket'`; URL, headers, query,
309
+ * params, auth, and settings are shared with HTTP requests. The HTTP handshake
310
+ * method is `GET`, but the method selector is not shown for WebSocket requests.
311
+ */
312
+ export interface WebSocketRequestConfig {
313
+ /** Raw WebSocket or Socket.IO. Defaults to raw WebSocket. */
314
+ protocol?: WebSocketProtocol;
315
+ /** Sec-WebSocket-Protocol values, in preference order. */
316
+ subprotocols?: string[];
317
+ /** Saved composer drafts. The live frame log is runtime-only. */
318
+ messages?: WebSocketMessageDraft[];
319
+ /** Socket connection and reconnection settings. */
320
+ settings?: WebSocketConnectionSettings;
321
+ /** Socket.IO-specific configuration. */
322
+ socketio?: SocketIoConfig;
323
+ /** Persisted frame log from previous runs. */
324
+ frameHistory?: WebSocketRunFrame[];
325
+ }
182
326
  /**
183
327
  * Request settings
184
328
  */
@@ -259,6 +403,7 @@ export interface HttpResponse {
259
403
  export interface ExecutionRequest {
260
404
  id: string;
261
405
  name: string;
406
+ requestType?: RequestType;
262
407
  method: string;
263
408
  url: string;
264
409
  headers?: Record<string, string>;
@@ -269,6 +414,7 @@ export interface ExecutionRequest {
269
414
  settings?: RequestSettings;
270
415
  scripts?: RequestScripts;
271
416
  auth?: RequestAuth;
417
+ websocket?: WebSocketRequestConfig;
272
418
  }
273
419
  /**
274
420
  * Variable scopes for script/request execution.
@@ -613,6 +759,7 @@ export interface RequestScripts {
613
759
  export interface CollectionRequest {
614
760
  id: string;
615
761
  name: string;
762
+ requestType?: RequestType;
616
763
  method: string;
617
764
  url: string;
618
765
  headers?: KeyValueEntry[];
@@ -623,6 +770,7 @@ export interface CollectionRequest {
623
770
  settings?: RequestSettings;
624
771
  scripts?: RequestScripts;
625
772
  auth?: RequestAuth;
773
+ websocket?: WebSocketRequestConfig;
626
774
  description?: string;
627
775
  doc?: string;
628
776
  disabled?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@http-forge/core",
3
- "version": "0.6.42",
3
+ "version": "0.7.0",
4
4
  "description": "Headless Postman-compatible API testing engine for Node.js, CI/CD, OpenAPI workflows, and HTTP Forge automation",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -70,9 +70,11 @@
70
70
  "java-parser": "^3.0.1",
71
71
  "lodash": "4.18.1",
72
72
  "moment": "^2.30.1",
73
+ "socket.io-client": "^4.8.1",
73
74
  "tv4": "^1.3.0",
74
75
  "typescript": "^5.3.0",
75
76
  "uuid": "^14.0.0",
77
+ "ws": "^8.22.0",
76
78
  "yaml": "^2.7.0"
77
79
  },
78
80
  "peerDependencies": {
@@ -104,6 +106,7 @@
104
106
  "@types/node": "^20.10.0",
105
107
  "@types/tv4": "^1.2.33",
106
108
  "@types/uuid": "^9.0.7",
109
+ "@types/ws": "^8.18.2",
107
110
  "esbuild": "0.28.2",
108
111
  "rimraf": "^5.0.5",
109
112
  "tsup": "^8.0.1",