@onyxsecurity/mcp-gateway 1.0.71 → 1.0.72

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.
Files changed (30) hide show
  1. package/dist/bin/mcp-gateway.js +2 -2
  2. package/dist/bin/mcp-gateway.js.map +1 -1
  3. package/dist/{cli-CdcSMGzs.js → cli-JCC2qGtw.js} +2 -2
  4. package/dist/{cli-CdcSMGzs.js.map → cli-JCC2qGtw.js.map} +1 -1
  5. package/dist/{env-U-H-5ckN.js → env-BnuHD5eY.js} +2 -2
  6. package/dist/{env-U-H-5ckN.js.map → env-BnuHD5eY.js.map} +1 -1
  7. package/dist/{env-CA395K36.js → env-DHl3_hWB.js} +1 -1
  8. package/dist/{helpers-DpRe9vc7.js → helpers-BPQVbZuN.js} +2 -2
  9. package/dist/helpers-BPQVbZuN.js.map +1 -0
  10. package/dist/index.js +1 -1
  11. package/dist/{logger-SA2az-xR.js → logger-oMpSZEyU.js} +2 -2
  12. package/dist/{logger-SA2az-xR.js.map → logger-oMpSZEyU.js.map} +1 -1
  13. package/dist/{main-CxI5J2Ez.js → main-k2nbXBwf.js} +2 -2
  14. package/dist/{main-CxI5J2Ez.js.map → main-k2nbXBwf.js.map} +1 -1
  15. package/dist/{oauthProvidersClient-Fxesyv3s.js → oauthProvidersClient-CXc5nmzo.js} +2 -2
  16. package/dist/{oauthProvidersClient-Fxesyv3s.js.map → oauthProvidersClient-CXc5nmzo.js.map} +1 -1
  17. package/dist/oauthProvidersClient-Mr86NGaJ.js +1 -0
  18. package/dist/{providers-BrPadh5c.js → providers-0y0vpfZj.js} +2 -2
  19. package/dist/{providers-BrPadh5c.js.map → providers-0y0vpfZj.js.map} +1 -1
  20. package/dist/secretstore-Bb3anONL.js +2 -0
  21. package/dist/secretstore-Bb3anONL.js.map +1 -0
  22. package/dist/{stdio-DcfnSJiF.js → stdio-CqyHOrvs.js} +2 -2
  23. package/dist/{stdio-DcfnSJiF.js.map → stdio-CqyHOrvs.js.map} +1 -1
  24. package/dist/{transportDetection-B8Oqn-xw.js → transportDetection-BQGSCPHb.js} +2 -2
  25. package/dist/{transportDetection-B8Oqn-xw.js.map → transportDetection-BQGSCPHb.js.map} +1 -1
  26. package/package.json +1 -1
  27. package/dist/helpers-DpRe9vc7.js.map +0 -1
  28. package/dist/oauthProvidersClient-D4JqW7V5.js +0 -1
  29. package/dist/secretstore-D1vTCZFj.js +0 -2
  30. package/dist/secretstore-D1vTCZFj.js.map +0 -1
