@pan-sec/notebooklm-mcp 2026.3.3 → 2026.4.1

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 (470) hide show
  1. package/dist/auth/auth-manager.d.ts +0 -1
  2. package/dist/auth/auth-manager.js +0 -1
  3. package/dist/auth/mcp-auth.d.ts +0 -1
  4. package/dist/auth/mcp-auth.js +0 -1
  5. package/dist/compliance/alert-manager.d.ts +6 -2
  6. package/dist/compliance/alert-manager.js +40 -10
  7. package/dist/compliance/breach-detection.d.ts +0 -1
  8. package/dist/compliance/breach-detection.js +0 -1
  9. package/dist/compliance/change-log.d.ts +13 -1
  10. package/dist/compliance/change-log.js +82 -16
  11. package/dist/compliance/compliance-logger.d.ts +29 -3
  12. package/dist/compliance/compliance-logger.js +90 -27
  13. package/dist/compliance/compliance-tools.d.ts +0 -1
  14. package/dist/compliance/compliance-tools.js +0 -1
  15. package/dist/compliance/consent-manager.d.ts +0 -1
  16. package/dist/compliance/consent-manager.js +0 -1
  17. package/dist/compliance/dashboard.d.ts +4 -3
  18. package/dist/compliance/dashboard.js +11 -8
  19. package/dist/compliance/data-classification.d.ts +0 -1
  20. package/dist/compliance/data-classification.js +0 -1
  21. package/dist/compliance/data-erasure.d.ts +0 -1
  22. package/dist/compliance/data-erasure.js +0 -1
  23. package/dist/compliance/data-export.d.ts +0 -1
  24. package/dist/compliance/data-export.js +0 -1
  25. package/dist/compliance/data-inventory.d.ts +0 -1
  26. package/dist/compliance/data-inventory.js +0 -1
  27. package/dist/compliance/dsar-handler.d.ts +0 -1
  28. package/dist/compliance/dsar-handler.js +0 -1
  29. package/dist/compliance/evidence-collector.d.ts +0 -1
  30. package/dist/compliance/evidence-collector.js +4 -2
  31. package/dist/compliance/health-monitor.d.ts +0 -1
  32. package/dist/compliance/health-monitor.js +0 -1
  33. package/dist/compliance/incident-manager.d.ts +0 -1
  34. package/dist/compliance/incident-manager.js +0 -1
  35. package/dist/compliance/index.d.ts +0 -1
  36. package/dist/compliance/index.js +0 -1
  37. package/dist/compliance/policy-docs.d.ts +0 -1
  38. package/dist/compliance/policy-docs.js +0 -1
  39. package/dist/compliance/privacy-notice-text.d.ts +0 -1
  40. package/dist/compliance/privacy-notice-text.js +0 -1
  41. package/dist/compliance/privacy-notice.d.ts +0 -1
  42. package/dist/compliance/privacy-notice.js +0 -1
  43. package/dist/compliance/report-generator.d.ts +7 -1
  44. package/dist/compliance/report-generator.js +116 -34
  45. package/dist/compliance/retention-engine.d.ts +0 -1
  46. package/dist/compliance/retention-engine.js +0 -1
  47. package/dist/compliance/siem-exporter.d.ts +26 -2
  48. package/dist/compliance/siem-exporter.js +89 -24
  49. package/dist/compliance/types.d.ts +0 -1
  50. package/dist/compliance/types.js +0 -1
  51. package/dist/config.d.ts +0 -1
  52. package/dist/config.js +2 -3
  53. package/dist/errors.d.ts +0 -1
  54. package/dist/errors.js +0 -1
  55. package/dist/events/event-emitter.d.ts +9 -1
  56. package/dist/events/event-emitter.js +47 -8
  57. package/dist/events/event-types.d.ts +0 -1
  58. package/dist/events/event-types.js +8 -2
  59. package/dist/gemini/gemini-client.d.ts +0 -1
  60. package/dist/gemini/gemini-client.js +237 -45
  61. package/dist/gemini/index.d.ts +0 -1
  62. package/dist/gemini/index.js +0 -1
  63. package/dist/gemini/pdf-chunker.d.ts +0 -1
  64. package/dist/gemini/pdf-chunker.js +60 -35
  65. package/dist/gemini/types.d.ts +0 -1
  66. package/dist/gemini/types.js +0 -1
  67. package/dist/index.d.ts +0 -1
  68. package/dist/index.js +60 -7
  69. package/dist/library/notebook-library.d.ts +30 -2
  70. package/dist/library/notebook-library.js +345 -85
  71. package/dist/library/types.d.ts +0 -1
  72. package/dist/library/types.js +0 -1
  73. package/dist/logging/index.d.ts +0 -1
  74. package/dist/logging/index.js +0 -1
  75. package/dist/logging/query-logger.d.ts +20 -1
  76. package/dist/logging/query-logger.js +104 -21
  77. package/dist/notebook-creation/audio-manager.d.ts +7 -16
  78. package/dist/notebook-creation/audio-manager.js +115 -58
  79. package/dist/notebook-creation/browser-options.d.ts +0 -1
  80. package/dist/notebook-creation/browser-options.js +0 -1
  81. package/dist/notebook-creation/data-table-manager.d.ts +8 -14
  82. package/dist/notebook-creation/data-table-manager.js +64 -37
  83. package/dist/notebook-creation/dom-scripts.d.ts +0 -1
  84. package/dist/notebook-creation/dom-scripts.js +0 -1
  85. package/dist/notebook-creation/errors.d.ts +0 -1
  86. package/dist/notebook-creation/errors.js +0 -1
  87. package/dist/notebook-creation/index.d.ts +0 -1
  88. package/dist/notebook-creation/index.js +0 -1
  89. package/dist/notebook-creation/notebook-creator.d.ts +9 -1
  90. package/dist/notebook-creation/notebook-creator.js +50 -1
  91. package/dist/notebook-creation/notebook-nav.d.ts +0 -1
  92. package/dist/notebook-creation/notebook-nav.js +21 -6
  93. package/dist/notebook-creation/notebook-sync.d.ts +14 -2
  94. package/dist/notebook-creation/notebook-sync.js +124 -35
  95. package/dist/notebook-creation/selectors.d.ts +0 -1
  96. package/dist/notebook-creation/selectors.js +6 -4
  97. package/dist/notebook-creation/source-manager-shared.d.ts +75 -0
  98. package/dist/notebook-creation/source-manager-shared.js +86 -0
  99. package/dist/notebook-creation/source-manager.d.ts +29 -2
  100. package/dist/notebook-creation/source-manager.js +0 -0
  101. package/dist/notebook-creation/studio-manager-base.d.ts +57 -0
  102. package/dist/notebook-creation/studio-manager-base.js +67 -0
  103. package/dist/notebook-creation/types.d.ts +0 -1
  104. package/dist/notebook-creation/types.js +0 -1
  105. package/dist/notebook-creation/video-manager.d.ts +3 -16
  106. package/dist/notebook-creation/video-manager.js +94 -53
  107. package/dist/observability/metrics.d.ts +0 -1
  108. package/dist/observability/metrics.js +0 -1
  109. package/dist/quota/index.d.ts +0 -1
  110. package/dist/quota/index.js +0 -1
  111. package/dist/quota/quota-manager.d.ts +59 -4
  112. package/dist/quota/quota-manager.js +195 -46
  113. package/dist/resources/resource-handlers.d.ts +0 -1
  114. package/dist/resources/resource-handlers.js +33 -3
  115. package/dist/session/browser-session.d.ts +0 -1
  116. package/dist/session/browser-session.js +0 -1
  117. package/dist/session/session-manager.d.ts +0 -1
  118. package/dist/session/session-manager.js +0 -1
  119. package/dist/session/session-timeout.d.ts +0 -1
  120. package/dist/session/session-timeout.js +0 -1
  121. package/dist/session/shared-context-manager.d.ts +0 -1
  122. package/dist/session/shared-context-manager.js +0 -1
  123. package/dist/tools/annotations.d.ts +0 -1
  124. package/dist/tools/annotations.js +0 -1
  125. package/dist/tools/definitions/ask-question.d.ts +6 -3
  126. package/dist/tools/definitions/ask-question.js +12 -8
  127. package/dist/tools/definitions/chat-history.d.ts +0 -1
  128. package/dist/tools/definitions/chat-history.js +1 -1
  129. package/dist/tools/definitions/data-tables.d.ts +0 -1
  130. package/dist/tools/definitions/data-tables.js +4 -1
  131. package/dist/tools/definitions/gemini.d.ts +0 -1
  132. package/dist/tools/definitions/gemini.js +14 -7
  133. package/dist/tools/definitions/notebook-management.d.ts +0 -1
  134. package/dist/tools/definitions/notebook-management.js +7 -2
  135. package/dist/tools/definitions/query-history.d.ts +0 -1
  136. package/dist/tools/definitions/query-history.js +0 -1
  137. package/dist/tools/definitions/session-management.d.ts +0 -1
  138. package/dist/tools/definitions/session-management.js +0 -1
  139. package/dist/tools/definitions/system.d.ts +0 -1
  140. package/dist/tools/definitions/system.js +32 -12
  141. package/dist/tools/definitions/video.d.ts +0 -1
  142. package/dist/tools/definitions/video.js +6 -3
  143. package/dist/tools/definitions.d.ts +0 -1
  144. package/dist/tools/definitions.js +0 -1
  145. package/dist/tools/handlers/ask-question.d.ts +0 -1
  146. package/dist/tools/handlers/ask-question.js +47 -18
  147. package/dist/tools/handlers/audio-video.d.ts +0 -1
  148. package/dist/tools/handlers/audio-video.js +0 -1
  149. package/dist/tools/handlers/auth.d.ts +0 -1
  150. package/dist/tools/handlers/auth.js +0 -1
  151. package/dist/tools/handlers/error-utils.d.ts +0 -1
  152. package/dist/tools/handlers/error-utils.js +0 -1
  153. package/dist/tools/handlers/gemini.d.ts +0 -1
  154. package/dist/tools/handlers/gemini.js +0 -1
  155. package/dist/tools/handlers/index.d.ts +0 -1
  156. package/dist/tools/handlers/index.js +0 -1
  157. package/dist/tools/handlers/notebook-creation.d.ts +0 -1
  158. package/dist/tools/handlers/notebook-creation.js +16 -1
  159. package/dist/tools/handlers/notebook-management.d.ts +0 -1
  160. package/dist/tools/handlers/notebook-management.js +7 -2
  161. package/dist/tools/handlers/session-management.d.ts +0 -1
  162. package/dist/tools/handlers/session-management.js +0 -1
  163. package/dist/tools/handlers/system.d.ts +0 -1
  164. package/dist/tools/handlers/system.js +0 -1
  165. package/dist/tools/handlers/types.d.ts +0 -1
  166. package/dist/tools/handlers/types.js +0 -1
  167. package/dist/tools/handlers/webhooks.d.ts +0 -1
  168. package/dist/tools/handlers/webhooks.js +0 -1
  169. package/dist/tools/icons.d.ts +0 -1
  170. package/dist/tools/icons.js +0 -1
  171. package/dist/tools/index.d.ts +0 -1
  172. package/dist/tools/index.js +0 -1
  173. package/dist/types.d.ts +0 -1
  174. package/dist/types.js +0 -1
  175. package/dist/utils/audit-logger.d.ts +11 -1
  176. package/dist/utils/audit-logger.js +189 -21
  177. package/dist/utils/cleanup-manager.d.ts +0 -1
  178. package/dist/utils/cleanup-manager.js +0 -1
  179. package/dist/utils/cli-handler.d.ts +0 -1
  180. package/dist/utils/cli-handler.js +0 -1
  181. package/dist/utils/crypto.d.ts +18 -9
  182. package/dist/utils/crypto.js +93 -28
  183. package/dist/utils/file-lock.d.ts +15 -1
  184. package/dist/utils/file-lock.js +67 -59
  185. package/dist/utils/file-permissions.d.ts +0 -1
  186. package/dist/utils/file-permissions.js +35 -7
  187. package/dist/utils/logger.d.ts +0 -1
  188. package/dist/utils/logger.js +0 -1
  189. package/dist/utils/page-utils.d.ts +0 -1
  190. package/dist/utils/page-utils.js +32 -28
  191. package/dist/utils/response-validator.d.ts +0 -1
  192. package/dist/utils/response-validator.js +18 -15
  193. package/dist/utils/secrets-scanner.d.ts +0 -1
  194. package/dist/utils/secrets-scanner.js +32 -7
  195. package/dist/utils/secure-memory.d.ts +34 -16
  196. package/dist/utils/secure-memory.js +40 -25
  197. package/dist/utils/security.d.ts +0 -1
  198. package/dist/utils/security.js +66 -39
  199. package/dist/utils/settings-manager.d.ts +9 -1
  200. package/dist/utils/settings-manager.js +45 -2
  201. package/dist/utils/stealth-utils.d.ts +0 -1
  202. package/dist/utils/stealth-utils.js +11 -9
  203. package/dist/webhooks/index.d.ts +0 -1
  204. package/dist/webhooks/index.js +0 -1
  205. package/dist/webhooks/types.d.ts +0 -1
  206. package/dist/webhooks/types.js +0 -1
  207. package/dist/webhooks/webhook-dispatcher.d.ts +0 -1
  208. package/dist/webhooks/webhook-dispatcher.js +0 -1
  209. package/package.json +5 -4
  210. package/dist/auth/auth-manager.d.ts.map +0 -1
  211. package/dist/auth/auth-manager.js.map +0 -1
  212. package/dist/auth/mcp-auth.d.ts.map +0 -1
  213. package/dist/auth/mcp-auth.js.map +0 -1
  214. package/dist/compliance/alert-manager.d.ts.map +0 -1
  215. package/dist/compliance/alert-manager.js.map +0 -1
  216. package/dist/compliance/breach-detection.d.ts.map +0 -1
  217. package/dist/compliance/breach-detection.js.map +0 -1
  218. package/dist/compliance/change-log.d.ts.map +0 -1
  219. package/dist/compliance/change-log.js.map +0 -1
  220. package/dist/compliance/compliance-logger.d.ts.map +0 -1
  221. package/dist/compliance/compliance-logger.js.map +0 -1
  222. package/dist/compliance/compliance-tools.d.ts.map +0 -1
  223. package/dist/compliance/compliance-tools.js.map +0 -1
  224. package/dist/compliance/consent-manager.d.ts.map +0 -1
  225. package/dist/compliance/consent-manager.js.map +0 -1
  226. package/dist/compliance/dashboard.d.ts.map +0 -1
  227. package/dist/compliance/dashboard.js.map +0 -1
  228. package/dist/compliance/data-classification.d.ts.map +0 -1
  229. package/dist/compliance/data-classification.js.map +0 -1
  230. package/dist/compliance/data-erasure.d.ts.map +0 -1
  231. package/dist/compliance/data-erasure.js.map +0 -1
  232. package/dist/compliance/data-export.d.ts.map +0 -1
  233. package/dist/compliance/data-export.js.map +0 -1
  234. package/dist/compliance/data-inventory.d.ts.map +0 -1
  235. package/dist/compliance/data-inventory.js.map +0 -1
  236. package/dist/compliance/dsar-handler.d.ts.map +0 -1
  237. package/dist/compliance/dsar-handler.js.map +0 -1
  238. package/dist/compliance/evidence-collector.d.ts.map +0 -1
  239. package/dist/compliance/evidence-collector.js.map +0 -1
  240. package/dist/compliance/health-monitor.d.ts.map +0 -1
  241. package/dist/compliance/health-monitor.js.map +0 -1
  242. package/dist/compliance/incident-manager.d.ts.map +0 -1
  243. package/dist/compliance/incident-manager.js.map +0 -1
  244. package/dist/compliance/index.d.ts.map +0 -1
  245. package/dist/compliance/index.js.map +0 -1
  246. package/dist/compliance/policy-docs.d.ts.map +0 -1
  247. package/dist/compliance/policy-docs.js.map +0 -1
  248. package/dist/compliance/privacy-notice-text.d.ts.map +0 -1
  249. package/dist/compliance/privacy-notice-text.js.map +0 -1
  250. package/dist/compliance/privacy-notice.d.ts.map +0 -1
  251. package/dist/compliance/privacy-notice.js.map +0 -1
  252. package/dist/compliance/report-generator.d.ts.map +0 -1
  253. package/dist/compliance/report-generator.js.map +0 -1
  254. package/dist/compliance/retention-engine.d.ts.map +0 -1
  255. package/dist/compliance/retention-engine.js.map +0 -1
  256. package/dist/compliance/siem-exporter.d.ts.map +0 -1
  257. package/dist/compliance/siem-exporter.js.map +0 -1
  258. package/dist/compliance/types.d.ts.map +0 -1
  259. package/dist/compliance/types.js.map +0 -1
  260. package/dist/config.d.ts.map +0 -1
  261. package/dist/config.js.map +0 -1
  262. package/dist/errors.d.ts.map +0 -1
  263. package/dist/errors.js.map +0 -1
  264. package/dist/events/event-emitter.d.ts.map +0 -1
  265. package/dist/events/event-emitter.js.map +0 -1
  266. package/dist/events/event-types.d.ts.map +0 -1
  267. package/dist/events/event-types.js.map +0 -1
  268. package/dist/gemini/gemini-client.d.ts.map +0 -1
  269. package/dist/gemini/gemini-client.js.map +0 -1
  270. package/dist/gemini/index.d.ts.map +0 -1
  271. package/dist/gemini/index.js.map +0 -1
  272. package/dist/gemini/pdf-chunker.d.ts.map +0 -1
  273. package/dist/gemini/pdf-chunker.js.map +0 -1
  274. package/dist/gemini/types.d.ts.map +0 -1
  275. package/dist/gemini/types.js.map +0 -1
  276. package/dist/index.d.ts.map +0 -1
  277. package/dist/index.js.map +0 -1
  278. package/dist/library/notebook-library.d.ts.map +0 -1
  279. package/dist/library/notebook-library.js.map +0 -1
  280. package/dist/library/types.d.ts.map +0 -1
  281. package/dist/library/types.js.map +0 -1
  282. package/dist/logging/index.d.ts.map +0 -1
  283. package/dist/logging/index.js.map +0 -1
  284. package/dist/logging/query-logger.d.ts.map +0 -1
  285. package/dist/logging/query-logger.js.map +0 -1
  286. package/dist/notebook-creation/audio-manager.d.ts.map +0 -1
  287. package/dist/notebook-creation/audio-manager.js.map +0 -1
  288. package/dist/notebook-creation/browser-options.d.ts.map +0 -1
  289. package/dist/notebook-creation/browser-options.js.map +0 -1
  290. package/dist/notebook-creation/data-table-manager.d.ts.map +0 -1
  291. package/dist/notebook-creation/data-table-manager.js.map +0 -1
  292. package/dist/notebook-creation/discover-creation-flow.d.ts +0 -2
  293. package/dist/notebook-creation/discover-creation-flow.d.ts.map +0 -1
  294. package/dist/notebook-creation/discover-creation-flow.js +0 -177
  295. package/dist/notebook-creation/discover-creation-flow.js.map +0 -1
  296. package/dist/notebook-creation/discover-quota.d.ts +0 -2
  297. package/dist/notebook-creation/discover-quota.d.ts.map +0 -1
  298. package/dist/notebook-creation/discover-quota.js +0 -194
  299. package/dist/notebook-creation/discover-quota.js.map +0 -1
  300. package/dist/notebook-creation/discover-source-dialog.d.ts +0 -8
  301. package/dist/notebook-creation/discover-source-dialog.d.ts.map +0 -1
  302. package/dist/notebook-creation/discover-source-dialog.js +0 -134
  303. package/dist/notebook-creation/discover-source-dialog.js.map +0 -1
  304. package/dist/notebook-creation/discover-sources.d.ts +0 -8
  305. package/dist/notebook-creation/discover-sources.d.ts.map +0 -1
  306. package/dist/notebook-creation/discover-sources.js +0 -272
  307. package/dist/notebook-creation/discover-sources.js.map +0 -1
  308. package/dist/notebook-creation/discover-text-input.d.ts +0 -7
  309. package/dist/notebook-creation/discover-text-input.d.ts.map +0 -1
  310. package/dist/notebook-creation/discover-text-input.js +0 -135
  311. package/dist/notebook-creation/discover-text-input.js.map +0 -1
  312. package/dist/notebook-creation/dom-scripts.d.ts.map +0 -1
  313. package/dist/notebook-creation/dom-scripts.js.map +0 -1
  314. package/dist/notebook-creation/errors.d.ts.map +0 -1
  315. package/dist/notebook-creation/errors.js.map +0 -1
  316. package/dist/notebook-creation/index.d.ts.map +0 -1
  317. package/dist/notebook-creation/index.js.map +0 -1
  318. package/dist/notebook-creation/notebook-creator.d.ts.map +0 -1
  319. package/dist/notebook-creation/notebook-creator.js.map +0 -1
  320. package/dist/notebook-creation/notebook-nav.d.ts.map +0 -1
  321. package/dist/notebook-creation/notebook-nav.js.map +0 -1
  322. package/dist/notebook-creation/notebook-sync.d.ts.map +0 -1
  323. package/dist/notebook-creation/notebook-sync.js.map +0 -1
  324. package/dist/notebook-creation/run-discovery.d.ts +0 -11
  325. package/dist/notebook-creation/run-discovery.d.ts.map +0 -1
  326. package/dist/notebook-creation/run-discovery.js +0 -151
  327. package/dist/notebook-creation/run-discovery.js.map +0 -1
  328. package/dist/notebook-creation/selector-discovery.d.ts +0 -65
  329. package/dist/notebook-creation/selector-discovery.d.ts.map +0 -1
  330. package/dist/notebook-creation/selector-discovery.js +0 -414
  331. package/dist/notebook-creation/selector-discovery.js.map +0 -1
  332. package/dist/notebook-creation/selectors.d.ts.map +0 -1
  333. package/dist/notebook-creation/selectors.js.map +0 -1
  334. package/dist/notebook-creation/selectors.ts +0 -112
  335. package/dist/notebook-creation/source-manager.d.ts.map +0 -1
  336. package/dist/notebook-creation/source-manager.js.map +0 -1
  337. package/dist/notebook-creation/test-create.d.ts +0 -8
  338. package/dist/notebook-creation/test-create.d.ts.map +0 -1
  339. package/dist/notebook-creation/test-create.js +0 -72
  340. package/dist/notebook-creation/test-create.js.map +0 -1
  341. package/dist/notebook-creation/types.d.ts.map +0 -1
  342. package/dist/notebook-creation/types.js.map +0 -1
  343. package/dist/notebook-creation/video-manager.d.ts.map +0 -1
  344. package/dist/notebook-creation/video-manager.js.map +0 -1
  345. package/dist/observability/metrics.d.ts.map +0 -1
  346. package/dist/observability/metrics.js.map +0 -1
  347. package/dist/quota/index.d.ts.map +0 -1
  348. package/dist/quota/index.js.map +0 -1
  349. package/dist/quota/quota-manager.d.ts.map +0 -1
  350. package/dist/quota/quota-manager.js.map +0 -1
  351. package/dist/resources/resource-handlers.d.ts.map +0 -1
  352. package/dist/resources/resource-handlers.js.map +0 -1
  353. package/dist/session/browser-session.d.ts.map +0 -1
  354. package/dist/session/browser-session.js.map +0 -1
  355. package/dist/session/session-manager.d.ts.map +0 -1
  356. package/dist/session/session-manager.js.map +0 -1
  357. package/dist/session/session-timeout.d.ts.map +0 -1
  358. package/dist/session/session-timeout.js.map +0 -1
  359. package/dist/session/shared-context-manager.d.ts.map +0 -1
  360. package/dist/session/shared-context-manager.js.map +0 -1
  361. package/dist/tools/annotations.d.ts.map +0 -1
  362. package/dist/tools/annotations.js.map +0 -1
  363. package/dist/tools/definitions/ask-question.d.ts.map +0 -1
  364. package/dist/tools/definitions/ask-question.js.map +0 -1
  365. package/dist/tools/definitions/chat-history.d.ts.map +0 -1
  366. package/dist/tools/definitions/chat-history.js.map +0 -1
  367. package/dist/tools/definitions/data-tables.d.ts.map +0 -1
  368. package/dist/tools/definitions/data-tables.js.map +0 -1
  369. package/dist/tools/definitions/gemini.d.ts.map +0 -1
  370. package/dist/tools/definitions/gemini.js.map +0 -1
  371. package/dist/tools/definitions/notebook-management.d.ts.map +0 -1
  372. package/dist/tools/definitions/notebook-management.js.map +0 -1
  373. package/dist/tools/definitions/query-history.d.ts.map +0 -1
  374. package/dist/tools/definitions/query-history.js.map +0 -1
  375. package/dist/tools/definitions/session-management.d.ts.map +0 -1
  376. package/dist/tools/definitions/session-management.js.map +0 -1
  377. package/dist/tools/definitions/system.d.ts.map +0 -1
  378. package/dist/tools/definitions/system.js.map +0 -1
  379. package/dist/tools/definitions/video.d.ts.map +0 -1
  380. package/dist/tools/definitions/video.js.map +0 -1
  381. package/dist/tools/definitions.d.ts.map +0 -1
  382. package/dist/tools/definitions.js.map +0 -1
  383. package/dist/tools/handlers/ask-question.d.ts.map +0 -1
  384. package/dist/tools/handlers/ask-question.js.map +0 -1
  385. package/dist/tools/handlers/audio-video.d.ts.map +0 -1
  386. package/dist/tools/handlers/audio-video.js.map +0 -1
  387. package/dist/tools/handlers/auth.d.ts.map +0 -1
  388. package/dist/tools/handlers/auth.js.map +0 -1
  389. package/dist/tools/handlers/error-utils.d.ts.map +0 -1
  390. package/dist/tools/handlers/error-utils.js.map +0 -1
  391. package/dist/tools/handlers/gemini.d.ts.map +0 -1
  392. package/dist/tools/handlers/gemini.js.map +0 -1
  393. package/dist/tools/handlers/index.d.ts.map +0 -1
  394. package/dist/tools/handlers/index.js.map +0 -1
  395. package/dist/tools/handlers/notebook-creation.d.ts.map +0 -1
  396. package/dist/tools/handlers/notebook-creation.js.map +0 -1
  397. package/dist/tools/handlers/notebook-management.d.ts.map +0 -1
  398. package/dist/tools/handlers/notebook-management.js.map +0 -1
  399. package/dist/tools/handlers/session-management.d.ts.map +0 -1
  400. package/dist/tools/handlers/session-management.js.map +0 -1
  401. package/dist/tools/handlers/system.d.ts.map +0 -1
  402. package/dist/tools/handlers/system.js.map +0 -1
  403. package/dist/tools/handlers/types.d.ts.map +0 -1
  404. package/dist/tools/handlers/types.js.map +0 -1
  405. package/dist/tools/handlers/webhooks.d.ts.map +0 -1
  406. package/dist/tools/handlers/webhooks.js.map +0 -1
  407. package/dist/tools/handlers.d.ts +0 -666
  408. package/dist/tools/handlers.d.ts.map +0 -1
  409. package/dist/tools/handlers.js +0 -2929
  410. package/dist/tools/handlers.js.map +0 -1
  411. package/dist/tools/icons.d.ts.map +0 -1
  412. package/dist/tools/icons.js.map +0 -1
  413. package/dist/tools/index.d.ts.map +0 -1
  414. package/dist/tools/index.js.map +0 -1
  415. package/dist/types.d.ts.map +0 -1
  416. package/dist/types.js.map +0 -1
  417. package/dist/utils/audit-logger.d.ts.map +0 -1
  418. package/dist/utils/audit-logger.js.map +0 -1
  419. package/dist/utils/cert-pinning.d.ts +0 -97
  420. package/dist/utils/cert-pinning.d.ts.map +0 -1
  421. package/dist/utils/cert-pinning.js +0 -328
  422. package/dist/utils/cert-pinning.js.map +0 -1
  423. package/dist/utils/cleanup-manager.d.ts.map +0 -1
  424. package/dist/utils/cleanup-manager.js.map +0 -1
  425. package/dist/utils/cli-handler.d.ts.map +0 -1
  426. package/dist/utils/cli-handler.js.map +0 -1
  427. package/dist/utils/crypto.d.ts.map +0 -1
  428. package/dist/utils/crypto.js.map +0 -1
  429. package/dist/utils/file-lock.d.ts.map +0 -1
  430. package/dist/utils/file-lock.js.map +0 -1
  431. package/dist/utils/file-permissions.d.ts.map +0 -1
  432. package/dist/utils/file-permissions.js.map +0 -1
  433. package/dist/utils/logger.d.ts.map +0 -1
  434. package/dist/utils/logger.js.map +0 -1
  435. package/dist/utils/page-utils.d.ts.map +0 -1
  436. package/dist/utils/page-utils.js.map +0 -1
  437. package/dist/utils/response-validator.d.ts.map +0 -1
  438. package/dist/utils/response-validator.js.map +0 -1
  439. package/dist/utils/secrets-scanner.d.ts.map +0 -1
  440. package/dist/utils/secrets-scanner.js.map +0 -1
  441. package/dist/utils/secure-memory.d.ts.map +0 -1
  442. package/dist/utils/secure-memory.js.map +0 -1
  443. package/dist/utils/security.d.ts.map +0 -1
  444. package/dist/utils/security.js.map +0 -1
  445. package/dist/utils/settings-manager.d.ts.map +0 -1
  446. package/dist/utils/settings-manager.js.map +0 -1
  447. package/dist/utils/stealth-utils.d.ts.map +0 -1
  448. package/dist/utils/stealth-utils.js.map +0 -1
  449. package/dist/utils/tool-validation.d.ts +0 -93
  450. package/dist/utils/tool-validation.d.ts.map +0 -1
  451. package/dist/utils/tool-validation.js +0 -277
  452. package/dist/utils/tool-validation.js.map +0 -1
  453. package/dist/webhooks/index.d.ts.map +0 -1
  454. package/dist/webhooks/index.js.map +0 -1
  455. package/dist/webhooks/types.d.ts.map +0 -1
  456. package/dist/webhooks/types.js.map +0 -1
  457. package/dist/webhooks/webhook-dispatcher.d.ts.map +0 -1
  458. package/dist/webhooks/webhook-dispatcher.js.map +0 -1
  459. package/docs/COMPLIANCE-SPEC.md +0 -1452
  460. package/docs/MCP-DIRECTORY-LISTINGS.md +0 -91
  461. package/docs/SECURITY-FORK-OPPORTUNITIES.md +0 -79
  462. package/docs/SECURITY_IMPLEMENTATION_PLAN.md +0 -437
  463. package/docs/archive/ISSUES-legacy-2026-04-24.md +0 -644
  464. package/docs/configuration.md +0 -94
  465. package/docs/dependency-risk.md +0 -25
  466. package/docs/improvement-sprint-2026.2.10.md +0 -210
  467. package/docs/testing-runbook.md +0 -166
  468. package/docs/tools.md +0 -34
  469. package/docs/troubleshooting.md +0 -59
  470. package/docs/usage-guide.md +0 -246
