@objectstack/core 0.9.1 → 1.0.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/{ENHANCED_FEATURES.md → ADVANCED_FEATURES.md} +13 -13
- package/CHANGELOG.md +21 -0
- package/PHASE2_IMPLEMENTATION.md +388 -0
- package/README.md +12 -341
- package/REFACTORING_SUMMARY.md +40 -0
- package/dist/api-registry-plugin.test.js +23 -21
- package/dist/api-registry.test.js +2 -2
- package/dist/dependency-resolver.d.ts +62 -0
- package/dist/dependency-resolver.d.ts.map +1 -0
- package/dist/dependency-resolver.js +317 -0
- package/dist/dependency-resolver.test.d.ts +2 -0
- package/dist/dependency-resolver.test.d.ts.map +1 -0
- package/dist/dependency-resolver.test.js +241 -0
- package/dist/health-monitor.d.ts +65 -0
- package/dist/health-monitor.d.ts.map +1 -0
- package/dist/health-monitor.js +269 -0
- package/dist/health-monitor.test.d.ts +2 -0
- package/dist/health-monitor.test.d.ts.map +1 -0
- package/dist/health-monitor.test.js +68 -0
- package/dist/hot-reload.d.ts +79 -0
- package/dist/hot-reload.d.ts.map +1 -0
- package/dist/hot-reload.js +313 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/kernel-base.d.ts +2 -2
- package/dist/kernel-base.js +2 -2
- package/dist/kernel.d.ts +89 -31
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +430 -73
- package/dist/kernel.test.js +375 -122
- package/dist/lite-kernel.d.ts +55 -0
- package/dist/lite-kernel.d.ts.map +1 -0
- package/dist/lite-kernel.js +112 -0
- package/dist/lite-kernel.test.d.ts +2 -0
- package/dist/lite-kernel.test.d.ts.map +1 -0
- package/dist/lite-kernel.test.js +161 -0
- package/dist/logger.d.ts +2 -2
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +26 -7
- package/dist/plugin-loader.d.ts +15 -0
- package/dist/plugin-loader.d.ts.map +1 -1
- package/dist/plugin-loader.js +40 -10
- package/dist/plugin-loader.test.js +9 -0
- package/dist/security/index.d.ts +3 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +4 -0
- package/dist/security/permission-manager.d.ts +96 -0
- package/dist/security/permission-manager.d.ts.map +1 -0
- package/dist/security/permission-manager.js +235 -0
- package/dist/security/permission-manager.test.d.ts +2 -0
- package/dist/security/permission-manager.test.d.ts.map +1 -0
- package/dist/security/permission-manager.test.js +220 -0
- package/dist/security/plugin-permission-enforcer.d.ts +1 -1
- package/dist/security/sandbox-runtime.d.ts +115 -0
- package/dist/security/sandbox-runtime.d.ts.map +1 -0
- package/dist/security/sandbox-runtime.js +310 -0
- package/dist/security/security-scanner.d.ts +92 -0
- package/dist/security/security-scanner.d.ts.map +1 -0
- package/dist/security/security-scanner.js +273 -0
- package/examples/{enhanced-kernel-example.ts → kernel-features-example.ts} +6 -6
- package/examples/phase2-integration.ts +355 -0
- package/package.json +3 -2
- package/src/api-registry-plugin.test.ts +23 -21
- package/src/api-registry.test.ts +2 -2
- package/src/dependency-resolver.test.ts +287 -0
- package/src/dependency-resolver.ts +388 -0
- package/src/health-monitor.test.ts +81 -0
- package/src/health-monitor.ts +316 -0
- package/src/hot-reload.ts +388 -0
- package/src/index.ts +6 -1
- package/src/kernel-base.ts +2 -2
- package/src/kernel.test.ts +471 -134
- package/src/kernel.ts +518 -76
- package/src/lite-kernel.test.ts +200 -0
- package/src/lite-kernel.ts +135 -0
- package/src/logger.ts +28 -7
- package/src/plugin-loader.test.ts +10 -1
- package/src/plugin-loader.ts +49 -13
- package/src/security/index.ts +19 -0
- package/src/security/permission-manager.test.ts +256 -0
- package/src/security/permission-manager.ts +336 -0
- package/src/security/plugin-permission-enforcer.test.ts +1 -1
- package/src/security/plugin-permission-enforcer.ts +1 -1
- package/src/security/sandbox-runtime.ts +432 -0
- package/src/security/security-scanner.ts +365 -0
- package/dist/enhanced-kernel.d.ts +0 -103
- package/dist/enhanced-kernel.d.ts.map +0 -1
- package/dist/enhanced-kernel.js +0 -403
- package/dist/enhanced-kernel.test.d.ts +0 -2
- package/dist/enhanced-kernel.test.d.ts.map +0 -1
- package/dist/enhanced-kernel.test.js +0 -412
- package/src/enhanced-kernel.test.ts +0 -535
- package/src/enhanced-kernel.ts +0 -496
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createLogger } from './logger.js';
|
|
2
|
+
import { ObjectKernelBase } from './kernel-base.js';
|
|
3
|
+
/**
|
|
4
|
+
* ObjectKernel - MiniKernel Architecture
|
|
5
|
+
*
|
|
6
|
+
* A highly modular, plugin-based microkernel that:
|
|
7
|
+
* - Manages plugin lifecycle (init, start, destroy)
|
|
8
|
+
* - Provides dependency injection via service registry
|
|
9
|
+
* - Implements event/hook system for inter-plugin communication
|
|
10
|
+
* - Handles dependency resolution (topological sort)
|
|
11
|
+
* - Provides configurable logging for server and browser
|
|
12
|
+
*
|
|
13
|
+
* Core philosophy:
|
|
14
|
+
* - Business logic is completely separated into plugins
|
|
15
|
+
* - Kernel only manages lifecycle, DI, and hooks
|
|
16
|
+
* - Plugins are loaded as equal building blocks
|
|
17
|
+
*/
|
|
18
|
+
export class LiteKernel extends ObjectKernelBase {
|
|
19
|
+
constructor(config) {
|
|
20
|
+
const logger = createLogger(config?.logger);
|
|
21
|
+
super(logger);
|
|
22
|
+
// Initialize context after logger is created
|
|
23
|
+
this.context = this.createContext();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Register a plugin
|
|
27
|
+
* @param plugin - Plugin instance
|
|
28
|
+
*/
|
|
29
|
+
use(plugin) {
|
|
30
|
+
this.validateIdle();
|
|
31
|
+
const pluginName = plugin.name;
|
|
32
|
+
if (this.plugins.has(pluginName)) {
|
|
33
|
+
throw new Error(`[Kernel] Plugin '${pluginName}' already registered`);
|
|
34
|
+
}
|
|
35
|
+
this.plugins.set(pluginName, plugin);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Bootstrap the kernel
|
|
40
|
+
* 1. Resolve dependencies (topological sort)
|
|
41
|
+
* 2. Init phase - plugins register services
|
|
42
|
+
* 3. Start phase - plugins execute business logic
|
|
43
|
+
* 4. Trigger 'kernel:ready' hook
|
|
44
|
+
*/
|
|
45
|
+
async bootstrap() {
|
|
46
|
+
this.validateState('idle');
|
|
47
|
+
this.state = 'initializing';
|
|
48
|
+
this.logger.info('Bootstrap started');
|
|
49
|
+
// Resolve dependencies
|
|
50
|
+
const orderedPlugins = this.resolveDependencies();
|
|
51
|
+
// Phase 1: Init - Plugins register services
|
|
52
|
+
this.logger.info('Phase 1: Init plugins');
|
|
53
|
+
for (const plugin of orderedPlugins) {
|
|
54
|
+
await this.runPluginInit(plugin);
|
|
55
|
+
}
|
|
56
|
+
// Phase 2: Start - Plugins execute business logic
|
|
57
|
+
this.logger.info('Phase 2: Start plugins');
|
|
58
|
+
this.state = 'running';
|
|
59
|
+
for (const plugin of orderedPlugins) {
|
|
60
|
+
await this.runPluginStart(plugin);
|
|
61
|
+
}
|
|
62
|
+
// Trigger ready hook
|
|
63
|
+
await this.triggerHook('kernel:ready');
|
|
64
|
+
this.logger.info('✅ Bootstrap complete', {
|
|
65
|
+
pluginCount: this.plugins.size
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Shutdown the kernel
|
|
70
|
+
* Calls destroy on all plugins in reverse order
|
|
71
|
+
*/
|
|
72
|
+
async shutdown() {
|
|
73
|
+
await this.destroy();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Graceful shutdown - destroy all plugins in reverse order
|
|
77
|
+
*/
|
|
78
|
+
async destroy() {
|
|
79
|
+
if (this.state === 'stopped') {
|
|
80
|
+
this.logger.warn('Kernel already stopped');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.state = 'stopping';
|
|
84
|
+
this.logger.info('Shutdown started');
|
|
85
|
+
// Trigger shutdown hook
|
|
86
|
+
await this.triggerHook('kernel:shutdown');
|
|
87
|
+
// Destroy plugins in reverse order
|
|
88
|
+
const orderedPlugins = this.resolveDependencies();
|
|
89
|
+
for (const plugin of orderedPlugins.reverse()) {
|
|
90
|
+
await this.runPluginDestroy(plugin);
|
|
91
|
+
}
|
|
92
|
+
this.state = 'stopped';
|
|
93
|
+
this.logger.info('✅ Shutdown complete');
|
|
94
|
+
// Cleanup logger resources
|
|
95
|
+
if (this.logger && typeof this.logger.destroy === 'function') {
|
|
96
|
+
await this.logger.destroy();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get a service from the registry
|
|
101
|
+
* Convenience method for external access
|
|
102
|
+
*/
|
|
103
|
+
getService(name) {
|
|
104
|
+
return this.context.getService(name);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Check if kernel is running
|
|
108
|
+
*/
|
|
109
|
+
isRunning() {
|
|
110
|
+
return this.state === 'running';
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lite-kernel.test.d.ts","sourceRoot":"","sources":["../src/lite-kernel.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
+
import { LiteKernel } from './lite-kernel';
|
|
3
|
+
describe('LiteKernel with Configurable Logger', () => {
|
|
4
|
+
let kernel;
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
kernel = new LiteKernel();
|
|
7
|
+
});
|
|
8
|
+
describe('Logger Configuration', () => {
|
|
9
|
+
it('should create kernel with default logger', () => {
|
|
10
|
+
expect(kernel).toBeDefined();
|
|
11
|
+
});
|
|
12
|
+
it('should create kernel with custom logger config', async () => {
|
|
13
|
+
const customKernel = new LiteKernel({
|
|
14
|
+
logger: {
|
|
15
|
+
level: 'debug',
|
|
16
|
+
format: 'pretty',
|
|
17
|
+
sourceLocation: true
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
expect(customKernel).toBeDefined();
|
|
21
|
+
// Cleanup
|
|
22
|
+
await customKernel.bootstrap();
|
|
23
|
+
await customKernel.shutdown();
|
|
24
|
+
});
|
|
25
|
+
it('should create kernel with file logging config', async () => {
|
|
26
|
+
const fileKernel = new LiteKernel({
|
|
27
|
+
logger: {
|
|
28
|
+
level: 'info',
|
|
29
|
+
format: 'json',
|
|
30
|
+
file: '/tmp/test-kernel.log'
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
expect(fileKernel).toBeDefined();
|
|
34
|
+
// Cleanup
|
|
35
|
+
await fileKernel.bootstrap();
|
|
36
|
+
await fileKernel.shutdown();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe('Plugin Context Logger', () => {
|
|
40
|
+
it('should provide logger to plugins', async () => {
|
|
41
|
+
let loggerReceived = false;
|
|
42
|
+
const testPlugin = {
|
|
43
|
+
name: 'test-plugin',
|
|
44
|
+
init: async (ctx) => {
|
|
45
|
+
if (ctx.logger) {
|
|
46
|
+
loggerReceived = true;
|
|
47
|
+
ctx.logger.info('Plugin initialized', { plugin: 'test-plugin' });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
kernel.use(testPlugin);
|
|
52
|
+
await kernel.bootstrap();
|
|
53
|
+
expect(loggerReceived).toBe(true);
|
|
54
|
+
await kernel.shutdown();
|
|
55
|
+
});
|
|
56
|
+
it('should allow plugins to use all log levels', async () => {
|
|
57
|
+
const logCalls = [];
|
|
58
|
+
const loggingPlugin = {
|
|
59
|
+
name: 'logging-plugin',
|
|
60
|
+
init: async (ctx) => {
|
|
61
|
+
ctx.logger.debug('Debug message');
|
|
62
|
+
logCalls.push('debug');
|
|
63
|
+
ctx.logger.info('Info message');
|
|
64
|
+
logCalls.push('info');
|
|
65
|
+
ctx.logger.warn('Warning message');
|
|
66
|
+
logCalls.push('warn');
|
|
67
|
+
ctx.logger.error('Error message');
|
|
68
|
+
logCalls.push('error');
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
kernel.use(loggingPlugin);
|
|
72
|
+
await kernel.bootstrap();
|
|
73
|
+
expect(logCalls).toContain('debug');
|
|
74
|
+
expect(logCalls).toContain('info');
|
|
75
|
+
expect(logCalls).toContain('warn');
|
|
76
|
+
expect(logCalls).toContain('error');
|
|
77
|
+
await kernel.shutdown();
|
|
78
|
+
});
|
|
79
|
+
it('should support metadata in logs', async () => {
|
|
80
|
+
const metadataPlugin = {
|
|
81
|
+
name: 'metadata-plugin',
|
|
82
|
+
init: async (ctx) => {
|
|
83
|
+
ctx.logger.info('User action', {
|
|
84
|
+
userId: '123',
|
|
85
|
+
action: 'create',
|
|
86
|
+
resource: 'document'
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
kernel.use(metadataPlugin);
|
|
91
|
+
await kernel.bootstrap();
|
|
92
|
+
await kernel.shutdown();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe('Kernel Lifecycle Logging', () => {
|
|
96
|
+
it('should log bootstrap process', async () => {
|
|
97
|
+
const plugin = {
|
|
98
|
+
name: 'lifecycle-test',
|
|
99
|
+
init: async () => {
|
|
100
|
+
// Init logic
|
|
101
|
+
},
|
|
102
|
+
start: async () => {
|
|
103
|
+
// Start logic
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
kernel.use(plugin);
|
|
107
|
+
await kernel.bootstrap();
|
|
108
|
+
expect(kernel.isRunning()).toBe(true);
|
|
109
|
+
await kernel.shutdown();
|
|
110
|
+
});
|
|
111
|
+
it('should log shutdown process', async () => {
|
|
112
|
+
const plugin = {
|
|
113
|
+
name: 'shutdown-test',
|
|
114
|
+
init: async () => { },
|
|
115
|
+
destroy: async () => {
|
|
116
|
+
// Cleanup
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
kernel.use(plugin);
|
|
120
|
+
await kernel.bootstrap();
|
|
121
|
+
await kernel.shutdown();
|
|
122
|
+
expect(kernel.getState()).toBe('stopped');
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
describe('Environment Compatibility', () => {
|
|
126
|
+
it('should work in Node.js environment', async () => {
|
|
127
|
+
const nodeKernel = new LiteKernel({
|
|
128
|
+
logger: {
|
|
129
|
+
level: 'info',
|
|
130
|
+
format: 'json'
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
const plugin = {
|
|
134
|
+
name: 'node-test',
|
|
135
|
+
init: async (ctx) => {
|
|
136
|
+
ctx.logger.info('Running in Node.js');
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
nodeKernel.use(plugin);
|
|
140
|
+
await nodeKernel.bootstrap();
|
|
141
|
+
await nodeKernel.shutdown();
|
|
142
|
+
});
|
|
143
|
+
it('should support browser-friendly logging', async () => {
|
|
144
|
+
const browserKernel = new LiteKernel({
|
|
145
|
+
logger: {
|
|
146
|
+
level: 'info',
|
|
147
|
+
format: 'pretty'
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const plugin = {
|
|
151
|
+
name: 'browser-test',
|
|
152
|
+
init: async (ctx) => {
|
|
153
|
+
ctx.logger.info('Browser-friendly format');
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
browserKernel.use(plugin);
|
|
157
|
+
await browserKernel.bootstrap();
|
|
158
|
+
await browserKernel.shutdown();
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
package/dist/logger.d.ts
CHANGED
|
@@ -44,8 +44,8 @@ export declare class ObjectLogger implements Logger {
|
|
|
44
44
|
debug(message: string, meta?: Record<string, any>): void;
|
|
45
45
|
info(message: string, meta?: Record<string, any>): void;
|
|
46
46
|
warn(message: string, meta?: Record<string, any>): void;
|
|
47
|
-
error(message: string,
|
|
48
|
-
fatal(message: string,
|
|
47
|
+
error(message: string, errorOrMeta?: Error | Record<string, any>, meta?: Record<string, any>): void;
|
|
48
|
+
fatal(message: string, errorOrMeta?: Error | Record<string, any>, meta?: Record<string, any>): void;
|
|
49
49
|
/**
|
|
50
50
|
* Create a child logger with additional context
|
|
51
51
|
* Note: Child loggers share the parent's Pino instance
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACH,qBAAa,YAAa,YAAW,MAAM;IACvC,OAAO,CAAC,MAAM,CAAkJ;IAChK,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,UAAU,CAAC,CAAM;IACzB,OAAO,CAAC,YAAY,CAAC,CAAM;IAC3B,OAAO,CAAC,OAAO,CAAC,CAAM;gBAEV,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM;IAwB9C;;OAEG;IACH,OAAO,CAAC,cAAc;IAuGtB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;OAEG;IACH,OAAO,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACH,qBAAa,YAAa,YAAW,MAAM;IACvC,OAAO,CAAC,MAAM,CAAkJ;IAChK,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,UAAU,CAAC,CAAM;IACzB,OAAO,CAAC,YAAY,CAAC,CAAM;IAC3B,OAAO,CAAC,OAAO,CAAC,CAAM;gBAEV,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM;IAwB9C;;OAEG;IACH,OAAO,CAAC,cAAc;IAuGtB;;OA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AC,GAAG,YAAY,CAEzE"}
|
package/dist/logger.js
CHANGED
|
@@ -179,7 +179,8 @@ export class ObjectLogger {
|
|
|
179
179
|
info: '\x1b[32m', // Green
|
|
180
180
|
warn: '\x1b[33m', // Yellow
|
|
181
181
|
error: '\x1b[31m', // Red
|
|
182
|
-
fatal: '\x1b[35m' // Magenta
|
|
182
|
+
fatal: '\x1b[35m', // Magenta
|
|
183
|
+
silent: ''
|
|
183
184
|
};
|
|
184
185
|
const reset = '\x1b[0m';
|
|
185
186
|
const color = levelColors[level] || '';
|
|
@@ -230,22 +231,40 @@ export class ObjectLogger {
|
|
|
230
231
|
this.logBrowser('warn', message, meta);
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
|
-
error(message,
|
|
234
|
+
error(message, errorOrMeta, meta) {
|
|
235
|
+
let error;
|
|
236
|
+
let context = {};
|
|
237
|
+
if (errorOrMeta instanceof Error) {
|
|
238
|
+
error = errorOrMeta;
|
|
239
|
+
context = meta || {};
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
context = errorOrMeta || {};
|
|
243
|
+
}
|
|
234
244
|
if (this.isNode && this.pinoLogger) {
|
|
235
|
-
const errorContext = error ? { err: error, ...
|
|
245
|
+
const errorContext = error ? { err: error, ...context } : context;
|
|
236
246
|
this.pinoLogger.error(errorContext, message);
|
|
237
247
|
}
|
|
238
248
|
else {
|
|
239
|
-
this.logBrowser('error', message,
|
|
249
|
+
this.logBrowser('error', message, context, error);
|
|
240
250
|
}
|
|
241
251
|
}
|
|
242
|
-
fatal(message,
|
|
252
|
+
fatal(message, errorOrMeta, meta) {
|
|
253
|
+
let error;
|
|
254
|
+
let context = {};
|
|
255
|
+
if (errorOrMeta instanceof Error) {
|
|
256
|
+
error = errorOrMeta;
|
|
257
|
+
context = meta || {};
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
context = errorOrMeta || {};
|
|
261
|
+
}
|
|
243
262
|
if (this.isNode && this.pinoLogger) {
|
|
244
|
-
const errorContext = error ? { err: error, ...
|
|
263
|
+
const errorContext = error ? { err: error, ...context } : context;
|
|
245
264
|
this.pinoLogger.fatal(errorContext, message);
|
|
246
265
|
}
|
|
247
266
|
else {
|
|
248
|
-
this.logBrowser('fatal', message,
|
|
267
|
+
this.logBrowser('fatal', message, context, error);
|
|
249
268
|
}
|
|
250
269
|
}
|
|
251
270
|
/**
|
package/dist/plugin-loader.d.ts
CHANGED
|
@@ -96,11 +96,22 @@ export interface VersionCompatibility {
|
|
|
96
96
|
*/
|
|
97
97
|
export declare class PluginLoader {
|
|
98
98
|
private logger;
|
|
99
|
+
private context?;
|
|
100
|
+
private configValidator;
|
|
99
101
|
private loadedPlugins;
|
|
100
102
|
private serviceFactories;
|
|
101
103
|
private serviceInstances;
|
|
102
104
|
private scopedServices;
|
|
105
|
+
private creating;
|
|
103
106
|
constructor(logger: Logger);
|
|
107
|
+
/**
|
|
108
|
+
* Set the plugin context for service factories
|
|
109
|
+
*/
|
|
110
|
+
setContext(context: PluginContext): void;
|
|
111
|
+
/**
|
|
112
|
+
* Get a synchronous service instance if it exists (Sync Helper)
|
|
113
|
+
*/
|
|
114
|
+
getServiceInstance<T>(name: string): T | undefined;
|
|
104
115
|
/**
|
|
105
116
|
* Load a plugin asynchronously with validation
|
|
106
117
|
*/
|
|
@@ -117,6 +128,10 @@ export declare class PluginLoader {
|
|
|
117
128
|
* Register a static service instance (legacy support)
|
|
118
129
|
*/
|
|
119
130
|
registerService(name: string, service: any): void;
|
|
131
|
+
/**
|
|
132
|
+
* Check if a service is registered (either as instance or factory)
|
|
133
|
+
*/
|
|
134
|
+
hasService(name: string): boolean;
|
|
120
135
|
/**
|
|
121
136
|
* Detect circular dependencies in service factories
|
|
122
137
|
* Note: This only detects cycles in service dependencies, not plugin dependencies.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-loader.d.ts","sourceRoot":"","sources":["../src/plugin-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM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types
|
|
3
4
|
* Defines how services are instantiated and managed
|
|
@@ -21,7 +22,21 @@ export class PluginLoader {
|
|
|
21
22
|
this.serviceFactories = new Map();
|
|
22
23
|
this.serviceInstances = new Map();
|
|
23
24
|
this.scopedServices = new Map();
|
|
25
|
+
this.creating = new Set();
|
|
24
26
|
this.logger = logger;
|
|
27
|
+
this.configValidator = new PluginConfigValidator(logger);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Set the plugin context for service factories
|
|
31
|
+
*/
|
|
32
|
+
setContext(context) {
|
|
33
|
+
this.context = context;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get a synchronous service instance if it exists (Sync Helper)
|
|
37
|
+
*/
|
|
38
|
+
getServiceInstance(name) {
|
|
39
|
+
return this.serviceInstances.get(name);
|
|
25
40
|
}
|
|
26
41
|
/**
|
|
27
42
|
* Load a plugin asynchronously with validation
|
|
@@ -112,6 +127,12 @@ export class PluginLoader {
|
|
|
112
127
|
}
|
|
113
128
|
this.serviceInstances.set(name, service);
|
|
114
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Check if a service is registered (either as instance or factory)
|
|
132
|
+
*/
|
|
133
|
+
hasService(name) {
|
|
134
|
+
return this.serviceInstances.has(name) || this.serviceFactories.has(name);
|
|
135
|
+
}
|
|
115
136
|
/**
|
|
116
137
|
* Detect circular dependencies in service factories
|
|
117
138
|
* Note: This only detects cycles in service dependencies, not plugin dependencies.
|
|
@@ -234,14 +255,14 @@ export class PluginLoader {
|
|
|
234
255
|
if (!plugin.configSchema) {
|
|
235
256
|
return;
|
|
236
257
|
}
|
|
237
|
-
if (
|
|
238
|
-
|
|
258
|
+
if (config === undefined) {
|
|
259
|
+
// In loadPlugin, we often don't have the config yet.
|
|
260
|
+
// We skip validation here or valid against empty object if schema allows?
|
|
261
|
+
// For now, let's keep the logging behavior but note it's delegating
|
|
262
|
+
this.logger.debug(`Plugin ${plugin.name} has configuration schema (config validation postponed)`);
|
|
239
263
|
return;
|
|
240
264
|
}
|
|
241
|
-
|
|
242
|
-
// This is a placeholder that logs the validation would happen
|
|
243
|
-
// The actual validation should be done by the caller when config is available
|
|
244
|
-
this.logger.debug(`Plugin ${plugin.name} has configuration schema (use PluginConfigValidator for validation)`);
|
|
265
|
+
this.configValidator.validatePluginConfig(plugin, config);
|
|
245
266
|
}
|
|
246
267
|
async verifyPluginSignature(plugin) {
|
|
247
268
|
if (!plugin.signature) {
|
|
@@ -281,9 +302,18 @@ export class PluginLoader {
|
|
|
281
302
|
return instance;
|
|
282
303
|
}
|
|
283
304
|
async createServiceInstance(registration) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
305
|
+
if (!this.context) {
|
|
306
|
+
throw new Error(`[PluginLoader] Context not set - cannot create service '${registration.name}'`);
|
|
307
|
+
}
|
|
308
|
+
if (this.creating.has(registration.name)) {
|
|
309
|
+
throw new Error(`Circular dependency detected: ${Array.from(this.creating).join(' -> ')} -> ${registration.name}`);
|
|
310
|
+
}
|
|
311
|
+
this.creating.add(registration.name);
|
|
312
|
+
try {
|
|
313
|
+
return await registration.factory(this.context);
|
|
314
|
+
}
|
|
315
|
+
finally {
|
|
316
|
+
this.creating.delete(registration.name);
|
|
317
|
+
}
|
|
288
318
|
}
|
|
289
319
|
}
|
|
@@ -6,6 +6,15 @@ describe('PluginLoader', () => {
|
|
|
6
6
|
beforeEach(() => {
|
|
7
7
|
const logger = createLogger({ level: 'error' }); // Suppress logs in tests
|
|
8
8
|
loader = new PluginLoader(logger);
|
|
9
|
+
loader.setContext({
|
|
10
|
+
registerService: () => { },
|
|
11
|
+
getService: () => { throw new Error('Mock service not found'); },
|
|
12
|
+
hook: () => { },
|
|
13
|
+
trigger: async () => { },
|
|
14
|
+
getServices: () => new Map(),
|
|
15
|
+
logger: logger,
|
|
16
|
+
getKernel: () => ({})
|
|
17
|
+
});
|
|
9
18
|
});
|
|
10
19
|
describe('Plugin Loading', () => {
|
|
11
20
|
it('should load a valid plugin', async () => {
|
package/dist/security/index.d.ts
CHANGED
|
@@ -11,4 +11,7 @@
|
|
|
11
11
|
export { PluginSignatureVerifier, type PluginSignatureConfig, type SignatureVerificationResult, } from './plugin-signature-verifier.js';
|
|
12
12
|
export { PluginConfigValidator, createPluginConfigValidator, } from './plugin-config-validator.js';
|
|
13
13
|
export { PluginPermissionEnforcer, SecurePluginContext, createPluginPermissionEnforcer, type PluginPermissions, type PermissionCheckResult, } from './plugin-permission-enforcer.js';
|
|
14
|
+
export { PluginPermissionManager, type PermissionGrant, type PermissionCheckResult as PluginPermissionCheckResult, } from './permission-manager.js';
|
|
15
|
+
export { PluginSandboxRuntime, type SandboxContext, type ResourceUsage, } from './sandbox-runtime.js';
|
|
16
|
+
export { PluginSecurityScanner, type ScanTarget, type SecurityIssue, } from './security-scanner.js';
|
|
14
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,GACjC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,8BAA8B,EAC9B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,GACjC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,8BAA8B,EAC9B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,qBAAqB,IAAI,2BAA2B,GAC1D,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,qBAAqB,EACrB,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC"}
|
package/dist/security/index.js
CHANGED
|
@@ -11,3 +11,7 @@
|
|
|
11
11
|
export { PluginSignatureVerifier, } from './plugin-signature-verifier.js';
|
|
12
12
|
export { PluginConfigValidator, createPluginConfigValidator, } from './plugin-config-validator.js';
|
|
13
13
|
export { PluginPermissionEnforcer, SecurePluginContext, createPluginPermissionEnforcer, } from './plugin-permission-enforcer.js';
|
|
14
|
+
// Advanced security components (Phase 2)
|
|
15
|
+
export { PluginPermissionManager, } from './permission-manager.js';
|
|
16
|
+
export { PluginSandboxRuntime, } from './sandbox-runtime.js';
|
|
17
|
+
export { PluginSecurityScanner, } from './security-scanner.js';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Permission, PermissionSet, PermissionAction, ResourceType } from '@objectstack/spec/kernel';
|
|
2
|
+
import type { ObjectLogger } from '../logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* Permission Grant
|
|
5
|
+
* Represents a granted permission at runtime
|
|
6
|
+
*/
|
|
7
|
+
export interface PermissionGrant {
|
|
8
|
+
permissionId: string;
|
|
9
|
+
pluginId: string;
|
|
10
|
+
grantedAt: Date;
|
|
11
|
+
grantedBy?: string;
|
|
12
|
+
expiresAt?: Date;
|
|
13
|
+
conditions?: Record<string, any>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Permission Check Result
|
|
17
|
+
*/
|
|
18
|
+
export interface PermissionCheckResult {
|
|
19
|
+
allowed: boolean;
|
|
20
|
+
reason?: string;
|
|
21
|
+
requiredPermission?: string;
|
|
22
|
+
grantedPermissions?: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Plugin Permission Manager
|
|
26
|
+
*
|
|
27
|
+
* Manages fine-grained permissions for plugin security and access control
|
|
28
|
+
*/
|
|
29
|
+
export declare class PluginPermissionManager {
|
|
30
|
+
private logger;
|
|
31
|
+
private permissionSets;
|
|
32
|
+
private grants;
|
|
33
|
+
private grantDetails;
|
|
34
|
+
constructor(logger: ObjectLogger);
|
|
35
|
+
/**
|
|
36
|
+
* Register permission requirements for a plugin
|
|
37
|
+
*/
|
|
38
|
+
registerPermissions(pluginId: string, permissionSet: PermissionSet): void;
|
|
39
|
+
/**
|
|
40
|
+
* Grant a permission to a plugin
|
|
41
|
+
*/
|
|
42
|
+
grantPermission(pluginId: string, permissionId: string, grantedBy?: string, expiresAt?: Date): void;
|
|
43
|
+
/**
|
|
44
|
+
* Revoke a permission from a plugin
|
|
45
|
+
*/
|
|
46
|
+
revokePermission(pluginId: string, permissionId: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Grant all permissions for a plugin
|
|
49
|
+
*/
|
|
50
|
+
grantAllPermissions(pluginId: string, grantedBy?: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a plugin has a specific permission
|
|
53
|
+
*/
|
|
54
|
+
hasPermission(pluginId: string, permissionId: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Check if plugin can perform an action on a resource
|
|
57
|
+
*/
|
|
58
|
+
checkAccess(pluginId: string, resource: ResourceType, action: PermissionAction, resourceId?: string): PermissionCheckResult;
|
|
59
|
+
/**
|
|
60
|
+
* Get all permissions for a plugin
|
|
61
|
+
*/
|
|
62
|
+
getPluginPermissions(pluginId: string): Permission[];
|
|
63
|
+
/**
|
|
64
|
+
* Get granted permissions for a plugin
|
|
65
|
+
*/
|
|
66
|
+
getGrantedPermissions(pluginId: string): string[];
|
|
67
|
+
/**
|
|
68
|
+
* Get required but not granted permissions
|
|
69
|
+
*/
|
|
70
|
+
getMissingPermissions(pluginId: string): Permission[];
|
|
71
|
+
/**
|
|
72
|
+
* Check if all required permissions are granted
|
|
73
|
+
*/
|
|
74
|
+
hasAllRequiredPermissions(pluginId: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Get permission grant details
|
|
77
|
+
*/
|
|
78
|
+
getGrantDetails(pluginId: string, permissionId: string): PermissionGrant | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Validate permission against scope constraints
|
|
81
|
+
*/
|
|
82
|
+
validatePermissionScope(permission: Permission, context: {
|
|
83
|
+
tenantId?: string;
|
|
84
|
+
userId?: string;
|
|
85
|
+
resourceId?: string;
|
|
86
|
+
}): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Clear all permissions for a plugin
|
|
89
|
+
*/
|
|
90
|
+
clearPluginPermissions(pluginId: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* Shutdown permission manager
|
|
93
|
+
*/
|
|
94
|
+
shutdown(): void;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=permission-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-manager.d.ts","sourceRoot":"","sources":["../../src/security/permission-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,UAAU,CAAC,EAAE,MA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