Bind domain access to registered node type
This commit is contained in:
parent
f3a1ee82a2
commit
8807b99d98
15 changed files with 168 additions and 63 deletions
|
|
@ -329,14 +329,14 @@ const domainAccessOrchestrator = new DomainAccessOrchestrator(
|
|||
{
|
||||
async read() {
|
||||
const stored = applyStoredServerAuth();
|
||||
if (!stored) {
|
||||
return { accountVerified: false, nodeId: defaultPersonalServerId() || '' };
|
||||
}
|
||||
if (!stored) return { accountVerified: false, nodeId: '', nodeRegistrationVerified: false };
|
||||
try {
|
||||
const { response } = await forgejoRequest(stored.nodeId, '/api/v1/user', {}, { token: stored.token });
|
||||
return { accountVerified: response.ok, nodeId: stored.nodeId };
|
||||
// Forgejo proves only the account part. A dedicated node-registration
|
||||
// verifier must independently supply nodeRegistrationVerified.
|
||||
return { accountVerified: response.ok, nodeId: stored.nodeId, nodeRegistrationVerified: false };
|
||||
} catch {
|
||||
return { accountVerified: false, nodeId: stored.nodeId };
|
||||
return { accountVerified: false, nodeId: stored.nodeId, nodeRegistrationVerified: false };
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
@ -602,8 +602,11 @@ ipcMain.handle('server:session', async (_event, requestedNodeId?: string) => {
|
|||
return { authenticated: false, nodeId };
|
||||
}
|
||||
});
|
||||
ipcMain.handle('server:domain-access', async (_event, domainId = 'DOM-FIFTH-0001') => {
|
||||
return domainAccessOrchestrator.domainAccess(String(domainId));
|
||||
ipcMain.handle('server:domain-access', async (_event, input: { domainId?: unknown; nodeType?: unknown } = {}) => {
|
||||
const domainId = String(input.domainId ?? 'DOM-FIFTH-0001');
|
||||
const nodeType = input.nodeType === 'cloud-resident' ? 'cloud-resident' : input.nodeType === 'local-terminal' ? 'local-terminal' : null;
|
||||
if (!nodeType) throw new Error('domain_access_node_type_invalid');
|
||||
return domainAccessOrchestrator.domainAccess(domainId, nodeType);
|
||||
});
|
||||
ipcMain.handle('server:login', async (_event, input: { nodeId: string; username: string; password: string }) => {
|
||||
const username = String(input.username || '').trim();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ contextBridge.exposeInMainWorld('hololake', {
|
|||
list: () => ipcRenderer.invoke('server:list'),
|
||||
connect: (nodeId: string) => ipcRenderer.invoke('server:connect', nodeId),
|
||||
domainRegistry: () => ipcRenderer.invoke('server:domain-registry'),
|
||||
domainAccess: (domainId: string) => ipcRenderer.invoke('server:domain-access', domainId),
|
||||
domainAccess: (domainId: string, nodeType: 'local-terminal' | 'cloud-resident') =>
|
||||
ipcRenderer.invoke('server:domain-access', { domainId, nodeType }),
|
||||
session: (nodeId?: string) => ipcRenderer.invoke('server:session', nodeId),
|
||||
login: (input: { nodeId: string; username: string; password: string }) =>
|
||||
ipcRenderer.invoke('server:login', input),
|
||||
|
|
|
|||
Loading…
Reference in a new issue