@http-forge/core 1.0.6 → 1.0.8
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 +1 -1
- package/dist/index.js +149 -149
- package/dist/index.mjs +149 -149
- package/dist/infrastructure/collection/folder-collection-store.d.ts +12 -1
- package/dist/infrastructure/http/native-http-client.d.ts +10 -1
- package/dist/infrastructure/secrets/aws-secret-resolver.d.ts +4 -3
- package/dist/infrastructure/secrets/azure-keyvault-resolver.d.ts +4 -3
- package/dist/infrastructure/secrets/base-secret-resolver.d.ts +50 -0
- package/dist/infrastructure/secrets/doppler-resolver.d.ts +4 -3
- package/dist/infrastructure/secrets/gcp-secret-resolver.d.ts +4 -3
- package/dist/infrastructure/secrets/hashicorp-vault-resolver.d.ts +4 -3
- package/dist/infrastructure/secrets/onepassword-resolver.d.ts +4 -3
- package/dist/infrastructure/secrets/secret-resolver-registry.d.ts +13 -1
- package/dist/templates/lib-package.json +3 -1
- package/dist/types/secret-resolver.d.ts +5 -0
- package/package.json +1 -1
|
@@ -42,6 +42,11 @@ export declare class FolderCollectionStore implements ICollectionStore {
|
|
|
42
42
|
* one item does not re-scan the whole collection folder for every lookup.
|
|
43
43
|
*/
|
|
44
44
|
private itemPathIndex;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the startup freshness check has already been performed this session.
|
|
47
|
+
* After the first load, we trust the cache (file watcher handles external changes).
|
|
48
|
+
*/
|
|
49
|
+
private startupFreshnessChecked;
|
|
45
50
|
/**
|
|
46
51
|
* Directory for serialized collection metadata caches. Lives inside the
|
|
47
52
|
* collections directory as `.cache/` so it is self-contained and already
|
|
@@ -120,7 +125,13 @@ export declare class FolderCollectionStore implements ICollectionStore {
|
|
|
120
125
|
* Write the collection cache asynchronously (fire-and-forget).
|
|
121
126
|
* Uses collection.json's mtime as the freshness key.
|
|
122
127
|
*/
|
|
123
|
-
private
|
|
128
|
+
private saveCollectionToCache;
|
|
129
|
+
/**
|
|
130
|
+
* Compute the maximum mtime of all files in a collection directory tree.
|
|
131
|
+
* Used as a freshness key for the cache: if any file was modified externally,
|
|
132
|
+
* the max mtime will be newer than the cached value.
|
|
133
|
+
*/
|
|
134
|
+
private computeMaxMtime;
|
|
124
135
|
/**
|
|
125
136
|
* Invalidate (delete) the cache for a collection.
|
|
126
137
|
*/
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
* - Cookie parsing from Set-Cookie headers
|
|
16
16
|
*/
|
|
17
17
|
import { IHttpClient } from '../../types/platform';
|
|
18
|
+
import { IConsoleService } from '../../types/console-service';
|
|
18
19
|
import { HttpRequest, HttpResponse, RequestSettings } from '../../types/types';
|
|
19
20
|
import { ProxyConfig } from '../config/config.interface';
|
|
21
|
+
import type { SecretResolverRegistry } from '../secrets/secret-resolver-registry';
|
|
20
22
|
/**
|
|
21
23
|
* Default request settings
|
|
22
24
|
* Same as plugin's DEFAULT_REQUEST_SETTINGS from shared/constants.ts
|
|
@@ -36,6 +38,11 @@ export type RequestSettingsSource = Partial<RequestSettings> | (() => Partial<Re
|
|
|
36
38
|
* May be a static config object or a provider function for live config reloads.
|
|
37
39
|
*/
|
|
38
40
|
export type ProxySource = ProxyConfig | null | undefined | (() => ProxyConfig | null | undefined);
|
|
41
|
+
/**
|
|
42
|
+
* Source of the secret resolver registry for {@link NodeHttpClient}.
|
|
43
|
+
* May be a provider function for live config reloads.
|
|
44
|
+
*/
|
|
45
|
+
export type SecretRegistrySource = SecretResolverRegistry | null | undefined | (() => SecretResolverRegistry | null | undefined);
|
|
39
46
|
/**
|
|
40
47
|
* Native HTTP client using Node.js http/https modules
|
|
41
48
|
*
|
|
@@ -44,9 +51,11 @@ export type ProxySource = ProxyConfig | null | undefined | (() => ProxyConfig |
|
|
|
44
51
|
export declare class NodeHttpClient implements IHttpClient {
|
|
45
52
|
private readonly resolveDefaults;
|
|
46
53
|
private readonly resolveProxy;
|
|
54
|
+
private readonly resolveSecretRegistry;
|
|
55
|
+
private readonly resolveConsole;
|
|
47
56
|
private version;
|
|
48
57
|
private readonly basePath;
|
|
49
|
-
constructor(defaultSettings?: RequestSettingsSource, basePath?: string, proxySource?: ProxySource);
|
|
58
|
+
constructor(defaultSettings?: RequestSettingsSource, basePath?: string, proxySource?: ProxySource, secretRegistrySource?: SecretRegistrySource, consoleServiceSource?: (() => IConsoleService | null | undefined));
|
|
50
59
|
/** Current default settings, resolved fresh from the configured source. */
|
|
51
60
|
private get settings();
|
|
52
61
|
/**
|
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
* e.g. {{secret:aws/myapp/prod/db-password}}
|
|
11
11
|
* {{secret:aws/myapp/prod/api-key#field}} (JSON secret field)
|
|
12
12
|
*/
|
|
13
|
-
import type { AwsSecretsConfig
|
|
14
|
-
|
|
13
|
+
import type { AwsSecretsConfig } from '../../types/secret-resolver';
|
|
14
|
+
import { BaseSecretResolver } from './base-secret-resolver';
|
|
15
|
+
export declare class AwsSecretResolver extends BaseSecretResolver {
|
|
15
16
|
readonly providerName = "aws";
|
|
16
17
|
private readonly region;
|
|
17
18
|
private readonly profile;
|
|
18
19
|
private readonly moduleRequire;
|
|
19
20
|
private sdk?;
|
|
20
21
|
constructor(config: AwsSecretsConfig, moduleRequire?: (name: string) => any);
|
|
21
|
-
|
|
22
|
+
protected fetchRaw(secretId: string): Promise<string | undefined>;
|
|
22
23
|
}
|
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Config requires vaultUrl, e.g. "https://myvault.vault.azure.net"
|
|
12
12
|
*/
|
|
13
|
-
import type { AzureKeyVaultConfig
|
|
14
|
-
|
|
13
|
+
import type { AzureKeyVaultConfig } from '../../types/secret-resolver';
|
|
14
|
+
import { BaseSecretResolver } from './base-secret-resolver';
|
|
15
|
+
export declare class AzureKeyVaultResolver extends BaseSecretResolver {
|
|
15
16
|
readonly providerName = "azure";
|
|
16
17
|
private readonly vaultUrl;
|
|
17
18
|
private readonly moduleRequire;
|
|
18
19
|
private client?;
|
|
19
20
|
constructor(config: AzureKeyVaultConfig, moduleRequire?: (name: string) => any);
|
|
20
|
-
|
|
21
|
+
protected fetchRaw(secretName: string, _jsonPath?: string): Promise<string | undefined>;
|
|
21
22
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Secret Resolver — universal caching + JSON path resolution.
|
|
3
|
+
*
|
|
4
|
+
* Specific providers (AWS, Azure, GCP, Vault, ...) extend this class and
|
|
5
|
+
* implement only `fetchRaw(secretName)`, which retrieves the raw secret string
|
|
6
|
+
* from the backing store. All shared logic lives here:
|
|
7
|
+
*
|
|
8
|
+
* - TTL-based caching of raw secret strings (cross-request, per instance)
|
|
9
|
+
* - Universal JSON path resolution with dot-notation and array indices:
|
|
10
|
+
* {{secret:alias/secret-name}} → raw string
|
|
11
|
+
* {{secret:alias/secret-name.field}} → JSON field (nested)
|
|
12
|
+
* {{secret:alias/secret-name.items[0].id}} → array index traversal
|
|
13
|
+
* {{secret:alias/secret-name#field}} → legacy #field (still supported)
|
|
14
|
+
* - Conversion of resolved values to strings
|
|
15
|
+
*
|
|
16
|
+
* Providers never parse JSON or manage cache themselves.
|
|
17
|
+
*/
|
|
18
|
+
export interface SecretCacheEntry {
|
|
19
|
+
value: string;
|
|
20
|
+
expiresAt: number;
|
|
21
|
+
}
|
|
22
|
+
export declare abstract class BaseSecretResolver {
|
|
23
|
+
readonly abstract providerName: string;
|
|
24
|
+
/** Default TTL: 5 minutes. Override via constructor option. */
|
|
25
|
+
protected readonly ttlMs: number;
|
|
26
|
+
private readonly cache;
|
|
27
|
+
constructor(options?: {
|
|
28
|
+
cacheTtlMs?: number;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Public entry point. Handles caching, path splitting, JSON parsing and
|
|
32
|
+
* traversal. Providers implement `fetchRaw` only.
|
|
33
|
+
*/
|
|
34
|
+
resolve(secretPath: string): Promise<string | undefined>;
|
|
35
|
+
private resolvePath;
|
|
36
|
+
/**
|
|
37
|
+
* Provider-specific raw string retrieval. Implement in subclasses.
|
|
38
|
+
* Must return the raw secret payload as a string (possibly JSON).
|
|
39
|
+
*/
|
|
40
|
+
protected abstract fetchRaw(secretName: string, jsonPath?: string): Promise<string | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* Clear the cache (e.g. on config reload or manual refresh).
|
|
43
|
+
*/
|
|
44
|
+
clearCache(): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Traverse a parsed JSON value using a dot-notation path with array indices.
|
|
48
|
+
* Supports: "a.b", "a[0]", "a.b[0].c", "items[2][1]".
|
|
49
|
+
*/
|
|
50
|
+
export declare function traverseJsonPath(obj: any, path: string): any;
|
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
* Prerequisites: none (uses Node.js built-in https)
|
|
15
15
|
*/
|
|
16
16
|
import type { ClientRequest, IncomingMessage, RequestOptions } from 'http';
|
|
17
|
-
import type { DopplerConfig
|
|
17
|
+
import type { DopplerConfig } from '../../types/secret-resolver';
|
|
18
|
+
import { BaseSecretResolver } from './base-secret-resolver';
|
|
18
19
|
type DopplerRequestFn = (url: string, options: RequestOptions, callback: (res: IncomingMessage) => void) => ClientRequest;
|
|
19
|
-
export declare class DopplerResolver
|
|
20
|
+
export declare class DopplerResolver extends BaseSecretResolver {
|
|
20
21
|
readonly providerName = "doppler";
|
|
21
22
|
private readonly token;
|
|
22
23
|
private readonly requestFn;
|
|
23
24
|
constructor(config: DopplerConfig, requestFn?: DopplerRequestFn);
|
|
24
|
-
|
|
25
|
+
protected fetchRaw(secretName: string, _jsonPath?: string): Promise<string | undefined>;
|
|
25
26
|
}
|
|
26
27
|
export {};
|
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
* Config: { "provider": "gcp", "projectId": "my-project" }
|
|
12
12
|
* projectId falls back to GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env vars.
|
|
13
13
|
*/
|
|
14
|
-
import type { GcpSecretsConfig
|
|
15
|
-
|
|
14
|
+
import type { GcpSecretsConfig } from '../../types/secret-resolver';
|
|
15
|
+
import { BaseSecretResolver } from './base-secret-resolver';
|
|
16
|
+
export declare class GcpSecretResolver extends BaseSecretResolver {
|
|
16
17
|
readonly providerName = "gcp";
|
|
17
18
|
private readonly projectId;
|
|
18
19
|
private readonly moduleRequire;
|
|
19
20
|
private client?;
|
|
20
21
|
constructor(config: GcpSecretsConfig, moduleRequire?: (name: string) => any);
|
|
21
|
-
|
|
22
|
+
protected fetchRaw(secretName: string, _jsonPath?: string): Promise<string | undefined>;
|
|
22
23
|
}
|
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
* The path format after the provider prefix: <mount>/<path>#<field>
|
|
15
15
|
* If no field is specified and the secret has a single key "value", that is returned.
|
|
16
16
|
*/
|
|
17
|
-
import type { HashiCorpVaultConfig
|
|
18
|
-
|
|
17
|
+
import type { HashiCorpVaultConfig } from '../../types/secret-resolver';
|
|
18
|
+
import { BaseSecretResolver } from './base-secret-resolver';
|
|
19
|
+
export declare class HashiCorpVaultResolver extends BaseSecretResolver {
|
|
19
20
|
readonly providerName = "vault";
|
|
20
21
|
private readonly address;
|
|
21
22
|
private readonly mountPath;
|
|
22
23
|
private readonly namespace;
|
|
23
24
|
constructor(config: HashiCorpVaultConfig);
|
|
24
|
-
|
|
25
|
+
protected fetchRaw(secretPath: string, jsonPath?: string): Promise<string | undefined>;
|
|
25
26
|
}
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
* configured; otherwise this falls back to the 1Password CLI (`op`). If the SDK
|
|
20
20
|
* package is missing, the CLI is also used with the configured account.
|
|
21
21
|
*/
|
|
22
|
-
import type {
|
|
22
|
+
import type { OnePasswordConfig } from '../../types/secret-resolver';
|
|
23
|
+
import { BaseSecretResolver } from './base-secret-resolver';
|
|
23
24
|
type ExecFileLike = (file: string, args: string[], options: Record<string, unknown>) => Promise<{
|
|
24
25
|
stdout: string;
|
|
25
26
|
stderr?: string;
|
|
26
27
|
}>;
|
|
27
|
-
export declare class OnePasswordResolver
|
|
28
|
+
export declare class OnePasswordResolver extends BaseSecretResolver {
|
|
28
29
|
readonly providerName = "1password";
|
|
29
30
|
private readonly defaultVault;
|
|
30
31
|
private readonly account;
|
|
@@ -33,7 +34,7 @@ export declare class OnePasswordResolver implements ISecretResolver {
|
|
|
33
34
|
private sdkClientPromise?;
|
|
34
35
|
private sdkAuthKey?;
|
|
35
36
|
constructor(config: OnePasswordConfig, moduleRequire?: (name: string) => any, execFileFn?: ExecFileLike);
|
|
36
|
-
|
|
37
|
+
protected fetchRaw(secretName: string, _jsonPath?: string): Promise<string | undefined>;
|
|
37
38
|
private tryResolveSdk;
|
|
38
39
|
private getSdkClient;
|
|
39
40
|
private resolveViaCli;
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
* - Results are cached within a single request lifetime to avoid redundant API calls
|
|
13
13
|
*/
|
|
14
14
|
import type { IConfigService } from '../config/config.interface';
|
|
15
|
+
import type { IConsoleService } from '../../types/console-service';
|
|
15
16
|
export declare class SecretResolverRegistry {
|
|
16
17
|
private readonly configService?;
|
|
18
|
+
private readonly consoleService?;
|
|
17
19
|
private readonly resolvers;
|
|
18
20
|
/**
|
|
19
21
|
* Require function rooted at the user's project (via config `scripts.modulePaths`),
|
|
@@ -27,7 +29,12 @@ export declare class SecretResolverRegistry {
|
|
|
27
29
|
* rebuild on the next resolution instead of leaving startup resolvers stale.
|
|
28
30
|
*/
|
|
29
31
|
private configKey?;
|
|
30
|
-
constructor(configService?: IConfigService | undefined);
|
|
32
|
+
constructor(configService?: IConfigService | undefined, consoleService?: IConsoleService | undefined);
|
|
33
|
+
/**
|
|
34
|
+
* Log a warning via the console service (VS Code output channel) when
|
|
35
|
+
* available, falling back to console.warn for CLI/standalone.
|
|
36
|
+
*/
|
|
37
|
+
private logWarn;
|
|
31
38
|
/**
|
|
32
39
|
* Scan a string (or recursively, any object) for {{secret:alias/path}} tokens
|
|
33
40
|
* and resolve them all in parallel.
|
|
@@ -36,6 +43,11 @@ export declare class SecretResolverRegistry {
|
|
|
36
43
|
* suitable for injection as extraVariables into VariableResolver.
|
|
37
44
|
*/
|
|
38
45
|
resolveSecretTokens(input: any, cache?: Map<string, string>): Promise<Record<string, string>>;
|
|
46
|
+
/**
|
|
47
|
+
* Clear all cached secret values across all providers.
|
|
48
|
+
* Called at the start of each run so stale secrets aren't reused.
|
|
49
|
+
*/
|
|
50
|
+
clearCache(): void;
|
|
39
51
|
/** Whether any providers are configured */
|
|
40
52
|
get hasProviders(): boolean;
|
|
41
53
|
/**
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
"xml2js": "^0.6.2",
|
|
17
17
|
"tv4": "^1.3.0",
|
|
18
18
|
"ajv": "^8.17.1",
|
|
19
|
-
"cheerio": "^1.1.2"
|
|
19
|
+
"cheerio": "^1.1.2",
|
|
20
|
+
"@aws-sdk/client-secrets-manager": "^3.1021.0",
|
|
21
|
+
"@google-cloud/secret-manager": "^7.2.0"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
22
24
|
"@types/node": "^20.0.0",
|
|
@@ -22,6 +22,7 @@ export interface ISecretResolver {
|
|
|
22
22
|
/**
|
|
23
23
|
* Resolve a secret by its provider-relative path.
|
|
24
24
|
* @param path The path after the provider prefix, e.g. "myapp/prod/apiKey"
|
|
25
|
+
* or "myapp/prod/apiKey.nested.key" for JSON path traversal.
|
|
25
26
|
* @returns The plaintext secret value, or undefined if not found
|
|
26
27
|
*/
|
|
27
28
|
resolve(path: string): Promise<string | undefined>;
|
|
@@ -29,6 +30,10 @@ export interface ISecretResolver {
|
|
|
29
30
|
* Human-readable provider name, e.g. "aws", "azure", "vault", "1password"
|
|
30
31
|
*/
|
|
31
32
|
readonly providerName: string;
|
|
33
|
+
/**
|
|
34
|
+
* Clear the in-memory cache for this resolver (optional).
|
|
35
|
+
*/
|
|
36
|
+
clearCache?(): void;
|
|
32
37
|
}
|
|
33
38
|
export interface AwsSecretsConfig {
|
|
34
39
|
provider: 'aws';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@http-forge/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
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",
|