@http-forge/core 0.2.8 → 0.2.10
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/README.md +14 -109
- package/dist/index.d.ts +3 -2
- package/dist/index.js +181 -178
- package/dist/index.mjs +181 -178
- package/dist/infrastructure/environment/environment-config-service.d.ts +21 -1
- package/dist/infrastructure/execution/request-preparer.d.ts +3 -3
- package/dist/infrastructure/script/request-script-session.d.ts +0 -2
- package/dist/infrastructure/script/script-executor.d.ts +0 -4
- package/dist/infrastructure/script/vm-script-executor.adapter.d.ts +1 -1
- package/dist/infrastructure/security/sensitive-data-redactor.d.ts +74 -0
- package/dist/infrastructure/test-suite/interfaces.d.ts +4 -1
- package/dist/infrastructure/test-suite/test-suite-store.d.ts +64 -7
- package/package.json +1 -1
|
@@ -43,9 +43,24 @@ export declare class EnvironmentConfigService implements IEnvironmentConfigServi
|
|
|
43
43
|
getEnvironmentNames(): string[];
|
|
44
44
|
getSelectedEnvironment(): string;
|
|
45
45
|
setSelectedEnvironment(envName: string): Promise<void>;
|
|
46
|
+
private getEnvOverridesStateKey;
|
|
47
|
+
/**
|
|
48
|
+
* Load persisted environment overrides from workspace state into the in-memory map.
|
|
49
|
+
* Called once at construction time.
|
|
50
|
+
*/
|
|
51
|
+
private loadPersistedEnvironmentOverrides;
|
|
52
|
+
/**
|
|
53
|
+
* Persist current environment overrides to workspace state (fire-and-forget).
|
|
54
|
+
*/
|
|
55
|
+
private persistEnvironmentOverrides;
|
|
46
56
|
setEnvironmentVariable(key: string, value: unknown): void;
|
|
47
57
|
deleteEnvironmentVariable(key: string): void;
|
|
48
58
|
clearEnvironmentVariables(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Reset all runtime environment overrides for the current environment.
|
|
61
|
+
* Equivalent to Postman's "Reset All" — reverts Current Values to Initial Values.
|
|
62
|
+
*/
|
|
63
|
+
resetEnvironmentOverrides(envName?: string): Promise<void>;
|
|
49
64
|
getEnvironmentVariableLocal(key: string): string | undefined;
|
|
50
65
|
getEnvironmentVariableLocals(): Record<string, string>;
|
|
51
66
|
setGlobalVariable(key: string, value: unknown): void;
|
|
@@ -55,12 +70,17 @@ export declare class EnvironmentConfigService implements IEnvironmentConfigServi
|
|
|
55
70
|
getGlobalVariableLocals(): Record<string, string>;
|
|
56
71
|
deleteGlobalVariable(key: string): void;
|
|
57
72
|
clearGlobalVariables(): void;
|
|
58
|
-
|
|
73
|
+
/** @deprecated Use setEnvironmentVariable instead */
|
|
59
74
|
setSessionVariable(key: string, value: unknown): Promise<void>;
|
|
75
|
+
/** @deprecated Use getEnvironmentVariableLocal instead */
|
|
60
76
|
getSessionVariable(key: string): string | undefined;
|
|
77
|
+
/** @deprecated Use getEnvironmentVariableLocals instead */
|
|
61
78
|
getSessionVariables(): Record<string, string>;
|
|
79
|
+
/** @deprecated Use deleteEnvironmentVariable instead */
|
|
62
80
|
deleteSessionVariable(key: string): Promise<void>;
|
|
81
|
+
/** @deprecated Use clearEnvironmentVariables instead */
|
|
63
82
|
clearSessionVariables(): Promise<void>;
|
|
83
|
+
/** @deprecated Use getEnvironmentVariableLocal instead */
|
|
64
84
|
hasSessionVariable(key: string): boolean;
|
|
65
85
|
getResolvedEnvironment(envName?: string): ResolvedEnvironment | null;
|
|
66
86
|
resolveVariables(input: string, envName?: string): string;
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Used by both Request Tester (manual) and Collection Runner (batch).
|
|
11
11
|
*/
|
|
12
|
-
import { IOAuth2TokenManager } from '../auth/interfaces';
|
|
13
12
|
import { IEnvironmentConfigService, ResolvedEnvironment } from '../../types/environment-config';
|
|
14
|
-
import { IHttpRequestService } from '../http/interfaces';
|
|
15
|
-
import { IRequestPreprocessor } from '../http/request-preprocessor';
|
|
16
13
|
import { IApplicationInfo } from '../../types/platform';
|
|
17
14
|
import { ExecutionRequest, PreparedRequest } from '../../types/types';
|
|
15
|
+
import { IOAuth2TokenManager } from '../auth/interfaces';
|
|
16
|
+
import { IHttpRequestService } from '../http/interfaces';
|
|
17
|
+
import { IRequestPreprocessor } from '../http/request-preprocessor';
|
|
18
18
|
import { IRequestPreparer } from './request-preparer-interfaces';
|
|
19
19
|
/**
|
|
20
20
|
* RequestPreparer implementation
|
|
@@ -34,10 +34,8 @@ export declare class RequestScriptSession implements IRequestScriptSession {
|
|
|
34
34
|
private _variables;
|
|
35
35
|
private _collectionVariables;
|
|
36
36
|
private _globals;
|
|
37
|
-
private _sessionVariables;
|
|
38
37
|
private _environmentVariables;
|
|
39
38
|
private _liveEnvironmentScope;
|
|
40
|
-
private _liveSessionScope;
|
|
41
39
|
private _liveGlobalsScope;
|
|
42
40
|
private _liveCollectionScope;
|
|
43
41
|
private _nextRequest;
|
|
@@ -49,10 +49,6 @@ export declare class ScriptExecutor implements IScriptExecutor {
|
|
|
49
49
|
* Create environment variable scope with change callbacks
|
|
50
50
|
*/
|
|
51
51
|
private createEnvironmentScope;
|
|
52
|
-
/**
|
|
53
|
-
* Create session variable scope with change callbacks
|
|
54
|
-
*/
|
|
55
|
-
private createSessionScope;
|
|
56
52
|
/**
|
|
57
53
|
* Create sendRequest function using httpService
|
|
58
54
|
*/
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* The legacy ScriptExecutor uses `createRequestSession()` pattern;
|
|
6
6
|
* this adapter translates to the simpler `executePreRequest` / `executePostResponse` port API.
|
|
7
7
|
*/
|
|
8
|
-
import { IScriptExecutor as IScriptExecutorPort,
|
|
8
|
+
import { IScriptExecutor as IScriptExecutorPort, IScriptResult, IScriptSession } from '../../ports/executors/script-executor.interface';
|
|
9
9
|
import { HttpResponse } from '../../types/types';
|
|
10
10
|
import { ScriptExecutor } from './script-executor';
|
|
11
11
|
/**
|
|
@@ -41,3 +41,77 @@ export declare function redactFullResponse(response: FullResponse): FullResponse
|
|
|
41
41
|
* Redact sensitive data from a FullResultDetails (suite test result).
|
|
42
42
|
*/
|
|
43
43
|
export declare function redactFullResultDetails(result: FullResultDetails): FullResultDetails;
|
|
44
|
+
/** A single warning about a hardcoded sensitive value. */
|
|
45
|
+
export interface SensitiveDataWarning {
|
|
46
|
+
/** Where the issue was found (e.g. "header", "auth", "body", "query", "url") */
|
|
47
|
+
location: string;
|
|
48
|
+
/** The field name that matched (e.g. "Authorization", "password") */
|
|
49
|
+
field: string;
|
|
50
|
+
/** Human-readable guidance */
|
|
51
|
+
message: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check a request for hardcoded sensitive data that should use environment
|
|
55
|
+
* variables instead. Returns an array of warnings. An empty array means the
|
|
56
|
+
* request is safe to save.
|
|
57
|
+
*
|
|
58
|
+
* Only values that are NOT `{{variable}}` template references are flagged.
|
|
59
|
+
*/
|
|
60
|
+
export declare function detectSensitiveData(request: {
|
|
61
|
+
url?: string;
|
|
62
|
+
headers?: Record<string, string> | Array<{
|
|
63
|
+
key: string;
|
|
64
|
+
value: string;
|
|
65
|
+
enabled?: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
query?: Record<string, string> | Array<{
|
|
68
|
+
key: string;
|
|
69
|
+
value: string;
|
|
70
|
+
enabled?: boolean;
|
|
71
|
+
}>;
|
|
72
|
+
body?: any;
|
|
73
|
+
auth?: any;
|
|
74
|
+
}): SensitiveDataWarning[];
|
|
75
|
+
/**
|
|
76
|
+
* A single sensitive value that can be extracted to a .local.json variable.
|
|
77
|
+
*/
|
|
78
|
+
export interface SensitiveExtraction {
|
|
79
|
+
/** Where the value was found */
|
|
80
|
+
location: 'header' | 'query' | 'body' | 'auth' | 'url';
|
|
81
|
+
/** The field name / key (e.g. "Authorization", "password") */
|
|
82
|
+
field: string;
|
|
83
|
+
/** Dot-path for nested body fields (e.g. "credentials.secret") */
|
|
84
|
+
path?: string;
|
|
85
|
+
/** The hardcoded value to extract */
|
|
86
|
+
value: string;
|
|
87
|
+
/** Suggested variable name for the .local.json file */
|
|
88
|
+
variableName: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Scan a request and build an extraction plan: a list of all hardcoded sensitive
|
|
92
|
+
* values with their locations and suggested variable names.
|
|
93
|
+
*
|
|
94
|
+
* The caller can use this plan to:
|
|
95
|
+
* 1. Write the values to a .local.json environment file
|
|
96
|
+
* 2. Replace each value with {{variableName}} in the request before saving
|
|
97
|
+
*/
|
|
98
|
+
export declare function buildExtractionPlan(request: {
|
|
99
|
+
url?: string;
|
|
100
|
+
headers?: Record<string, string> | Array<{
|
|
101
|
+
key: string;
|
|
102
|
+
value: string;
|
|
103
|
+
enabled?: boolean;
|
|
104
|
+
}>;
|
|
105
|
+
query?: Record<string, string> | Array<{
|
|
106
|
+
key: string;
|
|
107
|
+
value: string;
|
|
108
|
+
enabled?: boolean;
|
|
109
|
+
}>;
|
|
110
|
+
body?: any;
|
|
111
|
+
auth?: any;
|
|
112
|
+
}): SensitiveExtraction[];
|
|
113
|
+
/**
|
|
114
|
+
* Apply an extraction plan to a request: replace hardcoded values with {{variableName}}.
|
|
115
|
+
* Returns a deep copy of the request with all sensitive values replaced.
|
|
116
|
+
*/
|
|
117
|
+
export declare function applyExtractionPlan(request: any, plan: SensitiveExtraction[]): any;
|
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* Request reference within a Test Suite
|
|
8
|
-
* References a request from a Collection
|
|
8
|
+
* References a request from a Collection with an optional embedded snapshot.
|
|
9
|
+
* When a slug is present, request data lives in the suite's folder structure.
|
|
9
10
|
*/
|
|
10
11
|
export interface SuiteRequest {
|
|
12
|
+
/** Folder slug (directory name) within the suite — required for folder-based suites */
|
|
13
|
+
slug?: string;
|
|
11
14
|
/** Collection ID where the request lives */
|
|
12
15
|
collectionId: string;
|
|
13
16
|
/** Collection name for display purposes */
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Test Suite Store
|
|
3
3
|
*
|
|
4
4
|
* Manages suite requests that can come from different collections.
|
|
5
|
-
*
|
|
5
|
+
* Supports folder-based suite storage where each request has its own directory.
|
|
6
|
+
* Falls back to resolving from collection service for legacy suites.
|
|
6
7
|
*
|
|
7
|
-
* Single Responsibility: Maintain suite state and resolve requests
|
|
8
|
+
* Single Responsibility: Maintain suite state and resolve requests
|
|
8
9
|
* Dependency Inversion: Depends on ICollectionService abstraction
|
|
9
10
|
*/
|
|
10
11
|
import { CollectionRequest, ICollectionService, RequestScripts } from '../../types/collection';
|
|
@@ -30,6 +31,10 @@ export interface ITestSuiteStore {
|
|
|
30
31
|
* Set the test suite
|
|
31
32
|
*/
|
|
32
33
|
setSuite(suite: TestSuite): void;
|
|
34
|
+
/**
|
|
35
|
+
* Set the suite directory path (for folder-based suites)
|
|
36
|
+
*/
|
|
37
|
+
setSuiteDir(dir: string | undefined): void;
|
|
33
38
|
/**
|
|
34
39
|
* Get the current suite
|
|
35
40
|
*/
|
|
@@ -38,6 +43,10 @@ export interface ITestSuiteStore {
|
|
|
38
43
|
* Get a request by ID with full context (collection scripts + folder scripts)
|
|
39
44
|
*/
|
|
40
45
|
getRequestWithContext(collectionId: string, requestId: string): SuiteRequestEntry | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Get a request by slug with full context
|
|
48
|
+
*/
|
|
49
|
+
getRequestBySlug(slug: string): SuiteRequestEntry | undefined;
|
|
41
50
|
/**
|
|
42
51
|
* Get all suite requests with their resolved data
|
|
43
52
|
*/
|
|
@@ -55,6 +64,8 @@ export interface ITestSuiteStore {
|
|
|
55
64
|
collectionName: string;
|
|
56
65
|
folderPath: string;
|
|
57
66
|
enabled: boolean;
|
|
67
|
+
hasEmbeddedRequest: boolean;
|
|
68
|
+
slug?: string;
|
|
58
69
|
}>;
|
|
59
70
|
/**
|
|
60
71
|
* Get suite requests by selection state
|
|
@@ -62,9 +73,9 @@ export interface ITestSuiteStore {
|
|
|
62
73
|
*/
|
|
63
74
|
getSelectedRequests(selectedIds: string[]): SuiteRequestEntry[];
|
|
64
75
|
/**
|
|
65
|
-
* Add a request to the suite
|
|
76
|
+
* Add a request to the suite (creates folder if suiteDir is set)
|
|
66
77
|
*/
|
|
67
|
-
addRequest(request: SuiteRequest): void;
|
|
78
|
+
addRequest(request: SuiteRequest, fullRequest?: CollectionRequest): void;
|
|
68
79
|
/**
|
|
69
80
|
* Remove a request from the suite
|
|
70
81
|
*/
|
|
@@ -73,6 +84,14 @@ export interface ITestSuiteStore {
|
|
|
73
84
|
* Reorder requests
|
|
74
85
|
*/
|
|
75
86
|
reorderRequests(requestIds: string[]): void;
|
|
87
|
+
/**
|
|
88
|
+
* Update a suite request's data in its folder
|
|
89
|
+
*/
|
|
90
|
+
updateSuiteRequest(slug: string, updatedRequest: CollectionRequest): void;
|
|
91
|
+
/**
|
|
92
|
+
* Re-sync a suite request from its source collection
|
|
93
|
+
*/
|
|
94
|
+
resyncFromCollection(slug: string): CollectionRequest | undefined;
|
|
76
95
|
}
|
|
77
96
|
/**
|
|
78
97
|
* Implementation of TestSuiteStore
|
|
@@ -80,17 +99,37 @@ export interface ITestSuiteStore {
|
|
|
80
99
|
export declare class TestSuiteStore implements ITestSuiteStore {
|
|
81
100
|
private readonly collectionService;
|
|
82
101
|
private suite;
|
|
102
|
+
private suiteDir;
|
|
83
103
|
constructor(collectionService: ICollectionService);
|
|
84
104
|
/**
|
|
85
105
|
* Set the suite
|
|
86
106
|
*/
|
|
87
107
|
setSuite(suite: TestSuite): void;
|
|
108
|
+
/**
|
|
109
|
+
* Set the suite directory (for folder-based storage)
|
|
110
|
+
*/
|
|
111
|
+
setSuiteDir(dir: string | undefined): void;
|
|
88
112
|
/**
|
|
89
113
|
* Get the current suite
|
|
90
114
|
*/
|
|
91
115
|
getSuite(): TestSuite | undefined;
|
|
92
116
|
/**
|
|
93
|
-
*
|
|
117
|
+
* Load a suite request from its folder.
|
|
118
|
+
* Reads request.json + scripts/pre-request.js + scripts/post-response.js
|
|
119
|
+
*/
|
|
120
|
+
private loadSuiteRequest;
|
|
121
|
+
/**
|
|
122
|
+
* Save a suite request to its folder.
|
|
123
|
+
* Writes request.json + scripts/pre-request.js + scripts/post-response.js
|
|
124
|
+
*/
|
|
125
|
+
private saveSuiteRequest;
|
|
126
|
+
/**
|
|
127
|
+
* Check if a suite request has embedded data in its folder
|
|
128
|
+
*/
|
|
129
|
+
private hasEmbeddedRequest;
|
|
130
|
+
/**
|
|
131
|
+
* Resolve a suite request to its full request data.
|
|
132
|
+
* Priority: suite folder → collection (fallback for legacy suites)
|
|
94
133
|
*/
|
|
95
134
|
private resolveRequest;
|
|
96
135
|
/**
|
|
@@ -115,6 +154,7 @@ export declare class TestSuiteStore implements ITestSuiteStore {
|
|
|
115
154
|
* Always resolves fresh from collection service to ensure latest data
|
|
116
155
|
*/
|
|
117
156
|
getRequestWithContext(collectionId: string, requestId: string): SuiteRequestEntry | undefined;
|
|
157
|
+
getRequestBySlug(slug: string): SuiteRequestEntry | undefined;
|
|
118
158
|
/**
|
|
119
159
|
* Get all suite requests with resolved data
|
|
120
160
|
* Always resolves fresh from collection service to ensure latest data
|
|
@@ -134,6 +174,8 @@ export declare class TestSuiteStore implements ITestSuiteStore {
|
|
|
134
174
|
collectionName: string;
|
|
135
175
|
folderPath: string;
|
|
136
176
|
enabled: boolean;
|
|
177
|
+
hasEmbeddedRequest: boolean;
|
|
178
|
+
slug?: string;
|
|
137
179
|
}>;
|
|
138
180
|
/**
|
|
139
181
|
* Get selected requests in order
|
|
@@ -141,9 +183,14 @@ export declare class TestSuiteStore implements ITestSuiteStore {
|
|
|
141
183
|
*/
|
|
142
184
|
getSelectedRequests(selectedIds: string[]): SuiteRequestEntry[];
|
|
143
185
|
/**
|
|
144
|
-
* Add a request to the suite
|
|
186
|
+
* Add a request to the suite.
|
|
187
|
+
* If fullRequest is provided and suiteDir is set, creates a folder with request.json + scripts.
|
|
145
188
|
*/
|
|
146
|
-
addRequest(request: SuiteRequest): void;
|
|
189
|
+
addRequest(request: SuiteRequest, fullRequest?: CollectionRequest): void;
|
|
190
|
+
/**
|
|
191
|
+
* Resolve a unique slug (handle duplicates with numeric suffix)
|
|
192
|
+
*/
|
|
193
|
+
private resolveUniqueSlug;
|
|
147
194
|
/**
|
|
148
195
|
* Remove a request from the suite
|
|
149
196
|
*/
|
|
@@ -152,4 +199,14 @@ export declare class TestSuiteStore implements ITestSuiteStore {
|
|
|
152
199
|
* Reorder requests by request IDs (format: "collectionId:requestId")
|
|
153
200
|
*/
|
|
154
201
|
reorderRequests(orderedKeys: string[]): void;
|
|
202
|
+
/**
|
|
203
|
+
* Update the request data in the suite folder.
|
|
204
|
+
* Called when user edits a request from the suite panel.
|
|
205
|
+
*/
|
|
206
|
+
updateSuiteRequest(slug: string, updatedRequest: CollectionRequest): void;
|
|
207
|
+
/**
|
|
208
|
+
* Replace the suite request with the latest version from the collection.
|
|
209
|
+
* Overwrites the request folder content.
|
|
210
|
+
*/
|
|
211
|
+
resyncFromCollection(slug: string): CollectionRequest | undefined;
|
|
155
212
|
}
|
package/package.json
CHANGED