fix(coreflow): Fix Coreflow identity lookup and response shape; improve API client tests and bump dependencies

This commit is contained in:
2025-08-18 21:11:28 +00:00
parent 23c9e3f678
commit af7fcf6c2e
7 changed files with 456 additions and 217 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@serve.zone/cloudly',
version: '5.0.4',
version: '5.0.5',
description: 'A comprehensive tool for managing containerized applications across multiple cloud providers using Docker Swarmkit, featuring web, CLI, and API interfaces.'
}

View File

@@ -16,24 +16,23 @@ export class CloudlyCoreflowManager {
this.typedRouter.addTypedHandler<plugins.servezoneInterfaces.requests.identity.IRequest_Any_Cloudly_CoreflowManager_GetIdentityByToken>(
new plugins.typedrequest.TypedHandler('getIdentityByToken', async (requestData) => {
// Use getInstance with $elemMatch for querying nested arrays
const user = await this.cloudlyRef.authManager.CUser.getInstance({
data: {
tokens: [
{
token: requestData.token,
},
], // find the proper user here.
} as any,
tokens: {
$elemMatch: { token: requestData.token },
},
},
});
if (!user) {
throw new plugins.typedrequest.TypedResponseError(
'The supplied token is not valid. No matching user found.',
'The supplied token is not valid. No matching user found.'
);
}
if (user.data.type !== 'machine') {
throw new plugins.typedrequest.TypedResponseError(
'The supplied token is not valid. The user is not a machine.',
'The supplied token is not valid. The user is not a machine.'
);
}
let cluster: Cluster;
@@ -61,7 +60,7 @@ export class CloudlyCoreflowManager {
}),
},
};
}),
})
);
// lets enable the getting of cluster configs
@@ -76,10 +75,10 @@ export class CloudlyCoreflowManager {
console.log('got cluster config and sending it back to coreflow');
return {
configData: await cluster.createSavableObject(),
deploymentDirectives: [],
services: [],
};
},
),
}
)
);
// lets enable getting of certificates
@@ -89,14 +88,14 @@ export class CloudlyCoreflowManager {
async (dataArg) => {
console.log(`incoming API request for certificate ${dataArg.domainName}`);
const cert = await this.cloudlyRef.letsencryptConnector.getCertificateForDomain(
dataArg.domainName,
dataArg.domainName
);
console.log(`got certificate ready for reponse ${dataArg.domainName}`);
return {
certificate: await cert.createSavableObject(),
};
},
),
}
)
);
}
}