@pan-sec/notebooklm-mcp 1.4.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -7
- package/SECURITY.md +40 -6
- package/dist/auth/mcp-auth.d.ts.map +1 -1
- package/dist/auth/mcp-auth.js +3 -6
- package/dist/auth/mcp-auth.js.map +1 -1
- package/dist/compliance/alert-manager.d.ts +120 -0
- package/dist/compliance/alert-manager.d.ts.map +1 -0
- package/dist/compliance/alert-manager.js +420 -0
- package/dist/compliance/alert-manager.js.map +1 -0
- package/dist/compliance/breach-detection.d.ts +134 -0
- package/dist/compliance/breach-detection.d.ts.map +1 -0
- package/dist/compliance/breach-detection.js +456 -0
- package/dist/compliance/breach-detection.js.map +1 -0
- package/dist/compliance/change-log.d.ts +113 -0
- package/dist/compliance/change-log.d.ts.map +1 -0
- package/dist/compliance/change-log.js +275 -0
- package/dist/compliance/change-log.js.map +1 -0
- package/dist/compliance/compliance-logger.d.ts +136 -0
- package/dist/compliance/compliance-logger.d.ts.map +1 -0
- package/dist/compliance/compliance-logger.js +425 -0
- package/dist/compliance/compliance-logger.js.map +1 -0
- package/dist/compliance/compliance-tools.d.ts +18 -0
- package/dist/compliance/compliance-tools.d.ts.map +1 -0
- package/dist/compliance/compliance-tools.js +673 -0
- package/dist/compliance/compliance-tools.js.map +1 -0
- package/dist/compliance/consent-manager.d.ts +130 -0
- package/dist/compliance/consent-manager.d.ts.map +1 -0
- package/dist/compliance/consent-manager.js +386 -0
- package/dist/compliance/consent-manager.js.map +1 -0
- package/dist/compliance/dashboard.d.ts +243 -0
- package/dist/compliance/dashboard.d.ts.map +1 -0
- package/dist/compliance/dashboard.js +519 -0
- package/dist/compliance/dashboard.js.map +1 -0
- package/dist/compliance/data-classification.d.ts +117 -0
- package/dist/compliance/data-classification.d.ts.map +1 -0
- package/dist/compliance/data-classification.js +469 -0
- package/dist/compliance/data-classification.js.map +1 -0
- package/dist/compliance/data-erasure.d.ts +110 -0
- package/dist/compliance/data-erasure.d.ts.map +1 -0
- package/dist/compliance/data-erasure.js +501 -0
- package/dist/compliance/data-erasure.js.map +1 -0
- package/dist/compliance/data-export.d.ts +85 -0
- package/dist/compliance/data-export.d.ts.map +1 -0
- package/dist/compliance/data-export.js +394 -0
- package/dist/compliance/data-export.js.map +1 -0
- package/dist/compliance/data-inventory.d.ts +136 -0
- package/dist/compliance/data-inventory.d.ts.map +1 -0
- package/dist/compliance/data-inventory.js +335 -0
- package/dist/compliance/data-inventory.js.map +1 -0
- package/dist/compliance/dsar-handler.d.ts +123 -0
- package/dist/compliance/dsar-handler.d.ts.map +1 -0
- package/dist/compliance/dsar-handler.js +371 -0
- package/dist/compliance/dsar-handler.js.map +1 -0
- package/dist/compliance/evidence-collector.d.ts +187 -0
- package/dist/compliance/evidence-collector.d.ts.map +1 -0
- package/dist/compliance/evidence-collector.js +656 -0
- package/dist/compliance/evidence-collector.js.map +1 -0
- package/dist/compliance/health-monitor.d.ts +111 -0
- package/dist/compliance/health-monitor.d.ts.map +1 -0
- package/dist/compliance/health-monitor.js +509 -0
- package/dist/compliance/health-monitor.js.map +1 -0
- package/dist/compliance/incident-manager.d.ts +131 -0
- package/dist/compliance/incident-manager.d.ts.map +1 -0
- package/dist/compliance/incident-manager.js +418 -0
- package/dist/compliance/incident-manager.js.map +1 -0
- package/dist/compliance/index.d.ts +32 -0
- package/dist/compliance/index.d.ts.map +1 -0
- package/dist/compliance/index.js +35 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/compliance/policy-docs.d.ts +108 -0
- package/dist/compliance/policy-docs.d.ts.map +1 -0
- package/dist/compliance/policy-docs.js +464 -0
- package/dist/compliance/policy-docs.js.map +1 -0
- package/dist/compliance/privacy-notice-text.d.ts +58 -0
- package/dist/compliance/privacy-notice-text.d.ts.map +1 -0
- package/dist/compliance/privacy-notice-text.js +161 -0
- package/dist/compliance/privacy-notice-text.js.map +1 -0
- package/dist/compliance/privacy-notice.d.ts +128 -0
- package/dist/compliance/privacy-notice.d.ts.map +1 -0
- package/dist/compliance/privacy-notice.js +250 -0
- package/dist/compliance/privacy-notice.js.map +1 -0
- package/dist/compliance/report-generator.d.ts +168 -0
- package/dist/compliance/report-generator.d.ts.map +1 -0
- package/dist/compliance/report-generator.js +830 -0
- package/dist/compliance/report-generator.js.map +1 -0
- package/dist/compliance/retention-engine.d.ts +130 -0
- package/dist/compliance/retention-engine.d.ts.map +1 -0
- package/dist/compliance/retention-engine.js +510 -0
- package/dist/compliance/retention-engine.js.map +1 -0
- package/dist/compliance/siem-exporter.d.ts +150 -0
- package/dist/compliance/siem-exporter.d.ts.map +1 -0
- package/dist/compliance/siem-exporter.js +509 -0
- package/dist/compliance/siem-exporter.js.map +1 -0
- package/dist/compliance/types.d.ts +601 -0
- package/dist/compliance/types.d.ts.map +1 -0
- package/dist/compliance/types.js +22 -0
- package/dist/compliance/types.js.map +1 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -1
- package/dist/config.js.map +1 -1
- package/dist/events/event-emitter.d.ts +45 -0
- package/dist/events/event-emitter.d.ts.map +1 -0
- package/dist/events/event-emitter.js +100 -0
- package/dist/events/event-emitter.js.map +1 -0
- package/dist/events/event-types.d.ts +124 -0
- package/dist/events/event-types.d.ts.map +1 -0
- package/dist/events/event-types.js +18 -0
- package/dist/events/event-types.js.map +1 -0
- package/dist/index.js +59 -2
- package/dist/index.js.map +1 -1
- package/dist/library/notebook-library.d.ts +25 -2
- package/dist/library/notebook-library.d.ts.map +1 -1
- package/dist/library/notebook-library.js +144 -3
- package/dist/library/notebook-library.js.map +1 -1
- package/dist/library/types.d.ts +15 -0
- package/dist/library/types.d.ts.map +1 -1
- package/dist/notebook-creation/audio-manager.d.ts +56 -0
- package/dist/notebook-creation/audio-manager.d.ts.map +1 -0
- package/dist/notebook-creation/audio-manager.js +335 -0
- package/dist/notebook-creation/audio-manager.js.map +1 -0
- package/dist/notebook-creation/discover-creation-flow.d.ts +8 -0
- package/dist/notebook-creation/discover-creation-flow.d.ts.map +1 -0
- package/dist/notebook-creation/discover-creation-flow.js +177 -0
- package/dist/notebook-creation/discover-creation-flow.js.map +1 -0
- package/dist/notebook-creation/discover-quota.d.ts +8 -0
- package/dist/notebook-creation/discover-quota.d.ts.map +1 -0
- package/dist/notebook-creation/discover-quota.js +195 -0
- package/dist/notebook-creation/discover-quota.js.map +1 -0
- package/dist/notebook-creation/discover-source-dialog.d.ts +8 -0
- package/dist/notebook-creation/discover-source-dialog.d.ts.map +1 -0
- package/dist/notebook-creation/discover-source-dialog.js +134 -0
- package/dist/notebook-creation/discover-source-dialog.js.map +1 -0
- package/dist/notebook-creation/discover-sources.d.ts +8 -0
- package/dist/notebook-creation/discover-sources.d.ts.map +1 -0
- package/dist/notebook-creation/discover-sources.js +273 -0
- package/dist/notebook-creation/discover-sources.js.map +1 -0
- package/dist/notebook-creation/discover-text-input.d.ts +7 -0
- package/dist/notebook-creation/discover-text-input.d.ts.map +1 -0
- package/dist/notebook-creation/discover-text-input.js +135 -0
- package/dist/notebook-creation/discover-text-input.js.map +1 -0
- package/dist/notebook-creation/index.d.ts +12 -0
- package/dist/notebook-creation/index.d.ts.map +1 -0
- package/dist/notebook-creation/index.js +12 -0
- package/dist/notebook-creation/index.js.map +1 -0
- package/dist/notebook-creation/notebook-creator.d.ts +95 -0
- package/dist/notebook-creation/notebook-creator.d.ts.map +1 -0
- package/dist/notebook-creation/notebook-creator.js +689 -0
- package/dist/notebook-creation/notebook-creator.js.map +1 -0
- package/dist/notebook-creation/notebook-sync.d.ts +93 -0
- package/dist/notebook-creation/notebook-sync.d.ts.map +1 -0
- package/dist/notebook-creation/notebook-sync.js +370 -0
- package/dist/notebook-creation/notebook-sync.js.map +1 -0
- package/dist/notebook-creation/run-discovery.d.ts +11 -0
- package/dist/notebook-creation/run-discovery.d.ts.map +1 -0
- package/dist/notebook-creation/run-discovery.js +151 -0
- package/dist/notebook-creation/run-discovery.js.map +1 -0
- package/dist/notebook-creation/selector-discovery.d.ts +65 -0
- package/dist/notebook-creation/selector-discovery.d.ts.map +1 -0
- package/dist/notebook-creation/selector-discovery.js +421 -0
- package/dist/notebook-creation/selector-discovery.js.map +1 -0
- package/dist/notebook-creation/selectors.d.ts +150 -0
- package/dist/notebook-creation/selectors.d.ts.map +1 -0
- package/dist/notebook-creation/selectors.js +225 -0
- package/dist/notebook-creation/selectors.js.map +1 -0
- package/dist/notebook-creation/source-manager.d.ts +73 -0
- package/dist/notebook-creation/source-manager.d.ts.map +1 -0
- package/dist/notebook-creation/source-manager.js +486 -0
- package/dist/notebook-creation/source-manager.js.map +1 -0
- package/dist/notebook-creation/test-create.d.ts +8 -0
- package/dist/notebook-creation/test-create.d.ts.map +1 -0
- package/dist/notebook-creation/test-create.js +72 -0
- package/dist/notebook-creation/test-create.js.map +1 -0
- package/dist/notebook-creation/types.d.ts +173 -0
- package/dist/notebook-creation/types.d.ts.map +1 -0
- package/dist/notebook-creation/types.js +5 -0
- package/dist/notebook-creation/types.js.map +1 -0
- package/dist/quota/index.d.ts +8 -0
- package/dist/quota/index.d.ts.map +1 -0
- package/dist/quota/index.js +8 -0
- package/dist/quota/index.js.map +1 -0
- package/dist/quota/quota-manager.d.ts +125 -0
- package/dist/quota/quota-manager.d.ts.map +1 -0
- package/dist/quota/quota-manager.js +330 -0
- package/dist/quota/quota-manager.js.map +1 -0
- package/dist/session/session-manager.d.ts +5 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +6 -0
- package/dist/session/session-manager.js.map +1 -1
- package/dist/session/shared-context-manager.d.ts.map +1 -1
- package/dist/session/shared-context-manager.js +2 -1
- package/dist/session/shared-context-manager.js.map +1 -1
- package/dist/tools/definitions/notebook-management.d.ts.map +1 -1
- package/dist/tools/definitions/notebook-management.js +525 -0
- package/dist/tools/definitions/notebook-management.js.map +1 -1
- package/dist/tools/definitions/system.d.ts.map +1 -1
- package/dist/tools/definitions/system.js +158 -0
- package/dist/tools/definitions/system.js.map +1 -1
- package/dist/tools/handlers.d.ts +225 -0
- package/dist/tools/handlers.d.ts.map +1 -1
- package/dist/tools/handlers.js +911 -0
- package/dist/tools/handlers.js.map +1 -1
- package/dist/utils/audit-logger.d.ts +21 -1
- package/dist/utils/audit-logger.d.ts.map +1 -1
- package/dist/utils/audit-logger.js +53 -4
- package/dist/utils/audit-logger.js.map +1 -1
- package/dist/utils/crypto.d.ts.map +1 -1
- package/dist/utils/crypto.js +8 -15
- package/dist/utils/crypto.js.map +1 -1
- package/dist/utils/file-permissions.d.ts +85 -0
- package/dist/utils/file-permissions.d.ts.map +1 -0
- package/dist/utils/file-permissions.js +180 -0
- package/dist/utils/file-permissions.js.map +1 -0
- package/dist/utils/settings-manager.d.ts.map +1 -1
- package/dist/utils/settings-manager.js +6 -11
- package/dist/utils/settings-manager.js.map +1 -1
- package/dist/webhooks/index.d.ts +8 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +8 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/types.d.ts +57 -0
- package/dist/webhooks/types.d.ts.map +1 -0
- package/dist/webhooks/types.js +5 -0
- package/dist/webhooks/types.js.map +1 -0
- package/dist/webhooks/webhook-dispatcher.d.ts +120 -0
- package/dist/webhooks/webhook-dispatcher.d.ts.map +1 -0
- package/dist/webhooks/webhook-dispatcher.js +519 -0
- package/dist/webhooks/webhook-dispatcher.js.map +1 -0
- package/docs/COMPLIANCE-SPEC.md +1452 -0
- package/package.json +30 -4
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-Platform File Permissions Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides secure file permission handling across Linux, macOS, and Windows.
|
|
5
|
+
*
|
|
6
|
+
* On Unix systems (Linux/macOS):
|
|
7
|
+
* - Uses standard chmod-style permissions (0o600, 0o700, etc.)
|
|
8
|
+
*
|
|
9
|
+
* On Windows:
|
|
10
|
+
* - Uses icacls to restrict file access to current user only
|
|
11
|
+
* - Falls back gracefully if icacls fails
|
|
12
|
+
*
|
|
13
|
+
* Added by Pantheon Security for cross-platform support.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Platform detection
|
|
17
|
+
*/
|
|
18
|
+
export declare const isWindows: boolean;
|
|
19
|
+
export declare const isMacOS: boolean;
|
|
20
|
+
export declare const isLinux: boolean;
|
|
21
|
+
export declare const isUnix: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Common permission modes (Unix-style)
|
|
24
|
+
*/
|
|
25
|
+
export declare const PERMISSION_MODES: {
|
|
26
|
+
/** Owner read/write only (files with sensitive data) */
|
|
27
|
+
readonly OWNER_READ_WRITE: 384;
|
|
28
|
+
/** Owner read/write/execute only (directories, executables) */
|
|
29
|
+
readonly OWNER_FULL: 448;
|
|
30
|
+
/** Owner read/write, group/others read (less sensitive files) */
|
|
31
|
+
readonly OWNER_WRITE_ALL_READ: 420;
|
|
32
|
+
/** Owner full, group/others read+execute (less sensitive directories) */
|
|
33
|
+
readonly OWNER_FULL_ALL_READ_EXECUTE: 493;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Set secure file permissions (owner-only access)
|
|
37
|
+
*
|
|
38
|
+
* @param filePath - Path to the file
|
|
39
|
+
* @param mode - Unix permission mode (default: 0o600)
|
|
40
|
+
* @returns true if permissions were set successfully
|
|
41
|
+
*/
|
|
42
|
+
export declare function setSecureFilePermissions(filePath: string, mode?: number): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Set secure directory permissions (owner-only access)
|
|
45
|
+
*
|
|
46
|
+
* @param dirPath - Path to the directory
|
|
47
|
+
* @param mode - Unix permission mode (default: 0o700)
|
|
48
|
+
* @returns true if permissions were set successfully
|
|
49
|
+
*/
|
|
50
|
+
export declare function setSecureDirectoryPermissions(dirPath: string, mode?: number): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Create a directory with secure permissions
|
|
53
|
+
*
|
|
54
|
+
* @param dirPath - Path to create
|
|
55
|
+
* @param mode - Unix permission mode (default: 0o700)
|
|
56
|
+
*/
|
|
57
|
+
export declare function mkdirSecure(dirPath: string, mode?: number): void;
|
|
58
|
+
/**
|
|
59
|
+
* Write a file with secure permissions
|
|
60
|
+
*
|
|
61
|
+
* @param filePath - Path to write
|
|
62
|
+
* @param content - Content to write
|
|
63
|
+
* @param mode - Unix permission mode (default: 0o600)
|
|
64
|
+
*/
|
|
65
|
+
export declare function writeFileSecure(filePath: string, content: string | Buffer, mode?: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Append to a file with secure permissions
|
|
68
|
+
*
|
|
69
|
+
* @param filePath - Path to append to
|
|
70
|
+
* @param content - Content to append
|
|
71
|
+
* @param mode - Unix permission mode (default: 0o600)
|
|
72
|
+
*/
|
|
73
|
+
export declare function appendFileSecure(filePath: string, content: string | Buffer, mode?: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* Get platform information for logging/debugging
|
|
76
|
+
*/
|
|
77
|
+
export declare function getPlatformInfo(): {
|
|
78
|
+
platform: string;
|
|
79
|
+
isWindows: boolean;
|
|
80
|
+
isMacOS: boolean;
|
|
81
|
+
isLinux: boolean;
|
|
82
|
+
supportsUnixPermissions: boolean;
|
|
83
|
+
supportsWindowsACLs: boolean;
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=file-permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-permissions.d.ts","sourceRoot":"","sources":["../../src/utils/file-permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH;;GAEG;AACH,eAAO,MAAM,SAAS,SAA+B,CAAC;AACtD,eAAO,MAAM,OAAO,SAAgC,CAAC;AACrD,eAAO,MAAM,OAAO,SAA+B,CAAC;AACpD,eAAO,MAAM,MAAM,SAAa,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B,wDAAwD;;IAExD,+DAA+D;;IAE/D,iEAAiE;;IAEjE,yEAAyE;;CAEjE,CAAC;AAEX;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,MAA0C,GAC/C,OAAO,CAYT;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,MAAoC,GACzC,OAAO,CAYT;AAqCD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAoC,GAAG,IAAI,CAU7F;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,IAAI,GAAE,MAA0C,GAC/C,IAAI,CAYN;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,IAAI,GAAE,MAA0C,GAC/C,IAAI,CAQN;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,uBAAuB,EAAE,OAAO,CAAC;IACjC,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CASA"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-Platform File Permissions Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides secure file permission handling across Linux, macOS, and Windows.
|
|
5
|
+
*
|
|
6
|
+
* On Unix systems (Linux/macOS):
|
|
7
|
+
* - Uses standard chmod-style permissions (0o600, 0o700, etc.)
|
|
8
|
+
*
|
|
9
|
+
* On Windows:
|
|
10
|
+
* - Uses icacls to restrict file access to current user only
|
|
11
|
+
* - Falls back gracefully if icacls fails
|
|
12
|
+
*
|
|
13
|
+
* Added by Pantheon Security for cross-platform support.
|
|
14
|
+
*/
|
|
15
|
+
import fs from "fs";
|
|
16
|
+
import path from "path";
|
|
17
|
+
import { execSync } from "child_process";
|
|
18
|
+
/**
|
|
19
|
+
* Platform detection
|
|
20
|
+
*/
|
|
21
|
+
export const isWindows = process.platform === "win32";
|
|
22
|
+
export const isMacOS = process.platform === "darwin";
|
|
23
|
+
export const isLinux = process.platform === "linux";
|
|
24
|
+
export const isUnix = !isWindows;
|
|
25
|
+
/**
|
|
26
|
+
* Common permission modes (Unix-style)
|
|
27
|
+
*/
|
|
28
|
+
export const PERMISSION_MODES = {
|
|
29
|
+
/** Owner read/write only (files with sensitive data) */
|
|
30
|
+
OWNER_READ_WRITE: 0o600,
|
|
31
|
+
/** Owner read/write/execute only (directories, executables) */
|
|
32
|
+
OWNER_FULL: 0o700,
|
|
33
|
+
/** Owner read/write, group/others read (less sensitive files) */
|
|
34
|
+
OWNER_WRITE_ALL_READ: 0o644,
|
|
35
|
+
/** Owner full, group/others read+execute (less sensitive directories) */
|
|
36
|
+
OWNER_FULL_ALL_READ_EXECUTE: 0o755,
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Set secure file permissions (owner-only access)
|
|
40
|
+
*
|
|
41
|
+
* @param filePath - Path to the file
|
|
42
|
+
* @param mode - Unix permission mode (default: 0o600)
|
|
43
|
+
* @returns true if permissions were set successfully
|
|
44
|
+
*/
|
|
45
|
+
export function setSecureFilePermissions(filePath, mode = PERMISSION_MODES.OWNER_READ_WRITE) {
|
|
46
|
+
try {
|
|
47
|
+
if (isWindows) {
|
|
48
|
+
return setWindowsFilePermissions(filePath, true);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
fs.chmodSync(filePath, mode);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Silently fail - permissions are best-effort on some systems
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Set secure directory permissions (owner-only access)
|
|
62
|
+
*
|
|
63
|
+
* @param dirPath - Path to the directory
|
|
64
|
+
* @param mode - Unix permission mode (default: 0o700)
|
|
65
|
+
* @returns true if permissions were set successfully
|
|
66
|
+
*/
|
|
67
|
+
export function setSecureDirectoryPermissions(dirPath, mode = PERMISSION_MODES.OWNER_FULL) {
|
|
68
|
+
try {
|
|
69
|
+
if (isWindows) {
|
|
70
|
+
return setWindowsFilePermissions(dirPath, true);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
fs.chmodSync(dirPath, mode);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Silently fail - permissions are best-effort on some systems
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Set Windows file/directory permissions using icacls
|
|
84
|
+
*
|
|
85
|
+
* @param targetPath - Path to the file or directory
|
|
86
|
+
* @param ownerOnly - If true, restrict to current user only
|
|
87
|
+
* @returns true if permissions were set successfully
|
|
88
|
+
*/
|
|
89
|
+
function setWindowsFilePermissions(targetPath, ownerOnly) {
|
|
90
|
+
if (!isWindows)
|
|
91
|
+
return false;
|
|
92
|
+
try {
|
|
93
|
+
const username = process.env.USERNAME || process.env.USER;
|
|
94
|
+
if (!username) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (ownerOnly) {
|
|
98
|
+
// Remove inherited permissions and grant full control only to current user
|
|
99
|
+
// /inheritance:r - Remove inherited ACLs
|
|
100
|
+
// /grant:r - Replace existing permissions with specified ones
|
|
101
|
+
// (F) - Full control
|
|
102
|
+
execSync(`icacls "${targetPath}" /inheritance:r /grant:r "${username}:(F)" /q`, { stdio: "pipe" });
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// icacls may not be available or may fail - this is not critical
|
|
108
|
+
// The file is still created, just without restricted permissions
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create a directory with secure permissions
|
|
114
|
+
*
|
|
115
|
+
* @param dirPath - Path to create
|
|
116
|
+
* @param mode - Unix permission mode (default: 0o700)
|
|
117
|
+
*/
|
|
118
|
+
export function mkdirSecure(dirPath, mode = PERMISSION_MODES.OWNER_FULL) {
|
|
119
|
+
if (!fs.existsSync(dirPath)) {
|
|
120
|
+
if (isWindows) {
|
|
121
|
+
// On Windows, create directory first then set permissions
|
|
122
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
123
|
+
setWindowsFilePermissions(dirPath, true);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
fs.mkdirSync(dirPath, { recursive: true, mode });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Write a file with secure permissions
|
|
132
|
+
*
|
|
133
|
+
* @param filePath - Path to write
|
|
134
|
+
* @param content - Content to write
|
|
135
|
+
* @param mode - Unix permission mode (default: 0o600)
|
|
136
|
+
*/
|
|
137
|
+
export function writeFileSecure(filePath, content, mode = PERMISSION_MODES.OWNER_READ_WRITE) {
|
|
138
|
+
// Ensure parent directory exists
|
|
139
|
+
const dir = path.dirname(filePath);
|
|
140
|
+
mkdirSecure(dir);
|
|
141
|
+
if (isWindows) {
|
|
142
|
+
// On Windows, write file first then set permissions
|
|
143
|
+
fs.writeFileSync(filePath, content);
|
|
144
|
+
setWindowsFilePermissions(filePath, true);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
fs.writeFileSync(filePath, content, { mode });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Append to a file with secure permissions
|
|
152
|
+
*
|
|
153
|
+
* @param filePath - Path to append to
|
|
154
|
+
* @param content - Content to append
|
|
155
|
+
* @param mode - Unix permission mode (default: 0o600)
|
|
156
|
+
*/
|
|
157
|
+
export function appendFileSecure(filePath, content, mode = PERMISSION_MODES.OWNER_READ_WRITE) {
|
|
158
|
+
if (!fs.existsSync(filePath)) {
|
|
159
|
+
// If file doesn't exist, create with secure permissions
|
|
160
|
+
writeFileSecure(filePath, content, mode);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
// File exists, just append (permissions already set)
|
|
164
|
+
fs.appendFileSync(filePath, content);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get platform information for logging/debugging
|
|
169
|
+
*/
|
|
170
|
+
export function getPlatformInfo() {
|
|
171
|
+
return {
|
|
172
|
+
platform: process.platform,
|
|
173
|
+
isWindows,
|
|
174
|
+
isMacOS,
|
|
175
|
+
isLinux,
|
|
176
|
+
supportsUnixPermissions: isUnix,
|
|
177
|
+
supportsWindowsACLs: isWindows,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=file-permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-permissions.js","sourceRoot":"","sources":["../../src/utils/file-permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AACtD,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACrD,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AACpD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,SAAS,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,wDAA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,CAAC;SAAM,CAAC;QACN,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAgB,EAChB,OAAwB,EACxB,OAAe,gBAAgB,CAAC,gBAAgB;IAEhD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,wDAAwD;QACxD,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;SAAM,CAAC;QACN,qDAAqD;QACrD,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAQ7B,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS;QACT,OAAO;QACP,OAAO;QACP,uBAAuB,EAAE,MAAM;QAC/B,mBAAmB,EAAE,SAAS;KAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-manager.d.ts","sourceRoot":"","sources":["../../src/utils/settings-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"settings-manager.d.ts","sourceRoot":"","sources":["../../src/utils/settings-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAG1D,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;AAE1D,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACtC;AA8BD,qBAAa,eAAe;IAC1B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAW;;IAQ3B;;OAEG;IACH,OAAO,CAAC,YAAY;IAiBpB;;OAEG;IACG,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAajE;;OAEG;IACH,oBAAoB,IAAI,QAAQ;IAmBhC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE;IAmBrC,eAAe,IAAI,MAAM;IAIzB,WAAW,IAAI,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;CAG7C"}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Handles persistent configuration for the NotebookLM MCP Server.
|
|
5
5
|
* Manages profiles, disabled tools, and environment variable overrides.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
import { existsSync, mkdirSync } from "fs";
|
|
7
|
+
import { existsSync, readFileSync } from "fs";
|
|
9
8
|
import path from "path";
|
|
10
9
|
import { CONFIG } from "../config.js";
|
|
11
10
|
import { log } from "./logger.js";
|
|
11
|
+
import { mkdirSecure, writeFileSecure, PERMISSION_MODES } from "./file-permissions.js";
|
|
12
12
|
const DEFAULT_SETTINGS = {
|
|
13
13
|
profile: "full",
|
|
14
14
|
disabledTools: [],
|
|
@@ -48,17 +48,12 @@ export class SettingsManager {
|
|
|
48
48
|
*/
|
|
49
49
|
loadSettings() {
|
|
50
50
|
try {
|
|
51
|
-
// Ensure config dir exists
|
|
51
|
+
// Ensure config dir exists with secure permissions
|
|
52
52
|
if (!existsSync(CONFIG.configDir)) {
|
|
53
|
-
|
|
53
|
+
mkdirSecure(CONFIG.configDir, PERMISSION_MODES.OWNER_FULL);
|
|
54
54
|
}
|
|
55
55
|
if (existsSync(this.settingsPath)) {
|
|
56
|
-
|
|
57
|
-
// but here we used async fs in imports. For simplicity in constructor,
|
|
58
|
-
// we'll assume the file is read when needed or require explicit init.
|
|
59
|
-
// Actually, to keep it simple, let's use require/import or readFileSync.
|
|
60
|
-
const fsSync = require("fs");
|
|
61
|
-
const data = fsSync.readFileSync(this.settingsPath, "utf-8");
|
|
56
|
+
const data = readFileSync(this.settingsPath, "utf-8");
|
|
62
57
|
return { ...DEFAULT_SETTINGS, ...JSON.parse(data) };
|
|
63
58
|
}
|
|
64
59
|
}
|
|
@@ -73,7 +68,7 @@ export class SettingsManager {
|
|
|
73
68
|
async saveSettings(newSettings) {
|
|
74
69
|
this.settings = { ...this.settings, ...newSettings };
|
|
75
70
|
try {
|
|
76
|
-
|
|
71
|
+
writeFileSecure(this.settingsPath, JSON.stringify(this.settings, null, 2), PERMISSION_MODES.OWNER_READ_WRITE);
|
|
77
72
|
}
|
|
78
73
|
catch (error) {
|
|
79
74
|
throw new Error(`Failed to save settings: ${error}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-manager.js","sourceRoot":"","sources":["../../src/utils/settings-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"settings-manager.js","sourceRoot":"","sources":["../../src/utils/settings-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAUvF,MAAM,gBAAgB,GAAa;IACjC,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,EAAE;CAClB,CAAC;AAEF,MAAM,QAAQ,GAAkC;IAC9C,OAAO,EAAE;QACP,cAAc;QACd,YAAY;QACZ,gBAAgB;QAChB,iBAAiB;QACjB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I,CAAC,oBAAoB,EAAE,CAAC;QAC/D,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEvC,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC5B,mEAAmE;YACnE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrE,OAAO,KAAK,CAAC;YACf,CAAC;YAED,kCAAkC;YAClC,IAAI,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtC,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,WAAW;QACT,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webhooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/webhooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook Configuration Types
|
|
3
|
+
*/
|
|
4
|
+
import type { EventType } from "../events/event-types.js";
|
|
5
|
+
export interface WebhookConfig {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
url: string;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
events: (EventType | "*")[];
|
|
11
|
+
format: "generic" | "slack" | "discord" | "teams";
|
|
12
|
+
secret?: string;
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
retryCount?: number;
|
|
15
|
+
retryDelayMs?: number;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
}
|
|
20
|
+
export interface WebhookDelivery {
|
|
21
|
+
id: string;
|
|
22
|
+
webhookId: string;
|
|
23
|
+
eventType: EventType;
|
|
24
|
+
timestamp: string;
|
|
25
|
+
success: boolean;
|
|
26
|
+
statusCode?: number;
|
|
27
|
+
error?: string;
|
|
28
|
+
attempts: number;
|
|
29
|
+
durationMs: number;
|
|
30
|
+
}
|
|
31
|
+
export interface WebhookStats {
|
|
32
|
+
totalDeliveries: number;
|
|
33
|
+
successCount: number;
|
|
34
|
+
failureCount: number;
|
|
35
|
+
lastDelivery?: string;
|
|
36
|
+
lastSuccess?: string;
|
|
37
|
+
lastFailure?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface AddWebhookInput {
|
|
40
|
+
name: string;
|
|
41
|
+
url: string;
|
|
42
|
+
events?: (EventType | "*")[];
|
|
43
|
+
format?: "generic" | "slack" | "discord" | "teams";
|
|
44
|
+
secret?: string;
|
|
45
|
+
headers?: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
export interface UpdateWebhookInput {
|
|
48
|
+
id: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
url?: string;
|
|
51
|
+
enabled?: boolean;
|
|
52
|
+
events?: (EventType | "*")[];
|
|
53
|
+
format?: "generic" | "slack" | "discord" | "teams";
|
|
54
|
+
secret?: string;
|
|
55
|
+
headers?: Record<string, string>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAA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AAG,GAAG,CAAC,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,CAAC,SAAS,GAAG,GAAG,CAAC,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook Dispatcher
|
|
3
|
+
*
|
|
4
|
+
* Delivers events to configured webhook endpoints with retry logic.
|
|
5
|
+
*/
|
|
6
|
+
import type { SystemEvent } from "../events/event-types.js";
|
|
7
|
+
import type { WebhookConfig, WebhookStats, AddWebhookInput, UpdateWebhookInput } from "./types.js";
|
|
8
|
+
export declare class WebhookDispatcher {
|
|
9
|
+
private storePath;
|
|
10
|
+
private store;
|
|
11
|
+
private unsubscribe;
|
|
12
|
+
private deliveryHistory;
|
|
13
|
+
private maxDeliveryHistory;
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Load webhooks from disk
|
|
17
|
+
*/
|
|
18
|
+
private loadStore;
|
|
19
|
+
/**
|
|
20
|
+
* Save webhooks to disk
|
|
21
|
+
*/
|
|
22
|
+
private saveStore;
|
|
23
|
+
/**
|
|
24
|
+
* Initialize webhooks from environment variables
|
|
25
|
+
*/
|
|
26
|
+
private initializeFromEnv;
|
|
27
|
+
/**
|
|
28
|
+
* Subscribe to all events
|
|
29
|
+
*/
|
|
30
|
+
private subscribeToEvents;
|
|
31
|
+
/**
|
|
32
|
+
* Dispatch an event to all matching webhooks
|
|
33
|
+
*/
|
|
34
|
+
dispatch(event: SystemEvent): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Check if webhook should receive this event type
|
|
37
|
+
*/
|
|
38
|
+
private shouldSend;
|
|
39
|
+
/**
|
|
40
|
+
* Send event with retry logic
|
|
41
|
+
*/
|
|
42
|
+
private sendWithRetry;
|
|
43
|
+
/**
|
|
44
|
+
* Format event payload for different platforms
|
|
45
|
+
*/
|
|
46
|
+
private formatPayload;
|
|
47
|
+
/**
|
|
48
|
+
* Format for Slack
|
|
49
|
+
*/
|
|
50
|
+
private formatSlack;
|
|
51
|
+
/**
|
|
52
|
+
* Format for Discord
|
|
53
|
+
*/
|
|
54
|
+
private formatDiscord;
|
|
55
|
+
/**
|
|
56
|
+
* Format for Microsoft Teams
|
|
57
|
+
*/
|
|
58
|
+
private formatTeams;
|
|
59
|
+
/**
|
|
60
|
+
* Get emoji for event type
|
|
61
|
+
*/
|
|
62
|
+
private getEmoji;
|
|
63
|
+
/**
|
|
64
|
+
* Get color for event type (Discord embed color)
|
|
65
|
+
*/
|
|
66
|
+
private getColor;
|
|
67
|
+
/**
|
|
68
|
+
* Get title for event
|
|
69
|
+
*/
|
|
70
|
+
private getTitle;
|
|
71
|
+
/**
|
|
72
|
+
* Get description for event
|
|
73
|
+
*/
|
|
74
|
+
private getDescription;
|
|
75
|
+
/**
|
|
76
|
+
* Sign payload with HMAC-SHA256
|
|
77
|
+
*/
|
|
78
|
+
private sign;
|
|
79
|
+
/**
|
|
80
|
+
* Record delivery for history
|
|
81
|
+
*/
|
|
82
|
+
private recordDelivery;
|
|
83
|
+
/**
|
|
84
|
+
* Add a new webhook
|
|
85
|
+
*/
|
|
86
|
+
addWebhook(input: AddWebhookInput): WebhookConfig;
|
|
87
|
+
/**
|
|
88
|
+
* Update a webhook
|
|
89
|
+
*/
|
|
90
|
+
updateWebhook(input: UpdateWebhookInput): WebhookConfig | null;
|
|
91
|
+
/**
|
|
92
|
+
* Remove a webhook
|
|
93
|
+
*/
|
|
94
|
+
removeWebhook(id: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* List all webhooks
|
|
97
|
+
*/
|
|
98
|
+
listWebhooks(): WebhookConfig[];
|
|
99
|
+
/**
|
|
100
|
+
* Get a specific webhook
|
|
101
|
+
*/
|
|
102
|
+
getWebhook(id: string): WebhookConfig | null;
|
|
103
|
+
/**
|
|
104
|
+
* Test a webhook
|
|
105
|
+
*/
|
|
106
|
+
testWebhook(id: string): Promise<{
|
|
107
|
+
success: boolean;
|
|
108
|
+
error?: string;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Get webhook statistics
|
|
112
|
+
*/
|
|
113
|
+
getStats(): WebhookStats;
|
|
114
|
+
/**
|
|
115
|
+
* Cleanup
|
|
116
|
+
*/
|
|
117
|
+
destroy(): void;
|
|
118
|
+
}
|
|
119
|
+
export declare function getWebhookDispatcher(): WebhookDispatcher;
|
|
120
|
+
//# sourceMappingURL=webhook-dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-dispatcher.d.ts","sourceRoot":"","sources":["../../src/webhooks/webhook-dispatcher.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EACV,aAAa,EAEb,YAAY,EACZ,eAAe,EACf,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAQpB,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,SAAS,C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