UNPKG

@dooor-ai/trust

Version:

TEE Attestation and Confidential Computing utilities for Dooor OS

61 lines 2.9 kB
"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 TEEHttpLoggerInterceptor_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.TEEHttpLoggerInterceptor = void 0; const common_1 = require("@nestjs/common"); const operators_1 = require("rxjs/operators"); let TEEHttpLoggerInterceptor = TEEHttpLoggerInterceptor_1 = class TEEHttpLoggerInterceptor { constructor() { this.logger = new common_1.Logger('TEE-HTTP-LOGGER'); } intercept(context, next) { const request = context.switchToHttp().getRequest(); const startTime = Date.now(); this.logger.log(`📥 Incoming: ${request.method} ${request.url}`); return next.handle().pipe((0, operators_1.tap)({ next: (response) => { const duration = Date.now() - startTime; this.logger.log(`✅ Completed: ${request.method} ${request.url} (${duration}ms)`); }, error: (error) => { const duration = Date.now() - startTime; this.logger.error(`❌ Failed: ${request.method} ${request.url} (${duration}ms) - ${error.message}`); } })); } static logOutboundCall(method, url, options) { const logger = new common_1.Logger('TEE-HTTP-OUTBOUND'); const callLog = { timestamp: new Date().toISOString(), method: method.toUpperCase(), url: url, userAgent: options?.headers?.['User-Agent'] || 'TEE-Backend', status: undefined, duration: undefined }; TEEHttpLoggerInterceptor_1.httpCalls.push(callLog); if (TEEHttpLoggerInterceptor_1.httpCalls.length > 100) { TEEHttpLoggerInterceptor_1.httpCalls.shift(); } logger.log(`📤 Outbound HTTP: ${method.toUpperCase()} ${url}`); return callLog; } static getHttpCallLogs() { return TEEHttpLoggerInterceptor_1.httpCalls; } static clearLogs() { TEEHttpLoggerInterceptor_1.httpCalls = []; } }; exports.TEEHttpLoggerInterceptor = TEEHttpLoggerInterceptor; TEEHttpLoggerInterceptor.httpCalls = []; exports.TEEHttpLoggerInterceptor = TEEHttpLoggerInterceptor = TEEHttpLoggerInterceptor_1 = __decorate([ (0, common_1.Injectable)() ], TEEHttpLoggerInterceptor); //# sourceMappingURL=http-logger.interceptor.js.map