diff --git a/ui-service/src/policy-engine/import-export.ts b/ui-service/src/policy-engine/import-export.ts index 546b42ebc6..097457bc5a 100644 --- a/ui-service/src/policy-engine/import-export.ts +++ b/ui-service/src/policy-engine/import-export.ts @@ -23,8 +23,8 @@ importExportAPI.get('/:policyId/export/file', async (req: AuthenticatedRequest, res.setHeader('Content-disposition', `attachment; filename=${policy.name}`); res.setHeader('Content-type', 'application/zip'); arcStream.pipe(res); - } catch(e) { - res.status(500).send({code: 500, message: e.message}); + } catch (e) { + res.status(500).send({ code: 500, message: e.message }); } }); @@ -101,12 +101,9 @@ importExportAPI.post('/import/message/preview', async (req: AuthenticatedRequest if (!zip) { throw new Error('file in body is empty'); } - - const guardians = new Guardians(); + const policyToImport = await PolicyImportExportHelper.parseZipFile(zip); - const schemasIds = findAllEntities(policyToImport.policy.config, 'schema'); - // const schemas = await guardians.getSchemaPreview(schemasIds); - // res.status(200).json({ ...policyToImport, schemas }); + res.status(200).json(policyToImport); } catch (error) { res.status(500).json({ code: 500, message: error.message }); } diff --git a/vc-modules/src/helpers/hedera-mirror-node.helper.ts b/vc-modules/src/helpers/hedera-mirror-node.helper.ts index 5a457e9b7f..91741c9721 100644 --- a/vc-modules/src/helpers/hedera-mirror-node.helper.ts +++ b/vc-modules/src/helpers/hedera-mirror-node.helper.ts @@ -2,17 +2,21 @@ import axios from "axios"; import { HederaHelper, ISubmitModelMessage } from ".."; import { IPolicySubmitMessage } from "../interfaces/policy-submit-message.interface"; import { ISchemaSubmitMessage } from "../interfaces/schema-submit-message.interface"; +import { timeout } from "./utils"; /** * Hedera mirror node helper */ export class HederaMirrorNodeHelper { + public static MAX_TIMEOUT: number = 60000; + /** * Return message by timestamp (messageId) * @param {string} timeStamp Message identifier * * @returns {any} - Message */ + @timeout(HederaMirrorNodeHelper.MAX_TIMEOUT) public static async getTopicMessage(timeStamp: string): Promise<{ timeStamp: string, topicId: string, @@ -31,6 +35,7 @@ export class HederaMirrorNodeHelper { * @param timeStamp Message identifier * @returns Message */ + @timeout(HederaMirrorNodeHelper.MAX_TIMEOUT) public static async getSchemaTopicMessage(timeStamp: string): Promise<{ timeStamp: string, topicId: string, @@ -66,6 +71,7 @@ export class HederaMirrorNodeHelper { * @param timeStamp Message identifier * @returns Message */ + @timeout(HederaMirrorNodeHelper.MAX_TIMEOUT) public static async getPolicyTopicMessage(timeStamp: string): Promise<{ timeStamp: string, topicId: string, @@ -116,7 +122,7 @@ export class HederaMirrorNodeHelper { * @param message Message * @returns Validation flag */ - private static validateBasicMessageFields (message: ISubmitModelMessage): boolean { + private static validateBasicMessageFields(message: ISubmitModelMessage): boolean { if (!message.name) { return false; } @@ -142,7 +148,7 @@ export class HederaMirrorNodeHelper { * @param message Policy submit message * @returns Validation flag */ - private static validatePolicyMessageFields (message : IPolicySubmitMessage): boolean { + private static validatePolicyMessageFields(message: IPolicySubmitMessage): boolean { if (!this.validateBasicMessageFields(message)) { return false; } @@ -172,7 +178,7 @@ export class HederaMirrorNodeHelper { * @param message Schema submit message * @returns Validation flag */ - private static validateSchemaMessageFields (message : ISchemaSubmitMessage): boolean { + private static validateSchemaMessageFields(message: ISchemaSubmitMessage): boolean { if (!this.validateBasicMessageFields(message)) { return false; } diff --git a/vc-modules/src/helpers/hedera-vc-helper.ts b/vc-modules/src/helpers/hedera-vc-helper.ts index 5031e712e9..cf26d267e1 100644 --- a/vc-modules/src/helpers/hedera-vc-helper.ts +++ b/vc-modules/src/helpers/hedera-vc-helper.ts @@ -230,7 +230,7 @@ export class VCHelper { * * @returns {boolean} - is verified */ - public async verifyVC(vcDocument: HcsVcDocument | any) { + public async verifyVC(vcDocument: HcsVcDocument | any): Promise { let vc: any; if (vcDocument && typeof vcDocument.toJsonTree === 'function') { vc = vcDocument.toJsonTree();