feat: add secret settings manager and migration for legacy settings
- Implemented SecretSettingsManager to handle secret settings with encryption. - Added functionality to migrate legacy plaintext settings into encrypted storage. - Introduced methods for setting, getting, and clearing secret settings. - Created tests for verifying the migration and canonicalization of secret settings. - Updated app state to handle service updates via socket communication. - Added interface for push service updates to manage service state changes.
This commit is contained in:
@@ -985,6 +985,56 @@ startAutoRefresh();
|
||||
let socketClient: InstanceType<typeof plugins.typedsocket.TypedSocket> | null = null;
|
||||
const socketRouter = new plugins.domtools.plugins.typedrequest.TypedRouter();
|
||||
|
||||
const upsertService = (
|
||||
services: interfaces.data.IService[],
|
||||
service: interfaces.data.IService,
|
||||
): interfaces.data.IService[] => {
|
||||
const existingIndex = services.findIndex((item) => item.name === service.name);
|
||||
if (existingIndex === -1) {
|
||||
return [...services, service];
|
||||
}
|
||||
|
||||
const updatedServices = [...services];
|
||||
updatedServices[existingIndex] = service;
|
||||
return updatedServices;
|
||||
};
|
||||
|
||||
socketRouter.addTypedHandler(
|
||||
new plugins.domtools.plugins.typedrequest.TypedHandler<interfaces.requests.IReq_PushServiceUpdate>(
|
||||
'pushServiceUpdate',
|
||||
async (dataArg) => {
|
||||
const state = servicesStatePart.getState();
|
||||
let services = state.services;
|
||||
let currentService = state.currentService;
|
||||
let currentServiceLogs = state.currentServiceLogs;
|
||||
let currentServiceStats = state.currentServiceStats;
|
||||
|
||||
if (dataArg.action === 'deleted') {
|
||||
services = services.filter((service) => service.name !== dataArg.serviceName);
|
||||
if (currentService?.name === dataArg.serviceName) {
|
||||
currentService = null;
|
||||
currentServiceLogs = [];
|
||||
currentServiceStats = null;
|
||||
}
|
||||
} else if (dataArg.service) {
|
||||
services = upsertService(services, dataArg.service);
|
||||
if (currentService?.name === dataArg.service.name) {
|
||||
currentService = dataArg.service;
|
||||
}
|
||||
}
|
||||
|
||||
servicesStatePart.setState({
|
||||
...state,
|
||||
services,
|
||||
currentService,
|
||||
currentServiceLogs,
|
||||
currentServiceStats,
|
||||
});
|
||||
return {};
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// Handle server-pushed platform service log entries
|
||||
socketRouter.addTypedHandler(
|
||||
new plugins.domtools.plugins.typedrequest.TypedHandler<interfaces.requests.IReq_PushPlatformServiceLog>(
|
||||
|
||||
Reference in New Issue
Block a user