mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
45564b0a8a
Fold the 1497-line services/authService.ts into the DI-native nest/auth
domain (Wave-5 chain opener, unblocked by the atlas fold):
- Pure crypto half (backup-code hash/match/generate, stripUserForClient,
key masking, the import-time DUMMY_PASSWORD_HASH timing equaliser and
avatarDir mkdir — documented parity exceptions) moves verbatim to the
plain module nest/auth/auth.helpers.ts.
- DB half folds into AuthService over DatabaseService + injected
PermissionsService (ex permissions.bridge) + AtlasService (ex
atlas.bridge, deleted on schedule). mfaSetupPending and the per-email
reset throttle stay module-scoped so the bridge and container instances
share them; avatarDir and require('../../../package.json') re-anchor one
directory deeper — with the two injection swaps, the only non-verbatim
lines. Controller-facing method surface unchanged.
- New 8-export auth.bridge.ts for out-of-container consumers: mcp/index.ts
token verification, the journey/notifications/transports registrars'
isDemoUser, and the still-legacy adminService/oidcService/passkeyService.
- 15 domain *.mcp.ts demo guards now inject AuthService (their modules
import AuthModule); atlas.mcp.ts alone stays on the bridge because
AuthService injects AtlasService and the reverse module edge would close
an AuthModule<->AtlasModule cycle (places.mcp precedent). OidcService and
PasskeyEnabledGuard inject AuthService too.
- Tests move with case IDs preserved: authService.test.ts ->
auth.helpers.test.ts, authServiceDb.test.ts -> auth.service.test.ts
(+ AUTH-BR-001..007 bridge delegation, + AUTH-DB-050..088 pinning the
previously untested getAppConfig/login/MFA/reset/admin-settings branches
now under the src/nest coverage gate). auth.e2e converts DI-native (real
bcrypt, real audit rows); oidc.e2e swaps its dead path mock for an
instance spy; websocket/integration suites repoint to bridge/helpers.
Quirks preserved byte-for-byte (0-coord drop in getTravelStats,
un-transactioned registerUser/verifyMfaLogin multi-writes, unguarded
revokeUserSessions in deleteMcpToken, current! assertions in
updateApiKeys) — fixes land separately.
107 lines
6.5 KiB
TypeScript
107 lines
6.5 KiB
TypeScript
import { createTestRegistry, type McpRegistry } from '@trek/nest-mcp';
|
|
import { db } from '../../src/db/database';
|
|
import { trekMcpAccessPolicy, trekMcpValidateAccess } from '../../src/mcp/nest-mcp-policy';
|
|
import { AssignmentsMcp } from '../../src/nest/assignments/assignments.mcp';
|
|
import { AssignmentsService } from '../../src/nest/assignments/assignments.service';
|
|
import { AtlasMcp } from '../../src/nest/atlas/atlas.mcp';
|
|
import { AtlasService } from '../../src/nest/atlas/atlas.service';
|
|
import { AuthService } from '../../src/nest/auth/auth.service';
|
|
import { BudgetMcp } from '../../src/nest/budget/budget.mcp';
|
|
import { BudgetService } from '../../src/nest/budget/budget.service';
|
|
import { ExchangeRatesService } from '../../src/nest/budget/exchange-rates.service';
|
|
import { CategoriesMcp } from '../../src/nest/categories/categories.mcp';
|
|
import { CategoriesService } from '../../src/nest/categories/categories.service';
|
|
import { CollabMcp } from '../../src/nest/collab/collab.mcp';
|
|
import { CollabService } from '../../src/nest/collab/collab.service';
|
|
import { CollectionsMcp } from '../../src/nest/collections/collections.mcp';
|
|
import { CollectionsService } from '../../src/nest/collections/collections.service';
|
|
import { DatabaseService } from '../../src/nest/database/database.service';
|
|
import { DayNotesMcp } from '../../src/nest/days/day-notes.mcp';
|
|
import { DayNotesService } from '../../src/nest/days/day-notes.service';
|
|
import { DaysMcp } from '../../src/nest/days/days.mcp';
|
|
import { DaysService } from '../../src/nest/days/days.service';
|
|
import { MapsMcp } from '../../src/nest/maps/maps.mcp';
|
|
import { MapsService } from '../../src/nest/maps/maps.service';
|
|
import { PackingMcp } from '../../src/nest/packing/packing.mcp';
|
|
import { PackingService } from '../../src/nest/packing/packing.service';
|
|
import { PermissionsService } from '../../src/nest/permissions/permissions.service';
|
|
import { PlacesMcp } from '../../src/nest/places/places.mcp';
|
|
import { PlacesService } from '../../src/nest/places/places.service';
|
|
import { ReservationsMcp } from '../../src/nest/reservations/reservations.mcp';
|
|
import { ReservationsService } from '../../src/nest/reservations/reservations.service';
|
|
import { TagsMcp } from '../../src/nest/tags/tags.mcp';
|
|
import { TagsService } from '../../src/nest/tags/tags.service';
|
|
import { SettingsService } from '../../src/nest/settings/settings.service';
|
|
import { ShareMcp } from '../../src/nest/share/share.mcp';
|
|
import { ShareService } from '../../src/nest/share/share.service';
|
|
import { TodoMcp } from '../../src/nest/todo/todo.mcp';
|
|
import { TodoService } from '../../src/nest/todo/todo.service';
|
|
import { TransitMcp } from '../../src/nest/transit/transit.mcp';
|
|
import { TransitService } from '../../src/nest/transit/transit.service';
|
|
import { FilesService } from '../../src/nest/files/files.service';
|
|
import { TripsMcp } from '../../src/nest/trips/trips.mcp';
|
|
import { TripsService } from '../../src/nest/trips/trips.service';
|
|
import { VacayMcp } from '../../src/nest/vacay/vacay.mcp';
|
|
import { VacayService } from '../../src/nest/vacay/vacay.service';
|
|
import { RealtimeService } from '../../src/nest/realtime/realtime.service';
|
|
|
|
/**
|
|
* Hand-wired counterpart of the boot-time discovery in McpRegistryService,
|
|
* for the no-Nest MCP harness. One line per migrated domain — add the new
|
|
* @McpController instance here when a domain moves off the legacy registrar
|
|
* fan-out. Constructing against the `db` Proxy keeps per-file vi.mock's of
|
|
* src/db/database flowing through (same pattern as todo.bridge.ts).
|
|
*/
|
|
export function createMcpTestRegistry(): McpRegistry {
|
|
const dbService = new DatabaseService(db);
|
|
const permissionsService = new PermissionsService(dbService);
|
|
const authService = new AuthService(dbService, permissionsService, new AtlasService(dbService));
|
|
const realtimeService = new RealtimeService();
|
|
const daysService = new DaysService(dbService, permissionsService, realtimeService);
|
|
const exchangeRatesService = new ExchangeRatesService();
|
|
const budgetService = new BudgetService(dbService, permissionsService, exchangeRatesService, realtimeService);
|
|
const todoService = new TodoService(dbService, permissionsService, realtimeService);
|
|
const packingService = new PackingService(dbService, permissionsService, realtimeService);
|
|
const collabService = new CollabService(dbService, permissionsService, realtimeService);
|
|
const mapsService = new MapsService(dbService);
|
|
const placesService = new PlacesService(dbService, permissionsService, realtimeService, mapsService);
|
|
const reservationsService = new ReservationsService(dbService, permissionsService, budgetService, realtimeService);
|
|
const tripsService = new TripsService(
|
|
dbService,
|
|
todoService,
|
|
packingService,
|
|
new FilesService(dbService, permissionsService, realtimeService),
|
|
new ReservationsService(dbService, permissionsService, budgetService, realtimeService),
|
|
daysService,
|
|
permissionsService,
|
|
budgetService,
|
|
collabService,
|
|
new VacayService(dbService, realtimeService),
|
|
realtimeService,
|
|
placesService,
|
|
);
|
|
return createTestRegistry(
|
|
[
|
|
new TagsMcp(new TagsService(dbService), authService),
|
|
new CategoriesMcp(new CategoriesService(dbService)),
|
|
new TodoMcp(todoService, authService),
|
|
new PackingMcp(packingService, authService),
|
|
new BudgetMcp(budgetService, exchangeRatesService, dbService, authService),
|
|
new ReservationsMcp(reservationsService, daysService, budgetService, authService),
|
|
new DayNotesMcp(new DayNotesService(dbService, permissionsService, realtimeService), authService),
|
|
new DaysMcp(daysService, dbService, placesService, authService),
|
|
new AssignmentsMcp(new AssignmentsService(dbService, permissionsService, realtimeService), daysService, authService),
|
|
new CollabMcp(collabService, authService),
|
|
new VacayMcp(new VacayService(dbService, realtimeService), authService),
|
|
new TripsMcp(tripsService, todoService, collabService, authService),
|
|
new ShareMcp(new ShareService(dbService, new SettingsService(dbService), permissionsService), authService),
|
|
new MapsMcp(mapsService),
|
|
new PlacesMcp(placesService, mapsService, dbService, authService),
|
|
new CollectionsMcp(new CollectionsService(dbService, permissionsService, realtimeService), dbService, authService),
|
|
new TransitMcp(new TransitService(), daysService, reservationsService, dbService, authService),
|
|
new AtlasMcp(new AtlasService(dbService)),
|
|
],
|
|
{ accessPolicy: trekMcpAccessPolicy, validateAccess: trekMcpValidateAccess },
|
|
);
|
|
}
|