@pulsemcp/air-secrets-file 0.0.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/dist/file-transform.d.ts +13 -0
- package/dist/file-transform.d.ts.map +1 -0
- package/dist/file-transform.js +56 -0
- package/dist/file-transform.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { McpConfig, TransformContext } from "@pulsemcp/air-core";
|
|
2
|
+
/**
|
|
3
|
+
* Transform that resolves ${VAR} patterns from a JSON secrets file.
|
|
4
|
+
*
|
|
5
|
+
* The file path is provided via the --secrets-file CLI option (passed
|
|
6
|
+
* through context.options["secrets-file"]). If the option is not set,
|
|
7
|
+
* this transform is a no-op.
|
|
8
|
+
*
|
|
9
|
+
* The secrets file must be a JSON object of key-value string pairs:
|
|
10
|
+
* { "MY_SECRET": "value", "ANOTHER": "value2" }
|
|
11
|
+
*/
|
|
12
|
+
export declare function fileTransform(config: McpConfig, context: TransformContext): Promise<McpConfig>;
|
|
13
|
+
//# sourceMappingURL=file-transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-transform.d.ts","sourceRoot":"","sources":["../src/file-transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItE;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,CAAC,CAkBpB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
const ENV_VAR_PATTERN = /\$\{([^}]+)\}/g;
|
|
3
|
+
/**
|
|
4
|
+
* Transform that resolves ${VAR} patterns from a JSON secrets file.
|
|
5
|
+
*
|
|
6
|
+
* The file path is provided via the --secrets-file CLI option (passed
|
|
7
|
+
* through context.options["secrets-file"]). If the option is not set,
|
|
8
|
+
* this transform is a no-op.
|
|
9
|
+
*
|
|
10
|
+
* The secrets file must be a JSON object of key-value string pairs:
|
|
11
|
+
* { "MY_SECRET": "value", "ANOTHER": "value2" }
|
|
12
|
+
*/
|
|
13
|
+
export async function fileTransform(config, context) {
|
|
14
|
+
const secretsFilePath = context.options["secrets-file"];
|
|
15
|
+
if (!secretsFilePath)
|
|
16
|
+
return config;
|
|
17
|
+
let secrets;
|
|
18
|
+
try {
|
|
19
|
+
secrets = JSON.parse(readFileSync(secretsFilePath, "utf-8"));
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
23
|
+
throw new Error(`Failed to read secrets file "${secretsFilePath}": ${message}`);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...config,
|
|
27
|
+
mcpServers: resolveObject(config.mcpServers, secrets),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function resolveObject(obj, secrets) {
|
|
31
|
+
const result = {};
|
|
32
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
33
|
+
result[key] = resolveValue(value, secrets);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
function resolveValue(value, secrets) {
|
|
38
|
+
if (typeof value === "string") {
|
|
39
|
+
return value.replace(ENV_VAR_PATTERN, (match, varName) => {
|
|
40
|
+
const secretVal = secrets[varName];
|
|
41
|
+
return secretVal !== undefined ? secretVal : match;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
return value.map((v) => resolveValue(v, secrets));
|
|
46
|
+
}
|
|
47
|
+
if (value !== null && typeof value === "object") {
|
|
48
|
+
const resolved = {};
|
|
49
|
+
for (const [k, v] of Object.entries(value)) {
|
|
50
|
+
resolved[k] = resolveValue(v, secrets);
|
|
51
|
+
}
|
|
52
|
+
return resolved;
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=file-transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-transform.js","sourceRoot":"","sources":["../src/file-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAGlC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEzC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAiB,EACjB,OAAyB;IAEzB,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAuB,CAAC;IAC9E,IAAI,CAAC,eAAe;QAAE,OAAO,MAAM,CAAC;IAEpC,IAAI,OAA+B,CAAC;IACpC,IAAI,CAAC;QACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,MAAM,IAAI,KAAK,CACb,gCAAgC,eAAe,MAAM,OAAO,EAAE,CAC/D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,MAAM;QACT,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC;KACtD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CACpB,GAA4C,EAC5C,OAA+B;IAE/B,MAAM,MAAM,GAA4C,EAAE,CAAC;IAC3D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM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E,MAAM,qBAAqB,CAAC;AAEpD,QAAA,MAAM,SAAS,EAAE,YAUhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { fileTransform } from "./file-transform.js";
|
|
2
|
+
export { fileTransform } from "./file-transform.js";
|
|
3
|
+
const extension = {
|
|
4
|
+
name: "secrets-file",
|
|
5
|
+
transform: { transform: fileTransform },
|
|
6
|
+
prepareOptions: [
|
|
7
|
+
{
|
|
8
|
+
flag: "--secrets-file <path>",
|
|
9
|
+
description: "Path to a JSON file containing secret values for ${VAR} interpolation",
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
export default extension;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,SAAS,GAAiB;IAC9B,IAAI,EAAE,cAAc;IACpB,SAAS,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE;IACvC,cAAc,EAAE;QACd;YACE,IAAI,EAAE,uBAAuB;YAC7B,WAAW,EACT,uEAAuE;SAC1E;KACF;CACF,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pulsemcp/air-secrets-file",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/pulsemcp/air.git",
|
|
10
|
+
"directory": "packages/extensions/secrets-file"
|
|
11
|
+
},
|
|
12
|
+
"description": "AIR transform that resolves ${VAR} patterns from a JSON secrets file in MCP configs",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest",
|
|
29
|
+
"lint": "tsc --noEmit"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@pulsemcp/air-core": "0.0.10"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^22.10.0",
|
|
36
|
+
"typescript": "^5.7.0",
|
|
37
|
+
"vitest": "^2.1.0"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
}
|
|
42
|
+
}
|