+1
-1
@@ -2,4 +2,4 @@ node_modules
|
||||
RayLab-Core.zip
|
||||
RayLab-Core.rar
|
||||
.env
|
||||
dist
|
||||
dist/
|
||||
|
||||
Vendored
-37
@@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const identity_module_1 = require("./modules/identity/identity.module");
|
||||
const auth_module_1 = require("./modules/auth/auth.module");
|
||||
const health_module_1 = require("./modules/health/health.module");
|
||||
const authorization_module_1 = require("./modules/authorization/authorization.module");
|
||||
const audit_module_1 = require("./modules/audit/audit.module");
|
||||
const application_module_1 = require("./modules/application/application.module");
|
||||
let AppModule = class AppModule {
|
||||
};
|
||||
exports.AppModule = AppModule;
|
||||
exports.AppModule = AppModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
config_1.ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
}),
|
||||
identity_module_1.IdentityModule,
|
||||
auth_module_1.AuthModule,
|
||||
health_module_1.HealthModule,
|
||||
// Authorization module provides permission checks and cache
|
||||
authorization_module_1.AuthorizationModule,
|
||||
audit_module_1.AuditModule,
|
||||
application_module_1.ApplicationModule,
|
||||
],
|
||||
})
|
||||
], AppModule);
|
||||
//# sourceMappingURL=app.module.js.map
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2CAA8C;AAE9C,wEAAoE;AACpE,4DAAwD;AACxD,kEAA8D;AAC9D,uFAAmF;AACnF,+DAA2D;AAC3D,iFAA6E;AAmBtE,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAhBrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;aACf,CAAC;YAEE,gCAAc;YACd,wBAAU;YACV,4BAAY;YACZ,4DAA4D;YACpD,0CAAmB;YAC3B,0BAAW;YACX,sCAAiB;SAEtB;KACF,CAAC;GACW,SAAS,CAAG"}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PermissionType = void 0;
|
||||
exports.PermissionType = {
|
||||
USER_CREATE: 'USER_CREATE',
|
||||
USER_READ: 'USER_READ',
|
||||
USER_UPDATE: 'USER_UPDATE',
|
||||
USER_DELETE: 'USER_DELETE',
|
||||
ROLE_CREATE: 'ROLE_CREATE',
|
||||
ROLE_READ: 'ROLE_READ',
|
||||
ROLE_UPDATE: 'ROLE_UPDATE',
|
||||
ROLE_DELETE: 'ROLE_DELETE',
|
||||
PERMISSION_CREATE: 'PERMISSION_CREATE',
|
||||
PERMISSION_READ: 'PERMISSION_READ',
|
||||
PERMISSION_UPDATE: 'PERMISSION_UPDATE',
|
||||
PERMISSION_DELETE: 'PERMISSION_DELETE',
|
||||
};
|
||||
//# sourceMappingURL=permission.constants.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"permission.constants.js","sourceRoot":"","sources":["../../../src/common/constants/permission.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;IAC5B,WAAW,EAAE,aAAa;IAC1B,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAE1B,WAAW,EAAE,aAAa;IAC1B,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAE1B,iBAAiB,EAAE,mBAAmB;IACtC,eAAe,EAAE,iBAAiB;IAClC,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;CAC9B,CAAC"}
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JwtAuthGuard = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const jose_1 = require("jose");
|
||||
const identity_data_1 = require("../interfaces/identity-data");
|
||||
const jwt = __importStar(require("jsonwebtoken"));
|
||||
/**
|
||||
* JwtAuthGuard verifies JWTs issued by the external Identity Provider (Authentik)
|
||||
* using JWKS (RS256). It also accepts internal RayLab JWTs signed with a local secret.
|
||||
*/
|
||||
let JwtAuthGuard = class JwtAuthGuard {
|
||||
jwks = null;
|
||||
constructor() { }
|
||||
async canActivate(context) {
|
||||
const request = context.switchToHttp().getRequest();
|
||||
const authHeader = request.headers.authorization;
|
||||
if (!authHeader) {
|
||||
throw new common_1.UnauthorizedException('Authorization header is missing.');
|
||||
}
|
||||
const [type, token] = authHeader.split(' ');
|
||||
if (type !== 'Bearer' || !token) {
|
||||
throw new common_1.UnauthorizedException('Invalid authorization header.');
|
||||
}
|
||||
const jwksUri = process.env.AUTHENTIK_JWKS_URI;
|
||||
// First try verifying with external JWKS (Authentik)
|
||||
if (jwksUri) {
|
||||
try {
|
||||
if (!this.jwks)
|
||||
this.jwks = (0, jose_1.createRemoteJWKSet)(new URL(jwksUri));
|
||||
const { payload } = await (0, jose_1.jwtVerify)(token, this.jwks, {
|
||||
issuer: process.env.AUTHENTIK_ISSUER,
|
||||
audience: process.env.AUTHENTIK_AUDIENCE,
|
||||
});
|
||||
const identity = new identity_data_1.IdentityData(payload.sub, payload.preferred_username, payload.email, payload);
|
||||
request.identity = identity;
|
||||
return true;
|
||||
}
|
||||
catch (err) {
|
||||
// ignore and try internal verification
|
||||
}
|
||||
}
|
||||
// Fallback: verify with internal symmetric secret
|
||||
const secret = process.env.RAYLAB_JWT_SECRET;
|
||||
if (!secret) {
|
||||
throw new common_1.UnauthorizedException('Invalid or expired token.');
|
||||
}
|
||||
try {
|
||||
const payload = jwt.verify(token, secret);
|
||||
const identity = new identity_data_1.IdentityData(payload.sub, payload.preferred_username, payload.email, payload);
|
||||
request.identity = identity;
|
||||
return true;
|
||||
}
|
||||
catch (err) {
|
||||
throw new common_1.UnauthorizedException('Invalid or expired token.');
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.JwtAuthGuard = JwtAuthGuard;
|
||||
exports.JwtAuthGuard = JwtAuthGuard = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [])
|
||||
], JwtAuthGuard);
|
||||
//# sourceMappingURL=jwt-auth.guard.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"jwt-auth.guard.js","sourceRoot":"","sources":["../../../../src/core/auth/guards/jwt-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAKwB;AAExB,+BAAqD;AACrD,+DAA2D;AAC3D,kDAAoC;AAEpC;;;GAGG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IACf,IAAI,GAAiD,IAAI,CAAC;IAElE,gBAAe,CAAC;IAEhB,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAyC,CAAC;QAE3F,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC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,CAAC,2BAA2B,CAAC,CAAC;QAC/D,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAQ,CAAC;YAEjD,MAAM,QAAQ,GAAG,IAAI,4BAAY,CAC/B,OAAO,CAAC,GAAa,EACrB,OAAO,CAAC,kBAAwC,EAChD,OAAO,CAAC,KAA2B,EACnC,OAA8B,CAC/B,CAAC;YAEF,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,8BAAqB,CAAC,2BAA2B,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF,CAAA;AApEY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;;GACA,YAAY,CAoExB"}
|
||||
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=authenticated-request.interface.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"authenticated-request.interface.js","sourceRoot":"","sources":["../../../../src/core/auth/interfaces/authenticated-request.interface.ts"],"names":[],"mappings":""}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IdentityData = void 0;
|
||||
class IdentityData {
|
||||
sub;
|
||||
preferred_username;
|
||||
email;
|
||||
claims;
|
||||
constructor(sub, preferred_username, email, claims) {
|
||||
this.sub = sub;
|
||||
this.preferred_username = preferred_username;
|
||||
this.email = email;
|
||||
this.claims = claims;
|
||||
}
|
||||
}
|
||||
exports.IdentityData = IdentityData;
|
||||
//# sourceMappingURL=identity-data.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"identity-data.js","sourceRoot":"","sources":["../../../../src/core/auth/interfaces/identity-data.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAY;IAEL;IACA;IACA;IACA;IAJlB,YACkB,GAAW,EACX,kBAA2B,EAC3B,KAAc,EACd,MAA4B;QAH5B,QAAG,GAAH,GAAG,CAAQ;QACX,uBAAkB,GAAlB,kBAAkB,CAAS;QAC3B,UAAK,GAAL,KAAK,CAAS;QACd,WAAM,GAAN,MAAM,CAAsB;IAC3C,CAAC;CACL;AAPD,oCAOC"}
|
||||
Vendored
-13
@@ -1,13 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = () => ({
|
||||
database: {
|
||||
url: `postgresql://` +
|
||||
`${process.env.DB_USER}:` +
|
||||
`${process.env.DB_PASSWORD}@` +
|
||||
`${process.env.SERVER_HOST}:` +
|
||||
`${process.env.DB_PORT}/` +
|
||||
`${process.env.DB_NAME}?schema=public`
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=database.config.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"database.config.js","sourceRoot":"","sources":["../../../src/core/config/database.config.ts"],"names":[],"mappings":";;AAAA,kBAAe,GAAG,EAAE,CAAC,CAAC;IAClB,QAAQ,EAAE;QACN,GAAG,EACC,eAAe;YACf,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG;YACzB,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG;YAC7B,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG;YAC7B,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG;YACzB,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,gBAAgB;KAC7C;CACJ,CAAC,CAAC"}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var EventBus_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EventBus = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let EventBus = EventBus_1 = class EventBus {
|
||||
handlers = new Map();
|
||||
logger = new common_1.Logger(EventBus_1.name);
|
||||
// Accept either an EventEnvelope or (type, payload) signature for backward compatibility
|
||||
publish(eventOrType, payload) {
|
||||
let envelope;
|
||||
if (typeof eventOrType === 'string') {
|
||||
envelope = { id: require('crypto').randomUUID(), timestamp: new Date().toISOString(), type: eventOrType, payload: payload ?? {} };
|
||||
}
|
||||
else {
|
||||
envelope = eventOrType;
|
||||
}
|
||||
const handlers = this.handlers.get(envelope.type) || [];
|
||||
for (const h of handlers) {
|
||||
try {
|
||||
Promise.resolve(h(envelope)).catch((err) => this.logger.error('Event handler error', err));
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.error('Event handler threw', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
subscribe(eventType, handler) {
|
||||
const list = this.handlers.get(eventType) || [];
|
||||
list.push(handler);
|
||||
this.handlers.set(eventType, list);
|
||||
}
|
||||
};
|
||||
exports.EventBus = EventBus;
|
||||
exports.EventBus = EventBus = EventBus_1 = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], EventBus);
|
||||
//# sourceMappingURL=event-bus.service.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"event-bus.service.js","sourceRoot":"","sources":["../../../src/core/event-bus/event-bus.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAO7C,IAAM,QAAQ,gBAAd,MAAM,QAAQ;IACX,QAAQ,GAA2B,IAAI,GAAG,EAAE,CAAC;IACpC,MAAM,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F,CAAA;AA5BY,4BAAQ;mBAAR,QAAQ;IADpB,IAAA,mBAAU,GAAE;GACA,QAAQ,CA4BpB"}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=event.interface.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"event.interface.js","sourceRoot":"","sources":["../../../src/core/event-bus/event.interface.ts"],"names":[],"mappings":""}
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EventDispatcher = void 0;
|
||||
class EventDispatcher {
|
||||
publisher = new (require('./event-publisher').InMemoryEventPublisher)();
|
||||
register(handler) {
|
||||
this.publisher.register(handler);
|
||||
}
|
||||
async dispatch(event) {
|
||||
await this.publisher.publish(event);
|
||||
}
|
||||
}
|
||||
exports.EventDispatcher = EventDispatcher;
|
||||
//# sourceMappingURL=event-dispatcher.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"event-dispatcher.js","sourceRoot":"","sources":["../../../src/core/events/event-dispatcher.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAe;IAClB,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,sBAAsB,CAAC,EAAE,CAAC;IAEhF,QAAQ,CAAC,OAA0C;QACjD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAkB;QAC/B,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACF;AAVD,0CAUC"}
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=event-handler.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"event-handler.js","sourceRoot":"","sources":["../../../src/core/events/event-handler.ts"],"names":[],"mappings":""}
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.InMemoryEventPublisher = void 0;
|
||||
class InMemoryEventPublisher {
|
||||
handlers = [];
|
||||
register(handler) {
|
||||
this.handlers.push(handler);
|
||||
}
|
||||
async publish(event) {
|
||||
await Promise.all(this.handlers.map((h) => h(event)));
|
||||
}
|
||||
}
|
||||
exports.InMemoryEventPublisher = InMemoryEventPublisher;
|
||||
//# sourceMappingURL=event-publisher.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"event-publisher.js","sourceRoot":"","sources":["../../../src/core/events/event-publisher.ts"],"names":[],"mappings":";;;AAMA,MAAa,sBAAsB;IACzB,QAAQ,GAA6C,EAAE,CAAC;IAEhE,QAAQ,CAAC,OAA0C;QACjD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAkB;QAC9B,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AAVD,wDAUC"}
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=event.interface.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"event.interface.js","sourceRoot":"","sources":["../../../src/core/events/event.interface.ts"],"names":[],"mappings":""}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HttpExceptionFilter = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let HttpExceptionFilter = class HttpExceptionFilter {
|
||||
catch(exception, host) {
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse();
|
||||
const status = exception.getStatus ? exception.getStatus() : 500;
|
||||
response.status(status).json({
|
||||
success: false,
|
||||
error: {
|
||||
code: exception.code || 'INTERNAL_ERROR',
|
||||
message: exception.message || 'Internal server error',
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.HttpExceptionFilter = HttpExceptionFilter;
|
||||
exports.HttpExceptionFilter = HttpExceptionFilter = __decorate([
|
||||
(0, common_1.Catch)()
|
||||
], HttpExceptionFilter);
|
||||
//# sourceMappingURL=http-exception.filter.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"http-exception.filter.js","sourceRoot":"","sources":["../../../src/core/exceptions/http-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAuE;AAGhE,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,KAAK,CAAC,SAAc,EAAE,IAAmB;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAEjE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YAC3B,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,gBAAgB;gBACxC,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,uBAAuB;aACtD;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAdY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,cAAK,GAAE;GACK,mBAAmB,CAc/B"}
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.logger = void 0;
|
||||
const pino_1 = __importDefault(require("pino"));
|
||||
exports.logger = (0, pino_1.default)({
|
||||
level: process.env.LOG_LEVEL || 'info',
|
||||
});
|
||||
//# sourceMappingURL=logger.service.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"logger.service.js","sourceRoot":"","sources":["../../../src/core/logger/logger.service.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAEX,QAAA,MAAM,GAAG,IAAA,cAAI,EAAC;IACzB,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM;CACvC,CAAC,CAAC"}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RequestIdMiddleware = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const uuid_1 = require("uuid");
|
||||
let RequestIdMiddleware = class RequestIdMiddleware {
|
||||
use(req, res, next) {
|
||||
req.requestId = req.headers['x-request-id'] || (0, uuid_1.v4)();
|
||||
res.setHeader('X-Request-ID', req.requestId);
|
||||
next();
|
||||
}
|
||||
};
|
||||
exports.RequestIdMiddleware = RequestIdMiddleware;
|
||||
exports.RequestIdMiddleware = RequestIdMiddleware = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], RequestIdMiddleware);
|
||||
//# sourceMappingURL=request-id.middleware.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"request-id.middleware.js","sourceRoot":"","sources":["../../../src/core/middleware/request-id.middleware.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4D;AAC5D,+BAAoC;AAG7B,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,GAAG,CAAC,GAAQ,EAAE,GAAQ,EAAE,IAAgB;QACtC,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,IAAA,SAAM,GAAE,CAAC;QACxD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,EAAE,CAAC;IACT,CAAC;CACF,CAAA;AANY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;GACA,mBAAmB,CAM/B"}
|
||||
Vendored
-34
@@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const common_1 = require("@nestjs/common");
|
||||
const core_1 = require("@nestjs/core");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const app_module_1 = require("./app.module");
|
||||
async function bootstrap() {
|
||||
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
||||
const config = app.get(config_1.ConfigService);
|
||||
app.setGlobalPrefix('');
|
||||
app.useGlobalPipes(new common_1.ValidationPipe({
|
||||
whitelist: true,
|
||||
transform: true,
|
||||
forbidNonWhitelisted: true,
|
||||
}));
|
||||
app.enableCors();
|
||||
const swaggerEnabled = config.get('SWAGGER_ENABLED') === 'true';
|
||||
if (swaggerEnabled) {
|
||||
const swaggerConfig = new swagger_1.DocumentBuilder()
|
||||
.setTitle('RayLab Core API')
|
||||
.setDescription('RayLab Core REST API')
|
||||
.setVersion('1.0.0')
|
||||
.addBearerAuth()
|
||||
.build();
|
||||
const document = swagger_1.SwaggerModule.createDocument(app, swaggerConfig);
|
||||
swagger_1.SwaggerModule.setup('ApiList', app, document);
|
||||
}
|
||||
const port = config.get('PORT') || 3000;
|
||||
await app.listen(port);
|
||||
console.log(`Server running on http://localhost:${port}`);
|
||||
}
|
||||
bootstrap();
|
||||
//# sourceMappingURL=main.js.map
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,2CAAgD;AAChD,uCAA2C;AAC3C,2CAA+C;AAC/C,6CAAiE;AAEjE,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAEhD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,sBAAa,CAAC,CAAC;IAEtC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IAExB,GAAG,CAAC,cAAc,CAChB,IAAI,uBAAc,CAAC;QACjB,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,IAAI;QACf,oBAAoB,EAAE,IAAI;KAC3B,CAAC,CACH,CAAC;IAEF,GAAG,CAAC,UAAU,EAAE,CAAC;IAEjB,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAS,iBAAiB,CAAC,KAAK,MAAM,CAAC;IAExE,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,aAAa,GAAG,IAAI,yBAAe,EAAE;aACxC,QAAQ,CAAC,iBAAiB,CAAC;aAC3B,cAAc,CAAC,sBAAsB,CAAC;aACtC,UAAU,CAAC,OAAO,CAAC;aACnB,aAAa,EAAE;aACf,KAAK,EAAE,CAAC;QAEX,MAAM,QAAQ,GAAG,uBAAa,CAAC,cAAc,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;QAElE,uBAAa,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAS,MAAM,CAAC,IAAI,IAAI,CAAC;IAEhD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEvB,OAAO,CAAC,GAAG,CAAC,sCAAsC,IAAI,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,EAAE,CAAC"}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ApplicationModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const prisma_service_1 = require("../../shared/prisma.service");
|
||||
const applications_controller_1 = require("./presentation/controllers/applications.controller");
|
||||
const prisma_application_repository_1 = require("./infrastructure/repositories/prisma-application.repository");
|
||||
const application_interface_1 = require("./domain/repositories/application.interface");
|
||||
const get_applications_handler_1 = require("./application/handlers/get-applications.handler");
|
||||
const get_application_handler_1 = require("./application/handlers/get-application.handler");
|
||||
const create_application_handler_1 = require("./application/handlers/create-application.handler");
|
||||
const update_application_handler_1 = require("./application/handlers/update-application.handler");
|
||||
const delete_application_handler_1 = require("./application/handlers/delete-application.handler");
|
||||
const get_me_applications_handler_1 = require("./application/handlers/get-me-applications.handler");
|
||||
const application_validator_1 = require("./application/validators/application.validator");
|
||||
const jwt_auth_guard_1 = require("../../core/auth/guards/jwt-auth.guard");
|
||||
const identity_module_1 = require("../identity/identity.module");
|
||||
let ApplicationModule = class ApplicationModule {
|
||||
};
|
||||
exports.ApplicationModule = ApplicationModule;
|
||||
exports.ApplicationModule = ApplicationModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [identity_module_1.IdentityModule],
|
||||
providers: [
|
||||
prisma_service_1.PrismaService,
|
||||
prisma_application_repository_1.PrismaApplicationRepository,
|
||||
get_applications_handler_1.GetApplicationsHandler,
|
||||
get_application_handler_1.GetApplicationHandler,
|
||||
create_application_handler_1.CreateApplicationHandler,
|
||||
update_application_handler_1.UpdateApplicationHandler,
|
||||
delete_application_handler_1.DeleteApplicationHandler,
|
||||
get_me_applications_handler_1.GetMeApplicationsHandler,
|
||||
application_validator_1.ApplicationValidator,
|
||||
jwt_auth_guard_1.JwtAuthGuard,
|
||||
{
|
||||
provide: application_interface_1.IApplication,
|
||||
useClass: prisma_application_repository_1.PrismaApplicationRepository,
|
||||
},
|
||||
],
|
||||
controllers: [applications_controller_1.ApplicationsController],
|
||||
})
|
||||
], ApplicationModule);
|
||||
//# sourceMappingURL=application.module.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"application.module.js","sourceRoot":"","sources":["../../../src/modules/application/application.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,gEAA4D;AAC5D,gGAA4F;AAC5F,+GAA0G;AAC1G,uFAA2E;AAC3E,8FAAyF;AACzF,4FAAuF;AACvF,kGAA6F;AAC7F,kGAA6F;AAC7F,kGAA6F;AAC7F,oGAA8F;AAC9F,0FAAsF;AACtF,0EAAqE;AACrE,iEAA6D;AAsBtD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,8CAAiB;4BAAjB,iBAAiB;IApB7B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,gCAAc,CAAC;QACzB,SAAS,EAAE;YACT,8BAAa;YACb,2DAA2B;YAC3B,iDAAsB;YACtB,+CAAqB;YACrB,qDAAwB;YACxB,qDAAwB;YACxB,qDAAwB;YACxB,sDAAwB;YACxB,4CAAoB;YACpB,6BAAY;YACZ;gBACE,OAAO,EAAE,oCAAY;gBACrB,QAAQ,EAAE,2DAA2B;aACtC;SACF;QACD,WAAW,EAAE,CAAC,gDAAsB,CAAC;KACtC,CAAC;GACW,iBAAiB,CAAG"}
|
||||
@@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CreateApplicationHandler = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const application_interface_1 = require("../../domain/repositories/application.interface");
|
||||
const application_validator_1 = require("../../application/validators/application.validator");
|
||||
const application_entity_1 = require("../../domain/entities/application.entity");
|
||||
let CreateApplicationHandler = class CreateApplicationHandler {
|
||||
appRepo;
|
||||
validator;
|
||||
constructor(appRepo, validator) {
|
||||
this.appRepo = appRepo;
|
||||
this.validator = validator;
|
||||
}
|
||||
async execute(payload) {
|
||||
await this.validator.validateCreate(payload);
|
||||
const app = application_entity_1.ApplicationData.create({
|
||||
code: payload.code,
|
||||
name: payload.name,
|
||||
description: payload.description,
|
||||
icon: payload.icon,
|
||||
url: payload.url,
|
||||
applicationsClaim: payload.applicationsClaim,
|
||||
displayOrder: payload.displayOrder,
|
||||
});
|
||||
const created = await this.appRepo.create(app);
|
||||
return created;
|
||||
}
|
||||
};
|
||||
exports.CreateApplicationHandler = CreateApplicationHandler;
|
||||
exports.CreateApplicationHandler = CreateApplicationHandler = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [application_interface_1.IApplication, application_validator_1.ApplicationValidator])
|
||||
], CreateApplicationHandler);
|
||||
//# sourceMappingURL=create-application.handler.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"create-application.handler.js","sourceRoot":"","sources":["../../../../../src/modules/application/application/handlers/create-application.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiE;AACjE,2FAA+E;AAC/E,8FAA0F;AAC1F,iFAA2E;AAGpE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACN;IAAwC;IAArE,YAA6B,OAAqB,EAAmB,SAA+B;QAAvE,YAAO,GAAP,OAAO,CAAc;QAAmB,cAAS,GAAT,SAAS,CAAsB;IAAG,CAAC;IAExG,KAAK,CAAC,OAAO,CAAC,OAAY;QACxB,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAE7C,MAAM,GAAG,GAAG,oCAAe,CAAC,MAAM,CAAC;YACjC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;YAC5C,YAAY,EAAE,OAAO,CAAC,YAAY;SACnC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AAnBY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAE2B,oCAAY,EAA8B,4CAAoB;GADzF,wBAAwB,CAmBpC"}
|
||||
@@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DeleteApplicationHandler = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const application_interface_1 = require("../../domain/repositories/application.interface");
|
||||
let DeleteApplicationHandler = class DeleteApplicationHandler {
|
||||
appRepo;
|
||||
constructor(appRepo) {
|
||||
this.appRepo = appRepo;
|
||||
}
|
||||
async execute(id) {
|
||||
// ensure exists
|
||||
await this.appRepo.findById(id);
|
||||
await this.appRepo.delete(id);
|
||||
}
|
||||
};
|
||||
exports.DeleteApplicationHandler = DeleteApplicationHandler;
|
||||
exports.DeleteApplicationHandler = DeleteApplicationHandler = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [application_interface_1.IApplication])
|
||||
], DeleteApplicationHandler);
|
||||
//# sourceMappingURL=delete-application.handler.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"delete-application.handler.js","sourceRoot":"","sources":["../../../../../src/modules/application/application/handlers/delete-application.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2FAA+E;AAGxE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACN;IAA7B,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAEtD,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,gBAAgB;QAChB,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAChC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;CACF,CAAA;AARY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAE2B,oCAAY;GADvC,wBAAwB,CAQpC"}
|
||||
@@ -1,30 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GetApplicationHandler = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const application_interface_1 = require("../../domain/repositories/application.interface");
|
||||
let GetApplicationHandler = class GetApplicationHandler {
|
||||
appRepo;
|
||||
constructor(appRepo) {
|
||||
this.appRepo = appRepo;
|
||||
}
|
||||
async execute(id) {
|
||||
const app = await this.appRepo.findById(id);
|
||||
return app;
|
||||
}
|
||||
};
|
||||
exports.GetApplicationHandler = GetApplicationHandler;
|
||||
exports.GetApplicationHandler = GetApplicationHandler = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [application_interface_1.IApplication])
|
||||
], GetApplicationHandler);
|
||||
//# sourceMappingURL=get-application.handler.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"get-application.handler.js","sourceRoot":"","sources":["../../../../../src/modules/application/application/handlers/get-application.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2FAA+E;AAGxE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACH;IAA7B,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAEtD,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC5C,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAA;AAPY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAE2B,oCAAY;GADvC,qBAAqB,CAOjC"}
|
||||
@@ -1,30 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GetApplicationsHandler = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const application_interface_1 = require("../../domain/repositories/application.interface");
|
||||
let GetApplicationsHandler = class GetApplicationsHandler {
|
||||
appRepo;
|
||||
constructor(appRepo) {
|
||||
this.appRepo = appRepo;
|
||||
}
|
||||
async execute(query) {
|
||||
const res = await this.appRepo.find({ page: query.page, limit: query.limit, search: query.search || null });
|
||||
return res;
|
||||
}
|
||||
};
|
||||
exports.GetApplicationsHandler = GetApplicationsHandler;
|
||||
exports.GetApplicationsHandler = GetApplicationsHandler = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [application_interface_1.IApplication])
|
||||
], GetApplicationsHandler);
|
||||
//# sourceMappingURL=get-applications.handler.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"get-applications.handler.js","sourceRoot":"","sources":["../../../../../src/modules/application/application/handlers/get-applications.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2FAA+E;AAGxE,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACJ;IAA7B,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAEtD,KAAK,CAAC,OAAO,CAAC,KAAyD;QACrE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC;QAC5G,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAA;AAPY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAE2B,oCAAY;GADvC,sBAAsB,CAOlC"}
|
||||
@@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GetMeApplicationsHandler = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const application_interface_1 = require("../../domain/repositories/application.interface");
|
||||
let GetMeApplicationsHandler = class GetMeApplicationsHandler {
|
||||
appRepo;
|
||||
constructor(appRepo) {
|
||||
this.appRepo = appRepo;
|
||||
}
|
||||
async execute(applicationsClaimList) {
|
||||
if (!applicationsClaimList || applicationsClaimList.length === 0)
|
||||
return { data: [], total: 0 };
|
||||
// Only return active applications whose applicationsClaim exists in provided list
|
||||
const res = await this.appRepo.find({ page: 1, limit: 1000, isActive: true, applicationsClaimIn: applicationsClaimList });
|
||||
// sort by displayOrder asc
|
||||
res.data.sort((a, b) => (a.displayOrder ?? 0) - (b.displayOrder ?? 0));
|
||||
return res;
|
||||
}
|
||||
};
|
||||
exports.GetMeApplicationsHandler = GetMeApplicationsHandler;
|
||||
exports.GetMeApplicationsHandler = GetMeApplicationsHandler = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [application_interface_1.IApplication])
|
||||
], GetMeApplicationsHandler);
|
||||
//# sourceMappingURL=get-me-applications.handler.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"get-me-applications.handler.js","sourceRoot":"","sources":["../../../../../src/modules/application/application/handlers/get-me-applications.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2FAA+E;AAGxE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACN;IAA7B,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAEtD,KAAK,CAAC,OAAO,CAAC,qBAAkD;QAC9D,IAAI,CAAC,qBAAqB,IAAI,qBAAqB,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAEhG,kFAAkF;QAClF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,CAAC,CAAC;QAC1H,2BAA2B;QAC3B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,CAAC;QACvE,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAA;AAZY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAE2B,oCAAY;GADvC,wBAAwB,CAYpC"}
|
||||
@@ -1,38 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UpdateApplicationHandler = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const application_interface_1 = require("../../domain/repositories/application.interface");
|
||||
const application_validator_1 = require("../../application/validators/application.validator");
|
||||
let UpdateApplicationHandler = class UpdateApplicationHandler {
|
||||
appRepo;
|
||||
validator;
|
||||
constructor(appRepo, validator) {
|
||||
this.appRepo = appRepo;
|
||||
this.validator = validator;
|
||||
}
|
||||
async execute(id, payload) {
|
||||
const existing = await this.appRepo.findById(id);
|
||||
if (!existing)
|
||||
throw new Error('Application not found');
|
||||
await this.validator.validateUpdate(id, payload);
|
||||
existing.update(payload);
|
||||
const updated = await this.appRepo.update(existing);
|
||||
return updated;
|
||||
}
|
||||
};
|
||||
exports.UpdateApplicationHandler = UpdateApplicationHandler;
|
||||
exports.UpdateApplicationHandler = UpdateApplicationHandler = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [application_interface_1.IApplication, application_validator_1.ApplicationValidator])
|
||||
], UpdateApplicationHandler);
|
||||
//# sourceMappingURL=update-application.handler.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"update-application.handler.js","sourceRoot":"","sources":["../../../../../src/modules/application/application/handlers/update-application.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2FAA+E;AAC/E,8FAA0F;AAGnF,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACN;IAAwC;IAArE,YAA6B,OAAqB,EAAmB,SAA+B;QAAvE,YAAO,GAAP,OAAO,CAAc;QAAmB,cAAS,GAAT,SAAS,CAAsB;IAAG,CAAC;IAExG,KAAK,CAAC,OAAO,CAAC,EAAU,EAAE,OAAY;QACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAExD,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEjD,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACpD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AAbY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAE2B,oCAAY,EAA8B,4CAAoB;GADzF,wBAAwB,CAapC"}
|
||||
@@ -1,84 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ApplicationValidator = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const application_interface_1 = require("../../domain/repositories/application.interface");
|
||||
let ApplicationValidator = class ApplicationValidator {
|
||||
appRepo;
|
||||
constructor(appRepo) {
|
||||
this.appRepo = appRepo;
|
||||
}
|
||||
async validateCreate(payload) {
|
||||
if (!payload || !payload.code)
|
||||
throw new common_1.BadRequestException('code is required');
|
||||
if (!payload.name)
|
||||
throw new common_1.BadRequestException('name is required');
|
||||
if (!payload.applicationsClaim)
|
||||
throw new common_1.BadRequestException('applicationsClaim is required');
|
||||
// url validation if provided
|
||||
if (payload.url) {
|
||||
try {
|
||||
// allow relative urls
|
||||
if (!payload.url.startsWith('/') && !payload.url.startsWith('http')) {
|
||||
throw new Error('invalid');
|
||||
}
|
||||
// new URL(payload.url) // avoid throwing for relative
|
||||
}
|
||||
catch (e) {
|
||||
throw new common_1.BadRequestException('invalid url');
|
||||
}
|
||||
}
|
||||
// displayOrder
|
||||
if (payload.displayOrder !== undefined && typeof payload.displayOrder !== 'number') {
|
||||
throw new common_1.BadRequestException('invalid displayOrder');
|
||||
}
|
||||
// unique code
|
||||
const byCode = await this.appRepo.findByCode(payload.code);
|
||||
if (byCode)
|
||||
throw new common_1.BadRequestException('duplicate code');
|
||||
const byClaim = await this.appRepo.findByApplicationsClaim(payload.applicationsClaim);
|
||||
if (byClaim)
|
||||
throw new common_1.BadRequestException('duplicate applicationsClaim');
|
||||
}
|
||||
async validateUpdate(id, payload) {
|
||||
if (!payload)
|
||||
return;
|
||||
if (payload.url) {
|
||||
try {
|
||||
if (!payload.url.startsWith('/') && !payload.url.startsWith('http'))
|
||||
throw new Error('invalid');
|
||||
}
|
||||
catch (e) {
|
||||
throw new common_1.BadRequestException('invalid url');
|
||||
}
|
||||
}
|
||||
if (payload.displayOrder !== undefined && typeof payload.displayOrder !== 'number') {
|
||||
throw new common_1.BadRequestException('invalid displayOrder');
|
||||
}
|
||||
if (payload.code) {
|
||||
const existing = await this.appRepo.findByCode(payload.code);
|
||||
if (existing && existing.id !== id)
|
||||
throw new common_1.BadRequestException('duplicate code');
|
||||
}
|
||||
if (payload.applicationsClaim) {
|
||||
const existing = await this.appRepo.findByApplicationsClaim(payload.applicationsClaim);
|
||||
if (existing && existing.id !== id)
|
||||
throw new common_1.BadRequestException('duplicate applicationsClaim');
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.ApplicationValidator = ApplicationValidator;
|
||||
exports.ApplicationValidator = ApplicationValidator = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [application_interface_1.IApplication])
|
||||
], ApplicationValidator);
|
||||
//# sourceMappingURL=application.validator.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"application.validator.js","sourceRoot":"","sources":["../../../../../src/modules/application/application/validators/application.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiE;AACjE,2FAA+E;AAGxE,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IACF;IAA7B,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAEtD,KAAK,CAAC,cAAc,CAAC,OAAY;QAC/B,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,MAAM,IAAI,4BAAmB,CAAC,kBAAkB,CAAC,CAAC;QACjF,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,MAAM,IAAI,4BAAmB,CAAC,kBAAkB,CAAC,CAAC;QACrE,IAAI,CAAC,OAAO,CAAC,iBAAiB;YAAE,MAAM,IAAI,4BAAmB,CAAC,+BAA+B,CAAC,CAAC;QAE/F,6BAA6B;QAC7B,IAAI,OAAO,CAAC,GAAG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AAC;YAClG,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,IAAI,4BAAmB,CAAC,aAAa,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;QAED,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;YACnF,MAAM,IAAI,4BAAmB,CAAC,sBAAsB,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7D,IAAI,QAAQ,IAAI,QAAQ,CAAC,EAAE,KAAK,EAAE;gBAAE,MAAM,IAAI,4BAAmB,CAAC,gBAAgB,CAAC,CAAC;QACtF,CAAC;QAED,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YACvF,IAAI,QAAQ,IAAI,QAAQ,CAAC,EAAE,KAAK,EAAE;gBAAE,MAAM,IAAI,4BAAmB,CAAC,6BAA6B,CAAC,CAAC;QACnG,CAAC;IACH,CAAC;CACF,CAAA;AA3DY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAE2B,oCAAY;GADvC,oBAAoB,CA2DhC"}
|
||||
@@ -1,67 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ApplicationData = void 0;
|
||||
class ApplicationData {
|
||||
id;
|
||||
code;
|
||||
name;
|
||||
description;
|
||||
icon;
|
||||
url;
|
||||
applicationsClaim;
|
||||
isActive;
|
||||
displayOrder;
|
||||
createdAt;
|
||||
updatedAt;
|
||||
constructor(id, code, name, description, icon, url, applicationsClaim, isActive, displayOrder, createdAt, updatedAt) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.icon = icon;
|
||||
this.url = url;
|
||||
this.applicationsClaim = applicationsClaim;
|
||||
this.isActive = isActive;
|
||||
this.displayOrder = displayOrder;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
static create(data) {
|
||||
return new ApplicationData(crypto.randomUUID(), data.code, data.name, data.description ?? null, data.icon ?? null, data.url ?? null, data.applicationsClaim, true, data.displayOrder ?? 0, new Date(), new Date());
|
||||
}
|
||||
static restore(props) {
|
||||
return new ApplicationData(props.id, props.code, props.name, props.description ?? null, props.icon ?? null, props.url ?? null, props.applicationsClaim, props.isActive !== undefined ? props.isActive : true, props.displayOrder ?? 0, props.createdAt ?? null, props.updatedAt ?? null);
|
||||
}
|
||||
update(data) {
|
||||
if (data.code !== undefined)
|
||||
this.code = data.code;
|
||||
if (data.name !== undefined)
|
||||
this.name = data.name;
|
||||
if (data.description !== undefined)
|
||||
this.description = data.description;
|
||||
if (data.icon !== undefined)
|
||||
this.icon = data.icon;
|
||||
if (data.url !== undefined)
|
||||
this.url = data.url;
|
||||
if (data.applicationsClaim !== undefined)
|
||||
this.applicationsClaim = data.applicationsClaim;
|
||||
if (data.isActive !== undefined)
|
||||
this.isActive = data.isActive;
|
||||
if (data.displayOrder !== undefined)
|
||||
this.displayOrder = data.displayOrder;
|
||||
this.updatedAt = new Date();
|
||||
}
|
||||
toResponse() {
|
||||
return {
|
||||
id: this.id,
|
||||
code: this.code,
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
icon: this.icon,
|
||||
url: this.url,
|
||||
displayOrder: this.displayOrder,
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.ApplicationData = ApplicationData;
|
||||
//# sourceMappingURL=application.entity.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"application.entity.js","sourceRoot":"","sources":["../../../../../src/modules/application/domain/entities/application.entity.ts"],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,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC;IACJ,CAAC;CACF;AAnGD,0CAmGC"}
|
||||
@@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IApplication = void 0;
|
||||
class IApplication {
|
||||
}
|
||||
exports.IApplication = IApplication;
|
||||
//# sourceMappingURL=application.interface.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"application.interface.js","sourceRoot":"","sources":["../../../../../src/modules/application/domain/repositories/application.interface.ts"],"names":[],"mappings":";;;AAEA,MAAsB,YAAY;CASjC;AATD,oCASC"}
|
||||
@@ -1,23 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PrismaApplicationMapper = void 0;
|
||||
const application_entity_1 = require("../../domain/entities/application.entity");
|
||||
class PrismaApplicationMapper {
|
||||
static toDomain(model) {
|
||||
return application_entity_1.ApplicationData.restore({
|
||||
id: model.id,
|
||||
code: model.code,
|
||||
name: model.name,
|
||||
description: model.description,
|
||||
icon: model.icon,
|
||||
url: model.url,
|
||||
applicationsClaim: model.applicationsClaim,
|
||||
isActive: model.isActive,
|
||||
displayOrder: model.displayOrder,
|
||||
createdAt: model.createdAt,
|
||||
updatedAt: model.updatedAt,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.PrismaApplicationMapper = PrismaApplicationMapper;
|
||||
//# sourceMappingURL=prisma-application.mapper.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"prisma-application.mapper.js","sourceRoot":"","sources":["../../../../../src/modules/application/infrastructure/mappers/prisma-application.mapper.ts"],"names":[],"mappings":";;;AAAA,iFAA2E;AAE3E,MAAa,uBAAuB;IAClC,MAAM,CAAC,QAAQ,CAAC,KAAU;QACxB,OAAO,oCAAe,CAAC,OAAO,CAAC;YAC7B,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC,CAAC;IACL,CAAC;CACF;AAhBD,0DAgBC"}
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PrismaApplicationRepository = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const prisma_service_1 = require("../../../../shared/prisma.service");
|
||||
const prisma_application_mapper_1 = require("../mappers/prisma-application.mapper");
|
||||
let PrismaApplicationRepository = class PrismaApplicationRepository {
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
this.prisma = prisma;
|
||||
}
|
||||
async find(params) {
|
||||
const page = params.page && params.page > 0 ? params.page : 1;
|
||||
const limit = params.limit && params.limit > 0 ? params.limit : 25;
|
||||
const where = {};
|
||||
if (params.search) {
|
||||
where.OR = [
|
||||
{ name: { contains: params.search, mode: 'insensitive' } },
|
||||
{ code: { contains: params.search, mode: 'insensitive' } },
|
||||
{ description: { contains: params.search, mode: 'insensitive' } },
|
||||
];
|
||||
}
|
||||
if (params.isActive !== undefined && params.isActive !== null) {
|
||||
where.isActive = params.isActive;
|
||||
}
|
||||
if (params.applicationsClaimIn && params.applicationsClaimIn.length > 0) {
|
||||
where.applicationsClaim = { in: params.applicationsClaimIn };
|
||||
}
|
||||
const [total, items] = await Promise.all([
|
||||
this.prisma.application.count({ where }),
|
||||
this.prisma.application.findMany({ where, skip: (page - 1) * limit, take: limit, orderBy: { displayOrder: 'asc', createdAt: 'asc' } }),
|
||||
]);
|
||||
return { data: items.map(i => prisma_application_mapper_1.PrismaApplicationMapper.toDomain(i)), total };
|
||||
}
|
||||
async findById(id) {
|
||||
const row = await this.prisma.application.findUnique({ where: { id } });
|
||||
if (!row)
|
||||
throw new Error('Application not found');
|
||||
return prisma_application_mapper_1.PrismaApplicationMapper.toDomain(row);
|
||||
}
|
||||
async findByCode(code) {
|
||||
const row = await this.prisma.application.findUnique({ where: { code } });
|
||||
if (!row)
|
||||
return null;
|
||||
return prisma_application_mapper_1.PrismaApplicationMapper.toDomain(row);
|
||||
}
|
||||
async findByApplicationsClaim(claim) {
|
||||
const row = await this.prisma.application.findUnique({ where: { applicationsClaim: claim } });
|
||||
if (!row)
|
||||
return null;
|
||||
return prisma_application_mapper_1.PrismaApplicationMapper.toDomain(row);
|
||||
}
|
||||
async create(app) {
|
||||
const created = await this.prisma.application.create({ data: {
|
||||
id: app.id,
|
||||
code: app.code,
|
||||
name: app.name,
|
||||
description: app.description,
|
||||
icon: app.icon,
|
||||
url: app.url,
|
||||
applicationsClaim: app.applicationsClaim,
|
||||
isActive: app.isActive,
|
||||
displayOrder: app.displayOrder,
|
||||
} });
|
||||
return prisma_application_mapper_1.PrismaApplicationMapper.toDomain(created);
|
||||
}
|
||||
async update(app) {
|
||||
const updated = await this.prisma.application.update({ where: { id: app.id }, data: {
|
||||
code: app.code,
|
||||
name: app.name,
|
||||
description: app.description,
|
||||
icon: app.icon,
|
||||
url: app.url,
|
||||
applicationsClaim: app.applicationsClaim,
|
||||
isActive: app.isActive,
|
||||
displayOrder: app.displayOrder,
|
||||
} });
|
||||
return prisma_application_mapper_1.PrismaApplicationMapper.toDomain(updated);
|
||||
}
|
||||
async delete(appId) {
|
||||
await this.prisma.application.delete({ where: { id: appId } });
|
||||
}
|
||||
};
|
||||
exports.PrismaApplicationRepository = PrismaApplicationRepository;
|
||||
exports.PrismaApplicationRepository = PrismaApplicationRepository = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
], PrismaApplicationRepository);
|
||||
//# sourceMappingURL=prisma-application.repository.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"prisma-application.repository.js","sourceRoot":"","sources":["../../../../../src/modules/application/infrastructure/repositories/prisma-application.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,sEAAkE;AAElE,oFAA+E;AAIxE,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IACT;IAA7B,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD,KAAK,CAAC,IAAI,CAAC,MAAmI;QAC5I,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC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B;IADvC,IAAA,mBAAU,GAAE;qCAE0B,8BAAa;GADvC,2BAA2B,CAoFvC"}
|
||||
-136
@@ -1,136 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ApplicationsController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const jwt_auth_guard_1 = require("../../../../core/auth/guards/jwt-auth.guard");
|
||||
const current_user_guard_1 = require("../../../identity/presentation/guards/current-user.guard");
|
||||
const get_applications_handler_1 = require("../../application/handlers/get-applications.handler");
|
||||
const get_application_handler_1 = require("../../application/handlers/get-application.handler");
|
||||
const create_application_handler_1 = require("../../application/handlers/create-application.handler");
|
||||
const update_application_handler_1 = require("../../application/handlers/update-application.handler");
|
||||
const delete_application_handler_1 = require("../../application/handlers/delete-application.handler");
|
||||
const get_me_applications_handler_1 = require("../../application/handlers/get-me-applications.handler");
|
||||
let ApplicationsController = class ApplicationsController {
|
||||
getApplicationsHandler;
|
||||
getApplicationHandler;
|
||||
createApplicationHandler;
|
||||
updateApplicationHandler;
|
||||
deleteApplicationHandler;
|
||||
getMeApplicationsHandler;
|
||||
constructor(getApplicationsHandler, getApplicationHandler, createApplicationHandler, updateApplicationHandler, deleteApplicationHandler, getMeApplicationsHandler) {
|
||||
this.getApplicationsHandler = getApplicationsHandler;
|
||||
this.getApplicationHandler = getApplicationHandler;
|
||||
this.createApplicationHandler = createApplicationHandler;
|
||||
this.updateApplicationHandler = updateApplicationHandler;
|
||||
this.deleteApplicationHandler = deleteApplicationHandler;
|
||||
this.getMeApplicationsHandler = getMeApplicationsHandler;
|
||||
}
|
||||
async findAll(query) {
|
||||
const res = await this.getApplicationsHandler.execute({ page: query.page, limit: query.limit, search: query.search });
|
||||
return { success: true, data: res.data.map(a => a.toResponse ? a.toResponse() : a), meta: { total: res.total } };
|
||||
}
|
||||
async findOne(id) {
|
||||
const app = await this.getApplicationHandler.execute(id);
|
||||
return { success: true, data: app.toResponse(), meta: {} };
|
||||
}
|
||||
async create(body) {
|
||||
const created = await this.createApplicationHandler.execute(body);
|
||||
return { success: true, data: created.toResponse(), meta: {} };
|
||||
}
|
||||
async update(id, body) {
|
||||
const updated = await this.updateApplicationHandler.execute(id, body);
|
||||
return { success: true, data: updated.toResponse(), meta: {} };
|
||||
}
|
||||
async remove(id) {
|
||||
await this.deleteApplicationHandler.execute(id);
|
||||
return { success: true, data: null, meta: {} };
|
||||
}
|
||||
// Dashboard endpoint
|
||||
async me(req) {
|
||||
const ctx = req.raylabContext;
|
||||
const identity = ctx && ctx.identity ? ctx.identity : {};
|
||||
const applicationsClaimList = identity.applications || [];
|
||||
const res = await this.getMeApplicationsHandler.execute(applicationsClaimList);
|
||||
return { success: true, data: res.data.map(a => a.toResponse ? a.toResponse() : a), meta: { total: res.total } };
|
||||
}
|
||||
};
|
||||
exports.ApplicationsController = ApplicationsController;
|
||||
__decorate([
|
||||
(0, common_1.Get)('applications'),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, current_user_guard_1.CurrentUserGuard),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'List applications' }),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], ApplicationsController.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('applications/:id'),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, current_user_guard_1.CurrentUserGuard),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Get application by id' }),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], ApplicationsController.prototype, "findOne", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('applications'),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, current_user_guard_1.CurrentUserGuard),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Create application' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], ApplicationsController.prototype, "create", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)('applications/:id'),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, current_user_guard_1.CurrentUserGuard),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Update application' }),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], ApplicationsController.prototype, "update", null);
|
||||
__decorate([
|
||||
(0, common_1.Delete)('applications/:id'),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, current_user_guard_1.CurrentUserGuard),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Delete application' }),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], ApplicationsController.prototype, "remove", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('me/applications'),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, current_user_guard_1.CurrentUserGuard),
|
||||
(0, swagger_1.ApiOperation)({ summary: "Get current user's applications (filtered by Authentik claims)" }),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], ApplicationsController.prototype, "me", null);
|
||||
exports.ApplicationsController = ApplicationsController = __decorate([
|
||||
(0, swagger_1.ApiTags)('Applications'),
|
||||
(0, common_1.Controller)(),
|
||||
__metadata("design:paramtypes", [get_applications_handler_1.GetApplicationsHandler,
|
||||
get_application_handler_1.GetApplicationHandler,
|
||||
create_application_handler_1.CreateApplicationHandler,
|
||||
update_application_handler_1.UpdateApplicationHandler,
|
||||
delete_application_handler_1.DeleteApplicationHandler,
|
||||
get_me_applications_handler_1.GetMeApplicationsHandler])
|
||||
], ApplicationsController);
|
||||
//# sourceMappingURL=applications.controller.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"applications.controller.js","sourceRoot":"","sources":["../../../../../src/modules/application/presentation/controllers/applications.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0G;AAC1G,6CAAwD;AACxD,gFAA2E;AAC3E,iGAA4F;AAC5F,kGAA6F;AAC7F,gGAA2F;AAC3F,sGAAiG;AACjG,sGAAiG;AACjG,sGAAiG;AACjG,wGAAkG;AAI3F,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAEd;IACA;IACA;IACA;IACA;IACA;IANnB,YACmB,sBAA8C,EAC9C,qBAA4C,EAC5C,wBAAkD,EAClD,wBAAkD,EAClD,wBAAkD,EAClD,wBAAkD;Q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AAA,sBAAY,EAAC,EAAE,OAAO,EAAE,gEAAgE,EAAE,CAAC;IAClF,WAAA,IAAA,YAAG,GAAE,CAAA;;;;gDAOd;iCA7DU,sBAAsB;IAFlC,IAAA,iBAAO,EAAC,cAAc,CAAC;IACvB,IAAA,mBAAU,GAAE;qCAGgC,iDAAsB;QACvB,+CAAqB;QAClB,qDAAwB;QACxB,qDAAwB;QACxB,qDAAwB;QACxB,sDAAwB;GAP1D,sBAAsB,CA8DlC"}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var AuditEventHandler_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuditEventHandler = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const event_bus_service_1 = require("../../core/event-bus/event-bus.service");
|
||||
const audit_service_1 = require("./audit.service");
|
||||
let AuditEventHandler = AuditEventHandler_1 = class AuditEventHandler {
|
||||
events;
|
||||
auditService;
|
||||
logger = new common_1.Logger(AuditEventHandler_1.name);
|
||||
constructor(events, auditService) {
|
||||
this.events = events;
|
||||
this.auditService = auditService;
|
||||
this.events.subscribe('RolesSynchronized', (e) => this.handleRolesSynchronized(e));
|
||||
this.events.subscribe('UserAuthenticated', (e) => this.handleUserAuthenticated(e));
|
||||
this.events.subscribe('RoleCreated', (e) => this.handleGeneric(e));
|
||||
this.events.subscribe('RoleUpdated', (e) => this.handleGeneric(e));
|
||||
this.events.subscribe('RoleDeleted', (e) => this.handleGeneric(e));
|
||||
this.events.subscribe('PermissionCreated', (e) => this.handleGeneric(e));
|
||||
this.events.subscribe('PermissionUpdated', (e) => this.handleGeneric(e));
|
||||
this.events.subscribe('PermissionDeleted', (e) => this.handleGeneric(e));
|
||||
this.events.subscribe('UserActivated', (e) => this.handleGeneric(e));
|
||||
this.events.subscribe('UserDeactivated', (e) => this.handleGeneric(e));
|
||||
}
|
||||
async handleRolesSynchronized(event) {
|
||||
try {
|
||||
await this.auditService.createFromEvent(event);
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.error('Audit handler failed', e);
|
||||
}
|
||||
}
|
||||
async handleUserAuthenticated(event) {
|
||||
try {
|
||||
await this.auditService.createFromEvent(event);
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.error('Audit handler failed', e);
|
||||
}
|
||||
}
|
||||
async handleGeneric(event) {
|
||||
try {
|
||||
await this.auditService.createFromEvent(event);
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.error('Audit handler failed', e);
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.AuditEventHandler = AuditEventHandler;
|
||||
exports.AuditEventHandler = AuditEventHandler = AuditEventHandler_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [event_bus_service_1.EventBus, audit_service_1.AuditService])
|
||||
], AuditEventHandler);
|
||||
//# sourceMappingURL=audit.event-handler.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"audit.event-handler.js","sourceRoot":"","sources":["../../../src/modules/audit/audit.event-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8EAAkE;AAElE,mDAA+C;AAGxC,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAGC;IAAmC;IAF/C,MAAM,GAAG,IAAI,eAAM,CAAC,m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__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuditModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const audit_service_1 = require("./audit.service");
|
||||
const audit_event_handler_1 = require("./audit.event-handler");
|
||||
const prisma_service_1 = require("../../shared/prisma.service");
|
||||
const event_bus_service_1 = require("../../core/event-bus/event-bus.service");
|
||||
let AuditModule = class AuditModule {
|
||||
};
|
||||
exports.AuditModule = AuditModule;
|
||||
exports.AuditModule = AuditModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
providers: [audit_service_1.AuditService, audit_event_handler_1.AuditEventHandler, prisma_service_1.PrismaService, event_bus_service_1.EventBus],
|
||||
exports: [audit_service_1.AuditService],
|
||||
})
|
||||
], AuditModule);
|
||||
//# sourceMappingURL=audit.module.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"audit.module.js","sourceRoot":"","sources":["../../../src/modules/audit/audit.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mDAA+C;AAC/C,+DAA0D;AAC1D,gEAA4D;AAC5D,8EAAkE;AAM3D,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAJvB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,4BAAY,EAAE,uCAAiB,EAAE,8BAAa,EAAE,4BAAQ,CAAC;QACrE,OAAO,EAAE,CAAC,4BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"}
|
||||
Vendored
-46
@@ -1,46 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var AuditService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuditService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const prisma_service_1 = require("../../shared/prisma.service");
|
||||
let AuditService = AuditService_1 = class AuditService {
|
||||
prisma;
|
||||
logger = new common_1.Logger(AuditService_1.name);
|
||||
constructor(prisma) {
|
||||
this.prisma = prisma;
|
||||
}
|
||||
async createFromEvent(event) {
|
||||
try {
|
||||
// Map standard events to AuditLog entries
|
||||
await this.prisma.auditLog.create({
|
||||
data: {
|
||||
userId: event.payload?.userId || null,
|
||||
action: event.type,
|
||||
resource: event.payload?.resource || null,
|
||||
resourceId: event.payload?.resourceId || null,
|
||||
details: event.payload,
|
||||
createdAt: new Date(event.timestamp),
|
||||
},
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.error('Failed to write audit log', e);
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.AuditService = AuditService;
|
||||
exports.AuditService = AuditService = AuditService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
], AuditService);
|
||||
//# sourceMappingURL=audit.service.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"audit.service.js","sourceRoot":"","sources":["../../../src/modules/audit/audit.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,gEAA4D;AAIrD,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAGM;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,cAAY,CAAC,IAAI,CAAC,CAAC;IAExD,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD,KAAK,CAAC,eAAe,CAAC,KAAyB;QAC7C,IAAI,CAAC;YACH,0CAA0C;YAC1C,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAChC,IAAI,EAAE;oBACJ,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,IAAI;oBACrC,MAAM,EAAE,KAAK,CAAC,IAAI;oBAClB,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,QAAQ,IAAI,IAAI;oBACzC,UAAU,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,IAAI,IAAI;oBAC7C,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;iBACrC;aACF,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,CAAQ,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF,CAAA;AAtBY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAI0B,8BAAa;GAHvC,YAAY,CAsBxB"}
|
||||
Vendored
-110
@@ -1,110 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const auth_service_1 = require("./auth.service");
|
||||
let AuthController = class AuthController {
|
||||
authService;
|
||||
constructor(authService) {
|
||||
this.authService = authService;
|
||||
}
|
||||
async login(returnTo, res) {
|
||||
const redirect = await this.authService.createAuthorizationRedirect(returnTo);
|
||||
return res.redirect(302, redirect);
|
||||
}
|
||||
async callback(code, state, res) {
|
||||
const result = await this.authService.handleCallback(code, state);
|
||||
// set cookies
|
||||
const cookieOptions = {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
sameSite: 'lax',
|
||||
path: '/',
|
||||
};
|
||||
// access token cookie (internal JWT)
|
||||
res.cookie('raylab_jwt', result.accessToken, { ...cookieOptions, maxAge: result.expiresIn * 1000 });
|
||||
// refresh token cookie
|
||||
res.cookie('raylab_refresh', result.refreshToken, { ...cookieOptions, maxAge: result.refreshTtl * 1000 });
|
||||
return res.redirect(302, result.returnTo || '/');
|
||||
}
|
||||
async logout(req, res) {
|
||||
const refreshToken = req.cookies?.raylab_refresh || req.body?.refreshToken;
|
||||
const redirect = await this.authService.logout(refreshToken);
|
||||
return res.redirect(302, redirect);
|
||||
}
|
||||
async refresh(req) {
|
||||
const refreshToken = req.cookies?.raylab_refresh || req.body?.refreshToken;
|
||||
const result = await this.authService.refresh(refreshToken);
|
||||
return { success: true, data: result };
|
||||
}
|
||||
async me(req) {
|
||||
const token = (req.cookies?.raylab_jwt) || (req.headers.authorization && req.headers.authorization.replace(/^Bearer\s+/i, ''));
|
||||
const user = await this.authService.me(token);
|
||||
return { success: true, data: user };
|
||||
}
|
||||
};
|
||||
exports.AuthController = AuthController;
|
||||
__decorate([
|
||||
(0, common_1.Get)('login'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Start Authorization Code + PKCE login (redirect to Identity Provider)' }),
|
||||
__param(0, (0, common_1.Query)('returnTo')),
|
||||
__param(1, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "login", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('callback'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'OIDC callback endpoint' }),
|
||||
__param(0, (0, common_1.Query)('code')),
|
||||
__param(1, (0, common_1.Query)('state')),
|
||||
__param(2, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, String, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "callback", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('logout'),
|
||||
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Logout (invalidate internal session and redirect to identity provider logout)' }),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "logout", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('refresh'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Refresh internal JWT using internal refresh token' }),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "refresh", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('me'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Get current user from internal JWT (cookie or Authorization header)' }),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "me", null);
|
||||
exports.AuthController = AuthController = __decorate([
|
||||
(0, swagger_1.ApiTags)('Auth'),
|
||||
(0, common_1.Controller)('auth'),
|
||||
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
||||
], AuthController);
|
||||
//# sourceMappingURL=auth.controller.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../src/modules/auth/auth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,2CAAoG;AACpG,6CAAwD;AACxD,iDAA6C;AAKtC,IAAM,cAAc,GAApB,MAAM,cAAc;IACI;IAA7B,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAInD,AAAN,KAAK,CAAC,KAAK,CAAoB,QAA4B,EAAS,GAAa;QAC/E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;QAC9E,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAIK,AAAN,KAAK,CAAC,QAAQ,CAAgB,IAAY,EAAkB,KAAa,EAAS,GAAa;QAC7F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAA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AAE,OAAO,EAAE,mDAAmD,EAAE,CAAC;IAChE,WAAA,IAAA,YAAG,GAAE,CAAA;;;;6CAInB;AAIK;IAFL,IAAA,YAAG,EAAC,IAAI,CAAC;IACT,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,qEAAqE,EAAE,CAAC;IACvF,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wCAId;yBAvDU,cAAc;IAF1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAEyB,0BAAW;GAD1C,cAAc,CAwD1B"}
|
||||
Vendored
-75
@@ -1,75 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const auth_controller_1 = require("./auth.controller");
|
||||
const auth_service_1 = require("./auth.service");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const jwt_1 = require("@nestjs/jwt");
|
||||
const prisma_service_1 = require("../../shared/prisma.service");
|
||||
const user_interface_1 = require("../identity/domain/repositories/user.interface");
|
||||
const prisma_user_repository_1 = require("../identity/infrastructure/repositories/prisma-user.repository");
|
||||
const sync_identity_handler_1 = require("../identity/application/handlers/user/sync-identity.handler");
|
||||
const role_interface_1 = require("../identity/domain/repositories/role.interface");
|
||||
const prisma_role_repository_1 = require("../identity/infrastructure/repositories/prisma-role.repository");
|
||||
const i_auth_config_1 = require("../identity/application/config/i-auth-config");
|
||||
const env_auth_config_1 = require("../identity/application/config/env-auth-config");
|
||||
const redis_pkce_store_1 = require("./pkce/redis-pkce.store");
|
||||
const inmemory_refresh_store_1 = require("./refresh/inmemory-refresh.store");
|
||||
const oidc_service_1 = require("./oidc.service");
|
||||
const role_sync_service_1 = require("./role-sync.service");
|
||||
const redis_service_1 = require("../../shared/redis.service");
|
||||
const group_hash_service_1 = require("./group-hash.service");
|
||||
const authentication_service_1 = require("./authentication.service");
|
||||
const event_bus_service_1 = require("../../core/event-bus/event-bus.service");
|
||||
const audit_service_1 = require("../audit/audit.service");
|
||||
const authorization_module_1 = require("../authorization/authorization.module");
|
||||
let AuthModule = class AuthModule {
|
||||
};
|
||||
exports.AuthModule = AuthModule;
|
||||
exports.AuthModule = AuthModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
config_1.ConfigModule,
|
||||
authorization_module_1.AuthorizationModule,
|
||||
jwt_1.JwtModule.registerAsync({
|
||||
imports: [config_1.ConfigModule],
|
||||
useFactory: async (config) => ({
|
||||
secret: config.get('RAYLAB_JWT_SECRET') || 'raylab-secret',
|
||||
signOptions: { algorithm: 'HS256' },
|
||||
}),
|
||||
inject: [config_1.ConfigService],
|
||||
}),
|
||||
],
|
||||
controllers: [auth_controller_1.AuthController],
|
||||
providers: [
|
||||
auth_service_1.AuthService,
|
||||
prisma_service_1.PrismaService,
|
||||
prisma_user_repository_1.PrismaUserRepository,
|
||||
prisma_role_repository_1.PrismaRoleRepository,
|
||||
sync_identity_handler_1.SyncIdentityHandler,
|
||||
{ provide: user_interface_1.IUser, useClass: prisma_user_repository_1.PrismaUserRepository },
|
||||
{ provide: role_interface_1.IRole, useClass: prisma_role_repository_1.PrismaRoleRepository },
|
||||
{ provide: i_auth_config_1.IAuthConfig, useClass: env_auth_config_1.EnvAuthConfig },
|
||||
// In-memory PKCE and Refresh stores (Redis removed)
|
||||
redis_pkce_store_1.RedisPkceStore,
|
||||
inmemory_refresh_store_1.InMemoryRefreshStore,
|
||||
// OIDC & Role Sync
|
||||
oidc_service_1.OidcService,
|
||||
role_sync_service_1.RoleSyncService,
|
||||
group_hash_service_1.GroupHashService,
|
||||
authentication_service_1.AuthenticationService,
|
||||
event_bus_service_1.EventBus,
|
||||
audit_service_1.AuditService,
|
||||
redis_service_1.RedisService,
|
||||
],
|
||||
exports: [auth_service_1.AuthService, oidc_service_1.OidcService, role_sync_service_1.RoleSyncService, authentication_service_1.AuthenticationService, event_bus_service_1.EventBus],
|
||||
})
|
||||
], AuthModule);
|
||||
//# sourceMappingURL=auth.module.js.map
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../src/modules/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,uDAAmD;AACnD,iDAA6C;AAC7C,2CAA6D;AAC7D,qCAAwC;AACxC,gEAA4D;AAC5D,mFAAuE;AACvE,2GAAsG;AACtG,uGAAkG;AAClG,mFAAuE;AACvE,2GAAsG;AACtG,gFAA2E;AAC3E,oFAA+E;AAC/E,8DAAyD;AACzD,6EAAwE;AACxE,iDAA6C;AAC7C,2DAAsD;AACtD,8DAA0D;AAC1D,6DAAwD;AACxD,qEAAiE;AACjE,8EAAkE;AAClE,0DAAsD;AACtD,gFAA4E;AA0CrE,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IAvCtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY;YACZ,0CAAmB;YACnB,eAAS,CAAC,aAAa,CAAC;gBACtB,OAAO,EAAE,CAAC,qBAAY,CAAC;gBACvB,UAAU,EAAE,KAAK,EAAE,MAAqB,EAAE,EAAE,CAAC,CAAC;oBAC5C,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,eAAe;oBAC1D,WAAW,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE;iBACpC,CAAC;gBACF,MAAM,EAAE,CAAC,sBAAa,CAAC;aACxB,CAAC;SACH;QACD,WAAW,EAAE,CAAC,gCAAc,CAAC;QAC7B,SAAS,EAAE;YACT,0BAAW;YACX,8BAAa;YACb,6CAAoB;YACpB,6CAAoB;YACpB,2CAAmB;YACnB,EAAE,OAAO,EAAE,sBAAK,EAAE,QAAQ,EAAE,6CAAoB,EAAE;YAClD,EAAE,OAAO,EAAE,sBAAK,EAAE,QAAQ,EAAE,6CAAoB,EAAE;YAClD,EAAE,OAAO,EAAE,2BAAW,EAAE,QAAQ,EAAE,+BAAa,EAAE;YAEjD,oDAAoD;YACpD,iCAAc;YACd,6CAAoB;YAEpB,mBAAmB;YACnB,0BAAW;YACX,mCAAe;YACf,qCAAgB;YAChB,8CAAqB;YACrB,4BAAQ;YACR,4BAAY;YACZ,4BAAY;SACb;QACD,OAAO,EAAE,CAAC,0BAAW,EAAE,0BAAW,EAAE,mCAAe,EAAE,8CAAqB,EAAE,4BAAQ,CAAC;KACtF,CAAC;GACW,UAAU,CAAG"}
|
||||
Vendored
-209
@@ -1,209 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const jwt_1 = require("@nestjs/jwt");
|
||||
const sync_identity_handler_1 = require("../identity/application/handlers/user/sync-identity.handler");
|
||||
const user_interface_1 = require("../identity/domain/repositories/user.interface");
|
||||
const prisma_service_1 = require("../../shared/prisma.service");
|
||||
const redis_pkce_store_1 = require("./pkce/redis-pkce.store");
|
||||
const inmemory_refresh_store_1 = require("./refresh/inmemory-refresh.store");
|
||||
const openidClient = require('openid-client');
|
||||
let AuthService = class AuthService {
|
||||
config;
|
||||
jwtService;
|
||||
prisma;
|
||||
userRepository;
|
||||
syncIdentityHandler;
|
||||
pkceStore;
|
||||
refreshStore;
|
||||
constructor(config, jwtService, prisma, userRepository, syncIdentityHandler, pkceStore, refreshStore) {
|
||||
this.config = config;
|
||||
this.jwtService = jwtService;
|
||||
this.prisma = prisma;
|
||||
this.userRepository = userRepository;
|
||||
this.syncIdentityHandler = syncIdentityHandler;
|
||||
this.pkceStore = pkceStore;
|
||||
this.refreshStore = refreshStore;
|
||||
}
|
||||
issuer = null;
|
||||
client = null;
|
||||
async getIssuer() {
|
||||
if (this.issuer)
|
||||
return this.issuer;
|
||||
const issuerUrl = this.config.get('AUTHENTIK_ISSUER');
|
||||
if (!issuerUrl)
|
||||
throw new Error('AUTHENTIK_ISSUER not configured');
|
||||
this.issuer = await openidClient.Issuer.discover(issuerUrl);
|
||||
return this.issuer;
|
||||
}
|
||||
async getClient() {
|
||||
if (this.client)
|
||||
return this.client;
|
||||
const issuer = await this.getIssuer();
|
||||
const clientId = this.config.get('AUTHENTIK_CLIENT_ID');
|
||||
const clientSecret = this.config.get('AUTHENTIK_CLIENT_SECRET');
|
||||
if (!clientId)
|
||||
throw new Error('AUTHENTIK_CLIENT_ID not configured');
|
||||
this.client = new issuer.Client({ client_id: clientId, client_secret: clientSecret });
|
||||
return this.client;
|
||||
}
|
||||
async createAuthorizationRedirect(returnTo) {
|
||||
const client = await this.getClient();
|
||||
const redirectUri = this.config.get('AUTH_CALLBACK_URL') || `${this.config.get('APP_URL') || ''}/auth/callback`;
|
||||
const state = require('crypto').randomUUID();
|
||||
const code_verifier = openidClient.generators.codeVerifier();
|
||||
const code_challenge = await openidClient.generators.codeChallenge(code_verifier);
|
||||
const nonce = openidClient.generators.nonce();
|
||||
await this.pkceStore.save(state, { code_verifier, nonce, returnTo }, 300);
|
||||
const url = client.authorizationUrl({
|
||||
redirect_uri: redirectUri,
|
||||
scope: this.config.get('AUTHENTIK_DEFAULT_SCOPE') || 'openid email profile',
|
||||
response_type: 'code',
|
||||
code_challenge,
|
||||
code_challenge_method: 'S256',
|
||||
state,
|
||||
nonce,
|
||||
});
|
||||
return url;
|
||||
}
|
||||
async handleCallback(code, state) {
|
||||
const client = await this.getClient();
|
||||
const pkce = await this.pkceStore.get(state);
|
||||
if (!pkce)
|
||||
throw new common_1.UnauthorizedException('Invalid or expired state');
|
||||
// remove one-time state
|
||||
await this.pkceStore.remove(state);
|
||||
const redirectUri = this.config.get('AUTH_CALLBACK_URL') || `${this.config.get('APP_URL') || ''}/auth/callback`;
|
||||
// exchange code
|
||||
const tokenSet = await client.callback(redirectUri, { code, state }, { code_verifier: pkce.code_verifier, nonce: pkce.nonce });
|
||||
// verify id_token and get claims
|
||||
const claims = tokenSet.claims();
|
||||
// fetch userinfo if available
|
||||
let userInfo = null;
|
||||
try {
|
||||
if (tokenSet.access_token && client.userinfo) {
|
||||
userInfo = await client.userinfo(tokenSet.access_token);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// ignore
|
||||
}
|
||||
const identity = {
|
||||
sub: userInfo?.sub || claims.sub || null,
|
||||
preferred_username: userInfo?.preferred_username || userInfo?.username || userInfo?.email || claims.preferred_username || claims.email,
|
||||
email: userInfo?.email || claims.email,
|
||||
raw: { tokenSet, userInfo, claims },
|
||||
};
|
||||
// Sync identity to local user (create if needed)
|
||||
const domainUser = await this.syncIdentityHandler.execute(identity);
|
||||
// ensure active/not deleted
|
||||
if (!domainUser.isActive)
|
||||
throw new common_1.UnauthorizedException('User is not active');
|
||||
if (domainUser.deletedAt)
|
||||
throw new common_1.UnauthorizedException('User is deleted');
|
||||
// create internal JWT
|
||||
const jwtPayload = {
|
||||
sub: domainUser.id,
|
||||
preferred_username: domainUser.username,
|
||||
email: domainUser.email,
|
||||
};
|
||||
const expiresIn = Number(this.config.get('RAYLAB_JWT_EXPIRES_IN') || 3600);
|
||||
const access = this.jwtService.sign(jwtPayload, { expiresIn });
|
||||
// create internal refresh token
|
||||
const refreshToken = require('crypto').randomUUID();
|
||||
const refreshTtl = Number(this.config.get('RAYLAB_REFRESH_EXPIRES_IN') || 30 * 24 * 3600); // default 30 days
|
||||
await this.refreshStore.set(refreshToken, { userId: domainUser.id }, refreshTtl);
|
||||
return {
|
||||
accessToken: access,
|
||||
refreshToken,
|
||||
expiresIn,
|
||||
refreshTtl,
|
||||
user: {
|
||||
id: domainUser.id,
|
||||
username: domainUser.username,
|
||||
email: domainUser.email,
|
||||
roles: domainUser.roles || [],
|
||||
},
|
||||
returnTo: pkce.returnTo,
|
||||
};
|
||||
}
|
||||
async refresh(refreshToken) {
|
||||
if (!refreshToken)
|
||||
throw new common_1.UnauthorizedException('Missing refresh token');
|
||||
const data = await this.refreshStore.get(refreshToken);
|
||||
if (!data)
|
||||
throw new common_1.UnauthorizedException('Invalid refresh token');
|
||||
const userId = data.userId;
|
||||
// load user
|
||||
const domainUser = await this.userRepository.getById(userId);
|
||||
if (!domainUser)
|
||||
throw new common_1.UnauthorizedException('User not found');
|
||||
if (!domainUser.isActive)
|
||||
throw new common_1.UnauthorizedException('User is not active');
|
||||
// rotate refresh token
|
||||
await this.refreshStore.del(refreshToken);
|
||||
const newRefresh = require('crypto').randomUUID();
|
||||
const refreshTtl = Number(this.config.get('RAYLAB_REFRESH_EXPIRES_IN') || 30 * 24 * 3600);
|
||||
await this.refreshStore.set(newRefresh, { userId }, refreshTtl);
|
||||
const expiresIn = Number(this.config.get('RAYLAB_JWT_EXPIRES_IN') || 3600);
|
||||
const access = this.jwtService.sign({ sub: domainUser.id, preferred_username: domainUser.username, email: domainUser.email }, { expiresIn });
|
||||
return { accessToken: access, refreshToken: newRefresh, expiresIn, refreshTtl };
|
||||
}
|
||||
async logout(refreshToken) {
|
||||
if (refreshToken) {
|
||||
await this.refreshStore.del(refreshToken);
|
||||
}
|
||||
const issuer = await this.getIssuer();
|
||||
const endSession = issuer.metadata.end_session_endpoint;
|
||||
const postLogout = this.config.get('APP_URL') || '/';
|
||||
if (endSession) {
|
||||
// Redirect to identity provider logout
|
||||
const url = new URL(endSession);
|
||||
if (postLogout)
|
||||
url.searchParams.set('post_logout_redirect_uri', postLogout);
|
||||
return url.toString();
|
||||
}
|
||||
return postLogout;
|
||||
}
|
||||
async me(token) {
|
||||
if (!token)
|
||||
throw new common_1.UnauthorizedException('Missing token');
|
||||
try {
|
||||
const payload = this.jwtService.verify(token);
|
||||
const user = await this.userRepository.getById(payload.sub);
|
||||
if (!user)
|
||||
throw new common_1.UnauthorizedException('User not found');
|
||||
return { id: user.id, username: user.username, email: user.email, roles: user.roles || [] };
|
||||
}
|
||||
catch (e) {
|
||||
throw new common_1.UnauthorizedException('Invalid token');
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.AuthService = AuthService;
|
||||
exports.AuthService = AuthService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(3, (0, common_1.Inject)(user_interface_1.IUser)),
|
||||
__metadata("design:paramtypes", [config_1.ConfigService,
|
||||
jwt_1.JwtService,
|
||||
prisma_service_1.PrismaService,
|
||||
user_interface_1.IUser,
|
||||
sync_identity_handler_1.SyncIdentityHandler,
|
||||
redis_pkce_store_1.RedisPkceStore,
|
||||
inmemory_refresh_store_1.InMemoryRefreshStore])
|
||||
], AuthService);
|
||||
//# sourceMappingURL=auth.service.js.map
|
||||
-1
File diff suppressed because one or more lines are too long
-70
@@ -1,70 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var AuthenticationService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthenticationService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const oidc_service_1 = require("./oidc.service");
|
||||
const prisma_service_1 = require("../../shared/prisma.service");
|
||||
const role_sync_service_1 = require("./role-sync.service");
|
||||
const authorization_service_1 = require("../authorization/authorization.service");
|
||||
const event_bus_service_1 = require("../../core/event-bus/event-bus.service");
|
||||
let AuthenticationService = AuthenticationService_1 = class AuthenticationService {
|
||||
oidc;
|
||||
prisma;
|
||||
roleSync;
|
||||
authorization;
|
||||
events;
|
||||
logger = new common_1.Logger(AuthenticationService_1.name);
|
||||
constructor(oidc, prisma, roleSync, authorization, events) {
|
||||
this.oidc = oidc;
|
||||
this.prisma = prisma;
|
||||
this.roleSync = roleSync;
|
||||
this.authorization = authorization;
|
||||
this.events = events;
|
||||
}
|
||||
async authenticate(bearerToken) {
|
||||
// Validate token (signature/iss/aud/exp)
|
||||
const claims = await this.oidc.verifyToken(bearerToken);
|
||||
const sub = claims.sub;
|
||||
if (!sub)
|
||||
throw new Error('Invalid token: missing sub');
|
||||
// Resolve identity
|
||||
const identity = { sub, email: claims.email, preferred_username: claims.preferred_username, raw: claims };
|
||||
// Find or create user (materialize)
|
||||
let user = await this.prisma.user.findUnique({ where: { authentikId: sub } });
|
||||
if (!user) {
|
||||
user = await this.prisma.user.create({ data: { authentikId: sub, username: identity.preferred_username || identity.email || sub, email: identity.email || null } });
|
||||
}
|
||||
// Synchronize roles
|
||||
const groups = Array.isArray(claims.groups) ? claims.groups : [];
|
||||
await this.roleSync.syncUserRolesFromAuthentik(user.id, groups);
|
||||
// Load permissions
|
||||
const permissions = await this.authorization.getUserPermissions(user.id);
|
||||
// Build request context
|
||||
const rolesRows = await this.prisma.userRole.findMany({ where: { userId: user.id } });
|
||||
const roles = rolesRows.map((r) => r.roleId);
|
||||
const ctx = { user, identity, roles, permissions };
|
||||
// Publish domain event (legacy string event name expected by some subscribers/tests)
|
||||
this.events.publish('user.authenticated', { userId: user.id, identity });
|
||||
return ctx;
|
||||
}
|
||||
};
|
||||
exports.AuthenticationService = AuthenticationService;
|
||||
exports.AuthenticationService = AuthenticationService = AuthenticationService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [oidc_service_1.OidcService,
|
||||
prisma_service_1.PrismaService,
|
||||
role_sync_service_1.RoleSyncService,
|
||||
authorization_service_1.AuthorizationService,
|
||||
event_bus_service_1.EventBus])
|
||||
], AuthenticationService);
|
||||
//# sourceMappingURL=authentication.service.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../src/modules/auth/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,iDAA6C;AAC7C,gEAA4D;AAC5D,2DAAsD;AACtD,kFAA8E;AAC9E,8EAAkE;AAI3D,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAIb;IACA;IACA;IACA;IACA;IAPF,MAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAEjE,YACmB,IAAiB,EACjB,MAAqB,EACr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,CAAC,CAAC,EAAE,CAAC;QAC3E,MAAM,IAAI,CAAC,QAAQ,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAEhE,mBAAmB;QACnB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEzE,wBAAwB;QACxB,MAAM,SAAS,GAAG,MAAO,IAAI,CAAC,MAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC/F,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,GAAG,GAAmB,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;QAEnE,qFAAqF;QACrF,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEzE,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAA;AA7CY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAKc,0BAAW;QACT,8BAAa;QACX,mCAAe;QACV,4CAAoB;QAC3B,4BAAQ;GARxB,qBAAqB,CA6CjC"}
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
"use strict";
|
||||
// Login DTO removed. Password grant has been removed in favor of Authorization Code + PKCE flow.
|
||||
// Formerly contained username/password properties.
|
||||
//# sourceMappingURL=login.dto.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"login.dto.js","sourceRoot":"","sources":["../../../../src/modules/auth/dto/login.dto.ts"],"names":[],"mappings":";AAAA,iGAAiG;AACjG,mDAAmD"}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GroupHashService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const crypto = __importStar(require("crypto"));
|
||||
let GroupHashService = class GroupHashService {
|
||||
compute(groups) {
|
||||
const sorted = (groups || []).slice().sort();
|
||||
const data = sorted.join(',');
|
||||
return crypto.createHash('sha256').update(data, 'utf8').digest('hex');
|
||||
}
|
||||
};
|
||||
exports.GroupHashService = GroupHashService;
|
||||
exports.GroupHashService = GroupHashService = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], GroupHashService);
|
||||
//# sourceMappingURL=group-hash.service.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"group-hash.service.js","sourceRoot":"","sources":["../../../src/modules/auth/group-hash.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAAiC;AAG1B,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,OAAO,CAAC,MAAgB;QACtB,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;QAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC;CACF,CAAA;AANY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CAM5B"}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var OidcGuard_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OidcGuard = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const oidc_service_1 = require("../oidc.service");
|
||||
const authentication_service_1 = require("../authentication.service");
|
||||
let OidcGuard = OidcGuard_1 = class OidcGuard {
|
||||
oidc;
|
||||
authn;
|
||||
logger = new common_1.Logger(OidcGuard_1.name);
|
||||
constructor(oidc, authn) {
|
||||
this.oidc = oidc;
|
||||
this.authn = authn;
|
||||
}
|
||||
async canActivate(context) {
|
||||
const req = context.switchToHttp().getRequest();
|
||||
const auth = req.headers['authorization'] || req.headers['Authorization'];
|
||||
if (!auth || typeof auth !== 'string' || !auth.startsWith('Bearer '))
|
||||
throw new common_1.UnauthorizedException('Missing bearer token');
|
||||
const token = auth.substring(7).trim();
|
||||
try {
|
||||
const ctx = await this.authn.authenticate(token);
|
||||
// attach context to request under a structured key
|
||||
req.raylabContext = ctx;
|
||||
return true;
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.debug('Authentication failed', e.message);
|
||||
throw new common_1.UnauthorizedException('Invalid token or authentication failed');
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.OidcGuard = OidcGuard;
|
||||
exports.OidcGuard = OidcGuard = OidcGuard_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [oidc_service_1.OidcService, authentication_service_1.AuthenticationService])
|
||||
], OidcGuard);
|
||||
//# sourceMappingURL=oid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,CAAC;QAC5E,CAAC;IACH,CAAC;CACF,CAAA;AApBY,8BAAS;oBAAT,SAAS;IADrB,IAAA,mBAAU,GAAE;qCAGwB,0BAAW,EAA0B,8CAAqB;GAFlF,SAAS,CAoBrB"}
|
||||
Vendored
-89
@@ -1,89 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var OidcService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OidcService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const config_1 = require("@nestjs/config");
|
||||
let OidcService = OidcService_1 = class OidcService {
|
||||
config;
|
||||
jwksUri = null;
|
||||
issuer;
|
||||
audience;
|
||||
logger = new common_1.Logger(OidcService_1.name);
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
this.issuer = this.config.get('AUTHENTIK_ISSUER') || '';
|
||||
this.audience = this.config.get('AUTHENTIK_AUDIENCE') || undefined;
|
||||
const jwksUri = this.config.get('AUTHENTIK_JWKS_URI');
|
||||
if (jwksUri)
|
||||
this.jwksUri = jwksUri;
|
||||
else if (this.issuer)
|
||||
this.jwksUri = `${this.issuer.replace(/\/+$/, '')}/.well-known/jwks.json`;
|
||||
}
|
||||
async verifyToken(token) {
|
||||
if (!this.jwksUri)
|
||||
throw new Error('JWKS not configured');
|
||||
try {
|
||||
// dynamic import to avoid ESM loading issues in test environment
|
||||
const jose = await Promise.resolve().then(() => __importStar(require('jose')));
|
||||
const jwks = jose.createRemoteJWKSet(new URL(this.jwksUri));
|
||||
const { payload } = await jose.jwtVerify(token, jwks, {
|
||||
issuer: this.issuer || undefined,
|
||||
audience: this.audience,
|
||||
});
|
||||
return payload;
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.debug('Token verification failed', e.message);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.OidcService = OidcService;
|
||||
exports.OidcService = OidcService = OidcService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [config_1.ConfigService])
|
||||
], OidcService);
|
||||
//# sourceMappingURL=oidc.service.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"oidc.service.js","sourceRoot":"","sources":["../../../src/modules/auth/oidc.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA+C;AAGxC,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAMO;IALrB,OAAO,GAAkB,IAAI,CAAC;IAC9B,MAAM,CAAS;IACf,QAAQ,CAAgC;IACxC,MAAM,GAAG,IAAI,eAAM,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;IAE9C,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QAChD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAS,kBAAkB,CAAC,IAAI,EAAE,CAAC;QAChE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAS,oBAAoB,CAAC,IAAI,SAAS,CAAC;QAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAS,oBAAoB,CAAC,CAAC;QAC9D,IAAI,OAAO;YAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;aAC/B,IAAI,IAAI,CAAC,MAAM;YAAE,IAAI,CAAC,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,wBAAwB,CAAC;IAClG,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa;QAC7B,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAE1D,IAAI,CAAC;YACH,iEAAiE;YACjE,MAAM,IAAI,GAAG,wDAAa,MAAM,GAAC,CAAC;YAClC,MAAM,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5D,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE;gBACpD,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS;gBAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACjB,CAAC,CAAC;YAEV,OAAO,OAA8B,CAAC;QACxC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAG,CAAW,CAAC,OAAO,CAAC,CAAC;YACrE,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;CACF,CAAA;AAhCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAO0B,sBAAa;GANvC,WAAW,CAgCvB"}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RedisPkceStore = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let RedisPkceStore = class RedisPkceStore {
|
||||
// In-memory PKCE store replacing Redis-backed implementation
|
||||
map = new Map();
|
||||
cleanupInterval;
|
||||
constructor() {
|
||||
// periodic cleanup
|
||||
this.cleanupInterval = setInterval(() => {
|
||||
const now = Date.now();
|
||||
for (const [k, v] of this.map.entries()) {
|
||||
if (v.expiresAt <= now)
|
||||
this.map.delete(k);
|
||||
}
|
||||
}, 60 * 1000);
|
||||
}
|
||||
key(state) { return state; }
|
||||
async save(state, data, ttlSeconds = 300) {
|
||||
const expiresAt = Date.now() + ttlSeconds * 1000;
|
||||
this.map.set(this.key(state), { ...data, expiresAt });
|
||||
}
|
||||
async get(state) {
|
||||
const v = this.map.get(this.key(state));
|
||||
if (!v)
|
||||
return null;
|
||||
if (v.expiresAt <= Date.now()) {
|
||||
this.map.delete(this.key(state));
|
||||
return null;
|
||||
}
|
||||
return { code_verifier: v.code_verifier, nonce: v.nonce, returnTo: v.returnTo };
|
||||
}
|
||||
async remove(state) {
|
||||
this.map.delete(this.key(state));
|
||||
}
|
||||
onModuleDestroy() {
|
||||
if (this.cleanupInterval)
|
||||
clearInterval(this.cleanupInterval);
|
||||
}
|
||||
};
|
||||
exports.RedisPkceStore = RedisPkceStore;
|
||||
exports.RedisPkceStore = RedisPkceStore = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [])
|
||||
], RedisPkceStore);
|
||||
//# sourceMappingURL=redis-pkce.store.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"redis-pkce.store.js","sourceRoot":"","sources":["../../../../src/modules/auth/pkce/redis-pkce.store.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6D;AAKtD,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,6DAA6D;IACrD,GAAG,GAAG,IAAI,GAAG,EAAqB,CAAC;IACnC,eAAe,CAAkB;IAEzC;QACE,mBAAmB;QACnB,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;YACtC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE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C,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,eAAe;QACb,IAAI,IAAI,CAAC,eAAe;YAAE,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AApCY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;;GACA,cAAc,CAoC1B"}
|
||||
@@ -1,53 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.InMemoryRefreshStore = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let InMemoryRefreshStore = class InMemoryRefreshStore {
|
||||
map = new Map();
|
||||
cleanupInterval;
|
||||
constructor() {
|
||||
this.cleanupInterval = setInterval(() => {
|
||||
const now = Date.now();
|
||||
for (const [k, v] of this.map.entries()) {
|
||||
if (v.expiresAt <= now)
|
||||
this.map.delete(k);
|
||||
}
|
||||
}, 60 * 1000);
|
||||
}
|
||||
async set(token, data, ttlSeconds) {
|
||||
const expiresAt = Date.now() + ttlSeconds * 1000;
|
||||
this.map.set(token, { userId: data.userId, expiresAt });
|
||||
}
|
||||
async get(token) {
|
||||
const v = this.map.get(token);
|
||||
if (!v)
|
||||
return null;
|
||||
if (v.expiresAt <= Date.now()) {
|
||||
this.map.delete(token);
|
||||
return null;
|
||||
}
|
||||
return { userId: v.userId };
|
||||
}
|
||||
async del(token) {
|
||||
this.map.delete(token);
|
||||
}
|
||||
onModuleDestroy() {
|
||||
if (this.cleanupInterval)
|
||||
clearInterval(this.cleanupInterval);
|
||||
}
|
||||
};
|
||||
exports.InMemoryRefreshStore = InMemoryRefreshStore;
|
||||
exports.InMemoryRefreshStore = InMemoryRefreshStore = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [])
|
||||
], InMemoryRefreshStore);
|
||||
//# sourceMappingURL=inmemory-refresh.store.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"inmemory-refresh.store.js","sourceRoot":"","sources":["../../../../src/modules/auth/refresh/inmemory-refresh.store.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6D;AAKtD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IACvB,GAAG,GAAG,IAAI,GAAG,EAAwB,CAAC;IACtC,eAAe,CAAkB;IAEzC;QACE,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;YACtC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;gBACxC,IAAI,CAAC,CAAC,SAAS,IAAI,GAAG;oBAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAa,EAAE,IAAwB,EAAE,UAAkB;QACnE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,GAAG,IAAI,CAAC;QACjD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAa;QACrB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACpB,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAAC,OAAO,IAAI,CAAC;QAAC,CAAC;QACvE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAa;QACrB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,eAAe;QACb,IAAI,IAAI,CAAC,eAAe;YAAE,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AAhCY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;;GACA,oBAAoB,CAgChC"}
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
var RoleSyncService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RoleSyncService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const prisma_service_1 = require("../../shared/prisma.service");
|
||||
const event_bus_service_1 = require("../../core/event-bus/event-bus.service");
|
||||
const group_hash_service_1 = require("./group-hash.service");
|
||||
const authorization_service_1 = require("../authorization/authorization.service");
|
||||
let RoleSyncService = RoleSyncService_1 = class RoleSyncService {
|
||||
prisma;
|
||||
groupHash;
|
||||
permissionCache;
|
||||
events;
|
||||
logger = new common_1.Logger(RoleSyncService_1.name);
|
||||
constructor(prisma, groupHash, permissionCache, events) {
|
||||
this.prisma = prisma;
|
||||
this.groupHash = groupHash;
|
||||
this.permissionCache = permissionCache;
|
||||
this.events = events;
|
||||
}
|
||||
computeGroupHash(groups) {
|
||||
return this.groupHash.compute(groups || []);
|
||||
}
|
||||
async mapGroupsToRoleIds(groups) {
|
||||
if (!groups || groups.length === 0)
|
||||
return [];
|
||||
const mappings = await this.prisma.authGroupRoleMapping.findMany({ where: { authGroup: { in: groups } } });
|
||||
const roleIds = mappings.map((m) => m.roleId);
|
||||
return Array.from(new Set(roleIds));
|
||||
}
|
||||
async syncUserRolesFromAuthentik(userId, groups) {
|
||||
const groupHash = this.computeGroupHash(groups || []);
|
||||
const user = await this.prisma.user.findUnique({ where: { id: userId } });
|
||||
if (!user)
|
||||
throw new Error('User not found');
|
||||
if (user.lastGroupHash === groupHash) {
|
||||
this.logger.debug('Group hash unchanged, skipping sync');
|
||||
return { skipped: true };
|
||||
}
|
||||
const roleIds = await this.mapGroupsToRoleIds(groups || []);
|
||||
const previousRoleRows = await this.prisma.userRole.findMany({ where: { userId, source: 'AUTHENTIK' }, select: { roleId: true } });
|
||||
const previousRoles = previousRoleRows.map((r) => r.roleId);
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await tx.userRole.deleteMany({ where: { userId: userId, source: 'AUTHENTIK' } });
|
||||
if (roleIds.length > 0) {
|
||||
const createData = roleIds.map((rid) => ({ userId, roleId: rid, source: 'AUTHENTIK' }));
|
||||
await tx.userRole.createMany({ data: createData, skipDuplicates: true });
|
||||
}
|
||||
await tx.user.update({ where: { id: userId }, data: { lastGroupHash: groupHash } });
|
||||
});
|
||||
// Invalidate permission cache through abstraction
|
||||
try {
|
||||
await this.permissionCache.invalidate(userId);
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.error('Failed to invalidate permission cache', e);
|
||||
}
|
||||
// Publish event for audit and other subscribers
|
||||
this.events.publish({
|
||||
id: require('crypto').randomUUID(),
|
||||
timestamp: new Date().toISOString(),
|
||||
type: 'RolesSynchronized',
|
||||
payload: { userId, groups, assignedRoleIds: roleIds, previousRoles },
|
||||
});
|
||||
return { skipped: false, assignedRoleIds: roleIds };
|
||||
}
|
||||
};
|
||||
exports.RoleSyncService = RoleSyncService;
|
||||
exports.RoleSyncService = RoleSyncService = RoleSyncService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(2, (0, common_1.Inject)(authorization_service_1.PERMISSION_CACHE)),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService,
|
||||
group_hash_service_1.GroupHashService, Object, event_bus_service_1.EventBus])
|
||||
], RoleSyncService);
|
||||
//# sourceMappingURL=role-sync.service.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"role-sync.service.js","sourceRoot":"","sources":["../../../src/modules/auth/role-sync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,gEAA4D;AAE5D,8EAAkE;AAClE,6DAAwD;AACxD,kFAA0E;AAGnE,IAAM,eAAe,uBAArB,MAAM,eAAe;IAIP;IACA;IAC0B;IAC1B;IANF,MAAM,GA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MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;QACtF,CAAC,CAAC,CAAC;QAEH,kDAAkD;QAClD,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,CAAQ,CAAC,CAAC;QACvE,CAAC;QAED,gDAAgD;QAChD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YAClB,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE;YAClC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,EAAE;SACrE,CAAC,CAAC;QAEH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;IACtD,CAAC;CACF,CAAA;AAjEY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,wCAAgB,CAAC,CAAA;qCAFA,8BAAa;QACV,qCAAgB,UAEnB,4BAAQ;GAPxB,eAAe,CAiE3B"}
|
||||
@@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=authorization.service.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"authorization.service.js","sourceRoot":"","sources":["../../../../src/modules/authorization/application/authorization.service.ts"],"names":[],"mappings":""}
|
||||
@@ -1,29 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthorizationModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const authorization_service_1 = require("./authorization.service");
|
||||
const prisma_service_1 = require("../../shared/prisma.service");
|
||||
const redis_service_1 = require("../../shared/redis.service");
|
||||
const redis_permission_cache_service_1 = require("./cache/redis-permission-cache.service");
|
||||
let AuthorizationModule = class AuthorizationModule {
|
||||
};
|
||||
exports.AuthorizationModule = AuthorizationModule;
|
||||
exports.AuthorizationModule = AuthorizationModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
providers: [
|
||||
authorization_service_1.AuthorizationService,
|
||||
prisma_service_1.PrismaService,
|
||||
redis_service_1.RedisService,
|
||||
{ provide: authorization_service_1.PERMISSION_CACHE, useClass: redis_permission_cache_service_1.RedisPermissionCache },
|
||||
],
|
||||
exports: [authorization_service_1.AuthorizationService, authorization_service_1.PERMISSION_CACHE],
|
||||
})
|
||||
], AuthorizationModule);
|
||||
//# sourceMappingURL=authorization.module.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"authorization.module.js","sourceRoot":"","sources":["../../../src/modules/authorization/authorization.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mEAAiF;AACjF,gEAA4D;AAC5D,8DAA0D;AAC1D,2FAA8E;AAWvE,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAAG,CAAA;AAAtB,kDAAmB;8BAAnB,mBAAmB;IAT/B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,4CAAoB;YACpB,8BAAa;YACb,4BAAY;YACZ,EAAE,OAAO,EAAE,wCAAgB,EAAE,QAAQ,EAAE,qDAAoB,EAAE;SAC9D;QACD,OAAO,EAAE,CAAC,4CAAoB,EAAE,wCAAgB,CAAC;KAClD,CAAC;GACW,mBAAmB,CAAG"}
|
||||
@@ -1,71 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
var AuthorizationService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthorizationService = exports.PERMISSION_CACHE = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const prisma_service_1 = require("../../shared/prisma.service");
|
||||
exports.PERMISSION_CACHE = 'PERMISSION_CACHE';
|
||||
let AuthorizationService = AuthorizationService_1 = class AuthorizationService {
|
||||
prisma;
|
||||
cache;
|
||||
logger = new common_1.Logger(AuthorizationService_1.name);
|
||||
constructor(prisma, cache) {
|
||||
this.prisma = prisma;
|
||||
this.cache = cache;
|
||||
}
|
||||
async getUserPermissions(userId) {
|
||||
try {
|
||||
const cached = await this.cache.get(userId);
|
||||
if (cached)
|
||||
return cached;
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.debug('PermissionCache get failed', e);
|
||||
}
|
||||
const rows = await this.prisma.$queryRaw `
|
||||
SELECT p.code as code
|
||||
FROM "UserRole" ur
|
||||
JOIN "RolePermission" rp ON rp.role_id = ur.role_id
|
||||
JOIN "Permission" p ON p.id = rp.permission_id
|
||||
WHERE ur.user_id = ${userId}`;
|
||||
const perms = Array.isArray(rows) ? rows.map((r) => r.code) : [];
|
||||
try {
|
||||
await this.cache.set(userId, perms);
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.debug('PermissionCache set failed', e);
|
||||
}
|
||||
return perms;
|
||||
}
|
||||
async hasPermission(userId, permissionCode) {
|
||||
const perms = await this.getUserPermissions(userId);
|
||||
return perms.includes(permissionCode);
|
||||
}
|
||||
async invalidateUserPermissions(userId) {
|
||||
try {
|
||||
await this.cache.invalidate(userId);
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.debug('PermissionCache invalidate failed', e);
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.AuthorizationService = AuthorizationService;
|
||||
exports.AuthorizationService = AuthorizationService = AuthorizationService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(1, (0, common_1.Inject)(exports.PERMISSION_CACHE)),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService, Object])
|
||||
], AuthorizationService);
|
||||
//# sourceMappingURL=authorization.service.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"authorization.service.js","sourceRoot":"","sources":["../../../src/modules/authorization/authorization.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,gEAA4D;AAG/C,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AAG5C,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAGF;IAAkE;IAF9E,MAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAEhE,YAA6B,MAAqB,EAA6C,KAAsB;QAAxF,WAAM,GAAN,MAAM,CAAe;QAA6C,UAAK,GAAL,KAAK,CAAiB;IAAG,CAAC;IAEzH,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AC,KAAK,CAAC,mCAAmC,EAAE,CAAQ,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF,CAAA;AA3CY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAI0C,WAAA,IAAA,eAAM,EAAC,wBAAgB,CAAC,CAAA;qCAAxC,8BAAa;GAHvC,oBAAoB,CA2ChC"}
|
||||
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=permission-cache.interface.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"permission-cache.interface.js","sourceRoot":"","sources":["../../../../src/modules/authorization/cache/permission-cache.interface.ts"],"names":[],"mappings":""}
|
||||
@@ -1,48 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RedisPermissionCache = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const redis_service_1 = require("../../../shared/redis.service");
|
||||
let RedisPermissionCache = class RedisPermissionCache {
|
||||
redis;
|
||||
TTL = 60 * 5;
|
||||
constructor(redis) {
|
||||
this.redis = redis;
|
||||
}
|
||||
key(userId) {
|
||||
const { CacheKeys } = require('../../../shared/cache-keys');
|
||||
return CacheKeys.permission(userId);
|
||||
}
|
||||
async get(userId) {
|
||||
const data = await this.redis.get(this.key(userId));
|
||||
if (!data)
|
||||
return null;
|
||||
try {
|
||||
return JSON.parse(data);
|
||||
}
|
||||
catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
async set(userId, permissions, ttlSeconds) {
|
||||
await this.redis.set(this.key(userId), JSON.stringify(permissions), ttlSeconds ?? this.TTL);
|
||||
}
|
||||
async invalidate(userId) {
|
||||
await this.redis.del(this.key(userId));
|
||||
}
|
||||
};
|
||||
exports.RedisPermissionCache = RedisPermissionCache;
|
||||
exports.RedisPermissionCache = RedisPermissionCache = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [redis_service_1.RedisService])
|
||||
], RedisPermissionCache);
|
||||
//# sourceMappingURL=redis-permission-cache.service.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"redis-permission-cache.service.js","sourceRoot":"","sources":["../../../../src/modules/authorization/cache/redis-permission-cache.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,iEAA6D;AAGtD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAGF;IAFZ,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;IAE9B,YAA6B,KAAmB;QAAnB,UAAK,GAAL,KAAK,CAAc;IAAG,CAAC;IAE5C,GAAG,CAAC,MAAc;QACxB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAC5D,OAAO,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAc;QACtB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAa,CAAC;QACtC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAc,EAAE,WAAqB,EAAE,UAAmB;QAClE,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,UAAU,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9F,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AA3BY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAIyB,4BAAY;GAHrC,oBAAoB,CA2BhC"}
|
||||
@@ -1,52 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createPermissionGuard = exports.PermissionGuard = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const authorization_service_1 = require("../authorization.service");
|
||||
let PermissionGuard = class PermissionGuard {
|
||||
authz;
|
||||
permission;
|
||||
constructor(authz, permission) {
|
||||
this.authz = authz;
|
||||
this.permission = permission;
|
||||
}
|
||||
async canActivate(context) {
|
||||
const req = context.switchToHttp().getRequest();
|
||||
const user = req.raylab?.user;
|
||||
if (!user)
|
||||
throw new common_1.ForbiddenException('Missing user');
|
||||
const allowed = await this.authz.hasPermission(user.id, this.permission);
|
||||
if (!allowed)
|
||||
throw new common_1.ForbiddenException('Forbidden');
|
||||
return true;
|
||||
}
|
||||
};
|
||||
exports.PermissionGuard = PermissionGuard;
|
||||
exports.PermissionGuard = PermissionGuard = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [authorization_service_1.AuthorizationService, String])
|
||||
], PermissionGuard);
|
||||
// Factory to create guard instances with permission string (used in decorators)
|
||||
const createPermissionGuard = (permission) => {
|
||||
let _Guard = class _Guard extends PermissionGuard {
|
||||
constructor(authz) {
|
||||
super(authz, permission);
|
||||
}
|
||||
};
|
||||
_Guard = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [authorization_service_1.AuthorizationService])
|
||||
], _Guard);
|
||||
return _Guard;
|
||||
};
|
||||
exports.createPermissionGuard = createPermissionGuard;
|
||||
//# sourceMappingURL=permission.guard.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"permission.guard.js","sourceRoot":"","sources":["../../../../src/modules/authorization/guards/permission.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA+F;AAC/F,oEAAgE;AAGzD,IAAM,eAAe,GAArB,MAAM,eAAe;IACG;IAA8C;IAA3E,YAA6B,KAA2B,EAAmB,UAAkB;QAAhE,UAAK,GAAL,KAAK,CAAsB;QAAmB,eAAU,GAAV,UAAU,CAAQ;IAAG,CAAC;IAEjG,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC;QAC9B,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,2BAAkB,CAAC,cAAc,CAAC,CAAC;QAExD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACzE,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,2BAAkB,CAAC,WAAW,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAZY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAEyB,4CAAoB;GAD7C,eAAe,CAY3B;AAED,gFAAgF;AACzE,MAAM,qBAAqB,GAAG,CAAC,UAAkB,EAAE,EAAE;IAC1D,IACM,MAAM,GADZ,MACM,MAAO,SAAQ,eAAe;QAClC,YAAY,KAA2B;YACrC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAC3B,CAAC;KACF,CAAA;IAJK,MAAM;QADX,IAAA,mBAAU,GAAE;yCAEQ,4CAAoB;OADnC,MAAM,CAIX;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AARW,QAAA,qBAAqB,yBAQhC"}
|
||||
@@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Permissions = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const Permissions = (...permissions) => (0, common_1.SetMetadata)('permissions', permissions);
|
||||
exports.Permissions = Permissions;
|
||||
//# sourceMappingURL=permission.decorator.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user