@http-forge/core 0.2.9 → 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 CHANGED
@@ -13,15 +13,14 @@
13
13
  - 🚀 **Postman Collections** - Load and execute `.postman_collection.json` and `.forge.json` files
14
14
  - 📝 **JavaScript Scripting** - Pre-request and post-response scripts with full `pm.*` API (variables, assertions, execution flow, visualizer)
15
15
  - 🔄 **Dynamic Variables** - Built-in generators: `{{$randomInt}}`, `{{$timestamp}}`, `{{$uuid}}`, `{{$guid}}`, etc.
16
- - 🌍 **Environments** - Full variable scoping (globals, collection, environment, iterationData) with Postman-compatible cascade
16
+ - 🌍 **Environments** - Full variable scoping (globals, collection, environment, session, iterationData)
17
17
  - 👁️ **File Watching** - Automatic reload on collection/environment file changes with notification callbacks
18
18
  - 🍪 **Cookie Persistence** - Automatic cookie storage and reuse, `pm.cookies.jar()` and `.toObject()`
19
19
  - 📊 **Test Assertions** - BDD-style testing with `pm.test()` (sync/async) and full Chai `expect()` chains
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
- - �️ **Sensitive Data Redaction** - Auto-redacts tokens, passwords, secrets from persisted history/result files
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 3.0 round-trip
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?: boolean; // OpenAPI 3.0: boolean modifier on minimum (strict >)
540
- exclusiveMaximum?: boolean; // OpenAPI 3.0: boolean modifier on maximum (strict <)
541
- multipleOf?: number;
542
- // Array constraints
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?: boolean; // OpenAPI 3.0: boolean modifier (strict >)
572
- exclusiveMaximum?: boolean; // OpenAPI 3.0: boolean modifier (strict <)
573
- multipleOf?: number;
574
- // Array constraints
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: `type`, `format`, `pattern`, `enum`, `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum` (booleans), `multipleOf`, `minLength`, `maxLength`, `minItems`, `maxItems`, `uniqueItems`, `nullable`
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
- - `exclusiveMinimum`/`exclusiveMaximum` exported as booleans (OpenAPI 3.0 semantics)
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
- - **Existing has `oneOf`** incoming constraints appended as a new variant
600
- - **Incoming has `oneOf`** existing schema wrapped as single variant, incoming variants flattened in
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,23 +711,6 @@ MIT © Henry Huang
795
711
 
796
712
  ## 📝 Changelog
797
713
 
798
- ### 0.2.7 (Session Scope Removal & Postman Parity)
799
-
800
- - ✅ **Session scope removed** — The separate "session" variable scope has been removed. `pm.environment.set()` now persists to workspace state (matching Postman's behavior). Variable resolution uses a Postman-compatible 5-scope cascade: `variables > iterationData > environmentVariables > collectionVariables > globals`.
801
- - ✅ **Request preparer extraVariables fix** — All request resolutions (params, query, headers, bearer auth, basic auth, API key) now use `extraVariables`. Previously only body and URL used them.
802
- - ✅ **Exported `ResolvedEnvironment` type** — Now part of the public API for downstream consumers.
803
-
804
- ### 0.2.6 (Sensitive Data Redaction & Variable Propagation Fix)
805
-
806
- - ✅ **Sensitive data redaction** — History files, shared history, suite test results, and full response files automatically redact sensitive data before persisting to disk:
807
- - Headers matching `authorization`, `proxy-authorization`, or containing `token`, `cookie`, `secret`, `credential`, `api-key`, `bearer`, `session-id`
808
- - URL query params and JSON/form body fields matching `password`, `token`, `secret`, `api_key`, `client_secret`, `private_key`, `auth_code`, `jwt`, etc.
809
- - Response `Set-Cookie` headers and cookies with sensitive names
810
- - Unresolved `{{variable}}` templates in `originalConfig` are preserved — only resolved values redacted
811
- - Exported functions: `redactHeaders()`, `redactUrl()`, `redactBody()`, `redactHistoryEntry()`, `redactFullResponse()`, `redactFullResultDetails()`
812
- - ✅ **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.
813
- - ✅ **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.
814
-
815
714
  ### 0.2.5 (OpenAPI Constraint Round-Trip & Collision Merging)
816
715
 
817
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`
@@ -850,7 +749,7 @@ MIT © Henry Huang
850
749
  - ✅ **Core request execution** with Postman collection support
851
750
  - ✅ **Dynamic variables** - 7 generators for on-the-fly value generation
852
751
  - ✅ **Postman-compatible scripting** - `pm.*` API with full feature parity
853
- - ✅ **Variable scoping** - globals, collection, environment, workspace-state persistence for `pm.environment.set()`
752
+ - ✅ **Variable scoping** - globals, collection, environment, session, flow-level
854
753
  - ✅ **Cookie persistence** - automatic storage and reuse across request chains
855
754
  - ✅ **Pre-request & post-response scripts** with shared VM context
856
755
  - ✅ **Test assertions** with BDD-style `pm.test()` and expect chains