From 48ef25db1e5c3b63d694b84653f2a5935960f1ed Mon Sep 17 00:00:00 2001 From: annelein Date: Mon, 14 Feb 2022 14:12:39 +0100 Subject: [PATCH] refactor: pr comments Signed-off-by: annelein --- packages/core/src/transport/HttpOutboundTransport.ts | 4 ++-- packages/core/src/utils/{ValidJWEStucture.ts => JWE.ts} | 0 .../__tests__/{ValidJWEStructure.test.ts => JWE.test.ts} | 6 +++--- packages/core/src/utils/index.ts | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) rename packages/core/src/utils/{ValidJWEStucture.ts => JWE.ts} (100%) rename packages/core/src/utils/__tests__/{ValidJWEStructure.test.ts => JWE.test.ts} (84%) diff --git a/packages/core/src/transport/HttpOutboundTransport.ts b/packages/core/src/transport/HttpOutboundTransport.ts index 570f8be395..006731aa70 100644 --- a/packages/core/src/transport/HttpOutboundTransport.ts +++ b/packages/core/src/transport/HttpOutboundTransport.ts @@ -8,7 +8,7 @@ import { AbortController } from 'abort-controller' import { AgentConfig } from '../agent/AgentConfig' import { AriesFrameworkError } from '../error/AriesFrameworkError' -import { validJWEStucture } from '../utils/ValidJWEStucture' +import { isValidJweStucture } from '../utils' export class HttpOutboundTransport implements OutboundTransport { private agent!: Agent @@ -77,7 +77,7 @@ export class HttpOutboundTransport implements OutboundTransport { this.logger.debug(`Response received`, { responseMessage, status: response.status }) try { - if (!validJWEStucture(responseMessage)) { + if (!isValidJweStucture(responseMessage)) { throw new Error( `Received a response from the other agent but the structure of the incoming message is not a DIDComm message: ${responseMessage}` ) diff --git a/packages/core/src/utils/ValidJWEStucture.ts b/packages/core/src/utils/JWE.ts similarity index 100% rename from packages/core/src/utils/ValidJWEStucture.ts rename to packages/core/src/utils/JWE.ts diff --git a/packages/core/src/utils/__tests__/ValidJWEStructure.test.ts b/packages/core/src/utils/__tests__/JWE.test.ts similarity index 84% rename from packages/core/src/utils/__tests__/ValidJWEStructure.test.ts rename to packages/core/src/utils/__tests__/JWE.test.ts index 96546802be..65bc4ecd07 100644 --- a/packages/core/src/utils/__tests__/ValidJWEStructure.test.ts +++ b/packages/core/src/utils/__tests__/JWE.test.ts @@ -1,9 +1,9 @@ -import { validJWEStucture } from '../ValidJWEStucture' +import { isValidJweStucture } from '../JWE' describe('ValidJWEStructure', () => { test('throws error when the response message has an invalid JWE structure', async () => { const responseMessage = 'invalid JWE structure' - await expect(validJWEStucture(responseMessage)).toBeFalsy() + await expect(isValidJweStucture(responseMessage)).toBeFalsy() }) test('valid JWE structure', async () => { @@ -14,6 +14,6 @@ describe('ValidJWEStructure', () => { ciphertext: 'mwRMpVg9wkF4rIZcBeWLcc0fWhs=', tag: '0yW0Lx8-vWevj3if91R06g==', } - await expect(validJWEStucture(responseMessage)).toBeTruthy() + await expect(isValidJweStucture(responseMessage)).toBeTruthy() }) }) diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts index 86cc9445f5..1a92d10e30 100644 --- a/packages/core/src/utils/index.ts +++ b/packages/core/src/utils/index.ts @@ -4,3 +4,4 @@ export * from './JsonTransformer' export * from './MultiBaseEncoder' export * from './buffer' export * from './MultiHashEncoder' +export * from './JWE'