mastercontroller 1.2.14 → 1.3.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.
- package/.claude/settings.local.json +2 -1
- package/MasterControl.js +150 -101
- package/MasterCors.js +29 -0
- package/MasterPipeline.js +344 -0
- package/MasterRouter.js +44 -22
- package/MasterSession.js +19 -0
- package/MasterTimeout.js +332 -0
- package/MasterTools.js +40 -13
- package/README.md +1632 -36
- package/docs/timeout-and-error-handling.md +712 -0
- package/error/MasterErrorRenderer.js +529 -0
- package/package.json +5 -5
- package/security/SecurityMiddleware.js +73 -1
- package/security/SessionSecurity.js +99 -2
|
@@ -25,8 +25,8 @@ class SessionSecurity {
|
|
|
25
25
|
this.domain = options.domain || null;
|
|
26
26
|
this.path = options.path || '/';
|
|
27
27
|
|
|
28
|
-
// Session fingerprinting
|
|
29
|
-
this.useFingerprint = options.useFingerprint
|
|
28
|
+
// Session fingerprinting (disabled by default like ASP.NET Core)
|
|
29
|
+
this.useFingerprint = options.useFingerprint === true;
|
|
30
30
|
|
|
31
31
|
// Start cleanup interval
|
|
32
32
|
this._startCleanup();
|
|
@@ -407,6 +407,103 @@ const SESSION_BEST_PRACTICES = {
|
|
|
407
407
|
}
|
|
408
408
|
};
|
|
409
409
|
|
|
410
|
+
// MasterController Integration
|
|
411
|
+
const master = require('../MasterControl');
|
|
412
|
+
|
|
413
|
+
// Create MasterController-compatible wrapper
|
|
414
|
+
class MasterSessionSecurity {
|
|
415
|
+
constructor() {
|
|
416
|
+
this._instance = null;
|
|
417
|
+
this._options = {};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Initialize session security (Rails/Django style)
|
|
422
|
+
* Auto-registers with middleware pipeline
|
|
423
|
+
*/
|
|
424
|
+
init(options = {}) {
|
|
425
|
+
this._options = options;
|
|
426
|
+
this._instance = new SessionSecurity(options);
|
|
427
|
+
|
|
428
|
+
// Auto-register with pipeline if available
|
|
429
|
+
if (master.pipeline) {
|
|
430
|
+
master.pipeline.use(this._instance.middleware());
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return this;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Get middleware function
|
|
438
|
+
*/
|
|
439
|
+
middleware() {
|
|
440
|
+
if (!this._instance) {
|
|
441
|
+
this.init();
|
|
442
|
+
}
|
|
443
|
+
return this._instance.middleware();
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Destroy session
|
|
448
|
+
*/
|
|
449
|
+
destroy(req, res) {
|
|
450
|
+
if (!this._instance) {
|
|
451
|
+
throw new Error('SessionSecurity not initialized. Call master.session.init() first.');
|
|
452
|
+
}
|
|
453
|
+
return this._instance.destroySession(req, res);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Get session by ID
|
|
458
|
+
*/
|
|
459
|
+
getSession(sessionId) {
|
|
460
|
+
if (!this._instance) {
|
|
461
|
+
throw new Error('SessionSecurity not initialized. Call master.session.init() first.');
|
|
462
|
+
}
|
|
463
|
+
return this._instance.getSession(sessionId);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Touch session (extend expiry)
|
|
468
|
+
*/
|
|
469
|
+
touch(sessionId) {
|
|
470
|
+
if (!this._instance) {
|
|
471
|
+
throw new Error('SessionSecurity not initialized. Call master.session.init() first.');
|
|
472
|
+
}
|
|
473
|
+
return this._instance.touch(sessionId);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Get session count (monitoring)
|
|
478
|
+
*/
|
|
479
|
+
getSessionCount() {
|
|
480
|
+
if (!this._instance) {
|
|
481
|
+
throw new Error('SessionSecurity not initialized. Call master.session.init() first.');
|
|
482
|
+
}
|
|
483
|
+
return this._instance.getSessionCount();
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Clear all sessions (testing only)
|
|
488
|
+
*/
|
|
489
|
+
clearAllSessions() {
|
|
490
|
+
if (!this._instance) {
|
|
491
|
+
throw new Error('SessionSecurity not initialized. Call master.session.init() first.');
|
|
492
|
+
}
|
|
493
|
+
return this._instance.clearAllSessions();
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Get recommended settings for environment
|
|
498
|
+
*/
|
|
499
|
+
getBestPractices(env) {
|
|
500
|
+
return SESSION_BEST_PRACTICES[env] || SESSION_BEST_PRACTICES.development;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// Auto-register with MasterController
|
|
505
|
+
master.extend("session", MasterSessionSecurity);
|
|
506
|
+
|
|
410
507
|
module.exports = {
|
|
411
508
|
SessionSecurity,
|
|
412
509
|
session,
|