package/dist/types.js CHANGED
@@ -2,4 +2,3 @@
2
2
  * Global type definitions for NotebookLM MCP Server
3
3
  */
4
4
  export {};
5
- //# sourceMappingURL=types.js.map
@@ -54,6 +54,8 @@ export declare class AuditLogger {
54
54
  private config;
55
55
  private currentLogFile;
56
56
  private previousHash;
57
+ private checkpointPath;
58
+ private checkpointKey;
57
59
  private writeQueue;
58
60
  private pendingEvents;
59
61
  private hashChainWarningLogged;
@@ -152,6 +154,15 @@ export declare class AuditLogger {
152
154
  */
153
155
  flush(): Promise<void>;
154
156
  private getLogFilePathForTimestamp;
157
+ /** Compute the HMAC signature for a checkpoint hash, or null when no key is set. */
158
+ private signCheckpoint;
159
+ /**
160
+ * Persist the latest chain hash to the external checkpoint (outside the log dir).
161
+ * Best-effort: a failure here must never break audit writes.
162
+ */
163
+ private writeCheckpoint;
164
+ /** Read the external checkpoint, returning null if absent or unreadable. */
165
+ private readCheckpoint;
155
166
  private disableHashChainForSession;
156
167
  private handleWriteFailure;
157
168
  private registerProcessHandlers;
@@ -177,4 +188,3 @@ export declare const audit: {
177
188
  configChange: (setting: string, oldValue: unknown, newValue: unknown, changedBy?: string) => Promise<void>;
178
189
  retention: (action: "cleanup" | "archive" | "delete", dataType: string, count: number, details?: Record<string, unknown>) => Promise<void>;
179
190
  };
180
- //# sourceMappingURL=audit-logger.d.ts.map
@@ -16,7 +16,7 @@ import path from "path";
16
16
  import crypto from "crypto";
17
17
  import { CONFIG } from "../config.js";
18
18
  import { sanitizeForLogging } from "./security.js";
19
- import { withLock } from "./file-lock.js";
19
+ import { withLock, STALE_LOCK_THRESHOLD_MS } from "./file-lock.js";
20
20
  import { logger } from "./logger.js";
21
21
  import { mkdirSecure, appendFileSecure, PERMISSION_MODES, } from "./file-permissions.js";
22
22
  /**
@@ -43,6 +43,21 @@ export class AuditLogger {
43
43
  config;
44
44
  currentLogFile = "";
45
45
  previousHash = "GENESIS";
46
+ // M6: external tamper anchor (chosen over a co-located sequence counter — see note
47
+ // below). The checkpoint persists the latest chain hash to a sidecar file OUTSIDE
48
+ // the audit log dir. Threat model, honestly stated:
49
+ // - Location separation defends only against tampering scoped to the audit-*.jsonl
50
+ // files (a tool/path that rewrites the logs but doesn't know about the sidecar).
51
+ // - An attacker with broad filesystem write can also rewrite the sidecar. The HMAC
52
+ // SIGNATURE is the only real defense against that, and only if
53
+ // NLMCP_AUDIT_CHECKPOINT_KEY is stored where the attacker cannot read it.
54
+ // A co-located sequence counter was rejected: the same broad-write attacker would
55
+ // renumber it contiguously, so it would not close the stated threat, and it would
56
+ // touch the hashed payload (breaking the existing chain tests). The checkpoint leaves
57
+ // the hashed payload untouched. Set NLMCP_AUDIT_CHECKPOINT_PATH to place the sidecar
58
+ // on a different volume/trust domain for genuine location separation.
59
+ checkpointPath = "";
60
+ checkpointKey = process.env.NLMCP_AUDIT_CHECKPOINT_KEY;
46
61
  writeQueue = Promise.resolve();
47
62
  pendingEvents = [];
48
63
  hashChainWarningLogged = false;
@@ -64,6 +79,14 @@ export class AuditLogger {
64
79
  this.config = { ...getAuditConfig(), ...config };
65
80
  AuditLogger.instances.add(this);
66
81
  this.registerProcessHandlers();
82
+ // M6: place the tamper-anchor checkpoint OUTSIDE the audit log dir but in a
83
+ // directory that is guaranteed to exist at write time. The parent of logDir
84
+ // (dataDir in production) is created by ensureLogDirectory() in this constructor
85
+ // before any checkpoint write; configDir is intentionally never created by the app
86
+ // (see config.ts), so we do NOT use it — that would make this a silent no-op.
87
+ // NLMCP_AUDIT_CHECKPOINT_PATH lets ops relocate the sidecar to another trust domain.
88
+ this.checkpointPath = process.env.NLMCP_AUDIT_CHECKPOINT_PATH
89
+ || path.join(path.dirname(this.config.logDir), ".audit-checkpoint.json");
67
90
  if (this.config.enabled) {
68
91
  this.ensureLogDirectory();
69
92
  this.initializeLogFile();
@@ -100,14 +123,22 @@ export class AuditLogger {
100
123
  }
101
124
  }
102
125
  catch (err) {
103
- // Log corruption rather than silently resetting silent reset lets tampered chains pass (I217)
104
- logger.warning(`audit log chain corruption detected in ${this.currentLogFile}: ${err instanceof Error ? err.message : String(err)}. Restarting hash chain.`);
126
+ // A corrupt tail on the current day must NOT silently reset to a fresh GENESIS
127
+ // chain that would let an attacker append one garbage byte to force a chain
128
+ // restart and launder the break behind a new valid-looking chain (M7, was I217).
129
+ // Instead, quarantine the chain for this session (disable hash chaining) and
130
+ // surface a security-level warning. The "corruption detected" wording is also
131
+ // relied upon by tests/audit-logger.test.ts.
132
+ logger.warning(`audit log chain corruption detected in ${this.currentLogFile}: ${err instanceof Error ? err.message : String(err)}. Hash chain quarantined for this session.`);
133
+ this.disableHashChainForSession();
105
134
  this.previousHash = "GENESIS";
106
135
  }
107
136
  }
108
137
  // If today's file has no content yet, link the chain from the previous day's
109
138
  // last hash so cross-day gaps cannot be exploited by replacing a whole day's file.
110
- if (this.previousHash === "GENESIS") {
139
+ // Skip this if the chain has been quarantined (M7) so a corrupted session does not
140
+ // re-link to a previous hash and produce a fresh valid-looking chain.
141
+ if (this.config.hashChainEnabled && this.previousHash === "GENESIS") {
111
142
  const prevHash = this.findPreviousDayLastHash(today);
112
143
  if (prevHash) {
113
144
  this.previousHash = prevHash;
@@ -156,8 +187,12 @@ export class AuditLogger {
156
187
  cleanOldLogs() {
157
188
  try {
158
189
  const files = fs.readdirSync(this.config.logDir);
190
+ // Filenames are UTC dates (toISOString) and new Date("YYYY-MM-DD") parses as
191
+ // UTC midnight, so compute the cutoff at UTC midnight too — using local
192
+ // setDate/getDate would skew the comparison by up to a day near TZ boundaries (L13).
159
193
  const cutoffDate = new Date();
160
- cutoffDate.setDate(cutoffDate.getDate() - this.config.retentionDays);
194
+ cutoffDate.setUTCHours(0, 0, 0, 0);
195
+ cutoffDate.setUTCDate(cutoffDate.getUTCDate() - this.config.retentionDays);
161
196
  for (const file of files) {
162
197
  if (!file.startsWith("audit-") || !file.endsWith(".jsonl"))
163
198
  continue;
@@ -197,13 +232,26 @@ export class AuditLogger {
197
232
  const sanitized = {};
198
233
  for (const [key, value] of Object.entries(details)) {
199
234
  const lowerKey = key.toLowerCase();
200
- // Skip sensitive keys entirely
201
- if (/password|secret|token|key|credential|auth/i.test(key)) {
235
+ // Skip sensitive keys entirely. Anchored to exact key names (L14) so benign keys
236
+ // like author / keywords / tokenCount / monkey are no longer stomped to [REDACTED]
237
+ // by a loose substring match. The bare `auth` key is kept as an exact alternative so
238
+ // we retain full parity with the old loose regex (which matched `auth`) — `author`
239
+ // etc. are not exactly "auth" so they still pass through. accessToken / refreshToken
240
+ // / secretKey etc. are NOT matched here on purpose — their string values are still
241
+ // caught by the broad substring net in the string-value branch below, which we
242
+ // deliberately keep loose so real compound-named secrets do not leak.
243
+ if (/^(password|secret|token|api_?key|credential|auth|authorization)$/i.test(key)) {
202
244
  sanitized[key] = "[REDACTED]";
203
245
  continue;
204
246
  }
205
247
  // Sanitize string values
206
248
  if (typeof value === "string") {
249
+ // Intentionally broad (substring) safety net: this is what keeps camelCase
250
+ // compound secret keys (accessToken, refreshToken, secretKey, authToken) redacted
251
+ // now that the key-path above is exact-match (L14). Accepted tradeoff: a benign
252
+ // key holding a long (>8 char) string and containing one of these substrings
253
+ // (e.g. "keywords", "monkey") is still redacted here — preferred over leaking a
254
+ // real secret.
207
255
  if (value.length > 8 &&
208
256
  /password|token|secret|key|credential/.test(lowerKey)) {
209
257
  sanitized[key] = "[REDACTED]";
@@ -237,23 +285,35 @@ export class AuditLogger {
237
285
  return;
238
286
  }
239
287
  const logFile = this.getLogFilePathForTimestamp(event.timestamp);
240
- const line = `${JSON.stringify(event)}\n`;
241
288
  try {
242
289
  await withLock(logFile, async () => {
243
290
  if (!this.pendingEvents.includes(event)) {
244
291
  return;
245
292
  }
293
+ // Stamp the chain link and compute the hash inside the serialized critical section
294
+ // so the pointer advances atomically per event in write order (H20). Computing this
295
+ // at log() time would let concurrent calls share a previousHash and fork the chain.
296
+ if (this.config.hashChainEnabled) {
297
+ event.previousHash = this.previousHash;
298
+ const { hash: _ignored, ...eventWithoutHash } = event;
299
+ event.hash = this.computeHash(eventWithoutHash);
300
+ }
301
+ const line = `${JSON.stringify(event)}\n`;
246
302
  this.currentLogFile = logFile;
247
303
  appendFileSecure(logFile, line, PERMISSION_MODES.OWNER_READ_WRITE);
248
304
  this.pendingEvents = this.pendingEvents.filter((pendingEvent) => pendingEvent !== event);
249
305
  // Advance the chain pointer only after the write physically succeeds (I228)
250
306
  if (this.config.hashChainEnabled && event.hash) {
251
307
  this.previousHash = event.hash;
308
+ // Anchor the latest hash externally after it advances (M6).
309
+ this.writeCheckpoint(event.hash);
252
310
  }
253
311
  });
254
312
  // Fan-out to subscribers after successful write (I244)
255
313
  for (const sub of this.eventSubscribers) {
256
- sub(event).catch(() => { }); // fire-and-forget, never block audit writes
314
+ // Fire-and-forget so a slow/failing SIEM/compliance subscriber never blocks
315
+ // audit writes, but surface the failure at debug level so it is observable (L12).
316
+ sub(event).catch(err => logger.debug(`audit-logger: subscriber fan-out error: ${err instanceof Error ? err.message : String(err)}`));
257
317
  }
258
318
  }
259
319
  catch (error) {
@@ -278,23 +338,20 @@ export class AuditLogger {
278
338
  const sanitizedDetails = this.config.includeDetails
279
339
  ? this.sanitizeDetails(details)
280
340
  : {};
281
- const eventWithoutHash = {
341
+ // The previousHash and hash are NOT computed here. Concurrent log() calls would
342
+ // otherwise read the same this.previousHash before any write completes and fork the
343
+ // chain. Instead they are assigned inside flushEvent's serialized critical section, in
344
+ // write order, so the chain pointer advances atomically per event (H20).
345
+ const event = {
282
346
  timestamp: new Date().toISOString(),
283
347
  eventType,
284
348
  eventName,
285
349
  success,
286
350
  duration_ms,
287
351
  details: sanitizedDetails,
288
- previousHash: this.config.hashChainEnabled ? this.previousHash : "",
352
+ previousHash: "",
353
+ hash: "",
289
354
  };
290
- const hash = this.config.hashChainEnabled
291
- ? this.computeHash(eventWithoutHash)
292
- : "";
293
- const event = {
294
- ...eventWithoutHash,
295
- hash,
296
- };
297
- // previousHash is updated inside flushEvent after the write succeeds (I228)
298
355
  await this.writeEvent(event);
299
356
  }
300
357
  // ============================================================================
@@ -389,8 +446,21 @@ export class AuditLogger {
389
446
  */
390
447
  summarizeArgs(args) {
391
448
  const summary = {};
449
+ // M8: free-text fields from compliance tools (report_security_incident
450
+ // title/description, request_data_erasure reason, submit_dsar details) carry
451
+ // user-supplied PII. sanitizeDetails only redacts by KEY name and short values pass
452
+ // through verbatim, so these would persist in the audit log for the 2555-day
453
+ // retention. Hash + length-stamp them here (the single choke point for all tool
454
+ // calls) so the audit record stays useful (correlatable, length known) without
455
+ // storing raw PII.
456
+ const FREE_TEXT_PII = /^(description|reason|details|title)$/i;
392
457
  for (const [key, value] of Object.entries(args)) {
393
458
  if (typeof value === "string") {
459
+ if (FREE_TEXT_PII.test(key)) {
460
+ const digest = crypto.createHash("sha256").update(value).digest("hex").slice(0, 16);
461
+ summary[key] = `[redacted PII, ${value.length} chars, sha256:${digest}]`;
462
+ continue;
463
+ }
394
464
  // Log length for long strings, actual value for short ones
395
465
  if (value.length > 100) {
396
466
  summary[key] = `[string, ${value.length} chars]`;
@@ -467,6 +537,31 @@ export class AuditLogger {
467
537
  errors.push(`Line ${i + 1}: Invalid JSON`);
468
538
  }
469
539
  }
540
+ // M6: verify against the external tamper anchor. Log-file-scoped tampering that
541
+ // recomputes a self-consistent chain but does not also update the out-of-dir
542
+ // sidecar is caught here; broad filesystem tampering is caught only when an HMAC
543
+ // key (NLMCP_AUDIT_CHECKPOINT_KEY) is configured and held out of reach.
544
+ // Tolerate a missing checkpoint (first run / arbitrary historical file) — only
545
+ // flag when a checkpoint exists, so this never spuriously fails a clean log.
546
+ if (this.config.hashChainEnabled && lines.length > 0) {
547
+ const checkpoint = this.readCheckpoint();
548
+ if (checkpoint) {
549
+ // Only anchor-check the live current-day file: the checkpoint tracks the
550
+ // latest hash written, which belongs to the most recent file.
551
+ const isCurrentFile = path.resolve(file) === path.resolve(this.currentLogFile);
552
+ if (isCurrentFile) {
553
+ if (this.checkpointKey) {
554
+ const expectedSig = this.signCheckpoint(checkpoint.hash);
555
+ if (!checkpoint.signature || checkpoint.signature !== expectedSig) {
556
+ errors.push("Tamper anchor: checkpoint signature invalid (checkpoint may have been forged or key changed).");
557
+ }
558
+ }
559
+ if (checkpoint.hash !== expectedPreviousHash) {
560
+ errors.push(`Tamper anchor: external checkpoint hash does not match log tail. Expected ${checkpoint.hash}, log ends at ${expectedPreviousHash}. The log may have been rewritten.`);
561
+ }
562
+ }
563
+ }
564
+ }
470
565
  return { valid: errors.length === 0, errors };
471
566
  }
472
567
  catch (e) {
@@ -483,6 +578,51 @@ export class AuditLogger {
483
578
  const date = timestamp.split("T")[0];
484
579
  return path.join(this.config.logDir, `audit-${date}.jsonl`);
485
580
  }
581
+ // ============================================================================
582
+ // M6: external tamper-anchor checkpoint
583
+ // ============================================================================
584
+ /** Compute the HMAC signature for a checkpoint hash, or null when no key is set. */
585
+ signCheckpoint(hash) {
586
+ if (!this.checkpointKey)
587
+ return null;
588
+ return crypto.createHmac("sha256", this.checkpointKey).update(hash).digest("hex");
589
+ }
590
+ /**
591
+ * Persist the latest chain hash to the external checkpoint (outside the log dir).
592
+ * Best-effort: a failure here must never break audit writes.
593
+ */
594
+ writeCheckpoint(hash) {
595
+ if (!this.config.hashChainEnabled || !hash || hash === "GENESIS")
596
+ return;
597
+ try {
598
+ const payload = {
599
+ hash,
600
+ updatedAt: new Date().toISOString(),
601
+ };
602
+ const signature = this.signCheckpoint(hash);
603
+ if (signature)
604
+ payload.signature = signature;
605
+ fs.writeFileSync(this.checkpointPath, JSON.stringify(payload), { mode: 0o600 });
606
+ }
607
+ catch (err) {
608
+ logger.debug(`audit-logger: writing tamper-anchor checkpoint: ${err instanceof Error ? err.message : String(err)}`);
609
+ }
610
+ }
611
+ /** Read the external checkpoint, returning null if absent or unreadable. */
612
+ readCheckpoint() {
613
+ try {
614
+ if (!fs.existsSync(this.checkpointPath))
615
+ return null;
616
+ const parsed = JSON.parse(fs.readFileSync(this.checkpointPath, "utf-8"));
617
+ if (typeof parsed.hash !== "string" || parsed.hash.length === 0)
618
+ return null;
619
+ return { hash: parsed.hash, signature: parsed.signature };
620
+ }
621
+ catch (err) {
622
+ logger.debug(`audit-logger: reading tamper-anchor checkpoint: ${err instanceof Error ? err.message : String(err)}`);
623
+ return null;
624
+ }
625
+ }
486
626
  disableHashChainForSession() {
487
627
  if (!this.hashChainWarningLogged) {
488
628
  logger.warning(AuditLogger.MISSING_HASH_WARNING);
@@ -507,9 +647,19 @@ export class AuditLogger {
507
647
  process.on("beforeExit", () => {
508
648
  AuditLogger.flushAllSync();
509
649
  });
650
+ // Mirror SIGTERM for SIGINT (Ctrl-C) and SIGHUP so buffered audit events are
651
+ // flushed synchronously on those signals too (M5). The process entry point owns
652
+ // termination (it calls process.exit after its own async shutdown), so these are
653
+ // additive flush-only safety nets and do not suppress termination or hang.
510
654
  process.on("SIGTERM", () => {
511
655
  AuditLogger.flushAllSync();
512
656
  });
657
+ process.on("SIGINT", () => {
658
+ AuditLogger.flushAllSync();
659
+ });
660
+ process.on("SIGHUP", () => {
661
+ AuditLogger.flushAllSync();
662
+ });
513
663
  AuditLogger.processHandlersRegistered = true;
514
664
  }
515
665
  static flushAllSync() {
@@ -521,6 +671,19 @@ export class AuditLogger {
521
671
  if (!this.config.enabled || this.pendingEvents.length === 0) {
522
672
  return;
523
673
  }
674
+ // Re-chain the batch in write order before serializing. Buffered events were created
675
+ // with empty previousHash/hash (those are stamped inside flushEvent's lock on the async
676
+ // path); on the shutdown path we must stamp them here, advancing the running pointer
677
+ // per event, or the chain forks. Uses the same computeHash as the normal path so
678
+ // verifyIntegrity passes (H20).
679
+ if (this.config.hashChainEnabled) {
680
+ for (const event of this.pendingEvents) {
681
+ event.previousHash = this.previousHash;
682
+ const { hash: _ignored, ...eventWithoutHash } = event;
683
+ event.hash = this.computeHash(eventWithoutHash);
684
+ this.previousHash = event.hash;
685
+ }
686
+ }
524
687
  const groupedEvents = new Map();
525
688
  for (const event of this.pendingEvents) {
526
689
  const logFile = this.getLogFilePathForTimestamp(event.timestamp);
@@ -539,6 +702,10 @@ export class AuditLogger {
539
702
  }
540
703
  this.currentLogFile = logFile;
541
704
  }
705
+ // Anchor the final advanced hash externally on the shutdown path too (M6).
706
+ if (this.config.hashChainEnabled && this.previousHash && this.previousHash !== "GENESIS") {
707
+ this.writeCheckpoint(this.previousHash);
708
+ }
542
709
  this.pendingEvents = [];
543
710
  }
544
711
  writeWithSyncLock(logFile, lines) {
@@ -567,7 +734,9 @@ export class AuditLogger {
567
734
  try {
568
735
  const content = fs.readFileSync(lockPath, "utf-8");
569
736
  const existing = JSON.parse(content);
570
- if (typeof existing.timestamp === "number" && Date.now() - existing.timestamp > 30000) {
737
+ // Use the shared stale-lock threshold (L15) so this sync shutdown path and the
738
+ // async FileLock util agree on staleness for locks on the SAME audit files.
739
+ if (typeof existing.timestamp === "number" && Date.now() - existing.timestamp > STALE_LOCK_THRESHOLD_MS) {
571
740
  fs.unlinkSync(lockPath);
572
741
  continue;
573
742
  }
@@ -631,4 +800,3 @@ export const audit = {
631
800
  configChange: (setting, oldValue, newValue, changedBy) => getAuditLogger().logConfigChange(setting, oldValue, newValue, changedBy),
632
801
  retention: (action, dataType, count, details) => getAuditLogger().logRetentionEvent(action, dataType, count, details),
633
802
  };
634
- //# sourceMappingURL=audit-logger.js.map
@@ -130,4 +130,3 @@ export declare class CleanupManager {
130
130
  claudeProjectsPath: string;
131
131
  };
132
132
  }
133
- //# sourceMappingURL=cleanup-manager.d.ts.map
@@ -671,4 +671,3 @@ export class CleanupManager {
671
671
  };
672
672
  }
673
673
  }
674
- //# sourceMappingURL=cleanup-manager.js.map
@@ -13,4 +13,3 @@ export declare class CliHandler {
13
13
  private handleReset;
14
14
  private printHelp;
15
15
  }
16
- //# sourceMappingURL=cli-handler.d.ts.map
@@ -99,4 +99,3 @@ Profiles:
99
99
  `);
100
100
  }
101
101
  }
102
- //# sourceMappingURL=cli-handler.js.map
@@ -57,20 +57,23 @@ interface ClassicalEncryptedData {
57
57
  version: number;
58
58
  algorithm: string;
59
59
  nonce: string;
60
- salt: string;
60
+ salt?: string;
61
61
  ciphertext: string;
62
62
  }
63
63
  /**
64
- * Derive a key from a passphrase using PBKDF2
64
+ * Thrown when an encrypted file exists but cannot be decrypted (e.g. wrong
65
+ * key after rotation, corruption, or tampering). Distinct from a genuinely
66
+ * absent file (load() returns null), so callers can avoid overwriting
67
+ * good-but-undecryptable state.
65
68
  */
66
- export declare function deriveKey(passphrase: string, salt: Buffer, iterations?: number): Buffer;
69
+ export declare class DecryptionError extends Error {
70
+ readonly file: string;
71
+ constructor(message: string, file: string);
72
+ }
67
73
  /**
68
- * Generate a machine-derived key based on hardware/OS identifiers
69
- *
70
- * Note: This provides obscurity, not true security. It's a fallback
71
- * when no user key is provided.
74
+ * Derive a key from a passphrase using PBKDF2
72
75
  */
73
- export declare function getMachineKey(): string;
76
+ export declare function deriveKey(passphrase: string, salt: Buffer, iterations?: number): Buffer;
74
77
  export declare function getOrCreateMachineKey(keyPath: string): Buffer;
75
78
  /**
76
79
  * Generate ML-KEM key pair for post-quantum encryption
@@ -114,6 +117,13 @@ export declare class SecureStorage {
114
117
  private pqKeyPair;
115
118
  private initialized;
116
119
  private keyStorePath;
120
+ /**
121
+ * Captured at construction, before config.enabled can be mutated by
122
+ * initialize()/initializeClassicalKey(). Records whether the caller
123
+ * actually intended encryption. Used to fail closed: if encryption was
124
+ * expected but is unavailable, we refuse to write plaintext.
125
+ */
126
+ private readonly encryptionExpected;
117
127
  constructor(config?: Partial<EncryptionConfig>);
118
128
  /**
119
129
  * Initialize the secure storage (derive/load keys)
@@ -175,4 +185,3 @@ export declare class SecureStorage {
175
185
  */
176
186
  export declare function getSecureStorage(): SecureStorage;
177
187
  export {};
178
- //# sourceMappingURL=crypto.d.ts.map