@n24q02m/hull 0.0.0-stage → 0.4.0-beta.9

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 (231) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +166 -2
  3. package/build/auth/credential-form.d.ts +163 -0
  4. package/build/auth/credential-form.d.ts.map +1 -0
  5. package/build/auth/credential-form.js +1869 -0
  6. package/build/auth/credential-form.js.map +1 -0
  7. package/build/auth/delegated-oauth-app.d.ts +90 -0
  8. package/build/auth/delegated-oauth-app.d.ts.map +1 -0
  9. package/build/auth/delegated-oauth-app.js +881 -0
  10. package/build/auth/delegated-oauth-app.js.map +1 -0
  11. package/build/auth/index.d.ts +12 -0
  12. package/build/auth/index.d.ts.map +1 -0
  13. package/build/auth/index.js +12 -0
  14. package/build/auth/index.js.map +1 -0
  15. package/build/auth/local-oauth-app.d.ts +152 -0
  16. package/build/auth/local-oauth-app.d.ts.map +1 -0
  17. package/build/auth/local-oauth-app.js +975 -0
  18. package/build/auth/local-oauth-app.js.map +1 -0
  19. package/build/auth/relay-login.d.ts +46 -0
  20. package/build/auth/relay-login.d.ts.map +1 -0
  21. package/build/auth/relay-login.js +197 -0
  22. package/build/auth/relay-login.js.map +1 -0
  23. package/build/auth/router.d.ts +18 -0
  24. package/build/auth/router.d.ts.map +1 -0
  25. package/build/auth/router.js +62 -0
  26. package/build/auth/router.js.map +1 -0
  27. package/build/auth/session-store.d.ts +49 -0
  28. package/build/auth/session-store.d.ts.map +1 -0
  29. package/build/auth/session-store.js +94 -0
  30. package/build/auth/session-store.js.map +1 -0
  31. package/build/auth/stable-sub.d.ts +27 -0
  32. package/build/auth/stable-sub.d.ts.map +1 -0
  33. package/build/auth/stable-sub.js +38 -0
  34. package/build/auth/stable-sub.js.map +1 -0
  35. package/build/auth/well-known.d.ts +4 -0
  36. package/build/auth/well-known.d.ts.map +1 -0
  37. package/build/auth/well-known.js +26 -0
  38. package/build/auth/well-known.js.map +1 -0
  39. package/build/cli/build-cli.d.ts +97 -0
  40. package/build/cli/build-cli.d.ts.map +1 -0
  41. package/build/cli/build-cli.js +309 -0
  42. package/build/cli/build-cli.js.map +1 -0
  43. package/build/cli/index.d.ts +2 -0
  44. package/build/cli/index.d.ts.map +1 -0
  45. package/build/cli/index.js +2 -0
  46. package/build/cli/index.js.map +1 -0
  47. package/build/crypto/aes.d.ts +8 -0
  48. package/build/crypto/aes.d.ts.map +1 -0
  49. package/build/crypto/aes.js +27 -0
  50. package/build/crypto/aes.js.map +1 -0
  51. package/build/crypto/ecdh.d.ts +5 -0
  52. package/build/crypto/ecdh.d.ts.map +1 -0
  53. package/build/crypto/ecdh.js +16 -0
  54. package/build/crypto/ecdh.js.map +1 -0
  55. package/build/crypto/index.d.ts +4 -0
  56. package/build/crypto/index.d.ts.map +1 -0
  57. package/build/crypto/index.js +4 -0
  58. package/build/crypto/index.js.map +1 -0
  59. package/build/crypto/kdf.d.ts +15 -0
  60. package/build/crypto/kdf.d.ts.map +1 -0
  61. package/build/crypto/kdf.js +26 -0
  62. package/build/crypto/kdf.js.map +1 -0
  63. package/build/index.d.ts +19 -0
  64. package/build/index.d.ts.map +1 -0
  65. package/build/index.js +28 -0
  66. package/build/index.js.map +1 -0
  67. package/build/lifecycle/lock.d.ts +68 -0
  68. package/build/lifecycle/lock.d.ts.map +1 -0
  69. package/build/lifecycle/lock.js +173 -0
  70. package/build/lifecycle/lock.js.map +1 -0
  71. package/build/oauth/cache.d.ts +22 -0
  72. package/build/oauth/cache.d.ts.map +1 -0
  73. package/build/oauth/cache.js +24 -0
  74. package/build/oauth/cache.js.map +1 -0
  75. package/build/oauth/index.d.ts +6 -0
  76. package/build/oauth/index.d.ts.map +1 -0
  77. package/build/oauth/index.js +6 -0
  78. package/build/oauth/index.js.map +1 -0
  79. package/build/oauth/jwt-issuer.d.ts +87 -0
  80. package/build/oauth/jwt-issuer.d.ts.map +1 -0
  81. package/build/oauth/jwt-issuer.js +205 -0
  82. package/build/oauth/jwt-issuer.js.map +1 -0
  83. package/build/oauth/pkce.d.ts +10 -0
  84. package/build/oauth/pkce.d.ts.map +1 -0
  85. package/build/oauth/pkce.js +34 -0
  86. package/build/oauth/pkce.js.map +1 -0
  87. package/build/oauth/provider.d.ts +52 -0
  88. package/build/oauth/provider.d.ts.map +1 -0
  89. package/build/oauth/provider.js +98 -0
  90. package/build/oauth/provider.js.map +1 -0
  91. package/build/oauth/user-store.d.ts +25 -0
  92. package/build/oauth/user-store.d.ts.map +1 -0
  93. package/build/oauth/user-store.js +85 -0
  94. package/build/oauth/user-store.js.map +1 -0
  95. package/build/relay/browser.d.ts +15 -0
  96. package/build/relay/browser.d.ts.map +1 -0
  97. package/build/relay/browser.js +121 -0
  98. package/build/relay/browser.js.map +1 -0
  99. package/build/relay/client.d.ts +36 -0
  100. package/build/relay/client.d.ts.map +1 -0
  101. package/build/relay/client.js +135 -0
  102. package/build/relay/client.js.map +1 -0
  103. package/build/relay/session.d.ts +12 -0
  104. package/build/relay/session.d.ts.map +1 -0
  105. package/build/relay/session.js +55 -0
  106. package/build/relay/session.js.map +1 -0
  107. package/build/relay/tool-helpers.d.ts +85 -0
  108. package/build/relay/tool-helpers.d.ts.map +1 -0
  109. package/build/relay/tool-helpers.js +103 -0
  110. package/build/relay/tool-helpers.js.map +1 -0
  111. package/build/relay/wordlist.d.ts +2 -0
  112. package/build/relay/wordlist.d.ts.map +1 -0
  113. package/build/relay/wordlist.js +7782 -0
  114. package/build/relay/wordlist.js.map +1 -0
  115. package/build/schema/types.d.ts +67 -0
  116. package/build/schema/types.d.ts.map +1 -0
  117. package/build/schema/types.js +2 -0
  118. package/build/schema/types.js.map +1 -0
  119. package/build/storage/atomic-write.d.ts +8 -0
  120. package/build/storage/atomic-write.d.ts.map +1 -0
  121. package/build/storage/atomic-write.js +26 -0
  122. package/build/storage/atomic-write.js.map +1 -0
  123. package/build/storage/backends.d.ts +74 -0
  124. package/build/storage/backends.d.ts.map +1 -0
  125. package/build/storage/backends.js +193 -0
  126. package/build/storage/backends.js.map +1 -0
  127. package/build/storage/config-file.d.ts +35 -0
  128. package/build/storage/config-file.d.ts.map +1 -0
  129. package/build/storage/config-file.js +259 -0
  130. package/build/storage/config-file.js.map +1 -0
  131. package/build/storage/credential-store.d.ts +71 -0
  132. package/build/storage/credential-store.d.ts.map +1 -0
  133. package/build/storage/credential-store.js +91 -0
  134. package/build/storage/credential-store.js.map +1 -0
  135. package/build/storage/data-dir.d.ts +58 -0
  136. package/build/storage/data-dir.d.ts.map +1 -0
  137. package/build/storage/data-dir.js +79 -0
  138. package/build/storage/data-dir.js.map +1 -0
  139. package/build/storage/encryption.d.ts +9 -0
  140. package/build/storage/encryption.d.ts.map +1 -0
  141. package/build/storage/encryption.js +27 -0
  142. package/build/storage/encryption.js.map +1 -0
  143. package/build/storage/home-dir.d.ts +11 -0
  144. package/build/storage/home-dir.d.ts.map +1 -0
  145. package/build/storage/home-dir.js +18 -0
  146. package/build/storage/home-dir.js.map +1 -0
  147. package/build/storage/index.d.ts +12 -0
  148. package/build/storage/index.d.ts.map +1 -0
  149. package/build/storage/index.js +15 -0
  150. package/build/storage/index.js.map +1 -0
  151. package/build/storage/machine-id.d.ts +4 -0
  152. package/build/storage/machine-id.d.ts.map +1 -0
  153. package/build/storage/machine-id.js +73 -0
  154. package/build/storage/machine-id.js.map +1 -0
  155. package/build/storage/mode.d.ts +23 -0
  156. package/build/storage/mode.d.ts.map +1 -0
  157. package/build/storage/mode.js +46 -0
  158. package/build/storage/mode.js.map +1 -0
  159. package/build/storage/per-plugin-store.d.ts +65 -0
  160. package/build/storage/per-plugin-store.d.ts.map +1 -0
  161. package/build/storage/per-plugin-store.js +194 -0
  162. package/build/storage/per-plugin-store.js.map +1 -0
  163. package/build/storage/resolver.d.ts +7 -0
  164. package/build/storage/resolver.d.ts.map +1 -0
  165. package/build/storage/resolver.js +38 -0
  166. package/build/storage/resolver.js.map +1 -0
  167. package/build/storage/session-lock.d.ts +19 -0
  168. package/build/storage/session-lock.d.ts.map +1 -0
  169. package/build/storage/session-lock.js +105 -0
  170. package/build/storage/session-lock.js.map +1 -0
  171. package/build/token-auth/authenticator.d.ts +70 -0
  172. package/build/token-auth/authenticator.d.ts.map +1 -0
  173. package/build/token-auth/authenticator.js +146 -0
  174. package/build/token-auth/authenticator.js.map +1 -0
  175. package/build/token-auth/cli.d.ts +38 -0
  176. package/build/token-auth/cli.d.ts.map +1 -0
  177. package/build/token-auth/cli.js +192 -0
  178. package/build/token-auth/cli.js.map +1 -0
  179. package/build/token-auth/context.d.ts +30 -0
  180. package/build/token-auth/context.d.ts.map +1 -0
  181. package/build/token-auth/context.js +32 -0
  182. package/build/token-auth/context.js.map +1 -0
  183. package/build/token-auth/http-guard.d.ts +26 -0
  184. package/build/token-auth/http-guard.d.ts.map +1 -0
  185. package/build/token-auth/http-guard.js +51 -0
  186. package/build/token-auth/http-guard.js.map +1 -0
  187. package/build/token-auth/index.d.ts +14 -0
  188. package/build/token-auth/index.d.ts.map +1 -0
  189. package/build/token-auth/index.js +14 -0
  190. package/build/token-auth/index.js.map +1 -0
  191. package/build/token-auth/limiter.d.ts +20 -0
  192. package/build/token-auth/limiter.d.ts.map +1 -0
  193. package/build/token-auth/limiter.js +41 -0
  194. package/build/token-auth/limiter.js.map +1 -0
  195. package/build/token-auth/loopback.d.ts +17 -0
  196. package/build/token-auth/loopback.d.ts.map +1 -0
  197. package/build/token-auth/loopback.js +62 -0
  198. package/build/token-auth/loopback.js.map +1 -0
  199. package/build/token-auth/py-compat.d.ts +24 -0
  200. package/build/token-auth/py-compat.d.ts.map +1 -0
  201. package/build/token-auth/py-compat.js +76 -0
  202. package/build/token-auth/py-compat.js.map +1 -0
  203. package/build/token-auth/tokens.d.ts +36 -0
  204. package/build/token-auth/tokens.d.ts.map +1 -0
  205. package/build/token-auth/tokens.js +115 -0
  206. package/build/token-auth/tokens.js.map +1 -0
  207. package/build/token-auth/users.d.ts +62 -0
  208. package/build/token-auth/users.d.ts.map +1 -0
  209. package/build/token-auth/users.js +174 -0
  210. package/build/token-auth/users.js.map +1 -0
  211. package/build/transport/cache.d.ts +19 -0
  212. package/build/transport/cache.d.ts.map +1 -0
  213. package/build/transport/cache.js +76 -0
  214. package/build/transport/cache.js.map +1 -0
  215. package/build/transport/index.d.ts +5 -0
  216. package/build/transport/index.d.ts.map +1 -0
  217. package/build/transport/index.js +4 -0
  218. package/build/transport/index.js.map +1 -0
  219. package/build/transport/local-server.d.ts +173 -0
  220. package/build/transport/local-server.d.ts.map +1 -0
  221. package/build/transport/local-server.js +457 -0
  222. package/build/transport/local-server.js.map +1 -0
  223. package/build/transport/oauth-middleware.d.ts +45 -0
  224. package/build/transport/oauth-middleware.d.ts.map +1 -0
  225. package/build/transport/oauth-middleware.js +86 -0
  226. package/build/transport/oauth-middleware.js.map +1 -0
  227. package/build/transport/streamable-http.d.ts +54 -0
  228. package/build/transport/streamable-http.d.ts.map +1 -0
  229. package/build/transport/streamable-http.js +57 -0
  230. package/build/transport/streamable-http.js.map +1 -0
  231. package/package.json +107 -4
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Shared home-directory resolution with a testing override.
3
+ *
4
+ * Extracted out of per-plugin-store.ts so that both PerPluginStore and the
5
+ * LocalFsBackend in backends.ts can honor the same override without a circular
6
+ * value import (per-plugin-store imports backendFromEnv from backends).
7
+ */
8
+ /** Override the home directory used by storage modules. Pass null to reset. */
9
+ export declare function setHomeDirForTesting(dir: string | null): void;
10
+ export declare function getHomeDir(): string;
11
+ //# sourceMappingURL=home-dir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"home-dir.d.ts","sourceRoot":"","sources":["../../src/storage/home-dir.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE7D;AAED,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Shared home-directory resolution with a testing override.
3
+ *
4
+ * Extracted out of per-plugin-store.ts so that both PerPluginStore and the
5
+ * LocalFsBackend in backends.ts can honor the same override without a circular
6
+ * value import (per-plugin-store imports backendFromEnv from backends).
7
+ */
8
+ import { homedir } from 'node:os';
9
+ // Module-level override for testing.
10
+ let homeDirOverride = null;
11
+ /** Override the home directory used by storage modules. Pass null to reset. */
12
+ export function setHomeDirForTesting(dir) {
13
+ homeDirOverride = dir;
14
+ }
15
+ export function getHomeDir() {
16
+ return homeDirOverride ?? homedir();
17
+ }
18
+ //# sourceMappingURL=home-dir.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"home-dir.js","sourceRoot":"","sources":["../../src/storage/home-dir.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,qCAAqC;AACrC,IAAI,eAAe,GAAkB,IAAI,CAAA;AAEzC,+EAA+E;AAC/E,MAAM,UAAU,oBAAoB,CAAC,GAAkB;IACrD,eAAe,GAAG,GAAG,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,eAAe,IAAI,OAAO,EAAE,CAAA;AACrC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export { atomicWriteFile } from './atomic-write.js';
2
+ export { backendFromEnv, CfKvBackend, type CredentialBackend, InMemoryBackend, LocalFsBackend, type LocalFsBackendOptions } from './backends.js';
3
+ export { exportConfig, importConfig, listConfigs, setConfigPath } from './config-file.js';
4
+ export { deleteStoredConfig as deleteConfig, readStoredConfig as readConfig, writeStoredConfig as writeConfig } from './credential-store.js';
5
+ export { type DataDirLocation, dataDir, dataDirCandidates, legacyDataDirs } from './data-dir.js';
6
+ export { decryptData, deriveFileKey, derivePassphraseKey, encryptData } from './encryption.js';
7
+ export { getMachineId, getUsername } from './machine-id.js';
8
+ export { clearMode, getMode, type ServerMode, setLocalMode } from './mode.js';
9
+ export { credPath, PerPluginStore, setHomeDirForTesting } from './per-plugin-store.js';
10
+ export { type ConfigSource, type ResolvedConfig, resolveConfig } from './resolver.js';
11
+ export { acquireSessionLock, releaseSessionLock, type SessionInfo, setLockDir, writeSessionLock } from './session-lock.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EACL,cAAc,EACd,WAAW,EACX,KAAK,iBAAiB,EACtB,eAAe,EACf,cAAc,EACd,KAAK,qBAAqB,EAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAIzF,OAAO,EACL,kBAAkB,IAAI,YAAY,EAClC,gBAAgB,IAAI,UAAU,EAC9B,iBAAiB,IAAI,WAAW,EACjC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,KAAK,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAChG,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC9F,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACtF,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACrF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,WAAW,EAChB,UAAU,EACV,gBAAgB,EACjB,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,15 @@
1
+ export { atomicWriteFile } from './atomic-write.js';
2
+ export { backendFromEnv, CfKvBackend, InMemoryBackend, LocalFsBackend } from './backends.js';
3
+ export { exportConfig, importConfig, listConfigs, setConfigPath } from './config-file.js';
4
+ // Single-user credential read/write/delete route through the unified
5
+ // per-plugin store (with legacy config.enc read fallback), so downstream
6
+ // servers and the CLI built-ins converge on the same on-disk location.
7
+ export { deleteStoredConfig as deleteConfig, readStoredConfig as readConfig, writeStoredConfig as writeConfig } from './credential-store.js';
8
+ export { dataDir, dataDirCandidates, legacyDataDirs } from './data-dir.js';
9
+ export { decryptData, deriveFileKey, derivePassphraseKey, encryptData } from './encryption.js';
10
+ export { getMachineId, getUsername } from './machine-id.js';
11
+ export { clearMode, getMode, setLocalMode } from './mode.js';
12
+ export { credPath, PerPluginStore, setHomeDirForTesting } from './per-plugin-store.js';
13
+ export { resolveConfig } from './resolver.js';
14
+ export { acquireSessionLock, releaseSessionLock, setLockDir, writeSessionLock } from './session-lock.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EACL,cAAc,EACd,WAAW,EAEX,eAAe,EACf,cAAc,EAEf,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzF,qEAAqE;AACrE,yEAAyE;AACzE,uEAAuE;AACvE,OAAO,EACL,kBAAkB,IAAI,YAAY,EAClC,gBAAgB,IAAI,UAAU,EAC9B,iBAAiB,IAAI,WAAW,EACjC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAwB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAChG,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC9F,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAmB,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACtF,OAAO,EAA0C,aAAa,EAAE,MAAM,eAAe,CAAA;AACrF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAElB,UAAU,EACV,gBAAgB,EACjB,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare function clearMachineIdCacheForTesting(): void;
2
+ export declare function getMachineId(): Promise<string>;
3
+ export declare function getUsername(): string;
4
+ //# sourceMappingURL=machine-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"machine-id.d.ts","sourceRoot":"","sources":["../../src/storage/machine-id.ts"],"names":[],"mappings":"AASA,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAuDpD;AAED,wBAAgB,WAAW,IAAI,MAAM,CAMpC"}
@@ -0,0 +1,73 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { hostname, networkInterfaces, userInfo } from 'node:os';
4
+ import { promisify } from 'node:util';
5
+ const execFileAsync = promisify(execFile);
6
+ let cachedMachineId = null;
7
+ export function clearMachineIdCacheForTesting() {
8
+ cachedMachineId = null;
9
+ }
10
+ export async function getMachineId() {
11
+ if (cachedMachineId)
12
+ return cachedMachineId;
13
+ try {
14
+ if (process.platform === 'linux') {
15
+ cachedMachineId = (await readFile('/etc/machine-id', 'utf-8')).trim();
16
+ return cachedMachineId;
17
+ }
18
+ if (process.platform === 'darwin') {
19
+ const { stdout } = await execFileAsync('ioreg', ['-rd1', '-c', 'IOPlatformExpertDevice']);
20
+ const match = stdout.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);
21
+ if (match) {
22
+ cachedMachineId = match[1];
23
+ return cachedMachineId;
24
+ }
25
+ }
26
+ if (process.platform === 'win32') {
27
+ const { stdout } = await execFileAsync('reg', [
28
+ 'query',
29
+ 'HKLM\\SOFTWARE\\Microsoft\\Cryptography',
30
+ '/v',
31
+ 'MachineGuid'
32
+ ]);
33
+ const match = stdout.match(/MachineGuid\s+REG_SZ\s+(\S+)/);
34
+ if (match) {
35
+ cachedMachineId = match[1];
36
+ return cachedMachineId;
37
+ }
38
+ }
39
+ }
40
+ catch {
41
+ /* fallback below */
42
+ }
43
+ // Fallback: hostname + first MAC address
44
+ const nics = networkInterfaces();
45
+ // Optimization: Manual loops are significantly faster than .flat().find() in Bun
46
+ // as they avoid intermediate memory allocations and functional iteration overhead.
47
+ let mac;
48
+ for (const key in nics) {
49
+ const ifaces = nics[key];
50
+ if (ifaces) {
51
+ for (let i = 0; i < ifaces.length; i++) {
52
+ const n = ifaces[i];
53
+ if (n && !n.internal && n.mac !== '00:00:00:00:00:00') {
54
+ mac = n.mac;
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ if (mac)
60
+ break;
61
+ }
62
+ cachedMachineId = `${hostname()}-${mac ?? 'unknown'}`;
63
+ return cachedMachineId;
64
+ }
65
+ export function getUsername() {
66
+ try {
67
+ return userInfo().username;
68
+ }
69
+ catch {
70
+ return process.env.USER ?? process.env.USERNAME ?? 'unknown';
71
+ }
72
+ }
73
+ //# sourceMappingURL=machine-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"machine-id.js","sourceRoot":"","sources":["../../src/storage/machine-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,QAA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AAC,CAAA;gBAC1B,OAAO,eAAe,CAAA;YACxB,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,oBAAoB;IACtB,CAAC;IAED,yCAAyC;IACzC,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAA;IAEhC,iFAAiF;IACjF,mFAAmF;IACnF,IAAI,GAAuB,CAAA;IAC3B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;QACxB,IAAI,MAAM,EAAE,CAAC;YACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACvC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;gBACnB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,KAAK,mBAAmB,EAAE,CAAC;oBACtD,GAAG,GAAG,CAAC,CAAC,GAAG,CAAA;oBACX,MAAK;gBACP,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,GAAG;YAAE,MAAK;IAChB,CAAC;IAED,eAAe,GAAG,GAAG,QAAQ,EAAE,IAAI,GAAG,IAAI,SAAS,EAAE,CAAA;IACrD,OAAO,eAAe,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC;QACH,OAAO,QAAQ,EAAE,CAAC,QAAQ,CAAA;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,SAAS,CAAA;IAC9D,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Server mode management: local-only vs relay-configured.
3
+ *
4
+ * Persists user's choice to skip relay permanently by storing a mode marker
5
+ * in the existing config.enc encrypted storage.
6
+ */
7
+ export type ServerMode = 'local' | 'configured' | null;
8
+ /**
9
+ * Mark server as local-only (user explicitly skipped relay).
10
+ * Writes {"_mode": "local"} to config.enc[serverName].
11
+ */
12
+ export declare function setLocalMode(serverName: string): Promise<void>;
13
+ /**
14
+ * Get server mode.
15
+ * Returns "local" if local mode set, "configured" if has other keys, null if empty.
16
+ */
17
+ export declare function getMode(serverName: string): Promise<ServerMode>;
18
+ /**
19
+ * Remove mode marker (allows relay to trigger again).
20
+ * Deletes the server's config entry entirely.
21
+ */
22
+ export declare function clearMode(serverName: string): Promise<void>;
23
+ //# sourceMappingURL=mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../../src/storage/mode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,YAAY,GAAG,IAAI,CAAA;AAEtD;;;GAGG;AACH,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAoBrE;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Server mode management: local-only vs relay-configured.
3
+ *
4
+ * Persists user's choice to skip relay permanently by storing a mode marker
5
+ * in the existing config.enc encrypted storage.
6
+ */
7
+ import { deleteConfig, readConfig, writeConfig } from './config-file.js';
8
+ const MODE_KEY = '_mode';
9
+ const LOCAL_MODE_VALUE = 'local';
10
+ /**
11
+ * Mark server as local-only (user explicitly skipped relay).
12
+ * Writes {"_mode": "local"} to config.enc[serverName].
13
+ */
14
+ export async function setLocalMode(serverName) {
15
+ await writeConfig(serverName, { [MODE_KEY]: LOCAL_MODE_VALUE });
16
+ }
17
+ /**
18
+ * Get server mode.
19
+ * Returns "local" if local mode set, "configured" if has other keys, null if empty.
20
+ */
21
+ export async function getMode(serverName) {
22
+ const config = await readConfig(serverName);
23
+ if (config === null) {
24
+ return null;
25
+ }
26
+ if (config[MODE_KEY] === LOCAL_MODE_VALUE) {
27
+ return 'local';
28
+ }
29
+ // Has keys other than _mode -> configured
30
+ // Optimization: use for..in to return early and avoid O(N) array allocation
31
+ // from Object.keys().filter()
32
+ for (const k in config) {
33
+ if (k !== MODE_KEY && Object.hasOwn(config, k)) {
34
+ return 'configured';
35
+ }
36
+ }
37
+ return null;
38
+ }
39
+ /**
40
+ * Remove mode marker (allows relay to trigger again).
41
+ * Deletes the server's config entry entirely.
42
+ */
43
+ export async function clearMode(serverName) {
44
+ await deleteConfig(serverName);
45
+ }
46
+ //# sourceMappingURL=mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode.js","sourceRoot":"","sources":["../../src/storage/mode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAExE,MAAM,QAAQ,GAAG,OAAO,CAAA;AACxB,MAAM,gBAAgB,GAAG,OAAO,CAAA;AAIhC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,UAAkB;IACnD,MAAM,WAAW,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAA;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,UAAkB;IAC9C,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,CAAA;IAC3C,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,gBAAgB,EAAE,CAAC;QAC1C,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,0CAA0C;IAC1C,4EAA4E;IAC5E,8BAA8B;IAC9B,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC;YAC/C,OAAO,YAAY,CAAA;QACrB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,UAAkB;IAChD,MAAM,YAAY,CAAC,UAAU,CAAC,CAAA;AAChC,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Per-plugin encrypted credential store.
3
+ *
4
+ * Layout (written by every save; see `data-dir.ts`):
5
+ * Stdio / HTTP single-user: ~/.<plugin>/config.json
6
+ * HTTP multi-user: ~/.<plugin>/subs/<sub>/config.json
7
+ *
8
+ * Read fallback (local-fs default layout only), first blob found wins:
9
+ * ~/.<plugin>/ -> ~/.<plugin>-mcp/ -> ~/.better-<plugin>-mcp/
10
+ * A legacy blob is decrypted with that legacy directory's own key material,
11
+ * and the next save writes it to ~/.<plugin>/ (migrate on write). The legacy
12
+ * copy is left in place; `clear()` removes the blob from every location.
13
+ *
14
+ * Encryption:
15
+ * Stdio / single-user: AES-256-GCM with machine-bound key persisted at
16
+ * ~/.<plugin>/.secret (auto-generated, 32 bytes, 0600).
17
+ * HTTP multi-user: AES-256-GCM with key derived via scrypt from env
18
+ * CREDENTIAL_SECRET, salt `<plugin>:<sub>`.
19
+ *
20
+ * Replaces deprecated config-file (shared config.enc) which caused
21
+ * multi-daemon path-drift contention with platformdirs version skew.
22
+ */
23
+ import { type CredentialBackend } from './backends.js';
24
+ export { setHomeDirForTesting } from './home-dir.js';
25
+ /** Path of the credential blob in the current `~/.<plugin>/` layout. */
26
+ export declare function credPath(pluginName: string, sub: string | null): string;
27
+ export declare class PerPluginStore {
28
+ pluginName: string;
29
+ sub: string | null;
30
+ readonly credPath: string;
31
+ private readonly credKey;
32
+ private readonly backend;
33
+ private readonly readsLegacy;
34
+ constructor(pluginName: string, sub?: string | null, backend?: CredentialBackend);
35
+ /**
36
+ * Primary backend first, then the legacy dirs in read-precedence order.
37
+ * Resolved per operation, like the primary LocalFsBackend resolves home.
38
+ */
39
+ private sources;
40
+ private key;
41
+ /** Key material a legacy directory's writer used; null when it is gone. */
42
+ private legacyKey;
43
+ private reportCorrupt;
44
+ private decrypt;
45
+ /**
46
+ * Load the credential payload. The first location holding a blob decides
47
+ * the result; a corrupt blob there yields null rather than falling through
48
+ * to an older location, so a stale legacy credential is never resurrected
49
+ * behind a newer (damaged) one.
50
+ */
51
+ load(): Promise<Record<string, unknown> | null>;
52
+ /** Encrypt and write to the primary backend (current layout); legacy copies are kept. */
53
+ save(payload: Record<string, unknown>): Promise<void>;
54
+ /** Delete the blob from the primary backend and from every legacy location. */
55
+ clear(): Promise<void>;
56
+ /**
57
+ * Whether a credential blob is stored at all (in any read location),
58
+ * regardless of whether it decrypts. `load()` returns null for both "absent"
59
+ * and "corrupt"; a built-in CLI (`status` / `doctor`) needs to tell the two
60
+ * apart to report "not configured" vs "corrupt (re-run setup)". Reads only
61
+ * the opaque backend blobs, never the plaintext.
62
+ */
63
+ hasStoredBlob(): Promise<boolean>;
64
+ }
65
+ //# sourceMappingURL=per-plugin-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-plugin-store.d.ts","sourceRoot":"","sources":["../../src/storage/per-plugin-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,OAAO,EAAkB,KAAK,iBAAiB,EAAkB,MAAM,eAAe,CAAA;AAUtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAOpD,wEAAwE;AACxE,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAIvE;AA0DD,qBAAa,cAAc;IAOhB,UAAU,EAAE,MAAM;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI;IAP3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,YACS,UAAU,EAAE,MAAM,EAClB,GAAG,GAAE,MAAM,GAAG,IAAW,EAChC,OAAO,CAAC,EAAE,iBAAiB,EAS5B;IAED;;;OAGG;IACH,OAAO,CAAC,OAAO;YAYD,GAAG;IAIjB,2EAA2E;YAC7D,SAAS;IAIvB,OAAO,CAAC,aAAa;YAQP,OAAO;IAoBrB;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAMpD;IAED,yFAAyF;IACnF,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAO1D;IAED,+EAA+E;IACzE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3B;IAED;;;;;;OAMG;IACG,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAKtC;CACF"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Per-plugin encrypted credential store.
3
+ *
4
+ * Layout (written by every save; see `data-dir.ts`):
5
+ * Stdio / HTTP single-user: ~/.<plugin>/config.json
6
+ * HTTP multi-user: ~/.<plugin>/subs/<sub>/config.json
7
+ *
8
+ * Read fallback (local-fs default layout only), first blob found wins:
9
+ * ~/.<plugin>/ -> ~/.<plugin>-mcp/ -> ~/.better-<plugin>-mcp/
10
+ * A legacy blob is decrypted with that legacy directory's own key material,
11
+ * and the next save writes it to ~/.<plugin>/ (migrate on write). The legacy
12
+ * copy is left in place; `clear()` removes the blob from every location.
13
+ *
14
+ * Encryption:
15
+ * Stdio / single-user: AES-256-GCM with machine-bound key persisted at
16
+ * ~/.<plugin>/.secret (auto-generated, 32 bytes, 0600).
17
+ * HTTP multi-user: AES-256-GCM with key derived via scrypt from env
18
+ * CREDENTIAL_SECRET, salt `<plugin>:<sub>`.
19
+ *
20
+ * Replaces deprecated config-file (shared config.enc) which caused
21
+ * multi-daemon path-drift contention with platformdirs version skew.
22
+ */
23
+ import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from 'node:crypto';
24
+ import { existsSync } from 'node:fs';
25
+ import { chmod, mkdir, readFile } from 'node:fs/promises';
26
+ import { join } from 'node:path';
27
+ import { atomicWriteFile } from './atomic-write.js';
28
+ import { backendFromEnv, LocalFsBackend } from './backends.js';
29
+ import { assertValidPluginName, assertValidSub, blobPathIn, dataDir, legacyDataDirs } from './data-dir.js';
30
+ export { setHomeDirForTesting } from './home-dir.js';
31
+ // Credential-store directories already initialized in this process. init runs
32
+ // even when the secret already exists (read path) so a pre-existing
33
+ // overly-permissive directory is tightened exactly once (TOCTOU hardening).
34
+ const initDirs = new Set();
35
+ /** Path of the credential blob in the current `~/.<plugin>/` layout. */
36
+ export function credPath(pluginName, sub) {
37
+ assertValidPluginName(pluginName);
38
+ if (sub !== null)
39
+ assertValidSub(sub);
40
+ return blobPathIn(dataDir(pluginName), sub);
41
+ }
42
+ async function loadOrGenMachineKey(pluginName) {
43
+ const dir = dataDir(pluginName);
44
+ const secretPath = join(dir, '.secret');
45
+ if (!existsSync(dir)) {
46
+ await mkdir(dir, { recursive: true, mode: 0o700 });
47
+ }
48
+ if (!initDirs.has(dir)) {
49
+ // Explicitly chmod(0o700) to tighten an existing overly-permissive directory
50
+ // (TOCTOU hardening); runs once per directory even on the read path.
51
+ if (process.platform !== 'win32') {
52
+ await chmod(dir, 0o700);
53
+ }
54
+ initDirs.add(dir);
55
+ }
56
+ try {
57
+ return await readFile(secretPath);
58
+ }
59
+ catch {
60
+ const key = randomBytes(32);
61
+ await atomicWriteFile(secretPath, key);
62
+ return key;
63
+ }
64
+ }
65
+ /**
66
+ * Read-only machine key of a legacy directory. Never creates, chmods or mints
67
+ * anything there: a missing `.secret` means the blob cannot be decrypted.
68
+ */
69
+ async function readLegacyMachineKey(dir) {
70
+ try {
71
+ return await readFile(join(dir, '.secret'));
72
+ }
73
+ catch {
74
+ return null;
75
+ }
76
+ }
77
+ function deriveMultiUserKey(pluginName, sub) {
78
+ const master = process.env.CREDENTIAL_SECRET;
79
+ if (!master) {
80
+ throw new Error('CREDENTIAL_SECRET env required for HTTP multi-user mode');
81
+ }
82
+ return scryptSync(master, Buffer.from(`${pluginName}:${sub}`, 'utf-8'), 32, {
83
+ N: 16384,
84
+ r: 8,
85
+ p: 1
86
+ });
87
+ }
88
+ export class PerPluginStore {
89
+ constructor(pluginName, sub = null, backend) {
90
+ this.pluginName = pluginName;
91
+ this.sub = sub;
92
+ this.credPath = credPath(pluginName, sub);
93
+ this.credKey = sub ? `${pluginName}/subs/${sub}/config` : `${pluginName}/config`;
94
+ this.backend = backend ?? backendFromEnv();
95
+ // The legacy layouts only exist on local disk, so only a default-layout
96
+ // LocalFsBackend reads them. An injected in-memory/KV/custom-dir backend is
97
+ // taken as the single source of truth.
98
+ this.readsLegacy = this.backend instanceof LocalFsBackend && this.backend.isDefaultLayout;
99
+ }
100
+ /**
101
+ * Primary backend first, then the legacy dirs in read-precedence order.
102
+ * Resolved per operation, like the primary LocalFsBackend resolves home.
103
+ */
104
+ sources() {
105
+ const primary = { backend: this.backend, legacy: null };
106
+ if (!this.readsLegacy)
107
+ return [primary];
108
+ return [
109
+ primary,
110
+ ...legacyDataDirs(this.pluginName).map((loc) => ({
111
+ backend: new LocalFsBackend({ baseDir: () => loc.dir }),
112
+ legacy: loc
113
+ }))
114
+ ];
115
+ }
116
+ async key() {
117
+ return this.sub ? deriveMultiUserKey(this.pluginName, this.sub) : loadOrGenMachineKey(this.pluginName);
118
+ }
119
+ /** Key material a legacy directory's writer used; null when it is gone. */
120
+ async legacyKey(loc) {
121
+ return this.sub ? deriveMultiUserKey(loc.keyPlugin, this.sub) : readLegacyMachineKey(loc.dir);
122
+ }
123
+ reportCorrupt(legacy) {
124
+ const where = legacy ? ` (legacy dir ${legacy.dir})` : '';
125
+ console.error(`[hull PerPluginStore] Credential blob for ${this.credKey}${where} is corrupt or the encryption key changed; treating as not configured (re-run setup to restore)`);
126
+ return null;
127
+ }
128
+ async decrypt(blob, legacy) {
129
+ // Format: [12-byte IV][ciphertext][16-byte GCM tag]
130
+ if (blob.length < 29)
131
+ return this.reportCorrupt(legacy);
132
+ const key = legacy ? await this.legacyKey(legacy) : await this.key();
133
+ if (key === null)
134
+ return this.reportCorrupt(legacy);
135
+ const iv = blob.subarray(0, 12);
136
+ const tag = blob.subarray(blob.length - 16);
137
+ const data = blob.subarray(12, blob.length - 16);
138
+ try {
139
+ // createDecipheriv sits inside the try: a legacy `.secret` of the wrong
140
+ // length is unusable key material, i.e. the same "corrupt" outcome.
141
+ const decipher = createDecipheriv('aes-256-gcm', key, iv, { authTagLength: 16 });
142
+ decipher.setAuthTag(tag);
143
+ const plaintext = Buffer.concat([decipher.update(data), decipher.final()]);
144
+ return JSON.parse(plaintext.toString('utf-8'));
145
+ }
146
+ catch {
147
+ return this.reportCorrupt(legacy);
148
+ }
149
+ }
150
+ /**
151
+ * Load the credential payload. The first location holding a blob decides
152
+ * the result; a corrupt blob there yields null rather than falling through
153
+ * to an older location, so a stale legacy credential is never resurrected
154
+ * behind a newer (damaged) one.
155
+ */
156
+ async load() {
157
+ for (const source of this.sources()) {
158
+ const blob = await source.backend.get(this.credKey);
159
+ if (blob !== null)
160
+ return this.decrypt(blob, source.legacy);
161
+ }
162
+ return null;
163
+ }
164
+ /** Encrypt and write to the primary backend (current layout); legacy copies are kept. */
165
+ async save(payload) {
166
+ const iv = randomBytes(12);
167
+ const cipher = createCipheriv('aes-256-gcm', await this.key(), iv, { authTagLength: 16 });
168
+ const plaintext = Buffer.from(JSON.stringify(payload), 'utf-8');
169
+ const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
170
+ const tag = cipher.getAuthTag();
171
+ await this.backend.put(this.credKey, Buffer.concat([iv, ciphertext, tag]));
172
+ }
173
+ /** Delete the blob from the primary backend and from every legacy location. */
174
+ async clear() {
175
+ for (const source of this.sources()) {
176
+ await source.backend.delete(this.credKey);
177
+ }
178
+ }
179
+ /**
180
+ * Whether a credential blob is stored at all (in any read location),
181
+ * regardless of whether it decrypts. `load()` returns null for both "absent"
182
+ * and "corrupt"; a built-in CLI (`status` / `doctor`) needs to tell the two
183
+ * apart to report "not configured" vs "corrupt (re-run setup)". Reads only
184
+ * the opaque backend blobs, never the plaintext.
185
+ */
186
+ async hasStoredBlob() {
187
+ for (const source of this.sources()) {
188
+ if ((await source.backend.get(this.credKey)) !== null)
189
+ return true;
190
+ }
191
+ return false;
192
+ }
193
+ }
194
+ //# sourceMappingURL=per-plugin-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-plugin-store.js","sourceRoot":"","sources":["../../src/storage/per-plugin-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,cAAc,EAA0B,cAAc,EAAE,MAAM,eAAe,CAAA;AACtF,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,UAAU,EAEV,OAAO,EACP,cAAc,EACf,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;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AAC,OAAO,EAAE,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI;gBAAE,OAAO,IAAI,CAAA;QACpE,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export type ConfigSource = 'env' | 'file' | 'defaults' | null;
2
+ export interface ResolvedConfig {
3
+ config: Record<string, string> | null;
4
+ source: ConfigSource;
5
+ }
6
+ export declare function resolveConfig(serverName: string, requiredFields: string[], defaults?: Record<string, string>): Promise<ResolvedConfig>;
7
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/storage/resolver.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAAA;AAE7D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;IACrC,MAAM,EAAE,YAAY,CAAA;CACrB;AAED,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EAAE,EACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,cAAc,CAAC,CAqCzB"}
@@ -0,0 +1,38 @@
1
+ import { readStoredConfig } from './credential-store.js';
2
+ export async function resolveConfig(serverName, requiredFields, defaults) {
3
+ // 1. Check env vars -- if ALL required fields present as env vars, use them
4
+ const envConfig = {};
5
+ let allEnvPresent = requiredFields.length > 0;
6
+ const serverPrefix = serverName.toUpperCase().replaceAll('-', '_');
7
+ for (const field of requiredFields) {
8
+ const envKey = `MCP_${serverPrefix}_${field.toUpperCase().replaceAll('-', '_')}`;
9
+ const value = process.env[envKey];
10
+ if (value !== undefined && value !== '') {
11
+ envConfig[field] = value;
12
+ }
13
+ else {
14
+ allEnvPresent = false;
15
+ }
16
+ }
17
+ if (allEnvPresent) {
18
+ return { config: envConfig, source: 'env' };
19
+ }
20
+ // 2. Check stored config (per-plugin store, with legacy config.enc fallback)
21
+ const fileConfig = await readStoredConfig(serverName);
22
+ if (fileConfig) {
23
+ const hasAllRequired = requiredFields.every((f) => f in fileConfig && fileConfig[f] !== '');
24
+ if (hasAllRequired) {
25
+ return { config: fileConfig, source: 'file' };
26
+ }
27
+ }
28
+ // 3. Check defaults
29
+ if (defaults) {
30
+ const hasAllRequired = requiredFields.every((f) => f in defaults && defaults[f] !== '');
31
+ if (hasAllRequired) {
32
+ return { config: { ...defaults }, source: 'defaults' };
33
+ }
34
+ }
35
+ // 4. Nothing found -- trigger relay setup
36
+ return { config: null, source: null };
37
+ }
38
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/storage/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AASxD,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAkB,EAClB,cAAwB,EACxB,QAAiC;IAEjC,4EAA4E;IAC5E,MAAM,SAAS,GAA2B,EAAE,CAAA;IAC5C,IAAI,aAAa,GAAG,cAAc,CAAC,MAAM,GAAG,CAAC,CAAA;IAC7C,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAClE,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,OAAO,YAAY,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;QAChF,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACjC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;YACxC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,CAAA;QAC1B,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,KAAK,CAAA;QACvB,CAAC;IACH,CAAC;IACD,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;IAC7C,CAAC;IAED,6EAA6E;IAC7E,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,UAAU,CAAC,CAAA;IACrD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;QAC3F,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;QAC/C,CAAC;IACH,CAAC;IAED,oBAAoB;IACpB,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;QACvF,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,EAAE,GAAG,QAAQ,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAA;QACxD,CAAC;IACH,CAAC;IAED,0CAA0C;IAC1C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;AACvC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * File-based session lock to prevent duplicate relay sessions.
3
+ *
4
+ * When multiple MCP server processes start simultaneously (common in Claude Code),
5
+ * this lock prevents each from creating a separate relay session (rate limit:
6
+ * max 10 sessions/IP/10min).
7
+ *
8
+ * Lock file location: <config_dir>/mcp/relay-session-<server>.lock
9
+ */
10
+ export declare function setLockDir(path: string | null): void;
11
+ export interface SessionInfo {
12
+ sessionId: string;
13
+ relayUrl: string;
14
+ createdAt: number;
15
+ }
16
+ export declare function acquireSessionLock(serverName: string, maxAgeMs?: number): Promise<SessionInfo | null>;
17
+ export declare function writeSessionLock(serverName: string, info: SessionInfo): Promise<void>;
18
+ export declare function releaseSessionLock(serverName: string): Promise<void>;
19
+ //# sourceMappingURL=session-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-lock.d.ts","sourceRoot":"","sources":["../../src/storage/session-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmBH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAGpD;AAUD,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAQD,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,EAClB,QAAQ,SAAqB,GAC5B,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CA2C7B;AAED,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB3F;AAED,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAS1E"}