@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
package/README.md
CHANGED
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
- 🔐 **CryptoJS** - Full crypto library: hash, HMAC, AES/DES/TripleDES, PBKDF2, encoding helpers
|
|
21
21
|
- 🎯 **Execution Flow** - `pm.setNextRequest()`, `pm.execution.skipRequest()` for suite runner flow control
|
|
22
22
|
- 📈 **Visualizer** - `pm.visualizer.set(template, data)` for custom Handlebars-based HTML output
|
|
23
|
-
-
|
|
24
|
-
- �🔌 **Extensible** - Custom interceptors, HTTP clients, and module loaders
|
|
23
|
+
- 🔌 **Extensible** - Custom interceptors, HTTP clients, and module loaders
|
|
25
24
|
|
|
26
25
|
**Ideal for:**
|
|
27
26
|
- CI/CD pipeline integration (GitHub Actions, GitLab CI, Jenkins)
|
|
@@ -79,25 +78,6 @@ forge.setEnvironment({
|
|
|
79
78
|
const result = await forge.execute(request, collection);
|
|
80
79
|
```
|
|
81
80
|
|
|
82
|
-
### URL Path Parameters
|
|
83
|
-
|
|
84
|
-
If your request URL uses Express-style route parameters, provide values using the request `params` field.
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
const request = {
|
|
88
|
-
name: 'Redirect Test',
|
|
89
|
-
method: 'GET',
|
|
90
|
-
url: '{{baseUrl}}/redirect/:redirectNumber',
|
|
91
|
-
params: {
|
|
92
|
-
redirectNumber: '3'
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const result = await forge.execute(request, collection);
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
The engine will substitute `:redirectNumber` before execution, while still resolving environment variables and dynamic template expressions.
|
|
100
|
-
|
|
101
81
|
### With Custom Configuration
|
|
102
82
|
|
|
103
83
|
```typescript
|
|
@@ -380,47 +360,6 @@ const entries = history.getAll(); // All requests
|
|
|
380
360
|
const byId = history.getByRequestId(id); // Specific request history
|
|
381
361
|
```
|
|
382
362
|
|
|
383
|
-
### 🛡️ Sensitive Data Redaction
|
|
384
|
-
|
|
385
|
-
History and result files automatically redact sensitive data before writing to disk. This prevents tokens, passwords, and credentials from being persisted in plaintext.
|
|
386
|
-
|
|
387
|
-
```typescript
|
|
388
|
-
import {
|
|
389
|
-
redactHeaders, redactUrl, redactBody,
|
|
390
|
-
redactHistoryEntry, redactFullResponse, redactFullResultDetails
|
|
391
|
-
} from '@http-forge/core';
|
|
392
|
-
|
|
393
|
-
// Redact sensitive headers
|
|
394
|
-
redactHeaders({ 'Authorization': 'Bearer eyJ...', 'Content-Type': 'application/json' });
|
|
395
|
-
// → { 'Authorization': '***', 'Content-Type': 'application/json' }
|
|
396
|
-
|
|
397
|
-
// Any header containing 'token', 'cookie', 'secret' is redacted
|
|
398
|
-
redactHeaders({ 'avs-token': 'abc123', 'telus-access-token-cookie': 'xyz' });
|
|
399
|
-
// → { 'avs-token': '***', 'telus-access-token-cookie': '***' }
|
|
400
|
-
|
|
401
|
-
// Redact sensitive URL query params
|
|
402
|
-
redactUrl('https://api.example.com/auth?client_secret=abc&scope=read');
|
|
403
|
-
// → 'https://api.example.com/auth?client_secret=***&scope=read'
|
|
404
|
-
|
|
405
|
-
// Redact sensitive JSON body fields (recursive)
|
|
406
|
-
redactBody({ user: 'admin', password: 'hunter2', data: { api_token: 'xyz' } });
|
|
407
|
-
// → { user: 'admin', password: '***', data: { api_token: '***' } }
|
|
408
|
-
|
|
409
|
-
// Redact URL-encoded form bodies
|
|
410
|
-
redactBody('username=admin&password=secret&grant_type=password');
|
|
411
|
-
// → 'username=admin&password=***&grant_type=***'
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
**Auto-detected patterns:**
|
|
415
|
-
- **Headers**: `authorization`, `proxy-authorization`, `www-authenticate`, and any header containing `token`, `cookie`, `secret`, `credential`, `api-key`, `bearer`, `session-id`
|
|
416
|
-
- **Fields/Params**: Any name containing `password`, `passwd`, `pwd`, `token`, `cookie`, `secret`, `credential`, `api_key`, `access_token`, `refresh_token`, `client_secret`, `private_key`, `auth_code`, `bearer`, `session_id`, `jwt`
|
|
417
|
-
|
|
418
|
-
**Integration points:**
|
|
419
|
-
- `RequestHistoryService.addEntry()` — redacts `sentRequest` (headers, body, URL) before saving
|
|
420
|
-
- `RequestHistoryService.saveFullResponse()` — redacts response headers and cookies
|
|
421
|
-
- `ResultStorageService.saveResult()` — redacts request/response headers and body in suite results
|
|
422
|
-
- `originalConfig` (unresolved `{{variable}}` templates) is never redacted — only resolved values
|
|
423
|
-
|
|
424
363
|
## 📖 API Reference
|
|
425
364
|
|
|
426
365
|
### ForgeContainer
|
|
@@ -528,23 +467,14 @@ interface KeyValueEntry {
|
|
|
528
467
|
format?: string; // Semantic hint (e.g. "uuid", "date-time")
|
|
529
468
|
enum?: string[]; // Allowed values
|
|
530
469
|
deprecated?: boolean;
|
|
531
|
-
// Extended constraint fields for full OpenAPI
|
|
532
|
-
// String constraints
|
|
470
|
+
// Extended constraint fields for full OpenAPI round-trip
|
|
533
471
|
pattern?: string; // Regex validation pattern
|
|
534
|
-
minLength?: number;
|
|
535
|
-
maxLength?: number;
|
|
536
|
-
// Numeric constraints (integer / number)
|
|
537
472
|
minimum?: number;
|
|
538
473
|
maximum?: number;
|
|
539
|
-
exclusiveMinimum?:
|
|
540
|
-
exclusiveMaximum?:
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
minItems?: number;
|
|
544
|
-
maxItems?: number;
|
|
545
|
-
uniqueItems?: boolean;
|
|
546
|
-
// Common
|
|
547
|
-
nullable?: boolean;
|
|
474
|
+
exclusiveMinimum?: number;
|
|
475
|
+
exclusiveMaximum?: number;
|
|
476
|
+
minLength?: number;
|
|
477
|
+
maxLength?: number;
|
|
548
478
|
oneOf?: Array<Record<string, any>>; // Merged constraint variants
|
|
549
479
|
}
|
|
550
480
|
```
|
|
@@ -561,22 +491,13 @@ interface PathParamEntry {
|
|
|
561
491
|
format?: string;
|
|
562
492
|
enum?: string[];
|
|
563
493
|
deprecated?: boolean;
|
|
564
|
-
// String constraints
|
|
565
494
|
pattern?: string;
|
|
566
|
-
minLength?: number;
|
|
567
|
-
maxLength?: number;
|
|
568
|
-
// Numeric constraints
|
|
569
495
|
minimum?: number;
|
|
570
496
|
maximum?: number;
|
|
571
|
-
exclusiveMinimum?:
|
|
572
|
-
exclusiveMaximum?:
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
minItems?: number;
|
|
576
|
-
maxItems?: number;
|
|
577
|
-
uniqueItems?: boolean;
|
|
578
|
-
// Common
|
|
579
|
-
nullable?: boolean;
|
|
497
|
+
exclusiveMinimum?: number;
|
|
498
|
+
exclusiveMaximum?: number;
|
|
499
|
+
minLength?: number;
|
|
500
|
+
maxLength?: number;
|
|
580
501
|
oneOf?: Array<Record<string, any>>;
|
|
581
502
|
}
|
|
582
503
|
```
|
|
@@ -587,20 +508,15 @@ The core library includes full OpenAPI 3.0.3 import and export with constraint p
|
|
|
587
508
|
|
|
588
509
|
**Import** (`OpenApiImporter`):
|
|
589
510
|
- Parses OpenAPI 3.0 YAML/JSON specs into `UnifiedCollection`
|
|
590
|
-
- Extracts all parameter schema constraints
|
|
511
|
+
- Extracts all parameter schema constraints (`pattern`, `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `minLength`, `maxLength`, `enum`, `format`)
|
|
591
512
|
- Preserves `oneOf` schemas from merged parameters, deriving combined enum hints for UI display
|
|
592
|
-
- Sets `hasMetadata` flag when any constraint or description field is present
|
|
593
513
|
|
|
594
514
|
**Export** (`OpenApiExporter`):
|
|
595
515
|
- Generates OpenAPI 3.0.3 specs from collections
|
|
596
|
-
-
|
|
597
|
-
- **Collision-aware merging** via `mergeParameterSchema()`: When multiple requests normalize to the same path + HTTP method, they are merged into a single operation:
|
|
516
|
+
- **Collision-aware merging**: When multiple requests normalize to the same path + HTTP method, they are merged into a single operation:
|
|
598
517
|
- Descriptions are appended, tags are unioned
|
|
599
|
-
- **
|
|
600
|
-
-
|
|
601
|
-
- **Both simple, same constraint kind** (both enum, both pattern, etc.) → merged in-place (union enum values, widen numeric ranges, alternation-join patterns)
|
|
602
|
-
- **Both simple, different constraint kinds** → wrapped in `oneOf` — each variant keeps its self-consistent schema
|
|
603
|
-
- `stripConstraints()` called after **all** merge branches to prevent stale fields (e.g. `enum`) leaking alongside `oneOf`
|
|
518
|
+
- Parameters with the **same constraint kind** (both enum, both pattern, etc.) are merged in-place (union enum values, widen numeric ranges, alternation-join patterns)
|
|
519
|
+
- Parameters with **different constraint kinds** are wrapped in `oneOf` — each variant keeps its self-consistent schema
|
|
604
520
|
- All constraint fields round-trip without data loss
|
|
605
521
|
|
|
606
522
|
## 🛠️ Use Cases
|
|
@@ -795,17 +711,6 @@ MIT © Henry Huang
|
|
|
795
711
|
|
|
796
712
|
## 📝 Changelog
|
|
797
713
|
|
|
798
|
-
### 0.2.6 (Sensitive Data Redaction & Variable Propagation Fix)
|
|
799
|
-
|
|
800
|
-
- ✅ **Sensitive data redaction** — History files, shared history, suite test results, and full response files automatically redact sensitive data before persisting to disk:
|
|
801
|
-
- Headers matching `authorization`, `proxy-authorization`, or containing `token`, `cookie`, `secret`, `credential`, `api-key`, `bearer`, `session-id`
|
|
802
|
-
- URL query params and JSON/form body fields matching `password`, `token`, `secret`, `api_key`, `client_secret`, `private_key`, `auth_code`, `jwt`, etc.
|
|
803
|
-
- Response `Set-Cookie` headers and cookies with sensitive names
|
|
804
|
-
- Unresolved `{{variable}}` templates in `originalConfig` are preserved — only resolved values redacted
|
|
805
|
-
- Exported functions: `redactHeaders()`, `redactUrl()`, `redactBody()`, `redactHistoryEntry()`, `redactFullResponse()`, `redactFullResultDetails()`
|
|
806
|
-
- ✅ **Fixed `pm.environment.set()` propagation** — Post-response script `pm.environment.set()` now correctly propagates to `{{variable}}` resolution in subsequent collection runner requests. The session now uses live scope references instead of a disconnected snapshot.
|
|
807
|
-
- ✅ **Cookie jar flush in collection runner** — `flush()` is now called in the `finally` block ensuring script-set cookies persist to the shared session store after a run completes.
|
|
808
|
-
|
|
809
714
|
### 0.2.5 (OpenAPI Constraint Round-Trip & Collision Merging)
|
|
810
715
|
|
|
811
716
|
- ✅ **Full parameter constraint round-trip** — OpenAPI import/export now preserves all schema constraint fields: `pattern`, `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `minLength`, `maxLength`, and `oneOf` on both `KeyValueEntry` and `PathParamEntry`
|
package/dist/index.d.ts
CHANGED
|
@@ -50,7 +50,8 @@ export { createExpectChain, createResponseObject } from './infrastructure/script
|
|
|
50
50
|
export type { ExpectChain, ResponseAssertions, ScriptResponse } from './infrastructure/script/script-factories';
|
|
51
51
|
export { concatenateScripts, createScriptConsole, createTestFunction, formatConsoleOutput, hasChanged, normalizeHeaders } from './infrastructure/script/script-utils';
|
|
52
52
|
export type { ConsoleMessage } from './infrastructure/script/script-utils';
|
|
53
|
-
export { redactBody, redactFullResponse, redactFullResultDetails, redactHeaders, redactHistoryEntry, redactUrl } from './infrastructure/security/sensitive-data-redactor';
|
|
53
|
+
export { applyExtractionPlan, buildExtractionPlan, detectSensitiveData, redactBody, redactFullResponse, redactFullResultDetails, redactHeaders, redactHistoryEntry, redactUrl } from './infrastructure/security/sensitive-data-redactor';
|
|
54
|
+
export type { SensitiveDataWarning, SensitiveExtraction } from './infrastructure/security/sensitive-data-redactor';
|
|
54
55
|
export { CollectionLoader } from './infrastructure/collection/collection-loader';
|
|
55
56
|
export type { LoadOptions } from './infrastructure/collection/collection-loader';
|
|
56
57
|
export { CollectionLoaderFactory } from './infrastructure/collection/collection-loader-factory';
|
|
@@ -71,7 +72,7 @@ export { ForgeEnv } from './infrastructure/environment/forge-env';
|
|
|
71
72
|
export type { IForgeEnv } from './infrastructure/environment/forge-env';
|
|
72
73
|
export { createVariableResolver, VariableInterpolator, VariableResolver } from './infrastructure/environment/variable-interpolator';
|
|
73
74
|
export type { VariableResolverConfig } from './infrastructure/environment/variable-interpolator';
|
|
74
|
-
export type { IEnvironmentConfigService } from './types/environment-config';
|
|
75
|
+
export type { IEnvironmentConfigService, ResolvedEnvironment } from './types/environment-config';
|
|
75
76
|
export { CollectionRequestExecutor } from './infrastructure/execution/collection-request-executor';
|
|
76
77
|
export * from './infrastructure/execution/collection-request-executor-interfaces';
|
|
77
78
|
export { RequestExecutor } from './infrastructure/execution/request-executor';
|