@http-forge/core 0.6.41 → 0.6.42

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.
@@ -224,7 +224,7 @@ export interface ProxyConfig {
224
224
  */
225
225
  export interface SecretProviderEntry {
226
226
  /** Provider type */
227
- provider: 'aws' | 'azure' | 'gcp' | 'vault' | '1password' | 'doppler';
227
+ provider: 'aws' | 'azure' | 'gcp' | 'vault' | '1password' | 'doppler' | 'custom';
228
228
  /** AWS region (aws only) */
229
229
  region?: string;
230
230
  /** Azure Key Vault URL (azure only) */
@@ -239,8 +239,14 @@ export interface SecretProviderEntry {
239
239
  namespace?: string;
240
240
  /** 1Password vault name (1password only) */
241
241
  vault?: string;
242
+ /** 1Password desktop-app account name or UUID (1password only; used when no service-account token is set) */
243
+ account?: string;
242
244
  /** Doppler service token (doppler only; falls back to DOPPLER_TOKEN env var) */
243
245
  serviceToken?: string;
246
+ /** Custom resolver module path or package name (custom only) */
247
+ module?: string;
248
+ /** Non-sensitive options passed to the custom resolver factory (custom only) */
249
+ options?: Record<string, unknown>;
244
250
  }
245
251
  /**
246
252
  * Top-level secrets block in http-forge.config.json
@@ -32,7 +32,7 @@ export interface IHistoryWriter {
32
32
  * Full response storage operations
33
33
  */
34
34
  export interface IResponseStorage {
35
- saveFullResponse(environment: string, requestPath: string, requestId: string, entryId: string, response: FullResponse): void;
35
+ saveFullResponse(environment: string, requestPath: string, requestId: string, entryId: string, response: FullResponse, secretValues?: readonly string[]): void;
36
36
  loadFullResponse(environment: string, requestPath: string, requestId: string, entryId: string): FullResponse | null;
37
37
  loadSharedFullResponse(environment: string, requestPath: string, requestId: string, entryId: string): FullResponse | null;
38
38
  }
@@ -121,7 +121,7 @@ export declare class RequestHistoryService implements IRequestHistoryService {
121
121
  /**
122
122
  * Save full response to a separate file
123
123
  */
124
- saveFullResponse(environment: string, requestPath: string, requestId: string, entryId: string, response: FullResponse): void;
124
+ saveFullResponse(environment: string, requestPath: string, requestId: string, entryId: string, response: FullResponse, secretValues?: readonly string[]): void;
125
125
  /**
126
126
  * Load full response from file
127
127
  */
@@ -57,7 +57,16 @@ export declare class ScriptExecutor implements IScriptExecutor {
57
57
  */
58
58
  private createVault;
59
59
  /**
60
- * Create sendRequest function using httpService
60
+ * Create sendRequest function using httpService.
61
+ *
62
+ * Postman resolves variables (including `{{secret:...}}` tokens) in
63
+ * pm.sendRequest definitions. The normal request pipeline does this in
64
+ * RequestPreparer, but pm.sendRequest calls the HTTP service directly, so
65
+ * resolve the script scopes here first. Secrets are resolved asynchronously
66
+ * and injected into the merged scope, where the existing `replaceIn`
67
+ * pipeline handles filters and nested references.
61
68
  */
62
69
  private createSendRequest;
70
+ /** Recursively apply `replaceIn` to string values, preserving object shape. */
71
+ private replaceInObject;
63
72
  }
@@ -13,6 +13,7 @@ export declare class AwsSecretResolver implements ISecretResolver {
13
13
  readonly providerName = "aws";
14
14
  private readonly region;
15
15
  private readonly moduleRequire;
16
+ private sdk?;
16
17
  constructor(config: AwsSecretsConfig, moduleRequire?: (name: string) => any);
17
18
  resolve(path: string): Promise<string | undefined>;
18
19
  }
@@ -15,6 +15,7 @@ export declare class AzureKeyVaultResolver implements ISecretResolver {
15
15
  readonly providerName = "azure";
16
16
  private readonly vaultUrl;
17
17
  private readonly moduleRequire;
18
+ private client?;
18
19
  constructor(config: AzureKeyVaultConfig, moduleRequire?: (name: string) => any);
19
20
  resolve(path: string): Promise<string | undefined>;
20
21
  }
@@ -13,10 +13,14 @@
13
13
  *
14
14
  * Prerequisites: none (uses Node.js built-in https)
15
15
  */
16
+ import type { ClientRequest, IncomingMessage, RequestOptions } from 'http';
16
17
  import type { DopplerConfig, ISecretResolver } from '../../types/secret-resolver';
18
+ type DopplerRequestFn = (url: string, options: RequestOptions, callback: (res: IncomingMessage) => void) => ClientRequest;
17
19
  export declare class DopplerResolver implements ISecretResolver {
18
20
  readonly providerName = "doppler";
19
21
  private readonly token;
20
- constructor(config: DopplerConfig);
22
+ private readonly requestFn;
23
+ constructor(config: DopplerConfig, requestFn?: DopplerRequestFn);
21
24
  resolve(path: string): Promise<string | undefined>;
22
25
  }
26
+ export {};
@@ -16,6 +16,7 @@ export declare class GcpSecretResolver implements ISecretResolver {
16
16
  readonly providerName = "gcp";
17
17
  private readonly projectId;
18
18
  private readonly moduleRequire;
19
+ private client?;
19
20
  constructor(config: GcpSecretsConfig, moduleRequire?: (name: string) => any);
20
21
  resolve(path: string): Promise<string | undefined>;
21
22
  }
@@ -2,10 +2,10 @@
2
2
  * HashiCorp Vault resolver
3
3
  *
4
4
  * Credentials are NEVER stored in HTTP Forge config.
5
- * Authentication uses:
6
- * VAULT_TOKEN env var (token auth)
7
- * VAULT_ADDR env var (server address, overrides config)
8
- * VAULT_NAMESPACE env var (Enterprise/HCP namespace, overridden by config.namespace)
5
+ * Settings:
6
+ * config.address server address, falling back to VAULT_ADDR
7
+ * config.namespace Enterprise/HCP namespace, falling back to VAULT_NAMESPACE
8
+ * VAULT_TOKEN env var (token auth, always required)
9
9
  *
10
10
  * Token syntax: {{secret:vault/<mountPath>/<secretPath>#<field>}}
11
11
  * e.g. {{secret:vault/secret/myapp/prod#db_password}}
@@ -1,10 +1,12 @@
1
1
  /**
2
- * 1Password Connect / Service Account resolver
2
+ * 1Password secret resolver
3
3
  *
4
4
  * Credentials are NEVER stored in HTTP Forge config.
5
- * Authentication uses:
6
- * OP_SERVICE_ACCOUNT_TOKEN env var (1Password Service Account — recommended for CI)
7
- * OP_CONNECT_TOKEN + OP_CONNECT_HOST env vars (1Password Connect Server)
5
+ * Authentication priority:
6
+ * 1. OP_SERVICE_ACCOUNT_TOKEN env var → SDK service-account auth (no app/CLI)
7
+ * 2. `account` provider config → SDK DesktopAuth (personal account,
8
+ * requires the desktop app + SDK 0.5+)
9
+ * 3. `op` CLI signed-in session → interactive personal account
8
10
  *
9
11
  * Token syntax: {{secret:1password/<vault>/<item>/<field>}}
10
12
  * e.g. {{secret:1password/MyVault/MyApp/api_key}}
@@ -13,14 +15,27 @@
13
15
  * If `vault` is specified in the provider config, the token path may omit it:
14
16
  * {{secret:1password/<item>/<field>}}
15
17
  *
16
- * Uses the 1Password CLI (`op`) via child_process if SDK is unavailable.
18
+ * The SDK is used when either a service-account token or a desktop account is
19
+ * configured; otherwise this falls back to the 1Password CLI (`op`). If the SDK
20
+ * package is missing, the CLI is also used with the configured account.
17
21
  */
18
22
  import type { ISecretResolver, OnePasswordConfig } from '../../types/secret-resolver';
23
+ type ExecFileLike = (file: string, args: string[], options: Record<string, unknown>) => Promise<{
24
+ stdout: string;
25
+ stderr?: string;
26
+ }>;
19
27
  export declare class OnePasswordResolver implements ISecretResolver {
20
28
  readonly providerName = "1password";
21
29
  private readonly defaultVault;
22
- constructor(config: OnePasswordConfig);
30
+ private readonly account;
31
+ private readonly moduleRequire;
32
+ private readonly execFileFn;
33
+ private sdkClientPromise?;
34
+ private sdkAuthKey?;
35
+ constructor(config: OnePasswordConfig, moduleRequire?: (name: string) => any, execFileFn?: ExecFileLike);
23
36
  resolve(path: string): Promise<string | undefined>;
24
37
  private tryResolveSdk;
38
+ private getSdkClient;
25
39
  private resolveViaCli;
26
40
  }
41
+ export {};
@@ -13,14 +13,21 @@
13
13
  */
14
14
  import type { IConfigService } from '../config/config.interface';
15
15
  export declare class SecretResolverRegistry {
16
+ private readonly configService?;
16
17
  private readonly resolvers;
17
18
  /**
18
19
  * Require function rooted at the user's project (via config `scripts.modulePaths`),
19
20
  * so optional cloud SDKs resolve from the same place users install custom script
20
- * modules — not from the extension's own bundle.
21
+ * modules — not from the extension's own bundle. Rebuilt when module paths change.
21
22
  */
22
- private readonly moduleRequire;
23
- constructor(configService?: IConfigService);
23
+ private moduleRequire;
24
+ /**
25
+ * Snapshot of the config blocks that determine the resolver set. A config
26
+ * reload (including file-watcher reloads) changes this key, which triggers a
27
+ * rebuild on the next resolution instead of leaving startup resolvers stale.
28
+ */
29
+ private configKey?;
30
+ constructor(configService?: IConfigService | undefined);
24
31
  /**
25
32
  * Scan a string (or recursively, any object) for {{secret:alias/path}} tokens
26
33
  * and resolve them all in parallel.
@@ -31,8 +38,23 @@ export declare class SecretResolverRegistry {
31
38
  resolveSecretTokens(input: any, cache?: Map<string, string>): Promise<Record<string, string>>;
32
39
  /** Whether any providers are configured */
33
40
  get hasProviders(): boolean;
41
+ /**
42
+ * Rebuild the resolver set when the config snapshot changes.
43
+ *
44
+ * ConfigService.reload() swaps its in-memory config without notifying every
45
+ * consumer; comparing the small `secrets` block here keeps the registry in
46
+ * sync with file-watcher reloads while avoiding per-request rebuilds.
47
+ */
48
+ private refreshProviders;
34
49
  private collectTokens;
50
+ /**
51
+ * Normalize a captured template expression to the bare token.
52
+ * `{{secret:aws/x | upper}}` resolves the `secret:aws/x` value first and
53
+ * lets the normal interpolation pipeline apply the filter chain.
54
+ */
55
+ private baseToken;
35
56
  private createResolver;
57
+ private createCustomResolver;
36
58
  /**
37
59
  * Build a `require` function rooted at the user's project, so optional cloud SDKs
38
60
  * resolve from the same `node_modules` where users install custom script modules
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Resolved secret value tracking and opacity.
3
+ *
4
+ * Secret values are tracked in a WeakMap keyed by the prepared request. This
5
+ * keeps them out of JSON/webview payloads while still letting persistence code
6
+ * redact exact occurrences later in the execution pipeline.
7
+ *
8
+ * The protect/unprotect helpers keep a resolved value opaque to recursive
9
+ * variable interpolation: a secret containing `{{...}}` must not be treated as
10
+ * a template and expanded again.
11
+ */
12
+ /** Associate resolved secret values with a request/result object. */
13
+ export declare function attachSecretValues<T extends object>(target: T, values: Iterable<string> | undefined): T;
14
+ /** Read the resolved secret values associated with an object, if any. */
15
+ export declare function getSecretValues(target: object | null | undefined): readonly string[];
16
+ /** Copy tracked secret values from one object to a derived object. */
17
+ export declare function copySecretValues<T extends object>(source: object | null | undefined, target: T): T;
18
+ /** Replace template delimiters so a resolved value stays opaque during interpolation. */
19
+ export declare function protectSecretValue(value: string): string;
20
+ /** Restore template delimiters in a previously protected secret value. */
21
+ export declare function unprotectSecretValue(value: string): string;
22
+ /**
23
+ * Recursively restore protected delimiters in plain request data.
24
+ * Non-plain objects (Buffer, FormData, streams) are returned unchanged.
25
+ */
26
+ export declare function unprotectSecretValuesDeep<T>(value: T): T;
@@ -37,21 +37,30 @@ export declare function redactUrl(url: string): string;
37
37
  * Handles JSON objects, JSON strings, and URL-encoded form strings.
38
38
  */
39
39
  export declare function redactBody(body: any): any;
40
+ /**
41
+ * Recursively replace exact resolved secret values in plain data. This catches
42
+ * secrets used in URL path segments, innocuous header/field names, response
43
+ * echo bodies, assertion messages, and console output — cases that name-based
44
+ * redaction cannot detect.
45
+ */
46
+ export declare function redactSecretValuesDeep<T>(value: T, secretValues: readonly string[]): T;
40
47
  /**
41
48
  * Redact sensitive data from a HistoryEntry's sentRequest.
42
49
  * Returns a deep copy with sensitive values replaced.
43
50
  * The originalConfig (unresolved templates) is left untouched.
44
51
  */
45
- export declare function redactHistoryEntry(entry: HistoryEntry): HistoryEntry;
52
+ export declare function redactHistoryEntry(entry: HistoryEntry, secretValues?: readonly string[]): HistoryEntry;
46
53
  /**
47
- * Redact sensitive data from a FullResponse (response headers and cookies).
48
- * Response body is NOT redacted (too varied to pattern-match safely).
54
+ * Redact sensitive data from a FullResponse (headers, cookies, and exact
55
+ * resolved secret values echoed in the response body).
49
56
  */
50
- export declare function redactFullResponse(response: FullResponse): FullResponse;
57
+ export declare function redactFullResponse(response: FullResponse, secretValues?: readonly string[]): FullResponse;
51
58
  /**
52
- * Redact sensitive data from a FullResultDetails (suite test result).
59
+ * Redact sensitive data from a FullResultDetails (suite test result), including
60
+ * exact resolved secret values in request/response data, console output and
61
+ * assertion messages.
53
62
  */
54
- export declare function redactFullResultDetails(result: FullResultDetails): FullResultDetails;
63
+ export declare function redactFullResultDetails(result: FullResultDetails, secretValues?: readonly string[]): FullResultDetails;
55
64
  /** A single warning about a hardcoded sensitive value. */
56
65
  export interface SensitiveDataWarning {
57
66
  /** Where the issue was found (e.g. "header", "auth", "body", "query", "url") */
@@ -6,16 +6,17 @@
6
6
  *
7
7
  * Token syntax resolved by this interface: {{secret:provider/path}}
8
8
  * e.g. {{secret:aws/myapp/prod/db-password}}
9
- * {{secret:azure/https://myvault.vault.azure.net/secrets/apiKey}}
10
- * {{secret:vault/secret/data/myapp#password}}
11
- * {{secret:1password/MyVault/MyItem/password}}
9
+ * {{secret:azure/my-api-key}}
10
+ * {{secret:vault/myapp/prod#password}}
11
+ * {{secret:op/MyVault/MyItem/password}}
12
12
  *
13
13
  * Credentials are NEVER stored in HTTP Forge config.
14
14
  * Each provider uses its SDK's default credential chain:
15
15
  * - AWS → SDK credential chain (env vars / ~/.aws / IAM role)
16
16
  * - Azure → DefaultAzureCredential (env / managed identity / CLI login)
17
17
  * - Vault → VAULT_TOKEN / VAULT_ADDR env vars
18
- * - 1Password → OP_SERVICE_ACCOUNT_TOKEN env var
18
+ * - 1Password → OP_SERVICE_ACCOUNT_TOKEN env var, configured desktop account,
19
+ * or the signed-in `op` CLI session
19
20
  */
20
21
  export interface ISecretResolver {
21
22
  /**
@@ -64,6 +65,14 @@ export interface OnePasswordConfig {
64
65
  * If omitted, the path is expected to include vault/item/field.
65
66
  */
66
67
  vault?: string;
68
+ /**
69
+ * 1Password desktop-app account name (or account UUID) for personal-account auth.
70
+ * When OP_SERVICE_ACCOUNT_TOKEN is not set, the SDK uses DesktopAuth(account).
71
+ * Requires the 1Password desktop app and @1password/sdk 0.5.0 or newer.
72
+ * When the SDK package is unavailable, the same value is passed to the CLI as
73
+ * OP_ACCOUNT. If omitted, HTTP Forge uses the signed-in `op` CLI session.
74
+ */
75
+ account?: string;
67
76
  }
68
77
  export interface GcpSecretsConfig {
69
78
  provider: 'gcp';
@@ -81,7 +90,31 @@ export interface DopplerConfig {
81
90
  */
82
91
  serviceToken?: string;
83
92
  }
84
- export type SecretProviderConfig = AwsSecretsConfig | AzureKeyVaultConfig | HashiCorpVaultConfig | OnePasswordConfig | GcpSecretsConfig | DopplerConfig;
93
+ export interface CustomSecretProviderConfig {
94
+ provider: 'custom';
95
+ /**
96
+ * Module path or package name resolved from the first `scripts.modulePaths`
97
+ * entry that contains a package.json. Relative paths are resolved from that
98
+ * module directory.
99
+ */
100
+ module: string;
101
+ /** Non-sensitive options passed to the module's resolver factory. */
102
+ options?: Record<string, unknown>;
103
+ }
104
+ export interface CustomSecretProviderContext {
105
+ /** Alias used in `{{secret:<alias>/<path>}}`. */
106
+ alias: string;
107
+ /** The provider's `options` config, or an empty object. */
108
+ options: Record<string, unknown>;
109
+ }
110
+ export interface CustomSecretResolver {
111
+ /** Human-readable provider name; falls back to the configured alias. */
112
+ providerName?: string;
113
+ /** Resolve a secret path; return undefined when it does not exist. */
114
+ resolve(path: string): Promise<string | undefined>;
115
+ }
116
+ export type CustomSecretResolverFactory = (context: CustomSecretProviderContext) => CustomSecretResolver;
117
+ export type SecretProviderConfig = AwsSecretsConfig | AzureKeyVaultConfig | HashiCorpVaultConfig | OnePasswordConfig | GcpSecretsConfig | DopplerConfig | CustomSecretProviderConfig;
85
118
  /**
86
119
  * Top-level `secrets` block in http-forge.config.json
87
120
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@http-forge/core",
3
- "version": "0.6.41",
3
+ "version": "0.6.42",
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",
@@ -76,12 +76,16 @@
76
76
  "yaml": "^2.7.0"
77
77
  },
78
78
  "peerDependencies": {
79
+ "@1password/sdk": ">=0.1.0",
79
80
  "@aws-sdk/client-secrets-manager": ">=3.0.0",
80
81
  "@azure/identity": ">=3.0.0",
81
82
  "@azure/keyvault-secrets": ">=4.0.0",
82
- "node-vault": ">=0.9.0"
83
+ "@google-cloud/secret-manager": ">=5.0.0"
83
84
  },
84
85
  "peerDependenciesMeta": {
86
+ "@1password/sdk": {
87
+ "optional": true
88
+ },
85
89
  "@aws-sdk/client-secrets-manager": {
86
90
  "optional": true
87
91
  },
@@ -91,7 +95,7 @@
91
95
  "@azure/identity": {
92
96
  "optional": true
93
97
  },
94
- "node-vault": {
98
+ "@google-cloud/secret-manager": {
95
99
  "optional": true
96
100
  }
97
101
  },