jcc-express-mvc 1.8.8 → 1.8.21
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/__tests__/MySqlSchemaBlueprint.test.d.ts +2 -0
- package/__tests__/MySqlSchemaBlueprint.test.d.ts.map +1 -0
- package/__tests__/MySqlSchemaBlueprint.test.js +55 -0
- package/__tests__/PostgresTranslator.test.d.ts +2 -0
- package/__tests__/PostgresTranslator.test.d.ts.map +1 -0
- package/__tests__/PostgresTranslator.test.js +82 -0
- package/__tests__/SQLiteTranslator.test.d.ts +2 -0
- package/__tests__/SQLiteTranslator.test.d.ts.map +1 -0
- package/__tests__/SQLiteTranslator.test.js +125 -0
- package/__tests__/SchemaAlterBlueprint.test.d.ts +2 -0
- package/__tests__/SchemaAlterBlueprint.test.d.ts.map +1 -0
- package/__tests__/SchemaAlterBlueprint.test.js +35 -0
- package/global.d.ts +3 -1
- package/index.d.ts +28 -3
- package/index.d.ts.map +1 -1
- package/index.js +33 -75
- package/lib/Application/Application.d.ts +1 -1
- package/lib/Application/Application.d.ts.map +1 -1
- package/lib/Application/Application.js +2 -2
- package/lib/Application/ApplicationBuilder.d.ts.map +1 -1
- package/lib/Application/ApplicationBuilder.js +9 -2
- package/lib/Auth/AuthMiddleware.d.ts.map +1 -1
- package/lib/Auth/AuthMiddleware.js +29 -12
- package/lib/Auth/index.d.ts +17 -3
- package/lib/Auth/index.d.ts.map +1 -1
- package/lib/Auth/index.js +128 -26
- package/lib/Auth/loginRateLimit.d.ts +6 -0
- package/lib/Auth/loginRateLimit.d.ts.map +1 -0
- package/lib/Auth/loginRateLimit.js +25 -0
- package/lib/Auth/refreshTokenStore.d.ts +24 -0
- package/lib/Auth/refreshTokenStore.d.ts.map +1 -0
- package/lib/Auth/refreshTokenStore.js +46 -0
- package/lib/Command-Line/DBCommand.d.ts.map +1 -1
- package/lib/Command-Line/DBCommand.js +9 -3
- package/lib/Command-Line/KeyGenerateCommand.d.ts +6 -0
- package/lib/Command-Line/KeyGenerateCommand.d.ts.map +1 -0
- package/lib/Command-Line/KeyGenerateCommand.js +47 -0
- package/lib/Command-Line/NodeArtisanCommand.d.ts +2 -0
- package/lib/Command-Line/NodeArtisanCommand.d.ts.map +1 -1
- package/lib/Command-Line/NodeArtisanCommand.js +20 -3
- package/lib/Command-Line/NodeTinker/Tinker.d.ts +5 -2
- package/lib/Command-Line/NodeTinker/Tinker.d.ts.map +1 -1
- package/lib/Command-Line/NodeTinker/Tinker.js +13 -3
- package/lib/Command-Line/WatchCommand.d.ts +29 -0
- package/lib/Command-Line/WatchCommand.d.ts.map +1 -0
- package/lib/Command-Line/WatchCommand.js +234 -0
- package/lib/Command-Line/files/Models.d.ts.map +1 -1
- package/lib/Command-Line/files/Models.js +41 -16
- package/lib/Console/Command.d.ts +18 -0
- package/lib/Console/Command.d.ts.map +1 -1
- package/lib/Console/Command.js +29 -0
- package/lib/Container/index.d.ts.map +1 -1
- package/lib/Container/index.js +21 -7
- package/lib/Database/Database.d.ts +2 -1
- package/lib/Database/Database.d.ts.map +1 -1
- package/lib/Database/Database.js +6 -5
- package/lib/Database/DatabaseServiceProvider.d.ts +0 -4
- package/lib/Database/DatabaseServiceProvider.d.ts.map +1 -1
- package/lib/Database/DatabaseServiceProvider.js +9 -56
- package/lib/Database/Drivers/MongooseDriver.d.ts +2 -0
- package/lib/Database/Drivers/MongooseDriver.d.ts.map +1 -1
- package/lib/Database/Drivers/MongooseDriver.js +11 -13
- package/lib/Database/Drivers/SequelizeDriver.d.ts +9 -1
- package/lib/Database/Drivers/SequelizeDriver.d.ts.map +1 -1
- package/lib/Database/Drivers/SequelizeDriver.js +43 -18
- package/lib/Error/SocialiteAuthError/SocialiteAuthError.d.ts +9 -0
- package/lib/Error/SocialiteAuthError/SocialiteAuthError.d.ts.map +1 -0
- package/lib/Error/SocialiteAuthError/SocialiteAuthError.js +17 -0
- package/lib/Global/helpers.d.ts.map +1 -1
- package/lib/Global/helpers.js +6 -4
- package/lib/Http/index.d.ts +3 -1
- package/lib/Http/index.d.ts.map +1 -1
- package/lib/Http/index.js +26 -5
- package/lib/Interface/index.d.ts +12 -3
- package/lib/Interface/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Builder.d.ts +12 -1
- package/lib/Jcc-eloquent/lib/Builder.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Builder.js +116 -4
- package/lib/Jcc-eloquent/lib/Interfaces/index.d.ts +37 -2
- package/lib/Jcc-eloquent/lib/Interfaces/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Migration.d.ts +6 -0
- package/lib/Jcc-eloquent/lib/Migration.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Migration.js +24 -2
- package/lib/Jcc-eloquent/lib/Model.d.ts +24 -7
- package/lib/Jcc-eloquent/lib/Model.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Model.js +35 -2
- package/lib/Jcc-eloquent/lib/QueryBuilder.d.ts +2 -1
- package/lib/Jcc-eloquent/lib/QueryBuilder.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/QueryBuilder.js +10 -1
- package/lib/Jcc-eloquent/lib/Rollback.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Rollback.js +9 -2
- package/lib/Jcc-eloquent/lib/Schema/BaseSchemaEntity/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Schema/BaseSchemaEntity/index.js +3 -3
- package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.d.ts +6 -2
- package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.js +41 -12
- package/lib/Jcc-eloquent/lib/Schema/Translator/Sqlite.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Schema/Translator/Sqlite.js +21 -3
- package/lib/Jcc-eloquent/lib/Schema/Translator/postgres.d.ts +1 -0
- package/lib/Jcc-eloquent/lib/Schema/Translator/postgres.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Schema/Translator/postgres.js +70 -14
- package/lib/Jcc-eloquent/lib/Schema/index.d.ts +12 -0
- package/lib/Jcc-eloquent/lib/Schema/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Schema/index.js +27 -6
- package/lib/Jcc-eloquent/lib/utils/index.d.ts +13 -0
- package/lib/Jcc-eloquent/lib/utils/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/utils/index.js +62 -0
- package/lib/Middleware/index.d.ts.map +1 -1
- package/lib/Middleware/index.js +4 -7
- package/lib/Model/Sequelize.d.ts +3 -0
- package/lib/Model/Sequelize.d.ts.map +1 -0
- package/lib/Model/Sequelize.js +6 -0
- package/lib/Providers/SessionServiceProvider.d.ts +12 -0
- package/lib/Providers/SessionServiceProvider.d.ts.map +1 -0
- package/lib/Providers/SessionServiceProvider.js +47 -0
- package/lib/Queue/Controllers/QueueControllers.d.ts +4 -13
- package/lib/Queue/Controllers/QueueControllers.d.ts.map +1 -1
- package/lib/Queue/Controllers/QueueControllers.js +1 -16
- package/lib/Queue/Route/web.js +4 -1
- package/lib/Queue/index.d.ts +1 -0
- package/lib/Queue/index.d.ts.map +1 -1
- package/lib/Queue/index.js +3 -0
- package/lib/Queue/middleware/queueDashboardGuard.d.ts +7 -0
- package/lib/Queue/middleware/queueDashboardGuard.d.ts.map +1 -0
- package/lib/Queue/middleware/queueDashboardGuard.js +43 -0
- package/lib/Response/index.d.ts.map +1 -1
- package/lib/Response/index.js +6 -1
- package/lib/Routes/Route.d.ts +2 -2
- package/lib/Routes/Route.d.ts.map +1 -1
- package/lib/Routes/RouteBuilder.d.ts +2 -2
- package/lib/Routes/RouteBuilder.d.ts.map +1 -1
- package/lib/Security/CsrfMiddleware.d.ts.map +1 -1
- package/lib/Security/CsrfMiddleware.js +6 -4
- package/lib/Session/DatabaseSession.d.ts +9 -3
- package/lib/Session/DatabaseSession.d.ts.map +1 -1
- package/lib/Session/DatabaseSession.js +38 -36
- package/lib/Session/ExpressJccSession.d.ts +23 -0
- package/lib/Session/ExpressJccSession.d.ts.map +1 -0
- package/lib/Session/ExpressJccSession.js +110 -0
- package/lib/Session/RedisSession.d.ts +2 -2
- package/lib/Session/RedisSession.d.ts.map +1 -1
- package/lib/Session/RedisSession.js +19 -5
- package/lib/Session/SessionManager.d.ts +18 -4
- package/lib/Session/SessionManager.d.ts.map +1 -1
- package/lib/Session/SessionManager.js +53 -17
- package/lib/Socialite/AbstractProvider.d.ts +60 -0
- package/lib/Socialite/AbstractProvider.d.ts.map +1 -0
- package/lib/Socialite/AbstractProvider.js +136 -0
- package/lib/Socialite/Drivers/facebook/FacebookDriver.d.ts +9 -0
- package/lib/Socialite/Drivers/facebook/FacebookDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/facebook/FacebookDriver.js +40 -0
- package/lib/Socialite/Drivers/facebook/FacebookProvider.d.ts +15 -0
- package/lib/Socialite/Drivers/facebook/FacebookProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/facebook/FacebookProvider.js +28 -0
- package/lib/Socialite/Drivers/github/GitHubDriver.d.ts +9 -0
- package/lib/Socialite/Drivers/github/GitHubDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/github/GitHubDriver.js +54 -0
- package/lib/Socialite/Drivers/github/GitHubProvider.d.ts +15 -0
- package/lib/Socialite/Drivers/github/GitHubProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/github/GitHubProvider.js +28 -0
- package/lib/Socialite/Drivers/gitlab/GitLabDriver.d.ts +10 -0
- package/lib/Socialite/Drivers/gitlab/GitLabDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/gitlab/GitLabDriver.js +37 -0
- package/lib/Socialite/Drivers/gitlab/GitLabProvider.d.ts +15 -0
- package/lib/Socialite/Drivers/gitlab/GitLabProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/gitlab/GitLabProvider.js +28 -0
- package/lib/Socialite/Drivers/google/GoogleDriver.d.ts +9 -0
- package/lib/Socialite/Drivers/google/GoogleDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/google/GoogleDriver.js +39 -0
- package/lib/Socialite/Drivers/google/GoogleProvider.d.ts +15 -0
- package/lib/Socialite/Drivers/google/GoogleProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/google/GoogleProvider.js +28 -0
- package/lib/Socialite/Drivers/slack/SlackDriver.d.ts +9 -0
- package/lib/Socialite/Drivers/slack/SlackDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/slack/SlackDriver.js +41 -0
- package/lib/Socialite/Drivers/slack/SlackProvider.d.ts +16 -0
- package/lib/Socialite/Drivers/slack/SlackProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/slack/SlackProvider.js +37 -0
- package/lib/Socialite/Drivers/twitter/TwitterDriver.d.ts +9 -0
- package/lib/Socialite/Drivers/twitter/TwitterDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/twitter/TwitterDriver.js +57 -0
- package/lib/Socialite/Drivers/twitter/TwitterProvider.d.ts +16 -0
- package/lib/Socialite/Drivers/twitter/TwitterProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/twitter/TwitterProvider.js +38 -0
- package/lib/Socialite/SocialUser.d.ts +42 -0
- package/lib/Socialite/SocialUser.d.ts.map +1 -0
- package/lib/Socialite/SocialUser.js +116 -0
- package/lib/Socialite/Socialite.d.ts +13 -0
- package/lib/Socialite/Socialite.d.ts.map +1 -0
- package/lib/Socialite/Socialite.js +41 -0
- package/lib/Socialite/SocialiteProvider.d.ts +9 -0
- package/lib/Socialite/SocialiteProvider.d.ts.map +1 -0
- package/lib/Socialite/SocialiteProvider.js +15 -0
- package/lib/Socialite/config.d.ts +7 -0
- package/lib/Socialite/config.d.ts.map +1 -0
- package/lib/Socialite/config.js +44 -0
- package/lib/Socialite/constant.d.ts +18 -0
- package/lib/Socialite/constant.d.ts.map +1 -0
- package/lib/Socialite/constant.js +20 -0
- package/lib/Socialite/index.d.ts +13 -0
- package/lib/Socialite/index.d.ts.map +1 -0
- package/lib/Socialite/index.js +25 -0
- package/lib/Socialite/types.d.ts +13 -0
- package/lib/Socialite/types.d.ts.map +1 -0
- package/lib/Socialite/types.js +2 -0
- package/lib/Type/index.d.ts +1 -0
- package/lib/Type/index.d.ts.map +1 -1
- package/lib/Validation/Validator/CustomValidation.d.ts.map +1 -1
- package/lib/Validation/Validator/CustomValidation.js +2 -2
- package/lib/Validation/Validator/helper.d.ts.map +1 -1
- package/lib/Validation/Validator/helper.js +8 -1
- package/lib/util/index.d.ts +36 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +123 -26
- package/package.json +1 -1
|
@@ -6,24 +6,15 @@ export declare class QueueControllers {
|
|
|
6
6
|
/**
|
|
7
7
|
* Show the dashboard
|
|
8
8
|
*/
|
|
9
|
-
dashboard(): Promise<void
|
|
10
|
-
(url: string): void;
|
|
11
|
-
(status: number, url: string): void;
|
|
12
|
-
}>;
|
|
9
|
+
dashboard(): Promise<void>;
|
|
13
10
|
/**
|
|
14
|
-
*
|
|
11
|
+
* JSON list of queues (API)
|
|
15
12
|
*/
|
|
16
|
-
index(): Promise<
|
|
17
|
-
(url: string): void;
|
|
18
|
-
(status: number, url: string): void;
|
|
19
|
-
}>;
|
|
13
|
+
index(): Promise<import("../../Interface").AppResponse>;
|
|
20
14
|
/**
|
|
21
15
|
* Show the queue
|
|
22
16
|
*/
|
|
23
|
-
show(status: string): Promise<void
|
|
24
|
-
(url: string): void;
|
|
25
|
-
(status: number, url: string): void;
|
|
26
|
-
}>;
|
|
17
|
+
show(status: string): Promise<void>;
|
|
27
18
|
/**
|
|
28
19
|
* Retry a failed job or run a pending job.
|
|
29
20
|
* PUT /queue/jobs/:id/failed -> retry (re-queue as pending)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueControllers.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Queue/Controllers/QueueControllers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"QueueControllers.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Queue/Controllers/QueueControllers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,qBACa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,KAAK;IAEzC;;OAEG;IACG,SAAS;IAIf;;OAEG;IACG,KAAK;IAKX;;OAEG;IAEG,IAAI,CAAC,MAAM,EAAE,MAAM;IAWzB;;;;OAIG;IAEG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IA+BvC;;OAEG;IAEG,OAAO,CAAC,EAAE,EAAE,MAAM;IAKxB,OAAO,CAAC,SAAS;IAkBX,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,WAAW;CAGlC"}
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.QueueControllers = void 0;
|
|
13
13
|
const __1 = require("..");
|
|
14
14
|
const Dependency_1 = require("../../Dependency");
|
|
15
|
-
//
|
|
16
15
|
let QueueControllers = class QueueControllers {
|
|
17
16
|
constructor(queue) {
|
|
18
17
|
this.queue = queue;
|
|
@@ -21,21 +20,12 @@ let QueueControllers = class QueueControllers {
|
|
|
21
20
|
* Show the dashboard
|
|
22
21
|
*/
|
|
23
22
|
async dashboard() {
|
|
24
|
-
const user = { email: "abdoujammeh64@gmails.com" };
|
|
25
|
-
if (!(await can(user, "viewJobs")) && env("APP_ENV") !== "local") {
|
|
26
|
-
return redirect("/login");
|
|
27
|
-
}
|
|
28
23
|
return view("queue/dashboard");
|
|
29
24
|
}
|
|
30
25
|
/**
|
|
31
|
-
*
|
|
26
|
+
* JSON list of queues (API)
|
|
32
27
|
*/
|
|
33
28
|
async index() {
|
|
34
|
-
return await this.queue.getQueues();
|
|
35
|
-
const user = { email: "abdoujammeh64@gmails.com" };
|
|
36
|
-
if (!(await can(user, "viewJobs")) && env("APP_ENV") !== "local") {
|
|
37
|
-
return redirect("/login");
|
|
38
|
-
}
|
|
39
29
|
const queues = await this.queue.getQueues();
|
|
40
30
|
return response().json({ success: true, data: queues });
|
|
41
31
|
}
|
|
@@ -43,12 +33,7 @@ let QueueControllers = class QueueControllers {
|
|
|
43
33
|
* Show the queue
|
|
44
34
|
*/
|
|
45
35
|
async show(status) {
|
|
46
|
-
const user = { email: "abdoujammeh64@gmails.com" };
|
|
47
|
-
if (!(await can(user, "viewJobs")) && env("APP_ENV") !== "local") {
|
|
48
|
-
return redirect("/login");
|
|
49
|
-
}
|
|
50
36
|
const jobs = (await this.queue.findQueueBy("status", status)).map((job) => this.formatJob(job));
|
|
51
|
-
// return jobs;
|
|
52
37
|
return view("queue/jobs", {
|
|
53
38
|
jobs,
|
|
54
39
|
status: status,
|
package/lib/Queue/Route/web.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const Route_1 = require("../../Routes/Route");
|
|
4
4
|
const QueueControllers_1 = require("../Controllers/QueueControllers");
|
|
5
|
-
|
|
5
|
+
const queueDashboardGuard_1 = require("../middleware/queueDashboardGuard");
|
|
6
|
+
Route_1.Route.middleware([queueDashboardGuard_1.queueDashboardGuard])
|
|
7
|
+
.controller(QueueControllers_1.QueueControllers)
|
|
8
|
+
.group((Route) => {
|
|
6
9
|
Route.get("/dashboard", "dashboard");
|
|
7
10
|
Route.get("/jobs", "index");
|
|
8
11
|
Route.get("/jobs/{status}", "show");
|
package/lib/Queue/index.d.ts
CHANGED
package/lib/Queue/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Queue/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Queue/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/lib/Queue/index.js
CHANGED
|
@@ -14,7 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.queueDashboardGuard = void 0;
|
|
17
18
|
__exportStar(require("./Queue"), exports);
|
|
18
19
|
__exportStar(require("./Job"), exports);
|
|
19
20
|
__exportStar(require("./type"), exports);
|
|
20
21
|
__exportStar(require("./interface"), exports);
|
|
22
|
+
var queueDashboardGuard_1 = require("./middleware/queueDashboardGuard");
|
|
23
|
+
Object.defineProperty(exports, "queueDashboardGuard", { enumerable: true, get: function () { return queueDashboardGuard_1.queueDashboardGuard; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppNext, AppRequest, AppResponse } from "../../Interface";
|
|
2
|
+
/**
|
|
3
|
+
* Protects all `/queue/*` routes: in non-local env runs session auth then `viewJobs` gate.
|
|
4
|
+
* In `APP_ENV=local`, skips checks (development convenience).
|
|
5
|
+
*/
|
|
6
|
+
export declare function queueDashboardGuard(req: AppRequest, res: AppResponse, next: AppNext): void;
|
|
7
|
+
//# sourceMappingURL=queueDashboardGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queueDashboardGuard.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Queue/middleware/queueDashboardGuard.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQxE;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,OAAO,GACZ,IAAI,CA4BN"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.queueDashboardGuard = queueDashboardGuard;
|
|
4
|
+
const Config_1 = require("../../Config/Config");
|
|
5
|
+
const Authorization_1 = require("../../Authorization");
|
|
6
|
+
const AuthMiddleware_1 = require("../../Auth/AuthMiddleware");
|
|
7
|
+
const VIEW_JOBS_ABILITY = "viewJobs";
|
|
8
|
+
function isLocalEnv() {
|
|
9
|
+
return String(Config_1.config.get("APP_ENV", "") ?? "").toLowerCase() === "local";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Protects all `/queue/*` routes: in non-local env runs session auth then `viewJobs` gate.
|
|
13
|
+
* In `APP_ENV=local`, skips checks (development convenience).
|
|
14
|
+
*/
|
|
15
|
+
function queueDashboardGuard(req, res, next) {
|
|
16
|
+
if (isLocalEnv()) {
|
|
17
|
+
next();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
void AuthMiddleware_1.authMiddleware.auth(req, res, () => {
|
|
21
|
+
void (async () => {
|
|
22
|
+
try {
|
|
23
|
+
const user = req.user;
|
|
24
|
+
if (!user) {
|
|
25
|
+
req.jccSession?.put("redirect", req.originalUrl || req.url || "/");
|
|
26
|
+
return res.redirect(303, `/login?redirect=${encodeURIComponent(req.originalUrl || req.url || "/")}`);
|
|
27
|
+
}
|
|
28
|
+
if (!(await Authorization_1.GateFacade.can(user, VIEW_JOBS_ABILITY))) {
|
|
29
|
+
if (req.expectsJson() && !req.isInertia()) {
|
|
30
|
+
return res
|
|
31
|
+
.status(403)
|
|
32
|
+
.json({ message: "This action is unauthorized." });
|
|
33
|
+
}
|
|
34
|
+
return res.status(403).send("Forbidden");
|
|
35
|
+
}
|
|
36
|
+
next();
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
next(e);
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Response/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGvD;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAc;gBAClB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW;IAYtD;;;OAGG;IACH,SAAS,CAAC,WAAW;IAerB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,IAAI;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Response/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGvD;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAc;gBAClB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW;IAYtD;;;OAGG;IACH,SAAS,CAAC,WAAW;IAerB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,IAAI;CAQb"}
|
package/lib/Response/index.js
CHANGED
|
@@ -47,7 +47,12 @@ class HttpResponse {
|
|
|
47
47
|
// : this.response.redirect(303, reqUrls[0]);
|
|
48
48
|
}
|
|
49
49
|
with(message, type) {
|
|
50
|
-
this.request.
|
|
50
|
+
if (this.request.jccSession) {
|
|
51
|
+
this.request.jccSession.flash(type, message);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.request.flash(type, message);
|
|
55
|
+
}
|
|
51
56
|
return this;
|
|
52
57
|
}
|
|
53
58
|
}
|
package/lib/Routes/Route.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestHandler } from "express";
|
|
2
2
|
import { ResourceOption } from "../Interface/index";
|
|
3
|
-
import { Constructor,
|
|
3
|
+
import { Constructor, MiddlewareInput, RouteHandler } from "../Type";
|
|
4
4
|
export declare class Route<T extends Record<string, RequestHandler>> {
|
|
5
5
|
private static routeBuilder;
|
|
6
6
|
/**
|
|
@@ -20,7 +20,7 @@ export declare class Route<T extends Record<string, RequestHandler>> {
|
|
|
20
20
|
* @param {Array | function} middleware - Array of middleware functions.
|
|
21
21
|
* @returns {Route} - Returns the route instance.
|
|
22
22
|
*/
|
|
23
|
-
static middleware(middleware:
|
|
23
|
+
static middleware(middleware: MiddlewareInput): typeof Route;
|
|
24
24
|
/**
|
|
25
25
|
* Groups routes using a callback function.
|
|
26
26
|
* @param {Function} callback - Callback function for defining grouped routes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Routes/Route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,
|
|
1
|
+
{"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Routes/Route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EACL,WAAW,EAGX,eAAe,EACf,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,qBAAa,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC;IACzD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAqC;IAEhE;;;;OAIG;WACW,UAAU,CAAC,UAAU,EAAE,GAAG,GAAG,OAAO,KAAK;IAOvD;;;;OAIG;WACW,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,KAAK;IAK/C;;;;OAIG;WACW,UAAU,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,KAAK;IAKnE;;;;OAIG;WACW,KAAK,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,KAAK,IAAI,GAAG,OAAO,KAAK;IAQ3E;;;;;OAKG;WACW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI;IAS5D;;;;;OAKG;WACW,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI;IAI7D;;;;;OAKG;WACW,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI;IAI9D;;;;;OAKG;WACW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI;IAI5D;;;;;OAKG;WACW,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI;WAIjD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;WAM7C,QAAQ,CACpB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,EAC5B,MAAM,GAAE,cAAyC;WAarC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAMnC,OAAO,CAAC,MAAM,CAAC,mBAAmB;CAOnC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Application as ExpressApplication, RequestHandler } from "express";
|
|
2
2
|
import { BaseController, ExpressCallback, MethodsInterface, ResourceOption } from "../Interface";
|
|
3
|
-
import { HttpMethodType, HttpRoutes,
|
|
3
|
+
import { HttpMethodType, HttpRoutes, MiddlewareInput, ObjectType, RouteHandler } from "../Type";
|
|
4
4
|
import type { Application } from "../Application/Application";
|
|
5
5
|
export declare class RouteBuilder {
|
|
6
6
|
private static middlewareStack;
|
|
@@ -18,7 +18,7 @@ export declare class RouteBuilder {
|
|
|
18
18
|
static validateResourceOption(option: ResourceOption, methods: ObjectType): boolean | ObjectType;
|
|
19
19
|
static setPrefix(prefix: string): void;
|
|
20
20
|
private static replaceRouteParameters;
|
|
21
|
-
static setMiddle(middleware:
|
|
21
|
+
static setMiddle(middleware: MiddlewareInput): number | RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>[] | undefined;
|
|
22
22
|
static setController(Controller: new (...args: any[]) => any): void;
|
|
23
23
|
static buildRoute(httpMethod: HttpMethodType, url: string, callback: RouteHandler): void;
|
|
24
24
|
static setServiceContainer(container: Application): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteBuilder.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Routes/RouteBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAIL,cAAc,EACd,eAAe,EAEf,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EACd,UAAU,
|
|
1
|
+
{"version":3,"file":"RouteBuilder.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Routes/RouteBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAIL,cAAc,EACd,eAAe,EAEf,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EACd,UAAU,EAEV,eAAe,EACf,UAAU,EACV,YAAY,EACb,MAAM,SAAS,CAAC;AAMjB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,eAAe,CAA0B;IACxD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAwB;IACjD,OAAO,CAAC,MAAM,CAAC,MAAM,CAAS;IAC9B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAS;IACjC,SAAS,CAAC,MAAM,CAAC,gBAAgB,EAAE,WAAW,CAAC;IAC/C,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC;IAC5C,OAAO,CAAC,MAAM,CAAC,MAAM,CAAkB;WAEzB,UAAU;WAKV,QAAQ;IAItB,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;WAOpC,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB;WAahD,YAAY,CAAC,GAAG,EAAE,MAAM;WAIxB,sBAAsB,CAClC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,UAAU,GAClB,OAAO,GAAG,UAAU;WAmBT,SAAS,CAAC,MAAM,EAAE,MAAM;IAItC,OAAO,CAAC,MAAM,CAAC,sBAAsB;WAKvB,SAAS,CAAC,UAAU,EAAE,eAAe;WA4BrC,aAAa,CAAC,UAAU,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;WAIrD,UAAU,CACtB,UAAU,EAAE,cAAc,EAC1B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,YAAY;WA0BV,mBAAmB,CAAC,SAAS,EAAE,WAAW;IAIxD,SAAS,CAAC,MAAM,CAAC,QAAQ,CACvB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,cAAc,GAAG,cAAc,EAAE,GAC5C,GAAG;IASN,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAC/B,QAAQ,EAAE,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,GACpC,eAAe;IAwBlB,OAAO,CAAC,MAAM,CAAC,cAAc;WAgCf,aAAa,CAAC,GAAG,EAAE,kBAAkB;IAoCnD,WAAkB,SAAS,IAAI,UAAU,CAExC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CsrfMiddleware.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Security/CsrfMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhE,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC7B,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAmBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,IAUpC,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"CsrfMiddleware.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Security/CsrfMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhE,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC7B,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAmBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,IAUpC,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,UAkDzD"}
|
|
@@ -71,11 +71,13 @@ function csrf(options = {}) {
|
|
|
71
71
|
const submitted = req.body?.[fieldName] ||
|
|
72
72
|
req.headers[headerName] ||
|
|
73
73
|
req.headers[headerName.toLowerCase()];
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
!crypto_1.default.timingSafeEqual(Buffer.from(String(submitted)), Buffer.from(token));
|
|
74
|
+
if (!submitted) {
|
|
75
|
+
throw new MissMatchTokenException_1.MissMatchTokenException("CSRF token mismatch.");
|
|
77
76
|
}
|
|
78
|
-
|
|
77
|
+
const submittedBuf = Buffer.from(String(submitted), "utf8");
|
|
78
|
+
const tokenBuf = Buffer.from(token, "utf8");
|
|
79
|
+
if (submittedBuf.length !== tokenBuf.length ||
|
|
80
|
+
!crypto_1.default.timingSafeEqual(submittedBuf, tokenBuf)) {
|
|
79
81
|
throw new MissMatchTokenException_1.MissMatchTokenException("CSRF token mismatch.");
|
|
80
82
|
}
|
|
81
83
|
next();
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { SessionData, SessionStore } from "../Interface";
|
|
2
|
+
/**
|
|
3
|
+
* Database session store (Laravel-style `sessions` table).
|
|
4
|
+
* Requires Jcc-eloquent / Knex (`DB`) to be configured. Not for Sequelize-only apps.
|
|
5
|
+
*
|
|
6
|
+
* Expected columns: `id` (varchar, session id), `payload` (longtext), `last_activity` (int, unix).
|
|
7
|
+
*/
|
|
2
8
|
export declare class DatabaseSessionStore implements SessionStore {
|
|
3
|
-
private tableName;
|
|
4
|
-
|
|
9
|
+
private readonly tableName;
|
|
10
|
+
constructor(tableName?: string);
|
|
5
11
|
get(sessionId: string): Promise<SessionData | null>;
|
|
6
12
|
set(sessionId: string, data: SessionData, maxAge?: number): Promise<void>;
|
|
7
13
|
destroy(sessionId: string): Promise<void>;
|
|
8
14
|
touch(sessionId: string, maxAge?: number): Promise<void>;
|
|
9
|
-
clear(): Promise<
|
|
15
|
+
clear(): Promise<void>;
|
|
10
16
|
}
|
|
11
17
|
//# sourceMappingURL=DatabaseSession.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseSession.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Session/DatabaseSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzD,qBAAa,oBAAqB,YAAW,YAAY;
|
|
1
|
+
{"version":3,"file":"DatabaseSession.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Session/DatabaseSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;GAKG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,GAAE,MAAmB;IAErD,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAenD,GAAG,CACP,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,WAAW,EACjB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IA2BV,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzC,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYxD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
|
@@ -2,36 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DatabaseSessionStore = void 0;
|
|
4
4
|
const Jcc_eloquent_1 = require("../Jcc-eloquent");
|
|
5
|
+
/**
|
|
6
|
+
* Database session store (Laravel-style `sessions` table).
|
|
7
|
+
* Requires Jcc-eloquent / Knex (`DB`) to be configured. Not for Sequelize-only apps.
|
|
8
|
+
*
|
|
9
|
+
* Expected columns: `id` (varchar, session id), `payload` (longtext), `last_activity` (int, unix).
|
|
10
|
+
*/
|
|
5
11
|
class DatabaseSessionStore {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.tableName =
|
|
8
|
-
}
|
|
9
|
-
async createTable() {
|
|
10
|
-
const sqlQuery = Jcc_eloquent_1.Schema.create("sessions", function (table) {
|
|
11
|
-
table.id();
|
|
12
|
-
table.string("uuid");
|
|
13
|
-
table.foreignId("user_id").nullable().index();
|
|
14
|
-
table.string("ip_address", 45).nullable();
|
|
15
|
-
table.text("user_agent").nullable();
|
|
16
|
-
table.text("payload");
|
|
17
|
-
table.integer("last_activity").index();
|
|
18
|
-
table.timestamps();
|
|
19
|
-
});
|
|
20
|
-
try {
|
|
21
|
-
await Jcc_eloquent_1.DB.runQuery(sqlQuery);
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
console.error("Failed to create sessions table:", error);
|
|
25
|
-
}
|
|
12
|
+
constructor(tableName = "sessions") {
|
|
13
|
+
this.tableName = tableName;
|
|
26
14
|
}
|
|
27
15
|
async get(sessionId) {
|
|
28
16
|
try {
|
|
29
|
-
const
|
|
17
|
+
const row = (await Jcc_eloquent_1.DB.table(this.tableName)
|
|
30
18
|
.select("payload")
|
|
31
|
-
.where("
|
|
32
|
-
.where("expires", ">", Date.now())
|
|
19
|
+
.where("id", sessionId)
|
|
33
20
|
.first());
|
|
34
|
-
|
|
21
|
+
if (!row?.payload)
|
|
22
|
+
return null;
|
|
23
|
+
return JSON.parse(row.payload);
|
|
35
24
|
}
|
|
36
25
|
catch (error) {
|
|
37
26
|
console.error("Failed to get session from database:", error);
|
|
@@ -40,13 +29,25 @@ class DatabaseSessionStore {
|
|
|
40
29
|
}
|
|
41
30
|
async set(sessionId, data, maxAge) {
|
|
42
31
|
try {
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
32
|
+
const payload = JSON.stringify(data);
|
|
33
|
+
const lastActivity = Math.floor(Date.now() / 1000);
|
|
34
|
+
const existing = await Jcc_eloquent_1.DB.table(this.tableName)
|
|
35
|
+
.where("id", sessionId)
|
|
36
|
+
.first();
|
|
37
|
+
if (existing) {
|
|
38
|
+
await Jcc_eloquent_1.DB.table(this.tableName).where("id", sessionId).update({
|
|
39
|
+
payload,
|
|
40
|
+
last_activity: lastActivity,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
await Jcc_eloquent_1.DB.table(this.tableName).insert({
|
|
45
|
+
id: sessionId,
|
|
46
|
+
payload,
|
|
47
|
+
last_activity: lastActivity,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
void maxAge;
|
|
50
51
|
}
|
|
51
52
|
catch (error) {
|
|
52
53
|
console.error("Failed to set session in database:", error);
|
|
@@ -54,7 +55,7 @@ class DatabaseSessionStore {
|
|
|
54
55
|
}
|
|
55
56
|
async destroy(sessionId) {
|
|
56
57
|
try {
|
|
57
|
-
await Jcc_eloquent_1.DB.table(this.tableName).where("
|
|
58
|
+
await Jcc_eloquent_1.DB.table(this.tableName).where("id", sessionId).delete();
|
|
58
59
|
}
|
|
59
60
|
catch (error) {
|
|
60
61
|
console.error("Failed to destroy session in database:", error);
|
|
@@ -62,10 +63,11 @@ class DatabaseSessionStore {
|
|
|
62
63
|
}
|
|
63
64
|
async touch(sessionId, maxAge) {
|
|
64
65
|
try {
|
|
65
|
-
const
|
|
66
|
+
const lastActivity = Math.floor(Date.now() / 1000);
|
|
66
67
|
await Jcc_eloquent_1.DB.table(this.tableName)
|
|
67
|
-
.where("
|
|
68
|
-
.update({
|
|
68
|
+
.where("id", sessionId)
|
|
69
|
+
.update({ last_activity: lastActivity });
|
|
70
|
+
void maxAge;
|
|
69
71
|
}
|
|
70
72
|
catch (error) {
|
|
71
73
|
console.error("Failed to touch session in database:", error);
|
|
@@ -73,7 +75,7 @@ class DatabaseSessionStore {
|
|
|
73
75
|
}
|
|
74
76
|
async clear() {
|
|
75
77
|
try {
|
|
76
|
-
|
|
78
|
+
await Jcc_eloquent_1.DB.table(this.tableName).delete();
|
|
77
79
|
}
|
|
78
80
|
catch (error) {
|
|
79
81
|
console.error("Failed to clear sessions from database:", error);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AppRequest } from "../Interface";
|
|
2
|
+
import type { SessionData } from "../Interface";
|
|
3
|
+
import type { Session } from "./index";
|
|
4
|
+
export declare class ExpressJccSession {
|
|
5
|
+
private readonly req;
|
|
6
|
+
constructor(req: AppRequest);
|
|
7
|
+
flash(key: string, value: any): void;
|
|
8
|
+
getFlash(key: string, defaultValue?: any): any;
|
|
9
|
+
get(key: string, defaultValue?: any): any;
|
|
10
|
+
put(key: string, value: any): void;
|
|
11
|
+
has(key: string): boolean;
|
|
12
|
+
forget(key: string): void;
|
|
13
|
+
all(): SessionData;
|
|
14
|
+
only(keys: string[]): SessionData;
|
|
15
|
+
except(keys: string[]): SessionData;
|
|
16
|
+
flush(): void;
|
|
17
|
+
load(): Promise<void>;
|
|
18
|
+
save(): Promise<void>;
|
|
19
|
+
regenerate(): Promise<void>;
|
|
20
|
+
getId(): string;
|
|
21
|
+
}
|
|
22
|
+
export declare function createExpressJccSession(req: AppRequest): Session;
|
|
23
|
+
//# sourceMappingURL=ExpressJccSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpressJccSession.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Session/ExpressJccSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAWvC,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,UAAU;IAE5C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAIpC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG;IAO9C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG;IAOzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAMlC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAKzB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKzB,GAAG,IAAI,WAAW;IAKlB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW;IAQjC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW;IAUnC,KAAK,IAAI,IAAI;IASP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQrB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAUjC,KAAK,IAAI,MAAM;CAGhB;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAEhE"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExpressJccSession = void 0;
|
|
4
|
+
exports.createExpressJccSession = createExpressJccSession;
|
|
5
|
+
/**
|
|
6
|
+
* Bridges `req.jccSession` to the same underlying store as `express-session` +
|
|
7
|
+
* `connect-flash`, so flash messages set via `res.with()` or `req.flash()` stay
|
|
8
|
+
* in sync with `jccSession.flash()` / `getFlash()`.
|
|
9
|
+
*/
|
|
10
|
+
function sessionRecord(req) {
|
|
11
|
+
return req.session;
|
|
12
|
+
}
|
|
13
|
+
class ExpressJccSession {
|
|
14
|
+
constructor(req) {
|
|
15
|
+
this.req = req;
|
|
16
|
+
}
|
|
17
|
+
flash(key, value) {
|
|
18
|
+
this.req.flash(key, value);
|
|
19
|
+
}
|
|
20
|
+
getFlash(key, defaultValue) {
|
|
21
|
+
const raw = this.req.flash(key);
|
|
22
|
+
if (raw === undefined || raw === null)
|
|
23
|
+
return defaultValue;
|
|
24
|
+
if (Array.isArray(raw))
|
|
25
|
+
return raw.length ? raw[0] : defaultValue;
|
|
26
|
+
return raw;
|
|
27
|
+
}
|
|
28
|
+
get(key, defaultValue) {
|
|
29
|
+
const s = sessionRecord(this.req);
|
|
30
|
+
if (!s)
|
|
31
|
+
return defaultValue;
|
|
32
|
+
const v = s[key];
|
|
33
|
+
return v !== undefined ? v : defaultValue;
|
|
34
|
+
}
|
|
35
|
+
put(key, value) {
|
|
36
|
+
const s = sessionRecord(this.req);
|
|
37
|
+
if (!s)
|
|
38
|
+
return;
|
|
39
|
+
s[key] = value;
|
|
40
|
+
}
|
|
41
|
+
has(key) {
|
|
42
|
+
const s = sessionRecord(this.req);
|
|
43
|
+
return s != null && s[key] !== undefined;
|
|
44
|
+
}
|
|
45
|
+
forget(key) {
|
|
46
|
+
const s = sessionRecord(this.req);
|
|
47
|
+
if (s && key in s)
|
|
48
|
+
delete s[key];
|
|
49
|
+
}
|
|
50
|
+
all() {
|
|
51
|
+
const s = sessionRecord(this.req);
|
|
52
|
+
return s ? { ...s } : {};
|
|
53
|
+
}
|
|
54
|
+
only(keys) {
|
|
55
|
+
const out = {};
|
|
56
|
+
for (const key of keys) {
|
|
57
|
+
if (this.has(key))
|
|
58
|
+
out[key] = this.get(key);
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
except(keys) {
|
|
63
|
+
const full = this.all();
|
|
64
|
+
const skip = new Set(keys);
|
|
65
|
+
const out = {};
|
|
66
|
+
for (const k of Object.keys(full)) {
|
|
67
|
+
if (!skip.has(k))
|
|
68
|
+
out[k] = full[k];
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
flush() {
|
|
73
|
+
const s = sessionRecord(this.req);
|
|
74
|
+
if (!s)
|
|
75
|
+
return;
|
|
76
|
+
const keep = new Set(["cookie"]);
|
|
77
|
+
for (const k of Object.keys(s)) {
|
|
78
|
+
if (!keep.has(k))
|
|
79
|
+
delete s[k];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async load() {
|
|
83
|
+
/* express-session already populated req.session */
|
|
84
|
+
}
|
|
85
|
+
async save() {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
const s = this.req.session;
|
|
88
|
+
if (s?.save)
|
|
89
|
+
s.save((err) => (err ? reject(err) : resolve()));
|
|
90
|
+
else
|
|
91
|
+
resolve();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async regenerate() {
|
|
95
|
+
return new Promise((resolve, reject) => {
|
|
96
|
+
const s = this.req.session;
|
|
97
|
+
if (s?.regenerate)
|
|
98
|
+
s.regenerate((err) => (err ? reject(err) : resolve()));
|
|
99
|
+
else
|
|
100
|
+
resolve();
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
getId() {
|
|
104
|
+
return this.req.sessionID ?? "";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.ExpressJccSession = ExpressJccSession;
|
|
108
|
+
function createExpressJccSession(req) {
|
|
109
|
+
return new ExpressJccSession(req);
|
|
110
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SessionData, SessionStore } from "../Interface";
|
|
2
2
|
export declare class RedisSessionStore implements SessionStore {
|
|
3
|
-
private client;
|
|
4
|
-
private prefix;
|
|
3
|
+
private readonly client;
|
|
4
|
+
private readonly prefix;
|
|
5
5
|
constructor(redisUrl: string, prefix?: string);
|
|
6
6
|
private getKey;
|
|
7
7
|
get(sessionId: string): Promise<SessionData | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedisSession.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Session/RedisSession.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RedisSession.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Session/RedisSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA6BzD,qBAAa,iBAAkB,YAAW,YAAY;IACpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAE,MAAmB;IAOzD,OAAO,CAAC,MAAM;IAIR,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAgBnD,GAAG,CACP,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,WAAW,EACjB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAeV,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASzC,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYxD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAU7B"}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RedisSessionStore = void 0;
|
|
4
|
-
|
|
4
|
+
function loadRedisCreateClient() {
|
|
5
|
+
try {
|
|
6
|
+
// Optional peer dependency — only required when SESSION_DRIVER=redis
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
8
|
+
const redis = require("redis");
|
|
9
|
+
if (typeof redis.createClient !== "function") {
|
|
10
|
+
throw new Error("invalid redis module");
|
|
11
|
+
}
|
|
12
|
+
return redis.createClient;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error('Session driver "redis" needs the optional package: npm install redis');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
5
18
|
class RedisSessionStore {
|
|
6
19
|
constructor(redisUrl, prefix = "session:") {
|
|
7
|
-
|
|
20
|
+
const createClient = loadRedisCreateClient();
|
|
21
|
+
this.client = createClient({ url: redisUrl });
|
|
8
22
|
this.prefix = prefix;
|
|
9
|
-
this.client.connect();
|
|
23
|
+
void this.client.connect();
|
|
10
24
|
}
|
|
11
25
|
getKey(sessionId) {
|
|
12
26
|
return `${this.prefix}${sessionId}`;
|
|
@@ -46,7 +60,7 @@ class RedisSessionStore {
|
|
|
46
60
|
await this.client.del(key);
|
|
47
61
|
}
|
|
48
62
|
catch (error) {
|
|
49
|
-
console.error("Failed to destroy session
|
|
63
|
+
console.error("Failed to destroy session from Redis:", error);
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
66
|
async touch(sessionId, maxAge) {
|
|
@@ -64,7 +78,7 @@ class RedisSessionStore {
|
|
|
64
78
|
try {
|
|
65
79
|
const keys = await this.client.keys(`${this.prefix}*`);
|
|
66
80
|
if (keys.length > 0) {
|
|
67
|
-
await this.client.del(keys);
|
|
81
|
+
await this.client.del(...keys);
|
|
68
82
|
}
|
|
69
83
|
}
|
|
70
84
|
catch (error) {
|