@@ -1 +0,0 @@
1
- import"./env-U-H-5ckN.js";import"./logger-SA2az-xR.js";import"./providers-BrPadh5c.js";import{fetchOAuthProviders as e,initializeOAuthProviders as t}from"./oauthProvidersClient-Fxesyv3s.js";export{t as initializeOAuthProviders};
@@ -1,2 +0,0 @@
1
- import{join as e}from"node:path";import{env as t,platform as n}from"node:process";import{execFileSync as r}from"node:child_process";const i=`onyx-mcp-gateway`,a=`default`;async function o(e){return m(u(e),`LocalMachine`)}async function s(e){return n===`darwin`?d(e):n===`win32`?await o(e)??await c(e):f(e)}async function c(e){return m(l(e),`CurrentUser`)}function l(n){let r=t.LOCALAPPDATA??e(t.USERPROFILE??`C:\\`,`AppData`,`Local`);return e(r,`Onyx`,`mcp-gateway`,`${n}.bin`)}function u(n){let r=t.ProgramData??`C:\\ProgramData`;return e(r,`Onyx`,`mcp-gateway`,`${n}.bin`)}function d(e){return h(e,`/Library/Keychains/System.keychain`)??h(e,null)}async function f(e){try{return(await p(e)).getPassword()}catch{return null}}async function p(e){let{Entry:t}=await import(`@napi-rs/keyring`);return new t(i,e)}async function m(e,t){try{let{readFile:n}=await import(`node:fs/promises`),r=await n(e),{Dpapi:i}=await import(`@primno/dpapi`),a=i.unprotectData(new Uint8Array(r),null,t),o=Buffer.from(a).toString(`utf8`);return o===``?null:o}catch{return null}}function h(e,t){try{let n=[`find-generic-password`,`-s`,i,`-a`,e,`-w`];t!==null&&n.push(t);let a=r(`/usr/bin/security`,n,{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`],timeout:2e3}).trim();return a===``?null:a}catch{return null}}export{a as ACCOUNT_DEFAULT,s as getSecret};
2
- //# sourceMappingURL=secretstore-D1vTCZFj.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"secretstore-D1vTCZFj.js","names":[],"sources":["../src/lib/secretstore.ts"],"sourcesContent":["// Cross-platform keychain reader for the MCP Gateway.\n//\n// The scanner picks the store by privilege at install time: a privileged\n// (root/SYSTEM/MDM) install writes a MACHINE-SCOPED, boot-available store (so\n// it resolves even when no user is logged in); a regular-user install writes\n// that user's own per-user store. The gateway tries the machine store first,\n// then the per-user store. The read paths:\n//\n// macOS: shells out to /usr/bin/security. Tries the System keychain\n// (/Library/Keychains/System.keychain) explicitly first — where a privileged\n// install writes the allow-all (`-A`) entry, and passing the path explicitly\n// stops a customized search list from hiding it — then falls back to the\n// default search list, which covers the user's login keychain (where a\n// regular-user install writes). Same `security` caller on both ends ⇒ no\n// Keychain Services prompt.\n//\n// Linux: uses @napi-rs/keyring (libsecret) with the default (service, user)\n// constructor; libsecret stores by attribute set, not by TargetName, so\n// the default constructor finds entries the scanner wrote via go-keyring.\n// (No machine-scoped store on Linux — the scanner always uses the per-user\n// path.)\n//\n// Windows: reads a DPAPI blob (getMachineBlobSecret / getUserBlobSecret +\n// @primno/dpapi). Tries the machine blob under %ProgramData% (LocalMachine\n// scope — what a privileged/SYSTEM install writes, the path that works for\n// pre-login installs) first, then the per-user blob under %LOCALAPPDATA%\n// (CurrentUser scope — what a regular-user install writes). The scanner no\n// longer writes the per-user Credential Manager, so it isn't consulted.\n//\n// - macOS/Windows machine stores are unlocked at boot — no session, no prompt.\n// - the per-user stores (login keychain / CurrentUser blob) are readable by\n// the gateway running as that same user.\n// - Linux libsecret with an unlocked login keyring (the normal\n// desktop state) — silent. Locked / headless boxes return an error\n// which we treat as miss and fall through to env.\n//\n// All public functions are best-effort. On any error — missing backend,\n// timeout, malformed binding — getSecret returns null and the gateway\n// falls back to process.env (legacy behavior).\n//\n// Async API rationale: the @napi-rs/keyring native binding (Linux only) is\n// loaded via `await import(...)` so a missing prebuild on musl/alpine/headless\n// turns into a swallowed `catch` inside getSecretNative rather than a\n// module-load crash. Using `createRequire` for the same lazy-load worked\n// at runtime but was opaque to vitest's `vi.mock` (which only intercepts\n// ESM resolution), so the Linux test path resolved the real binding and\n// missed the mock. Dynamic ESM imports are interceptable on both runtime\n// and test paths.\n\nimport { execFileSync } from \"node:child_process\";\nimport { join } from \"node:path\";\nimport { env, platform } from \"node:process\";\n\n/** Keychain service name. MUST match scanner/internal/secretstore Service. */\nexport const SERVICE = \"onyx-mcp-gateway\";\n\n/** Single-tenant account name; multi-tenant on the same host is future work. */\nexport const ACCOUNT_DEFAULT = \"default\";\n\n/**\n * macOS machine-scoped keychain. The scanner writes the gateway key here (with\n * an allow-all ACL) so it is readable with no interactive-login dependency. We\n * pass this path explicitly rather than relying on the default search list, so\n * a customized search list can't hide the entry.\n */\nconst MAC_SYSTEM_KEYCHAIN = \"/Library/Keychains/System.keychain\";\n\n/** Hard cap on the security/Entry call so a hung backend never wedges startup. */\nconst READ_TIMEOUT_MS = 2_000;\n\n/**\n * getMachineBlobSecret reads the machine-scoped DPAPI blob a privileged install\n * writes under %ProgramData% (LocalMachine scope, readable by every user).\n */\nexport async function getMachineBlobSecret(account: string): Promise<null | string> {\n\treturn readDpapiBlob(programDataBlobPath(account), \"LocalMachine\");\n}\n\n/**\n * Look up the password under (SERVICE, account). Returns null on miss, on\n * any backend error, or if the underlying keychain access fails. Never\n * throws.\n */\nexport async function getSecret(account: string): Promise<null | string> {\n\tif (platform === \"darwin\") {\n\t\t// macOS: machine-scoped System keychain (where the scanner writes).\n\t\treturn getSecretMac(account);\n\t}\n\tif (platform === \"win32\") {\n\t\t// The scanner writes a privileged install to the machine blob\n\t\t// (%ProgramData%, LocalMachine) and a regular-user install to the\n\t\t// per-user blob (%LOCALAPPDATA%, CurrentUser). Try the machine blob\n\t\t// first, then the per-user blob. The scanner no longer writes the\n\t\t// per-user Credential Manager, so it isn't consulted.\n\t\treturn (await getMachineBlobSecret(account)) ?? (await getUserBlobSecret(account));\n\t}\n\t// Linux: per-user libsecret vault. No machine-scoped store exists, so the\n\t// scanner keeps the per-user path and we read it via @napi-rs/keyring.\n\treturn getSecretNative(account);\n}\n\n/**\n * getUserBlobSecret reads the per-user DPAPI blob a regular-user install writes\n * under %LOCALAPPDATA% (CurrentUser scope, readable only by that user).\n */\nexport async function getUserBlobSecret(account: string): Promise<null | string> {\n\treturn readDpapiBlob(localAppDataBlobPath(account), \"CurrentUser\");\n}\n\n/**\n * localAppDataBlobPath is the absolute path of the Windows per-user DPAPI blob a\n * regular-user install writes. MUST match scanner/internal/secretstore\n * userBlobPath: %LOCALAPPDATA%\\Onyx\\mcp-gateway\\<account>.bin.\n */\nexport function localAppDataBlobPath(account: string): string {\n\tconst base = env.LOCALAPPDATA ?? join(env.USERPROFILE ?? \"C:\\\\\", \"AppData\", \"Local\");\n\treturn join(base, \"Onyx\", \"mcp-gateway\", `${account}.bin`);\n}\n\n/**\n * programDataBlobPath is the absolute path of the Windows machine-scoped DPAPI\n * blob a privileged install writes. MUST match scanner/internal/secretstore\n * programDataBlobPath: %ProgramData%\\Onyx\\mcp-gateway\\<account>.bin.\n */\nexport function programDataBlobPath(account: string): string {\n\tconst base = env.ProgramData ?? \"C:\\\\ProgramData\";\n\treturn join(base, \"Onyx\", \"mcp-gateway\", `${account}.bin`);\n}\n\n/**\n * getSecretMac reads the gateway key from the macOS keychain. A privileged\n * install lands it in the System keychain (machine-wide); a regular-user\n * install lands it in the user's login keychain. Try the System keychain\n * explicitly first (so a customized search list can't hide it), then fall back\n * to the default search list, which covers the login keychain.\n */\nfunction getSecretMac(account: string): null | string {\n\treturn readSecurityKeychain(account, MAC_SYSTEM_KEYCHAIN) ?? readSecurityKeychain(account, null);\n}\n\nasync function getSecretNative(account: string): Promise<null | string> {\n\ttry {\n\t\tconst entry = await nativeEntry(account);\n\t\treturn entry.getPassword();\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Build an @napi-rs/keyring Entry for the Linux libsecret read. libsecret\n * matches by attribute set (service + user), so the default constructor finds\n * entries the scanner wrote via go-keyring. Linux is the only caller: darwin\n * shells to /usr/bin/security and Windows reads the machine DPAPI blob, so\n * neither loads the native binding. The dynamic `import` is lazy so a missing\n * prebuild on musl/alpine/headless becomes a swallowed exception inside\n * getSecretNative rather than a module-load crash. Using `await import(...)`\n * (rather than createRequire) makes the load interceptable by vitest's\n * `vi.mock` on the Linux test path.\n */\nasync function nativeEntry(account: string) {\n\tconst { Entry } = await import(\"@napi-rs/keyring\");\n\treturn new Entry(SERVICE, account);\n}\n\n/**\n * readDpapiBlob reads a Windows DPAPI blob from `path` and decrypts it with the\n * given scope. Best-effort: any error (file absent, decrypt failure, missing\n * binding) is swallowed and returns null so the caller falls back. The\n * @primno/dpapi import is lazy so a missing prebuild never crashes startup\n * (mirrors the @napi-rs/keyring lazy import).\n */\nasync function readDpapiBlob(\n\tpath: string,\n\tscope: \"CurrentUser\" | \"LocalMachine\",\n): Promise<null | string> {\n\ttry {\n\t\tconst { readFile } = await import(\"node:fs/promises\");\n\t\tconst blob = await readFile(path);\n\t\tconst { Dpapi } = await import(\"@primno/dpapi\");\n\t\tconst decrypted = Dpapi.unprotectData(new Uint8Array(blob), null, scope);\n\t\tconst value = Buffer.from(decrypted).toString(\"utf8\");\n\t\treturn value === \"\" ? null : value;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n// readSecurityKeychain runs `security find-generic-password -w`, reading the\n// explicit `keychain` path when given or the default search list when null.\n// Returns null on any miss/error.\nfunction readSecurityKeychain(account: string, keychain: null | string): null | string {\n\ttry {\n\t\tconst args = [\"find-generic-password\", \"-s\", SERVICE, \"-a\", account, \"-w\"];\n\t\tif (keychain !== null) {\n\t\t\targs.push(keychain);\n\t\t}\n\t\tconst out = execFileSync(\"/usr/bin/security\", args, {\n\t\t\tencoding: \"utf8\",\n\t\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t\t\ttimeout: READ_TIMEOUT_MS,\n\t\t});\n\t\tconst trimmed = out.trim();\n\t\treturn trimmed === \"\" ? null : trimmed;\n\t} catch {\n\t\t// \"could not be found\" or any other security CLI error → treated as miss.\n\t\treturn null;\n\t}\n}\n"],"mappings":"oIAsDA,MAAa,EAAU,mBAGV,EAAkB,UAiB/B,eAAsB,EAAqB,EAAyC,CACnF,OAAO,EAAc,EAAoB,EAAQ,CAAE,eAAe,CAQnE,eAAsB,EAAU,EAAyC,CAexE,OAdI,IAAa,SAET,EAAa,EAAQ,CAEzB,IAAa,QAMR,MAAM,EAAqB,EAAQ,EAAM,MAAM,EAAkB,EAAQ,CAI3E,EAAgB,EAAQ,CAOhC,eAAsB,EAAkB,EAAyC,CAChF,OAAO,EAAc,EAAqB,EAAQ,CAAE,cAAc,CAQnE,SAAgB,EAAqB,EAAyB,CAC7D,IAAM,EAAO,EAAI,cAAgB,EAAK,EAAI,aAAe,OAAQ,UAAW,QAAQ,CACpF,OAAO,EAAK,EAAM,OAAQ,cAAe,GAAG,EAAQ,MAAM,CAQ3D,SAAgB,EAAoB,EAAyB,CAC5D,IAAM,EAAO,EAAI,aAAe,kBAChC,OAAO,EAAK,EAAM,OAAQ,cAAe,GAAG,EAAQ,MAAM,CAU3D,SAAS,EAAa,EAAgC,CACrD,OAAO,EAAqB,EAAS,qCAAoB,EAAI,EAAqB,EAAS,KAAK,CAGjG,eAAe,EAAgB,EAAyC,CACvE,GAAI,CAEH,OADc,MAAM,EAAY,EAAQ,EAC3B,aAAa,MACnB,CACP,OAAO,MAeT,eAAe,EAAY,EAAiB,CAC3C,GAAM,CAAE,SAAU,MAAM,OAAO,oBAC/B,OAAO,IAAI,EAAM,EAAS,EAAQ,CAUnC,eAAe,EACd,EACA,EACyB,CACzB,GAAI,CACH,GAAM,CAAE,YAAa,MAAM,OAAO,oBAC5B,EAAO,MAAM,EAAS,EAAK,CAC3B,CAAE,SAAU,MAAM,OAAO,iBACzB,EAAY,EAAM,cAAc,IAAI,WAAW,EAAK,CAAE,KAAM,EAAM,CAClE,EAAQ,OAAO,KAAK,EAAU,CAAC,SAAS,OAAO,CACrD,OAAO,IAAU,GAAK,KAAO,OACtB,CACP,OAAO,MAOT,SAAS,EAAqB,EAAiB,EAAwC,CACtF,GAAI,CACH,IAAM,EAAO,CAAC,wBAAyB,KAAM,EAAS,KAAM,EAAS,KAAK,CACtE,IAAa,MAChB,EAAK,KAAK,EAAS,CAOpB,IAAM,EALM,EAAa,oBAAqB,EAAM,CACnD,SAAU,OACV,MAAO,CAAC,SAAU,OAAQ,SAAS,CACnC,QAAS,IACT,CAAC,CACkB,MAAM,CAC1B,OAAO,IAAY,GAAK,KAAO,OACxB,CAEP,OAAO"}