fix(coreflow): Fix Coreflow identity lookup and response shape; improve API client tests and bump dependencies
This commit is contained in:
		| @@ -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.' | ||||
| } | ||||
|   | ||||
| @@ -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(), | ||||
|           }; | ||||
|         }, | ||||
|       ), | ||||
|         } | ||||
|       ) | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user